@amqp-contract/client 0.3.0 → 0.3.2

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
@@ -72,69 +72,7 @@ publish(): Result<boolean, TechnicalError | MessageValidationError>
72
72
 
73
73
  ## API
74
74
 
75
- ### `TypedAmqpClient.create(options)`
76
-
77
- Create a type-safe AMQP client from a contract. Automatically connects to RabbitMQ and waits for the connection to be ready.
78
-
79
- **Parameters:**
80
-
81
- - `options.contract` - Contract definition
82
- - `options.urls` - Array of AMQP connection URLs (e.g., `['amqp://localhost']`)
83
- - `options.connectionOptions` - Optional connection manager options
84
-
85
- **Returns:** `Future<Result<TypedAmqpClient, TechnicalError>>`
86
-
87
- The method returns a Future that resolves to a Result. You must:
88
-
89
- 1. Await the Future to get the Result
90
- 2. Check if the Result is Ok or Error
91
- 3. Extract the client using `.get()` if successful
92
-
93
- **Example:**
94
-
95
- ```typescript
96
- const clientResult = await TypedAmqpClient.create({ contract, urls: ['amqp://localhost'] });
97
- if (clientResult.isError()) {
98
- throw clientResult.error; // Handle connection error
99
- }
100
- const client = clientResult.get();
101
- ```
102
-
103
- ### `TypedAmqpClient.publish(publisherName, message, options?)`
104
-
105
- Publish a message using a defined publisher. The message will be validated against the schema and type-checked at compile time.
106
-
107
- **Parameters:**
108
-
109
- - `publisherName` - Name of the publisher (type-checked against contract)
110
- - `message` - Message payload (type-checked against publisher schema)
111
- - `options` - Optional publish options (e.g., headers, priority)
112
-
113
- **Returns:** `Result<boolean, TechnicalError | MessageValidationError>`
114
-
115
- **Example:**
116
-
117
- ```typescript
118
- const result = client.publish('orderCreated', { orderId: '123' });
119
-
120
- if (result.isOk()) {
121
- // Message published successfully
122
- console.log('Published:', result.value); // true
123
- } else {
124
- // Handle specific error types
125
- if (result.error instanceof MessageValidationError) {
126
- console.error('Validation failed:', result.error.issues);
127
- } else if (result.error instanceof TechnicalError) {
128
- console.error('Technical error:', result.error.message);
129
- }
130
- }
131
- ```
132
-
133
- ### `TypedAmqpClient.close()`
134
-
135
- Close the channel and connection.
136
-
137
- **Returns:** `Promise<void>`
75
+ For complete API documentation, see the [Client API Reference](https://btravers.github.io/amqp-contract/api/client).
138
76
 
139
77
  ## Documentation
140
78
 
package/dist/index.cjs CHANGED
@@ -42,9 +42,10 @@ var MessageValidationError = class extends ClientError {
42
42
  * Type-safe AMQP client for publishing messages
43
43
  */
44
44
  var TypedAmqpClient = class TypedAmqpClient {
45
- constructor(contract, amqpClient) {
45
+ constructor(contract, amqpClient, logger) {
46
46
  this.contract = contract;
47
47
  this.amqpClient = amqpClient;
48
+ this.logger = logger;
48
49
  }
49
50
  /**
50
51
  * Create a type-safe AMQP client from a contract.
@@ -53,11 +54,11 @@ var TypedAmqpClient = class TypedAmqpClient {
53
54
  * by amqp-connection-manager via the {@link AmqpClient}. The client establishes
54
55
  * infrastructure asynchronously in the background once the connection is ready.
55
56
  */
56
- static create({ contract, urls, connectionOptions }) {
57
+ static create({ contract, urls, connectionOptions, logger }) {
57
58
  const client = new TypedAmqpClient(contract, new _amqp_contract_core.AmqpClient(contract, {
58
59
  urls,
59
60
  connectionOptions
60
- }));
61
+ }), logger);
61
62
  return client.waitForConnectionReady().mapOk(() => client);
62
63
  }
63
64
  /**
@@ -79,6 +80,11 @@ var TypedAmqpClient = class TypedAmqpClient {
79
80
  const publishMessage = (validatedMessage) => {
80
81
  return _swan_io_boxed.Future.fromPromise(this.amqpClient.channel.publish(publisher.exchange.name, publisher.routingKey ?? "", validatedMessage, options)).mapError((error) => new TechnicalError(`Failed to publish message`, error)).mapOkToResult((published) => {
81
82
  if (!published) return _swan_io_boxed.Result.Error(new TechnicalError(`Failed to publish message for publisher "${String(publisherName)}": Channel rejected the message (buffer full or other channel issue)`));
83
+ this.logger?.info("Message published successfully", {
84
+ publisherName: String(publisherName),
85
+ exchange: publisher.exchange.name,
86
+ routingKey: publisher.routingKey
87
+ });
82
88
  return _swan_io_boxed.Result.Ok(published);
83
89
  });
84
90
  };
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import { Options } from "amqplib";
2
2
  import { ContractDefinition, InferPublisherNames, PublisherDefinition } from "@amqp-contract/contract";
3
3
  import { Future, Result } from "@swan-io/boxed";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
+ import { Logger } from "@amqp-contract/core";
5
6
  import { AmqpConnectionManagerOptions, ConnectionUrl } from "amqp-connection-manager";
6
7
 
7
8
  //#region src/errors.d.ts
@@ -58,6 +59,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
58
59
  contract: TContract;
59
60
  urls: ConnectionUrl[];
60
61
  connectionOptions?: AmqpConnectionManagerOptions | undefined;
62
+ logger?: Logger | undefined;
61
63
  };
62
64
  /**
63
65
  * Type-safe AMQP client for publishing messages
@@ -65,6 +67,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
65
67
  declare class TypedAmqpClient<TContract extends ContractDefinition> {
66
68
  private readonly contract;
67
69
  private readonly amqpClient;
70
+ private readonly logger?;
68
71
  private constructor();
69
72
  /**
70
73
  * Create a type-safe AMQP client from a contract.
@@ -76,7 +79,8 @@ declare class TypedAmqpClient<TContract extends ContractDefinition> {
76
79
  static create<TContract extends ContractDefinition>({
77
80
  contract,
78
81
  urls,
79
- connectionOptions
82
+ connectionOptions,
83
+ logger
80
84
  }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>>;
81
85
  /**
82
86
  * Publish a message using a defined publisher
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;uBAGe,WAAA,SAAoB,KAAA;;;;;AAkBnC;AAaA;cAba,cAAA,SAAuB,WAAA;;;AChBH;;;;AAMC,cDuBrB,sBAAA,SAA+B,WAAA,CCvBV;EAK7B,SAAA,aAAmB,EAAA,MAAA;EAAoB,SAAA,MAAA,EAAA,OAAA;EAC1C,WA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AA;;;;;ADIF;AAaa,KEvBD,mBFuBwB,CAAA,kBEvBc,kBFuBK,CAAA,GAAA;YEtB3C;QACJ;sBACc;EDJjB,MAAA,CAAA,ECKM,MDLN,GAAA,SAAgB;CAAiB;;;;AAMjC,cCKQ,eDLW,CAAA,kBCKuB,kBDLvB,CAAA,CAAA;EAAoB,iBAAA,QAAA;EAC1C,iBAAA,UAAA;EADiE,iBAAA,MAAA;EAAgB,QAAA,WAAA,CAAA;EAO9E;;;;;AAAmE;;EAOpC,OAAA,MAAA,CAAA,kBCKF,kBDLE,CAAA,CAAA;IAAA,QAAA;IAAA,IAAA;IAAA,iBAAA;IAAA;EAAA,CAAA,ECU/B,mBDV+B,CCUX,SDVW,CAAA,CAAA,ECUE,MDVF,CCUS,MDVT,CCUgB,eDVhB,CCUgC,SDVhC,CAAA,ECU4C,cDV5C,CAAA,CAAA;EAApB;;;;EACoB,OAAA,CAAA,cCuBZ,mBDvBY,CCuBQ,SDvBR,CAAA,CAAA,CAAA,aAAA,ECwBjB,KDxBiB,EAAA,OAAA,ECyBvB,yBDzBuB,CCyBG,SDzBH,ECyBc,KDzBd,CAAA,EAAA,OAAA,CAAA,EC0BtB,OAAA,CAAQ,OD1Bc,CAAA,EC2B/B,MD3B+B,CC2BxB,MD3BwB,CAAA,OAAA,EC2BR,cD3BQ,GC2BS,sBD3BT,CAAA,CAAA;EAKxB;;;EAEI,KAAA,CAAA,CAAA,ECwFL,MDxFK,CCwFE,MDxFF,CAAA,IAAA,ECwFe,cDxFf,CAAA,CAAA;EACuB,QAAA,sBAAA"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Future, Result } from "@swan-io/boxed";
2
+ import { Logger } from "@amqp-contract/core";
2
3
  import { Options } from "amqplib";
3
4
  import { ContractDefinition, InferPublisherNames, PublisherDefinition } from "@amqp-contract/contract";
4
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -58,6 +59,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
58
59
  contract: TContract;
59
60
  urls: ConnectionUrl[];
60
61
  connectionOptions?: AmqpConnectionManagerOptions | undefined;
62
+ logger?: Logger | undefined;
61
63
  };
62
64
  /**
63
65
  * Type-safe AMQP client for publishing messages
@@ -65,6 +67,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
65
67
  declare class TypedAmqpClient<TContract extends ContractDefinition> {
66
68
  private readonly contract;
67
69
  private readonly amqpClient;
70
+ private readonly logger?;
68
71
  private constructor();
69
72
  /**
70
73
  * Create a type-safe AMQP client from a contract.
@@ -76,7 +79,8 @@ declare class TypedAmqpClient<TContract extends ContractDefinition> {
76
79
  static create<TContract extends ContractDefinition>({
77
80
  contract,
78
81
  urls,
79
- connectionOptions
82
+ connectionOptions,
83
+ logger
80
84
  }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>>;
81
85
  /**
82
86
  * Publish a message using a defined publisher
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;uBAGe,WAAA,SAAoB,KAAA;;;;;AAkBnC;AAaA;cAba,cAAA,SAAuB,WAAA;;;AChBH;;;;AAMC,cDuBrB,sBAAA,SAA+B,WAAA,CCvBV;EAK7B,SAAA,aAAmB,EAAA,MAAA;EAAoB,SAAA,MAAA,EAAA,OAAA;EAC1C,WAAA,CAAA,aAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA;;;;;;;KAPG,iCAAiC,oBACpC,gBAAgB;;;ADUlB;AAaA,KClBK,mBDkBQ,CAAA,mBClB+B,mBDkBW,CAAA,GClBY,gBDkBZ,CCjBrD,UDiBqD,CAAA,SAAA,CAAA,CAAA,SAAA,CAAA,CAAA;;;;AC7BtB,KAkB5B,eAbA,CAAA,kBAakC,kBAblB,CAAA,GAawC,WAbxC,CAaoD,SAbpD,CAAA,YAAA,CAAA,CAAA;;;;KAkBhB,cAjB6B,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CAAA,CAAA;IAAA,QAAA;IAAA,IAAA;IAAA,iBAAA;IAAA;EAAA,CAAA,ECU/B,mBDV+B,CCUX,SDVW,CAAA,CAAA,ECUE,MDVF,CCUS,MDVT,CCUgB,eDVhB,CCUgC,SDVhC,CAAA,ECU4C,cDV5C,CAAA,CAAA;EAApB;;;;EACoB,OAAA,CAAA,cCuBZ,mBDvBY,CCuBQ,SDvBR,CAAA,CAAA,CAAA,aAAA,ECwBjB,KDxBiB,EAAA,OAAA,ECyBvB,yBDzBuB,CCyBG,SDzBH,ECyBc,KDzBd,CAAA,EAAA,OAAA,CAAA,EC0BtB,OAAA,CAAQ,OD1Bc,CAAA,EC2B/B,MD3B+B,CC2BxB,MD3BwB,CAAA,OAAA,EC2BR,cD3BQ,GC2BS,sBD3BT,CAAA,CAAA;EAKxB;;;EAEI,KAAA,CAAA,CAAA,ECwFL,MDxFK,CCwFE,MDxFF,CAAA,IAAA,ECwFe,cDxFf,CAAA,CAAA;EACuB,QAAA,sBAAA"}
package/dist/index.mjs CHANGED
@@ -42,9 +42,10 @@ var MessageValidationError = class extends ClientError {
42
42
  * Type-safe AMQP client for publishing messages
43
43
  */
44
44
  var TypedAmqpClient = class TypedAmqpClient {
45
- constructor(contract, amqpClient) {
45
+ constructor(contract, amqpClient, logger) {
46
46
  this.contract = contract;
47
47
  this.amqpClient = amqpClient;
48
+ this.logger = logger;
48
49
  }
49
50
  /**
50
51
  * Create a type-safe AMQP client from a contract.
@@ -53,11 +54,11 @@ var TypedAmqpClient = class TypedAmqpClient {
53
54
  * by amqp-connection-manager via the {@link AmqpClient}. The client establishes
54
55
  * infrastructure asynchronously in the background once the connection is ready.
55
56
  */
56
- static create({ contract, urls, connectionOptions }) {
57
+ static create({ contract, urls, connectionOptions, logger }) {
57
58
  const client = new TypedAmqpClient(contract, new AmqpClient(contract, {
58
59
  urls,
59
60
  connectionOptions
60
- }));
61
+ }), logger);
61
62
  return client.waitForConnectionReady().mapOk(() => client);
62
63
  }
63
64
  /**
@@ -79,6 +80,11 @@ var TypedAmqpClient = class TypedAmqpClient {
79
80
  const publishMessage = (validatedMessage) => {
80
81
  return Future.fromPromise(this.amqpClient.channel.publish(publisher.exchange.name, publisher.routingKey ?? "", validatedMessage, options)).mapError((error) => new TechnicalError(`Failed to publish message`, error)).mapOkToResult((published) => {
81
82
  if (!published) return Result.Error(new TechnicalError(`Failed to publish message for publisher "${String(publisherName)}": Channel rejected the message (buffer full or other channel issue)`));
83
+ this.logger?.info("Message published successfully", {
84
+ publisherName: String(publisherName),
85
+ exchange: publisher.exchange.name,
86
+ routingKey: publisher.routingKey
87
+ });
82
88
  return Result.Ok(published);
83
89
  });
84
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["cause?: unknown","publisherName: string","issues: unknown","contract: TContract","amqpClient: AmqpClient"],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["/**\n * Base error class for client errors\n */\nabstract class ClientError extends Error {\n protected constructor(message: string) {\n super(message);\n this.name = \"ClientError\";\n // Node.js specific stack trace capture\n const ErrorConstructor = Error as unknown as {\n captureStackTrace?: (target: object, constructor: Function) => void;\n };\n if (typeof ErrorConstructor.captureStackTrace === \"function\") {\n ErrorConstructor.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for technical/runtime failures that cannot be prevented by TypeScript\n * This includes validation failures and AMQP channel issues\n */\nexport class TechnicalError extends ClientError {\n constructor(\n message: string,\n public override readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"TechnicalError\";\n }\n}\n\n/**\n * Error thrown when message validation fails\n */\nexport class MessageValidationError extends ClientError {\n constructor(\n public readonly publisherName: string,\n public readonly issues: unknown,\n ) {\n super(`Message validation failed for publisher \"${publisherName}\"`);\n this.name = \"MessageValidationError\";\n }\n}\n","import type { Options } from \"amqplib\";\nimport type { ContractDefinition, InferPublisherNames } from \"@amqp-contract/contract\";\nimport { Future, Result } from \"@swan-io/boxed\";\nimport { MessageValidationError, TechnicalError } from \"./errors.js\";\nimport type { ClientInferPublisherInput } from \"./types.js\";\nimport { AmqpClient } from \"@amqp-contract/core\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\n\n/**\n * Options for creating a client\n */\nexport type CreateClientOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n urls: ConnectionUrl[];\n connectionOptions?: AmqpConnectionManagerOptions | undefined;\n};\n\n/**\n * Type-safe AMQP client for publishing messages\n */\nexport class TypedAmqpClient<TContract extends ContractDefinition> {\n private constructor(\n private readonly contract: TContract,\n private readonly amqpClient: AmqpClient,\n ) {}\n\n /**\n * Create a type-safe AMQP client from a contract.\n *\n * Connection management (including automatic reconnection) is handled internally\n * by amqp-connection-manager via the {@link AmqpClient}. The client establishes\n * infrastructure asynchronously in the background once the connection is ready.\n */\n static create<TContract extends ContractDefinition>({\n contract,\n urls,\n connectionOptions,\n }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>> {\n const client = new TypedAmqpClient(\n contract,\n new AmqpClient(contract, { urls, connectionOptions }),\n );\n\n return client.waitForConnectionReady().mapOk(() => client);\n }\n\n /**\n * Publish a message using a defined publisher\n * Returns Result.Ok(true) on success, or Result.Error with specific error on failure\n */\n publish<TName extends InferPublisherNames<TContract>>(\n publisherName: TName,\n message: ClientInferPublisherInput<TContract, TName>,\n options?: Options.Publish,\n ): Future<Result<boolean, TechnicalError | MessageValidationError>> {\n const publishers = this.contract.publishers;\n if (!publishers) {\n return Future.value(Result.Error(new TechnicalError(\"No publishers defined in contract\")));\n }\n\n const publisher = publishers[publisherName as string];\n if (!publisher) {\n return Future.value(\n Result.Error(\n new TechnicalError(`Publisher \"${String(publisherName)}\" not found in contract`),\n ),\n );\n }\n\n const validateMessage = () => {\n const validationResult = publisher.message.payload[\"~standard\"].validate(message);\n return Future.fromPromise(\n validationResult instanceof Promise ? validationResult : Promise.resolve(validationResult),\n )\n .mapError((error) => new TechnicalError(`Validation failed`, error))\n .mapOkToResult((validation) => {\n if (validation.issues) {\n return Result.Error(\n new MessageValidationError(String(publisherName), validation.issues),\n );\n }\n\n return Result.Ok(validation.value);\n });\n };\n\n const publishMessage = (validatedMessage: unknown) => {\n return Future.fromPromise(\n this.amqpClient.channel.publish(\n publisher.exchange.name,\n publisher.routingKey ?? \"\",\n validatedMessage,\n options,\n ),\n )\n .mapError((error) => new TechnicalError(`Failed to publish message`, error))\n .mapOkToResult((published) => {\n if (!published) {\n return Result.Error(\n new TechnicalError(\n `Failed to publish message for publisher \"${String(publisherName)}\": Channel rejected the message (buffer full or other channel issue)`,\n ),\n );\n }\n\n return Result.Ok(published);\n });\n };\n\n // Validate message using schema\n return validateMessage().flatMapOk((validatedMessage) => publishMessage(validatedMessage));\n }\n\n /**\n * Close the channel and connection\n */\n close(): Future<Result<void, TechnicalError>> {\n return Future.fromPromise(this.amqpClient.close())\n .mapError((error) => new TechnicalError(\"Failed to close AMQP connection\", error))\n .mapOk(() => undefined);\n }\n\n private waitForConnectionReady(): Future<Result<void, TechnicalError>> {\n return Future.fromPromise(this.amqpClient.channel.waitForConnect()).mapError(\n (error) => new TechnicalError(\"Failed to wait for connection ready\", error),\n );\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAe,cAAf,cAAmC,MAAM;CACvC,AAAU,YAAY,SAAiB;AACrC,QAAM,QAAQ;AACd,OAAK,OAAO;EAEZ,MAAM,mBAAmB;AAGzB,MAAI,OAAO,iBAAiB,sBAAsB,WAChD,kBAAiB,kBAAkB,MAAM,KAAK,YAAY;;;;;;;AAShE,IAAa,iBAAb,cAAoC,YAAY;CAC9C,YACE,SACA,AAAyBA,OACzB;AACA,QAAM,QAAQ;EAFW;AAGzB,OAAK,OAAO;;;;;;AAOhB,IAAa,yBAAb,cAA4C,YAAY;CACtD,YACE,AAAgBC,eAChB,AAAgBC,QAChB;AACA,QAAM,4CAA4C,cAAc,GAAG;EAHnD;EACA;AAGhB,OAAK,OAAO;;;;;;;;;ACpBhB,IAAa,kBAAb,MAAa,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AAO,iBAAiB,CAAC,WAAW,qBAAqB,eAAe,iBAAiB,CAAC;;;;;CAM5F,QAA8C;AAC5C,SAAO,OAAO,YAAY,KAAK,WAAW,OAAO,CAAC,CAC/C,UAAU,UAAU,IAAI,eAAe,mCAAmC,MAAM,CAAC,CACjF,YAAY,OAAU;;CAG3B,AAAQ,yBAA+D;AACrE,SAAO,OAAO,YAAY,KAAK,WAAW,QAAQ,gBAAgB,CAAC,CAAC,UACjE,UAAU,IAAI,eAAe,uCAAuC,MAAM,CAC5E"}
1
+ {"version":3,"file":"index.mjs","names":["cause?: unknown","publisherName: string","issues: unknown","contract: TContract","amqpClient: AmqpClient","logger?: Logger"],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["/**\n * Base error class for client errors\n */\nabstract class ClientError extends Error {\n protected constructor(message: string) {\n super(message);\n this.name = \"ClientError\";\n // Node.js specific stack trace capture\n const ErrorConstructor = Error as unknown as {\n captureStackTrace?: (target: object, constructor: Function) => void;\n };\n if (typeof ErrorConstructor.captureStackTrace === \"function\") {\n ErrorConstructor.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for technical/runtime failures that cannot be prevented by TypeScript\n * This includes validation failures and AMQP channel issues\n */\nexport class TechnicalError extends ClientError {\n constructor(\n message: string,\n public override readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"TechnicalError\";\n }\n}\n\n/**\n * Error thrown when message validation fails\n */\nexport class MessageValidationError extends ClientError {\n constructor(\n public readonly publisherName: string,\n public readonly issues: unknown,\n ) {\n super(`Message validation failed for publisher \"${publisherName}\"`);\n this.name = \"MessageValidationError\";\n }\n}\n","import type { Options } from \"amqplib\";\nimport type { ContractDefinition, InferPublisherNames } from \"@amqp-contract/contract\";\nimport { Future, Result } from \"@swan-io/boxed\";\nimport { MessageValidationError, TechnicalError } from \"./errors.js\";\nimport type { ClientInferPublisherInput } from \"./types.js\";\nimport { AmqpClient, type Logger } from \"@amqp-contract/core\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\n\n/**\n * Options for creating a client\n */\nexport type CreateClientOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n urls: ConnectionUrl[];\n connectionOptions?: AmqpConnectionManagerOptions | undefined;\n logger?: Logger | undefined;\n};\n\n/**\n * Type-safe AMQP client for publishing messages\n */\nexport class TypedAmqpClient<TContract extends ContractDefinition> {\n private constructor(\n private readonly contract: TContract,\n private readonly amqpClient: AmqpClient,\n private readonly logger?: Logger,\n ) {}\n\n /**\n * Create a type-safe AMQP client from a contract.\n *\n * Connection management (including automatic reconnection) is handled internally\n * by amqp-connection-manager via the {@link AmqpClient}. The client establishes\n * infrastructure asynchronously in the background once the connection is ready.\n */\n static create<TContract extends ContractDefinition>({\n contract,\n urls,\n connectionOptions,\n logger,\n }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>> {\n const client = new TypedAmqpClient(\n contract,\n new AmqpClient(contract, { urls, connectionOptions }),\n logger,\n );\n\n return client.waitForConnectionReady().mapOk(() => client);\n }\n\n /**\n * Publish a message using a defined publisher\n * Returns Result.Ok(true) on success, or Result.Error with specific error on failure\n */\n publish<TName extends InferPublisherNames<TContract>>(\n publisherName: TName,\n message: ClientInferPublisherInput<TContract, TName>,\n options?: Options.Publish,\n ): Future<Result<boolean, TechnicalError | MessageValidationError>> {\n const publishers = this.contract.publishers;\n if (!publishers) {\n return Future.value(Result.Error(new TechnicalError(\"No publishers defined in contract\")));\n }\n\n const publisher = publishers[publisherName as string];\n if (!publisher) {\n return Future.value(\n Result.Error(\n new TechnicalError(`Publisher \"${String(publisherName)}\" not found in contract`),\n ),\n );\n }\n\n const validateMessage = () => {\n const validationResult = publisher.message.payload[\"~standard\"].validate(message);\n return Future.fromPromise(\n validationResult instanceof Promise ? validationResult : Promise.resolve(validationResult),\n )\n .mapError((error) => new TechnicalError(`Validation failed`, error))\n .mapOkToResult((validation) => {\n if (validation.issues) {\n return Result.Error(\n new MessageValidationError(String(publisherName), validation.issues),\n );\n }\n\n return Result.Ok(validation.value);\n });\n };\n\n const publishMessage = (validatedMessage: unknown) => {\n return Future.fromPromise(\n this.amqpClient.channel.publish(\n publisher.exchange.name,\n publisher.routingKey ?? \"\",\n validatedMessage,\n options,\n ),\n )\n .mapError((error) => new TechnicalError(`Failed to publish message`, error))\n .mapOkToResult((published) => {\n if (!published) {\n return Result.Error(\n new TechnicalError(\n `Failed to publish message for publisher \"${String(publisherName)}\": Channel rejected the message (buffer full or other channel issue)`,\n ),\n );\n }\n\n this.logger?.info(\"Message published successfully\", {\n publisherName: String(publisherName),\n exchange: publisher.exchange.name,\n routingKey: publisher.routingKey,\n });\n\n return Result.Ok(published);\n });\n };\n\n // Validate message using schema\n return validateMessage().flatMapOk((validatedMessage) => publishMessage(validatedMessage));\n }\n\n /**\n * Close the channel and connection\n */\n close(): Future<Result<void, TechnicalError>> {\n return Future.fromPromise(this.amqpClient.close())\n .mapError((error) => new TechnicalError(\"Failed to close AMQP connection\", error))\n .mapOk(() => undefined);\n }\n\n private waitForConnectionReady(): Future<Result<void, TechnicalError>> {\n return Future.fromPromise(this.amqpClient.channel.waitForConnect()).mapError(\n (error) => new TechnicalError(\"Failed to wait for connection ready\", error),\n );\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAe,cAAf,cAAmC,MAAM;CACvC,AAAU,YAAY,SAAiB;AACrC,QAAM,QAAQ;AACd,OAAK,OAAO;EAEZ,MAAM,mBAAmB;AAGzB,MAAI,OAAO,iBAAiB,sBAAsB,WAChD,kBAAiB,kBAAkB,MAAM,KAAK,YAAY;;;;;;;AAShE,IAAa,iBAAb,cAAoC,YAAY;CAC9C,YACE,SACA,AAAyBA,OACzB;AACA,QAAM,QAAQ;EAFW;AAGzB,OAAK,OAAO;;;;;;AAOhB,IAAa,yBAAb,cAA4C,YAAY;CACtD,YACE,AAAgBC,eAChB,AAAgBC,QAChB;AACA,QAAM,4CAA4C,cAAc,GAAG;EAHnD;EACA;AAGhB,OAAK,O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,cAAc,CAAC,sEACnE,CACF;AAGH,SAAK,QAAQ,KAAK,kCAAkC;KAClD,eAAe,OAAO,cAAc;KACpC,UAAU,UAAU,SAAS;KAC7B,YAAY,UAAU;KACvB,CAAC;AAEF,WAAO,OAAO,GAAG,UAAU;KAC3B;;AAIN,SAAO,iBAAiB,CAAC,WAAW,qBAAqB,eAAe,iBAAiB,CAAC;;;;;CAM5F,QAA8C;AAC5C,SAAO,OAAO,YAAY,KAAK,WAAW,OAAO,CAAC,CAC/C,UAAU,UAAU,IAAI,eAAe,mCAAmC,MAAM,CAAC,CACjF,YAAY,OAAU;;CAG3B,AAAQ,yBAA+D;AACrE,SAAO,OAAO,YAAY,KAAK,WAAW,QAAQ,gBAAgB,CAAC,CAAC,UACjE,UAAU,IAAI,eAAe,uCAAuC,MAAM,CAC5E"}
package/docs/index.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### MessageValidationError
10
10
 
11
- Defined in: [packages/client/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L35)
11
+ Defined in: [packages/client/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L35)
12
12
 
13
13
  Error thrown when message validation fails
14
14
 
@@ -24,7 +24,7 @@ Error thrown when message validation fails
24
24
  new MessageValidationError(publisherName, issues): MessageValidationError;
25
25
  ```
26
26
 
27
- Defined in: [packages/client/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L36)
27
+ Defined in: [packages/client/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L36)
28
28
 
29
29
  ###### Parameters
30
30
 
@@ -48,10 +48,10 @@ ClientError.constructor
48
48
  | Property | Modifier | Type | Description | Inherited from | Defined in |
49
49
  | ------ | ------ | ------ | ------ | ------ | ------ |
50
50
  | <a id="cause"></a> `cause?` | `public` | `unknown` | - | `ClientError.cause` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 |
51
- | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/client/src/errors.ts:38](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L38) |
51
+ | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/client/src/errors.ts:38](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L38) |
52
52
  | <a id="message"></a> `message` | `public` | `string` | - | `ClientError.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
53
53
  | <a id="name"></a> `name` | `public` | `string` | - | `ClientError.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
54
- | <a id="publishername"></a> `publisherName` | `readonly` | `string` | - | - | [packages/client/src/errors.ts:37](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L37) |
54
+ | <a id="publishername"></a> `publisherName` | `readonly` | `string` | - | - | [packages/client/src/errors.ts:37](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L37) |
55
55
  | <a id="stack"></a> `stack?` | `public` | `string` | - | `ClientError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
56
56
  | <a id="stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `ClientError.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.0.3/node\_modules/@types/node/globals.d.ts:67 |
57
57
 
@@ -159,7 +159,7 @@ ClientError.prepareStackTrace
159
159
 
160
160
  ### TechnicalError
161
161
 
162
- Defined in: [packages/client/src/errors.ts:22](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L22)
162
+ Defined in: [packages/client/src/errors.ts:22](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L22)
163
163
 
164
164
  Error for technical/runtime failures that cannot be prevented by TypeScript
165
165
  This includes validation failures and AMQP channel issues
@@ -176,7 +176,7 @@ This includes validation failures and AMQP channel issues
176
176
  new TechnicalError(message, cause?): TechnicalError;
177
177
  ```
178
178
 
179
- Defined in: [packages/client/src/errors.ts:23](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L23)
179
+ Defined in: [packages/client/src/errors.ts:23](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L23)
180
180
 
181
181
  ###### Parameters
182
182
 
@@ -199,7 +199,7 @@ ClientError.constructor
199
199
 
200
200
  | Property | Modifier | Type | Description | Inherited from | Defined in |
201
201
  | ------ | ------ | ------ | ------ | ------ | ------ |
202
- | <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `ClientError.cause` | [packages/client/src/errors.ts:25](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/errors.ts#L25) |
202
+ | <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `ClientError.cause` | [packages/client/src/errors.ts:25](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/errors.ts#L25) |
203
203
  | <a id="message-1"></a> `message` | `public` | `string` | - | `ClientError.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
204
204
  | <a id="name-1"></a> `name` | `public` | `string` | - | `ClientError.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
205
205
  | <a id="stack-1"></a> `stack?` | `public` | `string` | - | `ClientError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
@@ -309,7 +309,7 @@ ClientError.prepareStackTrace
309
309
 
310
310
  ### TypedAmqpClient
311
311
 
312
- Defined in: [packages/client/src/client.ts:21](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L21)
312
+ Defined in: [packages/client/src/client.ts:22](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L22)
313
313
 
314
314
  Type-safe AMQP client for publishing messages
315
315
 
@@ -327,7 +327,7 @@ Type-safe AMQP client for publishing messages
327
327
  close(): Future<Result<void, TechnicalError>>;
328
328
  ```
329
329
 
330
- Defined in: [packages/client/src/client.ts:117](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L117)
330
+ Defined in: [packages/client/src/client.ts:127](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L127)
331
331
 
332
332
  Close the channel and connection
333
333
 
@@ -346,7 +346,7 @@ publish<TName>(
346
346
  | MessageValidationError>>;
347
347
  ```
348
348
 
349
- Defined in: [packages/client/src/client.ts:51](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L51)
349
+ Defined in: [packages/client/src/client.ts:55](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L55)
350
350
 
351
351
  Publish a message using a defined publisher
352
352
  Returns Result.Ok(true) on success, or Result.Error with specific error on failure
@@ -377,7 +377,7 @@ Returns Result.Ok(true) on success, or Result.Error with specific error on failu
377
377
  static create<TContract>(__namedParameters): Future<Result<TypedAmqpClient<TContract>, TechnicalError>>;
378
378
  ```
379
379
 
380
- Defined in: [packages/client/src/client.ts:34](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L34)
380
+ Defined in: [packages/client/src/client.ts:36](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L36)
381
381
 
382
382
  Create a type-safe AMQP client from a contract.
383
383
 
@@ -409,7 +409,7 @@ infrastructure asynchronously in the background once the connection is ready.
409
409
  type ClientInferPublisherInput<TContract, TName> = PublisherInferInput<InferPublisher<TContract, TName>>;
410
410
  ```
411
411
 
412
- Defined in: [packages/client/src/types.ts:37](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/types.ts#L37)
412
+ Defined in: [packages/client/src/types.ts:37](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/types.ts#L37)
413
413
 
414
414
  Infer publisher input type (message payload) for a specific publisher in a contract
415
415
 
@@ -428,7 +428,7 @@ Infer publisher input type (message payload) for a specific publisher in a contr
428
428
  type CreateClientOptions<TContract> = object;
429
429
  ```
430
430
 
431
- Defined in: [packages/client/src/client.ts:12](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L12)
431
+ Defined in: [packages/client/src/client.ts:12](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L12)
432
432
 
433
433
  Options for creating a client
434
434
 
@@ -442,6 +442,7 @@ Options for creating a client
442
442
 
443
443
  | Property | Type | Defined in |
444
444
  | ------ | ------ | ------ |
445
- | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | [packages/client/src/client.ts:15](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L15) |
446
- | <a id="contract"></a> `contract` | `TContract` | [packages/client/src/client.ts:13](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L13) |
447
- | <a id="urls"></a> `urls` | `ConnectionUrl`[] | [packages/client/src/client.ts:14](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/client/src/client.ts#L14) |
445
+ | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | [packages/client/src/client.ts:15](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L15) |
446
+ | <a id="contract"></a> `contract` | `TContract` | [packages/client/src/client.ts:13](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L13) |
447
+ | <a id="logger"></a> `logger?` | `Logger` | [packages/client/src/client.ts:16](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L16) |
448
+ | <a id="urls"></a> `urls` | `ConnectionUrl`[] | [packages/client/src/client.ts:14](https://github.com/btravers/amqp-contract/blob/2e0e3a372088cd269fea97fb73812491d1fc5e14/packages/client/src/client.ts#L14) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amqp-contract/client",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Client utilities for publishing messages using amqp-contract",
5
5
  "keywords": [
6
6
  "amqp",
@@ -44,8 +44,8 @@
44
44
  "dependencies": {
45
45
  "@standard-schema/spec": "1.1.0",
46
46
  "@swan-io/boxed": "3.2.1",
47
- "@amqp-contract/contract": "0.3.0",
48
- "@amqp-contract/core": "0.3.0"
47
+ "@amqp-contract/contract": "0.3.2",
48
+ "@amqp-contract/core": "0.3.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/amqplib": "0.10.8",
@@ -54,12 +54,12 @@
54
54
  "amqp-connection-manager": "5.0.0",
55
55
  "amqplib": "0.10.9",
56
56
  "tsdown": "0.18.2",
57
- "typedoc": "0.28.3",
57
+ "typedoc": "0.28.15",
58
58
  "typedoc-plugin-markdown": "4.9.0",
59
59
  "typescript": "5.9.3",
60
60
  "vitest": "4.0.16",
61
61
  "zod": "4.2.1",
62
- "@amqp-contract/testing": "0.3.0",
62
+ "@amqp-contract/testing": "0.3.2",
63
63
  "@amqp-contract/tsconfig": "0.0.0",
64
64
  "@amqp-contract/typedoc": "0.0.1"
65
65
  },