@01.software/sdk 0.46.1 → 0.48.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 +69 -1
- package/README.md +81 -7
- package/dist/client.cjs +304 -63
- 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 +304 -63
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-L2rEgBaR.d.cts → collection-client-CBup9yOx.d.cts} +4 -4
- package/dist/{collection-client-BEGXnfQe.d.ts → collection-client-D3ExJU-7.d.ts} +4 -4
- package/dist/{const-y0eipvnQ.d.cts → const-BXEi1Kix.d.cts} +4 -4
- package/dist/{const-GYVwlXLr.d.ts → const-k9gHylYa.d.ts} +4 -4
- package/dist/errors.cjs +49 -1
- 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 +49 -1
- package/dist/errors.js.map +1 -1
- package/dist/{index-BfYL6Qb1.d.cts → index-BCM9CTL7.d.cts} +3 -3
- package/dist/{index-Bei4WlVw.d.ts → index-CHGGkcLj.d.ts} +3 -3
- package/dist/index.cjs +308 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +308 -64
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-3WNyC0gk.d.cts → payload-types-B6AZQcB7.d.cts} +177 -15
- package/dist/{payload-types-3WNyC0gk.d.ts → payload-types-B6AZQcB7.d.ts} +177 -15
- package/dist/query.cjs +144 -43
- 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 +144 -43
- 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 +385 -63
- 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 +385 -63
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +49 -1
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +49 -1
- package/dist/storefront-cache.js.map +1 -1
- package/dist/{types-CAicTn-o.d.cts → types-8us-_C-Q.d.cts} +2 -2
- package/dist/{types-DpSyNTxy.d.ts → types-ByD2zii1.d.ts} +2 -2
- package/dist/{types-mIROvhhP.d.ts → types-CM2je9Kw.d.cts} +84 -7
- package/dist/{types-CDJ2M-MJ.d.cts → types-DbA5V3mt.d.ts} +84 -7
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -39,34 +39,78 @@ var SDKError = class extends Error {
|
|
|
39
39
|
};
|
|
40
40
|
var COMMERCE_ERROR_CODES = [
|
|
41
41
|
"validation_failed",
|
|
42
|
+
"bad_request",
|
|
42
43
|
"unauthorized",
|
|
43
44
|
"forbidden",
|
|
45
|
+
"account_suspended",
|
|
46
|
+
"key_invalid",
|
|
47
|
+
"pat_tenant_header_forbidden",
|
|
48
|
+
"tenant_mismatch",
|
|
49
|
+
"test_tenant_expired",
|
|
50
|
+
"token_invalid",
|
|
44
51
|
"token_expired",
|
|
45
52
|
"origin_not_allowed",
|
|
46
53
|
"server_credentials_required",
|
|
54
|
+
"role_denied",
|
|
55
|
+
"scope_denied",
|
|
56
|
+
"feature_disabled",
|
|
47
57
|
"not_found",
|
|
48
58
|
"conflict",
|
|
59
|
+
"locked",
|
|
49
60
|
"cart_revision_conflict",
|
|
50
61
|
"rate_limit_exceeded",
|
|
51
62
|
"usage_limit_exceeded",
|
|
52
63
|
"service_unavailable",
|
|
53
64
|
"idempotency_conflict",
|
|
54
65
|
"idempotency_in_progress",
|
|
66
|
+
"idempotency_key_required",
|
|
67
|
+
"invalid_idempotency_key",
|
|
55
68
|
"cart_not_active",
|
|
56
69
|
"cart_locked",
|
|
57
70
|
"cart_empty",
|
|
58
71
|
"cart_market_unavailable",
|
|
59
72
|
"cart_market_mismatch",
|
|
60
73
|
"checkout_not_open",
|
|
74
|
+
"checkout_already_open",
|
|
61
75
|
"payment_slot_held",
|
|
62
76
|
"reservation_expired",
|
|
63
77
|
"payment_session_not_cancelable",
|
|
78
|
+
"payment_session_conflict",
|
|
64
79
|
"provider_identity_mismatch",
|
|
80
|
+
"payment_method_unavailable",
|
|
65
81
|
"provider_unavailable",
|
|
66
82
|
"lock_timeout",
|
|
67
83
|
"price_changed",
|
|
68
84
|
"pricing_fact_in_use",
|
|
69
85
|
"insufficient_stock",
|
|
86
|
+
"reservation_conflict",
|
|
87
|
+
"stock_lock_unavailable",
|
|
88
|
+
"variant_not_found",
|
|
89
|
+
"variant_stock_write_failed",
|
|
90
|
+
"stock_invariant_violation",
|
|
91
|
+
"payment_confirmation_in_flight",
|
|
92
|
+
"checkout_reservation_release_requires_transaction",
|
|
93
|
+
"admission_metadata_invalid",
|
|
94
|
+
"admission_metadata_required",
|
|
95
|
+
"capacity_exceeded",
|
|
96
|
+
"occurrence_lock_unavailable",
|
|
97
|
+
"occurrence_not_open",
|
|
98
|
+
"admission_type_capacity_exceeded",
|
|
99
|
+
"admission_type_occurrence_mismatch",
|
|
100
|
+
"admission_hold_expired",
|
|
101
|
+
"admission_hold_checkout_item_conflict",
|
|
102
|
+
"admission_hold_checkout_conflict",
|
|
103
|
+
"admission_hold_quantity_mismatch",
|
|
104
|
+
"admission_hold_unbound",
|
|
105
|
+
"admission_hold_missing",
|
|
106
|
+
"admission_hold_checkout_item_missing",
|
|
107
|
+
"admission_hold_expiry_failed",
|
|
108
|
+
"admission_hold_expiry_requires_transaction",
|
|
109
|
+
"admission_hold_line_item_mismatch",
|
|
110
|
+
"admission_materialization_failed",
|
|
111
|
+
"variant_inactive",
|
|
112
|
+
"variant_product_mismatch",
|
|
113
|
+
"product_not_public",
|
|
70
114
|
"market_not_found",
|
|
71
115
|
"market_shipping_currency_unsupported",
|
|
72
116
|
"missing_market_rate",
|
|
@@ -91,7 +135,11 @@ var COMMERCE_ERROR_CODES = [
|
|
|
91
135
|
"discount_min_order_amount",
|
|
92
136
|
"discount_currency_scope_required",
|
|
93
137
|
"discount_allocation_method_unsupported",
|
|
94
|
-
"currency_mismatch"
|
|
138
|
+
"currency_mismatch",
|
|
139
|
+
"customer_token_required",
|
|
140
|
+
"market_required",
|
|
141
|
+
"server_derived",
|
|
142
|
+
"internal_error"
|
|
95
143
|
];
|
|
96
144
|
var COMMERCE_ERROR_CODE_SET = new Set(
|
|
97
145
|
COMMERCE_ERROR_CODES
|
|
@@ -117,6 +165,12 @@ function commerceProtocolError(issue, trustedRequestId) {
|
|
|
117
165
|
);
|
|
118
166
|
}
|
|
119
167
|
function parseCommerceErrorEnvelope(body, headerRequestId) {
|
|
168
|
+
if (headerRequestId === void 0) {
|
|
169
|
+
throw commerceProtocolError("missing_request_id_header");
|
|
170
|
+
}
|
|
171
|
+
if (headerRequestId.length === 0) {
|
|
172
|
+
throw commerceProtocolError("empty_request_id_header");
|
|
173
|
+
}
|
|
120
174
|
if (!isPlainRecord(body)) {
|
|
121
175
|
throw commerceProtocolError("expected_object", headerRequestId);
|
|
122
176
|
}
|
|
@@ -126,7 +180,7 @@ function parseCommerceErrorEnvelope(body, headerRequestId) {
|
|
|
126
180
|
if (typeof body.error !== "string" || body.error.length === 0 || typeof body.reason !== "string" || body.reason.length === 0 || typeof body.requestId !== "string" || body.requestId.length === 0 || body.retryable !== void 0 && typeof body.retryable !== "boolean" || body.details !== void 0 && !isPlainRecord(body.details)) {
|
|
127
181
|
throw commerceProtocolError("invalid_field", headerRequestId);
|
|
128
182
|
}
|
|
129
|
-
if (headerRequestId && headerRequestId !== body.requestId) {
|
|
183
|
+
if (headerRequestId !== void 0 && headerRequestId !== body.requestId) {
|
|
130
184
|
throw commerceProtocolError("request_id_mismatch", headerRequestId);
|
|
131
185
|
}
|
|
132
186
|
return {
|
|
@@ -1155,7 +1209,10 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1155
1209
|
return parsed;
|
|
1156
1210
|
}
|
|
1157
1211
|
const data = parsed;
|
|
1158
|
-
|
|
1212
|
+
const hasCommerceEnvelopeSignal = options.errorFamily === "commerce" && ["error", "reason", "requestId", "retryable", "details"].some(
|
|
1213
|
+
(key) => Object.prototype.hasOwnProperty.call(data, key)
|
|
1214
|
+
);
|
|
1215
|
+
if (data.error || hasCommerceEnvelopeSignal) {
|
|
1159
1216
|
const errorMessage = typeof data.error === "string" ? data.error : "Unknown API error";
|
|
1160
1217
|
const reason = typeof data.reason === "string" ? data.reason : void 0;
|
|
1161
1218
|
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
@@ -1191,12 +1248,14 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1191
1248
|
|
|
1192
1249
|
// ../../internal/http-contracts/src/index.ts
|
|
1193
1250
|
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
1194
|
-
var operation = (collection, method, path) => Object.freeze({
|
|
1251
|
+
var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
1195
1252
|
[operationBrand]: true,
|
|
1196
1253
|
collection,
|
|
1197
1254
|
method,
|
|
1198
|
-
path
|
|
1255
|
+
path,
|
|
1256
|
+
...errorFamily && { errorFamily }
|
|
1199
1257
|
});
|
|
1258
|
+
var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
|
|
1200
1259
|
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
1201
1260
|
products: {
|
|
1202
1261
|
detail: operation("products", "get", "/detail"),
|
|
@@ -1229,13 +1288,13 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1229
1288
|
byPayment: operation("orders", "get", "/by-payment"),
|
|
1230
1289
|
cancel: operation("orders", "post", "/cancel"),
|
|
1231
1290
|
resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
|
|
1232
|
-
checkout:
|
|
1291
|
+
checkout: strictCommerceOperation("orders", "post", "/checkout"),
|
|
1233
1292
|
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
1234
1293
|
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
1235
1294
|
},
|
|
1236
1295
|
checkouts: {
|
|
1237
|
-
detail:
|
|
1238
|
-
query:
|
|
1296
|
+
detail: strictCommerceOperation("checkouts", "post", "/detail"),
|
|
1297
|
+
query: strictCommerceOperation("checkouts", "post", "/query")
|
|
1239
1298
|
},
|
|
1240
1299
|
transactions: {
|
|
1241
1300
|
update: operation("transactions", "post", "/update")
|
|
@@ -1256,29 +1315,58 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1256
1315
|
bulkImport: operation("fulfillments", "post", "/bulk-import")
|
|
1257
1316
|
},
|
|
1258
1317
|
carts: {
|
|
1259
|
-
create:
|
|
1260
|
-
retrieve:
|
|
1261
|
-
mine:
|
|
1262
|
-
merge:
|
|
1263
|
-
addItem:
|
|
1264
|
-
updateItem:
|
|
1265
|
-
removeItem:
|
|
1266
|
-
updateDiscountCodes:
|
|
1267
|
-
|
|
1268
|
-
|
|
1318
|
+
create: strictCommerceOperation("carts", "post", "/create"),
|
|
1319
|
+
retrieve: strictCommerceOperation("carts", "post", "/retrieve"),
|
|
1320
|
+
mine: strictCommerceOperation("carts", "post", "/mine"),
|
|
1321
|
+
merge: strictCommerceOperation("carts", "post", "/merge"),
|
|
1322
|
+
addItem: strictCommerceOperation("carts", "post", "/add-item"),
|
|
1323
|
+
updateItem: strictCommerceOperation("carts", "post", "/update-item"),
|
|
1324
|
+
removeItem: strictCommerceOperation("carts", "post", "/remove-item"),
|
|
1325
|
+
updateDiscountCodes: strictCommerceOperation(
|
|
1326
|
+
"carts",
|
|
1327
|
+
"post",
|
|
1328
|
+
"/update-discount-codes"
|
|
1329
|
+
),
|
|
1330
|
+
updateAttributes: strictCommerceOperation(
|
|
1331
|
+
"carts",
|
|
1332
|
+
"post",
|
|
1333
|
+
"/update-attributes"
|
|
1334
|
+
),
|
|
1335
|
+
clear: strictCommerceOperation("carts", "post", "/clear")
|
|
1269
1336
|
},
|
|
1270
1337
|
paymentSessions: {
|
|
1271
|
-
create:
|
|
1272
|
-
retrieve:
|
|
1273
|
-
cancel:
|
|
1338
|
+
create: strictCommerceOperation("payment-sessions", "post", "/create"),
|
|
1339
|
+
retrieve: strictCommerceOperation("payment-sessions", "post", "/retrieve"),
|
|
1340
|
+
cancel: strictCommerceOperation("payment-sessions", "post", "/cancel"),
|
|
1274
1341
|
server: {
|
|
1275
|
-
create:
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1342
|
+
create: strictCommerceOperation(
|
|
1343
|
+
"payment-sessions",
|
|
1344
|
+
"post",
|
|
1345
|
+
"/server/create"
|
|
1346
|
+
),
|
|
1347
|
+
retrieve: strictCommerceOperation(
|
|
1348
|
+
"payment-sessions",
|
|
1349
|
+
"post",
|
|
1350
|
+
"/server/retrieve"
|
|
1351
|
+
),
|
|
1352
|
+
cancel: strictCommerceOperation(
|
|
1353
|
+
"payment-sessions",
|
|
1354
|
+
"post",
|
|
1355
|
+
"/server/cancel"
|
|
1356
|
+
),
|
|
1357
|
+
confirm: strictCommerceOperation(
|
|
1358
|
+
"payment-sessions",
|
|
1359
|
+
"post",
|
|
1360
|
+
"/server/confirm"
|
|
1361
|
+
)
|
|
1279
1362
|
},
|
|
1280
1363
|
custom: {
|
|
1281
1364
|
create: operation("orders", "post", "/custom-payment-sessions"),
|
|
1365
|
+
retrieve: operation(
|
|
1366
|
+
"orders",
|
|
1367
|
+
"post",
|
|
1368
|
+
"/custom-payment-sessions/retrieve"
|
|
1369
|
+
),
|
|
1282
1370
|
confirm: operation("orders", "post", "/custom-payment-sessions/confirm")
|
|
1283
1371
|
}
|
|
1284
1372
|
},
|
|
@@ -1304,6 +1392,11 @@ var EVENTS_ENDPOINT_OPERATIONS = {
|
|
|
1304
1392
|
)
|
|
1305
1393
|
}
|
|
1306
1394
|
};
|
|
1395
|
+
var COMMUNITY_ENDPOINT_OPERATIONS = {
|
|
1396
|
+
posts: {
|
|
1397
|
+
detail: operation("posts", "get", "/detail")
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1307
1400
|
function resolveOperationTemplate(descriptor) {
|
|
1308
1401
|
return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
|
|
1309
1402
|
}
|
|
@@ -1335,6 +1428,9 @@ var sharedEndpoint = (descriptor) => descriptor;
|
|
|
1335
1428
|
function resolveOperationMethod2(descriptor) {
|
|
1336
1429
|
return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
|
|
1337
1430
|
}
|
|
1431
|
+
function resolveOperationErrorFamily(descriptor) {
|
|
1432
|
+
return "collection" in descriptor ? descriptor.errorFamily : void 0;
|
|
1433
|
+
}
|
|
1338
1434
|
function resolveOperationPath2(descriptor, options) {
|
|
1339
1435
|
if ("collection" in descriptor) {
|
|
1340
1436
|
return resolveOperationPath(descriptor, options);
|
|
@@ -1369,12 +1465,12 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1369
1465
|
updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
|
|
1370
1466
|
},
|
|
1371
1467
|
checkouts: {
|
|
1372
|
-
create:
|
|
1373
|
-
retrieve:
|
|
1468
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
1469
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),
|
|
1374
1470
|
server: {
|
|
1375
|
-
create:
|
|
1376
|
-
retrieve:
|
|
1377
|
-
query:
|
|
1471
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
1472
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),
|
|
1473
|
+
query: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.query)
|
|
1378
1474
|
}
|
|
1379
1475
|
},
|
|
1380
1476
|
returns: {
|
|
@@ -1392,10 +1488,10 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1392
1488
|
bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
|
|
1393
1489
|
},
|
|
1394
1490
|
carts: {
|
|
1395
|
-
create:
|
|
1491
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
1396
1492
|
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
1397
|
-
mine:
|
|
1398
|
-
merge:
|
|
1493
|
+
mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),
|
|
1494
|
+
merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),
|
|
1399
1495
|
server: {
|
|
1400
1496
|
// Server credentials are an authorization lane, not a second Cart
|
|
1401
1497
|
// transport. These must stay bound to the registered shared operations.
|
|
@@ -1415,29 +1511,46 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1415
1511
|
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
1416
1512
|
},
|
|
1417
1513
|
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
1418
|
-
updateItem:
|
|
1419
|
-
removeItem:
|
|
1420
|
-
updateDiscountCodes:
|
|
1421
|
-
|
|
1422
|
-
|
|
1514
|
+
updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),
|
|
1515
|
+
removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),
|
|
1516
|
+
updateDiscountCodes: sharedEndpoint(
|
|
1517
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes
|
|
1518
|
+
),
|
|
1519
|
+
updateAttributes: sharedEndpoint(
|
|
1520
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes
|
|
1521
|
+
),
|
|
1522
|
+
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
1423
1523
|
},
|
|
1424
1524
|
paymentSessions: {
|
|
1425
|
-
create:
|
|
1426
|
-
retrieve:
|
|
1427
|
-
|
|
1525
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create),
|
|
1526
|
+
retrieve: sharedEndpoint(
|
|
1527
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve
|
|
1528
|
+
),
|
|
1529
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.cancel),
|
|
1428
1530
|
custom: {
|
|
1429
1531
|
create: sharedEndpoint(
|
|
1430
1532
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create
|
|
1431
1533
|
),
|
|
1534
|
+
retrieve: sharedEndpoint(
|
|
1535
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.retrieve
|
|
1536
|
+
),
|
|
1432
1537
|
confirm: sharedEndpoint(
|
|
1433
1538
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm
|
|
1434
1539
|
)
|
|
1435
1540
|
},
|
|
1436
1541
|
server: {
|
|
1437
|
-
create:
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1542
|
+
create: sharedEndpoint(
|
|
1543
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create
|
|
1544
|
+
),
|
|
1545
|
+
retrieve: sharedEndpoint(
|
|
1546
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
1547
|
+
),
|
|
1548
|
+
cancel: sharedEndpoint(
|
|
1549
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.cancel
|
|
1550
|
+
),
|
|
1551
|
+
confirm: sharedEndpoint(
|
|
1552
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1553
|
+
)
|
|
1441
1554
|
}
|
|
1442
1555
|
},
|
|
1443
1556
|
shippingPolicies: {
|
|
@@ -1528,7 +1641,8 @@ var CustomerScopedApi = class {
|
|
|
1528
1641
|
return this.transport.request(resolveOperationPath2(endpoint2, options), {
|
|
1529
1642
|
method: resolveOperationMethod2(endpoint2),
|
|
1530
1643
|
body,
|
|
1531
|
-
headers: options?.headers
|
|
1644
|
+
headers: options?.headers,
|
|
1645
|
+
errorFamily: resolveOperationErrorFamily(endpoint2)
|
|
1532
1646
|
});
|
|
1533
1647
|
}
|
|
1534
1648
|
};
|
|
@@ -1550,15 +1664,39 @@ function unwrapPayloadDoc(value) {
|
|
|
1550
1664
|
}
|
|
1551
1665
|
return value;
|
|
1552
1666
|
}
|
|
1667
|
+
function hasCanonicalNotFoundReason(error) {
|
|
1668
|
+
const details = error.details;
|
|
1669
|
+
if (typeof details !== "object" || details === null) return false;
|
|
1670
|
+
if ("reason" in details && details.reason === "not_found") return true;
|
|
1671
|
+
if (!("body" in details) || typeof details.body !== "object" || details.body === null) {
|
|
1672
|
+
return false;
|
|
1673
|
+
}
|
|
1674
|
+
return "reason" in details.body && details.body.reason === "not_found";
|
|
1675
|
+
}
|
|
1553
1676
|
var CommunityClient = class extends RawCustomerScopedApi {
|
|
1554
1677
|
constructor(options) {
|
|
1555
1678
|
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1679
|
+
this.requiresSafePublicRawReads = !options.secretKey;
|
|
1556
1680
|
}
|
|
1557
1681
|
buildQuery(params) {
|
|
1558
1682
|
if (!params) return "";
|
|
1559
1683
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
1560
1684
|
return entries.length ? `?${new URLSearchParams(entries).toString()}` : "";
|
|
1561
1685
|
}
|
|
1686
|
+
withSafePublicRawReadQuery(query) {
|
|
1687
|
+
if (!this.requiresSafePublicRawReads) return query;
|
|
1688
|
+
if (!query) return "?depth=0&joins=false";
|
|
1689
|
+
return `?depth=0&joins=false&${query.slice(1)}`;
|
|
1690
|
+
}
|
|
1691
|
+
buildSafePublicRawListQuery(params) {
|
|
1692
|
+
if (!this.requiresSafePublicRawReads) {
|
|
1693
|
+
return this.buildQuery(params);
|
|
1694
|
+
}
|
|
1695
|
+
const queryParams = {};
|
|
1696
|
+
if (params?.page !== void 0) queryParams.page = params.page;
|
|
1697
|
+
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1698
|
+
return this.withSafePublicRawReadQuery(this.buildQuery(queryParams));
|
|
1699
|
+
}
|
|
1562
1700
|
buildPostsListQuery(params) {
|
|
1563
1701
|
const urlParams = new URLSearchParams();
|
|
1564
1702
|
const sort = params?.sort ?? DEFAULT_POST_LIST_SORT;
|
|
@@ -1618,15 +1756,35 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1618
1756
|
"GET"
|
|
1619
1757
|
);
|
|
1620
1758
|
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Public post detail projected by the same allowlist as the public feed.
|
|
1761
|
+
* Missing, hidden, and cross-tenant posts all resolve to `null`.
|
|
1762
|
+
*/
|
|
1763
|
+
async getPost(params) {
|
|
1764
|
+
const query = new URLSearchParams({ postId: params.postId });
|
|
1765
|
+
try {
|
|
1766
|
+
return await this.execute(
|
|
1767
|
+
resolveOperationPath(COMMUNITY_ENDPOINT_OPERATIONS.posts.detail, {
|
|
1768
|
+
query
|
|
1769
|
+
}),
|
|
1770
|
+
resolveOperationMethod(COMMUNITY_ENDPOINT_OPERATIONS.posts.detail)
|
|
1771
|
+
);
|
|
1772
|
+
} catch (error) {
|
|
1773
|
+
if (error instanceof NotFoundError && hasCanonicalNotFoundReason(error)) {
|
|
1774
|
+
return null;
|
|
1775
|
+
}
|
|
1776
|
+
throw error;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1621
1779
|
listPostCategories(params) {
|
|
1622
1780
|
return this.execute(
|
|
1623
|
-
`/api/post-categories${this.
|
|
1781
|
+
`/api/post-categories${this.buildSafePublicRawListQuery(params)}`,
|
|
1624
1782
|
"GET"
|
|
1625
1783
|
);
|
|
1626
1784
|
}
|
|
1627
1785
|
listPostTags(params) {
|
|
1628
1786
|
return this.execute(
|
|
1629
|
-
`/api/post-tags${this.
|
|
1787
|
+
`/api/post-tags${this.buildSafePublicRawListQuery(params)}`,
|
|
1630
1788
|
"GET"
|
|
1631
1789
|
);
|
|
1632
1790
|
}
|
|
@@ -1792,7 +1950,7 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1792
1950
|
}
|
|
1793
1951
|
getReactionTypes() {
|
|
1794
1952
|
return this.execute(
|
|
1795
|
-
|
|
1953
|
+
`/api/reaction-types${this.buildSafePublicRawListQuery({ limit: 100 })}`,
|
|
1796
1954
|
"GET"
|
|
1797
1955
|
);
|
|
1798
1956
|
}
|
|
@@ -1820,11 +1978,17 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1820
1978
|
}
|
|
1821
1979
|
// Profiles
|
|
1822
1980
|
listProfileLists(params) {
|
|
1823
|
-
return this.execute(
|
|
1981
|
+
return this.execute(
|
|
1982
|
+
`/api/customer-profile-lists${this.buildSafePublicRawListQuery(params)}`,
|
|
1983
|
+
"GET"
|
|
1984
|
+
);
|
|
1824
1985
|
}
|
|
1825
1986
|
async getProfileList(params) {
|
|
1826
1987
|
const query = "slug" in params ? `?where[slug][equals]=${encodeURIComponent(params.slug)}&limit=1` : `?where[id][equals]=${encodeURIComponent(params.id)}&limit=1`;
|
|
1827
|
-
const res = await this.execute(
|
|
1988
|
+
const res = await this.execute(
|
|
1989
|
+
`/api/customer-profile-lists${this.withSafePublicRawReadQuery(query)}`,
|
|
1990
|
+
"GET"
|
|
1991
|
+
);
|
|
1828
1992
|
return res.docs[0] ?? null;
|
|
1829
1993
|
}
|
|
1830
1994
|
updatePublicProfile(body) {
|
|
@@ -1937,7 +2101,7 @@ var ORDER_PRIMARY_DISPLAY_STATUSES = [
|
|
|
1937
2101
|
];
|
|
1938
2102
|
var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
|
|
1939
2103
|
var ABANDONED_REASONS = ["expired", "customer", "operator"];
|
|
1940
|
-
var PAYMENT_PROVIDERS = ["toss"];
|
|
2104
|
+
var PAYMENT_PROVIDERS = ["toss", "portone"];
|
|
1941
2105
|
var PAYMENT_PROVIDER_STATUSES = [
|
|
1942
2106
|
"requires_payment_method",
|
|
1943
2107
|
"requires_action",
|
|
@@ -3110,8 +3274,33 @@ function validateRequiredReconciliation(value, allowed, resource, path) {
|
|
|
3110
3274
|
previous = current;
|
|
3111
3275
|
});
|
|
3112
3276
|
}
|
|
3113
|
-
function validateNextAction(value, resource, path) {
|
|
3277
|
+
function validateNextAction(value, provider, resource, path) {
|
|
3114
3278
|
const action = record(value, resource, path);
|
|
3279
|
+
if (provider === "portone") {
|
|
3280
|
+
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
3281
|
+
if (action.type !== "portone_checkout") {
|
|
3282
|
+
fail(resource, `${path}.type`, "portone_checkout");
|
|
3283
|
+
}
|
|
3284
|
+
const checkoutUrl = boundedString(
|
|
3285
|
+
action.checkoutUrl,
|
|
3286
|
+
2048,
|
|
3287
|
+
resource,
|
|
3288
|
+
`${path}.checkoutUrl`
|
|
3289
|
+
);
|
|
3290
|
+
try {
|
|
3291
|
+
const parsed = new URL(checkoutUrl);
|
|
3292
|
+
if (parsed.protocol !== "https:" || parsed.username !== "" || parsed.password !== "") {
|
|
3293
|
+
throw new Error("unsafe checkout URL");
|
|
3294
|
+
}
|
|
3295
|
+
} catch {
|
|
3296
|
+
fail(
|
|
3297
|
+
resource,
|
|
3298
|
+
`${path}.checkoutUrl`,
|
|
3299
|
+
"absolute HTTPS URL without embedded credentials"
|
|
3300
|
+
);
|
|
3301
|
+
}
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3115
3304
|
exact(
|
|
3116
3305
|
action,
|
|
3117
3306
|
[
|
|
@@ -3162,10 +3351,18 @@ function validateNextAction(value, resource, path) {
|
|
|
3162
3351
|
if (action.customerEmail !== void 0)
|
|
3163
3352
|
validateCustomer({ email: action.customerEmail }, resource, path);
|
|
3164
3353
|
}
|
|
3165
|
-
function validatePublicPaymentSession(value) {
|
|
3354
|
+
function validatePublicPaymentSession(value, expectedProvider) {
|
|
3166
3355
|
const resource = "PaymentSession";
|
|
3167
3356
|
const session = record(value, resource, "$");
|
|
3168
|
-
|
|
3357
|
+
const provider = enumValue(
|
|
3358
|
+
session.provider,
|
|
3359
|
+
PAYMENT_PROVIDERS,
|
|
3360
|
+
resource,
|
|
3361
|
+
"$.provider"
|
|
3362
|
+
);
|
|
3363
|
+
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
3364
|
+
fail(resource, "$.provider", expectedProvider);
|
|
3365
|
+
}
|
|
3169
3366
|
const status = enumValue(
|
|
3170
3367
|
session.providerStatus,
|
|
3171
3368
|
PAYMENT_PROVIDER_STATUSES,
|
|
@@ -3202,7 +3399,12 @@ function validatePublicPaymentSession(value) {
|
|
|
3202
3399
|
}
|
|
3203
3400
|
if (!("nextAction" in session))
|
|
3204
3401
|
fail(resource, "$.nextAction", "required field");
|
|
3205
|
-
validateNextAction(
|
|
3402
|
+
validateNextAction(
|
|
3403
|
+
session.nextAction,
|
|
3404
|
+
provider,
|
|
3405
|
+
resource,
|
|
3406
|
+
"$.nextAction"
|
|
3407
|
+
);
|
|
3206
3408
|
} else if (session.sessionRole === "residual") {
|
|
3207
3409
|
if (session.presentationStatus !== "suppressed" || session.finalizationStatus !== "not_ready") {
|
|
3208
3410
|
fail(resource, "$", "suppressed residual not-ready state");
|
|
@@ -3945,8 +4147,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
3945
4147
|
}
|
|
3946
4148
|
});
|
|
3947
4149
|
}
|
|
3948
|
-
async paymentSession(result) {
|
|
3949
|
-
return validatePublicPaymentSession(await result);
|
|
4150
|
+
async paymentSession(result, expectedProvider) {
|
|
4151
|
+
return validatePublicPaymentSession(await result, expectedProvider);
|
|
3950
4152
|
}
|
|
3951
4153
|
create(params) {
|
|
3952
4154
|
const { idempotencyKey, ...body } = params;
|
|
@@ -3956,18 +4158,53 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
3956
4158
|
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
3957
4159
|
body,
|
|
3958
4160
|
idempotencyKey
|
|
3959
|
-
)
|
|
4161
|
+
),
|
|
4162
|
+
"toss"
|
|
4163
|
+
);
|
|
4164
|
+
}
|
|
4165
|
+
createPortOne(params) {
|
|
4166
|
+
const { idempotencyKey, ...body } = params;
|
|
4167
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
4168
|
+
return this.paymentSession(
|
|
4169
|
+
this.post(
|
|
4170
|
+
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
4171
|
+
body,
|
|
4172
|
+
idempotencyKey
|
|
4173
|
+
),
|
|
4174
|
+
"portone"
|
|
3960
4175
|
);
|
|
3961
4176
|
}
|
|
3962
4177
|
retrieve(params) {
|
|
3963
4178
|
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
3964
|
-
return this.paymentSession(
|
|
4179
|
+
return this.paymentSession(
|
|
4180
|
+
this.post(endpoint2, params),
|
|
4181
|
+
"toss"
|
|
4182
|
+
);
|
|
4183
|
+
}
|
|
4184
|
+
retrievePortOne(params) {
|
|
4185
|
+
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
4186
|
+
return this.paymentSession(
|
|
4187
|
+
this.post(endpoint2, params),
|
|
4188
|
+
"portone"
|
|
4189
|
+
);
|
|
3965
4190
|
}
|
|
3966
4191
|
cancel(params) {
|
|
3967
4192
|
const { idempotencyKey, ...body } = params;
|
|
3968
4193
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3969
4194
|
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
3970
|
-
return this.paymentSession(
|
|
4195
|
+
return this.paymentSession(
|
|
4196
|
+
this.post(endpoint2, body, idempotencyKey),
|
|
4197
|
+
"toss"
|
|
4198
|
+
);
|
|
4199
|
+
}
|
|
4200
|
+
cancelPortOne(params) {
|
|
4201
|
+
const { idempotencyKey, ...body } = params;
|
|
4202
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
4203
|
+
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
4204
|
+
return this.paymentSession(
|
|
4205
|
+
this.post(endpoint2, body, idempotencyKey),
|
|
4206
|
+
"portone"
|
|
4207
|
+
);
|
|
3971
4208
|
}
|
|
3972
4209
|
confirm(params) {
|
|
3973
4210
|
const { idempotencyKey, ...body } = params;
|
|
@@ -3977,7 +4214,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
3977
4214
|
COMMERCE_ENDPOINTS.paymentSessions.server.confirm,
|
|
3978
4215
|
body,
|
|
3979
4216
|
idempotencyKey
|
|
3980
|
-
)
|
|
4217
|
+
),
|
|
4218
|
+
"toss"
|
|
3981
4219
|
);
|
|
3982
4220
|
}
|
|
3983
4221
|
};
|
|
@@ -5947,8 +6185,11 @@ var CommerceClient = class {
|
|
|
5947
6185
|
};
|
|
5948
6186
|
this.paymentSessions = {
|
|
5949
6187
|
create: paymentSessionApi.create.bind(paymentSessionApi),
|
|
6188
|
+
createPortOne: paymentSessionApi.createPortOne.bind(paymentSessionApi),
|
|
5950
6189
|
retrieve: (params) => paymentSessionApi.retrieve(params),
|
|
5951
|
-
|
|
6190
|
+
retrievePortOne: (params) => paymentSessionApi.retrievePortOne(params),
|
|
6191
|
+
cancel: (params) => paymentSessionApi.cancel(params),
|
|
6192
|
+
cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params)
|
|
5952
6193
|
};
|
|
5953
6194
|
this.discounts = {
|
|
5954
6195
|
validate: (params) => api.requestEndpoint(
|
|
@@ -6609,7 +6850,6 @@ var INTERNAL_COLLECTIONS = [
|
|
|
6609
6850
|
"payment-provider-customer-aliases"
|
|
6610
6851
|
];
|
|
6611
6852
|
var COLLECTIONS = [
|
|
6612
|
-
"tenants",
|
|
6613
6853
|
"tenant-metadata",
|
|
6614
6854
|
"products",
|
|
6615
6855
|
"product-variants",
|
|
@@ -6669,6 +6909,10 @@ var COLLECTIONS = [
|
|
|
6669
6909
|
"customer-memberships"
|
|
6670
6910
|
];
|
|
6671
6911
|
var SERVER_ONLY_COLLECTIONS = [
|
|
6912
|
+
// The tenant record itself denies reads without an authenticated user, so a
|
|
6913
|
+
// publishable key never reaches it; `tenant-metadata` is the browser-public
|
|
6914
|
+
// tenant identity surface.
|
|
6915
|
+
"tenants",
|
|
6672
6916
|
"tenant-logos",
|
|
6673
6917
|
"brand-logos",
|
|
6674
6918
|
"images",
|