@neetru/sdk 3.5.0 → 3.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +71 -1
  2. package/dist/ai.cjs +254 -391
  3. package/dist/ai.d.cts +1 -1
  4. package/dist/ai.d.ts +1 -1
  5. package/dist/ai.mjs +254 -391
  6. package/dist/auth.cjs +3560 -4993
  7. package/dist/auth.d.cts +1 -1
  8. package/dist/auth.d.ts +1 -1
  9. package/dist/auth.mjs +3557 -4990
  10. package/dist/build-guard.cjs +101 -119
  11. package/dist/build-guard.mjs +91 -109
  12. package/dist/catalog.cjs +152 -224
  13. package/dist/catalog.d.cts +1 -1
  14. package/dist/catalog.d.ts +1 -1
  15. package/dist/catalog.mjs +152 -224
  16. package/dist/checkout.cjs +237 -320
  17. package/dist/checkout.d.cts +1 -1
  18. package/dist/checkout.d.ts +1 -1
  19. package/dist/checkout.mjs +236 -319
  20. package/dist/db-react.cjs +59 -87
  21. package/dist/db-react.d.cts +1 -1
  22. package/dist/db-react.d.ts +1 -1
  23. package/dist/db-react.mjs +56 -84
  24. package/dist/db.cjs +2055 -3013
  25. package/dist/db.d.cts +1 -1
  26. package/dist/db.d.ts +1 -1
  27. package/dist/db.mjs +2068 -3026
  28. package/dist/entitlements.cjs +12 -20
  29. package/dist/entitlements.d.cts +1 -1
  30. package/dist/entitlements.d.ts +1 -1
  31. package/dist/entitlements.mjs +12 -20
  32. package/dist/errors.cjs +9 -12
  33. package/dist/errors.d.cts +37 -2
  34. package/dist/errors.d.ts +37 -2
  35. package/dist/errors.mjs +8 -12
  36. package/dist/firestore-compat.cjs +241 -297
  37. package/dist/firestore-compat.d.cts +1 -1
  38. package/dist/firestore-compat.d.ts +1 -1
  39. package/dist/firestore-compat.mjs +215 -271
  40. package/dist/index.cjs +3627 -5135
  41. package/dist/index.d.cts +6 -4
  42. package/dist/index.d.ts +6 -4
  43. package/dist/index.mjs +3731 -5239
  44. package/dist/mobile.cjs +411 -0
  45. package/dist/mobile.d.cts +89 -0
  46. package/dist/mobile.d.ts +89 -0
  47. package/dist/mobile.mjs +409 -0
  48. package/dist/mocks.cjs +312 -447
  49. package/dist/mocks.d.cts +1 -1
  50. package/dist/mocks.d.ts +1 -1
  51. package/dist/mocks.mjs +306 -441
  52. package/dist/notifications.cjs +226 -314
  53. package/dist/notifications.d.cts +1 -1
  54. package/dist/notifications.d.ts +1 -1
  55. package/dist/notifications.mjs +225 -313
  56. package/dist/react.cjs +522 -693
  57. package/dist/react.d.cts +1 -1
  58. package/dist/react.d.ts +1 -1
  59. package/dist/react.mjs +512 -683
  60. package/dist/support.cjs +329 -325
  61. package/dist/support.d.cts +25 -3
  62. package/dist/support.d.ts +25 -3
  63. package/dist/support.mjs +328 -325
  64. package/dist/telemetry.cjs +197 -301
  65. package/dist/telemetry.d.cts +1 -1
  66. package/dist/telemetry.d.ts +1 -1
  67. package/dist/telemetry.mjs +197 -301
  68. package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
  69. package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
  70. package/dist/usage.cjs +163 -227
  71. package/dist/usage.d.cts +1 -1
  72. package/dist/usage.d.ts +1 -1
  73. package/dist/usage.mjs +163 -227
  74. package/dist/webhooks.cjs +258 -359
  75. package/dist/webhooks.d.cts +1 -1
  76. package/dist/webhooks.d.ts +1 -1
  77. package/dist/webhooks.mjs +255 -356
  78. package/package.json +9 -3
  79. package/dist/ai.cjs.map +0 -1
  80. package/dist/ai.mjs.map +0 -1
  81. package/dist/auth.cjs.map +0 -1
  82. package/dist/auth.mjs.map +0 -1
  83. package/dist/build-guard.cjs.map +0 -1
  84. package/dist/build-guard.mjs.map +0 -1
  85. package/dist/catalog.cjs.map +0 -1
  86. package/dist/catalog.mjs.map +0 -1
  87. package/dist/checkout.cjs.map +0 -1
  88. package/dist/checkout.mjs.map +0 -1
  89. package/dist/db-react.cjs.map +0 -1
  90. package/dist/db-react.mjs.map +0 -1
  91. package/dist/db.cjs.map +0 -1
  92. package/dist/db.mjs.map +0 -1
  93. package/dist/entitlements.cjs.map +0 -1
  94. package/dist/entitlements.mjs.map +0 -1
  95. package/dist/errors.cjs.map +0 -1
  96. package/dist/errors.mjs.map +0 -1
  97. package/dist/firestore-compat.cjs.map +0 -1
  98. package/dist/firestore-compat.mjs.map +0 -1
  99. package/dist/index.cjs.map +0 -1
  100. package/dist/index.mjs.map +0 -1
  101. package/dist/mocks.cjs.map +0 -1
  102. package/dist/mocks.mjs.map +0 -1
  103. package/dist/notifications.cjs.map +0 -1
  104. package/dist/notifications.mjs.map +0 -1
  105. package/dist/react.cjs.map +0 -1
  106. package/dist/react.mjs.map +0 -1
  107. package/dist/support.cjs.map +0 -1
  108. package/dist/support.mjs.map +0 -1
  109. package/dist/telemetry.cjs.map +0 -1
  110. package/dist/telemetry.mjs.map +0 -1
  111. package/dist/usage.cjs.map +0 -1
  112. package/dist/usage.mjs.map +0 -1
  113. package/dist/webhooks.cjs.map +0 -1
  114. package/dist/webhooks.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Y as NeetruDb, E as DbCollectionRef, P as FieldSentinel, K as DbQuery } from './types-BPATkXYu.js';
