@stackwright-services/capabilities 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +750 -0
- package/dist/index.d.ts +750 -0
- package/dist/index.js +1431 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1365 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { CapabilityDefinition, PredicateCondition } from '@stackwright-services/types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runtime capability handler -- the actual implementation function.
|
|
6
|
+
*
|
|
7
|
+
* For transforms: pure function, no side effects.
|
|
8
|
+
* For effects: may perform I/O (HTTP calls, notifications, etc.)
|
|
9
|
+
*/
|
|
10
|
+
type CapabilityHandler<TInput = unknown, TOutput = unknown> = (input: TInput, context: CapabilityContext) => Promise<TOutput>;
|
|
11
|
+
/**
|
|
12
|
+
* Minimal message bus interface for capability handlers.
|
|
13
|
+
*
|
|
14
|
+
* This is a subset of MessageBusProvider (from @stackwright-services/runtime).
|
|
15
|
+
* Defined inline to avoid circular dependency (capabilities ← runtime).
|
|
16
|
+
* Runtime's MessageBusProvider structurally satisfies this interface.
|
|
17
|
+
*/
|
|
18
|
+
interface CapabilityMessageBus {
|
|
19
|
+
publish(topic: string, message: {
|
|
20
|
+
payload: unknown;
|
|
21
|
+
traceContext?: Record<string, string>;
|
|
22
|
+
metadata?: {
|
|
23
|
+
timestamp?: string;
|
|
24
|
+
source?: string;
|
|
25
|
+
correlationId?: string;
|
|
26
|
+
messageId?: string;
|
|
27
|
+
};
|
|
28
|
+
}): Promise<{
|
|
29
|
+
messageId: string;
|
|
30
|
+
topic: string;
|
|
31
|
+
success: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Minimal data source provider interface for capability handlers.
|
|
36
|
+
*
|
|
37
|
+
* This is a subset of DataSourceProvider (from @stackwright-services/runtime).
|
|
38
|
+
* Defined inline to avoid circular dependency (capabilities ← runtime).
|
|
39
|
+
* Runtime's DataSourceProvider structurally satisfies this interface.
|
|
40
|
+
*
|
|
41
|
+
* Used by service.call to delegate to a typed provider when one is installed,
|
|
42
|
+
* falling back to raw HTTP when the source is not known by any provider.
|
|
43
|
+
*/
|
|
44
|
+
interface CapabilityDataSourceProvider {
|
|
45
|
+
/** Enumerate all sources this provider knows. Used to check resolvability before execute(). */
|
|
46
|
+
listSources(): Array<{
|
|
47
|
+
id: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Execute a named operation against a source.
|
|
51
|
+
* @param source - Source ID (without transport prefix, e.g. "equipment-api")
|
|
52
|
+
* @param operation - Operation name (e.g. "listUnits")
|
|
53
|
+
* @param params - Operation parameters
|
|
54
|
+
*/
|
|
55
|
+
execute(source: string, operation: string, params: unknown): Promise<{
|
|
56
|
+
data: unknown;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Minimal notification provider interface for capability handlers.
|
|
62
|
+
*
|
|
63
|
+
* This is a subset of NotificationProvider (from @stackwright-services/runtime).
|
|
64
|
+
* Defined inline to avoid circular dependency (capabilities ← runtime).
|
|
65
|
+
* Runtime's NotificationProvider structurally satisfies this interface.
|
|
66
|
+
*/
|
|
67
|
+
interface CapabilityNotificationProvider {
|
|
68
|
+
send(notification: {
|
|
69
|
+
/** Recipient user identifier — the provider resolves this to a delivery address */
|
|
70
|
+
recipient: string;
|
|
71
|
+
/** Delivery channel */
|
|
72
|
+
channel: 'email' | 'sms' | 'push' | 'in-app';
|
|
73
|
+
/** Template name for the notification content */
|
|
74
|
+
template: string;
|
|
75
|
+
/** Typed payload for template interpolation */
|
|
76
|
+
payload: unknown;
|
|
77
|
+
/** Optional subject line (for email, push) */
|
|
78
|
+
subject?: string;
|
|
79
|
+
/** Trace context for observability */
|
|
80
|
+
traceContext?: Record<string, string>;
|
|
81
|
+
/** Message metadata */
|
|
82
|
+
metadata?: {
|
|
83
|
+
timestamp?: string;
|
|
84
|
+
source?: string;
|
|
85
|
+
correlationId?: string;
|
|
86
|
+
};
|
|
87
|
+
}): Promise<{
|
|
88
|
+
notificationId: string;
|
|
89
|
+
channel: string;
|
|
90
|
+
success: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Runtime context passed to every capability handler.
|
|
95
|
+
* Provides controlled access to runtime services without ambient permissions.
|
|
96
|
+
*/
|
|
97
|
+
interface CapabilityContext {
|
|
98
|
+
/** Trace ID for observability correlation */
|
|
99
|
+
traceId: string;
|
|
100
|
+
/** Logger scoped to this capability invocation */
|
|
101
|
+
logger: CapabilityLogger;
|
|
102
|
+
/** Message bus for publishing events (injected by runtime, optional) */
|
|
103
|
+
messageBus?: CapabilityMessageBus;
|
|
104
|
+
/** Notification provider for sending user notifications (injected by runtime, optional) */
|
|
105
|
+
notificationProvider?: CapabilityNotificationProvider;
|
|
106
|
+
/**
|
|
107
|
+
* Data source provider for typed, permission-scoped source access (injected by runtime, optional).
|
|
108
|
+
* When present and a source is resolvable, service.call delegates to this instead of raw HTTP.
|
|
109
|
+
*/
|
|
110
|
+
dataSourceProvider?: CapabilityDataSourceProvider;
|
|
111
|
+
}
|
|
112
|
+
interface CapabilityLogger {
|
|
113
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
114
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
115
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
116
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A registered capability -- definition + handler + runtime schemas.
|
|
120
|
+
*/
|
|
121
|
+
interface RegisteredCapability<TInput = unknown, TOutput = unknown> {
|
|
122
|
+
/** The capability definition (from types package) */
|
|
123
|
+
definition: CapabilityDefinition;
|
|
124
|
+
/** The runtime handler function */
|
|
125
|
+
handler: CapabilityHandler<TInput, TOutput>;
|
|
126
|
+
/** Zod schema for runtime input validation */
|
|
127
|
+
inputSchema: z.ZodType<TInput>;
|
|
128
|
+
/** Zod schema for runtime output validation */
|
|
129
|
+
outputSchema: z.ZodType<TOutput>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The capability registry -- the audited library of what the system can do.
|
|
133
|
+
*
|
|
134
|
+
* This is the backend mirror of the frontend content-type registry.
|
|
135
|
+
* Citizen developers compose from it; engineers extend it.
|
|
136
|
+
* Registration is the audit chokepoint.
|
|
137
|
+
*/
|
|
138
|
+
declare class CapabilityRegistry {
|
|
139
|
+
private capabilities;
|
|
140
|
+
/**
|
|
141
|
+
* Register a capability. This is a security-relevant operation --
|
|
142
|
+
* every registration should be audited.
|
|
143
|
+
*
|
|
144
|
+
* @throws if a capability with the same name is already registered
|
|
145
|
+
*/
|
|
146
|
+
register<TInput, TOutput>(definition: CapabilityDefinition, handler: CapabilityHandler<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Look up a capability by name.
|
|
149
|
+
* @returns the registered capability, or undefined if not found
|
|
150
|
+
*/
|
|
151
|
+
lookup(name: string): RegisteredCapability | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Get a capability by name, throwing if not found.
|
|
154
|
+
* @throws if the capability is not registered
|
|
155
|
+
*/
|
|
156
|
+
get(name: string): RegisteredCapability;
|
|
157
|
+
/**
|
|
158
|
+
* List all registered capabilities.
|
|
159
|
+
*/
|
|
160
|
+
listAll(): RegisteredCapability[];
|
|
161
|
+
/**
|
|
162
|
+
* List all registered capability names.
|
|
163
|
+
*/
|
|
164
|
+
listNames(): string[];
|
|
165
|
+
/**
|
|
166
|
+
* Filter capabilities by kind (transform or effect).
|
|
167
|
+
*/
|
|
168
|
+
filterByKind(kind: 'transform' | 'effect'): RegisteredCapability[];
|
|
169
|
+
/**
|
|
170
|
+
* Check if a capability is registered.
|
|
171
|
+
*/
|
|
172
|
+
has(name: string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Get the count of registered capabilities.
|
|
175
|
+
*/
|
|
176
|
+
get size(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Clear all registrations. Primarily for testing.
|
|
179
|
+
*/
|
|
180
|
+
clear(): void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The global default registry instance.
|
|
184
|
+
* Packages register their capabilities here at import time.
|
|
185
|
+
*/
|
|
186
|
+
declare const defaultRegistry: CapabilityRegistry;
|
|
187
|
+
|
|
188
|
+
declare const UnitsConvertInput: z.ZodObject<{
|
|
189
|
+
value: z.ZodNumber;
|
|
190
|
+
from: z.ZodString;
|
|
191
|
+
to: z.ZodString;
|
|
192
|
+
category: z.ZodEnum<["length", "weight", "temperature", "volume"]>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
value: number;
|
|
195
|
+
from: string;
|
|
196
|
+
to: string;
|
|
197
|
+
category: "length" | "weight" | "temperature" | "volume";
|
|
198
|
+
}, {
|
|
199
|
+
value: number;
|
|
200
|
+
from: string;
|
|
201
|
+
to: string;
|
|
202
|
+
category: "length" | "weight" | "temperature" | "volume";
|
|
203
|
+
}>;
|
|
204
|
+
type UnitsConvertInput = z.infer<typeof UnitsConvertInput>;
|
|
205
|
+
declare const UnitsConvertOutput: z.ZodObject<{
|
|
206
|
+
result: z.ZodNumber;
|
|
207
|
+
from: z.ZodString;
|
|
208
|
+
to: z.ZodString;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
result: number;
|
|
211
|
+
from: string;
|
|
212
|
+
to: string;
|
|
213
|
+
}, {
|
|
214
|
+
result: number;
|
|
215
|
+
from: string;
|
|
216
|
+
to: string;
|
|
217
|
+
}>;
|
|
218
|
+
type UnitsConvertOutput = z.infer<typeof UnitsConvertOutput>;
|
|
219
|
+
declare const unitsConvertHandler: CapabilityHandler<UnitsConvertInput, UnitsConvertOutput>;
|
|
220
|
+
|
|
221
|
+
declare const TextFormatInput: z.ZodObject<{
|
|
222
|
+
template: z.ZodString;
|
|
223
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
224
|
+
}, "strip", z.ZodTypeAny, {
|
|
225
|
+
params: Record<string, string | number | boolean>;
|
|
226
|
+
template: string;
|
|
227
|
+
}, {
|
|
228
|
+
params: Record<string, string | number | boolean>;
|
|
229
|
+
template: string;
|
|
230
|
+
}>;
|
|
231
|
+
type TextFormatInput = z.infer<typeof TextFormatInput>;
|
|
232
|
+
declare const TextFormatOutput: z.ZodObject<{
|
|
233
|
+
result: z.ZodString;
|
|
234
|
+
}, "strip", z.ZodTypeAny, {
|
|
235
|
+
result: string;
|
|
236
|
+
}, {
|
|
237
|
+
result: string;
|
|
238
|
+
}>;
|
|
239
|
+
type TextFormatOutput = z.infer<typeof TextFormatOutput>;
|
|
240
|
+
declare const textFormatHandler: CapabilityHandler<TextFormatInput, TextFormatOutput>;
|
|
241
|
+
|
|
242
|
+
declare const CollectionFilterInput: z.ZodObject<{
|
|
243
|
+
items: z.ZodArray<z.ZodUnknown, "many">;
|
|
244
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
245
|
+
field: z.ZodString;
|
|
246
|
+
op: z.ZodString;
|
|
247
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
248
|
+
value_field: z.ZodOptional<z.ZodString>;
|
|
249
|
+
}, "strip", z.ZodTypeAny, {
|
|
250
|
+
field: string;
|
|
251
|
+
op: string;
|
|
252
|
+
value?: unknown;
|
|
253
|
+
value_field?: string | undefined;
|
|
254
|
+
}, {
|
|
255
|
+
field: string;
|
|
256
|
+
op: string;
|
|
257
|
+
value?: unknown;
|
|
258
|
+
value_field?: string | undefined;
|
|
259
|
+
}>, "many">;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
items: unknown[];
|
|
262
|
+
conditions: {
|
|
263
|
+
field: string;
|
|
264
|
+
op: string;
|
|
265
|
+
value?: unknown;
|
|
266
|
+
value_field?: string | undefined;
|
|
267
|
+
}[];
|
|
268
|
+
}, {
|
|
269
|
+
items: unknown[];
|
|
270
|
+
conditions: {
|
|
271
|
+
field: string;
|
|
272
|
+
op: string;
|
|
273
|
+
value?: unknown;
|
|
274
|
+
value_field?: string | undefined;
|
|
275
|
+
}[];
|
|
276
|
+
}>;
|
|
277
|
+
type CollectionFilterInput = z.infer<typeof CollectionFilterInput>;
|
|
278
|
+
declare const CollectionFilterOutput: z.ZodObject<{
|
|
279
|
+
items: z.ZodArray<z.ZodUnknown, "many">;
|
|
280
|
+
count: z.ZodNumber;
|
|
281
|
+
}, "strip", z.ZodTypeAny, {
|
|
282
|
+
count: number;
|
|
283
|
+
items: unknown[];
|
|
284
|
+
}, {
|
|
285
|
+
count: number;
|
|
286
|
+
items: unknown[];
|
|
287
|
+
}>;
|
|
288
|
+
type CollectionFilterOutput = z.infer<typeof CollectionFilterOutput>;
|
|
289
|
+
/**
|
|
290
|
+
* Evaluate a single typed predicate condition against an item.
|
|
291
|
+
*
|
|
292
|
+
* This function implements the CLOSED operator set from PredicateOperator.
|
|
293
|
+
* It uses an exhaustive switch -- adding an operator requires updating this function.
|
|
294
|
+
*
|
|
295
|
+
* @security-critical -- only the 13 operators in the closed enum are supported.
|
|
296
|
+
*/
|
|
297
|
+
declare function evaluatePredicate(item: unknown, condition: PredicateCondition): boolean;
|
|
298
|
+
declare const collectionFilterHandler: CapabilityHandler<CollectionFilterInput, CollectionFilterOutput>;
|
|
299
|
+
|
|
300
|
+
declare const CollectionAggregateInput: z.ZodObject<{
|
|
301
|
+
items: z.ZodArray<z.ZodUnknown, "many">;
|
|
302
|
+
field: z.ZodString;
|
|
303
|
+
operation: z.ZodEnum<["count", "sum", "avg", "min", "max"]>;
|
|
304
|
+
}, "strip", z.ZodTypeAny, {
|
|
305
|
+
items: unknown[];
|
|
306
|
+
field: string;
|
|
307
|
+
operation: "count" | "sum" | "avg" | "min" | "max";
|
|
308
|
+
}, {
|
|
309
|
+
items: unknown[];
|
|
310
|
+
field: string;
|
|
311
|
+
operation: "count" | "sum" | "avg" | "min" | "max";
|
|
312
|
+
}>;
|
|
313
|
+
type CollectionAggregateInput = z.infer<typeof CollectionAggregateInput>;
|
|
314
|
+
declare const CollectionAggregateOutput: z.ZodObject<{
|
|
315
|
+
result: z.ZodNumber;
|
|
316
|
+
}, "strip", z.ZodTypeAny, {
|
|
317
|
+
result: number;
|
|
318
|
+
}, {
|
|
319
|
+
result: number;
|
|
320
|
+
}>;
|
|
321
|
+
type CollectionAggregateOutput = z.infer<typeof CollectionAggregateOutput>;
|
|
322
|
+
declare const collectionAggregateHandler: CapabilityHandler<CollectionAggregateInput, CollectionAggregateOutput>;
|
|
323
|
+
|
|
324
|
+
declare const CollectionJoinInput: z.ZodObject<{
|
|
325
|
+
/** Left-side items array */
|
|
326
|
+
leftItems: z.ZodArray<z.ZodUnknown, "many">;
|
|
327
|
+
/** Right-side items array */
|
|
328
|
+
rightItems: z.ZodArray<z.ZodUnknown, "many">;
|
|
329
|
+
/** Field path on left items to join on */
|
|
330
|
+
leftField: z.ZodString;
|
|
331
|
+
/** Field path on right items to join on */
|
|
332
|
+
rightField: z.ZodString;
|
|
333
|
+
}, "strip", z.ZodTypeAny, {
|
|
334
|
+
leftItems: unknown[];
|
|
335
|
+
rightItems: unknown[];
|
|
336
|
+
leftField: string;
|
|
337
|
+
rightField: string;
|
|
338
|
+
}, {
|
|
339
|
+
leftItems: unknown[];
|
|
340
|
+
rightItems: unknown[];
|
|
341
|
+
leftField: string;
|
|
342
|
+
rightField: string;
|
|
343
|
+
}>;
|
|
344
|
+
type CollectionJoinInput = z.infer<typeof CollectionJoinInput>;
|
|
345
|
+
declare const CollectionJoinOutput: z.ZodObject<{
|
|
346
|
+
/** Merged items where left[leftField] === right[rightField] */
|
|
347
|
+
items: z.ZodArray<z.ZodObject<{
|
|
348
|
+
left: z.ZodUnknown;
|
|
349
|
+
right: z.ZodUnknown;
|
|
350
|
+
}, "strip", z.ZodTypeAny, {
|
|
351
|
+
left?: unknown;
|
|
352
|
+
right?: unknown;
|
|
353
|
+
}, {
|
|
354
|
+
left?: unknown;
|
|
355
|
+
right?: unknown;
|
|
356
|
+
}>, "many">;
|
|
357
|
+
/** Count of matched items */
|
|
358
|
+
count: z.ZodNumber;
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
count: number;
|
|
361
|
+
items: {
|
|
362
|
+
left?: unknown;
|
|
363
|
+
right?: unknown;
|
|
364
|
+
}[];
|
|
365
|
+
}, {
|
|
366
|
+
count: number;
|
|
367
|
+
items: {
|
|
368
|
+
left?: unknown;
|
|
369
|
+
right?: unknown;
|
|
370
|
+
}[];
|
|
371
|
+
}>;
|
|
372
|
+
type CollectionJoinOutput = z.infer<typeof CollectionJoinOutput>;
|
|
373
|
+
/**
|
|
374
|
+
* Join two arrays on matching field values for cross-domain data correlation.
|
|
375
|
+
*
|
|
376
|
+
* Pure transform (no I/O, trivially auditable).
|
|
377
|
+
* Uses hash-based lookup for O(n+m) performance instead of O(n*m).
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* join(patients, generators, 'currentFacility', 'facilityId')
|
|
381
|
+
* → [{ left: patient, right: generator }, ...]
|
|
382
|
+
*/
|
|
383
|
+
declare const collectionJoinHandler: CapabilityHandler<CollectionJoinInput, CollectionJoinOutput>;
|
|
384
|
+
|
|
385
|
+
declare const DateShiftInput: z.ZodObject<{
|
|
386
|
+
date: z.ZodString;
|
|
387
|
+
duration: z.ZodString;
|
|
388
|
+
direction: z.ZodEnum<["add", "subtract"]>;
|
|
389
|
+
}, "strip", z.ZodTypeAny, {
|
|
390
|
+
date: string;
|
|
391
|
+
direction: "add" | "subtract";
|
|
392
|
+
duration: string;
|
|
393
|
+
}, {
|
|
394
|
+
date: string;
|
|
395
|
+
direction: "add" | "subtract";
|
|
396
|
+
duration: string;
|
|
397
|
+
}>;
|
|
398
|
+
type DateShiftInput = z.infer<typeof DateShiftInput>;
|
|
399
|
+
declare const DateShiftOutput: z.ZodObject<{
|
|
400
|
+
result: z.ZodString;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
result: string;
|
|
403
|
+
}, {
|
|
404
|
+
result: string;
|
|
405
|
+
}>;
|
|
406
|
+
type DateShiftOutput = z.infer<typeof DateShiftOutput>;
|
|
407
|
+
declare const dateShiftHandler: CapabilityHandler<DateShiftInput, DateShiftOutput>;
|
|
408
|
+
|
|
409
|
+
declare const EventsFilterInput: z.ZodObject<{
|
|
410
|
+
/** The event payload to evaluate */
|
|
411
|
+
event: z.ZodUnknown;
|
|
412
|
+
/** Typed predicate conditions -- all must pass for the event to pass through */
|
|
413
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
414
|
+
field: z.ZodString;
|
|
415
|
+
op: z.ZodString;
|
|
416
|
+
value: z.ZodUnknown;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
field: string;
|
|
419
|
+
op: string;
|
|
420
|
+
value?: unknown;
|
|
421
|
+
}, {
|
|
422
|
+
field: string;
|
|
423
|
+
op: string;
|
|
424
|
+
value?: unknown;
|
|
425
|
+
}>, "many">;
|
|
426
|
+
}, "strip", z.ZodTypeAny, {
|
|
427
|
+
conditions: {
|
|
428
|
+
field: string;
|
|
429
|
+
op: string;
|
|
430
|
+
value?: unknown;
|
|
431
|
+
}[];
|
|
432
|
+
event?: unknown;
|
|
433
|
+
}, {
|
|
434
|
+
conditions: {
|
|
435
|
+
field: string;
|
|
436
|
+
op: string;
|
|
437
|
+
value?: unknown;
|
|
438
|
+
}[];
|
|
439
|
+
event?: unknown;
|
|
440
|
+
}>;
|
|
441
|
+
type EventsFilterInput = z.infer<typeof EventsFilterInput>;
|
|
442
|
+
declare const EventsFilterOutput: z.ZodObject<{
|
|
443
|
+
/** The event if it passed all conditions, or null if filtered out */
|
|
444
|
+
event: z.ZodNullable<z.ZodUnknown>;
|
|
445
|
+
/** Whether the event passed all conditions */
|
|
446
|
+
passed: z.ZodBoolean;
|
|
447
|
+
}, "strip", z.ZodTypeAny, {
|
|
448
|
+
passed: boolean;
|
|
449
|
+
event?: unknown;
|
|
450
|
+
}, {
|
|
451
|
+
passed: boolean;
|
|
452
|
+
event?: unknown;
|
|
453
|
+
}>;
|
|
454
|
+
type EventsFilterOutput = z.infer<typeof EventsFilterOutput>;
|
|
455
|
+
declare const eventsFilterHandler: CapabilityHandler<EventsFilterInput, EventsFilterOutput>;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Register all built-in transform capabilities with the given registry.
|
|
459
|
+
*/
|
|
460
|
+
declare function registerTransforms(registry: CapabilityRegistry): void;
|
|
461
|
+
|
|
462
|
+
declare const ServiceCallInput: z.ZodObject<{
|
|
463
|
+
/** The URL to call (raw HTTP fallback — always required so the effect works without a provider) */
|
|
464
|
+
url: z.ZodString;
|
|
465
|
+
/** HTTP method */
|
|
466
|
+
method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
|
|
467
|
+
/**
|
|
468
|
+
* Data source ID for provider delegation (e.g. "equipment-api").
|
|
469
|
+
* When provided alongside `operation`, and a DataSourceProvider in context can resolve
|
|
470
|
+
* this source, the call is delegated to the provider instead of raw HTTP.
|
|
471
|
+
* Falls back to `url`+`method` when no provider is installed or source is not known.
|
|
472
|
+
*/
|
|
473
|
+
source: z.ZodOptional<z.ZodString>;
|
|
474
|
+
/**
|
|
475
|
+
* Operation name for provider delegation (e.g. "listUnits").
|
|
476
|
+
* Must be provided together with `source` to trigger provider delegation.
|
|
477
|
+
*/
|
|
478
|
+
operation: z.ZodOptional<z.ZodString>;
|
|
479
|
+
/** Request headers */
|
|
480
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
481
|
+
/** Request body (for POST/PUT/PATCH, or provider operation params when delegating) */
|
|
482
|
+
body: z.ZodOptional<z.ZodUnknown>;
|
|
483
|
+
/** Expected response type (defaults to 'json') */
|
|
484
|
+
responseType: z.ZodOptional<z.ZodEnum<["json", "text"]>>;
|
|
485
|
+
/** Timeout in milliseconds (defaults to 30000) */
|
|
486
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
487
|
+
}, "strip", z.ZodTypeAny, {
|
|
488
|
+
url: string;
|
|
489
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
490
|
+
operation?: string | undefined;
|
|
491
|
+
source?: string | undefined;
|
|
492
|
+
headers?: Record<string, string> | undefined;
|
|
493
|
+
body?: unknown;
|
|
494
|
+
responseType?: "json" | "text" | undefined;
|
|
495
|
+
timeout?: number | undefined;
|
|
496
|
+
}, {
|
|
497
|
+
url: string;
|
|
498
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
499
|
+
operation?: string | undefined;
|
|
500
|
+
source?: string | undefined;
|
|
501
|
+
headers?: Record<string, string> | undefined;
|
|
502
|
+
body?: unknown;
|
|
503
|
+
responseType?: "json" | "text" | undefined;
|
|
504
|
+
timeout?: number | undefined;
|
|
505
|
+
}>;
|
|
506
|
+
type ServiceCallInput = z.infer<typeof ServiceCallInput>;
|
|
507
|
+
declare const ServiceCallOutput: z.ZodObject<{
|
|
508
|
+
/** HTTP status code */
|
|
509
|
+
status: z.ZodNumber;
|
|
510
|
+
/** Response headers */
|
|
511
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
512
|
+
/** Response body */
|
|
513
|
+
body: z.ZodUnknown;
|
|
514
|
+
/** Whether the call was successful (2xx status) */
|
|
515
|
+
ok: z.ZodBoolean;
|
|
516
|
+
}, "strip", z.ZodTypeAny, {
|
|
517
|
+
status: number;
|
|
518
|
+
headers: Record<string, string>;
|
|
519
|
+
ok: boolean;
|
|
520
|
+
body?: unknown;
|
|
521
|
+
}, {
|
|
522
|
+
status: number;
|
|
523
|
+
headers: Record<string, string>;
|
|
524
|
+
ok: boolean;
|
|
525
|
+
body?: unknown;
|
|
526
|
+
}>;
|
|
527
|
+
type ServiceCallOutput = z.infer<typeof ServiceCallOutput>;
|
|
528
|
+
/**
|
|
529
|
+
* Service call effect -- invokes an HTTP endpoint.
|
|
530
|
+
*
|
|
531
|
+
* This is the raw-HTTP escape hatch and also the provider-delegation bridge:
|
|
532
|
+
* - When `source` + `operation` are given and a DataSourceProvider in context
|
|
533
|
+
* knows about the source, execution is delegated to the provider (typed, validated).
|
|
534
|
+
* - Otherwise (no provider, or source not resolvable) it falls back to raw Fetch.
|
|
535
|
+
*
|
|
536
|
+
* This is an Effect capability: it touches the outside world.
|
|
537
|
+
* Required permissions are declared in the definition and used
|
|
538
|
+
* for least-privilege derivation at compile time.
|
|
539
|
+
*
|
|
540
|
+
* Uses the standard Fetch API -- works in Node.js 22+, Lambda, and edge.
|
|
541
|
+
*/
|
|
542
|
+
declare const serviceCallHandler: CapabilityHandler<ServiceCallInput, ServiceCallOutput>;
|
|
543
|
+
|
|
544
|
+
declare const EventsPublishInput: z.ZodObject<{
|
|
545
|
+
/** Topic to publish to (e.g. "bus:equipment-status" or "equipment-status") */
|
|
546
|
+
topic: z.ZodString;
|
|
547
|
+
/** Message payload to publish */
|
|
548
|
+
payload: z.ZodUnknown;
|
|
549
|
+
/** Optional metadata to include with the message */
|
|
550
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
551
|
+
/** Logical source identifier */
|
|
552
|
+
source: z.ZodOptional<z.ZodString>;
|
|
553
|
+
/** Correlation ID for request-scoped grouping */
|
|
554
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
555
|
+
}, "strip", z.ZodTypeAny, {
|
|
556
|
+
source?: string | undefined;
|
|
557
|
+
correlationId?: string | undefined;
|
|
558
|
+
}, {
|
|
559
|
+
source?: string | undefined;
|
|
560
|
+
correlationId?: string | undefined;
|
|
561
|
+
}>>;
|
|
562
|
+
}, "strip", z.ZodTypeAny, {
|
|
563
|
+
topic: string;
|
|
564
|
+
payload?: unknown;
|
|
565
|
+
metadata?: {
|
|
566
|
+
source?: string | undefined;
|
|
567
|
+
correlationId?: string | undefined;
|
|
568
|
+
} | undefined;
|
|
569
|
+
}, {
|
|
570
|
+
topic: string;
|
|
571
|
+
payload?: unknown;
|
|
572
|
+
metadata?: {
|
|
573
|
+
source?: string | undefined;
|
|
574
|
+
correlationId?: string | undefined;
|
|
575
|
+
} | undefined;
|
|
576
|
+
}>;
|
|
577
|
+
type EventsPublishInput = z.infer<typeof EventsPublishInput>;
|
|
578
|
+
declare const EventsPublishOutput: z.ZodObject<{
|
|
579
|
+
/** Provider-assigned message ID */
|
|
580
|
+
messageId: z.ZodString;
|
|
581
|
+
/** Topic the message was published to (without bus: prefix) */
|
|
582
|
+
topic: z.ZodString;
|
|
583
|
+
/** Whether publishing succeeded */
|
|
584
|
+
success: z.ZodBoolean;
|
|
585
|
+
}, "strip", z.ZodTypeAny, {
|
|
586
|
+
topic: string;
|
|
587
|
+
messageId: string;
|
|
588
|
+
success: boolean;
|
|
589
|
+
}, {
|
|
590
|
+
topic: string;
|
|
591
|
+
messageId: string;
|
|
592
|
+
success: boolean;
|
|
593
|
+
}>;
|
|
594
|
+
type EventsPublishOutput = z.infer<typeof EventsPublishOutput>;
|
|
595
|
+
/**
|
|
596
|
+
* Strip the "bus:" prefix from a topic if present.
|
|
597
|
+
* YAML writes "bus:equipment-status"; the provider receives "equipment-status".
|
|
598
|
+
*/
|
|
599
|
+
declare function stripBusPrefix(topic: string): string;
|
|
600
|
+
/**
|
|
601
|
+
* events.publish effect — publishes a message to a message bus topic.
|
|
602
|
+
*
|
|
603
|
+
* This is an Effect capability: it touches the outside world.
|
|
604
|
+
* The MessageBusProvider is injected via CapabilityContext.messageBus.
|
|
605
|
+
*
|
|
606
|
+
* Declares required permissions for least-privilege derivation:
|
|
607
|
+
* { resource: 'bus:<topic>', action: 'publish' }
|
|
608
|
+
*/
|
|
609
|
+
declare const eventsPublishHandler: CapabilityHandler<EventsPublishInput, EventsPublishOutput>;
|
|
610
|
+
/**
|
|
611
|
+
* events.publish capability definition.
|
|
612
|
+
*
|
|
613
|
+
* This is an Effect — it declares requiredPermissions.
|
|
614
|
+
* At compile time, the permission derivation system reads these to generate
|
|
615
|
+
* least-privilege IAM policies / RBAC manifests.
|
|
616
|
+
*
|
|
617
|
+
* Permission: { resource: 'bus:*', action: 'publish' }
|
|
618
|
+
* The compiler can narrow the wildcard to specific topics by inspecting the
|
|
619
|
+
* flow's step parameters (e.g. bus:equipment-status).
|
|
620
|
+
*/
|
|
621
|
+
declare const eventsPublishDefinition: {
|
|
622
|
+
kind: "effect";
|
|
623
|
+
name: string;
|
|
624
|
+
description: string;
|
|
625
|
+
inputSchema: string;
|
|
626
|
+
outputSchema: string;
|
|
627
|
+
requiredPermissions: {
|
|
628
|
+
resource: string;
|
|
629
|
+
action: string;
|
|
630
|
+
}[];
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Supported notification channels.
|
|
635
|
+
* The set is closed — adding a new channel is a deliberate, audited act.
|
|
636
|
+
*/
|
|
637
|
+
declare const NotificationChannel: z.ZodEnum<["email", "sms", "push", "in-app"]>;
|
|
638
|
+
type NotificationChannel = z.infer<typeof NotificationChannel>;
|
|
639
|
+
declare const NotifyUserInput: z.ZodObject<{
|
|
640
|
+
/** Recipient user identifier — the provider resolves this to a delivery address */
|
|
641
|
+
recipient: z.ZodString;
|
|
642
|
+
/** Delivery channel */
|
|
643
|
+
channel: z.ZodEnum<["email", "sms", "push", "in-app"]>;
|
|
644
|
+
/** Template name for the notification content */
|
|
645
|
+
template: z.ZodString;
|
|
646
|
+
/** Typed payload for template interpolation */
|
|
647
|
+
payload: z.ZodUnknown;
|
|
648
|
+
/** Optional subject line (for email, push) */
|
|
649
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
650
|
+
/** Optional metadata to include with the notification */
|
|
651
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
652
|
+
/** Logical source identifier */
|
|
653
|
+
source: z.ZodOptional<z.ZodString>;
|
|
654
|
+
/** Correlation ID for request-scoped grouping */
|
|
655
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
656
|
+
}, "strip", z.ZodTypeAny, {
|
|
657
|
+
source?: string | undefined;
|
|
658
|
+
correlationId?: string | undefined;
|
|
659
|
+
}, {
|
|
660
|
+
source?: string | undefined;
|
|
661
|
+
correlationId?: string | undefined;
|
|
662
|
+
}>>;
|
|
663
|
+
}, "strip", z.ZodTypeAny, {
|
|
664
|
+
template: string;
|
|
665
|
+
recipient: string;
|
|
666
|
+
channel: "email" | "sms" | "push" | "in-app";
|
|
667
|
+
payload?: unknown;
|
|
668
|
+
metadata?: {
|
|
669
|
+
source?: string | undefined;
|
|
670
|
+
correlationId?: string | undefined;
|
|
671
|
+
} | undefined;
|
|
672
|
+
subject?: string | undefined;
|
|
673
|
+
}, {
|
|
674
|
+
template: string;
|
|
675
|
+
recipient: string;
|
|
676
|
+
channel: "email" | "sms" | "push" | "in-app";
|
|
677
|
+
payload?: unknown;
|
|
678
|
+
metadata?: {
|
|
679
|
+
source?: string | undefined;
|
|
680
|
+
correlationId?: string | undefined;
|
|
681
|
+
} | undefined;
|
|
682
|
+
subject?: string | undefined;
|
|
683
|
+
}>;
|
|
684
|
+
type NotifyUserInput = z.infer<typeof NotifyUserInput>;
|
|
685
|
+
declare const NotifyUserOutput: z.ZodObject<{
|
|
686
|
+
/** Provider-assigned notification ID */
|
|
687
|
+
notificationId: z.ZodString;
|
|
688
|
+
/** Channel the notification was sent through */
|
|
689
|
+
channel: z.ZodString;
|
|
690
|
+
/** Whether sending succeeded */
|
|
691
|
+
success: z.ZodBoolean;
|
|
692
|
+
}, "strip", z.ZodTypeAny, {
|
|
693
|
+
success: boolean;
|
|
694
|
+
channel: string;
|
|
695
|
+
notificationId: string;
|
|
696
|
+
}, {
|
|
697
|
+
success: boolean;
|
|
698
|
+
channel: string;
|
|
699
|
+
notificationId: string;
|
|
700
|
+
}>;
|
|
701
|
+
type NotifyUserOutput = z.infer<typeof NotifyUserOutput>;
|
|
702
|
+
/**
|
|
703
|
+
* notify.user effect — sends a notification to a user via a configured channel.
|
|
704
|
+
*
|
|
705
|
+
* This is an Effect capability: it touches the outside world.
|
|
706
|
+
* The NotificationProvider is injected via CapabilityContext.notificationProvider.
|
|
707
|
+
*
|
|
708
|
+
* Multi-channel (email, SMS, push, in-app) via a NotificationProvider adapter.
|
|
709
|
+
* Template-based with typed payload — the provider resolves the template name
|
|
710
|
+
* to actual content and interpolates the payload.
|
|
711
|
+
*
|
|
712
|
+
* Declares required permissions for least-privilege derivation:
|
|
713
|
+
* { resource: 'notification:<channel>', action: 'send' }
|
|
714
|
+
*/
|
|
715
|
+
declare const notifyUserHandler: CapabilityHandler<NotifyUserInput, NotifyUserOutput>;
|
|
716
|
+
/**
|
|
717
|
+
* notify.user capability definition.
|
|
718
|
+
*
|
|
719
|
+
* This is an Effect — it declares requiredPermissions.
|
|
720
|
+
* At compile time, the permission derivation system reads these to generate
|
|
721
|
+
* least-privilege IAM policies / RBAC manifests.
|
|
722
|
+
*
|
|
723
|
+
* Permission: { resource: 'notification:*', action: 'send' }
|
|
724
|
+
* The compiler can narrow the wildcard to specific channels by inspecting the
|
|
725
|
+
* flow's step parameters (e.g. notification:email).
|
|
726
|
+
*/
|
|
727
|
+
declare const notifyUserDefinition: {
|
|
728
|
+
kind: "effect";
|
|
729
|
+
name: string;
|
|
730
|
+
description: string;
|
|
731
|
+
inputSchema: string;
|
|
732
|
+
outputSchema: string;
|
|
733
|
+
requiredPermissions: {
|
|
734
|
+
resource: string;
|
|
735
|
+
action: string;
|
|
736
|
+
}[];
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Register all effect capabilities.
|
|
741
|
+
* Effects touch the outside world and declare required permissions.
|
|
742
|
+
*/
|
|
743
|
+
declare function registerEffects(registry: CapabilityRegistry): void;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Register all built-in capabilities (transforms + effects).
|
|
747
|
+
*/
|
|
748
|
+
declare function registerAllCapabilities(registry: CapabilityRegistry): void;
|
|
749
|
+
|
|
750
|
+
export { type CapabilityContext, type CapabilityHandler, type CapabilityLogger, type CapabilityMessageBus, type CapabilityNotificationProvider, CapabilityRegistry, CollectionAggregateInput, CollectionAggregateOutput, CollectionFilterInput, CollectionFilterOutput, CollectionJoinInput, CollectionJoinOutput, DateShiftInput, DateShiftOutput, EventsFilterInput, EventsFilterOutput, EventsPublishInput, EventsPublishOutput, NotificationChannel, NotifyUserInput, NotifyUserOutput, type RegisteredCapability, ServiceCallInput, ServiceCallOutput, TextFormatInput, TextFormatOutput, UnitsConvertInput, UnitsConvertOutput, collectionAggregateHandler, collectionFilterHandler, collectionJoinHandler, dateShiftHandler, defaultRegistry, evaluatePredicate, eventsFilterHandler, eventsPublishDefinition, eventsPublishHandler, notifyUserDefinition, notifyUserHandler, registerAllCapabilities, registerEffects, registerTransforms, serviceCallHandler, stripBusPrefix, textFormatHandler, unitsConvertHandler };
|