@candlerip/shared 0.0.47 → 0.0.59

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 (133) hide show
  1. package/package.json +7 -17
  2. package/src/common/custom-error/domains.d.ts +14 -0
  3. package/src/common/custom-error/utils/compose-custom-error/index.d.ts +2 -0
  4. package/src/{error/utils/compose-error → common/custom-error/utils/compose-custom-error}/index.js +1 -1
  5. package/src/common/custom-error/utils/compose-custom-error/type.d.ts +2 -0
  6. package/src/common/custom-error/utils/console-custom-error/index.d.ts +2 -0
  7. package/src/{error/utils/console-error → common/custom-error/utils/console-custom-error}/index.js +1 -1
  8. package/src/common/custom-error/utils/console-custom-error/type.d.ts +2 -0
  9. package/src/common/custom-error/utils/index.d.ts +2 -0
  10. package/src/common/custom-error/utils/index.js +2 -0
  11. package/src/common/custom-error/workers/index.d.ts +2 -0
  12. package/src/common/custom-error/workers/index.js +32 -0
  13. package/src/common/custom-error/workers/type.d.ts +19 -0
  14. package/src/{environment → common/environment}/environment-variable-name/constants.d.ts +1 -1
  15. package/src/{environment → common/environment}/environment-variable-name/constants.js +0 -1
  16. package/src/{environment → common/environment}/environment-variables/domains.d.ts +0 -1
  17. package/src/{environment → common/environment}/index.d.ts +0 -1
  18. package/src/{environment → common/environment}/index.js +0 -1
  19. package/src/{index.d.ts → common/index.d.ts} +1 -1
  20. package/src/{index.js → common/index.js} +1 -1
  21. package/src/common/service/index.d.ts +1 -0
  22. package/src/common/service/index.js +1 -0
  23. package/src/{service → common/service}/service-name/constants.d.ts +1 -1
  24. package/src/common/service/service-name/constants.js +1 -0
  25. package/devops/cdk/cdk-deploy.sh +0 -4
  26. package/devops/docker/publish-to-docker-hub.sh +0 -7
  27. package/devops/environment/create-env-file.sh +0 -25
  28. package/devops/eslint/eslint.base.config.js +0 -26
  29. package/devops/eslint/eslint.sh +0 -4
  30. package/devops/npm/publish-to-npm-registry.sh +0 -15
  31. package/devops/prettier/prettier.base.config.js +0 -7
  32. package/devops/prettier/prettier.sh +0 -4
  33. package/devops/typescript/tsc-build.sh +0 -6
  34. package/devops/typescript/tsc-watch.sh +0 -5
  35. package/devops/typescript/tsconfig.base.json +0 -17
  36. package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.d.ts +0 -2
  37. package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.js +0 -8
  38. package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.d.ts +0 -2
  39. package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.js +0 -1
  40. package/src/devops/env-file/create-env-file/index.d.ts +0 -2
  41. package/src/devops/env-file/create-env-file/index.js +0 -42
  42. package/src/devops/env-file/create-env-file/types.d.ts +0 -6
  43. package/src/devops/env-file/create-env-file/types.js +0 -1
  44. package/src/devops/env-file/create-env-file/validate-parameters/index.d.ts +0 -2
  45. package/src/devops/env-file/create-env-file/validate-parameters/index.js +0 -56
  46. package/src/devops/env-file/create-env-file/validate-parameters/types.d.ts +0 -8
  47. package/src/devops/env-file/create-env-file/validate-parameters/types.js +0 -1
  48. package/src/devops/env-file/index.d.ts +0 -1
  49. package/src/devops/env-file/index.js +0 -1
  50. package/src/devops/index.d.ts +0 -1
  51. package/src/devops/index.js +0 -1
  52. package/src/error/domains.d.ts +0 -14
  53. package/src/error/utils/compose-error/index.d.ts +0 -2
  54. package/src/error/utils/compose-error/type.d.ts +0 -2
  55. package/src/error/utils/console-error/index.d.ts +0 -2
  56. package/src/error/utils/console-error/type.d.ts +0 -2
  57. package/src/error/utils/index.d.ts +0 -2
  58. package/src/error/utils/index.js +0 -2
  59. package/src/error/workers/index.d.ts +0 -2
  60. package/src/error/workers/index.js +0 -32
  61. package/src/error/workers/type.d.ts +0 -19
  62. package/src/service/index.d.ts +0 -2
  63. package/src/service/index.js +0 -2
  64. package/src/service/service-environment-variable-names/constants.d.ts +0 -2
  65. package/src/service/service-environment-variable-names/constants.js +0 -17
  66. package/src/service/service-environment-variable-names/index.d.ts +0 -1
  67. package/src/service/service-environment-variable-names/index.js +0 -1
  68. package/src/service/service-environment-variable-names/type.d.ts +0 -5
  69. package/src/service/service-environment-variable-names/type.js +0 -1
  70. package/src/service/service-name/constants.js +0 -1
  71. /package/src/{environment/environment-mode → common/custom-error}/domains.js +0 -0
  72. /package/src/{error → common/custom-error}/index.d.ts +0 -0
  73. /package/src/{error → common/custom-error}/index.js +0 -0
  74. /package/src/{error/utils/compose-error → common/custom-error/utils/compose-custom-error}/type.js +0 -0
  75. /package/src/{error/utils/console-error → common/custom-error/utils/console-custom-error}/type.js +0 -0
  76. /package/src/{error → common/custom-error}/workers/type.js +0 -0
  77. /package/src/{environment → common/environment}/environment-mode/constants.d.ts +0 -0
  78. /package/src/{environment → common/environment}/environment-mode/constants.js +0 -0
  79. /package/src/{environment → common/environment}/environment-mode/domains.d.ts +0 -0
  80. /package/src/{environment/environment-variable-name → common/environment/environment-mode}/domains.js +0 -0
  81. /package/src/{environment → common/environment}/environment-mode/index.d.ts +0 -0
  82. /package/src/{environment → common/environment}/environment-mode/index.js +0 -0
  83. /package/src/{environment → common/environment}/environment-mode/type-guards/index.d.ts +0 -0
  84. /package/src/{environment → common/environment}/environment-mode/type-guards/index.js +0 -0
  85. /package/src/{environment → common/environment}/environment-mode/type-guards/is-development.d.ts +0 -0
  86. /package/src/{environment → common/environment}/environment-mode/type-guards/is-development.js +0 -0
  87. /package/src/{environment → common/environment}/environment-mode/type-guards/is-environment-mode.d.ts +0 -0
  88. /package/src/{environment → common/environment}/environment-mode/type-guards/is-environment-mode.js +0 -0
  89. /package/src/{environment → common/environment}/environment-mode/type-guards/is-production.d.ts +0 -0
  90. /package/src/{environment → common/environment}/environment-mode/type-guards/is-production.js +0 -0
  91. /package/src/{environment → common/environment}/environment-variable-name/domains.d.ts +0 -0
  92. /package/src/{environment/environment-variables → common/environment/environment-variable-name}/domains.js +0 -0
  93. /package/src/{environment → common/environment}/environment-variable-name/index.d.ts +0 -0
  94. /package/src/{environment → common/environment}/environment-variable-name/index.js +0 -0
  95. /package/src/{environment → common/environment}/environment-variable-name/type-guards.d.ts +0 -0
  96. /package/src/{environment → common/environment}/environment-variable-name/type-guards.js +0 -0
  97. /package/src/{error → common/environment/environment-variables}/domains.js +0 -0
  98. /package/src/{environment → common/environment}/environment-variables/index.d.ts +0 -0
  99. /package/src/{environment → common/environment}/environment-variables/index.js +0 -0
  100. /package/src/{helpers → common/helpers}/index.d.ts +0 -0
  101. /package/src/{helpers → common/helpers}/index.js +0 -0
  102. /package/src/{helpers → common/helpers}/reveal-all-object-props/index.d.ts +0 -0
  103. /package/src/{helpers → common/helpers}/reveal-all-object-props/index.js +0 -0
  104. /package/src/{helpers → common/helpers}/reveal-all-object-props/type.d.ts +0 -0
  105. /package/src/{helpers → common/helpers}/reveal-all-object-props/type.js +0 -0
  106. /package/src/{helpers → common/helpers}/stringify/index.d.ts +0 -0
  107. /package/src/{helpers → common/helpers}/stringify/index.js +0 -0
  108. /package/src/{helpers → common/helpers}/stringify/type.d.ts +0 -0
  109. /package/src/{helpers → common/helpers}/stringify/type.js +0 -0
  110. /package/src/{service → common/service}/service-name/domains.d.ts +0 -0
  111. /package/src/{service → common/service}/service-name/domains.js +0 -0
  112. /package/src/{service → common/service}/service-name/index.d.ts +0 -0
  113. /package/src/{service → common/service}/service-name/index.js +0 -0
  114. /package/src/{service → common/service}/service-name/type-guards.d.ts +0 -0
  115. /package/src/{service → common/service}/service-name/type-guards.js +0 -0
  116. /package/src/{type → common/type}/array/index.d.ts +0 -0
  117. /package/src/{type → common/type}/array/index.js +0 -0
  118. /package/src/{type → common/type}/array/type-guards.d.ts +0 -0
  119. /package/src/{type → common/type}/array/type-guards.js +0 -0
  120. /package/src/{type → common/type}/index.d.ts +0 -0
  121. /package/src/{type → common/type}/index.js +0 -0
  122. /package/src/{type → common/type}/null/index.d.ts +0 -0
  123. /package/src/{type → common/type}/null/index.js +0 -0
  124. /package/src/{type → common/type}/null/type-guards.d.ts +0 -0
  125. /package/src/{type → common/type}/null/type-guards.js +0 -0
  126. /package/src/{type → common/type}/object/index.d.ts +0 -0
  127. /package/src/{type → common/type}/object/index.js +0 -0
  128. /package/src/{type → common/type}/object/type-guards.d.ts +0 -0
  129. /package/src/{type → common/type}/object/type-guards.js +0 -0
  130. /package/src/{type → common/type}/string/index.d.ts +0 -0
  131. /package/src/{type → common/type}/string/index.js +0 -0
  132. /package/src/{type → common/type}/string/type-guards.d.ts +0 -0
  133. /package/src/{type → common/type}/string/type-guards.js +0 -0
