@btravstack/temporal-worker 0.35.1 → 0.36.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.
package/README.md CHANGED
@@ -222,17 +222,17 @@ optional peers. See
222
222
  and the module lists (`imports`, `provides`, `exports`, `needs`). It is the
223
223
  only way to compose the starter, which is not exported:
224
224
 
225
- | Option | What it is |
226
- | --------------- | ----------------------------------------------------------------------------------------------------------------------- |
227
- | `contract` | the `temporal-contract` contract; the task queue this worker polls is read off it |
228
- | `activities` | the activities provider — what `TemporalActivities(contract)(...)` returns for this contract |
229
- | `workflows` | where the sandbox's code comes from: `{ workflowsPath }` or `{ workflowBundle }` |
230
- | `address` | pins the service instead of reading `TEMPORAL_ADDRESS` |
231
- | `namespace` | pins the namespace instead of reading `TEMPORAL_NAMESPACE` |
232
- | `gracePeriod` | pins `TEMPORAL_GRACE_PERIOD_MS` — Temporal's `shutdownGraceTime`, a `Duration` (default `10_000` ms) |
233
- | `forceAfter` | pins `TEMPORAL_FORCE_AFTER_MS` — Temporal's `shutdownForceTime` (default `15_000` ms); keep it under `DRAIN_TIMEOUT_MS` |
234
- | `unit` | `{ activity }` — the module the worker forks around every activity it dispatches, seeded with the validated input |
235
- | `dataConverter` | the application's port for the `DataConverter` (payload codecs) the worker and its clients share |
225
+ | Option | What it is |
226
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
227
+ | `contract` | the `temporal-contract` contract; the task queue this worker polls is read off it |
228
+ | `activities` | the activities provider — what `TemporalActivities(contract)(...)` returns for this contract |
229
+ | `workflows` | where the sandbox's code comes from: `{ workflowsPath }` or `{ workflowBundle }`; required unless the contract declares no workflows |
230
+ | `address` | pins the service instead of reading `TEMPORAL_ADDRESS` |
231
+ | `namespace` | pins the namespace instead of reading `TEMPORAL_NAMESPACE` |
232
+ | `gracePeriod` | pins `TEMPORAL_GRACE_PERIOD_MS` — Temporal's `shutdownGraceTime`, a `Duration` (default `10_000` ms) |
233
+ | `forceAfter` | pins `TEMPORAL_FORCE_AFTER_MS` — Temporal's `shutdownForceTime` (default `15_000` ms); keep it under `DRAIN_TIMEOUT_MS` |
234
+ | `unit` | `{ activity }` — the module the worker forks around every activity it dispatches, seeded with the validated input |
235
+ | `dataConverter` | the application's port for the `DataConverter` (payload codecs) the worker and its clients share |
236
236
 
237
237
  The full table — required/optional, defaults, and the reasoning — lives on
238
238
  [the reference page](https://btravstack.github.io/btravstack/reference/temporal-worker),
package/dist/index.d.mts CHANGED
@@ -223,6 +223,16 @@ type TemporalTuning<Unit extends AnyUnitModule | undefined = undefined, Converte
223
223
  */
224
224
  readonly dataConverter?: Converter;
225
225
  };
226
+ /**
227
+ * The workflow source a worker needs: required when the contract declares a
228
+ * workflow, which the worker would otherwise boot and never run, and optional
229
+ * only for a contract that declares none (an activity-only worker).
230
+ */
231
+ type WorkflowsOption<C extends ContractDefinition> = [keyof C["workflows"]] extends [never] ? {
232
+ readonly workflows?: WorkflowSource;
233
+ } : {
234
+ readonly workflows: WorkflowSource;
235
+ };
226
236
  type TemporalOptions<C extends ContractDefinition, Unit extends AnyUnitModule | undefined = undefined, Converter extends DataConverterPort = never> = TemporalTuning<Unit, Converter> & {
227
237
  /**
228
238
  * The contract; the task queue this worker polls is read off it, and the
@@ -230,8 +240,7 @@ type TemporalOptions<C extends ContractDefinition, Unit extends AnyUnitModule |
230
240
  * `declareActivitiesHandler` itself, with its unit middleware in place.
231
241
  */
232
242
  readonly contract: C;
233
- readonly workflows: WorkflowSource;
234
- };
243
+ } & WorkflowsOption<C>;
235
244
  //#endregion
