@fire-spark/core 0.3.1 → 0.3.3

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +33 -1
  2. package/dist/index.js +1224 -1164
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -264,6 +264,13 @@ declare const updateOrder: (id: string, body: OrderUpdateInput, options?: Servic
264
264
  declare const cancelOrder: (id: string, options?: ServiceHttpOptions) => Promise<Order$1>;
265
265
  declare const refundOrder: (id: string, options?: ServiceHttpOptions) => Promise<Order$1>;
266
266
  declare const reorderOrder: (id: string, body?: OrderReorderInput, options?: ServiceHttpOptions) => Promise<Order$1>;
267
+ /**
268
+ * `POST /storefront/v1/orders/:id/reopen`: voids every payment of a placed,
269
+ * unpaid order, cancels it (`VOIDED`) and returns the new `OPEN` order with
270
+ * the same content. Rejects with `StorefrontHttpError` 400
271
+ * (`details.code: "ORDER_PAYMENT_CAPTURED"`) when a payment was captured.
272
+ */
273
+ declare const reopenOrder: (id: string, options?: ServiceHttpOptions) => Promise<Order$1>;
267
274
  declare const validateOrder: (body: OrderValidateInput, options?: ServiceHttpOptions) => Promise<OrderValidateOutput>;
268
275
  //#endregion
269
276
  //#region src/order/payments/orchestrator.d.ts
@@ -451,11 +458,18 @@ declare class Order {
451
458
  private readonly listeners;
452
459
  private readonly externalNotify?;
453
460
  private readonly http;
461
+ private readonly debounceMs;
454
462
  private readonly flush;
455
463
  private readonly payments;
456
464
  /** Real tenders chosen with `setTenders`; REDEMPTION ones come from redeem. */
457
465
  private realTenders;
458
466
  private readonly redemptionProviders;
467
+ /**
468
+ * Redeems as applied, before the D18 cap trims payment amounts. The cap
469
+ * is re-derived from these on every edit, so a redeem trimmed while the
470
+ * total was low recovers its amount once the total grows back.
471
+ */
472
+ private requestedRedeem;
459
473
  private constructor();
460
474
  /**
461
475
  * Opens a cart session: reuses an existing OPEN order for the scope, or a
@@ -528,9 +542,23 @@ declare class Order {
528
542
  billing_info?: Order$1["customer"]["billing_info"];
529
543
  }): void;
530
544
  cancelOrder(): Promise<void>;
545
+ /**
546
+ * Reopens this placed, unpaid order: the server voids every payment
547
+ * (REDEMPTION points released), cancels it as `VOIDED` and opens a new
548
+ * `OPEN` order with the same content. This instance is closed afterwards;
549
+ * replace it with the returned `Order` (same HTTP options and listener).
550
+ *
551
+ * Rejects with `StorefrontHttpError` 400 and
552
+ * `details.code: "ORDER_PAYMENT_CAPTURED"` when a payment was already
553
+ * captured; nothing changes then and this instance stays usable.
554
+ */
555
+ reopen(): Promise<Order>;
531
556
  refundOrder(): Promise<void>;
532
557
  validateOrder(): Promise<void>;
533
- /** Tenders of the next intent: real ones plus one per payment redeem. */
558
+ /**
559
+ * Tenders of the next intent: real ones plus one per payment redeem.
560
+ * When the payment redeems cover the total, only REDEMPTION tenders.
561
+ */
534
562
  getTenders(payment?: PlaceOrderInput["payment"]): PaymentTenderInput[];
535
563
  /**
536
564
  * Chooses the real tenders (with allocation for mixed payments) and saves
@@ -542,6 +570,9 @@ declare class Order {
542
570
  clearTenders(): Promise<Order$1>;
543
571
  private syncPaymentIntent;
544
572
  private applyServerOrder;
573
+ /** Keeps the applied redeems while the server holds the same capped ones. */
574
+ private replaceDraft;
575
+ private appliedRedeem;
545
576
  /**
546
577
  * Places the order with a DRAFT intent: `intent_id` as is, else the
547
578
  * tenders of `getTenders(input.payment)` saved first (simple flow: one
@@ -959,6 +990,7 @@ declare const services: {
959
990
  cancel: typeof cancelOrder;
960
991
  refund: typeof refundOrder;
961
992
  reorder: typeof reorderOrder;
993
+ reopen: typeof reopenOrder;
962
994
  validate: typeof validateOrder;
963
995
  place: typeof placeOrder;
964
996
  recordPayment: typeof recordOrderPayment;