@klerick/json-api-nestjs 10.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## 10.1.0 (2026-09-12)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **json-api-nestjs:** let the date column decide whether a zone may be omitted ([0886790](https://github.com/klerick/nestjs-json-api/commit/0886790))
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - **json-api-nestjs:** accept a UTC offset in date attributes ([#120](https://github.com/klerick/nestjs-json-api/issues/120))
10
+
11
+ ### 🧱 Updated Dependencies
12
+
13
+ - Updated json-api-nestjs-shared to 1.0.0
14
+
15
+ ### ❤️ Thank You
16
+
17
+ - Alex H
18
+ - Claude Opus 5 (1M context)
19
+
1
20
  # 10.0.0 (2026-08-13)
2
21
 
3
22
  ### 🚀 Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klerick/json-api-nestjs",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
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.8",
24
+ "@klerick/json-api-nestjs-shared": "^1.0.0",
25
25
  "ts-toolbelt": "^9.6.0",
26
26
  "zod": "^4.1.0",
27
27
  "zod-validation-error": "^4.0.0"
package/src/index.d.ts CHANGED
@@ -2,7 +2,8 @@ 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, JsonApiResponseFrom } from './lib/modules/mixin/decorators';
4
4
  export { entityForClass, excludeMethod, patchInputData, } from './lib/modules/mixin/helpers/utils';
5
- export { PrepareParams, NestProvider, ValidateQueryError, UnionToTuple, EntityParam, TypeField, Params, JsonApiReadOnlyField, JsonApiImmutableField, } from './lib/types';
5
+ export { isTimezoneAwareColumnType } from './lib/utils';
6
+ export { PrepareParams, NestProvider, ValidateQueryError, UnionToTuple, EntityParam, DatePropertyTimezone, TypeField, Params, JsonApiReadOnlyField, JsonApiImmutableField, } from './lib/types';
6
7
  export { JsonApiTransformerService, ErrorFormatService, EntityParamMapService } from './lib/modules/mixin/service';
7
8
  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';
8
9
  export { OrmService, OrmService as JsonApiService, EntityControllerParam, CheckRelationName, FindOneRowEntity, RunInTransaction, EntityParamMap, MethodName } from './lib/modules/mixin/types';
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.patchInputData = exports.excludeMethod = exports.entityForClass = exports.JsonApiResponseFrom = 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.isTimezoneAwareColumnType = exports.patchInputData = exports.excludeMethod = exports.entityForClass = exports.JsonApiResponseFrom = 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");
@@ -15,6 +15,8 @@ var utils_1 = require("./lib/modules/mixin/helpers/utils");
15
15
  Object.defineProperty(exports, "entityForClass", { enumerable: true, get: function () { return utils_1.entityForClass; } });
16
16
  Object.defineProperty(exports, "excludeMethod", { enumerable: true, get: function () { return utils_1.excludeMethod; } });
17
17
  Object.defineProperty(exports, "patchInputData", { enumerable: true, get: function () { return utils_1.patchInputData; } });
18
+ var utils_2 = require("./lib/utils");
19
+ Object.defineProperty(exports, "isTimezoneAwareColumnType", { enumerable: true, get: function () { return utils_2.isTimezoneAwareColumnType; } });
18
20
  var types_1 = require("./lib/types");
19
21
  Object.defineProperty(exports, "TypeField", { enumerable: true, get: function () { return types_1.TypeField; } });
20
22
  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,0H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AJnB,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"}
@@ -6,14 +6,14 @@ declare function getZodRulesForNumberFunc<Null extends true | false, isPatch ext
6
6
  declare const getZodRulesForNumber: typeof getZodRulesForNumberFunc;
7
7
  declare function getZodRulesForStringFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodString, Null, isPatch>;
8
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>>;
9
+ declare function getZodRulesForDateFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch, hasTimezone?: boolean): 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
10
  declare const getZodRulesForDate: typeof getZodRulesForDateFunc;
11
11
  declare function getZodRulesForBooleanFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodBoolean, Null, isPatch>;
12
12
  declare const getZodRulesForBoolean: typeof getZodRulesForBooleanFunc;
13
13
  declare function getZodSchemaForJsonFunc<Null extends true | false, isPatch extends true | false>(isNullable: Null, isPatch: isPatch): ResultSchema<z.ZodJSONSchema, Null, isPatch>;
14
14
  declare const getZodSchemaForJson: typeof getZodSchemaForJsonFunc;
15
15
  type ZodRulesResultArray<T extends TypeField, Null extends true | false, isPatch extends true | false> = ResultSchema<ZodArray<ZodRulesForType<T, false, false>>, Null, isPatch>;
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>;
16
+ declare function getZodRulesForArrayFunc<T extends TypeField, Null extends true | false, isPatch extends true | false>(propsField: T, isNullable: Null, isPatch: isPatch, hasTimezone?: boolean): ZodRulesResultArray<T, Null, isPatch>;
17
17
  declare const getZodRulesForArray: typeof getZodRulesForArrayFunc;
