@requence/service 0.8.2-edge.1151 → 0.8.2-edge.1155
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/README.md +258 -0
- package/build/{chunk-974rc2jy.js → chunk-gpyt51xn.js} +164 -3
- package/build/{chunk-974rc2jy.js.map → chunk-gpyt51xn.js.map} +7 -4
- package/build/cli.js +17 -30
- package/build/cli.js.map +3 -3
- package/build/index.js +538 -94
- package/build/index.js.map +18 -10
- package/build/types/helpers/src/index.d.ts +5 -0
- package/build/types/helpers/src/index.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/NodeTree.d.ts +29 -0
- package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/command.d.ts +859 -7
- package/build/types/helpers/src/protocol/command.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/index.d.ts +1 -0
- package/build/types/helpers/src/protocol/index.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/sliceTreeList.d.ts +81 -0
- package/build/types/helpers/src/protocol/sliceTreeList.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/treeNodes.d.ts +577 -2
- package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/update.d.ts +128 -10
- package/build/types/helpers/src/protocol/update.d.ts.map +1 -1
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts +113 -18
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts.map +1 -1
- package/build/types/helpers/src/utils/matchSchema.d.ts +14 -0
- package/build/types/helpers/src/utils/matchSchema.d.ts.map +1 -1
- package/build/types/helpers/src/utils/serviceRender.d.ts +73 -0
- package/build/types/helpers/src/utils/serviceRender.d.ts.map +1 -0
- package/build/types/helpers/src/utils/sliceClock.d.ts +61 -0
- package/build/types/helpers/src/utils/sliceClock.d.ts.map +1 -0
- package/build/types/helpers/src/utils/surfaceComponent.d.ts +116 -0
- package/build/types/helpers/src/utils/surfaceComponent.d.ts.map +1 -0
- package/build/types/helpers/src/utils/surfaceHandler.d.ts +171 -0
- package/build/types/helpers/src/utils/surfaceHandler.d.ts.map +1 -0
- package/build/types/helpers/src/utils/uiRebuild.d.ts +48 -0
- package/build/types/helpers/src/utils/uiRebuild.d.ts.map +1 -0
- package/build/types/service/src/boundary.d.ts +14 -1
- package/build/types/service/src/boundary.d.ts.map +1 -1
- package/build/types/service/src/createAmqpConnection.d.ts +55 -0
- package/build/types/service/src/createAmqpConnection.d.ts.map +1 -1
- package/build/types/service/src/errors.d.ts +11 -0
- package/build/types/service/src/errors.d.ts.map +1 -1
- package/build/types/service/src/helpers.d.ts +68 -0
- package/build/types/service/src/helpers.d.ts.map +1 -1
- package/build/types/service/src/index.d.ts +2 -0
- package/build/types/service/src/index.d.ts.map +1 -1
- package/build/types/service/src/surfaceHandler.d.ts +36 -0
- package/build/types/service/src/surfaceHandler.d.ts.map +1 -0
- package/build/types/service/src/surfaceUi.d.ts +141 -0
- package/build/types/service/src/surfaceUi.d.ts.map +1 -0
- package/build/types/service/src/transformer.d.ts +14 -0
- package/build/types/service/src/transformer.d.ts.map +1 -1
- package/build/types/service/src/ui.d.ts +247 -0
- package/build/types/service/src/ui.d.ts.map +1 -0
- package/build/types/service/src/uiWatch.d.ts +68 -0
- package/build/types/service/src/uiWatch.d.ts.map +1 -0
- package/package.json +10 -4
|
@@ -90,7 +90,7 @@ declare const nodeUpdateSchema: z.ZodObject<{
|
|
|
90
90
|
}, z.core.$strip>;
|
|
91
91
|
type: z.ZodLiteral<"NODE_UPDATE">;
|
|
92
92
|
output: z.ZodNullable<z.ZodString>;
|
|
93
|
-
data: z.ZodUnknown
|
|
93
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
94
94
|
overwrite: z.ZodBoolean;
|
|
95
95
|
}, z.core.$strip>;
|
|
96
96
|
export type NodeUpdate = z.infer<typeof nodeUpdateSchema>;
|
|
@@ -122,7 +122,7 @@ declare const nodeCallbackSchema: z.ZodObject<{
|
|
|
122
122
|
}, z.core.$strip>;
|
|
123
123
|
propertyPath: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
124
124
|
output: z.ZodNullable<z.ZodString>;
|
|
125
|
-
data: z.ZodUnknown
|
|
125
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
126
126
|
}, z.core.$strip>;
|
|
127
127
|
export type NodeCallback = z.infer<typeof nodeCallbackSchema>;
|
|
128
128
|
declare const nodeEndUpdateSchema: z.ZodObject<{
|
|
@@ -166,9 +166,72 @@ declare const nodeDebugUpdateSchema: z.ZodObject<{
|
|
|
166
166
|
system: "system";
|
|
167
167
|
warn: "warn";
|
|
168
168
|
}>;
|
|
169
|
-
data: z.ZodUnknown
|
|
169
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
170
170
|
}, z.core.$strip>;
|
|
171
171
|
export type NodeDebugUpdate = z.infer<typeof nodeDebugUpdateSchema>;
|
|
172
|
+
declare const nodeRenderUpdateSchema: z.ZodObject<{
|
|
173
|
+
component: z.ZodObject<{
|
|
174
|
+
id: z.ZodString;
|
|
175
|
+
hash: z.ZodString;
|
|
176
|
+
source: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
props: z.ZodUnknown;
|
|
179
|
+
defaults: z.ZodOptional<z.ZodUnknown>;
|
|
180
|
+
surfaceId: z.ZodString;
|
|
181
|
+
devSession: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
182
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
183
|
+
id: z.ZodUUID;
|
|
184
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
185
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
186
|
+
node: z.ZodObject<{
|
|
187
|
+
id: z.ZodUUID;
|
|
188
|
+
type: z.ZodEnum<{
|
|
189
|
+
logic: "logic";
|
|
190
|
+
or: "or";
|
|
191
|
+
reference: "reference";
|
|
192
|
+
service: "service";
|
|
193
|
+
}>;
|
|
194
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
type: z.ZodLiteral<"NODE_RENDER">;
|
|
197
|
+
messageId: z.ZodUUID;
|
|
198
|
+
connectionId: z.ZodUUID;
|
|
199
|
+
ownTraceId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
200
|
+
handlerQueue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type NodeRenderUpdate = z.infer<typeof nodeRenderUpdateSchema>;
|
|
203
|
+
declare const surfaceDeadUpdateSchema: z.ZodObject<{
|
|
204
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
205
|
+
id: z.ZodUUID;
|
|
206
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
207
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
208
|
+
type: z.ZodLiteral<"SURFACE_DEAD">;
|
|
209
|
+
messageId: z.ZodUUID;
|
|
210
|
+
connectionId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
export type SurfaceDeadUpdate = z.infer<typeof surfaceDeadUpdateSchema>;
|
|
213
|
+
declare const surfaceInteractionErrorUpdateSchema: z.ZodObject<{
|
|
214
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
215
|
+
id: z.ZodUUID;
|
|
216
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
217
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
218
|
+
type: z.ZodLiteral<"SURFACE_INTERACTION_ERROR">;
|
|
219
|
+
surface: z.ZodUUID;
|
|
220
|
+
message: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
221
|
+
}, z.core.$strip>;
|
|
222
|
+
export type SurfaceInteractionErrorUpdate = z.infer<typeof surfaceInteractionErrorUpdateSchema>;
|
|
223
|
+
declare const uiRebuiltUpdateSchema: z.ZodObject<{
|
|
224
|
+
devSession: z.ZodString;
|
|
225
|
+
uiId: z.ZodString;
|
|
226
|
+
hash: z.ZodString;
|
|
227
|
+
source: z.ZodString;
|
|
228
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
229
|
+
id: z.ZodUUID;
|
|
230
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
231
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
232
|
+
type: z.ZodLiteral<"UI_REBUILT">;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
export type UiRebuiltUpdate = z.infer<typeof uiRebuiltUpdateSchema>;
|
|
172
235
|
declare const nodeDeferUpdateSchema: z.ZodObject<{
|
|
173
236
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
174
237
|
id: z.ZodUUID;
|
|
@@ -185,7 +248,7 @@ declare const nodeDeferUpdateSchema: z.ZodObject<{
|
|
|
185
248
|
alias: z.ZodOptional<z.ZodString>;
|
|
186
249
|
}, z.core.$strip>;
|
|
187
250
|
type: z.ZodLiteral<"NODE_DEFER">;
|
|
188
|
-
reason: z.ZodUnknown
|
|
251
|
+
reason: z.ZodOptional<z.ZodUnknown>;
|
|
189
252
|
}, z.core.$strip>;
|
|
190
253
|
export type NodeDeferUpdate = z.infer<typeof nodeDeferUpdateSchema>;
|
|
191
254
|
declare const taskStartUpdateSchema: z.ZodObject<{
|
|
@@ -200,7 +263,7 @@ declare const taskStartUpdateSchema: z.ZodObject<{
|
|
|
200
263
|
nodeId: z.ZodUUID;
|
|
201
264
|
messageId: z.ZodUUID;
|
|
202
265
|
}, z.core.$strip>>>;
|
|
203
|
-
input: z.ZodUnknown
|
|
266
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
204
267
|
}, z.core.$strip>;
|
|
205
268
|
export type TaskStartUpdate = z.infer<typeof taskStartUpdateSchema>;
|
|
206
269
|
declare const taskErrorUpdateSchema: z.ZodObject<{
|
|
@@ -307,7 +370,7 @@ export declare const updateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
307
370
|
}, z.core.$strip>;
|
|
308
371
|
type: z.ZodLiteral<"NODE_UPDATE">;
|
|
309
372
|
output: z.ZodNullable<z.ZodString>;
|
|
310
|
-
data: z.ZodUnknown
|
|
373
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
311
374
|
overwrite: z.ZodBoolean;
|
|
312
375
|
}, z.core.$strip>, z.ZodObject<{
|
|
313
376
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
@@ -337,7 +400,7 @@ export declare const updateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
337
400
|
}, z.core.$strip>;
|
|
338
401
|
propertyPath: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
339
402
|
output: z.ZodNullable<z.ZodString>;
|
|
340
|
-
data: z.ZodUnknown
|
|
403
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
341
404
|
}, z.core.$strip>, z.ZodObject<{
|
|
342
405
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
343
406
|
id: z.ZodUUID;
|
|
@@ -377,7 +440,62 @@ export declare const updateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
377
440
|
system: "system";
|
|
378
441
|
warn: "warn";
|
|
379
442
|
}>;
|
|
380
|
-
data: z.ZodUnknown
|
|
443
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
444
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
445
|
+
component: z.ZodObject<{
|
|
446
|
+
id: z.ZodString;
|
|
447
|
+
hash: z.ZodString;
|
|
448
|
+
source: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
449
|
+
}, z.core.$strip>;
|
|
450
|
+
props: z.ZodUnknown;
|
|
451
|
+
defaults: z.ZodOptional<z.ZodUnknown>;
|
|
452
|
+
surfaceId: z.ZodString;
|
|
453
|
+
devSession: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
454
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
455
|
+
id: z.ZodUUID;
|
|
456
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
457
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
458
|
+
node: z.ZodObject<{
|
|
459
|
+
id: z.ZodUUID;
|
|
460
|
+
type: z.ZodEnum<{
|
|
461
|
+
logic: "logic";
|
|
462
|
+
or: "or";
|
|
463
|
+
reference: "reference";
|
|
464
|
+
service: "service";
|
|
465
|
+
}>;
|
|
466
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
467
|
+
}, z.core.$strip>;
|
|
468
|
+
type: z.ZodLiteral<"NODE_RENDER">;
|
|
469
|
+
messageId: z.ZodUUID;
|
|
470
|
+
connectionId: z.ZodUUID;
|
|
471
|
+
ownTraceId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
472
|
+
handlerQueue: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
473
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
474
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
475
|
+
id: z.ZodUUID;
|
|
476
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
477
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
478
|
+
type: z.ZodLiteral<"SURFACE_DEAD">;
|
|
479
|
+
messageId: z.ZodUUID;
|
|
480
|
+
connectionId: z.ZodDefault<z.ZodNullable<z.ZodUUID>>;
|
|
481
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
482
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
483
|
+
id: z.ZodUUID;
|
|
484
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
485
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
486
|
+
type: z.ZodLiteral<"SURFACE_INTERACTION_ERROR">;
|
|
487
|
+
surface: z.ZodUUID;
|
|
488
|
+
message: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
489
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
490
|
+
devSession: z.ZodString;
|
|
491
|
+
uiId: z.ZodString;
|
|
492
|
+
hash: z.ZodString;
|
|
493
|
+
source: z.ZodString;
|
|
494
|
+
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
495
|
+
id: z.ZodUUID;
|
|
496
|
+
rootTaskId: z.ZodOptional<z.ZodUUID>;
|
|
497
|
+
traceIds: z.ZodArray<z.ZodString>;
|
|
498
|
+
type: z.ZodLiteral<"UI_REBUILT">;
|
|
381
499
|
}, z.core.$strip>, z.ZodObject<{
|
|
382
500
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
383
501
|
id: z.ZodUUID;
|
|
@@ -394,7 +512,7 @@ export declare const updateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
394
512
|
alias: z.ZodOptional<z.ZodString>;
|
|
395
513
|
}, z.core.$strip>;
|
|
396
514
|
type: z.ZodLiteral<"NODE_DEFER">;
|
|
397
|
-
reason: z.ZodUnknown
|
|
515
|
+
reason: z.ZodOptional<z.ZodUnknown>;
|
|
398
516
|
}, z.core.$strip>, z.ZodObject<{
|
|
399
517
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
400
518
|
id: z.ZodUUID;
|
|
@@ -407,7 +525,7 @@ export declare const updateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
407
525
|
nodeId: z.ZodUUID;
|
|
408
526
|
messageId: z.ZodUUID;
|
|
409
527
|
}, z.core.$strip>>>;
|
|
410
|
-
input: z.ZodUnknown
|
|
528
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
411
529
|
}, z.core.$strip>, z.ZodObject<{
|
|
412
530
|
timestamp: z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>;
|
|
413
531
|
id: z.ZodUUID;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/protocol/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/protocol/update.ts"],"names":[],"mappings":"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"}
|
|
@@ -11,35 +11,130 @@ export declare const DEFAULT_AMQP_PUBLISH_RETRY_ATTEMPTS = 3;
|
|
|
11
11
|
* out and retries) and far below the incident's multi-second stalls.
|
|
12
12
|
*/
|
|
13
13
|
export declare const PUBLISH_STARVATION_THRESHOLD_MS = 1000;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* How long to wait, after a confirm deadline elapsed on a starved loop, before
|
|
16
|
+
* reading the link's incarnation for the second time.
|
|
17
|
+
*
|
|
18
|
+
* The stall that delayed the confirm delayed the socket's own close callback
|
|
19
|
+
* too, and Node runs the timers phase BEFORE the poll phase — so the deadline's
|
|
20
|
+
* timer can fire before the disconnect it was caused by has even been read off
|
|
21
|
+
* the socket. Deciding on the spot would call that lost message delivered. One
|
|
22
|
+
* settle turn puts the read after the poll phase; the margin above that costs
|
|
23
|
+
* nothing, because this only ever delays a publish that already spent its full
|
|
24
|
+
* timeout.
|
|
25
|
+
*/
|
|
26
|
+
export declare const PUBLISH_LINK_SETTLE_MS = 250;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the publish link's incarnation: a number that changes on every
|
|
29
|
+
* (re)connect, and `null` for as long as the link is down.
|
|
30
|
+
*
|
|
31
|
+
* Encoding "down" as `null` is what lets a single equality carry the whole
|
|
32
|
+
* liveness question — `start !== null && start === end` holds only if the link
|
|
33
|
+
* was up at both ends AND never cycled in between.
|
|
34
|
+
*/
|
|
35
|
+
export type PublishLinkEpoch = () => number | null;
|
|
36
|
+
export interface PublishLinkTracker {
|
|
37
|
+
/** Pass this to `createPublishWindowProbe`. */
|
|
38
|
+
epoch: PublishLinkEpoch;
|
|
39
|
+
/** Call when the publish channel is (re)connected and usable. */
|
|
40
|
+
markConnected: () => void;
|
|
41
|
+
/** Call when the connection or the publish channel is lost. */
|
|
42
|
+
markDisconnected: () => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Tracks whether a publisher's link to the broker is up, and how many times it
|
|
46
|
+
* has been re-made. Every AMQP client wires this to its own connection and
|
|
47
|
+
* channel events; the counter is deliberately not derived from the library's
|
|
48
|
+
* `isConnected()`, because a drop-and-recover inside one publish window is
|
|
49
|
+
* invisible to a boolean and must not read as "the link held".
|
|
50
|
+
*/
|
|
51
|
+
export declare function createPublishLinkTracker(): PublishLinkTracker;
|
|
52
|
+
export interface PublishTimeoutVerdict {
|
|
53
|
+
/** Longest stretch (ms) in which the loop could not run a callback. */
|
|
54
|
+
starvedMs: number;
|
|
55
|
+
/** The loop was starved past the threshold during the window. */
|
|
56
|
+
starved: boolean;
|
|
57
|
+
/** The link was down at some point while the confirm was outstanding. */
|
|
58
|
+
linkLost: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* A reading taken while the message was still the library's responsibility
|
|
61
|
+
* found the publisher's send queue empty, which proves this message was handed
|
|
62
|
+
* to the socket. `false` means unproven, not "provably still queued".
|
|
63
|
+
*/
|
|
64
|
+
leftSendQueue: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Only true when the loop was starved AND the link held throughout AND the
|
|
67
|
+
* message provably left the send queue: it is in the broker's hands and must
|
|
68
|
+
* NOT be re-sent.
|
|
69
|
+
*/
|
|
70
|
+
delivered: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface PublishWindowProbe {
|
|
73
|
+
/**
|
|
74
|
+
* Take a send-queue reading now. Call it synchronously right after handing the
|
|
75
|
+
* message to the publisher: `ChannelWrapper.publish()` enqueues AND runs its
|
|
76
|
+
* send worker synchronously, so on a healthy channel the queue is already
|
|
77
|
+
* empty by the time it returns — which is the sharpest reading available.
|
|
78
|
+
*/
|
|
79
|
+
observeSendQueue: () => void;
|
|
80
|
+
/** Stop sampling. Idempotent; call it on the success path. */
|
|
81
|
+
stop: () => void;
|
|
15
82
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
83
|
+
* Decide what an elapsed confirm deadline means. Stops sampling, then — only
|
|
84
|
+
* where the answer could still flip — waits out `settleMs` before re-reading
|
|
85
|
+
* the link. Idempotent: subsequent calls return the first verdict.
|
|
19
86
|
*/
|
|
20
|
-
|
|
87
|
+
readTimeoutVerdict: () => Promise<PublishTimeoutVerdict>;
|
|
88
|
+
}
|
|
89
|
+
interface PublishWindowProbeOptions {
|
|
90
|
+
epoch: PublishLinkEpoch;
|
|
91
|
+
/**
|
|
92
|
+
* Reads how many messages the publisher still holds unsent — the wrapper's
|
|
93
|
+
* `queueLength()`. Required, not optional: a publisher that skipped it would
|
|
94
|
+
* silently inherit the pre-#139 verdict and drop messages again.
|
|
95
|
+
*/
|
|
96
|
+
sendQueueLength: () => number;
|
|
97
|
+
now?: () => number;
|
|
98
|
+
settleMs?: number;
|
|
21
99
|
}
|
|
22
100
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
101
|
+
* Watch a single publish's in-flight window: how long the event loop was
|
|
102
|
+
* starved, whether the link to the broker survived, and whether the message
|
|
103
|
+
* provably left the publisher's send queue.
|
|
104
|
+
*
|
|
105
|
+
* The starvation term runs a self-rescheduling timer and, crucially, also reads
|
|
106
|
+
* the pending gap synchronously when sampling stops: a stall that blocked the
|
|
107
|
+
* loop right up to that moment is caught by `now() - expected` even though the
|
|
108
|
+
* timer never got a chance to fire. That makes the reading immune to the very
|
|
109
|
+
* stall it measures and independent of callback ordering after the loop resumes.
|
|
110
|
+
*
|
|
111
|
+
* The send-queue term samples on the same tick, and the caller adds the sharpest
|
|
112
|
+
* reading of all through `observeSendQueue()` — the synchronous one taken right
|
|
113
|
+
* after the publisher accepted the message, which no stall can delay.
|
|
29
114
|
*
|
|
30
115
|
* The clock is monotonic (`performance.now`), never wall time — the operator's
|
|
31
116
|
* lag monitor uses the same, and a wall-clock step (NTP) must not read as
|
|
32
|
-
* starvation and suppress a legitimate retry. `now`
|
|
117
|
+
* starvation and suppress a legitimate retry. `now` and `settleMs` are
|
|
118
|
+
* injectable for tests.
|
|
33
119
|
*/
|
|
34
|
-
export declare function
|
|
35
|
-
now?: () => number;
|
|
36
|
-
}): LoopStarvationProbe;
|
|
120
|
+
export declare function createPublishWindowProbe({ epoch, sendQueueLength, now, settleMs, }: PublishWindowProbeOptions): PublishWindowProbe;
|
|
37
121
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
122
|
+
* The starvation term of the verdict — whether the loop was unresponsive long
|
|
123
|
+
* enough for the confirm deadline to be an artefact of the stall. On its own it
|
|
124
|
+
* is NOT a reason to suppress a re-send; see `createPublishWindowProbe`.
|
|
41
125
|
*/
|
|
42
126
|
export declare function isStarvedPublishTimeout(starvedMs: number): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* The error a non-delivered confirm deadline becomes. Shared so the operator and
|
|
129
|
+
* the task SDK report the same thing, and worded to say WHICH of the two failure
|
|
130
|
+
* shapes happened — a starved window whose link died reads as a healthy broker
|
|
131
|
+
* timing out unless the message says otherwise.
|
|
132
|
+
*
|
|
133
|
+
* The `RabbitMQ publish timed out` prefix is load-bearing:
|
|
134
|
+
* `isRetryablePublishError` matches on it.
|
|
135
|
+
*/
|
|
136
|
+
export declare function formatPublishTimeoutError({ starved, starvedMs, linkLost, leftSendQueue, }: PublishTimeoutVerdict): string;
|
|
43
137
|
export declare function isRetryablePublishError(error: unknown): boolean;
|
|
44
138
|
export declare function computeAmqpPublishRetryDelay(attempt: number): number;
|
|
139
|
+
export {};
|
|
45
140
|
//# sourceMappingURL=amqpPublishRetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqpPublishRetry.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/amqpPublishRetry.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,+BAA+B,QAAS,CAAA;AACrD,eAAO,MAAM,mCAAmC,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"amqpPublishRetry.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/amqpPublishRetry.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,+BAA+B,QAAS,CAAA;AACrD,eAAO,MAAM,mCAAmC,IAAI,CAAA;AAoEpD;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,OAAQ,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAA;AAEzC;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,MAAM,GAAG,IAAI,CAAA;AAElD,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,KAAK,EAAE,gBAAgB,CAAA;IACvB,iEAAiE;IACjE,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,kBAAkB,CAc7D;AAED,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;CACzD;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,gBAAgB,CAAA;IACvB;;;;OAIG;IACH,eAAe,EAAE,MAAM,MAAM,CAAA;IAC7B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,KAAK,EACL,eAAe,EACf,GAA6B,EAC7B,QAAiC,GAClC,EAAE,yBAAyB,GAAG,kBAAkB,CAuEhD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,WAExD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,OAAO,EACP,SAAS,EACT,QAAQ,EACR,aAAa,GACd,EAAE,qBAAqB,UAevB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,WAQrD;AAID,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,UAM3D"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* Curried on **arity**, never on the value — which is what the rest parameter
|
|
4
|
+
* buys over an optional one.
|
|
5
|
+
*
|
|
6
|
+
* It used to branch on `if (input)`, so a falsy second argument fell through to
|
|
7
|
+
* the curried arm and the caller was handed a predicate *function* instead of an
|
|
8
|
+
* answer. A function is truthy, so `if (!matchSchema(schema, value))` passed on
|
|
9
|
+
* exactly the input it was written to catch (a missing `correlationId`, an absent
|
|
10
|
+
* `taskId` header), and `if (matchSchema(schema, value))` fired on values that
|
|
11
|
+
* match nothing — `resolveAccept`'s unresolvable `#/definitions/…` hop reached
|
|
12
|
+
* `undefined.const` that way. The mirror image was just as wrong: `0`, `''` and
|
|
13
|
+
* `false` are legitimate values a guard must be able to say *yes* about, and
|
|
14
|
+
* `index: 0` is the first publish of every service message.
|
|
15
|
+
*/
|
|
2
16
|
export declare function matchSchema<Schema extends z.ZodSchema>(schema: Schema, input: unknown): input is z.infer<Schema>;
|
|
3
17
|
export declare function matchSchema<Schema extends z.ZodSchema>(schema: Schema): (input: unknown) => input is z.infer<Schema>;
|
|
4
18
|
//# sourceMappingURL=matchSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchSchema.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/matchSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC3B,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,GACb,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"matchSchema.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/matchSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC3B,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,GACb,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* The render payload a service publishes when a handler calls
|
|
4
|
+
* `context.render(ui, props)` — the wire shape shared by the service SDK
|
|
5
|
+
* (which composes it) and the operator (which parses it before emitting the
|
|
6
|
+
* render as a task update). See `knowledge/service-ui-surfaces.md`.
|
|
7
|
+
*
|
|
8
|
+
* `component.source` travels only on the **first** render of a given hash into a
|
|
9
|
+
* given task; later renders carry the hash alone, because ui/backend stores the
|
|
10
|
+
* bundle hash-addressed and that row outlives every render. A hash arriving
|
|
11
|
+
* without a source that ui/backend has never seen is an error state on the
|
|
12
|
+
* surface, not a silent fallback (D16).
|
|
13
|
+
*
|
|
14
|
+
* Per task rather than per connection because bundle retention is per task
|
|
15
|
+
* (D19): the last-referent sweep removes a bundle once no task references it, and
|
|
16
|
+
* a connection can outlive every task that referenced its component.
|
|
17
|
+
*
|
|
18
|
+
* Every field is deliberately a *top-level* key, because that is the granularity
|
|
19
|
+
* the size-triggered claim-check works at: it offloads a record body's largest
|
|
20
|
+
* top-level values first, and the publisher pins every one of these inline except
|
|
21
|
+
* `props`. So an oversized render always offloads `props` — the one value whose
|
|
22
|
+
* loss is a named error state rather than a broken surface. The source is capped
|
|
23
|
+
* at {@link MAX_UI_SOURCE_BYTES} anyway, well under the offload threshold, so the
|
|
24
|
+
* bundle always travels inline (D4).
|
|
25
|
+
*/
|
|
26
|
+
export declare const serviceRenderSchema: z.ZodObject<{
|
|
27
|
+
component: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
hash: z.ZodString;
|
|
30
|
+
source: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
props: z.ZodUnknown;
|
|
33
|
+
defaults: z.ZodOptional<z.ZodUnknown>;
|
|
34
|
+
surfaceId: z.ZodString;
|
|
35
|
+
devSession: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type ServiceRender = z.infer<typeof serviceRenderSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Hard cap on a UI component bundle, enforced when the component is registered
|
|
40
|
+
* (D4). Fits a self-contained React component, stays storable inline in
|
|
41
|
+
* Postgres, and fails fast on an accidental whole-app bundle.
|
|
42
|
+
*/
|
|
43
|
+
export declare const MAX_UI_SOURCE_BYTES: number;
|
|
44
|
+
/**
|
|
45
|
+
* The surface a render targets when it names none (D3). A node's surfaces are
|
|
46
|
+
* keyed by this id, so the default is a single surface per node/trace.
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_SURFACE_ID = "default";
|
|
49
|
+
/**
|
|
50
|
+
* Hard cap on one value a browser sends into a surface — a callback
|
|
51
|
+
* invocation's argument, or a deferred form's submitted response — enforced in
|
|
52
|
+
* ui/backend before either is published (D7).
|
|
53
|
+
*
|
|
54
|
+
* One number for both because they are the same thing arriving by two routes:
|
|
55
|
+
* viewer-authored bytes that reach service code, bounded before they enter the
|
|
56
|
+
* fabric. A response additionally has to fit the node's own output, which the
|
|
57
|
+
* operator enforces on the way in as it does for any service result.
|
|
58
|
+
*
|
|
59
|
+
* An interaction is exactly that — a click, a form submit, an approval — not
|
|
60
|
+
* a data transfer, and unlike a service's own publishes it crosses no outbound
|
|
61
|
+
* boundary: nothing offloads it, so its bytes reach the broker as they are. The
|
|
62
|
+
* cap is what keeps that true, and it is deliberately far below any message
|
|
63
|
+
* limit rather than tuned to one, so a task's `maxPayloadSize` can never make
|
|
64
|
+
* the difference between a usable synchronous rejection and a dropped AMQP
|
|
65
|
+
* connection.
|
|
66
|
+
*
|
|
67
|
+
* Lives here, next to {@link MAX_UI_SOURCE_BYTES}, rather than inside ui/backend:
|
|
68
|
+
* the browser is the other party that has to respect it, and when the surface
|
|
69
|
+
* host starts refusing an oversized argument before the round trip it should
|
|
70
|
+
* read the number from where the server enforces it, not restate it.
|
|
71
|
+
*/
|
|
72
|
+
export declare const MAX_SURFACE_INTERACTION_BYTES: number;
|
|
73
|
+
//# sourceMappingURL=serviceRender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceRender.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/serviceRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAkD9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAc,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,YAAY,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,6BAA6B,QAAY,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE SHARED YIELD RULE FOR LONG SYNCHRONOUS WORK (#134).
|
|
3
|
+
*
|
|
4
|
+
* A loop that does real CPU per item blocks every callback for its whole
|
|
5
|
+
* length — the AMQP heartbeat included. On 2026-08-07 that took the operator's
|
|
6
|
+
* connection down and lost every publish issued inside the dead window (#130).
|
|
7
|
+
* The fix in every such loop is the same shape: after each item, ask whether the
|
|
8
|
+
* current slice has run long enough, and if it has, hand the loop back.
|
|
9
|
+
*
|
|
10
|
+
* This is that rule, once. Two loops use it — `protocol/sliceTreeList.ts` (tree
|
|
11
|
+
* validation, the expensive one) and the operator's `machinePacker.unpack`
|
|
12
|
+
* (snapshot restore) — and any third should use it rather than re-time itself.
|
|
13
|
+
*
|
|
14
|
+
* It does NOT make work interruptible. A slice always overruns by the cost of
|
|
15
|
+
* the item that tripped it, because the item itself — an AJV compile, a msgpack
|
|
16
|
+
* decode — cannot be split part-way. The bound is `budgetMs` plus the single
|
|
17
|
+
* most expensive item, which is why the budget is set two orders of magnitude
|
|
18
|
+
* below the threshold anyone cares about.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* How long one uninterrupted slice may run before the loop yields.
|
|
22
|
+
*
|
|
23
|
+
* TIME, not a fixed item count, and that is deliberate: #134 asked for "every N
|
|
24
|
+
* items" picked by measurement, but N cannot hold the invariant that actually
|
|
25
|
+
* matters. Item cost spans four orders of magnitude across the callers — an edge
|
|
26
|
+
* validates in 0.004 ms, a service node with three JSON schemas in ~12 ms, a
|
|
27
|
+
* 20 kB snapshot payload in 0.01 ms — so any N tuned for one caller is wrong for
|
|
28
|
+
* the next. A time budget is the same rule expressed on the axis the loop cares
|
|
29
|
+
* about, and it makes N adaptive for free.
|
|
30
|
+
*
|
|
31
|
+
* 20 ms is two orders of magnitude below `LAG_WARN_THRESHOLD` (1000 ms in the
|
|
32
|
+
* operator's `utils/eventLoopLag.ts`), which leaves room for the overrun above.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SLICE_BUDGET_MS = 20;
|
|
35
|
+
export type SliceOptions = {
|
|
36
|
+
/** @see SLICE_BUDGET_MS */
|
|
37
|
+
budgetMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* How the loop hands control back. Injectable so a spec can count the yields
|
|
40
|
+
* instead of waiting for them.
|
|
41
|
+
*/
|
|
42
|
+
yieldToEventLoop?: () => Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
export type SliceStats = {
|
|
45
|
+
/** How many uninterrupted slices the work took. */
|
|
46
|
+
slices: number;
|
|
47
|
+
/** The longest of them, in ms — the stall the work actually caused. */
|
|
48
|
+
longestSliceMs: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The clock a sliced loop yields on. It measures the slice it is IN, so the
|
|
52
|
+
* reported worst slice includes the item that overran the budget — the honest
|
|
53
|
+
* number.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSliceClock(options?: SliceOptions): {
|
|
56
|
+
/** Called after every item. Yields only when the budget is spent. */
|
|
57
|
+
tick(): Promise<void>;
|
|
58
|
+
stats(): SliceStats;
|
|
59
|
+
};
|
|
60
|
+
export type SliceClock = ReturnType<typeof createSliceClock>;
|
|
61
|
+
//# sourceMappingURL=sliceClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliceClock.d.ts","sourceRoot":"","sources":["../../../../../../helpers/src/utils/sliceClock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,KAAK,CAAA;AAEjC,MAAM,MAAM,YAAY,GAAG;IACzB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAyBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,YAAiB;IASvD,qEAAqE;IAC/D,IAAI;IAWV,KAAK,IAAI,UAAU;EAOtB;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|