graphddb 0.5.3 → 0.7.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.
@@ -1,5 +1,5 @@
1
- export { C as CdcEmulator, M as MAINT_OUTBOX_PK_PREFIX, a as MaintenanceDrain, b as MaintenanceDrainOptions, c as createCdcEmulator, d as createMaintenanceDrain, e as createMaintenanceDrainHandler, p as parseChange } from '../from-change-DQK2Jm9R.js';
2
- export { B as BatchResult, C as CdcEmulatorOptions, a as CdcMode, b as ChangeBatch, c as ChangeEvent, d as ChangeEventName, e as ChangeHandler, f as ClockMode, g as ConcurrentRecomputeRef, E as EventLog, F as FaultSpec, R as ReplayOptions, S as ShardId, h as StartingPosition, i as StreamViewType, j as SubscribeHandler, k as SubscribeHandlers, U as Unsubscribe, l as buildSubscribeHandler } from '../maintenance-view-adapter-D5t9taTE.js';
1
+ export { C as CdcEmulator, M as MAINT_OUTBOX_PK_PREFIX, a as MaintenanceDrain, b as MaintenanceDrainOptions, c as createCdcEmulator, d as createMaintenanceDrain, e as createMaintenanceDrainHandler, p as parseChange } from '../from-change-pnURY-cV.js';
2
+ export { B as BatchResult, C as CdcEmulatorOptions, a as CdcMode, b as ChangeBatch, c as ChangeEvent, d as ChangeEventName, e as ChangeHandler, f as ClockMode, g as ConcurrentRecomputeRef, E as EventLog, F as FaultSpec, R as ReplayOptions, S as ShardId, h as StartingPosition, i as StreamViewType, j as SubscribeHandler, k as SubscribeHandlers, U as Unsubscribe, l as buildSubscribeHandler } from '../maintenance-view-adapter-BP2CJDdz.js';
3
3
  import '@aws-sdk/client-dynamodb';
4
4
 
5
5
  /**
package/dist/cdc/index.js CHANGED
@@ -8,11 +8,11 @@ import {
8
8
  createMaintenanceDrainHandler,
9
9
  hashString,
10
10
  shardIdFor
11
- } from "../chunk-M6URQOAW.js";
11
+ } from "../chunk-5NXNEW43.js";
12
12
  import {
13
13
  buildSubscribeHandler,
14
14
  parseChange
15
- } from "../chunk-CCIVET5K.js";
15
+ } from "../chunk-F2DI3GTI.js";
16
16
  import "../chunk-PDUVTYC5.js";
17
17
  export {
18
18
  CdcEmulator,
@@ -7,7 +7,7 @@ import {
7
7
  buildMaintenanceGraph,
8
8
  buildPutInput,
9
9
  resolveModelClass
10
- } from "./chunk-CCIVET5K.js";
10
+ } from "./chunk-F2DI3GTI.js";
11
11
 
12
12
  // src/cdc/prng.ts
13
13
  var SeededRandom = class {
@@ -245,6 +245,73 @@ function buildRelation(select) {
245
245
  });
246
246
  }
247
247
 
248
+ // src/relation/detect.ts
249
+ function isRelationSpec(value) {
250
+ if (typeof value !== "object" || value === null) return false;
251
+ return "select" in value || isSelectBuilder(value);
252
+ }
253
+ function isInlineSnapshotSpec(value) {
254
+ return typeof value === "object" && value !== null && !isSelectBuilder(value) && value.inline === true && !("select" in value);
255
+ }
256
+ function detectRelationFields(select, metadata) {
257
+ const result = [];
258
+ for (const [fieldName, value] of Object.entries(select)) {
259
+ if (isRelationSpec(value)) {
260
+ const rel = metadata.relations.find((r) => r.propertyName === fieldName);
261
+ if (rel) {
262
+ result.push(rel);
263
+ }
264
+ }
265
+ }
266
+ return result;
267
+ }
268
+ function validateInlineSnapshotSelect(select, metadata, resolveTargetMeta) {
269
+ for (const [fieldName, value] of Object.entries(select)) {
270
+ if (isInlineSnapshotSpec(value)) {
271
+ const rel = metadata.relations.find((r) => r.propertyName === fieldName);
272
+ if (!rel) {
273
+ throw new Error(
274
+ `Inline read '{ ${fieldName}: { inline: true } }' is only valid on an embeddedSnapshot relation, but '${fieldName}' is not a relation on '${metadata.prefix}'. Use '${fieldName}: true' for a scalar / embedded field.`
275
+ );
276
+ }
277
+ if (rel.options?.pattern !== "embeddedSnapshot") {
278
+ throw new Error(
279
+ `Inline read '{ ${fieldName}: { inline: true } }' is only valid on an embeddedSnapshot relation. '${fieldName}' is a plain '${rel.type}' relation (no 'pattern: embeddedSnapshot'); use '{ ${fieldName}: { select: \u2026 } }' to traverse to its child rows instead.`
280
+ );
281
+ }
282
+ continue;
283
+ }
284
+ if (typeof value === "object" && value !== null && isRelationSpec(value)) {
285
+ const rel = metadata.relations.find((r) => r.propertyName === fieldName);
286
+ if (!rel) continue;
287
+ const targetMeta = resolveTargetMeta(rel);
288
+ const nested = normalizeSelectSpec(value).select;
289
+ if (nested) {
290
+ validateInlineSnapshotSelect(nested, targetMeta, resolveTargetMeta);
291
+ }
292
+ }
293
+ }
294
+ }
295
+ function getImplicitKeyFields(select, metadata) {
296
+ const relations = detectRelationFields(select, metadata);
297
+ const needed = /* @__PURE__ */ new Set();
298
+ for (const rel of relations) {
299
+ if (rel.type === "refs" && rel.refs) {
300
+ const listField = rel.refs.from;
301
+ if (!(listField in select) || select[listField] !== true) {
302
+ needed.add(listField);
303
+ }
304
+ continue;
305
+ }
306
+ for (const sourceField of Object.values(rel.keyBinding)) {
307
+ if (!(sourceField in select) || select[sourceField] !== true) {
308
+ needed.add(sourceField);
309
+ }
310
+ }
311
+ }
312
+ return [...needed];
313
+ }
314
+
248
315
  // src/define/param.ts
