@voltro/runtime 0.86.0 → 0.88.0
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/CHANGELOG.md +5484 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.md +1511 -276
- package/dist/aggregate.js +1 -2
- package/dist/aggregateExtrema.js +1 -2
- package/dist/aggregateIvm.js +1 -2
- package/dist/analyticsMirror.js +1 -2
- package/dist/analyticsSink.js +9 -16
- package/dist/apiKeyUsage.js +1 -2
- package/dist/apiKeys.js +83 -80
- package/dist/apiKeysWiring.js +1 -2
- package/dist/apiRoleBucketSampler.js +63 -0
- package/dist/apiRoleWorkloadHistory.js +55 -0
- package/dist/apiRoleWorkloadMetrics.js +77 -0
- package/dist/apiRoleWorkloadStorage.js +94 -0
- package/dist/approvalBuiltins.js +1 -2
- package/dist/approvals.js +68 -76
- package/dist/authMiddlewareLayer.js +8 -8
- package/dist/bindEvent.js +49 -30
- package/dist/boot-refusal.d.ts +10 -0
- package/dist/{bootRefusal.js → boot-refusal.js} +1 -2
- package/dist/bootListener.js +203 -47
- package/dist/bootStoreCodec.js +39 -39
- package/dist/businessRules.js +1 -2
- package/dist/changeClaimsTable.js +1 -2
- package/dist/circuitBreaker.js +1 -72
- package/dist/columnOnUpdate.js +1 -2
- package/dist/composeAnalytics.js +32 -12
- package/dist/computedQuery.js +1 -2
- package/dist/computedQueryCache.js +289 -0
- package/dist/connectionBuiltins.js +1 -2
- package/dist/connectionCredentials.js +1 -2
- package/dist/connectionState.js +1 -2
- package/dist/connectionVault.js +1 -2
- package/dist/connectionsFacade.js +33 -32
- package/dist/coordinatedSchedule.js +85 -80
- package/dist/crdtHistory.js +1 -2
- package/dist/crdtMerge.js +1 -2
- package/dist/crdtVersionsTable.js +1 -2
- package/dist/credentialBound.js +1 -2
- package/dist/crud.js +1 -2
- package/dist/dataStore.js +155 -123
- package/dist/dataloader.js +1 -2
- package/dist/declaredTablesGuard.js +3 -3
- package/dist/defineExecutor.js +1 -2
- package/dist/dependencyGraph.js +1 -2
- package/dist/devices.js +1 -2
- package/dist/devicesWiring.js +1 -2
- package/dist/dialectReplicationAdapter.js +1 -2
- package/dist/dispatcher.js +404 -330
- package/dist/effectStore.js +3 -4
- package/dist/engineClients.js +23 -0
- package/dist/eventBus.js +1 -2
- package/dist/eventPublish.js +1 -2
- package/dist/events.js +1 -2
- package/dist/expectation.js +1 -2
- package/dist/expectationEvaluator.js +2 -3
- package/dist/experiment.js +1 -2
- package/dist/experimentEvaluator.js +1 -2
- package/dist/externalizedTasks.js +20 -8
- package/dist/fieldCipher.js +110 -42
- package/dist/fieldKeyRegistry.js +294 -0
- package/dist/fieldKeyRekey.js +285 -0
- package/dist/fieldKeyScan.js +135 -0
- package/dist/fieldKeyring.js +76 -0
- package/dist/fingerprint.js +1 -2
- package/dist/finops.js +1 -2
- package/dist/finopsAccountant.js +1 -2
- package/dist/handlerBody.js +1 -2
- package/dist/healthProbes.js +1 -2
- package/dist/hot.d.ts +56 -0
- package/dist/hot.js +3 -0
- package/dist/hotDataStore.js +147 -0
- package/dist/hotDataStoreSnapshot.js +97 -0
- package/dist/hotDataStoreTables.js +17 -0
- package/dist/http-range.d.ts +53 -0
- package/dist/http-range.js +51 -0
- package/dist/httpClientSsrf.js +13 -39
- package/dist/httpClientTracing.js +13 -11
- package/dist/httpCompression.js +18 -19
- package/dist/httpInputStream.js +81 -0
- package/dist/httpKeepAlive.js +1 -2
- package/dist/httpRouteMounts.js +2 -2
- package/dist/idempotencyStore.js +93 -54
- package/dist/idleDetector.js +1 -2
- package/dist/index.d.ts +1185 -452
- package/dist/index.js +144 -134
- package/dist/insertRequiredColumns.js +1 -2
- package/dist/instanceMembership.js +1 -2
- package/dist/ivm.js +1 -2
- package/dist/kvDataStore.js +1 -2
- package/dist/kvFacade.js +24 -19
- package/dist/matcher.js +1 -2
- package/dist/memoryColumnDefaults.js +1 -2
- package/dist/memoryQueryJoins.js +17 -18
- package/dist/memorySetOperations.js +42 -0
- package/dist/metrics.js +39 -26
- package/dist/observability.js +2 -3
- package/dist/observedGraph.js +1 -2
- package/dist/originGuard.js +1 -2
- package/dist/outbox.js +2 -3
- package/dist/pluginRefRules.js +1 -2
- package/dist/policyGuardResolver.js +1 -2
- package/dist/preview.js +1 -2
- package/dist/projectedRows.js +1 -2
- package/dist/provenance.js +1 -2
- package/dist/rangeIndex.js +1 -2
- package/dist/rawReadScope.js +2 -3
- package/dist/reaction.js +1 -2
- package/dist/reactiveConfig.js +1 -2
- package/dist/readClassification.js +1 -2
- package/dist/readRecorder.js +36 -36
- package/dist/readScopePredicate.js +11 -0
- package/dist/rebac.js +1 -2
- package/dist/rebacInterceptor.js +1 -2
- package/dist/registry.js +1 -2
- package/dist/relevantFields.js +1 -2
- package/dist/replicaHealth.js +1 -2
- package/dist/replicaLocality.js +1 -2
- package/dist/replicaObservations.js +1 -2
- package/dist/replicaSelection.js +1 -2
- package/dist/replicatedDataStore.js +23 -6
- package/dist/requestLoader.js +1 -2
- package/dist/resumeCensus.js +1 -2
- package/dist/revalidation.js +1 -2
- package/dist/rowFilter.js +57 -41
- package/dist/rowStateBytes.js +1 -2
- package/dist/rpcBodyCap.js +1 -2
- package/dist/rpcConnections.js +9 -10
- package/dist/rpcDefectDiagnostics.js +1 -2
- package/dist/rpcServer.js +523 -451
- package/dist/rpcWorkloadAdmission.js +49 -0
- package/dist/runAsSystem.js +1 -2
- package/dist/rywPositionStore.js +83 -49
- package/dist/schedule.js +1 -2
- package/dist/scheduleBackfillRequests.js +1 -2
- package/dist/scheduleClaimsTable.js +1 -2
- package/dist/scheduleRunsTable.js +1 -2
- package/dist/scheduler.js +7 -3
- package/dist/schemaRegistry.js +1 -2
- package/dist/secretsResolver.js +1 -2
- package/dist/securityHeaders.js +1 -2
- package/dist/servePipeline.js +238 -154
- package/dist/serverOnlyAudit.js +1 -2
- package/dist/serverTracer.js +1 -2
- package/dist/serviceCredentials.js +1 -2
- package/dist/setReadScopes.js +27 -0
- package/dist/singleNodeOrchestrator.js +1 -2
- package/dist/snapshotValueCodec.js +45 -0
- package/dist/sourceResolution.js +35 -26
- package/dist/storeMiddleware.js +213 -212
- package/dist/storeQuery.js +1 -2
- package/dist/storeRead.js +1 -2
- package/dist/subscriber.js +2 -2
- package/dist/subscriptionOutbox.js +1 -2
- package/dist/subscriptionRegistry.js +1 -2
- package/dist/subscriptionResume.js +1 -2
- package/dist/subscriptionSocketMetrics.js +1 -2
- package/dist/systemSubject.js +1 -2
- package/dist/tenantScope.js +9 -22
- package/dist/tenantSelection.js +1 -2
- package/dist/timeline.js +1 -2
- package/dist/traceContext.js +1 -2
- package/dist/traceSink.js +1 -2
- package/dist/traceSpansTable.js +1 -2
- package/dist/traceparent.js +9 -21
- package/dist/transactionSubject.js +1 -2
- package/dist/trustedProxy.js +2 -3
- package/dist/undo.js +1 -2
- package/dist/undoBuiltins.js +1 -2
- package/dist/undoCapture.js +1 -2
- package/dist/undoLogTable.js +1 -2
- package/dist/upsertBinding.js +1 -2
- package/dist/wakeOrchestrator.js +1 -2
- package/dist/wakeRegistry.js +1 -2
- package/dist/wakeRouter.js +1 -2
- package/dist/wakeSupervisor.js +1 -2
- package/dist/wakeupsTable.js +1 -2
- package/dist/webSocketGatewayRuntime.js +112 -73
- package/dist/webhookVerification.js +1 -2
- package/dist/wireColumnStrip.js +1 -2
- package/dist/workflowReadBuiltins.js +1 -2
- package/dist/workflowRuntime.js +10 -11
- package/package.json +36 -17
package/dist/rpcServer.js
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { crdtFoldCell as e, crdtIncrementalCell as t } from "./crdtMerge.js";
|
|
2
|
-
import {
|
|
3
|
-
import { buildSubjectKey as
|
|
4
|
-
import { runWithRoutingContext as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { RpcSerialization as
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
2
|
+
import { resolveDependentTables as n } from "./dependencyGraph.js";
|
|
3
|
+
import { buildSubjectKey as r } from "./rywPositionStore.js";
|
|
4
|
+
import { runWithRoutingContext as i, runWithRoutingContextEffect as a } from "./replicatedDataStore.js";
|
|
5
|
+
import { makeDefaultRefilter as o, rowFilterMayNarrow as s } from "./rowFilter.js";
|
|
6
|
+
import { captureRpcWorkloadAdmission as c, selectRpcWorkloadGroup as l } from "./rpcWorkloadAdmission.js";
|
|
7
|
+
import { applyKeepAlive as u, resolveKeepAlive as d } from "./httpKeepAlive.js";
|
|
8
|
+
import { rpcFrameDefects as f } from "./rpcDefectDiagnostics.js";
|
|
9
|
+
import { makeHttpRouteGroupFinder as p, makeUnmatchedGroupFinder as m, planHttpRouteMounts as h } from "./httpRouteMounts.js";
|
|
10
|
+
import { isComputedQuery as g } from "./computedQuery.js";
|
|
11
|
+
import { registerConnectionStream as _ } from "./connectionCredentials.js";
|
|
12
|
+
import { getRpcConnection as v, withRpcClientAddress as y, withRpcConnectionIdentity as b } from "./rpcConnections.js";
|
|
13
|
+
import { makeSubscriptionOutbox as x, pumpOutbox as S, reactiveSocketTunables as C } from "./subscriptionOutbox.js";
|
|
14
|
+
import { adoptDetached as ee, canonicalInputKey as te, detachForResume as ne, recordForResume as re } from "./subscriptionResume.js";
|
|
15
|
+
import { externalSpanFromTraceparent as ie, newTraceId as w, parseTraceparent as T } from "./traceparent.js";
|
|
16
|
+
import { runWithTraceContext as E } from "./traceContext.js";
|
|
17
|
+
import { runWithObservedProcedure as D } from "./observedGraph.js";
|
|
18
|
+
import { actingUserId as O } from "./storeMiddleware.js";
|
|
19
|
+
import { readCappedBody as ae, withBufferedBody as oe } from "./rpcBodyCap.js";
|
|
20
|
+
import { dispatchHttpInputStream as se } from "./httpInputStream.js";
|
|
21
|
+
import { maybeCompress as ce, mergeCompressionHeaders as le } from "./httpCompression.js";
|
|
22
|
+
import { runWebSocketGateway as ue } from "./webSocketGatewayRuntime.js";
|
|
23
|
+
import { noteResumeVerdict as de } from "./resumeCensus.js";
|
|
24
|
+
import { publishServerTracerLayer as fe } from "./serverTracer.js";
|
|
25
|
+
import { boundByCredential as pe } from "./credentialBound.js";
|
|
26
|
+
import { classifyRequestOrigin as me, isStateChangingMethod as he, makeOriginGuardExemption as ge, resolveOriginGuardConfig as _e } from "./originGuard.js";
|
|
27
|
+
import { resolveRequestClientAddress as ve, resolveRequestIsHttps as ye, resolveTrustedProxies as be } from "./trustedProxy.js";
|
|
28
|
+
import { resolveSecurityHeaders as xe, securityHeadersFor as Se } from "./securityHeaders.js";
|
|
29
|
+
import { assertWebhookRoutesDeclareVerification as Ce } from "./webhookVerification.js";
|
|
30
|
+
import { Cause as k, Context as we, Deferred as A, Effect as j, Fiber as Te, Layer as M, Queue as N, Schema as P, Stream as F } from "effect";
|
|
31
|
+
import { extractDbCause as Ee, hasEagerLoads as I, runWithWriteAttribution as L } from "@voltro/database";
|
|
32
|
+
import { randomUUID as De } from "node:crypto";
|
|
33
|
+
import { ConnectionInfo as R, MUTATION_IN_FLIGHT_RETRY_AFTER_MS as Oe, MutationConnectionRequired as z, MutationIdempotencyRefused as ke, MutationInFlight as Ae, SubjectService as je, Unauthenticated as Me, beginIdempotent as Ne, currentSubjectAuthority as Pe, defineWebSocket as Fe, failIdempotent as Ie, finishIdempotent as Le, groupShapeDigests as Re, holdIdempotentClaim as ze, prepareIdempotentInput as Be, recheckGuardsEffect as Ve, validateHttpStreamMaxDuration as He, wsMutationIdempotencyScope as Ue } from "@voltro/protocol";
|
|
34
|
+
import { LoggerLayer as We, createLogger as B } from "@voltro/logger";
|
|
35
|
+
import { RpcSerialization as Ge, RpcServer as V } from "effect/rpc";
|
|
36
|
+
import { Server as Ke, createServer as qe } from "node:http";
|
|
37
|
+
import { HttpRouter as H, HttpServer as Je, HttpServerError as Ye, HttpServerRequest as U, HttpServerResponse as W } from "effect/http";
|
|
38
|
+
import { NodeHttpServer as Xe, NodeHttpServerRequest as Ze, NodeServices as Qe } from "@effect/platform-node";
|
|
39
|
+
import { dispatchSharedPath as $e, restCorsHeaders as et, restCorsPreflight as tt, routeAcceptsPath as nt } from "@voltro/protocol/rest";
|
|
40
|
+
import { instanceId as rt, replicaId as it } from "@voltro/protocol/identity";
|
|
41
|
+
// src/rpcServer.ts
|
|
42
|
+
var at = (e) => {
|
|
40
43
|
let t = e.indexOf(".");
|
|
41
44
|
if (t <= 0) return;
|
|
42
45
|
let n = e.slice(0, t), r = e.slice(t + 1);
|
|
@@ -50,137 +53,134 @@ var q = (e) => {
|
|
|
50
53
|
kind: n
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
|
-
},
|
|
54
|
-
let n =
|
|
55
|
-
return n === void 0 ? t() :
|
|
56
|
-
},
|
|
57
|
-
let r =
|
|
56
|
+
}, G = (e, t) => {
|
|
57
|
+
let n = at(e);
|
|
58
|
+
return n === void 0 ? t() : D(n, t);
|
|
59
|
+
}, ot = (e, t, n, r) => e === "subject" ? `${t}:s:${n}` : e === "global" ? `${t}:global` : r.tenantId == null ? void 0 : `${t}:t:${r.tenantId}`, st = We({}), K = (e, t) => j.callback((n) => {
|
|
60
|
+
let r = L(t, () => j.runFork(e.pipe(j.provide(st))));
|
|
58
61
|
return r.addObserver((e) => {
|
|
59
62
|
n(e);
|
|
60
|
-
}),
|
|
61
|
-
}),
|
|
62
|
-
let
|
|
63
|
+
}), j.asVoid(Te.interrupt(r));
|
|
64
|
+
}), ct = (e, t, n, r) => {
|
|
65
|
+
let i = n === void 0 ? void 0 : v(n);
|
|
63
66
|
return {
|
|
64
67
|
subject: e,
|
|
65
|
-
traceId: t?.traceId ??
|
|
68
|
+
traceId: t?.traceId ?? w(),
|
|
69
|
+
...r === void 0 ? {} : { cookieHeader: r },
|
|
66
70
|
...t?.spanId === void 0 ? {} : { spanId: t.spanId },
|
|
67
71
|
...n === void 0 ? {} : { clientId: n },
|
|
68
|
-
...
|
|
69
|
-
...
|
|
72
|
+
...i === void 0 ? {} : { connection: i },
|
|
73
|
+
...i?.remoteAddr === void 0 ? {} : { remoteAddr: i.remoteAddr }
|
|
70
74
|
};
|
|
71
|
-
},
|
|
75
|
+
}, lt = j.currentSpan.pipe(j.catch(() => j.succeed(void 0))), ut = (e) => ({
|
|
72
76
|
traceId: e.traceId,
|
|
73
77
|
...e.spanId === void 0 ? {} : { spanId: e.spanId }
|
|
74
|
-
}),
|
|
78
|
+
}), dt = (e, t, n) => {
|
|
75
79
|
e !== void 0 && (e.attribute("rpc.tag", t), e.attribute("subject.type", n.type), n.tenantId !== void 0 && n.tenantId !== null && e.attribute("tenant.id", n.tenantId));
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
single: (t) =>
|
|
80
|
-
end: () =>
|
|
81
|
-
}),
|
|
82
|
-
let h =
|
|
80
|
+
}, ft = (e) => o(e, (e) => {
|
|
81
|
+
J.error("row filter failed to load — subscription", {}, e instanceof Error ? e : Error(String(e)));
|
|
82
|
+
}), q = (e) => ({
|
|
83
|
+
single: (t) => j.runPromise(N.offer(e, t)),
|
|
84
|
+
end: () => N.endUnsafe(e)
|
|
85
|
+
}), pt = (r, i, a, o, c, l, u, d, f, p) => F.callback((m) => j.gen(function* () {
|
|
86
|
+
let h = f ?? C(), g = i.crdtColumnsFor(r.table), v = x({
|
|
83
87
|
maxBufferedBytes: h.maxBufferedBytes,
|
|
84
88
|
overrunAfterMs: h.overrunAfterMs,
|
|
85
89
|
oversizedEventBytes: h.oversizedEventBytes,
|
|
86
|
-
label:
|
|
90
|
+
label: c,
|
|
87
91
|
...g.size > 0 ? { crdt: {
|
|
88
92
|
columns: g,
|
|
89
93
|
merge: e,
|
|
90
94
|
incremental: t
|
|
91
95
|
} } : {}
|
|
92
96
|
});
|
|
93
|
-
yield*
|
|
94
|
-
let
|
|
95
|
-
label:
|
|
96
|
-
inputKey:
|
|
97
|
+
yield* j.addFinalizer(() => j.sync(() => v.close()));
|
|
98
|
+
let y = s([...n(r)]), b = d !== void 0 && (I(r) || y), ie = p !== void 0 && !b, w = ie ? te(p.input) : "unused", T = ie && w !== "uncanonical" ? {
|
|
99
|
+
label: c,
|
|
100
|
+
inputKey: w,
|
|
97
101
|
subjectId: a.subject.id ?? "anonymous",
|
|
98
102
|
tenantId: a.subject.tenantId ?? ""
|
|
99
103
|
} : void 0;
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
|
|
104
|
+
de(c, p === void 0 ? "not-offered" : b ? y ? "row-filter" : "eager-load" : w !== "uncanonical" || "uncanonical-input");
|
|
105
|
+
let E = { current: (e) => {
|
|
106
|
+
T !== void 0 && re(T, e), v.push(e);
|
|
103
107
|
} };
|
|
104
|
-
if (
|
|
105
|
-
let e =
|
|
108
|
+
if (T !== void 0 && p?.fromRevision !== void 0 && p.reconcile === void 0) {
|
|
109
|
+
let e = u !== void 0 && (yield* j.tryPromise(() => u()).pipe(j.match({
|
|
106
110
|
onFailure: () => !0,
|
|
107
111
|
onSuccess: (e) => !!e
|
|
108
|
-
}))) ? void 0 :
|
|
112
|
+
}))) ? void 0 : ee(T, p.fromRevision);
|
|
109
113
|
if (e !== void 0) {
|
|
110
|
-
for (let t of e.deltas)
|
|
114
|
+
for (let t of e.deltas) v.push({
|
|
111
115
|
_tag: "delta",
|
|
112
116
|
revision: t.revision,
|
|
113
117
|
emittedAt: t.emittedAt,
|
|
114
118
|
patch: t.patch
|
|
115
119
|
});
|
|
116
|
-
e.sink.current =
|
|
120
|
+
e.sink.current = E.current;
|
|
117
121
|
let t = e.unsubscribe;
|
|
118
|
-
if (yield*
|
|
119
|
-
e.sink.current = () => {},
|
|
122
|
+
if (yield* j.addFinalizer(() => j.sync(() => {
|
|
123
|
+
e.sink.current = () => {}, ne(T, {
|
|
120
124
|
sink: e.sink,
|
|
121
125
|
unsubscribe: t
|
|
122
126
|
});
|
|
123
|
-
})), yield*
|
|
124
|
-
let e =
|
|
125
|
-
|
|
127
|
+
})), yield* j.forkScoped(j.promise(() => S(v, q(m), c))), a.clientId !== void 0) {
|
|
128
|
+
let e = _(a.clientId, () => {
|
|
129
|
+
N.endUnsafe(m);
|
|
126
130
|
});
|
|
127
|
-
yield*
|
|
131
|
+
yield* j.addFinalizer(() => j.sync(() => e()));
|
|
128
132
|
}
|
|
129
133
|
return;
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
|
-
let
|
|
133
|
-
|
|
134
|
-
}, a, o,
|
|
135
|
-
onFailure: (e) => (
|
|
136
|
+
let D = yield* j.tryPromise(() => i.subscribe(r, (e) => {
|
|
137
|
+
E.current(e);
|
|
138
|
+
}, a, o, c, p?.reconcile === void 0 ? l : void 0, u, d, p?.reconcile !== void 0)).pipe(j.matchCause({
|
|
139
|
+
onFailure: (e) => (X(`subscription.${c}`, a.traceId, e), {
|
|
136
140
|
ok: !1,
|
|
137
|
-
error:
|
|
141
|
+
error: Tt(e)
|
|
138
142
|
}),
|
|
139
143
|
onSuccess: (e) => ({
|
|
140
144
|
ok: !0,
|
|
141
145
|
unsubscribe: e
|
|
142
146
|
})
|
|
143
147
|
}));
|
|
144
|
-
if (!
|
|
145
|
-
|
|
148
|
+
if (!D.ok) {
|
|
149
|
+
N.offerUnsafe(m, {
|
|
146
150
|
_tag: "error",
|
|
147
|
-
error:
|
|
148
|
-
}),
|
|
151
|
+
error: D.error
|
|
152
|
+
}), N.endUnsafe(m);
|
|
149
153
|
return;
|
|
150
154
|
}
|
|
151
|
-
let
|
|
152
|
-
if (yield*
|
|
153
|
-
|
|
154
|
-
sink:
|
|
155
|
-
unsubscribe:
|
|
155
|
+
let O = D.unsubscribe;
|
|
156
|
+
if (yield* j.addFinalizer(() => j.sync(() => {
|
|
157
|
+
T === void 0 ? O() : (E.current = () => {}, ne(T, {
|
|
158
|
+
sink: E,
|
|
159
|
+
unsubscribe: O
|
|
156
160
|
}));
|
|
157
|
-
})), yield*
|
|
158
|
-
let e =
|
|
159
|
-
|
|
161
|
+
})), yield* j.forkScoped(j.promise(() => S(v, q(m), c))), a.clientId !== void 0) {
|
|
162
|
+
let e = _(a.clientId, () => {
|
|
163
|
+
N.endUnsafe(m);
|
|
160
164
|
});
|
|
161
|
-
yield*
|
|
165
|
+
yield* j.addFinalizer(() => j.sync(() => e()));
|
|
162
166
|
}
|
|
163
|
-
}), { bufferSize: 1 }),
|
|
164
|
-
|
|
165
|
-
}, at = (e) => {
|
|
166
|
-
rt.has(e) || (rt.add(e), ft.warn(`${e}: \`cache:\` is declared but NOT applied — this query's handler returns a computed value, and the snapshot cache only wraps a store read. Every subscriber re-runs the handler. Either return a query descriptor (so the read can be cached), or drop \`cache:\` so the declaration matches what happens.`, { label: e }));
|
|
167
|
-
}, ot = (e, t, n, r, i) => R.callback((a) => P.gen(function* () {
|
|
168
|
-
let o = i ?? b(), s = v({
|
|
167
|
+
}), { bufferSize: 1 }), mt = (e, t, n, r, i) => F.callback((a) => j.gen(function* () {
|
|
168
|
+
let o = i ?? C(), s = x({
|
|
169
169
|
maxBufferedBytes: o.maxBufferedBytes,
|
|
170
170
|
overrunAfterMs: o.overrunAfterMs,
|
|
171
171
|
oversizedEventBytes: o.oversizedEventBytes,
|
|
172
172
|
label: r
|
|
173
173
|
});
|
|
174
|
-
yield*
|
|
175
|
-
let c = yield*
|
|
174
|
+
yield* j.addFinalizer(() => j.sync(() => s.close()));
|
|
175
|
+
let c = yield* j.tryPromise(() => t.subscribeComputed(e, (e) => {
|
|
176
176
|
s.push(e._tag === "snapshot" ? {
|
|
177
177
|
...e,
|
|
178
178
|
computed: !0
|
|
179
179
|
} : e);
|
|
180
|
-
}, n, r)).pipe(
|
|
181
|
-
onFailure: (e) => (
|
|
180
|
+
}, n, r)).pipe(j.matchCause({
|
|
181
|
+
onFailure: (e) => (X(`subscription.${r}`, n.traceId, e), {
|
|
182
182
|
ok: !1,
|
|
183
|
-
error:
|
|
183
|
+
error: Tt(e)
|
|
184
184
|
}),
|
|
185
185
|
onSuccess: (e) => ({
|
|
186
186
|
ok: !0,
|
|
@@ -188,38 +188,38 @@ var q = (e) => {
|
|
|
188
188
|
})
|
|
189
189
|
}));
|
|
190
190
|
if (!c.ok) {
|
|
191
|
-
|
|
191
|
+
N.offerUnsafe(a, {
|
|
192
192
|
_tag: "error",
|
|
193
193
|
error: c.error
|
|
194
|
-
}),
|
|
194
|
+
}), N.endUnsafe(a);
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
let l = c.unsubscribe;
|
|
198
|
-
if (
|
|
199
|
-
let e =
|
|
200
|
-
|
|
198
|
+
if (de(r, "computed"), yield* j.addFinalizer(() => j.sync(() => l())), yield* j.forkScoped(j.promise(() => S(s, q(a), r))), n.clientId !== void 0) {
|
|
199
|
+
let e = _(n.clientId, () => {
|
|
200
|
+
N.endUnsafe(a);
|
|
201
201
|
});
|
|
202
|
-
yield*
|
|
202
|
+
yield* j.addFinalizer(() => j.sync(() => e()));
|
|
203
203
|
}
|
|
204
|
-
}), { bufferSize: 1 }),
|
|
205
|
-
let u = yield*
|
|
206
|
-
let t =
|
|
204
|
+
}), { bufferSize: 1 }), ht = (e, t, n = "rpc.subscription", o, s, c, l) => F.unwrap(j.gen(function* () {
|
|
205
|
+
let u = yield* je, d = yield* R, f = (e) => {
|
|
206
|
+
let t = F.make({
|
|
207
207
|
_tag: "error",
|
|
208
|
-
error: new
|
|
208
|
+
error: new Me({ reason: "The session has expired. Sign in again." })
|
|
209
209
|
});
|
|
210
|
-
return
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
let
|
|
214
|
-
subjectKey:
|
|
210
|
+
return pe(e, d.credentialExpiresAt, t, t);
|
|
211
|
+
}, p = yield* lt;
|
|
212
|
+
dt(p, n, u);
|
|
213
|
+
let m = ct(u, p, d.clientId, d.cookieHeader), h = r(u.id, d.clientId), _ = {
|
|
214
|
+
subjectKey: h,
|
|
215
215
|
...d.reconcile === void 0 ? {} : { forcePrimary: !0 }
|
|
216
|
-
}, v =
|
|
217
|
-
traceId:
|
|
218
|
-
...
|
|
219
|
-
}, () =>
|
|
220
|
-
onFailure: (e) => (
|
|
216
|
+
}, v = i(_, () => E({
|
|
217
|
+
traceId: m.traceId,
|
|
218
|
+
...m.spanId === void 0 ? {} : { spanId: m.spanId }
|
|
219
|
+
}, () => G(n, () => e(m)))), y = j.isEffect(v) ? yield* a(_, v).pipe(j.matchCause({
|
|
220
|
+
onFailure: (e) => (X(`subscription.${n}`, m.traceId, e), {
|
|
221
221
|
ok: !1,
|
|
222
|
-
error:
|
|
222
|
+
error: Tt(e)
|
|
223
223
|
}),
|
|
224
224
|
onSuccess: (e) => ({
|
|
225
225
|
ok: !0,
|
|
@@ -229,43 +229,55 @@ var q = (e) => {
|
|
|
229
229
|
ok: !0,
|
|
230
230
|
value: v
|
|
231
231
|
};
|
|
232
|
-
if (!y.ok) return
|
|
232
|
+
if (!y.ok) return F.make({
|
|
233
233
|
_tag: "error",
|
|
234
234
|
error: y.error
|
|
235
235
|
});
|
|
236
236
|
let b = y.value;
|
|
237
|
-
if (
|
|
237
|
+
if (g(b)) return f(gt(mt(d.reconcile === void 0 ? b : {
|
|
238
238
|
...b,
|
|
239
|
-
recompute: () =>
|
|
240
|
-
}, t,
|
|
241
|
-
let x = b, S =
|
|
242
|
-
return f(
|
|
239
|
+
recompute: () => i(_, b.recompute)
|
|
240
|
+
}, t, m, n), d.reconcile));
|
|
241
|
+
let x = b, S = o?.(x), C = s === void 0 ? void 0 : ot(s.scope, s.baseKey, h, u);
|
|
242
|
+
return f(gt(pt(x, t, m, S, n, s === void 0 || C === void 0 ? void 0 : {
|
|
243
243
|
key: C,
|
|
244
244
|
ttlMs: s.ttlMs,
|
|
245
|
-
swrMs: s.swrMs
|
|
246
|
-
|
|
245
|
+
swrMs: s.swrMs,
|
|
246
|
+
label: n.replace(/^subscription\./, "")
|
|
247
|
+
}, c?.(u), l?.(u) ?? ft(u), void 0, {
|
|
247
248
|
input: x,
|
|
248
249
|
...d.resumeFrom === void 0 ? {} : { fromRevision: d.resumeFrom },
|
|
249
250
|
...d.reconcile === void 0 ? {} : { reconcile: d.reconcile }
|
|
250
251
|
}), d.reconcile));
|
|
251
|
-
}).pipe(
|
|
252
|
+
}).pipe(j.withSpan(n, { attributes: { "framework.kind": "subscription" } }))), gt = (e, t) => t === void 0 ? e : e.pipe(F.mapAccum(() => !1, (e, n) => !e && n._tag === "snapshot" ? [!0, [{
|
|
252
253
|
...n,
|
|
253
254
|
reconciles: t
|
|
254
|
-
}]] : [e, [n]])),
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
255
|
+
}]] : [e, [n]])), _t = (e, t = "rpc.stream", n, r, i) => F.unwrap(j.gen(function* () {
|
|
256
|
+
let a = yield* je, o = yield* R, s = yield* lt;
|
|
257
|
+
dt(s, t, a);
|
|
258
|
+
let c = ct(a, s, o.clientId, o.cookieHeader), l = n ?? [], u = () => Ve(a, l, r), d = j.gen(function* () {
|
|
259
|
+
let n = yield* u();
|
|
260
|
+
if (n) return yield* j.fail(n);
|
|
261
|
+
let r = G(t, () => e(c));
|
|
262
|
+
return j.isEffect(r) ? yield* r : r;
|
|
263
|
+
}), f = yield* (i?.interceptor ? i.interceptor(d, {
|
|
264
|
+
tag: i.tag,
|
|
265
|
+
kind: "stream",
|
|
266
|
+
input: r,
|
|
267
|
+
subject: a,
|
|
268
|
+
traceId: c.traceId,
|
|
269
|
+
...c.spanId === void 0 ? {} : { spanId: c.spanId },
|
|
270
|
+
...c.remoteAddr === void 0 ? {} : { remoteAddr: c.remoteAddr }
|
|
271
|
+
}) : d).pipe(j.catchCause((e) => j.succeed(F.failCause(e)))), p = F.flatMap(f, (e) => F.unwrap(u().pipe(j.map((t) => t ? F.fail(t) : F.make(e))))), m = pe(p, o.credentialExpiresAt, F.empty);
|
|
272
|
+
if (c.clientId === void 0) return m;
|
|
273
|
+
let h = c.clientId;
|
|
274
|
+
return F.unwrap(j.gen(function* () {
|
|
275
|
+
let e = yield* A.make(), t = _(h, () => {
|
|
276
|
+
A.doneUnsafe(e, j.void);
|
|
265
277
|
});
|
|
266
|
-
return yield*
|
|
278
|
+
return yield* j.addFinalizer(() => j.sync(() => t())), m.pipe(F.interruptWhen(A.await(e)));
|
|
267
279
|
}));
|
|
268
|
-
}).pipe(
|
|
280
|
+
}).pipe(j.withSpan(t, { attributes: { "framework.kind": "stream" } }))), J = B({ scope: "voltro:rpc" }), vt = B({ scope: "voltro:http" }), Y = B({ scope: "voltro:shutdown" }), yt = (e) => {
|
|
269
281
|
if (e instanceof Error) {
|
|
270
282
|
let t = e._tag;
|
|
271
283
|
return {
|
|
@@ -283,40 +295,40 @@ var q = (e) => {
|
|
|
283
295
|
};
|
|
284
296
|
}
|
|
285
297
|
return { value: String(e).slice(0, 300) };
|
|
286
|
-
},
|
|
287
|
-
if (
|
|
288
|
-
let r =
|
|
298
|
+
}, X = (e, t, n) => {
|
|
299
|
+
if (k.hasInterruptsOnly(n)) return;
|
|
300
|
+
let r = k.squash(n), i = r?._tag, a = r instanceof Error ? r.message : r?.message ?? String(r), o = k.hasDies(n), s = Ee(r), c = {
|
|
289
301
|
traceId: t,
|
|
290
302
|
...i === void 0 ? {} : { errorTag: i },
|
|
291
303
|
...s
|
|
292
304
|
}, l = a === "Failed to execute statement" && typeof s.dbMessage == "string" ? s.dbMessage : a;
|
|
293
|
-
o ?
|
|
294
|
-
},
|
|
305
|
+
o ? J.error(`${e} failed: ${l}`, c) : J.warn(`${e} failed: ${l}`, c);
|
|
306
|
+
}, bt = /* @__PURE__ */ new Set([
|
|
295
307
|
"SqlError",
|
|
296
308
|
"ResultLengthMismatch",
|
|
297
309
|
"FieldDecryptionError"
|
|
298
|
-
]),
|
|
310
|
+
]), Z = (e) => typeof e == "object" && !!e && typeof e._tag == "string" && bt.has(e._tag), xt = (e, t) => {
|
|
299
311
|
try {
|
|
300
|
-
return
|
|
312
|
+
return P.is(e)(t);
|
|
301
313
|
} catch {
|
|
302
314
|
return !0;
|
|
303
315
|
}
|
|
304
|
-
},
|
|
316
|
+
}, St = /* @__PURE__ */ new Set(), Ct = (e, t) => {
|
|
305
317
|
let n = `${e}\u0000${t}`;
|
|
306
|
-
|
|
318
|
+
St.has(n) || (St.size >= 1e3 && St.clear(), St.add(n), J.warn(`${e} failed with '${t}', which is undeclared on its wire union — the client received InternalError instead. Add ${t} to the descriptor's \`error:\`, register it app-wide through a plugin's \`errorSchemas\`, or map it to a declared error (\`Effect.orDie\` if it is a defect). \`defineExecutor\` reports this at compile time.`, {
|
|
307
319
|
procedure: e,
|
|
308
320
|
errorTag: t
|
|
309
321
|
}));
|
|
310
|
-
},
|
|
322
|
+
}, wt = (e, t = "internal server error") => ({
|
|
311
323
|
_tag: "InternalError",
|
|
312
324
|
message: t,
|
|
313
325
|
traceId: e
|
|
314
|
-
}),
|
|
326
|
+
}), Q = (e) => {
|
|
315
327
|
let t = e instanceof Error ? e.message : e?.message, n = typeof t == "string" && t.length > 0 ? t : String(e), r = e?._tag, i = typeof r == "string" && r.length > 0 && !n.startsWith(r) ? `${r}: ${n}` : n;
|
|
316
328
|
return i.length <= 500 ? i : `${i.slice(0, 500)}…`;
|
|
317
|
-
},
|
|
318
|
-
let t =
|
|
319
|
-
if (t && typeof t == "object" && t._tag === "UnknownError" && (t = t.error ?? t.cause ?? t),
|
|
329
|
+
}, Tt = (e) => {
|
|
330
|
+
let t = k.squash(e);
|
|
331
|
+
if (t && typeof t == "object" && t._tag === "UnknownError" && (t = t.error ?? t.cause ?? t), Z(t)) return {
|
|
320
332
|
_tag: "InternalError",
|
|
321
333
|
message: "internal server error"
|
|
322
334
|
};
|
|
@@ -328,96 +340,152 @@ var q = (e) => {
|
|
|
328
340
|
...typeof i == "string" ? { _tag: i } : {},
|
|
329
341
|
message: typeof a == "string" ? a : String(t)
|
|
330
342
|
};
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
let t = L.encodeUnknownSync(e), n = L.decodeUnknownSync(e);
|
|
343
|
+
}, Et = (e, t, n) => {
|
|
344
|
+
let r = P.encodeUnknownSync(t), i = P.decodeUnknownSync(t);
|
|
334
345
|
return {
|
|
346
|
+
input: e,
|
|
347
|
+
admit: n,
|
|
335
348
|
encode: (e) => {
|
|
336
349
|
try {
|
|
337
|
-
return
|
|
350
|
+
return r(e);
|
|
338
351
|
} catch {
|
|
339
|
-
|
|
352
|
+
throw Error("Mutation output cannot be recorded for replay");
|
|
340
353
|
}
|
|
341
354
|
},
|
|
342
355
|
decode: (e) => {
|
|
343
356
|
try {
|
|
344
|
-
return
|
|
357
|
+
return i(e);
|
|
345
358
|
} catch {
|
|
346
|
-
|
|
359
|
+
throw Error("Stored mutation response is incompatible with the current output contract");
|
|
347
360
|
}
|
|
348
361
|
}
|
|
349
362
|
};
|
|
350
|
-
},
|
|
363
|
+
}, Dt = (e) => {
|
|
351
364
|
let t = {}, n;
|
|
352
365
|
for (let [r, i] of Object.entries(e ?? {})) Array.isArray(i) ? r.toLowerCase() === "set-cookie" ? n = i : t[r] = i.join(", ") : t[r] = i;
|
|
353
366
|
return {
|
|
354
367
|
headers: t,
|
|
355
368
|
setCookie: n
|
|
356
369
|
};
|
|
357
|
-
},
|
|
358
|
-
let l = yield*
|
|
359
|
-
|
|
360
|
-
let
|
|
361
|
-
|
|
362
|
-
|
|
370
|
+
}, Ot = (e, t, n = "rpc.mutation", a, o, s, c = "subject") => j.gen(function* () {
|
|
371
|
+
let l = t, u = yield* je, d = yield* R, f = yield* lt;
|
|
372
|
+
dt(f, n, u);
|
|
373
|
+
let p = ct(u, f, d.clientId, d.cookieHeader), m = async () => {
|
|
374
|
+
if (typeof a?.admit != "function") throw Error("Missing current mutation admission");
|
|
375
|
+
await a.admit(l, p);
|
|
376
|
+
}, h = () => j.tryPromise({
|
|
377
|
+
try: m,
|
|
378
|
+
catch: (e) => e
|
|
379
|
+
}), g = c === "connection";
|
|
380
|
+
if (g && (p.connection?.transport !== "websocket" || p.connection.signal.aborted)) return yield* j.fail(new z({ traceId: p.traceId }));
|
|
381
|
+
let _ = o && d.idempotencyKey ? {
|
|
363
382
|
store: o.store,
|
|
364
383
|
ttlMs: o.ttlMs,
|
|
365
|
-
key:
|
|
366
|
-
scope:
|
|
367
|
-
} : null,
|
|
368
|
-
traceId:
|
|
369
|
-
subjectId:
|
|
384
|
+
key: d.idempotencyKey,
|
|
385
|
+
scope: Ue(u.tenantId, O(u), n, g ? p.connection?.id : void 0)
|
|
386
|
+
} : null, v = r(u.id, d.clientId), y = {
|
|
387
|
+
traceId: p.traceId,
|
|
388
|
+
subjectId: O(u),
|
|
370
389
|
procedure: n
|
|
371
|
-
},
|
|
372
|
-
let
|
|
373
|
-
traceId:
|
|
374
|
-
...
|
|
375
|
-
}, () =>
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
}, b = (t = (e) => e) => j.suspend(() => {
|
|
391
|
+
let r = i({ subjectKey: v }, () => E({
|
|
392
|
+
traceId: p.traceId,
|
|
393
|
+
...p.spanId === void 0 ? {} : { spanId: p.spanId }
|
|
394
|
+
}, () => L(y, () => G(n, () => e(l, {
|
|
395
|
+
...p,
|
|
396
|
+
subject: Pe(u)
|
|
397
|
+
})))));
|
|
398
|
+
return j.isEffect(r) ? t(K(r, y)) : j.tryPromise({
|
|
399
|
+
try: () => Promise.resolve(r),
|
|
378
400
|
catch: (e) => e
|
|
379
401
|
});
|
|
380
|
-
}),
|
|
381
|
-
return yield* (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
402
|
+
}), x = !1, S;
|
|
403
|
+
return yield* (_ ? j.acquireUseRelease(j.tryPromise({
|
|
404
|
+
try: async () => {
|
|
405
|
+
let e;
|
|
406
|
+
try {
|
|
407
|
+
if (!a) throw Error("Missing declared mutation codec");
|
|
408
|
+
let n = await Be(a.input, t, u);
|
|
409
|
+
l = n.input, e = n.fingerprint;
|
|
410
|
+
} catch {
|
|
411
|
+
throw new ke({
|
|
412
|
+
traceId: p.traceId,
|
|
413
|
+
reason: "input-unavailable"
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
await m();
|
|
417
|
+
let n = await Ne(_.store, _.scope, _.key, e, _.ttlMs, Date.now());
|
|
418
|
+
return n.kind === "fresh" && (S = ze(_.store, n.claim)), n;
|
|
419
|
+
},
|
|
420
|
+
catch: (e) => e
|
|
421
|
+
}), (e) => j.gen(function* () {
|
|
422
|
+
if (yield* j.yieldNow, yield* h(), g && p.connection?.signal.aborted) return yield* j.fail(new z({ traceId: p.traceId }));
|
|
423
|
+
if (e.kind === "replay") {
|
|
424
|
+
if (e.response.status !== 200) throw Error("Stored mutation response is unavailable");
|
|
425
|
+
try {
|
|
426
|
+
return a ? a.decode(e.response.body) : e.response.body;
|
|
427
|
+
} catch {
|
|
428
|
+
throw Error("Stored mutation response is incompatible with the current output contract");
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return e.kind === "input-conflict" || e.kind === "input-unbound" ? yield* j.fail(new ke({
|
|
432
|
+
traceId: p.traceId,
|
|
433
|
+
reason: e.kind
|
|
434
|
+
})) : e.kind === "conflict" ? yield* j.fail(new Ae({
|
|
435
|
+
traceId: p.traceId,
|
|
436
|
+
retryAfterMs: Oe
|
|
437
|
+
})) : yield* j.uninterruptibleMask((t) => t(j.void).pipe(j.flatMap(() => b(t)), j.tap((t) => {
|
|
438
|
+
x = !0;
|
|
439
|
+
let n;
|
|
440
|
+
try {
|
|
441
|
+
n = {
|
|
442
|
+
status: 200,
|
|
443
|
+
body: a ? a.encode(t) : t
|
|
444
|
+
};
|
|
445
|
+
} catch {
|
|
446
|
+
n = {
|
|
447
|
+
status: 500,
|
|
448
|
+
body: null
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return j.promise(async () => {
|
|
452
|
+
try {
|
|
453
|
+
if (!await Le(_.store, e.claim, n, Date.now())) throw Error("Original mutation claim is no longer owned");
|
|
454
|
+
} catch {
|
|
455
|
+
throw Error("Mutation replay receipt could not be retained");
|
|
456
|
+
}
|
|
457
|
+
if (n.status !== 200) throw Error("Mutation output cannot be recorded for replay");
|
|
458
|
+
});
|
|
459
|
+
})));
|
|
460
|
+
}), (e) => j.sync(() => S?.()).pipe(j.andThen(e.kind === "fresh" && !x ? j.promise(() => Ie(_.store, e.claim)).pipe(j.ignore) : j.void))) : a ? h().pipe(j.flatMap(() => b())) : b()).pipe(j.tapCause((e) => j.sync(() => X(n, p.traceId, e))), j.catchIf(Z, () => j.die(wt(p.traceId))), j.catchIf((e) => e instanceof Error && typeof e._tag != "string", (e) => j.die(wt(p.traceId, Q(e)))), j.catchIf((e) => s !== void 0 && typeof e?._tag == "string" && !xt(s, e), (e) => j.sync(() => Ct(n, e._tag)).pipe(j.andThen(j.die(wt(p.traceId, Q(e)))))), j.catchDefect((e) => e?._tag === "InternalError" ? j.die(e) : j.die(wt(p.traceId, Q(e)))), j.annotateLogs(ut(p)));
|
|
461
|
+
}).pipe(j.withSpan(n, { attributes: { "framework.kind": "mutation" } })), kt = 8388608, At = (e) => {
|
|
462
|
+
let t = c(e.workloadAdmission), n = l(e.group, t, "http"), r = l(e.group, t, "websocket"), i = e.port ?? 4e3, a = e.host, o = e.path ?? "/ws", s = o, g = e.replicaId ?? it();
|
|
463
|
+
Ce(e.webhookRoutes);
|
|
464
|
+
let _ = e.listener, x = _?.server ?? qe(), S = /* @__PURE__ */ new Set();
|
|
465
|
+
x.on("connection", (e) => {
|
|
466
|
+
S.add(e), e.once("close", () => {
|
|
467
|
+
S.delete(e);
|
|
400
468
|
});
|
|
401
|
-
}),
|
|
402
|
-
let
|
|
403
|
-
if (!e.inspectRoute) return
|
|
469
|
+
}), u(x, d(e));
|
|
470
|
+
let C = (t) => U.HttpServerRequest.pipe(j.flatMap((t) => j.gen(function* () {
|
|
471
|
+
if (!e.inspectRoute) return W.text("inspect route not configured", { status: 404 });
|
|
404
472
|
let n = {};
|
|
405
473
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
406
474
|
let r = e.inspectRoute, i = r.binary?.[new URL(t.url, "http://inspect.invalid").pathname], a;
|
|
407
|
-
!i && t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (a = yield* t.text.pipe(
|
|
408
|
-
let o = yield*
|
|
475
|
+
!i && t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (a = yield* t.text.pipe(j.orElseSucceed(() => "")));
|
|
476
|
+
let o = yield* j.promise(async (e) => {
|
|
409
477
|
if (!i) return r.handle(t.url, n, t.method, a, e);
|
|
410
|
-
let o =
|
|
478
|
+
let o = F.toReadableStream(t.stream);
|
|
411
479
|
return i(t.url, n, t.method, o, e);
|
|
412
480
|
});
|
|
413
|
-
if (o === null) return
|
|
481
|
+
if (o === null) return W.text("inspect route not found", { status: 404 });
|
|
414
482
|
if (o.byteStream !== void 0) {
|
|
415
483
|
let e = {
|
|
416
484
|
...o.headers,
|
|
417
485
|
...o.byteStream.contentLength === void 0 ? {} : { "content-length": String(o.byteStream.contentLength) },
|
|
418
486
|
...o.byteStream.contentDisposition === void 0 ? {} : { "content-disposition": o.byteStream.contentDisposition }
|
|
419
487
|
};
|
|
420
|
-
if (t.method === "HEAD") return
|
|
488
|
+
if (t.method === "HEAD") return W.empty({
|
|
421
489
|
status: o.status,
|
|
422
490
|
headers: {
|
|
423
491
|
...e,
|
|
@@ -425,7 +493,7 @@ var q = (e) => {
|
|
|
425
493
|
}
|
|
426
494
|
});
|
|
427
495
|
let n = o.byteStream.stream;
|
|
428
|
-
return
|
|
496
|
+
return W.stream(F.fromReadableStream({
|
|
429
497
|
evaluate: () => typeof n == "function" ? n() : n,
|
|
430
498
|
onError: (e) => e
|
|
431
499
|
}), {
|
|
@@ -434,25 +502,25 @@ var q = (e) => {
|
|
|
434
502
|
headers: e
|
|
435
503
|
});
|
|
436
504
|
}
|
|
437
|
-
return
|
|
505
|
+
return W.text(o.body, {
|
|
438
506
|
status: o.status,
|
|
439
507
|
contentType: o.contentType,
|
|
440
508
|
headers: o.headers ?? {}
|
|
441
509
|
});
|
|
442
|
-
}))),
|
|
510
|
+
}))), ee = () => U.HttpServerRequest.pipe(j.flatMap((t) => {
|
|
443
511
|
let n = e.inspectStream;
|
|
444
|
-
if (!n) return
|
|
512
|
+
if (!n) return j.succeed(W.text("inspect stream not configured", { status: 404 }));
|
|
445
513
|
let r = {};
|
|
446
514
|
for (let [e, n] of Object.entries(t.headers)) n !== void 0 && (r[e.toLowerCase()] = Array.isArray(n) ? n.join(", ") : n);
|
|
447
515
|
let i = n.corsHeaders(r.origin);
|
|
448
|
-
if (n.isDisabled()) return
|
|
516
|
+
if (n.isDisabled()) return j.succeed(W.text(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }), {
|
|
449
517
|
status: 503,
|
|
450
518
|
contentType: "application/json; charset=utf-8",
|
|
451
519
|
headers: i
|
|
452
520
|
}));
|
|
453
521
|
let a = n.authorize(r);
|
|
454
|
-
return a.ok ? (n.select?.(t.url, r) ??
|
|
455
|
-
if (e?.kind === "stream") return
|
|
522
|
+
return a.ok ? (n.select?.(t.url, r) ?? j.succeed(void 0)).pipe(j.flatMap((e) => {
|
|
523
|
+
if (e?.kind === "stream") return j.succeed(W.stream(e.stream, {
|
|
456
524
|
status: 200,
|
|
457
525
|
headers: {
|
|
458
526
|
...i,
|
|
@@ -461,7 +529,7 @@ var q = (e) => {
|
|
|
461
529
|
"x-accel-buffering": "no"
|
|
462
530
|
}
|
|
463
531
|
}));
|
|
464
|
-
if (e?.kind === "refused") return
|
|
532
|
+
if (e?.kind === "refused") return j.succeed(W.text(JSON.stringify(e.body), {
|
|
465
533
|
status: e.status,
|
|
466
534
|
contentType: "application/json; charset=utf-8",
|
|
467
535
|
headers: i
|
|
@@ -470,18 +538,18 @@ var q = (e) => {
|
|
|
470
538
|
if (!u || e.indexOf("event: ") !== 0) return !0;
|
|
471
539
|
let t = e.indexOf("\n", 7);
|
|
472
540
|
return t < 0 || u.has(e.slice(7, t).trim());
|
|
473
|
-
}, f =
|
|
474
|
-
if (
|
|
541
|
+
}, f = F.callback((e) => j.gen(function* () {
|
|
542
|
+
if (N.offerUnsafe(e, r.encode("retry: 5000\n\n")), !c) for (let t of n.replay()) d(t) && N.offerUnsafe(e, r.encode(t));
|
|
475
543
|
let t = n.subscribe((t) => {
|
|
476
|
-
d(t) &&
|
|
544
|
+
d(t) && N.offerUnsafe(e, r.encode(t));
|
|
477
545
|
}), i = setInterval(() => {
|
|
478
|
-
|
|
546
|
+
N.offerUnsafe(e, r.encode(n.keepAlive()));
|
|
479
547
|
}, a);
|
|
480
|
-
yield*
|
|
548
|
+
yield* j.addFinalizer(() => j.sync(() => {
|
|
481
549
|
clearInterval(i), t();
|
|
482
550
|
}));
|
|
483
551
|
}));
|
|
484
|
-
return
|
|
552
|
+
return j.succeed(W.stream(f, {
|
|
485
553
|
status: 200,
|
|
486
554
|
headers: {
|
|
487
555
|
"content-type": "text/event-stream; charset=utf-8",
|
|
@@ -492,7 +560,7 @@ var q = (e) => {
|
|
|
492
560
|
...i
|
|
493
561
|
}
|
|
494
562
|
}));
|
|
495
|
-
})) :
|
|
563
|
+
})) : j.succeed(W.text(JSON.stringify({
|
|
496
564
|
error: "unauthorized",
|
|
497
565
|
reason: a.reason
|
|
498
566
|
}), {
|
|
@@ -500,17 +568,17 @@ var q = (e) => {
|
|
|
500
568
|
contentType: "application/json; charset=utf-8",
|
|
501
569
|
headers: i
|
|
502
570
|
}));
|
|
503
|
-
})),
|
|
504
|
-
e.inspectRoute !== void 0 && (
|
|
505
|
-
let
|
|
506
|
-
let t = Object.entries(
|
|
507
|
-
for (let r of t) (e ?
|
|
571
|
+
})), te = C(!0), ne = C(!1), re = H.add("*", "/_voltro/inspect/*", U.HttpServerRequest.pipe(j.flatMap((e) => e.url.split("?")[0] === "/_voltro/inspect" ? te : ne))), E = M.empty;
|
|
572
|
+
e.inspectRoute !== void 0 && (E = e.inspectStream === void 0 ? re : M.mergeAll(H.add("GET", "/_voltro/inspect/stream", ee()), re));
|
|
573
|
+
let D = e.publishSurfaceDigest === !0 ? Re(e.group) : void 0, O = e.serviceSurfaceTags ?? /* @__PURE__ */ new Set(), de = (e) => {
|
|
574
|
+
let t = Object.entries(D), n = 0;
|
|
575
|
+
for (let r of t) (e ? O.has(r[0]) : !O.has(r[0])) && (t[n++] = r);
|
|
508
576
|
return t.length = n, Object.fromEntries(t);
|
|
509
|
-
},
|
|
577
|
+
}, pe = D === void 0 ? void 0 : de(!1), A = D === void 0 || O.size === 0 ? void 0 : de(!0), P = j.succeed(W.text(JSON.stringify({
|
|
510
578
|
protocol: 1,
|
|
511
579
|
mutationReplay: e.mutationReplay === !0,
|
|
512
|
-
...
|
|
513
|
-
...
|
|
580
|
+
...pe === void 0 ? {} : { surface: pe },
|
|
581
|
+
...A === void 0 ? {} : { serviceSurface: A }
|
|
514
582
|
}), {
|
|
515
583
|
status: 200,
|
|
516
584
|
contentType: "application/json; charset=utf-8",
|
|
@@ -518,135 +586,140 @@ var q = (e) => {
|
|
|
518
586
|
"cache-control": "no-store",
|
|
519
587
|
"access-control-allow-origin": "*"
|
|
520
588
|
}
|
|
521
|
-
})),
|
|
589
|
+
})), I = "/_voltro/runtime-capabilities", L = `${s.slice(0, s.lastIndexOf("/"))}/_voltro/runtime-capabilities`, R = L === I ? H.add("GET", I, P) : M.mergeAll(H.add("GET", I, P), H.add("GET", L, P)), Oe = M.empty;
|
|
522
590
|
if (e.webhookRoutes !== void 0 && e.webhookRoutes.size > 0) {
|
|
523
|
-
let t = (t) =>
|
|
591
|
+
let t = (t) => U.HttpServerRequest.pipe(j.flatMap((n) => j.gen(function* () {
|
|
524
592
|
let r = {};
|
|
525
593
|
for (let [e, t] of Object.entries(n.headers)) t !== void 0 && (r[e.toLowerCase()] = Array.isArray(t) ? t.join(", ") : t);
|
|
526
|
-
let i = n.url.split("?")[0], a = t.maxBodyBytes ??
|
|
594
|
+
let i = n.url.split("?")[0], a = t.maxBodyBytes ?? ot, o = /* @__PURE__ */ new Uint8Array();
|
|
527
595
|
if (n.method !== "GET" && n.method !== "HEAD") {
|
|
528
596
|
let e = Number(r["content-length"]);
|
|
529
|
-
if (Number.isFinite(e) && e > a) return
|
|
530
|
-
let t = yield*
|
|
531
|
-
if (t._tag === "aborted") return
|
|
532
|
-
if (t._tag === "too-large") return
|
|
597
|
+
if (Number.isFinite(e) && e > a) return W.text("payload too large", { status: 413 });
|
|
598
|
+
let t = yield* ae(n.source, a);
|
|
599
|
+
if (t._tag === "aborted") return W.text("request aborted", { status: 400 });
|
|
600
|
+
if (t._tag === "too-large") return W.text("payload too large", { status: 413 });
|
|
533
601
|
o = new Uint8Array(t.bytes);
|
|
534
602
|
}
|
|
535
|
-
let s =
|
|
603
|
+
let s = ie(r.traceparent), c = yield* j.promise(() => t.handle({
|
|
536
604
|
method: n.method,
|
|
537
605
|
path: i,
|
|
538
606
|
headers: r,
|
|
539
607
|
rawBody: o
|
|
540
|
-
})).pipe(
|
|
608
|
+
})).pipe(j.withSpan(`webhook${i}`, {
|
|
541
609
|
attributes: {
|
|
542
610
|
"framework.kind": "webhook",
|
|
543
611
|
"http.route": i
|
|
544
612
|
},
|
|
545
613
|
...s ? { parent: s } : {}
|
|
546
|
-
})), l = new TextEncoder().encode(c.body), u =
|
|
614
|
+
})), l = new TextEncoder().encode(c.body), u = ce({
|
|
547
615
|
body: l,
|
|
548
616
|
contentType: c.contentType,
|
|
549
617
|
acceptEncoding: r["accept-encoding"],
|
|
550
618
|
options: e.compression
|
|
551
619
|
});
|
|
552
|
-
return u.compressed ?
|
|
620
|
+
return u.compressed ? W.uint8Array(u.bytes, {
|
|
553
621
|
status: c.status,
|
|
554
622
|
contentType: c.contentType,
|
|
555
623
|
headers: u.headers
|
|
556
|
-
}) :
|
|
624
|
+
}) : W.text(c.body, {
|
|
557
625
|
status: c.status,
|
|
558
626
|
contentType: c.contentType
|
|
559
627
|
});
|
|
560
|
-
}))), n = Array.from(e.webhookRoutes.entries()).map(([e, n]) =>
|
|
561
|
-
|
|
628
|
+
}))), n = Array.from(e.webhookRoutes.entries()).map(([e, n]) => H.add("*", e, t(n)));
|
|
629
|
+
Oe = M.mergeAll(...n);
|
|
562
630
|
}
|
|
563
|
-
let
|
|
631
|
+
let z = be(e.security?.trustedProxies, process.env, e.security?.clientAddressHeader), ke = M.empty, Ae = () => void 0;
|
|
564
632
|
if (e.httpRoutes !== void 0 && e.httpRoutes.length > 0) {
|
|
565
|
-
let t = (t) =>
|
|
633
|
+
let t = (t) => U.HttpServerRequest.pipe(j.flatMap((n) => j.gen(function* () {
|
|
566
634
|
let r = {};
|
|
567
635
|
for (let [e, t] of Object.entries(n.headers)) t !== void 0 && (r[e.toLowerCase()] = Array.isArray(t) ? t.join(", ") : t);
|
|
568
636
|
let i = n.url.indexOf("?"), a = i >= 0 ? n.url.slice(0, i) : n.url, o = i >= 0 ? n.url.slice(i + 1) : "";
|
|
569
|
-
if (!t.some((e) =>
|
|
570
|
-
let s = t.reduce((e, t) => Math.max(e, t.maxBodyBytes ??
|
|
571
|
-
if (n.method !== "GET" && n.method !== "HEAD") {
|
|
637
|
+
if (!t.some((e) => nt(e, a))) return W.text("not found", { status: 404 });
|
|
638
|
+
let s = t.reduce((e, t) => Math.max(e, t.maxBodyBytes ?? ot), 0), c = t[0]?.handleStream, l = /* @__PURE__ */ new Uint8Array();
|
|
639
|
+
if (c !== void 0 || n.method !== "GET" && n.method !== "HEAD") {
|
|
572
640
|
let e = Number(r["content-length"]);
|
|
573
|
-
if (Number.isFinite(e) && e > s) return
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
641
|
+
if (Number.isFinite(e) && e > s) return W.text("payload too large", { status: 413 });
|
|
642
|
+
if (c === void 0) {
|
|
643
|
+
let e = yield* ae(n.source, s);
|
|
644
|
+
if (e._tag === "aborted") return W.text("request aborted", { status: 400 });
|
|
645
|
+
if (e._tag === "too-large") return W.text("payload too large", { status: 413 });
|
|
646
|
+
l = new Uint8Array(e.bytes);
|
|
647
|
+
}
|
|
578
648
|
}
|
|
579
|
-
let
|
|
649
|
+
let u = e.getStore?.(), d;
|
|
580
650
|
try {
|
|
581
|
-
|
|
651
|
+
d = n.source?.socket?.remoteAddress;
|
|
582
652
|
} catch {
|
|
583
|
-
|
|
653
|
+
d = void 0;
|
|
584
654
|
}
|
|
585
|
-
let
|
|
586
|
-
socketAddress:
|
|
655
|
+
let f = ve({
|
|
656
|
+
socketAddress: d,
|
|
587
657
|
headers: r,
|
|
588
|
-
config:
|
|
589
|
-
}),
|
|
658
|
+
config: z
|
|
659
|
+
}), p = {
|
|
590
660
|
method: n.method,
|
|
591
661
|
path: a,
|
|
592
662
|
query: o,
|
|
593
663
|
headers: r,
|
|
594
|
-
|
|
595
|
-
...
|
|
596
|
-
|
|
597
|
-
|
|
664
|
+
...u === void 0 ? {} : { store: u },
|
|
665
|
+
...f === void 0 ? {} : { remoteAddr: f }
|
|
666
|
+
}, m = Date.now(), h = yield* j.promise((e) => c === void 0 ? $e(t, {
|
|
667
|
+
...p,
|
|
668
|
+
rawBody: l
|
|
669
|
+
}) : se(n.source, s, p, c, e));
|
|
598
670
|
if (e.onHttpRoute !== void 0) try {
|
|
599
671
|
e.onHttpRoute({
|
|
600
672
|
method: n.method,
|
|
601
673
|
path: a,
|
|
602
|
-
status:
|
|
603
|
-
durationMs: Date.now() -
|
|
604
|
-
traceId:
|
|
674
|
+
status: h.status,
|
|
675
|
+
durationMs: Date.now() - m,
|
|
676
|
+
traceId: T(r.traceparent)?.traceId ?? w()
|
|
605
677
|
});
|
|
606
678
|
} catch {}
|
|
607
|
-
|
|
679
|
+
h.status >= 500 && vt.warn(`${n.method} ${a} → ${h.status}`, {
|
|
608
680
|
method: n.method,
|
|
609
681
|
path: a,
|
|
610
|
-
status:
|
|
611
|
-
...typeof
|
|
612
|
-
...
|
|
682
|
+
status: h.status,
|
|
683
|
+
...typeof h.body == "string" && h.body.length > 0 ? { body: h.body.slice(0, 1e3) } : {},
|
|
684
|
+
...h.cause === void 0 ? {} : { cause: yt(h.cause) }
|
|
613
685
|
});
|
|
614
|
-
let
|
|
615
|
-
status:
|
|
616
|
-
...
|
|
617
|
-
headers:
|
|
686
|
+
let g = Dt(h.headers), _ = g.headers, v = (e) => (g.setCookie !== void 0 && Ze.toServerResponse(n).setHeader("set-cookie", [...g.setCookie]), e), y = {
|
|
687
|
+
status: h.status,
|
|
688
|
+
...h.contentType ? { contentType: h.contentType } : {},
|
|
689
|
+
headers: _
|
|
618
690
|
};
|
|
619
|
-
if (
|
|
620
|
-
let e =
|
|
621
|
-
return
|
|
691
|
+
if (h.byteStream !== void 0) {
|
|
692
|
+
let e = h.byteStream.stream, t = typeof e == "function" ? e() : e;
|
|
693
|
+
return v(W.stream(F.fromReadableStream({
|
|
622
694
|
evaluate: () => t,
|
|
623
695
|
onError: (e) => e
|
|
624
696
|
}), {
|
|
625
|
-
status:
|
|
626
|
-
contentType:
|
|
697
|
+
status: h.status,
|
|
698
|
+
contentType: h.contentType ?? "application/octet-stream",
|
|
627
699
|
headers: {
|
|
628
|
-
...
|
|
629
|
-
...
|
|
630
|
-
...
|
|
700
|
+
..._,
|
|
701
|
+
...h.byteStream.contentLength === void 0 ? {} : { "content-length": String(h.byteStream.contentLength) },
|
|
702
|
+
...h.byteStream.contentDisposition === void 0 ? {} : { "content-disposition": h.byteStream.contentDisposition }
|
|
631
703
|
}
|
|
632
704
|
}));
|
|
633
705
|
}
|
|
634
|
-
if (
|
|
635
|
-
let { subscribe: e, keepAliveMs: t } =
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}),
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
706
|
+
if (h.stream !== void 0) {
|
|
707
|
+
let { subscribe: e, keepAliveMs: t } = h.stream, n = He(h.stream.maxDurationMs), r = new TextEncoder(), i = t ?? 15e3, a = F.callback((t) => j.gen(function* () {
|
|
708
|
+
let n, a, o = !1;
|
|
709
|
+
yield* j.addFinalizer(() => j.sync(() => {
|
|
710
|
+
o = !0, a !== void 0 && clearInterval(a), n?.();
|
|
711
|
+
})), N.offerUnsafe(t, r.encode("retry: 5000\n\n"));
|
|
712
|
+
let s = e((e) => {
|
|
713
|
+
o || N.offerUnsafe(t, r.encode(e));
|
|
714
|
+
});
|
|
715
|
+
o ? s() : n = s, a = !o && i > 0 ? setInterval(() => {
|
|
716
|
+
N.offerUnsafe(t, r.encode(": keep-alive\n\n"));
|
|
717
|
+
}, i) : void 0;
|
|
718
|
+
})), o = n === void 0 ? a : a.pipe(F.interruptWhen(j.sleep(n)));
|
|
719
|
+
return v(W.stream(o, {
|
|
720
|
+
status: h.status,
|
|
648
721
|
headers: {
|
|
649
|
-
...
|
|
722
|
+
..._,
|
|
650
723
|
"content-type": "text/event-stream; charset=utf-8",
|
|
651
724
|
"cache-control": "no-cache, no-transform",
|
|
652
725
|
connection: "keep-alive",
|
|
@@ -654,52 +727,52 @@ var q = (e) => {
|
|
|
654
727
|
}
|
|
655
728
|
}));
|
|
656
729
|
}
|
|
657
|
-
if (n.method === "HEAD") return
|
|
658
|
-
status:
|
|
659
|
-
headers:
|
|
730
|
+
if (n.method === "HEAD") return v(W.empty({
|
|
731
|
+
status: y.status,
|
|
732
|
+
headers: _
|
|
660
733
|
}));
|
|
661
|
-
let
|
|
662
|
-
body:
|
|
663
|
-
contentType:
|
|
734
|
+
let b = h.body instanceof Uint8Array ? h.body : new TextEncoder().encode(h.body ?? ""), x = ce({
|
|
735
|
+
body: b,
|
|
736
|
+
contentType: h.contentType,
|
|
664
737
|
acceptEncoding: r["accept-encoding"],
|
|
665
738
|
options: e.compression
|
|
666
739
|
});
|
|
667
|
-
return
|
|
668
|
-
...
|
|
669
|
-
headers:
|
|
740
|
+
return v(W.uint8Array(x.bytes, {
|
|
741
|
+
...y,
|
|
742
|
+
headers: le(_, x.headers)
|
|
670
743
|
}));
|
|
671
|
-
})),
|
|
672
|
-
|
|
744
|
+
})), j.tapCause((e) => k.hasInterruptsOnly(e) ? j.void : j.sync(() => vt.error(`${t.map((e) => e.method).join("|")} ${t[0].path} threw`, { path: t[0].path }, k.squash(e))))), n = h(e.httpRoutes), r = new Map(n.map((e) => [e, t(e.routes)])), i = m(n);
|
|
745
|
+
Ae = (e) => {
|
|
673
746
|
let t = i(e);
|
|
674
747
|
return t === void 0 ? void 0 : { effect: r.get(t) };
|
|
675
748
|
};
|
|
676
749
|
let a = n.flatMap((e) => {
|
|
677
750
|
let t = r.get(e);
|
|
678
|
-
return e.methods.map((n) =>
|
|
751
|
+
return e.methods.map((n) => H.add(n, `${e.mountPath}/*`, t));
|
|
679
752
|
});
|
|
680
|
-
|
|
753
|
+
ke = M.mergeAll(...a);
|
|
681
754
|
}
|
|
682
|
-
let
|
|
683
|
-
let t =
|
|
684
|
-
return (e) =>
|
|
685
|
-
let r =
|
|
686
|
-
return
|
|
755
|
+
let je = V.layerProtocolWebsocket({ path: o }), Me = (e) => {
|
|
756
|
+
let t = B({ scope: e }), n = /* @__PURE__ */ new Map();
|
|
757
|
+
return (e) => M.flatMap(e, (e) => {
|
|
758
|
+
let r = we.get(e, V.Protocol);
|
|
759
|
+
return M.succeedContext(we.make(V.Protocol, {
|
|
687
760
|
...r,
|
|
688
|
-
run: (e) => r.run((t, r) =>
|
|
761
|
+
run: (e) => r.run((t, r) => j.suspend(() => {
|
|
689
762
|
if (r._tag === "Request") {
|
|
690
763
|
let e = n.get(t);
|
|
691
|
-
e === void 0 && (n.set(t, e = /* @__PURE__ */ new Map()),
|
|
764
|
+
e === void 0 && (n.set(t, e = /* @__PURE__ */ new Map()), v(t)?.signal.addEventListener("abort", () => {
|
|
692
765
|
n.delete(t);
|
|
693
766
|
}, { once: !0 })), e.set(String(r.id), r.tag);
|
|
694
767
|
}
|
|
695
768
|
return e(t, r);
|
|
696
769
|
})),
|
|
697
770
|
end: (e) => (n.delete(e), r.end(e)),
|
|
698
|
-
send: (e, i, a) =>
|
|
771
|
+
send: (e, i, a) => j.suspend(() => {
|
|
699
772
|
let o = n.get(e), s = "requestId" in i ? String(i.requestId) : void 0, c = s === void 0 ? o?.size === 1 ? o.values().next().value : void 0 : o?.get(s);
|
|
700
773
|
i._tag === "Exit" && s !== void 0 && o?.delete(s);
|
|
701
|
-
for (let n of
|
|
702
|
-
let r =
|
|
774
|
+
for (let n of f(i)) {
|
|
775
|
+
let r = Ee(n), i = typeof r.dbMessage == "string" ? r.dbMessage : void 0;
|
|
703
776
|
t.error(i === void 0 ? "rpc defect sent to client" : `rpc defect sent to client: ${i}`, {
|
|
704
777
|
clientId: e,
|
|
705
778
|
defect: n,
|
|
@@ -715,60 +788,60 @@ var q = (e) => {
|
|
|
715
788
|
})
|
|
716
789
|
}));
|
|
717
790
|
});
|
|
718
|
-
},
|
|
791
|
+
}, Ne = { disableFatalDefects: !0 }, Pe = V.layer(r, Ne), Ie = V.layer(n, Ne).pipe(M.provide(Me("voltro:rpc:http")(b(V.layerProtocolHttp({ path: "/rpc" }), "http"))), M.provide(Ge.layerJson), M.provide(e.httpHandlersLayer ?? e.handlersLayer)), Le = Pe.pipe(M.provide(Me("voltro:rpc")(b(je, "websocket"))), M.provide(Ge.layerJson), M.provide(e.handlersLayer)), ze = new Set((e.webSocketGateways ?? []).map((e) => e.path)), Be;
|
|
719
792
|
if (e.webSocketGateways !== void 0 && e.webSocketGateways.length > 0) {
|
|
720
|
-
let t =
|
|
793
|
+
let t = B({ scope: "voltro:gateway" }), n = e.webSocketGateways.map(Fe).map((n) => H.add("GET", n.path, U.HttpServerRequest.pipe(j.flatMap((r) => j.gen(function* () {
|
|
721
794
|
let i = {};
|
|
722
795
|
for (let [e, t] of Object.entries(r.headers)) t !== void 0 && (i[e.toLowerCase()] = Array.isArray(t) ? t.join(", ") : t);
|
|
723
|
-
if (!
|
|
796
|
+
if (!gt(r.method, i)) return W.text("upgrade required", {
|
|
724
797
|
status: 426,
|
|
725
798
|
headers: { upgrade: "websocket" }
|
|
726
799
|
});
|
|
727
800
|
let a = null, o;
|
|
728
801
|
if (n.auth === "subject") {
|
|
729
802
|
let r = e.resolveGatewaySubject;
|
|
730
|
-
if (r === void 0) return t.error("gateway declares auth: subject but the boot passed no resolveGatewaySubject", { path: n.path }),
|
|
731
|
-
let s = yield*
|
|
732
|
-
if (s === null) return
|
|
803
|
+
if (r === void 0) return t.error("gateway declares auth: subject but the boot passed no resolveGatewaySubject", { path: n.path }), W.text("gateway auth unavailable", { status: 500 });
|
|
804
|
+
let s = yield* j.promise(() => r(i).catch(() => null));
|
|
805
|
+
if (s === null) return W.text("unauthorized", { status: 401 });
|
|
733
806
|
a = s.subject, o = s.credentialExpiresAt;
|
|
734
807
|
}
|
|
735
808
|
let s = yield* r.upgrade;
|
|
736
|
-
return yield*
|
|
809
|
+
return yield* ue(s, r.source.socket, n, a, i, o, (e) => t.error("gateway handler failed", { path: n.path }, e)), W.empty({ status: 200 });
|
|
737
810
|
})))));
|
|
738
|
-
|
|
811
|
+
Be = M.mergeAll(...n);
|
|
739
812
|
}
|
|
740
|
-
let
|
|
813
|
+
let Ve = H.make.pipe(j.provideService(H.RouterConfig, {
|
|
741
814
|
caseSensitive: !0,
|
|
742
815
|
ignoreTrailingSlash: !1,
|
|
743
816
|
ignoreDuplicateSlashes: !1
|
|
744
|
-
})),
|
|
817
|
+
})), Ue = M.mergeAll(R, ...t === void 0 || r.requests.size > 0 ? [Le] : [], ...t === void 0 || n.requests.size > 0 ? [Ie] : [], E, Oe, ke, ...Be === void 0 ? [] : [Be]), We = e.pluginHttpInterceptor, Ke = Number(process.env.VOLTRO_MAX_RPC_BODY_BYTES), at = e.maxRpcBodyBytes ?? (Number.isFinite(Ke) && Ke > 0 ? Ke : 8388608), G = Number(process.env.VOLTRO_MAX_BODY_BYTES), ot = e.maxBodyBytes ?? (Number.isFinite(G) && G > 0 ? G : 8388608), K = { "cache-control": "no-store" }, ct = e.httpRoutes?.some((e) => e.cors !== void 0 || e.credentials !== void 0) ? p(h(e.httpRoutes)) : () => void 0, lt = _e({
|
|
745
818
|
...e.security?.originGuard === void 0 ? {} : { mode: e.security.originGuard },
|
|
746
819
|
...e.security?.allowedOrigins === void 0 ? {} : { allowedOrigins: e.security.allowedOrigins }
|
|
747
|
-
}),
|
|
820
|
+
}), ut = ge({
|
|
748
821
|
...e.webhookRoutes === void 0 ? {} : { webhookPaths: e.webhookRoutes.keys() },
|
|
749
822
|
...e.httpRoutes === void 0 ? {} : { httpRoutes: e.httpRoutes }
|
|
750
|
-
}),
|
|
823
|
+
}), dt = xe(e.security?.headers), ft = B({ scope: "voltro:security" }), q = B({ scope: "voltro:rpc" }), pt = (e) => {
|
|
751
824
|
try {
|
|
752
825
|
let t = new URL(e, "http://voltro.invalid").searchParams.get("voltro-socket-id");
|
|
753
826
|
return t !== null && /^[A-Za-z0-9-]{1,80}$/.test(t) ? t : void 0;
|
|
754
827
|
} catch {
|
|
755
828
|
return;
|
|
756
829
|
}
|
|
757
|
-
},
|
|
830
|
+
}, mt = (e) => {
|
|
758
831
|
let t = Object.create(e);
|
|
759
832
|
return Object.defineProperty(t, "upgrade", {
|
|
760
833
|
configurable: !0,
|
|
761
|
-
get: () =>
|
|
762
|
-
let t = yield* e.upgrade, n =
|
|
763
|
-
return
|
|
764
|
-
replicaId:
|
|
765
|
-
instanceId:
|
|
834
|
+
get: () => j.gen(function* () {
|
|
835
|
+
let t = yield* e.upgrade, n = De(), r = pt(e.url), i = Date.now();
|
|
836
|
+
return q.info("rpc websocket opened", {
|
|
837
|
+
replicaId: g,
|
|
838
|
+
instanceId: rt(),
|
|
766
839
|
connectionId: n,
|
|
767
840
|
...r === void 0 ? {} : { clientSocketId: r }
|
|
768
|
-
}), yield*
|
|
769
|
-
|
|
770
|
-
replicaId:
|
|
771
|
-
instanceId:
|
|
841
|
+
}), yield* j.addFinalizer(() => j.sync(() => {
|
|
842
|
+
q.info("rpc websocket closed", {
|
|
843
|
+
replicaId: g,
|
|
844
|
+
instanceId: rt(),
|
|
772
845
|
connectionId: n,
|
|
773
846
|
...r === void 0 ? {} : { clientSocketId: r },
|
|
774
847
|
durationMs: Date.now() - i
|
|
@@ -776,151 +849,151 @@ var q = (e) => {
|
|
|
776
849
|
})), t;
|
|
777
850
|
})
|
|
778
851
|
}), t;
|
|
779
|
-
},
|
|
780
|
-
let n = e.headers, r =
|
|
852
|
+
}, ht = (e, t) => {
|
|
853
|
+
let n = e.headers, r = Se(dt, {
|
|
781
854
|
contentType: n["content-type"],
|
|
782
855
|
https: t
|
|
783
856
|
}), i = {};
|
|
784
857
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (i[e] = t);
|
|
785
|
-
return Object.keys(i).length === 0 ? e :
|
|
786
|
-
},
|
|
787
|
-
let t = yield*
|
|
858
|
+
return Object.keys(i).length === 0 ? e : W.setHeaders(e, i);
|
|
859
|
+
}, gt = (e, t) => e.toUpperCase() === "GET" && (t.upgrade ?? "").toLowerCase().includes("websocket"), _t = (e) => j.gen(function* () {
|
|
860
|
+
let t = yield* U.HttpServerRequest, n = {};
|
|
788
861
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
789
|
-
let r = t.url.indexOf("?"),
|
|
862
|
+
let r = t.url.indexOf("?"), i = r === -1 ? t.url : t.url.slice(0, r), a, o = !1;
|
|
790
863
|
try {
|
|
791
864
|
let e = t.source?.socket;
|
|
792
|
-
|
|
865
|
+
a = e?.remoteAddress, o = e?.encrypted === !0;
|
|
793
866
|
} catch {
|
|
794
|
-
|
|
867
|
+
a = void 0;
|
|
795
868
|
}
|
|
796
|
-
let c =
|
|
797
|
-
socketEncrypted:
|
|
798
|
-
socketAddress:
|
|
869
|
+
let c = ye({
|
|
870
|
+
socketEncrypted: o,
|
|
871
|
+
socketAddress: a,
|
|
799
872
|
xForwardedProto: n["x-forwarded-proto"],
|
|
800
|
-
config:
|
|
801
|
-
}), l =
|
|
802
|
-
socketAddress:
|
|
873
|
+
config: z
|
|
874
|
+
}), l = ve({
|
|
875
|
+
socketAddress: a,
|
|
803
876
|
headers: n,
|
|
804
|
-
config:
|
|
805
|
-
}), u = t.method === "OPTIONS" ? n["access-control-request-method"] ?? t.method : t.method, d = (
|
|
877
|
+
config: z
|
|
878
|
+
}), u = t.method === "OPTIONS" ? n["access-control-request-method"] ?? t.method : t.method, d = (ct(i)?.routes ?? []).filter((e) => nt(e, i)), f = d.find((e) => e.method === u || e.method === "*" || u === "HEAD" && e.method === "GET"), p = f ?? d[0], m = et(p?.cors, n.origin), h = (e) => {
|
|
806
879
|
let t = e.headers.vary, n = p?.cors !== void 0 && t !== void 0 ? {
|
|
807
880
|
...m,
|
|
808
881
|
vary: [...new Set(`${t}, Origin`.split(",").map((e) => e.trim()))].join(", ")
|
|
809
882
|
} : m;
|
|
810
|
-
return
|
|
883
|
+
return ht(W.setHeaders(e, n), c);
|
|
811
884
|
};
|
|
812
885
|
if (t.method === "OPTIONS" && f?.cors !== void 0 && n["access-control-request-method"] !== void 0) {
|
|
813
|
-
let e =
|
|
814
|
-
return h(
|
|
886
|
+
let e = tt(f.cors, f.method, n);
|
|
887
|
+
return h(W.empty({
|
|
815
888
|
status: e.status,
|
|
816
889
|
headers: e.headers
|
|
817
890
|
}));
|
|
818
891
|
}
|
|
819
|
-
if (t.method === "POST" &&
|
|
892
|
+
if (t.method === "POST" && i === "/rpc") {
|
|
820
893
|
let e = n["content-length"];
|
|
821
|
-
if (e !== void 0 && Number(e) >
|
|
894
|
+
if (e !== void 0 && Number(e) > at) return h(W.text("rpc payload too large", {
|
|
822
895
|
status: 413,
|
|
823
|
-
headers:
|
|
896
|
+
headers: K
|
|
824
897
|
}));
|
|
825
898
|
}
|
|
826
|
-
let
|
|
827
|
-
if (
|
|
828
|
-
let e =
|
|
899
|
+
let g = i === "/rpc" && he(t.method), _ = (i === s || ze.has(i)) && gt(t.method, n);
|
|
900
|
+
if (he(t.method) && !ut(i) && f?.credentials !== "bearer" || _) {
|
|
901
|
+
let e = me({
|
|
829
902
|
headers: n,
|
|
830
|
-
config:
|
|
903
|
+
config: lt
|
|
831
904
|
});
|
|
832
|
-
if (!e.allowed) return
|
|
833
|
-
path:
|
|
905
|
+
if (!e.allowed) return ft.warn("refused cross-site request", {
|
|
906
|
+
path: i,
|
|
834
907
|
method: t.method,
|
|
835
908
|
reason: e.reason,
|
|
836
909
|
origin: e.origin,
|
|
837
|
-
surface:
|
|
838
|
-
}), h(
|
|
910
|
+
surface: _ ? "websocket-upgrade" : g ? "rpc" : "http-route"
|
|
911
|
+
}), h(W.text("origin not allowed", {
|
|
839
912
|
status: 403,
|
|
840
|
-
headers:
|
|
913
|
+
headers: K
|
|
841
914
|
}));
|
|
842
915
|
}
|
|
843
|
-
let
|
|
844
|
-
let r = yield*
|
|
845
|
-
return r._tag === "aborted" ? h(
|
|
916
|
+
let v = g ? j.gen(function* () {
|
|
917
|
+
let r = yield* ae(t.source, at);
|
|
918
|
+
return r._tag === "aborted" ? h(W.text("rpc request body incomplete", {
|
|
846
919
|
status: 400,
|
|
847
|
-
headers:
|
|
848
|
-
})) : r._tag === "too-large" ? (
|
|
849
|
-
path:
|
|
850
|
-
cap:
|
|
920
|
+
headers: K
|
|
921
|
+
})) : r._tag === "too-large" ? (ft.warn("refused an over-cap rpc body", {
|
|
922
|
+
path: i,
|
|
923
|
+
cap: at,
|
|
851
924
|
receivedAtLeast: r.received,
|
|
852
925
|
declaredLength: n["content-length"] ?? null
|
|
853
|
-
}), h(
|
|
926
|
+
}), h(W.text("rpc payload too large", {
|
|
854
927
|
status: 413,
|
|
855
|
-
headers:
|
|
856
|
-
}))) : yield*
|
|
857
|
-
}) : e, b =
|
|
858
|
-
if (!
|
|
928
|
+
headers: K
|
|
929
|
+
}))) : yield* j.provideService(e, U.HttpServerRequest, oe(y(t, l), r.bytes));
|
|
930
|
+
}) : e, b = _ && i === s ? mt(y(t, l)) : t, x = b === t ? v : j.provideService(v, U.HttpServerRequest, b);
|
|
931
|
+
if (!We) {
|
|
859
932
|
let e = yield* x;
|
|
860
|
-
return
|
|
933
|
+
return W.isHttpServerResponse(e) ? h(e) : e;
|
|
861
934
|
}
|
|
862
|
-
let S = yield*
|
|
935
|
+
let S = yield* j.tryPromise(() => We(async () => null, {
|
|
863
936
|
method: t.method,
|
|
864
|
-
path:
|
|
937
|
+
path: i,
|
|
865
938
|
headers: n,
|
|
866
939
|
remoteAddr: l
|
|
867
|
-
})).pipe(
|
|
940
|
+
})).pipe(j.catch((e) => j.sync(() => (vt.error("http interceptor threw — request REFUSED (fail-closed)", {
|
|
868
941
|
method: t.method,
|
|
869
|
-
path:
|
|
942
|
+
path: i
|
|
870
943
|
}, e), {
|
|
871
944
|
status: 500,
|
|
872
945
|
body: "internal error",
|
|
873
946
|
headers: void 0
|
|
874
947
|
}))));
|
|
875
|
-
if (S !== null) return h(
|
|
948
|
+
if (S !== null) return h(W.text(S.body ?? "", {
|
|
876
949
|
status: S.status,
|
|
877
950
|
...S.headers ? { headers: S.headers } : {}
|
|
878
951
|
}));
|
|
879
952
|
let C = yield* x;
|
|
880
|
-
return
|
|
881
|
-
}),
|
|
882
|
-
if (
|
|
953
|
+
return W.isHttpServerResponse(C) ? h(C) : C;
|
|
954
|
+
}), J = _ === void 0 ? void 0 : new jt(x);
|
|
955
|
+
if (_ !== void 0 && J !== void 0) {
|
|
883
956
|
let e = new Promise((e) => {
|
|
884
957
|
let t = (n) => {
|
|
885
|
-
n === "request" && (
|
|
958
|
+
n === "request" && (J.removeListener("newListener", t), e());
|
|
886
959
|
};
|
|
887
|
-
|
|
960
|
+
J.on("newListener", t);
|
|
888
961
|
});
|
|
889
|
-
|
|
890
|
-
|
|
962
|
+
Mt.set(x, e), e.then(() => {
|
|
963
|
+
_.delegate({
|
|
891
964
|
request: (e, t) => {
|
|
892
|
-
|
|
965
|
+
J.emit("request", e, t);
|
|
893
966
|
},
|
|
894
967
|
upgrade: (e, t, n) => {
|
|
895
|
-
|
|
968
|
+
J.emit("upgrade", e, t, n);
|
|
896
969
|
}
|
|
897
970
|
});
|
|
898
971
|
});
|
|
899
972
|
}
|
|
900
|
-
let
|
|
901
|
-
let e = yield*
|
|
902
|
-
return yield*
|
|
903
|
-
}).pipe(
|
|
904
|
-
let t =
|
|
905
|
-
return t === void 0 ?
|
|
906
|
-
}))))))).pipe(
|
|
907
|
-
port:
|
|
908
|
-
host:
|
|
909
|
-
})),
|
|
910
|
-
e.tracerLayer && (
|
|
911
|
-
let
|
|
912
|
-
|
|
913
|
-
}))),
|
|
914
|
-
return
|
|
915
|
-
server:
|
|
973
|
+
let Y = M.unwrap(j.gen(function* () {
|
|
974
|
+
let e = yield* Ve;
|
|
975
|
+
return yield* M.build(M.provide(Ue, M.succeed(H.HttpRouter, e))), e.asHttpEffect();
|
|
976
|
+
}).pipe(j.map((e) => Je.serve(_t(e.pipe(j.catchIf((e) => Ye.isHttpServerError(e) && e.reason._tag === "RouteNotFound", (e) => {
|
|
977
|
+
let t = Ae(e.request.url.split("?")[0]);
|
|
978
|
+
return t === void 0 ? j.fail(e) : t.effect;
|
|
979
|
+
}))))))).pipe(M.provide(Xe.layer(() => J ?? x, a === void 0 ? { port: i } : {
|
|
980
|
+
port: i,
|
|
981
|
+
host: a
|
|
982
|
+
})), M.provide(Qe.layer), M.provide(st));
|
|
983
|
+
e.tracerLayer && (Y = Y.pipe(M.provide(fe), M.provide(e.tracerLayer)));
|
|
984
|
+
let X = B({ scope: "voltro:rpc" }), bt = M.launch(Y).pipe(j.catchCause((e) => j.sync(() => {
|
|
985
|
+
X.error("rpc server crashed", {}, k.squash(e)), process.exit(1);
|
|
986
|
+
}))), Z = j.runFork(bt);
|
|
987
|
+
return $.add(Z), Vt(), {
|
|
988
|
+
server: x,
|
|
916
989
|
shutdown: async () => {
|
|
917
|
-
|
|
918
|
-
let e =
|
|
919
|
-
for (let e of
|
|
920
|
-
|
|
990
|
+
$.delete(Z);
|
|
991
|
+
let e = j.runPromise(Te.interrupt(Z)).then(() => void 0, () => void 0);
|
|
992
|
+
for (let e of S) e.destroy();
|
|
993
|
+
x.closeIdleConnections(), await e, _ !== void 0 && await _.close();
|
|
921
994
|
}
|
|
922
995
|
};
|
|
923
|
-
},
|
|
996
|
+
}, jt = class extends Ke {
|
|
924
997
|
bound;
|
|
925
998
|
constructor(e) {
|
|
926
999
|
super(), this.bound = e;
|
|
@@ -932,40 +1005,40 @@ var q = (e) => {
|
|
|
932
1005
|
address() {
|
|
933
1006
|
return this.bound.address();
|
|
934
1007
|
}
|
|
935
|
-
},
|
|
936
|
-
|
|
937
|
-
}),
|
|
1008
|
+
}, Mt = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new Set(), Nt = /* @__PURE__ */ new Set(), Pt = !1, Ft = (e) => (Nt.add(e), () => {
|
|
1009
|
+
Nt.delete(e);
|
|
1010
|
+
}), It = 1e4, Lt = 1e3, Rt = 3e5, zt = () => {
|
|
938
1011
|
let e = process.env.VOLTRO_SHUTDOWN_GRACE_MS;
|
|
939
|
-
if (e === void 0 || e === "") return
|
|
1012
|
+
if (e === void 0 || e === "") return It;
|
|
940
1013
|
let t = Number(e);
|
|
941
|
-
return !Number.isFinite(t) || t <= 0 ?
|
|
942
|
-
},
|
|
1014
|
+
return !Number.isFinite(t) || t <= 0 ? It : Math.min(Rt, Math.max(Lt, Math.trunc(t)));
|
|
1015
|
+
}, Bt = (e) => {
|
|
943
1016
|
let t = Date.now(), n = !1, r = (r) => () => {
|
|
944
1017
|
n || (n = !0, clearTimeout(i), e.onOutcome?.({
|
|
945
1018
|
reason: r,
|
|
946
1019
|
ms: Date.now() - t
|
|
947
1020
|
}), e.exit());
|
|
948
1021
|
}, i = setTimeout(r("deadline"), e.deadlineMs);
|
|
949
|
-
i.unref?.(), Promise.all(e.hooks.map((e) => Promise.resolve().then(e).then(() => void 0, () => void 0))).then(() => Promise.all(e.fibers.map((e) =>
|
|
950
|
-
},
|
|
951
|
-
if (
|
|
952
|
-
|
|
1022
|
+
i.unref?.(), Promise.all(e.hooks.map((e) => Promise.resolve().then(e).then(() => void 0, () => void 0))).then(() => Promise.all(e.fibers.map((e) => j.runPromise(Te.interrupt(e)).then(() => void 0, () => void 0)))).then(r("drained"), r("drained"));
|
|
1023
|
+
}, Vt = () => {
|
|
1024
|
+
if (Pt) return;
|
|
1025
|
+
Pt = !0;
|
|
953
1026
|
let e = () => {
|
|
954
|
-
let e = [
|
|
955
|
-
|
|
1027
|
+
let e = [...$], t = [...Nt];
|
|
1028
|
+
$.clear(), Nt.clear(), Bt({
|
|
956
1029
|
fibers: e,
|
|
957
1030
|
hooks: t,
|
|
958
|
-
deadlineMs:
|
|
1031
|
+
deadlineMs: zt(),
|
|
959
1032
|
exit: () => process.exit(0),
|
|
960
1033
|
onOutcome: ({ reason: e, ms: t }) => {
|
|
961
|
-
e === "drained" ?
|
|
1034
|
+
e === "drained" ? Y.info(`drained in ${t}ms`) : Y.error(`drain deadline exceeded — cut at ${t}ms`, { hint: "a shutdown hook or a pool drain did not complete; whatever had not finished did not happen" });
|
|
962
1035
|
}
|
|
963
1036
|
});
|
|
964
1037
|
};
|
|
965
1038
|
process.once("SIGINT", e), process.once("SIGTERM", e);
|
|
966
|
-
},
|
|
1039
|
+
}, Ht = (e, t = 1e4) => new Promise((n, r) => {
|
|
967
1040
|
if (e.listening) {
|
|
968
|
-
let i =
|
|
1041
|
+
let i = Mt.get(e);
|
|
969
1042
|
if (i === void 0) {
|
|
970
1043
|
n();
|
|
971
1044
|
return;
|
|
@@ -988,5 +1061,4 @@ var q = (e) => {
|
|
|
988
1061
|
}
|
|
989
1062
|
a = setTimeout(() => o(/* @__PURE__ */ Error(`rpc server did not bind within ${t}ms`)), t), e.on("listening", s), e.on("error", c);
|
|
990
1063
|
});
|
|
991
|
-
|
|
992
|
-
export { wt as DEFAULT_MAX_RPC_BODY_BYTES, Rt as awaitServerListening, ot as bindComputedUntyped, Ct as bindMutation, ct as bindStream, st as bindSubscription, nt as bindSubscriptionUntyped, yt as defectMessage, It as drainForShutdown, ht as isInfraError, xt as makeMutationOutputCodec, jt as onProcessShutdown, it as resetComputedQueryCacheWarnings, Ft as shutdownGraceMsFromEnv, Tt as startRpcServer };
|
|
1064
|
+
export { kt as DEFAULT_MAX_RPC_BODY_BYTES, Ht as awaitServerListening, mt as bindComputedUntyped, Ot as bindMutation, _t as bindStream, ht as bindSubscription, pt as bindSubscriptionUntyped, Q as defectMessage, Bt as drainForShutdown, Z as isInfraError, Et as makeMutationCodec, Ft as onProcessShutdown, zt as shutdownGraceMsFromEnv, At as startRpcServer };
|