@clipboard-health/json-api-nestjs 0.15.6 → 0.15.8
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/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clipboard-health/json-api-nestjs",
|
|
3
3
|
"description": "TypeScript-friendly utilities for adhering to the JSON:API specification with NestJS.",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.8",
|
|
5
5
|
"bugs": "https://github.com/ClipboardHealth/core-utils/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@clipboard-health/contract-core": "0.3.0",
|
|
8
8
|
"tslib": "2.8.0",
|
|
9
|
-
"type-fest": "4.
|
|
9
|
+
"type-fest": "4.33.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@clipboard-health/testing-core": "0.11.
|
|
12
|
+
"@clipboard-health/testing-core": "0.11.7",
|
|
13
13
|
"zod": "3.24.1"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GreaterThan, type Subtract } from "type-fest";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { type JsonApiDocument, type Relationship } from "../types";
|
|
3
|
+
import { type JsonApiDocument, type Relationship, type Relationships } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Recursively traverse the JSON:API document to build a list of all possible relationship paths up
|
|
6
6
|
* to the specified depth, which prevents stack overflow for circular relationships. Use the result
|
|
@@ -13,12 +13,12 @@ import { type JsonApiDocument, type Relationship } from "../types";
|
|
|
13
13
|
*/
|
|
14
14
|
export type RelationshipPaths<MapT extends Record<string, z.ZodTypeAny>, DocumentT extends JsonApiDocument, Depth extends number = 5, Prefix extends string = ""> = GreaterThan<Depth, 0> extends true ? DocumentT["data"] extends Array<infer Data> | infer Data ? Data extends {
|
|
15
15
|
relationships?: infer Relation;
|
|
16
|
-
} ? Relation extends
|
|
17
|
-
[K in keyof Relation]: K extends string ? Relation[K]["data"] extends {
|
|
16
|
+
} ? Relation extends Relationships ? {
|
|
17
|
+
[K in keyof Relation]: K extends string ? NonNullable<Relation[K]> extends Relationship ? NonNullable<Relation[K]>["data"] extends {
|
|
18
18
|
type?: infer RelationT;
|
|
19
19
|
} | Array<{
|
|
20
20
|
type?: infer RelationT;
|
|
21
|
-
}> ? RelationT extends keyof MapT ? `${Prefix}${K}` | RelationshipPaths<MapT, z.infer<MapT[RelationT]>, Subtract<Depth, 1>, `${Prefix}${K}.`> : never : never : never;
|
|
21
|
+
}> ? RelationT extends keyof MapT ? `${Prefix}${K}` | RelationshipPaths<MapT, z.infer<MapT[RelationT]>, Subtract<Depth, 1>, `${Prefix}${K}.`> : never : never : never : never;
|
|
22
22
|
}[keyof Relation] : never : never : never : never;
|
|
23
23
|
/**
|
|
24
24
|
* Creates a Zod schema for JSON:API include parameters.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"includeQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/includeQuery.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"includeQuery.js","sourceRoot":"","sources":["../../../../../../packages/json-api-nestjs/src/lib/query/includeQuery.ts"],"names":[],"mappings":";;AAuHA,oCAuBC;AA7ID,6BAAwB;AAExB,yDAAsD;AAgDtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;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"}
|
package/src/lib/types.d.ts
CHANGED
|
@@ -11,12 +11,13 @@ export interface Relationship {
|
|
|
11
11
|
links?: ApiLinks;
|
|
12
12
|
meta?: Meta;
|
|
13
13
|
}
|
|
14
|
+
export type Relationships = Record<string, Relationship | undefined>;
|
|
14
15
|
export interface Data {
|
|
15
16
|
attributes?: Record<string, unknown>;
|
|
16
17
|
id?: string;
|
|
17
18
|
links?: ApiLinks;
|
|
18
19
|
meta?: Meta;
|
|
19
|
-
relationships?:
|
|
20
|
+
relationships?: Relationships;
|
|
20
21
|
type?: ApiType;
|
|
21
22
|
}
|
|
22
23
|
/**
|