@taskora-uni/common 1.3.0 → 2.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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "./enums";
2
2
  export * from "./utils";
3
3
  export * from "./types";
4
- export * from "./env";
package/dist/index.js CHANGED
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enums"), exports);
18
18
  __exportStar(require("./utils"), exports);
19
19
  __exportStar(require("./types"), exports);
20
- __exportStar(require("./env"), exports);
@@ -0,0 +1 @@
1
+ export declare const sha256: (value: string) => string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sha256 = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const sha256 = (value) => (0, crypto_1.createHash)("sha256").update(value).digest("hex");
6
+ exports.sha256 = sha256;
@@ -1 +1,2 @@
1
1
  export * from "./timestamp.util";
2
+ export * from "./hash.util";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./timestamp.util"), exports);
18
+ __exportStar(require("./hash.util"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskora-uni/common",
3
- "version": "1.3.0",
3
+ "version": "2.1.0",
4
4
  "description": "Shared common modules for Taskora Uni backend services",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * from "./utils";
package/dist/env/index.js DELETED
@@ -1,18 +0,0 @@
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);
@@ -1 +0,0 @@
1
- export type EnvSource = Record<string, string | undefined>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export * from "./env-source.type";
@@ -1,17 +0,0 @@
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);
@@ -1,3 +0,0 @@
1
- import { ClassConstructor } from "class-transformer";
2
- import { EnvSource } from "../types";
3
- export declare const createEnvConfig: <TSchema extends object, TConfig>(env: EnvSource, envClass: ClassConstructor<TSchema>, map: (validatedEnv: TSchema) => TConfig) => TConfig;
@@ -1,8 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- export * from "./create-env-config.util";
2
- export * from "./validate-env.util";
@@ -1,18 +0,0 @@
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);
@@ -1,3 +0,0 @@
1
- import { ClassConstructor } from "class-transformer";
2
- import { EnvSource } from "../types";
3
- export declare const validateEnv: <T extends object>(env: EnvSource, envVariablesClass: ClassConstructor<T>) => T;
@@ -1,26 +0,0 @@
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;