@candlerip/shared3 0.0.101 → 0.0.103

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/_devops/npm/npm-update-packages.sh +1 -1
  2. package/package.json +16 -1
  3. package/src/_devops/get-project-config/domains/args/index.d.ts +5 -0
  4. package/src/_devops/get-project-config/domains/args/index.js +1 -0
  5. package/src/_devops/get-project-config/domains/index.d.ts +1 -0
  6. package/src/_devops/get-project-config/domains/index.js +1 -0
  7. package/src/_devops/get-project-config/index.d.ts +2 -0
  8. package/src/_devops/get-project-config/index.js +18 -0
  9. package/src/aws/account-id/config.d.ts +1 -0
  10. package/src/aws/account-id/config.js +1 -0
  11. package/src/aws/account-id/index.d.ts +1 -0
  12. package/src/aws/account-id/index.js +1 -0
  13. package/src/aws/app-config/get-app-config/index.d.ts +1 -0
  14. package/src/aws/app-config/get-app-config/index.js +1 -0
  15. package/src/aws/app-config/get-app-config/util.d.ts +10 -0
  16. package/src/aws/app-config/get-app-config/util.js +79 -0
  17. package/src/aws/app-config/index.d.ts +1 -0
  18. package/src/aws/app-config/index.js +1 -0
  19. package/src/aws/cdk/attach-policy/index.d.ts +1 -0
  20. package/src/aws/cdk/attach-policy/index.js +1 -0
  21. package/src/aws/cdk/attach-policy/type.d.ts +24 -0
  22. package/src/aws/cdk/attach-policy/type.js +1 -0
  23. package/src/aws/cdk/attach-policy/util.d.ts +2 -0
  24. package/src/aws/cdk/attach-policy/util.js +33 -0
  25. package/src/aws/cdk/compose-cdk-stack/index.d.ts +1 -0
  26. package/src/aws/cdk/compose-cdk-stack/index.js +1 -0
  27. package/src/aws/cdk/compose-cdk-stack/type.d.ts +2 -0
  28. package/src/aws/cdk/compose-cdk-stack/type.js +1 -0
  29. package/src/aws/cdk/compose-cdk-stack/util.d.ts +2 -0
  30. package/src/aws/cdk/compose-cdk-stack/util.js +2 -0
  31. package/src/aws/cdk/index.d.ts +2 -0
  32. package/src/aws/cdk/index.js +2 -0
  33. package/src/aws/index.d.ts +7 -0
  34. package/src/aws/index.js +7 -0
  35. package/src/aws/lambda/index.d.ts +2 -0
  36. package/src/aws/lambda/index.js +2 -0
  37. package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.d.ts +1 -0
  38. package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.js +1 -0
  39. package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.d.ts +2 -0
  40. package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.js +1 -0
  41. package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.d.ts +2 -0
  42. package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.js +2 -0
  43. package/src/aws/lambda/lambda-arn/config.d.ts +1 -0
  44. package/src/aws/lambda/lambda-arn/config.js +3 -0
  45. package/src/aws/lambda/lambda-arn/index.d.ts +2 -0
  46. package/src/aws/lambda/lambda-arn/index.js +2 -0
  47. package/src/aws/lambda/lambda-name/config.d.ts +1 -0
  48. package/src/aws/lambda/lambda-name/config.js +1 -0
  49. package/src/aws/lambda/lambda-name/index.d.ts +2 -0
  50. package/src/aws/lambda/lambda-name/index.js +2 -0
  51. package/src/aws/lambda/lambda-name/type.d.ts +2 -0
  52. package/src/aws/lambda/lambda-name/type.js +1 -0
  53. package/src/aws/region/config.d.ts +1 -0
  54. package/src/aws/region/config.js +1 -0
  55. package/src/aws/region/default.d.ts +2 -0
  56. package/src/aws/region/default.js +1 -0
  57. package/src/aws/region/index.d.ts +3 -0
  58. package/src/aws/region/index.js +3 -0
  59. package/src/aws/region/type.d.ts +2 -0
  60. package/src/aws/region/type.js +1 -0
  61. package/src/aws/s3/index.d.ts +1 -0
  62. package/src/aws/s3/index.js +1 -0
  63. package/src/aws/s3/s3-arn/compose-s3-arn/index.d.ts +1 -0
  64. package/src/aws/s3/s3-arn/compose-s3-arn/index.js +1 -0
  65. package/src/aws/s3/s3-arn/compose-s3-arn/type.d.ts +1 -0
  66. package/src/aws/s3/s3-arn/compose-s3-arn/type.js +1 -0
  67. package/src/aws/s3/s3-arn/compose-s3-arn/util.d.ts +2 -0
  68. package/src/aws/s3/s3-arn/compose-s3-arn/util.js +2 -0
  69. package/src/aws/s3/s3-arn/config.d.ts +1 -0
  70. package/src/aws/s3/s3-arn/config.js +1 -0
  71. package/src/aws/s3/s3-arn/index.d.ts +2 -0
  72. package/src/aws/s3/s3-arn/index.js +2 -0
  73. package/src/aws/sqs/index.d.ts +2 -0
  74. package/src/aws/sqs/index.js +2 -0
  75. package/src/aws/sqs/queue-arn/compose-queue-arn/index.d.ts +1 -0
  76. package/src/aws/sqs/queue-arn/compose-queue-arn/index.js +1 -0
  77. package/src/aws/sqs/queue-arn/compose-queue-arn/type.d.ts +2 -0
  78. package/src/aws/sqs/queue-arn/compose-queue-arn/type.js +1 -0
  79. package/src/aws/sqs/queue-arn/compose-queue-arn/util.d.ts +2 -0
  80. package/src/aws/sqs/queue-arn/compose-queue-arn/util.js +2 -0
  81. package/src/aws/sqs/queue-arn/config.d.ts +1 -0
  82. package/src/aws/sqs/queue-arn/config.js +3 -0
  83. package/src/aws/sqs/queue-arn/index.d.ts +2 -0
  84. package/src/aws/sqs/queue-arn/index.js +2 -0
  85. package/src/aws/sqs/queue-name/cache/config.d.ts +1 -0
  86. package/src/aws/sqs/queue-name/cache/config.js +1 -0
  87. package/src/aws/sqs/queue-name/cache/index.d.ts +2 -0
  88. package/src/aws/sqs/queue-name/cache/index.js +2 -0
  89. package/src/aws/sqs/queue-name/cache/type.d.ts +2 -0
  90. package/src/aws/sqs/queue-name/cache/type.js +1 -0
  91. package/src/aws/sqs/queue-name/index.d.ts +3 -0
  92. package/src/aws/sqs/queue-name/index.js +3 -0
  93. package/src/aws/sqs/queue-name/logger/config.d.ts +1 -0
  94. package/src/aws/sqs/queue-name/logger/config.js +1 -0
  95. package/src/aws/sqs/queue-name/logger/index.d.ts +2 -0
  96. package/src/aws/sqs/queue-name/logger/index.js +2 -0
  97. package/src/aws/sqs/queue-name/logger/type.d.ts +2 -0
  98. package/src/aws/sqs/queue-name/logger/type.js +1 -0
  99. package/src/aws/sqs/queue-name/queue-name/config.d.ts +1 -0
  100. package/src/aws/sqs/queue-name/queue-name/config.js +3 -0
  101. package/src/aws/sqs/queue-name/queue-name/index.d.ts +2 -0
  102. package/src/aws/sqs/queue-name/queue-name/index.js +2 -0
  103. package/src/aws/sqs/queue-name/queue-name/type.d.ts +2 -0
  104. package/src/aws/sqs/queue-name/queue-name/type.js +1 -0
  105. package/src/backend/cache/cache/index.d.ts +2 -0
  106. package/src/backend/cache/cache/index.js +2 -0
  107. package/src/backend/cache/cache/singleton.d.ts +23 -0
  108. package/src/backend/cache/cache/singleton.js +104 -0
  109. package/src/backend/cache/cache/type.d.ts +5 -0
  110. package/src/backend/cache/cache/type.js +1 -0
  111. package/src/backend/cache/cache-key/config.d.ts +1 -0
  112. package/src/backend/cache/cache-key/config.js +18 -0
  113. package/src/backend/cache/cache-key/index.d.ts +3 -0
  114. package/src/backend/cache/cache-key/index.js +3 -0
  115. package/src/backend/cache/cache-key/type-guard.d.ts +2 -0
  116. package/src/backend/cache/cache-key/type-guard.js +4 -0
  117. package/src/backend/cache/cache-key/type.d.ts +2 -0
  118. package/src/backend/cache/cache-key/type.js +1 -0
  119. package/src/backend/cache/index.d.ts +2 -0
  120. package/src/backend/cache/index.js +2 -0
  121. package/src/backend/database/connect-database/index.d.ts +1 -0
  122. package/src/backend/database/connect-database/index.js +1 -0
  123. package/src/backend/database/connect-database/type.d.ts +1 -0
  124. package/src/backend/database/connect-database/type.js +1 -0
  125. package/src/backend/database/connect-database/util.d.ts +2 -0
  126. package/src/backend/database/connect-database/util.js +12 -0
  127. package/src/backend/database/model/translation/index.d.ts +2 -0
  128. package/src/backend/database/model/translation/index.js +2 -0
  129. package/src/backend/database/model/translation/type.d.ts +7 -0
  130. package/src/backend/database/model/translation/type.js +1 -0
  131. package/src/backend/database/model/translation/util.d.ts +7 -0
  132. package/src/backend/database/model/translation/util.js +7 -0
  133. package/src/backend/database/mutation/translation/get-translations/index.d.ts +1 -0
  134. package/src/backend/database/mutation/translation/get-translations/index.js +1 -0
  135. package/src/backend/database/mutation/translation/get-translations/type.d.ts +8 -0
  136. package/src/backend/database/mutation/translation/get-translations/type.js +1 -0
  137. package/src/backend/database/mutation/translation/get-translations/util.d.ts +2 -0
  138. package/src/backend/database/mutation/translation/get-translations/util.js +30 -0
  139. package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.d.ts +1 -0
  140. package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.js +1 -0
  141. package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.d.ts +7 -0
  142. package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.js +51 -0
  143. package/src/backend/database/mutation/translation/index.d.ts +2 -0
  144. package/src/backend/database/mutation/translation/index.js +2 -0
  145. package/src/backend/dictionary/compose-dictionary/index.d.ts +1 -0
  146. package/src/backend/dictionary/compose-dictionary/index.js +1 -0
  147. package/src/backend/dictionary/compose-dictionary/type.d.ts +10 -0
  148. package/src/backend/dictionary/compose-dictionary/type.js +1 -0
  149. package/src/backend/dictionary/compose-dictionary/util.d.ts +2 -0
  150. package/src/backend/dictionary/compose-dictionary/util.js +10 -0
  151. package/src/backend/dictionary/get-excluded-translation-ids/index.d.ts +1 -0
  152. package/src/backend/dictionary/get-excluded-translation-ids/index.js +1 -0
  153. package/src/backend/dictionary/get-excluded-translation-ids/type.d.ts +5 -0
  154. package/src/backend/dictionary/get-excluded-translation-ids/type.js +1 -0
  155. package/src/backend/dictionary/get-excluded-translation-ids/util.d.ts +2 -0
  156. package/src/backend/dictionary/get-excluded-translation-ids/util.js +10 -0
  157. package/src/backend/dictionary/index.d.ts +2 -0
  158. package/src/backend/dictionary/index.js +2 -0
  159. package/src/backend/express/index.d.ts +1 -0
  160. package/src/backend/express/index.js +1 -0
  161. package/src/backend/express/start-express-app/index.d.ts +1 -0
  162. package/src/backend/express/start-express-app/index.js +1 -0
  163. package/src/backend/express/start-express-app/type.d.ts +2 -0
  164. package/src/backend/express/start-express-app/type.js +1 -0
  165. package/src/backend/express/start-express-app/util.d.ts +2 -0
  166. package/src/backend/express/start-express-app/util.js +8 -0
  167. package/src/backend/message-broker/index.d.ts +4 -0
  168. package/src/backend/message-broker/index.js +4 -0
  169. package/src/backend/message-broker/log-custom-error/index.d.ts +1 -0
  170. package/src/backend/message-broker/log-custom-error/index.js +1 -0
  171. package/src/backend/message-broker/log-custom-error/type.d.ts +2 -0
  172. package/src/backend/message-broker/log-custom-error/type.js +1 -0
  173. package/src/backend/message-broker/log-custom-error/util.d.ts +2 -0
  174. package/src/backend/message-broker/log-custom-error/util.js +2 -0
  175. package/src/backend/message-broker/message-broker/config.d.ts +4 -0
  176. package/src/backend/message-broker/message-broker/config.js +4 -0
  177. package/src/backend/message-broker/message-broker/index.d.ts +3 -0
  178. package/src/backend/message-broker/message-broker/index.js +3 -0
  179. package/src/backend/message-broker/message-broker/singleton.d.ts +7 -0
  180. package/src/backend/message-broker/message-broker/singleton.js +70 -0
  181. package/src/backend/message-broker/message-broker/type.d.ts +12 -0
  182. package/src/backend/message-broker/message-broker/type.js +1 -0
  183. package/src/backend/message-broker/message-broker-queue-name/index.d.ts +1 -0
  184. package/src/backend/message-broker/message-broker-queue-name/index.js +1 -0
  185. package/src/backend/message-broker/message-broker-queue-name/type.d.ts +2 -0
  186. package/src/backend/message-broker/message-broker-queue-name/type.js +1 -0
  187. package/src/backend/message-broker/message-broker-refresh-cache/index.d.ts +2 -0
  188. package/src/backend/message-broker/message-broker-refresh-cache/index.js +2 -0
  189. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.d.ts +1 -0
  190. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.js +1 -0
  191. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.d.ts +2 -0
  192. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.js +1 -0
  193. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.d.ts +2 -0
  194. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.js +6 -0
  195. package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +4 -0
  196. package/src/backend/message-broker/message-broker-refresh-cache/type.js +1 -0
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/bash
2
2
 
