rivetkit 2.3.6 → 2.3.8
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 +34 -6
- package/dist/browser/client.js +33 -14
- 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/agent-os/index.cjs +1 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +34 -6
- package/dist/tsup/agent-os/index.d.ts +34 -6
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-AXEGEUYB.cjs → chunk-5MJPN3QU.cjs} +172 -151
- package/dist/tsup/chunk-5MJPN3QU.cjs.map +1 -0
- package/dist/tsup/{chunk-WS3PP253.cjs → chunk-7TNEDX3Y.cjs} +3 -3
- package/dist/tsup/{chunk-WS3PP253.cjs.map → chunk-7TNEDX3Y.cjs.map} +1 -1
- package/dist/tsup/{chunk-F6ZW7JZQ.js → chunk-BL6ERZQO.js} +36 -15
- package/dist/tsup/chunk-BL6ERZQO.js.map +1 -0
- package/dist/tsup/{chunk-HVOKIYUB.cjs → chunk-F6GCLL5Z.cjs} +7 -7
- package/dist/tsup/{chunk-HVOKIYUB.cjs.map → chunk-F6GCLL5Z.cjs.map} +1 -1
- package/dist/tsup/{chunk-PLLHHJWR.js → chunk-HWBISPRP.js} +2 -2
- package/dist/tsup/{chunk-FNTTW25Q.cjs → chunk-IJMVVULS.cjs} +4 -4
- package/dist/tsup/{chunk-FNTTW25Q.cjs.map → chunk-IJMVVULS.cjs.map} +1 -1
- package/dist/tsup/{chunk-BX4G2O6M.js → chunk-MY6BRV3S.js} +3 -3
- package/dist/tsup/{chunk-234EFKN2.cjs → chunk-NUMGL52R.cjs} +6 -3
- package/dist/tsup/chunk-NUMGL52R.cjs.map +1 -0
- package/dist/tsup/{chunk-PD7SZKHY.cjs → chunk-TMTJPSHQ.cjs} +9 -9
- package/dist/tsup/{chunk-PD7SZKHY.cjs.map → chunk-TMTJPSHQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-OH6CBWUD.js → chunk-V7PJYBA5.js} +2 -2
- package/dist/tsup/{chunk-3ZE5UDOA.js → chunk-YFXQ7DBH.js} +3 -3
- package/dist/tsup/{chunk-RDTFPGU2.js → chunk-ZKDZW5DQ.js} +6 -3
- package/dist/tsup/chunk-ZKDZW5DQ.js.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-BRpVbJCD.d.ts → config-CUymbyM6.d.ts} +35 -7
- package/dist/tsup/{config-BobvQpex.d.cts → config-CpB-e4I9.d.cts} +35 -7
- package/dist/tsup/{context-Cj-DFyiy.d.ts → context-YBUBTwTS.d.ts} +1 -1
- package/dist/tsup/{context-YEBNJrws.d.cts → context-c-6G4mjk.d.cts} +1 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/mod.cjs +449 -124
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +388 -63
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +6 -6
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +3 -3
- package/package.json +8 -8
- package/src/client/actor-handle.ts +3 -1
- package/src/client/raw-utils.ts +11 -2
- package/src/common/actor-router-consts.ts +1 -0
- package/src/common/encoding.ts +4 -1
- package/src/common/fetch-like.ts +49 -0
- package/src/engine-client/actor-http-client.ts +6 -22
- package/src/registry/index.ts +159 -14
- package/src/registry/napi-runtime.ts +74 -0
- package/src/registry/native-http.ts +208 -0
- package/src/registry/native.ts +111 -63
- package/src/registry/runtime.ts +35 -0
- package/src/registry/wasm-runtime.ts +11 -0
- package/dist/tsup/chunk-234EFKN2.cjs.map +0 -1
- package/dist/tsup/chunk-AXEGEUYB.cjs.map +0 -1
- package/dist/tsup/chunk-F6ZW7JZQ.js.map +0 -1
- package/dist/tsup/chunk-RDTFPGU2.js.map +0 -1
- /package/dist/tsup/{chunk-PLLHHJWR.js.map → chunk-HWBISPRP.js.map} +0 -0
- /package/dist/tsup/{chunk-BX4G2O6M.js.map → chunk-MY6BRV3S.js.map} +0 -0
- /package/dist/tsup/{chunk-OH6CBWUD.js.map → chunk-V7PJYBA5.js.map} +0 -0
- /package/dist/tsup/{chunk-3ZE5UDOA.js.map → chunk-YFXQ7DBH.js.map} +0 -0
package/dist/tsup/test/mod.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkF6GCLL5Zcjs = require('../chunk-F6GCLL5Z.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5MJPN3QUcjs = require('../chunk-5MJPN3QU.cjs');
|
|
7
7
|
require('../chunk-MYWZCDML.cjs');
|
|
8
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-7TNEDX3Y.cjs');
|
|
9
9
|
require('../chunk-UEULFXUI.cjs');
|
|
10
|
-
require('../chunk-
|
|
10
|
+
require('../chunk-NUMGL52R.cjs');
|
|
11
11
|
require('../chunk-4FC7TVS6.cjs');
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
|
@@ -36,8 +36,8 @@ async function setupTest(c, registry) {
|
|
|
36
36
|
registry.config.noWelcome = true;
|
|
37
37
|
registry.start();
|
|
38
38
|
await waitForRegistryReady(registry);
|
|
39
|
-
const client =
|
|
40
|
-
...
|
|
39
|
+
const client = _chunkF6GCLL5Zcjs.createClient.call(void 0, {
|
|
40
|
+
..._chunk5MJPN3QUcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
|
|
41
41
|
disableMetadataLookup: false
|
|
42
42
|
});
|
|
43
43
|
c.onTestFinished(async () => {
|
package/dist/tsup/test/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { aC as Registry, a2 as Client } from '../config-
|
|
2
|
+
import { aC as Registry, a2 as Client } from '../config-CpB-e4I9.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-BxOimoGX.cjs';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
package/dist/tsup/test/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { aC as Registry, a2 as Client } from '../config-
|
|
2
|
+
import { aC as Registry, a2 as Client } from '../config-CUymbyM6.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-BxOimoGX.js';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
package/dist/tsup/test/mod.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-YFXQ7DBH.js";
|
|
4
4
|
import {
|
|
5
5
|
convertRegistryConfigToClientConfig
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-BL6ERZQO.js";
|
|
7
7
|
import "../chunk-JI6GZ2C2.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-V7PJYBA5.js";
|
|
9
9
|
import "../chunk-7AFZMFPQ.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-ZKDZW5DQ.js";
|
|
11
11
|
import "../chunk-ZZ3WBRPD.js";
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
package/dist/tsup/utils.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkNUMGL52Rcjs = require('./chunk-NUMGL52R.cjs');
|
|
23
23
|
require('./chunk-4FC7TVS6.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
@@ -42,5 +42,5 @@ require('./chunk-4FC7TVS6.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.EXTRA_ERROR_LOG =
|
|
45
|
+
exports.EXTRA_ERROR_LOG = _chunkNUMGL52Rcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkNUMGL52Rcjs.SinglePromiseQueue; exports.VERSION = _chunkNUMGL52Rcjs.VERSION; exports.arrayBuffersEqual = _chunkNUMGL52Rcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkNUMGL52Rcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkNUMGL52Rcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkNUMGL52Rcjs.combineUrlPath; exports.dbg = _chunkNUMGL52Rcjs.dbg; exports.detectRuntime = _chunkNUMGL52Rcjs.detectRuntime; exports.getEnvUniversal = _chunkNUMGL52Rcjs.getEnvUniversal; exports.httpUserAgent = _chunkNUMGL52Rcjs.httpUserAgent; exports.interval = _chunkNUMGL52Rcjs.interval; exports.joinSignals = _chunkNUMGL52Rcjs.joinSignals; exports.jsonParseCompat = _chunkNUMGL52Rcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkNUMGL52Rcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkNUMGL52Rcjs.promiseWithResolvers; exports.setLongTimeout = _chunkNUMGL52Rcjs.setLongTimeout; exports.sleep = _chunkNUMGL52Rcjs.sleep; exports.stringifyError = _chunkNUMGL52Rcjs.stringifyError; exports.toUint8Array = _chunkNUMGL52Rcjs.toUint8Array;
|
|
46
46
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/tsup/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var _chunkTMTJPSHQcjs = require('../chunk-TMTJPSHQ.cjs');
|
|
4
|
+
require('../chunk-IJMVVULS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ var _chunkHNHLBM3Ycjs = require('../chunk-HNHLBM3Y.cjs');
|
|
|
12
12
|
var _chunkMYWZCDMLcjs = require('../chunk-MYWZCDML.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkNUMGL52Rcjs = require('../chunk-NUMGL52R.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -716,7 +716,7 @@ function workflow(fn, options = {}) {
|
|
|
716
716
|
function getWorkflowInspector(actorId) {
|
|
717
717
|
let workflowInspector = workflowInspectors.get(actorId);
|
|
718
718
|
if (!workflowInspector) {
|
|
719
|
-
workflowInspector =
|
|
719
|
+
workflowInspector = _chunkTMTJPSHQcjs.createWorkflowInspectorAdapter.call(void 0, );
|
|
720
720
|
workflowInspectors.set(actorId, workflowInspector);
|
|
721
721
|
}
|
|
722
722
|
return workflowInspector;
|
|
@@ -784,13 +784,13 @@ function workflow(fn, options = {}) {
|
|
|
784
784
|
if (shouldRethrowWorkflowError(error)) {
|
|
785
785
|
runCtx.log.error({
|
|
786
786
|
msg: "workflow run failed",
|
|
787
|
-
error:
|
|
787
|
+
error: _chunkNUMGL52Rcjs.stringifyError.call(void 0, error)
|
|
788
788
|
});
|
|
789
789
|
throw error;
|
|
790
790
|
}
|
|
791
791
|
runCtx.log.warn({
|
|
792
792
|
msg: "workflow failed and will sleep until woken",
|
|
793
|
-
error:
|
|
793
|
+
error: _chunkNUMGL52Rcjs.stringifyError.call(void 0, error)
|
|
794
794
|
});
|
|
795
795
|
} finally {
|
|
796
796
|
runCtx.abortSignal.removeEventListener("abort", onAbort);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
2
2
|
export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
3
|
-
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-
|
|
3
|
+
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-CpB-e4I9.cjs';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-BxOimoGX.cjs';
|
|
5
|
-
import { d as WorkflowContext } from '../context-
|
|
6
|
-
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-
|
|
5
|
+
import { d as WorkflowContext } from '../context-c-6G4mjk.cjs';
|
|
6
|
+
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-c-6G4mjk.cjs';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
9
9
|
import 'zod';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
2
2
|
export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
3
|
-
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-
|
|
3
|
+
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-CUymbyM6.js';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-BxOimoGX.js';
|
|
5
|
-
import { d as WorkflowContext } from '../context-
|
|
6
|
-
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-
|
|
5
|
+
import { d as WorkflowContext } from '../context-YBUBTwTS.js';
|
|
6
|
+
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-YBUBTwTS.js';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
9
9
|
import 'zod';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWorkflowInspectorAdapter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-MY6BRV3S.js";
|
|
4
|
+
import "../chunk-HWBISPRP.js";
|
|
5
5
|
import {
|
|
6
6
|
ACTOR_CONTEXT_INTERNAL_SYMBOL,
|
|
7
7
|
RUN_FUNCTION_CONFIG_SYMBOL
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../chunk-JI6GZ2C2.js";
|
|
13
13
|
import {
|
|
14
14
|
stringifyError
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-ZKDZW5DQ.js";
|
|
16
16
|
import {
|
|
17
17
|
RivetError,
|
|
18
18
|
isActorAbortedError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivetkit",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.8",
|
|
4
4
|
"description": "Lightweight libraries for building stateful actors on edge platforms",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -201,14 +201,14 @@
|
|
|
201
201
|
"@hono/zod-openapi": "^1.1.5",
|
|
202
202
|
"@rivet-dev/agent-os-core": "^0.1.1",
|
|
203
203
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
204
|
-
"@rivetkit/engine-cli": "2.3.
|
|
205
|
-
"@rivetkit/engine-envoy-protocol": "2.3.
|
|
204
|
+
"@rivetkit/engine-cli": "2.3.8",
|
|
205
|
+
"@rivetkit/engine-envoy-protocol": "2.3.8",
|
|
206
206
|
"@rivetkit/on-change": "6.0.1",
|
|
207
|
-
"@rivetkit/rivetkit-napi": "2.3.
|
|
208
|
-
"@rivetkit/rivetkit-wasm": "2.3.
|
|
209
|
-
"@rivetkit/traces": "2.3.
|
|
210
|
-
"@rivetkit/virtual-websocket": "2.3.
|
|
211
|
-
"@rivetkit/workflow-engine": "2.3.
|
|
207
|
+
"@rivetkit/rivetkit-napi": "2.3.8",
|
|
208
|
+
"@rivetkit/rivetkit-wasm": "2.3.8",
|
|
209
|
+
"@rivetkit/traces": "2.3.8",
|
|
210
|
+
"@rivetkit/virtual-websocket": "2.3.8",
|
|
211
|
+
"@rivetkit/workflow-engine": "2.3.8",
|
|
212
212
|
"cbor-x": "^1.6.0",
|
|
213
213
|
"drizzle-orm": "^0.44.2",
|
|
214
214
|
"hono": "^4.7.0",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
HEADER_CONN_PARAMS,
|
|
5
5
|
HEADER_ENCODING,
|
|
6
6
|
} from "@/common/actor-router-consts";
|
|
7
|
+
import { isRequestLike } from "@/common/fetch-like";
|
|
7
8
|
import type * as protocol from "@/common/client-protocol";
|
|
8
9
|
import {
|
|
9
10
|
CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
@@ -640,6 +641,7 @@ export class ActorHandleRaw {
|
|
|
640
641
|
) {
|
|
641
642
|
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
642
643
|
let useQueryTarget = false;
|
|
644
|
+
const retryableRequest = isRequestLike(input) ? input.clone() : undefined;
|
|
643
645
|
const { skipReadyWait, ...requestInit } = init ?? {};
|
|
644
646
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
645
647
|
this.#gatewayOptions,
|
|
@@ -660,7 +662,7 @@ export class ActorHandleRaw {
|
|
|
660
662
|
this.#driver,
|
|
661
663
|
target,
|
|
662
664
|
this.#params,
|
|
663
|
-
input,
|
|
665
|
+
retryableRequest ? retryableRequest.clone() : input,
|
|
664
666
|
requestInit,
|
|
665
667
|
gatewayOptions,
|
|
666
668
|
);
|
package/src/client/raw-utils.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HEADER_CONN_PARAMS,
|
|
3
|
+
HEADER_ORIGINAL_REQUEST_URL,
|
|
3
4
|
PATH_WEBSOCKET_PREFIX,
|
|
4
5
|
} from "@/common/actor-router-consts";
|
|
5
6
|
import { deconstructError } from "@/common/utils";
|
|
7
|
+
import { isRequestLike, isUrlLike } from "@/common/fetch-like";
|
|
6
8
|
import type {
|
|
7
9
|
EngineControlClient,
|
|
8
10
|
GatewayRequestOptions,
|
|
@@ -24,16 +26,19 @@ export async function rawHttpFetch(
|
|
|
24
26
|
): Promise<Response> {
|
|
25
27
|
// Extract path and merge init options
|
|
26
28
|
let path: string;
|
|
29
|
+
let originalUrl: string | undefined;
|
|
27
30
|
let mergedInit: RequestInit = init || {};
|
|
28
31
|
|
|
29
32
|
if (typeof input === "string") {
|
|
30
33
|
path = input;
|
|
31
|
-
} else if (input
|
|
34
|
+
} else if (isUrlLike(input)) {
|
|
32
35
|
path = input.pathname + input.search;
|
|
33
|
-
|
|
36
|
+
originalUrl = input.toString();
|
|
37
|
+
} else if (isRequestLike(input)) {
|
|
34
38
|
// Extract path from Request URL
|
|
35
39
|
const url = new URL(input.url);
|
|
36
40
|
path = url.pathname + url.search;
|
|
41
|
+
originalUrl = url.toString();
|
|
37
42
|
// Merge Request properties with init
|
|
38
43
|
const requestHeaders = new Headers(input.headers);
|
|
39
44
|
const initHeaders = new Headers(init?.headers || {});
|
|
@@ -85,6 +90,10 @@ export async function rawHttpFetch(
|
|
|
85
90
|
|
|
86
91
|
// Forward conn params if provided
|
|
87
92
|
const proxyRequestHeaders = new Headers(mergedInit.headers);
|
|
93
|
+
proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
|
|
94
|
+
if (originalUrl) {
|
|
95
|
+
proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
|
|
96
|
+
}
|
|
88
97
|
if (params) {
|
|
89
98
|
proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
|
|
90
99
|
}
|
|
@@ -12,6 +12,7 @@ export const HEADER_ENCODING = "x-rivet-encoding";
|
|
|
12
12
|
|
|
13
13
|
// IMPORTANT: Params must be in headers or in an E2EE part of the request (i.e. NOT the URL or query string) in order to ensure that tokens can be securely passed in params.
|
|
14
14
|
export const HEADER_CONN_PARAMS = "x-rivet-conn-params";
|
|
15
|
+
export const HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
|
|
15
16
|
|
|
16
17
|
export const HEADER_ACTOR_ID = "x-rivet-actor";
|
|
17
18
|
export const HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
|
package/src/common/encoding.ts
CHANGED
|
@@ -484,7 +484,10 @@ export function jsonStringifyCompat(
|
|
|
484
484
|
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
485
485
|
}
|
|
486
486
|
if (value instanceof ArrayBuffer) {
|
|
487
|
-
return [
|
|
487
|
+
return [
|
|
488
|
+
JSON_COMPAT_ARRAY_BUFFER,
|
|
489
|
+
base64EncodeArrayBuffer(value),
|
|
490
|
+
];
|
|
488
491
|
}
|
|
489
492
|
if (value instanceof Uint8Array) {
|
|
490
493
|
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
type HeadersLike = {
|
|
2
|
+
entries(): IterableIterator<[string, string]>;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type RequestLike = Request & {
|
|
6
|
+
readonly headers: HeadersLike & Request["headers"];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ResponseLike = Response & {
|
|
10
|
+
readonly headers: HeadersLike & Response["headers"];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function isUrlLike(value: unknown): value is URL {
|
|
14
|
+
return (
|
|
15
|
+
typeof value === "object" &&
|
|
16
|
+
value !== null &&
|
|
17
|
+
typeof (value as URL).href === "string" &&
|
|
18
|
+
typeof (value as URL).pathname === "string" &&
|
|
19
|
+
typeof (value as URL).search === "string"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isRequestLike(value: unknown): value is RequestLike {
|
|
24
|
+
return (
|
|
25
|
+
typeof value === "object" &&
|
|
26
|
+
value !== null &&
|
|
27
|
+
typeof (value as Request).url === "string" &&
|
|
28
|
+
typeof (value as Request).method === "string" &&
|
|
29
|
+
isHeadersLike((value as Request).headers)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isResponseLike(value: unknown): value is ResponseLike {
|
|
34
|
+
return (
|
|
35
|
+
typeof value === "object" &&
|
|
36
|
+
value !== null &&
|
|
37
|
+
typeof (value as Response).status === "number" &&
|
|
38
|
+
isHeadersLike((value as Response).headers) &&
|
|
39
|
+
typeof (value as Response).arrayBuffer === "function"
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isHeadersLike(value: unknown): value is HeadersLike {
|
|
44
|
+
return (
|
|
45
|
+
typeof value === "object" &&
|
|
46
|
+
value !== null &&
|
|
47
|
+
typeof (value as HeadersLike).entries === "function"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -17,8 +17,7 @@ export async function sendHttpRequestToGateway(
|
|
|
17
17
|
actorRequest: Request,
|
|
18
18
|
options: HttpGatewayRequestOptions = {},
|
|
19
19
|
): Promise<Response> {
|
|
20
|
-
|
|
21
|
-
let bodyToSend: ArrayBuffer | null = null;
|
|
20
|
+
let bodyToSend: ReadableStream<Uint8Array> | null = null;
|
|
22
21
|
const guardHeaders = buildGuardHeaders(runConfig, actorRequest, options);
|
|
23
22
|
|
|
24
23
|
if (actorRequest.method !== "GET" && actorRequest.method !== "HEAD") {
|
|
@@ -26,35 +25,20 @@ export async function sendHttpRequestToGateway(
|
|
|
26
25
|
throw new Error("Request body has already been consumed");
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const reqBody = await actorRequest.arrayBuffer();
|
|
32
|
-
|
|
33
|
-
if (reqBody.byteLength !== 0) {
|
|
34
|
-
bodyToSend = reqBody;
|
|
35
|
-
|
|
36
|
-
// If this is a streaming request, we need to convert the headers
|
|
37
|
-
// for the basic array buffer.
|
|
28
|
+
if (actorRequest.body) {
|
|
29
|
+
bodyToSend = actorRequest.body;
|
|
38
30
|
guardHeaders.delete("transfer-encoding");
|
|
39
31
|
guardHeaders.delete("content-length");
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
return fetch(gatewayUrl, {
|
|
44
36
|
method: actorRequest.method,
|
|
45
37
|
headers: guardHeaders,
|
|
46
38
|
body: bodyToSend,
|
|
47
39
|
signal: actorRequest.signal,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return mutableResponse(await fetch(guardRequest));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function mutableResponse(fetchRes: Response): Response {
|
|
54
|
-
// We cannot return the raw response from `fetch` since the response type is not mutable.
|
|
55
|
-
//
|
|
56
|
-
// In order for middleware to be able to mutate the response, we need to build a new Response object that is mutable.
|
|
57
|
-
return new Response(fetchRes.body, fetchRes);
|
|
40
|
+
...(bodyToSend ? { duplex: "half" } : {}),
|
|
41
|
+
} as RequestInit);
|
|
58
42
|
}
|
|
59
43
|
|
|
60
44
|
function buildGuardHeaders(
|