@rivetkit/supabase 2.3.4 → 2.3.5-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mod.js +1691 -1268
- package/dist/mod.mjs +1691 -1268
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -508,7 +508,7 @@ function unsupportedFeature(feature) {
|
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
511
|
+
// ../rivetkit/dist/tsup/chunk-B4IZU537.js
|
|
512
512
|
var import_pino = require("pino");
|
|
513
513
|
|
|
514
514
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
@@ -13181,7 +13181,9 @@ var classic_default = external_exports;
|
|
|
13181
13181
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13182
13182
|
var v4_default = classic_default;
|
|
13183
13183
|
|
|
13184
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13184
|
+
// ../rivetkit/dist/tsup/chunk-B4IZU537.js
|
|
13185
|
+
var cbor = __toESM(require("cbor-x"), 1);
|
|
13186
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13185
13187
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13186
13188
|
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13187
13189
|
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
@@ -13344,7 +13346,7 @@ function noopNext() {
|
|
|
13344
13346
|
}
|
|
13345
13347
|
var package_default = {
|
|
13346
13348
|
name: "rivetkit",
|
|
13347
|
-
version: "2.3.
|
|
13349
|
+
version: "2.3.5-rc.1",
|
|
13348
13350
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13349
13351
|
license: "Apache-2.0",
|
|
13350
13352
|
keywords: [
|
|
@@ -13741,834 +13743,1194 @@ function quoteLogfmtString(value) {
|
|
|
13741
13743
|
}
|
|
13742
13744
|
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`;
|
|
13743
13745
|
}
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
if (_userAgent !== void 0) {
|
|
13748
|
-
return _userAgent;
|
|
13746
|
+
function uint8ArrayToBase642(uint8Array) {
|
|
13747
|
+
if (typeof Buffer !== "undefined") {
|
|
13748
|
+
return Buffer.from(uint8Array).toString("base64");
|
|
13749
13749
|
}
|
|
13750
|
-
let
|
|
13751
|
-
const
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
return userAgent;
|
|
13755
|
-
}
|
|
13756
|
-
function getEnvUniversal(key) {
|
|
13757
|
-
if (typeof Deno !== "undefined") {
|
|
13758
|
-
return Deno.env.get(key);
|
|
13759
|
-
} else if (typeof process !== "undefined") {
|
|
13760
|
-
return process.env[key];
|
|
13750
|
+
let binary = "";
|
|
13751
|
+
const len = uint8Array.byteLength;
|
|
13752
|
+
for (let i = 0; i < len; i++) {
|
|
13753
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
13761
13754
|
}
|
|
13755
|
+
return btoa(binary);
|
|
13762
13756
|
}
|
|
13763
|
-
function
|
|
13764
|
-
if (
|
|
13765
|
-
return
|
|
13766
|
-
} else if (
|
|
13767
|
-
return
|
|
13768
|
-
} else if (ArrayBuffer.isView(data)) {
|
|
13769
|
-
return new Uint8Array(
|
|
13770
|
-
data.buffer.slice(
|
|
13771
|
-
data.byteOffset,
|
|
13772
|
-
data.byteOffset + data.byteLength
|
|
13773
|
-
)
|
|
13774
|
-
);
|
|
13757
|
+
function contentTypeForEncoding(encoding) {
|
|
13758
|
+
if (encoding === "json") {
|
|
13759
|
+
return "application/json";
|
|
13760
|
+
} else if (encoding === "cbor" || encoding === "bare") {
|
|
13761
|
+
return "application/octet-stream";
|
|
13775
13762
|
} else {
|
|
13776
|
-
|
|
13763
|
+
assertUnreachable(encoding);
|
|
13777
13764
|
}
|
|
13778
13765
|
}
|
|
13779
|
-
function
|
|
13780
|
-
|
|
13781
|
-
let reject;
|
|
13782
|
-
const promise2 = new Promise((res, rej) => {
|
|
13783
|
-
resolve = res;
|
|
13784
|
-
reject = rej;
|
|
13785
|
-
});
|
|
13786
|
-
promise2.catch(onReject);
|
|
13787
|
-
return { promise: promise2, resolve, reject };
|
|
13766
|
+
function encodeCborCompat(value) {
|
|
13767
|
+
return cbor.encode(encodeJsonCompatValue(value));
|
|
13788
13768
|
}
|
|
13789
|
-
function
|
|
13790
|
-
return
|
|
13791
|
-
buf.byteOffset,
|
|
13792
|
-
buf.byteOffset + buf.byteLength
|
|
13793
|
-
);
|
|
13769
|
+
function decodeCborCompat(buffer) {
|
|
13770
|
+
return reviveJsonCompatValue(cbor.decode(buffer));
|
|
13794
13771
|
}
|
|
13795
|
-
function
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
if (
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
if (value !== void 0) {
|
|
13810
|
-
queryParts.push(
|
|
13811
|
-
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
13812
|
-
);
|
|
13813
|
-
}
|
|
13772
|
+
function serializeWithEncoding(encoding, value, versionedDataHandler, version2, zodSchema, toJson, toBare) {
|
|
13773
|
+
if (encoding === "json") {
|
|
13774
|
+
const jsonValue = toJson(value);
|
|
13775
|
+
const validated = zodSchema.parse(jsonValue);
|
|
13776
|
+
return jsonStringifyCompat(validated);
|
|
13777
|
+
} else if (encoding === "cbor") {
|
|
13778
|
+
const jsonValue = toJson(value);
|
|
13779
|
+
const validated = zodSchema.parse(jsonValue);
|
|
13780
|
+
return cbor.encode(validated);
|
|
13781
|
+
} else if (encoding === "bare") {
|
|
13782
|
+
if (!versionedDataHandler) {
|
|
13783
|
+
throw new Error(
|
|
13784
|
+
"VersionedDataHandler is required for 'bare' encoding"
|
|
13785
|
+
);
|
|
13814
13786
|
}
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
function assert2(test, message = "") {
|
|
13826
|
-
if (!test) {
|
|
13827
|
-
const e = new AssertionError(message);
|
|
13828
|
-
V8Error.captureStackTrace?.(e, assert2);
|
|
13829
|
-
throw e;
|
|
13787
|
+
if (version2 === void 0) {
|
|
13788
|
+
throw new Error("version is required for 'bare' encoding");
|
|
13789
|
+
}
|
|
13790
|
+
const bareValue = toBare(value);
|
|
13791
|
+
return versionedDataHandler.serializeWithEmbeddedVersion(
|
|
13792
|
+
bareValue,
|
|
13793
|
+
version2
|
|
13794
|
+
);
|
|
13795
|
+
} else {
|
|
13796
|
+
assertUnreachable(encoding);
|
|
13830
13797
|
}
|
|
13831
13798
|
}
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13799
|
+
function deserializeWithEncoding(encoding, buffer, versionedDataHandler, zodSchema, fromJson, fromBare) {
|
|
13800
|
+
if (encoding === "json") {
|
|
13801
|
+
let parsed;
|
|
13802
|
+
if (typeof buffer === "string") {
|
|
13803
|
+
parsed = jsonParseCompat(buffer);
|
|
13804
|
+
} else {
|
|
13805
|
+
const decoder = new TextDecoder("utf-8");
|
|
13806
|
+
const jsonString = decoder.decode(buffer);
|
|
13807
|
+
parsed = jsonParseCompat(jsonString);
|
|
13808
|
+
}
|
|
13809
|
+
const validated = zodSchema.parse(parsed);
|
|
13810
|
+
return fromJson(validated);
|
|
13811
|
+
} else if (encoding === "cbor") {
|
|
13812
|
+
(0, import_invariant.default)(
|
|
13813
|
+
typeof buffer !== "string",
|
|
13814
|
+
"buffer cannot be string for cbor encoding"
|
|
13815
|
+
);
|
|
13816
|
+
const decoded = decodeCborCompat(buffer);
|
|
13817
|
+
const validated = zodSchema.parse(decoded);
|
|
13818
|
+
return fromJson(validated);
|
|
13819
|
+
} else if (encoding === "bare") {
|
|
13820
|
+
(0, import_invariant.default)(
|
|
13821
|
+
typeof buffer !== "string",
|
|
13822
|
+
"buffer cannot be string for bare encoding"
|
|
13823
|
+
);
|
|
13824
|
+
if (!versionedDataHandler) {
|
|
13825
|
+
throw new Error(
|
|
13826
|
+
"VersionedDataHandler is required for 'bare' encoding"
|
|
13827
|
+
);
|
|
13828
|
+
}
|
|
13829
|
+
const bareValue = versionedDataHandler.deserializeWithEmbeddedVersion(buffer);
|
|
13830
|
+
return fromBare(bareValue);
|
|
13831
|
+
} else {
|
|
13832
|
+
assertUnreachable(encoding);
|
|
13836
13833
|
}
|
|
13837
|
-
};
|
|
13838
|
-
|
|
13839
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/validator.js
|
|
13840
|
-
function isU8(val) {
|
|
13841
|
-
return val === (val & 255);
|
|
13842
13834
|
}
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13835
|
+
var JSON_COMPAT_BIGINT = "$BigInt";
|
|
13836
|
+
var JSON_COMPAT_ARRAY_BUFFER = "$ArrayBuffer";
|
|
13837
|
+
var JSON_COMPAT_UINT8_ARRAY = "$Uint8Array";
|
|
13838
|
+
var JSON_COMPAT_UNDEFINED = "$Undefined";
|
|
13839
|
+
var JSON_COMPAT_SET = "$Set";
|
|
13840
|
+
function isTypedArray(value) {
|
|
13841
|
+
return value instanceof Uint8ClampedArray || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof BigUint64Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array || value instanceof BigInt64Array || value instanceof Float32Array || value instanceof Float64Array;
|
|
13848
13842
|
}
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
var INT_SAFE_MAX_BYTE_COUNT = 8;
|
|
13854
|
-
var UINT_MAX_BYTE_COUNT = 10;
|
|
13855
|
-
var UINT_SAFE32_MAX_BYTE_COUNT = 5;
|
|
13856
|
-
var INVALID_UTF8_STRING = "invalid UTF-8 string";
|
|
13857
|
-
var NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
13858
|
-
var TOO_LARGE_BUFFER = "too large buffer";
|
|
13859
|
-
var TOO_LARGE_NUMBER = "too large number";
|
|
13860
|
-
|
|
13861
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/bare-error.js
|
|
13862
|
-
var BareError = class extends Error {
|
|
13863
|
-
constructor(offset, issue2, opts) {
|
|
13864
|
-
super(`(byte:${offset}) ${issue2}`);
|
|
13865
|
-
this.name = "BareError";
|
|
13866
|
-
this.issue = issue2;
|
|
13867
|
-
this.offset = offset;
|
|
13868
|
-
this.cause = opts?.cause;
|
|
13843
|
+
function assertJsonCompatValue(value, path2 = "") {
|
|
13844
|
+
var _a2;
|
|
13845
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
13846
|
+
return;
|
|
13869
13847
|
}
|
|
13870
|
-
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
/**
|
|
13875
|
-
* @throws {BareError} Buffer exceeds `config.maxBufferLength`
|
|
13876
|
-
*/
|
|
13877
|
-
constructor(bytes, config3) {
|
|
13878
|
-
this.offset = 0;
|
|
13879
|
-
if (bytes.length > config3.maxBufferLength) {
|
|
13880
|
-
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
13881
|
-
}
|
|
13882
|
-
this.bytes = bytes;
|
|
13883
|
-
this.config = config3;
|
|
13884
|
-
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
13848
|
+
if (typeof value === "function") {
|
|
13849
|
+
throw new TypeError(
|
|
13850
|
+
`Value at ${path2 || "root"} is a function and is not CBOR serializable`
|
|
13851
|
+
);
|
|
13885
13852
|
}
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13853
|
+
if (typeof value === "symbol") {
|
|
13854
|
+
throw new TypeError(
|
|
13855
|
+
`Value at ${path2 || "root"} is a symbol and is not CBOR serializable`
|
|
13856
|
+
);
|
|
13890
13857
|
}
|
|
13891
|
-
if (
|
|
13892
|
-
|
|
13858
|
+
if (value instanceof Date || value instanceof RegExp || value instanceof Error || value instanceof ArrayBuffer || value instanceof Uint8Array || isTypedArray(value)) {
|
|
13859
|
+
return;
|
|
13893
13860
|
}
|
|
13894
|
-
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
|
|
13861
|
+
if (value instanceof WeakMap) {
|
|
13862
|
+
throw new TypeError(
|
|
13863
|
+
`Value at ${path2 || "root"} is a WeakMap and is not CBOR serializable`
|
|
13864
|
+
);
|
|
13898
13865
|
}
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13866
|
+
if (value instanceof WeakSet) {
|
|
13867
|
+
throw new TypeError(
|
|
13868
|
+
`Value at ${path2 || "root"} is a WeakSet and is not CBOR serializable`
|
|
13869
|
+
);
|
|
13902
13870
|
}
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13871
|
+
if (value instanceof WeakRef) {
|
|
13872
|
+
throw new TypeError(
|
|
13873
|
+
`Value at ${path2 || "root"} is a WeakRef and is not CBOR serializable`
|
|
13874
|
+
);
|
|
13907
13875
|
}
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
} else {
|
|
13918
|
-
buffer.grow(newLen);
|
|
13876
|
+
if (value instanceof Promise) {
|
|
13877
|
+
throw new TypeError(
|
|
13878
|
+
`Value at ${path2 || "root"} is a Promise and is not CBOR serializable`
|
|
13879
|
+
);
|
|
13880
|
+
}
|
|
13881
|
+
if (value instanceof Map) {
|
|
13882
|
+
for (const [k, v] of value.entries()) {
|
|
13883
|
+
assertJsonCompatValue(k, `${path2 || "root"}.key(${String(k)})`);
|
|
13884
|
+
assertJsonCompatValue(v, `${path2 || "root"}.value(${String(k)})`);
|
|
13919
13885
|
}
|
|
13920
|
-
|
|
13921
|
-
} else {
|
|
13922
|
-
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength);
|
|
13923
|
-
newBytes = new Uint8Array(newLen);
|
|
13924
|
-
newBytes.set(bc.bytes);
|
|
13886
|
+
return;
|
|
13925
13887
|
}
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
}
|
|
13932
|
-
|
|
13933
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/fixed-primitive.js
|
|
13934
|
-
function readBool(bc) {
|
|
13935
|
-
const val = readU8(bc);
|
|
13936
|
-
if (val > 1) {
|
|
13937
|
-
bc.offset--;
|
|
13938
|
-
throw new BareError(bc.offset, "a bool must be equal to 0 or 1");
|
|
13888
|
+
if (value instanceof Set) {
|
|
13889
|
+
let index = 0;
|
|
13890
|
+
for (const item of value.values()) {
|
|
13891
|
+
assertJsonCompatValue(item, `${path2 || "root"}.set[${index}]`);
|
|
13892
|
+
index++;
|
|
13893
|
+
}
|
|
13894
|
+
return;
|
|
13939
13895
|
}
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
13896
|
+
if (Array.isArray(value)) {
|
|
13897
|
+
for (let i = 0; i < value.length; i++) {
|
|
13898
|
+
assertJsonCompatValue(value[i], `${path2 || "root"}[${i}]`);
|
|
13899
|
+
}
|
|
13900
|
+
return;
|
|
13901
|
+
}
|
|
13902
|
+
if (isPlainObject2(value)) {
|
|
13903
|
+
for (const key in value) {
|
|
13904
|
+
assertJsonCompatValue(
|
|
13905
|
+
value[key],
|
|
13906
|
+
path2 ? `${path2}.${key}` : key
|
|
13907
|
+
);
|
|
13908
|
+
}
|
|
13909
|
+
return;
|
|
13910
|
+
}
|
|
13911
|
+
const typeName = typeof value === "object" && value !== null ? ((_a2 = value.constructor) == null ? void 0 : _a2.name) ?? typeof value : typeof value;
|
|
13912
|
+
throw new TypeError(
|
|
13913
|
+
`Value at ${path2 || "root"} of type "${typeName}" is not CBOR serializable`
|
|
13914
|
+
);
|
|
13948
13915
|
}
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13916
|
+
var EncodingSchema = external_exports.enum(["json", "cbor", "bare"]);
|
|
13917
|
+
async function inputDataToBuffer(data) {
|
|
13918
|
+
if (typeof data === "string") {
|
|
13919
|
+
return data;
|
|
13952
13920
|
}
|
|
13953
|
-
|
|
13954
|
-
|
|
13921
|
+
if (data instanceof Blob) {
|
|
13922
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
13923
|
+
}
|
|
13924
|
+
if (data instanceof Uint8Array) {
|
|
13925
|
+
return data;
|
|
13926
|
+
}
|
|
13927
|
+
if (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) {
|
|
13928
|
+
return new Uint8Array(data);
|
|
13929
|
+
}
|
|
13930
|
+
throw new Error("Malformed message");
|
|
13955
13931
|
}
|
|
13956
|
-
function
|
|
13957
|
-
|
|
13958
|
-
const
|
|
13959
|
-
|
|
13960
|
-
|
|
13932
|
+
function base64EncodeUint8Array(uint8Array) {
|
|
13933
|
+
let binary = "";
|
|
13934
|
+
for (const value of uint8Array) {
|
|
13935
|
+
binary += String.fromCharCode(value);
|
|
13936
|
+
}
|
|
13937
|
+
return btoa(binary);
|
|
13961
13938
|
}
|
|
13962
|
-
function
|
|
13963
|
-
|
|
13964
|
-
const result = bc.view.getBigUint64(bc.offset, true);
|
|
13965
|
-
bc.offset += 8;
|
|
13966
|
-
return result;
|
|
13939
|
+
function base64EncodeArrayBuffer(arrayBuffer) {
|
|
13940
|
+
return base64EncodeUint8Array(new Uint8Array(arrayBuffer));
|
|
13967
13941
|
}
|
|
13968
|
-
function
|
|
13969
|
-
if (
|
|
13970
|
-
|
|
13942
|
+
function isPlainObject2(value) {
|
|
13943
|
+
if (value === null || typeof value !== "object") {
|
|
13944
|
+
return false;
|
|
13971
13945
|
}
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
bc.offset += 8;
|
|
13946
|
+
const proto = Object.getPrototypeOf(value);
|
|
13947
|
+
return proto === Object.prototype || proto === null;
|
|
13975
13948
|
}
|
|
13976
|
-
|
|
13977
|
-
|
|
13978
|
-
|
|
13979
|
-
|
|
13980
|
-
if (low >= 128) {
|
|
13981
|
-
low &= 127;
|
|
13982
|
-
let shiftMul = 128;
|
|
13983
|
-
let byteCount = 1;
|
|
13984
|
-
let byte;
|
|
13985
|
-
do {
|
|
13986
|
-
byte = readU8(bc);
|
|
13987
|
-
low += (byte & 127) * shiftMul;
|
|
13988
|
-
shiftMul *= /* 2**7 */
|
|
13989
|
-
128;
|
|
13990
|
-
byteCount++;
|
|
13991
|
-
} while (byte >= 128 && byteCount < 7);
|
|
13992
|
-
let height = 0;
|
|
13993
|
-
shiftMul = 1;
|
|
13994
|
-
while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
|
|
13995
|
-
byte = readU8(bc);
|
|
13996
|
-
height += (byte & 127) * shiftMul;
|
|
13997
|
-
shiftMul *= /* 2**7 */
|
|
13998
|
-
128;
|
|
13999
|
-
byteCount++;
|
|
14000
|
-
}
|
|
14001
|
-
if (byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
|
|
14002
|
-
bc.offset -= byteCount;
|
|
14003
|
-
throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
|
|
14004
|
-
}
|
|
14005
|
-
return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
|
|
13949
|
+
function encodeJsonCompatValue(input) {
|
|
13950
|
+
var _a2;
|
|
13951
|
+
if (input === null) {
|
|
13952
|
+
return input;
|
|
14006
13953
|
}
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
function writeUint(bc, x) {
|
|
14010
|
-
const truncated = BigInt.asUintN(64, x);
|
|
14011
|
-
if (DEV) {
|
|
14012
|
-
assert2(truncated === x, TOO_LARGE_NUMBER);
|
|
13954
|
+
if (input === void 0) {
|
|
13955
|
+
return [JSON_COMPAT_UNDEFINED, 0];
|
|
14013
13956
|
}
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
13957
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
|
13958
|
+
return input;
|
|
13959
|
+
}
|
|
13960
|
+
if (typeof input === "bigint") {
|
|
13961
|
+
return [JSON_COMPAT_BIGINT, input.toString()];
|
|
13962
|
+
}
|
|
13963
|
+
if (input instanceof ArrayBuffer) {
|
|
13964
|
+
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];
|
|
13965
|
+
}
|
|
13966
|
+
if (input instanceof Uint8Array) {
|
|
13967
|
+
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];
|
|
13968
|
+
}
|
|
13969
|
+
if (isTypedArray(input)) {
|
|
13970
|
+
return input;
|
|
13971
|
+
}
|
|
13972
|
+
if (input instanceof Date || input instanceof RegExp || input instanceof Error) {
|
|
13973
|
+
return input;
|
|
13974
|
+
}
|
|
13975
|
+
if (input instanceof Set) {
|
|
13976
|
+
const encoded = [...input.values()].map(
|
|
13977
|
+
(v) => encodeJsonCompatValue(v)
|
|
13978
|
+
);
|
|
13979
|
+
return [JSON_COMPAT_SET, encoded];
|
|
13980
|
+
}
|
|
13981
|
+
if (input instanceof Map) {
|
|
13982
|
+
const encoded = /* @__PURE__ */ new Map();
|
|
13983
|
+
for (const [k, v] of input.entries()) {
|
|
13984
|
+
encoded.set(
|
|
13985
|
+
encodeJsonCompatValue(k),
|
|
13986
|
+
encodeJsonCompatValue(v)
|
|
13987
|
+
);
|
|
14028
13988
|
}
|
|
13989
|
+
return encoded;
|
|
14029
13990
|
}
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
let shift = 7;
|
|
14037
|
-
let byteCount = 1;
|
|
14038
|
-
let byte;
|
|
14039
|
-
do {
|
|
14040
|
-
byte = readU8(bc);
|
|
14041
|
-
result += (byte & 127) << shift >>> 0;
|
|
14042
|
-
shift += 7;
|
|
14043
|
-
byteCount++;
|
|
14044
|
-
} while (byte >= 128 && byteCount < UINT_SAFE32_MAX_BYTE_COUNT);
|
|
14045
|
-
if (byte === 0) {
|
|
14046
|
-
bc.offset -= byteCount - 1;
|
|
14047
|
-
throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
|
|
13991
|
+
if (Array.isArray(input)) {
|
|
13992
|
+
const encoded = input.map(
|
|
13993
|
+
(value) => encodeJsonCompatValue(value)
|
|
13994
|
+
);
|
|
13995
|
+
if (encoded.length === 2 && typeof encoded[0] === "string" && encoded[0].startsWith("$")) {
|
|
13996
|
+
return [`$${encoded[0]}`, encoded[1]];
|
|
14048
13997
|
}
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
13998
|
+
return encoded;
|
|
13999
|
+
}
|
|
14000
|
+
if (isPlainObject2(input)) {
|
|
14001
|
+
const encoded = {};
|
|
14002
|
+
for (const [key, value] of Object.entries(input)) {
|
|
14003
|
+
encoded[key] = encodeJsonCompatValue(value);
|
|
14052
14004
|
}
|
|
14005
|
+
return encoded;
|
|
14053
14006
|
}
|
|
14054
|
-
|
|
14007
|
+
const typeName = typeof input === "object" && input !== null ? ((_a2 = input.constructor) == null ? void 0 : _a2.name) ?? typeof input : typeof input;
|
|
14008
|
+
throw new TypeError(`Value of type "${typeName}" is not CBOR serializable`);
|
|
14055
14009
|
}
|
|
14056
|
-
function
|
|
14057
|
-
if (
|
|
14058
|
-
|
|
14010
|
+
function reviveJsonCompatValue(input, options = {}) {
|
|
14011
|
+
if (typeof input === "bigint") {
|
|
14012
|
+
if (options.coerceSafeIntegerBigInts && input >= BigInt(Number.MIN_SAFE_INTEGER) && input <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
14013
|
+
return Number(input);
|
|
14014
|
+
}
|
|
14015
|
+
return input;
|
|
14059
14016
|
}
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14017
|
+
if (input instanceof Map) {
|
|
14018
|
+
const revived = /* @__PURE__ */ new Map();
|
|
14019
|
+
for (const [k, v] of input.entries()) {
|
|
14020
|
+
revived.set(
|
|
14021
|
+
reviveJsonCompatValue(k, options),
|
|
14022
|
+
reviveJsonCompatValue(v, options)
|
|
14023
|
+
);
|
|
14024
|
+
}
|
|
14025
|
+
return revived;
|
|
14064
14026
|
}
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14027
|
+
if (Array.isArray(input)) {
|
|
14028
|
+
if (input.length === 2 && typeof input[0] === "string" && input[0].startsWith("$")) {
|
|
14029
|
+
if (input[0] === JSON_COMPAT_BIGINT) {
|
|
14030
|
+
return BigInt(input[1]);
|
|
14031
|
+
}
|
|
14032
|
+
if (input[0] === JSON_COMPAT_ARRAY_BUFFER) {
|
|
14033
|
+
return base64DecodeToArrayBuffer(input[1]);
|
|
14034
|
+
}
|
|
14035
|
+
if (input[0] === JSON_COMPAT_UINT8_ARRAY) {
|
|
14036
|
+
return base64DecodeToUint8Array(input[1]);
|
|
14037
|
+
}
|
|
14038
|
+
if (input[0] === JSON_COMPAT_UNDEFINED) {
|
|
14039
|
+
return void 0;
|
|
14040
|
+
}
|
|
14041
|
+
if (input[0] === JSON_COMPAT_SET) {
|
|
14042
|
+
const items = input[1].map(
|
|
14043
|
+
(v) => reviveJsonCompatValue(v, options)
|
|
14044
|
+
);
|
|
14045
|
+
return new Set(items);
|
|
14046
|
+
}
|
|
14047
|
+
if (input[0].startsWith("$$")) {
|
|
14048
|
+
return [
|
|
14049
|
+
input[0].substring(1),
|
|
14050
|
+
reviveJsonCompatValue(input[1], options)
|
|
14051
|
+
];
|
|
14052
|
+
}
|
|
14053
|
+
throw new Error(
|
|
14054
|
+
`Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`
|
|
14055
|
+
);
|
|
14087
14056
|
}
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14057
|
+
return input.map((value) => reviveJsonCompatValue(value, options));
|
|
14058
|
+
}
|
|
14059
|
+
if (isPlainObject2(input)) {
|
|
14060
|
+
const decoded = {};
|
|
14061
|
+
for (const [key, value] of Object.entries(input)) {
|
|
14062
|
+
decoded[key] = reviveJsonCompatValue(value, options);
|
|
14091
14063
|
}
|
|
14064
|
+
return decoded;
|
|
14092
14065
|
}
|
|
14093
|
-
return
|
|
14066
|
+
return input;
|
|
14094
14067
|
}
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14068
|
+
function base64DecodeToUint8Array(base643) {
|
|
14069
|
+
if (typeof Buffer !== "undefined") {
|
|
14070
|
+
return new Uint8Array(Buffer.from(base643, "base64"));
|
|
14071
|
+
}
|
|
14072
|
+
const binary = atob(base643);
|
|
14073
|
+
const bytes = new Uint8Array(binary.length);
|
|
14074
|
+
for (let i = 0; i < binary.length; i++) {
|
|
14075
|
+
bytes[i] = binary.charCodeAt(i);
|
|
14076
|
+
}
|
|
14077
|
+
return bytes;
|
|
14099
14078
|
}
|
|
14100
|
-
function
|
|
14101
|
-
|
|
14102
|
-
writeU8FixedArray(bc, x);
|
|
14079
|
+
function base64DecodeToArrayBuffer(base643) {
|
|
14080
|
+
return base64DecodeToUint8Array(base643).buffer;
|
|
14103
14081
|
}
|
|
14104
|
-
function
|
|
14105
|
-
return
|
|
14082
|
+
function jsonStringifyCompat(input, space) {
|
|
14083
|
+
return JSON.stringify(
|
|
14084
|
+
input,
|
|
14085
|
+
(_key, value) => {
|
|
14086
|
+
if (typeof value === "bigint") {
|
|
14087
|
+
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14088
|
+
}
|
|
14089
|
+
if (value instanceof ArrayBuffer) {
|
|
14090
|
+
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(value)];
|
|
14091
|
+
}
|
|
14092
|
+
if (value instanceof Uint8Array) {
|
|
14093
|
+
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
14094
|
+
}
|
|
14095
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0].startsWith("$")) {
|
|
14096
|
+
return [`$${value[0]}`, value[1]];
|
|
14097
|
+
}
|
|
14098
|
+
return value;
|
|
14099
|
+
},
|
|
14100
|
+
space
|
|
14101
|
+
);
|
|
14106
14102
|
}
|
|
14107
|
-
function
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14103
|
+
function jsonParseCompat(input) {
|
|
14104
|
+
return reviveJsonCompatValue(JSON.parse(input));
|
|
14105
|
+
}
|
|
14106
|
+
var VERSION = package_default.version;
|
|
14107
|
+
var _userAgent;
|
|
14108
|
+
function httpUserAgent() {
|
|
14109
|
+
if (_userAgent !== void 0) {
|
|
14110
|
+
return _userAgent;
|
|
14113
14111
|
}
|
|
14112
|
+
let userAgent = `RivetKit/${VERSION}`;
|
|
14113
|
+
const navigatorObj = typeof navigator !== "undefined" ? navigator : void 0;
|
|
14114
|
+
if (navigatorObj == null ? void 0 : navigatorObj.userAgent) userAgent += ` ${navigatorObj.userAgent}`;
|
|
14115
|
+
_userAgent = userAgent;
|
|
14116
|
+
return userAgent;
|
|
14114
14117
|
}
|
|
14115
|
-
function
|
|
14116
|
-
if (
|
|
14117
|
-
|
|
14118
|
+
function getEnvUniversal(key) {
|
|
14119
|
+
if (typeof Deno !== "undefined") {
|
|
14120
|
+
return Deno.env.get(key);
|
|
14121
|
+
} else if (typeof process !== "undefined") {
|
|
14122
|
+
return process.env[key];
|
|
14118
14123
|
}
|
|
14119
|
-
check2(bc, len);
|
|
14120
|
-
const offset = bc.offset;
|
|
14121
|
-
bc.offset += len;
|
|
14122
|
-
return bc.bytes.subarray(offset, offset + len);
|
|
14123
14124
|
}
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14125
|
+
function toUint8Array(data) {
|
|
14126
|
+
if (data instanceof Uint8Array) {
|
|
14127
|
+
return data;
|
|
14128
|
+
} else if (data instanceof ArrayBuffer) {
|
|
14129
|
+
return new Uint8Array(data);
|
|
14130
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
14131
|
+
return new Uint8Array(
|
|
14132
|
+
data.buffer.slice(
|
|
14133
|
+
data.byteOffset,
|
|
14134
|
+
data.byteOffset + data.byteLength
|
|
14135
|
+
)
|
|
14136
|
+
);
|
|
14137
|
+
} else {
|
|
14138
|
+
throw new TypeError("Input must be ArrayBuffer or ArrayBufferView");
|
|
14139
|
+
}
|
|
14128
14140
|
}
|
|
14129
|
-
function
|
|
14130
|
-
|
|
14141
|
+
function promiseWithResolvers(onReject) {
|
|
14142
|
+
let resolve;
|
|
14143
|
+
let reject;
|
|
14144
|
+
const promise2 = new Promise((res, rej) => {
|
|
14145
|
+
resolve = res;
|
|
14146
|
+
reject = rej;
|
|
14147
|
+
});
|
|
14148
|
+
promise2.catch(onReject);
|
|
14149
|
+
return { promise: promise2, resolve, reject };
|
|
14131
14150
|
}
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14151
|
+
function bufferToArrayBuffer(buf) {
|
|
14152
|
+
return buf.buffer.slice(
|
|
14153
|
+
buf.byteOffset,
|
|
14154
|
+
buf.byteOffset + buf.byteLength
|
|
14155
|
+
);
|
|
14136
14156
|
}
|
|
14137
|
-
function
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14157
|
+
function combineUrlPath(endpoint, path2, queryParams) {
|
|
14158
|
+
const baseUrl = new URL(endpoint);
|
|
14159
|
+
const pathParts = path2.split("?");
|
|
14160
|
+
const pathOnly = pathParts[0];
|
|
14161
|
+
const existingQuery = pathParts[1] || "";
|
|
14162
|
+
const basePath = baseUrl.pathname.replace(/\/$/, "");
|
|
14163
|
+
const cleanPath = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
|
|
14164
|
+
const fullPath = (basePath + cleanPath).replace(/\/\//g, "/");
|
|
14165
|
+
const queryParts = [];
|
|
14166
|
+
if (existingQuery) {
|
|
14167
|
+
queryParts.push(existingQuery);
|
|
14147
14168
|
}
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14169
|
+
if (queryParams) {
|
|
14170
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
14171
|
+
if (value !== void 0) {
|
|
14172
|
+
queryParts.push(
|
|
14173
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
14174
|
+
);
|
|
14175
|
+
}
|
|
14176
|
+
}
|
|
14152
14177
|
}
|
|
14153
|
-
|
|
14154
|
-
|
|
14178
|
+
const fullQuery = queryParts.length > 0 ? `?${queryParts.join("&")}` : "";
|
|
14179
|
+
return `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;
|
|
14180
|
+
}
|
|
14181
|
+
|
|
14182
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/imports/dev.node.js
|
|
14183
|
+
var DEV = process.env.NODE_ENV === "development";
|
|
14184
|
+
|
|
14185
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/assert.js
|
|
14186
|
+
var V8Error = Error;
|
|
14187
|
+
function assert2(test, message = "") {
|
|
14188
|
+
if (!test) {
|
|
14189
|
+
const e = new AssertionError(message);
|
|
14190
|
+
V8Error.captureStackTrace?.(e, assert2);
|
|
14191
|
+
throw e;
|
|
14155
14192
|
}
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14193
|
+
}
|
|
14194
|
+
var AssertionError = class extends Error {
|
|
14195
|
+
constructor() {
|
|
14196
|
+
super(...arguments);
|
|
14197
|
+
this.name = "AssertionError";
|
|
14160
14198
|
}
|
|
14199
|
+
};
|
|
14200
|
+
|
|
14201
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/validator.js
|
|
14202
|
+
function isU8(val) {
|
|
14203
|
+
return val === (val & 255);
|
|
14161
14204
|
}
|
|
14162
|
-
function
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
if (malformed) {
|
|
14201
|
-
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14202
|
-
}
|
|
14205
|
+
function isU32(val) {
|
|
14206
|
+
return val === val >>> 0;
|
|
14207
|
+
}
|
|
14208
|
+
function isU64(val) {
|
|
14209
|
+
return val === BigInt.asUintN(64, val);
|
|
14210
|
+
}
|
|
14211
|
+
|
|
14212
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/constants.js
|
|
14213
|
+
var TEXT_DECODER_THRESHOLD = 256;
|
|
14214
|
+
var TEXT_ENCODER_THRESHOLD = 256;
|
|
14215
|
+
var INT_SAFE_MAX_BYTE_COUNT = 8;
|
|
14216
|
+
var UINT_MAX_BYTE_COUNT = 10;
|
|
14217
|
+
var UINT_SAFE32_MAX_BYTE_COUNT = 5;
|
|
14218
|
+
var INVALID_UTF8_STRING = "invalid UTF-8 string";
|
|
14219
|
+
var NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
14220
|
+
var TOO_LARGE_BUFFER = "too large buffer";
|
|
14221
|
+
var TOO_LARGE_NUMBER = "too large number";
|
|
14222
|
+
|
|
14223
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/bare-error.js
|
|
14224
|
+
var BareError = class extends Error {
|
|
14225
|
+
constructor(offset, issue2, opts) {
|
|
14226
|
+
super(`(byte:${offset}) ${issue2}`);
|
|
14227
|
+
this.name = "BareError";
|
|
14228
|
+
this.issue = issue2;
|
|
14229
|
+
this.offset = offset;
|
|
14230
|
+
this.cause = opts?.cause;
|
|
14231
|
+
}
|
|
14232
|
+
};
|
|
14233
|
+
|
|
14234
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/byte-cursor.js
|
|
14235
|
+
var ByteCursor = class {
|
|
14236
|
+
/**
|
|
14237
|
+
* @throws {BareError} Buffer exceeds `config.maxBufferLength`
|
|
14238
|
+
*/
|
|
14239
|
+
constructor(bytes, config3) {
|
|
14240
|
+
this.offset = 0;
|
|
14241
|
+
if (bytes.length > config3.maxBufferLength) {
|
|
14242
|
+
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14203
14243
|
}
|
|
14204
|
-
|
|
14244
|
+
this.bytes = bytes;
|
|
14245
|
+
this.config = config3;
|
|
14246
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
14247
|
+
}
|
|
14248
|
+
};
|
|
14249
|
+
function check2(bc, min) {
|
|
14250
|
+
if (DEV) {
|
|
14251
|
+
assert2(isU32(min));
|
|
14252
|
+
}
|
|
14253
|
+
if (bc.offset + min > bc.bytes.length) {
|
|
14254
|
+
throw new BareError(bc.offset, "missing bytes");
|
|
14205
14255
|
}
|
|
14206
|
-
bc.offset = offset;
|
|
14207
|
-
return result;
|
|
14208
14256
|
}
|
|
14209
|
-
function
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
bytes[offset++] = codePoint;
|
|
14217
|
-
} else {
|
|
14218
|
-
if (codePoint < 2048) {
|
|
14219
|
-
bytes[offset++] = 192 | codePoint >> 6;
|
|
14220
|
-
} else {
|
|
14221
|
-
if (codePoint < 65536) {
|
|
14222
|
-
bytes[offset++] = 224 | codePoint >> 12;
|
|
14223
|
-
} else {
|
|
14224
|
-
bytes[offset++] = 240 | codePoint >> 18;
|
|
14225
|
-
bytes[offset++] = 128 | codePoint >> 12 & 63;
|
|
14226
|
-
i++;
|
|
14227
|
-
}
|
|
14228
|
-
bytes[offset++] = 128 | codePoint >> 6 & 63;
|
|
14229
|
-
}
|
|
14230
|
-
bytes[offset++] = 128 | codePoint & 63;
|
|
14231
|
-
}
|
|
14257
|
+
function reserve(bc, min) {
|
|
14258
|
+
if (DEV) {
|
|
14259
|
+
assert2(isU32(min));
|
|
14260
|
+
}
|
|
14261
|
+
const minLen = bc.offset + min | 0;
|
|
14262
|
+
if (minLen > bc.bytes.length) {
|
|
14263
|
+
grow(bc, minLen);
|
|
14232
14264
|
}
|
|
14233
|
-
bc.offset = offset;
|
|
14234
14265
|
}
|
|
14235
|
-
function
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14266
|
+
function grow(bc, minLen) {
|
|
14267
|
+
if (minLen > bc.config.maxBufferLength) {
|
|
14268
|
+
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14269
|
+
}
|
|
14270
|
+
const buffer = bc.bytes.buffer;
|
|
14271
|
+
let newBytes;
|
|
14272
|
+
if (isEs2024ArrayBufferLike(buffer) && // Make sure that the view covers the end of the buffer.
|
|
14273
|
+
// If it is not the case, this indicates that the user don't want
|
|
14274
|
+
// to override the trailing bytes.
|
|
14275
|
+
bc.bytes.byteOffset + bc.bytes.byteLength === buffer.byteLength && bc.bytes.byteLength + minLen <= buffer.maxByteLength) {
|
|
14276
|
+
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength, buffer.maxByteLength);
|
|
14277
|
+
if (buffer instanceof ArrayBuffer) {
|
|
14278
|
+
buffer.resize(newLen);
|
|
14279
|
+
} else {
|
|
14280
|
+
buffer.grow(newLen);
|
|
14247
14281
|
}
|
|
14282
|
+
newBytes = new Uint8Array(buffer, bc.bytes.byteOffset, newLen);
|
|
14283
|
+
} else {
|
|
14284
|
+
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength);
|
|
14285
|
+
newBytes = new Uint8Array(newLen);
|
|
14286
|
+
newBytes.set(bc.bytes);
|
|
14248
14287
|
}
|
|
14249
|
-
|
|
14288
|
+
bc.bytes = newBytes;
|
|
14289
|
+
bc.view = new DataView(newBytes.buffer);
|
|
14250
14290
|
}
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/config.js
|
|
14255
|
-
function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32 }) {
|
|
14256
|
-
if (DEV) {
|
|
14257
|
-
assert2(isU32(initialBufferLength), TOO_LARGE_NUMBER);
|
|
14258
|
-
assert2(isU32(maxBufferLength), TOO_LARGE_NUMBER);
|
|
14259
|
-
assert2(initialBufferLength <= maxBufferLength, "initialBufferLength must be lower than or equal to maxBufferLength");
|
|
14260
|
-
}
|
|
14261
|
-
return {
|
|
14262
|
-
initialBufferLength,
|
|
14263
|
-
maxBufferLength
|
|
14264
|
-
};
|
|
14291
|
+
function isEs2024ArrayBufferLike(buffer) {
|
|
14292
|
+
return "maxByteLength" in buffer;
|
|
14265
14293
|
}
|
|
14266
14294
|
|
|
14267
|
-
//
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14295
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/fixed-primitive.js
|
|
14296
|
+
function readBool(bc) {
|
|
14297
|
+
const val = readU8(bc);
|
|
14298
|
+
if (val > 1) {
|
|
14299
|
+
bc.offset--;
|
|
14300
|
+
throw new BareError(bc.offset, "a bool must be equal to 0 or 1");
|
|
14301
|
+
}
|
|
14302
|
+
return val > 0;
|
|
14271
14303
|
}
|
|
14272
|
-
function
|
|
14273
|
-
|
|
14304
|
+
function writeBool(bc, x) {
|
|
14305
|
+
writeU8(bc, x ? 1 : 0);
|
|
14274
14306
|
}
|
|
14275
|
-
function
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
iteration: readU32(bc)
|
|
14279
|
-
};
|
|
14307
|
+
function readU8(bc) {
|
|
14308
|
+
check2(bc, 1);
|
|
14309
|
+
return bc.bytes[bc.offset++];
|
|
14280
14310
|
}
|
|
14281
|
-
function
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
switch (tag) {
|
|
14285
|
-
case 0:
|
|
14286
|
-
return { tag: "WorkflowNameIndex", val: readWorkflowNameIndex(bc) };
|
|
14287
|
-
case 1:
|
|
14288
|
-
return {
|
|
14289
|
-
tag: "WorkflowLoopIterationMarker",
|
|
14290
|
-
val: readWorkflowLoopIterationMarker(bc)
|
|
14291
|
-
};
|
|
14292
|
-
default: {
|
|
14293
|
-
bc.offset = offset;
|
|
14294
|
-
throw new BareError(offset, "invalid tag");
|
|
14295
|
-
}
|
|
14311
|
+
function writeU8(bc, x) {
|
|
14312
|
+
if (DEV) {
|
|
14313
|
+
assert2(isU8(x), TOO_LARGE_NUMBER);
|
|
14296
14314
|
}
|
|
14315
|
+
reserve(bc, 1);
|
|
14316
|
+
bc.bytes[bc.offset++] = x;
|
|
14297
14317
|
}
|
|
14298
|
-
function
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
}
|
|
14303
|
-
const result = [readWorkflowPathSegment(bc)];
|
|
14304
|
-
for (let i = 1; i < len; i++) {
|
|
14305
|
-
result[i] = readWorkflowPathSegment(bc);
|
|
14306
|
-
}
|
|
14318
|
+
function readU32(bc) {
|
|
14319
|
+
check2(bc, 4);
|
|
14320
|
+
const result = bc.view.getUint32(bc.offset, true);
|
|
14321
|
+
bc.offset += 4;
|
|
14307
14322
|
return result;
|
|
14308
14323
|
}
|
|
14309
|
-
function
|
|
14310
|
-
|
|
14311
|
-
const
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
return "PENDING";
|
|
14315
|
-
case 1:
|
|
14316
|
-
return "RUNNING";
|
|
14317
|
-
case 2:
|
|
14318
|
-
return "COMPLETED";
|
|
14319
|
-
case 3:
|
|
14320
|
-
return "FAILED";
|
|
14321
|
-
case 4:
|
|
14322
|
-
return "EXHAUSTED";
|
|
14323
|
-
default: {
|
|
14324
|
-
bc.offset = offset;
|
|
14325
|
-
throw new BareError(offset, "invalid tag");
|
|
14326
|
-
}
|
|
14327
|
-
}
|
|
14324
|
+
function readU64(bc) {
|
|
14325
|
+
check2(bc, 8);
|
|
14326
|
+
const result = bc.view.getBigUint64(bc.offset, true);
|
|
14327
|
+
bc.offset += 8;
|
|
14328
|
+
return result;
|
|
14328
14329
|
}
|
|
14329
|
-
function
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
switch (tag) {
|
|
14333
|
-
case 0:
|
|
14334
|
-
return "PENDING";
|
|
14335
|
-
case 1:
|
|
14336
|
-
return "COMPLETED";
|
|
14337
|
-
case 2:
|
|
14338
|
-
return "INTERRUPTED";
|
|
14339
|
-
default: {
|
|
14340
|
-
bc.offset = offset;
|
|
14341
|
-
throw new BareError(offset, "invalid tag");
|
|
14342
|
-
}
|
|
14330
|
+
function writeU64(bc, x) {
|
|
14331
|
+
if (DEV) {
|
|
14332
|
+
assert2(isU64(x), TOO_LARGE_NUMBER);
|
|
14343
14333
|
}
|
|
14334
|
+
reserve(bc, 8);
|
|
14335
|
+
bc.view.setBigUint64(bc.offset, x, true);
|
|
14336
|
+
bc.offset += 8;
|
|
14344
14337
|
}
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14338
|
+
|
|
14339
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/uint.js
|
|
14340
|
+
function readUint(bc) {
|
|
14341
|
+
let low = readU8(bc);
|
|
14342
|
+
if (low >= 128) {
|
|
14343
|
+
low &= 127;
|
|
14344
|
+
let shiftMul = 128;
|
|
14345
|
+
let byteCount = 1;
|
|
14346
|
+
let byte;
|
|
14347
|
+
do {
|
|
14348
|
+
byte = readU8(bc);
|
|
14349
|
+
low += (byte & 127) * shiftMul;
|
|
14350
|
+
shiftMul *= /* 2**7 */
|
|
14351
|
+
128;
|
|
14352
|
+
byteCount++;
|
|
14353
|
+
} while (byte >= 128 && byteCount < 7);
|
|
14354
|
+
let height = 0;
|
|
14355
|
+
shiftMul = 1;
|
|
14356
|
+
while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
|
|
14357
|
+
byte = readU8(bc);
|
|
14358
|
+
height += (byte & 127) * shiftMul;
|
|
14359
|
+
shiftMul *= /* 2**7 */
|
|
14360
|
+
128;
|
|
14361
|
+
byteCount++;
|
|
14362
|
+
}
|
|
14363
|
+
if (byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
|
|
14364
|
+
bc.offset -= byteCount;
|
|
14365
|
+
throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
|
|
14362
14366
|
}
|
|
14367
|
+
return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
|
|
14363
14368
|
}
|
|
14369
|
+
return BigInt(low);
|
|
14364
14370
|
}
|
|
14365
|
-
function
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
function readWorkflowStepEntry(bc) {
|
|
14372
|
-
return {
|
|
14373
|
-
output: read0(bc),
|
|
14374
|
-
error: read1(bc)
|
|
14375
|
-
};
|
|
14376
|
-
}
|
|
14377
|
-
function readWorkflowLoopEntry(bc) {
|
|
14378
|
-
return {
|
|
14379
|
-
state: readWorkflowCbor(bc),
|
|
14380
|
-
iteration: readU32(bc),
|
|
14381
|
-
output: read0(bc)
|
|
14382
|
-
};
|
|
14383
|
-
}
|
|
14384
|
-
function readWorkflowSleepEntry(bc) {
|
|
14385
|
-
return {
|
|
14386
|
-
deadline: readU64(bc),
|
|
14387
|
-
state: readWorkflowSleepState(bc)
|
|
14388
|
-
};
|
|
14371
|
+
function writeUint(bc, x) {
|
|
14372
|
+
const truncated = BigInt.asUintN(64, x);
|
|
14373
|
+
if (DEV) {
|
|
14374
|
+
assert2(truncated === x, TOO_LARGE_NUMBER);
|
|
14375
|
+
}
|
|
14376
|
+
writeUintTruncated(bc, truncated);
|
|
14389
14377
|
}
|
|
14390
|
-
function
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14378
|
+
function writeUintTruncated(bc, x) {
|
|
14379
|
+
let tmp = Number(BigInt.asUintN(7 * 7, x));
|
|
14380
|
+
let rest = Number(x >> BigInt(7 * 7));
|
|
14381
|
+
let byteCount = 0;
|
|
14382
|
+
while (tmp >= 128 || rest > 0) {
|
|
14383
|
+
writeU8(bc, 128 | tmp & 127);
|
|
14384
|
+
tmp = Math.floor(tmp / /* 2**7 */
|
|
14385
|
+
128);
|
|
14386
|
+
byteCount++;
|
|
14387
|
+
if (byteCount === 7) {
|
|
14388
|
+
tmp = rest;
|
|
14389
|
+
rest = 0;
|
|
14390
|
+
}
|
|
14391
|
+
}
|
|
14392
|
+
writeU8(bc, tmp);
|
|
14395
14393
|
}
|
|
14396
|
-
function
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14394
|
+
function readUintSafe32(bc) {
|
|
14395
|
+
let result = readU8(bc);
|
|
14396
|
+
if (result >= 128) {
|
|
14397
|
+
result &= 127;
|
|
14398
|
+
let shift = 7;
|
|
14399
|
+
let byteCount = 1;
|
|
14400
|
+
let byte;
|
|
14401
|
+
do {
|
|
14402
|
+
byte = readU8(bc);
|
|
14403
|
+
result += (byte & 127) << shift >>> 0;
|
|
14404
|
+
shift += 7;
|
|
14405
|
+
byteCount++;
|
|
14406
|
+
} while (byte >= 128 && byteCount < UINT_SAFE32_MAX_BYTE_COUNT);
|
|
14407
|
+
if (byte === 0) {
|
|
14408
|
+
bc.offset -= byteCount - 1;
|
|
14409
|
+
throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
|
|
14410
|
+
}
|
|
14411
|
+
if (byteCount === UINT_SAFE32_MAX_BYTE_COUNT && byte > 15) {
|
|
14412
|
+
bc.offset -= byteCount - 1;
|
|
14413
|
+
throw new BareError(bc.offset, TOO_LARGE_NUMBER);
|
|
14414
|
+
}
|
|
14415
|
+
}
|
|
14416
|
+
return result;
|
|
14400
14417
|
}
|
|
14401
|
-
function
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14418
|
+
function writeUintSafe32(bc, x) {
|
|
14419
|
+
if (DEV) {
|
|
14420
|
+
assert2(isU32(x), TOO_LARGE_NUMBER);
|
|
14421
|
+
}
|
|
14422
|
+
let zigZag = x >>> 0;
|
|
14423
|
+
while (zigZag >= 128) {
|
|
14424
|
+
writeU8(bc, 128 | zigZag & 127);
|
|
14425
|
+
zigZag >>>= 7;
|
|
14426
|
+
}
|
|
14427
|
+
writeU8(bc, zigZag);
|
|
14407
14428
|
}
|
|
14408
|
-
function
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14429
|
+
function readUintSafe(bc) {
|
|
14430
|
+
let result = readU8(bc);
|
|
14431
|
+
if (result >= 128) {
|
|
14432
|
+
result &= 127;
|
|
14433
|
+
let shiftMul = (
|
|
14434
|
+
/* 2**7 */
|
|
14435
|
+
128
|
|
14436
|
+
);
|
|
14437
|
+
let byteCount = 1;
|
|
14438
|
+
let byte;
|
|
14439
|
+
do {
|
|
14440
|
+
byte = readU8(bc);
|
|
14441
|
+
result += (byte & 127) * shiftMul;
|
|
14442
|
+
shiftMul *= /* 2**7 */
|
|
14443
|
+
128;
|
|
14444
|
+
byteCount++;
|
|
14445
|
+
} while (byte >= 128 && byteCount < INT_SAFE_MAX_BYTE_COUNT);
|
|
14446
|
+
if (byte === 0) {
|
|
14447
|
+
bc.offset -= byteCount - 1;
|
|
14448
|
+
throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
|
|
14449
|
+
}
|
|
14450
|
+
if (byteCount === INT_SAFE_MAX_BYTE_COUNT && byte > 15) {
|
|
14451
|
+
bc.offset -= byteCount - 1;
|
|
14452
|
+
throw new BareError(bc.offset, TOO_LARGE_NUMBER);
|
|
14417
14453
|
}
|
|
14418
|
-
result.set(key, readWorkflowBranchStatus(bc));
|
|
14419
14454
|
}
|
|
14420
14455
|
return result;
|
|
14421
14456
|
}
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14457
|
+
|
|
14458
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/u8-array.js
|
|
14459
|
+
function readU8Array(bc) {
|
|
14460
|
+
return readU8FixedArray(bc, readUintSafe32(bc));
|
|
14426
14461
|
}
|
|
14427
|
-
function
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
branches: read2(bc)
|
|
14431
|
-
};
|
|
14462
|
+
function writeU8Array(bc, x) {
|
|
14463
|
+
writeUintSafe32(bc, x.length);
|
|
14464
|
+
writeU8FixedArray(bc, x);
|
|
14432
14465
|
}
|
|
14433
|
-
function
|
|
14434
|
-
return
|
|
14435
|
-
originalType: readString(bc),
|
|
14436
|
-
originalName: read1(bc)
|
|
14437
|
-
};
|
|
14466
|
+
function readU8FixedArray(bc, len) {
|
|
14467
|
+
return readUnsafeU8FixedArray(bc, len).slice();
|
|
14438
14468
|
}
|
|
14439
|
-
function
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14469
|
+
function writeU8FixedArray(bc, x) {
|
|
14470
|
+
const len = x.length;
|
|
14471
|
+
if (len > 0) {
|
|
14472
|
+
reserve(bc, len);
|
|
14473
|
+
bc.bytes.set(x, bc.offset);
|
|
14474
|
+
bc.offset += len;
|
|
14475
|
+
}
|
|
14444
14476
|
}
|
|
14445
|
-
function
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
switch (tag) {
|
|
14449
|
-
case 0:
|
|
14450
|
-
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
14451
|
-
case 1:
|
|
14452
|
-
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
14453
|
-
case 2:
|
|
14454
|
-
return {
|
|
14455
|
-
tag: "WorkflowSleepEntry",
|
|
14456
|
-
val: readWorkflowSleepEntry(bc)
|
|
14457
|
-
};
|
|
14458
|
-
case 3:
|
|
14459
|
-
return {
|
|
14460
|
-
tag: "WorkflowMessageEntry",
|
|
14461
|
-
val: readWorkflowMessageEntry(bc)
|
|
14462
|
-
};
|
|
14463
|
-
case 4:
|
|
14464
|
-
return {
|
|
14465
|
-
tag: "WorkflowRollbackCheckpointEntry",
|
|
14466
|
-
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
14467
|
-
};
|
|
14468
|
-
case 5:
|
|
14469
|
-
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14470
|
-
case 6:
|
|
14471
|
-
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14472
|
-
case 7:
|
|
14473
|
-
return {
|
|
14474
|
-
tag: "WorkflowRemovedEntry",
|
|
14475
|
-
val: readWorkflowRemovedEntry(bc)
|
|
14476
|
-
};
|
|
14477
|
-
case 8:
|
|
14478
|
-
return {
|
|
14479
|
-
tag: "WorkflowVersionCheckEntry",
|
|
14480
|
-
val: readWorkflowVersionCheckEntry(bc)
|
|
14481
|
-
};
|
|
14482
|
-
default: {
|
|
14483
|
-
bc.offset = offset;
|
|
14484
|
-
throw new BareError(offset, "invalid tag");
|
|
14485
|
-
}
|
|
14477
|
+
function readUnsafeU8FixedArray(bc, len) {
|
|
14478
|
+
if (DEV) {
|
|
14479
|
+
assert2(isU32(len));
|
|
14486
14480
|
}
|
|
14481
|
+
check2(bc, len);
|
|
14482
|
+
const offset = bc.offset;
|
|
14483
|
+
bc.offset += len;
|
|
14484
|
+
return bc.bytes.subarray(offset, offset + len);
|
|
14487
14485
|
}
|
|
14488
|
-
|
|
14486
|
+
|
|
14487
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/data.js
|
|
14488
|
+
function readData(bc) {
|
|
14489
|
+
return readU8Array(bc).buffer;
|
|
14490
|
+
}
|
|
14491
|
+
function writeData(bc, x) {
|
|
14492
|
+
writeU8Array(bc, new Uint8Array(x));
|
|
14493
|
+
}
|
|
14494
|
+
|
|
14495
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/string.js
|
|
14496
|
+
function readString(bc) {
|
|
14497
|
+
return readFixedString(bc, readUintSafe32(bc));
|
|
14498
|
+
}
|
|
14499
|
+
function writeString(bc, x) {
|
|
14500
|
+
if (x.length < TEXT_ENCODER_THRESHOLD) {
|
|
14501
|
+
const byteLen = utf8ByteLength(x);
|
|
14502
|
+
writeUintSafe32(bc, byteLen);
|
|
14503
|
+
reserve(bc, byteLen);
|
|
14504
|
+
writeUtf8Js(bc, x);
|
|
14505
|
+
} else {
|
|
14506
|
+
const strBytes = UTF8_ENCODER.encode(x);
|
|
14507
|
+
writeUintSafe32(bc, strBytes.length);
|
|
14508
|
+
writeU8FixedArray(bc, strBytes);
|
|
14509
|
+
}
|
|
14510
|
+
}
|
|
14511
|
+
function readFixedString(bc, byteLen) {
|
|
14512
|
+
if (DEV) {
|
|
14513
|
+
assert2(isU32(byteLen));
|
|
14514
|
+
}
|
|
14515
|
+
if (byteLen < TEXT_DECODER_THRESHOLD) {
|
|
14516
|
+
return readUtf8Js(bc, byteLen);
|
|
14517
|
+
}
|
|
14518
|
+
try {
|
|
14519
|
+
return UTF8_DECODER.decode(readUnsafeU8FixedArray(bc, byteLen));
|
|
14520
|
+
} catch (_cause) {
|
|
14521
|
+
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14522
|
+
}
|
|
14523
|
+
}
|
|
14524
|
+
function readUtf8Js(bc, byteLen) {
|
|
14525
|
+
check2(bc, byteLen);
|
|
14526
|
+
let result = "";
|
|
14527
|
+
const bytes = bc.bytes;
|
|
14528
|
+
let offset = bc.offset;
|
|
14529
|
+
const upperOffset = offset + byteLen;
|
|
14530
|
+
while (offset < upperOffset) {
|
|
14531
|
+
let codePoint = bytes[offset++];
|
|
14532
|
+
if (codePoint > 127) {
|
|
14533
|
+
let malformed = true;
|
|
14534
|
+
const byte1 = codePoint;
|
|
14535
|
+
if (offset < upperOffset && codePoint < 224) {
|
|
14536
|
+
const byte2 = bytes[offset++];
|
|
14537
|
+
codePoint = (byte1 & 31) << 6 | byte2 & 63;
|
|
14538
|
+
malformed = codePoint >> 7 === 0 || // non-canonical char
|
|
14539
|
+
byte1 >> 5 !== 6 || // invalid tag
|
|
14540
|
+
byte2 >> 6 !== 2;
|
|
14541
|
+
} else if (offset + 1 < upperOffset && codePoint < 240) {
|
|
14542
|
+
const byte2 = bytes[offset++];
|
|
14543
|
+
const byte3 = bytes[offset++];
|
|
14544
|
+
codePoint = (byte1 & 15) << 12 | (byte2 & 63) << 6 | byte3 & 63;
|
|
14545
|
+
malformed = codePoint >> 11 === 0 || // non-canonical char or missing data
|
|
14546
|
+
codePoint >> 11 === 27 || // surrogate char (0xD800 <= codePoint <= 0xDFFF)
|
|
14547
|
+
byte1 >> 4 !== 14 || // invalid tag
|
|
14548
|
+
byte2 >> 6 !== 2 || // invalid tag
|
|
14549
|
+
byte3 >> 6 !== 2;
|
|
14550
|
+
} else if (offset + 2 < upperOffset) {
|
|
14551
|
+
const byte2 = bytes[offset++];
|
|
14552
|
+
const byte3 = bytes[offset++];
|
|
14553
|
+
const byte4 = bytes[offset++];
|
|
14554
|
+
codePoint = (byte1 & 7) << 18 | (byte2 & 63) << 12 | (byte3 & 63) << 6 | byte4 & 63;
|
|
14555
|
+
malformed = codePoint >> 16 === 0 || // non-canonical char or missing data
|
|
14556
|
+
codePoint > 1114111 || // too large code point
|
|
14557
|
+
byte1 >> 3 !== 30 || // invalid tag
|
|
14558
|
+
byte2 >> 6 !== 2 || // invalid tag
|
|
14559
|
+
byte3 >> 6 !== 2 || // invalid tag
|
|
14560
|
+
byte4 >> 6 !== 2;
|
|
14561
|
+
}
|
|
14562
|
+
if (malformed) {
|
|
14563
|
+
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14564
|
+
}
|
|
14565
|
+
}
|
|
14566
|
+
result += String.fromCodePoint(codePoint);
|
|
14567
|
+
}
|
|
14568
|
+
bc.offset = offset;
|
|
14569
|
+
return result;
|
|
14570
|
+
}
|
|
14571
|
+
function writeUtf8Js(bc, s) {
|
|
14572
|
+
const bytes = bc.bytes;
|
|
14573
|
+
let offset = bc.offset;
|
|
14574
|
+
let i = 0;
|
|
14575
|
+
while (i < s.length) {
|
|
14576
|
+
const codePoint = s.codePointAt(i++);
|
|
14577
|
+
if (codePoint < 128) {
|
|
14578
|
+
bytes[offset++] = codePoint;
|
|
14579
|
+
} else {
|
|
14580
|
+
if (codePoint < 2048) {
|
|
14581
|
+
bytes[offset++] = 192 | codePoint >> 6;
|
|
14582
|
+
} else {
|
|
14583
|
+
if (codePoint < 65536) {
|
|
14584
|
+
bytes[offset++] = 224 | codePoint >> 12;
|
|
14585
|
+
} else {
|
|
14586
|
+
bytes[offset++] = 240 | codePoint >> 18;
|
|
14587
|
+
bytes[offset++] = 128 | codePoint >> 12 & 63;
|
|
14588
|
+
i++;
|
|
14589
|
+
}
|
|
14590
|
+
bytes[offset++] = 128 | codePoint >> 6 & 63;
|
|
14591
|
+
}
|
|
14592
|
+
bytes[offset++] = 128 | codePoint & 63;
|
|
14593
|
+
}
|
|
14594
|
+
}
|
|
14595
|
+
bc.offset = offset;
|
|
14596
|
+
}
|
|
14597
|
+
function utf8ByteLength(s) {
|
|
14598
|
+
let result = s.length;
|
|
14599
|
+
for (let i = 0; i < s.length; i++) {
|
|
14600
|
+
const codePoint = s.codePointAt(i);
|
|
14601
|
+
if (codePoint > 127) {
|
|
14602
|
+
result++;
|
|
14603
|
+
if (codePoint > 2047) {
|
|
14604
|
+
result++;
|
|
14605
|
+
if (codePoint > 65535) {
|
|
14606
|
+
i++;
|
|
14607
|
+
}
|
|
14608
|
+
}
|
|
14609
|
+
}
|
|
14610
|
+
}
|
|
14611
|
+
return result;
|
|
14612
|
+
}
|
|
14613
|
+
var UTF8_DECODER = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
|
|
14614
|
+
var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
|
|
14615
|
+
|
|
14616
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/config.js
|
|
14617
|
+
function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32 }) {
|
|
14618
|
+
if (DEV) {
|
|
14619
|
+
assert2(isU32(initialBufferLength), TOO_LARGE_NUMBER);
|
|
14620
|
+
assert2(isU32(maxBufferLength), TOO_LARGE_NUMBER);
|
|
14621
|
+
assert2(initialBufferLength <= maxBufferLength, "initialBufferLength must be lower than or equal to maxBufferLength");
|
|
14622
|
+
}
|
|
14489
14623
|
return {
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
kind: readWorkflowEntryKind(bc)
|
|
14624
|
+
initialBufferLength,
|
|
14625
|
+
maxBufferLength
|
|
14493
14626
|
};
|
|
14494
14627
|
}
|
|
14495
|
-
|
|
14496
|
-
|
|
14628
|
+
|
|
14629
|
+
// ../rivetkit/dist/tsup/chunk-MGTSVSUC.js
|
|
14630
|
+
var config2 = /* @__PURE__ */ Config({});
|
|
14631
|
+
function readWorkflowCbor(bc) {
|
|
14632
|
+
return readData(bc);
|
|
14497
14633
|
}
|
|
14498
|
-
function
|
|
14634
|
+
function readWorkflowNameIndex(bc) {
|
|
14635
|
+
return readU32(bc);
|
|
14636
|
+
}
|
|
14637
|
+
function readWorkflowLoopIterationMarker(bc) {
|
|
14499
14638
|
return {
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
attempts: readU32(bc),
|
|
14503
|
-
lastAttemptAt: readU64(bc),
|
|
14504
|
-
createdAt: readU64(bc),
|
|
14505
|
-
completedAt: read3(bc),
|
|
14506
|
-
rollbackCompletedAt: read3(bc),
|
|
14507
|
-
rollbackError: read1(bc)
|
|
14639
|
+
loop: readWorkflowNameIndex(bc),
|
|
14640
|
+
iteration: readU32(bc)
|
|
14508
14641
|
};
|
|
14509
14642
|
}
|
|
14510
|
-
function
|
|
14511
|
-
const
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14643
|
+
function readWorkflowPathSegment(bc) {
|
|
14644
|
+
const offset = bc.offset;
|
|
14645
|
+
const tag = readU8(bc);
|
|
14646
|
+
switch (tag) {
|
|
14647
|
+
case 0:
|
|
14648
|
+
return { tag: "WorkflowNameIndex", val: readWorkflowNameIndex(bc) };
|
|
14649
|
+
case 1:
|
|
14650
|
+
return {
|
|
14651
|
+
tag: "WorkflowLoopIterationMarker",
|
|
14652
|
+
val: readWorkflowLoopIterationMarker(bc)
|
|
14653
|
+
};
|
|
14654
|
+
default: {
|
|
14655
|
+
bc.offset = offset;
|
|
14656
|
+
throw new BareError(offset, "invalid tag");
|
|
14657
|
+
}
|
|
14518
14658
|
}
|
|
14519
|
-
return result;
|
|
14520
14659
|
}
|
|
14521
|
-
function
|
|
14660
|
+
function readWorkflowLocation(bc) {
|
|
14522
14661
|
const len = readUintSafe(bc);
|
|
14523
14662
|
if (len === 0) {
|
|
14524
14663
|
return [];
|
|
14525
14664
|
}
|
|
14526
|
-
const result = [
|
|
14665
|
+
const result = [readWorkflowPathSegment(bc)];
|
|
14527
14666
|
for (let i = 1; i < len; i++) {
|
|
14528
|
-
result[i] =
|
|
14667
|
+
result[i] = readWorkflowPathSegment(bc);
|
|
14529
14668
|
}
|
|
14530
14669
|
return result;
|
|
14531
14670
|
}
|
|
14532
|
-
function
|
|
14533
|
-
const
|
|
14534
|
-
const
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14671
|
+
function readWorkflowEntryStatus(bc) {
|
|
14672
|
+
const offset = bc.offset;
|
|
14673
|
+
const tag = readU8(bc);
|
|
14674
|
+
switch (tag) {
|
|
14675
|
+
case 0:
|
|
14676
|
+
return "PENDING";
|
|
14677
|
+
case 1:
|
|
14678
|
+
return "RUNNING";
|
|
14679
|
+
case 2:
|
|
14680
|
+
return "COMPLETED";
|
|
14681
|
+
case 3:
|
|
14682
|
+
return "FAILED";
|
|
14683
|
+
case 4:
|
|
14684
|
+
return "EXHAUSTED";
|
|
14685
|
+
default: {
|
|
14539
14686
|
bc.offset = offset;
|
|
14540
|
-
throw new BareError(offset, "
|
|
14687
|
+
throw new BareError(offset, "invalid tag");
|
|
14541
14688
|
}
|
|
14542
|
-
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14543
14689
|
}
|
|
14544
|
-
return result;
|
|
14545
|
-
}
|
|
14546
|
-
function readWorkflowHistory(bc) {
|
|
14547
|
-
return {
|
|
14548
|
-
nameRegistry: read4(bc),
|
|
14549
|
-
entries: read5(bc),
|
|
14550
|
-
entryMetadata: read6(bc)
|
|
14551
|
-
};
|
|
14552
14690
|
}
|
|
14553
|
-
function
|
|
14554
|
-
const
|
|
14555
|
-
const
|
|
14556
|
-
|
|
14557
|
-
|
|
14691
|
+
function readWorkflowSleepState(bc) {
|
|
14692
|
+
const offset = bc.offset;
|
|
14693
|
+
const tag = readU8(bc);
|
|
14694
|
+
switch (tag) {
|
|
14695
|
+
case 0:
|
|
14696
|
+
return "PENDING";
|
|
14697
|
+
case 1:
|
|
14698
|
+
return "COMPLETED";
|
|
14699
|
+
case 2:
|
|
14700
|
+
return "INTERRUPTED";
|
|
14701
|
+
default: {
|
|
14702
|
+
bc.offset = offset;
|
|
14703
|
+
throw new BareError(offset, "invalid tag");
|
|
14704
|
+
}
|
|
14558
14705
|
}
|
|
14559
|
-
return result;
|
|
14560
|
-
}
|
|
14561
|
-
function decodeWorkflowHistoryTransport(data) {
|
|
14562
|
-
return decodeWorkflowHistory(toUint8Array(data));
|
|
14563
14706
|
}
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14707
|
+
function readWorkflowBranchStatusType(bc) {
|
|
14708
|
+
const offset = bc.offset;
|
|
14709
|
+
const tag = readU8(bc);
|
|
14710
|
+
switch (tag) {
|
|
14711
|
+
case 0:
|
|
14712
|
+
return "PENDING";
|
|
14713
|
+
case 1:
|
|
14714
|
+
return "RUNNING";
|
|
14715
|
+
case 2:
|
|
14716
|
+
return "COMPLETED";
|
|
14717
|
+
case 3:
|
|
14718
|
+
return "FAILED";
|
|
14719
|
+
case 4:
|
|
14720
|
+
return "CANCELLED";
|
|
14721
|
+
default: {
|
|
14722
|
+
bc.offset = offset;
|
|
14723
|
+
throw new BareError(offset, "invalid tag");
|
|
14724
|
+
}
|
|
14725
|
+
}
|
|
14726
|
+
}
|
|
14727
|
+
function read0(bc) {
|
|
14728
|
+
return readBool(bc) ? readWorkflowCbor(bc) : null;
|
|
14729
|
+
}
|
|
14730
|
+
function read1(bc) {
|
|
14731
|
+
return readBool(bc) ? readString(bc) : null;
|
|
14732
|
+
}
|
|
14733
|
+
function readWorkflowStepEntry(bc) {
|
|
14734
|
+
return {
|
|
14735
|
+
output: read0(bc),
|
|
14736
|
+
error: read1(bc)
|
|
14737
|
+
};
|
|
14738
|
+
}
|
|
14739
|
+
function readWorkflowLoopEntry(bc) {
|
|
14740
|
+
return {
|
|
14741
|
+
state: readWorkflowCbor(bc),
|
|
14742
|
+
iteration: readU32(bc),
|
|
14743
|
+
output: read0(bc)
|
|
14744
|
+
};
|
|
14745
|
+
}
|
|
14746
|
+
function readWorkflowSleepEntry(bc) {
|
|
14747
|
+
return {
|
|
14748
|
+
deadline: readU64(bc),
|
|
14749
|
+
state: readWorkflowSleepState(bc)
|
|
14750
|
+
};
|
|
14751
|
+
}
|
|
14752
|
+
function readWorkflowMessageEntry(bc) {
|
|
14753
|
+
return {
|
|
14754
|
+
name: readString(bc),
|
|
14755
|
+
messageData: readWorkflowCbor(bc)
|
|
14756
|
+
};
|
|
14757
|
+
}
|
|
14758
|
+
function readWorkflowRollbackCheckpointEntry(bc) {
|
|
14759
|
+
return {
|
|
14760
|
+
name: readString(bc)
|
|
14761
|
+
};
|
|
14762
|
+
}
|
|
14763
|
+
function readWorkflowBranchStatus(bc) {
|
|
14764
|
+
return {
|
|
14765
|
+
status: readWorkflowBranchStatusType(bc),
|
|
14766
|
+
output: read0(bc),
|
|
14767
|
+
error: read1(bc)
|
|
14768
|
+
};
|
|
14769
|
+
}
|
|
14770
|
+
function read2(bc) {
|
|
14771
|
+
const len = readUintSafe(bc);
|
|
14772
|
+
const result = /* @__PURE__ */ new Map();
|
|
14773
|
+
for (let i = 0; i < len; i++) {
|
|
14774
|
+
const offset = bc.offset;
|
|
14775
|
+
const key = readString(bc);
|
|
14776
|
+
if (result.has(key)) {
|
|
14777
|
+
bc.offset = offset;
|
|
14778
|
+
throw new BareError(offset, "duplicated key");
|
|
14779
|
+
}
|
|
14780
|
+
result.set(key, readWorkflowBranchStatus(bc));
|
|
14781
|
+
}
|
|
14782
|
+
return result;
|
|
14783
|
+
}
|
|
14784
|
+
function readWorkflowJoinEntry(bc) {
|
|
14785
|
+
return {
|
|
14786
|
+
branches: read2(bc)
|
|
14787
|
+
};
|
|
14788
|
+
}
|
|
14789
|
+
function readWorkflowRaceEntry(bc) {
|
|
14790
|
+
return {
|
|
14791
|
+
winner: read1(bc),
|
|
14792
|
+
branches: read2(bc)
|
|
14793
|
+
};
|
|
14794
|
+
}
|
|
14795
|
+
function readWorkflowRemovedEntry(bc) {
|
|
14796
|
+
return {
|
|
14797
|
+
originalType: readString(bc),
|
|
14798
|
+
originalName: read1(bc)
|
|
14799
|
+
};
|
|
14800
|
+
}
|
|
14801
|
+
function readWorkflowVersionCheckEntry(bc) {
|
|
14802
|
+
return {
|
|
14803
|
+
resolved: readU32(bc),
|
|
14804
|
+
latest: readU32(bc)
|
|
14805
|
+
};
|
|
14806
|
+
}
|
|
14807
|
+
function readWorkflowEntryKind(bc) {
|
|
14808
|
+
const offset = bc.offset;
|
|
14809
|
+
const tag = readU8(bc);
|
|
14810
|
+
switch (tag) {
|
|
14811
|
+
case 0:
|
|
14812
|
+
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
14813
|
+
case 1:
|
|
14814
|
+
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
14815
|
+
case 2:
|
|
14816
|
+
return {
|
|
14817
|
+
tag: "WorkflowSleepEntry",
|
|
14818
|
+
val: readWorkflowSleepEntry(bc)
|
|
14819
|
+
};
|
|
14820
|
+
case 3:
|
|
14821
|
+
return {
|
|
14822
|
+
tag: "WorkflowMessageEntry",
|
|
14823
|
+
val: readWorkflowMessageEntry(bc)
|
|
14824
|
+
};
|
|
14825
|
+
case 4:
|
|
14826
|
+
return {
|
|
14827
|
+
tag: "WorkflowRollbackCheckpointEntry",
|
|
14828
|
+
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
14829
|
+
};
|
|
14830
|
+
case 5:
|
|
14831
|
+
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14832
|
+
case 6:
|
|
14833
|
+
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14834
|
+
case 7:
|
|
14835
|
+
return {
|
|
14836
|
+
tag: "WorkflowRemovedEntry",
|
|
14837
|
+
val: readWorkflowRemovedEntry(bc)
|
|
14838
|
+
};
|
|
14839
|
+
case 8:
|
|
14840
|
+
return {
|
|
14841
|
+
tag: "WorkflowVersionCheckEntry",
|
|
14842
|
+
val: readWorkflowVersionCheckEntry(bc)
|
|
14843
|
+
};
|
|
14844
|
+
default: {
|
|
14845
|
+
bc.offset = offset;
|
|
14846
|
+
throw new BareError(offset, "invalid tag");
|
|
14847
|
+
}
|
|
14848
|
+
}
|
|
14849
|
+
}
|
|
14850
|
+
function readWorkflowEntry(bc) {
|
|
14851
|
+
return {
|
|
14852
|
+
id: readString(bc),
|
|
14853
|
+
location: readWorkflowLocation(bc),
|
|
14854
|
+
kind: readWorkflowEntryKind(bc)
|
|
14855
|
+
};
|
|
14856
|
+
}
|
|
14857
|
+
function read3(bc) {
|
|
14858
|
+
return readBool(bc) ? readU64(bc) : null;
|
|
14859
|
+
}
|
|
14860
|
+
function readWorkflowEntryMetadata(bc) {
|
|
14861
|
+
return {
|
|
14862
|
+
status: readWorkflowEntryStatus(bc),
|
|
14863
|
+
error: read1(bc),
|
|
14864
|
+
attempts: readU32(bc),
|
|
14865
|
+
lastAttemptAt: readU64(bc),
|
|
14866
|
+
createdAt: readU64(bc),
|
|
14867
|
+
completedAt: read3(bc),
|
|
14868
|
+
rollbackCompletedAt: read3(bc),
|
|
14869
|
+
rollbackError: read1(bc)
|
|
14870
|
+
};
|
|
14871
|
+
}
|
|
14872
|
+
function read4(bc) {
|
|
14873
|
+
const len = readUintSafe(bc);
|
|
14874
|
+
if (len === 0) {
|
|
14875
|
+
return [];
|
|
14876
|
+
}
|
|
14877
|
+
const result = [readString(bc)];
|
|
14878
|
+
for (let i = 1; i < len; i++) {
|
|
14879
|
+
result[i] = readString(bc);
|
|
14880
|
+
}
|
|
14881
|
+
return result;
|
|
14882
|
+
}
|
|
14883
|
+
function read5(bc) {
|
|
14884
|
+
const len = readUintSafe(bc);
|
|
14885
|
+
if (len === 0) {
|
|
14886
|
+
return [];
|
|
14887
|
+
}
|
|
14888
|
+
const result = [readWorkflowEntry(bc)];
|
|
14889
|
+
for (let i = 1; i < len; i++) {
|
|
14890
|
+
result[i] = readWorkflowEntry(bc);
|
|
14891
|
+
}
|
|
14892
|
+
return result;
|
|
14893
|
+
}
|
|
14894
|
+
function read6(bc) {
|
|
14895
|
+
const len = readUintSafe(bc);
|
|
14896
|
+
const result = /* @__PURE__ */ new Map();
|
|
14897
|
+
for (let i = 0; i < len; i++) {
|
|
14898
|
+
const offset = bc.offset;
|
|
14899
|
+
const key = readString(bc);
|
|
14900
|
+
if (result.has(key)) {
|
|
14901
|
+
bc.offset = offset;
|
|
14902
|
+
throw new BareError(offset, "duplicated key");
|
|
14903
|
+
}
|
|
14904
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14905
|
+
}
|
|
14906
|
+
return result;
|
|
14907
|
+
}
|
|
14908
|
+
function readWorkflowHistory(bc) {
|
|
14909
|
+
return {
|
|
14910
|
+
nameRegistry: read4(bc),
|
|
14911
|
+
entries: read5(bc),
|
|
14912
|
+
entryMetadata: read6(bc)
|
|
14913
|
+
};
|
|
14914
|
+
}
|
|
14915
|
+
function decodeWorkflowHistory(bytes) {
|
|
14916
|
+
const bc = new ByteCursor(bytes, config2);
|
|
14917
|
+
const result = readWorkflowHistory(bc);
|
|
14918
|
+
if (bc.offset < bc.view.byteLength) {
|
|
14919
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
14920
|
+
}
|
|
14921
|
+
return result;
|
|
14922
|
+
}
|
|
14923
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
14924
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
14925
|
+
}
|
|
14926
|
+
|
|
14927
|
+
// ../rivetkit/dist/tsup/chunk-SHBE77IT.js
|
|
14928
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
14929
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
14930
|
+
"rivetkit.actor_context_internal"
|
|
14931
|
+
);
|
|
14932
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
14933
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
14572
14934
|
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
14573
14935
|
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
14574
14936
|
getHistory: zFunction(),
|
|
@@ -14583,6 +14945,7 @@ var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
|
14583
14945
|
"database",
|
|
14584
14946
|
"state",
|
|
14585
14947
|
"queue",
|
|
14948
|
+
"schedules",
|
|
14586
14949
|
"connections",
|
|
14587
14950
|
"console"
|
|
14588
14951
|
];
|
|
@@ -14679,6 +15042,8 @@ var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
|
14679
15042
|
name: external_exports.string().optional(),
|
|
14680
15043
|
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
14681
15044
|
icon: external_exports.string().optional(),
|
|
15045
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
15046
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
14682
15047
|
/**
|
|
14683
15048
|
* Can hibernate WebSockets for onWebSocket.
|
|
14684
15049
|
*
|
|
@@ -14710,10 +15075,12 @@ var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
|
14710
15075
|
noSleep: external_exports.boolean().default(false),
|
|
14711
15076
|
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
14712
15077
|
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15078
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
15079
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
14713
15080
|
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
14714
|
-
/**
|
|
15081
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
14715
15082
|
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
14716
|
-
/**
|
|
15083
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
14717
15084
|
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
14718
15085
|
}).strict();
|
|
14719
15086
|
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
@@ -14772,6 +15139,9 @@ var DocActorOptionsSchema = external_exports.object({
|
|
|
14772
15139
|
icon: external_exports.string().optional().describe(
|
|
14773
15140
|
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
14774
15141
|
),
|
|
15142
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
15143
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
15144
|
+
),
|
|
14775
15145
|
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
14776
15146
|
createConnStateTimeout: external_exports.number().optional().describe(
|
|
14777
15147
|
"Timeout in ms for createConnState handler. Default: 5000"
|
|
@@ -14809,17 +15179,14 @@ var DocActorOptionsSchema = external_exports.object({
|
|
|
14809
15179
|
maxQueueSize: external_exports.number().optional().describe(
|
|
14810
15180
|
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
14811
15181
|
),
|
|
15182
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15183
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15184
|
+
),
|
|
14812
15185
|
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
14813
15186
|
"Maximum size of each queue message in bytes. Default: 65536"
|
|
14814
15187
|
),
|
|
14815
15188
|
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
14816
15189
|
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
14817
|
-
),
|
|
14818
|
-
preloadMaxWorkflowBytes: external_exports.number().optional().describe(
|
|
14819
|
-
"Override RivetKit's workflow preload budget for this actor. Set to 0 to disable workflow preloading."
|
|
14820
|
-
),
|
|
14821
|
-
preloadMaxConnectionsBytes: external_exports.number().optional().describe(
|
|
14822
|
-
"Override RivetKit's connections preload budget for this actor. Set to 0 to disable connections preloading."
|
|
14823
15190
|
)
|
|
14824
15191
|
}).describe("Actor options for timeouts and behavior configuration.");
|
|
14825
15192
|
var DocActorConfigSchema = external_exports.object({
|
|
@@ -14891,7 +15258,7 @@ var DocActorConfigSchema = external_exports.object({
|
|
|
14891
15258
|
options: DocActorOptionsSchema.optional()
|
|
14892
15259
|
}).describe("Actor configuration passed to the actor() function.");
|
|
14893
15260
|
|
|
14894
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15261
|
+
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
14895
15262
|
var EMPTY_KEY = "/";
|
|
14896
15263
|
var KEY_SEPARATOR = "/";
|
|
14897
15264
|
var KEYS = {
|
|
@@ -14934,450 +15301,109 @@ var QUEUE_METADATA_KEY = concatPrefix(
|
|
|
14934
15301
|
);
|
|
14935
15302
|
var QUEUE_MESSAGES_PREFIX = concatPrefix(
|
|
14936
15303
|
QUEUE_STORAGE_PREFIX,
|
|
14937
|
-
QUEUE_NAMESPACE.MESSAGES
|
|
14938
|
-
);
|
|
14939
|
-
var WORKFLOW_STORAGE_PREFIX = concatPrefix(
|
|
14940
|
-
KEYS.WORKFLOW_PREFIX,
|
|
14941
|
-
STORAGE_VERSION_BYTES.WORKFLOW
|
|
14942
|
-
);
|
|
14943
|
-
var TRACES_STORAGE_PREFIX = concatPrefix(
|
|
14944
|
-
KEYS.TRACES_PREFIX,
|
|
14945
|
-
STORAGE_VERSION_BYTES.TRACES
|
|
14946
|
-
);
|
|
14947
|
-
function serializeActorKey(key) {
|
|
14948
|
-
if (key.length === 0) {
|
|
14949
|
-
return EMPTY_KEY;
|
|
14950
|
-
}
|
|
14951
|
-
const escapedParts = key.map((part) => {
|
|
14952
|
-
if (part === "") {
|
|
14953
|
-
return "\\0";
|
|
14954
|
-
}
|
|
14955
|
-
let escaped = part.replace(/\\/g, "\\\\");
|
|
14956
|
-
escaped = escaped.replace(/\//g, `\\${KEY_SEPARATOR}`);
|
|
14957
|
-
return escaped;
|
|
14958
|
-
});
|
|
14959
|
-
return escapedParts.join(KEY_SEPARATOR);
|
|
14960
|
-
}
|
|
14961
|
-
function deserializeActorKey(keyString) {
|
|
14962
|
-
if (keyString === void 0 || keyString === null || keyString === EMPTY_KEY) {
|
|
14963
|
-
return [];
|
|
14964
|
-
}
|
|
14965
|
-
const parts = [];
|
|
14966
|
-
let currentPart = "";
|
|
14967
|
-
let escaping = false;
|
|
14968
|
-
let isEmptyStringMarker = false;
|
|
14969
|
-
for (let i = 0; i < keyString.length; i++) {
|
|
14970
|
-
const char = keyString[i];
|
|
14971
|
-
if (escaping) {
|
|
14972
|
-
if (char === "0") {
|
|
14973
|
-
isEmptyStringMarker = true;
|
|
14974
|
-
} else {
|
|
14975
|
-
currentPart += char;
|
|
14976
|
-
}
|
|
14977
|
-
escaping = false;
|
|
14978
|
-
} else if (char === "\\") {
|
|
14979
|
-
escaping = true;
|
|
14980
|
-
} else if (char === KEY_SEPARATOR) {
|
|
14981
|
-
if (isEmptyStringMarker) {
|
|
14982
|
-
parts.push("");
|
|
14983
|
-
isEmptyStringMarker = false;
|
|
14984
|
-
} else {
|
|
14985
|
-
parts.push(currentPart);
|
|
14986
|
-
}
|
|
14987
|
-
currentPart = "";
|
|
14988
|
-
} else {
|
|
14989
|
-
currentPart += char;
|
|
14990
|
-
}
|
|
14991
|
-
}
|
|
14992
|
-
if (escaping) {
|
|
14993
|
-
parts.push(`${currentPart}\\`);
|
|
14994
|
-
} else if (isEmptyStringMarker) {
|
|
14995
|
-
parts.push("");
|
|
14996
|
-
} else if (currentPart !== "" || parts.length > 0) {
|
|
14997
|
-
parts.push(currentPart);
|
|
14998
|
-
}
|
|
14999
|
-
return parts;
|
|
15000
|
-
}
|
|
15001
|
-
function makePrefixedKey(key) {
|
|
15002
|
-
const prefixed = new Uint8Array(KEYS.KV.length + key.length);
|
|
15003
|
-
prefixed.set(KEYS.KV, 0);
|
|
15004
|
-
prefixed.set(key, KEYS.KV.length);
|
|
15005
|
-
return prefixed;
|
|
15006
|
-
}
|
|
15007
|
-
function removePrefixFromKey(prefixedKey) {
|
|
15008
|
-
return prefixedKey.slice(KEYS.KV.length);
|
|
15009
|
-
}
|
|
15010
|
-
function workflowStoragePrefix() {
|
|
15011
|
-
return Uint8Array.from(WORKFLOW_STORAGE_PREFIX);
|
|
15012
|
-
}
|
|
15013
|
-
function queueMetadataKey() {
|
|
15014
|
-
return Uint8Array.from(QUEUE_METADATA_KEY);
|
|
15015
|
-
}
|
|
15016
|
-
function queueMessagesPrefix() {
|
|
15017
|
-
return Uint8Array.from(QUEUE_MESSAGES_PREFIX);
|
|
15018
|
-
}
|
|
15019
|
-
|
|
15020
|
-
// ../rivetkit/dist/tsup/chunk-W6WPKZ6I.js
|
|
15021
|
-
var cbor = __toESM(require("cbor-x"), 1);
|
|
15022
|
-
var import_invariant = __toESM(require_invariant(), 1);
|
|
15023
|
-
var JSON_COMPAT_BIGINT = "$BigInt";
|
|
15024
|
-
var JSON_COMPAT_ARRAY_BUFFER = "$ArrayBuffer";
|
|
15025
|
-
var JSON_COMPAT_UINT8_ARRAY = "$Uint8Array";
|
|
15026
|
-
var JSON_COMPAT_UNDEFINED = "$Undefined";
|
|
15027
|
-
var JSON_COMPAT_SET = "$Set";
|
|
15028
|
-
function isTypedArray(value) {
|
|
15029
|
-
return value instanceof Uint8ClampedArray || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof BigUint64Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array || value instanceof BigInt64Array || value instanceof Float32Array || value instanceof Float64Array;
|
|
15030
|
-
}
|
|
15031
|
-
function assertJsonCompatValue(value, path2 = "") {
|
|
15032
|
-
var _a2;
|
|
15033
|
-
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
15034
|
-
return;
|
|
15035
|
-
}
|
|
15036
|
-
if (typeof value === "function") {
|
|
15037
|
-
throw new TypeError(
|
|
15038
|
-
`Value at ${path2 || "root"} is a function and is not CBOR serializable`
|
|
15039
|
-
);
|
|
15040
|
-
}
|
|
15041
|
-
if (typeof value === "symbol") {
|
|
15042
|
-
throw new TypeError(
|
|
15043
|
-
`Value at ${path2 || "root"} is a symbol and is not CBOR serializable`
|
|
15044
|
-
);
|
|
15045
|
-
}
|
|
15046
|
-
if (value instanceof Date || value instanceof RegExp || value instanceof Error || value instanceof ArrayBuffer || value instanceof Uint8Array || isTypedArray(value)) {
|
|
15047
|
-
return;
|
|
15048
|
-
}
|
|
15049
|
-
if (value instanceof WeakMap) {
|
|
15050
|
-
throw new TypeError(
|
|
15051
|
-
`Value at ${path2 || "root"} is a WeakMap and is not CBOR serializable`
|
|
15052
|
-
);
|
|
15053
|
-
}
|
|
15054
|
-
if (value instanceof WeakSet) {
|
|
15055
|
-
throw new TypeError(
|
|
15056
|
-
`Value at ${path2 || "root"} is a WeakSet and is not CBOR serializable`
|
|
15057
|
-
);
|
|
15058
|
-
}
|
|
15059
|
-
if (value instanceof WeakRef) {
|
|
15060
|
-
throw new TypeError(
|
|
15061
|
-
`Value at ${path2 || "root"} is a WeakRef and is not CBOR serializable`
|
|
15062
|
-
);
|
|
15063
|
-
}
|
|
15064
|
-
if (value instanceof Promise) {
|
|
15065
|
-
throw new TypeError(
|
|
15066
|
-
`Value at ${path2 || "root"} is a Promise and is not CBOR serializable`
|
|
15067
|
-
);
|
|
15068
|
-
}
|
|
15069
|
-
if (value instanceof Map) {
|
|
15070
|
-
for (const [k, v] of value.entries()) {
|
|
15071
|
-
assertJsonCompatValue(k, `${path2 || "root"}.key(${String(k)})`);
|
|
15072
|
-
assertJsonCompatValue(v, `${path2 || "root"}.value(${String(k)})`);
|
|
15073
|
-
}
|
|
15074
|
-
return;
|
|
15075
|
-
}
|
|
15076
|
-
if (value instanceof Set) {
|
|
15077
|
-
let index = 0;
|
|
15078
|
-
for (const item of value.values()) {
|
|
15079
|
-
assertJsonCompatValue(item, `${path2 || "root"}.set[${index}]`);
|
|
15080
|
-
index++;
|
|
15081
|
-
}
|
|
15082
|
-
return;
|
|
15083
|
-
}
|
|
15084
|
-
if (Array.isArray(value)) {
|
|
15085
|
-
for (let i = 0; i < value.length; i++) {
|
|
15086
|
-
assertJsonCompatValue(value[i], `${path2 || "root"}[${i}]`);
|
|
15087
|
-
}
|
|
15088
|
-
return;
|
|
15089
|
-
}
|
|
15090
|
-
if (isPlainObject2(value)) {
|
|
15091
|
-
for (const key in value) {
|
|
15092
|
-
assertJsonCompatValue(
|
|
15093
|
-
value[key],
|
|
15094
|
-
path2 ? `${path2}.${key}` : key
|
|
15095
|
-
);
|
|
15096
|
-
}
|
|
15097
|
-
return;
|
|
15098
|
-
}
|
|
15099
|
-
const typeName = typeof value === "object" && value !== null ? ((_a2 = value.constructor) == null ? void 0 : _a2.name) ?? typeof value : typeof value;
|
|
15100
|
-
throw new TypeError(
|
|
15101
|
-
`Value at ${path2 || "root"} of type "${typeName}" is not CBOR serializable`
|
|
15102
|
-
);
|
|
15103
|
-
}
|
|
15104
|
-
var EncodingSchema = external_exports.enum(["json", "cbor", "bare"]);
|
|
15105
|
-
async function inputDataToBuffer(data) {
|
|
15106
|
-
if (typeof data === "string") {
|
|
15107
|
-
return data;
|
|
15108
|
-
}
|
|
15109
|
-
if (data instanceof Blob) {
|
|
15110
|
-
return new Uint8Array(await data.arrayBuffer());
|
|
15111
|
-
}
|
|
15112
|
-
if (data instanceof Uint8Array) {
|
|
15113
|
-
return data;
|
|
15114
|
-
}
|
|
15115
|
-
if (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) {
|
|
15116
|
-
return new Uint8Array(data);
|
|
15117
|
-
}
|
|
15118
|
-
throw new Error("Malformed message");
|
|
15119
|
-
}
|
|
15120
|
-
function base64EncodeUint8Array(uint8Array) {
|
|
15121
|
-
let binary = "";
|
|
15122
|
-
for (const value of uint8Array) {
|
|
15123
|
-
binary += String.fromCharCode(value);
|
|
15124
|
-
}
|
|
15125
|
-
return btoa(binary);
|
|
15126
|
-
}
|
|
15127
|
-
function base64EncodeArrayBuffer(arrayBuffer) {
|
|
15128
|
-
return base64EncodeUint8Array(new Uint8Array(arrayBuffer));
|
|
15129
|
-
}
|
|
15130
|
-
function isPlainObject2(value) {
|
|
15131
|
-
if (value === null || typeof value !== "object") {
|
|
15132
|
-
return false;
|
|
15133
|
-
}
|
|
15134
|
-
const proto = Object.getPrototypeOf(value);
|
|
15135
|
-
return proto === Object.prototype || proto === null;
|
|
15136
|
-
}
|
|
15137
|
-
function encodeJsonCompatValue(input) {
|
|
15138
|
-
var _a2;
|
|
15139
|
-
if (input === null) {
|
|
15140
|
-
return input;
|
|
15141
|
-
}
|
|
15142
|
-
if (input === void 0) {
|
|
15143
|
-
return [JSON_COMPAT_UNDEFINED, 0];
|
|
15144
|
-
}
|
|
15145
|
-
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
|
15146
|
-
return input;
|
|
15147
|
-
}
|
|
15148
|
-
if (typeof input === "bigint") {
|
|
15149
|
-
return [JSON_COMPAT_BIGINT, input.toString()];
|
|
15150
|
-
}
|
|
15151
|
-
if (input instanceof ArrayBuffer) {
|
|
15152
|
-
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];
|
|
15153
|
-
}
|
|
15154
|
-
if (input instanceof Uint8Array) {
|
|
15155
|
-
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];
|
|
15156
|
-
}
|
|
15157
|
-
if (isTypedArray(input)) {
|
|
15158
|
-
return input;
|
|
15159
|
-
}
|
|
15160
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Error) {
|
|
15161
|
-
return input;
|
|
15162
|
-
}
|
|
15163
|
-
if (input instanceof Set) {
|
|
15164
|
-
const encoded = [...input.values()].map(
|
|
15165
|
-
(v) => encodeJsonCompatValue(v)
|
|
15166
|
-
);
|
|
15167
|
-
return [JSON_COMPAT_SET, encoded];
|
|
15168
|
-
}
|
|
15169
|
-
if (input instanceof Map) {
|
|
15170
|
-
const encoded = /* @__PURE__ */ new Map();
|
|
15171
|
-
for (const [k, v] of input.entries()) {
|
|
15172
|
-
encoded.set(
|
|
15173
|
-
encodeJsonCompatValue(k),
|
|
15174
|
-
encodeJsonCompatValue(v)
|
|
15175
|
-
);
|
|
15176
|
-
}
|
|
15177
|
-
return encoded;
|
|
15178
|
-
}
|
|
15179
|
-
if (Array.isArray(input)) {
|
|
15180
|
-
const encoded = input.map(
|
|
15181
|
-
(value) => encodeJsonCompatValue(value)
|
|
15182
|
-
);
|
|
15183
|
-
if (encoded.length === 2 && typeof encoded[0] === "string" && encoded[0].startsWith("$")) {
|
|
15184
|
-
return [`$${encoded[0]}`, encoded[1]];
|
|
15185
|
-
}
|
|
15186
|
-
return encoded;
|
|
15187
|
-
}
|
|
15188
|
-
if (isPlainObject2(input)) {
|
|
15189
|
-
const encoded = {};
|
|
15190
|
-
for (const [key, value] of Object.entries(input)) {
|
|
15191
|
-
encoded[key] = encodeJsonCompatValue(value);
|
|
15192
|
-
}
|
|
15193
|
-
return encoded;
|
|
15194
|
-
}
|
|
15195
|
-
const typeName = typeof input === "object" && input !== null ? ((_a2 = input.constructor) == null ? void 0 : _a2.name) ?? typeof input : typeof input;
|
|
15196
|
-
throw new TypeError(`Value of type "${typeName}" is not CBOR serializable`);
|
|
15197
|
-
}
|
|
15198
|
-
function reviveJsonCompatValue(input, options = {}) {
|
|
15199
|
-
if (typeof input === "bigint") {
|
|
15200
|
-
if (options.coerceSafeIntegerBigInts && input >= BigInt(Number.MIN_SAFE_INTEGER) && input <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
15201
|
-
return Number(input);
|
|
15202
|
-
}
|
|
15203
|
-
return input;
|
|
15304
|
+
QUEUE_NAMESPACE.MESSAGES
|
|
15305
|
+
);
|
|
15306
|
+
var WORKFLOW_STORAGE_PREFIX = concatPrefix(
|
|
15307
|
+
KEYS.WORKFLOW_PREFIX,
|
|
15308
|
+
STORAGE_VERSION_BYTES.WORKFLOW
|
|
15309
|
+
);
|
|
15310
|
+
var TRACES_STORAGE_PREFIX = concatPrefix(
|
|
15311
|
+
KEYS.TRACES_PREFIX,
|
|
15312
|
+
STORAGE_VERSION_BYTES.TRACES
|
|
15313
|
+
);
|
|
15314
|
+
function serializeActorKey(key) {
|
|
15315
|
+
if (key.length === 0) {
|
|
15316
|
+
return EMPTY_KEY;
|
|
15204
15317
|
}
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
revived.set(
|
|
15209
|
-
reviveJsonCompatValue(k, options),
|
|
15210
|
-
reviveJsonCompatValue(v, options)
|
|
15211
|
-
);
|
|
15318
|
+
const escapedParts = key.map((part) => {
|
|
15319
|
+
if (part === "") {
|
|
15320
|
+
return "\\0";
|
|
15212
15321
|
}
|
|
15213
|
-
|
|
15322
|
+
let escaped = part.replace(/\\/g, "\\\\");
|
|
15323
|
+
escaped = escaped.replace(/\//g, `\\${KEY_SEPARATOR}`);
|
|
15324
|
+
return escaped;
|
|
15325
|
+
});
|
|
15326
|
+
return escapedParts.join(KEY_SEPARATOR);
|
|
15327
|
+
}
|
|
15328
|
+
function deserializeActorKey(keyString) {
|
|
15329
|
+
if (keyString === void 0 || keyString === null || keyString === EMPTY_KEY) {
|
|
15330
|
+
return [];
|
|
15214
15331
|
}
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
if (input[0] === JSON_COMPAT_UNDEFINED) {
|
|
15227
|
-
return void 0;
|
|
15228
|
-
}
|
|
15229
|
-
if (input[0] === JSON_COMPAT_SET) {
|
|
15230
|
-
const items = input[1].map(
|
|
15231
|
-
(v) => reviveJsonCompatValue(v, options)
|
|
15232
|
-
);
|
|
15233
|
-
return new Set(items);
|
|
15332
|
+
const parts = [];
|
|
15333
|
+
let currentPart = "";
|
|
15334
|
+
let escaping = false;
|
|
15335
|
+
let isEmptyStringMarker = false;
|
|
15336
|
+
for (let i = 0; i < keyString.length; i++) {
|
|
15337
|
+
const char = keyString[i];
|
|
15338
|
+
if (escaping) {
|
|
15339
|
+
if (char === "0") {
|
|
15340
|
+
isEmptyStringMarker = true;
|
|
15341
|
+
} else {
|
|
15342
|
+
currentPart += char;
|
|
15234
15343
|
}
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15344
|
+
escaping = false;
|
|
15345
|
+
} else if (char === "\\") {
|
|
15346
|
+
escaping = true;
|
|
15347
|
+
} else if (char === KEY_SEPARATOR) {
|
|
15348
|
+
if (isEmptyStringMarker) {
|
|
15349
|
+
parts.push("");
|
|
15350
|
+
isEmptyStringMarker = false;
|
|
15351
|
+
} else {
|
|
15352
|
+
parts.push(currentPart);
|
|
15240
15353
|
}
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15354
|
+
currentPart = "";
|
|
15355
|
+
} else {
|
|
15356
|
+
currentPart += char;
|
|
15244
15357
|
}
|
|
15245
|
-
return input.map((value) => reviveJsonCompatValue(value, options));
|
|
15246
15358
|
}
|
|
15247
|
-
if (
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15359
|
+
if (escaping) {
|
|
15360
|
+
parts.push(`${currentPart}\\`);
|
|
15361
|
+
} else if (isEmptyStringMarker) {
|
|
15362
|
+
parts.push("");
|
|
15363
|
+
} else if (currentPart !== "" || parts.length > 0) {
|
|
15364
|
+
parts.push(currentPart);
|
|
15253
15365
|
}
|
|
15254
|
-
return
|
|
15366
|
+
return parts;
|
|
15255
15367
|
}
|
|
15256
|
-
function
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
const bytes = new Uint8Array(binary.length);
|
|
15262
|
-
for (let i = 0; i < binary.length; i++) {
|
|
15263
|
-
bytes[i] = binary.charCodeAt(i);
|
|
15264
|
-
}
|
|
15265
|
-
return bytes;
|
|
15368
|
+
function makePrefixedKey(key) {
|
|
15369
|
+
const prefixed = new Uint8Array(KEYS.KV.length + key.length);
|
|
15370
|
+
prefixed.set(KEYS.KV, 0);
|
|
15371
|
+
prefixed.set(key, KEYS.KV.length);
|
|
15372
|
+
return prefixed;
|
|
15266
15373
|
}
|
|
15267
|
-
function
|
|
15268
|
-
return
|
|
15374
|
+
function removePrefixFromKey(prefixedKey) {
|
|
15375
|
+
return prefixedKey.slice(KEYS.KV.length);
|
|
15269
15376
|
}
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
15280
|
-
}
|
|
15281
|
-
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0].startsWith("$")) {
|
|
15282
|
-
return [`$${value[0]}`, value[1]];
|
|
15377
|
+
|
|
15378
|
+
// ../rivetkit/dist/tsup/chunk-7AFZMFPQ.js
|
|
15379
|
+
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15380
|
+
var AsyncMutex = class {
|
|
15381
|
+
#locked = false;
|
|
15382
|
+
#waiting = [];
|
|
15383
|
+
async acquire() {
|
|
15384
|
+
while (this.#locked) {
|
|
15385
|
+
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15283
15386
|
}
|
|
15284
|
-
|
|
15285
|
-
});
|
|
15286
|
-
}
|
|
15287
|
-
function jsonParseCompat(input) {
|
|
15288
|
-
return reviveJsonCompatValue(JSON.parse(input));
|
|
15289
|
-
}
|
|
15290
|
-
function uint8ArrayToBase642(uint8Array) {
|
|
15291
|
-
if (typeof Buffer !== "undefined") {
|
|
15292
|
-
return Buffer.from(uint8Array).toString("base64");
|
|
15293
|
-
}
|
|
15294
|
-
let binary = "";
|
|
15295
|
-
const len = uint8Array.byteLength;
|
|
15296
|
-
for (let i = 0; i < len; i++) {
|
|
15297
|
-
binary += String.fromCharCode(uint8Array[i]);
|
|
15298
|
-
}
|
|
15299
|
-
return btoa(binary);
|
|
15300
|
-
}
|
|
15301
|
-
function contentTypeForEncoding(encoding) {
|
|
15302
|
-
if (encoding === "json") {
|
|
15303
|
-
return "application/json";
|
|
15304
|
-
} else if (encoding === "cbor" || encoding === "bare") {
|
|
15305
|
-
return "application/octet-stream";
|
|
15306
|
-
} else {
|
|
15307
|
-
assertUnreachable(encoding);
|
|
15387
|
+
this.#locked = true;
|
|
15308
15388
|
}
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
return reviveJsonCompatValue(cbor.decode(buffer));
|
|
15315
|
-
}
|
|
15316
|
-
function serializeWithEncoding(encoding, value, versionedDataHandler, version2, zodSchema, toJson, toBare) {
|
|
15317
|
-
if (encoding === "json") {
|
|
15318
|
-
const jsonValue = toJson(value);
|
|
15319
|
-
const validated = zodSchema.parse(jsonValue);
|
|
15320
|
-
return jsonStringifyCompat(validated);
|
|
15321
|
-
} else if (encoding === "cbor") {
|
|
15322
|
-
const jsonValue = toJson(value);
|
|
15323
|
-
const validated = zodSchema.parse(jsonValue);
|
|
15324
|
-
return cbor.encode(validated);
|
|
15325
|
-
} else if (encoding === "bare") {
|
|
15326
|
-
if (!versionedDataHandler) {
|
|
15327
|
-
throw new Error(
|
|
15328
|
-
"VersionedDataHandler is required for 'bare' encoding"
|
|
15329
|
-
);
|
|
15330
|
-
}
|
|
15331
|
-
if (version2 === void 0) {
|
|
15332
|
-
throw new Error("version is required for 'bare' encoding");
|
|
15389
|
+
release() {
|
|
15390
|
+
this.#locked = false;
|
|
15391
|
+
const next = this.#waiting.shift();
|
|
15392
|
+
if (next) {
|
|
15393
|
+
next();
|
|
15333
15394
|
}
|
|
15334
|
-
const bareValue = toBare(value);
|
|
15335
|
-
return versionedDataHandler.serializeWithEmbeddedVersion(
|
|
15336
|
-
bareValue,
|
|
15337
|
-
version2
|
|
15338
|
-
);
|
|
15339
|
-
} else {
|
|
15340
|
-
assertUnreachable(encoding);
|
|
15341
15395
|
}
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
} else {
|
|
15349
|
-
const decoder = new TextDecoder("utf-8");
|
|
15350
|
-
const jsonString = decoder.decode(buffer);
|
|
15351
|
-
parsed = jsonParseCompat(jsonString);
|
|
15352
|
-
}
|
|
15353
|
-
const validated = zodSchema.parse(parsed);
|
|
15354
|
-
return fromJson(validated);
|
|
15355
|
-
} else if (encoding === "cbor") {
|
|
15356
|
-
(0, import_invariant.default)(
|
|
15357
|
-
typeof buffer !== "string",
|
|
15358
|
-
"buffer cannot be string for cbor encoding"
|
|
15359
|
-
);
|
|
15360
|
-
const decoded = decodeCborCompat(buffer);
|
|
15361
|
-
const validated = zodSchema.parse(decoded);
|
|
15362
|
-
return fromJson(validated);
|
|
15363
|
-
} else if (encoding === "bare") {
|
|
15364
|
-
(0, import_invariant.default)(
|
|
15365
|
-
typeof buffer !== "string",
|
|
15366
|
-
"buffer cannot be string for bare encoding"
|
|
15367
|
-
);
|
|
15368
|
-
if (!versionedDataHandler) {
|
|
15369
|
-
throw new Error(
|
|
15370
|
-
"VersionedDataHandler is required for 'bare' encoding"
|
|
15371
|
-
);
|
|
15396
|
+
async run(fn) {
|
|
15397
|
+
await this.acquire();
|
|
15398
|
+
try {
|
|
15399
|
+
return await fn();
|
|
15400
|
+
} finally {
|
|
15401
|
+
this.release();
|
|
15372
15402
|
}
|
|
15373
|
-
const bareValue = versionedDataHandler.deserializeWithEmbeddedVersion(buffer);
|
|
15374
|
-
return fromBare(bareValue);
|
|
15375
|
-
} else {
|
|
15376
|
-
assertUnreachable(encoding);
|
|
15377
15403
|
}
|
|
15378
|
-
}
|
|
15404
|
+
};
|
|
15379
15405
|
|
|
15380
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15406
|
+
// ../rivetkit/dist/tsup/chunk-PAG6G46L.js
|
|
15381
15407
|
function logger() {
|
|
15382
15408
|
return getLogger("actor-client");
|
|
15383
15409
|
}
|
|
@@ -15415,34 +15441,7 @@ async function importWebSocket() {
|
|
|
15415
15441
|
return webSocketPromise;
|
|
15416
15442
|
}
|
|
15417
15443
|
|
|
15418
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15419
|
-
var AsyncMutex = class {
|
|
15420
|
-
#locked = false;
|
|
15421
|
-
#waiting = [];
|
|
15422
|
-
async acquire() {
|
|
15423
|
-
while (this.#locked) {
|
|
15424
|
-
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15425
|
-
}
|
|
15426
|
-
this.#locked = true;
|
|
15427
|
-
}
|
|
15428
|
-
release() {
|
|
15429
|
-
this.#locked = false;
|
|
15430
|
-
const next = this.#waiting.shift();
|
|
15431
|
-
if (next) {
|
|
15432
|
-
next();
|
|
15433
|
-
}
|
|
15434
|
-
}
|
|
15435
|
-
async run(fn) {
|
|
15436
|
-
await this.acquire();
|
|
15437
|
-
try {
|
|
15438
|
-
return await fn();
|
|
15439
|
-
} finally {
|
|
15440
|
-
this.release();
|
|
15441
|
-
}
|
|
15442
|
-
}
|
|
15443
|
-
};
|
|
15444
|
-
|
|
15445
|
-
// ../rivetkit/dist/tsup/chunk-CMPFZ724.js
|
|
15444
|
+
// ../rivetkit/dist/tsup/chunk-GAV4PKFT.js
|
|
15446
15445
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15447
15446
|
|
|
15448
15447
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15620,7 +15619,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15620
15619
|
return new VersionedDataHandler(config3);
|
|
15621
15620
|
}
|
|
15622
15621
|
|
|
15623
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15622
|
+
// ../rivetkit/dist/tsup/chunk-GAV4PKFT.js
|
|
15624
15623
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15625
15624
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15626
15625
|
var PATH_CONNECT = "/connect";
|
|
@@ -20449,13 +20448,6 @@ async function updateRunnerConfig(config3, runnerName, request) {
|
|
|
20449
20448
|
request
|
|
20450
20449
|
);
|
|
20451
20450
|
}
|
|
20452
|
-
async function kvGet(config3, actorId, key) {
|
|
20453
|
-
return apiCall(
|
|
20454
|
-
config3,
|
|
20455
|
-
"GET",
|
|
20456
|
-
`/actors/${encodeURIComponent(actorId)}/kv/keys/${encodeURIComponent(key)}`
|
|
20457
|
-
);
|
|
20458
|
-
}
|
|
20459
20451
|
function shouldSkipReadyWait(options = {}) {
|
|
20460
20452
|
return options.skipReadyWait === true;
|
|
20461
20453
|
}
|
|
@@ -21221,28 +21213,6 @@ var RemoteEngineControlClient = class {
|
|
|
21221
21213
|
const args = await createWebSocketProxy(c, wsGuardUrl, protocols);
|
|
21222
21214
|
return await upgradeWebSocket(() => args)(c, noopNext());
|
|
21223
21215
|
}
|
|
21224
|
-
async kvGet(actorId, key) {
|
|
21225
|
-
await this.#metadataPromise;
|
|
21226
|
-
logger2().debug({ msg: "getting kv value via engine api", key });
|
|
21227
|
-
const response = await kvGet(
|
|
21228
|
-
this.#config,
|
|
21229
|
-
actorId,
|
|
21230
|
-
new TextDecoder("utf8").decode(key)
|
|
21231
|
-
);
|
|
21232
|
-
return response.value;
|
|
21233
|
-
}
|
|
21234
|
-
async kvBatchGet(_actorId, _keys) {
|
|
21235
|
-
throw new Error("kvBatchGet not supported on remote engine client");
|
|
21236
|
-
}
|
|
21237
|
-
async kvBatchPut(_actorId, _entries) {
|
|
21238
|
-
throw new Error("kvBatchPut not supported on remote engine client");
|
|
21239
|
-
}
|
|
21240
|
-
async kvBatchDelete(_actorId, _keys) {
|
|
21241
|
-
throw new Error("kvBatchDelete not supported on remote engine client");
|
|
21242
|
-
}
|
|
21243
|
-
async kvDeleteRange(_actorId, _start, _end) {
|
|
21244
|
-
throw new Error("kvDeleteRange not supported on remote engine client");
|
|
21245
|
-
}
|
|
21246
21216
|
displayInformation() {
|
|
21247
21217
|
return { properties: {} };
|
|
21248
21218
|
}
|
|
@@ -22565,15 +22535,21 @@ var import_meta = {};
|
|
|
22565
22535
|
function loggerWithoutContext() {
|
|
22566
22536
|
return getLogger("actor-runtime");
|
|
22567
22537
|
}
|
|
22568
|
-
var
|
|
22569
|
-
|
|
22538
|
+
var warnedDeprecatedOptionKeys = /* @__PURE__ */ new Set();
|
|
22539
|
+
var DEPRECATED_OPTION_MESSAGES = {
|
|
22540
|
+
onDestroyTimeout: "Configure `sleepGracePeriod` instead, which bounds the entire graceful shutdown window for both sleep and destroy.",
|
|
22541
|
+
waitUntilTimeout: "Configure `sleepGracePeriod` instead, which bounds the entire graceful shutdown window for both sleep and destroy.",
|
|
22542
|
+
preloadMaxWorkflowBytes: "Internal storage moved to SQLite and no longer uses KV preloading.",
|
|
22543
|
+
preloadMaxConnectionsBytes: "Internal storage moved to SQLite and no longer uses KV preloading."
|
|
22544
|
+
};
|
|
22545
|
+
function warnDeprecatedOptionKeys(options) {
|
|
22570
22546
|
if (!options || typeof options !== "object") return;
|
|
22571
22547
|
const opts = options;
|
|
22572
|
-
for (const key of
|
|
22573
|
-
if (opts[key] !== void 0 && !
|
|
22574
|
-
|
|
22548
|
+
for (const [key, detail] of Object.entries(DEPRECATED_OPTION_MESSAGES)) {
|
|
22549
|
+
if (opts[key] !== void 0 && !warnedDeprecatedOptionKeys.has(key)) {
|
|
22550
|
+
warnedDeprecatedOptionKeys.add(key);
|
|
22575
22551
|
loggerWithoutContext().warn({
|
|
22576
|
-
msg: `actor option \`${key}\` is deprecated and is now ignored.
|
|
22552
|
+
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 2.2.0.`
|
|
22577
22553
|
});
|
|
22578
22554
|
}
|
|
22579
22555
|
}
|
|
@@ -22591,7 +22567,7 @@ function isStaticActorInstance(_actor) {
|
|
|
22591
22567
|
return true;
|
|
22592
22568
|
}
|
|
22593
22569
|
function actor(input) {
|
|
22594
|
-
|
|
22570
|
+
warnDeprecatedOptionKeys(
|
|
22595
22571
|
input == null ? void 0 : input.options
|
|
22596
22572
|
);
|
|
22597
22573
|
const config3 = ActorConfigSchema.parse(input);
|
|
@@ -23296,31 +23272,6 @@ function buildActorNames(config3) {
|
|
|
23296
23272
|
const metadata = {};
|
|
23297
23273
|
metadata.icon = options.icon ?? runMeta.icon;
|
|
23298
23274
|
metadata.name = options.name ?? runMeta.name;
|
|
23299
|
-
metadata.preload = {
|
|
23300
|
-
keys: [
|
|
23301
|
-
Array.from(KEYS.PERSIST_DATA),
|
|
23302
|
-
Array.from(KEYS.INSPECTOR_TOKEN),
|
|
23303
|
-
Array.from(queueMetadataKey()),
|
|
23304
|
-
Array.from(KEYS.LAST_PUSHED_ALARM)
|
|
23305
|
-
],
|
|
23306
|
-
prefixes: [
|
|
23307
|
-
{
|
|
23308
|
-
prefix: Array.from(workflowStoragePrefix()),
|
|
23309
|
-
maxBytes: options.preloadMaxWorkflowBytes ?? 131072,
|
|
23310
|
-
partial: false
|
|
23311
|
-
},
|
|
23312
|
-
{
|
|
23313
|
-
prefix: Array.from(KEYS.CONN_PREFIX),
|
|
23314
|
-
maxBytes: options.preloadMaxConnectionsBytes ?? 65536,
|
|
23315
|
-
partial: false
|
|
23316
|
-
},
|
|
23317
|
-
{
|
|
23318
|
-
prefix: Array.from(queueMessagesPrefix()),
|
|
23319
|
-
maxBytes: 65536,
|
|
23320
|
-
partial: false
|
|
23321
|
-
}
|
|
23322
|
-
]
|
|
23323
|
-
};
|
|
23324
23275
|
if (!metadata.icon) delete metadata.icon;
|
|
23325
23276
|
if (!metadata.name) delete metadata.name;
|
|
23326
23277
|
return [actorName, { metadata }];
|
|
@@ -23508,6 +23459,12 @@ function toNativeBindings(sql, params) {
|
|
|
23508
23459
|
return toNativeBinding(value);
|
|
23509
23460
|
});
|
|
23510
23461
|
}
|
|
23462
|
+
function toNativeBatchStatement(statement) {
|
|
23463
|
+
return {
|
|
23464
|
+
sql: statement.sql,
|
|
23465
|
+
params: toNativeBindings(statement.sql, statement.params)
|
|
23466
|
+
};
|
|
23467
|
+
}
|
|
23511
23468
|
function normalizeNativeMetrics(metrics) {
|
|
23512
23469
|
if (!metrics) return null;
|
|
23513
23470
|
const raw = metrics;
|
|
@@ -23621,6 +23578,60 @@ function wrapJsNativeDatabase(database) {
|
|
|
23621
23578
|
async execute(sql, params) {
|
|
23622
23579
|
return await executeNative(sql, params);
|
|
23623
23580
|
},
|
|
23581
|
+
async executeBatch(statements) {
|
|
23582
|
+
const nativeStatements = statements.map(toNativeBatchStatement);
|
|
23583
|
+
const release = gate.enter();
|
|
23584
|
+
let transaction;
|
|
23585
|
+
try {
|
|
23586
|
+
const results = database.executeBatch ? await database.executeBatch(nativeStatements) : await (async () => {
|
|
23587
|
+
transaction = await database.beginTransaction();
|
|
23588
|
+
const transactionResults = [];
|
|
23589
|
+
for (const statement of nativeStatements) {
|
|
23590
|
+
transactionResults.push(
|
|
23591
|
+
await transaction.execute(
|
|
23592
|
+
statement.sql,
|
|
23593
|
+
statement.params
|
|
23594
|
+
)
|
|
23595
|
+
);
|
|
23596
|
+
}
|
|
23597
|
+
await transaction.commit();
|
|
23598
|
+
transaction = void 0;
|
|
23599
|
+
return transactionResults;
|
|
23600
|
+
})();
|
|
23601
|
+
for (const result of results) {
|
|
23602
|
+
if (result.lastInsertRowId !== void 0) {
|
|
23603
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
23604
|
+
}
|
|
23605
|
+
}
|
|
23606
|
+
return results;
|
|
23607
|
+
} catch (error46) {
|
|
23608
|
+
if (transaction) {
|
|
23609
|
+
try {
|
|
23610
|
+
await transaction.rollback();
|
|
23611
|
+
} catch {
|
|
23612
|
+
}
|
|
23613
|
+
}
|
|
23614
|
+
enrichNativeDatabaseError(database, error46);
|
|
23615
|
+
} finally {
|
|
23616
|
+
release();
|
|
23617
|
+
}
|
|
23618
|
+
},
|
|
23619
|
+
async beginTransaction(timeoutMs) {
|
|
23620
|
+
const release = gate.enter();
|
|
23621
|
+
let transaction;
|
|
23622
|
+
try {
|
|
23623
|
+
transaction = await database.beginTransaction(timeoutMs);
|
|
23624
|
+
} catch (error46) {
|
|
23625
|
+
enrichNativeDatabaseError(database, error46);
|
|
23626
|
+
} finally {
|
|
23627
|
+
release();
|
|
23628
|
+
}
|
|
23629
|
+
return wrapTransaction(database, transaction, gate, (result) => {
|
|
23630
|
+
if (result.lastInsertRowId !== void 0) {
|
|
23631
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
23632
|
+
}
|
|
23633
|
+
});
|
|
23634
|
+
},
|
|
23624
23635
|
async run(sql, params) {
|
|
23625
23636
|
await executeNative(sql, params);
|
|
23626
23637
|
},
|
|
@@ -23638,6 +23649,59 @@ function wrapJsNativeDatabase(database) {
|
|
|
23638
23649
|
}
|
|
23639
23650
|
};
|
|
23640
23651
|
}
|
|
23652
|
+
function wrapTransaction(database, transaction, gate, onExecute) {
|
|
23653
|
+
return {
|
|
23654
|
+
async exec(sql, callback) {
|
|
23655
|
+
const release = gate.enter();
|
|
23656
|
+
let result;
|
|
23657
|
+
try {
|
|
23658
|
+
result = await transaction.exec(sql);
|
|
23659
|
+
} catch (error46) {
|
|
23660
|
+
enrichNativeDatabaseError(database, error46);
|
|
23661
|
+
} finally {
|
|
23662
|
+
release();
|
|
23663
|
+
}
|
|
23664
|
+
if (callback) {
|
|
23665
|
+
for (const row of result.rows) callback(row, result.columns);
|
|
23666
|
+
}
|
|
23667
|
+
},
|
|
23668
|
+
async execute(sql, params) {
|
|
23669
|
+
const release = gate.enter();
|
|
23670
|
+
try {
|
|
23671
|
+
const result = await transaction.execute(
|
|
23672
|
+
sql,
|
|
23673
|
+
toNativeBindings(sql, params)
|
|
23674
|
+
);
|
|
23675
|
+
onExecute(result);
|
|
23676
|
+
return result;
|
|
23677
|
+
} catch (error46) {
|
|
23678
|
+
enrichNativeDatabaseError(database, error46);
|
|
23679
|
+
} finally {
|
|
23680
|
+
release();
|
|
23681
|
+
}
|
|
23682
|
+
},
|
|
23683
|
+
async commit() {
|
|
23684
|
+
const release = gate.enter();
|
|
23685
|
+
try {
|
|
23686
|
+
await transaction.commit();
|
|
23687
|
+
} catch (error46) {
|
|
23688
|
+
enrichNativeDatabaseError(database, error46);
|
|
23689
|
+
} finally {
|
|
23690
|
+
release();
|
|
23691
|
+
}
|
|
23692
|
+
},
|
|
23693
|
+
async rollback() {
|
|
23694
|
+
const release = gate.enter();
|
|
23695
|
+
try {
|
|
23696
|
+
await transaction.rollback();
|
|
23697
|
+
} catch (error46) {
|
|
23698
|
+
enrichNativeDatabaseError(database, error46);
|
|
23699
|
+
} finally {
|
|
23700
|
+
release();
|
|
23701
|
+
}
|
|
23702
|
+
}
|
|
23703
|
+
};
|
|
23704
|
+
}
|
|
23641
23705
|
function lastInsertRowIdColumnName(sql) {
|
|
23642
23706
|
const match = sql.match(
|
|
23643
23707
|
/^\s*SELECT\s+last_insert_rowid\s*\(\s*\)\s*(?:AS\s+("[^"]+"|`[^`]+`|\[[^\]]+\]|\w+))?\s*;?\s*$/i
|
|
@@ -23745,6 +23809,9 @@ function asNativeConn(handle) {
|
|
|
23745
23809
|
function asNativeWebSocket(handle) {
|
|
23746
23810
|
return handle;
|
|
23747
23811
|
}
|
|
23812
|
+
function asNativeSqlTransaction(handle) {
|
|
23813
|
+
return handle;
|
|
23814
|
+
}
|
|
23748
23815
|
function asNativeCancellationToken(handle) {
|
|
23749
23816
|
return handle;
|
|
23750
23817
|
}
|
|
@@ -23774,6 +23841,12 @@ function toNapiSqlBindParams(params) {
|
|
|
23774
23841
|
}
|
|
23775
23842
|
return params.map((param) => toNapiSqlBindParam(param));
|
|
23776
23843
|
}
|
|
23844
|
+
function toNapiSqlBatchStatement(statement) {
|
|
23845
|
+
return {
|
|
23846
|
+
sql: statement.sql,
|
|
23847
|
+
params: toNapiSqlBindParams(statement.params) ?? void 0
|
|
23848
|
+
};
|
|
23849
|
+
}
|
|
23777
23850
|
function toNapiBuffer(value) {
|
|
23778
23851
|
return Buffer.from(value);
|
|
23779
23852
|
}
|
|
@@ -23897,11 +23970,16 @@ var NapiCoreRuntime = class {
|
|
|
23897
23970
|
createCancellationToken() {
|
|
23898
23971
|
return new this.#bindings.CancellationToken();
|
|
23899
23972
|
}
|
|
23900
|
-
|
|
23901
|
-
return
|
|
23902
|
-
|
|
23903
|
-
|
|
23904
|
-
|
|
23973
|
+
decodeInspectorRequest(bytes, advertisedVersion) {
|
|
23974
|
+
return this.#bindings.decodeInspectorRequest(
|
|
23975
|
+
toNapiBuffer(bytes),
|
|
23976
|
+
advertisedVersion
|
|
23977
|
+
);
|
|
23978
|
+
}
|
|
23979
|
+
encodeInspectorResponse(bytes, targetVersion) {
|
|
23980
|
+
return this.#bindings.encodeInspectorResponse(
|
|
23981
|
+
toNapiBuffer(bytes),
|
|
23982
|
+
targetVersion
|
|
23905
23983
|
);
|
|
23906
23984
|
}
|
|
23907
23985
|
cancellationTokenAborted(token) {
|
|
@@ -23965,6 +24043,14 @@ var NapiCoreRuntime = class {
|
|
|
23965
24043
|
toNapiStateDeltaPayload(payload)
|
|
23966
24044
|
);
|
|
23967
24045
|
}
|
|
24046
|
+
async actorSaveStateAndWorkflowBatch(ctx, writes) {
|
|
24047
|
+
await asNativeActorContext(ctx).saveStateAndWorkflowBatch(
|
|
24048
|
+
writes.map((write) => ({
|
|
24049
|
+
key: toNapiBuffer(write.key),
|
|
24050
|
+
value: toNapiBuffer(write.value)
|
|
24051
|
+
}))
|
|
24052
|
+
);
|
|
24053
|
+
}
|
|
23968
24054
|
actorId(ctx) {
|
|
23969
24055
|
return asNativeActorContext(ctx).actorId();
|
|
23970
24056
|
}
|
|
@@ -24071,6 +24157,33 @@ var NapiCoreRuntime = class {
|
|
|
24071
24157
|
);
|
|
24072
24158
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
24073
24159
|
}
|
|
24160
|
+
async actorSqlExecuteBatch(ctx, statements) {
|
|
24161
|
+
const results = await this.#actorSql(ctx).executeBatch(
|
|
24162
|
+
statements.map(toNapiSqlBatchStatement)
|
|
24163
|
+
);
|
|
24164
|
+
return results.map(normalizeRuntimeSqlExecuteResult);
|
|
24165
|
+
}
|
|
24166
|
+
async actorSqlBeginTransaction(ctx, timeoutMs) {
|
|
24167
|
+
return await this.#actorSql(ctx).beginTransaction(
|
|
24168
|
+
timeoutMs
|
|
24169
|
+
);
|
|
24170
|
+
}
|
|
24171
|
+
async actorSqlTransactionExec(transaction, sql) {
|
|
24172
|
+
return await asNativeSqlTransaction(transaction).exec(sql);
|
|
24173
|
+
}
|
|
24174
|
+
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
24175
|
+
const result = await asNativeSqlTransaction(transaction).execute(
|
|
24176
|
+
sql,
|
|
24177
|
+
toNapiSqlBindParams(params)
|
|
24178
|
+
);
|
|
24179
|
+
return normalizeRuntimeSqlExecuteResult(result);
|
|
24180
|
+
}
|
|
24181
|
+
async actorSqlTransactionCommit(transaction) {
|
|
24182
|
+
await asNativeSqlTransaction(transaction).commit();
|
|
24183
|
+
}
|
|
24184
|
+
async actorSqlTransactionRollback(transaction) {
|
|
24185
|
+
await asNativeSqlTransaction(transaction).rollback();
|
|
24186
|
+
}
|
|
24074
24187
|
async actorSqlQuery(ctx, sql, params) {
|
|
24075
24188
|
return await this.#actorSql(ctx).query(
|
|
24076
24189
|
sql,
|
|
@@ -24097,6 +24210,9 @@ var NapiCoreRuntime = class {
|
|
|
24097
24210
|
this.#sql.delete(nativeCtx);
|
|
24098
24211
|
await database.close();
|
|
24099
24212
|
}
|
|
24213
|
+
async actorRuntimeSocketProvision(ctx) {
|
|
24214
|
+
return await asNativeActorContext(ctx).provisionActorRuntimeSocket();
|
|
24215
|
+
}
|
|
24100
24216
|
async actorQueueSend(ctx, name, body) {
|
|
24101
24217
|
return toNapiQueueMessage(
|
|
24102
24218
|
await asNativeActorContext(ctx).queue().send(name, toNapiBuffer(body))
|
|
@@ -24145,11 +24261,51 @@ var NapiCoreRuntime = class {
|
|
|
24145
24261
|
async actorQueueReset(ctx) {
|
|
24146
24262
|
await asNativeActorContext(ctx).queue().reset();
|
|
24147
24263
|
}
|
|
24148
|
-
actorScheduleAfter(ctx, durationMs, actionName, args) {
|
|
24149
|
-
asNativeActorContext(ctx).schedule().after(durationMs, actionName, toNapiBuffer(args));
|
|
24264
|
+
async actorScheduleAfter(ctx, durationMs, actionName, args) {
|
|
24265
|
+
return await asNativeActorContext(ctx).schedule().after(durationMs, actionName, toNapiBuffer(args));
|
|
24266
|
+
}
|
|
24267
|
+
async actorScheduleAt(ctx, timestampMs, actionName, args) {
|
|
24268
|
+
return await asNativeActorContext(ctx).schedule().at(timestampMs, actionName, toNapiBuffer(args));
|
|
24269
|
+
}
|
|
24270
|
+
async actorScheduleCancel(ctx, id) {
|
|
24271
|
+
return await asNativeActorContext(ctx).schedule().cancel(id);
|
|
24272
|
+
}
|
|
24273
|
+
async actorScheduleGet(ctx, id) {
|
|
24274
|
+
return await asNativeActorContext(ctx).schedule().get(id) ?? void 0;
|
|
24275
|
+
}
|
|
24276
|
+
async actorScheduleList(ctx) {
|
|
24277
|
+
return await asNativeActorContext(ctx).schedule().list();
|
|
24278
|
+
}
|
|
24279
|
+
async actorCronSet(ctx, name, expression, timezone, actionName, args, maxHistory) {
|
|
24280
|
+
await asNativeActorContext(ctx).schedule().cronSet(
|
|
24281
|
+
name,
|
|
24282
|
+
expression,
|
|
24283
|
+
timezone,
|
|
24284
|
+
actionName,
|
|
24285
|
+
toNapiBuffer(args),
|
|
24286
|
+
maxHistory
|
|
24287
|
+
);
|
|
24288
|
+
}
|
|
24289
|
+
async actorCronEvery(ctx, name, intervalMs, actionName, args, maxHistory) {
|
|
24290
|
+
await asNativeActorContext(ctx).schedule().cronEvery(
|
|
24291
|
+
name,
|
|
24292
|
+
intervalMs,
|
|
24293
|
+
actionName,
|
|
24294
|
+
toNapiBuffer(args),
|
|
24295
|
+
maxHistory
|
|
24296
|
+
);
|
|
24297
|
+
}
|
|
24298
|
+
async actorCronGet(ctx, name) {
|
|
24299
|
+
return await asNativeActorContext(ctx).schedule().cronGet(name) ?? void 0;
|
|
24150
24300
|
}
|
|
24151
|
-
|
|
24152
|
-
asNativeActorContext(ctx).schedule().
|
|
24301
|
+
async actorCronList(ctx) {
|
|
24302
|
+
return await asNativeActorContext(ctx).schedule().cronList();
|
|
24303
|
+
}
|
|
24304
|
+
async actorCronDelete(ctx, name) {
|
|
24305
|
+
return await asNativeActorContext(ctx).schedule().cronDelete(name);
|
|
24306
|
+
}
|
|
24307
|
+
async actorCronHistory(ctx, name, limit) {
|
|
24308
|
+
return await asNativeActorContext(ctx).schedule().cronHistory(name, limit);
|
|
24153
24309
|
}
|
|
24154
24310
|
connId(conn) {
|
|
24155
24311
|
return asNativeConn(conn).id();
|
|
@@ -24552,6 +24708,13 @@ var WasmCoreRuntime = class {
|
|
|
24552
24708
|
async actorSaveState(ctx, payload) {
|
|
24553
24709
|
await callHandleAsync(asWasmActorContext(ctx), "saveState", payload);
|
|
24554
24710
|
}
|
|
24711
|
+
async actorSaveStateAndWorkflowBatch(ctx, writes) {
|
|
24712
|
+
await callHandleAsync(
|
|
24713
|
+
asWasmActorContext(ctx),
|
|
24714
|
+
"saveStateAndWorkflowBatch",
|
|
24715
|
+
writes
|
|
24716
|
+
);
|
|
24717
|
+
}
|
|
24555
24718
|
actorId(ctx) {
|
|
24556
24719
|
return callHandle(asWasmActorContext(ctx), "actorId");
|
|
24557
24720
|
}
|
|
@@ -24698,6 +24861,38 @@ var WasmCoreRuntime = class {
|
|
|
24698
24861
|
);
|
|
24699
24862
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
24700
24863
|
}
|
|
24864
|
+
async actorSqlExecuteBatch(ctx, statements) {
|
|
24865
|
+
const results = await callWasm(
|
|
24866
|
+
() => this.#actorSql(ctx).executeBatch(statements)
|
|
24867
|
+
);
|
|
24868
|
+
return results.map(normalizeRuntimeSqlExecuteResult);
|
|
24869
|
+
}
|
|
24870
|
+
async actorSqlBeginTransaction(ctx, timeoutMs) {
|
|
24871
|
+
return await callWasm(
|
|
24872
|
+
() => this.#actorSql(ctx).beginTransaction(timeoutMs)
|
|
24873
|
+
);
|
|
24874
|
+
}
|
|
24875
|
+
async actorSqlTransactionExec(transaction, sql) {
|
|
24876
|
+
return await callWasm(
|
|
24877
|
+
() => transaction.exec(sql)
|
|
24878
|
+
);
|
|
24879
|
+
}
|
|
24880
|
+
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
24881
|
+
const result = await callWasm(
|
|
24882
|
+
() => transaction.execute(sql, params)
|
|
24883
|
+
);
|
|
24884
|
+
return normalizeRuntimeSqlExecuteResult(result);
|
|
24885
|
+
}
|
|
24886
|
+
async actorSqlTransactionCommit(transaction) {
|
|
24887
|
+
await callWasm(
|
|
24888
|
+
() => transaction.commit()
|
|
24889
|
+
);
|
|
24890
|
+
}
|
|
24891
|
+
async actorSqlTransactionRollback(transaction) {
|
|
24892
|
+
await callWasm(
|
|
24893
|
+
() => transaction.rollback()
|
|
24894
|
+
);
|
|
24895
|
+
}
|
|
24701
24896
|
async actorSqlQuery(ctx, sql, params) {
|
|
24702
24897
|
return await callWasm(() => this.#actorSql(ctx).query(sql, params));
|
|
24703
24898
|
}
|
|
@@ -24721,6 +24916,17 @@ var WasmCoreRuntime = class {
|
|
|
24721
24916
|
this.#sql.delete(wasmCtx);
|
|
24722
24917
|
await callWasm(() => database.close());
|
|
24723
24918
|
}
|
|
24919
|
+
async actorRuntimeSocketProvision(_ctx) {
|
|
24920
|
+
throw new RivetError(
|
|
24921
|
+
"actor_runtime_socket",
|
|
24922
|
+
"unsupported",
|
|
24923
|
+
"Actor Runtime Socket is only available on Unix native runtimes.",
|
|
24924
|
+
{
|
|
24925
|
+
public: true,
|
|
24926
|
+
metadata: { runtime: "wasm" }
|
|
24927
|
+
}
|
|
24928
|
+
);
|
|
24929
|
+
}
|
|
24724
24930
|
async actorQueueSend(ctx, name, body) {
|
|
24725
24931
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
24726
24932
|
return normalizeQueueMessage(
|
|
@@ -24792,13 +24998,97 @@ var WasmCoreRuntime = class {
|
|
|
24792
24998
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
24793
24999
|
await callHandleAsync(queue2, "reset");
|
|
24794
25000
|
}
|
|
24795
|
-
actorScheduleAfter(ctx, durationMs, actionName, args) {
|
|
25001
|
+
async actorScheduleAfter(ctx, durationMs, actionName, args) {
|
|
25002
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25003
|
+
return await callHandleAsync(
|
|
25004
|
+
schedule,
|
|
25005
|
+
"after",
|
|
25006
|
+
wasmNumber(durationMs),
|
|
25007
|
+
actionName,
|
|
25008
|
+
args
|
|
25009
|
+
);
|
|
25010
|
+
}
|
|
25011
|
+
async actorScheduleAt(ctx, timestampMs, actionName, args) {
|
|
25012
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25013
|
+
return await callHandleAsync(
|
|
25014
|
+
schedule,
|
|
25015
|
+
"at",
|
|
25016
|
+
wasmNumber(timestampMs),
|
|
25017
|
+
actionName,
|
|
25018
|
+
args
|
|
25019
|
+
);
|
|
25020
|
+
}
|
|
25021
|
+
async actorScheduleCancel(ctx, id) {
|
|
25022
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25023
|
+
return await callHandleAsync(schedule, "cancel", id);
|
|
25024
|
+
}
|
|
25025
|
+
async actorScheduleGet(ctx, id) {
|
|
25026
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25027
|
+
return await callHandleAsync(
|
|
25028
|
+
schedule,
|
|
25029
|
+
"get",
|
|
25030
|
+
id
|
|
25031
|
+
);
|
|
25032
|
+
}
|
|
25033
|
+
async actorScheduleList(ctx) {
|
|
25034
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25035
|
+
return await callHandleAsync(
|
|
25036
|
+
schedule,
|
|
25037
|
+
"list"
|
|
25038
|
+
);
|
|
25039
|
+
}
|
|
25040
|
+
async actorCronSet(ctx, name, expression, timezone, actionName, args, maxHistory) {
|
|
25041
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25042
|
+
await callHandleAsync(
|
|
25043
|
+
schedule,
|
|
25044
|
+
"cronSet",
|
|
25045
|
+
name,
|
|
25046
|
+
expression,
|
|
25047
|
+
timezone,
|
|
25048
|
+
actionName,
|
|
25049
|
+
args,
|
|
25050
|
+
maxHistory
|
|
25051
|
+
);
|
|
25052
|
+
}
|
|
25053
|
+
async actorCronEvery(ctx, name, intervalMs, actionName, args, maxHistory) {
|
|
25054
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25055
|
+
await callHandleAsync(
|
|
25056
|
+
schedule,
|
|
25057
|
+
"cronEvery",
|
|
25058
|
+
name,
|
|
25059
|
+
intervalMs,
|
|
25060
|
+
actionName,
|
|
25061
|
+
args,
|
|
25062
|
+
maxHistory
|
|
25063
|
+
);
|
|
25064
|
+
}
|
|
25065
|
+
async actorCronGet(ctx, name) {
|
|
25066
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25067
|
+
return await callHandleAsync(
|
|
25068
|
+
schedule,
|
|
25069
|
+
"cronGet",
|
|
25070
|
+
name
|
|
25071
|
+
);
|
|
25072
|
+
}
|
|
25073
|
+
async actorCronList(ctx) {
|
|
24796
25074
|
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
24797
|
-
|
|
25075
|
+
return await callHandleAsync(
|
|
25076
|
+
schedule,
|
|
25077
|
+
"cronList"
|
|
25078
|
+
);
|
|
25079
|
+
}
|
|
25080
|
+
async actorCronDelete(ctx, name) {
|
|
25081
|
+
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
25082
|
+
return await callHandleAsync(schedule, "cronDelete", name);
|
|
24798
25083
|
}
|
|
24799
|
-
|
|
25084
|
+
async actorCronHistory(ctx, name, limit) {
|
|
24800
25085
|
const schedule = childHandle(asWasmActorContext(ctx), "schedule");
|
|
24801
|
-
|
|
25086
|
+
return await callHandleAsync(
|
|
25087
|
+
schedule,
|
|
25088
|
+
"cronHistory",
|
|
25089
|
+
name,
|
|
25090
|
+
limit
|
|
25091
|
+
);
|
|
24802
25092
|
}
|
|
24803
25093
|
connId(conn) {
|
|
24804
25094
|
return callHandle(asWasmConn(conn), "id");
|
|
@@ -25133,6 +25423,23 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
|
25133
25423
|
const database = wrapJsNativeDatabase({
|
|
25134
25424
|
exec: (sql) => runtime.actorSqlExec(ctx, sql),
|
|
25135
25425
|
execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
|
|
25426
|
+
executeBatch: (statements) => runtime.actorSqlExecuteBatch(ctx, statements),
|
|
25427
|
+
beginTransaction: async (timeoutMs) => {
|
|
25428
|
+
const transaction = await runtime.actorSqlBeginTransaction(
|
|
25429
|
+
ctx,
|
|
25430
|
+
timeoutMs
|
|
25431
|
+
);
|
|
25432
|
+
return {
|
|
25433
|
+
exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
|
|
25434
|
+
execute: (sql, params) => runtime.actorSqlTransactionExecute(
|
|
25435
|
+
transaction,
|
|
25436
|
+
sql,
|
|
25437
|
+
params
|
|
25438
|
+
),
|
|
25439
|
+
commit: () => runtime.actorSqlTransactionCommit(transaction),
|
|
25440
|
+
rollback: () => runtime.actorSqlTransactionRollback(transaction)
|
|
25441
|
+
};
|
|
25442
|
+
},
|
|
25136
25443
|
query: (sql, params) => runtime.actorSqlQuery(ctx, sql, params),
|
|
25137
25444
|
run: (sql, params) => runtime.actorSqlRun(ctx, sql, params),
|
|
25138
25445
|
metrics: () => runtime.actorSqlMetrics(ctx),
|
|
@@ -25626,26 +25933,116 @@ var NativeScheduleAdapter = class {
|
|
|
25626
25933
|
this.#ctx = ctx;
|
|
25627
25934
|
}
|
|
25628
25935
|
async after(duration3, action, ...args) {
|
|
25629
|
-
|
|
25630
|
-
|
|
25631
|
-
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
encodeValue(args)
|
|
25635
|
-
)
|
|
25936
|
+
return await this.#runtime.actorScheduleAfter(
|
|
25937
|
+
this.#ctx,
|
|
25938
|
+
duration3,
|
|
25939
|
+
action,
|
|
25940
|
+
encodeValue(args)
|
|
25636
25941
|
);
|
|
25637
25942
|
}
|
|
25638
25943
|
async at(timestamp, action, ...args) {
|
|
25639
|
-
|
|
25640
|
-
|
|
25641
|
-
|
|
25642
|
-
|
|
25643
|
-
|
|
25644
|
-
|
|
25645
|
-
|
|
25944
|
+
return await this.#runtime.actorScheduleAt(
|
|
25945
|
+
this.#ctx,
|
|
25946
|
+
timestamp,
|
|
25947
|
+
action,
|
|
25948
|
+
encodeValue(args)
|
|
25949
|
+
);
|
|
25950
|
+
}
|
|
25951
|
+
async cancel(id) {
|
|
25952
|
+
return await this.#runtime.actorScheduleCancel(this.#ctx, id);
|
|
25953
|
+
}
|
|
25954
|
+
async get(id) {
|
|
25955
|
+
const event2 = await this.#runtime.actorScheduleGet(this.#ctx, id);
|
|
25956
|
+
return event2 ? decodeScheduledEventInfo(event2) : void 0;
|
|
25957
|
+
}
|
|
25958
|
+
async list() {
|
|
25959
|
+
return (await this.#runtime.actorScheduleList(this.#ctx)).map(
|
|
25960
|
+
decodeScheduledEventInfo
|
|
25961
|
+
);
|
|
25962
|
+
}
|
|
25963
|
+
};
|
|
25964
|
+
var NativeCronAdapter = class {
|
|
25965
|
+
#runtime;
|
|
25966
|
+
#ctx;
|
|
25967
|
+
constructor(runtime, ctx) {
|
|
25968
|
+
this.#runtime = runtime;
|
|
25969
|
+
this.#ctx = ctx;
|
|
25970
|
+
}
|
|
25971
|
+
async set(options) {
|
|
25972
|
+
await this.#runtime.actorCronSet(
|
|
25973
|
+
this.#ctx,
|
|
25974
|
+
options.name,
|
|
25975
|
+
options.expression,
|
|
25976
|
+
options.timezone,
|
|
25977
|
+
options.action,
|
|
25978
|
+
encodeValue(options.args ?? []),
|
|
25979
|
+
options.maxHistory
|
|
25980
|
+
);
|
|
25981
|
+
}
|
|
25982
|
+
async every(options) {
|
|
25983
|
+
await this.#runtime.actorCronEvery(
|
|
25984
|
+
this.#ctx,
|
|
25985
|
+
options.name,
|
|
25986
|
+
options.interval,
|
|
25987
|
+
options.action,
|
|
25988
|
+
encodeValue(options.args ?? []),
|
|
25989
|
+
options.maxHistory
|
|
25990
|
+
);
|
|
25991
|
+
}
|
|
25992
|
+
async get(name) {
|
|
25993
|
+
const job = await this.#runtime.actorCronGet(this.#ctx, name);
|
|
25994
|
+
return job ? decodeCronJobInfo(job) : void 0;
|
|
25995
|
+
}
|
|
25996
|
+
async list() {
|
|
25997
|
+
return (await this.#runtime.actorCronList(this.#ctx)).map(
|
|
25998
|
+
decodeCronJobInfo
|
|
25646
25999
|
);
|
|
25647
26000
|
}
|
|
26001
|
+
async delete(name) {
|
|
26002
|
+
return await this.#runtime.actorCronDelete(this.#ctx, name);
|
|
26003
|
+
}
|
|
26004
|
+
async history(name, options) {
|
|
26005
|
+
return (await this.#runtime.actorCronHistory(
|
|
26006
|
+
this.#ctx,
|
|
26007
|
+
name,
|
|
26008
|
+
options == null ? void 0 : options.limit
|
|
26009
|
+
)).map(decodeCronFire);
|
|
26010
|
+
}
|
|
25648
26011
|
};
|
|
26012
|
+
function decodeScheduledEventInfo(event2) {
|
|
26013
|
+
return {
|
|
26014
|
+
id: event2.id,
|
|
26015
|
+
action: event2.action,
|
|
26016
|
+
args: decodeArgs(event2.args),
|
|
26017
|
+
runAt: event2.runAt
|
|
26018
|
+
};
|
|
26019
|
+
}
|
|
26020
|
+
function decodeCronJobInfo(job) {
|
|
26021
|
+
const base = {
|
|
26022
|
+
name: job.name,
|
|
26023
|
+
action: job.action,
|
|
26024
|
+
args: decodeArgs(job.args),
|
|
26025
|
+
nextRunAt: job.nextRunAt,
|
|
26026
|
+
lastRunAt: job.lastRunAt,
|
|
26027
|
+
maxHistory: job.maxHistory
|
|
26028
|
+
};
|
|
26029
|
+
if (job.kind === "cron") {
|
|
26030
|
+
return {
|
|
26031
|
+
...base,
|
|
26032
|
+
kind: "cron",
|
|
26033
|
+
expression: job.expression,
|
|
26034
|
+
timezone: job.timezone
|
|
26035
|
+
};
|
|
26036
|
+
}
|
|
26037
|
+
return {
|
|
26038
|
+
...base,
|
|
26039
|
+
kind: "every",
|
|
26040
|
+
interval: job.intervalMs
|
|
26041
|
+
};
|
|
26042
|
+
}
|
|
26043
|
+
function decodeCronFire(fire) {
|
|
26044
|
+
return { ...fire };
|
|
26045
|
+
}
|
|
25649
26046
|
var NativeKvAdapter = class {
|
|
25650
26047
|
#runtime;
|
|
25651
26048
|
#ctx;
|
|
@@ -26426,6 +26823,7 @@ var ActorContextHandleAdapter = class {
|
|
|
26426
26823
|
#client;
|
|
26427
26824
|
#clientFactory;
|
|
26428
26825
|
#connMap;
|
|
26826
|
+
#cron;
|
|
26429
26827
|
#databaseProvider;
|
|
26430
26828
|
#db;
|
|
26431
26829
|
#dispatchCancelToken;
|
|
@@ -26466,6 +26864,11 @@ var ActorContextHandleAdapter = class {
|
|
|
26466
26864
|
}
|
|
26467
26865
|
return this.#sql;
|
|
26468
26866
|
}
|
|
26867
|
+
async actorRuntimeSocket() {
|
|
26868
|
+
return await callNative(
|
|
26869
|
+
() => this.#runtime.actorRuntimeSocketProvision(this.#ctx)
|
|
26870
|
+
);
|
|
26871
|
+
}
|
|
26469
26872
|
get db() {
|
|
26470
26873
|
if (!this.#databaseProvider) {
|
|
26471
26874
|
throw databaseNotConfiguredError();
|
|
@@ -26555,6 +26958,12 @@ var ActorContextHandleAdapter = class {
|
|
|
26555
26958
|
}
|
|
26556
26959
|
return this.#schedule;
|
|
26557
26960
|
}
|
|
26961
|
+
get cron() {
|
|
26962
|
+
if (!this.#cron) {
|
|
26963
|
+
this.#cron = new NativeCronAdapter(this.#runtime, this.#ctx);
|
|
26964
|
+
}
|
|
26965
|
+
return this.#cron;
|
|
26966
|
+
}
|
|
26558
26967
|
get actorId() {
|
|
26559
26968
|
return callNativeSync(() => this.#runtime.actorId(this.#ctx));
|
|
26560
26969
|
}
|
|
@@ -26739,6 +27148,11 @@ var ActorContextHandleAdapter = class {
|
|
|
26739
27148
|
() => this.#runtime.actorRequestSave(this.#ctx, { immediate: false })
|
|
26740
27149
|
);
|
|
26741
27150
|
}
|
|
27151
|
+
async saveStateAndWorkflowBatch(writes) {
|
|
27152
|
+
await callNative(
|
|
27153
|
+
() => this.#runtime.actorSaveStateAndWorkflowBatch(this.#ctx, writes)
|
|
27154
|
+
);
|
|
27155
|
+
}
|
|
26742
27156
|
serializeForTick(reason) {
|
|
26743
27157
|
void reason;
|
|
26744
27158
|
const actorState = getNativePersistState(this.#runtime, this.#ctx);
|
|
@@ -27053,6 +27467,9 @@ var NativeWorkflowRuntimeAdapter = class {
|
|
|
27053
27467
|
this.stateManager = {
|
|
27054
27468
|
saveState: async (opts) => {
|
|
27055
27469
|
await this.#ctx.saveState(opts);
|
|
27470
|
+
},
|
|
27471
|
+
saveStateAndWorkflowBatch: async (writes) => {
|
|
27472
|
+
await this.#ctx.saveStateAndWorkflowBatch(writes);
|
|
27056
27473
|
}
|
|
27057
27474
|
};
|
|
27058
27475
|
}
|
|
@@ -27122,11 +27539,13 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
27122
27539
|
const config3 = definition.config;
|
|
27123
27540
|
const options = config3.options ?? {};
|
|
27124
27541
|
const canHibernate = options.canHibernateWebSocket;
|
|
27542
|
+
const usesRemoteSqlite = sqliteBackendForConfig(registryConfig) === "remote";
|
|
27125
27543
|
return {
|
|
27126
27544
|
name: options.name,
|
|
27127
27545
|
icon: options.icon,
|
|
27128
|
-
hasDatabase: config3.db !== void 0,
|
|
27129
|
-
remoteSqlite:
|
|
27546
|
+
hasDatabase: config3.db !== void 0 || usesRemoteSqlite,
|
|
27547
|
+
remoteSqlite: usesRemoteSqlite,
|
|
27548
|
+
enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
|
|
27130
27549
|
hasState: config3.state !== void 0 || typeof config3.createState === "function",
|
|
27131
27550
|
canHibernateWebsocket: typeof canHibernate === "boolean" ? canHibernate : void 0,
|
|
27132
27551
|
stateSaveIntervalMs: options.stateSaveInterval,
|
|
@@ -27142,6 +27561,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
27142
27561
|
connectionLivenessTimeoutMs: options.connectionLivenessTimeout,
|
|
27143
27562
|
connectionLivenessIntervalMs: options.connectionLivenessInterval,
|
|
27144
27563
|
maxQueueSize: options.maxQueueSize,
|
|
27564
|
+
maxSchedules: options.maxSchedules,
|
|
27145
27565
|
maxQueueMessageSize: options.maxQueueMessageSize,
|
|
27146
27566
|
maxIncomingMessageSize: registryConfig.maxIncomingMessageSize,
|
|
27147
27567
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
@@ -27418,7 +27838,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
27418
27838
|
400
|
|
27419
27839
|
);
|
|
27420
27840
|
}
|
|
27421
|
-
const cbor2 = encodeCborCompat(
|
|
27841
|
+
const cbor2 = encodeCborCompat(
|
|
27842
|
+
body.body ?? null
|
|
27843
|
+
);
|
|
27422
27844
|
const message = await runtime.actorQueueSend(ctx, name, cbor2);
|
|
27423
27845
|
return jsonResponse({
|
|
27424
27846
|
id: message.id().toString(),
|
|
@@ -28111,7 +28533,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28111
28533
|
name,
|
|
28112
28534
|
wrapNativeCallback(
|
|
28113
28535
|
async (error46, payload) => {
|
|
28114
|
-
const { ctx, conn, args, cancelToken } = unwrapTsfnPayload(error46, payload);
|
|
28536
|
+
const { ctx, conn, args, scheduledFire, cancelToken } = unwrapTsfnPayload(error46, payload);
|
|
28115
28537
|
const actorCtx = conn != null ? makeConnCtx(ctx, conn, void 0, cancelToken) : makeActorCtx(ctx, void 0, cancelToken);
|
|
28116
28538
|
try {
|
|
28117
28539
|
return encodeValue(
|
|
@@ -28121,7 +28543,8 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28121
28543
|
schemaConfig.actionInputSchemas,
|
|
28122
28544
|
name,
|
|
28123
28545
|
decodeArgs(args)
|
|
28124
|
-
)
|
|
28546
|
+
),
|
|
28547
|
+
...scheduledFire ? [scheduledFire] : []
|
|
28125
28548
|
)
|
|
28126
28549
|
);
|
|
28127
28550
|
} finally {
|