3
- PACKAGES=( @candlerip/shared3 @candlerip/shared-aws3 @candlerip/shared-backend3 )
3
+ PACKAGES=( @candlerip/shared3 )
4
4
  for PACKAGE in "${PACKAGES[@]}"
5
5
  do
6
6
  npm list --depth=0 | grep $PACKAGE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.101",
3
+ "version": "0.0.103",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  "crs-docker-publish": "./_devops/docker/docker-publish.sh",
9
9
  "crs-ec2-deploy": "./_devops/ec2/ec2-deploy.sh",
10
10
  "crs-eslint": "./_devops/eslint/eslint.sh",
11
+ "crs-get-project-config": "./src/_devops/get-project-config/index.js",
11
12
  "crs-git-push": "./_devops/git/git-push.sh",
12
13
  "crs-npm-patch-version": "./_devops/npm/npm-patch-version.sh",
13
14
  "crs-npm-publish": "./_devops/npm/npm-publish.sh",
@@ -21,6 +22,8 @@
21
22
  "start": "./_devops/typescript/tsc-watch.sh"
22
23
  },
23
24
  "devDependencies": {
25
+ "@types/amqplib": "^0.10.5",
26
+ "@types/express": "^5.0.0",
24
27
  "@types/node": "^22.7.4",
25
28
  "eslint": "^9.12.0",
26
29
  "globals": "^15.10.0",
@@ -28,5 +31,17 @@
28
31
  "tsc-alias": "^1.8.10",
29
32
  "typescript": "^5.6.2",
30
33
  "typescript-eslint": "^8.8.0"
34
+ },
35
+ "dependencies": {
36
+ "@aws-sdk/client-appconfig": "^3.682.0",
37
+ "@aws-sdk/client-appconfigdata": "^3.682.0",
38
+ "@aws-sdk/client-s3": "^3.685.0",
39
+ "amqplib": "^0.10.4",
40
+ "aws-cdk-lib": "^2.165.0",
41
+ "commander": "^12.1.0",
42
+ "dotenv": "^16.4.5",
43
+ "express": "^4.21.1",
44
+ "mongoose": "^8.8.0",
45
+ "redis": "^4.7.0"
31
46
  }
