@unchainedshop/utils 2.12.2 → 3.0.0-alpha2
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/build-obfuscated-fields-filter.d.ts.map +1 -1
- package/lib/build-obfuscated-fields-filter.js +2 -3
- package/lib/build-obfuscated-fields-filter.js.map +1 -1
- package/lib/locale-helpers.d.ts +2 -4
- package/lib/locale-helpers.d.ts.map +1 -1
- package/lib/locale-helpers.js +13 -9
- package/lib/locale-helpers.js.map +1 -1
- package/lib/utils-index.js +0 -61
- package/lib/utils-index.js.map +1 -1
- package/package.json +5 -6
- package/src/build-obfuscated-fields-filter.ts +2 -3
- package/src/locale-helpers.ts +14 -11
- package/src/utils-index.test.ts +0 -2
- package/src/utils-index.ts +0 -62
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-obfuscated-fields-filter.d.ts","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-obfuscated-fields-filter.d.ts","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,2BAA2B,0BAA0B,MAAM,EAAE,uBA2BlE,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-obfuscated-fields-filter.js","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAG;IAC9B,UAAU;IACV,
|
|
1
|
+
{"version":3,"file":"build-obfuscated-fields-filter.js","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAG;IAC9B,UAAU;IACV,aAAa;IACb,aAAa;IACb,eAAe;IACf,QAAQ;IACR,WAAW;IACX,aAAa;IACb,OAAO;CACR,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,uBAAiC,EAAE,EAAE,EAAE;IAC1E,MAAM,eAAe,GAAG,oBAAoB,IAAI,uBAAuB,CAAC;IAExE,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,EAAE;QACxC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,IAAI,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAChC,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACvB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,GAAG,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,CAAC,2BAA2B;QAC1C,CAAC;QAED,OAAO,IAAI,CAAC,CAAC,wCAAwC;IACvD,CAAC,CAAC;IAEF,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
package/lib/locale-helpers.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { Currency } from '@unchainedshop/types/currencies.js';
|
|
1
2
|
import type { Locale as LocaleType, Locales as LocalesType } from 'locale';
|
|
2
3
|
export declare const systemLocale: LocaleType;
|
|
3
4
|
export declare const resolveBestSupported: (acceptLanguage: string, supportedLocales: LocalesType) => LocaleType;
|
|
4
5
|
export declare const resolveBestCountry: (localeCountry: any, shopCountry: any, countries: any) => any;
|
|
5
|
-
export declare const
|
|
6
|
-
remoteAddress: any;
|
|
7
|
-
remotePort: any;
|
|
8
|
-
};
|
|
6
|
+
export declare const resolveBestCurrency: (localeCurrency: any, currencies: Array<Currency>) => string;
|
|
9
7
|
//# sourceMappingURL=locale-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAO3E,eAAO,MAAM,YAAY,YAAuD,CAAC;AAEjF,eAAO,MAAM,oBAAoB,mBACf,MAAM,oBACJ,WAAW,KAC5B,UAKF,CAAC;AAEF,eAAO,MAAM,kBAAkB,+DAa9B,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAO3E,eAAO,MAAM,YAAY,YAAuD,CAAC;AAEjF,eAAO,MAAM,oBAAoB,mBACf,MAAM,oBACJ,WAAW,KAC5B,UAKF,CAAC;AAEF,eAAO,MAAM,kBAAkB,+DAa9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,oCAAgC,KAAK,CAAC,QAAQ,CAAC,WAc9E,CAAC"}
|
package/lib/locale-helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import localePkg from 'locale';
|
|
2
2
|
const { Locales, Locale } = localePkg;
|
|
3
|
-
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH' } = process.env;
|
|
3
|
+
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH', UNCHAINED_CURRENCY = 'CHF' } = process.env;
|
|
4
4
|
export const systemLocale = new Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
5
5
|
export const resolveBestSupported = (acceptLanguage, supportedLocales) => {
|
|
6
6
|
const acceptLocale = new Locales(acceptLanguage);
|
|
@@ -23,13 +23,17 @@ export const resolveBestCountry = (localeCountry, shopCountry, countries) => {
|
|
|
23
23
|
}
|
|
24
24
|
return localeCountry || systemLocale.country;
|
|
25
25
|
};
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
export const resolveBestCurrency = (localeCurrency, currencies) => {
|
|
27
|
+
if (localeCurrency) {
|
|
28
|
+
const resolvedCurrency = currencies.find((currency) => currency.isoCode === localeCurrency);
|
|
29
|
+
if (resolvedCurrency) {
|
|
30
|
+
return resolvedCurrency.isoCode;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const fallbackCurrency = currencies.find((currency) => currency.isoCode === UNCHAINED_CURRENCY);
|
|
34
|
+
if (fallbackCurrency) {
|
|
35
|
+
return fallbackCurrency.isoCode;
|
|
36
|
+
}
|
|
37
|
+
return currencies?.[0]?.isoCode || UNCHAINED_CURRENCY;
|
|
34
38
|
};
|
|
35
39
|
//# sourceMappingURL=locale-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-helpers.js","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale-helpers.js","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAE/B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;AAEtC,MAAM,EAAE,cAAc,GAAG,IAAI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IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,CAAC;IACH,CAAC;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,KAAK,kBAAkB,CAAC,CAAC;IAChG,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,kBAAkB,CAAC;AACxD,CAAC,CAAC"}
|
package/lib/utils-index.js
CHANGED
|
@@ -21,65 +21,4 @@ export { BasePricingDirector } from './director/BasePricingDirector.js';
|
|
|
21
21
|
export { BasePricingSheet } from './director/BasePricingSheet.js';
|
|
22
22
|
export { BaseDiscountAdapter } from './director/BaseDiscountAdapter.js';
|
|
23
23
|
export { BaseDiscountDirector } from './director/BaseDiscountDirector.js';
|
|
24
|
-
/*
|
|
25
|
-
|
|
26
|
-
function resolveBestCountry(
|
|
27
|
-
contextCountry: string,
|
|
28
|
-
headerCountry: string | string[],
|
|
29
|
-
countries: Array<Country>,
|
|
30
|
-
): string;
|
|
31
|
-
function resolveUserRemoteAddress(req: IncomingMessage): {
|
|
32
|
-
remoteAddress: string;
|
|
33
|
-
remotePort: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function objectInvert(obj: Record<string, string>): Record<string, string>;
|
|
37
|
-
|
|
38
|
-
const systemLocale: Locale;
|
|
39
|
-
|
|
40
|
-
const Schemas: {
|
|
41
|
-
timestampFields: TimestampFields;
|
|
42
|
-
User: SimpleSchema;
|
|
43
|
-
Address: SimpleSchema;
|
|
44
|
-
Contact: SimpleSchema;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Director
|
|
48
|
-
const BaseAdapter: IBaseAdapter;
|
|
49
|
-
const BaseDirector: <Adapter extends IBaseAdapter>(
|
|
50
|
-
directorName: string,
|
|
51
|
-
options?: {
|
|
52
|
-
adapterSortKey?: string;
|
|
53
|
-
adapterKeyField?: string;
|
|
54
|
-
},
|
|
55
|
-
) => IBaseDirector<Adapter>;
|
|
56
|
-
|
|
57
|
-
const BaseDiscountAdapter: Omit<IDiscountAdapter, 'key' | 'label' | 'version'>;
|
|
58
|
-
const BaseDiscountDirector: (directorName: string) => IDiscountDirector;
|
|
59
|
-
|
|
60
|
-
const BasePricingAdapter: <
|
|
61
|
-
AdapterContext extends BasePricingAdapterContext,
|
|
62
|
-
Calculation extends PricingCalculation,
|
|
63
|
-
>() => IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>;
|
|
64
|
-
|
|
65
|
-
const BasePricingDirector: <
|
|
66
|
-
PricingContext extends BasePricingContext,
|
|
67
|
-
AdapterPricingContext extends BasePricingAdapterContext,
|
|
68
|
-
Calculation extends PricingCalculation,
|
|
69
|
-
Adapter extends IPricingAdapter<AdapterPricingContext, Calculation, IPricingSheet<Calculation>>,
|
|
70
|
-
>(
|
|
71
|
-
directorName: string,
|
|
72
|
-
) => IPricingDirector<
|
|
73
|
-
PricingContext,
|
|
74
|
-
Calculation,
|
|
75
|
-
AdapterPricingContext,
|
|
76
|
-
IPricingSheet<Calculation>,
|
|
77
|
-
Adapter
|
|
78
|
-
>;
|
|
79
|
-
|
|
80
|
-
const BasePricingSheet: <Calculation extends PricingCalculation>(
|
|
81
|
-
params: PricingSheetParams<Calculation>,
|
|
82
|
-
) => IBasePricingSheet<Calculation>;
|
|
83
|
-
|
|
84
|
-
*/
|
|
85
24
|
//# sourceMappingURL=utils-index.js.map
|
package/lib/utils-index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-index.js","sourceRoot":"","sources":["../src/utils-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI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EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAE7F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha2",
|
|
4
4
|
"main": "lib/utils-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/utils-index.js",
|
|
@@ -30,16 +30,15 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@unchainedshop/logger": "^
|
|
34
|
-
"abort-controller": "3.0.0",
|
|
33
|
+
"@unchainedshop/logger": "^3.0.0-alpha2",
|
|
35
34
|
"hashids": "^2.3.0",
|
|
36
35
|
"locale": "0.1.0",
|
|
37
36
|
"simpl-schema": "^3.4.6"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^20.14.
|
|
41
|
-
"@unchainedshop/types": "^
|
|
39
|
+
"@types/node": "^20.14.12",
|
|
40
|
+
"@unchainedshop/types": "^3.0.0-alpha2",
|
|
42
41
|
"jest": "^29.7.0",
|
|
43
|
-
"typescript": "^5.5.
|
|
42
|
+
"typescript": "^5.5.4"
|
|
44
43
|
}
|
|
45
44
|
}
|
package/src/locale-helpers.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Currency } from '@unchainedshop/types/currencies.js';
|
|
1
2
|
import type { Locale as LocaleType, Locales as LocalesType } from 'locale';
|
|
2
3
|
import localePkg from 'locale';
|
|
3
4
|
|
|
4
5
|
const { Locales, Locale } = localePkg;
|
|
5
6
|
|
|
6
|
-
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH' } = process.env;
|
|
7
|
+
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH', UNCHAINED_CURRENCY = 'CHF' } = process.env;
|
|
7
8
|
|
|
8
9
|
export const systemLocale = new Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
9
10
|
|
|
@@ -32,16 +33,18 @@ export const resolveBestCountry = (localeCountry, shopCountry, countries) => {
|
|
|
32
33
|
return localeCountry || systemLocale.country;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
export const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
export const resolveBestCurrency = (localeCurrency, currencies: Array<Currency>) => {
|
|
37
|
+
if (localeCurrency) {
|
|
38
|
+
const resolvedCurrency = currencies.find((currency) => currency.isoCode === localeCurrency);
|
|
39
|
+
if (resolvedCurrency) {
|
|
40
|
+
return resolvedCurrency.isoCode;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
const fallbackCurrency = currencies.find((currency) => currency.isoCode === UNCHAINED_CURRENCY);
|
|
45
|
+
if (fallbackCurrency) {
|
|
46
|
+
return fallbackCurrency.isoCode;
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
return
|
|
49
|
+
return currencies?.[0]?.isoCode || UNCHAINED_CURRENCY;
|
|
47
50
|
};
|
package/src/utils-index.test.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveBestCountry,
|
|
3
3
|
resolveBestSupported,
|
|
4
|
-
resolveUserRemoteAddress,
|
|
5
4
|
slugify,
|
|
6
5
|
systemLocale,
|
|
7
6
|
} from '@unchainedshop/utils';
|
|
@@ -13,7 +12,6 @@ describe('Utils', () => {
|
|
|
13
12
|
expect(systemLocale).toBeDefined();
|
|
14
13
|
expect(resolveBestCountry).toBeInstanceOf(Function)
|
|
15
14
|
expect(resolveBestSupported).toBeInstanceOf(Function)
|
|
16
|
-
expect(resolveUserRemoteAddress).toBeInstanceOf(Function)
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
describe('generateHashId', () => {
|
package/src/utils-index.ts
CHANGED
|
@@ -26,65 +26,3 @@ export { BasePricingDirector } from './director/BasePricingDirector.js';
|
|
|
26
26
|
export { BasePricingSheet } from './director/BasePricingSheet.js';
|
|
27
27
|
export { BaseDiscountAdapter } from './director/BaseDiscountAdapter.js';
|
|
28
28
|
export { BaseDiscountDirector } from './director/BaseDiscountDirector.js';
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
|
|
32
|
-
function resolveBestCountry(
|
|
33
|
-
contextCountry: string,
|
|
34
|
-
headerCountry: string | string[],
|
|
35
|
-
countries: Array<Country>,
|
|
36
|
-
): string;
|
|
37
|
-
function resolveUserRemoteAddress(req: IncomingMessage): {
|
|
38
|
-
remoteAddress: string;
|
|
39
|
-
remotePort: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function objectInvert(obj: Record<string, string>): Record<string, string>;
|
|
43
|
-
|
|
44
|
-
const systemLocale: Locale;
|
|
45
|
-
|
|
46
|
-
const Schemas: {
|
|
47
|
-
timestampFields: TimestampFields;
|
|
48
|
-
User: SimpleSchema;
|
|
49
|
-
Address: SimpleSchema;
|
|
50
|
-
Contact: SimpleSchema;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Director
|
|
54
|
-
const BaseAdapter: IBaseAdapter;
|
|
55
|
-
const BaseDirector: <Adapter extends IBaseAdapter>(
|
|
56
|
-
directorName: string,
|
|
57
|
-
options?: {
|
|
58
|
-
adapterSortKey?: string;
|
|
59
|
-
adapterKeyField?: string;
|
|
60
|
-
},
|
|
61
|
-
) => IBaseDirector<Adapter>;
|
|
62
|
-
|
|
63
|
-
const BaseDiscountAdapter: Omit<IDiscountAdapter, 'key' | 'label' | 'version'>;
|
|
64
|
-
const BaseDiscountDirector: (directorName: string) => IDiscountDirector;
|
|
65
|
-
|
|
66
|
-
const BasePricingAdapter: <
|
|
67
|
-
AdapterContext extends BasePricingAdapterContext,
|
|
68
|
-
Calculation extends PricingCalculation,
|
|
69
|
-
>() => IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>;
|
|
70
|
-
|
|
71
|
-
const BasePricingDirector: <
|
|
72
|
-
PricingContext extends BasePricingContext,
|
|
73
|
-
AdapterPricingContext extends BasePricingAdapterContext,
|
|
74
|
-
Calculation extends PricingCalculation,
|
|
75
|
-
Adapter extends IPricingAdapter<AdapterPricingContext, Calculation, IPricingSheet<Calculation>>,
|
|
76
|
-
>(
|
|
77
|
-
directorName: string,
|
|
78
|
-
) => IPricingDirector<
|
|
79
|
-
PricingContext,
|
|
80
|
-
Calculation,
|
|
81
|
-
AdapterPricingContext,
|
|
82
|
-
IPricingSheet<Calculation>,
|
|
83
|
-
Adapter
|
|
84
|
-
>;
|
|
85
|
-
|
|
86
|
-
const BasePricingSheet: <Calculation extends PricingCalculation>(
|
|
87
|
-
params: PricingSheetParams<Calculation>,
|
|
88
|
-
) => IBasePricingSheet<Calculation>;
|
|
89
|
-
|
|
90
|
-
*/
|