@nicia-ai/typegraph 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/ast-BVyihVbP.d.cts +564 -0
  4. package/dist/ast-BVyihVbP.d.ts +564 -0
  5. package/dist/backend/drizzle/index.cjs +41 -0
  6. package/dist/backend/drizzle/index.cjs.map +1 -0
  7. package/dist/backend/drizzle/index.d.cts +12 -0
  8. package/dist/backend/drizzle/index.d.ts +12 -0
  9. package/dist/backend/drizzle/index.js +12 -0
  10. package/dist/backend/drizzle/index.js.map +1 -0
  11. package/dist/backend/drizzle/postgres.cjs +27 -0
  12. package/dist/backend/drizzle/postgres.cjs.map +1 -0
  13. package/dist/backend/drizzle/postgres.d.cts +37 -0
  14. package/dist/backend/drizzle/postgres.d.ts +37 -0
  15. package/dist/backend/drizzle/postgres.js +10 -0
  16. package/dist/backend/drizzle/postgres.js.map +1 -0
  17. package/dist/backend/drizzle/schema/postgres.cjs +40 -0
  18. package/dist/backend/drizzle/schema/postgres.cjs.map +1 -0
  19. package/dist/backend/drizzle/schema/postgres.d.cts +2419 -0
  20. package/dist/backend/drizzle/schema/postgres.d.ts +2419 -0
  21. package/dist/backend/drizzle/schema/postgres.js +7 -0
  22. package/dist/backend/drizzle/schema/postgres.js.map +1 -0
  23. package/dist/backend/drizzle/schema/sqlite.cjs +40 -0
  24. package/dist/backend/drizzle/schema/sqlite.cjs.map +1 -0
  25. package/dist/backend/drizzle/schema/sqlite.d.cts +2647 -0
  26. package/dist/backend/drizzle/schema/sqlite.d.ts +2647 -0
  27. package/dist/backend/drizzle/schema/sqlite.js +7 -0
  28. package/dist/backend/drizzle/schema/sqlite.js.map +1 -0
  29. package/dist/backend/drizzle/sqlite.cjs +27 -0
  30. package/dist/backend/drizzle/sqlite.cjs.map +1 -0
  31. package/dist/backend/drizzle/sqlite.d.cts +36 -0
  32. package/dist/backend/drizzle/sqlite.d.ts +36 -0
  33. package/dist/backend/drizzle/sqlite.js +10 -0
  34. package/dist/backend/drizzle/sqlite.js.map +1 -0
  35. package/dist/backend/postgres/index.cjs +53 -0
  36. package/dist/backend/postgres/index.cjs.map +1 -0
  37. package/dist/backend/postgres/index.d.cts +12 -0
  38. package/dist/backend/postgres/index.d.ts +12 -0
  39. package/dist/backend/postgres/index.js +12 -0
  40. package/dist/backend/postgres/index.js.map +1 -0
  41. package/dist/backend/sqlite/index.cjs +117 -0
  42. package/dist/backend/sqlite/index.cjs.map +1 -0
  43. package/dist/backend/sqlite/index.d.cts +71 -0
  44. package/dist/backend/sqlite/index.d.ts +71 -0
  45. package/dist/backend/sqlite/index.js +78 -0
  46. package/dist/backend/sqlite/index.js.map +1 -0
  47. package/dist/chunk-2QHQ2C4P.js +146 -0
  48. package/dist/chunk-2QHQ2C4P.js.map +1 -0
  49. package/dist/chunk-3A5TKOEJ.js +306 -0
  50. package/dist/chunk-3A5TKOEJ.js.map +1 -0
  51. package/dist/chunk-4PIEL2VO.js +162 -0
  52. package/dist/chunk-4PIEL2VO.js.map +1 -0
  53. package/dist/chunk-536PH5FT.js +342 -0
  54. package/dist/chunk-536PH5FT.js.map +1 -0
  55. package/dist/chunk-DBFCKELK.cjs +156 -0
  56. package/dist/chunk-DBFCKELK.cjs.map +1 -0
  57. package/dist/chunk-DDM2FZRJ.cjs +1143 -0
  58. package/dist/chunk-DDM2FZRJ.cjs.map +1 -0
  59. package/dist/chunk-DGUM43GV.js +10 -0
  60. package/dist/chunk-DGUM43GV.js.map +1 -0
  61. package/dist/chunk-F32HCHYA.cjs +680 -0
  62. package/dist/chunk-F32HCHYA.cjs.map +1 -0
  63. package/dist/chunk-IIAT36MI.js +353 -0
  64. package/dist/chunk-IIAT36MI.js.map +1 -0
  65. package/dist/chunk-JDAET5LO.js +236 -0
  66. package/dist/chunk-JDAET5LO.js.map +1 -0
  67. package/dist/chunk-JEQ2X3Z6.cjs +12 -0
  68. package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
  69. package/dist/chunk-JKTO7TW3.js +299 -0
  70. package/dist/chunk-JKTO7TW3.js.map +1 -0
  71. package/dist/chunk-K7SQ3SWP.js +497 -0
  72. package/dist/chunk-K7SQ3SWP.js.map +1 -0
  73. package/dist/chunk-L642L24T.js +142 -0
  74. package/dist/chunk-L642L24T.js.map +1 -0
  75. package/dist/chunk-MFVCSNIY.cjs +308 -0
  76. package/dist/chunk-MFVCSNIY.cjs.map +1 -0
  77. package/dist/chunk-MNO33ASC.cjs +240 -0
  78. package/dist/chunk-MNO33ASC.cjs.map +1 -0
  79. package/dist/chunk-N4AOJ3VF.cjs +154 -0
  80. package/dist/chunk-N4AOJ3VF.cjs.map +1 -0
  81. package/dist/chunk-P5CNM325.cjs +508 -0
  82. package/dist/chunk-P5CNM325.cjs.map +1 -0
  83. package/dist/chunk-RYT4H46I.js +646 -0
  84. package/dist/chunk-RYT4H46I.js.map +1 -0
  85. package/dist/chunk-SV5H3XM5.cjs +321 -0
  86. package/dist/chunk-SV5H3XM5.cjs.map +1 -0
  87. package/dist/chunk-TXHKFLWX.cjs +344 -0
  88. package/dist/chunk-TXHKFLWX.cjs.map +1 -0
  89. package/dist/chunk-UJAGXJDG.cjs +170 -0
  90. package/dist/chunk-UJAGXJDG.cjs.map +1 -0
  91. package/dist/chunk-VXRVGFCI.js +1128 -0
  92. package/dist/chunk-VXRVGFCI.js.map +1 -0
  93. package/dist/chunk-YM5AL65Y.cjs +357 -0
  94. package/dist/chunk-YM5AL65Y.cjs.map +1 -0
  95. package/dist/index.cjs +8334 -0
  96. package/dist/index.cjs.map +1 -0
  97. package/dist/index.d.cts +1365 -0
  98. package/dist/index.d.ts +1365 -0
  99. package/dist/index.js +8105 -0
  100. package/dist/index.js.map +1 -0
  101. package/dist/indexes/index.cjs +67 -0
  102. package/dist/indexes/index.cjs.map +1 -0
  103. package/dist/indexes/index.d.cts +62 -0
  104. package/dist/indexes/index.d.ts +62 -0
  105. package/dist/indexes/index.js +6 -0
  106. package/dist/indexes/index.js.map +1 -0
  107. package/dist/interchange/index.cjs +612 -0
  108. package/dist/interchange/index.cjs.map +1 -0
  109. package/dist/interchange/index.d.cts +288 -0
  110. package/dist/interchange/index.d.ts +288 -0
  111. package/dist/interchange/index.js +598 -0
  112. package/dist/interchange/index.js.map +1 -0
  113. package/dist/profiler/index.cjs +793 -0
  114. package/dist/profiler/index.cjs.map +1 -0
  115. package/dist/profiler/index.d.cts +283 -0
  116. package/dist/profiler/index.d.ts +283 -0
  117. package/dist/profiler/index.js +785 -0
  118. package/dist/profiler/index.js.map +1 -0
  119. package/dist/store-60Lcfi0w.d.ts +2263 -0
  120. package/dist/store-Bifii8MZ.d.cts +2263 -0
  121. package/dist/test-helpers-BjyRYJZX.d.ts +22 -0
  122. package/dist/test-helpers-NoQXhleQ.d.cts +22 -0
  123. package/dist/types-BRzHlhKC.d.cts +14 -0
  124. package/dist/types-BRzHlhKC.d.ts +14 -0
  125. package/dist/types-BrSfFSpW.d.cts +158 -0
  126. package/dist/types-CX4cLd7M.d.ts +152 -0
  127. package/dist/types-CjZ7g_7v.d.ts +442 -0
  128. package/dist/types-DDOSfrih.d.cts +442 -0
  129. package/dist/types-D_3mEv2y.d.ts +158 -0
  130. package/dist/types-a5rAxC92.d.cts +152 -0
  131. package/package.json +201 -0
