@cedarjs/gqlorm 2.6.1-next.104

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/cjs/generator/graphqlGenerator.d.ts +24 -0
  4. package/dist/cjs/generator/graphqlGenerator.d.ts.map +1 -0
  5. package/dist/cjs/generator/graphqlGenerator.js +421 -0
  6. package/dist/cjs/live/types.d.ts +262 -0
  7. package/dist/cjs/live/types.d.ts.map +1 -0
  8. package/dist/cjs/live/types.js +16 -0
  9. package/dist/cjs/package.json +1 -0
  10. package/dist/cjs/parser/queryParser.d.ts +27 -0
  11. package/dist/cjs/parser/queryParser.d.ts.map +1 -0
  12. package/dist/cjs/parser/queryParser.js +338 -0
  13. package/dist/cjs/queryBuilder.d.ts +106 -0
  14. package/dist/cjs/queryBuilder.d.ts.map +1 -0
  15. package/dist/cjs/queryBuilder.js +225 -0
  16. package/dist/cjs/react/useLiveQuery.d.ts +12 -0
  17. package/dist/cjs/react/useLiveQuery.d.ts.map +1 -0
  18. package/dist/cjs/react/useLiveQuery.js +62 -0
  19. package/dist/cjs/types/ast.d.ts +80 -0
  20. package/dist/cjs/types/ast.d.ts.map +1 -0
  21. package/dist/cjs/types/ast.js +16 -0
  22. package/dist/cjs/types/orm.d.ts +157 -0
  23. package/dist/cjs/types/orm.d.ts.map +1 -0
  24. package/dist/cjs/types/orm.js +16 -0
  25. package/dist/cjs/types/orm_for_testing.d.ts +44 -0
  26. package/dist/cjs/types/orm_for_testing.d.ts.map +1 -0
  27. package/dist/cjs/types/orm_for_testing.js +16 -0
  28. package/dist/cjs/types/schema.d.ts +4 -0
  29. package/dist/cjs/types/schema.d.ts.map +1 -0
  30. package/dist/cjs/types/schema.js +16 -0
  31. package/dist/cjs/types/typeUtils.d.ts +10 -0
  32. package/dist/cjs/types/typeUtils.d.ts.map +1 -0
  33. package/dist/cjs/types/typeUtils.js +65 -0
  34. package/dist/generator/graphqlGenerator.d.ts +24 -0
  35. package/dist/generator/graphqlGenerator.d.ts.map +1 -0
  36. package/dist/generator/graphqlGenerator.js +399 -0
  37. package/dist/live/types.d.ts +262 -0
  38. package/dist/live/types.d.ts.map +1 -0
  39. package/dist/live/types.js +0 -0
  40. package/dist/parser/queryParser.d.ts +27 -0
  41. package/dist/parser/queryParser.d.ts.map +1 -0
  42. package/dist/parser/queryParser.js +312 -0
  43. package/dist/queryBuilder.d.ts +106 -0
  44. package/dist/queryBuilder.d.ts.map +1 -0
  45. package/dist/queryBuilder.js +196 -0
  46. package/dist/react/useLiveQuery.d.ts +12 -0
  47. package/dist/react/useLiveQuery.d.ts.map +1 -0
  48. package/dist/react/useLiveQuery.js +38 -0
  49. package/dist/types/ast.d.ts +80 -0
  50. package/dist/types/ast.d.ts.map +1 -0
  51. package/dist/types/ast.js +0 -0
  52. package/dist/types/orm.d.ts +157 -0
  53. package/dist/types/orm.d.ts.map +1 -0
  54. package/dist/types/orm.js +0 -0
  55. package/dist/types/orm_for_testing.d.ts +44 -0
  56. package/dist/types/orm_for_testing.d.ts.map +1 -0
  57. package/dist/types/orm_for_testing.js +0 -0
  58. package/dist/types/schema.d.ts +4 -0
  59. package/dist/types/schema.d.ts.map +1 -0
  60. package/dist/types/schema.js +0 -0
  61. package/dist/types/typeUtils.d.ts +10 -0
  62. package/dist/types/typeUtils.d.ts.map +1 -0
  63. package/dist/types/typeUtils.js +34 -0
  64. package/package.json +163 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orm.d.ts","sourceRoot":"","sources":["../../../src/types/orm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAA;AAG5D,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IAC3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Descriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var orm_exports = {};
