@clipboard-health/json-api-nestjs 0.3.0 → 0.4.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.
Files changed (35) hide show
  1. package/README.md +35 -14
  2. package/package.json +2 -1
  3. package/src/index.d.ts +5 -5
  4. package/src/index.js +5 -5
  5. package/src/index.js.map +1 -1
  6. package/src/lib/internal/queryFilterPreprocessor.js +2 -2
  7. package/src/lib/internal/queryFilterPreprocessor.js.map +1 -1
  8. package/src/lib/query/{createCursorPagination.d.ts → cursorPaginationQuery.d.ts} +13 -5
  9. package/src/lib/query/{createCursorPagination.js → cursorPaginationQuery.js} +15 -7
  10. package/src/lib/query/cursorPaginationQuery.js.map +1 -0
  11. package/src/lib/query/{createFields.d.ts → fieldsQuery.d.ts} +10 -4
  12. package/src/lib/query/{createFields.js → fieldsQuery.js} +6 -6
  13. package/src/lib/query/fieldsQuery.js.map +1 -0
  14. package/src/lib/query/{createFilter.d.ts → filterQuery.d.ts} +4 -4
  15. package/src/lib/query/{createFilter.js → filterQuery.js} +8 -6
  16. package/src/lib/query/filterQuery.js.map +1 -0
  17. package/src/lib/query/includeQuery.d.ts +31 -0
  18. package/src/lib/query/{createInclude.js → includeQuery.js} +6 -6
  19. package/src/lib/query/includeQuery.js.map +1 -0
  20. package/src/lib/query/{createSort.d.ts → sortQuery.d.ts} +3 -3
  21. package/src/lib/query/{createSort.js → sortQuery.js} +6 -6
  22. package/src/lib/query/sortQuery.js.map +1 -0
  23. package/src/lib/schemas.d.ts +5 -1
  24. package/src/lib/schemas.js +7 -1
  25. package/src/lib/schemas.js.map +1 -1
  26. package/src/lib/types.d.ts +34 -0
  27. package/src/test/index.d.ts +0 -1
  28. package/src/test/index.js +0 -1
  29. package/src/test/index.js.map +1 -1
  30. package/src/lib/query/createCursorPagination.js.map +0 -1
  31. package/src/lib/query/createFields.js.map +0 -1
  32. package/src/lib/query/createFilter.js.map +0 -1
  33. package/src/lib/query/createInclude.d.ts +0 -12
  34. package/src/lib/query/createInclude.js.map +0 -1
  35. package/src/lib/query/createSort.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # @clipboard-health/json-api-nestjs
1
+ # @clipboard-health/json-api-nestjs <!-- omit from toc -->
2
2
 
