@unchainedshop/utils 4.0.0-rc.9 → 4.0.1
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.js +1 -1
- package/lib/calculation.js.map +1 -1
- package/lib/ch/addressToString.d.ts +1 -1
- package/lib/ch/addressToString.d.ts.map +1 -1
- package/lib/ch/addressToString.js +2 -0
- package/lib/ch/addressToString.js.map +1 -1
- package/lib/director/BaseDirector.d.ts +1 -1
- package/lib/director/BaseDirector.d.ts.map +1 -1
- package/lib/director/BaseDirector.js +1 -1
- package/lib/director/BaseDirector.js.map +1 -1
- package/lib/director/BaseDiscountAdapter.d.ts +3 -0
- package/lib/director/BaseDiscountAdapter.d.ts.map +1 -0
- package/lib/director/BaseDiscountAdapter.js +48 -0
- package/lib/director/BaseDiscountAdapter.js.map +1 -0
- package/lib/director/BaseDiscountDirector.d.ts +3 -0
- package/lib/director/BaseDiscountDirector.d.ts.map +1 -0
- package/lib/director/BaseDiscountDirector.js +50 -0
- package/lib/director/BaseDiscountDirector.js.map +1 -0
- package/lib/director/BasePricingAdapter.d.ts +3 -0
- package/lib/director/BasePricingAdapter.d.ts.map +1 -0
- package/lib/director/BasePricingAdapter.js +25 -0
- package/lib/director/BasePricingAdapter.js.map +1 -0
- package/lib/director/BasePricingDirector.d.ts +3 -0
- package/lib/director/BasePricingDirector.d.ts.map +1 -0
- package/lib/director/BasePricingDirector.js +61 -0
- package/lib/director/BasePricingDirector.js.map +1 -0
- package/lib/director/BasePricingSheet.d.ts +3 -0
- package/lib/director/BasePricingSheet.d.ts.map +1 -0
- package/lib/director/BasePricingSheet.js +54 -0
- package/lib/director/BasePricingSheet.js.map +1 -0
- package/lib/find-unused-slug.d.ts +2 -2
- package/lib/find-unused-slug.d.ts.map +1 -1
- package/lib/find-unused-slug.js +2 -0
- package/lib/find-unused-slug.js.map +1 -1
- package/lib/locale-helpers.d.ts +13 -4
- package/lib/locale-helpers.d.ts.map +1 -1
- package/lib/locale-helpers.js +33 -24
- package/lib/locale-helpers.js.map +1 -1
- package/lib/random-value-hex.d.ts +2 -0
- package/lib/random-value-hex.d.ts.map +1 -0
- package/lib/random-value-hex.js +8 -0
- package/lib/random-value-hex.js.map +1 -0
- package/lib/schemas/AddressSchema.d.ts +3 -0
- package/lib/schemas/AddressSchema.d.ts.map +1 -0
- package/lib/schemas/AddressSchema.js +13 -0
- package/lib/schemas/AddressSchema.js.map +1 -0
- package/lib/schemas/ContactSchema.d.ts +3 -0
- package/lib/schemas/ContactSchema.d.ts.map +1 -0
- package/lib/schemas/ContactSchema.js +6 -0
- package/lib/schemas/ContactSchema.js.map +1 -0
- package/lib/schemas/UsersSchema.d.ts +5 -0
- package/lib/schemas/UsersSchema.d.ts.map +1 -0
- package/lib/schemas/UsersSchema.js +52 -0
- package/lib/schemas/UsersSchema.js.map +1 -0
- package/lib/schemas/commonSchemaFields.d.ts +35 -0
- package/lib/schemas/commonSchemaFields.d.ts.map +1 -0
- package/lib/schemas/commonSchemaFields.js +28 -0
- package/lib/schemas/commonSchemaFields.js.map +1 -0
- package/lib/schemas/index.d.ts +43 -0
- package/lib/schemas/index.d.ts.map +1 -0
- package/lib/schemas/index.js +14 -0
- package/lib/schemas/index.js.map +1 -0
- package/lib/sha1.d.ts +1 -1
- package/lib/sha1.d.ts.map +1 -1
- package/lib/sha1.js +2 -1
- package/lib/sha1.js.map +1 -1
- package/lib/sha256.d.ts.map +1 -1
- package/lib/sha256.js +4 -1
- package/lib/sha256.js.map +1 -1
- package/package.json +2 -2
- package/src/calculation.ts +3 -3
- package/src/ch/addressToString.ts +4 -2
- package/src/director/BaseDirector.ts +2 -2
- package/src/director/base-director.test.ts +4 -4
- package/src/find-unused-slug.ts +5 -3
- package/src/locale-helpers.ts +52 -32
- package/src/sha1.ts +2 -1
- package/src/sha256.ts +4 -1
- package/src/utils-index.test.ts +1 -2
- package/tsconfig.json +2 -1
package/lib/calculation.js
CHANGED
|
@@ -2,7 +2,7 @@ export const roundToNext = (value, precision) => Math.ceil(value / precision) *
|
|
|
2
2
|
export const calculateAmountToSplit = (configuration, amount) => {
|
|
3
3
|
const deductionAmount = configuration.rate
|
|
4
4
|
? amount * configuration.rate
|
|
5
|
-
: Math.min(configuration.fixedRate, amount);
|
|
5
|
+
: Math.min(configuration.fixedRate || 0, amount);
|
|
6
6
|
const leftInDiscount = Math.max(0, deductionAmount);
|
|
7
7
|
return leftInDiscount;
|
|
8
8
|
};
|
package/lib/calculation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculation.js","sourceRoot":"","sources":["../src/calculation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,SAAiB,EAAE,EAAE,CAC9D,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,aAAoD,EACpD,MAAc,EACd,EAAE;IACF,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI;QACxC,CAAC,CAAC,MAAM,GAAG,aAAa,CAAC,IAAI;QAC7B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"calculation.js","sourceRoot":"","sources":["../src/calculation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,SAAiB,EAAE,EAAE,CAC9D,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,aAAoD,EACpD,MAAc,EACd,EAAE;IACF,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI;QACxC,CAAC,CAAC,MAAM,GAAG,aAAa,CAAC,IAAI;QAC7B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC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AE;IAC9D,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;QACnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzE,OAAO,CAAC,qBAAqB,GAAG,WAAW,EAAE,gBAAgB,GAAG,cAAc,CAAC,CAAC;IAClF,CAAC,EACD,CAAC,CAAC,EAAE,CAAC,CAAC,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressToString.d.ts","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,
|
|
1
|
+
{"version":3,"file":"addressToString.d.ts","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,UAAU;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,KAAG,MAcH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressToString.js","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAU/B,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"addressToString.js","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAU/B,EAAU,EAAE;IACX,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,OAAO;QACL,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/D,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,WAAW;QACnB,OAAO,CAAC,YAAY;QACpB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5D,OAAO,CAAC,UAAU;QAClB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KAC/C;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ export interface IBaseDirector<Adapter extends IBaseAdapter> {
|
|
|
3
3
|
getAdapters: (options?: {
|
|
4
4
|
adapterFilter?: (adapter: Adapter) => boolean;
|
|
5
5
|
}) => Adapter[];
|
|
6
|
-
getAdapter: (key: string) => Adapter;
|
|
6
|
+
getAdapter: (key: string) => Adapter | null;
|
|
7
7
|
registerAdapter: (A: Adapter) => void;
|
|
8
8
|
unregisterAdapter: (key: string) => boolean;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,YAAY;IACzD,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;KAAE,KAAK,OAAO,EAAE,CAAC;IACxF,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,YAAY;IACzD,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;KAAE,KAAK,OAAO,EAAE,CAAC;IACxF,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,YAAY,EAC3D,cAAc,MAAM,EACpB,UAAU;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KACA,aAAa,CAAC,WAAW,CAwB3B,CAAC"}
|
|
@@ -3,7 +3,7 @@ export const BaseDirector = (directorName, options) => {
|
|
|
3
3
|
const keyField = options?.adapterKeyField || 'key';
|
|
4
4
|
return {
|
|
5
5
|
getAdapter: (key) => {
|
|
6
|
-
return Adapters.get(key);
|
|
6
|
+
return Adapters.get(key) || null;
|
|
7
7
|
},
|
|
8
8
|
getAdapters: ({ adapterFilter } = {}) => {
|
|
9
9
|
const sortKey = options?.adapterSortKey || keyField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDirector.js","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MA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ED,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BaseDiscountAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAqD5F,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
export const BaseDiscountAdapter = {
|
|
3
|
+
orderIndex: 0,
|
|
4
|
+
isManualAdditionAllowed: async () => {
|
|
5
|
+
return false;
|
|
6
|
+
},
|
|
7
|
+
// return true if a discount is allowed to get removed manually by a user
|
|
8
|
+
isManualRemovalAllowed: async () => {
|
|
9
|
+
return false;
|
|
10
|
+
},
|
|
11
|
+
actions: async () => ({
|
|
12
|
+
// return true if a discount is valid to be part of the order
|
|
13
|
+
// without input of a user. that could be a time based global discount
|
|
14
|
+
// like a 10% discount day
|
|
15
|
+
// if you return false, this discount will
|
|
16
|
+
// get removed from the order before any price calculation
|
|
17
|
+
// takes place.
|
|
18
|
+
// eslint-disable-next-line
|
|
19
|
+
isValidForSystemTriggering: async () => {
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
// return an arbitrary JSON serializable object with reservation data
|
|
23
|
+
// this method is called when a discount is added through a manual code and let's
|
|
24
|
+
// you manually deduct expendable discounts (coupon balances for ex.) before checkout
|
|
25
|
+
reserve: async () => {
|
|
26
|
+
return {};
|
|
27
|
+
},
|
|
28
|
+
// return void, allows you to free up any reservations in backend systems
|
|
29
|
+
release: async () => {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
// return true if a discount is valid to be part of the order.
|
|
33
|
+
// if you return false, this discount will
|
|
34
|
+
// get removed from the order before any price calculation
|
|
35
|
+
// takes place.
|
|
36
|
+
isValidForCodeTriggering: async () => {
|
|
37
|
+
return false;
|
|
38
|
+
},
|
|
39
|
+
// returns the appropriate discount context for a calculation adapter
|
|
40
|
+
discountForPricingAdapterKey() {
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
log(message, { level = LogLevel.Debug, ...options } = {}) {
|
|
45
|
+
return log(message, { level, ...options });
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=BaseDiscountAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountAdapter.js","sourceRoot":"","sources":["../../src/director/BaseDiscountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,MAAM,CAAC,MAAM,mBAAmB,GAAiE;IAC/F,UAAU,EAAE,CAAC;IAEb,uBAAuB,EAAE,KAAK,IAAI,EAAE;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yEAAyE;IACzE,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,6DAA6D;QAC7D,sEAAsE;QACtE,0BAA0B;QAC1B,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,2BAA2B;QAC3B,0BAA0B,EAAE,KAAK,IAAI,EAAE;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,iFAAiF;QACjF,qFAAqF;QACrF,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,yEAAyE;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,8DAA8D;QAC9D,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,wBAAwB,EAAE,KAAK,IAAI,EAAE;YACnC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,4BAA4B;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDiscountDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAIvF,eAAO,MAAM,oBAAoB,GAAI,yBAAyB,gBAC9C,MAAM,KACnB,iBAAiB,CAAC,yBAAyB,CAyD7C,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { BaseDirector } from './BaseDirector.js';
|
|
3
|
+
export const BaseDiscountDirector = (directorName) => {
|
|
4
|
+
const baseDirector = BaseDirector(directorName, {
|
|
5
|
+
adapterSortKey: 'orderIndex',
|
|
6
|
+
});
|
|
7
|
+
return {
|
|
8
|
+
...baseDirector,
|
|
9
|
+
actions: async (discountContext, unchainedAPI) => {
|
|
10
|
+
const context = { ...discountContext, ...unchainedAPI };
|
|
11
|
+
return {
|
|
12
|
+
resolveDiscountKeyFromStaticCode: async (options) => {
|
|
13
|
+
if (!context.order)
|
|
14
|
+
return null;
|
|
15
|
+
log(`DiscountDirector -> Find user discount for static code ${options?.code}`);
|
|
16
|
+
const discounts = await Promise.all(baseDirector
|
|
17
|
+
.getAdapters()
|
|
18
|
+
.filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
|
|
19
|
+
.map(async (Adapter) => {
|
|
20
|
+
const adapter = await Adapter.actions({ context });
|
|
21
|
+
return {
|
|
22
|
+
key: Adapter.key,
|
|
23
|
+
isValid: await adapter.isValidForCodeTriggering(options),
|
|
24
|
+
};
|
|
25
|
+
}));
|
|
26
|
+
return discounts.find(({ isValid }) => isValid === true)?.key;
|
|
27
|
+
},
|
|
28
|
+
async findSystemDiscounts() {
|
|
29
|
+
if (!context.order)
|
|
30
|
+
return [];
|
|
31
|
+
const discounts = await Promise.all(baseDirector.getAdapters().map(async (Adapter) => {
|
|
32
|
+
const adapter = await Adapter.actions({ context });
|
|
33
|
+
return {
|
|
34
|
+
key: Adapter.key,
|
|
35
|
+
isValid: await adapter.isValidForSystemTriggering(),
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
const validDiscounts = discounts
|
|
39
|
+
.filter(({ isValid }) => isValid === true)
|
|
40
|
+
.map(({ key }) => key);
|
|
41
|
+
if (validDiscounts.length > 0) {
|
|
42
|
+
log(`DiscountDirector -> Found ${validDiscounts.length} system discounts`);
|
|
43
|
+
}
|
|
44
|
+
return validDiscounts;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=BaseDiscountDirector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountDirector.js","sourceRoot":"","sources":["../../src/director/BaseDiscountDirector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAoB,EAC0B,EAAE;IAChD,MAAM,YAAY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K,EAAE,OAAO,EAAE,EAAE;wBAC/C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;wBACnD,OAAO;4BACL,GAAG,EAAE,OAAO,CAAC,GAAG;4BAChB,OAAO,EAAE,MAAM,OAAO,CAAC,0BAA0B,EAAE;yBACpD,CAAC;oBACJ,CAAC,CAAC,CACH,CAAC;oBAEF,MAAM,cAAc,GAAG,SAAS;yBAC7B,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;yBACzC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;oBAEzB,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC9B,GAAG,CAAC,6BAA6B,cAAc,CAAC,MAAM,mBAAmB,CAAC,CAAC;oBAC7E,CAAC;oBACD,OAAO,cAAc,CAAC;gBACxB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BasePricingAdapterContext, IPricingSheet, IPricingAdapter, PricingCalculation } from '@unchainedshop/types/pricing.js';
|
|
2
|
+
export declare const BasePricingAdapter: <Context extends BasePricingAdapterContext, Calculation extends PricingCalculation>() => IPricingAdapter<Context, Calculation, IPricingSheet<Calculation>>;
|
|
3
|
+
//# sourceMappingURL=BasePricingAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,eAAe,EACf,kBAAkB,EAEnB,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,yBAAyB,EACzC,WAAW,SAAS,kBAAkB,OACnC,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CA4BnE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
export const BasePricingAdapter = () => ({
|
|
3
|
+
key: '',
|
|
4
|
+
label: '',
|
|
5
|
+
version: '',
|
|
6
|
+
orderIndex: 0,
|
|
7
|
+
isActivatedFor: () => {
|
|
8
|
+
return false;
|
|
9
|
+
},
|
|
10
|
+
actions: (params) => {
|
|
11
|
+
const calculation = [];
|
|
12
|
+
const actions = {
|
|
13
|
+
calculate: async () => {
|
|
14
|
+
return [];
|
|
15
|
+
},
|
|
16
|
+
getCalculation: () => calculation,
|
|
17
|
+
getContext: () => params.context,
|
|
18
|
+
};
|
|
19
|
+
return actions;
|
|
20
|
+
},
|
|
21
|
+
log(message, { level = LogLevel.Debug, ...options } = {}) {
|
|
22
|
+
return log(message, { level, ...options });
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=BasePricingAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingAdapter.js","sourceRoot":"","sources":["../../src/director/BasePricingAdapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAGqC,EAAE,CAAC,CAAC;IACzE,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,CAAC;IAEb,cAAc,EAAE,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;QAClB,MAAM,WAAW,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAiD;YAC5D,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,cAAc,EAAE,GAAG,EAAE,CAAC,WAAW;YACjC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO;SACjC,CAAC;QAEF,OAAO,OAEN,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BasePricingAdapterContext, BasePricingContext, IPricingDirector, IPricingAdapter, IPricingSheet, PricingCalculation } from '@unchainedshop/types/pricing.js';
|
|
2
|
+
export declare const BasePricingDirector: <DirectorContext extends BasePricingContext, AdapterContext extends BasePricingAdapterContext, Calculation extends PricingCalculation, PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>>(directorName: string) => IPricingDirector<DirectorContext, Calculation, AdapterContext, IPricingSheet<Calculation>, PricingAdapter>;
|
|
3
|
+
//# sourceMappingURL=BasePricingDirector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingDirector.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingDirector.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,EAEnB,MAAM,iCAAiC,CAAC;AAIzC,eAAO,MAAM,mBAAmB,GAC9B,eAAe,SAAS,kBAAkB,EAC1C,cAAc,SAAS,yBAAyB,EAChD,WAAW,SAAS,kBAAkB,EACtC,cAAc,SAAS,eAAe,CAAC,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,gBAEjF,MAAM,KACnB,gBAAgB,CACjB,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,CAAC,WAAW,CAAC,EAC1B,cAAc,CAgFf,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import { BaseDirector } from './BaseDirector.js';
|
|
3
|
+
export const BasePricingDirector = (directorName) => {
|
|
4
|
+
const baseDirector = BaseDirector(directorName, {
|
|
5
|
+
adapterSortKey: 'orderIndex',
|
|
6
|
+
});
|
|
7
|
+
const director = {
|
|
8
|
+
...baseDirector,
|
|
9
|
+
buildPricingContext: async () => {
|
|
10
|
+
return {};
|
|
11
|
+
},
|
|
12
|
+
actions: async (pricingContext, unchainedAPI, buildPricingContext) => {
|
|
13
|
+
const context = await buildPricingContext(pricingContext, unchainedAPI);
|
|
14
|
+
let calculation = [];
|
|
15
|
+
const actions = {
|
|
16
|
+
async calculate() {
|
|
17
|
+
const Adapters = baseDirector.getAdapters({
|
|
18
|
+
adapterFilter: (Adapter) => {
|
|
19
|
+
return Adapter.isActivatedFor(context);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
calculation = await Adapters.reduce(async (previousPromise, Adapter) => {
|
|
23
|
+
const resolvedCalculation = await previousPromise;
|
|
24
|
+
if (!resolvedCalculation)
|
|
25
|
+
return null;
|
|
26
|
+
const discounts = await Promise.all(context.discounts.map(async (discount) => ({
|
|
27
|
+
discountId: discount._id,
|
|
28
|
+
configuration: await context.modules.orders.discounts.configurationForPricingAdapterKey(discount, Adapter.key, this.calculationSheet(), context),
|
|
29
|
+
})));
|
|
30
|
+
try {
|
|
31
|
+
const adapter = Adapter.actions({
|
|
32
|
+
context,
|
|
33
|
+
calculationSheet: this.calculationSheet(),
|
|
34
|
+
discounts: discounts.filter(({ configuration }) => configuration !== null),
|
|
35
|
+
});
|
|
36
|
+
const nextCalculationResult = await adapter.calculate();
|
|
37
|
+
if (!nextCalculationResult)
|
|
38
|
+
return null;
|
|
39
|
+
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
40
|
+
return calculation;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
log(error, { level: LogLevel.Error });
|
|
44
|
+
}
|
|
45
|
+
return resolvedCalculation;
|
|
46
|
+
}, Promise.resolve([]));
|
|
47
|
+
return calculation;
|
|
48
|
+
},
|
|
49
|
+
getCalculation() {
|
|
50
|
+
return calculation;
|
|
51
|
+
},
|
|
52
|
+
getContext() {
|
|
53
|
+
return context;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
return actions;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return director;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=BasePricingDirector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingDirector.js","sourceRoot":"","sources":["../../src/director/BasePricingDirector.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAMjC,YAAoB,EAOpB,EAAE;IACF,MAAM,YAAY,GAAG,YAAY,CAAiB,YAAY,EAAE;QAC9D,cAAc,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAMV;QACF,GAAG,YAAY;QACf,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAC9B,OAAO,EAAoB,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,EAAE;YACnE,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAExE,IAAI,WAAW,GAAuB,EAAE,CAAC;YAEzC,MAAM,OAAO,GAAwD;gBACnE,KAAK,CAAC,SAAS;oBACb,MAAM,QAAQ,GAAG,YA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GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;wBACxC,CAAC;wBACD,OAAO,mBAAmB,CAAC;oBAC7B,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;oBAExB,OAAO,WAAW,CAAC;gBACrB,CAAC;gBACD,cAAc;oBACZ,OAAO,WAAW,CAAC;gBACrB,CAAC;gBACD,UAAU;oBACR,OAAO,OAAO,CAAC;gBACjB,CAAC;aACF,CAAC;YAEF,OAAO,OAEN,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PricingCalculation, IBasePricingSheet, PricingSheetParams } from '@unchainedshop/types/pricing.js';
|
|
2
|
+
export declare const BasePricingSheet: <Calculation extends PricingCalculation>(params: PricingSheetParams<Calculation>) => IBasePricingSheet<Calculation>;
|
|
3
|
+
//# sourceMappingURL=BasePricingSheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingSheet.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS,kBAAkB,UAC7D,kBAAkB,CAAC,WAAW,CAAC,KACtC,iBAAiB,CAAC,WAAW,CAwE/B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const BasePricingSheet = (params) => {
|
|
2
|
+
const pricingSheet = {
|
|
3
|
+
calculation: params.calculation || [],
|
|
4
|
+
currency: params.currency,
|
|
5
|
+
quantity: params.quantity,
|
|
6
|
+
getRawPricingSheet() {
|
|
7
|
+
return this.calculation;
|
|
8
|
+
},
|
|
9
|
+
isValid() {
|
|
10
|
+
return this.calculation.length > 0;
|
|
11
|
+
},
|
|
12
|
+
sum(filter) {
|
|
13
|
+
return this.filterBy(filter)
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.reduce((sum, calculationRow) => sum + calculationRow.amount, 0);
|
|
16
|
+
},
|
|
17
|
+
taxSum() {
|
|
18
|
+
return 0;
|
|
19
|
+
},
|
|
20
|
+
gross() {
|
|
21
|
+
// Sum contains taxes, thus it's gross when just suming everything
|
|
22
|
+
return this.sum();
|
|
23
|
+
},
|
|
24
|
+
net() {
|
|
25
|
+
// Remove all taxes from gross to get net
|
|
26
|
+
return this.sum() - this.taxSum();
|
|
27
|
+
},
|
|
28
|
+
total({ category, useNetPrice, discountId } = { useNetPrice: false }) {
|
|
29
|
+
const amount = this.sum({ category, discountId });
|
|
30
|
+
const taxAmountForCategory = this.taxSum({ baseCategory: category, discountId });
|
|
31
|
+
// Sum does not contain taxes when filtering by category, it's net in that case and gross if there is no category
|
|
32
|
+
const netAmount = !category ? amount - taxAmountForCategory : amount;
|
|
33
|
+
return {
|
|
34
|
+
amount: Math.round(useNetPrice ? netAmount : netAmount + taxAmountForCategory),
|
|
35
|
+
currency: this.currency,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
filterBy(filter) {
|
|
39
|
+
const filteredCalculation = Object.keys(filter || {}).reduce((oldCalculation, filterKey) => oldCalculation.filter((row) => !!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey])), this.calculation);
|
|
40
|
+
return filteredCalculation;
|
|
41
|
+
},
|
|
42
|
+
resetCalculation(calculationSheet) {
|
|
43
|
+
calculationSheet.filterBy().forEach(({ amount, ...row }) => {
|
|
44
|
+
this.calculation.push({
|
|
45
|
+
...row,
|
|
46
|
+
amount: amount * -1,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return this.calculation;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return pricingSheet;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL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}: {
|
|
2
|
-
slugify
|
|
2
|
+
slugify: (text: string) => string;
|
|
3
3
|
}) => ((params: {
|
|
4
4
|
title?: string;
|
|
5
|
-
existingSlug
|
|
5
|
+
existingSlug?: string;
|
|
6
6
|
newSlug?: string;
|
|
7
7
|
}) => Promise<string>);
|
|
8
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-unused-slug.d.ts","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"yBAcE,qBAAqB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACvD,aAAa;IAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"find-unused-slug.d.ts","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"yBAcE,qBAAqB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACvD,aAAa;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,KACjD,CAAC,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAH7F,wBAyBE"}
|
package/lib/find-unused-slug.js
CHANGED
|
@@ -14,6 +14,8 @@ export default (checkSlugIsUniqueFn, { slugify }) => {
|
|
|
14
14
|
if (!(await checkSlugIsUniqueFn(slug))) {
|
|
15
15
|
const isSlugAlreadySuffixed = !!newSlug;
|
|
16
16
|
return findUnusedSlug({
|
|
17
|
+
title,
|
|
18
|
+
existingSlug,
|
|
17
19
|
newSlug: isSlugAlreadySuffixed ? incrementSuffixedSlug(slug) : addSuffixToSlug(slug),
|
|
18
20
|
});
|
|
19
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-unused-slug.js","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IACjE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IAC3E,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,eAAe,CAAC,iBAAiB,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,eAAe,CACb,mBAAuD,EACvD,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"find-unused-slug.js","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IACjE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IAC3E,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,eAAe,CAAC,iBAAiB,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,eAAe,CACb,mBAAuD,EACvD,EAAE,OAAO,EAAyC,EAC0C,EAAE;IAC9F,MAAM,cAAc,GAAG,KAAK,EAAE,EAC5B,KAAK,EACL,YAAY,EACZ,OAAO,GAKR,EAAE,EAAE;QACH,MAAM,IAAI,GAAG,OAAO,IAAI,YAAY,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,CAAC,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACvC,MAAM,qBAAqB,GAAG,CAAC,CAAC,OAAO,CAAC;YACxC,OAAO,cAAc,CAAC;gBACpB,KAAK;gBACL,YAAY;gBACZ,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;aACrF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
package/lib/locale-helpers.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export declare const systemLocale: Intl.Locale;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const resolveBestCountry: (localeCountry: string, shopCountry: string, countries: {
|
|
2
|
+
export declare const determineFallbackLocale: (countries: {
|
|
4
3
|
isoCode: string;
|
|
5
|
-
}[]
|
|
6
|
-
|
|
4
|
+
}[], languages: {
|
|
5
|
+
isoCode: string;
|
|
6
|
+
}[]) => Intl.Locale;
|
|
7
|
+
export declare const resolveBestSupported: (acceptLanguage: string, acceptCountry: string, { countries, languages, }: {
|
|
8
|
+
countries: {
|
|
9
|
+
isoCode: string;
|
|
10
|
+
}[];
|
|
11
|
+
languages: {
|
|
12
|
+
isoCode: string;
|
|
13
|
+
}[];
|
|
14
|
+
}) => Intl.Locale;
|
|
15
|
+
export declare const resolveBestCurrency: (currencyCode: string | null, currencies: {
|
|
7
16
|
isoCode: string;
|
|
8
17
|
}[]) => string;
|
|
9
18
|
//# sourceMappingURL=locale-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,aAA4D,CAAC;AAEtF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,aAA4D,CAAC;AAEtF,eAAO,MAAM,uBAAuB,GAClC,WAAW;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,EAChC,WAAW;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,KAC/B,IAAI,CAAC,MAYP,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,MAAM,EACtB,eAAe,MAAM,EACrB,2BAGG;IACD,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjC,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC,KACA,IAAI,CAAC,MA8BP,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM,GAAG,IAAI,EAAE,YAAY;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,WAajG,CAAC"}
|
package/lib/locale-helpers.js
CHANGED
|
@@ -1,42 +1,51 @@
|
|
|
1
1
|
import { resolveAcceptLanguage } from 'resolve-accept-language';
|
|
2
2
|
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH', UNCHAINED_CURRENCY = 'CHF' } = process.env;
|
|
3
3
|
export const systemLocale = new Intl.Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
4
|
-
export const
|
|
4
|
+
export const determineFallbackLocale = (countries, languages) => {
|
|
5
5
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const country = countries.find((country) => country.isoCode === systemLocale.region)?.isoCode ||
|
|
7
|
+
countries[0]?.isoCode;
|
|
8
|
+
const language = languages.find((language) => language.isoCode === systemLocale.language)?.isoCode ||
|
|
9
|
+
languages[0]?.isoCode;
|
|
10
|
+
return new Intl.Locale(`${language}-${country}`);
|
|
10
11
|
}
|
|
11
12
|
catch {
|
|
12
13
|
return systemLocale;
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
export const resolveBestSupported = (acceptLanguage, acceptCountry, { countries = [], languages = [], }) => {
|
|
17
|
+
const supportedLocales = languages.reduce((accumulator, language) => {
|
|
18
|
+
const added = countries
|
|
19
|
+
.filter((country) => {
|
|
20
|
+
if (acceptCountry) {
|
|
21
|
+
return country.isoCode === acceptCountry;
|
|
20
22
|
}
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
}
|
|
23
|
+
return true;
|
|
24
|
+
})
|
|
25
|
+
.map((country) => {
|
|
26
|
+
return `${language.isoCode}-${country.isoCode}`;
|
|
27
|
+
});
|
|
28
|
+
return accumulator.concat(added);
|
|
29
|
+
}, []);
|
|
30
|
+
const fallbackLocale = determineFallbackLocale(countries, languages);
|
|
31
|
+
try {
|
|
32
|
+
const { match } = resolveAcceptLanguage(acceptLanguage || '', supportedLocales, fallbackLocale.baseName, {
|
|
33
|
+
returnMatchType: true,
|
|
34
|
+
});
|
|
35
|
+
return new Intl.Locale(match);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return fallbackLocale;
|
|
26
39
|
}
|
|
27
|
-
return localeCountry || systemLocale.region;
|
|
28
40
|
};
|
|
29
|
-
export const resolveBestCurrency = (
|
|
30
|
-
if (
|
|
31
|
-
const resolvedCurrency = currencies.find((currency) => currency.isoCode ===
|
|
41
|
+
export const resolveBestCurrency = (currencyCode, currencies) => {
|
|
42
|
+
if (currencyCode) {
|
|
43
|
+
const resolvedCurrency = currencies.find((currency) => currency.isoCode.toUpperCase() === currencyCode.toUpperCase());
|
|
32
44
|
if (resolvedCurrency) {
|
|
33
45
|
return resolvedCurrency.isoCode;
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return fallbackCurrency.isoCode;
|
|
39
|
-
}
|
|
40
|
-
return currencies?.[0]?.isoCode || UNCHAINED_CURRENCY;
|
|
48
|
+
return (currencies.find((currency) => currency.isoCode === UNCHAINED_CURRENCY)?.isoCode ||
|
|
49
|
+
currencies[0]?.isoCode);
|
|
41
50
|
};
|
|
42
51
|
//# sourceMappingURL=locale-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-helpers.js","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,EAAE,cAAc,GAAG,IAAI,EAAE,iBAAiB,GAAG,IAAI,EAAE,kBAAkB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEpG,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,cAAc,IAAI,iBAAiB,EAAE,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"locale-helpers.js","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,EAAE,cAAc,GAAG,IAAI,EAAE,i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":3,"file":"random-value-hex.d.ts","sourceRoot":"","sources":["../src/random-value-hex.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
export default function randomValueHex(len) {
|
|
3
|
+
return crypto
|
|
4
|
+
.randomBytes(Math.ceil(len / 2))
|
|
5
|
+
.toString('hex') // convert to hexadecimal format
|
|
6
|
+
.slice(0, len); // return required number of characters
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=random-value-hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-value-hex.js","sourceRoot":"","sources":["../src/random-value-hex.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAW;IAChD,OAAO,MAAM;SACV,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC,gCAAgC;SAChD,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,uCAAuC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|