@substrat-run/adapter-sqlite 0.240.0 → 0.242.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/dist/delivery-broker.d.ts +28 -0
- package/dist/delivery-broker.d.ts.map +1 -1
- package/dist/delivery-broker.js +76 -4
- package/dist/delivery-broker.js.map +1 -1
- package/dist/dev-connector-network.d.ts +43 -1
- package/dist/dev-connector-network.d.ts.map +1 -1
- package/dist/dev-connector-network.js +67 -8
- package/dist/dev-connector-network.js.map +1 -1
- package/dist/index.d.ts +20 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -15
- package/dist/index.js.map +1 -1
- package/dist/local-relay-mesh.d.ts +50 -0
- package/dist/local-relay-mesh.d.ts.map +1 -0
- package/dist/local-relay-mesh.js +52 -0
- package/dist/local-relay-mesh.js.map +1 -0
- package/dist/local-relay-router.d.ts +55 -0
- package/dist/local-relay-router.d.ts.map +1 -0
- package/dist/local-relay-router.js +101 -0
- package/dist/local-relay-router.js.map +1 -0
- package/dist/relay-edges.d.ts +53 -0
- package/dist/relay-edges.d.ts.map +1 -0
- package/dist/relay-edges.js +74 -0
- package/dist/relay-edges.js.map +1 -0
- package/dist/vertical-broker.d.ts +10 -0
- package/dist/vertical-broker.d.ts.map +1 -1
- package/dist/vertical-broker.js +24 -15
- package/dist/vertical-broker.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DeliveryComparison, type HandOffOptions, type WitnessReader, type BrokerStateReport, type BrokerTelemetrySink, type BrokerCountDay, type BrokerLakeSink, type BrokerErasure, type BrokerErasureTarget, type BrokerMessage, type BrokerRelayOptions, type BrokerTiming, type BrokerQueue, type DeadLetter, type DeliveryBroker, type DeliveryPass, type DeliveryPolicyInput, type DeliveryReceiver, type HandOffAnswer, type HandoffMarks, type RelayHop, type RelayReply, type RelayRequest, type WaitRecord } from '@substrat-run/kernel';
|
|
2
2
|
import { type RelayAnswer, type RelayEnvelope } from '@substrat-run/contracts';
|
|
3
|
+
import { type RelayEdge } from './relay-edges.js';
|
|
3
4
|
export interface InProcessDeliveryBrokerOptions {
|
|
4
5
|
/** The database file; omitted, an in-memory database (lost with the process). */
|
|
5
6
|
file?: string;
|
|
@@ -26,9 +27,15 @@ export interface InProcessDeliveryBrokerOptions {
|
|
|
26
27
|
* Broker to broker and request-reply (#3469): the router and the scope ends this broker relays
|
|
27
28
|
* through, and the relay subscription's policy. Omitted, it relays nothing and answers another
|
|
28
29
|
* app's broker `no-broker`.
|
|
30
|
+
*
|
|
31
|
+
* `edges` (K-74): subscribing apps whose own receiver policy applies, each (app, type) its own
|
|
32
|
+
* subscription (`relayEdgeSubscription`) under the `delivery` it declares, over the platform's.
|
|
33
|
+
* Fixed for the broker's life, so only on an in-memory broker (no `file`); an app no edge names
|
|
34
|
+
* goes by the relay, under `policy`.
|
|
29
35
|
*/
|
|
30
36
|
relay?: Omit<BrokerRelayOptions, 'now'> & {
|
|
31
37
|
policy?: DeliveryPolicyInput;
|
|
38
|
+
edges?: readonly RelayEdge[];
|
|
32
39
|
};
|
|
33
40
|
/** A5: record every message owed under `SHADOW_RECEIVER`, and answer `deliveryComparison`. */
|
|
34
41
|
shadow?: boolean;
|
|
@@ -68,6 +75,10 @@ export interface InProcessSubscription {
|
|
|
68
75
|
name: string;
|
|
69
76
|
receiver: DeliveryReceiver;
|
|
70
77
|
policy?: DeliveryPolicyInput;
|
|
78
|
+
/** Only events of these types are owed to it (`BrokerSubscriptionSpec.eventTypes`); a relay edge's one type. */
|
|
79
|
+
eventTypes?: readonly string[];
|
|
80
|
+
/** Its ordered lanes are per (tenant, key) (`BrokerSubscriptionSpec.tenantLanes`); a relay edge's. */
|
|
81
|
+
tenantLanes?: boolean;
|
|
71
82
|
}
|
|
72
83
|
export declare class InProcessDeliveryBroker implements DeliveryBroker {
|
|
73
84
|
private readonly db;
|
|
@@ -80,6 +91,9 @@ export declare class InProcessDeliveryBroker implements DeliveryBroker {
|
|
|
80
91
|
private readonly recorder;
|
|
81
92
|
private readonly options;
|
|
82
93
|
private readonly lake;
|
|
94
|
+
/** The relay's edges and the router that answers who subscribes, unfiltered (`relay-edges.ts`). */
|
|
95
|
+
private readonly edges;
|
|
96
|
+
private readonly edgeRouter;
|
|
83
97
|
constructor(options?: InProcessDeliveryBrokerOptions);
|
|
84
98
|
handOff(messages: readonly BrokerMessage[], options?: HandOffOptions): Promise<HandOffAnswer>;
|
|
85
99
|
/** A5: the shadow comparison. Null when it records nothing or reads no witness. #3684: `scopeId` and `since` narrow it. */
|
|
@@ -103,6 +117,20 @@ export declare class InProcessDeliveryBroker implements DeliveryBroker {
|
|
|
103
117
|
*/
|
|
104
118
|
deliverDue(): Promise<DeliveryPass>;
|
|
105
119
|
private pass;
|
|
120
|
+
/**
|
|
121
|
+
* K-74: before the prune, ask once per (edge, tenant) whether the edge's app subscribes in that
|
|
122
|
+
* tenant, as its receiver would when the delivery reached it — because the prune comes first, and an
|
|
123
|
+
* event of a tenant the app does not subscribe in could otherwise reach its time to live and stop its
|
|
124
|
+
* lane as a dead letter. Not subscribing: what the edge is owed there settles (owed nothing). Read
|
|
125
|
+
* failed: the (edge, tenant) group is held — nothing in it is sent, expires or wakes the broker —
|
|
126
|
+
* and asked again at the group's one retry time, after the edge's own backoff. Subscribing: the hold,
|
|
127
|
+
* if any, ends, and the prune and the receiver judge each delivery as before. A held group is not
|
|
128
|
+
* asked again before its retry time, whatever else the pass carries.
|
|
129
|
+
*
|
|
130
|
+
* Eligibility only. Whether the producer scope exports the event (`exportOne`) is still the
|
|
131
|
+
* receiver's, per message: an unexported one is settled when it reaches its lane's head.
|
|
132
|
+
*/
|
|
133
|
+
private judgeEdgeEligibility;
|
|
106
134
|
private relayOrThrow;
|
|
107
135
|
/** What another app's broker relayed here, as the router hands it. A broker with no relay has none. */
|
|
108
136
|
acceptRelayed(envelope: RelayEnvelope): Promise<RelayAnswer>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-broker.d.ts","sourceRoot":"","sources":["../src/delivery-broker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delivery-broker.d.ts","sourceRoot":"","sources":["../src/delivery-broker.ts"],"names":[],"mappings":"AAkCA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAGxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC9F,OAAO,EAAqG,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAErJ,MAAM,WAAW,8BAA8B;IAC7C,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0HAA0H;IAC1H,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,gFAAgF;IAChF,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,uFAAuF;IACvF,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACjD,mDAAmD;IACnD,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,+F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gHAAgH;IAChH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExC;IAED,uHAAuH;IACvH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;IAED,8GAA8G;IAC9G,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAInD;IAED,+FAA+F;IAC/F,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAIpD;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
package/dist/delivery-broker.js
CHANGED
|
@@ -27,11 +27,14 @@
|
|
|
27
27
|
* Given a `relay` (#3469), it also hands events to other apps' brokers and takes theirs
|
|
28
28
|
* (`acceptRelayed`), sends requests and pairs their replies: the kernel's `BrokerRelay`, in the same
|
|
29
29
|
* database, registered as the subscription `RELAY_SUBSCRIPTION`. `deliverDue()` then runs the relay's
|
|
30
|
-
* own pass after the delivery pass.
|
|
30
|
+
* own pass after the delivery pass. Given `relay.edges` (K-74's receiver's half), each subscribing
|
|
31
|
+
* app and type an edge names is its own subscription under the policy that app declares, and the
|
|
32
|
+
* relay carries only the apps no edge covers (`relay-edges.ts`, with its stated limits).
|
|
31
33
|
*/
|
|
32
34
|
import Database from 'better-sqlite3';
|
|
33
35
|
import { BrokerRelay, BrokerStore, compareDeliveries, LAKE_RECEIVER, LIVE_RECEIVER, SHADOW_RECEIVER, ShadowRecorder, BrokerTelemetry, RELAY_SUBSCRIPTION, runDeliveryPass, } from '@substrat-run/kernel';
|
|
34
36
|
import { relayEnvelope } from '@substrat-run/contracts';
|
|
37
|
+
import { assertDistinctEdges, assertEdgesInMemory, relayEdgeReceiver, relayEdgeSubscription, routerWithout } from './relay-edges.js';
|
|
35
38
|
export class InProcessDeliveryBroker {
|
|
36
39
|
db;
|
|
37
40
|
store;
|
|
@@ -43,8 +46,13 @@ export class InProcessDeliveryBroker {
|
|
|
43
46
|
recorder;
|
|
44
47
|
options;
|
|
45
48
|
lake;
|
|
49
|
+
/** The relay's edges and the router that answers who subscribes, unfiltered (`relay-edges.ts`). */
|
|
50
|
+
edges;
|
|
51
|
+
edgeRouter;
|
|
46
52
|
constructor(options = {}) {
|
|
47
53
|
this.options = options;
|
|
54
|
+
// Checked before the file is opened, so a refused broker creates nothing.
|
|
55
|
+
assertEdgesInMemory(options.file, options.relay?.edges);
|
|
48
56
|
this.db = new Database(options.file ?? ':memory:');
|
|
49
57
|
this.now = options.now ?? Date.now;
|
|
50
58
|
const sql = {
|
|
@@ -52,9 +60,23 @@ export class InProcessDeliveryBroker {
|
|
|
52
60
|
all: (q, ...params) => this.db.prepare(q).all(...params),
|
|
53
61
|
transaction: (fn) => this.db.transaction(fn)(),
|
|
54
62
|
};
|
|
55
|
-
const { policy: relayPolicy, ...relay } = options.relay ?? {};
|
|
63
|
+
const { policy: relayPolicy, edges = [], ...relay } = options.relay ?? {};
|
|
56
64
|
try {
|
|
57
|
-
|
|
65
|
+
assertDistinctEdges(edges);
|
|
66
|
+
const seams = relay;
|
|
67
|
+
this.relay = options.relay ? new BrokerRelay(sql, { ...seams, router: routerWithout(seams.router, edges), now: this.now }) : null;
|
|
68
|
+
const edgeSubscriptions = this.relay
|
|
69
|
+
? edges.map((e) => ({
|
|
70
|
+
name: relayEdgeSubscription(e),
|
|
71
|
+
receiver: relayEdgeReceiver(e, seams, sql),
|
|
72
|
+
// Owed only its own type's events: another message can hold none of its lanes.
|
|
73
|
+
eventTypes: [e.type],
|
|
74
|
+
// A key is ordered within its tenant, as on a hosted broker (one per tenant): one tenant's
|
|
75
|
+
// head never holds another's.
|
|
76
|
+
tenantLanes: true,
|
|
77
|
+
...(e.delivery ? { policy: e.delivery } : {}),
|
|
78
|
+
}))
|
|
79
|
+
: [];
|
|
58
80
|
this.windows = new ShadowRecorder(sql);
|
|
59
81
|
this.recorder = options.shadow ? this.windows : null;
|
|
60
82
|
const subscriptions = [
|
|
@@ -66,10 +88,16 @@ export class InProcessDeliveryBroker {
|
|
|
66
88
|
...(options.receiver ? [{ name: 'default', receiver: options.receiver, ...(options.policy ? { policy: options.policy } : {}) }] : []),
|
|
67
89
|
...(options.subscriptions ?? []),
|
|
68
90
|
...(this.relay ? [{ name: RELAY_SUBSCRIPTION, receiver: this.relay.receiver(), ...(relayPolicy ? { policy: relayPolicy } : {}) }] : []),
|
|
91
|
+
...edgeSubscriptions,
|
|
69
92
|
];
|
|
70
93
|
this.receivers = Object.fromEntries(subscriptions.map((s) => [s.name, s.receiver]));
|
|
71
94
|
this.store = new BrokerStore(sql, {
|
|
72
|
-
subscriptions: subscriptions.map((s) => ({
|
|
95
|
+
subscriptions: subscriptions.map((s) => ({
|
|
96
|
+
name: s.name,
|
|
97
|
+
...(s.policy ? { policy: s.policy } : {}),
|
|
98
|
+
...(s.eventTypes ? { eventTypes: s.eventTypes } : {}),
|
|
99
|
+
...(s.tenantLanes ? { tenantLanes: true } : {}),
|
|
100
|
+
})),
|
|
73
101
|
...(options.timing ? { timing: options.timing } : {}),
|
|
74
102
|
...(options.random ? { random: options.random } : {}),
|
|
75
103
|
now: this.now,
|
|
@@ -80,6 +108,8 @@ export class InProcessDeliveryBroker {
|
|
|
80
108
|
this.db.close();
|
|
81
109
|
throw err;
|
|
82
110
|
}
|
|
111
|
+
this.edges = this.relay ? edges : [];
|
|
112
|
+
this.edgeRouter = this.relay ? relay.router : null;
|
|
83
113
|
this.lake = options.lake ?? null;
|
|
84
114
|
const t = options.telemetry;
|
|
85
115
|
this.telemetry = t
|
|
@@ -143,6 +173,7 @@ export class InProcessDeliveryBroker {
|
|
|
143
173
|
}
|
|
144
174
|
}
|
|
145
175
|
async pass() {
|
|
176
|
+
await this.judgeEdgeEligibility();
|
|
146
177
|
const pass = await runDeliveryPass(this.store, this.receivers, this.now, undefined, this.telemetry?.passObserver());
|
|
147
178
|
const relayed = this.relay ? await this.relay.pass() : null;
|
|
148
179
|
this.recorder?.prune(this.now());
|
|
@@ -158,6 +189,47 @@ export class InProcessDeliveryBroker {
|
|
|
158
189
|
const at = [this.store.nextWakeAt(), relayed.nextAt].filter((t) => t !== null);
|
|
159
190
|
return { ...pass, nextAt: at.length ? Math.min(...at) : null };
|
|
160
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* K-74: before the prune, ask once per (edge, tenant) whether the edge's app subscribes in that
|
|
194
|
+
* tenant, as its receiver would when the delivery reached it — because the prune comes first, and an
|
|
195
|
+
* event of a tenant the app does not subscribe in could otherwise reach its time to live and stop its
|
|
196
|
+
* lane as a dead letter. Not subscribing: what the edge is owed there settles (owed nothing). Read
|
|
197
|
+
* failed: the (edge, tenant) group is held — nothing in it is sent, expires or wakes the broker —
|
|
198
|
+
* and asked again at the group's one retry time, after the edge's own backoff. Subscribing: the hold,
|
|
199
|
+
* if any, ends, and the prune and the receiver judge each delivery as before. A held group is not
|
|
200
|
+
* asked again before its retry time, whatever else the pass carries.
|
|
201
|
+
*
|
|
202
|
+
* Eligibility only. Whether the producer scope exports the event (`exportOne`) is still the
|
|
203
|
+
* receiver's, per message: an unexported one is settled when it reaches its lane's head.
|
|
204
|
+
*/
|
|
205
|
+
async judgeEdgeEligibility() {
|
|
206
|
+
if (!this.edgeRouter || this.edges.length === 0)
|
|
207
|
+
return;
|
|
208
|
+
const now = this.now();
|
|
209
|
+
const answers = new Map();
|
|
210
|
+
for (const edge of this.edges) {
|
|
211
|
+
const receiver = relayEdgeSubscription(edge);
|
|
212
|
+
for (const tenantId of this.store.eligibilityTenants(receiver)) {
|
|
213
|
+
const hold = this.store.eligibilityHold(receiver, tenantId);
|
|
214
|
+
if (hold && hold.retryAt > now)
|
|
215
|
+
continue;
|
|
216
|
+
const asked = JSON.stringify([tenantId, edge.type]);
|
|
217
|
+
if (!answers.has(asked))
|
|
218
|
+
answers.set(asked, this.edgeRouter.subscribers({ tenantId, type: edge.type }));
|
|
219
|
+
let apps;
|
|
220
|
+
try {
|
|
221
|
+
apps = await answers.get(asked);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
this.store.holdEligibility(receiver, tenantId, now);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
this.store.releaseEligibility(receiver, tenantId);
|
|
228
|
+
if (!apps.includes(edge.app))
|
|
229
|
+
this.store.settleIneligible(receiver, tenantId, now);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
161
233
|
// -- broker to broker (#3469) ----------------------------------------------------------------
|
|
162
234
|
relayOrThrow() {
|
|
163
235
|
if (!this.relay)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-broker.js","sourceRoot":"","sources":["../src/delivery-broker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EAId,eAAe,EAGf,kBAAkB,EAClB,eAAe,GAoBhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAwC,MAAM,yBAAyB,CAAC;AAoD9F,MAAM,OAAO,uBAAuB;IACjB,EAAE,CAAoB;IACtB,KAAK,CAAc;IACnB,SAAS,CAAmC;IAC5C,GAAG,CAAe;IAClB,SAAS,CAAyB;IAClC,KAAK,CAAqB;IAC1B,OAAO,CAAiB;IACxB,QAAQ,CAAwB;IAChC,OAAO,CAAiC;IACxC,IAAI,CAAqE;IAE1F,YAAY,OAAO,GAAmC,EAAE;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAA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,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,IAAI,OAAO;YAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DevConnectorMode } from '@substrat-run/contracts';
|
|
1
|
+
import { type ConnectorRecording, type DevConnectorMode } from '@substrat-run/contracts';
|
|
2
2
|
import { type FetchLike } from '@substrat-run/kernel';
|
|
3
3
|
/** Where `record` writes, under the data directory. */
|
|
4
4
|
export declare const DEV_RECORDING_FILE: string;
|
|
@@ -18,4 +18,46 @@ export interface DevConnectorNetwork {
|
|
|
18
18
|
readonly fetch: FetchLike;
|
|
19
19
|
}
|
|
20
20
|
export declare function devConnectorNetwork(options: DevConnectorNetworkOptions): DevConnectorNetwork;
|
|
21
|
+
/** The environment a local run's calls come from (D-83): a named environment's scopes are previews, which reach no connector locally. */
|
|
22
|
+
export declare const DEV_PROFILE_ENVIRONMENT = "production";
|
|
23
|
+
/** One recording, answering the calls of one exact (tenant, app, environment, scope). */
|
|
24
|
+
export interface DevConnectorProfile {
|
|
25
|
+
tenantId: string;
|
|
26
|
+
/** The app's slug: the target's `slug`. */
|
|
27
|
+
app: string;
|
|
28
|
+
/**
|
|
29
|
+
* The environment (D-83). Only {@link DEV_PROFILE_ENVIRONMENT} is selectable: a local run refuses
|
|
30
|
+
* a preview's or a fork's call before it reaches a connector, and a named environment's scope is
|
|
31
|
+
* one. Another name is refused when the profiles are built.
|
|
32
|
+
*/
|
|
33
|
+
environment: string;
|
|
34
|
+
/** The scope a scoped call (sweep, dispatch, bind) is for; `null` for a connection-level call (a probe). */
|
|
35
|
+
scopeId: string | null;
|
|
36
|
+
/** In memory, or a fixture file, which must be scrubbed (`substrat recording scrub`). */
|
|
37
|
+
recording: ConnectorRecording | {
|
|
38
|
+
file: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** What a call's target names, of what selects a profile. `localConnectorCalls` hands it over. */
|
|
42
|
+
export interface DevConnectorProfileTarget {
|
|
43
|
+
slug: string;
|
|
44
|
+
tenantId?: string;
|
|
45
|
+
scopeId?: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface DevConnectorProfiles {
|
|
48
|
+
/**
|
|
49
|
+
* The network one call is answered on: the replay of the profile keyed exactly on the target's
|
|
50
|
+
* (tenant, app, production, scope), or, with none, a network that refuses every request, naming
|
|
51
|
+
* the key. Never the provider: profiles are handed no network to fall back to.
|
|
52
|
+
*/
|
|
53
|
+
networkFor(target: DevConnectorProfileTarget): FetchLike;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Recordings selected per call (the mock profiles of connector-scripts.md §4, locally): pass
|
|
57
|
+
* `networkFor` as `localConnectorCalls({ fetchFor })`, under the hold to the declared hosts as any
|
|
58
|
+
* network is. Nothing is recorded or written, and a profile is read once, when this is built.
|
|
59
|
+
*/
|
|
60
|
+
export declare function devConnectorProfiles(options: {
|
|
61
|
+
profiles: readonly DevConnectorProfile[];
|
|
62
|
+
}): DevConnectorProfiles;
|
|
21
63
|
//# sourceMappingURL=dev-connector-network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-connector-network.d.ts","sourceRoot":"","sources":["../src/dev-connector-network.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev-connector-network.d.ts","sourceRoot":"","sources":["../src/dev-connector-network.ts"],"names":[],"mappings":"AAuBA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAqF,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEzI,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,QAAiD,CAAC;AA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CAyChH"}
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* A replay answers a request by its method and URL (a scrubbed recording's URL, scrubbed the same
|
|
16
16
|
* way), the calls for one request in the order they were recorded, the last again once they run
|
|
17
17
|
* out. A request it has no call for fails, naming it. Request bodies are recorded, never matched on.
|
|
18
|
+
*
|
|
19
|
+
* {@link devConnectorProfiles} is the same replay, selected per call: a recording for each exact
|
|
20
|
+
* (tenant, app, environment, scope), for a suite or a local run that exercises several scopes.
|
|
18
21
|
*/
|
|
19
22
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
20
23
|
import { dirname, join, relative, resolve, isAbsolute } from 'node:path';
|
|
@@ -89,6 +92,14 @@ export function devConnectorNetwork(options) {
|
|
|
89
92
|
return { mode: 'record', file, fetch };
|
|
90
93
|
}
|
|
91
94
|
const file = options.file ?? join(options.dataDir, DEV_RECORDING_FILE);
|
|
95
|
+
const recording = readRecording(file);
|
|
96
|
+
if (!recording.scrubbed && !inside(options.dataDir, file)) {
|
|
97
|
+
throw new Error(`connector replay: ${file} is outside the data directory and was not scrubbed. A raw recording holds the ` +
|
|
98
|
+
'credential and the provider\'s data; scrub it with `substrat recording scrub` before keeping it anywhere else.');
|
|
99
|
+
}
|
|
100
|
+
return { mode: 'replay', file, fetch: replayFetch(recording, file) };
|
|
101
|
+
}
|
|
102
|
+
function readRecording(file) {
|
|
92
103
|
let raw;
|
|
93
104
|
try {
|
|
94
105
|
raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
@@ -99,11 +110,10 @@ export function devConnectorNetwork(options) {
|
|
|
99
110
|
const parsed = connectorRecording.safeParse(raw);
|
|
100
111
|
if (!parsed.success)
|
|
101
112
|
throw new Error(`connector replay: ${file} is not a connector recording: ${parsed.error.issues[0]?.message ?? 'invalid'}`);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
113
|
+
return parsed.data;
|
|
114
|
+
}
|
|
115
|
+
/** A recording answering instead of the provider: by method and URL, in recorded order, refusing a request it has no call for. */
|
|
116
|
+
function replayFetch(recording, label) {
|
|
107
117
|
const keyOf = (method, url) => `${method.toUpperCase()} ${recording.scrubbed ? scrubUrl(url) : url}`;
|
|
108
118
|
const byKey = new Map();
|
|
109
119
|
for (const call of recording.calls) {
|
|
@@ -111,15 +121,64 @@ export function devConnectorNetwork(options) {
|
|
|
111
121
|
byKey.set(key, [...(byKey.get(key) ?? []), call]);
|
|
112
122
|
}
|
|
113
123
|
const served = new Map();
|
|
114
|
-
|
|
124
|
+
return async (input, init) => {
|
|
115
125
|
const key = keyOf(init?.method ?? 'GET', input);
|
|
116
126
|
const calls = byKey.get(key);
|
|
117
127
|
if (!calls)
|
|
118
|
-
throw new Error(`connector replay: ${
|
|
128
|
+
throw new Error(`connector replay: ${label} has no recorded answer for ${key}. Record it with \`substrat dev --connectors record\`.`);
|
|
119
129
|
const n = served.get(key) ?? 0;
|
|
120
130
|
served.set(key, n + 1);
|
|
121
131
|
return answerOf(calls[Math.min(n, calls.length - 1)].response);
|
|
122
132
|
};
|
|
123
|
-
|
|
133
|
+
}
|
|
134
|
+
/** The environment a local run's calls come from (D-83): a named environment's scopes are previews, which reach no connector locally. */
|
|
135
|
+
export const DEV_PROFILE_ENVIRONMENT = 'production';
|
|
136
|
+
const profileKey = (tenantId, app, environment, scopeId) => `tenant ${tenantId}, app '${app}', environment '${environment}', ${scopeId === null ? 'connection level' : `scope ${scopeId}`}`;
|
|
137
|
+
/**
|
|
138
|
+
* Recordings selected per call (the mock profiles of connector-scripts.md §4, locally): pass
|
|
139
|
+
* `networkFor` as `localConnectorCalls({ fetchFor })`, under the hold to the declared hosts as any
|
|
140
|
+
* network is. Nothing is recorded or written, and a profile is read once, when this is built.
|
|
141
|
+
*/
|
|
142
|
+
export function devConnectorProfiles(options) {
|
|
143
|
+
const byKey = new Map();
|
|
144
|
+
for (const p of options.profiles) {
|
|
145
|
+
const key = profileKey(p.tenantId, p.app, p.environment, p.scopeId);
|
|
146
|
+
if (p.environment !== DEV_PROFILE_ENVIRONMENT) {
|
|
147
|
+
throw new Error(`connector mock profile: ${key} names an environment other than '${DEV_PROFILE_ENVIRONMENT}'. A named environment's scopes are ` +
|
|
148
|
+
'previews, which reach no connector in a local run, so it could never be selected.');
|
|
149
|
+
}
|
|
150
|
+
if (byKey.has(key))
|
|
151
|
+
throw new Error(`connector mock profile: two recordings for ${key}; one key is one recording`);
|
|
152
|
+
let recording;
|
|
153
|
+
let label;
|
|
154
|
+
if ('file' in p.recording) {
|
|
155
|
+
recording = readRecording(p.recording.file);
|
|
156
|
+
label = p.recording.file;
|
|
157
|
+
if (!recording.scrubbed) {
|
|
158
|
+
throw new Error(`connector mock profile: ${label} was not scrubbed. A profile is a fixture kept with the code, and a raw recording holds the ` +
|
|
159
|
+
'credential and the provider\'s data; scrub it with `substrat recording scrub` first.');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const parsed = connectorRecording.safeParse(p.recording);
|
|
164
|
+
if (!parsed.success)
|
|
165
|
+
throw new Error(`connector mock profile: the recording for ${key} is not a connector recording: ${parsed.error.issues[0]?.message ?? 'invalid'}`);
|
|
166
|
+
recording = parsed.data;
|
|
167
|
+
label = `the recording for ${key}`;
|
|
168
|
+
}
|
|
169
|
+
byKey.set(key, replayFetch(recording, label));
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
networkFor: (target) => {
|
|
173
|
+
const key = target.tenantId === undefined ? null : profileKey(target.tenantId, target.slug, DEV_PROFILE_ENVIRONMENT, target.scopeId ?? null);
|
|
174
|
+
const found = key === null ? undefined : byKey.get(key);
|
|
175
|
+
if (found)
|
|
176
|
+
return found;
|
|
177
|
+
const why = key === null ? `a call to '${target.slug}' that names no tenant` : key;
|
|
178
|
+
return async (input, init) => {
|
|
179
|
+
throw new Error(`connector mock profile: no recording for ${why}, so ${(init?.method ?? 'GET').toUpperCase()} ${scrubUrl(input)} is not sent anywhere.`);
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
};
|
|
124
183
|
}
|
|
125
184
|
//# sourceMappingURL=dev-connector-network.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-connector-network.js","sourceRoot":"","sources":["../src/dev-connector-network.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dev-connector-network.js","sourceRoot":"","sources":["../src/dev-connector-network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,QAAQ,GAKT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAqE,MAAM,sBAAsB,CAAC;AAEzI,uDAAuD;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;AAmBjF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,kGAAkG,CAAC;AAEnH,SAAS,MAAM,CAAC,KAAiB,EAAE,WAA+B;IAChE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3D,IAAI,CAAC;YACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,C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C3J,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type UploadLinkView, type BlobStoreHandle, type ManifestConnectionLandings, type ManifestConnectors, type ImportBatch, type PushedImport, type ImportResult, type Coverage, type PeerCoverage, type VerticalCaller, type BoundedBecomeMint, type BoundedBindLinkMint, type CapabilityExchangeOptions, type PrincipalBindLinkInput, type BoundedBecomeRevoke, type BoundedUnbind, type BecomeLinkState, type PrincipalBecomeCapabilityInput, type CapabilityExchange, type CapabilityId, type ConnectionId, type ModuleId, type DomainEvent, type PlatformRequestId, type PlatformRequestEntry, type PlatformRequestFilter, type ProjectedConnectionGrant, type EntityRef, type PermissionKey, type PlatformActorId, type OnBehalfOf, type PrincipalId, type QueryScopeInput, type ReadScopeTableInput, type ScopeDumpInput, type ScopeId, type ScopeQueryResult, type ScopeTable, type ImpersonationSessionId, type ScopeTablePage, type TenantId, type TenantStoreHandle, type EntityHistoryInput, type EventCauseInput, type EventEffectsInput, type EffectsTree, type InvocationEventsInput, type InvocationEvents, type DeadLettersInput, type DeadLetter, type LifecycleFlowInput, type LifecycleFlowResult, type OperationSeriesInput, type OperationSeriesResult, type CauseChain, type EventFacetInput, type EventFacetResult, type HistoryEntry, type Page } from '@substrat-run/contracts';
|
|
2
|
-
import { type ModuleLogSink, type InvocationLineSink, type FreshnessReport, type FreshnessRegistration, type BlobStoreProvisionInput, type AttachmentOpenOptions, type OpenedAttachmentStream, type ScopeAttachments, type TenantBlobStore, type ExecutorDeadLetter, type ExecutorDrainReport, type MigrateScopeOutcome, type MigrationFrontier, type ExecutorHandler, type ExecutorRetryPolicy, type ScopeRoleHolder, type RoleState, type DeclaredPermissions, type ConnectorHandler, type ConnectorOptions, type Clock, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScheduleTick, type ScopeHost, type ScopeStub, type PersonScopeOptions, type ScopeStubOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type AttachmentExtractor, type AttachmentTextBounds, type OrphanSweepReport, type OrphanSweepRequest, type RelayScopeDoors, type JobDriveReport, type JobHandler, type JobRun, type JobRunFilter, type StartJobRunInput, type UndrainedEvents, type ConnectorCallRecorder, type StoreStub, type ScopeStoreStubOptions, type AppliedMigration, type ScopeStoreHostOptions, type StoreErasureReplay } from '@substrat-run/kernel';
|
|
2
|
+
import { type ModuleLogSink, type InvocationLineSink, type FreshnessReport, type FreshnessRegistration, type BlobStoreProvisionInput, type AttachmentOpenOptions, type OpenedAttachmentStream, type ScopeAttachments, type TenantBlobStore, type ExecutorDeadLetter, type ExecutorDrainReport, type MigrateScopeOutcome, type MigrationFrontier, type ExecutorHandler, type ExecutorRetryPolicy, type ScopeRoleHolder, type RoleState, type DeclaredPermissions, type SecretBoxCanaryMode, type ConnectorHandler, type ConnectorOptions, type Clock, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScheduleTick, type ScopeHost, type ScopeStub, type PersonScopeOptions, type ScopeStubOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type AttachmentExtractor, type AttachmentTextBounds, type OrphanSweepReport, type OrphanSweepRequest, type RelayScopeDoors, CrossVerticalRegistry, type JobDriveReport, type JobHandler, type JobRun, type JobRunFilter, type StartJobRunInput, type UndrainedEvents, type ConnectorCallRecorder, type StoreStub, type ScopeStoreStubOptions, type AppliedMigration, type ScopeStoreHostOptions, type StoreErasureReplay } from '@substrat-run/kernel';
|
|
3
3
|
import { type BrokerTelemetrySink } from '@substrat-run/kernel';
|
|
4
4
|
import { type ChildScopeCaller } from '@substrat-run/kernel';
|
|
5
5
|
import { type PlatformRequestSettle } from '@substrat-run/kernel';
|
|
@@ -10,8 +10,9 @@ import { type ContainerPassLauncher, type SystemAttachments } from '@substrat-ru
|
|
|
10
10
|
import { type RedeemedUploadLink, type UploadLinkRedeemInput } from '@substrat-run/kernel';
|
|
11
11
|
export { scopeStoreRunnersFor } from './scope-store-runners.js';
|
|
12
12
|
export { InProcessDeliveryBroker, type InProcessDeliveryBrokerOptions, type InProcessSubscription } from './delivery-broker.js';
|
|
13
|
+
export { relayEdgeSubscription, type RelayEdge } from './relay-edges.js';
|
|
13
14
|
export { devMailOutbox, MAIL_OUTBOX_ENV, type DevMailOutbox, type DevMailOutboxOptions, type OutboxNode } from './dev-mail-outbox.js';
|
|
14
|
-
export { devConnectorNetwork, DEV_RECORDING_FILE, type DevConnectorNetwork, type DevConnectorNetworkOptions } from './dev-connector-network.js';
|
|
15
|
+
export { devConnectorNetwork, devConnectorProfiles, DEV_PROFILE_ENVIRONMENT, DEV_RECORDING_FILE, type DevConnectorNetwork, type DevConnectorNetworkOptions, type DevConnectorProfile, type DevConnectorProfiles, type DevConnectorProfileTarget, } from './dev-connector-network.js';
|
|
15
16
|
/**
|
|
16
17
|
* A fault in the database itself (full, corrupt, I/O), as opposed to one statement failing.
|
|
17
18
|
* The #1764 backfill logs and opens past a failed batch, but never past one of these.
|
|
@@ -81,6 +82,12 @@ export interface SqliteScopeHostOptions {
|
|
|
81
82
|
* keeps working, so a deployment that uses no connectors needs no key.
|
|
82
83
|
*/
|
|
83
84
|
secretBox?: SecretBox;
|
|
85
|
+
/**
|
|
86
|
+
* #3464: whether every seal first proves `secretBox` holds the directory's key, against a canary
|
|
87
|
+
* kept in the directory (`guardSecretBox`), and how a directory with none is seeded. Omitted or
|
|
88
|
+
* `off`: no canary, as before. Ignored without a `secretBox`, which already refuses every seal.
|
|
89
|
+
*/
|
|
90
|
+
secretBoxCanary?: SecretBoxCanaryMode;
|
|
84
91
|
/**
|
|
85
92
|
* Egress for connectors. Defaults to the runtime's `fetch`.
|
|
86
93
|
*
|
|
@@ -355,6 +362,8 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
355
362
|
private readonly accessSummary;
|
|
356
363
|
private readonly systemPrincipal;
|
|
357
364
|
private readonly secretBox;
|
|
365
|
+
/** #3464: the canary mode `secretBox` was guarded with, which its preflight reports. */
|
|
366
|
+
private readonly secretBoxCanaryMode;
|
|
358
367
|
/** The parsers attachment text is extracted with (K-43); the host's own, never imported here. */
|
|
359
368
|
private readonly attachmentExtractors;
|
|
360
369
|
/** D-85 (#3752): `SqliteScopeHostOptions.containerPasses`. */
|
|
@@ -959,12 +968,13 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
959
968
|
* resolution both `ctx.canAssign` and the host's `canAssign` answer from.
|
|
960
969
|
*/
|
|
961
970
|
private assignmentBound;
|
|
962
|
-
/**
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
971
|
+
/**
|
|
972
|
+
* #1705: what this deployment imports — the sweep's reason to call no scope when it is empty —
|
|
973
|
+
* with each edge's declared receiver policy (K-74), which the local relay router answers with.
|
|
974
|
+
*/
|
|
975
|
+
registeredImports(): ReturnType<CrossVerticalRegistry['consumes']>;
|
|
976
|
+
/** #1705: the event types this deployment exports to other verticals, which the local relay mesh relays (K-74). */
|
|
977
|
+
registeredExportTypes(): readonly string[];
|
|
968
978
|
registeredSchedules(): ScheduleRegistration[];
|
|
969
979
|
registeredFreshness(): FreshnessRegistration[];
|
|
970
980
|
/**
|
|
@@ -1219,6 +1229,8 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
1219
1229
|
* check there would let a caller reach another tenant's keys by naming their scope id.
|
|
1220
1230
|
*/
|
|
1221
1231
|
private assertScope;
|
|
1232
|
+
/** #3464: the directory's SecretBox canary, for `guardSecretBox`. Read at seal time, never before. */
|
|
1233
|
+
private secretBoxCanaryRecords;
|
|
1222
1234
|
/**
|
|
1223
1235
|
* This scope's per-subject keys (#37). The crypto lives in the kernel
|
|
1224
1236
|
* (`createSubjectKeys`); what the adapter supplies is the three row operations against
|