236
245
  //#region src/temporal-module.d.ts
237
246
  /** The starter's own module, as the sugar adds it to the application's imports. */
@@ -243,7 +252,6 @@ type Provides<P extends readonly AnyProvider[], C extends ContractDefinition, Ac
243
252
  type TemporalModuleOptions<C extends ContractDefinition, ActivitiesError, ActivitiesNeeds, Declared, Unit extends AnyUnitModule | undefined, I extends readonly AnyModule[], P extends readonly AnyProvider[], X extends readonly Exportable<Imports<I, C, Unit, Converter>, Provides<P, C, ActivitiesError, ActivitiesNeeds>>[], N extends readonly AnyPort[] | undefined, Converter extends DataConverterPort = never> = TemporalTuning<Unit, Converter> & {
244
253
  /** The `temporal-contract` contract; the task queue this worker polls is read off it. */
245
254
  readonly contract: C;
246
- readonly workflows: WorkflowSource;
247
255
  /**
248
256
  * The application's activity implementations — what
249
257
  * `TemporalActivities(contract)(…)` returns. Its `_declaredUnit` phantom
@@ -262,7 +270,7 @@ type TemporalModuleOptions<C extends ContractDefinition, ActivitiesError, Activi
262
270
  * over the augmented tuples below, so forgetting one is an error at THIS call.
263
271
  */
264
272
  readonly needs?: N;
265
- } & NeedsGate<Imports<I, C, Unit, Converter>, Provides<P, C, ActivitiesError, ActivitiesNeeds>, N> & UnitGate<Unit, Declared>;
273
+ } & WorkflowsOption<C> & NeedsGate<Imports<I, C, Unit, Converter>, Provides<P, C, ActivitiesError, ActivitiesNeeds>, N> & UnitGate<Unit, Declared>;
266
274
  /**
267
275
  * `Module(name)({...})` for a Temporal worker deployment: everything a di module
268
276
  * takes, plus the contract, the activities provider and the workflow source. The
package/dist/index.mjs CHANGED
@@ -279,7 +279,7 @@ const createWorker = (host, connection, config, activities, options, observers,
279
279
  connection,
280
280
  namespace,
281
281
  taskQueue,
282
- ...options.workflows,
282
+ ...options.workflows ?? {},
283
283
  activities: handler,
284
284
  shutdownGraceTime: config.gracePeriodMs,
285
285
  shutdownForceTime: config.forceAfterMs,
@@ -1,5 +1,5 @@
1
1
  import { AsyncResult } from "unthrown";
2
- import { ScheduleNotFoundError, TypedScheduleClient, TypedScheduleCreateOptions, WorkflowNotInContractError, WorkflowValidationError } from "@temporal-contract/client";
2
+ import { ScheduleNotFoundError, TypedScheduleClient, TypedScheduleCreateOptions, WorkflowValidationError } from "@temporal-contract/client";
3
3
  import { ContractDefinition } from "@temporal-contract/contract";
4
4
  //#region src/schedule.d.ts
5
5
  /** Whether the schedule had to be created, or was already there and had its spec reconciled. */
@@ -50,5 +50,5 @@ export type ScheduleOutcome = "created" | "updated";
50
50
  * });
