@ultrst-armada/krnl 1.0.7 → 1.0.9
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 +15 -0
- package/package.json +14 -2
- package/packages/cli/dist/bin/krnl.cjs +5 -15
- package/packages/cli/dist/bin/krnl.js +1 -1
- package/packages/cli/dist/{chunk-GHWYEAPD.js → chunk-OOVZPIMX.js} +4 -14
- package/packages/cli/dist/index.cjs +5 -15
- package/packages/cli/dist/index.js +1 -1
- package/packages/core/dist/index.cjs +590 -102
- package/packages/core/dist/index.d.cts +310 -24
- package/packages/core/dist/index.d.ts +310 -24
- package/packages/core/dist/index.js +582 -102
- package/packages/core/package.json +2 -2
|
@@ -15,10 +15,252 @@ declare class LifecycleManager {
|
|
|
15
15
|
assertRunning(serviceName: string): void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @file EventTypes.ts
|
|
20
|
+
* @description Canonical event contracts for functionality and orchestration events.
|
|
21
|
+
*/
|
|
22
|
+
type EventHandler<TPayload> = (payload: TPayload) => void;
|
|
23
|
+
interface EventSubscription {
|
|
24
|
+
readonly unsubscribe: () => void;
|
|
25
|
+
}
|
|
26
|
+
interface EventChannel<TPayload> {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
subscribe(handler: EventHandler<TPayload>): EventSubscription;
|
|
29
|
+
on(handler: EventHandler<TPayload>): () => void;
|
|
30
|
+
}
|
|
31
|
+
interface EventDefinition<TPayload = unknown> {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly description?: string;
|
|
34
|
+
readonly payloadSchema?: Record<string, unknown>;
|
|
35
|
+
readonly marker?: TPayload;
|
|
36
|
+
}
|
|
37
|
+
interface FunctionalityLifecyclePayload {
|
|
38
|
+
readonly serviceId: string;
|
|
39
|
+
readonly functionalityId: string;
|
|
40
|
+
readonly functionalityName: string;
|
|
41
|
+
readonly correlationId?: string;
|
|
42
|
+
readonly timestamp: number;
|
|
43
|
+
readonly input?: unknown;
|
|
44
|
+
readonly output?: unknown;
|
|
45
|
+
readonly error?: string;
|
|
46
|
+
}
|
|
47
|
+
type FunctionalityLifecycleEvent = 'triggered' | 'completed' | 'failed';
|
|
48
|
+
interface OrchestrationLifecyclePayload {
|
|
49
|
+
readonly serviceId: string;
|
|
50
|
+
readonly orchestrationId: string;
|
|
51
|
+
readonly orchestrationName: string;
|
|
52
|
+
readonly correlationId: string;
|
|
53
|
+
readonly executionId?: string;
|
|
54
|
+
readonly timestamp: number;
|
|
55
|
+
readonly status?: string;
|
|
56
|
+
readonly output?: unknown;
|
|
57
|
+
readonly error?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @file FunctionalityContract.ts
|
|
62
|
+
* @description Canonical functionality contracts and event surface.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
type FunctionalityCustomEvents = Record<string, unknown>;
|
|
66
|
+
type FunctionalityEvents<TEvents extends FunctionalityCustomEvents = {}> = Omit<TEvents, 'triggered' | 'completed' | 'failed'> & {
|
|
67
|
+
triggered: FunctionalityLifecyclePayload;
|
|
68
|
+
completed: FunctionalityLifecyclePayload;
|
|
69
|
+
failed: FunctionalityLifecyclePayload;
|
|
70
|
+
};
|
|
71
|
+
interface FunctionalityExecutionContext<TState = Record<string, unknown>, TEvents extends FunctionalityCustomEvents = {}> {
|
|
72
|
+
readonly serviceId: string;
|
|
73
|
+
readonly functionalityId: string;
|
|
74
|
+
readonly correlationId?: string;
|
|
75
|
+
readonly state: Readonly<TState>;
|
|
76
|
+
readonly metadata?: Record<string, unknown>;
|
|
77
|
+
readonly emit: <K extends keyof FunctionalityEvents<TEvents> & string>(event: K, payload: FunctionalityEvents<TEvents>[K]) => void;
|
|
78
|
+
}
|
|
79
|
+
interface FunctionalityDefinition<TInput = unknown, TOutput = unknown, TState = Record<string, unknown>, TEvents extends FunctionalityCustomEvents = {}> {
|
|
80
|
+
readonly id?: string;
|
|
81
|
+
readonly name?: string;
|
|
82
|
+
readonly description?: string;
|
|
83
|
+
readonly events?: Record<keyof TEvents & string, EventDefinition<any>>;
|
|
84
|
+
readonly bubbleEvents?: boolean;
|
|
85
|
+
readonly execute: (input: TInput, context: FunctionalityExecutionContext<TState, TEvents>) => Promise<TOutput> | TOutput;
|
|
86
|
+
}
|
|
87
|
+
type FunctionalityEventNamespace<TEvents extends FunctionalityCustomEvents = {}> = {
|
|
88
|
+
readonly [K in keyof FunctionalityEvents<TEvents>]: EventChannel<FunctionalityEvents<TEvents>[K]>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @file FunctionalityFacade.ts
|
|
93
|
+
* @description First-class functionality boundary with lifecycle and custom events.
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
declare class FunctionalityFacade<TInput = unknown, TOutput = unknown, TState = Record<string, unknown>, TEvents extends Record<string, unknown> = {}> {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly description: string;
|
|
100
|
+
readonly bubbleEvents: boolean;
|
|
101
|
+
readonly definition: FunctionalityDefinition<TInput, TOutput, TState, TEvents>;
|
|
102
|
+
private readonly eventBus;
|
|
103
|
+
readonly events: FunctionalityEventNamespace<TEvents>;
|
|
104
|
+
constructor(id: string, definition: FunctionalityDefinition<TInput, TOutput, TState, TEvents>, options?: {
|
|
105
|
+
bubbleEvents?: boolean;
|
|
106
|
+
});
|
|
107
|
+
getEventDefinitions(): Record<string, EventDefinition<any>>;
|
|
108
|
+
subscribe<K extends keyof FunctionalityEvents<TEvents> & string>(event: K, handler: (payload: FunctionalityEvents<TEvents>[K]) => void): () => void;
|
|
109
|
+
emit<K extends keyof FunctionalityEvents<TEvents> & string>(event: K, payload: FunctionalityEvents<TEvents>[K]): void;
|
|
110
|
+
execute(input: TInput, context: Omit<FunctionalityExecutionContext<TState, TEvents>, 'emit'>): Promise<TOutput>;
|
|
111
|
+
clearEventSubscriptions(): void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @file TelemetryTypes.ts
|
|
116
|
+
* @description Framework-native service invocation telemetry contracts.
|
|
117
|
+
*/
|
|
118
|
+
type TelemetryMode = 'off' | 'standard' | 'detailed' | 'profile';
|
|
119
|
+
type TelemetryStatus = {
|
|
120
|
+
enabled: boolean;
|
|
121
|
+
mode: TelemetryMode;
|
|
122
|
+
serviceId: string;
|
|
123
|
+
invocationCount: number;
|
|
124
|
+
activeInvocations: number;
|
|
125
|
+
lastInvocationAt?: number;
|
|
126
|
+
};
|
|
127
|
+
interface TelemetryResourceSample {
|
|
128
|
+
cpuUserMicros?: number;
|
|
129
|
+
cpuSystemMicros?: number;
|
|
130
|
+
heapUsedBytes?: number;
|
|
131
|
+
heapTotalBytes?: number;
|
|
132
|
+
rssBytes?: number;
|
|
133
|
+
externalBytes?: number;
|
|
134
|
+
arrayBuffersBytes?: number;
|
|
135
|
+
eventLoopUtilization?: number;
|
|
136
|
+
scope: 'process' | 'runtime';
|
|
137
|
+
}
|
|
138
|
+
interface TelemetryInvocation {
|
|
139
|
+
invocationId: string;
|
|
140
|
+
traceId: string;
|
|
141
|
+
spanId: string;
|
|
142
|
+
parentSpanId?: string;
|
|
143
|
+
serviceId: string;
|
|
144
|
+
target: string;
|
|
145
|
+
kind: 'service' | 'functionality' | 'orchestration';
|
|
146
|
+
correlationId?: string;
|
|
147
|
+
startedAt: number;
|
|
148
|
+
completedAt: number;
|
|
149
|
+
durationMs: number;
|
|
150
|
+
status: 'completed' | 'failed';
|
|
151
|
+
error?: {
|
|
152
|
+
name: string;
|
|
153
|
+
message: string;
|
|
154
|
+
};
|
|
155
|
+
resources?: {
|
|
156
|
+
start: TelemetryResourceSample;
|
|
157
|
+
end: TelemetryResourceSample;
|
|
158
|
+
delta: TelemetryResourceSample;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
interface TelemetryPercentiles {
|
|
162
|
+
min: number;
|
|
163
|
+
mean: number;
|
|
164
|
+
p50: number;
|
|
165
|
+
p90: number;
|
|
166
|
+
p95: number;
|
|
167
|
+
p99: number;
|
|
168
|
+
max: number;
|
|
169
|
+
}
|
|
170
|
+
interface TelemetryTargetStats {
|
|
171
|
+
target: string;
|
|
172
|
+
kind: TelemetryInvocation['kind'];
|
|
173
|
+
count: number;
|
|
174
|
+
successCount: number;
|
|
175
|
+
errorCount: number;
|
|
176
|
+
durationMs: TelemetryPercentiles;
|
|
177
|
+
lastInvocationAt?: number;
|
|
178
|
+
}
|
|
179
|
+
interface TelemetrySnapshot {
|
|
180
|
+
serviceId: string;
|
|
181
|
+
mode: TelemetryMode;
|
|
182
|
+
capturedAt: number;
|
|
183
|
+
status: TelemetryStatus;
|
|
184
|
+
totals: {
|
|
185
|
+
invocationCount: number;
|
|
186
|
+
successCount: number;
|
|
187
|
+
errorCount: number;
|
|
188
|
+
durationMs: TelemetryPercentiles;
|
|
189
|
+
};
|
|
190
|
+
targets: TelemetryTargetStats[];
|
|
191
|
+
activeInvocations: number;
|
|
192
|
+
recentInvocations: TelemetryInvocation[];
|
|
193
|
+
}
|
|
194
|
+
interface TelemetryOptions {
|
|
195
|
+
mode?: TelemetryMode;
|
|
196
|
+
maxSamples?: number;
|
|
197
|
+
maxRecentInvocations?: number;
|
|
198
|
+
}
|
|
199
|
+
interface TelemetryHandle {
|
|
200
|
+
readonly invocationId: string;
|
|
201
|
+
readonly traceId: string;
|
|
202
|
+
readonly spanId: string;
|
|
203
|
+
readonly parentSpanId?: string;
|
|
204
|
+
end(error?: unknown): void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @file TelemetryResources.ts
|
|
209
|
+
* @description Capability-detected runtime resource sampling.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
declare function telemetryNow(): number;
|
|
213
|
+
declare function sampleResources(): TelemetryResourceSample;
|
|
214
|
+
declare function deltaResources(start: TelemetryResourceSample, end: TelemetryResourceSample): TelemetryResourceSample;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @file TelemetryController.ts
|
|
218
|
+
* @description Per-service telemetry recorder and public control surface.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
type ActiveInvocation = {
|
|
222
|
+
invocationId: string;
|
|
223
|
+
traceId: string;
|
|
224
|
+
spanId: string;
|
|
225
|
+
parentSpanId?: string;
|
|
226
|
+
serviceId: string;
|
|
227
|
+
target: string;
|
|
228
|
+
kind: TelemetryInvocation['kind'];
|
|
229
|
+
correlationId?: string;
|
|
230
|
+
startedAt: number;
|
|
231
|
+
resourcesStart?: ReturnType<typeof sampleResources>;
|
|
232
|
+
};
|
|
233
|
+
declare class TelemetryController {
|
|
234
|
+
private readonly serviceId;
|
|
235
|
+
private mode;
|
|
236
|
+
private readonly maxSamples;
|
|
237
|
+
private readonly maxRecentInvocations;
|
|
238
|
+
private readonly samples;
|
|
239
|
+
private readonly active;
|
|
240
|
+
private totalInvocationCount;
|
|
241
|
+
private totalSuccessCount;
|
|
242
|
+
private totalErrorCount;
|
|
243
|
+
private lastInvocationAt?;
|
|
244
|
+
constructor(serviceId: string, options?: TelemetryOptions);
|
|
245
|
+
enable(mode?: Exclude<TelemetryMode, 'off'>): void;
|
|
246
|
+
disable(): void;
|
|
247
|
+
setMode(mode: TelemetryMode): void;
|
|
248
|
+
getMode(): TelemetryMode;
|
|
249
|
+
status(): TelemetryStatus;
|
|
250
|
+
begin(target: string, kind: ActiveInvocation['kind'], correlationId?: string, parentSpanId?: string): TelemetryHandle;
|
|
251
|
+
reset(): void;
|
|
252
|
+
snapshot(): TelemetrySnapshot;
|
|
253
|
+
functionality(name: string): TelemetryTargetStats | undefined;
|
|
254
|
+
functionalities(): TelemetryTargetStats[];
|
|
255
|
+
private findTraceId;
|
|
256
|
+
private finish;
|
|
257
|
+
}
|
|
258
|
+
|
|
18
259
|
/**
|
|
19
260
|
* @file ServiceContract.ts
|
|
20
261
|
* @description Canonical service contracts for the KrnlTS Service Kernel.
|
|
21
|
-
*
|
|
262
|
+
* Services are execution and namespace boundaries; application events belong to
|
|
263
|
+
* functionalities and orchestration lifecycle, never to the service itself.
|
|
22
264
|
*/
|
|
23
265
|
|
|
24
266
|
type ProtocolType = 'http' | 'https' | 'ws' | 'wss' | 'udp' | 'p2p' | 'signaling' | 'memory';
|
|
@@ -70,7 +312,7 @@ interface ServiceCapability {
|
|
|
70
312
|
protocols: ProtocolType[];
|
|
71
313
|
metadata?: Record<string, unknown>;
|
|
72
314
|
}
|
|
73
|
-
interface ServiceNamespace<TLibraries extends Record<string, unknown> = Record<string, unknown>, TFunctionalities extends Record<string,
|
|
315
|
+
interface ServiceNamespace<TLibraries extends Record<string, unknown> = Record<string, unknown>, TFunctionalities extends Record<string, FunctionalityFacade<any, any, any, any>> = Record<string, FunctionalityFacade<any, any, any, any>>, TOrchestrations extends Record<string, unknown> = Record<string, unknown>> {
|
|
74
316
|
readonly serviceId: string;
|
|
75
317
|
readonly serviceName: string;
|
|
76
318
|
readonly version: string;
|
|
@@ -89,7 +331,9 @@ interface EndpointDescriptor {
|
|
|
89
331
|
channel?: string;
|
|
90
332
|
capabilities: string[];
|
|
91
333
|
}
|
|
92
|
-
interface ServiceDefinition<TState extends Record<string, unknown> = Record<string, unknown>,
|
|
334
|
+
interface ServiceDefinition<TState extends Record<string, unknown> = Record<string, unknown>,
|
|
335
|
+
/** @deprecated Service-owned events are no longer part of the KrnlTS event model. */
|
|
336
|
+
TLegacyEvents extends Record<string, unknown> = Record<string, unknown>> {
|
|
93
337
|
id: string;
|
|
94
338
|
name: string;
|
|
95
339
|
version: string;
|
|
@@ -97,26 +341,26 @@ interface ServiceDefinition<TState extends Record<string, unknown> = Record<stri
|
|
|
97
341
|
outputs?: Record<string, Record<string, unknown>>;
|
|
98
342
|
operations: Record<string, OperationContract<any, any>>;
|
|
99
343
|
state?: StateContract<TState>;
|
|
100
|
-
events?: Record<keyof TEvents & string, EventContract<any>>;
|
|
101
344
|
lifecycle?: LifecycleContract;
|
|
102
345
|
dependencies?: DependencyContract[];
|
|
103
346
|
capabilities?: ServiceCapability[];
|
|
104
347
|
protocols?: ProtocolType[];
|
|
105
348
|
}
|
|
106
|
-
interface IService<TState extends Record<string, unknown> = Record<string, unknown>,
|
|
349
|
+
interface IService<TState extends Record<string, unknown> = Record<string, unknown>,
|
|
350
|
+
/** @deprecated Service-owned events are no longer part of the KrnlTS event model. */
|
|
351
|
+
TLegacyEvents extends Record<string, unknown> = Record<string, unknown>> {
|
|
107
352
|
readonly id: string;
|
|
108
353
|
readonly name: string;
|
|
109
354
|
readonly version: string;
|
|
355
|
+
readonly telemetry: TelemetryController;
|
|
110
356
|
call<TIn = unknown, TOut = unknown>(op: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
|
|
111
357
|
getState(): Readonly<TState>;
|
|
112
358
|
setState(mutation: Partial<TState>): void;
|
|
113
|
-
on<K extends keyof TEvents & string>(event: K, handler: (payload: TEvents[K]) => void): () => void;
|
|
114
|
-
emit<K extends keyof TEvents & string>(event: K, payload: TEvents[K]): void;
|
|
115
359
|
getStatus(): ServiceStatus;
|
|
116
360
|
start(): Promise<void>;
|
|
117
361
|
stop(): Promise<void>;
|
|
118
362
|
dispose(): Promise<void>;
|
|
119
|
-
getDefinition(): ServiceDefinition<TState,
|
|
363
|
+
getDefinition(): ServiceDefinition<TState, TLegacyEvents>;
|
|
120
364
|
}
|
|
121
365
|
|
|
122
366
|
/**
|
|
@@ -129,8 +373,8 @@ declare class ServiceInstance<TState extends Record<string, unknown> = Record<st
|
|
|
129
373
|
readonly id: string;
|
|
130
374
|
readonly name: string;
|
|
131
375
|
readonly version: string;
|
|
376
|
+
readonly telemetry: TelemetryController;
|
|
132
377
|
private stateStore?;
|
|
133
|
-
private readonly eventBus;
|
|
134
378
|
private readonly lifecycle;
|
|
135
379
|
private initialized;
|
|
136
380
|
private disposed;
|
|
@@ -143,8 +387,6 @@ declare class ServiceInstance<TState extends Record<string, unknown> = Record<st
|
|
|
143
387
|
call<TIn = unknown, TOut = unknown>(op: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
|
|
144
388
|
getState(): Readonly<TState>;
|
|
145
389
|
setState(mutation: Partial<TState>): void;
|
|
146
|
-
on<K extends keyof TEvents & string>(event: K, handler: (payload: TEvents[K]) => void): () => void;
|
|
147
|
-
emit<K extends keyof TEvents & string>(event: K, payload: TEvents[K]): void;
|
|
148
390
|
}
|
|
149
391
|
|
|
150
392
|
/**
|
|
@@ -202,6 +444,7 @@ declare class ServiceProxy<TState extends Record<string, unknown> = Record<strin
|
|
|
202
444
|
readonly id: string;
|
|
203
445
|
readonly name: string;
|
|
204
446
|
readonly version: string;
|
|
447
|
+
readonly telemetry: TelemetryController;
|
|
205
448
|
private stateCache;
|
|
206
449
|
private readonly eventHandlers;
|
|
207
450
|
private readonly lifecycle;
|
|
@@ -296,6 +539,7 @@ interface OrchestrationDefinition<TInput = unknown, TOutput = unknown> {
|
|
|
296
539
|
readonly version: string;
|
|
297
540
|
readonly description?: string;
|
|
298
541
|
readonly scope: 'functionality' | 'service';
|
|
542
|
+
readonly bubbleEvents?: boolean;
|
|
299
543
|
readonly dependencies: readonly string[];
|
|
300
544
|
readonly defaultFrontend?: OrchestrationFrontendReference;
|
|
301
545
|
readonly timeoutMs?: number;
|
|
@@ -334,6 +578,7 @@ interface OrchestrationDescriptor {
|
|
|
334
578
|
readonly timeoutMs?: number;
|
|
335
579
|
readonly concurrency?: number;
|
|
336
580
|
readonly scope?: 'functionality' | 'service';
|
|
581
|
+
readonly bubbleEvents?: boolean;
|
|
337
582
|
}
|
|
338
583
|
interface OrchestrationContext {
|
|
339
584
|
readonly correlationId: string;
|
|
@@ -386,6 +631,27 @@ interface DAGValidationResult {
|
|
|
386
631
|
*/
|
|
387
632
|
declare function validateOrchestrationDAG(steps: readonly OrchestrationStep[]): DAGValidationResult;
|
|
388
633
|
|
|
634
|
+
/**
|
|
635
|
+
* @file OrchestrationEventFacade.ts
|
|
636
|
+
* @description Default lifecycle event surface for functionality orchestrations.
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
interface OrchestrationEventNamespace {
|
|
640
|
+
readonly triggered: EventChannel<OrchestrationLifecyclePayload>;
|
|
641
|
+
readonly completed: EventChannel<OrchestrationLifecyclePayload>;
|
|
642
|
+
readonly failed: EventChannel<OrchestrationLifecyclePayload>;
|
|
643
|
+
}
|
|
644
|
+
declare class OrchestrationEventFacade {
|
|
645
|
+
private readonly eventBus;
|
|
646
|
+
readonly events: OrchestrationEventNamespace;
|
|
647
|
+
constructor();
|
|
648
|
+
get triggered(): EventChannel<OrchestrationLifecyclePayload>;
|
|
649
|
+
get completed(): EventChannel<OrchestrationLifecyclePayload>;
|
|
650
|
+
get failed(): EventChannel<OrchestrationLifecyclePayload>;
|
|
651
|
+
emit(event: 'triggered' | 'completed' | 'failed', payload: OrchestrationLifecyclePayload): void;
|
|
652
|
+
clear(): void;
|
|
653
|
+
}
|
|
654
|
+
|
|
389
655
|
interface FunctionalityFlowStep {
|
|
390
656
|
readonly id: string;
|
|
391
657
|
readonly type: 'functionality' | 'functionalityOrchestration';
|
|
@@ -428,6 +694,8 @@ declare class FunctionalityOrchestration {
|
|
|
428
694
|
readonly description: string;
|
|
429
695
|
readonly timeoutMs?: number;
|
|
430
696
|
readonly scope: 'functionality';
|
|
697
|
+
readonly bubbleEvents: boolean;
|
|
698
|
+
readonly events: OrchestrationEventFacade;
|
|
431
699
|
private readonly steps;
|
|
432
700
|
private readonly flows;
|
|
433
701
|
constructor(descriptor: OrchestrationDescriptor);
|
|
@@ -691,7 +959,7 @@ declare class ServiceFacade<TState extends Record<string, unknown> = Record<stri
|
|
|
691
959
|
readonly name: string;
|
|
692
960
|
readonly version: string;
|
|
693
961
|
readonly description: string;
|
|
694
|
-
readonly functionalities: Record<string,
|
|
962
|
+
readonly functionalities: Record<string, FunctionalityFacade<any, any, any, any>>;
|
|
695
963
|
readonly functionalityOrchestrations: Record<string, FunctionalityOrchestration>;
|
|
696
964
|
readonly libraries: TLibraries;
|
|
697
965
|
readonly dependencies: readonly DependencyContract[];
|
|
@@ -699,6 +967,7 @@ declare class ServiceFacade<TState extends Record<string, unknown> = Record<stri
|
|
|
699
967
|
readonly defaultFrontend?: DefaultFrontendReference;
|
|
700
968
|
private readonly instance;
|
|
701
969
|
private readonly queue;
|
|
970
|
+
readonly telemetry: TelemetryController;
|
|
702
971
|
constructor(config: ServiceFacadeConfig<TState, TEvents, TLibraries>);
|
|
703
972
|
get orchestrations(): Record<string, FunctionalityOrchestration>;
|
|
704
973
|
getInstance(): IService<TState, TEvents>;
|
|
@@ -740,17 +1009,18 @@ declare class ServiceFacade<TState extends Record<string, unknown> = Record<stri
|
|
|
740
1009
|
}): Promise<any>;
|
|
741
1010
|
getState(): Readonly<TState>;
|
|
742
1011
|
setState(mutation: Partial<TState>): void;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1012
|
+
getFunctionality(name: string): FunctionalityFacade<any, any, any, any>;
|
|
1013
|
+
registerFunctionality(name: string, functionality: unknown, options?: {
|
|
1014
|
+
bubbleEvents?: boolean;
|
|
1015
|
+
}): this;
|
|
746
1016
|
registerFunctionalityOrchestration(name: string, orchestration: FunctionalityOrchestration): this;
|
|
747
1017
|
/** @deprecated Use registerFunctionalityOrchestration */
|
|
748
1018
|
registerOrchestration(name: string, orchestration: FunctionalityOrchestration): this;
|
|
749
1019
|
registerLibrary<TLib = unknown>(name: string, library: TLib): this;
|
|
750
1020
|
getLibrary<TLib = unknown>(name: string): TLib;
|
|
751
|
-
get namespace(): ServiceNamespace<TLibraries, Record<string,
|
|
752
|
-
getNamespace(): ServiceNamespace<TLibraries, Record<string,
|
|
753
|
-
getServiceFacadeMetadata(): ServiceNamespace<TLibraries, Record<string,
|
|
1021
|
+
get namespace(): ServiceNamespace<TLibraries, Record<string, FunctionalityFacade<any, any, any, any>>, Record<string, FunctionalityOrchestration>>;
|
|
1022
|
+
getNamespace(): ServiceNamespace<TLibraries, Record<string, FunctionalityFacade<any, any, any, any>>, Record<string, FunctionalityOrchestration>>;
|
|
1023
|
+
getServiceFacadeMetadata(): ServiceNamespace<TLibraries, Record<string, FunctionalityFacade<any, any, any, any>>, Record<string, FunctionalityOrchestration>>;
|
|
754
1024
|
}
|
|
755
1025
|
declare function createServiceFacade<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>, TLibraries extends Record<string, unknown> = Record<string, unknown>>(config: ServiceFacadeConfig<TState, TEvents, TLibraries>): ServiceFacade<TState, TEvents, TLibraries>;
|
|
756
1026
|
|
|
@@ -946,15 +1216,31 @@ declare class ServiceStateStore<TState extends Record<string, unknown> = Record<
|
|
|
946
1216
|
}
|
|
947
1217
|
|
|
948
1218
|
/**
|
|
949
|
-
* @file
|
|
950
|
-
* @description
|
|
1219
|
+
* @file EventBus.ts
|
|
1220
|
+
* @description Generic in-process event bus used by functionality and orchestration event surfaces.
|
|
951
1221
|
*/
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1222
|
+
|
|
1223
|
+
declare class EventBus<TEvents extends Record<string, unknown> = Record<string, unknown>> {
|
|
1224
|
+
private readonly handlers;
|
|
1225
|
+
subscribe<K extends keyof TEvents & string>(event: K, handler: EventHandler<TEvents[K]>): EventSubscription;
|
|
1226
|
+
on<K extends keyof TEvents & string>(event: K, handler: EventHandler<TEvents[K]>): () => void;
|
|
955
1227
|
emit<K extends keyof TEvents & string>(event: K, payload: TEvents[K]): void;
|
|
956
1228
|
clear(): void;
|
|
957
1229
|
}
|
|
1230
|
+
declare function createEventChannels<TEvents extends Record<string, unknown>>(bus: EventBus<TEvents>, names: readonly (keyof TEvents & string)[]): {
|
|
1231
|
+
[K in keyof TEvents]: EventChannel<TEvents[K]>;
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* @file ServiceEventBus.ts
|
|
1236
|
+
* @description Backward-compatible generic event bus.
|
|
1237
|
+
*
|
|
1238
|
+
* KrnlTS no longer defines service-owned application events. First-class
|
|
1239
|
+
* application events are owned by functionalities and orchestration lifecycle.
|
|
1240
|
+
*/
|
|
1241
|
+
|
|
1242
|
+
declare class ServiceEventBus<TEvents extends Record<string, unknown> = Record<string, unknown>> extends EventBus<TEvents> {
|
|
1243
|
+
}
|
|
958
1244
|
|
|
959
1245
|
/**
|
|
960
1246
|
* @file ProtocolResolver.ts
|
|
@@ -966,4 +1252,4 @@ declare class ProtocolResolver {
|
|
|
966
1252
|
static getSupportedProtocols(definition: ServiceDefinition): ProtocolType[];
|
|
967
1253
|
}
|
|
968
1254
|
|
|
969
|
-
export { type BackendCommand, type Connection, type DAGValidationResult, type DefaultFrontendReference, type DependencyContract, type EndpointDescriptor, type EventContract, type ExecutionContext, type FunctionalityFlow, type FunctionalityFlowStep, FunctionalityOrchestration, type FunctionalityStepOptions, HttpProtocolAdapter, type IService, type IServiceFacade, type JobStatus, type KrnlJobDefinition, type KrnlJobHandle, type KrnlJobOptions, KrnlPackageReconciler, KrnlQueue, type KrnlQueueOptions, type KrnlWorkerInfo, KrnlWorkerPool, type KrnlWorkerState, type LifecycleContract, LifecycleManager, MemoryTransport, type NormalizedResult, type OperationContext, type OperationContract, type OrchestrationContext, type OrchestrationDefinition, type OrchestrationDescriptor, type OrchestrationFrontendReference, type OrchestrationResult, type OrchestrationStatus, type OrchestrationStep, P2PProtocolAdapter, type PeerRecord, type ProtocolAdapter, type ProtocolCapabilities, type ProtocolEnvelope, ProtocolResolver, type ProtocolType, type ReconcileResult, type RegisteredServiceRecord, type SagaCompensationHandler, type ServiceCapability, type ServiceDefinition, ServiceDiscovery, ServiceEventBus, ServiceFacade, type ServiceFacadeConfig, ServiceInstance, type ServiceNamespace, ServiceProxy, ServiceRegistry, ServiceRuntime, ServiceStateStore, type ServiceStatus, type StateContract, type StepCompensation, type StepCondition, type StepDefinition, type StepExecutionResult, type StepExecutionStatus, type StepRetryPolicy, type StepStatus, type StepTimeoutPolicy, type StepType, UdpProtocolAdapter, WebSocketProtocolAdapter, WorkerExecutionBoundary, createService, createServiceDefinition, createServiceFacade, createServiceProxy, validateOrchestrationDAG, validateServiceDefinition };
|
|
1255
|
+
export { type BackendCommand, type Connection, type DAGValidationResult, type DefaultFrontendReference, type DependencyContract, type EndpointDescriptor, EventBus, type EventChannel, type EventContract, type EventDefinition, type EventHandler, type EventSubscription, type ExecutionContext, type FunctionalityCustomEvents, type FunctionalityDefinition, type FunctionalityEventNamespace, type FunctionalityEvents, type FunctionalityExecutionContext, FunctionalityFacade, type FunctionalityFlow, type FunctionalityFlowStep, type FunctionalityLifecycleEvent, type FunctionalityLifecyclePayload, FunctionalityOrchestration, type FunctionalityStepOptions, HttpProtocolAdapter, type IService, type IServiceFacade, type JobStatus, type KrnlJobDefinition, type KrnlJobHandle, type KrnlJobOptions, KrnlPackageReconciler, KrnlQueue, type KrnlQueueOptions, type KrnlWorkerInfo, KrnlWorkerPool, type KrnlWorkerState, type LifecycleContract, LifecycleManager, MemoryTransport, type NormalizedResult, type OperationContext, type OperationContract, type OrchestrationContext, type OrchestrationDefinition, type OrchestrationDescriptor, OrchestrationEventFacade, type OrchestrationEventNamespace, type OrchestrationFrontendReference, type OrchestrationLifecyclePayload, type OrchestrationResult, type OrchestrationStatus, type OrchestrationStep, P2PProtocolAdapter, type PeerRecord, type ProtocolAdapter, type ProtocolCapabilities, type ProtocolEnvelope, ProtocolResolver, type ProtocolType, type ReconcileResult, type RegisteredServiceRecord, type SagaCompensationHandler, type ServiceCapability, type ServiceDefinition, ServiceDiscovery, ServiceEventBus, ServiceFacade, type ServiceFacadeConfig, ServiceInstance, type ServiceNamespace, ServiceProxy, ServiceRegistry, ServiceRuntime, ServiceStateStore, type ServiceStatus, type StateContract, type StepCompensation, type StepCondition, type StepDefinition, type StepExecutionResult, type StepExecutionStatus, type StepRetryPolicy, type StepStatus, type StepTimeoutPolicy, type StepType, TelemetryController, type TelemetryHandle, type TelemetryInvocation, type TelemetryMode, type TelemetryOptions, type TelemetryPercentiles, type TelemetryResourceSample, type TelemetrySnapshot, type TelemetryStatus, type TelemetryTargetStats, UdpProtocolAdapter, WebSocketProtocolAdapter, WorkerExecutionBoundary, createEventChannels, createService, createServiceDefinition, createServiceFacade, createServiceProxy, deltaResources, sampleResources, telemetryNow, validateOrchestrationDAG, validateServiceDefinition };
|