@adobe-commerce/aio-toolkit 1.2.5 → 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 +134 -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/dist/index.mjs CHANGED
@@ -11876,6 +11876,218 @@ __name(_RabbitMQClient, "RabbitMQClient");
11876
11876
  var RabbitMQClient = _RabbitMQClient;
11877
11877
  var rabbit_mq_client_default = RabbitMQClient;
11878
11878
 
11879
+ // src/integration/amazon-sqs-client/index.ts
11880
+ import { randomUUID as randomUUID2 } from "crypto";
11881
+ import {
11882
+ SQSClient,
11883
+ SendMessageBatchCommand,
11884
+ ReceiveMessageCommand,
11885
+ DeleteMessageBatchCommand
11886
+ } from "@aws-sdk/client-sqs";
11887
+
11888
+ // src/integration/amazon-sqs-client/types.ts
11889
+ var SQS_MAX_BATCH_SIZE = 10;
11890
+ var DEFAULT_VISIBILITY_TIMEOUT = 30;
11891
+ var DEFAULT_WAIT_TIME_SECONDS = 0;
11892
+ var DEFAULT_MESSAGE_GROUP_ID = "default";
11893
+
11894
+ // src/integration/amazon-sqs-client/index.ts
11895
+ var _AmazonSQSClient = class _AmazonSQSClient {
11896
+ /**
11897
+ * @param config - AWS region, IAM credentials, target queue URL, and optional
11898
+ * consumer/FIFO settings (visibilityTimeout, waitTimeSeconds, messageGroupId).
11899
+ */
11900
+ constructor(config) {
11901
+ this.queueUrl = config.queueUrl;
11902
+ this.isFifo = config.queueUrl.endsWith(".fifo");
11903
+ this.visibilityTimeout = config.visibilityTimeout ?? DEFAULT_VISIBILITY_TIMEOUT;
11904
+ this.waitTimeSeconds = config.waitTimeSeconds ?? DEFAULT_WAIT_TIME_SECONDS;
11905
+ this.messageGroupId = config.messageGroupId ?? DEFAULT_MESSAGE_GROUP_ID;
11906
+ this.client = new SQSClient({
11907
+ region: config.region,
11908
+ credentials: {
11909
+ accessKeyId: config.accessKeyId,
11910
+ secretAccessKey: config.secretAccessKey
11911
+ }
11912
+ });
11913
+ }
11914
+ /**
11915
+ * Publishes all `payloads` to the bound queue in batches of 10 (the SQS hard limit
11916
+ * per `SendMessageBatch` call). Failed entries reported by SQS within a successful
11917
+ * batch response are tracked individually in `stats.errors`. Transport errors
11918
+ * (thrown exceptions) are captured per-batch so a single failing batch does not
11919
+ * abort the rest.
11920
+ *
11921
+ * For FIFO queues (URL ends in `.fifo`), every entry is stamped with:
11922
+ * - `MessageGroupId` — the value set at construction time (`config.messageGroupId`,
11923
+ * defaulting to `'default'`).
11924
+ * - `MessageDeduplicationId` — a unique `randomUUID()` per entry, ensuring
11925
+ * at-most-once delivery within the 5-minute SQS deduplication window regardless
11926
+ * of whether content-based deduplication is enabled on the queue.
11927
+ *
11928
+ * @param payloads - Array of string message bodies to send.
11929
+ * @returns Counts of published and failed messages plus per-failure details.
11930
+ */
11931
+ async publish(payloads) {
11932
+ const stats = { published: 0, failed: 0, errors: [] };
11933
+ if (payloads.length === 0) return stats;
11934
+ const chunks = this.chunk(payloads, SQS_MAX_BATCH_SIZE);
11935
+ let globalIndex = 0;
11936
+ for (const chunk of chunks) {
11937
+ await this.sendBatch(chunk, globalIndex, stats);
11938
+ globalIndex += chunk.length;
11939
+ }
11940
+ return stats;
11941
+ }
11942
+ /**
11943
+ * Pulls up to `batchSize` messages from the bound queue and processes each
11944
+ * one via `handler`.
11945
+ *
11946
+ * Processing steps:
11947
+ * 1. Receive messages in ReceiveMessage loops (≤ 10 per call) until `batchSize`
11948
+ * messages are accumulated or the queue returns empty.
11949
+ * 2. Invoke `handler` concurrently for all received messages.
11950
+ * 3. Delete every message whose handler resolved successfully.
11951
+ * Messages whose handler threw are left in the queue and become visible again
11952
+ * after the configured `visibilityTimeout` (set at construction time).
11953
+ *
11954
+ * @param batchSize - Total number of messages to pull per invocation.
11955
+ * @param handler - Callback invoked with the SQS MessageId and raw body string.
11956
+ * @returns Receive / process / delete / fail counts plus per-error details.
11957
+ * @throws Propagates SQS transport errors (receive, delete) to the caller.
11958
+ */
11959
+ async consume(batchSize, handler) {
11960
+ const stats = {
11961
+ received: 0,
11962
+ processed: 0,
11963
+ deleted: 0,
11964
+ failed: 0,
11965
+ errors: []
11966
+ };
11967
+ const messages = await this.receiveMessages(batchSize);
11968
+ stats.received = messages.length;
11969
+ if (messages.length === 0) return stats;
11970
+ const toDelete = [];
11971
+ await Promise.all(
11972
+ messages.map(async (msg) => {
11973
+ stats.processed++;
11974
+ try {
11975
+ await handler(msg.MessageId ?? "", msg.Body ?? "");
11976
+ toDelete.push(msg);
11977
+ } catch (error) {
11978
+ stats.failed++;
11979
+ stats.errors.push({ messageId: msg.MessageId ?? "", error });
11980
+ }
11981
+ })
11982
+ );
11983
+ if (toDelete.length > 0) {
11984
+ await this.deleteMessages(toDelete);
11985
+ stats.deleted += toDelete.length;
11986
+ }
11987
+ return stats;
11988
+ }
11989
+ /**
11990
+ * Loops ReceiveMessage calls until `batchSize` messages are accumulated
11991
+ * or the queue returns an empty response (queue drained).
11992
+ *
11993
+ * The first call uses `this.waitTimeSeconds` (enabling long polling when > 0).
11994
+ * Subsequent fill-up calls always use waitTimeSeconds = 0 to avoid blocking —
11995
+ * if the first call returned messages the queue is clearly non-empty.
11996
+ */
11997
+ async receiveMessages(batchSize) {
11998
+ const messages = [];
11999
+ let isFirstCall = true;
12000
+ while (messages.length < batchSize) {
12001
+ const remaining = batchSize - messages.length;
12002
+ const maxMessages = Math.min(remaining, SQS_MAX_BATCH_SIZE);
12003
+ const response = await this.client.send(
12004
+ new ReceiveMessageCommand({
12005
+ QueueUrl: this.queueUrl,
12006
+ MaxNumberOfMessages: maxMessages,
12007
+ VisibilityTimeout: this.visibilityTimeout,
12008
+ WaitTimeSeconds: isFirstCall ? this.waitTimeSeconds : 0
12009
+ })
12010
+ );
12011
+ isFirstCall = false;
12012
+ const received = response.Messages ?? [];
12013
+ if (received.length === 0) break;
12014
+ messages.push(...received);
12015
+ if (received.length < maxMessages) break;
12016
+ }
12017
+ return messages;
12018
+ }
12019
+ /**
12020
+ * Deletes messages from the queue after successful processing.
12021
+ * Uses DeleteMessageBatch (≤ 10 per call).
12022
+ */
12023
+ async deleteMessages(messages) {
12024
+ const chunks = this.chunk(messages, SQS_MAX_BATCH_SIZE);
12025
+ for (const chunk of chunks) {
12026
+ const entries = chunk.map((msg, i) => ({
12027
+ Id: String(i),
12028
+ ReceiptHandle: msg.ReceiptHandle ?? ""
12029
+ }));
12030
+ await this.client.send(
12031
+ new DeleteMessageBatchCommand({ QueueUrl: this.queueUrl, Entries: entries })
12032
+ );
12033
+ }
12034
+ }
12035
+ /**
12036
+ * Sends a single publish batch via `SendMessageBatchCommand`.
12037
+ * `globalOffset` generates unique, stable entry IDs across consecutive batches
12038
+ * (SQS requires unique IDs within each request, not globally).
12039
+ * For FIFO queues, each entry is stamped with a `MessageGroupId` and a unique
12040
+ * `MessageDeduplicationId` (randomUUID).
12041
+ * Per-entry SQS failures are captured in `stats.errors`; transport exceptions
12042
+ * mark all entries in the chunk as failed without re-throwing.
12043
+ */
12044
+ async sendBatch(chunk, globalOffset, stats) {
12045
+ const entries = chunk.map((payload, i) => ({
12046
+ Id: String(globalOffset + i),
12047
+ MessageBody: payload,
12048
+ ...this.isFifo && {
12049
+ MessageGroupId: this.messageGroupId,
12050
+ MessageDeduplicationId: randomUUID2()
12051
+ }
12052
+ }));
12053
+ try {
12054
+ const response = await this.client.send(
12055
+ new SendMessageBatchCommand({ QueueUrl: this.queueUrl, Entries: entries })
12056
+ );
12057
+ const successful = response.Successful ?? [];
12058
+ const failed = response.Failed ?? [];
12059
+ stats.published += successful.length;
12060
+ for (const failure of failed) {
12061
+ const entryIndex = Number(failure.Id) - globalOffset;
12062
+ const payload = chunk[entryIndex] ?? "";
12063
+ const error = new Error(
12064
+ `SQS batch entry failed [Id=${failure.Id}] Code=${failure.Code}: ${failure.Message ?? "unknown"}`
12065
+ );
12066
+ stats.failed++;
12067
+ stats.errors.push({ payload, error });
12068
+ }
12069
+ } catch (error) {
12070
+ for (const payload of chunk) {
12071
+ stats.failed++;
12072
+ stats.errors.push({ payload, error });
12073
+ }
12074
+ }
12075
+ }
12076
+ /**
12077
+ * Splits `items` into sequential chunks of at most `size` elements.
12078
+ */
12079
+ chunk(items, size) {
12080
+ const chunks = [];
12081
+ for (let i = 0; i < items.length; i += size) {
12082
+ chunks.push(items.slice(i, i + size));
12083
+ }
12084
+ return chunks;
12085
+ }
12086
+ };
12087
+ __name(_AmazonSQSClient, "AmazonSQSClient");
12088
+ var AmazonSQSClient = _AmazonSQSClient;
12089
+ var amazon_sqs_client_default = AmazonSQSClient;
12090
+
11879
12091
  // src/commerce/adobe-commerce-client/index.ts
11880
12092
  import got from "got";
11881
12093
  var _AdobeCommerceClient = class _AdobeCommerceClient {
@@ -12869,6 +13081,7 @@ export {
12869
13081
  AdminUiSdk,
12870
13082
  adobe_auth_default as AdobeAuth,
12871
13083
  adobe_commerce_client_default as AdobeCommerceClient,
13084
+ amazon_sqs_client_default as AmazonSQSClient,
12872
13085
  basic_auth_connection_default as BasicAuthConnection,
12873
13086
  bearer_token_default as BearerToken,
12874
13087
  create_events_default as CreateEvents,