@neetru/sdk 3.0.2 → 3.1.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 +554 -530
- package/dist/auth.cjs +60 -39
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -2
- package/dist/auth.d.ts +1 -2
- package/dist/auth.mjs +60 -39
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.d.cts +1 -2
- package/dist/catalog.d.ts +1 -2
- package/dist/checkout.d.cts +1 -2
- package/dist/checkout.d.ts +1 -2
- package/dist/db-react.cjs +15 -5
- package/dist/db-react.cjs.map +1 -1
- package/dist/db-react.d.cts +35 -13
- package/dist/db-react.d.ts +35 -13
- package/dist/db-react.mjs +15 -5
- package/dist/db-react.mjs.map +1 -1
- package/dist/db.cjs +71 -50
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +1 -2
- package/dist/db.d.ts +1 -2
- package/dist/db.mjs +71 -50
- package/dist/db.mjs.map +1 -1
- package/dist/entitlements.d.cts +1 -2
- package/dist/entitlements.d.ts +1 -2
- package/dist/firestore-compat.cjs +399 -0
- package/dist/firestore-compat.cjs.map +1 -0
- package/dist/firestore-compat.d.cts +294 -0
- package/dist/firestore-compat.d.ts +294 -0
- package/dist/firestore-compat.mjs +371 -0
- package/dist/firestore-compat.mjs.map +1 -0
- package/dist/index.cjs +72 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +72 -51
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.d.cts +1 -2
- package/dist/mocks.d.ts +1 -2
- package/dist/notifications.d.cts +1 -2
- package/dist/notifications.d.ts +1 -2
- package/dist/react.cjs +267 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +117 -3
- package/dist/react.d.ts +117 -3
- package/dist/react.mjs +265 -1
- package/dist/react.mjs.map +1 -1
- package/dist/support.d.cts +1 -2
- package/dist/support.d.ts +1 -2
- package/dist/telemetry.d.cts +1 -2
- package/dist/telemetry.d.ts +1 -2
- package/dist/{types-D7zVkO3n.d.ts → types-BRv8wBxX.d.ts} +581 -2
- package/dist/{types-Dc4bjrrt.d.cts → types-nwErcRX8.d.cts} +581 -2
- package/dist/usage.d.cts +1 -2
- package/dist/usage.d.ts +1 -2
- package/dist/webhooks.d.cts +1 -2
- package/dist/webhooks.d.ts +1 -2
- package/package.json +156 -151
- package/dist/collection-ref-BDdfD87k.d.cts +0 -581
- package/dist/collection-ref-BDdfD87k.d.ts +0 -581
package/dist/auth.cjs
CHANGED
|
@@ -2043,7 +2043,60 @@ var MutationQueue = class {
|
|
|
2043
2043
|
}
|
|
2044
2044
|
};
|
|
2045
2045
|
|
|
2046
|
+
// src/db/field-value.ts
|
|
2047
|
+
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
2048
|
+
function isFieldSentinel(v) {
|
|
2049
|
+
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
2050
|
+
}
|
|
2051
|
+
function isServerTimestampSentinel(v) {
|
|
2052
|
+
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
2053
|
+
}
|
|
2054
|
+
function isIncrementSentinel(v) {
|
|
2055
|
+
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
2056
|
+
}
|
|
2057
|
+
function resolveSentinelLocally(value, baseValue) {
|
|
2058
|
+
if (isServerTimestampSentinel(value)) {
|
|
2059
|
+
return Date.now();
|
|
2060
|
+
}
|
|
2061
|
+
if (isIncrementSentinel(value)) {
|
|
2062
|
+
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
2063
|
+
return base + value.operand;
|
|
2064
|
+
}
|
|
2065
|
+
return value;
|
|
2066
|
+
}
|
|
2067
|
+
function resolveSentinelsLocally(data, existing) {
|
|
2068
|
+
let touched = false;
|
|
2069
|
+
const out = {};
|
|
2070
|
+
for (const [k, v] of Object.entries(data)) {
|
|
2071
|
+
if (isFieldSentinel(v)) {
|
|
2072
|
+
touched = true;
|
|
2073
|
+
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
2074
|
+
} else {
|
|
2075
|
+
out[k] = v;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
return touched ? out : data;
|
|
2079
|
+
}
|
|
2080
|
+
function hasFieldSentinel(data) {
|
|
2081
|
+
for (const v of Object.values(data)) {
|
|
2082
|
+
if (isFieldSentinel(v)) return true;
|
|
2083
|
+
}
|
|
2084
|
+
return false;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2046
2087
|
// src/db/offline/sync-engine.ts
|
|
2088
|
+
function hasSentinels(payload) {
|
|
2089
|
+
return payload !== null && hasFieldSentinel(payload);
|
|
2090
|
+
}
|
|
2091
|
+
function sanitizeSentinelPayload(payload) {
|
|
2092
|
+
if (payload === null) return null;
|
|
2093
|
+
if (!hasFieldSentinel(payload)) return payload;
|
|
2094
|
+
const out = {};
|
|
2095
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
2096
|
+
if (!isFieldSentinel(v)) out[k] = v;
|
|
2097
|
+
}
|
|
2098
|
+
return out;
|
|
2099
|
+
}
|
|
2047
2100
|
var SyncEngine = class {
|
|
2048
2101
|
_store;
|
|
2049
2102
|
_queue;
|
|
@@ -2251,11 +2304,16 @@ var SyncEngine = class {
|
|
|
2251
2304
|
}
|
|
2252
2305
|
return;
|
|
2253
2306
|
}
|
|
2254
|
-
const
|
|
2307
|
+
const literalPayload = sanitizeSentinelPayload(mut.payload);
|
|
2308
|
+
const newData = literalPayload ?? (existing?.data ?? {});
|
|
2255
2309
|
const updatedDoc = {
|
|
2256
2310
|
collection,
|
|
2257
2311
|
id: docId,
|
|
2258
|
-
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } :
|
|
2312
|
+
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } : (
|
|
2313
|
+
// add/set: se o payload tinha sentinels, o cache otimista (existing.data)
|
|
2314
|
+
// é a fonte de verdade até o pull; senão usa o payload literal.
|
|
2315
|
+
hasSentinels(mut.payload) ? { ...existing?.data ?? {}, ...newData } : newData
|
|
2316
|
+
),
|
|
2259
2317
|
meta: {
|
|
2260
2318
|
serverVersion,
|
|
2261
2319
|
updatedAtServer: serverTimestamp,
|
|
@@ -3337,43 +3395,6 @@ var TabCoordinator = class {
|
|
|
3337
3395
|
|
|
3338
3396
|
// src/db/collection-ref.ts
|
|
3339
3397
|
init_db_errors();
|
|
3340
|
-
|
|
3341
|
-
// src/db/field-value.ts
|
|
3342
|
-
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
3343
|
-
function isFieldSentinel(v) {
|
|
3344
|
-
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
3345
|
-
}
|
|
3346
|
-
function isServerTimestampSentinel(v) {
|
|
3347
|
-
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
3348
|
-
}
|
|
3349
|
-
function isIncrementSentinel(v) {
|
|
3350
|
-
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
3351
|
-
}
|
|
3352
|
-
function resolveSentinelLocally(value, baseValue) {
|
|
3353
|
-
if (isServerTimestampSentinel(value)) {
|
|
3354
|
-
return Date.now();
|
|
3355
|
-
}
|
|
3356
|
-
if (isIncrementSentinel(value)) {
|
|
3357
|
-
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
3358
|
-
return base + value.operand;
|
|
3359
|
-
}
|
|
3360
|
-
return value;
|
|
3361
|
-
}
|
|
3362
|
-
function resolveSentinelsLocally(data, existing) {
|
|
3363
|
-
let touched = false;
|
|
3364
|
-
const out = {};
|
|
3365
|
-
for (const [k, v] of Object.entries(data)) {
|
|
3366
|
-
if (isFieldSentinel(v)) {
|
|
3367
|
-
touched = true;
|
|
3368
|
-
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
3369
|
-
} else {
|
|
3370
|
-
out[k] = v;
|
|
3371
|
-
}
|
|
3372
|
-
}
|
|
3373
|
-
return touched ? out : data;
|
|
3374
|
-
}
|
|
3375
|
-
|
|
3376
|
-
// src/db/collection-ref.ts
|
|
3377
3398
|
function isIndexedDBUnavailable() {
|
|
3378
3399
|
return typeof indexedDB === "undefined" || typeof window === "undefined";
|
|
3379
3400
|
}
|