@shopfront/bridge 1.8.0 → 1.11.0

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 (67) hide show
  1. package/.idea/embedded-bridge.iml +10 -0
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/README.md +3 -2
  6. package/lib/APIs/CurrentSale/Sale.d.ts +12 -0
  7. package/lib/APIs/CurrentSale/Sale.js +18 -0
  8. package/lib/APIs/CurrentSale/SaleProduct.d.ts +1 -1
  9. package/lib/APIs/CurrentSale/SaleProduct.js +1 -2
  10. package/lib/APIs/CurrentSale/ShopfrontSaleState.d.ts +1 -0
  11. package/lib/APIs/CurrentSale/index.js +5 -1
  12. package/lib/APIs/InternalMessages/InternalMessageSource.d.ts +1 -1
  13. package/lib/Actions/BaseAction.d.ts +13 -8
  14. package/lib/Actions/BaseAction.js +7 -6
  15. package/lib/Actions/Button.js +0 -1
  16. package/lib/Actions/Redirect.js +0 -2
  17. package/lib/Actions/SaleKey.js +0 -1
  18. package/lib/Actions/SaleUpdate.d.ts +5 -2
  19. package/lib/Actions/SaleUpdate.js +0 -1
  20. package/lib/Actions/Toast.d.ts +1 -2
  21. package/lib/Application.d.ts +26 -7
  22. package/lib/Application.js +87 -10
  23. package/lib/ApplicationEvents.d.ts +42 -6
  24. package/lib/ApplicationEvents.js +6 -4
  25. package/lib/Bridge.d.ts +1 -1
  26. package/lib/Bridge.js +6 -2
  27. package/lib/Common/EventEmitter.d.ts +4 -3
  28. package/lib/Common/Serializable.d.ts +1 -1
  29. package/lib/EmitableEvents/SellScreenPromotionApplicable.d.ts +13 -0
  30. package/lib/EmitableEvents/SellScreenPromotionApplicable.js +19 -0
  31. package/lib/Events/BaseEvent.d.ts +5 -4
  32. package/lib/Events/BaseEvent.js +1 -0
  33. package/lib/Events/Callback.d.ts +1 -1
  34. package/lib/Events/Callback.js +2 -2
  35. package/lib/Events/FormatIntegratedProduct.d.ts +14 -3
  36. package/lib/Events/FormatIntegratedProduct.js +1 -1
  37. package/lib/Events/InternalPageMessage.d.ts +4 -8
  38. package/lib/Events/InternalPageMessage.js +1 -1
  39. package/lib/Events/PaymentMethodsEnabled.d.ts +15 -0
  40. package/lib/Events/PaymentMethodsEnabled.js +21 -0
  41. package/lib/Events/Ready.d.ts +2 -2
  42. package/lib/Events/Ready.js +1 -1
  43. package/lib/Events/RegisterChanged.js +1 -1
  44. package/lib/Events/RequestButtons.d.ts +7 -2
  45. package/lib/Events/RequestButtons.js +2 -2
  46. package/lib/Events/RequestCustomerListOptions.d.ts +3 -2
  47. package/lib/Events/RequestCustomerListOptions.js +3 -2
  48. package/lib/Events/RequestSaleKeys.d.ts +2 -1
  49. package/lib/Events/RequestSaleKeys.js +2 -2
  50. package/lib/Events/RequestSellScreenOptions.d.ts +3 -2
  51. package/lib/Events/RequestSellScreenOptions.js +3 -2
  52. package/lib/Events/RequestSettings.d.ts +3 -2
  53. package/lib/Events/RequestSettings.js +3 -2
  54. package/lib/Events/RequestTableColumns.d.ts +6 -2
  55. package/lib/Events/RequestTableColumns.js +1 -1
  56. package/lib/Events/SaleComplete.d.ts +1 -1
  57. package/lib/Events/SaleComplete.js +1 -1
  58. package/lib/Events/UIPipeline.d.ts +15 -0
  59. package/lib/Events/UIPipeline.js +31 -0
  60. package/lib/Utilities/ActionEventRegistrar.d.ts +3 -3
  61. package/lib/Utilities/MiscTypes.d.ts +3 -0
  62. package/lib/Utilities/Static.js +2 -0
  63. package/lib/index.d.ts +2 -1
  64. package/lib/index.js +8 -2
  65. package/package.json +31 -27
  66. package/bitbucket-pipelines.yml +0 -22
  67. package/yarn.lock +0 -8
@@ -15,6 +15,8 @@ import { RequestCustomerListOptions, SellScreenCustomerListOption } from "./Even
15
15
  import { SaleKey } from "./Actions/SaleKey";
16
16
  import { RequestSaleKeys } from "./Events/RequestSaleKeys";
17
17
  import { CompletedSale, SaleComplete } from "./Events/SaleComplete";
