@geekmidas/constructs 9.4.0 → 9.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/{AWSScheduledFunction-DgQuL5kt.d.mts → AWSScheduledFunction--49dTSUQ.d.mts} +3 -3
  3. package/dist/{AWSScheduledFunction-DoDZR8E6.d.cts.map → AWSScheduledFunction--49dTSUQ.d.mts.map} +1 -1
  4. package/dist/{AWSScheduledFunction-DoDZR8E6.d.cts → AWSScheduledFunction-D0_HIJj8.d.cts} +2 -2
  5. package/dist/{AWSScheduledFunction-DgQuL5kt.d.mts.map → AWSScheduledFunction-D0_HIJj8.d.cts.map} +1 -1
  6. package/dist/{AWSScheduledFunction-BXmRm9W6.mjs → AWSScheduledFunction-DHh9vo1L.mjs} +2 -2
  7. package/dist/{AWSScheduledFunction-BXmRm9W6.mjs.map → AWSScheduledFunction-DHh9vo1L.mjs.map} +1 -1
  8. package/dist/{Construct-D5LZBFhb.mjs → Construct-DE-_c3UK.mjs} +2 -2
  9. package/dist/{Construct-D5LZBFhb.mjs.map → Construct-DE-_c3UK.mjs.map} +1 -1
  10. package/dist/{Construct-CgluLUuF.d.mts → Construct-qnOnQTcP.d.mts} +1 -1
  11. package/dist/{Construct-CgluLUuF.d.mts.map → Construct-qnOnQTcP.d.mts.map} +1 -1
  12. package/dist/{Endpoint-1u_i-nCT.d.cts → Endpoint-DIQblT3d.d.cts} +2 -2
  13. package/dist/Endpoint-DIQblT3d.d.cts.map +1 -0
  14. package/dist/{Endpoint-CypDvYJW.d.mts → Endpoint-ZtG0zVz1.d.mts} +4 -4
  15. package/dist/{Endpoint-CypDvYJW.d.mts.map → Endpoint-ZtG0zVz1.d.mts.map} +1 -1
  16. package/dist/{HonoEndpointAdaptor-D_2UDPNs.cjs → HonoEndpointAdaptor-1aMXc8F3.cjs} +1 -1
  17. package/dist/{HonoEndpointAdaptor-D_2UDPNs.cjs.map → HonoEndpointAdaptor-1aMXc8F3.cjs.map} +1 -1
  18. package/dist/{HonoEndpointAdaptor-C-mPVfwk.mjs → HonoEndpointAdaptor-B1rUkVYx.mjs} +2 -2
  19. package/dist/{HonoEndpointAdaptor-C-mPVfwk.mjs.map → HonoEndpointAdaptor-B1rUkVYx.mjs.map} +1 -1
  20. package/dist/{Queue-Dhl8bc45.d.mts → Queue-Bg6WzavN.d.mts} +54 -6
  21. package/dist/Queue-Bg6WzavN.d.mts.map +1 -0
  22. package/dist/Queue-DOjT60Ah.mjs +65 -0
  23. package/dist/Queue-DOjT60Ah.mjs.map +1 -0
  24. package/dist/Queue-Di2a2N-b.cjs +76 -0
  25. package/dist/Queue-Di2a2N-b.cjs.map +1 -0
  26. package/dist/{Queue-Bl87Atny.d.cts → Queue-GJexVGOh.d.cts} +53 -5
  27. package/dist/Queue-GJexVGOh.d.cts.map +1 -0
  28. package/dist/{Subscriber-panMf5vp.d.mts → Subscriber-Bjil86Ub.d.mts} +2 -2
  29. package/dist/{Subscriber-panMf5vp.d.mts.map → Subscriber-Bjil86Ub.d.mts.map} +1 -1
  30. package/dist/{Topic-DGtlTlu5.d.mts → Topic-D8-wkoh4.d.mts} +2 -2
  31. package/dist/{Topic-DGtlTlu5.d.mts.map → Topic-D8-wkoh4.d.mts.map} +1 -1
  32. package/dist/adaptors/aws.cjs +23 -9
  33. package/dist/adaptors/aws.cjs.map +1 -1
  34. package/dist/adaptors/aws.d.cts +10 -8
  35. package/dist/adaptors/aws.d.cts.map +1 -1
  36. package/dist/adaptors/aws.d.mts +14 -12
  37. package/dist/adaptors/aws.d.mts.map +1 -1
  38. package/dist/adaptors/aws.mjs +27 -13
  39. package/dist/adaptors/aws.mjs.map +1 -1
  40. package/dist/adaptors/hono.cjs +1 -1
  41. package/dist/adaptors/hono.d.cts +2 -2
  42. package/dist/adaptors/hono.d.mts +5 -5
  43. package/dist/adaptors/hono.mjs +4 -4
  44. package/dist/adaptors/testing.cjs +11 -3
  45. package/dist/adaptors/testing.cjs.map +1 -1
  46. package/dist/adaptors/testing.d.cts +10 -4
  47. package/dist/adaptors/testing.d.cts.map +1 -1
  48. package/dist/adaptors/testing.d.mts +14 -8
  49. package/dist/adaptors/testing.d.mts.map +1 -1
  50. package/dist/adaptors/testing.mjs +14 -6
  51. package/dist/adaptors/testing.mjs.map +1 -1
  52. package/dist/crons/index.d.cts +6 -6
  53. package/dist/crons/index.d.mts +3 -3
  54. package/dist/crons/index.mjs +3 -3
  55. package/dist/endpoints/index.d.cts +4 -4
  56. package/dist/endpoints/index.d.mts +5 -5
  57. package/dist/endpoints/index.mjs +3 -3
  58. package/dist/functions/index.d.cts +1 -1
  59. package/dist/functions/index.d.mts +2 -2
  60. package/dist/functions/index.mjs +2 -2
  61. package/dist/{functions-CNJbRq0O.mjs → functions-BFE--uOu.mjs} +2 -2
  62. package/dist/{functions-CNJbRq0O.mjs.map → functions-BFE--uOu.mjs.map} +1 -1
  63. package/dist/{index-BUNi5ldW.d.mts → index-CbhtERFB.d.mts} +2 -2
  64. package/dist/{index-BUNi5ldW.d.mts.map → index-CbhtERFB.d.mts.map} +1 -1
  65. package/dist/{index-zeG5G432.d.cts → index-XJKTxGx7.d.cts} +5 -5
  66. package/dist/{index-zeG5G432.d.cts.map → index-XJKTxGx7.d.cts.map} +1 -1
  67. package/dist/index.d.mts +3 -3
  68. package/dist/index.mjs +1 -1
  69. package/dist/{lazyAccessors-BjAZqRqK.mjs → lazyAccessors-B4TjBt0u.mjs} +3 -3
  70. package/dist/{lazyAccessors-BjAZqRqK.mjs.map → lazyAccessors-B4TjBt0u.mjs.map} +1 -1
  71. package/dist/monitors/index.d.mts +1 -1
  72. package/dist/queue/index.cjs +26 -57
  73. package/dist/queue/index.cjs.map +1 -1
  74. package/dist/queue/index.d.cts +23 -6
  75. package/dist/queue/index.d.cts.map +1 -1
  76. package/dist/queue/index.d.mts +22 -5
  77. package/dist/queue/index.d.mts.map +1 -1
  78. package/dist/queue/index.mjs +27 -59
  79. package/dist/queue/index.mjs.map +1 -1
  80. package/dist/subscribers/index.d.cts +2 -2
  81. package/dist/subscribers/index.d.cts.map +1 -1
  82. package/dist/subscribers/index.d.mts +3 -3
  83. package/dist/subscribers/index.mjs +1 -1
  84. package/dist/{telemetry-Bp4DLvdQ.d.mts → telemetry-vq7C0ZBy.d.mts} +1 -1
  85. package/dist/{telemetry-Bp4DLvdQ.d.mts.map → telemetry-vq7C0ZBy.d.mts.map} +1 -1
  86. package/dist/topic/index.d.mts +2 -2
  87. package/dist/topic/index.mjs +1 -1
  88. package/dist/{types-j0ti0JTY.d.mts → types-X37z95fN.d.mts} +1 -1
  89. package/dist/{types-j0ti0JTY.d.mts.map → types-X37z95fN.d.mts.map} +1 -1
  90. package/dist/types.d.mts +1 -1
  91. package/package.json +22 -22
  92. package/src/queue/AWSLambdaQueueAdaptor.ts +38 -9
  93. package/src/queue/Queue.ts +51 -1
  94. package/src/queue/QueueBuilder.ts +36 -3
  95. package/src/queue/TestQueueAdaptor.ts +18 -4
  96. package/src/queue/__tests__/AWSLambdaQueueAdaptor.spec.ts +196 -0
  97. package/src/queue/__tests__/QueueBuilder.spec.ts +19 -0
  98. package/src/queue/__tests__/TestQueueAdaptor.spec.ts +58 -0
  99. package/src/queue/index.ts +3 -0
  100. package/dist/Endpoint-1u_i-nCT.d.cts.map +0 -1
  101. package/dist/Queue-Bl87Atny.d.cts.map +0 -1
  102. package/dist/Queue-Dhl8bc45.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["DEFAULT_LOGGER","ConsoleLogger","Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import { environmentCase } from '@geekmidas/envkit';\nimport {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as unknown as Logger;\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t);\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;AAcA,MAAMA,mBAAiB,IAAIC;;;;;;;;;;AAsB3B,IAAa,QAAb,cAKUC,4BAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAASC,gCAAc,MAC3C;CACD;CAED,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBV,kBAE3BW,WAEAC,MACf;AACD,QACCR,gCAAc,OACd,QACA,UACA,CAAE,mBAGF,QACA;EAnBe;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;CAWhB;;;;;;;;;;;;CAaD,IAAI,YAGF;EACD,MAAM,UAAU,EAAE,wCAAgB,KAAK,KAAK,CAAC;AAC7C,SAAO;GACN,cAAc,EAAE,KAAK,KAAK;GAC1B,MAAM,SAAS,EAAE,WAAW,EAAE;IAC7B,MAAM,EAAE,kBAAkB,GAAG,UAC3B,OAAO,CAAC,SAAS,EACjB,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CACtC,GAAE,CACF,OAAO;AAET,WAAO,6BAAU,qBAChB,iBACA;GACD;EACD;CACD;AACD;;;;;;;;;;AC/FD,IAAa,eAAb,MAKE;CACD,AAAQ;CACR,AAAQ;CACR,AAAQ,WAAW;CACnB,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAuB,CAAE;CACjC,AAAQ,UAAmBS;;CAG3B,MACCC,MACgD;AAChD,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CAMvC;CAED,QAAQC,SAAuB;AAC9B,SAAO,wBAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;;CAGD,UAAUC,WAAyB;AAClC,SAAO,wBAAU,MAAM,EAAE,YAAY,UAAW,EAAC;CACjD;;CAGD,KAAK,OAAO,MAAY;AACvB,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CACvC;CAED,SACCC,UAC+D;AAC/D,SAAO,wBAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,wBAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,wBAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK;AAON,SAAO;CACP;AACD;;;;ACvGD,MAAa,IAAI,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":["DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","fifo:\n\t\t\t| boolean\n\t\t\t| {\n\t\t\t\t\tgroupId: (\n\t\t\t\t\t\tmessage: TMessage extends StandardSchemaV1\n\t\t\t\t\t\t\t? InferStandardSchema<TMessage>\n\t\t\t\t\t\t\t: never,\n\t\t\t\t\t) => string;\n\t\t\t }","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>","Queue"],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _envelope = true;\n\tprivate _groupId?: (message: any) => string;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/**\n\t * Mark the queue as FIFO (deployed). Pass `{ groupId }` to give each message\n\t * its message group, which the queue's publisher then sends: a FIFO queue\n\t * refuses a message without one. Messages in one group keep their order.\n\t */\n\tfifo(\n\t\tfifo:\n\t\t\t| boolean\n\t\t\t| {\n\t\t\t\t\tgroupId: (\n\t\t\t\t\t\tmessage: TMessage extends StandardSchemaV1\n\t\t\t\t\t\t\t? InferStandardSchema<TMessage>\n\t\t\t\t\t\t\t: never,\n\t\t\t\t\t) => string;\n\t\t\t } = true,\n\t): this {\n\t\tif (typeof fifo === 'boolean') {\n\t\t\treturn cloneWith(this, { _fifo: fifo });\n\t\t}\n\t\treturn cloneWith(this, { _fifo: true, _groupId: fifo.groupId });\n\t}\n\n\t/**\n\t * Whether messages arrive in the `{ type, payload }` envelope the queue's\n\t * publisher writes. Pass `false` for a queue fed by something else — an IoT\n\t * rule, a webhook forwarder — whose bodies are the message as they stand: a\n\t * body is then never unwrapped, even one that has a `payload` field of its\n\t * own, and one that is not JSON is the message as a string.\n\t */\n\tenvelope(envelope = true): this {\n\t\treturn cloneWith(this, { _envelope: envelope });\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._envelope,\n\t\t\tthis._groupId,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tisQueueResult,\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n\ttype QueueRecord,\n\ttype QueueResult,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,eAAb,MAKE;CACD,AAAQ;CACR,AAAQ;CACR,AAAQ,WAAW;CACnB,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CACR,AAAQ,YAAuB,CAAE;CACjC,AAAQ,UAAmBA;;CAG3B,MACCC,MACgD;AAChD,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CAMvC;CAED,QAAQC,SAAuB;AAC9B,SAAO,wBAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;;CAGD,UAAUC,WAAyB;AAClC,SAAO,wBAAU,MAAM,EAAE,YAAY,UAAW,EAAC;CACjD;;;;;;CAOD,KACCC,OAQO,MACA;AACP,aAAW,SAAS,UACnB,QAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;AAExC,SAAO,wBAAU,MAAM;GAAE,OAAO;GAAM,UAAU,KAAK;EAAS,EAAC;CAC/D;;;;;;;;CASD,SAAS,WAAW,MAAY;AAC/B,SAAO,wBAAU,MAAM,EAAE,WAAW,SAAU,EAAC;CAC/C;CAED,SACCC,UAC+D;AAC/D,SAAO,wBAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,wBAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,wBAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAIC,oBACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,WACL,KAAK;AAON,SAAO;CACP;AACD;;;;ACrID,MAAa,IAAI,IAAI"}
@@ -1,7 +1,8 @@
1
1
  import "../Construct-BEh2DSMe.cjs";
2
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-Bl87Atny.cjs";
3
- import * as _geekmidas_logger8 from "@geekmidas/logger";
2
+ import { Queue, QueueContext, QueueHandler, QueueMessage, QueueRecord, QueueResult, isQueueResult } from "../Queue-GJexVGOh.cjs";
3
+ import * as _geekmidas_logger6 from "@geekmidas/logger";
4
4
  import { Logger } from "@geekmidas/logger";
5
+ import { InferStandardSchema } from "@geekmidas/schema";
5
6
  import { Service } from "@geekmidas/services";
6
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
7
8
 
@@ -19,6 +20,8 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
19
20
  private _timeout;
20
21
  private _batchSize?;
21
22
  private _fifo?;
23
+ private _envelope;
24
+ private _groupId?;
22
25
  private _services;
23
26
  private _logger;
24
27
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
@@ -26,8 +29,22 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
26
29
  timeout(timeout: number): this;
27
30
  /** SQS event-source batch size (deployed). */
28
31
  batchSize(batchSize: number): this;
29
- /** Mark the queue as FIFO (deployed). */
30
- fifo(fifo?: boolean): this;
32
+ /**
33
+ * Mark the queue as FIFO (deployed). Pass `{ groupId }` to give each message
34
+ * its message group, which the queue's publisher then sends: a FIFO queue
35
+ * refuses a message without one. Messages in one group keep their order.
36
+ */
37
+ fifo(fifo?: boolean | {
38
+ groupId: (message: TMessage extends StandardSchemaV1 ? InferStandardSchema<TMessage> : never) => string;
39
+ }): this;
40
+ /**
41
+ * Whether messages arrive in the `{ type, payload }` envelope the queue's
42
+ * publisher writes. Pass `false` for a queue fed by something else — an IoT
43
+ * rule, a webhook forwarder — whose bodies are the message as they stand: a
44
+ * body is then never unwrapped, even one that has a `payload` field of its
45
+ * own, and one that is not JSON is the message as a string.
46
+ */
47
+ envelope(envelope?: boolean): this;
31
48
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
32
49
  logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
33
50
  /** The typed message (job) payload the queue carries. */
@@ -37,9 +54,9 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
37
54
  //# sourceMappingURL=QueueBuilder.d.ts.map
38
55
  //#endregion
39
56
  //#region src/queue/index.d.ts
40
- declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger8.Logger>;
57
+ declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger6.Logger>;
41
58
  //# sourceMappingURL=index.d.ts.map
42
59
 
43
60
  //#endregion
44
- export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, q };
61
+ export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, QueueRecord, QueueResult, isQueueResult, q };
45
62
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAaA;;AAEkB,cAFL,YAEK,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,gBAAA,GAAA,SAAA,GAAA,SAAA,EAAA,kBACC,OADD,EAAA,GAAA,EAAA,EAAA,gBAED,MAFC,GAEQ,MAFR,CAAA,CAAA;EAAgB,QACf,KAAA;EAAO,QACT,cAAA;EAAM,QAAG,QAAA;EAAM,QAYxB,UAAA;EAAC,QACQ,KAAA;EAAC,QAAE,SAAA;EAAQ,QAAE,OAAA;EAAS;EAAS,KAA5C,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EADI,CACJ,CAAA,EAAA,YAAA,CAAa,CAAb,EAAgB,QAAhB,EAA0B,SAA1B,EAAqC,OAArC,CAAA;EAAY,OAuBI,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAO;EACd,SACI,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAK;EAAU,IAAM,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAS,QAAK,CAAA,UAFhC,OAEgC,EAAA,CAAA,CAAA,QAAA,EADxC,CACwC,CAAA,EAAhD,YAAgD,CAAnC,KAAmC,EAA5B,QAA4B,EAAA,CAAA,GAAd,SAAc,EAAA,GAAA,CAAA,CAAA,EAAI,OAAJ,CAAA;EAAC,MAAG,CAAA,UAWtC,MAXsC,CAAA,CAAA,MAAA,EAY9C,CAZ8C,CAAA,EAapD,YAboD,CAavC,KAbuC,EAahC,QAbgC,EAatB,SAbsB,EAaX,CAbW,CAAA;EAAO;EAA/C,OAWE,CAAA,UASC,gBATD,CAAA,CAAA,MAAA,EAUR,CAVQ,CAAA,EAWd,Y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AA,KAAA,EAAA,GAAA,MAAA;EAAY,CAAA,CAAA,EAWE,IAAA;EAAM;;;;;;;EASW,QACzB,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAC,QACM,CAAA,UAxBG,OAwBH,EAAA,CAAA,CAAA,QAAA,EAvBL,CAuBK,CAAA,EAtBb,YAsBa,CAtBA,KAsBA,EAtBO,QAsBP,EAAA,CAAA,GAtBqB,SAsBrB,EAAA,GAtBmC,CAsBnC,CAAA,EAtBuC,OAsBvC,CAAA;EAAK,MAAE,CAAA,UAXN,MAWM,CAAA,CAAA,MAAA,EAVd,CAUc,CAAA,EATpB,YASoB,CATP,KASO,EATA,QASA,EATU,SASV,EATqB,CASrB,CAAA;EAAC;EAAW,OAAE,CAAA,UAFnB,gBAEmB,CAAA,CAAA,MAAA,EAD5B,CAC4B,CAAA,EAAlC,YAAkC,CAArB,KAAqB,EAAd,CAAc,EAAX,SAAW,EAAA,OAAA,CAAA;EAAO,MAAzC,CAAA,EAAA,EAOE,YAPF,CAOe,WAPf,CAO2B,QAP3B,CAAA,EAOsC,SAPtC,EAOiD,OAPjD,CAAA,CAAA,EAQA,KARA,CAQM,KARN,EAQa,WARb,CAQyB,QARzB,CAAA,EAQoC,SARpC,EAQ+C,OAR/C,CAAA;;;;;cC9FS,GAAC,oCAAqB,kBAAA,CAArB,MAAA"}
@@ -1,7 +1,8 @@
1
- import "../Construct-CgluLUuF.mjs";
2
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-Dhl8bc45.mjs";
1
+ import "../Construct-qnOnQTcP.mjs";
2
+ import { Queue, QueueContext, QueueHandler, QueueMessage, QueueRecord, QueueResult, isQueueResult } from "../Queue-Bg6WzavN.mjs";
3
3
  import { Service } from "@geekmidas/services";