package/package.json CHANGED
@@ -1,36 +1,26 @@
1
1
  {
2
2
  "name": "@candlerip/shared",
3
- "version": "0.0.47",
3
+ "version": "0.0.59",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "=22.19.0"
7
7
  },
8
- "main": "src/index.js",
9
- "bin": {
10
- "crs-cdk-deploy": "devops/cdk/cdk-deploy.sh",
11
- "crs-create-env-file": "src/devops/env-file/create-env-file/index.js",
12
- "crs-publish-to-docker-hub": "./devops/docker/publish-to-docker-hub.sh",
13
- "crs-eslint": "devops/eslint/eslint.sh",
14
- "crs-publish-to-npm-registry": "devops/npm/publish-to-npm-registry.sh",
15
- "crs-prettier": "devops/prettier/prettier.sh",
16
- "crs-tsc-build": "devops/typescript/tsc-build.sh",
17
- "crs-tsc-watch": "devops/typescript/tsc-watch.sh"
8
+ "exports": {
9
+ "./common": "./dist/common/index.js"
18
10
  },
19
11
  "scripts": {
20
- "dev": "sh ./devops/typescript/tsc-watch.sh"
12
+ "dev": "crs-tsc-watch"
21
13
  },
22
14
  "dependencies": {
23
- "@aws-sdk/client-ssm": "^3.917.0",
24
15
  "eslint": "^9.28.0",
25
- "globals": "^16.2.0",
26
16
  "prettier": "^3.5.3",
27
17
  "tsc-alias": "^1.8.16",
28
18
  "typescript": "^5.8.3",
29
- "typescript-eslint": "^8.33.1",
30
- "yargs": "^18.0.0"
19
+ "typescript-eslint": "^8.33.1"
31
20
  },
32
21
  "devDependencies": {
22
+ "@candlerip/shared-devops": "^0.0.50",
33
23
  "@types/node": "^24.9.1",
34
- "@types/yargs": "^17.0.34"
24
+ "globals": "^16.4.0"
35
25
  }
36
26
  }
