@cadenza.io/service 2.18.2 → 2.19.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.
Files changed (50) hide show
  1. package/README.md +258 -0
  2. package/dist/Cadenza-DCMs7q97.d.mts +1666 -0
  3. package/dist/Cadenza-DCMs7q97.d.ts +1666 -0
  4. package/dist/browser/chunk-4XOTT2KM.mjs +31 -0
  5. package/dist/browser/chunk-4XOTT2KM.mjs.map +1 -0
  6. package/dist/browser/index.js +15295 -7234
  7. package/dist/browser/index.js.map +1 -1
  8. package/dist/browser/index.mjs +15279 -7234
  9. package/dist/browser/index.mjs.map +1 -1
  10. package/dist/browser/nuxt/index.js +166 -0
  11. package/dist/browser/nuxt/index.js.map +1 -0
  12. package/dist/browser/nuxt/index.mjs +121 -0
  13. package/dist/browser/nuxt/index.mjs.map +1 -0
  14. package/dist/browser/react/index.js +179 -0
  15. package/dist/browser/react/index.js.map +1 -0
  16. package/dist/browser/react/index.mjs +140 -0
  17. package/dist/browser/react/index.mjs.map +1 -0
  18. package/dist/browser/vue/index.js +178 -0
  19. package/dist/browser/vue/index.js.map +1 -0
  20. package/dist/browser/vue/index.mjs +140 -0
  21. package/dist/browser/vue/index.mjs.map +1 -0
  22. package/dist/chunk-DBCS4XXY.mjs +31 -0
  23. package/dist/chunk-DBCS4XXY.mjs.map +1 -0
  24. package/dist/index.d.mts +244 -22947
  25. package/dist/index.d.ts +244 -22947
  26. package/dist/index.js +19432 -10213
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +19382 -10214
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/nuxt/index.d.mts +42 -0
  31. package/dist/nuxt/index.d.ts +42 -0
  32. package/dist/nuxt/index.js +173 -0
  33. package/dist/nuxt/index.js.map +1 -0
  34. package/dist/nuxt/index.mjs +121 -0
  35. package/dist/nuxt/index.mjs.map +1 -0
  36. package/dist/react/index.d.mts +52 -0
  37. package/dist/react/index.d.ts +52 -0
  38. package/dist/react/index.js +188 -0
  39. package/dist/react/index.js.map +1 -0
  40. package/dist/react/index.mjs +140 -0
  41. package/dist/react/index.mjs.map +1 -0
  42. package/dist/runtimeProjectionState-CitON2P3.d.mts +6 -0
  43. package/dist/runtimeProjectionState-CitON2P3.d.ts +6 -0
  44. package/dist/vue/index.d.mts +48 -0
  45. package/dist/vue/index.d.ts +48 -0
  46. package/dist/vue/index.js +187 -0
  47. package/dist/vue/index.js.map +1 -0
  48. package/dist/vue/index.mjs +140 -0
  49. package/dist/vue/index.mjs.map +1 -0
  50. package/package.json +64 -7
