@klerick/json-api-nestjs 10.0.0-beta.13 → 10.0.0-beta.15
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.md +29 -0
- package/package.json +2 -2
- package/src/lib/modules/mixin/swagger/method/get-all.js +4 -37
- package/src/lib/modules/mixin/swagger/method/get-all.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-one.js +3 -3
- package/src/lib/modules/mixin/swagger/method/get-one.js.map +1 -1
- package/src/lib/modules/mixin/zod/map-transform-to-json-shema.d.ts +2 -0
- package/src/lib/modules/mixin/zod/map-transform-to-json-shema.js +10 -0
- package/src/lib/modules/mixin/zod/map-transform-to-json-shema.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/fields.d.ts +3 -0
- package/src/lib/modules/mixin/zod/zod-input-query-schema/fields.js +9 -6
- package/src/lib/modules/mixin/zod/zod-input-query-schema/fields.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/filter.d.ts +67 -2
- package/src/lib/modules/mixin/zod/zod-input-query-schema/filter.js +25 -8
- package/src/lib/modules/mixin/zod/zod-input-query-schema/filter.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/index.d.ts +29 -4
- package/src/lib/modules/mixin/zod/zod-input-query-schema/index.js +3 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/fields.d.ts +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/fields.js +5 -4
- package/src/lib/modules/mixin/zod/zod-query-schema/fields.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/filter.d.ts +2 -0
- package/src/lib/modules/mixin/zod/zod-query-schema/filter.js +3 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/filter.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/sort.d.ts +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/sort.js +5 -4
- package/src/lib/modules/mixin/zod/zod-query-schema/sort.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-utils.d.ts +1 -0
- package/src/lib/modules/mixin/zod/zod-utils.js +8 -0
- package/src/lib/modules/mixin/zod/zod-utils.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## 10.0.0-beta.15 (2026-02-01)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **json-api-nestjs:** refactor query parameter schemas with Zod, improve Swagger definitions, and add reusable transformers ([70e955f](https://github.com/klerick/nestjs-json-api/commit/70e955f))
|
|
6
|
+
- **json-api-nestjs:** add primary key handling for relations and improve query schema generation ([7caea1a](https://github.com/klerick/nestjs-json-api/commit/7caea1a))
|
|
7
|
+
|
|
8
|
+
### 🧱 Updated Dependencies
|
|
9
|
+
|
|
10
|
+
- Updated json-api-nestjs-shared to 1.0.0-beta.7
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- Alex H
|
|
15
|
+
|
|
16
|
+
## 10.0.0-beta.14 (2026-01-23)
|
|
17
|
+
|
|
18
|
+
### 🚀 Features
|
|
19
|
+
|
|
20
|
+
- **json-api-nestjs-shared,json-api-nestjs:** im did mistake in commit msg ([56c483a](https://github.com/klerick/nestjs-json-api/commit/56c483a))
|
|
21
|
+
|
|
22
|
+
### 🧱 Updated Dependencies
|
|
23
|
+
|
|
24
|
+
- Updated json-api-nestjs-shared to 1.0.0-beta.6
|
|
25
|
+
|
|
26
|
+
### ❤️ Thank You
|
|
27
|
+
|
|
28
|
+
- Alex H
|
|
29
|
+
|
|
1
30
|
## 10.0.0-beta.13 (2026-01-23)
|
|
2
31
|
|
|
3
32
|
This was a version bump only for json-api-nestjs to align it with other projects, there were no code changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klerick/json-api-nestjs",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.15",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "JsonApi Plugin for NestJs",
|
|
6
6
|
"keywords": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tslib": ">2.3.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@klerick/json-api-nestjs-shared": "^1.0.0-beta.
|
|
24
|
+
"@klerick/json-api-nestjs-shared": "^1.0.0-beta.7",
|
|
25
25
|
"ts-toolbelt": "^9.6.0",
|
|
26
26
|
"zod": "^4.1.0",
|
|
27
27
|
"zod-validation-error": "^4.0.0"
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAll = getAll;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
5
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
|
+
const zod_1 = require("zod");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const zod_2 = require("../../zod");
|
|
7
9
|
const constants_1 = require("../../../../constants");
|
|
8
10
|
const error_response_model_1 = require("../error-response-model");
|
|
9
11
|
function getAll(controller, descriptor, entity, mapEntity, methodName) {
|
|
@@ -26,9 +28,7 @@ function getAll(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
26
28
|
name: 'fields',
|
|
27
29
|
required: false,
|
|
28
30
|
style: 'deepObject',
|
|
29
|
-
schema:
|
|
30
|
-
type: 'object',
|
|
31
|
-
},
|
|
31
|
+
schema: zod_1.z.toJSONSchema((0, zod_2.zodFieldsInputQuerySwagger)(mapEntity), utils_1.zodToJSONSchemaParams),
|
|
32
32
|
examples: {
|
|
33
33
|
allField: {
|
|
34
34
|
summary: 'Select all field',
|
|
@@ -56,40 +56,7 @@ function getAll(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
56
56
|
name: 'filter',
|
|
57
57
|
required: false,
|
|
58
58
|
style: 'deepObject',
|
|
59
|
-
schema:
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
...props.reduce((acum, i) => {
|
|
63
|
-
Reflect.set(acum, String(i), {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: Object.keys(json_api_nestjs_shared_1.FilterOperand).reduce((acum, name) => {
|
|
66
|
-
Reflect.set(acum, String(name), {
|
|
67
|
-
type: 'string',
|
|
68
|
-
});
|
|
69
|
-
return acum;
|
|
70
|
-
}, {}),
|
|
71
|
-
minProperties: 1,
|
|
72
|
-
additionalProperties: false,
|
|
73
|
-
});
|
|
74
|
-
return acum;
|
|
75
|
-
}, {}),
|
|
76
|
-
...relationTree.reduce((acum, i) => {
|
|
77
|
-
Reflect.set(acum, String(i), {
|
|
78
|
-
type: 'object',
|
|
79
|
-
properties: Object.keys(json_api_nestjs_shared_1.FilterOperand).reduce((acum, name) => {
|
|
80
|
-
Reflect.set(acum, String(name), {
|
|
81
|
-
type: 'string',
|
|
82
|
-
});
|
|
83
|
-
return acum;
|
|
84
|
-
}, {}),
|
|
85
|
-
minProperties: 1,
|
|
86
|
-
additionalProperties: false,
|
|
87
|
-
});
|
|
88
|
-
return acum;
|
|
89
|
-
}, {}),
|
|
90
|
-
},
|
|
91
|
-
additionalProperties: false,
|
|
92
|
-
},
|
|
59
|
+
schema: zod_1.z.toJSONSchema((0, zod_2.zodFilterInputQuerySwagger)(mapEntity), utils_1.zodToJSONSchemaParams),
|
|
93
60
|
examples: {
|
|
94
61
|
simpleExample: {
|
|
95
62
|
summary: 'Several conditional',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-all.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/get-all.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"get-all.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/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,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,qCAAqC;QAClD,MAAM,EAAE,IAAA,0BAAkB,EAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC;KACpD,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOne = getOne;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
5
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
|
+
const zod_1 = require("zod");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const zod_2 = require("../../zod");
|
|
7
9
|
const types_1 = require("../../../../types");
|
|
8
10
|
const error_response_model_1 = require("../error-response-model");
|
|
9
11
|
function getOne(controller, descriptor, entity, mapEntity, methodName) {
|
|
@@ -28,9 +30,7 @@ function getOne(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
28
30
|
name: 'fields',
|
|
29
31
|
required: false,
|
|
30
32
|
style: 'deepObject',
|
|
31
|
-
schema:
|
|
32
|
-
type: 'object',
|
|
33
|
-
},
|
|
33
|
+
schema: zod_1.z.toJSONSchema((0, zod_2.zodFieldsInputQuerySwagger)(mapEntity), utils_1.zodToJSONSchemaParams),
|
|
34
34
|
examples: {
|
|
35
35
|
allField: {
|
|
36
36
|
summary: 'Select all field',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-one.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/get-one.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"get-one.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/get-one.ts"],"names":[],"mappings":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ACvF,QAAQ,EAAE;gBACR,WAAW,EAAE;oBACX,OAAO,EAAE,kBAAkB;oBAC3B,WAAW,EAAE,kBAAkB;oBAC/B,KAAK,EAAE,SAAS;iBACjB;gBACD,OAAO,EAAE;oBACP,OAAO,EAAE,kBAAkB;oBAC3B,WAAW,EAAE,sBAAsB;oBACnC,KAAK,EAAE,EAAE;iBACV;aACF;SACF,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;IACD,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,qBAAqB,UAAU,aAAa;QACzD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,gDAAyB,CAAC,EAAE;KAC3D,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,wBAAwB;QACrC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,gDAAyB,CAAC,EAAE;KAC3D,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,yCAAyC;QACtD,MAAM,EAAE,IAAA,0BAAkB,EAAC,MAAM,EAAE,SAAS,CAAC;KAC9C,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -2,5 +2,7 @@ import type { JSONSchema } from 'zod/v4/core';
|
|
|
2
2
|
type DateStringTransform<Null extends true | false, isPatch extends true | false> = isPatch extends true ? Null extends true ? Date | null | undefined : Date | undefined : Null extends true ? Date | null | undefined : Date;
|
|
3
3
|
export declare function transformDateString<Null extends true | false, isPatch extends true | false>(i: string | null | undefined): DateStringTransform<Null, isPatch>;
|
|
4
4
|
export declare function transformStringToArray(input: string | undefined): string[] | undefined;
|
|
5
|
+
export declare function transformFilterValueToString(r: string | null | number): string;
|
|
6
|
+
export declare function transformToNull(): null;
|
|
5
7
|
declare const mapTransformFunctionToJsonShema: Map<string, JSONSchema.JSONSchema>;
|
|
6
8
|
export { mapTransformFunctionToJsonShema };
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mapTransformFunctionToJsonShema = void 0;
|
|
4
4
|
exports.transformDateString = transformDateString;
|
|
5
5
|
exports.transformStringToArray = transformStringToArray;
|
|
6
|
+
exports.transformFilterValueToString = transformFilterValueToString;
|
|
7
|
+
exports.transformToNull = transformToNull;
|
|
6
8
|
function transformDateString(i) {
|
|
7
9
|
if (i === null || i === undefined) {
|
|
8
10
|
return i;
|
|
@@ -12,6 +14,12 @@ function transformDateString(i) {
|
|
|
12
14
|
function transformStringToArray(input) {
|
|
13
15
|
return input ? input.split(',') : undefined;
|
|
14
16
|
}
|
|
17
|
+
function transformFilterValueToString(r) {
|
|
18
|
+
return `${r}`;
|
|
19
|
+
}
|
|
20
|
+
function transformToNull() {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
15
23
|
const mapTransformFunctionToJsonShema = new Map([
|
|
16
24
|
[
|
|
17
25
|
transformDateString.name,
|
|
@@ -22,6 +30,8 @@ const mapTransformFunctionToJsonShema = new Map([
|
|
|
22
30
|
},
|
|
23
31
|
],
|
|
24
32
|
[transformStringToArray.name, { type: 'array', items: { type: 'string' } }],
|
|
33
|
+
[transformFilterValueToString.name, { type: 'string' }],
|
|
34
|
+
[transformToNull.name, { type: 'null' }],
|
|
25
35
|
]);
|
|
26
36
|
exports.mapTransformFunctionToJsonShema = mapTransformFunctionToJsonShema;
|
|
27
37
|
//# sourceMappingURL=map-transform-to-json-shema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-transform-to-json-shema.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/map-transform-to-json-shema.ts"],"names":[],"mappings":";;;AAWA,kDASC;AAED,wDAEC;
|
|
1
|
+
{"version":3,"file":"map-transform-to-json-shema.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/map-transform-to-json-shema.ts"],"names":[],"mappings":";;;AAWA,kDASC;AAED,wDAEC;AAED,oEAEC;AAED,0CAEC;AArBD,SAAgB,mBAAmB,CAGjC,CAA4B;IAE5B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAuC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;AACpB,CAAC;AAED,SAAgB,sBAAsB,CAAC,KAAyB;IAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED,SAAgB,4BAA4B,CAAC,CAAyB;IACpE,OAAO,GAAG,CAAC,EAAE,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAgC;IAC7E;QACE,mBAAmB,CAAC,IAAI;QACxB;YACE,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SACrC;KACF;IACD,CAAC,sBAAsB,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;IAC3E,CAAC,4BAA4B,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACvD,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;CACzC,CAAC,CAAC;AAEM,0EAA+B"}
|
|
@@ -5,6 +5,9 @@ declare function getZodRules(): z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTrans
|
|
|
5
5
|
type ZodRule = ReturnType<typeof getZodRules>;
|
|
6
6
|
type CastPropertyKey<T> = T extends PropertyKey ? T : never;
|
|
7
7
|
type ZorRelationType<E extends object, IdKey extends string> = Record<CastPropertyKey<EntityParam<E, IdKey>['relations'][number]>, ZodRule>;
|
|
8
|
+
export declare function zodFieldsInputQuerySwagger<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodOptional<z.ZodObject<{
|
|
9
|
+
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
10
|
+
} & ZorRelationType<E, IdKey>, z.core.$strict>>;
|
|
8
11
|
export declare function zodFieldsInputQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
9
12
|
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
10
13
|
} & ZorRelationType<E, IdKey>, z.core.$strict>>, z.ZodTransform<Awaited<z.core.$InferObjectOutput<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zodFieldsInputQuerySwagger = zodFieldsInputQuerySwagger;
|
|
3
4
|
exports.zodFieldsInputQuery = zodFieldsInputQuery;
|
|
4
5
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
5
6
|
const zod_1 = require("zod");
|
|
@@ -11,13 +12,13 @@ function getZodRules() {
|
|
|
11
12
|
.optional()
|
|
12
13
|
.transform(map_transform_to_json_shema_1.transformStringToArray);
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function zodFieldsInputQuerySwagger(entityParamMapService) {
|
|
15
16
|
const { relations } = entityParamMapService.entityParaMap;
|
|
16
17
|
const relation = relations.reduce((acum, item) => ({
|
|
17
18
|
...acum,
|
|
18
19
|
[item]: getZodRules(),
|
|
19
20
|
}), {});
|
|
20
|
-
return
|
|
21
|
+
return zod_1.z
|
|
21
22
|
.strictObject({
|
|
22
23
|
target: getZodRules(),
|
|
23
24
|
...relation,
|
|
@@ -25,15 +26,17 @@ function zodFieldsInputQuery(entityParamMapService) {
|
|
|
25
26
|
error: (err) => err.code === 'unrecognized_keys'
|
|
26
27
|
? (0, zod_utils_1.getValidationErrorForStrict)([
|
|
27
28
|
'target',
|
|
28
|
-
...entityParamMapService.entityParaMap
|
|
29
|
-
.relations,
|
|
29
|
+
...entityParamMapService.entityParaMap.relations,
|
|
30
30
|
], 'Fields')
|
|
31
31
|
: err.message,
|
|
32
32
|
})
|
|
33
33
|
.refine((0, zod_utils_1.nonEmptyObject)(), {
|
|
34
34
|
message: 'Validation error: Need select field for target or relation',
|
|
35
35
|
})
|
|
36
|
-
.optional()
|
|
36
|
+
.optional();
|
|
37
|
+
}
|
|
38
|
+
function zodFieldsInputQuery(entityParamMapService) {
|
|
39
|
+
return zodFieldsInputQuerySwagger(entityParamMapService)
|
|
37
40
|
.transform((input) => {
|
|
38
41
|
if (!input)
|
|
39
42
|
return null;
|
|
@@ -47,6 +50,6 @@ function zodFieldsInputQuery(entityParamMapService) {
|
|
|
47
50
|
};
|
|
48
51
|
}, {});
|
|
49
52
|
return Object.keys(result).length > 0 ? result : null;
|
|
50
|
-
})
|
|
53
|
+
});
|
|
51
54
|
}
|
|
52
55
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-query-schema/fields.ts"],"names":[],"mappings":";;AAmBA,
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../../../../../libs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AAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAC9C,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YAChB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAiE,CAAC;YAEvF,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAE9C,OAAO;gBACL,GAAG,IAAI;gBACP,CAAC,GAAG,CAAC,EAAE,KAAK;aACb,CAAC;QACJ,CAAC,EACD,EAAkB,CACnB,CAAC;QAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -29,7 +29,60 @@ export type ConcatRelationField<E extends object, IdKey extends string> = UnionT
|
|
|
29
29
|
}[keyof EntityRelationProps<E, IdKey>]>;
|
|
30
30
|
export type ShapeArrayInput<E extends object, IdKey extends string> = EntityParam<E, IdKey>['props'] | EntityParam<E, IdKey>['relations'] | ConcatRelationField<E, IdKey>;
|
|
31
31
|
export declare function shapeForArray<E extends object, Z extends ZodType, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>>(fields: PropsList, zodSchema: Z): Record<CastPropertyKey<PropsList[number]>, Z>;
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function zodFilterInputQuerySwagger<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodOptional<z.ZodObject<{ [Id in IdKey]: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
33
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
34
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
35
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
36
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
37
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
38
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
39
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
40
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
41
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
42
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
43
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
44
|
+
}, z.core.$strict>]>>; } & Record<CastPropertyKey<UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number]>, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
45
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
46
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
47
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
48
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
49
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
50
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
51
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
52
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
53
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
54
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
55
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
56
|
+
}, z.core.$strict>]>>> & Record<CastPropertyKey<UnionToTuple<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>, import("ts-toolbelt/out/Union/Last").Last<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>>, [import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>] extends [never] ? true : false>[number]>, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
57
|
+
eq: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
ne: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
60
|
+
}, z.core.$strict>]>>> & Record<CastPropertyKey<UnionToTuple<{ [K_1 in keyof EntityRelationProps<E, IdKey>]: `${K_1}.${EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">], import("ts-toolbelt/out/Union/Last").Last<{ [K_1 in keyof EntityRelationProps<E, IdKey>]: `${K_1}.${EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]>, [{ [K_1 in keyof EntityRelationProps<E, IdKey>]: `${K_1}.${EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]] extends [never] ? true : false>[number]>, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
61
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
62
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
63
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
64
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
65
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
66
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
67
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
68
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
69
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
70
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
71
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
72
|
+
}, z.core.$strict>]>>> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>>;
|
|
73
|
+
export declare function zodFilterInputQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodPipe<z.ZodOptional<z.ZodObject<{ [Id in IdKey]: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
74
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
75
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
76
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
77
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
78
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
79
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
80
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
81
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
82
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
83
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
84
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
85
|
+
}, z.core.$strict>]>>; } & Record<CastPropertyKey<UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number]>, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
33
86
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
34
87
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
35
88
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -57,7 +110,19 @@ export declare function zodFilterInputQuery<E extends object, IdKey extends stri
|
|
|
57
110
|
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
58
111
|
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
59
112
|
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
60
|
-
}, z.core.$strict>]>>> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>>, z.ZodTransform<OutPutFilter, z.core.$InferObjectOutput<
|
|
113
|
+
}, z.core.$strict>]>>> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>>, z.ZodTransform<OutPutFilter, z.core.$InferObjectOutput<{ [Id in IdKey]: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
114
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
115
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
116
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
117
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
118
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
119
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
120
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
121
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
122
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
123
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
124
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
125
|
+
}, z.core.$strict>]>>; } & Record<CastPropertyKey<UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number]>, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
61
126
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
62
127
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
63
128
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shapeForArray = shapeForArray;
|
|
4
|
+
exports.zodFilterInputQuerySwagger = zodFilterInputQuerySwagger;
|
|
4
5
|
exports.zodFilterInputQuery = zodFilterInputQuery;
|
|
5
6
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
7
|
const zod_1 = require("zod");
|
|
7
8
|
const zod_utils_1 = require("../zod-utils");
|
|
9
|
+
const map_transform_to_json_shema_1 = require("../map-transform-to-json-shema");
|
|
8
10
|
const arrayOp = {
|
|
9
11
|
[json_api_nestjs_shared_1.FilterOperand.in]: true,
|
|
10
12
|
[json_api_nestjs_shared_1.FilterOperand.nin]: true,
|
|
@@ -31,7 +33,7 @@ function convertToFilterObject(value) {
|
|
|
31
33
|
function getZodRulesForFilterOperator() {
|
|
32
34
|
const filterConditional = zod_1.z
|
|
33
35
|
.union([zod_1.z.string().refine((0, zod_utils_1.stringLongerThan)()), zod_1.z.null(), zod_1.z.number()])
|
|
34
|
-
.transform(
|
|
36
|
+
.transform(map_transform_to_json_shema_1.transformFilterValueToString);
|
|
35
37
|
const conditional = zod_1.z
|
|
36
38
|
.object(json_api_nestjs_shared_1.ObjectTyped.values(json_api_nestjs_shared_1.FilterOperand).reduce((acum, item) => {
|
|
37
39
|
acum[item] = filterConditional;
|
|
@@ -52,14 +54,14 @@ function getZodRulesForRelation() {
|
|
|
52
54
|
.object({
|
|
53
55
|
[json_api_nestjs_shared_1.FilterOperand.eq]: zod_1.z
|
|
54
56
|
.union([zod_1.z.literal('null'), zod_1.z.null()])
|
|
55
|
-
.transform(
|
|
57
|
+
.transform(map_transform_to_json_shema_1.transformToNull),
|
|
56
58
|
})
|
|
57
59
|
.strict(),
|
|
58
60
|
zod_1.z
|
|
59
61
|
.object({
|
|
60
62
|
[json_api_nestjs_shared_1.FilterOperand.ne]: zod_1.z
|
|
61
63
|
.union([zod_1.z.literal('null'), zod_1.z.null()])
|
|
62
|
-
.transform(
|
|
64
|
+
.transform(map_transform_to_json_shema_1.transformToNull),
|
|
63
65
|
})
|
|
64
66
|
.strict(),
|
|
65
67
|
])
|
|
@@ -82,17 +84,32 @@ function shapeForArray(fields, zodSchema) {
|
|
|
82
84
|
[item]: zodSchema,
|
|
83
85
|
}), {});
|
|
84
86
|
}
|
|
85
|
-
function
|
|
86
|
-
const target =
|
|
87
|
+
function zodFilterInputQuerySwagger(entityParamMapService) {
|
|
88
|
+
const target = {
|
|
89
|
+
...{
|
|
90
|
+
[entityParamMapService.entityParaMap.primaryColumnName]: zodRulesForFilterOperator,
|
|
91
|
+
},
|
|
92
|
+
...shapeForArray(entityParamMapService.entityParaMap.props, zodRulesForFilterOperator),
|
|
93
|
+
};
|
|
87
94
|
const relations = shapeForArray(entityParamMapService.entityParaMap.relations, zodRulesForRelation);
|
|
88
95
|
const relationList = (0, zod_utils_1.getRelationProps)(entityParamMapService);
|
|
96
|
+
const relationPrimaryName = (0, zod_utils_1.getRelationPrimaryName)(entityParamMapService);
|
|
97
|
+
for (const [key, val] of json_api_nestjs_shared_1.ObjectTyped.entries(relationPrimaryName)) {
|
|
98
|
+
if (relationList[key].includes(val))
|
|
99
|
+
continue;
|
|
100
|
+
relationList[key].push(val);
|
|
101
|
+
}
|
|
89
102
|
const relationFields = shapeForArray(getTupleConcatRelationFields(relationList), zodRulesForFilterOperator);
|
|
90
|
-
return zod_1.z
|
|
103
|
+
return zod_1.z
|
|
104
|
+
.object({
|
|
91
105
|
...target,
|
|
92
106
|
...relations,
|
|
93
|
-
...relationFields
|
|
107
|
+
...relationFields,
|
|
94
108
|
})
|
|
95
|
-
.optional()
|
|
109
|
+
.optional();
|
|
110
|
+
}
|
|
111
|
+
function zodFilterInputQuery(entityParamMapService) {
|
|
112
|
+
return zodFilterInputQuerySwagger(entityParamMapService)
|
|
96
113
|
.transform((data) => {
|
|
97
114
|
if (!data) {
|
|
98
115
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-query-schema/filter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-query-schema/filter.ts"],"names":[],"mappings":";;AAmIA,sCAgBC;AAED,gEA4CC;AAED,kDAiCC;AApOD,4EAIyC;AACzC,6BAAiC;AAGjC,4CAAiG;AACjG,gFAA+F;AAgB/F,MAAM,OAAO,GAAG;IACd,CAAC,sCAAa,CAAC,EAAE,CAAC,EAAE,IAAI;IACxB,CAAC,sCAAa,CAAC,GAAG,CAAC,EAAE,IAAI;IACzB,CAAC,sCAAa,CAAC,IAAI,CA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UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvD,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;YACxC,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAkB,CACjD,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { EntityParamMapService } from '../../service';
|
|
3
|
-
import { zodFieldsInputQuery } from './fields';
|
|
4
|
-
|
|
3
|
+
import { zodFieldsInputQuery, zodFieldsInputQuerySwagger } from './fields';
|
|
4
|
+
import { zodFilterInputQuerySwagger } from './filter';
|
|
5
|
+
export { zodFieldsInputQuery, zodFieldsInputQuerySwagger, zodFilterInputQuerySwagger };
|
|
5
6
|
export declare function zodInputQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodObject<{
|
|
6
7
|
fields: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
7
8
|
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
@@ -10,7 +11,19 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
10
11
|
} & { [P in import("../../../../types").UnionToTuple<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>, import("ts-toolbelt/out/Union/Last").Last<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>>, [import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>] extends [never] ? true : false>[number] extends infer T_1 ? T_1 extends import("../../../../types").UnionToTuple<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>, import("ts-toolbelt/out/Union/Last").Last<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>>, [import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>] extends [never] ? true : false>[number] ? T_1 extends PropertyKey ? T_1 : never : never : never]: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>; }, {}>> | null, z.core.$InferObjectOutput<{
|
|
11
12
|
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
12
13
|
} & { [P in import("../../../../types").UnionToTuple<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>, import("ts-toolbelt/out/Union/Last").Last<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>>, [import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>] extends [never] ? true : false>[number] extends infer T_2 ? T_2 extends import("../../../../types").UnionToTuple<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>, import("ts-toolbelt/out/Union/Last").Last<import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>>, [import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey>] extends [never] ? true : false>[number] ? T_2 extends PropertyKey ? T_2 : never : never : never]: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>; }, {}> | undefined>>;
|
|
13
|
-
filter: z.ZodPipe<z.ZodOptional<z.ZodObject<
|
|
14
|
+
filter: z.ZodPipe<z.ZodOptional<z.ZodObject<{ [Id in IdKey]: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
15
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
16
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
17
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
18
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
19
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
20
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
21
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
22
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
23
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
24
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
25
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
26
|
+
}, z.core.$strict>]>>; } & Record<import("../../../../types").UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number] extends infer T_4 ? T_4 extends import("../../../../types").UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number] ? T_4 extends PropertyKey ? T_4 : never : never : never, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
14
27
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
15
28
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
16
29
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -65,7 +78,19 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
65
78
|
nin: string | string[];
|
|
66
79
|
some: string | string[];
|
|
67
80
|
}>>;
|
|
68
|
-
}, z.core.$InferObjectOutput<
|
|
81
|
+
}, z.core.$InferObjectOutput<{ [Id in IdKey]: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
82
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
83
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
84
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
85
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
86
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
87
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
88
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
89
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
90
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
91
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
92
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
93
|
+
}, z.core.$strict>]>>; } & Record<import("../../../../types").UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number] extends infer T_8 ? T_8 extends import("../../../../types").UnionToTuple<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>, import("ts-toolbelt/out/Union/Last").Last<Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>>, [Exclude<Exclude<Extract<keyof E, string>, import("@klerick/json-api-nestjs-shared").RelationKeys<E, IdKey> | { [K in Extract<keyof E, string>]: E[K] extends Function ? K : never; }[Extract<keyof E, string>]>, IdKey>] extends [never] ? true : false>[number] ? T_8 extends PropertyKey ? T_8 : never : never : never, z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>, z.ZodObject<{
|
|
69
94
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
70
95
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
71
96
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zodFieldsInputQuery = void 0;
|
|
3
|
+
exports.zodFilterInputQuerySwagger = exports.zodFieldsInputQuerySwagger = exports.zodFieldsInputQuery = void 0;
|
|
4
4
|
exports.zodInputQuery = zodInputQuery;
|
|
5
5
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
7
|
const fields_1 = require("./fields");
|
|
8
8
|
Object.defineProperty(exports, "zodFieldsInputQuery", { enumerable: true, get: function () { return fields_1.zodFieldsInputQuery; } });
|
|
9
|
+
Object.defineProperty(exports, "zodFieldsInputQuerySwagger", { enumerable: true, get: function () { return fields_1.zodFieldsInputQuerySwagger; } });
|
|
9
10
|
const filter_1 = require("./filter");
|
|
11
|
+
Object.defineProperty(exports, "zodFilterInputQuerySwagger", { enumerable: true, get: function () { return filter_1.zodFilterInputQuerySwagger; } });
|
|
10
12
|
const include_1 = require("./include");
|
|
11
13
|
const sort_1 = require("./sort");
|
|
12
14
|
const zod_share_1 = require("../zod-share");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-query-schema/index.ts"],"names":[],"mappings":";;;AAYA,sCAeC;AA3BD,4EAA6D;AAC7D,6BAAwB;AAGxB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-query-schema/index.ts"],"names":[],"mappings":";;;AAYA,sCAeC;AA3BD,4EAA6D;AAC7D,6BAAwB;AAGxB,qCAA2E;AAMlE,oGANA,4BAAmB,OAMA;AAAE,2GANA,mCAA0B,OAMA;AALxD,qCAA2E;AAKjB,2GAL5B,mCAA0B,OAK4B;AAJpF,uCAAiD;AACjD,iCAA2C;AAC3C,4CAAiD;AAIjD,SAAgB,aAAa,CAC3B,qBAAsD;IAEtD,OAAO,OAAC;SACL,YAAY,CAAC;QACZ,CAAC,mCAAU,CAAC,MAAM,CAAC,EAAE,IAAA,4BAAmB,EAAW,qBAAqB,CAAC;QACzE,CAAC,mCAAU,CAAC,MAAM,CAAC,EAAE,IAAA,4BAAmB,EAAW,qBAAqB,CAAC;QACzE,CAAC,mCAAU,CAAC,OAAO,CAAC,EAAE,IAAA,8BAAoB,GAAE;QAC5C,CAAC,mCAAU,CAAC,IAAI,CAAC,EAAE,IAAA,wBAAiB,GAAE;QACtC,CAAC,mCAAU,CAAC,IAAI,CAAC,EAAE,IAAA,6BAAiB,GAAE;KACvC,EAAE;QACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,mDAAmD,MAAM,CAAC,IAAI,CAC/G,mCAAU,CACX,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO;KAC/B,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { EntityParam, EntityRelationProps, NonEmptyStringTuple } from '../../../../types';
|
|
3
3
|
import { EntityParamMapService } from '../../service';
|
|
4
|
-
declare function getZodFieldRule<E extends object, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>>(fields: PropsList): z.ZodOptional<z.ZodArray<z.ZodEnum<{ [k_1 in NonEmptyStringTuple<PropsList>[number]]: k_1; } extends infer T ? { [k in keyof T]: T[k]; } : never>>>;
|
|
4
|
+
declare function getZodFieldRule<E extends object, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>>(fields: PropsList, id: IdKey): z.ZodOptional<z.ZodArray<z.ZodEnum<{ [k_1 in NonEmptyStringTuple<PropsList>[number]]: k_1; } extends infer T ? { [k in keyof T]: T[k]; } : never>>>;
|
|
5
5
|
type ShapeArrayInput<E extends object, IdKey extends string> = EntityParam<E, IdKey>['props'] | EntityRelationProps<E, IdKey>[keyof EntityRelationProps<E, IdKey>];
|
|
6
6
|
type ZodFieldRule<E extends object, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>> = ReturnType<typeof getZodFieldRule<E, IdKey, PropsList>>;
|
|
7
7
|
export type ZodFieldsShape<E extends object, IdKey extends string> = {
|
|
@@ -4,8 +4,8 @@ exports.zodFieldsQuery = zodFieldsQuery;
|
|
|
4
4
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const zod_utils_1 = require("../zod-utils");
|
|
7
|
-
function getZodFieldRule(fields) {
|
|
8
|
-
const fieldsProps = fields;
|
|
7
|
+
function getZodFieldRule(fields, id) {
|
|
8
|
+
const fieldsProps = [...fields, id];
|
|
9
9
|
return zod_1.z
|
|
10
10
|
.enum(fieldsProps)
|
|
11
11
|
.array()
|
|
@@ -17,11 +17,12 @@ function getZodFieldRule(fields) {
|
|
|
17
17
|
}
|
|
18
18
|
function getShapeFields(entityParamMapService) {
|
|
19
19
|
const relationList = (0, zod_utils_1.getRelationProps)(entityParamMapService);
|
|
20
|
+
const relationListPrimaryName = (0, zod_utils_1.getRelationPrimaryName)(entityParamMapService);
|
|
20
21
|
const fieldShape = json_api_nestjs_shared_1.ObjectTyped.entries(relationList).reduce((acum, [key, val]) => ({
|
|
21
22
|
...acum,
|
|
22
|
-
[key]: getZodFieldRule(val),
|
|
23
|
+
[key]: getZodFieldRule(val, relationListPrimaryName[key]),
|
|
23
24
|
}), {
|
|
24
|
-
target: getZodFieldRule(entityParamMapService.entityParaMap.props),
|
|
25
|
+
target: getZodFieldRule(entityParamMapService.entityParaMap.props, entityParamMapService.entityParaMap.primaryColumnName),
|
|
25
26
|
});
|
|
26
27
|
return zod_1.z.strictObject(fieldShape, {
|
|
27
28
|
error: (err) => err.code === 'unrecognized_keys'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/fields.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/fields.ts"],"names":[],"mappings":";;AA+EA,wCAQC;AAvFD,4EAA8D;AAC9D,6BAAmC;AAEnC,4CAKsB;AAQtB,SAAS,eAAe,CAItB,MAAiB,EAAE,EAAS;IAC5B,MAAM,WAAW,GAAmC,CAAC,GAAG,MAAM,EAAE,EAAE,CAAQ,CAAC;IAE3E,OAAO,OAAC;SACL,IAAI,CAAC,WAAW,CAAC;SACjB,KAAK,EAAE;SACP,QAAQ,EAAE;SACV,MAAM,CAAC,IAAA,uBAAW,GAAE,EAAE;QACrB,KAAK,EAAE,wBAAwB;KAChC,CAAC;SACD,QAAQ,EAAE,CAAC;AAChB,CAAC;AAsBD,SAAS,cAAc,CACrB,qBAAsD;IAEtD,MAAM,YAAY,GAAG,IAAA,4BAAgB,EAAC,qBAAqB,CAAC,CAAC;IAC7D,MAAM,uBAAuB,GAAG,IAAA,kCAAsB,EAAC,qBAAqB,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,oCAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CACzD,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACrB,GAAG,IAAI;QACP,CAAC,GAAkB,CAAC,EAAE,eAAe,CAAuB,GAAG,EAAE,uBAAuB,CAAC,GAAG,CAAU,CAAC;KACxG,CAAC,EACF;QACE,MAAM,EAAE,eAAe,CACrB,qBAAqB,CAAC,aAAa,CAAC,KAAK,EACzC,qBAAqB,CAAC,aAAa,CAAC,iBAAiB,CACtD;KAC0B,CAC9B,CAAC;IAEF,OAAO,OAAC,CAAC,YAAY,CAAC,UAAU,EAAE;QAChC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,CAAC,IAAI,KAAK,mBAAmB;YAC9B,CAAC,CAAC,mCAAmC;YACrC,CAAC,CAAC,GAAG,CAAC,OAAO;KAClB,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAC5B,qBAAsD;IAEtD,OAAO,cAAc,CAAC,qBAAqB,CAAC;SACzC,MAAM,CAAC,IAAA,0BAAc,GAAE,EAAE;QACxB,OAAO,EAAE,oDAAoD;KAC9D,CAAC;SACD,QAAQ,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -33,6 +33,8 @@ type RelationFilterProps<E extends object, IdKey extends string> = {
|
|
|
33
33
|
};
|
|
34
34
|
export type FilterProps<E extends object, IdKey extends string> = {
|
|
35
35
|
[Props in EntityParam<E, IdKey>['props'][number] & PropertyKey]: Props extends keyof E ? E[Props] extends TypeField.array ? ZodOptional<ZodRuleForArrayField> : ZodOptional<ZodRulesForField> : never;
|
|
36
|
+
} & {
|
|
37
|
+
[id in EntityParam<E, IdKey>['primaryColumnName']]?: ZodOptional<ZodRulesForField>;
|
|
36
38
|
};
|
|
37
39
|
type TargetRelationShape<E extends object, IdKey extends string> = {
|
|
38
40
|
[Props in EntityParam<E, IdKey>['relations'][number] & PropertyKey]: ZodOptional<ZodRuleFilterRelationSchema>;
|
|
@@ -100,7 +100,9 @@ function getFilterPropsShapeForEntity(entityParam) {
|
|
|
100
100
|
: getZodRulesForFieldUsingCache(propertyType);
|
|
101
101
|
Reflect.set(acum, field, value.optional());
|
|
102
102
|
return acum;
|
|
103
|
-
}, {
|
|
103
|
+
}, {
|
|
104
|
+
[entityParam.primaryColumnName]: getZodRulesForFieldUsingCache(entityParam.primaryColumnType).optional()
|
|
105
|
+
});
|
|
104
106
|
}
|
|
105
107
|
function zodFilterQuery(entityParamMapService) {
|
|
106
108
|
const targetResult = entityParamMapService.entityParaMap.relations.reduce((acum, item) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/filter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/filter.ts"],"names":[],"mappings":";;AAqNA,wCA+CC;AApQD,4EAKyC;AACzC,6BAAqC;AAGrC,6CAA8E;AAC9E,4CAOsB;AAEtB,MAAM,gBAAgB,GAAG,OAAC,CAAC,KAAK,CAAC;IAC/B,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IACvC,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAA,4BAAgB,GAAE,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CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -5,7 +5,7 @@ declare function getZodSortRule(): z.ZodOptional<z.ZodEnum<{
|
|
|
5
5
|
DESC: "DESC";
|
|
6
6
|
ASC: "ASC";
|
|
7
7
|
}>>;
|
|
8
|
-
declare function getZodFieldRule<E extends object, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>>(fields: PropsList, zodSchema: ZodSortRule): z.ZodOptional<z.ZodObject<{ [K in PropsList[number] & PropertyKey]: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
declare function getZodFieldRule<E extends object, IdKey extends string, PropsList extends ShapeArrayInput<E, IdKey>>(fields: PropsList, zodSchema: ZodSortRule, idKey: IdKey): z.ZodOptional<z.ZodObject<{ [K in (IdKey | PropsList[number]) & PropertyKey]: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
DESC: "DESC";
|
|
10
10
|
ASC: "ASC";
|
|
11
11
|
}>>; } extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strict>>;
|
|
@@ -8,21 +8,22 @@ const zod_utils_1 = require("../zod-utils");
|
|
|
8
8
|
function getZodSortRule() {
|
|
9
9
|
return zod_1.z.enum(constants_1.SORT_TYPE).optional();
|
|
10
10
|
}
|
|
11
|
-
function getZodFieldRule(fields, zodSchema) {
|
|
11
|
+
function getZodFieldRule(fields, zodSchema, idKey) {
|
|
12
12
|
const targetShape = fields.reduce((acum, item) => ({
|
|
13
13
|
...acum,
|
|
14
14
|
[item]: zodSchema,
|
|
15
|
-
}), {});
|
|
15
|
+
}), { [idKey]: zodSchema });
|
|
16
16
|
return zod_1.z.object(targetShape).strict().refine((0, zod_utils_1.nonEmptyObject)()).optional();
|
|
17
17
|
}
|
|
18
18
|
function zodSortObject(entityParamMapService) {
|
|
19
19
|
const zodSortRule = getZodSortRule();
|
|
20
20
|
const relationList = (0, zod_utils_1.getRelationProps)(entityParamMapService);
|
|
21
|
+
const relationListPrimaryName = (0, zod_utils_1.getRelationPrimaryName)(entityParamMapService);
|
|
21
22
|
const sortShape = json_api_nestjs_shared_1.ObjectTyped.entries(relationList).reduce((acum, [key, val]) => ({
|
|
22
23
|
...acum,
|
|
23
|
-
[key]: getZodFieldRule(val, zodSortRule),
|
|
24
|
+
[key]: getZodFieldRule(val, zodSortRule, relationListPrimaryName[key]),
|
|
24
25
|
}), {
|
|
25
|
-
target: getZodFieldRule(entityParamMapService.entityParaMap.props, zodSortRule),
|
|
26
|
+
target: getZodFieldRule(entityParamMapService.entityParaMap.props, zodSortRule, entityParamMapService.entityParaMap.primaryColumnName),
|
|
26
27
|
});
|
|
27
28
|
return zod_1.z.strictObject(sortShape);
|
|
28
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/sort.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/sort.ts"],"names":[],"mappings":";;AAuFA,oCAOC;AA9FD,4EAA8D;AAC9D,6BAAmC;AAGnC,qDAAkD;AAClD,4CAIsB;AAGtB,SAAS,cAAc;IACrB,OAAO,OAAC,CAAC,IAAI,CAAC,qBAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAItB,MAAiB,EAAE,SAAsB,EAAE,KAAY;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAC/B,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACf,GAAG,IAAI;QACP,CAAC,IAAmB,CAAC,EAAE,SAAS;KACjC,CAAC,EACF,EAAC,CAAC,KAAK,CAAC,EAAE,SAAS,EAAsE,CAC1F,CAAC;IAEF,OAAO,OAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC5E,CAAC;AA8BD,SAAS,aAAa,CACpB,qBAAsD;IAEtD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAG,IAAA,4BAAgB,EAAC,qBAAqB,CAAC,CAAC;IAC7D,MAAM,uBAAuB,GAAG,IAAA,kCAAsB,EAAC,qBAAqB,CAAC,CAAC;IAE9E,MAAM,SAAS,GAAG,oCAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CACxD,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACrB,GAAG,IAAI;QACP,CAAC,GAAkB,CAAC,EAAE,eAAe,CACnC,GAAG,EACH,WAAW,EACX,uBAAuB,CAAC,GAAG,CAAC,CAC7B;KACF,CAAC,EACF;QACE,MAAM,EAAE,eAAe,CACrB,qBAAqB,CAAC,aAAa,CAAC,KAAK,EACzC,WAAW,EACX,qBAAqB,CAAC,aAAa,CAAC,iBAAiB,CACtD;KACwB,CAC5B,CAAC;IACF,OAAO,OAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;AAClC,CAAC;AAED,SAAgB,YAAY,CAC1B,qBAAsD;IAEtD,OAAO,aAAa,CAAC,qBAAqB,CAAC;SACxC,OAAO,EAAE;SACT,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC;SACxB,QAAQ,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -12,5 +12,6 @@ export declare const stringMustBe: (type?: TypeField) => (inputString: string |
|
|
|
12
12
|
export declare const elementOfArrayMustBe: (type?: TypeField) => (inputArray: unknown[]) => boolean;
|
|
13
13
|
export declare function guardIsKeyOfObject<R>(object: R, key: string | number | symbol): asserts key is keyof R;
|
|
14
14
|
export declare function getRelationProps<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): EntityRelationProps<E, IdKey>;
|
|
15
|
+
export declare function getRelationPrimaryName<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): { [K in keyof EntityRelationProps<E, IdKey>]: IdKey; };
|
|
15
16
|
export declare function setOptionalOrNot<Schema extends ZodType, Null extends true | false, isPatch extends true | false>(schema: Schema, isNullable: Null, isPatch: isPatch): ResultSchema<Schema, Null, isPatch>;
|
|
16
17
|
export declare function memoize<T extends (...args: any[]) => any>(fn: T): T;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.elementOfArrayMustBe = exports.stringMustBe = exports.arrayItemStringLongerThan = exports.stringLongerThan = exports.oneOf = exports.getValidationErrorForStrict = exports.uniqueArray = exports.nonEmptyObject = void 0;
|
|
4
4
|
exports.guardIsKeyOfObject = guardIsKeyOfObject;
|
|
5
5
|
exports.getRelationProps = getRelationProps;
|
|
6
|
+
exports.getRelationPrimaryName = getRelationPrimaryName;
|
|
6
7
|
exports.setOptionalOrNot = setOptionalOrNot;
|
|
7
8
|
exports.memoize = memoize;
|
|
8
9
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
@@ -62,6 +63,13 @@ function getRelationProps(entityParamMapService) {
|
|
|
62
63
|
return acum;
|
|
63
64
|
}, {});
|
|
64
65
|
}
|
|
66
|
+
function getRelationPrimaryName(entityParamMapService) {
|
|
67
|
+
return json_api_nestjs_shared_1.ObjectTyped.entries(entityParamMapService.entityParaMap.relationProperty).reduce((acum, [name, value]) => {
|
|
68
|
+
const relMap = entityParamMapService.getParamMap(value.entityClass);
|
|
69
|
+
Reflect.set(acum, name, relMap.primaryColumnName);
|
|
70
|
+
return acum;
|
|
71
|
+
}, {});
|
|
72
|
+
}
|
|
65
73
|
function setOptionalOrNot(schema, isNullable, isPatch) {
|
|
66
74
|
if (isPatch) {
|
|
67
75
|
return (isNullable ? schema.nullable() : schema).optional();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-utils.ts"],"names":[],"mappings":";;;AAkEA,gDAQC;AAED,4CAUC;AAED,4CAsBC;AAED,0BASC;
|
|
1
|
+
{"version":3,"file":"zod-utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-utils.ts"],"names":[],"mappings":";;;AAkEA,gDAQC;AAED,4CAUC;AAED,wDAkBC;AAED,4CAsBC;AAED,0BASC;AA7ID,4EAA4E;AAI5E,0CAA+F;AAIxF,MAAM,cAAc,GACzB,GAAG,EAAE,CACH,CAAI,MAAS,EAAE,EAAE,CACf,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAHpE,QAAA,cAAc,kBAGsD;AAE1E,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,CAAC;AAAlE,QAAA,WAAW,eAAuD;AAExE,MAAM,2BAA2B,GAAG,CACzC,KAAe,EACf,IAAyB,EACzB,EAAE,CACF,qBAAqB,IAAI,iCAAiC,KAAK,CAAC,IAAI,CAClE,KAAK,CACN,IAAI,CAAC;AANK,QAAA,2BAA2B,+BAMhC;AAED,MAAM,KAAK,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,CAAC,GAAQ,EAAE,EAAE;IACpD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CA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