@adonis-agora/durable 0.6.1 → 0.8.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 (159) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +1 -1
  3. package/dist/commands/main.d.ts +3 -2
  4. package/dist/commands/main.d.ts.map +1 -1
  5. package/dist/commands/main.js +3 -2
  6. package/dist/commands/main.js.map +1 -1
  7. package/dist/commands/make_workflow.d.ts +4 -3
  8. package/dist/commands/make_workflow.d.ts.map +1 -1
  9. package/dist/commands/make_workflow.js +4 -3
  10. package/dist/commands/make_workflow.js.map +1 -1
  11. package/dist/configure.d.ts +6 -5
  12. package/dist/configure.d.ts.map +1 -1
  13. package/dist/configure.js +9 -6
  14. package/dist/configure.js.map +1 -1
  15. package/dist/providers/dashboard_provider.d.ts +34 -3
  16. package/dist/providers/dashboard_provider.d.ts.map +1 -1
  17. package/dist/providers/dashboard_provider.js +110 -6
  18. package/dist/providers/dashboard_provider.js.map +1 -1
  19. package/dist/providers/durable_provider.d.ts.map +1 -1
  20. package/dist/providers/durable_provider.js +41 -4
  21. package/dist/providers/durable_provider.js.map +1 -1
  22. package/dist/src/base-workflow.d.ts +78 -0
  23. package/dist/src/base-workflow.d.ts.map +1 -0
  24. package/dist/src/base-workflow.js +106 -0
  25. package/dist/src/base-workflow.js.map +1 -0
  26. package/dist/src/codec-state-store.d.ts +13 -0
  27. package/dist/src/codec-state-store.d.ts.map +1 -1
  28. package/dist/src/codec-state-store.js +13 -0
  29. package/dist/src/codec-state-store.js.map +1 -1
  30. package/dist/src/control-flow-signal.d.ts +50 -0
  31. package/dist/src/control-flow-signal.d.ts.map +1 -0
  32. package/dist/src/control-flow-signal.js +54 -0
  33. package/dist/src/control-flow-signal.js.map +1 -0
  34. package/dist/src/control-plane-redis/redis-control-plane.d.ts +57 -5
  35. package/dist/src/control-plane-redis/redis-control-plane.d.ts.map +1 -1
  36. package/dist/src/control-plane-redis/redis-control-plane.js +100 -2
  37. package/dist/src/control-plane-redis/redis-control-plane.js.map +1 -1
  38. package/dist/src/dashboard/auth.d.ts +89 -0
  39. package/dist/src/dashboard/auth.d.ts.map +1 -0
  40. package/dist/src/dashboard/auth.js +113 -0
  41. package/dist/src/dashboard/auth.js.map +1 -0
  42. package/dist/src/dashboard/define_config.d.ts +17 -0
  43. package/dist/src/dashboard/define_config.d.ts.map +1 -1
  44. package/dist/src/dashboard/define_config.js +23 -1
  45. package/dist/src/dashboard/define_config.js.map +1 -1
  46. package/dist/src/dashboard/index.d.ts +6 -1
  47. package/dist/src/dashboard/index.d.ts.map +1 -1
  48. package/dist/src/dashboard/index.js +5 -1
  49. package/dist/src/dashboard/index.js.map +1 -1
  50. package/dist/src/dashboard/login_page.d.ts +23 -0
  51. package/dist/src/dashboard/login_page.d.ts.map +1 -0
  52. package/dist/src/dashboard/login_page.js +170 -0
  53. package/dist/src/dashboard/login_page.js.map +1 -0
  54. package/dist/src/dashboard/session_cookie.d.ts +42 -0
  55. package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
  56. package/dist/src/dashboard/session_cookie.js +97 -0
  57. package/dist/src/dashboard/session_cookie.js.map +1 -0
  58. package/dist/src/define_config.d.ts +11 -2
  59. package/dist/src/define_config.d.ts.map +1 -1
  60. package/dist/src/define_config.js.map +1 -1
  61. package/dist/src/engine.d.ts +91 -3
  62. package/dist/src/engine.d.ts.map +1 -1
  63. package/dist/src/engine.js +331 -44
  64. package/dist/src/engine.js.map +1 -1
  65. package/dist/src/entities.js +2 -2
  66. package/dist/src/entities.js.map +1 -1
  67. package/dist/src/errors.d.ts +6 -1
  68. package/dist/src/errors.d.ts.map +1 -1
  69. package/dist/src/errors.js +7 -2
  70. package/dist/src/errors.js.map +1 -1
  71. package/dist/src/event-accumulators.d.ts +1 -1
  72. package/dist/src/event-accumulators.d.ts.map +1 -1
  73. package/dist/src/events.d.ts +16 -0
  74. package/dist/src/events.d.ts.map +1 -1
  75. package/dist/src/events.js +26 -1
  76. package/dist/src/events.js.map +1 -1
  77. package/dist/src/hooks/steps.d.ts +43 -0
  78. package/dist/src/hooks/steps.d.ts.map +1 -0
  79. package/dist/src/hooks/steps.js +46 -0
  80. package/dist/src/hooks/steps.js.map +1 -0
  81. package/dist/src/hooks/workflows.d.ts +3 -2
  82. package/dist/src/hooks/workflows.d.ts.map +1 -1
  83. package/dist/src/hooks/workflows.js +3 -2
  84. package/dist/src/hooks/workflows.js.map +1 -1
  85. package/dist/src/index.d.ts +8 -2
  86. package/dist/src/index.d.ts.map +1 -1
  87. package/dist/src/index.js +8 -2
  88. package/dist/src/index.js.map +1 -1
  89. package/dist/src/interfaces.d.ts +160 -43
  90. package/dist/src/interfaces.d.ts.map +1 -1
  91. package/dist/src/services/main.d.ts +13 -0
  92. package/dist/src/services/main.d.ts.map +1 -0
  93. package/dist/src/services/main.js +17 -0
  94. package/dist/src/services/main.js.map +1 -0
  95. package/dist/src/step-discovery.d.ts +42 -0
  96. package/dist/src/step-discovery.d.ts.map +1 -0
  97. package/dist/src/step-discovery.js +127 -0
  98. package/dist/src/step-discovery.js.map +1 -0
  99. package/dist/src/step-name-symbol.d.ts +63 -0
  100. package/dist/src/step-name-symbol.d.ts.map +1 -0
  101. package/dist/src/step-name-symbol.js +42 -0
  102. package/dist/src/step-name-symbol.js.map +1 -0
  103. package/dist/src/step-ref.d.ts +70 -0
  104. package/dist/src/step-ref.d.ts.map +1 -0
  105. package/dist/src/step-ref.js +93 -0
  106. package/dist/src/step-ref.js.map +1 -0
  107. package/dist/src/stores/lucid-schema.d.ts +1 -0
  108. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  109. package/dist/src/stores/lucid-schema.js +15 -0
  110. package/dist/src/stores/lucid-schema.js.map +1 -1
  111. package/dist/src/stores/lucid.d.ts +13 -0
  112. package/dist/src/stores/lucid.d.ts.map +1 -1
  113. package/dist/src/stores/lucid.js +43 -0
  114. package/dist/src/stores/lucid.js.map +1 -1
  115. package/dist/src/tenant-group.d.ts +18 -0
  116. package/dist/src/tenant-group.d.ts.map +1 -0
  117. package/dist/src/tenant-group.js +24 -0
  118. package/dist/src/tenant-group.js.map +1 -0
  119. package/dist/src/testing/in-memory-state-store.d.ts +16 -0
  120. package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
  121. package/dist/src/testing/in-memory-state-store.js +29 -0
  122. package/dist/src/testing/in-memory-state-store.js.map +1 -1
  123. package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
  124. package/dist/src/testing-kit/state-store-conformance.js +33 -2
  125. package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
  126. package/dist/src/testing-kit/transport-conformance.d.ts.map +1 -1
  127. package/dist/src/testing-kit/transport-conformance.js +7 -12
  128. package/dist/src/testing-kit/transport-conformance.js.map +1 -1
  129. package/dist/src/transports/db.d.ts +14 -5
  130. package/dist/src/transports/db.d.ts.map +1 -1
  131. package/dist/src/transports/db.js +20 -15
  132. package/dist/src/transports/db.js.map +1 -1
  133. package/dist/src/transports/queue.d.ts +15 -5
  134. package/dist/src/transports/queue.d.ts.map +1 -1
  135. package/dist/src/transports/queue.js +19 -17
  136. package/dist/src/transports/queue.js.map +1 -1
  137. package/dist/src/workflow-als.d.ts +21 -0
  138. package/dist/src/workflow-als.d.ts.map +1 -0
  139. package/dist/src/workflow-als.js +22 -0
  140. package/dist/src/workflow-als.js.map +1 -0
  141. package/dist/src/workflow-ctx.d.ts +27 -8
  142. package/dist/src/workflow-ctx.d.ts.map +1 -1
  143. package/dist/src/workflow-ctx.js +183 -19
  144. package/dist/src/workflow-ctx.js.map +1 -1
  145. package/dist/src/workflow-discovery.d.ts +21 -15
  146. package/dist/src/workflow-discovery.d.ts.map +1 -1
  147. package/dist/src/workflow-discovery.js +17 -13
  148. package/dist/src/workflow-discovery.js.map +1 -1
  149. package/dist/src/workflow-ref.d.ts +9 -27
  150. package/dist/src/workflow-ref.d.ts.map +1 -1
  151. package/dist/src/workflow-ref.js +12 -34
  152. package/dist/src/workflow-ref.js.map +1 -1
  153. package/dist/stubs/database/migrations/create_durable_tables.stub +13 -1
  154. package/dist/stubs/make/workflow/main.stub +5 -4
  155. package/package.json +11 -1
  156. package/dist/src/remote-step-factory.d.ts +0 -15
  157. package/dist/src/remote-step-factory.d.ts.map +0 -1
  158. package/dist/src/remote-step-factory.js +0 -12
  159. package/dist/src/remote-step-factory.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAAmD,CAAC;AAE3F,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,+FAA+F;AAC/F,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,IACvC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK;IAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAA;CAAE,EAC7F,QAAQ,CAAC,KACR,CAAC,CASL;AAED,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAGtE;AAED,sGAAsG;AACtG,MAAM,MAAM,aAAa,CAAC,MAAM,GAAG,OAAO,E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GAAG,MAAM,CASrD"}
