postgresdk 0.18.0 → 0.18.2

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 (86) hide show
  1. package/dist/cli.js +15 -1
  2. package/dist/index.js +15 -1
  3. package/package.json +1 -1
  4. package/dist/cli.d.ts.map +0 -1
  5. package/dist/cli.js.map +0 -1
  6. package/dist/core/operations.d.ts +0 -68
  7. package/dist/emit-api-contract.d.ts +0 -60
  8. package/dist/emit-client.d.ts.map +0 -1
  9. package/dist/emit-client.js +0 -114
  10. package/dist/emit-client.js.map +0 -1
  11. package/dist/emit-include-builder.d.ts.map +0 -1
  12. package/dist/emit-include-builder.js +0 -30
  13. package/dist/emit-include-builder.js.map +0 -1
  14. package/dist/emit-include-loader.d.ts.map +0 -1
  15. package/dist/emit-include-loader.js +0 -299
  16. package/dist/emit-include-loader.js.map +0 -1
  17. package/dist/emit-include-spec.d.ts.map +0 -1
  18. package/dist/emit-include-spec.js +0 -26
  19. package/dist/emit-include-spec.js.map +0 -1
  20. package/dist/emit-logger.d.ts.map +0 -1
  21. package/dist/emit-logger.js +0 -35
  22. package/dist/emit-logger.js.map +0 -1
  23. package/dist/emit-router.d.ts +0 -5
  24. package/dist/emit-routes.d.ts.map +0 -1
  25. package/dist/emit-routes.js +0 -208
  26. package/dist/emit-routes.js.map +0 -1
  27. package/dist/emit-server-index.d.ts +0 -5
  28. package/dist/emit-types.d.ts.map +0 -1
  29. package/dist/emit-types.js +0 -51
  30. package/dist/emit-types.js.map +0 -1
  31. package/dist/emit-zod.d.ts.map +0 -1
  32. package/dist/emit-zod.js +0 -43
  33. package/dist/emit-zod.js.map +0 -1
  34. package/dist/gen.config.d.ts +0 -10
  35. package/dist/gen.config.js +0 -10
  36. package/dist/gen.config.js.map +0 -1
  37. package/dist/index.d.ts.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/introspect.d.ts.map +0 -1
  40. package/dist/introspect.js +0 -132
  41. package/dist/introspect.js.map +0 -1
  42. package/dist/rel-classify.d.ts.map +0 -1
  43. package/dist/rel-classify.js +0 -52
  44. package/dist/rel-classify.js.map +0 -1
  45. package/dist/src/cli.d.ts +0 -2
  46. package/dist/src/cli.js +0 -39
  47. package/dist/src/cli.js.map +0 -1
  48. package/dist/src/emit-client.d.ts +0 -3
  49. package/dist/src/emit-client.js +0 -114
  50. package/dist/src/emit-client.js.map +0 -1
  51. package/dist/src/emit-include-builder.d.ts +0 -2
  52. package/dist/src/emit-include-builder.js +0 -30
  53. package/dist/src/emit-include-builder.js.map +0 -1
  54. package/dist/src/emit-include-loader.d.ts +0 -9
  55. package/dist/src/emit-include-loader.js +0 -299
  56. package/dist/src/emit-include-loader.js.map +0 -1
  57. package/dist/src/emit-include-spec.d.ts +0 -2
  58. package/dist/src/emit-include-spec.js +0 -26
  59. package/dist/src/emit-include-spec.js.map +0 -1
  60. package/dist/src/emit-logger.d.ts +0 -1
  61. package/dist/src/emit-logger.js +0 -35
  62. package/dist/src/emit-logger.js.map +0 -1
  63. package/dist/src/emit-routes.d.ts +0 -20
  64. package/dist/src/emit-routes.js +0 -208
  65. package/dist/src/emit-routes.js.map +0 -1
  66. package/dist/src/emit-types.d.ts +0 -5
  67. package/dist/src/emit-types.js +0 -51
  68. package/dist/src/emit-types.js.map +0 -1
  69. package/dist/src/emit-zod.d.ts +0 -5
  70. package/dist/src/emit-zod.js +0 -43
  71. package/dist/src/emit-zod.js.map +0 -1
  72. package/dist/src/index.d.ts +0 -1
  73. package/dist/src/index.js +0 -83
  74. package/dist/src/index.js.map +0 -1
  75. package/dist/src/introspect.d.ts +0 -26
  76. package/dist/src/introspect.js +0 -132
  77. package/dist/src/introspect.js.map +0 -1
  78. package/dist/src/rel-classify.d.ts +0 -10
  79. package/dist/src/rel-classify.js +0 -52
  80. package/dist/src/rel-classify.js.map +0 -1
  81. package/dist/src/utils.d.ts +0 -6
  82. package/dist/src/utils.js +0 -17
  83. package/dist/src/utils.js.map +0 -1
  84. package/dist/utils.d.ts.map +0 -1
  85. package/dist/utils.js +0 -17
  86. package/dist/utils.js.map +0 -1
