rivetkit 2.3.9 → 2.3.11-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +2 -12
- package/dist/browser/client.js +22 -27
- 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 +2 -12
- package/dist/tsup/agent-os/index.d.ts +2 -12
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-S57DMBTM.cjs → chunk-57ZE43T5.cjs} +3 -3
- package/dist/tsup/{chunk-S57DMBTM.cjs.map → chunk-57ZE43T5.cjs.map} +1 -1
- package/dist/tsup/{chunk-X25YYVFL.js → chunk-5FVMFSBH.js} +2 -2
- package/dist/tsup/{chunk-BQU4XTKM.js → chunk-5ZS22TOP.js} +3 -3
- package/dist/tsup/{chunk-CQ23UFQ4.js → chunk-6ZPMYIZ6.js} +2 -2
- package/dist/tsup/{chunk-UBYPRYJR.js → chunk-ET2F6BXK.js} +2 -2
- package/dist/tsup/chunk-ET2F6BXK.js.map +1 -0
- package/dist/tsup/{chunk-AVUMOGUE.cjs → chunk-JAQHV6LB.cjs} +7 -7
- package/dist/tsup/{chunk-AVUMOGUE.cjs.map → chunk-JAQHV6LB.cjs.map} +1 -1
- package/dist/tsup/{chunk-GZ5DYSIR.cjs → chunk-K4DNAIWT.cjs} +4 -4
- package/dist/tsup/{chunk-GZ5DYSIR.cjs.map → chunk-K4DNAIWT.cjs.map} +1 -1
- package/dist/tsup/{chunk-KVKWTOW7.js → chunk-L4DYLD7P.js} +3 -3
- package/dist/tsup/{chunk-MQDQ3A72.js → chunk-MMPE77KO.js} +27 -33
- package/dist/tsup/chunk-MMPE77KO.js.map +1 -0
- package/dist/tsup/{chunk-M4R2O5NJ.cjs → chunk-TWNMQDZK.cjs} +2 -2
- package/dist/tsup/chunk-TWNMQDZK.cjs.map +1 -0
- package/dist/tsup/{chunk-3IDKUXQT.cjs → chunk-W2YEXCCJ.cjs} +163 -169
- package/dist/tsup/chunk-W2YEXCCJ.cjs.map +1 -0
- package/dist/tsup/{chunk-KPP2YRS5.cjs → chunk-XEOPXHN2.cjs} +9 -9
- package/dist/tsup/{chunk-KPP2YRS5.cjs.map → chunk-XEOPXHN2.cjs.map} +1 -1
- 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-CUymbyM6.d.ts → config-BKAMOHez.d.ts} +2 -12
- package/dist/tsup/{config-CpB-e4I9.d.cts → config-Caocy3Z9.d.cts} +2 -12
- package/dist/tsup/{context-YBUBTwTS.d.ts → context-AfCExwbr.d.ts} +1 -1
- package/dist/tsup/{context-c-6G4mjk.d.cts → context-D1_m5x1D.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 +131 -341
- 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 +68 -278
- 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 +1 -3
- package/src/client/raw-utils.ts +0 -8
- package/src/common/actor-router-consts.ts +0 -1
- package/src/engine-client/actor-http-client.ts +22 -6
- package/src/registry/index.ts +11 -51
- package/src/registry/napi-runtime.ts +5 -32
- package/src/registry/native.ts +63 -110
- package/src/registry/runtime.ts +2 -16
- package/dist/tsup/chunk-3IDKUXQT.cjs.map +0 -1
- package/dist/tsup/chunk-M4R2O5NJ.cjs.map +0 -1
- package/dist/tsup/chunk-MQDQ3A72.js.map +0 -1
- package/dist/tsup/chunk-UBYPRYJR.js.map +0 -1
- package/src/registry/native-http.ts +0 -208
- /package/dist/tsup/{chunk-X25YYVFL.js.map → chunk-5FVMFSBH.js.map} +0 -0
- /package/dist/tsup/{chunk-BQU4XTKM.js.map → chunk-5ZS22TOP.js.map} +0 -0
- /package/dist/tsup/{chunk-CQ23UFQ4.js.map → chunk-6ZPMYIZ6.js.map} +0 -0
- /package/dist/tsup/{chunk-KVKWTOW7.js.map → chunk-L4DYLD7P.js.map} +0 -0
package/src/registry/native.ts
CHANGED
|
@@ -47,7 +47,7 @@ import { HEADER_CONN_PARAMS } from "@/common/actor-router-consts";
|
|
|
47
47
|
import type { AnyDatabaseProvider } from "@/common/database/config";
|
|
48
48
|
import { wrapJsNativeDatabase } from "@/common/database/native-database";
|
|
49
49
|
import { assertJsonCompatValue, type JsonCompatValue } from "@/common/encoding";
|
|
50
|
-
import { isResponseLike } from "@/common/fetch-like";
|
|
50
|
+
import { isResponseLike, type ResponseLike } from "@/common/fetch-like";
|
|
51
51
|
import { decodeWorkflowHistoryTransport } from "@/common/inspector-transport";
|
|
52
52
|
import { deconstructError, stringifyError } from "@/common/utils";
|
|
53
53
|
import type {
|
|
@@ -72,13 +72,6 @@ import {
|
|
|
72
72
|
} from "@/utils/node";
|
|
73
73
|
import { logger } from "./log";
|
|
74
74
|
import { loadNapiRuntime } from "./napi-runtime";
|
|
75
|
-
import {
|
|
76
|
-
buildNativeHttpRequest,
|
|
77
|
-
cancelNativeHttpRequestBody,
|
|
78
|
-
convertNativeHttpResponse,
|
|
79
|
-
type NativeHttpRequestBodyStream,
|
|
80
|
-
type NativeHttpResponseBodyStream,
|
|
81
|
-
} from "./native-http";
|
|
82
75
|
import {
|
|
83
76
|
type NativeValidationConfig,
|
|
84
77
|
validateActionArgs,
|
|
@@ -98,6 +91,7 @@ import type {
|
|
|
98
91
|
RuntimeBytes,
|
|
99
92
|
RuntimeCronFire,
|
|
100
93
|
RuntimeCronJobInfo,
|
|
94
|
+
RuntimeHttpResponse,
|
|
101
95
|
RuntimeInspectorTabEntry,
|
|
102
96
|
RuntimeQueueMessage,
|
|
103
97
|
RuntimeScheduledEventInfo,
|
|
@@ -1169,6 +1163,38 @@ function decodeArgs(value?: RuntimeBytes | null): unknown[] {
|
|
|
1169
1163
|
return normalizeArgs(decoded);
|
|
1170
1164
|
}
|
|
1171
1165
|
|
|
1166
|
+
function buildRequest(init: {
|
|
1167
|
+
method: string;
|
|
1168
|
+
uri: string;
|
|
1169
|
+
headers?: Record<string, string>;
|
|
1170
|
+
body?: RuntimeBytes;
|
|
1171
|
+
}): Request {
|
|
1172
|
+
const url = init.uri.startsWith("http")
|
|
1173
|
+
? init.uri
|
|
1174
|
+
: new URL(init.uri, "http://127.0.0.1").toString();
|
|
1175
|
+
const body =
|
|
1176
|
+
init.body && init.body.length > 0
|
|
1177
|
+
? runtimeBytesToArrayBuffer(init.body)
|
|
1178
|
+
: undefined;
|
|
1179
|
+
return new Request(url, {
|
|
1180
|
+
method: init.method,
|
|
1181
|
+
headers: init.headers,
|
|
1182
|
+
body,
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
async function toRuntimeHttpResponse(
|
|
1187
|
+
response: ResponseLike,
|
|
1188
|
+
): Promise<RuntimeHttpResponse> {
|
|
1189
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
1190
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
1191
|
+
return {
|
|
1192
|
+
status: response.status,
|
|
1193
|
+
headers,
|
|
1194
|
+
body,
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1172
1198
|
function toActorKey(
|
|
1173
1199
|
segments: Array<{
|
|
1174
1200
|
kind: string;
|
|
@@ -3690,22 +3716,19 @@ export function buildNativeFactory(
|
|
|
3690
3716
|
);
|
|
3691
3717
|
const maybeHandleNativeInspectorRequest = async (
|
|
3692
3718
|
ctx: ActorContextHandle,
|
|
3693
|
-
|
|
3719
|
+
_rawRequest: {
|
|
3694
3720
|
method: string;
|
|
3695
3721
|
uri: string;
|
|
3696
3722
|
headers?: Record<string, string>;
|
|
3697
3723
|
body?: RuntimeBytes;
|
|
3698
3724
|
},
|
|
3725
|
+
jsRequest: Request,
|
|
3699
3726
|
): Promise<Response | undefined> => {
|
|
3700
|
-
const
|
|
3701
|
-
? rawRequest.uri
|
|
3702
|
-
: new URL(rawRequest.uri, "http://127.0.0.1").toString();
|
|
3703
|
-
const url = new URL(rawUrl);
|
|
3727
|
+
const url = new URL(jsRequest.url);
|
|
3704
3728
|
if (!url.pathname.startsWith("/inspector/")) {
|
|
3705
3729
|
return undefined;
|
|
3706
3730
|
}
|
|
3707
3731
|
|
|
3708
|
-
const jsRequest = buildNativeHttpRequest(rawRequest);
|
|
3709
3732
|
const jsonResponse = (body: unknown, init?: ResponseInit) =>
|
|
3710
3733
|
new Response(JSON.stringify(body), {
|
|
3711
3734
|
status: init?.status ?? 200,
|
|
@@ -4397,9 +4420,7 @@ export function buildNativeFactory(
|
|
|
4397
4420
|
);
|
|
4398
4421
|
const actorCtx = makeActorCtx(
|
|
4399
4422
|
ctx,
|
|
4400
|
-
request
|
|
4401
|
-
? buildNativeHttpRequest(request)
|
|
4402
|
-
: undefined,
|
|
4423
|
+
request ? buildRequest(request) : undefined,
|
|
4403
4424
|
);
|
|
4404
4425
|
try {
|
|
4405
4426
|
await config.onBeforeConnect(
|
|
@@ -4436,9 +4457,7 @@ export function buildNativeFactory(
|
|
|
4436
4457
|
unwrapTsfnPayload(error, payload);
|
|
4437
4458
|
const actorCtx = makeActorCtx(
|
|
4438
4459
|
ctx,
|
|
4439
|
-
request
|
|
4440
|
-
? buildNativeHttpRequest(request)
|
|
4441
|
-
: undefined,
|
|
4460
|
+
request ? buildRequest(request) : undefined,
|
|
4442
4461
|
);
|
|
4443
4462
|
const connAdapter = new NativeConnAdapter(
|
|
4444
4463
|
runtime,
|
|
@@ -4493,9 +4512,7 @@ export function buildNativeFactory(
|
|
|
4493
4512
|
);
|
|
4494
4513
|
const actorCtx = makeActorCtx(
|
|
4495
4514
|
ctx,
|
|
4496
|
-
request
|
|
4497
|
-
? buildNativeHttpRequest(request)
|
|
4498
|
-
: undefined,
|
|
4515
|
+
request ? buildRequest(request) : undefined,
|
|
4499
4516
|
);
|
|
4500
4517
|
const connAdapter = new NativeConnAdapter(
|
|
4501
4518
|
runtime,
|
|
@@ -4645,63 +4662,38 @@ export function buildNativeFactory(
|
|
|
4645
4662
|
uri: string;
|
|
4646
4663
|
headers?: Record<string, string>;
|
|
4647
4664
|
body?: RuntimeBytes;
|
|
4648
|
-
bodyStream?: NativeHttpRequestBodyStream;
|
|
4649
4665
|
};
|
|
4650
4666
|
cancelToken?: CancellationTokenHandle;
|
|
4651
|
-
responseBodyStream?: NativeHttpResponseBodyStream;
|
|
4652
4667
|
},
|
|
4653
4668
|
) => {
|
|
4654
4669
|
try {
|
|
4655
|
-
const { ctx, request, cancelToken
|
|
4656
|
-
|
|
4670
|
+
const { ctx, request, cancelToken } = unwrapTsfnPayload(
|
|
4671
|
+
error,
|
|
4672
|
+
payload,
|
|
4673
|
+
);
|
|
4674
|
+
const jsRequest = buildRequest(request);
|
|
4657
4675
|
const inspectorResponse =
|
|
4658
|
-
await maybeHandleNativeInspectorRequest(
|
|
4676
|
+
await maybeHandleNativeInspectorRequest(
|
|
4677
|
+
ctx,
|
|
4678
|
+
request,
|
|
4679
|
+
jsRequest,
|
|
4680
|
+
);
|
|
4659
4681
|
if (inspectorResponse) {
|
|
4660
|
-
await
|
|
4661
|
-
return (
|
|
4662
|
-
await convertNativeHttpResponse(
|
|
4663
|
-
inspectorResponse,
|
|
4664
|
-
responseBodyStream,
|
|
4665
|
-
)
|
|
4666
|
-
).response;
|
|
4682
|
+
return await toRuntimeHttpResponse(inspectorResponse);
|
|
4667
4683
|
}
|
|
4668
4684
|
|
|
4669
4685
|
if (typeof config.onRequest !== "function") {
|
|
4670
|
-
await
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
new Response(null, { status: 404 }),
|
|
4674
|
-
responseBodyStream,
|
|
4675
|
-
)
|
|
4676
|
-
).response;
|
|
4686
|
+
return await toRuntimeHttpResponse(
|
|
4687
|
+
new Response(null, { status: 404 }),
|
|
4688
|
+
);
|
|
4677
4689
|
}
|
|
4678
4690
|
|
|
4679
|
-
const requestAbortController = new AbortController();
|
|
4680
|
-
const handlerRequest = buildNativeHttpRequest({
|
|
4681
|
-
...request,
|
|
4682
|
-
abortController: requestAbortController,
|
|
4683
|
-
});
|
|
4684
4691
|
const rawConnParams =
|
|
4685
|
-
|
|
4692
|
+
jsRequest.headers.get(HEADER_CONN_PARAMS);
|
|
4686
4693
|
let requestCtx:
|
|
4687
4694
|
| ReturnType<typeof withConnContext>
|
|
4688
4695
|
| undefined;
|
|
4689
4696
|
let conn: ConnHandle | undefined;
|
|
4690
|
-
let removeRequestAbortListener: (() => void) | undefined;
|
|
4691
|
-
let cleanupDeferredToBody = false;
|
|
4692
|
-
let cleanedUp = false;
|
|
4693
|
-
const cleanupRequest = async () => {
|
|
4694
|
-
if (cleanedUp) return;
|
|
4695
|
-
cleanedUp = true;
|
|
4696
|
-
removeRequestAbortListener?.();
|
|
4697
|
-
try {
|
|
4698
|
-
await requestCtx?.dispose();
|
|
4699
|
-
} finally {
|
|
4700
|
-
if (conn) {
|
|
4701
|
-
await runtime.connDisconnect(conn);
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
|
-
};
|
|
4705
4697
|
try {
|
|
4706
4698
|
const connParams = validateConnParams(
|
|
4707
4699
|
schemaConfig.connParamsSchema,
|
|
@@ -4719,62 +4711,23 @@ export function buildNativeFactory(
|
|
|
4719
4711
|
requestCtx = makeConnCtx(
|
|
4720
4712
|
ctx,
|
|
4721
4713
|
conn,
|
|
4722
|
-
|
|
4714
|
+
jsRequest,
|
|
4723
4715
|
cancelToken,
|
|
4724
4716
|
);
|
|
4725
|
-
const ctxAbortSignal = requestCtx.abortSignal;
|
|
4726
|
-
const abortRequest = () =>
|
|
4727
|
-
requestAbortController.abort(ctxAbortSignal.reason);
|
|
4728
|
-
if (ctxAbortSignal.aborted) {
|
|
4729
|
-
abortRequest();
|
|
4730
|
-
} else {
|
|
4731
|
-
ctxAbortSignal.addEventListener(
|
|
4732
|
-
"abort",
|
|
4733
|
-
abortRequest,
|
|
4734
|
-
{ once: true },
|
|
4735
|
-
);
|
|
4736
|
-
removeRequestAbortListener = () =>
|
|
4737
|
-
ctxAbortSignal.removeEventListener(
|
|
4738
|
-
"abort",
|
|
4739
|
-
abortRequest,
|
|
4740
|
-
);
|
|
4741
|
-
}
|
|
4742
4717
|
const response = await config.onRequest(
|
|
4743
4718
|
requestCtx,
|
|
4744
|
-
|
|
4719
|
+
jsRequest,
|
|
4745
4720
|
);
|
|
4746
4721
|
if (!isResponseLike(response)) {
|
|
4747
4722
|
throw new Error(
|
|
4748
4723
|
"onRequest handler must return a Response",
|
|
4749
4724
|
);
|
|
4750
4725
|
}
|
|
4751
|
-
|
|
4752
|
-
response,
|
|
4753
|
-
responseBodyStream,
|
|
4754
|
-
);
|
|
4755
|
-
if (conversion.bodyCompletion) {
|
|
4756
|
-
cleanupDeferredToBody = true;
|
|
4757
|
-
void conversion.bodyCompletion
|
|
4758
|
-
.then(cleanupRequest)
|
|
4759
|
-
.catch((cleanupError) => {
|
|
4760
|
-
logger().error({
|
|
4761
|
-
msg: "failed to clean up native streaming http request",
|
|
4762
|
-
error: cleanupError,
|
|
4763
|
-
});
|
|
4764
|
-
});
|
|
4765
|
-
}
|
|
4766
|
-
return conversion.response;
|
|
4726
|
+
return await toRuntimeHttpResponse(response);
|
|
4767
4727
|
} finally {
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
await cancelNativeHttpRequestBody(
|
|
4772
|
-
request.bodyStream,
|
|
4773
|
-
);
|
|
4774
|
-
} finally {
|
|
4775
|
-
if (!cleanupDeferredToBody) {
|
|
4776
|
-
await cleanupRequest();
|
|
4777
|
-
}
|
|
4728
|
+
await requestCtx?.dispose();
|
|
4729
|
+
if (conn) {
|
|
4730
|
+
await runtime.connDisconnect(conn);
|
|
4778
4731
|
}
|
|
4779
4732
|
}
|
|
4780
4733
|
} catch (error) {
|
|
@@ -4806,7 +4759,7 @@ export function buildNativeFactory(
|
|
|
4806
4759
|
const { ctx, conn, ws, request } =
|
|
4807
4760
|
unwrapTsfnPayload(error, payload);
|
|
4808
4761
|
const jsRequest = request
|
|
4809
|
-
?
|
|
4762
|
+
? buildRequest(request)
|
|
4810
4763
|
: undefined;
|
|
4811
4764
|
const actorCtx = makeConnCtx(ctx, conn, jsRequest);
|
|
4812
4765
|
try {
|
|
@@ -4966,7 +4919,7 @@ export function buildNativeFactory(
|
|
|
4966
4919
|
timeoutMs,
|
|
4967
4920
|
cancelToken,
|
|
4968
4921
|
} = unwrapTsfnPayload(error, payload);
|
|
4969
|
-
const jsRequest =
|
|
4922
|
+
const jsRequest = buildRequest(request);
|
|
4970
4923
|
const actorCtx = withConnContext(
|
|
4971
4924
|
runtime,
|
|
4972
4925
|
ctx,
|
package/src/registry/runtime.ts
CHANGED
|
@@ -36,14 +36,6 @@ export interface RuntimeHttpResponse {
|
|
|
36
36
|
status?: number;
|
|
37
37
|
headers?: Record<string, string>;
|
|
38
38
|
body?: RuntimeBytes;
|
|
39
|
-
stream?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RuntimeHttpResponseBodyStream {
|
|
43
|
-
cancelled(): Promise<void>;
|
|
44
|
-
write(chunk: Uint8Array): Promise<void>;
|
|
45
|
-
end(): Promise<void>;
|
|
46
|
-
error(message: string): Promise<void>;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
export interface RuntimeStateDeltaPayload {
|
|
@@ -364,20 +356,14 @@ export interface RuntimeServerlessRequest {
|
|
|
364
356
|
body: RuntimeBytes;
|
|
365
357
|
}
|
|
366
358
|
|
|
367
|
-
export interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
|
|
368
|
-
cancelToken?: CancellationTokenHandle;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
359
|
export interface RuntimeApplicationResponse {
|
|
372
360
|
status: number;
|
|
373
361
|
headers: Record<string, string>;
|
|
374
|
-
body
|
|
375
|
-
stream?: boolean;
|
|
362
|
+
body: RuntimeBytes;
|
|
376
363
|
}
|
|
377
364
|
|
|
378
365
|
export type RuntimeApplicationFetch = (
|
|
379
|
-
request:
|
|
380
|
-
responseBodyStream?: RuntimeHttpResponseBodyStream,
|
|
366
|
+
request: RuntimeServerlessRequest,
|
|
381
367
|
) => Promise<RuntimeApplicationResponse>;
|
|
382
368
|
|
|
383
369
|
export interface RuntimeApplicationListenerConfig
|