@01.software/sdk 0.48.0 → 0.49.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 +27 -0
- package/README.md +64 -7
- package/dist/client.cjs +189 -26
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +7 -6
- package/dist/client.d.ts +7 -6
- package/dist/client.js +189 -26
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-D3ExJU-7.d.ts → collection-client-DnDt6EQz.d.ts} +4 -4
- package/dist/{collection-client-CBup9yOx.d.cts → collection-client-XfGLPuTf.d.cts} +4 -4
- package/dist/{const-BXEi1Kix.d.cts → const-CBba4lDo.d.cts} +1 -1
- package/dist/{const-k9gHylYa.d.ts → const-DCNV5Kq7.d.ts} +1 -1
- package/dist/errors.cjs +63 -15
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +10 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.js +63 -15
- package/dist/errors.js.map +1 -1
- package/dist/{index-BCM9CTL7.d.cts → index-CbKyoEzy.d.cts} +3 -3
- package/dist/{index-CHGGkcLj.d.ts → index-DUuIqUS8.d.ts} +3 -3
- package/dist/index.cjs +152 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +152 -48
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-B6AZQcB7.d.cts → payload-types-MKbx5MuJ.d.cts} +133 -3
- package/dist/{payload-types-B6AZQcB7.d.ts → payload-types-MKbx5MuJ.d.ts} +133 -3
- package/dist/query.cjs +21 -0
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/query.js +21 -0
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +189 -26
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +8 -7
- package/dist/server.d.ts +8 -7
- package/dist/server.js +189 -26
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +21 -0
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +21 -0
- package/dist/storefront-cache.js.map +1 -1
- package/dist/{types-DbA5V3mt.d.ts → types-1UeOk1Uy.d.cts} +31 -6
- package/dist/{types-8us-_C-Q.d.cts → types-BKr_2avj.d.cts} +2 -2
- package/dist/{types-CM2je9Kw.d.cts → types-Du4s5anw.d.ts} +31 -6
- package/dist/{types-ByD2zii1.d.ts → types-L_nh-ED7.d.ts} +2 -2
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/package.json +5 -4
package/dist/client.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, M as MarketDiscovery, d as CustomerMembershipView, e as CancelMembershipParams, f as CancelMembershipResponse, g as ClientState, h as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, i as ApiQueryOptions, j as CancelBrowserPaymentSessionParams, k as CartMergeParams, l as CartMergeResult, m as CartMineResult, n as CartMutationResult, o as CheckoutAbandonedReason, p as CheckoutAmounts, q as CheckoutOrderReference, r as CheckoutPaymentSessionRef, s as CheckoutShippingAddress, t as ClearCartParams, u as ClientMetadata, v as ContentClientOptions, w as CreateCartParams, x as CreateCartResult, y as CreateCheckoutParams, z as CreateCheckoutResult, B as CreatePaymentSessionParams, D as CreatePortOnePaymentSessionParams, F as CustomerSnapshot, G as DebugConfig, H as DeepPartial, I as ExtractArrayType, J as MembershipStatus, K as Money, O as OpenCheckoutPaymentState, P as PayloadFindResponse, L as PayloadMutationResponse, N as PaymentFailureReason, Q as PaymentNextAction, R as PaymentProviderStatus, S as PaymentReconciliationReason, T as PaymentSessionRole, U as PortOneHostedPaymentMethod, V as PortOnePaymentNextAction, W as PortOnePublicPaymentSession, X as ProductUpsertInput, Y as ProductUpsertParams, Z as ProductUpsertResponse, _ as ProductUpsertVariantInput, $ as PublicAttribute, a0 as PublicCaptureEvidence, a1 as PublicCart, a2 as PublicCartItem, a3 as PublicCartItemAdmission, a4 as PublicCartMarket, a5 as PublicCartReference, a6 as PublicCheckout, a7 as PublicCheckoutItem, a8 as PublicMediaAsset, a9 as PublicMediaSize, aa as PublicOrder, ab as PublicOrderAmounts, ac as PublicOrderItem, ad as PublicOrderReference, ae as PublicPaymentSession, af as ReconciliationRequired, ag as RemoveItemParams, ah as RetrieveBrowserPaymentSessionParams, ai as RetrieveCartParams, aj as RetrieveCheckoutParams, ak as RetryConfig, al as RootClient, al as RootClientType, am as RootCollectionClient, an as RootReadOnlyQueryBuilder, ao as ShippingLine, ap as Sort, aq as SpentCheckoutPaymentState, ar as StorefrontContentListOptions, as as StorefrontContentReference, at as StorefrontGalleryItem, au as StorefrontGalleryItemsListOptions, av as StorefrontGalleryItemsSort, aw as StorefrontLink, ax as StorefrontLinksListOptions, ay as StorefrontLinksSort, az as UpdateCartAttributesParams, aA as UpdateDiscountCodesParams, aB as UpdateItemParams, aC as VariantInput, aD as Where } from './types-
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-XfGLPuTf.cjs';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, M as MarketDiscovery, d as CustomerMembershipView, e as CancelMembershipParams, f as CancelMembershipResponse, g as ClientState, h as ClientConfig } from './types-1UeOk1Uy.cjs';
|
|
3
|
+
export { A as AddItemParams, i as ApiQueryOptions, j as CancelBrowserPaymentSessionParams, k as CartMergeParams, l as CartMergeResult, m as CartMineResult, n as CartMutationResult, o as CheckoutAbandonedReason, p as CheckoutAmounts, q as CheckoutOrderReference, r as CheckoutPaymentSessionRef, s as CheckoutShippingAddress, t as ClearCartParams, u as ClientMetadata, v as ContentClientOptions, w as CreateCartParams, x as CreateCartResult, y as CreateCheckoutParams, z as CreateCheckoutResult, B as CreatePaymentSessionParams, D as CreatePortOnePaymentSessionParams, F as CustomerSnapshot, G as DebugConfig, H as DeepPartial, I as ExtractArrayType, J as MembershipStatus, K as Money, O as OpenCheckoutPaymentState, P as PayloadFindResponse, L as PayloadMutationResponse, N as PaymentFailureReason, Q as PaymentNextAction, R as PaymentProviderStatus, S as PaymentReconciliationReason, T as PaymentSessionRole, U as PortOneHostedPaymentMethod, V as PortOnePaymentNextAction, W as PortOnePublicPaymentSession, X as ProductUpsertInput, Y as ProductUpsertParams, Z as ProductUpsertResponse, _ as ProductUpsertVariantInput, $ as PublicAttribute, a0 as PublicCaptureEvidence, a1 as PublicCart, a2 as PublicCartItem, a3 as PublicCartItemAdmission, a4 as PublicCartMarket, a5 as PublicCartReference, a6 as PublicCheckout, a7 as PublicCheckoutItem, a8 as PublicMediaAsset, a9 as PublicMediaSize, aa as PublicOrder, ab as PublicOrderAmounts, ac as PublicOrderItem, ad as PublicOrderReference, ae as PublicPaymentSession, af as ReconciliationRequired, ag as RemoveItemParams, ah as RetrieveBrowserPaymentSessionParams, ai as RetrieveCartParams, aj as RetrieveCheckoutParams, ak as RetryConfig, al as RootClient, al as RootClientType, am as RootCollectionClient, an as RootReadOnlyQueryBuilder, ao as ShippingLine, ap as Sort, aq as SpentCheckoutPaymentState, ar as StorefrontContentListOptions, as as StorefrontContentReference, at as StorefrontGalleryItem, au as StorefrontGalleryItemsListOptions, av as StorefrontGalleryItemsSort, aw as StorefrontLink, ax as StorefrontLinksListOptions, ay as StorefrontLinksSort, az as UpdateCartAttributesParams, aA as UpdateDiscountCodesParams, aB as UpdateItemParams, aC as VariantInput, aD as Where } from './types-1UeOk1Uy.cjs';
|
|
4
|
+
export { isApiError, isAuthError, isCommerceSDKError, isConfigError, isConflictError, isGoneError, isNetworkError, isNotFoundError, isPermissionError, isRateLimitError, isSDKError, isServiceUnavailableError, isTimeoutError, isUsageLimitError, isValidationError } from './errors.cjs';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-CBba4lDo.cjs';
|
|
6
|
+
import './payload-types-MKbx5MuJ.cjs';
|
|
6
7
|
import './metadata.cjs';
|
|
7
|
-
import './types-
|
|
8
|
+
import './types-BKr_2avj.cjs';
|
|
8
9
|
|
|
9
10
|
declare class Client {
|
|
10
11
|
commerce: CommerceClient;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, M as MarketDiscovery, d as CustomerMembershipView, e as CancelMembershipParams, f as CancelMembershipResponse, g as ClientState, h as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, i as ApiQueryOptions, j as CancelBrowserPaymentSessionParams, k as CartMergeParams, l as CartMergeResult, m as CartMineResult, n as CartMutationResult, o as CheckoutAbandonedReason, p as CheckoutAmounts, q as CheckoutOrderReference, r as CheckoutPaymentSessionRef, s as CheckoutShippingAddress, t as ClearCartParams, u as ClientMetadata, v as ContentClientOptions, w as CreateCartParams, x as CreateCartResult, y as CreateCheckoutParams, z as CreateCheckoutResult, B as CreatePaymentSessionParams, D as CreatePortOnePaymentSessionParams, F as CustomerSnapshot, G as DebugConfig, H as DeepPartial, I as ExtractArrayType, J as MembershipStatus, K as Money, O as OpenCheckoutPaymentState, P as PayloadFindResponse, L as PayloadMutationResponse, N as PaymentFailureReason, Q as PaymentNextAction, R as PaymentProviderStatus, S as PaymentReconciliationReason, T as PaymentSessionRole, U as PortOneHostedPaymentMethod, V as PortOnePaymentNextAction, W as PortOnePublicPaymentSession, X as ProductUpsertInput, Y as ProductUpsertParams, Z as ProductUpsertResponse, _ as ProductUpsertVariantInput, $ as PublicAttribute, a0 as PublicCaptureEvidence, a1 as PublicCart, a2 as PublicCartItem, a3 as PublicCartItemAdmission, a4 as PublicCartMarket, a5 as PublicCartReference, a6 as PublicCheckout, a7 as PublicCheckoutItem, a8 as PublicMediaAsset, a9 as PublicMediaSize, aa as PublicOrder, ab as PublicOrderAmounts, ac as PublicOrderItem, ad as PublicOrderReference, ae as PublicPaymentSession, af as ReconciliationRequired, ag as RemoveItemParams, ah as RetrieveBrowserPaymentSessionParams, ai as RetrieveCartParams, aj as RetrieveCheckoutParams, ak as RetryConfig, al as RootClient, al as RootClientType, am as RootCollectionClient, an as RootReadOnlyQueryBuilder, ao as ShippingLine, ap as Sort, aq as SpentCheckoutPaymentState, ar as StorefrontContentListOptions, as as StorefrontContentReference, at as StorefrontGalleryItem, au as StorefrontGalleryItemsListOptions, av as StorefrontGalleryItemsSort, aw as StorefrontLink, ax as StorefrontLinksListOptions, ay as StorefrontLinksSort, az as UpdateCartAttributesParams, aA as UpdateDiscountCodesParams, aB as UpdateItemParams, aC as VariantInput, aD as Where } from './types-
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-DnDt6EQz.js';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, M as MarketDiscovery, d as CustomerMembershipView, e as CancelMembershipParams, f as CancelMembershipResponse, g as ClientState, h as ClientConfig } from './types-Du4s5anw.js';
|
|
3
|
+
export { A as AddItemParams, i as ApiQueryOptions, j as CancelBrowserPaymentSessionParams, k as CartMergeParams, l as CartMergeResult, m as CartMineResult, n as CartMutationResult, o as CheckoutAbandonedReason, p as CheckoutAmounts, q as CheckoutOrderReference, r as CheckoutPaymentSessionRef, s as CheckoutShippingAddress, t as ClearCartParams, u as ClientMetadata, v as ContentClientOptions, w as CreateCartParams, x as CreateCartResult, y as CreateCheckoutParams, z as CreateCheckoutResult, B as CreatePaymentSessionParams, D as CreatePortOnePaymentSessionParams, F as CustomerSnapshot, G as DebugConfig, H as DeepPartial, I as ExtractArrayType, J as MembershipStatus, K as Money, O as OpenCheckoutPaymentState, P as PayloadFindResponse, L as PayloadMutationResponse, N as PaymentFailureReason, Q as PaymentNextAction, R as PaymentProviderStatus, S as PaymentReconciliationReason, T as PaymentSessionRole, U as PortOneHostedPaymentMethod, V as PortOnePaymentNextAction, W as PortOnePublicPaymentSession, X as ProductUpsertInput, Y as ProductUpsertParams, Z as ProductUpsertResponse, _ as ProductUpsertVariantInput, $ as PublicAttribute, a0 as PublicCaptureEvidence, a1 as PublicCart, a2 as PublicCartItem, a3 as PublicCartItemAdmission, a4 as PublicCartMarket, a5 as PublicCartReference, a6 as PublicCheckout, a7 as PublicCheckoutItem, a8 as PublicMediaAsset, a9 as PublicMediaSize, aa as PublicOrder, ab as PublicOrderAmounts, ac as PublicOrderItem, ad as PublicOrderReference, ae as PublicPaymentSession, af as ReconciliationRequired, ag as RemoveItemParams, ah as RetrieveBrowserPaymentSessionParams, ai as RetrieveCartParams, aj as RetrieveCheckoutParams, ak as RetryConfig, al as RootClient, al as RootClientType, am as RootCollectionClient, an as RootReadOnlyQueryBuilder, ao as ShippingLine, ap as Sort, aq as SpentCheckoutPaymentState, ar as StorefrontContentListOptions, as as StorefrontContentReference, at as StorefrontGalleryItem, au as StorefrontGalleryItemsListOptions, av as StorefrontGalleryItemsSort, aw as StorefrontLink, ax as StorefrontLinksListOptions, ay as StorefrontLinksSort, az as UpdateCartAttributesParams, aA as UpdateDiscountCodesParams, aB as UpdateItemParams, aC as VariantInput, aD as Where } from './types-Du4s5anw.js';
|
|
4
|
+
export { isApiError, isAuthError, isCommerceSDKError, isConfigError, isConflictError, isGoneError, isNetworkError, isNotFoundError, isPermissionError, isRateLimitError, isSDKError, isServiceUnavailableError, isTimeoutError, isUsageLimitError, isValidationError } from './errors.js';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-DCNV5Kq7.js';
|
|
6
|
+
import './payload-types-MKbx5MuJ.js';
|
|
6
7
|
import './metadata.js';
|
|
7
|
-
import './types-
|
|
8
|
+
import './types-L_nh-ED7.js';
|
|
8
9
|
|
|
9
10
|
declare class Client {
|
|
10
11
|
commerce: CommerceClient;
|
package/dist/client.js
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
import { stringify } from "qs-esm";
|
|
3
3
|
|
|
4
4
|
// src/core/errors.ts
|
|
5
|
+
var SDK_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError");
|
|
6
|
+
var SDK_ERROR_TYPE_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError.type");
|
|
7
|
+
function defineSDKErrorBrand(error) {
|
|
8
|
+
Object.defineProperty(error, SDK_ERROR_BRAND, {
|
|
9
|
+
value: true,
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: false,
|
|
12
|
+
writable: false
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function defineSDKErrorType(error, type) {
|
|
16
|
+
Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {
|
|
17
|
+
value: type,
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: false,
|
|
20
|
+
writable: false
|
|
21
|
+
});
|
|
22
|
+
}
|
|
5
23
|
var SDKError = class extends Error {
|
|
6
24
|
constructor(code, message, status, details, userMessage, suggestion, requestId) {
|
|
7
25
|
super(message);
|
|
@@ -12,6 +30,7 @@ var SDKError = class extends Error {
|
|
|
12
30
|
this.userMessage = userMessage;
|
|
13
31
|
this.suggestion = suggestion;
|
|
14
32
|
this.requestId = requestId;
|
|
33
|
+
defineSDKErrorBrand(this);
|
|
15
34
|
if (Error.captureStackTrace) {
|
|
16
35
|
Error.captureStackTrace(this, new.target);
|
|
17
36
|
}
|
|
@@ -32,6 +51,7 @@ var SDKError = class extends Error {
|
|
|
32
51
|
...this.kind !== void 0 && { kind: this.kind },
|
|
33
52
|
...this.reason !== void 0 && { reason: this.reason },
|
|
34
53
|
...this.rawReason !== void 0 && { rawReason: this.rawReason },
|
|
54
|
+
...this.apiReason !== void 0 && { apiReason: this.apiReason },
|
|
35
55
|
...this.retryable !== void 0 && { retryable: this.retryable },
|
|
36
56
|
...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
|
|
37
57
|
};
|
|
@@ -205,8 +225,16 @@ function enhanceCommerceError(error, body, headerRequestId) {
|
|
|
205
225
|
});
|
|
206
226
|
return error;
|
|
207
227
|
}
|
|
228
|
+
function enhanceNonCommerceError(error, reason) {
|
|
229
|
+
if (typeof reason === "string") Object.assign(error, { apiReason: reason });
|
|
230
|
+
return error;
|
|
231
|
+
}
|
|
232
|
+
function getSDKErrorReason(error) {
|
|
233
|
+
if (error.kind !== "commerce") return error.apiReason;
|
|
234
|
+
return error.reason === "unknown_commerce_error" ? error.rawReason : error.reason;
|
|
235
|
+
}
|
|
208
236
|
function isCommerceSDKError(error) {
|
|
209
|
-
if (!(error
|
|
237
|
+
if (!isSDKError(error) || error.kind !== "commerce") return false;
|
|
210
238
|
if (typeof error.requestId !== "string" || typeof error.retryable !== "boolean" || error.retryAfter !== void 0 && (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0) || typeof error.reason !== "string") {
|
|
211
239
|
return false;
|
|
212
240
|
}
|
|
@@ -216,12 +244,14 @@ var NetworkError = class extends SDKError {
|
|
|
216
244
|
constructor(message, status, details, userMessage, suggestion) {
|
|
217
245
|
super("NETWORK_ERROR", message, status, details, userMessage, suggestion);
|
|
218
246
|
this.name = "NetworkError";
|
|
247
|
+
defineSDKErrorType(this, "NetworkError");
|
|
219
248
|
}
|
|
220
249
|
};
|
|
221
250
|
var ValidationError = class extends SDKError {
|
|
222
251
|
constructor(message, details, userMessage, suggestion, status = 400) {
|
|
223
252
|
super("VALIDATION_ERROR", message, status, details, userMessage, suggestion);
|
|
224
253
|
this.name = "ValidationError";
|
|
254
|
+
defineSDKErrorType(this, "ValidationError");
|
|
225
255
|
}
|
|
226
256
|
};
|
|
227
257
|
var ApiError = class extends SDKError {
|
|
@@ -236,24 +266,28 @@ var ApiError = class extends SDKError {
|
|
|
236
266
|
requestId
|
|
237
267
|
);
|
|
238
268
|
this.name = "ApiError";
|
|
269
|
+
defineSDKErrorType(this, "ApiError");
|
|
239
270
|
}
|
|
240
271
|
};
|
|
241
272
|
var ConfigError = class extends SDKError {
|
|
242
273
|
constructor(message, details, userMessage, suggestion) {
|
|
243
274
|
super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
|
|
244
275
|
this.name = "ConfigError";
|
|
276
|
+
defineSDKErrorType(this, "ConfigError");
|
|
245
277
|
}
|
|
246
278
|
};
|
|
247
279
|
var TimeoutError = class extends SDKError {
|
|
248
280
|
constructor(message = "Request timed out.", details, userMessage, suggestion) {
|
|
249
281
|
super("TIMEOUT_ERROR", message, 408, details, userMessage, suggestion);
|
|
250
282
|
this.name = "TimeoutError";
|
|
283
|
+
defineSDKErrorType(this, "TimeoutError");
|
|
251
284
|
}
|
|
252
285
|
};
|
|
253
286
|
var GoneError = class extends SDKError {
|
|
254
287
|
constructor(message = "The requested resource is no longer available.", details, userMessage, suggestion) {
|
|
255
288
|
super("GONE_ERROR", message, 410, details, userMessage, suggestion);
|
|
256
289
|
this.name = "GoneError";
|
|
290
|
+
defineSDKErrorType(this, "GoneError");
|
|
257
291
|
}
|
|
258
292
|
};
|
|
259
293
|
var ServiceUnavailableError = class extends SDKError {
|
|
@@ -268,6 +302,7 @@ var ServiceUnavailableError = class extends SDKError {
|
|
|
268
302
|
);
|
|
269
303
|
this.name = "ServiceUnavailableError";
|
|
270
304
|
this.retryAfter = retryAfter;
|
|
305
|
+
defineSDKErrorType(this, "ServiceUnavailableError");
|
|
271
306
|
}
|
|
272
307
|
};
|
|
273
308
|
var UsageLimitError = class extends SDKError {
|
|
@@ -275,6 +310,7 @@ var UsageLimitError = class extends SDKError {
|
|
|
275
310
|
super("USAGE_LIMIT_ERROR", message, 429, details, userMessage, suggestion);
|
|
276
311
|
this.name = "UsageLimitError";
|
|
277
312
|
this.usage = usage;
|
|
313
|
+
defineSDKErrorType(this, "UsageLimitError");
|
|
278
314
|
}
|
|
279
315
|
toJSON() {
|
|
280
316
|
return {
|
|
@@ -295,6 +331,7 @@ var AuthError = class extends SDKError {
|
|
|
295
331
|
requestId
|
|
296
332
|
);
|
|
297
333
|
this.name = "AuthError";
|
|
334
|
+
defineSDKErrorType(this, "AuthError");
|
|
298
335
|
}
|
|
299
336
|
};
|
|
300
337
|
var PermissionError = class extends SDKError {
|
|
@@ -309,6 +346,7 @@ var PermissionError = class extends SDKError {
|
|
|
309
346
|
requestId
|
|
310
347
|
);
|
|
311
348
|
this.name = "PermissionError";
|
|
349
|
+
defineSDKErrorType(this, "PermissionError");
|
|
312
350
|
}
|
|
313
351
|
};
|
|
314
352
|
var NotFoundError = class extends SDKError {
|
|
@@ -323,12 +361,14 @@ var NotFoundError = class extends SDKError {
|
|
|
323
361
|
requestId
|
|
324
362
|
);
|
|
325
363
|
this.name = "NotFoundError";
|
|
364
|
+
defineSDKErrorType(this, "NotFoundError");
|
|
326
365
|
}
|
|
327
366
|
};
|
|
328
367
|
var ConflictError = class extends SDKError {
|
|
329
368
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
330
369
|
super("conflict", message, 409, details, userMessage, suggestion, requestId);
|
|
331
370
|
this.name = "ConflictError";
|
|
371
|
+
defineSDKErrorType(this, "ConflictError");
|
|
332
372
|
}
|
|
333
373
|
};
|
|
334
374
|
var RateLimitError = class extends SDKError {
|
|
@@ -344,8 +384,64 @@ var RateLimitError = class extends SDKError {
|
|
|
344
384
|
);
|
|
345
385
|
this.name = "RateLimitError";
|
|
346
386
|
this.retryAfter = retryAfter;
|
|
387
|
+
defineSDKErrorType(this, "RateLimitError");
|
|
347
388
|
}
|
|
348
389
|
};
|
|
390
|
+
function hasBrandedSDKErrorShape(error) {
|
|
391
|
+
if (error === null || typeof error !== "object") return false;
|
|
392
|
+
const candidate = error;
|
|
393
|
+
return candidate[SDK_ERROR_BRAND] === true && typeof candidate.name === "string" && typeof candidate.code === "string" && typeof candidate.message === "string" && (candidate.status === void 0 || typeof candidate.status === "number") && (candidate.userMessage === void 0 || typeof candidate.userMessage === "string") && (candidate.suggestion === void 0 || typeof candidate.suggestion === "string") && (candidate.requestId === void 0 || typeof candidate.requestId === "string") && (candidate.kind === void 0 || candidate.kind === "commerce") && (candidate.reason === void 0 || typeof candidate.reason === "string") && (candidate.rawReason === void 0 || typeof candidate.rawReason === "string") && (candidate.apiReason === void 0 || typeof candidate.apiReason === "string") && (candidate.retryable === void 0 || typeof candidate.retryable === "boolean") && (candidate.retryAfter === void 0 || typeof candidate.retryAfter === "number") && typeof candidate.getUserMessage === "function" && typeof candidate.toJSON === "function";
|
|
394
|
+
}
|
|
395
|
+
function hasSDKErrorType(error, type) {
|
|
396
|
+
return hasBrandedSDKErrorShape(error) && error[SDK_ERROR_TYPE_BRAND] === type;
|
|
397
|
+
}
|
|
398
|
+
function isSDKError(error) {
|
|
399
|
+
return error instanceof SDKError || hasBrandedSDKErrorShape(error);
|
|
400
|
+
}
|
|
401
|
+
function isNetworkError(error) {
|
|
402
|
+
return error instanceof NetworkError || hasSDKErrorType(error, "NetworkError");
|
|
403
|
+
}
|
|
404
|
+
function isValidationError(error) {
|
|
405
|
+
if (error instanceof ValidationError || hasSDKErrorType(error, "ValidationError")) {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
if (error == null || typeof error !== "object") return false;
|
|
409
|
+
const candidate = error;
|
|
410
|
+
return candidate.name === "ValidationError" && candidate.code === "VALIDATION_ERROR" && typeof candidate.message === "string" && typeof candidate.getUserMessage === "function" && typeof candidate.toJSON === "function";
|
|
411
|
+
}
|
|
412
|
+
function isApiError(error) {
|
|
413
|
+
return error instanceof ApiError || hasSDKErrorType(error, "ApiError");
|
|
414
|
+
}
|
|
415
|
+
function isConfigError(error) {
|
|
416
|
+
return error instanceof ConfigError || hasSDKErrorType(error, "ConfigError");
|
|
417
|
+
}
|
|
418
|
+
function isTimeoutError(error) {
|
|
419
|
+
return error instanceof TimeoutError || hasSDKErrorType(error, "TimeoutError");
|
|
420
|
+
}
|
|
421
|
+
function isGoneError(error) {
|
|
422
|
+
return error instanceof GoneError || hasSDKErrorType(error, "GoneError");
|
|
423
|
+
}
|
|
424
|
+
function isServiceUnavailableError(error) {
|
|
425
|
+
return error instanceof ServiceUnavailableError || hasSDKErrorType(error, "ServiceUnavailableError");
|
|
426
|
+
}
|
|
427
|
+
function isUsageLimitError(error) {
|
|
428
|
+
return error instanceof UsageLimitError || hasSDKErrorType(error, "UsageLimitError");
|
|
429
|
+
}
|
|
430
|
+
function isAuthError(error) {
|
|
431
|
+
return error instanceof AuthError || hasSDKErrorType(error, "AuthError");
|
|
432
|
+
}
|
|
433
|
+
function isPermissionError(error) {
|
|
434
|
+
return error instanceof PermissionError || hasSDKErrorType(error, "PermissionError");
|
|
435
|
+
}
|
|
436
|
+
function isNotFoundError(error) {
|
|
437
|
+
return error instanceof NotFoundError || hasSDKErrorType(error, "NotFoundError");
|
|
438
|
+
}
|
|
439
|
+
function isConflictError(error) {
|
|
440
|
+
return error instanceof ConflictError || hasSDKErrorType(error, "ConflictError");
|
|
441
|
+
}
|
|
442
|
+
function isRateLimitError(error) {
|
|
443
|
+
return error instanceof RateLimitError || hasSDKErrorType(error, "RateLimitError");
|
|
444
|
+
}
|
|
349
445
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
350
446
|
var createValidationError = (message, details, userMessage, suggestion, status) => new ValidationError(message, details, userMessage, suggestion, status);
|
|
351
447
|
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
@@ -555,7 +651,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
|
|
|
555
651
|
if (retryAfter !== void 0) {
|
|
556
652
|
Object.assign(withRequestId, { retryAfter });
|
|
557
653
|
}
|
|
558
|
-
return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : withRequestId;
|
|
654
|
+
return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
|
|
559
655
|
};
|
|
560
656
|
if (status === 400 || status === 422) {
|
|
561
657
|
return finalize(
|
|
@@ -742,7 +838,7 @@ async function httpFetch(url, options) {
|
|
|
742
838
|
),
|
|
743
839
|
requestId
|
|
744
840
|
);
|
|
745
|
-
throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : usageError;
|
|
841
|
+
throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
|
|
746
842
|
}
|
|
747
843
|
if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
|
|
748
844
|
hasRetried401 = true;
|
|
@@ -1189,7 +1285,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1189
1285
|
}
|
|
1190
1286
|
const withRequestId = attachRequestId(error, requestId);
|
|
1191
1287
|
if (retryAfter !== void 0) Object.assign(withRequestId, { retryAfter });
|
|
1192
|
-
throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : withRequestId;
|
|
1288
|
+
throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : enhanceNonCommerceError(withRequestId, reason);
|
|
1193
1289
|
}
|
|
1194
1290
|
return data;
|
|
1195
1291
|
}
|
|
@@ -1613,13 +1709,7 @@ function unwrapPayloadDoc(value) {
|
|
|
1613
1709
|
return value;
|
|
1614
1710
|
}
|
|
1615
1711
|
function hasCanonicalNotFoundReason(error) {
|
|
1616
|
-
|
|
1617
|
-
if (typeof details !== "object" || details === null) return false;
|
|
1618
|
-
if ("reason" in details && details.reason === "not_found") return true;
|
|
1619
|
-
if (!("body" in details) || typeof details.body !== "object" || details.body === null) {
|
|
1620
|
-
return false;
|
|
1621
|
-
}
|
|
1622
|
-
return "reason" in details.body && details.body.reason === "not_found";
|
|
1712
|
+
return getSDKErrorReason(error) === "not_found";
|
|
1623
1713
|
}
|
|
1624
1714
|
var CommunityClient = class extends RawCustomerScopedApi {
|
|
1625
1715
|
constructor(options) {
|
|
@@ -3225,9 +3315,77 @@ function validateRequiredReconciliation(value, allowed, resource, path) {
|
|
|
3225
3315
|
function validateNextAction(value, provider, resource, path) {
|
|
3226
3316
|
const action = record(value, resource, path);
|
|
3227
3317
|
if (provider === "portone") {
|
|
3318
|
+
if (action.type === "portone_sdk") {
|
|
3319
|
+
exact(
|
|
3320
|
+
action,
|
|
3321
|
+
[
|
|
3322
|
+
"type",
|
|
3323
|
+
"version",
|
|
3324
|
+
"storeId",
|
|
3325
|
+
"channelKey",
|
|
3326
|
+
"paymentId",
|
|
3327
|
+
"orderName",
|
|
3328
|
+
"totalAmount",
|
|
3329
|
+
"currency",
|
|
3330
|
+
"payMethod",
|
|
3331
|
+
"redirectUrl"
|
|
3332
|
+
],
|
|
3333
|
+
[],
|
|
3334
|
+
resource,
|
|
3335
|
+
path
|
|
3336
|
+
);
|
|
3337
|
+
if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
|
|
3338
|
+
for (const key of ["storeId", "channelKey"]) {
|
|
3339
|
+
boundedString(action[key], 255, resource, `${path}.${key}`);
|
|
3340
|
+
}
|
|
3341
|
+
const paymentId = boundedString(
|
|
3342
|
+
action.paymentId,
|
|
3343
|
+
40,
|
|
3344
|
+
resource,
|
|
3345
|
+
`${path}.paymentId`
|
|
3346
|
+
);
|
|
3347
|
+
if (!/^[A-Za-z0-9]{6,40}$/.test(paymentId)) {
|
|
3348
|
+
fail(
|
|
3349
|
+
resource,
|
|
3350
|
+
`${path}.paymentId`,
|
|
3351
|
+
"6-40 ASCII alphanumeric characters"
|
|
3352
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
boundedString(
|
|
3355
|
+
action.orderName,
|
|
3356
|
+
MAX_COMMERCE_SHORT_TEXT_LENGTH,
|
|
3357
|
+
resource,
|
|
3358
|
+
`${path}.orderName`
|
|
3359
|
+
);
|
|
3360
|
+
positiveInteger(action.totalAmount, resource, `${path}.totalAmount`);
|
|
3361
|
+
if (action.currency !== "CURRENCY_KRW") {
|
|
3362
|
+
fail(resource, `${path}.currency`, "CURRENCY_KRW");
|
|
3363
|
+
}
|
|
3364
|
+
if (action.payMethod !== "CARD")
|
|
3365
|
+
fail(resource, `${path}.payMethod`, "CARD");
|
|
3366
|
+
const redirectUrl = boundedString(
|
|
3367
|
+
action.redirectUrl,
|
|
3368
|
+
2048,
|
|
3369
|
+
resource,
|
|
3370
|
+
`${path}.redirectUrl`
|
|
3371
|
+
);
|
|
3372
|
+
try {
|
|
3373
|
+
const parsed = new URL(redirectUrl);
|
|
3374
|
+
const loopback = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
|
|
3375
|
+
if (!loopback && parsed.protocol !== "https:" || parsed.username || parsed.password)
|
|
3376
|
+
throw new Error("unsafe redirect URL");
|
|
3377
|
+
} catch {
|
|
3378
|
+
fail(
|
|
3379
|
+
resource,
|
|
3380
|
+
`${path}.redirectUrl`,
|
|
3381
|
+
"HTTPS or loopback URL without embedded credentials"
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3384
|
+
return;
|
|
3385
|
+
}
|
|
3228
3386
|
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
3229
3387
|
if (action.type !== "portone_checkout") {
|
|
3230
|
-
fail(resource, `${path}.type`, "portone_checkout");
|
|
3388
|
+
fail(resource, `${path}.type`, "portone_checkout | portone_sdk");
|
|
3231
3389
|
}
|
|
3232
3390
|
const checkoutUrl = boundedString(
|
|
3233
3391
|
action.checkoutUrl,
|
|
@@ -5190,21 +5348,11 @@ var PRODUCT_DETAIL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
|
|
|
5190
5348
|
"not_published",
|
|
5191
5349
|
"feature_disabled"
|
|
5192
5350
|
]);
|
|
5193
|
-
function isRecord(value) {
|
|
5194
|
-
return typeof value === "object" && value !== null;
|
|
5195
|
-
}
|
|
5196
|
-
function readProductDetailUnavailableReason(value) {
|
|
5197
|
-
if (!isRecord(value)) return void 0;
|
|
5198
|
-
const directReason = value.reason ?? value.code;
|
|
5199
|
-
if (typeof directReason === "string" && PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(directReason)) {
|
|
5200
|
-
return directReason;
|
|
5201
|
-
}
|
|
5202
|
-
return readProductDetailUnavailableReason(value.body);
|
|
5203
|
-
}
|
|
5204
5351
|
function productDetailResultFromError(error) {
|
|
5205
5352
|
if (!(error instanceof SDKError) || error.status !== 404) return void 0;
|
|
5206
|
-
const reason =
|
|
5207
|
-
if (!reason
|
|
5353
|
+
const reason = getSDKErrorReason(error);
|
|
5354
|
+
if (!reason || !PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(reason))
|
|
5355
|
+
return void 0;
|
|
5208
5356
|
return { found: false, reason };
|
|
5209
5357
|
}
|
|
5210
5358
|
var MARKET_PRICE_QUERY_UNSUPPORTED_MESSAGE = "Market listing pages do not support base price filters or price sorts.";
|
|
@@ -5731,6 +5879,21 @@ function createClient(options) {
|
|
|
5731
5879
|
export {
|
|
5732
5880
|
Client,
|
|
5733
5881
|
ContentClient,
|
|
5734
|
-
createClient
|
|
5882
|
+
createClient,
|
|
5883
|
+
isApiError,
|
|
5884
|
+
isAuthError,
|
|
5885
|
+
isCommerceSDKError,
|
|
5886
|
+
isConfigError,
|
|
5887
|
+
isConflictError,
|
|
5888
|
+
isGoneError,
|
|
5889
|
+
isNetworkError,
|
|
5890
|
+
isNotFoundError,
|
|
5891
|
+
isPermissionError,
|
|
5892
|
+
isRateLimitError,
|
|
5893
|
+
isSDKError,
|
|
5894
|
+
isServiceUnavailableError,
|
|
5895
|
+
isTimeoutError,
|
|
5896
|
+
isUsageLimitError,
|
|
5897
|
+
isValidationError
|
|
5735
5898
|
};
|
|
5736
5899
|
//# sourceMappingURL=client.js.map
|