UNPKG

@hank.chat/types

Version:
1,583 lines (1,571 loc) 46.8 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/plugin/metadata.ts var metadata_exports = {}; __export(metadata_exports, { Metadata: () => Metadata }); module.exports = __toCommonJS(metadata_exports); // node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js function varint64read() { let lowBits = 0; let highBits = 0; for (let shift = 0; shift < 28; shift += 7) { let b = this.buf[this.pos++]; lowBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } let middleByte = this.buf[this.pos++]; lowBits |= (middleByte & 15) << 28; highBits = (middleByte & 112) >> 4; if ((middleByte & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } for (let shift = 3; shift <= 31; shift += 7) { let b = this.buf[this.pos++]; highBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } throw new Error("invalid varint"); } function varint64write(lo, hi, bytes) { for (let i = 0; i < 28; i = i + 7) { const shift = lo >>> i; const hasNext = !(shift >>> 7 == 0 && hi == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } const splitBits = lo >>> 28 & 15 | (hi & 7) << 4; const hasMoreBits = !(hi >> 3 == 0); bytes.push((hasMoreBits ? splitBits | 128 : splitBits) & 255); if (!hasMoreBits) { return; } for (let i = 3; i < 31; i = i + 7) { const shift = hi >>> i; const hasNext = !(shift >>> 7 == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } bytes.push(hi >>> 31 & 1); } var TWO_PWR_32_DBL = 4294967296; function int64FromString(dec) { const minus = dec[0] === "-"; if (minus) { dec = dec.slice(1); } const base = 1e6; let lowBits = 0; let highBits = 0; function add1e6digit(begin, end) { const digit1e6 = Number(dec.slice(begin, end)); highBits *= base; lowBits = lowBits * base + digit1e6; if (lowBits >= TWO_PWR_32_DBL) { highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0); lowBits = lowBits % TWO_PWR_32_DBL; } } add1e6digit(-24, -18); add1e6digit(-18, -12); add1e6digit(-12, -6); add1e6digit(-6); return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits); } function int64ToString(lo, hi) { let bits = newBits(lo, hi); const negative = bits.hi & 2147483648; if (negative) { bits = negate(bits.lo, bits.hi); } const result = uInt64ToString(bits.lo, bits.hi); return negative ? "-" + result : result; } function uInt64ToString(lo, hi) { ({ lo, hi } = toUnsigned(lo, hi)); if (hi <= 2097151) { return String(TWO_PWR_32_DBL * hi + lo); } const low = lo & 16777215; const mid = (lo >>> 24 | hi << 8) & 16777215; const high = hi >> 16 & 65535; let digitA = low + mid * 6777216 + high * 6710656; let digitB = mid + high * 8147497; let digitC = high * 2; const base = 1e7; if (digitA >= base) { digitB += Math.floor(digitA / base); digitA %= base; } if (digitB >= base) { digitC += Math.floor(digitB / base); digitB %= base; } return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) + decimalFrom1e7WithLeadingZeros(digitA); } function toUnsigned(lo, hi) { return { lo: lo >>> 0, hi: hi >>> 0 }; } function newBits(lo, hi) { return { lo: lo | 0, hi: hi | 0 }; } function negate(lowBits, highBits) { highBits = ~highBits; if (lowBits) { lowBits = ~lowBits + 1; } else { highBits += 1; } return newBits(lowBits, highBits); } var decimalFrom1e7WithLeadingZeros = (digit1e7) => { const partial = String(digit1e7); return "0000000".slice(partial.length) + partial; }; function varint32write(value, bytes) { if (value >= 0) { while (value > 127) { bytes.push(value & 127 | 128); value = value >>> 7; } bytes.push(value); } else { for (let i = 0; i < 9; i++) { bytes.push(value & 127 | 128); value = value >> 7; } bytes.push(1); } } function varint32read() { let b = this.buf[this.pos++]; let result = b & 127; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 7; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 14; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 21; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 15) << 28; for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++) b = this.buf[this.pos++]; if ((b & 128) != 0) throw new Error("invalid varint"); this.assertBounds(); return result >>> 0; } // node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js var protoInt64 = /* @__PURE__ */ makeInt64Support(); function makeInt64Support() { const dv = new DataView(new ArrayBuffer(8)); const ok = typeof BigInt === "function" && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function" && (typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1"); if (ok) { const MIN = BigInt("-9223372036854775808"), MAX = BigInt("9223372036854775807"), UMIN = BigInt("0"), UMAX = BigInt("18446744073709551615"); return { zero: BigInt(0), supported: true, parse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > MAX || bi < MIN) { throw new Error(`invalid int64: ${value}`); } return bi; }, uParse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > UMAX || bi < UMIN) { throw new Error(`invalid uint64: ${value}`); } return bi; }, enc(value) { dv.setBigInt64(0, this.parse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, uEnc(value) { dv.setBigInt64(0, this.uParse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, dec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigInt64(0, true); }, uDec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigUint64(0, true); } }; } return { zero: "0", supported: false, parse(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return value; }, uParse(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return value; }, enc(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return int64FromString(value); }, uEnc(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return int64FromString(value); }, dec(lo, hi) { return int64ToString(lo, hi); }, uDec(lo, hi) { return uInt64ToString(lo, hi); } }; } function assertInt64String(value) { if (!/^-?[0-9]+$/.test(value)) { throw new Error("invalid int64: " + value); } } function assertUInt64String(value) { if (!/^[0-9]+$/.test(value)) { throw new Error("invalid uint64: " + value); } } // node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js var symbol = Symbol.for("@bufbuild/protobuf/text-encoding"); function getTextEncoding() { if (globalThis[symbol] == void 0) { const te = new globalThis.TextEncoder(); const td = new globalThis.TextDecoder(); globalThis[symbol] = { encodeUtf8(text) { return te.encode(text); }, decodeUtf8(bytes) { return td.decode(bytes); }, checkUtf8(text) { try { encodeURIComponent(text); return true; } catch (e) { return false; } } }; } return globalThis[symbol]; } // node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js var WireType; (function(WireType2) { WireType2[WireType2["Varint"] = 0] = "Varint"; WireType2[WireType2["Bit64"] = 1] = "Bit64"; WireType2[WireType2["LengthDelimited"] = 2] = "LengthDelimited"; WireType2[WireType2["StartGroup"] = 3] = "StartGroup"; WireType2[WireType2["EndGroup"] = 4] = "EndGroup"; WireType2[WireType2["Bit32"] = 5] = "Bit32"; })(WireType || (WireType = {})); var FLOAT32_MAX = 34028234663852886e22; var FLOAT32_MIN = -34028234663852886e22; var UINT32_MAX = 4294967295; var INT32_MAX = 2147483647; var INT32_MIN = -2147483648; var BinaryWriter = class { constructor(encodeUtf8 = getTextEncoding().encodeUtf8) { this.encodeUtf8 = encodeUtf8; this.stack = []; this.chunks = []; this.buf = []; } /** * Return all bytes written and reset this writer. */ finish() { this.chunks.push(new Uint8Array(this.buf)); let len = 0; for (let i = 0; i < this.chunks.length; i++) len += this.chunks[i].length; let bytes = new Uint8Array(len); let offset = 0; for (let i = 0; i < this.chunks.length; i++) { bytes.set(this.chunks[i], offset); offset += this.chunks[i].length; } this.chunks = []; return bytes; } /** * Start a new fork for length-delimited data like a message * or a packed repeated field. * * Must be joined later with `join()`. */ fork() { this.stack.push({ chunks: this.chunks, buf: this.buf }); this.chunks = []; this.buf = []; return this; } /** * Join the last fork. Write its length and bytes, then * return to the previous state. */ join() { let chunk = this.finish(); let prev = this.stack.pop(); if (!prev) throw new Error("invalid state, fork stack empty"); this.chunks = prev.chunks; this.buf = prev.buf; this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Writes a tag (field number and wire type). * * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`. * * Generated code should compute the tag ahead of time and call `uint32()`. */ tag(fieldNo, type) { return this.uint32((fieldNo << 3 | type) >>> 0); } /** * Write a chunk of raw bytes. */ raw(chunk) { if (this.buf.length) { this.chunks.push(new Uint8Array(this.buf)); this.buf = []; } this.chunks.push(chunk); return this; } /** * Write a `uint32` value, an unsigned 32 bit varint. */ uint32(value) { assertUInt32(value); while (value > 127) { this.buf.push(value & 127 | 128); value = value >>> 7; } this.buf.push(value); return this; } /** * Write a `int32` value, a signed 32 bit varint. */ int32(value) { assertInt32(value); varint32write(value, this.buf); return this; } /** * Write a `bool` value, a variant. */ bool(value) { this.buf.push(value ? 1 : 0); return this; } /** * Write a `bytes` value, length-delimited arbitrary data. */ bytes(value) { this.uint32(value.byteLength); return this.raw(value); } /** * Write a `string` value, length-delimited data converted to UTF-8 text. */ string(value) { let chunk = this.encodeUtf8(value); this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Write a `float` value, 32-bit floating point number. */ float(value) { assertFloat32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setFloat32(0, value, true); return this.raw(chunk); } /** * Write a `double` value, a 64-bit floating point number. */ double(value) { let chunk = new Uint8Array(8); new DataView(chunk.buffer).setFloat64(0, value, true); return this.raw(chunk); } /** * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer. */ fixed32(value) { assertUInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setUint32(0, value, true); return this.raw(chunk); } /** * Write a `sfixed32` value, a signed, fixed-length 32-bit integer. */ sfixed32(value) { assertInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setInt32(0, value, true); return this.raw(chunk); } /** * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint. */ sint32(value) { assertInt32(value); value = (value << 1 ^ value >> 31) >>> 0; varint32write(value, this.buf); return this; } /** * Write a `fixed64` value, a signed, fixed-length 64-bit integer. */ sfixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.enc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer. */ fixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.uEnc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `int64` value, a signed 64-bit varint. */ int64(value) { let tc = protoInt64.enc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } /** * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint. */ sint64(value) { let tc = protoInt64.enc(value), sign = tc.hi >> 31, lo = tc.lo << 1 ^ sign, hi = (tc.hi << 1 | tc.lo >>> 31) ^ sign; varint64write(lo, hi, this.buf); return this; } /** * Write a `uint64` value, an unsigned 64-bit varint. */ uint64(value) { let tc = protoInt64.uEnc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } }; var BinaryReader = class { constructor(buf, decodeUtf8 = getTextEncoding().decodeUtf8) { this.decodeUtf8 = decodeUtf8; this.varint64 = varint64read; this.uint32 = varint32read; this.buf = buf; this.len = buf.length; this.pos = 0; this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); } /** * Reads a tag - field number and wire type. */ tag() { let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7; if (fieldNo <= 0 || wireType < 0 || wireType > 5) throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType); return [fieldNo, wireType]; } /** * Skip one element and return the skipped data. * * When skipping StartGroup, provide the tags field number to check for * matching field number in the EndGroup tag. */ skip(wireType, fieldNo) { let start = this.pos; switch (wireType) { case WireType.Varint: while (this.buf[this.pos++] & 128) { } break; // eslint-disable-next-line // @ts-expect-error TS7029: Fallthrough case in switch case WireType.Bit64: this.pos += 4; // eslint-disable-next-line no-fallthrough case WireType.Bit32: this.pos += 4; break; case WireType.LengthDelimited: let len = this.uint32(); this.pos += len; break; case WireType.StartGroup: for (; ; ) { const [fn, wt] = this.tag(); if (wt === WireType.EndGroup) { if (fieldNo !== void 0 && fn !== fieldNo) { throw new Error("invalid end group tag"); } break; } this.skip(wt, fn); } break; default: throw new Error("cant skip wire type " + wireType); } this.assertBounds(); return this.buf.subarray(start, this.pos); } /** * Throws error if position in byte array is out of range. */ assertBounds() { if (this.pos > this.len) throw new RangeError("premature EOF"); } /** * Read a `int32` field, a signed 32 bit varint. */ int32() { return this.uint32() | 0; } /** * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint. */ sint32() { let zze = this.uint32(); return zze >>> 1 ^ -(zze & 1); } /** * Read a `int64` field, a signed 64-bit varint. */ int64() { return protoInt64.dec(...this.varint64()); } /** * Read a `uint64` field, an unsigned 64-bit varint. */ uint64() { return protoInt64.uDec(...this.varint64()); } /** * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint. */ sint64() { let [lo, hi] = this.varint64(); let s = -(lo & 1); lo = (lo >>> 1 | (hi & 1) << 31) ^ s; hi = hi >>> 1 ^ s; return protoInt64.dec(lo, hi); } /** * Read a `bool` field, a variant. */ bool() { let [lo, hi] = this.varint64(); return lo !== 0 || hi !== 0; } /** * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer. */ fixed32() { return this.view.getUint32((this.pos += 4) - 4, true); } /** * Read a `sfixed32` field, a signed, fixed-length 32-bit integer. */ sfixed32() { return this.view.getInt32((this.pos += 4) - 4, true); } /** * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer. */ fixed64() { return protoInt64.uDec(this.sfixed32(), this.sfixed32()); } /** * Read a `fixed64` field, a signed, fixed-length 64-bit integer. */ sfixed64() { return protoInt64.dec(this.sfixed32(), this.sfixed32()); } /** * Read a `float` field, 32-bit floating point number. */ float() { return this.view.getFloat32((this.pos += 4) - 4, true); } /** * Read a `double` field, a 64-bit floating point number. */ double() { return this.view.getFloat64((this.pos += 8) - 8, true); } /** * Read a `bytes` field, length-delimited arbitrary data. */ bytes() { let len = this.uint32(), start = this.pos; this.pos += len; this.assertBounds(); return this.buf.subarray(start, start + len); } /** * Read a `string` field, length-delimited data converted to UTF-8 text. */ string() { return this.decodeUtf8(this.bytes()); } }; function assertInt32(arg) { if (typeof arg == "string") { arg = Number(arg); } else if (typeof arg != "number") { throw new Error("invalid int32: " + typeof arg); } if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN) throw new Error("invalid int32: " + arg); } function assertUInt32(arg) { if (typeof arg == "string") { arg = Number(arg); } else if (typeof arg != "number") { throw new Error("invalid uint32: " + typeof arg); } if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0) throw new Error("invalid uint32: " + arg); } function assertFloat32(arg) { if (typeof arg == "string") { const o = arg; arg = Number(arg); if (isNaN(arg) && o !== "NaN") { throw new Error("invalid float32: " + o); } } else if (typeof arg != "number") { throw new Error("invalid float32: " + typeof arg); } if (Number.isFinite(arg) && (arg > FLOAT32_MAX || arg < FLOAT32_MIN)) throw new Error("invalid float32: " + arg); } // src/access_check/access_check_operator.ts function accessCheckOperatorFromJSON(object) { switch (object) { case 0: case "AND": return 0 /* AND */; case 1: case "OR": return 1 /* OR */; case -1: case "UNRECOGNIZED": default: return -1 /* UNRECOGNIZED */; } } function accessCheckOperatorToJSON(object) { switch (object) { case 0 /* AND */: return "AND"; case 1 /* OR */: return "OR"; case -1 /* UNRECOGNIZED */: default: return "UNRECOGNIZED"; } } // src/access_check/access_check.ts function createBaseAccessCheck() { return { kind: void 0 }; } var AccessCheck = { encode(message, writer = new BinaryWriter()) { switch (message.kind?.$case) { case "chain": AccessCheckChain.encode(message.kind.value, writer.uint32(10).fork()).join(); break; case "user": writer.uint32(18).string(message.kind.value); break; case "role": writer.uint32(26).string(message.kind.value); break; } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseAccessCheck(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.kind = { $case: "chain", value: AccessCheckChain.decode(reader, reader.uint32()) }; continue; case 2: if (tag !== 18) { break; } message.kind = { $case: "user", value: reader.string() }; continue; case 3: if (tag !== 26) { break; } message.kind = { $case: "role", value: reader.string() }; continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { kind: isSet(object.chain) ? { $case: "chain", value: AccessCheckChain.fromJSON(object.chain) } : isSet(object.user) ? { $case: "user", value: globalThis.String(object.user) } : isSet(object.role) ? { $case: "role", value: globalThis.String(object.role) } : void 0 }; }, toJSON(message) { const obj = {}; if (message.kind?.$case === "chain") { obj.chain = AccessCheckChain.toJSON(message.kind.value); } if (message.kind?.$case === "user") { obj.user = message.kind.value; } if (message.kind?.$case === "role") { obj.role = message.kind.value; } return obj; }, create(base) { return AccessCheck.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseAccessCheck(); if (object.kind?.$case === "chain" && object.kind?.value !== void 0 && object.kind?.value !== null) { message.kind = { $case: "chain", value: AccessCheckChain.fromPartial(object.kind.value) }; } if (object.kind?.$case === "user" && object.kind?.value !== void 0 && object.kind?.value !== null) { message.kind = { $case: "user", value: object.kind.value }; } if (object.kind?.$case === "role" && object.kind?.value !== void 0 && object.kind?.value !== null) { message.kind = { $case: "role", value: object.kind.value }; } return message; } }; function createBaseAccessCheckChain() { return { operator: 0, checks: [] }; } var AccessCheckChain = { encode(message, writer = new BinaryWriter()) { if (message.operator !== 0) { writer.uint32(8).int32(message.operator); } for (const v of message.checks) { AccessCheck.encode(v, writer.uint32(18).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseAccessCheckChain(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 8) { break; } message.operator = reader.int32(); continue; case 2: if (tag !== 18) { break; } message.checks.push(AccessCheck.decode(reader, reader.uint32())); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { operator: isSet(object.operator) ? accessCheckOperatorFromJSON(object.operator) : 0, checks: globalThis.Array.isArray(object?.checks) ? object.checks.map((e) => AccessCheck.fromJSON(e)) : [] }; }, toJSON(message) { const obj = {}; if (message.operator !== 0) { obj.operator = accessCheckOperatorToJSON(message.operator); } if (message.checks?.length) { obj.checks = message.checks.map((e) => AccessCheck.toJSON(e)); } return obj; }, create(base) { return AccessCheckChain.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseAccessCheckChain(); message.operator = object.operator ?? 0; message.checks = object.checks?.map((e) => AccessCheck.fromPartial(e)) || []; return message; } }; function isSet(value) { return value !== null && value !== void 0; } // src/plugin/argument.ts function createBaseArgument() { return { name: "", description: "", defaultValue: void 0, required: false, short: void 0, long: void 0 }; } var Argument = { encode(message, writer = new BinaryWriter()) { if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.description !== "") { writer.uint32(18).string(message.description); } if (message.defaultValue !== void 0) { writer.uint32(26).string(message.defaultValue); } if (message.required !== false) { writer.uint32(32).bool(message.required); } if (message.short !== void 0) { writer.uint32(42).string(message.short); } if (message.long !== void 0) { writer.uint32(50).string(message.long); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseArgument(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.name = reader.string(); continue; case 2: if (tag !== 18) { break; } message.description = reader.string(); continue; case 3: if (tag !== 26) { break; } message.defaultValue = reader.string(); continue; case 4: if (tag !== 32) { break; } message.required = reader.bool(); continue; case 5: if (tag !== 42) { break; } message.short = reader.string(); continue; case 6: if (tag !== 50) { break; } message.long = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { name: isSet2(object.name) ? globalThis.String(object.name) : "", description: isSet2(object.description) ? globalThis.String(object.description) : "", defaultValue: isSet2(object.defaultValue) ? globalThis.String(object.defaultValue) : void 0, required: isSet2(object.required) ? globalThis.Boolean(object.required) : false, short: isSet2(object.short) ? globalThis.String(object.short) : void 0, long: isSet2(object.long) ? globalThis.String(object.long) : void 0 }; }, toJSON(message) { const obj = {}; if (message.name !== "") { obj.name = message.name; } if (message.description !== "") { obj.description = message.description; } if (message.defaultValue !== void 0) { obj.defaultValue = message.defaultValue; } if (message.required !== false) { obj.required = message.required; } if (message.short !== void 0) { obj.short = message.short; } if (message.long !== void 0) { obj.long = message.long; } return obj; }, create(base) { return Argument.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseArgument(); message.name = object.name ?? ""; message.description = object.description ?? ""; message.defaultValue = object.defaultValue ?? void 0; message.required = object.required ?? false; message.short = object.short ?? void 0; message.long = object.long ?? void 0; return message; } }; function isSet2(value) { return value !== null && value !== void 0; } // src/plugin/command.ts function createBaseCommand() { return { name: "", description: "", author: void 0, version: void 0, aliases: [], arguments: [], subcommands: [], accessChecks: void 0, argRequiredElseHelp: false }; } var Command = { encode(message, writer = new BinaryWriter()) { if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.description !== "") { writer.uint32(18).string(message.description); } if (message.author !== void 0) { writer.uint32(26).string(message.author); } if (message.version !== void 0) { writer.uint32(34).string(message.version); } for (const v of message.aliases) { writer.uint32(42).string(v); } for (const v of message.arguments) { Argument.encode(v, writer.uint32(50).fork()).join(); } for (const v of message.subcommands) { Command.encode(v, writer.uint32(58).fork()).join(); } if (message.accessChecks !== void 0) { AccessCheckChain.encode(message.accessChecks, writer.uint32(66).fork()).join(); } if (message.argRequiredElseHelp !== false) { writer.uint32(72).bool(message.argRequiredElseHelp); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseCommand(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.name = reader.string(); continue; case 2: if (tag !== 18) { break; } message.description = reader.string(); continue; case 3: if (tag !== 26) { break; } message.author = reader.string(); continue; case 4: if (tag !== 34) { break; } message.version = reader.string(); continue; case 5: if (tag !== 42) { break; } message.aliases.push(reader.string()); continue; case 6: if (tag !== 50) { break; } message.arguments.push(Argument.decode(reader, reader.uint32())); continue; case 7: if (tag !== 58) { break; } message.subcommands.push(Command.decode(reader, reader.uint32())); continue; case 8: if (tag !== 66) { break; } message.accessChecks = AccessCheckChain.decode(reader, reader.uint32()); continue; case 9: if (tag !== 72) { break; } message.argRequiredElseHelp = reader.bool(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { name: isSet3(object.name) ? globalThis.String(object.name) : "", description: isSet3(object.description) ? globalThis.String(object.description) : "", author: isSet3(object.author) ? globalThis.String(object.author) : void 0, version: isSet3(object.version) ? globalThis.String(object.version) : void 0, aliases: globalThis.Array.isArray(object?.aliases) ? object.aliases.map((e) => globalThis.String(e)) : [], arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e) => Argument.fromJSON(e)) : [], subcommands: globalThis.Array.isArray(object?.subcommands) ? object.subcommands.map((e) => Command.fromJSON(e)) : [], accessChecks: isSet3(object.accessChecks) ? AccessCheckChain.fromJSON(object.accessChecks) : void 0, argRequiredElseHelp: isSet3(object.argRequiredElseHelp) ? globalThis.Boolean(object.argRequiredElseHelp) : false }; }, toJSON(message) { const obj = {}; if (message.name !== "") { obj.name = message.name; } if (message.description !== "") { obj.description = message.description; } if (message.author !== void 0) { obj.author = message.author; } if (message.version !== void 0) { obj.version = message.version; } if (message.aliases?.length) { obj.aliases = message.aliases; } if (message.arguments?.length) { obj.arguments = message.arguments.map((e) => Argument.toJSON(e)); } if (message.subcommands?.length) { obj.subcommands = message.subcommands.map((e) => Command.toJSON(e)); } if (message.accessChecks !== void 0) { obj.accessChecks = AccessCheckChain.toJSON(message.accessChecks); } if (message.argRequiredElseHelp !== false) { obj.argRequiredElseHelp = message.argRequiredElseHelp; } return obj; }, create(base) { return Command.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseCommand(); message.name = object.name ?? ""; message.description = object.description ?? ""; message.author = object.author ?? void 0; message.version = object.version ?? void 0; message.aliases = object.aliases?.map((e) => e) || []; message.arguments = object.arguments?.map((e) => Argument.fromPartial(e)) || []; message.subcommands = object.subcommands?.map((e) => Command.fromPartial(e)) || []; message.accessChecks = object.accessChecks !== void 0 && object.accessChecks !== null ? AccessCheckChain.fromPartial(object.accessChecks) : void 0; message.argRequiredElseHelp = object.argRequiredElseHelp ?? false; return message; } }; function isSet3(value) { return value !== null && value !== void 0; } // src/plugin/escalated_privilege.ts function escalatedPrivilegeFromJSON(object) { switch (object) { case 0: case "ALL": return 0 /* ALL */; case 1: case "RELOAD_PLUGIN": return 1 /* RELOAD_PLUGIN */; case 2: case "LOAD_PLUGIN": return 2 /* LOAD_PLUGIN */; case 3: case "UNLOAD_PLUGIN": return 3 /* UNLOAD_PLUGIN */; case 4: case "INSTRUCT_PLUGIN": return 4 /* INSTRUCT_PLUGIN */; case -1: case "UNRECOGNIZED": default: return -1 /* UNRECOGNIZED */; } } function escalatedPrivilegeToJSON(object) { switch (object) { case 0 /* ALL */: return "ALL"; case 1 /* RELOAD_PLUGIN */: return "RELOAD_PLUGIN"; case 2 /* LOAD_PLUGIN */: return "LOAD_PLUGIN"; case 3 /* UNLOAD_PLUGIN */: return "UNLOAD_PLUGIN"; case 4 /* INSTRUCT_PLUGIN */: return "INSTRUCT_PLUGIN"; case -1 /* UNRECOGNIZED */: default: return "UNRECOGNIZED"; } } // src/plugin/metadata.ts function createBaseMetadata() { return { name: "", description: "", version: "", database: false, accessChecks: void 0, escalationKey: void 0, escalatedPrivileges: [], author: "", handlesCommands: false, handlesMessages: false, commandName: void 0, aliases: [], arguments: [], subcommands: [], allowedHosts: [], poolSize: void 0, argRequiredElseHelp: false }; } var Metadata = { encode(message, writer = new BinaryWriter()) { if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.description !== "") { writer.uint32(18).string(message.description); } if (message.version !== "") { writer.uint32(26).string(message.version); } if (message.database !== false) { writer.uint32(32).bool(message.database); } if (message.accessChecks !== void 0) { AccessCheckChain.encode(message.accessChecks, writer.uint32(42).fork()).join(); } if (message.escalationKey !== void 0) { writer.uint32(50).string(message.escalationKey); } writer.uint32(58).fork(); for (const v of message.escalatedPrivileges) { writer.int32(v); } writer.join(); if (message.author !== "") { writer.uint32(66).string(message.author); } if (message.handlesCommands !== false) { writer.uint32(72).bool(message.handlesCommands); } if (message.handlesMessages !== false) { writer.uint32(80).bool(message.handlesMessages); } if (message.commandName !== void 0) { writer.uint32(90).string(message.commandName); } for (const v of message.aliases) { writer.uint32(98).string(v); } for (const v of message.arguments) { Argument.encode(v, writer.uint32(106).fork()).join(); } for (const v of message.subcommands) { Command.encode(v, writer.uint32(114).fork()).join(); } for (const v of message.allowedHosts) { writer.uint32(122).string(v); } if (message.poolSize !== void 0) { writer.uint32(128).int32(message.poolSize); } if (message.argRequiredElseHelp !== false) { writer.uint32(136).bool(message.argRequiredElseHelp); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseMetadata(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.name = reader.string(); continue; case 2: if (tag !== 18) { break; } message.description = reader.string(); continue; case 3: if (tag !== 26) { break; } message.version = reader.string(); continue; case 4: if (tag !== 32) { break; } message.database = reader.bool(); continue; case 5: if (tag !== 42) { break; } message.accessChecks = AccessCheckChain.decode(reader, reader.uint32()); continue; case 6: if (tag !== 50) { break; } message.escalationKey = reader.string(); continue; case 7: if (tag === 56) { message.escalatedPrivileges.push(reader.int32()); continue; } if (tag === 58) { const end2 = reader.uint32() + reader.pos; while (reader.pos < end2) { message.escalatedPrivileges.push(reader.int32()); } continue; } break; case 8: if (tag !== 66) { break; } message.author = reader.string(); continue; case 9: if (tag !== 72) { break; } message.handlesCommands = reader.bool(); continue; case 10: if (tag !== 80) { break; } message.handlesMessages = reader.bool(); continue; case 11: if (tag !== 90) { break; } message.commandName = reader.string(); continue; case 12: if (tag !== 98) { break; } message.aliases.push(reader.string()); continue; case 13: if (tag !== 106) { break; } message.arguments.push(Argument.decode(reader, reader.uint32())); continue; case 14: if (tag !== 114) { break; } message.subcommands.push(Command.decode(reader, reader.uint32())); continue; case 15: if (tag !== 122) { break; } message.allowedHosts.push(reader.string()); continue; case 16: if (tag !== 128) { break; } message.poolSize = reader.int32(); continue; case 17: if (tag !== 136) { break; } message.argRequiredElseHelp = reader.bool(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { name: isSet4(object.name) ? globalThis.String(object.name) : "", description: isSet4(object.description) ? globalThis.String(object.description) : "", version: isSet4(object.version) ? globalThis.String(object.version) : "", database: isSet4(object.database) ? globalThis.Boolean(object.database) : false, accessChecks: isSet4(object.accessChecks) ? AccessCheckChain.fromJSON(object.accessChecks) : void 0, escalationKey: isSet4(object.escalationKey) ? globalThis.String(object.escalationKey) : void 0, escalatedPrivileges: globalThis.Array.isArray(object?.escalatedPrivileges) ? object.escalatedPrivileges.map((e) => escalatedPrivilegeFromJSON(e)) : [], author: isSet4(object.author) ? globalThis.String(object.author) : "", handlesCommands: isSet4(object.handlesCommands) ? globalThis.Boolean(object.handlesCommands) : false, handlesMessages: isSet4(object.handlesMessages) ? globalThis.Boolean(object.handlesMessages) : false, commandName: isSet4(object.commandName) ? globalThis.String(object.commandName) : void 0, aliases: globalThis.Array.isArray(object?.aliases) ? object.aliases.map((e) => globalThis.String(e)) : [], arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e) => Argument.fromJSON(e)) : [], subcommands: globalThis.Array.isArray(object?.subcommands) ? object.subcommands.map((e) => Command.fromJSON(e)) : [], allowedHosts: globalThis.Array.isArray(object?.allowedHosts) ? object.allowedHosts.map((e) => globalThis.String(e)) : [], poolSize: isSet4(object.poolSize) ? globalThis.Number(object.poolSize) : void 0, argRequiredElseHelp: isSet4(object.argRequiredElseHelp) ? globalThis.Boolean(object.argRequiredElseHelp) : false }; }, toJSON(message) { const obj = {}; if (message.name !== "") { obj.name = message.name; } if (message.description !== "") { obj.description = message.description; } if (message.version !== "") { obj.version = message.version; } if (message.database !== false) { obj.database = message.database; } if (message.accessChecks !== void 0) { obj.accessChecks = AccessCheckChain.toJSON(message.accessChecks); } if (message.escalationKey !== void 0) { obj.escalationKey = message.escalationKey; } if (message.escalatedPrivileges?.length) { obj.escalatedPrivileges = message.escalatedPrivileges.map((e) => escalatedPrivilegeToJSON(e)); } if (message.author !== "") { obj.author = message.author; } if (message.handlesCommands !== false) { obj.handlesCommands = message.handlesCommands; } if (message.handlesMessages !== false) { obj.handlesMessages = message.handlesMessages; } if (message.commandName !== void 0) { obj.commandName = message.commandName; } if (message.aliases?.length) { obj.aliases = message.aliases; } if (message.arguments?.length) { obj.arguments = message.arguments.map((e) => Argument.toJSON(e)); } if (message.subcommands?.length) { obj.subcommands = message.subcommands.map((e) => Command.toJSON(e)); } if (message.allowedHosts?.length) { obj.allowedHosts = message.allowedHosts; } if (message.poolSize !== void 0) { obj.poolSize = Math.round(message.poolSize); } if (message.argRequiredElseHelp !== false) { obj.argRequiredElseHelp = message.argRequiredElseHelp; } return obj; }, create(base) { return Metadata.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseMetadata(); message.name = object.name ?? ""; message.description = object.description ?? ""; message.version = object.version ?? ""; message.database = object.database ?? false; message.accessChecks = object.accessChecks !== void 0 && object.accessChecks !== null ? AccessCheckChain.fromPartial(object.accessChecks) : void 0; message.escalationKey = object.escalationKey ?? void 0; message.escalatedPrivileges = object.escalatedPrivileges?.map((e) => e) || []; message.author = object.author ?? ""; message.handlesCommands = object.handlesCommands ?? false; message.handlesMessages = object.handlesMessages ?? false; message.commandName = object.commandName ?? void 0; message.aliases = object.aliases?.map((e) => e) || []; message.arguments = object.arguments?.map((e) => Argument.fromPartial(e)) || []; message.subcommands = object.subcommands?.map((e) => Command.fromPartial(e)) || []; message.allowedHosts = object.allowedHosts?.map((e) => e) || []; message.poolSize = object.poolSize ?? void 0; message.argRequiredElseHelp = object.argRequiredElseHelp ?? false; return message; } }; function isSet4(value) { return value !== null && value !== void 0; } //# sourceMappingURL=metadata.js.map