@adobe-commerce/aio-toolkit 1.2.4 → 1.2.6

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 (31) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +169 -0
  3. package/dist/aio-toolkit-cli-workflow/bin/cli.js +2048 -0
  4. package/dist/aio-toolkit-cli-workflow/bin/cli.js.map +1 -0
  5. package/dist/aio-toolkit-cursor-context/bin/cli.js +16 -0
  6. package/dist/aio-toolkit-cursor-context/bin/cli.js.map +1 -1
  7. package/dist/index.d.mts +51 -6
  8. package/dist/index.d.ts +51 -6
  9. package/dist/index.js +209 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +213 -0
  12. package/dist/index.mjs.map +1 -1
  13. package/files/cursor-context/commands/aio-toolkit-analyze-adobe-commerce-module.md +612 -0
  14. package/files/cursor-context/commands/aio-toolkit-create-amazon-sqs-consumer.md +445 -0
  15. package/files/cursor-context/commands/aio-toolkit-create-event-consumer-action.md +6 -0
  16. package/files/cursor-context/commands/aio-toolkit-create-graphql-action.md +21 -7
  17. package/files/cursor-context/commands/aio-toolkit-create-openwhisk-action.md +326 -0
  18. package/files/cursor-context/commands/aio-toolkit-create-runtime-action.md +15 -5
  19. package/files/cursor-context/commands/aio-toolkit-create-shipping-carrier.md +681 -0
  20. package/files/cursor-context/commands/aio-toolkit-create-webhook-action.md +22 -9
  21. package/files/cursor-context/rules/aio-toolkit-create-adobe-commerce-client.mdc +252 -116
  22. package/files/cursor-context/rules/aio-toolkit-oop-best-practices.mdc +10 -4
  23. package/files/cursor-context/rules/aio-toolkit-setup-new-relic-telemetry.mdc +167 -2
  24. package/files/cursor-context/rules/aio-toolkit-use-abdb-collection.mdc +610 -0
  25. package/files/cursor-context/rules/aio-toolkit-use-abdb-repository.mdc +705 -0
  26. package/files/cursor-context/rules/aio-toolkit-use-adobe-auth.mdc +442 -0
  27. package/files/cursor-context/rules/aio-toolkit-use-amazon-sqs-publish.mdc +397 -0
  28. package/files/cursor-context/rules/aio-toolkit-use-file-repository.mdc +502 -0
  29. package/files/cursor-context/rules/aio-toolkit-use-publish-event.mdc +510 -0
  30. package/files/cursor-context/rules/aio-toolkit-use-runtime-api-gateway-service.mdc +542 -0
  31. package/package.json +4 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,151 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.6] - 2026-05-10
9
+
10
+ ### ✨ Features
11
+
12
+ - **feat(cli-workflow): add `aio-toolkit-cli-workflow` CLI**
13
+
14
+ New `npx aio-toolkit-cli-workflow` binary for orchestrating Adobe I/O CLI workflows.
15
+ Performs an AIO CLI pre-flight check with installation guidance on startup.
16
+
17
+ **`env:setup`** — interactive environment configuration:
18
+ - Prompts "Do you have a workspace config file?" and runs `aio app use <file>` if yes.
19
+ - Falls back to `aio console org select` → `aio console project select` → `aio console workspace select` if no config file is provided.
20
+ - Accepts `--config-file` to skip the prompt and use a specified file directly.
21
+
22
+ **`env:reset`** — full AIO CLI environment reset:
23
+ - Accepts `--env stage|prod` (default `prod`).
24
+ - Runs: logout → clear local & global config → telemetry off → set env → login → telemetry on.
25
+
26
+ **`cron:enable`** — enable AIO Runtime cron rules:
27
+ - Confirms the current workspace, lists rules via `aio rt rule list --json`, and prompts for rule selection.
28
+ - Accepts `--all` to enable every rule without prompting.
29
+
30
+ **`cron:disable`** — disable AIO Runtime cron rules:
31
+ - Mirrors `cron:enable` but calls `aio rt rule disable`.
32
+
33
+ **`cron:status`** — display detailed cron rule status:
34
+ - Lists all rules with action name, status, trigger name, cron schedule, and version.
35
+ - Accepts `--name <ruleName>` to inspect a single rule.
36
+ - Uses a multi-strategy JSON parser (stdout/stderr fallback, ANSI stripping, oclif-envelope unwrapping, prefix-text slicing) for reliable output capture.
37
+
38
+ **`cron:delete`** — delete cron rules and their triggers:
39
+ - Confirms workspace, prompts for rule selection, then deletes the trigger (`aio rt trigger delete`) before the rule (`aio rt rule delete`).
40
+
41
+ - **feat(integration): add `AmazonSQSClient`**
42
+
43
+ New `AmazonSQSClient` in `src/integration/amazon-sqs-client/` for Amazon SQS integration:
44
+ - **Batched publish** for standard and FIFO queues (with `MessageGroupId` and `MessageDeduplicationId` support).
45
+ - **Long-polling consume** with configurable batch size, wait time, and auto-deletion.
46
+ - Full TypeScript types: `AmazonSQSConfig`, `MessageHandler`, `PublishStats`, `ConsumeStats`.
47
+ - 38 tests with 100% statement, branch, function, and line coverage.
48
+
49
+ ### 🛠️ Internal
50
+
51
+ - **feat(framework): add `ParseCliFlag` helper**
52
+
53
+ New `ParseCliFlag` class with a static `parse(args, flag)` method that handles both
54
+ `--flag=value` and `--flag value` argument styles. Used by `env:setup`, `env:reset`,
55
+ and `cron:status`.
56
+
57
+ - **feat(framework): add `AioCliDetector` helper**
58
+
59
+ New `AioCliDetector` class to detect whether the `aio` CLI is installed and to verify
60
+ availability of sub-commands. Integrated into the `aio-toolkit-cli-workflow` startup check.
61
+
62
+ - **feat(framework): extend `CommandDescriptor` with `options`**
63
+
64
+ Added optional `options?: CommandOption[]` to `CommandDescriptor` so each command class
65
+ can declare its own flags. `CliWorkflowHelp` reads these dynamically when rendering help output.
66
+
67
+ ### 📚 Documentation & Cursor Context
68
+
69
+ - **Package overview** — added `docs/OVERVIEW.md` covering installation, dependency
70
+ resolution, and a full module index for all toolkit components.
71
+
72
+ - **Framework reference docs** — new docs added under `docs/framework/`:
73
+ `runtime-action`, `webhook-action`, `graphql-action`, `event-consumer-action`,
74
+ `openwhisk`, `publish-event`, `abdb-collection`, `abdb-repository`,
75
+ `file-repository`, `runtime-api-gateway-service`, `telemetry`.
76
+
77
+ - **Commerce reference docs** — new docs added under `docs/commerce/`:
78
+ `adobe-commerce-client`, `adobe-auth`, `shipping-carrier`, `onboard-commerce`.
79
+
80
+ - **Integration reference docs** — new `docs/integration/amazon-sqs-client.md`.
81
+
82
+ - **Security rules** — 13 global security rules added under `.cursor/rules/security-global/`
83
+ covering API security, authentication, injection, SSRF, path traversal, SQL, XXE,
84
+ output encoding, data protection, error handling, dependency management, input validation,
85
+ and dangerous flows. Also added `security-lang-node.mdc` for Node.js-specific patterns.
86
+
87
+ - **New Cursor commands**:
88
+ - `aio-toolkit-create-openwhisk-action.md` — AI-guided scaffolding for OpenWhisk sub-actions and orchestrators.
89
+ - `aio-toolkit-analyze-adobe-commerce-module.md` — analyzes existing Adobe Commerce modules.
90
+ - `aio-toolkit-create-shipping-carrier.md` — scaffolds a custom shipping carrier integration.
91
+ - `aio-toolkit-create-amazon-sqs-consumer.md` — scaffolds an Amazon SQS consumer action.
92
+
93
+ - **New Cursor rules**:
94
+ - `aio-toolkit-use-publish-event.mdc` — guides integrating `PublishEvent` for CloudEvents publishing to Adobe I/O Events.
95
+ - `aio-toolkit-use-abdb-collection.mdc` — guides schema-validated ABDB collection usage.
96
+ - `aio-toolkit-use-abdb-repository.mdc` — guides repository pattern usage with ABDB.
97
+ - `aio-toolkit-use-file-repository.mdc` — guides Adobe I/O Files-based persistence.
98
+ - `aio-toolkit-use-runtime-api-gateway-service.mdc` — guides API Gateway HTTP calls via `RuntimeApiGatewayService`.
99
+ - `aio-toolkit-use-adobe-auth.mdc` — guides Adobe IMS authentication patterns.
100
+ - `aio-toolkit-use-amazon-sqs-publish.mdc` — guides SQS message publishing with `AmazonSQSClient`.
101
+
102
+ ### 🔧 Fixes & Improvements
103
+
104
+ - **fix(cursor): rename exception field `class` → `type` in webhook command**
105
+
106
+ `WebhookActionResponse.exception()` parameter renamed from `exceptionClass` to
107
+ `exceptionType` and the JSON response field from `class` to `type`, matching the
108
+ actual library behavior introduced in v1.2.4.
109
+
110
+ - **fix(cursor): correct `IMS_ORD_ID` typo to `IMS_ORG_ID` in Commerce client rule**
111
+
112
+ All env var references in `aio-toolkit-create-adobe-commerce-client.mdc` now use
113
+ the correct `IMS_ORG_ID` key.
114
+
115
+ - **fix(cursor): document `raw-http: true` requirement for webhook signature verification**
116
+
117
+ The webhook command now explicitly states that `raw-http: true` must be set under
118
+ `annotations:` in `app.config.yaml` for signature verification to work.
119
+
120
+ - **fix(cursor): expand GraphQL resolver `ctx` destructuring in commands and rules**
121
+
122
+ Resolver examples now show the full context (`logger`, `headers`, `telemetry`,
123
+ `params`) with inline descriptions of each field.
124
+
125
+ - **fix(cursor): add HEAD/OPTIONS to supported HTTP methods in runtime-action command**
126
+
127
+ `create-runtime-action.md` now lists all six supported methods including `HEAD`
128
+ and `OPTIONS`.
129
+
130
+ - **fix(cursor): document optional `headers` parameter on `RuntimeActionResponse.success()`**
131
+
132
+ Updated command docs to reflect that `success(result, headers?)` accepts an optional
133
+ second argument for custom HTTP response headers.
134
+
135
+ - **chore(cursor): set `alwaysApply: false` on Commerce client rule**
136
+
137
+ `aio-toolkit-create-adobe-commerce-client.mdc` is now opt-in; it was previously
138
+ applying on every session regardless of context.
139
+
140
+ ---
141
+
142
+ ## [1.2.5] - 2026-04-20
143
+
144
+ ### 🔧 Chores
145
+
146
+ - **chore(release): bump version to 1.2.5 to fix version inconsistency**
147
+
148
+ Version was out of sync between the package and the release tag. This patch
149
+ release corrects the version number with no functional code changes.
150
+
151
+ ---
152
+
8
153
  ## [1.2.4] - 2026-04-20
