@merchi/sdk 1.42.16 → 1.42.18
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/constants/roles.d.ts +2 -1
- package/dist/constants/roles.js +3 -0
- package/dist/entities/cart_item.test.js +25 -0
- package/dist/entity.d.ts +1 -1
- package/dist/entity.js +1 -1
- package/package.json +1 -1
- package/src/constants/roles.ts +3 -0
- package/src/entities/cart_item.test.ts +30 -0
- package/src/entity.ts +3 -3
package/dist/constants/roles.js
CHANGED
|
@@ -36,6 +36,7 @@ export var Role;
|
|
|
36
36
|
Role[Role["THEME_EDITOR"] = 8] = "THEME_EDITOR";
|
|
37
37
|
Role[Role["REFERRER"] = 9] = "REFERRER";
|
|
38
38
|
Role[Role["FULFILLMENT"] = 10] = "FULFILLMENT";
|
|
39
|
+
Role[Role["ANALYTICS"] = 11] = "ANALYTICS";
|
|
39
40
|
})(Role || (Role = {}));
|
|
40
41
|
export var DOMAIN_MANAGERS = [Role.ADMIN, Role.MANAGER];
|
|
41
42
|
export var MANAGEMENT_TEAM = __spreadArray(__spreadArray([], __read(DOMAIN_MANAGERS), false), [
|
|
@@ -48,12 +49,14 @@ export var BUSINESS_ACCOUNTS = __spreadArray(__spreadArray([], __read(MANAGEMENT
|
|
|
48
49
|
Role.FULFILLMENT,
|
|
49
50
|
Role.THEME_EDITOR,
|
|
50
51
|
Role.REFERRER,
|
|
52
|
+
Role.ANALYTICS,
|
|
51
53
|
], false);
|
|
52
54
|
export var MANAGEMENT_ROLES = [Role.ADMIN, Role.MANAGER];
|
|
53
55
|
export var THEME_ROLES = __spreadArray(__spreadArray([], __read(MANAGEMENT_ROLES), false), [Role.THEME_EDITOR], false);
|
|
54
56
|
export var ROLES_RANK = [
|
|
55
57
|
Role.PUBLIC,
|
|
56
58
|
Role.CLIENT,
|
|
59
|
+
Role.ANALYTICS,
|
|
57
60
|
Role.REFERRER,
|
|
58
61
|
Role.THEME_EDITOR,
|
|
59
62
|
Role.ACCOUNTANT,
|
|
@@ -26,3 +26,28 @@ test('Get quote update job cost', function () {
|
|
|
26
26
|
expect(item.totalCost).toEqual(100);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
+
test('a cart item preserves a job without a tax relationship', function () {
|
|
30
|
+
var merchi = new Merchi();
|
|
31
|
+
var job = new merchi.Job().fromJson({ quantity: 100, taxType: null });
|
|
32
|
+
var item = new merchi.CartItem();
|
|
33
|
+
// The cart transfers this nullable API value through its untyped entity adapter.
|
|
34
|
+
expect(function () { item.taxType = job.taxType; }).not.toThrow();
|
|
35
|
+
expect(item.toJson()).toMatchObject({ taxType: null });
|
|
36
|
+
expect(Array.from(item.toFormData().entries())).toEqual([
|
|
37
|
+
['taxType-0-id', '-1'],
|
|
38
|
+
['taxType-count', '1'],
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
test('clearing a cart tax relationship preserves normal entity linking', function () {
|
|
42
|
+
var merchi = new Merchi();
|
|
43
|
+
var item = new merchi.CartItem();
|
|
44
|
+
var tax = new merchi.CountryTax();
|
|
45
|
+
tax.id = 7;
|
|
46
|
+
item.taxType = tax;
|
|
47
|
+
expect(tax.backObjects.has(item)).toBe(true);
|
|
48
|
+
expect(function () { item.taxType = null; }).not.toThrow();
|
|
49
|
+
expect(item.toJson()).toMatchObject({ taxType: null });
|
|
50
|
+
item.taxType = tax;
|
|
51
|
+
expect(tax.backObjects.has(item)).toBe(true);
|
|
52
|
+
expect(item.taxType).toBe(tax);
|
|
53
|
+
});
|
package/dist/entity.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ export declare class Entity {
|
|
|
198
198
|
toJson: () => any;
|
|
199
199
|
protected forEachProperty: (fn: (i: PropertyInfo) => void) => void;
|
|
200
200
|
toFormData: (options?: SerialiseOptions, fileIndex?: Counter) => FormData;
|
|
201
|
-
protected addBackObject: (remote?: Entity) => void;
|
|
201
|
+
protected addBackObject: (remote?: Entity | null) => void;
|
|
202
202
|
protected addBackObjectList: (remotes?: Entity[]) => void;
|
|
203
203
|
updateOrder: (property: string) => void;
|
|
204
204
|
protected markDirty: (property: string, newValue: any) => void;
|
package/dist/entity.js
CHANGED
package/package.json
CHANGED
package/src/constants/roles.ts
CHANGED
|
@@ -10,6 +10,7 @@ export enum Role {
|
|
|
10
10
|
THEME_EDITOR = 8,
|
|
11
11
|
REFERRER = 9,
|
|
12
12
|
FULFILLMENT = 10,
|
|
13
|
+
ANALYTICS = 11,
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const DOMAIN_MANAGERS = [Role.ADMIN, Role.MANAGER];
|
|
@@ -27,6 +28,7 @@ export const BUSINESS_ACCOUNTS = [
|
|
|
27
28
|
Role.FULFILLMENT,
|
|
28
29
|
Role.THEME_EDITOR,
|
|
29
30
|
Role.REFERRER,
|
|
31
|
+
Role.ANALYTICS,
|
|
30
32
|
];
|
|
31
33
|
|
|
32
34
|
export const MANAGEMENT_ROLES = [Role.ADMIN, Role.MANAGER];
|
|
@@ -35,6 +37,7 @@ export const THEME_ROLES = [...MANAGEMENT_ROLES, Role.THEME_EDITOR];
|
|
|
35
37
|
export const ROLES_RANK = [
|
|
36
38
|
Role.PUBLIC,
|
|
37
39
|
Role.CLIENT,
|
|
40
|
+
Role.ANALYTICS,
|
|
38
41
|
Role.REFERRER,
|
|
39
42
|
Role.THEME_EDITOR,
|
|
40
43
|
Role.ACCOUNTANT,
|
|
@@ -31,3 +31,33 @@ test('Get quote update job cost', () => {
|
|
|
31
31
|
expect(item.totalCost).toEqual(100);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
test('a cart item preserves a job without a tax relationship', () => {
|
|
37
|
+
const merchi = new Merchi();
|
|
38
|
+
const job = new merchi.Job().fromJson({ quantity: 100, taxType: null });
|
|
39
|
+
const item = new merchi.CartItem();
|
|
40
|
+
|
|
41
|
+
// The cart transfers this nullable API value through its untyped entity adapter.
|
|
42
|
+
expect(() => { (item as any).taxType = job.taxType; }).not.toThrow();
|
|
43
|
+
expect(item.toJson()).toMatchObject({ taxType: null });
|
|
44
|
+
expect(Array.from((item.toFormData() as any).entries())).toEqual([
|
|
45
|
+
['taxType-0-id', '-1'],
|
|
46
|
+
['taxType-count', '1'],
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('clearing a cart tax relationship preserves normal entity linking', () => {
|
|
51
|
+
const merchi = new Merchi();
|
|
52
|
+
const item = new merchi.CartItem();
|
|
53
|
+
const tax = new merchi.CountryTax();
|
|
54
|
+
tax.id = 7;
|
|
55
|
+
item.taxType = tax;
|
|
56
|
+
expect(tax.backObjects.has(item)).toBe(true);
|
|
57
|
+
|
|
58
|
+
expect(() => { (item as any).taxType = null; }).not.toThrow();
|
|
59
|
+
expect(item.toJson()).toMatchObject({ taxType: null });
|
|
60
|
+
item.taxType = tax;
|
|
61
|
+
expect(tax.backObjects.has(item)).toBe(true);
|
|
62
|
+
expect(item.taxType).toBe(tax);
|
|
63
|
+
});
|
package/src/entity.ts
CHANGED
|
@@ -347,7 +347,7 @@ export class Entity {
|
|
|
347
347
|
const get = () => {
|
|
348
348
|
return info.currentValue;
|
|
349
349
|
};
|
|
350
|
-
const set = (newValue?: Entity) => {
|
|
350
|
+
const set = (newValue?: Entity | null) => {
|
|
351
351
|
info.currentValue = newValue;
|
|
352
352
|
this.addBackObject(newValue);
|
|
353
353
|
this.markDirty(info.property, newValue);
|
|
@@ -1040,8 +1040,8 @@ export class Entity {
|
|
|
1040
1040
|
return result;
|
|
1041
1041
|
};
|
|
1042
1042
|
|
|
1043
|
-
protected addBackObject = (remote?: Entity) => {
|
|
1044
|
-
if (remote !== undefined) {
|
|
1043
|
+
protected addBackObject = (remote?: Entity | null) => {
|
|
1044
|
+
if (remote !== undefined && remote !== null) {
|
|
1045
1045
|
remote.backObjects.add(this);
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|