@typicalday/firegraph 0.14.0 → 0.14.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.
@@ -235,7 +235,6 @@ function isTerminalValue(value) {
235
235
  if (ctor && typeof ctor.name === "string" && FIRESTORE_TERMINAL_CTOR.has(ctor.name)) return true;
236
236
  return true;
237
237
  }
238
- var SAFE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_-]*$/;
239
238
  function assertUpdatePayloadExclusive(update) {
240
239
  if (update.replaceData !== void 0 && update.dataOps !== void 0) {
241
240
  throw new Error(
@@ -274,9 +273,9 @@ function walkForDeleteSentinels(node, path, parent, visit) {
274
273
  }
275
274
  function assertSafePath(path) {
276
275
  for (const seg of path) {
277
- if (!SAFE_KEY_RE.test(seg)) {
276
+ if (seg === "") {
278
277
  throw new Error(
279
- `firegraph: unsafe object key ${JSON.stringify(seg)} at path ${path.map((p) => JSON.stringify(p)).join(" > ")}. Keys used inside update payloads must match /^[A-Za-z_][A-Za-z0-9_-]*$/ so they can be embedded safely in SQLite JSON paths.`
278
+ `firegraph: empty object key at path ${path.map((p) => JSON.stringify(p)).join(" > ")}. Object keys in update payloads must be non-empty.`
280
279
  );
281
280
  }
282
281
  }
@@ -2302,7 +2301,7 @@ function generateId() {
2302
2301
  }
2303
2302
 
2304
2303
  // src/firestore-standard/backend.ts
2305
- var import_firestore3 = require("@google-cloud/firestore");
2304
+ var import_firestore4 = require("@google-cloud/firestore");
2306
2305
 
2307
2306
  // src/bulk.ts
2308
2307
  var MAX_BATCH_SIZE = 500;
@@ -2533,8 +2532,8 @@ function createFirestoreAdapter(db, collectionPath) {
2533
2532
  await collectionRef.doc(docId).set(data);
2534
2533
  }
2535
2534
  },
2536
- async updateDoc(docId, data) {
2537
- await collectionRef.doc(docId).update(data);
2535
+ async updateDoc(docId, args) {
2536
+ await collectionRef.doc(docId).update(...args);
2538
2537
  },
2539
2538
  async deleteDoc(docId) {
2540
2539
  await collectionRef.doc(docId).delete();
@@ -2570,8 +2569,8 @@ function createTransactionAdapter(db, collectionPath, tx) {
2570
2569
  tx.set(collectionRef.doc(docId), data);
2571
2570
  }
2572
2571
  },
2573
- updateDoc(docId, data) {
2574
- tx.update(collectionRef.doc(docId), data);
2572
+ updateDoc(docId, args) {
2573
+ tx.update(collectionRef.doc(docId), ...args);
2575
2574
  },
2576
2575
  deleteDoc(docId) {
2577
2576
  tx.delete(collectionRef.doc(docId));
@@ -2603,8 +2602,8 @@ function createBatchAdapter(db, collectionPath) {
2603
2602
  batch.set(collectionRef.doc(docId), data);
2604
2603
  }
2605
2604
  },
2606
- updateDoc(docId, data) {
2607
- batch.update(collectionRef.doc(docId), data);
2605
+ updateDoc(docId, args) {
2606
+ batch.update(collectionRef.doc(docId), ...args);
2608
2607
  },
2609
2608
  deleteDoc(docId) {
2610
2609
  batch.delete(collectionRef.doc(docId));
@@ -2796,6 +2795,27 @@ async function runFirestoreFindEdgesProjected(base, select, filters, options) {
2796
2795
  });
2797
2796
  }
2798
2797
 
2798
+ // src/internal/firestore-update.ts
2799
+ var import_firestore3 = require("@google-cloud/firestore");
2800
+ init_serialization();
2801
+ function buildFirestoreUpdateArgs(update, db) {
2802
+ assertUpdatePayloadExclusive(update);
2803
+ const args = [];
2804
+ if (update.replaceData) {
2805
+ args.push("data", deserializeFirestoreTypes(update.replaceData, db));
2806
+ } else if (update.dataOps) {
2807
+ for (const op of update.dataOps) {
2808
+ assertSafePath(op.path);
2809
+ args.push(new import_firestore3.FieldPath("data", ...op.path), op.delete ? import_firestore3.FieldValue.delete() : op.value);
2810
+ }
2811
+ }
2812
+ args.push("updatedAt", import_firestore3.FieldValue.serverTimestamp());
2813
+ if (update.v !== void 0) {
2814
+ args.push("v", update.v);
2815
+ }
2816
+ return args;
2817
+ }
2818
+
2799
2819
  // src/internal/firestore-vector.ts
2800
2820
  var ENVELOPE_FIELDS = /* @__PURE__ */ new Set([
2801
2821
  "aType",
@@ -2865,7 +2885,6 @@ async function runFirestoreFindNearest(base, params) {
2865
2885
  }
2866
2886
 
2867
2887
  // src/firestore-standard/backend.ts
2868
- init_serialization();
2869
2888
  var STANDARD_CAPS = /* @__PURE__ */ new Set([
2870
2889
  "core.read",
2871
2890
  "core.write",
@@ -2878,30 +2897,8 @@ var STANDARD_CAPS = /* @__PURE__ */ new Set([
2878
2897
  "search.vector",
2879
2898
  "raw.firestore"
2880
2899
  ]);
2881
- function dottedDataPath(op) {
2882
- assertSafePath(op.path);
2883
- return `data.${op.path.join(".")}`;
2884
- }
2885
- function buildFirestoreUpdate(update, db) {
2886
- assertUpdatePayloadExclusive(update);
2887
- const out = {
2888
- updatedAt: import_firestore3.FieldValue.serverTimestamp()
2889
- };
2890
- if (update.replaceData) {
2891
- out.data = deserializeFirestoreTypes(update.replaceData, db);
2892
- } else if (update.dataOps) {
2893
- for (const op of update.dataOps) {
2894
- const key = dottedDataPath(op);
2895
- out[key] = op.delete ? import_firestore3.FieldValue.delete() : op.value;
2896
- }
2897
- }
2898
- if (update.v !== void 0) {
2899
- out.v = update.v;
2900
- }
2901
- return out;
2902
- }
2903
2900
  function stampWritableRecord(record) {
2904
- const now = import_firestore3.FieldValue.serverTimestamp();
2901
+ const now = import_firestore4.FieldValue.serverTimestamp();
2905
2902
  const out = {
2906
2903
  aType: record.aType,
2907
2904
  aUid: record.aUid,
@@ -2934,7 +2931,7 @@ var FirestoreStandardTransactionBackend = class {
2934
2931
  );
2935
2932
  }
2936
2933
  async updateDoc(docId, update) {
2937
- this.adapter.updateDoc(docId, buildFirestoreUpdate(update, this.db));
2934
+ this.adapter.updateDoc(docId, buildFirestoreUpdateArgs(update, this.db));
2938
2935
  }
2939
2936
  async deleteDoc(docId) {
2940
2937
  this.adapter.deleteDoc(docId);
@@ -2953,7 +2950,7 @@ var FirestoreStandardBatchBackend = class {
2953
2950
  );
2954
2951
  }
2955
2952
  updateDoc(docId, update) {
2956
- this.adapter.updateDoc(docId, buildFirestoreUpdate(update, this.db));
2953
+ this.adapter.updateDoc(docId, buildFirestoreUpdateArgs(update, this.db));
2957
2954
  }
2958
2955
  deleteDoc(docId) {
2959
2956
  this.adapter.deleteDoc(docId);
@@ -2989,7 +2986,7 @@ var FirestoreStandardBackendImpl = class _FirestoreStandardBackendImpl {
2989
2986
  );
2990
2987
  }
2991
2988
  updateDoc(docId, update) {
2992
- return this.adapter.updateDoc(docId, buildFirestoreUpdate(update, this.db));
2989
+ return this.adapter.updateDoc(docId, buildFirestoreUpdateArgs(update, this.db));
2993
2990
  }
2994
2991
  deleteDoc(docId) {
2995
2992
  return this.adapter.deleteDoc(docId);