@01.software/sdk 0.46.0 → 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 +75 -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-DolMjCoC.d.cts → collection-client-CBup9yOx.d.cts} +4 -4
- package/dist/{collection-client-D6kKrYdq.d.ts → collection-client-D3ExJU-7.d.ts} +4 -4
- package/dist/{const-BAG0MH0u.d.cts → const-BXEi1Kix.d.cts} +4 -4
- package/dist/{const-CaPq2AE4.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-YGrZrxNn.d.cts → index-BCM9CTL7.d.cts} +3 -3
- package/dist/{index-BNICJxBL.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-CJZuXcgF.d.cts → payload-types-B6AZQcB7.d.cts} +182 -15
- package/dist/{payload-types-CJZuXcgF.d.ts → payload-types-B6AZQcB7.d.ts} +182 -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-D5p7-m1l.d.cts → types-8us-_C-Q.d.cts} +2 -2
- package/dist/{types-BC6rVmJa.d.ts → types-ByD2zii1.d.ts} +2 -2
- package/dist/{types-xlqBeW2N.d.cts → types-CM2je9Kw.d.cts} +84 -7
- package/dist/{types-C60vHIkY.d.ts → 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.cjs
CHANGED
|
@@ -184,34 +184,78 @@ var SDKError = class extends Error {
|
|
|
184
184
|
};
|
|
185
185
|
var COMMERCE_ERROR_CODES = [
|
|
186
186
|
"validation_failed",
|
|
187
|
+
"bad_request",
|
|
187
188
|
"unauthorized",
|
|
188
189
|
"forbidden",
|
|
190
|
+
"account_suspended",
|
|
191
|
+
"key_invalid",
|
|
192
|
+
"pat_tenant_header_forbidden",
|
|
193
|
+
"tenant_mismatch",
|
|
194
|
+
"test_tenant_expired",
|
|
195
|
+
"token_invalid",
|
|
189
196
|
"token_expired",
|
|
190
197
|
"origin_not_allowed",
|
|
191
198
|
"server_credentials_required",
|
|
199
|
+
"role_denied",
|
|
200
|
+
"scope_denied",
|
|
201
|
+
"feature_disabled",
|
|
192
202
|
"not_found",
|
|
193
203
|
"conflict",
|
|
204
|
+
"locked",
|
|
194
205
|
"cart_revision_conflict",
|
|
195
206
|
"rate_limit_exceeded",
|
|
196
207
|
"usage_limit_exceeded",
|
|
197
208
|
"service_unavailable",
|
|
198
209
|
"idempotency_conflict",
|
|
199
210
|
"idempotency_in_progress",
|
|
211
|
+
"idempotency_key_required",
|
|
212
|
+
"invalid_idempotency_key",
|
|
200
213
|
"cart_not_active",
|
|
201
214
|
"cart_locked",
|
|
202
215
|
"cart_empty",
|
|
203
216
|
"cart_market_unavailable",
|
|
204
217
|
"cart_market_mismatch",
|
|
205
218
|
"checkout_not_open",
|
|
219
|
+
"checkout_already_open",
|
|
206
220
|
"payment_slot_held",
|
|
207
221
|
"reservation_expired",
|
|
208
222
|
"payment_session_not_cancelable",
|
|
223
|
+
"payment_session_conflict",
|
|
209
224
|
"provider_identity_mismatch",
|
|
225
|
+
"payment_method_unavailable",
|
|
210
226
|
"provider_unavailable",
|
|
211
227
|
"lock_timeout",
|
|
212
228
|
"price_changed",
|
|
213
229
|
"pricing_fact_in_use",
|
|
214
230
|
"insufficient_stock",
|
|
231
|
+
"reservation_conflict",
|
|
232
|
+
"stock_lock_unavailable",
|
|
233
|
+
"variant_not_found",
|
|
234
|
+
"variant_stock_write_failed",
|
|
235
|
+
"stock_invariant_violation",
|
|
236
|
+
"payment_confirmation_in_flight",
|
|
237
|
+
"checkout_reservation_release_requires_transaction",
|
|
238
|
+
"admission_metadata_invalid",
|
|
239
|
+
"admission_metadata_required",
|
|
240
|
+
"capacity_exceeded",
|
|
241
|
+
"occurrence_lock_unavailable",
|
|
242
|
+
"occurrence_not_open",
|
|
243
|
+
"admission_type_capacity_exceeded",
|
|
244
|
+
"admission_type_occurrence_mismatch",
|
|
245
|
+
"admission_hold_expired",
|
|
246
|
+
"admission_hold_checkout_item_conflict",
|
|
247
|
+
"admission_hold_checkout_conflict",
|
|
248
|
+
"admission_hold_quantity_mismatch",
|
|
249
|
+
"admission_hold_unbound",
|
|
250
|
+
"admission_hold_missing",
|
|
251
|
+
"admission_hold_checkout_item_missing",
|
|
252
|
+
"admission_hold_expiry_failed",
|
|
253
|
+
"admission_hold_expiry_requires_transaction",
|
|
254
|
+
"admission_hold_line_item_mismatch",
|
|
255
|
+
"admission_materialization_failed",
|
|
256
|
+
"variant_inactive",
|
|
257
|
+
"variant_product_mismatch",
|
|
258
|
+
"product_not_public",
|
|
215
259
|
"market_not_found",
|
|
216
260
|
"market_shipping_currency_unsupported",
|
|
217
261
|
"missing_market_rate",
|
|
@@ -236,7 +280,11 @@ var COMMERCE_ERROR_CODES = [
|
|
|
236
280
|
"discount_min_order_amount",
|
|
237
281
|
"discount_currency_scope_required",
|
|
238
282
|
"discount_allocation_method_unsupported",
|
|
239
|
-
"currency_mismatch"
|
|
283
|
+
"currency_mismatch",
|
|
284
|
+
"customer_token_required",
|
|
285
|
+
"market_required",
|
|
286
|
+
"server_derived",
|
|
287
|
+
"internal_error"
|
|
240
288
|
];
|
|
241
289
|
var COMMERCE_ERROR_CODE_SET = new Set(
|
|
242
290
|
COMMERCE_ERROR_CODES
|
|
@@ -262,6 +310,12 @@ function commerceProtocolError(issue, trustedRequestId) {
|
|
|
262
310
|
);
|
|
263
311
|
}
|
|
264
312
|
function parseCommerceErrorEnvelope(body, headerRequestId) {
|
|
313
|
+
if (headerRequestId === void 0) {
|
|
314
|
+
throw commerceProtocolError("missing_request_id_header");
|
|
315
|
+
}
|
|
316
|
+
if (headerRequestId.length === 0) {
|
|
317
|
+
throw commerceProtocolError("empty_request_id_header");
|
|
318
|
+
}
|
|
265
319
|
if (!isPlainRecord(body)) {
|
|
266
320
|
throw commerceProtocolError("expected_object", headerRequestId);
|
|
267
321
|
}
|
|
@@ -271,7 +325,7 @@ function parseCommerceErrorEnvelope(body, headerRequestId) {
|
|
|
271
325
|
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)) {
|
|
272
326
|
throw commerceProtocolError("invalid_field", headerRequestId);
|
|
273
327
|
}
|
|
274
|
-
if (headerRequestId && headerRequestId !== body.requestId) {
|
|
328
|
+
if (headerRequestId !== void 0 && headerRequestId !== body.requestId) {
|
|
275
329
|
throw commerceProtocolError("request_id_mismatch", headerRequestId);
|
|
276
330
|
}
|
|
277
331
|
return {
|
|
@@ -1300,7 +1354,10 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1300
1354
|
return parsed;
|
|
1301
1355
|
}
|
|
1302
1356
|
const data = parsed;
|
|
1303
|
-
|
|
1357
|
+
const hasCommerceEnvelopeSignal = options.errorFamily === "commerce" && ["error", "reason", "requestId", "retryable", "details"].some(
|
|
1358
|
+
(key) => Object.prototype.hasOwnProperty.call(data, key)
|
|
1359
|
+
);
|
|
1360
|
+
if (data.error || hasCommerceEnvelopeSignal) {
|
|
1304
1361
|
const errorMessage = typeof data.error === "string" ? data.error : "Unknown API error";
|
|
1305
1362
|
const reason = typeof data.reason === "string" ? data.reason : void 0;
|
|
1306
1363
|
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
@@ -1336,12 +1393,14 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1336
1393
|
|
|
1337
1394
|
// ../../internal/http-contracts/src/index.ts
|
|
1338
1395
|
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
1339
|
-
var operation = (collection, method, path) => Object.freeze({
|
|
1396
|
+
var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
1340
1397
|
[operationBrand]: true,
|
|
1341
1398
|
collection,
|
|
1342
1399
|
method,
|
|
1343
|
-
path
|
|
1400
|
+
path,
|
|
1401
|
+
...errorFamily && { errorFamily }
|
|
1344
1402
|
});
|
|
1403
|
+
var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
|
|
1345
1404
|
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
1346
1405
|
products: {
|
|
1347
1406
|
detail: operation("products", "get", "/detail"),
|
|
@@ -1374,13 +1433,13 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1374
1433
|
byPayment: operation("orders", "get", "/by-payment"),
|
|
1375
1434
|
cancel: operation("orders", "post", "/cancel"),
|
|
1376
1435
|
resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
|
|
1377
|
-
checkout:
|
|
1436
|
+
checkout: strictCommerceOperation("orders", "post", "/checkout"),
|
|
1378
1437
|
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
1379
1438
|
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
1380
1439
|
},
|
|
1381
1440
|
checkouts: {
|
|
1382
|
-
detail:
|
|
1383
|
-
query:
|
|
1441
|
+
detail: strictCommerceOperation("checkouts", "post", "/detail"),
|
|
1442
|
+
query: strictCommerceOperation("checkouts", "post", "/query")
|
|
1384
1443
|
},
|
|
1385
1444
|
transactions: {
|
|
1386
1445
|
update: operation("transactions", "post", "/update")
|
|
@@ -1401,29 +1460,58 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1401
1460
|
bulkImport: operation("fulfillments", "post", "/bulk-import")
|
|
1402
1461
|
},
|
|
1403
1462
|
carts: {
|
|
1404
|
-
create:
|
|
1405
|
-
retrieve:
|
|
1406
|
-
mine:
|
|
1407
|
-
merge:
|
|
1408
|
-
addItem:
|
|
1409
|
-
updateItem:
|
|
1410
|
-
removeItem:
|
|
1411
|
-
updateDiscountCodes:
|
|
1412
|
-
|
|
1413
|
-
|
|
1463
|
+
create: strictCommerceOperation("carts", "post", "/create"),
|
|
1464
|
+
retrieve: strictCommerceOperation("carts", "post", "/retrieve"),
|
|
1465
|
+
mine: strictCommerceOperation("carts", "post", "/mine"),
|
|
1466
|
+
merge: strictCommerceOperation("carts", "post", "/merge"),
|
|
1467
|
+
addItem: strictCommerceOperation("carts", "post", "/add-item"),
|
|
1468
|
+
updateItem: strictCommerceOperation("carts", "post", "/update-item"),
|
|
1469
|
+
removeItem: strictCommerceOperation("carts", "post", "/remove-item"),
|
|
1470
|
+
updateDiscountCodes: strictCommerceOperation(
|
|
1471
|
+
"carts",
|
|
1472
|
+
"post",
|
|
1473
|
+
"/update-discount-codes"
|
|
1474
|
+
),
|
|
1475
|
+
updateAttributes: strictCommerceOperation(
|
|
1476
|
+
"carts",
|
|
1477
|
+
"post",
|
|
1478
|
+
"/update-attributes"
|
|
1479
|
+
),
|
|
1480
|
+
clear: strictCommerceOperation("carts", "post", "/clear")
|
|
1414
1481
|
},
|
|
1415
1482
|
paymentSessions: {
|
|
1416
|
-
create:
|
|
1417
|
-
retrieve:
|
|
1418
|
-
cancel:
|
|
1483
|
+
create: strictCommerceOperation("payment-sessions", "post", "/create"),
|
|
1484
|
+
retrieve: strictCommerceOperation("payment-sessions", "post", "/retrieve"),
|
|
1485
|
+
cancel: strictCommerceOperation("payment-sessions", "post", "/cancel"),
|
|
1419
1486
|
server: {
|
|
1420
|
-
create:
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1487
|
+
create: strictCommerceOperation(
|
|
1488
|
+
"payment-sessions",
|
|
1489
|
+
"post",
|
|
1490
|
+
"/server/create"
|
|
1491
|
+
),
|
|
1492
|
+
retrieve: strictCommerceOperation(
|
|
1493
|
+
"payment-sessions",
|
|
1494
|
+
"post",
|
|
1495
|
+
"/server/retrieve"
|
|
1496
|
+
),
|
|
1497
|
+
cancel: strictCommerceOperation(
|
|
1498
|
+
"payment-sessions",
|
|
1499
|
+
"post",
|
|
1500
|
+
"/server/cancel"
|
|
1501
|
+
),
|
|
1502
|
+
confirm: strictCommerceOperation(
|
|
1503
|
+
"payment-sessions",
|
|
1504
|
+
"post",
|
|
1505
|
+
"/server/confirm"
|
|
1506
|
+
)
|
|
1424
1507
|
},
|
|
1425
1508
|
custom: {
|
|
1426
1509
|
create: operation("orders", "post", "/custom-payment-sessions"),
|
|
1510
|
+
retrieve: operation(
|
|
1511
|
+
"orders",
|
|
1512
|
+
"post",
|
|
1513
|
+
"/custom-payment-sessions/retrieve"
|
|
1514
|
+
),
|
|
1427
1515
|
confirm: operation("orders", "post", "/custom-payment-sessions/confirm")
|
|
1428
1516
|
}
|
|
1429
1517
|
},
|
|
@@ -1449,6 +1537,11 @@ var EVENTS_ENDPOINT_OPERATIONS = {
|
|
|
1449
1537
|
)
|
|
1450
1538
|
}
|
|
1451
1539
|
};
|
|
1540
|
+
var COMMUNITY_ENDPOINT_OPERATIONS = {
|
|
1541
|
+
posts: {
|
|
1542
|
+
detail: operation("posts", "get", "/detail")
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1452
1545
|
function resolveOperationTemplate(descriptor) {
|
|
1453
1546
|
return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
|
|
1454
1547
|
}
|
|
@@ -1480,6 +1573,9 @@ var sharedEndpoint = (descriptor) => descriptor;
|
|
|
1480
1573
|
function resolveOperationMethod2(descriptor) {
|
|
1481
1574
|
return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
|
|
1482
1575
|
}
|
|
1576
|
+
function resolveOperationErrorFamily(descriptor) {
|
|
1577
|
+
return "collection" in descriptor ? descriptor.errorFamily : void 0;
|
|
1578
|
+
}
|
|
1483
1579
|
function resolveOperationPath2(descriptor, options) {
|
|
1484
1580
|
if ("collection" in descriptor) {
|
|
1485
1581
|
return resolveOperationPath(descriptor, options);
|
|
@@ -1514,12 +1610,12 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1514
1610
|
updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
|
|
1515
1611
|
},
|
|
1516
1612
|
checkouts: {
|
|
1517
|
-
create:
|
|
1518
|
-
retrieve:
|
|
1613
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
1614
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),
|
|
1519
1615
|
server: {
|
|
1520
|
-
create:
|
|
1521
|
-
retrieve:
|
|
1522
|
-
query:
|
|
1616
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
1617
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),
|
|
1618
|
+
query: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.query)
|
|
1523
1619
|
}
|
|
1524
1620
|
},
|
|
1525
1621
|
returns: {
|
|
@@ -1537,10 +1633,10 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1537
1633
|
bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
|
|
1538
1634
|
},
|
|
1539
1635
|
carts: {
|
|
1540
|
-
create:
|
|
1636
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
1541
1637
|
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
1542
|
-
mine:
|
|
1543
|
-
merge:
|
|
1638
|
+
mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),
|
|
1639
|
+
merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),
|
|
1544
1640
|
server: {
|
|
1545
1641
|
// Server credentials are an authorization lane, not a second Cart
|
|
1546
1642
|
// transport. These must stay bound to the registered shared operations.
|
|
@@ -1560,29 +1656,46 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1560
1656
|
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
1561
1657
|
},
|
|
1562
1658
|
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
1563
|
-
updateItem:
|
|
1564
|
-
removeItem:
|
|
1565
|
-
updateDiscountCodes:
|
|
1566
|
-
|
|
1567
|
-
|
|
1659
|
+
updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),
|
|
1660
|
+
removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),
|
|
1661
|
+
updateDiscountCodes: sharedEndpoint(
|
|
1662
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes
|
|
1663
|
+
),
|
|
1664
|
+
updateAttributes: sharedEndpoint(
|
|
1665
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes
|
|
1666
|
+
),
|
|
1667
|
+
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
1568
1668
|
},
|
|
1569
1669
|
paymentSessions: {
|
|
1570
|
-
create:
|
|
1571
|
-
retrieve:
|
|
1572
|
-
|
|
1670
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create),
|
|
1671
|
+
retrieve: sharedEndpoint(
|
|
1672
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve
|
|
1673
|
+
),
|
|
1674
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.cancel),
|
|
1573
1675
|
custom: {
|
|
1574
1676
|
create: sharedEndpoint(
|
|
1575
1677
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create
|
|
1576
1678
|
),
|
|
1679
|
+
retrieve: sharedEndpoint(
|
|
1680
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.retrieve
|
|
1681
|
+
),
|
|
1577
1682
|
confirm: sharedEndpoint(
|
|
1578
1683
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm
|
|
1579
1684
|
)
|
|
1580
1685
|
},
|
|
1581
1686
|
server: {
|
|
1582
|
-
create:
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1687
|
+
create: sharedEndpoint(
|
|
1688
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create
|
|
1689
|
+
),
|
|
1690
|
+
retrieve: sharedEndpoint(
|
|
1691
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
1692
|
+
),
|
|
1693
|
+
cancel: sharedEndpoint(
|
|
1694
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.cancel
|
|
1695
|
+
),
|
|
1696
|
+
confirm: sharedEndpoint(
|
|
1697
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1698
|
+
)
|
|
1586
1699
|
}
|
|
1587
1700
|
},
|
|
1588
1701
|
shippingPolicies: {
|
|
@@ -1673,7 +1786,8 @@ var CustomerScopedApi = class {
|
|
|
1673
1786
|
return this.transport.request(resolveOperationPath2(endpoint2, options), {
|
|
1674
1787
|
method: resolveOperationMethod2(endpoint2),
|
|
1675
1788
|
body,
|
|
1676
|
-
headers: options?.headers
|
|
1789
|
+
headers: options?.headers,
|
|
1790
|
+
errorFamily: resolveOperationErrorFamily(endpoint2)
|
|
1677
1791
|
});
|
|
1678
1792
|
}
|
|
1679
1793
|
};
|
|
@@ -1695,15 +1809,39 @@ function unwrapPayloadDoc(value) {
|
|
|
1695
1809
|
}
|
|
1696
1810
|
return value;
|
|
1697
1811
|
}
|
|
1812
|
+
function hasCanonicalNotFoundReason(error) {
|
|
1813
|
+
const details = error.details;
|
|
1814
|
+
if (typeof details !== "object" || details === null) return false;
|
|
1815
|
+
if ("reason" in details && details.reason === "not_found") return true;
|
|
1816
|
+
if (!("body" in details) || typeof details.body !== "object" || details.body === null) {
|
|
1817
|
+
return false;
|
|
1818
|
+
}
|
|
1819
|
+
return "reason" in details.body && details.body.reason === "not_found";
|
|
1820
|
+
}
|
|
1698
1821
|
var CommunityClient = class extends RawCustomerScopedApi {
|
|
1699
1822
|
constructor(options) {
|
|
1700
1823
|
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1824
|
+
this.requiresSafePublicRawReads = !options.secretKey;
|
|
1701
1825
|
}
|
|
1702
1826
|
buildQuery(params) {
|
|
1703
1827
|
if (!params) return "";
|
|
1704
1828
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
1705
1829
|
return entries.length ? `?${new URLSearchParams(entries).toString()}` : "";
|
|
1706
1830
|
}
|
|
1831
|
+
withSafePublicRawReadQuery(query) {
|
|
1832
|
+
if (!this.requiresSafePublicRawReads) return query;
|
|
1833
|
+
if (!query) return "?depth=0&joins=false";
|
|
1834
|
+
return `?depth=0&joins=false&${query.slice(1)}`;
|
|
1835
|
+
}
|
|
1836
|
+
buildSafePublicRawListQuery(params) {
|
|
1837
|
+
if (!this.requiresSafePublicRawReads) {
|
|
1838
|
+
return this.buildQuery(params);
|
|
1839
|
+
}
|
|
1840
|
+
const queryParams = {};
|
|
1841
|
+
if (params?.page !== void 0) queryParams.page = params.page;
|
|
1842
|
+
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1843
|
+
return this.withSafePublicRawReadQuery(this.buildQuery(queryParams));
|
|
1844
|
+
}
|
|
1707
1845
|
buildPostsListQuery(params) {
|
|
1708
1846
|
const urlParams = new URLSearchParams();
|
|
1709
1847
|
const sort = params?.sort ?? DEFAULT_POST_LIST_SORT;
|
|
@@ -1763,15 +1901,35 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1763
1901
|
"GET"
|
|
1764
1902
|
);
|
|
1765
1903
|
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Public post detail projected by the same allowlist as the public feed.
|
|
1906
|
+
* Missing, hidden, and cross-tenant posts all resolve to `null`.
|
|
1907
|
+
*/
|
|
1908
|
+
async getPost(params) {
|
|
1909
|
+
const query = new URLSearchParams({ postId: params.postId });
|
|
1910
|
+
try {
|
|
1911
|
+
return await this.execute(
|
|
1912
|
+
resolveOperationPath(COMMUNITY_ENDPOINT_OPERATIONS.posts.detail, {
|
|
1913
|
+
query
|
|
1914
|
+
}),
|
|
1915
|
+
resolveOperationMethod(COMMUNITY_ENDPOINT_OPERATIONS.posts.detail)
|
|
1916
|
+
);
|
|
1917
|
+
} catch (error) {
|
|
1918
|
+
if (error instanceof NotFoundError && hasCanonicalNotFoundReason(error)) {
|
|
1919
|
+
return null;
|
|
1920
|
+
}
|
|
1921
|
+
throw error;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1766
1924
|
listPostCategories(params) {
|
|
1767
1925
|
return this.execute(
|
|
1768
|
-
`/api/post-categories${this.
|
|
1926
|
+
`/api/post-categories${this.buildSafePublicRawListQuery(params)}`,
|
|
1769
1927
|
"GET"
|
|
1770
1928
|
);
|
|
1771
1929
|
}
|
|
1772
1930
|
listPostTags(params) {
|
|
1773
1931
|
return this.execute(
|
|
1774
|
-
`/api/post-tags${this.
|
|
1932
|
+
`/api/post-tags${this.buildSafePublicRawListQuery(params)}`,
|
|
1775
1933
|
"GET"
|
|
1776
1934
|
);
|
|
1777
1935
|
}
|
|
@@ -1937,7 +2095,7 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1937
2095
|
}
|
|
1938
2096
|
getReactionTypes() {
|
|
1939
2097
|
return this.execute(
|
|
1940
|
-
|
|
2098
|
+
`/api/reaction-types${this.buildSafePublicRawListQuery({ limit: 100 })}`,
|
|
1941
2099
|
"GET"
|
|
1942
2100
|
);
|
|
1943
2101
|
}
|
|
@@ -1965,11 +2123,17 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
1965
2123
|
}
|
|
1966
2124
|
// Profiles
|
|
1967
2125
|
listProfileLists(params) {
|
|
1968
|
-
return this.execute(
|
|
2126
|
+
return this.execute(
|
|
2127
|
+
`/api/customer-profile-lists${this.buildSafePublicRawListQuery(params)}`,
|
|
2128
|
+
"GET"
|
|
2129
|
+
);
|
|
1969
2130
|
}
|
|
1970
2131
|
async getProfileList(params) {
|
|
1971
2132
|
const query = "slug" in params ? `?where[slug][equals]=${encodeURIComponent(params.slug)}&limit=1` : `?where[id][equals]=${encodeURIComponent(params.id)}&limit=1`;
|
|
1972
|
-
const res = await this.execute(
|
|
2133
|
+
const res = await this.execute(
|
|
2134
|
+
`/api/customer-profile-lists${this.withSafePublicRawReadQuery(query)}`,
|
|
2135
|
+
"GET"
|
|
2136
|
+
);
|
|
1973
2137
|
return res.docs[0] ?? null;
|
|
1974
2138
|
}
|
|
1975
2139
|
updatePublicProfile(body) {
|
|
@@ -2082,7 +2246,7 @@ var ORDER_PRIMARY_DISPLAY_STATUSES = [
|
|
|
2082
2246
|
];
|
|
2083
2247
|
var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
|
|
2084
2248
|
var ABANDONED_REASONS = ["expired", "customer", "operator"];
|
|
2085
|
-
var PAYMENT_PROVIDERS = ["toss"];
|
|
2249
|
+
var PAYMENT_PROVIDERS = ["toss", "portone"];
|
|
2086
2250
|
var PAYMENT_PROVIDER_STATUSES = [
|
|
2087
2251
|
"requires_payment_method",
|
|
2088
2252
|
"requires_action",
|
|
@@ -3255,8 +3419,33 @@ function validateRequiredReconciliation(value, allowed, resource, path) {
|
|
|
3255
3419
|
previous = current;
|
|
3256
3420
|
});
|
|
3257
3421
|
}
|
|
3258
|
-
function validateNextAction(value, resource, path) {
|
|
3422
|
+
function validateNextAction(value, provider, resource, path) {
|
|
3259
3423
|
const action = record(value, resource, path);
|
|
3424
|
+
if (provider === "portone") {
|
|
3425
|
+
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
3426
|
+
if (action.type !== "portone_checkout") {
|
|
3427
|
+
fail(resource, `${path}.type`, "portone_checkout");
|
|
3428
|
+
}
|
|
3429
|
+
const checkoutUrl = boundedString(
|
|
3430
|
+
action.checkoutUrl,
|
|
3431
|
+
2048,
|
|
3432
|
+
resource,
|
|
3433
|
+
`${path}.checkoutUrl`
|
|
3434
|
+
);
|
|
3435
|
+
try {
|
|
3436
|
+
const parsed = new URL(checkoutUrl);
|
|
3437
|
+
if (parsed.protocol !== "https:" || parsed.username !== "" || parsed.password !== "") {
|
|
3438
|
+
throw new Error("unsafe checkout URL");
|
|
3439
|
+
}
|
|
3440
|
+
} catch {
|
|
3441
|
+
fail(
|
|
3442
|
+
resource,
|
|
3443
|
+
`${path}.checkoutUrl`,
|
|
3444
|
+
"absolute HTTPS URL without embedded credentials"
|
|
3445
|
+
);
|
|
3446
|
+
}
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3260
3449
|
exact(
|
|
3261
3450
|
action,
|
|
3262
3451
|
[
|
|
@@ -3307,10 +3496,18 @@ function validateNextAction(value, resource, path) {
|
|
|
3307
3496
|
if (action.customerEmail !== void 0)
|
|
3308
3497
|
validateCustomer({ email: action.customerEmail }, resource, path);
|
|
3309
3498
|
}
|
|
3310
|
-
function validatePublicPaymentSession(value) {
|
|
3499
|
+
function validatePublicPaymentSession(value, expectedProvider) {
|
|
3311
3500
|
const resource = "PaymentSession";
|
|
3312
3501
|
const session = record(value, resource, "$");
|
|
3313
|
-
|
|
3502
|
+
const provider = enumValue(
|
|
3503
|
+
session.provider,
|
|
3504
|
+
PAYMENT_PROVIDERS,
|
|
3505
|
+
resource,
|
|
3506
|
+
"$.provider"
|
|
3507
|
+
);
|
|
3508
|
+
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
3509
|
+
fail(resource, "$.provider", expectedProvider);
|
|
3510
|
+
}
|
|
3314
3511
|
const status = enumValue(
|
|
3315
3512
|
session.providerStatus,
|
|
3316
3513
|
PAYMENT_PROVIDER_STATUSES,
|
|
@@ -3347,7 +3544,12 @@ function validatePublicPaymentSession(value) {
|
|
|
3347
3544
|
}
|
|
3348
3545
|
if (!("nextAction" in session))
|
|
3349
3546
|
fail(resource, "$.nextAction", "required field");
|
|
3350
|
-
validateNextAction(
|
|
3547
|
+
validateNextAction(
|
|
3548
|
+
session.nextAction,
|
|
3549
|
+
provider,
|
|
3550
|
+
resource,
|
|
3551
|
+
"$.nextAction"
|
|
3552
|
+
);
|
|
3351
3553
|
} else if (session.sessionRole === "residual") {
|
|
3352
3554
|
if (session.presentationStatus !== "suppressed" || session.finalizationStatus !== "not_ready") {
|
|
3353
3555
|
fail(resource, "$", "suppressed residual not-ready state");
|
|
@@ -4090,8 +4292,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
4090
4292
|
}
|
|
4091
4293
|
});
|
|
4092
4294
|
}
|
|
4093
|
-
async paymentSession(result) {
|
|
4094
|
-
return validatePublicPaymentSession(await result);
|
|
4295
|
+
async paymentSession(result, expectedProvider) {
|
|
4296
|
+
return validatePublicPaymentSession(await result, expectedProvider);
|
|
4095
4297
|
}
|
|
4096
4298
|
create(params) {
|
|
4097
4299
|
const { idempotencyKey, ...body } = params;
|
|
@@ -4101,18 +4303,53 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
4101
4303
|
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
4102
4304
|
body,
|
|
4103
4305
|
idempotencyKey
|
|
4104
|
-
)
|
|
4306
|
+
),
|
|
4307
|
+
"toss"
|
|
4308
|
+
);
|
|
4309
|
+
}
|
|
4310
|
+
createPortOne(params) {
|
|
4311
|
+
const { idempotencyKey, ...body } = params;
|
|
4312
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
4313
|
+
return this.paymentSession(
|
|
4314
|
+
this.post(
|
|
4315
|
+
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
4316
|
+
body,
|
|
4317
|
+
idempotencyKey
|
|
4318
|
+
),
|
|
4319
|
+
"portone"
|
|
4105
4320
|
);
|
|
4106
4321
|
}
|
|
4107
4322
|
retrieve(params) {
|
|
4108
4323
|
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
4109
|
-
return this.paymentSession(
|
|
4324
|
+
return this.paymentSession(
|
|
4325
|
+
this.post(endpoint2, params),
|
|
4326
|
+
"toss"
|
|
4327
|
+
);
|
|
4328
|
+
}
|
|
4329
|
+
retrievePortOne(params) {
|
|
4330
|
+
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
4331
|
+
return this.paymentSession(
|
|
4332
|
+
this.post(endpoint2, params),
|
|
4333
|
+
"portone"
|
|
4334
|
+
);
|
|
4110
4335
|
}
|
|
4111
4336
|
cancel(params) {
|
|
4112
4337
|
const { idempotencyKey, ...body } = params;
|
|
4113
4338
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
4114
4339
|
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
4115
|
-
return this.paymentSession(
|
|
4340
|
+
return this.paymentSession(
|
|
4341
|
+
this.post(endpoint2, body, idempotencyKey),
|
|
4342
|
+
"toss"
|
|
4343
|
+
);
|
|
4344
|
+
}
|
|
4345
|
+
cancelPortOne(params) {
|
|
4346
|
+
const { idempotencyKey, ...body } = params;
|
|
4347
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
4348
|
+
const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
4349
|
+
return this.paymentSession(
|
|
4350
|
+
this.post(endpoint2, body, idempotencyKey),
|
|
4351
|
+
"portone"
|
|
4352
|
+
);
|
|
4116
4353
|
}
|
|
4117
4354
|
confirm(params) {
|
|
4118
4355
|
const { idempotencyKey, ...body } = params;
|
|
@@ -4122,7 +4359,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
4122
4359
|
COMMERCE_ENDPOINTS.paymentSessions.server.confirm,
|
|
4123
4360
|
body,
|
|
4124
4361
|
idempotencyKey
|
|
4125
|
-
)
|
|
4362
|
+
),
|
|
4363
|
+
"toss"
|
|
4126
4364
|
);
|
|
4127
4365
|
}
|
|
4128
4366
|
};
|
|
@@ -6092,8 +6330,11 @@ var CommerceClient = class {
|
|
|
6092
6330
|
};
|
|
6093
6331
|
this.paymentSessions = {
|
|
6094
6332
|
create: paymentSessionApi.create.bind(paymentSessionApi),
|
|
6333
|
+
createPortOne: paymentSessionApi.createPortOne.bind(paymentSessionApi),
|
|
6095
6334
|
retrieve: (params) => paymentSessionApi.retrieve(params),
|
|
6096
|
-
|
|
6335
|
+
retrievePortOne: (params) => paymentSessionApi.retrievePortOne(params),
|
|
6336
|
+
cancel: (params) => paymentSessionApi.cancel(params),
|
|
6337
|
+
cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params)
|
|
6097
6338
|
};
|
|
6098
6339
|
this.discounts = {
|
|
6099
6340
|
validate: (params) => api.requestEndpoint(
|
|
@@ -6754,7 +6995,6 @@ var INTERNAL_COLLECTIONS = [
|
|
|
6754
6995
|
"payment-provider-customer-aliases"
|
|
6755
6996
|
];
|
|
6756
6997
|
var COLLECTIONS = [
|
|
6757
|
-
"tenants",
|
|
6758
6998
|
"tenant-metadata",
|
|
6759
6999
|
"products",
|
|
6760
7000
|
"product-variants",
|
|
@@ -6814,6 +7054,10 @@ var COLLECTIONS = [
|
|
|
6814
7054
|
"customer-memberships"
|
|
6815
7055
|
];
|
|
6816
7056
|
var SERVER_ONLY_COLLECTIONS = [
|
|
7057
|
+
// The tenant record itself denies reads without an authenticated user, so a
|
|
7058
|
+
// publishable key never reaches it; `tenant-metadata` is the browser-public
|
|
7059
|
+
// tenant identity surface.
|
|
7060
|
+
"tenants",
|
|
6817
7061
|
"tenant-logos",
|
|
6818
7062
|
"brand-logos",
|
|
6819
7063
|
"images",
|