@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,145 +1,124 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/db/field-value.ts
|
|
4
|
-
function
|
|
4
|
+
function g() {
|
|
5
5
|
return { __neetru__: "serverTimestamp" };
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
if (typeof
|
|
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(
|
|
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
|
|
18
|
-
return typeof
|
|
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
|
|
21
|
-
|
|
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
|
|
26
|
-
return { __neetruFirestore: true, db:
|
|
22
|
+
function P(e) {
|
|
23
|
+
return { __neetruFirestore: true, db: u(e) };
|
|
27
24
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
25
|
+
function E(e, n) {
|
|
26
|
+
let t = u(e);
|
|
30
27
|
return {
|
|
31
28
|
type: "collection",
|
|
32
29
|
__kind: "collection",
|
|
33
|
-
id:
|
|
34
|
-
path:
|
|
35
|
-
db:
|
|
36
|
-
ref:
|
|
30
|
+
id: n,
|
|
31
|
+
path: n,
|
|
32
|
+
db: t,
|
|
33
|
+
ref: t.collection(n)
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
|
-
function
|
|
40
|
-
if (typeof
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
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
|
|
48
|
+
return d(t, n[0] ?? "", m());
|
|
54
49
|
}
|
|
55
|
-
function
|
|
50
|
+
function d(e, n, t) {
|
|
56
51
|
return {
|
|
57
52
|
type: "document",
|
|
58
53
|
__kind: "document",
|
|
59
|
-
id,
|
|
60
|
-
collection:
|
|
61
|
-
path: `${
|
|
62
|
-
db
|
|
54
|
+
id: t,
|
|
55
|
+
collection: n,
|
|
56
|
+
path: `${n}/${t}`,
|
|
57
|
+
db: e
|
|
63
58
|
};
|
|
64
59
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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:
|
|
91
|
-
collection:
|
|
92
|
-
db:
|
|
93
|
-
ref:
|
|
80
|
+
path: e.path,
|
|
81
|
+
collection: e.id,
|
|
82
|
+
db: e.db,
|
|
83
|
+
ref: e.ref,
|
|
94
84
|
constraints: []
|
|
95
85
|
};
|
|
96
|
-
return { ...
|
|
97
|
-
}
|
|
98
|
-
function
|
|
99
|
-
return { __constraint: "where", field, op, value };
|
|
100
|
-
}
|
|
101
|
-
function
|
|
102
|
-
return { __constraint: "orderBy", field, direction };
|
|
103
|
-
}
|
|
104
|
-
function
|
|
105
|
-
return { __constraint: "limit", value };
|
|
106
|
-
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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(
|
|
155
|
-
return this._data ? this._data[
|
|
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(
|
|
163
|
-
this.docs =
|
|
164
|
-
|
|
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: () =>
|
|
144
|
+
id: i,
|
|
145
|
+
data: () => o,
|
|
169
146
|
exists: () => true,
|
|
170
|
-
get: (
|
|
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(
|
|
179
|
-
this.docs.forEach(
|
|
153
|
+
forEach(n) {
|
|
154
|
+
this.docs.forEach(n);
|
|
180
155
|
}
|
|
181
156
|
};
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
return { data:
|
|
185
|
-
}
|
|
186
|
-
async function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
|
196
|
-
return
|
|
169
|
+
function k(e) {
|
|
170
|
+
return e.docs.map((n) => ({ id: n.id, data: { ...n.data } }));
|
|
197
171
|
}
|
|
198
|
-
async function
|
|
199
|
-
|
|
200
|
-
|
|
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
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
214
|
-
|
|
215
|
-
return
|
|
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
|
|
218
|
-
await
|
|
184
|
+
async function M(e, n) {
|
|
185
|
+
await e.db.collection(e.collection).update(e.id, n);
|
|
219
186
|
}
|
|
220
|
-
async function
|
|
221
|
-
await
|
|
187
|
+
async function $(e) {
|
|
188
|
+
await e.db.collection(e.collection).remove(e.id);
|
|
222
189
|
}
|
|
223
|
-
var
|
|
224
|
-
constructor(
|
|
225
|
-
this.db =
|
|
190
|
+
var f = class {
|
|
191
|
+
constructor(n) {
|
|
192
|
+
this.db = n;
|
|
226
193
|
}
|
|
227
194
|
db;
|
|
228
195
|
ops = [];
|
|
229
|
-
set(
|
|
230
|
-
|
|
231
|
-
this.ops.push({
|
|
232
|
-
collection:
|
|
233
|
-
op:
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
250
|
-
for (
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
262
|
-
return new
|
|
263
|
-
}
|
|
264
|
-
var
|
|
265
|
-
async function
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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(
|
|
279
|
-
|
|
280
|
-
return tx;
|
|
235
|
+
set(o, a, c) {
|
|
236
|
+
return r.set(o, a, c), i;
|
|
281
237
|
},
|
|
282
|
-
update(
|
|
283
|
-
|
|
284
|
-
return tx;
|
|
238
|
+
update(o, a) {
|
|
239
|
+
return r.update(o, a), i;
|
|
285
240
|
},
|
|
286
|
-
delete(
|
|
287
|
-
|
|
288
|
-
return tx;
|
|
241
|
+
delete(o) {
|
|
242
|
+
return r.delete(o), i;
|
|
289
243
|
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
await batch.commit();
|
|
293
|
-
return result;
|
|
244
|
+
}, s = await n(i);
|
|
245
|
+
return await r.commit(), s;
|
|
294
246
|
}
|
|
295
|
-
function
|
|
296
|
-
if (
|
|
297
|
-
|
|
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
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
new
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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 (
|
|
311
|
-
|
|
312
|
-
return () => {
|
|
261
|
+
} catch (c) {
|
|
262
|
+
return t?.(c instanceof Error ? c : new Error(String(c))), () => {
|
|
313
263
|
};
|
|
314
264
|
}
|
|
315
265
|
}
|
|
316
|
-
|
|
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
|
|
321
|
-
|
|
322
|
-
new
|
|
268
|
+
return s.onSnapshot(i, (o) => {
|
|
269
|
+
n(
|
|
270
|
+
new p(k(o), e.db, r)
|
|
323
271
|
);
|
|
324
272
|
});
|
|
325
|
-
} catch (
|
|
326
|
-
|
|
327
|
-
return () => {
|
|
273
|
+
} catch (o) {
|
|
274
|
+
return t?.(o instanceof Error ? o : new Error(String(o))), () => {
|
|
328
275
|
};
|
|
329
276
|
}
|
|
330
277
|
}
|
|
331
|
-
var
|
|
332
|
-
constructor(
|
|
333
|
-
this.seconds =
|
|
334
|
-
this.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
|
|
286
|
+
return e.fromMillis(Date.now());
|
|
340
287
|
}
|
|
341
|
-
static fromDate(
|
|
342
|
-
return
|
|
288
|
+
static fromDate(n) {
|
|
289
|
+
return e.fromMillis(n.getTime());
|
|
343
290
|
}
|
|
344
|
-
static fromMillis(
|
|
345
|
-
|
|
346
|
-
|
|
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(
|
|
356
|
-
return this.seconds ===
|
|
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
|
|
369
|
-
return
|
|
314
|
+
function S() {
|
|
315
|
+
return g();
|
|
370
316
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
317
|
+
function F(e) {
|
|
318
|
+
return b(e);
|
|
373
319
|
}
|
|
374
|
-
function
|
|
375
|
-
return { __neetru__: "arrayUnion", elements };
|
|
320
|
+
function v(...e) {
|
|
321
|
+
return { __neetru__: "arrayUnion", elements: e };
|
|
376
322
|
}
|
|
377
|
-
function
|
|
378
|
-
return { __neetru__: "arrayRemove", elements };
|
|
323
|
+
function C(...e) {
|
|
324
|
+
return { __neetru__: "arrayRemove", elements: e };
|
|
379
325
|
}
|
|
380
|
-
function
|
|
326
|
+
function N() {
|
|
381
327
|
return { __neetru__: "deleteField" };
|
|
382
328
|
}
|
|
383
|
-
var
|
|
384
|
-
serverTimestamp:
|
|
385
|
-
increment:
|
|
386
|
-
arrayUnion,
|
|
387
|
-
arrayRemove,
|
|
388
|
-
delete:
|
|
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 =
|
|
392
|
-
exports.FieldValue =
|
|
393
|
-
exports.QuerySnapshot =
|
|
394
|
-
exports.Timestamp =
|
|
395
|
-
exports.WriteBatch =
|
|
396
|
-
exports.addDoc =
|
|
397
|
-
exports.arrayRemove =
|
|
398
|
-
exports.arrayUnion =
|
|
399
|
-
exports.collection =
|
|
400
|
-
exports.deleteDoc =
|
|
401
|
-
exports.deleteField =
|
|
402
|
-
exports.doc =
|
|
403
|
-
exports.getDoc =
|
|
404
|
-
exports.getDocs =
|
|
405
|
-
exports.getFirestore =
|
|
406
|
-
exports.increment =
|
|
407
|
-
exports.limit =
|
|
408
|
-
exports.onSnapshot =
|
|
409
|
-
exports.orderBy =
|
|
410
|
-
exports.query =
|
|
411
|
-
exports.runTransaction =
|
|
412
|
-
exports.serverTimestamp =
|
|
413
|
-
exports.setDoc =
|
|
414
|
-
exports.toDbQuery =
|
|
415
|
-
exports.updateDoc =
|
|
416
|
-
exports.where =
|
|
417
|
-
exports.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-
|
|
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
|
|