@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/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { createNeetruClient } from './auth.cjs';
|
|
2
2
|
export { NeetruError, NeetruErrorCode } from './errors.cjs';
|
|
3
|
-
export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType,
|
|
4
|
-
export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, S as ServerTimestampSentinel, W as WithFieldSentinels, l as increment, m as isFieldSentinel, n as isIncrementSentinel, o as isServerTimestampSentinel, s as serverTimestamp } from './collection-ref-BDdfD87k.cjs';
|
|
3
|
+
export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, k as CreateTicketInput, D as DEFAULT_BASE_URL, l as DbBatchOp, m as DbChangeType, n as DbCollectionRef, o as DbDoc, p as DbDocRef, q as DbGetResult, r as DbListResult, s as DbNamespace, t as DbQuery, u as DbSqlLease, v as DbWhereFilter, E as EntitlementCheck, F as FieldSentinel, I as IncrementSentinel, L as ListNotificationsOptions, M as MockCheckout, x as MockNotifications, y as MockWebhooks, N as NEETRU_SENTINEL_KEY, z as NeetruClient, B as NeetruClientConfig, G as NeetruDb, J as NeetruDbEngine, K as NeetruDbError, O as NeetruDbErrorCode, P as NeetruDbOptions, Q as NeetruDbTransport, R as NeetruEnv, S as NeetruSqlClient, T as NeetruUser, U as NotificationScopeOptions, V as NotificationsNamespace, W as Product, X as ProductNotification, Y as ProductNotificationSeverity, Z as ProductPlan, _ as ProductStatus, a0 as RegisterWebhookInput, a1 as ResolvedConfig, a2 as SendNotificationInput, a3 as ServerTimestampSentinel, a4 as SignInOptions, a6 as SupportNamespace, a7 as SupportSeverity, a8 as SupportStatus, a9 as SupportTicket, ab as TelemetryEventAck, ac as TelemetryEventInput, ag as UsageEventInput, ah as UsageNamespace, ai as UsageQuota, aj as VerifyTokenOptions, ak as WebhookEndpoint, al as WebhookEvent, am as WebhookScopeOptions, an as WebhookTestResult, ao as WebhooksNamespace, ap as WithFieldSentinels, aq as createCheckoutNamespace, ar as createNeetruDb, as as createNotificationsNamespace, au as createWebhooksNamespace, aw as increment, ax as isFieldSentinel, ay as isIncrementSentinel, az as isServerTimestampSentinel, aA as serverTimestamp, aB as verifyWebhookSignature } from './types-nwErcRX8.cjs';
|
|
5
4
|
export { DEV_FIXTURE_USER, MockAuth, MockDb, MockEntitlements, MockSupport, MockUsage } from './mocks.cjs';
|
|
6
5
|
import 'drizzle-orm/node-postgres';
|
|
7
6
|
|
|
@@ -37,6 +36,6 @@ import 'drizzle-orm/node-postgres';
|
|
|
37
36
|
*/
|
|
38
37
|
|
|
39
38
|
/** Versão do SDK — exportada explicitamente pra detecção em runtime. */
|
|
40
|
-
declare const VERSION: "3.0
|
|
39
|
+
declare const VERSION: "3.1.0";
|
|
41
40
|
|
|
42
41
|
export { VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { createNeetruClient } from './auth.js';
|
|
2
2
|
export { NeetruError, NeetruErrorCode } from './errors.js';
|
|
3
|
-
export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType,
|
|
4
|
-
export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, S as ServerTimestampSentinel, W as WithFieldSentinels, l as increment, m as isFieldSentinel, n as isIncrementSentinel, o as isServerTimestampSentinel, s as serverTimestamp } from './collection-ref-BDdfD87k.js';
|
|
3
|
+
export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, k as CreateTicketInput, D as DEFAULT_BASE_URL, l as DbBatchOp, m as DbChangeType, n as DbCollectionRef, o as DbDoc, p as DbDocRef, q as DbGetResult, r as DbListResult, s as DbNamespace, t as DbQuery, u as DbSqlLease, v as DbWhereFilter, E as EntitlementCheck, F as FieldSentinel, I as IncrementSentinel, L as ListNotificationsOptions, M as MockCheckout, x as MockNotifications, y as MockWebhooks, N as NEETRU_SENTINEL_KEY, z as NeetruClient, B as NeetruClientConfig, G as NeetruDb, J as NeetruDbEngine, K as NeetruDbError, O as NeetruDbErrorCode, P as NeetruDbOptions, Q as NeetruDbTransport, R as NeetruEnv, S as NeetruSqlClient, T as NeetruUser, U as NotificationScopeOptions, V as NotificationsNamespace, W as Product, X as ProductNotification, Y as ProductNotificationSeverity, Z as ProductPlan, _ as ProductStatus, a0 as RegisterWebhookInput, a1 as ResolvedConfig, a2 as SendNotificationInput, a3 as ServerTimestampSentinel, a4 as SignInOptions, a6 as SupportNamespace, a7 as SupportSeverity, a8 as SupportStatus, a9 as SupportTicket, ab as TelemetryEventAck, ac as TelemetryEventInput, ag as UsageEventInput, ah as UsageNamespace, ai as UsageQuota, aj as VerifyTokenOptions, ak as WebhookEndpoint, al as WebhookEvent, am as WebhookScopeOptions, an as WebhookTestResult, ao as WebhooksNamespace, ap as WithFieldSentinels, aq as createCheckoutNamespace, ar as createNeetruDb, as as createNotificationsNamespace, au as createWebhooksNamespace, aw as increment, ax as isFieldSentinel, ay as isIncrementSentinel, az as isServerTimestampSentinel, aA as serverTimestamp, aB as verifyWebhookSignature } from './types-BRv8wBxX.js';
|
|
5
4
|
export { DEV_FIXTURE_USER, MockAuth, MockDb, MockEntitlements, MockSupport, MockUsage } from './mocks.js';
|
|
6
5
|
import 'drizzle-orm/node-postgres';
|
|
7
6
|
|
|
@@ -37,6 +36,6 @@ import 'drizzle-orm/node-postgres';
|
|
|
37
36
|
*/
|
|
38
37
|
|
|
39
38
|
/** Versão do SDK — exportada explicitamente pra detecção em runtime. */
|
|
40
|
-
declare const VERSION: "3.0
|
|
39
|
+
declare const VERSION: "3.1.0";
|
|
41
40
|
|
|
42
41
|
export { VERSION };
|
package/dist/index.mjs
CHANGED
|
@@ -2041,7 +2041,71 @@ var MutationQueue = class {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
};
|
|
2043
2043
|
|
|
2044
|
+
// src/db/field-value.ts
|
|
2045
|
+
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
2046
|
+
function serverTimestamp() {
|
|
2047
|
+
return { __neetru__: "serverTimestamp" };
|
|
2048
|
+
}
|
|
2049
|
+
function increment(n) {
|
|
2050
|
+
if (typeof n !== "number" || !Number.isFinite(n)) {
|
|
2051
|
+
throw new TypeError(
|
|
2052
|
+
`increment(n): n deve ser um n\xFAmero finito (recebido: ${String(n)}).`
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
return { __neetru__: "increment", operand: n };
|
|
2056
|
+
}
|
|
2057
|
+
function isFieldSentinel(v) {
|
|
2058
|
+
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
2059
|
+
}
|
|
2060
|
+
function isServerTimestampSentinel(v) {
|
|
2061
|
+
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
2062
|
+
}
|
|
2063
|
+
function isIncrementSentinel(v) {
|
|
2064
|
+
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
2065
|
+
}
|
|
2066
|
+
function resolveSentinelLocally(value, baseValue) {
|
|
2067
|
+
if (isServerTimestampSentinel(value)) {
|
|
2068
|
+
return Date.now();
|
|
2069
|
+
}
|
|
2070
|
+
if (isIncrementSentinel(value)) {
|
|
2071
|
+
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
2072
|
+
return base + value.operand;
|
|
2073
|
+
}
|
|
2074
|
+
return value;
|
|
2075
|
+
}
|
|
2076
|
+
function resolveSentinelsLocally(data, existing) {
|
|
2077
|
+
let touched = false;
|
|
2078
|
+
const out = {};
|
|
2079
|
+
for (const [k, v] of Object.entries(data)) {
|
|
2080
|
+
if (isFieldSentinel(v)) {
|
|
2081
|
+
touched = true;
|
|
2082
|
+
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
2083
|
+
} else {
|
|
2084
|
+
out[k] = v;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
return touched ? out : data;
|
|
2088
|
+
}
|
|
2089
|
+
function hasFieldSentinel(data) {
|
|
2090
|
+
for (const v of Object.values(data)) {
|
|
2091
|
+
if (isFieldSentinel(v)) return true;
|
|
2092
|
+
}
|
|
2093
|
+
return false;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2044
2096
|
// src/db/offline/sync-engine.ts
|
|
2097
|
+
function hasSentinels(payload) {
|
|
2098
|
+
return payload !== null && hasFieldSentinel(payload);
|
|
2099
|
+
}
|
|
2100
|
+
function sanitizeSentinelPayload(payload) {
|
|
2101
|
+
if (payload === null) return null;
|
|
2102
|
+
if (!hasFieldSentinel(payload)) return payload;
|
|
2103
|
+
const out = {};
|
|
2104
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
2105
|
+
if (!isFieldSentinel(v)) out[k] = v;
|
|
2106
|
+
}
|
|
2107
|
+
return out;
|
|
2108
|
+
}
|
|
2045
2109
|
var SyncEngine = class {
|
|
2046
2110
|
_store;
|
|
2047
2111
|
_queue;
|
|
@@ -2249,11 +2313,16 @@ var SyncEngine = class {
|
|
|
2249
2313
|
}
|
|
2250
2314
|
return;
|
|
2251
2315
|
}
|
|
2252
|
-
const
|
|
2316
|
+
const literalPayload = sanitizeSentinelPayload(mut.payload);
|
|
2317
|
+
const newData = literalPayload ?? (existing?.data ?? {});
|
|
2253
2318
|
const updatedDoc = {
|
|
2254
2319
|
collection,
|
|
2255
2320
|
id: docId,
|
|
2256
|
-
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } :
|
|
2321
|
+
data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } : (
|
|
2322
|
+
// add/set: se o payload tinha sentinels, o cache otimista (existing.data)
|
|
2323
|
+
// é a fonte de verdade até o pull; senão usa o payload literal.
|
|
2324
|
+
hasSentinels(mut.payload) ? { ...existing?.data ?? {}, ...newData } : newData
|
|
2325
|
+
),
|
|
2257
2326
|
meta: {
|
|
2258
2327
|
serverVersion,
|
|
2259
2328
|
updatedAtServer: serverTimestamp2,
|
|
@@ -3335,54 +3404,6 @@ var TabCoordinator = class {
|
|
|
3335
3404
|
|
|
3336
3405
|
// src/db/collection-ref.ts
|
|
3337
3406
|
init_db_errors();
|
|
3338
|
-
|
|
3339
|
-
// src/db/field-value.ts
|
|
3340
|
-
var NEETRU_SENTINEL_KEY = "__neetru__";
|
|
3341
|
-
function serverTimestamp() {
|
|
3342
|
-
return { __neetru__: "serverTimestamp" };
|
|
3343
|
-
}
|
|
3344
|
-
function increment(n) {
|
|
3345
|
-
if (typeof n !== "number" || !Number.isFinite(n)) {
|
|
3346
|
-
throw new TypeError(
|
|
3347
|
-
`increment(n): n deve ser um n\xFAmero finito (recebido: ${String(n)}).`
|
|
3348
|
-
);
|
|
3349
|
-
}
|
|
3350
|
-
return { __neetru__: "increment", operand: n };
|
|
3351
|
-
}
|
|
3352
|
-
function isFieldSentinel(v) {
|
|
3353
|
-
return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
|
|
3354
|
-
}
|
|
3355
|
-
function isServerTimestampSentinel(v) {
|
|
3356
|
-
return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
|
|
3357
|
-
}
|
|
3358
|
-
function isIncrementSentinel(v) {
|
|
3359
|
-
return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
|
|
3360
|
-
}
|
|
3361
|
-
function resolveSentinelLocally(value, baseValue) {
|
|
3362
|
-
if (isServerTimestampSentinel(value)) {
|
|
3363
|
-
return Date.now();
|
|
3364
|
-
}
|
|
3365
|
-
if (isIncrementSentinel(value)) {
|
|
3366
|
-
const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
|
|
3367
|
-
return base + value.operand;
|
|
3368
|
-
}
|
|
3369
|
-
return value;
|
|
3370
|
-
}
|
|
3371
|
-
function resolveSentinelsLocally(data, existing) {
|
|
3372
|
-
let touched = false;
|
|
3373
|
-
const out = {};
|
|
3374
|
-
for (const [k, v] of Object.entries(data)) {
|
|
3375
|
-
if (isFieldSentinel(v)) {
|
|
3376
|
-
touched = true;
|
|
3377
|
-
out[k] = resolveSentinelLocally(v, existing?.[k]);
|
|
3378
|
-
} else {
|
|
3379
|
-
out[k] = v;
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
return touched ? out : data;
|
|
3383
|
-
}
|
|
3384
|
-
|
|
3385
|
-
// src/db/collection-ref.ts
|
|
3386
3407
|
function isIndexedDBUnavailable() {
|
|
3387
3408
|
return typeof indexedDB === "undefined" || typeof window === "undefined";
|
|
3388
3409
|
}
|
|
@@ -6140,7 +6161,7 @@ function createNeetruClient(config = {}) {
|
|
|
6140
6161
|
// src/index.ts
|
|
6141
6162
|
init_errors();
|
|
6142
6163
|
init_db_errors();
|
|
6143
|
-
var VERSION = "3.0
|
|
6164
|
+
var VERSION = "3.1.0";
|
|
6144
6165
|
|
|
6145
6166
|
export { DEFAULT_BASE_URL, DEV_FIXTURE_USER, MockAuth, MockCheckout, MockDb, MockEntitlements, MockNotifications, MockSupport, MockUsage, MockWebhooks, NEETRU_SENTINEL_KEY, NeetruDbError, NeetruError, VERSION, createCheckoutNamespace, createNeetruClient, createNeetruDb, createNotificationsNamespace, createWebhooksNamespace, increment, isFieldSentinel, isIncrementSentinel, isServerTimestampSentinel, serverTimestamp, verifyWebhookSignature };
|
|
6146
6167
|
//# sourceMappingURL=index.mjs.map
|