rivetkit 2.3.0-rc.5 → 2.3.0-rc.6
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/browser/client.d.ts +21 -18
- package/dist/browser/client.js +735 -170
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +4 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +3 -1
- package/dist/tsup/agent-os/index.cjs +1 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +18 -7
- package/dist/tsup/agent-os/index.d.ts +18 -7
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2G64KSZQ.cjs} +10 -10
- package/dist/tsup/{chunk-2GANBXVP.cjs.map → chunk-2G64KSZQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-N2DQSJIW.js → chunk-6S25NVAP.js} +13 -46
- package/dist/tsup/chunk-6S25NVAP.js.map +1 -0
- package/dist/tsup/{chunk-NATOT3ET.js → chunk-CAF6JDJE.js} +4 -4
- package/dist/tsup/{chunk-PGYEMIOE.js → chunk-DEO7MMWQ.js} +2 -2
- package/dist/tsup/{chunk-SULB574D.js → chunk-EMO6E3PJ.js} +3 -3
- package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ENK7C66G.cjs} +838 -236
- package/dist/tsup/chunk-ENK7C66G.cjs.map +1 -0
- package/dist/tsup/{chunk-JY73X7VU.js → chunk-FLODVLYW.js} +690 -88
- package/dist/tsup/chunk-FLODVLYW.js.map +1 -0
- package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-HTR4YLNT.cjs} +4 -4
- package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-HTR4YLNT.cjs.map} +1 -1
- package/dist/tsup/{chunk-LELRJK66.cjs → chunk-JALSAX7Z.cjs} +3 -3
- package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-JALSAX7Z.cjs.map} +1 -1
- package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-K5BA2LEO.cjs} +19 -52
- package/dist/tsup/chunk-K5BA2LEO.cjs.map +1 -0
- package/dist/tsup/{chunk-K34B3OVG.js → chunk-KIWH5H3K.js} +30 -9
- package/dist/tsup/chunk-KIWH5H3K.js.map +1 -0
- package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-LIXXFXVR.cjs} +5 -5
- package/dist/tsup/{chunk-NW2J4SOL.cjs.map → chunk-LIXXFXVR.cjs.map} +1 -1
- package/dist/tsup/{chunk-HR547GVH.cjs → chunk-M5C7YNI5.cjs} +8 -8
- package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-M5C7YNI5.cjs.map} +1 -1
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-QAZLM4WT.cjs} +31 -10
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +1 -0
- package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-RTC2AZGB.js} +2 -2
- package/dist/tsup/{chunk-UXTP4EBU.js → chunk-ZI5QJMKO.js} +2 -2
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.d.cts +3 -4
- package/dist/tsup/client/mod.d.ts +3 -4
- package/dist/tsup/client/mod.js +6 -6
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-CvQUtDp9.d.ts → config-0Ta55UV0.d.ts} +10 -9
- package/dist/tsup/{config-C-a9vrke.d.cts → config-Ca8dN4cS.d.cts} +10 -9
- package/dist/tsup/{context-A7R0bsZL.d.ts → context-B_IWbWne.d.ts} +1 -1
- package/dist/tsup/{context-CA3r-pf2.d.cts → context-CUrQ9MHc.d.cts} +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +252 -207
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -5
- package/dist/tsup/mod.d.ts +4 -5
- package/dist/tsup/mod.js +183 -138
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -3
- package/dist/tsup/test/mod.d.ts +2 -3
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
- package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +9 -9
- package/dist/tsup/workflow/mod.d.cts +4 -5
- package/dist/tsup/workflow/mod.d.ts +4 -5
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +8 -8
- package/src/actor/errors.ts +53 -7
- package/src/client/actor-conn.ts +52 -29
- package/src/client/actor-handle.ts +57 -23
- package/src/client/errors.ts +2 -1
- package/src/client/raw-utils.ts +2 -4
- package/src/client/utils.ts +32 -3
- package/src/common/actor-router-consts.ts +4 -0
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/client-protocol-versioned.ts +125 -18
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/native-database.test.ts +35 -0
- package/src/common/database/native-database.ts +8 -4
- package/src/common/router.ts +38 -8
- package/src/common/utils.ts +9 -52
- package/src/drivers/engine/actor-driver.ts +18 -17
- package/src/registry/config/index.ts +3 -5
- package/src/registry/index.ts +156 -19
- package/src/registry/napi-runtime.ts +44 -6
- package/src/registry/native.ts +5 -152
- package/src/registry/runtime.ts +16 -5
- package/src/registry/wasm-runtime.ts +22 -2
- package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
- package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
- package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- /package/dist/tsup/{chunk-NATOT3ET.js.map → chunk-CAF6JDJE.js.map} +0 -0
- /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-DEO7MMWQ.js.map} +0 -0
- /package/dist/tsup/{chunk-SULB574D.js.map → chunk-EMO6E3PJ.js.map} +0 -0
- /package/dist/tsup/{chunk-LDTT6WKJ.js.map → chunk-RTC2AZGB.js.map} +0 -0
- /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-ZI5QJMKO.js.map} +0 -0
|
@@ -4,7 +4,7 @@ var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
|
4
4
|
var USER_ERROR_CODE = "user_error";
|
|
5
5
|
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
6
6
|
function looksLikeRivetErrorOptions(value) {
|
|
7
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "cause" in value);
|
|
7
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
8
8
|
}
|
|
9
9
|
function isTypedErrorTag(value) {
|
|
10
10
|
return value === "ActorError" || value === "RivetError";
|
|
@@ -18,11 +18,15 @@ function errorMessage(error, fallback = String(error)) {
|
|
|
18
18
|
function isRivetErrorLike(error) {
|
|
19
19
|
return typeof error === "object" && error !== null && "group" in error && typeof error.group === "string" && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string" && (!("__type" in error) || isTypedErrorTag(error.__type));
|
|
20
20
|
}
|
|
21
|
+
function isActorSpecifier(value) {
|
|
22
|
+
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
23
|
+
}
|
|
21
24
|
var RivetError = class extends Error {
|
|
22
25
|
__type = "RivetError";
|
|
23
26
|
public;
|
|
24
27
|
metadata;
|
|
25
28
|
statusCode;
|
|
29
|
+
actor;
|
|
26
30
|
group;
|
|
27
31
|
code;
|
|
28
32
|
static isRivetError(error) {
|
|
@@ -40,6 +44,7 @@ var RivetError = class extends Error {
|
|
|
40
44
|
this.public = normalized.public ?? false;
|
|
41
45
|
this.metadata = normalized.metadata;
|
|
42
46
|
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
47
|
+
this.actor = normalized.actor;
|
|
43
48
|
}
|
|
44
49
|
toString() {
|
|
45
50
|
return this.message;
|
|
@@ -72,6 +77,7 @@ function toRivetError(error, fallback) {
|
|
|
72
77
|
public: error.public,
|
|
73
78
|
statusCode: error.statusCode,
|
|
74
79
|
metadata: error.metadata,
|
|
80
|
+
actor: error.actor,
|
|
75
81
|
cause: error instanceof Error ? error.cause : void 0
|
|
76
82
|
});
|
|
77
83
|
}
|
|
@@ -83,6 +89,7 @@ function toRivetError(error, fallback) {
|
|
|
83
89
|
public: fallback == null ? void 0 : fallback.public,
|
|
84
90
|
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
85
91
|
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
92
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
86
93
|
cause: error instanceof Error ? error : void 0
|
|
87
94
|
}
|
|
88
95
|
);
|
|
@@ -94,10 +101,11 @@ function encodeBridgeRivetError(error) {
|
|
|
94
101
|
message: error.message,
|
|
95
102
|
metadata: error.metadata,
|
|
96
103
|
public: error.public,
|
|
97
|
-
statusCode: error.statusCode
|
|
104
|
+
statusCode: error.statusCode,
|
|
105
|
+
actor: error.actor
|
|
98
106
|
})}`;
|
|
99
107
|
}
|
|
100
|
-
function
|
|
108
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
101
109
|
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
102
110
|
return void 0;
|
|
103
111
|
}
|
|
@@ -108,15 +116,26 @@ function decodeBridgeRivetError(value) {
|
|
|
108
116
|
if (!isRivetErrorLike(payload)) {
|
|
109
117
|
return void 0;
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
119
|
+
if (payload.actor !== void 0 && !isActorSpecifier(payload.actor)) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
return payload;
|
|
116
123
|
} catch {
|
|
117
124
|
return void 0;
|
|
118
125
|
}
|
|
119
126
|
}
|
|
127
|
+
function decodeBridgeRivetError(value) {
|
|
128
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
129
|
+
if (!payload) {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
133
|
+
metadata: payload.metadata,
|
|
134
|
+
public: payload.public,
|
|
135
|
+
statusCode: payload.statusCode,
|
|
136
|
+
actor: payload.actor
|
|
137
|
+
});
|
|
138
|
+
}
|
|
120
139
|
function isRivetErrorCode(error, group, code) {
|
|
121
140
|
return isRivetErrorLike(error) && error.group === group && error.code === code;
|
|
122
141
|
}
|
|
@@ -129,6 +148,7 @@ function internalError(message, options) {
|
|
|
129
148
|
public: options == null ? void 0 : options.public,
|
|
130
149
|
statusCode: options == null ? void 0 : options.statusCode,
|
|
131
150
|
metadata: options == null ? void 0 : options.metadata,
|
|
151
|
+
actor: options == null ? void 0 : options.actor,
|
|
132
152
|
cause: options == null ? void 0 : options.cause
|
|
133
153
|
}
|
|
134
154
|
);
|
|
@@ -210,6 +230,7 @@ export {
|
|
|
210
230
|
UserError,
|
|
211
231
|
toRivetError,
|
|
212
232
|
encodeBridgeRivetError,
|
|
233
|
+
decodeBridgeRivetErrorPayload,
|
|
213
234
|
decodeBridgeRivetError,
|
|
214
235
|
isRivetErrorCode,
|
|
215
236
|
internalError,
|
|
@@ -221,4 +242,4 @@ export {
|
|
|
221
242
|
forbiddenError,
|
|
222
243
|
unsupportedFeature
|
|
223
244
|
};
|
|
224
|
-
//# sourceMappingURL=chunk-
|
|
245
|
+
//# sourceMappingURL=chunk-KIWH5H3K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/actor/errors.ts"],"sourcesContent":["import type { DeconstructedError } from \"@/common/utils\";\n\nexport const INTERNAL_ERROR_CODE = \"internal_error\";\nexport const INTERNAL_ERROR_DESCRIPTION = \"An internal error occurred\";\nexport type InternalErrorMetadata = Record<string, never>;\n\nexport const USER_ERROR_CODE = \"user_error\";\nexport const BRIDGE_RIVET_ERROR_PREFIX = \"__RIVET_ERROR_JSON__:\";\n\nexport interface RivetErrorOptions extends ErrorOptions {\n\t/** Error data can safely be serialized in a response to the client. */\n\tpublic?: boolean;\n\t/** Metadata associated with this error. */\n\tmetadata?: unknown;\n\t/** Explicit HTTP status override for router responses. */\n\tstatusCode?: number;\n\t/** Actor context associated with this error. */\n\tactor?: ActorSpecifier;\n}\n\n/** Identifies the actor that was handling work when an error was produced. */\nexport interface ActorSpecifier {\n\tactorId: string;\n\tgeneration: number;\n\tkey?: string;\n}\n\nexport interface RivetErrorLike {\n\t__type?: \"ActorError\" | \"RivetError\";\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n\tpublic?: boolean;\n\tstatusCode?: number;\n\tactor?: ActorSpecifier;\n}\n\nexport interface BridgeRivetErrorPayload extends RivetErrorLike {}\n\nexport interface UserErrorOptions extends ErrorOptions {\n\t/**\n\t * Machine readable code for this error. Useful for catching different types of\n\t * errors in try-catch.\n\t */\n\tcode?: string;\n\t/**\n\t * Additional metadata related to the error. Useful for understanding context\n\t * about the error.\n\t */\n\tmetadata?: unknown;\n}\n\nfunction looksLikeRivetErrorOptions(\n\tvalue: unknown,\n): value is RivetErrorOptions {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t(\"public\" in value ||\n\t\t\t\"metadata\" in value ||\n\t\t\t\"statusCode\" in value ||\n\t\t\t\"actor\" in value ||\n\t\t\t\"cause\" in value)\n\t);\n}\n\nfunction isTypedErrorTag(value: unknown): value is \"ActorError\" | \"RivetError\" {\n\treturn value === \"ActorError\" || value === \"RivetError\";\n}\n\nfunction errorMessage(error: unknown, fallback = String(error)): string {\n\tif (\n\t\terror &&\n\t\ttypeof error === \"object\" &&\n\t\t\"message\" in error &&\n\t\ttypeof error.message === \"string\"\n\t) {\n\t\treturn error.message;\n\t}\n\n\treturn fallback;\n}\n\nexport function isRivetErrorLike(\n\terror: unknown,\n): error is RivetError | DeconstructedError | RivetErrorLike {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"group\" in error &&\n\t\ttypeof error.group === \"string\" &&\n\t\t\"code\" in error &&\n\t\ttypeof error.code === \"string\" &&\n\t\t\"message\" in error &&\n\t\ttypeof error.message === \"string\" &&\n\t\t(!(\"__type\" in error) || isTypedErrorTag(error.__type))\n\t);\n}\n\nfunction isActorSpecifier(value: unknown): value is ActorSpecifier {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"actorId\" in value &&\n\t\ttypeof value.actorId === \"string\" &&\n\t\t\"generation\" in value &&\n\t\ttypeof value.generation === \"number\" &&\n\t\t(!(\"key\" in value) || value.key === undefined || typeof value.key === \"string\")\n\t);\n}\n\nexport class RivetError extends Error {\n\t__type = \"RivetError\" as const;\n\n\tpublic public: boolean;\n\tpublic metadata?: unknown;\n\tpublic statusCode: number;\n\tpublic actor?: ActorSpecifier;\n\tpublic readonly group: string;\n\tpublic readonly code: string;\n\n\tpublic static isRivetError(\n\t\terror: unknown,\n\t): error is RivetError | DeconstructedError {\n\t\treturn isRivetErrorLike(error);\n\t}\n\n\tpublic static isActorError(\n\t\terror: unknown,\n\t): error is RivetError | DeconstructedError {\n\t\treturn isRivetErrorLike(error);\n\t}\n\n\tconstructor(\n\t\tgroup: string,\n\t\tcode: string,\n\t\tmessage: string,\n\t\toptions?: RivetErrorOptions | unknown,\n\t) {\n\t\tconst normalized = looksLikeRivetErrorOptions(options)\n\t\t\t? options\n\t\t\t: { metadata: options };\n\n\t\tsuper(message, { cause: normalized.cause });\n\t\tthis.name = \"RivetError\";\n\t\tthis.group = group;\n\t\tthis.code = code;\n\t\tthis.public = normalized.public ?? false;\n\t\tthis.metadata = normalized.metadata;\n\t\tthis.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);\n\t\tthis.actor = normalized.actor;\n\t}\n\n\ttoString() {\n\t\treturn this.message;\n\t}\n}\n\nexport { RivetError as ActorError };\n\nexport class UserError extends RivetError {\n\tconstructor(message: string, options?: UserErrorOptions) {\n\t\tsuper(\"user\", options?.code ?? USER_ERROR_CODE, message, {\n\t\t\tpublic: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tcause: options?.cause,\n\t\t});\n\t}\n}\n\nexport function toRivetError(\n\terror: unknown,\n\tfallback?: Partial<RivetErrorLike>,\n): RivetError {\n\tif (typeof error === \"string\") {\n\t\tconst bridged = decodeBridgeRivetError(error);\n\t\tif (bridged) {\n\t\t\treturn bridged;\n\t\t}\n\t}\n\n\tif (error instanceof Error) {\n\t\tconst bridged = decodeBridgeRivetError(error.message);\n\t\tif (bridged) {\n\t\t\treturn bridged;\n\t\t}\n\t}\n\n\tif (isRivetErrorLike(error)) {\n\t\treturn new RivetError(error.group, error.code, error.message, {\n\t\t\tpublic: error.public,\n\t\t\tstatusCode: error.statusCode,\n\t\t\tmetadata: error.metadata,\n\t\t\tactor: error.actor,\n\t\t\tcause: error instanceof Error ? error.cause : undefined,\n\t\t});\n\t}\n\n\treturn new RivetError(\n\t\tfallback?.group ?? \"actor\",\n\t\tfallback?.code ?? INTERNAL_ERROR_CODE,\n\t\terrorMessage(error, fallback?.message ?? \"Unknown error\"),\n\t\t{\n\t\t\tpublic: fallback?.public,\n\t\t\tstatusCode: fallback?.statusCode,\n\t\t\tmetadata: fallback?.metadata,\n\t\t\tactor: fallback?.actor,\n\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t},\n\t);\n}\n\nexport function encodeBridgeRivetError(error: RivetErrorLike): string {\n\treturn `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({\n\t\tgroup: error.group,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\tmetadata: error.metadata,\n\t\tpublic: error.public,\n\t\tstatusCode: error.statusCode,\n\t\tactor: error.actor,\n\t})}`;\n}\n\nexport function decodeBridgeRivetErrorPayload(\n\tvalue: string,\n): BridgeRivetErrorPayload | undefined {\n\tif (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {\n\t\treturn undefined;\n\t}\n\n\ttry {\n\t\tconst payload = JSON.parse(\n\t\t\tvalue.slice(BRIDGE_RIVET_ERROR_PREFIX.length),\n\t\t) as BridgeRivetErrorPayload;\n\t\tif (!isRivetErrorLike(payload)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (payload.actor !== undefined && !isActorSpecifier(payload.actor)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn payload;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function decodeBridgeRivetError(value: string): RivetError | undefined {\n\tconst payload = decodeBridgeRivetErrorPayload(value);\n\tif (!payload) {\n\t\treturn undefined;\n\t}\n\n\treturn new RivetError(payload.group, payload.code, payload.message, {\n\t\tmetadata: payload.metadata,\n\t\tpublic: payload.public,\n\t\tstatusCode: payload.statusCode,\n\t\tactor: payload.actor,\n\t});\n}\n\nexport function isRivetErrorCode(\n\terror: unknown,\n\tgroup: string,\n\tcode: string,\n): error is RivetError {\n\treturn (\n\t\tisRivetErrorLike(error) && error.group === group && error.code === code\n\t);\n}\n\nexport function internalError(\n\tmessage: string,\n\toptions?: Partial<RivetErrorOptions> & {\n\t\tgroup?: string;\n\t\tcode?: string;\n\t},\n): RivetError {\n\treturn new RivetError(\n\t\toptions?.group ?? \"actor\",\n\t\toptions?.code ?? INTERNAL_ERROR_CODE,\n\t\tmessage,\n\t\t{\n\t\t\tpublic: options?.public,\n\t\t\tstatusCode: options?.statusCode,\n\t\t\tmetadata: options?.metadata,\n\t\t\tactor: options?.actor,\n\t\t\tcause: options?.cause,\n\t\t},\n\t);\n}\n\nexport function invalidEncoding(format?: string): RivetError {\n\treturn new RivetError(\n\t\t\"encoding\",\n\t\t\"invalid\",\n\t\t`Invalid encoding \\`${format}\\`. (https://www.rivet.dev/docs/clients/javascript)`,\n\t\t{\n\t\t\tpublic: true,\n\t\t},\n\t);\n}\n\nexport function invalidRequest(error?: unknown): RivetError {\n\treturn new RivetError(\n\t\t\"request\",\n\t\t\"invalid\",\n\t\t`Invalid request: ${errorMessage(error, String(error))}`,\n\t\t{\n\t\t\tpublic: true,\n\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t},\n\t);\n}\n\nexport function actorNotFound(identifier?: string): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"not_found\",\n\t\tidentifier\n\t\t\t? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)`\n\t\t\t: \"Actor not found (https://www.rivet.dev/docs/clients/javascript)\",\n\t\t{ public: true },\n\t);\n}\n\nexport function actorStopping(identifier?: string): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"stopping\",\n\t\tidentifier ? `Actor stopping: ${identifier}` : \"Actor stopping\",\n\t\t{ public: true },\n\t);\n}\n\nexport interface ActorRestartingOptions {\n\tphase?: \"stopping\" | \"sleeping\" | \"waking\" | \"runner_shutdown\";\n\tretryAfterMs?: number;\n}\n\nexport function actorRestarting(opts?: ActorRestartingOptions): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"restarting\",\n\t\t\"Actor is restarting. Retry the request.\",\n\t\t{\n\t\t\tpublic: true,\n\t\t\tstatusCode: 503,\n\t\t\tmetadata: {\n\t\t\t\tretryable: true,\n\t\t\t\t...(opts?.phase ? { phase: opts.phase } : {}),\n\t\t\t\t...(opts?.retryAfterMs !== undefined\n\t\t\t\t\t? { retryAfterMs: opts.retryAfterMs }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport function forbiddenError(): RivetError {\n\treturn new RivetError(\"auth\", \"forbidden\", \"Forbidden\", {\n\t\tpublic: true,\n\t\tstatusCode: 403,\n\t});\n}\n\nexport function unsupportedFeature(feature: string): RivetError {\n\treturn new RivetError(\n\t\t\"feature\",\n\t\t\"unsupported\",\n\t\t`Unsupported feature: ${feature}`,\n\t);\n}\n"],"mappings":";AAEO,IAAM,sBAAsB;AAC5B,IAAM,6BAA6B;AAGnC,IAAM,kBAAkB;AACxB,IAAM,4BAA4B;AA8CzC,SAAS,2BACR,OAC6B;AAC7B,SACC,OAAO,UAAU,YACjB,UAAU,SACT,YAAY,SACZ,cAAc,SACd,gBAAgB,SAChB,WAAW,SACX,WAAW;AAEd;AAEA,SAAS,gBAAgB,OAAsD;AAC9E,SAAO,UAAU,gBAAgB,UAAU;AAC5C;AAEA,SAAS,aAAa,OAAgB,WAAW,OAAO,KAAK,GAAW;AACvE,MACC,SACA,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY,UACxB;AACD,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAEO,SAAS,iBACf,OAC4D;AAC5D,SACC,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAO,MAAM,UAAU,YACvB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,aAAa,SACb,OAAO,MAAM,YAAY,aACxB,EAAE,YAA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,oBAAoB,UAAU,qDAC9B;AAAA,IACH,EAAE,QAAQ,KAAK;AAAA,EAChB;AACD;AAEO,SAAS,cAAc,YAAiC;AAC9D,SAAO,IAAI;AAAA,IACV;AAAA,IACA;AAAA,IACA,aAAa,mBAAmB,UAAU,KAAK;AAAA,IAC/C,EAAE,QAAQ,KAAK;AAAA,EAChB;AACD;AAOO,SAAS,gBAAgB,MAA2C;AAC1E,SAAO,IAAI;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACC,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,UAAU;AAAA,QACT,WAAW;AAAA,QACX,IAAI,6BAAM,SAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,QAC3C,IAAI,6BAAM,kBAAiB,SACxB,EAAE,cAAc,KAAK,aAAa,IAClC,CAAC;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACD;AAEO,SAAS,iBAA6B;AAC5C,SAAO,IAAI,WAAW,QAAQ,aAAa,aAAa;AAAA,IACvD,QAAQ;AAAA,IACR,YAAY;AAAA,EACb,CAAC;AACF;AAEO,SAAS,mBAAmB,SAA6B;AAC/D,SAAO,IAAI;AAAA,IACV;AAAA,IACA;AAAA,IACA,wBAAwB,OAAO;AAAA,EAChC;AACD;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkK5BA2LEOcjs = require('./chunk-K5BA2LEO.cjs');
|
|
4
4
|
|
|
5
5
|
// src/serde.ts
|
|
6
6
|
var _cborx = require('cbor-x'); var cbor = _interopRequireWildcard(_cborx);
|
|
@@ -175,7 +175,7 @@ function contentTypeForEncoding(encoding) {
|
|
|
175
175
|
} else if (encoding === "cbor" || encoding === "bare") {
|
|
176
176
|
return "application/octet-stream";
|
|
177
177
|
} else {
|
|
178
|
-
|
|
178
|
+
_chunkK5BA2LEOcjs.assertUnreachable.call(void 0, encoding);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
function encodeCborCompat(value) {
|
|
@@ -213,7 +213,7 @@ function serializeWithEncoding(encoding, value, versionedDataHandler, version, z
|
|
|
213
213
|
version
|
|
214
214
|
);
|
|
215
215
|
} else {
|
|
216
|
-
|
|
216
|
+
_chunkK5BA2LEOcjs.assertUnreachable.call(void 0, encoding);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
function deserializeWithEncoding(encoding, buffer, versionedDataHandler, zodSchema, fromJson, fromBare) {
|
|
@@ -249,7 +249,7 @@ function deserializeWithEncoding(encoding, buffer, versionedDataHandler, zodSche
|
|
|
249
249
|
const bareValue = versionedDataHandler.deserializeWithEmbeddedVersion(buffer);
|
|
250
250
|
return fromBare(bareValue);
|
|
251
251
|
} else {
|
|
252
|
-
|
|
252
|
+
_chunkK5BA2LEOcjs.assertUnreachable.call(void 0, encoding);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -265,4 +265,4 @@ function deserializeWithEncoding(encoding, buffer, versionedDataHandler, zodSche
|
|
|
265
265
|
|
|
266
266
|
|
|
267
267
|
exports.uint8ArrayToBase64 = uint8ArrayToBase64; exports.contentTypeForEncoding = contentTypeForEncoding; exports.encodeCborCompat = encodeCborCompat; exports.decodeCborCompat = decodeCborCompat; exports.decodeCborJsonCompat = decodeCborJsonCompat; exports.serializeWithEncoding = serializeWithEncoding; exports.deserializeWithEncoding = deserializeWithEncoding; exports.EncodingSchema = EncodingSchema; exports.inputDataToBuffer = inputDataToBuffer; exports.jsonStringifyCompat = jsonStringifyCompat;
|
|
268
|
-
//# sourceMappingURL=chunk-
|
|
268
|
+
//# sourceMappingURL=chunk-LIXXFXVR.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-NW2J4SOL.cjs","../../src/serde.ts","../../src/common/encoding.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,2EAAsB;AACtB,4FAAsB;ADMtB;AACA;AERA,4BAAkB;AAWlB,IAAM,mBAAA,EAAqB,SAAA;AAC3B,IAAM,yBAAA,EAA2B,cAAA;AACjC,IAAM,wBAAA,EAA0B,aAAA;AAChC,IAAM,sBAAA,EAAwB,YAAA;AAEvB,IAAM,eAAA,EAAiB,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM,CAAC,CAAA;AA2D7D,MAAA,SAAsB,iBAAA,CACrB,IAAA,EAC+B;AAC/B,EAAA,GAAA,CAAI,OAAO,KAAA,IAAS,QAAA,EAAU;AAC7B,IAAA,OAAO,IAAA;AAAA,EACR;AACA,EAAA,GAAA,CAAI,KAAA,WAAgB,IAAA,EAAM;AACzB,IAAA,OAAO,IAAI,UAAA,CAAW,MAAM,IAAA,CAAK,WAAA,CAAY,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,GAAA,CAAI,KAAA,WAAgB,UAAA,EAAY;AAC/B,IAAA,OAAO,IAAA;AAAA,EACR;AACA,EAAA,GAAA,CAAI,KAAA,WAAgB,YAAA,GAAe,KAAA,WAAgB,iBAAA,EAAmB;AACrE,IAAA,OAAO,IAAI,UAAA,CAAW,IAAI,CAAA;AAAA,EAC3B;AACA,EAAA,MAAM,IAAI,KAAA,CAAM,mBAAmB,CAAA;AACpC;AAEA,SAAS,sBAAA,CAAuB,UAAA,EAAgC;AAC/D,EAAA,IAAI,OAAA,EAAS,EAAA;AACb,EAAA,IAAA,CAAA,MAAW,MAAA,GAAS,UAAA,EAAY;AAC/B,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A,MACC,OAAO,OAAA,IAAW,QAAA;AAAA,MAClB;AAAA,IACD,CAAA;AAEA,IAAA,MAAM,QAAA,EAAU,gBAAA,CAAiB,MAAM,CAAA;AAEvC,IAAA,MAAM,UAAA,EAAY,SAAA,CAAU,KAAA,CAAM,OAAO,CAAA;AAEzC,IAAA,OAAO,QAAA,CAAS,SAAS,CAAA;AAAA,EAC1B,EAAA,KAAA,GAAA,CAAW,SAAA,IAAa,MAAA,EAAQ;AAC/B,IAAA,iCAAA;AAAA,MACC,OAAO,OAAA,IAAW,QAAA;AAAA,MAClB;AAAA,IACD,CAAA;AACA,IAAA,GAAA,CAAI,CAAC,oBAAA,EAAsB;AAC1B,MAAA,MAAM,IAAI,KAAA;AAAA,QACT;AAAA,MACD,CAAA;AAAA,IACD;AACA,IAAA,MAAM,UAAA,EACL,oBAAA,CAAqB,8BAAA,CAA+B,MAAM,CAAA;AAC3D,IAAA,OAAO,QAAA,CAAS,SAAS,CAAA;AAAA,EAC1B,EAAA,KAAO;AACN,IAAA,iDAAA,QAA0B,CAAA;AAAA,EAC3B;AACD;ADkGA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,qfAAC","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-NW2J4SOL.cjs","sourcesContent":[null,"import * as cbor from \"cbor-x\";\nimport invariant from \"invariant\";\nimport type { VersionedDataHandler } from \"vbare\";\nimport type { z } from \"zod/v4\";\nimport { assertUnreachable } from \"@/common/utils\";\nimport type { Encoding } from \"@/common/encoding\";\nimport {\n\tencodeJsonCompatValue,\n\tjsonParseCompat,\n\tjsonStringifyCompat,\n\treviveJsonCompatValue,\n} from \"./common/encoding\";\n\nexport function uint8ArrayToBase64(uint8Array: Uint8Array): string {\n\t// Check if Buffer is available (Node.js)\n\tif (typeof Buffer !== \"undefined\") {\n\t\treturn Buffer.from(uint8Array).toString(\"base64\");\n\t}\n\n\t// Browser environment - use btoa\n\tlet binary = \"\";\n\tconst len = uint8Array.byteLength;\n\tfor (let i = 0; i < len; i++) {\n\t\tbinary += String.fromCharCode(uint8Array[i]);\n\t}\n\treturn btoa(binary);\n}\n\nexport function encodingIsBinary(encoding: Encoding): boolean {\n\tif (encoding === \"json\") {\n\t\treturn false;\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn true;\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function contentTypeForEncoding(encoding: Encoding): string {\n\tif (encoding === \"json\") {\n\t\treturn \"application/json\";\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn \"application/octet-stream\";\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function encodeCborCompat(value: unknown): Uint8Array {\n\treturn cbor.encode(encodeJsonCompatValue(value));\n}\n\nexport function decodeCborCompat<T>(buffer: Uint8Array): T {\n\treturn reviveJsonCompatValue(cbor.decode(buffer)) as T;\n}\n\nexport function decodeCborJsonCompat<T>(buffer: Uint8Array): T {\n\treturn reviveJsonCompatValue(cbor.decode(buffer), {\n\t\tcoerceSafeIntegerBigInts: true,\n\t}) as T;\n}\n\nexport function wsBinaryTypeForEncoding(\n\tencoding: Encoding,\n): \"arraybuffer\" | \"blob\" {\n\tif (encoding === \"json\") {\n\t\treturn \"blob\";\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn \"arraybuffer\";\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function serializeWithEncoding<TBare, TJson, T = TBare>(\n\tencoding: Encoding,\n\tvalue: T,\n\tversionedDataHandler: VersionedDataHandler<TBare> | undefined,\n\tversion: number | undefined,\n\tzodSchema: z.ZodType<TJson>,\n\ttoJson: (value: T) => TJson,\n\ttoBare: (value: T) => TBare,\n): Uint8Array | string {\n\tif (encoding === \"json\") {\n\t\tconst jsonValue = toJson(value);\n\t\tconst validated = zodSchema.parse(jsonValue);\n\t\treturn jsonStringifyCompat(validated);\n\t} else if (encoding === \"cbor\") {\n\t\tconst jsonValue = toJson(value);\n\t\tconst validated = zodSchema.parse(jsonValue);\n\t\treturn cbor.encode(validated);\n\t} else if (encoding === \"bare\") {\n\t\tif (!versionedDataHandler) {\n\t\t\tthrow new Error(\n\t\t\t\t\"VersionedDataHandler is required for 'bare' encoding\",\n\t\t\t);\n\t\t}\n\t\tif (version === undefined) {\n\t\t\tthrow new Error(\"version is required for 'bare' encoding\");\n\t\t}\n\t\tconst bareValue = toBare(value);\n\t\treturn versionedDataHandler.serializeWithEmbeddedVersion(\n\t\t\tbareValue,\n\t\t\tversion,\n\t\t);\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function deserializeWithEncoding<TBare, TJson, T = TBare>(\n\tencoding: Encoding,\n\tbuffer: Uint8Array | string,\n\tversionedDataHandler: VersionedDataHandler<TBare> | undefined,\n\tzodSchema: z.ZodType<TJson>,\n\tfromJson: (value: TJson) => T,\n\tfromBare: (value: TBare) => T,\n): T {\n\tif (encoding === \"json\") {\n\t\tlet parsed: unknown;\n\t\tif (typeof buffer === \"string\") {\n\t\t\tparsed = jsonParseCompat(buffer);\n\t\t} else {\n\t\t\tconst decoder = new TextDecoder(\"utf-8\");\n\t\t\tconst jsonString = decoder.decode(buffer);\n\t\t\tparsed = jsonParseCompat(jsonString);\n\t\t}\n\t\tconst validated = zodSchema.parse(parsed);\n\t\treturn fromJson(validated);\n\t} else if (encoding === \"cbor\") {\n\t\tinvariant(\n\t\t\ttypeof buffer !== \"string\",\n\t\t\t\"buffer cannot be string for cbor encoding\",\n\t\t);\n\t\t// Decode CBOR to get JavaScript values (similar to JSON.parse)\n\t\tconst decoded = decodeCborCompat(buffer);\n\t\t// Validate with Zod schema (CBOR produces same structure as JSON)\n\t\tconst validated = zodSchema.parse(decoded);\n\t\t// CBOR decoding produces JS objects, use fromJson\n\t\treturn fromJson(validated);\n\t} else if (encoding === \"bare\") {\n\t\tinvariant(\n\t\t\ttypeof buffer !== \"string\",\n\t\t\t\"buffer cannot be string for bare encoding\",\n\t\t);\n\t\tif (!versionedDataHandler) {\n\t\t\tthrow new Error(\n\t\t\t\t\"VersionedDataHandler is required for 'bare' encoding\",\n\t\t\t);\n\t\t}\n\t\tconst bareValue =\n\t\t\tversionedDataHandler.deserializeWithEmbeddedVersion(buffer);\n\t\treturn fromBare(bareValue);\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n","import { z } from \"zod/v4\";\nimport type { VersionedDataHandler } from \"vbare\";\nimport { serializeWithEncoding } from \"@/serde\";\nimport { assertUnreachable } from \"./utils\";\n\n/** Data that can be deserialized. */\nexport type InputData = string | Buffer | Blob | ArrayBufferLike | Uint8Array;\n\n/** Data that's been serialized. */\nexport type OutputData = string | Uint8Array;\n\nconst JSON_COMPAT_BIGINT = \"$BigInt\";\nconst JSON_COMPAT_ARRAY_BUFFER = \"$ArrayBuffer\";\nconst JSON_COMPAT_UINT8_ARRAY = \"$Uint8Array\";\nconst JSON_COMPAT_UNDEFINED = \"$Undefined\";\n\nexport const EncodingSchema = z.enum([\"json\", \"cbor\", \"bare\"]);\n\n/**\n * Encoding used to communicate between the client & actor.\n */\nexport type Encoding = z.infer<typeof EncodingSchema>;\n\n/**\n * Helper class that helps serialize data without re-serializing for the same encoding.\n */\nexport class CachedSerializer<TBare, TJson, T = TBare> {\n\t#data: T;\n\t#cache = new Map<Encoding, OutputData>();\n\t#versionedDataHandler: VersionedDataHandler<TBare>;\n\t#version: number;\n\t#zodSchema: z.ZodType<TJson>;\n\t#toJson: (value: T) => TJson;\n\t#toBare: (value: T) => TBare;\n\n\tconstructor(\n\t\tdata: T,\n\t\tversionedDataHandler: VersionedDataHandler<TBare>,\n\t\tversion: number,\n\t\tzodSchema: z.ZodType<TJson>,\n\t\ttoJson: (value: T) => TJson,\n\t\ttoBare: (value: T) => TBare,\n\t) {\n\t\tthis.#data = data;\n\t\tthis.#versionedDataHandler = versionedDataHandler;\n\t\tthis.#version = version;\n\t\tthis.#zodSchema = zodSchema;\n\t\tthis.#toJson = toJson;\n\t\tthis.#toBare = toBare;\n\t}\n\n\tpublic get rawData(): T {\n\t\treturn this.#data;\n\t}\n\n\tpublic serialize(encoding: Encoding): OutputData {\n\t\tconst cached = this.#cache.get(encoding);\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\n\t\tconst serialized = serializeWithEncoding(\n\t\t\tencoding,\n\t\t\tthis.#data,\n\t\t\tthis.#versionedDataHandler,\n\t\t\tthis.#version,\n\t\t\tthis.#zodSchema,\n\t\t\tthis.#toJson,\n\t\t\tthis.#toBare,\n\t\t);\n\t\tthis.#cache.set(encoding, serialized);\n\t\treturn serialized;\n\t}\n}\n\nexport async function inputDataToBuffer(\n\tdata: InputData,\n): Promise<Uint8Array | string> {\n\tif (typeof data === \"string\") {\n\t\treturn data;\n\t}\n\tif (data instanceof Blob) {\n\t\treturn new Uint8Array(await data.arrayBuffer());\n\t}\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t}\n\tif (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t}\n\tthrow new Error(\"Malformed message\");\n}\n\nfunction base64EncodeUint8Array(uint8Array: Uint8Array): string {\n\tlet binary = \"\";\n\tfor (const value of uint8Array) {\n\t\tbinary += String.fromCharCode(value);\n\t}\n\treturn btoa(binary);\n}\n\nfunction base64EncodeArrayBuffer(arrayBuffer: ArrayBuffer): string {\n\treturn base64EncodeUint8Array(new Uint8Array(arrayBuffer));\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\n\nexport function encodeJsonCompatValue(input: any): any {\n\tif (input === undefined) {\n\t\treturn [JSON_COMPAT_UNDEFINED, 0];\n\t}\n\tif (typeof input === \"bigint\") {\n\t\treturn [JSON_COMPAT_BIGINT, input.toString()];\n\t}\n\tif (input instanceof ArrayBuffer) {\n\t\treturn [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];\n\t}\n\tif (input instanceof Uint8Array) {\n\t\treturn [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];\n\t}\n\tif (Array.isArray(input)) {\n\t\tconst encoded = input.map((value) => encodeJsonCompatValue(value));\n\t\tif (\n\t\t\tencoded.length === 2 &&\n\t\t\ttypeof encoded[0] === \"string\" &&\n\t\t\tencoded[0].startsWith(\"$\")\n\t\t) {\n\t\t\treturn [\"$\" + encoded[0], encoded[1]];\n\t\t}\n\t\treturn encoded;\n\t}\n\tif (isPlainObject(input)) {\n\t\tconst encoded: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\tencoded[key] = encodeJsonCompatValue(value);\n\t\t}\n\t\treturn encoded;\n\t}\n\treturn input;\n}\n\nexport interface JsonCompatReviveOptions {\n\tcoerceSafeIntegerBigInts?: boolean;\n}\n\nexport function reviveJsonCompatValue(\n\tinput: any,\n\toptions: JsonCompatReviveOptions = {},\n): any {\n\tif (typeof input === \"bigint\") {\n\t\tif (\n\t\t\toptions.coerceSafeIntegerBigInts &&\n\t\t\tinput >= BigInt(Number.MIN_SAFE_INTEGER) &&\n\t\t\tinput <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t) {\n\t\t\treturn Number(input);\n\t\t}\n\t\treturn input;\n\t}\n\tif (Array.isArray(input)) {\n\t\tif (\n\t\t\tinput.length === 2 &&\n\t\t\ttypeof input[0] === \"string\" &&\n\t\t\tinput[0].startsWith(\"$\")\n\t\t) {\n\t\t\tif (input[0] === JSON_COMPAT_BIGINT) {\n\t\t\t\treturn BigInt(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_ARRAY_BUFFER) {\n\t\t\t\treturn base64DecodeToArrayBuffer(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_UINT8_ARRAY) {\n\t\t\t\treturn base64DecodeToUint8Array(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_UNDEFINED) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (input[0].startsWith(\"$$\")) {\n\t\t\t\treturn [\n\t\t\t\t\tinput[0].substring(1),\n\t\t\t\t\treviveJsonCompatValue(input[1], options),\n\t\t\t\t];\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`,\n\t\t\t);\n\t\t}\n\t\treturn input.map((value) => reviveJsonCompatValue(value, options));\n\t}\n\tif (isPlainObject(input)) {\n\t\tconst decoded: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\tdecoded[key] = reviveJsonCompatValue(value, options);\n\t\t}\n\t\treturn decoded;\n\t}\n\treturn input;\n}\n\n/** Converts data that was encoded to a string. Some formats do not support raw binary data. */\nexport function encodeDataToString(message: OutputData): string {\n\tif (typeof message === \"string\") {\n\t\treturn message;\n\t}\n\tif (message instanceof Uint8Array) {\n\t\treturn base64EncodeUint8Array(message);\n\t}\n\tassertUnreachable(message);\n}\n\nfunction base64DecodeToUint8Array(base64: string): Uint8Array {\n\tif (typeof Buffer !== \"undefined\") {\n\t\treturn new Uint8Array(Buffer.from(base64, \"base64\"));\n\t}\n\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i);\n\t}\n\treturn bytes;\n}\n\nfunction base64DecodeToArrayBuffer(base64: string): ArrayBuffer {\n\treturn base64DecodeToUint8Array(base64).buffer as ArrayBuffer;\n}\n\n/** Stringifies with compat for values that BARE & CBOR supports. */\nexport function jsonStringifyCompat(input: any): string {\n\treturn JSON.stringify(input, (_key, value) => {\n\t\tif (typeof value === \"bigint\") {\n\t\t\treturn [JSON_COMPAT_BIGINT, value.toString()];\n\t\t}\n\t\tif (value instanceof ArrayBuffer) {\n\t\t\treturn [\n\t\t\t\tJSON_COMPAT_ARRAY_BUFFER,\n\t\t\t\tbase64EncodeArrayBuffer(value),\n\t\t\t];\n\t\t}\n\t\tif (value instanceof Uint8Array) {\n\t\t\treturn [\n\t\t\t\tJSON_COMPAT_UINT8_ARRAY,\n\t\t\t\tbase64EncodeUint8Array(value),\n\t\t\t];\n\t\t}\n\t\tif (\n\t\t\tArray.isArray(value) &&\n\t\t\tvalue.length === 2 &&\n\t\t\ttypeof value[0] === \"string\" &&\n\t\t\tvalue[0].startsWith(\"$\")\n\t\t) {\n\t\t\treturn [\"$\" + value[0], value[1]];\n\t\t}\n\t\treturn value;\n\t});\n}\n\n/** Parses JSON with compat for values that BARE & CBOR supports. */\nexport function jsonParseCompat(input: string): any {\n\treturn reviveJsonCompatValue(JSON.parse(input));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-LIXXFXVR.cjs","../../src/serde.ts","../../src/common/encoding.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,2EAAsB;AACtB,4FAAsB;ADMtB;AACA;AERA,4BAAkB;AAWlB,IAAM,mBAAA,EAAqB,SAAA;AAC3B,IAAM,yBAAA,EAA2B,cAAA;AACjC,IAAM,wBAAA,EAA0B,aAAA;AAChC,IAAM,sBAAA,EAAwB,YAAA;AAEvB,IAAM,eAAA,EAAiB,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM,CAAC,CAAA;AA2D7D,MAAA,SAAsB,iBAAA,CACrB,IAAA,EAC+B;AAC/B,EAAA,GAAA,CAAI,OAAO,KAAA,IAAS,QAAA,EAAU;AAC7B,IAAA,OAAO,IAAA;AAAA,EACR;AACA,EAAA,GAAA,CAAI,KAAA,WAAgB,IAAA,EAAM;AACzB,IAAA,OAAO,IAAI,UAAA,CAAW,MAAM,IAAA,CAAK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/packages/rivetkit/dist/tsup/chunk-LIXXFXVR.cjs","sourcesContent":[null,"import * as cbor from \"cbor-x\";\nimport invariant from \"invariant\";\nimport type { VersionedDataHandler } from \"vbare\";\nimport type { z } from \"zod/v4\";\nimport { assertUnreachable } from \"@/common/utils\";\nimport type { Encoding } from \"@/common/encoding\";\nimport {\n\tencodeJsonCompatValue,\n\tjsonParseCompat,\n\tjsonStringifyCompat,\n\treviveJsonCompatValue,\n} from \"./common/encoding\";\n\nexport function uint8ArrayToBase64(uint8Array: Uint8Array): string {\n\t// Check if Buffer is available (Node.js)\n\tif (typeof Buffer !== \"undefined\") {\n\t\treturn Buffer.from(uint8Array).toString(\"base64\");\n\t}\n\n\t// Browser environment - use btoa\n\tlet binary = \"\";\n\tconst len = uint8Array.byteLength;\n\tfor (let i = 0; i < len; i++) {\n\t\tbinary += String.fromCharCode(uint8Array[i]);\n\t}\n\treturn btoa(binary);\n}\n\nexport function encodingIsBinary(encoding: Encoding): boolean {\n\tif (encoding === \"json\") {\n\t\treturn false;\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn true;\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function contentTypeForEncoding(encoding: Encoding): string {\n\tif (encoding === \"json\") {\n\t\treturn \"application/json\";\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn \"application/octet-stream\";\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function encodeCborCompat(value: unknown): Uint8Array {\n\treturn cbor.encode(encodeJsonCompatValue(value));\n}\n\nexport function decodeCborCompat<T>(buffer: Uint8Array): T {\n\treturn reviveJsonCompatValue(cbor.decode(buffer)) as T;\n}\n\nexport function decodeCborJsonCompat<T>(buffer: Uint8Array): T {\n\treturn reviveJsonCompatValue(cbor.decode(buffer), {\n\t\tcoerceSafeIntegerBigInts: true,\n\t}) as T;\n}\n\nexport function wsBinaryTypeForEncoding(\n\tencoding: Encoding,\n): \"arraybuffer\" | \"blob\" {\n\tif (encoding === \"json\") {\n\t\treturn \"blob\";\n\t} else if (encoding === \"cbor\" || encoding === \"bare\") {\n\t\treturn \"arraybuffer\";\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function serializeWithEncoding<TBare, TJson, T = TBare>(\n\tencoding: Encoding,\n\tvalue: T,\n\tversionedDataHandler: VersionedDataHandler<TBare> | undefined,\n\tversion: number | undefined,\n\tzodSchema: z.ZodType<TJson>,\n\ttoJson: (value: T) => TJson,\n\ttoBare: (value: T) => TBare,\n): Uint8Array | string {\n\tif (encoding === \"json\") {\n\t\tconst jsonValue = toJson(value);\n\t\tconst validated = zodSchema.parse(jsonValue);\n\t\treturn jsonStringifyCompat(validated);\n\t} else if (encoding === \"cbor\") {\n\t\tconst jsonValue = toJson(value);\n\t\tconst validated = zodSchema.parse(jsonValue);\n\t\treturn cbor.encode(validated);\n\t} else if (encoding === \"bare\") {\n\t\tif (!versionedDataHandler) {\n\t\t\tthrow new Error(\n\t\t\t\t\"VersionedDataHandler is required for 'bare' encoding\",\n\t\t\t);\n\t\t}\n\t\tif (version === undefined) {\n\t\t\tthrow new Error(\"version is required for 'bare' encoding\");\n\t\t}\n\t\tconst bareValue = toBare(value);\n\t\treturn versionedDataHandler.serializeWithEmbeddedVersion(\n\t\t\tbareValue,\n\t\t\tversion,\n\t\t);\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n\nexport function deserializeWithEncoding<TBare, TJson, T = TBare>(\n\tencoding: Encoding,\n\tbuffer: Uint8Array | string,\n\tversionedDataHandler: VersionedDataHandler<TBare> | undefined,\n\tzodSchema: z.ZodType<TJson>,\n\tfromJson: (value: TJson) => T,\n\tfromBare: (value: TBare) => T,\n): T {\n\tif (encoding === \"json\") {\n\t\tlet parsed: unknown;\n\t\tif (typeof buffer === \"string\") {\n\t\t\tparsed = jsonParseCompat(buffer);\n\t\t} else {\n\t\t\tconst decoder = new TextDecoder(\"utf-8\");\n\t\t\tconst jsonString = decoder.decode(buffer);\n\t\t\tparsed = jsonParseCompat(jsonString);\n\t\t}\n\t\tconst validated = zodSchema.parse(parsed);\n\t\treturn fromJson(validated);\n\t} else if (encoding === \"cbor\") {\n\t\tinvariant(\n\t\t\ttypeof buffer !== \"string\",\n\t\t\t\"buffer cannot be string for cbor encoding\",\n\t\t);\n\t\t// Decode CBOR to get JavaScript values (similar to JSON.parse)\n\t\tconst decoded = decodeCborCompat(buffer);\n\t\t// Validate with Zod schema (CBOR produces same structure as JSON)\n\t\tconst validated = zodSchema.parse(decoded);\n\t\t// CBOR decoding produces JS objects, use fromJson\n\t\treturn fromJson(validated);\n\t} else if (encoding === \"bare\") {\n\t\tinvariant(\n\t\t\ttypeof buffer !== \"string\",\n\t\t\t\"buffer cannot be string for bare encoding\",\n\t\t);\n\t\tif (!versionedDataHandler) {\n\t\t\tthrow new Error(\n\t\t\t\t\"VersionedDataHandler is required for 'bare' encoding\",\n\t\t\t);\n\t\t}\n\t\tconst bareValue =\n\t\t\tversionedDataHandler.deserializeWithEmbeddedVersion(buffer);\n\t\treturn fromBare(bareValue);\n\t} else {\n\t\tassertUnreachable(encoding);\n\t}\n}\n","import { z } from \"zod/v4\";\nimport type { VersionedDataHandler } from \"vbare\";\nimport { serializeWithEncoding } from \"@/serde\";\nimport { assertUnreachable } from \"./utils\";\n\n/** Data that can be deserialized. */\nexport type InputData = string | Buffer | Blob | ArrayBufferLike | Uint8Array;\n\n/** Data that's been serialized. */\nexport type OutputData = string | Uint8Array;\n\nconst JSON_COMPAT_BIGINT = \"$BigInt\";\nconst JSON_COMPAT_ARRAY_BUFFER = \"$ArrayBuffer\";\nconst JSON_COMPAT_UINT8_ARRAY = \"$Uint8Array\";\nconst JSON_COMPAT_UNDEFINED = \"$Undefined\";\n\nexport const EncodingSchema = z.enum([\"json\", \"cbor\", \"bare\"]);\n\n/**\n * Encoding used to communicate between the client & actor.\n */\nexport type Encoding = z.infer<typeof EncodingSchema>;\n\n/**\n * Helper class that helps serialize data without re-serializing for the same encoding.\n */\nexport class CachedSerializer<TBare, TJson, T = TBare> {\n\t#data: T;\n\t#cache = new Map<Encoding, OutputData>();\n\t#versionedDataHandler: VersionedDataHandler<TBare>;\n\t#version: number;\n\t#zodSchema: z.ZodType<TJson>;\n\t#toJson: (value: T) => TJson;\n\t#toBare: (value: T) => TBare;\n\n\tconstructor(\n\t\tdata: T,\n\t\tversionedDataHandler: VersionedDataHandler<TBare>,\n\t\tversion: number,\n\t\tzodSchema: z.ZodType<TJson>,\n\t\ttoJson: (value: T) => TJson,\n\t\ttoBare: (value: T) => TBare,\n\t) {\n\t\tthis.#data = data;\n\t\tthis.#versionedDataHandler = versionedDataHandler;\n\t\tthis.#version = version;\n\t\tthis.#zodSchema = zodSchema;\n\t\tthis.#toJson = toJson;\n\t\tthis.#toBare = toBare;\n\t}\n\n\tpublic get rawData(): T {\n\t\treturn this.#data;\n\t}\n\n\tpublic serialize(encoding: Encoding): OutputData {\n\t\tconst cached = this.#cache.get(encoding);\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\n\t\tconst serialized = serializeWithEncoding(\n\t\t\tencoding,\n\t\t\tthis.#data,\n\t\t\tthis.#versionedDataHandler,\n\t\t\tthis.#version,\n\t\t\tthis.#zodSchema,\n\t\t\tthis.#toJson,\n\t\t\tthis.#toBare,\n\t\t);\n\t\tthis.#cache.set(encoding, serialized);\n\t\treturn serialized;\n\t}\n}\n\nexport async function inputDataToBuffer(\n\tdata: InputData,\n): Promise<Uint8Array | string> {\n\tif (typeof data === \"string\") {\n\t\treturn data;\n\t}\n\tif (data instanceof Blob) {\n\t\treturn new Uint8Array(await data.arrayBuffer());\n\t}\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t}\n\tif (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t}\n\tthrow new Error(\"Malformed message\");\n}\n\nfunction base64EncodeUint8Array(uint8Array: Uint8Array): string {\n\tlet binary = \"\";\n\tfor (const value of uint8Array) {\n\t\tbinary += String.fromCharCode(value);\n\t}\n\treturn btoa(binary);\n}\n\nfunction base64EncodeArrayBuffer(arrayBuffer: ArrayBuffer): string {\n\treturn base64EncodeUint8Array(new Uint8Array(arrayBuffer));\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\n\nexport function encodeJsonCompatValue(input: any): any {\n\tif (input === undefined) {\n\t\treturn [JSON_COMPAT_UNDEFINED, 0];\n\t}\n\tif (typeof input === \"bigint\") {\n\t\treturn [JSON_COMPAT_BIGINT, input.toString()];\n\t}\n\tif (input instanceof ArrayBuffer) {\n\t\treturn [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];\n\t}\n\tif (input instanceof Uint8Array) {\n\t\treturn [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];\n\t}\n\tif (Array.isArray(input)) {\n\t\tconst encoded = input.map((value) => encodeJsonCompatValue(value));\n\t\tif (\n\t\t\tencoded.length === 2 &&\n\t\t\ttypeof encoded[0] === \"string\" &&\n\t\t\tencoded[0].startsWith(\"$\")\n\t\t) {\n\t\t\treturn [\"$\" + encoded[0], encoded[1]];\n\t\t}\n\t\treturn encoded;\n\t}\n\tif (isPlainObject(input)) {\n\t\tconst encoded: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\tencoded[key] = encodeJsonCompatValue(value);\n\t\t}\n\t\treturn encoded;\n\t}\n\treturn input;\n}\n\nexport interface JsonCompatReviveOptions {\n\tcoerceSafeIntegerBigInts?: boolean;\n}\n\nexport function reviveJsonCompatValue(\n\tinput: any,\n\toptions: JsonCompatReviveOptions = {},\n): any {\n\tif (typeof input === \"bigint\") {\n\t\tif (\n\t\t\toptions.coerceSafeIntegerBigInts &&\n\t\t\tinput >= BigInt(Number.MIN_SAFE_INTEGER) &&\n\t\t\tinput <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t) {\n\t\t\treturn Number(input);\n\t\t}\n\t\treturn input;\n\t}\n\tif (Array.isArray(input)) {\n\t\tif (\n\t\t\tinput.length === 2 &&\n\t\t\ttypeof input[0] === \"string\" &&\n\t\t\tinput[0].startsWith(\"$\")\n\t\t) {\n\t\t\tif (input[0] === JSON_COMPAT_BIGINT) {\n\t\t\t\treturn BigInt(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_ARRAY_BUFFER) {\n\t\t\t\treturn base64DecodeToArrayBuffer(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_UINT8_ARRAY) {\n\t\t\t\treturn base64DecodeToUint8Array(input[1]);\n\t\t\t}\n\t\t\tif (input[0] === JSON_COMPAT_UNDEFINED) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (input[0].startsWith(\"$$\")) {\n\t\t\t\treturn [\n\t\t\t\t\tinput[0].substring(1),\n\t\t\t\t\treviveJsonCompatValue(input[1], options),\n\t\t\t\t];\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`,\n\t\t\t);\n\t\t}\n\t\treturn input.map((value) => reviveJsonCompatValue(value, options));\n\t}\n\tif (isPlainObject(input)) {\n\t\tconst decoded: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\tdecoded[key] = reviveJsonCompatValue(value, options);\n\t\t}\n\t\treturn decoded;\n\t}\n\treturn input;\n}\n\n/** Converts data that was encoded to a string. Some formats do not support raw binary data. */\nexport function encodeDataToString(message: OutputData): string {\n\tif (typeof message === \"string\") {\n\t\treturn message;\n\t}\n\tif (message instanceof Uint8Array) {\n\t\treturn base64EncodeUint8Array(message);\n\t}\n\tassertUnreachable(message);\n}\n\nfunction base64DecodeToUint8Array(base64: string): Uint8Array {\n\tif (typeof Buffer !== \"undefined\") {\n\t\treturn new Uint8Array(Buffer.from(base64, \"base64\"));\n\t}\n\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i);\n\t}\n\treturn bytes;\n}\n\nfunction base64DecodeToArrayBuffer(base64: string): ArrayBuffer {\n\treturn base64DecodeToUint8Array(base64).buffer as ArrayBuffer;\n}\n\n/** Stringifies with compat for values that BARE & CBOR supports. */\nexport function jsonStringifyCompat(input: any): string {\n\treturn JSON.stringify(input, (_key, value) => {\n\t\tif (typeof value === \"bigint\") {\n\t\t\treturn [JSON_COMPAT_BIGINT, value.toString()];\n\t\t}\n\t\tif (value instanceof ArrayBuffer) {\n\t\t\treturn [\n\t\t\t\tJSON_COMPAT_ARRAY_BUFFER,\n\t\t\t\tbase64EncodeArrayBuffer(value),\n\t\t\t];\n\t\t}\n\t\tif (value instanceof Uint8Array) {\n\t\t\treturn [\n\t\t\t\tJSON_COMPAT_UINT8_ARRAY,\n\t\t\t\tbase64EncodeUint8Array(value),\n\t\t\t];\n\t\t}\n\t\tif (\n\t\t\tArray.isArray(value) &&\n\t\t\tvalue.length === 2 &&\n\t\t\ttypeof value[0] === \"string\" &&\n\t\t\tvalue[0].startsWith(\"$\")\n\t\t) {\n\t\t\treturn [\"$\" + value[0], value[1]];\n\t\t}\n\t\treturn value;\n\t});\n}\n\n/** Parses JSON with compat for values that BARE & CBOR supports. */\nexport function jsonParseCompat(input: string): any {\n\treturn reviveJsonCompatValue(JSON.parse(input));\n}\n"]}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkENK7C66Gcjs = require('./chunk-ENK7C66G.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkK5BA2LEOcjs = require('./chunk-K5BA2LEO.cjs');
|
|
10
10
|
|
|
11
11
|
// src/devtools-loader/log.ts
|
|
12
12
|
function logger() {
|
|
13
|
-
return
|
|
13
|
+
return _chunkK5BA2LEOcjs.getLogger.call(void 0, "devtools");
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// src/devtools-loader/index.ts
|
|
17
|
-
var DEFAULT_DEVTOOLS_URL = (version =
|
|
17
|
+
var DEFAULT_DEVTOOLS_URL = (version = _chunkK5BA2LEOcjs.VERSION) => `https://releases.rivet.dev/rivet/latest/devtools/mod.js?v=${version}`;
|
|
18
18
|
var scriptId = "rivetkit-devtools-script";
|
|
19
19
|
function injectDevtools(config) {
|
|
20
20
|
if (!window) {
|
|
@@ -35,15 +35,15 @@ function injectDevtools(config) {
|
|
|
35
35
|
// src/client/mod.ts
|
|
36
36
|
function createClient(endpointOrConfig) {
|
|
37
37
|
const configInput = endpointOrConfig === void 0 ? {} : typeof endpointOrConfig === "string" ? { endpoint: endpointOrConfig } : endpointOrConfig;
|
|
38
|
-
const config =
|
|
39
|
-
const driver = new (0,
|
|
38
|
+
const config = _chunkENK7C66Gcjs.ClientConfigSchema.parse(configInput);
|
|
39
|
+
const driver = new (0, _chunkENK7C66Gcjs.RemoteEngineControlClient)(config);
|
|
40
40
|
if (config.devtools) {
|
|
41
41
|
injectDevtools(config);
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return _chunkENK7C66Gcjs.createClientWithDriver.call(void 0, driver, config);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
exports.createClient = createClient;
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-M5C7YNI5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-M5C7YNI5.cjs","../../src/devtools-loader/log.ts","../../src/devtools-loader/index.ts","../../src/client/mod.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACRO,SAAS,MAAA,CAAA,EAAS;AACxB,EAAA,OAAO,yCAAA,UAAoB,CAAA;AAC5B;ADUA;AACA;AELA,IAAM,qBAAA,EAAuB,CAAC,QAAA,EAAU,yBAAA,EAAA,GACvC,CAAA,0DAAA,EAA6D,OAAO,CAAA,CAAA;AAEpD;AAEyC;AAC5C,EAAA;AACsD,IAAA;AAClE,IAAA;AACD,EAAA;AAEwC,EAAA;AACO,IAAA;AAClC,IAAA;AAEqD,IAAA;AAClD,IAAA;AACiB,IAAA;AACjC,EAAA;AAE0C,EAAA;AACb,EAAA;AAC9B;AFCuH;AACA;AGuB1G;AAMK,EAAA;AAEkC,EAAA;AAGA,EAAA;AAE9B,EAAA;AACC,IAAA;AACtB,EAAA;AAE+C,EAAA;AAChD;AH/BuH;AACA;AACA;AACA","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-M5C7YNI5.cjs","sourcesContent":[null,"import { getLogger } from \"@/common/log\";\n\nexport function logger() {\n\treturn getLogger(\"devtools\");\n}\n","import type { ClientConfigInput } from \"@/client/client\";\nimport { VERSION } from \"@/utils\";\nimport { logger } from \"./log\";\n\ndeclare global {\n\t// Injected via tsup config\n\t// biome-ignore lint/style/noVar: required for global declaration\n\tvar CUSTOM_RIVETKIT_DEVTOOLS_URL: string | undefined;\n}\n\nconst DEFAULT_DEVTOOLS_URL = (version = VERSION) =>\n\t`https://releases.rivet.dev/rivet/latest/devtools/mod.js?v=${version}`;\n\nconst scriptId = \"rivetkit-devtools-script\";\n\nexport function injectDevtools(config: ClientConfigInput) {\n\tif (!window) {\n\t\tlogger().warn(\"devtools not available outside browser environment\");\n\t\treturn;\n\t}\n\n\tif (!document.getElementById(scriptId)) {\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = scriptId;\n\t\tscript.src =\n\t\t\tglobalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL || DEFAULT_DEVTOOLS_URL();\n\t\tscript.async = true;\n\t\tdocument.head.appendChild(script);\n\t}\n\n\twindow.__rivetkit = window.__rivetkit || [];\n\twindow.__rivetkit.push(config);\n}\n","import { injectDevtools } from \"@/devtools-loader\";\nimport { RemoteEngineControlClient } from \"@/engine-client/mod\";\nimport type { Registry } from \"@/registry\";\nimport {\n\ttype Client,\n\ttype ClientConfigInput,\n\tcreateClientWithDriver,\n} from \"./client\";\nimport { ClientConfigSchema } from \"./config\";\n\nexport type { ActorDefinition, AnyActorDefinition } from \"@/actor/definition\";\nexport {\n\tActorClientError,\n\tActorConnDisposed,\n\tActorError,\n\tMalformedResponseMessage,\n\tManagerError,\n\tRivetError,\n\tUserError,\n} from \"@/client/errors\";\nexport type { CreateRequest } from \"@/client/query\";\nexport type { Encoding } from \"@/common/encoding\";\nexport type {\n\tActorActionFunction,\n\tActorActionOptions,\n\tActorConnectOptions,\n\tActorGatewayOptions,\n} from \"./actor-common\";\nexport type {\n\tActorConn,\n\tActorConnStatus,\n\tConnectionStateCallback,\n\tEventUnsubscribe,\n\tStatusChangeCallback,\n} from \"./actor-conn\";\nexport { ActorConnRaw } from \"./actor-conn\";\nexport type { ActorHandle } from \"./actor-handle\";\nexport { ActorHandleRaw } from \"./actor-handle\";\nexport type {\n\tActorAccessor,\n\tClient,\n\tClientConfigInput,\n\tClientRaw,\n\tCreateOptions,\n\tExtractActorsFromRegistry,\n\tExtractRegistryFromClient,\n\tGetOptions,\n\tGetWithIdOptions,\n\tQueryOptions,\n\tRegion,\n} from \"./client\";\n\n/**\n * Creates a client with the actor accessor proxy.\n */\nexport function createClient<A extends Registry<any>>(\n\tendpointOrConfig?: string | ClientConfigInput,\n): Client<A> {\n\t// Parse config\n\tconst configInput =\n\t\tendpointOrConfig === undefined\n\t\t\t? {}\n\t\t\t: typeof endpointOrConfig === \"string\"\n\t\t\t\t? { endpoint: endpointOrConfig }\n\t\t\t\t: endpointOrConfig;\n\tconst config = ClientConfigSchema.parse(configInput);\n\n\t// Create client\n\tconst driver = new RemoteEngineControlClient(config);\n\n\tif (config.devtools) {\n\t\tinjectDevtools(config);\n\t}\n\n\treturn createClientWithDriver<A>(driver, config);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
|
4
4
|
var USER_ERROR_CODE = "user_error";
|
|
5
5
|
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
6
6
|
function looksLikeRivetErrorOptions(value) {
|
|
7
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "cause" in value);
|
|
7
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
8
8
|
}
|
|
9
9
|
function isTypedErrorTag(value) {
|
|
10
10
|
return value === "ActorError" || value === "RivetError";
|
|
@@ -18,6 +18,9 @@ function errorMessage(error, fallback = String(error)) {
|
|
|
18
18
|
function isRivetErrorLike(error) {
|
|
19
19
|
return typeof error === "object" && error !== null && "group" in error && typeof error.group === "string" && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string" && (!("__type" in error) || isTypedErrorTag(error.__type));
|
|
20
20
|
}
|
|
21
|
+
function isActorSpecifier(value) {
|
|
22
|
+
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
23
|
+
}
|
|
21
24
|
var RivetError = (_class = class extends Error {
|
|
22
25
|
__init() {this.__type = "RivetError"}
|
|
23
26
|
|
|
@@ -25,6 +28,7 @@ var RivetError = (_class = class extends Error {
|
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
|
|
31
|
+
|
|
28
32
|
static isRivetError(error) {
|
|
29
33
|
return isRivetErrorLike(error);
|
|
30
34
|
}
|
|
@@ -40,6 +44,7 @@ var RivetError = (_class = class extends Error {
|
|
|
40
44
|
this.public = _nullishCoalesce(normalized.public, () => ( false));
|
|
41
45
|
this.metadata = normalized.metadata;
|
|
42
46
|
this.statusCode = _nullishCoalesce(normalized.statusCode, () => ( (this.public ? 400 : 500)));
|
|
47
|
+
this.actor = normalized.actor;
|
|
43
48
|
}
|
|
44
49
|
toString() {
|
|
45
50
|
return this.message;
|
|
@@ -72,6 +77,7 @@ function toRivetError(error, fallback) {
|
|
|
72
77
|
public: error.public,
|
|
73
78
|
statusCode: error.statusCode,
|
|
74
79
|
metadata: error.metadata,
|
|
80
|
+
actor: error.actor,
|
|
75
81
|
cause: error instanceof Error ? error.cause : void 0
|
|
76
82
|
});
|
|
77
83
|
}
|
|
@@ -83,6 +89,7 @@ function toRivetError(error, fallback) {
|
|
|
83
89
|
public: fallback == null ? void 0 : fallback.public,
|
|
84
90
|
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
85
91
|
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
92
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
86
93
|
cause: error instanceof Error ? error : void 0
|
|
87
94
|
}
|
|
88
95
|
);
|
|
@@ -94,10 +101,11 @@ function encodeBridgeRivetError(error) {
|
|
|
94
101
|
message: error.message,
|
|
95
102
|
metadata: error.metadata,
|
|
96
103
|
public: error.public,
|
|
97
|
-
statusCode: error.statusCode
|
|
104
|
+
statusCode: error.statusCode,
|
|
105
|
+
actor: error.actor
|
|
98
106
|
})}`;
|
|
99
107
|
}
|
|
100
|
-
function
|
|
108
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
101
109
|
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
102
110
|
return void 0;
|
|
103
111
|
}
|
|
@@ -108,15 +116,26 @@ function decodeBridgeRivetError(value) {
|
|
|
108
116
|
if (!isRivetErrorLike(payload)) {
|
|
109
117
|
return void 0;
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
119
|
+
if (payload.actor !== void 0 && !isActorSpecifier(payload.actor)) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
return payload;
|
|
116
123
|
} catch (e) {
|
|
117
124
|
return void 0;
|
|
118
125
|
}
|
|
119
126
|
}
|
|
127
|
+
function decodeBridgeRivetError(value) {
|
|
128
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
129
|
+
if (!payload) {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
133
|
+
metadata: payload.metadata,
|
|
134
|
+
public: payload.public,
|
|
135
|
+
statusCode: payload.statusCode,
|
|
136
|
+
actor: payload.actor
|
|
137
|
+
});
|
|
138
|
+
}
|
|
120
139
|
function isRivetErrorCode(error, group, code) {
|
|
121
140
|
return isRivetErrorLike(error) && error.group === group && error.code === code;
|
|
122
141
|
}
|
|
@@ -129,6 +148,7 @@ function internalError(message, options) {
|
|
|
129
148
|
public: options == null ? void 0 : options.public,
|
|
130
149
|
statusCode: options == null ? void 0 : options.statusCode,
|
|
131
150
|
metadata: options == null ? void 0 : options.metadata,
|
|
151
|
+
actor: options == null ? void 0 : options.actor,
|
|
132
152
|
cause: options == null ? void 0 : options.cause
|
|
133
153
|
}
|
|
134
154
|
);
|
|
@@ -220,5 +240,6 @@ function unsupportedFeature(feature) {
|
|
|
220
240
|
|
|
221
241
|
|
|
222
242
|
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
|
|
244
|
+
exports.INTERNAL_ERROR_CODE = INTERNAL_ERROR_CODE; exports.INTERNAL_ERROR_DESCRIPTION = INTERNAL_ERROR_DESCRIPTION; exports.USER_ERROR_CODE = USER_ERROR_CODE; exports.BRIDGE_RIVET_ERROR_PREFIX = BRIDGE_RIVET_ERROR_PREFIX; exports.isRivetErrorLike = isRivetErrorLike; exports.RivetError = RivetError; exports.UserError = UserError; exports.toRivetError = toRivetError; exports.encodeBridgeRivetError = encodeBridgeRivetError; exports.decodeBridgeRivetErrorPayload = decodeBridgeRivetErrorPayload; exports.decodeBridgeRivetError = decodeBridgeRivetError; exports.isRivetErrorCode = isRivetErrorCode; exports.internalError = internalError; exports.invalidEncoding = invalidEncoding; exports.invalidRequest = invalidRequest; exports.actorNotFound = actorNotFound; exports.actorStopping = actorStopping; exports.actorRestarting = actorRestarting; exports.forbiddenError = forbiddenError; exports.unsupportedFeature = unsupportedFeature;
|
|
245
|
+
//# sourceMappingURL=chunk-QAZLM4WT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-QAZLM4WT.cjs","../../src/actor/errors.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,oBAAA,EAAsB,gBAAA;AAC5B,IAAM,2BAAA,EAA6B,4BAAA;AAGnC,IAAM,gBAAA,EAAkB,YAAA;AACxB,IAAM,0BAAA,EAA4B,uBAAA;AA8CzC,SAAS,0BAAA,CACR,KAAA,EAC6B;AAC7B,EAAA,OACC,OAAO,MAAA,IAAU,SAAA,GACjB,MAAA,IAAU,KAAA,GAAA,CACT,SAAA,GAAY,MAAA,GACZ,WAAA,GAAc,MAAA,GACd,aAAA,GAAgB,MAAA,GAChB,QAAA,GAAW,MAAA,GACX,QAAA,GAAW,KAAA,CAAA;AAEd;AAEA,SAAS,eAAA,CAAgB,KAAA,EAAsD;AAC9E,EAAA,OAAO,MAAA,IAAU,aAAA,GAAgB,MAAA,IAAU,YAAA;AAC5C;AAEA,SAAS,YAAA,CAAa,KAAA,EAAgB,SAAA,EAAW,MAAA,CAAO,KAAK,CAAA,EAAW;AACvE,EAAA,GAAA,CACC,MAAA,GACA,OAAO,MAAA,IAAU,SAAA,GACjB,UAAA,GAAa,MAAA,GACb,OAAO,KAAA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ACD,EAAA;AACD;AAEgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACC,MAAA;AACA,MAAA;AACD,IAAA;AACD,EAAA;AACD;AAEgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AAGE,IAAA;AACH,EAAA;AACD;AAEgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AACE,IAAA;AACH,EAAA;AACD;AAOgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACC,QAAA;AACA,QAAA;AACA,QAAA;AAGD,MAAA;AACD,IAAA;AACD,EAAA;AACD;AAEgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,EAAA;AACF;AAEgB;AACR,EAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACD;ADzJU;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-QAZLM4WT.cjs","sourcesContent":[null,"import type { DeconstructedError } from \"@/common/utils\";\n\nexport const INTERNAL_ERROR_CODE = \"internal_error\";\nexport const INTERNAL_ERROR_DESCRIPTION = \"An internal error occurred\";\nexport type InternalErrorMetadata = Record<string, never>;\n\nexport const USER_ERROR_CODE = \"user_error\";\nexport const BRIDGE_RIVET_ERROR_PREFIX = \"__RIVET_ERROR_JSON__:\";\n\nexport interface RivetErrorOptions extends ErrorOptions {\n\t/** Error data can safely be serialized in a response to the client. */\n\tpublic?: boolean;\n\t/** Metadata associated with this error. */\n\tmetadata?: unknown;\n\t/** Explicit HTTP status override for router responses. */\n\tstatusCode?: number;\n\t/** Actor context associated with this error. */\n\tactor?: ActorSpecifier;\n}\n\n/** Identifies the actor that was handling work when an error was produced. */\nexport interface ActorSpecifier {\n\tactorId: string;\n\tgeneration: number;\n\tkey?: string;\n}\n\nexport interface RivetErrorLike {\n\t__type?: \"ActorError\" | \"RivetError\";\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n\tpublic?: boolean;\n\tstatusCode?: number;\n\tactor?: ActorSpecifier;\n}\n\nexport interface BridgeRivetErrorPayload extends RivetErrorLike {}\n\nexport interface UserErrorOptions extends ErrorOptions {\n\t/**\n\t * Machine readable code for this error. Useful for catching different types of\n\t * errors in try-catch.\n\t */\n\tcode?: string;\n\t/**\n\t * Additional metadata related to the error. Useful for understanding context\n\t * about the error.\n\t */\n\tmetadata?: unknown;\n}\n\nfunction looksLikeRivetErrorOptions(\n\tvalue: unknown,\n): value is RivetErrorOptions {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t(\"public\" in value ||\n\t\t\t\"metadata\" in value ||\n\t\t\t\"statusCode\" in value ||\n\t\t\t\"actor\" in value ||\n\t\t\t\"cause\" in value)\n\t);\n}\n\nfunction isTypedErrorTag(value: unknown): value is \"ActorError\" | \"RivetError\" {\n\treturn value === \"ActorError\" || value === \"RivetError\";\n}\n\nfunction errorMessage(error: unknown, fallback = String(error)): string {\n\tif (\n\t\terror &&\n\t\ttypeof error === \"object\" &&\n\t\t\"message\" in error &&\n\t\ttypeof error.message === \"string\"\n\t) {\n\t\treturn error.message;\n\t}\n\n\treturn fallback;\n}\n\nexport function isRivetErrorLike(\n\terror: unknown,\n): error is RivetError | DeconstructedError | RivetErrorLike {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"group\" in error &&\n\t\ttypeof error.group === \"string\" &&\n\t\t\"code\" in error &&\n\t\ttypeof error.code === \"string\" &&\n\t\t\"message\" in error &&\n\t\ttypeof error.message === \"string\" &&\n\t\t(!(\"__type\" in error) || isTypedErrorTag(error.__type))\n\t);\n}\n\nfunction isActorSpecifier(value: unknown): value is ActorSpecifier {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"actorId\" in value &&\n\t\ttypeof value.actorId === \"string\" &&\n\t\t\"generation\" in value &&\n\t\ttypeof value.generation === \"number\" &&\n\t\t(!(\"key\" in value) || value.key === undefined || typeof value.key === \"string\")\n\t);\n}\n\nexport class RivetError extends Error {\n\t__type = \"RivetError\" as const;\n\n\tpublic public: boolean;\n\tpublic metadata?: unknown;\n\tpublic statusCode: number;\n\tpublic actor?: ActorSpecifier;\n\tpublic readonly group: string;\n\tpublic readonly code: string;\n\n\tpublic static isRivetError(\n\t\terror: unknown,\n\t): error is RivetError | DeconstructedError {\n\t\treturn isRivetErrorLike(error);\n\t}\n\n\tpublic static isActorError(\n\t\terror: unknown,\n\t): error is RivetError | DeconstructedError {\n\t\treturn isRivetErrorLike(error);\n\t}\n\n\tconstructor(\n\t\tgroup: string,\n\t\tcode: string,\n\t\tmessage: string,\n\t\toptions?: RivetErrorOptions | unknown,\n\t) {\n\t\tconst normalized = looksLikeRivetErrorOptions(options)\n\t\t\t? options\n\t\t\t: { metadata: options };\n\n\t\tsuper(message, { cause: normalized.cause });\n\t\tthis.name = \"RivetError\";\n\t\tthis.group = group;\n\t\tthis.code = code;\n\t\tthis.public = normalized.public ?? false;\n\t\tthis.metadata = normalized.metadata;\n\t\tthis.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);\n\t\tthis.actor = normalized.actor;\n\t}\n\n\ttoString() {\n\t\treturn this.message;\n\t}\n}\n\nexport { RivetError as ActorError };\n\nexport class UserError extends RivetError {\n\tconstructor(message: string, options?: UserErrorOptions) {\n\t\tsuper(\"user\", options?.code ?? USER_ERROR_CODE, message, {\n\t\t\tpublic: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tcause: options?.cause,\n\t\t});\n\t}\n}\n\nexport function toRivetError(\n\terror: unknown,\n\tfallback?: Partial<RivetErrorLike>,\n): RivetError {\n\tif (typeof error === \"string\") {\n\t\tconst bridged = decodeBridgeRivetError(error);\n\t\tif (bridged) {\n\t\t\treturn bridged;\n\t\t}\n\t}\n\n\tif (error instanceof Error) {\n\t\tconst bridged = decodeBridgeRivetError(error.message);\n\t\tif (bridged) {\n\t\t\treturn bridged;\n\t\t}\n\t}\n\n\tif (isRivetErrorLike(error)) {\n\t\treturn new RivetError(error.group, error.code, error.message, {\n\t\t\tpublic: error.public,\n\t\t\tstatusCode: error.statusCode,\n\t\t\tmetadata: error.metadata,\n\t\t\tactor: error.actor,\n\t\t\tcause: error instanceof Error ? error.cause : undefined,\n\t\t});\n\t}\n\n\treturn new RivetError(\n\t\tfallback?.group ?? \"actor\",\n\t\tfallback?.code ?? INTERNAL_ERROR_CODE,\n\t\terrorMessage(error, fallback?.message ?? \"Unknown error\"),\n\t\t{\n\t\t\tpublic: fallback?.public,\n\t\t\tstatusCode: fallback?.statusCode,\n\t\t\tmetadata: fallback?.metadata,\n\t\t\tactor: fallback?.actor,\n\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t},\n\t);\n}\n\nexport function encodeBridgeRivetError(error: RivetErrorLike): string {\n\treturn `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({\n\t\tgroup: error.group,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\tmetadata: error.metadata,\n\t\tpublic: error.public,\n\t\tstatusCode: error.statusCode,\n\t\tactor: error.actor,\n\t})}`;\n}\n\nexport function decodeBridgeRivetErrorPayload(\n\tvalue: string,\n): BridgeRivetErrorPayload | undefined {\n\tif (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {\n\t\treturn undefined;\n\t}\n\n\ttry {\n\t\tconst payload = JSON.parse(\n\t\t\tvalue.slice(BRIDGE_RIVET_ERROR_PREFIX.length),\n\t\t) as BridgeRivetErrorPayload;\n\t\tif (!isRivetErrorLike(payload)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (payload.actor !== undefined && !isActorSpecifier(payload.actor)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn payload;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function decodeBridgeRivetError(value: string): RivetError | undefined {\n\tconst payload = decodeBridgeRivetErrorPayload(value);\n\tif (!payload) {\n\t\treturn undefined;\n\t}\n\n\treturn new RivetError(payload.group, payload.code, payload.message, {\n\t\tmetadata: payload.metadata,\n\t\tpublic: payload.public,\n\t\tstatusCode: payload.statusCode,\n\t\tactor: payload.actor,\n\t});\n}\n\nexport function isRivetErrorCode(\n\terror: unknown,\n\tgroup: string,\n\tcode: string,\n): error is RivetError {\n\treturn (\n\t\tisRivetErrorLike(error) && error.group === group && error.code === code\n\t);\n}\n\nexport function internalError(\n\tmessage: string,\n\toptions?: Partial<RivetErrorOptions> & {\n\t\tgroup?: string;\n\t\tcode?: string;\n\t},\n): RivetError {\n\treturn new RivetError(\n\t\toptions?.group ?? \"actor\",\n\t\toptions?.code ?? INTERNAL_ERROR_CODE,\n\t\tmessage,\n\t\t{\n\t\t\tpublic: options?.public,\n\t\t\tstatusCode: options?.statusCode,\n\t\t\tmetadata: options?.metadata,\n\t\t\tactor: options?.actor,\n\t\t\tcause: options?.cause,\n\t\t},\n\t);\n}\n\nexport function invalidEncoding(format?: string): RivetError {\n\treturn new RivetError(\n\t\t\"encoding\",\n\t\t\"invalid\",\n\t\t`Invalid encoding \\`${format}\\`. (https://www.rivet.dev/docs/clients/javascript)`,\n\t\t{\n\t\t\tpublic: true,\n\t\t},\n\t);\n}\n\nexport function invalidRequest(error?: unknown): RivetError {\n\treturn new RivetError(\n\t\t\"request\",\n\t\t\"invalid\",\n\t\t`Invalid request: ${errorMessage(error, String(error))}`,\n\t\t{\n\t\t\tpublic: true,\n\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t},\n\t);\n}\n\nexport function actorNotFound(identifier?: string): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"not_found\",\n\t\tidentifier\n\t\t\t? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)`\n\t\t\t: \"Actor not found (https://www.rivet.dev/docs/clients/javascript)\",\n\t\t{ public: true },\n\t);\n}\n\nexport function actorStopping(identifier?: string): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"stopping\",\n\t\tidentifier ? `Actor stopping: ${identifier}` : \"Actor stopping\",\n\t\t{ public: true },\n\t);\n}\n\nexport interface ActorRestartingOptions {\n\tphase?: \"stopping\" | \"sleeping\" | \"waking\" | \"runner_shutdown\";\n\tretryAfterMs?: number;\n}\n\nexport function actorRestarting(opts?: ActorRestartingOptions): RivetError {\n\treturn new RivetError(\n\t\t\"actor\",\n\t\t\"restarting\",\n\t\t\"Actor is restarting. Retry the request.\",\n\t\t{\n\t\t\tpublic: true,\n\t\t\tstatusCode: 503,\n\t\t\tmetadata: {\n\t\t\t\tretryable: true,\n\t\t\t\t...(opts?.phase ? { phase: opts.phase } : {}),\n\t\t\t\t...(opts?.retryAfterMs !== undefined\n\t\t\t\t\t? { retryAfterMs: opts.retryAfterMs }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport function forbiddenError(): RivetError {\n\treturn new RivetError(\"auth\", \"forbidden\", \"Forbidden\", {\n\t\tpublic: true,\n\t\tstatusCode: 403,\n\t});\n}\n\nexport function unsupportedFeature(feature: string): RivetError {\n\treturn new RivetError(\n\t\t\"feature\",\n\t\t\"unsupported\",\n\t\t`Unsupported feature: ${feature}`,\n\t);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertUnreachable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6S25NVAP.js";
|
|
4
4
|
|
|
5
5
|
// src/serde.ts
|
|
6
6
|
import * as cbor from "cbor-x";
|
|
@@ -265,4 +265,4 @@ export {
|
|
|
265
265
|
inputDataToBuffer,
|
|
266
266
|
jsonStringifyCompat
|
|
267
267
|
};
|
|
268
|
-
//# sourceMappingURL=chunk-
|
|
268
|
+
//# sourceMappingURL=chunk-RTC2AZGB.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLogger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6S25NVAP.js";
|
|
4
4
|
|
|
5
5
|
// src/client/log.ts
|
|
6
6
|
function logger() {
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
logger,
|
|
47
47
|
importWebSocket
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-ZI5QJMKO.js.map
|
package/dist/tsup/client/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkM5C7YNI5cjs = require('../chunk-M5C7YNI5.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -8,16 +8,16 @@ var _chunkHR547GVHcjs = require('../chunk-HR547GVH.cjs');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkENK7C66Gcjs = require('../chunk-ENK7C66G.cjs');
|
|
12
12
|
require('../chunk-LD5YASJU.cjs');
|
|
13
|
-
require('../chunk-
|
|
13
|
+
require('../chunk-LIXXFXVR.cjs');
|
|
14
14
|
require('../chunk-2NDZ7JCR.cjs');
|
|
15
|
-
require('../chunk-
|
|
16
|
-
require('../chunk-
|
|
15
|
+
require('../chunk-JALSAX7Z.cjs');
|
|
16
|
+
require('../chunk-K5BA2LEO.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkQAZLM4WTcjs = require('../chunk-QAZLM4WT.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -29,5 +29,5 @@ var _chunkV3QNBJ7Ncjs = require('../chunk-V3QNBJ7N.cjs');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.ActorClientError =
|
|
32
|
+
exports.ActorClientError = _chunkENK7C66Gcjs.ActorClientError; exports.ActorConnDisposed = _chunkENK7C66Gcjs.ActorConnDisposed; exports.ActorConnRaw = _chunkENK7C66Gcjs.ActorConnRaw; exports.ActorError = _chunkQAZLM4WTcjs.RivetError; exports.ActorHandleRaw = _chunkENK7C66Gcjs.ActorHandleRaw; exports.MalformedResponseMessage = _chunkENK7C66Gcjs.MalformedResponseMessage; exports.ManagerError = _chunkENK7C66Gcjs.ManagerError; exports.RivetError = _chunkQAZLM4WTcjs.RivetError; exports.UserError = _chunkQAZLM4WTcjs.UserError; exports.createClient = _chunkM5C7YNI5cjs.createClient;
|
|
33
33
|
//# sourceMappingURL=mod.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ap as Registry, V as Client } from '../config-
|
|
2
|
-
export { a_ as ActorAccessor, a$ as ActorActionFunction, b0 as ActorActionOptions, b1 as ActorConn, b2 as ActorConnRaw, b3 as ActorConnStatus, b4 as ActorConnectOptions, r as ActorDefinition, b5 as ActorGatewayOptions, b6 as ActorHandle, b7 as ActorHandleRaw, A as AnyActorDefinition, b8 as ClientRaw, b9 as ConnectionStateCallback, ba as CreateOptions, bb as CreateRequest, a4 as Encoding, bc as EventUnsubscribe, bd as ExtractActorsFromRegistry, be as ExtractRegistryFromClient, bf as GetOptions, bg as GetWithIdOptions, bh as QueryOptions, bi as Region, bj as StatusChangeCallback } from '../config-
|
|
1
|
+
import { ap as Registry, V as Client } from '../config-Ca8dN4cS.cjs';
|
|
2
|
+
export { a_ as ActorAccessor, a$ as ActorActionFunction, b0 as ActorActionOptions, b1 as ActorConn, b2 as ActorConnRaw, b3 as ActorConnStatus, b4 as ActorConnectOptions, r as ActorDefinition, b5 as ActorGatewayOptions, b6 as ActorHandle, b7 as ActorHandleRaw, A as AnyActorDefinition, b8 as ClientRaw, b9 as ConnectionStateCallback, ba as CreateOptions, bb as CreateRequest, a4 as Encoding, bc as EventUnsubscribe, bd as ExtractActorsFromRegistry, be as ExtractRegistryFromClient, bf as GetOptions, bg as GetWithIdOptions, bh as QueryOptions, bi as Region, bj as StatusChangeCallback } from '../config-Ca8dN4cS.cjs';
|
|
3
3
|
import z from 'zod/v4';
|
|
4
4
|
import { GetUpgradeWebSocket } from '../utils.cjs';
|
|
5
|
-
export { ActorError,
|
|
5
|
+
export { R as ActorError, R as RivetError, U as UserError } from '../utils-DVekpm4I.cjs';
|
|
6
6
|
import '@rivetkit/virtual-websocket';
|
|
7
7
|
import '../config-CxjGYf4K.cjs';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
@@ -10,7 +10,6 @@ import 'zod';
|
|
|
10
10
|
import 'pino';
|
|
11
11
|
import '@standard-schema/spec';
|
|
12
12
|
import 'hono';
|
|
13
|
-
import '../utils-fwx3o3K9.cjs';
|
|
14
13
|
import 'hono/utils/http-status';
|
|
15
14
|
|
|
16
15
|
declare class ActorClientError extends Error {
|