@geekmidas/cli 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.
- package/CHANGELOG.md +53 -0
- package/dist/index.cjs +32 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +32 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/generators/QueueGenerator.ts +12 -1
- package/src/generators/__tests__/QueueGenerator.spec.ts +4 -0
- package/src/init/versions.ts +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @geekmidas/cli
|
|
2
2
|
|
|
3
|
+
## 9.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6ca73be`](https://github.com/geekmidas/toolbox/commit/6ca73be57c19d21b7e14048968674a5fea9debd5), [`6ca73be`](https://github.com/geekmidas/toolbox/commit/6ca73be57c19d21b7e14048968674a5fea9debd5)]:
|
|
8
|
+
- @geekmidas/constructs@9.6.0
|
|
9
|
+
- @geekmidas/envkit@9.6.0
|
|
10
|
+
- @geekmidas/errors@9.6.0
|
|
11
|
+
- @geekmidas/logger@9.6.0
|
|
12
|
+
- @geekmidas/manifest@9.6.0
|
|
13
|
+
- @geekmidas/schema@9.6.0
|
|
14
|
+
- @geekmidas/telescope@9.6.0
|
|
15
|
+
|
|
16
|
+
## 9.5.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [#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
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
export const ordersQueue = q
|
|
26
|
+
.queue("orders")
|
|
27
|
+
.message(OrderSchema)
|
|
28
|
+
.handle(async ({ records, services }) => {
|
|
29
|
+
const failed: string[] = [];
|
|
30
|
+
for (const { id, message } of records) {
|
|
31
|
+
try {
|
|
32
|
+
await services.orders.fulfil(message);
|
|
33
|
+
} catch {
|
|
34
|
+
failed.push(id);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { failed };
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
`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`.
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`9a4cef0`](https://github.com/geekmidas/toolbox/commit/9a4cef04d59cf001b597c697cdf1a0e096109347)]:
|
|
48
|
+
- @geekmidas/constructs@9.5.0
|
|
49
|
+
- @geekmidas/envkit@9.5.0
|
|
50
|
+
- @geekmidas/errors@9.5.0
|
|
51
|
+
- @geekmidas/logger@9.5.0
|
|
52
|
+
- @geekmidas/manifest@9.5.0
|
|
53
|
+
- @geekmidas/schema@9.5.0
|
|
54
|
+
- @geekmidas/telescope@9.5.0
|
|
55
|
+
|
|
3
56
|
## 9.4.0
|
|
4
57
|
|
|
5
58
|
### 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.
|
|
40
|
+
var version = "9.5.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
|
-
|
|
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.
|
|
6951
|
-
"@geekmidas/auth": "~9.
|
|
6952
|
-
"@geekmidas/cache": "~9.
|
|
6953
|
-
"@geekmidas/client": "~9.
|
|
6954
|
-
"@geekmidas/cloud": "~9.
|
|
6955
|
-
"@geekmidas/constructs": "~9.
|
|
6956
|
-
"@geekmidas/db": "~9.
|
|
6957
|
-
"@geekmidas/emailkit": "~9.
|
|
6958
|
-
"@geekmidas/envkit": "~9.
|
|
6959
|
-
"@geekmidas/errors": "~9.
|
|
6960
|
-
"@geekmidas/events": "~9.
|
|
6961
|
-
"@geekmidas/logger": "~9.
|
|
6962
|
-
"@geekmidas/rate-limit": "~9.
|
|
6963
|
-
"@geekmidas/schema": "~9.
|
|
6964
|
-
"@geekmidas/services": "~9.
|
|
6965
|
-
"@geekmidas/storage": "~9.
|
|
6966
|
-
"@geekmidas/studio": "~9.
|
|
6967
|
-
"@geekmidas/telescope": "~9.
|
|
6968
|
-
"@geekmidas/testkit": "~9.
|
|
6961
|
+
"@geekmidas/audit": "~9.5.0",
|
|
6962
|
+
"@geekmidas/auth": "~9.5.0",
|
|
6963
|
+
"@geekmidas/cache": "~9.5.0",
|
|
6964
|
+
"@geekmidas/client": "~9.5.0",
|
|
6965
|
+
"@geekmidas/cloud": "~9.5.0",
|
|
6966
|
+
"@geekmidas/constructs": "~9.5.0",
|
|
6967
|
+
"@geekmidas/db": "~9.5.0",
|
|
6968
|
+
"@geekmidas/emailkit": "~9.5.0",
|
|
6969
|
+
"@geekmidas/envkit": "~9.5.0",
|
|
6970
|
+
"@geekmidas/errors": "~9.5.0",
|
|
6971
|
+
"@geekmidas/events": "~9.5.0",
|
|
6972
|
+
"@geekmidas/logger": "~9.5.0",
|
|
6973
|
+
"@geekmidas/rate-limit": "~9.5.0",
|
|
6974
|
+
"@geekmidas/schema": "~9.5.0",
|
|
6975
|
+
"@geekmidas/services": "~9.5.0",
|
|
6976
|
+
"@geekmidas/storage": "~9.5.0",
|
|
6977
|
+
"@geekmidas/studio": "~9.5.0",
|
|
6978
|
+
"@geekmidas/telescope": "~9.5.0",
|
|
6979
|
+
"@geekmidas/testkit": "~9.5.0",
|
|
6969
6980
|
"@geekmidas/cli": CLI_VERSION
|
|
6970
6981
|
};
|
|
6971
6982
|
|