@hotmeshio/hotmesh 0.10.1 → 0.11.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 (49) hide show
  1. package/README.md +1 -1
  2. package/build/modules/errors.d.ts +2 -0
  3. package/build/modules/errors.js +2 -0
  4. package/build/modules/key.js +3 -2
  5. package/build/package.json +3 -1
  6. package/build/services/activities/worker.js +10 -0
  7. package/build/services/dba/index.d.ts +54 -19
  8. package/build/services/dba/index.js +129 -31
  9. package/build/services/durable/client.js +6 -1
  10. package/build/services/durable/exporter.d.ts +75 -3
  11. package/build/services/durable/exporter.js +768 -2
  12. package/build/services/durable/handle.d.ts +12 -1
  13. package/build/services/durable/handle.js +13 -0
  14. package/build/services/durable/schemas/factory.d.ts +1 -1
  15. package/build/services/durable/schemas/factory.js +27 -4
  16. package/build/services/durable/worker.d.ts +2 -2
  17. package/build/services/durable/worker.js +15 -9
  18. package/build/services/durable/workflow/context.js +2 -0
  19. package/build/services/durable/workflow/execChild.js +5 -2
  20. package/build/services/durable/workflow/hook.js +6 -0
  21. package/build/services/durable/workflow/proxyActivities.js +3 -4
  22. package/build/services/engine/index.js +5 -3
  23. package/build/services/store/index.d.ts +40 -0
  24. package/build/services/store/providers/postgres/exporter-sql.d.ts +23 -0
  25. package/build/services/store/providers/postgres/exporter-sql.js +52 -0
  26. package/build/services/store/providers/postgres/kvtables.js +12 -1
  27. package/build/services/store/providers/postgres/postgres.d.ts +34 -0
  28. package/build/services/store/providers/postgres/postgres.js +99 -0
  29. package/build/services/stream/providers/postgres/kvtables.d.ts +1 -1
  30. package/build/services/stream/providers/postgres/kvtables.js +175 -82
  31. package/build/services/stream/providers/postgres/lifecycle.d.ts +4 -3
  32. package/build/services/stream/providers/postgres/lifecycle.js +6 -5
  33. package/build/services/stream/providers/postgres/messages.d.ts +9 -6
  34. package/build/services/stream/providers/postgres/messages.js +121 -75
  35. package/build/services/stream/providers/postgres/notifications.d.ts +5 -2
  36. package/build/services/stream/providers/postgres/notifications.js +39 -35
  37. package/build/services/stream/providers/postgres/postgres.d.ts +20 -118
  38. package/build/services/stream/providers/postgres/postgres.js +83 -140
  39. package/build/services/stream/registry.d.ts +62 -0
  40. package/build/services/stream/registry.js +198 -0
  41. package/build/services/worker/index.js +20 -6
  42. package/build/types/dba.d.ts +31 -5
  43. package/build/types/durable.d.ts +6 -1
  44. package/build/types/error.d.ts +2 -0
  45. package/build/types/exporter.d.ts +166 -0
  46. package/build/types/hotmesh.d.ts +7 -1
  47. package/build/types/index.d.ts +1 -1
  48. package/build/types/stream.d.ts +2 -0
  49. package/package.json +3 -1
@@ -1,8 +1,46 @@
1
1
  import { ILogger } from '../logger';
2
2
  import { StoreService } from '../store';
3
- import { ExportOptions, DurableJobExport, TimelineType, TransitionType, ExportFields } from '../../types/exporter';
3
+ import { ExportOptions, DurableJobExport, TimelineType, TransitionType, ExportFields, ExecutionExportOptions, WorkflowExecution, WorkflowExecutionStatus } from '../../types/exporter';
4
4
  import { ProviderClient, ProviderTransaction } from '../../types/provider';
5
5
  import { StringStringType, Symbols } from '../../types/serializer';
