@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.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './collection-ref-BDdfD87k.cjs';
|
|
1
|
+
import { B as NeetruClientConfig, z as NeetruClient } from './types-nwErcRX8.cjs';
|
|
3
2
|
import 'drizzle-orm/node-postgres';
|
|
4
3
|
import './errors.cjs';
|
|
5
4
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './collection-ref-BDdfD87k.js';
|
|
1
|
+
import { B as NeetruClientConfig, z as NeetruClient } from './types-BRv8wBxX.js';
|
|
3
2
|
import 'drizzle-orm/node-postgres';
|
|
4
3
|
import './errors.js';
|
|
5
4
|
|
package/dist/auth.mjs
CHANGED
|
@@ -2041,7 +2041,60 @@ var MutationQueue = class {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
};
|
|
2043
2043
|
|
|
2044
|
+
// src/db/field-value.ts
|
|
2045
|
+
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
2046
|
+
function isFieldSentinel(v) {
|
|
2047
|
+
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
2048
|
+
}
|
|
2049
|
+
function isServerTimestampSentinel(v) {
|
|
2050
|
+
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
2051
|
+
}
|
|
2052
|
+
function isIncrementSentinel(v) {
|
|
2053
|
+
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
2054
|
+
}
|
|
2055
|
+
function resolveSentinelLocally(value, baseValue) {
|
|
2056
|
+
if (isServerTimestampSentinel(value)) {
|
|
2057
|
+
return Date.now();
|
|
2058
|
+
}
|
|
2059
|
+
if (isIncrementSentinel(value)) {
|
|
2060
|
+
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
2061
|
+
return base + value.operand;
|
|
2062
|
+
}
|
|
2063
|
+
return value;
|
|
2064
|
+
}
|
|
2065
|
+
function resolveSentinelsLocally(data, existing) {
|
|
2066
|
+
let touched = false;
|
|
2067
|
+
const out = {};
|
|
2068
|
+
for (const [k, v] of Object.entries(data)) {
|
|
2069
|
+
if (isFieldSentinel(v)) {
|
|
2070
|
+
touched = true;
|
|
2071
|
+
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
2072
|
+
} else {
|
|
2073
|
+
out[k] = v;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
return touched ? out : data;
|
|
2077
|
+
}
|
|
2078
|
+
function hasFieldSentinel(data) {
|
|
2079
|
+
for (const v of Object.values(data)) {
|
|
2080
|
+
if (isFieldSentinel(v)) return true;
|
|
2081
|
+
}
|
|
2082
|
+
return false;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2044
2085
|
// src/db/offline/sync-engine.ts
|
|
2086
|
+
function hasSentinels(payload) {
|
|
2087
|
+
return payload !== null && hasFieldSentinel(payload);
|
|
2088
|
+
}
|
|
2089
|
+
function sanitizeSentinelPayload(payload) {
|
|
2090
|
+
if (payload === null) return null;
|
|
2091
|
+
if (!hasFieldSentinel(payload)) return payload;
|
|
2092
|
+
const out = {};
|
|
2093
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
2094
|
+
if (!isFieldSentinel(v)) out[k] = v;
|
|
2095
|
+
}
|
|
2096
|
+
return out;
|
|
2097
|
+
}
|
|
2045
2098
|
var SyncEngine = class {
|
|
2046
2099
|
_store;
|
|
2047
2100
|
_queue;
|
|
@@ -2249,11 +2302,16 @@ var SyncEngine = class {
|
|
|
2249
2302
|
}
|
|
2250
2303
|
return;
|
|
2251
2304
|
}
|
|
2252
|
-
const
|
|
2305
|
+
const literalPayload = sanitizeSentinelPayload(mut.payload);
|
|
2306
|
+
const newData = literalPayload ?? (existing?.data ?? {});
|
|
2253
2307
|
const updatedDoc = {
|
|
2254
2308
|
collection,
|
|
2255
2309
|
id: docId,
|
|
2256
|
-
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } :
|
|
2310
|
+
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } : (
|
|
2311
|
+
// add/set: se o payload tinha sentinels, o cache otimista (existing.data)
|
|
2312
|
+
// é a fonte de verdade até o pull; senão usa o payload literal.
|
|
2313
|
+
hasSentinels(mut.payload) ? { ...existing?.data ?? {}, ...newData } : newData
|
|
2314
|
+
),
|
|
2257
2315
|
meta: {
|
|
2258
2316
|
serverVersion,
|
|
2259
2317
|
updatedAtServer: serverTimestamp,
|
|
@@ -3335,43 +3393,6 @@ var TabCoordinator = class {
|
|
|
3335
3393
|
|
|
3336
3394
|
// src/db/collection-ref.ts
|
|
3337
3395
|
init_db_errors();
|
|
3338
|
-
|
|
3339
|
-
// src/db/field-value.ts
|
|
3340
|
-
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
3341
|
-
function isFieldSentinel(v) {
|
|
3342
|
-
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
3343
|
-
}
|
|
3344
|
-
function isServerTimestampSentinel(v) {
|
|
3345
|
-
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
3346
|
-
}
|
|
3347
|
-
function isIncrementSentinel(v) {
|
|
3348
|
-
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
3349
|
-
}
|
|
3350
|
-
function resolveSentinelLocally(value, baseValue) {
|
|
3351
|
-
if (isServerTimestampSentinel(value)) {
|
|
3352
|
-
return Date.now();
|
|
3353
|
-
}
|
|
3354
|
-
if (isIncrementSentinel(value)) {
|
|
3355
|
-
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
3356
|
-
return base + value.operand;
|
|
3357
|
-
}
|
|
3358
|
-
return value;
|
|
3359
|
-
}
|
|
3360
|
-
function resolveSentinelsLocally(data, existing) {
|
|
3361
|
-
let touched = false;
|
|
3362
|
-
const out = {};
|
|
3363
|
-
for (const [k, v] of Object.entries(data)) {
|
|
3364
|
-
if (isFieldSentinel(v)) {
|
|
3365
|
-
touched = true;
|
|
3366
|
-
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
3367
|
-
} else {
|
|
3368
|
-
out[k] = v;
|
|
3369
|
-
}
|
|
3370
|
-
}
|
|
3371
|
-
return touched ? out : data;
|
|
3372
|
-
}
|
|
3373
|
-
|
|
3374
|
-
// src/db/collection-ref.ts
|
|
3375
3396
|
function isIndexedDBUnavailable() {
|
|
3376
3397
|
return typeof indexedDB === "undefined" || typeof window === "undefined";
|
|
3377
3398
|
}
|