@workglow/tasks 0.0.79 → 0.0.80

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/README.md CHANGED
@@ -8,7 +8,7 @@ A package of task types for common operations, workflow management, and data pro
8
8
  - [Installation](#installation)
9
9
  - [Quick Start](#quick-start)
10
10
  - [Available Tasks](#available-tasks)
11
- - [FetchTask](#fetchtask)
11
+ - [FetchUrlTask](#fetchurltask)
12
12
  - [DebugLogTask](#debuglogtask)
13
13
  - [DelayTask](#delaytask)
14
14
  - [JavaScriptTask](#javascripttask)
@@ -29,22 +29,22 @@ bun add @workglow/tasks
29
29
  ## Quick Start
30
30
 
31
31
  ```typescript
32
- import { Workflow, Fetch, DebugLog, Delay } from "@workglow/tasks";
32
+ import { Workflow, fetch, debugLog, delay } from "@workglow/tasks";
33
33
 
34
34
  // Simple workflow example (fluent API)
35
35
  const workflow = new Workflow()
36
- .Fetch({ url: "https://api.example.com/data", response_type: "json" })
37
- .DebugLog({ log_level: "info" })
38
- .Delay({ delay: 1000 });
36
+ .fetch({ url: "https://api.example.com/data", response_type: "json" })
37
+ .debugLog({ log_level: "info" })
38
+ .delay({ delay: 1000 });
39
39
 
40
40
  const results = await workflow.run();
41
41
  ```
42
42
 
43
43
  ```typescript
44
- import { FetchTask, DebugLogTask, DelayTask } from "@workglow/tasks";
44
+ import { FetchUrlTask, DebugLogTask, DelayTask } from "@workglow/tasks";
45
45
 
46
46
  // Simple sequence using Task classes directly
47
- const fetchResult = await new FetchTask({
47
+ const fetchResult = await new FetchUrlTask({
48
48
  url: "https://api.example.com/data",
49
49
  response_type: "json",
50
50
  }).run();
@@ -58,13 +58,13 @@ await new DelayTask({ delay: 1000 }).run();
58
58
  ```
59
59
 
60
60
  ```typescript
61
- import { Fetch, DebugLog, Delay } from "@workglow/tasks";
61
+ import { fetch, debugLog, delay } from "@workglow/tasks";
62
62
 
63
- const data = await Fetch({
63
+ const data = await fetch({
64
64
  url: "https://example.com/readme.txt",
65
65
  response_type: "text",
66
66
  });
67
- await DebugLog({
67
+ await debugLog({
68
68
  console: data.text,
69
69
  log_level: "info",
70
70
  });
@@ -72,7 +72,7 @@ await DebugLog({
72
72
 
73
73
  ## Available Tasks
74
74
 
75
- ### FetchTask
75
+ ### FetchUrlTask
76
76
 
77
77
  Makes HTTP requests with built-in retry logic, progress tracking, and multiple response types.
78
78
 
@@ -97,14 +97,14 @@ Makes HTTP requests with built-in retry logic, progress tracking, and multiple r
97
97
 
98
98
  ```typescript
99
99
  // Simple GET request
100
- const response = await new FetchTask({
100
+ const response = await new FetchUrlTask({
101
101
  url: "https://api.example.com/users",
102
102
  response_type: "json",
103
103
  }).run();
104
104
  console.log(response.json);
105
105
 
106
106
  // POST request with headers
107
- const postResponse = await new FetchTask({
107
+ const postResponse = await new FetchUrlTask({
108
108
  url: "https://api.example.com/users",
109
109
  method: "POST",
110
110
  headers: {
@@ -116,7 +116,7 @@ const postResponse = await new FetchTask({
116
116
  }).run();
117
117
 
118
118
  // Text response
119
- const textResponse = await new FetchTask({
119
+ const textResponse = await new FetchUrlTask({
120
120
  url: "https://example.com/readme.txt",
121
121
  response_type: "text",
122
122
  }).run();
@@ -161,9 +161,9 @@ await new DebugLogTask({
161
161
 
162
162
  // In workflow with data flow
163
163
  const workflow = new Workflow()
164
- .Fetch({ url: "https://api.example.com/data" })
165
- .DebugLog({ log_level: "dir" }) // Logs the fetched data
166
- .Delay({ delay: 1000 });
164
+ .fetch({ url: "https://api.example.com/data" })
165
+ .debugLog({ log_level: "dir" }) // Logs the fetched data
166
+ .delay({ delay: 1000 });
167
167
  ```
168
168
 
169
169
  **Features:**
@@ -201,9 +201,9 @@ console.log(result); // { message: "Data preserved through delay" }
201
201
 
202
202
  // In workflow
203
203
  const workflow = new Workflow()
204
- .Fetch({ url: "https://api.example.com/data" })
205
- .Delay({ delay: 2000 }) // 2 second delay
206
- .DebugLog({ log_level: "info" });
204
+ .fetch({ url: "https://api.example.com/data" })
205
+ .delay({ delay: 2000 }) // 2 second delay
206
+ .debugLog({ log_level: "info" });
207
207
  ```
208
208
 
209
209
  **Features:**
@@ -249,14 +249,14 @@ console.log(processed.output); // { sum: 15, average: 3, count: 5 }
249
249
 
250
250
  // In workflow
251
251
  const workflow = new Workflow()
252
- .Fetch({ url: "https://api.example.com/data" })
253
- .JavaScript({
252
+ .fetch({ url: "https://api.example.com/data" })
253
+ .javaScript({
254
254
  code: `
255
255
  const data = input.json;
256
256
  return data.filter(item => item.active === true);
257
257
  `,
258
258
  })
259
- .DebugLog({ log_level: "info" });
259
+ .debugLog({ log_level: "info" });
260
260
  ```
261
261
 
262
262
  **Features:**
@@ -380,7 +380,7 @@ Creates and executes task graphs from JSON configurations, enabling dynamic work
380
380
  ```typescript
381
381
  interface JsonTaskItem {
382
382
  id: string; // Unique task identifier
383
- type: string; // Task type (e.g., "FetchTask", "DelayTask")
383
+ type: string; // Task type (e.g., "FetchUrlTask", "DelayTask")
384
384
  input?: any; // Task input data
385
385
  config?: any; // Task configuration
386
386
  dependencies?: {
@@ -403,7 +403,7 @@ const linearWorkflow = await new JsonTask({
403
403
  json: JSON.stringify([
404
404
  {
405
405
  id: "fetch-data",
406
- type: "FetchTask",
406
+ type: "FetchUrlTask",
407
407
  input: {
408
408
  url: "https://api.example.com/users",
409
409
  response_type: "json",
@@ -432,7 +432,7 @@ const complexWorkflow = await new JsonTask({
432
432
  json: JSON.stringify([
433
433
  {
434
434
  id: "fetch-users",
435
- type: "FetchTask",
435
+ type: "FetchUrlTask",
436
436
  input: {
437
437
  url: "https://api.example.com/users",
438
438
  response_type: "json",
@@ -440,7 +440,7 @@ const complexWorkflow = await new JsonTask({
440
440
  },
441
441
  {
442
442
  id: "fetch-posts",
443
- type: "FetchTask",
443
+ type: "FetchUrlTask",
444
444
  input: {
445
445
  url: "https://api.example.com/posts",
446
446
  response_type: "json",
@@ -503,16 +503,16 @@ import { Workflow } from "@workglow/tasks";
503
503
 
504
504
  // Fluent workflow API
505
505
  const workflow = new Workflow()
506
- .Fetch({
506
+ .fetch({
507
507
  url: "https://api.example.com/data",
508
508
  response_type: "json",
509
509
  })
510
- .JavaScript({
510
+ .javaScript({
511
511
  code: "return input.json.filter(item => item.status === 'active');",
512
512
  })
513
- .DebugLog({ log_level: "info" })
514
- .Delay({ delay: 500 })
515
- .Lambda(
513
+ .debugLog({ log_level: "info" })
514
+ .delay({ delay: 500 })
515
+ .lambda(
516
516
  {},
517
517
  {
518
518
  execute: async (input) => ({
@@ -532,7 +532,7 @@ Tasks include comprehensive error handling:
532
532
 
533
533
  ```typescript
534
534
  try {
535
- const result = await new FetchTask({
535
+ const result = await new FetchUrlTask({
536
536
  url: "https://api.example.com/data",
537
537
  response_type: "json",
538
538
  timeout: 5000,
@@ -556,7 +556,7 @@ Tasks support various configuration options:
556
556
 
557
557
  ```typescript
558
558
  // Task-specific configuration
559
- const fetchTask = new FetchTask(
559
+ const fetchTask = new FetchUrlTask(
560
560
  {
561
561
  url: "https://api.example.com/data",
562
562
  },
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export * from "./task/DebugLogTask";
7
7
  export * from "./task/DelayTask";
8
- export * from "./task/FetchTask";
8
+ export * from "./task/FetchUrlTask";
9
9
  export * from "./task/JavaScriptTask";
10
10
  export * from "./task/JsonTask";
11
11
  export * from "./task/LambdaTask";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -62,11 +62,11 @@ class DebugLogTask extends Task {
62
62
  }
63
63
  }
64
64
  TaskRegistry.registerTask(DebugLogTask);
65
- var DebugLog = (input, config = {}) => {
65
+ var debugLog = (input, config = {}) => {
66
66
  const task = new DebugLogTask(input, config);
67
67
  return task.run();
68
68
  };
69
- Workflow.prototype.DebugLog = CreateWorkflow(DebugLogTask);
69
+ Workflow.prototype.debugLog = CreateWorkflow(DebugLogTask);
70
70
  // src/task/DelayTask.ts
71
71
  import {
72
72
  CreateWorkflow as CreateWorkflow2,
@@ -127,12 +127,12 @@ class DelayTask extends Task2 {
127
127
  }
128
128
  }
129
129
  TaskRegistry2.registerTask(DelayTask);
130
- var Delay = (input, config = {}) => {
130
+ var delay = (input, config = {}) => {
131
131
  const task = new DelayTask(input, config);
132
132
  return task.run();
133
133
  };
134
- Workflow2.prototype.Delay = CreateWorkflow2(DelayTask);
135
- // src/task/FetchTask.ts
134
+ Workflow2.prototype.delay = CreateWorkflow2(DelayTask);
135
+ // src/task/FetchUrlTask.ts
136
136
  import {
137
137
  AbortSignalJobError,
138
138
  Job,
@@ -222,7 +222,7 @@ async function fetchWithProgress(url, options = {}, onProgress) {
222
222
  if (!options.signal) {
223
223
  throw new TaskConfigurationError("An AbortSignal must be provided.");
224
224
  }
225
- const response = await fetch(url, options);
225
+ const response = await globalThis.fetch(url, options);
226
226
  if (!response.body) {
227
227
  throw new Error("ReadableStream not supported in this environment.");
228
228
  }
@@ -268,11 +268,11 @@ async function fetchWithProgress(url, options = {}, onProgress) {
268
268
  });
269
269
  }
270
270
 
271
- class FetchJob extends Job {
271
+ class FetchUrlJob extends Job {
272
272
  constructor(config = { input: {} }) {
273
273
  super(config);
274
274
  }
275
- static type = "FetchJob";
275
+ static type = "FetchUrlJob";
276
276
  async execute(input, context) {
277
277
  const response = await fetchWithProgress(input.url, {
278
278
  method: input.method,
@@ -330,8 +330,8 @@ class FetchJob extends Job {
330
330
  }
331
331
  }
332
332
 
333
- class FetchTask extends JobQueueTask {
334
- static type = "FetchTask";
333
+ class FetchUrlTask extends JobQueueTask {
334
+ static type = "FetchUrlTask";
335
335
  static category = "Input";
336
336
  static title = "Fetch";
337
337
  static description = "Fetches data from a URL with progress tracking and automatic retry handling";
@@ -379,7 +379,7 @@ class FetchTask extends JobQueueTask {
379
379
  config.queue = false;
380
380
  }
381
381
  super(input, config);
382
- this.jobClass = FetchJob;
382
+ this.jobClass = FetchUrlJob;
383
383
  }
384
384
  setInput(input) {
385
385
  if (!("response_type" in input)) {
@@ -413,12 +413,12 @@ class FetchTask extends JobQueueTask {
413
413
  }
414
414
  }
415
415
  }
416
- TaskRegistry3.registerTask(FetchTask);
417
- var Fetch = async (input, config = {}) => {
418
- const result = await new FetchTask(input, config).run();
416
+ TaskRegistry3.registerTask(FetchUrlTask);
417
+ var fetchUrl = async (input, config = {}) => {
418
+ const result = await new FetchUrlTask(input, config).run();
419
419
  return result;
420
420
  };
421
- Workflow3.prototype.Fetch = CreateWorkflow3(FetchTask);
421
+ Workflow3.prototype.fetch = CreateWorkflow3(FetchUrlTask);
422
422
  // src/task/JavaScriptTask.ts
423
423
  import { CreateWorkflow as CreateWorkflow4, Task as Task3, TaskRegistry as TaskRegistry4, Workflow as Workflow4 } from "@workglow/task-graph";
424
424
 
@@ -3724,7 +3724,7 @@ Interpreter.prototype.createTask_ = function(isInterval, args) {
3724
3724
  var parentState = this.stateStack[this.stateStack.length - 1];
3725
3725
  var argsArray = Array.from(args);
3726
3726
  var exec = argsArray.shift();
3727
- var delay = Math.max(Number(argsArray.shift() || 0), 0);
3727
+ var delay2 = Math.max(Number(argsArray.shift() || 0), 0);
3728
3728
  var node = this.newNode();
3729
3729
  var scope, functionRef, ast;
3730
3730
  if (exec instanceof Interpreter.Object && exec.class === "Function") {
@@ -3746,12 +3746,12 @@ Interpreter.prototype.createTask_ = function(isInterval, args) {
3746
3746
  scope = this.globalScope;
3747
3747
  argsArray.length = 0;
3748
3748
  }
3749
- var task = new Interpreter.Task(functionRef, argsArray, scope, node, isInterval ? delay : -1);
3750
- this.scheduleTask_(task, delay);
3749
+ var task = new Interpreter.Task(functionRef, argsArray, scope, node, isInterval ? delay2 : -1);
3750
+ this.scheduleTask_(task, delay2);
3751
3751
  return task.pid;
3752
3752
  };
3753
- Interpreter.prototype.scheduleTask_ = function(task, delay) {
3754
- task.time = Date.now() + delay;
3753
+ Interpreter.prototype.scheduleTask_ = function(task, delay2) {
3754
+ task.time = Date.now() + delay2;
3755
3755
  this.tasks.push(task);
3756
3756
  this.tasks.sort(function(a, b) {
3757
3757
  return a.time - b.time;
@@ -4938,10 +4938,10 @@ class JavaScriptTask extends Task3 {
4938
4938
  }
4939
4939
  }
4940
4940
  TaskRegistry4.registerTask(JavaScriptTask);
4941
- var JavaScript = (input2, config = {}) => {
4941
+ var javaScript = (input2, config = {}) => {
4942
4942
  return new JavaScriptTask(input2, config).run();
4943
4943
  };
4944
- Workflow4.prototype.JavaScript = CreateWorkflow4(JavaScriptTask);
4944
+ Workflow4.prototype.javaScript = CreateWorkflow4(JavaScriptTask);
4945
4945
  // src/task/JsonTask.ts
4946
4946
  import {
4947
4947
  createGraphFromDependencyJSON,
@@ -5010,10 +5010,10 @@ class JsonTask extends GraphAsTask {
5010
5010
  }
5011
5011
  }
5012
5012
  TaskRegistry5.registerTask(JsonTask);
5013
- var Json = (input2, config = {}) => {
5013
+ var json = (input2, config = {}) => {
5014
5014
  return new JsonTask(input2, config).run();
5015
5015
  };
5016
- Workflow5.prototype.Json = CreateWorkflow5(JsonTask);
5016
+ Workflow5.prototype.json = CreateWorkflow5(JsonTask);
5017
5017
  // src/task/LambdaTask.ts
5018
5018
  import {
5019
5019
  CreateWorkflow as CreateWorkflow6,
@@ -5081,7 +5081,7 @@ function process(value) {
5081
5081
  return value * 2;
5082
5082
  return value ? "True" : "False";
5083
5083
  }
5084
- function Lambda(input2, config) {
5084
+ function lambda(input2, config) {
5085
5085
  if (typeof input2 === "function") {
5086
5086
  const task2 = new LambdaTask({}, {
5087
5087
  execute: input2
@@ -5091,7 +5091,7 @@ function Lambda(input2, config) {
5091
5091
  const task = new LambdaTask(input2, config);
5092
5092
  return task.run();
5093
5093
  }
5094
- Workflow6.prototype.Lambda = CreateWorkflow6(LambdaTask);
5094
+ Workflow6.prototype.lambda = CreateWorkflow6(LambdaTask);
5095
5095
  // src/task/MergeTask.ts
5096
5096
  import {
5097
5097
  CreateWorkflow as CreateWorkflow7,
@@ -5137,18 +5137,13 @@ class MergeTask extends Task5 {
5137
5137
  }
5138
5138
  }
5139
5139
  TaskRegistry7.registerTask(MergeTask);
5140
- var Merge = (input2, config = {}) => {
5140
+ var merge = (input2, config = {}) => {
5141
5141
  const task = new MergeTask(input2, config);
5142
5142
  return task.run();
5143
5143
  };
5144
- Workflow7.prototype.Merge = CreateWorkflow7(MergeTask);
5144
+ Workflow7.prototype.merge = CreateWorkflow7(MergeTask);
5145
5145
  // src/task/SplitTask.ts
5146
- import {
5147
- CreateWorkflow as CreateWorkflow8,
5148
- Task as Task6,
5149
- TaskRegistry as TaskRegistry8,
5150
- Workflow as Workflow8
5151
- } from "@workglow/task-graph";
5146
+ import { CreateWorkflow as CreateWorkflow8, Task as Task6, TaskRegistry as TaskRegistry8, Workflow as Workflow8 } from "@workglow/task-graph";
5152
5147
  var inputSchema8 = {
5153
5148
  type: "object",
5154
5149
  properties: {
@@ -5170,14 +5165,18 @@ class SplitTask extends Task6 {
5170
5165
  static category = "Utility";
5171
5166
  static title = "Split";
5172
5167
  static description = "Splits an array into individual outputs, creating one output per element";
5173
- static cacheable = true;
5168
+ static hasDynamicSchemas = true;
5169
+ static cacheable = false;
5174
5170
  static inputSchema() {
5175
5171
  return inputSchema8;
5176
5172
  }
5177
5173
  static outputSchema() {
5178
5174
  return outputSchema8;
5179
5175
  }
5180
- async execute(input2, context) {
5176
+ outputSchema() {
5177
+ return outputSchema8;
5178
+ }
5179
+ async executeReactive(input2) {
5181
5180
  const inputValue = input2.input;
5182
5181
  const output = {};
5183
5182
  if (Array.isArray(inputValue)) {
@@ -5191,30 +5190,30 @@ class SplitTask extends Task6 {
5191
5190
  }
5192
5191
  }
5193
5192
  TaskRegistry8.registerTask(SplitTask);
5194
- var Split = (input2, config = {}) => {
5193
+ var split = (input2, config = {}) => {
5195
5194
  const task = new SplitTask(input2, config);
5196
5195
  return task.run();
5197
5196
  };
5198
- Workflow8.prototype.Split = CreateWorkflow8(SplitTask);
5197
+ Workflow8.prototype.split = CreateWorkflow8(SplitTask);
5199
5198
  export {
5199
+ split,
5200
5200
  process,
5201
+ merge,
5202
+ lambda,
5203
+ json,
5204
+ javaScript,
5205
+ fetchUrl,
5206
+ delay,
5207
+ debugLog,
5201
5208
  SplitTask,
5202
- Split,
5203
5209
  MergeTask,
5204
- Merge,
5205
5210
  LambdaTask,
5206
- Lambda,
5207
5211
  JsonTask,
5208
- Json,
5209
5212
  JavaScriptTask,
5210
- JavaScript,
5211
- FetchTask,
5212
- FetchJob,
5213
- Fetch,
5213
+ FetchUrlTask,
5214
+ FetchUrlJob,
5214
5215
  DelayTask,
5215
- Delay,
5216
- DebugLogTask,
5217
- DebugLog
5216
+ DebugLogTask
5218
5217
  };
5219
5218
 
5220
- //# debugId=5B9570B00AF9AE2664756E2164756E21
5219
+ //# debugId=5A48AA5322FF43C164756E2164756E21