@celerity-sdk/topic 0.4.0 → 0.6.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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/providers/sns/sns-topic-client.ts","../src/providers/sns/sns-topic.ts","../src/errors.ts","../src/providers/sns/config.ts","../src/providers/redis/redis-topic.ts","../src/providers/redis/config.ts","../src/providers/redis/redis-topic-client.ts","../src/factory.ts","../src/decorators.ts","../src/helpers.ts","../src/layer.ts"],"sourcesContent":["import type { Closeable } from \"@celerity-sdk/types\";\n\nexport const TopicClient = Symbol.for(\"TopicClient\");\n\n/**\n * A topic client abstraction for pub/sub topics. Provides access to named\n * topics, each representing a logical destination for published messages.\n */\nexport interface TopicClient extends Closeable {\n /**\n * Retrieves a topic instance by its name. The returned topic is a lightweight\n * handle — no network calls are made until an operation is invoked.\n *\n * @param name The topic identifier (SNS topic ARN, Redis channel name, etc.).\n */\n topic(name: string): Topic;\n}\n\n/**\n * A topic represents a logical pub/sub destination. It provides methods for\n * publishing messages individually or in batches. The Celerity runtime handles\n * all subscription and consumption — this interface is producer-only.\n */\nexport interface Topic {\n /**\n * Publish a single message to the topic. The body is serialized to JSON.\n *\n * @param body The message body (serialized to JSON string for transport).\n * @param options Optional publish parameters such as FIFO ordering or subject.\n * @returns A promise that resolves to the publish result with the provider-assigned message ID.\n */\n publish<T = Record<string, unknown>>(body: T, options?: PublishOptions): Promise<PublishResult>;\n\n /**\n * Publish multiple messages in a single batch. The provider may impose batch\n * size limits (e.g. SNS limits to 10 per request) — the implementation\n * handles chunking transparently.\n *\n * @param entries The batch of messages to publish, each with a caller-assigned ID for correlation.\n * @returns A promise that resolves to the batch result with successful and failed entries.\n */\n publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult>;\n}\n\n/**\n * Options for the publish and publishBatch operations.\n */\nexport type PublishOptions = {\n /** Message group ID for FIFO topics (SNS: MessageGroupId, Pub/Sub: ordering key). */\n groupId?: string;\n /** Deduplication ID for FIFO topics. */\n deduplicationId?: string;\n /** Message subject (SNS: Subject). */\n subject?: string;\n /** String key-value message attributes (metadata sent alongside the body). */\n attributes?: Record<string, string>;\n};\n\n/**\n * The result of a single publish call.\n */\nexport type PublishResult = {\n /** The provider-assigned message identifier. */\n messageId: string;\n};\n\n/**\n * A single entry in a batch publish request.\n */\nexport type BatchPublishEntry<T = Record<string, unknown>> = {\n /** Caller-assigned ID for correlating results within the batch. */\n id: string;\n /** The message body (serialized to JSON). */\n body: T;\n /** Per-message publish options. */\n options?: PublishOptions;\n};\n\n/**\n * The result of a batch publish operation.\n */\nexport type BatchPublishResult = {\n /** Entries that were published successfully. */\n successful: BatchPublishSuccess[];\n /** Entries that failed. */\n failed: BatchPublishFailure[];\n};\n\n/**\n * A successfully published entry from a batch operation.\n */\nexport type BatchPublishSuccess = {\n /** The caller-assigned entry ID. */\n id: string;\n /** The provider-assigned message ID. */\n messageId: string;\n};\n\n/**\n * A failed entry from a batch operation.\n */\nexport type BatchPublishFailure = {\n /** The caller-assigned entry ID. */\n id: string;\n /** Provider error code. */\n code: string;\n /** Human-readable error message. */\n message: string;\n};\n","import { SNSClient } from \"@aws-sdk/client-sns\";\nimport type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient, Topic } from \"../../types\";\nimport { SNSTopic } from \"./sns-topic\";\nimport type { SNSTopicConfig } from \"./types\";\nimport { captureSNSConfig } from \"./config\";\n\nexport class SNSTopicClient implements TopicClient {\n private client: SNSClient | null = null;\n private readonly config: SNSTopicConfig;\n\n constructor(\n config?: SNSTopicConfig,\n private readonly tracer?: CelerityTracer,\n ) {\n this.config = config ?? captureSNSConfig();\n }\n\n topic(name: string): Topic {\n return new SNSTopic(name, this.getClient(), this.tracer);\n }\n\n close(): void {\n this.client?.destroy();\n this.client = null;\n }\n\n private getClient(): SNSClient {\n if (!this.client) {\n this.client = new SNSClient({\n region: this.config.region,\n endpoint: this.config.endpoint,\n credentials: this.config.credentials,\n });\n }\n return this.client;\n }\n}\n","import createDebug from \"debug\";\nimport {\n type SNSClient,\n PublishCommand,\n PublishBatchCommand,\n type MessageAttributeValue,\n type PublishBatchRequestEntry,\n} from \"@aws-sdk/client-sns\";\nimport type { CelerityTracer, CeleritySpan } from \"@celerity-sdk/types\";\nimport type {\n Topic,\n PublishOptions,\n PublishResult,\n BatchPublishEntry,\n BatchPublishResult,\n BatchPublishSuccess,\n BatchPublishFailure,\n} from \"../../types\";\nimport { TopicError } from \"../../errors\";\n\nconst debug = createDebug(\"celerity:topic:sns\");\n\nconst SNS_MAX_BATCH_SIZE = 10;\n\nexport class SNSTopic implements Topic {\n constructor(\n private readonly topicArn: string,\n private readonly client: SNSClient,\n private readonly tracer?: CelerityTracer,\n ) {}\n\n async publish<T = Record<string, unknown>>(\n body: T,\n options?: PublishOptions,\n ): Promise<PublishResult> {\n debug(\"publish %s\", this.topicArn);\n return this.traced(\"celerity.topic.publish\", { \"topic.arn\": this.topicArn }, async () => {\n try {\n const result = await this.client.send(\n new PublishCommand({\n TopicArn: this.topicArn,\n Message: JSON.stringify(body),\n MessageGroupId: options?.groupId,\n MessageDeduplicationId: options?.deduplicationId,\n Subject: options?.subject,\n MessageAttributes: options?.attributes\n ? toSNSAttributes(options.attributes)\n : undefined,\n }),\n );\n return { messageId: result.MessageId! };\n } catch (error) {\n throw new TopicError(\n `Failed to publish message to topic \"${this.topicArn}\"`,\n this.topicArn,\n { cause: error },\n );\n }\n });\n }\n\n async publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult> {\n debug(\"publishBatch %s (%d entries)\", this.topicArn, entries.length);\n return this.traced(\n \"celerity.topic.publish_batch\",\n { \"topic.arn\": this.topicArn, \"topic.message_count\": entries.length },\n async () => {\n const successful: BatchPublishSuccess[] = [];\n const failed: BatchPublishFailure[] = [];\n\n // Auto-chunk into groups of 10 (SNS limit)\n for (let i = 0; i < entries.length; i += SNS_MAX_BATCH_SIZE) {\n const chunk = entries.slice(i, i + SNS_MAX_BATCH_SIZE);\n const snsEntries: PublishBatchRequestEntry[] = chunk.map((entry) => ({\n Id: entry.id,\n Message: JSON.stringify(entry.body),\n MessageGroupId: entry.options?.groupId,\n MessageDeduplicationId: entry.options?.deduplicationId,\n Subject: entry.options?.subject,\n MessageAttributes: entry.options?.attributes\n ? toSNSAttributes(entry.options.attributes)\n : undefined,\n }));\n\n try {\n const result = await this.client.send(\n new PublishBatchCommand({\n TopicArn: this.topicArn,\n PublishBatchRequestEntries: snsEntries,\n }),\n );\n\n for (const s of result.Successful ?? []) {\n successful.push({ id: s.Id!, messageId: s.MessageId! });\n }\n for (const f of result.Failed ?? []) {\n failed.push({ id: f.Id!, code: f.Code!, message: f.Message ?? \"Unknown error\" });\n }\n } catch (error) {\n throw new TopicError(\n `Failed to publish message batch to topic \"${this.topicArn}\"`,\n this.topicArn,\n { cause: error },\n );\n }\n }\n\n return { successful, failed };\n },\n );\n }\n\n private traced<T>(\n name: string,\n attributes: Record<string, string | number | boolean>,\n fn: (span?: CeleritySpan) => Promise<T>,\n ): Promise<T> {\n if (!this.tracer) return fn();\n return this.tracer.withSpan(name, (span) => fn(span), attributes);\n }\n}\n\nfunction toSNSAttributes(attrs: Record<string, string>): Record<string, MessageAttributeValue> {\n const result: Record<string, MessageAttributeValue> = {};\n for (const [key, value] of Object.entries(attrs)) {\n result[key] = { DataType: \"String\", StringValue: value };\n }\n return result;\n}\n","/**\n * Base error for topic operations. Wraps provider SDK errors and includes\n * the topic identifier for context.\n */\nexport class TopicError extends Error {\n constructor(\n message: string,\n public readonly topic: string,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n this.name = \"TopicError\";\n }\n}\n","import type { SNSTopicConfig } from \"./types\";\n\n/**\n * Captures SNS configuration from environment variables.\n * This is the only place that reads `process.env` for SNS config.\n */\nexport function captureSNSConfig(): SNSTopicConfig {\n return {\n region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION,\n endpoint: process.env.AWS_ENDPOINT_URL,\n credentials:\n process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY\n ? {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n }\n : undefined,\n };\n}\n","import { randomUUID } from \"node:crypto\";\nimport createDebug from \"debug\";\nimport type Redis from \"ioredis\";\nimport type { CelerityTracer, CeleritySpan } from \"@celerity-sdk/types\";\nimport type {\n Topic,\n PublishOptions,\n PublishResult,\n BatchPublishEntry,\n BatchPublishResult,\n BatchPublishSuccess,\n BatchPublishFailure,\n} from \"../../types\";\nimport { TopicError } from \"../../errors\";\n\nconst debug = createDebug(\"celerity:topic:redis\");\n\nexport class RedisTopic implements Topic {\n constructor(\n private readonly channelName: string,\n private readonly client: Redis,\n private readonly tracer?: CelerityTracer,\n ) {}\n\n async publish<T = Record<string, unknown>>(\n body: T,\n options?: PublishOptions,\n ): Promise<PublishResult> {\n debug(\"publish %s\", this.channelName);\n return this.traced(\n \"celerity.topic.publish\",\n { \"topic.channel\": this.channelName },\n async () => {\n try {\n const messageId = randomUUID();\n const payload = buildEnvelope(body, messageId, options);\n await this.client.publish(this.channelName, payload);\n return { messageId };\n } catch (error) {\n throw new TopicError(\n `Failed to publish message to channel \"${this.channelName}\"`,\n this.channelName,\n { cause: error },\n );\n }\n },\n );\n }\n\n async publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult> {\n debug(\"publishBatch %s (%d entries)\", this.channelName, entries.length);\n return this.traced(\n \"celerity.topic.publish_batch\",\n { \"topic.channel\": this.channelName, \"topic.message_count\": entries.length },\n async () => {\n const successful: BatchPublishSuccess[] = [];\n const failed: BatchPublishFailure[] = [];\n\n const messageIds: string[] = [];\n const pipeline = this.client.pipeline();\n for (const entry of entries) {\n const messageId = randomUUID();\n messageIds.push(messageId);\n const payload = buildEnvelope(entry.body, messageId, entry.options);\n pipeline.publish(this.channelName, payload);\n }\n\n try {\n const results = await pipeline.exec();\n if (!results) {\n throw new Error(\"Pipeline returned null\");\n }\n\n for (let i = 0; i < entries.length; i++) {\n const [err] = results[i];\n if (err) {\n failed.push({\n id: entries[i].id,\n code: err.name ?? \"PipelineError\",\n message: err.message,\n });\n } else {\n successful.push({\n id: entries[i].id,\n messageId: messageIds[i],\n });\n }\n }\n } catch (error) {\n throw new TopicError(\n `Failed to publish message batch to channel \"${this.channelName}\"`,\n this.channelName,\n { cause: error },\n );\n }\n\n return { successful, failed };\n },\n );\n }\n\n private traced<T>(\n name: string,\n attributes: Record<string, string | number | boolean>,\n fn: (span?: CeleritySpan) => Promise<T>,\n ): Promise<T> {\n if (!this.tracer) return fn();\n return this.tracer.withSpan(name, (span) => fn(span), attributes);\n }\n}\n\n/**\n * Builds the JSON envelope published to the pub/sub channel.\n * The local-events bridge parses this envelope and extracts individual\n * fields when writing to target consumer streams.\n *\n * `messageId`, `subject`, and `attributes` are included in the envelope.\n * `groupId` and `deduplicationId` are silently ignored — ordering is\n * inherent in the single-instance bridge architecture.\n */\nfunction buildEnvelope<T>(body: T, messageId: string, options?: PublishOptions): string {\n const envelope: Record<string, unknown> = {\n body: JSON.stringify(body),\n messageId,\n };\n\n if (options?.subject) {\n envelope.subject = options.subject;\n }\n if (options?.attributes && Object.keys(options.attributes).length > 0) {\n envelope.attributes = options.attributes;\n }\n\n return JSON.stringify(envelope);\n}\n","import type { RedisTopicConfig } from \"./types\";\n\nconst DEFAULT_REDIS_URL = \"redis://localhost:6379\";\n\n/**\n * Captures Redis configuration from environment variables.\n * This is the only place that reads `process.env` for Redis config.\n */\nexport function captureRedisConfig(): RedisTopicConfig {\n return {\n url: process.env.CELERITY_LOCAL_REDIS_URL ?? DEFAULT_REDIS_URL,\n };\n}\n","import type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient, Topic } from \"../../types\";\nimport { RedisTopic } from \"./redis-topic\";\nimport type { RedisTopicConfig } from \"./types\";\nimport { captureRedisConfig } from \"./config\";\n\nexport class RedisTopicClient implements TopicClient {\n private client: import(\"ioredis\").default | null = null;\n private readonly config: RedisTopicConfig;\n\n constructor(\n config?: RedisTopicConfig,\n private readonly tracer?: CelerityTracer,\n ) {\n this.config = config ?? captureRedisConfig();\n }\n\n topic(name: string): Topic {\n return new RedisTopic(name, this.getClient(), this.tracer);\n }\n\n async close(): Promise<void> {\n if (this.client) {\n await this.client.quit();\n this.client = null;\n }\n }\n\n private getClient(): import(\"ioredis\").default {\n if (!this.client) {\n // Dynamic require to avoid bundling ioredis when not used.\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const Redis = require(\"ioredis\").default ?? require(\"ioredis\");\n this.client = new Redis(this.config.url);\n }\n return this.client!;\n }\n}\n","import { resolveConfig } from \"@celerity-sdk/config\";\nimport type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient } from \"./types\";\nimport type { SNSTopicConfig } from \"./providers/sns/types\";\nimport type { RedisTopicConfig } from \"./providers/redis/types\";\nimport { SNSTopicClient } from \"./providers/sns/sns-topic-client\";\nimport { RedisTopicClient } from \"./providers/redis/redis-topic-client\";\n\nexport type CreateTopicClientOptions = {\n /** Override provider selection. If omitted, derived from platform config. */\n provider?: \"aws\" | \"local\" | \"gcp\" | \"azure\";\n /** SNS-specific configuration overrides. */\n aws?: SNSTopicConfig;\n /** Redis-specific configuration overrides (local environment). */\n local?: RedisTopicConfig;\n /** Optional tracer for Celerity-level span instrumentation. */\n tracer?: CelerityTracer;\n};\n\nexport function createTopicClient(options?: CreateTopicClientOptions): TopicClient {\n const resolved = resolveConfig(\"topic\");\n const provider = options?.provider ?? resolved.provider;\n\n switch (provider) {\n case \"aws\":\n return new SNSTopicClient(options?.aws, options?.tracer);\n // Local environments always use Redis pub/sub regardless of deploy target.\n // The Celerity CLI manages the Redis instance and local-events sidecar.\n case \"local\":\n return new RedisTopicClient(options?.local, options?.tracer);\n // case \"gcp\":\n // v1: Google Cloud Pub/Sub\n // case \"azure\":\n // v1: Azure Service Bus Topics\n default:\n throw new Error(`Unsupported topic provider: \"${provider}\"`);\n }\n}\n","import \"reflect-metadata\";\nimport { INJECT_METADATA, USE_RESOURCE_METADATA } from \"@celerity-sdk/common\";\nimport type { Topic as TopicType } from \"./types\";\n\n// Re-declare as interface so the type merges with the decorator function below.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface Topic extends TopicType {}\n\nexport function topicToken(resourceName: string): symbol {\n return Symbol.for(`celerity:topic:${resourceName}`);\n}\n\nexport const DEFAULT_TOPIC_TOKEN = Symbol.for(\"celerity:topic:default\");\n\n/**\n * Parameter decorator that injects a {@link Topic} instance for the given\n * blueprint resource. Writes both DI injection metadata and CLI resource-ref\n * metadata using well-known `Symbol.for()` keys (no dependency on core).\n *\n * When `resourceName` is omitted, the default topic token is used — this\n * auto-resolves when exactly one topic resource exists.\n *\n * @example\n * ```ts\n * @Controller(\"/orders\")\n * class OrderController {\n * constructor(@Topic(\"orderEvents\") private events: Topic) {}\n * }\n * ```\n */\nexport function Topic(resourceName?: string): ParameterDecorator {\n return (target, _propertyKey, parameterIndex) => {\n const token = resourceName ? topicToken(resourceName) : DEFAULT_TOPIC_TOKEN;\n const existing: Map<number, unknown> =\n Reflect.getOwnMetadata(INJECT_METADATA, target) ?? new Map();\n existing.set(parameterIndex, token);\n Reflect.defineMetadata(INJECT_METADATA, existing, target);\n\n if (resourceName) {\n const resources: string[] = Reflect.getOwnMetadata(USE_RESOURCE_METADATA, target) ?? [];\n if (!resources.includes(resourceName)) {\n Reflect.defineMetadata(USE_RESOURCE_METADATA, [...resources, resourceName], target);\n }\n }\n };\n}\n","import type { ServiceContainer } from \"@celerity-sdk/types\";\nimport type { Topic } from \"./types\";\nimport { topicToken, DEFAULT_TOPIC_TOKEN } from \"./decorators\";\n\n/**\n * Resolves a {@link Topic} instance from the DI container.\n * For function-based handlers where parameter decorators aren't available.\n *\n * @param container - The service container (typically `context.container`).\n * @param resourceName - The blueprint resource name. Omit when exactly one\n * topic resource exists to use the default.\n *\n * @example\n * ```ts\n * const handler = createHttpHandler(async (req, ctx) => {\n * const events = await getTopic(ctx.container, \"orderEvents\");\n * await events.publish({ orderId: \"123\", action: \"created\" });\n * });\n * ```\n */\nexport function getTopic(container: ServiceContainer, resourceName?: string): Promise<Topic> {\n const token = resourceName ? topicToken(resourceName) : DEFAULT_TOPIC_TOKEN;\n return container.resolve<Topic>(token);\n}\n","import createDebug from \"debug\";\nimport type { CelerityLayer, BaseHandlerContext, CelerityTracer } from \"@celerity-sdk/types\";\nimport { TRACER_TOKEN, CONFIG_SERVICE_TOKEN } from \"@celerity-sdk/common\";\nimport {\n type ConfigService,\n captureResourceLinks,\n getLinksOfType,\n RESOURCE_CONFIG_NAMESPACE,\n} from \"@celerity-sdk/config\";\nimport { createTopicClient } from \"./factory\";\nimport { topicToken, DEFAULT_TOPIC_TOKEN } from \"./decorators\";\n\nconst debug = createDebug(\"celerity:topic\");\n\n/**\n * System layer that auto-registers {@link TopicClient} and per-resource\n * {@link Topic} handles in the DI container.\n *\n * Reads resource link topology from `CELERITY_RESOURCE_LINKS` and resolves\n * actual topic ARNs / channel names from the ConfigService \"resources\" namespace.\n * Must run after ConfigLayer in the layer pipeline.\n */\nexport class TopicLayer implements CelerityLayer<BaseHandlerContext> {\n private initialized = false;\n\n async handle(context: BaseHandlerContext, next: () => Promise<unknown>): Promise<unknown> {\n if (!this.initialized) {\n const tracer = context.container.has(TRACER_TOKEN)\n ? await context.container.resolve<CelerityTracer>(TRACER_TOKEN)\n : undefined;\n\n const client = createTopicClient({ tracer });\n debug(\"registering TopicClient\");\n context.container.register(\"TopicClient\", { useValue: client });\n\n const links = captureResourceLinks();\n const topicLinks = getLinksOfType(links, \"topic\");\n\n if (topicLinks.size > 0) {\n const configService = await context.container.resolve<ConfigService>(CONFIG_SERVICE_TOKEN);\n const resourceConfig = configService.namespace(RESOURCE_CONFIG_NAMESPACE);\n\n for (const [resourceName, configKey] of topicLinks) {\n const actualName = await resourceConfig.getOrThrow(configKey);\n debug(\"registered topic resource %s → %s\", resourceName, actualName);\n context.container.register(topicToken(resourceName), {\n useValue: client.topic(actualName),\n });\n }\n\n if (topicLinks.size === 1) {\n const [, configKey] = [...topicLinks.entries()][0];\n const actualName = await resourceConfig.getOrThrow(configKey);\n debug(\"registered default topic → %s\", actualName);\n context.container.register(DEFAULT_TOPIC_TOKEN, {\n useValue: client.topic(actualName),\n });\n }\n }\n\n this.initialized = true;\n }\n\n return next();\n }\n}\n"],"mappings":";;;;;;;;;;AAEO,IAAMA,cAAcC,uBAAOC,IAAI,aAAA;;;ACFtC,SAASC,iBAAiB;;;ACA1B,OAAOC,iBAAiB;AACxB,SAEEC,gBACAC,2BAGK;;;ACHA,IAAMC,aAAN,cAAyBC,MAAAA;EAJhC,OAIgCA;;;;EAC9B,YACEC,SACgBC,OAChBC,SACA;AACA,UAAMF,SAASE,OAAAA,GAAAA,KAHCD,QAAAA;AAIhB,SAAKE,OAAO;EACd;AACF;;;ADOA,IAAMC,QAAQC,YAAY,oBAAA;AAE1B,IAAMC,qBAAqB;AAEpB,IAAMC,WAAN,MAAMA;EAxBb,OAwBaA;;;;;;EACX,YACmBC,UACAC,QACAC,QACjB;SAHiBF,WAAAA;SACAC,SAAAA;SACAC,SAAAA;EAChB;EAEH,MAAMC,QACJC,MACAC,SACwB;AACxBT,UAAM,cAAc,KAAKI,QAAQ;AACjC,WAAO,KAAKM,OAAO,0BAA0B;MAAE,aAAa,KAAKN;IAAS,GAAG,YAAA;AAC3E,UAAI;AACF,cAAMO,SAAS,MAAM,KAAKN,OAAOO,KAC/B,IAAIC,eAAe;UACjBC,UAAU,KAAKV;UACfW,SAASC,KAAKC,UAAUT,IAAAA;UACxBU,gBAAgBT,SAASU;UACzBC,wBAAwBX,SAASY;UACjCC,SAASb,SAASc;UAClBC,mBAAmBf,SAASgB,aACxBC,gBAAgBjB,QAAQgB,U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zC,UAAIE,WAAWE,OAAO,GAAG;AACvB,cAAMC,gBAAgB,MAAMjB,QAAQG,UAAUG,QAAuBY,oBAAAA;AACrE,cAAMC,iBAAiBF,cAAcG,UAAUC,yBAAAA;AAE/C,mBAAW,CAACC,cAAcC,SAAAA,KAAcT,YAAY;AAClD,gBAAMU,aAAa,MAAML,eAAeM,WAAWF,SAAAA;AACnD5B,UAAAA,OAAM,0CAAqC2B,cAAcE,UAAAA;AACzDxB,kBAAQG,UAAUO,SAASgB,WAAWJ,YAAAA,GAAe;YACnDX,UAAUH,OAAOmB,MAAMH,UAAAA;UACzB,CAAA;QACF;AAEA,YAAIV,WAAWE,SAAS,GAAG;AACzB,gBAAM,CAAA,EAAGO,SAAAA,IAAa;eAAIT,WAAWc,QAAO;YAAI,CAAA;AAChD,gBAAMJ,aAAa,MAAML,eAAeM,WAAWF,SAAAA;AACnD5B,UAAAA,OAAM,sCAAiC6B,UAAAA;AACvCxB,kBAAQG,UAAUO,SAASmB,qBAAqB;YAC9ClB,UAAUH,OAAOmB,MAAMH,UAAAA;UACzB,CAAA;QACF;MACF;AAEA,WAAK1B,cAAc;IACrB;AAEA,WAAOG,KAAAA;EACT;AACF;","names":["TopicClient","Symbol","for","SNSClient","createDebug","PublishCommand","PublishBatchCommand","TopicError","Error","message","topic","options","name","debug","createDebug","SNS_MAX_BATCH_SIZE","SNSTopic","topicArn","client","tracer","publish","body","options","traced","result","send","PublishCommand","TopicArn","Message","JSON","stringify","MessageGroupId","groupId","MessageDeduplicationId","deduplicationId","Subject","subject","MessageAttributes","attributes","toSNSAttributes","undefined","messageId","MessageId","error","TopicError","cause","publishBatch","entries","length","successful","failed","i","chunk","slice","snsEntries","map","entry","Id","id","PublishBatchCommand","PublishBatchRequestEntries","s","Successful","push","f","Failed","code","Code","message","name","fn","withSpan","span","attrs","key","value","Object","DataType","StringValue","captureSNSConfig","region","process","env","AWS_REGION","AWS_DEFAULT_REGION","endpoint","AWS_ENDPOINT_URL","credentials","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","accessKeyId","secretAccessKey","undefined","SNSTopicClient","client","config","tracer","captureSNSConfig","topic","name","SNSTopic","getClient","close","destroy","SNSClient","region","endpoint","credentials","randomUUID","createDebug","debug","createDebug","RedisTopic","channelName","client","tracer","publish","body","options","traced","messageId","randomUUID","payload","buildEnvelope","error","TopicError","cause","publishBatch","entries","length","successful","failed","messageIds","pipeline","entry","push","results","exec","Error","i","err","id","code","name","message","attributes","fn","withSpan","span","envelope","JSON","stringify","subject","Object","keys","DEFAULT_REDIS_URL","captureRedisConfig","url","process","env","CELERITY_LOCAL_REDIS_URL","RedisTopicClient","client","config","tracer","captureRedisConfig","topic","name","RedisTopic","getClient","close","quit","Redis","require","default","url","resolveConfig","createTopicClient","options","resolved","resolveConfig","provider","SNSTopicClient","aws","tracer","RedisTopicClient","local","Error","INJECT_METADATA","USE_RESOURCE_METADATA","topicToken","resourceName","Symbol","for","DEFAULT_TOPIC_TOKEN","Topic","target","_propertyKey","parameterIndex","token","existing","Reflect","getOwnMetadata","INJECT_METADATA","Map","set","defineMetadata","resources","USE_RESOURCE_METADATA","includes","getTopic","container","resourceName","token","topicToken","DEFAULT_TOPIC_TOKEN","resolve","createDebug","TRACER_TOKEN","CONFIG_SERVICE_TOKEN","captureResourceLinks","getLinksOfType","RESOURCE_CONFIG_NAMESPACE","debug","createDebug","TopicLayer","initialized","handle","context","next","tracer","container","has","TRACER_TOKEN","resolve","undefined","client","createTopicClient","register","useValue","links","captureResourceLinks","topicLinks","getLinksOfType","size","configService","CONFIG_SERVICE_TOKEN","resourceConfig","namespace","RESOURCE_CONFIG_NAMESPACE","resourceName","configKey","actualName","getOrThrow","topicToken","topic","entries","DEFAULT_TOPIC_TOKEN"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/factory.ts","../src/decorators.ts","../src/helpers.ts","../src/layer.ts"],"sourcesContent":["import type { Closeable } from \"@celerity-sdk/types\";\n\nexport const TopicClient = Symbol.for(\"TopicClient\");\n\n/**\n * A topic client abstraction for pub/sub topics. Provides access to named\n * topics, each representing a logical destination for published messages.\n */\nexport interface TopicClient extends Closeable {\n /**\n * Retrieves a topic instance by its name. The returned topic is a lightweight\n * handle — no network calls are made until an operation is invoked.\n *\n * @param name The topic identifier (SNS topic ARN, Redis channel name, etc.).\n */\n topic(name: string): Topic;\n}\n\n/**\n * A topic represents a logical pub/sub destination. It provides methods for\n * publishing messages individually or in batches. The Celerity runtime handles\n * all subscription and consumption — this interface is producer-only.\n */\nexport interface Topic {\n /**\n * Publish a single message to the topic. The body is serialized to JSON.\n *\n * @param body The message body (serialized to JSON string for transport).\n * @param options Optional publish parameters such as FIFO ordering or subject.\n * @returns A promise that resolves to the publish result with the provider-assigned message ID.\n */\n publish<T = Record<string, unknown>>(body: T, options?: PublishOptions): Promise<PublishResult>;\n\n /**\n * Publish multiple messages in a single batch. The provider may impose batch\n * size limits (e.g. SNS limits to 10 per request) — the implementation\n * handles chunking transparently.\n *\n * @param entries The batch of messages to publish, each with a caller-assigned ID for correlation.\n * @returns A promise that resolves to the batch result with successful and failed entries.\n */\n publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult>;\n}\n\n/**\n * Options for the publish and publishBatch operations.\n */\nexport type PublishOptions = {\n /** Message group ID for FIFO topics (SNS: MessageGroupId, Pub/Sub: ordering key). */\n groupId?: string;\n /** Deduplication ID for FIFO topics. */\n deduplicationId?: string;\n /** Message subject (SNS: Subject). */\n subject?: string;\n /** String key-value message attributes (metadata sent alongside the body). */\n attributes?: Record<string, string>;\n};\n\n/**\n * The result of a single publish call.\n */\nexport type PublishResult = {\n /** The provider-assigned message identifier. */\n messageId: string;\n};\n\n/**\n * A single entry in a batch publish request.\n */\nexport type BatchPublishEntry<T = Record<string, unknown>> = {\n /** Caller-assigned ID for correlating results within the batch. */\n id: string;\n /** The message body (serialized to JSON). */\n body: T;\n /** Per-message publish options. */\n options?: PublishOptions;\n};\n\n/**\n * The result of a batch publish operation.\n */\nexport type BatchPublishResult = {\n /** Entries that were published successfully. */\n successful: BatchPublishSuccess[];\n /** Entries that failed. */\n failed: BatchPublishFailure[];\n};\n\n/**\n * A successfully published entry from a batch operation.\n */\nexport type BatchPublishSuccess = {\n /** The caller-assigned entry ID. */\n id: string;\n /** The provider-assigned message ID. */\n messageId: string;\n};\n\n/**\n * A failed entry from a batch operation.\n */\nexport type BatchPublishFailure = {\n /** The caller-assigned entry ID. */\n id: string;\n /** Provider error code. */\n code: string;\n /** Human-readable error message. */\n message: string;\n};\n","import { resolveConfig } from \"@celerity-sdk/config\";\nimport type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient } from \"./types\";\nimport type { SNSTopicConfig } from \"./providers/sns/types\";\nimport type { RedisTopicConfig } from \"./providers/redis/types\";\n\nexport type CreateTopicClientOptions = {\n /** Override provider selection. If omitted, derived from platform config. */\n provider?: \"aws\" | \"local\" | \"gcp\" | \"azure\";\n /** SNS-specific configuration overrides. */\n aws?: SNSTopicConfig;\n /** Redis-specific configuration overrides (local environment). */\n local?: RedisTopicConfig;\n /** Optional tracer for Celerity-level span instrumentation. */\n tracer?: CelerityTracer;\n};\n\nexport async function createTopicClient(options?: CreateTopicClientOptions): Promise<TopicClient> {\n const resolved = resolveConfig(\"topic\");\n const provider = options?.provider ?? resolved.provider;\n\n switch (provider) {\n case \"aws\": {\n const { SNSTopicClient } = await import(\"./providers/sns/sns-topic-client.js\");\n return new SNSTopicClient(options?.aws, options?.tracer);\n }\n // Local environments always use Redis pub/sub regardless of deploy target.\n // The Celerity CLI manages the Redis instance and local-events sidecar.\n case \"local\": {\n const { RedisTopicClient } = await import(\"./providers/redis/redis-topic-client.js\");\n const client = new RedisTopicClient(options?.local, options?.tracer);\n await client.ensureIoRedis();\n return client;\n }\n // case \"gcp\":\n // v1: Google Cloud Pub/Sub\n // case \"azure\":\n // v1: Azure Service Bus Topics\n default:\n throw new Error(`Unsupported topic provider: \"${provider}\"`);\n }\n}\n","import \"reflect-metadata\";\nimport { INJECT_METADATA, USE_RESOURCE_METADATA } from \"@celerity-sdk/common\";\nimport type { Topic as TopicType } from \"./types\";\n\n// Re-declare as interface so the type merges with the decorator function below.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface Topic extends TopicType {}\n\nexport function topicToken(resourceName: string): symbol {\n return Symbol.for(`celerity:topic:${resourceName}`);\n}\n\nexport const DEFAULT_TOPIC_TOKEN = Symbol.for(\"celerity:topic:default\");\n\n/**\n * Parameter decorator that injects a {@link Topic} instance for the given\n * blueprint resource. Writes both DI injection metadata and CLI resource-ref\n * metadata using well-known `Symbol.for()` keys (no dependency on core).\n *\n * When `resourceName` is omitted, the default topic token is used — this\n * auto-resolves when exactly one topic resource exists.\n *\n * @example\n * ```ts\n * @Controller(\"/orders\")\n * class OrderController {\n * constructor(@Topic(\"orderEvents\") private events: Topic) {}\n * }\n * ```\n */\nexport function Topic(resourceName?: string): ParameterDecorator {\n return (target, _propertyKey, parameterIndex) => {\n const token = resourceName ? topicToken(resourceName) : DEFAULT_TOPIC_TOKEN;\n const existing: Map<number, unknown> =\n Reflect.getOwnMetadata(INJECT_METADATA, target) ?? new Map();\n existing.set(parameterIndex, token);\n Reflect.defineMetadata(INJECT_METADATA, existing, target);\n\n if (resourceName) {\n const resources: string[] = Reflect.getOwnMetadata(USE_RESOURCE_METADATA, target) ?? [];\n if (!resources.includes(resourceName)) {\n Reflect.defineMetadata(USE_RESOURCE_METADATA, [...resources, resourceName], target);\n }\n }\n };\n}\n","import type { ServiceContainer } from \"@celerity-sdk/types\";\nimport type { Topic } from \"./types\";\nimport { topicToken, DEFAULT_TOPIC_TOKEN } from \"./decorators\";\n\n/**\n * Resolves a {@link Topic} instance from the DI container.\n * For function-based handlers where parameter decorators aren't available.\n *\n * @param container - The service container (typically `context.container`).\n * @param resourceName - The blueprint resource name. Omit when exactly one\n * topic resource exists to use the default.\n *\n * @example\n * ```ts\n * const handler = createHttpHandler(async (req, ctx) => {\n * const events = await getTopic(ctx.container, \"orderEvents\");\n * await events.publish({ orderId: \"123\", action: \"created\" });\n * });\n * ```\n */\nexport function getTopic(container: ServiceContainer, resourceName?: string): Promise<Topic> {\n const token = resourceName ? topicToken(resourceName) : DEFAULT_TOPIC_TOKEN;\n return container.resolve<Topic>(token);\n}\n","import createDebug from \"debug\";\nimport type { CelerityLayer, BaseHandlerContext, CelerityTracer } from \"@celerity-sdk/types\";\nimport { TRACER_TOKEN, CONFIG_SERVICE_TOKEN } from \"@celerity-sdk/common\";\nimport {\n type ConfigService,\n captureResourceLinks,\n getLinksOfType,\n RESOURCE_CONFIG_NAMESPACE,\n} from \"@celerity-sdk/config\";\nimport { createTopicClient } from \"./factory\";\nimport { topicToken, DEFAULT_TOPIC_TOKEN } from \"./decorators\";\n\nconst debug = createDebug(\"celerity:topic\");\n\n/**\n * System layer that auto-registers {@link TopicClient} and per-resource\n * {@link Topic} handles in the DI container.\n *\n * Reads resource link topology from `CELERITY_RESOURCE_LINKS` and resolves\n * actual topic ARNs / channel names from the ConfigService \"resources\" namespace.\n * Must run after ConfigLayer in the layer pipeline.\n */\nexport class TopicLayer implements CelerityLayer<BaseHandlerContext> {\n private initialized = false;\n\n async handle(context: BaseHandlerContext, next: () => Promise<unknown>): Promise<unknown> {\n if (!this.initialized) {\n const tracer = context.container.has(TRACER_TOKEN)\n ? await context.container.resolve<CelerityTracer>(TRACER_TOKEN)\n : undefined;\n\n const client = await createTopicClient({ tracer });\n debug(\"registering TopicClient\");\n context.container.register(\"TopicClient\", { useValue: client });\n\n const links = captureResourceLinks();\n const topicLinks = getLinksOfType(links, \"topic\");\n\n if (topicLinks.size > 0) {\n const configService = await context.container.resolve<ConfigService>(CONFIG_SERVICE_TOKEN);\n const resourceConfig = configService.namespace(RESOURCE_CONFIG_NAMESPACE);\n\n for (const [resourceName, configKey] of topicLinks) {\n const actualName = await resourceConfig.getOrThrow(configKey);\n debug(\"registered topic resource %s → %s\", resourceName, actualName);\n context.container.register(topicToken(resourceName), {\n useValue: client.topic(actualName),\n });\n }\n\n if (topicLinks.size === 1) {\n const [, configKey] = [...topicLinks.entries()][0];\n const actualName = await resourceConfig.getOrThrow(configKey);\n debug(\"registered default topic → %s\", actualName);\n context.container.register(DEFAULT_TOPIC_TOKEN, {\n useValue: client.topic(actualName),\n });\n }\n }\n\n this.initialized = true;\n }\n\n return next();\n }\n}\n"],"mappings":";;;;;;AAEO,IAAMA,cAAcC,uBAAOC,IAAI,aAAA;;;ACFtC,SAASC,qBAAqB;AAiB9B,eAAsBC,kBAAkBC,SAAkC;AACxE,QAAMC,WAAWC,cAAc,OAAA;AAC/B,QAAMC,WAAWH,SAASG,YAAYF,SAASE;AAE/C,UAAQA,UAAAA;IACN,KAAK,OAAO;AACV,YAAM,EAAEC,eAAc,IAAK,MAAM,OAAO,gCAAA;AACxC,aAAO,IAAIA,eAAeJ,SAASK,KAAKL,SAASM,MAAAA;IACnD;;;IAGA,KAAK,SAAS;AACZ,YAAM,EAAEC,iBAAgB,IAAK,MAAM,OAAO,kCAAA;AAC1C,YAAMC,SAAS,IAAID,iBAAiBP,SAASS,OAAOT,SAASM,MAAAA;AAC7D,YAAME,OAAOE,cAAa;AAC1B,aAAOF;IACT;;;;;IAKA;AACE,YAAM,IAAIG,MAAM,gCAAgCR,QAAAA,GAAW;EAC/D;AACF;AAxBsBJ;;;ACjBtB,OAAO;AACP,SAASa,iBAAiBC,6BAA6B;AAOhD,SAASC,WAAWC,cAAoB;AAC7C,SAAOC,uBAAOC,IAAI,kBAAkBF,YAAAA,EAAc;AACpD;AAFgBD;AAIT,IAAMI,sBAAsBF,uBAAOC,IAAI,wBAAA;AAkBvC,SAASE,MAAMJ,cAAqB;AACzC,SAAO,CAACK,QAAQC,cAAcC,mBAAAA;AAC5B,UAAMC,QAAQR,eAAeD,WAAWC,YAAAA,IAAgBG;AACxD,UAAMM,WACJC,QAAQC,eAAeC,iBAAiBP,MAAAA,KAAW,oBAAIQ,IAAAA;AACzDJ,a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BAAM,0CAAqC2B,cAAcE,UAAAA;AACzDxB,kBAAQG,UAAUO,SAASgB,WAAWJ,YAAAA,GAAe;YACnDX,UAAUH,OAAOmB,MAAMH,UAAAA;UACzB,CAAA;QACF;AAEA,YAAIV,WAAWE,SAAS,GAAG;AACzB,gBAAM,CAAA,EAAGO,SAAAA,IAAa;eAAIT,WAAWc,QAAO;YAAI,CAAA;AAChD,gBAAMJ,aAAa,MAAML,eAAeM,WAAWF,SAAAA;AACnD5B,gBAAM,sCAAiC6B,UAAAA;AACvCxB,kBAAQG,UAAUO,SAASmB,qBAAqB;YAC9ClB,UAAUH,OAAOmB,MAAMH,UAAAA;UACzB,CAAA;QACF;MACF;AAEA,WAAK1B,cAAc;IACrB;AAEA,WAAOG,KAAAA;EACT;AACF;","names":["TopicClient","Symbol","for","resolveConfig","createTopicClient","options","resolved","resolveConfig","provider","SNSTopicClient","aws","tracer","RedisTopicClient","client","local","ensureIoRedis","Error","INJECT_METADATA","USE_RESOURCE_METADATA","topicToken","resourceName","Symbol","for","DEFAULT_TOPIC_TOKEN","Topic","target","_propertyKey","parameterIndex","token","existing","Reflect","getOwnMetadata","INJECT_METADATA","Map","set","defineMetadata","resources","USE_RESOURCE_METADATA","includes","getTopic","container","resourceName","token","topicToken","DEFAULT_TOPIC_TOKEN","resolve","createDebug","TRACER_TOKEN","CONFIG_SERVICE_TOKEN","captureResourceLinks","getLinksOfType","RESOURCE_CONFIG_NAMESPACE","debug","createDebug","TopicLayer","initialized","handle","context","next","tracer","container","has","TRACER_TOKEN","resolve","undefined","client","createTopicClient","register","useValue","links","captureResourceLinks","topicLinks","getLinksOfType","size","configService","CONFIG_SERVICE_TOKEN","resourceConfig","namespace","RESOURCE_CONFIG_NAMESPACE","resourceName","configKey","actualName","getOrThrow","topicToken","topic","entries","DEFAULT_TOPIC_TOKEN"]}
@@ -0,0 +1,158 @@
1
+ import {
2
+ TopicError,
3
+ __name
4
+ } from "./chunk-T4LCI5X5.js";
5
+
6
+ // src/providers/redis/redis-topic.ts
7
+ import { randomUUID } from "crypto";
8
+ import createDebug from "debug";
9
+ var debug = createDebug("celerity:topic:redis");
10
+ var RedisTopic = class {
11
+ static {
12
+ __name(this, "RedisTopic");
13
+ }
14
+ channelName;
15
+ client;
16
+ tracer;
17
+ constructor(channelName, client, tracer) {
18
+ this.channelName = channelName;
19
+ this.client = client;
20
+ this.tracer = tracer;
21
+ }
22
+ async publish(body, options) {
23
+ debug("publish %s", this.channelName);
24
+ return this.traced("celerity.topic.publish", {
25
+ "topic.channel": this.channelName
26
+ }, async () => {
27
+ try {
28
+ const messageId = randomUUID();
29
+ const payload = buildEnvelope(body, messageId, options);
30
+ await this.client.publish(this.channelName, payload);
31
+ return {
32
+ messageId
33
+ };
34
+ } catch (error) {
35
+ throw new TopicError(`Failed to publish message to channel "${this.channelName}"`, this.channelName, {
36
+ cause: error
37
+ });
38
+ }
39
+ });
40
+ }
41
+ async publishBatch(entries) {
42
+ debug("publishBatch %s (%d entries)", this.channelName, entries.length);
43
+ return this.traced("celerity.topic.publish_batch", {
44
+ "topic.channel": this.channelName,
45
+ "topic.message_count": entries.length
46
+ }, async () => {
47
+ const successful = [];
48
+ const failed = [];
49
+ const messageIds = [];
50
+ const pipeline = this.client.pipeline();
51
+ for (const entry of entries) {
52
+ const messageId = randomUUID();
53
+ messageIds.push(messageId);
54
+ const payload = buildEnvelope(entry.body, messageId, entry.options);
55
+ pipeline.publish(this.channelName, payload);
56
+ }
57
+ try {
58
+ const results = await pipeline.exec();
59
+ if (!results) {
60
+ throw new Error("Pipeline returned null");
61
+ }
62
+ for (let i = 0; i < entries.length; i++) {
63
+ const [err] = results[i];
64
+ if (err) {
65
+ failed.push({
66
+ id: entries[i].id,
67
+ code: err.name ?? "PipelineError",
68
+ message: err.message
69
+ });
70
+ } else {
71
+ successful.push({
72
+ id: entries[i].id,
73
+ messageId: messageIds[i]
74
+ });
75
+ }
76
+ }
77
+ } catch (error) {
78
+ throw new TopicError(`Failed to publish message batch to channel "${this.channelName}"`, this.channelName, {
79
+ cause: error
80
+ });
81
+ }
82
+ return {
83
+ successful,
84
+ failed
85
+ };
86
+ });
87
+ }
88
+ traced(name, attributes, fn) {
89
+ if (!this.tracer) return fn();
90
+ return this.tracer.withSpan(name, (span) => fn(span), attributes);
91
+ }
92
+ };
93
+ function buildEnvelope(body, messageId, options) {
94
+ const envelope = {
95
+ body: JSON.stringify(body),
96
+ messageId
97
+ };
98
+ if (options?.subject) {
99
+ envelope.subject = options.subject;
100
+ }
101
+ if (options?.attributes && Object.keys(options.attributes).length > 0) {
102
+ envelope.attributes = options.attributes;
103
+ }
104
+ return JSON.stringify(envelope);
105
+ }
106
+ __name(buildEnvelope, "buildEnvelope");
107
+
108
+ // src/providers/redis/config.ts
109
+ var DEFAULT_REDIS_URL = "redis://localhost:6379";
110
+ function captureRedisConfig() {
111
+ return {
112
+ url: process.env.CELERITY_REDIS_ENDPOINT ?? DEFAULT_REDIS_URL
113
+ };
114
+ }
115
+ __name(captureRedisConfig, "captureRedisConfig");
116
+
117
+ // src/providers/redis/redis-topic-client.ts
118
+ var RedisTopicClient = class {
119
+ static {
120
+ __name(this, "RedisTopicClient");
121
+ }
122
+ tracer;
123
+ client = null;
124
+ ioredisModule = null;
125
+ config;
126
+ constructor(config, tracer) {
127
+ this.tracer = tracer;
128
+ this.config = config ?? captureRedisConfig();
129
+ }
130
+ topic(name) {
131
+ const channel = `celerity:topic:channel:${name}`;
132
+ return new RedisTopic(channel, this.getClient(), this.tracer);
133
+ }
134
+ async close() {
135
+ if (this.client) {
136
+ await this.client.quit();
137
+ this.client = null;
138
+ }
139
+ }
140
+ async ensureIoRedis() {
141
+ if (!this.ioredisModule) {
142
+ const pkg = "ioredis";
143
+ this.ioredisModule = await import(pkg);
144
+ }
145
+ }
146
+ getClient() {
147
+ if (!this.client) {
148
+ const ioredis = this.ioredisModule;
149
+ const Redis = ioredis.default ?? ioredis;
150
+ this.client = new Redis(this.config.url);
151
+ }
152
+ return this.client;
153
+ }
154
+ };
155
+ export {
156
+ RedisTopicClient
157
+ };
158
+ //# sourceMappingURL=redis-topic-client-SPF63T34.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/redis/redis-topic.ts","../src/providers/redis/config.ts","../src/providers/redis/redis-topic-client.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport createDebug from \"debug\";\nimport type Redis from \"ioredis\";\nimport type { CelerityTracer, CeleritySpan } from \"@celerity-sdk/types\";\nimport type {\n Topic,\n PublishOptions,\n PublishResult,\n BatchPublishEntry,\n BatchPublishResult,\n BatchPublishSuccess,\n BatchPublishFailure,\n} from \"../../types\";\nimport { TopicError } from \"../../errors\";\n\nconst debug = createDebug(\"celerity:topic:redis\");\n\nexport class RedisTopic implements Topic {\n constructor(\n private readonly channelName: string,\n private readonly client: Redis,\n private readonly tracer?: CelerityTracer,\n ) {}\n\n async publish<T = Record<string, unknown>>(\n body: T,\n options?: PublishOptions,\n ): Promise<PublishResult> {\n debug(\"publish %s\", this.channelName);\n return this.traced(\n \"celerity.topic.publish\",\n { \"topic.channel\": this.channelName },\n async () => {\n try {\n const messageId = randomUUID();\n const payload = buildEnvelope(body, messageId, options);\n await this.client.publish(this.channelName, payload);\n return { messageId };\n } catch (error) {\n throw new TopicError(\n `Failed to publish message to channel \"${this.channelName}\"`,\n this.channelName,\n { cause: error },\n );\n }\n },\n );\n }\n\n async publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult> {\n debug(\"publishBatch %s (%d entries)\", this.channelName, entries.length);\n return this.traced(\n \"celerity.topic.publish_batch\",\n { \"topic.channel\": this.channelName, \"topic.message_count\": entries.length },\n async () => {\n const successful: BatchPublishSuccess[] = [];\n const failed: BatchPublishFailure[] = [];\n\n const messageIds: string[] = [];\n const pipeline = this.client.pipeline();\n for (const entry of entries) {\n const messageId = randomUUID();\n messageIds.push(messageId);\n const payload = buildEnvelope(entry.body, messageId, entry.options);\n pipeline.publish(this.channelName, payload);\n }\n\n try {\n const results = await pipeline.exec();\n if (!results) {\n throw new Error(\"Pipeline returned null\");\n }\n\n for (let i = 0; i < entries.length; i++) {\n const [err] = results[i];\n if (err) {\n failed.push({\n id: entries[i].id,\n code: err.name ?? \"PipelineError\",\n message: err.message,\n });\n } else {\n successful.push({\n id: entries[i].id,\n messageId: messageIds[i],\n });\n }\n }\n } catch (error) {\n throw new TopicError(\n `Failed to publish message batch to channel \"${this.channelName}\"`,\n this.channelName,\n { cause: error },\n );\n }\n\n return { successful, failed };\n },\n );\n }\n\n private traced<T>(\n name: string,\n attributes: Record<string, string | number | boolean>,\n fn: (span?: CeleritySpan) => Promise<T>,\n ): Promise<T> {\n if (!this.tracer) return fn();\n return this.tracer.withSpan(name, (span) => fn(span), attributes);\n }\n}\n\n/**\n * Builds the JSON envelope published to the pub/sub channel.\n * The local-events bridge parses this envelope and extracts individual\n * fields when writing to target consumer streams.\n *\n * `messageId`, `subject`, and `attributes` are included in the envelope.\n * `groupId` and `deduplicationId` are silently ignored — ordering is\n * inherent in the single-instance bridge architecture.\n */\nfunction buildEnvelope<T>(body: T, messageId: string, options?: PublishOptions): string {\n const envelope: Record<string, unknown> = {\n body: JSON.stringify(body),\n messageId,\n };\n\n if (options?.subject) {\n envelope.subject = options.subject;\n }\n if (options?.attributes && Object.keys(options.attributes).length > 0) {\n envelope.attributes = options.attributes;\n }\n\n return JSON.stringify(envelope);\n}\n","import type { RedisTopicConfig } from \"./types\";\n\nconst DEFAULT_REDIS_URL = \"redis://localhost:6379\";\n\n/**\n * Captures Redis configuration from environment variables.\n * This is the only place that reads `process.env` for Redis config.\n */\nexport function captureRedisConfig(): RedisTopicConfig {\n return {\n url: process.env.CELERITY_REDIS_ENDPOINT ?? DEFAULT_REDIS_URL,\n };\n}\n","import type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient, Topic } from \"../../types\";\nimport { RedisTopic } from \"./redis-topic\";\nimport type { RedisTopicConfig } from \"./types\";\nimport { captureRedisConfig } from \"./config\";\n\nexport class RedisTopicClient implements TopicClient {\n private client: import(\"ioredis\").default | null = null;\n private ioredisModule: typeof import(\"ioredis\") | null = null;\n private readonly config: RedisTopicConfig;\n\n constructor(\n config?: RedisTopicConfig,\n private readonly tracer?: CelerityTracer,\n ) {\n this.config = config ?? captureRedisConfig();\n }\n\n topic(name: string): Topic {\n const channel = `celerity:topic:channel:${name}`;\n return new RedisTopic(channel, this.getClient(), this.tracer);\n }\n\n async close(): Promise<void> {\n if (this.client) {\n await this.client.quit();\n this.client = null;\n }\n }\n\n async ensureIoRedis(): Promise<void> {\n if (!this.ioredisModule) {\n const pkg = \"ioredis\";\n this.ioredisModule = (await import(pkg)) as typeof import(\"ioredis\");\n }\n }\n\n private getClient(): import(\"ioredis\").default {\n if (!this.client) {\n const ioredis = this.ioredisModule!;\n const Redis = ioredis.default ?? ioredis;\n this.client = new Redis(this.config.url as string);\n }\n return this.client!;\n }\n}\n"],"mappings":";;;;;;AAAA,SAASA,kBAAkB;AAC3B,OAAOC,iBAAiB;AAcxB,IAAMC,QAAQC,YAAY,sBAAA;AAEnB,IAAMC,aAAN,MAAMA;EAjBb,OAiBaA;;;;;;EACX,YACmBC,aACAC,QACAC,QACjB;SAHiBF,cAAAA;SACAC,SAAAA;SACAC,SAAAA;EAChB;EAEH,MAAMC,QACJC,MACAC,SACwB;AACxBR,UAAM,cAAc,KAAKG,WAAW;AACpC,WAAO,KAAKM,OACV,0BACA;MAAE,iBAAiB,KAAKN;IAAY,GACpC,YAAA;AACE,UAAI;AACF,cAAMO,YAAYC,WAAAA;AAClB,cAAMC,UAAUC,cAAcN,MAAMG,WAAWF,OAAAA;AAC/C,cAAM,KAAKJ,OAAOE,QAAQ,KAAKH,aAAaS,OAAAA;AAC5C,eAAO;UAAEF;QAAU;MACrB,SAASI,OAAO;AACd,cAAM,IAAIC,WACR,yCAAyC,KAAKZ,WAAW,KACzD,KAAKA,aACL;UAAEa,OAAOF;QAAM,CAAA;MAE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AM,KAAKb,OAAOe,GAAG;IACzC;AACA,WAAO,KAAKjB;EACd;AACF;","names":["randomUUID","createDebug","debug","createDebug","RedisTopic","channelName","client","tracer","publish","body","options","traced","messageId","randomUUID","payload","buildEnvelope","error","TopicError","cause","publishBatch","entries","length","successful","failed","messageIds","pipeline","entry","push","results","exec","Error","i","err","id","code","name","message","attributes","fn","withSpan","span","envelope","JSON","stringify","subject","Object","keys","DEFAULT_REDIS_URL","captureRedisConfig","url","process","env","CELERITY_REDIS_ENDPOINT","RedisTopicClient","client","ioredisModule","config","tracer","captureRedisConfig","topic","name","channel","RedisTopic","getClient","close","quit","ensureIoRedis","pkg","ioredis","Redis","default","url"]}
@@ -0,0 +1,161 @@
1
+ import {
2
+ TopicError,
3
+ __name
4
+ } from "./chunk-T4LCI5X5.js";
5
+
6
+ // src/providers/sns/sns-topic-client.ts
7
+ import { SNSClient } from "@aws-sdk/client-sns";
8
+
9
+ // src/providers/sns/sns-topic.ts
10
+ import createDebug from "debug";
11
+ import { PublishCommand, PublishBatchCommand } from "@aws-sdk/client-sns";
12
+ var debug = createDebug("celerity:topic:sns");
13
+ var SNS_MAX_BATCH_SIZE = 10;
14
+ var SNSTopic = class {
15
+ static {
16
+ __name(this, "SNSTopic");
17
+ }
18
+ topicArn;
19
+ client;
20
+ tracer;
21
+ constructor(topicArn, client, tracer) {
22
+ this.topicArn = topicArn;
23
+ this.client = client;
24
+ this.tracer = tracer;
25
+ }
26
+ async publish(body, options) {
27
+ debug("publish %s", this.topicArn);
28
+ return this.traced("celerity.topic.publish", {
29
+ "topic.arn": this.topicArn
30
+ }, async () => {
31
+ try {
32
+ const result = await this.client.send(new PublishCommand({
33
+ TopicArn: this.topicArn,
34
+ Message: JSON.stringify(body),
35
+ MessageGroupId: options?.groupId,
36
+ MessageDeduplicationId: options?.deduplicationId,
37
+ Subject: options?.subject,
38
+ MessageAttributes: options?.attributes ? toSNSAttributes(options.attributes) : void 0
39
+ }));
40
+ return {
41
+ messageId: result.MessageId
42
+ };
43
+ } catch (error) {
44
+ throw new TopicError(`Failed to publish message to topic "${this.topicArn}"`, this.topicArn, {
45
+ cause: error
46
+ });
47
+ }
48
+ });
49
+ }
50
+ async publishBatch(entries) {
51
+ debug("publishBatch %s (%d entries)", this.topicArn, entries.length);
52
+ return this.traced("celerity.topic.publish_batch", {
53
+ "topic.arn": this.topicArn,
54
+ "topic.message_count": entries.length
55
+ }, async () => {
56
+ const successful = [];
57
+ const failed = [];
58
+ for (let i = 0; i < entries.length; i += SNS_MAX_BATCH_SIZE) {
59
+ const chunk = entries.slice(i, i + SNS_MAX_BATCH_SIZE);
60
+ const snsEntries = chunk.map((entry) => ({
61
+ Id: entry.id,
62
+ Message: JSON.stringify(entry.body),
63
+ MessageGroupId: entry.options?.groupId,
64
+ MessageDeduplicationId: entry.options?.deduplicationId,
65
+ Subject: entry.options?.subject,
66
+ MessageAttributes: entry.options?.attributes ? toSNSAttributes(entry.options.attributes) : void 0
67
+ }));
68
+ try {
69
+ const result = await this.client.send(new PublishBatchCommand({
70
+ TopicArn: this.topicArn,
71
+ PublishBatchRequestEntries: snsEntries
72
+ }));
73
+ for (const s of result.Successful ?? []) {
74
+ successful.push({
75
+ id: s.Id,
76
+ messageId: s.MessageId
77
+ });
78
+ }
79
+ for (const f of result.Failed ?? []) {
80
+ failed.push({
81
+ id: f.Id,
82
+ code: f.Code,
83
+ message: f.Message ?? "Unknown error"
84
+ });
85
+ }
86
+ } catch (error) {
87
+ throw new TopicError(`Failed to publish message batch to topic "${this.topicArn}"`, this.topicArn, {
88
+ cause: error
89
+ });
90
+ }
91
+ }
92
+ return {
93
+ successful,
94
+ failed
95
+ };
96
+ });
97
+ }
98
+ traced(name, attributes, fn) {
99
+ if (!this.tracer) return fn();
100
+ return this.tracer.withSpan(name, (span) => fn(span), attributes);
101
+ }
102
+ };
103
+ function toSNSAttributes(attrs) {
104
+ const result = {};
105
+ for (const [key, value] of Object.entries(attrs)) {
106
+ result[key] = {
107
+ DataType: "String",
108
+ StringValue: value
109
+ };
110
+ }
111
+ return result;
112
+ }
113
+ __name(toSNSAttributes, "toSNSAttributes");
114
+
115
+ // src/providers/sns/config.ts
116
+ function captureSNSConfig() {
117
+ return {
118
+ region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION,
119
+ endpoint: process.env.CELERITY_AWS_SNS_ENDPOINT ?? process.env.AWS_ENDPOINT_URL,
120
+ credentials: process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY ? {
121
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
122
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
123
+ } : void 0
124
+ };
125
+ }
126
+ __name(captureSNSConfig, "captureSNSConfig");
127
+
128
+ // src/providers/sns/sns-topic-client.ts
129
+ var SNSTopicClient = class {
130
+ static {
131
+ __name(this, "SNSTopicClient");
132
+ }
133
+ tracer;
134
+ client = null;
135
+ config;
136
+ constructor(config, tracer) {
137
+ this.tracer = tracer;
138
+ this.config = config ?? captureSNSConfig();
139
+ }
140
+ topic(name) {
141
+ return new SNSTopic(name, this.getClient(), this.tracer);
142
+ }
143
+ close() {
144
+ this.client?.destroy();
145
+ this.client = null;
146
+ }
147
+ getClient() {
148
+ if (!this.client) {
149
+ this.client = new SNSClient({
150
+ region: this.config.region,
151
+ endpoint: this.config.endpoint,
152
+ credentials: this.config.credentials
153
+ });
154
+ }
155
+ return this.client;
156
+ }
157
+ };
158
+ export {
159
+ SNSTopicClient
160
+ };
161
+ //# sourceMappingURL=sns-topic-client-643MNMBF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/sns/sns-topic-client.ts","../src/providers/sns/sns-topic.ts","../src/providers/sns/config.ts"],"sourcesContent":["import { SNSClient } from \"@aws-sdk/client-sns\";\nimport type { CelerityTracer } from \"@celerity-sdk/types\";\nimport type { TopicClient, Topic } from \"../../types\";\nimport { SNSTopic } from \"./sns-topic\";\nimport type { SNSTopicConfig } from \"./types\";\nimport { captureSNSConfig } from \"./config\";\n\nexport class SNSTopicClient implements TopicClient {\n private client: SNSClient | null = null;\n private readonly config: SNSTopicConfig;\n\n constructor(\n config?: SNSTopicConfig,\n private readonly tracer?: CelerityTracer,\n ) {\n this.config = config ?? captureSNSConfig();\n }\n\n topic(name: string): Topic {\n return new SNSTopic(name, this.getClient(), this.tracer);\n }\n\n close(): void {\n this.client?.destroy();\n this.client = null;\n }\n\n private getClient(): SNSClient {\n if (!this.client) {\n this.client = new SNSClient({\n region: this.config.region,\n endpoint: this.config.endpoint,\n credentials: this.config.credentials,\n });\n }\n return this.client;\n }\n}\n","import createDebug from \"debug\";\nimport {\n type SNSClient,\n PublishCommand,\n PublishBatchCommand,\n type MessageAttributeValue,\n type PublishBatchRequestEntry,\n} from \"@aws-sdk/client-sns\";\nimport type { CelerityTracer, CeleritySpan } from \"@celerity-sdk/types\";\nimport type {\n Topic,\n PublishOptions,\n PublishResult,\n BatchPublishEntry,\n BatchPublishResult,\n BatchPublishSuccess,\n BatchPublishFailure,\n} from \"../../types\";\nimport { TopicError } from \"../../errors\";\n\nconst debug = createDebug(\"celerity:topic:sns\");\n\nconst SNS_MAX_BATCH_SIZE = 10;\n\nexport class SNSTopic implements Topic {\n constructor(\n private readonly topicArn: string,\n private readonly client: SNSClient,\n private readonly tracer?: CelerityTracer,\n ) {}\n\n async publish<T = Record<string, unknown>>(\n body: T,\n options?: PublishOptions,\n ): Promise<PublishResult> {\n debug(\"publish %s\", this.topicArn);\n return this.traced(\"celerity.topic.publish\", { \"topic.arn\": this.topicArn }, async () => {\n try {\n const result = await this.client.send(\n new PublishCommand({\n TopicArn: this.topicArn,\n Message: JSON.stringify(body),\n MessageGroupId: options?.groupId,\n MessageDeduplicationId: options?.deduplicationId,\n Subject: options?.subject,\n MessageAttributes: options?.attributes\n ? toSNSAttributes(options.attributes)\n : undefined,\n }),\n );\n return { messageId: result.MessageId! };\n } catch (error) {\n throw new TopicError(\n `Failed to publish message to topic \"${this.topicArn}\"`,\n this.topicArn,\n { cause: error },\n );\n }\n });\n }\n\n async publishBatch<T = Record<string, unknown>>(\n entries: BatchPublishEntry<T>[],\n ): Promise<BatchPublishResult> {\n debug(\"publishBatch %s (%d entries)\", this.topicArn, entries.length);\n return this.traced(\n \"celerity.topic.publish_batch\",\n { \"topic.arn\": this.topicArn, \"topic.message_count\": entries.length },\n async () => {\n const successful: BatchPublishSuccess[] = [];\n const failed: BatchPublishFailure[] = [];\n\n // Auto-chunk into groups of 10 (SNS limit)\n for (let i = 0; i < entries.length; i += SNS_MAX_BATCH_SIZE) {\n const chunk = entries.slice(i, i + SNS_MAX_BATCH_SIZE);\n const snsEntries: PublishBatchRequestEntry[] = chunk.map((entry) => ({\n Id: entry.id,\n Message: JSON.stringify(entry.body),\n MessageGroupId: entry.options?.groupId,\n MessageDeduplicationId: entry.options?.deduplicationId,\n Subject: entry.options?.subject,\n MessageAttributes: entry.options?.attributes\n ? toSNSAttributes(entry.options.attributes)\n : undefined,\n }));\n\n try {\n const result = await this.client.send(\n new PublishBatchCommand({\n TopicArn: this.topicArn,\n PublishBatchRequestEntries: snsEntries,\n }),\n );\n\n for (const s of result.Successful ?? []) {\n successful.push({ id: s.Id!, messageId: s.MessageId! });\n }\n for (const f of result.Failed ?? []) {\n failed.push({ id: f.Id!, code: f.Code!, message: f.Message ?? \"Unknown error\" });\n }\n } catch (error) {\n throw new TopicError(\n `Failed to publish message batch to topic \"${this.topicArn}\"`,\n this.topicArn,\n { cause: error },\n );\n }\n }\n\n return { successful, failed };\n },\n );\n }\n\n private traced<T>(\n name: string,\n attributes: Record<string, string | number | boolean>,\n fn: (span?: CeleritySpan) => Promise<T>,\n ): Promise<T> {\n if (!this.tracer) return fn();\n return this.tracer.withSpan(name, (span) => fn(span), attributes);\n }\n}\n\nfunction toSNSAttributes(attrs: Record<string, string>): Record<string, MessageAttributeValue> {\n const result: Record<string, MessageAttributeValue> = {};\n for (const [key, value] of Object.entries(attrs)) {\n result[key] = { DataType: \"String\", StringValue: value };\n }\n return result;\n}\n","import type { SNSTopicConfig } from \"./types\";\n\n/**\n * Captures SNS configuration from environment variables.\n * This is the only place that reads `process.env` for SNS config.\n */\nexport function captureSNSConfig(): SNSTopicConfig {\n return {\n region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION,\n endpoint: process.env.CELERITY_AWS_SNS_ENDPOINT ?? process.env.AWS_ENDPOINT_URL,\n credentials:\n process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY\n ? {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n }\n : undefined,\n };\n}\n"],"mappings":";;;;;;AAAA,SAASA,iBAAiB;;;ACA1B,OAAOC,iBAAiB;AACxB,SAEEC,gBACAC,2BAGK;AAaP,IAAMC,QAAQC,YAAY,oBAAA;AAE1B,IAAMC,qBAAqB;AAEpB,IAAMC,WAAN,MAAMA;EAxBb,OAwBaA;;;;;;EACX,YACmBC,UACAC,QACAC,QACjB;SAHiBF,WAAAA;SACAC,SAAAA;SACAC,SAAAA;EAChB;EAEH,MAAMC,QACJC,MACAC,SACwB;AACxBT,UAAM,cAAc,KAAKI,QAAQ;AACjC,WAAO,KAAKM,OAAO,0BAA0B;MAAE,aAAa,KAAKN;IAAS,GAAG,YAAA;AAC3E,UAAI;AACF,cAAMO,SAAS,MAAM,KAAKN,OAAOO,KAC/B,IAAIC,eAAe;UACjBC,UAAU,KAAKV;UACfW,SAASC,KAAKC,UAAUT,IAAAA;UACxBU,gBAAgBT,SAASU;UACzBC,wBAAwBX,SAASY;UACjCC,SAASb,SAASc;UAClBC,mBAAmBf,SAASgB,aACxBC,gBAAgBjB,QAAQgB,UAAU,IAClCE;QACN,CAAA,CAAA;AAEF,eAAO;UAAEC,WAAWjB,OAAOkB;QAAW;MACxC,SAASC,OAAO;AACd,cAAM,IAAIC,WACR,uCAAuC,KAAK3B,QAAQ,KACpD,KAAKA,UACL;UAAE4B,O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Z,OAAOY;MAC3B,CAAA;IACF;AACA,WAAO,KAAKb;EACd;AACF;","names":["SNSClient","createDebug","PublishCommand","PublishBatchCommand","debug","createDebug","SNS_MAX_BATCH_SIZE","SNSTopic","topicArn","client","tracer","publish","body","options","traced","result","send","PublishCommand","TopicArn","Message","JSON","stringify","MessageGroupId","groupId","MessageDeduplicationId","deduplicationId","Subject","subject","MessageAttributes","attributes","toSNSAttributes","undefined","messageId","MessageId","error","TopicError","cause","publishBatch","entries","length","successful","failed","i","chunk","slice","snsEntries","map","entry","Id","id","PublishBatchCommand","PublishBatchRequestEntries","s","Successful","push","f","Failed","code","Code","message","name","fn","withSpan","span","attrs","key","value","Object","DataType","StringValue","captureSNSConfig","region","process","env","AWS_REGION","AWS_DEFAULT_REGION","endpoint","CELERITY_AWS_SNS_ENDPOINT","AWS_ENDPOINT_URL","credentials","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","accessKeyId","secretAccessKey","undefined","SNSTopicClient","client","config","tracer","captureSNSConfig","topic","name","SNSTopic","getClient","close","destroy","SNSClient","region","endpoint","credentials"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celerity-sdk/topic",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Pub/Sub topic abstraction for the Celerity Node SDK (SNS / Pub/Sub / Service Bus Topics)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -32,9 +32,9 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "debug": "^4.4.0",
35
- "@celerity-sdk/types": "^0.4.0",
36
- "@celerity-sdk/common": "^0.4.0",
37
- "@celerity-sdk/config": "^0.4.0"
35
+ "@celerity-sdk/config": "^0.6.0",
36
+ "@celerity-sdk/types": "^0.6.0",
37
+ "@celerity-sdk/common": "^0.6.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@aws-sdk/client-sns": "^3.750.0",