@btravstack/temporal-worker 0.25.0 → 0.27.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
@@ -113,7 +113,6 @@ const ActivityUnit = Module("ActivityUnit")({
113
113
  // there is nothing to name). What the leaves read off `context.unit` is
114
114
  // declared once, beside `inject`.
115
115
  const orderActivities = TemporalActivities(contract)({
116
- inject: {},
117
116
  unit: { place: PlaceOrder },
118
117
  sync: () => ({
119
118
  placeOrder: {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AnyUnitModule, Refuse, Runtime, RuntimePort, UnitGate, UnitNeedsOf, UnitRecordOf } from "@btravstack/core";
2
2
  import { AnyModule, AnyPort, AnyProvider, Exportable, Module, NeedsGate, PortClassOf, PortInstance, Provider, Scope, ServiceOf } from "@btravstack/di";
3
- import { ConfigInvalid, Env } from "@btravstack/config";
3
+ import { ConfigInvalid, EnvReading } from "@btravstack/config";
4
4
  import { DeclareActivitiesHandlerOptions, EmptyContext } from "@temporal-contract/worker/activity";
5
5
  import { Duration } from "@temporalio/common";
6
6
  import { NativeConnection, Worker, WorkflowBundleWithSourceMap } from "@temporalio/worker";
@@ -91,12 +91,14 @@ type ScopedActivitiesOf<C extends ContractDefinition, K extends ActivitiesKeyOf<
91
91
  * out of the fork the attempt opened; the root's `unit.activity` module must
92
92
  * export every one of them.
93
93
  */
94
- export declare const TemporalWorkflowActivities: <C extends ContractDefinition, const K extends ActivitiesKeyOf<C>>(contract: C, key: K) => <const D extends Readonly<Record<string, AnyPort>>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
95
- readonly inject: D;
94
+ export declare const TemporalWorkflowActivities: <C extends ContractDefinition, const K extends ActivitiesKeyOf<C>>(contract: C, key: K) => <const D extends Readonly<Record<string, AnyPort>> = Record<never, never>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
95
+ readonly inject?: D;
96
96
  /** The unit-scoped ports these activities read off `context.unit`. */
97
97
  readonly unit?: U;
98
98
  readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => ScopedActivitiesOf<C, K, U>;
99
- }) => MintedActivities<C, K, InstanceType<D[keyof D]>, U>;
99
+ } & ([keyof D] extends [never] ? unknown : {
100
+ readonly inject: D;
101
+ })) => MintedActivities<C, K, InstanceType<D[keyof D]>, U>;
100
102
  //#endregion
101
103
  //#region src/temporal-runtime.d.ts
102
104
  /** What the worker publishes once it is polling, read back through `RunningApp.runtimeInfo()`. */
@@ -220,11 +222,11 @@ type Provided = TemporalRuntime | TemporalConfig | TemporalConnection;
220
222
  * Each configuration field is pinned on its own: a pinned field reads nothing
221
223
  * from the environment, and a field left unpinned still does.
222
224
  */
223
- export declare const temporal: <C extends ContractDefinition, Unit extends AnyUnitModule | undefined = undefined>(options: TemporalOptions<C, Unit>) => Module<Provided, ConfigInvalid | TemporalUnreachable, Env | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit>>;
225
+ export declare const temporal: <C extends ContractDefinition, Unit extends AnyUnitModule | undefined = undefined>(options: TemporalOptions<C, Unit>) => Module<Provided, ConfigInvalid | TemporalUnreachable, EnvReading<never, "TEMPORAL_ADDRESS" | "TEMPORAL_NAMESPACE" | "TEMPORAL_GRACE_PERIOD_MS" | "TEMPORAL_FORCE_AFTER_MS"> | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit>>;
224
226
  //#endregion
225
227
  //#region src/temporal-module.d.ts
226
228
  /** The starter's own module, as the sugar adds it to the application's imports. */
227
- type TemporalStarter<C extends ContractDefinition, Unit extends AnyUnitModule | undefined> = Module<TemporalRuntime | TemporalConfig | TemporalConnection, ConfigInvalid | TemporalUnreachable, Env | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit>>;
229
+ type TemporalStarter<C extends ContractDefinition, Unit extends AnyUnitModule | undefined> = Module<TemporalRuntime | TemporalConfig | TemporalConnection, ConfigInvalid | TemporalUnreachable, EnvReading<never, "TEMPORAL_ADDRESS" | "TEMPORAL_NAMESPACE" | "TEMPORAL_GRACE_PERIOD_MS" | "TEMPORAL_FORCE_AFTER_MS"> | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit>>;
228
230
  /** The application's imports plus the starter — the tuple `Module(name)` is handed. */
229
231
  type Imports<I extends readonly AnyModule[], C extends ContractDefinition, Unit extends AnyUnitModule | undefined> = readonly [...I, TemporalStarter<C, Unit>];
230
232
  /** The activities provider plus the application's own — the tuple `Module(name)` is handed. */
@@ -292,21 +294,23 @@ type Uncovered<C extends ContractDefinition, T extends readonly PieceOf<C>[]> =
292
294
  * The record arm: the whole activities record from one `sync`, with one `unit:`
293
295
  * record shared by every entry in it.
294
296
  *
295
- * It is `{ inject, unit?, sync }` — di's other arms are gone — for PARITY, not
297
+ * It is `{ inject?, unit?, sync }` — di's other arms are gone — for PARITY, not
296
298
  * for a type-system reason: `value` could have carried the record just as well,
297
299
  * since `U` infers from `unit` and never from the arm. `@btravstack/http-server`'s
298
- * `api.OrpcRouter(contract)` is `{ inject, unit?, sync }` and so are all three
300
+ * `api.OrpcRouter(contract)` is `{ inject?, unit?, sync }` and so are all three
299
301
  * packages' piece factories, so one arm across the family is one surface to
300
302
  * learn and one to keep.
301
303
  */
302
- type Whole<C extends ContractDefinition> = <const D extends Readonly<Record<string, AnyPort>>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
303
- readonly inject: D;
304
+ type Whole<C extends ContractDefinition> = <const D extends Readonly<Record<string, AnyPort>> = Record<never, never>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
305
+ readonly inject?: D;
304
306
  /** The unit-scoped ports every activity in the record reads off `context.unit`. */
305
307
  readonly unit?: U;
306
308
  readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => ActivitiesOf<C, {
307
309
  readonly unit: UnitRecordOf<U>;
308
310
  }>;
309
- }) => Provider<ActivitiesInstanceOf<C>, never, InstanceType<D[keyof D]>> & {
311
+ } & ([keyof D] extends [never] ? unknown : {
312
+ readonly inject: D;
313
+ })) => Provider<ActivitiesInstanceOf<C>, never, InstanceType<D[keyof D]>> & {
310
314
  readonly port: ActivitiesPortOf<C>;
311
315
  /** Phantom: the declared ports, which `TemporalModule` gates `unit.activity` against. */
312
316
  readonly _declaredUnit?: InstanceType<U[keyof U]>;
@@ -333,7 +337,7 @@ type Compose<C extends ContractDefinition> = <const T extends readonly PieceOf<C
333
337
  * TemporalActivities(orderContract)([fulfillOrder, chargeOrder])
334
338
  * ```
335
339
  *
336
- * The first is `{ inject, unit?, sync }`, whose `sync` hands back the whole
340
+ * The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
337
341
  * activities record — one `unit:` record for every entry in it. The second
338
342
  * takes the pieces `TemporalWorkflowActivities(contract, key)` builds: they are
339
343
  * the provider's deps, keyed by the contract key each piece's port id carries,
package/dist/index.mjs CHANGED
@@ -333,7 +333,7 @@ const TemporalModule = (name) => (options) => {
333
333
  * TemporalActivities(orderContract)([fulfillOrder, chargeOrder])
334
334
  * ```
335
335
  *
336
- * The first is `{ inject, unit?, sync }`, whose `sync` hands back the whole
336
+ * The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
337
337
  * activities record — one `unit:` record for every entry in it. The second
338
338
  * takes the pieces `TemporalWorkflowActivities(contract, key)` builds: they are
339
339
  * the provider's deps, keyed by the contract key each piece's port id carries,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/temporal-worker",
3
- "version": "0.25.0",
3
+ "version": "0.27.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",
@@ -46,11 +46,11 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@btravstack/config": "0.25.0",
50
- "@btravstack/core": "0.25.0",
51
- "@btravstack/di": "0.25.0",
49
+ "@btravstack/config": "0.27.0",
50
+ "@btravstack/core": "0.27.0",
51
+ "@btravstack/di": "0.27.0",
52
52
  "@btravstack/internal-test-infra": "0.0.0",
53
- "@btravstack/testing": "0.25.0",
53
+ "@btravstack/testing": "0.27.0",
54
54
  "@btravstack/tsconfig": "0.4.0",
55
55
  "@temporal-contract/client": "8.0.0-beta.11",
56
56
  "@temporal-contract/contract": "8.0.0-beta.11",
@@ -71,9 +71,9 @@
71
71
  "zod": "4.6.5"
72
72
  },
73
73
  "peerDependencies": {
74
- "@btravstack/config": "^0.25.0",
75
- "@btravstack/core": "^0.25.0",
76
- "@btravstack/di": "^0.25.0",
74
+ "@btravstack/config": "^0.27.0",
75
+ "@btravstack/core": "^0.27.0",
76
+ "@btravstack/di": "^0.27.0",
77
77
  "@temporal-contract/client": "^8.0.0-beta.9",
78
78
  "@temporal-contract/contract": "^8.0.0-beta.9",
79
79
  "@temporal-contract/worker": "^8.0.0-beta.9",