@01.software/sdk 0.49.0 → 0.56.1
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 +257 -1
- package/MIGRATION.md +56 -0
- package/README.md +269 -56
- package/dist/client.cjs +608 -190
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +608 -190
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-Bmr53saa.d.ts} +6 -4
- package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-DxuBDso_.d.cts} +6 -4
- package/dist/{const-CBba4lDo.d.cts → const-BKUqg96Q.d.ts} +5 -5
- package/dist/{const-DCNV5Kq7.d.ts → const-Cv1DCsp6.d.cts} +5 -5
- package/dist/embedded-admin/server.cjs +306 -0
- package/dist/embedded-admin/server.cjs.map +1 -0
- package/dist/embedded-admin/server.d.cts +33 -0
- package/dist/embedded-admin/server.d.ts +33 -0
- package/dist/embedded-admin/server.js +288 -0
- package/dist/embedded-admin/server.js.map +1 -0
- package/dist/embedded-admin.cjs +400 -0
- package/dist/embedded-admin.cjs.map +1 -0
- package/dist/embedded-admin.d.cts +61 -0
- package/dist/embedded-admin.d.ts +61 -0
- package/dist/embedded-admin.js +377 -0
- package/dist/embedded-admin.js.map +1 -0
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/{index-DUuIqUS8.d.ts → index-CGsT4AQ8.d.cts} +89 -10
- package/dist/{index-CbKyoEzy.d.cts → index-DFHLLqYu.d.ts} +89 -10
- package/dist/index.cjs +752 -436
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -69
- package/dist/index.d.ts +12 -69
- package/dist/index.js +752 -436
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-Bk-duc5k.d.cts} +545 -141
- package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-Bk-duc5k.d.ts} +545 -141
- package/dist/query.cjs +108 -71
- 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 +108 -71
- 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 +502 -175
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.js +502 -175
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +1 -0
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +1 -0
- package/dist/storefront-cache.js.map +1 -1
- package/dist/{types-1UeOk1Uy.d.cts → types-CEK8uTvU.d.ts} +287 -30
- package/dist/{types-BKr_2avj.d.cts → types-CNdpj2fI.d.cts} +2 -2
- package/dist/{types-L_nh-ED7.d.ts → types-D4mjGFj4.d.ts} +2 -2
- package/dist/{types-Du4s5anw.d.ts → types-Dhk5NX7Z.d.cts} +287 -30
- 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.cjs +135 -80
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +21 -5
- package/dist/webhook.d.ts +21 -5
- package/dist/webhook.js +135 -80
- package/dist/webhook.js.map +1 -1
- package/package.json +28 -6
package/dist/server.js
CHANGED
|
@@ -97,6 +97,7 @@ var COMMERCE_ERROR_CODES = [
|
|
|
97
97
|
"payment_session_not_cancelable",
|
|
98
98
|
"payment_session_conflict",
|
|
99
99
|
"provider_identity_mismatch",
|
|
100
|
+
"managed_refund_attestation_forbidden",
|
|
100
101
|
"payment_method_unavailable",
|
|
101
102
|
"provider_unavailable",
|
|
102
103
|
"lock_timeout",
|
|
@@ -639,11 +640,11 @@ function parseRetryAfter(response) {
|
|
|
639
640
|
permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
|
|
640
641
|
};
|
|
641
642
|
}
|
|
642
|
-
function mapResponseToError(status, parsed, details, requestId, retryAfter,
|
|
643
|
+
function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
|
|
643
644
|
const errorDetails = {
|
|
644
645
|
...details,
|
|
645
646
|
...parsed.errors && { errors: parsed.errors },
|
|
646
|
-
|
|
647
|
+
...!canonicalCommerceError && parsed.body && { body: parsed.body }
|
|
647
648
|
};
|
|
648
649
|
const suggestion = getParsedErrorSuggestion(status, parsed);
|
|
649
650
|
const finalize = (error) => {
|
|
@@ -651,7 +652,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
|
|
|
651
652
|
if (retryAfter !== void 0) {
|
|
652
653
|
Object.assign(withRequestId, { retryAfter });
|
|
653
654
|
}
|
|
654
|
-
return
|
|
655
|
+
return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
|
|
655
656
|
};
|
|
656
657
|
if (status === 400 || status === 422) {
|
|
657
658
|
return finalize(
|
|
@@ -757,6 +758,7 @@ async function httpFetch(url, options) {
|
|
|
757
758
|
retry,
|
|
758
759
|
onUnauthorized,
|
|
759
760
|
errorFamily,
|
|
761
|
+
typedCommerceErrorReasons,
|
|
760
762
|
...requestInit
|
|
761
763
|
} = options || {};
|
|
762
764
|
const baseUrl = resolveApiUrl(apiUrl);
|
|
@@ -810,7 +812,8 @@ async function httpFetch(url, options) {
|
|
|
810
812
|
});
|
|
811
813
|
if (!response.ok) {
|
|
812
814
|
const parsed = await parseErrorBody(response);
|
|
813
|
-
const
|
|
815
|
+
const canonicalCommerceError = errorFamily === "commerce" || typeof parsed.reason === "string" && typedCommerceErrorReasons?.includes(parsed.reason) === true;
|
|
816
|
+
const commerceEnvelope = canonicalCommerceError ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
|
|
814
817
|
if (isUsageLimitExceededResponse(response)) {
|
|
815
818
|
const limit = parseInt(
|
|
816
819
|
response.headers.get("X-Usage-Limit") || "0",
|
|
@@ -838,7 +841,7 @@ async function httpFetch(url, options) {
|
|
|
838
841
|
),
|
|
839
842
|
requestId
|
|
840
843
|
);
|
|
841
|
-
throw
|
|
844
|
+
throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
|
|
842
845
|
}
|
|
843
846
|
if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
|
|
844
847
|
hasRetried401 = true;
|
|
@@ -863,7 +866,7 @@ async function httpFetch(url, options) {
|
|
|
863
866
|
details,
|
|
864
867
|
requestId,
|
|
865
868
|
retryAfter.seconds,
|
|
866
|
-
|
|
869
|
+
canonicalCommerceError
|
|
867
870
|
);
|
|
868
871
|
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
869
872
|
const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
|
|
@@ -1041,15 +1044,15 @@ var HttpClient = class {
|
|
|
1041
1044
|
throw err;
|
|
1042
1045
|
}
|
|
1043
1046
|
}
|
|
1044
|
-
buildUrl(
|
|
1045
|
-
if (!options) return
|
|
1047
|
+
buildUrl(endpoint, options) {
|
|
1048
|
+
if (!options) return endpoint;
|
|
1046
1049
|
const { fallbackLocale, ...rest } = options;
|
|
1047
1050
|
const queryOptions = fallbackLocale === void 0 ? rest : {
|
|
1048
1051
|
...rest,
|
|
1049
1052
|
"fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
|
|
1050
1053
|
};
|
|
1051
1054
|
const queryString = stringify(queryOptions, { addQueryPrefix: true });
|
|
1052
|
-
return queryString ? `${
|
|
1055
|
+
return queryString ? `${endpoint}${queryString}` : endpoint;
|
|
1053
1056
|
}
|
|
1054
1057
|
assertJsonResponse(response) {
|
|
1055
1058
|
const contentType = response.headers.get("content-type");
|
|
@@ -1240,16 +1243,16 @@ var CollectionQueryBuilder = class {
|
|
|
1240
1243
|
* @returns Payload CMS mutation response with doc and message
|
|
1241
1244
|
*/
|
|
1242
1245
|
async create(data, options) {
|
|
1243
|
-
const
|
|
1246
|
+
const endpoint = `/api/${String(this.collection)}`;
|
|
1244
1247
|
if (options?.file) {
|
|
1245
1248
|
return this.api.requestCreateWithFile(
|
|
1246
|
-
|
|
1249
|
+
endpoint,
|
|
1247
1250
|
data,
|
|
1248
1251
|
options.file,
|
|
1249
1252
|
options.filename
|
|
1250
1253
|
);
|
|
1251
1254
|
}
|
|
1252
|
-
return this.api.requestCreate(
|
|
1255
|
+
return this.api.requestCreate(endpoint, data);
|
|
1253
1256
|
}
|
|
1254
1257
|
/**
|
|
1255
1258
|
* Update a document by ID
|
|
@@ -1257,16 +1260,16 @@ var CollectionQueryBuilder = class {
|
|
|
1257
1260
|
* @returns Payload CMS mutation response with doc and message
|
|
1258
1261
|
*/
|
|
1259
1262
|
async update(id, data, options) {
|
|
1260
|
-
const
|
|
1263
|
+
const endpoint = `/api/${String(this.collection)}/${String(id)}`;
|
|
1261
1264
|
if (options?.file) {
|
|
1262
1265
|
return this.api.requestUpdateWithFile(
|
|
1263
|
-
|
|
1266
|
+
endpoint,
|
|
1264
1267
|
data,
|
|
1265
1268
|
options.file,
|
|
1266
1269
|
options.filename
|
|
1267
1270
|
);
|
|
1268
1271
|
}
|
|
1269
|
-
return this.api.requestUpdate(
|
|
1272
|
+
return this.api.requestUpdate(endpoint, data);
|
|
1270
1273
|
}
|
|
1271
1274
|
/**
|
|
1272
1275
|
* Count documents
|
|
@@ -1362,8 +1365,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1362
1365
|
* Find documents (list query)
|
|
1363
1366
|
* GET /api/{collection}
|
|
1364
1367
|
*/
|
|
1365
|
-
async requestFind(
|
|
1366
|
-
const url = this.buildUrl(
|
|
1368
|
+
async requestFind(endpoint, options) {
|
|
1369
|
+
const url = this.buildUrl(endpoint, options);
|
|
1367
1370
|
const response = await this.fetchWithTracking(url, {
|
|
1368
1371
|
...this.defaultOptions,
|
|
1369
1372
|
method: "GET"
|
|
@@ -1374,8 +1377,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1374
1377
|
* Find-like response from a custom endpoint
|
|
1375
1378
|
* POST /api/...custom-endpoint
|
|
1376
1379
|
*/
|
|
1377
|
-
async requestFindEndpoint(
|
|
1378
|
-
const response = await this.fetchWithTracking(
|
|
1380
|
+
async requestFindEndpoint(endpoint, data) {
|
|
1381
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1379
1382
|
...this.defaultOptions,
|
|
1380
1383
|
method: "POST",
|
|
1381
1384
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1385,8 +1388,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1385
1388
|
/**
|
|
1386
1389
|
* Find-like response from a cacheable GET custom endpoint.
|
|
1387
1390
|
*/
|
|
1388
|
-
async requestFindEndpointGet(
|
|
1389
|
-
const response = await this.fetchWithTracking(
|
|
1391
|
+
async requestFindEndpointGet(endpoint) {
|
|
1392
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1390
1393
|
...this.defaultOptions,
|
|
1391
1394
|
method: "GET"
|
|
1392
1395
|
});
|
|
@@ -1396,8 +1399,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1396
1399
|
* Find document by ID
|
|
1397
1400
|
* GET /api/{collection}/{id}
|
|
1398
1401
|
*/
|
|
1399
|
-
async requestFindById(
|
|
1400
|
-
const url = this.buildUrl(
|
|
1402
|
+
async requestFindById(endpoint, options) {
|
|
1403
|
+
const url = this.buildUrl(endpoint, options);
|
|
1401
1404
|
const response = await this.fetchWithTracking(url, {
|
|
1402
1405
|
...this.defaultOptions,
|
|
1403
1406
|
method: "GET"
|
|
@@ -1408,8 +1411,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1408
1411
|
* Create document
|
|
1409
1412
|
* POST /api/{collection}
|
|
1410
1413
|
*/
|
|
1411
|
-
async requestCreate(
|
|
1412
|
-
const response = await this.fetchWithTracking(
|
|
1414
|
+
async requestCreate(endpoint, data) {
|
|
1415
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1413
1416
|
...this.defaultOptions,
|
|
1414
1417
|
method: "POST",
|
|
1415
1418
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1420,8 +1423,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1420
1423
|
* Update document
|
|
1421
1424
|
* PATCH /api/{collection}/{id}
|
|
1422
1425
|
*/
|
|
1423
|
-
async requestUpdate(
|
|
1424
|
-
const response = await this.fetchWithTracking(
|
|
1426
|
+
async requestUpdate(endpoint, data) {
|
|
1427
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1425
1428
|
...this.defaultOptions,
|
|
1426
1429
|
method: "PATCH",
|
|
1427
1430
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1432,8 +1435,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1432
1435
|
* Count documents
|
|
1433
1436
|
* GET /api/{collection}/count
|
|
1434
1437
|
*/
|
|
1435
|
-
async requestCount(
|
|
1436
|
-
const url = this.buildUrl(
|
|
1438
|
+
async requestCount(endpoint, options) {
|
|
1439
|
+
const url = this.buildUrl(endpoint, options);
|
|
1437
1440
|
const response = await this.fetchWithTracking(url, {
|
|
1438
1441
|
...this.defaultOptions,
|
|
1439
1442
|
method: "GET"
|
|
@@ -1444,8 +1447,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1444
1447
|
* Update multiple documents (bulk update)
|
|
1445
1448
|
* PATCH /api/{collection}
|
|
1446
1449
|
*/
|
|
1447
|
-
async requestUpdateMany(
|
|
1448
|
-
const response = await this.fetchWithTracking(
|
|
1450
|
+
async requestUpdateMany(endpoint, data) {
|
|
1451
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1449
1452
|
...this.defaultOptions,
|
|
1450
1453
|
method: "PATCH",
|
|
1451
1454
|
body: JSON.stringify(data)
|
|
@@ -1456,8 +1459,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1456
1459
|
* Delete document
|
|
1457
1460
|
* DELETE /api/{collection}/{id}
|
|
1458
1461
|
*/
|
|
1459
|
-
async requestDelete(
|
|
1460
|
-
const url = this.buildUrl(
|
|
1462
|
+
async requestDelete(endpoint, options) {
|
|
1463
|
+
const url = this.buildUrl(endpoint, options);
|
|
1461
1464
|
const response = await this.fetchWithTracking(url, {
|
|
1462
1465
|
...this.defaultOptions,
|
|
1463
1466
|
method: "DELETE"
|
|
@@ -1468,8 +1471,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1468
1471
|
* Delete multiple documents (bulk delete)
|
|
1469
1472
|
* DELETE /api/{collection}
|
|
1470
1473
|
*/
|
|
1471
|
-
async requestDeleteMany(
|
|
1472
|
-
const response = await this.fetchWithTracking(
|
|
1474
|
+
async requestDeleteMany(endpoint, data) {
|
|
1475
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1473
1476
|
...this.defaultOptions,
|
|
1474
1477
|
method: "DELETE",
|
|
1475
1478
|
body: JSON.stringify(data)
|
|
@@ -1480,8 +1483,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1480
1483
|
* Create document with file upload
|
|
1481
1484
|
* POST /api/{collection} (multipart/form-data)
|
|
1482
1485
|
*/
|
|
1483
|
-
async requestCreateWithFile(
|
|
1484
|
-
const response = await this.fetchWithTracking(
|
|
1486
|
+
async requestCreateWithFile(endpoint, data, file, filename) {
|
|
1487
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1485
1488
|
...this.defaultOptions,
|
|
1486
1489
|
method: "POST",
|
|
1487
1490
|
body: buildPayloadFormData(data, file, filename)
|
|
@@ -1492,8 +1495,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1492
1495
|
* Update document with file upload
|
|
1493
1496
|
* PATCH /api/{collection}/{id} (multipart/form-data)
|
|
1494
1497
|
*/
|
|
1495
|
-
async requestUpdateWithFile(
|
|
1496
|
-
const response = await this.fetchWithTracking(
|
|
1498
|
+
async requestUpdateWithFile(endpoint, data, file, filename) {
|
|
1499
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1497
1500
|
...this.defaultOptions,
|
|
1498
1501
|
method: "PATCH",
|
|
1499
1502
|
body: buildPayloadFormData(data, file, filename)
|
|
@@ -1508,7 +1511,7 @@ var ServerCollectionClient = class extends CollectionClient {
|
|
|
1508
1511
|
};
|
|
1509
1512
|
|
|
1510
1513
|
// src/core/api/parse-response.ts
|
|
1511
|
-
async function parseApiResponse(response,
|
|
1514
|
+
async function parseApiResponse(response, endpoint, options = {}) {
|
|
1512
1515
|
if (response.status === 204 || response.headers.get("content-length") === "0") {
|
|
1513
1516
|
return void 0;
|
|
1514
1517
|
}
|
|
@@ -1517,7 +1520,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1517
1520
|
parsed = await response.json();
|
|
1518
1521
|
} catch {
|
|
1519
1522
|
throw createApiError(
|
|
1520
|
-
`Invalid JSON response from ${
|
|
1523
|
+
`Invalid JSON response from ${endpoint}`,
|
|
1521
1524
|
response.status,
|
|
1522
1525
|
void 0,
|
|
1523
1526
|
"Server returned an invalid response.",
|
|
@@ -1567,6 +1570,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1567
1570
|
|
|
1568
1571
|
// ../../internal/http-contracts/src/index.ts
|
|
1569
1572
|
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
1573
|
+
var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
|
|
1570
1574
|
var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
1571
1575
|
[operationBrand]: true,
|
|
1572
1576
|
collection,
|
|
@@ -1575,6 +1579,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
|
1575
1579
|
...errorFamily && { errorFamily }
|
|
1576
1580
|
});
|
|
1577
1581
|
var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
|
|
1582
|
+
var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
|
|
1583
|
+
...operation(collection, method, path),
|
|
1584
|
+
typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
|
|
1585
|
+
});
|
|
1578
1586
|
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
1579
1587
|
products: {
|
|
1580
1588
|
detail: operation("products", "get", "/detail"),
|
|
@@ -1606,7 +1614,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1606
1614
|
confirmPayment: operation("orders", "post", "/confirm-payment"),
|
|
1607
1615
|
byPayment: operation("orders", "get", "/by-payment"),
|
|
1608
1616
|
cancel: operation("orders", "post", "/cancel"),
|
|
1609
|
-
resolveCancelRefund:
|
|
1617
|
+
resolveCancelRefund: selectiveCommerceOperation(
|
|
1618
|
+
"orders",
|
|
1619
|
+
"post",
|
|
1620
|
+
"/resolve-cancel-refund",
|
|
1621
|
+
["managed_refund_attestation_forbidden"]
|
|
1622
|
+
),
|
|
1610
1623
|
checkout: strictCommerceOperation("orders", "post", "/checkout"),
|
|
1611
1624
|
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
1612
1625
|
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
@@ -1615,6 +1628,11 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1615
1628
|
detail: strictCommerceOperation("checkouts", "post", "/detail"),
|
|
1616
1629
|
query: strictCommerceOperation("checkouts", "post", "/query")
|
|
1617
1630
|
},
|
|
1631
|
+
draftOrders: {
|
|
1632
|
+
calculate: operation("draft-orders", "post", "/:id/calculate"),
|
|
1633
|
+
complete: operation("draft-orders", "post", "/:id/complete"),
|
|
1634
|
+
finalize: operation("draft-orders", "post", "/:id/finalize")
|
|
1635
|
+
},
|
|
1618
1636
|
transactions: {
|
|
1619
1637
|
update: operation("transactions", "post", "/update")
|
|
1620
1638
|
},
|
|
@@ -1677,6 +1695,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1677
1695
|
"payment-sessions",
|
|
1678
1696
|
"post",
|
|
1679
1697
|
"/server/confirm"
|
|
1698
|
+
),
|
|
1699
|
+
findPortOne: strictCommerceOperation(
|
|
1700
|
+
"payment-sessions",
|
|
1701
|
+
"post",
|
|
1702
|
+
"/server/portone/find"
|
|
1703
|
+
),
|
|
1704
|
+
reconcilePortOne: strictCommerceOperation(
|
|
1705
|
+
"payment-sessions",
|
|
1706
|
+
"post",
|
|
1707
|
+
"/server/portone/reconcile"
|
|
1680
1708
|
)
|
|
1681
1709
|
},
|
|
1682
1710
|
custom: {
|
|
@@ -1696,12 +1724,34 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1696
1724
|
validate: operation("discounts", "post", "/validate")
|
|
1697
1725
|
}
|
|
1698
1726
|
};
|
|
1727
|
+
var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
|
|
1728
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
|
|
1729
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
|
|
1730
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
|
|
1731
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
1732
|
+
]);
|
|
1699
1733
|
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
1700
1734
|
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
1701
1735
|
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
1702
|
-
me: operation(null, "get", "/memberships/me")
|
|
1736
|
+
me: operation(null, "get", "/memberships/me"),
|
|
1737
|
+
chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
|
|
1738
|
+
refundResult: operation(null, "post", "/memberships/:id/refund-result"),
|
|
1739
|
+
revoke: operation(null, "post", "/memberships/:id/revoke")
|
|
1740
|
+
};
|
|
1741
|
+
var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
|
|
1742
|
+
members: operation("customer-groups", "get", "/:id/members"),
|
|
1743
|
+
grant: operation("customer-groups", "post", "/:id/members/grant"),
|
|
1744
|
+
revoke: operation("customer-groups", "post", "/:id/members/revoke")
|
|
1745
|
+
};
|
|
1746
|
+
var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
|
|
1747
|
+
show: operation("tenants", "get", "/embedded-admin-app"),
|
|
1748
|
+
configure: operation("tenants", "patch", "/embedded-admin-app"),
|
|
1749
|
+
disable: operation("tenants", "delete", "/embedded-admin-app")
|
|
1703
1750
|
};
|
|
1704
1751
|
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
1752
|
+
events: {
|
|
1753
|
+
convertSchedule: operation("events", "post", "/:id/schedule")
|
|
1754
|
+
},
|
|
1705
1755
|
occurrences: {
|
|
1706
1756
|
range: operation("event-occurrences", "get", "/range"),
|
|
1707
1757
|
admissionAvailability: operation(
|
|
@@ -1742,46 +1792,54 @@ function resolveOperationMethod(descriptor) {
|
|
|
1742
1792
|
}
|
|
1743
1793
|
|
|
1744
1794
|
// src/core/api/endpoints.ts
|
|
1745
|
-
var endpoint = (method, path) => ({ method, path });
|
|
1746
1795
|
var sharedEndpoint = (descriptor) => descriptor;
|
|
1747
|
-
function resolveOperationMethod2(descriptor) {
|
|
1748
|
-
return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
|
|
1749
|
-
}
|
|
1750
1796
|
function resolveOperationErrorFamily(descriptor) {
|
|
1751
|
-
return
|
|
1797
|
+
return descriptor.errorFamily;
|
|
1752
1798
|
}
|
|
1753
|
-
function
|
|
1754
|
-
|
|
1755
|
-
return resolveOperationPath(descriptor, options);
|
|
1756
|
-
}
|
|
1757
|
-
const query = options?.query?.toString().replace(/^\?/, "");
|
|
1758
|
-
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
1799
|
+
function resolveOperationTypedCommerceErrorReasons(descriptor) {
|
|
1800
|
+
return descriptor.typedCommerceErrorReasons;
|
|
1759
1801
|
}
|
|
1760
1802
|
var COMMERCE_ENDPOINTS = {
|
|
1761
1803
|
products: {
|
|
1762
|
-
detail:
|
|
1763
|
-
detailCatalog:
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1804
|
+
detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
|
|
1805
|
+
detailCatalog: sharedEndpoint(
|
|
1806
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
|
|
1807
|
+
),
|
|
1808
|
+
listingGroups: sharedEndpoint(
|
|
1809
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
|
|
1810
|
+
),
|
|
1811
|
+
listingGroupsCatalog: sharedEndpoint(
|
|
1812
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
|
|
1813
|
+
),
|
|
1814
|
+
// The manifest keeps the GET read and the POST body-query apart; this
|
|
1815
|
+
// semantic name has always resolved to the GET one.
|
|
1816
|
+
listingGroupsQuery: sharedEndpoint(
|
|
1817
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
|
|
1818
|
+
),
|
|
1819
|
+
listingGroupsQueryCatalog: sharedEndpoint(
|
|
1820
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
|
|
1821
|
+
),
|
|
1822
|
+
stockCheck: sharedEndpoint(
|
|
1823
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
|
|
1768
1824
|
),
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
"GET",
|
|
1772
|
-
"/api/products/listing-groups/query/catalog"
|
|
1825
|
+
stockSnapshot: sharedEndpoint(
|
|
1826
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
|
|
1773
1827
|
),
|
|
1774
|
-
|
|
1775
|
-
stockSnapshot: endpoint("GET", "/api/products/stock"),
|
|
1776
|
-
upsert: endpoint("POST", "/api/products/upsert")
|
|
1828
|
+
upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
|
|
1777
1829
|
},
|
|
1778
1830
|
orders: {
|
|
1779
|
-
update:
|
|
1780
|
-
byPayment:
|
|
1781
|
-
cancel:
|
|
1782
|
-
resolveCancelRefund:
|
|
1783
|
-
|
|
1784
|
-
|
|
1831
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
|
|
1832
|
+
byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
|
|
1833
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
|
|
1834
|
+
resolveCancelRefund: sharedEndpoint(
|
|
1835
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
|
|
1836
|
+
),
|
|
1837
|
+
createFulfillment: sharedEndpoint(
|
|
1838
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
|
|
1839
|
+
),
|
|
1840
|
+
updateFulfillment: sharedEndpoint(
|
|
1841
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
|
|
1842
|
+
)
|
|
1785
1843
|
},
|
|
1786
1844
|
checkouts: {
|
|
1787
1845
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
@@ -1793,18 +1851,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1793
1851
|
}
|
|
1794
1852
|
},
|
|
1795
1853
|
returns: {
|
|
1796
|
-
create:
|
|
1797
|
-
update:
|
|
1798
|
-
returnRefund:
|
|
1854
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
|
|
1855
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
|
|
1856
|
+
returnRefund: sharedEndpoint(
|
|
1857
|
+
COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
|
|
1858
|
+
)
|
|
1799
1859
|
},
|
|
1800
1860
|
fulfillmentOrders: {
|
|
1801
|
-
prepare:
|
|
1802
|
-
|
|
1803
|
-
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1861
|
+
prepare: sharedEndpoint(
|
|
1862
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
|
|
1804
1863
|
)
|
|
1805
1864
|
},
|
|
1806
1865
|
fulfillments: {
|
|
1807
|
-
bulkImport:
|
|
1866
|
+
bulkImport: sharedEndpoint(
|
|
1867
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
|
|
1868
|
+
)
|
|
1808
1869
|
},
|
|
1809
1870
|
carts: {
|
|
1810
1871
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
@@ -1869,42 +1930,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1869
1930
|
),
|
|
1870
1931
|
confirm: sharedEndpoint(
|
|
1871
1932
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1933
|
+
),
|
|
1934
|
+
findPortOne: sharedEndpoint(
|
|
1935
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
|
|
1936
|
+
),
|
|
1937
|
+
reconcilePortOne: sharedEndpoint(
|
|
1938
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
|
|
1872
1939
|
)
|
|
1873
1940
|
}
|
|
1874
1941
|
},
|
|
1875
1942
|
shippingPolicies: {
|
|
1876
|
-
calculate:
|
|
1943
|
+
calculate: sharedEndpoint(
|
|
1944
|
+
COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
|
|
1945
|
+
)
|
|
1877
1946
|
}
|
|
1878
1947
|
};
|
|
1879
|
-
function isCommerceEndpointDescriptor(value) {
|
|
1880
|
-
if (!value || typeof value !== "object") return false;
|
|
1881
|
-
const candidate = value;
|
|
1882
|
-
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
1883
|
-
}
|
|
1884
|
-
function flattenEndpointPaths(value) {
|
|
1885
|
-
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
1886
|
-
if (!value || typeof value !== "object") return [];
|
|
1887
|
-
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
1888
|
-
}
|
|
1889
|
-
function flattenEndpointDescriptors(value) {
|
|
1890
|
-
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
1891
|
-
if (!value || typeof value !== "object") return [];
|
|
1892
|
-
return Object.values(value).flatMap(
|
|
1893
|
-
(entry) => flattenEndpointDescriptors(entry)
|
|
1894
|
-
);
|
|
1895
|
-
}
|
|
1896
|
-
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
1897
|
-
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
1898
|
-
var MEMBERSHIP_ENDPOINTS = {
|
|
1899
|
-
subscribe: "/api/memberships/subscribe",
|
|
1900
|
-
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
1901
|
-
me: "/api/memberships/me"
|
|
1902
|
-
};
|
|
1903
|
-
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1904
|
-
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1905
|
-
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1906
|
-
MEMBERSHIP_ENDPOINTS.me
|
|
1907
|
-
];
|
|
1908
1948
|
|
|
1909
1949
|
// src/core/api/customer-scoped-api.ts
|
|
1910
1950
|
var CustomerScopedTransport = class {
|
|
@@ -1925,10 +1965,10 @@ var CustomerScopedTransport = class {
|
|
|
1925
1965
|
this.onUnauthorized = options.onUnauthorized;
|
|
1926
1966
|
this.onRequestId = options.onRequestId;
|
|
1927
1967
|
}
|
|
1928
|
-
async request(
|
|
1968
|
+
async request(endpoint, options) {
|
|
1929
1969
|
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1930
1970
|
try {
|
|
1931
|
-
const response = await httpFetch(
|
|
1971
|
+
const response = await httpFetch(endpoint, {
|
|
1932
1972
|
method: options.method,
|
|
1933
1973
|
apiUrl: this.apiUrl,
|
|
1934
1974
|
publishableKey: this.publishableKey,
|
|
@@ -1942,7 +1982,7 @@ var CustomerScopedTransport = class {
|
|
|
1942
1982
|
...options.errorFamily && { errorFamily: options.errorFamily }
|
|
1943
1983
|
});
|
|
1944
1984
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1945
|
-
return parseApiResponse(response,
|
|
1985
|
+
return parseApiResponse(response, endpoint, {
|
|
1946
1986
|
errorFamily: options.errorFamily
|
|
1947
1987
|
});
|
|
1948
1988
|
} catch (err) {
|
|
@@ -1956,12 +1996,12 @@ var CustomerScopedApi = class {
|
|
|
1956
1996
|
constructor(apiName, options) {
|
|
1957
1997
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
1958
1998
|
}
|
|
1959
|
-
requestEndpoint(
|
|
1960
|
-
return this.transport.request(
|
|
1961
|
-
method:
|
|
1999
|
+
requestEndpoint(endpoint, body, options) {
|
|
2000
|
+
return this.transport.request(resolveOperationPath(endpoint, options), {
|
|
2001
|
+
method: resolveOperationMethod(endpoint),
|
|
1962
2002
|
body,
|
|
1963
2003
|
headers: options?.headers,
|
|
1964
|
-
errorFamily: resolveOperationErrorFamily(
|
|
2004
|
+
errorFamily: resolveOperationErrorFamily(endpoint)
|
|
1965
2005
|
});
|
|
1966
2006
|
}
|
|
1967
2007
|
};
|
|
@@ -1969,8 +2009,8 @@ var RawCustomerScopedApi = class {
|
|
|
1969
2009
|
constructor(apiName, options) {
|
|
1970
2010
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
1971
2011
|
}
|
|
1972
|
-
request(
|
|
1973
|
-
return this.transport.request(
|
|
2012
|
+
request(endpoint, options) {
|
|
2013
|
+
return this.transport.request(endpoint, options);
|
|
1974
2014
|
}
|
|
1975
2015
|
};
|
|
1976
2016
|
|
|
@@ -2045,11 +2085,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
2045
2085
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
2046
2086
|
return `/api/comments/public?${urlParams.toString()}`;
|
|
2047
2087
|
}
|
|
2048
|
-
async execute(
|
|
2049
|
-
return this.request(
|
|
2088
|
+
async execute(endpoint, method, body) {
|
|
2089
|
+
return this.request(endpoint, { method, body });
|
|
2050
2090
|
}
|
|
2051
|
-
async executeDoc(
|
|
2052
|
-
const response = await this.execute(
|
|
2091
|
+
async executeDoc(endpoint, method, body) {
|
|
2092
|
+
const response = await this.execute(endpoint, method, body);
|
|
2053
2093
|
return unwrapPayloadDoc(response);
|
|
2054
2094
|
}
|
|
2055
2095
|
createPost(params) {
|
|
@@ -2328,20 +2368,23 @@ var ServerApiTransport = class {
|
|
|
2328
2368
|
this.apiUrl = options.apiUrl;
|
|
2329
2369
|
this.onRequestId = options.onRequestId;
|
|
2330
2370
|
}
|
|
2331
|
-
async request(
|
|
2371
|
+
async request(endpoint, body, options) {
|
|
2332
2372
|
const method = options?.method ?? "POST";
|
|
2333
2373
|
try {
|
|
2334
|
-
const response = await httpFetch(
|
|
2374
|
+
const response = await httpFetch(endpoint, {
|
|
2335
2375
|
method,
|
|
2336
2376
|
apiUrl: this.apiUrl,
|
|
2337
2377
|
publishableKey: this.publishableKey,
|
|
2338
2378
|
secretKey: this.secretKey,
|
|
2339
2379
|
...body !== void 0 && { body: JSON.stringify(body) },
|
|
2340
2380
|
...options?.headers && { headers: options.headers },
|
|
2341
|
-
...options?.errorFamily && { errorFamily: options.errorFamily }
|
|
2381
|
+
...options?.errorFamily && { errorFamily: options.errorFamily },
|
|
2382
|
+
...options?.typedCommerceErrorReasons && {
|
|
2383
|
+
typedCommerceErrorReasons: options.typedCommerceErrorReasons
|
|
2384
|
+
}
|
|
2342
2385
|
});
|
|
2343
2386
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
2344
|
-
return parseApiResponse(response,
|
|
2387
|
+
return parseApiResponse(response, endpoint, {
|
|
2345
2388
|
errorFamily: options?.errorFamily
|
|
2346
2389
|
});
|
|
2347
2390
|
} catch (err) {
|
|
@@ -2355,14 +2398,15 @@ var BaseApi = class {
|
|
|
2355
2398
|
constructor(apiName, options) {
|
|
2356
2399
|
this.transport = new ServerApiTransport(apiName, options);
|
|
2357
2400
|
}
|
|
2358
|
-
requestEndpoint(
|
|
2401
|
+
requestEndpoint(endpoint, body, options) {
|
|
2359
2402
|
return this.transport.request(
|
|
2360
|
-
|
|
2403
|
+
resolveOperationPath(endpoint, options),
|
|
2361
2404
|
body,
|
|
2362
2405
|
{
|
|
2363
|
-
method:
|
|
2406
|
+
method: resolveOperationMethod(endpoint),
|
|
2364
2407
|
headers: options?.headers,
|
|
2365
|
-
errorFamily: resolveOperationErrorFamily(
|
|
2408
|
+
errorFamily: resolveOperationErrorFamily(endpoint),
|
|
2409
|
+
typedCommerceErrorReasons: resolveOperationTypedCommerceErrorReasons(endpoint)
|
|
2366
2410
|
}
|
|
2367
2411
|
);
|
|
2368
2412
|
}
|
|
@@ -2379,8 +2423,8 @@ var RawBaseApi = class {
|
|
|
2379
2423
|
this.apiUrl = options.apiUrl;
|
|
2380
2424
|
this.onRequestId = options.onRequestId;
|
|
2381
2425
|
}
|
|
2382
|
-
request(
|
|
2383
|
-
return this.transport.request(
|
|
2426
|
+
request(endpoint, body, options) {
|
|
2427
|
+
return this.transport.request(endpoint, body, options);
|
|
2384
2428
|
}
|
|
2385
2429
|
};
|
|
2386
2430
|
|
|
@@ -2419,7 +2463,10 @@ var MAX_COMMERCE_CAPABILITY_LENGTH = 512;
|
|
|
2419
2463
|
var MAX_CART_DISCOUNT_CODE_LENGTH = 128;
|
|
2420
2464
|
var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
|
|
2421
2465
|
var ABANDONED_REASONS = ["expired", "customer", "operator"];
|
|
2422
|
-
|
|
2466
|
+
function managedPaymentProviders(providers) {
|
|
2467
|
+
return providers;
|
|
2468
|
+
}
|
|
2469
|
+
var PAYMENT_PROVIDERS = managedPaymentProviders(["toss", "portone"]);
|
|
2423
2470
|
var PAYMENT_PROVIDER_STATUSES = [
|
|
2424
2471
|
"requires_payment_method",
|
|
2425
2472
|
"requires_action",
|
|
@@ -2441,6 +2488,18 @@ var PAYMENT_FAILURE_REASONS = [
|
|
|
2441
2488
|
"provider_terminal_failure",
|
|
2442
2489
|
"unknown_provider_terminal_failure"
|
|
2443
2490
|
];
|
|
2491
|
+
var PAYMENT_RECONCILIATION_REASONS = [
|
|
2492
|
+
"provider_outcome_unknown",
|
|
2493
|
+
"local_commit_ambiguous",
|
|
2494
|
+
"amount_mismatch",
|
|
2495
|
+
"currency_mismatch",
|
|
2496
|
+
"excess_capture_pending_order",
|
|
2497
|
+
"inventory_unavailable",
|
|
2498
|
+
"admission_unavailable",
|
|
2499
|
+
"excess_capture",
|
|
2500
|
+
"late_capture",
|
|
2501
|
+
"cross_checkout_duplicate"
|
|
2502
|
+
];
|
|
2444
2503
|
var CART_WARNING_CODES = [
|
|
2445
2504
|
"DISCOUNT_CODE_NOT_HONOURED",
|
|
2446
2505
|
"DISCOUNT_CURRENTLY_INACTIVE",
|
|
@@ -2467,6 +2526,26 @@ function invalidCanonicalResponse(resource, details) {
|
|
|
2467
2526
|
function fail(resource, path, expected) {
|
|
2468
2527
|
invalidCanonicalResponse(resource, { path, expected });
|
|
2469
2528
|
}
|
|
2529
|
+
function providerMismatch(resource, expected, actual, operation2) {
|
|
2530
|
+
if (operation2 === "cancel") {
|
|
2531
|
+
const method = {
|
|
2532
|
+
toss: "cancel()",
|
|
2533
|
+
portone: "cancelPortOne()"
|
|
2534
|
+
}[actual];
|
|
2535
|
+
throw createApiError(
|
|
2536
|
+
`Canonical ${resource} response provider mismatch: expected ${expected}, received ${actual}.`,
|
|
2537
|
+
502,
|
|
2538
|
+
{ resource, path: "$.provider", expected, actual },
|
|
2539
|
+
`The server applied the cancellation to a ${actual} PaymentSession, but this SDK method expects ${expected}.`,
|
|
2540
|
+
`Re-invoke ${method} with the same idempotencyKey; do not create a new key.`
|
|
2541
|
+
);
|
|
2542
|
+
}
|
|
2543
|
+
invalidCanonicalResponse(resource, {
|
|
2544
|
+
path: "$.provider",
|
|
2545
|
+
expected,
|
|
2546
|
+
actual
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2470
2549
|
function record(value, resource, path) {
|
|
2471
2550
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2472
2551
|
fail(resource, path, "object");
|
|
@@ -2502,6 +2581,9 @@ function nullableString(value, resource, path) {
|
|
|
2502
2581
|
fail(resource, path, "string or null");
|
|
2503
2582
|
}
|
|
2504
2583
|
}
|
|
2584
|
+
function nullableNonEmptyString(value, resource, path) {
|
|
2585
|
+
if (value !== null) string(value, resource, path);
|
|
2586
|
+
}
|
|
2505
2587
|
function nonBlankString(value, resource, path) {
|
|
2506
2588
|
const parsed = string(value, resource, path);
|
|
2507
2589
|
if (parsed.trim().length === 0) {
|
|
@@ -3022,8 +3104,8 @@ function validateCheckoutItem(value, resource, path) {
|
|
|
3022
3104
|
validateReference(item.product, resource, `${path}.product`);
|
|
3023
3105
|
validateReference(item.variant, resource, `${path}.variant`);
|
|
3024
3106
|
string(item.productTitle, resource, `${path}.productTitle`);
|
|
3025
|
-
|
|
3026
|
-
|
|
3107
|
+
nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
|
|
3108
|
+
nullableNonEmptyString(item.sku, resource, `${path}.sku`);
|
|
3027
3109
|
validateAdmissions(item.admissions, resource, `${path}.admissions`);
|
|
3028
3110
|
cartLineQuantity(item.quantity, resource, `${path}.quantity`);
|
|
3029
3111
|
const unitPrice = safeMinor(
|
|
@@ -3391,6 +3473,141 @@ function validateRetrievedCustomPaymentSession(value) {
|
|
|
3391
3473
|
nullableResourceId(session.orderId, resource, "$.orderId");
|
|
3392
3474
|
return value;
|
|
3393
3475
|
}
|
|
3476
|
+
function validatePortOnePaymentCurrentState(value, resource, path) {
|
|
3477
|
+
const current = record(value, resource, path);
|
|
3478
|
+
exact(
|
|
3479
|
+
current,
|
|
3480
|
+
["paymentSession", "checkout", "order", "money"],
|
|
3481
|
+
[],
|
|
3482
|
+
resource,
|
|
3483
|
+
path
|
|
3484
|
+
);
|
|
3485
|
+
const session = record(
|
|
3486
|
+
current.paymentSession,
|
|
3487
|
+
resource,
|
|
3488
|
+
`${path}.paymentSession`
|
|
3489
|
+
);
|
|
3490
|
+
exact(
|
|
3491
|
+
session,
|
|
3492
|
+
[
|
|
3493
|
+
"id",
|
|
3494
|
+
"provider",
|
|
3495
|
+
"providerStatus",
|
|
3496
|
+
"finalizationStatus",
|
|
3497
|
+
"sessionRole",
|
|
3498
|
+
"reconciliation"
|
|
3499
|
+
],
|
|
3500
|
+
[],
|
|
3501
|
+
resource,
|
|
3502
|
+
`${path}.paymentSession`
|
|
3503
|
+
);
|
|
3504
|
+
boundedString(
|
|
3505
|
+
session.id,
|
|
3506
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3507
|
+
resource,
|
|
3508
|
+
`${path}.paymentSession.id`
|
|
3509
|
+
);
|
|
3510
|
+
if (session.provider !== "portone") {
|
|
3511
|
+
fail(resource, `${path}.paymentSession.provider`, "portone");
|
|
3512
|
+
}
|
|
3513
|
+
enumValue(
|
|
3514
|
+
session.providerStatus,
|
|
3515
|
+
PAYMENT_PROVIDER_STATUSES,
|
|
3516
|
+
resource,
|
|
3517
|
+
`${path}.paymentSession.providerStatus`
|
|
3518
|
+
);
|
|
3519
|
+
enumValue(
|
|
3520
|
+
session.finalizationStatus,
|
|
3521
|
+
["not_ready", "pending", "committed"],
|
|
3522
|
+
resource,
|
|
3523
|
+
`${path}.paymentSession.finalizationStatus`
|
|
3524
|
+
);
|
|
3525
|
+
enumValue(
|
|
3526
|
+
session.sessionRole,
|
|
3527
|
+
["active", "canonical_candidate", "canonical", "residual", "historical"],
|
|
3528
|
+
resource,
|
|
3529
|
+
`${path}.paymentSession.sessionRole`
|
|
3530
|
+
);
|
|
3531
|
+
const reconciliation = record(
|
|
3532
|
+
session.reconciliation,
|
|
3533
|
+
resource,
|
|
3534
|
+
`${path}.paymentSession.reconciliation`
|
|
3535
|
+
);
|
|
3536
|
+
if (reconciliation.status === "none") {
|
|
3537
|
+
validateNoReconciliation(
|
|
3538
|
+
reconciliation,
|
|
3539
|
+
resource,
|
|
3540
|
+
`${path}.paymentSession.reconciliation`
|
|
3541
|
+
);
|
|
3542
|
+
} else {
|
|
3543
|
+
validateRequiredReconciliation(
|
|
3544
|
+
reconciliation,
|
|
3545
|
+
PAYMENT_RECONCILIATION_REASONS,
|
|
3546
|
+
resource,
|
|
3547
|
+
`${path}.paymentSession.reconciliation`
|
|
3548
|
+
);
|
|
3549
|
+
}
|
|
3550
|
+
const checkout = record(current.checkout, resource, `${path}.checkout`);
|
|
3551
|
+
exact(checkout, ["id"], [], resource, `${path}.checkout`);
|
|
3552
|
+
boundedString(
|
|
3553
|
+
checkout.id,
|
|
3554
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3555
|
+
resource,
|
|
3556
|
+
`${path}.checkout.id`
|
|
3557
|
+
);
|
|
3558
|
+
if (current.order !== null) {
|
|
3559
|
+
const order = record(current.order, resource, `${path}.order`);
|
|
3560
|
+
exact(order, ["id", "orderNumber"], [], resource, `${path}.order`);
|
|
3561
|
+
boundedString(
|
|
3562
|
+
order.id,
|
|
3563
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3564
|
+
resource,
|
|
3565
|
+
`${path}.order.id`
|
|
3566
|
+
);
|
|
3567
|
+
nonBlankString(order.orderNumber, resource, `${path}.order.orderNumber`);
|
|
3568
|
+
}
|
|
3569
|
+
validateMoney(current.money, resource, `${path}.money`);
|
|
3570
|
+
}
|
|
3571
|
+
function validatePortOnePaymentFacadeResult(value, mutating) {
|
|
3572
|
+
const resource = mutating ? "PortOne payment reconciliation result" : "PortOne payment find result";
|
|
3573
|
+
const result = record(value, resource, "$");
|
|
3574
|
+
boolean(result.found, resource, "$.found");
|
|
3575
|
+
if (result.found === false) {
|
|
3576
|
+
exact(
|
|
3577
|
+
result,
|
|
3578
|
+
mutating ? ["found", "disposition"] : ["found"],
|
|
3579
|
+
[],
|
|
3580
|
+
resource,
|
|
3581
|
+
"$"
|
|
3582
|
+
);
|
|
3583
|
+
if (mutating && result.disposition !== "requires_attention") {
|
|
3584
|
+
fail(resource, "$.disposition", "requires_attention");
|
|
3585
|
+
}
|
|
3586
|
+
return value;
|
|
3587
|
+
}
|
|
3588
|
+
exact(
|
|
3589
|
+
result,
|
|
3590
|
+
mutating ? ["found", "disposition", "current"] : ["found", "current"],
|
|
3591
|
+
[],
|
|
3592
|
+
resource,
|
|
3593
|
+
"$"
|
|
3594
|
+
);
|
|
3595
|
+
if (mutating) {
|
|
3596
|
+
enumValue(
|
|
3597
|
+
result.disposition,
|
|
3598
|
+
[
|
|
3599
|
+
"applied",
|
|
3600
|
+
"observed",
|
|
3601
|
+
"recovered_after_ambiguous_result",
|
|
3602
|
+
"requires_attention"
|
|
3603
|
+
],
|
|
3604
|
+
resource,
|
|
3605
|
+
"$.disposition"
|
|
3606
|
+
);
|
|
3607
|
+
}
|
|
3608
|
+
validatePortOnePaymentCurrentState(result.current, resource, "$.current");
|
|
3609
|
+
return value;
|
|
3610
|
+
}
|
|
3394
3611
|
function validateConfirmCustomPaymentSessionResponse(value) {
|
|
3395
3612
|
const resource = "custom PaymentSession confirmation";
|
|
3396
3613
|
const result = record(value, resource, "$");
|
|
@@ -3445,11 +3662,21 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3445
3662
|
const action = record(value, resource, path);
|
|
3446
3663
|
if (provider === "portone") {
|
|
3447
3664
|
if (action.type === "portone_sdk") {
|
|
3665
|
+
const hasCancelable = "cancelable" in action;
|
|
3666
|
+
const hasRetryPolicy = "retryPolicy" in action;
|
|
3667
|
+
if (hasCancelable !== hasRetryPolicy) {
|
|
3668
|
+
fail(
|
|
3669
|
+
resource,
|
|
3670
|
+
path,
|
|
3671
|
+
"exact released action or exact negotiated capability action"
|
|
3672
|
+
);
|
|
3673
|
+
}
|
|
3448
3674
|
exact(
|
|
3449
3675
|
action,
|
|
3450
3676
|
[
|
|
3451
3677
|
"type",
|
|
3452
3678
|
"version",
|
|
3679
|
+
...hasCancelable ? ["cancelable", "retryPolicy"] : [],
|
|
3453
3680
|
"storeId",
|
|
3454
3681
|
"channelKey",
|
|
3455
3682
|
"paymentId",
|
|
@@ -3464,6 +3691,11 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3464
3691
|
path
|
|
3465
3692
|
);
|
|
3466
3693
|
if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
|
|
3694
|
+
if (hasCancelable && action.cancelable !== false)
|
|
3695
|
+
fail(resource, `${path}.cancelable`, "false");
|
|
3696
|
+
if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
|
|
3697
|
+
fail(resource, `${path}.retryPolicy`, "same_action_only");
|
|
3698
|
+
}
|
|
3467
3699
|
for (const key of ["storeId", "channelKey"]) {
|
|
3468
3700
|
boundedString(action[key], 255, resource, `${path}.${key}`);
|
|
3469
3701
|
}
|
|
@@ -3510,6 +3742,10 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3510
3742
|
"HTTPS or loopback URL without embedded credentials"
|
|
3511
3743
|
);
|
|
3512
3744
|
}
|
|
3745
|
+
if (!hasCancelable) {
|
|
3746
|
+
action.cancelable = false;
|
|
3747
|
+
action.retryPolicy = "same_action_only";
|
|
3748
|
+
}
|
|
3513
3749
|
return;
|
|
3514
3750
|
}
|
|
3515
3751
|
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
@@ -3586,7 +3822,7 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3586
3822
|
if (action.customerEmail !== void 0)
|
|
3587
3823
|
validateCustomer({ email: action.customerEmail }, resource, path);
|
|
3588
3824
|
}
|
|
3589
|
-
function validatePublicPaymentSession(value, expectedProvider) {
|
|
3825
|
+
function validatePublicPaymentSession(value, expectedProvider, operation2) {
|
|
3590
3826
|
const resource = "PaymentSession";
|
|
3591
3827
|
const session = record(value, resource, "$");
|
|
3592
3828
|
const provider = enumValue(
|
|
@@ -3595,9 +3831,6 @@ function validatePublicPaymentSession(value, expectedProvider) {
|
|
|
3595
3831
|
resource,
|
|
3596
3832
|
"$.provider"
|
|
3597
3833
|
);
|
|
3598
|
-
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
3599
|
-
fail(resource, "$.provider", expectedProvider);
|
|
3600
|
-
}
|
|
3601
3834
|
const status = enumValue(
|
|
3602
3835
|
session.providerStatus,
|
|
3603
3836
|
PAYMENT_PROVIDER_STATUSES,
|
|
@@ -3801,6 +4034,16 @@ function validatePublicPaymentSession(value, expectedProvider) {
|
|
|
3801
4034
|
"$.cancellationReason"
|
|
3802
4035
|
);
|
|
3803
4036
|
}
|
|
4037
|
+
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
4038
|
+
if (operation2 === "cancel" && status !== "canceling" && status !== "canceled") {
|
|
4039
|
+
fail(
|
|
4040
|
+
resource,
|
|
4041
|
+
"$.providerStatus",
|
|
4042
|
+
"canceling or canceled after a successful cancellation"
|
|
4043
|
+
);
|
|
4044
|
+
}
|
|
4045
|
+
providerMismatch(resource, expectedProvider, provider, operation2);
|
|
4046
|
+
}
|
|
3804
4047
|
return value;
|
|
3805
4048
|
}
|
|
3806
4049
|
|
|
@@ -3827,8 +4070,8 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3827
4070
|
endpoint(key) {
|
|
3828
4071
|
return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
|
|
3829
4072
|
}
|
|
3830
|
-
execute(
|
|
3831
|
-
return this.requestEndpoint(
|
|
4073
|
+
execute(endpoint, body, idempotencyKey) {
|
|
4074
|
+
return this.requestEndpoint(endpoint, body, {
|
|
3832
4075
|
...idempotencyKey && {
|
|
3833
4076
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
3834
4077
|
}
|
|
@@ -3845,26 +4088,26 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3845
4088
|
);
|
|
3846
4089
|
}
|
|
3847
4090
|
mine(params = {}) {
|
|
3848
|
-
const
|
|
3849
|
-
return this.execute(
|
|
4091
|
+
const endpoint = this.endpoint("mine");
|
|
4092
|
+
return this.execute(endpoint, params).then(
|
|
3850
4093
|
(value) => validateCartMineResult(value)
|
|
3851
4094
|
);
|
|
3852
4095
|
}
|
|
3853
4096
|
merge(params) {
|
|
3854
4097
|
const { idempotencyKey, ...body } = params;
|
|
3855
4098
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3856
|
-
const
|
|
3857
|
-
return this.execute(
|
|
4099
|
+
const endpoint = this.endpoint("merge");
|
|
4100
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3858
4101
|
(value) => validateCartMergeResult(value)
|
|
3859
4102
|
);
|
|
3860
4103
|
}
|
|
3861
4104
|
addItem(params) {
|
|
3862
4105
|
return this.mutate(this.endpoint("addItem"), params);
|
|
3863
4106
|
}
|
|
3864
|
-
mutate(
|
|
4107
|
+
mutate(endpoint, params) {
|
|
3865
4108
|
const { idempotencyKey, ...body } = params;
|
|
3866
4109
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3867
|
-
return this.execute(
|
|
4110
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3868
4111
|
(value) => validateCartMutationResult(value)
|
|
3869
4112
|
);
|
|
3870
4113
|
}
|
|
@@ -5273,8 +5516,8 @@ var CheckoutApi = class extends CustomerScopedApi {
|
|
|
5273
5516
|
constructor(options) {
|
|
5274
5517
|
super("CheckoutApi", { ...options, requiresCredential: false });
|
|
5275
5518
|
}
|
|
5276
|
-
post(
|
|
5277
|
-
return this.requestEndpoint(
|
|
5519
|
+
post(endpoint, body, idempotencyKey) {
|
|
5520
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5278
5521
|
...idempotencyKey && {
|
|
5279
5522
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
5280
5523
|
}
|
|
@@ -5341,15 +5584,23 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5341
5584
|
super("PaymentSessionApi", { ...options, requiresCredential: false });
|
|
5342
5585
|
this.serverTransport = Boolean(options.secretKey);
|
|
5343
5586
|
}
|
|
5344
|
-
post(
|
|
5345
|
-
|
|
5346
|
-
...idempotencyKey && {
|
|
5347
|
-
|
|
5587
|
+
post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
|
|
5588
|
+
const headers = {
|
|
5589
|
+
...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
|
|
5590
|
+
...negotiateStandardActionCapabilities && {
|
|
5591
|
+
Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
|
|
5348
5592
|
}
|
|
5593
|
+
};
|
|
5594
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5595
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
5349
5596
|
});
|
|
5350
5597
|
}
|
|
5351
|
-
async paymentSession(result, expectedProvider) {
|
|
5352
|
-
return validatePublicPaymentSession(
|
|
5598
|
+
async paymentSession(result, expectedProvider, operation2) {
|
|
5599
|
+
return validatePublicPaymentSession(
|
|
5600
|
+
await result,
|
|
5601
|
+
expectedProvider,
|
|
5602
|
+
operation2
|
|
5603
|
+
);
|
|
5353
5604
|
}
|
|
5354
5605
|
create(params) {
|
|
5355
5606
|
const { idempotencyKey, ...body } = params;
|
|
@@ -5370,41 +5621,44 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5370
5621
|
this.post(
|
|
5371
5622
|
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
5372
5623
|
body,
|
|
5373
|
-
idempotencyKey
|
|
5624
|
+
idempotencyKey,
|
|
5625
|
+
body.providerOptions.profile === "standard_v2"
|
|
5374
5626
|
),
|
|
5375
5627
|
"portone"
|
|
5376
5628
|
);
|
|
5377
5629
|
}
|
|
5378
5630
|
retrieve(params) {
|
|
5379
|
-
const
|
|
5631
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5380
5632
|
return this.paymentSession(
|
|
5381
|
-
this.post(
|
|
5633
|
+
this.post(endpoint, params),
|
|
5382
5634
|
"toss"
|
|
5383
5635
|
);
|
|
5384
5636
|
}
|
|
5385
5637
|
retrievePortOne(params) {
|
|
5386
|
-
const
|
|
5638
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5387
5639
|
return this.paymentSession(
|
|
5388
|
-
this.post(
|
|
5640
|
+
this.post(endpoint, params, void 0, true),
|
|
5389
5641
|
"portone"
|
|
5390
5642
|
);
|
|
5391
5643
|
}
|
|
5392
5644
|
cancel(params) {
|
|
5393
5645
|
const { idempotencyKey, ...body } = params;
|
|
5394
5646
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5395
|
-
const
|
|
5647
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5396
5648
|
return this.paymentSession(
|
|
5397
|
-
this.post(
|
|
5398
|
-
"toss"
|
|
5649
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5650
|
+
"toss",
|
|
5651
|
+
"cancel"
|
|
5399
5652
|
);
|
|
5400
5653
|
}
|
|
5401
5654
|
cancelPortOne(params) {
|
|
5402
5655
|
const { idempotencyKey, ...body } = params;
|
|
5403
5656
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5404
|
-
const
|
|
5657
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5405
5658
|
return this.paymentSession(
|
|
5406
|
-
this.post(
|
|
5407
|
-
"portone"
|
|
5659
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5660
|
+
"portone",
|
|
5661
|
+
"cancel"
|
|
5408
5662
|
);
|
|
5409
5663
|
}
|
|
5410
5664
|
confirm(params) {
|
|
@@ -5420,6 +5674,34 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5420
5674
|
);
|
|
5421
5675
|
}
|
|
5422
5676
|
};
|
|
5677
|
+
var PortOnePaymentReconciliationApi = class extends BaseApi {
|
|
5678
|
+
constructor(options) {
|
|
5679
|
+
super("PortOnePaymentReconciliationApi", options);
|
|
5680
|
+
}
|
|
5681
|
+
async find(params) {
|
|
5682
|
+
const result = await this.requestEndpoint(
|
|
5683
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.findPortOne,
|
|
5684
|
+
params
|
|
5685
|
+
);
|
|
5686
|
+
return validatePortOnePaymentFacadeResult(
|
|
5687
|
+
result,
|
|
5688
|
+
false
|
|
5689
|
+
);
|
|
5690
|
+
}
|
|
5691
|
+
async reconcile(params) {
|
|
5692
|
+
const { idempotencyKey, ...body } = params;
|
|
5693
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5694
|
+
const result = await this.requestEndpoint(
|
|
5695
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.reconcilePortOne,
|
|
5696
|
+
body,
|
|
5697
|
+
{ headers: { "X-Idempotency-Key": idempotencyKey } }
|
|
5698
|
+
);
|
|
5699
|
+
return validatePortOnePaymentFacadeResult(
|
|
5700
|
+
result,
|
|
5701
|
+
true
|
|
5702
|
+
);
|
|
5703
|
+
}
|
|
5704
|
+
};
|
|
5423
5705
|
var CustomPaymentSessionApi = class extends BaseApi {
|
|
5424
5706
|
constructor(options) {
|
|
5425
5707
|
super("CustomPaymentSessionApi", options);
|
|
@@ -5549,6 +5831,9 @@ var ServerCommerceClient = class {
|
|
|
5549
5831
|
const orderApi = new OrderApi(serverOptions);
|
|
5550
5832
|
const checkoutApi = new CheckoutApi(serverOptions);
|
|
5551
5833
|
const paymentSessionApi = new PaymentSessionApi(serverOptions);
|
|
5834
|
+
const portOneReconciliationApi = new PortOnePaymentReconciliationApi(
|
|
5835
|
+
serverOptions
|
|
5836
|
+
);
|
|
5552
5837
|
const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
|
|
5553
5838
|
this.product = {
|
|
5554
5839
|
stockCheck: productApi.stockCheck.bind(productApi),
|
|
@@ -5599,6 +5884,10 @@ var ServerCommerceClient = class {
|
|
|
5599
5884
|
cancel: (params) => paymentSessionApi.cancel(params),
|
|
5600
5885
|
cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params),
|
|
5601
5886
|
confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
|
|
5887
|
+
findPortOne: portOneReconciliationApi.find.bind(portOneReconciliationApi),
|
|
5888
|
+
reconcilePortOne: portOneReconciliationApi.reconcile.bind(
|
|
5889
|
+
portOneReconciliationApi
|
|
5890
|
+
),
|
|
5602
5891
|
custom: {
|
|
5603
5892
|
create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
|
|
5604
5893
|
retrieve: customPaymentSessionApi.retrieve.bind(
|
|
@@ -5680,11 +5969,11 @@ var EventsClient = class {
|
|
|
5680
5969
|
{ useCustomerAuth: false }
|
|
5681
5970
|
);
|
|
5682
5971
|
}
|
|
5683
|
-
async execute(
|
|
5972
|
+
async execute(endpoint, method, body, options = {}) {
|
|
5684
5973
|
const useCustomerAuth = options.useCustomerAuth === true;
|
|
5685
5974
|
const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
|
|
5686
5975
|
try {
|
|
5687
|
-
const response = await httpFetch(
|
|
5976
|
+
const response = await httpFetch(endpoint, {
|
|
5688
5977
|
method,
|
|
5689
5978
|
apiUrl: this.apiUrl,
|
|
5690
5979
|
publishableKey: this.publishableKey,
|
|
@@ -5693,7 +5982,7 @@ var EventsClient = class {
|
|
|
5693
5982
|
...body !== void 0 && { body: JSON.stringify(body) }
|
|
5694
5983
|
});
|
|
5695
5984
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
5696
|
-
return parseApiResponse(response,
|
|
5985
|
+
return parseApiResponse(response, endpoint);
|
|
5697
5986
|
} catch (err) {
|
|
5698
5987
|
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
5699
5988
|
this.onRequestId?.(id);
|
|
@@ -5795,13 +6084,14 @@ var MarketDiscovery = class {
|
|
|
5795
6084
|
};
|
|
5796
6085
|
|
|
5797
6086
|
// src/core/api/tenant-introspection-api.ts
|
|
6087
|
+
var TENANT_CONTEXT_PATH = "/api/tenants/context";
|
|
5798
6088
|
var TenantIntrospectionApi = class extends RawBaseApi {
|
|
5799
6089
|
constructor(options) {
|
|
5800
6090
|
super("TenantIntrospectionApi", options);
|
|
5801
6091
|
}
|
|
5802
6092
|
context(params = {}) {
|
|
5803
|
-
const
|
|
5804
|
-
return this.request(
|
|
6093
|
+
const endpoint = params.includeCounts ? `${TENANT_CONTEXT_PATH}?counts=true` : TENANT_CONTEXT_PATH;
|
|
6094
|
+
return this.request(endpoint, void 0, {
|
|
5805
6095
|
method: "GET"
|
|
5806
6096
|
});
|
|
5807
6097
|
}
|
|
@@ -5829,9 +6119,10 @@ var MembershipApi = class extends BaseApi {
|
|
|
5829
6119
|
super("MembershipApi", options);
|
|
5830
6120
|
}
|
|
5831
6121
|
/**
|
|
5832
|
-
*
|
|
5833
|
-
*
|
|
5834
|
-
* `
|
|
6122
|
+
* Prepare a delegated first charge for a paid Membership, or immediately
|
|
6123
|
+
* start a trial. For a paid response, charge through the tenant PSP with
|
|
6124
|
+
* `firstCharge.idempotencyKey`, then post the existing signed charge result
|
|
6125
|
+
* to activate the membership.
|
|
5835
6126
|
*
|
|
5836
6127
|
* `subscribeIntentKey` is used as the HTTP idempotency key so the call is
|
|
5837
6128
|
* safely retryable.
|
|
@@ -5860,6 +6151,39 @@ var MembershipApi = class extends BaseApi {
|
|
|
5860
6151
|
}
|
|
5861
6152
|
};
|
|
5862
6153
|
|
|
6154
|
+
// src/core/api/customer-group-api.ts
|
|
6155
|
+
var CustomerGroupApi = class extends BaseApi {
|
|
6156
|
+
constructor(options) {
|
|
6157
|
+
super("CustomerGroupApi", options);
|
|
6158
|
+
}
|
|
6159
|
+
listMembers(params) {
|
|
6160
|
+
const query = new URLSearchParams();
|
|
6161
|
+
if (params.page !== void 0) query.set("page", String(params.page));
|
|
6162
|
+
if (params.limit !== void 0) query.set("limit", String(params.limit));
|
|
6163
|
+
return this.requestEndpoint(
|
|
6164
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.members,
|
|
6165
|
+
void 0,
|
|
6166
|
+
{ pathParams: { id: params.groupId }, query }
|
|
6167
|
+
);
|
|
6168
|
+
}
|
|
6169
|
+
grantMember(params) {
|
|
6170
|
+
const { groupId, ...body } = params;
|
|
6171
|
+
return this.requestEndpoint(
|
|
6172
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.grant,
|
|
6173
|
+
body,
|
|
6174
|
+
{ pathParams: { id: groupId } }
|
|
6175
|
+
);
|
|
6176
|
+
}
|
|
6177
|
+
revokeMember(params) {
|
|
6178
|
+
const { groupId, ...body } = params;
|
|
6179
|
+
return this.requestEndpoint(
|
|
6180
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.revoke,
|
|
6181
|
+
body,
|
|
6182
|
+
{ pathParams: { id: groupId } }
|
|
6183
|
+
);
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
|
|
5863
6187
|
// src/core/client/client.server.ts
|
|
5864
6188
|
var ServerClient = class _ServerClient {
|
|
5865
6189
|
constructor(options) {
|
|
@@ -5899,6 +6223,7 @@ var ServerClient = class _ServerClient {
|
|
|
5899
6223
|
subscribe: membershipApi.subscribe.bind(membershipApi),
|
|
5900
6224
|
cancel: membershipApi.cancel.bind(membershipApi)
|
|
5901
6225
|
};
|
|
6226
|
+
this.customerGroups = new CustomerGroupApi(serverOptions);
|
|
5902
6227
|
const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
|
|
5903
6228
|
this.tenant = {
|
|
5904
6229
|
context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),
|
|
@@ -5967,12 +6292,14 @@ function createServerClient(options) {
|
|
|
5967
6292
|
export {
|
|
5968
6293
|
CollectionClient,
|
|
5969
6294
|
CommunityClient,
|
|
6295
|
+
CustomerGroupApi,
|
|
5970
6296
|
EventsClient,
|
|
5971
6297
|
ModerationApi,
|
|
5972
6298
|
ServerClient,
|
|
5973
6299
|
ServerCollectionClient,
|
|
5974
6300
|
ServerCommerceClient,
|
|
5975
6301
|
ServerPreviewClient,
|
|
6302
|
+
TENANT_CONTEXT_PATH,
|
|
5976
6303
|
TenantIntrospectionApi,
|
|
5977
6304
|
createServerClient,
|
|
5978
6305
|
isApiError,
|