@techzunction/sdk 0.7.0 → 0.8.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/dist/index.cjs +21 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +236 -26
- package/dist/index.d.ts +236 -26
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
4
4
|
// src/query.ts
|
|
5
5
|
var TZQuery = class _TZQuery {
|
|
6
|
+
controller;
|
|
7
|
+
_promise;
|
|
8
|
+
_executor;
|
|
6
9
|
constructor(executor) {
|
|
7
10
|
this._executor = executor;
|
|
8
11
|
this.controller = new AbortController();
|
|
@@ -42,6 +45,9 @@ var TZQuery = class _TZQuery {
|
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
47
|
var TZPaginatedQuery = class extends TZQuery {
|
|
48
|
+
_page;
|
|
49
|
+
_limit;
|
|
50
|
+
_pageFactory;
|
|
45
51
|
constructor(executor, page, limit, pageFactory) {
|
|
46
52
|
super(executor);
|
|
47
53
|
this._page = page;
|
|
@@ -116,9 +122,15 @@ function toQs(params) {
|
|
|
116
122
|
return entries.length ? "?" + new URLSearchParams(entries).toString() : "";
|
|
117
123
|
}
|
|
118
124
|
var TZClient = class {
|
|
125
|
+
baseUrl;
|
|
126
|
+
orgSlug;
|
|
127
|
+
orgKey;
|
|
128
|
+
store;
|
|
129
|
+
keys;
|
|
130
|
+
onAuthExpired;
|
|
131
|
+
enduserRefreshPromise = null;
|
|
132
|
+
staffRefreshPromise = null;
|
|
119
133
|
constructor(config) {
|
|
120
|
-
this.enduserRefreshPromise = null;
|
|
121
|
-
this.staffRefreshPromise = null;
|
|
122
134
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
123
135
|
this.orgSlug = config.orgSlug;
|
|
124
136
|
this.orgKey = config.orgKey;
|
|
@@ -376,7 +388,7 @@ var ScopedClient = class {
|
|
|
376
388
|
const executor = async (signal) => {
|
|
377
389
|
const rawRes = await this.root.rawRequest("GET", fp, { scope, signal, sendOrgKey: this.sendOrgKey });
|
|
378
390
|
const envelope = rawRes.raw;
|
|
379
|
-
const pagination = envelope
|
|
391
|
+
const pagination = envelope["pagination"] ?? { page: p, limit: l, total: 0, totalPages: 0, hasNextPage: false, hasPrevPage: false };
|
|
380
392
|
return {
|
|
381
393
|
data: { data: rawRes.data, pagination },
|
|
382
394
|
raw: rawRes.raw,
|
|
@@ -2456,10 +2468,10 @@ var TZ = {
|
|
|
2456
2468
|
const config = {
|
|
2457
2469
|
baseUrl,
|
|
2458
2470
|
orgSlug,
|
|
2459
|
-
orgKey,
|
|
2460
2471
|
keyPrefix: options.keyPrefix ?? "tz",
|
|
2461
|
-
|
|
2462
|
-
|
|
2472
|
+
...orgKey != null ? { orgKey } : {},
|
|
2473
|
+
...options.tokenStore != null ? { tokenStore: options.tokenStore } : {},
|
|
2474
|
+
...options.onAuthExpired != null ? { onAuthExpired: options.onAuthExpired } : {}
|
|
2463
2475
|
};
|
|
2464
2476
|
_client = new TZClient(config);
|
|
2465
2477
|
_sf = _client.scoped("/storefront", "public", true);
|
|
@@ -2511,10 +2523,10 @@ function createTZ(options = {}) {
|
|
|
2511
2523
|
const client = new TZClient({
|
|
2512
2524
|
baseUrl,
|
|
2513
2525
|
orgSlug,
|
|
2514
|
-
orgKey,
|
|
2515
2526
|
keyPrefix: options.keyPrefix ?? "tz",
|
|
2516
|
-
|
|
2517
|
-
|
|
2527
|
+
...orgKey != null ? { orgKey } : {},
|
|
2528
|
+
...options.tokenStore != null ? { tokenStore: options.tokenStore } : {},
|
|
2529
|
+
...options.onAuthExpired != null ? { onAuthExpired: options.onAuthExpired } : {}
|
|
2518
2530
|
});
|
|
2519
2531
|
const sf = client.scoped("/storefront", "public", true);
|
|
2520
2532
|
const admin = client.scoped("", "staff", false);
|