@amqp-contract/client 0.13.0 → 0.14.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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Logger, TechnicalError, TelemetryProvider } from "@amqp-contract/core";
2
2
  import { AmqpConnectionManagerOptions, ConnectionUrl } from "amqp-connection-manager";
3
- import { CompressionAlgorithm, ContractDefinition, InferPublisherNames, PublisherDefinition } from "@amqp-contract/contract";
3
+ import { CompressionAlgorithm, ContractDefinitionInput, InferPublisherNames, PublisherEntry } from "@amqp-contract/contract";
4
4
  import { Future, Result } from "@swan-io/boxed";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
  import { Options } from "amqplib";
@@ -11,21 +11,27 @@ import { Options } from "amqplib";
11
11
  */
12
12
  type InferSchemaInput<TSchema extends StandardSchemaV1> = TSchema extends StandardSchemaV1<infer TInput> ? TInput : never;
13
13
  /**
14
- * Infer publisher message input type
14
+ * Infer publisher message input type.
15
+ * Works with both PublisherDefinition and EventPublisherConfig since both have
16
+ * a `message` property with a `payload` schema.
15
17
  */
16
- type PublisherInferInput<TPublisher extends PublisherDefinition> = InferSchemaInput<TPublisher["message"]["payload"]>;
18
+ type PublisherInferInput<TPublisher extends PublisherEntry> = TPublisher extends {
19
+ message: {
20
+ payload: StandardSchemaV1;
21
+ };
22
+ } ? InferSchemaInput<TPublisher["message"]["payload"]> : never;
17
23
  /**
18
24
  * Infer all publishers from contract
19
25
  */
20
- type InferPublishers<TContract extends ContractDefinition> = NonNullable<TContract["publishers"]>;
26
+ type InferPublishers<TContract extends ContractDefinitionInput> = NonNullable<TContract["publishers"]>;
21
27
  /**
22
28
  * Get specific publisher definition from contract
23
29
  */
24
- type InferPublisher<TContract extends ContractDefinition, TName extends InferPublisherNames<TContract>> = InferPublishers<TContract>[TName];
30
+ type InferPublisher<TContract extends ContractDefinitionInput, TName extends InferPublisherNames<TContract>> = InferPublishers<TContract>[TName];
25
31
  /**
26
32
  * Infer publisher input type (message payload) for a specific publisher in a contract
27
33
  */
28
- type ClientInferPublisherInput<TContract extends ContractDefinition, TName extends InferPublisherNames<TContract>> = PublisherInferInput<InferPublisher<TContract, TName>>;
34
+ type ClientInferPublisherInput<TContract extends ContractDefinitionInput, TName extends InferPublisherNames<TContract>> = PublisherInferInput<InferPublisher<TContract, TName>>;
29
35
  //#endregion
30
36
  //#region src/errors.d.ts
31
37
  /**
@@ -52,7 +58,7 @@ type PublishOptions = Options.Publish & {
52
58
  /**
53
59
  * Options for creating a client
54
60
  */
