@nicia-ai/typegraph 0.27.0 → 0.28.1

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 (77) hide show
  1. package/dist/backend/postgres/index.cjs +100 -58
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +4 -4
  4. package/dist/backend/postgres/index.d.ts +4 -4
  5. package/dist/backend/postgres/index.js +48 -6
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/sqlite/index.cjs +14 -14
  8. package/dist/backend/sqlite/index.d.cts +5 -5
  9. package/dist/backend/sqlite/index.d.ts +5 -5
  10. package/dist/backend/sqlite/index.js +4 -4
  11. package/dist/backend/sqlite/libsql.cjs +7 -7
  12. package/dist/backend/sqlite/libsql.d.cts +2 -2
  13. package/dist/backend/sqlite/libsql.d.ts +2 -2
  14. package/dist/backend/sqlite/libsql.js +4 -4
  15. package/dist/backend/sqlite/local.cjs +8 -8
  16. package/dist/backend/sqlite/local.d.cts +2 -2
  17. package/dist/backend/sqlite/local.d.ts +2 -2
  18. package/dist/backend/sqlite/local.js +4 -4
  19. package/dist/{chunk-X53YKGHR.js → chunk-5MTOKWDA.js} +3 -3
  20. package/dist/{chunk-X53YKGHR.js.map → chunk-5MTOKWDA.js.map} +1 -1
  21. package/dist/chunk-FFHW2JEK.cjs +55 -0
  22. package/dist/chunk-FFHW2JEK.cjs.map +1 -0
  23. package/dist/{chunk-DN4RUDF3.cjs → chunk-LYRUNG6E.cjs} +2 -2
  24. package/dist/chunk-LYRUNG6E.cjs.map +1 -0
  25. package/dist/{chunk-RVT2N4RF.cjs → chunk-NMOE2ZEU.cjs} +46 -46
  26. package/dist/{chunk-RVT2N4RF.cjs.map → chunk-NMOE2ZEU.cjs.map} +1 -1
  27. package/dist/{chunk-TVUARC7S.cjs → chunk-NYQFPGYP.cjs} +52 -24
  28. package/dist/chunk-NYQFPGYP.cjs.map +1 -0
  29. package/dist/chunk-O57GYGYK.js +51 -0
  30. package/dist/chunk-O57GYGYK.js.map +1 -0
  31. package/dist/{chunk-ENXJLDRK.js → chunk-PCHTTG42.js} +2 -2
  32. package/dist/chunk-PCHTTG42.js.map +1 -0
  33. package/dist/{chunk-DDVA4QBA.js → chunk-PGU2XKMA.js} +4 -4
  34. package/dist/{chunk-DDVA4QBA.js.map → chunk-PGU2XKMA.js.map} +1 -1
  35. package/dist/{chunk-RF5EUQWS.js → chunk-TKM2WDT4.js} +51 -23
  36. package/dist/chunk-TKM2WDT4.js.map +1 -0
  37. package/dist/{chunk-ZGEMI7MJ.cjs → chunk-WZH2MKHW.cjs} +15 -15
  38. package/dist/{chunk-ZGEMI7MJ.cjs.map → chunk-WZH2MKHW.cjs.map} +1 -1
  39. package/dist/{ddl-9kw8UADK.d.ts → ddl-0Ooc2dpL.d.ts} +2 -2
  40. package/dist/{ddl-Cw82BPM4.d.cts → ddl-Dza3kDrI.d.cts} +2 -2
  41. package/dist/index.cjs +81 -69
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +7 -7
  44. package/dist/index.d.ts +7 -7
  45. package/dist/index.js +18 -6
  46. package/dist/index.js.map +1 -1
  47. package/dist/indexes/index.d.cts +4 -4
  48. package/dist/indexes/index.d.ts +4 -4
  49. package/dist/interchange/index.d.cts +3 -3
  50. package/dist/interchange/index.d.ts +3 -3
  51. package/dist/{manager-CWa9cgwb.d.cts → manager-c1MGaVVR.d.cts} +1 -1
  52. package/dist/{manager-Cfcb2sJL.d.ts → manager-ehLTTNq0.d.ts} +1 -1
  53. package/dist/profiler/index.d.cts +5 -5
  54. package/dist/profiler/index.d.ts +5 -5
  55. package/dist/schema/index.cjs +26 -26
  56. package/dist/schema/index.d.cts +4 -4
  57. package/dist/schema/index.d.ts +4 -4
  58. package/dist/schema/index.js +3 -3
  59. package/dist/{sqlite-GKvcDPVn.d.ts → sqlite-BxZUPbyD.d.ts} +1 -1
  60. package/dist/{sqlite-BvSEbybu.d.cts → sqlite-mvpXjEeB.d.cts} +1 -1
  61. package/dist/{store-Ojf0NOKk.d.cts → store-D7YEMg2v.d.cts} +26 -2
  62. package/dist/{store-C57kdvAa.d.ts → store-Ufc1Eoey.d.ts} +26 -2
  63. package/dist/{types-Cars4JZ1.d.ts → types-B-sJJ4GQ.d.ts} +1 -1
  64. package/dist/{types-DZPBXZOK.d.cts → types-CMQymcwk.d.cts} +11 -0
  65. package/dist/{types-Dzkr0Eqi.d.ts → types-CQ7xXJMP.d.ts} +11 -0
  66. package/dist/{types-CF7nDH3q.d.cts → types-CmUA9sal.d.cts} +1 -1
  67. package/dist/{where-BmtjfWuS.d.cts → where-5zf15aFZ.d.cts} +1 -1
  68. package/dist/{where-kk1Zz2En.d.ts → where-CtrLu1Zf.d.ts} +1 -1
  69. package/package.json +8 -8
  70. package/dist/chunk-5H3BAMTB.js +0 -32
  71. package/dist/chunk-5H3BAMTB.js.map +0 -1
  72. package/dist/chunk-DN4RUDF3.cjs.map +0 -1
  73. package/dist/chunk-ENXJLDRK.js.map +0 -1
  74. package/dist/chunk-IUIWCFG3.cjs +0 -36
  75. package/dist/chunk-IUIWCFG3.cjs.map +0 -1
  76. package/dist/chunk-RF5EUQWS.js.map +0 -1
  77. package/dist/chunk-TVUARC7S.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { isMissingTableError, sortedReplacer } from './chunk-5H3BAMTB.js';