@@ -0,0 +1,1666 @@
1
+ import { Task, ThrottleTagGetter, Schema, GraphContext, AnyObject, InquiryOptions, TaskResult, GraphRoutine, SchemaDefinition, Actor, SignalBroker, InquiryBroker, GraphRunner, GraphRegistry, CadenzaMode, EmitOptions, Intent, RuntimeValidationPolicy, RuntimeValidationScope, TaskOptions, ActorSpec, ActorFactoryOptions, ActorDefinition, TaskFunction, DebounceOptions, DebounceTask, EphemeralTaskOptions, EphemeralTask } from '@cadenza.io/core';
2
+
3
+ /**
4
+ * Represents a task that delegates execution of a routine to a remote system or service.
5
+ * The `DeputyTask` serves as a proxy to perform and track the progress of a remote workflow.
6
+ * It extends the `Task` class with additional delegation capabilities.
7
+ *
8
+ * Emits various meta-signals for monitoring delegation progress and resolution.
9
+ */
10
+ declare class DeputyTask extends Task {
11
+ readonly isDeputy: boolean;
12
+ protected readonly remoteRoutineName: string;
13
+ protected serviceName: string | undefined;
14
+ registeredDeputyMap: boolean;
15
+ /**
16
+ * Constructs a new instance of the class with the specified parameters.
17
+ *
18
+ * @param {string} name - The name of the task.
19
+ * @param {string} remoteRoutineName - The name of the remote routine to delegate tasks to.
20
+ * @param {string | undefined} [serviceName=undefined] - The name of the service associated with the task.
21
+ * @param {string} [description=""] - A brief description of the task.
22
+ * @param {number} [concurrency=0] - The concurrency level of the task.
23
+ * @param {number} [timeout=0] - The timeout duration for the task.
24
+ * @param {boolean} [register=true] - Whether the task should be registered in the system.
25
+ * @param {boolean} [isUnique=false] - Whether the task is unique.
26
+ * @param {boolean} [isMeta=false] - Whether the task is a meta task.
27
+ * @param {boolean} [isSubMeta=false] - Whether the task is a sub-meta task.
28
+ * @param {boolean} [isHidden=false] - Whether the task is hidden from the system.
29
+ * @param {ThrottleTagGetter | undefined} [getTagCallback=undefined] - A callback function to retrieve throttle tags.
30
+ * @param {SchemaDefinition | undefined} [inputSchema=undefined] - The input schema definition for the task.
31
+ * @param {boolean} [validateInputContext=false] - Whether to validate the input context against the input schema.
32
+ * @param {SchemaDefinition | undefined} [outputSchema=undefined] - The output schema definition for the task.
33
+ * @param {boolean} [validateOutputContext=false] - Whether to validate the output context against the output schema.
34
+ * @param {number} [retryCount=0] - The number of retries allowed for task execution.
35
+ * @param {number} [retryDelay=0] - The initial delay between retries in milliseconds.
36
+ * @param {number} [retryDelayMax=0] - The maximum retry delay in milliseconds.
37
+ * @param {number} [retryDelayFactor=1] - The factor by which to increase the retry delay for subsequent retries.
38
+ * @return {void} This constructor does not return a value.
39
+ */
40
+ constructor(name: string, remoteRoutineName: string, serviceName?: string | undefined, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema | undefined, validateInputContext?: boolean, outputSchema?: Schema | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
41
+ /**
42
+ * Executes the specified task function within the provided execution context.
43
+ *
44
+ * @param {GraphContext} context - The execution context containing methods and metadata for task execution.
45
+ * @param {function(string, AnyObject): void} emit - A function for emitting signals with associated data during execution.
46
+ * @param inquire
47
+ * @param {function(number): void} progressCallback - A callback function to report progress updates during task processing.
48
+ * @param {{ nodeId: string, routineExecId: string }} nodeData - Object containing identifiers for the node and routine execution.
49
+ * @return {TaskResult} Returns the result of the task function execution.
50
+ */
51
+ execute(context: GraphContext, emit: (signal: string, ctx: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
52
+ nodeId: string;
53
+ routineExecId: string;
54
+ }): TaskResult;
55
+ }
56
+
57
+ type DbOperationType$1 = "query" | "insert" | "update" | "delete";
58
+ type QueryMode = "rows" | "count" | "exists" | "one" | "aggregate";
59
+ type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
60
+ interface AggregateDefinition {
61
+ fn: AggregateFunction;
62
+ field?: string;
63
+ as?: string;
64
+ distinct?: boolean;
65
+ }
66
+ type SortDirection = "asc" | "desc";
67
+ interface JoinDefinition {
68
+ on: string;
69
+ fields: string[];
70
+ returnAs?: "array" | "object";
71
+ filter?: AnyObject;
72
+ alias?: string;
73
+ joins?: Record<string, JoinDefinition>;
74
+ }
75
+ type SubOperationType = "insert" | "query";
76
+ interface SubOperation {
77
+ subOperation: SubOperationType;
78
+ table: string;
79
+ data?: AnyObject | AnyObject[];
80
+ filter?: AnyObject;
81
+ fields?: string[];
82
+ return?: string;
83
+ }
84
+ interface OnConflictAction {
85
+ do: "nothing" | "update";
86
+ set?: Record<string, any>;
87
+ where?: string;
88
+ }
89
+ type OpEffect = "increment" | "decrement" | "set";
90
+ type ValueOrSubOp = any | SubOperation | OpEffect;
91
+ type ValueOrList = any | any[];
92
+ interface DbOperationPayload {
93
+ data?: Record<string, ValueOrSubOp> | Record<string, ValueOrSubOp>[];
94
+ filter?: Record<string, ValueOrList>;
95
+ fields?: string[];
96
+ joins?: Record<string, JoinDefinition>;
97
+ queryMode?: QueryMode;
98
+ aggregates?: AggregateDefinition[];
99
+ groupBy?: string[];
100
+ sort?: Record<string, SortDirection>;
101
+ limit?: number;
102
+ offset?: number;
103
+ transaction?: boolean;
104
+ batch?: boolean;
105
+ onConflict?: {
106
+ target: string[];
107
+ action: OnConflictAction;
108
+ };
109
+ }
110
+
111
+ /**
112
+ * Represents a specialized task for delegating database operations. Extends `DeputyTask`.
113
+ * This class is designed to abstract database operation requests, delegating execution to a meta-layer system.
114
+ */
115
+ declare class DatabaseTask extends DeputyTask {
116
+ private readonly queryData;
117
+ /**
118
+ * Constructs an instance of the class with the provided parameters, defining
119
+ * various configuration options and behaviors for the task.
120
+ *
121
+ * @param {string} name - The unique name of the task.
122
+ * @param {string} taskName - The specific name of the task.
123
+ * @param {string | undefined} serviceName - The associated service name. Defaults to undefined.
124
+ * @param {string} description - A brief description of the task. Defaults to an empty string.
125
+ * @param {DbOperationPayload} queryData - The data payload for database operations.
126
+ * @param {number} concurrency - The level of concurrency allowed. Defaults to 0.
127
+ * @param {number} timeout - The timeout duration in milliseconds. Defaults to 0.
128
+ * @param {boolean} register - A flag indicating whether to register the task. Defaults to true.
129
+ * @param {boolean} isUnique - Indicates if the task instance is unique. Defaults to false.
130
+ * @param {boolean} isMeta - Indicates if the task is meta. Defaults to false.
131
+ * @param {boolean} isSubMeta - Indicates if the task is a sub-meta task. Defaults to false.
132
+ * @param {boolean} isHidden - Indicates if the task is hidden. Defaults to false.
133
+ * @param {ThrottleTagGetter | undefined} getTagCallback - A callback used for throttling. Defaults to undefined.
134
+ * @param {SchemaDefinition | undefined} inputSchema - The schema definition for input validation. Defaults to undefined.
135
+ * @param {boolean} validateInputContext - Whether to validate the input context. Defaults to false.
136
+ * @param {SchemaDefinition | undefined} outputSchema - The schema definition for output validation. Defaults to undefined.
137
+ * @param {boolean} validateOutputContext - Whether to validate the output context. Defaults to false.
138
+ * @param {number} retryCount - The maximum number of retry attempts. Defaults to 0.
139
+ * @param {number} retryDelay - The delay between retries in milliseconds. Defaults to 0.
140
+ * @param {number} retryDelayMax - The maximum delay between retries in milliseconds. Defaults to 0.
141
+ * @param {number} retryDelayFactor - The factor for exponential backoff. Defaults to 1.
142
+ * @return {void}
143
+ */
144
+ constructor(name: string, taskName: string, serviceName: string | undefined, description: string | undefined, queryData: DbOperationPayload, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema | undefined, validateInputContext?: boolean, outputSchema?: Schema | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
145
+ /**
146
+ * Executes the specified task within the given context.
147
+ *
148
+ * @param {GraphContext} context - The execution context for the current task, which includes data and metadata required for processing.
149
+ * @param {(signal: string, ctx: AnyObject) => void} emit - A function used to send signals or events during task execution.
150
+ * @param inquire
151
+ * @param {(progress: number) => void} progressCallback - A function to report execution progress as a percentage (0-100).
152
+ * @param {{ nodeId: string; routineExecId: string }} nodeData - An object containing identifiers for the current node and routine execution.
153
+ * @return {TaskResult} The result of the task execution.
154
+ */
155
+ execute(context: GraphContext, emit: (signal: string, ctx: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
156
+ nodeId: string;
157
+ routineExecId: string;
158
+ }): TaskResult;
159
+ }
160
+
161
+ interface InquiryResponderDescriptor {
162
+ isRemote: boolean;
163
+ serviceName: string;
164
+ taskName: string;
165
+ taskVersion: number;
166
+ localTaskName: string;
167
+ }
168
+ interface InquiryResponderStatus extends InquiryResponderDescriptor {
169
+ status: "fulfilled" | "failed" | "timed_out";
170
+ durationMs: number;
171
+ error?: string;
172
+ }
173
+ interface DistributedInquiryMeta {
174
+ inquiry: string;
175
+ isMetaInquiry: boolean;
176
+ totalResponders: number;
177
+ eligibleResponders: number;
178
+ filteredOutResponders: number;
179
+ responded: number;
180
+ failed: number;
181
+ timedOut: number;
182
+ pending: number;
183
+ durationMs: number;
184
+ responders: InquiryResponderStatus[];
185
+ }
186
+ type DistributedInquiryOptions = Partial<InquiryOptions> & {
187
+ /**
188
+ * Total timeout budget for the whole inquiry fan-out.
189
+ * Falls back to InquiryOptions.timeout when not set.
190
+ */
191
+ overallTimeoutMs?: number;
192
+ /**
193
+ * If true, reject on timeout / partial completion.
194
+ * If false (default), resolve with partial result and metadata.
195
+ */
196
+ requireComplete?: boolean;
197
+ /**
198
+ * Timeout propagated to responder execution context (__timeout).
199
+ * Mainly used by distributed deputy responders.
200
+ */
201
+ perResponderTimeoutMs?: number;
202
+ /**
203
+ * Optional hydration cache key used to consume one SSR-provided inquiry result
204
+ * before the live frontend runtime performs normal distributed routing.
205
+ */
206
+ hydrationKey?: string;
207
+ };
208
+
209
+ type RuntimeStatusState = "healthy" | "degraded" | "overloaded" | "unavailable";
210
+
211
+ type ServiceTransportRole = "internal" | "public";
212
+ type ServiceTransportProtocol = "rest" | "socket";
213
+ type ServiceTransportSecurityProfile = "low" | "medium" | "high";
214
+ interface ServiceTransportConfig {
215
+ role: ServiceTransportRole;
216
+ origin: string;
217
+ protocols?: ServiceTransportProtocol[];
218
+ securityProfile?: ServiceTransportSecurityProfile | null;
219
+ authStrategy?: string | null;
220
+ }
221
+ interface ServiceTransportDescriptor {
222
+ uuid: string;
223
+ serviceInstanceId: string;
224
+ role: ServiceTransportRole;
225
+ origin: string;
226
+ protocols: ServiceTransportProtocol[];
227
+ securityProfile: ServiceTransportSecurityProfile | null;
228
+ authStrategy: string | null;
229
+ deleted?: boolean;
230
+ clientCreated?: boolean;
231
+ }
232
+
233
+ interface ServiceInstanceDescriptor {
234
+ uuid: string;
235
+ serviceName: string;
236
+ numberOfRunningGraphs?: number;
237
+ isPrimary: boolean;
238
+ isActive: boolean;
239
+ isNonResponsive: boolean;
240
+ isBlocked: boolean;
241
+ runtimeState?: RuntimeStatusState;
242
+ acceptingWork?: boolean;
243
+ reportedAt?: string;
244
+ health: AnyObject;
245
+ isFrontend: boolean;
246
+ isDatabase?: boolean;
247
+ isBootstrapPlaceholder?: boolean;
248
+ transports: ServiceTransportDescriptor[];
249
+ clientCreatedTransportIds?: string[];
250
+ clientPendingTransportIds?: string[];
251
+ clientReadyTransportIds?: string[];
252
+ }
253
+
254
+ declare const AUTHORITY_RUNTIME_STATUS_REPORT_INTENT = "meta-service-registry-authority-runtime-status-report";
255
+ declare const RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL = "meta.service_registry.runtime_status_authority_sync_requested";
256
+ interface RuntimeMetricsHealthDetail {
257
+ sampledAt?: string;
258
+ cpuUsage?: number | null;
259
+ memoryUsage?: number | null;
260
+ eventLoopLag?: number | null;
261
+ rssBytes?: number | null;
262
+ heapUsedBytes?: number | null;
263
+ heapTotalBytes?: number | null;
264
+ memoryLimitBytes?: number | null;
265
+ }
266
+ interface AuthorityRuntimeStatusReport {
267
+ serviceName: string;
268
+ serviceInstanceId: string;
269
+ transportId?: string;
270
+ transportRole?: ServiceTransportRole;
271
+ transportOrigin?: string;
272
+ transportProtocols?: ServiceTransportProtocol[];
273
+ isFrontend?: boolean;
274
+ reportedAt: string;
275
+ state: RuntimeStatusState;
276
+ acceptingWork: boolean;
277
+ numberOfRunningGraphs: number;
278
+ cpuUsage?: number | null;
279
+ memoryUsage?: number | null;
280
+ eventLoopLag?: number | null;
281
+ isActive: boolean;
282
+ isNonResponsive: boolean;
283
+ isBlocked: boolean;
284
+ health?: AnyObject;
285
+ }
286
+ declare function normalizeAuthorityRuntimeStatusReport(input: Record<string, any> | null | undefined): AuthorityRuntimeStatusReport | null;
287
+ declare function buildAuthorityRuntimeStatusSignature(report: AuthorityRuntimeStatusReport): string;
288
+
289
+ interface DeputyDescriptor {
290
+ serviceName: string;
291
+ remoteRoutineName?: string;
292
+ signalName?: string;
293
+ localTaskName: string;
294
+ communicationType: string;
295
+ }
296
+ /**
297
+ * The ServiceRegistry class is a singleton that manages the registration and lifecycle of
298
+ * service instances, deputies, and remote signals in a distributed service architecture.
299
+ * It handles various tasks such as instance updates, remote signal registration,
300
+ * service status synchronization, and error/event broadcasting.
301
+ */
302
+ declare class ServiceRegistry {
303
+ private static _instance;
304
+ static get instance(): ServiceRegistry;
305
+ private instances;
306
+ private remoteRoutesByKey;
307
+ private localInstanceSeed;
308
+ private deputies;
309
+ private remoteSignals;
310
+ private remoteIntents;
311
+ private gatheredSyncTransmissionServices;
312
+ private remoteIntentDeputiesByKey;
313
+ private remoteIntentDeputiesByTask;
314
+ private dependeesByService;
315
+ private dependeeByInstance;
316
+ private readinessDependeesByService;
317
+ private readinessDependeeByInstance;
318
+ private lastHeartbeatAtByInstance;
319
+ private missedHeartbeatsByInstance;
320
+ private runtimeStatusFallbackInFlightByInstance;
321
+ private runtimeStatusRestRefreshInFlightByInstance;
322
+ private routingCooldownsByKey;
323
+ private transportFailuresByKey;
324
+ private activeRoutineExecutionIds;
325
+ private runtimeStatusHeartbeatStarted;
326
+ private runtimeMetricsSamplingStarted;
327
+ private lastRuntimeStatusSnapshot;
328
+ private lastPeerRuntimeStatusSnapshot;
329
+ private latestRuntimeMetricsSnapshot;
330
+ private readonly runtimeMetricsSampler;
331
+ private readonly runtimeStatusHeartbeatIntervalMs;
332
+ private readonly runtimeMetricsSampleIntervalMs;
333
+ private readonly runtimeStatusRestRefreshIntervalMs;
334
+ private readonly runtimeStatusMissThreshold;
335
+ private readonly runtimeStatusFallbackTimeoutMs;
336
+ private readonly runtimeStatusAuthorityReportTimeoutMs;
337
+ private readonly runtimeStatusInactiveMissThreshold;
338
+ private readonly noRouteCooldownFailureThreshold;
339
+ private readonly noRouteCooldownWindowMs;
340
+ private readonly noRouteCooldownMs;
341
+ private readonly transportFailureThreshold;
342
+ private readonly transportFailureWindowMs;
343
+ private readonly routeFailurePenaltyMs;
344
+ private readonly degradedGraphThreshold;
345
+ private readonly overloadedGraphThreshold;
346
+ serviceName: string | null;
347
+ serviceInstanceId: string | null;
348
+ numberOfRunningGraphs: number;
349
+ useSocket: boolean;
350
+ retryCount: number;
351
+ isFrontend: boolean;
352
+ connectsToCadenzaDB: boolean;
353
+ private bootstrapFullSyncRetryTimer;
354
+ private bootstrapFullSyncRetryIndex;
355
+ private bootstrapFullSyncRetryGeneration;
356
+ private bootstrapFullSyncSatisfied;
357
+ private bootstrapFullSyncRetryReason;
358
+ private knownGlobalSignalMaps;
359
+ private authorityBootstrapRoute;
360
+ private authorityBootstrapHandshakeInFlight;
361
+ handleInstanceUpdateTask: Task;
362
+ handleTransportUpdateTask: Task;
363
+ handleGlobalSignalRegistrationTask: Task;
364
+ handleGlobalIntentRegistrationTask: Task;
365
+ reconcileGatheredSyncTransmissionsTask: Task;
366
+ handleSocketStatusUpdateTask: Task;
367
+ fullSyncTask: GraphRoutine | Task;
368
+ getAllInstances: Task;
369
+ doForEachInstance: Task;
370
+ deleteInstance: Task;
371
+ getBalancedInstance: Task;
372
+ getInstanceById: Task;
373
+ getInstancesByServiceName: Task;
374
+ handleDeputyRegistrationTask: Task;
375
+ getStatusTask: Task;
376
+ insertServiceTask: Task;
377
+ insertServiceInstanceTask: Task;
378
+ insertServiceTransportTask: Task;
379
+ handleServiceNotRespondingTask: Task;
380
+ handleServiceHandshakeTask: Task;
381
+ collectTransportDiagnosticsTask: Task;
382
+ collectReadinessTask: Task;
383
+ private authorityFullSyncResponderTask;
384
+ private authorityServiceCommunicationPersistenceTask;
385
+ private readonly localLifecycleFlushActor;
386
+ private collectBootstrapFullSyncPayload;
387
+ private buildRemoteIntentDeputyKey;
388
+ private readArrayPayload;
389
+ private normalizeSignalMaps;
390
+ private rememberKnownGlobalSignalMaps;
391
+ private applyGlobalSignalRegistrations;
392
+ reconcileKnownGlobalSignalRegistrations(): boolean;
393
+ private normalizeIntentMaps;
394
+ private normalizeServiceInstancesFromSync;
395
+ private shouldReconcileGatheredSyncTransmissions;
396
+ private collectGatheredSyncTransmissionRecipients;
397
+ private reconcileGatheredSyncTransmissions;
398
+ seedAuthorityBootstrapRoute(origin: string, role?: ServiceTransportRole): void;
399
+ private noteAuthorityBootstrapHandshake;
400
+ private getAuthorityBootstrapRestTarget;
401
+ hasAuthorityBootstrapHandshakeEstablished(): boolean;
402
+ private invalidateAuthorityBootstrapHandshake;
403
+ private requestAuthorityBootstrapHandshake;
404
+ private invokeAuthorityBootstrapRoutine;
405
+ private registerRemoteIntentDeputy;
406
+ private unregisterRemoteIntentDeputy;
407
+ ensureAuthorityFullSyncResponderTask(): Task | null;
408
+ ensureAuthorityServiceCommunicationPersistenceTask(): Task | null;
409
+ private registerBootstrapFullSyncDeputies;
410
+ ensureBootstrapAuthorityControlPlaneForInquiry(intentName: string, ctx?: AnyObject): boolean;
411
+ private ensureBootstrapAuthorityControlPlane;
412
+ private hasBootstrapFullSyncDeputies;
413
+ private ensureAuthorityBootstrapSignalTransmissions;
414
+ private clearBootstrapFullSyncRetryTimer;
415
+ private invalidateBootstrapFullSyncRetryState;
416
+ private markBootstrapFullSyncSatisfied;
417
+ private hasHealthyBootstrapFullSyncResult;
418
+ private scheduleNextBootstrapFullSyncRetry;
419
+ private restartBootstrapFullSyncRetryChain;
420
+ bootstrapFullSync(emit: (signal: string, ctx: AnyObject) => void, ctx?: AnyObject, reason?: string): boolean;
421
+ getInquiryResponderDescriptor(task: Task): InquiryResponderDescriptor;
422
+ private getInstance;
423
+ private getLocalInstance;
424
+ hasLocalInstanceRegistered(): boolean;
425
+ seedLocalInstance(value: unknown, options?: {
426
+ markTransportsReady?: boolean;
427
+ }): ServiceInstanceDescriptor | null;
428
+ private summarizeTransportForDebug;
429
+ private summarizeInstanceForRuntimeStatusFallback;
430
+ private summarizeRuntimeStatusInquiryReports;
431
+ private createRuntimeStatusFallbackError;
432
+ resolveLocalStatusCheck(ctx?: AnyObject): {
433
+ __status: string;
434
+ __error: string;
435
+ errored: boolean;
436
+ } | {
437
+ __status: string;
438
+ __serviceName: string;
439
+ __serviceInstanceId: string;
440
+ __numberOfRunningGraphs: number;
441
+ __health: AnyObject;
442
+ __active: boolean;
443
+ cpuUsage: number | null;
444
+ memoryUsage: number | null;
445
+ eventLoopLag: number | null;
446
+ reportedAt: string;
447
+ serviceName: string;
448
+ serviceInstanceId: string;
449
+ numberOfRunningGraphs: number;
450
+ health: AnyObject;
451
+ isActive: boolean;
452
+ isNonResponsive: boolean;
453
+ isBlocked: boolean;
454
+ state: RuntimeStatusState;
455
+ acceptingWork: boolean;
456
+ __error?: undefined;
457
+ errored?: undefined;
458
+ };
459
+ private resolveTransportProtocolOrder;
460
+ private selectTransportForInstance;
461
+ private selectReadyTransportForInstance;
462
+ private getRoutingTransportRole;
463
+ private getPreferredRoutingProtocol;
464
+ private buildRoutingCooldownKey;
465
+ private getActiveRoutingCooldown;
466
+ private recordRoutingFailure;
467
+ private clearRoutingCooldown;
468
+ private hasRouteableInstanceForRouting;
469
+ private refreshRoutingCooldownsForService;
470
+ private buildTransportFailureKey;
471
+ private clearTransportFailureState;
472
+ private classifyTransportFailureKind;
473
+ private getTransportFailureThreshold;
474
+ private recordTransportFailure;
475
+ private findInstanceByTransportId;
476
+ private resolveRouteRecordFromContext;
477
+ private isCurrentRouteContext;
478
+ private maybeDemoteFailedTransport;
479
+ private getTransportById;
480
+ private getRouteableTransport;
481
+ private getTransportClientKey;
482
+ private resolveCommunicationTypesForService;
483
+ private ensureDependeeClientForInstance;
484
+ private ensureDependeeClientsForService;
485
+ private scheduleDependeeClientRecovery;
486
+ private shouldEagerlyEstablishRemoteClients;
487
+ private shouldDemandEstablishRemoteClients;
488
+ private buildTransportRouteKey;
489
+ private buildTransportProtocolHandleKey;
490
+ private resolveProtocolFromContext;
491
+ private ensureRouteProtocolState;
492
+ private cloneRouteBalancingState;
493
+ private resolveRouteDispatchToken;
494
+ private getNumericHealthMetric;
495
+ private compareOptionalBalancingMetric;
496
+ private buildRouteBalancingSnapshot;
497
+ private compareRouteBalancingSnapshots;
498
+ private markRouteDispatchSelected;
499
+ private markRouteDispatchCompleted;
500
+ recordBalancedRouteSelection(routeKey: string, ctx: AnyObject): void;
501
+ recordBalancedRouteOutcome(ctx: AnyObject, outcome: "success" | "failure" | "neutral"): void;
502
+ private matchesSignalBroadcastFilter;
503
+ private routeHasProtocolState;
504
+ private syncInstanceClientRouteState;
505
+ private findRemoteRouteRecordByTransportId;
506
+ private upsertRemoteRouteRecord;
507
+ private clearRemoteRouteRecordIfCurrent;
508
+ private emitTransportHandleShutdowns;
509
+ private resolveTransportRouteKey;
510
+ private hasTransportClientCreated;
511
+ private markTransportClientPending;
512
+ private hasTransportClientReady;
513
+ private hasReadyClientTransportForProtocol;
514
+ private hasAnyReadyClientProtocolForTransport;
515
+ private markTransportClientReady;
516
+ private clearTransportClientState;
517
+ shouldProcessRemoteRouteEvent(ctx: AnyObject): boolean;
518
+ private resolveRequiredReadinessFromCommunicationTypes;
519
+ private markTransportReadyFromContext;
520
+ private clearTransportReadyFromContext;
521
+ private registerDependee;
522
+ private unregisterDependee;
523
+ private getInstanceRouteRole;
524
+ private findSupersededInstancesForTransport;
525
+ private compareInstancesForRoutePrecedence;
526
+ private hasReadyTransportForRoute;
527
+ private retireSupersededInstancesForTransport;
528
+ private shouldRetireSupersededInstancesForTransport;
529
+ private hydrateAuthorityInstanceForTransport;
530
+ private reconcileBootstrapPlaceholderInstance;
531
+ private adoptBootstrapPlaceholderInstanceId;
532
+ private getHeartbeatMisses;
533
+ private getRuntimeStatusInactiveThreshold;
534
+ private buildGracefulShutdownTransportDeactivationContext;
535
+ private applyInstanceLifecycleState;
536
+ private emitInstanceLifecyclePersistence;
537
+ private deactivateInstanceTransports;
538
+ private emitTransportDeletionPersistence;
539
+ private markInstanceInactive;
540
+ private handleLocalInboundActivity;
541
+ private handleRemoteActivityObserved;
542
+ private resolveRouteFreshnessTimestamp;
543
+ private collapseInstancesByRouteOrigin;
544
+ private shouldRequireReadinessFromCommunicationTypes;
545
+ private resolveRuntimeStatusSnapshot;
546
+ private captureRuntimeMetricsSample;
547
+ private getLatestRuntimeMetricsSnapshot;
548
+ private buildRuntimeMetricsHealthPayload;
549
+ private stripRuntimeStatusReportForPeer;
550
+ private buildPeerRuntimeStatusSnapshot;
551
+ private hasSignificantPeerRuntimeStatusChange;
552
+ private readRuntimeStatusMetric;
553
+ private normalizeRuntimeStatusReport;
554
+ private applyRuntimeStatusReport;
555
+ private retireLocalRemoteInstance;
556
+ private applyRuntimeStatusIdentityReplacement;
557
+ applyAuthorityRuntimeStatusReport(report: AuthorityRuntimeStatusReport): boolean;
558
+ private buildLocalRuntimeStatusReport;
559
+ private selectRuntimeStatusReportForTarget;
560
+ private resolveRuntimeStatusFallbackInquiry;
561
+ private requestRuntimeStatusViaRest;
562
+ private shouldRefreshRuntimeStatusViaRest;
563
+ private getAuthorityRestTransport;
564
+ private delegateAuthorityLifecycleUpdate;
565
+ reportLocalShutdownToAuthority(reason: string, timeoutMs: number): Promise<boolean>;
566
+ private evaluateDependencyReadinessDetail;
567
+ private buildLocalReadinessReport;
568
+ /**
569
+ * Initializes a private constructor for managing service instances, remote signals,
570
+ * service health, and handling updates or synchronization tasks. The constructor
571
+ * creates a variety of meta tasks that process different lifecycle events and
572
+ * service-related updates in a distributed service registry model.
573
+ *
574
+ * @return {Object} An instance of the constructed class with initialized tasks
575
+ * and state management necessary to process service-related events.
576
+ */
577
+ private constructor();
578
+ reset(): void;
579
+ }
580
+
581
+ /**
582
+ * Represents a task responsible for transmitting signals to a remote service
583
+ * through the meta-layer for operations delegation.
584
+ *
585
+ * @class
586
+ * @extends Task
587
+ */
588
+ declare class SignalTransmissionTask extends Task {
589
+ readonly isDeputy: boolean;
590
+ protected readonly signalName: string;
591
+ protected readonly serviceName: string;
592
+ /**
593
+ * Constructs a new instance of the class and initializes it with the provided parameters.
594
+ *
595
+ * @param {string} name - The name of the task being created.
596
+ * @param {string} signalName - The name of the signal associated with this task.
597
+ * @param {string} serviceName - The name of the service associated with this task.
598
+ * @param {string} [description=""] - An optional description of the task.
599
+ * @param {number} [concurrency=0] - The maximum allowed concurrency for this task.
600
+ * @param {number} [timeout=0] - The maximum execution time for this task, in milliseconds.
601
+ * @param {boolean} [register=true] - Whether the task should be registered upon creation.
602
+ * @param {boolean} [isUnique=false] - Indicates if the task should enforce uniqueness.
603
+ * @param {boolean} [isMeta=false] - Specifies if the task is a meta-task.
604
+ * @param {boolean} [isSubMeta=false] - Specifies if the task is a sub-meta-task.
605
+ * @param {boolean} [isHidden=false] - Indicates if the task is hidden from visibility.
606
+ * @param {ThrottleTagGetter|undefined} [getTagCallback=undefined] - A callback for tag throttling logic.
607
+ * @param {SchemaDefinition|undefined} [inputSchema=undefined] - An optional schema for validating input data.
608
+ * @param {boolean} [validateInputContext=false] - Whether to validate the input context against the input schema.
609
+ * @param {SchemaDefinition|undefined} [outputSchema=undefined] - An optional schema for validating output data.
610
+ * @param {boolean} [validateOutputContext=false] - Whether to validate the output context against the output schema.
611
+ * @param {number} [retryCount=0] - The number of retry attempts allowed in case of task failure.
612
+ * @param {number} [retryDelay=0] - The initial delay before retrying a failed task, in milliseconds.
613
+ * @param {number} [retryDelayMax=0] - The maximum delay between retry attempts, in milliseconds.
614
+ * @param {number} [retryDelayFactor=1] - A multiplier applied to retry delay for exponential backoff.
615
+ * @return {void} Does not return a value.
616
+ */
617
+ constructor(name: string, signalName: string, serviceName: string, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema | undefined, validateInputContext?: boolean, outputSchema?: Schema | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
618
+ /**
619
+ * Executes the given task function within the provided execution context.
620
+ *
621
+ * @param {GraphContext} context - The context object providing the graph execution environment and metadata.
622
+ * @param {Function} emit - A function to emit signals with the provided name and context.
623
+ * @param inquire
624
+ * @param {Function} progressCallback - A callback function to report the progress of the task execution as a number between 0 and 1.
625
+ * @return {TaskResult} The result of the executed task function.
626
+ */
627
+ execute(context: GraphContext, emit: (signal: string, ctx: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void): TaskResult;
628
+ }
629
+
630
+ type SchemaType = "varchar" | "text" | "int" | "bigint" | "decimal" | "boolean" | "array" | "object" | "jsonb" | "uuid" | "timestamp" | "date" | "geo_point" | "bytea" | "any";
631
+ type SchemaConstraints = {
632
+ min?: number;
633
+ max?: number;
634
+ minLength?: number;
635
+ maxLength?: number;
636
+ pattern?: string;
637
+ enum?: any[];
638
+ multipleOf?: number;
639
+ format?: "email" | "url" | "date-time" | "uuid" | "custom";
640
+ oneOf?: any[];
641
+ appendOnly?: boolean;
642
+ check?: string;
643
+ precision?: number;
644
+ scale?: number;
645
+ };
646
+ interface FieldDefinition {
647
+ type: SchemaType;
648
+ primary?: boolean;
649
+ index?: boolean;
650
+ unique?: boolean;
651
+ default?: any;
652
+ required?: boolean;
653
+ nullable?: boolean;
654
+ encrypted?: boolean;
655
+ constraints?: SchemaConstraints;
656
+ references?: string;
657
+ items?: FieldDefinition;
658
+ description?: string;
659
+ generated?: "uuid" | "timestamp" | "now" | "autoIncrement";
660
+ onDelete?: "cascade" | "set null" | "no action" | "set default" | "restrict";
661
+ onUpdate?: "cascade" | "set null" | "no action" | "set default";
662
+ }
663
+ type DbOperationType = "query" | "insert" | "update" | "delete";
664
+ interface TableDefinition {
665
+ fields: Record<string, FieldDefinition>;
666
+ meta?: {
667
+ description?: string;
668
+ tags?: string[];
669
+ shardKey?: string;
670
+ partitionHint?: string;
671
+ appendOnly?: boolean;
672
+ encryptedFields?: string[];
673
+ };
674
+ indexes?: string[][];
675
+ uniqueConstraints?: string[][];
676
+ primaryKey?: string[];
677
+ fullTextIndexes?: string[][];
678
+ foreignKeys?: {
679
+ tableName: string;
680
+ fields: string[];
681
+ referenceFields: string[];
682
+ onDelete?: "cascade" | "set null" | "no action";
683
+ }[];
684
+ triggers?: Record<string, {
685
+ when: "before" | "after";
686
+ event: "insert" | "update" | "delete";
687
+ function: string;
688
+ }>;
689
+ customSignals?: {
690
+ triggers?: {
691
+ [key in DbOperationType]?: (string | {
692
+ signal: string;
693
+ condition?: (ctx: AnyObject) => boolean;
694
+ queryData?: DbOperationPayload;
695
+ })[];
696
+ };
697
+ emissions?: {
698
+ [key in DbOperationType]?: (string | {
699
+ signal: string;
700
+ condition?: (ctx: AnyObject) => boolean;
701
+ })[];
702
+ };
703
+ };
704
+ customIntents?: {
705
+ query?: (string | {
706
+ intent: string;
707
+ description?: string;
708
+ input?: SchemaDefinition;
709
+ })[];
710
+ insert?: (string | {
711
+ intent: string;
712
+ description?: string;
713
+ input?: SchemaDefinition;
714
+ })[];
715
+ update?: (string | {
716
+ intent: string;
717
+ description?: string;
718
+ input?: SchemaDefinition;
719
+ })[];
720
+ delete?: (string | {
721
+ intent: string;
722
+ description?: string;
723
+ input?: SchemaDefinition;
724
+ })[];
725
+ };
726
+ initialData?: {
727
+ fields: string[];
728
+ data: any[][];
729
+ };
730
+ }
731
+ interface DatabaseMigrationPolicy {
732
+ baselineOnEmpty?: boolean;
733
+ adoptExistingVersion?: number | null;
734
+ allowDestructive?: boolean;
735
+ transactionalMode?: "per_migration" | "none";
736
+ }
737
+ type DatabaseMigrationConstraintDefinition = {
738
+ kind: "primaryKey";
739
+ fields: string[];
740
+ } | {
741
+ kind: "unique";
742
+ fields: string[];
743
+ } | {
744
+ kind: "foreignKey";
745
+ fields: string[];
746
+ referenceTable: string;
747
+ referenceFields: string[];
748
+ onDelete?: "cascade" | "set null" | "no action";
749
+ } | {
750
+ kind: "check";
751
+ expression: string;
752
+ } | {
753
+ kind: "sql";
754
+ sql: string;
755
+ };
756
+ type DatabaseMigrationStep = {
757
+ kind: "createTable";
758
+ table: string;
759
+ definition: TableDefinition;
760
+ } | {
761
+ kind: "dropTable";
762
+ table: string;
763
+ ifExists?: boolean;
764
+ cascade?: boolean;
765
+ } | {
766
+ kind: "addColumn";
767
+ table: string;
768
+ column: string;
769
+ definition: FieldDefinition;
770
+ ifNotExists?: boolean;
771
+ } | {
772
+ kind: "dropColumn";
773
+ table: string;
774
+ column: string;
775
+ ifExists?: boolean;
776
+ cascade?: boolean;
777
+ } | {
778
+ kind: "alterColumn";
779
+ table: string;
780
+ column: string;
781
+ setType?: SchemaType;
782
+ using?: string;
783
+ setDefault?: any;
784
+ dropDefault?: boolean;
785
+ setNotNull?: boolean;
786
+ dropNotNull?: boolean;
787
+ } | {
788
+ kind: "renameColumn";
789
+ table: string;
790
+ from: string;
791
+ to: string;
792
+ } | {
793
+ kind: "renameTable";
794
+ from: string;
795
+ to: string;
796
+ } | {
797
+ kind: "addIndex";
798
+ table: string;
799
+ fields: string[];
800
+ name?: string;
801
+ unique?: boolean;
802
+ } | {
803
+ kind: "dropIndex";
804
+ table?: string;
805
+ fields?: string[];
806
+ name?: string;
807
+ ifExists?: boolean;
808
+ } | {
809
+ kind: "addConstraint";
810
+ table: string;
811
+ name: string;
812
+ definition: DatabaseMigrationConstraintDefinition;
813
+ } | {
814
+ kind: "dropConstraint";
815
+ table: string;
816
+ name: string;
817
+ ifExists?: boolean;
818
+ } | {
819
+ kind: "sql";
820
+ sql: string | string[];
821
+ };
822
+ interface DatabaseMigrationDefinition {
823
+ version: number;
824
+ name: string;
825
+ description?: string;
826
+ steps: DatabaseMigrationStep[];
827
+ transaction?: "inherit" | "required" | "none";
828
+ }
829
+ interface DatabaseSchemaDefinition {
830
+ version?: number;
831
+ tables: Record<string, TableDefinition>;
832
+ migrations?: DatabaseMigrationDefinition[];
833
+ migrationPolicy?: DatabaseMigrationPolicy;
834
+ relations?: Record<string, {
835
+ on: string;
836
+ type?: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many";
837
+ }>;
838
+ meta?: {
839
+ defaultEncoding?: "utf8" | "base64";
840
+ autoIndex?: boolean;
841
+ relationsVersion?: number;
842
+ dropExisting?: boolean;
843
+ };
844
+ }
845
+
846
+ interface BootstrapOptions {
847
+ url?: string;
848
+ injectedGlobalKey?: string;
849
+ }
850
+ interface HydrationOptions {
851
+ initialInquiryResults?: Record<string, unknown>;
852
+ }
853
+ interface ResolvedBootstrapEndpoint {
854
+ url: string;
855
+ protocol: "http" | "https";
856
+ address: string;
857
+ port: number;
858
+ exposed: boolean;
859
+ injectedGlobalKey: string;
860
+ }
861
+
862
+ interface BrowserRuntimeActorRuntimeState<TProjectionState extends Record<string, any> = Record<string, any>> {
863
+ ready: boolean;
864
+ projectionState: TProjectionState;
865
+ lastReadyAt: string | null;
866
+ lastSyncRequestedAt: string | null;
867
+ }
868
+ interface BrowserRuntimeProjectionBinding<TProjectionState extends Record<string, any> = Record<string, any>> {
869
+ signal: string;
870
+ taskName?: string;
871
+ description?: string;
872
+ reduce: (current: TProjectionState, payload: Record<string, any>) => TProjectionState;
873
+ }
874
+ interface BrowserRuntimeServiceOptions extends Omit<ServerOptions, "isFrontend" | "bootstrap" | "hydration"> {
875
+ name: string;
876
+ description?: string;
877
+ bootstrap: BootstrapOptions;
878
+ hydration?: HydrationOptions;
879
+ }
880
+ interface BrowserRuntimeActorOptions<TProjectionState extends Record<string, any> = Record<string, any>> {
881
+ actorName: string;
882
+ actorDescription?: string;
883
+ actorKey?: string;
884
+ service: BrowserRuntimeServiceOptions;
885
+ initialProjectionState: TProjectionState | (() => TProjectionState);
886
+ signalBindings?: Array<BrowserRuntimeProjectionBinding<TProjectionState>>;
887
+ readySignal?: string;
888
+ syncSignals?: string[];
889
+ }
890
+ interface BrowserRuntimeActorHandle<TProjectionState extends Record<string, any> = Record<string, any>> {
891
+ actor: Actor<Record<string, never>, BrowserRuntimeActorRuntimeState<TProjectionState>>;
892
+ actorKey: string;
893
+ waitUntilReady: () => Promise<void>;
894
+ inquire: (inquiry: string, context?: Record<string, any>, options?: DistributedInquiryOptions) => Promise<AnyObject>;
895
+ getRuntimeState: () => BrowserRuntimeActorRuntimeState<TProjectionState>;
896
+ subscribe: (listener: (state: BrowserRuntimeActorRuntimeState<TProjectionState>) => void) => () => void;
897
+ }
898
+
899
+ type SecurityProfile = "low" | "medium" | "high";
900
+ type NetworkMode = "internal" | "exposed" | "exposed-high-sec" | "auto" | "dev";
901
+ type ServerOptions = {
902
+ customServiceId?: string;
903
+ loadBalance?: boolean;
904
+ useSocket?: boolean;
905
+ log?: boolean;
906
+ displayName?: string;
907
+ isMeta?: boolean;
908
+ port?: number;
909
+ securityProfile?: SecurityProfile;
910
+ networkMode?: NetworkMode;
911
+ retryCount?: number;
912
+ cadenzaDB?: {
913
+ connect?: boolean;
914
+ address?: string;
915
+ port?: number;
916
+ };
917
+ bootstrap?: BootstrapOptions;
918
+ hydration?: HydrationOptions;
919
+ transports?: ServiceTransportConfig[];
920
+ relatedServices?: string[][];
921
+ isDatabase?: boolean;
922
+ isFrontend?: boolean;
923
+ };
924
+ interface DatabaseOptions {
925
+ databaseType?: "postgres";
926
+ databaseName?: string;
927
+ poolSize?: number;
928
+ ownerServiceName?: string | null;
929
+ }
930
+ /**
931
+ * The CadenzaService class serves as a central service layer providing various utility methods for managing tasks, signals, logging, and service interactions.
932
+ * This class handles the initialization (`bootstrap`) and validation of services, as well as the creation of tasks associated with services and signals.
933
+ */
934
+ declare class CadenzaService {
935
+ static signalBroker: SignalBroker;
936
+ static inquiryBroker: InquiryBroker;
937
+ static runner: GraphRunner;
938
+ static metaRunner: GraphRunner;
939
+ static registry: GraphRegistry;
940
+ static serviceRegistry: ServiceRegistry;
941
+ protected static isBootstrapped: boolean;
942
+ protected static serviceCreated: boolean;
943
+ protected static bootstrapSyncCompleted: boolean;
944
+ protected static bootstrapSignalRegistrationsCompleted: boolean;
945
+ protected static bootstrapIntentRegistrationsCompleted: boolean;
946
+ protected static defaultDatabaseServiceName: string | null;
947
+ protected static warnedInvalidMetaIntentResponderKeys: Set<string>;
948
+ protected static hydratedInquiryResults: Map<string, AnyObject>;
949
+ protected static frontendSyncScheduled: boolean;
950
+ protected static serviceManifestRevision: number;
951
+ protected static lastPublishedServiceManifestHash: string | null;
952
+ protected static serviceManifestPublicationInFlight: boolean;
953
+ protected static serviceManifestPublicationPendingReason: string | null;
954
+ private static shutdownHandlersRegistered;
955
+ private static shutdownInFlight;
956
+ private static shutdownHandlerCleanup;
957
+ private static unregisterGracefulShutdownHandlers;
958
+ private static registerGracefulShutdownHandlers;
959
+ private static replayRegisteredTaskIntentAssociations;
960
+ private static replayRegisteredTaskSignalObservations;
961
+ private static replayRegisteredTaskGraphMetadata;
962
+ private static requestServiceManifestPublication;
963
+ private static scheduleServiceManifestPublicationRetry;
964
+ private static publishServiceManifestIfNeeded;
965
+ private static ensureServiceManifestPublicationTasks;
966
+ private static buildLegacyLocalCadenzaDBTaskName;
967
+ private static buildGeneratedLocalCadenzaDBTaskName;
968
+ /**
969
+ * Initializes the application by setting up necessary components and configurations.
970
+ * This method ensures the initialization process is only executed once throughout the application lifecycle.
971
+ *
972
+ * @return {void} This method does not return any value.
973
+ */
974
+ static bootstrap(): void;
975
+ private static ensureTransportControllers;
976
+ private static setHydrationResults;
977
+ private static consumeHydratedInquiryResult;
978
+ private static ensureFrontendSyncLoop;
979
+ private static normalizeDeclaredTransports;
980
+ private static createBootstrapTransport;
981
+ /**
982
+ * Validates the provided service name based on specific rules.
983
+ *
984
+ * @param {string} serviceName - The service name to validate. Must be less than 100 characters,
985
+ * must not contain spaces, dots, or backslashes, and must start with a capital letter.
986
+ * @return {void} Throws an error if the service name does not meet the validation criteria.
987
+ * @throws {Error} If the service name exceeds 100 characters.
988
+ * @throws {Error} If the service name contains spaces.
989
+ * @throws {Error} If the service name contains dots.
990
+ * @throws {Error} If the service name contains backslashes.
991
+ * @throws {Error} If the service name does not start with a capital letter.
992
+ */
993
+ protected static validateServiceName(serviceName: string): void;
994
+ /**
995
+ * Validates the provided name to ensure it meets the required criteria.
996
+ *
997
+ * @param {string} name - The name to be validated.
998
+ * @return {void} Does not return any value.
999
+ */
1000
+ protected static validateName(name: string): void;
1001
+ /**
1002
+ * Gets the current run strategy from the Cadenza configuration.
1003
+ *
1004
+ * @return {Function} The run strategy function defined in the Cadenza configuration.
1005
+ */
1006
+ static get runStrategy(): {
1007
+ PARALLEL: unknown;
1008
+ SEQUENTIAL: unknown;
1009
+ };
1010
+ /**
1011
+ * Sets the mode for the Cadenza application.
1012
+ *
1013
+ * @param {CadenzaMode} mode - The mode to be set for the application.
1014
+ * @return {void} This method does not return a value.
1015
+ */
1016
+ static setMode(mode: CadenzaMode): void;
1017
+ static hasCompletedBootstrapSync(): boolean;
1018
+ static isServiceReady(): boolean;
1019
+ static getServiceReadySignalName(serviceName?: string): string;
1020
+ private static getServiceReadyHandoffSignalName;
1021
+ static markBootstrapSyncCompleted(): void;
1022
+ /**
1023
+ * Emits a signal with the specified data using the associated broker.
1024
+ *
1025
+ * @param {string} signal - The name of the event or signal to emit.
1026
+ * @param {AnyObject} [data={}] - The data to be emitted along with the signal.
1027
+ * @param options
1028
+ * @return {void} No return value.
1029
+ *
1030
+ * @example
1031
+ * This is meant to be used as a global event emitter.
1032
+ * If you want to emit an event from within a task, you can use the `emit` method provided to the task function. See {@link TaskFunction}.
1033
+ * ```ts
1034
+ * Cadenza.emit('main.my_event', { foo: 'bar' });
1035
+ * ```
1036
+ */
1037
+ static emit(signal: string, data?: AnyObject, options?: EmitOptions): void;
1038
+ static debounce(signal: string, context?: any, delayMs?: number): void;
1039
+ static schedule(signal: string, context: AnyObject, timeoutMs: number, exactDateTime?: Date): void;
1040
+ static interval(signal: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
1041
+ static defineIntent(intent: Intent): Intent;
1042
+ static getRuntimeValidationPolicy(): RuntimeValidationPolicy;
1043
+ static setRuntimeValidationPolicy(policy?: RuntimeValidationPolicy): RuntimeValidationPolicy;
1044
+ static replaceRuntimeValidationPolicy(policy?: RuntimeValidationPolicy): RuntimeValidationPolicy;
1045
+ static clearRuntimeValidationPolicy(): void;
1046
+ static getRuntimeValidationScopes(): RuntimeValidationScope[];
1047
+ static upsertRuntimeValidationScope(scope: RuntimeValidationScope): RuntimeValidationScope;
1048
+ static removeRuntimeValidationScope(id: string): void;
1049
+ static clearRuntimeValidationScopes(): void;
1050
+ private static getInquiryResponderDescriptor;
1051
+ private static compareInquiryResponders;
1052
+ private static buildInquirySummary;
1053
+ private static shouldPersistInquiry;
1054
+ private static splitInquiryPersistenceContext;
1055
+ private static buildInquiryPersistenceStartData;
1056
+ static inquire(inquiry: string, context: AnyObject, options?: DistributedInquiryOptions): Promise<AnyObject>;
1057
+ /**
1058
+ * Executes the given task or graph routine within the provided context using the configured runner.
1059
+ *
1060
+ * @param {Task | GraphRoutine} task - The task or graph routine to be executed.
1061
+ * @param {AnyObject} context - The context within which the task will be executed.
1062
+ * @return {void}
1063
+ *
1064
+ * @example
1065
+ * ```ts
1066
+ * const task = Cadenza.createTask('My task', (ctx) => {
1067
+ * console.log('My task executed with context:', ctx);
1068
+ * });
1069
+ *
1070
+ * Cadenza.run(task, { foo: 'bar' });
1071
+ *
1072
+ * const routine = Cadenza.createRoutine('My routine', [task], 'My routine description');
1073
+ *
1074
+ * Cadenza.run(routine, { foo: 'bar' });
1075
+ * ```
1076
+ */
1077
+ static run(task: Task | GraphRoutine, context: AnyObject): void;
1078
+ /**
1079
+ * Logs a message with a specified log level and additional contextual data.
1080
+ * Records in the CadenzaDB when available.
1081
+ *
1082
+ * @param {string} message - The main message to be logged.
1083
+ * @param {any} [data={}] - Additional data or metadata to include with the log.
1084
+ * @param {"info"|"warning"|"error"|"critical"} [level="info"] - The severity level of the log message.
1085
+ * @param {string|null} [subjectServiceName=null] - The name of the subject service related to the log.
1086
+ * @param {string|null} [subjectServiceInstanceId=null] - The instance ID of the subject service related to the log.
1087
+ * @return {void} No return value.
1088
+ */
1089
+ static log(message: string, data?: any, level?: "info" | "warning" | "error" | "critical", subjectServiceName?: string | null, subjectServiceInstanceId?: string | null): void;
1090
+ static get(taskName: string): Task | undefined;
1091
+ static getLocalCadenzaDBTask(tableName: string, operation: DbOperationType$1): Task | undefined;
1092
+ static getLocalCadenzaDBInsertTask(tableName: string): Task | undefined;
1093
+ static getLocalCadenzaDBQueryTask(tableName: string): Task | undefined;
1094
+ static getActor<D extends Record<string, any> = AnyObject, R = AnyObject>(actorName: string): Actor<D, R> | undefined;
1095
+ static getAllActors<D extends Record<string, any> = AnyObject, R = AnyObject>(): Actor<D, R>[];
1096
+ static getRoutine(routineName: string): GraphRoutine | undefined;
1097
+ /**
1098
+ * Creates a new DeputyTask instance based on the provided routine name, service name, and options.
1099
+ * This method ensures proper task initialization, including setting a unique name,
1100
+ * validation of the routine name, and applying default option values.
1101
+ *
1102
+ * @param {string} routineName - The name of the routine the task references. This is mandatory and should be a valid string.
1103
+ * @param {string|undefined} [serviceName] - The name of the service that the routine belongs to. This is optional and defaults to undefined.
1104
+ * @param {TaskOptions} [options={}] - A configuration object for the task, allowing various properties such as concurrency, timeout, and retry settings to be customized.
1105
+ * @return {DeputyTask} - A new DeputyTask instance initialized with the specified parameters.
1106
+ *
1107
+ * @example
1108
+ * Let's say we are writing the code for a Service called "Service1".
1109
+ * We also have an additional service called "Service2" with a routine called "My Routine".
1110
+ * A flow on Service1 depends on the result of "My Routine" on Service2.
1111
+ * We can create a deputy task for the routine using the following code:
1112
+ * ```ts
1113
+ * Cadenza.createDeputyTask("My Routine", "Service2").then(
1114
+ * Cadenza.createTask("Handle result", (ctx) => {
1115
+ * console.log("'Handle result' executed with context:", ctx);
1116
+ * }),
1117
+ * );
1118
+ * ```
1119
+ * Internally, this will send a request to an available "Service2" instance to execute the "My Routine" routine.
1120
+ * The deputy task will wait for the response and then execute the next task(s) in the chain.
1121
+ *
1122
+ * You can visualize the execution of the deputy task as follows:
1123
+ * ```
1124
+ * Service1 flow = [Deputy tasks for "My Routine"] -> ["Handle result"]
1125
+ * || A
1126
+ * V ||
1127
+ * Service2 flow = [[My Routine]]
1128
+ * ```
1129
+ *
1130
+ * Deputy tasks are useful for delegating flows to other services, allowing for parallel execution and load balancing.
1131
+ * But it creates tight coupling between the services, which may not be desirable in some cases.
1132
+ * In cases where an event on one service should simply trigger a flow on another service, without the need for a result,
1133
+ * it is recommended to use signals instead. Like this:
1134
+ *
1135
+ * Service1
1136
+ * ```ts
1137
+ * Cadenza.createTask("Generate event", (ctx, emit) => {
1138
+ * // Do something
1139
+ * emit("some.event");
1140
+ * });
1141
+ * ```
1142
+ *
1143
+ * Service2
1144
+ * ```ts
1145
+ * Cadenza.createTask("Handle event", (ctx) => {
1146
+ * console.log("Handle event executed with context:", ctx);
1147
+ * }).doOn("Service1.some.event");
1148
+ * ```
1149
+ *
1150
+ * Every time the "Generate event" task is executed, it will emit a signal "Service1.some.event" to one Service2 instance and trigger the "Handle event" task.
1151
+ */
1152
+ static createDeputyTask(routineName: string, serviceName?: string | undefined, options?: TaskOptions): DeputyTask;
1153
+ /**
1154
+ * Creates a meta deputy task by setting the `isMeta` property in the options to true,
1155
+ * and delegating task creation to the `createDeputyTask` method.
1156
+ * See {@link createDeputyTask} and {@link createMetaTask} for more information.
1157
+ *
1158
+ * @param {string} routineName - The name of the routine associated with the task.
1159
+ * @param {string | undefined} [serviceName] - The optional name of the service associated with the task.
1160
+ * @param {TaskOptions} [options={}] - Additional options for the task. Defaults to an empty object if not provided.
1161
+ * @return {DeputyTask} - The created meta deputy task.
1162
+ */
1163
+ static createMetaDeputyTask(routineName: string, serviceName?: string | undefined, options?: TaskOptions): DeputyTask;
1164
+ /**
1165
+ * Creates a throttled deputy task with the specified parameters.
1166
+ * See {@link createThrottledTask} and {@link createDeputyTask} for more information.
1167
+ *
1168
+ * @param {string} routineName - The name of the routine to be executed.
1169
+ * @param {string | undefined} [serviceName=undefined] - The name of the service, if applicable.
1170
+ * @param {ThrottleTagGetter} [throttledIdGetter=() => "default"] - A function to get the throttled tag for the task.
1171
+ * @param {TaskOptions} [options={}] - The options for task configuration, including concurrency and callbacks.
1172
+ * @return {DeputyTask} The created throttled deputy task.
1173
+ */
1174
+ static createThrottledDeputyTask(routineName: string, serviceName?: string | undefined, throttledIdGetter?: ThrottleTagGetter, options?: TaskOptions): DeputyTask;
1175
+ /**
1176
+ * Creates a throttled deputy task with meta-task settings enabled.
1177
+ * See {@link createThrottledTask},{@link createDeputyTask} and {@link createMetaTask} for more information.
1178
+ *
1179
+ * @param {string} routineName - The name of the routine for which the task is being created.
1180
+ * @param {string|undefined} [serviceName=undefined] - The name of the service associated with the task, or undefined if not applicable.
1181
+ * @param {ThrottleTagGetter} [throttledIdGetter=() => "default"] - A function to compute or return the throttling identifier.
1182
+ * @param {TaskOptions} [options={}] - Additional options for the task configuration.
1183
+ * @return {any} Returns the created throttled deputy task instance.
1184
+ */
1185
+ static createMetaThrottledDeputyTask(routineName: string, serviceName?: string | undefined, throttledIdGetter?: ThrottleTagGetter, options?: TaskOptions): DeputyTask;
1186
+ /**
1187
+ * Creates and configures a signal transmission task that handles the transmission
1188
+ * of a specified signal to a target service with a set of customizable options.
1189
+ * This is only used for internal purposes and is not exposed to the business logic layer.
1190
+ *
1191
+ * @param {string} signalName - The name of the signal to be transmitted.
1192
+ * @param {string} serviceName - The name of the target service to transmit the signal to.
1193
+ * @param {TaskOptions} [options={}] - A set of optional parameters to further configure the task.
1194
+ * @return {SignalTransmissionTask} A new instance of SignalTransmissionTask configured with the given parameters.
1195
+ */
1196
+ static createSignalTransmissionTask(signalName: string, serviceName: string, options?: TaskOptions): SignalTransmissionTask | undefined;
1197
+ /**
1198
+ * Creates and configures a database task that performs an operation on a specified table.
1199
+ *
1200
+ * @param {string} tableName - The name of the database table on which the operation will be performed.
1201
+ * @param {DbOperationType} operation - The type of database operation to execute (e.g., insert, update, delete).
1202
+ * @param {string|undefined} [databaseServiceName=undefined] - The name of the database service; defaults to "default database service" if not provided.
1203
+ * @param {DbOperationPayload} queryData - The data payload required for executing the specified database operation.
1204
+ * @param {TaskOptions} [options={}] - Optional configuration for the task, including concurrency, timeout, and retry policies.
1205
+ * @return {DatabaseTask} A configured database task instance ready for execution.
1206
+ */
1207
+ static createDatabaseTask(tableName: string, operation: DbOperationType$1, databaseServiceName: string | undefined, queryData: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1208
+ /**
1209
+ * Creates a task for performing a database insert operation.
1210
+ *
1211
+ * @param {string} tableName - The name of the table where the insert operation will be performed.
1212
+ * @param {string | undefined} [databaseServiceName=undefined] - The name of the database service to use. Optional parameter, defaults to undefined.
1213
+ * @param {DbOperationPayload} [queryData={}] - The data payload for the insert operation. Defaults to an empty object.
1214
+ * @param {TaskOptions} [options={}] - Additional task options to configure the insert operation. Defaults to an empty object.
1215
+ * @return {object} A task configuration object for the database insert operation.
1216
+ */
1217
+ static createDatabaseInsertTask(tableName: string, databaseServiceName?: string | undefined, queryData?: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1218
+ /**
1219
+ * Creates a database query task for the specified table and configuration.
1220
+ *
1221
+ * @param {string} tableName - The name of the database table to execute the query on.
1222
+ * @param {string | undefined} [databaseServiceName=undefined] - The name of the database service to use. If undefined, the default service will be used.
1223
+ * @param {DbOperationPayload} queryData - The payload containing the query data to be executed.
1224
+ * @param {TaskOptions} [options={}] - Optional parameters to configure the task execution.
1225
+ * @return {Task} The created database query task.
1226
+ */
1227
+ static createDatabaseQueryTask(tableName: string, databaseServiceName: string | undefined, queryData: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1228
+ /**
1229
+ * Creates a database task for the CadenzaDB with the specified parameters.
1230
+ *
1231
+ * @param {string} tableName - The name of the database table on which the operation will be performed.
1232
+ * @param {DbOperationType} operation - The type of database operation to execute (e.g., INSERT, UPDATE, DELETE).
1233
+ * @param {DbOperationPayload} queryData - The payload or data required to perform the database operation.
1234
+ * @param {TaskOptions} [options={}] - Additional options for the task, such as configuration settings.
1235
+ * @return {any} The result of creating the database task.
1236
+ */
1237
+ static createCadenzaDBTask(tableName: string, operation: DbOperationType$1, queryData: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1238
+ /**
1239
+ * Creates a database insert task specifically for the CadenzaDB database.
1240
+ *
1241
+ * @param {string} tableName - The name of the table into which the data will be inserted.
1242
+ * @param {DbOperationPayload} [queryData={}] - An object representing the data to be inserted.
1243
+ * @param {TaskOptions} [options={}] - Additional options to customize the task. The `isMeta` property is set to true by default.
1244
+ * @return {Task} A task object configured to perform an insert operation in the CadenzaDB database.
1245
+ */
1246
+ static createCadenzaDBInsertTask(tableName: string, queryData?: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1247
+ /**
1248
+ * Creates a database query task specifically for the CadenzaDB.
1249
+ *
1250
+ * @param {string} tableName - The name of the database table to execute the query on.
1251
+ * @param {DbOperationPayload} queryData - The payload containing data and parameters for the database operation.
1252
+ * @param {TaskOptions} [options={}] - Additional options for the task configuration.
1253
+ * @return {any} The created task for executing a database query.
1254
+ */
1255
+ static createCadenzaDBQueryTask(tableName: string, queryData: DbOperationPayload, options?: TaskOptions): DatabaseTask;
1256
+ /**
1257
+ * Creates a new Cadenza service with the specified configuration.
1258
+ *
1259
+ * @param {string} serviceName - The unique name of the service to create.
1260
+ * @param {string} [description] - An optional description of the service.
1261
+ * @param {ServerOptions} [options] - An optional object containing configuration options for the service.
1262
+ * @return {boolean} Returns true when the service is successfully created.
1263
+ */
1264
+ static createCadenzaService(serviceName: string, description?: string, options?: ServerOptions): void;
1265
+ /**
1266
+ * Creates a Cadenza metadata service with the specified name, description, and options.
1267
+ *
1268
+ * @param {string} serviceName - The name of the metadata service to be created.
1269
+ * @param {string} description - A brief description of the metadata service.
1270
+ * @param {ServerOptions} [options={}] - Optional configuration for the metadata service. Defaults to an empty object.
1271
+ * @return {void} Does not return a value.
1272
+ */
1273
+ static createCadenzaMetaService(serviceName: string, description: string, options?: ServerOptions): void;
1274
+ /**
1275
+ * Creates a framework-agnostic browser runtime actor on top of frontend mode.
1276
+ * The actor owns readiness and projected browser runtime state while the caller
1277
+ * remains free to adapt that state into any frontend framework.
1278
+ */
1279
+ static createBrowserRuntimeActor<TProjectionState extends Record<string, any>>(options: BrowserRuntimeActorOptions<TProjectionState>): BrowserRuntimeActorHandle<TProjectionState>;
1280
+ /**
1281
+ * Creates and initializes a specialized PostgresActor.
1282
+ * This is actor-only and does not create or register a network service.
1283
+ *
1284
+ * @param {string} name - Logical PostgresActor name.
1285
+ * @param {DatabaseSchemaDefinition} schema - Database schema definition.
1286
+ * @param {string} [description=""] - Optional human-readable actor description.
1287
+ * @param {ServerOptions & DatabaseOptions} [options={}] - Actor/database runtime options.
1288
+ * @return {void}
1289
+ */
1290
+ static createPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
1291
+ /**
1292
+ * Creates a meta PostgresActor.
1293
+ *
1294
+ * @param {string} name - Logical PostgresActor name.
1295
+ * @param {DatabaseSchemaDefinition} schema - Database schema definition.
1296
+ * @param {string} [description=""] - Optional description.
1297
+ * @param {ServerOptions & DatabaseOptions} [options={}] - Optional actor/database options.
1298
+ * @return {void}
1299
+ */
1300
+ static createMetaPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
1301
+ /**
1302
+ * Creates a dedicated database service by composing a PostgresActor and a Cadenza service.
1303
+ */
1304
+ static createDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
1305
+ /**
1306
+ * Creates a meta database service with the specified configuration.
1307
+ *
1308
+ * @param {string} name - The name of the database service to be created.
1309
+ * @param {DatabaseSchemaDefinition} schema - The schema definition for the database.
1310
+ * @param {string} [description=""] - An optional description of the database service.
1311
+ * @param {ServerOptions & DatabaseOptions} [options={}] - Optional server and database configuration options. The `isMeta` flag will be automatically set to true.
1312
+ * @return {void} - This method does not return a value.
1313
+ */
1314
+ static createMetaDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
1315
+ private static normalizePostgresActorOptions;
1316
+ private static normalizeDatabaseServiceOptions;
1317
+ private static registerDatabaseServiceBridgeTask;
1318
+ static createActor<D extends Record<string, any> = AnyObject, R = AnyObject>(spec: ActorSpec<D, R>, options?: ActorFactoryOptions): Actor<D, R>;
1319
+ static createActorFromDefinition<D extends Record<string, any> = AnyObject, R = AnyObject>(definition: ActorDefinition<D, R>, options?: ActorFactoryOptions<D, R>): Actor<D, R>;
1320
+ /**
1321
+ * Creates and registers a new task with the provided name, function, and optional details.
1322
+ *
1323
+ * @param {string} name - The name of the task to be created.
1324
+ * @param {TaskFunction} func - The function that contains the task execution logic.
1325
+ * @param {string} [description] - An optional description of what the task does.
1326
+ * @param {TaskOptions} [options={}] - An optional configuration object specifying additional task options.
1327
+ * @return {Task} - The created task instance.
1328
+ *
1329
+ * @example
1330
+ * You can use arrow functions to create tasks.
1331
+ * ```ts
1332
+ * const task = Cadenza.createTask('My task', (ctx) => {
1333
+ * console.log('My task executed with context:', ctx);
1334
+ * }, 'My task description');
1335
+ * ```
1336
+ *
1337
+ * You can also use named functions to create tasks.
1338
+ * This is the preferred way to create tasks since it allows for code inspection in the CadenzaUI.
1339
+ * ```ts
1340
+ * function myTask(ctx) {
1341
+ * console.log('My task executed with context:', ctx);
1342
+ * }
1343
+ *
1344
+ * const task = Cadenza.createTask('My task', myTask);
1345
+ * ```
1346
+ *
1347
+ * ** Use the TaskOptions object to configure the task. **
1348
+ *
1349
+ * With concurrency limit, timeout limit and retry settings.
1350
+ * ```ts
1351
+ * Cadenza.createTask('My task', (ctx) => {
1352
+ * console.log('My task executed with context:', ctx);
1353
+ * }, 'My task description', {
1354
+ * concurrency: 10,
1355
+ * timeout: 10000,
1356
+ * retryCount: 3,
1357
+ * retryDelay: 1000,
1358
+ * retryDelayFactor: 1.5,
1359
+ * });
1360
+ * ```
1361
+ *
1362
+ * You can specify the input and output context schemas for the task.
1363
+ * ```ts
1364
+ * Cadenza.createTask('My task', (ctx) => {
1365
+ * return { bar: 'foo' + ctx.foo };
1366
+ * }, 'My task description', {
1367
+ * inputContextSchema: {
1368
+ * type: 'object',
1369
+ * properties: {
1370
+ * foo: {
1371
+ * type: 'string',
1372
+ * },
1373
+ * },
1374
+ * required: ['foo'],
1375
+ * },
1376
+ * validateInputContext: true, // default is false
1377
+ * outputContextSchema: {
1378
+ * type: 'object',
1379
+ * properties: {
1380
+ * bar: {
1381
+ * type: 'string',
1382
+ * },
1383
+ * },
1384
+ * required: ['bar'],
1385
+ * },
1386
+ * validateOutputContext: true, // default is false
1387
+ * });
1388
+ * ```
1389
+ */
1390
+ static createTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): Task;
1391
+ /**
1392
+ * Creates a meta task with the specified name, functionality, description, and options.
1393
+ * This is used for creating tasks that lives on the meta layer.
1394
+ * The meta layer is a special layer that is executed separately from the business logic layer and is used for extending Cadenzas core functionality.
1395
+ * See {@link Task} or {@link createTask} for more information.
1396
+ *
1397
+ * @param {string} name - The name of the meta task.
1398
+ * @param {TaskFunction} func - The function to be executed by the meta task.
1399
+ * @param {string} [description] - An optional description of the meta task.
1400
+ * @param {TaskOptions} [options={}] - Additional optional task configuration. Automatically sets `isMeta` to true.
1401
+ * @return {Task} A task instance configured as a meta task.
1402
+ */
1403
+ static createMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): Task;
1404
+ /**
1405
+ * Creates a unique task by wrapping the provided task function with a uniqueness constraint.
1406
+ * Unique tasks are designed to execute once per execution ID, merging parents. This is useful for
1407
+ * tasks that require fan-in/joins after parallel branches.
1408
+ * See {@link Task} for more information.
1409
+ * @param {string} name Unique identifier.
1410
+ * @param {TaskFunction} func Function receiving joinedContexts as a list (context.joinedContexts).
1411
+ * @param {string} [description] Optional description.
1412
+ * @param {TaskOptions} [options={}] Optional task options.
1413
+ * @returns {Task} The created UniqueTask.
1414
+ *
1415
+ * @example
1416
+ * ```ts
1417
+ * const splitTask = Cadenza.createTask('Split foos', function* (ctx) {
1418
+ * for (const foo of ctx.foos) {
1419
+ * yield { foo };
1420
+ * }
1421
+ * }, 'Splits a list of foos into multiple sub-branches');
1422
+ *
1423
+ * const processTask = Cadenza.createTask('Process foo', (ctx) => {
1424
+ * return { bar: 'foo' + ctx.foo };
1425
+ * }, 'Process a foo');
1426
+ *
1427
+ * const uniqueTask = Cadenza.createUniqueTask('Gather processed foos', (ctx) => {
1428
+ * // A unique task will always be provided with a list of contexts (ctx.joinedContexts) from its predecessors.
1429
+ * const processedFoos = ctx.joinedContexts.map((c) => c.bar);
1430
+ * return { foos: processedFoos };
1431
+ * }, 'Gathers together the processed foos.');
1432
+ *
1433
+ * splitTask.then(
1434
+ * processTask.then(
1435
+ * uniqueTask,
1436
+ * ),
1437
+ * );
1438
+ *
1439
+ * // Give the flow a name using a routine
1440
+ * Cadenza.createRoutine(
1441
+ * 'Process foos',
1442
+ * [splitTask],
1443
+ * 'Processes a list of foos'
1444
+ * ).doOn('main.received_foos'); // Subscribe to a signal
1445
+ *
1446
+ * // Trigger the flow from anywhere
1447
+ * Cadenza.emit('main.received_foos', { foos: ['foo1', 'foo2', 'foo3'] });
1448
+ * ```
1449
+ */
1450
+ static createUniqueTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): Task;
1451
+ /**
1452
+ * Creates a unique meta task with the specified name, function, description, and options.
1453
+ * See {@link createUniqueTask} and {@link createMetaTask} for more information.
1454
+ *
1455
+ * @param {string} name - The name of the task to create.
1456
+ * @param {TaskFunction} func - The function to execute when the task is run.
1457
+ * @param {string} [description] - An optional description of the task.
1458
+ * @param {TaskOptions} [options={}] - Optional settings for the task. Defaults to an empty object. Automatically sets `isMeta` and `isUnique` to true.
1459
+ * @return {Task} The created unique meta task.
1460
+ */
1461
+ static createUniqueMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): Task;
1462
+ /**
1463
+ * Creates a throttled task with a concurrency limit of 1, ensuring that only one instance of the task can run at a time for a specific throttle tag.
1464
+ * This is useful for ensuring execution order and preventing race conditions.
1465
+ * See {@link Task} for more information.
1466
+ *
1467
+ * @param {string} name - The name of the task.
1468
+ * @param {TaskFunction} func - The function to be executed when the task runs.
1469
+ * @param {ThrottleTagGetter} [throttledIdGetter=() => "default"] - A function that generates a throttle tag identifier to group tasks for throttling.
1470
+ * @param {string} [description] - An optional description of the task.
1471
+ * @param {TaskOptions} [options={}] - Additional options to customize the task behavior.
1472
+ * @return {Task} The created throttled task.
1473
+ *
1474
+ * @example
1475
+ * ```ts
1476
+ * const task = Cadenza.createThrottledTask(
1477
+ * 'My task',
1478
+ * async (ctx) => {
1479
+ * await new Promise((resolve) => setTimeout(resolve, 1000));
1480
+ * console.log('My task executed with context:', ctx);
1481
+ * },
1482
+ * // Will throttle by the value of ctx.foo to make sure tasks with the same value are executed sequentially
1483
+ * (ctx) => ctx.foo,
1484
+ * );
1485
+ *
1486
+ * Cadenza.run(task, { foo: 'bar' }); // (First execution)
1487
+ * Cadenza.run(task, { foo: 'bar' }); // This will be executed after the first execution is finished
1488
+ * Cadenza.run(task, { foo: 'baz' }); // This will be executed in parallel with the first execution
1489
+ * ```
1490
+ */
1491
+ static createThrottledTask(name: string, func: TaskFunction, throttledIdGetter?: ThrottleTagGetter, description?: string, options?: TaskOptions): Task;
1492
+ /**
1493
+ * Creates a throttled meta task with the specified configuration.
1494
+ * See {@link createThrottledTask} and {@link createMetaTask} for more information.
1495
+ *
1496
+ * @param {string} name - The name of the throttled meta task.
1497
+ * @param {TaskFunction} func - The task function to be executed.
1498
+ * @param {ThrottleTagGetter} throttledIdGetter - A function to retrieve the throttling identifier.
1499
+ * @param {string} [description] - An optional description of the task.
1500
+ * @param {TaskOptions} [options={}] - Additional options for configuring the task.
1501
+ * @return {Task} The created throttled meta task.
1502
+ */
1503
+ static createThrottledMetaTask(name: string, func: TaskFunction, throttledIdGetter?: ThrottleTagGetter, description?: string, options?: TaskOptions): Task;
1504
+ /**
1505
+ * Creates and returns a new debounced task with the specified parameters.
1506
+ * This is useful to prevent rapid execution of tasks that may be triggered by multiple events within a certain time frame.
1507
+ * See {@link DebounceTask} for more information.
1508
+ *
1509
+ * @param {string} name - The unique name of the task to be created.
1510
+ * @param {TaskFunction} func - The function to be executed by the task.
1511
+ * @param {string} [description] - An optional description of the task.
1512
+ * @param {number} [debounceTime=1000] - The debounce time in milliseconds to delay the execution of the task.
1513
+ * @param {TaskOptions & DebounceOptions} [options={}] - Additional configuration options for the task, including debounce behavior and other task properties.
1514
+ * @return {DebounceTask} A new instance of the DebounceTask with the specified configuration.
1515
+ *
1516
+ * @example
1517
+ * ```ts
1518
+ * const task = Cadenza.createDebounceTask(
1519
+ * 'My debounced task',
1520
+ * (ctx) => {
1521
+ * console.log('My task executed with context:', ctx);
1522
+ * },
1523
+ * 'My debounced task description',
1524
+ * 100, // Debounce time in milliseconds. Default is 1000
1525
+ * {
1526
+ * leading: false, // Should the first execution of a burst be executed immediately? Default is false
1527
+ * trailing: true, // Should the last execution of a burst be executed? Default is true
1528
+ * maxWait: 1000, // Maximum time in milliseconds to wait for the next execution. Default is 0
1529
+ * },
1530
+ * );
1531
+ *
1532
+ * Cadenza.run(task, { foo: 'bar' }); // This will not be executed
1533
+ * Cadenza.run(task, { foo: 'bar' }); // This will not be executed
1534
+ * Cadenza.run(task, { foo: 'baz' }); // This execution will be delayed by 100ms
1535
+ * ```
1536
+ */
1537
+ static createDebounceTask(name: string, func: TaskFunction, description?: string, debounceTime?: number, options?: TaskOptions & DebounceOptions): DebounceTask;
1538
+ /**
1539
+ * Creates a debounced meta task with the specified parameters.
1540
+ * See {@link createDebounceTask} and {@link createMetaTask} for more information.
1541
+ *
1542
+ * @param {string} name - The name of the task.
1543
+ * @param {TaskFunction} func - The function to be executed by the task.
1544
+ * @param {string} [description] - Optional description of the task.
1545
+ * @param {number} [debounceTime=1000] - The debounce delay in milliseconds.
1546
+ * @param {TaskOptions & DebounceOptions} [options={}] - Additional configuration options for the task.
1547
+ * @return {DebounceTask} Returns an instance of the debounced meta task.
1548
+ */
1549
+ static createDebounceMetaTask(name: string, func: TaskFunction, description?: string, debounceTime?: number, options?: TaskOptions & DebounceOptions): DebounceTask;
1550
+ /**
1551
+ * Creates an ephemeral task with the specified configuration.
1552
+ * Ephemeral tasks are designed to self-destruct after execution or a certain condition is met.
1553
+ * This is useful for transient tasks such as resolving promises or performing cleanup operations.
1554
+ * They are not registered by default.
1555
+ * See {@link EphemeralTask} for more information.
1556
+ *
1557
+ * @param {string} name - The name of the task to be created.
1558
+ * @param {TaskFunction} func - The function that defines the logic of the task.
1559
+ * @param {string} [description] - An optional description of the task.
1560
+ * @param {TaskOptions & EphemeralTaskOptions} [options={}] - The configuration options for the task, including concurrency, timeouts, and retry policies.
1561
+ * @return {EphemeralTask} The created ephemeral task instance.
1562
+ *
1563
+ * @example
1564
+ * By default, ephemeral tasks are executed once and destroyed after execution.
1565
+ * ```ts
1566
+ * const task = Cadenza.createEphemeralTask('My ephemeral task', (ctx) => {
1567
+ * console.log('My task executed with context:', ctx);
1568
+ * });
1569
+ *
1570
+ * Cadenza.run(task); // Executes the task once and destroys it after execution
1571
+ * Cadenza.run(task); // Does nothing, since the task is destroyed
1572
+ * ```
1573
+ *
1574
+ * Use destroy condition to conditionally destroy the task
1575
+ * ```ts
1576
+ * const task = Cadenza.createEphemeralTask(
1577
+ * 'My ephemeral task',
1578
+ * (ctx) => {
1579
+ * console.log('My task executed with context:', ctx);
1580
+ * },
1581
+ * 'My ephemeral task description',
1582
+ * {
1583
+ * once: false, // Should the task be executed only once? Default is true
1584
+ * destroyCondition: (ctx) => ctx.foo > 10, // Should the task be destroyed after execution? Default is undefined
1585
+ * },
1586
+ * );
1587
+ *
1588
+ * Cadenza.run(task, { foo: 5 }); // The task will not be destroyed and can still be executed
1589
+ * Cadenza.run(task, { foo: 10 }); // The task will not be destroyed and can still be executed
1590
+ * Cadenza.run(task, { foo: 20 }); // The task will be destroyed after execution and cannot be executed anymore
1591
+ * Cadenza.run(task, { foo: 30 }); // This will not be executed
1592
+ * ```
1593
+ *
1594
+ * A practical use case for ephemeral tasks is to resolve a promise upon some external event.
1595
+ * ```ts
1596
+ * const task = Cadenza.createTask('Confirm something', (ctx, emit) => {
1597
+ * return new Promise((resolve) => {
1598
+ * ctx.foo = uuid();
1599
+ *
1600
+ * Cadenza.createEphemeralTask(`Resolve promise of ${ctx.foo}`, (c) => {
1601
+ * console.log('My task executed with context:', ctx);
1602
+ * resolve(c);
1603
+ * }).doOn(`socket.confirmation_received:${ctx.foo}`);
1604
+ *
1605
+ * emit('this_domain.confirmation_requested', ctx);
1606
+ * });
1607
+ * });
1608
+ * ```
1609
+ */
1610
+ static createEphemeralTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
1611
+ /**
1612
+ * Creates an ephemeral meta-task with the specified name, function, description, and options.
1613
+ * See {@link createEphemeralTask} and {@link createMetaTask} for more details.
1614
+ *
1615
+ * @param {string} name - The name of the task to be created.
1616
+ * @param {TaskFunction} func - The function to be executed as part of the task.
1617
+ * @param {string} [description] - An optional description of the task.
1618
+ * @param {TaskOptions & EphemeralTaskOptions} [options={}] - Additional options for configuring the task.
1619
+ * @return {EphemeralTask} The created ephemeral meta-task.
1620
+ */
1621
+ static createEphemeralMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
1622
+ /**
1623
+ * Creates a new routine with the specified name, tasks, and an optional description.
1624
+ * Routines are named entry points to starting tasks and are registered in the GraphRegistry.
1625
+ * They are used to group tasks together and provide a high-level structure for organizing and managing the execution of a set of tasks.
1626
+ * See {@link GraphRoutine} for more information.
1627
+ *
1628
+ * @param {string} name - The name of the routine to create.
1629
+ * @param {Task[]} tasks - A list of tasks to include in the routine.
1630
+ * @param {string} [description=""] - An optional description for the routine.
1631
+ * @return {GraphRoutine} A new instance of the GraphRoutine containing the specified tasks and description.
1632
+ *
1633
+ * @example
1634
+ * ```ts
1635
+ * const task1 = Cadenza.createTask("Task 1", () => {});
1636
+ * const task2 = Cadenza.createTask("Task 2", () => {});
1637
+ *
1638
+ * task1.then(task2);
1639
+ *
1640
+ * const routine = Cadenza.createRoutine("Some routine", [task1]);
1641
+ *
1642
+ * Cadenza.run(routine);
1643
+ *
1644
+ * // Or, routines can be triggered by signals
1645
+ * routine.doOn("some.signal");
1646
+ *
1647
+ * Cadenza.emit("some.signal", {});
1648
+ * ```
1649
+ */
1650
+ static createRoutine(name: string, tasks: Task[], description?: string): GraphRoutine;
1651
+ /**
1652
+ * Creates a meta routine with a given name, tasks, and optional description.
1653
+ * Routines are named entry points to starting tasks and are registered in the GraphRegistry.
1654
+ * They are used to group tasks together and provide a high-level structure for organizing and managing the execution of a set of tasks.
1655
+ * See {@link GraphRoutine} and {@link createRoutine} for more information.
1656
+ *
1657
+ * @param {string} name - The name of the routine to be created.
1658
+ * @param {Task[]} tasks - An array of tasks that the routine will consist of.
1659
+ * @param {string} [description=""] - An optional description for the routine.
1660
+ * @return {GraphRoutine} A new instance of the `GraphRoutine` representing the created routine.
1661
+ */
1662
+ static createMetaRoutine(name: string, tasks: Task[], description?: string): GraphRoutine;
1663
+ static reset(): void;
1664
+ }
1665
+
1666
+ export { AUTHORITY_RUNTIME_STATUS_REPORT_INTENT as A, type BootstrapOptions as B, CadenzaService as C, type DatabaseSchemaDefinition as D, type ServiceInstanceDescriptor as E, type FieldDefinition as F, type ServiceTransportConfig as G, type HydrationOptions as H, type InquiryResponderDescriptor as I, type JoinDefinition as J, type ServiceTransportDescriptor as K, type ServiceTransportProtocol as L, type ServiceTransportRole as M, type NetworkMode as N, type OpEffect as O, type ServiceTransportSecurityProfile as P, type QueryMode as Q, RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL as R, type ServerOptions as S, SignalTransmissionTask as T, type SortDirection as U, type SubOperationType as V, type TableDefinition as W, type ValueOrSubOp as X, buildAuthorityRuntimeStatusSignature as Y, normalizeAuthorityRuntimeStatusReport as Z, type DatabaseOptions as a, type DbOperationPayload as b, type SubOperation as c, type DistributedInquiryOptions as d, ServiceRegistry as e, type AggregateDefinition as f, type AggregateFunction as g, type AuthorityRuntimeStatusReport as h, type BrowserRuntimeActorHandle as i, type BrowserRuntimeActorOptions as j, type BrowserRuntimeActorRuntimeState as k, type BrowserRuntimeProjectionBinding as l, type BrowserRuntimeServiceOptions as m, type DatabaseMigrationConstraintDefinition as n, type DatabaseMigrationDefinition as o, type DatabaseMigrationPolicy as p, type DatabaseMigrationStep as q, DatabaseTask as r, type DbOperationType$1 as s, type DeputyDescriptor as t, DeputyTask as u, type DistributedInquiryMeta as v, type InquiryResponderStatus as w, type ResolvedBootstrapEndpoint as x, type RuntimeMetricsHealthDetail as y, type SecurityProfile as z };