@fire-spark/core 0.35.3 → 0.35.5

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Money, PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentReversal, PaymentStorage, PaymentUI, RedeemLike, RedeemSource, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
2
- import { AndConditions, ApplyFeesInput, ApplyFeesOrderScope, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fee, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, MasivoTotpCode, MasivoTotpCreateInput, MasivoTotpVerification, MasivoTotpVerifyInput, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderFulfillmentWorkflow, OrderFulfillmentWorkflowEdge, OrderFulfillmentWorkflowNode, OrderInsertInput, OrderLine, OrderListInput, OrderRecord, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosFloorInput, PosFloorOccupancy, PosFloorPlan, PosFloorRealtimeToken, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PosTableAttachOrderInput, PosTableCloseInput, PosTableJoinInput, PosTableSeatInput, PosTableSeatReservationInput, PosTableSplitInput, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronFormatter, RecurringDateCronResult, RecurringDateCronSummary, RecurringDateCronValues, RulesEngineOrder, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, SwitchCustomerArg, SwitchCustomerArg as SwitchCustomerArg$1, SwitchCustomerIdToken, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup, WordFilterCheckInput, WordFilterCheckResult } from "@fire-spark/types";
2
+ import { AndConditions, ApplyFeesInput, ApplyFeesOrderScope, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fee, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceConfigInput, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskPickupNameRules, KioskRealtimeToken, MasivoTotpCode, MasivoTotpCreateInput, MasivoTotpVerification, MasivoTotpVerifyInput, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderFulfillmentWorkflow, OrderFulfillmentWorkflowEdge, OrderFulfillmentWorkflowNode, OrderInsertInput, OrderLine, OrderListInput, OrderRateInput, OrderRating, OrderRecord, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderSetCustomerInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosFloorInput, PosFloorOccupancy, PosFloorPlan, PosFloorRealtimeToken, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PosTableAttachOrderInput, PosTableCloseInput, PosTableJoinInput, PosTableSeatInput, PosTableSeatReservationInput, PosTableSplitInput, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronFormatter, RecurringDateCronResult, RecurringDateCronSummary, RecurringDateCronValues, RulesEngineOrder, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, SwitchCustomerArg, SwitchCustomerArg as SwitchCustomerArg$1, SwitchCustomerIdToken, SwitchCustomerResult, SwitchCustomerResult as SwitchCustomerResult$1, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup, WordFilterCheckInput, WordFilterCheckResult } from "@fire-spark/types";
3
3
  import { Big } from "big.js";
4
4
  //#region src/productCustomization/catalog.utils.d.ts
5
5
  /** Image for a product inside one modifier group, else the product image. */
