@viu/emporix-sdk 4.0.1 → 4.2.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 +65 -0
- package/README.md +1 -0
- package/dist/cart.cjs +85 -0
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.d.cts +352 -1
- package/dist/cart.d.ts +352 -1
- package/dist/cart.js +1 -1
- package/dist/{chunk-QQMLN76U.js → chunk-2OTFVTG6.js} +7 -4
- package/dist/chunk-2OTFVTG6.js.map +1 -0
- package/dist/{chunk-CSYXGTOH.js → chunk-5MPL4XBD.js} +68 -4
- package/dist/chunk-5MPL4XBD.js.map +1 -0
- package/dist/{chunk-P3RANRGB.js → chunk-IYNT5BQW.js} +16 -2
- package/dist/chunk-IYNT5BQW.js.map +1 -0
- package/dist/{chunk-ZOFGDNSX.js → chunk-K4KXT6NX.js} +12 -6
- package/dist/chunk-K4KXT6NX.js.map +1 -0
- package/dist/{chunk-XJJDCK2Z.js → chunk-N2CE3J4M.js} +12 -7
- package/dist/chunk-N2CE3J4M.js.map +1 -0
- package/dist/{chunk-YVZ6GOLE.js → chunk-S2ERKGYL.js} +48 -3
- package/dist/chunk-S2ERKGYL.js.map +1 -0
- package/dist/{chunk-5XZ6MSXW.js → chunk-VXORPTMP.js} +19 -2
- package/dist/chunk-VXORPTMP.js.map +1 -0
- package/dist/chunk-ZWJUDXTK.js +15 -0
- package/dist/chunk-ZWJUDXTK.js.map +1 -0
- package/dist/companies.cjs +15 -2
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +5 -3
- package/dist/companies.d.ts +5 -3
- package/dist/companies.js +2 -1
- package/dist/customer-groups.cjs +17 -0
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.js +1 -1
- package/dist/index.cjs +259 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +150 -28
- package/dist/index.d.ts +150 -28
- package/dist/index.js +99 -59
- package/dist/index.js.map +1 -1
- package/dist/media.cjs +66 -2
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +184 -5
- package/dist/media.d.ts +184 -5
- package/dist/media.js +1 -1
- package/dist/orders.cjs +14 -0
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +6 -0
- package/dist/orders.d.ts +6 -0
- package/dist/orders.js +1 -1
- package/dist/price.cjs +20 -4
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +12 -4
- package/dist/price.d.ts +12 -4
- package/dist/price.js +2 -1
- package/dist/search-DU6tE356.d.cts +15 -0
- package/dist/search-DU6tE356.d.ts +15 -0
- package/dist/segment.cjs +21 -5
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.d.cts +16 -6
- package/dist/segment.d.ts +16 -6
- package/dist/segment.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-5XZ6MSXW.js.map +0 -1
- package/dist/chunk-CSYXGTOH.js.map +0 -1
- package/dist/chunk-P3RANRGB.js.map +0 -1
- package/dist/chunk-QQMLN76U.js.map +0 -1
- package/dist/chunk-XJJDCK2Z.js.map +0 -1
- package/dist/chunk-YVZ6GOLE.js.map +0 -1
- package/dist/chunk-ZOFGDNSX.js.map +0 -1
package/dist/cart.d.cts
CHANGED
|
@@ -739,6 +739,54 @@ type CreatedCart = {
|
|
|
739
739
|
cartId: string;
|
|
740
740
|
yrn: Yrn;
|
|
741
741
|
};
|
|
742
|
+
type Discount = {
|
|
743
|
+
/**
|
|
744
|
+
* Discount unique identifier.
|
|
745
|
+
*/
|
|
746
|
+
id?: string;
|
|
747
|
+
couponYrn?: Yrn;
|
|
748
|
+
/**
|
|
749
|
+
* Discount code generated when a discount coupon is created through the Coupon Service.
|
|
750
|
+
*/
|
|
751
|
+
code: string;
|
|
752
|
+
/**
|
|
753
|
+
* Three-letter currency code, compliant with the ISO 4217 standard.
|
|
754
|
+
*/
|
|
755
|
+
currency?: string;
|
|
756
|
+
/**
|
|
757
|
+
* Discount expressed as fixed amount.
|
|
758
|
+
*/
|
|
759
|
+
amount?: number;
|
|
760
|
+
/**
|
|
761
|
+
* Discount displayed name.
|
|
762
|
+
*/
|
|
763
|
+
name?: string;
|
|
764
|
+
/**
|
|
765
|
+
* Discount expressed as a percentage of the price.
|
|
766
|
+
*/
|
|
767
|
+
discountRate?: number;
|
|
768
|
+
/**
|
|
769
|
+
* Determines whether the coupon is applied to the total or subtotal value of the order.
|
|
770
|
+
*/
|
|
771
|
+
discountCalculationType?: 'SUBTOTAL' | 'TOTAL';
|
|
772
|
+
/**
|
|
773
|
+
* Links to Coupon Service endpoints used to validate and redeem the discount.
|
|
774
|
+
*/
|
|
775
|
+
links?: Array<Link>;
|
|
776
|
+
/**
|
|
777
|
+
* Calculation type specifies how the discount should be calculated. It can be set to one of the following:
|
|
778
|
+
* * `ApplyDiscountBeforeTax`
|
|
779
|
+
* * `ApplyDiscountAfterTax`
|
|
780
|
+
*
|
|
781
|
+
* The field is **deprecated** and is not used in calculatedPrice fields. The calculated price takes into account site's settings
|
|
782
|
+
* where:
|
|
783
|
+
* * `includesTax=true` results in `ApplyDiscountAfterTax`
|
|
784
|
+
* * `includesTax=false` results in `ApplyDiscountBeforeTax`
|
|
785
|
+
*
|
|
786
|
+
* @deprecated
|
|
787
|
+
*/
|
|
788
|
+
calculationType?: 'ApplyDiscountBeforeTax' | 'ApplyDiscountAfterTax';
|
|
789
|
+
};
|
|
742
790
|
/**
|
|
743
791
|
* Discount details.
|
|
744
792
|
*/
|
|
@@ -1287,6 +1335,186 @@ type CartItemsBatchUpdateRequest = Array<CartItemRequest & {
|
|
|
1287
1335
|
[key: string]: unknown;
|
|
1288
1336
|
}>;
|
|
1289
1337
|
type BatchResponse = Array<SingleBatchResponse>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Body of `POST /cart/{tenant}/carts/{cartId}/execute`. Between 1 and 10 commands.
|
|
1340
|
+
*/
|
|
1341
|
+
type ExecuteRequest = {
|
|
1342
|
+
/**
|
|
1343
|
+
* Commands to run sequentially. Maximum 10. Request duration is approximately the sum of the chained commands.
|
|
1344
|
+
*
|
|
1345
|
+
* Each item needs `type`. `data` is the REST request body and is omitted for commands that have no body. The cart id is the path parameter. `options` holds remaining path and query equivalents (`itemId`, `partial`, `expandCalculation`, `zipCode`, `countryCode`, `resourceVersion`, `codes`, `discountIndex`).
|
|
1346
|
+
*
|
|
1347
|
+
*/
|
|
1348
|
+
commands: Array<ExecuteCommand>;
|
|
1349
|
+
};
|
|
1350
|
+
/**
|
|
1351
|
+
* One operation in the execute chain. `type` selects the REST equivalent. `data` is that endpoint’s request body. The cart id is the execute path parameter. `options` fields are remaining path and query equivalents (`itemId`, `partial`, `expandCalculation`, `zipCode`, `countryCode`, `resourceVersion`, `codes`, `discountIndex`).
|
|
1352
|
+
*
|
|
1353
|
+
* Session and legal-entity identity are request headers, not command fields.
|
|
1354
|
+
*
|
|
1355
|
+
*/
|
|
1356
|
+
type ExecuteCommand = {
|
|
1357
|
+
/**
|
|
1358
|
+
* Operation to run.
|
|
1359
|
+
*
|
|
1360
|
+
* Possible values:
|
|
1361
|
+
* * `AddCartItem`
|
|
1362
|
+
* * `UpdateCartItem`
|
|
1363
|
+
* * `DeleteCartItem`
|
|
1364
|
+
* * `DeleteCartItems`
|
|
1365
|
+
* * `GetCart`
|
|
1366
|
+
* * `AddCartItemsBatch`
|
|
1367
|
+
* * `UpdateCartItemsBatch`
|
|
1368
|
+
* * `UpdateCart`
|
|
1369
|
+
* * `ApplyCartDiscount`
|
|
1370
|
+
* * `GetCartDiscounts`
|
|
1371
|
+
* * `DeleteCartDiscounts`
|
|
1372
|
+
* * `DeleteCartDiscount`
|
|
1373
|
+
* * `RefreshCart`
|
|
1374
|
+
* * `ValidateCart`
|
|
1375
|
+
*
|
|
1376
|
+
*/
|
|
1377
|
+
type: 'AddCartItem' | 'UpdateCartItem' | 'DeleteCartItem' | 'DeleteCartItems' | 'GetCart' | 'AddCartItemsBatch' | 'UpdateCartItemsBatch' | 'UpdateCart' | 'ApplyCartDiscount' | 'GetCartDiscounts' | 'DeleteCartDiscounts' | 'DeleteCartDiscount' | 'RefreshCart' | 'ValidateCart';
|
|
1378
|
+
/**
|
|
1379
|
+
* Request body of the equivalent REST operation.
|
|
1380
|
+
*
|
|
1381
|
+
* * `AddCartItem` – cart item body
|
|
1382
|
+
* * `UpdateCartItem` – cart item update body
|
|
1383
|
+
* * `AddCartItemsBatch` – list of cart item bodies
|
|
1384
|
+
* * `UpdateCartItemsBatch` – list of cart item updates (maximum 50)
|
|
1385
|
+
* * `UpdateCart` – cart update body
|
|
1386
|
+
* * `ApplyCartDiscount` – discount body
|
|
1387
|
+
*
|
|
1388
|
+
* Omit `data` for `GetCart`, `RefreshCart`, `ValidateCart`, deletes, `GetCartDiscounts`, `DeleteCartDiscounts`, and `DeleteCartDiscount`.
|
|
1389
|
+
*
|
|
1390
|
+
* The service selects the body type from `type`. A single item body is an object. Batch commands send an array.
|
|
1391
|
+
*
|
|
1392
|
+
*/
|
|
1393
|
+
data?: {
|
|
1394
|
+
[key: string]: unknown;
|
|
1395
|
+
} | Array<{
|
|
1396
|
+
[key: string]: unknown;
|
|
1397
|
+
}>;
|
|
1398
|
+
options?: ExecuteCommandOptions;
|
|
1399
|
+
};
|
|
1400
|
+
/**
|
|
1401
|
+
* Remaining path and query equivalents for the command. Required fields depend on `type`. The cart id is the execute path parameter, not an option.
|
|
1402
|
+
*/
|
|
1403
|
+
type ExecuteCommandOptions = {
|
|
1404
|
+
/**
|
|
1405
|
+
* Cart item unique identifier generated when the product is added to the cart.
|
|
1406
|
+
*
|
|
1407
|
+
* Required for `UpdateCartItem` and `DeleteCartItem`.
|
|
1408
|
+
*
|
|
1409
|
+
*/
|
|
1410
|
+
itemId?: string;
|
|
1411
|
+
/**
|
|
1412
|
+
* When `true`, only the provided item or batch fields are updated. Same default as the REST `partial` query parameter (`false`).
|
|
1413
|
+
*
|
|
1414
|
+
* Used by `UpdateCartItem` and `UpdateCartItemsBatch`.
|
|
1415
|
+
*
|
|
1416
|
+
*/
|
|
1417
|
+
partial?: boolean;
|
|
1418
|
+
/**
|
|
1419
|
+
* When `true`, `GetCart` returns a fully calculated cart. Same default as the REST `expandCalculation` query parameter (`true`).
|
|
1420
|
+
*
|
|
1421
|
+
* Used by `GetCart`.
|
|
1422
|
+
*
|
|
1423
|
+
*/
|
|
1424
|
+
expandCalculation?: boolean;
|
|
1425
|
+
/**
|
|
1426
|
+
* Zip code of the shipping address, used for tax calculations, shipping cost estimations, and pricing. Provide together with `countryCode` if either is specified.
|
|
1427
|
+
*
|
|
1428
|
+
* Used by `GetCart`.
|
|
1429
|
+
*
|
|
1430
|
+
*/
|
|
1431
|
+
zipCode?: string;
|
|
1432
|
+
/**
|
|
1433
|
+
* Two-letter country code of the shipping address. Provide together with `zipCode` if either is specified.
|
|
1434
|
+
*
|
|
1435
|
+
* Used by `GetCart`.
|
|
1436
|
+
*
|
|
1437
|
+
*/
|
|
1438
|
+
countryCode?: string;
|
|
1439
|
+
/**
|
|
1440
|
+
* Cart resource version used as If-Match for participating writes (`AddCartItem`, `UpdateCartItem`, `UpdateCart`, `ApplyCartDiscount`).
|
|
1441
|
+
*
|
|
1442
|
+
* * `versioning=skip` – ignored
|
|
1443
|
+
* * `versioning=explicit` – required on every participating command (whole-request preflight)
|
|
1444
|
+
* * `versioning=follow` – required to seed the first participating write; omit on later writes
|
|
1445
|
+
*
|
|
1446
|
+
* Extra `resourceVersion` on `GetCart`, `ValidateCart`, `RefreshCart`, deletes, and itemsBatch is ignored.
|
|
1447
|
+
*
|
|
1448
|
+
*/
|
|
1449
|
+
resourceVersion?: number;
|
|
1450
|
+
/**
|
|
1451
|
+
* Discount codes to remove. If omitted, `DeleteCartDiscounts` removes all discounts. Same meaning as the REST `codes` query parameter.
|
|
1452
|
+
*
|
|
1453
|
+
* Used by `DeleteCartDiscounts`.
|
|
1454
|
+
*
|
|
1455
|
+
*/
|
|
1456
|
+
codes?: Array<string>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Index of the discount in the cart discounts array.
|
|
1459
|
+
*
|
|
1460
|
+
* Required for `DeleteCartDiscount`.
|
|
1461
|
+
*
|
|
1462
|
+
*/
|
|
1463
|
+
discountIndex?: string;
|
|
1464
|
+
};
|
|
1465
|
+
/**
|
|
1466
|
+
* Body of a 207 execute response. Present only when the chain was accepted and executed.
|
|
1467
|
+
*/
|
|
1468
|
+
type ExecuteResponse = {
|
|
1469
|
+
/**
|
|
1470
|
+
* Ordered results for commands that ran. With `onError=fail`, the array stops after the first non-2xx command.
|
|
1471
|
+
*
|
|
1472
|
+
*/
|
|
1473
|
+
results: Array<ExecuteCommandResult>;
|
|
1474
|
+
};
|
|
1475
|
+
/**
|
|
1476
|
+
* Result of one command in the execute chain. `data` matches the REST response body for that command.
|
|
1477
|
+
*/
|
|
1478
|
+
type ExecuteCommandResult = {
|
|
1479
|
+
/**
|
|
1480
|
+
* Zero-based index of the command in the request `commands` array.
|
|
1481
|
+
*/
|
|
1482
|
+
index: number;
|
|
1483
|
+
/**
|
|
1484
|
+
* Command type that produced this result.
|
|
1485
|
+
*/
|
|
1486
|
+
type: string;
|
|
1487
|
+
/**
|
|
1488
|
+
* HTTP status code of the equivalent REST operation.
|
|
1489
|
+
*/
|
|
1490
|
+
code: number;
|
|
1491
|
+
/**
|
|
1492
|
+
* HTTP reason phrase that matches `code`.
|
|
1493
|
+
*/
|
|
1494
|
+
status: string;
|
|
1495
|
+
/**
|
|
1496
|
+
* Response body of the equivalent REST operation. Omitted when that endpoint returns 204.
|
|
1497
|
+
*
|
|
1498
|
+
* A single-object body (`AddCartItem`, `GetCart`, `ApplyCartDiscount`, `ValidateCart`, or an error) is an object. `GetCartDiscounts`, `AddCartItemsBatch`, and `UpdateCartItemsBatch` return an array. Failures use the same error shape as REST (`code`, `status`, `message`).
|
|
1499
|
+
*
|
|
1500
|
+
*/
|
|
1501
|
+
data?: {
|
|
1502
|
+
[key: string]: unknown;
|
|
1503
|
+
} | Array<{
|
|
1504
|
+
[key: string]: unknown;
|
|
1505
|
+
}> | null;
|
|
1506
|
+
/**
|
|
1507
|
+
* Response headers for this command.
|
|
1508
|
+
*
|
|
1509
|
+
* When a participating write applied If-Match, this object contains `hybris-resource-version` set to the version after the write. `versioning=skip` does not send If-Match, so the header is absent.
|
|
1510
|
+
*
|
|
1511
|
+
* `AddCartItemsBatch` does not use this object for item locations. Each created item's `data[].headers.location` uses the same location as REST `POST .../itemsBatch`.
|
|
1512
|
+
*
|
|
1513
|
+
*/
|
|
1514
|
+
headers?: {
|
|
1515
|
+
[key: string]: string;
|
|
1516
|
+
};
|
|
1517
|
+
};
|
|
1290
1518
|
/**
|
|
1291
1519
|
* YRN
|
|
1292
1520
|
*
|
|
@@ -1916,6 +2144,60 @@ type ValidationError = {
|
|
|
1916
2144
|
*/
|
|
1917
2145
|
field?: string;
|
|
1918
2146
|
};
|
|
2147
|
+
type PostCartExecuteData = {
|
|
2148
|
+
body: ExecuteRequest;
|
|
2149
|
+
headers?: {
|
|
2150
|
+
/**
|
|
2151
|
+
* Anonymous customer unique session identifier. Shared by every command in the chain. Commands cannot override this header.
|
|
2152
|
+
*
|
|
2153
|
+
*/
|
|
2154
|
+
'session-id'?: string;
|
|
2155
|
+
/**
|
|
2156
|
+
* Legal entity of the shopper context. Shared by every command in the chain. Commands cannot override this header. To act as a different legal entity, send another request.
|
|
2157
|
+
*
|
|
2158
|
+
*/
|
|
2159
|
+
'legal-entity-id'?: string;
|
|
2160
|
+
};
|
|
2161
|
+
path: {
|
|
2162
|
+
/**
|
|
2163
|
+
* Cart unique identifier generated when a cart is created.
|
|
2164
|
+
*/
|
|
2165
|
+
cartId: string;
|
|
2166
|
+
/**
|
|
2167
|
+
* Your Emporix tenant name.
|
|
2168
|
+
*
|
|
2169
|
+
* **Note**: The tenant should always be written in lowercase.
|
|
2170
|
+
*
|
|
2171
|
+
*/
|
|
2172
|
+
tenant: string;
|
|
2173
|
+
};
|
|
2174
|
+
query?: {
|
|
2175
|
+
/**
|
|
2176
|
+
* Controls whether the chain stops after the first non-2xx command.
|
|
2177
|
+
*
|
|
2178
|
+
* Possible values:
|
|
2179
|
+
* * `fail` – Stop after the first non-2xx command. `results` contains only the commands that ran, including the failed one.
|
|
2180
|
+
* * `resume` – Run every command. Later commands still see earlier successful mutations.
|
|
2181
|
+
*
|
|
2182
|
+
* An invalid value returns **400** for the whole request before any command runs.
|
|
2183
|
+
*
|
|
2184
|
+
*/
|
|
2185
|
+
onError?: 'fail' | 'resume';
|
|
2186
|
+
/**
|
|
2187
|
+
* If-Match strategy for participating writes (`AddCartItem`, `UpdateCartItem`, `UpdateCart`, `ApplyCartDiscount`).
|
|
2188
|
+
*
|
|
2189
|
+
* Possible values:
|
|
2190
|
+
* * `skip` – Never pass a version. Ignore `options.resourceVersion` if present.
|
|
2191
|
+
* * `explicit` – Every participating command must send `options.resourceVersion`. Missing version on any participating write returns **400** for the whole request (preflight). This is not `skip`.
|
|
2192
|
+
* * `follow` – Seed from the first participating write, then use that cursor for later writes. After the cursor exists, a successful `RefreshCart`, delete, or itemsBatch also bumps it.
|
|
2193
|
+
*
|
|
2194
|
+
* An invalid value returns **400** for the whole request before any command runs.
|
|
2195
|
+
*
|
|
2196
|
+
*/
|
|
2197
|
+
versioning?: 'skip' | 'explicit' | 'follow';
|
|
2198
|
+
};
|
|
2199
|
+
url: '/cart/{tenant}/carts/{cartId}/execute';
|
|
2200
|
+
};
|
|
1919
2201
|
|
|
1920
2202
|
/** A cart as returned by the Cart service (all generated fields). */
|
|
1921
2203
|
type Cart = Cart$1;
|
|
@@ -1949,6 +2231,50 @@ type CartUpdateInput = UpdateCart;
|
|
|
1949
2231
|
type CartDiscount = DiscountResponse;
|
|
1950
2232
|
/** Lead-time and non-delivery-time restrictions for a cart (`GET …/dtRestrictions`). */
|
|
1951
2233
|
type CartDeliveryRestrictions = CartDtRestrictions;
|
|
2234
|
+
/** Body for applying a discount (`POST /carts/{id}/discounts`, generated). */
|
|
2235
|
+
type CartDiscountInput = Discount;
|
|
2236
|
+
/**
|
|
2237
|
+
* Request body per command type of {@link CartService.execute}. The spec states
|
|
2238
|
+
* this only in prose — its `data` is an untyped object — so it is the one
|
|
2239
|
+
* hand-written piece. A command type missing here (one Emporix adds after this
|
|
2240
|
+
* was written) keeps the spec's untyped `data` and still works.
|
|
2241
|
+
*/
|
|
2242
|
+
interface CartCommandBodies {
|
|
2243
|
+
AddCartItem: CartItemInput;
|
|
2244
|
+
UpdateCartItem: CartItemUpdate;
|
|
2245
|
+
AddCartItemsBatch: CartItemInput[];
|
|
2246
|
+
UpdateCartItemsBatch: CartItemsBatchUpdateInput;
|
|
2247
|
+
UpdateCart: CartUpdateInput;
|
|
2248
|
+
ApplyCartDiscount: CartDiscountInput;
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* One command of a {@link CartService.execute} chain: `type` picks the REST
|
|
2252
|
+
* operation, `data` is that operation's request body, `options` holds its
|
|
2253
|
+
* remaining path and query parameters (`itemId`, `partial`, `expandCalculation`,
|
|
2254
|
+
* `zipCode`, `countryCode`, `resourceVersion`, `codes`, `discountIndex`). The
|
|
2255
|
+
* cart id is the `execute` path parameter, never a command field.
|
|
2256
|
+
*
|
|
2257
|
+
* `options` is the generated type, where every field is optional: `itemId`
|
|
2258
|
+
* (`UpdateCartItem`, `DeleteCartItem`) and `discountIndex` (`DeleteCartDiscount`)
|
|
2259
|
+
* are required by the server, which reports a missing one on that command.
|
|
2260
|
+
*/
|
|
2261
|
+
type CartCommand = {
|
|
2262
|
+
[T in ExecuteCommand["type"]]: Omit<ExecuteCommand, "type" | "data"> & {
|
|
2263
|
+
type: T;
|
|
2264
|
+
} & (T extends keyof CartCommandBodies ? {
|
|
2265
|
+
data: CartCommandBodies[T];
|
|
2266
|
+
} : Pick<ExecuteCommand, "data">);
|
|
2267
|
+
}[ExecuteCommand["type"]];
|
|
2268
|
+
/** `onError` and `versioning` of {@link CartService.execute} — both query parameters (generated). */
|
|
2269
|
+
type CartExecuteOptions = NonNullable<PostCartExecuteData["query"]>;
|
|
2270
|
+
/** The `207` body of {@link CartService.execute}: one result per command that ran, in order (generated). */
|
|
2271
|
+
type CartExecuteResult = ExecuteResponse;
|
|
2272
|
+
/**
|
|
2273
|
+
* One entry of {@link CartExecuteResult}`.results`: `code`/`status` of the
|
|
2274
|
+
* equivalent REST call, and as `data` its response body — or its error body
|
|
2275
|
+
* when `code` is not 2xx; absent for a 204 (generated).
|
|
2276
|
+
*/
|
|
2277
|
+
type CartCommandResult = ExecuteCommandResult;
|
|
1952
2278
|
/** Cart operations. Every method requires an explicit customer/anonymous context. */
|
|
1953
2279
|
declare class CartService {
|
|
1954
2280
|
private readonly ctx;
|
|
@@ -2116,6 +2442,31 @@ declare class CartService {
|
|
|
2116
2442
|
removeDiscountByIndex(cartId: string, discountIndex: string, auth: AuthContext): Promise<Cart>;
|
|
2117
2443
|
/** Retrieves the cart's lead-time and non-delivery-time restrictions (`GET /carts/{cartId}/dtRestrictions`). */
|
|
2118
2444
|
getDeliveryRestrictions(cartId: string, auth: AuthContext): Promise<CartDeliveryRestrictions>;
|
|
2445
|
+
/**
|
|
2446
|
+
* Runs up to 10 cart commands on this cart in one request, in order
|
|
2447
|
+
* (`POST /carts/{cartId}/execute`). The typical chain is `AddCartItem` then
|
|
2448
|
+
* `GetCart`: the calculated cart comes back without a second round trip.
|
|
2449
|
+
*
|
|
2450
|
+
* - `onError: "fail"` (default) stops at the first command that does not
|
|
2451
|
+
* answer 2xx and **throws the error that command's REST call would have
|
|
2452
|
+
* thrown** — an `EmporixNotFoundError` for a 404, … — with the command's
|
|
2453
|
+
* error body. The commands before it **have already been applied**.
|
|
2454
|
+
* - `onError: "resume"` runs every command and resolves with all results;
|
|
2455
|
+
* check each `code`.
|
|
2456
|
+
* - A `400` for the whole request (no commands or more than 10, an unknown
|
|
2457
|
+
* type, `versioning: "explicit"` without a `resourceVersion`) means no
|
|
2458
|
+
* command ran.
|
|
2459
|
+
*
|
|
2460
|
+
* The request takes about as long as its commands together — size the
|
|
2461
|
+
* client's `timeouts.readMs` for long chains. It is never retried: a replay
|
|
2462
|
+
* would apply the writes twice.
|
|
2463
|
+
*
|
|
2464
|
+
* `auth` is forwarded unguarded: a customer or anonymous token works on the
|
|
2465
|
+
* shopper's own cart; a service token needs `cart.cart_manage`, plus
|
|
2466
|
+
* `cart.cart_manage_external_prices` when a command carries an external
|
|
2467
|
+
* price, product, fee or discount.
|
|
2468
|
+
*/
|
|
2469
|
+
execute(cartId: string, commands: CartCommand[], auth: AuthContext, opts?: CartExecuteOptions): Promise<CartExecuteResult>;
|
|
2119
2470
|
}
|
|
2120
2471
|
|
|
2121
|
-
export { type Cart, type CartAddress, type CartCreated, type CartDeliveryRestrictions, type CartDiscount, type CartItem, type CartItemBatchEntry, type CartItemInput, type CartItemUpdate, type CartItemsBatchResponse, type CartItemsBatchUpdateInput, type CartItemsBatchUpdateResult, type CartSearchInput, CartService, type CartSummary, type CartUpdateInput, type CartValidationResult, type CreateCartInput };
|
|
2472
|
+
export { type Cart, type CartAddress, type CartCommand, type CartCommandBodies, type CartCommandResult, type CartCreated, type CartDeliveryRestrictions, type CartDiscount, type CartDiscountInput, type CartExecuteOptions, type CartExecuteResult, type CartItem, type CartItemBatchEntry, type CartItemInput, type CartItemUpdate, type CartItemsBatchResponse, type CartItemsBatchUpdateInput, type CartItemsBatchUpdateResult, type CartSearchInput, CartService, type CartSummary, type CartUpdateInput, type CartValidationResult, type CreateCartInput };
|