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/core/index.d.cts
CHANGED
|
@@ -556,13 +556,25 @@ interface EntityDefinition {
|
|
|
556
556
|
/**
|
|
557
557
|
* How a delete is done upstream:
|
|
558
558
|
* - `"delete"`: `DELETE {apiUrl}/<upstream>` with the `idHeader` (205, empty body)
|
|
559
|
-
* - `"retire"`: the API has no DELETE; the record is retired by
|
|
560
|
-
* `
|
|
559
|
+
* - `"retire"`: the API has no DELETE; the record is retired by setting
|
|
560
|
+
* `retireField` to now (employees: `exitDate`, promotions: `endDate`)
|
|
561
561
|
* - `"none"`: can't be deleted
|
|
562
562
|
*/
|
|
563
563
|
deleteMode: "delete" | "retire" | "none";
|
|
564
564
|
/** Date field set to "now" when `deleteMode` is `"retire"`. */
|
|
565
565
|
retireField?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Retire by reading the record and POSTing all of it back with the date(s)
|
|
568
|
+
* changed, instead of a partial `{ id, [retireField]: <now> }`. Needed where
|
|
569
|
+
* the API rejects a partial save (promotions: error 899, live 14 Oct 2026).
|
|
570
|
+
*/
|
|
571
|
+
retireWithRecord?: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Start-date field of a record retired with `retireWithRecord`. If the record
|
|
574
|
+
* hasn't started yet (start after now), the start moves to now as well, so
|
|
575
|
+
* start = end and the record is expired without ever running.
|
|
576
|
+
*/
|
|
577
|
+
retireStartField?: string;
|
|
566
578
|
}
|
|
567
579
|
type EntityKind = "product" | "category" | "store" | "promotion" | "employee" | "consumer";
|
|
568
580
|
/** Entities that can be created/updated through the API. */
|
|
@@ -574,7 +586,10 @@ type DeletableEntityKind = Exclude<EntityKind, "consumer">;
|
|
|
574
586
|
* (https://developer.merchantstack.com/api-reference.html) and checked against
|
|
575
587
|
* the live API where noted:
|
|
576
588
|
* - category/product/store: GET filtered by `<x>Ids`, POST upsert, DELETE with `<x>Id` → 205.
|
|
577
|
-
* - promotion: no DELETE;
|
|
589
|
+
* - promotion: no DELETE; promotions are never deleted, only expired. Expiring
|
|
590
|
+
* reads the promotion and saves the whole record back with `endDate` = now (and
|
|
591
|
+
* `startDate` = now too if it hadn't started); the live API rejects a partial
|
|
592
|
+
* `{ id, endDate }` save with error 899. Dates are UTC `YYYY-MM-DD HH:mm:ss`.
|
|
578
593
|
* - employee: POST updates `roleId`, `joinedDate`, `exitDate` (names can't be
|
|
579
594
|
* changed); no DELETE (live API: "Cannot DELETE /employee") → retired via `exitDate`.
|
|
580
595
|
* - consumer: read-only (`GET` with `ids`, comma-separated); live POST → 404.
|
|
@@ -618,7 +633,8 @@ declare function saveEntity<K extends WritableEntityKind>(kind: K, item: EntityI
|
|
|
618
633
|
/**
|
|
619
634
|
* Deletes one entity (a soft delete: it stays readable with `deleted: true`).
|
|
620
635
|
* Employees and promotions can't be deleted in Shopwave; for them the route
|
|
621
|
-
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`)
|
|
636
|
+
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`), and a
|
|
637
|
+
* promotion is saved back whole (see {@link deletePromotion}).
|
|
622
638
|
*
|
|
623
639
|
* Shopwave answers 205 with an empty body — also for ids that don't exist — so
|
|
624
640
|
* a resolved promise means "the API accepted the request", not "a record was
|
|
@@ -650,7 +666,12 @@ declare const saveStore: (store: EntityInput<Store>, options?: RequestOptions) =
|
|
|
650
666
|
declare const deleteStore: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
651
667
|
declare const fetchStore: (id: EntityId, params?: FetchByIdParams, options?: RequestOptions) => Promise<Store | null>;
|
|
652
668
|
declare const savePromotion: (promotion: EntityInput<Promotion>, options?: RequestOptions) => Promise<Saved<Promotion>>;
|
|
653
|
-
/**
|
|
669
|
+
/**
|
|
670
|
+
* Expires a promotion (Shopwave never deletes promotions). The route reads the
|
|
671
|
+
* promotion and saves it back with `endDate` set to now; a promotion that hasn't
|
|
672
|
+
* started yet gets `startDate` = `endDate` = now. Rejects if the promotion doesn't
|
|
673
|
+
* exist or the save fails.
|
|
674
|
+
*/
|
|
654
675
|
declare const deletePromotion: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
655
676
|
declare const fetchPromotion: (id: EntityId, params?: FetchByIdParams, options?: RequestOptions) => Promise<Promotion | null>;
|
|
656
677
|
/**
|
package/dist/core/index.d.ts
CHANGED
|
@@ -556,13 +556,25 @@ interface EntityDefinition {
|
|
|
556
556
|
/**
|
|
557
557
|
* How a delete is done upstream:
|
|
558
558
|
* - `"delete"`: `DELETE {apiUrl}/<upstream>` with the `idHeader` (205, empty body)
|
|
559
|
-
* - `"retire"`: the API has no DELETE; the record is retired by
|
|
560
|
-
* `
|
|
559
|
+
* - `"retire"`: the API has no DELETE; the record is retired by setting
|
|
560
|
+
* `retireField` to now (employees: `exitDate`, promotions: `endDate`)
|
|
561
561
|
* - `"none"`: can't be deleted
|
|
562
562
|
*/
|
|
563
563
|
deleteMode: "delete" | "retire" | "none";
|
|
564
564
|
/** Date field set to "now" when `deleteMode` is `"retire"`. */
|
|
565
565
|
retireField?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Retire by reading the record and POSTing all of it back with the date(s)
|
|
568
|
+
* changed, instead of a partial `{ id, [retireField]: <now> }`. Needed where
|
|
569
|
+
* the API rejects a partial save (promotions: error 899, live 14 Oct 2026).
|
|
570
|
+
*/
|
|
571
|
+
retireWithRecord?: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Start-date field of a record retired with `retireWithRecord`. If the record
|
|
574
|
+
* hasn't started yet (start after now), the start moves to now as well, so
|
|
575
|
+
* start = end and the record is expired without ever running.
|
|
576
|
+
*/
|
|
577
|
+
retireStartField?: string;
|
|
566
578
|
}
|
|
567
579
|
type EntityKind = "product" | "category" | "store" | "promotion" | "employee" | "consumer";
|
|
568
580
|
/** Entities that can be created/updated through the API. */
|
|
@@ -574,7 +586,10 @@ type DeletableEntityKind = Exclude<EntityKind, "consumer">;
|
|
|
574
586
|
* (https://developer.merchantstack.com/api-reference.html) and checked against
|
|
575
587
|
* the live API where noted:
|
|
576
588
|
* - category/product/store: GET filtered by `<x>Ids`, POST upsert, DELETE with `<x>Id` → 205.
|
|
577
|
-
* - promotion: no DELETE;
|
|
589
|
+
* - promotion: no DELETE; promotions are never deleted, only expired. Expiring
|
|
590
|
+
* reads the promotion and saves the whole record back with `endDate` = now (and
|
|
591
|
+
* `startDate` = now too if it hadn't started); the live API rejects a partial
|
|
592
|
+
* `{ id, endDate }` save with error 899. Dates are UTC `YYYY-MM-DD HH:mm:ss`.
|
|
578
593
|
* - employee: POST updates `roleId`, `joinedDate`, `exitDate` (names can't be
|
|
579
594
|
* changed); no DELETE (live API: "Cannot DELETE /employee") → retired via `exitDate`.
|
|
580
595
|
* - consumer: read-only (`GET` with `ids`, comma-separated); live POST → 404.
|
|
@@ -618,7 +633,8 @@ declare function saveEntity<K extends WritableEntityKind>(kind: K, item: EntityI
|
|
|
618
633
|
/**
|
|
619
634
|
* Deletes one entity (a soft delete: it stays readable with `deleted: true`).
|
|
620
635
|
* Employees and promotions can't be deleted in Shopwave; for them the route
|
|
621
|
-
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`)
|
|
636
|
+
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`), and a
|
|
637
|
+
* promotion is saved back whole (see {@link deletePromotion}).
|
|
622
638
|
*
|
|
623
639
|
* Shopwave answers 205 with an empty body — also for ids that don't exist — so
|
|
624
640
|
* a resolved promise means "the API accepted the request", not "a record was
|
|
@@ -650,7 +666,12 @@ declare const saveStore: (store: EntityInput<Store>, options?: RequestOptions) =
|
|
|
650
666
|
declare const deleteStore: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
651
667
|
declare const fetchStore: (id: EntityId, params?: FetchByIdParams, options?: RequestOptions) => Promise<Store | null>;
|
|
652
668
|
declare const savePromotion: (promotion: EntityInput<Promotion>, options?: RequestOptions) => Promise<Saved<Promotion>>;
|
|
653
|
-
/**
|
|
669
|
+
/**
|
|
670
|
+
* Expires a promotion (Shopwave never deletes promotions). The route reads the
|
|
671
|
+
* promotion and saves it back with `endDate` set to now; a promotion that hasn't
|
|
672
|
+
* started yet gets `startDate` = `endDate` = now. Rejects if the promotion doesn't
|
|
673
|
+
* exist or the save fails.
|
|
674
|
+
*/
|
|
654
675
|
declare const deletePromotion: (id: EntityId, options?: RequestOptions) => Promise<void>;
|
|
655
676
|
declare const fetchPromotion: (id: EntityId, params?: FetchByIdParams, options?: RequestOptions) => Promise<Promotion | null>;
|
|
656
677
|
/**
|
package/dist/core/index.js
CHANGED
|
@@ -483,7 +483,10 @@ async function submitEntity({ endpoint, method = "POST", payload }, options = {}
|
|
|
483
483
|
* (https://developer.merchantstack.com/api-reference.html) and checked against
|
|
484
484
|
* the live API where noted:
|
|
485
485
|
* - category/product/store: GET filtered by `<x>Ids`, POST upsert, DELETE with `<x>Id` → 205.
|
|
486
|
-
* - promotion: no DELETE;
|
|
486
|
+
* - promotion: no DELETE; promotions are never deleted, only expired. Expiring
|
|
487
|
+
* reads the promotion and saves the whole record back with `endDate` = now (and
|
|
488
|
+
* `startDate` = now too if it hadn't started); the live API rejects a partial
|
|
489
|
+
* `{ id, endDate }` save with error 899. Dates are UTC `YYYY-MM-DD HH:mm:ss`.
|
|
487
490
|
* - employee: POST updates `roleId`, `joinedDate`, `exitDate` (names can't be
|
|
488
491
|
* changed); no DELETE (live API: "Cannot DELETE /employee") → retired via `exitDate`.
|
|
489
492
|
* - consumer: read-only (`GET` with `ids`, comma-separated); live POST → 404.
|
|
@@ -524,7 +527,9 @@ const SHOPWAVE_ENTITIES = Object.freeze({
|
|
|
524
527
|
idHeader: "promotionId",
|
|
525
528
|
writable: true,
|
|
526
529
|
deleteMode: "retire",
|
|
527
|
-
retireField: "endDate"
|
|
530
|
+
retireField: "endDate",
|
|
531
|
+
retireWithRecord: true,
|
|
532
|
+
retireStartField: "startDate"
|
|
528
533
|
},
|
|
529
534
|
employee: {
|
|
530
535
|
route: "employees",
|
|
@@ -599,7 +604,8 @@ async function saveEntity(kind, item, options = {}) {
|
|
|
599
604
|
/**
|
|
600
605
|
* Deletes one entity (a soft delete: it stays readable with `deleted: true`).
|
|
601
606
|
* Employees and promotions can't be deleted in Shopwave; for them the route
|
|
602
|
-
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`)
|
|
607
|
+
* sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`), and a
|
|
608
|
+
* promotion is saved back whole (see {@link deletePromotion}).
|
|
603
609
|
*
|
|
604
610
|
* Shopwave answers 205 with an empty body — also for ids that don't exist — so
|
|
605
611
|
* a resolved promise means "the API accepted the request", not "a record was
|
|
@@ -640,7 +646,12 @@ const saveStore = (store, options) => saveEntity("store", store, options);
|
|
|
640
646
|
const deleteStore = (id, options) => deleteEntityById("store", id, options);
|
|
641
647
|
const fetchStore = (id, params, options) => fetchEntityById("store", id, params, options);
|
|
642
648
|
const savePromotion = (promotion, options) => saveEntity("promotion", promotion, options);
|
|
643
|
-
/**
|
|
649
|
+
/**
|
|
650
|
+
* Expires a promotion (Shopwave never deletes promotions). The route reads the
|
|
651
|
+
* promotion and saves it back with `endDate` set to now; a promotion that hasn't
|
|
652
|
+
* started yet gets `startDate` = `endDate` = now. Rejects if the promotion doesn't
|
|
653
|
+
* exist or the save fails.
|
|
654
|
+
*/
|
|
644
655
|
const deletePromotion = (id, options) => deleteEntityById("promotion", id, options);
|
|
645
656
|
const fetchPromotion = (id, params, options) => fetchEntityById("promotion", id, params, options);
|
|
646
657
|
/**
|