@hotmeshio/hotmesh 0.12.1 → 0.14.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 (202) hide show
  1. package/README.md +18 -22
  2. package/build/modules/enums.d.ts +60 -5
  3. package/build/modules/enums.js +62 -7
  4. package/build/modules/errors.d.ts +15 -2
  5. package/build/modules/errors.js +17 -1
  6. package/build/modules/storage.d.ts +1 -0
  7. package/build/modules/storage.js +2 -1
  8. package/build/package.json +8 -2
  9. package/build/services/activities/activity/context.d.ts +22 -0
  10. package/build/services/activities/activity/context.js +76 -0
  11. package/build/services/activities/activity/index.d.ts +116 -0
  12. package/build/services/activities/activity/index.js +299 -0
  13. package/build/services/activities/activity/mapping.d.ts +12 -0
  14. package/build/services/activities/activity/mapping.js +63 -0
  15. package/build/services/activities/activity/process.d.ts +28 -0
  16. package/build/services/activities/activity/process.js +100 -0
  17. package/build/services/activities/activity/protocol.d.ts +39 -0
  18. package/build/services/activities/activity/protocol.js +151 -0
  19. package/build/services/activities/activity/state.d.ts +40 -0
  20. package/build/services/activities/activity/state.js +143 -0
  21. package/build/services/activities/activity/transition.d.ts +23 -0
  22. package/build/services/activities/activity/transition.js +71 -0
  23. package/build/services/activities/activity/verify.d.ts +22 -0
  24. package/build/services/activities/activity/verify.js +85 -0
  25. package/build/services/activities/await.d.ts +1 -4
  26. package/build/services/activities/await.js +2 -36
  27. package/build/services/activities/cycle.d.ts +1 -11
  28. package/build/services/activities/cycle.js +3 -46
  29. package/build/services/activities/hook.d.ts +2 -11
  30. package/build/services/activities/hook.js +30 -50
  31. package/build/services/activities/interrupt.d.ts +2 -4
  32. package/build/services/activities/interrupt.js +4 -38
  33. package/build/services/activities/signal.d.ts +1 -11
  34. package/build/services/activities/signal.js +3 -48
  35. package/build/services/activities/trigger.d.ts +1 -3
  36. package/build/services/activities/trigger.js +0 -3
  37. package/build/services/activities/worker.d.ts +3 -6
  38. package/build/services/activities/worker.js +4 -40
  39. package/build/services/connector/factory.d.ts +6 -0
  40. package/build/services/connector/factory.js +24 -0
  41. package/build/services/dba/index.d.ts +14 -4
  42. package/build/services/dba/index.js +57 -18
  43. package/build/services/durable/activity.d.ts +30 -0
  44. package/build/services/durable/activity.js +46 -0
  45. package/build/services/durable/client.d.ts +26 -31
  46. package/build/services/durable/client.js +26 -31
  47. package/build/services/durable/connection.d.ts +13 -7
  48. package/build/services/durable/connection.js +13 -7
  49. package/build/services/durable/exporter.d.ts +2 -2
  50. package/build/services/durable/exporter.js +27 -12
  51. package/build/services/durable/handle.d.ts +59 -41
  52. package/build/services/durable/handle.js +61 -41
  53. package/build/services/durable/index.d.ts +152 -283
  54. package/build/services/durable/index.js +161 -289
  55. package/build/services/durable/interceptor.d.ts +43 -33
  56. package/build/services/durable/interceptor.js +59 -39
  57. package/build/services/durable/schemas/factory.d.ts +2 -3
  58. package/build/services/durable/schemas/factory.js +180 -30
  59. package/build/services/durable/telemetry.d.ts +80 -0
  60. package/build/services/durable/telemetry.js +137 -0
  61. package/build/services/durable/worker.d.ts +100 -21
  62. package/build/services/durable/worker.js +314 -60
  63. package/build/services/durable/workflow/all.d.ts +1 -1
  64. package/build/services/durable/workflow/all.js +1 -1
  65. package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
  66. package/build/services/durable/workflow/cancellationScope.js +139 -0
  67. package/build/services/durable/workflow/common.d.ts +5 -4
  68. package/build/services/durable/workflow/common.js +6 -1
  69. package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
  70. package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
  71. package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
  72. package/build/services/durable/workflow/continueAsNew.js +92 -0
  73. package/build/services/durable/workflow/didRun.d.ts +2 -2
  74. package/build/services/durable/workflow/didRun.js +4 -4
  75. package/build/services/durable/workflow/enrich.d.ts +5 -0
  76. package/build/services/durable/workflow/enrich.js +5 -0
  77. package/build/services/durable/workflow/entityMethods.d.ts +7 -0
  78. package/build/services/durable/workflow/entityMethods.js +7 -0
  79. package/build/services/durable/workflow/execHook.js +3 -3
  80. package/build/services/durable/workflow/execHookBatch.js +2 -2
  81. package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
  82. package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
  83. package/build/services/durable/workflow/hook.d.ts +1 -1
  84. package/build/services/durable/workflow/hook.js +4 -3
  85. package/build/services/durable/workflow/index.d.ts +45 -50
  86. package/build/services/durable/workflow/index.js +46 -51
  87. package/build/services/durable/workflow/interruption.d.ts +7 -6
  88. package/build/services/durable/workflow/interruption.js +11 -7
  89. package/build/services/durable/workflow/patched.d.ts +72 -0
  90. package/build/services/durable/workflow/patched.js +110 -0
  91. package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
  92. package/build/services/durable/workflow/proxyActivities.js +51 -15
  93. package/build/services/durable/workflow/searchMethods.d.ts +7 -0
  94. package/build/services/durable/workflow/searchMethods.js +7 -0
  95. package/build/services/durable/workflow/signal.d.ts +4 -4
  96. package/build/services/durable/workflow/signal.js +4 -4
  97. package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
  98. package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
  99. package/build/services/durable/workflow/terminate.d.ts +55 -0
  100. package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
  101. package/build/services/durable/workflow/trace.js +2 -2
  102. package/build/services/durable/workflow/uuid4.d.ts +14 -0
  103. package/build/services/durable/workflow/uuid4.js +39 -0
  104. package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
  105. package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
  106. package/build/services/engine/compiler.d.ts +19 -0
  107. package/build/services/engine/compiler.js +20 -0
  108. package/build/services/engine/completion.d.ts +46 -0
  109. package/build/services/engine/completion.js +145 -0
  110. package/build/services/engine/dispatch.d.ts +24 -0
  111. package/build/services/engine/dispatch.js +98 -0
  112. package/build/services/engine/index.d.ts +49 -81
  113. package/build/services/engine/index.js +175 -573
  114. package/build/services/engine/init.d.ts +42 -0
  115. package/build/services/engine/init.js +74 -0
  116. package/build/services/engine/pubsub.d.ts +50 -0
  117. package/build/services/engine/pubsub.js +118 -0
  118. package/build/services/engine/reporting.d.ts +20 -0
  119. package/build/services/engine/reporting.js +38 -0
  120. package/build/services/engine/schema.d.ts +23 -0
  121. package/build/services/engine/schema.js +62 -0
  122. package/build/services/engine/signal.d.ts +57 -0
  123. package/build/services/engine/signal.js +117 -0
  124. package/build/services/engine/state.d.ts +35 -0
  125. package/build/services/engine/state.js +61 -0
  126. package/build/services/engine/version.d.ts +31 -0
  127. package/build/services/engine/version.js +73 -0
  128. package/build/services/hotmesh/deployment.d.ts +21 -0
  129. package/build/services/hotmesh/deployment.js +25 -0
  130. package/build/services/hotmesh/index.d.ts +142 -533
  131. package/build/services/hotmesh/index.js +223 -674
  132. package/build/services/hotmesh/init.d.ts +42 -0
  133. package/build/services/hotmesh/init.js +93 -0
  134. package/build/services/hotmesh/jobs.d.ts +67 -0
  135. package/build/services/hotmesh/jobs.js +99 -0
  136. package/build/services/hotmesh/pubsub.d.ts +38 -0
  137. package/build/services/hotmesh/pubsub.js +54 -0
  138. package/build/services/hotmesh/quorum.d.ts +30 -0
  139. package/build/services/hotmesh/quorum.js +62 -0
  140. package/build/services/hotmesh/validation.d.ts +6 -0
  141. package/build/services/hotmesh/validation.js +28 -0
  142. package/build/services/quorum/index.js +1 -0
  143. package/build/services/router/consumption/index.d.ts +11 -5
  144. package/build/services/router/consumption/index.js +24 -17
  145. package/build/services/router/error-handling/index.d.ts +2 -2
  146. package/build/services/router/error-handling/index.js +14 -14
  147. package/build/services/router/index.d.ts +1 -1
  148. package/build/services/router/index.js +2 -2
  149. package/build/services/serializer/index.d.ts +22 -0
  150. package/build/services/serializer/index.js +39 -1
  151. package/build/services/store/index.d.ts +1 -0
  152. package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
  153. package/build/services/store/providers/postgres/exporter-sql.js +4 -4
  154. package/build/services/store/providers/postgres/kvtables.js +7 -6
  155. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
  156. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
  157. package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
  158. package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
  159. package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
  160. package/build/services/store/providers/postgres/postgres.d.ts +1 -0
  161. package/build/services/store/providers/postgres/postgres.js +14 -4
  162. package/build/services/stream/factory.d.ts +3 -1
  163. package/build/services/stream/factory.js +2 -2
  164. package/build/services/stream/index.d.ts +1 -0
  165. package/build/services/stream/providers/nats/nats.d.ts +1 -0
  166. package/build/services/stream/providers/nats/nats.js +1 -0
  167. package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
  168. package/build/services/stream/providers/postgres/credentials.js +129 -0
  169. package/build/services/stream/providers/postgres/kvtables.js +18 -0
  170. package/build/services/stream/providers/postgres/messages.js +7 -7
  171. package/build/services/stream/providers/postgres/notifications.js +16 -2
  172. package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
  173. package/build/services/stream/providers/postgres/postgres.js +35 -4
  174. package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
  175. package/build/services/stream/providers/postgres/procedures.js +213 -0
  176. package/build/services/stream/providers/postgres/secured.d.ts +34 -0
  177. package/build/services/stream/providers/postgres/secured.js +146 -0
  178. package/build/services/stream/providers/postgres/stats.d.ts +1 -0
  179. package/build/services/stream/providers/postgres/stats.js +1 -0
  180. package/build/services/stream/registry.d.ts +1 -1
  181. package/build/services/stream/registry.js +5 -2
  182. package/build/services/telemetry/index.d.ts +10 -1
  183. package/build/services/telemetry/index.js +40 -7
  184. package/build/services/worker/credentials.d.ts +51 -0
  185. package/build/services/worker/credentials.js +87 -0
  186. package/build/services/worker/index.d.ts +2 -2
  187. package/build/services/worker/index.js +7 -6
  188. package/build/types/codec.d.ts +84 -0
  189. package/build/types/codec.js +2 -0
  190. package/build/types/dba.d.ts +39 -3
  191. package/build/types/durable.d.ts +123 -25
  192. package/build/types/error.d.ts +10 -0
  193. package/build/types/exporter.d.ts +1 -1
  194. package/build/types/hotmesh.d.ts +67 -4
  195. package/build/types/index.d.ts +2 -1
  196. package/build/types/provider.d.ts +2 -2
  197. package/build/types/quorum.d.ts +35 -1
  198. package/build/types/stream.d.ts +12 -6
  199. package/package.json +8 -2
  200. package/build/services/activities/activity.d.ts +0 -192
  201. package/build/services/activities/activity.js +0 -786
  202. package/build/services/durable/workflow/interrupt.d.ts +0 -55
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DurableTelemetryService = void 0;
7
+ const package_json_1 = __importDefault(require("../../package.json"));
8
+ const enums_1 = require("../../modules/enums");
9
+ const telemetry_1 = require("../../types/telemetry");
10
+ /**
11
+ * Emits OpenTelemetry spans for durable workflow execution. All methods
12
+ * are no-ops when no OTel SDK is registered — `@opentelemetry/api`
13
+ * returns a no-op tracer by default, so there is zero overhead without
14
+ * a configured exporter.
15
+ *
16
+ * ## Span Categories
17
+ *
18
+ * | Span | When | Mode |
19
+ * |------|------|------|
20
+ * | `WORKFLOW/START/{name}` | First execution (not replay) | `info` |
21
+ * | `WORKFLOW/COMPLETE/{name}` | Workflow returns successfully | `info` |
22
+ * | `WORKFLOW/ERROR/{name}` | Workflow throws a fatal error | `info` |
23
+ * | `ACTIVITY/{name}` | Real wall-clock activity execution on the worker | `info` |
24
+ * | `DISPATCH/{type}/{name}/{idx}` | Operation dispatched (first execution only) | `debug` |
25
+ * | `RETURN/{type}/{name}/{idx}` | Operation result returned (with ac/au duration) | `debug` |
26
+ *
27
+ * ## Gating
28
+ *
29
+ * - `isEnabled()` — true when `HMSH_TELEMETRY` is set (any value)
30
+ * - `isVerbose()` — true only when `HMSH_TELEMETRY === 'debug'`
31
+ *
32
+ * In `info` mode, engine-layer spans (stream hops, DAG activity spans)
33
+ * are suppressed for durable workflows — only the spans above are
34
+ * emitted. This keeps dashboards clean and focused on the user's
35
+ * workflow story. Set `HMSH_TELEMETRY=debug` to also see engine
36
+ * internals and per-operation DISPATCH/RETURN spans.
37
+ *
38
+ * ## Setup
39
+ *
40
+ * Register an OTel SDK with a trace exporter before starting workers:
41
+ *
42
+ * ```typescript
43
+ * import { NodeSDK } from '@opentelemetry/sdk-node';
44
+ * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
45
+ * import { resourceFromAttributes } from '@opentelemetry/resources';
46
+ * import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
47
+ *
48
+ * const sdk = new NodeSDK({
49
+ * resource: resourceFromAttributes({ [ATTR_SERVICE_NAME]: 'my-service' }),
50
+ * traceExporter: new OTLPTraceExporter({
51
+ * url: 'https://api.honeycomb.io/v1/traces',
52
+ * headers: { 'x-honeycomb-team': process.env.HONEYCOMB_API_KEY },
53
+ * }),
54
+ * });
55
+ * sdk.start();
56
+ * ```
57
+ *
58
+ * ```bash
59
+ * # Concise workflow telemetry (recommended for production)
60
+ * HMSH_TELEMETRY=info node worker.js
61
+ *
62
+ * # Full operational detail (debugging)
63
+ * HMSH_TELEMETRY=debug node worker.js
64
+ * ```
65
+ */
66
+ class DurableTelemetryService {
67
+ static isEnabled() {
68
+ return !!enums_1.HMSH_TELEMETRY;
69
+ }
70
+ static isVerbose() {
71
+ return enums_1.HMSH_TELEMETRY === 'debug';
72
+ }
73
+ static getParentContext(traceId, spanId) {
74
+ const restoredSpanContext = {
75
+ traceId,
76
+ spanId,
77
+ isRemote: true,
78
+ traceFlags: 1,
79
+ };
80
+ return telemetry_1.trace.setSpanContext(telemetry_1.context.active(), restoredSpanContext);
81
+ }
82
+ /**
83
+ * Emit a point-in-time span (starts and ends immediately).
84
+ */
85
+ static emitPointSpan(traceId, parentSpanId, spanName, attributes, statusCode, statusMessage) {
86
+ const tracer = telemetry_1.trace.getTracer(package_json_1.default.name, package_json_1.default.version);
87
+ const parentContext = DurableTelemetryService.getParentContext(traceId, parentSpanId);
88
+ telemetry_1.context.with(parentContext, () => {
89
+ const span = tracer.startSpan(spanName, {
90
+ kind: telemetry_1.SpanKind.CLIENT,
91
+ attributes,
92
+ });
93
+ if (statusCode !== undefined) {
94
+ span.setStatus({ code: statusCode, message: statusMessage });
95
+ }
96
+ span.end();
97
+ });
98
+ }
99
+ /**
100
+ * Emit a duration span with explicit start/end times.
101
+ * Used for reconstructing operation durations from stored timestamps.
102
+ */
103
+ static emitDurationSpan(traceId, parentSpanId, spanName, startTimeMs, endTimeMs, attributes) {
104
+ const tracer = telemetry_1.trace.getTracer(package_json_1.default.name, package_json_1.default.version);
105
+ const parentContext = DurableTelemetryService.getParentContext(traceId, parentSpanId);
106
+ telemetry_1.context.with(parentContext, () => {
107
+ const span = tracer.startSpan(spanName, {
108
+ kind: telemetry_1.SpanKind.CLIENT,
109
+ attributes,
110
+ startTime: startTimeMs,
111
+ }, parentContext);
112
+ span.end(endTimeMs);
113
+ });
114
+ }
115
+ /**
116
+ * Start a span and return it for manual end (e.g., wrapping activity execution).
117
+ */
118
+ static startSpan(traceId, parentSpanId, spanName, attributes) {
119
+ const tracer = telemetry_1.trace.getTracer(package_json_1.default.name, package_json_1.default.version);
120
+ const parentContext = DurableTelemetryService.getParentContext(traceId, parentSpanId);
121
+ return tracer.startSpan(spanName, {
122
+ kind: telemetry_1.SpanKind.CLIENT,
123
+ attributes,
124
+ }, parentContext);
125
+ }
126
+ /**
127
+ * Parse ac/au timestamps from jmark results to epoch ms.
128
+ * Handles both ISO strings and numeric epoch values.
129
+ */
130
+ static parseTimestamp(ts) {
131
+ if (typeof ts === 'number')
132
+ return ts;
133
+ const parsed = Date.parse(ts);
134
+ return isNaN(parsed) ? Date.now() : parsed;
135
+ }
136
+ }
137
+ exports.DurableTelemetryService = DurableTelemetryService;
@@ -2,28 +2,90 @@ import { HotMesh } from '../hotmesh';
2
2
  import { Connection, Registry, WorkerConfig, WorkerOptions } from '../../types/durable';
