@pgfsm/api 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/esm/_dnt.polyfills.d.ts +17 -0
  2. package/esm/_dnt.polyfills.js +15 -0
  3. package/esm/_dnt.shims.d.ts +5 -0
  4. package/esm/_dnt.shims.js +61 -0
  5. package/esm/database-src/generated/database.types.d.ts +2131 -0
  6. package/esm/database-src/generated/database.types.js +21 -0
  7. package/esm/deps/jsr.io/@std/cli/1.0.31/parse_args.d.ts +342 -0
  8. package/esm/deps/jsr.io/@std/cli/1.0.31/parse_args.js +372 -0
  9. package/esm/fsm-api-ts/env.d.ts +143 -0
  10. package/esm/fsm-api-ts/env.js +72 -0
  11. package/esm/fsm-api-ts/lib/configure-open-api.d.ts +3 -0
  12. package/esm/fsm-api-ts/lib/configure-open-api.js +25 -0
  13. package/esm/fsm-api-ts/lib/constants.d.ts +15 -0
  14. package/esm/fsm-api-ts/lib/constants.js +11 -0
  15. package/esm/fsm-api-ts/lib/create-app.d.ts +19 -0
  16. package/esm/fsm-api-ts/lib/create-app.js +137 -0
  17. package/esm/fsm-api-ts/lib/create-router.d.ts +3 -0
  18. package/esm/fsm-api-ts/lib/create-router.js +10 -0
  19. package/esm/fsm-api-ts/lib/license.d.ts +13 -0
  20. package/esm/fsm-api-ts/lib/license.js +15 -0
  21. package/esm/fsm-api-ts/lib/types.d.ts +19 -0
  22. package/esm/fsm-api-ts/lib/types.js +1 -0
  23. package/esm/fsm-api-ts/logger.d.ts +3 -0
  24. package/esm/fsm-api-ts/logger.js +20 -0
  25. package/esm/fsm-api-ts/middlewares/api-key-auth.d.ts +34 -0
  26. package/esm/fsm-api-ts/middlewares/api-key-auth.js +70 -0
  27. package/esm/fsm-api-ts/middlewares/logtape-logger.d.ts +2 -0
  28. package/esm/fsm-api-ts/middlewares/logtape-logger.js +33 -0
  29. package/esm/fsm-api-ts/middlewares/otel-trace.d.ts +2 -0
  30. package/esm/fsm-api-ts/middlewares/otel-trace.js +29 -0
  31. package/esm/fsm-api-ts/middlewares/supabase.d.ts +10 -0
  32. package/esm/fsm-api-ts/middlewares/supabase.js +34 -0
  33. package/esm/fsm-api-ts/mod.d.ts +2 -0
  34. package/esm/fsm-api-ts/mod.js +6 -0
  35. package/esm/fsm-api-ts/routes/admin/admin.handlers.d.ts +8 -0
  36. package/esm/fsm-api-ts/routes/admin/admin.handlers.js +98 -0
  37. package/esm/fsm-api-ts/routes/admin/admin.index.d.ts +189 -0
  38. package/esm/fsm-api-ts/routes/admin/admin.index.js +11 -0
  39. package/esm/fsm-api-ts/routes/admin/admin.routes.d.ts +473 -0
  40. package/esm/fsm-api-ts/routes/admin/admin.routes.js +130 -0
  41. package/esm/fsm-api-ts/routes/definitions/definitions.handlers.d.ts +5 -0
  42. package/esm/fsm-api-ts/routes/definitions/definitions.handlers.js +29 -0
  43. package/esm/fsm-api-ts/routes/definitions/definitions.index.d.ts +86 -0
  44. package/esm/fsm-api-ts/routes/definitions/definitions.index.js +8 -0
  45. package/esm/fsm-api-ts/routes/definitions/definitions.routes.d.ts +204 -0
  46. package/esm/fsm-api-ts/routes/definitions/definitions.routes.js +56 -0
  47. package/esm/fsm-api-ts/routes/index.route.d.ts +19 -0
  48. package/esm/fsm-api-ts/routes/index.route.js +31 -0
  49. package/esm/fsm-api-ts/routes/instances/instances.handlers.d.ts +8 -0
  50. package/esm/fsm-api-ts/routes/instances/instances.handlers.js +108 -0
  51. package/esm/fsm-api-ts/routes/instances/instances.index.d.ts +237 -0
  52. package/esm/fsm-api-ts/routes/instances/instances.index.js +11 -0
  53. package/esm/fsm-api-ts/routes/instances/instances.routes.d.ts +411 -0
  54. package/esm/fsm-api-ts/routes/instances/instances.routes.js +104 -0
  55. package/esm/fsm-api-ts/src/cli/index.d.ts +2 -0
  56. package/esm/fsm-api-ts/src/cli/index.js +197 -0
  57. package/esm/fsm-api-ts/src/cli/invocation.node.d.ts +1 -0
  58. package/esm/fsm-api-ts/src/cli/invocation.node.js +4 -0
  59. package/esm/fsm-api-ts/src/cli/key-bootstrap.d.ts +14 -0
  60. package/esm/fsm-api-ts/src/cli/key-bootstrap.js +35 -0
  61. package/esm/fsm-api-ts/src/cli/serve.node.d.ts +6 -0
  62. package/esm/fsm-api-ts/src/cli/serve.node.js +20 -0
  63. package/esm/fsm-api-ts/src/cli/version.node.d.ts +1 -0
  64. package/esm/fsm-api-ts/src/cli/version.node.js +2 -0
  65. package/esm/fsm-api-ts/stoker-src/http-status-codes.d.ts +354 -0
  66. package/esm/fsm-api-ts/stoker-src/http-status-codes.js +356 -0
  67. package/esm/fsm-api-ts/stoker-src/http-status-phrases.d.ts +354 -0
  68. package/esm/fsm-api-ts/stoker-src/http-status-phrases.js +356 -0
  69. package/esm/fsm-api-ts/stoker-src/middlewares/index.d.ts +3 -0
  70. package/esm/fsm-api-ts/stoker-src/middlewares/index.js +3 -0
  71. package/esm/fsm-api-ts/stoker-src/middlewares/not-found.d.ts +3 -0
  72. package/esm/fsm-api-ts/stoker-src/middlewares/not-found.js +8 -0
  73. package/esm/fsm-api-ts/stoker-src/middlewares/on-error.d.ts +3 -0
  74. package/esm/fsm-api-ts/stoker-src/middlewares/on-error.js +19 -0
  75. package/esm/fsm-api-ts/stoker-src/middlewares/serve-emoji-favicon.d.ts +3 -0
  76. package/esm/fsm-api-ts/stoker-src/middlewares/serve-emoji-favicon.js +10 -0
  77. package/esm/fsm-api-ts/stoker-src/openapi/default-hook.d.ts +3 -0
  78. package/esm/fsm-api-ts/stoker-src/openapi/default-hook.js +11 -0
  79. package/esm/fsm-api-ts/stoker-src/openapi/helpers/index.d.ts +4 -0
  80. package/esm/fsm-api-ts/stoker-src/openapi/helpers/index.js +4 -0
  81. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-one-of.d.ts +12 -0
  82. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-one-of.js +14 -0
  83. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-required.d.ts +11 -0
  84. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-required.js +8 -0
  85. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content.d.ts +10 -0
  86. package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content.js +11 -0
  87. package/esm/fsm-api-ts/stoker-src/openapi/helpers/one-of.d.ts +3 -0
  88. package/esm/fsm-api-ts/stoker-src/openapi/helpers/one-of.js +13 -0
  89. package/esm/fsm-api-ts/stoker-src/openapi/helpers/types.d.ts +2 -0
  90. package/esm/fsm-api-ts/stoker-src/openapi/helpers/types.js +1 -0
  91. package/esm/fsm-api-ts/stoker-src/openapi/index.d.ts +3 -0
  92. package/esm/fsm-api-ts/stoker-src/openapi/index.js +3 -0
  93. package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-error-schema.d.ts +56 -0
  94. package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-error-schema.js +25 -0
  95. package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-message-object.d.ts +9 -0
  96. package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-message-object.js +11 -0
  97. package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-params.d.ts +9 -0
  98. package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-params.js +13 -0
  99. package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-uuid-params.d.ts +9 -0
  100. package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-uuid-params.js +13 -0
  101. package/esm/fsm-api-ts/stoker-src/openapi/schemas/index.d.ts +5 -0
  102. package/esm/fsm-api-ts/stoker-src/openapi/schemas/index.js +5 -0
  103. package/esm/fsm-api-ts/stoker-src/openapi/schemas/slug-params.d.ts +9 -0
  104. package/esm/fsm-api-ts/stoker-src/openapi/schemas/slug-params.js +18 -0
  105. package/esm/fsm-core-db-ts/src/database.types.d.ts +4 -0
  106. package/esm/fsm-core-db-ts/src/database.types.js +17 -0
  107. package/esm/package.json +3 -0
  108. package/package.json +45 -3
  109. package/script/_dnt.polyfills.d.ts +17 -0
  110. package/script/_dnt.polyfills.js +16 -0
  111. package/script/_dnt.shims.d.ts +5 -0
  112. package/script/_dnt.shims.js +65 -0
  113. package/script/fsm-api-ts/mod.d.ts +2 -0
  114. package/script/fsm-api-ts/mod.js +10 -0
  115. package/script/fsm-api-ts/src/cli/version.node.d.ts +1 -0
  116. package/script/fsm-api-ts/src/cli/version.node.js +5 -0
  117. package/script/package.json +3 -0
  118. package/README.md +0 -3