@@ -6,53 +6,31 @@
6
6
  * string stays available for the cross-runtime case.
7
7
  */
8
8
  /**
9
- * The symbol the `@Workflow` decorator stamps the full options onto (name + version + tags …), so
10
- * auto-discovery can register the class against the engine and a class ref can be resolved back to
11
- * its name via {@link workflowName}. A global-registry symbol (`Symbol.for`) so it survives duplicate
12
- * copies of this package in a dependency tree.
9
+ * Read a class's {@link WorkflowMeta} its name/version/tags/… from its `static workflow =
10
+ * { name, version, }` config (the {@link BaseWorkflow} authoring form). Any absent `version` is
11
+ * normalized to `'1'`. Returns `undefined` for a class carrying no valid config (a class with no
12
+ * `static workflow`, or one whose `name` is not a string, is not a registrable workflow).
13
13
  */
14
- export const WORKFLOW_META_KEY = Symbol.for('@agora/durable:workflow-meta');
15
- /**
16
- * Class decorator marking a class as a durable workflow. Stamps the full options (name + version +
17
- * tags …) so a class ref resolves via {@link workflowName} and the provider's `app/workflows`
18
- * auto-discovery can register it on the engine — no manual `engine.register(...)`. The class must
19
- * expose `run(ctx, input)`; that method becomes the workflow body.
20
- *
21
- * ```ts
22
- * @Workflow({ name: 'order', version: '1' })
23
- * export default class OrderWorkflow {
24
- * async run(ctx: WorkflowCtx, input: { id: string }) { ... }
25
- * }
26
- * ```
27
- */
28
- export function Workflow(options) {
29
- return (target) => {
30
- const meta = { ...options, version: options.version ?? '1' };
31
- Object.defineProperty(target, WORKFLOW_META_KEY, {
32
- value: meta,
33
- enumerable: false,
34
- configurable: true,
35
- });
36
- return target;
37
- };
38
- }
39
- /** Read the {@link WorkflowMeta} a `@Workflow` decorator stamped on a class, or `undefined`. */
40
14
  export function workflowMeta(target) {
41
15
  if (typeof target !== 'function')
42
16
  return undefined;
43
- return target[WORKFLOW_META_KEY];
17
+ const config = target.workflow;
18
+ if (config && typeof config === 'object' && typeof config.name === 'string') {
19
+ return { ...config, version: config.version ?? '1' };
20
+ }
21
+ return undefined;
44
22
  }
