@shopfront/bridge 1.20.3 → 1.20.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/.github/workflows/npm-publish.yml +29 -0
- package/.idea/modules.xml +1 -1
- package/.idea/php.xml +1 -0
- package/.idea/{embedded-bridge.iml → shopfront-embedded-bridge.iml} +1 -3
- package/.idea/vcs.xml +1 -1
- package/lib/Application.js +12 -0
- package/lib/ApplicationEvents.d.ts +12 -0
- package/lib/ApplicationEvents.js +1 -0
- package/lib/Events/CheckGiftCardCollision.d.ts +14 -0
- package/lib/Events/CheckGiftCardCollision.js +25 -0
- package/lib/Events/GiftCardCodeCheck.d.ts +14 -0
- package/lib/Events/GiftCardCodeCheck.js +21 -0
- package/package.json +3 -3
- package/.idea/misc.xml +0 -6
- package/lib/APIs/CurrentSale/Exceptions.d.ts +0 -6
- package/lib/APIs/CurrentSale/Exceptions.js +0 -15
- package/lib/APIs/CurrentSale/Sale.d.ts +0 -182
- package/lib/APIs/CurrentSale/Sale.js +0 -290
- package/lib/APIs/CurrentSale/SaleCustomer.d.ts +0 -10
- package/lib/APIs/CurrentSale/SaleCustomer.js +0 -17
- package/lib/APIs/CurrentSale/SalePayment.d.ts +0 -68
- package/lib/APIs/CurrentSale/SalePayment.js +0 -99
- package/lib/APIs/CurrentSale/SaleProduct.d.ts +0 -121
- package/lib/APIs/CurrentSale/SaleProduct.js +0 -167
- package/lib/APIs/CurrentSale/ShopfrontSaleState.d.ts +0 -53
- package/lib/APIs/CurrentSale/ShopfrontSaleState.js +0 -2
- package/lib/APIs/CurrentSale/index.d.ts +0 -6
- package/lib/APIs/CurrentSale/index.js +0 -37
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SaleProduct = void 0;
|
|
4
|
-
class SaleProduct {
|
|
5
|
-
constructor(id, quantity, price, indexAddress) {
|
|
6
|
-
this.metaData = {};
|
|
7
|
-
this.id = id;
|
|
8
|
-
this.quantity = quantity;
|
|
9
|
-
this.price = price;
|
|
10
|
-
this.indexAddress = indexAddress || [];
|
|
11
|
-
this.contains = [];
|
|
12
|
-
this.edited = typeof price !== "undefined";
|
|
13
|
-
this.note = "";
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Hydrate a sale product from the SaleState.
|
|
17
|
-
*
|
|
18
|
-
* @internal
|
|
19
|
-
* @param {ShopfrontSaleProduct} product
|
|
20
|
-
* @param {Array<number>} indexAddress
|
|
21
|
-
* @returns {SaleProduct}
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
static HydrateFromState(product, indexAddress) {
|
|
25
|
-
const hydrated = new SaleProduct(product.uuid, product.quantity, product.prices.price, indexAddress);
|
|
26
|
-
hydrated.setInternal(product, indexAddress);
|
|
27
|
-
return hydrated;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Append a product to this product's list of contained products.
|
|
31
|
-
*
|
|
32
|
-
* @protected
|
|
33
|
-
* @param {SaleProduct} product
|
|
34
|
-
*/
|
|
35
|
-
appendProduct(product) {
|
|
36
|
-
this.contains.push(product);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Set the internal data for the product.
|
|
40
|
-
* This method is for hydration of the product from Shopfront, it's highly recommend that you DO NOT use this method.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
* @param {ShopfrontSaleProduct} data
|
|
44
|
-
* @param {Array<number>} indexAddress
|
|
45
|
-
*/
|
|
46
|
-
setInternal(data, indexAddress) {
|
|
47
|
-
this.name = data.name;
|
|
48
|
-
this.type = data.type;
|
|
49
|
-
this.taxRateAmount = data.tax?.amount || 0;
|
|
50
|
-
this.note = data.note;
|
|
51
|
-
this.edited = data.edited;
|
|
52
|
-
this.caseQuantity = data.caseQuantity;
|
|
53
|
-
this.metaData = data.metaData;
|
|
54
|
-
for (let i = 0, l = data.products.length; i < l; i++) {
|
|
55
|
-
this.appendProduct(SaleProduct.HydrateFromState(data.products[i], [
|
|
56
|
-
...indexAddress,
|
|
57
|
-
i,
|
|
58
|
-
]));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the ID of the product.
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
getId() {
|
|
66
|
-
return this.id;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get the current sale quantity of the product.
|
|
70
|
-
* @returns {number}
|
|
71
|
-
*/
|
|
72
|
-
getQuantity() {
|
|
73
|
-
return this.quantity;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the current price of the product.
|
|
77
|
-
* @returns {number | undefined}
|
|
78
|
-
*/
|
|
79
|
-
getPrice() {
|
|
80
|
-
return this.price;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get the index address of the product.
|
|
84
|
-
* This is the internal address of where the product is in the sale.
|
|
85
|
-
* (e.g. if the address is [1, 3] it's the fourth contained product in the second sale line).
|
|
86
|
-
*
|
|
87
|
-
* @returns {Array<number>}
|
|
88
|
-
*/
|
|
89
|
-
getIndexAddress() {
|
|
90
|
-
return this.indexAddress;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get the name of the product.
|
|
94
|
-
*
|
|
95
|
-
* @returns {string | undefined}
|
|
96
|
-
*/
|
|
97
|
-
getName() {
|
|
98
|
-
return this.name;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Get the type of product this product is.
|
|
102
|
-
*
|
|
103
|
-
* @returns {ShopfrontSaleProductType | undefined}
|
|
104
|
-
*/
|
|
105
|
-
getType() {
|
|
106
|
-
return this.type;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get the tax rate amount.
|
|
110
|
-
* This is the rate of the tax rate (e.g. 10 is a tax rate of 10%).
|
|
111
|
-
*
|
|
112
|
-
* @returns {number | undefined}
|
|
113
|
-
*/
|
|
114
|
-
getTaxRateAmount() {
|
|
115
|
-
return this.taxRateAmount;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Get the sale note attached to this product.
|
|
119
|
-
*
|
|
120
|
-
* @returns {string}
|
|
121
|
-
*/
|
|
122
|
-
getNote() {
|
|
123
|
-
return this.note;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the products this product contains.
|
|
127
|
-
*
|
|
128
|
-
* @returns {Array<SaleProduct>}
|
|
129
|
-
*/
|
|
130
|
-
getContains() {
|
|
131
|
-
return this.contains;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Get whether this product has been "edited".
|
|
135
|
-
* Typically, being edited just means that this product has been discounted.
|
|
136
|
-
*
|
|
137
|
-
* @returns {boolean}
|
|
138
|
-
*/
|
|
139
|
-
getEdited() {
|
|
140
|
-
return this.edited;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get the case quantity for this product.
|
|
144
|
-
*
|
|
145
|
-
* @returns {number | undefined}
|
|
146
|
-
*/
|
|
147
|
-
getCaseQuantity() {
|
|
148
|
-
return this.caseQuantity;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Get the meta data for the product.
|
|
152
|
-
*
|
|
153
|
-
* @returns {Record<string, unknown>}
|
|
154
|
-
*/
|
|
155
|
-
getMetaData() {
|
|
156
|
-
return this.metaData;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Set the metaData for a product
|
|
160
|
-
* @param key
|
|
161
|
-
* @param value
|
|
162
|
-
*/
|
|
163
|
-
setMetaData(key, value) {
|
|
164
|
-
this.metaData[key] = value;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.SaleProduct = SaleProduct;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export declare type ShopfrontSalePaymentStatus = "completed" | "cancelled" | "failed";
|
|
2
|
-
export declare type ShopfrontSaleProductType = "Normal" | "Basket" | "Package" | "Component" | "Voucher";
|
|
3
|
-
export interface ShopfrontSaleProduct {
|
|
4
|
-
uuid: string;
|
|
5
|
-
type: ShopfrontSaleProductType;
|
|
6
|
-
name: string;
|
|
7
|
-
quantity: number;
|
|
8
|
-
prices: {
|
|
9
|
-
price: number;
|
|
10
|
-
normal: number;
|
|
11
|
-
};
|
|
12
|
-
tax: null | {
|
|
13
|
-
id: string;
|
|
14
|
-
amount: number;
|
|
15
|
-
};
|
|
16
|
-
note: string;
|
|
17
|
-
products: Array<ShopfrontSaleProduct>;
|
|
18
|
-
edited: boolean;
|
|
19
|
-
caseQuantity: number;
|
|
20
|
-
metaData: Record<string, unknown>;
|
|
21
|
-
}
|
|
22
|
-
interface ShopfrontSaleCustomer {
|
|
23
|
-
uuid: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ShopfrontSalePayment {
|
|
26
|
-
method: string;
|
|
27
|
-
type: string;
|
|
28
|
-
status: ShopfrontSalePaymentStatus;
|
|
29
|
-
amount: number;
|
|
30
|
-
cashout: number;
|
|
31
|
-
rounding: number;
|
|
32
|
-
}
|
|
33
|
-
export interface ShopfrontSaleState {
|
|
34
|
-
products: Array<ShopfrontSaleProduct>;
|
|
35
|
-
customer: false | ShopfrontSaleCustomer;
|
|
36
|
-
payments: Array<ShopfrontSalePayment>;
|
|
37
|
-
notes: {
|
|
38
|
-
internal: string;
|
|
39
|
-
sale: string;
|
|
40
|
-
};
|
|
41
|
-
totals: {
|
|
42
|
-
sale: number;
|
|
43
|
-
paid: number;
|
|
44
|
-
savings: number;
|
|
45
|
-
discount: number;
|
|
46
|
-
};
|
|
47
|
-
linkedTo: string;
|
|
48
|
-
orderReference: string;
|
|
49
|
-
refundReason: string;
|
|
50
|
-
priceSet: string | null;
|
|
51
|
-
metaData: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Sale } from "./Sale";
|
|
2
|
-
export { SaleProduct } from "./SaleProduct";
|
|
3
|
-
export { SalePayment } from "./SalePayment";
|
|
4
|
-
export { SalePaymentStatus } from "./SalePayment";
|
|
5
|
-
export { SaleCustomer } from "./SaleCustomer";
|
|
6
|
-
export * as Exceptions from "./Exceptions";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = 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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Exceptions = exports.SaleCustomer = exports.SalePaymentStatus = exports.SalePayment = exports.SaleProduct = exports.Sale = void 0;
|
|
27
|
-
var Sale_1 = require("./Sale");
|
|
28
|
-
Object.defineProperty(exports, "Sale", { enumerable: true, get: function () { return Sale_1.Sale; } });
|
|
29
|
-
var SaleProduct_1 = require("./SaleProduct");
|
|
30
|
-
Object.defineProperty(exports, "SaleProduct", { enumerable: true, get: function () { return SaleProduct_1.SaleProduct; } });
|
|
31
|
-
var SalePayment_1 = require("./SalePayment");
|
|
32
|
-
Object.defineProperty(exports, "SalePayment", { enumerable: true, get: function () { return SalePayment_1.SalePayment; } });
|
|
33
|
-
var SalePayment_2 = require("./SalePayment");
|
|
34
|
-
Object.defineProperty(exports, "SalePaymentStatus", { enumerable: true, get: function () { return SalePayment_2.SalePaymentStatus; } });
|
|
35
|
-
var SaleCustomer_1 = require("./SaleCustomer");
|
|
36
|
-
Object.defineProperty(exports, "SaleCustomer", { enumerable: true, get: function () { return SaleCustomer_1.SaleCustomer; } });
|
|
37
|
-
exports.Exceptions = __importStar(require("./Exceptions"));
|