@hank.chat/pdk
Version:
TypeScript PDK for Hank
1,536 lines (1,534 loc) • 169 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/@hank.chat/types/dist/index.js
var require_dist = __commonJS({
"node_modules/@hank.chat/types/dist/index.js"(exports, module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports2 = {};
__export2(src_exports2, {
AccessCheck: () => AccessCheck2,
AccessCheckChain: () => AccessCheckChain2,
AccessCheckOperator: () => AccessCheckOperator2,
Argument: () => Argument,
Channel: () => Channel,
ChannelKind: () => ChannelKind,
ChatCommandInput: () => ChatCommandInput2,
ChatCommandOutput: () => ChatCommandOutput,
ChatMessageInput: () => ChatMessageInput2,
ChatMessageOutput: () => ChatMessageOutput,
Command: () => Command,
CommandContext: () => CommandContext,
CommandContextArgument: () => CommandContextArgument,
CronInput: () => CronInput2,
CronJob: () => CronJob2,
CronOutput: () => CronOutput,
DatetimeInput: () => DatetimeInput2,
DatetimeOutput: () => DatetimeOutput2,
DbQueryInput: () => DbQueryInput2,
DbQueryOutput: () => DbQueryOutput2,
EscalatedPrivilege: () => EscalatedPrivilege,
GetMetadataInput: () => GetMetadataInput,
GetMetadataOutput: () => GetMetadataOutput2,
HandleChatCommandInput: () => HandleChatCommandInput,
HandleChatCommandOutput: () => HandleChatCommandOutput,
HankClientImpl: () => HankClientImpl2,
HankServiceName: () => HankServiceName,
InitializeInput: () => InitializeInput,
InitializeOutput: () => InitializeOutput,
InstallInput: () => InstallInput,
InstallOutput: () => InstallOutput,
InstructPluginInput: () => InstructPluginInput,
InstructPluginOutput: () => InstructPluginOutput,
Instruction: () => Instruction,
InstructionKind: () => InstructionKind,
LoadPluginInput: () => LoadPluginInput,
LoadPluginOutput: () => LoadPluginOutput,
Message: () => Message2,
Metadata: () => Metadata2,
OneShotInput: () => OneShotInput2,
OneShotJob: () => OneShotJob2,
OneShotOutput: () => OneShotOutput,
PluginClientImpl: () => PluginClientImpl,
PluginServiceName: () => PluginServiceName,
PreparedStatement: () => PreparedStatement2,
ReactInput: () => ReactInput2,
ReactOutput: () => ReactOutput,
Reaction: () => Reaction2,
ReloadPluginInput: () => ReloadPluginInput2,
ReloadPluginOutput: () => ReloadPluginOutput,
Results: () => Results2,
Role: () => Role,
ScheduledJobInput: () => ScheduledJobInput2,
ScheduledJobOutput: () => ScheduledJobOutput,
SendMessageInput: () => SendMessageInput2,
SendMessageOutput: () => SendMessageOutput,
ShutdownInput: () => ShutdownInput,
ShutdownOutput: () => ShutdownOutput,
Timestamp: () => Timestamp,
UnloadPluginInput: () => UnloadPluginInput,
UnloadPluginOutput: () => UnloadPluginOutput,
User: () => User,
accessCheckOperatorFromJSON: () => accessCheckOperatorFromJSON2,
accessCheckOperatorToJSON: () => accessCheckOperatorToJSON,
channelKindFromJSON: () => channelKindFromJSON,
channelKindToJSON: () => channelKindToJSON,
escalatedPrivilegeFromJSON: () => escalatedPrivilegeFromJSON,
escalatedPrivilegeToJSON: () => escalatedPrivilegeToJSON,
instructionKindFromJSON: () => instructionKindFromJSON,
instructionKindToJSON: () => instructionKindToJSON
});
module2.exports = __toCommonJS2(src_exports2);
var AccessCheckOperator2 = /* @__PURE__ */ ((AccessCheckOperator3) => {
AccessCheckOperator3[AccessCheckOperator3["AND"] = 0] = "AND";
AccessCheckOperator3[AccessCheckOperator3["OR"] = 1] = "OR";
AccessCheckOperator3[AccessCheckOperator3["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
return AccessCheckOperator3;
})(AccessCheckOperator2 || {});
function accessCheckOperatorFromJSON2(object) {
switch (object) {
case 0:
case "AND":
return 0;
case 1:
case "OR":
return 1;
case -1:
case "UNRECOGNIZED":
default:
return -1;
}
}
function accessCheckOperatorToJSON(object) {
switch (object) {
case 0:
return "AND";
case 1:
return "OR";
case -1:
default:
return "UNRECOGNIZED";
}
}
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 i2 = 0; i2 < 28; i2 = i2 + 7) {
const shift = lo >>> i2;
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 i2 = 3; i2 < 31; i2 = i2 + 7) {
const shift = hi >>> i2;
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 i2 = 0; i2 < 9; i2++) {
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;
}
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);
}
}
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];
}
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 i2 = 0; i2 < this.chunks.length; i2++)
len += this.chunks[i2].length;
let bytes = new Uint8Array(len);
let offset = 0;
for (let i2 = 0; i2 < this.chunks.length; i2++) {
bytes.set(this.chunks[i2], offset);
offset += this.chunks[i2].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 s2 = -(lo & 1);
lo = (lo >>> 1 | (hi & 1) << 31) ^ s2;
hi = hi >>> 1 ^ s2;
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);
}
function createBaseCommandContextArgument() {
return { name: "", value: "" };
}
var CommandContextArgument = {
encode(message, writer = new BinaryWriter()) {
if (message.name !== "") {
writer.uint32(10).string(message.name);
}
if (message.value !== "") {
writer.uint32(18).string(message.value);
}
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 = createBaseCommandContextArgument();
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.value = 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) : "",
value: isSet2(object.value) ? globalThis.String(object.value) : ""
};
},
toJSON(message) {
const obj = {};
if (message.name !== "") {
obj.name = message.name;
}
if (message.value !== "") {
obj.value = message.value;
}
return obj;
},
create(base) {
return CommandContextArgument.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseCommandContextArgument();
message.name = object.name ?? "";
message.value = object.value ?? "";
return message;
}
};
function isSet2(value) {
return value !== null && value !== void 0;
}
function createBaseHandleChatCommandOutput() {
return {};
}
var HandleChatCommandOutput = {
encode(_, writer = new BinaryWriter()) {
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 = createBaseHandleChatCommandOutput();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(_) {
return {};
},
toJSON(_) {
const obj = {};
return obj;
},
create(base) {
return HandleChatCommandOutput.fromPartial(base ?? {});
},
fromPartial(_) {
const message = createBaseHandleChatCommandOutput();
return message;
}
};
var ChannelKind = /* @__PURE__ */ ((ChannelKind3) => {
ChannelKind3[ChannelKind3["CHAT_ROOM"] = 0] = "CHAT_ROOM";
ChannelKind3[ChannelKind3["DIRECT_MESSAGE"] = 1] = "DIRECT_MESSAGE";
ChannelKind3[ChannelKind3["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
return ChannelKind3;
})(ChannelKind || {});
function channelKindFromJSON(object) {
switch (object) {
case 0:
case "CHAT_ROOM":
return 0;
case 1:
case "DIRECT_MESSAGE":
return 1;
case -1:
case "UNRECOGNIZED":
default:
return -1;
}
}
function channelKindToJSON(object) {
switch (object) {
case 0:
return "CHAT_ROOM";
case 1:
return "DIRECT_MESSAGE";
case -1:
default:
return "UNRECOGNIZED";
}
}
function createBaseChannel() {
return { kind: 0, id: "", name: "" };
}
var Channel = {
encode(message, writer = new BinaryWriter()) {
if (message.kind !== 0) {
writer.uint32(8).int32(message.kind);
}
if (message.id !== "") {
writer.uint32(18).string(message.id);
}
if (message.name !== "") {
writer.uint32(26).string(message.name);
}
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 = createBaseChannel();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.kind = reader.int32();
continue;
case 2:
if (tag !== 18) {
break;
}
message.id = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.name = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
kind: isSet22(object.kind) ? channelKindFromJSON(object.kind) : 0,
id: isSet22(object.id) ? globalThis.String(object.id) : "",
name: isSet22(object.name) ? globalThis.String(object.name) : ""
};
},
toJSON(message) {
const obj = {};
if (message.kind !== 0) {
obj.kind = channelKindToJSON(message.kind);
}
if (message.id !== "") {
obj.id = message.id;
}
if (message.name !== "") {
obj.name = message.name;
}
return obj;
},
create(base) {
return Channel.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseChannel();
message.kind = object.kind ?? 0;
message.id = object.id ?? "";
message.name = object.name ?? "";
return message;
}
};
function isSet22(value) {
return value !== null && value !== void 0;
}
function createBaseTimestamp() {
return { seconds: 0, nanos: 0 };
}
var Timestamp = {
encode(message, writer = new BinaryWriter()) {
if (message.seconds !== 0) {
writer.uint32(8).int64(message.seconds);
}
if (message.nanos !== 0) {
writer.uint32(16).int32(message.nanos);
}
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 = createBaseTimestamp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.seconds = longToNumber(reader.int64());
continue;
case 2:
if (tag !== 16) {
break;
}
message.nanos = reader.int32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
seconds: isSet3(object.seconds) ? globalThis.Number(object.seconds) : 0,
nanos: isSet3(object.nanos) ? globalThis.Number(object.nanos) : 0
};
},
toJSON(message) {
const obj = {};
if (message.seconds !== 0) {
obj.seconds = Math.round(message.seconds);
}
if (message.nanos !== 0) {
obj.nanos = Math.round(message.nanos);
}
return obj;
},
create(base) {
return Timestamp.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseTimestamp();
message.seconds = object.seconds ?? 0;
message.nanos = object.nanos ?? 0;
return message;
}
};
function longToNumber(int64) {
const num = globalThis.Number(int64.toString());
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
if (num < globalThis.Number.MIN_SAFE_INTEGER) {
throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
}
return num;
}
function isSet3(value) {
return value !== null && value !== void 0;
}
function createBaseRole() {
return { id: "", name: "" };
}
var Role = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.name !== "") {
writer.uint32(18).string(message.name);
}
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 = createBaseRole();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.name = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet4(object.id) ? globalThis.String(object.id) : "",
name: isSet4(object.name) ? globalThis.String(object.name) : ""
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.name !== "") {
obj.name = message.name;
}
return obj;
},
create(base) {
return Role.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRole();
message.id = object.id ?? "";
message.name = object.name ?? "";
return message;
}
};
function isSet4(value) {
return value !== null && value !== void 0;
}
function createBaseUser() {
return { id: "", name: "", displayName: "", roles: [] };
}
var User = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.name !== "") {
writer.uint32(18).string(message.name);
}
if (message.displayName !== "") {
writer.uint32(26).string(message.displayName);
}
for (const v of message.roles) {
Role.encode(v, writer.uint32(34).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 = createBaseUser();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.name = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.displayName = reader.string();
continue;
case 4:
if (tag !== 34) {
break;
}
message.roles.push(Role.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet5(object.id) ? globalThis.String(object.id) : "",
name: isSet5(object.name) ? globalThis.String(object.name) : "",
displayName: isSet5(object.displayName) ? globalThis.String(object.displayName) : "",
roles: globalThis.Array.isArray(object?.roles) ? object.roles.map((e) => Role.fromJSON(e)) : []
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.name !== "") {
obj.name = message.name;
}
if (message.displayName !== "") {
obj.displayName = message.displayName;
}
if (message.roles?.length) {
obj.roles = message.roles.map((e) => Role.toJSON(e));
}
return obj;
},
create(base) {
return User.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseUser();
message.id = object.id ?? "";
message.name = object.name ?? "";
message.displayName = object.displayName ?? "";
message.roles = object.roles?.map((e) => Role.fromPartial(e)) || [];
return message;
}
};
function isSet5(value) {
return value !== null && value !== void 0;
}
function createBaseMessage() {
return { id: void 0, timestamp: void 0, author: void 0, channel: void 0, content: "" };
}
var Message2 = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== void 0) {
writer.uint32(10).string(message.id);
}
if (message.timestamp !== void 0) {
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(18).fork()).join();
}
if (message.author !== void 0) {
User.encode(message.author, writer.uint32(26).fork()).join();
}
if (message.channel !== void 0) {
Channel.encode(message.channel, writer.uint32(34).fork()).join();
}
if (message.content !== "") {
writer.uint32(42).string(message.content);
}
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 = createBaseMessage();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.author = User.decode(reader, reader.uint32());
continue;
case 4:
if (tag !== 34) {
break;
}
message.channel = Channel.decode(reader, reader.uint32());
continue;
case 5:
if (tag !== 42) {
break;
}
message.content = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet6(object.id) ? globalThis.String(object.id) : void 0,
timestamp: isSet6(object.timestamp) ? fromJsonTimestamp(object.timestamp) : void 0,
author: isSet6(object.author) ? User.fromJSON(object.author) : void 0,
channel: isSet6(object.channel) ? Channel.fromJSON(object.channel) : void 0,
content: isSet6(object.content) ? globalThis.String(object.content) : ""
};
},
toJSON(message) {
const obj = {};
if (message.id !== void 0) {
obj.id = message.id;
}
if (message.timestamp !== void 0) {
obj.timestamp = message.timestamp.toISOString();
}
if (message.author !== void 0) {
obj.author = User.toJSON(message.author);
}
if (message.channel !== void 0) {
obj.channel = Channel.toJSON(message.channel);
}
if (message.content !== "") {
obj.content = message.content;
}
return obj;
},
create(base) {
return Message2.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseMessage();
message.id = object.id ?? void 0;
message.timestamp = object.timestamp ?? void 0;
message.author = object.author !== void 0 && object.author !== null ? User.fromPartial(object.author) : void 0;
message.channel = object.channel !== void 0 && object.channel !== null ? Channel.fromPartial(object.channel) : void 0;
message.content = object.content ?? "";
return message;
}
};
function toTimestamp(date) {
const seconds = Math.trunc(date.getTime() / 1e3);
const nanos = date.getTime() % 1e3 * 1e6;
return { seconds, nanos };
}
function fromTimestamp(t) {
let millis = (t.seconds || 0) * 1e3;
millis += (t.nanos || 0) / 1e6;
return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
if (o instanceof globalThis.Date) {
return o;
} else if (typeof o === "string") {
return new globalThis.Date(o);
} else {
return fromTimestamp(Timestamp.fromJSON(o));
}
}
function isSet6(value) {
return value !== null && value !== void 0;
}
function createBaseCommandContext() {
return { name: "", arguments: [], subcommand: void 0 };
}
var CommandContext = {
encode(message, writer = new BinaryWriter()) {
if (message.name !== "") {
writer.uint32(10).string(message.name);
}
for (const v of message.arguments) {
CommandContextArgument.encode(v, writer.uint32(18).fork()).join();
}
if (message.subcommand !== void 0) {
CommandContext.encode(message.subcommand, writer.uint32(26).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 = createBaseCommandContext();
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.arguments.push(CommandContextArgument.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.subcommand = CommandContext.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
name: isSet7(object.name) ? globalThis.String(object.name) : "",
arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e) => CommandContextArgument.fromJSON(e)) : [],
subcommand: isSet7(object.subcommand) ? CommandContext.fromJSON(object.subcommand) : void 0
};
},
toJSON(message) {
const obj = {};
if (message.name !== "") {
obj.name = message.name;
}
if (message.arguments?.length) {
obj.arguments = message.arguments.map((e) => CommandContextArgument.toJSON(e));
}
if (message.subcommand !== void 0) {
obj.subcommand = CommandContext.toJSON(message.subcommand);
}
return obj;
},
create(base) {
return CommandContext.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseCommandContext();