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