@fire-spark/core 0.3.1 → 0.3.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.ts +20 -0
- package/dist/index.js +38 -0
- 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,6 +458,7 @@ 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. */
|
|
@@ -528,6 +536,17 @@ declare class Order {
|
|
|
528
536
|
billing_info?: Order$1["customer"]["billing_info"];
|
|
529
537
|
}): void;
|
|
530
538
|
cancelOrder(): Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Reopens this placed, unpaid order: the server voids every payment
|
|
541
|
+
* (REDEMPTION points released), cancels it as `VOIDED` and opens a new
|
|
542
|
+
* `OPEN` order with the same content. This instance is closed afterwards;
|
|
543
|
+
* replace it with the returned `Order` (same HTTP options and listener).
|
|
544
|
+
*
|
|
545
|
+
* Rejects with `StorefrontHttpError` 400 and
|
|
546
|
+
* `details.code: "ORDER_PAYMENT_CAPTURED"` when a payment was already
|
|
547
|
+
* captured; nothing changes then and this instance stays usable.
|
|
548
|
+
*/
|
|
549
|
+
reopen(): Promise<Order>;
|
|
531
550
|
refundOrder(): Promise<void>;
|
|
532
551
|
validateOrder(): Promise<void>;
|
|
533
552
|
/** Tenders of the next intent: real ones plus one per payment redeem. */
|
|
@@ -959,6 +978,7 @@ declare const services: {
|
|
|
959
978
|
cancel: typeof cancelOrder;
|
|
960
979
|
refund: typeof refundOrder;
|
|
961
980
|
reorder: typeof reorderOrder;
|
|
981
|
+
reopen: typeof reopenOrder;
|
|
962
982
|
validate: typeof validateOrder;
|
|
963
983
|
place: typeof placeOrder;
|
|
964
984
|
recordPayment: typeof recordOrderPayment;
|
package/dist/index.js
CHANGED
|
@@ -2605,6 +2605,15 @@ const reorderOrder = (id, body = {}, options) => {
|
|
|
2605
2605
|
body: JSON.stringify(body)
|
|
2606
2606
|
}, options);
|
|
2607
2607
|
};
|
|
2608
|
+
/**
|
|
2609
|
+
* `POST /storefront/v1/orders/:id/reopen`: voids every payment of a placed,
|
|
2610
|
+
* unpaid order, cancels it (`VOIDED`) and returns the new `OPEN` order with
|
|
2611
|
+
* the same content. Rejects with `StorefrontHttpError` 400
|
|
2612
|
+
* (`details.code: "ORDER_PAYMENT_CAPTURED"`) when a payment was captured.
|
|
2613
|
+
*/
|
|
2614
|
+
const reopenOrder = (id, options) => {
|
|
2615
|
+
return storefrontJson(`${orderPath(id)}/reopen`, { method: "POST" }, options);
|
|
2616
|
+
};
|
|
2608
2617
|
const parseValidationDetails = (body) => {
|
|
2609
2618
|
if (!body || typeof body !== "object") return null;
|
|
2610
2619
|
const details = body.details;
|
|
@@ -2940,6 +2949,7 @@ const services = {
|
|
|
2940
2949
|
cancel: cancelOrder,
|
|
2941
2950
|
refund: refundOrder,
|
|
2942
2951
|
reorder: reorderOrder,
|
|
2952
|
+
reopen: reopenOrder,
|
|
2943
2953
|
validate: validateOrder,
|
|
2944
2954
|
place: placeOrder,
|
|
2945
2955
|
recordPayment: recordOrderPayment,
|
|
@@ -5279,6 +5289,7 @@ var Order = class Order {
|
|
|
5279
5289
|
listeners = /* @__PURE__ */ new Set();
|
|
5280
5290
|
externalNotify;
|
|
5281
5291
|
http;
|
|
5292
|
+
debounceMs;
|
|
5282
5293
|
flush;
|
|
5283
5294
|
payments;
|
|
5284
5295
|
/** Real tenders chosen with `setTenders`; REDEMPTION ones come from redeem. */
|
|
@@ -5290,6 +5301,7 @@ var Order = class Order {
|
|
|
5290
5301
|
this.rememberLogScope();
|
|
5291
5302
|
this.persisted = config.persisted;
|
|
5292
5303
|
this.http = config.http;
|
|
5304
|
+
this.debounceMs = config.debounceMs;
|
|
5293
5305
|
this.externalNotify = notify;
|
|
5294
5306
|
this.flush = createFlushController({
|
|
5295
5307
|
getDraft: () => this.draft,
|
|
@@ -5620,6 +5632,32 @@ var Order = class Order {
|
|
|
5620
5632
|
this.deleted = true;
|
|
5621
5633
|
this.notify();
|
|
5622
5634
|
}
|
|
5635
|
+
/**
|
|
5636
|
+
* Reopens this placed, unpaid order: the server voids every payment
|
|
5637
|
+
* (REDEMPTION points released), cancels it as `VOIDED` and opens a new
|
|
5638
|
+
* `OPEN` order with the same content. This instance is closed afterwards;
|
|
5639
|
+
* replace it with the returned `Order` (same HTTP options and listener).
|
|
5640
|
+
*
|
|
5641
|
+
* Rejects with `StorefrontHttpError` 400 and
|
|
5642
|
+
* `details.code: "ORDER_PAYMENT_CAPTURED"` when a payment was already
|
|
5643
|
+
* captured; nothing changes then and this instance stays usable.
|
|
5644
|
+
*/
|
|
5645
|
+
async reopen() {
|
|
5646
|
+
if (!this.persisted) throw new Error("Only a placed order is reopened");
|
|
5647
|
+
this.flush.cancel();
|
|
5648
|
+
const c1 = {
|
|
5649
|
+
order: await services.orders.reopen(this.draft.id, this.http),
|
|
5650
|
+
http: this.http,
|
|
5651
|
+
debounceMs: this.debounceMs
|
|
5652
|
+
};
|
|
5653
|
+
const reopened = new Order({
|
|
5654
|
+
...c1,
|
|
5655
|
+
persisted: true
|
|
5656
|
+
}, this.externalNotify);
|
|
5657
|
+
this.deleted = true;
|
|
5658
|
+
this.notify();
|
|
5659
|
+
return reopened;
|
|
5660
|
+
}
|
|
5623
5661
|
async refundOrder() {
|
|
5624
5662
|
if (this.deleted) return;
|
|
5625
5663
|
this.flush.cancel();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Fire Spark headless SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"big.js": "6.2.1",
|
|
21
21
|
"dayjs": "1.11.9",
|
|
22
22
|
"@types/big.js": "6.2.2",
|
|
23
|
-
"@fire-spark/payments": "^0.3.
|
|
24
|
-
"@fire-spark/types": "^0.3.
|
|
23
|
+
"@fire-spark/payments": "^0.3.2",
|
|
24
|
+
"@fire-spark/types": "^0.3.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|