@fire-spark/core 0.42.0 → 0.42.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 +14 -0
- package/dist/index.js +25 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -344,6 +344,12 @@ declare const storefrontJson: <T>(path: string, init?: RequestInit, options?: Se
|
|
|
344
344
|
declare const listOrders: (input?: OrderListInput, options?: ServiceHttpOptions) => Promise<Order$1[]>;
|
|
345
345
|
declare const createOrder: (body: OrderInsertInput, options?: ServiceHttpOptions) => Promise<Order$1>;
|
|
346
346
|
declare const getOrder: (id: string, options?: ServiceHttpOptions) => Promise<Order$1>;
|
|
347
|
+
/**
|
|
348
|
+
* Reads an order through the kiosk / POS that stamped it, whatever its
|
|
349
|
+
* `customer_id` (anonymous kiosk sessions, customer switches). `404` when
|
|
350
|
+
* that device did not stamp the order.
|
|
351
|
+
*/
|
|
352
|
+
declare const getOrderByDevice: (id: string, device: PlaceOrderDevice, options?: ServiceHttpOptions) => Promise<Order$1>;
|
|
347
353
|
type PlaceOrderDevice = {
|
|
348
354
|
kind: "KIOSK" | "POS";
|
|
349
355
|
uid: string;
|
|
@@ -953,6 +959,13 @@ declare class Order {
|
|
|
953
959
|
*/
|
|
954
960
|
refund(options?: Omit<OrderCancelOptions, "type">): Promise<OrderCancelResult>;
|
|
955
961
|
private freshCancelType;
|
|
962
|
+
/**
|
|
963
|
+
* `GET /orders/:id` with the session token; on `404` with a device
|
|
964
|
+
* credential, reads it through the device that stamped it. Kiosk
|
|
965
|
+
* sessions are often anonymous or switched customer, so the token's
|
|
966
|
+
* customer no longer owns the order the operator is cancelling.
|
|
967
|
+
*/
|
|
968
|
+
private fetchOwnOrder;
|
|
956
969
|
private runCancel;
|
|
957
970
|
/** Voids one tender (operator flow); idempotent per call. */
|
|
958
971
|
voidTender(tenderId: string, reason?: string): Promise<Order$1>;
|
|
@@ -1849,6 +1862,7 @@ declare const services: {
|
|
|
1849
1862
|
list: typeof listOrders;
|
|
1850
1863
|
post: typeof createOrder;
|
|
1851
1864
|
get: typeof getOrder;
|
|
1865
|
+
getByDevice: typeof getOrderByDevice;
|
|
1852
1866
|
patch: typeof updateOrder;
|
|
1853
1867
|
setCustomer: typeof setOrderCustomer;
|
|
1854
1868
|
clearCustomer: typeof clearOrderCustomer;
|
package/dist/index.js
CHANGED
|
@@ -3404,6 +3404,14 @@ const createOrder = (body, options) => {
|
|
|
3404
3404
|
const getOrder = (id, options) => {
|
|
3405
3405
|
return storefrontJson(orderPath(id), {}, options);
|
|
3406
3406
|
};
|
|
3407
|
+
/**
|
|
3408
|
+
* Reads an order through the kiosk / POS that stamped it, whatever its
|
|
3409
|
+
* `customer_id` (anonymous kiosk sessions, customer switches). `404` when
|
|
3410
|
+
* that device did not stamp the order.
|
|
3411
|
+
*/
|
|
3412
|
+
const getOrderByDevice = (id, device, options) => {
|
|
3413
|
+
return postJson$1(`${orderPath(id)}/device`, { device }, options);
|
|
3414
|
+
};
|
|
3407
3415
|
const placeOrder = (id, body = {}, options) => {
|
|
3408
3416
|
const init = {
|
|
3409
3417
|
method: "POST",
|
|
@@ -5655,6 +5663,7 @@ const services = {
|
|
|
5655
5663
|
list: listOrders,
|
|
5656
5664
|
post: createOrder,
|
|
5657
5665
|
get: getOrder,
|
|
5666
|
+
getByDevice: getOrderByDevice,
|
|
5658
5667
|
patch: updateOrder,
|
|
5659
5668
|
setCustomer: setOrderCustomer,
|
|
5660
5669
|
clearCustomer: clearOrderCustomer,
|
|
@@ -11147,10 +11156,25 @@ var Order = class Order {
|
|
|
11147
11156
|
async freshCancelType() {
|
|
11148
11157
|
if (!this.persisted) throw new Error("Only a placed order is cancelled");
|
|
11149
11158
|
this.flush.cancel();
|
|
11150
|
-
const next = await
|
|
11159
|
+
const next = await this.fetchOwnOrder();
|
|
11151
11160
|
this.applyServerOrder(next);
|
|
11152
11161
|
return cancelTypeOf(this.draft);
|
|
11153
11162
|
}
|
|
11163
|
+
/**
|
|
11164
|
+
* `GET /orders/:id` with the session token; on `404` with a device
|
|
11165
|
+
* credential, reads it through the device that stamped it. Kiosk
|
|
11166
|
+
* sessions are often anonymous or switched customer, so the token's
|
|
11167
|
+
* customer no longer owns the order the operator is cancelling.
|
|
11168
|
+
*/
|
|
11169
|
+
async fetchOwnOrder() {
|
|
11170
|
+
const http = this.activeHttp();
|
|
11171
|
+
try {
|
|
11172
|
+
return await services.orders.get(this.draft.id, http);
|
|
11173
|
+
} catch (error) {
|
|
11174
|
+
if (!(error instanceof StorefrontHttpError) || error.status !== 404 || !this.device) throw error;
|
|
11175
|
+
return services.orders.getByDevice(this.draft.id, this.device, http);
|
|
11176
|
+
}
|
|
11177
|
+
}
|
|
11154
11178
|
async runCancel(path, type, options) {
|
|
11155
11179
|
const earlier = this.unreported;
|
|
11156
11180
|
const done = new Set(earlier.map((reversal) => reversal.tender.id));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.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.42.
|
|
24
|
-
"@fire-spark/types": "^0.42.
|
|
23
|
+
"@fire-spark/payments": "^0.42.2",
|
|
24
|
+
"@fire-spark/types": "^0.42.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|