4
4
  import { Logger as Logger$1 } from "@geekmidas/logger";
5
+ import { InferStandardSchema } from "@geekmidas/schema";
5
6
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
7
 
7
8
  //#region src/queue/QueueBuilder.d.ts
@@ -18,6 +19,8 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
18
19
  private _timeout;
19
20
  private _batchSize?;
20
21
  private _fifo?;
22
+ private _envelope;
23
+ private _groupId?;
21
24
  private _services;
22
25
  private _logger;
23
26
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
@@ -25,8 +28,22 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
25
28
  timeout(timeout: number): this;
26
29
  /** SQS event-source batch size (deployed). */
27
30
  batchSize(batchSize: number): this;
28
- /** Mark the queue as FIFO (deployed). */
29
- fifo(fifo?: boolean): this;
31
+ /**
32
+ * Mark the queue as FIFO (deployed). Pass `{ groupId }` to give each message
33
+ * its message group, which the queue's publisher then sends: a FIFO queue
34
+ * refuses a message without one. Messages in one group keep their order.
35
+ */
36
+ fifo(fifo?: boolean | {
37
+ groupId: (message: TMessage extends StandardSchemaV1 ? InferStandardSchema<TMessage> : never) => string;
38
+ }): this;
39
+ /**
40
+ * Whether messages arrive in the `{ type, payload }` envelope the queue's
41
+ * publisher writes. Pass `false` for a queue fed by something else — an IoT
42
+ * rule, a webhook forwarder — whose bodies are the message as they stand: a
43
+ * body is then never unwrapped, even one that has a `payload` field of its
44
+ * own, and one that is not JSON is the message as a string.
45
+ */
46
+ envelope(envelope?: boolean): this;
30
47
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
31
48
  logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
