@klerick/json-api-nestjs 10.0.0-beta.8 → 10.0.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/CHANGELOG.md +167 -0
- package/README.md +299 -23
- package/package.json +4 -8
- package/src/index.d.ts +2 -2
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lib/constants/di.d.ts +1 -0
- package/src/lib/constants/di.js +2 -1
- package/src/lib/constants/di.js.map +1 -1
- package/src/lib/json-api.module.js +3 -2
- package/src/lib/json-api.module.js.map +1 -1
- package/src/lib/modules/atomic-operation/atomic-operation.module.d.ts +1 -2
- package/src/lib/modules/atomic-operation/atomic-operation.module.js +6 -5
- package/src/lib/modules/atomic-operation/atomic-operation.module.js.map +1 -1
- package/src/lib/modules/atomic-operation/controllers/operation.controller.js +4 -4
- package/src/lib/modules/atomic-operation/controllers/operation.controller.js.map +1 -1
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.d.ts +1 -2
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.js +8 -7
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.js.map +1 -1
- package/src/lib/modules/atomic-operation/pipes/input-operation.pipe.js.map +1 -1
- package/src/lib/modules/atomic-operation/service/execute.service.d.ts +13 -3
- package/src/lib/modules/atomic-operation/service/execute.service.js +80 -33
- package/src/lib/modules/atomic-operation/service/execute.service.js.map +1 -1
- package/src/lib/modules/atomic-operation/service/explorer.service.js +10 -6
- package/src/lib/modules/atomic-operation/service/explorer.service.js.map +1 -1
- package/src/lib/modules/atomic-operation/service/swagger.service.js +6 -6
- package/src/lib/modules/atomic-operation/service/swagger.service.js.map +1 -1
- package/src/lib/modules/atomic-operation/utils/zod/zod-helper.d.ts +14 -7
- package/src/lib/modules/atomic-operation/utils/zod/zod-helper.js +12 -9
- package/src/lib/modules/atomic-operation/utils/zod/zod-helper.js.map +1 -1
- package/src/lib/modules/mixin/config/bindings.js +20 -0
- package/src/lib/modules/mixin/config/bindings.js.map +1 -1
- package/src/lib/modules/mixin/controllers/json-base.controller.d.ts +5 -5
- package/src/lib/modules/mixin/controllers/json-base.controller.js +5 -5
- package/src/lib/modules/mixin/controllers/json-base.controller.js.map +1 -1
- package/src/lib/modules/mixin/decorators/index.d.ts +1 -0
- package/src/lib/modules/mixin/decorators/index.js +1 -0
- package/src/lib/modules/mixin/decorators/index.js.map +1 -1
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.d.ts +19 -0
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.js +35 -0
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.js.map +1 -0
- package/src/lib/modules/mixin/factory/zod-validate.factory.d.ts +2 -1
- package/src/lib/modules/mixin/factory/zod-validate.factory.js +5 -1
- package/src/lib/modules/mixin/factory/zod-validate.factory.js.map +1 -1
- package/src/lib/modules/mixin/helpers/bind-controller.js +4 -1
- package/src/lib/modules/mixin/helpers/bind-controller.js.map +1 -1
- package/src/lib/modules/mixin/helpers/utils.d.ts +2 -0
- package/src/lib/modules/mixin/helpers/utils.js +10 -0
- package/src/lib/modules/mixin/helpers/utils.js.map +1 -1
- package/src/lib/modules/mixin/mixin.module.js +1 -0
- package/src/lib/modules/mixin/mixin.module.js.map +1 -1
- package/src/lib/modules/mixin/pipe/index.d.ts +1 -0
- package/src/lib/modules/mixin/pipe/index.js +5 -0
- package/src/lib/modules/mixin/pipe/index.js.map +1 -1
- package/src/lib/modules/mixin/pipe/meta-extractor/index.d.ts +1 -0
- package/src/lib/modules/mixin/pipe/meta-extractor/index.js +5 -0
- package/src/lib/modules/mixin/pipe/meta-extractor/index.js.map +1 -0
- package/src/lib/modules/mixin/pipe/meta-extractor/meta-extractor.pipe.d.ts +6 -0
- package/src/lib/modules/mixin/pipe/meta-extractor/meta-extractor.pipe.js +27 -0
- package/src/lib/modules/mixin/pipe/meta-extractor/meta-extractor.pipe.js.map +1 -0
- package/src/lib/modules/mixin/service/json-api-transformer.service.d.ts +2 -2
- package/src/lib/modules/mixin/service/json-api-transformer.service.js.map +1 -1
- package/src/lib/modules/mixin/swagger/error-response-model.d.ts +11 -0
- package/src/lib/modules/mixin/swagger/error-response-model.js +63 -0
- package/src/lib/modules/mixin/swagger/error-response-model.js.map +1 -0
- package/src/lib/modules/mixin/swagger/method/delete-one.js +3 -3
- package/src/lib/modules/mixin/swagger/method/delete-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/delete-relationship.js +6 -6
- package/src/lib/modules/mixin/swagger/method/delete-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-all.js +9 -39
- package/src/lib/modules/mixin/swagger/method/get-all.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-one.js +5 -5
- package/src/lib/modules/mixin/swagger/method/get-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-relationship.js +5 -4
- package/src/lib/modules/mixin/swagger/method/get-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/patch-one.js +5 -5
- package/src/lib/modules/mixin/swagger/method/patch-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/patch-relationship.js +7 -7
- package/src/lib/modules/mixin/swagger/method/patch-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/post-one.js +5 -5
- package/src/lib/modules/mixin/swagger/method/post-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/post-relationship.js +7 -7
- package/src/lib/modules/mixin/swagger/method/post-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/open-api-types.d.ts +18 -0
- package/src/lib/modules/mixin/swagger/open-api-types.js +3 -0
- package/src/lib/modules/mixin/swagger/open-api-types.js.map +1 -0
- package/src/lib/modules/mixin/swagger/swagger-bind.service.d.ts +1 -0
- package/src/lib/modules/mixin/swagger/swagger-bind.service.js +52 -13
- package/src/lib/modules/mixin/swagger/swagger-bind.service.js.map +1 -1
- package/src/lib/modules/mixin/swagger/utils.d.ts +17 -142
- package/src/lib/modules/mixin/swagger/utils.js +178 -124
- package/src/lib/modules/mixin/swagger/utils.js.map +1 -1
- package/src/lib/modules/mixin/zod/index.d.ts +1 -1
- package/src/lib/modules/mixin/zod/index.js +4 -0
- package/src/lib/modules/mixin/zod/index.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-patch-relationship-schema/index.d.ts +8 -0
- package/src/lib/modules/mixin/zod/zod-input-patch-relationship-schema/index.js +8 -3
- package/src/lib/modules/mixin/zod/zod-input-patch-relationship-schema/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-patch-schema/index.d.ts +14 -3
- package/src/lib/modules/mixin/zod/zod-input-patch-schema/index.js +1 -0
- package/src/lib/modules/mixin/zod/zod-input-patch-schema/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-post-relationship-schema/index.d.ts +1 -0
- package/src/lib/modules/mixin/zod/zod-input-post-relationship-schema/index.js +1 -0
- package/src/lib/modules/mixin/zod/zod-input-post-relationship-schema/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-post-schema/index.d.ts +16 -6
- package/src/lib/modules/mixin/zod/zod-input-post-schema/index.js +2 -11
- package/src/lib/modules/mixin/zod/zod-input-post-schema/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/fields.d.ts +8 -5
- package/src/lib/modules/mixin/zod/zod-input-query-schema/fields.js +16 -12
- 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 +76 -6
- package/src/lib/modules/mixin/zod/zod-input-query-schema/filter.js +32 -10
- 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 +40 -15
- 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 +4 -2
- package/src/lib/modules/mixin/zod/zod-query-schema/filter.js +19 -8
- package/src/lib/modules/mixin/zod/zod-query-schema/filter.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/include.d.ts +9 -2
- package/src/lib/modules/mixin/zod/zod-query-schema/include.js +2 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/include.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/sort.d.ts +2 -2
- 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-share/attributes.d.ts +12 -6
- package/src/lib/modules/mixin/zod/zod-share/attributes.js +12 -7
- package/src/lib/modules/mixin/zod/zod-share/attributes.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-share/id.d.ts +12 -0
- package/src/lib/modules/mixin/zod/zod-share/id.js +17 -0
- package/src/lib/modules/mixin/zod/zod-share/id.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-share/index.d.ts +1 -0
- package/src/lib/modules/mixin/zod/zod-share/index.js +1 -0
- package/src/lib/modules/mixin/zod/zod-share/index.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-share/meta.d.ts +11 -0
- package/src/lib/modules/mixin/zod/zod-share/meta.js +15 -0
- package/src/lib/modules/mixin/zod/zod-share/meta.js.map +1 -0
- package/src/lib/modules/mixin/zod/zod-share/page.d.ts +2 -2
- package/src/lib/modules/mixin/zod/zod-utils.d.ts +2 -0
- package/src/lib/modules/mixin/zod/zod-utils.js +20 -0
- package/src/lib/modules/mixin/zod/zod-utils.js.map +1 -1
- package/src/lib/types/entity-param.type.d.ts +10 -9
- package/src/lib/types/entity-param.type.js +13 -0
- package/src/lib/types/entity-param.type.js.map +1 -1
- package/src/lib/types/module-options.types.d.ts +1 -0
- package/src/lib/utils/module-helper.js +1 -0
- package/src/lib/utils/module-helper.js.map +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
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>>;
|
|
8
|
-
} & { [
|
|
9
|
+
} & { [P_1 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]: string[] | undefined; } extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strict>>, z.ZodTransform<Awaited<z.core.$InferObjectOutput<{
|
|
9
10
|
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
10
|
-
} & { [
|
|
11
|
+
} & { [P_1 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_3 ? T_3 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_3 extends PropertyKey ? T_3 : never : never : never]: string[] | undefined; } extends infer T_2 ? { -readonly [P in keyof T_2]: T_2[P]; } : never, {}>> | null, z.core.$InferObjectOutput<{
|
|
11
12
|
target: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | undefined, string | undefined>>;
|
|
12
|
-
} & { [
|
|
13
|
-
filter: z.ZodPipe<z.ZodOptional<z.ZodObject<
|
|
13
|
+
} & { [P_1 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_5 ? T_5 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_5 extends PropertyKey ? T_5 : never : never : never]: string[] | undefined; } extends infer T_4 ? { -readonly [P in keyof T_4]: T_4[P]; } : never, {}> | undefined>>;
|
|
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<{
|
|
14
15
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
15
16
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
16
17
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -22,11 +23,23 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
22
23
|
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
23
24
|
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
24
25
|
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
25
|
-
}, z.core.$strict>]
|
|
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_7 ? T_7 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_7 extends PropertyKey ? T_7 : 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<{
|
|
27
|
+
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
28
|
+
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
29
|
+
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
30
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
31
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
32
|
+
like: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
33
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
34
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
35
|
+
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
36
|
+
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
37
|
+
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
38
|
+
}, z.core.$strict>]>>> & Record<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_8 ? T_8 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_8 extends PropertyKey ? T_8 : never : never : never, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
26
39
|
eq: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
27
40
|
}, z.core.$strict>, z.ZodObject<{
|
|
28
41
|
ne: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
29
|
-
}, z.core.$strict>]>>> & Record<import("../../../../types").UnionToTuple<{ [
|
|
42
|
+
}, z.core.$strict>]>>> & Record<import("../../../../types").UnionToTuple<{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").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 import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]>, [{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]] extends [never] ? true : false>[number] extends infer T_9 ? T_9 extends import("../../../../types").UnionToTuple<{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").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 import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]>, [{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]] extends [never] ? true : false>[number] ? T_9 extends PropertyKey ? T_9 : 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<{
|
|
30
43
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
31
44
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
32
45
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -38,7 +51,7 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
38
51
|
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
39
52
|
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
40
53
|
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
41
|
-
}, z.core.$strict>]>>> extends infer
|
|
54
|
+
}, z.core.$strict>]>>> extends infer T_6 ? { -readonly [P_2 in keyof T_6]: T_6[P_2]; } : never, z.core.$strip>>, z.ZodTransform<{
|
|
42
55
|
relation: null | Record<string, Record<string, Partial<{
|
|
43
56
|
eq: string | string[];
|
|
44
57
|
gt: string | string[];
|
|
@@ -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_11 ? T_11 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_11 extends PropertyKey ? T_11 : 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>>>;
|
|
@@ -77,11 +102,11 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
77
102
|
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
78
103
|
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
79
104
|
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
80
|
-
}, z.core.$strict>]>>> & Record<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
|
|
105
|
+
}, z.core.$strict>]>>> & Record<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_12 ? T_12 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_12 extends PropertyKey ? T_12 : never : never : never, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
81
106
|
eq: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
82
107
|
}, z.core.$strict>, z.ZodObject<{
|
|
83
108
|
ne: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<"null">, z.ZodNull]>, z.ZodTransform<null, "null" | null>>;
|
|
84
|
-
}, z.core.$strict>]>>> & Record<import("../../../../types").UnionToTuple<{ [
|
|
109
|
+
}, z.core.$strict>]>>> & Record<import("../../../../types").UnionToTuple<{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").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 import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]>, [{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]] extends [never] ? true : false>[number] extends infer T_13 ? T_13 extends import("../../../../types").UnionToTuple<{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").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 import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]>, [{ [K_1 in keyof import("../../../../types").EntityRelationProps<E, IdKey>]: `${K_1}.${import("../../../../types").EntityRelationProps<E, IdKey>[K_1][number] & string}`; }[import("@klerick/json-api-nestjs-shared").RelationKeys<E, "id">]] extends [never] ? true : false>[number] ? T_13 extends PropertyKey ? T_13 : 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<{
|
|
85
110
|
some: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
86
111
|
in: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
87
112
|
eq: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
@@ -93,12 +118,12 @@ export declare function zodInputQuery<E extends object, IdKey extends string>(en
|
|
|
93
118
|
ne: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
94
119
|
regexp: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
95
120
|
nin: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodNumber]>, z.ZodTransform<string, string | number | null>>>;
|
|
96
|
-
}, z.core.$strict>]>>> extends infer
|
|
121
|
+
}, z.core.$strict>]>>> extends infer T_10 ? { -readonly [P_2 in keyof T_10]: T_10[P_2]; } : never, {}> | undefined>>;
|
|
97
122
|
include: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string[] | null, string | undefined>>;
|
|
98
123
|
sort: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<Record<string, Record<string, "DESC" | "ASC">> | null, string | undefined>>;
|
|
99
124
|
page: z.ZodDefault<z.ZodObject<{
|
|
100
|
-
size: z.ZodDefault<z.
|
|
101
|
-
number: z.ZodDefault<z.
|
|
125
|
+
size: z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>;
|
|
126
|
+
number: z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>;
|
|
102
127
|
}, z.core.$strict>>;
|
|
103
128
|
}, z.core.$strict>;
|
|
104
129
|
export type ZodInputQuery<E extends object, IdKey extends string> = ReturnType<typeof zodInputQuery<E, IdKey>>;
|
|
@@ -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,SAA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oDAAoD;KAC9D,CAAC;SACD,QAAQ,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -33,14 +33,16 @@ 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>;
|
|
39
41
|
};
|
|
40
42
|
type ResultTargetType<E extends object, IdKey extends string> = FilterProps<E, IdKey> & TargetRelationShape<E, IdKey>;
|
|
41
43
|
export declare function zodFilterQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodObject<{
|
|
42
|
-
target: z.ZodNullable<z.
|
|
43
|
-
relation: z.ZodNullable<z.
|
|
44
|
+
target: z.ZodNullable<z.ZodObject<ResultTargetType<E, IdKey> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strict>>;
|
|
45
|
+
relation: z.ZodNullable<z.ZodObject<RelationFilterProps<E, IdKey> extends infer T_1 ? { -readonly [P_1 in keyof T_1]: T_1[P_1]; } : never, z.core.$strict>>;
|
|
44
46
|
}, z.core.$strict>;
|
|
45
47
|
export type ZodFilterQuery<E extends object, IdKey extends string> = ReturnType<typeof zodFilterQuery<E, IdKey>>;
|
|
46
48
|
export type FilterQuery<E extends object, IdKey extends string> = z.infer<ZodFilterQuery<E, IdKey>>;
|
|
@@ -82,15 +82,27 @@ function getZodRulesForField(type = types_1.TypeField.string) {
|
|
|
82
82
|
function getZodRulesForRelationShape(shape) {
|
|
83
83
|
return zod_1.z.object(shape).strict().optional().refine((0, zod_utils_1.nonEmptyObject)());
|
|
84
84
|
}
|
|
85
|
+
const zodRulesForFieldCache = new Map();
|
|
86
|
+
function getZodRulesForFieldUsingCache(type) {
|
|
87
|
+
let rules = zodRulesForFieldCache.get(type);
|
|
88
|
+
if (rules) {
|
|
89
|
+
return rules;
|
|
90
|
+
}
|
|
91
|
+
rules = getZodRulesForField(type);
|
|
92
|
+
zodRulesForFieldCache.set(type, rules);
|
|
93
|
+
return rules;
|
|
94
|
+
}
|
|
85
95
|
function getFilterPropsShapeForEntity(entityParam) {
|
|
86
96
|
return entityParam.props.reduce((acum, field) => {
|
|
87
97
|
const propertyType = Reflect.get(entityParam.propsType, field);
|
|
88
98
|
const value = propertyType === types_1.TypeField.array
|
|
89
99
|
? zodRuleForArrayField
|
|
90
|
-
:
|
|
100
|
+
: getZodRulesForFieldUsingCache(propertyType);
|
|
91
101
|
Reflect.set(acum, field, value.optional());
|
|
92
102
|
return acum;
|
|
93
|
-
}, {
|
|
103
|
+
}, {
|
|
104
|
+
[entityParam.primaryColumnName]: getZodRulesForFieldUsingCache(entityParam.primaryColumnType).optional()
|
|
105
|
+
});
|
|
94
106
|
}
|
|
95
107
|
function zodFilterQuery(entityParamMapService) {
|
|
96
108
|
const targetResult = entityParamMapService.entityParaMap.relations.reduce((acum, item) => ({
|
|
@@ -105,15 +117,14 @@ function zodFilterQuery(entityParamMapService) {
|
|
|
105
117
|
[relName]: zodFilter.optional(),
|
|
106
118
|
};
|
|
107
119
|
}, {});
|
|
120
|
+
// Both keys are required: this schema guards what reaches the controller, and
|
|
121
|
+
// the input pipe always emits them -- its reducer starts from
|
|
122
|
+
// { relation: null, target: null }. A null value means "nothing filtered on
|
|
123
|
+
// this side"; a missing key means the query never went through the pipe.
|
|
108
124
|
const targetShapeFilter = {
|
|
109
|
-
target: zod_1.z
|
|
110
|
-
.strictObject(targetResult)
|
|
111
|
-
.optional()
|
|
112
|
-
.refine((0, zod_utils_1.nonEmptyObject)())
|
|
113
|
-
.nullable(),
|
|
125
|
+
target: zod_1.z.strictObject(targetResult).refine((0, zod_utils_1.nonEmptyObject)()).nullable(),
|
|
114
126
|
relation: zod_1.z
|
|
115
127
|
.strictObject(relationFilterProps)
|
|
116
|
-
.optional()
|
|
117
128
|
.refine((0, zod_utils_1.nonEmptyObject)())
|
|
118
129
|
.nullable(),
|
|
119
130
|
};
|
|
@@ -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,wCA8CC;AAnQD,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,EAAE;QACpC,KAAK,EAAE,4BAA4B;KACpC,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,gBAAgB;KACxC,KAAK,EAAE;KACP,QAAQ,EAAE;KACV,MAAM,CAAC,IAAA,qCAAyB,EAAC,CAAC,CAAC,EAAE;IACpC,KAAK,EAAE,2BAA2B;CACnC,CAAC,CAAC;AAEL,MAAM,WAAW,GAAG,OAAC,CAAC,KAAK,CAAC;IAC1B,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACjB,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,C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AAC,OAAO,CAC7C,qBAAqB,CAAC,aAAa,CAAC,gBAAgB,CACrD,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE;QAIrC,MAAM,SAAS,GAAG,qBAAqB,CAAC,WAAW,CACjD,QAAQ,CAAC,WAAkB,CACF,CAAC;QAE5B,MAAM,SAAS,GAAG,2BAA2B,CAC3C,4BAA4B,CAAC,SAAS,CAAC,CACxC,CAAC;QAEF,OAAO;YACL,GAAG,IAAI;YACP,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,QAAQ,EAAE;SAChC,CAAC;IACJ,CAAC,EAAE,EAAmC,CAAC,CAAC;IAExC,8EAA8E;IAC9E,8DAA8D;IAC9D,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,iBAAiB,GAAG;QACxB,MAAM,EAAE,OAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC,CAAC,QAAQ,EAAE;QACxE,QAAQ,EAAE,OAAC;aACR,YAAY,CAAC,mBAAmB,CAAC;aACjC,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC;aACxB,QAAQ,EAAE;KACd,CAAC;IAEF,OAAO,OAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { ZodNullable, ZodArray, ZodEnum } from 'zod';
|
|
2
3
|
import { EntityParamMapService } from '../../service';
|
|
3
4
|
import { NonEmptyStringTuple } from '../../../../types';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type Relations<E extends object, IdKey extends string> = EntityParamMapService<E, IdKey>['entityParaMap']['relations'];
|
|
6
|
+
type RelationsTuple<E extends object, IdKey extends string> = NonEmptyStringTuple<Relations<E, IdKey>>;
|
|
7
|
+
type EnumLike<T extends readonly string[]> = {
|
|
8
|
+
[K in T[number]]: K;
|
|
9
|
+
};
|
|
10
|
+
export type ZodIncludeQuery<E extends object, IdKey extends string> = ZodNullable<ZodArray<ZodEnum<EnumLike<RelationsTuple<E, IdKey>>>>>;
|
|
11
|
+
export declare function zodIncludeQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): ZodIncludeQuery<E, IdKey>;
|
|
6
12
|
export type IncludeQuery<E extends object, IdKey extends string> = z.infer<ZodIncludeQuery<E, IdKey>>;
|
|
13
|
+
export {};
|
|
@@ -4,7 +4,8 @@ exports.zodIncludeQuery = zodIncludeQuery;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zod_utils_1 = require("../zod-utils");
|
|
6
6
|
function zodIncludeQuery(entityParamMapService) {
|
|
7
|
-
const relationProps = entityParamMapService
|
|
7
|
+
const relationProps = entityParamMapService
|
|
8
|
+
.entityParaMap.relations;
|
|
8
9
|
return zod_1.z
|
|
9
10
|
.enum(relationProps)
|
|
10
11
|
.array()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/include.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"include.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-query-schema/include.ts"],"names":[],"mappings":";;AAwBA,0CAcC;AAtCD,6BAAwB;AAGxB,4CAA2C;AAqB3C,SAAgB,eAAe,CAC7B,qBAAsD;IAEtD,MAAM,aAAa,GAA6B,qBAAqB;SAClE,aAAa,CAAC,SAAqC,CAAC;IAEvD,OAAO,OAAC;SACL,IAAI,CAAC,aAAa,CAAC;SACnB,KAAK,EAAE;SACP,QAAQ,EAAE;SACV,MAAM,CAAC,IAAA,uBAAW,GAAE,EAAE;QACrB,KAAK,EAAE,qCAAqC;KAC7C,CAAC;SACD,QAAQ,EAAE,CAAC;AAChB,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>>;
|
|
@@ -21,7 +21,7 @@ type ZodSortRelation<E extends object, IdKey extends string> = {
|
|
|
21
21
|
type ZodSortShape<E extends object, IdKey extends string> = ZodSortTarget<E, IdKey> & ZodSortRelation<E, IdKey>;
|
|
22
22
|
export declare function zodSortQuery<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>): z.ZodNullable<z.ZodObject<ZodSortShape<E, IdKey> extends infer T extends Readonly<{
|
|
23
23
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
24
|
-
}> ? { [k in keyof T]: z.ZodOptional<T[k]>; } : never, z.core.$strict>>;
|
|
24
|
+
}> ? { -readonly [k in keyof T]: z.ZodOptional<T[k]>; } : never, z.core.$strict>>;
|
|
25
25
|
export type ZodSortQuery<E extends object, IdKey extends string> = ReturnType<typeof zodSortQuery<E, IdKey>>;
|
|
26
26
|
export type SortQuery<E extends object, IdKey extends string> = z.infer<ZodSortQuery<E, IdKey>>;
|
|
27
27
|
export {};
|
|
@@ -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"}
|
|
@@ -2,13 +2,19 @@ import { z, ZodArray } from 'zod';
|
|
|
2
2
|
import { EntityParam, TypeField, ExtractJsonApiReadOnlyKeys, ExtractJsonApiImmutableKeys } from '../../../../types';
|
|
3
3
|
import { ResultSchema } from './type';
|
|
4
4
|
import { EntityParamMapService } from '../../service';
|
|
5
|
-
|
|
6
|
-
declare
|
|
7
|
-
declare function
|
|
8
|
-
declare
|
|
9
|
-
declare function
|
|
5
|
+
declare function getZodRulesForNumberFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodPreprocess<z.ZodNumber>, Null, isPatch>;
|
|
6
|
+
declare const getZodRulesForNumber: typeof getZodRulesForNumberFunc;
|
|
7
|
+
declare function getZodRulesForStringFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodString, Null, isPatch>;
|
|
8
|
+
declare const getZodRulesForString: typeof getZodRulesForStringFunc;
|
|
9
|
+
declare function getZodRulesForDateFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Awaited<isPatch extends true ? Null extends true ? Date | null | undefined : Date | undefined : Null extends true ? Date | null | undefined : Date>, string>> | z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>, z.ZodTransform<Awaited<isPatch extends true ? Null extends true ? Date | null | undefined : Date | undefined : Null extends true ? Date | null | undefined : Date>, string | null | undefined>> | z.ZodPipe<z.ZodOptional<z.ZodISODateTime>, z.ZodTransform<Awaited<isPatch extends true ? Null extends true ? Date | null | undefined : Date | undefined : Null extends true ? Date | null | undefined : Date>, string | undefined>>;
|
|
10
|
+
declare const getZodRulesForDate: typeof getZodRulesForDateFunc;
|
|
11
|
+
declare function getZodRulesForBooleanFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodBoolean, Null, isPatch>;
|
|
12
|
+
declare const getZodRulesForBoolean: typeof getZodRulesForBooleanFunc;
|
|
13
|
+
declare function getZodSchemaForJsonFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodJSONSchema, Null, isPatch>;
|
|
14
|
+
declare const getZodSchemaForJson: typeof getZodSchemaForJsonFunc;
|
|
10
15
|
type ZodRulesResultArray<T extends TypeField, Null extends true | false, isPatch extends true | false> = ResultSchema<ZodArray<ZodRulesForType<T, false, false>>, Null, isPatch>;
|
|
11
|
-
declare function
|
|
16
|
+
declare function getZodRulesForArrayFunc<T extends TypeField, Null extends true | false, isPatch extends true | false>(propsField: T, isNullable: Null, isPatch: isPatch): ZodRulesResultArray<T, Null, isPatch>;
|
|
17
|
+
declare const getZodRulesForArray: typeof getZodRulesForArrayFunc;
|
|
12
18
|
type ZodRulesForArray<T extends TypeField, Null extends true | false, isPatch extends true | false> = ReturnType<typeof getZodRulesForArray<T, Null, isPatch>>;
|
|
13
19
|
export type ZodRulesForType<T extends TypeField, Null extends true | false, isPatch extends true | false> = ReturnType<T extends TypeField.date ? typeof getZodRulesForDate<Null, isPatch> : T extends TypeField.boolean ? typeof getZodRulesForBoolean<Null, isPatch> : T extends TypeField.number ? typeof getZodRulesForNumber<Null, isPatch> : T extends TypeField.object ? typeof getZodSchemaForJson<Null, isPatch> : typeof getZodRulesForString<Null, isPatch>>;
|
|
14
20
|
export type IsNullableProps<E extends object, IdKey extends string, K extends keyof E> = K extends EntityParam<E, IdKey>['propsNullable'][number] ? true : false;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZodRulesForNumber = getZodRulesForNumber;
|
|
4
3
|
exports.zodAttributes = zodAttributes;
|
|
5
4
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
5
|
const zod_1 = require("zod");
|
|
7
6
|
const types_1 = require("../../../../types");
|
|
8
7
|
const zod_utils_1 = require("../zod-utils");
|
|
9
8
|
const map_transform_to_json_shema_1 = require("../map-transform-to-json-shema");
|
|
10
|
-
function
|
|
9
|
+
function getZodRulesForNumberFunc(isNullable, isPatch) {
|
|
11
10
|
const schema = zod_1.z.preprocess((x) => Number(x), zod_1.z.number());
|
|
12
11
|
return (0, zod_utils_1.setOptionalOrNot)(schema, isNullable, isPatch);
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
const getZodRulesForNumber = (0, zod_utils_1.memoize)(getZodRulesForNumberFunc);
|
|
14
|
+
function getZodRulesForStringFunc(isNullable, isPatch) {
|
|
15
15
|
return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.string(), isNullable, isPatch);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const getZodRulesForString = (0, zod_utils_1.memoize)(getZodRulesForStringFunc);
|
|
18
|
+
function getZodRulesForDateFunc(isNullable, isPatch) {
|
|
18
19
|
return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.iso.datetime(), isNullable, isPatch).transform((map_transform_to_json_shema_1.transformDateString));
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
const getZodRulesForDate = (0, zod_utils_1.memoize)(getZodRulesForDateFunc);
|
|
22
|
+
function getZodRulesForBooleanFunc(isNullable, isPatch) {
|
|
21
23
|
return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.boolean(), isNullable, isPatch);
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
const getZodRulesForBoolean = (0, zod_utils_1.memoize)(getZodRulesForBooleanFunc);
|
|
26
|
+
function getZodSchemaForJsonFunc(isNullable, isPatch) {
|
|
24
27
|
return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.json(), isNullable, isPatch);
|
|
25
28
|
}
|
|
26
|
-
|
|
29
|
+
const getZodSchemaForJson = (0, zod_utils_1.memoize)(getZodSchemaForJsonFunc);
|
|
30
|
+
function getZodRulesForArrayFunc(propsField, isNullable, isPatch) {
|
|
27
31
|
let schema;
|
|
28
32
|
switch (propsField) {
|
|
29
33
|
case types_1.TypeField.number:
|
|
@@ -40,6 +44,7 @@ function getZodRulesForArray(propsField, isNullable, isPatch) {
|
|
|
40
44
|
}
|
|
41
45
|
return (0, zod_utils_1.setOptionalOrNot)(schema.array(), isNullable, isPatch);
|
|
42
46
|
}
|
|
47
|
+
const getZodRulesForArray = (0, zod_utils_1.memoize)(getZodRulesForArrayFunc);
|
|
43
48
|
function assertPropsIsarrayProps(paramMap, propsName) {
|
|
44
49
|
return Reflect.get(paramMap.propsType, `${propsName}`) === types_1.TypeField.array;
|
|
45
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-share/attributes.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-share/attributes.ts"],"names":[],"mappings":";;AA2PA,sCAkCC;AA7RD,4EAA8D;AAC9D,6BAA2C;AAE3C,6CAAoH;AACpH,4CAAyE;AAGzE,gFAAqE;AAErE,SAAS,wBAAwB,CAG/B,UAAgB,EAAE,OAAgB;IAClC,MAAM,MAAM,GAAG,OAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,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AC,SAAS,EAAE,GAAG,EAAE,OAAO,IAAI,WAAW,CAAC,CAAC;YACnE,IAAI,CAAC,GAAG,CAAC,GAAG,MAAmE,CAAC;QAClF,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,EACD,EAAsC,CACvC,CAAC;IAEF,OAAO,OAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAA,0BAAc,GAAE,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -3,3 +3,15 @@ import { TypeForId } from '../../../../types';
|
|
|
3
3
|
export declare function zodId(typeId: TypeForId): z.ZodString;
|
|
4
4
|
export type ZodId = ReturnType<typeof zodId>;
|
|
5
5
|
export type Id = z.infer<ZodId>;
|
|
6
|
+
/**
|
|
7
|
+
* JSON:API carries every id as a string, including ids of numeric primary keys.
|
|
8
|
+
* A client-supplied id ends up written straight onto the new entity, so it has
|
|
9
|
+
* to match the declared primary-key type: MikroORM 7 validates property types
|
|
10
|
+
* on flush and rejects a string written to a numeric key, where earlier
|
|
11
|
+
* versions coerced it silently.
|
|
12
|
+
*
|
|
13
|
+
* Only the resource's own id is converted. Relationship linkage ids keep their
|
|
14
|
+
* string form -- they travel a different path and are matched as strings.
|
|
15
|
+
*/
|
|
16
|
+
export declare function zodPrimaryKeyId(typeId: TypeForId): z.ZodString | z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
17
|
+
export type ZodPrimaryKeyId = ReturnType<typeof zodPrimaryKeyId>;
|