@@ -0,0 +1,411 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ export declare const list: {
3
+ path: "/instances";
4
+ method: "get";
5
+ request: {
6
+ query: z.ZodObject<{
7
+ fsm_name: z.ZodOptional<z.ZodString>;
8
+ fsm_version: z.ZodOptional<z.ZodString>;
9
+ status: z.ZodOptional<z.ZodEnum<["active", "done", "error", "stopped"]>>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ limit: number;
13
+ status?: "error" | "active" | "done" | "stopped" | undefined;
14
+ fsm_name?: string | undefined;
15
+ fsm_version?: string | undefined;
16
+ }, {
17
+ status?: "error" | "active" | "done" | "stopped" | undefined;
18
+ fsm_name?: string | undefined;
19
+ fsm_version?: string | undefined;
20
+ limit?: number | undefined;
21
+ }>;
22
+ };
23
+ tags: string[];
24
+ responses: {
25
+ 200: {
26
+ content: {
27
+ "application/json": {
28
+ schema: z.ZodObject<{
29
+ data: z.ZodArray<z.ZodObject<{
30
+ id: z.ZodString;
31
+ fsm_name: z.ZodNullable<z.ZodString>;
32
+ fsm_version: z.ZodNullable<z.ZodString>;
33
+ fsm_instance_status: z.ZodUnknown;
34
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
35
+ id: z.ZodString;
36
+ fsm_name: z.ZodNullable<z.ZodString>;
37
+ fsm_version: z.ZodNullable<z.ZodString>;
38
+ fsm_instance_status: z.ZodUnknown;
39
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
40
+ id: z.ZodString;
41
+ fsm_name: z.ZodNullable<z.ZodString>;
42
+ fsm_version: z.ZodNullable<z.ZodString>;
43
+ fsm_instance_status: z.ZodUnknown;
44
+ }, z.ZodTypeAny, "passthrough">>, "many">;
45
+ }, "strip", z.ZodTypeAny, {
46
+ data: z.objectOutputType<{
47
+ id: z.ZodString;
48
+ fsm_name: z.ZodNullable<z.ZodString>;
49
+ fsm_version: z.ZodNullable<z.ZodString>;
50
+ fsm_instance_status: z.ZodUnknown;
51
+ }, z.ZodTypeAny, "passthrough">[];
52
+ }, {
53
+ data: z.objectInputType<{
54
+ id: z.ZodString;
55
+ fsm_name: z.ZodNullable<z.ZodString>;
56
+ fsm_version: z.ZodNullable<z.ZodString>;
57
+ fsm_instance_status: z.ZodUnknown;
58
+ }, z.ZodTypeAny, "passthrough">[];
59
+ }>;
60
+ };
61
+ };
62
+ description: string;
63
+ };
64
+ 500: {
65
+ content: {
66
+ "application/json": {
67
+ schema: z.ZodObject<{
68
+ error: z.ZodString;
69
+ }, "strip", z.ZodTypeAny, {
70
+ error: string;
71
+ }, {
72
+ error: string;
73
+ }>;
74
+ };
75
+ };
76
+ description: string;
77
+ };
78
+ };
79
+ } & {
80
+ getRoutingPath(): "/instances";
81
+ };
82
+ export declare const getOne: {
83
+ path: "/instances/{id}";
84
+ method: "get";
85
+ request: {
86
+ params: z.ZodObject<{
87
+ id: z.ZodString;
88
+ }, "strip", z.ZodTypeAny, {
89
+ id: string;
90
+ }, {
91
+ id: string;
92
+ }>;
93
+ };
94
+ tags: string[];
95
+ responses: {
96
+ 200: {
97
+ content: {
98
+ "application/json": {
99
+ schema: z.ZodObject<{
100
+ data: z.ZodObject<{
101
+ fsm_instance_row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
102
+ resolved_state_value: z.ZodUnknown;
103
+ }, "strip", z.ZodTypeAny, {
104
+ fsm_instance_row: Record<string, unknown>;
105
+ resolved_state_value?: unknown;
106
+ }, {
107
+ fsm_instance_row: Record<string, unknown>;
108
+ resolved_state_value?: unknown;
109
+ }>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ data: {
112
+ fsm_instance_row: Record<string, unknown>;
113
+ resolved_state_value?: unknown;
114
+ };
115
+ }, {
116
+ data: {
117
+ fsm_instance_row: Record<string, unknown>;
118
+ resolved_state_value?: unknown;
119
+ };
120
+ }>;
121
+ };
122
+ };
123
+ description: string;
124
+ };
125
+ 404: {
126
+ content: {
127
+ "application/json": {
128
+ schema: z.ZodObject<{
129
+ message: z.ZodString;
130
+ }, "strip", z.ZodTypeAny, {
131
+ message: string;
132
+ }, {
133
+ message: string;
134
+ }>;
135
+ };
136
+ };
137
+ description: string;
138
+ };
139
+ 500: {
140
+ content: {
141
+ "application/json": {
142
+ schema: z.ZodObject<{
143
+ error: z.ZodString;
144
+ }, "strip", z.ZodTypeAny, {
145
+ error: string;
146
+ }, {
147
+ error: string;
148
+ }>;
149
+ };
150
+ };
151
+ description: string;
152
+ };
153
+ };
154
+ } & {
155
+ getRoutingPath(): "/instances/:id";
156
+ };
157
+ export declare const create: {
158
+ path: "/instances";
159
+ method: "post";
160
+ request: {
161
+ body: {
162
+ required: boolean;
163
+ content: {
164
+ "application/json": {
165
+ schema: z.ZodObject<{
166
+ fsm_name: z.ZodString;
167
+ fsm_version: z.ZodString;
168
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ fsm_name: string;
171
+ fsm_version: string;
172
+ input?: Record<string, unknown> | undefined;
173
+ }, {
174
+ fsm_name: string;
175
+ fsm_version: string;
176
+ input?: Record<string, unknown> | undefined;
177
+ }>;
178
+ };
179
+ };
180
+ description: string;
181
+ };
182
+ };
183
+ tags: string[];
184
+ responses: {
185
+ 200: {
186
+ content: {
187
+ "application/json": {
188
+ schema: z.ZodObject<{
189
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
190
+ }, "strip", z.ZodTypeAny, {
191
+ data: Record<string, unknown>;
192
+ }, {
193
+ data: Record<string, unknown>;
194
+ }>;
195
+ };
196
+ };
197
+ description: string;
198
+ };
199
+ 500: {
200
+ content: {
201
+ "application/json": {
202
+ schema: z.ZodObject<{
203
+ error: z.ZodString;
204
+ }, "strip", z.ZodTypeAny, {
205
+ error: string;
206
+ }, {
207
+ error: string;
208
+ }>;
209
+ };
210
+ };
211
+ description: string;
212
+ };
213
+ };
214
+ } & {
215
+ getRoutingPath(): "/instances";
216
+ };
217
+ export declare const sendEvent: {
218
+ path: "/instances/{id}/events";
219
+ method: "post";
220
+ request: {
221
+ params: z.ZodObject<{
222
+ id: z.ZodString;
223
+ }, "strip", z.ZodTypeAny, {
224
+ id: string;
225
+ }, {
226
+ id: string;
227
+ }>;
228
+ body: {
229
+ required: boolean;
230
+ content: {
231
+ "application/json": {
232
+ schema: z.ZodObject<{
233
+ type: z.ZodString;
234
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
235
+ type: z.ZodString;
236
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
237
+ type: z.ZodString;
238
+ }, z.ZodTypeAny, "passthrough">>;
239
+ };
240
+ };
241
+ description: string;
242
+ };
243
+ };
244
+ tags: string[];
245
+ responses: {
246
+ 200: {
247
+ content: {
248
+ "application/json": {
249
+ schema: z.ZodObject<{
250
+ data: z.ZodAny;
251
+ }, "strip", z.ZodTypeAny, {
252
+ data?: any;
253
+ }, {
254
+ data?: any;
255
+ }>;
256
+ };
257
+ };
258
+ description: string;
259
+ };
260
+ 404: {
261
+ content: {
262
+ "application/json": {
263
+ schema: z.ZodObject<{
264
+ message: z.ZodString;
265
+ }, "strip", z.ZodTypeAny, {
266
+ message: string;
267
+ }, {
268
+ message: string;
269
+ }>;
270
+ };
271
+ };
272
+ description: string;
273
+ };
274
+ 500: {
275
+ content: {
276
+ "application/json": {
277
+ schema: z.ZodObject<{
278
+ error: z.ZodString;
279
+ }, "strip", z.ZodTypeAny, {
280
+ error: string;
281
+ }, {
282
+ error: string;
283
+ }>;
284
+ };
285
+ };
286
+ description: string;
287
+ };
288
+ };
289
+ } & {
290
+ getRoutingPath(): "/instances/:id/events";
291
+ };
292
+ export declare const resume: {
293
+ path: "/instances/{id}/resume";
294
+ method: "post";
295
+ request: {
296
+ params: z.ZodObject<{
297
+ id: z.ZodString;
298
+ }, "strip", z.ZodTypeAny, {
299
+ id: string;
300
+ }, {
301
+ id: string;
302
+ }>;
303
+ };
304
+ tags: string[];
305
+ responses: {
306
+ 200: {
307
+ content: {
308
+ "application/json": {
309
+ schema: z.ZodObject<{
310
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ data: Record<string, unknown>;
313
+ }, {
314
+ data: Record<string, unknown>;
315
+ }>;
316
+ };
317
+ };
318
+ description: string;
319
+ };
320
+ 404: {
321
+ content: {
322
+ "application/json": {
323
+ schema: z.ZodObject<{
324
+ message: z.ZodString;
325
+ }, "strip", z.ZodTypeAny, {
326
+ message: string;
327
+ }, {
328
+ message: string;
329
+ }>;
330
+ };
331
+ };
332
+ description: string;
333
+ };
334
+ 500: {
335
+ content: {
336
+ "application/json": {
337
+ schema: z.ZodObject<{
338
+ error: z.ZodString;
339
+ }, "strip", z.ZodTypeAny, {
340
+ error: string;
341
+ }, {
342
+ error: string;
343
+ }>;
344
+ };
345
+ };
346
+ description: string;
347
+ };
348
+ };
349
+ } & {
350
+ getRoutingPath(): "/instances/:id/resume";
351
+ };
352
+ export declare const stop: {
353
+ path: "/instances/{id}/stop";
354
+ method: "post";
355
+ request: {
356
+ params: z.ZodObject<{
357
+ id: z.ZodString;
358
+ }, "strip", z.ZodTypeAny, {
359
+ id: string;
360
+ }, {
361
+ id: string;
362
+ }>;
363
+ };
364
+ tags: string[];
365
+ responses: {
366
+ 200: {
367
+ content: {
368
+ "application/json": {
369
+ schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
370
+ };
371
+ };
372
+ description: string;
373
+ };
374
+ 404: {
375
+ content: {
376
+ "application/json": {
377
+ schema: z.ZodObject<{
378
+ message: z.ZodString;
379
+ }, "strip", z.ZodTypeAny, {
380
+ message: string;
381
+ }, {
382
+ message: string;
383
+ }>;
384
+ };
385
+ };
386
+ description: string;
387
+ };
388
+ 500: {
389
+ content: {
390
+ "application/json": {
391
+ schema: z.ZodObject<{
392
+ error: z.ZodString;
393
+ }, "strip", z.ZodTypeAny, {
394
+ error: string;
395
+ }, {
396
+ error: string;
397
+ }>;
398
+ };
399
+ };
400
+ description: string;
401
+ };
402
+ };
403
+ } & {
404
+ getRoutingPath(): "/instances/:id/stop";
405
+ };
406
+ export type ListRoute = typeof list;
407
+ export type GetOneRoute = typeof getOne;
408
+ export type CreateRoute = typeof create;
409
+ export type SendEventRoute = typeof sendEvent;
410
+ export type ResumeRoute = typeof resume;
411
+ export type StopRoute = typeof stop;
@@ -0,0 +1,104 @@
1
+ import { createRoute, z } from "@hono/zod-openapi";
2
+ import * as HttpStatusCodes from "../../stoker-src/http-status-codes.js";
3
+ import { jsonContent, jsonContentRequired, } from "../../stoker-src/openapi/helpers/index.js";
4
+ import { IdUUIDParamsSchema } from "../../stoker-src/openapi/schemas/index.js";
5
+ import { notFoundSchema } from "../../lib/constants.js";
6
+ // FSM instances (#675): one resource, its id in the path, actions as
7
+ // sub-resources. Every route needs an operator (or admin) key.
8
+ const tags = ["instances"];
9
+ const errorSchema = z.object({ error: z.string() });
10
+ const instanceNotFound = jsonContent(notFoundSchema, "No such FSM instance");
11
+ export const list = createRoute({
12
+ path: "/instances",
13
+ method: "get",
14
+ request: {
15
+ // Filtered and limited in the database (#661).
16
+ query: z.object({
17
+ fsm_name: z.string().optional().describe("Only this FSM"),
18
+ fsm_version: z.string().optional().describe("Only this version"),
19
+ status: z.enum(["active", "done", "error", "stopped"]).optional()
20
+ .describe("Only instances with this status"),
21
+ limit: z.coerce.number().int().min(1).max(1000).default(50).describe("At most this many, newest first (default 50, max 1000)"),
22
+ }),
23
+ },
24
+ tags,
25
+ responses: {
26
+ [HttpStatusCodes.OK]: jsonContent(z.object({
27
+ data: z.array(z.object({
28
+ id: z.string(),
29
+ fsm_name: z.string().nullable(),
30
+ fsm_version: z.string().nullable(),
31
+ fsm_instance_status: z.unknown(),
32
+ }).passthrough()),
33
+ }), "FSM instances, newest first"),
34
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
35
+ },
36
+ });
37
+ export const getOne = createRoute({
38
+ path: "/instances/{id}",
39
+ method: "get",
40
+ request: { params: IdUUIDParamsSchema },
41
+ tags,
42
+ responses: {
43
+ [HttpStatusCodes.OK]: jsonContent(z.object({
44
+ data: z.object({
45
+ fsm_instance_row: z.record(z.unknown()),
46
+ resolved_state_value: z.unknown(),
47
+ }),
48
+ }), "The FSM instance and its resolved state"),
49
+ [HttpStatusCodes.NOT_FOUND]: instanceNotFound,
50
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
51
+ },
52
+ });
53
+ export const create = createRoute({
54
+ path: "/instances",
55
+ method: "post",
56
+ request: {
57
+ body: jsonContentRequired(z.object({
58
+ fsm_name: z.string().min(1).describe("The FSM definition name"),
59
+ fsm_version: z.string().min(1).describe("The FSM version"),
60
+ input: z.record(z.unknown()).optional().describe("Initial context, merged over the definition's static context (XState's input; defaults to {})"),
61
+ }), "The FSM to start"),
62
+ },
63
+ tags,
64
+ responses: {
65
+ [HttpStatusCodes.OK]: jsonContent(z.object({ data: z.record(z.unknown()) }), "The created instance, enqueued for scheduling"),
66
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
67
+ },
68
+ });
69
+ export const sendEvent = createRoute({
70
+ path: "/instances/{id}/events",
71
+ method: "post",
72
+ request: {
73
+ params: IdUUIDParamsSchema,
74
+ body: jsonContentRequired(z.object({ type: z.string().min(1) }).passthrough(), "The event: its type and any payload fields"),
75
+ },
76
+ tags,
77
+ responses: {
78
+ [HttpStatusCodes.OK]: jsonContent(z.object({ data: z.any() }), "The event was queued for the instance"),
79
+ [HttpStatusCodes.NOT_FOUND]: instanceNotFound,
80
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
81
+ },
82
+ });
83
+ export const resume = createRoute({
84
+ path: "/instances/{id}/resume",
85
+ method: "post",
86
+ request: { params: IdUUIDParamsSchema },
87
+ tags,
88
+ responses: {
89
+ [HttpStatusCodes.OK]: jsonContent(z.object({ data: z.record(z.unknown()) }), "The instance was re-enqueued for scheduling"),
90
+ [HttpStatusCodes.NOT_FOUND]: instanceNotFound,
91
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
92
+ },
93
+ });
94
+ export const stop = createRoute({
95
+ path: "/instances/{id}/stop",
96
+ method: "post",
97
+ request: { params: IdUUIDParamsSchema },
98
+ tags,
99
+ responses: {
100
+ [HttpStatusCodes.OK]: jsonContent(z.object({}), "The instance's worker was told to stop"),
101
+ [HttpStatusCodes.NOT_FOUND]: instanceNotFound,
102
+ [HttpStatusCodes.INTERNAL_SERVER_ERROR]: jsonContent(errorSchema, "Error"),
103
+ },
104
+ });
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../../../_dnt.polyfills.js";