@@ -0,0 +1,14 @@
1
+ export interface CustomError {
2
+ id: string;
3
+ info?: CustomErrorInfo;
4
+ message: CustomErrorMessage;
5
+ }
6
+ export type CustomErrorInfo = Record<string, unknown>;
7
+ export type CustomErrorMessage = string;
8
+ export type TCustomError<T = never> = {
9
+ data: T;
10
+ error?: never;
11
+ } | {
12
+ error: CustomError;
13
+ data?: never;
14
+ };
@@ -0,0 +1,2 @@
1
+ import { ComposeCustomError } from './type.js';
2
+ export declare const composeCustomError: ComposeCustomError;
@@ -1,4 +1,4 @@
1
- export const composeError = (message, info) => ({
1
+ export const composeCustomError = (message, info) => ({
2
2
  id: Math.random().toString(16).slice(2).toUpperCase(),
3
3
  info,
4
4
  message: message ?? '',
@@ -0,0 +1,2 @@
1
+ import { CustomError, CustomErrorInfo, CustomErrorMessage } from '../../domains.js';
2
+ export type ComposeCustomError = (message?: CustomErrorMessage, info?: CustomErrorInfo) => CustomError;
@@ -0,0 +1,2 @@
1
+ import { ConsoleCustomError } from './type.js';
2
+ export declare const consoleCustomError: ConsoleCustomError;
@@ -1,5 +1,5 @@
1
1
  import { stringify } from '../../../helpers/index.js';
2
- export const consoleError = (error) => {
2
+ export const consoleCustomError = (error) => {
3
3
  const { id, info, message } = error;
4
4
  let msg = `ERROR: ${message} (ID) ${id}`;
5
5
  if (info) {
@@ -0,0 +1,2 @@
1
+ import { CustomError } from '../../domains.js';
2
+ export type ConsoleCustomError = (error: CustomError) => void;
@@ -0,0 +1,2 @@
1
+ export * from './compose-custom-error/index.js';
2
+ export * from './console-custom-error/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-custom-error/index.js';
2
+ export * from './console-custom-error/index.js';
@@ -0,0 +1,2 @@
1
+ import { CustomErrorWorkerType } from './type.js';
2
+ export declare const CustomErrorWorker: CustomErrorWorkerType;
@@ -0,0 +1,32 @@
1
+ import { composeCustomError as composeCustomErrorFunc } from '../utils/index.js';
2
+ export const CustomErrorWorker = (props) => {
3
+ let _error = props ? composeCustomErrorFunc(props.message, props.info) : undefined;
4
+ const _composeInfo = (info) => {
5
+ if (_error) {
6
+ _error.info = {
7
+ ..._error.info,
8
+ ...info,
9
+ };
10
+ return;
11
+ }
12
+ _error = composeCustomErrorFunc(undefined, info);
13
+ };
14
+ const addCustomErrorInfo = (info) => {
15
+ _composeInfo(info);
16
+ };
17
+ const addCustomErrorMessage = (message) => {
18
+ _error = composeCustomErrorFunc(message);
19
+ };
20
+ const composeCustomError = (message, info) => composeCustomErrorFunc(message, info ?? _error?.info);
21
+ const getCustomError = () => (_error ? { error: _error } : undefined);
22
+ const resetCustomError = () => {
23
+ _error = undefined;
24
+ };
25
+ return {
26
+ addCustomErrorInfo,
27
+ addCustomErrorMessage,
28
+ composeCustomError,
29
+ getCustomError,
30
+ resetCustomError,
31
+ };
32
+ };
@@ -0,0 +1,19 @@
1
+ import { CustomError, CustomErrorInfo, CustomErrorMessage } from '../domains.js';
2
+ export type CustomErrorWorkerType = (props?: {
3
+ message?: CustomErrorMessage;
4
+ info?: CustomErrorInfo;
5
+ }) => {
6
+ addCustomErrorInfo: AddCustomErrorInfo;
7
+ addCustomErrorMessage: AddCustomErrorMessage;
8
+ composeCustomError: ComposeCustomError;
9
+ getCustomError: GetCustomError;
10
+ resetCustomError: ResetCustomError;
11
+ };
12
+ export type _ComposeInfo = (info?: CustomErrorInfo) => void;
13
+ export type AddCustomErrorInfo = (info: CustomErrorInfo) => void;
14
+ export type AddCustomErrorMessage = (message: CustomErrorMessage) => void;
15
+ export type ComposeCustomError = (message: CustomErrorMessage, info?: CustomErrorInfo) => CustomError;
16
+ export type GetCustomError = () => {
17
+ error: CustomError;
18
+ } | undefined;
19
+ export type ResetCustomError = () => void;
@@ -1,2 +1,2 @@
1
- export declare const ENVIRONMENT_VARIABLE_NAMES: readonly ["APP_NAME", "APP_PORT", "AWS_REGION", "AWS_S3_IMAGES_BUCKET_NAME", "CACHE_SERVICE_PORT", "DATABASE_URL", "DOMAIN_NAME", "FRONTEND_URL", "LOGGER_SERVICE_PORT", "MOBILE_APP_URL", "NODE_ENV", "RABBITMQ_MANAGEMENT_PORT", "RABBITMQ_PORT", "RABBITMQ_PWD", "RABBITMQ_USER", "RABBITMQ_URL", "REDIS_PORT", "REDIS_PWD", "REDIS_URL", "REDIS_URL_APP", "SSL_PRIVATE_KEY"];
1
+ export declare const ENVIRONMENT_VARIABLE_NAMES: readonly ["APP_NAME", "APP_PORT", "AWS_REGION", "AWS_S3_IMAGES_BUCKET_NAME", "CACHE_SERVICE_PORT", "DATABASE_URL", "DOMAIN_NAME", "FRONTEND_URL", "MOBILE_APP_URL", "NODE_ENV", "RABBITMQ_MANAGEMENT_PORT", "RABBITMQ_PORT", "RABBITMQ_PWD", "RABBITMQ_USER", "RABBITMQ_URL", "REDIS_PORT", "REDIS_PWD", "REDIS_URL", "REDIS_URL_APP", "SSL_PRIVATE_KEY"];
2
2
  export declare const MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES: readonly ["DATABASE_URL"];
@@ -7,7 +7,6 @@ export const ENVIRONMENT_VARIABLE_NAMES = [
7
7
  'DATABASE_URL',
8
8
  'DOMAIN_NAME',
9
9
  'FRONTEND_URL',
10
- 'LOGGER_SERVICE_PORT',
11
10
  'MOBILE_APP_URL',
12
11
  'NODE_ENV',
13
12
  'RABBITMQ_MANAGEMENT_PORT',
@@ -8,7 +8,6 @@ export type EnvironmentVariables = {
8
8
  DATABASE_URL: string;
9
9
  DOMAIN_NAME: string;
10
10
  FRONTEND_URL: string;
11
- LOGGER_SERVICE_PORT: number;
12
11
  MOBILE_APP_URL: string;
13
12
  NODE_ENV: EnvironmentMode;
14
13
  RABBITMQ_MANAGEMENT_PORT: number;
@@ -1,3 +1,2 @@
1
- export * from './environment-mode/index.js';
2
1
  export * from './environment-variable-name/index.js';
3
2
  export * from './environment-variables/index.js';
@@ -1,3 +1,2 @@
1
- export * from './environment-mode/index.js';
2
1
  export * from './environment-variable-name/index.js';
3
2
  export * from './environment-variables/index.js';
@@ -1,5 +1,5 @@
1
1
  export * from './environment/index.js';
2
- export * from './error/index.js';
2
+ export * from './custom-error/index.js';
3
3
  export * from './helpers/index.js';
4
4
  export * from './service/index.js';
5
5
  export * from './type/index.js';
@@ -1,5 +1,5 @@
1
1
  export * from './environment/index.js';
2
- export * from './error/index.js';
2
+ export * from './custom-error/index.js';
3
3
  export * from './helpers/index.js';
4
4
  export * from './service/index.js';
5
5
  export * from './type/index.js';
@@ -0,0 +1 @@
1
+ export * from './service-name/index.js';
@@ -0,0 +1 @@
1
+ export * from './service-name/index.js';
@@ -1 +1 @@
1
- export declare const SERVICE_NAMES: readonly ["cache-service", "logger-service", "nginx", "rabbitmq", "redis", "server"];
1
+ export declare const SERVICE_NAMES: readonly ["cache-service", "nginx", "redis", "server"];
@@ -0,0 +1 @@
1
+ export const SERVICE_NAMES = ['cache-service', 'nginx', 'redis', 'server'];
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- cdk deploy --require-approval never
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- DOCKERFILE=${2:-"Dockerfile"}
4
-
5
- echo "$DOCKER_ACCESS_TOKEN" | docker login -u $DOCKER_USERNAME --password-stdin
6
- docker build -f $DOCKERFILE -t reveszimre/$1 .
7
- docker push reveszimre/$1
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- PARAM_NAMES=(${1//,/ })
5
-
6
- ENVS=()
7
- for ((i=0; i<${#PARAM_NAMES[@]}; i+=10)); do
8
- chunk=("${PARAM_NAMES[@]:i:10}")
9
-
10
- PARAMS=$(aws ssm get-parameters --names "${chunk[@]}" --output text --query "Parameters[*].{Name:Name,Value:Value}" --with-decryption | sed -E 's/\s+/=/g')
11
-
12
- PARAMS1="${PARAMS[@]//_DEVELOPMENT/}"
13
- PARAMS2="${PARAMS1[@]//_PRODUCTION/}"
14
- PARAMS3="${PARAMS2[@]//AMAZONWEBSERVICES/AWS}"
15
- ENVS+=("$PARAMS3")
16
- done
17
-
18
- if [[ $2 ]]
19
- then
20
- FILENAME=".env.$2"
21
- else
22
- FILENAME=".env"
23
- fi
24
-
25
- printf "%s\n" "${ENVS[@]}" > $FILENAME
@@ -1,26 +0,0 @@
1
- import js from '@eslint/js';
2
- import ts from 'typescript-eslint';
3
- import globals from 'globals';
4
-
5
- export default (projectConfig) =>
6
- ts.config(
7
- js.configs.recommended,
8
- ...ts.configs.recommended,
9
- {
10
- ignores: ['.next', 'cdk.out', 'dist', 'temp'],
11
- },
12
- {
13
- languageOptions: {
14
- globals: {
15
- ...globals.browser,
16
- ...globals.node,
17
- },
18
- },
19
- },
20
- {
21
- rules: {
22
- 'no-console': [2, { allow: ['error', 'info'] }],
23
- },
24
- },
25
- ...(projectConfig ?? []),
26
- );
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- npx eslint .
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- npm config set //registry.npmjs.org/:_authToken $NPM_ACCESS_TOKEN
5
-
6
- ls -al
7
- cat package.json
8
- cat ~/.npmrc
9
-
10
- if [ -d "devops" ]; then
11
- cp -r devops dist
12
- fi
13
- cp package.json dist
14
-
15
- npm publish ./dist --access public
@@ -1,7 +0,0 @@
1
- export default {
2
- semi: true,
3
- printWidth: 150,
4
- singleQuote: true,
5
- tabWidth: 2,
6
- trailingComma: 'all',
7
- };
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- npx prettier . --write
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- rm -rf dist
5
- npx tsc
6
- npx tsc-alias
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -e
3
-
4
- rm -rf dist
5
- npx tsc --watch
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "esModuleInterop": true,
5
- "module": "ES2022",
6
- "moduleResolution": "bundler",
7
- "outDir": "${configDir}/dist",
8
- "rootDir": "${configDir}/src",
9
- "skipLibCheck": true,
10
- "strict": true,
11
- "target": "ES2022"
12
- },
13
- "tsc-alias": {
14
- "verbose": false,
15
- "resolveFullPaths": true
16
- }
17
- }
@@ -1,2 +0,0 @@
1
- import { ConvertEnvironmentVariableNameToSsmParameterName } from './types.js';
2
- export declare const convertEnvironmentVariableNameToSsmParameterName: ConvertEnvironmentVariableNameToSsmParameterName;
@@ -1,8 +0,0 @@
1
- import { MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES } from '../../../../environment/index.js';
2
- export const convertEnvironmentVariableNameToSsmParameterName = (environmentVariableName, environmentMode) => {
3
- let parameterName = environmentVariableName;
4
- if (MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES.includes(environmentVariableName)) {
5
- parameterName = `${environmentVariableName}_${environmentMode?.toUpperCase()}`;
6
- }
7
- return parameterName.replace('AWS', 'AMAZONWEBSERVICES');
8
- };
@@ -1,2 +0,0 @@
1
- import { EnvironmentMode, EnvironmentVariableName } from '../../../../environment/index.js';
2
- export type ConvertEnvironmentVariableNameToSsmParameterName = (environmentVariableName: EnvironmentVariableName, environmentMode?: EnvironmentMode) => string;
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
- import { SERVICE_ENVIRONMENT_VARIABLE_NAMES } from '../../../service/index.js';
3
- import { SSMClient, GetParametersCommand } from '@aws-sdk/client-ssm';
4
- import * as fs from 'fs';
5
- import { isEnvironmentMode } from '../../../environment/index.js';
6
- import { validateParameters } from './validate-parameters/index.js';
7
- import { convertEnvironmentVariableNameToSsmParameterName } from './convert-environment-variable-name-to-ssm-parameter-name/index.js';
8
- const parameters = validateParameters();
9
- if (parameters) {
10
- const { environmentMode, environmentVariableName, fileName, serviceName } = parameters;
11
- const ssmClient = new SSMClient();
12
- let parameterNames = [];
13
- if (environmentVariableName) {
14
- parameterNames = [convertEnvironmentVariableNameToSsmParameterName(environmentVariableName, environmentMode)];
15
- }
16
- else if (serviceName) {
17
- const envNames = SERVICE_ENVIRONMENT_VARIABLE_NAMES[serviceName];
18
- parameterNames = envNames.map((envName) => convertEnvironmentVariableNameToSsmParameterName(envName, environmentMode));
19
- }
20
- const environmentVariables = {};
21
- for (let i = 0; i < parameterNames.length; i += 10) {
22
- const response = await ssmClient.send(new GetParametersCommand({
23
- Names: parameterNames.slice(i, i + 10),
24
- WithDecryption: true,
25
- }));
26
- parameterNames.forEach((parameterName) => {
27
- let envName = parameterName.replace('AMAZONWEBSERVICES', 'AWS');
28
- const parts = envName.split('_');
29
- const lastPart = parts.pop()?.toLowerCase();
30
- if (isEnvironmentMode(lastPart)) {
31
- envName = parts.join('_');
32
- }
33
- const value = response.Parameters?.find((p) => p.Name === parameterName)?.Value;
34
- environmentVariables[envName] = value;
35
- });
36
- fs.writeFileSync(fileName, environmentVariableName
37
- ? Object.values(environmentVariables)[0]
38
- : Object.entries(environmentVariables)
39
- .map(([k, v]) => `${k}=${v}`)
40
- .join('\n'), 'utf8');
41
- }
42
- }
@@ -1,6 +0,0 @@
1
- export type Args = {
2
- 'environment-mode'?: string;
3
- 'environment-variable-name'?: string;
4
- 'file-name'?: string;
5
- 'service-name'?: string;
6
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { ValidateParameters } from './types.js';
2
- export declare const validateParameters: ValidateParameters;
@@ -1,56 +0,0 @@
1
- import { isServiceName } from '../../../../service/index.js';
2
- import yargs from 'yargs';
3
- import { hideBin } from 'yargs/helpers';
4
- import { isString } from '../../../../type/index.js';
5
- import { consoleError, ErrorWorker } from '../../../../error/index.js';
6
- import { isEnvironmentMode, isEnvironmentVariableName } from '../../../../environment/index.js';
7
- export const validateParameters = () => {
8
- const argv = yargs(hideBin(process.argv)).parse();
9
- const environmentModeArg = argv['environment-mode'];
10
- const environmentVariableNameArg = argv['environment-variable-name'];
11
- const serviceNameArg = argv['service-name'];
12
- const fileName = argv['file-name'];
13
- const { composeError } = ErrorWorker({
14
- info: {
15
- args: process.argv,
16
- },
17
- });
18
- if (!isString(fileName)) {
19
- consoleError(composeError('Invalid or missing file-name parameter'));
20
- process.exit(1);
21
- }
22
- let environmentMode;
23
- if (environmentModeArg) {
24
- if (!isEnvironmentMode(environmentModeArg)) {
25
- consoleError(composeError('Invalid environment-mode parameter'));
26
- process.exit(1);
27
- }
28
- environmentMode = environmentModeArg;
29
- }
30
- if (!environmentVariableNameArg && !serviceNameArg) {
31
- consoleError(composeError('Missing environment-variable-name or service-name parameter'));
32
- process.exit(1);
33
- }
34
- let environmentVariableName;
35
- if (environmentVariableNameArg) {
36
- if (!isEnvironmentVariableName(environmentVariableNameArg)) {
37
- consoleError(composeError('Invalid environment-variable-name parameter'));
38
- process.exit(1);
39
- }
40
- environmentVariableName = environmentVariableNameArg;
41
- }
42
- let serviceName;
43
- if (serviceNameArg) {
44
- if (!isServiceName(serviceNameArg)) {
45
- consoleError(composeError('Invalid service-name parameter'));
46
- process.exit(1);
47
- }
48
- serviceName = serviceNameArg;
49
- }
50
- return {
51
- environmentMode,
52
- environmentVariableName,
53
- fileName,
54
- serviceName,
55
- };
56
- };
@@ -1,8 +0,0 @@
1
- import { ServiceName } from '../../../../service/index.js';
2
- import { EnvironmentMode, EnvironmentVariableName } from '../../../../environment/index.js';
3
- export type ValidateParameters = () => {
4
- environmentMode?: EnvironmentMode;
5
- environmentVariableName?: EnvironmentVariableName;
6
- fileName: string;
7
- serviceName?: ServiceName;
8
- } | void;
@@ -1 +0,0 @@
1
- export * from './create-env-file/index.js';
@@ -1 +0,0 @@
1
- export * from './create-env-file/index.js';
@@ -1 +0,0 @@
1
- export * from './env-file/index.js';
@@ -1 +0,0 @@
1
- export * from './env-file/index.js';
@@ -1,14 +0,0 @@
1
- export interface Error {
2
- id: string;
3
- info?: ErrorInfo;
4
- message: ErrorMessage;
5
- }
6
- export type ErrorInfo = Record<string, unknown>;
7
- export type ErrorMessage = string;
8
- export type TError<T = never> = {
9
- data: T;
10
- error?: never;
11
- } | {
12
- error: Error;
13
- data?: never;
14
- };
@@ -1,2 +0,0 @@
1
- import { ComposeError } from './type.js';
2
- export declare const composeError: ComposeError;
@@ -1,2 +0,0 @@
1
- import { Error, ErrorInfo, ErrorMessage } from '../../domains.js';
2
- export type ComposeError = (message?: ErrorMessage, info?: ErrorInfo) => Error;
@@ -1,2 +0,0 @@
1
- import { ConsoleError } from './type.js';
2
- export declare const consoleError: ConsoleError;
@@ -1,2 +0,0 @@
1
- import { Error } from '../../domains.js';
2
- export type ConsoleError = (error: Error) => void;
@@ -1,2 +0,0 @@
1
- export * from './compose-error/index.js';
2
- export * from './console-error/index.js';
@@ -1,2 +0,0 @@
1
- export * from './compose-error/index.js';
2
- export * from './console-error/index.js';
@@ -1,2 +0,0 @@
1
- import { ErrorWorkerType } from './type.js';
2
- export declare const ErrorWorker: ErrorWorkerType;
@@ -1,32 +0,0 @@
1
- import { composeError as composeErrorFunc } from '../utils/index.js';
2
- export const ErrorWorker = (props) => {
3
- let _error = props ? composeErrorFunc(props.message, props.info) : undefined;
4
- const _composeInfo = (info) => {
5
- if (_error) {
6
- _error.info = {
7
- ..._error.info,
8
- ...info,
9
- };
10
- return;
11
- }
12
- _error = composeErrorFunc(undefined, info);
13
- };
14
- const addErrorInfo = (info) => {
15
- _composeInfo(info);
16
- };
17
- const addErrorMessage = (message) => {
18
- _error = composeErrorFunc(message);
19
- };
20
- const composeError = (message, info) => composeErrorFunc(message, info ?? _error?.info);
21
- const getError = () => (_error ? { error: _error } : undefined);
22
- const resetError = () => {
23
- _error = undefined;
24
- };
25
- return {
26
- addErrorInfo,
27
- addErrorMessage,
28
- composeError,
29
- getError,
30
- resetError,
31
- };
32
- };
@@ -1,19 +0,0 @@
1
- import { Error, ErrorInfo, ErrorMessage } from '../domains.js';
2
- export type ErrorWorkerType = (props?: {
3
- message?: ErrorMessage;
4
- info?: ErrorInfo;
5
- }) => {
6
- addErrorInfo: AddErrorInfo;
7
- addErrorMessage: AddErrorMessage;
8
- composeError: ComposeError;
9
- getError: GetError;
10
- resetError: ResetError;
11
- };
12
- export type _ComposeInfo = (info?: ErrorInfo) => void;
13
- export type AddErrorInfo = (info: ErrorInfo) => void;
14
- export type AddErrorMessage = (message: ErrorMessage) => void;
15
- export type ComposeError = (message: ErrorMessage, info?: ErrorInfo) => Error;
16
- export type GetError = () => {
17
- error: Error;
18
- } | undefined;
19
- export type ResetError = () => void;
@@ -1,2 +0,0 @@
1
- export * from './service-environment-variable-names/index.js';
2
- export * from './service-name/index.js';
@@ -1,2 +0,0 @@
1
- export * from './service-environment-variable-names/index.js';
2
- export * from './service-name/index.js';
@@ -1,2 +0,0 @@
1
- import { ServiceEnvironmentVariableNames } from './type.js';
2
- export declare const SERVICE_ENVIRONMENT_VARIABLE_NAMES: ServiceEnvironmentVariableNames;
@@ -1,17 +0,0 @@
1
- export const SERVICE_ENVIRONMENT_VARIABLE_NAMES = {
2
- 'cache-service': ['APP_NAME'],
3
- nginx: ['APP_PORT'],
4
- 'logger-service': ['DATABASE_URL', 'LOGGER_SERVICE_PORT'],
5
- rabbitmq: ['RABBITMQ_MANAGEMENT_PORT', 'RABBITMQ_PORT', 'RABBITMQ_PWD', 'RABBITMQ_USER'],
6
- redis: ['REDIS_PORT', 'REDIS_PWD'],
7
- server: [
8
- 'APP_PORT',
9
- 'CACHE_SERVICE_PORT',
10
- 'LOGGER_SERVICE_PORT',
11
- 'RABBITMQ_MANAGEMENT_PORT',
12
- 'RABBITMQ_PORT',
13
- 'RABBITMQ_PWD',
14
- 'RABBITMQ_USER',
15
- 'REDIS_PORT',
16
- ],
17
- };
@@ -1 +0,0 @@
1
- export * from './constants.js';
@@ -1 +0,0 @@
1
- export * from './constants.js';
@@ -1,5 +0,0 @@
1
- import { EnvironmentVariableName } from '../../environment/index.js';
2
- import { ServiceName } from '../service-name/index.js';
3
- export type ServiceEnvironmentVariableNames = {
4
- [key in ServiceName]: EnvironmentVariableName[];
5
- };
@@ -1 +0,0 @@
1
- export const SERVICE_NAMES = ['cache-service', 'logger-service', 'nginx', 'rabbitmq', 'redis', 'server'];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes