@aigne/afs-domain-action 1.11.0-beta.6
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/LICENSE.md +26 -0
- package/dist/index.d.mts +574 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +306 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
8
|
+
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
11
|
+
|
|
12
|
+
## No License Granted
|
|
13
|
+
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
16
|
+
|
|
17
|
+
## Public Artifact Distribution
|
|
18
|
+
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
23
|
+
|
|
24
|
+
## Contact
|
|
25
|
+
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
declare const EffectSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
5
|
+
write: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
write: string;
|
|
8
|
+
}, {
|
|
9
|
+
write: string;
|
|
10
|
+
}>, {
|
|
11
|
+
type: "write";
|
|
12
|
+
kind: string;
|
|
13
|
+
}, {
|
|
14
|
+
write: string;
|
|
15
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
16
|
+
delete: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
delete: string;
|
|
19
|
+
}, {
|
|
20
|
+
delete: string;
|
|
21
|
+
}>, {
|
|
22
|
+
type: "delete";
|
|
23
|
+
kind: string;
|
|
24
|
+
}, {
|
|
25
|
+
delete: string;
|
|
26
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
27
|
+
call: z.ZodString;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
call: string;
|
|
30
|
+
}, {
|
|
31
|
+
call: string;
|
|
32
|
+
}>, {
|
|
33
|
+
type: "call";
|
|
34
|
+
provider: string;
|
|
35
|
+
}, {
|
|
36
|
+
call: string;
|
|
37
|
+
}>]>;
|
|
38
|
+
type EffectSpec = z.output<typeof EffectSchema>;
|
|
39
|
+
declare const ConstraintSchema: z.ZodEffects<z.ZodObject<{
|
|
40
|
+
requires: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
requires: string;
|
|
43
|
+
}, {
|
|
44
|
+
requires: string;
|
|
45
|
+
}>, {
|
|
46
|
+
type: "authenticated";
|
|
47
|
+
role?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
type: "role";
|
|
50
|
+
role: string | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
requires: string;
|
|
53
|
+
}>;
|
|
54
|
+
type ConstraintSpec = z.output<typeof ConstraintSchema>;
|
|
55
|
+
declare const AutoFieldSchema: z.ZodUnion<[z.ZodEffects<z.ZodNumber, {
|
|
56
|
+
type: "literal";
|
|
57
|
+
value: number;
|
|
58
|
+
}, number>, z.ZodEffects<z.ZodBoolean, {
|
|
59
|
+
type: "literal";
|
|
60
|
+
value: boolean;
|
|
61
|
+
}, boolean>, z.ZodEffects<z.ZodString, {
|
|
62
|
+
type: "time";
|
|
63
|
+
key?: undefined;
|
|
64
|
+
field?: undefined;
|
|
65
|
+
value?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
type: "context";
|
|
68
|
+
key: string;
|
|
69
|
+
field?: undefined;
|
|
70
|
+
value?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
type: "input";
|
|
73
|
+
field: string;
|
|
74
|
+
key?: undefined;
|
|
75
|
+
value?: undefined;
|
|
76
|
+
} | {
|
|
77
|
+
type: "literal";
|
|
78
|
+
value: string;
|
|
79
|
+
key?: undefined;
|
|
80
|
+
field?: undefined;
|
|
81
|
+
}, string>]>;
|
|
82
|
+
type AutoFieldSpec = z.output<typeof AutoFieldSchema>;
|
|
83
|
+
declare class ActionErrorClass extends Error {
|
|
84
|
+
name: string;
|
|
85
|
+
}
|
|
86
|
+
declare const InputSchemaSpec: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
87
|
+
type InputSchema = z.output<typeof InputSchemaSpec>;
|
|
88
|
+
declare const OutputSchemaSpec: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
89
|
+
type OutputSchema = z.output<typeof OutputSchemaSpec>;
|
|
90
|
+
declare const ActionSpecSchema: z.ZodObject<{
|
|
91
|
+
level: z.ZodOptional<z.ZodEnum<["declarative", "imperative"]>>;
|
|
92
|
+
description: z.ZodString;
|
|
93
|
+
input: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
94
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
95
|
+
effects: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
96
|
+
write: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
write: string;
|
|
99
|
+
}, {
|
|
100
|
+
write: string;
|
|
101
|
+
}>, {
|
|
102
|
+
type: "write";
|
|
103
|
+
kind: string;
|
|
104
|
+
}, {
|
|
105
|
+
write: string;
|
|
106
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
107
|
+
delete: z.ZodString;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
delete: string;
|
|
110
|
+
}, {
|
|
111
|
+
delete: string;
|
|
112
|
+
}>, {
|
|
113
|
+
type: "delete";
|
|
114
|
+
kind: string;
|
|
115
|
+
}, {
|
|
116
|
+
delete: string;
|
|
117
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
118
|
+
call: z.ZodString;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
call: string;
|
|
121
|
+
}, {
|
|
122
|
+
call: string;
|
|
123
|
+
}>, {
|
|
124
|
+
type: "call";
|
|
125
|
+
provider: string;
|
|
126
|
+
}, {
|
|
127
|
+
call: string;
|
|
128
|
+
}>]>, "many">;
|
|
129
|
+
constraints: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
130
|
+
requires: z.ZodString;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
requires: string;
|
|
133
|
+
}, {
|
|
134
|
+
requires: string;
|
|
135
|
+
}>, {
|
|
136
|
+
type: "authenticated";
|
|
137
|
+
role?: undefined;
|
|
138
|
+
} | {
|
|
139
|
+
type: "role";
|
|
140
|
+
role: string | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
requires: string;
|
|
143
|
+
}>, "many">>;
|
|
144
|
+
executor: z.ZodOptional<z.ZodString>;
|
|
145
|
+
auto: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodNumber, {
|
|
146
|
+
type: "literal";
|
|
147
|
+
value: number;
|
|
148
|
+
}, number>, z.ZodEffects<z.ZodBoolean, {
|
|
149
|
+
type: "literal";
|
|
150
|
+
value: boolean;
|
|
151
|
+
}, boolean>, z.ZodEffects<z.ZodString, {
|
|
152
|
+
type: "time";
|
|
153
|
+
key?: undefined;
|
|
154
|
+
field?: undefined;
|
|
155
|
+
value?: undefined;
|
|
156
|
+
} | {
|
|
157
|
+
type: "context";
|
|
158
|
+
key: string;
|
|
159
|
+
field?: undefined;
|
|
160
|
+
value?: undefined;
|
|
161
|
+
} | {
|
|
162
|
+
type: "input";
|
|
163
|
+
field: string;
|
|
164
|
+
key?: undefined;
|
|
165
|
+
value?: undefined;
|
|
166
|
+
} | {
|
|
167
|
+
type: "literal";
|
|
168
|
+
value: string;
|
|
169
|
+
key?: undefined;
|
|
170
|
+
field?: undefined;
|
|
171
|
+
}, string>]>>>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
input: Record<string, string>;
|
|
174
|
+
description: string;
|
|
175
|
+
effects: ({
|
|
176
|
+
type: "write";
|
|
177
|
+
kind: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: "delete";
|
|
180
|
+
kind: string;
|
|
181
|
+
} | {
|
|
182
|
+
type: "call";
|
|
183
|
+
provider: string;
|
|
184
|
+
})[];
|
|
185
|
+
level?: "declarative" | "imperative" | undefined;
|
|
186
|
+
output?: Record<string, string> | undefined;
|
|
187
|
+
constraints?: ({
|
|
188
|
+
type: "authenticated";
|
|
189
|
+
role?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
type: "role";
|
|
192
|
+
role: string | undefined;
|
|
193
|
+
})[] | undefined;
|
|
194
|
+
executor?: string | undefined;
|
|
195
|
+
auto?: Record<string, {
|
|
196
|
+
type: "literal";
|
|
197
|
+
value: number;
|
|
198
|
+
} | {
|
|
199
|
+
type: "literal";
|
|
200
|
+
value: boolean;
|
|
201
|
+
} | {
|
|
202
|
+
type: "time";
|
|
203
|
+
key?: undefined;
|
|
204
|
+
field?: undefined;
|
|
205
|
+
value?: undefined;
|
|
206
|
+
} | {
|
|
207
|
+
type: "context";
|
|
208
|
+
key: string;
|
|
209
|
+
field?: undefined;
|
|
210
|
+
value?: undefined;
|
|
211
|
+
} | {
|
|
212
|
+
type: "input";
|
|
213
|
+
field: string;
|
|
214
|
+
key?: undefined;
|
|
215
|
+
value?: undefined;
|
|
216
|
+
} | {
|
|
217
|
+
type: "literal";
|
|
218
|
+
value: string;
|
|
219
|
+
key?: undefined;
|
|
220
|
+
field?: undefined;
|
|
221
|
+
}> | undefined;
|
|
222
|
+
}, {
|
|
223
|
+
input: Record<string, string>;
|
|
224
|
+
description: string;
|
|
225
|
+
effects: ({
|
|
226
|
+
write: string;
|
|
227
|
+
} | {
|
|
228
|
+
delete: string;
|
|
229
|
+
} | {
|
|
230
|
+
call: string;
|
|
231
|
+
})[];
|
|
232
|
+
level?: "declarative" | "imperative" | undefined;
|
|
233
|
+
output?: Record<string, string> | undefined;
|
|
234
|
+
constraints?: {
|
|
235
|
+
requires: string;
|
|
236
|
+
}[] | undefined;
|
|
237
|
+
executor?: string | undefined;
|
|
238
|
+
auto?: Record<string, string | number | boolean> | undefined;
|
|
239
|
+
}>;
|
|
240
|
+
type ActionSpec = z.output<typeof ActionSpecSchema>;
|
|
241
|
+
declare const DomainSpecSchema: z.ZodObject<{
|
|
242
|
+
domain: z.ZodString;
|
|
243
|
+
actions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
244
|
+
level: z.ZodOptional<z.ZodEnum<["declarative", "imperative"]>>;
|
|
245
|
+
description: z.ZodString;
|
|
246
|
+
input: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
247
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
248
|
+
effects: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
249
|
+
write: z.ZodString;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
write: string;
|
|
252
|
+
}, {
|
|
253
|
+
write: string;
|
|
254
|
+
}>, {
|
|
255
|
+
type: "write";
|
|
256
|
+
kind: string;
|
|
257
|
+
}, {
|
|
258
|
+
write: string;
|
|
259
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
260
|
+
delete: z.ZodString;
|
|
261
|
+
}, "strip", z.ZodTypeAny, {
|
|
262
|
+
delete: string;
|
|
263
|
+
}, {
|
|
264
|
+
delete: string;
|
|
265
|
+
}>, {
|
|
266
|
+
type: "delete";
|
|
267
|
+
kind: string;
|
|
268
|
+
}, {
|
|
269
|
+
delete: string;
|
|
270
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
271
|
+
call: z.ZodString;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
call: string;
|
|
274
|
+
}, {
|
|
275
|
+
call: string;
|
|
276
|
+
}>, {
|
|
277
|
+
type: "call";
|
|
278
|
+
provider: string;
|
|
279
|
+
}, {
|
|
280
|
+
call: string;
|
|
281
|
+
}>]>, "many">;
|
|
282
|
+
constraints: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
283
|
+
requires: z.ZodString;
|
|
284
|
+
}, "strip", z.ZodTypeAny, {
|
|
285
|
+
requires: string;
|
|
286
|
+
}, {
|
|
287
|
+
requires: string;
|
|
288
|
+
}>, {
|
|
289
|
+
type: "authenticated";
|
|
290
|
+
role?: undefined;
|
|
291
|
+
} | {
|
|
292
|
+
type: "role";
|
|
293
|
+
role: string | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
requires: string;
|
|
296
|
+
}>, "many">>;
|
|
297
|
+
executor: z.ZodOptional<z.ZodString>;
|
|
298
|
+
auto: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodNumber, {
|
|
299
|
+
type: "literal";
|
|
300
|
+
value: number;
|
|
301
|
+
}, number>, z.ZodEffects<z.ZodBoolean, {
|
|
302
|
+
type: "literal";
|
|
303
|
+
value: boolean;
|
|
304
|
+
}, boolean>, z.ZodEffects<z.ZodString, {
|
|
305
|
+
type: "time";
|
|
306
|
+
key?: undefined;
|
|
307
|
+
field?: undefined;
|
|
308
|
+
value?: undefined;
|
|
309
|
+
} | {
|
|
310
|
+
type: "context";
|
|
311
|
+
key: string;
|
|
312
|
+
field?: undefined;
|
|
313
|
+
value?: undefined;
|
|
314
|
+
} | {
|
|
315
|
+
type: "input";
|
|
316
|
+
field: string;
|
|
317
|
+
key?: undefined;
|
|
318
|
+
value?: undefined;
|
|
319
|
+
} | {
|
|
320
|
+
type: "literal";
|
|
321
|
+
value: string;
|
|
322
|
+
key?: undefined;
|
|
323
|
+
field?: undefined;
|
|
324
|
+
}, string>]>>>;
|
|
325
|
+
}, "strip", z.ZodTypeAny, {
|
|
326
|
+
input: Record<string, string>;
|
|
327
|
+
description: string;
|
|
328
|
+
effects: ({
|
|
329
|
+
type: "write";
|
|
330
|
+
kind: string;
|
|
331
|
+
} | {
|
|
332
|
+
type: "delete";
|
|
333
|
+
kind: string;
|
|
334
|
+
} | {
|
|
335
|
+
type: "call";
|
|
336
|
+
provider: string;
|
|
337
|
+
})[];
|
|
338
|
+
level?: "declarative" | "imperative" | undefined;
|
|
339
|
+
output?: Record<string, string> | undefined;
|
|
340
|
+
constraints?: ({
|
|
341
|
+
type: "authenticated";
|
|
342
|
+
role?: undefined;
|
|
343
|
+
} | {
|
|
344
|
+
type: "role";
|
|
345
|
+
role: string | undefined;
|
|
346
|
+
})[] | undefined;
|
|
347
|
+
executor?: string | undefined;
|
|
348
|
+
auto?: Record<string, {
|
|
349
|
+
type: "literal";
|
|
350
|
+
value: number;
|
|
351
|
+
} | {
|
|
352
|
+
type: "literal";
|
|
353
|
+
value: boolean;
|
|
354
|
+
} | {
|
|
355
|
+
type: "time";
|
|
356
|
+
key?: undefined;
|
|
357
|
+
field?: undefined;
|
|
358
|
+
value?: undefined;
|
|
359
|
+
} | {
|
|
360
|
+
type: "context";
|
|
361
|
+
key: string;
|
|
362
|
+
field?: undefined;
|
|
363
|
+
value?: undefined;
|
|
364
|
+
} | {
|
|
365
|
+
type: "input";
|
|
366
|
+
field: string;
|
|
367
|
+
key?: undefined;
|
|
368
|
+
value?: undefined;
|
|
369
|
+
} | {
|
|
370
|
+
type: "literal";
|
|
371
|
+
value: string;
|
|
372
|
+
key?: undefined;
|
|
373
|
+
field?: undefined;
|
|
374
|
+
}> | undefined;
|
|
375
|
+
}, {
|
|
376
|
+
input: Record<string, string>;
|
|
377
|
+
description: string;
|
|
378
|
+
effects: ({
|
|
379
|
+
write: string;
|
|
380
|
+
} | {
|
|
381
|
+
delete: string;
|
|
382
|
+
} | {
|
|
383
|
+
call: string;
|
|
384
|
+
})[];
|
|
385
|
+
level?: "declarative" | "imperative" | undefined;
|
|
386
|
+
output?: Record<string, string> | undefined;
|
|
387
|
+
constraints?: {
|
|
388
|
+
requires: string;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
executor?: string | undefined;
|
|
391
|
+
auto?: Record<string, string | number | boolean> | undefined;
|
|
392
|
+
}>>;
|
|
393
|
+
}, "strip", z.ZodTypeAny, {
|
|
394
|
+
domain: string;
|
|
395
|
+
actions: Record<string, {
|
|
396
|
+
input: Record<string, string>;
|
|
397
|
+
description: string;
|
|
398
|
+
effects: ({
|
|
399
|
+
type: "write";
|
|
400
|
+
kind: string;
|
|
401
|
+
} | {
|
|
402
|
+
type: "delete";
|
|
403
|
+
kind: string;
|
|
404
|
+
} | {
|
|
405
|
+
type: "call";
|
|
406
|
+
provider: string;
|
|
407
|
+
})[];
|
|
408
|
+
level?: "declarative" | "imperative" | undefined;
|
|
409
|
+
output?: Record<string, string> | undefined;
|
|
410
|
+
constraints?: ({
|
|
411
|
+
type: "authenticated";
|
|
412
|
+
role?: undefined;
|
|
413
|
+
} | {
|
|
414
|
+
type: "role";
|
|
415
|
+
role: string | undefined;
|
|
416
|
+
})[] | undefined;
|
|
417
|
+
executor?: string | undefined;
|
|
418
|
+
auto?: Record<string, {
|
|
419
|
+
type: "literal";
|
|
420
|
+
value: number;
|
|
421
|
+
} | {
|
|
422
|
+
type: "literal";
|
|
423
|
+
value: boolean;
|
|
424
|
+
} | {
|
|
425
|
+
type: "time";
|
|
426
|
+
key?: undefined;
|
|
427
|
+
field?: undefined;
|
|
428
|
+
value?: undefined;
|
|
429
|
+
} | {
|
|
430
|
+
type: "context";
|
|
431
|
+
key: string;
|
|
432
|
+
field?: undefined;
|
|
433
|
+
value?: undefined;
|
|
434
|
+
} | {
|
|
435
|
+
type: "input";
|
|
436
|
+
field: string;
|
|
437
|
+
key?: undefined;
|
|
438
|
+
value?: undefined;
|
|
439
|
+
} | {
|
|
440
|
+
type: "literal";
|
|
441
|
+
value: string;
|
|
442
|
+
key?: undefined;
|
|
443
|
+
field?: undefined;
|
|
444
|
+
}> | undefined;
|
|
445
|
+
}>;
|
|
446
|
+
}, {
|
|
447
|
+
domain: string;
|
|
448
|
+
actions: Record<string, {
|
|
449
|
+
input: Record<string, string>;
|
|
450
|
+
description: string;
|
|
451
|
+
effects: ({
|
|
452
|
+
write: string;
|
|
453
|
+
} | {
|
|
454
|
+
delete: string;
|
|
455
|
+
} | {
|
|
456
|
+
call: string;
|
|
457
|
+
})[];
|
|
458
|
+
level?: "declarative" | "imperative" | undefined;
|
|
459
|
+
output?: Record<string, string> | undefined;
|
|
460
|
+
constraints?: {
|
|
461
|
+
requires: string;
|
|
462
|
+
}[] | undefined;
|
|
463
|
+
executor?: string | undefined;
|
|
464
|
+
auto?: Record<string, string | number | boolean> | undefined;
|
|
465
|
+
}>;
|
|
466
|
+
}>;
|
|
467
|
+
type DomainSpec = z.output<typeof DomainSpecSchema>;
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/effects.d.ts
|
|
470
|
+
interface WorldInterface {
|
|
471
|
+
read(kind: string, id: string): Promise<unknown>;
|
|
472
|
+
list(kind: string): Promise<unknown[]>;
|
|
473
|
+
write(kind: string, id: string, data: unknown): Promise<void>;
|
|
474
|
+
delete(kind: string, id: string): Promise<void>;
|
|
475
|
+
}
|
|
476
|
+
type CallFn = (provider: string, args: unknown) => Promise<unknown>;
|
|
477
|
+
declare function createWorldProxy(world: WorldInterface, declaredEffects: EffectSpec[]): WorldInterface;
|
|
478
|
+
declare function createCallProxy(callFn: CallFn, declaredEffects: EffectSpec[]): CallFn;
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/autogen.d.ts
|
|
481
|
+
interface ExecutionPlan {
|
|
482
|
+
type: "create" | "update" | "delete";
|
|
483
|
+
kind: string;
|
|
484
|
+
}
|
|
485
|
+
declare function compileExecutionPlan(spec: ActionSpec): ExecutionPlan;
|
|
486
|
+
interface AutoContext {
|
|
487
|
+
did: string;
|
|
488
|
+
now: Date;
|
|
489
|
+
}
|
|
490
|
+
declare function resolveAutoFields(auto: Record<string, AutoFieldSpec> | undefined, input: Record<string, unknown>, ctx: AutoContext): Record<string, unknown>;
|
|
491
|
+
interface ExecuteContext {
|
|
492
|
+
world: WorldInterface;
|
|
493
|
+
input: Record<string, unknown>;
|
|
494
|
+
caller: AutoContext;
|
|
495
|
+
genId: () => string;
|
|
496
|
+
auto?: Record<string, AutoFieldSpec>;
|
|
497
|
+
}
|
|
498
|
+
declare function executeAutoPlan(plan: ExecutionPlan, ctx: ExecuteContext): Promise<{
|
|
499
|
+
id: string;
|
|
500
|
+
}>;
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/constraints.d.ts
|
|
503
|
+
interface CallerInfo {
|
|
504
|
+
did: string | null;
|
|
505
|
+
roles: string[];
|
|
506
|
+
}
|
|
507
|
+
declare function checkConstraints(constraints: ConstraintSpec[], caller: CallerInfo): void;
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/executor.d.ts
|
|
510
|
+
interface ActionContext {
|
|
511
|
+
world: WorldInterface;
|
|
512
|
+
call: CallFn;
|
|
513
|
+
now: () => string;
|
|
514
|
+
id: {
|
|
515
|
+
gen: () => string;
|
|
516
|
+
};
|
|
517
|
+
caller: CallerInfo;
|
|
518
|
+
error: (message: string) => ActionErrorClass;
|
|
519
|
+
}
|
|
520
|
+
type ExecutorFunction = (ctx: ActionContext, input: Record<string, unknown>) => Promise<unknown>;
|
|
521
|
+
interface ActionContextOptions {
|
|
522
|
+
world: WorldInterface;
|
|
523
|
+
callFn: CallFn;
|
|
524
|
+
caller: CallerInfo;
|
|
525
|
+
now: Date;
|
|
526
|
+
genId: () => string;
|
|
527
|
+
}
|
|
528
|
+
declare function createActionContext(opts: ActionContextOptions): ActionContext;
|
|
529
|
+
declare function loadExecutor(executorPath: string, basePath: string): Promise<ExecutorFunction>;
|
|
530
|
+
declare function executeImperative(executor: ExecutorFunction, ctx: ActionContext, input: Record<string, unknown>): Promise<unknown>;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/orchestrator.d.ts
|
|
533
|
+
interface DomainExecutorOptions {
|
|
534
|
+
spec: DomainSpec;
|
|
535
|
+
world: WorldInterface;
|
|
536
|
+
executorsBase: string;
|
|
537
|
+
genId: () => string;
|
|
538
|
+
callFn?: (provider: string, args: unknown) => Promise<unknown>;
|
|
539
|
+
}
|
|
540
|
+
interface ExecInput {
|
|
541
|
+
input: Record<string, unknown>;
|
|
542
|
+
caller: CallerInfo;
|
|
543
|
+
}
|
|
544
|
+
type DomainExecutorFn = (actionName: string, opts: ExecInput) => Promise<unknown>;
|
|
545
|
+
declare function createDomainExecutor(options: DomainExecutorOptions): DomainExecutorFn;
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/parser.d.ts
|
|
548
|
+
/**
|
|
549
|
+
* Parse a YAML string containing domain action specs into a validated DomainSpec.
|
|
550
|
+
*/
|
|
551
|
+
declare function parseDomainSpec(yamlContent: string): DomainSpec;
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/registry.d.ts
|
|
554
|
+
interface RegistryEntry {
|
|
555
|
+
name: string;
|
|
556
|
+
spec: ActionSpec;
|
|
557
|
+
}
|
|
558
|
+
declare class ActionRegistry {
|
|
559
|
+
private actions;
|
|
560
|
+
private _domain;
|
|
561
|
+
get domain(): string;
|
|
562
|
+
load(spec: DomainSpec): void;
|
|
563
|
+
get(name: string): ActionSpec;
|
|
564
|
+
list(): RegistryEntry[];
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Build a Zod validator from ActionSpec.input and validate the given input.
|
|
568
|
+
* Optional fields (type ending with "?") become z.string().optional().
|
|
569
|
+
* Strict mode: extra fields are rejected.
|
|
570
|
+
*/
|
|
571
|
+
declare function validateInput(spec: ActionSpec, input: unknown): Record<string, unknown>;
|
|
572
|
+
//#endregion
|
|
573
|
+
export { type ActionContext, type ActionContextOptions, ActionErrorClass, ActionRegistry, type ActionSpec, ActionSpecSchema, type AutoContext, AutoFieldSchema, type AutoFieldSpec, type CallFn, type CallerInfo, ConstraintSchema, type ConstraintSpec, type DomainExecutorFn, type DomainExecutorOptions, type DomainSpec, DomainSpecSchema, EffectSchema, type EffectSpec, type ExecInput, type ExecuteContext, type ExecutionPlan, type ExecutorFunction, type InputSchema, InputSchemaSpec, type OutputSchema, OutputSchemaSpec, type RegistryEntry, type WorldInterface, checkConstraints, compileExecutionPlan, createActionContext, createCallProxy, createDomainExecutor, createWorldProxy, executeAutoPlan, executeImperative, loadExecutor, parseDomainSpec, resolveAutoFields, validateInput };
|
|
574
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/effects.ts","../src/autogen.ts","../src/constraints.ts","../src/executor.ts","../src/orchestrator.ts","../src/parser.ts","../src/registry.ts"],"mappings":";;;cAgBa,YAAA,EAAY,CAAA,CAAA,QAAA,EAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEb,UAAA,GAAa,CAAA,CAAE,MAAA,QAAc,YAAA;AAAA,cAmB5B,gBAAA,EAAgB,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;KAEjB,cAAA,GAAiB,CAAA,CAAE,MAAA,QAAc,gBAAA;AAAA,cAIhC,eAAA,EAAe,CAAA,CAAA,QAAA,EAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAWhB,aAAA,GAAgB,C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AA;AAAA,iBAGc,mBAAA,CAAoB,IAAA,EAAM,oBAAA,GAAuB,aAAA;AAAA,iBAY3C,YAAA,CACpB,YAAA,UACA,QAAA,WACC,OAAA,CAAQ,gBAAA;AAAA,iBAcW,iBAAA,CACpB,QAAA,EAAU,gBAAA,EACV,GAAA,EAAK,aAAA,EACL,KAAA,EAAO,MAAA,oBACN,OAAA;;;UCjDc,qBAAA;EACf,IAAA,EAAM,UAAA;EACN,KAAA,EAAO,cAAA;EACP,aAAA;EACA,KAAA;EACA,MAAA,IAAU,QAAA,UAAkB,IAAA,cAAkB,OAAA;AAAA;AAAA,UAG/B,SAAA;EACf,KAAA,EAAO,MAAA;EACP,MAAA,EAAQ,UAAA;AAAA;AAAA,KAGE,gBAAA,IAAoB,UAAA,UAAoB,IAAA,EAAM,SAAA,KAAc,OAAA;AAAA,iBAExD,oBAAA,CAAqB,OAAA,EAAS,qBAAA,GAAwB,gBAAA;;;;;ALTtE;iBMTgB,eAAA,CAAgB,WAAA,WAAsB,UAAA;;;UCHrC,aAAA;EACf,IAAA;EACA,IAAA,EAAM,UAAA;AAAA;AAAA,cAGK,cAAA;EAAA,QACH,OAAA;EAAA,QACA,OAAA;EAAA,IAEJ,MAAA,CAAA;EAIJ,IAAA,CAAK,IAAA,EAAM,UAAA;EAQX,GAAA,CAAI,IAAA,WAAe,UAAA;EAQnB,IAAA,CAAA,GAAQ,aAAA;AAAA;;;;;;iBAUM,aAAA,CAAc,IAAA,EAAM,UAAA,EAAY,KAAA,YAAiB,MAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { parse } from "yaml";
|
|
3
|
+
|
|
4
|
+
//#region src/types.ts
|
|
5
|
+
const WriteEffectSchema = z.object({ write: z.string() }).transform((v) => ({
|
|
6
|
+
type: "write",
|
|
7
|
+
kind: v.write
|
|
8
|
+
}));
|
|
9
|
+
const DeleteEffectSchema = z.object({ delete: z.string() }).transform((v) => ({
|
|
10
|
+
type: "delete",
|
|
11
|
+
kind: v.delete
|
|
12
|
+
}));
|
|
13
|
+
const CallEffectSchema = z.object({ call: z.string() }).transform((v) => ({
|
|
14
|
+
type: "call",
|
|
15
|
+
provider: v.call
|
|
16
|
+
}));
|
|
17
|
+
const EffectSchema = z.union([
|
|
18
|
+
WriteEffectSchema,
|
|
19
|
+
DeleteEffectSchema,
|
|
20
|
+
CallEffectSchema
|
|
21
|
+
]);
|
|
22
|
+
const RequiresSchema = z.object({ requires: z.string() }).transform((v) => {
|
|
23
|
+
if (v.requires === "authenticated") return { type: "authenticated" };
|
|
24
|
+
const roleMatch = v.requires.match(/^role\((\w+)\)$/);
|
|
25
|
+
if (roleMatch) return {
|
|
26
|
+
type: "role",
|
|
27
|
+
role: roleMatch[1]
|
|
28
|
+
};
|
|
29
|
+
throw new Error(`Invalid constraint: "${v.requires}". Only "authenticated" and "role(xxx)" are allowed.`);
|
|
30
|
+
});
|
|
31
|
+
const ConstraintSchema = RequiresSchema;
|
|
32
|
+
const AutoFieldSchema = z.union([
|
|
33
|
+
z.number().transform((v) => ({
|
|
34
|
+
type: "literal",
|
|
35
|
+
value: v
|
|
36
|
+
})),
|
|
37
|
+
z.boolean().transform((v) => ({
|
|
38
|
+
type: "literal",
|
|
39
|
+
value: v
|
|
40
|
+
})),
|
|
41
|
+
z.string().transform((v) => {
|
|
42
|
+
if (v === "@now") return { type: "time" };
|
|
43
|
+
if (v.startsWith("@")) return {
|
|
44
|
+
type: "context",
|
|
45
|
+
key: v.slice(1)
|
|
46
|
+
};
|
|
47
|
+
if (v.startsWith("input.")) return {
|
|
48
|
+
type: "input",
|
|
49
|
+
field: v.slice(6)
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
type: "literal",
|
|
53
|
+
value: v
|
|
54
|
+
};
|
|
55
|
+
})
|
|
56
|
+
]);
|
|
57
|
+
var ActionErrorClass = class extends Error {
|
|
58
|
+
name = "ActionError";
|
|
59
|
+
};
|
|
60
|
+
const InputFieldTypeSchema = z.string();
|
|
61
|
+
const InputSchemaSpec = z.record(z.string(), InputFieldTypeSchema);
|
|
62
|
+
const OutputSchemaSpec = z.record(z.string(), InputFieldTypeSchema);
|
|
63
|
+
const ActionSpecSchema = z.object({
|
|
64
|
+
level: z.enum(["declarative", "imperative"]).optional(),
|
|
65
|
+
description: z.string(),
|
|
66
|
+
input: InputSchemaSpec,
|
|
67
|
+
output: OutputSchemaSpec.optional(),
|
|
68
|
+
effects: z.array(EffectSchema).min(1),
|
|
69
|
+
constraints: z.array(ConstraintSchema).optional(),
|
|
70
|
+
executor: z.string().optional(),
|
|
71
|
+
auto: z.record(z.string(), AutoFieldSchema).optional()
|
|
72
|
+
});
|
|
73
|
+
const DomainSpecSchema = z.object({
|
|
74
|
+
domain: z.string(),
|
|
75
|
+
actions: z.record(z.string(), ActionSpecSchema)
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/autogen.ts
|
|
80
|
+
function compileExecutionPlan(spec) {
|
|
81
|
+
const writes = spec.effects.filter((e) => e.type === "write");
|
|
82
|
+
const deletes = spec.effects.filter((e) => e.type === "delete");
|
|
83
|
+
if (spec.effects.filter((e) => e.type === "call").length > 0 || writes.length + deletes.length !== 1) throw new ActionErrorClass("cannot auto-generate for actions with multiple or mixed effects");
|
|
84
|
+
if (writes.length === 1) {
|
|
85
|
+
const kind = writes[0].kind;
|
|
86
|
+
return {
|
|
87
|
+
type: "id" in spec.input ? "update" : "create",
|
|
88
|
+
kind
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
type: "delete",
|
|
93
|
+
kind: deletes[0].kind
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function resolveAutoFields(auto, input, ctx) {
|
|
97
|
+
const result = { ...input };
|
|
98
|
+
if (!auto) return result;
|
|
99
|
+
for (const [field, spec] of Object.entries(auto)) if (spec.type === "literal") result[field] = spec.value;
|
|
100
|
+
else if (spec.type === "input") result[field] = input[spec.field];
|
|
101
|
+
else if (spec.type === "context") result[field] = ctx.did;
|
|
102
|
+
else if (spec.type === "time") result[field] = ctx.now.toISOString();
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async function executeAutoPlan(plan, ctx) {
|
|
106
|
+
const { world, input, caller, genId } = ctx;
|
|
107
|
+
if (plan.type === "create") {
|
|
108
|
+
const id$1 = genId();
|
|
109
|
+
const data = {
|
|
110
|
+
id: id$1,
|
|
111
|
+
...resolveAutoFields(ctx.auto, input, caller)
|
|
112
|
+
};
|
|
113
|
+
await world.write(plan.kind, id$1, data);
|
|
114
|
+
return { id: id$1 };
|
|
115
|
+
}
|
|
116
|
+
if (plan.type === "update") {
|
|
117
|
+
const id$1 = input.id;
|
|
118
|
+
const existing = await world.read(plan.kind, id$1);
|
|
119
|
+
const { id: _id, ...updates } = input;
|
|
120
|
+
const merged = {
|
|
121
|
+
...existing,
|
|
122
|
+
...updates
|
|
123
|
+
};
|
|
124
|
+
await world.write(plan.kind, id$1, merged);
|
|
125
|
+
return { id: id$1 };
|
|
126
|
+
}
|
|
127
|
+
const id = input.id;
|
|
128
|
+
await world.delete(plan.kind, id);
|
|
129
|
+
return { id };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/constraints.ts
|
|
134
|
+
function checkConstraints(constraints, caller) {
|
|
135
|
+
for (const constraint of constraints) if (constraint.type === "authenticated") {
|
|
136
|
+
if (!caller.did) throw new ActionErrorClass("Authentication required");
|
|
137
|
+
} else if (constraint.type === "role") {
|
|
138
|
+
const role = constraint.role;
|
|
139
|
+
if (!caller.roles.includes(role)) throw new ActionErrorClass(`Missing role: ${role}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/effects.ts
|
|
145
|
+
function createWorldProxy(world, declaredEffects) {
|
|
146
|
+
const writeKinds = new Set(declaredEffects.filter((e) => e.type === "write").map((e) => e.kind));
|
|
147
|
+
const deleteKinds = new Set(declaredEffects.filter((e) => e.type === "delete").map((e) => e.kind));
|
|
148
|
+
return {
|
|
149
|
+
read: (kind, id) => world.read(kind, id),
|
|
150
|
+
list: (kind) => world.list(kind),
|
|
151
|
+
async write(kind, id, data) {
|
|
152
|
+
if (!writeKinds.has(kind)) throw new ActionErrorClass(`Effect not declared: write ${kind}`);
|
|
153
|
+
return world.write(kind, id, data);
|
|
154
|
+
},
|
|
155
|
+
async delete(kind, id) {
|
|
156
|
+
if (!deleteKinds.has(kind)) throw new ActionErrorClass(`Effect not declared: delete ${kind}`);
|
|
157
|
+
return world.delete(kind, id);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function createCallProxy(callFn, declaredEffects) {
|
|
162
|
+
const allowedProviders = new Set(declaredEffects.filter((e) => e.type === "call").map((e) => e.provider));
|
|
163
|
+
return async (provider, args) => {
|
|
164
|
+
if (!allowedProviders.has(provider)) throw new ActionErrorClass(`Effect not declared: call ${provider}`);
|
|
165
|
+
return callFn(provider, args);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/executor.ts
|
|
171
|
+
function createActionContext(opts) {
|
|
172
|
+
const frozenNow = opts.now.toISOString();
|
|
173
|
+
return {
|
|
174
|
+
world: opts.world,
|
|
175
|
+
call: opts.callFn,
|
|
176
|
+
now: () => frozenNow,
|
|
177
|
+
id: { gen: opts.genId },
|
|
178
|
+
caller: opts.caller,
|
|
179
|
+
error: (message) => new ActionErrorClass(message)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async function loadExecutor(executorPath, basePath) {
|
|
183
|
+
const fullPath = new URL(executorPath, `file://${basePath}/`).pathname;
|
|
184
|
+
let mod;
|
|
185
|
+
try {
|
|
186
|
+
mod = await import(fullPath);
|
|
187
|
+
} catch {
|
|
188
|
+
throw new ActionErrorClass(`Executor not found: ${executorPath}`);
|
|
189
|
+
}
|
|
190
|
+
if (typeof mod.default !== "function") throw new ActionErrorClass("Executor must have default export");
|
|
191
|
+
return mod.default;
|
|
192
|
+
}
|
|
193
|
+
async function executeImperative(executor, ctx, input) {
|
|
194
|
+
try {
|
|
195
|
+
return await executor(ctx, input);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
if (e instanceof ActionErrorClass) throw e;
|
|
198
|
+
throw new Error(`System error in executor: ${e.message}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/registry.ts
|
|
204
|
+
var ActionRegistry = class {
|
|
205
|
+
actions = /* @__PURE__ */ new Map();
|
|
206
|
+
_domain = "";
|
|
207
|
+
get domain() {
|
|
208
|
+
return this._domain;
|
|
209
|
+
}
|
|
210
|
+
load(spec) {
|
|
211
|
+
this._domain = spec.domain;
|
|
212
|
+
this.actions.clear();
|
|
213
|
+
for (const [name, actionSpec] of Object.entries(spec.actions)) this.actions.set(name, actionSpec);
|
|
214
|
+
}
|
|
215
|
+
get(name) {
|
|
216
|
+
const spec = this.actions.get(name);
|
|
217
|
+
if (!spec) throw new ActionErrorClass(`Unknown action: ${name}`);
|
|
218
|
+
return spec;
|
|
219
|
+
}
|
|
220
|
+
list() {
|
|
221
|
+
return [...this.actions.entries()].map(([name, spec]) => ({
|
|
222
|
+
name,
|
|
223
|
+
spec
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Build a Zod validator from ActionSpec.input and validate the given input.
|
|
229
|
+
* Optional fields (type ending with "?") become z.string().optional().
|
|
230
|
+
* Strict mode: extra fields are rejected.
|
|
231
|
+
*/
|
|
232
|
+
function validateInput(spec, input) {
|
|
233
|
+
const shape = {};
|
|
234
|
+
for (const [field, typeStr] of Object.entries(spec.input)) {
|
|
235
|
+
const isOptional = typeStr.endsWith("?");
|
|
236
|
+
const baseSchema = z.string();
|
|
237
|
+
shape[field] = isOptional ? baseSchema.optional() : baseSchema;
|
|
238
|
+
}
|
|
239
|
+
return z.object(shape).strict().parse(input);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/orchestrator.ts
|
|
244
|
+
function createDomainExecutor(options) {
|
|
245
|
+
const registry = new ActionRegistry();
|
|
246
|
+
registry.load(options.spec);
|
|
247
|
+
const executorCache = /* @__PURE__ */ new Map();
|
|
248
|
+
const defaultCallFn = options.callFn ?? (async () => {
|
|
249
|
+
throw new Error("No call provider configured");
|
|
250
|
+
});
|
|
251
|
+
return async (actionName, opts) => {
|
|
252
|
+
if (actionName === "list-actions") return registry.list().map((e) => ({
|
|
253
|
+
name: e.name,
|
|
254
|
+
description: e.spec.description,
|
|
255
|
+
level: e.spec.level
|
|
256
|
+
}));
|
|
257
|
+
const spec = registry.get(actionName);
|
|
258
|
+
if (spec.constraints) checkConstraints(spec.constraints, opts.caller);
|
|
259
|
+
const validatedInput = validateInput(spec, opts.input);
|
|
260
|
+
const worldProxy = createWorldProxy(options.world, spec.effects);
|
|
261
|
+
const callProxy = createCallProxy(defaultCallFn, spec.effects);
|
|
262
|
+
const now = /* @__PURE__ */ new Date();
|
|
263
|
+
if (spec.executor) {
|
|
264
|
+
let executor = executorCache.get(spec.executor);
|
|
265
|
+
if (!executor) {
|
|
266
|
+
executor = await loadExecutor(spec.executor, options.executorsBase);
|
|
267
|
+
executorCache.set(spec.executor, executor);
|
|
268
|
+
}
|
|
269
|
+
const ctx = createActionContext({
|
|
270
|
+
world: worldProxy,
|
|
271
|
+
callFn: callProxy,
|
|
272
|
+
caller: opts.caller,
|
|
273
|
+
now,
|
|
274
|
+
genId: options.genId
|
|
275
|
+
});
|
|
276
|
+
return executeImperative(executor, ctx, validatedInput);
|
|
277
|
+
}
|
|
278
|
+
return executeAutoPlan(compileExecutionPlan(spec), {
|
|
279
|
+
world: worldProxy,
|
|
280
|
+
input: resolveAutoFields(spec.auto, validatedInput, {
|
|
281
|
+
did: opts.caller.did ?? "",
|
|
282
|
+
now
|
|
283
|
+
}),
|
|
284
|
+
caller: {
|
|
285
|
+
did: opts.caller.did ?? "",
|
|
286
|
+
now
|
|
287
|
+
},
|
|
288
|
+
genId: options.genId,
|
|
289
|
+
auto: spec.auto
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/parser.ts
|
|
296
|
+
/**
|
|
297
|
+
* Parse a YAML string containing domain action specs into a validated DomainSpec.
|
|
298
|
+
*/
|
|
299
|
+
function parseDomainSpec(yamlContent) {
|
|
300
|
+
const raw = parse(yamlContent);
|
|
301
|
+
return DomainSpecSchema.parse(raw);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
//#endregion
|
|
305
|
+
export { ActionErrorClass, ActionRegistry, ActionSpecSchema, AutoFieldSchema, ConstraintSchema, DomainSpecSchema, EffectSchema, InputSchemaSpec, OutputSchemaSpec, checkConstraints, compileExecutionPlan, createActionContext, createCallProxy, createDomainExecutor, createWorldProxy, executeAutoPlan, executeImperative, loadExecutor, parseDomainSpec, resolveAutoFields, validateInput };
|
|
306
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["id","parseYaml"],"sources":["../src/types.ts","../src/autogen.ts","../src/constraints.ts","../src/effects.ts","../src/executor.ts","../src/registry.ts","../src/orchestrator.ts","../src/parser.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// --- Effects ---\n\nconst WriteEffectSchema = z\n .object({ write: z.string() })\n .transform((v) => ({ type: \"write\" as const, kind: v.write }));\n\nconst DeleteEffectSchema = z\n .object({ delete: z.string() })\n .transform((v) => ({ type: \"delete\" as const, kind: v.delete }));\n\nconst CallEffectSchema = z\n .object({ call: z.string() })\n .transform((v) => ({ type: \"call\" as const, provider: v.call }));\n\nexport const EffectSchema = z.union([WriteEffectSchema, DeleteEffectSchema, CallEffectSchema]);\n\nexport type EffectSpec = z.output<typeof EffectSchema>;\n\n// --- Constraints ---\n\nconst RequiresSchema = z.object({ requires: z.string() }).transform((v) => {\n // Try authenticated first\n if (v.requires === \"authenticated\") {\n return { type: \"authenticated\" as const };\n }\n // Try role(xxx)\n const roleMatch = v.requires.match(/^role\\((\\w+)\\)$/);\n if (roleMatch) {\n return { type: \"role\" as const, role: roleMatch[1] };\n }\n throw new Error(\n `Invalid constraint: \"${v.requires}\". Only \"authenticated\" and \"role(xxx)\" are allowed.`,\n );\n});\n\nexport const ConstraintSchema = RequiresSchema;\n\nexport type ConstraintSpec = z.output<typeof ConstraintSchema>;\n\n// --- Auto Fields ---\n\nexport const AutoFieldSchema = z.union([\n z.number().transform((v) => ({ type: \"literal\" as const, value: v })),\n z.boolean().transform((v) => ({ type: \"literal\" as const, value: v })),\n z.string().transform((v) => {\n if (v === \"@now\") return { type: \"time\" as const };\n if (v.startsWith(\"@\")) return { type: \"context\" as const, key: v.slice(1) };\n if (v.startsWith(\"input.\")) return { type: \"input\" as const, field: v.slice(6) };\n return { type: \"literal\" as const, value: v };\n }),\n]);\n\nexport type AutoFieldSpec = z.output<typeof AutoFieldSchema>;\n\n// --- ActionError ---\n\nexport class ActionErrorClass extends Error {\n override name = \"ActionError\";\n}\n\n// --- Input/Output Schema ---\n\nexport const InputFieldTypeSchema = z.string(); // \"string\", \"text\", \"string?\", \"ref:Identity\", etc.\n\nexport const InputSchemaSpec = z.record(z.string(), InputFieldTypeSchema);\nexport type InputSchema = z.output<typeof InputSchemaSpec>;\n\nexport const OutputSchemaSpec = z.record(z.string(), InputFieldTypeSchema);\nexport type OutputSchema = z.output<typeof OutputSchemaSpec>;\n\n// --- ActionSpec ---\n\nexport const ActionSpecSchema = z.object({\n level: z.enum([\"declarative\", \"imperative\"]).optional(),\n description: z.string(),\n input: InputSchemaSpec,\n output: OutputSchemaSpec.optional(),\n effects: z.array(EffectSchema).min(1),\n constraints: z.array(ConstraintSchema).optional(),\n executor: z.string().optional(),\n auto: z.record(z.string(), AutoFieldSchema).optional(),\n});\n\nexport type ActionSpec = z.output<typeof ActionSpecSchema>;\n\n// --- DomainSpec ---\n\nexport const DomainSpecSchema = z.object({\n domain: z.string(),\n actions: z.record(z.string(), ActionSpecSchema),\n});\n\nexport type DomainSpec = z.output<typeof DomainSpecSchema>;\n","import type { WorldInterface } from \"./effects.js\";\nimport type { ActionSpec, AutoFieldSpec } from \"./types.js\";\nimport { ActionErrorClass } from \"./types.js\";\n\n// --- Execution Plan ---\n\nexport interface ExecutionPlan {\n type: \"create\" | \"update\" | \"delete\";\n kind: string;\n}\n\nexport function compileExecutionPlan(spec: ActionSpec): ExecutionPlan {\n const writes = spec.effects.filter((e) => e.type === \"write\");\n const deletes = spec.effects.filter((e) => e.type === \"delete\");\n const calls = spec.effects.filter((e) => e.type === \"call\");\n\n // Can only auto-gen for single-effect actions (one write OR one delete, no calls)\n if (calls.length > 0 || writes.length + deletes.length !== 1) {\n throw new ActionErrorClass(\"cannot auto-generate for actions with multiple or mixed effects\");\n }\n\n if (writes.length === 1) {\n const kind = (writes[0] as { type: \"write\"; kind: string }).kind;\n const hasId = \"id\" in spec.input;\n return { type: hasId ? \"update\" : \"create\", kind };\n }\n\n const kind = (deletes[0] as { type: \"delete\"; kind: string }).kind;\n return { type: \"delete\", kind };\n}\n\n// --- Auto Field Resolution ---\n\nexport interface AutoContext {\n did: string;\n now: Date;\n}\n\nexport function resolveAutoFields(\n auto: Record<string, AutoFieldSpec> | undefined,\n input: Record<string, unknown>,\n ctx: AutoContext,\n): Record<string, unknown> {\n const result = { ...input };\n\n if (!auto) return result;\n\n for (const [field, spec] of Object.entries(auto)) {\n if (spec.type === \"literal\") {\n result[field] = spec.value;\n } else if (spec.type === \"input\") {\n result[field] = input[(spec as { type: \"input\"; field: string }).field];\n } else if (spec.type === \"context\") {\n // For now, context key \"current_user_did\" maps to caller DID\n result[field] = ctx.did;\n } else if (spec.type === \"time\") {\n result[field] = ctx.now.toISOString();\n }\n }\n\n return result;\n}\n\n// --- Execute Auto Plan ---\n\nexport interface ExecuteContext {\n world: WorldInterface;\n input: Record<string, unknown>;\n caller: AutoContext;\n genId: () => string;\n auto?: Record<string, AutoFieldSpec>;\n}\n\nexport async function executeAutoPlan(\n plan: ExecutionPlan,\n ctx: ExecuteContext,\n): Promise<{ id: string }> {\n const { world, input, caller, genId } = ctx;\n\n if (plan.type === \"create\") {\n const id = genId();\n const data = { id, ...resolveAutoFields(ctx.auto, input, caller) };\n await world.write(plan.kind, id, data);\n return { id };\n }\n\n if (plan.type === \"update\") {\n const id = input.id as string;\n const existing = (await world.read(plan.kind, id)) as Record<string, unknown>;\n const { id: _id, ...updates } = input;\n const merged = { ...existing, ...updates };\n await world.write(plan.kind, id, merged);\n return { id };\n }\n\n // delete\n const id = input.id as string;\n await world.delete(plan.kind, id);\n return { id };\n}\n","import type { ConstraintSpec } from \"./types.js\";\nimport { ActionErrorClass } from \"./types.js\";\n\nexport interface CallerInfo {\n did: string | null;\n roles: string[];\n}\n\nexport function checkConstraints(constraints: ConstraintSpec[], caller: CallerInfo): void {\n for (const constraint of constraints) {\n if (constraint.type === \"authenticated\") {\n if (!caller.did) {\n throw new ActionErrorClass(\"Authentication required\");\n }\n } else if (constraint.type === \"role\") {\n const role = (constraint as { type: \"role\"; role: string }).role;\n if (!caller.roles.includes(role)) {\n throw new ActionErrorClass(`Missing role: ${role}`);\n }\n }\n }\n}\n","import type { EffectSpec } from \"./types.js\";\nimport { ActionErrorClass } from \"./types.js\";\n\nexport interface WorldInterface {\n read(kind: string, id: string): Promise<unknown>;\n list(kind: string): Promise<unknown[]>;\n write(kind: string, id: string, data: unknown): Promise<void>;\n delete(kind: string, id: string): Promise<void>;\n}\n\nexport type CallFn = (provider: string, args: unknown) => Promise<unknown>;\n\nexport function createWorldProxy(\n world: WorldInterface,\n declaredEffects: EffectSpec[],\n): WorldInterface {\n const writeKinds = new Set(\n declaredEffects\n .filter((e) => e.type === \"write\")\n .map((e) => (e as { type: \"write\"; kind: string }).kind),\n );\n const deleteKinds = new Set(\n declaredEffects\n .filter((e) => e.type === \"delete\")\n .map((e) => (e as { type: \"delete\"; kind: string }).kind),\n );\n\n return {\n read: (kind, id) => world.read(kind, id),\n list: (kind) => world.list(kind),\n async write(kind, id, data) {\n if (!writeKinds.has(kind)) {\n throw new ActionErrorClass(`Effect not declared: write ${kind}`);\n }\n return world.write(kind, id, data);\n },\n async delete(kind, id) {\n if (!deleteKinds.has(kind)) {\n throw new ActionErrorClass(`Effect not declared: delete ${kind}`);\n }\n return world.delete(kind, id);\n },\n };\n}\n\nexport function createCallProxy(callFn: CallFn, declaredEffects: EffectSpec[]): CallFn {\n const allowedProviders = new Set(\n declaredEffects\n .filter((e) => e.type === \"call\")\n .map((e) => (e as { type: \"call\"; provider: string }).provider),\n );\n\n return async (provider, args) => {\n if (!allowedProviders.has(provider)) {\n throw new ActionErrorClass(`Effect not declared: call ${provider}`);\n }\n return callFn(provider, args);\n };\n}\n","import type { CallerInfo } from \"./constraints.js\";\nimport type { CallFn, WorldInterface } from \"./effects.js\";\nimport { ActionErrorClass } from \"./types.js\";\n\nexport interface ActionContext {\n world: WorldInterface;\n call: CallFn;\n now: () => string;\n id: { gen: () => string };\n caller: CallerInfo;\n error: (message: string) => ActionErrorClass;\n}\n\nexport type ExecutorFunction = (\n ctx: ActionContext,\n input: Record<string, unknown>,\n) => Promise<unknown>;\n\nexport interface ActionContextOptions {\n world: WorldInterface;\n callFn: CallFn;\n caller: CallerInfo;\n now: Date;\n genId: () => string;\n}\n\nexport function createActionContext(opts: ActionContextOptions): ActionContext {\n const frozenNow = opts.now.toISOString();\n return {\n world: opts.world,\n call: opts.callFn,\n now: () => frozenNow,\n id: { gen: opts.genId },\n caller: opts.caller,\n error: (message: string) => new ActionErrorClass(message),\n };\n}\n\nexport async function loadExecutor(\n executorPath: string,\n basePath: string,\n): Promise<ExecutorFunction> {\n const fullPath = new URL(executorPath, `file://${basePath}/`).pathname;\n let mod: Record<string, unknown>;\n try {\n mod = await import(fullPath);\n } catch {\n throw new ActionErrorClass(`Executor not found: ${executorPath}`);\n }\n if (typeof mod.default !== \"function\") {\n throw new ActionErrorClass(\"Executor must have default export\");\n }\n return mod.default as ExecutorFunction;\n}\n\nexport async function executeImperative(\n executor: ExecutorFunction,\n ctx: ActionContext,\n input: Record<string, unknown>,\n): Promise<unknown> {\n try {\n return await executor(ctx, input);\n } catch (e) {\n if (e instanceof ActionErrorClass) {\n throw e;\n }\n throw new Error(`System error in executor: ${(e as Error).message}`);\n }\n}\n","import { z } from \"zod\";\nimport type { ActionSpec, DomainSpec } from \"./types.js\";\nimport { ActionErrorClass } from \"./types.js\";\n\nexport interface RegistryEntry {\n name: string;\n spec: ActionSpec;\n}\n\nexport class ActionRegistry {\n private actions = new Map<string, ActionSpec>();\n private _domain = \"\";\n\n get domain(): string {\n return this._domain;\n }\n\n load(spec: DomainSpec): void {\n this._domain = spec.domain;\n this.actions.clear();\n for (const [name, actionSpec] of Object.entries(spec.actions)) {\n this.actions.set(name, actionSpec);\n }\n }\n\n get(name: string): ActionSpec {\n const spec = this.actions.get(name);\n if (!spec) {\n throw new ActionErrorClass(`Unknown action: ${name}`);\n }\n return spec;\n }\n\n list(): RegistryEntry[] {\n return [...this.actions.entries()].map(([name, spec]) => ({ name, spec }));\n }\n}\n\n/**\n * Build a Zod validator from ActionSpec.input and validate the given input.\n * Optional fields (type ending with \"?\") become z.string().optional().\n * Strict mode: extra fields are rejected.\n */\nexport function validateInput(spec: ActionSpec, input: unknown): Record<string, unknown> {\n const shape: Record<string, z.ZodTypeAny> = {};\n\n for (const [field, typeStr] of Object.entries(spec.input)) {\n const isOptional = typeStr.endsWith(\"?\");\n const baseSchema = z.string();\n shape[field] = isOptional ? baseSchema.optional() : baseSchema;\n }\n\n const schema = z.object(shape).strict();\n return schema.parse(input);\n}\n","import { compileExecutionPlan, executeAutoPlan, resolveAutoFields } from \"./autogen.js\";\nimport type { CallerInfo } from \"./constraints.js\";\nimport { checkConstraints } from \"./constraints.js\";\nimport type { WorldInterface } from \"./effects.js\";\nimport { createCallProxy, createWorldProxy } from \"./effects.js\";\nimport type { ExecutorFunction } from \"./executor.js\";\nimport { createActionContext, executeImperative, loadExecutor } from \"./executor.js\";\nimport { ActionRegistry, validateInput } from \"./registry.js\";\nimport type { DomainSpec } from \"./types.js\";\n\nexport interface DomainExecutorOptions {\n spec: DomainSpec;\n world: WorldInterface;\n executorsBase: string;\n genId: () => string;\n callFn?: (provider: string, args: unknown) => Promise<unknown>;\n}\n\nexport interface ExecInput {\n input: Record<string, unknown>;\n caller: CallerInfo;\n}\n\nexport type DomainExecutorFn = (actionName: string, opts: ExecInput) => Promise<unknown>;\n\nexport function createDomainExecutor(options: DomainExecutorOptions): DomainExecutorFn {\n const registry = new ActionRegistry();\n registry.load(options.spec);\n\n const executorCache = new Map<string, ExecutorFunction>();\n const defaultCallFn =\n options.callFn ??\n (async () => {\n throw new Error(\"No call provider configured\");\n });\n\n return async (actionName: string, opts: ExecInput): Promise<unknown> => {\n // Built-in: list-actions\n if (actionName === \"list-actions\") {\n return registry.list().map((e) => ({\n name: e.name,\n description: e.spec.description,\n level: e.spec.level,\n }));\n }\n\n // 1. Lookup\n const spec = registry.get(actionName);\n\n // 2. Constraints\n if (spec.constraints) {\n checkConstraints(spec.constraints, opts.caller);\n }\n\n // 3. Input validation\n const validatedInput = validateInput(spec, opts.input);\n\n // 4. Build proxies\n const worldProxy = createWorldProxy(options.world, spec.effects);\n const callProxy = createCallProxy(defaultCallFn, spec.effects);\n const now = new Date();\n\n // 5. Dispatch: declarative (auto-gen) or imperative (TS executor)\n if (spec.executor) {\n // Imperative: load and execute TS executor\n let executor = executorCache.get(spec.executor);\n if (!executor) {\n executor = await loadExecutor(spec.executor, options.executorsBase);\n executorCache.set(spec.executor, executor);\n }\n const ctx = createActionContext({\n world: worldProxy,\n callFn: callProxy,\n caller: opts.caller,\n now,\n genId: options.genId,\n });\n return executeImperative(executor, ctx, validatedInput);\n }\n\n // Declarative: auto-generate execution plan\n const plan = compileExecutionPlan(spec);\n const resolvedInput = resolveAutoFields(spec.auto, validatedInput, {\n did: opts.caller.did ?? \"\",\n now,\n });\n return executeAutoPlan(plan, {\n world: worldProxy,\n input: resolvedInput,\n caller: { did: opts.caller.did ?? \"\", now },\n genId: options.genId,\n auto: spec.auto,\n });\n };\n}\n","import { parse as parseYaml } from \"yaml\";\n\nimport { type DomainSpec, DomainSpecSchema } from \"./types.js\";\n\n/**\n * Parse a YAML string containing domain action specs into a validated DomainSpec.\n */\nexport function parseDomainSpec(yamlContent: string): DomainSpec {\n const raw = parseYaml(yamlContent);\n return DomainSpecSchema.parse(raw);\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB,EACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAC7B,WAAW,OAAO;CAAE,MAAM;CAAkB,MAAM,EAAE;CAAO,EAAE;AAEhE,MAAM,qBAAqB,EACxB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAC9B,WAAW,OAAO;CAAE,MAAM;CAAmB,MAAM,EAAE;CAAQ,EAAE;AAElE,MAAM,mBAAmB,EACtB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAC5B,WAAW,OAAO;CAAE,MAAM;CAAiB,UAAU,EAAE;CAAM,EAAE;AAElE,MAAa,eAAe,EAAE,MAAM;CAAC;CAAmB;CAAoB;CAAiB,CAAC;AAM9F,MAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,WAAW,MAAM;AAEzE,KAAI,EAAE,aAAa,gBACjB,QAAO,EAAE,MAAM,iBAA0B;CAG3C,MAAM,YAAY,EAAE,SAAS,MAAM,kBAAkB;AACrD,KAAI,UACF,QAAO;EAAE,MAAM;EAAiB,MAAM,UAAU;EAAI;AAEtD,OAAM,IAAI,MACR,wBAAwB,EAAE,SAAS,sDACpC;EACD;AAE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I,KAAK,UAAU;GAEjB,IAAI,WAAW,cAAc,IAAI,KAAK,SAAS;AAC/C,OAAI,CAAC,UAAU;AACb,eAAW,MAAM,aAAa,KAAK,UAAU,QAAQ,cAAc;AACnE,kBAAc,IAAI,KAAK,UAAU,SAAS;;GAE5C,MAAM,MAAM,oBAAoB;IAC9B,OAAO;IACP,QAAQ;IACR,QAAQ,KAAK;IACb;IACA,OAAO,QAAQ;IAChB,CAAC;AACF,UAAO,kBAAkB,UAAU,KAAK,eAAe;;AASzD,SAAO,gBALM,qBAAqB,KAAK,EAKV;GAC3B,OAAO;GACP,OANoB,kBAAkB,KAAK,MAAM,gBAAgB;IACjE,KAAK,KAAK,OAAO,OAAO;IACxB;IACD,CAAC;GAIA,QAAQ;IAAE,KAAK,KAAK,OAAO,OAAO;IAAI;IAAK;GAC3C,OAAO,QAAQ;GACf,MAAM,KAAK;GACZ,CAAC;;;;;;;;;ACrFN,SAAgB,gBAAgB,aAAiC;CAC/D,MAAM,MAAMC,MAAU,YAAY;AAClC,QAAO,iBAAiB,MAAM,IAAI"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aigne/afs-domain-action",
|
|
3
|
+
"version": "1.11.0-beta.6",
|
|
4
|
+
"description": "Domain Action Provider for AFS - program-scoped write model with DSL command spec and constrained TS executors",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"author": "Arcblock <blocklet@arcblock.io> https://github.com/arcblock",
|
|
10
|
+
"homepage": "https://github.com/arcblock/afs",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/arcblock/afs"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/arcblock/afs/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./*": "./*"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"yaml": "^2.8.2",
|
|
37
|
+
"zod": "^3.25.67",
|
|
38
|
+
"@aigne/afs": "1.11.0-beta.6"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/bun": "^1.3.6",
|
|
42
|
+
"npm-run-all": "^4.1.5",
|
|
43
|
+
"rimraf": "^6.1.2",
|
|
44
|
+
"tsdown": "0.20.0-beta.3",
|
|
45
|
+
"typescript": "5.9.2",
|
|
46
|
+
"@aigne/typescript-config": "0.0.0",
|
|
47
|
+
"@aigne/scripts": "0.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsdown",
|
|
51
|
+
"check-types": "tsc --noEmit",
|
|
52
|
+
"clean": "rimraf dist coverage",
|
|
53
|
+
"test": "bun test",
|
|
54
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
|
|
55
|
+
}
|
|
56
|
+
}
|