45
23
  /**
46
24
  * Resolve a {@link WorkflowRef} to its registered workflow name: a string is returned as-is; a
47
- * `@Workflow` class is resolved via the name the decorator stamped in its metadata. Throws if a
48
- * class was never decorated (so it carries no registered name).
25
+ * workflow class is resolved via the name on its `static workflow` config. Throws if a class carries
26
+ * no `static workflow` config (so it has no registered name).
49
27
  */
50
28
  export function workflowName(ref) {
51
29
  if (typeof ref === 'string')
52
30
  return ref;
53
31
  const name = workflowMeta(ref)?.name;
54
32
  if (!name) {
55
- throw new Error(`workflow class ${ref.name} has no registered name — is it decorated with @Workflow({ name })?`);
33
+ throw new Error(`workflow class ${ref.name} has no registered name — does it declare \`static workflow = { name }\`?`);
56
34
  }
57
35
  return name;
58
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAqB3F;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,OAAO,CACL,MAAS,EACN,EAAE;QACL,MAAM,IAAI,GAAiB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QAC3E,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,iBAAiB,EAAE;YAC/C,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACnD,OAAQ,MAAiD,CAAC,iBAAiB,CAAC,CAAC;AAC/E,CAAC;AAgCD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,kBAAkB,GAAG,CAAC,IAAI,qEAAqE,CAChG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,MAAM,GAAI,MAAyC,CAAC,QAAQ,CAAC;IACnE,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5E,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAgCD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,kBAAkB,GAAG,CAAC,IAAI,2EAA2E,CACtG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -5,7 +5,7 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
5
5
 
6
6
  /**
7
7
  * Durable workflow tables for the @adonis-agora/durable `lucid` state store: runs, step checkpoints, the
8
- * search-attribute side-table, signal waiters and buffered signals. JSON payloads are stored as TEXT (the store
8
+ * search-attribute side-table, signal waiters, buffered signals and buffered events. JSON payloads are stored as TEXT (the store
9
9
  * (de)serializes them) and timestamps as epoch-ms integers, so the schema is portable across
10
10
  * SQLite / Postgres / MySQL.
11
11
  */
@@ -79,9 +79,21 @@ export default class extends BaseSchema {
79
79
  table.text('payload')
80
80
  table.index(['token'], 'durable_buffered_signals_token_idx')
81
81
  })
