@neetru/sdk 2.3.5 → 3.0.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 +184 -0
- package/README.md +59 -22
- package/dist/auth.cjs +368 -142
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +368 -142
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.cjs +21 -2
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +21 -2
- package/dist/catalog.mjs.map +1 -1
- package/dist/checkout.cjs +21 -2
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +21 -2
- package/dist/checkout.mjs.map +1 -1
- package/dist/db.cjs +36 -5
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +36 -5
- package/dist/db.mjs.map +1 -1
- package/dist/entitlements.cjs +21 -2
- package/dist/entitlements.cjs.map +1 -1
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +21 -2
- package/dist/entitlements.mjs.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +3 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +432 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -19
- package/dist/index.d.ts +31 -19
- package/dist/index.mjs +432 -152
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.cjs +49 -37
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +23 -19
- package/dist/mocks.d.ts +23 -19
- package/dist/mocks.mjs +49 -37
- package/dist/mocks.mjs.map +1 -1
- package/dist/notifications.cjs +80 -14
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +80 -14
- package/dist/notifications.mjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/support.cjs +72 -12
- package/dist/support.cjs.map +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +72 -12
- package/dist/support.mjs.map +1 -1
- package/dist/telemetry.cjs +23 -4
- package/dist/telemetry.cjs.map +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +23 -4
- package/dist/telemetry.mjs.map +1 -1
- package/dist/{types-sGGN1vkg.d.cts → types-DLOvkeAP.d.cts} +110 -49
- package/dist/{types-CSC-RIdS.d.ts → types-dw19bdID.d.ts} +110 -49
- package/dist/usage.cjs +57 -63
- package/dist/usage.cjs.map +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +57 -63
- package/dist/usage.mjs.map +1 -1
- package/dist/webhooks.cjs +110 -33
- package/dist/webhooks.cjs.map +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +110 -33
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +2 -2
package/dist/db.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { C as ConflictRecord, a as CreateOfflineDocumentsOptions, D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery, i as DbWhereFilter, N as NeetruDbDocuments, R as RealtimeTransport, S as SyncState } from './collection-ref-DqAAhuhX.cjs';
|
|
2
|
-
export { k as DbSqlLease, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, w as NeetruSqlClient,
|
|
2
|
+
export { k as DbSqlLease, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, w as NeetruSqlClient, K as SqlOptions, a7 as createNeetruDb, a9 as createRestSyncTransport, ab as getWebSocketRealtimeClient } from './types-DLOvkeAP.cjs';
|
|
3
3
|
import '@neetru/realtime-protocol';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.cjs';
|
package/dist/db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { C as ConflictRecord, a as CreateOfflineDocumentsOptions, D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery, i as DbWhereFilter, N as NeetruDbDocuments, R as RealtimeTransport, S as SyncState } from './collection-ref-DqAAhuhX.js';
|
|
2
|
-
export { k as DbSqlLease, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, w as NeetruSqlClient,
|
|
2
|
+
export { k as DbSqlLease, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, w as NeetruSqlClient, K as SqlOptions, a7 as createNeetruDb, a9 as createRestSyncTransport, ab as getWebSocketRealtimeClient } from './types-dw19bdID.js';
|
|
3
3
|
import '@neetru/realtime-protocol';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.js';
|
package/dist/db.mjs
CHANGED
|
@@ -65,6 +65,23 @@ var init_db_errors = __esm({
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// src/idempotency.ts
|
|
69
|
+
function generateIdempotencyKey() {
|
|
70
|
+
const cryptoObj = typeof globalThis !== "undefined" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
71
|
+
if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
|
|
72
|
+
return cryptoObj.randomUUID();
|
|
73
|
+
}
|
|
74
|
+
throw new NeetruError(
|
|
75
|
+
"runtime_unsupported",
|
|
76
|
+
"crypto.randomUUID not available in this runtime. SDK 3.0 requires Node \u226520 or modern browser/Edge."
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
var init_idempotency = __esm({
|
|
80
|
+
"src/idempotency.ts"() {
|
|
81
|
+
init_errors();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
68
85
|
// src/http.ts
|
|
69
86
|
var http_exports = {};
|
|
70
87
|
__export(http_exports, {
|
|
@@ -122,7 +139,8 @@ async function safeJson(res) {
|
|
|
122
139
|
async function httpRequest(config, opts) {
|
|
123
140
|
const method = opts.method ?? "GET";
|
|
124
141
|
const url = buildUrl(config.baseUrl, opts.path, opts.query);
|
|
125
|
-
const
|
|
142
|
+
const defaultRetries = READ_METHODS.has(method) ? DEFAULT_RETRIES_READ : DEFAULT_RETRIES_WRITE;
|
|
143
|
+
const maxRetries = opts.retries ?? defaultRetries;
|
|
126
144
|
const headers = {
|
|
127
145
|
accept: "application/json",
|
|
128
146
|
...opts.headers
|
|
@@ -136,6 +154,10 @@ async function httpRequest(config, opts) {
|
|
|
136
154
|
}
|
|
137
155
|
headers.authorization = `Bearer ${config.apiKey}`;
|
|
138
156
|
}
|
|
157
|
+
if (opts.idempotencyKey) {
|
|
158
|
+
const key = typeof opts.idempotencyKey === "string" ? opts.idempotencyKey : generateIdempotencyKey();
|
|
159
|
+
headers["idempotency-key"] = key;
|
|
160
|
+
}
|
|
139
161
|
const bodyString = opts.body !== void 0 && method !== "GET" && method !== "DELETE" ? JSON.stringify(opts.body) : void 0;
|
|
140
162
|
if (bodyString !== void 0) {
|
|
141
163
|
headers["content-type"] = "application/json";
|
|
@@ -187,11 +209,14 @@ async function httpRequest(config, opts) {
|
|
|
187
209
|
}
|
|
188
210
|
throw lastError ?? new NeetruError("unknown", "unexpected httpRequest exit");
|
|
189
211
|
}
|
|
190
|
-
var
|
|
212
|
+
var DEFAULT_RETRIES_READ, DEFAULT_RETRIES_WRITE, READ_METHODS, RETRYABLE_CODES2;
|
|
191
213
|
var init_http = __esm({
|
|
192
214
|
"src/http.ts"() {
|
|
193
215
|
init_errors();
|
|
194
|
-
|
|
216
|
+
init_idempotency();
|
|
217
|
+
DEFAULT_RETRIES_READ = 2;
|
|
218
|
+
DEFAULT_RETRIES_WRITE = 0;
|
|
219
|
+
READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
195
220
|
RETRYABLE_CODES2 = /* @__PURE__ */ new Set([
|
|
196
221
|
"rate_limited",
|
|
197
222
|
"server_error",
|
|
@@ -447,7 +472,10 @@ function parseLease(raw) {
|
|
|
447
472
|
};
|
|
448
473
|
}
|
|
449
474
|
async function createPgPool(lease) {
|
|
450
|
-
const { Pool } = await import(
|
|
475
|
+
const { Pool } = await import(
|
|
476
|
+
/* webpackIgnore: true */
|
|
477
|
+
'pg'
|
|
478
|
+
);
|
|
451
479
|
const ssl = lease.sslca ? {
|
|
452
480
|
ca: lease.sslca,
|
|
453
481
|
cert: lease.clientCert ?? void 0,
|
|
@@ -467,7 +495,10 @@ async function createPgPool(lease) {
|
|
|
467
495
|
});
|
|
468
496
|
}
|
|
469
497
|
async function createDrizzleHandle(pool, schema) {
|
|
470
|
-
const { drizzle } = await import(
|
|
498
|
+
const { drizzle } = await import(
|
|
499
|
+
/* webpackIgnore: true */
|
|
500
|
+
'drizzle-orm/node-postgres'
|
|
501
|
+
);
|
|
471
502
|
return drizzle(pool, { schema });
|
|
472
503
|
}
|
|
473
504
|
async function createSqlClientWithDeps(deps, options) {
|