@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.
- package/CHANGELOG.md +71 -1
- package/dist/ai.cjs +254 -391
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +254 -391
- package/dist/auth.cjs +3560 -4993
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +3557 -4990
- package/dist/build-guard.cjs +101 -119
- package/dist/build-guard.mjs +91 -109
- package/dist/catalog.cjs +152 -224
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +152 -224
- package/dist/checkout.cjs +237 -320
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +236 -319
- package/dist/db-react.cjs +59 -87
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db-react.mjs +56 -84
- package/dist/db.cjs +2055 -3013
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +2068 -3026
- package/dist/entitlements.cjs +12 -20
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +12 -20
- package/dist/errors.cjs +9 -12
- package/dist/errors.d.cts +37 -2
- package/dist/errors.d.ts +37 -2
- package/dist/errors.mjs +8 -12
- package/dist/firestore-compat.cjs +241 -297
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/firestore-compat.mjs +215 -271
- package/dist/index.cjs +3627 -5135
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +3731 -5239
- package/dist/mobile.cjs +411 -0
- package/dist/mobile.d.cts +89 -0
- package/dist/mobile.d.ts +89 -0
- package/dist/mobile.mjs +409 -0
- package/dist/mocks.cjs +312 -447
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.mjs +306 -441
- package/dist/notifications.cjs +226 -314
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +225 -313
- package/dist/react.cjs +522 -693
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +512 -683
- package/dist/support.cjs +329 -325
- package/dist/support.d.cts +25 -3
- package/dist/support.d.ts +25 -3
- package/dist/support.mjs +328 -325
- package/dist/telemetry.cjs +197 -301
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +197 -301
- package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
- package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
- package/dist/usage.cjs +163 -227
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +163 -227
- package/dist/webhooks.cjs +258 -359
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +255 -356
- package/package.json +9 -3
- package/dist/ai.cjs.map +0 -1
- package/dist/ai.mjs.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.mjs.map +0 -1
- package/dist/build-guard.cjs.map +0 -1
- package/dist/build-guard.mjs.map +0 -1
- package/dist/catalog.cjs.map +0 -1
- package/dist/catalog.mjs.map +0 -1
- package/dist/checkout.cjs.map +0 -1
- package/dist/checkout.mjs.map +0 -1
- package/dist/db-react.cjs.map +0 -1
- package/dist/db-react.mjs.map +0 -1
- package/dist/db.cjs.map +0 -1
- package/dist/db.mjs.map +0 -1
- package/dist/entitlements.cjs.map +0 -1
- package/dist/entitlements.mjs.map +0 -1
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/firestore-compat.cjs.map +0 -1
- package/dist/firestore-compat.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/mocks.cjs.map +0 -1
- package/dist/mocks.mjs.map +0 -1
- package/dist/notifications.cjs.map +0 -1
- package/dist/notifications.mjs.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.mjs.map +0 -1
- package/dist/support.cjs.map +0 -1
- package/dist/support.mjs.map +0 -1
- package/dist/telemetry.cjs.map +0 -1
- package/dist/telemetry.mjs.map +0 -1
- package/dist/usage.cjs.map +0 -1
- package/dist/usage.mjs.map +0 -1
- package/dist/webhooks.cjs.map +0 -1
- 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-
|
|
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
|
|
2
|
+
function g() {
|
|
3
3
|
return { __neetru__: "serverTimestamp" };
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
if (typeof
|
|
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(
|
|
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
|
|
16
|
-
return typeof
|
|
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
|
|
19
|
-
|
|
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
|
|
24
|
-
return { __neetruFirestore: true, db:
|
|
20
|
+
function P(e) {
|
|
21
|
+
return { __neetruFirestore: true, db: u(e) };
|
|
25
22
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
23
|
+
function E(e, n) {
|
|
24
|
+
let t = u(e);
|
|
28
25
|
return {
|
|
29
26
|
type: "collection",
|
|
30
27
|
__kind: "collection",
|
|
31
|
-
id:
|
|
32
|
-
path:
|
|
33
|
-
db:
|
|
34
|
-
ref:
|
|
28
|
+
id: n,
|
|
29
|
+
path: n,
|
|
30
|
+
db: t,
|
|
31
|
+
ref: t.collection(n)
|
|
35
32
|
};
|
|
36
33
|
}
|
|
37
|
-
function
|
|
38
|
-
if (typeof
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
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
|
|
46
|
+
return d(t, n[0] ?? "", m());
|
|
52
47
|
}
|
|
53
|
-
function
|
|
48
|
+
function d(e, n, t) {
|
|
54
49
|
return {
|
|
55
50
|
type: "document",
|
|
56
51
|
__kind: "document",
|
|
57
|
-
id,
|
|
58
|
-
collection:
|
|
59
|
-
path: `${
|
|
60
|
-
db
|
|
52
|
+
id: t,
|
|
53
|
+
collection: n,
|
|
54
|
+
path: `${n}/${t}`,
|
|
55
|
+
db: e
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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:
|
|
89
|
-
collection:
|
|
90
|
-
db:
|
|
91
|
-
ref:
|
|
78
|
+
path: e.path,
|
|
79
|
+
collection: e.id,
|
|
80
|
+
db: e.db,
|
|
81
|
+
ref: e.ref,
|
|
92
82
|
constraints: []
|
|
93
83
|
};
|
|
94
|
-
return { ...
|
|
95
|
-
}
|
|
96
|
-
function
|
|
97
|
-
return { __constraint: "where", field, op, value };
|
|
98
|
-
}
|
|
99
|
-
function
|
|
100
|
-
return { __constraint: "orderBy", field, direction };
|
|
101
|
-
}
|
|
102
|
-
function
|
|
103
|
-
return { __constraint: "limit", value };
|
|
104
|
-
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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(
|
|
153
|
-
return this._data ? this._data[
|
|
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(
|
|
161
|
-
this.docs =
|
|
162
|
-
|
|
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: () =>
|
|
142
|
+
id: i,
|
|
143
|
+
data: () => o,
|
|
167
144
|
exists: () => true,
|
|
168
|
-
get: (
|
|
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(
|
|
177
|
-
this.docs.forEach(
|
|
151
|
+
forEach(n) {
|
|
152
|
+
this.docs.forEach(n);
|
|
178
153
|
}
|
|
179
154
|
};
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
return { data:
|
|
183
|
-
}
|
|
184
|
-
async function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
194
|
-
return
|
|
167
|
+
function k(e) {
|
|
168
|
+
return e.docs.map((n) => ({ id: n.id, data: { ...n.data } }));
|
|
195
169
|
}
|
|
196
|
-
async function
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
203
|
-
|
|
204
|
-
|
|
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
|
|
212
|
-
|
|
213
|
-
return
|
|
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
|
|
216
|
-
await
|
|
182
|
+
async function M(e, n) {
|
|
183
|
+
await e.db.collection(e.collection).update(e.id, n);
|
|
217
184
|
}
|
|
218
|
-
async function
|
|
219
|
-
await
|
|
185
|
+
async function $(e) {
|
|
186
|
+
await e.db.collection(e.collection).remove(e.id);
|
|
220
187
|
}
|
|
221
|
-
var
|
|
222
|
-
constructor(
|
|
223
|
-
this.db =
|
|
188
|
+
var f = class {
|
|
189
|
+
constructor(n) {
|
|
190
|
+
this.db = n;
|
|
224
191
|
}
|
|
225
192
|
db;
|
|
226
193
|
ops = [];
|
|
227
|
-
set(
|
|
228
|
-
|
|
229
|
-
this.ops.push({
|
|
230
|
-
collection:
|
|
231
|
-
op:
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
248
|
-
for (
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
260
|
-
return new
|
|
261
|
-
}
|
|
262
|
-
var
|
|
263
|
-
async function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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(
|
|
277
|
-
|
|
278
|
-
return tx;
|
|
233
|
+
set(o, a, c) {
|
|
234
|
+
return r.set(o, a, c), i;
|
|
279
235
|
},
|
|
280
|
-
update(
|
|
281
|
-
|
|
282
|
-
return tx;
|
|
236
|
+
update(o, a) {
|
|
237
|
+
return r.update(o, a), i;
|
|
283
238
|
},
|
|
284
|
-
delete(
|
|
285
|
-
|
|
286
|
-
return tx;
|
|
239
|
+
delete(o) {
|
|
240
|
+
return r.delete(o), i;
|
|
287
241
|
}
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
await batch.commit();
|
|
291
|
-
return result;
|
|
242
|
+
}, s = await n(i);
|
|
243
|
+
return await r.commit(), s;
|
|
292
244
|
}
|
|
293
|
-
function
|
|
294
|
-
if (
|
|
295
|
-
|
|
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
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
new
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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 (
|
|
309
|
-
|
|
310
|
-
return () => {
|
|
259
|
+
} catch (c) {
|
|
260
|
+
return t?.(c instanceof Error ? c : new Error(String(c))), () => {
|
|
311
261
|
};
|
|
312
262
|
}
|
|
313
263
|
}
|
|
314
|
-
|
|
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
|
|
319
|
-
|
|
320
|
-
new
|
|
266
|
+
return s.onSnapshot(i, (o) => {
|
|
267
|
+
n(
|
|
268
|
+
new p(k(o), e.db, r)
|
|
321
269
|
);
|
|
322
270
|
});
|
|
323
|
-
} catch (
|
|
324
|
-
|
|
325
|
-
return () => {
|
|
271
|
+
} catch (o) {
|
|
272
|
+
return t?.(o instanceof Error ? o : new Error(String(o))), () => {
|
|
326
273
|
};
|
|
327
274
|
}
|
|
328
275
|
}
|
|
329
|
-
var
|
|
330
|
-
constructor(
|
|
331
|
-
this.seconds =
|
|
332
|
-
this.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
|
|
284
|
+
return e.fromMillis(Date.now());
|
|
338
285
|
}
|
|
339
|
-
static fromDate(
|
|
340
|
-
return
|
|
286
|
+
static fromDate(n) {
|
|
287
|
+
return e.fromMillis(n.getTime());
|
|
341
288
|
}
|
|
342
|
-
static fromMillis(
|
|
343
|
-
|
|
344
|
-
|
|
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(
|
|
354
|
-
return this.seconds ===
|
|
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
|
|
367
|
-
return
|
|
312
|
+
function S() {
|
|
313
|
+
return g();
|
|
368
314
|
}
|
|
369
|
-
function
|
|
370
|
-
return
|
|
315
|
+
function F(e) {
|
|
316
|
+
return b(e);
|
|
371
317
|
}
|
|
372
|
-
function
|
|
373
|
-
return { __neetru__: "arrayUnion", elements };
|
|
318
|
+
function v(...e) {
|
|
319
|
+
return { __neetru__: "arrayUnion", elements: e };
|
|
374
320
|
}
|
|
375
|
-
function
|
|
376
|
-
return { __neetru__: "arrayRemove", elements };
|
|
321
|
+
function C(...e) {
|
|
322
|
+
return { __neetru__: "arrayRemove", elements: e };
|
|
377
323
|
}
|
|
378
|
-
function
|
|
324
|
+
function N() {
|
|
379
325
|
return { __neetru__: "deleteField" };
|
|
380
326
|
}
|
|
381
|
-
var
|
|
382
|
-
serverTimestamp:
|
|
383
|
-
increment:
|
|
384
|
-
arrayUnion,
|
|
385
|
-
arrayRemove,
|
|
386
|
-
delete:
|
|
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,
|
|
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 };
|