32
49
  /** The typed message (job) payload the queue carries. */
@@ -40,5 +57,5 @@ declare const q: QueueBuilder<string, undefined, [], Logger>;
40
57
  //# sourceMappingURL=index.d.ts.map
41
58
 
42
59
  //#endregion
43
- export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, q };
60
+ export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, QueueRecord, QueueResult, isQueueResult, q };
44
61
  //# sourceMappingURL=index.d.mts.map
@@ -1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OAAA,CAAA,EAAA,IAAA;EAAK,QAAE,CAAA,UAxBJ,OAwBI,EAAA,CAAA,CAAA,QAAA,EAvBZ,CAuBY,CAAA,EAtBpB,YAsBoB,CAtBP,KAsBO,EAtBA,QAsBA,EAAA,CAAA,GAtBc,SAsBd,EAAA,GAtB4B,CAsB5B,CAAA,EAtBgC,OAsBhC,CAAA;EAAC,MAAE,CAAA,UAXT,QAWS,CAAA,CAAA,MAAA,EAVjB,CAUiB,CAAA,EATvB,YASuB,CATV,KASU,EATH,QASG,EATO,SASP,EATkB,CASlB,CAAA;EAAS;EAAS,OAAzC,CAAA,UAFe,gBAEf,CAAA,CAAA,MAAA,EADM,CACN,CAAA,EAAA,YAAA,CAAa,KAAb,EAAoB,CAApB,EAAuB,SAAvB,EAAkC,OAAlC,CAAA;EAAY,MAOe,CAAA,EAAA,EAAzB,YAAyB,CAAZ,WAAY,CAAA,QAAA,CAAA,EAAW,SAAX,EAAsB,OAAtB,CAAA,CAAA,EAC3B,KAD2B,CACrB,KADqB,EACd,WADc,CACF,QADE,CAAA,EACS,SADT,EACoB,OADpB,CAAA;;;;;cCrGlB,GAAC,oCAAA"}
@@ -1,60 +1,8 @@
1
- import { Construct, ConstructType } from "../Construct-D5LZBFhb.mjs";
1
+ import "../Construct-DE-_c3UK.mjs";
2
2
  import { cloneWith } from "../clone-BWIwx6vL.mjs";