55
- type CreateClientOptions<TContract extends ContractDefinition> = {
61
+ type CreateClientOptions<TContract extends ContractDefinitionInput> = {
56
62
  contract: TContract;
57
63
  urls: ConnectionUrl[];
58
64
  connectionOptions?: AmqpConnectionManagerOptions | undefined;
@@ -67,7 +73,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
67
73
  /**
68
74
  * Type-safe AMQP client for publishing messages
69
75
  */
70
- declare class TypedAmqpClient<TContract extends ContractDefinition> {
76
+ declare class TypedAmqpClient<TContract extends ContractDefinitionInput> {
71
77
  private readonly contract;
72
78
  private readonly amqpClient;
73
79
  private readonly logger?;
@@ -83,7 +89,7 @@ declare class TypedAmqpClient<TContract extends ContractDefinition> {
83
89
  * Connections are automatically shared across clients with the same URLs and
84
90
  * connection options, following RabbitMQ best practices.
85
91
  */
86
- static create<TContract extends ContractDefinition>({
92
+ static create<TContract extends ContractDefinitionInput>({
87
93
  contract,
88
94
  urls,
89
95
  connectionOptions,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAUK,iCAAiC,oBACpC,gBAAgB;;;AAN4C;KAWzD,mBANiC,CAAA,mBAMM,mBANN,CAAA,GAM6B,gBAN7B,CAOpC,UAPoC,CAAA,SAAA,CAAA,CAAA,SAAA,CAAA,CAAA;;;;A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AqC8C,SArC9C,CAAA,EAqC0D,cArC1D,CAAA,CAAA;EACX;;;AAYX;;;;;;;;;;;EAwBoD;;;;EA6BR,OAAA,CAAA,cAApB,mBAAoB,CAAA,SAAA,CAAA,CAAA,CAAA,aAAA,EACzB,KADyB,EAAA,OAAA,EAE/B,yBAF+B,CAEL,SAFK,EAEM,KAFN,CAAA,EAAA,OAAA,CAAA,EAG9B,cAH8B,CAAA,EAIvC,MAJuC,CAIhC,MAJgC,CAAA,IAAA,EAInB,cAJmB,GAIF,sBAJE,CAAA,CAAA;EAApB;;;EAE0B,KAAA,CAAA,CAAA,EA4FvC,MA5FuC,CA4FhC,MA5FgC,CAAA,IAAA,EA4FnB,cA5FmB,CAAA,CAAA;EAArC,QAAA,sBAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAUK,iCAAiC,oBACpC,gBAAgB;;;AAN4C;;;KAazD,mBAPa,CAAA,mBAO0B,cAP1B,CAAA,GAO4C,UAP5C,SAAA;EAAgB,OAAA,EAAA;IAO7B,OAAA,EACiB,gBADE;EAAoB,CAAA;CAAkB,GAG1D,gBAH0D,CAGzC,UAHyC,CAAA,SAAA,CAAA,CAAA,SAAA,CAAA,CAAA,GAAA,KAAA;;;;KASzD,eANe,CAAA,kBAMmB,uBANnB,CAAA,GAM8C,WAN9C,CAOlB,SAPkB,CAAA,YAAA,CAAA,CAAA;AAAA;;;KAaf,cAP6D,CAAA,kBAQ9C,uBAR8C,EAAA,cASlD,mBATkD,CAS9B,SAT8B,CAAA,CAAA,GAU9D,eAV8D,CAU9C,SAV8C,CAAA,CAUnC,KAVmC,CAAA;;AAAW;;AASzC,KAMxB,yBANwB,CAAA,kBAOhB,uBAPgB,EAAA,cAQpB,mBARoB,CAQA,SARA,CAAA,CAAA,GAShC,mBATgC,CASZ,cATY,CASG,SATH,EASc,KATd,CAAA,CAAA;;;;;;cCjCvB,s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,KAAA,CAAA,CAAA,EA6FR,MA7FQ,CA6FD,MA7FC,CAAA,IAAA,EA6FY,cA7FZ,CAAA,CAAA;EACoB,QAAA,sBAAA"}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Logger, TechnicalError, TelemetryProvider } from "@amqp-contract/core";
2
2
  import { Future, Result } from "@swan-io/boxed";
3
3
  import { AmqpConnectionManagerOptions, ConnectionUrl } from "amqp-connection-manager";
4
- import { CompressionAlgorithm, ContractDefinition, InferPublisherNames, PublisherDefinition } from "@amqp-contract/contract";
4
+ import { CompressionAlgorithm, ContractDefinitionInput, InferPublisherNames, PublisherEntry } from "@amqp-contract/contract";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
  import { Options } from "amqplib";
7
7
 
@@ -11,21 +11,27 @@ import { Options } from "amqplib";
11
11
  */
12
12
  type InferSchemaInput<TSchema extends StandardSchemaV1> = TSchema extends StandardSchemaV1<infer TInput> ? TInput : never;
13
13
  /**
14
- * Infer publisher message input type
14
+ * Infer publisher message input type.
15
+ * Works with both PublisherDefinition and EventPublisherConfig since both have
16
+ * a `message` property with a `payload` schema.
15
17
  */
16
- type PublisherInferInput<TPublisher extends PublisherDefinition> = InferSchemaInput<TPublisher["message"]["payload"]>;
18
+ type PublisherInferInput<TPublisher extends PublisherEntry> = TPublisher extends {
19
+ message: {
20
+ payload: StandardSchemaV1;
21
+ };
22
+ } ? InferSchemaInput<TPublisher["message"]["payload"]> : never;
17
23
  /**
18
24
  * Infer all publishers from contract
19
25
  */
20
- type InferPublishers<TContract extends ContractDefinition> = NonNullable<TContract["publishers"]>;
26
+ type InferPublishers<TContract extends ContractDefinitionInput> = NonNullable<TContract["publishers"]>;
21
27
  /**
22
28
  * Get specific publisher definition from contract
23
29
  */
24
- type InferPublisher<TContract extends ContractDefinition, TName extends InferPublisherNames<TContract>> = InferPublishers<TContract>[TName];
30
+ type InferPublisher<TContract extends ContractDefinitionInput, TName extends InferPublisherNames<TContract>> = InferPublishers<TContract>[TName];
25
31
  /**
26
32
  * Infer publisher input type (message payload) for a specific publisher in a contract
27
33
  */
28
- type ClientInferPublisherInput<TContract extends ContractDefinition, TName extends InferPublisherNames<TContract>> = PublisherInferInput<InferPublisher<TContract, TName>>;
34
+ type ClientInferPublisherInput<TContract extends ContractDefinitionInput, TName extends InferPublisherNames<TContract>> = PublisherInferInput<InferPublisher<TContract, TName>>;
29
35
  //#endregion
30
36
  //#region src/errors.d.ts
31
37
  /**
@@ -52,7 +58,7 @@ type PublishOptions = Options.Publish & {
52
58
  /**
53
59
  * Options for creating a client
54
60
  */
55
- type CreateClientOptions<TContract extends ContractDefinition> = {
61
+ type CreateClientOptions<TContract extends ContractDefinitionInput> = {
56
62
  contract: TContract;
57
63
  urls: ConnectionUrl[];
58
64
  connectionOptions?: AmqpConnectionManagerOptions | undefined;
@@ -67,7 +73,7 @@ type CreateClientOptions<TContract extends ContractDefinition> = {
67
73
  /**
68
74
  * Type-safe AMQP client for publishing messages
69
75
  */
70
- declare class TypedAmqpClient<TContract extends ContractDefinition> {
76
+ declare class TypedAmqpClient<TContract extends ContractDefinitionInput> {
71
77
  private readonly contract;
72
78
  private readonly amqpClient;
73
79
  private readonly logger?;
@@ -83,7 +89,7 @@ declare class TypedAmqpClient<TContract extends ContractDefinition> {
83
89
  * Connections are automatically shared across clients with the same URLs and
84
90
  * connection options, following RabbitMQ best practices.
85
91
  */
86
- static create<TContract extends ContractDefinition>({
92
+ static create<TContract extends ContractDefinitionInput>({
87
93
  contract,
88
94
  urls,
89
95
  connectionOptions,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAUK,iCAAiC,oBACpC,gBAAgB;;;AAN4C;KAWzD,mBANiC,CAAA,mBAMM,mBANN,CAAA,GAM6B,gBAN7B,CAOpC,UAPoC,CAAA,SAAA,CAAA,CAAA,SAAA,CAAA,CAAA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C9B,CAqC8C,SArC9C,CAAA,EAqC0D,cArC1D,CAAA,CAAA;EACX;;;AAYX;;;;;;;;;;;EAwBoD;;;;EA6BR,OAAA,CAAA,cAApB,mBAAoB,CAAA,SAAA,CAAA,CAAA,CAAA,aAAA,EACzB,KADyB,EAAA,OAAA,EAE/B,yBAF+B,CAEL,SAFK,EAEM,KAFN,CAAA,EAAA,OAAA,CAAA,EAG9B,cAH8B,CAAA,EAIvC,MAJuC,CAIhC,MAJgC,CAAA,IAAA,EAInB,cAJmB,GAIF,sBAJE,CAAA,CAAA;EAApB;;;EAE0B,KAAA,CAAA,CAAA,EA4FvC,MA5FuC,CA4FhC,MA5FgC,CAAA,IAAA,EA4FnB,cA5FmB,CAAA,CAAA;EAArC,QAAA,sBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KAUK,iCAAiC,oBACpC,gBAAgB;;;AAN4C;;;KAazD,mBAPa,CAAA,mBAO0B,cAP1B,CAAA,GAO4C,UAP5C,SAAA;EAAgB,OAAA,EAAA;IAO7B,OAAA,EACiB,gBADE;EAAoB,CAAA;CAAkB,GAG1D,gBAH0D,CAGzC,UAHyC,CAAA,SAAA,CAAA,CAAA,SAAA,CAAA,CAAA,GAAA,KAAA;;;;KASzD,eANe,CAAA,kBAMmB,uBANnB,CAAA,GAM8C,WAN9C,CAOlB,SAPkB,CAAA,YAAA,CAAA,CAAA;AAAA;;;KAaf,cAP6D,CAAA,kBAQ9C,uBAR8C,EAAA,cASlD,mBATkD,CAS9B,SAT8B,CAAA,CAAA,GAU9D,eAV8D,CAU9C,SAV8C,CAAA,CAUnC,KAVmC,CAAA;;AAAW;;AASzC,KAMxB,yBANwB,CAAA,kBAOhB,uBAPgB,EAAA,cAQpB,mBARoB,CAQA,SARA,CAAA,CAAA,GAShC,mBATgC,CASZ,cATY,CASG,SATH,EASc,KATd,CAAA,CAAA;;;;;;cCj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A8BnB,KAAA,CAAA,CAAA,EA6FR,MA7FQ,CA6FD,MA7FC,CAAA,IAAA,EA6FY,cA7FZ,CAAA,CAAA;EACoB,QAAA,sBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/errors.ts","../src/compression.ts","../src/client.ts"],"sourcesContent":["/**\n * Error thrown when message validation fails\n */\nexport class MessageValidationError extends Error {\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 // 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","import { Future, Result } from \"@swan-io/boxed\";\nimport { deflate, gzip } from \"node:zlib\";\nimport type { CompressionAlgorithm } from \"@amqp-contract/contract\";\nimport { TechnicalError } from \"@amqp-contract/core\";\nimport { match } from \"ts-pattern\";\nimport { promisify } from \"node:util\";\n\nconst gzipAsync = promisify(gzip);\nconst deflateAsync = promisify(deflate);\n\n/**\n * Compress a buffer using the specified compression algorithm.\n *\n * @param buffer - The buffer to compress\n * @param algorithm - The compression algorithm to use\n * @returns A Future with the compressed buffer or a TechnicalError\n *\n * @internal\n */\nexport function compressBuffer(\n buffer: Buffer,\n algorithm: CompressionAlgorithm,\n): Future<Result<Buffer, TechnicalError>> {\n return match(algorithm)\n .with(\"gzip\", () =>\n Future.fromPromise(gzipAsync(buffer)).mapError(\n (error) => new TechnicalError(\"Failed to compress with gzip\", error),\n ),\n )\n .with(\"deflate\", () =>\n Future.fromPromise(deflateAsync(buffer)).mapError(\n (error) => new TechnicalError(\"Failed to compress with deflate\", error),\n ),\n )\n .exhaustive();\n}\n","import {\n AmqpClient,\n type Logger,\n TechnicalError,\n type TelemetryProvider,\n defaultTelemetryProvider,\n endSpanError,\n endSpanSuccess,\n recordPublishMetric,\n startPublishSpan,\n} from \"@amqp-contract/core\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\nimport type {\n CompressionAlgorithm,\n ContractDefinition,\n InferPublisherNames,\n} from \"@amqp-contract/contract\";\nimport { Future, Result } from \"@swan-io/boxed\";\nimport type { ClientInferPublisherInput } from \"./types.js\";\nimport { MessageValidationError } from \"./errors.js\";\nimport type { Options } from \"amqplib\";\nimport { compressBuffer } from \"./compression.js\";\n\n/**\n * Publish options that extend amqplib's Options.Publish with optional compression support.\n */\nexport type PublishOptions = Options.Publish & {\n /**\n * Optional compression algorithm to use for the message payload.\n * When specified, the message will be compressed using the chosen algorithm\n * and the contentEncoding header will be set automatically.\n */\n compression?: CompressionAlgorithm | undefined;\n};\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 * Optional telemetry provider for tracing and metrics.\n * If not provided, uses the default provider which attempts to load OpenTelemetry.\n * OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed.\n */\n telemetry?: TelemetryProvider | 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 private readonly telemetry: TelemetryProvider = defaultTelemetryProvider,\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 * Connections are automatically shared across clients with the same URLs and\n * connection options, following RabbitMQ best practices.\n */\n static create<TContract extends ContractDefinition>({\n contract,\n urls,\n connectionOptions,\n logger,\n telemetry,\n }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>> {\n const client = new TypedAmqpClient(\n contract,\n new AmqpClient(contract, { urls, connectionOptions }),\n logger,\n telemetry ?? defaultTelemetryProvider,\n );\n\n return client.waitForConnectionReady().mapOk(() => client);\n }\n\n /**\n * Publish a message using a defined publisher\n *\n * @param publisherName - The name of the publisher to use\n * @param message - The message to publish\n * @param options - Optional publish options including compression, headers, priority, etc.\n *\n * @remarks\n * If `options.compression` is specified, the message will be compressed before publishing\n * and the `contentEncoding` property will be set automatically. Any `contentEncoding`\n * value already in options will be overwritten by the compression algorithm.\n *\n * @returns Result.Ok(void) on success, or Result.Error with specific error on failure\n */\n /**\n * Publish a message using a defined publisher.\n * TypeScript guarantees publisher exists for valid publisher names.\n */\n publish<TName extends InferPublisherNames<TContract>>(\n publisherName: TName,\n message: ClientInferPublisherInput<TContract, TName>,\n options?: PublishOptions,\n ): Future<Result<void, TechnicalError | MessageValidationError>> {\n const startTime = Date.now();\n // Non-null assertions safe: TypeScript guarantees these exist for valid TName\n const publisher = this.contract.publishers![publisherName as string]!;\n const { exchange, routingKey } = publisher;\n\n // Start telemetry span\n const span = startPublishSpan(this.telemetry, exchange.name, routingKey, {\n \"amqp.publisher.name\": String(publisherName),\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): Future<Result<void, TechnicalError>> => {\n // Extract compression from options and create publish options without it\n const { compression, ...restOptions } = options ?? {};\n const publishOptions: Options.Publish = { ...restOptions };\n\n // Prepare payload and options based on compression configuration\n const preparePayload = (): Future<Result<Buffer | unknown, TechnicalError>> => {\n if (compression) {\n // Compress the message payload\n const messageBuffer = Buffer.from(JSON.stringify(validatedMessage));\n publishOptions.contentEncoding = compression;\n\n return compressBuffer(messageBuffer, compression);\n }\n\n // No compression: use the channel's built-in JSON serialization\n return Future.value(Result.Ok(validatedMessage));\n };\n\n // Publish the prepared payload\n return preparePayload().flatMapOk((payload) =>\n this.amqpClient\n .publish(publisher.exchange.name, publisher.routingKey ?? \"\", payload, publishOptions)\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 compressed: !!compression,\n });\n\n return Result.Ok(undefined);\n }),\n );\n };\n\n // Validate message using schema\n return validateMessage()\n .flatMapOk((validatedMessage) => publishMessage(validatedMessage))\n .tapOk(() => {\n const durationMs = Date.now() - startTime;\n endSpanSuccess(span);\n recordPublishMetric(this.telemetry, exchange.name, routingKey, true, durationMs);\n })\n .tapError((error) => {\n const durationMs = Date.now() - startTime;\n endSpanError(span, error);\n recordPublishMetric(this.telemetry, exchange.name, routingKey, false, durationMs);\n });\n }\n\n /**\n * Close the channel and connection\n */\n close(): Future<Result<void, TechnicalError>> {\n return this.amqpClient.close().mapOk(() => undefined);\n }\n\n private waitForConnectionReady(): Future<Result<void, TechnicalError>> {\n return this.amqpClient.waitForConnect();\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YACE,AAAgB,eAChB,AAAgB,QAChB;AACA,QAAM,4CAA4C,cAAc,GAAG;EAHnD;EACA;AAGhB,OAAK,OAAO;EAEZ,MAAM,mBAAmB;AAGzB,MAAI,OAAO,iBAAiB,sBAAsB,WAChD,kBAAiB,kBAAkB,MAAM,KAAK,YAAY;;;;;;ACRhE,MAAM,YAAY,UAAU,KAAK;AACjC,MAAM,eAAe,UAAU,QAAQ;;;;;;;;;;AAWv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compression.ts","../src/client.ts"],"sourcesContent":["/**\n * Error thrown when message validation fails\n */\nexport class MessageValidationError extends Error {\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 // 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","import { Future, Result } from \"@swan-io/boxed\";\nimport { deflate, gzip } from \"node:zlib\";\nimport type { CompressionAlgorithm } from \"@amqp-contract/contract\";\nimport { TechnicalError } from \"@amqp-contract/core\";\nimport { match } from \"ts-pattern\";\nimport { promisify } from \"node:util\";\n\nconst gzipAsync = promisify(gzip);\nconst deflateAsync = promisify(deflate);\n\n/**\n * Compress a buffer using the specified compression algorithm.\n *\n * @param buffer - The buffer to compress\n * @param algorithm - The compression algorithm to use\n * @returns A Future with the compressed buffer or a TechnicalError\n *\n * @internal\n */\nexport function compressBuffer(\n buffer: Buffer,\n algorithm: CompressionAlgorithm,\n): Future<Result<Buffer, TechnicalError>> {\n return match(algorithm)\n .with(\"gzip\", () =>\n Future.fromPromise(gzipAsync(buffer)).mapError(\n (error) => new TechnicalError(\"Failed to compress with gzip\", error),\n ),\n )\n .with(\"deflate\", () =>\n Future.fromPromise(deflateAsync(buffer)).mapError(\n (error) => new TechnicalError(\"Failed to compress with deflate\", error),\n ),\n )\n .exhaustive();\n}\n","import {\n AmqpClient,\n type Logger,\n TechnicalError,\n type TelemetryProvider,\n defaultTelemetryProvider,\n endSpanError,\n endSpanSuccess,\n recordPublishMetric,\n startPublishSpan,\n} from \"@amqp-contract/core\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\nimport type {\n CompressionAlgorithm,\n ContractDefinitionInput,\n InferPublisherNames,\n} from \"@amqp-contract/contract\";\nimport { Future, Result } from \"@swan-io/boxed\";\nimport type { ClientInferPublisherInput } from \"./types.js\";\nimport { MessageValidationError } from \"./errors.js\";\nimport type { Options } from \"amqplib\";\nimport { compressBuffer } from \"./compression.js\";\n\n/**\n * Publish options that extend amqplib's Options.Publish with optional compression support.\n */\nexport type PublishOptions = Options.Publish & {\n /**\n * Optional compression algorithm to use for the message payload.\n * When specified, the message will be compressed using the chosen algorithm\n * and the contentEncoding header will be set automatically.\n */\n compression?: CompressionAlgorithm | undefined;\n};\n\n/**\n * Options for creating a client\n */\nexport type CreateClientOptions<TContract extends ContractDefinitionInput> = {\n contract: TContract;\n urls: ConnectionUrl[];\n connectionOptions?: AmqpConnectionManagerOptions | undefined;\n logger?: Logger | undefined;\n /**\n * Optional telemetry provider for tracing and metrics.\n * If not provided, uses the default provider which attempts to load OpenTelemetry.\n * OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed.\n */\n telemetry?: TelemetryProvider | undefined;\n};\n\n/**\n * Type-safe AMQP client for publishing messages\n */\nexport class TypedAmqpClient<TContract extends ContractDefinitionInput> {\n private constructor(\n private readonly contract: TContract,\n private readonly amqpClient: AmqpClient,\n private readonly logger?: Logger,\n private readonly telemetry: TelemetryProvider = defaultTelemetryProvider,\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 * Connections are automatically shared across clients with the same URLs and\n * connection options, following RabbitMQ best practices.\n */\n static create<TContract extends ContractDefinitionInput>({\n contract,\n urls,\n connectionOptions,\n logger,\n telemetry,\n }: CreateClientOptions<TContract>): Future<Result<TypedAmqpClient<TContract>, TechnicalError>> {\n const client = new TypedAmqpClient(\n contract,\n new AmqpClient(contract, { urls, connectionOptions }),\n logger,\n telemetry ?? defaultTelemetryProvider,\n );\n\n return client.waitForConnectionReady().mapOk(() => client);\n }\n\n /**\n * Publish a message using a defined publisher\n *\n * @param publisherName - The name of the publisher to use\n * @param message - The message to publish\n * @param options - Optional publish options including compression, headers, priority, etc.\n *\n * @remarks\n * If `options.compression` is specified, the message will be compressed before publishing\n * and the `contentEncoding` property will be set automatically. Any `contentEncoding`\n * value already in options will be overwritten by the compression algorithm.\n *\n * @returns Result.Ok(void) on success, or Result.Error with specific error on failure\n */\n /**\n * Publish a message using a defined publisher.\n * TypeScript guarantees publisher exists for valid publisher names.\n */\n publish<TName extends InferPublisherNames<TContract>>(\n publisherName: TName,\n message: ClientInferPublisherInput<TContract, TName>,\n options?: PublishOptions,\n ): Future<Result<void, TechnicalError | MessageValidationError>> {\n const startTime = Date.now();\n // Non-null assertions safe: TypeScript guarantees these exist for valid TName\n const publisher = this.contract.publishers![publisherName as string]!;\n const { exchange, routingKey } = publisher;\n\n // Start telemetry span\n const span = startPublishSpan(this.telemetry, exchange.name, routingKey, {\n \"amqp.publisher.name\": String(publisherName),\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): Future<Result<void, TechnicalError>> => {\n // Extract compression from options and create publish options without it\n const { compression, ...restOptions } = options ?? {};\n const publishOptions: Options.Publish = { ...restOptions };\n\n // Prepare payload and options based on compression configuration\n const preparePayload = (): Future<Result<Buffer | unknown, TechnicalError>> => {\n if (compression) {\n // Compress the message payload\n const messageBuffer = Buffer.from(JSON.stringify(validatedMessage));\n publishOptions.contentEncoding = compression;\n\n return compressBuffer(messageBuffer, compression);\n }\n\n // No compression: use the channel's built-in JSON serialization\n return Future.value(Result.Ok(validatedMessage));\n };\n\n // Publish the prepared payload\n return preparePayload().flatMapOk((payload) =>\n this.amqpClient\n .publish(publisher.exchange.name, publisher.routingKey ?? \"\", payload, publishOptions)\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 compressed: !!compression,\n });\n\n return Result.Ok(undefined);\n }),\n );\n };\n\n // Validate message using schema\n return validateMessage()\n .flatMapOk((validatedMessage) => publishMessage(validatedMessage))\n .tapOk(() => {\n const durationMs = Date.now() - startTime;\n endSpanSuccess(span);\n recordPublishMetric(this.telemetry, exchange.name, routingKey, true, durationMs);\n })\n .tapError((error) => {\n const durationMs = Date.now() - startTime;\n endSpanError(span, error);\n recordPublishMetric(this.telemetry, exchange.name, routingKey, false, durationMs);\n });\n }\n\n /**\n * Close the channel and connection\n */\n close(): Future<Result<void, TechnicalError>> {\n return this.amqpClient.close().mapOk(() => undefined);\n }\n\n private waitForConnectionReady(): Future<Result<void, TechnicalError>> {\n return this.amqpClient.waitForConnect();\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YACE,AAAgB,eAChB,AAAgB,QAChB;AACA,QAAM,4CAA4C,cAAc,GAAG;EAHnD;EACA;AAGhB,OAAK,OAAO;EAEZ,MAAM,mBAAmB;AAGzB,MAAI,OAAO,iBAAiB,sBAAsB,WAChD,kBAAiB,kBAAkB,MAAM,KAAK,YAAY;;;;;;ACRhE,MAAM,YAAY,UAAU,KAAK;AACjC,MAAM,eAAe,UAAU,QAAQ;;;;;;;;;;AAWvC,SAAgB,eACd,QACA,WACwC;AACxC,QAAO,MAAM,UAAU,CACpB,KAAK,cACJ,OAAO,YAAY,UAAU,OAAO,CAAC,CAAC,UACnC,UAAU,IAAI,eAAe,gCAAgC,MAAM,CACrE,CACF,CACA,KAAK,i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;KAEf,MAAM,gBAAgB,OAAO,KAAK,KAAK,UAAU,iBAAiB,CAAC;AACnE,oBAAe,kBAAkB;AAEjC,YAAO,eAAe,eAAe,YAAY;;AAInD,WAAO,OAAO,MAAM,OAAO,GAAG,iBAAiB,CAAC;;AAIlD,UAAO,gBAAgB,CAAC,WAAW,YACjC,KAAK,WACF,QAAQ,UAAU,SAAS,MAAM,UAAU,cAAc,IAAI,SAAS,eAAe,CACrF,eAAe,cAAc;AAC5B,QAAI,CAAC,UACH,QAAO,OAAO,MACZ,IAAI,eACF,4CAA4C,OAAO,cAAc,CAAC,sEACnE,CACF;AAGH,SAAK,QAAQ,KAAK,kCAAkC;KAClD,eAAe,OAAO,cAAc;KACpC,UAAU,UAAU,SAAS;KAC7B,YAAY,UAAU;KACtB,YAAY,CAAC,CAAC;KACf,CAAC;AAEF,WAAO,OAAO,GAAG,OAAU;KAC3B,CACL;;AAIH,SAAO,iBAAiB,CACrB,WAAW,qBAAqB,eAAe,iBAAiB,CAAC,CACjE,YAAY;GACX,MAAM,aAAa,KAAK,KAAK,GAAG;AAChC,kBAAe,KAAK;AACpB,uBAAoB,KAAK,WAAW,SAAS,MAAM,YAAY,MAAM,WAAW;IAChF,CACD,UAAU,UAAU;GACnB,MAAM,aAAa,KAAK,KAAK,GAAG;AAChC,gBAAa,MAAM,MAAM;AACzB,uBAAoB,KAAK,WAAW,SAAS,MAAM,YAAY,OAAO,WAAW;IACjF;;;;;CAMN,QAA8C;AAC5C,SAAO,KAAK,WAAW,OAAO,CAAC,YAAY,OAAU;;CAGvD,AAAQ,yBAA+D;AACrE,SAAO,KAAK,WAAW,gBAAgB"}
package/docs/index.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### MessageValidationError
10
10
 
11
- Defined in: [packages/client/src/errors.ts:4](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/errors.ts#L4)
11
+ Defined in: [packages/client/src/errors.ts:4](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/errors.ts#L4)
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:5](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/errors.ts#L5)
27
+ Defined in: [packages/client/src/errors.ts:5](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/errors.ts#L5)
28
28
 
29
29
  ###### Parameters
30
30
 
@@ -48,10 +48,10 @@ Error.constructor
48
48
  | Property | Modifier | Type | Description | Inherited from | Defined in |
49
49
  | ------ | ------ | ------ | ------ | ------ | ------ |
50
50
  | <a id="cause"></a> `cause?` | `public` | `unknown` | - | `Error.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:7](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/errors.ts#L7) |
51
+ | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/client/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/errors.ts#L7) |
52
52
  | <a id="message"></a> `message` | `public` | `string` | - | `Error.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` | - | `Error.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:6](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/errors.ts#L6) |
54
+ | <a id="publishername"></a> `publisherName` | `readonly` | `string` | - | - | [packages/client/src/errors.ts:6](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/errors.ts#L6) |
55
55
  | <a id="stack"></a> `stack?` | `public` | `string` | - | `Error.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. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.0.9/node\_modules/@types/node/globals.d.ts:67 |
57
57
 
@@ -159,7 +159,7 @@ Error.prepareStackTrace
159
159
 
160
160
  ### TypedAmqpClient
161
161
 
162
- Defined in: [packages/client/src/client.ts:55](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L55)
162
+ Defined in: [packages/client/src/client.ts:55](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L55)
163
163
 
164
164
  Type-safe AMQP client for publishing messages
165
165
 
@@ -167,7 +167,7 @@ Type-safe AMQP client for publishing messages
167
167
 
168
168
  | Type Parameter |
169
169
  | ------ |
170
- | `TContract` *extends* `ContractDefinition` |
170
+ | `TContract` *extends* `ContractDefinitionInput` |
171
171
 
172
172
  #### Methods
173
173
 
@@ -177,7 +177,7 @@ Type-safe AMQP client for publishing messages
177
177
  close(): Future<Result<void, TechnicalError>>;
178
178
  ```
179
179
 
180
- Defined in: [packages/client/src/client.ts:202](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L202)
180
+ Defined in: [packages/client/src/client.ts:202](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L202)
181
181
 
182
182
  Close the channel and connection
183
183
 
@@ -194,7 +194,7 @@ publish<TName>(
194
194
  options?): Future<Result<void, TechnicalError | MessageValidationError>>;
195
195
  ```
196
196
 
197
- Defined in: [packages/client/src/client.ts:108](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L108)
197
+ Defined in: [packages/client/src/client.ts:108](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L108)
198
198
 
199
199
  Publish a message using a defined publisher.
200
200
  TypeScript guarantees publisher exists for valid publisher names.
@@ -223,7 +223,7 @@ TypeScript guarantees publisher exists for valid publisher names.
223
223
  static create<TContract>(__namedParameters): Future<Result<TypedAmqpClient<TContract>, TechnicalError>>;
224
224
  ```
225
225
 
226
- Defined in: [packages/client/src/client.ts:73](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L73)
226
+ Defined in: [packages/client/src/client.ts:73](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L73)
227
227
 
228
228
  Create a type-safe AMQP client from a contract.
229
229
 
@@ -238,7 +238,7 @@ connection options, following RabbitMQ best practices.
238
238
 
239
239
  | Type Parameter |
240
240
  | ------ |
241
- | `TContract` *extends* `ContractDefinition` |
241
+ | `TContract` *extends* `ContractDefinitionInput` |
242
242
 
243
243
  ###### Parameters
244
244
 
@@ -258,7 +258,7 @@ connection options, following RabbitMQ best practices.
258
258
  type ClientInferPublisherInput<TContract, TName> = PublisherInferInput<InferPublisher<TContract, TName>>;
259
259
  ```
260
260
 
261
- Defined in: [packages/client/src/types.ts:37](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/types.ts#L37)
261
+ Defined in: [packages/client/src/types.ts:43](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/types.ts#L43)
262
262
 
263
263
  Infer publisher input type (message payload) for a specific publisher in a contract
264
264
 
@@ -266,7 +266,7 @@ Infer publisher input type (message payload) for a specific publisher in a contr
266
266
 
267
267
  | Type Parameter |
268
268
  | ------ |
269
- | `TContract` *extends* `ContractDefinition` |
269
+ | `TContract` *extends* `ContractDefinitionInput` |
270
270
  | `TName` *extends* `InferPublisherNames`&lt;`TContract`&gt; |
271
271
 
272
272
  ***
@@ -277,7 +277,7 @@ Infer publisher input type (message payload) for a specific publisher in a contr
277
277
  type CreateClientOptions<TContract> = object;
278
278
  ```
279
279
 
280
- Defined in: [packages/client/src/client.ts:39](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L39)
280
+ Defined in: [packages/client/src/client.ts:39](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L39)
281
281
 
282
282
  Options for creating a client
283
283
 
@@ -285,17 +285,17 @@ Options for creating a client
285
285
 
286
286
  | Type Parameter |
287
287
  | ------ |
288
- | `TContract` *extends* `ContractDefinition` |
288
+ | `TContract` *extends* `ContractDefinitionInput` |
289
289
 
290
290
  #### Properties
291
291
 
292
292
  | Property | Type | Description | Defined in |
293
293
  | ------ | ------ | ------ | ------ |
294
- | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | - | [packages/client/src/client.ts:42](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L42) |
295
- | <a id="contract"></a> `contract` | `TContract` | - | [packages/client/src/client.ts:40](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L40) |
296
- | <a id="logger"></a> `logger?` | `Logger` | - | [packages/client/src/client.ts:43](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L43) |
297
- | <a id="telemetry"></a> `telemetry?` | `TelemetryProvider` | Optional telemetry provider for tracing and metrics. If not provided, uses the default provider which attempts to load OpenTelemetry. OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed. | [packages/client/src/client.ts:49](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L49) |
298
- | <a id="urls"></a> `urls` | `ConnectionUrl`[] | - | [packages/client/src/client.ts:41](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L41) |
294
+ | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | - | [packages/client/src/client.ts:42](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L42) |
295
+ | <a id="contract"></a> `contract` | `TContract` | - | [packages/client/src/client.ts:40](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L40) |
296
+ | <a id="logger"></a> `logger?` | `Logger` | - | [packages/client/src/client.ts:43](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L43) |
297
+ | <a id="telemetry"></a> `telemetry?` | `TelemetryProvider` | Optional telemetry provider for tracing and metrics. If not provided, uses the default provider which attempts to load OpenTelemetry. OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed. | [packages/client/src/client.ts:49](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L49) |
298
+ | <a id="urls"></a> `urls` | `ConnectionUrl`[] | - | [packages/client/src/client.ts:41](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L41) |
299
299
 
300
300
  ***
301
301
 
@@ -305,7 +305,7 @@ Options for creating a client
305
305
  type PublishOptions = Options.Publish & object;
306
306
  ```
307
307
 
308
- Defined in: [packages/client/src/client.ts:27](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L27)
308
+ Defined in: [packages/client/src/client.ts:27](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L27)
309
309
 
310
310
  Publish options that extend amqplib's Options.Publish with optional compression support.
311
311
 
@@ -313,4 +313,4 @@ Publish options that extend amqplib's Options.Publish with optional compression
313
313
 
314
314
  | Name | Type | Description | Defined in |
315
315
  | ------ | ------ | ------ | ------ |
316
- | `compression?` | `CompressionAlgorithm` | Optional compression algorithm to use for the message payload. When specified, the message will be compressed using the chosen algorithm and the contentEncoding header will be set automatically. | [packages/client/src/client.ts:33](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/client/src/client.ts#L33) |
316
+ | `compression?` | `CompressionAlgorithm` | Optional compression algorithm to use for the message payload. When specified, the message will be compressed using the chosen algorithm and the contentEncoding header will be set automatically. | [packages/client/src/client.ts:33](https://github.com/btravers/amqp-contract/blob/d132d062ebeaa9cc84db5471805355a29e3a50dc/packages/client/src/client.ts#L33) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amqp-contract/client",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Client utilities for publishing messages using amqp-contract",
5
5
  "keywords": [
6
6
  "amqp",
@@ -53,8 +53,8 @@
53
53
  "@standard-schema/spec": "1.1.0",
54
54
  "@swan-io/boxed": "3.2.1",
55
55
  "ts-pattern": "5.9.0",
56
- "@amqp-contract/contract": "0.13.0",
57
- "@amqp-contract/core": "0.13.0"
56
+ "@amqp-contract/contract": "0.14.0",
57
+ "@amqp-contract/core": "0.14.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/amqplib": "0.10.8",
@@ -68,7 +68,7 @@
68
68
  "typescript": "5.9.3",
69
69
  "vitest": "4.0.17",
70
70
  "zod": "4.3.5",
71
- "@amqp-contract/testing": "0.13.0",
71
+ "@amqp-contract/testing": "0.14.0",
72
72
  "@amqp-contract/tsconfig": "0.1.0",
73
73
  "@amqp-contract/typedoc": "0.1.0"
74
74
  },