@@ -0,0 +1,1128 @@
1
+ import { getDialect, EDGE_META_KEYS, NODE_META_KEYS } from './chunk-IIAT36MI.js';
2
+ import { createSchemaIntrospector, jsonPointer, normalizeJsonPointer, parseJsonPointer, resolveFieldTypeInfoAtJsonPointer } from './chunk-K7SQ3SWP.js';
3
+ import { sql } from 'drizzle-orm';
4
+ import { CasingCache } from 'drizzle-orm/casing';
5
+ import { uniqueIndex, index } from 'drizzle-orm/pg-core';
6
+ import { uniqueIndex as uniqueIndex$1, index as index$1 } from 'drizzle-orm/sqlite-core';
7
+
8
+ function compileNodeIndexKeys(index, dialect, propsColumn, systemColumn) {
9
+ const adapter = getDialect(dialect);
10
+ const keys = [];
11
+ for (const column of getNodeScopeColumns(index.scope)) {
12
+ keys.push(systemColumn(column));
13
+ }
14
+ const allPointers = [...index.fields, ...index.coveringFields];
15
+ const allValueTypes = [
16
+ ...index.fieldValueTypes,
17
+ ...index.coveringFieldValueTypes
18
+ ];
19
+ for (const [pointerIndex, pointer] of allPointers.entries()) {
20
+ const valueType = allValueTypes[pointerIndex];
21
+ const extracted = compileIndexKeyValue(
22
+ adapter,
23
+ propsColumn,
24
+ pointer,
25
+ valueType
26
+ );
27
+ keys.push(sql`(${extracted})`);
28
+ }
29
+ return { keys };
30
+ }
31
+ function compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn) {
32
+ const adapter = getDialect(dialect);
33
+ const keys = [];
34
+ for (const column of getEdgeScopeColumns(index.scope, index.direction)) {
35
+ keys.push(systemColumn(column));
36
+ }
37
+ const allPointers = [...index.fields, ...index.coveringFields];
38
+ const allValueTypes = [
39
+ ...index.fieldValueTypes,
40
+ ...index.coveringFieldValueTypes
41
+ ];
42
+ for (const [pointerIndex, pointer] of allPointers.entries()) {
43
+ const valueType = allValueTypes[pointerIndex];
44
+ const extracted = compileIndexKeyValue(
45
+ adapter,
46
+ propsColumn,
47
+ pointer,
48
+ valueType
49
+ );
50
+ keys.push(sql`(${extracted})`);
51
+ }
52
+ return { keys };
53
+ }
54
+ function compileIndexKeyValue(dialect, propsColumn, pointer, valueType) {
55
+ switch (valueType) {
56
+ case "number": {
57
+ return dialect.jsonExtractNumber(propsColumn, pointer);
58
+ }
59
+ case "boolean": {
60
+ return dialect.jsonExtractBoolean(propsColumn, pointer);
61
+ }
62
+ case "date": {
63
+ return dialect.jsonExtractDate(propsColumn, pointer);
64
+ }
65
+ case "string":
66
+ case "unknown":
67
+ case void 0: {
68
+ return dialect.jsonExtractText(propsColumn, pointer);
69
+ }
70
+ case "array":
71
+ case "object":
72
+ case "embedding": {
73
+ return dialect.jsonExtract(propsColumn, pointer);
74
+ }
75
+ }
76
+ }
77
+ function getNodeScopeColumns(scope) {
78
+ switch (scope) {
79
+ case "graphAndKind": {
80
+ return ["graph_id", "kind"];
81
+ }
82
+ case "graph": {
83
+ return ["graph_id"];
84
+ }
85
+ case "none": {
86
+ return [];
87
+ }
88
+ }
89
+ }
90
+ function getEdgeScopeColumns(scope, direction) {
91
+ const base = scope === "graphAndKind" ? ["graph_id", "kind"] : scope === "graph" ? ["graph_id"] : [];
92
+ if (direction === "out") {
93
+ return [...base, "from_id"];
94
+ }
95
+ if (direction === "in") {
96
+ return [...base, "to_id"];
97
+ }
98
+ return [...base];
99
+ }
100
+ function isIndexWhereLiteralList(value) {
101
+ return Array.isArray(value);
102
+ }
103
+ function compileIndexWhere(ctx, expression) {
104
+ switch (expression.__type) {
105
+ case "index_where_and": {
106
+ return sql`(${sql.join(
107
+ expression.predicates.map((p) => compileIndexWhere(ctx, p)),
108
+ sql` AND `
109
+ )})`;
110
+ }
111
+ case "index_where_or": {
112
+ return sql`(${sql.join(
113
+ expression.predicates.map((p) => compileIndexWhere(ctx, p)),
114
+ sql` OR `
115
+ )})`;
116
+ }
117
+ case "index_where_not": {
118
+ return sql`(NOT ${compileIndexWhere(ctx, expression.predicate)})`;
119
+ }
120
+ case "index_where_null_check": {
121
+ const operand = compileIndexWhereOperand(ctx, expression.operand);
122
+ return expression.op === "isNull" ? sql`${operand} IS NULL` : sql`${operand} IS NOT NULL`;
123
+ }
124
+ case "index_where_comparison": {
125
+ const left = compileIndexWhereOperand(ctx, expression.left);
126
+ const right = expression.right;
127
+ if (isIndexWhereLiteralList(right)) {
128
+ if (expression.op !== "in" && expression.op !== "notIn") {
129
+ throw new Error(
130
+ `Operator "${expression.op}" does not support list comparison in index WHERE clause`
131
+ );
132
+ }
133
+ const values = right.map(
134
+ (literal) => compileIndexWhereLiteral(ctx.dialect, literal)
135
+ );
136
+ const operator = expression.op === "in" ? sql`IN` : sql`NOT IN`;
137
+ return sql`${left} ${operator} (${sql.join(values, sql`, `)})`;
138
+ }
139
+ if (expression.op === "in" || expression.op === "notIn") {
140
+ throw new Error(
141
+ `Operator "${expression.op}" requires a list of values in index WHERE clause`
142
+ );
143
+ }
144
+ const rightLiteral = compileIndexWhereLiteral(ctx.dialect, right);
145
+ const opSql = compileComparisonOperator(expression.op);
146
+ return sql`${left} ${opSql} ${rightLiteral}`;
147
+ }
148
+ }
149
+ }
150
+ function compileIndexWhereOperand(ctx, operand) {
151
+ if (operand.__type === "index_operand_system") {
152
+ return ctx.systemColumn(operand.column);
153
+ }
154
+ const adapter = getDialect(ctx.dialect);
155
+ const pointer = jsonPointer([operand.field]);
156
+ switch (operand.valueType) {
157
+ case "number": {
158
+ return adapter.jsonExtractNumber(ctx.propsColumn, pointer);
159
+ }
160
+ case "boolean": {
161
+ return adapter.jsonExtractBoolean(ctx.propsColumn, pointer);
162
+ }
163
+ case "date": {
164
+ return adapter.jsonExtractDate(ctx.propsColumn, pointer);
165
+ }
166
+ case "array":
167
+ case "object":
168
+ case "embedding": {
169
+ return adapter.jsonExtract(ctx.propsColumn, pointer);
170
+ }
171
+ case "string":
172
+ case "unknown":
173
+ case void 0: {
174
+ return adapter.jsonExtractText(ctx.propsColumn, pointer);
175
+ }
176
+ }
177
+ }
178
+ function compileIndexWhereLiteral(dialect, literal) {
179
+ switch (literal.valueType) {
180
+ case "string":
181
+ case "date": {
182
+ return sql.raw(escapeStringLiteral(literal.value.toString()));
183
+ }
184
+ case "number": {
185
+ return sql.raw(literal.value.toString());
186
+ }
187
+ case "boolean": {
188
+ return getDialect(dialect).booleanLiteral(literal.value);
189
+ }
190
+ case "array":
191
+ case "object":
192
+ case "embedding":
193
+ case "unknown": {
194
+ return sql.raw(escapeStringLiteral(literal.value.toString()));
195
+ }
196
+ }
197
+ }
198
+ function compileComparisonOperator(op) {
199
+ switch (op) {
200
+ case "eq": {
201
+ return sql`=`;
202
+ }
203
+ case "neq": {
204
+ return sql`<>`;
205
+ }
206
+ case "gt": {
207
+ return sql`>`;
208
+ }
209
+ case "gte": {
210
+ return sql`>=`;
211
+ }
212
+ case "lt": {
213
+ return sql`<`;
214
+ }
215
+ case "lte": {
216
+ return sql`<=`;
217
+ }
218
+ }
219
+ }
220
+ function escapeStringLiteral(value) {
221
+ return `'${value.replaceAll("'", "''")}'`;
222
+ }
223
+
224
+ // src/indexes/ddl.ts
225
+ function generateIndexDDL(index, dialect, options = {}) {
226
+ if (index.__type === "typegraph_node_index") {
227
+ return generateNodeIndexDDL(index, dialect, options);
228
+ }
229
+ return generateEdgeIndexDDL(index, dialect, options);
230
+ }
231
+ function generateNodeIndexDDL(index, dialect, options = {}) {
232
+ const tableName = options.nodesTableName ?? "typegraph_nodes";
233
+ return generateTableIndexDDL(index, dialect, tableName, options);
234
+ }
235
+ function generateEdgeIndexDDL(index, dialect, options = {}) {
236
+ const tableName = options.edgesTableName ?? "typegraph_edges";
237
+ return generateTableIndexDDL(index, dialect, tableName, options);
238
+ }
239
+ function generateTableIndexDDL(index, dialect, tableName, options) {
240
+ const ifNotExists = options.ifNotExists ?? true;
241
+ const propsColumn = sql.raw('"props"');
242
+ const systemColumn = (column) => sql.raw(quoteIdentifier(column));
243
+ const keys = index.__type === "typegraph_node_index" ? compileNodeIndexKeys(index, dialect, propsColumn, systemColumn).keys : compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn).keys;
244
+ const whereSql = index.where ? sqlToInlineString(
245
+ compileIndexWhere(
246
+ {
247
+ dialect,
248
+ propsColumn,
249
+ systemColumn
250
+ },
251
+ index.where
252
+ ),
253
+ dialect
254
+ ) : void 0;
255
+ const keySql = keys.map((k) => sqlToInlineString(k, dialect)).join(", ");
256
+ const unique = index.unique ? "UNIQUE " : "";
257
+ const ifNotExistsSql = ifNotExists ? "IF NOT EXISTS " : "";
258
+ const whereClause = whereSql ? ` WHERE ${whereSql}` : "";
259
+ return `CREATE ${unique}INDEX ${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${keySql})${whereClause};`;
260
+ }
261
+ function quoteIdentifier(identifier) {
262
+ return `"${identifier.replaceAll('"', '""')}"`;
263
+ }
264
+ function sqlToInlineString(object, dialect) {
265
+ const query = object.toQuery({
266
+ casing: new CasingCache(),
267
+ escapeName: (name) => name,
268
+ escapeParam: (_number, value) => inlineParam(value, dialect),
269
+ escapeString: (value) => escapeStringLiteral2(value),
270
+ inlineParams: true,
271
+ invokeSource: "indexes"
272
+ });
273
+ if (query.params.length > 0) {
274
+ throw new Error(
275
+ "Index DDL generation produced parameters; expected fully inlined SQL"
276
+ );
277
+ }
278
+ return query.sql;
279
+ }
280
+ function inlineParam(value, dialect) {
281
+ if (value === null || value === void 0) {
282
+ return "NULL";
283
+ }
284
+ if (value instanceof Date) {
285
+ return escapeStringLiteral2(value.toISOString());
286
+ }
287
+ if (typeof value === "string") {
288
+ return escapeStringLiteral2(value);
289
+ }
290
+ if (typeof value === "number") {
291
+ return value.toString();
292
+ }
293
+ if (typeof value === "boolean") {
294
+ return getDialect(dialect).booleanLiteralString(value);
295
+ }
296
+ if (typeof value === "bigint") {
297
+ return value.toString();
298
+ }
299
+ throw new TypeError(
300
+ "Index DDL generation received an unsupported SQL parameter value"
301
+ );
302
+ }
303
+ function escapeStringLiteral2(value) {
304
+ return `'${value.replaceAll("'", "''")}'`;
305
+ }
306
+
307
+ // src/indexes/define-index.ts
308
+ function defineNodeIndex(node, config) {
309
+ const scope = config.scope ?? "graphAndKind";
310
+ const unique = config.unique ?? false;
311
+ const schemaIntrospector = createSchemaIntrospector(
312
+ /* @__PURE__ */ new Map([[node.name, { schema: node.schema }]])
313
+ );
314
+ const { pointers: fields, valueTypes: fieldValueTypes } = normalizeNodeIndexFieldsOrThrow(
315
+ node,
316
+ config.fields,
317
+ schemaIntrospector,
318
+ "fields",
319
+ { allowEmpty: false }
320
+ );
321
+ const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } = normalizeNodeIndexFieldsOrThrow(
322
+ node,
323
+ config.coveringFields ?? [],
324
+ schemaIntrospector,
325
+ "coveringFields",
326
+ { allowEmpty: true }
327
+ );
328
+ assertNoOverlap(fields, coveringFields, "fields", "coveringFields");
329
+ const where = normalizeWhereInput(
330
+ config.where,
331
+ () => createNodeWhereBuilder(node, schemaIntrospector)
332
+ );
333
+ const name = config.name ?? generateDefaultIndexName({
334
+ kind: "node",
335
+ kindName: node.name,
336
+ unique,
337
+ scope,
338
+ direction: "none",
339
+ fields,
340
+ coveringFields
341
+ });
342
+ return {
343
+ __type: "typegraph_node_index",
344
+ node,
345
+ nodeKind: node.name,
346
+ fields,
347
+ fieldValueTypes,
348
+ coveringFields,
349
+ coveringFieldValueTypes,
350
+ unique,
351
+ scope,
352
+ where,
353
+ name
354
+ };
355
+ }
356
+ function defineEdgeIndex(edge, config) {
357
+ const scope = config.scope ?? "graphAndKind";
358
+ const unique = config.unique ?? false;
359
+ const direction = config.direction ?? "none";
360
+ const schemaIntrospector = createSchemaIntrospector(
361
+ /* @__PURE__ */ new Map(),
362
+ /* @__PURE__ */ new Map([[edge.name, { schema: edge.schema }]])
363
+ );
364
+ const { pointers: fields, valueTypes: fieldValueTypes } = normalizeEdgeIndexFieldsOrThrow(
365
+ edge,
366
+ config.fields,
367
+ schemaIntrospector,
368
+ "fields",
369
+ { allowEmpty: false }
370
+ );
371
+ const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } = normalizeEdgeIndexFieldsOrThrow(
372
+ edge,
373
+ config.coveringFields ?? [],
374
+ schemaIntrospector,
375
+ "coveringFields",
376
+ { allowEmpty: true }
377
+ );
378
+ assertNoOverlap(fields, coveringFields, "fields", "coveringFields");
379
+ const where = normalizeWhereInput(
380
+ config.where,
381
+ () => createEdgeWhereBuilder(edge, schemaIntrospector)
382
+ );
383
+ const name = config.name ?? generateDefaultIndexName({
384
+ kind: "edge",
385
+ kindName: edge.name,
386
+ unique,
387
+ scope,
388
+ direction,
389
+ fields,
390
+ coveringFields
391
+ });
392
+ return {
393
+ __type: "typegraph_edge_index",
394
+ edge,
395
+ edgeKind: edge.name,
396
+ fields,
397
+ fieldValueTypes,
398
+ coveringFields,
399
+ coveringFieldValueTypes,
400
+ unique,
401
+ scope,
402
+ direction,
403
+ where,
404
+ name
405
+ };
406
+ }
407
+ function normalizeWhereInput(input, createBuilder) {
408
+ if (input === void 0) {
409
+ return void 0;
410
+ }
411
+ if (typeof input === "function") {
412
+ return input(createBuilder());
413
+ }
414
+ return input;
415
+ }
416
+ function createNodeWhereBuilder(node, schemaIntrospector) {
417
+ const shape = getSchemaShape(node.schema);
418
+ const system = createSystemColumnMapForNode();
419
+ function getOperand(key) {
420
+ const systemColumn = system.get(key);
421
+ if (systemColumn) {
422
+ return {
423
+ __type: "index_operand_system",
424
+ column: systemColumn.column,
425
+ valueType: systemColumn.valueType
426
+ };
427
+ }
428
+ if (!(key in shape)) {
429
+ throw new Error(
430
+ `Unknown field "${key}" in node index WHERE clause for "${node.name}"`
431
+ );
432
+ }
433
+ const info = schemaIntrospector.getFieldTypeInfo(node.name, key);
434
+ const valueType = info?.valueType;
435
+ return {
436
+ __type: "index_operand_prop",
437
+ field: key,
438
+ valueType
439
+ };
440
+ }
441
+ return createWhereProxy((key) => getOperand(key));
442
+ }
443
+ function createEdgeWhereBuilder(edge, schemaIntrospector) {
444
+ const shape = getSchemaShape(edge.schema);
445
+ const system = createSystemColumnMapForEdge();
446
+ function getOperand(key) {
447
+ const systemColumn = system.get(key);
448
+ if (systemColumn) {
449
+ return {
450
+ __type: "index_operand_system",
451
+ column: systemColumn.column,
452
+ valueType: systemColumn.valueType
453
+ };
454
+ }
455
+ if (!(key in shape)) {
456
+ throw new Error(
457
+ `Unknown field "${key}" in edge index WHERE clause for "${edge.name}"`
458
+ );
459
+ }
460
+ const info = schemaIntrospector.getEdgeFieldTypeInfo(edge.name, key);
461
+ const valueType = info?.valueType;
462
+ return {
463
+ __type: "index_operand_prop",
464
+ field: key,
465
+ valueType
466
+ };
467
+ }
468
+ return createWhereProxy((key) => getOperand(key));
469
+ }
470
+ function createWhereProxy(getOperand) {
471
+ return new Proxy(/* @__PURE__ */ Object.create(null), {
472
+ get: (_target, property) => {
473
+ if (typeof property !== "string") return;
474
+ if (property === "then") return;
475
+ if (property === "toJSON") return;
476
+ const operand = getOperand(property);
477
+ return createIndexWhereFieldBuilder(operand);
478
+ }
479
+ });
480
+ }
481
+ function createIndexWhereFieldBuilder(operand) {
482
+ function isNull() {
483
+ return { __type: "index_where_null_check", operand, op: "isNull" };
484
+ }
485
+ function isNotNull() {
486
+ return { __type: "index_where_null_check", operand, op: "isNotNull" };
487
+ }
488
+ function comparison(op, value) {
489
+ return {
490
+ __type: "index_where_comparison",
491
+ left: operand,
492
+ op,
493
+ right: toLiteralOrThrow(value, operand.valueType)
494
+ };
495
+ }
496
+ function listComparison(op, values) {
497
+ const literals = values.map(
498
+ (value) => toLiteralOrThrow(value, operand.valueType)
499
+ );
500
+ return {
501
+ __type: "index_where_comparison",
502
+ left: operand,
503
+ op,
504
+ right: literals
505
+ };
506
+ }
507
+ return {
508
+ eq: (value) => comparison("eq", value),
509
+ neq: (value) => comparison("neq", value),
510
+ gt: (value) => comparison("gt", value),
511
+ gte: (value) => comparison("gte", value),
512
+ lt: (value) => comparison("lt", value),
513
+ lte: (value) => comparison("lte", value),
514
+ in: (values) => listComparison("in", values),
515
+ notIn: (values) => listComparison("notIn", values),
516
+ isNull,
517
+ isNotNull
518
+ };
519
+ }
520
+ function toLiteralOrThrow(value, preferredType) {
521
+ if (value instanceof Date) {
522
+ return {
523
+ __type: "index_where_literal",
524
+ value: value.toISOString(),
525
+ valueType: "date"
526
+ };
527
+ }
528
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
529
+ const valueType = inferValueType(value, preferredType);
530
+ return { __type: "index_where_literal", value, valueType };
531
+ }
532
+ throw new Error(
533
+ `Unsupported literal value type in index WHERE clause: ${String(value)}`
534
+ );
535
+ }
536
+ function inferValueType(value, preferredType) {
537
+ if (preferredType === "date" && typeof value === "string") {
538
+ return "date";
539
+ }
540
+ if (preferredType === "number" && typeof value === "string") {
541
+ return "number";
542
+ }
543
+ if (preferredType === "boolean" && typeof value === "string") {
544
+ return "boolean";
545
+ }
546
+ if (typeof value === "string") return "string";
547
+ if (typeof value === "number") return "number";
548
+ return "boolean";
549
+ }
550
+ function toSystemColumnName(metaKey) {
551
+ const snake = metaKey.replaceAll(/([A-Z])/g, "_$1").toLowerCase();
552
+ switch (snake) {
553
+ case "deleted_at":
554
+ case "valid_from":
555
+ case "valid_to":
556
+ case "created_at":
557
+ case "updated_at": {
558
+ return snake;
559
+ }
560
+ default: {
561
+ throw new Error(`Unsupported system meta key: ${metaKey}`);
562
+ }
563
+ }
564
+ }
565
+ function createSystemColumnMapForNode() {
566
+ const entries = [
567
+ ["graphId", { column: "graph_id", valueType: "string" }],
568
+ ["kind", { column: "kind", valueType: "string" }],
569
+ ["id", { column: "id", valueType: "string" }]
570
+ ];
571
+ for (const key of NODE_META_KEYS) {
572
+ if (key === "version") {
573
+ entries.push([key, { column: "version", valueType: "number" }]);
574
+ continue;
575
+ }
576
+ entries.push([key, { column: toSystemColumnName(key), valueType: "date" }]);
577
+ }
578
+ return new Map(entries);
579
+ }
580
+ function createSystemColumnMapForEdge() {
581
+ const entries = [
582
+ ["graphId", { column: "graph_id", valueType: "string" }],
583
+ ["kind", { column: "kind", valueType: "string" }],
584
+ ["id", { column: "id", valueType: "string" }],
585
+ ["fromKind", { column: "from_kind", valueType: "string" }],
586
+ ["fromId", { column: "from_id", valueType: "string" }],
587
+ ["toKind", { column: "to_kind", valueType: "string" }],
588
+ ["toId", { column: "to_id", valueType: "string" }]
589
+ ];
590
+ for (const key of EDGE_META_KEYS) {
591
+ entries.push([key, { column: toSystemColumnName(key), valueType: "date" }]);
592
+ }
593
+ return new Map(entries);
594
+ }
595
+ function getSchemaShape(schema) {
596
+ if (schema.type !== "object") {
597
+ throw new Error("Index definitions require an object schema");
598
+ }
599
+ const def = schema.def;
600
+ const shape = def.shape;
601
+ if (!shape) {
602
+ throw new Error("Index definitions require a resolvable object shape");
603
+ }
604
+ return shape;
605
+ }
606
+ function assertNonEmpty(values, label) {
607
+ if (values.length === 0) {
608
+ throw new Error(`Index ${label} must not be empty`);
609
+ }
610
+ }
611
+ function assertUnique(values, label) {
612
+ const set = /* @__PURE__ */ new Set();
613
+ for (const value of values) {
614
+ if (set.has(value)) {
615
+ throw new Error(`Index ${label} contains duplicate value: ${value}`);
616
+ }
617
+ set.add(value);
618
+ }
619
+ }
620
+ function assertNoOverlap(a, b, aLabel, bLabel) {
621
+ const set = new Set(a);
622
+ for (const value of b) {
623
+ if (set.has(value)) {
624
+ throw new Error(`Index ${bLabel} must not overlap ${aLabel}: ${value}`);
625
+ }
626
+ }
627
+ }
628
+ function assertIndexableValueType(valueType, context) {
629
+ if (valueType === "embedding") {
630
+ throw new Error(
631
+ `Cannot create props index for embedding field (${context}); use vector indexes on the embeddings table instead`
632
+ );
633
+ }
634
+ if (valueType === "array" || valueType === "object") {
635
+ throw new Error(
636
+ `Cannot create btree props index for ${valueType} field (${context}); use a GIN/JSON index strategy instead`
637
+ );
638
+ }
639
+ }
640
+ function normalizeNodeIndexFieldsOrThrow(node, inputs, schemaIntrospector, label, options) {
641
+ if (inputs.length === 0 && options.allowEmpty) {
642
+ return { pointers: [], valueTypes: [] };
643
+ }
644
+ assertNonEmpty(inputs, label);
645
+ const pointers = [];
646
+ const valueTypes = [];
647
+ for (const input of inputs) {
648
+ const pointer = normalizeIndexFieldPointer(input);
649
+ const info = resolveNodeFieldTypeInfoOrThrow(
650
+ node.name,
651
+ pointer,
652
+ schemaIntrospector
653
+ );
654
+ assertIndexableValueType(info.valueType, `node "${node.name}" ${pointer}`);
655
+ pointers.push(pointer);
656
+ valueTypes.push(info.valueType);
657
+ }
658
+ assertUnique(pointers, label);
659
+ return { pointers, valueTypes };
660
+ }
661
+ function normalizeEdgeIndexFieldsOrThrow(edge, inputs, schemaIntrospector, label, options) {
662
+ if (inputs.length === 0 && options.allowEmpty) {
663
+ return { pointers: [], valueTypes: [] };
664
+ }
665
+ assertNonEmpty(inputs, label);
666
+ const pointers = [];
667
+ const valueTypes = [];
668
+ for (const input of inputs) {
669
+ const pointer = normalizeIndexFieldPointer(input);
670
+ const info = resolveEdgeFieldTypeInfoOrThrow(
671
+ edge.name,
672
+ pointer,
673
+ schemaIntrospector
674
+ );
675
+ assertIndexableValueType(info.valueType, `edge "${edge.name}" ${pointer}`);
676
+ pointers.push(pointer);
677
+ valueTypes.push(info.valueType);
678
+ }
679
+ assertUnique(pointers, label);
680
+ return { pointers, valueTypes };
681
+ }
682
+ function normalizeIndexFieldPointer(input) {
683
+ if (Array.isArray(input)) {
684
+ if (input.length === 0) {
685
+ throw new Error("Index field JSON pointer must not be empty");
686
+ }
687
+ return jsonPointer(input);
688
+ }
689
+ if (typeof input === "string") {
690
+ if (input.startsWith("/")) {
691
+ const pointer = normalizeJsonPointer(
692
+ input
693
+ );
694
+ if (pointer === "") {
695
+ throw new Error("Index field JSON pointer must not be empty");
696
+ }
697
+ return pointer;
698
+ }
699
+ return jsonPointer([input]);
700
+ }
701
+ throw new Error(`Unsupported index field input: ${String(input)}`);
702
+ }
703
+ function resolveNodeFieldTypeInfoOrThrow(nodeKind, pointer, schemaIntrospector) {
704
+ const segments = parseJsonPointer(pointer);
705
+ const [first, ...rest] = segments;
706
+ if (!first) {
707
+ throw new Error("Index field JSON pointer must not be empty");
708
+ }
709
+ const rootInfo = schemaIntrospector.getFieldTypeInfo(nodeKind, first);
710
+ if (!rootInfo) {
711
+ throw new Error(
712
+ `Unknown field "${first}" for node "${nodeKind}" in index definition`
713
+ );
714
+ }
715
+ if (rest.length === 0) {
716
+ return rootInfo;
717
+ }
718
+ const resolved = resolveFieldTypeInfoAtJsonPointer(
719
+ rootInfo,
720
+ jsonPointer(rest)
721
+ );
722
+ if (!resolved) {
723
+ throw new Error(
724
+ `Unknown JSON pointer "${pointer}" for node "${nodeKind}" in index definition`
725
+ );
726
+ }
727
+ return resolved;
728
+ }
729
+ function resolveEdgeFieldTypeInfoOrThrow(edgeKind, pointer, schemaIntrospector) {
730
+ const segments = parseJsonPointer(pointer);
731
+ const [first, ...rest] = segments;
732
+ if (!first) {
733
+ throw new Error("Index field JSON pointer must not be empty");
734
+ }
735
+ const rootInfo = schemaIntrospector.getEdgeFieldTypeInfo(edgeKind, first);
736
+ if (!rootInfo) {
737
+ throw new Error(
738
+ `Unknown field "${first}" for edge "${edgeKind}" in index definition`
739
+ );
740
+ }
741
+ if (rest.length === 0) {
742
+ return rootInfo;
743
+ }
744
+ const resolved = resolveFieldTypeInfoAtJsonPointer(
745
+ rootInfo,
746
+ jsonPointer(rest)
747
+ );
748
+ if (!resolved) {
749
+ throw new Error(
750
+ `Unknown JSON pointer "${pointer}" for edge "${edgeKind}" in index definition`
751
+ );
752
+ }
753
+ return resolved;
754
+ }
755
+ function generateDefaultIndexName(parts) {
756
+ const hash = fnv1aBase36Hash(
757
+ JSON.stringify({
758
+ kind: parts.kind,
759
+ kindName: parts.kindName,
760
+ unique: parts.unique,
761
+ scope: parts.scope,
762
+ direction: parts.direction,
763
+ fields: parts.fields,
764
+ covering: parts.coveringFields
765
+ })
766
+ );
767
+ const nameParts = [
768
+ "idx",
769
+ "tg",
770
+ parts.kind,
771
+ sanitizeIdentifierComponent(parts.kindName),
772
+ sanitizeIdentifierComponent(parts.fields.join("_")),
773
+ parts.coveringFields.length > 0 ? `cov_${sanitizeIdentifierComponent(parts.coveringFields.join("_"))}` : void 0,
774
+ parts.direction === "none" ? void 0 : parts.direction,
775
+ parts.unique ? "uniq" : void 0,
776
+ parts.scope === "graphAndKind" ? void 0 : sanitizeIdentifierComponent(parts.scope),
777
+ hash
778
+ ].filter((part) => part !== void 0);
779
+ const joined = nameParts.join("_");
780
+ return joined.length <= 63 ? joined : `${joined.slice(0, 54)}_${hash}`;
781
+ }
782
+ function sanitizeIdentifierComponent(value) {
783
+ return value.toLowerCase().replaceAll(/[^a-z0-9_]+/g, "_").replaceAll(/^_+|_+$/g, "").slice(0, 20);
784
+ }
785
+ function fnv1aBase36Hash(input) {
786
+ let hash = 2166136261;
787
+ for (const character of input) {
788
+ const codePoint = character.codePointAt(0);
789
+ if (codePoint === void 0) {
790
+ continue;
791
+ }
792
+ hash ^= codePoint;
793
+ hash = Math.imul(hash, 16777619);
794
+ }
795
+ return (hash >>> 0).toString(36);
796
+ }
797
+ function buildPostgresNodeIndexBuilders(table, indexes) {
798
+ const nodeIndexes = indexes.filter(
799
+ (index) => index.__type === "typegraph_node_index"
800
+ );
801
+ return nodeIndexes.map((index$1) => {
802
+ const propsColumn = sql`${table.props}`;
803
+ const systemColumn = (column) => sql`${getPostgresNodeSystemColumn(table, column)}`;
804
+ const { keys } = compileNodeIndexKeys(
805
+ index$1,
806
+ "postgres",
807
+ propsColumn,
808
+ systemColumn
809
+ );
810
+ assertNonEmpty2(keys, `node index "${index$1.name}"`);
811
+ const base = index$1.unique ? uniqueIndex(index$1.name) : index(index$1.name);
812
+ const builder = base.on(...keys);
813
+ if (index$1.where) {
814
+ const ctx = {
815
+ dialect: "postgres",
816
+ propsColumn,
817
+ systemColumn
818
+ };
819
+ builder.where(compileIndexWhere(ctx, index$1.where));
820
+ }
821
+ return builder;
822
+ });
823
+ }
824
+ function buildPostgresEdgeIndexBuilders(table, indexes) {
825
+ const edgeIndexes = indexes.filter(
826
+ (index) => index.__type === "typegraph_edge_index"
827
+ );
828
+ return edgeIndexes.map((index$1) => {
829
+ const propsColumn = sql`${table.props}`;
830
+ const systemColumn = (column) => sql`${getPostgresEdgeSystemColumn(table, column)}`;
831
+ const { keys } = compileEdgeIndexKeys(
832
+ index$1,
833
+ "postgres",
834
+ propsColumn,
835
+ systemColumn
836
+ );
837
+ assertNonEmpty2(keys, `edge index "${index$1.name}"`);
838
+ const base = index$1.unique ? uniqueIndex(index$1.name) : index(index$1.name);
839
+ const builder = base.on(...keys);
840
+ if (index$1.where) {
841
+ const ctx = {
842
+ dialect: "postgres",
843
+ propsColumn,
844
+ systemColumn
845
+ };
846
+ builder.where(compileIndexWhere(ctx, index$1.where));
847
+ }
848
+ return builder;
849
+ });
850
+ }
851
+ function getPostgresNodeSystemColumn(table, column) {
852
+ switch (column) {
853
+ case "graph_id": {
854
+ return table.graphId;
855
+ }
856
+ case "kind": {
857
+ return table.kind;
858
+ }
859
+ case "id": {
860
+ return table.id;
861
+ }
862
+ case "from_kind":
863
+ case "from_id":
864
+ case "to_kind":
865
+ case "to_id": {
866
+ throw new Error(`Unsupported node system column for indexes: ${column}`);
867
+ }
868
+ case "deleted_at": {
869
+ return table.deletedAt;
870
+ }
871
+ case "valid_from": {
872
+ return table.validFrom;
873
+ }
874
+ case "valid_to": {
875
+ return table.validTo;
876
+ }
877
+ case "created_at": {
878
+ return table.createdAt;
879
+ }
880
+ case "updated_at": {
881
+ return table.updatedAt;
882
+ }
883
+ case "version": {
884
+ return table.version;
885
+ }
886
+ }
887
+ }
888
+ function getPostgresEdgeSystemColumn(table, column) {
889
+ switch (column) {
890
+ case "graph_id": {
891
+ return table.graphId;
892
+ }
893
+ case "kind": {
894
+ return table.kind;
895
+ }
896
+ case "id": {
897
+ return table.id;
898
+ }
899
+ case "from_kind": {
900
+ return table.fromKind;
901
+ }
902
+ case "from_id": {
903
+ return table.fromId;
904
+ }
905
+ case "to_kind": {
906
+ return table.toKind;
907
+ }
908
+ case "to_id": {
909
+ return table.toId;
910
+ }
911
+ case "deleted_at": {
912
+ return table.deletedAt;
913
+ }
914
+ case "valid_from": {
915
+ return table.validFrom;
916
+ }
917
+ case "valid_to": {
918
+ return table.validTo;
919
+ }
920
+ case "created_at": {
921
+ return table.createdAt;
922
+ }
923
+ case "updated_at": {
924
+ return table.updatedAt;
925
+ }
926
+ case "version": {
927
+ throw new Error(`Unsupported edge system column for indexes: ${column}`);
928
+ }
929
+ }
930
+ }
931
+ function buildSqliteNodeIndexBuilders(table, indexes) {
932
+ const nodeIndexes = indexes.filter(
933
+ (index) => index.__type === "typegraph_node_index"
934
+ );
935
+ return nodeIndexes.map((index) => {
936
+ const propsColumn = sql`${table.props}`;
937
+ const systemColumn = (column) => sql`${getSqliteNodeSystemColumn(table, column)}`;
938
+ const { keys } = compileNodeIndexKeys(
939
+ index,
940
+ "sqlite",
941
+ propsColumn,
942
+ systemColumn
943
+ );
944
+ assertNonEmpty2(keys, `node index "${index.name}"`);
945
+ const base = index.unique ? uniqueIndex$1(index.name) : index$1(index.name);
946
+ const builder = base.on(...keys);
947
+ if (index.where) {
948
+ const ctx = {
949
+ dialect: "sqlite",
950
+ propsColumn,
951
+ systemColumn
952
+ };
953
+ builder.where(compileIndexWhere(ctx, index.where));
954
+ }
955
+ return builder;
956
+ });
957
+ }
958
+ function buildSqliteEdgeIndexBuilders(table, indexes) {
959
+ const edgeIndexes = indexes.filter(
960
+ (index) => index.__type === "typegraph_edge_index"
961
+ );
962
+ return edgeIndexes.map((index) => {
963
+ const propsColumn = sql`${table.props}`;
964
+ const systemColumn = (column) => sql`${getSqliteEdgeSystemColumn(table, column)}`;
965
+ const { keys } = compileEdgeIndexKeys(
966
+ index,
967
+ "sqlite",
968
+ propsColumn,
969
+ systemColumn
970
+ );
971
+ assertNonEmpty2(keys, `edge index "${index.name}"`);
972
+ const base = index.unique ? uniqueIndex$1(index.name) : index$1(index.name);
973
+ const builder = base.on(...keys);
974
+ if (index.where) {
975
+ const ctx = {
976
+ dialect: "sqlite",
977
+ propsColumn,
978
+ systemColumn
979
+ };
980
+ builder.where(compileIndexWhere(ctx, index.where));
981
+ }
982
+ return builder;
983
+ });
984
+ }
985
+ function getSqliteNodeSystemColumn(table, column) {
986
+ switch (column) {
987
+ case "graph_id": {
988
+ return table.graphId;
989
+ }
990
+ case "kind": {
991
+ return table.kind;
992
+ }
993
+ case "id": {
994
+ return table.id;
995
+ }
996
+ case "from_kind":
997
+ case "from_id":
998
+ case "to_kind":
999
+ case "to_id": {
1000
+ throw new Error(`Unsupported node system column for indexes: ${column}`);
1001
+ }
1002
+ case "deleted_at": {
1003
+ return table.deletedAt;
1004
+ }
1005
+ case "valid_from": {
1006
+ return table.validFrom;
1007
+ }
1008
+ case "valid_to": {
1009
+ return table.validTo;
1010
+ }
1011
+ case "created_at": {
1012
+ return table.createdAt;
1013
+ }
1014
+ case "updated_at": {
1015
+ return table.updatedAt;
1016
+ }
1017
+ case "version": {
1018
+ return table.version;
1019
+ }
1020
+ }
1021
+ }
1022
+ function getSqliteEdgeSystemColumn(table, column) {
1023
+ switch (column) {
1024
+ case "graph_id": {
1025
+ return table.graphId;
1026
+ }
1027
+ case "kind": {
1028
+ return table.kind;
1029
+ }
1030
+ case "id": {
1031
+ return table.id;
1032
+ }
1033
+ case "from_kind": {
1034
+ return table.fromKind;
1035
+ }
1036
+ case "from_id": {
1037
+ return table.fromId;
1038
+ }
1039
+ case "to_kind": {
1040
+ return table.toKind;
1041
+ }
1042
+ case "to_id": {
1043
+ return table.toId;
1044
+ }
1045
+ case "deleted_at": {
1046
+ return table.deletedAt;
1047
+ }
1048
+ case "valid_from": {
1049
+ return table.validFrom;
1050
+ }
1051
+ case "valid_to": {
1052
+ return table.validTo;
1053
+ }
1054
+ case "created_at": {
1055
+ return table.createdAt;
1056
+ }
1057
+ case "updated_at": {
1058
+ return table.updatedAt;
1059
+ }
1060
+ case "version": {
1061
+ throw new Error(`Unsupported edge system column for indexes: ${column}`);
1062
+ }
1063
+ }
1064
+ }
1065
+ function assertNonEmpty2(values, label) {
1066
+ if (values.length === 0) {
1067
+ throw new Error(`Index must have at least one key (${label})`);
1068
+ }
1069
+ }
1070
+
1071
+ // src/indexes/profiler.ts
1072
+ function toDeclaredIndex(index) {
1073
+ if (index.__type === "typegraph_node_index") {
1074
+ return toDeclaredNodeIndex(index);
1075
+ }
1076
+ return toDeclaredEdgeIndex(index);
1077
+ }
1078
+ function toDeclaredIndexes(indexes) {
1079
+ return indexes.map((index) => toDeclaredIndex(index));
1080
+ }
1081
+ function toDeclaredNodeIndex(index) {
1082
+ return {
1083
+ entityType: "node",
1084
+ kind: index.nodeKind,
1085
+ fields: [...index.fields],
1086
+ unique: index.unique,
1087
+ name: index.name
1088
+ };
1089
+ }
1090
+ function toDeclaredEdgeIndex(index) {
1091
+ return {
1092
+ entityType: "edge",
1093
+ kind: index.edgeKind,
1094
+ fields: [...index.fields],
1095
+ unique: index.unique,
1096
+ name: index.name
1097
+ };
1098
+ }
1099
+
1100
+ // src/indexes/where.ts
1101
+ function andWhere(...predicates) {
1102
+ if (predicates.length === 1) {
1103
+ return predicates[0];
1104
+ }
1105
+ return {
1106
+ __type: "index_where_and",
1107
+ predicates
1108
+ };
1109
+ }
1110
+ function orWhere(...predicates) {
1111
+ if (predicates.length === 1) {
1112
+ return predicates[0];
1113
+ }
1114
+ return {
1115
+ __type: "index_where_or",
1116
+ predicates
1117
+ };
1118
+ }
1119
+ function notWhere(predicate) {
1120
+ return {
1121
+ __type: "index_where_not",
1122
+ predicate
1123
+ };
1124
+ }
1125
+
1126
+ export { andWhere, buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders, defineEdgeIndex, defineNodeIndex, generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL, notWhere, orWhere, toDeclaredIndex, toDeclaredIndexes };
1127
+ //# sourceMappingURL=chunk-VXRVGFCI.js.map
1128
+ //# sourceMappingURL=chunk-VXRVGFCI.js.map