@klerick/json-api-nestjs 10.0.0-beta.8 → 10.0.0-beta.9

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 10.0.0-beta.9 (2026-01-20)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **json-api-nestjs:** enhance Patch and Post schema handling, add utility for merging patch data and refine type definitions for attributes and relationships ([2887603](https://github.com/klerick/nestjs-json-api/commit/2887603))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Alex H
10
+
1
11
  ## 10.0.0-beta.8 (2026-01-19)
2
12
 
3
13
  ### 🚀 Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klerick/json-api-nestjs",
3
- "version": "10.0.0-beta.8",
3
+ "version": "10.0.0-beta.9",
4
4
  "type": "commonjs",
5
5
  "description": "JsonApi Plugin for NestJs",
6
6
  "keywords": [
package/src/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { JsonApiModule } from './lib/json-api.module';
2
2
  export { JsonBaseController } from './lib/modules/mixin/controllers/json-base.controller';
3
3
  export { JsonApi, InjectService, JsonApiReadOnly, JsonApiImmutable } from './lib/modules/mixin/decorators';
4
- export { entityForClass, excludeMethod, } from './lib/modules/mixin/helpers/utils';
4
+ export { entityForClass, excludeMethod, patchInputData, } from './lib/modules/mixin/helpers/utils';
5
5
  export { PrepareParams, NestProvider, ValidateQueryError, UnionToTuple, EntityParam, TypeField, Params, JsonApiReadOnlyField, JsonApiImmutableField, } from './lib/types';
6
6
  export { JsonApiTransformerService, ErrorFormatService, EntityParamMapService } from './lib/modules/mixin/service';
7
7
  export { MODULE_OPTIONS_TOKEN, CONTROLLER_OPTIONS_TOKEN, ASC, DESC, FIND_ONE_ROW_ENTITY, CHECK_RELATION_NAME, RUN_IN_TRANSACTION_FUNCTION, ORM_SERVICE, ENTITY_PARAM_MAP, DEFAULT_PAGE_SIZE, DEFAULT_QUERY_PAGE, CURRENT_ENTITY, METHOD_NAME } from './lib/constants';
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.METHOD_NAME = exports.CURRENT_ENTITY = exports.DEFAULT_QUERY_PAGE = exports.DEFAULT_PAGE_SIZE = exports.ENTITY_PARAM_MAP = exports.ORM_SERVICE = exports.RUN_IN_TRANSACTION_FUNCTION = exports.CHECK_RELATION_NAME = exports.FIND_ONE_ROW_ENTITY = exports.DESC = exports.ASC = exports.CONTROLLER_OPTIONS_TOKEN = exports.MODULE_OPTIONS_TOKEN = exports.EntityParamMapService = exports.ErrorFormatService = exports.JsonApiTransformerService = exports.TypeField = exports.excludeMethod = exports.entityForClass = exports.JsonApiImmutable = exports.JsonApiReadOnly = exports.InjectService = exports.JsonApi = exports.JsonBaseController = exports.JsonApiModule = void 0;
3
+ exports.METHOD_NAME = exports.CURRENT_ENTITY = exports.DEFAULT_QUERY_PAGE = exports.DEFAULT_PAGE_SIZE = exports.ENTITY_PARAM_MAP = exports.ORM_SERVICE = exports.RUN_IN_TRANSACTION_FUNCTION = exports.CHECK_RELATION_NAME = exports.FIND_ONE_ROW_ENTITY = exports.DESC = exports.ASC = exports.CONTROLLER_OPTIONS_TOKEN = exports.MODULE_OPTIONS_TOKEN = exports.EntityParamMapService = exports.ErrorFormatService = exports.JsonApiTransformerService = exports.TypeField = exports.patchInputData = exports.excludeMethod = exports.entityForClass = exports.JsonApiImmutable = exports.JsonApiReadOnly = exports.InjectService = exports.JsonApi = exports.JsonBaseController = exports.JsonApiModule = void 0;
4
4
  var json_api_module_1 = require("./lib/json-api.module");
5
5
  Object.defineProperty(exports, "JsonApiModule", { enumerable: true, get: function () { return json_api_module_1.JsonApiModule; } });
6
6
  var json_base_controller_1 = require("./lib/modules/mixin/controllers/json-base.controller");
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "JsonApiImmutable", { enumerable: true, get: func
13
13
  var utils_1 = require("./lib/modules/mixin/helpers/utils");
14
14
  Object.defineProperty(exports, "entityForClass", { enumerable: true, get: function () { return utils_1.entityForClass; } });
15
15
  Object.defineProperty(exports, "excludeMethod", { enumerable: true, get: function () { return utils_1.excludeMethod; } });
16
+ Object.defineProperty(exports, "patchInputData", { enumerable: true, get: function () { return utils_1.patchInputData; } });
16
17
  var types_1 = require("./lib/types");
17
18
  Object.defineProperty(exports, "TypeField", { enumerable: true, get: function () { return types_1.TypeField; } });
18
19
  var service_1 = require("./lib/modules/mixin/service");
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/json-api/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AAEtB,6FAA0F;AAAjF,0HAAA,kBAAkB,OAAA;AAC3B,6DAA2G;AAAlG,qGAAA,OAAO,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAClE,2DAG2C;AAFzC,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AAEf,qCAUqB;AAJnB,kGAAA,SAAS,OAAA;AAKX,uDAIqC;AAHnC,oHAAA,yBAAyB,OAAA;AACzB,6GAAA,kBAAkB,OAAA;AAClB,gHAAA,qBAAqB,OAAA;AAEvB,6CAcyB;AAbvB,iHAAA,oBAAoB,OAAA;AACpB,qHAAA,wBAAwB,OAAA;AACxB,gGAAA,GAAG,OAAA;AACH,iGAAA,IAAI,OAAA;AACJ,gHAAA,mBAAmB,OAAA;AACnB,gHAAA,mBAAmB,OAAA;AACnB,wHAAA,2BAA2B,OAAA;AAC3B,wGAAA,WAAW,OAAA;AACX,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/json-api/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AAEtB,6FAA0F;AAAjF,0HAAA,kBAAkB,OAAA;AAC3B,6DAA2G;AAAlG,qGAAA,OAAO,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAClE,2DAI2C;AAHzC,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AAEhB,qCAUqB;AAJnB,kGAAA,SAAS,OAAA;AAKX,uDAIqC;AAHnC,oHAAA,yBAAyB,OAAA;AACzB,6GAAA,kBAAkB,OAAA;AAClB,gHAAA,qBAAqB,OAAA;AAEvB,6CAcyB;AAbvB,iHAAA,oBAAoB,OAAA;AACpB,qHAAA,wBAAwB,OAAA;AACxB,gGAAA,GAAG,OAAA;AACH,iGAAA,IAAI,OAAA;AACJ,gHAAA,mBAAmB,OAAA;AACnB,gHAAA,mBAAmB,OAAA;AACnB,wHAAA,2BAA2B,OAAA;AAC3B,wGAAA,WAAW,OAAA;AACX,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA"}
@@ -1,9 +1,11 @@
1
1
  import { EntityClass, AnyEntity } from '@klerick/json-api-nestjs-shared';
2
2
  import { MethodName } from '../types';
3
3
  import { Type } from '@nestjs/common/interfaces';
4
+ import { PostData, PatchData, Attributes, PatchDataRaw, PostDataRaw } from '../zod';
4
5
  export declare const nameIt: (name: string, cls: new (...rest: unknown[]) => Record<never, unknown>) => {
5
6
  new (...arg: unknown[]): {};
6
7
  };
7
8
  export declare function getProviderName<Entity extends object>(entity: EntityClass<Entity>, name: string): string;
8
9
  export declare function excludeMethod(names: Array<Partial<MethodName>>): Array<MethodName>;
9
10
  export declare function entityForClass<T = any>(type: Type<T>): EntityClass<AnyEntity>;
11
+ export declare function patchInputData<E extends object, IdKey extends string = 'id'>(data: PostData<E, IdKey> | PatchData<E, IdKey>, patch: Partial<Attributes<E, IdKey, true>>): PostData<E, IdKey> | PatchData<E, IdKey> extends PatchData<E, IdKey> ? PatchDataRaw<E, IdKey> : PostDataRaw<E, IdKey>;
@@ -4,6 +4,7 @@ exports.nameIt = void 0;
4
4
  exports.getProviderName = getProviderName;
5
5
  exports.excludeMethod = excludeMethod;
6
6
  exports.entityForClass = entityForClass;
7
+ exports.patchInputData = patchInputData;
7
8
  const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
8
9
  const change_case_commonjs_1 = require("change-case-commonjs");
9
10
  const bindings_1 = require("../config/bindings");
@@ -27,4 +28,13 @@ function excludeMethod(names) {
27
28
  function entityForClass(type) {
28
29
  return Reflect.getMetadata(constants_1.JSON_API_DECORATOR_ENTITY, type);
29
30
  }
31
+ function patchInputData(data, patch) {
32
+ return {
33
+ ...data,
34
+ attributes: {
35
+ ...data.attributes,
36
+ ...patch,
37
+ },
38
+ };
39
+ }
30
40
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/helpers/utils.ts"],"names":[],"mappings":";;;AA0BA,0CAMC;AAED,sCAUC;AAED,wCAEC;AAhDD,4EAKyC;AACzC,+DAAkD;AAIlD,iDAA8C;AAE9C,kDAA+D;AAExD,MAAM,MAAM,GAAG,CACpB,IAAY,EACZ,GAAuD,EACvD,EAAE,CACF,CAAC;IACC,CAAC,IAAI,CAAC,EAAE,KAAM,SAAQ,GAAG;QACvB,YAAY,GAAG,GAAc;YAC3B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QAChB,CAAC;KACF;CACF,CAAC,IAAI,CAAC,CAAC,CAAC;AAVE,QAAA,MAAM,UAUR;AAEX,SAAgB,eAAe,CAC7B,MAA2B,EAC3B,IAAY;IAEZ,MAAM,UAAU,GAAG,IAAA,sCAAa,EAAC,MAAM,CAAC,CAAC;IACzC,OAAO,GAAG,IAAA,iCAAU,EAAC,UAAU,CAAC,GAAG,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,aAAa,CAC3B,KAAiC;IAEjC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAC5B,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,EACzC,EAA0C,CAC3C,CAAC;IACF,OAAO,oCAAW,CAAC,IAAI,CAAC,mBAAQ,CAAC,CAAC,MAAM,CACtC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CACV,CAAC;AACzB,CAAC;AAED,SAAgB,cAAc,CAAU,IAAa;IACnD,OAAO,OAAO,CAAC,WAAW,CAAC,qCAAyB,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/helpers/utils.ts"],"names":[],"mappings":";;;AAiCA,0CAMC;AAED,sCAUC;AAED,wCAEC;AACD,wCAeC;AAvED,4EAKyC;AACzC,+DAAkD;AAIlD,iDAA8C;AAE9C,kDAA+D;AASxD,MAAM,MAAM,GAAG,CACpB,IAAY,EACZ,GAAuD,EACvD,EAAE,CACF,CAAC;IACC,CAAC,IAAI,CAAC,EAAE,KAAM,SAAQ,GAAG;QACvB,YAAY,GAAG,GAAc;YAC3B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QAChB,CAAC;KACF;CACF,CAAC,IAAI,CAAC,CAAC,CAAC;AAVE,QAAA,MAAM,UAUR;AAEX,SAAgB,eAAe,CAC7B,MAA2B,EAC3B,IAAY;IAEZ,MAAM,UAAU,GAAG,IAAA,sCAAa,EAAC,MAAM,CAAC,CAAC;IACzC,OAAO,GAAG,IAAA,iCAAU,EAAC,UAAU,CAAC,GAAG,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,aAAa,CAC3B,KAAiC;IAEjC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAC5B,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,EACzC,EAA0C,CAC3C,CAAC;IACF,OAAO,oCAAW,CAAC,IAAI,CAAC,mBAAQ,CAAC,CAAC,MAAM,CACtC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CACV,CAAC;AACzB,CAAC;AAED,SAAgB,cAAc,CAAU,IAAa;IACnD,OAAO,OAAO,CAAC,WAAW,CAAC,qCAAyB,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AACD,SAAgB,cAAc,CAC5B,IAA8C,EAC9C,KAA0C;IAI1C,OAAO;QACL,GAAG,IAAI;QACP,UAAU,EAAE;YACV,GAAG,IAAI,CAAC,UAAU;YAClB,GAAG,KAAK;SACT;KAGsB,CAAC;AAC5B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { z, ZodObject, ZodOptional } from 'zod';
2
- import { ZodAttributes, ZodId, ZodRelationships, ZodType } from '../zod-share';
2
+ import { ZodAttributes, ZodId, ZodRelationships, ZodType, Id, Attributes, Relationships } from '../zod-share';
3
3
  import { EntityParamMapService } from '../../service';
4
4
  import { ExtractJsonApiReadOnlyKeys, ExtractJsonApiImmutableKeys } from '../../../../types';
5
5
  type ZodPatchPatchShape<E extends object, IdKey extends string> = {
@@ -14,6 +14,15 @@ type ZodInputPatchDataShape<E extends object, IdKey extends string> = {
14
14
  };
15
15
  export declare function zodPatch<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>, readOnlyProps?: ExtractJsonApiReadOnlyKeys<E>[], immutableProps?: ExtractJsonApiImmutableKeys<E>[]): ZodPatch<E, IdKey>;
16
16
  export type ZodPatch<E extends object, IdKey extends string> = ZodObject<ZodInputPatchDataShape<E, IdKey>, z.core.$strict>;
17
- type PatchEntity<E extends object> = Omit<E, ExtractJsonApiReadOnlyKeys<E> | ExtractJsonApiImmutableKeys<E>>;
18
- export type PatchData<E extends object, IdKey extends string> = z.infer<ZodPatch<PatchEntity<E>, IdKey>>['data'];
17
+ export type PatchDataRaw<E extends object, IdKey extends string> = z.infer<ZodPatch<E, IdKey>>['data'];
18
+ type PatchAttributesType<E extends object, IdKey extends string> = Partial<Omit<Attributes<E, IdKey>, ExtractJsonApiReadOnlyKeys<E> | ExtractJsonApiImmutableKeys<E>>>;
19
+ export type PatchData<E extends object, IdKey extends string> = {
20
+ id: Id;
21
+ type: string;
22
+ attributes?: PatchAttributesType<E, IdKey>;
23
+ relationships?: Relationships<E, IdKey, true>;
24
+ };
25
+ export type Patch<E extends object, IdKey extends string> = {
26
+ data: PatchData<E, IdKey>;
27
+ };
19
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-patch-schema/index.ts"],"names":[],"mappings":";;AAgDA,4BAUC;AA1DD,6BAAgD;AAChD,4CASsB;AAqBtB,SAAS,QAAQ,CACf,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,IAAA,iBAAK,EACP,qBAAqB,CAAC,aAAa,CAAC,iBAA8B,CACnE;QACD,IAAI,EAAE,IAAA,mBAAO,EAAC,qBAAqB,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,UAAU,EAAE,IAAA,yBAAa,EAAC,qBAAqB,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,QAAQ,EAAE;QAChG,aAAa,EAAE,IAAA,4BAAgB,EAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE;KACxE,CAAC;IAEF,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,QAAQ,CACtB,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG,QAAQ,CAAC,qBAAqB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;IAE7E,OAAO,OAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-patch-schema/index.ts"],"names":[],"mappings":";;AAmDA,4BAUC;AA7DD,6BAAgD;AAChD,4CAYsB;AAqBtB,SAAS,QAAQ,CACf,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,IAAA,iBAAK,EACP,qBAAqB,CAAC,aAAa,CAAC,iBAA8B,CACnE;QACD,IAAI,EAAE,IAAA,mBAAO,EAAC,qBAAqB,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,UAAU,EAAE,IAAA,yBAAa,EAAC,qBAAqB,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,QAAQ,EAAE;QAChG,aAAa,EAAE,IAAA,4BAAgB,EAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE;KACxE,CAAC;IAEF,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,QAAQ,CACtB,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG,QAAQ,CAAC,qBAAqB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;IAE7E,OAAO,OAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { z, ZodObject, ZodOptional } from 'zod';
2
2
  import { ExtractJsonApiReadOnlyKeys, ExtractJsonApiImmutableKeys } from '../../../../types';
3
- import { ZodId, ZodType, ZodAttributes, ZodRelationships } from '../zod-share';
3
+ import { ZodId, ZodType, ZodAttributes, ZodRelationships, Id, Attributes, Relationships } from '../zod-share';
4
4
  import { EntityParamMapService } from '../../service';
5
5
  type ZodInputPostShape<E extends object, IdKey extends string> = {
6
6
  id: ZodOptional<ZodId>;
7
7
  type: ZodType<string>;
8
- attributes: ZodAttributes<PostEntity<E>, IdKey>;
8
+ attributes: ZodAttributes<E, IdKey>;
9
9
  relationships: ZodOptional<ZodRelationships<E, IdKey>>;
10
10
  };
11
11
  type ZodInputPostSchema<E extends object, IdKey extends string> = ZodObject<ZodInputPostShape<E, IdKey>, z.core.$strict>;
@@ -14,7 +14,15 @@ type ZodInputPostDataShape<E extends object, IdKey extends string> = {
14
14
  };
15
15
  export declare function zodPost<E extends object, IdKey extends string>(entityParamMapService: EntityParamMapService<E, IdKey>, readOnlyProps?: ExtractJsonApiReadOnlyKeys<E>[], immutableProps?: ExtractJsonApiImmutableKeys<E>[]): ZodPost<E, IdKey>;
16
16
  export type ZodPost<E extends object, IdKey extends string> = ZodObject<ZodInputPostDataShape<E, IdKey>, z.core.$strict>;
17
- export type Post<E extends object, IdKey extends string> = z.infer<ZodPost<E, IdKey>>;
18
- type PostEntity<E> = E extends object ? Omit<E, ExtractJsonApiReadOnlyKeys<E> | ExtractJsonApiImmutableKeys<E>> & Partial<Pick<E, ExtractJsonApiImmutableKeys<E>>> : never;
19
- export type PostData<E extends object, IdKey extends string> = Post<E, IdKey>['data'];
17
+ export type PostDataRaw<E extends object, IdKey extends string> = Post<E, IdKey>['data'];
18
+ type PostAttributesType<E extends object, IdKey extends string> = Omit<Attributes<E, IdKey, false>, ExtractJsonApiReadOnlyKeys<E> | ExtractJsonApiImmutableKeys<E>> & Partial<Pick<Attributes<E, IdKey, false>, Extract<ExtractJsonApiImmutableKeys<E>, keyof Attributes<E, IdKey, false>>>>;
19
+ export type PostData<E extends object, IdKey extends string> = {
20
+ id?: Id;
21
+ type: string;
22
+ attributes: PostAttributesType<E, IdKey>;
23
+ relationships?: Relationships<E, IdKey, false>;
24
+ };
25
+ export type Post<E extends object, IdKey extends string> = {
26
+ data: PostData<E, IdKey>;
27
+ };
20
28
  export {};
@@ -17,14 +17,4 @@ function zodPost(entityParamMapService, readOnlyProps = [], immutableProps = [])
17
17
  data: getShape(entityParamMapService, readOnlyProps, immutableProps),
18
18
  });
19
19
  }
20
- class Users {
21
- id;
22
- login;
23
- }
24
- class Test {
25
- id;
26
- name;
27
- updatedAt = new Date();
28
- createdBy;
29
- }
30
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-post-schema/index.ts"],"names":[],"mappings":";;AA2DA,0BAQC;AAnED,6BAAgD;AAQhD,4CASsB;AAoBtB,SAAS,QAAQ,CACf,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,IAAA,iBAAK,EACP,qBAAqB,CAAC,aAAa,CAAC,iBAA8B,CACnE,CAAC,QAAQ,EAAE;QACZ,IAAI,EAAE,IAAA,mBAAO,EAAC,qBAAqB,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,UAAU,EAAE,IAAA,yBAAa,EACvB,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,cAAc,CACmC;QACnD,aAAa,EAAE,IAAA,4BAAgB,EAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;KACzE,CAAC;IAEF,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,OAAO,CACrB,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,OAAO,OAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,QAAQ,CAAC,qBAAqB,EAAE,aAAa,EAAE,cAAc,CAAC;KACrE,CAAC,CAAC;AACL,CAAC;AAqBD,MAAM,KAAK;IACT,EAAE,CAAU;IACZ,KAAK,CAAU;CAChB;AAGD,MAAM,IAAI;IACR,EAAE,CAAU;IACZ,IAAI,CAAU;IACd,SAAS,GAAgC,IAAI,IAAI,EAAE,CAAC;IACpD,SAAS,CAAU;CACpB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/zod/zod-input-post-schema/index.ts"],"names":[],"mappings":";;AA6DA,0BAQC;AArED,6BAAgD;AAOhD,4CAYsB;AAoBtB,SAAS,QAAQ,CACf,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,IAAA,iBAAK,EACP,qBAAqB,CAAC,aAAa,CAAC,iBAA8B,CACnE,CAAC,QAAQ,EAAE;QACZ,IAAI,EAAE,IAAA,mBAAO,EAAC,qBAAqB,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,UAAU,EAAE,IAAA,yBAAa,EACvB,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,cAAc,CACf;QACD,aAAa,EAAE,IAAA,4BAAgB,EAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;KACzE,CAAC;IAEF,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,OAAO,CACrB,qBAAsD,EACtD,gBAAiD,EAAE,EACnD,iBAAmD,EAAE;IAErD,OAAO,OAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,QAAQ,CAAC,qBAAqB,EAAE,aAAa,EAAE,cAAc,CAAC;KACrE,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { Union, Object } from 'ts-toolbelt';
2
2
  import { PropertyKeys, RelationKeys, IsIterator, Constructor } from '@klerick/json-api-nestjs-shared';
3
3
  import { CastIteratorType, UnionToTuple, IsArray, CastArrayType } from './utils-type';
4
+ type ExtractBaseType<T> = T extends Date ? Date : T extends boolean ? boolean : T extends number ? number : T extends string ? string : T extends null ? null : T extends undefined ? undefined : T extends (infer U)[] ? U[] : object;
4
5
  export declare enum TypeField {
5
6
  array = "array",
6
7
  date = "date",
@@ -11,15 +12,15 @@ export declare enum TypeField {
11
12
  null = "null"
12
13
  }
13
14
  export type TypeForId = Extract<TypeField, TypeField.number | TypeField.string>;
14
- type TypeProps<T> = T extends Date ? TypeField.date : T extends any[] ? TypeField.array : T extends object ? TypeField.object : T extends boolean ? TypeField.boolean : T extends number ? TypeField.number : T extends string ? TypeField.string : TypeField.object;
15
+ type TypeProps<T> = T extends Date ? TypeField.date : T extends any[] ? TypeField.array : T extends object ? TypeField.object : T extends boolean ? TypeField.boolean : T extends number ? TypeField.number : T extends string ? TypeField.string : T extends undefined ? never : TypeField.object;
15
16
  export type PropertyWithType<E extends object, IdKey extends string = 'id'> = {
16
- [K in PropertyKeys<E, IdKey>]: Exclude<E[K], null> extends never ? TypeField.null : TypeProps<Exclude<E[K], null>>;
17
+ [K in PropertyKeys<E, IdKey>]: Exclude<E[K], null | undefined> extends never ? TypeField.null : TypeProps<ExtractBaseType<Exclude<E[K], null | undefined>>>;
17
18
  };
18
19
  export type ArrayProperty<E extends object, IdKey extends string = 'id'> = {
19
- [K in PropertyKeys<E, IdKey>]: Exclude<E[K], null> extends never ? never : IsArray<Exclude<E[K], null>> extends 1 ? K : never;
20
+ [K in PropertyKeys<E, IdKey>]: Exclude<E[K], null | undefined> extends never ? never : IsArray<Exclude<E[K], null | undefined>> extends 1 ? K : never;
20
21
  }[PropertyKeys<E, IdKey>];
21
22
  export type ArrayPropertyType<E extends object, IdKey extends string = 'id'> = {
22
- [K in ArrayProperty<E, IdKey>]: TypeProps<CastArrayType<Exclude<E[K], null>>>;
23
+ [K in ArrayProperty<E, IdKey>]: TypeProps<CastArrayType<Exclude<E[K], null | undefined>>>;
23
24
  };
24
25
  export type NullableProperty<E extends object, IdKey extends string = 'id'> = Union.Intersect<Object.NullableKeys<E>, PropertyKeys<E, IdKey>>;
25
26
  export type RelationProperty<E extends object, IdKey extends string = 'id'> = {
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypeField = void 0;
4
+ // import {
5
+ // JsonApiReadOnlyField,
6
+ // JsonApiImmutableField,
7
+ // } from './json-api-read-only';
8
+ // // Remove marker types from value type
9
+ // type CleanMarkerTypes<T> = T extends JsonApiReadOnlyField &
10
+ // JsonApiImmutableField
11
+ // ? Omit<T, keyof JsonApiReadOnlyField | keyof JsonApiImmutableField>
12
+ // : T extends JsonApiReadOnlyField
13
+ // ? Omit<T, keyof JsonApiReadOnlyField>
14
+ // : T extends JsonApiImmutableField
15
+ // ? Omit<T, keyof JsonApiImmutableField>
16
+ // : T;
4
17
  var TypeField;
5
18
  (function (TypeField) {
6
19
  TypeField["array"] = "array";
@@ -1 +1 @@
1
- {"version":3,"file":"entity-param.type.js","sourceRoot":"","sources":["../../../../../../../libs/json-api/json-api-nestjs/src/lib/types/entity-param.type.ts"],"names":[],"mappings":";;;AAcA,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,0BAAa,CAAA;AACf,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB"}
1
+ {"version":3,"file":"entity-param.type.js","sourceRoot":"","sources":["../../../../../../../libs/json-api/json-api-nestjs/src/lib/types/entity-param.type.ts"],"names":[],"mappings":";;;AAyBA,WAAW;AACX,0BAA0B;AAC1B,2BAA2B;AAC3B,iCAAiC;AAEjC,yCAAyC;AACzC,8DAA8D;AAC9D,0BAA0B;AAC1B,wEAAwE;AACxE,qCAAqC;AACrC,0CAA0C;AAC1C,sCAAsC;AACtC,2CAA2C;AAC3C,SAAS;AAET,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,0BAAa,CAAA;AACf,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB"}