3
3
  import { StreamData, StreamDataResponse } from '../../types/stream';
4
4
  /**
5
- * The *Worker* service Registers worker functions and connects them to the mesh,
6
- * using the target backend provider/s (Postgres, NATS, etc).
5
+ * Hosts workflow and activity functions, connecting them to Postgres
6
+ * for durable execution, replay, and automatic retry.
7
+ *
8
+ * ## Connection Modes
9
+ *
10
+ * ### Standard (legacy) — full admin access
11
+ *
12
+ * The worker connects with the same Postgres credentials as the engine.
13
+ * Simple to set up; all workers share the same connection pool.
7
14
  *
8
- * @example
9
15
  * ```typescript
10
- * import { Durable } from '@hotmeshio/hotmesh';
11
- * import { Client as Postgres } from 'pg';
12
- * import * as workflows from './workflows';
16
+ * const worker = await Durable.Worker.create({
17
+ * connection: {
18
+ * class: Postgres,
19
+ * options: { connectionString: 'postgres://user:pass@host:5432/hotmesh' },
20
+ * },
21
+ * taskQueue: 'orders',
22
+ * workflow: orderWorkflow,
23
+ * });
24
+ * ```
13
25
  *
14
- * async function run() {
15
- * const worker = await Durable.Worker.create({
16
- * connection: {
17
- * class: Postgres,
18
- * options: { connectionString: 'postgres://user:password@localhost:5432/db' }
19
- * },
20
- * taskQueue: 'default',
21
- * workflow: workflows.example,
22
- * });
26
+ * ### Secured — scoped Postgres role (recommended for production)
23
27
  *
24
- * await worker.run();
25
- * }
28
+ * The worker connects as a restricted Postgres role that can only
29
+ * dequeue/ack/respond on its assigned stream names. All data access
30
+ * goes through SECURITY DEFINER stored procedures that validate the
31
+ * role's `app.allowed_streams` session variable before executing.
32
+ *
33
+ * **Step 1**: Provision a scoped credential (run once, from the engine/admin):
34
+ * ```typescript
35
+ * const cred = await Durable.provisionWorkerRole({
36
+ * connection: { class: Postgres, options: adminPgOptions },
37
+ * namespace: 'durable',
38
+ * streamNames: ['orders-activity'],
39
+ * });
40
+ * // cred = { roleName: 'hmsh_wrk_durable_orders_activity', password: '...' }
26
41
  * ```
42
+ *
43
+ * **Step 2**: Pass the credential when creating the worker:
44
+ * ```typescript
45
+ * const worker = await Durable.Worker.create({
46
+ * connection: {
47
+ * class: Postgres,
48
+ * options: { host: 'pg.prod', port: 5432, database: 'hotmesh' },
49
+ * },
50
+ * taskQueue: 'orders',
51
+ * workflow: orderWorkflow,
52
+ * workerCredentials: { user: cred.roleName, password: cred.password },
53
+ * });
54
+ * ```
55
+ *
56
+ * The worker role **cannot**:
57
+ * - SELECT/INSERT/UPDATE/DELETE any table directly
58
+ * - Access `jobs`, `jobs_attributes`, or any engine tables
59
+ * - Dequeue messages from other workers' streams
60
+ * - LISTEN on other workers' notification channels
61
+ *
62
+ * See {@link Durable.provisionWorkerRole} for credential lifecycle management.
63
+ *
64
+ * ## Telemetry
65
+ *
66
+ * Workers automatically emit OpenTelemetry spans when an OTel SDK is
67
+ * registered. Initialize the SDK **before** calling `create()`:
68
+ *
69
+ * ```typescript
70
+ * import { NodeSDK } from '@opentelemetry/sdk-node';
71
+ * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
72
+ * import { resourceFromAttributes } from '@opentelemetry/resources';
73
+ * import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
74
+ *
75
+ * const sdk = new NodeSDK({
76
+ * resource: resourceFromAttributes({ [ATTR_SERVICE_NAME]: 'my-service' }),
77
+ * traceExporter: new OTLPTraceExporter({
78
+ * url: 'https://api.honeycomb.io/v1/traces',
79
+ * headers: { 'x-honeycomb-team': process.env.HONEYCOMB_API_KEY },
80
+ * }),
81
+ * });
82
+ * sdk.start();
83
+ * ```
84
+ *
85
+ * | `HMSH_TELEMETRY` | Spans emitted |
86
+ * |-------|---------------|
87
+ * | `'info'` (default) | `WORKFLOW/START`, `WORKFLOW/COMPLETE`, `WORKFLOW/ERROR`, `ACTIVITY/{name}` |
88
+ * | `'debug'` | All `info` spans + `DISPATCH/RETURN` per operation + engine internals |
27
89
  */