18
+ import { UIPipeline } from "./Events/UIPipeline";
19
+ import { PaymentMethodsEnabled } from "./Events/PaymentMethodsEnabled";
18
20
  export declare enum ToShopfront {
19
21
  READY = "READY",
20
22
  SERIALIZED = "SERIALIZED",
@@ -33,11 +35,14 @@ export declare enum ToShopfront {
33
35
  RESPONSE_CUSTOMER_LIST_OPTIONS = "RESPONSE_CUSTOMER_LIST_OPTIONS",
34
36
  RESPONSE_SALE_KEYS = "RESPONSE_SALE_KEYS",
35
37
  PRINT_RECEIPT = "PRINT_RECEIPT",
38
+ REDIRECT = "REDIRECT",
39
+ GET_OPTION = "GET_OPTION",
40
+ RESPONSE_UI_PIPELINE = "RESPONSE_UI_PIPELINE",
36
41
  SELL_SCREEN_OPTION_CHANGE = "SELL_SCREEN_OPTION_CHANGE",
37
42
  INTERNAL_PAGE_MESSAGE = "INTERNAL_PAGE_MESSAGE",
38
- TABLE_UPDATE = "TABLE_UPDATE"
39
- }
40
- export declare enum WithinApplication {
43
+ TABLE_UPDATE = "TABLE_UPDATE",
44
+ PIPELINE_TRIGGER = "PIPELINE_TRIGGER",
45
+ SELL_SCREEN_PROMOTION_APPLICABLE = "SELL_SCREEN_PROMOTION_APPLICABLE"
41
46
  }
42
47
  export interface FromShopfrontReturns {
43
48
  READY: void;
@@ -78,11 +83,13 @@ export interface FromShopfrontReturns {
78
83
  REQUEST_CUSTOMER_LIST_OPTIONS: Array<SellScreenCustomerListOption>;
79
84
  REQUEST_SALE_KEYS: Array<SaleKey>;
80
85
  SALE_COMPLETE: void;
86
+ UI_PIPELINE: Array<UIPipelineResponse>;
87
+ PAYMENT_METHODS_ENABLED: Array<SellScreenPaymentMethod>;
81
88
  }
82
89
  export interface InternalPageMessageEvent {
83
90
  method: "REQUEST_SETTINGS" | "REQUEST_SELL_SCREEN_OPTIONS" | "EXTERNAL_APPLICATION";
84
91
  url: string;
85
- message: any;
92
+ message: unknown;
86
93
  reference: InternalMessageSource;
87
94
  }
88
95
  export interface RegisterChangedEvent {
@@ -96,6 +103,30 @@ export interface FormatIntegratedProductEvent {
96
103
  export interface SaleCompletedEvent {
97
104
  sale: CompletedSale;
98
105
  }
106
+ export declare type UIPipelineResponse = {
107
+ name: string;
108
+ content: string;
109
+ };
110
+ export interface UIPipelineBaseContext {
111
+ location: string;
112
+ }
113
+ export interface UIPipelineContext extends UIPipelineBaseContext {
114
+ trigger?: () => void;
115
+ }
116
+ export interface SellScreenPaymentMethod {
117
+ uuid: string;
118
+ name: string;
119
+ type: "global" | "cash" | "eftpos" | "giftcard" | "voucher" | "cheque" | "pc-eftpos" | "linkly-vaa" | "direct-deposit" | "tyro" | "custom";
120
+ default_pay_exact: boolean;
121
+ background_colour?: string;
122
+ text_colour?: string;
123
+ }
124
+ export interface PaymentMethodEnabledContext {
125
+ register: string;
126
+ customer: false | {
127
+ uuid: string;
128
+ };
129
+ }
99
130
  export interface FromShopfrontCallbacks {
100
131
  READY: (event: RegisterChangedEvent) => MaybePromise<FromShopfrontReturns["READY"]>;
101
132
  REQUEST_SETTINGS: () => MaybePromise<FromShopfrontReturns["REQUEST_SETTINGS"]>;
@@ -109,6 +140,8 @@ export interface FromShopfrontCallbacks {
109
140
  REQUEST_CUSTOMER_LIST_OPTIONS: () => MaybePromise<FromShopfrontReturns["REQUEST_CUSTOMER_LIST_OPTIONS"]>;
110
141
  REQUEST_SALE_KEYS: () => MaybePromise<FromShopfrontReturns["REQUEST_SALE_KEYS"]>;
111
142
  SALE_COMPLETE: (event: SaleCompletedEvent) => MaybePromise<FromShopfrontReturns["SALE_COMPLETE"]>;
143
+ UI_PIPELINE: (event: Array<UIPipelineResponse>, context: UIPipelineContext) => MaybePromise<FromShopfrontReturns["UI_PIPELINE"]>;
144
+ PAYMENT_METHODS_ENABLED: (event: Array<SellScreenPaymentMethod>, context: PaymentMethodEnabledContext) => MaybePromise<FromShopfrontReturns["PAYMENT_METHODS_ENABLED"]>;
112
145
  }
113
146
  export interface FromShopfront {
114
147
  READY: Ready;
@@ -116,13 +149,15 @@ export interface FromShopfront {
116
149
  REQUEST_BUTTONS: RequestButtons;
117
150
  REQUEST_TABLE_COLUMNS: RequestTableColumns;
118
151
  REQUEST_SELL_SCREEN_OPTIONS: RequestSellScreenOptions;
152
+ CALLBACK: Callback;
119
153
  INTERNAL_PAGE_MESSAGE: InternalPageMessage;
120
154
  REGISTER_CHANGED: RegisterChanged;
121
- CALLBACK: Callback;
122
155
  FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProduct;
123
156
  REQUEST_CUSTOMER_LIST_OPTIONS: RequestCustomerListOptions;
124
- REQUEST_SALE_KEYS: RequestSaleKeys;
125
157
  SALE_COMPLETE: SaleComplete;
158
+ REQUEST_SALE_KEYS: RequestSaleKeys;
159
+ UI_PIPELINE: UIPipeline;
160
+ PAYMENT_METHODS_ENABLED: PaymentMethodsEnabled;
126
161
  }
127
162
  export declare const directShopfrontEvents: readonly ["SALE_ADD_PRODUCT", "SALE_REMOVE_PRODUCT", "SALE_UPDATE_PRODUCTS", "SALE_CHANGE_QUANTITY", "SALE_ADD_CUSTOMER", "SALE_REMOVE_CUSTOMER", "SALE_CLEAR"];
128
163
  export declare type DirectShopfrontEvent = typeof directShopfrontEvents[number];
@@ -132,4 +167,5 @@ export interface FromShopfrontInternal {
132
167
  RESPONSE_CURRENT_SALE: "RESPONSE_CURRENT_SALE";
133
168
  RESPONSE_DATABASE_REQUEST: "RESPONSE_DATABASE_REQUEST";
134
169
  RESPONSE_LOCATION: "RESPONSE_LOCATION";
170
+ RESPONSE_OPTION: "RESPONSE_OPTION";
135
171
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.directShopfrontEvents = exports.WithinApplication = exports.ToShopfront = void 0;
3
+ exports.directShopfrontEvents = exports.ToShopfront = void 0;
4
4
  var ToShopfront;
5
5
  (function (ToShopfront) {
6
6
  ToShopfront["READY"] = "READY";
@@ -20,14 +20,16 @@ var ToShopfront;
20
20
  ToShopfront["RESPONSE_CUSTOMER_LIST_OPTIONS"] = "RESPONSE_CUSTOMER_LIST_OPTIONS";
21
21
  ToShopfront["RESPONSE_SALE_KEYS"] = "RESPONSE_SALE_KEYS";
22
22
  ToShopfront["PRINT_RECEIPT"] = "PRINT_RECEIPT";
23
+ ToShopfront["REDIRECT"] = "REDIRECT";
24
+ ToShopfront["GET_OPTION"] = "GET_OPTION";
25
+ ToShopfront["RESPONSE_UI_PIPELINE"] = "RESPONSE_UI_PIPELINE";
23
26
  // Emitable Events
24
27
  ToShopfront["SELL_SCREEN_OPTION_CHANGE"] = "SELL_SCREEN_OPTION_CHANGE";
25
28
  ToShopfront["INTERNAL_PAGE_MESSAGE"] = "INTERNAL_PAGE_MESSAGE";
26
29
  ToShopfront["TABLE_UPDATE"] = "TABLE_UPDATE";
30
+ ToShopfront["PIPELINE_TRIGGER"] = "PIPELINE_TRIGGER";
31
+ ToShopfront["SELL_SCREEN_PROMOTION_APPLICABLE"] = "SELL_SCREEN_PROMOTION_APPLICABLE";
27
32
  })(ToShopfront = exports.ToShopfront || (exports.ToShopfront = {}));
28
- var WithinApplication;
29
- (function (WithinApplication) {
30
- })(WithinApplication = exports.WithinApplication || (exports.WithinApplication = {}));
31
33
  exports.directShopfrontEvents = [
32
34
  "SALE_ADD_PRODUCT",
33
35
  "SALE_REMOVE_PRODUCT",
package/lib/Bridge.d.ts CHANGED
@@ -5,7 +5,7 @@ interface ApplicationOptions {
5
5
  vendor: string;
6
6
  }
7
7
  interface ApplicationEventListener {
8
- (event: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal, data: {}, id: string): void;
8
+ (event: keyof ApplicationEvents.FromShopfront | keyof ApplicationEvents.FromShopfrontInternal, data: Record<string, unknown>, id: string): void;
9
9
  }
10
10
  export declare class Bridge {
11
11
  static createApplication(options: ApplicationOptions): Application;
package/lib/Bridge.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -143,7 +147,7 @@ class Bridge {
143
147
  }
144
148
  }
145
149
  removeEventListener(listener) {
146
- let index = this.listeners.indexOf(listener);
150
+ const index = this.listeners.indexOf(listener);
147
151
  if (index === -1) {
148
152
  return;
149
153
  }
@@ -1,7 +1,8 @@
1
+ import { MaybePromise } from "../Utilities/MiscTypes";
1
2
  export declare class EventEmitter {
2
3
  protected supportedEvents: Array<string>;
3
4
  private listeners;
4
- addEventListener(event: string, callback: Function): void;
5
- removeEventListener(event: string, callback: Function): void;
6
- protected emit(event: string, ...args: any[]): Promise<Array<any>>;
5
+ addEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void;
6
+ removeEventListener(event: string, callback: (...args: Array<unknown>) => MaybePromise<unknown>): void;
7
+ protected emit(event: string, ...args: Array<unknown>): Promise<Array<unknown>>;
7
8
  }
@@ -1,5 +1,5 @@
1
1
  export interface Serialized<T> {
2
- properties: Array<any>;
2
+ properties: Array<unknown>;
3
3
  events: {
4
4
  [event: string]: Array<string>;
5
5
  };
@@ -0,0 +1,13 @@
1
+ import { BaseEmitableEvent } from "./BaseEmitableEvent";
2
+ export interface PromotionApplicableData {
3
+ enable: boolean;
4
+ key: string;
5
+ }
6
+ export declare class SellScreenPromotionApplicable extends BaseEmitableEvent<PromotionApplicableData> {
7
+ /**
8
+ * Enable or disable a set of already created "applicable" promotions
9
+ * @param key {string} The key to enable or disable, this supports wildcards using an asterisk
10
+ * @param enable {boolean} Whether the key should be enabled or disabled
11
+ */
12
+ constructor(key: string, enable: boolean);
13
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SellScreenPromotionApplicable = void 0;
4
+ const BaseEmitableEvent_1 = require("./BaseEmitableEvent");
5
+ const ApplicationEvents_1 = require("../ApplicationEvents");
6
+ class SellScreenPromotionApplicable extends BaseEmitableEvent_1.BaseEmitableEvent {
7
+ /**
8
+ * Enable or disable a set of already created "applicable" promotions
9
+ * @param key {string} The key to enable or disable, this supports wildcards using an asterisk
10
+ * @param enable {boolean} Whether the key should be enabled or disabled
11
+ */
12
+ constructor(key, enable) {
13
+ super(ApplicationEvents_1.ToShopfront.SELL_SCREEN_PROMOTION_APPLICABLE, {
14
+ key,
15
+ enable,
16
+ });
17
+ }
18
+ }
19
+ exports.SellScreenPromotionApplicable = SellScreenPromotionApplicable;
@@ -1,5 +1,6 @@
1
- export declare abstract class BaseEvent {
2
- protected callback: Function;
3
- protected constructor(callback: Function);
4
- abstract emit(data: object): Promise<any>;
1
+ import { Bridge } from "../Bridge";
2
+ export declare abstract class BaseEvent<TData = any, TCallbackReturn = void, TEmitReturn = any, TCallbackData = TData, TCallbackContext = undefined> {
3
+ protected callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn;
4
+ protected constructor(callback: (data: TCallbackData, context: TCallbackContext) => TCallbackReturn);
5
+ abstract emit(data: TData, bridge?: Bridge): Promise<TEmitReturn>;
5
6
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEvent = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
5
  class BaseEvent {
5
6
  constructor(callback) {
6
7
  this.callback = callback;
@@ -2,5 +2,5 @@ import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEven
2
2
  import { BaseEvent } from "./BaseEvent";
3
3
  export declare class Callback extends BaseEvent {
4
4
  constructor(callback: FromShopfrontCallbacks["CALLBACK"]);
5
- emit(data: {}): Promise<FromShopfrontReturns["CALLBACK"]>;
5
+ emit(): Promise<FromShopfrontReturns["CALLBACK"]>;
6
6
  }
@@ -6,8 +6,8 @@ class Callback extends BaseEvent_1.BaseEvent {
6
6
  constructor(callback) {
7
7
  super(callback);
8
8
  }
9
- async emit(data) {
10
- return this.callback();
9
+ async emit() {
10
+ return this.callback(undefined, undefined);
11
11
  }
12
12
  }
13
13
  exports.Callback = Callback;
@@ -1,6 +1,7 @@
1
1
  import { BaseEvent } from "./BaseEvent";
2
2
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
3
3
  import { Bridge } from "../Bridge";
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
4
5
  export declare type FormattedSaleProductType = "Normal" | "Product" | "GiftCard" | "Voucher" | "Basket" | "Package" | "Component" | "Integrated";
5
6
  export interface SaleGiftCard {
6
7
  code: string;
@@ -60,13 +61,23 @@ export interface FormattedSaleProduct {
60
61
  requestPrice?: boolean;
61
62
  lockQuantity: boolean;
62
63
  metaData: {
63
- [key: string]: any;
64
+ [key: string]: unknown;
64
65
  };
65
66
  }
66
- export declare class FormatIntegratedProduct extends BaseEvent {
67
+ export declare class FormatIntegratedProduct extends BaseEvent<{
68
+ data: {
69
+ product: FormattedSaleProduct;
70
+ };
71
+ context: Record<string, never>;
72
+ }, MaybePromise<FromShopfrontReturns["FORMAT_INTEGRATED_PRODUCT"]>, FromShopfrontReturns["FORMAT_INTEGRATED_PRODUCT"], {
73
+ product: FormattedSaleProduct;
74
+ }, Record<string, never>> {
67
75
  constructor(callback: FromShopfrontCallbacks["FORMAT_INTEGRATED_PRODUCT"]);
68
76
  emit(data: {
69
- product: FormattedSaleProduct;
77
+ data: {
78
+ product: FormattedSaleProduct;
79
+ };
80
+ context: Record<string, never>;
70
81
  }): Promise<FromShopfrontReturns["FORMAT_INTEGRATED_PRODUCT"]>;
71
82
  static respond(bridge: Bridge, data: Array<FromShopfrontReturns["FORMAT_INTEGRATED_PRODUCT"]>, id: string): Promise<void>;
72
83
  }
@@ -8,7 +8,7 @@ class FormatIntegratedProduct extends BaseEvent_1.BaseEvent {
8
8
  super(callback);
9
9
  }
10
10
  async emit(data) {
11
- const result = await Promise.resolve(this.callback(data));
11
+ const result = await this.callback(data.data, data.context);
12
12
  if (typeof result !== "object" || result === null) {
13
13
  throw new TypeError("Callback must return an object");
14
14
  }
@@ -1,14 +1,10 @@
1
1
  import { BaseEvent } from "./BaseEvent";
2
- import { FromShopfront, FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
+ import { FromShopfront, FromShopfrontCallbacks, FromShopfrontReturns, InternalPageMessageEvent } from "../ApplicationEvents";
3
3
  import { InternalMessageSource } from "../APIs/InternalMessages/InternalMessageSource";
4
4
  import { Application } from "../Application";
5
- export declare class InternalPageMessage extends BaseEvent {
5
+ export declare class InternalPageMessage extends BaseEvent<InternalPageMessageEvent> {
6
6
  protected application: Application;
7
7
  constructor(callback: FromShopfrontCallbacks["INTERNAL_PAGE_MESSAGE"], application: Application);
8
- protected createReference(method: keyof FromShopfront, url: string): InternalMessageSource;
9
- emit(data: {
10
- method: keyof FromShopfront;
11
- url: string;
12
- message: any;
13
- }): Promise<FromShopfrontReturns["INTERNAL_PAGE_MESSAGE"]>;
8
+ protected createReference(method: keyof FromShopfront | "EXTERNAL_APPLICATION", url: string): InternalMessageSource;
9
+ emit(data: InternalPageMessageEvent): Promise<FromShopfrontReturns["INTERNAL_PAGE_MESSAGE"]>;
14
10
  }
@@ -17,7 +17,7 @@ class InternalPageMessage extends BaseEvent_1.BaseEvent {
17
17
  url: data.url,
18
18
  message: data.message,
19
19
  reference: this.createReference(data.method, data.url)
20
- });
20
+ }, undefined);
21
21
  }
22
22
  }
23
23
  exports.InternalPageMessage = InternalPageMessage;
@@ -0,0 +1,15 @@
1
+ import { BaseEvent } from "./BaseEvent";
2
+ import { FromShopfrontCallbacks, FromShopfrontReturns, PaymentMethodEnabledContext, SellScreenPaymentMethod } from "../ApplicationEvents";
3
+ import { Bridge } from "../Bridge";
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
5
+ export declare class PaymentMethodsEnabled extends BaseEvent<{
6
+ data: Array<SellScreenPaymentMethod>;
7
+ context: PaymentMethodEnabledContext;
8
+ }, MaybePromise<FromShopfrontReturns["PAYMENT_METHODS_ENABLED"]>, FromShopfrontReturns["PAYMENT_METHODS_ENABLED"], Array<SellScreenPaymentMethod>, PaymentMethodEnabledContext> {
9
+ constructor(callback: FromShopfrontCallbacks["PAYMENT_METHODS_ENABLED"]);
10
+ emit(data: {
11
+ data: Array<SellScreenPaymentMethod>;
12
+ context: PaymentMethodEnabledContext;
13
+ }): Promise<FromShopfrontReturns["PAYMENT_METHODS_ENABLED"]>;
14
+ static respond(bridge: Bridge, data: FromShopfrontReturns["PAYMENT_METHODS_ENABLED"], id: string): Promise<void>;
15
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentMethodsEnabled = void 0;
4
+ const BaseEvent_1 = require("./BaseEvent");
5
+ const ApplicationEvents_1 = require("../ApplicationEvents");
6
+ class PaymentMethodsEnabled extends BaseEvent_1.BaseEvent {
7
+ constructor(callback) {
8
+ super(callback);
9
+ }
10
+ async emit(data) {
11
+ const result = await this.callback(data.data, data.context);
12
+ if (typeof result !== "object" || result === null) {
13
+ throw new TypeError("Callback must return an object");
14
+ }
15
+ return result;
16
+ }
17
+ static async respond(bridge, data, id) {
18
+ bridge.sendMessage(ApplicationEvents_1.ToShopfront.RESPONSE_UI_PIPELINE, data, id);
19
+ }
20
+ }
21
+ exports.PaymentMethodsEnabled = PaymentMethodsEnabled;
@@ -1,6 +1,6 @@
1
- import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
1
+ import { FromShopfrontCallbacks, FromShopfrontReturns, RegisterChangedEvent } from "../ApplicationEvents";
2
2
  import { BaseEvent } from "./BaseEvent";
3
- export declare class Ready extends BaseEvent {
3
+ export declare class Ready extends BaseEvent<RegisterChangedEvent> {
4
4
  constructor(callback: FromShopfrontCallbacks["READY"]);
5
5
  emit(data: {
6
6
  outlet: string | null;
@@ -11,7 +11,7 @@ class Ready extends BaseEvent_1.BaseEvent {
11
11
  outlet: data.outlet,
12
12
  register: data.register,
13
13
  user: data.user,
14
- });
14
+ }, undefined);
15
15
  }
16
16
  }
17
17
  exports.Ready = Ready;
@@ -7,7 +7,7 @@ class RegisterChanged extends BaseEvent_1.BaseEvent {
7
7
  super(callback);
8
8
  }
9
9
  async emit(data) {
10
- this.callback(data);
10
+ this.callback(data, undefined);
11
11
  }
12
12
  }
13
13
  exports.RegisterChanged = RegisterChanged;
@@ -1,12 +1,17 @@
1
1
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
2
  import { Bridge, Button } from "..";
3
3
  import { BaseEvent } from "./BaseEvent";
4
- export declare class RequestButtons extends BaseEvent {
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
5
+ export declare class RequestButtons extends BaseEvent<{
6
+ location: string;
7
+ id: string;
8
+ context: unknown;
9
+ }, MaybePromise<FromShopfrontReturns["REQUEST_BUTTONS"]>, MaybePromise<FromShopfrontReturns["REQUEST_BUTTONS"]>, string, unknown> {
5
10
  constructor(callback: FromShopfrontCallbacks["REQUEST_BUTTONS"]);
6
11
  emit(data: {
7
12
  location: string;
8
13
  id: string;
9
- context: any;
14
+ context: unknown;
10
15
  }): Promise<FromShopfrontReturns["REQUEST_BUTTONS"]>;
11
16
  static respond(bridge: Bridge, buttons: Array<Button>, id: string): Promise<void>;
12
17
  }
@@ -9,7 +9,7 @@ class RequestButtons extends BaseEvent_1.BaseEvent {
9
9
  super(callback);
10
10
  }
11
11
  async emit(data) {
12
- let result = await Promise.resolve(this.callback(data.location, data.context));
12
+ let result = await this.callback(data.location, data.context);
13
13
  if (!Array.isArray(result)) {
14
14
  result = [result];
15
15
  }
@@ -21,7 +21,7 @@ class RequestButtons extends BaseEvent_1.BaseEvent {
21
21
  return result;
22
22
  }
23
23
  static async respond(bridge, buttons, id) {
24
- let response = [];
24
+ const response = [];
25
25
  for (let i = 0, l = buttons.length; i < l; i++) {
26
26
  if (!(buttons[i] instanceof __1.Button)) {
27
27
  throw new TypeError("Invalid response returned, expected button");
@@ -1,12 +1,13 @@
1
1
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
2
  import { Bridge } from "..";
3
3
  import { BaseEvent } from "./BaseEvent";
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
4
5
  export interface SellScreenCustomerListOption {
5
6
  contents: string;
6
7
  onClick: () => void;
7
8
  }
8
- export declare class RequestCustomerListOptions extends BaseEvent {
9
+ export declare class RequestCustomerListOptions extends BaseEvent<Record<string, unknown>, MaybePromise<FromShopfrontReturns["REQUEST_CUSTOMER_LIST_OPTIONS"]>, FromShopfrontReturns["REQUEST_CUSTOMER_LIST_OPTIONS"], undefined> {
9
10
  constructor(callback: FromShopfrontCallbacks["REQUEST_CUSTOMER_LIST_OPTIONS"]);
10
- emit(data: {}): Promise<FromShopfrontReturns["REQUEST_CUSTOMER_LIST_OPTIONS"]>;
11
+ emit(_: Record<string, unknown>): Promise<FromShopfrontReturns["REQUEST_CUSTOMER_LIST_OPTIONS"]>;
11
12
  static respond(bridge: Bridge, options: Array<SellScreenCustomerListOption>, id: string): Promise<void>;
12
13
  }
@@ -8,8 +8,9 @@ class RequestCustomerListOptions extends BaseEvent_1.BaseEvent {
8
8
  constructor(callback) {
9
9
  super(callback);
10
10
  }
11
- async emit(data) {
12
- let result = await Promise.resolve(this.callback());
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ async emit(_) {
13
+ let result = await this.callback(undefined, undefined);
13
14
  if (!Array.isArray(result)) {
14
15
  result = [result];
15
16
  }
@@ -2,7 +2,8 @@ import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEven
2
2
  import { Bridge } from "..";
3
3
  import { BaseEvent } from "./BaseEvent";
4
4
  import { SaleKey } from "../Actions/SaleKey";
5
- export declare class RequestSaleKeys extends BaseEvent {
5
+ import { MaybePromise } from "../Utilities/MiscTypes";
6
+ export declare class RequestSaleKeys extends BaseEvent<undefined, MaybePromise<Array<SaleKey>>, Array<SaleKey>> {
6
7
  constructor(callback: FromShopfrontCallbacks["REQUEST_SALE_KEYS"]);
7
8
  emit(): Promise<FromShopfrontReturns["REQUEST_SALE_KEYS"]>;
8
9
  static respond(bridge: Bridge, keys: Array<SaleKey>, id: string): Promise<void>;
@@ -9,7 +9,7 @@ class RequestSaleKeys extends BaseEvent_1.BaseEvent {
9
9
  super(callback);
10
10
  }
11
11
  async emit() {
12
- let result = await Promise.resolve(this.callback());
12
+ let result = await this.callback(undefined, undefined);
13
13
  if (!Array.isArray(result)) {
14
14
  result = [result];
15
15
  }
@@ -21,7 +21,7 @@ class RequestSaleKeys extends BaseEvent_1.BaseEvent {
21
21
  return result;
22
22
  }
23
23
  static async respond(bridge, keys, id) {
24
- let response = [];
24
+ const response = [];
25
25
  for (let i = 0, l = keys.length; i < l; i++) {
26
26
  if (!(keys[i] instanceof SaleKey_1.SaleKey)) {
27
27
  throw new TypeError("Invalid response returned, expected SaleKey");
@@ -1,15 +1,16 @@
1
1
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
2
  import { Bridge } from "..";
3
3
  import { BaseEvent } from "./BaseEvent";
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
4
5
  export interface SellScreenOption {
5
6
  url: string;
6
7
  title: string;
7
8
  id?: string;
8
9
  }
9
- export declare class RequestSellScreenOptions extends BaseEvent {
10
+ export declare class RequestSellScreenOptions extends BaseEvent<undefined, MaybePromise<FromShopfrontReturns["REQUEST_SELL_SCREEN_OPTIONS"]>, FromShopfrontReturns["REQUEST_SELL_SCREEN_OPTIONS"]> {
10
11
  constructor(callback: FromShopfrontCallbacks["REQUEST_SELL_SCREEN_OPTIONS"]);
11
12
  static getOptionId(url: string): string;
12
13
  static validateURL(url: string): void;
13
- emit(data: {}): Promise<FromShopfrontReturns["REQUEST_SELL_SCREEN_OPTIONS"]>;
14
+ emit(_: never): Promise<FromShopfrontReturns["REQUEST_SELL_SCREEN_OPTIONS"]>;
14
15
  static respond(bridge: Bridge, options: Array<SellScreenOption>, id: string): Promise<void>;
15
16
  }
@@ -22,8 +22,9 @@ class RequestSellScreenOptions extends BaseEvent_1.BaseEvent {
22
22
  throw new TypeError(`The URL "${url}" is invalid, please ensure that you're using the HTTPS protocol`);
23
23
  }
24
24
  }
25
- async emit(data) {
26
- let result = await Promise.resolve(this.callback());
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ async emit(_) {
27
+ let result = await this.callback(undefined, undefined);
27
28
  if (!Array.isArray(result)) {
28
29
  result = [result];
29
30
  }
@@ -1,8 +1,9 @@
1
1
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
2
  import { BaseEvent } from "./BaseEvent";
3
3
  import { Bridge } from "../Bridge";
4
- export declare class RequestSettings extends BaseEvent {
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
5
+ export declare class RequestSettings extends BaseEvent<undefined, MaybePromise<FromShopfrontReturns["REQUEST_SETTINGS"]>, FromShopfrontReturns["REQUEST_SETTINGS"]> {
5
6
  constructor(callback: FromShopfrontCallbacks["REQUEST_SETTINGS"]);
6
- emit(data: {}): Promise<FromShopfrontReturns["REQUEST_SETTINGS"]>;
7
+ emit(_: never): Promise<FromShopfrontReturns["REQUEST_SETTINGS"]>;
7
8
  static respond(bridge: Bridge, settings: Array<FromShopfrontReturns["REQUEST_SETTINGS"]>, id: string): Promise<void>;
8
9
  }
@@ -7,8 +7,9 @@ class RequestSettings extends BaseEvent_1.BaseEvent {
7
7
  constructor(callback) {
8
8
  super(callback);
9
9
  }
10
- async emit(data) {
11
- const result = await Promise.resolve(this.callback());
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+ async emit(_) {
12
+ const result = await this.callback(undefined, undefined);
12
13
  if (typeof result !== "object" || result === null) {
13
14
  throw new TypeError("Callback must return an object");
14
15
  }
@@ -1,11 +1,15 @@
1
1
  import { FromShopfrontCallbacks, FromShopfrontReturns } from "../ApplicationEvents";
2
2
  import { BaseEvent } from "./BaseEvent";
3
3
  import { Bridge } from "../Bridge";
4
- export declare class RequestTableColumns extends BaseEvent {
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
5
+ export declare class RequestTableColumns extends BaseEvent<{
6
+ location: string;
7
+ context: unknown;
8
+ }, MaybePromise<FromShopfrontReturns["REQUEST_TABLE_COLUMNS"]>, FromShopfrontReturns["REQUEST_TABLE_COLUMNS"], string, unknown> {
5
9
  constructor(callback: FromShopfrontCallbacks["REQUEST_TABLE_COLUMNS"]);
6
10
  emit(data: {
7
11
  location: string;
8
- context: any;
12
+ context: unknown;
9
13
  }): Promise<FromShopfrontReturns["REQUEST_TABLE_COLUMNS"]>;
10
14
  static respond(bridge: Bridge, columns: Array<FromShopfrontReturns["REQUEST_TABLE_COLUMNS"]>, id: string): Promise<void>;
11
15
  }
@@ -8,7 +8,7 @@ class RequestTableColumns extends BaseEvent_1.BaseEvent {
8
8
  super(callback);
9
9
  }
10
10
  async emit(data) {
11
- const result = await Promise.resolve(this.callback(data.location, data.context));
11
+ const result = await this.callback(data.location, data.context);
12
12
  if (typeof result !== "object") {
13
13
  throw new TypeError("Callback must return an object");
14
14
  }
@@ -57,7 +57,7 @@ interface CompletedSaleProduct {
57
57
  requestPrice?: boolean;
58
58
  lockQuantity: boolean;
59
59
  metaData: {
60
- [key: string]: any;
60
+ [key: string]: unknown;
61
61
  };
62
62
  }
63
63
  interface CompletedSalePayment {
@@ -7,7 +7,7 @@ class SaleComplete extends BaseEvent_1.BaseEvent {
7
7
  super(callback);
8
8
  }
9
9
  async emit(data) {
10
- this.callback(data);
10
+ this.callback(data, undefined);
11
11
  }
12
12
  }
13
13
  exports.SaleComplete = SaleComplete;
@@ -0,0 +1,15 @@
1
+ import { BaseEvent } from "./BaseEvent";
2
+ import { FromShopfrontCallbacks, FromShopfrontReturns, UIPipelineBaseContext, UIPipelineContext, UIPipelineResponse } from "../ApplicationEvents";
3
+ import { Bridge } from "../Bridge";
4
+ import { MaybePromise } from "../Utilities/MiscTypes";
5
+ interface UIPPipelineIncomingData {
6
+ data: Array<UIPipelineResponse>;
7
+ context: UIPipelineBaseContext;
8
+ pipelineId?: string;
9
+ }
10
+ export declare class UIPipeline extends BaseEvent<UIPPipelineIncomingData, MaybePromise<FromShopfrontReturns["UI_PIPELINE"]>, FromShopfrontReturns["UI_PIPELINE"], Array<UIPipelineResponse>, UIPipelineContext> {
11
+ constructor(callback: FromShopfrontCallbacks["UI_PIPELINE"]);
12
+ emit(data: UIPPipelineIncomingData, bridge: Bridge): Promise<FromShopfrontReturns["UI_PIPELINE"]>;
13
+ static respond(bridge: Bridge, data: FromShopfrontReturns["UI_PIPELINE"], id: string): Promise<void>;
14
+ }
15
+ export {};