@amqp-contract/worker 0.14.0 → 0.16.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 +1 -1
- package/dist/index.cjs +9 -7
- package/dist/index.d.cts +78 -40
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +77 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +71 -70
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @amqp-contract/worker
|
|
2
2
|
|
|
3
|
-
**Type-safe AMQP worker for consuming messages using amqp-contract with
|
|
3
|
+
**Type-safe AMQP worker for consuming messages using amqp-contract with Future/Result error handling.**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/btravers/amqp-contract/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/@amqp-contract/worker)
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
let _amqp_contract_core = require("@amqp-contract/core");
|
|
2
3
|
let _amqp_contract_contract = require("@amqp-contract/contract");
|
|
3
4
|
let _swan_io_boxed = require("@swan-io/boxed");
|
|
@@ -230,17 +231,18 @@ function isHandlerTuple(entry) {
|
|
|
230
231
|
* @example
|
|
231
232
|
* ```typescript
|
|
232
233
|
* import { TypedAmqpWorker } from '@amqp-contract/worker';
|
|
234
|
+
* import { defineQueue, defineMessage, defineContract, defineConsumer } from '@amqp-contract/contract';
|
|
233
235
|
* import { z } from 'zod';
|
|
234
236
|
*
|
|
237
|
+
* const orderQueue = defineQueue('order-processing', { durable: true });
|
|
238
|
+
* const orderMessage = defineMessage(z.object({
|
|
239
|
+
* orderId: z.string(),
|
|
240
|
+
* amount: z.number()
|
|
241
|
+
* }));
|
|
242
|
+
*
|
|
235
243
|
* const contract = defineContract({
|
|
236
|
-
* queues: {
|
|
237
|
-
* orderProcessing: defineQueue('order-processing', { durable: true })
|
|
238
|
-
* },
|
|
239
244
|
* consumers: {
|
|
240
|
-
* processOrder: defineConsumer(
|
|
241
|
-
* orderId: z.string(),
|
|
242
|
-
* amount: z.number()
|
|
243
|
-
* }))
|
|
245
|
+
* processOrder: defineConsumer(orderQueue, orderMessage)
|
|
244
246
|
* }
|
|
245
247
|
* });
|
|
246
248
|
*
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
import { Logger, TechnicalError, TelemetryProvider } from "@amqp-contract/core";
|
|
2
|
-
import
|
|
3
|
-
import { ConsumerDefinition, ConsumerEntry, ContractDefinitionInput, InferConsumerNames, MessageDefinition } from "@amqp-contract/contract";
|
|
4
|
-
import { Future, Result } from "@swan-io/boxed";
|
|
2
|
+
import * as amqp from "amqplib";
|
|
5
3
|
import { ConsumeMessage } from "amqplib";
|
|
4
|
+
import { TcpSocketConnectOpts } from "net";
|
|
5
|
+
import { ConnectionOptions } from "tls";
|
|
6
|
+
import { ConsumerDefinition, ConsumerEntry, ContractDefinition, InferConsumerNames, MessageDefinition } from "@amqp-contract/contract";
|
|
7
|
+
import { Future, Result } from "@swan-io/boxed";
|
|
6
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
9
|
|
|
10
|
+
//#region ../../node_modules/.pnpm/amqp-connection-manager@5.0.0_amqplib@0.10.9/node_modules/amqp-connection-manager/dist/types/AmqpConnectionManager.d.ts
|
|
11
|
+
type ConnectionUrl = string | amqp.Options.Connect | {
|
|
12
|
+
url: string;
|
|
13
|
+
connectionOptions?: AmqpConnectionOptions;
|
|
14
|
+
};
|
|
15
|
+
type AmqpConnectionOptions = (ConnectionOptions | TcpSocketConnectOpts) & {
|
|
16
|
+
noDelay?: boolean;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
keepAlive?: boolean;
|
|
19
|
+
keepAliveDelay?: number;
|
|
20
|
+
clientProperties?: any;
|
|
21
|
+
credentials?: {
|
|
22
|
+
mechanism: string;
|
|
23
|
+
username: string;
|
|
24
|
+
password: string;
|
|
25
|
+
response: () => Buffer;
|
|
26
|
+
} | {
|
|
27
|
+
mechanism: string;
|
|
28
|
+
response: () => Buffer;
|
|
29
|
+
} | undefined;
|
|
30
|
+
};
|
|
31
|
+
interface AmqpConnectionManagerOptions {
|
|
32
|
+
/** Interval to send heartbeats to broker. Defaults to 5 seconds. */
|
|
33
|
+
heartbeatIntervalInSeconds?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The time to wait before trying to reconnect. If not specified, defaults
|
|
36
|
+
* to `heartbeatIntervalInSeconds`.
|
|
37
|
+
*/
|
|
38
|
+
reconnectTimeInSeconds?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* `findServers` is a function that which returns one or more servers to
|
|
41
|
+
* connect to. This should return either a single URL or an array of URLs.
|
|
42
|
+
* This is handy when you're using a service discovery mechanism such as
|
|
43
|
+
* Consul or etcd. Instead of taking a callback, this can also return a
|
|
44
|
+
* Promise. Note that if this is supplied, then `urls` is ignored.
|
|
45
|
+
*/
|
|
46
|
+
findServers?: ((callback: (urls: ConnectionUrl | ConnectionUrl[]) => void) => void) | (() => Promise<ConnectionUrl | ConnectionUrl[]>) | undefined;
|
|
47
|
+
/** Connection options, passed as options to the amqplib.connect() method. */
|
|
48
|
+
connectionOptions?: AmqpConnectionOptions;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
8
51
|
//#region src/errors.d.ts
|
|
9
52
|
/**
|
|
10
53
|
* Error thrown when message validation fails
|
|
@@ -184,20 +227,20 @@ type ConsumerInferHeadersInput<TConsumer extends ConsumerEntry> = ExtractConsume
|
|
|
184
227
|
/**
|
|
185
228
|
* Infer all consumers from contract
|
|
186
229
|
*/
|
|
187
|
-
type InferConsumers<TContract extends
|
|
230
|
+
type InferConsumers<TContract extends ContractDefinition> = NonNullable<TContract["consumers"]>;
|
|
188
231
|
/**
|
|
189
232
|
* Get specific consumer entry from contract
|
|
190
233
|
*/
|
|
191
|
-
type InferConsumer<TContract extends
|
|
234
|
+
type InferConsumer<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = InferConsumers<TContract>[TName];
|
|
192
235
|
/**
|
|
193
236
|
* Infer the payload type for a specific consumer
|
|
194
237
|
*/
|
|
195
|
-
type WorkerInferConsumerPayload<TContract extends
|
|
238
|
+
type WorkerInferConsumerPayload<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = ConsumerInferPayloadInput<InferConsumer<TContract, TName>>;
|
|
196
239
|
/**
|
|
197
240
|
* Infer the headers type for a specific consumer
|
|
198
241
|
* Returns undefined if no headers schema is defined
|
|
199
242
|
*/
|
|
200
|
-
type WorkerInferConsumerHeaders<TContract extends
|
|
243
|
+
type WorkerInferConsumerHeaders<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = ConsumerInferHeadersInput<InferConsumer<TContract, TName>>;
|
|
201
244
|
/**
|
|
202
245
|
* A consumed message containing parsed payload and headers.
|
|
203
246
|
*
|
|
@@ -218,17 +261,15 @@ type WorkerInferConsumerHeaders<TContract extends ContractDefinitionInput, TName
|
|
|
218
261
|
* });
|
|
219
262
|
* ```
|
|
220
263
|
*/
|
|
221
|
-
type WorkerConsumedMessage<TPayload, THeaders
|
|
222
|
-
/** The validated message payload */
|
|
223
|
-
|
|
224
|
-
/** The validated message headers (present only when headers schema is defined) */
|
|
225
|
-
headers: THeaders$1 extends undefined ? undefined : THeaders$1;
|
|
264
|
+
type WorkerConsumedMessage<TPayload, THeaders = undefined> = {
|
|
265
|
+
/** The validated message payload */payload: TPayload; /** The validated message headers (present only when headers schema is defined) */
|
|
266
|
+
headers: THeaders extends undefined ? undefined : THeaders;
|
|
226
267
|
};
|
|
227
268
|
/**
|
|
228
269
|
* Infer the full consumed message type for a specific consumer.
|
|
229
270
|
* Includes both payload and headers (if defined).
|
|
230
271
|
*/
|
|
231
|
-
type WorkerInferConsumedMessage<TContract extends
|
|
272
|
+
type WorkerInferConsumedMessage<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerConsumedMessage<WorkerInferConsumerPayload<TContract, TName>, WorkerInferConsumerHeaders<TContract, TName>>;
|
|
232
273
|
/**
|
|
233
274
|
* Consumer handler type for a specific consumer.
|
|
234
275
|
* Returns a `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
@@ -253,7 +294,7 @@ type WorkerInferConsumedMessage<TContract extends ContractDefinitionInput, TName
|
|
|
253
294
|
* };
|
|
254
295
|
* ```
|
|
255
296
|
*/
|
|
256
|
-
type WorkerInferConsumerHandler<TContract extends
|
|
297
|
+
type WorkerInferConsumerHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = (message: WorkerInferConsumedMessage<TContract, TName>, rawMessage: ConsumeMessage) => Future<Result<void, HandlerError>>;
|
|
257
298
|
/**
|
|
258
299
|
* Handler entry for a consumer - either a function or a tuple of [handler, options].
|
|
259
300
|
*
|
|
@@ -264,7 +305,7 @@ type WorkerInferConsumerHandler<TContract extends ContractDefinitionInput, TName
|
|
|
264
305
|
* Note: Retry configuration is now defined at the queue level in the contract,
|
|
265
306
|
* not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
266
307
|
*/
|
|
267
|
-
type WorkerInferConsumerHandlerEntry<TContract extends
|
|
308
|
+
type WorkerInferConsumerHandlerEntry<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandler<TContract, TName> | readonly [WorkerInferConsumerHandler<TContract, TName>, {
|
|
268
309
|
prefetch?: number;
|
|
269
310
|
}];
|
|
270
311
|
/**
|
|
@@ -281,19 +322,19 @@ type WorkerInferConsumerHandlerEntry<TContract extends ContractDefinitionInput,
|
|
|
281
322
|
* };
|
|
282
323
|
* ```
|
|
283
324
|
*/
|
|
284
|
-
type WorkerInferConsumerHandlers<TContract extends
|
|
325
|
+
type WorkerInferConsumerHandlers<TContract extends ContractDefinition> = { [K in InferConsumerNames<TContract>]: WorkerInferConsumerHandlerEntry<TContract, K> };
|
|
285
326
|
/**
|
|
286
327
|
* @deprecated Use `WorkerInferConsumerHandler` instead. Will be removed in next major version.
|
|
287
328
|
*/
|
|
288
|
-
type WorkerInferSafeConsumerHandler<TContract extends
|
|
329
|
+
type WorkerInferSafeConsumerHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandler<TContract, TName>;
|
|
289
330
|
/**
|
|
290
331
|
* @deprecated Use `WorkerInferConsumerHandlerEntry` instead. Will be removed in next major version.
|
|
291
332
|
*/
|
|
292
|
-
type WorkerInferSafeConsumerHandlerEntry<TContract extends
|
|
333
|
+
type WorkerInferSafeConsumerHandlerEntry<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
293
334
|
/**
|
|
294
335
|
* @deprecated Use `WorkerInferConsumerHandlers` instead. Will be removed in next major version.
|
|
295
336
|
*/
|
|
296
|
-
type WorkerInferSafeConsumerHandlers<TContract extends
|
|
337
|
+
type WorkerInferSafeConsumerHandlers<TContract extends ContractDefinition> = WorkerInferConsumerHandlers<TContract>;
|
|
297
338
|
//#endregion
|
|
298
339
|
//#region src/worker.d.ts
|
|
299
340
|
/**
|
|
@@ -331,20 +372,16 @@ type WorkerInferSafeConsumerHandlers<TContract extends ContractDefinitionInput>
|
|
|
331
372
|
* Note: Retry configuration is defined at the queue level in the contract,
|
|
332
373
|
* not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
333
374
|
*/
|
|
334
|
-
type CreateWorkerOptions<TContract extends
|
|
335
|
-
/** The AMQP contract definition specifying consumers and their message schemas */
|
|
336
|
-
contract: TContract;
|
|
375
|
+
type CreateWorkerOptions<TContract extends ContractDefinition> = {
|
|
376
|
+
/** The AMQP contract definition specifying consumers and their message schemas */contract: TContract;
|
|
337
377
|
/**
|
|
338
378
|
* Handlers for each consumer defined in the contract.
|
|
339
379
|
* Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
340
380
|
* Use defineHandler() to create handlers.
|
|
341
381
|
*/
|
|
342
|
-
handlers: WorkerInferConsumerHandlers<TContract>;
|
|
343
|
-
/**
|
|
344
|
-
|
|
345
|
-
/** Optional connection configuration (heartbeat, reconnect settings, etc.) */
|
|
346
|
-
connectionOptions?: AmqpConnectionManagerOptions | undefined;
|
|
347
|
-
/** Optional logger for logging message consumption and errors */
|
|
382
|
+
handlers: WorkerInferConsumerHandlers<TContract>; /** AMQP broker URL(s). Multiple URLs provide failover support */
|
|
383
|
+
urls: ConnectionUrl[]; /** Optional connection configuration (heartbeat, reconnect settings, etc.) */
|
|
384
|
+
connectionOptions?: AmqpConnectionManagerOptions | undefined; /** Optional logger for logging message consumption and errors */
|
|
348
385
|
logger?: Logger | undefined;
|
|
349
386
|
/**
|
|
350
387
|
* Optional telemetry provider for tracing and metrics.
|
|
@@ -364,17 +401,18 @@ type CreateWorkerOptions<TContract extends ContractDefinitionInput> = {
|
|
|
364
401
|
* @example
|
|
365
402
|
* ```typescript
|
|
366
403
|
* import { TypedAmqpWorker } from '@amqp-contract/worker';
|
|
404
|
+
* import { defineQueue, defineMessage, defineContract, defineConsumer } from '@amqp-contract/contract';
|
|
367
405
|
* import { z } from 'zod';
|
|
368
406
|
*
|
|
407
|
+
* const orderQueue = defineQueue('order-processing', { durable: true });
|
|
408
|
+
* const orderMessage = defineMessage(z.object({
|
|
409
|
+
* orderId: z.string(),
|
|
410
|
+
* amount: z.number()
|
|
411
|
+
* }));
|
|
412
|
+
*
|
|
369
413
|
* const contract = defineContract({
|
|
370
|
-
* queues: {
|
|
371
|
-
* orderProcessing: defineQueue('order-processing', { durable: true })
|
|
372
|
-
* },
|
|
373
414
|
* consumers: {
|
|
374
|
-
* processOrder: defineConsumer(
|
|
375
|
-
* orderId: z.string(),
|
|
376
|
-
* amount: z.number()
|
|
377
|
-
* }))
|
|
415
|
+
* processOrder: defineConsumer(orderQueue, orderMessage)
|
|
378
416
|
* }
|
|
379
417
|
* });
|
|
380
418
|
*
|
|
@@ -393,7 +431,7 @@ type CreateWorkerOptions<TContract extends ContractDefinitionInput> = {
|
|
|
393
431
|
* await worker.close().resultToPromise();
|
|
394
432
|
* ```
|
|
395
433
|
*/
|
|
396
|
-
declare class TypedAmqpWorker<TContract extends
|
|
434
|
+
declare class TypedAmqpWorker<TContract extends ContractDefinition> {
|
|
397
435
|
private readonly contract;
|
|
398
436
|
private readonly amqpClient;
|
|
399
437
|
private readonly logger?;
|
|
@@ -430,7 +468,7 @@ declare class TypedAmqpWorker<TContract extends ContractDefinitionInput> {
|
|
|
430
468
|
* }).resultToPromise();
|
|
431
469
|
* ```
|
|
432
470
|
*/
|
|
433
|
-
static create<TContract extends
|
|
471
|
+
static create<TContract extends ContractDefinition>({
|
|
434
472
|
contract,
|
|
435
473
|
handlers,
|
|
436
474
|
urls,
|
|
@@ -607,8 +645,8 @@ declare class TypedAmqpWorker<TContract extends ContractDefinitionInput> {
|
|
|
607
645
|
* );
|
|
608
646
|
* ```
|
|
609
647
|
*/
|
|
610
|
-
declare function defineHandler<TContract extends
|
|
611
|
-
declare function defineHandler<TContract extends
|
|
648
|
+
declare function defineHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>>(contract: TContract, consumerName: TName, handler: WorkerInferConsumerHandler<TContract, TName>): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
649
|
+
declare function defineHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>>(contract: TContract, consumerName: TName, handler: WorkerInferConsumerHandler<TContract, TName>, options: {
|
|
612
650
|
prefetch?: number;
|
|
613
651
|
}): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
614
652
|
/**
|
|
@@ -640,7 +678,7 @@ declare function defineHandler<TContract extends ContractDefinitionInput, TName
|
|
|
640
678
|
* });
|
|
641
679
|
* ```
|
|
642
680
|
*/
|
|
643
|
-
declare function defineHandlers<TContract extends
|
|
681
|
+
declare function defineHandlers<TContract extends ContractDefinition>(contract: TContract, handlers: WorkerInferConsumerHandlers<TContract>): WorkerInferConsumerHandlers<TContract>;
|
|
644
682
|
//#endregion
|
|
645
683
|
export { type CreateWorkerOptions, type HandlerError, MessageValidationError, NonRetryableError, RetryableError, TypedAmqpWorker, type WorkerConsumedMessage, type WorkerInferConsumedMessage, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlerEntry, type WorkerInferConsumerHandlers, type WorkerInferConsumerHeaders, type WorkerInferSafeConsumerHandler, type WorkerInferSafeConsumerHandlerEntry, type WorkerInferSafeConsumerHandlers, defineHandler, defineHandlers, isHandlerError, isNonRetryableError, isRetryableError, nonRetryable, retryable };
|
|
646
684
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["amqp","EventEmitter","TcpSocketConnectOpts","ConnectionOptions","ChannelWrapper","CreateChannelOpts","ConnectionUrl","Options","Connect","AmqpConnectionOptions","url","connectionOptions","ConnectListener","Connection","connection","arg","ConnectFailedListener","Error","err","Buffer","noDelay","timeout","keepAlive","keepAliveDelay","clientProperties","credentials","mechanism","username","password","response","AmqpConnectionManagerOptions","Promise","heartbeatIntervalInSeconds","reconnectTimeInSeconds","findServers","urls","callback","IAmqpConnectionManager","Function","ChannelModel","addListener","event","args","listener","reason","listeners","eventName","on","once","prependListener","prependOnceListener","removeListener","connect","options","reconnect","createChannel","close","isConnected","channelCount","AmqpConnectionManager","_channels","_currentUrl","_closed","_cancelRetriesHandler","_connectPromise","_currentConnection","_findServers","_urls","constructor","_connect","default"],"sources":["../../../node_modules/.pnpm/amqp-connection-manager@5.0.0_amqplib@0.10.9/node_modules/amqp-connection-manager/dist/types/AmqpConnectionManager.d.ts","../src/errors.ts","../src/types.ts","../src/worker.ts","../src/handlers.ts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;KAKYM,aAAAA,YAAyBN,IAA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BA;iBIiEgB,aAAA,mBACI,kBAAA,gBACJ,kBAAA,CAAmB,SAAA,EAAA,CAEjC,QAAA,EAAU,SAAA,EACV,YAAA,EAAc,KAAA,EACd,OAAA,EAAS,0BAAA,CAA2B,SAAA,EAAW,KAAA,IAC9C,+BAAA,CAAgC,SAAA,EAAW,KAAA;AAAA,iBAC9B,aAAA,mBACI,kBAAA,gBACJ,kBAAA,CAAmB,SAAA,EAAA,CAEjC,QAAA,EAAU,SAAA,EACV,YAAA,EAAc,KAAA,EACd,OAAA,EAAS,0BAAA,CAA2B,SAAA,EAAW,KAAA,GAC/C,OAAA;EAAW,QAAA;AAAA,IACV,+BAAA,CAAgC,SAAA,EAAW,KAAA;;;;;;;;;;;;;;;;;;;;;;;;AHnH9C;;;;;;iBGkKgB,cAAA,mBAAiC,kBAAA,CAAA,CAC/C,QAAA,EAAU,SAAA,EACV,QAAA,EAAU,2BAAA,CAA4B,SAAA,IACrC,2BAAA,CAA4B,SAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
import { Logger, TechnicalError, TelemetryProvider } from "@amqp-contract/core";
|
|
2
|
-
import { ConsumerDefinition, ConsumerEntry,
|
|
2
|
+
import { ConsumerDefinition, ConsumerEntry, ContractDefinition, InferConsumerNames, MessageDefinition } from "@amqp-contract/contract";
|
|
3
3
|
import { Future, Result } from "@swan-io/boxed";
|
|
4
|
-
import
|
|
4
|
+
import * as amqp from "amqplib";
|
|
5
5
|
import { ConsumeMessage } from "amqplib";
|
|
6
|
+
import { TcpSocketConnectOpts } from "net";
|
|
7
|
+
import { ConnectionOptions } from "tls";
|
|
6
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
9
|
|
|
10
|
+
//#region ../../node_modules/.pnpm/amqp-connection-manager@5.0.0_amqplib@0.10.9/node_modules/amqp-connection-manager/dist/types/AmqpConnectionManager.d.ts
|
|
11
|
+
type ConnectionUrl = string | amqp.Options.Connect | {
|
|
12
|
+
url: string;
|
|
13
|
+
connectionOptions?: AmqpConnectionOptions;
|
|
14
|
+
};
|
|
15
|
+
type AmqpConnectionOptions = (ConnectionOptions | TcpSocketConnectOpts) & {
|
|
16
|
+
noDelay?: boolean;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
keepAlive?: boolean;
|
|
19
|
+
keepAliveDelay?: number;
|
|
20
|
+
clientProperties?: any;
|
|
21
|
+
credentials?: {
|
|
22
|
+
mechanism: string;
|
|
23
|
+
username: string;
|
|
24
|
+
password: string;
|
|
25
|
+
response: () => Buffer;
|
|
26
|
+
} | {
|
|
27
|
+
mechanism: string;
|
|
28
|
+
response: () => Buffer;
|
|
29
|
+
} | undefined;
|
|
30
|
+
};
|
|
31
|
+
interface AmqpConnectionManagerOptions {
|
|
32
|
+
/** Interval to send heartbeats to broker. Defaults to 5 seconds. */
|
|
33
|
+
heartbeatIntervalInSeconds?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The time to wait before trying to reconnect. If not specified, defaults
|
|
36
|
+
* to `heartbeatIntervalInSeconds`.
|
|
37
|
+
*/
|
|
38
|
+
reconnectTimeInSeconds?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* `findServers` is a function that which returns one or more servers to
|
|
41
|
+
* connect to. This should return either a single URL or an array of URLs.
|
|
42
|
+
* This is handy when you're using a service discovery mechanism such as
|
|
43
|
+
* Consul or etcd. Instead of taking a callback, this can also return a
|
|
44
|
+
* Promise. Note that if this is supplied, then `urls` is ignored.
|
|
45
|
+
*/
|
|
46
|
+
findServers?: ((callback: (urls: ConnectionUrl | ConnectionUrl[]) => void) => void) | (() => Promise<ConnectionUrl | ConnectionUrl[]>) | undefined;
|
|
47
|
+
/** Connection options, passed as options to the amqplib.connect() method. */
|
|
48
|
+
connectionOptions?: AmqpConnectionOptions;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
8
51
|
//#region src/errors.d.ts
|
|
9
52
|
/**
|
|
10
53
|
* Error thrown when message validation fails
|
|
@@ -184,20 +227,20 @@ type ConsumerInferHeadersInput<TConsumer extends ConsumerEntry> = ExtractConsume
|
|
|
184
227
|
/**
|
|
185
228
|
* Infer all consumers from contract
|
|
186
229
|
*/
|
|
187
|
-
type InferConsumers<TContract extends
|
|
230
|
+
type InferConsumers<TContract extends ContractDefinition> = NonNullable<TContract["consumers"]>;
|
|
188
231
|
/**
|
|
189
232
|
* Get specific consumer entry from contract
|
|
190
233
|
*/
|
|
191
|
-
type InferConsumer<TContract extends
|
|
234
|
+
type InferConsumer<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = InferConsumers<TContract>[TName];
|
|
192
235
|
/**
|
|
193
236
|
* Infer the payload type for a specific consumer
|
|
194
237
|
*/
|
|
195
|
-
type WorkerInferConsumerPayload<TContract extends
|
|
238
|
+
type WorkerInferConsumerPayload<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = ConsumerInferPayloadInput<InferConsumer<TContract, TName>>;
|
|
196
239
|
/**
|
|
197
240
|
* Infer the headers type for a specific consumer
|
|
198
241
|
* Returns undefined if no headers schema is defined
|
|
199
242
|
*/
|
|
200
|
-
type WorkerInferConsumerHeaders<TContract extends
|
|
243
|
+
type WorkerInferConsumerHeaders<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = ConsumerInferHeadersInput<InferConsumer<TContract, TName>>;
|
|
201
244
|
/**
|
|
202
245
|
* A consumed message containing parsed payload and headers.
|
|
203
246
|
*
|
|
@@ -218,17 +261,15 @@ type WorkerInferConsumerHeaders<TContract extends ContractDefinitionInput, TName
|
|
|
218
261
|
* });
|
|
219
262
|
* ```
|
|
220
263
|
*/
|
|
221
|
-
type WorkerConsumedMessage<TPayload, THeaders
|
|
222
|
-
/** The validated message payload */
|
|
223
|
-
|
|
224
|
-
/** The validated message headers (present only when headers schema is defined) */
|
|
225
|
-
headers: THeaders$1 extends undefined ? undefined : THeaders$1;
|
|
264
|
+
type WorkerConsumedMessage<TPayload, THeaders = undefined> = {
|
|
265
|
+
/** The validated message payload */payload: TPayload; /** The validated message headers (present only when headers schema is defined) */
|
|
266
|
+
headers: THeaders extends undefined ? undefined : THeaders;
|
|
226
267
|
};
|
|
227
268
|
/**
|
|
228
269
|
* Infer the full consumed message type for a specific consumer.
|
|
229
270
|
* Includes both payload and headers (if defined).
|
|
230
271
|
*/
|
|
231
|
-
type WorkerInferConsumedMessage<TContract extends
|
|
272
|
+
type WorkerInferConsumedMessage<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerConsumedMessage<WorkerInferConsumerPayload<TContract, TName>, WorkerInferConsumerHeaders<TContract, TName>>;
|
|
232
273
|
/**
|
|
233
274
|
* Consumer handler type for a specific consumer.
|
|
234
275
|
* Returns a `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
@@ -253,7 +294,7 @@ type WorkerInferConsumedMessage<TContract extends ContractDefinitionInput, TName
|
|
|
253
294
|
* };
|
|
254
295
|
* ```
|
|
255
296
|
*/
|
|
256
|
-
type WorkerInferConsumerHandler<TContract extends
|
|
297
|
+
type WorkerInferConsumerHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = (message: WorkerInferConsumedMessage<TContract, TName>, rawMessage: ConsumeMessage) => Future<Result<void, HandlerError>>;
|
|
257
298
|
/**
|
|
258
299
|
* Handler entry for a consumer - either a function or a tuple of [handler, options].
|
|
259
300
|
*
|
|
@@ -264,7 +305,7 @@ type WorkerInferConsumerHandler<TContract extends ContractDefinitionInput, TName
|
|
|
264
305
|
* Note: Retry configuration is now defined at the queue level in the contract,
|
|
265
306
|
* not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
266
307
|
*/
|
|
267
|
-
type WorkerInferConsumerHandlerEntry<TContract extends
|
|
308
|
+
type WorkerInferConsumerHandlerEntry<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandler<TContract, TName> | readonly [WorkerInferConsumerHandler<TContract, TName>, {
|
|
268
309
|
prefetch?: number;
|
|
269
310
|
}];
|
|
270
311
|
/**
|
|
@@ -281,19 +322,19 @@ type WorkerInferConsumerHandlerEntry<TContract extends ContractDefinitionInput,
|
|
|
281
322
|
* };
|
|
282
323
|
* ```
|
|
283
324
|
*/
|
|
284
|
-
type WorkerInferConsumerHandlers<TContract extends
|
|
325
|
+
type WorkerInferConsumerHandlers<TContract extends ContractDefinition> = { [K in InferConsumerNames<TContract>]: WorkerInferConsumerHandlerEntry<TContract, K> };
|
|
285
326
|
/**
|
|
286
327
|
* @deprecated Use `WorkerInferConsumerHandler` instead. Will be removed in next major version.
|
|
287
328
|
*/
|
|
288
|
-
type WorkerInferSafeConsumerHandler<TContract extends
|
|
329
|
+
type WorkerInferSafeConsumerHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandler<TContract, TName>;
|
|
289
330
|
/**
|
|
290
331
|
* @deprecated Use `WorkerInferConsumerHandlerEntry` instead. Will be removed in next major version.
|
|
291
332
|
*/
|
|
292
|
-
type WorkerInferSafeConsumerHandlerEntry<TContract extends
|
|
333
|
+
type WorkerInferSafeConsumerHandlerEntry<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>> = WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
293
334
|
/**
|
|
294
335
|
* @deprecated Use `WorkerInferConsumerHandlers` instead. Will be removed in next major version.
|
|
295
336
|
*/
|
|
296
|
-
type WorkerInferSafeConsumerHandlers<TContract extends
|
|
337
|
+
type WorkerInferSafeConsumerHandlers<TContract extends ContractDefinition> = WorkerInferConsumerHandlers<TContract>;
|
|
297
338
|
//#endregion
|
|
298
339
|
//#region src/worker.d.ts
|
|
299
340
|
/**
|
|
@@ -331,20 +372,16 @@ type WorkerInferSafeConsumerHandlers<TContract extends ContractDefinitionInput>
|
|
|
331
372
|
* Note: Retry configuration is defined at the queue level in the contract,
|
|
332
373
|
* not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
333
374
|
*/
|
|
334
|
-
type CreateWorkerOptions<TContract extends
|
|
335
|
-
/** The AMQP contract definition specifying consumers and their message schemas */
|
|
336
|
-
contract: TContract;
|
|
375
|
+
type CreateWorkerOptions<TContract extends ContractDefinition> = {
|
|
376
|
+
/** The AMQP contract definition specifying consumers and their message schemas */contract: TContract;
|
|
337
377
|
/**
|
|
338
378
|
* Handlers for each consumer defined in the contract.
|
|
339
379
|
* Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
340
380
|
* Use defineHandler() to create handlers.
|
|
341
381
|
*/
|
|
342
|
-
handlers: WorkerInferConsumerHandlers<TContract>;
|
|
343
|
-
/**
|
|
344
|
-
|
|
345
|
-
/** Optional connection configuration (heartbeat, reconnect settings, etc.) */
|
|
346
|
-
connectionOptions?: AmqpConnectionManagerOptions | undefined;
|
|
347
|
-
/** Optional logger for logging message consumption and errors */
|
|
382
|
+
handlers: WorkerInferConsumerHandlers<TContract>; /** AMQP broker URL(s). Multiple URLs provide failover support */
|
|
383
|
+
urls: ConnectionUrl[]; /** Optional connection configuration (heartbeat, reconnect settings, etc.) */
|
|
384
|
+
connectionOptions?: AmqpConnectionManagerOptions | undefined; /** Optional logger for logging message consumption and errors */
|
|
348
385
|
logger?: Logger | undefined;
|
|
349
386
|
/**
|
|
350
387
|
* Optional telemetry provider for tracing and metrics.
|
|
@@ -364,17 +401,18 @@ type CreateWorkerOptions<TContract extends ContractDefinitionInput> = {
|
|
|
364
401
|
* @example
|
|
365
402
|
* ```typescript
|
|
366
403
|
* import { TypedAmqpWorker } from '@amqp-contract/worker';
|
|
404
|
+
* import { defineQueue, defineMessage, defineContract, defineConsumer } from '@amqp-contract/contract';
|
|
367
405
|
* import { z } from 'zod';
|
|
368
406
|
*
|
|
407
|
+
* const orderQueue = defineQueue('order-processing', { durable: true });
|
|
408
|
+
* const orderMessage = defineMessage(z.object({
|
|
409
|
+
* orderId: z.string(),
|
|
410
|
+
* amount: z.number()
|
|
411
|
+
* }));
|
|
412
|
+
*
|
|
369
413
|
* const contract = defineContract({
|
|
370
|
-
* queues: {
|
|
371
|
-
* orderProcessing: defineQueue('order-processing', { durable: true })
|
|
372
|
-
* },
|
|
373
414
|
* consumers: {
|
|
374
|
-
* processOrder: defineConsumer(
|
|
375
|
-
* orderId: z.string(),
|
|
376
|
-
* amount: z.number()
|
|
377
|
-
* }))
|
|
415
|
+
* processOrder: defineConsumer(orderQueue, orderMessage)
|
|
378
416
|
* }
|
|
379
417
|
* });
|
|
380
418
|
*
|
|
@@ -393,7 +431,7 @@ type CreateWorkerOptions<TContract extends ContractDefinitionInput> = {
|
|
|
393
431
|
* await worker.close().resultToPromise();
|
|
394
432
|
* ```
|
|
395
433
|
*/
|
|
396
|
-
declare class TypedAmqpWorker<TContract extends
|
|
434
|
+
declare class TypedAmqpWorker<TContract extends ContractDefinition> {
|
|
397
435
|
private readonly contract;
|
|
398
436
|
private readonly amqpClient;
|
|
399
437
|
private readonly logger?;
|
|
@@ -430,7 +468,7 @@ declare class TypedAmqpWorker<TContract extends ContractDefinitionInput> {
|
|
|
430
468
|
* }).resultToPromise();
|
|
431
469
|
* ```
|
|
432
470
|
*/
|
|
433
|
-
static create<TContract extends
|
|
471
|
+
static create<TContract extends ContractDefinition>({
|
|
434
472
|
contract,
|
|
435
473
|
handlers,
|
|
436
474
|
urls,
|
|
@@ -607,8 +645,8 @@ declare class TypedAmqpWorker<TContract extends ContractDefinitionInput> {
|
|
|
607
645
|
* );
|
|
608
646
|
* ```
|
|
609
647
|
*/
|
|
610
|
-
declare function defineHandler<TContract extends
|
|
611
|
-
declare function defineHandler<TContract extends
|
|
648
|
+
declare function defineHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>>(contract: TContract, consumerName: TName, handler: WorkerInferConsumerHandler<TContract, TName>): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
649
|
+
declare function defineHandler<TContract extends ContractDefinition, TName extends InferConsumerNames<TContract>>(contract: TContract, consumerName: TName, handler: WorkerInferConsumerHandler<TContract, TName>, options: {
|
|
612
650
|
prefetch?: number;
|
|
613
651
|
}): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
614
652
|
/**
|
|
@@ -640,7 +678,7 @@ declare function defineHandler<TContract extends ContractDefinitionInput, TName
|
|
|
640
678
|
* });
|
|
641
679
|
* ```
|
|
642
680
|
*/
|
|
643
|
-
declare function defineHandlers<TContract extends
|
|
681
|
+
declare function defineHandlers<TContract extends ContractDefinition>(contract: TContract, handlers: WorkerInferConsumerHandlers<TContract>): WorkerInferConsumerHandlers<TContract>;
|
|
644
682
|
//#endregion
|
|
645
683
|
export { type CreateWorkerOptions, type HandlerError, MessageValidationError, NonRetryableError, RetryableError, TypedAmqpWorker, type WorkerConsumedMessage, type WorkerInferConsumedMessage, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlerEntry, type WorkerInferConsumerHandlers, type WorkerInferConsumerHeaders, type WorkerInferSafeConsumerHandler, type WorkerInferSafeConsumerHandlerEntry, type WorkerInferSafeConsumerHandlers, defineHandler, defineHandlers, isHandlerError, isNonRetryableError, isRetryableError, nonRetryable, retryable };
|
|
646
684
|
//# sourceMappingURL=index.d.mts.map
|