package/dist/cli.js CHANGED
@@ -3583,12 +3583,16 @@ function emitClient(table, graph, opts, model) {
3583
3583
  const paramName = toIncludeParamName(key);
3584
3584
  includeParamNames.push(paramName);
3585
3585
  paramsType = `{
3586
+ select?: string[];
3587
+ exclude?: string[];
3586
3588
  limit?: number;
3587
3589
  offset?: number;
3588
3590
  where?: Where<Select${Type}>;
3589
3591
  orderBy?: string | string[];
3590
3592
  order?: "asc" | "desc" | ("asc" | "desc")[];
3591
3593
  ${paramName}?: {
3594
+ select?: string[];
3595
+ exclude?: string[];
3592
3596
  orderBy?: string | string[];
3593
3597
  order?: "asc" | "desc";
3594
3598
  limit?: number;
@@ -3601,6 +3605,8 @@ function emitClient(table, graph, opts, model) {
3601
3605
  const paramName = toIncludeParamName(key);
3602
3606
  includeParamNames.push(paramName);
3603
3607
  return `${paramName}?: {
3608
+ select?: string[];
3609
+ exclude?: string[];
3604
3610
  orderBy?: string | string[];
3605
3611
  order?: "asc" | "desc";
3606
3612
  limit?: number;
@@ -3609,6 +3615,8 @@ function emitClient(table, graph, opts, model) {
3609
3615
  }).join(`;
3610
3616
  `);
3611
3617
  paramsType = `{
3618
+ select?: string[];
3619
+ exclude?: string[];
3612
3620
  limit?: number;
3613
3621
  offset?: number;
3614
3622
  where?: Where<Select${Type}>;
@@ -3620,12 +3628,16 @@ function emitClient(table, graph, opts, model) {
3620
3628
  const paramName = toIncludeParamName(pattern.nestedKey);
3621
3629
  includeParamNames.push(paramName);
3622
3630
  paramsType = `{
3631
+ select?: string[];
3632
+ exclude?: string[];
3623
3633
  limit?: number;
3624
3634
  offset?: number;
3625
3635
  where?: Where<Select${Type}>;
3626
3636
  orderBy?: string | string[];
3627
3637
  order?: "asc" | "desc" | ("asc" | "desc")[];
3628
3638
  ${paramName}?: {
3639
+ select?: string[];
3640
+ exclude?: string[];
3629
3641
  orderBy?: string | string[];
3630
3642
  order?: "asc" | "desc";
3631
3643
  limit?: number;
@@ -3669,12 +3681,14 @@ function emitClient(table, graph, opts, model) {
3669
3681
  /**
3670
3682
  * Get a ${table.name} record by primary key with included related ${relationshipDesc}
3671
3683
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
3672
- * @param params - Optional include options
3684
+ * @param params - Optional include options (including select/exclude for base and nested tables)
3673
3685
  * @returns The record with nested ${method.path.join(" and ")} if found, null otherwise
3674
3686
  */
3675
3687
  async ${method.name}(pk: ${pkType}, params?: ${paramsType}): Promise<${method.returnType}> {${transformCode}
3676
3688
  const results = await this.post<PaginatedResponse<${baseReturnType}>>(\`\${this.resource}/list\`, {
3677
3689
  where: ${pkWhere},
3690
+ select: params?.select,
3691
+ exclude: params?.exclude,
3678
3692
  include: includeSpec,
3679
3693
  limit: 1
3680
3694
  });
package/dist/index.js CHANGED
@@ -2604,12 +2604,16 @@ function emitClient(table, graph, opts, model) {
2604
2604
  const paramName = toIncludeParamName(key);
2605
2605
  includeParamNames.push(paramName);
2606
2606
  paramsType = `{
2607
+ select?: string[];
2608
+ exclude?: string[];
2607
2609
  limit?: number;
2608
2610
  offset?: number;
2609
2611
  where?: Where<Select${Type}>;
2610
2612
  orderBy?: string | string[];
2611
2613
  order?: "asc" | "desc" | ("asc" | "desc")[];
2612
2614
  ${paramName}?: {
2615
+ select?: string[];
2616
+ exclude?: string[];
2613
2617
  orderBy?: string | string[];
2614
2618
  order?: "asc" | "desc";
2615
2619
  limit?: number;
@@ -2622,6 +2626,8 @@ function emitClient(table, graph, opts, model) {
2622
2626
  const paramName = toIncludeParamName(key);
2623
2627
  includeParamNames.push(paramName);
2624
2628
  return `${paramName}?: {
2629
+ select?: string[];
2630
+ exclude?: string[];
2625
2631
  orderBy?: string | string[];
2626
2632
  order?: "asc" | "desc";
2627
2633
  limit?: number;
@@ -2630,6 +2636,8 @@ function emitClient(table, graph, opts, model) {
2630
2636
  }).join(`;
2631
2637
  `);
2632
2638
  paramsType = `{
2639
+ select?: string[];
2640
+ exclude?: string[];
2633
2641
  limit?: number;
2634
2642
  offset?: number;
2635
2643
  where?: Where<Select${Type}>;
@@ -2641,12 +2649,16 @@ function emitClient(table, graph, opts, model) {
2641
2649
  const paramName = toIncludeParamName(pattern.nestedKey);
2642
2650
  includeParamNames.push(paramName);
2643
2651
  paramsType = `{
2652
+ select?: string[];
2653
+ exclude?: string[];
2644
2654
  limit?: number;
2645
2655
  offset?: number;
2646
2656
  where?: Where<Select${Type}>;
2647
2657
  orderBy?: string | string[];
2648
2658
  order?: "asc" | "desc" | ("asc" | "desc")[];
2649
2659
  ${paramName}?: {
2660
+ select?: string[];
2661
+ exclude?: string[];
2650
2662
  orderBy?: string | string[];
2651
2663
  order?: "asc" | "desc";
2652
2664
  limit?: number;
@@ -2690,12 +2702,14 @@ function emitClient(table, graph, opts, model) {
2690
2702
  /**
2691
2703
  * Get a ${table.name} record by primary key with included related ${relationshipDesc}
2692
2704
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
2693
- * @param params - Optional include options
2705
+ * @param params - Optional include options (including select/exclude for base and nested tables)
2694
2706
  * @returns The record with nested ${method.path.join(" and ")} if found, null otherwise
2695
2707
  */
2696
2708
  async ${method.name}(pk: ${pkType}, params?: ${paramsType}): Promise<${method.returnType}> {${transformCode}
2697
2709
  const results = await this.post<PaginatedResponse<${baseReturnType}>>(\`\${this.resource}/list\`, {
2698
2710
  where: ${pkWhere},
2711
+ select: params?.select,
2712
+ exclude: params?.exclude,
2699
2713
  include: includeSpec,
2700
2714
  limit: 1
2701
2715
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"m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AAClB,CAAC;AAED,kBAAkB;AAClB,IAAI,UAAU,GAAG,sBAAsB,CAAC;AACxC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC,CAAC;AACxE,IAAI,WAAW,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC;IAChD,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,CAAC,CAAE,CAAC;AACtC,CAAC;AAED,gBAAgB;AAChB,IAAI,CAAC;IACH,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;AACrD,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -1,68 +0,0 @@
1
- /**
2
- * Core database operations that are framework-agnostic.
3
- * These functions handle the actual database logic and can be used by any framework adapter.
4
- */
5
- export interface DatabaseClient {
6
- query: (text: string, params?: any[]) => Promise<{
7
- rows: any[];
8
- }>;
9
- }
10
- export interface OperationContext {
11
- pg: DatabaseClient;
12
- table: string;
13
- pkColumns: string[];
14
- softDeleteColumn?: string | null;
15
- includeMethodsDepth: number;
16
- }
17
- /**
18
- * CREATE operation - Insert a new record
19
- */
20
- export declare function createRecord(ctx: OperationContext, data: Record<string, any>): Promise<{
21
- data?: any;
22
- error?: string;
23
- issues?: any;
24
- status: number;
25
- }>;
26
- /**
27
- * READ operation - Get a record by primary key
28
- */
29
- export declare function getByPk(ctx: OperationContext, pkValues: any[]): Promise<{
30
- data?: any;
31
- error?: string;
32
- status: number;
33
- }>;
34
- /**
35
- * LIST operation - Get multiple records with optional filters
36
- */
37
- export declare function listRecords(ctx: OperationContext, params: {
38
- where?: any;
39
- limit?: number;
40
- offset?: number;
41
- include?: any;
42
- orderBy?: string | string[];
43
- order?: "asc" | "desc" | ("asc" | "desc")[];
44
- }): Promise<{
45
- data?: any;
46
- error?: string;
47
- issues?: any;
48
- needsIncludes?: boolean;
49
- includeSpec?: any;
50
- status: number;
51
- }>;
52
- /**
53
- * UPDATE operation - Update a record by primary key
54
- */
55
- export declare function updateRecord(ctx: OperationContext, pkValues: any[], updateData: Record<string, any>): Promise<{
56
- data?: any;
57
- error?: string;
58
- issues?: any;
59
- status: number;
60
- }>;
61
- /**
62
- * DELETE operation - Delete or soft-delete a record by primary key
63
- */
64
- export declare function deleteRecord(ctx: OperationContext, pkValues: any[]): Promise<{
65
- data?: any;
66
- error?: string;
67
- status: number;
68
- }>;
@@ -1,60 +0,0 @@
1
- import type { Model } from "./introspect";
2
- import type { Config, AuthConfig } from "./types";
3
- export interface ApiContract {
4
- version: string;
5
- generatedAt: string;
6
- description: string;
7
- authentication?: {
8
- type: string;
9
- description: string;
10
- };
11
- resources: ResourceContract[];
12
- relationships: RelationshipContract[];
13
- }
14
- export interface ResourceContract {
15
- name: string;
16
- tableName: string;
17
- description: string;
18
- endpoints: EndpointContract[];
19
- fields: FieldContract[];
20
- }
21
- export interface EndpointContract {
22
- method: string;
23
- path: string;
24
- description: string;
25
- requestBody?: any;
26
- responseBody?: any;
27
- queryParameters?: any;
28
- }
29
- export interface FieldContract {
30
- name: string;
31
- type: string;
32
- required: boolean;
33
- description: string;
34
- foreignKey?: {
35
- table: string;
36
- field: string;
37
- };
38
- }
39
- export interface RelationshipContract {
40
- from: string;
41
- to: string;
42
- type: "one-to-many" | "many-to-one" | "many-to-many";
43
- description: string;
44
- }
45
- /**
46
- * Generate a comprehensive API contract in JSON format
47
- */
48
- export declare function generateApiContract(model: Model, config: Config & {
49
- auth?: AuthConfig;
50
- }): ApiContract;
51
- /**
52
- * Generate a human-readable markdown version of the contract
53
- */
54
- export declare function generateApiContractMarkdown(contract: ApiContract): string;
55
- /**
56
- * Emit the API contract as TypeScript code that can be served as an endpoint
57
- */
58
- export declare function emitApiContract(model: Model, config: Config & {
59
- auth?: AuthConfig;
60
- }): string;
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-client.d.ts","sourceRoot":"","sources":["../src/emit-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,UA8FtC;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,UAmB9C"}
@@ -1,114 +0,0 @@
1
- import { pascal } from "./utils";
2
- export function emitClient(table) {
3
- const Type = pascal(table.name);
4
- // Normalize PKs
5
- const pkCols = Array.isArray(table.pk)
6
- ? table.pk
7
- : table.pk
8
- ? [table.pk]
9
- : [];
10
- const safePk = pkCols.length ? pkCols : ["id"];
11
- const hasCompositePk = safePk.length > 1;
12
- const pkType = hasCompositePk ? `{ ${safePk.map((c) => `${c}: string`).join("; ")} }` : `string`;
13
- const pkPathExpr = hasCompositePk ? safePk.map((c) => `pk.${c}`).join(` + "/" + `) : `pk`;
14
- return `/* Generated. Do not edit. */
15
- import type { ${Type}IncludeSpec } from "./include-spec";
16
- import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}";
17
-
18
- export class ${Type}Client {
19
- constructor(
20
- private baseUrl: string,
21
- private fetchFn: typeof fetch = fetch,
22
- private auth?: () => Promise<Record<string,string>>
23
- ) {}
24
-
25
- private async headers(json = false) {
26
- const extra = (await this.auth?.()) ?? {};
27
- return json ? { "Content-Type": "application/json", ...extra } : extra;
28
- }
29
-
30
- private async okOrThrow(res: Response, action: string) {
31
- if (!res.ok) {
32
- let detail = "";
33
- try { detail = await res.text(); } catch {}
34
- throw new Error(\`\${action} ${table.name} failed: \${res.status} \${detail}\`);
35
- }
36
- }
37
-
38
- async create(data: Insert${Type}): Promise<Select${Type}> {
39
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}\`, {
40
- method: "POST",
41
- headers: await this.headers(true),
42
- body: JSON.stringify(data),
43
- });
44
- await this.okOrThrow(res, "create");
45
- return (await res.json()) as Select${Type};
46
- }
47
-
48
- async getByPk(pk: ${pkType}): Promise<Select${Type} | null> {
49
- const path = ${pkPathExpr};
50
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
51
- headers: await this.headers(),
52
- });
53
- if (res.status === 404) return null;
54
- await this.okOrThrow(res, "get");
55
- return (await res.json()) as Select${Type};
56
- }
57
-
58
- async list(params?: { include?: ${Type}IncludeSpec; limit?: number; offset?: number }): Promise<Select${Type}[]> {
59
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/list\`, {
60
- method: "POST",
61
- headers: await this.headers(true),
62
- body: JSON.stringify(params ?? {}),
63
- });
64
- await this.okOrThrow(res, "list");
65
- return (await res.json()) as Select${Type}[];
66
- }
67
-
68
- async update(pk: ${pkType}, patch: Update${Type}): Promise<Select${Type} | null> {
69
- const path = ${pkPathExpr};
70
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
71
- method: "PATCH",
72
- headers: await this.headers(true),
73
- body: JSON.stringify(patch),
74
- });
75
- if (res.status === 404) return null;
76
- await this.okOrThrow(res, "update");
77
- return (await res.json()) as Select${Type};
78
- }
79
-
80
- async delete(pk: ${pkType}): Promise<Select${Type} | null> {
81
- const path = ${pkPathExpr};
82
- const res = await this.fetchFn(\`\${this.baseUrl}/v1/${table.name}/\${path}\`, {
83
- method: "DELETE",
84
- headers: await this.headers(),
85
- });
86
- if (res.status === 404) return null;
87
- await this.okOrThrow(res, "delete");
88
- return (await res.json()) as Select${Type};
89
- }
90
- }
91
- `;
92
- }
93
- export function emitClientIndex(tables) {
94
- let out = `/* Generated. Do not edit. */\n`;
95
- for (const t of tables) {
96
- out += `import { ${pascal(t.name)}Client } from "./${t.name}";\n`;
97
- }
98
- out += `\nexport class SDK {\n`;
99
- for (const t of tables) {
100
- out += ` public ${t.name}: ${pascal(t.name)}Client;\n`;
101
- }
102
- out += `\n constructor(cfg: { baseUrl: string; fetch?: typeof fetch; auth?: () => Promise<Record<string,string>> }) {\n`;
103
- out += ` const f = cfg.fetch ?? fetch;\n`;
104
- for (const t of tables) {
105
- out += ` this.${t.name} = new ${pascal(t.name)}Client(cfg.baseUrl, f, cfg.auth);\n`;
106
- }
107
- out += ` }\n`;
108
- out += `}\n`;
109
- for (const t of tables)
110
- out += `export { ${pascal(t.name)}Client } from "./${t.name}";\n`;
111
- out += `export * from "./include-spec";\n`;
112
- return out;
113
- }
114
- //# sourceMappingURL=emit-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-client.js","sourceRoot":"","sources":["../src/emit-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhC,gBAAgB;IAChB,MAAM,MAAM,GAAa,KAAK,CAAC,OAAO,CAAE,KAAa,CAAC,EAAE,CAAC;QACvD,CAAC,CAAE,KAAa,CAAC,EAAE;QACnB,CAAC,CAAE,KAAa,CAAC,EAAE;YACnB,CAAC,CAAC,CAAE,KAAa,CAAC,EAAE,CAAC;YACrB,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC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W,CAAC;IAC1D,CAAC;IACD,GAAG,IAAI,kHAAkH,CAAC;IAC1H,GAAG,IAAI,qCAAqC,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,GAAG,IAAI,YAAY,CAAC,CAAC,IAAI,UAAU,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,qCAAqC,CAAC;IACzF,CAAC;IACD,GAAG,IAAI,OAAO,CAAC;IACf,GAAG,IAAI,KAAK,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,GAAG,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,MAAM,CAAC;IAC1F,GAAG,IAAI,mCAAmC,CAAC;IAC3C,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-include-builder.d.ts","sourceRoot":"","sources":["../src/emit-include-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UA4BhE"}
@@ -1,30 +0,0 @@
1
- export function emitIncludeBuilder(graph, maxDepth) {
2
- return `// Generated. Do not edit.
3
- export const RELATION_GRAPH = ${JSON.stringify(graph, null, 2)} as const;
4
- type TableName = keyof typeof RELATION_GRAPH;
5
-
6
- export function buildWith(root: TableName, spec: any, maxDepth = ${maxDepth}) {
7
- return walk(root as string, spec, 0);
8
- function walk(table: string, s: any, depth: number): any {
9
- if (!s || depth >= maxDepth) return undefined;
10
- const rels: any = (RELATION_GRAPH as any)[table] || {};
11
- const out: any = {};
12
- for (const key of Object.keys(s)) {
13
- const rel = rels[key];
14
- if (!rel) throw new Error(\`Unknown include key '\${key}' on table '\${table}'\`);
15
- const v = s[key];
16
- if (v === true) out[key] = true;
17
- else if (v && typeof v === "object") {
18
- const child = "include" in v ? walk(rel.target, v.include, depth + 1) : undefined;
19
- out[key] = child ? { with: child } : true;
20
- }
21
- }
22
- return Object.keys(out).length ? out : undefined;
23
- }
24
- }
25
-
26
- export const buildWithFor = (t: TableName) =>
27
- (spec?: any, depth = ${maxDepth}) => (spec ? buildWith(t, spec, depth) : undefined);
28
- `;
29
- }
30
- //# sourceMappingURL=emit-include-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-include-builder.js","sourceRoot":"","sources":["../src/emit-include-builder.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,QAAgB;IAC/D,OAAO;gCACuB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;;mEAGK,QAAQ;;;;;;;;;;;;;;;;;;;;;yBAqBlD,QAAQ;CAChC,CAAC;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-include-loader.d.ts","sourceRoot":"","sources":["../src/emit-include-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAgT7E"}