18
18
  type ZodRulesForArray<T extends TypeField, Null extends true | false, isPatch extends true | false> = ReturnType<typeof getZodRulesForArray<T, Null, isPatch>>;
19
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>>;
@@ -15,8 +15,18 @@ 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) {
19
- return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.iso.datetime(), isNullable, isPatch).transform((map_transform_to_json_shema_1.transformDateString));
18
+ function getZodRulesForDateFunc(isNullable, isPatch, hasTimezone = true) {
19
+ // An explicit offset (2026-09-11T12:20:30+02:00) names an instant just as
20
+ // unambiguously as a trailing Z, so both are accepted. Bare z.iso.datetime()
21
+ // takes only Z, which silently narrowed this field when it moved off
22
+ // z.coerce.date().
23
+ //
24
+ // Whether a zone may be left out follows the column. One that stores no
25
+ // timezone holds a wall-clock reading, so a zone-less datetime says exactly
26
+ // what will be stored. One that does store a timezone would have to fill the
27
+ // missing zone in from wherever the server runs, making the same request mean
28
+ // different instants on different machines -- so there a zone stays required.
29
+ return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.iso.datetime({ offset: true, local: !hasTimezone }), isNullable, isPatch).transform((map_transform_to_json_shema_1.transformDateString));
20
30
  }
21
31
  const getZodRulesForDate = (0, zod_utils_1.memoize)(getZodRulesForDateFunc);