3
- import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
4
- import { environmentCase } from "@geekmidas/envkit";
5
- import { Publisher } from "@geekmidas/events";
3
+ import { Queue, isQueueResult } from "../Queue-DOjT60Ah.mjs";
4
+ import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
6
5
 
7
- //#region src/queue/Queue.ts
8
- const DEFAULT_LOGGER$1 = new ConsoleLogger();
9
- /**
10
- * A queue worker — a point-to-point SQS-style queue and its single consumer.
11
- * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
12
- * drains every message of its one `message` type. Build one with `q` (see
13
- * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.
14
- *
15
- * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`
16
- * that any endpoint/function drops into `.services([...])` to send messages.
17
- */
18
- var Queue = class extends Construct {
19
- __IS_QUEUE__ = true;
20
- static isQueue(obj) {
21
- return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === ConstructType.Queue);
22
- }
23
- constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = DEFAULT_LOGGER$1, batchSize, fifo) {
24
- super(ConstructType.Queue, logger, services, [], void 0, void 0, timeout);
25
- this.name = name;
26
- this.handler = handler;
27
- this.messageSchema = messageSchema;
28
- this.timeout = timeout;
29
- this.services = services;
30
- this.logger = logger;
31
- this.batchSize = batchSize;
32
- this.fifo = fifo;
33
- }
34
- /**
35
- * The producer side — a `Service` exposing an `EventPublisher` typed to this
36
- * queue's message. Inject it via `.services([queue.publisher])`; the handler
37
- * then calls `services.<name>Publisher.publish([{ type, payload }])`.
38
- *
39
- * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from
40
- * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same
41
- * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,
42
- * `Construct.getEnvironment()` sniffs it, so the env requirement flows into
43
- * the manifest and infra links exactly this queue with least privilege.
44
- */
45
- get publisher() {
46
- const envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;
47
- return {
48
- serviceName: `${this.name}Publisher`,
49
- async register({ envParser }) {
50
- const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
51
- return Publisher.fromConnectionString(connectionString);
52
- }
53
- };
54
- }
55
- };
56
-
57
- //#endregion
58
6
  //#region src/queue/QueueBuilder.ts
