@nicia-ai/typegraph 0.35.0 → 0.36.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 (116) hide show
  1. package/dist/backend/postgres/index.cjs +19 -19
  2. package/dist/backend/postgres/index.js +6 -6
  3. package/dist/backend/postgres/pglite.cjs +11 -11
  4. package/dist/backend/postgres/pglite.js +6 -6
  5. package/dist/backend/sqlite/index.cjs +9 -9
  6. package/dist/backend/sqlite/index.js +6 -6
  7. package/dist/backend/sqlite/libsql.cjs +8 -8
  8. package/dist/backend/sqlite/libsql.js +6 -6
  9. package/dist/backend/sqlite/local.cjs +16 -16
  10. package/dist/backend/sqlite/local.js +6 -6
  11. package/dist/{chunk-VPYHY3LJ.cjs → chunk-2THZ3TQI.cjs} +11 -11
  12. package/dist/{chunk-VPYHY3LJ.cjs.map → chunk-2THZ3TQI.cjs.map} +1 -1
  13. package/dist/{chunk-EM3CWPND.cjs → chunk-456Z2U7Y.cjs} +51 -51
  14. package/dist/{chunk-EM3CWPND.cjs.map → chunk-456Z2U7Y.cjs.map} +1 -1
  15. package/dist/{chunk-GSQ6NPH6.cjs → chunk-4BCU6VFZ.cjs} +7 -7
  16. package/dist/{chunk-GSQ6NPH6.cjs.map → chunk-4BCU6VFZ.cjs.map} +1 -1
  17. package/dist/chunk-4BMPGT35.cjs +12 -0
  18. package/dist/{chunk-GUR2FNB5.cjs.map → chunk-4BMPGT35.cjs.map} +1 -1
  19. package/dist/{chunk-WJT7OU7E.cjs → chunk-4CAXEB2F.cjs} +124 -92
  20. package/dist/chunk-4CAXEB2F.cjs.map +1 -0
  21. package/dist/{chunk-WDBCBWC4.js → chunk-4GX2JJXS.js} +6 -6
  22. package/dist/{chunk-WDBCBWC4.js.map → chunk-4GX2JJXS.js.map} +1 -1
  23. package/dist/{chunk-UES55P7G.js → chunk-5DIPR3L3.js} +284 -154
  24. package/dist/chunk-5DIPR3L3.js.map +1 -0
  25. package/dist/{chunk-CZQ3FO2Q.js → chunk-5VTR2F2K.js} +49 -16
  26. package/dist/chunk-5VTR2F2K.js.map +1 -0
  27. package/dist/{chunk-CTTSDJLY.cjs → chunk-5W4L6DLF.cjs} +11 -11
  28. package/dist/{chunk-CTTSDJLY.cjs.map → chunk-5W4L6DLF.cjs.map} +1 -1
  29. package/dist/{chunk-J7WFGBJR.cjs → chunk-7BQLPXK6.cjs} +865 -735
  30. package/dist/chunk-7BQLPXK6.cjs.map +1 -0
  31. package/dist/{chunk-3TWF3SH4.js → chunk-BJVEU3ZL.js} +7 -7
  32. package/dist/{chunk-3TWF3SH4.js.map → chunk-BJVEU3ZL.js.map} +1 -1
  33. package/dist/{chunk-LGEALRC6.cjs → chunk-DIK74MXX.cjs} +18 -2
  34. package/dist/chunk-DIK74MXX.cjs.map +1 -0
  35. package/dist/{chunk-QNKSQTKQ.js → chunk-DN5VP4JC.js} +48 -17
  36. package/dist/chunk-DN5VP4JC.js.map +1 -0
  37. package/dist/{chunk-4JEZZJ6S.cjs → chunk-HW3LW7DH.cjs} +39 -39
  38. package/dist/{chunk-4JEZZJ6S.cjs.map → chunk-HW3LW7DH.cjs.map} +1 -1
  39. package/dist/{chunk-JBTOYDMN.js → chunk-IU46OHVW.js} +4 -4
  40. package/dist/{chunk-JBTOYDMN.js.map → chunk-IU46OHVW.js.map} +1 -1
  41. package/dist/{chunk-FL472AMI.cjs → chunk-J3LEGNQB.cjs} +8 -8
  42. package/dist/{chunk-FL472AMI.cjs.map → chunk-J3LEGNQB.cjs.map} +1 -1
  43. package/dist/{chunk-O7UN7OXA.cjs → chunk-JFMEONLG.cjs} +80 -80
  44. package/dist/{chunk-O7UN7OXA.cjs.map → chunk-JFMEONLG.cjs.map} +1 -1
  45. package/dist/{chunk-I7ZUZKFD.js → chunk-JFUPDJXD.js} +3 -3
  46. package/dist/{chunk-I7ZUZKFD.js.map → chunk-JFUPDJXD.js.map} +1 -1
  47. package/dist/{chunk-K3PPLHY7.js → chunk-M75SUBFG.js} +7 -7
  48. package/dist/{chunk-K3PPLHY7.js.map → chunk-M75SUBFG.js.map} +1 -1
  49. package/dist/{chunk-CK5BVQOW.cjs → chunk-PWGX5DF5.cjs} +79 -79
  50. package/dist/{chunk-CK5BVQOW.cjs.map → chunk-PWGX5DF5.cjs.map} +1 -1
  51. package/dist/{chunk-KMI7LYAF.js → chunk-PZKNKG5M.js} +8 -8
  52. package/dist/{chunk-KMI7LYAF.js.map → chunk-PZKNKG5M.js.map} +1 -1
  53. package/dist/{chunk-55MZDDZV.js → chunk-RAXU3RMB.js} +4 -4
  54. package/dist/{chunk-55MZDDZV.js.map → chunk-RAXU3RMB.js.map} +1 -1
  55. package/dist/{chunk-BLZDPRXT.cjs → chunk-RSSQKPSZ.cjs} +5 -5
  56. package/dist/{chunk-BLZDPRXT.cjs.map → chunk-RSSQKPSZ.cjs.map} +1 -1
  57. package/dist/{chunk-RGPG7EOJ.js → chunk-S5F7ZLP2.js} +3 -3
  58. package/dist/{chunk-RGPG7EOJ.js.map → chunk-S5F7ZLP2.js.map} +1 -1
  59. package/dist/{chunk-QWEUYILR.js → chunk-SKCOUWAX.js} +3 -3
  60. package/dist/{chunk-QWEUYILR.js.map → chunk-SKCOUWAX.js.map} +1 -1
  61. package/dist/{chunk-QOTI55H7.js → chunk-SXGE7ITL.js} +4 -4
  62. package/dist/{chunk-QOTI55H7.js.map → chunk-SXGE7ITL.js.map} +1 -1
  63. package/dist/{chunk-RGP33ZJ5.js → chunk-VQEXF5D4.js} +7 -7
  64. package/dist/{chunk-RGP33ZJ5.js.map → chunk-VQEXF5D4.js.map} +1 -1
  65. package/dist/{chunk-MP2JQKSG.js → chunk-WI7ISNQF.js} +17 -3
  66. package/dist/chunk-WI7ISNQF.js.map +1 -0
  67. package/dist/{chunk-4TOD4LBZ.cjs → chunk-X4JBT642.cjs} +29 -29
  68. package/dist/{chunk-4TOD4LBZ.cjs.map → chunk-X4JBT642.cjs.map} +1 -1
  69. package/dist/{chunk-EMF62TZG.cjs → chunk-ZAMFOJ5P.cjs} +86 -86
  70. package/dist/{chunk-EMF62TZG.cjs.map → chunk-ZAMFOJ5P.cjs.map} +1 -1
  71. package/dist/{chunk-VSPCZAXF.js → chunk-ZIGXMKQQ.js} +3 -3
  72. package/dist/{chunk-VSPCZAXF.js.map → chunk-ZIGXMKQQ.js.map} +1 -1
  73. package/dist/{chunk-XOX22WHL.cjs → chunk-ZUNQ5BEP.cjs} +104 -71
  74. package/dist/chunk-ZUNQ5BEP.cjs.map +1 -0
  75. package/dist/graph-extension/index.cjs +19 -19
  76. package/dist/graph-extension/index.d.cts +1 -1
  77. package/dist/graph-extension/index.d.ts +1 -1
  78. package/dist/graph-extension/index.js +4 -4
  79. package/dist/graph-merge/index.cjs +82 -82
  80. package/dist/graph-merge/index.cjs.map +1 -1
  81. package/dist/graph-merge/index.d.cts +2 -2
  82. package/dist/graph-merge/index.d.ts +2 -2
  83. package/dist/graph-merge/index.js +13 -13
  84. package/dist/graph-merge/index.js.map +1 -1
  85. package/dist/{index-6CSUAq-x.d.ts → index-BFvdmBPV.d.ts} +68 -1
  86. package/dist/{index-Bks_3HHK.d.cts → index-BLtQWKRj.d.cts} +68 -1
  87. package/dist/index.cjs +144 -136
  88. package/dist/index.d.cts +3 -3
  89. package/dist/index.d.ts +3 -3
  90. package/dist/index.js +14 -14
  91. package/dist/interchange/index.cjs +27 -26
  92. package/dist/interchange/index.d.cts +1 -1
  93. package/dist/interchange/index.d.ts +1 -1
  94. package/dist/interchange/index.js +9 -8
  95. package/dist/profiler/index.d.cts +1 -1
  96. package/dist/profiler/index.d.ts +1 -1
  97. package/dist/provenance/index.cjs +31 -31
  98. package/dist/provenance/index.d.cts +1 -1
  99. package/dist/provenance/index.d.ts +1 -1
  100. package/dist/provenance/index.js +4 -4
  101. package/dist/schema/index.cjs +31 -31
  102. package/dist/schema/index.d.cts +1 -1
  103. package/dist/schema/index.d.ts +1 -1
  104. package/dist/schema/index.js +7 -7
  105. package/dist/{store-view-BSpqvAxK.d.cts → store-view-9KDOpZzF.d.cts} +250 -36
  106. package/dist/{store-view-CKbHFRnn.d.ts → store-view-DplHC3Nt.d.ts} +250 -36
  107. package/package.json +1 -1
  108. package/dist/chunk-CZQ3FO2Q.js.map +0 -1
  109. package/dist/chunk-GUR2FNB5.cjs +0 -12
  110. package/dist/chunk-J7WFGBJR.cjs.map +0 -1
  111. package/dist/chunk-LGEALRC6.cjs.map +0 -1
  112. package/dist/chunk-MP2JQKSG.js.map +0 -1
  113. package/dist/chunk-QNKSQTKQ.js.map +0 -1
  114. package/dist/chunk-UES55P7G.js.map +0 -1
  115. package/dist/chunk-WJT7OU7E.cjs.map +0 -1
  116. package/dist/chunk-XOX22WHL.cjs.map +0 -1
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkVPYHY3LJ_cjs = require('./chunk-VPYHY3LJ.cjs');
3
+ var chunk2THZ3TQI_cjs = require('./chunk-2THZ3TQI.cjs');
4
+ var chunkACSVZPK7_cjs = require('./chunk-ACSVZPK7.cjs');
4
5
  var chunkD7ZEOS56_cjs = require('./chunk-D7ZEOS56.cjs');
