@geekmidas/cli 9.4.0 → 9.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @geekmidas/cli
2
2
 
3
+ ## 9.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#462](https://github.com/geekmidas/toolbox/pull/462) [`9a4cef0`](https://github.com/geekmidas/toolbox/commit/9a4cef04d59cf001b597c697cdf1a0e096109347) Thanks [@geekmidas](https://github.com/geekmidas)! - Queue handlers can retry only the messages that failed
8
+
9
+ A handler now receives `records` beside `messages`: the same batch, each message with the id its transport gave it (the SQS message id deployed, a generated id under `gkm dev`). Returning `{ failed: [...ids] }` retries only those records; the rest of the batch is acknowledged.
10
+
11
+ ```ts
12
+ export const ordersQueue = q
13
+ .queue("orders")
14
+ .message(OrderSchema)
15
+ .handle(async ({ records, services }) => {
16
+ const failed: string[] = [];
17
+ for (const { id, message } of records) {
18
+ try {
19
+ await services.orders.fulfil(message);
20
+ } catch {
21
+ failed.push(id);
22
+ }
23
+ }
24
+ return { failed };
25
+ });
26
+ ```
27
+
28
+ Before, a handler could only retry the whole batch by throwing, so one bad message redelivered every message that had already succeeded. Throwing still does that, and a handler that returns nothing still acknowledges the batch, so existing queues behave as before.
29
+
30
+ `TestQueueAdaptor.invoke` takes `records` as well as `messages`, to drive a handler with chosen ids. `QueueRecord`, `QueueResult` and `isQueueResult` are exported from `@geekmidas/constructs/queue`.
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [[`9a4cef0`](https://github.com/geekmidas/toolbox/commit/9a4cef04d59cf001b597c697cdf1a0e096109347)]:
35
+ - @geekmidas/constructs@9.5.0
36
+ - @geekmidas/envkit@9.5.0
37
+ - @geekmidas/errors@9.5.0
38
+ - @geekmidas/logger@9.5.0
39
+ - @geekmidas/manifest@9.5.0
40
+ - @geekmidas/schema@9.5.0
41
+ - @geekmidas/telescope@9.5.0
42
+
3
43
  ## 9.4.0
4
44
 
5
45
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -37,7 +37,7 @@ const prompts = require_chunk.__toESM(require("prompts"));
37
37
 
38
38
  //#region package.json
39
39
  var name = "@geekmidas/cli";
40
- var version = "9.3.0";
40
+ var version = "9.4.0";
41
41
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
42
42
  var private$1 = false;
43
43
  var type = "module";
@@ -598,6 +598,8 @@ import type { EnvironmentParser } from '@geekmidas/envkit';
598
598
  import type { Logger } from '@geekmidas/logger';
599
599
  import { EventConnectionFactory, Subscriber } from '@geekmidas/events';
600
600
  import type { EventConnection, EventSubscriber } from '@geekmidas/events';
601
+ import { randomUUID } from 'node:crypto';
602
+ import { isQueueResult } from '@geekmidas/constructs/queue';
601
603
  import { ServiceDiscovery } from '@geekmidas/services';
602
604
  ${imports}
603
605
 
@@ -650,12 +652,21 @@ export async function setupQueues(
650
652
  return;
651
653
  }
652
654
 
653
- await queue.handler({
655
+ // One message per delivery locally, so it gets an id of its own for
656
+ // the handler to report it by, as SQS's message id is deployed.
657
+ const id = randomUUID();
658
+ const result = await queue.handler({
654
659
  messages: [validation.value],
660
+ records: [{ id, message: validation.value }],
655
661
  services: services,
656
662
  logger: queue.logger,
657
663
  });
658
664
 
665
+ if (isQueueResult(result) && result.failed.includes(id)) {
666
+ logger.error({ queue: queue.name }, 'Queue handler reported the message as failed');
667
+ return;
668
+ }
669
+
659
670
  logger.debug({ queue: queue.name }, 'Successfully processed queue message');
660
671
  } catch (error) {
661
672
  logger.error({ error, queue: queue.name }, 'Failed to process queue message');
@@ -6947,25 +6958,25 @@ const CLI_VERSION = `~${pkg.version}`;
6947
6958
  * Run: pnpm --filter @geekmidas/cli sync-versions
6948
6959
  */
6949
6960
  const GEEKMIDAS_VERSIONS = {
6950
- "@geekmidas/audit": "~9.3.0",
6951
- "@geekmidas/auth": "~9.3.0",
6952
- "@geekmidas/cache": "~9.3.0",
6953
- "@geekmidas/client": "~9.3.0",
6954
- "@geekmidas/cloud": "~9.3.0",
6955
- "@geekmidas/constructs": "~9.3.0",
6956
- "@geekmidas/db": "~9.3.0",
6957
- "@geekmidas/emailkit": "~9.3.0",
6958
- "@geekmidas/envkit": "~9.3.0",
6959
- "@geekmidas/errors": "~9.3.0",
6960
- "@geekmidas/events": "~9.3.0",
6961
- "@geekmidas/logger": "~9.3.0",
6962
- "@geekmidas/rate-limit": "~9.3.0",
6963
- "@geekmidas/schema": "~9.3.0",
6964
- "@geekmidas/services": "~9.3.0",
6965
- "@geekmidas/storage": "~9.3.0",
6966
- "@geekmidas/studio": "~9.3.0",
6967
- "@geekmidas/telescope": "~9.3.0",
6968
- "@geekmidas/testkit": "~9.3.0",
6961
+ "@geekmidas/audit": "~9.4.0",
6962
+ "@geekmidas/auth": "~9.4.0",
6963
+ "@geekmidas/cache": "~9.4.0",
6964
+ "@geekmidas/client": "~9.4.0",
6965
+ "@geekmidas/cloud": "~9.4.0",
6966
+ "@geekmidas/constructs": "~9.4.0",
6967
+ "@geekmidas/db": "~9.4.0",
6968
+ "@geekmidas/emailkit": "~9.4.0",
6969
+ "@geekmidas/envkit": "~9.4.0",
6970
+ "@geekmidas/errors": "~9.4.0",
6971
+ "@geekmidas/events": "~9.4.0",
6972
+ "@geekmidas/logger": "~9.4.0",
6973
+ "@geekmidas/rate-limit": "~9.4.0",
6974
+ "@geekmidas/schema": "~9.4.0",
6975
+ "@geekmidas/services": "~9.4.0",
6976
+ "@geekmidas/storage": "~9.4.0",
6977
+ "@geekmidas/studio": "~9.4.0",
6978
+ "@geekmidas/telescope": "~9.4.0",
6979
+ "@geekmidas/testkit": "~9.4.0",
6969
6980
  "@geekmidas/cli": CLI_VERSION
6970
6981
  };
6971
6982