59
7
  /**
60
8
  * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
@@ -68,6 +16,8 @@ var QueueBuilder = class {
68
16
  _timeout = 3e4;
69
17
  _batchSize;
70
18
  _fifo;
19
+ _envelope = true;
20
+ _groupId;
71
21
  _services = [];
72
22
  _logger = DEFAULT_LOGGER;
73
23
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
@@ -81,9 +31,27 @@ var QueueBuilder = class {
81
31
  batchSize(batchSize) {
82
32
  return cloneWith(this, { _batchSize: batchSize });
83
33
  }
84
- /** Mark the queue as FIFO (deployed). */
34
+ /**
35
+ * Mark the queue as FIFO (deployed). Pass `{ groupId }` to give each message
36
+ * its message group, which the queue's publisher then sends: a FIFO queue
37
+ * refuses a message without one. Messages in one group keep their order.
38
+ */
85
39
  fifo(fifo = true) {
86
- return cloneWith(this, { _fifo: fifo });
40
+ if (typeof fifo === "boolean") return cloneWith(this, { _fifo: fifo });
41
+ return cloneWith(this, {
42
+ _fifo: true,
43
+ _groupId: fifo.groupId
44
+ });
45
+ }
46
+ /**
47
+ * Whether messages arrive in the `{ type, payload }` envelope the queue's
48
+ * publisher writes. Pass `false` for a queue fed by something else — an IoT
49
+ * rule, a webhook forwarder — whose bodies are the message as they stand: a
50
+ * body is then never unwrapped, even one that has a `payload` field of its
51
+ * own, and one that is not JSON is the message as a string.
52
+ */
53
+ envelope(envelope = true) {
54
+ return cloneWith(this, { _envelope: envelope });
87
55
  }
88
56
  services(services) {
89
57
  return cloneWith(this, { _services: [...this._services, ...services] });
@@ -98,7 +66,7 @@ var QueueBuilder = class {
98
66
  handle(fn) {
99
67
  if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
100
68
  if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
101
- const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo);
69
+ const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._envelope, this._groupId);
102
70
  return queue;
103
71
  }
104
72
  };