5
- var chunkGSQ6NPH6_cjs = require('./chunk-GSQ6NPH6.cjs');
6
- var chunkXOX22WHL_cjs = require('./chunk-XOX22WHL.cjs');
6
+ var chunk4BCU6VFZ_cjs = require('./chunk-4BCU6VFZ.cjs');
7
+ var chunkZUNQ5BEP_cjs = require('./chunk-ZUNQ5BEP.cjs');
7
8
  var chunkEOLERH7Y_cjs = require('./chunk-EOLERH7Y.cjs');
8
- var chunk4TOD4LBZ_cjs = require('./chunk-4TOD4LBZ.cjs');
9
- var chunkBLZDPRXT_cjs = require('./chunk-BLZDPRXT.cjs');
10
- var chunkLGEALRC6_cjs = require('./chunk-LGEALRC6.cjs');
9
+ var chunkX4JBT642_cjs = require('./chunk-X4JBT642.cjs');
10
+ var chunkRSSQKPSZ_cjs = require('./chunk-RSSQKPSZ.cjs');
11
+ var chunkDIK74MXX_cjs = require('./chunk-DIK74MXX.cjs');
11
12
  var chunkTDXIBCGY_cjs = require('./chunk-TDXIBCGY.cjs');
12
13
  var drizzleOrm = require('drizzle-orm');
