@eqxjs/nest-common 0.1.0
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/CHANGELOG +17 -0
- package/README.md +21 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/enums.d.ts +12 -0
- package/dist/enums.js +17 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/result.d.ts +106 -0
- package/dist/result.js +19 -0
- package/dist/result.js.map +1 -0
- package/package.json +102 -0
package/CHANGELOG
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2025-07-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### 🚀 Features
|
|
9
|
+
|
|
10
|
+
* add CHANGELOG file ([42de96e](https://github.com/corp-ais/cronus-eqxjs-common-library-common/commit/42de96ee400ae523ac39199ac4be796fbc591df9))
|
|
11
|
+
* add result, enums, and constants implementation ([015447c](https://github.com/corp-ais/cronus-eqxjs-common-library-common/commit/015447cb4f764f5df9ea32163afcacd8e12c8b04))
|
|
12
|
+
* **setup:** initialize project ([0fbfaed](https://github.com/corp-ais/cronus-eqxjs-common-library-common/commit/0fbfaed58c91170da63973f9e1c27b3c1b0eba0d))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 🧼 Code Refactoring
|
|
16
|
+
|
|
17
|
+
* cleanup code and its documentation ([00d6dee](https://github.com/corp-ais/cronus-eqxjs-common-library-common/commit/00d6dee5a4d8103e67247fbf1889ecd0b3941099))
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# cronus-eqxjs-common-library-nest-common
|
|
2
|
+
|
|
3
|
+
A common library use in `@eqxjs` ecosystem.
|
|
4
|
+
|
|
5
|
+
Node: `>=22`
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
yarn add @eqxjs/nest-common
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
Please see [contributing.md](CONTRIBUTING.md)
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Please see [LICENSE](LICENSE)
|
|
20
|
+
|
|
21
|
+
## Remark
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HEADER_X_SESSION_ID = "X-Session-Id";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,cAAc,CAAC"}
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enum representing different environment keys.
|
|
3
|
+
* These keys are used to identify the environment in which the application is running.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum EnvironmentKey {
|
|
6
|
+
DEV = "dev",
|
|
7
|
+
PROD = "prod",
|
|
8
|
+
PRD = "prd",
|
|
9
|
+
SIT = "sit",
|
|
10
|
+
UAT = "uat",
|
|
11
|
+
STG = "stg"
|
|
12
|
+
}
|
package/dist/enums.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvironmentKey = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An enum representing different environment keys.
|
|
6
|
+
* These keys are used to identify the environment in which the application is running.
|
|
7
|
+
*/
|
|
8
|
+
var EnvironmentKey;
|
|
9
|
+
(function (EnvironmentKey) {
|
|
10
|
+
EnvironmentKey["DEV"] = "dev";
|
|
11
|
+
EnvironmentKey["PROD"] = "prod";
|
|
12
|
+
EnvironmentKey["PRD"] = "prd";
|
|
13
|
+
EnvironmentKey["SIT"] = "sit";
|
|
14
|
+
EnvironmentKey["UAT"] = "uat";
|
|
15
|
+
EnvironmentKey["STG"] = "stg";
|
|
16
|
+
})(EnvironmentKey || (exports.EnvironmentKey = EnvironmentKey = {}));
|
|
17
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,6BAAW,CAAA;IACX,6BAAW,CAAA;IACX,6BAAW,CAAA;AACb,CAAC,EAPW,cAAc,8BAAd,cAAc,QAOzB"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enums"), exports);
|
|
18
|
+
__exportStar(require("./result"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,8CAA4B"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enum defines various error types that can occur in operations.
|
|
3
|
+
* It is used to categorize errors based on their nature and context.
|
|
4
|
+
* This enum is used in the ReturnResult type to provide detailed error information.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ResultErrorType {
|
|
7
|
+
Failure = "failure",
|
|
8
|
+
Unexpected = "unexpected",
|
|
9
|
+
Validation = "validation",
|
|
10
|
+
Conflict = "conflict",
|
|
11
|
+
NotFound = "not_found",
|
|
12
|
+
Unauthorized = "unauthorized",
|
|
13
|
+
Forbidden = "forbidden"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An interface defines the structure of a return result.
|
|
17
|
+
* It is a base interface that indicates whether the operation was successful or resulted in an error.
|
|
18
|
+
*/
|
|
19
|
+
interface IReturnResult {
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether the operation resulted in an error.
|
|
22
|
+
* If true, the operation failed and an error object will be present.
|
|
23
|
+
* If false, the operation was successful and data will be present.
|
|
24
|
+
*/
|
|
25
|
+
isError: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* An interface defines the structure of an error return result.
|
|
29
|
+
* It includes the type of error, a description, and optional details about the error.
|
|
30
|
+
* This interface is used to provide detailed information about errors that occur during operations.
|
|
31
|
+
*
|
|
32
|
+
* @template T - Optional type for additional error details, defaulting to an empty object.
|
|
33
|
+
*/
|
|
34
|
+
export interface IResultError<T = Record<string, unknown>> {
|
|
35
|
+
/**
|
|
36
|
+
* type indicates the type of error that occurred.
|
|
37
|
+
* It is a value from the {@link ResultErrorType} enum, providing context about the nature of the error.
|
|
38
|
+
*/
|
|
39
|
+
type: ResultErrorType;
|
|
40
|
+
/**
|
|
41
|
+
* Description provides a human-readable explanation of the error.
|
|
42
|
+
* It is a string that describes what went wrong during the operation.
|
|
43
|
+
*/
|
|
44
|
+
description: string;
|
|
45
|
+
/**
|
|
46
|
+
* Details provides additional information about the error.
|
|
47
|
+
* It is an optional field that can include any relevant data that helps to understand the error better.
|
|
48
|
+
* This can be useful for debugging or logging purposes.
|
|
49
|
+
*
|
|
50
|
+
* @template T - The type of additional error details, defaulting to an Record<string, unknown> object.
|
|
51
|
+
*/
|
|
52
|
+
details?: T;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A type defines the structure of a successful return result.
|
|
56
|
+
* It extends IReturnResult and includes the data returned from the operation.
|
|
57
|
+
* It indicates that the operation was successful and contains the result data.
|
|
58
|
+
*
|
|
59
|
+
* @template T - The type of data returned from the operation.
|
|
60
|
+
*/
|
|
61
|
+
export type SuccessReturnResult<T> = IReturnResult & {
|
|
62
|
+
/**
|
|
63
|
+
* Indicates that the operation was successful and no error occurred.
|
|
64
|
+
* This field is always false for a SuccessReturnResult.
|
|
65
|
+
*/
|
|
66
|
+
isError: false;
|
|
67
|
+
/**
|
|
68
|
+
* The data returned from the operation.
|
|
69
|
+
* This field contains the result of the successful operation.
|
|
70
|
+
*
|
|
71
|
+
* @template T - The type of data returned, which can be any type.
|
|
72
|
+
*/
|
|
73
|
+
data: T;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* A type defines the structure of an error return result.
|
|
77
|
+
* It extends IReturnResult and includes an error object that conforms to IErrorReturnResult.
|
|
78
|
+
* It indicates that the operation resulted in an error and provides details about the error.
|
|
79
|
+
*
|
|
80
|
+
* @template TErrorDetails - The type of additional error details, defaulting to an empty object.
|
|
81
|
+
* @template TError - The type of error returned, extending IResultError.
|
|
82
|
+
*/
|
|
83
|
+
export type ErrorReturnResult<TErrorDetails = Record<string, unknown>, TError extends IResultError<TErrorDetails> = IResultError<TErrorDetails>> = IReturnResult & {
|
|
84
|
+
/**
|
|
85
|
+
* Indicates that the operation resulted in an error.
|
|
86
|
+
* This field is always true for an ErrorReturnResult.
|
|
87
|
+
*/
|
|
88
|
+
isError: true;
|
|
89
|
+
/**
|
|
90
|
+
* The error object that contains details about the error that occurred.
|
|
91
|
+
* This field provides information about the type of error, a description, and optional details.
|
|
92
|
+
*
|
|
93
|
+
* @template TError - The type of error returned, which extends IResultError.
|
|
94
|
+
*/
|
|
95
|
+
error: TError;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* An union type defines the structure of a return result that can either be a success or an error.
|
|
99
|
+
* It is a union type that can be either a SuccessReturnResult or an ErrorReturnResult
|
|
100
|
+
* and is used to represent the outcome of operations in a consistent manner.
|
|
101
|
+
*
|
|
102
|
+
* @template T - The type of data returned from the operation, defaulting to unknown.
|
|
103
|
+
* @template TError - The type of error returned, defaulting to an object with unknown properties.
|
|
104
|
+
*/
|
|
105
|
+
export type ReturnResult<T = unknown, TError = Record<string, unknown>> = SuccessReturnResult<T> | ErrorReturnResult<TError>;
|
|
106
|
+
export {};
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResultErrorType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An enum defines various error types that can occur in operations.
|
|
6
|
+
* It is used to categorize errors based on their nature and context.
|
|
7
|
+
* This enum is used in the ReturnResult type to provide detailed error information.
|
|
8
|
+
*/
|
|
9
|
+
var ResultErrorType;
|
|
10
|
+
(function (ResultErrorType) {
|
|
11
|
+
ResultErrorType["Failure"] = "failure";
|
|
12
|
+
ResultErrorType["Unexpected"] = "unexpected";
|
|
13
|
+
ResultErrorType["Validation"] = "validation";
|
|
14
|
+
ResultErrorType["Conflict"] = "conflict";
|
|
15
|
+
ResultErrorType["NotFound"] = "not_found";
|
|
16
|
+
ResultErrorType["Unauthorized"] = "unauthorized";
|
|
17
|
+
ResultErrorType["Forbidden"] = "forbidden";
|
|
18
|
+
})(ResultErrorType || (exports.ResultErrorType = ResultErrorType = {}));
|
|
19
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,4CAAyB,CAAA;IACzB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,yCAAsB,CAAA;IACtB,gDAA6B,CAAA;IAC7B,0CAAuB,CAAA;AACzB,CAAC,EARW,eAAe,+BAAf,eAAe,QAQ1B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eqxjs/nest-common",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Common library for eqxjs provides shared constants, enums, and utilities.",
|
|
5
|
+
"author": "ESBM Cronus",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"private": false,
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prebuild": "yarn run clean",
|
|
12
|
+
"format": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
13
|
+
"format:fix": "prettier --write --list-different \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
14
|
+
"prepare": "husky && yarn run prepare:commit-msg && yarn run prepare:pre-commit && yarn run prepare:prepare-commit-msg",
|
|
15
|
+
"prepare:commit-msg": "echo 'npx --no -- commitlint --edit $1' > .husky/commit-msg",
|
|
16
|
+
"prepare:pre-commit": "rm -f .husky/pre-commit && yarn run prepare:pre-commit:format-fix && yarn run prepare:pre-commit:lint && yarn run prepare:pre-commit:lint-staged",
|
|
17
|
+
"prepare:pre-commit:format-fix": "echo 'yarn run format:fix' >> .husky/pre-commit",
|
|
18
|
+
"prepare:pre-commit:lint": "echo 'yarn run lint' >> .husky/pre-commit",
|
|
19
|
+
"prepare:pre-commit:lint-staged": "echo 'yarn run lint-staged --concurrent false' >> .husky/pre-commit",
|
|
20
|
+
"prepare:prepare-commit-msg": "echo '#!/bin/sh\n\nscripts/prepare-commit-msg.sh \"$1\" \"$2\"' > .husky/prepare-commit-msg && chmod +x .husky/prepare-commit-msg",
|
|
21
|
+
"build": "tsc -b tsconfig.build.json -v",
|
|
22
|
+
"clean": "tsc -b tsconfig.build.json --clean",
|
|
23
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
24
|
+
"lint-staged": "lint-staged",
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"test:watch": "jest --watch",
|
|
27
|
+
"test:cov": "jest --coverage",
|
|
28
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
29
|
+
"release": "standard-version --infile CHANGELOG",
|
|
30
|
+
"release:changelog": "standard-version --infile CHANGELOG --skip.tag --skip.commit",
|
|
31
|
+
"release:init": "standard-version --first-release --infile CHANGELOG",
|
|
32
|
+
"release:init:changelog": "standard-version --first-release --infile CHANGELOG --skip.tag --skip.commit"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"reflect-metadata": "^0.2.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@commitlint/cli": "^19.8.1",
|
|
42
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
43
|
+
"@commitlint/types": "^19.5.0",
|
|
44
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
45
|
+
"@eslint/js": "^9.18.0",
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
47
|
+
"@types/node": "^22",
|
|
48
|
+
"@types/supertest": "^6.0.2",
|
|
49
|
+
"commitizen": "^4.3.1",
|
|
50
|
+
"conventional-changelog-atom": "^5.0.0",
|
|
51
|
+
"conventional-changelog-cli": "^5.0.0",
|
|
52
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
53
|
+
"eslint": "^9.18.0",
|
|
54
|
+
"eslint-config-prettier": "^10.0.1",
|
|
55
|
+
"eslint-plugin-jest": "~29.0.1",
|
|
56
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
57
|
+
"globals": "^16.0.0",
|
|
58
|
+
"husky": "^9.1.7",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"jest-mock-extended": "^3",
|
|
61
|
+
"lint-staged": "~16.1.2",
|
|
62
|
+
"prettier": "^3.4.2",
|
|
63
|
+
"source-map-support": "^0.5.21",
|
|
64
|
+
"standard-version": "^9.5.0",
|
|
65
|
+
"supertest": "^7.0.0",
|
|
66
|
+
"ts-jest": "^29.2.5",
|
|
67
|
+
"ts-loader": "^9.5.2",
|
|
68
|
+
"ts-node": "^10.9.2",
|
|
69
|
+
"tsconfig-paths": "^4.2.0",
|
|
70
|
+
"typescript": "^5.7.3",
|
|
71
|
+
"typescript-eslint": "^8.20.0"
|
|
72
|
+
},
|
|
73
|
+
"jest": {
|
|
74
|
+
"moduleFileExtensions": [
|
|
75
|
+
"js",
|
|
76
|
+
"json",
|
|
77
|
+
"ts"
|
|
78
|
+
],
|
|
79
|
+
"moduleNameMapper": {
|
|
80
|
+
"@/(.*)": "<rootDir>/src/$1"
|
|
81
|
+
},
|
|
82
|
+
"rootDir": ".",
|
|
83
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
84
|
+
"transform": {
|
|
85
|
+
"^.+\\.(t|j)s$": [
|
|
86
|
+
"ts-jest",
|
|
87
|
+
{
|
|
88
|
+
"tsconfig": "tsconfig.json"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"collectCoverageFrom": [
|
|
93
|
+
"src/**/*.(t|j)s"
|
|
94
|
+
],
|
|
95
|
+
"coverageDirectory": "../coverage",
|
|
96
|
+
"testEnvironment": "node",
|
|
97
|
+
"testPathIgnorePatterns": [
|
|
98
|
+
"/node_modules/",
|
|
99
|
+
"/dist/"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
}
|