@final-commerce/command-frame 0.3.0-beta.7 → 0.3.0-beta.8
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/actions/send-email/action.d.ts +6 -0
- package/dist/actions/send-email/action.js +8 -0
- package/dist/actions/send-email/mock.d.ts +2 -0
- package/dist/actions/send-email/mock.js +11 -0
- package/dist/actions/send-email/types.d.ts +28 -0
- package/dist/actions/send-email/types.js +2 -0
- package/dist/actions/send-sms/action.d.ts +6 -0
- package/dist/actions/send-sms/action.js +8 -0
- package/dist/actions/send-sms/mock.d.ts +2 -0
- package/dist/actions/send-sms/mock.js +11 -0
- package/dist/actions/send-sms/types.d.ts +24 -0
- package/dist/actions/send-sms/types.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -1
- package/dist/projects/render/mocks.js +5 -1
- package/dist/projects/render/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send email action — email the customer the active order's (or a refund's) receipt.
|
|
3
|
+
* Calls the sendEmail action on the parent window.
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const sendEmail = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("sendEmail", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const mockSendEmail = async (params) => {
|
|
2
|
+
console.log("[Mock] sendEmail called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
channel: "email",
|
|
6
|
+
email: params?.email || "mock@example.com",
|
|
7
|
+
entityId: params?.refundId || params?.orderId || "mock_order_1",
|
|
8
|
+
type: params?.type || "order",
|
|
9
|
+
timestamp: new Date().toISOString()
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which receipt to send: a finalized order (default) or a refund.
|
|
3
|
+
* Values MUST stay in lockstep with `ReceiptType` in `@final-commerce/common` (used by hub-api);
|
|
4
|
+
* this SDK intentionally has no dependency on that package, so the literal is duplicated here.
|
|
5
|
+
*/
|
|
6
|
+
export type SendReceiptType = 'order' | 'refund';
|
|
7
|
+
export interface SendEmailParams {
|
|
8
|
+
/** Recipient email. Defaults to the active customer's email. */
|
|
9
|
+
email?: string;
|
|
10
|
+
/** Order id to send the receipt for. Defaults to the active order. */
|
|
11
|
+
orderId?: string;
|
|
12
|
+
/** Refund id — required when `type` is 'refund'. */
|
|
13
|
+
refundId?: string;
|
|
14
|
+
/** 'order' (default) or 'refund'. */
|
|
15
|
+
type?: SendReceiptType;
|
|
16
|
+
}
|
|
17
|
+
export interface SendEmailResponse {
|
|
18
|
+
success: boolean;
|
|
19
|
+
/** Always 'email' for this action. */
|
|
20
|
+
channel: 'email';
|
|
21
|
+
/** The email the receipt was sent to. */
|
|
22
|
+
email: string;
|
|
23
|
+
/** The order or refund id the receipt was sent for. */
|
|
24
|
+
entityId: string;
|
|
25
|
+
type: SendReceiptType;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
}
|
|
28
|
+
export type SendEmail = (params?: SendEmailParams) => Promise<SendEmailResponse>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send SMS action — text the customer the active order's (or a refund's) receipt.
|
|
3
|
+
* Calls the sendSms action on the parent window.
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const sendSms = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("sendSms", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const mockSendSms = async (params) => {
|
|
2
|
+
console.log("[Mock] sendSms called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
channel: "text",
|
|
6
|
+
phone: params?.phone || "+15555550123",
|
|
7
|
+
entityId: params?.refundId || params?.orderId || "mock_order_1",
|
|
8
|
+
type: params?.type || "order",
|
|
9
|
+
timestamp: new Date().toISOString()
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SendReceiptType } from "../send-email/types";
|
|
2
|
+
export type { SendReceiptType };
|
|
3
|
+
export interface SendSmsParams {
|
|
4
|
+
/** Recipient phone in E.164 format (e.g. +15555550123). Defaults to the active customer's phone. */
|
|
5
|
+
phone?: string;
|
|
6
|
+
/** Order id to send the receipt for. Defaults to the active order. */
|
|
7
|
+
orderId?: string;
|
|
8
|
+
/** Refund id — required when `type` is 'refund'. */
|
|
9
|
+
refundId?: string;
|
|
10
|
+
/** 'order' (default) or 'refund'. */
|
|
11
|
+
type?: SendReceiptType;
|
|
12
|
+
}
|
|
13
|
+
export interface SendSmsResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
/** Always 'text' for this action. */
|
|
16
|
+
channel: 'text';
|
|
17
|
+
/** The phone the receipt was sent to (E.164). */
|
|
18
|
+
phone: string;
|
|
19
|
+
/** The order or refund id the receipt was sent for. */
|
|
20
|
+
entityId: string;
|
|
21
|
+
type: SendReceiptType;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
}
|
|
24
|
+
export type SendSms = (params?: SendSmsParams) => Promise<SendSmsResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export declare const command: {
|
|
|
69
69
|
readonly removeOrderNote: import(".").RemoveOrderNote;
|
|
70
70
|
readonly removeCustomSale: import(".").RemoveCustomSale;
|
|
71
71
|
readonly removeNonRevenueItem: import(".").RemoveNonRevenueItem;
|
|
72
|
+
readonly sendEmail: import(".").SendEmail;
|
|
73
|
+
readonly sendSms: import(".").SendSms;
|
|
72
74
|
readonly initiateRefund: import(".").InitiateRefund;
|
|
73
75
|
readonly setRefundStockAction: import(".").SetRefundStockAction;
|
|
74
76
|
readonly selectAllRefundItems: import(".").SelectAllRefundItems;
|
|
@@ -200,6 +202,8 @@ export type { RemoveCartFee, RemoveCartFeeParams, RemoveCartFeeResponse } from "
|
|
|
200
202
|
export type { RemoveOrderNote, RemoveOrderNoteResponse } from "./actions/remove-order-note/types";
|
|
201
203
|
export type { RemoveCustomSale, RemoveCustomSaleParams, RemoveCustomSaleResponse } from "./actions/remove-custom-sale/types";
|
|
202
204
|
export type { RemoveNonRevenueItem, RemoveNonRevenueItemParams, RemoveNonRevenueItemResponse } from "./actions/remove-non-revenue-item/types";
|
|
205
|
+
export type { SendEmail, SendEmailParams, SendEmailResponse, SendReceiptType } from "./actions/send-email/types";
|
|
206
|
+
export type { SendSms, SendSmsParams, SendSmsResponse } from "./actions/send-sms/types";
|
|
203
207
|
export * from "./CommonTypes";
|
|
204
208
|
export { setMockDatabase, setMockActiveProduct } from "./demo/database";
|
|
205
209
|
export type { MockDatabaseConfig } from "./demo/database";
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,9 @@ import { removeOrderNote } from "./actions/remove-order-note/action";
|
|
|
73
73
|
import { removeCustomSale } from "./actions/remove-custom-sale/action";
|
|
74
74
|
import { removeNonRevenueItem } from "./actions/remove-non-revenue-item/action";
|
|
75
75
|
// Integration Actions
|
|
76
|
+
// Receipt send Actions
|
|
77
|
+
import { sendEmail } from "./actions/send-email/action";
|
|
78
|
+
import { sendSms } from "./actions/send-sms/action";
|
|
76
79
|
// Refund Actions
|
|
77
80
|
import { getRefunds } from "./actions/get-refunds/action";
|
|
78
81
|
import { initiateRefund } from "./actions/initiate-refund/action";
|
|
@@ -199,6 +202,9 @@ export const command = {
|
|
|
199
202
|
removeCustomSale,
|
|
200
203
|
removeNonRevenueItem,
|
|
201
204
|
// Integration Actions
|
|
205
|
+
// Receipt send Actions
|
|
206
|
+
sendEmail,
|
|
207
|
+
sendSms,
|
|
202
208
|
// Refund Actions
|
|
203
209
|
initiateRefund,
|
|
204
210
|
setRefundStockAction,
|
|
@@ -247,7 +253,6 @@ export const command = {
|
|
|
247
253
|
getAvailableTransitions,
|
|
248
254
|
applyTransition
|
|
249
255
|
};
|
|
250
|
-
// Integration Actions
|
|
251
256
|
// Export Common Types
|
|
252
257
|
export * from "./CommonTypes";
|
|
253
258
|
// Mock database override (standalone / extension dev)
|
|
@@ -92,6 +92,8 @@ import { canTransitionMock } from "../../actions/can-transition/mock";
|
|
|
92
92
|
import { getAvailableTransitionsMock } from "../../actions/get-available-transitions/mock";
|
|
93
93
|
import { mockGetSmartGridLayout } from "../../actions/get-smart-grid-layout/mock";
|
|
94
94
|
import { mockSaveSmartGridLayout } from "../../actions/save-smart-grid-layout/mock";
|
|
95
|
+
import { mockSendEmail } from "../../actions/send-email/mock";
|
|
96
|
+
import { mockSendSms } from "../../actions/send-sms/mock";
|
|
95
97
|
export const RENDER_MOCKS = {
|
|
96
98
|
addCartDiscount: mockAddCartDiscount,
|
|
97
99
|
addCartFee: mockAddCartFee,
|
|
@@ -188,5 +190,7 @@ export const RENDER_MOCKS = {
|
|
|
188
190
|
canTransition: canTransitionMock,
|
|
189
191
|
getAvailableTransitions: getAvailableTransitionsMock,
|
|
190
192
|
getSmartGridLayout: mockGetSmartGridLayout,
|
|
191
|
-
saveSmartGridLayout: mockSaveSmartGridLayout
|
|
193
|
+
saveSmartGridLayout: mockSaveSmartGridLayout,
|
|
194
|
+
sendEmail: mockSendEmail,
|
|
195
|
+
sendSms: mockSendSms
|
|
192
196
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout } from "../../index";
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms } from "../../index";
|
|
2
2
|
import type { OpenExtensionOverlay } from "../../actions/open-extension-overlay/types";
|
|
3
3
|
import type { ResolveExtensionOverlay } from "../../actions/resolve-extension-overlay/types";
|
|
4
4
|
export interface RenderProviderActions {
|
|
@@ -98,4 +98,6 @@ export interface RenderProviderActions {
|
|
|
98
98
|
getAvailableTransitions: GetAvailableTransitions;
|
|
99
99
|
getSmartGridLayout: GetSmartGridLayout;
|
|
100
100
|
saveSmartGridLayout: SaveSmartGridLayout;
|
|
101
|
+
sendEmail: SendEmail;
|
|
102
|
+
sendSms: SendSms;
|
|
101
103
|
}
|