13
14
 
@@ -16,8 +17,8 @@ function nullToUndefined(value) {
16
17
  return value === null ? void 0 : value;
17
18
  }
18
19
  function rowToNode(row) {
19
- const rawProps = chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
20
- const props = chunkGSQ6NPH6_cjs.filterReservedKeys(rawProps, chunkGSQ6NPH6_cjs.RESERVED_NODE_KEYS);
20
+ const rawProps = chunkX4JBT642_cjs.rowPropsToObject(row.props);
21
+ const props = chunk4BCU6VFZ_cjs.filterReservedKeys(rawProps, chunk4BCU6VFZ_cjs.RESERVED_NODE_KEYS);
21
22
  return {
22
23
  kind: row.kind,
23
24
  id: row.id,
@@ -36,8 +37,8 @@ function rowToNodeMeta(row) {
36
37
  };
37
38
  }
38
39
  function rowToEdge(row) {
39
- const rawProps = chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
40
- const props = chunkGSQ6NPH6_cjs.filterReservedKeys(rawProps, chunkGSQ6NPH6_cjs.RESERVED_EDGE_KEYS);
40
+ const rawProps = chunkX4JBT642_cjs.rowPropsToObject(row.props);
41
+ const props = chunk4BCU6VFZ_cjs.filterReservedKeys(rawProps, chunk4BCU6VFZ_cjs.RESERVED_EDGE_KEYS);
41
42
  return {
42
43
  id: row.id,
43
44
  kind: row.kind,
@@ -62,11 +63,11 @@ function rowToEdgeMeta(row) {
62
63
  // src/store/operations/write-transaction.ts
63
64
  function runInWriteTransaction(ctx, backend, fn) {
64
65
  const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
65
- return chunk4TOD4LBZ_cjs.runOptionallyInTransaction(backend, async (target) => {
66
- const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await chunkXOX22WHL_cjs.lockRecordedGraphWrite(target, ctx.graphId) : chunkXOX22WHL_cjs.uncapturedGraphWriteLock();
66
+ return chunkX4JBT642_cjs.runOptionallyInTransaction(backend, async (target) => {
67
+ const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await chunkZUNQ5BEP_cjs.lockRecordedGraphWrite(target, ctx.graphId) : chunkZUNQ5BEP_cjs.uncapturedGraphWriteLock();
67
68
  const result = await fn(target, lock);
68
69
  if (ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
69
- await chunkXOX22WHL_cjs.advanceRevisionClock(
70
+ await chunkZUNQ5BEP_cjs.advanceRevisionClock(
70
71
  target,
71
72
  ctx.revisionSchema,
72
73
  ctx.graphId,
@@ -89,7 +90,7 @@ async function checkDisjointnessConstraint(ctx, kind, id) {
89
90
  for (const disjointKind of disjointKinds) {
90
91
  const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);
91
92
  if (existing && !existing.deleted_at) {
92
- const error = chunkXOX22WHL_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
93
+ const error = chunkZUNQ5BEP_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
93
94
  if (error) throw error;
94
95
  }
95
96
  }
@@ -106,7 +107,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
106
107
  fromKind,
107
108
  fromId
108
109
  });
109
- const error = chunkXOX22WHL_cjs.checkCardinality(
110
+ const error = chunkZUNQ5BEP_cjs.checkCardinality(
110
111
  edgeKind,
111
112
  fromKind,
112
113
  fromId,
@@ -126,7 +127,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
126
127
  toKind,
127
128
  toId
128
129
  });
129
- const error = chunkXOX22WHL_cjs.checkUniqueEdge(
130
+ const error = chunkZUNQ5BEP_cjs.checkUniqueEdge(
130
131
  edgeKind,
131
132
  fromKind,
132
133
  fromId,
@@ -148,7 +149,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
148
149
  fromId,
149
150
  activeOnly: true
150
151
  });
151
- const error = chunkXOX22WHL_cjs.checkCardinality(
152
+ const error = chunkZUNQ5BEP_cjs.checkCardinality(
152
153
  edgeKind,
153
154
  fromKind,
154
155
  fromId,
@@ -165,7 +166,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
165
166
  // src/store/operations/node-operations.ts
166
167
  function getNodeRegistration(graph, kind) {
167
168
  const registration = graph.nodes[kind];
168
- if (registration === void 0) throw new chunkLGEALRC6_cjs.KindNotFoundError(kind, "node");
169
+ if (registration === void 0) throw new chunkDIK74MXX_cjs.KindNotFoundError(kind, "node");
169
170
  return registration;
170
171
  }
171
172
  var CACHE_KEY_SEPARATOR = "\0";
@@ -176,7 +177,7 @@ function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
176
177
  return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
177
178
  }
178
179
  function createNodeAlreadyExistsError(kind, id) {
179
- return new chunkLGEALRC6_cjs.ValidationError(
180
+ return new chunkDIK74MXX_cjs.ValidationError(
180
181
  `Node already exists: ${kind}/${id}`,
181
182
  {
182
183
  entityType: "node",
@@ -217,7 +218,7 @@ function resolveConstraint(graph, kind, constraintName) {
217
218
  (candidate) => candidate.name === constraintName
218
219
  );
219
220
  if (constraint === void 0) {
220
- throw new chunkLGEALRC6_cjs.NodeConstraintNotFoundError(constraintName, kind);
221
+ throw new chunkDIK74MXX_cjs.NodeConstraintNotFoundError(constraintName, kind);
221
222
  }
222
223
  return constraint;
223
224
  }
@@ -278,8 +279,8 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
278
279
  }
279
280
  function registerPendingUniqueEntries(kind, id, props, constraints) {
280
281
  for (const constraint of constraints) {
281
- if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, props)) continue;
282
- const key = chunkXOX22WHL_cjs.computeUniqueKey(
282
+ if (!chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, props)) continue;
283
+ const key = chunkZUNQ5BEP_cjs.computeUniqueKey(
283
284
  props,
284
285
  constraint.fields,
285
286
  constraint.collation
@@ -292,7 +293,7 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
292
293
  );
293
294
  pendingUniqueOwners.set(concreteEntryKey, id);
294
295
  if (constraint.scope !== "kind") {
295
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
296
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
296
297
  kind,
297
298
  constraint.scope,
298
299
  registry
@@ -311,12 +312,12 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
311
312
  }
312
313
  function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
313
314
  for (const constraint of constraints) {
314
- const oldApplies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, oldProps);
315
- const newApplies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, newProps);
316
- const oldKey = oldApplies ? chunkXOX22WHL_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
317
- const newKey = newApplies ? chunkXOX22WHL_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
315
+ const oldApplies = chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, oldProps);
316
+ const newApplies = chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, newProps);
317
+ const oldKey = oldApplies ? chunkZUNQ5BEP_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
318
+ const newKey = newApplies ? chunkZUNQ5BEP_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
318
319
  if (oldKey === newKey) continue;
319
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
320
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
320
321
  kind,
321
322
  constraint.scope,
322
323
  registry
@@ -356,7 +357,7 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
356
357
  if (uniqueCache.has(cacheKey)) return;
357
358
  uniqueCache.set(cacheKey, row);
358
359
  }
359
- const validationBackend = chunk4TOD4LBZ_cjs.createBackendOverlay(backend, {
360
+ const validationBackend = chunkX4JBT642_cjs.createBackendOverlay(backend, {
360
361
  getNode: getNodeCached,
361
362
  checkUnique: checkUniqueCached
362
363
  });
@@ -373,7 +374,7 @@ function draftNodeCreate(ctx, input, id, options) {
373
374
  const kind = input.kind;
374
375
  const registration = getNodeRegistration(ctx.graph, kind);
375
376
  const nodeKind = registration.type;
376
- const validatedProps = options?.propsPreValidated === true ? input.props : chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, input.props, {
377
+ const validatedProps = options?.propsPreValidated === true ? input.props : chunk2THZ3TQI_cjs.validateNodeProps(nodeKind.schema, input.props, {
377
378
  kind,
378
379
  operation: "create"
379
380
  });
@@ -383,8 +384,8 @@ function draftNodeCreate(ctx, input, id, options) {
383
384
  nodeKind,
384
385
  uniqueConstraints: registration.unique ?? [],
385
386
  validatedProps,
386
- validFrom: chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
387
- validTo: chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo")
387
+ validFrom: chunkRSSQKPSZ_cjs.validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
388
+ validTo: chunkRSSQKPSZ_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo")
388
389
  };
389
390
  }
390
391
  async function finishNodeCreatePreparation(ctx, draft, backend) {
@@ -399,8 +400,8 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
399
400
  backend
400
401
  };
401
402
  await checkDisjointnessConstraint(constraintContext, kind, id);
402
- await chunkXOX22WHL_cjs.checkUniquenessConstraints(
403
- chunkXOX22WHL_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
403
+ await chunkZUNQ5BEP_cjs.checkUniquenessConstraints(
404
+ chunkZUNQ5BEP_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
404
405
  kind,
405
406
  id,
406
407
  validatedProps,
@@ -430,8 +431,8 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
430
431
  );
431
432
  }
432
433
  async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
433
- await chunkXOX22WHL_cjs.applyNodeInsertSideEffectsBatch(
434
- chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
434
+ await chunkZUNQ5BEP_cjs.applyNodeInsertSideEffectsBatch(
435
+ chunkZUNQ5BEP_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
435
436
  preparedCreates.map((prepared) => ({
436
437
  kind: prepared.kind,
437
438
  id: prepared.id,
@@ -443,8 +444,8 @@ async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
443
444
  );
444
445
  }
445
446
  async function finalizeNodeCreate(ctx, prepared, backend, lock) {
446
- await chunkXOX22WHL_cjs.applyNodeInsertSideEffects(
447
- chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
447
+ await chunkZUNQ5BEP_cjs.applyNodeInsertSideEffects(
448
+ chunkZUNQ5BEP_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
448
449
  {
449
450
  kind: prepared.kind,
450
451
  id: prepared.id,
@@ -455,21 +456,51 @@ async function finalizeNodeCreate(ctx, prepared, backend, lock) {
455
456
  backend
456
457
  );
457
458
  }
459
+ function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
460
+ const registration = getNodeRegistration(ctx.graph, kind);
461
+ const validatedProps = chunk2THZ3TQI_cjs.validateNodeProps(
462
+ registration.type.schema,
463
+ { ...existingProps, ...inputProps },
464
+ { kind, operation: "update", id }
465
+ );
466
+ return { registration, validatedProps };
467
+ }
468
+ function resolveNodeUpdateProps(ctx, existing, inputProps) {
469
+ const existingProps = chunkX4JBT642_cjs.rowPropsToObject(existing.props);
470
+ const { registration, validatedProps } = computeNodeUpdate(
471
+ ctx,
472
+ existing.kind,
473
+ existing.id,
474
+ existingProps,
475
+ inputProps
476
+ );
477
+ return { registration, existingProps, validatedProps };
478
+ }
479
+ function nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
480
+ const { validatedProps } = computeNodeUpdate(
481
+ ctx,
482
+ kind,
483
+ id,
484
+ existingProps,
485
+ inputProps
486
+ );
487
+ return {
488
+ validatedProps,
489
+ unchanged: chunkACSVZPK7_cjs.canonicalEqual(validatedProps, existingProps)
490
+ };
491
+ }
458
492
  async function performNodeUpdate(ctx, input, backend, lock, options) {
459
493
  const { kind, id } = input;
460
- const registration = getNodeRegistration(ctx.graph, kind);
461
494
  const existing = await backend.getNode(ctx.graphId, kind, id);
462
- if (!existing) throw new chunkLGEALRC6_cjs.NodeNotFoundError(kind, id);
463
- const existingProps = chunk4TOD4LBZ_cjs.rowPropsToObject(existing.props);
464
- const mergedProps = { ...existingProps, ...input.props };
495
+ if (!existing) throw new chunkDIK74MXX_cjs.NodeNotFoundError(kind, id);
496
+ const { registration, validatedProps } = resolveNodeUpdateProps(
497
+ ctx,
498
+ existing,
499
+ input.props
500
+ );
465
501
  const nodeKind = registration.type;
466
- const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
467
- kind,
468
- operation: "update",
469
- id
470
- });
471
- const validTo = chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
472
- const writeContext = chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
502
+ const validTo = chunkRSSQKPSZ_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
503
+ const writeContext = chunkZUNQ5BEP_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
473
504
  const shared = {
474
505
  schema: nodeKind.schema,
475
506
  validatedProps,
@@ -477,15 +508,15 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
477
508
  ...validTo !== void 0 && { validTo }
478
509
  };
479
510
  if (options?.clearDeleted) {
480
- const row2 = await chunkXOX22WHL_cjs.applyNodeUpdate(
511
+ const row2 = await chunkZUNQ5BEP_cjs.applyNodeUpdate(
481
512
  writeContext,
482
513
  { ...shared, existing, clearDeleted: true },
483
514
  backend
484
515
  );
485
516
  return rowToNode(row2);
486
517
  }
487
- if (!chunk4TOD4LBZ_cjs.isLiveNodeRow(existing)) throw new chunkLGEALRC6_cjs.NodeNotFoundError(kind, id);
488
- const row = await chunkXOX22WHL_cjs.applyNodeUpdate(
518
+ if (!chunkX4JBT642_cjs.isLiveNodeRow(existing)) throw new chunkDIK74MXX_cjs.NodeNotFoundError(kind, id);
519
+ const row = await chunkZUNQ5BEP_cjs.applyNodeUpdate(
489
520
  writeContext,
490
521
  { ...shared, existing },
491
522
  backend
@@ -513,13 +544,13 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
513
544
  const groups = /* @__PURE__ */ new Map();
514
545
  for (const draft of drafts) {
515
546
  for (const constraint of draft.uniqueConstraints) {
516
- if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
517
- const key = chunkXOX22WHL_cjs.computeUniqueKey(
547
+ if (!chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
548
+ const key = chunkZUNQ5BEP_cjs.computeUniqueKey(
518
549
  draft.validatedProps,
519
550
  constraint.fields,
520
551
  constraint.collation
521
552
  );
522
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
553
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
523
554
  draft.kind,
524
555
  constraint.scope,
525
556
  ctx.registry
@@ -565,7 +596,7 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
565
596
  seedUniqueRow
566
597
  } = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
567
598
  const drafts = inputs.map(
568
- (input) => draftNodeCreate(ctx, input, input.id ?? chunkXOX22WHL_cjs.generateId(), options)
599
+ (input) => draftNodeCreate(ctx, input, input.id ?? chunkZUNQ5BEP_cjs.generateId(), options)
569
600
  );
570
601
  await primeBatchValidationCaches(ctx, drafts, backend, {
571
602
  seedNodeRow,
@@ -641,7 +672,7 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
641
672
  }
642
673
  async function executeNodeCreateInternal(ctx, input, backend, options) {
643
674
  const kind = input.kind;
644
- const id = input.id ?? chunkXOX22WHL_cjs.generateId();
675
+ const id = input.id ?? chunkZUNQ5BEP_cjs.generateId();
645
676
  const opContext = ctx.createOperationContext("create", "node", kind, id);
646
677
  const shouldReturnRow = options?.returnRow ?? true;
647
678
  return runHookedWriteOperation(
@@ -660,8 +691,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
660
691
  if (shouldReturnRow) {
661
692
  row = await target.insertNode(prepared.insertParams);
662
693
  } else {
663
- await chunkXOX22WHL_cjs.runInsertNoReturn(
664
- chunkXOX22WHL_cjs.nodeInsertDispatch(target),
694
+ await chunkZUNQ5BEP_cjs.runInsertNoReturn(
695
+ chunkZUNQ5BEP_cjs.nodeInsertDispatch(target),
665
696
  prepared.insertParams
666
697
  );
667
698
  }
@@ -677,7 +708,7 @@ async function executeNodeCreate(ctx, input, backend, options) {
677
708
  ...options
678
709
  });
679
710
  if (!result) {
680
- throw new chunkLGEALRC6_cjs.DatabaseOperationError(
711
+ throw new chunkDIK74MXX_cjs.DatabaseOperationError(
681
712
  "Node create failed: expected created node row",
682
713
  { operation: "insert", entity: "node" }
683
714
  );
@@ -692,7 +723,7 @@ async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
692
723
  inputs,
693
724
  target
694
725
  );
695
- await chunkXOX22WHL_cjs.runInsertBatch(chunkXOX22WHL_cjs.nodeInsertDispatch(target), batchInsertParams);
726
+ await chunkZUNQ5BEP_cjs.runInsertBatch(chunkZUNQ5BEP_cjs.nodeInsertDispatch(target), batchInsertParams);
696
727
  await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
697
728
  });
698
729
  }
@@ -705,8 +736,8 @@ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
705
736
  target,
706
737
  options
707
738
  );
708
- const rows = await chunkXOX22WHL_cjs.runInsertBatchReturning(
709
- chunkXOX22WHL_cjs.nodeInsertDispatch(target),
739
+ const rows = await chunkZUNQ5BEP_cjs.runInsertBatchReturning(
740
+ chunkZUNQ5BEP_cjs.nodeInsertDispatch(target),
710
741
  batchInsertParams
711
742
  );
712
743
  await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
@@ -745,9 +776,9 @@ async function executeNodeDelete(ctx, kind, id, backend) {
745
776
  async (target, lock) => {
746
777
  const registration = getNodeRegistration(ctx.graph, kind);
747
778
  const preflight = await target.getNode(ctx.graphId, kind, id);
748
- if (!preflight || !chunk4TOD4LBZ_cjs.isLiveNodeRow(preflight)) return;
749
- await chunkXOX22WHL_cjs.applyNodeSoftDelete(
750
- chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
779
+ if (!preflight || !chunkX4JBT642_cjs.isLiveNodeRow(preflight)) return;
780
+ await chunkZUNQ5BEP_cjs.applyNodeSoftDelete(
781
+ chunkZUNQ5BEP_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
751
782
  {
752
783
  existing: preflight,
753
784
  schema: registration.type.schema,
@@ -769,8 +800,8 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
769
800
  backend,
770
801
  async (target, lock) => {
771
802
  const registration = getNodeRegistration(ctx.graph, kind);
772
- await chunkXOX22WHL_cjs.applyNodeHardDelete(
773
- chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
803
+ await chunkZUNQ5BEP_cjs.applyNodeHardDelete(
804
+ chunkZUNQ5BEP_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
774
805
  {
775
806
  kind,
776
807
  id,
@@ -786,12 +817,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
786
817
  const ifExists = options?.ifExists ?? "return";
787
818
  const registration = getNodeRegistration(ctx.graph, kind);
788
819
  const nodeKind = registration.type;
789
- const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, props, {
820
+ const validatedProps = chunk2THZ3TQI_cjs.validateNodeProps(nodeKind.schema, props, {
790
821
  kind,
791
822
  operation: "create"
792
823
  });
793
824
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
794
- if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps)) {
825
+ if (!chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, validatedProps)) {
795
826
  const node = await executeNodeCreate(
796
827
  ctx,
797
828
  { kind, props: validatedProps },
@@ -800,12 +831,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
800
831
  );
801
832
  return { node, action: "created" };
802
833
  }
803
- const key = chunkXOX22WHL_cjs.computeUniqueKey(
834
+ const key = chunkZUNQ5BEP_cjs.computeUniqueKey(
804
835
  validatedProps,
805
836
  constraint.fields,
806
837
  constraint.collation
807
838
  );
808
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
839
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
809
840
  kind,
810
841
  constraint.scope,
811
842
  ctx.registry
@@ -862,25 +893,25 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
862
893
  try {
863
894
  return await attempt();
864
895
  } catch (error) {
865
- if (!(error instanceof chunkLGEALRC6_cjs.UniquenessError)) throw error;
896
+ if (!(error instanceof chunkDIK74MXX_cjs.UniquenessError)) throw error;
866
897
  return attempt();
867
898
  }
868
899
  }
869
900
  async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
870
901
  const registration = getNodeRegistration(ctx.graph, kind);
871
902
  const nodeKind = registration.type;
872
- const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, props, {
903
+ const validatedProps = chunk2THZ3TQI_cjs.validateNodeProps(nodeKind.schema, props, {
873
904
  kind,
874
905
  operation: "create"
875
906
  });
876
907
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
877
- if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
878
- const key = chunkXOX22WHL_cjs.computeUniqueKey(
908
+ if (!chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
909
+ const key = chunkZUNQ5BEP_cjs.computeUniqueKey(
879
910
  validatedProps,
880
911
  constraint.fields,
881
912
  constraint.collation
882
913
  );
883
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
914
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
884
915
  kind,
885
916
  constraint.scope,
886
917
  ctx.registry
@@ -906,12 +937,12 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
906
937
  function validateAndComputeKeys(nodeKind, kind, constraint, items) {
907
938
  const validated = [];
908
939
  for (const item of items) {
909
- const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, item.props, {
940
+ const validatedProps = chunk2THZ3TQI_cjs.validateNodeProps(nodeKind.schema, item.props, {
910
941
  kind,
911
942
  operation: "create"
912
943
  });
913
- const applies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps);
914
- const key = applies ? chunkXOX22WHL_cjs.computeUniqueKey(
944
+ const applies = chunkZUNQ5BEP_cjs.checkWherePredicate(constraint, validatedProps);
945
+ const key = applies ? chunkZUNQ5BEP_cjs.computeUniqueKey(
915
946
  validatedProps,
916
947
  constraint.fields,
917
948
  constraint.collation
@@ -934,7 +965,7 @@ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items,
934
965
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
935
966
  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
936
967
  const uniqueKeys = collectUniqueKeys(validated);
937
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
968
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
938
969
  kind,
939
970
  constraint.scope,
940
971
  ctx.registry
@@ -984,10 +1015,10 @@ function resolveNodeIndex(graph, kind, indexName) {
984
1015
  (candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
985
1016
  );
986
1017
  if (declaration?.entity !== "node") {
987
- throw new chunkLGEALRC6_cjs.NodeIndexNotFoundError(indexName, kind);
1018
+ throw new chunkDIK74MXX_cjs.NodeIndexNotFoundError(indexName, kind);
988
1019
  }
989
1020
  if (declaration.method !== void 0) {
990
- throw new chunkLGEALRC6_cjs.ConfigurationError(
1021
+ throw new chunkDIK74MXX_cjs.ConfigurationError(
991
1022
  `bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
992
1023
  { indexName, kind, method: declaration.method }
993
1024
  );
@@ -1025,7 +1056,7 @@ function validateIndexProbeValue(value, valueType, pointer, kind) {
1025
1056
  }
1026
1057
  }
1027
1058
  function indexProbeTypeError(pointer, kind, expected, value) {
1028
- return new chunkLGEALRC6_cjs.ValidationError(
1059
+ return new chunkDIK74MXX_cjs.ValidationError(
1029
1060
  `Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
1030
1061
  {
1031
1062
  entityType: "node",
@@ -1059,7 +1090,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1059
1090
  if (items.length === 0) return [];
1060
1091
  const index = resolveNodeIndex(ctx.graph, kind, indexName);
1061
1092
  if (index.fields.length === 0) {
1062
- throw new chunkLGEALRC6_cjs.ConfigurationError(
1093
+ throw new chunkDIK74MXX_cjs.ConfigurationError(
1063
1094
  `bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
1064
1095
  { indexName, kind },
1065
1096
  {
@@ -1068,7 +1099,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1068
1099
  );
1069
1100
  }
1070
1101
  if (index.fieldValueTypes.includes("date")) {
1071
- throw new chunkLGEALRC6_cjs.ConfigurationError(
1102
+ throw new chunkDIK74MXX_cjs.ConfigurationError(
1072
1103
  `bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
1073
1104
  { indexName, kind },
1074
1105
  {
@@ -1078,7 +1109,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1078
1109
  }
1079
1110
  const limitPerInput = options?.limitPerInput;
1080
1111
  if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
1081
- throw new chunkLGEALRC6_cjs.ValidationError(
1112
+ throw new chunkDIK74MXX_cjs.ValidationError(
1082
1113
  "bulkFindByIndex limitPerInput must be a positive integer",
1083
1114
  {
1084
1115
  entityType: "node",
@@ -1120,7 +1151,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1120
1151
  }
1121
1152
  groupToInputs[existing]?.push(inputIndex);
1122
1153
  }
1123
- const schema = backend.tableNames ? chunkXOX22WHL_cjs.createSqlSchema(backend.tableNames) : chunkXOX22WHL_cjs.DEFAULT_SQL_SCHEMA;
1154
+ const schema = backend.tableNames ? chunkZUNQ5BEP_cjs.createSqlSchema(backend.tableNames) : chunkZUNQ5BEP_cjs.DEFAULT_SQL_SCHEMA;
1124
1155
  const compileContext = {
1125
1156
  dialect: backend.dialect,
1126
1157
  propsColumn: drizzleOrm.sql.raw(`"props"`),
@@ -1193,7 +1224,7 @@ function capMatchesPerGroup(matches, limitPerInput) {
1193
1224
  return capped;
1194
1225
  }
1195
1226
  async function hydrateNodesById(backend, graphId, kind, ids) {
1196
- const rowsById = await chunkXOX22WHL_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
1227
+ const rowsById = await chunkZUNQ5BEP_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
1197
1228
  const nodesById = /* @__PURE__ */ new Map();
1198
1229
  for (const [id, row] of rowsById) {
1199
1230
  if (row.deleted_at !== void 0) continue;
@@ -1209,7 +1240,7 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1209
1240
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1210
1241
  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
1211
1242
  const uniqueKeys = collectUniqueKeys(validated);
1212
- const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
1243
+ const kindsToCheck = chunkZUNQ5BEP_cjs.getKindsForUniquenessCheck(
1213
1244
  kind,
1214
1245
  constraint.scope,
1215
1246
  ctx.registry
@@ -1323,6 +1354,7 @@ exports.executeNodeGetOrCreateByConstraint = executeNodeGetOrCreateByConstraint;
1323
1354
  exports.executeNodeHardDelete = executeNodeHardDelete;
1324
1355
  exports.executeNodeUpdate = executeNodeUpdate;
1325
1356
  exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
1357
+ exports.nodeUpsertDirtyCheck = nodeUpsertDirtyCheck;
1326
1358
  exports.primeBatchValidationCaches = primeBatchValidationCaches;
1327
1359
  exports.rowToEdge = rowToEdge;
1328
1360
  exports.rowToEdgeMeta = rowToEdgeMeta;
@@ -1330,5 +1362,5 @@ exports.rowToNode = rowToNode;
1330
1362
  exports.rowToNodeMeta = rowToNodeMeta;
1331
1363
  exports.runHookedWriteOperation = runHookedWriteOperation;
1332
1364
  exports.runInWriteTransaction = runInWriteTransaction;
1333
- //# sourceMappingURL=chunk-WJT7OU7E.cjs.map
1334
- //# sourceMappingURL=chunk-WJT7OU7E.cjs.map
1365
+ //# sourceMappingURL=chunk-4CAXEB2F.cjs.map
1366
+ //# sourceMappingURL=chunk-4CAXEB2F.cjs.map