@01.software/sdk 0.2.9-dev.260311.bb95a4e → 0.2.9-dev.260314.f493447
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/README.md +81 -48
- package/dist/auth.cjs +3 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -1
- package/dist/auth.js.map +1 -1
- package/dist/index.cjs +168 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +173 -76
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-BjvBwB8Z.d.cts → payload-types-ggU6BNuH.d.cts} +293 -1372
- package/dist/{payload-types-BjvBwB8Z.d.ts → payload-types-ggU6BNuH.d.ts} +293 -1372
- package/dist/ui/code-block.cjs +8 -5
- package/dist/ui/code-block.cjs.map +1 -1
- package/dist/ui/code-block.js +8 -5
- package/dist/ui/code-block.js.map +1 -1
- package/dist/ui/flow.cjs +108 -60
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.js +108 -60
- package/dist/ui/flow.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/rich-text.cjs.map +1 -1
- package/dist/ui/rich-text.js.map +1 -1
- package/dist/{webhook-_LdLdjGa.d.ts → webhook-B54a-HGd.d.ts} +2 -2
- package/dist/{webhook-CszIpUKn.d.cts → webhook-DInps2xX.d.cts} +2 -2
- package/dist/webhook.cjs +7 -5
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/dist/webhook.js +7 -5
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,7 +128,9 @@ function parseApiKey(apiKey) {
|
|
|
128
128
|
}
|
|
129
129
|
return { clientKey, secretKey };
|
|
130
130
|
} catch (e) {
|
|
131
|
-
throw new Error(
|
|
131
|
+
throw new Error(
|
|
132
|
+
'Invalid API key. Expected Base64 encoded "clientKey:secretKey"'
|
|
133
|
+
);
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -199,7 +201,14 @@ var GoneError = class extends SDKError {
|
|
|
199
201
|
};
|
|
200
202
|
var ServiceUnavailableError = class extends SDKError {
|
|
201
203
|
constructor(message = "Service temporarily unavailable.", retryAfter, details, userMessage, suggestion) {
|
|
202
|
-
super(
|
|
204
|
+
super(
|
|
205
|
+
"SERVICE_UNAVAILABLE_ERROR",
|
|
206
|
+
message,
|
|
207
|
+
503,
|
|
208
|
+
details,
|
|
209
|
+
userMessage,
|
|
210
|
+
suggestion
|
|
211
|
+
);
|
|
203
212
|
this.name = "ServiceUnavailableError";
|
|
204
213
|
this.retryAfter = retryAfter;
|
|
205
214
|
}
|
|
@@ -256,7 +265,7 @@ function resolveApiUrl() {
|
|
|
256
265
|
if (envUrl) {
|
|
257
266
|
return envUrl.replace(/\/$/, "");
|
|
258
267
|
}
|
|
259
|
-
return "
|
|
268
|
+
return "https://api-dev.01.software";
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
// src/core/internal/utils/http.ts
|
|
@@ -276,8 +285,7 @@ function debugLog(debug, type, message, data) {
|
|
|
276
285
|
function getErrorSuggestion(status) {
|
|
277
286
|
if (status === 401) return "Please check your authentication credentials.";
|
|
278
287
|
if (status === 404) return "The requested resource was not found.";
|
|
279
|
-
if (status >= 500)
|
|
280
|
-
return "A server error occurred. Please try again later.";
|
|
288
|
+
if (status >= 500) return "A server error occurred. Please try again later.";
|
|
281
289
|
return void 0;
|
|
282
290
|
}
|
|
283
291
|
function delay(ms) {
|
|
@@ -356,9 +364,18 @@ function httpFetch(url, options) {
|
|
|
356
364
|
});
|
|
357
365
|
if (!response.ok) {
|
|
358
366
|
if (response.status === 429 && response.headers.get("X-Usage-Limit")) {
|
|
359
|
-
const limit = parseInt(
|
|
360
|
-
|
|
361
|
-
|
|
367
|
+
const limit = parseInt(
|
|
368
|
+
response.headers.get("X-Usage-Limit") || "0",
|
|
369
|
+
10
|
|
370
|
+
);
|
|
371
|
+
const current = parseInt(
|
|
372
|
+
response.headers.get("X-Usage-Current") || "0",
|
|
373
|
+
10
|
|
374
|
+
);
|
|
375
|
+
const remaining = parseInt(
|
|
376
|
+
response.headers.get("X-Usage-Remaining") || "0",
|
|
377
|
+
10
|
|
378
|
+
);
|
|
362
379
|
throw createUsageLimitError(
|
|
363
380
|
`Monthly API usage limit exceeded (${current.toLocaleString()}/${limit.toLocaleString()})`,
|
|
364
381
|
{ limit, current, remaining },
|
|
@@ -541,7 +558,10 @@ var OrderApi = class extends BaseApi {
|
|
|
541
558
|
return this.request("/api/orders/update-fulfillment", params);
|
|
542
559
|
}
|
|
543
560
|
returnWithRefund(params) {
|
|
544
|
-
return this.request(
|
|
561
|
+
return this.request(
|
|
562
|
+
"/api/returns/return-refund",
|
|
563
|
+
params
|
|
564
|
+
);
|
|
545
565
|
}
|
|
546
566
|
createReturn(params) {
|
|
547
567
|
return this.request("/api/returns/create", params);
|
|
@@ -550,10 +570,16 @@ var OrderApi = class extends BaseApi {
|
|
|
550
570
|
return this.request("/api/returns/update", params);
|
|
551
571
|
}
|
|
552
572
|
validateDiscount(params) {
|
|
553
|
-
return this.request(
|
|
573
|
+
return this.request(
|
|
574
|
+
"/api/discounts/validate",
|
|
575
|
+
params
|
|
576
|
+
);
|
|
554
577
|
}
|
|
555
578
|
calculateShipping(params) {
|
|
556
|
-
return this.request(
|
|
579
|
+
return this.request(
|
|
580
|
+
"/api/shipping-policies/calculate",
|
|
581
|
+
params
|
|
582
|
+
);
|
|
557
583
|
}
|
|
558
584
|
createExchange(params) {
|
|
559
585
|
return this.request("/api/exchanges/create", params);
|
|
@@ -570,7 +596,9 @@ var CartApi = class {
|
|
|
570
596
|
throw createConfigError("clientKey is required for CartApi.");
|
|
571
597
|
}
|
|
572
598
|
if (!options.secretKey && !options.customerToken) {
|
|
573
|
-
throw createConfigError(
|
|
599
|
+
throw createConfigError(
|
|
600
|
+
"Either secretKey or customerToken is required for CartApi."
|
|
601
|
+
);
|
|
574
602
|
}
|
|
575
603
|
this.clientKey = options.clientKey;
|
|
576
604
|
this.secretKey = options.secretKey;
|
|
@@ -623,7 +651,11 @@ var CartApi = class {
|
|
|
623
651
|
return this.execute("/api/carts/update-item", "POST", params);
|
|
624
652
|
}
|
|
625
653
|
removeItem(params) {
|
|
626
|
-
return this.execute(
|
|
654
|
+
return this.execute(
|
|
655
|
+
"/api/carts/remove-item",
|
|
656
|
+
"POST",
|
|
657
|
+
params
|
|
658
|
+
);
|
|
627
659
|
}
|
|
628
660
|
applyDiscount(params) {
|
|
629
661
|
return this.execute("/api/carts/apply-discount", "POST", params);
|
|
@@ -632,7 +664,11 @@ var CartApi = class {
|
|
|
632
664
|
return this.execute("/api/carts/remove-discount", "POST", params);
|
|
633
665
|
}
|
|
634
666
|
clearCart(params) {
|
|
635
|
-
return this.execute(
|
|
667
|
+
return this.execute(
|
|
668
|
+
"/api/carts/clear",
|
|
669
|
+
"POST",
|
|
670
|
+
params
|
|
671
|
+
);
|
|
636
672
|
}
|
|
637
673
|
};
|
|
638
674
|
|
|
@@ -869,7 +905,11 @@ var HttpClient = class {
|
|
|
869
905
|
}
|
|
870
906
|
get defaultOptions() {
|
|
871
907
|
var _a;
|
|
872
|
-
const opts = {
|
|
908
|
+
const opts = {
|
|
909
|
+
clientKey: this.clientKey,
|
|
910
|
+
secretKey: this.secretKey,
|
|
911
|
+
baseUrl: this.baseUrl
|
|
912
|
+
};
|
|
873
913
|
const token = (_a = this.getCustomerToken) == null ? void 0 : _a.call(this);
|
|
874
914
|
if (token) {
|
|
875
915
|
opts.customerToken = token;
|
|
@@ -887,7 +927,9 @@ var HttpClient = class {
|
|
|
887
927
|
assertJsonResponse(response) {
|
|
888
928
|
const contentType = response.headers.get("content-type");
|
|
889
929
|
if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
|
|
890
|
-
throw createApiError("Response is not in JSON format.", response.status, {
|
|
930
|
+
throw createApiError("Response is not in JSON format.", response.status, {
|
|
931
|
+
contentType
|
|
932
|
+
});
|
|
891
933
|
}
|
|
892
934
|
}
|
|
893
935
|
/**
|
|
@@ -902,7 +944,9 @@ var HttpClient = class {
|
|
|
902
944
|
this.assertJsonResponse(response);
|
|
903
945
|
const jsonData = yield response.json();
|
|
904
946
|
if (jsonData.docs === void 0) {
|
|
905
|
-
throw createApiError("Invalid find response.", response.status, {
|
|
947
|
+
throw createApiError("Invalid find response.", response.status, {
|
|
948
|
+
jsonData
|
|
949
|
+
});
|
|
906
950
|
}
|
|
907
951
|
return {
|
|
908
952
|
docs: jsonData.docs,
|
|
@@ -936,7 +980,9 @@ var HttpClient = class {
|
|
|
936
980
|
this.assertJsonResponse(response);
|
|
937
981
|
const jsonData = yield response.json();
|
|
938
982
|
if (jsonData.doc === void 0) {
|
|
939
|
-
throw createApiError("Invalid mutation response.", response.status, {
|
|
983
|
+
throw createApiError("Invalid mutation response.", response.status, {
|
|
984
|
+
jsonData
|
|
985
|
+
});
|
|
940
986
|
}
|
|
941
987
|
return {
|
|
942
988
|
message: jsonData.message || "",
|
|
@@ -1000,7 +1046,9 @@ var CollectionClient = class extends HttpClient {
|
|
|
1000
1046
|
requestFind(endpoint, options) {
|
|
1001
1047
|
return __async(this, null, function* () {
|
|
1002
1048
|
const url = this.buildUrl(endpoint, options);
|
|
1003
|
-
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1049
|
+
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1050
|
+
method: "GET"
|
|
1051
|
+
}));
|
|
1004
1052
|
return this.parseFindResponse(response);
|
|
1005
1053
|
});
|
|
1006
1054
|
}
|
|
@@ -1011,7 +1059,9 @@ var CollectionClient = class extends HttpClient {
|
|
|
1011
1059
|
requestFindById(endpoint, options) {
|
|
1012
1060
|
return __async(this, null, function* () {
|
|
1013
1061
|
const url = this.buildUrl(endpoint, options);
|
|
1014
|
-
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1062
|
+
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1063
|
+
method: "GET"
|
|
1064
|
+
}));
|
|
1015
1065
|
return this.parseDocumentResponse(response);
|
|
1016
1066
|
});
|
|
1017
1067
|
}
|
|
@@ -1048,7 +1098,9 @@ var CollectionClient = class extends HttpClient {
|
|
|
1048
1098
|
requestCount(endpoint, options) {
|
|
1049
1099
|
return __async(this, null, function* () {
|
|
1050
1100
|
const url = this.buildUrl(endpoint, options);
|
|
1051
|
-
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1101
|
+
const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1102
|
+
method: "GET"
|
|
1103
|
+
}));
|
|
1052
1104
|
return this.parseDocumentResponse(response);
|
|
1053
1105
|
});
|
|
1054
1106
|
}
|
|
@@ -1123,13 +1175,11 @@ var COLLECTIONS = [
|
|
|
1123
1175
|
"tenants",
|
|
1124
1176
|
"tenant-metadata",
|
|
1125
1177
|
"tenant-logos",
|
|
1126
|
-
"tenant-og-images",
|
|
1127
1178
|
"products",
|
|
1128
1179
|
"product-variants",
|
|
1129
1180
|
"product-options",
|
|
1130
1181
|
"product-categories",
|
|
1131
1182
|
"product-tags",
|
|
1132
|
-
"product-images",
|
|
1133
1183
|
"product-collections",
|
|
1134
1184
|
"brands",
|
|
1135
1185
|
"brand-logos",
|
|
@@ -1145,7 +1195,6 @@ var COLLECTIONS = [
|
|
|
1145
1195
|
"customers",
|
|
1146
1196
|
"customer-addresses",
|
|
1147
1197
|
"customer-groups",
|
|
1148
|
-
"customer-group-images",
|
|
1149
1198
|
"carts",
|
|
1150
1199
|
"cart-items",
|
|
1151
1200
|
"discounts",
|
|
@@ -1153,35 +1202,29 @@ var COLLECTIONS = [
|
|
|
1153
1202
|
"documents",
|
|
1154
1203
|
"document-categories",
|
|
1155
1204
|
"document-types",
|
|
1156
|
-
"document-images",
|
|
1157
1205
|
"posts",
|
|
1158
1206
|
"post-categories",
|
|
1159
1207
|
"post-tags",
|
|
1160
|
-
"post-images",
|
|
1161
1208
|
"playlists",
|
|
1162
|
-
"playlist-images",
|
|
1163
1209
|
"playlist-categories",
|
|
1164
1210
|
"playlist-tags",
|
|
1165
1211
|
"musics",
|
|
1166
1212
|
"galleries",
|
|
1167
|
-
"gallery-images",
|
|
1168
1213
|
"gallery-categories",
|
|
1169
1214
|
"gallery-tags",
|
|
1215
|
+
"gallery-items",
|
|
1170
1216
|
"flows",
|
|
1171
|
-
"flow-images",
|
|
1172
1217
|
"flow-node-types",
|
|
1173
1218
|
"flow-edge-types",
|
|
1174
1219
|
"flow-categories",
|
|
1175
1220
|
"flow-tags",
|
|
1176
1221
|
"videos",
|
|
1177
|
-
"video-images",
|
|
1178
1222
|
"video-categories",
|
|
1179
1223
|
"video-tags",
|
|
1180
1224
|
"live-streams",
|
|
1181
|
-
"
|
|
1225
|
+
"images",
|
|
1182
1226
|
"forms",
|
|
1183
|
-
"form-submissions"
|
|
1184
|
-
"media"
|
|
1227
|
+
"form-submissions"
|
|
1185
1228
|
];
|
|
1186
1229
|
|
|
1187
1230
|
// src/core/customer/customer-auth.ts
|
|
@@ -1189,19 +1232,20 @@ var DEFAULT_TIMEOUT2 = 15e3;
|
|
|
1189
1232
|
var CustomerAuth = class {
|
|
1190
1233
|
constructor(clientKey, baseUrl, options) {
|
|
1191
1234
|
this.refreshPromise = null;
|
|
1192
|
-
var _a, _b;
|
|
1235
|
+
var _a, _b, _c;
|
|
1193
1236
|
this.clientKey = clientKey;
|
|
1194
1237
|
this.baseUrl = baseUrl;
|
|
1195
|
-
|
|
1196
|
-
|
|
1238
|
+
const persist = (_a = options == null ? void 0 : options.persist) != null ? _a : true;
|
|
1239
|
+
if (persist) {
|
|
1240
|
+
const key = typeof persist === "string" ? persist : "customer-token";
|
|
1197
1241
|
const isBrowser = typeof window !== "undefined";
|
|
1198
|
-
this.token = isBrowser ? (
|
|
1242
|
+
this.token = isBrowser ? (_b = localStorage.getItem(key)) != null ? _b : null : null;
|
|
1199
1243
|
this.onTokenChange = isBrowser ? (token) => {
|
|
1200
1244
|
if (token) localStorage.setItem(key, token);
|
|
1201
1245
|
else localStorage.removeItem(key);
|
|
1202
1246
|
} : void 0;
|
|
1203
1247
|
} else {
|
|
1204
|
-
this.token = (
|
|
1248
|
+
this.token = (_c = options == null ? void 0 : options.token) != null ? _c : null;
|
|
1205
1249
|
this.onTokenChange = options == null ? void 0 : options.onTokenChange;
|
|
1206
1250
|
}
|
|
1207
1251
|
}
|
|
@@ -1221,10 +1265,13 @@ var CustomerAuth = class {
|
|
|
1221
1265
|
*/
|
|
1222
1266
|
login(data) {
|
|
1223
1267
|
return __async(this, null, function* () {
|
|
1224
|
-
const result = yield this.requestJson(
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1268
|
+
const result = yield this.requestJson(
|
|
1269
|
+
"/api/customers/login",
|
|
1270
|
+
{
|
|
1271
|
+
method: "POST",
|
|
1272
|
+
body: JSON.stringify(data)
|
|
1273
|
+
}
|
|
1274
|
+
);
|
|
1228
1275
|
this.setToken(result.token);
|
|
1229
1276
|
return result;
|
|
1230
1277
|
});
|
|
@@ -1246,10 +1293,13 @@ var CustomerAuth = class {
|
|
|
1246
1293
|
}
|
|
1247
1294
|
_doRefreshToken() {
|
|
1248
1295
|
return __async(this, null, function* () {
|
|
1249
|
-
const result = yield this.requestJson(
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1296
|
+
const result = yield this.requestJson(
|
|
1297
|
+
"/api/customers/refresh",
|
|
1298
|
+
{
|
|
1299
|
+
method: "POST",
|
|
1300
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
1301
|
+
}
|
|
1302
|
+
);
|
|
1253
1303
|
this.setToken(result.token);
|
|
1254
1304
|
return result;
|
|
1255
1305
|
});
|
|
@@ -1268,10 +1318,13 @@ var CustomerAuth = class {
|
|
|
1268
1318
|
var _a;
|
|
1269
1319
|
if (!this.token) return null;
|
|
1270
1320
|
try {
|
|
1271
|
-
const data = yield this.requestJson(
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1321
|
+
const data = yield this.requestJson(
|
|
1322
|
+
"/api/customers/me",
|
|
1323
|
+
{
|
|
1324
|
+
method: "GET",
|
|
1325
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1275
1328
|
return (_a = data.customer) != null ? _a : null;
|
|
1276
1329
|
} catch (error) {
|
|
1277
1330
|
if (error instanceof ApiError && error.status === 401) {
|
|
@@ -1310,11 +1363,14 @@ var CustomerAuth = class {
|
|
|
1310
1363
|
updateProfile(data) {
|
|
1311
1364
|
return __async(this, null, function* () {
|
|
1312
1365
|
if (!this.token) throw new ApiError("Not authenticated", 401);
|
|
1313
|
-
const result = yield this.requestJson(
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1366
|
+
const result = yield this.requestJson(
|
|
1367
|
+
"/api/customers/me",
|
|
1368
|
+
{
|
|
1369
|
+
method: "PATCH",
|
|
1370
|
+
headers: { Authorization: `Bearer ${this.token}` },
|
|
1371
|
+
body: JSON.stringify(data)
|
|
1372
|
+
}
|
|
1373
|
+
);
|
|
1318
1374
|
return result.customer;
|
|
1319
1375
|
});
|
|
1320
1376
|
}
|
|
@@ -1401,10 +1457,10 @@ var CustomerAuth = class {
|
|
|
1401
1457
|
} catch (error) {
|
|
1402
1458
|
clearTimeout(timeoutId);
|
|
1403
1459
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1404
|
-
throw new TimeoutError(
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
);
|
|
1460
|
+
throw new TimeoutError(`Request timed out after ${DEFAULT_TIMEOUT2}ms`, {
|
|
1461
|
+
url: path,
|
|
1462
|
+
timeout: DEFAULT_TIMEOUT2
|
|
1463
|
+
});
|
|
1408
1464
|
}
|
|
1409
1465
|
throw new NetworkError(
|
|
1410
1466
|
error instanceof Error ? error.message : "Network request failed",
|
|
@@ -1427,14 +1483,23 @@ var CustomerAuth = class {
|
|
|
1427
1483
|
try {
|
|
1428
1484
|
return yield res.json();
|
|
1429
1485
|
} catch (e) {
|
|
1430
|
-
throw new ApiError(
|
|
1486
|
+
throw new ApiError(
|
|
1487
|
+
"Invalid JSON response from server",
|
|
1488
|
+
res.status,
|
|
1489
|
+
void 0,
|
|
1490
|
+
"INVALID_RESPONSE"
|
|
1491
|
+
);
|
|
1431
1492
|
}
|
|
1432
1493
|
});
|
|
1433
1494
|
}
|
|
1434
1495
|
};
|
|
1435
1496
|
|
|
1436
1497
|
// src/core/query/get-query-client.ts
|
|
1437
|
-
import {
|
|
1498
|
+
import {
|
|
1499
|
+
isServer,
|
|
1500
|
+
QueryClient,
|
|
1501
|
+
defaultShouldDehydrateQuery
|
|
1502
|
+
} from "@tanstack/react-query";
|
|
1438
1503
|
function makeQueryClient() {
|
|
1439
1504
|
return new QueryClient({
|
|
1440
1505
|
defaultOptions: {
|
|
@@ -1542,7 +1607,11 @@ var CollectionHooks = class {
|
|
|
1542
1607
|
}
|
|
1543
1608
|
// ===== useInfiniteQuery =====
|
|
1544
1609
|
useInfiniteQuery(params, options) {
|
|
1545
|
-
const {
|
|
1610
|
+
const {
|
|
1611
|
+
collection,
|
|
1612
|
+
options: queryOptions,
|
|
1613
|
+
pageSize = DEFAULT_PAGE_SIZE
|
|
1614
|
+
} = params;
|
|
1546
1615
|
return useInfiniteQueryOriginal(__spreadValues({
|
|
1547
1616
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
1548
1617
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
@@ -1557,7 +1626,11 @@ var CollectionHooks = class {
|
|
|
1557
1626
|
}
|
|
1558
1627
|
// ===== useSuspenseInfiniteQuery =====
|
|
1559
1628
|
useSuspenseInfiniteQuery(params, options) {
|
|
1560
|
-
const {
|
|
1629
|
+
const {
|
|
1630
|
+
collection,
|
|
1631
|
+
options: queryOptions,
|
|
1632
|
+
pageSize = DEFAULT_PAGE_SIZE
|
|
1633
|
+
} = params;
|
|
1561
1634
|
return useSuspenseInfiniteQueryOriginal(__spreadValues({
|
|
1562
1635
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
1563
1636
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
@@ -1600,7 +1673,11 @@ var CollectionHooks = class {
|
|
|
1600
1673
|
prefetchInfiniteQuery(params, options) {
|
|
1601
1674
|
return __async(this, null, function* () {
|
|
1602
1675
|
var _a;
|
|
1603
|
-
const {
|
|
1676
|
+
const {
|
|
1677
|
+
collection,
|
|
1678
|
+
options: queryOptions,
|
|
1679
|
+
pageSize = DEFAULT_PAGE_SIZE
|
|
1680
|
+
} = params;
|
|
1604
1681
|
return this.queryClient.prefetchInfiniteQuery({
|
|
1605
1682
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
1606
1683
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
@@ -1628,7 +1705,9 @@ var CollectionHooks = class {
|
|
|
1628
1705
|
}),
|
|
1629
1706
|
onSuccess: (data) => {
|
|
1630
1707
|
var _a;
|
|
1631
|
-
this.queryClient.invalidateQueries({
|
|
1708
|
+
this.queryClient.invalidateQueries({
|
|
1709
|
+
queryKey: collectionKeys(collection).all
|
|
1710
|
+
});
|
|
1632
1711
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
|
|
1633
1712
|
},
|
|
1634
1713
|
onError: options == null ? void 0 : options.onError,
|
|
@@ -1647,7 +1726,9 @@ var CollectionHooks = class {
|
|
|
1647
1726
|
}),
|
|
1648
1727
|
onSuccess: (data) => {
|
|
1649
1728
|
var _a;
|
|
1650
|
-
this.queryClient.invalidateQueries({
|
|
1729
|
+
this.queryClient.invalidateQueries({
|
|
1730
|
+
queryKey: collectionKeys(collection).all
|
|
1731
|
+
});
|
|
1651
1732
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
|
|
1652
1733
|
},
|
|
1653
1734
|
onError: options == null ? void 0 : options.onError,
|
|
@@ -1662,7 +1743,9 @@ var CollectionHooks = class {
|
|
|
1662
1743
|
}),
|
|
1663
1744
|
onSuccess: (data) => {
|
|
1664
1745
|
var _a;
|
|
1665
|
-
this.queryClient.invalidateQueries({
|
|
1746
|
+
this.queryClient.invalidateQueries({
|
|
1747
|
+
queryKey: collectionKeys(collection).all
|
|
1748
|
+
});
|
|
1666
1749
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
|
|
1667
1750
|
},
|
|
1668
1751
|
onError: options == null ? void 0 : options.onError,
|
|
@@ -1676,9 +1759,13 @@ var CollectionHooks = class {
|
|
|
1676
1759
|
}
|
|
1677
1760
|
getQueryData(collection, type, idOrOptions, options) {
|
|
1678
1761
|
if (type === "list") {
|
|
1679
|
-
return this.queryClient.getQueryData(
|
|
1762
|
+
return this.queryClient.getQueryData(
|
|
1763
|
+
collectionKeys(collection).list(idOrOptions)
|
|
1764
|
+
);
|
|
1680
1765
|
}
|
|
1681
|
-
return this.queryClient.getQueryData(
|
|
1766
|
+
return this.queryClient.getQueryData(
|
|
1767
|
+
collectionKeys(collection).detail(idOrOptions, options)
|
|
1768
|
+
);
|
|
1682
1769
|
}
|
|
1683
1770
|
setQueryData(collection, type, dataOrId, dataOrOptions, options) {
|
|
1684
1771
|
if (type === "list") {
|
|
@@ -1861,7 +1948,11 @@ var BrowserClient = class {
|
|
|
1861
1948
|
};
|
|
1862
1949
|
this.state = { metadata };
|
|
1863
1950
|
this.queryClient = getQueryClient();
|
|
1864
|
-
this.customer = new CustomerAuth(
|
|
1951
|
+
this.customer = new CustomerAuth(
|
|
1952
|
+
this.config.clientKey,
|
|
1953
|
+
this.baseUrl,
|
|
1954
|
+
options.customer
|
|
1955
|
+
);
|
|
1865
1956
|
const onUnauthorized = () => __async(this, null, function* () {
|
|
1866
1957
|
var _a2;
|
|
1867
1958
|
try {
|
|
@@ -1884,7 +1975,11 @@ var BrowserClient = class {
|
|
|
1884
1975
|
() => this.customer.getToken(),
|
|
1885
1976
|
onUnauthorized
|
|
1886
1977
|
);
|
|
1887
|
-
this.query = new QueryHooks(
|
|
1978
|
+
this.query = new QueryHooks(
|
|
1979
|
+
this.queryClient,
|
|
1980
|
+
this.collections,
|
|
1981
|
+
this.customer
|
|
1982
|
+
);
|
|
1888
1983
|
}
|
|
1889
1984
|
from(collection) {
|
|
1890
1985
|
return this.collections.from(collection);
|
|
@@ -2017,17 +2112,19 @@ function handleWebhook(request, handler, options) {
|
|
|
2017
2112
|
);
|
|
2018
2113
|
} catch (error) {
|
|
2019
2114
|
console.error("Webhook processing error:", error);
|
|
2020
|
-
return new Response(
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
);
|
|
2115
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
2116
|
+
status: 500,
|
|
2117
|
+
headers: { "Content-Type": "application/json" }
|
|
2118
|
+
});
|
|
2024
2119
|
}
|
|
2025
2120
|
});
|
|
2026
2121
|
}
|
|
2027
2122
|
function createTypedWebhookHandler(collection, handler) {
|
|
2028
2123
|
return (event) => __async(null, null, function* () {
|
|
2029
2124
|
if (event.collection !== collection) {
|
|
2030
|
-
throw new Error(
|
|
2125
|
+
throw new Error(
|
|
2126
|
+
`Expected collection "${collection}", got "${event.collection}"`
|
|
2127
|
+
);
|
|
2031
2128
|
}
|
|
2032
2129
|
return handler(event);
|
|
2033
2130
|
});
|