@requence/task 1.0.0-alpha.43 → 1.0.0-alpha.45
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/CHANGELOG.md +12 -0
- package/build/index.js +138 -131
- package/build/index.js.map +11 -11
- package/build/types/helpers/src/files/mapOutput.d.ts.map +1 -1
- package/build/types/helpers/src/index.d.ts +3 -2
- package/build/types/helpers/src/index.d.ts.map +1 -1
- package/build/types/helpers/src/jsonschema/zod.d.ts +1 -0
- package/build/types/helpers/src/jsonschema/zod.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/NodeTree.d.ts +31 -14
- package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/command.d.ts +4 -12
- package/build/types/helpers/src/protocol/command.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/nodeType.d.ts +2 -0
- package/build/types/helpers/src/protocol/nodeType.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/taskOptions.d.ts +0 -3
- package/build/types/helpers/src/protocol/taskOptions.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts +32 -0
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/treeNodes.d.ts +10 -6
- package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -1
- package/build/types/helpers/src/utils/debounce.d.ts +4 -0
- package/build/types/helpers/src/utils/debounce.d.ts.map +1 -0
- package/build/types/helpers/src/utils/guards.d.ts +3 -0
- package/build/types/helpers/src/utils/guards.d.ts.map +1 -0
- package/build/types/helpers/src/utils/obj.d.ts +4 -0
- package/build/types/helpers/src/utils/obj.d.ts.map +1 -0
- package/build/types/helpers/src/utils/requenceCallback.d.ts.map +1 -1
- package/build/types/helpers/src/utils/types.d.ts +3 -0
- package/build/types/helpers/src/utils/types.d.ts.map +1 -1
- package/build/types/task/src/createTask.d.ts +6 -10
- package/build/types/task/src/createTask.d.ts.map +1 -1
- package/build/types/task/src/getTask.d.ts +1 -0
- package/build/types/task/src/getTask.d.ts.map +1 -1
- package/build/types/task/src/recreateTask.d.ts +1 -10
- package/build/types/task/src/recreateTask.d.ts.map +1 -1
- package/build/types/task/src/types.d.ts +2 -1
- package/build/types/task/src/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/build/types/helpers/src/utils/createRemotePromise.d.ts +0 -7
- package/build/types/helpers/src/utils/createRemotePromise.d.ts.map +0 -1
- package/build/types/helpers/src/utils/isRecord.d.ts +0 -2
- package/build/types/helpers/src/utils/isRecord.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
package/build/index.js
CHANGED
|
@@ -49,12 +49,13 @@ function callbackToAsyncIterable(...args) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// ../helpers/src/utils/
|
|
52
|
+
// ../helpers/src/utils/guards.ts
|
|
53
53
|
import { z } from "zod/v4";
|
|
54
54
|
var recordSchema = z.record(z.string(), z.unknown());
|
|
55
55
|
function isRecord(data) {
|
|
56
56
|
return recordSchema.safeParse(data).success;
|
|
57
57
|
}
|
|
58
|
+
var uuidSchema = z.uuid();
|
|
58
59
|
|
|
59
60
|
// ../helpers/src/utils/mapData.ts
|
|
60
61
|
function resolve(value, onResolve) {
|
|
@@ -153,110 +154,22 @@ function isCallbackObject(data) {
|
|
|
153
154
|
return callbackObjectSchema.safeParse(data).success;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
// ../helpers/src/files/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
return toFileObject(data);
|
|
171
|
-
}
|
|
172
|
-
async function stream(streamUrl, stream2, signal, contentType) {
|
|
173
|
-
const [testStream, dataStream] = stream2.tee();
|
|
174
|
-
const reader = testStream.getReader();
|
|
175
|
-
const dataPromise = reader.read().then(({ done: done2 }) => {
|
|
176
|
-
if (done2) {
|
|
177
|
-
throw new Error("No streaming date received");
|
|
178
|
-
}
|
|
179
|
-
reader.cancel();
|
|
180
|
-
});
|
|
181
|
-
const streamResponse = await fetch(streamUrl, {
|
|
182
|
-
method: "POST",
|
|
183
|
-
signal,
|
|
184
|
-
headers: contentType ? { "Content-Type": contentType } : {}
|
|
185
|
-
});
|
|
186
|
-
const data = await streamResponse.json();
|
|
187
|
-
if (!data || typeof data !== "object") {
|
|
188
|
-
throw new Error("invalid stream response");
|
|
189
|
-
}
|
|
190
|
-
const { mime, url } = data;
|
|
191
|
-
await dataPromise;
|
|
192
|
-
const done = fetch(url, {
|
|
193
|
-
method: "POST",
|
|
194
|
-
signal,
|
|
195
|
-
duplex: "half",
|
|
196
|
-
body: dataStream
|
|
197
|
-
});
|
|
198
|
-
return [toStreamObject({ mime, url }), done];
|
|
157
|
+
// ../helpers/src/files/fileObject.ts
|
|
158
|
+
import { z as z3 } from "zod/v4";
|
|
159
|
+
var fileObjectSchema = z3.object({
|
|
160
|
+
size: z3.int().positive(),
|
|
161
|
+
mime: z3.string(),
|
|
162
|
+
url: z3.url(),
|
|
163
|
+
__REQUENCE_type: z3.literal("RequenceFile")
|
|
164
|
+
});
|
|
165
|
+
function toFileObject(fileInfo) {
|
|
166
|
+
return {
|
|
167
|
+
...fileInfo,
|
|
168
|
+
__REQUENCE_type: "RequenceFile"
|
|
169
|
+
};
|
|
199
170
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const mapped = await mapData(params.value, {
|
|
203
|
-
async Object(obj) {
|
|
204
|
-
if (obj instanceof Blob || obj instanceof RequenceFile) {
|
|
205
|
-
if (obj instanceof RequenceFile && obj.fileObject) {
|
|
206
|
-
return obj.fileObject;
|
|
207
|
-
}
|
|
208
|
-
if (params.options.uploadUrl) {
|
|
209
|
-
try {
|
|
210
|
-
if (obj instanceof Blob) {
|
|
211
|
-
return await upload(params.options.uploadUrl, obj, params.signal, obj.type);
|
|
212
|
-
}
|
|
213
|
-
if (obj instanceof RequenceFile) {
|
|
214
|
-
return await upload(params.options.uploadUrl, await obj.blob(), params.signal, obj.mimeType);
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
if (!(error instanceof Error)) {
|
|
218
|
-
throw error;
|
|
219
|
-
}
|
|
220
|
-
params.onFail?.(error);
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
params.onSkip?.();
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (obj instanceof Response || obj instanceof RequenceStream) {
|
|
229
|
-
if (obj instanceof RequenceStream && obj.streamObject) {
|
|
230
|
-
return obj.streamObject;
|
|
231
|
-
}
|
|
232
|
-
if (params.options.streamUrl) {
|
|
233
|
-
try {
|
|
234
|
-
if (obj instanceof Response && obj.body) {
|
|
235
|
-
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.body, params.signal, obj.headers.get("Content-Type"));
|
|
236
|
-
streamPromises.push(streamPromise);
|
|
237
|
-
return streamObject;
|
|
238
|
-
}
|
|
239
|
-
if (obj instanceof RequenceStream) {
|
|
240
|
-
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.stream(), params.signal, obj.mimeType);
|
|
241
|
-
streamPromises.push(streamPromise);
|
|
242
|
-
return streamObject;
|
|
243
|
-
}
|
|
244
|
-
} catch (error) {
|
|
245
|
-
if (!(error instanceof Error)) {
|
|
246
|
-
throw error;
|
|
247
|
-
}
|
|
248
|
-
params.onFail?.(error);
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
} else {
|
|
252
|
-
params.onSkip?.();
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
Promise.allSettled(streamPromises).then(() => params.onDone?.());
|
|
259
|
-
return mapped;
|
|
171
|
+
function isFileObject(data) {
|
|
172
|
+
return fileObjectSchema.safeParse(data).success;
|
|
260
173
|
}
|
|
261
174
|
|
|
262
175
|
// ../helpers/src/files/RequenceFile.ts
|
|
@@ -323,15 +236,15 @@ class RequenceStream {
|
|
|
323
236
|
#data;
|
|
324
237
|
#stream = null;
|
|
325
238
|
#options;
|
|
326
|
-
constructor(
|
|
327
|
-
this.#data =
|
|
239
|
+
constructor(stream, options) {
|
|
240
|
+
this.#data = stream;
|
|
328
241
|
this.#options = options;
|
|
329
242
|
}
|
|
330
|
-
static fromStreamObject(
|
|
243
|
+
static fromStreamObject(stream) {
|
|
331
244
|
const instance = new this(null, {
|
|
332
245
|
type: "x/x"
|
|
333
246
|
});
|
|
334
|
-
instance.#stream =
|
|
247
|
+
instance.#stream = stream;
|
|
335
248
|
return instance;
|
|
336
249
|
}
|
|
337
250
|
get streamObject() {
|
|
@@ -380,11 +293,11 @@ class RequenceStream {
|
|
|
380
293
|
}
|
|
381
294
|
|
|
382
295
|
// ../helpers/src/files/streamObject.ts
|
|
383
|
-
import { z as
|
|
384
|
-
var streamObjectSchema =
|
|
385
|
-
mime:
|
|
386
|
-
url:
|
|
387
|
-
__REQUENCE_type:
|
|
296
|
+
import { z as z4 } from "zod/v4";
|
|
297
|
+
var streamObjectSchema = z4.object({
|
|
298
|
+
mime: z4.string(),
|
|
299
|
+
url: z4.string().url(),
|
|
300
|
+
__REQUENCE_type: z4.literal("RequenceStream")
|
|
388
301
|
});
|
|
389
302
|
function isStreamObject(data) {
|
|
390
303
|
return streamObjectSchema.safeParse(data).success;
|
|
@@ -396,22 +309,110 @@ function toStreamObject(streamInfo) {
|
|
|
396
309
|
};
|
|
397
310
|
}
|
|
398
311
|
|
|
399
|
-
// ../helpers/src/files/
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
312
|
+
// ../helpers/src/files/mapOutput.ts
|
|
313
|
+
async function upload(uploadUrl, body, signal, contentType) {
|
|
314
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
315
|
+
method: "POST",
|
|
316
|
+
signal,
|
|
317
|
+
headers: contentType ? {
|
|
318
|
+
"Content-Type": contentType
|
|
319
|
+
} : {},
|
|
320
|
+
body
|
|
321
|
+
});
|
|
322
|
+
const data = await uploadResponse.json();
|
|
323
|
+
if (!data || typeof data !== "object") {
|
|
324
|
+
throw new Error("invalid upload response");
|
|
325
|
+
}
|
|
326
|
+
return toFileObject(data);
|
|
412
327
|
}
|
|
413
|
-
function
|
|
414
|
-
|
|
328
|
+
async function stream(streamUrl, stream2, signal, contentType) {
|
|
329
|
+
const [testStream, dataStream] = stream2.tee();
|
|
330
|
+
const reader = testStream.getReader();
|
|
331
|
+
const dataPromise = reader.read().then(({ done: done2 }) => {
|
|
332
|
+
if (done2) {
|
|
333
|
+
throw new Error("No streaming date received");
|
|
334
|
+
}
|
|
335
|
+
reader.cancel();
|
|
336
|
+
});
|
|
337
|
+
const streamResponse = await fetch(streamUrl, {
|
|
338
|
+
method: "POST",
|
|
339
|
+
signal,
|
|
340
|
+
headers: contentType ? { "Content-Type": contentType } : {}
|
|
341
|
+
});
|
|
342
|
+
const data = await streamResponse.json();
|
|
343
|
+
if (!data || typeof data !== "object") {
|
|
344
|
+
throw new Error("invalid stream response");
|
|
345
|
+
}
|
|
346
|
+
const { mime, url } = data;
|
|
347
|
+
await dataPromise;
|
|
348
|
+
const done = fetch(url, {
|
|
349
|
+
method: "POST",
|
|
350
|
+
signal,
|
|
351
|
+
duplex: "half",
|
|
352
|
+
body: dataStream
|
|
353
|
+
});
|
|
354
|
+
return [toStreamObject({ mime, url }), done];
|
|
355
|
+
}
|
|
356
|
+
async function mapOutput(params) {
|
|
357
|
+
const streamPromises = [];
|
|
358
|
+
const mapped = await mapData(params.value, {
|
|
359
|
+
async Object(obj) {
|
|
360
|
+
if (obj instanceof Blob || obj instanceof RequenceFile) {
|
|
361
|
+
if (obj instanceof RequenceFile && obj.fileObject) {
|
|
362
|
+
return obj.fileObject;
|
|
363
|
+
}
|
|
364
|
+
if (params.options.uploadUrl) {
|
|
365
|
+
try {
|
|
366
|
+
if (obj instanceof Blob) {
|
|
367
|
+
return await upload(params.options.uploadUrl, obj, params.signal, obj.type);
|
|
368
|
+
}
|
|
369
|
+
if (obj instanceof RequenceFile) {
|
|
370
|
+
return await upload(params.options.uploadUrl, await obj.blob(), params.signal, obj.mimeType);
|
|
371
|
+
}
|
|
372
|
+
} catch (error) {
|
|
373
|
+
if (!(error instanceof Error)) {
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
376
|
+
params.onFail?.(error);
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
params.onSkip?.();
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (obj instanceof Response || obj instanceof RequenceStream) {
|
|
385
|
+
if (obj instanceof RequenceStream && obj.streamObject) {
|
|
386
|
+
return obj.streamObject;
|
|
387
|
+
}
|
|
388
|
+
if (params.options.streamUrl) {
|
|
389
|
+
try {
|
|
390
|
+
if (obj instanceof Response && obj.body) {
|
|
391
|
+
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.body, params.signal, obj.headers.get("Content-Type"));
|
|
392
|
+
streamPromises.push(streamPromise);
|
|
393
|
+
return streamObject;
|
|
394
|
+
}
|
|
395
|
+
if (obj instanceof RequenceStream) {
|
|
396
|
+
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.stream(), params.signal, obj.mimeType);
|
|
397
|
+
streamPromises.push(streamPromise);
|
|
398
|
+
return streamObject;
|
|
399
|
+
}
|
|
400
|
+
} catch (error) {
|
|
401
|
+
if (!(error instanceof Error)) {
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
params.onFail?.(error);
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
params.onSkip?.();
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
Promise.allSettled(streamPromises).then(() => params.onDone?.());
|
|
415
|
+
return mapped;
|
|
415
416
|
}
|
|
416
417
|
|
|
417
418
|
// ../helpers/src/utils/resolveRequenceTypes.ts
|
|
@@ -434,6 +435,7 @@ function resolveRequenceTypes(data, onCallback) {
|
|
|
434
435
|
}
|
|
435
436
|
|
|
436
437
|
// src/createTask.ts
|
|
438
|
+
import chalk from "chalk";
|
|
437
439
|
import { createEventSource } from "eventsource-client";
|
|
438
440
|
|
|
439
441
|
// src/utils/getAccessToken.ts
|
|
@@ -717,6 +719,9 @@ function createTask(options, onUpdate) {
|
|
|
717
719
|
return;
|
|
718
720
|
}
|
|
719
721
|
const prepareData = await prepareResponse.json();
|
|
722
|
+
if (prepareData.branch !== "live" && !options.suppressBranchWarning) {
|
|
723
|
+
console.warn(chalk.hex("#eab308")("task is executed in", chalk.bold(prepareData.branch), "branch"));
|
|
724
|
+
}
|
|
720
725
|
taskIdPromiseWithResolvers.resolve(prepareData.taskId);
|
|
721
726
|
const mappedParams = await mapOutput({
|
|
722
727
|
value: {
|
|
@@ -795,7 +800,7 @@ function createTask(options, onUpdate) {
|
|
|
795
800
|
});
|
|
796
801
|
}
|
|
797
802
|
};
|
|
798
|
-
return Object.
|
|
803
|
+
return Object.defineProperties(asyncIterable, Object.getOwnPropertyDescriptors(methods));
|
|
799
804
|
}
|
|
800
805
|
// src/watchTasks.ts
|
|
801
806
|
import { createEventSource as createEventSource2 } from "eventsource-client";
|
|
@@ -934,7 +939,8 @@ var taskSchema = z6.object({
|
|
|
934
939
|
taskTemplate: z6.string(),
|
|
935
940
|
name: z6.string(),
|
|
936
941
|
nodesData: z6.array(z6.object({ alias: z6.string(), data: z6.unknown() })),
|
|
937
|
-
nodesError: z6.array(z6.object({ alias: z6.string(), error: z6.string() }))
|
|
942
|
+
nodesError: z6.array(z6.object({ alias: z6.string(), error: z6.string() })),
|
|
943
|
+
branch: z6.union([z6.literal("live"), z6.string()])
|
|
938
944
|
});
|
|
939
945
|
async function getTask(taskIdOrOptions) {
|
|
940
946
|
const taskId = typeof taskIdOrOptions === "string" ? taskIdOrOptions : taskIdOrOptions.taskId;
|
|
@@ -966,6 +972,7 @@ async function getTask(taskIdOrOptions) {
|
|
|
966
972
|
statusText: taskData.statusText,
|
|
967
973
|
taskTemplate: taskData.taskTemplate,
|
|
968
974
|
name: taskData.name,
|
|
975
|
+
branch: taskData.branch,
|
|
969
976
|
context
|
|
970
977
|
};
|
|
971
978
|
}
|
|
@@ -991,5 +998,5 @@ export {
|
|
|
991
998
|
RequenceFile
|
|
992
999
|
};
|
|
993
1000
|
|
|
994
|
-
//# debugId=
|
|
1001
|
+
//# debugId=1B1F4B631C601AA564756E2164756E21
|
|
995
1002
|
//# sourceMappingURL=index.js.map
|