@lerianstudio/sindarian-server 1.0.0-beta.9 → 1.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/README.md +268 -21
- package/dist/constants/keys.d.ts +3 -0
- package/dist/constants/keys.d.ts.map +1 -1
- package/dist/constants/keys.js +4 -1
- package/dist/constants/keys.js.map +1 -1
- package/dist/controllers/decorators/body-decorator.d.ts +12 -16
- package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/body-decorator.js +52 -58
- package/dist/controllers/decorators/body-decorator.js.map +1 -1
- package/dist/controllers/decorators/controller-decorator.d.ts +5 -4
- package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/controller-decorator.js +29 -22
- package/dist/controllers/decorators/controller-decorator.js.map +1 -1
- package/dist/controllers/decorators/param-decorator.d.ts +4 -9
- package/dist/controllers/decorators/param-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/param-decorator.js +33 -29
- package/dist/controllers/decorators/param-decorator.js.map +1 -1
- package/dist/controllers/decorators/query-decorator.d.ts +11 -15
- package/dist/controllers/decorators/query-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/query-decorator.js +24 -38
- package/dist/controllers/decorators/query-decorator.js.map +1 -1
- package/dist/controllers/decorators/request-decorator.d.ts +8 -12
- package/dist/controllers/decorators/request-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/request-decorator.js +21 -17
- package/dist/controllers/decorators/request-decorator.js.map +1 -1
- package/dist/controllers/decorators/route-decorator.d.ts +16 -1
- package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/route-decorator.js +31 -16
- package/dist/controllers/decorators/route-decorator.js.map +1 -1
- package/dist/dependency-injection/container.d.ts +4 -3
- package/dist/dependency-injection/container.d.ts.map +1 -1
- package/dist/dependency-injection/container.js +14 -3
- package/dist/dependency-injection/container.js.map +1 -1
- package/dist/dependency-injection/injectable-decorator.d.ts +5 -0
- package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -1
- package/dist/dependency-injection/injectable-decorator.js +9 -0
- package/dist/dependency-injection/injectable-decorator.js.map +1 -1
- package/dist/exceptions/api-exception.d.ts +4 -7
- package/dist/exceptions/api-exception.d.ts.map +1 -1
- package/dist/exceptions/api-exception.js +8 -4
- package/dist/exceptions/api-exception.js.map +1 -1
- package/dist/exceptions/base-exception-filter.d.ts.map +1 -1
- package/dist/exceptions/base-exception-filter.js +10 -3
- package/dist/exceptions/base-exception-filter.js.map +1 -1
- package/dist/exceptions/decorators/use-filters-decorator.d.ts +12 -1
- package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -1
- package/dist/exceptions/decorators/use-filters-decorator.js +34 -3
- package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -1
- package/dist/guards/can-activate.d.ts +21 -0
- package/dist/guards/can-activate.d.ts.map +1 -0
- package/dist/guards/can-activate.js +3 -0
- package/dist/guards/can-activate.js.map +1 -0
- package/dist/guards/decorators/index.d.ts +2 -0
- package/dist/guards/decorators/index.d.ts.map +1 -0
- package/dist/guards/decorators/index.js +18 -0
- package/dist/guards/decorators/index.js.map +1 -0
- package/dist/guards/decorators/use-guards-decorator.d.ts +44 -0
- package/dist/guards/decorators/use-guards-decorator.d.ts.map +1 -0
- package/dist/guards/decorators/use-guards-decorator.js +127 -0
- package/dist/guards/decorators/use-guards-decorator.js.map +1 -0
- package/dist/guards/index.d.ts +3 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +19 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +10 -3
- package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -1
- package/dist/interceptor/decorators/use-interceptor-decorator.js +52 -22
- package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -1
- package/dist/logger/console-logger.d.ts.map +1 -1
- package/dist/logger/console-logger.js +6 -0
- package/dist/logger/console-logger.js.map +1 -1
- package/dist/middleware/index.d.ts +3 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +19 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/middleware-handler.d.ts +6 -0
- package/dist/middleware/middleware-handler.d.ts.map +1 -0
- package/dist/middleware/middleware-handler.js +19 -0
- package/dist/middleware/middleware-handler.js.map +1 -0
- package/dist/middleware/middleware.d.ts +6 -0
- package/dist/middleware/middleware.d.ts.map +1 -0
- package/dist/middleware/middleware.js +7 -0
- package/dist/middleware/middleware.js.map +1 -0
- package/dist/modules/module-decorator.d.ts +2 -2
- package/dist/modules/module-decorator.d.ts.map +1 -1
- package/dist/modules/module-decorator.js +34 -14
- package/dist/modules/module-decorator.js.map +1 -1
- package/dist/pipes/decorators/index.d.ts +2 -0
- package/dist/pipes/decorators/index.d.ts.map +1 -0
- package/dist/pipes/decorators/index.js +6 -0
- package/dist/pipes/decorators/index.js.map +1 -0
- package/dist/pipes/decorators/use-pipes.d.ts +19 -0
- package/dist/pipes/decorators/use-pipes.d.ts.map +1 -0
- package/dist/pipes/decorators/use-pipes.js +118 -0
- package/dist/pipes/decorators/use-pipes.js.map +1 -0
- package/dist/pipes/index.d.ts +3 -0
- package/dist/pipes/index.d.ts.map +1 -0
- package/dist/pipes/index.js +18 -0
- package/dist/pipes/index.js.map +1 -0
- package/dist/pipes/pipe-transform.d.ts +46 -0
- package/dist/pipes/pipe-transform.d.ts.map +1 -0
- package/dist/pipes/pipe-transform.js +3 -0
- package/dist/pipes/pipe-transform.js.map +1 -0
- package/dist/server/server-factory.d.ts +48 -1
- package/dist/server/server-factory.d.ts.map +1 -1
- package/dist/server/server-factory.js +169 -34
- package/dist/server/server-factory.js.map +1 -1
- package/dist/services/guards.d.ts +2 -0
- package/dist/services/guards.d.ts.map +1 -0
- package/dist/services/guards.js +5 -0
- package/dist/services/guards.js.map +1 -0
- package/dist/services/middleware.d.ts +2 -0
- package/dist/services/middleware.d.ts.map +1 -0
- package/dist/services/middleware.js +5 -0
- package/dist/services/middleware.js.map +1 -0
- package/dist/services/pipes.d.ts +2 -0
- package/dist/services/pipes.d.ts.map +1 -0
- package/dist/services/pipes.js +5 -0
- package/dist/services/pipes.js.map +1 -0
- package/dist/utils/routes/route-specificity.d.ts +40 -0
- package/dist/utils/routes/route-specificity.d.ts.map +1 -0
- package/dist/utils/routes/route-specificity.js +89 -0
- package/dist/utils/routes/route-specificity.js.map +1 -0
- package/dist/utils/url/url-match.d.ts.map +1 -1
- package/dist/utils/url/url-match.js +16 -2
- package/dist/utils/url/url-match.js.map +1 -1
- package/dist/zod/create-zod-dto.d.ts +16 -0
- package/dist/zod/create-zod-dto.d.ts.map +1 -0
- package/dist/zod/create-zod-dto.js +14 -0
- package/dist/zod/create-zod-dto.js.map +1 -0
- package/dist/zod/index.d.ts +3 -0
- package/dist/zod/index.d.ts.map +1 -0
- package/dist/zod/index.js +8 -0
- package/dist/zod/index.js.map +1 -0
- package/dist/zod/zod-validation-pipe.d.ts +5 -0
- package/dist/zod/zod-validation-pipe.d.ts.map +1 -0
- package/dist/zod/zod-validation-pipe.js +35 -0
- package/dist/zod/zod-validation-pipe.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortRoutesBySpecificity = sortRoutesBySpecificity;
|
|
4
|
+
exports.calculateRouteSpecificity = calculateRouteSpecificity;
|
|
5
|
+
/**
|
|
6
|
+
* Sort routes by specificity (most specific first)
|
|
7
|
+
* Routes with more static segments come before routes with parameters
|
|
8
|
+
* This matches NestJS behavior to ensure routes like:
|
|
9
|
+
* - GET /organizations/:id/ledgers/with-assets (more specific)
|
|
10
|
+
* - GET /organizations/:id/ledgers/:ledgerId (less specific)
|
|
11
|
+
* are matched in the correct order
|
|
12
|
+
*
|
|
13
|
+
* @param routes - Array of route metadata to sort
|
|
14
|
+
* @returns Sorted array with most specific routes first
|
|
15
|
+
*/
|
|
16
|
+
function sortRoutesBySpecificity(routes) {
|
|
17
|
+
return [...routes].sort((a, b) => {
|
|
18
|
+
const aScore = calculateRouteSpecificity(a.path);
|
|
19
|
+
const bScore = calculateRouteSpecificity(b.path);
|
|
20
|
+
return bScore - aScore; // Higher score = more specific = comes first
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Calculate specificity score for a route path
|
|
25
|
+
* Higher score = more specific route
|
|
26
|
+
*
|
|
27
|
+
* This algorithm is based on the route-sort library by Luke Edwards
|
|
28
|
+
* https://github.com/lukeed/route-sort
|
|
29
|
+
*
|
|
30
|
+
* Segment Values (lower = more specific):
|
|
31
|
+
* - Static segment: 1
|
|
32
|
+
* - Parameter (:id): 111
|
|
33
|
+
* - Parameter with suffix (:id.format): 11
|
|
34
|
+
* - Optional parameter (:id?): 1111
|
|
35
|
+
* - Wildcard (*): 100000000000 (1e11)
|
|
36
|
+
*
|
|
37
|
+
* Rank = (segment_count - 1) / sum_of_segment_values
|
|
38
|
+
* Higher rank = more specific route
|
|
39
|
+
*
|
|
40
|
+
* Examples:
|
|
41
|
+
* - /users/active (2 static) = 1 / 2 = 0.5
|
|
42
|
+
* - /users/:id (1 static + 1 param) = 1 / 112 = ~0.0089
|
|
43
|
+
* - /users/* (1 static + 1 wildcard) = 1 / 100000000001 = ~1e-11
|
|
44
|
+
*
|
|
45
|
+
* @param path - The route path to score
|
|
46
|
+
* @returns Specificity score (higher = more specific)
|
|
47
|
+
*/
|
|
48
|
+
function calculateRouteSpecificity(path) {
|
|
49
|
+
const segments = path.split('/').filter((s) => s.length > 0);
|
|
50
|
+
if (segments.length === 0) {
|
|
51
|
+
// Root path is treated as a static route
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
let totalValue = 0;
|
|
55
|
+
for (const segment of segments) {
|
|
56
|
+
totalValue += getSegmentValue(segment);
|
|
57
|
+
}
|
|
58
|
+
// Calculate rank: (segment_count - 1) / total_value
|
|
59
|
+
// Higher rank = more specific
|
|
60
|
+
return (segments.length - 1) / totalValue;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get numeric value for a route segment
|
|
64
|
+
* Lower value = more specific
|
|
65
|
+
*
|
|
66
|
+
* @param segment - Route segment to evaluate
|
|
67
|
+
* @returns Numeric value representing specificity
|
|
68
|
+
*/
|
|
69
|
+
function getSegmentValue(segment) {
|
|
70
|
+
// Wildcard
|
|
71
|
+
if (segment === '*') {
|
|
72
|
+
return 1e11;
|
|
73
|
+
}
|
|
74
|
+
// Optional parameter (:id?)
|
|
75
|
+
if (/^:.*\?$/.test(segment)) {
|
|
76
|
+
return 1111;
|
|
77
|
+
}
|
|
78
|
+
// Parameter with suffix (:id.format)
|
|
79
|
+
if (/^:.*\./.test(segment)) {
|
|
80
|
+
return 11;
|
|
81
|
+
}
|
|
82
|
+
// Regular parameter (:id)
|
|
83
|
+
if (segment.startsWith(':')) {
|
|
84
|
+
return 111;
|
|
85
|
+
}
|
|
86
|
+
// Static segment
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=route-specificity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-specificity.js","sourceRoot":"","sources":["../../../src/utils/routes/route-specificity.ts"],"names":[],"mappings":";;AAaA,0DAQC;AA2BD,8DAiBC;AA/DD;;;;;;;;;;GAUG;AACH,SAAgB,uBAAuB,CACrC,MAAwB;IAExB,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAChD,MAAM,MAAM,GAAG,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAChD,OAAO,MAAM,GAAG,MAAM,CAAA,CAAC,6CAA6C;IACtE,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,yBAAyB,CAAC,IAAY;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAE5D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,yCAAyC;QACzC,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,CAAA;IAElB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,UAAU,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,oDAAoD;IACpD,8BAA8B;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,CAAA;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAe;IACtC,WAAW;IACX,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,4BAA4B;IAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,qCAAqC;IACrC,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,iBAAiB;IACjB,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-match.d.ts","sourceRoot":"","sources":["../../../src/utils/url/url-match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url-match.d.ts","sourceRoot":"","sources":["../../../src/utils/url/url-match.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAOvD"}
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.urlMatch = urlMatch;
|
|
4
4
|
const path_to_regexp_1 = require("path-to-regexp");
|
|
5
|
+
/**
|
|
6
|
+
* Normalize a path by removing trailing slashes (except for root path)
|
|
7
|
+
* @param path - The path to normalize
|
|
8
|
+
* @returns The normalized path
|
|
9
|
+
*/
|
|
10
|
+
function normalizePath(path) {
|
|
11
|
+
if (path === '/' || path === '') {
|
|
12
|
+
return path;
|
|
13
|
+
}
|
|
14
|
+
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
15
|
+
}
|
|
5
16
|
/**
|
|
6
17
|
* Check if a pathname matches a route
|
|
7
18
|
* @param pathname - The pathname to check
|
|
@@ -9,7 +20,10 @@ const path_to_regexp_1 = require("path-to-regexp");
|
|
|
9
20
|
* @returns True if the pathname matches the route, false otherwise
|
|
10
21
|
*/
|
|
11
22
|
function urlMatch(pathname, route) {
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
// Normalize both paths to handle Next.js trailingSlash configuration
|
|
24
|
+
const normalizedPathname = normalizePath(pathname);
|
|
25
|
+
const normalizedRoute = normalizePath(route);
|
|
26
|
+
const { regexp } = (0, path_to_regexp_1.pathToRegexp)(normalizedRoute);
|
|
27
|
+
return regexp.test(normalizedPathname);
|
|
14
28
|
}
|
|
15
29
|
//# sourceMappingURL=url-match.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-match.js","sourceRoot":"","sources":["../../../src/utils/url/url-match.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"url-match.js","sourceRoot":"","sources":["../../../src/utils/url/url-match.ts"],"names":[],"mappings":";;AAoBA,4BAOC;AA3BD,mDAA6C;AAE7C;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACtD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,QAAgB,EAAE,KAAa;IACtD,qEAAqE;IACrE,MAAM,kBAAkB,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IAE5C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,6BAAY,EAAC,eAAe,CAAC,CAAA;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as z3 from 'zod/v3';
|
|
2
|
+
import { $ZodType } from 'zod/v4/core/index.cjs';
|
|
3
|
+
export interface UnknownSchema {
|
|
4
|
+
parse(input: unknown): unknown;
|
|
5
|
+
array?: () => UnknownSchema;
|
|
6
|
+
}
|
|
7
|
+
export interface ZodDto<TSchema extends UnknownSchema> {
|
|
8
|
+
new (): ReturnType<TSchema['parse']>;
|
|
9
|
+
isZodDto: true;
|
|
10
|
+
schema: TSchema;
|
|
11
|
+
create(input: unknown): ReturnType<TSchema['parse']>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createZodDto<TSchema extends UnknownSchema | z3.ZodTypeAny | ($ZodType & {
|
|
14
|
+
parse: (input: unknown) => unknown;
|
|
15
|
+
})>(schema: TSchema): ZodDto<TSchema>;
|
|
16
|
+
//# sourceMappingURL=create-zod-dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-zod-dto.d.ts","sourceRoot":"","sources":["../../src/zod/create-zod-dto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,aAAa,CAAA;CAC5B;AAED,MAAM,WAAW,MAAM,CAAC,OAAO,SAAS,aAAa;IACnD,QAAQ,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IACpC,QAAQ,EAAE,IAAI,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;CACrD;AAED,wBAAgB,YAAY,CAC1B,OAAO,SACH,aAAa,GACb,EAAE,CAAC,UAAU,GACb,CAAC,QAAQ,GAAG;IAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;CAAE,CAAC,EACvD,MAAM,EAAE,OAAO,GAUsB,MAAM,CAAC,OAAO,CAAC,CACrD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZodDto = createZodDto;
|
|
4
|
+
function createZodDto(schema) {
|
|
5
|
+
class AugmentedZodDto {
|
|
6
|
+
static create(input) {
|
|
7
|
+
return this.schema.parse(input);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
AugmentedZodDto.isZodDto = true;
|
|
11
|
+
AugmentedZodDto.schema = schema;
|
|
12
|
+
return AugmentedZodDto;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=create-zod-dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-zod-dto.js","sourceRoot":"","sources":["../../src/zod/create-zod-dto.ts"],"names":[],"mappings":";;AAeA,oCAgBC;AAhBD,SAAgB,YAAY,CAK1B,MAAe;IACf,MAAM,eAAe;QAIZ,MAAM,CAAC,MAAM,CAAC,KAAc;YACjC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACjC,CAAC;;IALsB,wBAAQ,GAAG,IAAI,CAAA;IACf,sBAAM,GAAG,MAAM,CAAA;IAOxC,OAAO,eAA6C,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zod/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodValidationPipe = exports.createZodDto = void 0;
|
|
4
|
+
var create_zod_dto_1 = require("./create-zod-dto");
|
|
5
|
+
Object.defineProperty(exports, "createZodDto", { enumerable: true, get: function () { return create_zod_dto_1.createZodDto; } });
|
|
6
|
+
var zod_validation_pipe_1 = require("./zod-validation-pipe");
|
|
7
|
+
Object.defineProperty(exports, "ZodValidationPipe", { enumerable: true, get: function () { return zod_validation_pipe_1.ZodValidationPipe; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/zod/index.ts"],"names":[],"mappings":";;;AAAA,mDAAuD;AAAtC,8GAAA,YAAY,OAAA;AAC7B,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-validation-pipe.d.ts","sourceRoot":"","sources":["../../src/zod/zod-validation-pipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAGxE,qBACa,iBAAkB,YAAW,aAAa;IACrD,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,GAAG,GAAG;CAmBvD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ZodValidationPipe = void 0;
|
|
10
|
+
const inversify_1 = require("inversify");
|
|
11
|
+
const api_exception_1 = require("../exceptions/api-exception");
|
|
12
|
+
let ZodValidationPipe = class ZodValidationPipe {
|
|
13
|
+
transform(value, metadata) {
|
|
14
|
+
try {
|
|
15
|
+
// Check if the metadata has a metatype
|
|
16
|
+
if (!metadata.metatype) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
const dto = metadata.metatype;
|
|
20
|
+
// Check if the dto is a ZodDto
|
|
21
|
+
if (!dto.isZodDto) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return dto.create(value);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new api_exception_1.ValidationApiException('Validation failed', error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.ZodValidationPipe = ZodValidationPipe;
|
|
32
|
+
exports.ZodValidationPipe = ZodValidationPipe = __decorate([
|
|
33
|
+
(0, inversify_1.injectable)()
|
|
34
|
+
], ZodValidationPipe);
|
|
35
|
+
//# sourceMappingURL=zod-validation-pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-validation-pipe.js","sourceRoot":"","sources":["../../src/zod/zod-validation-pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAsC;AAGtC,8DAAmE;AAG5D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,SAAS,CAAC,KAAU,EAAE,QAA0B;QAC9C,IAAI,CAAC;YACH,uCAAuC;YACvC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAA;YACd,CAAC;YAED,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAuB,CAAA;YAE5C,+BAA+B;YAC/B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAO,KAAK,CAAA;YACd,CAAC;YAED,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,sCAAsB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;CACF,CAAA;AApBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,GAAE;GACA,iBAAiB,CAoB7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lerianstudio/sindarian-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Sindarian Server",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/LerianStudio/console-sdk.git",
|
|
13
|
+
"url": "git+https://github.com/LerianStudio/console-sdk.git",
|
|
14
14
|
"directory": "packages/sindarian-server"
|
|
15
15
|
},
|
|
16
16
|
"type": "commonjs",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./zod": "./dist/zod/index.js"
|
|
25
|
+
},
|
|
22
26
|
"scripts": {
|
|
23
27
|
"build": "tsc && npm run build:paths",
|
|
24
28
|
"build:paths": "tsc-alias -p tsconfig.json",
|
|
@@ -28,7 +32,6 @@
|
|
|
28
32
|
"lint:check": "eslint ."
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@lerianstudio/lib-logs": ">=1.1.0",
|
|
32
35
|
"path-to-regexp": "^8.3.0"
|
|
33
36
|
},
|
|
34
37
|
"peerDependencies": {
|