6
+ /**
7
+ * Parse a HotMesh compact timestamp (YYYYMMDDHHmmss.mmm) into ISO 8601.
8
+ * Also accepts ISO 8601 strings directly.
9
+ */
10
+ declare function parseTimestamp(raw: string | undefined | null): string | null;
11
+ /**
12
+ * Compute duration in milliseconds between two HotMesh timestamps.
13
+ */
14
+ declare function computeDuration(ac: string | undefined, au: string | undefined): number | null;
15
+ /**
16
+ * Extract the operation type (proxy, child, start, wait, sleep, hook)
17
+ * from a timeline key like `-proxy,0,0-1-`.
18
+ */
19
+ declare function extractOperation(key: string): string;
20
+ /**
21
+ * Extract the activity name from a timeline entry value's job_id.
22
+ *
23
+ * Job ID format: `-{workflowId}-$${activityName}{dimension}-{execIndex}`
24
+ * Examples:
25
+ * `-wfId-$analyzeContent-5` → `'analyzeContent'`
26
+ * `-wfId-$processOrder,0,0-3` → `'processOrder'`
27
+ */
28
+ declare function extractActivityName(value: Record<string, any> | null): string;
29
+ /**
30
+ * Check if an activity name is a system (interceptor) operation.
31
+ */
32
+ declare function isSystemActivity(name: string): boolean;
33
+ /**
34
+ * Map HotMesh job state to a human-readable execution status.
35
+ *
36
+ * HotMesh semaphore: `0` = idle, `> 0` = pending activities,
37
+ * `< 0` = failed / interrupted.
38
+ *
39
+ * A workflow can be "done" (`state.data.done === true`) while the
40
+ * semaphore is still > 0 (cleanup activities pending). We check
41
+ * both the `done` flag and the semaphore to determine status.
42
+ */
43
+ declare function mapStatus(rawStatus: number | undefined, isDone?: boolean, hasError?: boolean): WorkflowExecutionStatus;
6
44
  declare class ExporterService {
7
45
  appId: string;
8
46
  logger: ILogger;
@@ -11,10 +49,44 @@ declare class ExporterService {
11
49
  private static symbols;
12
50
  constructor(appId: string, store: StoreService<ProviderClient, ProviderTransaction>, logger: ILogger);
13
51
  /**
14
- * Convert the job hash from its compiles format into a DurableJobExport object with
52
+ * Convert the job hash from its compiled format into a DurableJobExport object with
15
53
  * facets that describe the workflow in terms relevant to narrative storytelling.
16
54
  */
17
55
  export(jobId: string, options?: ExportOptions): Promise<DurableJobExport>;
56
+ /**
57
+ * Export a workflow execution as a Temporal-compatible event history.
58
+ *
59
+ * **Sparse mode** (default): transforms the main workflow's timeline
60
+ * into a flat event list. No additional I/O beyond the initial export.
61
+ *
62
+ * **Verbose mode**: recursively fetches child workflow jobs and attaches
63
+ * their executions as nested `children`.
64
+ */
65
+ exportExecution(jobId: string, workflowTopic: string, options?: ExecutionExportOptions): Promise<WorkflowExecution>;
66
+ /**
67
+ * Reconstruct a WorkflowExecution from raw database rows when the job
68
+ * handle has expired or been pruned. Only available if the store provider
69
+ * implements getJobByKeyDirect.
70
+ */
71
+ private exportExecutionDirect;
72
+ /**
73
+ * Enrich execution events with activity and child workflow inputs.
74
+ * Queries the store for activity arguments and child workflow arguments.
75
+ */
76
+ private enrichExecutionInputs;
77
+ /**
78
+ * Resolve a symbol field from stable JSON path using the symbol registry.
79
+ */
80
+ private resolveSymbolField;
81
+ /**
82
+ * Pure transformation: convert a raw DurableJobExport into a
83
+ * Temporal-compatible WorkflowExecution event history.
84
+ */
85
+ transformToExecution(raw: DurableJobExport, workflowId: string, workflowTopic: string, options: ExecutionExportOptions): WorkflowExecution;
86
+ /**
87
+ * Recursively fetch child workflow executions for verbose mode.
88
+ */
89
+ private fetchChildren;
18
90
  /**
19
91
  * Inflates the job data into a DurableJobExport object
20
92
  * @param jobHash - the job data
@@ -48,4 +120,4 @@ declare class ExporterService {
48
120
  */
49
121
  sortParts(parts: TimelineType[]): TimelineType[];
50
122
  }
51
- export { ExporterService };
123
+ export { ExporterService, parseTimestamp, computeDuration, extractOperation, extractActivityName, isSystemActivity, mapStatus, };