32
47
  }
@@ -0,0 +1,5 @@
1
+ import { EnvironmentMode, EnvironmentVariables } from '../../../../environment/index.js';
2
+ export interface Args {
3
+ projectName: keyof EnvironmentVariables;
4
+ environmentMode: EnvironmentMode;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './args/index.js';
@@ -0,0 +1 @@
1
+ export * from './args/index.js';
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { program } from 'commander';
3
+ import * as fs from 'fs';
4
+ import { getAppConfig } from '../../aws/index.js';
5
+ import { ProjectSingleton } from '../../project/index.js';
6
+ import { consoleCustomError } from '../../error/index.js';
7
+ ProjectSingleton.init('shared-aws');
8
+ program.requiredOption('--project-name <value>').requiredOption('--environment-mode <value>');
9
+ program.parse();
10
+ const { environmentMode, projectName } = program.opts();
11
+ const resp = await getAppConfig({ projectName, environmentMode });
12
+ if ('customError' in resp) {
13
+ consoleCustomError(resp.customError);
14
+ process.exit(1);
15
+ }
16
+ const config = resp.data;
17
+ const fileData = Object.keys(config).map((it) => `${it}=${config[it]}`).join('\n');
18
+ fs.writeFileSync(`.env.${environmentMode}`, fileData);
@@ -0,0 +1 @@
1
+ export declare const AWS_ACCOUNT_ID = 430408040574;
@@ -0,0 +1 @@
1
+ export const AWS_ACCOUNT_ID = 430408040574;
@@ -0,0 +1 @@
1
+ export * from './config.js';
@@ -0,0 +1 @@
1
+ export * from './config.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1,10 @@
1
+ import { EnvironmentMode, EnvironmentVariables } from '../../../environment/index.js';
2
+ import { CustomError } from '../../../error/index.js';
3
+ export declare const getAppConfig: <T extends keyof EnvironmentVariables>(props: {
4
+ environmentMode: EnvironmentMode;
5
+ projectName: T;
6
+ }) => Promise<{
7
+ data: EnvironmentVariables[T];
8
+ } | {
9
+ customError: CustomError;
10
+ }>;
@@ -0,0 +1,79 @@
1
+ import * as appConfigDataSdk from '@aws-sdk/client-appconfigdata';
2
+ import * as appConfigSdk from '@aws-sdk/client-appconfig';
3
+ import { customErrorWorker } from '../../../error/index.js';
4
+ export const getAppConfig = async (props) => {
5
+ const { environmentMode, projectName } = props;
6
+ const { composeCustomError } = customErrorWorker(props);
7
+ let client;
8
+ let resp;
9
+ client = new appConfigSdk.AppConfigClient();
10
+ try {
11
+ resp = await client.send(new appConfigSdk.ListApplicationsCommand());
12
+ }
13
+ catch (err) {
14
+ return composeCustomError('Error during list AppConfig Applications', { err });
15
+ }
16
+ const applications = resp.Items;
17
+ if (!applications) {
18
+ return composeCustomError('No AppConfig Applications found');
19
+ }
20
+ const application = applications.find((it) => it.Name === projectName);
21
+ if (!application) {
22
+ return composeCustomError('AppConfig Application not found');
23
+ }
24
+ const applicationId = application.Id;
25
+ try {
26
+ resp = await client.send(new appConfigSdk.ListEnvironmentsCommand({ ApplicationId: applicationId }));
27
+ }
28
+ catch (err) {
29
+ return composeCustomError('Error during list AppConfig Environments', { err });
30
+ }
31
+ const environments = resp.Items;
32
+ if (!environments) {
33
+ return composeCustomError('No AppConfig Environments found');
34
+ }
35
+ const environment = environments.find((it) => it.Name === environmentMode);
36
+ if (!environment) {
37
+ return composeCustomError('AppConfig Environment not found');
38
+ }
39
+ const environmentId = environment.Id;
40
+ try {
41
+ resp = await client.send(new appConfigSdk.ListConfigurationProfilesCommand({ ApplicationId: applicationId }));
42
+ }
43
+ catch (err) {
44
+ return composeCustomError('Error during list AppConfig Configuration Profiles', { err });
45
+ }
46
+ const configurationProfiles = resp.Items;
47
+ if (!configurationProfiles) {
48
+ return composeCustomError('No AppConfig Configuration Profiles found');
49
+ }
50
+ const configurationProfile = configurationProfiles.find((it) => it.Name === `${environmentMode}-profile`);
51
+ if (!configurationProfile) {
52
+ return composeCustomError('AppConfig Configuration Profile not found');
53
+ }
54
+ const configurationProfileId = configurationProfile.Id;
55
+ client = new appConfigDataSdk.AppConfigDataClient();
56
+ try {
57
+ resp = await client.send(new appConfigDataSdk.StartConfigurationSessionCommand({
58
+ ApplicationIdentifier: applicationId,
59
+ EnvironmentIdentifier: environmentId,
60
+ ConfigurationProfileIdentifier: configurationProfileId,
61
+ }));
62
+ }
63
+ catch (err) {
64
+ return composeCustomError('Error during get AppConfig initial configuration token', { err });
65
+ }
66
+ const ConfigurationToken = resp.InitialConfigurationToken;
67
+ let appConfig;
68
+ try {
69
+ resp = await client.send(new appConfigDataSdk.GetLatestConfigurationCommand({ ConfigurationToken }));
70
+ const appConfigStr = new TextDecoder().decode(resp.Configuration);
71
+ appConfig = JSON.parse(appConfigStr);
72
+ }
73
+ catch (err) {
74
+ return composeCustomError('Error during get AppConfig', { err });
75
+ }
76
+ return {
77
+ data: appConfig,
78
+ };
79
+ };
@@ -0,0 +1 @@
1
+ export * from './get-app-config/index.js';
@@ -0,0 +1 @@
1
+ export * from './get-app-config/index.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1,24 @@
1
+ import { Function as LambdaFunction } from 'aws-cdk-lib/aws-lambda';
2
+ import { Instance } from 'aws-cdk-lib/aws-ec2';
3
+ import { LambdaName } from '../../lambda/index.js';
4
+ import { QueueName } from '../../sqs/index.js';
5
+ export type AttachPolicy = (instance: LambdaFunction | Instance, props: {
6
+ appConfig: {
7
+ actions: Array<'appconfig:GetLatestConfiguration' | 'appconfig:ListApplications' | 'appconfig:ListConfigurationProfiles' | 'appconfig:ListEnvironments' | 'appconfig:StartConfigurationSession'>;
8
+ };
9
+ } | {
10
+ lambda: {
11
+ actions: 'lambda:InvokeFunction'[];
12
+ name: LambdaName;
13
+ };
14
+ } | {
15
+ sqs: {
16
+ actions: 'sqs:SendMessage'[];
17
+ name: QueueName;
18
+ };
19
+ } | {
20
+ s3: {
21
+ actions: Array<'s3:DeleteObject' | 's3:PutObject'>;
22
+ bucketName: string;
23
+ };
24
+ }) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AttachPolicy } from './type.js';
2
+ export declare const attachPolicy: AttachPolicy;
@@ -0,0 +1,33 @@
1
+ import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam';
2
+ import { composeLambdaArn } from '../../lambda/index.js';
3
+ import { composeQueueArn } from '../../sqs/index.js';
4
+ import { composeS3Arn } from '../../s3/index.js';
5
+ export const attachPolicy = (instance, props) => {
6
+ let actions;
7
+ let resource;
8
+ if ('appConfig' in props) {
9
+ const { appConfig } = props;
10
+ actions = appConfig.actions;
11
+ resource = '*';
12
+ }
13
+ else if ('lambda' in props) {
14
+ const { lambda } = props;
15
+ actions = lambda.actions;
16
+ resource = composeLambdaArn(lambda.name);
17
+ }
18
+ else if ('sqs' in props) {
19
+ const { sqs } = props;
20
+ actions = sqs.actions;
21
+ resource = composeQueueArn(sqs.name);
22
+ }
23
+ else {
24
+ const { s3 } = props;
25
+ actions = s3.actions;
26
+ resource = composeS3Arn(s3.bucketName);
27
+ }
28
+ instance.addToRolePolicy(new PolicyStatement({
29
+ effect: Effect.ALLOW,
30
+ actions,
31
+ resources: [resource],
32
+ }));
33
+ };
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1,2 @@
1
+ import * as cdk from 'aws-cdk-lib';
2
+ export type ComposeCdkStack = (stackName: string) => cdk.Stack;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ComposeCdkStack } from './type.js';
2
+ export declare const composeCdkStack: ComposeCdkStack;
@@ -0,0 +1,2 @@
1
+ import * as cdk from 'aws-cdk-lib';
2
+ export const composeCdkStack = (stackName) => new cdk.Stack(new cdk.App(), stackName);
@@ -0,0 +1,2 @@
1
+ export * from './attach-policy/index.js';
2
+ export * from './compose-cdk-stack/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './attach-policy/index.js';
2
+ export * from './compose-cdk-stack/index.js';
@@ -0,0 +1,7 @@
1
+ export * from './account-id/index.js';
2
+ export * from './app-config/index.js';
3
+ export * from './cdk/index.js';
4
+ export * from './lambda/index.js';
5
+ export * from './region/index.js';
6
+ export * from './s3/index.js';
7
+ export * from './sqs/index.js';
@@ -0,0 +1,7 @@
1
+ export * from './account-id/index.js';
2
+ export * from './app-config/index.js';
3
+ export * from './cdk/index.js';
4
+ export * from './lambda/index.js';
5
+ export * from './region/index.js';
6
+ export * from './s3/index.js';
7
+ export * from './sqs/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './lambda-arn/index.js';
2
+ export * from './lambda-name/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './lambda-arn/index.js';
2
+ export * from './lambda-name/index.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1,2 @@
1
+ import { LambdaName } from '../../lambda-name/index.js';
2
+ export type ComposeLambdaArn = (lambdaName: LambdaName) => string;
@@ -0,0 +1,2 @@
1
+ import { LambdaName } from '../../lambda-name/index.js';
2
+ export declare const composeLambdaArn: (lambdaName: LambdaName) => string;
@@ -0,0 +1,2 @@
1
+ import { LAMBDA_ARN_TEMPLATE } from '../config.js';
2
+ export const composeLambdaArn = (lambdaName) => LAMBDA_ARN_TEMPLATE.replace('<NAME>', lambdaName);
@@ -0,0 +1 @@
1
+ export declare const LAMBDA_ARN_TEMPLATE: string;
@@ -0,0 +1,3 @@
1
+ import { AWS_ACCOUNT_ID } from '../../account-id/index.js';
2
+ import { DEFAULT_AWS_REGION } from '../../region/index.js';
3
+ export const LAMBDA_ARN_TEMPLATE = `arn:aws:sqs:${DEFAULT_AWS_REGION}:${AWS_ACCOUNT_ID}:function:<NAME>`;
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-lambda-arn/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-lambda-arn/index.js';
@@ -0,0 +1 @@
1
+ export declare const LAMBDA_NAMES: readonly ["cache-development", "cache-production", "logger-development", "logger-production"];
@@ -0,0 +1 @@
1
+ export const LAMBDA_NAMES = ['cache-development', 'cache-production', 'logger-development', 'logger-production'];
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { LAMBDA_NAMES } from './config.js';
2
+ export type LambdaName = (typeof LAMBDA_NAMES)[number];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const AWS_REGIONS: readonly ["eu-central-1", "us-east-1"];
@@ -0,0 +1 @@
1
+ export const AWS_REGIONS = ['eu-central-1', 'us-east-1'];
@@ -0,0 +1,2 @@
1
+ import { AwsRegion } from './type.js';
2
+ export declare const DEFAULT_AWS_REGION: AwsRegion;
@@ -0,0 +1 @@
1
+ export const DEFAULT_AWS_REGION = 'eu-central-1';
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './default.js';
3
+ export * from './type.js';
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './default.js';
3
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { AWS_REGIONS } from './config.js';
2
+ export type AwsRegion = (typeof AWS_REGIONS)[number];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './s3-arn/index.js';
@@ -0,0 +1 @@
1
+ export * from './s3-arn/index.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export type ComposeS3Arn = (bucketName: string) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ComposeS3Arn } from './type.js';
2
+ export declare const composeS3Arn: ComposeS3Arn;
@@ -0,0 +1,2 @@
1
+ import { S3_ARN_TEMPLATE } from '../config.js';
2
+ export const composeS3Arn = (bucketName) => S3_ARN_TEMPLATE.replace('<NAME>', bucketName);
@@ -0,0 +1 @@
1
+ export declare const S3_ARN_TEMPLATE = "arn:aws:s3:::<NAME>/*";
@@ -0,0 +1 @@
1
+ export const S3_ARN_TEMPLATE = `arn:aws:s3:::<NAME>/*`;
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-s3-arn/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-s3-arn/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './queue-arn/index.js';
2
+ export * from './queue-name/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './queue-arn/index.js';
2
+ export * from './queue-name/index.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1 @@
1
+ export * from './util.js';
@@ -0,0 +1,2 @@
1
+ import { QueueName } from '../../queue-name/index.js';
2
+ export type ComposeQueueArn = (queueName: QueueName) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ComposeQueueArn } from './type.js';
2
+ export declare const composeQueueArn: ComposeQueueArn;
@@ -0,0 +1,2 @@
1
+ import { QUEUE_ARN_TEMPLATE } from '../config.js';
2
+ export const composeQueueArn = (queueName) => QUEUE_ARN_TEMPLATE.replace('<NAME>', queueName);
@@ -0,0 +1 @@
1
+ export declare const QUEUE_ARN_TEMPLATE: string;
@@ -0,0 +1,3 @@
1
+ import { AWS_ACCOUNT_ID } from '../../account-id/index.js';
2
+ import { DEFAULT_AWS_REGION } from '../../region/index.js';
3
+ export const QUEUE_ARN_TEMPLATE = `arn:aws:sqs:${DEFAULT_AWS_REGION}:${AWS_ACCOUNT_ID}:<NAME>`;
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-queue-arn/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './compose-queue-arn/index.js';
@@ -0,0 +1 @@
1
+ export declare const CACHE_QUEUE_NAMES: readonly ["cache-development", "cache-production"];
@@ -0,0 +1 @@
1
+ export const CACHE_QUEUE_NAMES = ['cache-development', 'cache-production'];
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { CACHE_QUEUE_NAMES } from './config.js';
2
+ export type CacheQueueName = (typeof CACHE_QUEUE_NAMES)[number];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './cache/index.js';
2
+ export * from './logger/index.js';
3
+ export * from './queue-name/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './cache/index.js';
2
+ export * from './logger/index.js';
3
+ export * from './queue-name/index.js';
@@ -0,0 +1 @@
1
+ export declare const LOGGER_QUEUE_NAMES: readonly ["logger-development", "logger-production"];
@@ -0,0 +1 @@
1
+ export const LOGGER_QUEUE_NAMES = ['logger-development', 'logger-production'];
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { LOGGER_QUEUE_NAMES } from './config.js';
2
+ export type LoggerQueueName = (typeof LOGGER_QUEUE_NAMES)[number];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const QUEUE_NAMES: ("cache-development" | "cache-production" | "logger-development" | "logger-production")[];
@@ -0,0 +1,3 @@
1
+ import { CACHE_QUEUE_NAMES } from '../cache/index.js';
2
+ import { LOGGER_QUEUE_NAMES } from '../logger/index.js';
3
+ export const QUEUE_NAMES = [...LOGGER_QUEUE_NAMES, ...CACHE_QUEUE_NAMES];
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { QUEUE_NAMES } from './config.js';
2
+ export type QueueName = (typeof QUEUE_NAMES)[number];