82
+
83
+ // Reliable (buffered) events: a publish matching no live waiter keeps ONE copy here, consumed by
84
+ // the first future matching `waitForEvent`. Keyed by `name` (many waiters share a name with
85
+ // different `match`); `id` is the caller-minted PK; `published_at` is epoch-ms.
86
+ this.schema.createTable('durable_buffered_events', (table) => {
87
+ table.string('id').primary()
88
+ table.string('name').notNullable()
89
+ table.text('payload')
90
+ table.bigInteger('published_at').notNullable()
91
+ table.index(['name', 'published_at'], 'durable_buffered_events_name_idx')
92
+ })
82
93
  }
83
94
 
84
95
  async down() {
96
+ this.schema.dropTableIfExists('durable_buffered_events')
85
97
  this.schema.dropTableIfExists('durable_buffered_signals')
86
98
  this.schema.dropTableIfExists('durable_signal_waiters')
87
99
  this.schema.dropTableIfExists('durable_run_attributes')
@@ -6,17 +6,18 @@
6
6
  to: app.makePath('app/workflows', entity.path, workflowFileName + '.ts')
7
7
  })
8
8
  }}}
9
- import { Workflow } from '@adonis-agora/durable'
9
+ import { BaseWorkflow } from '@adonis-agora/durable'
10
10
  import type { WorkflowCtx } from '@adonis-agora/durable'