249
316
  function isParamOptions(value) {
250
317
  return typeof value === "object" && value !== null;
@@ -2718,6 +2785,11 @@ function hydrateItem(raw, select, metadata, updatable = false) {
2718
2785
  const fieldMeta = fieldMap.get(fieldName);
2719
2786
  result[fieldName] = deserializeValue(value, fieldMeta);
2720
2787
  }
2788
+ } else if (isInlineSnapshotSpec(selectValue)) {
2789
+ const value = raw[fieldName];
2790
+ if (value !== void 0) {
2791
+ result[fieldName] = value;
2792
+ }
2721
2793
  } else if (typeof selectValue === "object" && selectValue !== null) {
2722
2794
  if ("select" in selectValue || isSelectBuilder(selectValue)) {
2723
2795
  continue;
@@ -2856,6 +2928,18 @@ var recorder = {
2856
2928
  deleteEdge(targetFactory, relationProperty) {
2857
2929
  return { kind: "deleteEdge", targetFactory, relationProperty };
2858
2930
  },
2931
+ dualEdge(forward, inverse) {
2932
+ return {
2933
+ kind: "putEdge",
2934
+ targetFactory: forward.target,
2935
+ relationProperty: forward.relationProperty,
2936
+ inverse: {
2937
+ adjacencyFactory: inverse.adjacency,
2938
+ targetFactory: inverse.target,
2939
+ relationProperty: inverse.relationProperty
2940
+ }
2941
+ };
2942
+ },
2859
2943
  increment(targetFactory, keys, attribute, amount) {
2860
2944
  return { kind: "derive", targetFactory, keys, attribute, amount };
2861
2945
  },
@@ -3713,6 +3797,10 @@ export {
3713
3797
  normalizeTopLevelSelect,
3714
3798
  buildProject,
3715
3799
  buildRelation,
3800
+ isInlineSnapshotSpec,
3801
+ detectRelationFields,
3802
+ validateInlineSnapshotSelect,
3803
+ getImplicitKeyFields,
3716
3804
  param,
3717
3805
  isParam,
3718
3806
  BATCH_GET_MAX_KEYS,