@btravstack/temporal-worker 0.48.0 → 0.48.1

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
@@ -160,6 +160,9 @@ itself, inside its own error qualifier, so a contract it cannot satisfy is a
160
160
  startup `Err`, not a defect. `runtimeInfo()` reads `{ taskQueue, namespace }`
161
161
  back once the worker is polling.
162
162
 
163
+ Activity-piece DI identities include the contract task queue. Separate worker
164
+ contracts can reuse keys without sharing a port; wire activity names stay unchanged.
165
+
163
166
  A worker polling for several workflows can be several slices instead of one
164
167
  record: `TemporalWorkflowActivities(contract, key)({ inject: { name: Dep }, unit, fork, sync })` mints a
165
168
  provider for ONE workflow's activities (or a contract-global activity),
package/dist/index.d.mts CHANGED
@@ -58,7 +58,7 @@ declare const WORKFLOW_ACTIVITIES_PREFIX = "TemporalWorkflowActivities:";
58
58
  * slices claiming one workflow di's duplicate-provider defect rather than a
59
59
  * silent merge.
60
60
  */
61
- type WorkflowActivitiesPortOf<C extends ContractDefinition, K extends ActivitiesKeyOf<C>> = PortClassOf<`${typeof WORKFLOW_ACTIVITIES_PREFIX}${K}`, ActivitiesRecordOf<C>[K]>;
61
+ type WorkflowActivitiesPortOf<C extends ContractDefinition, K extends ActivitiesKeyOf<C>> = PortClassOf<`${typeof WORKFLOW_ACTIVITIES_PREFIX}${C["taskQueue"]}:${K}`, ActivitiesRecordOf<C>[K]>;
62
62
  /**
63
63
  * What a minted piece returns. A piece naming its own `fork` owes that
64
64
  * module's unmet needs, and leaves nothing for the root's `unit.activity` to
@@ -66,6 +66,7 @@ type WorkflowActivitiesPortOf<C extends ContractDefinition, K extends Activities
66
66
  */
67
67
  type MintedActivities<C extends ContractDefinition, K extends ActivitiesKeyOf<C>, N, U extends Readonly<Record<string, AnyPort>>, M extends AnyUnitModule | undefined> = Provider<InstanceType<WorkflowActivitiesPortOf<C, K>>, never, N | UnitNeedsOf$1<M>> & {
68
68
  readonly port: WorkflowActivitiesPortOf<C, K>;
69
+ readonly _activityKey?: K;
69
70
  /** Phantom: the ports this piece injects, which the root's `unit.activity` must export. */
70
71
  readonly _declared?: undefined extends M ? InstanceType<U[keyof U]> : never;
71
72
  };
@@ -80,16 +81,16 @@ type ScopedActivitiesOf<C extends ContractDefinition, K extends ActivitiesKeyOf<
80
81
  *
81
82
  * A worker that polls one queue for several workflows is several pieces, each
82
83
  * declaring the services its own activities call;
83
- * `TemporalActivities(contract)([...])` composes them. `contract` is read for
84
- * its TYPE only, and types both `key` and the record — so an activity the
85
- * workflow does not declare is a compile error here rather than at startup.
84
+ * `TemporalActivities(contract)([...])` composes them. The contract types both
85
+ * `key` and the record and supplies the task queue that namespaces the port.
86
+ * An undeclared activity is a compile error rather than a startup failure.
86
87
  *
87
88
  * `key` is any top-level key of the activities record, which includes a
88
89
  * contract-global activity as well as a workflow; the name is imprecise in that
89
90
  * one case deliberately, since narrowing it would lock such a contract out of
90
91
  * the split.
91
92
  *
92
- * There is no name to give: the key IS the port's name.
93
+ * The contract's task queue and the key identify the port; wire activity names stay unchanged.
93
94
  *
94
95
  * `unit` declares the ports the activities read off `context.unit`, resolved
95
96
  * out of the fork the attempt opened; the root's `unit.activity` module must
@@ -292,6 +293,7 @@ export declare const TemporalModule: <const Name extends string>(name: Name) =>
292
293
  /** One piece of the activities record — what `TemporalWorkflowActivities(contract, key)(…)` returns. */
293
294
  type PieceOf<C extends ContractDefinition> = { readonly [K in ActivitiesKeyOf<C>]: {
294
295
  readonly port: WorkflowActivitiesPortOf<C, K>;
296
+ readonly _activityKey?: K;
295
297
  /** Phantom, carrying the ports the piece injects off `context.unit`. */
296
298
  readonly _declared?: unknown;
297
299
  }; }[ActivitiesKeyOf<C>];
@@ -299,11 +301,9 @@ type PieceOf<C extends ContractDefinition> = { readonly [K in ActivitiesKeyOf<C>
299
301
  type DeclaredOf<T extends readonly {
300
302
  readonly _declared?: unknown;
301
303
  }[]> = NonNullable<T[number]["_declared"]>;
302
- /** The key a piece carries, read back off its port id. */
304
+ /** The contract key a piece carries independently of its queue namespace. */
303
305
  type KeyOfPiece<P> = P extends {
304
- readonly port: {
305
- readonly portId: `${typeof WORKFLOW_ACTIVITIES_PREFIX}${infer K}`;
306
- };
306
+ readonly _activityKey?: infer K;
307
307
  } ? K : never;
308
308
  /** The record's top-level keys no piece in `T` covers. */
309
309
  type Uncovered<C extends ContractDefinition, T extends readonly PieceOf<C>[]> = Exclude<ActivitiesKeyOf<C>, KeyOfPiece<T[number]>>;
package/dist/index.mjs CHANGED
@@ -61,16 +61,16 @@ const WORKFLOW_ACTIVITIES_PREFIX = "TemporalWorkflowActivities:";
61
61
  *
62
62
  * A worker that polls one queue for several workflows is several pieces, each
63
63
  * declaring the services its own activities call;
64
- * `TemporalActivities(contract)([...])` composes them. `contract` is read for
65
- * its TYPE only, and types both `key` and the record — so an activity the
66
- * workflow does not declare is a compile error here rather than at startup.
64
+ * `TemporalActivities(contract)([...])` composes them. The contract types both
65
+ * `key` and the record and supplies the task queue that namespaces the port.
66
+ * An undeclared activity is a compile error rather than a startup failure.
67
67
  *
68
68
  * `key` is any top-level key of the activities record, which includes a
69
69
  * contract-global activity as well as a workflow; the name is imprecise in that
70
70
  * one case deliberately, since narrowing it would lock such a contract out of
71
71
  * the split.
72
72
  *
73
- * There is no name to give: the key IS the port's name.
73
+ * The contract's task queue and the key identify the port; wire activity names stay unchanged.
74
74
  *
75
75
  * `unit` declares the ports the activities read off `context.unit`, resolved
76
76
  * out of the fork the attempt opened; the root's `unit.activity` module must
@@ -84,7 +84,7 @@ const WORKFLOW_ACTIVITIES_PREFIX = "TemporalWorkflowActivities:";
84
84
  * declares are then checked against this module, here.
85
85
  */
86
86
  const TemporalWorkflowActivities = (contract, key) => {
87
- const port = class extends Port(`${WORKFLOW_ACTIVITIES_PREFIX}${key}`) {};
87
+ const port = class extends Port(`${WORKFLOW_ACTIVITIES_PREFIX}${contract.taskQueue}:${key}`) {};
88
88
  return (options) => mintPiece(port, (record, entry) => withFork(withUnit(record, entry), options.fork))(options);
89
89
  };
90
90
  //#endregion
@@ -377,7 +377,7 @@ const TemporalModule = (name) => (options) => {
377
377
  * and two slices claiming one key are di's duplicate-provider defect at build.
378
378
  */
379
379
  const TemporalActivities = (contract) => {
380
- return composeByPrefix(TemporalActivitiesPort, WORKFLOW_ACTIVITIES_PREFIX, withUnit);
380
+ return composeByPrefix(TemporalActivitiesPort, `${WORKFLOW_ACTIVITIES_PREFIX}${contract.taskQueue}:`, withUnit);
381
381
  };
382
382
  //#endregion
383
383
  export { ActivityInput, TemporalActivities, TemporalConfig, TemporalConnection, TemporalModule, TemporalRuntime, TemporalUnreachable, TemporalWorkflowActivities };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/temporal-worker",
3
- "version": "0.48.0",
3
+ "version": "0.48.1",
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,11 +52,11 @@
52
52
  }
53
53
  },
54
54
  "devDependencies": {
55
- "@btravstack/config": "0.48.0",
56
- "@btravstack/core": "0.48.0",
57
- "@btravstack/di": "0.48.0",
55
+ "@btravstack/config": "0.48.1",
56
+ "@btravstack/core": "0.48.1",
57
+ "@btravstack/di": "0.48.1",
58
58
  "@btravstack/internal-test-infra": "0.0.0",
59
- "@btravstack/testing": "0.48.0",
59
+ "@btravstack/testing": "0.48.1",
60
60
  "@btravstack/tsconfig": "0.4.0",
61
61
  "@temporal-contract/client": "8.0.0-beta.14",
62
62
  "@temporal-contract/contract": "8.0.0-beta.14",
@@ -78,9 +78,9 @@
78
78
  "zod": "4.6.7"
79
79
  },
80
80
  "peerDependencies": {
81
- "@btravstack/config": "^0.48.0",
82
- "@btravstack/core": "^0.48.0",
83
- "@btravstack/di": "^0.48.0",
81
+ "@btravstack/config": "^0.48.1",
82
+ "@btravstack/core": "^0.48.1",
83
+ "@btravstack/di": "^0.48.1",
84
84
  "@temporal-contract/client": "^8.0.0-beta.14",
85
85
  "@temporal-contract/contract": "^8.0.0-beta.14",
86
86
  "@temporal-contract/worker": "^8.0.0-beta.14",