16
+ module.exports = __toCommonJS(orm_exports);
@@ -0,0 +1,44 @@
1
+ import type { FindManyArgs, FindUniqueArgs, IncludeInput, OrderByInput, SelectInput, WhereInput } from './orm.js';
2
+ export interface User {
3
+ id: string;
4
+ email: string;
5
+ name: string | null;
6
+ isActive: boolean;
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ posts?: Post[];
10
+ profile?: Profile;
11
+ }
12
+ export interface Post {
13
+ id: number;
14
+ title: string;
15
+ content: string | null;
16
+ published: boolean;
17
+ authorId: number;
18
+ createdAt: Date;
19
+ updatedAt: Date;
20
+ author?: User;
21
+ comments?: Comment[];
22
+ }
23
+ export interface Comment {
24
+ id: number;
25
+ content: string;
26
+ postId: number;
27
+ authorId: number;
28
+ createdAt: Date;
29
+ post?: Post;
30
+ author?: User;
31
+ }
32
+ export interface Profile {
33
+ id: number;
34
+ bio: string | null;
35
+ userId: number;
36
+ user?: User;
37
+ }
38
+ export type UserWhereInput = WhereInput<User>;
39
+ export type UserSelectInput = SelectInput<User>;
40
+ export type UserIncludeInput = IncludeInput<User>;
41
+ export type UserOrderByInput = OrderByInput<User>;
42
+ export type UserFindManyArgs = FindManyArgs<User>;
43
+ export type UserFindUniqueArgs = FindUniqueArgs<User>;
44
+ //# sourceMappingURL=orm_for_testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orm_for_testing.d.ts","sourceRo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AAI,CAAC,CAAA;AAC7C,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;AAC/C,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;AACjD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;AACjD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;AACjD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var orm_for_testing_exports = {};
16
+ module.exports = __toCommonJS(orm_for_testing_exports);
@@ -0,0 +1,4 @@
1
+ export interface ModelSchema {
2
+ [modelName: string]: string[];
3
+ }
4
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/types/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC9B"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var schema_exports = {};
16
+ module.exports = __toCommonJS(schema_exports);
@@ -0,0 +1,10 @@
1
+ import type { ASTNode, FieldCondition, IncludeAST, LogicalCondition, LogicalOperator, QueryAST, RelationCondition, SelectAST, WhereAST, WhereCondition } from './ast.js';
2
+ export declare function isQueryAST(node: ASTNode): node is QueryAST;
3
+ export declare function isWhereAST(node: ASTNode): node is WhereAST;
4
+ export declare function isSelectAST(node: ASTNode): node is SelectAST;
5
+ export declare function isIncludeAST(node: ASTNode): node is IncludeAST;
6
+ export declare function isFieldCondition(condition: WhereCondition | undefined): condition is FieldCondition;
7
+ export declare function isLogicalCondition(condition: WhereCondition): condition is LogicalCondition;
8
+ export declare function isRelationCondition(condition: WhereCondition): condition is RelationCondition;
9
+ export declare function isLogicalOperator(value: any): value is LogicalOperator;
10
+ //# sourceMappingURL=typeUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../../src/types/typeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,QAAQ,CAE1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,QAAQ,CAE1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAE5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,cAAc,GAAG,SAAS,GACpC,SAAS,IAAI,cAAc,CAE7B;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,cAAc,GACxB,SAAS,IAAI,gBAAgB,CAE/B;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,GACxB,SAAS,IAAI,iBAAiB,CAEhC;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,eAAe,CAEtE"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var typeUtils_exports = {};
20
+ __export(typeUtils_exports, {
21
+ isFieldCondition: () => isFieldCondition,
22
+ isIncludeAST: () => isIncludeAST,
23
+ isLogicalCondition: () => isLogicalCondition,
24
+ isLogicalOperator: () => isLogicalOperator,
25
+ isQueryAST: () => isQueryAST,
26
+ isRelationCondition: () => isRelationCondition,
27
+ isSelectAST: () => isSelectAST,
28
+ isWhereAST: () => isWhereAST
29
+ });
30
+ module.exports = __toCommonJS(typeUtils_exports);
31
+ function isQueryAST(node) {
32
+ return node.type === "Query";
33
+ }
34
+ function isWhereAST(node) {
35
+ return node.type === "Where";
36
+ }
37
+ function isSelectAST(node) {
38
+ return node.type === "Select";
39
+ }
40
+ function isIncludeAST(node) {
41
+ return node.type === "Include";
42
+ }
43
+ function isFieldCondition(condition) {
44
+ return condition?.type === "FieldCondition";
45
+ }
46
+ function isLogicalCondition(condition) {
47
+ return condition.type === "LogicalCondition";
48
+ }
49
+ function isRelationCondition(condition) {
50
+ return condition.type === "RelationCondition";
51
+ }
52
+ function isLogicalOperator(value) {
53
+ return ["AND", "OR", "NOT"].includes(value);
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ isFieldCondition,
58
+ isIncludeAST,
59
+ isLogicalCondition,
60
+ isLogicalOperator,
61
+ isQueryAST,
62
+ isRelationCondition,
63
+ isSelectAST,
64
+ isWhereAST
65
+ });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * GraphQL query generator that converts AST to GraphQL query strings
3
+ * Transforms our internal AST representation into valid GraphQL queries
4
+ */
5
+ import type { QueryAST } from '../types/ast.js';
6
+ import { type ModelSchema } from '../types/schema.js';
7
+ export declare class GraphQLGenerateError extends Error {
8
+ context?: any | undefined;
9
+ constructor(message: string, context?: any | undefined);
10
+ }
11
+ export interface GraphQLQuery {
12
+ query: string;
13
+ variables?: Record<string, any>;
14
+ }
15
+ export declare class GraphQLGenerator {
16
+ #private;
17
+ constructor(schema?: ModelSchema);
18
+ /**
19
+ * Generate GraphQL query from AST
20
+ */
21
+ generate(ast: QueryAST): GraphQLQuery;
22
+ }
23
+ export declare const graphqlGenerator: GraphQLGenerator;
24
+ //# sourceMappingURL=graphqlGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphqlGenerator.d.ts","sourceRoot":"","sources":["../../src/generator/graphqlGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAOV,QAAQ,EAKT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAOrD,qBAAa,oBAAqB,SAAQ,KAAK;IAGpC,OAAO,CAAC,EAAE,GAAG;gBADpB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,GAAG,YAAA;CAKvB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC;AAED,qBAAa,gBAAgB;;gBASf,MAAM,CAAC,EAAE,WAAW;IAIhC;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,YAAY;CAodtC;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
@@ -0,0 +1,399 @@
1
+ import {
2
+ isFieldCondition,
3
+ isLogicalCondition,
4
+ isRelationCondition
5
+ } from "../types/typeUtils.js";
6
+ class GraphQLGenerateError extends Error {
7
+ constructor(message, context) {
8
+ super(message);
9
+ this.context = context;
10
+ this.name = "GraphQLGenerateError";
11
+ }
12
+ }
13
+ class GraphQLGenerator {
14
+ #variableCounter = 0;
15
+ #variables = {};
16
+ // Track field names for each variable
17
+ #variableFields = /* @__PURE__ */ new Map();
18
+ // Track current operation for context-aware type generation
19
+ #operation;
20
+ #schema;
21
+ constructor(schema) {
22
+ this.#schema = schema;
23
+ }
24
+ /**
25
+ * Generate GraphQL query from AST
26
+ */
27
+ generate(ast) {
28
+ this.#resetState();
29
+ this.#operation = ast.operation;
30
+ const operationName = this.#generateOperationName(ast);
31
+ const queryBody = this.#generateQueryBody(ast);
32
+ let query = `query ${operationName}`;
33
+ const hasVariables = Object.keys(this.#variables).length > 0;
34
+ if (hasVariables) {
35
+ const variableDefinitions = this.#generateVariableDefinitions();
36
+ query += `(${variableDefinitions})`;
37
+ }
38
+ query += ` {
39
+ ${queryBody}
40
+ }`;
41
+ const result = { query };
42
+ if (hasVariables) {
43
+ result.variables = structuredClone(this.#variables);
44
+ }
45
+ return result;
46
+ }
47
+ /**
48
+ * Reset internal state for new query generation
49
+ */
50
+ #resetState() {
51
+ this.#variableCounter = 0;
52
+ this.#variables = {};
53
+ this.#variableFields.clear();
54
+ this.#operation = void 0;
55
+ }
56
+ /**
57
+ * Generate operation name
58
+ */
59
+ #generateOperationName(ast) {
60
+ const { model, operation } = ast;
61
+ return `${operation}${this.#capitalize(model)}`;
62
+ }
63
+ /**
64
+ * Generate main query body
65
+ */
66
+ #generateQueryBody(ast) {
67
+ const { model, operation, args, isLive } = ast;
68
+ const fieldName = this.#getGraphQLFieldName(model, operation);
69
+ let query = ` ${fieldName}`;
70
+ if (args) {
71
+ const argsString = this.#generateArguments(args, operation);
72
+ if (argsString) {
73
+ query += `(${argsString})`;
74
+ }
75
+ }
76
+ if (isLive) {
77
+ query += " @live";
78
+ }
79
+ const fields = this.#generateFieldSelection(args, model);
80
+ query += ` {
81
+ ${fields}
82
+ }`;
83
+ return query;
84
+ }
85
+ /**
86
+ * Convert operation to GraphQL field name
87
+ */
88
+ #getGraphQLFieldName(model, operation) {
89
+ switch (operation) {
90
+ case "findMany":
91
+ return `${model}s`;
92
+ case "findUnique":
93
+ case "findUniqueOrThrow":
94
+ return model;
95
+ case "findFirst":
96
+ case "findFirstOrThrow":
97
+ return model;
98
+ default:
99
+ throw new GraphQLGenerateError(`Unsupported operation: ${operation}`);
100
+ }
101
+ }
102
+ /**
103
+ * Generate GraphQL arguments from query args
104
+ */
105
+ #generateArguments(args, operation) {
106
+ const argParts = [];
107
+ if (args?.where) {
108
+ const isFindUnique = operation === "findUnique" || operation === "findUniqueOrThrow";
109
+ const simpleUniqueArg = isFindUnique ? this.#extractSimpleUniqueArgument(args.where) : null;
110
+ if (simpleUniqueArg) {
111
+ argParts.push(simpleUniqueArg);
112
+ } else {
113
+ const whereArg = this.#generateWhereArgument(args.where);
114
+ if (whereArg && whereArg !== "{}") {
115
+ argParts.push(`where: ${whereArg}`);
116
+ }
117
+ }
118
+ }
119
+ if (args?.orderBy) {
120
+ const orderByArg = this.#generateOrderByArgument(args.orderBy);
121
+ argParts.push(`orderBy: ${orderByArg}`);
122
+ }
123
+ if (typeof args?.take === "number") {
124
+ argParts.push(`first: ${args.take}`);
125
+ }
126
+ if (typeof args?.skip === "number") {
127
+ argParts.push(`skip: ${args.skip}`);
128
+ }
129
+ return argParts.join(", ");
130
+ }
131
+ /**
132
+ * Extract simple unique argument for findUnique operations
133
+ * Returns direct argument format (e.g., "id: $var0") if the where clause
134
+ * contains a single simple field equality, otherwise returns null
135
+ */
136
+ #extractSimpleUniqueArgument(where) {
137
+ if (where.conditions.length !== 1) {
138
+ return null;
139
+ }
140
+ const condition = where.conditions[0];
141
+ if (!isFieldCondition(condition) || condition.operator !== "equals") {
142
+ return null;
143
+ }
144
+ const variableName = this.#addVariable(condition.value, condition.field);
145
+ return `${condition.field}: $${variableName}`;
146
+ }
147
+ /**
148
+ * Generate variable definitions for GraphQL query
149
+ */
150
+ #generateVariableDefinitions() {
151
+ return Object.entries(this.#variables).map(([name, value]) => {
152
+ const fieldName = this.#variableFields.get(name);
153
+ const baseType = this.#getGraphQLType(value, fieldName);
154
+ const isFindUnique = this.#operation === "findUnique" || this.#operation === "findUniqueOrThrow";
155
+ const isIdField = fieldName === "id" || fieldName?.endsWith("Id");
156
+ if (isFindUnique && isIdField && !baseType.includes("!")) {
157
+ return `$${name}: ${baseType}!`;
158
+ }
159
+ return `$${name}: ${baseType}`;
160
+ }).join(", ");
161
+ }
162
+ /**
163
+ * Generate WHERE argument
164
+ */
165
+ #generateWhereArgument(where) {
166
+ const conditions = where.conditions.map(
167
+ (condition) => this.#generateCondition(condition)
168
+ );
169
+ if (conditions.length === 0) {
170
+ return "{}";
171
+ }
172
+ if (conditions.length === 1) {
173
+ return conditions[0];
174
+ }
175
+ return `{ AND: [${conditions.join(", ")}] }`;
176
+ }
177
+ /**
178
+ * Generate individual where condition
179
+ */
180
+ #generateCondition(condition) {
181
+ if (isFieldCondition(condition)) {
182
+ return this.#generateFieldCondition(condition);
183
+ } else if (isLogicalCondition(condition)) {
184
+ return this.#generateLogicalCondition(condition);
185
+ } else if (isRelationCondition(condition)) {
186
+ return this.#generateRelationCondition(condition);
187
+ }
188
+ throw new GraphQLGenerateError("Unknown condition type", { condition });
189
+ }
190
+ /**
191
+ * Generate field condition
192
+ */
193
+ #generateFieldCondition(condition) {
194
+ const { field, operator, value } = condition;
195
+ if (operator === "equals") {
196
+ const variableName2 = this.#addVariable(value, field);
197
+ return `{ ${field}: $${variableName2} }`;
198
+ }
199
+ const operatorMap = {
200
+ equals: "equals",
201
+ not: "not",
202
+ in: "in",
203
+ notIn: "notIn",
204
+ lt: "lt",
205
+ lte: "lte",
206
+ gt: "gt",
207
+ gte: "gte",
208
+ contains: "contains",
209
+ startsWith: "startsWith",
210
+ endsWith: "endsWith",
211
+ isNull: "isNull",
212
+ isNotNull: "isNotNull"
213
+ };
214
+ const gqlOperator = operatorMap[operator];
215
+ if (!gqlOperator) {
216
+ throw new GraphQLGenerateError(`Unsupported operator: ${operator}`);
217
+ }
218
+ if (operator === "isNull" || operator === "isNotNull") {
219
+ return `{ ${field}: { ${gqlOperator}: ${operator === "isNull"} } }`;
220
+ }
221
+ const variableName = this.#addVariable(value, field);
222
+ return `{ ${field}: { ${gqlOperator}: $${variableName} } }`;
223
+ }
224
+ /**
225
+ * Generate logical condition
226
+ */
227
+ #generateLogicalCondition(condition) {
228
+ const { operator, conditions } = condition;
229
+ const conditionStrings = conditions.map(
230
+ (cond) => this.#generateCondition(cond)
231
+ );
232
+ if (operator === "NOT") {
233
+ if (conditionStrings.length !== 1) {
234
+ throw new GraphQLGenerateError(
235
+ "NOT operator must have exactly one condition"
236
+ );
237
+ }
238
+ return `{ NOT: ${conditionStrings[0]} }`;
239
+ }
240
+ return `{ ${operator}: [${conditionStrings.join(", ")}] }`;
241
+ }
242
+ /**
243
+ * Generate relation condition
244
+ */
245
+ #generateRelationCondition(condition) {
246
+ const { relation, condition: nestedCondition } = condition;
247
+ const whereArg = this.#generateWhereArgument(nestedCondition);
248
+ return `{ ${relation}: ${whereArg} }`;
249
+ }
250
+ /**
251
+ * Generate ORDER BY argument
252
+ */
253
+ #generateOrderByArgument(orderBy) {
254
+ const fields = orderBy.fields.map((field) => {
255
+ const direction = field.direction.toUpperCase();
256
+ return `{ ${field.field}: ${direction} }`;
257
+ });
258
+ if (fields.length === 1) {
259
+ return fields[0];
260
+ }
261
+ return `[${fields.join(", ")}]`;
262
+ }
263
+ /**
264
+ * Generate field selection
265
+ */
266
+ #generateFieldSelection(args, model) {
267
+ if (args?.select) {
268
+ return this.#generateSelectFields(args.select);
269
+ }
270
+ if (args?.include) {
271
+ return this.#generateIncludeFields(args.include);
272
+ }
273
+ if (model && this.#schema && this.#schema[model]) {
274
+ const fields = this.#schema[model];
275
+ return fields.map((field) => ` ${field}`).join("\n");
276
+ }
277
+ return " id\n createdAt\n updatedAt";
278
+ }
279
+ /**
280
+ * Generate fields from SELECT clause
281
+ */
282
+ #generateSelectFields(select) {
283
+ const fieldStrings = [];
284
+ for (const fieldSelection of select.fields) {
285
+ if (!fieldSelection.selected) {
286
+ continue;
287
+ }
288
+ if (fieldSelection.nested) {
289
+ const nestedFields = fieldSelection.nested.type === "Select" ? this.#generateSelectFields(fieldSelection.nested) : this.#generateIncludeFields(fieldSelection.nested);
290
+ const indentedFields = this.#indent(nestedFields, 2);
291
+ fieldStrings.push(
292
+ ` ${fieldSelection.field} {
293
+ ${indentedFields}
294
+ }`
295
+ );
296
+ } else {
297
+ fieldStrings.push(` ${fieldSelection.field}`);
298
+ }
299
+ }
300
+ return fieldStrings.join("\n");
301
+ }
302
+ /**
303
+ * Generate fields from INCLUDE clause
304
+ */
305
+ #generateIncludeFields(include) {
306
+ const fieldStrings = [];
307
+ fieldStrings.push(" id");
308
+ for (const relationInclusion of include.relations) {
309
+ if (!relationInclusion.included) {
310
+ continue;
311
+ }
312
+ let relationQuery = ` ${relationInclusion.relation}`;
313
+ if (relationInclusion.args) {
314
+ const argsString = this.#generateArguments(relationInclusion.args);
315
+ if (argsString) {
316
+ relationQuery += `(${argsString})`;
317
+ }
318
+ }
319
+ let nestedFields;
320
+ if (relationInclusion.nested) {
321
+ nestedFields = this.#generateIncludeFields(relationInclusion.nested);
322
+ } else if (relationInclusion.args?.select) {
323
+ nestedFields = this.#generateSelectFields(relationInclusion.args.select);
324
+ } else {
325
+ nestedFields = " id";
326
+ }
327
+ relationQuery += ` {
328
+ ${this.#indent(nestedFields, 2)}
329
+ }`;
330
+ fieldStrings.push(relationQuery);
331
+ }
332
+ return fieldStrings.join("\n");
333
+ }
334
+ /**
335
+ * Add variable and return variable name
336
+ */
337
+ #addVariable(value, fieldName) {
338
+ const variableName = `var${this.#variableCounter++}`;
339
+ this.#variables[variableName] = value;
340
+ if (fieldName) {
341
+ this.#variableFields.set(variableName, fieldName);
342
+ }
343
+ return variableName;
344
+ }
345
+ /**
346
+ * Get GraphQL type for a value
347
+ */
348
+ #getGraphQLType(value, fieldName) {
349
+ const isIdField = fieldName && /^(id|.*Id|.*ID)$/.test(fieldName);
350
+ if (value === void 0 || value === null) {
351
+ return isIdField ? "ID" : "String";
352
+ }
353
+ if (typeof value === "string") {
354
+ return isIdField ? "ID" : "String";
355
+ }
356
+ if (typeof value === "number") {
357
+ if (isIdField) {
358
+ return "ID";
359
+ }
360
+ return Number.isInteger(value) ? "Int" : "Float";
361
+ }
362
+ if (typeof value === "boolean") {
363
+ return "Boolean";
364
+ }
365
+ if (value instanceof Date) {
366
+ return "DateTime";
367
+ }
368
+ if (Array.isArray(value)) {
369
+ if (value.length === 0) {
370
+ return "[String]";
371
+ }
372
+ const itemType = this.#getGraphQLType(value[0], fieldName);
373
+ if (isIdField && (itemType === "ID" || itemType === "String")) {
374
+ return `[ID!]`;
375
+ }
376
+ return `[${itemType}]`;
377
+ }
378
+ return "String";
379
+ }
380
+ /**
381
+ * Capitalize first letter of string
382
+ */
383
+ #capitalize(str) {
384
+ return str.charAt(0).toUpperCase() + str.slice(1);
385
+ }
386
+ /**
387
+ * Indent text by specified number of levels
388
+ */
389
+ #indent(text, levels) {
390
+ const indentation = " ".repeat(levels);
391
+ return text.split("\n").map((line) => line.trim() ? `${indentation}${line}` : line).join("\n");
392
+ }
393
+ }
394
+ const graphqlGenerator = new GraphQLGenerator();
395
+ export {
396
+ GraphQLGenerateError,
397
+ GraphQLGenerator,
398
+ graphqlGenerator
399
+ };