3
3
  Utilities for adhering to the [JSON:API](https://jsonapi.org/) specification with [NestJS](https://nestjs.com/).
4
4
 
5
- ## Table of Contents
5
+ ## Table of contents <!-- omit from toc -->
6
6
 
7
7
  - [Install](#install)
8
8
  - [Usage](#usage)
@@ -23,23 +23,44 @@ Create Zod schemas for your API's queries:
23
23
 
24
24
  <!-- prettier-ignore -->
25
25
  ```ts
26
- // ./examples/query.ts
26
+ // ../example-nestjs/examples/query.ts
27
27
 
28
28
  import {
29
29
  booleanString,
30
- createCursorPagination,
31
- createFields,
32
- createFilter,
33
- createInclude,
34
- createSort,
30
+ cursorPaginationQuery,
31
+ fieldsQuery,
32
+ filterQuery,
33
+ includeQuery,
34
+ sortQuery,
35
35
  } from "@clipboard-health/json-api-nestjs";
36
36
  import { z } from "zod";
37
37
 
38
+ import {
39
+ type ArticleAttributeFields,
40
+ type UserAttributeFields,
41
+ type UserIncludeFields,
42
+ } from "../src/contract";
43
+
44
+ const articleFields = ["title"] as const satisfies readonly ArticleAttributeFields[];
45
+ const userFields = ["age", "dateOfBirth"] as const satisfies readonly UserAttributeFields[];
46
+ const includeFields = [
47
+ "articles",
48
+ "articles.comments",
49
+ ] as const satisfies readonly UserIncludeFields[];
50
+
51
+ /**
52
+ * Disclaimer: Just because JSON:API supports robust querying doesn’t mean your service should
53
+ * implement them as they may require database indexes, which have a cost. **Implement only access
54
+ * patterns required by clients.**
55
+ *
56
+ * The spec says that if clients provide fields the server doesn’t support, it **MUST** return 400
57
+ * Bad Request, hence the `.strict()`.
58
+ */
38
59
  export const query = z
39
60
  .object({
40
- ...createCursorPagination(),
41
- ...createFields({ user: ["age", "name"], article: ["title"] }),
42
- ...createFilter({
61
+ ...cursorPaginationQuery(),
62
+ ...fieldsQuery({ user: userFields, article: articleFields }),
63
+ ...filterQuery({
43
64
  age: {
44
65
  filters: ["eq", "gt"],
45
66
  schema: z.coerce.number().int().positive().max(125),
@@ -50,11 +71,11 @@ export const query = z
50
71
  },
51
72
  dateOfBirth: {
52
73
  filters: ["gte"],
53
- schema: z.coerce.date().min(new Date("1900-01-01")),
74
+ schema: z.coerce.date().min(new Date("1900-01-01")).max(new Date()),
54
75
  },
55
76
  }),
56
- ...createSort(["age", "name"]),
57
- ...createInclude(["articles", "articles.comments"]),
77
+ ...sortQuery(userFields),
78
+ ...includeQuery(includeFields),
58
79
  })
59
80
  .strict();
60
81
 
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@clipboard-health/json-api-nestjs",
3
3
  "description": "Utilities for adhering to the JSON:API specification with NestJS.",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "dependencies": {
6
6
  "tslib": "2.7.0",
7
+ "type-fest": "4.26.1",
7
8
  "zod": "3.23.8"
8
9
  },
9
10
  "keywords": [],
package/src/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./lib/query/createCursorPagination";
2
- export * from "./lib/query/createFields";
3
- export * from "./lib/query/createFilter";
4
- export * from "./lib/query/createInclude";
5
- export * from "./lib/query/createSort";
1
+ export * from "./lib/query/cursorPaginationQuery";
2
+ export * from "./lib/query/fieldsQuery";
3
+ export * from "./lib/query/filterQuery";
4
+ export * from "./lib/query/includeQuery";
5
+ export * from "./lib/query/sortQuery";
6
6
  export * from "./lib/schemas";
7
7
  export * from "./lib/types";
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/query/createCursorPagination"), exports);
5
- tslib_1.__exportStar(require("./lib/query/createFields"), exports);
6
- tslib_1.__exportStar(require("./lib/query/createFilter"), exports);
7
- tslib_1.__exportStar(require("./lib/query/createInclude"), exports);
8
- tslib_1.__exportStar(require("./lib/query/createSort"), exports);
4
+ tslib_1.__exportStar(require("./lib/query/cursorPaginationQuery"), exports);
5
+ tslib_1.__exportStar(require("./lib/query/fieldsQuery"), exports);
6
+ tslib_1.__exportStar(require("./lib/query/filterQuery"), exports);
7
+ tslib_1.__exportStar(require("./lib/query/includeQuery"), exports);
8
+ tslib_1.__exportStar(require("./lib/query/sortQuery"), exports);
9
9
  tslib_1.__exportStar(require("./lib/schemas"), exports);
10
10
  tslib_1.__exportStar(require("./lib/types"), exports);
11
11
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD;AACnD,mEAAyC;AACzC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,wDAA8B;AAC9B,sDAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,4EAAkD;AAClD,kEAAwC;AACxC,kEAAwC;AACxC,mEAAyC;AACzC,gEAAsC;AACtC,wDAA8B;AAC9B,sDAA4B"}
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryFilterPreprocessor = queryFilterPreprocessor;
2
4
  /**
3
5
  * NestJS-specific query processing based on the output of `ctx.switchToHttp().getRequest().query`.
4
6
  *
@@ -12,8 +14,6 @@
12
14
  * 5. For `?filter[age][gt]=5&filter[age]=10&filter[age]=20`, `value` is `{'0': '10', '1': '20', gt:
13
15
  * '5'}`, which we transform to `{eq: "10,20", gt: "5"}`.
14
16
  */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.queryFilterPreprocessor = queryFilterPreprocessor;
17
17
  function queryFilterPreprocessor(value) {
18
18
  if (!isObject(value)) {
19
19
  // Cases 1 and 2.
@@ -1 +1 @@
1
- {"version":3,"file":"queryFilterPreprocessor.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/internal/queryFilterPreprocessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAEH,0DAwBC;AAxBD,SAAgB,uBAAuB,CAAC,KAAc;IACpD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,iBAAiB;QACjB,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAyB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,SAAS,CAAC;QAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;YACnC,iBAAiB;YACjB,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO;gBACL,GAAG,MAAM;gBACT,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAChD,CAAC;QACJ,CAAC;QAED,+CAA+C;QAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO;YACL,GAAG,MAAM;YACT,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW;SACnE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,uDAAuD;IACvD,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"queryFilterPreprocessor.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/internal/queryFilterPreprocessor.ts"],"names":[],"mappings":";;AAaA,0DAwBC;AArCD;;;;;;;;;;;;GAYG;AACH,SAAgB,uBAAuB,CAAC,KAAc;IACpD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,iBAAiB;QACjB,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAyB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,SAAS,CAAC;QAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;YACnC,iBAAiB;YACjB,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO;gBACL,GAAG,MAAM;gBACT,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;aAChD,CAAC;QACJ,CAAC;QAED,+CAA+C;QAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO;YACL,GAAG,MAAM;YACT,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW;SACnE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,uDAAuD;IACvD,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC"}
@@ -1,16 +1,24 @@
1
1
  import { z } from "zod";
2
+ export declare const PAGINATION: {
3
+ readonly size: {
4
+ readonly maximum: 200;
5
+ readonly default: 20;
6
+ };
7
+ };
2
8
  /**
3
9
  * Creates a Zod schema for JSON:API cursor pagination.
4
10
  *
5
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
11
+ * @includeExample ./packages/example-nestjs/examples/query.ts
6
12
  *
7
- * @see [Usage example](../../../examples/query.ts)
13
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
8
14
  * @see {@link https://jsonapi.org/format/#fetching-pagination JSON:API pagination}
9
15
  * @see {@link https://jsonapi.org/examples/#pagination JSON:API pagination examples}
10
16
  */
11
- export declare function createCursorPagination(parameters?: Readonly<{
12
- maximumSize?: number;
13
- defaultSize?: number;
17
+ export declare function cursorPaginationQuery(parameters?: Readonly<{
18
+ size: {
19
+ maximum?: number;
20
+ default?: number;
21
+ };
14
22
  }>): {
15
23
  page: z.ZodDefault<z.ZodObject<{
16
24
  size: z.ZodDefault<z.ZodNumber>;
@@ -1,27 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCursorPagination = createCursorPagination;
3
+ exports.PAGINATION = void 0;
4
+ exports.cursorPaginationQuery = cursorPaginationQuery;
4
5
  const zod_1 = require("zod");
5
6
  const schemas_1 = require("../schemas");
7
+ exports.PAGINATION = {
8
+ size: {
9
+ maximum: 200,
10
+ default: 20,
11
+ },
12
+ };
6
13
  /**
7
14
  * Creates a Zod schema for JSON:API cursor pagination.
8
15
  *
9
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
16
+ * @includeExample ./packages/example-nestjs/examples/query.ts
10
17
  *
11
- * @see [Usage example](../../../examples/query.ts)
18
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
12
19
  * @see {@link https://jsonapi.org/format/#fetching-pagination JSON:API pagination}
13
20
  * @see {@link https://jsonapi.org/examples/#pagination JSON:API pagination examples}
14
21
  */
15
- function createCursorPagination(parameters) {
16
- const { maximumSize = 200, defaultSize = 20 } = parameters ?? {};
22
+ function cursorPaginationQuery(parameters) {
23
+ const { size } = exports.PAGINATION;
24
+ const { maximum = size.maximum, default: defaultSize = size.default } = parameters?.size ?? {};
17
25
  return {
18
26
  page: zod_1.z
19
27
  .object({
20
- size: zod_1.z.coerce.number().int().positive().max(maximumSize).default(defaultSize),
28
+ size: zod_1.z.coerce.number().int().positive().max(maximum).default(defaultSize),
21
29
  cursor: schemas_1.nonEmptyString.optional(),
22
30
  })
23
31
  .strict()
24
32
  .default({ size: defaultSize }),
25
33
  };
26
34
  }
27
- //# sourceMappingURL=createCursorPagination.js.map
35
+ //# sourceMappingURL=cursorPaginationQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursorPaginationQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/cursorPaginationQuery.ts"],"names":[],"mappings":";;;AAoBA,sDAeC;AAnCD,6BAAwB;AAExB,wCAA4C;AAE/B,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,EAAE;KACZ;CACO,CAAC;AAEX;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,UAAuE;IAEvE,MAAM,EAAE,IAAI,EAAE,GAAG,kBAAU,CAAC;IAC5B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC;IAE/F,OAAO;QACL,IAAI,EAAE,OAAC;aACJ,MAAM,CAAC;YACN,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;YAC1E,MAAM,EAAE,wBAAc,CAAC,QAAQ,EAAE;SAClC,CAAC;aACD,MAAM,EAAE;aACR,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC"}
@@ -1,17 +1,23 @@
1
1
  import { z } from "zod";
2
- import { type ApiType, type Field } from "../types";
2
+ import { type ApiType, type Data, type Field, type JsonApiDocument } from "../types";
3
3
  export type FieldsMap = Record<ApiType, readonly [Field, ...Field[]]>;
4
4
  export type FieldsSchema<MapT extends FieldsMap> = {
5
5
  [K in keyof MapT]: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEnum<z.Writeable<MapT[K]>>>>, Array<MapT[K][number]> | undefined, unknown>;
6
6
  };
7
+ /**
8
+ * JSON:API attribute fields for use in fields queries.
9
+ *
10
+ * @template DocumentT - The JSON:API document.
11
+ */
12
+ export type AttributeFields<DocumentT extends JsonApiDocument> = DocumentT["data"] extends Array<infer R extends Data> ? keyof R["attributes"] : DocumentT["data"] extends Data ? keyof DocumentT["data"]["attributes"] : never;
7
13
  /**
8
14
  * Creates a Zod schema for JSON:API sparse fieldsets.
9
15
  *
10
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
16
+ * @includeExample ./packages/example-nestjs/examples/query.ts
11
17
  *
12
- * @see [Usage example](../../../examples/query.ts)
18
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
13
19
  * @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets JSON:API sparse fieldsets}
14
20
  */
15
- export declare function createFields<const MapT extends FieldsMap>(parameters: Readonly<MapT>): {
21
+ export declare function fieldsQuery<const MapT extends FieldsMap>(parameters: Readonly<MapT>): {
16
22
  fields: z.ZodOptional<z.ZodObject<FieldsSchema<MapT>, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FieldsSchema<MapT>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FieldsSchema<MapT>>, any>[k]; } : never, z.baseObjectInputType<FieldsSchema<MapT>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<FieldsSchema<MapT>>[k_1]; } : never>>;
17
23
  };
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFields = createFields;
3
+ exports.fieldsQuery = fieldsQuery;
4
4
  const zod_1 = require("zod");
5
5
  const splitString_1 = require("../internal/splitString");
6
6
  /**
7
7
  * Creates a Zod schema for JSON:API sparse fieldsets.
8
8
  *
9
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
9
+ * @includeExample ./packages/example-nestjs/examples/query.ts
10
10
  *
11
- * @see [Usage example](../../../examples/query.ts)
11
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
12
12
  * @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets JSON:API sparse fieldsets}
13
13
  */
14
- function createFields(parameters) {
14
+ function fieldsQuery(parameters) {
15
15
  const fieldSchemas = Object.fromEntries(Object.entries(parameters).map(([apiType, fields]) => [
16
16
  apiType,
17
- zod_1.z.preprocess(splitString_1.splitString, zod_1.z.array(zod_1.z.enum(fields)).min(1).optional()),
17
+ zod_1.z.preprocess(splitString_1.splitString, zod_1.z.enum(fields).array().min(1).max(100).optional()),
18
18
  ]));
19
19
  return {
20
20
  fields: zod_1.z.object(fieldSchemas).strict().optional(),
21
21
  };
22
22
  }
23
- //# sourceMappingURL=createFields.js.map
23
+ //# sourceMappingURL=fieldsQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldsQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/fieldsQuery.ts"],"names":[],"mappings":";;AAmCA,kCAYC;AA/CD,6BAAwB;AAExB,yDAAsD;AAyBtD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAA+B,UAA0B;IAClF,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CACrC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAiC,EAAE,EAAE,CAAC;QACpF,OAAO;QACP,OAAC,CAAC,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC7E,CAAC,CAEmB,CAAC;IAExB,OAAO;QACL,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACnD,CAAC;AACJ,CAAC"}
@@ -7,18 +7,18 @@ export type FilterMap = Record<ApiType, {
7
7
  }>;
8
8
  export type FilterSchema<MapT extends FilterMap> = {
9
9
  [K in keyof MapT]: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodObject<{
10
- [F in MapT[K]["filters"][number]]: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodArray<MapT[K]["schema"]>>>>;
10
+ [F in MapT[K]["filters"][number]]: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodReadonly<z.ZodArray<MapT[K]["schema"]>>>>>;
11
11
  }>>>>;
12
12
  };
13
13
  /**
14
14
  * Creates a Zod schema for JSON:API filters.
15
15
  *
16
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
16
+ * @includeExample ./packages/example-nestjs/examples/query.ts
17
17
  *
18
- * @see [Usage example](../../../examples/query.ts)
18
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
19
19
  * @see {@link https://jsonapi.org/recommendations/#filtering JSON:API filtering}
20
20
  * @see {@link https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257 JSON:API filtering strategy}
21
21
  */
22
- export declare function createFilter<const MapT extends FilterMap>(parameters: Readonly<MapT>): {
22
+ export declare function filterQuery<const MapT extends FilterMap>(parameters: Readonly<MapT>): {
23
23
  filter: z.ZodOptional<z.ZodObject<FilterSchema<MapT>, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterSchema<MapT>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterSchema<MapT>>, any>[k]; } : never, z.baseObjectInputType<FilterSchema<MapT>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<FilterSchema<MapT>>[k_1]; } : never>>;
24
24
  };
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFilter = createFilter;
3
+ exports.filterQuery = filterQuery;
4
4
  const zod_1 = require("zod");
5
5
  const queryFilterPreprocessor_1 = require("../internal/queryFilterPreprocessor");
6
6
  const splitString_1 = require("../internal/splitString");
7
7
  /**
8
8
  * Creates a Zod schema for JSON:API filters.
9
9
  *
10
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
10
+ * @includeExample ./packages/example-nestjs/examples/query.ts
11
11
  *
12
- * @see [Usage example](../../../examples/query.ts)
12
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
13
13
  * @see {@link https://jsonapi.org/recommendations/#filtering JSON:API filtering}
14
14
  * @see {@link https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257 JSON:API filtering strategy}
15
15
  */
16
- function createFilter(parameters) {
16
+ function filterQuery(parameters) {
17
17
  return {
18
18
  filter: zod_1.z
19
19
  .object(Object.fromEntries(Object.entries(parameters).map(([apiType, { filters, schema }]) => [
@@ -22,7 +22,9 @@ function createFilter(parameters) {
22
22
  .preprocess(queryFilterPreprocessor_1.queryFilterPreprocessor, zod_1.z
23
23
  .object(Object.fromEntries(filters.map((filter) => [
24
24
  filter,
25
- zod_1.z.preprocess(splitString_1.splitString, zod_1.z.array(schema).optional()).optional(),
25
+ zod_1.z
26
+ .preprocess(splitString_1.splitString, schema.array().min(1).max(10_000).readonly().optional())
27
+ .optional(),
26
28
  ])))
27
29
  .strict()
28
30
  .optional())
@@ -32,4 +34,4 @@ function createFilter(parameters) {
32
34
  .optional(),
33
35
  };
34
36
  }
35
- //# sourceMappingURL=createFilter.js.map
37
+ //# sourceMappingURL=filterQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/filterQuery.ts"],"names":[],"mappings":";;AAuCA,kCAqCC;AA5ED,6BAAwB;AAExB,iFAA8E;AAC9E,yDAAsD;AA2BtD;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAA+B,UAA0B;IAClF,OAAO;QACL,MAAM,EAAE,OAAC;aACN,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAC5B,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAiC,EAAE,EAAE,CAAC;YAClE,OAAO;YACP,OAAC;iBACE,UAAU,CACT,iDAAuB,EACvB,OAAC;iBACE,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC;gBAC9B,MAAM;gBACN,OAAC;qBACE,UAAU,CACT,yBAAW,EACX,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CACxD;qBACA,QAAQ,EAAE;aACd,CAAC,CACH,CACF;iBACA,MAAM,EAAE;iBACR,QAAQ,EAAE,CACd;iBACA,QAAQ,EAAE;SACd,CACF,CAEoB,CACxB;aACA,MAAM,EAAE;aACR,QAAQ,EAAE;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type GreaterThan, type Subtract } from "type-fest";
2
+ import { z } from "zod";
3
+ import { type JsonApiDocument, type Relationship } from "../types";
4
+ /**
5
+ * JSON:API relationship paths for use in include queries.
6
+ *
7
+ * @template MapT - A map of ApiType to Zod schemas.
8
+ * @template DocumentT - The JSON:API document.
9
+ * @template RecursiveDepth - The maximum depth for recursive relationship traversal.
10
+ * @template Prefix - The prefix for nested relationship paths.
11
+ */
12
+ export type RelationshipPaths<MapT extends Record<string, z.ZodTypeAny>, DocumentT extends JsonApiDocument, RecursiveDepth extends number = 5, Prefix extends string = ""> = RecursiveDepth extends infer Depth extends number ? GreaterThan<Depth, 0> extends true ? DocumentT["data"] extends Array<infer SingleOrArray> | infer SingleOrArray ? SingleOrArray extends {
13
+ relationships?: infer R;
14
+ } ? R extends Record<string, Relationship> ? {
15
+ [K in keyof R]: K extends string ? R[K]["data"] extends {
16
+ type?: infer RelationT;
17
+ } | Array<{
18
+ type?: infer RelationT;
19
+ }> ? RelationT extends keyof MapT ? `${Prefix}${K}` | RelationshipPaths<MapT, z.infer<MapT[RelationT]>, Subtract<Depth, 1>, `${Prefix}${K}.`> : never : never : never;
20
+ }[keyof R] : never : never : never : never : never;
21
+ /**
22
+ * Creates a Zod schema for JSON:API include parameters.
23
+ *
24
+ * @includeExample ./packages/example-nestjs/examples/query.ts
25
+ *
26
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
27
+ * @see {@link https://jsonapi.org/format/#fetching-includes JSON:API includes}
28
+ */
29
+ export declare function includeQuery<const FieldT extends readonly string[]>(fields: FieldT): {
30
+ include: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodString, "many">>, string[] | undefined, unknown>, string[] | undefined, unknown>, FieldT[number][] | undefined, unknown>;
31
+ };
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInclude = createInclude;
3
+ exports.includeQuery = includeQuery;
4
4
  const zod_1 = require("zod");
5
5
  const splitString_1 = require("../internal/splitString");
6
6
  /**
7
7
  * Creates a Zod schema for JSON:API include parameters.
8
8
  *
9
- * @param fields An array of valid include fields.
10
- * @returns A Zod schema for the include parameter.
9
+ * @includeExample ./packages/example-nestjs/examples/query.ts
11
10
  *
11
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
12
12
  * @see {@link https://jsonapi.org/format/#fetching-includes JSON:API includes}
13
13
  */
14
- function createInclude(fields) {
14
+ function includeQuery(fields) {
15
15
  const fieldSet = new Set(fields);
16
16
  return {
17
17
  include: zod_1.z
18
- .preprocess(splitString_1.splitString, zod_1.z.array(zod_1.z.string()).optional())
18
+ .preprocess(splitString_1.splitString, zod_1.z.string().array().min(1).max(100).optional())
19
19
  .superRefine((value, context) => {
20
20
  if (!value) {
21
21
  return;
@@ -33,4 +33,4 @@ function createInclude(fields) {
33
33
  .transform((value) => value),
34
34
  };
35
35
  }
36
- //# sourceMappingURL=createInclude.js.map
36
+ //# sourceMappingURL=includeQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"includeQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/includeQuery.ts"],"names":[],"mappings":";;AAwDA,oCAuBC;AA9ED,6BAAwB;AAExB,yDAAsD;AA6CtD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAyC,MAAc;IACjF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO;QACL,OAAO,EAAE,OAAC;aACP,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;aACtE,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;wBAC3B,OAAO,EAAE,2BAA2B,KAAK,GAAG;wBAC5C,IAAI,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC;qBACzB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAA0C,CAAC;KACpE,CAAC;AACJ,CAAC"}
@@ -3,11 +3,11 @@ import { type Field } from "../types";
3
3
  /**
4
4
  * Creates a Zod schema for JSON:API sort parameters.
5
5
  *
6
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
6
+ * @includeExample ./packages/example-nestjs/examples/query.ts
7
7
  *
8
- * @see [Usage example](../../../examples/query.ts)
8
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
9
9
  * @see {@link https://jsonapi.org/format/#fetching-sorting JSON:API sorting}
10
10
  */
11
- export declare function createSort<const FieldT extends readonly [Field, ...Field[]]>(fields: FieldT): {
11
+ export declare function sortQuery<const FieldT extends readonly [Field, ...Field[]]>(fields: FieldT): {
12
12
  sort: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodString, "many">>, string[] | undefined, unknown>, string[] | undefined, unknown>, (FieldT[number] | `-${FieldT[number]}`)[] | undefined, unknown>;
13
13
  };
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSort = createSort;
3
+ exports.sortQuery = sortQuery;
4
4
  const zod_1 = require("zod");
5
5
  const splitString_1 = require("../internal/splitString");
6
6
  /**
7
7
  * Creates a Zod schema for JSON:API sort parameters.
8
8
  *
9
- * @includeExample ./packages/json-api-nestjs/examples/query.ts
9
+ * @includeExample ./packages/example-nestjs/examples/query.ts
10
10
  *
11
- * @see [Usage example](../../../examples/query.ts)
11
+ * @see [Usage example](../../../../example-nestjs/examples/query.ts)
12
12
  * @see {@link https://jsonapi.org/format/#fetching-sorting JSON:API sorting}
13
13
  */
14
- function createSort(fields) {
14
+ function sortQuery(fields) {
15
15
  const fieldSet = new Set(fields);
16
16
  return {
17
17
  sort: zod_1.z
18
- .preprocess(splitString_1.splitString, zod_1.z.array(zod_1.z.string()).optional())
18
+ .preprocess(splitString_1.splitString, zod_1.z.string().array().min(1).max(100).optional())
19
19
  .superRefine((value, context) => {
20
20
  if (!value) {
21
21
  return;
@@ -33,4 +33,4 @@ function createSort(fields) {
33
33
  .transform((value) => value),
34
34
  };
35
35
  }
36
- //# sourceMappingURL=createSort.js.map
36
+ //# sourceMappingURL=sortQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/sortQuery.ts"],"names":[],"mappings":";;AAaA,8BAsBC;AAnCD,6BAAwB;AAExB,yDAAsD;AAGtD;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAoD,MAAc;IACzF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO;QACL,IAAI,EAAE,OAAC;aACJ,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;aACtE,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClE,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;wBAC3B,OAAO,EAAE,wBAAwB,KAAK,GAAG;wBACzC,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;qBACtB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAiE,CAAC;KAC3F,CAAC;AACJ,CAAC"}
@@ -6,5 +6,9 @@ export declare const nonEmptyString: z.ZodString;
6
6
  /**
7
7
  * A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
8
8
  * value as `true`.
9
+ *
10
+ * `.transform((value) => value === "true")` causes inference issues in controllers.
9
11
  */
10
- export declare const booleanString: z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">;
12
+ export declare const booleanString: z.ZodEnum<["true", "false"]>;
13
+ export type BooleanString = z.infer<typeof booleanString>;
14
+ export declare function toBoolean(value: BooleanString): boolean;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.booleanString = exports.nonEmptyString = void 0;
4
+ exports.toBoolean = toBoolean;
4
5
  const zod_1 = require("zod");
5
6
  /**
6
7
  * A non-empty string Zod schema.
@@ -9,6 +10,11 @@ exports.nonEmptyString = zod_1.z.string().min(1);
9
10
  /**
10
11
  * A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
11
12
  * value as `true`.
13
+ *
14
+ * `.transform((value) => value === "true")` causes inference issues in controllers.
12
15
  */
13
- exports.booleanString = zod_1.z.enum(["true", "false"]).transform((value) => value === "true");
16
+ exports.booleanString = zod_1.z.enum(["true", "false"]);
17
+ function toBoolean(value) {
18
+ return value === "true";
19
+ }
14
20
  //# sourceMappingURL=schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../../packages/json-api-nestjs/src/lib/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;GAEG;AACU,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhD;;;GAGG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../../packages/json-api-nestjs/src/lib/schemas.ts"],"names":[],"mappings":";;;AAiBA,8BAEC;AAnBD,6BAAwB;AAExB;;GAEG;AACU,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhD;;;;;GAKG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAIvD,SAAgB,SAAS,CAAC,KAAoB;IAC5C,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC"}
@@ -1,2 +1,36 @@
1
+ import { type Arrayable } from "type-fest";
1
2
  export type ApiType = string;
2
3
  export type Field = string;
4
+ export type Meta = Record<string, unknown>;
5
+ export type ApiLinks = Record<string, string | undefined>;
6
+ export interface Relationship {
7
+ data?: Arrayable<{
8
+ id?: string;
9
+ type?: ApiType;
10
+ }>;
11
+ links?: ApiLinks;
12
+ meta?: Meta;
13
+ }
14
+ export interface Data {
15
+ attributes?: Record<string, unknown>;
16
+ id?: string;
17
+ links?: ApiLinks;
18
+ meta?: Meta;
19
+ relationships?: Record<string, Relationship>;
20
+ type?: ApiType;
21
+ }
22
+ /**
23
+ * The JSON:API document shape.
24
+ */
25
+ export interface JsonApiDocument {
26
+ data?: Arrayable<Data>;
27
+ included?: Data[];
28
+ jsonapi?: {
29
+ ext?: Record<string, unknown>;
30
+ meta?: Meta;
31
+ profile?: string;
32
+ version?: string;
33
+ };
34
+ links?: ApiLinks;
35
+ meta?: Meta;
36
+ }
@@ -1,4 +1,3 @@
1
1
  import { type SafeParseError, type SafeParseReturnType, type SafeParseSuccess } from "zod";
2
- export declare function expectToBeDefined<T>(value: T | undefined): asserts value is T;
3
2
  export declare function expectToBeSuccess<Input, Output>(value: Readonly<SafeParseReturnType<Input, Output>>): asserts value is SafeParseSuccess<Output>;
4
3
  export declare function expectToBeError<Input, Output>(value: Readonly<SafeParseReturnType<Input, Output>>): asserts value is SafeParseError<Input>;
package/src/test/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expectToBeDefined = expectToBeDefined;
4
3
  exports.expectToBeSuccess = expectToBeSuccess;
5
4
  exports.expectToBeError = expectToBeError;
6
5
  const node_assert_1 = require("node:assert");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/json-api-nestjs/src/test/index.ts"],"names":[],"mappings":";;AAeA,8CAEC;AAED,8CAKC;AAED,0CAKC;AA/BD,6CAAiC;AAOjC,SAAS,iBAAiB,CAAI,KAA0B;IACtD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED,SAAS,SAAS,CAAI,KAA0B;IAC9C,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,iBAAiB,CAAI,KAAoB;IACvD,IAAA,gBAAE,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,SAAgB,iBAAiB,CAC/B,KAAmD;IAEnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AAED,SAAgB,eAAe,CAC7B,KAAmD;IAEnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/json-api-nestjs/src/test/index.ts"],"names":[],"mappings":";;AAmBA,8CAKC;AAED,0CAKC;AA/BD,6CAAiC;AAOjC,SAAS,iBAAiB,CAAI,KAA0B;IACtD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED,SAAS,SAAS,CAAI,KAA0B;IAC9C,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,iBAAiB,CAAI,KAAoB;IAChD,IAAA,gBAAE,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,SAAgB,iBAAiB,CAC/B,KAAmD;IAEnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AAED,SAAgB,eAAe,CAC7B,KAAmD;IAEnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCursorPagination.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/createCursorPagination.ts"],"names":[],"mappings":";;AAaA,wDAcC;AA3BD,6BAAwB;AAExB,wCAA4C;AAE5C;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,UAAqE;IAErE,MAAM,EAAE,WAAW,GAAG,GAAG,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE,OAAC;aACJ,MAAM,CAAC;YACN,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;YAC9E,MAAM,EAAE,wBAAc,CAAC,QAAQ,EAAE;SAClC,CAAC;aACD,MAAM,EAAE;aACR,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createFields.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/createFields.ts"],"names":[],"mappings":";;AAuBA,oCAYC;AAnCD,6BAAwB;AAExB,yDAAsD;AAatD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAA+B,UAA0B;IACnF,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CACrC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAiC,EAAE,EAAE,CAAC;QACpF,OAAO;QACP,OAAC,CAAC,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KACrE,CAAC,CAEmB,CAAC;IAExB,OAAO;QACL,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACnD,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createFilter.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/createFilter.ts"],"names":[],"mappings":";;AAuCA,oCAgCC;AAvED,6BAAwB;AAExB,iFAA8E;AAC9E,yDAAsD;AA2BtD;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAA+B,UAA0B;IACnF,OAAO;QACL,MAAM,EAAE,OAAC;aACN,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAC5B,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAiC,EAAE,EAAE,CAAC;YAClE,OAAO;YACP,OAAC;iBACE,UAAU,CACT,iDAAuB,EACvB,OAAC;iBACE,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC;gBAC9B,MAAM;gBACN,OAAC,CAAC,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;aACjE,CAAC,CACH,CACF;iBACA,MAAM,EAAE;iBACR,QAAQ,EAAE,CACd;iBACA,QAAQ,EAAE;SACd,CACF,CAEoB,CACxB;aACA,MAAM,EAAE;aACR,QAAQ,EAAE;KACd,CAAC;AACJ,CAAC"}
@@ -1,12 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Creates a Zod schema for JSON:API include parameters.
4
- *
5
- * @param fields An array of valid include fields.
6
- * @returns A Zod schema for the include parameter.
7
- *
8
- * @see {@link https://jsonapi.org/format/#fetching-includes JSON:API includes}
9
- */
10
- export declare function createInclude<const FieldT extends readonly string[]>(fields: FieldT): {
11
- include: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodString, "many">>, string[] | undefined, unknown>, string[] | undefined, unknown>, FieldT[number][] | undefined, unknown>;
12
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"createInclude.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/createInclude.ts"],"names":[],"mappings":";;AAYA,sCAuBC;AAnCD,6BAAwB;AAExB,yDAAsD;AAEtD;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAyC,MAAc;IAClF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO;QACL,OAAO,EAAE,OAAC;aACP,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;aACvD,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;wBAC3B,OAAO,EAAE,2BAA2B,KAAK,GAAG;wBAC5C,IAAI,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC;qBACzB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAA0C,CAAC;KACpE,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSort.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/createSort.ts"],"names":[],"mappings":";;AAaA,gCAsBC;AAnCD,6BAAwB;AAExB,yDAAsD;AAGtD;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAoD,MAAc;IAC1F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO;QACL,IAAI,EAAE,OAAC;aACJ,UAAU,CAAC,yBAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;aACvD,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClE,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;wBAC3B,OAAO,EAAE,wBAAwB,KAAK,GAAG;wBACzC,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;qBACtB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAiE,CAAC;KAC3F,CAAC;AACJ,CAAC"}