1
+ import { Y as NeetruDb, E as DbCollectionRef, P as FieldSentinel, K as DbQuery } from './types-Dx0IrOSF.js';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.js';
4
4
 
@@ -1,143 +1,122 @@
1
1
  // src/db/field-value.ts
2
- function serverTimestamp() {
2
+ function g() {
3
3
  return { __neetru__: "serverTimestamp" };
4
4
  }
5
- function increment(n) {
6
- if (typeof n !== "number" || !Number.isFinite(n)) {
5
+ function b(e) {
6
+ if (typeof e != "number" || !Number.isFinite(e))
7
7
  throw new TypeError(
8
- `increment(n): n deve ser um n\xFAmero finito (recebido: ${String(n)}).`
8
+ `increment(n): n deve ser um n\xFAmero finito (recebido: ${String(e)}).`
9
9
  );
10
- }
11
- return { __neetru__: "increment", operand: n };
10
+ return { __neetru__: "increment", operand: e };
12
11
  }
13
12
 
14
13
  // src/firestore-compat.ts
15
- function isClientWrapper(v) {
16
- return typeof v === "object" && v !== null && "db" in v && typeof v.db === "object" && v.db?.collection !== void 0;
14
+ function h(e) {
15
+ return typeof e == "object" && e !== null && "db" in e && typeof e.db == "object" && e.db?.collection !== void 0;
17
16
  }
18
- function resolveDb(handle) {
19
- if (handle.__neetruFirestore) return handle.db;
20
- if (isClientWrapper(handle)) return handle.db;
21
- return handle;
17
+ function u(e) {
18
+ return e.__neetruFirestore || h(e) ? e.db : e;
22
19
  }
23
- function getFirestore(handle) {
24
- return { __neetruFirestore: true, db: resolveDb(handle) };
20
+ function P(e) {
21
+ return { __neetruFirestore: true, db: u(e) };
25
22
  }
26
- function collection(db, name) {
27
- const resolved = resolveDb(db);
23
+ function E(e, n) {
24
+ let t = u(e);
28
25
  return {
29
26
  type: "collection",
30
27
  __kind: "collection",
31
- id: name,
32
- path: name,
33
- db: resolved,
34
- ref: resolved.collection(name)
28
+ id: n,
29
+ path: n,
30
+ db: t,
31
+ ref: t.collection(n)
35
32
  };
36
33
  }
37
- function doc(dbOrCollection, ...path) {
38
- if (typeof dbOrCollection === "object" && dbOrCollection !== null && dbOrCollection.__kind === "collection") {
39
- const col = dbOrCollection;
40
- const id = path[0] ?? generateId();
41
- return makeDocRef(col.db, col.id, id);
42
- }
43
- const resolved = resolveDb(dbOrCollection);
44
- if (path.length >= 2) {
45
- return makeDocRef(resolved, path[0], path.slice(1).join("/"));
34
+ function A(e, ...n) {
35
+ if (typeof e == "object" && e !== null && e.__kind === "collection") {
36
+ let r = e, i = n[0] ?? m();
37
+ return d(r.db, r.id, i);
46
38
  }
47
- if (path[0]?.includes("/")) {
48
- const parts = path[0].split("/");
49
- return makeDocRef(resolved, parts[0], parts.slice(1).join("/") || generateId());
39
+ let t = u(e);
40
+ if (n.length >= 2)
41
+ return d(t, n[0], n.slice(1).join("/"));
42
+ if (n[0]?.includes("/")) {
43
+ let r = n[0].split("/");
44
+ return d(t, r[0], r.slice(1).join("/") || m());
50
45
  }
51
- return makeDocRef(resolved, path[0] ?? "", generateId());
46
+ return d(t, n[0] ?? "", m());
52
47
  }
53
- function makeDocRef(db, collectionName, id) {
48
+ function d(e, n, t) {
54
49
  return {
55
50
  type: "document",
56
51
  __kind: "document",
57
- id,
58
- collection: collectionName,
59
- path: `${collectionName}/${id}`,
60
- db
52
+ id: t,
53
+ collection: n,
54
+ path: `${n}/${t}`,
55
+ db: e
61
56
  };
62
57
  }
63
- function generateId() {
64
- const CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
65
- const cryptoObj = globalThis.crypto;
66
- if (!cryptoObj?.getRandomValues) {
58
+ function m() {
59
+ let e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = globalThis.crypto;
60
+ if (!n?.getRandomValues)
67
61
  throw new Error(
68
62
  "[Neetru SDK / firestore-compat] WebCrypto indispon\xEDvel: generateId() exige globalThis.crypto.getRandomValues (Node \u226520 ou ambiente browser)."
69
63
  );
70
- }
71
- let out = "";
72
- while (out.length < 20) {
73
- const buf = new Uint8Array(20 - out.length);
74
- cryptoObj.getRandomValues(buf);
75
- for (const byte of buf) {
76
- if (byte < 248) {
77
- out += CHARS[byte % 62];
78
- if (out.length === 20) break;
79
- }
80
- }
81
- }
82
- return out;
83
- }
84
- function query(source, ...constraints) {
85
- const base = source.__kind === "query" ? source : {
64
+ let t = "";
65
+ for (; t.length < 20; ) {
66
+ let r = new Uint8Array(20 - t.length);
67
+ n.getRandomValues(r);
68
+ for (let i of r)
69
+ if (i < 248 && (t += e[i % 62], t.length === 20))
70
+ break;
71
+ }
72
+ return t;
73
+ }
74
+ function B(e, ...n) {
75
+ let t = e.__kind === "query" ? e : {
86
76
  type: "query",
87
77
  __kind: "query",
88
- path: source.path,
89
- collection: source.id,
90
- db: source.db,
91
- ref: source.ref,
78
+ path: e.path,
79
+ collection: e.id,
80
+ db: e.db,
81
+ ref: e.ref,
92
82
  constraints: []
93
83
  };
94
- return { ...base, constraints: [...base.constraints, ...constraints] };
95
- }
96
- function where(field, op, value) {
97
- return { __constraint: "where", field, op, value };
98
- }
99
- function orderBy(field, direction = "asc") {
100
- return { __constraint: "orderBy", field, direction };
101
- }
102
- function limit(value) {
103
- return { __constraint: "limit", value };
104
- }
105
- function toDbQuery(constraints) {
106
- const whereFilters = [];
107
- let orderByClause;
108
- let limitValue;
109
- for (const c of constraints) {
110
- if (c.__constraint === "where") {
111
- const w = c;
112
- whereFilters.push({ field: w.field, op: normalizeOp(w.op), value: w.value });
113
- } else if (c.__constraint === "orderBy") {
114
- const o = c;
115
- orderByClause = { field: o.field, direction: o.direction };
116
- } else if (c.__constraint === "limit") {
117
- limitValue = c.value;
118
- }
119
- }
120
- const out = {};
121
- if (whereFilters.length > 0) out.where = whereFilters;
122
- if (orderByClause) out.orderBy = orderByClause;
123
- if (limitValue !== void 0) out.limit = limitValue;
124
- return out;
125
- }
126
- function normalizeOp(op) {
127
- return op;
128
- }
129
- function stripId(raw) {
130
- if (raw && typeof raw === "object" && "id" in raw) {
131
- const { id: _omit, ...rest } = raw;
132
- return rest;
133
- }
134
- return raw;
135
- }
136
- var DocumentSnapshot = class {
137
- constructor(id, _data, ref) {
138
- this.id = id;
139
- this._data = _data;
140
- this.ref = ref;
84
+ return { ...t, constraints: [...t.constraints, ...n] };
85
+ }
86
+ function L(e, n, t) {
87
+ return { __constraint: "where", field: e, op: n, value: t };
88
+ }
89
+ function W(e, n = "asc") {
90
+ return { __constraint: "orderBy", field: e, direction: n };
91
+ }
92
+ function I(e) {
93
+ return { __constraint: "limit", value: e };
94
+ }
95
+ function w(e) {
96
+ let n = [], t, r;
97
+ for (let s of e)
98
+ if (s.__constraint === "where") {
99
+ let o = s;
100
+ n.push({ field: o.field, op: o.op, value: o.value });
101
+ } else if (s.__constraint === "orderBy") {
102
+ let o = s;
103
+ t = { field: o.field, direction: o.direction };
104
+ } else s.__constraint === "limit" && (r = s.value);
105
+ let i = {};
106
+ return n.length > 0 && (i.where = n), t && (i.orderBy = t), r !== void 0 && (i.limit = r), i;
107
+ }
108
+ function y(e) {
109
+ if (e && typeof e == "object" && "id" in e) {
110
+ let { id: n, ...t } = e;
111
+ return t;
112
+ }
113
+ return e;
114
+ }
115
+ var l = class {
116
+ constructor(n, t, r) {
117
+ this.id = n;
118
+ this._data = t;
119
+ this.ref = r;
141
120
  }
142
121
  id;
143
122
  _data;
@@ -149,200 +128,167 @@ var DocumentSnapshot = class {
149
128
  return this._data ?? void 0;
150
129
  }
151
130
  /** Compat: `snap.get('field')` lê um campo top-level. */
152
- get(field) {
153
- return this._data ? this._data[field] : void 0;
131
+ get(n) {
132
+ return this._data ? this._data[n] : void 0;
154
133
  }
155
- };
156
- var QuerySnapshot = class {
134
+ }, p = class {
157
135
  docs;
158
136
  empty;
159
137
  size;
160
- constructor(rows, db, collectionName) {
161
- this.docs = rows.map(({ id, data }) => {
162
- const stripped = stripId(data);
163
- const ref = db && collectionName ? makeDocRef(db, collectionName, id) : void 0;
138
+ constructor(n, t, r) {
139
+ this.docs = n.map(({ id: i, data: s }) => {
140
+ let o = y(s), a = t && r ? d(t, r, i) : void 0;
164
141
  return {
165
- id,
166
- data: () => stripped,
142
+ id: i,
143
+ data: () => o,
167
144
  exists: () => true,
168
- get: (field) => stripped?.[field],
145
+ get: (c) => o?.[c],
169
146
  // ref sempre presente quando db+collection conhecidos (caso comum).
170
- ref
147
+ ref: a
171
148
  };
172
- });
173
- this.empty = this.docs.length === 0;
174
- this.size = this.docs.length;
149
+ }), this.empty = this.docs.length === 0, this.size = this.docs.length;
175
150
  }
176
- forEach(cb) {
177
- this.docs.forEach(cb);
151
+ forEach(n) {
152
+ this.docs.forEach(n);
178
153
  }
179
154
  };
180
- function firstDocData(result) {
181
- const first = result?.docs[0];
182
- return { data: first ? first.data : null, id: first?.id ?? null };
183
- }
184
- async function getDoc(ref) {
185
- const result = await ref.db.collection(ref.collection).get(ref.id);
186
- const { data } = firstDocData(result);
187
- return new DocumentSnapshot(
188
- ref.id,
189
- data ? stripId({ id: ref.id, ...data }) : null,
190
- ref
155
+ function D(e) {
156
+ let n = e?.docs[0];
157
+ return { data: n ? n.data : null, id: n?.id ?? null };
158
+ }
159
+ async function x(e) {
160
+ let n = await e.db.collection(e.collection).get(e.id), { data: t } = D(n);
161
+ return new l(
162
+ e.id,
163
+ t ? y({ id: e.id, ...t }) : null,
164
+ e
191
165
  );
192
166
  }
193
- function listResultToRows(result) {
194
- return result.docs.map((d) => ({ id: d.id, data: { ...d.data } }));
167
+ function k(e) {
168
+ return e.docs.map((n) => ({ id: n.id, data: { ...n.data } }));
195
169
  }
196
- async function getDocs(source) {
197
- const dbQuery = source.__kind === "query" ? toDbQuery(source.constraints) : void 0;
198
- const collectionName = source.__kind === "query" ? source.collection : source.id;
199
- const result = await source.db.collection(collectionName).list(dbQuery);
200
- return new QuerySnapshot(listResultToRows(result), source.db, collectionName);
170
+ async function U(e) {
171
+ let n = e.__kind === "query" ? w(e.constraints) : void 0, t = e.__kind === "query" ? e.collection : e.id, r = await e.db.collection(t).list(n);
172
+ return new p(k(r), e.db, t);
201
173
  }
202
- async function setDoc(ref, data, options = {}) {
203
- const col = ref.db.collection(ref.collection);
204
- const payload = data;
205
- if (options.merge || options.mergeFields && options.mergeFields.length > 0) {
206
- await col.update(ref.id, payload, { upsert: true });
207
- } else {
208
- await col.set(ref.id, payload);
209
- }
174
+ async function j(e, n, t = {}) {
175
+ let r = e.db.collection(e.collection), i = n;
176
+ t.merge || t.mergeFields && t.mergeFields.length > 0 ? await r.update(e.id, i, { upsert: true }) : await r.set(e.id, i);
210
177
  }
211
- async function addDoc(source, data) {
212
- const result = await source.db.collection(source.id).add(data);
213
- return makeDocRef(source.db, source.id, result.id);
178
+ async function q(e, n) {
179
+ let t = await e.db.collection(e.id).add(n);
180
+ return d(e.db, e.id, t.id);
214
181
  }
215
- async function updateDoc(ref, data) {
216
- await ref.db.collection(ref.collection).update(ref.id, data);
182
+ async function M(e, n) {
183
+ await e.db.collection(e.collection).update(e.id, n);
217
184
  }
218
- async function deleteDoc(ref) {
219
- await ref.db.collection(ref.collection).remove(ref.id);
185
+ async function $(e) {
186
+ await e.db.collection(e.collection).remove(e.id);
220
187
  }
221
- var WriteBatch = class {
222
- constructor(db) {
223
- this.db = db;
188
+ var f = class {
189
+ constructor(n) {
190
+ this.db = n;
224
191
  }
225
192
  db;
226
193
  ops = [];
227
- set(ref, data, options) {
228
- const merge = !!(options?.merge || options?.mergeFields && options.mergeFields.length > 0);
229
- this.ops.push({
230
- collection: ref.collection,
231
- op: merge ? { kind: "update", id: ref.id, data, upsert: true } : { kind: "set", id: ref.id, data }
232
- });
233
- return this;
234
- }
235
- update(ref, data) {
236
- this.ops.push({
237
- collection: ref.collection,
238
- op: { kind: "update", id: ref.id, data }
239
- });
240
- return this;
241
- }
242
- delete(ref) {
243
- this.ops.push({ collection: ref.collection, op: { kind: "remove", id: ref.id } });
244
- return this;
194
+ set(n, t, r) {
195
+ let i = !!(r?.merge || r?.mergeFields && r.mergeFields.length > 0);
196
+ return this.ops.push({
197
+ collection: n.collection,
198
+ op: i ? { kind: "update", id: n.id, data: t, upsert: true } : { kind: "set", id: n.id, data: t }
199
+ }), this;
200
+ }
201
+ update(n, t) {
202
+ return this.ops.push({
203
+ collection: n.collection,
204
+ op: { kind: "update", id: n.id, data: t }
205
+ }), this;
206
+ }
207
+ delete(n) {
208
+ return this.ops.push({ collection: n.collection, op: { kind: "remove", id: n.id } }), this;
245
209
  }
246
210
  async commit() {
247
- const byCol = /* @__PURE__ */ new Map();
248
- for (const { collection: name, op } of this.ops) {
249
- const list = byCol.get(name) ?? [];
250
- list.push(op);
251
- byCol.set(name, list);
252
- }
253
- for (const [name, ops] of byCol.entries()) {
254
- await this.db.collection(name).batch(ops);
211
+ let n = /* @__PURE__ */ new Map();
212
+ for (let { collection: t, op: r } of this.ops) {
213
+ let i = n.get(t) ?? [];
214
+ i.push(r), n.set(t, i);
255
215
  }
216
+ for (let [t, r] of n.entries())
217
+ await this.db.collection(t).batch(r);
256
218
  this.ops = [];
257
219
  }
258
220
  };
259
- function writeBatch(db) {
260
- return new WriteBatch(resolveDb(db));
261
- }
262
- var _runTransactionWarnEmitted = false;
263
- async function runTransaction(db, updateFunction) {
264
- if (!_runTransactionWarnEmitted) {
265
- _runTransactionWarnEmitted = true;
266
- console.warn(
267
- "[Neetru SDK / firestore-compat] runTransaction(): esta emula\xE7\xE3o N\xC3O oferece isolamento server-side. Reads e writes s\xE3o executados em rounds separados; um write concorrente entre o get() e o commit() resultar\xE1 em lost-update silencioso. Para atomicidade real, use Server Actions no Core ou sentinels increment()/arrayUnion(). Veja a doc em src/firestore-compat.ts \xA7 runTransaction."
268
- );
269
- }
270
- const resolved = resolveDb(db);
271
- const batch = new WriteBatch(resolved);
272
- const tx = {
273
- async get(ref) {
274
- return getDoc(ref);
221
+ function V(e) {
222
+ return new f(u(e));
223
+ }
224
+ var R = false;
225
+ async function z(e, n) {
226
+ R || (R = true, console.warn(
227
+ "[Neetru SDK / firestore-compat] runTransaction(): esta emula\xE7\xE3o N\xC3O oferece isolamento server-side. Reads e writes s\xE3o executados em rounds separados; um write concorrente entre o get() e o commit() resultar\xE1 em lost-update silencioso. Para atomicidade real, use Server Actions no Core ou sentinels increment()/arrayUnion(). Veja a doc em src/firestore-compat.ts \xA7 runTransaction."
228
+ ));
229
+ let t = u(e), r = new f(t), i = {
230
+ async get(o) {
231
+ return x(o);
275
232
  },
276
- set(ref, data, options) {
277
- batch.set(ref, data, options);
278
- return tx;
233
+ set(o, a, c) {
234
+ return r.set(o, a, c), i;
279
235
  },
280
- update(ref, data) {
281
- batch.update(ref, data);
282
- return tx;
236
+ update(o, a) {
237
+ return r.update(o, a), i;
283
238
  },
284
- delete(ref) {
285
- batch.delete(ref);
286
- return tx;
239
+ delete(o) {
240
+ return r.delete(o), i;
287
241
  }
288
- };
289
- const result = await updateFunction(tx);
290
- await batch.commit();
291
- return result;
242
+ }, s = await n(i);
243
+ return await r.commit(), s;
292
244
  }
293
- function onSnapshot(source, onNext, onError) {
294
- if (source.__kind === "document") {
295
- const ref = source;
296
- const docRef = ref.db.collection(ref.collection).doc(ref.id);
245
+ function G(e, n, t) {
246
+ if (e.__kind === "document") {
247
+ let o = e, a = o.db.collection(o.collection).doc(o.id);
297
248
  try {
298
- return docRef.onSnapshot((snap) => {
299
- const data = snap?.docs[0]?.data;
300
- onNext(
301
- new DocumentSnapshot(
302
- ref.id,
303
- data ? stripId({ id: ref.id, ...data }) : null,
304
- ref
249
+ return a.onSnapshot((c) => {
250
+ let T = c?.docs[0]?.data;
251
+ n(
252
+ new l(
253
+ o.id,
254
+ T ? y({ id: o.id, ...T }) : null,
255
+ o
305
256
  )
306
257
  );
307
258
  });
308
- } catch (err) {
309
- onError?.(err instanceof Error ? err : new Error(String(err)));
310
- return () => {
259
+ } catch (c) {
260
+ return t?.(c instanceof Error ? c : new Error(String(c))), () => {
311
261
  };
312
262
  }
313
263
  }
314
- const collectionName = source.__kind === "query" ? source.collection : source.id;
315
- const dbQuery = source.__kind === "query" ? toDbQuery(source.constraints) : void 0;
316
- const col = source.db.collection(collectionName);
264
+ let r = e.__kind === "query" ? e.collection : e.id, i = e.__kind === "query" ? w(e.constraints) : void 0, s = e.db.collection(r);
317
265
  try {
318
- return col.onSnapshot(dbQuery, (snap) => {
319
- onNext(
320
- new QuerySnapshot(listResultToRows(snap), source.db, collectionName)
266
+ return s.onSnapshot(i, (o) => {
267
+ n(
268
+ new p(k(o), e.db, r)
321
269
  );
322
270
  });
323
- } catch (err) {
324
- onError?.(err instanceof Error ? err : new Error(String(err)));
325
- return () => {
271
+ } catch (o) {
272
+ return t?.(o instanceof Error ? o : new Error(String(o))), () => {
326
273
  };
327
274
  }
328
275
  }
329
- var Timestamp = class _Timestamp {
330
- constructor(seconds, nanoseconds) {
331
- this.seconds = seconds;
332
- this.nanoseconds = nanoseconds;
276
+ var _ = class e {
277
+ constructor(n, t) {
278
+ this.seconds = n;
279
+ this.nanoseconds = t;
333
280
  }
334
281
  seconds;
335
282
  nanoseconds;
336
283
  static now() {
337
- return _Timestamp.fromMillis(Date.now());
284
+ return e.fromMillis(Date.now());
338
285
  }
339
- static fromDate(date) {
340
- return _Timestamp.fromMillis(date.getTime());
286
+ static fromDate(n) {
287
+ return e.fromMillis(n.getTime());
341
288
  }
342
- static fromMillis(millis) {
343
- const seconds = Math.floor(millis / 1e3);
344
- const nanoseconds = (millis - seconds * 1e3) * 1e6;
345
- return new _Timestamp(seconds, nanoseconds);
289
+ static fromMillis(n) {
290
+ let t = Math.floor(n / 1e3), r = (n - t * 1e3) * 1e6;
291
+ return new e(t, r);
346
292
  }
347
293
  toDate() {
348
294
  return new Date(this.toMillis());
@@ -350,8 +296,8 @@ var Timestamp = class _Timestamp {
350
296
  toMillis() {
351
297
  return this.seconds * 1e3 + Math.floor(this.nanoseconds / 1e6);
352
298
  }
353
- isEqual(other) {
354
- return this.seconds === other.seconds && this.nanoseconds === other.nanoseconds;
299
+ isEqual(n) {
300
+ return this.seconds === n.seconds && this.nanoseconds === n.nanoseconds;
355
301
  }
356
302
  valueOf() {
357
303
  return `${this.seconds.toString().padStart(12, "0")}.${this.nanoseconds.toString().padStart(9, "0")}`;
@@ -363,29 +309,27 @@ var Timestamp = class _Timestamp {
363
309
  return `Timestamp(seconds=${this.seconds}, nanoseconds=${this.nanoseconds})`;
364
310
  }
365
311
  };
366
- function serverTimestamp2() {
367
- return serverTimestamp();
312
+ function S() {
313
+ return g();
368
314
  }
369
- function increment2(n) {
370
- return increment(n);
315
+ function F(e) {
316
+ return b(e);
371
317
  }
372
- function arrayUnion(...elements) {
373
- return { __neetru__: "arrayUnion", elements };
318
+ function v(...e) {
319
+ return { __neetru__: "arrayUnion", elements: e };
374
320
  }
375
- function arrayRemove(...elements) {
376
- return { __neetru__: "arrayRemove", elements };
321
+ function C(...e) {
322
+ return { __neetru__: "arrayRemove", elements: e };
377
323
  }
378
- function deleteField() {
324
+ function N() {
379
325
  return { __neetru__: "deleteField" };
380
326
  }
381
- var FieldValue = {
382
- serverTimestamp: serverTimestamp2,
383
- increment: increment2,
384
- arrayUnion,
385
- arrayRemove,
386
- delete: deleteField
327
+ var K = {
328
+ serverTimestamp: S,
329
+ increment: F,
330
+ arrayUnion: v,
331
+ arrayRemove: C,
332
+ delete: N
387
333
  };
388
334
 
389
- export { DocumentSnapshot, FieldValue, QuerySnapshot, Timestamp, WriteBatch, addDoc, arrayRemove, arrayUnion, collection, deleteDoc, deleteField, doc, getDoc, getDocs, getFirestore, increment2 as increment, limit, onSnapshot, orderBy, query, runTransaction, serverTimestamp2 as serverTimestamp, setDoc, toDbQuery, updateDoc, where, writeBatch };
390
- //# sourceMappingURL=firestore-compat.mjs.map
391
- //# sourceMappingURL=firestore-compat.mjs.map
335
+ export { l as DocumentSnapshot, K as FieldValue, p as QuerySnapshot, _ as Timestamp, f as WriteBatch, q as addDoc, C as arrayRemove, v as arrayUnion, E as collection, $ as deleteDoc, N as deleteField, A as doc, x as getDoc, U as getDocs, P as getFirestore, F as increment, I as limit, G as onSnapshot, W as orderBy, B as query, z as runTransaction, S as serverTimestamp, j as setDoc, w as toDbQuery, M as updateDoc, L as where, V as writeBatch };