28
90
  export declare class WorkerService {
29
91
  /**
@@ -106,7 +168,7 @@ export declare class WorkerService {
106
168
  * sendEmail: (to: string, subject: string) => Promise<void>;
107
169
  * }>({
108
170
  * taskQueue: 'payment',
109
- * retryPolicy: { maximumAttempts: 3 }
171
+ * retry: { maximumAttempts: 3 }
110
172
  * });
111
173
  *
112
174
  * const result = await processPayment(amount);
@@ -135,19 +197,36 @@ export declare class WorkerService {
135
197
  * taskQueue: 'shared'
136
198
  * }, { auditLog, collectMetrics }, 'shared');
137
199
  *
138
- * const interceptor: WorkflowInterceptor = {
200
+ * const interceptor: WorkflowInboundCallsInterceptor = {
139
201
  * async execute(ctx, next) {
140
202
  * const { auditLog } = Durable.workflow.proxyActivities<{
141
203
  * auditLog: (id: string, action: string) => Promise<void>;
142
204
  * }>({
143
205
  * taskQueue: 'shared',
144
- * retryPolicy: { maximumAttempts: 3 }
206
+ * retry: { maximumAttempts: 3 }
145
207
  * });
146
208
  * await auditLog(ctx.get('workflowId'), 'started');
147
209
  * return next();
148
210
  * }
149
211
  * };
150
212
  * ```
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * // Secured worker with scoped Postgres credentials (VNF-style isolation)
217
+ * // Step 1: Admin provisions a credential (one-time)
218
+ * const cred = await Durable.provisionWorkerRole({
219
+ * connection: { class: Postgres, options: adminOptions },
220
+ * streamNames: ['payment-activity'],
221
+ * });
222
+ *
223
+ * // Step 2: Worker connects with scoped role — can only access payment-activity
224
+ * await Durable.registerActivityWorker({
225
+ * connection: { class: Postgres, options: { host: 'pg.prod', database: 'hotmesh' } },
226
+ * taskQueue: 'payment',
227
+ * workerCredentials: { user: cred.roleName, password: cred.password },
228
+ * }, { processPayment, refundPayment });
229
+ * ```
151
230
  */
152
231
  static registerActivityWorker(config: Partial<WorkerConfig>, activities: any, activityTaskQueue?: string): Promise<HotMesh>;
153
232
  /**
@@ -156,7 +235,7 @@ export declare class WorkerService {
156
235
  */
157
236
  static createActivityCallback(): (payload: StreamData) => Promise<StreamDataResponse>;
158
237
  /**
159
- * Connects a worker to the mesh.
238
+ * Creates and starts a workflow worker.
160
239
  *
161
240
  * @example
162
241
  * ```typescript