@shopfront/bridge 1.18.0 → 1.18.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/.idea/codeStyles/Project.xml +0 -111
- package/.idea/misc.xml +6 -0
- package/.idea/php.xml +18 -0
- package/.idea/shopfront-embedded-bridge.iml +1 -3
- package/lib/APIs/Sale/SalePayment.d.ts +7 -0
- package/lib/APIs/Sale/SalePayment.js +10 -0
- package/lib/APIs/Sale/ShopfrontSaleState.d.ts +1 -0
- package/lib/Application.d.ts +2 -1
- package/lib/Utilities/SaleCreate.d.ts +1 -0
- package/lib/Utilities/SaleCreate.js +1 -0
- package/package.json +1 -1
- package/lib/EmitableEvents/Fulfilment/OrderSaleCreate.d.ts +0 -8
- package/lib/EmitableEvents/Fulfilment/OrderSaleCreate.js +0 -14
- package/lib/EmitableEvents/SaleCreate.d.ts +0 -31
- package/lib/EmitableEvents/SaleCreate.js +0 -63
|
@@ -1,121 +1,10 @@
|
|
|
1
1
|
<component name="ProjectCodeStyleConfiguration">
|
|
2
2
|
<code_scheme name="Project" version="173">
|
|
3
|
-
<DB2CodeStyleSettings version="6">
|
|
4
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
5
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
6
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
7
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
8
|
-
</DB2CodeStyleSettings>
|
|
9
|
-
<DerbyCodeStyleSettings version="6">
|
|
10
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
11
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
12
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
13
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
14
|
-
</DerbyCodeStyleSettings>
|
|
15
|
-
<H2CodeStyleSettings version="6">
|
|
16
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
17
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
18
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
19
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
20
|
-
</H2CodeStyleSettings>
|
|
21
|
-
<H2CodeStyleSettings version="6">
|
|
22
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
23
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
24
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
25
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
26
|
-
</H2CodeStyleSettings>
|
|
27
|
-
<HSQLCodeStyleSettings version="6">
|
|
28
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
29
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
30
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
31
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
32
|
-
</HSQLCodeStyleSettings>
|
|
33
|
-
<HTMLCodeStyleSettings>
|
|
34
|
-
<option name="HTML_ATTRIBUTE_WRAP" value="4" />
|
|
35
|
-
<option name="HTML_NEWLINE_BEFORE_FIRST_ATTRIBUTE" value="When multiline" />
|
|
36
|
-
<option name="HTML_NEWLINE_AFTER_LAST_ATTRIBUTE" value="When multiline" />
|
|
37
|
-
</HTMLCodeStyleSettings>
|
|
38
3
|
<JSCodeStyleSettings version="0">
|
|
39
4
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
40
|
-
<option name="ALIGN_OBJECT_PROPERTIES" value="2" />
|
|
41
|
-
<option name="ALIGN_VAR_STATEMENTS" value="2" />
|
|
42
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
43
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
44
5
|
</JSCodeStyleSettings>
|
|
45
|
-
<MSSQLCodeStyleSettings version="6">
|
|
46
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
47
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
48
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
49
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
50
|
-
</MSSQLCodeStyleSettings>
|
|
51
|
-
<MySQLCodeStyleSettings version="6">
|
|
52
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
53
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
54
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
55
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
56
|
-
</MySQLCodeStyleSettings>
|
|
57
|
-
<OracleCodeStyleSettings version="6">
|
|
58
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
59
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
60
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
61
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
62
|
-
</OracleCodeStyleSettings>
|
|
63
|
-
<PostgresCodeStyleSettings version="6">
|
|
64
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
65
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
66
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
67
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
68
|
-
</PostgresCodeStyleSettings>
|
|
69
|
-
<SQLiteCodeStyleSettings version="6">
|
|
70
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
71
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
72
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
73
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
74
|
-
</SQLiteCodeStyleSettings>
|
|
75
|
-
<SqlCodeStyleSettings version="6">
|
|
76
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
77
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
78
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
79
|
-
</SqlCodeStyleSettings>
|
|
80
|
-
<SybaseCodeStyleSettings version="6">
|
|
81
|
-
<option name="USE_GENERAL_STYLE" value="false" />
|
|
82
|
-
<option name="KEYWORD_CASE" value="2" />
|
|
83
|
-
<option name="IDENTIFIER_CASE" value="1" />
|
|
84
|
-
<option name="FROM_INDENT_JOIN" value="false" />
|
|
85
|
-
</SybaseCodeStyleSettings>
|
|
86
6
|
<TypeScriptCodeStyleSettings version="0">
|
|
87
7
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
88
|
-
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
|
89
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
90
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
91
8
|
</TypeScriptCodeStyleSettings>
|
|
92
|
-
<codeStyleSettings language="CSS">
|
|
93
|
-
<indentOptions>
|
|
94
|
-
<option name="INDENT_SIZE" value="2" />
|
|
95
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
96
|
-
<option name="TAB_SIZE" value="2" />
|
|
97
|
-
</indentOptions>
|
|
98
|
-
</codeStyleSettings>
|
|
99
|
-
<codeStyleSettings language="HTML">
|
|
100
|
-
<indentOptions>
|
|
101
|
-
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
102
|
-
</indentOptions>
|
|
103
|
-
</codeStyleSettings>
|
|
104
|
-
<codeStyleSettings language="JavaScript">
|
|
105
|
-
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
|
106
|
-
</codeStyleSettings>
|
|
107
|
-
<codeStyleSettings language="PHP">
|
|
108
|
-
<option name="KEEP_LINE_BREAKS" value="false" />
|
|
109
|
-
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
|
110
|
-
<option name="CLASS_BRACE_STYLE" value="1" />
|
|
111
|
-
<option name="METHOD_BRACE_STYLE" value="1" />
|
|
112
|
-
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
|
113
|
-
</codeStyleSettings>
|
|
114
|
-
<codeStyleSettings language="SCSS">
|
|
115
|
-
<indentOptions>
|
|
116
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
117
|
-
<option name="TAB_SIZE" value="2" />
|
|
118
|
-
</indentOptions>
|
|
119
|
-
</codeStyleSettings>
|
|
120
9
|
</code_scheme>
|
|
121
10
|
</component>
|
package/.idea/misc.xml
ADDED
package/.idea/php.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="MessDetectorOptionsConfiguration">
|
|
4
|
+
<option name="transferred" value="true" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="PHPCSFixerOptionsConfiguration">
|
|
7
|
+
<option name="transferred" value="true" />
|
|
8
|
+
</component>
|
|
9
|
+
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
10
|
+
<option name="transferred" value="true" />
|
|
11
|
+
</component>
|
|
12
|
+
<component name="PhpStanOptionsConfiguration">
|
|
13
|
+
<option name="transferred" value="true" />
|
|
14
|
+
</component>
|
|
15
|
+
<component name="PsalmOptionsConfiguration">
|
|
16
|
+
<option name="transferred" value="true" />
|
|
17
|
+
</component>
|
|
18
|
+
</project>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
|
3
3
|
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$"
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/lib" />
|
|
6
|
-
</content>
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
7
5
|
<orderEntry type="inheritedJdk" />
|
|
8
6
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
9
7
|
</component>
|
|
@@ -12,6 +12,7 @@ export declare class SalePayment {
|
|
|
12
12
|
protected amount: number;
|
|
13
13
|
protected cashout?: number;
|
|
14
14
|
protected rounding?: number;
|
|
15
|
+
protected metaData: Record<string, unknown>;
|
|
15
16
|
constructor(id: string, amount: number, cashout?: number, status?: SalePaymentStatus);
|
|
16
17
|
/**
|
|
17
18
|
* Hydrate a sale payment from the SaleState.
|
|
@@ -66,4 +67,10 @@ export declare class SalePayment {
|
|
|
66
67
|
* @returns {number | undefined}
|
|
67
68
|
*/
|
|
68
69
|
getRounding(): number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get the metadata attached to this payment method
|
|
72
|
+
*
|
|
73
|
+
* @returns {Record<string, unknown>}
|
|
74
|
+
*/
|
|
75
|
+
getMetaData(): Record<string, unknown>;
|
|
69
76
|
}
|
|
@@ -13,6 +13,7 @@ var SalePaymentStatus;
|
|
|
13
13
|
})(SalePaymentStatus = exports.SalePaymentStatus || (exports.SalePaymentStatus = {}));
|
|
14
14
|
class SalePayment {
|
|
15
15
|
constructor(id, amount, cashout, status) {
|
|
16
|
+
this.metaData = {};
|
|
16
17
|
this.internalId = UUID_1.default.generate();
|
|
17
18
|
this.id = id;
|
|
18
19
|
this.amount = amount;
|
|
@@ -51,6 +52,7 @@ class SalePayment {
|
|
|
51
52
|
setInternal(data) {
|
|
52
53
|
this.type = data.type;
|
|
53
54
|
this.rounding = data.rounding;
|
|
55
|
+
this.metaData = JSON.parse(data.metadata);
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Get the ID of the sale payment method.
|
|
@@ -100,5 +102,13 @@ class SalePayment {
|
|
|
100
102
|
getRounding() {
|
|
101
103
|
return this.rounding;
|
|
102
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the metadata attached to this payment method
|
|
107
|
+
*
|
|
108
|
+
* @returns {Record<string, unknown>}
|
|
109
|
+
*/
|
|
110
|
+
getMetaData() {
|
|
111
|
+
return this.metaData;
|
|
112
|
+
}
|
|
103
113
|
}
|
|
104
114
|
exports.SalePayment = SalePayment;
|
package/lib/Application.d.ts
CHANGED
|
@@ -41,7 +41,8 @@ export declare class Application {
|
|
|
41
41
|
protected emit(event: keyof Omit<FromShopfront, "CALLBACK"> | DirectShopfrontEvent, data: Record<string, unknown> | undefined, id: string): void | Promise<void>;
|
|
42
42
|
addEventListener<E extends keyof FromShopfrontCallbacks>(event: E, callback: FromShopfrontCallbacks[E]): void;
|
|
43
43
|
addEventListener<D>(event: DirectShopfrontEvent, callback: (event: D) => MaybePromise<void>): void;
|
|
44
|
-
removeEventListener
|
|
44
|
+
removeEventListener<E extends keyof FromShopfrontCallbacks>(event: E, callback: FromShopfrontCallbacks[E]): void;
|
|
45
|
+
removeEventListener<D>(event: DirectShopfrontEvent, callback: (event: D) => MaybePromise<void>): void;
|
|
45
46
|
send(item: BaseEmitableEvent<unknown>): void;
|
|
46
47
|
send(item: Serializable<unknown>): void;
|
|
47
48
|
download(file: string): void;
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseEmitableEvent } from "../BaseEmitableEvent";
|
|
2
|
-
import { FulfilmentSale } from "../../APIs/Fulfilment/FulfilmentTypes";
|
|
3
|
-
export declare class OrderSaleCreate extends BaseEmitableEvent<{
|
|
4
|
-
id: string;
|
|
5
|
-
sale: FulfilmentSale;
|
|
6
|
-
}> {
|
|
7
|
-
constructor(id: string, sale: FulfilmentSale);
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OrderSaleCreate = void 0;
|
|
4
|
-
const BaseEmitableEvent_1 = require("../BaseEmitableEvent");
|
|
5
|
-
const ApplicationEvents_1 = require("../../ApplicationEvents");
|
|
6
|
-
class OrderSaleCreate extends BaseEmitableEvent_1.BaseEmitableEvent {
|
|
7
|
-
constructor(id, sale) {
|
|
8
|
-
super(ApplicationEvents_1.ToShopfront.FULFILMENT_CREATE_SALE, {
|
|
9
|
-
id,
|
|
10
|
-
sale,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.OrderSaleCreate = OrderSaleCreate;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BaseEmitableEvent } from "./BaseEmitableEvent";
|
|
2
|
-
import { BaseSaleData } from "../APIs/Sale/BaseSale";
|
|
3
|
-
import { Sale } from "../APIs/Sale";
|
|
4
|
-
import { ShopfrontSalePaymentStatus } from "../APIs/Sale";
|
|
5
|
-
export interface SaleProductData {
|
|
6
|
-
uuid: string;
|
|
7
|
-
caseQuantity: number;
|
|
8
|
-
quantity: number;
|
|
9
|
-
price: number;
|
|
10
|
-
metaData: Record<string, unknown>;
|
|
11
|
-
products: Array<SaleProductData>;
|
|
12
|
-
note: string;
|
|
13
|
-
}
|
|
14
|
-
export interface SalePaymentData {
|
|
15
|
-
method: string;
|
|
16
|
-
type: undefined | string;
|
|
17
|
-
amount: number;
|
|
18
|
-
status: undefined | ShopfrontSalePaymentStatus;
|
|
19
|
-
rounding: number;
|
|
20
|
-
cashout: number;
|
|
21
|
-
}
|
|
22
|
-
export interface SaleData extends BaseSaleData {
|
|
23
|
-
customer: null | string;
|
|
24
|
-
payments: Array<SalePaymentData>;
|
|
25
|
-
products: Array<SaleProductData>;
|
|
26
|
-
}
|
|
27
|
-
export declare class SaleCreate extends BaseEmitableEvent<{
|
|
28
|
-
sale: SaleData;
|
|
29
|
-
}> {
|
|
30
|
-
constructor(sale: Sale);
|
|
31
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SaleCreate = void 0;
|
|
4
|
-
const BaseEmitableEvent_1 = require("./BaseEmitableEvent");
|
|
5
|
-
const ApplicationEvents_1 = require("../ApplicationEvents");
|
|
6
|
-
function buildSaleProductData(product) {
|
|
7
|
-
const price = product.getPrice();
|
|
8
|
-
if (typeof price !== "number") {
|
|
9
|
-
throw new TypeError("Sale Product must have price when creating the sale.");
|
|
10
|
-
}
|
|
11
|
-
const caseQuantity = product.getCaseQuantity();
|
|
12
|
-
if (typeof caseQuantity !== "number") {
|
|
13
|
-
throw new TypeError("Sale Product must have case quantity when creating the sale.");
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
uuid: product.getId(),
|
|
17
|
-
quantity: product.getQuantity(),
|
|
18
|
-
metaData: product.getMetaData(),
|
|
19
|
-
products: product.getContains().map(buildSaleProductData),
|
|
20
|
-
note: product.getNote(),
|
|
21
|
-
caseQuantity,
|
|
22
|
-
price,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function buildSaleData(sale) {
|
|
26
|
-
const customer = sale.getCustomer();
|
|
27
|
-
return {
|
|
28
|
-
clientId: sale.getClientId(),
|
|
29
|
-
notes: {
|
|
30
|
-
internal: sale.getInternalNote(),
|
|
31
|
-
sale: sale.getExternalNote(),
|
|
32
|
-
},
|
|
33
|
-
totals: {
|
|
34
|
-
sale: sale.getSaleTotal(),
|
|
35
|
-
paid: sale.getPaidTotal(),
|
|
36
|
-
savings: sale.getSavingsTotal(),
|
|
37
|
-
discount: sale.getDiscountTotal(),
|
|
38
|
-
},
|
|
39
|
-
linkedTo: sale.getLinkedTo(),
|
|
40
|
-
orderReference: sale.getOrderReference(),
|
|
41
|
-
refundReason: sale.getRefundReason(),
|
|
42
|
-
priceSet: sale.getPriceSet(),
|
|
43
|
-
metaData: sale.getMetaData(),
|
|
44
|
-
customer: customer ? customer.getId() : null,
|
|
45
|
-
products: sale.getProducts().map(buildSaleProductData),
|
|
46
|
-
payments: sale.getPayments().map(payment => ({
|
|
47
|
-
method: payment.getId(),
|
|
48
|
-
type: payment.getType(),
|
|
49
|
-
amount: payment.getAmount(),
|
|
50
|
-
status: payment.getStatus(),
|
|
51
|
-
rounding: payment.getRounding() || 0,
|
|
52
|
-
cashout: payment.getCashout() || 0,
|
|
53
|
-
})),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
class SaleCreate extends BaseEmitableEvent_1.BaseEmitableEvent {
|
|
57
|
-
constructor(sale) {
|
|
58
|
-
super(ApplicationEvents_1.ToShopfront.CREATE_SALE, {
|
|
59
|
-
sale: buildSaleData(sale),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.SaleCreate = SaleCreate;
|