@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/realtime.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-CBba4lDo.cjs';
|
|
4
|
+
import './payload-types-MKbx5MuJ.cjs';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-D7HtUpqt.js';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.js';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-DCNV5Kq7.js';
|
|
4
|
+
import './payload-types-MKbx5MuJ.js';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|
package/dist/server.cjs
CHANGED
|
@@ -29,7 +29,22 @@ __export(server_exports, {
|
|
|
29
29
|
ServerCommerceClient: () => ServerCommerceClient,
|
|
30
30
|
ServerPreviewClient: () => ServerPreviewClient,
|
|
31
31
|
TenantIntrospectionApi: () => TenantIntrospectionApi,
|
|
32
|
-
createServerClient: () => createServerClient
|
|
32
|
+
createServerClient: () => createServerClient,
|
|
33
|
+
isApiError: () => isApiError,
|
|
34
|
+
isAuthError: () => isAuthError,
|
|
35
|
+
isCommerceSDKError: () => isCommerceSDKError,
|
|
36
|
+
isConfigError: () => isConfigError,
|
|
37
|
+
isConflictError: () => isConflictError,
|
|
38
|
+
isGoneError: () => isGoneError,
|
|
39
|
+
isNetworkError: () => isNetworkError,
|
|
40
|
+
isNotFoundError: () => isNotFoundError,
|
|
41
|
+
isPermissionError: () => isPermissionError,
|
|
42
|
+
isRateLimitError: () => isRateLimitError,
|
|
43
|
+
isSDKError: () => isSDKError,
|
|
44
|
+
isServiceUnavailableError: () => isServiceUnavailableError,
|
|
45
|
+
isTimeoutError: () => isTimeoutError,
|
|
46
|
+
isUsageLimitError: () => isUsageLimitError,
|
|
47
|
+
isValidationError: () => isValidationError
|
|
33
48
|
});
|
|
34
49
|
module.exports = __toCommonJS(server_exports);
|
|
35
50
|
|
|
@@ -37,6 +52,24 @@ module.exports = __toCommonJS(server_exports);
|
|
|
37
52
|
var import_qs_esm = require("qs-esm");
|
|
38
53
|
|
|
39
54
|
// src/core/errors.ts
|
|
55
|
+
var SDK_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError");
|
|
56
|
+
var SDK_ERROR_TYPE_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError.type");
|
|
57
|
+
function defineSDKErrorBrand(error) {
|
|
58
|
+
Object.defineProperty(error, SDK_ERROR_BRAND, {
|
|
59
|
+
value: true,
|
|
60
|
+
enumerable: false,
|
|
61
|
+
configurable: false,
|
|
62
|
+
writable: false
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function defineSDKErrorType(error, type) {
|
|
66
|
+
Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {
|
|
67
|
+
value: type,
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: false,
|
|
70
|
+
writable: false
|
|
71
|
+
});
|
|
72
|
+
}
|
|
40
73
|
var SDKError = class extends Error {
|
|
41
74
|
constructor(code, message, status, details, userMessage, suggestion, requestId) {
|
|
42
75
|
super(message);
|
|
@@ -47,6 +80,7 @@ var SDKError = class extends Error {
|
|
|
47
80
|
this.userMessage = userMessage;
|
|
48
81
|
this.suggestion = suggestion;
|
|
49
82
|
this.requestId = requestId;
|
|
83
|
+
defineSDKErrorBrand(this);
|
|
50
84
|
if (Error.captureStackTrace) {
|
|
51
85
|
Error.captureStackTrace(this, new.target);
|
|
52
86
|
}
|
|
@@ -67,6 +101,7 @@ var SDKError = class extends Error {
|
|
|
67
101
|
...this.kind !== void 0 && { kind: this.kind },
|
|
68
102
|
...this.reason !== void 0 && { reason: this.reason },
|
|
69
103
|
...this.rawReason !== void 0 && { rawReason: this.rawReason },
|
|
104
|
+
...this.apiReason !== void 0 && { apiReason: this.apiReason },
|
|
70
105
|
...this.retryable !== void 0 && { retryable: this.retryable },
|
|
71
106
|
...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
|
|
72
107
|
};
|
|
@@ -240,8 +275,16 @@ function enhanceCommerceError(error, body, headerRequestId) {
|
|
|
240
275
|
});
|
|
241
276
|
return error;
|
|
242
277
|
}
|
|
278
|
+
function enhanceNonCommerceError(error, reason) {
|
|
279
|
+
if (typeof reason === "string") Object.assign(error, { apiReason: reason });
|
|
280
|
+
return error;
|
|
281
|
+
}
|
|
282
|
+
function getSDKErrorReason(error) {
|
|
283
|
+
if (error.kind !== "commerce") return error.apiReason;
|
|
284
|
+
return error.reason === "unknown_commerce_error" ? error.rawReason : error.reason;
|
|
285
|
+
}
|
|
243
286
|
function isCommerceSDKError(error) {
|
|
244
|
-
if (!(error
|
|
287
|
+
if (!isSDKError(error) || error.kind !== "commerce") return false;
|
|
245
288
|
if (typeof error.requestId !== "string" || typeof error.retryable !== "boolean" || error.retryAfter !== void 0 && (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0) || typeof error.reason !== "string") {
|
|
246
289
|
return false;
|
|
247
290
|
}
|
|
@@ -251,12 +294,14 @@ var NetworkError = class extends SDKError {
|
|
|
251
294
|
constructor(message, status, details, userMessage, suggestion) {
|
|
252
295
|
super("NETWORK_ERROR", message, status, details, userMessage, suggestion);
|
|
253
296
|
this.name = "NetworkError";
|
|
297
|
+
defineSDKErrorType(this, "NetworkError");
|
|
254
298
|
}
|
|
255
299
|
};
|
|
256
300
|
var ValidationError = class extends SDKError {
|
|
257
301
|
constructor(message, details, userMessage, suggestion, status = 400) {
|
|
258
302
|
super("VALIDATION_ERROR", message, status, details, userMessage, suggestion);
|
|
259
303
|
this.name = "ValidationError";
|
|
304
|
+
defineSDKErrorType(this, "ValidationError");
|
|
260
305
|
}
|
|
261
306
|
};
|
|
262
307
|
var ApiError = class extends SDKError {
|
|
@@ -271,24 +316,28 @@ var ApiError = class extends SDKError {
|
|
|
271
316
|
requestId
|
|
272
317
|
);
|
|
273
318
|
this.name = "ApiError";
|
|
319
|
+
defineSDKErrorType(this, "ApiError");
|
|
274
320
|
}
|
|
275
321
|
};
|
|
276
322
|
var ConfigError = class extends SDKError {
|
|
277
323
|
constructor(message, details, userMessage, suggestion) {
|
|
278
324
|
super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
|
|
279
325
|
this.name = "ConfigError";
|
|
326
|
+
defineSDKErrorType(this, "ConfigError");
|
|
280
327
|
}
|
|
281
328
|
};
|
|
282
329
|
var TimeoutError = class extends SDKError {
|
|
283
330
|
constructor(message = "Request timed out.", details, userMessage, suggestion) {
|
|
284
331
|
super("TIMEOUT_ERROR", message, 408, details, userMessage, suggestion);
|
|
285
332
|
this.name = "TimeoutError";
|
|
333
|
+
defineSDKErrorType(this, "TimeoutError");
|
|
286
334
|
}
|
|
287
335
|
};
|
|
288
336
|
var GoneError = class extends SDKError {
|
|
289
337
|
constructor(message = "The requested resource is no longer available.", details, userMessage, suggestion) {
|
|
290
338
|
super("GONE_ERROR", message, 410, details, userMessage, suggestion);
|
|
291
339
|
this.name = "GoneError";
|
|
340
|
+
defineSDKErrorType(this, "GoneError");
|
|
292
341
|
}
|
|
293
342
|
};
|
|
294
343
|
var ServiceUnavailableError = class extends SDKError {
|
|
@@ -303,6 +352,7 @@ var ServiceUnavailableError = class extends SDKError {
|
|
|
303
352
|
);
|
|
304
353
|
this.name = "ServiceUnavailableError";
|
|
305
354
|
this.retryAfter = retryAfter;
|
|
355
|
+
defineSDKErrorType(this, "ServiceUnavailableError");
|
|
306
356
|
}
|
|
307
357
|
};
|
|
308
358
|
var UsageLimitError = class extends SDKError {
|
|
@@ -310,6 +360,7 @@ var UsageLimitError = class extends SDKError {
|
|
|
310
360
|
super("USAGE_LIMIT_ERROR", message, 429, details, userMessage, suggestion);
|
|
311
361
|
this.name = "UsageLimitError";
|
|
312
362
|
this.usage = usage;
|
|
363
|
+
defineSDKErrorType(this, "UsageLimitError");
|
|
313
364
|
}
|
|
314
365
|
toJSON() {
|
|
315
366
|
return {
|
|
@@ -330,6 +381,7 @@ var AuthError = class extends SDKError {
|
|
|
330
381
|
requestId
|
|
331
382
|
);
|
|
332
383
|
this.name = "AuthError";
|
|
384
|
+
defineSDKErrorType(this, "AuthError");
|
|
333
385
|
}
|
|
334
386
|
};
|
|
335
387
|
var PermissionError = class extends SDKError {
|
|
@@ -344,6 +396,7 @@ var PermissionError = class extends SDKError {
|
|
|
344
396
|
requestId
|
|
345
397
|
);
|
|
346
398
|
this.name = "PermissionError";
|
|
399
|
+
defineSDKErrorType(this, "PermissionError");
|
|
347
400
|
}
|
|
348
401
|
};
|
|
349
402
|
var NotFoundError = class extends SDKError {
|
|
@@ -358,12 +411,14 @@ var NotFoundError = class extends SDKError {
|
|
|
358
411
|
requestId
|
|
359
412
|
);
|
|
360
413
|
this.name = "NotFoundError";
|
|
414
|
+
defineSDKErrorType(this, "NotFoundError");
|
|
361
415
|
}
|
|
362
416
|
};
|
|
363
417
|
var ConflictError = class extends SDKError {
|
|
364
418
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
365
419
|
super("conflict", message, 409, details, userMessage, suggestion, requestId);
|
|
366
420
|
this.name = "ConflictError";
|
|
421
|
+
defineSDKErrorType(this, "ConflictError");
|
|
367
422
|
}
|
|
368
423
|
};
|
|
369
424
|
var RateLimitError = class extends SDKError {
|
|
@@ -379,8 +434,64 @@ var RateLimitError = class extends SDKError {
|
|
|
379
434
|
);
|
|
380
435
|
this.name = "RateLimitError";
|
|
381
436
|
this.retryAfter = retryAfter;
|
|
437
|
+
defineSDKErrorType(this, "RateLimitError");
|
|
382
438
|
}
|
|
383
439
|
};
|
|
440
|
+
function hasBrandedSDKErrorShape(error) {
|
|
441
|
+
if (error === null || typeof error !== "object") return false;
|
|
442
|
+
const candidate = error;
|
|
443
|
+
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";
|
|
444
|
+
}
|
|
445
|
+
function hasSDKErrorType(error, type) {
|
|
446
|
+
return hasBrandedSDKErrorShape(error) && error[SDK_ERROR_TYPE_BRAND] === type;
|
|
447
|
+
}
|
|
448
|
+
function isSDKError(error) {
|
|
449
|
+
return error instanceof SDKError || hasBrandedSDKErrorShape(error);
|
|
450
|
+
}
|
|
451
|
+
function isNetworkError(error) {
|
|
452
|
+
return error instanceof NetworkError || hasSDKErrorType(error, "NetworkError");
|
|
453
|
+
}
|
|
454
|
+
function isValidationError(error) {
|
|
455
|
+
if (error instanceof ValidationError || hasSDKErrorType(error, "ValidationError")) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
if (error == null || typeof error !== "object") return false;
|
|
459
|
+
const candidate = error;
|
|
460
|
+
return candidate.name === "ValidationError" && candidate.code === "VALIDATION_ERROR" && typeof candidate.message === "string" && typeof candidate.getUserMessage === "function" && typeof candidate.toJSON === "function";
|
|
461
|
+
}
|
|
462
|
+
function isApiError(error) {
|
|
463
|
+
return error instanceof ApiError || hasSDKErrorType(error, "ApiError");
|
|
464
|
+
}
|
|
465
|
+
function isConfigError(error) {
|
|
466
|
+
return error instanceof ConfigError || hasSDKErrorType(error, "ConfigError");
|
|
467
|
+
}
|
|
468
|
+
function isTimeoutError(error) {
|
|
469
|
+
return error instanceof TimeoutError || hasSDKErrorType(error, "TimeoutError");
|
|
470
|
+
}
|
|
471
|
+
function isGoneError(error) {
|
|
472
|
+
return error instanceof GoneError || hasSDKErrorType(error, "GoneError");
|
|
473
|
+
}
|
|
474
|
+
function isServiceUnavailableError(error) {
|
|
475
|
+
return error instanceof ServiceUnavailableError || hasSDKErrorType(error, "ServiceUnavailableError");
|
|
476
|
+
}
|
|
477
|
+
function isUsageLimitError(error) {
|
|
478
|
+
return error instanceof UsageLimitError || hasSDKErrorType(error, "UsageLimitError");
|
|
479
|
+
}
|
|
480
|
+
function isAuthError(error) {
|
|
481
|
+
return error instanceof AuthError || hasSDKErrorType(error, "AuthError");
|
|
482
|
+
}
|
|
483
|
+
function isPermissionError(error) {
|
|
484
|
+
return error instanceof PermissionError || hasSDKErrorType(error, "PermissionError");
|
|
485
|
+
}
|
|
486
|
+
function isNotFoundError(error) {
|
|
487
|
+
return error instanceof NotFoundError || hasSDKErrorType(error, "NotFoundError");
|
|
488
|
+
}
|
|
489
|
+
function isConflictError(error) {
|
|
490
|
+
return error instanceof ConflictError || hasSDKErrorType(error, "ConflictError");
|
|
491
|
+
}
|
|
492
|
+
function isRateLimitError(error) {
|
|
493
|
+
return error instanceof RateLimitError || hasSDKErrorType(error, "RateLimitError");
|
|
494
|
+
}
|
|
384
495
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
385
496
|
var createValidationError = (message, details, userMessage, suggestion, status) => new ValidationError(message, details, userMessage, suggestion, status);
|
|
386
497
|
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
@@ -590,7 +701,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
|
|
|
590
701
|
if (retryAfter !== void 0) {
|
|
591
702
|
Object.assign(withRequestId, { retryAfter });
|
|
592
703
|
}
|
|
593
|
-
return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : withRequestId;
|
|
704
|
+
return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
|
|
594
705
|
};
|
|
595
706
|
if (status === 400 || status === 422) {
|
|
596
707
|
return finalize(
|
|
@@ -777,7 +888,7 @@ async function httpFetch(url, options) {
|
|
|
777
888
|
),
|
|
778
889
|
requestId
|
|
779
890
|
);
|
|
780
|
-
throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : usageError;
|
|
891
|
+
throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
|
|
781
892
|
}
|
|
782
893
|
if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
|
|
783
894
|
hasRetried401 = true;
|
|
@@ -1499,7 +1610,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1499
1610
|
}
|
|
1500
1611
|
const withRequestId = attachRequestId(error, requestId);
|
|
1501
1612
|
if (retryAfter !== void 0) Object.assign(withRequestId, { retryAfter });
|
|
1502
|
-
throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : withRequestId;
|
|
1613
|
+
throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : enhanceNonCommerceError(withRequestId, reason);
|
|
1503
1614
|
}
|
|
1504
1615
|
return data;
|
|
1505
1616
|
}
|
|
@@ -1923,13 +2034,7 @@ function unwrapPayloadDoc(value) {
|
|
|
1923
2034
|
return value;
|
|
1924
2035
|
}
|
|
1925
2036
|
function hasCanonicalNotFoundReason(error) {
|
|
1926
|
-
|
|
1927
|
-
if (typeof details !== "object" || details === null) return false;
|
|
1928
|
-
if ("reason" in details && details.reason === "not_found") return true;
|
|
1929
|
-
if (!("body" in details) || typeof details.body !== "object" || details.body === null) {
|
|
1930
|
-
return false;
|
|
1931
|
-
}
|
|
1932
|
-
return "reason" in details.body && details.body.reason === "not_found";
|
|
2037
|
+
return getSDKErrorReason(error) === "not_found";
|
|
1933
2038
|
}
|
|
1934
2039
|
var CommunityClient = class extends RawCustomerScopedApi {
|
|
1935
2040
|
constructor(options) {
|
|
@@ -3389,9 +3494,77 @@ function validateRequiredReconciliation(value, allowed, resource, path) {
|
|
|
3389
3494
|
function validateNextAction(value, provider, resource, path) {
|
|
3390
3495
|
const action = record(value, resource, path);
|
|
3391
3496
|
if (provider === "portone") {
|
|
3497
|
+
if (action.type === "portone_sdk") {
|
|
3498
|
+
exact(
|
|
3499
|
+
action,
|
|
3500
|
+
[
|
|
3501
|
+
"type",
|
|
3502
|
+
"version",
|
|
3503
|
+
"storeId",
|
|
3504
|
+
"channelKey",
|
|
3505
|
+
"paymentId",
|
|
3506
|
+
"orderName",
|
|
3507
|
+
"totalAmount",
|
|
3508
|
+
"currency",
|
|
3509
|
+
"payMethod",
|
|
3510
|
+
"redirectUrl"
|
|
3511
|
+
],
|
|
3512
|
+
[],
|
|
3513
|
+
resource,
|
|
3514
|
+
path
|
|
3515
|
+
);
|
|
3516
|
+
if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
|
|
3517
|
+
for (const key of ["storeId", "channelKey"]) {
|
|
3518
|
+
boundedString(action[key], 255, resource, `${path}.${key}`);
|
|
3519
|
+
}
|
|
3520
|
+
const paymentId = boundedString(
|
|
3521
|
+
action.paymentId,
|
|
3522
|
+
40,
|
|
3523
|
+
resource,
|
|
3524
|
+
`${path}.paymentId`
|
|
3525
|
+
);
|
|
3526
|
+
if (!/^[A-Za-z0-9]{6,40}$/.test(paymentId)) {
|
|
3527
|
+
fail(
|
|
3528
|
+
resource,
|
|
3529
|
+
`${path}.paymentId`,
|
|
3530
|
+
"6-40 ASCII alphanumeric characters"
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
boundedString(
|
|
3534
|
+
action.orderName,
|
|
3535
|
+
MAX_COMMERCE_SHORT_TEXT_LENGTH,
|
|
3536
|
+
resource,
|
|
3537
|
+
`${path}.orderName`
|
|
3538
|
+
);
|
|
3539
|
+
positiveInteger(action.totalAmount, resource, `${path}.totalAmount`);
|
|
3540
|
+
if (action.currency !== "CURRENCY_KRW") {
|
|
3541
|
+
fail(resource, `${path}.currency`, "CURRENCY_KRW");
|
|
3542
|
+
}
|
|
3543
|
+
if (action.payMethod !== "CARD")
|
|
3544
|
+
fail(resource, `${path}.payMethod`, "CARD");
|
|
3545
|
+
const redirectUrl = boundedString(
|
|
3546
|
+
action.redirectUrl,
|
|
3547
|
+
2048,
|
|
3548
|
+
resource,
|
|
3549
|
+
`${path}.redirectUrl`
|
|
3550
|
+
);
|
|
3551
|
+
try {
|
|
3552
|
+
const parsed = new URL(redirectUrl);
|
|
3553
|
+
const loopback = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
|
|
3554
|
+
if (!loopback && parsed.protocol !== "https:" || parsed.username || parsed.password)
|
|
3555
|
+
throw new Error("unsafe redirect URL");
|
|
3556
|
+
} catch {
|
|
3557
|
+
fail(
|
|
3558
|
+
resource,
|
|
3559
|
+
`${path}.redirectUrl`,
|
|
3560
|
+
"HTTPS or loopback URL without embedded credentials"
|
|
3561
|
+
);
|
|
3562
|
+
}
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3392
3565
|
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
3393
3566
|
if (action.type !== "portone_checkout") {
|
|
3394
|
-
fail(resource, `${path}.type`, "portone_checkout");
|
|
3567
|
+
fail(resource, `${path}.type`, "portone_checkout | portone_sdk");
|
|
3395
3568
|
}
|
|
3396
3569
|
const checkoutUrl = boundedString(
|
|
3397
3570
|
action.checkoutUrl,
|
|
@@ -4788,21 +4961,11 @@ var PRODUCT_DETAIL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
|
|
|
4788
4961
|
"not_published",
|
|
4789
4962
|
"feature_disabled"
|
|
4790
4963
|
]);
|
|
4791
|
-
function isRecord(value) {
|
|
4792
|
-
return typeof value === "object" && value !== null;
|
|
4793
|
-
}
|
|
4794
|
-
function readProductDetailUnavailableReason(value) {
|
|
4795
|
-
if (!isRecord(value)) return void 0;
|
|
4796
|
-
const directReason = value.reason ?? value.code;
|
|
4797
|
-
if (typeof directReason === "string" && PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(directReason)) {
|
|
4798
|
-
return directReason;
|
|
4799
|
-
}
|
|
4800
|
-
return readProductDetailUnavailableReason(value.body);
|
|
4801
|
-
}
|
|
4802
4964
|
function productDetailResultFromError(error) {
|
|
4803
4965
|
if (!(error instanceof SDKError) || error.status !== 404) return void 0;
|
|
4804
|
-
const reason =
|
|
4805
|
-
if (!reason
|
|
4966
|
+
const reason = getSDKErrorReason(error);
|
|
4967
|
+
if (!reason || !PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(reason))
|
|
4968
|
+
return void 0;
|
|
4806
4969
|
return { found: false, reason };
|
|
4807
4970
|
}
|
|
4808
4971
|
var MARKET_PRICE_QUERY_UNSUPPORTED_MESSAGE = "Market listing pages do not support base price filters or price sorts.";
|