1
+ import { isMissingTableError, sortedReplacer } from './chunk-O57GYGYK.js';
2
2
  import { buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders, tsvectorStrategy, fts5Strategy, BASE_CONTRIBUTION_OWNER, quotedTableName, quotedColumn, edgeColumnList, sqlNull, nodeColumnList } from './chunk-ZTREJOGB.js';
3
3
  import { MAX_PG_IDENTIFIER_LENGTH, sha256Hex } from './chunk-EJCDOA37.js';
4
4
  import { DatabaseOperationError, ConfigurationError, MigrationError, SchemaContentConflictError, UniquenessError, StoreNotInitializedError, StaleVersionError } from './chunk-U5ROKVRF.js';
@@ -1155,39 +1155,56 @@ function createContributionMaterializer(deps) {
1155
1155
  error: void 0
1156
1156
  });
1157
1157
  }
1158
+ async function readContributionState(graphId, contribution) {
1159
+ const signature = await computeContributionSignature(
1160
+ dialect,
1161
+ contribution,
1162
+ contribution.createDdl
1163
+ );
1164
+ const identity = identityOf(graphId, contribution);
1165
+ try {
1166
+ const existing = await deps.getMarker(identity);
1167
+ return {
1168
+ kind: "state",
1169
+ state: evaluateContributionState(existing, signature)
1170
+ };
1171
+ } catch (error) {
1172
+ if (!isMissingTableError(error)) throw error;
1173
+ return { kind: "missing-table", error };
1174
+ }
1175
+ }
1176
+ async function allContributionsInitialized(graphId, contributions) {
1177
+ for (const contribution of contributions) {
1178
+ const read = await readContributionState(graphId, contribution);
1179
+ if (read.kind !== "state" || read.state !== "initialized") return false;
1180
+ }
1181
+ return true;
1182
+ }
1158
1183
  async function ensureRuntimeContributions(graphId) {
1159
1184
  if (initializedGraphIds.has(graphId)) return;
1160
1185
  const contributions = runtimeContributions();
1161
- if (contributions.length > 0) {
1162
- await deps.ensureMarkerTable();
1163
- for (const contribution of contributions) {
1164
- await materializeOne(graphId, contribution);
1165
- }
1186
+ if (await allContributionsInitialized(graphId, contributions)) {
1187
+ initializedGraphIds.add(graphId);
1188
+ return;
1189
+ }
1190
+ await deps.ensureMarkerTable();
1191
+ for (const contribution of contributions) {
1192
+ await materializeOne(graphId, contribution);
1166
1193
  }
1167
1194
  initializedGraphIds.add(graphId);
1168
1195
  }
1169
1196
  async function assertInitialized(graphId) {
1170
1197
  if (initializedGraphIds.has(graphId)) return;
1171
1198
  for (const contribution of runtimeContributions()) {
1172
- const signature = await computeContributionSignature(
1173
- dialect,
1174
- contribution,
1175
- contribution.createDdl
1176
- );
1177
- const identity = identityOf(graphId, contribution);
1178
- let existing;
1179
- try {
1180
- existing = await deps.getMarker(identity);
1181
- } catch (error) {
1182
- if (!isMissingTableError(error)) throw error;
1199
+ const read = await readContributionState(graphId, contribution);
1200
+ if (read.kind === "missing-table") {
1183
1201
  throw new StoreNotInitializedError(graphId, "missing", {
1184
- cause: error,
1202
+ cause: read.error,
1185
1203
  details: { logicalName: contribution.logicalName }
1186
1204
  });
1187
1205
  }
1188
- const state = evaluateContributionState(existing, signature);
1189
- if (state !== "initialized") {
1190
- throw new StoreNotInitializedError(graphId, state, {
1206
+ if (read.state !== "initialized") {
1207
+ throw new StoreNotInitializedError(graphId, read.state, {
1191
1208
  details: { logicalName: contribution.logicalName }
1192
1209
  });
1193
1210
  }
@@ -2405,6 +2422,7 @@ function buildCheckUniqueBatch(tables3, params) {
2405
2422
  AND ${uniques3.deletedAt} IS NULL
2406
2423
  `;
2407
2424
  }
2425
+ var MAX_HNSW_EF_SEARCH = 1e3;
2408
2426
  function assertFiniteNumberArray(array, name) {
2409
2427
  for (const [index3, value] of array.entries()) {
2410
2428
  if (typeof value !== "number" || !Number.isFinite(value)) {
@@ -2546,11 +2564,21 @@ function assertVectorSearchBounds(params) {
2546
2564
  if (!Number.isInteger(params.limit) || params.limit <= 0) {
2547
2565
  throw new Error(`limit must be a positive integer, got: ${params.limit}`);
2548
2566
  }
2567
+ if (params.efSearch !== void 0 && (!Number.isInteger(params.efSearch) || params.efSearch <= 0)) {
2568
+ throw new Error(
2569
+ `efSearch must be a positive integer, got: ${params.efSearch}`
2570
+ );
2571
+ }
2549
2572
  }
2550
2573
  function buildVectorSearchPostgres(tables3, params) {
2551
2574
  const { embeddings: embeddings3 } = tables3;
2552
2575
  const queryLiteral = formatEmbeddingLiteral(params.queryEmbedding);
2553
2576
  assertVectorSearchBounds(params);
2577
+ if (params.efSearch !== void 0 && params.efSearch > MAX_HNSW_EF_SEARCH) {
2578
+ throw new RangeError(
2579
+ `efSearch must be \u2264 ${MAX_HNSW_EF_SEARCH} (pgvector's hnsw.ef_search valid range is 1..${MAX_HNSW_EF_SEARCH}), got: ${params.efSearch}`
2580
+ );
2581
+ }
2554
2582
  const embeddingColumn = sql`${embeddings3.embedding}`;
2555
2583
  const distanceExpression = buildDistanceExpression(
2556
2584
  embeddingColumn,
@@ -2974,5 +3002,5 @@ function compileQueryWithDialect(db, query, backendName) {
2974
3002
  }
2975
3003
 
2976
3004
  export { POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, POSTGRES_INDEX_MAT_TIMESTAMPS, POSTGRES_KIND_REMOVAL_TIMESTAMPS, POSTGRES_ROW_MAPPER_CONFIG, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, SQLITE_INDEX_MAT_TIMESTAMPS, SQLITE_KIND_REMOVAL_TIMESTAMPS, SQLITE_ROW_MAPPER_CONFIG, assertAdoptedDialect, buildContributionInsertValues, buildContributionOnConflictSet, buildKindRemovalInsertValues, buildKindRemovalOnConflictSet, buildMaterializationInsertValues, buildMaterializationOnConflictSet, coerceNumericScore, compileQueryWithDialect, createCommonOperationBackend, createContributionMaterializer, createEdgeRowMapper, createNodeRowMapper, createPostgresOperationStrategy, createPostgresTables, createPostgresVectorIndex, createSchemaVersionRowMapper, createSqliteOperationStrategy, createSqliteTables, createSqliteVectorIndex, createUniqueRowMapper, dropPostgresVectorIndex, dropSqliteVectorIndex, edges, edges2, embeddings, embeddings2, formatPostgresTimestamp, fulltext, gateFulltext, gateFulltextMethods, generatePgCreateTableSQL, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteCreateTableSQL, generateSqliteDDL, generateSqliteMigrationSQL, generateVectorIndexName, getOrCreateLru, mapContributionMaterializationRow, mapKindRemovalRow, mapMaterializationRow, nodes, nodes2, nowIso, schemaVersions, schemaVersions2, tables, tables2, uniques, uniques2 };
2977
- //# sourceMappingURL=chunk-RF5EUQWS.js.map
2978
- //# sourceMappingURL=chunk-RF5EUQWS.js.map
3005
+ //# sourceMappingURL=chunk-TKM2WDT4.js.map
3006
+ //# sourceMappingURL=chunk-TKM2WDT4.js.map