@candlerip/shared 0.0.4 → 0.0.17
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/devops/docker/publish-to-docker-hub.sh +5 -0
- package/devops/environment/create-env-file.sh +11 -15
- package/devops/eslint/eslint.base.config.js +26 -0
- package/devops/eslint/eslint.sh +4 -4
- package/devops/npm/publish-to-npm-registry.sh +11 -0
- package/devops/prettier/{config.js → prettier.base.config.js} +1 -1
- package/devops/prettier/prettier.sh +4 -4
- package/devops/typescript/tsc-build.sh +1 -1
- package/devops/typescript/tsc-watch.sh +1 -1
- package/devops/typescript/tsconfig.base.json +1 -2
- package/package.json +11 -25
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/service/index.d.ts +1 -0
- package/src/service/index.js +1 -0
- package/src/service/service-name/constants.d.ts +1 -0
- package/src/service/service-name/constants.js +1 -0
- package/src/service/service-name/domains.d.ts +2 -0
- package/src/service/service-name/index.d.ts +2 -0
- package/src/service/service-name/index.js +2 -0
- package/devops/npm/publish-to-npm.sh +0 -10
- package/devops/publish-package.sh +0 -12
- package/dist/backend/environment/env-file/index.d.ts +0 -1
- package/dist/backend/environment/env-file/index.js +0 -1
- package/dist/backend/environment/env-file/utils/index.d.ts +0 -1
- package/dist/backend/environment/env-file/utils/index.js +0 -1
- package/dist/backend/environment/env-file/utils/load-env-file/index.d.ts +0 -2
- package/dist/backend/environment/env-file/utils/load-env-file/index.js +0 -47
- package/dist/backend/environment/env-file/utils/load-env-file/type.d.ts +0 -4
- package/dist/backend/environment/env-file/utils/load-env-file/type.js +0 -1
- package/dist/backend/environment/index.d.ts +0 -1
- package/dist/backend/environment/index.js +0 -1
- package/dist/common/environment/environment-mode/configs.d.ts +0 -1
- package/dist/common/environment/environment-mode/configs.js +0 -1
- package/dist/common/environment/environment-mode/domains.d.ts +0 -2
- package/dist/common/environment/environment-mode/index.d.ts +0 -3
- package/dist/common/environment/environment-mode/index.js +0 -3
- package/dist/common/environment/environment-mode/type-guards/index.d.ts +0 -3
- package/dist/common/environment/environment-mode/type-guards/index.js +0 -3
- package/dist/common/environment/environment-mode/type-guards/is-development.d.ts +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-development.js +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-environment-mode.d.ts +0 -2
- package/dist/common/environment/environment-mode/type-guards/is-environment-mode.js +0 -2
- package/dist/common/environment/environment-mode/type-guards/is-production.d.ts +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-production.js +0 -1
- package/dist/common/environment/environment-variables/domains.d.ts +0 -18
- package/dist/common/environment/environment-variables/domains.js +0 -1
- package/dist/common/environment/environment-variables/index.d.ts +0 -2
- package/dist/common/environment/environment-variables/index.js +0 -2
- package/dist/common/environment/environment-variables/singletons/index.d.ts +0 -8
- package/dist/common/environment/environment-variables/singletons/index.js +0 -20
- package/dist/common/environment/environment-variables/singletons/type.d.ts +0 -6
- package/dist/common/environment/environment-variables/singletons/type.js +0 -1
- package/dist/common/environment/index.d.ts +0 -2
- package/dist/common/environment/index.js +0 -2
- package/dist/common/error/domains.d.ts +0 -13
- package/dist/common/error/domains.js +0 -1
- package/dist/common/error/index.d.ts +0 -3
- package/dist/common/error/index.js +0 -3
- package/dist/common/error/utils/compose-error/index.d.ts +0 -2
- package/dist/common/error/utils/compose-error/index.js +0 -7
- package/dist/common/error/utils/compose-error/type.d.ts +0 -2
- package/dist/common/error/utils/compose-error/type.js +0 -1
- package/dist/common/error/utils/console-error/index.d.ts +0 -2
- package/dist/common/error/utils/console-error/index.js +0 -12
- package/dist/common/error/utils/console-error/type.d.ts +0 -2
- package/dist/common/error/utils/console-error/type.js +0 -1
- package/dist/common/error/utils/index.d.ts +0 -2
- package/dist/common/error/utils/index.js +0 -2
- package/dist/common/error/workers/index.d.ts +0 -2
- package/dist/common/error/workers/index.js +0 -32
- package/dist/common/error/workers/type.d.ts +0 -19
- package/dist/common/error/workers/type.js +0 -1
- package/dist/common/helpers/index.d.ts +0 -2
- package/dist/common/helpers/index.js +0 -2
- package/dist/common/helpers/reveal-all-object-props/index.d.ts +0 -2
- package/dist/common/helpers/reveal-all-object-props/index.js +0 -13
- package/dist/common/helpers/reveal-all-object-props/type.d.ts +0 -1
- package/dist/common/helpers/reveal-all-object-props/type.js +0 -1
- package/dist/common/helpers/stringify/index.d.ts +0 -2
- package/dist/common/helpers/stringify/index.js +0 -3
- package/dist/common/helpers/stringify/type.d.ts +0 -1
- package/dist/common/helpers/stringify/type.js +0 -1
- package/dist/common/index.d.ts +0 -5
- package/dist/common/index.js +0 -5
- package/dist/common/service/index.d.ts +0 -1
- package/dist/common/service/index.js +0 -1
- package/dist/common/service/singletons/index.d.ts +0 -5
- package/dist/common/service/singletons/index.js +0 -11
- package/dist/common/service/singletons/type.d.ts +0 -2
- package/dist/common/service/singletons/type.js +0 -1
- package/dist/common/type/array/index.d.ts +0 -1
- package/dist/common/type/array/index.js +0 -1
- package/dist/common/type/array/type-guards.d.ts +0 -1
- package/dist/common/type/array/type-guards.js +0 -9
- package/dist/common/type/index.d.ts +0 -3
- package/dist/common/type/index.js +0 -3
- package/dist/common/type/null/index.d.ts +0 -1
- package/dist/common/type/null/index.js +0 -1
- package/dist/common/type/null/type-guards.d.ts +0 -1
- package/dist/common/type/null/type-guards.js +0 -1
- package/dist/common/type/object/index.d.ts +0 -1
- package/dist/common/type/object/index.js +0 -1
- package/dist/common/type/object/type-guards.d.ts +0 -1
- package/dist/common/type/object/type-guards.js +0 -11
- package/dist/devops/eslint/configs.d.ts +0 -2
- package/dist/devops/eslint/configs.js +0 -8
- package/dist/devops/eslint/index.d.ts +0 -2
- package/dist/devops/eslint/index.js +0 -2
- package/dist/devops/eslint/utils/compose-eslint-config/index.d.ts +0 -2
- package/dist/devops/eslint/utils/compose-eslint-config/index.js +0 -20
- package/dist/devops/eslint/utils/compose-eslint-config/type.d.ts +0 -4
- package/dist/devops/eslint/utils/compose-eslint-config/type.js +0 -1
- package/dist/devops/eslint/utils/index.d.ts +0 -1
- package/dist/devops/eslint/utils/index.js +0 -1
- package/dist/devops/index.d.ts +0 -1
- package/dist/devops/index.js +0 -1
- package/src/backend/environment/env-file/index.ts +0 -1
- package/src/backend/environment/env-file/utils/index.ts +0 -1
- package/src/backend/environment/env-file/utils/load-env-file/index.ts +0 -53
- package/src/backend/environment/env-file/utils/load-env-file/type.ts +0 -5
- package/src/backend/environment/index.ts +0 -1
- package/src/common/environment/environment-mode/configs.ts +0 -1
- package/src/common/environment/environment-mode/domains.ts +0 -3
- package/src/common/environment/environment-mode/index.ts +0 -5
- package/src/common/environment/environment-mode/type-guards/index.ts +0 -5
- package/src/common/environment/environment-mode/type-guards/is-development.ts +0 -1
- package/src/common/environment/environment-mode/type-guards/is-environment-mode.ts +0 -4
- package/src/common/environment/environment-mode/type-guards/is-production.ts +0 -1
- package/src/common/environment/environment-variables/domains.ts +0 -19
- package/src/common/environment/environment-variables/index.ts +0 -3
- package/src/common/environment/environment-variables/singletons/index.ts +0 -29
- package/src/common/environment/environment-variables/singletons/type.ts +0 -11
- package/src/common/environment/index.ts +0 -3
- package/src/common/error/domains.ts +0 -8
- package/src/common/error/index.ts +0 -5
- package/src/common/error/utils/compose-error/index.ts +0 -9
- package/src/common/error/utils/compose-error/type.ts +0 -3
- package/src/common/error/utils/console-error/index.ts +0 -18
- package/src/common/error/utils/console-error/type.ts +0 -3
- package/src/common/error/utils/index.ts +0 -3
- package/src/common/error/workers/index.ts +0 -41
- package/src/common/error/workers/type.ts +0 -21
- package/src/common/helpers/index.ts +0 -3
- package/src/common/helpers/reveal-all-object-props/index.ts +0 -16
- package/src/common/helpers/reveal-all-object-props/type.ts +0 -1
- package/src/common/helpers/stringify/index.ts +0 -5
- package/src/common/helpers/stringify/type.ts +0 -1
- package/src/common/index.ts +0 -9
- package/src/common/service/index.ts +0 -1
- package/src/common/service/singletons/index.ts +0 -16
- package/src/common/service/singletons/type.ts +0 -3
- package/src/common/type/array/index.ts +0 -1
- package/src/common/type/array/type-guards.ts +0 -11
- package/src/common/type/index.ts +0 -5
- package/src/common/type/null/index.ts +0 -1
- package/src/common/type/null/type-guards.ts +0 -1
- package/src/common/type/object/index.ts +0 -1
- package/src/common/type/object/type-guards.ts +0 -12
- package/src/devops/eslint/configs.ts +0 -10
- package/src/devops/eslint/index.ts +0 -3
- package/src/devops/eslint/utils/compose-eslint-config/index.ts +0 -29
- package/src/devops/eslint/utils/compose-eslint-config/type.ts +0 -3
- package/src/devops/eslint/utils/index.ts +0 -1
- package/src/devops/index.ts +0 -1
- /package/{dist/common/environment/environment-mode → src/service/service-name}/domains.js +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../type/index.js';
|
|
2
|
-
export const revealAllObjectProps = (obj) => {
|
|
3
|
-
const newObj = {};
|
|
4
|
-
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
5
|
-
if (isObject(obj[key])) {
|
|
6
|
-
newObj[key] = revealAllObjectProps(obj[key]);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
newObj[key] = obj[key];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return newObj;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type RevealAllObjectProps = (obj: Record<string, unknown>) => Record<string, unknown>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Stringify = (obj: unknown) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/common/index.d.ts
DELETED
package/dist/common/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './singletons/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './singletons/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isArray: <T>(data?: unknown, typeGuard?: (data?: unknown) => data is T) => data is T[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isNull: (data?: unknown) => data is null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isNull = (data) => data === null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isObject: (data?: unknown) => data is Record<string, unknown>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import { defineConfig } from 'eslint/config';
|
|
3
|
-
import tseslint from 'typescript-eslint';
|
|
4
|
-
import * as globals from 'globals';
|
|
5
|
-
import { ESLINT_RULES } from '../../configs.js';
|
|
6
|
-
export const composeEslintConfig = (props = {}) => {
|
|
7
|
-
const { ignores = [] } = props;
|
|
8
|
-
return defineConfig(eslint.configs.recommended, ...tseslint.configs.recommended, {
|
|
9
|
-
ignores,
|
|
10
|
-
}, {
|
|
11
|
-
languageOptions: {
|
|
12
|
-
globals: {
|
|
13
|
-
...globals.browser,
|
|
14
|
-
...globals.node,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
}, {
|
|
18
|
-
rules: ESLINT_RULES,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './compose-eslint-config/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './compose-eslint-config/index.js';
|
package/dist/devops/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './eslint/index.js';
|
package/dist/devops/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './eslint/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './utils';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './load-env-file';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { ErrorWorker } from '../../../../../common';
|
|
3
|
-
import { LoadEnvFile } from './type';
|
|
4
|
-
|
|
5
|
-
export const loadEnvFile: LoadEnvFile = (environmentMode) => {
|
|
6
|
-
const { composeError } = ErrorWorker({ info: { environmentMode } });
|
|
7
|
-
|
|
8
|
-
let fileName = '.env';
|
|
9
|
-
if (environmentMode) {
|
|
10
|
-
fileName += `.${environmentMode}`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const parsed = {} as Record<string, string>;
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const file = fs.readFileSync(fileName, 'utf-8');
|
|
17
|
-
file.split('\n').forEach((fileLine) => {
|
|
18
|
-
if (fileLine.length === 0) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const envVar = fileLine.split('=');
|
|
22
|
-
parsed[`${envVar[0]}`] = envVar[1];
|
|
23
|
-
});
|
|
24
|
-
} catch (err) {
|
|
25
|
-
return {
|
|
26
|
-
error: composeError(`Error loading ${fileName}`, {
|
|
27
|
-
info: {
|
|
28
|
-
err,
|
|
29
|
-
fileName,
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
const data = {} as any;
|
|
37
|
-
|
|
38
|
-
(Object.keys(parsed) as Array<keyof typeof parsed>).forEach((key) => {
|
|
39
|
-
const parsedItem = parsed[key];
|
|
40
|
-
|
|
41
|
-
if (['false', 'true'].includes(parsedItem)) {
|
|
42
|
-
data[key] = Boolean(parsedItem === 'true');
|
|
43
|
-
} else if (!Number.isNaN(parseInt(parsedItem))) {
|
|
44
|
-
data[key] = parseInt(parsedItem);
|
|
45
|
-
} else {
|
|
46
|
-
data[key] = parsedItem;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
data,
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './env-file';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const ENVIRONMENT_MODES = ['development', 'production'] as const;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isDevelopment = (data?: unknown): data is 'development' => data === 'development';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isProduction = (data?: unknown): data is 'production' => data === 'production';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EnvironmentMode } from '../environment-mode';
|
|
2
|
-
|
|
3
|
-
export type EnvironmentVariables = {
|
|
4
|
-
APP_NAME: string;
|
|
5
|
-
AWS_REGION: string;
|
|
6
|
-
AWS_S3_IMAGES_BUCKET_NAME: string;
|
|
7
|
-
CACHE_SERVICE_PORT: string;
|
|
8
|
-
CACHE_ENABLED: boolean;
|
|
9
|
-
DATABASE_URL: string;
|
|
10
|
-
DOMAIN_NAME: string;
|
|
11
|
-
FRONTEND_URL: string;
|
|
12
|
-
LOGGER_SERVICE_PORT: string;
|
|
13
|
-
MOBILE_APP_URL: string;
|
|
14
|
-
NODE_ENV: EnvironmentMode;
|
|
15
|
-
RABBITMQ_URL: string;
|
|
16
|
-
REDIS_PWD: string;
|
|
17
|
-
REDIS_URL: string;
|
|
18
|
-
REDIS_URL_APP: string;
|
|
19
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { isDevelopment as isDev, isProduction as isProd } from '../../environment-mode';
|
|
2
|
-
import { EnvironmentVariables } from '../domains';
|
|
3
|
-
import { GetEnv, GetEnvs, Init, IsDevelopment, IsProduction } from './type';
|
|
4
|
-
|
|
5
|
-
export const EnvironmentVariablesSingleton = (() => {
|
|
6
|
-
let _envs: Partial<EnvironmentVariables>;
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
const getEnv: GetEnv = (name) => _envs[name] as any;
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
const getEnvs: GetEnvs = (names) => names.reduce((acc, curr) => ({ ...acc, [`${curr}`]: _envs[curr] }), {}) as any;
|
|
13
|
-
|
|
14
|
-
const init: Init = (envs) => {
|
|
15
|
-
_envs = envs;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const isDevelopment: IsDevelopment = () => isDev(_envs.NODE_ENV);
|
|
19
|
-
|
|
20
|
-
const isProduction: IsProduction = () => isProd(_envs.NODE_ENV);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
getEnv,
|
|
24
|
-
getEnvs,
|
|
25
|
-
init,
|
|
26
|
-
isDevelopment,
|
|
27
|
-
isProduction,
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EnvironmentVariables } from '../domains';
|
|
2
|
-
|
|
3
|
-
export type GetEnv = <T extends keyof EnvironmentVariables = never>(name: T) => EnvironmentVariables[T];
|
|
4
|
-
|
|
5
|
-
export type GetEnvs = <T extends keyof EnvironmentVariables = never>(names: T[]) => Pick<EnvironmentVariables, T>;
|
|
6
|
-
|
|
7
|
-
export type Init = (envs: Partial<EnvironmentVariables>) => void;
|
|
8
|
-
|
|
9
|
-
export type IsDevelopment = () => boolean;
|
|
10
|
-
|
|
11
|
-
export type IsProduction = () => boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ServiceSingleton } from '../../../service';
|
|
2
|
-
import { ComposeError } from './type';
|
|
3
|
-
|
|
4
|
-
export const composeError: ComposeError = (message, info) => ({
|
|
5
|
-
id: Math.random().toString(16).slice(2).toUpperCase(),
|
|
6
|
-
info,
|
|
7
|
-
message: message ?? '',
|
|
8
|
-
serviceName: ServiceSingleton.getServiceName(),
|
|
9
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { stringify } from '../../../helpers';
|
|
2
|
-
import { ConsoleError } from './type';
|
|
3
|
-
|
|
4
|
-
export const consoleError: ConsoleError = (error) => {
|
|
5
|
-
const { id, info, message, serviceName } = error;
|
|
6
|
-
|
|
7
|
-
let msg = `ERROR: ${message} (ID) ${id}`;
|
|
8
|
-
|
|
9
|
-
if (serviceName) {
|
|
10
|
-
msg += ` (SERVICE-NAME) ${serviceName}`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (info) {
|
|
14
|
-
msg += ` (INFO) ${stringify(info)}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.error(msg);
|
|
18
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { _ComposeInfo, ErrorWorkerType, GetError, ResetError, AddErrorInfo, AddErrorMessage, ComposeError } from './type';
|
|
2
|
-
import { composeError as composeErrorFunc } from '../utils';
|
|
3
|
-
|
|
4
|
-
export const ErrorWorker: ErrorWorkerType = (props) => {
|
|
5
|
-
let _error = props ? composeErrorFunc(props.message, props.info) : undefined;
|
|
6
|
-
|
|
7
|
-
const _composeInfo: _ComposeInfo = (info) => {
|
|
8
|
-
if (_error) {
|
|
9
|
-
_error.info = {
|
|
10
|
-
..._error.info,
|
|
11
|
-
...info,
|
|
12
|
-
};
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
_error = composeErrorFunc(undefined, info);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const addErrorInfo: AddErrorInfo = (info) => {
|
|
19
|
-
_composeInfo(info);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const addErrorMessage: AddErrorMessage = (message) => {
|
|
23
|
-
_error = composeErrorFunc(message);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const composeError: ComposeError = (message, info) => composeErrorFunc(message, info ?? _error?.info);
|
|
27
|
-
|
|
28
|
-
const getError: GetError = () => (_error ? { error: _error } : undefined);
|
|
29
|
-
|
|
30
|
-
const resetError: ResetError = () => {
|
|
31
|
-
_error = undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
addErrorInfo,
|
|
36
|
-
addErrorMessage,
|
|
37
|
-
composeError,
|
|
38
|
-
getError,
|
|
39
|
-
resetError,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Error } from '../domains';
|
|
2
|
-
|
|
3
|
-
export type ErrorWorkerType = (props?: { message?: string; info?: Record<string, unknown> }) => {
|
|
4
|
-
addErrorInfo: AddErrorInfo;
|
|
5
|
-
addErrorMessage: AddErrorMessage;
|
|
6
|
-
composeError: ComposeError;
|
|
7
|
-
getError: GetError;
|
|
8
|
-
resetError: ResetError;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type _ComposeInfo = (info?: Record<string, unknown>) => void;
|
|
12
|
-
|
|
13
|
-
export type AddErrorInfo = (info: Record<string, unknown>) => void;
|
|
14
|
-
|
|
15
|
-
export type AddErrorMessage = (message: string) => void;
|
|
16
|
-
|
|
17
|
-
export type ComposeError = (message: string, info?: Record<string, unknown>) => Error;
|
|
18
|
-
|
|
19
|
-
export type GetError = () => { error: Error } | undefined;
|
|
20
|
-
|
|
21
|
-
export type ResetError = () => void;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../type';
|
|
2
|
-
import { RevealAllObjectProps } from './type';
|
|
3
|
-
|
|
4
|
-
export const revealAllObjectProps: RevealAllObjectProps = (obj) => {
|
|
5
|
-
const newObj = {} as Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
8
|
-
if (isObject(obj[key])) {
|
|
9
|
-
newObj[key] = revealAllObjectProps(obj[key]);
|
|
10
|
-
} else {
|
|
11
|
-
newObj[key] = obj[key];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return newObj;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type RevealAllObjectProps = (obj: Record<string, unknown>) => Record<string, unknown>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Stringify = (obj: unknown) => string;
|
package/src/common/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './singletons';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { GetServiceName, Init } from './type';
|
|
2
|
-
|
|
3
|
-
export const ServiceSingleton = (() => {
|
|
4
|
-
let _serviceName: string;
|
|
5
|
-
|
|
6
|
-
const getServiceName: GetServiceName = () => _serviceName;
|
|
7
|
-
|
|
8
|
-
const init: Init = (serviceName) => {
|
|
9
|
-
_serviceName = serviceName;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
getServiceName,
|
|
14
|
-
init,
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards';
|
package/src/common/type/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-guards';
|