@qodalis/cli-server-plugin-aws 0.0.0-stage → 1.0.0-beta.14

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +155 -2
  3. package/dist/aws-command-processor.d.ts +19 -0
  4. package/dist/aws-command-processor.d.ts.map +1 -0
  5. package/dist/aws-command-processor.js +265 -0
  6. package/dist/aws-command-processor.js.map +1 -0
  7. package/dist/index.d.ts +12 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +23 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/processors/cloudwatch-processor.d.ts +12 -0
  12. package/dist/processors/cloudwatch-processor.d.ts.map +1 -0
  13. package/dist/processors/cloudwatch-processor.js +168 -0
  14. package/dist/processors/cloudwatch-processor.js.map +1 -0
  15. package/dist/processors/dynamodb-processor.d.ts +12 -0
  16. package/dist/processors/dynamodb-processor.d.ts.map +1 -0
  17. package/dist/processors/dynamodb-processor.js +201 -0
  18. package/dist/processors/dynamodb-processor.js.map +1 -0
  19. package/dist/processors/ec2-processor.d.ts +12 -0
  20. package/dist/processors/ec2-processor.d.ts.map +1 -0
  21. package/dist/processors/ec2-processor.js +305 -0
  22. package/dist/processors/ec2-processor.js.map +1 -0
  23. package/dist/processors/ecs-processor.d.ts +12 -0
  24. package/dist/processors/ecs-processor.d.ts.map +1 -0
  25. package/dist/processors/ecs-processor.js +169 -0
  26. package/dist/processors/ecs-processor.js.map +1 -0
  27. package/dist/processors/iam-processor.d.ts +12 -0
  28. package/dist/processors/iam-processor.d.ts.map +1 -0
  29. package/dist/processors/iam-processor.js +151 -0
  30. package/dist/processors/iam-processor.js.map +1 -0
  31. package/dist/processors/lambda-processor.d.ts +12 -0
  32. package/dist/processors/lambda-processor.d.ts.map +1 -0
  33. package/dist/processors/lambda-processor.js +187 -0
  34. package/dist/processors/lambda-processor.js.map +1 -0
  35. package/dist/processors/s3-processor.d.ts +27 -0
  36. package/dist/processors/s3-processor.d.ts.map +1 -0
  37. package/dist/processors/s3-processor.js +345 -0
  38. package/dist/processors/s3-processor.js.map +1 -0
  39. package/dist/processors/sns-processor.d.ts +12 -0
  40. package/dist/processors/sns-processor.d.ts.map +1 -0
  41. package/dist/processors/sns-processor.js +157 -0
  42. package/dist/processors/sns-processor.js.map +1 -0
  43. package/dist/processors/sqs-processor.d.ts +12 -0
  44. package/dist/processors/sqs-processor.d.ts.map +1 -0
  45. package/dist/processors/sqs-processor.js +191 -0
  46. package/dist/processors/sqs-processor.js.map +1 -0
  47. package/dist/services/aws-config-service.d.ts +50 -0
  48. package/dist/services/aws-config-service.d.ts.map +1 -0
  49. package/dist/services/aws-config-service.js +61 -0
  50. package/dist/services/aws-config-service.js.map +1 -0
  51. package/dist/services/aws-credential-manager.d.ts +29 -0
  52. package/dist/services/aws-credential-manager.d.ts.map +1 -0
  53. package/dist/services/aws-credential-manager.js +50 -0
  54. package/dist/services/aws-credential-manager.js.map +1 -0
  55. package/dist/utils/output-helpers.d.ts +68 -0
  56. package/dist/utils/output-helpers.d.ts.map +1 -0
  57. package/dist/utils/output-helpers.js +107 -0
  58. package/dist/utils/output-helpers.js.map +1 -0
  59. package/dist/utils/pagination.d.ts +9 -0
  60. package/dist/utils/pagination.d.ts.map +1 -0
  61. package/dist/utils/pagination.js +21 -0
  62. package/dist/utils/pagination.js.map +1 -0
  63. package/package.json +51 -5
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AwsSqsProcessor = void 0;
4
+ const cli_server_abstractions_1 = require("@qodalis/cli-server-abstractions");
5
+ const client_sqs_1 = require("@aws-sdk/client-sqs");
6
+ const output_helpers_1 = require("../utils/output-helpers");
7
+ /** Sub-processor that lists SQS queues. */
8
+ class SqsListProcessor extends cli_server_abstractions_1.CliCommandProcessor {
9
+ credentialManager;
10
+ command = 'list';
11
+ description = 'List SQS queues';
12
+ parameters = [
13
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('region', 'AWS region override', false, 'string', ['-r']),
14
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('output', 'Output format (list|json|text)', false, 'string', ['-o'], 'list'),
15
+ ];
16
+ constructor(credentialManager) {
17
+ super();
18
+ this.credentialManager = credentialManager;
19
+ }
20
+ /** @inheritdoc */
21
+ async handleAsync() {
22
+ return '';
23
+ }
24
+ /** @inheritdoc */
25
+ async handleStructuredAsync(command) {
26
+ const client = this.credentialManager.getClient(client_sqs_1.SQSClient, {
27
+ region: command.args?.region ? String(command.args.region) : undefined,
28
+ });
29
+ try {
30
+ const response = await client.send(new client_sqs_1.ListQueuesCommand({}));
31
+ const queueUrls = response.QueueUrls ?? [];
32
+ if (queueUrls.length === 0) {
33
+ return (0, output_helpers_1.buildResponse)([{ type: 'text', value: 'No SQS queues found.', style: 'warning' }]);
34
+ }
35
+ const listOutput = (0, output_helpers_1.formatAsList)(queueUrls);
36
+ return (0, output_helpers_1.buildResponse)([(0, output_helpers_1.applyOutputFormat)(command, listOutput, queueUrls)]);
37
+ }
38
+ catch (err) {
39
+ return (0, output_helpers_1.buildErrorResponse)(`Failed to list SQS queues: ${err.message ?? err}`);
40
+ }
41
+ }
42
+ }
43
+ /** Sub-processor that sends a message to an SQS queue. */
44
+ class SqsSendProcessor extends cli_server_abstractions_1.CliCommandProcessor {
45
+ credentialManager;
46
+ command = 'send';
47
+ description = 'Send a message to an SQS queue';
48
+ valueRequired = true;
49
+ parameters = [
50
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('message', 'Message body to send', true, 'string', ['-m']),
51
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('region', 'AWS region override', false, 'string', ['-r']),
52
+ ];
53
+ constructor(credentialManager) {
54
+ super();
55
+ this.credentialManager = credentialManager;
56
+ }
57
+ /** @inheritdoc */
58
+ async handleAsync() {
59
+ return '';
60
+ }
61
+ /** @inheritdoc */
62
+ async handleStructuredAsync(command) {
63
+ const queueUrl = (0, cli_server_abstractions_1.getPositionalText)(command);
64
+ if (!queueUrl) {
65
+ return (0, output_helpers_1.buildErrorResponse)('Queue URL is required. Usage: sqs send <queue-url> --message <body>');
66
+ }
67
+ const messageBody = command.args?.message;
68
+ if (!messageBody) {
69
+ return (0, output_helpers_1.buildErrorResponse)('--message is required. Usage: sqs send <queue-url> --message <body>');
70
+ }
71
+ const client = this.credentialManager.getClient(client_sqs_1.SQSClient, {
72
+ region: command.args?.region ? String(command.args.region) : undefined,
73
+ });
74
+ try {
75
+ const response = await client.send(new client_sqs_1.SendMessageCommand({
76
+ QueueUrl: queueUrl,
77
+ MessageBody: messageBody,
78
+ }));
79
+ return (0, output_helpers_1.buildSuccessResponse)(`Message sent successfully. MessageId: ${response.MessageId}`);
80
+ }
81
+ catch (err) {
82
+ return (0, output_helpers_1.buildErrorResponse)(`Failed to send message: ${err.message ?? err}`);
83
+ }
84
+ }
85
+ }
86
+ /** Sub-processor that receives messages from an SQS queue. */
87
+ class SqsReceiveProcessor extends cli_server_abstractions_1.CliCommandProcessor {
88
+ credentialManager;
89
+ command = 'receive';
90
+ description = 'Receive messages from an SQS queue';
91
+ valueRequired = true;
92
+ parameters = [
93
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('max', 'Maximum number of messages to receive (default: 1)', false, 'number', ['-n'], '1'),
94
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('region', 'AWS region override', false, 'string', ['-r']),
95
+ ];
96
+ constructor(credentialManager) {
97
+ super();
98
+ this.credentialManager = credentialManager;
99
+ }
100
+ /** @inheritdoc */
101
+ async handleAsync() {
102
+ return '';
103
+ }
104
+ /** @inheritdoc */
105
+ async handleStructuredAsync(command) {
106
+ const queueUrl = (0, cli_server_abstractions_1.getPositionalText)(command);
107
+ if (!queueUrl) {
108
+ return (0, output_helpers_1.buildErrorResponse)('Queue URL is required. Usage: sqs receive <queue-url>');
109
+ }
110
+ const max = command.args?.max ? Number(command.args.max) : 1;
111
+ const client = this.credentialManager.getClient(client_sqs_1.SQSClient, {
112
+ region: command.args?.region ? String(command.args.region) : undefined,
113
+ });
114
+ try {
115
+ const response = await client.send(new client_sqs_1.ReceiveMessageCommand({
116
+ QueueUrl: queueUrl,
117
+ MaxNumberOfMessages: max,
118
+ }));
119
+ const messages = response.Messages ?? [];
120
+ if (messages.length === 0) {
121
+ return (0, output_helpers_1.buildResponse)([{ type: 'text', value: 'No messages available in the queue.', style: 'warning' }]);
122
+ }
123
+ return (0, output_helpers_1.buildResponse)([(0, output_helpers_1.formatAsJson)(messages)]);
124
+ }
125
+ catch (err) {
126
+ return (0, output_helpers_1.buildErrorResponse)(`Failed to receive messages: ${err.message ?? err}`);
127
+ }
128
+ }
129
+ }
130
+ /** Sub-processor that purges all messages from an SQS queue, with optional dry-run support. */
131
+ class SqsPurgeProcessor extends cli_server_abstractions_1.CliCommandProcessor {
132
+ credentialManager;
133
+ command = 'purge';
134
+ description = 'Purge all messages from an SQS queue';
135
+ valueRequired = true;
136
+ parameters = [
137
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('dry-run', 'Show what would be purged without actually purging', false, 'boolean', ['--dry-run']),
138
+ new cli_server_abstractions_1.CliCommandParameterDescriptor('region', 'AWS region override', false, 'string', ['-r']),
139
+ ];
140
+ constructor(credentialManager) {
141
+ super();
142
+ this.credentialManager = credentialManager;
143
+ }
144
+ /** @inheritdoc */
145
+ async handleAsync() {
146
+ return '';
147
+ }
148
+ /** @inheritdoc */
149
+ async handleStructuredAsync(command) {
150
+ const queueUrl = (0, cli_server_abstractions_1.getPositionalText)(command);
151
+ if (!queueUrl) {
152
+ return (0, output_helpers_1.buildErrorResponse)('Queue URL is required. Usage: sqs purge <queue-url>');
153
+ }
154
+ if ((0, output_helpers_1.isDryRun)(command)) {
155
+ return (0, output_helpers_1.buildResponse)([
156
+ { type: 'text', value: `[dry-run] Would purge all messages from queue: ${queueUrl}`, style: 'warning' },
157
+ ]);
158
+ }
159
+ const client = this.credentialManager.getClient(client_sqs_1.SQSClient, {
160
+ region: command.args?.region ? String(command.args.region) : undefined,
161
+ });
162
+ try {
163
+ await client.send(new client_sqs_1.PurgeQueueCommand({ QueueUrl: queueUrl }));
164
+ return (0, output_helpers_1.buildSuccessResponse)(`Queue purged successfully: ${queueUrl}`);
165
+ }
166
+ catch (err) {
167
+ return (0, output_helpers_1.buildErrorResponse)(`Failed to purge queue: ${err.message ?? err}`);
168
+ }
169
+ }
170
+ }
171
+ /** Parent processor for SQS sub-commands (list, send, receive, purge). */
172
+ class AwsSqsProcessor extends cli_server_abstractions_1.CliCommandProcessor {
173
+ command = 'sqs';
174
+ description = 'AWS SQS operations — list, send, receive, purge';
175
+ processors;
176
+ constructor(credentialManager) {
177
+ super();
178
+ this.processors = [
179
+ new SqsListProcessor(credentialManager),
180
+ new SqsSendProcessor(credentialManager),
181
+ new SqsReceiveProcessor(credentialManager),
182
+ new SqsPurgeProcessor(credentialManager),
183
+ ];
184
+ }
185
+ /** @inheritdoc */
186
+ async handleAsync() {
187
+ return '';
188
+ }
189
+ }
190
+ exports.AwsSqsProcessor = AwsSqsProcessor;
191
+ //# sourceMappingURL=sqs-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqs-processor.js","sourceRoot":"","sources":["../../src/processors/sqs-processor.ts"],"names":[],"mappings":";;;AAAA,8EAO0C;AAC1C,oDAM6B;AAE7B,4DAQiC;AAEjC,2CAA2C;AAC3C,MAAM,gBAAiB,SAAQ,6CAAmB;IAQjB;IAP7B,OAAO,GAAG,MAAM,CAAC;IACjB,WAAW,GAAG,iBAAiB,CAAC;IAChC,UAAU,GAAG;QACT,IAAI,uDAA6B,CAAC,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3F,IAAI,uDAA6B,CAAC,QAAQ,EAAE,gCAAgC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACjH,CAAC;IAEF,YAA6B,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ACL,CAAC;CACJ;AAED,0EAA0E;AAC1E,MAAa,eAAgB,SAAQ,6CAAmB;IACpD,OAAO,GAAG,KAAK,CAAC;IAChB,WAAW,GAAG,iDAAiD,CAAC;IAChE,UAAU,CAAyB;IAEnC,YAAY,iBAAuC;QAC/C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG;YACd,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;YACvC,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;YACvC,IAAI,mBAAmB,CAAC,iBAAiB,CAAC;YAC1C,IAAI,iBAAiB,CAAC,iBAAiB,CAAC;SAC3C,CAAC;IACN,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,WAAW;QACb,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAnBD,0CAmBC"}
@@ -0,0 +1,50 @@
1
+ /** Summary of the current AWS configuration with secrets masked. */
2
+ export interface AwsConfigSummary {
3
+ accessKeyId?: string;
4
+ secretAccessKey?: string;
5
+ region?: string;
6
+ profile?: string;
7
+ }
8
+ /** Manages in-memory AWS configuration (credentials, region, profile). */
9
+ export declare class AwsConfigService {
10
+ private _accessKeyId?;
11
+ private _secretAccessKey?;
12
+ private _region?;
13
+ private _profile?;
14
+ /** Returns the configured AWS access key ID, or undefined if not set. */
15
+ getAccessKeyId(): string | undefined;
16
+ /** Returns the configured AWS secret access key, or undefined if not set. */
17
+ getSecretAccessKey(): string | undefined;
18
+ /** Returns the configured AWS region, or undefined if not set. */
19
+ getRegion(): string | undefined;
20
+ /** Returns the configured AWS profile name, or undefined if not set. */
21
+ getProfile(): string | undefined;
22
+ /**
23
+ * Sets the AWS access key ID and secret access key.
24
+ * @param accessKeyId - The AWS access key ID.
25
+ * @param secretAccessKey - The AWS secret access key.
26
+ */
27
+ setCredentials(accessKeyId: string, secretAccessKey: string): void;
28
+ /**
29
+ * Sets the AWS region.
30
+ * @param region - The AWS region identifier (e.g., 'us-east-1').
31
+ */
32
+ setRegion(region: string): void;
33
+ /**
34
+ * Sets the AWS profile name.
35
+ * @param profile - The profile name from ~/.aws/credentials or ~/.aws/config.
36
+ */
37
+ setProfile(profile: string): void;
38
+ /**
39
+ * Returns a summary of the current configuration with secrets masked.
40
+ * @returns An {@link AwsConfigSummary} with the access key partially masked and the secret fully masked.
41
+ */
42
+ getConfigSummary(): AwsConfigSummary;
43
+ /**
44
+ * Masks a key string, showing only the first 4 and last 5 characters.
45
+ * @param key - The key string to mask.
46
+ * @returns The masked key string.
47
+ */
48
+ private maskKey;
49
+ }
50
+ //# sourceMappingURL=aws-config-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws-config-service.d.ts","sourceRoot":"","sources":["../../src/services/aws-config-service.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,0EAA0E;AAC1E,qBAAa,gBAAgB;IACzB,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAE1B,yEAAyE;IACzE,cAAc,IAAI,MAAM,GAAG,SAAS;IAEpC,6EAA6E;IAC7E,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAExC,kEAAkE;IAClE,SAAS,IAAI,MAAM,GAAG,SAAS;IAE/B,wEAAwE;IACxE,UAAU,IAAI,MAAM,GAAG,SAAS;IAEhC;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;IAKlE;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAE/B;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAEjC;;;OAGG;IACH,gBAAgB,IAAI,gBAAgB;IASpC;;;;OAIG;IACH,OAAO,CAAC,OAAO;CAIlB"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AwsConfigService = void 0;
4
+ /** Manages in-memory AWS configuration (credentials, region, profile). */
5
+ class AwsConfigService {
6
+ _accessKeyId;
7
+ _secretAccessKey;
8
+ _region;
9
+ _profile;
10
+ /** Returns the configured AWS access key ID, or undefined if not set. */
11
+ getAccessKeyId() { return this._accessKeyId; }
12
+ /** Returns the configured AWS secret access key, or undefined if not set. */
13
+ getSecretAccessKey() { return this._secretAccessKey; }
14
+ /** Returns the configured AWS region, or undefined if not set. */
15
+ getRegion() { return this._region; }
16
+ /** Returns the configured AWS profile name, or undefined if not set. */
17
+ getProfile() { return this._profile; }
18
+ /**
19
+ * Sets the AWS access key ID and secret access key.
20
+ * @param accessKeyId - The AWS access key ID.
21
+ * @param secretAccessKey - The AWS secret access key.
22
+ */
23
+ setCredentials(accessKeyId, secretAccessKey) {
24
+ this._accessKeyId = accessKeyId;
25
+ this._secretAccessKey = secretAccessKey;
26
+ }
27
+ /**
28
+ * Sets the AWS region.
29
+ * @param region - The AWS region identifier (e.g., 'us-east-1').
30
+ */
31
+ setRegion(region) { this._region = region; }
32
+ /**
33
+ * Sets the AWS profile name.
34
+ * @param profile - The profile name from ~/.aws/credentials or ~/.aws/config.
35
+ */
36
+ setProfile(profile) { this._profile = profile; }
37
+ /**
38
+ * Returns a summary of the current configuration with secrets masked.
39
+ * @returns An {@link AwsConfigSummary} with the access key partially masked and the secret fully masked.
40
+ */
41
+ getConfigSummary() {
42
+ return {
43
+ accessKeyId: this._accessKeyId ? this.maskKey(this._accessKeyId) : undefined,
44
+ secretAccessKey: this._secretAccessKey ? '****' : undefined,
45
+ region: this._region,
46
+ profile: this._profile,
47
+ };
48
+ }
49
+ /**
50
+ * Masks a key string, showing only the first 4 and last 5 characters.
51
+ * @param key - The key string to mask.
52
+ * @returns The masked key string.
53
+ */
54
+ maskKey(key) {
55
+ if (key.length <= 8)
56
+ return '****';
57
+ return key.slice(0, 4) + '***' + key.slice(-5);
58
+ }
59
+ }
60
+ exports.AwsConfigService = AwsConfigService;
61
+ //# sourceMappingURL=aws-config-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws-config-service.js","sourceRoot":"","sources":["../../src/services/aws-config-service.ts"],"names":[],"mappings":";;;AAQA,0EAA0E;AAC1E,MAAa,gBAAgB;IACjB,YAAY,CAAU;IACtB,gBAAgB,CAAU;IAC1B,OAAO,CAAU;IACjB,QAAQ,CAAU;IAE1B,yEAAyE;IACzE,cAAc,KAAyB,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAElE,6EAA6E;IAC7E,kBAAkB,KAAyB,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAE1E,kEAAkE;IAClE,SAAS,KAAyB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAExD,wEAAwE;IACxE,UAAU,KAAyB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE1D;;;;OAIG;IACH,cAAc,CAAC,WAAmB,EAAE,eAAuB;QACvD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAc,IAAU,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;IAE1D;;;OAGG;IACH,UAAU,CAAC,OAAe,IAAU,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAE9D;;;OAGG;IACH,gBAAgB;QACZ,OAAO;YACH,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;YAC5E,eAAe,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC3D,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;SACzB,CAAC;IACN,CAAC;IAED;;;;OAIG;IACK,OAAO,CAAC,GAAW;QACvB,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC;QACnC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ;AA9DD,4CA8DC"}
@@ -0,0 +1,29 @@
1
+ import { AwsConfigService } from './aws-config-service';
2
+ /** Options for overriding region or profile when creating AWS SDK clients. */
3
+ export interface AwsClientOptions {
4
+ region?: string;
5
+ profile?: string;
6
+ }
7
+ /** Manages AWS SDK client instantiation and caching based on the current configuration. */
8
+ export declare class AwsCredentialManager {
9
+ private readonly config;
10
+ private readonly _clientCache;
11
+ /** @param config - The AWS configuration service providing credentials and region. */
12
+ constructor(config: AwsConfigService);
13
+ /**
14
+ * Builds an AWS SDK client configuration object from the current settings and overrides.
15
+ * @param overrides - Optional region/profile overrides.
16
+ * @returns A configuration record suitable for passing to an AWS SDK client constructor.
17
+ */
18
+ getClientConfig(overrides?: AwsClientOptions): Record<string, any>;
19
+ /**
20
+ * Returns a cached AWS SDK client instance, creating one if necessary.
21
+ * @param ClientClass - The AWS SDK client class to instantiate.
22
+ * @param overrides - Optional region/profile overrides for client configuration.
23
+ * @returns A cached instance of the requested client class.
24
+ */
25
+ getClient<T>(ClientClass: new (config: Record<string, any>) => T, overrides?: AwsClientOptions): T;
26
+ /** Clears the cached AWS SDK client instances, forcing re-creation on next access. */
27
+ clearCache(): void;
28
+ }
29
+ //# sourceMappingURL=aws-credential-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws-credential-manager.d.ts","sourceRoot":"","sources":["../../src/services/aws-credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,2FAA2F;AAC3F,qBAAa,oBAAoB;IAIjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;IAEvD,sFAAsF;gBACzD,MAAM,EAAE,gBAAgB;IAErD;;;;OAIG;IACH,eAAe,CAAC,SAAS,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAYlE;;;;;OAKG;IACH,SAAS,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,EAAE,gBAAgB,GAAG,CAAC;IAUlG,sFAAsF;IACtF,UAAU,IAAI,IAAI;CAGrB"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AwsCredentialManager = void 0;
4
+ /** Manages AWS SDK client instantiation and caching based on the current configuration. */
5
+ class AwsCredentialManager {
6
+ config;
7
+ _clientCache = new Map();
8
+ /** @param config - The AWS configuration service providing credentials and region. */
9
+ constructor(config) {
10
+ this.config = config;
11
+ }
12
+ /**
13
+ * Builds an AWS SDK client configuration object from the current settings and overrides.
14
+ * @param overrides - Optional region/profile overrides.
15
+ * @returns A configuration record suitable for passing to an AWS SDK client constructor.
16
+ */
17
+ getClientConfig(overrides) {
18
+ const config = {};
19
+ const region = overrides?.region ?? this.config.getRegion() ?? process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION;
20
+ if (region)
21
+ config.region = region;
22
+ const accessKeyId = this.config.getAccessKeyId() ?? process.env.AWS_ACCESS_KEY_ID;
23
+ const secretAccessKey = this.config.getSecretAccessKey() ?? process.env.AWS_SECRET_ACCESS_KEY;
24
+ if (accessKeyId && secretAccessKey) {
25
+ config.credentials = { accessKeyId, secretAccessKey };
26
+ }
27
+ return config;
28
+ }
29
+ /**
30
+ * Returns a cached AWS SDK client instance, creating one if necessary.
31
+ * @param ClientClass - The AWS SDK client class to instantiate.
32
+ * @param overrides - Optional region/profile overrides for client configuration.
33
+ * @returns A cached instance of the requested client class.
34
+ */
35
+ getClient(ClientClass, overrides) {
36
+ const region = overrides?.region ?? this.config.getRegion() ?? 'default';
37
+ const profile = overrides?.profile ?? this.config.getProfile() ?? 'default';
38
+ const key = `${ClientClass.name}:${region}:${profile}`;
39
+ if (!this._clientCache.has(key)) {
40
+ this._clientCache.set(key, new ClientClass(this.getClientConfig(overrides)));
41
+ }
42
+ return this._clientCache.get(key);
43
+ }
44
+ /** Clears the cached AWS SDK client instances, forcing re-creation on next access. */
45
+ clearCache() {
46
+ this._clientCache.clear();
47
+ }
48
+ }
49
+ exports.AwsCredentialManager = AwsCredentialManager;
50
+ //# sourceMappingURL=aws-credential-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws-credential-manager.js","sourceRoot":"","sources":["../../src/services/aws-credential-manager.ts"],"names":[],"mappings":";;;AAQA,2FAA2F;AAC3F,MAAa,oBAAoB;IAIA;IAHZ,YAAY,GAAG,IAAI,GAAG,EAAe,CAAC;IAEvD,sFAAsF;IACtF,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAEzD;;;;OAIG;IACH,eAAe,CAAC,SAA4B;QACxC,MAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,SAAS,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,OAAO,CAAC,GAAG,C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}
@@ -0,0 +1,68 @@
1
+ import { CliProcessCommand, CliStructuredResponse, CliStructuredOutput } from '@qodalis/cli-server-abstractions';
2
+ /** Supported output format identifiers. */
3
+ export type OutputFormat = 'table' | 'json' | 'text';
4
+ /**
5
+ * Extracts the output format from a command's `--output` argument.
6
+ * @param command - The parsed CLI command.
7
+ * @returns The requested output format, defaulting to `'table'`.
8
+ */
9
+ export declare function getOutputFormat(command: CliProcessCommand): OutputFormat;
10
+ /**
11
+ * Checks whether the `--dry-run` flag is set on a command.
12
+ * @param command - The parsed CLI command.
13
+ * @returns `true` if dry-run mode is enabled.
14
+ */
15
+ export declare function isDryRun(command: CliProcessCommand): boolean;
16
+ /**
17
+ * Builds a structured response with the given outputs and exit code.
18
+ * @param outputs - The structured output items to include.
19
+ * @param exitCode - Process exit code, defaults to 0.
20
+ * @returns A CLI structured response.
21
+ */
22
+ export declare function buildResponse(outputs: CliStructuredOutput[], exitCode?: number): CliStructuredResponse;
23
+ /**
24
+ * Builds an error response with exit code 1 and the given message.
25
+ * @param message - The error message to display.
26
+ * @returns A CLI structured response styled as an error.
27
+ */
28
+ export declare function buildErrorResponse(message: string): CliStructuredResponse;
29
+ /**
30
+ * Builds a success response with exit code 0 and the given message.
31
+ * @param message - The success message to display.
32
+ * @returns A CLI structured response styled as a success.
33
+ */
34
+ export declare function buildSuccessResponse(message: string): CliStructuredResponse;
35
+ /**
36
+ * Wraps arbitrary data as a JSON structured output.
37
+ * @param data - The data to serialize as JSON.
38
+ * @returns A CLI structured output of type `'json'`.
39
+ */
40
+ export declare function formatAsJson(data: any): CliStructuredOutput;
41
+ /**
42
+ * Formats tabular data with headers and rows.
43
+ * @param headers - Column header labels.
44
+ * @param rows - Two-dimensional array of cell values.
45
+ * @returns A CLI structured output of type `'table'`.
46
+ */
47
+ export declare function formatAsTable(headers: string[], rows: string[][]): CliStructuredOutput;
48
+ /**
49
+ * Formats a record of key-value pairs for display.
50
+ * @param entries - An object whose keys and values will be displayed.
51
+ * @returns A CLI structured output of type `'key-value'`.
52
+ */
53
+ export declare function formatAsKeyValue(entries: Record<string, string>): CliStructuredOutput;
54
+ /**
55
+ * Formats an array of strings as a list output.
56
+ * @param items - The list items to display.
57
+ * @returns A CLI structured output of type `'list'`.
58
+ */
59
+ export declare function formatAsList(items: string[]): CliStructuredOutput;
60
+ /**
61
+ * Converts the default output to the format requested by the command's `--output` argument.
62
+ * @param command - The parsed CLI command containing format preferences.
63
+ * @param defaultOutput - The default structured output (typically a table or list).
64
+ * @param rawData - The raw data to use when JSON format is requested.
65
+ * @returns The structured output in the requested format.
66
+ */
67
+ export declare function applyOutputFormat(command: CliProcessCommand, defaultOutput: CliStructuredOutput, rawData: any): CliStructuredOutput;
68
+ //# sourceMappingURL=output-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/output-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEjH,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,QAAQ,SAAI,GAAG,qBAAqB,CAEjG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,mBAAmB,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,mBAAmB,CAEtF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,mBAAmB,CAErF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,OAAO,EAAE,GAAG,GAAG,mBAAmB,CAQnI"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOutputFormat = getOutputFormat;
4
+ exports.isDryRun = isDryRun;
5
+ exports.buildResponse = buildResponse;
6
+ exports.buildErrorResponse = buildErrorResponse;
7
+ exports.buildSuccessResponse = buildSuccessResponse;
8
+ exports.formatAsJson = formatAsJson;
9
+ exports.formatAsTable = formatAsTable;
10
+ exports.formatAsKeyValue = formatAsKeyValue;
11
+ exports.formatAsList = formatAsList;
12
+ exports.applyOutputFormat = applyOutputFormat;
13
+ /**
14
+ * Extracts the output format from a command's `--output` argument.
15
+ * @param command - The parsed CLI command.
16
+ * @returns The requested output format, defaulting to `'table'`.
17
+ */
18
+ function getOutputFormat(command) {
19
+ const format = command.args?.output;
20
+ if (format === 'json' || format === 'table' || format === 'text')
21
+ return format;
22
+ return 'table';
23
+ }
24
+ /**
25
+ * Checks whether the `--dry-run` flag is set on a command.
26
+ * @param command - The parsed CLI command.
27
+ * @returns `true` if dry-run mode is enabled.
28
+ */
29
+ function isDryRun(command) {
30
+ return command.args?.['dry-run'] === true || command.args?.dryRun === true;
31
+ }
32
+ /**
33
+ * Builds a structured response with the given outputs and exit code.
34
+ * @param outputs - The structured output items to include.
35
+ * @param exitCode - Process exit code, defaults to 0.
36
+ * @returns A CLI structured response.
37
+ */
38
+ function buildResponse(outputs, exitCode = 0) {
39
+ return { exitCode, outputs };
40
+ }
41
+ /**
42
+ * Builds an error response with exit code 1 and the given message.
43
+ * @param message - The error message to display.
44
+ * @returns A CLI structured response styled as an error.
45
+ */
46
+ function buildErrorResponse(message) {
47
+ return { exitCode: 1, outputs: [{ type: 'text', value: message, style: 'error' }] };
48
+ }
49
+ /**
50
+ * Builds a success response with exit code 0 and the given message.
51
+ * @param message - The success message to display.
52
+ * @returns A CLI structured response styled as a success.
53
+ */
54
+ function buildSuccessResponse(message) {
55
+ return { exitCode: 0, outputs: [{ type: 'text', value: message, style: 'success' }] };
56
+ }
57
+ /**
58
+ * Wraps arbitrary data as a JSON structured output.
59
+ * @param data - The data to serialize as JSON.
60
+ * @returns A CLI structured output of type `'json'`.
61
+ */
62
+ function formatAsJson(data) {
63
+ return { type: 'json', value: data };
64
+ }
65
+ /**
66
+ * Formats tabular data with headers and rows.
67
+ * @param headers - Column header labels.
68
+ * @param rows - Two-dimensional array of cell values.
69
+ * @returns A CLI structured output of type `'table'`.
70
+ */
71
+ function formatAsTable(headers, rows) {
72
+ return { type: 'table', headers, rows };
73
+ }
74
+ /**
75
+ * Formats a record of key-value pairs for display.
76
+ * @param entries - An object whose keys and values will be displayed.
77
+ * @returns A CLI structured output of type `'key-value'`.
78
+ */
79
+ function formatAsKeyValue(entries) {
80
+ return { type: 'key-value', entries: Object.entries(entries).map(([key, value]) => ({ key, value })) };
81
+ }
82
+ /**
83
+ * Formats an array of strings as a list output.
84
+ * @param items - The list items to display.
85
+ * @returns A CLI structured output of type `'list'`.
86
+ */
87
+ function formatAsList(items) {
88
+ return { type: 'list', items };
89
+ }
90
+ /**
91
+ * Converts the default output to the format requested by the command's `--output` argument.
92
+ * @param command - The parsed CLI command containing format preferences.
93
+ * @param defaultOutput - The default structured output (typically a table or list).
94
+ * @param rawData - The raw data to use when JSON format is requested.
95
+ * @returns The structured output in the requested format.
96
+ */
97
+ function applyOutputFormat(command, defaultOutput, rawData) {
98
+ const format = getOutputFormat(command);
99
+ if (format === 'json')
100
+ return formatAsJson(rawData);
101
+ if (format === 'text' && defaultOutput.type === 'table') {
102
+ const table = defaultOutput;
103
+ return { type: 'text', value: table.rows.map((row) => row.join('\t')).join('\n') };
104
+ }
105
+ return defaultOutput;
106
+ }
107
+ //# sourceMappingURL=output-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-helpers.js","sourceRoot":"","sources":["../../src/utils/output-helpers.ts"],"names":[],"mappings":";;AAUA,0CAIC;AAOD,4BAEC;AAQD,sCAEC;AAOD,gDAEC;AAOD,oDAEC;AAOD,oCAEC;AAQD,sCAEC;AAOD,4CAEC;AAOD,oCAEC;AASD,8CAQC;AApGD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,OAA0B;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;IACpC,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAChF,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,OAA0B;IAC/C,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAC/E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,OAA8B,EAAE,QAAQ,GAAG,CAAC;IACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAC9C,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE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EAAE,CAAC;QACtD,MAAM,KAAK,GAAG,aAAuE,CAAC;QACtF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACvF,CAAC;IACD,OAAO,aAAa,CAAC;AACzB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Collects items from an async paginator into a single array.
3
+ * @param paginator - The async iterable paginator returned by an AWS SDK paginate function.
4
+ * @param extract - A function that extracts the relevant items array from each page.
5
+ * @param maxResults - Optional cap on the total number of items to return.
6
+ * @returns A flat array of all extracted items, truncated to maxResults if specified.
7
+ */
8
+ export declare function paginateAll<T>(paginator: AsyncIterable<T>, extract: (page: T) => any[], maxResults?: number): Promise<any[]>;
9
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAC/B,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,EAAE,EAC3B,UAAU,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,GAAG,EAAE,CAAC,CAShB"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paginateAll = paginateAll;
4
+ /**
5
+ * Collects items from an async paginator into a single array.
6
+ * @param paginator - The async iterable paginator returned by an AWS SDK paginate function.
7
+ * @param extract - A function that extracts the relevant items array from each page.
8
+ * @param maxResults - Optional cap on the total number of items to return.
9
+ * @returns A flat array of all extracted items, truncated to maxResults if specified.
10
+ */
11
+ async function paginateAll(paginator, extract, maxResults) {
12
+ const results = [];
13
+ for await (const page of paginator) {
14
+ results.push(...extract(page));
15
+ if (maxResults && results.length >= maxResults) {
16
+ return results.slice(0, maxResults);
17
+ }
18
+ }
19
+ return results;
20
+ }
21
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":";;AAOA,kCAaC;AApBD;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAC7B,SAA2B,EAC3B,OAA2B,EAC3B,UAAmB;IAEnB,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/B,IAAI,UAAU,IAAI,OAAO,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YAC7C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}