@@ -108,5 +76,5 @@ var QueueBuilder = class {
108
76
  const q = new QueueBuilder();
109
77
 
110
78
  //#endregion
111
- export { Queue, QueueBuilder, q };
79
+ export { Queue, QueueBuilder, isQueueResult, q };
112
80
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["DEFAULT_LOGGER","obj: unknown","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","name: T","timeout: number","batchSize: number","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import { environmentCase } from '@geekmidas/envkit';\nimport {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as unknown as Logger;\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t);\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;AAcA,MAAMA,mBAAiB,IAAI;;;;;;;;;;AAsB3B,IAAa,QAAb,cAKU,UAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAS,cAAc,MAC3C;CACD;CAED,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBP,kBAE3BQ,WAEAC,MACf;AACD,QACC,cAAc,OACd,QACA,UACA,CAAE,mBAGF,QACA;EAnBe;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;CAWhB;;;;;;;;;;;;CAaD,IAAI,YAGF;EACD,MAAM,UAAU,EAAE,gBAAgB,KAAK,KAAK,CAAC;AAC7C,SAAO;GACN,cAAc,EAAE,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","batchSize: number","fifo:\n\t\t\t| boolean\n\t\t\t| {\n\t\t\t\t\tgroupId: (\n\t\t\t\t\t\tmessage: TMessage extends StandardSchemaV1\n\t\t\t\t\t\t\t? InferStandardSchema<TMessage>\n\t\t\t\t\t\t\t: never,\n\t\t\t\t\t) => string;\n\t\t\t }","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _envelope = true;\n\tprivate _groupId?: (message: any) => string;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/**\n\t * Mark the queue as FIFO (deployed). Pass `{ groupId }` to give each message\n\t * its message group, which the queue's publisher then sends: a FIFO queue\n\t * refuses a message without one. Messages in one group keep their order.\n\t */\n\tfifo(\n\t\tfifo:\n\t\t\t| boolean\n\t\t\t| {\n\t\t\t\t\tgroupId: (\n\t\t\t\t\t\tmessage: TMessage extends StandardSchemaV1\n\t\t\t\t\t\t\t? InferStandardSchema<TMessage>\n\t\t\t\t\t\t\t: never,\n\t\t\t\t\t) => string;\n\t\t\t } = true,\n\t): this {\n\t\tif (typeof fifo === 'boolean') {\n\t\t\treturn cloneWith(this, { _fifo: fifo });\n\t\t}\n\t\treturn cloneWith(this, { _fifo: true, _groupId: fifo.groupId });\n\t}\n\n\t/**\n\t * Whether messages arrive in the `{ type, payload }` envelope the queue's\n\t * publisher writes. Pass `false` for a queue fed by something else — an IoT\n\t * rule, a webhook forwarder — whose bodies are the message as they stand: a\n\t * body is then never unwrapped, even one that has a `payload` field of its\n\t * own, and one that is not JSON is the message as a string.\n\t */\n\tenvelope(envelope = true): this {\n\t\treturn cloneWith(this, { _envelope: envelope });\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._envelope,\n\t\t\tthis._groupId,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tisQueueResult,\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n\ttype QueueRecord,\n\ttype QueueResult,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,eAAb,MAKE;CACD,AAAQ;CACR,AAAQ;CACR,AAAQ,WAAW;CACnB,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CACR,AAAQ,YAAuB,CAAE;CACjC,AAAQ,UAAmB;;CAG3B,MACCA,MACgD;AAChD,SAAO,UAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CAMvC;CAED,QAAQC,SAAuB;AAC9B,SAAO,UAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;;CAGD,UAAUC,WAAyB;AAClC,SAAO,UAAU,MAAM,EAAE,YAAY,UAAW,EAAC;CACjD;;;;;;CAOD,KACCC,OAQO,MACA;AACP,aAAW,SAAS,UACnB,QAAO,UAAU,MAAM,EAAE,OAAO,KAAM,EAAC;AAExC,SAAO,UAAU,MAAM;GAAE,OAAO;GAAM,UAAU,KAAK;EAAS,EAAC;CAC/D;;;;;;;;CASD,SAAS,WAAW,MAAY;AAC/B,SAAO,UAAU,MAAM,EAAE,WAAW,SAAU,EAAC;CAC/C;CAED,SACCC,UAC+D;AAC/D,SAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,UAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,UAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,WACL,KAAK;AAON,SAAO;CACP;AACD;;;;ACrID,MAAa,IAAI,IAAI"}
@@ -2,7 +2,7 @@ import "../Construct-BEh2DSMe.cjs";
2
2
  import { Subscriber, SubscriberHandler } from "../Subscriber-YwPpHrBc.cjs";
3
3
  import { Topic, TopicEvents, TopicMessage } from "../Topic-dIcPqSLa.cjs";
4
4
  import { EventPublisher, ExtractPublisherMessage } from "@geekmidas/events";
5
- import * as _geekmidas_logger10 from "@geekmidas/logger";
5
+ import * as _geekmidas_logger9 from "@geekmidas/logger";
6
6
  import { Logger } from "@geekmidas/logger";
7
7
  import { Service } from "@geekmidas/services";
8
8
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -40,7 +40,7 @@ declare class SubscriberBuilder<TServices extends Service[] = [], TLogger extend
40
40
  //# sourceMappingURL=SubscriberBuilder.d.ts.map
41
41
  //#endregion
42
42
  //#region src/subscribers/index.d.ts
43
- declare const s: SubscriberBuilder<[], _geekmidas_logger10.Logger, undefined, undefined, string, []>;
43
+ declare const s: SubscriberBuilder<[], _geekmidas_logger9.Logger, undefined, undefined, string, []>;
44
44
  //# sourceMappingURL=index.d.ts.map
45
45
 
46
46
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/SubscriberBuilder.ts","../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAYa,oCACM,gCACF,SAAS,0BACP,kEACM;;;;EAJZ,QAAA,SAAA;EAAiB,QAAA,OAAA;EAAA,QACX,UAAA;EAAO,QACT,UAAA;EAAM,WAAG,CAAA;EAAM;;;;;;;;;;;EAmCH,KAA3B,CAAA,cAAA,MAAA,EAAA,gBAN2C,WAM3C,CAAA,CAAA,KAAA,EALO,KAKP,CALa,KAKb,EALoB,OAKpB,CAAA,CAAA,EAJE,iBAIF,CAHA,SAGA,EAFA,OAEA,EADA,SACA,EAAA,cAAA,CAAe,YAAf,CAA4B,OAA5B,CAAA,CAAA,EACA,0BADA,EAEA,iBAFA,CAAA;EAAc,OACd,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAA0B,MAC1B,CAAA,UAkBgB,gBAlBhB,CAAA,CAAA,MAAA,EAmBQ,CAnBR,CAAA,EAoBE,iBApBF,CAqBA,SArBA,EAsBA,OAtBA,EAuBA,CAvBA,EAwBA,eAxBA,EAyBA,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BA5ED,EA6EC,SA7ED,EA8EC,OA9ED,EA+EC,SA/ED,CAAA,CAAA,EAiFE,UAjFF,CAkFA,SAlFA,EAmFA,OAnFA,EAoFA,SApFA,EAqFA,eArFA,EAsFA,0BAtFA,EAuFA,iBAvFA,CAAA;;;;;cCvEW,GAAC,sBAA0B,mBAAA,CAA1B,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/SubscriberBuilder.ts","../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAYa,oCACM,gCACF,SAAS,0BACP,kEACM;;;;EAJZ,QAAA,SAAA;EAAiB,QAAA,OAAA;EAAA,QACX,UAAA;EAAO,QACT,UAAA;EAAM,WAAG,CAAA;EAAM;;;;;;;;;;;EAmCH,KAA3B,CAAA,cAAA,MAAA,EAAA,gBAN2C,WAM3C,CAAA,CAAA,KAAA,EALO,KAKP,CALa,KAKb,EALoB,OAKpB,CAAA,CAAA,EAJE,iBAIF,CAHA,SAGA,EAFA,OAEA,EADA,SACA,EAAA,cAAA,CAAe,YAAf,CAA4B,OAA5B,CAAA,CAAA,EACA,0BADA,EAEA,iBAFA,CAAA;EAAc,OACd,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAA0B,MAC1B,CAAA,UAkBgB,gBAlBhB,CAAA,CAAA,MAAA,EAmBQ,CAnBR,CAAA,EAoBE,iBApBF,CAqBA,SArBA,EAsBA,OAtBA,EAuBA,CAvBA,EAwBA,eAxBA,EAyBA,0BAzBA,EA0BA,iBA1BA,CAAA;EAAiB,QANf,CAAA,UAuCgB,OAvChB,EAAA,CAAA,CAAA,QAAA,EAwCQ,CAxCR,CAAA,EAyCA,iBAzCA,CAAA,CAwBc,GAkBZ,SAlBY,EACR,GAiBU,CAjBV,CAAC,EAkBT,OAhBA,EAiBA,SAjBA,EAkBA,eAlBA,EAmBA,0BAnBA,EAoBA,iBApBA,CAAA;EAAS,MACT,CAAA,UA0BgB,MA1BhB,CAAA,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ber-panMf5vp.mjs";
3
- import { Topic, TopicEvents, TopicMessage } from "../Topic-DGtlTlu5.mjs";
1
+ import "../Construct-qnOnQTcP.mjs";
2
+ import { Subscriber, SubscriberHandler } from "../Subscriber-Bjil86Ub.mjs";
3
+ import { Topic, TopicEvents, TopicMessage } from "../Topic-D8-wkoh4.mjs";
4
4
  import { Service } from "@geekmidas/services";
5
5
  import { EventPublisher, ExtractPublisherMessage } from "@geekmidas/events";
6
6
  import { Logger as Logger$1 } from "@geekmidas/logger";
@@ -1,4 +1,4 @@
1
- import { Construct, ConstructType } from "../Construct-D5LZBFhb.mjs";
1
+ import { Construct, ConstructType } from "../Construct-DE-_c3UK.mjs";
2
2
  import { cloneWith } from "../clone-BWIwx6vL.mjs";
3
3
  import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
4
4
 
@@ -92,4 +92,4 @@ interface Telemetry {
92
92
  //# sourceMappingURL=telemetry.d.ts.map
93
93
  //#endregion
94
94
  export { Telemetry, TelemetryContext, TelemetryRequest, TelemetryResponse };
95
- //# sourceMappingURL=telemetry-Bp4DLvdQ.d.mts.map
95
+ //# sourceMappingURL=telemetry-vq7C0ZBy.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-Bp4DLvdQ.d.mts","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6FmB,UAlFF,gBAAA,CAkFE;EAAgB;;;EAQgB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;UAhFlC,gBAAA;;;;;;;;WASP;;;;;UAMO,iBAAA;;;;;;;;;;;;YAcN;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BM,SAAA;;;;;;;0BAOQ,mBAAmB;;;;;;;oBAQzB,4BAA4B;;;;;;;sBAQ1B,yBAAyB"}
1
+ {"version":3,"file":"telemetry-vq7C0ZBy.d.mts","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6FmB,UAlFF,gBAAA,CAkFE;EAAgB;;;EAQgB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;UAhFlC,gBAAA;;;;;;;;WASP;;;;;UAMO,iBAAA;;;;;;;;;;;;YAcN;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BM,SAAA;;;;;;;0BAOQ,mBAAmB;;;;;;;oBAQzB,4BAA4B;;;;;;;sBAQ1B,yBAAyB"}
@@ -1,5 +1,5 @@
1
- import "../Construct-CgluLUuF.mjs";
2
- import { Topic, TopicEvents, TopicMessage } from "../Topic-DGtlTlu5.mjs";
1
+ import "../Construct-qnOnQTcP.mjs";
2
+ import { Topic, TopicEvents, TopicMessage } from "../Topic-D8-wkoh4.mjs";
3
3
  import { Logger } from "@geekmidas/logger";
4
4
 
5
5
  //#region src/topic/TopicBuilder.d.ts
@@ -1,4 +1,4 @@
1
- import { Construct, ConstructType } from "../Construct-D5LZBFhb.mjs";
1
+ import { Construct, ConstructType } from "../Construct-DE-_c3UK.mjs";
2
2
  import { cloneWith } from "../clone-BWIwx6vL.mjs";
3
3
  import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
4
4
  import { environmentCase } from "@geekmidas/envkit";
@@ -6,4 +6,4 @@ type LowerHttpMethod<T extends HttpMethod> = Lowercase<T>;
6
6
 
7
7
  //#endregion
8
8
  export { HttpMethod, LowerHttpMethod, RemoveUndefined };
9
- //# sourceMappingURL=types-j0ti0JTY.d.mts.map
9
+ //# sourceMappingURL=types-X37z95fN.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-j0ti0JTY.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,6BAAA,MACC,CADD,IACM,CADS,CACP,CADO,CAAA,SAAA,SAAA,GAAA,KAAA,GACwB,CADxB,GAC4B,CAD5B,CAC8B,CAD9B,CAAA,EAAA;AACd,KAGD,UAAA,GAHC,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,OAAA,GAAA,QAAA,GAAA,SAAA;AAAK,KAWN,eAXM,CAAA,UAWoB,UAXpB,CAAA,GAWkC,SAXlC,CAW4C,CAX5C,CAAA"}
1
+ {"version":3,"file":"types-X37z95fN.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,6BAAA,MACC,CADD,IACM,CADS,CACP,CADO,CAAA,SAAA,SAAA,GAAA,KAAA,GACwB,CADxB,GAC4B,CAD5B,CAC8B,CAD9B,CAAA,EAAA;AACd,KAGD,UAAA,GAHC,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,OAAA,GAAA,QAAA,GAAA,SAAA;AAAK,KAWN,eAXM,CAAA,UAWoB,UAXpB,CAAA,GAWkC,SAXlC,CAW4C,CAX5C,CAAA"}
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-j0ti0JTY.mjs";
1
+ import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-X37z95fN.mjs";
2
2
  export { HttpMethod, LowerHttpMethod, RemoveUndefined };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/constructs",
3
- "version": "9.4.0",
3
+ "version": "9.6.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -152,33 +152,33 @@
152
152
  "pg": "~8.16.3",
153
153
  "msw": "~2.10.3",
154
154
  "zod": "~4.6.6",
155
- "@geekmidas/audit": "^9.4.0",
156
- "@geekmidas/cache": "^9.4.0",
157
- "@geekmidas/db": "^9.4.0",
158
- "@geekmidas/envkit": "^9.4.0",
159
- "@geekmidas/errors": "^9.4.0",
160
- "@geekmidas/events": "^9.4.0",
161
- "@geekmidas/logger": "^9.4.0",
162
- "@geekmidas/rate-limit": "^9.4.0",
163
- "@geekmidas/schema": "^9.4.0",
164
- "@geekmidas/services": "^9.4.0",
165
- "@geekmidas/testkit": "^9.4.0"
155
+ "@geekmidas/audit": "^9.6.0",
156
+ "@geekmidas/db": "^9.6.0",
157
+ "@geekmidas/envkit": "^9.6.0",
158
+ "@geekmidas/errors": "^9.6.0",
159
+ "@geekmidas/events": "^9.6.0",
160
+ "@geekmidas/logger": "^9.6.0",
161
+ "@geekmidas/rate-limit": "^9.6.0",
162
+ "@geekmidas/schema": "^9.6.0",
163
+ "@geekmidas/services": "^9.6.0",
164
+ "@geekmidas/testkit": "^9.6.0",
165
+ "@geekmidas/cache": "^9.6.0"
166
166
  },
167
167
  "peerDependencies": {
168
168
  "@middy/core": ">=6.3.1",
169
169
  "@types/aws-lambda": ">=8.10.92",
170
170
  "hono": ">=4.8.2",
171
171
  "msw": ">=2.0.0",
172
- "@geekmidas/audit": "^9.4.0",
173
- "@geekmidas/cache": "^9.4.0",
174
- "@geekmidas/db": "^9.4.0",
175
- "@geekmidas/envkit": "^9.4.0",
176
- "@geekmidas/errors": "^9.4.0",
177
- "@geekmidas/events": "^9.4.0",
178
- "@geekmidas/logger": "^9.4.0",
179
- "@geekmidas/rate-limit": "^9.4.0",
180
- "@geekmidas/schema": "^9.4.0",
181
- "@geekmidas/services": "^9.4.0"
172
+ "@geekmidas/audit": "^9.6.0",
173
+ "@geekmidas/cache": "^9.6.0",
174
+ "@geekmidas/db": "^9.6.0",
175
+ "@geekmidas/envkit": "^9.6.0",
176
+ "@geekmidas/errors": "^9.6.0",
177
+ "@geekmidas/events": "^9.6.0",
178
+ "@geekmidas/logger": "^9.6.0",
179
+ "@geekmidas/rate-limit": "^9.6.0",
180
+ "@geekmidas/schema": "^9.6.0",
181
+ "@geekmidas/services": "^9.6.0"
182
182
  },
183
183
  "peerDependenciesMeta": {
184
184
  "@geekmidas/audit": {
@@ -12,7 +12,7 @@ import type {
12
12
  SQSEvent,
13
13
  SQSRecord,
14
14
  } from 'aws-lambda';
15
- import type { Queue } from './Queue';
15
+ import { isQueueResult, type Queue, type QueueRecord } from './Queue';
16
16
 
17
17
  export type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<
18
18
  TEvent,
@@ -26,9 +26,10 @@ export type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<
26
26
  * unwrapped to its `payload`, validated against the queue's `messageSchema`, and
27
27
  * the whole batch is handed to the handler as `messages`.
28
28
  *
29
- * Uses SQS partial-batch responses: a record that fails to parse, validate, or
30
- * (when the handler throws) process is returned in `batchItemFailures` so SQS
31
- * retries only those records.
29
+ * Uses SQS partial-batch responses: a record that fails to parse or validate
30
+ * is returned in `batchItemFailures`, so SQS retries only it. After that, the
31
+ * handler decides: returning a {@link QueueResult} retries only the records it
32
+ * names, and throwing retries every record in the batch.
32
33
  */
33
34
  export class AWSLambdaQueue<
34
35
  TName extends string = string,
@@ -74,10 +75,14 @@ export class AWSLambdaQueue<
74
75
 
75
76
  /**
76
77
  * Unwrap the queue payload from an SQS record. The SQS publisher writes
77
- * `{ type, payload }`; a payload-only body is also accepted as-is.
78
+ * `{ type, payload }`; a payload-only body is also accepted as-is. A queue
79
+ * built with `.envelope(false)` is never unwrapped: its body is the message.
78
80
  */
79
81
  private extractPayload(record: SQSRecord): unknown {
80
82
  const body = this.safeJsonParse(record.body);
83
+ if (!this.queue.envelope) {
84
+ return body ?? record.body;
85
+ }
81
86
  if (body && typeof body === 'object' && 'payload' in body) {
82
87
  return (body as { payload: unknown }).payload;
83
88
  }
@@ -100,7 +105,7 @@ export class AWSLambdaQueue<
100
105
  const schema = this.queue.messageSchema;
101
106
 
102
107
  const batchItemFailures: { itemIdentifier: string }[] = [];
103
- const messages: InferStandardSchema<TMessage>[] = [];
108
+ const records: QueueRecord<TMessage>[] = [];
104
109
 
105
110
  for (const record of event.Records) {
106
111
  try {
@@ -114,7 +119,10 @@ export class AWSLambdaQueue<
114
119
  batchItemFailures.push({ itemIdentifier: record.messageId });
115
120
  continue;
116
121
  }
117
- messages.push(validation.value as InferStandardSchema<TMessage>);
122
+ records.push({
123
+ id: record.messageId,
124
+ message: validation.value as InferStandardSchema<TMessage>,
125
+ });
118
126
  } catch (error) {
119
127
  logger.error(
120
128
  { error, messageId: record.messageId },
@@ -124,12 +132,33 @@ export class AWSLambdaQueue<
124
132
  }
125
133
  }
126
134
 
127
- if (messages.length === 0) {
135
+ if (records.length === 0) {
128
136
  return { batchItemFailures };
129
137
  }
130
138
 
131
139
  try {
132
- await this.queue.handler({ messages, services, logger });
140
+ const result = await this.queue.handler({
141
+ messages: records.map((r) => r.message),
142
+ records,
143
+ services,
144
+ logger,
145
+ });
146
+
147
+ if (isQueueResult(result)) {
148
+ const handed = new Set(records.map((r) => r.id));
149
+ const unknown = result.failed.filter((id) => !handed.has(id));
150
+ if (unknown.length > 0) {
151
+ logger.warn(
152
+ { unknown },
153
+ 'Queue handler reported records not in its batch',
154
+ );
155
+ }
156
+ for (const id of result.failed) {
157
+ if (handed.has(id)) {
158
+ batchItemFailures.push({ itemIdentifier: id });
159
+ }
160
+ }
161
+ }
133
162
  } catch (error) {
134
163
  logger.error(wrapError(error), 'Queue handler failed; retrying batch');
135
164
  // Handler processes the batch atomically — fail the whole batch so SQS