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/dist/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 POSTing
560
- * `{ id, [retireField]: <now> }` (employees: `exitDate`, promotions: `endDate`)
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; "deleting" a promotion ends it by setting `endDate` to now.
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
- /** Ends a promotion: Shopwave has no promotion DELETE, so this sets `endDate` to now. */
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/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 POSTing
560
- * `{ id, [retireField]: <now> }` (employees: `exitDate`, promotions: `endDate`)
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; "deleting" a promotion ends it by setting `endDate` to now.
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
- /** Ends a promotion: Shopwave has no promotion DELETE, so this sets `endDate` to now. */
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/index.js CHANGED
@@ -485,7 +485,10 @@ async function submitEntity({ endpoint, method = "POST", payload }, options = {}
485
485
  * (https://developer.merchantstack.com/api-reference.html) and checked against
486
486
  * the live API where noted:
487
487
  * - category/product/store: GET filtered by `<x>Ids`, POST upsert, DELETE with `<x>Id` → 205.
488
- * - promotion: no DELETE; "deleting" a promotion ends it by setting `endDate` to now.
488
+ * - promotion: no DELETE; promotions are never deleted, only expired. Expiring
489
+ * reads the promotion and saves the whole record back with `endDate` = now (and
490
+ * `startDate` = now too if it hadn't started); the live API rejects a partial
491
+ * `{ id, endDate }` save with error 899. Dates are UTC `YYYY-MM-DD HH:mm:ss`.
489
492
  * - employee: POST updates `roleId`, `joinedDate`, `exitDate` (names can't be
490
493
  * changed); no DELETE (live API: "Cannot DELETE /employee") → retired via `exitDate`.
491
494
  * - consumer: read-only (`GET` with `ids`, comma-separated); live POST → 404.
@@ -526,7 +529,9 @@ const SHOPWAVE_ENTITIES = Object.freeze({
526
529
  idHeader: "promotionId",
527
530
  writable: true,
528
531
  deleteMode: "retire",
529
- retireField: "endDate"
532
+ retireField: "endDate",
533
+ retireWithRecord: true,
534
+ retireStartField: "startDate"
530
535
  },
531
536
  employee: {
532
537
  route: "employees",
@@ -601,7 +606,8 @@ async function saveEntity(kind, item, options = {}) {
601
606
  /**
602
607
  * Deletes one entity (a soft delete: it stays readable with `deleted: true`).
603
608
  * Employees and promotions can't be deleted in Shopwave; for them the route
604
- * sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`).
609
+ * sets `exitDate` / `endDate` to now instead (see `SHOPWAVE_ENTITIES`), and a
610
+ * promotion is saved back whole (see {@link deletePromotion}).
605
611
  *
606
612
  * Shopwave answers 205 with an empty body — also for ids that don't exist — so
607
613
  * a resolved promise means "the API accepted the request", not "a record was
@@ -642,7 +648,12 @@ const saveStore = (store, options) => saveEntity("store", store, options);
642
648
  const deleteStore = (id, options) => deleteEntityById("store", id, options);
643
649
  const fetchStore = (id, params, options) => fetchEntityById("store", id, params, options);
644
650
  const savePromotion = (promotion, options) => saveEntity("promotion", promotion, options);
645
- /** Ends a promotion: Shopwave has no promotion DELETE, so this sets `endDate` to now. */
651
+ /**
652
+ * Expires a promotion (Shopwave never deletes promotions). The route reads the
653
+ * promotion and saves it back with `endDate` set to now; a promotion that hasn't
654
+ * started yet gets `startDate` = `endDate` = now. Rejects if the promotion doesn't
655
+ * exist or the save fails.
656
+ */
646
657
  const deletePromotion = (id, options) => deleteEntityById("promotion", id, options);
647
658
  const fetchPromotion = (id, params, options) => fetchEntityById("promotion", id, params, options);
648
659
  /**