22
32
  function getZodRulesForBooleanFunc(isNullable, isPatch) {
@@ -27,14 +37,14 @@ function getZodSchemaForJsonFunc(isNullable, isPatch) {
27
37
  return (0, zod_utils_1.setOptionalOrNot)(zod_1.z.json(), isNullable, isPatch);
28
38
  }
29
39
  const getZodSchemaForJson = (0, zod_utils_1.memoize)(getZodSchemaForJsonFunc);
30
- function getZodRulesForArrayFunc(propsField, isNullable, isPatch) {
40
+ function getZodRulesForArrayFunc(propsField, isNullable, isPatch, hasTimezone = true) {
31
41
  let schema;
32
42
  switch (propsField) {
33
43
  case types_1.TypeField.number:
34
44
  schema = getZodRulesForNumber(false, false);
35
45
  break;
36
46
  case types_1.TypeField.date:
37
- schema = getZodRulesForDate(false, false);
47
+ schema = getZodRulesForDate(false, false, hasTimezone);
38
48
  break;
39
49
  case types_1.TypeField.boolean:
40
50
  schema = getZodRulesForBoolean(false, false);
@@ -51,14 +61,18 @@ function assertPropsIsarrayProps(paramMap, propsName) {
51
61
  function buildSchema(paramMap, propsName, isPatch) {
52
62
  // @ts-expect-error need check in tuple
53
63
  const isNullable = paramMap.propsNullable.includes(propsName);
64
+ // Absent means the adapter could not read a column type, and the stricter
65
+ // reading -- a zone is required -- is what that falls back to.
66
+ const hasTimezone = Reflect.get(paramMap.propsDateTimezone ?? {}, propsName) ??
67
+ true;
54
68
  if (assertPropsIsarrayProps(paramMap, propsName)) {
55
69
  const arrayPropsType = paramMap.propsArrayType[propsName];
56
- return getZodRulesForArray(arrayPropsType, isNullable, isPatch);
70
+ return getZodRulesForArray(arrayPropsType, isNullable, isPatch, hasTimezone);
57
71
  }
58
72
  const propsType = paramMap.propsType[propsName];
59
73
  switch (propsType) {
60
74
  case types_1.TypeField.date:
61
- return getZodRulesForDate(isNullable, isPatch);
75
+ return getZodRulesForDate(isNullable, isPatch, hasTimezone);
62
76
  case types_1.TypeField.boolean:
63
77
  return getZodRulesForBoolean(isNullable, isPatch);
64
78
  case types_1.TypeField.number:
@@ -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":";;AA2PA,sCAkCC;AA7RD,4EAA8D;AAC9D,6BAA2C;AAE3C,6CAA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Y,CAAC,QAAQ,CAAC,GAA+C,CAAC,EACvE,CAAC;YACD,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAgD,CAAC,CAAC;YAC9F,MAAM,MAAM,GAAG,WAAW,CAAC,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"}
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":";;AAoRA,sCAkCC;AAtTD,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,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1D,OAAO,IAAA,4BAAgB,EAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAA,mBAAO,EAAC,wBAAwB,CAAC,CAAC;AAE/D,SAAS,wBAAwB,CAG/B,UAAgB,EAAE,OAAgB;IAClC,OAAO,IAAA,4BAAgB,EAAC,OAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAA,mBAAO,EAAC,wBAAwB,CAAC,CAAC;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,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"}
@@ -22,6 +22,19 @@ export type ArrayProperty<E extends object, IdKey extends string = 'id'> = {
22
22
  export type ArrayPropertyType<E extends object, IdKey extends string = 'id'> = {
23
23
  [K in ArrayProperty<E, IdKey>]: TypeProps<CastArrayType<Exclude<E[K], null | undefined>>>;
24
24
  };
25
+ export type DateProperty<E extends object, IdKey extends string = 'id'> = {
26
+ [K in AttrKeys<E, IdKey>]: Exclude<E[K], null | undefined> extends Date ? K : never;
27
+ }[AttrKeys<E, IdKey>];
28
+ /**
29
+ * Whether a date column carries a timezone, keyed by property. True for types
30
+ * like `timestamptz`, false for `timestamp without time zone`.
31
+ *
32
+ * Only the runtime metadata knows this -- both column kinds surface as `Date`
33
+ * in TypeScript -- so a property is absent whenever the adapter could not read
34
+ * a column type. Absent is read as "carries a timezone", the stricter of the
35
+ * two, which keeps a zone mandatory for anything not positively identified.
36
+ */
37
+ export type DatePropertyTimezone<E extends object, IdKey extends string = 'id'> = Partial<Record<DateProperty<E, IdKey>, boolean>>;
25
38
  export type NullableProperty<E extends object, IdKey extends string = 'id'> = Union.Intersect<Object.NullableKeys<E>, AttrKeys<E, IdKey>>;
26
39
  export type RelationProperty<E extends object, IdKey extends string = 'id'> = {
27
40
  [K in RelationKeys<E, IdKey>]: {
@@ -35,6 +48,7 @@ export type EntityParam<E extends object, IdKey extends string = 'id'> = {
35
48
  props: UnionToTuple<AttrKeys<E, IdKey>>;
36
49
  propsType: PropertyWithType<E, IdKey>;
37
50
  propsArrayType: ArrayPropertyType<E, IdKey>;
51
+ propsDateTimezone?: DatePropertyTimezone<E, IdKey>;
38
52
  propsNullable: UnionToTuple<NullableProperty<E, IdKey>>;
39
53
  primaryColumnName: IdKey;
40
54
  primaryColumnType: PrimaryType<E, IdKey>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Whether a database column type stores a timezone alongside the value.
3
+ *
4
+ * The adapters read the column type from their own metadata and hand the raw
5
+ * string here, so the dialect spellings live in one place: Postgres reports
6
+ * `timestamp with time zone` or the `timestamptz` shorthand, MikroORM adds the
7
+ * precision inside the phrase (`timestamp(0) with time zone`), and MySQL and
8
+ * SQL Server have no timezone-aware type at all.
9
+ *
10
+ * `without time zone` has to be ruled out before `with time zone` is looked
11
+ * for, since the former contains the latter as a substring.
12
+ */
13
+ export declare function isTimezoneAwareColumnType(columnType: unknown): boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTimezoneAwareColumnType = isTimezoneAwareColumnType;
4
+ /**
5
+ * Whether a database column type stores a timezone alongside the value.
6
+ *
7
+ * The adapters read the column type from their own metadata and hand the raw
8
+ * string here, so the dialect spellings live in one place: Postgres reports
9
+ * `timestamp with time zone` or the `timestamptz` shorthand, MikroORM adds the
10
+ * precision inside the phrase (`timestamp(0) with time zone`), and MySQL and
11
+ * SQL Server have no timezone-aware type at all.
12
+ *
13
+ * `without time zone` has to be ruled out before `with time zone` is looked
14
+ * for, since the former contains the latter as a substring.
15
+ */
16
+ function isTimezoneAwareColumnType(columnType) {
17
+ if (typeof columnType !== 'string') {
18
+ return false;
19
+ }
20
+ const normalized = columnType.toLowerCase();
21
+ if (normalized.includes('without time zone')) {
22
+ return false;
23
+ }
24
+ return (normalized.includes('with time zone') ||
25
+ /\b(timestamptz|timetz)\b/.test(normalized));
26
+ }
27
+ //# sourceMappingURL=column-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-type.js","sourceRoot":"","sources":["../../../../../../../libs/json-api/json-api-nestjs/src/lib/utils/column-type.ts"],"names":[],"mappings":";;AAYA,8DAeC;AA3BD;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,UAAmB;IAC3D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAE5C,IAAI,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACrC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAC5C,CAAC;AACJ,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './module-helper';
2
+ export * from './column-type';
@@ -2,4 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./module-helper"), exports);
5
+ tslib_1.__exportStar(require("./column-type"), exports);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/json-api/json-api-nestjs/src/lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/json-api/json-api-nestjs/src/lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,wDAA8B"}