51
51
  * ```
52
52
  */
53
- export declare const ensureSchedule: <C extends ContractDefinition, W extends keyof C["workflows"] & string>(schedules: TypedScheduleClient<C>, workflow: W, options: TypedScheduleCreateOptions<C, W>) => AsyncResult<ScheduleOutcome, WorkflowNotInContractError | WorkflowValidationError | ScheduleNotFoundError>;
53
+ export declare const ensureSchedule: <C extends ContractDefinition, W extends keyof C["workflows"] & string>(schedules: TypedScheduleClient<C>, workflow: W, options: TypedScheduleCreateOptions<C, W>) => AsyncResult<ScheduleOutcome, WorkflowValidationError | ScheduleNotFoundError>;
54
54
  //#endregion
package/dist/schedule.mjs CHANGED
@@ -56,6 +56,6 @@ const ensureSchedule = (schedules, workflow, options) => schedules.create(workfl
56
56
  args: [options.args]
57
57
  },
58
58
  ...options.policies === void 0 ? {} : { policies: options.policies }
59
- })).map(() => "updated")).with(P.tag("@temporal-contract/WorkflowNotInContractError"), (error) => ErrAsync(error)).with(P.tag("@temporal-contract/WorkflowValidationError"), (error) => ErrAsync(error)));
59
+ })).map(() => "updated")).with(P.tag("@temporal-contract/WorkflowValidationError"), (error) => ErrAsync(error)));
60
60
  //#endregion
61
61
  export { ensureSchedule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/temporal-worker",
3
- "version": "0.35.1",
3
+ "version": "0.36.0",
4
4
  "description": "The Temporal worker runtime for @btravstack/core: one unit per activity attempt, and a drain that honours the kernel's deadline",
5
5
  "keywords": [
6
6
  "graceful-shutdown",
@@ -52,15 +52,15 @@
52
52
  }
53
53
  },
54
54
  "devDependencies": {
55
- "@btravstack/config": "0.35.1",
56
- "@btravstack/core": "0.35.1",
57
- "@btravstack/di": "0.35.1",
55
+ "@btravstack/config": "0.36.0",
56
+ "@btravstack/core": "0.36.0",
57
+ "@btravstack/di": "0.36.0",
58
58
  "@btravstack/internal-test-infra": "0.0.0",
59
- "@btravstack/testing": "0.35.1",
59
+ "@btravstack/testing": "0.36.0",
60
60
  "@btravstack/tsconfig": "0.4.0",
61
- "@temporal-contract/client": "8.0.0-beta.11",
62
- "@temporal-contract/contract": "8.0.0-beta.11",
63
- "@temporal-contract/worker": "8.0.0-beta.11",
61
+ "@temporal-contract/client": "8.0.0-beta.14",
62
+ "@temporal-contract/contract": "8.0.0-beta.14",
63
+ "@temporal-contract/worker": "8.0.0-beta.14",
64
64
  "@temporalio/activity": "1.24.0",
65
65
  "@temporalio/client": "1.24.0",
66
66
  "@temporalio/common": "1.24.0",
@@ -78,17 +78,17 @@
78
78
  "zod": "4.6.6"
79
79
  },
80
80
  "peerDependencies": {
81
- "@btravstack/config": "^0.35.1",
82
- "@btravstack/core": "^0.35.1",
83
- "@btravstack/di": "^0.35.1",
84
- "@temporal-contract/client": "^8.0.0-beta.9",
85
- "@temporal-contract/contract": "^8.0.0-beta.9",
86
- "@temporal-contract/worker": "^8.0.0-beta.9",
87
- "@temporalio/activity": "^1.22.0",
88
- "@temporalio/common": "^1.22.0",
89
- "@temporalio/worker": "^1.22.0",
81
+ "@btravstack/config": "^0.36.0",
82
+ "@btravstack/core": "^0.36.0",
83
+ "@btravstack/di": "^0.36.0",
84
+ "@temporal-contract/client": "^8.0.0-beta.14",
85
+ "@temporal-contract/contract": "^8.0.0-beta.14",
86
+ "@temporal-contract/worker": "^8.0.0-beta.14",
87
+ "@temporalio/activity": "^1.24.0",
88
+ "@temporalio/common": "^1.24.0",
89
+ "@temporalio/worker": "^1.24.0",
90
90
  "testcontainers": "^12.0.0",
91
- "unthrown": "^5.7.0",
91
+ "unthrown": "^5.11.0",
92
92
  "vitest": ">=3.2.0"
93
93
  },
94
94
  "peerDependenciesMeta": {