@requence/task 1.0.0-alpha.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.
@@ -0,0 +1,371 @@
1
+ import { z } from 'zod';
2
+ type Prettify<T> = {
3
+ [K in keyof T]: T[K];
4
+ } & {};
5
+ type IfUnknown<T, Then, Else> = unknown extends T ? T extends unknown ? Then : Else : Else;
6
+ type IfNull<T, Then, Else> = T extends null ? null extends T ? Then : Else : Else;
7
+ export type CreateTaskOptions<T> = {
8
+ taskTemplate: T;
9
+ accessToken?: string;
10
+ } & IfNull<Input<T>, {
11
+ input?: null;
12
+ }, IfUnknown<Input<T>, {
13
+ input?: any;
14
+ }, {
15
+ input: Input<T>;
16
+ }>> & IfNull<Meta<T>, {
17
+ meta?: null;
18
+ }, IfUnknown<Meta<T>, {
19
+ meta?: any;
20
+ }, {
21
+ meta: Meta<T>;
22
+ }>>;
23
+ type Input<T> = T extends keyof Requence.TaskTemplate ? Requence.TaskTemplate[T]['input'] : unknown;
24
+ type Meta<T> = T extends keyof Requence.TaskTemplate ? Requence.TaskTemplate[T]['meta'] : unknown;
25
+ type Data<T> = T extends keyof Requence.TaskTemplate ? Prettify<Requence.TaskTemplate[T]['results']> : unknown;
26
+ type NamedData<T, A> = T extends keyof Requence.TaskTemplate ? A extends keyof Requence.TaskTemplate[T]['namedResults'] ? Prettify<Requence.TaskTemplate[T]['namedResults'][A]> : unknown : unknown;
27
+ type Alias<T> = T extends keyof Requence.TaskTemplate ? keyof Requence.TaskTemplate[T]['namedResults'] : string;
28
+ export interface Result<T> {
29
+ getInput(): Input<T>;
30
+ getMeta(): Meta<T>;
31
+ getData: {
32
+ (): Data<T>;
33
+ <A extends Alias<T>>(alias: A): NamedData<T, A>;
34
+ };
35
+ getError(alias: Alias<T>): string | null;
36
+ }
37
+ export declare const updateSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
38
+ type: z.ZodLiteral<"taskStart">;
39
+ timestamp: z.ZodDate;
40
+ input: z.ZodUnknown;
41
+ meta: z.ZodUnknown;
42
+ }, "strip", z.ZodTypeAny, {
43
+ type: "taskStart";
44
+ timestamp: Date;
45
+ input?: unknown;
46
+ meta?: unknown;
47
+ }, {
48
+ type: "taskStart";
49
+ timestamp: Date;
50
+ input?: unknown;
51
+ meta?: unknown;
52
+ }>, z.ZodObject<{
53
+ type: z.ZodLiteral<"taskError">;
54
+ timestamp: z.ZodDate;
55
+ error: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ type: "taskError";
58
+ timestamp: Date;
59
+ error: string;
60
+ }, {
61
+ type: "taskError";
62
+ timestamp: Date;
63
+ error: string;
64
+ }>, z.ZodObject<{
65
+ type: z.ZodLiteral<"taskEnd">;
66
+ timestamp: z.ZodDate;
67
+ result: z.ZodRecord<z.ZodString, z.ZodUnknown>;
68
+ partialResults: z.ZodArray<z.ZodObject<{
69
+ node: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
70
+ id: z.ZodString;
71
+ type: z.ZodLiteral<"service">;
72
+ alias: z.ZodOptional<z.ZodString>;
73
+ service: z.ZodOptional<z.ZodObject<{
74
+ id: z.ZodString;
75
+ name: z.ZodString;
76
+ version: z.ZodString;
77
+ }, "strip", z.ZodTypeAny, {
78
+ id: string;
79
+ name: string;
80
+ version: string;
81
+ }, {
82
+ id: string;
83
+ name: string;
84
+ version: string;
85
+ }>>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ type: "service";
88
+ id: string;
89
+ service?: {
90
+ id: string;
91
+ name: string;
92
+ version: string;
93
+ } | undefined;
94
+ alias?: string | undefined;
95
+ }, {
96
+ type: "service";
97
+ id: string;
98
+ service?: {
99
+ id: string;
100
+ name: string;
101
+ version: string;
102
+ } | undefined;
103
+ alias?: string | undefined;
104
+ }>, z.ZodObject<{
105
+ id: z.ZodString;
106
+ type: z.ZodLiteral<"logic">;
107
+ alias: z.ZodOptional<z.ZodString>;
108
+ logic: z.ZodOptional<z.ZodObject<{
109
+ language: z.ZodEnum<["typescript", "javascript", "python"]>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ language: "typescript" | "javascript" | "python";
112
+ }, {
113
+ language: "typescript" | "javascript" | "python";
114
+ }>>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ type: "logic";
117
+ id: string;
118
+ alias?: string | undefined;
119
+ logic?: {
120
+ language: "typescript" | "javascript" | "python";
121
+ } | undefined;
122
+ }, {
123
+ type: "logic";
124
+ id: string;
125
+ alias?: string | undefined;
126
+ logic?: {
127
+ language: "typescript" | "javascript" | "python";
128
+ } | undefined;
129
+ }>]>;
130
+ timestamp: z.ZodNullable<z.ZodDate>;
131
+ data: z.ZodUnknown;
132
+ error: z.ZodOptional<z.ZodString>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ timestamp: Date | null;
135
+ node: {
136
+ type: "service";
137
+ id: string;
138
+ service?: {
139
+ id: string;
140
+ name: string;
141
+ version: string;
142
+ } | undefined;
143
+ alias?: string | undefined;
144
+ } | {
145
+ type: "logic";
146
+ id: string;
147
+ alias?: string | undefined;
148
+ logic?: {
149
+ language: "typescript" | "javascript" | "python";
150
+ } | undefined;
151
+ };
152
+ error?: string | undefined;
153
+ data?: unknown;
154
+ }, {
155
+ timestamp: Date | null;
156
+ node: {
157
+ type: "service";
158
+ id: string;
159
+ service?: {
160
+ id: string;
161
+ name: string;
162
+ version: string;
163
+ } | undefined;
164
+ alias?: string | undefined;
165
+ } | {
166
+ type: "logic";
167
+ id: string;
168
+ alias?: string | undefined;
169
+ logic?: {
170
+ language: "typescript" | "javascript" | "python";
171
+ } | undefined;
172
+ };
173
+ error?: string | undefined;
174
+ data?: unknown;
175
+ }>, "many">;
176
+ }, "strip", z.ZodTypeAny, {
177
+ type: "taskEnd";
178
+ timestamp: Date;
179
+ result: Record<string, unknown>;
180
+ partialResults: {
181
+ timestamp: Date | null;
182
+ node: {
183
+ type: "service";
184
+ id: string;
185
+ service?: {
186
+ id: string;
187
+ name: string;
188
+ version: string;
189
+ } | undefined;
190
+ alias?: string | undefined;
191
+ } | {
192
+ type: "logic";
193
+ id: string;
194
+ alias?: string | undefined;
195
+ logic?: {
196
+ language: "typescript" | "javascript" | "python";
197
+ } | undefined;
198
+ };
199
+ error?: string | undefined;
200
+ data?: unknown;
201
+ }[];
202
+ }, {
203
+ type: "taskEnd";
204
+ timestamp: Date;
205
+ result: Record<string, unknown>;
206
+ partialResults: {
207
+ timestamp: Date | null;
208
+ node: {
209
+ type: "service";
210
+ id: string;
211
+ service?: {
212
+ id: string;
213
+ name: string;
214
+ version: string;
215
+ } | undefined;
216
+ alias?: string | undefined;
217
+ } | {
218
+ type: "logic";
219
+ id: string;
220
+ alias?: string | undefined;
221
+ logic?: {
222
+ language: "typescript" | "javascript" | "python";
223
+ } | undefined;
224
+ };
225
+ error?: string | undefined;
226
+ data?: unknown;
227
+ }[];
228
+ }>, z.ZodObject<{
229
+ type: z.ZodLiteral<"nodeStart">;
230
+ timestamp: z.ZodDate;
231
+ node: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
232
+ id: z.ZodString;
233
+ type: z.ZodLiteral<"service">;
234
+ alias: z.ZodOptional<z.ZodString>;
235
+ service: z.ZodOptional<z.ZodObject<{
236
+ id: z.ZodString;
237
+ name: z.ZodString;
238
+ version: z.ZodString;
239
+ }, "strip", z.ZodTypeAny, {
240
+ id: string;
241
+ name: string;
242
+ version: string;
243
+ }, {
244
+ id: string;
245
+ name: string;
246
+ version: string;
247
+ }>>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ type: "service";
250
+ id: string;
251
+ service?: {
252
+ id: string;
253
+ name: string;
254
+ version: string;
255
+ } | undefined;
256
+ alias?: string | undefined;
257
+ }, {
258
+ type: "service";
259
+ id: string;
260
+ service?: {
261
+ id: string;
262
+ name: string;
263
+ version: string;
264
+ } | undefined;
265
+ alias?: string | undefined;
266
+ }>, z.ZodObject<{
267
+ id: z.ZodString;
268
+ type: z.ZodLiteral<"logic">;
269
+ alias: z.ZodOptional<z.ZodString>;
270
+ logic: z.ZodOptional<z.ZodObject<{
271
+ language: z.ZodEnum<["typescript", "javascript", "python"]>;
272
+ }, "strip", z.ZodTypeAny, {
273
+ language: "typescript" | "javascript" | "python";
274
+ }, {
275
+ language: "typescript" | "javascript" | "python";
276
+ }>>;
277
+ }, "strip", z.ZodTypeAny, {
278
+ type: "logic";
279
+ id: string;
280
+ alias?: string | undefined;
281
+ logic?: {
282
+ language: "typescript" | "javascript" | "python";
283
+ } | undefined;
284
+ }, {
285
+ type: "logic";
286
+ id: string;
287
+ alias?: string | undefined;
288
+ logic?: {
289
+ language: "typescript" | "javascript" | "python";
290
+ } | undefined;
291
+ }>]>;
292
+ }, "strip", z.ZodTypeAny, {
293
+ type: "nodeStart";
294
+ timestamp: Date;
295
+ node: {
296
+ type: "service";
297
+ id: string;
298
+ service?: {
299
+ id: string;
300
+ name: string;
301
+ version: string;
302
+ } | undefined;
303
+ alias?: string | undefined;
304
+ } | {
305
+ type: "logic";
306
+ id: string;
307
+ alias?: string | undefined;
308
+ logic?: {
309
+ language: "typescript" | "javascript" | "python";
310
+ } | undefined;
311
+ };
312
+ }, {
313
+ type: "nodeStart";
314
+ timestamp: Date;
315
+ node: {
316
+ type: "service";
317
+ id: string;
318
+ service?: {
319
+ id: string;
320
+ name: string;
321
+ version: string;
322
+ } | undefined;
323
+ alias?: string | undefined;
324
+ } | {
325
+ type: "logic";
326
+ id: string;
327
+ alias?: string | undefined;
328
+ logic?: {
329
+ language: "typescript" | "javascript" | "python";
330
+ } | undefined;
331
+ };
332
+ }>, z.ZodObject<{
333
+ type: z.ZodLiteral<"nodeUpdate">;
334
+ timestamp: z.ZodDate;
335
+ data: z.ZodUnknown;
336
+ }, "strip", z.ZodTypeAny, {
337
+ type: "nodeUpdate";
338
+ timestamp: Date;
339
+ data?: unknown;
340
+ }, {
341
+ type: "nodeUpdate";
342
+ timestamp: Date;
343
+ data?: unknown;
344
+ }>, z.ZodObject<{
345
+ type: z.ZodLiteral<"nodeError">;
346
+ timestamp: z.ZodDate;
347
+ error: z.ZodString;
348
+ }, "strip", z.ZodTypeAny, {
349
+ type: "nodeError";
350
+ timestamp: Date;
351
+ error: string;
352
+ }, {
353
+ type: "nodeError";
354
+ timestamp: Date;
355
+ error: string;
356
+ }>, z.ZodObject<{
357
+ type: z.ZodLiteral<"nodeDefer">;
358
+ timestamp: z.ZodDate;
359
+ reason: z.ZodOptional<z.ZodString>;
360
+ }, "strip", z.ZodTypeAny, {
361
+ type: "nodeDefer";
362
+ timestamp: Date;
363
+ reason?: string | undefined;
364
+ }, {
365
+ type: "nodeDefer";
366
+ timestamp: Date;
367
+ reason?: string | undefined;
368
+ }>]>;
369
+ export type Update = z.infer<typeof updateSchema>;
370
+ export {};
371
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,KAAK,QAAQ,CAAC,CAAC,IAAI;KAChB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAA;AAEN,KAAK,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,OAAO,SAAS,CAAC,GAC7C,CAAC,SAAS,OAAO,GACf,IAAI,GACJ,IAAI,GACN,IAAI,CAAA;AAER,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,SAAS,IAAI,GACvC,IAAI,SAAS,CAAC,GACZ,IAAI,GACJ,IAAI,GACN,IAAI,CAAA;AAER,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,YAAY,EAAE,CAAC,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,MAAM,CACR,KAAK,CAAC,CAAC,CAAC,EACR;IAAE,KAAK,CAAC,EAAE,IAAI,CAAA;CAAE,EAChB,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,QAAQ,CAAC,YAAY,GACjD,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,GAC9C,MAAM,CAAA;AAEV,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAA;IACpB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;IAClB,OAAO,EAAE;QACP,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;QACX,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;KAChD,CAAA;IACD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;CACzC;AAkFD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQvB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export default function callbackToAsyncIterator<T>(options: {
2
+ subscribe: (push: (value: T) => void) => void | (() => void);
3
+ done: (value: T) => boolean;
4
+ }): AsyncIterable<T>;
5
+ //# sourceMappingURL=callbackToAsyncIterator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callbackToAsyncIterator.d.ts","sourceRoot":"","sources":["../../../../../src/utils/callbackToAsyncIterator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC1D,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;IAC5D,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAA;CAC5B,GAAG,aAAa,CAAC,CAAC,CAAC,CA2CnB"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@requence/task",
3
+ "type": "module",
4
+ "version": "1.0.0-alpha.1",
5
+ "bin": {
6
+ "requence-task": "build/cli.js"
7
+ },
8
+ "exports": {
9
+ ".": {
10
+ "types": "./build/types/task/src/index.d.ts",
11
+ "default": "./build/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "start": "bun src/main.ts",
16
+ "check-types": "tsc",
17
+ "test": "bun test",
18
+ "build-declaration": "tsc -p tsconfig.declaration.json && tsc-alias -p tsconfig.declaration.json 2>/dev/null",
19
+ "build": "ADD_ENTRYPOINT=src/cli.ts bun -e \"import('@requence/utils/build-package.mts')\" && bun build-declaration "
20
+ },
21
+ "dependencies": {
22
+ "eventsource": "^3.0.1",
23
+ "zod": "^3.24.1"
24
+ },
25
+ "devDependencies": {
26
+ "@requence/helpers": "workspace:*",
27
+ "@requence/utils": "workspace:*",
28
+ "@types/eventsource": "^1.1.15"
29
+ }
30
+ }