react-shopwave-connect 0.4.1 → 0.4.2
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/README.md +3 -3
- package/dist/core/index.cjs +15 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +26 -5
- package/dist/core/index.d.ts +26 -5
- package/dist/core/index.js +15 -4
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +15 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +59 -2
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +18 -3
- package/dist/next/index.d.ts +18 -3
- package/dist/next/index.js +59 -2
- package/dist/next/index.js.map +1 -1
- package/dist/server/index.cjs +59 -2
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +18 -3
- package/dist/server/index.d.ts +18 -3
- package/dist/server/index.js +59 -2
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -509,7 +509,10 @@ async function submitEntity({ endpoint, method = "POST", payload }, options = {}
|
|
|
509
509
|
* (https://developer.merchantstack.com/api-reference.html) and checked against
|
|
510
510
|
* the live API where noted:
|
|
511
511
|
* - category/product/store: GET filtered by `<x>Ids`, POST upsert, DELETE with `<x>Id` → 205.
|
|
512
|
-
* - promotion: no DELETE;
|
|
512
|
+
* - promotion: no DELETE; promotions are never deleted, only expired. Expiring
|
|
513
|
+
* reads the promotion and saves the whole record back with `endDate` = now (and
|
|
514
|
+
* `startDate` = now too if it hadn't started); the live API rejects a partial
|
|
515
|
+
* `{ id, endDate }` save with error 899. Dates are UTC `YYYY-MM-DD HH:mm:ss`.
|
|
513
516
|
* - employee: POST updates `roleId`, `joinedDate`, `exitDate` (names can't be
|
|
514
517
|
* changed); no DELETE (live API: "Cannot DELETE /employee") → retired via `exitDate`.
|
|
515
518
|
* - consumer: read-only (`GET` with `ids`, comma-separated); live POST → 404.
|
|
@@ -550,7 +553,9 @@ const SHOPWAVE_ENTITIES = Object.freeze({
|
|
|
550
553
|
idHeader: "promotionId",
|
|
551
554
|
writable: true,
|
|
552
555
|
deleteMode: "retire",
|
|
553
|
-
retireField: "endDate"
|
|
556
|
+
retireField: "endDate",
|
|
557
|
+
retireWithRecord: true,
|
|
558
|
+
retireStartField: "startDate"
|
|
554
559
|
},
|
|
555
560
|
employee: {
|
|
556
561
|
route: "employees",
|
|
@@ -625,7 +630,8 @@ async function saveEntity(kind, item, options = {}) {
|
|
|
625
630
|
/**
|
|
626
631
|
* Deletes one entity (a soft delete: it stays readable with `deleted: true`).
|
|
627
632
|
* Employees and promotions can't be deleted in Shopwave; for them the route
|
|
628
|
-
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`)
|
|
633
|
+
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`), and a
|
|
634
|
+
* promotion is saved back whole (see {@link deletePromotion}).
|
|
629
635
|
*
|
|
630
636
|
* Shopwave answers 205 with an empty body — also for ids that don't exist — so
|
|
631
637
|
* a resolved promise means "the API accepted the request", not "a record was
|
|
@@ -666,7 +672,12 @@ const saveStore = (store, options) => saveEntity("store", store, options);
|
|
|
666
672
|
const deleteStore = (id, options) => deleteEntityById("store", id, options);
|
|
667
673
|
const fetchStore = (id, params, options) => fetchEntityById("store", id, params, options);
|
|
668
674
|
const savePromotion = (promotion, options) => saveEntity("promotion", promotion, options);
|
|
669
|
-
/**
|
|
675
|
+
/**
|
|
676
|
+
* Expires a promotion (Shopwave never deletes promotions). The route reads the
|
|
677
|
+
* promotion and saves it back with `endDate` set to now; a promotion that hasn't
|
|
678
|
+
* started yet gets `startDate` = `endDate` = now. Rejects if the promotion doesn't
|
|
679
|
+
* exist or the save fails.
|
|
680
|
+
*/
|
|
670
681
|
const deletePromotion = (id, options) => deleteEntityById("promotion", id, options);
|
|
671
682
|
const fetchPromotion = (id, params, options) => fetchEntityById("promotion", id, params, options);
|
|
672
683
|
/**
|