@01.software/sdk 0.49.0 → 0.51.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 +130 -1
- package/MIGRATION.md +56 -0
- package/README.md +215 -45
- package/dist/client.cjs +188 -137
- 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 +188 -137
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
- package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
- package/dist/{const-DCNV5Kq7.d.ts → const-D8LixhAJ.d.cts} +5 -5
- package/dist/{const-CBba4lDo.d.cts → const-JD8obaKg.d.ts} +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-CbKyoEzy.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
- package/dist/{index-DUuIqUS8.d.ts → index-Bu0kCc6o.d.cts} +72 -10
- package/dist/index.cjs +320 -383
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -66
- package/dist/index.d.ts +8 -66
- package/dist/index.js +320 -383
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-BOsckg8B.d.cts} +263 -54
- package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-BOsckg8B.d.ts} +263 -54
- package/dist/query.cjs +94 -70
- 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 +94 -70
- 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 +404 -162
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +404 -162
- 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-L_nh-ED7.d.ts → types-5ZlcAFuU.d.ts} +2 -2
- package/dist/{types-BKr_2avj.d.cts → types-B14sEt1z.d.cts} +2 -2
- package/dist/{types-1UeOk1Uy.d.cts → types-Bj8j7VHU.d.ts} +79 -23
- package/dist/{types-Du4s5anw.d.ts → types-CM5qiR2k.d.cts} +79 -23
- 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 +124 -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 +124 -80
- package/dist/webhook.js.map +1 -1
- package/package.json +23 -2
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")
|
|
@@ -1677,6 +1690,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1677
1690
|
"payment-sessions",
|
|
1678
1691
|
"post",
|
|
1679
1692
|
"/server/confirm"
|
|
1693
|
+
),
|
|
1694
|
+
findPortOne: strictCommerceOperation(
|
|
1695
|
+
"payment-sessions",
|
|
1696
|
+
"post",
|
|
1697
|
+
"/server/portone/find"
|
|
1698
|
+
),
|
|
1699
|
+
reconcilePortOne: strictCommerceOperation(
|
|
1700
|
+
"payment-sessions",
|
|
1701
|
+
"post",
|
|
1702
|
+
"/server/portone/reconcile"
|
|
1680
1703
|
)
|
|
1681
1704
|
},
|
|
1682
1705
|
custom: {
|
|
@@ -1696,12 +1719,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1696
1719
|
validate: operation("discounts", "post", "/validate")
|
|
1697
1720
|
}
|
|
1698
1721
|
};
|
|
1722
|
+
var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
|
|
1723
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
|
|
1724
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
|
|
1725
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
|
|
1726
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
1727
|
+
]);
|
|
1699
1728
|
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
1700
1729
|
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
1701
1730
|
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
1702
1731
|
me: operation(null, "get", "/memberships/me")
|
|
1703
1732
|
};
|
|
1733
|
+
var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
|
|
1734
|
+
show: operation("tenants", "get", "/embedded-admin-app"),
|
|
1735
|
+
configure: operation("tenants", "patch", "/embedded-admin-app"),
|
|
1736
|
+
disable: operation("tenants", "delete", "/embedded-admin-app")
|
|
1737
|
+
};
|
|
1704
1738
|
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
1739
|
+
events: {
|
|
1740
|
+
convertSchedule: operation("events", "post", "/:id/schedule")
|
|
1741
|
+
},
|
|
1705
1742
|
occurrences: {
|
|
1706
1743
|
range: operation("event-occurrences", "get", "/range"),
|
|
1707
1744
|
admissionAvailability: operation(
|
|
@@ -1742,46 +1779,54 @@ function resolveOperationMethod(descriptor) {
|
|
|
1742
1779
|
}
|
|
1743
1780
|
|
|
1744
1781
|
// src/core/api/endpoints.ts
|
|
1745
|
-
var endpoint = (method, path) => ({ method, path });
|
|
1746
1782
|
var sharedEndpoint = (descriptor) => descriptor;
|
|
1747
|
-
function resolveOperationMethod2(descriptor) {
|
|
1748
|
-
return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
|
|
1749
|
-
}
|
|
1750
1783
|
function resolveOperationErrorFamily(descriptor) {
|
|
1751
|
-
return
|
|
1784
|
+
return descriptor.errorFamily;
|
|
1752
1785
|
}
|
|
1753
|
-
function
|
|
1754
|
-
|
|
1755
|
-
return resolveOperationPath(descriptor, options);
|
|
1756
|
-
}
|
|
1757
|
-
const query = options?.query?.toString().replace(/^\?/, "");
|
|
1758
|
-
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
1786
|
+
function resolveOperationTypedCommerceErrorReasons(descriptor) {
|
|
1787
|
+
return descriptor.typedCommerceErrorReasons;
|
|
1759
1788
|
}
|
|
1760
1789
|
var COMMERCE_ENDPOINTS = {
|
|
1761
1790
|
products: {
|
|
1762
|
-
detail:
|
|
1763
|
-
detailCatalog:
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1791
|
+
detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
|
|
1792
|
+
detailCatalog: sharedEndpoint(
|
|
1793
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
|
|
1794
|
+
),
|
|
1795
|
+
listingGroups: sharedEndpoint(
|
|
1796
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
|
|
1797
|
+
),
|
|
1798
|
+
listingGroupsCatalog: sharedEndpoint(
|
|
1799
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
|
|
1768
1800
|
),
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1801
|
+
// The manifest keeps the GET read and the POST body-query apart; this
|
|
1802
|
+
// semantic name has always resolved to the GET one.
|
|
1803
|
+
listingGroupsQuery: sharedEndpoint(
|
|
1804
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
|
|
1773
1805
|
),
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1806
|
+
listingGroupsQueryCatalog: sharedEndpoint(
|
|
1807
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
|
|
1808
|
+
),
|
|
1809
|
+
stockCheck: sharedEndpoint(
|
|
1810
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
|
|
1811
|
+
),
|
|
1812
|
+
stockSnapshot: sharedEndpoint(
|
|
1813
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
|
|
1814
|
+
),
|
|
1815
|
+
upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
|
|
1777
1816
|
},
|
|
1778
1817
|
orders: {
|
|
1779
|
-
update:
|
|
1780
|
-
byPayment:
|
|
1781
|
-
cancel:
|
|
1782
|
-
resolveCancelRefund:
|
|
1783
|
-
|
|
1784
|
-
|
|
1818
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
|
|
1819
|
+
byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
|
|
1820
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
|
|
1821
|
+
resolveCancelRefund: sharedEndpoint(
|
|
1822
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
|
|
1823
|
+
),
|
|
1824
|
+
createFulfillment: sharedEndpoint(
|
|
1825
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
|
|
1826
|
+
),
|
|
1827
|
+
updateFulfillment: sharedEndpoint(
|
|
1828
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
|
|
1829
|
+
)
|
|
1785
1830
|
},
|
|
1786
1831
|
checkouts: {
|
|
1787
1832
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
@@ -1793,18 +1838,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1793
1838
|
}
|
|
1794
1839
|
},
|
|
1795
1840
|
returns: {
|
|
1796
|
-
create:
|
|
1797
|
-
update:
|
|
1798
|
-
returnRefund:
|
|
1841
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
|
|
1842
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
|
|
1843
|
+
returnRefund: sharedEndpoint(
|
|
1844
|
+
COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
|
|
1845
|
+
)
|
|
1799
1846
|
},
|
|
1800
1847
|
fulfillmentOrders: {
|
|
1801
|
-
prepare:
|
|
1802
|
-
|
|
1803
|
-
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1848
|
+
prepare: sharedEndpoint(
|
|
1849
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
|
|
1804
1850
|
)
|
|
1805
1851
|
},
|
|
1806
1852
|
fulfillments: {
|
|
1807
|
-
bulkImport:
|
|
1853
|
+
bulkImport: sharedEndpoint(
|
|
1854
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
|
|
1855
|
+
)
|
|
1808
1856
|
},
|
|
1809
1857
|
carts: {
|
|
1810
1858
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
@@ -1869,42 +1917,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1869
1917
|
),
|
|
1870
1918
|
confirm: sharedEndpoint(
|
|
1871
1919
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1920
|
+
),
|
|
1921
|
+
findPortOne: sharedEndpoint(
|
|
1922
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
|
|
1923
|
+
),
|
|
1924
|
+
reconcilePortOne: sharedEndpoint(
|
|
1925
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
|
|
1872
1926
|
)
|
|
1873
1927
|
}
|
|
1874
1928
|
},
|
|
1875
1929
|
shippingPolicies: {
|
|
1876
|
-
calculate:
|
|
1930
|
+
calculate: sharedEndpoint(
|
|
1931
|
+
COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
|
|
1932
|
+
)
|
|
1877
1933
|
}
|
|
1878
1934
|
};
|
|
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
1935
|
|
|
1909
1936
|
// src/core/api/customer-scoped-api.ts
|
|
1910
1937
|
var CustomerScopedTransport = class {
|
|
@@ -1925,10 +1952,10 @@ var CustomerScopedTransport = class {
|
|
|
1925
1952
|
this.onUnauthorized = options.onUnauthorized;
|
|
1926
1953
|
this.onRequestId = options.onRequestId;
|
|
1927
1954
|
}
|
|
1928
|
-
async request(
|
|
1955
|
+
async request(endpoint, options) {
|
|
1929
1956
|
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1930
1957
|
try {
|
|
1931
|
-
const response = await httpFetch(
|
|
1958
|
+
const response = await httpFetch(endpoint, {
|
|
1932
1959
|
method: options.method,
|
|
1933
1960
|
apiUrl: this.apiUrl,
|
|
1934
1961
|
publishableKey: this.publishableKey,
|
|
@@ -1942,7 +1969,7 @@ var CustomerScopedTransport = class {
|
|
|
1942
1969
|
...options.errorFamily && { errorFamily: options.errorFamily }
|
|
1943
1970
|
});
|
|
1944
1971
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1945
|
-
return parseApiResponse(response,
|
|
1972
|
+
return parseApiResponse(response, endpoint, {
|
|
1946
1973
|
errorFamily: options.errorFamily
|
|
1947
1974
|
});
|
|
1948
1975
|
} catch (err) {
|
|
@@ -1956,12 +1983,12 @@ var CustomerScopedApi = class {
|
|
|
1956
1983
|
constructor(apiName, options) {
|
|
1957
1984
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
1958
1985
|
}
|
|
1959
|
-
requestEndpoint(
|
|
1960
|
-
return this.transport.request(
|
|
1961
|
-
method:
|
|
1986
|
+
requestEndpoint(endpoint, body, options) {
|
|
1987
|
+
return this.transport.request(resolveOperationPath(endpoint, options), {
|
|
1988
|
+
method: resolveOperationMethod(endpoint),
|
|
1962
1989
|
body,
|
|
1963
1990
|
headers: options?.headers,
|
|
1964
|
-
errorFamily: resolveOperationErrorFamily(
|
|
1991
|
+
errorFamily: resolveOperationErrorFamily(endpoint)
|
|
1965
1992
|
});
|
|
1966
1993
|
}
|
|
1967
1994
|
};
|
|
@@ -1969,8 +1996,8 @@ var RawCustomerScopedApi = class {
|
|
|
1969
1996
|
constructor(apiName, options) {
|
|
1970
1997
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
1971
1998
|
}
|
|
1972
|
-
request(
|
|
1973
|
-
return this.transport.request(
|
|
1999
|
+
request(endpoint, options) {
|
|
2000
|
+
return this.transport.request(endpoint, options);
|
|
1974
2001
|
}
|
|
1975
2002
|
};
|
|
1976
2003
|
|
|
@@ -2045,11 +2072,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
2045
2072
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
2046
2073
|
return `/api/comments/public?${urlParams.toString()}`;
|
|
2047
2074
|
}
|
|
2048
|
-
async execute(
|
|
2049
|
-
return this.request(
|
|
2075
|
+
async execute(endpoint, method, body) {
|
|
2076
|
+
return this.request(endpoint, { method, body });
|
|
2050
2077
|
}
|
|
2051
|
-
async executeDoc(
|
|
2052
|
-
const response = await this.execute(
|
|
2078
|
+
async executeDoc(endpoint, method, body) {
|
|
2079
|
+
const response = await this.execute(endpoint, method, body);
|
|
2053
2080
|
return unwrapPayloadDoc(response);
|
|
2054
2081
|
}
|
|
2055
2082
|
createPost(params) {
|
|
@@ -2328,20 +2355,23 @@ var ServerApiTransport = class {
|
|
|
2328
2355
|
this.apiUrl = options.apiUrl;
|
|
2329
2356
|
this.onRequestId = options.onRequestId;
|
|
2330
2357
|
}
|
|
2331
|
-
async request(
|
|
2358
|
+
async request(endpoint, body, options) {
|
|
2332
2359
|
const method = options?.method ?? "POST";
|
|
2333
2360
|
try {
|
|
2334
|
-
const response = await httpFetch(
|
|
2361
|
+
const response = await httpFetch(endpoint, {
|
|
2335
2362
|
method,
|
|
2336
2363
|
apiUrl: this.apiUrl,
|
|
2337
2364
|
publishableKey: this.publishableKey,
|
|
2338
2365
|
secretKey: this.secretKey,
|
|
2339
2366
|
...body !== void 0 && { body: JSON.stringify(body) },
|
|
2340
2367
|
...options?.headers && { headers: options.headers },
|
|
2341
|
-
...options?.errorFamily && { errorFamily: options.errorFamily }
|
|
2368
|
+
...options?.errorFamily && { errorFamily: options.errorFamily },
|
|
2369
|
+
...options?.typedCommerceErrorReasons && {
|
|
2370
|
+
typedCommerceErrorReasons: options.typedCommerceErrorReasons
|
|
2371
|
+
}
|
|
2342
2372
|
});
|
|
2343
2373
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
2344
|
-
return parseApiResponse(response,
|
|
2374
|
+
return parseApiResponse(response, endpoint, {
|
|
2345
2375
|
errorFamily: options?.errorFamily
|
|
2346
2376
|
});
|
|
2347
2377
|
} catch (err) {
|
|
@@ -2355,14 +2385,15 @@ var BaseApi = class {
|
|
|
2355
2385
|
constructor(apiName, options) {
|
|
2356
2386
|
this.transport = new ServerApiTransport(apiName, options);
|
|
2357
2387
|
}
|
|
2358
|
-
requestEndpoint(
|
|
2388
|
+
requestEndpoint(endpoint, body, options) {
|
|
2359
2389
|
return this.transport.request(
|
|
2360
|
-
|
|
2390
|
+
resolveOperationPath(endpoint, options),
|
|
2361
2391
|
body,
|
|
2362
2392
|
{
|
|
2363
|
-
method:
|
|
2393
|
+
method: resolveOperationMethod(endpoint),
|
|
2364
2394
|
headers: options?.headers,
|
|
2365
|
-
errorFamily: resolveOperationErrorFamily(
|
|
2395
|
+
errorFamily: resolveOperationErrorFamily(endpoint),
|
|
2396
|
+
typedCommerceErrorReasons: resolveOperationTypedCommerceErrorReasons(endpoint)
|
|
2366
2397
|
}
|
|
2367
2398
|
);
|
|
2368
2399
|
}
|
|
@@ -2379,8 +2410,8 @@ var RawBaseApi = class {
|
|
|
2379
2410
|
this.apiUrl = options.apiUrl;
|
|
2380
2411
|
this.onRequestId = options.onRequestId;
|
|
2381
2412
|
}
|
|
2382
|
-
request(
|
|
2383
|
-
return this.transport.request(
|
|
2413
|
+
request(endpoint, body, options) {
|
|
2414
|
+
return this.transport.request(endpoint, body, options);
|
|
2384
2415
|
}
|
|
2385
2416
|
};
|
|
2386
2417
|
|
|
@@ -2441,6 +2472,18 @@ var PAYMENT_FAILURE_REASONS = [
|
|
|
2441
2472
|
"provider_terminal_failure",
|
|
2442
2473
|
"unknown_provider_terminal_failure"
|
|
2443
2474
|
];
|
|
2475
|
+
var PAYMENT_RECONCILIATION_REASONS = [
|
|
2476
|
+
"provider_outcome_unknown",
|
|
2477
|
+
"local_commit_ambiguous",
|
|
2478
|
+
"amount_mismatch",
|
|
2479
|
+
"currency_mismatch",
|
|
2480
|
+
"excess_capture_pending_order",
|
|
2481
|
+
"inventory_unavailable",
|
|
2482
|
+
"admission_unavailable",
|
|
2483
|
+
"excess_capture",
|
|
2484
|
+
"late_capture",
|
|
2485
|
+
"cross_checkout_duplicate"
|
|
2486
|
+
];
|
|
2444
2487
|
var CART_WARNING_CODES = [
|
|
2445
2488
|
"DISCOUNT_CODE_NOT_HONOURED",
|
|
2446
2489
|
"DISCOUNT_CURRENTLY_INACTIVE",
|
|
@@ -2502,6 +2545,9 @@ function nullableString(value, resource, path) {
|
|
|
2502
2545
|
fail(resource, path, "string or null");
|
|
2503
2546
|
}
|
|
2504
2547
|
}
|
|
2548
|
+
function nullableNonEmptyString(value, resource, path) {
|
|
2549
|
+
if (value !== null) string(value, resource, path);
|
|
2550
|
+
}
|
|
2505
2551
|
function nonBlankString(value, resource, path) {
|
|
2506
2552
|
const parsed = string(value, resource, path);
|
|
2507
2553
|
if (parsed.trim().length === 0) {
|
|
@@ -3022,8 +3068,8 @@ function validateCheckoutItem(value, resource, path) {
|
|
|
3022
3068
|
validateReference(item.product, resource, `${path}.product`);
|
|
3023
3069
|
validateReference(item.variant, resource, `${path}.variant`);
|
|
3024
3070
|
string(item.productTitle, resource, `${path}.productTitle`);
|
|
3025
|
-
|
|
3026
|
-
|
|
3071
|
+
nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
|
|
3072
|
+
nullableNonEmptyString(item.sku, resource, `${path}.sku`);
|
|
3027
3073
|
validateAdmissions(item.admissions, resource, `${path}.admissions`);
|
|
3028
3074
|
cartLineQuantity(item.quantity, resource, `${path}.quantity`);
|
|
3029
3075
|
const unitPrice = safeMinor(
|
|
@@ -3391,6 +3437,141 @@ function validateRetrievedCustomPaymentSession(value) {
|
|
|
3391
3437
|
nullableResourceId(session.orderId, resource, "$.orderId");
|
|
3392
3438
|
return value;
|
|
3393
3439
|
}
|
|
3440
|
+
function validatePortOnePaymentCurrentState(value, resource, path) {
|
|
3441
|
+
const current = record(value, resource, path);
|
|
3442
|
+
exact(
|
|
3443
|
+
current,
|
|
3444
|
+
["paymentSession", "checkout", "order", "money"],
|
|
3445
|
+
[],
|
|
3446
|
+
resource,
|
|
3447
|
+
path
|
|
3448
|
+
);
|
|
3449
|
+
const session = record(
|
|
3450
|
+
current.paymentSession,
|
|
3451
|
+
resource,
|
|
3452
|
+
`${path}.paymentSession`
|
|
3453
|
+
);
|
|
3454
|
+
exact(
|
|
3455
|
+
session,
|
|
3456
|
+
[
|
|
3457
|
+
"id",
|
|
3458
|
+
"provider",
|
|
3459
|
+
"providerStatus",
|
|
3460
|
+
"finalizationStatus",
|
|
3461
|
+
"sessionRole",
|
|
3462
|
+
"reconciliation"
|
|
3463
|
+
],
|
|
3464
|
+
[],
|
|
3465
|
+
resource,
|
|
3466
|
+
`${path}.paymentSession`
|
|
3467
|
+
);
|
|
3468
|
+
boundedString(
|
|
3469
|
+
session.id,
|
|
3470
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3471
|
+
resource,
|
|
3472
|
+
`${path}.paymentSession.id`
|
|
3473
|
+
);
|
|
3474
|
+
if (session.provider !== "portone") {
|
|
3475
|
+
fail(resource, `${path}.paymentSession.provider`, "portone");
|
|
3476
|
+
}
|
|
3477
|
+
enumValue(
|
|
3478
|
+
session.providerStatus,
|
|
3479
|
+
PAYMENT_PROVIDER_STATUSES,
|
|
3480
|
+
resource,
|
|
3481
|
+
`${path}.paymentSession.providerStatus`
|
|
3482
|
+
);
|
|
3483
|
+
enumValue(
|
|
3484
|
+
session.finalizationStatus,
|
|
3485
|
+
["not_ready", "pending", "committed"],
|
|
3486
|
+
resource,
|
|
3487
|
+
`${path}.paymentSession.finalizationStatus`
|
|
3488
|
+
);
|
|
3489
|
+
enumValue(
|
|
3490
|
+
session.sessionRole,
|
|
3491
|
+
["active", "canonical_candidate", "canonical", "residual", "historical"],
|
|
3492
|
+
resource,
|
|
3493
|
+
`${path}.paymentSession.sessionRole`
|
|
3494
|
+
);
|
|
3495
|
+
const reconciliation = record(
|
|
3496
|
+
session.reconciliation,
|
|
3497
|
+
resource,
|
|
3498
|
+
`${path}.paymentSession.reconciliation`
|
|
3499
|
+
);
|
|
3500
|
+
if (reconciliation.status === "none") {
|
|
3501
|
+
validateNoReconciliation(
|
|
3502
|
+
reconciliation,
|
|
3503
|
+
resource,
|
|
3504
|
+
`${path}.paymentSession.reconciliation`
|
|
3505
|
+
);
|
|
3506
|
+
} else {
|
|
3507
|
+
validateRequiredReconciliation(
|
|
3508
|
+
reconciliation,
|
|
3509
|
+
PAYMENT_RECONCILIATION_REASONS,
|
|
3510
|
+
resource,
|
|
3511
|
+
`${path}.paymentSession.reconciliation`
|
|
3512
|
+
);
|
|
3513
|
+
}
|
|
3514
|
+
const checkout = record(current.checkout, resource, `${path}.checkout`);
|
|
3515
|
+
exact(checkout, ["id"], [], resource, `${path}.checkout`);
|
|
3516
|
+
boundedString(
|
|
3517
|
+
checkout.id,
|
|
3518
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3519
|
+
resource,
|
|
3520
|
+
`${path}.checkout.id`
|
|
3521
|
+
);
|
|
3522
|
+
if (current.order !== null) {
|
|
3523
|
+
const order = record(current.order, resource, `${path}.order`);
|
|
3524
|
+
exact(order, ["id", "orderNumber"], [], resource, `${path}.order`);
|
|
3525
|
+
boundedString(
|
|
3526
|
+
order.id,
|
|
3527
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3528
|
+
resource,
|
|
3529
|
+
`${path}.order.id`
|
|
3530
|
+
);
|
|
3531
|
+
nonBlankString(order.orderNumber, resource, `${path}.order.orderNumber`);
|
|
3532
|
+
}
|
|
3533
|
+
validateMoney(current.money, resource, `${path}.money`);
|
|
3534
|
+
}
|
|
3535
|
+
function validatePortOnePaymentFacadeResult(value, mutating) {
|
|
3536
|
+
const resource = mutating ? "PortOne payment reconciliation result" : "PortOne payment find result";
|
|
3537
|
+
const result = record(value, resource, "$");
|
|
3538
|
+
boolean(result.found, resource, "$.found");
|
|
3539
|
+
if (result.found === false) {
|
|
3540
|
+
exact(
|
|
3541
|
+
result,
|
|
3542
|
+
mutating ? ["found", "disposition"] : ["found"],
|
|
3543
|
+
[],
|
|
3544
|
+
resource,
|
|
3545
|
+
"$"
|
|
3546
|
+
);
|
|
3547
|
+
if (mutating && result.disposition !== "requires_attention") {
|
|
3548
|
+
fail(resource, "$.disposition", "requires_attention");
|
|
3549
|
+
}
|
|
3550
|
+
return value;
|
|
3551
|
+
}
|
|
3552
|
+
exact(
|
|
3553
|
+
result,
|
|
3554
|
+
mutating ? ["found", "disposition", "current"] : ["found", "current"],
|
|
3555
|
+
[],
|
|
3556
|
+
resource,
|
|
3557
|
+
"$"
|
|
3558
|
+
);
|
|
3559
|
+
if (mutating) {
|
|
3560
|
+
enumValue(
|
|
3561
|
+
result.disposition,
|
|
3562
|
+
[
|
|
3563
|
+
"applied",
|
|
3564
|
+
"observed",
|
|
3565
|
+
"recovered_after_ambiguous_result",
|
|
3566
|
+
"requires_attention"
|
|
3567
|
+
],
|
|
3568
|
+
resource,
|
|
3569
|
+
"$.disposition"
|
|
3570
|
+
);
|
|
3571
|
+
}
|
|
3572
|
+
validatePortOnePaymentCurrentState(result.current, resource, "$.current");
|
|
3573
|
+
return value;
|
|
3574
|
+
}
|
|
3394
3575
|
function validateConfirmCustomPaymentSessionResponse(value) {
|
|
3395
3576
|
const resource = "custom PaymentSession confirmation";
|
|
3396
3577
|
const result = record(value, resource, "$");
|
|
@@ -3445,11 +3626,21 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3445
3626
|
const action = record(value, resource, path);
|
|
3446
3627
|
if (provider === "portone") {
|
|
3447
3628
|
if (action.type === "portone_sdk") {
|
|
3629
|
+
const hasCancelable = "cancelable" in action;
|
|
3630
|
+
const hasRetryPolicy = "retryPolicy" in action;
|
|
3631
|
+
if (hasCancelable !== hasRetryPolicy) {
|
|
3632
|
+
fail(
|
|
3633
|
+
resource,
|
|
3634
|
+
path,
|
|
3635
|
+
"exact released action or exact negotiated capability action"
|
|
3636
|
+
);
|
|
3637
|
+
}
|
|
3448
3638
|
exact(
|
|
3449
3639
|
action,
|
|
3450
3640
|
[
|
|
3451
3641
|
"type",
|
|
3452
3642
|
"version",
|
|
3643
|
+
...hasCancelable ? ["cancelable", "retryPolicy"] : [],
|
|
3453
3644
|
"storeId",
|
|
3454
3645
|
"channelKey",
|
|
3455
3646
|
"paymentId",
|
|
@@ -3464,6 +3655,11 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3464
3655
|
path
|
|
3465
3656
|
);
|
|
3466
3657
|
if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
|
|
3658
|
+
if (hasCancelable && action.cancelable !== false)
|
|
3659
|
+
fail(resource, `${path}.cancelable`, "false");
|
|
3660
|
+
if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
|
|
3661
|
+
fail(resource, `${path}.retryPolicy`, "same_action_only");
|
|
3662
|
+
}
|
|
3467
3663
|
for (const key of ["storeId", "channelKey"]) {
|
|
3468
3664
|
boundedString(action[key], 255, resource, `${path}.${key}`);
|
|
3469
3665
|
}
|
|
@@ -3510,6 +3706,10 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3510
3706
|
"HTTPS or loopback URL without embedded credentials"
|
|
3511
3707
|
);
|
|
3512
3708
|
}
|
|
3709
|
+
if (!hasCancelable) {
|
|
3710
|
+
action.cancelable = false;
|
|
3711
|
+
action.retryPolicy = "same_action_only";
|
|
3712
|
+
}
|
|
3513
3713
|
return;
|
|
3514
3714
|
}
|
|
3515
3715
|
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
@@ -3827,8 +4027,8 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3827
4027
|
endpoint(key) {
|
|
3828
4028
|
return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
|
|
3829
4029
|
}
|
|
3830
|
-
execute(
|
|
3831
|
-
return this.requestEndpoint(
|
|
4030
|
+
execute(endpoint, body, idempotencyKey) {
|
|
4031
|
+
return this.requestEndpoint(endpoint, body, {
|
|
3832
4032
|
...idempotencyKey && {
|
|
3833
4033
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
3834
4034
|
}
|
|
@@ -3845,26 +4045,26 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3845
4045
|
);
|
|
3846
4046
|
}
|
|
3847
4047
|
mine(params = {}) {
|
|
3848
|
-
const
|
|
3849
|
-
return this.execute(
|
|
4048
|
+
const endpoint = this.endpoint("mine");
|
|
4049
|
+
return this.execute(endpoint, params).then(
|
|
3850
4050
|
(value) => validateCartMineResult(value)
|
|
3851
4051
|
);
|
|
3852
4052
|
}
|
|
3853
4053
|
merge(params) {
|
|
3854
4054
|
const { idempotencyKey, ...body } = params;
|
|
3855
4055
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3856
|
-
const
|
|
3857
|
-
return this.execute(
|
|
4056
|
+
const endpoint = this.endpoint("merge");
|
|
4057
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3858
4058
|
(value) => validateCartMergeResult(value)
|
|
3859
4059
|
);
|
|
3860
4060
|
}
|
|
3861
4061
|
addItem(params) {
|
|
3862
4062
|
return this.mutate(this.endpoint("addItem"), params);
|
|
3863
4063
|
}
|
|
3864
|
-
mutate(
|
|
4064
|
+
mutate(endpoint, params) {
|
|
3865
4065
|
const { idempotencyKey, ...body } = params;
|
|
3866
4066
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3867
|
-
return this.execute(
|
|
4067
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3868
4068
|
(value) => validateCartMutationResult(value)
|
|
3869
4069
|
);
|
|
3870
4070
|
}
|
|
@@ -5273,8 +5473,8 @@ var CheckoutApi = class extends CustomerScopedApi {
|
|
|
5273
5473
|
constructor(options) {
|
|
5274
5474
|
super("CheckoutApi", { ...options, requiresCredential: false });
|
|
5275
5475
|
}
|
|
5276
|
-
post(
|
|
5277
|
-
return this.requestEndpoint(
|
|
5476
|
+
post(endpoint, body, idempotencyKey) {
|
|
5477
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5278
5478
|
...idempotencyKey && {
|
|
5279
5479
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
5280
5480
|
}
|
|
@@ -5341,11 +5541,15 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5341
5541
|
super("PaymentSessionApi", { ...options, requiresCredential: false });
|
|
5342
5542
|
this.serverTransport = Boolean(options.secretKey);
|
|
5343
5543
|
}
|
|
5344
|
-
post(
|
|
5345
|
-
|
|
5346
|
-
...idempotencyKey && {
|
|
5347
|
-
|
|
5544
|
+
post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
|
|
5545
|
+
const headers = {
|
|
5546
|
+
...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
|
|
5547
|
+
...negotiateStandardActionCapabilities && {
|
|
5548
|
+
Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
|
|
5348
5549
|
}
|
|
5550
|
+
};
|
|
5551
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5552
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
5349
5553
|
});
|
|
5350
5554
|
}
|
|
5351
5555
|
async paymentSession(result, expectedProvider) {
|
|
@@ -5370,40 +5574,41 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5370
5574
|
this.post(
|
|
5371
5575
|
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
5372
5576
|
body,
|
|
5373
|
-
idempotencyKey
|
|
5577
|
+
idempotencyKey,
|
|
5578
|
+
body.providerOptions.profile === "standard_v2"
|
|
5374
5579
|
),
|
|
5375
5580
|
"portone"
|
|
5376
5581
|
);
|
|
5377
5582
|
}
|
|
5378
5583
|
retrieve(params) {
|
|
5379
|
-
const
|
|
5584
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5380
5585
|
return this.paymentSession(
|
|
5381
|
-
this.post(
|
|
5586
|
+
this.post(endpoint, params),
|
|
5382
5587
|
"toss"
|
|
5383
5588
|
);
|
|
5384
5589
|
}
|
|
5385
5590
|
retrievePortOne(params) {
|
|
5386
|
-
const
|
|
5591
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5387
5592
|
return this.paymentSession(
|
|
5388
|
-
this.post(
|
|
5593
|
+
this.post(endpoint, params, void 0, true),
|
|
5389
5594
|
"portone"
|
|
5390
5595
|
);
|
|
5391
5596
|
}
|
|
5392
5597
|
cancel(params) {
|
|
5393
5598
|
const { idempotencyKey, ...body } = params;
|
|
5394
5599
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5395
|
-
const
|
|
5600
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5396
5601
|
return this.paymentSession(
|
|
5397
|
-
this.post(
|
|
5602
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5398
5603
|
"toss"
|
|
5399
5604
|
);
|
|
5400
5605
|
}
|
|
5401
5606
|
cancelPortOne(params) {
|
|
5402
5607
|
const { idempotencyKey, ...body } = params;
|
|
5403
5608
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5404
|
-
const
|
|
5609
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5405
5610
|
return this.paymentSession(
|
|
5406
|
-
this.post(
|
|
5611
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5407
5612
|
"portone"
|
|
5408
5613
|
);
|
|
5409
5614
|
}
|
|
@@ -5420,6 +5625,34 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5420
5625
|
);
|
|
5421
5626
|
}
|
|
5422
5627
|
};
|
|
5628
|
+
var PortOnePaymentReconciliationApi = class extends BaseApi {
|
|
5629
|
+
constructor(options) {
|
|
5630
|
+
super("PortOnePaymentReconciliationApi", options);
|
|
5631
|
+
}
|
|
5632
|
+
async find(params) {
|
|
5633
|
+
const result = await this.requestEndpoint(
|
|
5634
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.findPortOne,
|
|
5635
|
+
params
|
|
5636
|
+
);
|
|
5637
|
+
return validatePortOnePaymentFacadeResult(
|
|
5638
|
+
result,
|
|
5639
|
+
false
|
|
5640
|
+
);
|
|
5641
|
+
}
|
|
5642
|
+
async reconcile(params) {
|
|
5643
|
+
const { idempotencyKey, ...body } = params;
|
|
5644
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5645
|
+
const result = await this.requestEndpoint(
|
|
5646
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.reconcilePortOne,
|
|
5647
|
+
body,
|
|
5648
|
+
{ headers: { "X-Idempotency-Key": idempotencyKey } }
|
|
5649
|
+
);
|
|
5650
|
+
return validatePortOnePaymentFacadeResult(
|
|
5651
|
+
result,
|
|
5652
|
+
true
|
|
5653
|
+
);
|
|
5654
|
+
}
|
|
5655
|
+
};
|
|
5423
5656
|
var CustomPaymentSessionApi = class extends BaseApi {
|
|
5424
5657
|
constructor(options) {
|
|
5425
5658
|
super("CustomPaymentSessionApi", options);
|
|
@@ -5549,6 +5782,9 @@ var ServerCommerceClient = class {
|
|
|
5549
5782
|
const orderApi = new OrderApi(serverOptions);
|
|
5550
5783
|
const checkoutApi = new CheckoutApi(serverOptions);
|
|
5551
5784
|
const paymentSessionApi = new PaymentSessionApi(serverOptions);
|
|
5785
|
+
const portOneReconciliationApi = new PortOnePaymentReconciliationApi(
|
|
5786
|
+
serverOptions
|
|
5787
|
+
);
|
|
5552
5788
|
const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
|
|
5553
5789
|
this.product = {
|
|
5554
5790
|
stockCheck: productApi.stockCheck.bind(productApi),
|
|
@@ -5599,6 +5835,10 @@ var ServerCommerceClient = class {
|
|
|
5599
5835
|
cancel: (params) => paymentSessionApi.cancel(params),
|
|
5600
5836
|
cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params),
|
|
5601
5837
|
confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
|
|
5838
|
+
findPortOne: portOneReconciliationApi.find.bind(portOneReconciliationApi),
|
|
5839
|
+
reconcilePortOne: portOneReconciliationApi.reconcile.bind(
|
|
5840
|
+
portOneReconciliationApi
|
|
5841
|
+
),
|
|
5602
5842
|
custom: {
|
|
5603
5843
|
create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
|
|
5604
5844
|
retrieve: customPaymentSessionApi.retrieve.bind(
|
|
@@ -5680,11 +5920,11 @@ var EventsClient = class {
|
|
|
5680
5920
|
{ useCustomerAuth: false }
|
|
5681
5921
|
);
|
|
5682
5922
|
}
|
|
5683
|
-
async execute(
|
|
5923
|
+
async execute(endpoint, method, body, options = {}) {
|
|
5684
5924
|
const useCustomerAuth = options.useCustomerAuth === true;
|
|
5685
5925
|
const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
|
|
5686
5926
|
try {
|
|
5687
|
-
const response = await httpFetch(
|
|
5927
|
+
const response = await httpFetch(endpoint, {
|
|
5688
5928
|
method,
|
|
5689
5929
|
apiUrl: this.apiUrl,
|
|
5690
5930
|
publishableKey: this.publishableKey,
|
|
@@ -5693,7 +5933,7 @@ var EventsClient = class {
|
|
|
5693
5933
|
...body !== void 0 && { body: JSON.stringify(body) }
|
|
5694
5934
|
});
|
|
5695
5935
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
5696
|
-
return parseApiResponse(response,
|
|
5936
|
+
return parseApiResponse(response, endpoint);
|
|
5697
5937
|
} catch (err) {
|
|
5698
5938
|
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
5699
5939
|
this.onRequestId?.(id);
|
|
@@ -5795,13 +6035,14 @@ var MarketDiscovery = class {
|
|
|
5795
6035
|
};
|
|
5796
6036
|
|
|
5797
6037
|
// src/core/api/tenant-introspection-api.ts
|
|
6038
|
+
var TENANT_CONTEXT_PATH = "/api/tenants/context";
|
|
5798
6039
|
var TenantIntrospectionApi = class extends RawBaseApi {
|
|
5799
6040
|
constructor(options) {
|
|
5800
6041
|
super("TenantIntrospectionApi", options);
|
|
5801
6042
|
}
|
|
5802
6043
|
context(params = {}) {
|
|
5803
|
-
const
|
|
5804
|
-
return this.request(
|
|
6044
|
+
const endpoint = params.includeCounts ? `${TENANT_CONTEXT_PATH}?counts=true` : TENANT_CONTEXT_PATH;
|
|
6045
|
+
return this.request(endpoint, void 0, {
|
|
5805
6046
|
method: "GET"
|
|
5806
6047
|
});
|
|
5807
6048
|
}
|
|
@@ -5973,6 +6214,7 @@ export {
|
|
|
5973
6214
|
ServerCollectionClient,
|
|
5974
6215
|
ServerCommerceClient,
|
|
5975
6216
|
ServerPreviewClient,
|
|
6217
|
+
TENANT_CONTEXT_PATH,
|
|
5976
6218
|
TenantIntrospectionApi,
|
|
5977
6219
|
createServerClient,
|
|
5978
6220
|
isApiError,
|