@@ -396,6 +396,14 @@ declare const cancelOrder: (id: string, options?: ServiceHttpOptions, body?: Ord
396
396
  /** Refunds the tenders only; the order status stays. `type` is `REFUND`. */
397
397
  declare const refundOrder: (id: string, options?: ServiceHttpOptions, body?: OrderCancelInput$1) => Promise<Order$1>;
398
398
  declare const reorderOrder: (id: string, body?: OrderReorderInput, options?: ServiceHttpOptions) => Promise<Order$1>;
399
+ /**
400
+ * `POST /storefront/v1/orders/:id/rating`: rates a `COMPLETED` order of the
401
+ * signed-in customer once, on the scale stored in `order.rating`. Rejects
402
+ * with `StorefrontHttpError` and `details.code`: `ORDER_NOT_FOUND` (404),
403
+ * `ORDER_NOT_COMPLETED` (422), `ORDER_ALREADY_RATED` (409) or
404
+ * `INVALID_RATING` (400 bad body, 422 score outside the order's scale).
405
+ */
406
+ declare const rateOrder: (id: string, body: OrderRateInput, options?: ServiceHttpOptions) => Promise<Order$1>;
399
407
  /**
400
408
  * `POST /storefront/v1/orders/:id/reopen`: voids every payment of a placed,
401
409
  * unpaid order, cancels it (`VOIDED`) and returns the new `OPEN` order with
@@ -791,6 +799,13 @@ declare class Order {
791
799
  */
792
800
  reopen(orderId?: string): Promise<Order>;
793
801
  refundOrder(): Promise<void>;
802
+ /**
803
+ * Rates this `COMPLETED` order once, on the scale in `order.rating`
804
+ * (`min_score` to `max_score`, stored when the order was created).
805
+ * Rejects with `StorefrontHttpError` and `details.code`
806
+ * `ORDER_NOT_COMPLETED`, `ORDER_ALREADY_RATED` or `INVALID_RATING`.
807
+ */
808
+ rate(input: OrderRateInput): Promise<OrderRating>;
794
809
  validateOrder(): Promise<void>;
795
810
  /**
796
811
  * Tenders of the next intent: one REDEMPTION per `payment_id` that
@@ -1543,6 +1558,7 @@ declare const services: {
1543
1558
  refund: typeof refundOrder;
1544
1559
  reorder: typeof reorderOrder;
1545
1560
  reopen: typeof reopenOrder;
1561
+ rate: typeof rateOrder;
1546
1562
  validate: typeof validateOrder;
1547
1563
  place: typeof placeOrder;
1548
1564
  recordPayment: typeof recordOrderPayment;
package/dist/index.js CHANGED
@@ -3295,6 +3295,19 @@ const reorderOrder = (id, body = {}, options) => {
3295
3295
  }, options);
3296
3296
  };
3297
3297
  /**
3298
+ * `POST /storefront/v1/orders/:id/rating`: rates a `COMPLETED` order of the
3299
+ * signed-in customer once, on the scale stored in `order.rating`. Rejects
3300
+ * with `StorefrontHttpError` and `details.code`: `ORDER_NOT_FOUND` (404),
3301
+ * `ORDER_NOT_COMPLETED` (422), `ORDER_ALREADY_RATED` (409) or
3302
+ * `INVALID_RATING` (400 bad body, 422 score outside the order's scale).
3303
+ */
3304
+ const rateOrder = (id, body, options) => {
3305
+ return storefrontJson(`${orderPath(id)}/rating`, {
3306
+ method: "POST",
3307
+ body: JSON.stringify(body)
3308
+ }, options);
3309
+ };
3310
+ /**
3298
3311
  * `POST /storefront/v1/orders/:id/reopen`: voids every payment of a placed,
3299
3312
  * unpaid order, cancels it (`VOIDED`) and returns the new `OPEN` order with
3300
3313
  * the same content. Rejects with `StorefrontHttpError` 400
@@ -3788,6 +3801,7 @@ const services = {
3788
3801
  refund: refundOrder,
3789
3802
  reorder: reorderOrder,
3790
3803
  reopen: reopenOrder,
3804
+ rate: rateOrder,
3791
3805
  validate: validateOrder,
3792
3806
  place: placeOrder,
3793
3807
  recordPayment: recordOrderPayment,
@@ -7107,6 +7121,20 @@ var Order = class Order {
7107
7121
  this.notify();
7108
7122
  auth.releaseDelegatedOrder(this.draft.id);
7109
7123
  }
7124
+ /**
7125
+ * Rates this `COMPLETED` order once, on the scale in `order.rating`
7126
+ * (`min_score` to `max_score`, stored when the order was created).
7127
+ * Rejects with `StorefrontHttpError` and `details.code`
7128
+ * `ORDER_NOT_COMPLETED`, `ORDER_ALREADY_RATED` or `INVALID_RATING`.
7129
+ */
7130
+ async rate(input) {
7131
+ if (!this.persisted) throw new Error("Only a placed order is rated");
7132
+ this.flush.cancel();
7133
+ const next = await services.orders.rate(this.draft.id, input, this.http);
7134
+ this.applyServerOrder(next);
7135
+ if (!next.rating) throw new Error("Storefront response missing rating");
7136
+ return next.rating;
7137
+ }
7110
7138
  async validateOrder() {
7111
7139
  const draft = this.getOrder();
7112
7140
  const b1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fire-spark/core",
3
- "version": "0.35.3",
3
+ "version": "0.35.5",
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.35.3",
24
- "@fire-spark/types": "^0.35.3"
23
+ "@fire-spark/payments": "^0.35.5",
24
+ "@fire-spark/types": "^0.35.5"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsdown": "^0.22.14",