@taskora-uni/common 1.1.1 → 1.3.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/dist/env/index.d.ts +2 -0
- package/dist/env/index.js +18 -0
- package/dist/env/types/env-source.type.d.ts +1 -0
- package/dist/env/types/env-source.type.js +2 -0
- package/dist/env/types/index.d.ts +1 -0
- package/dist/env/types/index.js +17 -0
- package/dist/env/utils/create-env-config.util.d.ts +3 -0
- package/dist/env/utils/create-env-config.util.js +8 -0
- package/dist/env/utils/index.d.ts +2 -0
- package/dist/env/utils/index.js +18 -0
- package/dist/env/utils/validate-env.util.d.ts +3 -0
- package/dist/env/utils/validate-env.util.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/auth-token-payload.type.d.ts +9 -0
- package/dist/types/auth-token-payload.type.js +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +17 -0
- package/package.json +5 -1
|
@@ -0,0 +1,18 @@
|
|
|
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("./types"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EnvSource = Record<string, string | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./env-source.type";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./env-source.type"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEnvConfig = void 0;
|
|
4
|
+
const validate_env_util_1 = require("./validate-env.util");
|
|
5
|
+
const createEnvConfig = (env, envClass, map) => {
|
|
6
|
+
return map((0, validate_env_util_1.validateEnv)(env, envClass));
|
|
7
|
+
};
|
|
8
|
+
exports.createEnvConfig = createEnvConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./create-env-config.util"), exports);
|
|
18
|
+
__exportStar(require("./validate-env.util"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateEnv = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const validateEnv = (env, envVariablesClass) => {
|
|
7
|
+
const validatedEnv = (0, class_transformer_1.plainToClass)(envVariablesClass, env, {
|
|
8
|
+
enableImplicitConversion: true,
|
|
9
|
+
});
|
|
10
|
+
const errors = (0, class_validator_1.validateSync)(validatedEnv, {
|
|
11
|
+
skipMissingProperties: false,
|
|
12
|
+
});
|
|
13
|
+
if (errors.length > 0) {
|
|
14
|
+
const errorMessage = errors
|
|
15
|
+
.map(error => {
|
|
16
|
+
const constraints = error.constraints
|
|
17
|
+
? Object.entries(error.constraints).map(([key, value]) => `+ ${key}: ${value}`)
|
|
18
|
+
: ["+ Validation failed"];
|
|
19
|
+
return `\nError in ${error.property}:\n${constraints.join("\n")}`;
|
|
20
|
+
})
|
|
21
|
+
.join("\n");
|
|
22
|
+
throw new Error(errorMessage);
|
|
23
|
+
}
|
|
24
|
+
return validatedEnv;
|
|
25
|
+
};
|
|
26
|
+
exports.validateEnv = validateEnv;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./enums"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./env"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth-token-payload.type";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./auth-token-payload.type"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskora-uni/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shared common modules for Taskora Uni backend services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"class-transformer": "^0.5.1",
|
|
17
|
+
"class-validator": "^0.15.1"
|
|
18
|
+
},
|
|
15
19
|
"devDependencies": {
|
|
16
20
|
"@taskora-uni/core": "latest",
|
|
17
21
|
"@types/node": "^25.5.0",
|