@hg-ts/validation 0.1.49 → 0.1.51
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/.eslintcache +1 -1
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-lint$colon$ts.log +2 -0
- package/.turbo/turbo-test.log +9 -0
- package/dist/dto.d.ts +0 -3
- package/dist/dto.d.ts.map +1 -1
- package/dist/dto.js +2 -32
- package/dist/dto.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/eslint.config.mjs +3 -0
- package/package.json +21 -21
- package/src/dto.ts +1 -34
- package/src/extensions.ts +1 -1
- package/src/index.ts +1 -3
- package/tsconfig.json +1 -1
- package/.eslintrc.json +0 -1
- package/dist/validation.exception.d.ts +0 -11
- package/dist/validation.exception.d.ts.map +0 -1
- package/dist/validation.exception.js +0 -19
- package/dist/validation.exception.js.map +0 -1
- package/dist-esm/async-context.not-found.exception.d.ts +0 -5
- package/dist-esm/async-context.not-found.exception.d.ts.map +0 -1
- package/dist-esm/async-context.not-found.exception.js +0 -7
- package/dist-esm/async-context.not-found.exception.js.map +0 -1
- package/dist-esm/async-context.provider.d.ts +0 -18
- package/dist-esm/async-context.provider.d.ts.map +0 -1
- package/dist-esm/async-context.provider.js +0 -57
- package/dist-esm/async-context.provider.js.map +0 -1
- package/dist-esm/async-context.test-suite.d.ts +0 -16
- package/dist-esm/async-context.test-suite.d.ts.map +0 -1
- package/dist-esm/async-context.test-suite.js +0 -156
- package/dist-esm/async-context.test-suite.js.map +0 -1
- package/dist-esm/dto.d.ts +0 -12
- package/dist-esm/dto.d.ts.map +0 -1
- package/dist-esm/dto.js +0 -39
- package/dist-esm/dto.js.map +0 -1
- package/dist-esm/extensions.d.ts +0 -10
- package/dist-esm/extensions.d.ts.map +0 -1
- package/dist-esm/extensions.js +0 -14
- package/dist-esm/extensions.js.map +0 -1
- package/dist-esm/index.d.ts +0 -7
- package/dist-esm/index.d.ts.map +0 -1
- package/dist-esm/index.js +0 -7
- package/dist-esm/index.js.map +0 -1
- package/dist-esm/validation.exception.d.ts +0 -11
- package/dist-esm/validation.exception.d.ts.map +0 -1
- package/dist-esm/validation.exception.js +0 -15
- package/dist-esm/validation.exception.js.map +0 -1
- package/src/validation.exception.ts +0 -25
- package/tsconfig.esm.json +0 -9
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/
|
|
1
|
+
[{"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/dto.js":"1","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/extensions.js":"2","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/index.js":"3","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/eslint.config.mjs":"4","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/dto.ts":"5","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/extensions.ts":"6","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/index.ts":"7"},{"size":391,"mtime":1746292861209,"results":"8","hashOfConfig":"9"},{"size":679,"mtime":1746292861213,"results":"10","hashOfConfig":"9"},{"size":304,"mtime":1746292861215,"results":"11","hashOfConfig":"9"},{"size":59,"mtime":1736896000120,"results":"12","hashOfConfig":"9"},{"size":595,"mtime":1736876770680,"results":"13","hashOfConfig":"14"},{"size":1328,"mtime":1736893489221,"results":"15","hashOfConfig":"14"},{"size":88,"mtime":1736876770680,"results":"16","hashOfConfig":"14"},{"filePath":"17","messages":"18","suppressedMessages":"19","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1gtnk1i",{"filePath":"20","messages":"21","suppressedMessages":"22","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","suppressedMessages":"25","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"26","messages":"27","suppressedMessages":"28","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"29","messages":"30","suppressedMessages":"31","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"i5df87",{"filePath":"32","messages":"33","suppressedMessages":"34","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"35","messages":"36","suppressedMessages":"37","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/dto.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/extensions.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/eslint.config.mjs",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/dto.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/extensions.ts",[],["38"],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/index.ts",[],[],{"ruleId":"39","severity":2,"message":"40","line":17,"column":12,"nodeType":"41","messageId":"42","endLine":17,"endColumn":21,"fix":"43","suppressions":"44"},"@typescript/consistent-type-definitions","Use a `type` instead of an `interface`.","Identifier","typeOverInterface",{"range":"45","text":"46"},["47"],[276,363],"type ZodSchema<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> = ",{"kind":"48","justification":"49"},"directive",""]
|
package/dist/dto.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
/// <reference types="@hg-ts/types" />
|
|
2
1
|
import { ZodSchema, ZodTypeDef } from 'zod';
|
|
3
2
|
export type ZodDto<TOutput = any> = {
|
|
4
3
|
new (): TOutput;
|
|
5
4
|
isZodDto: true;
|
|
6
5
|
schema: ZodSchema<TOutput, ZodTypeDef, unknown>;
|
|
7
6
|
create(input: unknown): TOutput;
|
|
8
|
-
createAsync(input: unknown): Promise<TOutput>;
|
|
9
7
|
};
|
|
10
8
|
export declare function createZodDto<TOutput = any>(schema: ZodSchema<TOutput, ZodTypeDef, unknown>): ZodDto<TOutput>;
|
|
11
|
-
export declare function isZodDto(ctor: Class<any, any[]>): ctor is ZodDto;
|
|
12
9
|
//# sourceMappingURL=dto.d.ts.map
|
package/dist/dto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,UAAU,EACV,MAAM,KAAK,CAAC;AAEb,MAAM,MAAM,MAAM,CAAC,OAAO,GAAG,GAAG,IAAI;IACnC,QAAQ,OAAO,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CAChC,CAAA;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAG,GAAG,EACzC,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,GAC7C,MAAM,CAAC,OAAO,CAAC,CAWjB"}
|
package/dist/dto.js
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const validation_exception_1 = require("./validation.exception");
|
|
3
|
+
exports.createZodDto = createZodDto;
|
|
6
4
|
function createZodDto(schema) {
|
|
7
5
|
class AugmentedZodDto {
|
|
8
6
|
static isZodDto = true;
|
|
9
7
|
static schema = schema;
|
|
10
8
|
static create(input) {
|
|
11
|
-
|
|
12
|
-
return this.schema.parse(input);
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
if (error instanceof zod_1.ZodError) {
|
|
16
|
-
AugmentedZodDto.formatError(error);
|
|
17
|
-
}
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
static async createAsync(input) {
|
|
22
|
-
try {
|
|
23
|
-
const result = await this.schema.parseAsync(input);
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
if (error instanceof zod_1.ZodError) {
|
|
28
|
-
AugmentedZodDto.formatError(error);
|
|
29
|
-
}
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static formatError(error) {
|
|
34
|
-
throw new validation_exception_1.ValidationException(error);
|
|
9
|
+
return this.schema.parse(input);
|
|
35
10
|
}
|
|
36
11
|
}
|
|
37
12
|
return AugmentedZodDto;
|
|
38
13
|
}
|
|
39
|
-
exports.createZodDto = createZodDto;
|
|
40
|
-
function isZodDto(ctor) {
|
|
41
|
-
return 'isZodDto' in ctor && ctor.isZodDto === true;
|
|
42
|
-
}
|
|
43
|
-
exports.isZodDto = isZodDto;
|
|
44
14
|
//# sourceMappingURL=dto.js.map
|
package/dist/dto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":";;AAYA,oCAaC;AAbD,SAAgB,YAAY,CAC3B,MAA+C;IAE/C,MAAM,eAAe;QACb,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAEvB,MAAM,CAAC,MAAM,CAAC,KAAc;YAClC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAoB,CAAC;QACpD,CAAC;;IAGF,OAAO,eAA6C,CAAC;AACtD,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,cAAc,KAAK,CAAC;AACpB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,eAAe,GAAG,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isZodDto = void 0;
|
|
4
3
|
const tslib_1 = require("tslib");
|
|
5
4
|
require("./extensions");
|
|
6
|
-
const zod_1 = tslib_1.__importDefault(require("zod"));
|
|
7
|
-
var dto_1 = require("./dto");
|
|
8
|
-
Object.defineProperty(exports, "isZodDto", { enumerable: true, get: function () { return dto_1.isZodDto; } });
|
|
9
|
-
tslib_1.__exportStar(require("./validation.exception"), exports);
|
|
10
5
|
tslib_1.__exportStar(require("zod"), exports);
|
|
6
|
+
const zod_1 = tslib_1.__importDefault(require("zod"));
|
|
11
7
|
exports.default = zod_1.default;
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wBAAsB;AACtB,8CAAoB;AACpB,sDAAsB;AAEtB,kBAAe,aAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/validation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js"
|
|
7
|
+
},
|
|
6
8
|
"repository": "git@gitlab.com:hyper-graph/framework.git",
|
|
7
9
|
"scripts": {
|
|
8
|
-
"prepack": "yarn build && yarn lint",
|
|
9
|
-
"build": "
|
|
10
|
-
"build:dev": "
|
|
11
|
-
"lint": "
|
|
12
|
-
"lint:fix": "
|
|
10
|
+
"prepack": "yarn build && yarn lint:ts",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"build:dev": "tsc-watch",
|
|
13
|
+
"lint:ts": "lint-ts",
|
|
14
|
+
"lint:ts:fix": "lint-ts --fix",
|
|
15
|
+
"test": "node --test",
|
|
16
|
+
"test:dev": "yarn build:dev --onSuccess \"yarn test\""
|
|
13
17
|
},
|
|
14
18
|
"devDependencies": {
|
|
15
|
-
"@hg-ts-config/
|
|
16
|
-
"@hg-ts
|
|
17
|
-
"@hg-ts/
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"tsc-watch": "6.0.4",
|
|
25
|
-
"tslib": "2.6.2",
|
|
26
|
-
"typescript": "5.2.2"
|
|
19
|
+
"@hg-ts-config/typescript": "0.1.51",
|
|
20
|
+
"@hg-ts/linter": "0.1.51",
|
|
21
|
+
"@hg-ts/types": "0.1.51",
|
|
22
|
+
"@types/node": "22.10.6",
|
|
23
|
+
"eslint": "9.18.0",
|
|
24
|
+
"reflect-metadata": "0.2.2",
|
|
25
|
+
"tsc-watch": "6.3.0",
|
|
26
|
+
"tslib": "2.8.1",
|
|
27
|
+
"typescript": "5.7.3"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"reflect-metadata": "*",
|
|
30
31
|
"tslib": "*"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"zod": "3.22.5"
|
|
34
|
+
"zod": "3.24.1"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/dto.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ZodError,
|
|
3
2
|
ZodSchema,
|
|
4
3
|
ZodTypeDef,
|
|
5
4
|
} from 'zod';
|
|
6
|
-
import { ValidationException } from './validation.exception';
|
|
7
5
|
|
|
8
6
|
export type ZodDto<TOutput = any> = {
|
|
9
7
|
new (): TOutput;
|
|
10
8
|
isZodDto: true;
|
|
11
9
|
schema: ZodSchema<TOutput, ZodTypeDef, unknown>;
|
|
12
10
|
create(input: unknown): TOutput;
|
|
13
|
-
createAsync(input: unknown): Promise<TOutput>;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
export function createZodDto<TOutput = any>(
|
|
@@ -21,39 +18,9 @@ export function createZodDto<TOutput = any>(
|
|
|
21
18
|
public static schema = schema;
|
|
22
19
|
|
|
23
20
|
public static create(input: unknown): AugmentedZodDto {
|
|
24
|
-
|
|
25
|
-
return this.schema.parse(input) as AugmentedZodDto;
|
|
26
|
-
} catch (error: unknown) {
|
|
27
|
-
if (error instanceof ZodError) {
|
|
28
|
-
AugmentedZodDto.formatError(error);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public static async createAsync(input: unknown): Promise<AugmentedZodDto> {
|
|
36
|
-
try {
|
|
37
|
-
const result = await this.schema.parseAsync(input);
|
|
38
|
-
|
|
39
|
-
return result as AugmentedZodDto;
|
|
40
|
-
} catch (error: unknown) {
|
|
41
|
-
if (error instanceof ZodError) {
|
|
42
|
-
AugmentedZodDto.formatError(error);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
protected static formatError(error: ZodError): never {
|
|
50
|
-
throw new ValidationException(error);
|
|
21
|
+
return this.schema.parse(input) as AugmentedZodDto;
|
|
51
22
|
}
|
|
52
23
|
}
|
|
53
24
|
|
|
54
25
|
return AugmentedZodDto as unknown as ZodDto<TOutput>;
|
|
55
26
|
}
|
|
56
|
-
|
|
57
|
-
export function isZodDto(ctor: Class<any, any[]>): ctor is ZodDto {
|
|
58
|
-
return 'isZodDto' in ctor && ctor.isZodDto === true;
|
|
59
|
-
}
|
package/src/extensions.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from './dto';
|
|
14
14
|
|
|
15
15
|
declare module 'zod' {
|
|
16
|
-
// eslint-disable-next-line @typescript
|
|
16
|
+
// eslint-disable-next-line @typescript/consistent-type-definitions
|
|
17
17
|
interface ZodSchema<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
|
|
18
18
|
enforceEnv<T extends ZodSchema<Output, Def, Input>>(this: T, name: string): ZodEffects<T, ZodInfer<T> | string>;
|
|
19
19
|
transformBooleanString<T extends ZodSchema<Output, Def, Input>>(
|
package/src/index.ts
CHANGED
package/tsconfig.json
CHANGED
package/.eslintrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "extends": "@hg-ts-config/eslint-config" }
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseException, JSONBaseException } from '@hg-ts/exception';
|
|
2
|
-
import { ZodError, ZodIssue } from 'zod';
|
|
3
|
-
export type JSONValidationException = JSONBaseException & {
|
|
4
|
-
errors: ZodIssue[];
|
|
5
|
-
};
|
|
6
|
-
export declare class ValidationException extends BaseException {
|
|
7
|
-
errors: ZodIssue[];
|
|
8
|
-
constructor(error: ZodError);
|
|
9
|
-
toJSON(): JSONValidationException;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=validation.exception.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.exception.d.ts","sourceRoot":"","sources":["../src/validation.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEzC,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG;IACzD,MAAM,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAA;AAED,qBAAa,mBAAoB,SAAQ,aAAa;IAC9C,MAAM,EAAE,QAAQ,EAAE,CAAC;gBACP,KAAK,EAAE,QAAQ;IAMlB,MAAM,IAAI,uBAAuB;CAMjD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationException = void 0;
|
|
4
|
-
const exception_1 = require("@hg-ts/exception");
|
|
5
|
-
class ValidationException extends exception_1.BaseException {
|
|
6
|
-
errors;
|
|
7
|
-
constructor(error) {
|
|
8
|
-
super('Validation failed');
|
|
9
|
-
this.errors = error.issues;
|
|
10
|
-
}
|
|
11
|
-
toJSON() {
|
|
12
|
-
return {
|
|
13
|
-
...super.toJSON(),
|
|
14
|
-
errors: this.errors,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ValidationException = ValidationException;
|
|
19
|
-
//# sourceMappingURL=validation.exception.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.exception.js","sourceRoot":"","sources":["../src/validation.exception.ts"],"names":[],"mappings":";;;AAAA,gDAG0B;AAO1B,MAAa,mBAAoB,SAAQ,yBAAa;IAC9C,MAAM,CAAa;IAC1B,YAAmB,KAAe;QACjC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEe,MAAM;QACrB,OAAO;YACN,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC;IACH,CAAC;CACD;AAdD,kDAcC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-context.not-found.exception.d.ts","sourceRoot":"","sources":["../src/async-context.not-found.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,6BAA8B,SAAQ,aAAa;;CAI/D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-context.not-found.exception.js","sourceRoot":"","sources":["../src/async-context.not-found.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,OAAO,6BAA8B,SAAQ,aAAa;IAC/D;QACC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACrC,CAAC;CACD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="@hg-ts/types" />
|
|
3
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
-
import { MonoTypeOperatorFunction } from 'rxjs';
|
|
5
|
-
type AsyncContextProviderCallback<T> = () => T;
|
|
6
|
-
type AsyncContextFactory<InputType, Context> = (input: InputType) => Context;
|
|
7
|
-
export declare class AsyncContextProvider<Context> {
|
|
8
|
-
protected readonly storage: AsyncLocalStorage<Context>;
|
|
9
|
-
get(): Nullable<Context>;
|
|
10
|
-
getOrFail(): NonNullable<Context>;
|
|
11
|
-
run<ReturnType>(context: Context, callback: AsyncContextProviderCallback<ReturnType>): ReturnType;
|
|
12
|
-
exit<ReturnType>(callback: AsyncContextProviderCallback<ReturnType>): ReturnType;
|
|
13
|
-
runOperator<T>(factory?: AsyncContextFactory<T, Context>): MonoTypeOperatorFunction<T>;
|
|
14
|
-
exitOperator<T>(): MonoTypeOperatorFunction<T>;
|
|
15
|
-
private createOperator;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=async-context.provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-context.provider.d.ts","sourceRoot":"","sources":["../src/async-context.provider.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACN,wBAAwB,EAExB,MAAM,MAAM,CAAC;AAGd,KAAK,4BAA4B,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAC/C,KAAK,mBAAmB,CAAC,SAAS,EAAE,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;AAI7E,qBAAa,oBAAoB,CAAC,OAAO;IACxC,SAAS,CAAC,QAAQ,CAAC,OAAO,6BAAoC;IAEvD,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC;IAIxB,SAAS,IAAI,WAAW,CAAC,OAAO,CAAC;IAUjC,GAAG,CAAC,UAAU,EACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,4BAA4B,CAAC,UAAU,CAAC,GAChD,UAAU;IAIN,IAAI,CAAC,UAAU,EACrB,QAAQ,EAAE,4BAA4B,CAAC,UAAU,CAAC,GAChD,UAAU;IAIN,WAAW,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC,GACvC,wBAAwB,CAAC,CAAC,CAAC;IAOvB,YAAY,CAAC,CAAC,KAAK,wBAAwB,CAAC,CAAC,CAAC;IAIrD,OAAO,CAAC,cAAc;CA0BtB"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { Observable, } from 'rxjs';
|
|
3
|
-
import { AsyncContextNotFoundException } from './async-context.not-found.exception';
|
|
4
|
-
export class AsyncContextProvider {
|
|
5
|
-
storage = new AsyncLocalStorage();
|
|
6
|
-
get() {
|
|
7
|
-
return this.storage.getStore() ?? null;
|
|
8
|
-
}
|
|
9
|
-
getOrFail() {
|
|
10
|
-
const context = this.get();
|
|
11
|
-
if (typeof context === 'undefined' || context === null) {
|
|
12
|
-
throw new AsyncContextNotFoundException();
|
|
13
|
-
}
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
run(context, callback) {
|
|
17
|
-
return this.storage.run(context, callback);
|
|
18
|
-
}
|
|
19
|
-
exit(callback) {
|
|
20
|
-
return this.storage.exit(callback);
|
|
21
|
-
}
|
|
22
|
-
runOperator(factory) {
|
|
23
|
-
return this.createOperator((next, value) => {
|
|
24
|
-
const context = factory ? factory(value) : value;
|
|
25
|
-
this.storage.run(context, next);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exitOperator() {
|
|
29
|
-
return this.createOperator(next => this.storage.exit(next));
|
|
30
|
-
}
|
|
31
|
-
createOperator(onNext) {
|
|
32
|
-
return (source) => new Observable(subscriber => {
|
|
33
|
-
const callNext = input => {
|
|
34
|
-
const next = () => {
|
|
35
|
-
if (!subscriber.closed) {
|
|
36
|
-
subscriber.next(input);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
onNext(next, input);
|
|
40
|
-
};
|
|
41
|
-
const callError = input => {
|
|
42
|
-
const next = () => {
|
|
43
|
-
if (!subscriber.closed) {
|
|
44
|
-
subscriber.error(input);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
onNext(next, input);
|
|
48
|
-
};
|
|
49
|
-
source.subscribe({
|
|
50
|
-
next: callNext,
|
|
51
|
-
error: callError,
|
|
52
|
-
complete: () => subscriber.complete(),
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=async-context.provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1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AAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEO,cAAc,CAAI,MAA4C;QACrE,OAAO,CAAC,MAAM,EAAiB,EAAE,CAAC,IAAI,UAAU,CAAI,UAAU,CAAC,EAAE;YAChE,MAAM,QAAQ,GAAoB,KAAK,CAAC,EAAE;gBACzC,MAAM,IAAI,GAAG,GAAS,EAAE;oBACvB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;wBACvB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;qBACvB;gBACF,CAAC,CAAC;gBACF,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACrB,CAAC,CAAC;YACF,MAAM,SAAS,GAAoB,KAAK,CAAC,EAAE;gBAC1C,MAAM,IAAI,GAAG,GAAS,EAAE;oBACvB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;wBACvB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACxB;gBACF,CAAC,CAAC;gBACF,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACrB,CAAC,CAAC;YAEF,MAAM,CAAC,SAAS,CAAC;gBAChB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;aACrC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TestSuite } from '@hg-ts/tests';
|
|
2
|
-
export declare class AsyncContextTestSuite extends TestSuite {
|
|
3
|
-
private context;
|
|
4
|
-
emptyContext(): Promise<void>;
|
|
5
|
-
noPromiseContext(): Promise<void>;
|
|
6
|
-
promiseContext(): Promise<void>;
|
|
7
|
-
operatorContext(): Promise<void>;
|
|
8
|
-
operatorWithFactory(): Promise<void>;
|
|
9
|
-
operatorWithErrorContext(): Promise<void>;
|
|
10
|
-
operatorAfterUnsubscribe(): Promise<void>;
|
|
11
|
-
operatorWithErrorAfterUnsubscribe(): Promise<void>;
|
|
12
|
-
contextNotFound(): Promise<void>;
|
|
13
|
-
beforeEach(): Promise<void>;
|
|
14
|
-
private createOperatorTestSubscription;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=async-context.test-suite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-context.test-suite.d.ts","sourceRoot":"","sources":["../src/async-context.test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,SAAS,EACT,MAAM,cAAc,CAAC;AAiBtB,qBACa,qBAAsB,SAAQ,SAAS;IACnD,OAAO,CAAC,OAAO,CAA+B;IAGjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBjC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAUhC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUpC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUzC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAWzC,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC;IAYlD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjD,OAAO,CAAC,8BAA8B;CAgCtC"}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Describe, expect, ExpectException, Test, TestSuite, } from '@hg-ts/tests';
|
|
3
|
-
import { Subject, tap, } from 'rxjs';
|
|
4
|
-
import { AsyncContextNotFoundException } from './async-context.not-found.exception';
|
|
5
|
-
import { AsyncContextProvider } from './async-context.provider';
|
|
6
|
-
let AsyncContextTestSuite = class AsyncContextTestSuite extends TestSuite {
|
|
7
|
-
context;
|
|
8
|
-
async emptyContext() {
|
|
9
|
-
expect(this.context.get()).toBe(null);
|
|
10
|
-
}
|
|
11
|
-
async noPromiseContext() {
|
|
12
|
-
const contextValue = Math.random();
|
|
13
|
-
const resultValue = Math.random();
|
|
14
|
-
const result = this.context.run(contextValue, () => {
|
|
15
|
-
expect(this.context.getOrFail()).toBe(contextValue);
|
|
16
|
-
this.context.exit(() => {
|
|
17
|
-
expect(this.context.get()).toBe(null);
|
|
18
|
-
});
|
|
19
|
-
return resultValue;
|
|
20
|
-
});
|
|
21
|
-
expect(result).toBe(resultValue);
|
|
22
|
-
}
|
|
23
|
-
async promiseContext() {
|
|
24
|
-
const contextValue = Math.random();
|
|
25
|
-
const resultValue = Math.random();
|
|
26
|
-
const result = await this.context.run(contextValue, async () => {
|
|
27
|
-
expect(this.context.getOrFail()).toBe(contextValue);
|
|
28
|
-
await this.context.exit(async () => {
|
|
29
|
-
expect(this.context.get()).toBe(null);
|
|
30
|
-
});
|
|
31
|
-
return resultValue;
|
|
32
|
-
});
|
|
33
|
-
expect(result).toBe(resultValue);
|
|
34
|
-
}
|
|
35
|
-
async operatorContext() {
|
|
36
|
-
const { subject, input } = this.createOperatorTestSubscription();
|
|
37
|
-
subject.next(input);
|
|
38
|
-
subject.complete();
|
|
39
|
-
expect.assertions(4);
|
|
40
|
-
}
|
|
41
|
-
async operatorWithFactory() {
|
|
42
|
-
const { subject, input } = this.createOperatorTestSubscription(value => -value);
|
|
43
|
-
subject.next(input);
|
|
44
|
-
subject.complete();
|
|
45
|
-
expect.assertions(4);
|
|
46
|
-
}
|
|
47
|
-
async operatorWithErrorContext() {
|
|
48
|
-
const { subject, input } = this.createOperatorTestSubscription();
|
|
49
|
-
subject.error(input);
|
|
50
|
-
subject.complete();
|
|
51
|
-
expect.assertions(4);
|
|
52
|
-
}
|
|
53
|
-
async operatorAfterUnsubscribe() {
|
|
54
|
-
const { subject, input, subscription } = this.createOperatorTestSubscription();
|
|
55
|
-
subscription.unsubscribe();
|
|
56
|
-
subject.next(input);
|
|
57
|
-
subject.complete();
|
|
58
|
-
expect.assertions(2);
|
|
59
|
-
}
|
|
60
|
-
async operatorWithErrorAfterUnsubscribe() {
|
|
61
|
-
const { subject, input, subscription } = this.createOperatorTestSubscription();
|
|
62
|
-
subscription.unsubscribe();
|
|
63
|
-
subject.error(input);
|
|
64
|
-
subject.complete();
|
|
65
|
-
expect.assertions(2);
|
|
66
|
-
}
|
|
67
|
-
async contextNotFound() {
|
|
68
|
-
this.context.getOrFail();
|
|
69
|
-
}
|
|
70
|
-
async beforeEach() {
|
|
71
|
-
this.context = new AsyncContextProvider();
|
|
72
|
-
}
|
|
73
|
-
createOperatorTestSubscription(factory) {
|
|
74
|
-
const subject = new Subject();
|
|
75
|
-
const input = Math.random();
|
|
76
|
-
const context = factory ? factory(input) : input;
|
|
77
|
-
const withContext = (value) => {
|
|
78
|
-
expect(value).toBe(input);
|
|
79
|
-
expect(this.context.getOrFail()).toBe(context);
|
|
80
|
-
};
|
|
81
|
-
const withoutContext = (value) => {
|
|
82
|
-
expect(value).toBe(input);
|
|
83
|
-
expect(this.context.get()).toBe(null);
|
|
84
|
-
};
|
|
85
|
-
const subscription = subject.asObservable()
|
|
86
|
-
.pipe(this.context.runOperator(factory), tap({
|
|
87
|
-
next: withContext,
|
|
88
|
-
error: withContext,
|
|
89
|
-
}), this.context.exitOperator(), tap({
|
|
90
|
-
next: withoutContext,
|
|
91
|
-
error: withoutContext,
|
|
92
|
-
}))
|
|
93
|
-
.subscribe({ next() { }, error() { } });
|
|
94
|
-
return { subject, subscription, input, context };
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
__decorate([
|
|
98
|
-
Test(),
|
|
99
|
-
__metadata("design:type", Function),
|
|
100
|
-
__metadata("design:paramtypes", []),
|
|
101
|
-
__metadata("design:returntype", Promise)
|
|
102
|
-
], AsyncContextTestSuite.prototype, "emptyContext", null);
|
|
103
|
-
__decorate([
|
|
104
|
-
Test(),
|
|
105
|
-
__metadata("design:type", Function),
|
|
106
|
-
__metadata("design:paramtypes", []),
|
|
107
|
-
__metadata("design:returntype", Promise)
|
|
108
|
-
], AsyncContextTestSuite.prototype, "noPromiseContext", null);
|
|
109
|
-
__decorate([
|
|
110
|
-
Test(),
|
|
111
|
-
__metadata("design:type", Function),
|
|
112
|
-
__metadata("design:paramtypes", []),
|
|
113
|
-
__metadata("design:returntype", Promise)
|
|
114
|
-
], AsyncContextTestSuite.prototype, "promiseContext", null);
|
|
115
|
-
__decorate([
|
|
116
|
-
Test(),
|
|
117
|
-
__metadata("design:type", Function),
|
|
118
|
-
__metadata("design:paramtypes", []),
|
|
119
|
-
__metadata("design:returntype", Promise)
|
|
120
|
-
], AsyncContextTestSuite.prototype, "operatorContext", null);
|
|
121
|
-
__decorate([
|
|
122
|
-
Test(),
|
|
123
|
-
__metadata("design:type", Function),
|
|
124
|
-
__metadata("design:paramtypes", []),
|
|
125
|
-
__metadata("design:returntype", Promise)
|
|
126
|
-
], AsyncContextTestSuite.prototype, "operatorWithFactory", null);
|
|
127
|
-
__decorate([
|
|
128
|
-
Test(),
|
|
129
|
-
__metadata("design:type", Function),
|
|
130
|
-
__metadata("design:paramtypes", []),
|
|
131
|
-
__metadata("design:returntype", Promise)
|
|
132
|
-
], AsyncContextTestSuite.prototype, "operatorWithErrorContext", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
Test(),
|
|
135
|
-
__metadata("design:type", Function),
|
|
136
|
-
__metadata("design:paramtypes", []),
|
|
137
|
-
__metadata("design:returntype", Promise)
|
|
138
|
-
], AsyncContextTestSuite.prototype, "operatorAfterUnsubscribe", null);
|
|
139
|
-
__decorate([
|
|
140
|
-
Test(),
|
|
141
|
-
__metadata("design:type", Function),
|
|
142
|
-
__metadata("design:paramtypes", []),
|
|
143
|
-
__metadata("design:returntype", Promise)
|
|
144
|
-
], AsyncContextTestSuite.prototype, "operatorWithErrorAfterUnsubscribe", null);
|
|
145
|
-
__decorate([
|
|
146
|
-
Test(),
|
|
147
|
-
ExpectException(AsyncContextNotFoundException),
|
|
148
|
-
__metadata("design:type", Function),
|
|
149
|
-
__metadata("design:paramtypes", []),
|
|
150
|
-
__metadata("design:returntype", Promise)
|
|
151
|
-
], AsyncContextTestSuite.prototype, "contextNotFound", null);
|
|
152
|
-
AsyncContextTestSuite = __decorate([
|
|
153
|
-
Describe()
|
|
154
|
-
], AsyncContextTestSuite);
|
|
155
|
-
export { AsyncContextTestSuite };
|
|
156
|
-
//# sourceMappingURL=async-context.test-suite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-context.test-suite.js","sourceRoot":"","sources":["../src/async-context.test-suite.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,QAAQ,EACR,MAAM,EACN,eAAe,EACf,IAAI,EACJ,SAAS,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,OAAO,EAEP,GAAG,GACH,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUzD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,SAAS;IAC3C,OAAO,CAA+B;IAGjC,AAAN,KAAK,CAAC,YAAY;QACxB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAGY,AAAN,KAAK,CAAC,gBAAgB;QAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAElC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YA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E,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAClD,CAAC;CACD,CAAA;AApIa;IADZ,IAAI,EAAE;;;;yDAGN;AAGY;IADZ,IAAI,EAAE;;;;6DAeN;AAGY;IADZ,IAAI,EAAE;;;;2DAeN;AAGY;IADZ,IAAI,EAAE;;;;4DAQN;AAGY;IADZ,IAAI,EAAE;;;;gEAQN;AAGY;IADZ,IAAI,EAAE;;;;qEAQN;AAGY;IADZ,IAAI,EAAE;;;;qEASN;AAGY;IADZ,IAAI,EAAE;;;;8EASN;AAIY;IAFZ,IAAI,EAAE;IACN,eAAe,CAAC,6BAA6B,CAAC;;;;4DAG9C;AAlGW,qBAAqB;IADjC,QAAQ,EAAE;GACE,qBAAqB,CAwIjC"}
|
package/dist-esm/dto.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="@hg-ts/types" />
|
|
2
|
-
import { ZodSchema, ZodTypeDef } from 'zod';
|
|
3
|
-
export type ZodDto<TOutput = any> = {
|
|
4
|
-
new (): TOutput;
|
|
5
|
-
isZodDto: true;
|
|
6
|
-
schema: ZodSchema<TOutput, ZodTypeDef, unknown>;
|
|
7
|
-
create(input: unknown): TOutput;
|
|
8
|
-
createAsync(input: unknown): Promise<TOutput>;
|
|
9
|
-
};
|
|
10
|
-
export declare function createZodDto<TOutput = any>(schema: ZodSchema<TOutput, ZodTypeDef, unknown>): ZodDto<TOutput>;
|
|
11
|
-
export declare function isZodDto(ctor: Class<any, any[]>): ctor is ZodDto;
|
|
12
|
-
//# sourceMappingURL=dto.d.ts.map
|
package/dist-esm/dto.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":";AAAA,OAAO,EAEN,SAAS,EACT,UAAU,EACV,MAAM,KAAK,CAAC;AAGb,MAAM,MAAM,MAAM,CAAC,OAAO,GAAG,GAAG,IAAI;IACnC,QAAQ,OAAO,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAA;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAG,GAAG,EACzC,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,GAC7C,MAAM,CAAC,OAAO,CAAC,CAqCjB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,IAAI,MAAM,CAEhE"}
|
package/dist-esm/dto.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ZodError, } from 'zod';
|
|
2
|
-
import { ValidationException } from './validation.exception';
|
|
3
|
-
export function createZodDto(schema) {
|
|
4
|
-
class AugmentedZodDto {
|
|
5
|
-
static isZodDto = true;
|
|
6
|
-
static schema = schema;
|
|
7
|
-
static create(input) {
|
|
8
|
-
try {
|
|
9
|
-
return this.schema.parse(input);
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
if (error instanceof ZodError) {
|
|
13
|
-
AugmentedZodDto.formatError(error);
|
|
14
|
-
}
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
static async createAsync(input) {
|
|
19
|
-
try {
|
|
20
|
-
const result = await this.schema.parseAsync(input);
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
if (error instanceof ZodError) {
|
|
25
|
-
AugmentedZodDto.formatError(error);
|
|
26
|
-
}
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
static formatError(error) {
|
|
31
|
-
throw new ValidationException(error);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return AugmentedZodDto;
|
|
35
|
-
}
|
|
36
|
-
export function isZodDto(ctor) {
|
|
37
|
-
return 'isZodDto' in ctor && ctor.isZodDto === true;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=dto.js.map
|
package/dist-esm/dto.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../src/dto.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAU7D,MAAM,UAAU,YAAY,CAC3B,MAA+C;IAE/C,MAAM,eAAe;QACb,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAEvB,MAAM,CAAC,MAAM,CAAC,KAAc;YAClC,IAAI;gBACH,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAoB,CAAC;aACnD;YAAC,OAAO,KAAc,EAAE;gBACxB,IAAI,KAAK,YAAY,QAAQ,EAAE;oBAC9B,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;iBACnC;gBAED,MAAM,KAAK,CAAC;aACZ;QACF,CAAC;QAEM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAc;YAC7C,IAAI;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAEnD,OAAO,MAAyB,CAAC;aACjC;YAAC,OAAO,KAAc,EAAE;gBACxB,IAAI,KAAK,YAAY,QAAQ,EAAE;oBAC9B,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;iBACnC;gBAED,MAAM,KAAK,CAAC;aACZ;QACF,CAAC;QAES,MAAM,CAAC,WAAW,CAAC,KAAe;YAC3C,MAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;;IAGF,OAAO,eAA6C,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAuB;IAC/C,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
package/dist-esm/extensions.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ZodEffects, ZodTypeDef, infer as ZodInfer, input as ZodInput, ZodPipeline, ZodBoolean } from 'zod';
|
|
2
|
-
import { ZodDto } from './dto';
|
|
3
|
-
declare module 'zod' {
|
|
4
|
-
interface ZodSchema<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
|
|
5
|
-
enforceEnv<T extends ZodSchema<Output, Def, Input>>(this: T, name: string): ZodEffects<T, ZodInfer<T> | string>;
|
|
6
|
-
transformBooleanString<T extends ZodSchema<Output, Def, Input>>(this: T): ZodPipeline<ZodEffects<T, boolean, ZodInput<T>>, ZodBoolean>;
|
|
7
|
-
toClass<T extends ZodSchema<Output, Def, Input>>(this: T): ZodDto<ZodInfer<T>>;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAY,EACX,UAAU,EAEV,UAAU,EACV,KAAK,IAAI,QAAQ,EACjB,KAAK,IAAI,QAAQ,EACjB,WAAW,EACX,UAAU,EACV,MAAM,KAAK,CAAC;AACb,OAAO,EAEN,MAAM,EACN,MAAM,OAAO,CAAC;AAEf,OAAO,QAAQ,KAAK,CAAC;IAEpB,UAAU,SAAS,CAAC,MAAM,GAAG,GAAG,EAAE,GAAG,SAAS,UAAU,GAAG,UAAU,EAAE,KAAK,GAAG,MAAM;QACpF,UAAU,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QAChH,sBAAsB,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EAC7D,IAAI,EAAE,CAAC,GACL,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/E;CACD"}
|
package/dist-esm/extensions.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import zod from 'zod';
|
|
2
|
-
import { createZodDto, } from './dto';
|
|
3
|
-
zod.Schema.prototype.enforceEnv = function (name) {
|
|
4
|
-
return this.transform(value => process.env[name] ?? value);
|
|
5
|
-
};
|
|
6
|
-
zod.Schema.prototype.transformBooleanString = function () {
|
|
7
|
-
return this
|
|
8
|
-
.transform(value => (typeof value === 'boolean' ? value : value === 'true'))
|
|
9
|
-
.pipe(zod.boolean());
|
|
10
|
-
};
|
|
11
|
-
zod.Schema.prototype.toClass = function () {
|
|
12
|
-
return createZodDto(this);
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=extensions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,GAQN,MAAM,KAAK,CAAC;AACb,OAAO,EACN,YAAY,GAEZ,MAAM,OAAO,CAAC;AAaf,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,GAAG,UAEjC,IAAY;IAEZ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAsB,GAAG;IAG7C,OAAO,IAAI;SACT,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;SAC3E,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG;IAG9B,OAAO,YAAY,CAAc,IAAI,CAAC,CAAC;AACxC,CAAC,CAAC"}
|
package/dist-esm/index.d.ts
DELETED
package/dist-esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,KAAK,CAAC;AACpB,eAAe,GAAG,CAAC"}
|
package/dist-esm/index.js
DELETED
package/dist-esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAU,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,KAAK,CAAC;AACpB,eAAe,GAAG,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseException, JSONBaseException } from '@hg-ts/exception';
|
|
2
|
-
import { ZodError, ZodIssue } from 'zod';
|
|
3
|
-
export type JSONValidationException = JSONBaseException & {
|
|
4
|
-
errors: ZodIssue[];
|
|
5
|
-
};
|
|
6
|
-
export declare class ValidationException extends BaseException {
|
|
7
|
-
errors: ZodIssue[];
|
|
8
|
-
constructor(error: ZodError);
|
|
9
|
-
toJSON(): JSONValidationException;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=validation.exception.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.exception.d.ts","sourceRoot":"","sources":["../src/validation.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEzC,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG;IACzD,MAAM,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAA;AAED,qBAAa,mBAAoB,SAAQ,aAAa;IAC9C,MAAM,EAAE,QAAQ,EAAE,CAAC;gBACP,KAAK,EAAE,QAAQ;IAMlB,MAAM,IAAI,uBAAuB;CAMjD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseException, } from '@hg-ts/exception';
|
|
2
|
-
export class ValidationException extends BaseException {
|
|
3
|
-
errors;
|
|
4
|
-
constructor(error) {
|
|
5
|
-
super('Validation failed');
|
|
6
|
-
this.errors = error.issues;
|
|
7
|
-
}
|
|
8
|
-
toJSON() {
|
|
9
|
-
return {
|
|
10
|
-
...super.toJSON(),
|
|
11
|
-
errors: this.errors,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=validation.exception.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.exception.js","sourceRoot":"","sources":["../src/validation.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,GAEb,MAAM,kBAAkB,CAAC;AAO1B,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAC9C,MAAM,CAAa;IAC1B,YAAmB,KAAe;QACjC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEe,MAAM;QACrB,OAAO;YACN,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC;IACH,CAAC;CACD"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseException,
|
|
3
|
-
JSONBaseException,
|
|
4
|
-
} from '@hg-ts/exception';
|
|
5
|
-
import { ZodError, ZodIssue } from 'zod';
|
|
6
|
-
|
|
7
|
-
export type JSONValidationException = JSONBaseException & {
|
|
8
|
-
errors: ZodIssue[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ValidationException extends BaseException {
|
|
12
|
-
public errors: ZodIssue[];
|
|
13
|
-
public constructor(error: ZodError) {
|
|
14
|
-
super('Validation failed');
|
|
15
|
-
|
|
16
|
-
this.errors = error.issues;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public override toJSON(): JSONValidationException {
|
|
20
|
-
return {
|
|
21
|
-
...super.toJSON(),
|
|
22
|
-
errors: this.errors,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|