@unchainedshop/utils 3.0.0-alpha2 → 3.0.0-alpha4
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/lib/calculation.d.ts +1 -1
- package/lib/calculation.d.ts.map +1 -1
- package/lib/director/BaseAdapter.d.ts +10 -1
- package/lib/director/BaseAdapter.d.ts.map +1 -1
- package/lib/director/BaseAdapter.js.map +1 -1
- package/lib/director/BaseDirector.d.ts +9 -1
- package/lib/director/BaseDirector.d.ts.map +1 -1
- package/lib/director/BaseDirector.js.map +1 -1
- package/lib/director/BaseDiscountAdapter.d.ts +36 -1
- package/lib/director/BaseDiscountAdapter.d.ts.map +1 -1
- package/lib/director/BaseDiscountAdapter.js.map +1 -1
- package/lib/director/BaseDiscountDirector.d.ts +11 -1
- package/lib/director/BaseDiscountDirector.d.ts.map +1 -1
- package/lib/director/BaseDiscountDirector.js.map +1 -1
- package/lib/director/BasePricingAdapter.d.ts +45 -2
- package/lib/director/BasePricingAdapter.d.ts.map +1 -1
- package/lib/director/BasePricingAdapter.js.map +1 -1
- package/lib/director/BasePricingDirector.d.ts +14 -1
- package/lib/director/BasePricingDirector.d.ts.map +1 -1
- package/lib/director/BasePricingDirector.js.map +1 -1
- package/lib/director/BasePricingSheet.d.ts +45 -1
- package/lib/director/BasePricingSheet.d.ts.map +1 -1
- package/lib/director/BasePricingSheet.js.map +1 -1
- package/lib/locale-helpers.d.ts +8 -6
- package/lib/locale-helpers.d.ts.map +1 -1
- package/lib/locale-helpers.js +8 -10
- package/lib/locale-helpers.js.map +1 -1
- package/lib/object-invert.d.ts +1 -1
- package/lib/object-invert.d.ts.map +1 -1
- package/lib/object-invert.js.map +1 -1
- package/lib/utils-index.d.ts +17 -8
- package/lib/utils-index.d.ts.map +1 -1
- package/lib/utils-index.js +12 -8
- package/lib/utils-index.js.map +1 -1
- package/package.json +5 -7
- package/src/calculation.test.ts +24 -32
- package/src/calculation.ts +1 -1
- package/src/director/BaseAdapter.ts +13 -1
- package/src/director/BaseDirector.ts +8 -1
- package/src/director/BaseDiscountAdapter.ts +32 -1
- package/src/director/BaseDiscountDirector.ts +15 -2
- package/src/director/BasePricingAdapter.ts +59 -11
- package/src/director/BasePricingDirector.ts +36 -9
- package/src/director/BasePricingSheet.ts +45 -5
- package/src/director/base-director.test.ts +55 -66
- package/src/director/base-discount-adapter.test.ts +22 -25
- package/src/director/base-price-sheet.test.ts +50 -56
- package/src/locale-helpers.ts +17 -16
- package/src/object-invert.ts +1 -1
- package/src/utils-index.test.ts +47 -57
- package/src/utils-index.ts +20 -8
- package/lib/schemas/AddressSchema.d.ts +0 -3
- package/lib/schemas/AddressSchema.d.ts.map +0 -1
- package/lib/schemas/AddressSchema.js +0 -13
- package/lib/schemas/AddressSchema.js.map +0 -1
- package/lib/schemas/ContactSchema.d.ts +0 -3
- package/lib/schemas/ContactSchema.d.ts.map +0 -1
- package/lib/schemas/ContactSchema.js +0 -6
- package/lib/schemas/ContactSchema.js.map +0 -1
- package/lib/schemas/UsersSchema.d.ts +0 -5
- package/lib/schemas/UsersSchema.d.ts.map +0 -1
- package/lib/schemas/UsersSchema.js +0 -52
- package/lib/schemas/UsersSchema.js.map +0 -1
- package/lib/schemas/commonSchemaFields.d.ts +0 -35
- package/lib/schemas/commonSchemaFields.d.ts.map +0 -1
- package/lib/schemas/commonSchemaFields.js +0 -28
- package/lib/schemas/commonSchemaFields.js.map +0 -1
- package/lib/schemas/index.d.ts +0 -43
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/index.js +0 -14
- package/lib/schemas/index.js.map +0 -1
- package/src/schemas/AddressSchema.ts +0 -16
- package/src/schemas/ContactSchema.ts +0 -9
- package/src/schemas/UsersSchema.ts +0 -67
- package/src/schemas/commonSchemaFields.ts +0 -29
- package/src/schemas/index.ts +0 -18
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { BaseDiscountAdapter } from
|
|
1
|
+
import { BaseDiscountAdapter } from './BaseDiscountAdapter.js';
|
|
2
2
|
|
|
3
|
-
describe(
|
|
3
|
+
describe('BaseDiscountAdapter instantiation', () => {
|
|
4
4
|
const adapter = BaseDiscountAdapter;
|
|
5
|
-
const context = null
|
|
6
|
-
it(
|
|
5
|
+
const context = null as any;
|
|
6
|
+
it('should initialize with default values', async () => {
|
|
7
7
|
expect(adapter.orderIndex).toEqual(0);
|
|
8
8
|
expect(adapter.log).toEqual(expect.any(Function));
|
|
9
|
-
expect(adapter.isManualAdditionAllowed('')).
|
|
10
|
-
expect(adapter.isManualRemovalAllowed()).
|
|
11
|
-
|
|
12
|
-
expect(adapter.actions(context)).resolves.toEqual({
|
|
9
|
+
expect(await adapter.isManualAdditionAllowed('')).toEqual(false);
|
|
10
|
+
expect(await adapter.isManualRemovalAllowed()).toEqual(false);
|
|
11
|
+
expect(await adapter.actions(context)).toEqual({
|
|
13
12
|
isValidForSystemTriggering: expect.any(Function),
|
|
14
13
|
reserve: expect.any(Function),
|
|
15
14
|
release: expect.any(Function),
|
|
@@ -18,35 +17,33 @@ describe("BaseDiscountAdapter instantiation", () => {
|
|
|
18
17
|
});
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
describe('actions',
|
|
22
|
-
const actions = adapter.actions(context)
|
|
23
|
-
|
|
20
|
+
describe('actions', () => {
|
|
24
21
|
it('isValidForSystemTriggering', async () => {
|
|
25
22
|
const result = await adapter.actions(context);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
23
|
+
expect(await result.isValidForSystemTriggering()).toEqual(false);
|
|
24
|
+
});
|
|
29
25
|
|
|
30
26
|
it('reserve', async () => {
|
|
31
27
|
const result = await adapter.actions(context);
|
|
32
|
-
expect(await result.reserve({code: ''})).toEqual({})
|
|
33
|
-
})
|
|
28
|
+
expect(await result.reserve({ code: '' })).toEqual({});
|
|
29
|
+
});
|
|
34
30
|
|
|
35
31
|
it('release', async () => {
|
|
36
32
|
const result = await adapter.actions(context);
|
|
37
|
-
expect(await result.release()).toEqual(null)
|
|
38
|
-
})
|
|
33
|
+
expect(await result.release()).toEqual(null);
|
|
34
|
+
});
|
|
39
35
|
|
|
40
36
|
it('isValidForCodeTriggering', async () => {
|
|
41
37
|
const result = await adapter.actions(context);
|
|
42
|
-
expect(await result.isValidForCodeTriggering({code: ''})).toEqual(false)
|
|
43
|
-
})
|
|
38
|
+
expect(await result.isValidForCodeTriggering({ code: '' })).toEqual(false);
|
|
39
|
+
});
|
|
44
40
|
|
|
45
41
|
it('discountForPricingAdapterKey', async () => {
|
|
46
42
|
const result = await adapter.actions(context);
|
|
47
|
-
const calculationSheet = {}
|
|
48
|
-
expect(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const calculationSheet = {};
|
|
44
|
+
expect(
|
|
45
|
+
await result.discountForPricingAdapterKey({ calculationSheet, pricingAdapterKey: 'key' } as any),
|
|
46
|
+
).toEqual(null);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
52
49
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePricingSheet } from
|
|
1
|
+
import { BasePricingSheet } from './BasePricingSheet.js';
|
|
2
2
|
|
|
3
3
|
describe('BasePricingSheet', () => {
|
|
4
4
|
let pricingSheet;
|
|
@@ -9,7 +9,7 @@ describe('BasePricingSheet', () => {
|
|
|
9
9
|
const calculations = [TAX, DISCOUNT, ITEM1, ITEM2];
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
|
-
pricingSheet =
|
|
12
|
+
pricingSheet = BasePricingSheet({
|
|
13
13
|
calculation: calculations,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -21,86 +21,80 @@ describe('BasePricingSheet', () => {
|
|
|
21
21
|
it('gross() returns 0 if the calculation is empty', () => {
|
|
22
22
|
expect(BasePricingSheet({ calculation: [] }).gross()).toEqual(0);
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
|
|
25
|
+
it('total() calculates the sum of the amounts in the calculations by default', () => {
|
|
26
|
+
expect(pricingSheet.total()).toEqual({ amount: 550, currency: undefined });
|
|
27
|
+
});
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
it('total() calculates the sum of the amounts in the calculations for a given category', () => {
|
|
32
|
-
expect(pricingSheet.total({ category: 'item' })).toEqual({ amount: 400, currency: undefined });
|
|
33
|
-
});
|
|
29
|
+
it('total() calculates the sum of the amounts in the calculations for a given category', () => {
|
|
30
|
+
expect(pricingSheet.total({ category: 'item' })).toEqual({ amount: 400, currency: undefined });
|
|
31
|
+
});
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
it('total() calculates the net sum of the amounts in the calculations if useNetPrice is true', () => {
|
|
34
|
+
expect(pricingSheet.total({ useNetPrice: true })).toEqual({ amount: 550, currency: undefined });
|
|
35
|
+
});
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
it('calculates the correct net amount', () => {
|
|
44
|
-
expect(pricingSheet.net()).toEqual(550);
|
|
45
|
-
});
|
|
37
|
+
it('total() returns 0 if the calculation is empty', () => {
|
|
38
|
+
expect(BasePricingSheet({ calculation: [] }).total()).toEqual({ amount: 0, currency: undefined });
|
|
39
|
+
});
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
it('calculates the correct net amount', () => {
|
|
42
|
+
expect(pricingSheet.net()).toEqual(550);
|
|
43
|
+
});
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
it('calculates the correct sum for a given category', () => {
|
|
46
|
+
expect(pricingSheet.sum({ category: 'item' })).toEqual(400);
|
|
47
|
+
});
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
it('calculates the correct tax amount', () => {
|
|
50
|
+
expect(pricingSheet.taxSum()).toEqual(0);
|
|
51
|
+
});
|
|
56
52
|
|
|
57
53
|
describe('getRawPricingSheet', () => {
|
|
58
|
-
it('returns the correct list of calculations', () => {
|
|
54
|
+
it('returns the correct list of calculations', () => {
|
|
59
55
|
expect(pricingSheet.getRawPricingSheet()).toEqual(calculations);
|
|
60
56
|
});
|
|
61
|
-
|
|
57
|
+
|
|
62
58
|
it('returns an empty list of calculations if none are provided', () => {
|
|
63
59
|
expect(BasePricingSheet({}).getRawPricingSheet()).toEqual([]);
|
|
64
60
|
});
|
|
65
61
|
});
|
|
66
|
-
|
|
67
62
|
|
|
68
|
-
describe('isValid', () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
describe('isValid', () => {
|
|
64
|
+
it('returns true if the sheet has calculations', () => {
|
|
65
|
+
expect(pricingSheet.isValid()).toEqual(true);
|
|
66
|
+
});
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
it('returns false if the sheet does not have calculations', () => {
|
|
69
|
+
expect(BasePricingSheet({}).isValid()).toEqual(false);
|
|
70
|
+
});
|
|
75
71
|
});
|
|
76
|
-
});
|
|
77
72
|
|
|
78
|
-
describe('filterBy', () => {
|
|
73
|
+
describe('filterBy', () => {
|
|
79
74
|
it('filters the list of calculations correctly', () => {
|
|
80
75
|
expect(pricingSheet.filterBy({ category: 'item' })).toEqual([ITEM1, ITEM2]);
|
|
81
76
|
});
|
|
82
77
|
|
|
83
78
|
it('returns the full list of calculations if no filter is provided', () => {
|
|
84
|
-
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
expect(pricingSheet.filterBy()).toEqual(calculations);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
89
82
|
|
|
90
|
-
describe('resetCalculation', () => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
describe('resetCalculation', () => {
|
|
84
|
+
it('resets the list of calculations correctly', () => {
|
|
85
|
+
const expectedCalculations = calculations.reduce(
|
|
86
|
+
(prev, { amount, ...row }) => {
|
|
87
|
+
return [
|
|
94
88
|
...prev,
|
|
95
89
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
...row,
|
|
91
|
+
amount: -amount,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
},
|
|
95
|
+
[...calculations],
|
|
96
|
+
);
|
|
97
|
+
expect(pricingSheet.resetCalculation(pricingSheet)).toEqual(expectedCalculations);
|
|
98
|
+
});
|
|
102
99
|
});
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
|
|
106
100
|
});
|
package/src/locale-helpers.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Locale as LocaleType, Locales as LocalesType } from 'locale';
|
|
3
|
-
import localePkg from 'locale';
|
|
4
|
-
|
|
5
|
-
const { Locales, Locale } = localePkg;
|
|
1
|
+
import { resolveAcceptLanguage } from 'resolve-accept-language';
|
|
6
2
|
|
|
7
3
|
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH', UNCHAINED_CURRENCY = 'CHF' } = process.env;
|
|
8
4
|
|
|
9
|
-
export const systemLocale = new Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
5
|
+
export const systemLocale = new Intl.Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
10
6
|
|
|
11
7
|
export const resolveBestSupported = (
|
|
12
8
|
acceptLanguage: string,
|
|
13
|
-
supportedLocales:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
supportedLocales: Array<string>,
|
|
10
|
+
fallbackLocale: string,
|
|
11
|
+
): Intl.Locale => {
|
|
12
|
+
const { match } = resolveAcceptLanguage(acceptLanguage || '', supportedLocales, fallbackLocale, {
|
|
13
|
+
returnMatchType: true,
|
|
14
|
+
});
|
|
15
|
+
return new Intl.Locale(match);
|
|
19
16
|
};
|
|
20
17
|
|
|
21
|
-
export const resolveBestCountry = (
|
|
18
|
+
export const resolveBestCountry = (
|
|
19
|
+
localeCountry: string,
|
|
20
|
+
shopCountry: string,
|
|
21
|
+
countries: Array<{ isoCode: string }>,
|
|
22
|
+
) => {
|
|
22
23
|
if (shopCountry) {
|
|
23
|
-
const resolvedCountry = countries.reduce((lastResolved, country) => {
|
|
24
|
+
const resolvedCountry = countries.reduce<string>((lastResolved, country) => {
|
|
24
25
|
if (shopCountry === country.isoCode) {
|
|
25
26
|
return country.isoCode;
|
|
26
27
|
}
|
|
@@ -30,10 +31,10 @@ export const resolveBestCountry = (localeCountry, shopCountry, countries) => {
|
|
|
30
31
|
return resolvedCountry;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
return localeCountry || systemLocale.
|
|
34
|
+
return localeCountry || systemLocale.region;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
export const resolveBestCurrency = (localeCurrency, currencies: Array<
|
|
37
|
+
export const resolveBestCurrency = (localeCurrency: string, currencies: Array<{ isoCode: string }>) => {
|
|
37
38
|
if (localeCurrency) {
|
|
38
39
|
const resolvedCurrency = currencies.find((currency) => currency.isoCode === localeCurrency);
|
|
39
40
|
if (resolvedCurrency) {
|
package/src/object-invert.ts
CHANGED
package/src/utils-index.test.ts
CHANGED
|
@@ -1,67 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
resolveBestSupported,
|
|
4
|
-
slugify,
|
|
5
|
-
systemLocale,
|
|
6
|
-
} from '@unchainedshop/utils';
|
|
7
|
-
import generateHashId from './generate-random-hash.js'
|
|
1
|
+
import { resolveBestCountry, resolveBestSupported, slugify, systemLocale } from '@unchainedshop/utils';
|
|
2
|
+
import generateHashId from './generate-random-hash.js';
|
|
8
3
|
|
|
9
4
|
describe('Utils', () => {
|
|
10
|
-
|
|
11
5
|
it('Locale', () => {
|
|
12
6
|
expect(systemLocale).toBeDefined();
|
|
13
|
-
expect(resolveBestCountry).toBeInstanceOf(Function)
|
|
14
|
-
expect(resolveBestSupported).toBeInstanceOf(Function)
|
|
7
|
+
expect(resolveBestCountry).toBeInstanceOf(Function);
|
|
8
|
+
expect(resolveBestSupported).toBeInstanceOf(Function);
|
|
15
9
|
});
|
|
16
10
|
|
|
17
|
-
describe('generateHashId', () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
expect(typeof result).toBe('string');
|
|
22
|
-
expect(result).toMatch(/^[A-Z0-9]+$/);
|
|
23
|
-
})
|
|
24
|
-
});
|
|
11
|
+
describe('generateHashId', () => {
|
|
12
|
+
it('should create a random hash ', () => {
|
|
13
|
+
const result = generateHashId();
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
30
|
-
|
|
31
|
-
const result = slugify(text);
|
|
32
|
-
|
|
33
|
-
expect(result).toEqual(expected);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('with a string containing special characters', () => {
|
|
37
|
-
const text = 'The Quick Brown Fox! Jumps Over The Lazy Dog?';
|
|
38
|
-
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
39
|
-
|
|
40
|
-
const result = slugify(text);
|
|
41
|
-
|
|
42
|
-
expect(result).toEqual(expected);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('with a string containing multiple spaces', () => {
|
|
46
|
-
const text = 'The Quick Brown Fox Jumps Over The Lazy Dog';
|
|
47
|
-
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
48
|
-
|
|
49
|
-
const result = slugify(text);
|
|
50
|
-
|
|
51
|
-
expect(result).toEqual(expected);
|
|
15
|
+
expect(typeof result).toBe('string');
|
|
16
|
+
expect(result).toMatch(/^[A-Z0-9]+$/);
|
|
17
|
+
});
|
|
52
18
|
});
|
|
53
|
-
|
|
54
|
-
it('with a string containing only special characters (leave underscore)', () => {
|
|
55
|
-
const text = '!@#$%^&*()_+';
|
|
56
|
-
const expected = '_';
|
|
57
|
-
|
|
58
|
-
const result = slugify(text);
|
|
59
|
-
|
|
60
|
-
expect(result).toEqual(expected);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
});
|
|
66
19
|
|
|
20
|
+
describe('slugify', () => {
|
|
21
|
+
it('with a normal string', () => {
|
|
22
|
+
const text = 'The Quick Brown Fox Jumps Over The Lazy Dog';
|
|
23
|
+
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
24
|
+
|
|
25
|
+
const result = slugify(text);
|
|
26
|
+
|
|
27
|
+
expect(result).toEqual(expected);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('with a string containing special characters', () => {
|
|
31
|
+
const text = 'The Quick Brown Fox! Jumps Over The Lazy Dog?';
|
|
32
|
+
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
67
33
|
|
|
34
|
+
const result = slugify(text);
|
|
35
|
+
|
|
36
|
+
expect(result).toEqual(expected);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('with a string containing multiple spaces', () => {
|
|
40
|
+
const text = 'The Quick Brown Fox Jumps Over The Lazy Dog';
|
|
41
|
+
const expected = 'the-quick-brown-fox-jumps-over-the-lazy-dog';
|
|
42
|
+
|
|
43
|
+
const result = slugify(text);
|
|
44
|
+
|
|
45
|
+
expect(result).toEqual(expected);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('with a string containing only special characters (leave underscore)', () => {
|
|
49
|
+
const text = '!@#$%^&*()_+';
|
|
50
|
+
const expected = '_';
|
|
51
|
+
|
|
52
|
+
const result = slugify(text);
|
|
53
|
+
|
|
54
|
+
expect(result).toEqual(expected);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
package/src/utils-index.ts
CHANGED
|
@@ -13,16 +13,28 @@ export { default as buildObfuscatedFieldsFilter } from './build-obfuscated-field
|
|
|
13
13
|
* Schemas
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export enum SortDirection {
|
|
17
|
+
ASC = 'ASC',
|
|
18
|
+
DESC = 'DESC',
|
|
19
|
+
}
|
|
17
20
|
|
|
21
|
+
export type SortOption = {
|
|
22
|
+
key: string;
|
|
23
|
+
value: SortDirection;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type NodeOrTree<T> = string | Tree<T>; // eslint-disable-line
|
|
27
|
+
export type Tree<T> = Array<NodeOrTree<T>>;
|
|
18
28
|
/*
|
|
19
29
|
* Director
|
|
20
30
|
*/
|
|
21
31
|
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
|
|
32
|
+
export * from './director/BaseAdapter.js';
|
|
33
|
+
export * from './director/BaseDirector.js';
|
|
34
|
+
|
|
35
|
+
export * from './director/BasePricingAdapter.js';
|
|
36
|
+
export * from './director/BasePricingDirector.js';
|
|
37
|
+
export * from './director/BasePricingSheet.js';
|
|
38
|
+
|
|
39
|
+
export * from './director/BaseDiscountAdapter.js';
|
|
40
|
+
export * from './director/BaseDiscountDirector.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AddressSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/AddressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,aAAa,cAazB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import SimpleSchema from 'simpl-schema';
|
|
2
|
-
export const AddressSchema = new SimpleSchema({
|
|
3
|
-
firstName: String,
|
|
4
|
-
lastName: String,
|
|
5
|
-
company: String,
|
|
6
|
-
addressLine: String,
|
|
7
|
-
addressLine2: String,
|
|
8
|
-
city: String,
|
|
9
|
-
postalCode: String,
|
|
10
|
-
regionCode: String,
|
|
11
|
-
countryCode: String,
|
|
12
|
-
}, { requiredByDefault: false });
|
|
13
|
-
//# sourceMappingURL=AddressSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AddressSchema.js","sourceRoot":"","sources":["../../src/schemas/AddressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;IACnB,YAAY,EAAE,MAAM;IACpB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;CACpB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContactSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/ContactSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,aAAa,cAMzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContactSchema.js","sourceRoot":"","sources":["../../src/schemas/ContactSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/UsersSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAexC,eAAO,MAAM,eAAe,cAU3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,cA+BtB,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import SimpleSchema from 'simpl-schema';
|
|
2
|
-
import { AddressSchema } from './AddressSchema.js';
|
|
3
|
-
import { timestampFields } from './commonSchemaFields.js';
|
|
4
|
-
const ProfileSchema = new SimpleSchema({
|
|
5
|
-
displayName: String,
|
|
6
|
-
birthday: Date,
|
|
7
|
-
phoneMobile: String,
|
|
8
|
-
gender: String,
|
|
9
|
-
address: AddressSchema,
|
|
10
|
-
}, { requiredByDefault: false });
|
|
11
|
-
export const LastLoginSchema = new SimpleSchema({
|
|
12
|
-
timestamp: Date,
|
|
13
|
-
locale: String,
|
|
14
|
-
countryCode: String,
|
|
15
|
-
remoteAddress: String,
|
|
16
|
-
remotePort: String,
|
|
17
|
-
userAgent: String,
|
|
18
|
-
}, { requiredByDefault: false });
|
|
19
|
-
export const LastContactSchema = new SimpleSchema({
|
|
20
|
-
telNumber: String,
|
|
21
|
-
emailAddress: String,
|
|
22
|
-
}, { requiredByDefault: false });
|
|
23
|
-
export const UserSchema = new SimpleSchema({
|
|
24
|
-
emails: Array,
|
|
25
|
-
'emails.$': Object,
|
|
26
|
-
'emails.$.address': String,
|
|
27
|
-
'emails.$.verified': Boolean,
|
|
28
|
-
username: String,
|
|
29
|
-
lastLogin: LastLoginSchema,
|
|
30
|
-
profile: ProfileSchema,
|
|
31
|
-
lastBillingAddress: AddressSchema,
|
|
32
|
-
lastContact: LastContactSchema,
|
|
33
|
-
guest: Boolean,
|
|
34
|
-
initialPassword: Boolean,
|
|
35
|
-
tags: Array,
|
|
36
|
-
'tags.$': String,
|
|
37
|
-
avatarId: String,
|
|
38
|
-
meta: {
|
|
39
|
-
type: Object,
|
|
40
|
-
optional: true,
|
|
41
|
-
blackbox: true,
|
|
42
|
-
},
|
|
43
|
-
services: {
|
|
44
|
-
type: Object,
|
|
45
|
-
optional: true,
|
|
46
|
-
blackbox: true,
|
|
47
|
-
},
|
|
48
|
-
roles: Array,
|
|
49
|
-
'roles.$': String,
|
|
50
|
-
...timestampFields,
|
|
51
|
-
}, { requiredByDefault: false });
|
|
52
|
-
//# sourceMappingURL=UsersSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSchema.js","sourceRoot":"","sources":["../../src/schemas/UsersSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,aAAa,GAAG,IAAI,YAAY,CACpC;IACE,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,aAAa;CACvB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,MAAM;IACnB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;CAClB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,YAAY,CAC/C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,YAAY,CACxC;IACE,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,MAAM;IAClB,kBAAkB,EAAE,MAAM;IAC1B,mBAAmB,EAAE,OAAO;IAC5B,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,aAAa;IACtB,kBAAkB,EAAE,aAAa;IACjC,WAAW,EAAE,iBAAiB;IAC9B,KAAK,EAAE,OAAO;IACd,eAAe,EAAE,OAAO;IACxB,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,MAAM;IACjB,GAAG,eAAe;CACnB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare const contextFields: {
|
|
2
|
-
context: {
|
|
3
|
-
type: ObjectConstructor;
|
|
4
|
-
blackbox: boolean;
|
|
5
|
-
required: boolean;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const logFields: {
|
|
9
|
-
log: ArrayConstructor;
|
|
10
|
-
'log.$': {
|
|
11
|
-
type: ObjectConstructor;
|
|
12
|
-
};
|
|
13
|
-
'log.$.date': {
|
|
14
|
-
type: DateConstructor;
|
|
15
|
-
};
|
|
16
|
-
'log.$.status': {
|
|
17
|
-
type: StringConstructor;
|
|
18
|
-
};
|
|
19
|
-
'log.$.info': {
|
|
20
|
-
type: StringConstructor;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare const timestampFields: {
|
|
24
|
-
created: {
|
|
25
|
-
type: DateConstructor;
|
|
26
|
-
required: boolean;
|
|
27
|
-
};
|
|
28
|
-
updated: {
|
|
29
|
-
type: DateConstructor;
|
|
30
|
-
};
|
|
31
|
-
deleted: {
|
|
32
|
-
type: DateConstructor;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=commonSchemaFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commonSchemaFields.d.ts","sourceRoot":"","sources":["../../src/schemas/commonSchemaFields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAcrB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;CAI3B,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const contextFields = {
|
|
2
|
-
context: {
|
|
3
|
-
type: Object,
|
|
4
|
-
blackbox: true,
|
|
5
|
-
required: false,
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
export const logFields = {
|
|
9
|
-
log: Array,
|
|
10
|
-
'log.$': {
|
|
11
|
-
type: Object,
|
|
12
|
-
},
|
|
13
|
-
'log.$.date': {
|
|
14
|
-
type: Date,
|
|
15
|
-
},
|
|
16
|
-
'log.$.status': {
|
|
17
|
-
type: String,
|
|
18
|
-
},
|
|
19
|
-
'log.$.info': {
|
|
20
|
-
type: String,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
export const timestampFields = {
|
|
24
|
-
created: { type: Date, required: true },
|
|
25
|
-
updated: { type: Date },
|
|
26
|
-
deleted: { type: Date },
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=commonSchemaFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commonSchemaFields.js","sourceRoot":"","sources":["../../src/schemas/commonSchemaFields.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,IAAI;KACX;IACD,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM;KACb;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACvB,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;CACxB,CAAC"}
|