11
11
 
12
12
  interface {{ workflowName }}Input {
13
13
  // Define your workflow input here
14
14
  }
15
15
 
16
- @Workflow({ name: '{{ registeredName }}', version: '1' })
17
- export default class {{ workflowName }}Workflow {
16
+ export default class {{ workflowName }}Workflow extends BaseWorkflow {
17
+ static workflow = { name: '{{ registeredName }}', version: '1' }
18
+
18
19
  async run(ctx: WorkflowCtx, input: {{ workflowName }}Input) {
19
- // Your workflow logic here — compose ctx.step / ctx.call / ctx.child / ctx.sleep …
20
+ // Your workflow logic here — compose ctx.step / ctx.localStep / ctx.child / ctx.sleep …
20
21
  return input
21
22
  }
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis-agora/durable",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Durable cross-app workflows for AdonisJS — deterministic replay engine, AdonisJS binding, ace commands, dashboard, OpenTelemetry, Telescope, testing harness and Redis admission, all in one package. Part of the Agora ecosystem.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,11 @@
18
18
  "import": "./dist/src/index.js",
19
19
  "default": "./dist/src/index.js"
20
20
  },
21
+ "./services/main": {
22
+ "types": "./dist/src/services/main.d.ts",
23
+ "import": "./dist/src/services/main.js",
24
+ "default": "./dist/src/services/main.js"
25
+ },
21
26
  "./durable_provider": {
22
27
  "types": "./dist/providers/durable_provider.d.ts",
23
28
  "import": "./dist/providers/durable_provider.js",
@@ -58,6 +63,11 @@
58
63
  "import": "./dist/src/hooks/workflows.js",
59
64
  "default": "./dist/src/hooks/workflows.js"
60
65
  },
66
+ "./hooks/steps": {
67
+ "types": "./dist/src/hooks/steps.d.ts",
68
+ "import": "./dist/src/hooks/steps.js",
69
+ "default": "./dist/src/hooks/steps.js"
70
+ },
61
71
  "./admission-redis": {
62
72
  "types": "./dist/src/admission-redis/index.d.ts",
63
73
  "import": "./dist/src/admission-redis/index.js",
@@ -1,15 +0,0 @@
1
- import type { z } from 'zod';
2
- import type { RemoteStepDef, StepOptions } from './interfaces.js';
3
- export interface RemoteStepConfig<TInput, TOutput> extends StepOptions {
4
- name: string;
5
- /** Worker group expected to handle this step. Defaults to the `name` prefix before the first dot. */
6
- group?: string;
7
- input: z.ZodType<TInput>;
8
- output: z.ZodType<TOutput>;
9
- }
10
- /**
11
- * Defines a typed handle to a step that runs on a remote worker. Call it from a workflow with
12
- * `ctx.call(step, input)`; a worker registers a handler under the same `name`.
13
- */
14
- export declare function remoteStep<TInput, TOutput>(config: RemoteStepConfig<TInput, TOutput>): RemoteStepDef<TInput, TOutput>;
15
- //# sourceMappingURL=remote-step-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-step-factory.d.ts","sourceRoot":"","sources":["../../src/remote-step-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,WAAW,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAE,SAAQ,WAAW;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,qGAAqG;IACrG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EACxC,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAMhC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Defines a typed handle to a step that runs on a remote worker. Call it from a workflow with
3
- * `ctx.call(step, input)`; a worker registers a handler under the same `name`.
4
- */
5
- export function remoteStep(config) {
6
- return {
7
- ...config,
8
- group: config.group ?? config.name.split('.')[0] ?? config.name,
9
- __remote: true,
10
- };
11
- }
12
- //# sourceMappingURL=remote-step-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-step-factory.js","sourceRoot":"","sources":["../../src/remote-step-factory.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,MAAyC;IAEzC,OAAO;QACL,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI;QAC/D,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC"}