9
154
 
10
155
  ### ✨ Features
package/README.md CHANGED
@@ -1650,6 +1650,73 @@ if (stats.errors.length) {
1650
1650
 
1651
1651
  ---
1652
1652
 
1653
+ #### `AmazonSQSClient`
1654
+ Batched publisher and long-polling consumer for Amazon SQS standard and FIFO queues.
1655
+
1656
+ **Installation**
1657
+ ```bash
1658
+ npm install @aws-sdk/client-sqs
1659
+ ```
1660
+
1661
+ **Basic Usage**
1662
+ ```typescript
1663
+ const { AmazonSQSClient } = require('@adobe-commerce/aio-toolkit');
1664
+
1665
+ const client = new AmazonSQSClient({
1666
+ region: 'us-east-1',
1667
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
1668
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
1669
+ queueUrl: 'https://sqs.us-east-1.amazonaws.com/123456789/my-queue',
1670
+ });
1671
+ ```
1672
+
1673
+ **Publishing messages**
1674
+ ```typescript
1675
+ const payloads = orders.map(o => JSON.stringify(o));
1676
+ const stats = await client.publish(payloads);
1677
+
1678
+ console.log(`published=${stats.published} failed=${stats.failed}`);
1679
+ if (stats.errors.length) {
1680
+ console.error('Failed payloads:', stats.errors);
1681
+ }
1682
+ ```
1683
+
1684
+ **Publishing to a FIFO queue**
1685
+ ```typescript
1686
+ const fifoClient = new AmazonSQSClient({
1687
+ region: 'us-east-1',
1688
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
1689
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
1690
+ queueUrl: 'https://sqs.us-east-1.amazonaws.com/123456789/my-queue.fifo',
1691
+ messageGroupId: 'order-processing', // required for FIFO
1692
+ messageDeduplicationId: 'unique-batch-id', // optional — omit to use content-based dedup
1693
+ });
1694
+
1695
+ const stats = await fifoClient.publish(payloads);
1696
+ ```
1697
+
1698
+ **Consuming messages**
1699
+ ```typescript
1700
+ const stats = await client.consume(
1701
+ { batchSize: 10, waitTimeSeconds: 20 }, // long polling
1702
+ async (message) => {
1703
+ const order = JSON.parse(message.body);
1704
+ await processOrder(order);
1705
+ }
1706
+ );
1707
+
1708
+ console.log(`consumed=${stats.consumed} acked=${stats.acked} failed=${stats.failed}`);
1709
+ ```
1710
+
1711
+ **API Reference**
1712
+
1713
+ | Method | Description | Returns |
1714
+ |---|---|---|
1715
+ | `publish(payloads)` | Sends each payload as an SQS message; FIFO queues include group/dedup IDs | `Promise<PublishStats>` |
1716
+ | `consume(options, handler)` | Long-polls the queue, invokes `handler` for each message, auto-deletes on success | `Promise<ConsumeStats>` |
1717
+
1718
+ ---
1719
+
1653
1720
  #### `InfiniteLoopBreaker`
1654
1721
  Detect and prevent infinite loops in event-driven applications.
1655
1722
 
@@ -2118,6 +2185,108 @@ deployment:
2118
2185
  3. **CI/CD Integration**: Automate event configuration in deployment pipelines
2119
2186
  4. **Multi-Environment Setup**: Use different config files for dev/staging/production environments
2120
2187
 
2188
+ #### `aio-toolkit-cli-workflow`
2189
+
2190
+ Command-line tool for orchestrating Adobe I/O CLI workflows in your App Builder projects. This CLI acts as a wrapper around the `aio` CLI to streamline environment setup, resets, and cron rule management via interactive prompts.
2191
+
2192
+ > **Prerequisite:** The `aio` CLI must be installed. If it is missing, the command will detect this at startup and print installation instructions pointing to the [Adobe App Builder CLI install guide](https://developer.adobe.com/app-builder/docs/guides/runtime_guides/tools/cli-install).
2193
+
2194
+ ##### Commands
2195
+
2196
+ ###### `env:setup`
2197
+ Interactively configure the AIO Console environment (org → project → workspace).
2198
+
2199
+ ```bash
2200
+ npx aio-toolkit-cli-workflow env:setup
2201
+
2202
+ # Skip the interactive prompt and use a specific workspace config file
2203
+ npx aio-toolkit-cli-workflow env:setup --config-file ./path/to/.aio
2204
+ ```
2205
+
2206
+ **Flow without `--config-file`:**
2207
+ 1. Prompts "Do you have a workspace config file?" (yes/no).
2208
+ 2. If **yes** — prompts for the file path and runs `aio app use <file>`.
2209
+ 3. If **no** — runs `aio console org select` → `aio console project select` → `aio console workspace select` interactively.
2210
+
2211
+ ###### `env:reset`
2212
+ Fully reset the AIO CLI environment and re-authenticate.
2213
+
2214
+ ```bash
2215
+ # Reset for production (default)
2216
+ npx aio-toolkit-cli-workflow env:reset
2217
+
2218
+ # Reset for staging
2219
+ npx aio-toolkit-cli-workflow env:reset --env stage
2220
+ ```
2221
+
2222
+ **Steps performed:**
2223
+ 1. `aio auth logout`
2224
+ 2. `aio config clear -f` (local) + `aio config clear -g -f` (global)
2225
+ 3. `aio telemetry off`
2226
+ 4. `aio config set cli.env <stage|prod>`
2227
+ 5. `aio auth login`
2228
+ 6. `aio telemetry on`
2229
+
2230
+ After reset, verify with `aio config get cli.env` and `aio console where`.
2231
+
2232
+ ###### `cron:status`
2233
+ Display the status of all AIO Runtime cron rules in the current workspace.
2234
+
2235
+ ```bash
2236
+ # List all cron rules
2237
+ npx aio-toolkit-cli-workflow cron:status
2238
+
2239
+ # Inspect a single rule by name
2240
+ npx aio-toolkit-cli-workflow cron:status --name myRuleName
2241
+ ```
2242
+
2243
+ **Output per rule:** rule name, status (active/inactive), action name, action path, publish status, trigger name, cron schedule, version.
2244
+
2245
+ ###### `cron:enable`
2246
+ Enable AIO Runtime cron rules interactively.
2247
+
2248
+ ```bash
2249
+ # Interactive rule selection
2250
+ npx aio-toolkit-cli-workflow cron:enable
2251
+
2252
+ # Enable all rules without prompting
2253
+ npx aio-toolkit-cli-workflow cron:enable --all
2254
+ ```
2255
+
2256
+ ###### `cron:disable`
2257
+ Disable AIO Runtime cron rules interactively.
2258
+
2259
+ ```bash
2260
+ # Interactive rule selection
2261
+ npx aio-toolkit-cli-workflow cron:disable
2262
+
2263
+ # Disable all rules without prompting
2264
+ npx aio-toolkit-cli-workflow cron:disable --all
2265
+ ```
2266
+
2267
+ ###### `cron:delete`
2268
+ Delete AIO Runtime cron rules and their associated triggers.
2269
+
2270
+ ```bash
2271
+ npx aio-toolkit-cli-workflow cron:delete
2272
+ ```
2273
+
2274
+ Confirms the workspace, lists all rules (with trigger names), and prompts for one or more rule numbers to delete. For each selected rule the associated trigger is deleted first (`aio rt trigger delete`) and then the rule (`aio rt rule delete`).
2275
+
2276
+ ###### `help`
2277
+ Displays help information for the CLI.
2278
+
2279
+ ```bash
2280
+ npx aio-toolkit-cli-workflow help
2281
+ ```
2282
+
2283
+ ##### Use Cases
2284
+
2285
+ 1. **First-time setup**: Run `env:setup` to select org, project, and workspace in one step.
2286
+ 2. **Environment switching**: Run `env:reset --env stage` or `env:reset --env prod` to cleanly switch AIO CLI environments.
2287
+ 3. **Cron management**: Use `cron:status` to audit schedules, then `cron:enable` / `cron:disable` to control them without memorising `aio rt` commands.
2288
+ 4. **Rule cleanup**: Use `cron:delete` to remove stale rules and their triggers together.
2289
+
2121
2290
  ## Environment Variables
2122
2291
 
2123
2292
  Common environment variables used across components: