awaitly 2.0.0 → 3.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 (88) hide show
  1. package/dist/di-Biw_plBn.d.cts +15 -0
  2. package/dist/di-DxyH2N3i.d.ts +15 -0
  3. package/dist/durable.cjs +4670 -0
  4. package/dist/durable.cjs.map +1 -0
  5. package/dist/durable.d.cts +9 -0
  6. package/dist/durable.d.ts +9 -0
  7. package/dist/durable.js +4610 -0
  8. package/dist/durable.js.map +1 -0
  9. package/dist/{di-BbFFfO8y.d.ts → duration-BjVn3QpB.d.cts} +1 -15
  10. package/dist/{di-BDlT7InM.d.cts → duration-BjVn3QpB.d.ts} +1 -15
  11. package/dist/engine.cjs +4501 -0
  12. package/dist/engine.cjs.map +1 -0
  13. package/dist/engine.d.cts +113 -0
  14. package/dist/engine.d.ts +113 -0
  15. package/dist/engine.js +4474 -0
  16. package/dist/engine.js.map +1 -0
  17. package/dist/{errors-DtXvrCiO.d.cts → errors-sDSeaZBO.d.cts} +1 -1
  18. package/dist/{errors-DtXvrCiO.d.ts → errors-sDSeaZBO.d.ts} +1 -1
  19. package/dist/guards-CwQZro1F.d.ts +72 -0
  20. package/dist/guards-DhhOJZda.d.cts +72 -0
  21. package/dist/hitl-BnnnLzh2.d.cts +468 -0
  22. package/dist/hitl-pYfkQMv_.d.ts +468 -0
  23. package/dist/hitl.cjs +646 -0
  24. package/dist/hitl.cjs.map +1 -0
  25. package/dist/hitl.d.cts +440 -0
  26. package/dist/hitl.d.ts +440 -0
  27. package/dist/hitl.js +605 -0
  28. package/dist/hitl.js.map +1 -0
  29. package/dist/index-Bew12SZ8.d.ts +417 -0
  30. package/dist/index-Bwt-iz50.d.cts +417 -0
  31. package/dist/{types-B8NfNRGX.d.ts → index-Cv4K_3sZ.d.ts} +2 -1162
  32. package/dist/{types-BZ2f4MRR.d.cts → index-ICmfQi08.d.cts} +2 -1162
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +11 -1527
  35. package/dist/index.d.ts +11 -1527
  36. package/dist/persistence.cjs +552 -0
  37. package/dist/persistence.cjs.map +1 -0
  38. package/dist/persistence.d.cts +254 -0
  39. package/dist/persistence.d.ts +254 -0
  40. package/dist/persistence.js +499 -0
  41. package/dist/persistence.js.map +1 -0
  42. package/dist/reliability.cjs +1651 -0
  43. package/dist/reliability.cjs.map +1 -0
  44. package/dist/reliability.d.cts +1442 -0
  45. package/dist/reliability.d.ts +1442 -0
  46. package/dist/reliability.js +1589 -0
  47. package/dist/reliability.js.map +1 -0
  48. package/dist/result.d.cts +1 -1
  49. package/dist/result.d.ts +1 -1
  50. package/dist/run.cjs +2283 -0
  51. package/dist/run.cjs.map +1 -0
  52. package/dist/run.d.cts +90 -0
  53. package/dist/run.d.ts +90 -0
  54. package/dist/run.js +2247 -0
  55. package/dist/run.js.map +1 -0
  56. package/dist/saga.cjs +3699 -0
  57. package/dist/saga.cjs.map +1 -0
  58. package/dist/saga.d.cts +162 -0
  59. package/dist/saga.d.ts +162 -0
  60. package/dist/saga.js +3670 -0
  61. package/dist/saga.js.map +1 -0
  62. package/dist/store-contract-BI98VYmX.d.ts +66 -0
  63. package/dist/store-contract-C2HyR_o6.d.cts +66 -0
  64. package/dist/streaming.cjs +895 -0
  65. package/dist/streaming.cjs.map +1 -0
  66. package/dist/streaming.d.cts +594 -0
  67. package/dist/streaming.d.ts +594 -0
  68. package/dist/streaming.js +832 -0
  69. package/dist/streaming.js.map +1 -0
  70. package/dist/testing.d.cts +4 -2
  71. package/dist/testing.d.ts +4 -2
  72. package/dist/types-BDTxgKKc.d.ts +845 -0
  73. package/dist/types-C9Y71dua.d.cts +845 -0
  74. package/dist/types-d8q8iQlk.d.cts +323 -0
  75. package/dist/types-sObbY4mX.d.ts +323 -0
  76. package/dist/webhook.cjs +461 -0
  77. package/dist/webhook.cjs.map +1 -0
  78. package/dist/webhook.d.cts +497 -0
  79. package/dist/webhook.d.ts +497 -0
  80. package/dist/webhook.js +422 -0
  81. package/dist/webhook.js.map +1 -0
  82. package/dist/workflow.cjs +2 -2614
  83. package/dist/workflow.cjs.map +1 -1
  84. package/dist/workflow.d.cts +12 -3023
  85. package/dist/workflow.d.ts +12 -3023
  86. package/dist/workflow.js +2 -2535
  87. package/dist/workflow.js.map +1 -1
  88. package/package.json +46 -1
@@ -0,0 +1,66 @@
1
+ import { h as StepResult, R as ResumeState, b as WorkflowSnapshot } from './types-BDTxgKKc.js';
2
+
3
+ /**
4
+ * Serialization for ResumeState to/from JSON-safe format.
5
+ * Centralizes Map serialization so adapters don't re-implement it.
6
+ */
7
+
8
+ /**
9
+ * JSON-serializable resume state. Use this shape when persisting to storage.
10
+ * Discriminator `kind: "ResumeState"` enables adapters and migrations to detect format.
11
+ */
12
+ type SerializedResumeState = {
13
+ kind: "ResumeState";
14
+ steps: [string, StepResult][];
15
+ };
16
+ /**
17
+ * Serialize resume state to a JSON-safe object. Preserves step order (array).
18
+ * Use with JSON.stringify for storage; adapters can rely on this shape.
19
+ *
20
+ * @example
21
+ * const serialized = serializeResumeState(collector.getResumeState());
22
+ * await store.save(id, JSON.stringify(serialized));
23
+ */
24
+ declare function serializeResumeState(state: ResumeState): SerializedResumeState;
25
+ /**
26
+ * Type guard for SerializedResumeState. Use when loading from storage to discriminate from WorkflowSnapshot.
27
+ */
28
+ declare function isSerializedResumeState(x: unknown): x is SerializedResumeState;
29
+ /**
30
+ * Deserialize from JSON-parsed object back to ResumeState (runtime Map).
31
+ *
32
+ * @example
33
+ * const parsed = JSON.parse(await store.load(id));
34
+ * if (isSerializedResumeState(parsed)) {
35
+ * const state = deserializeResumeState(parsed);
36
+ * await workflow.run(fn, { resumeState: state });
37
+ * }
38
+ */
39
+ declare function deserializeResumeState(raw: SerializedResumeState): ResumeState;
40
+
41
+ /**
42
+ * Extended persistence contract: save/load accept both WorkflowSnapshot and ResumeState.
43
+ * Use type guards (isWorkflowSnapshot, isResumeState, isSerializedResumeState) in adapters.
44
+ * Core persistence.SnapshotStore stays narrow; this module defines the broad contract and helpers.
45
+ */
46
+
47
+ /** What stores persist (JSON/database shape). Use for type discrimination in adapters. */
48
+ type PersistedWorkflowState = WorkflowSnapshot | SerializedResumeState;
49
+ /** What save() can accept: snapshot or runtime resume state. Adapters branch with type guards. */
50
+ type StoreSaveInput = WorkflowSnapshot | ResumeState;
51
+ /** What load() can return. Use toResumeState() or loadResumeState for type-safe restore. */
52
+ type StoreLoadResult = WorkflowSnapshot | ResumeState | null;
53
+ /**
54
+ * Convert a loaded value to ResumeState for workflow.run(fn, { resumeState }).
55
+ * - If loaded is already ResumeState, returns it.
56
+ * - If loaded is null or WorkflowSnapshot, returns undefined (use run(fn, { snapshot }) for snapshots).
57
+ * Two explicit flows: resume from ResumeState vs resume from snapshot; don't pass snapshot to resumeState.
58
+ *
59
+ * @example
60
+ * const loaded = await store.load('wf-123');
61
+ * const resumeState = toResumeState(loaded);
62
+ * if (resumeState) await workflow.run(fn, { resumeState });
63
+ */
64
+ declare function toResumeState(loaded: StoreLoadResult): ResumeState | undefined;
65
+
66
+ export { type PersistedWorkflowState as P, type SerializedResumeState as S, type StoreLoadResult as a, type StoreSaveInput as b, deserializeResumeState as d, isSerializedResumeState as i, serializeResumeState as s, toResumeState as t };
@@ -0,0 +1,66 @@
1
+ import { h as StepResult, R as ResumeState, b as WorkflowSnapshot } from './types-C9Y71dua.cjs';
2
+
3
+ /**
4
+ * Serialization for ResumeState to/from JSON-safe format.
5
+ * Centralizes Map serialization so adapters don't re-implement it.
6
+ */
7
+
8
+ /**
9
+ * JSON-serializable resume state. Use this shape when persisting to storage.
10
+ * Discriminator `kind: "ResumeState"` enables adapters and migrations to detect format.
11
+ */
12
+ type SerializedResumeState = {
13
+ kind: "ResumeState";
14
+ steps: [string, StepResult][];
15
+ };
16
+ /**
17
+ * Serialize resume state to a JSON-safe object. Preserves step order (array).
18
+ * Use with JSON.stringify for storage; adapters can rely on this shape.
19
+ *
20
+ * @example
21
+ * const serialized = serializeResumeState(collector.getResumeState());
22
+ * await store.save(id, JSON.stringify(serialized));
23
+ */
24
+ declare function serializeResumeState(state: ResumeState): SerializedResumeState;
25
+ /**
26
+ * Type guard for SerializedResumeState. Use when loading from storage to discriminate from WorkflowSnapshot.
27
+ */
28
+ declare function isSerializedResumeState(x: unknown): x is SerializedResumeState;
29
+ /**
30
+ * Deserialize from JSON-parsed object back to ResumeState (runtime Map).
31
+ *
32
+ * @example
33
+ * const parsed = JSON.parse(await store.load(id));
34
+ * if (isSerializedResumeState(parsed)) {
35
+ * const state = deserializeResumeState(parsed);
36
+ * await workflow.run(fn, { resumeState: state });
37
+ * }
38
+ */
39
+ declare function deserializeResumeState(raw: SerializedResumeState): ResumeState;
40
+
41
+ /**
42
+ * Extended persistence contract: save/load accept both WorkflowSnapshot and ResumeState.
43
+ * Use type guards (isWorkflowSnapshot, isResumeState, isSerializedResumeState) in adapters.
44
+ * Core persistence.SnapshotStore stays narrow; this module defines the broad contract and helpers.
45
+ */
46
+
47
+ /** What stores persist (JSON/database shape). Use for type discrimination in adapters. */
48
+ type PersistedWorkflowState = WorkflowSnapshot | SerializedResumeState;
49
+ /** What save() can accept: snapshot or runtime resume state. Adapters branch with type guards. */
50
+ type StoreSaveInput = WorkflowSnapshot | ResumeState;
51
+ /** What load() can return. Use toResumeState() or loadResumeState for type-safe restore. */
52
+ type StoreLoadResult = WorkflowSnapshot | ResumeState | null;
53
+ /**
54
+ * Convert a loaded value to ResumeState for workflow.run(fn, { resumeState }).
55
+ * - If loaded is already ResumeState, returns it.
56
+ * - If loaded is null or WorkflowSnapshot, returns undefined (use run(fn, { snapshot }) for snapshots).
57
+ * Two explicit flows: resume from ResumeState vs resume from snapshot; don't pass snapshot to resumeState.
58
+ *
59
+ * @example
60
+ * const loaded = await store.load('wf-123');
61
+ * const resumeState = toResumeState(loaded);
62
+ * if (resumeState) await workflow.run(fn, { resumeState });
63
+ */
64
+ declare function toResumeState(loaded: StoreLoadResult): ResumeState | undefined;
65
+
66
+ export { type PersistedWorkflowState as P, type SerializedResumeState as S, type StoreLoadResult as a, type StoreSaveInput as b, deserializeResumeState as d, isSerializedResumeState as i, serializeResumeState as s, toResumeState as t };