@goldstack/template-sqs 0.1.1
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/README.md +3 -0
- package/dist/src/mockedSQS.d.ts +8 -0
- package/dist/src/mockedSQS.d.ts.map +1 -0
- package/dist/src/mockedSQS.js +27 -0
- package/dist/src/mockedSQS.js.map +1 -0
- package/dist/src/sqsConnect.d.ts +50 -0
- package/dist/src/sqsConnect.d.ts.map +1 -0
- package/dist/src/sqsConnect.js +171 -0
- package/dist/src/sqsConnect.js.map +1 -0
- package/dist/src/templateSqs.d.ts +9 -0
- package/dist/src/templateSqs.d.ts.map +1 -0
- package/dist/src/templateSqs.js +30 -0
- package/dist/src/templateSqs.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
+
import { MessageCallback } from './sqsConnect';
|
|
3
|
+
export declare type CreateSQSClientSignature = typeof createSQSClient;
|
|
4
|
+
export declare function createSQSClient({ sqsClient, onMessageSend, }: {
|
|
5
|
+
sqsClient?: SQSClient;
|
|
6
|
+
onMessageSend?: MessageCallback;
|
|
7
|
+
}): SQSClient;
|
|
8
|
+
//# sourceMappingURL=mockedSQS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockedSQS.d.ts","sourceRoot":"","sources":["../../src/mockedSQS.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGV,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,oBAAY,wBAAwB,GAAG,OAAO,eAAe,CAAC;AAE9D,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,aAAa,GACd,EAAE;IACD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,eAAe,CAAC;CACjC,GAAG,SAAS,CAwBZ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSQSClient = void 0;
|
|
4
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
|
+
const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
function createSQSClient({ sqsClient, onMessageSend, }) {
|
|
8
|
+
if (!sqsClient) {
|
|
9
|
+
sqsClient = new client_sqs_1.SQSClient();
|
|
10
|
+
}
|
|
11
|
+
const mockedClient = (0, aws_sdk_client_mock_1.mockClient)(sqsClient);
|
|
12
|
+
const sendMessageRequests = [];
|
|
13
|
+
sqsClient._goldstackSentRequests = sendMessageRequests;
|
|
14
|
+
mockedClient.on(client_sqs_1.SendMessageCommand).callsFake(async (input) => {
|
|
15
|
+
sendMessageRequests.push(input);
|
|
16
|
+
// If a callback is provided, invoke it with the message input
|
|
17
|
+
if (onMessageSend) {
|
|
18
|
+
await onMessageSend(input);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
MessageId: (0, uuid_1.v4)(),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return sqsClient;
|
|
25
|
+
}
|
|
26
|
+
exports.createSQSClient = createSQSClient;
|
|
27
|
+
//# sourceMappingURL=mockedSQS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockedSQS.js","sourceRoot":"","sources":["../../src/mockedSQS.ts"],"names":[],"mappings":";;;AAAA,oDAI6B;AAC7B,6DAAiD;AACjD,+BAAmC;AAKnC,SAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,aAAa,GAId;IACC,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;KAC7B;IACD,MAAM,YAAY,GAAG,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC;IAE3C,MAAM,mBAAmB,GAAyB,EAAE,CAAC;IAEpD,SAAiB,CAAC,sBAAsB,GAAG,mBAAmB,CAAC;IAEhE,YAAY,CAAC,EAAE,CAAC,+BAAkB,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAgB,EAAE;QAC1E,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,8DAA8D;QAC9D,IAAI,aAAa,EAAE;YACjB,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;SAC5B;QAED,OAAO;YACL,SAAS,EAAE,IAAA,SAAK,GAAE;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC;AA9BD,0CA8BC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SendMessageRequest, SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
+
export declare type MessageCallback = (input: SendMessageRequest) => Promise<void> | void;
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a mocked SQS client for local development. Initializes the client if not already created.
|
|
5
|
+
* @param {MessageCallback} [onMessageSend] - Optional callback to handle the message sent event.
|
|
6
|
+
* @returns {SQSClient} The mocked SQS client.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getMockedSQS: (onMessageSend?: MessageCallback) => SQSClient;
|
|
9
|
+
/**
|
|
10
|
+
* Connects to SQS, using a mocked client for local deployment or a real SQS client for other environments.
|
|
11
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
12
|
+
* @param {any} packageSchema - Package schema.
|
|
13
|
+
* @param {any} deploymentData - Deployment data.
|
|
14
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
15
|
+
* @returns {Promise<SQSClient>} The SQS client.
|
|
16
|
+
*/
|
|
17
|
+
export declare const connect: (goldstackConfig: any, packageSchema: any, deploymentData: any, deploymentName?: string) => Promise<SQSClient>;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the SQS queue name for the specified deployment or environment.
|
|
20
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
21
|
+
* @param {any} packageSchema - Package schema.
|
|
22
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
23
|
+
* @returns {Promise<string>} The name of the SQS queue.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getSQSQueueName: (goldstackConfig: any, packageSchema: any, deploymentName?: string) => Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the SQS Dead Letter Queue (DLQ) name for the specified deployment or environment.
|
|
28
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
29
|
+
* @param {any} packageSchema - Package schema.
|
|
30
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
31
|
+
* @returns {Promise<string>} The name of the SQS DLQ queue.
|
|
32
|
+
*/
|
|
33
|
+
export declare const getSQSDLQQueueName: (goldstackConfig: any, packageSchema: any, deploymentName?: string) => Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Constructs the SQS queue URL for the given deployment.
|
|
36
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
37
|
+
* @param {any} packageSchema - Package schema.
|
|
38
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
39
|
+
* @returns {Promise<string>} The URL of the SQS queue.
|
|
40
|
+
*/
|
|
41
|
+
export declare const getSQSQueueUrl: (goldstackConfig: any, packageSchema: any, deploymentName?: string) => Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Constructs the SQS Dead Letter Queue (DLQ) URL for the given deployment.
|
|
44
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
45
|
+
* @param {any} packageSchema - Package schema.
|
|
46
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
47
|
+
* @returns {Promise<string>} The URL of the SQS DLQ queue.
|
|
48
|
+
*/
|
|
49
|
+
export declare const getSQSDLQQueueUrl: (goldstackConfig: any, packageSchema: any, deploymentName?: string) => Promise<string>;
|
|
50
|
+
//# sourceMappingURL=sqsConnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsConnect.d.ts","sourceRoot":"","sources":["../../src/sqsConnect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAoCpE,oBAAY,eAAe,GAAG,CAC5B,KAAK,EAAE,kBAAkB,KACtB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE1B;;;;GAIG;AACH,eAAO,MAAM,YAAY,mBAAoB,eAAe,KAAG,SAW9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,oBACD,GAAG,iBACL,GAAG,kBACF,GAAG,mBACF,MAAM,KACtB,QAAQ,SAAS,CAgBnB,CAAC;AAcF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,oBACT,GAAG,iBACL,GAAG,mBACD,MAAM,KACtB,QAAQ,MAAM,CAWhB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,oBACZ,GAAG,iBACL,GAAG,mBACD,MAAM,KACtB,QAAQ,MAAM,CAWhB,CAAC;AAwBF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,oBACR,GAAG,iBACL,GAAG,mBACD,MAAM,KACtB,QAAQ,MAAM,CAShB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,oBACX,GAAG,iBACL,GAAG,mBACD,MAAM,KACtB,QAAQ,MAAM,CAShB,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSQSDLQQueueUrl = exports.getSQSQueueUrl = exports.getSQSDLQQueueName = exports.getSQSQueueName = exports.connect = exports.getMockedSQS = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
5
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
6
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
7
|
+
const utils_package_config_embedded_1 = require("@goldstack/utils-package-config-embedded");
|
|
8
|
+
const utils_esbuild_1 = require("@goldstack/utils-esbuild");
|
|
9
|
+
let mockedSQS;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves an environment variable by key. Throws an error if the variable is not set.
|
|
12
|
+
* @param {string} key - The environment variable key.
|
|
13
|
+
* @returns {string} The value of the environment variable.
|
|
14
|
+
* @throws Will throw an error if the environment variable is not set.
|
|
15
|
+
*/
|
|
16
|
+
const getEnvVar = (key) => {
|
|
17
|
+
const value = process.env[key];
|
|
18
|
+
if (!value)
|
|
19
|
+
throw new Error(`${key} environment variable is not set.`);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Constructs the SQS Queue URL based on the queue name, region, and account ID.
|
|
24
|
+
* @param {string} queueName - The name of the SQS queue.
|
|
25
|
+
* @param {string} region - AWS region.
|
|
26
|
+
* @param {string} accountId - AWS account ID.
|
|
27
|
+
* @returns {string} The constructed SQS Queue URL.
|
|
28
|
+
*/
|
|
29
|
+
const constructQueueUrl = (queueName, region, accountId) => `https://sqs.${region}.amazonaws.com/${accountId}/${queueName}`;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves a mocked SQS client for local development. Initializes the client if not already created.
|
|
32
|
+
* @param {MessageCallback} [onMessageSend] - Optional callback to handle the message sent event.
|
|
33
|
+
* @returns {SQSClient} The mocked SQS client.
|
|
34
|
+
*/
|
|
35
|
+
const getMockedSQS = (onMessageSend) => {
|
|
36
|
+
if (!mockedSQS) {
|
|
37
|
+
const createSQSClient = require((0, utils_esbuild_1.excludeInBundle)('./mockedSQS')).createSQSClient;
|
|
38
|
+
mockedSQS = createSQSClient({ sqsClient: undefined, onMessageSend });
|
|
39
|
+
}
|
|
40
|
+
if (!mockedSQS) {
|
|
41
|
+
throw new Error('Mocked SQS client not initialized');
|
|
42
|
+
}
|
|
43
|
+
return mockedSQS;
|
|
44
|
+
};
|
|
45
|
+
exports.getMockedSQS = getMockedSQS;
|
|
46
|
+
/**
|
|
47
|
+
* Connects to SQS, using a mocked client for local deployment or a real SQS client for other environments.
|
|
48
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
49
|
+
* @param {any} packageSchema - Package schema.
|
|
50
|
+
* @param {any} deploymentData - Deployment data.
|
|
51
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
52
|
+
* @returns {Promise<SQSClient>} The SQS client.
|
|
53
|
+
*/
|
|
54
|
+
const connect = async (goldstackConfig, packageSchema, deploymentData, deploymentName) => {
|
|
55
|
+
deploymentName = deploymentName || getEnvVar('GOLDSTACK_DEPLOYMENT');
|
|
56
|
+
if (deploymentName === 'local') {
|
|
57
|
+
return (0, exports.getMockedSQS)();
|
|
58
|
+
}
|
|
59
|
+
const deployment = deploymentData[deploymentName];
|
|
60
|
+
const awsUser = process.env.AWS_ACCESS_KEY_ID
|
|
61
|
+
? (0, credential_providers_1.fromEnv)()
|
|
62
|
+
: await getAwsUser(deployment.awsUser);
|
|
63
|
+
return new client_sqs_1.SQSClient({
|
|
64
|
+
credentials: awsUser,
|
|
65
|
+
region: deployment.awsRegion,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
exports.connect = connect;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the AWS user credentials based on the given configuration.
|
|
71
|
+
* @param {any} awsUserConfig - Configuration for the AWS user.
|
|
72
|
+
* @returns {Promise<AwsCredentialIdentityProvider>} The AWS credential provider.
|
|
73
|
+
*/
|
|
74
|
+
const getAwsUser = async (awsUserConfig) => {
|
|
75
|
+
const infraAWSLib = require((0, utils_esbuild_1.excludeInBundle)('@goldstack/infra-aws'));
|
|
76
|
+
return infraAWSLib.getAWSUser(awsUserConfig);
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the SQS queue name for the specified deployment or environment.
|
|
80
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
81
|
+
* @param {any} packageSchema - Package schema.
|
|
82
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
83
|
+
* @returns {Promise<string>} The name of the SQS queue.
|
|
84
|
+
*/
|
|
85
|
+
const getSQSQueueName = async (goldstackConfig, packageSchema, deploymentName) => {
|
|
86
|
+
const packageConfig = new utils_package_config_embedded_1.EmbeddedPackageConfig({
|
|
87
|
+
goldstackJson: goldstackConfig,
|
|
88
|
+
packageSchema,
|
|
89
|
+
});
|
|
90
|
+
deploymentName = deploymentName || getEnvVar('GOLDSTACK_DEPLOYMENT');
|
|
91
|
+
if (deploymentName === 'local')
|
|
92
|
+
return 'test-local-queue';
|
|
93
|
+
const deployment = packageConfig.getDeployment(deploymentName);
|
|
94
|
+
return getRequiredConfig(deployment, 'sqs_queue_name', deploymentName);
|
|
95
|
+
};
|
|
96
|
+
exports.getSQSQueueName = getSQSQueueName;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves the SQS Dead Letter Queue (DLQ) name for the specified deployment or environment.
|
|
99
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
100
|
+
* @param {any} packageSchema - Package schema.
|
|
101
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
102
|
+
* @returns {Promise<string>} The name of the SQS DLQ queue.
|
|
103
|
+
*/
|
|
104
|
+
const getSQSDLQQueueName = async (goldstackConfig, packageSchema, deploymentName) => {
|
|
105
|
+
const packageConfig = new utils_package_config_embedded_1.EmbeddedPackageConfig({
|
|
106
|
+
goldstackJson: goldstackConfig,
|
|
107
|
+
packageSchema,
|
|
108
|
+
});
|
|
109
|
+
deploymentName = deploymentName || getEnvVar('GOLDSTACK_DEPLOYMENT');
|
|
110
|
+
if (deploymentName === 'local')
|
|
111
|
+
return 'test-local-dlq';
|
|
112
|
+
const deployment = packageConfig.getDeployment(deploymentName);
|
|
113
|
+
return getRequiredConfig(deployment, 'sqs_dlq_queue_name', deploymentName);
|
|
114
|
+
};
|
|
115
|
+
exports.getSQSDLQQueueName = getSQSDLQQueueName;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves the required configuration value from the deployment configuration.
|
|
118
|
+
* @param {any} deployment - Deployment configuration.
|
|
119
|
+
* @param {string} configKey - Key for the configuration value (e.g., sqs_queue_name).
|
|
120
|
+
* @param {string} deploymentName - Name of the deployment.
|
|
121
|
+
* @returns {string} The configuration value.
|
|
122
|
+
* @throws Will throw an error if the configuration value is not found.
|
|
123
|
+
*/
|
|
124
|
+
const getRequiredConfig = (deployment, configKey, deploymentName) => {
|
|
125
|
+
const value = deployment.configuration[configKey];
|
|
126
|
+
if (!value) {
|
|
127
|
+
throw new Error(`No ${configKey} for deployment ${deploymentName}. Provide it in the configuration.`);
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Constructs the SQS queue URL for the given deployment.
|
|
133
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
134
|
+
* @param {any} packageSchema - Package schema.
|
|
135
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
136
|
+
* @returns {Promise<string>} The URL of the SQS queue.
|
|
137
|
+
*/
|
|
138
|
+
const getSQSQueueUrl = async (goldstackConfig, packageSchema, deploymentName) => {
|
|
139
|
+
const queueName = await (0, exports.getSQSQueueName)(goldstackConfig, packageSchema, deploymentName);
|
|
140
|
+
const { region, accountId } = getAwsInfo(deploymentName);
|
|
141
|
+
return constructQueueUrl(queueName, region, accountId);
|
|
142
|
+
};
|
|
143
|
+
exports.getSQSQueueUrl = getSQSQueueUrl;
|
|
144
|
+
/**
|
|
145
|
+
* Constructs the SQS Dead Letter Queue (DLQ) URL for the given deployment.
|
|
146
|
+
* @param {any} goldstackConfig - Goldstack configuration object.
|
|
147
|
+
* @param {any} packageSchema - Package schema.
|
|
148
|
+
* @param {string} [deploymentName] - Optional deployment name. Defaults to environment variable GOLDSTACK_DEPLOYMENT.
|
|
149
|
+
* @returns {Promise<string>} The URL of the SQS DLQ queue.
|
|
150
|
+
*/
|
|
151
|
+
const getSQSDLQQueueUrl = async (goldstackConfig, packageSchema, deploymentName) => {
|
|
152
|
+
const dlqQueueName = await (0, exports.getSQSDLQQueueName)(goldstackConfig, packageSchema, deploymentName);
|
|
153
|
+
const { region, accountId } = getAwsInfo(deploymentName);
|
|
154
|
+
return constructQueueUrl(dlqQueueName, region, accountId);
|
|
155
|
+
};
|
|
156
|
+
exports.getSQSDLQQueueUrl = getSQSDLQQueueUrl;
|
|
157
|
+
/**
|
|
158
|
+
* Helper function to retrieve the AWS region and account ID. Defaults to mock values for local deployment.
|
|
159
|
+
* @param {string} [deploymentName] - Optional deployment name.
|
|
160
|
+
* @returns {{region: string, accountId: string}} The AWS region and account ID.
|
|
161
|
+
*/
|
|
162
|
+
const getAwsInfo = (deploymentName) => {
|
|
163
|
+
deploymentName = deploymentName || getEnvVar('GOLDSTACK_DEPLOYMENT');
|
|
164
|
+
if (deploymentName === 'local') {
|
|
165
|
+
return { region: 'mock-region', accountId: '123456789012' };
|
|
166
|
+
}
|
|
167
|
+
const region = getEnvVar('AWS_REGION');
|
|
168
|
+
const accountId = getEnvVar('AWS_ACCOUNT_ID');
|
|
169
|
+
return { region, accountId };
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=sqsConnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsConnect.js","sourceRoot":"","sources":["../../src/sqsConnect.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,oDAAoE;AAEpE,wEAAwD;AAGxD,4FAAiF;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iB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC5D,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B;AAEF;;;;GAIG;AACH,MAAM,UAAU,GAAG,CACjB,cAAuB,EACgB,EAAE;IACzC,cAAc,GAAG,cAAc,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAC;IACrE,IAAI,cAAc,KAAK,OAAO,EAAE;QAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;KAC7D;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC9C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { connect, getMockedSQS, getSQSDLQQueueName, getSQSDLQQueueUrl, getSQSQueueName, getSQSQueueUrl, } from './sqsConnect';
|
|
2
|
+
import { SendMessageRequest, SQSClient } from '@aws-sdk/client-sqs';
|
|
3
|
+
import { MessageCallback } from './sqsConnect';
|
|
4
|
+
export declare function createSQSClient({ sqsClient, onMessageSend, }: {
|
|
5
|
+
sqsClient?: SQSClient;
|
|
6
|
+
onMessageSend?: MessageCallback;
|
|
7
|
+
}): SQSClient;
|
|
8
|
+
export declare const getSentMessageRequests: (sqsClient: SQSClient) => SendMessageRequest[];
|
|
9
|
+
//# sourceMappingURL=templateSqs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSqs.d.ts","sourceRoot":"","sources":["../../src/templateSqs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,aAAa,GACd,EAAE;IACD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,eAAe,CAAC;CACjC,GAAG,SAAS,CAMZ;AAGD,eAAO,MAAM,sBAAsB,cACtB,SAAS,KACnB,kBAAkB,EAQpB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSentMessageRequests = exports.createSQSClient = exports.getSQSQueueUrl = exports.getSQSQueueName = exports.getSQSDLQQueueUrl = exports.getSQSDLQQueueName = exports.getMockedSQS = exports.connect = void 0;
|
|
4
|
+
var sqsConnect_1 = require("./sqsConnect"); // Now importing from SQS-related module
|
|
5
|
+
Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return sqsConnect_1.connect; } });
|
|
6
|
+
Object.defineProperty(exports, "getMockedSQS", { enumerable: true, get: function () { return sqsConnect_1.getMockedSQS; } });
|
|
7
|
+
Object.defineProperty(exports, "getSQSDLQQueueName", { enumerable: true, get: function () { return sqsConnect_1.getSQSDLQQueueName; } });
|
|
8
|
+
Object.defineProperty(exports, "getSQSDLQQueueUrl", { enumerable: true, get: function () { return sqsConnect_1.getSQSDLQQueueUrl; } });
|
|
9
|
+
Object.defineProperty(exports, "getSQSQueueName", { enumerable: true, get: function () { return sqsConnect_1.getSQSQueueName; } });
|
|
10
|
+
Object.defineProperty(exports, "getSQSQueueUrl", { enumerable: true, get: function () { return sqsConnect_1.getSQSQueueUrl; } });
|
|
11
|
+
const utils_esbuild_1 = require("@goldstack/utils-esbuild");
|
|
12
|
+
function createSQSClient({ sqsClient, onMessageSend, }) {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
return require((0, utils_esbuild_1.excludeInBundle)('./mockedSQS')).createSQSClient({
|
|
15
|
+
sqsClient,
|
|
16
|
+
onMessageSend,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.createSQSClient = createSQSClient;
|
|
20
|
+
// Helper function to retrieve sent message requests from the mocked SQS client
|
|
21
|
+
const getSentMessageRequests = (sqsClient) => {
|
|
22
|
+
// Check if the _goldstackSentRequests property exists and return the array of sent requests
|
|
23
|
+
if (sqsClient._goldstackSentRequests) {
|
|
24
|
+
return sqsClient._goldstackSentRequests;
|
|
25
|
+
}
|
|
26
|
+
// If no messages have been sent, return an empty array
|
|
27
|
+
return [];
|
|
28
|
+
};
|
|
29
|
+
exports.getSentMessageRequests = getSentMessageRequests;
|
|
30
|
+
//# sourceMappingURL=templateSqs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSqs.js","sourceRoot":"","sources":["../../src/templateSqs.ts"],"names":[],"mappings":";;;AAAA,2CAOsB,CAAC,wCAAwC;AAN7D,qGAAA,OAAO,OAAA;AACP,0GAAA,YAAY,OAAA;AACZ,gHAAA,kBAAkB,OAAA;AAClB,+GAAA,iBAAiB,OAAA;AACjB,6GAAA,eAAe,OAAA;AACf,4GAAA,cAAc,OAAA;AAIhB,4DAA2D;AAG3D,SAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,aAAa,GAId;IACC,8DAA8D;IAC9D,OAAO,OAAO,CAAC,IAAA,+BAAe,EAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7D,SAAS;QACT,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAZD,0CAYC;AAED,+EAA+E;AACxE,MAAM,sBAAsB,GAAG,CACpC,SAAoB,EACE,EAAE;IACxB,4FAA4F;IAC5F,IAAK,SAAiB,CAAC,sBAAsB,EAAE;QAC7C,OAAQ,SAAiB,CAAC,sBAAsB,CAAC;KAClD;IAED,uDAAuD;IACvD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAVW,QAAA,sBAAsB,0BAUjC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goldstack/template-sqs",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Utilities for packages that implement SQS functionality",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"goldstack",
|
|
7
|
+
"utility",
|
|
8
|
+
"infrastructure",
|
|
9
|
+
"IaC",
|
|
10
|
+
"aws",
|
|
11
|
+
"SQS",
|
|
12
|
+
"queue",
|
|
13
|
+
"serverless",
|
|
14
|
+
"configuration"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://goldstack.party",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/goldstack/goldstack/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/goldstack/goldstack.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Max Rohde",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "dist/src/templateSqs.js",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "yarn clean && yarn compile",
|
|
30
|
+
"build:watch": "yarn clean && yarn compile-watch",
|
|
31
|
+
"clean": "rimraf ./dist",
|
|
32
|
+
"compile": "tsc -p tsconfig.json",
|
|
33
|
+
"compile-watch": "tsc -p tsconfig.json --watch",
|
|
34
|
+
"compile-watch:light": "nodemon --watch ./src/ -e '*' --exec 'yarn compile'",
|
|
35
|
+
"coverage": "jest --collect-coverage --passWithNoTests --config=./jest.config.js --runInBand",
|
|
36
|
+
"prepublishOnly": "yarn run build",
|
|
37
|
+
"publish": "utils-git changed --exec \"yarn npm publish $@\"",
|
|
38
|
+
"test": "GOLDSTACK_DEPLOYMENT=local jest --watch --config=./jest.config.js --runInBand",
|
|
39
|
+
"test-ci": "GOLDSTACK_DEPLOYMENT=local jest --passWithNoTests --config=./jest.config.js --runInBand",
|
|
40
|
+
"version:apply": "utils-git changed --exec \"yarn version $@ && yarn version apply\"",
|
|
41
|
+
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@aws-sdk/client-sqs": "3.645.0",
|
|
45
|
+
"@aws-sdk/credential-providers": "3.645.0",
|
|
46
|
+
"@aws-sdk/types": "^3.609.0",
|
|
47
|
+
"@goldstack/infra": "0.4.12",
|
|
48
|
+
"@goldstack/infra-aws": "0.4.21",
|
|
49
|
+
"@goldstack/utils-cli": "0.3.10",
|
|
50
|
+
"@goldstack/utils-esbuild": "0.5.9",
|
|
51
|
+
"@goldstack/utils-package": "0.4.12",
|
|
52
|
+
"@goldstack/utils-package-config-embedded": "0.5.13",
|
|
53
|
+
"@goldstack/utils-terraform": "0.4.26",
|
|
54
|
+
"@goldstack/utils-terraform-aws": "0.4.29",
|
|
55
|
+
"aws-sdk-client-mock": "^4.0.1",
|
|
56
|
+
"uuid": "^8.3.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@goldstack/utils-git": "0.2.9",
|
|
60
|
+
"@goldstack/utils-package-config-generate": "0.3.10",
|
|
61
|
+
"@swc/core": "^1.3.74",
|
|
62
|
+
"@swc/jest": "^0.2.27",
|
|
63
|
+
"@types/jest": "^29.0.1",
|
|
64
|
+
"@types/mock-aws-s3": "^2.6.3",
|
|
65
|
+
"@types/node": "^18.7.13",
|
|
66
|
+
"@types/uuid": "^8.3.0",
|
|
67
|
+
"jest": "^29.3.1",
|
|
68
|
+
"rimraf": "^3.0.2",
|
|
69
|
+
"ts-node": "^10.9.1",
|
|
70
|
+
"typescript": "^4.8.4"
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"main": "dist/src/templateSqs.js"
|
|
74
|
+
}
|
|
75
|
+
}
|