@btravstack/amqp-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/dist/index.cjs +1 -1
- package/dist/index.d.cts +16 -12
- package/dist/index.d.mts +16 -12
- package/dist/index.mjs +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -242,7 +242,7 @@ const amqp = (options) => {
|
|
|
242
242
|
* AmqpHandlers(orderContract)([orderNotifications, orderAudit])
|
|
243
243
|
* ```
|
|
244
244
|
*
|
|
245
|
-
* The first is `{ inject
|
|
245
|
+
* The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
|
|
246
246
|
* handlers record — one `unit:` record for every entry in it. The second takes
|
|
247
247
|
* the pieces `AmqpHandler(contract, key)` builds: they are the provider's deps,
|
|
248
248
|
* keyed by the contract key each piece's port id carries, so the services
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigInvalid,
|
|
1
|
+
import { ConfigInvalid, EnvReading } from "@btravstack/config";
|
|
2
2
|
import { AnyUnitModule, Refuse, Runtime, RuntimePort, UnitGate, UnitNeedsOf, UnitRecordOf } from "@btravstack/core";
|
|
3
3
|
import { AnyModule, AnyPort, AnyProvider, Exportable, Module, NeedsGate, PortClassOf, PortInstance, Provider, ServiceOf } from "@btravstack/di";
|
|
4
4
|
import { ConsumerOptions, TypedAmqpWorker, WorkerInferHandlers } from "@amqp-contract/worker";
|
|
@@ -68,8 +68,8 @@ type MintedHandler<C extends AnyAmqpContract, K extends HandlerKeyOf<C>, N, U ex
|
|
|
68
68
|
* of the fork the delivery opened; the root's `unit.message` module must export
|
|
69
69
|
* every one of them.
|
|
70
70
|
*/
|
|
71
|
-
export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends HandlerKeyOf<C>>(contract: C, key: K) => <const D extends Readonly<Record<string, AnyPort
|
|
72
|
-
readonly inject
|
|
71
|
+
export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends HandlerKeyOf<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: {
|
|
72
|
+
readonly inject?: D;
|
|
73
73
|
/** The unit-scoped ports this handler reads off `context.unit`. */
|
|
74
74
|
readonly unit?: U;
|
|
75
75
|
readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => WorkerInferHandlers<C, {
|
|
@@ -77,7 +77,9 @@ export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends Ha
|
|
|
77
77
|
}>[K & keyof WorkerInferHandlers<C, {
|
|
78
78
|
readonly unit: UnitRecordOf<U>;
|
|
79
79
|
}>];
|
|
80
|
-
}
|
|
80
|
+
} & ([keyof D] extends [never] ? unknown : {
|
|
81
|
+
readonly inject: D;
|
|
82
|
+
})) => MintedHandler<C, K, InstanceType<D[keyof D]>, U>;
|
|
81
83
|
//#endregion
|
|
82
84
|
//#region src/amqp-runtime.d.ts
|
|
83
85
|
/** What the worker publishes once it is consuming, read back through `RunningApp.runtimeInfo()`. */
|
|
@@ -162,7 +164,7 @@ type AmqpTuning<Unit extends AnyUnitModule | undefined = undefined> = {
|
|
|
162
164
|
*
|
|
163
165
|
* With `url` pinned the module reads nothing from the environment.
|
|
164
166
|
*/
|
|
165
|
-
export declare const amqp: <TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined = undefined>(options: AmqpOptions<TContract, Unit>) => Module<AmqpRuntime | AmqpConfig, ConfigInvalid,
|
|
167
|
+
export declare const amqp: <TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined = undefined>(options: AmqpOptions<TContract, Unit>) => Module<AmqpRuntime | AmqpConfig, ConfigInvalid, EnvReading<never, "AMQP_URL" | "AMQP_CONNECT_TIMEOUT_MS"> | HandlersInstanceOf<TContract> | UnitNeedsOf$1<Unit>>;
|
|
166
168
|
/** One piece of the handlers record — what `AmqpHandler(contract, key)(…)` returns, as the composing form consumes it. */
|
|
167
169
|
type PieceOf<C extends AnyAmqpContract> = { readonly [K in HandlerKeyOf<C>]: {
|
|
168
170
|
readonly port: HandlerPortOf<C, K>;
|
|
@@ -185,21 +187,23 @@ type Uncovered<C extends AnyAmqpContract, T extends readonly PieceOf<C>[]> = Exc
|
|
|
185
187
|
* The record arm: the whole handlers record from one `sync`, with one `unit:`
|
|
186
188
|
* record shared by every entry in it.
|
|
187
189
|
*
|
|
188
|
-
* It is `{ inject
|
|
190
|
+
* It is `{ inject?, unit?, sync }` — di's other arms are gone — for PARITY, not
|
|
189
191
|
* for a type-system reason: `value` could have carried the record just as well,
|
|
190
192
|
* since `U` infers from `unit` and never from the arm. `@btravstack/http-server`'s
|
|
191
|
-
* `api.OrpcRouter(contract)` is `{ inject
|
|
193
|
+
* `api.OrpcRouter(contract)` is `{ inject?, unit?, sync }` and so are all three
|
|
192
194
|
* packages' piece factories, so one arm across the family is one surface to
|
|
193
195
|
* learn and one to keep.
|
|
194
196
|
*/
|
|
195
|
-
type Whole<C extends AnyAmqpContract> = <const D extends Readonly<Record<string, AnyPort
|
|
196
|
-
readonly inject
|
|
197
|
+
type Whole<C extends AnyAmqpContract> = <const D extends Readonly<Record<string, AnyPort>> = Record<never, never>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
|
|
198
|
+
readonly inject?: D;
|
|
197
199
|
/** The unit-scoped ports every handler in the record reads off `context.unit`. */
|
|
198
200
|
readonly unit?: U;
|
|
199
201
|
readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => WorkerInferHandlers<C, {
|
|
200
202
|
readonly unit: UnitRecordOf<U>;
|
|
201
203
|
}>;
|
|
202
|
-
}
|
|
204
|
+
} & ([keyof D] extends [never] ? unknown : {
|
|
205
|
+
readonly inject: D;
|
|
206
|
+
})) => Provider<HandlersInstanceOf<C>, never, InstanceType<D[keyof D]>> & {
|
|
203
207
|
readonly port: HandlersPortOf<C>;
|
|
204
208
|
/** Phantom: the declared ports, which `AmqpModule` gates `unit.message` against. */
|
|
205
209
|
readonly _declaredUnit?: InstanceType<U[keyof U]>;
|
|
@@ -226,7 +230,7 @@ type Compose<C extends AnyAmqpContract> = <const T extends readonly PieceOf<C>[]
|
|
|
226
230
|
* AmqpHandlers(orderContract)([orderNotifications, orderAudit])
|
|
227
231
|
* ```
|
|
228
232
|
*
|
|
229
|
-
* The first is `{ inject
|
|
233
|
+
* The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
|
|
230
234
|
* handlers record — one `unit:` record for every entry in it. The second takes
|
|
231
235
|
* the pieces `AmqpHandler(contract, key)` builds: they are the provider's deps,
|
|
232
236
|
* keyed by the contract key each piece's port id carries, so the services
|
|
@@ -237,7 +241,7 @@ export declare const AmqpHandlers: <C extends AnyAmqpContract>(contract: C) => W
|
|
|
237
241
|
//#endregion
|
|
238
242
|
//#region src/amqp-module.d.ts
|
|
239
243
|
/** The starter's own module, as the sugar adds it to the application's imports. */
|
|
240
|
-
type AmqpStarter<TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = Module<AmqpRuntime | AmqpConfig, ConfigInvalid,
|
|
244
|
+
type AmqpStarter<TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = Module<AmqpRuntime | AmqpConfig, ConfigInvalid, EnvReading<never, "AMQP_URL" | "AMQP_CONNECT_TIMEOUT_MS"> | HandlersInstanceOf<TContract> | UnitNeedsOf$1<Unit>>;
|
|
241
245
|
/** The application's imports plus the starter — the tuple `Module(name)` is handed. */
|
|
242
246
|
type Imports<I extends readonly AnyModule[], TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = readonly [...I, AmqpStarter<TContract, Unit>];
|
|
243
247
|
/** The handlers provider plus the application's own — the tuple `Module(name)` is handed. */
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyModule, AnyPort, AnyProvider, Exportable, Module, NeedsGate, PortClassOf, PortInstance, Provider, ServiceOf } from "@btravstack/di";
|
|
2
2
|
import { ConsumerOptions, TypedAmqpWorker, WorkerInferHandlers } from "@amqp-contract/worker";
|
|
3
|
-
import { ConfigInvalid,
|
|
3
|
+
import { ConfigInvalid, EnvReading } from "@btravstack/config";
|
|
4
4
|
import { AnyUnitModule, Refuse, Runtime, RuntimePort, UnitGate, UnitNeedsOf, UnitRecordOf } from "@btravstack/core";
|
|
5
5
|
//#region src/handler.d.ts
|
|
6
6
|
/** The consumer and rpc names `C` declares — the keys of its handlers record. */
|
|
@@ -68,8 +68,8 @@ type MintedHandler<C extends AnyAmqpContract, K extends HandlerKeyOf<C>, N, U ex
|
|
|
68
68
|
* of the fork the delivery opened; the root's `unit.message` module must export
|
|
69
69
|
* every one of them.
|
|
70
70
|
*/
|
|
71
|
-
export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends HandlerKeyOf<C>>(contract: C, key: K) => <const D extends Readonly<Record<string, AnyPort
|
|
72
|
-
readonly inject
|
|
71
|
+
export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends HandlerKeyOf<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: {
|
|
72
|
+
readonly inject?: D;
|
|
73
73
|
/** The unit-scoped ports this handler reads off `context.unit`. */
|
|
74
74
|
readonly unit?: U;
|
|
75
75
|
readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => WorkerInferHandlers<C, {
|
|
@@ -77,7 +77,9 @@ export declare const AmqpHandler: <C extends AnyAmqpContract, const K extends Ha
|
|
|
77
77
|
}>[K & keyof WorkerInferHandlers<C, {
|
|
78
78
|
readonly unit: UnitRecordOf<U>;
|
|
79
79
|
}>];
|
|
80
|
-
}
|
|
80
|
+
} & ([keyof D] extends [never] ? unknown : {
|
|
81
|
+
readonly inject: D;
|
|
82
|
+
})) => MintedHandler<C, K, InstanceType<D[keyof D]>, U>;
|
|
81
83
|
//#endregion
|
|
82
84
|
//#region src/amqp-runtime.d.ts
|
|
83
85
|
/** What the worker publishes once it is consuming, read back through `RunningApp.runtimeInfo()`. */
|
|
@@ -162,7 +164,7 @@ type AmqpTuning<Unit extends AnyUnitModule | undefined = undefined> = {
|
|
|
162
164
|
*
|
|
163
165
|
* With `url` pinned the module reads nothing from the environment.
|
|
164
166
|
*/
|
|
165
|
-
export declare const amqp: <TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined = undefined>(options: AmqpOptions<TContract, Unit>) => Module<AmqpRuntime | AmqpConfig, ConfigInvalid,
|
|
167
|
+
export declare const amqp: <TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined = undefined>(options: AmqpOptions<TContract, Unit>) => Module<AmqpRuntime | AmqpConfig, ConfigInvalid, EnvReading<never, "AMQP_URL" | "AMQP_CONNECT_TIMEOUT_MS"> | HandlersInstanceOf<TContract> | UnitNeedsOf$1<Unit>>;
|
|
166
168
|
/** One piece of the handlers record — what `AmqpHandler(contract, key)(…)` returns, as the composing form consumes it. */
|
|
167
169
|
type PieceOf<C extends AnyAmqpContract> = { readonly [K in HandlerKeyOf<C>]: {
|
|
168
170
|
readonly port: HandlerPortOf<C, K>;
|
|
@@ -185,21 +187,23 @@ type Uncovered<C extends AnyAmqpContract, T extends readonly PieceOf<C>[]> = Exc
|
|
|
185
187
|
* The record arm: the whole handlers record from one `sync`, with one `unit:`
|
|
186
188
|
* record shared by every entry in it.
|
|
187
189
|
*
|
|
188
|
-
* It is `{ inject
|
|
190
|
+
* It is `{ inject?, unit?, sync }` — di's other arms are gone — for PARITY, not
|
|
189
191
|
* for a type-system reason: `value` could have carried the record just as well,
|
|
190
192
|
* since `U` infers from `unit` and never from the arm. `@btravstack/http-server`'s
|
|
191
|
-
* `api.OrpcRouter(contract)` is `{ inject
|
|
193
|
+
* `api.OrpcRouter(contract)` is `{ inject?, unit?, sync }` and so are all three
|
|
192
194
|
* packages' piece factories, so one arm across the family is one surface to
|
|
193
195
|
* learn and one to keep.
|
|
194
196
|
*/
|
|
195
|
-
type Whole<C extends AnyAmqpContract> = <const D extends Readonly<Record<string, AnyPort
|
|
196
|
-
readonly inject
|
|
197
|
+
type Whole<C extends AnyAmqpContract> = <const D extends Readonly<Record<string, AnyPort>> = Record<never, never>, const U extends Readonly<Record<string, AnyPort>> = Record<never, never>>(options: {
|
|
198
|
+
readonly inject?: D;
|
|
197
199
|
/** The unit-scoped ports every handler in the record reads off `context.unit`. */
|
|
198
200
|
readonly unit?: U;
|
|
199
201
|
readonly sync: (services: { readonly [N in keyof D]: ServiceOf<InstanceType<D[N]>>; }) => WorkerInferHandlers<C, {
|
|
200
202
|
readonly unit: UnitRecordOf<U>;
|
|
201
203
|
}>;
|
|
202
|
-
}
|
|
204
|
+
} & ([keyof D] extends [never] ? unknown : {
|
|
205
|
+
readonly inject: D;
|
|
206
|
+
})) => Provider<HandlersInstanceOf<C>, never, InstanceType<D[keyof D]>> & {
|
|
203
207
|
readonly port: HandlersPortOf<C>;
|
|
204
208
|
/** Phantom: the declared ports, which `AmqpModule` gates `unit.message` against. */
|
|
205
209
|
readonly _declaredUnit?: InstanceType<U[keyof U]>;
|
|
@@ -226,7 +230,7 @@ type Compose<C extends AnyAmqpContract> = <const T extends readonly PieceOf<C>[]
|
|
|
226
230
|
* AmqpHandlers(orderContract)([orderNotifications, orderAudit])
|
|
227
231
|
* ```
|
|
228
232
|
*
|
|
229
|
-
* The first is `{ inject
|
|
233
|
+
* The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
|
|
230
234
|
* handlers record — one `unit:` record for every entry in it. The second takes
|
|
231
235
|
* the pieces `AmqpHandler(contract, key)` builds: they are the provider's deps,
|
|
232
236
|
* keyed by the contract key each piece's port id carries, so the services
|
|
@@ -237,7 +241,7 @@ export declare const AmqpHandlers: <C extends AnyAmqpContract>(contract: C) => W
|
|
|
237
241
|
//#endregion
|
|
238
242
|
//#region src/amqp-module.d.ts
|
|
239
243
|
/** The starter's own module, as the sugar adds it to the application's imports. */
|
|
240
|
-
type AmqpStarter<TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = Module<AmqpRuntime | AmqpConfig, ConfigInvalid,
|
|
244
|
+
type AmqpStarter<TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = Module<AmqpRuntime | AmqpConfig, ConfigInvalid, EnvReading<never, "AMQP_URL" | "AMQP_CONNECT_TIMEOUT_MS"> | HandlersInstanceOf<TContract> | UnitNeedsOf$1<Unit>>;
|
|
241
245
|
/** The application's imports plus the starter — the tuple `Module(name)` is handed. */
|
|
242
246
|
type Imports<I extends readonly AnyModule[], TContract extends AnyAmqpContract, Unit extends AnyUnitModule | undefined> = readonly [...I, AmqpStarter<TContract, Unit>];
|
|
243
247
|
/** The handlers provider plus the application's own — the tuple `Module(name)` is handed. */
|
package/dist/index.mjs
CHANGED
|
@@ -241,7 +241,7 @@ const amqp = (options) => {
|
|
|
241
241
|
* AmqpHandlers(orderContract)([orderNotifications, orderAudit])
|
|
242
242
|
* ```
|
|
243
243
|
*
|
|
244
|
-
* The first is `{ inject
|
|
244
|
+
* The first is `{ inject?, unit?, sync }`, whose `sync` hands back the whole
|
|
245
245
|
* handlers record — one `unit:` record for every entry in it. The second takes
|
|
246
246
|
* the pieces `AmqpHandler(contract, key)` builds: they are the provider's deps,
|
|
247
247
|
* keyed by the contract key each piece's port id carries, so the services
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btravstack/amqp-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "The AMQP starter for @btravstack/core: the handlers as a port, one unit per delivery, and a drain the kernel's deadline releases",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"@amqp-contract/contract": "3.0.0-beta.11",
|
|
48
48
|
"@amqp-contract/testing": "3.0.0-beta.11",
|
|
49
49
|
"@amqp-contract/worker": "3.0.0-beta.11",
|
|
50
|
-
"@btravstack/config": "0.
|
|
51
|
-
"@btravstack/core": "0.
|
|
52
|
-
"@btravstack/di": "0.
|
|
50
|
+
"@btravstack/config": "0.27.0",
|
|
51
|
+
"@btravstack/core": "0.27.0",
|
|
52
|
+
"@btravstack/di": "0.27.0",
|
|
53
53
|
"@btravstack/internal-test-infra": "0.0.0",
|
|
54
|
-
"@btravstack/testing": "0.
|
|
54
|
+
"@btravstack/testing": "0.27.0",
|
|
55
55
|
"@btravstack/tsconfig": "0.4.0",
|
|
56
56
|
"@opentelemetry/api": "1.9.1",
|
|
57
57
|
"@types/node": "26.6.4",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@amqp-contract/worker": "^3.0.0-beta.7",
|
|
69
|
-
"@btravstack/config": "^0.
|
|
70
|
-
"@btravstack/core": "^0.
|
|
71
|
-
"@btravstack/di": "^0.
|
|
69
|
+
"@btravstack/config": "^0.27.0",
|
|
70
|
+
"@btravstack/core": "^0.27.0",
|
|
71
|
+
"@btravstack/di": "^0.27.0",
|
|
72
72
|
"@opentelemetry/api": "^1",
|
|
73
73
|
"unthrown": "^5.7.0"
|
|
74
74
|
},
|