@unchainedshop/utils 3.0.0-alpha2 → 3.0.0-alpha3
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 +6 -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.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/locale-helpers.ts +19 -16
- package/src/object-invert.ts +1 -1
- 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,6 +1,37 @@
|
|
|
1
1
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
3
|
+
import { IBaseAdapter } from './BaseAdapter.js';
|
|
4
|
+
import { IPricingSheet, PricingCalculation } from './BasePricingSheet.js';
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
export interface DiscountContext {
|
|
7
|
+
code?: string;
|
|
8
|
+
orderDiscount?: { _id?: string; orderId: string };
|
|
9
|
+
order?: { _id?: string; userId: string };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type IDiscountAdapter<DiscountConfiguration> = IBaseAdapter & {
|
|
13
|
+
orderIndex: number;
|
|
14
|
+
|
|
15
|
+
isManualAdditionAllowed: (code: string) => Promise<boolean>;
|
|
16
|
+
isManualRemovalAllowed: () => Promise<boolean>;
|
|
17
|
+
|
|
18
|
+
actions: (params: {
|
|
19
|
+
context: DiscountContext & UnchainedCore;
|
|
20
|
+
}) => Promise<DiscountAdapterActions<DiscountConfiguration>>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
24
|
+
isValidForSystemTriggering: () => Promise<boolean>;
|
|
25
|
+
isValidForCodeTriggering: (params: { code: string }) => Promise<boolean>;
|
|
26
|
+
|
|
27
|
+
discountForPricingAdapterKey: (params: {
|
|
28
|
+
pricingAdapterKey: string;
|
|
29
|
+
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
30
|
+
}) => DiscountConfiguration;
|
|
31
|
+
|
|
32
|
+
reserve: (params: { code: string }) => Promise<any>;
|
|
33
|
+
release: () => Promise<void>;
|
|
34
|
+
}
|
|
4
35
|
|
|
5
36
|
export const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label' | 'version'> = {
|
|
6
37
|
orderIndex: 0,
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import { IDiscountAdapter, IDiscountDirector } from '@unchainedshop/types/discount.js';
|
|
2
1
|
import { log } from '@unchainedshop/logger';
|
|
3
|
-
import { BaseDirector } from './BaseDirector.js';
|
|
2
|
+
import { BaseDirector, IBaseDirector } from './BaseDirector.js';
|
|
3
|
+
import { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.js';
|
|
4
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
|
+
|
|
6
|
+
export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<
|
|
7
|
+
IDiscountAdapter<DiscountConfiguration>
|
|
8
|
+
> & {
|
|
9
|
+
actions: (
|
|
10
|
+
discountContext: DiscountContext,
|
|
11
|
+
unchainedAPI: UnchainedCore,
|
|
12
|
+
) => Promise<{
|
|
13
|
+
resolveDiscountKeyFromStaticCode: (params: { code: string }) => Promise<string | null>;
|
|
14
|
+
findSystemDiscounts: () => Promise<Array<string>>;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
4
17
|
|
|
5
18
|
export const BaseDiscountDirector = <DiscountConfigurationType>(
|
|
6
19
|
directorName: string,
|
|
@@ -1,16 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
IPricingSheet,
|
|
4
|
-
IPricingAdapter,
|
|
5
|
-
PricingCalculation,
|
|
6
|
-
IPricingAdapterActions,
|
|
7
|
-
} from '@unchainedshop/types/pricing.js';
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { User } from '@unchainedshop/core-users';
|
|
8
3
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
4
|
+
import { IPricingSheet, PricingCalculation } from './BasePricingSheet.js';
|
|
5
|
+
import { IBaseAdapter } from './BaseAdapter.js';
|
|
6
|
+
import { Discount } from './BasePricingDirector.js';
|
|
7
|
+
|
|
8
|
+
type Order = { _id?: string };
|
|
9
|
+
type OrderDiscount = { _id?: string };
|
|
10
|
+
|
|
11
|
+
interface IDiscountableItem {
|
|
12
|
+
_id?: string;
|
|
13
|
+
orderId?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BasePricingAdapterContext extends UnchainedCore {
|
|
17
|
+
order?: Order;
|
|
18
|
+
user: User;
|
|
19
|
+
discounts: Array<OrderDiscount>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type BasePricingContext =
|
|
23
|
+
| {
|
|
24
|
+
order?: Order;
|
|
25
|
+
user?: User;
|
|
26
|
+
discounts?: Array<OrderDiscount>;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
item: IDiscountableItem;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface IPricingAdapterActions<
|
|
33
|
+
Calculation extends PricingCalculation,
|
|
34
|
+
PricingAdapterContext extends BasePricingAdapterContext,
|
|
35
|
+
> {
|
|
36
|
+
calculate: () => Promise<Array<Calculation>>;
|
|
37
|
+
getCalculation: () => Array<Calculation>;
|
|
38
|
+
getContext: () => PricingAdapterContext;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type IPricingAdapter<
|
|
42
|
+
PricingAdapterContext extends BasePricingAdapterContext,
|
|
43
|
+
Calculation extends PricingCalculation,
|
|
44
|
+
Sheet extends IPricingSheet<Calculation>,
|
|
45
|
+
DiscountConfiguration = unknown,
|
|
46
|
+
> = IBaseAdapter & {
|
|
47
|
+
orderIndex: number;
|
|
48
|
+
|
|
49
|
+
isActivatedFor: (context: PricingAdapterContext) => boolean;
|
|
50
|
+
|
|
51
|
+
actions: (params: {
|
|
52
|
+
context: PricingAdapterContext;
|
|
53
|
+
calculationSheet: Sheet;
|
|
54
|
+
discounts: Array<Discount<DiscountConfiguration>>;
|
|
55
|
+
}) => IPricingAdapterActions<Calculation, PricingAdapterContext> & { resultSheet: () => Sheet };
|
|
56
|
+
};
|
|
9
57
|
|
|
10
58
|
export const BasePricingAdapter = <
|
|
11
|
-
|
|
59
|
+
PricingAdapterContext extends BasePricingAdapterContext,
|
|
12
60
|
Calculation extends PricingCalculation,
|
|
13
|
-
>(): IPricingAdapter<
|
|
61
|
+
>(): IPricingAdapter<PricingAdapterContext, Calculation, IPricingSheet<Calculation>> => ({
|
|
14
62
|
key: '',
|
|
15
63
|
label: '',
|
|
16
64
|
version: '',
|
|
@@ -22,7 +70,7 @@ export const BasePricingAdapter = <
|
|
|
22
70
|
|
|
23
71
|
actions: (params) => {
|
|
24
72
|
const calculation = [];
|
|
25
|
-
const actions: IPricingAdapterActions<Calculation,
|
|
73
|
+
const actions: IPricingAdapterActions<Calculation, PricingAdapterContext> = {
|
|
26
74
|
calculate: async () => {
|
|
27
75
|
return [];
|
|
28
76
|
},
|
|
@@ -30,7 +78,7 @@ export const BasePricingAdapter = <
|
|
|
30
78
|
getContext: () => params.context,
|
|
31
79
|
};
|
|
32
80
|
|
|
33
|
-
return actions as IPricingAdapterActions<Calculation,
|
|
81
|
+
return actions as IPricingAdapterActions<Calculation, PricingAdapterContext> & {
|
|
34
82
|
resultSheet: () => IPricingSheet<Calculation>;
|
|
35
83
|
};
|
|
36
84
|
},
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import { BaseDirector, IBaseDirector } from './BaseDirector.js';
|
|
3
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
4
|
import {
|
|
3
5
|
BasePricingAdapterContext,
|
|
4
6
|
BasePricingContext,
|
|
5
|
-
IPricingDirector,
|
|
6
7
|
IPricingAdapter,
|
|
7
|
-
IPricingSheet,
|
|
8
|
-
PricingCalculation,
|
|
9
8
|
IPricingAdapterActions,
|
|
10
|
-
} from '
|
|
11
|
-
import {
|
|
12
|
-
|
|
9
|
+
} from './BasePricingAdapter.js';
|
|
10
|
+
import { IPricingSheet, PricingCalculation } from './BasePricingSheet.js';
|
|
11
|
+
export interface Discount<DiscountConfiguration> {
|
|
12
|
+
discountId: string;
|
|
13
|
+
configuration: DiscountConfiguration;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type IPricingDirector<
|
|
17
|
+
PricingContext extends BasePricingContext,
|
|
18
|
+
Calculation extends PricingCalculation,
|
|
19
|
+
PricingAdapterContext extends BasePricingAdapterContext,
|
|
20
|
+
PricingAdapterSheet extends IPricingSheet<Calculation>,
|
|
21
|
+
Adapter extends IPricingAdapter<PricingAdapterContext, Calculation, PricingAdapterSheet>,
|
|
22
|
+
> = IBaseDirector<Adapter> & {
|
|
23
|
+
buildPricingContext: (
|
|
24
|
+
context: PricingContext,
|
|
25
|
+
unchainedAPI: UnchainedCore,
|
|
26
|
+
) => Promise<PricingAdapterContext>;
|
|
27
|
+
actions: (
|
|
28
|
+
pricingContext: PricingContext,
|
|
29
|
+
unchainedAPI: UnchainedCore,
|
|
30
|
+
buildPricingContext?: (
|
|
31
|
+
pricingCtx: PricingContext,
|
|
32
|
+
_unchainedAPI: UnchainedCore,
|
|
33
|
+
) => Promise<PricingAdapterContext>,
|
|
34
|
+
) => Promise<
|
|
35
|
+
IPricingAdapterActions<Calculation, PricingAdapterContext> & {
|
|
36
|
+
calculationSheet: () => PricingAdapterSheet;
|
|
37
|
+
}
|
|
38
|
+
>;
|
|
39
|
+
};
|
|
13
40
|
|
|
14
41
|
export const BasePricingDirector = <
|
|
15
42
|
DirectorContext extends BasePricingContext,
|
|
@@ -61,10 +88,10 @@ export const BasePricingDirector = <
|
|
|
61
88
|
context.discounts.map(async (discount) => ({
|
|
62
89
|
discountId: discount._id,
|
|
63
90
|
configuration: await context.modules.orders.discounts.configurationForPricingAdapterKey(
|
|
64
|
-
discount,
|
|
91
|
+
discount as any,
|
|
65
92
|
Adapter.key,
|
|
66
93
|
this.calculationSheet(),
|
|
67
|
-
context,
|
|
94
|
+
context as any,
|
|
68
95
|
),
|
|
69
96
|
})),
|
|
70
97
|
);
|
|
@@ -1,8 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export interface PricingCalculation {
|
|
2
|
+
category: string;
|
|
3
|
+
amount: number;
|
|
4
|
+
baseCategory?: string;
|
|
5
|
+
meta?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface PricingDiscount {
|
|
8
|
+
discountId: string;
|
|
9
|
+
amount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IPricingSheet<Calculation extends PricingCalculation>
|
|
14
|
+
extends IBasePricingSheet<Calculation> {
|
|
15
|
+
discountPrices: (discountId?: string) => Array<PricingDiscount>;
|
|
16
|
+
addDiscount: (params: { amount: number; discountId: string; meta?: any }) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IBasePricingSheet<Calculation extends PricingCalculation> {
|
|
20
|
+
calculation: Array<Calculation>;
|
|
21
|
+
currency?: string;
|
|
22
|
+
quantity?: number;
|
|
23
|
+
|
|
24
|
+
getRawPricingSheet: () => Array<Calculation>;
|
|
25
|
+
filterBy: (filter?: Partial<Calculation>) => Array<Calculation>;
|
|
26
|
+
isValid: () => boolean;
|
|
27
|
+
|
|
28
|
+
gross: () => number;
|
|
29
|
+
net: () => number;
|
|
30
|
+
sum: (filter?: Partial<Calculation>) => number;
|
|
31
|
+
total: (params?: { category?: string; discountId?: string; useNetPrice?: boolean }) => {
|
|
32
|
+
amount: number;
|
|
33
|
+
currency: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
taxSum: (filter?: Partial<Calculation>) => number;
|
|
37
|
+
|
|
38
|
+
resetCalculation: (sheetToInvert: IBasePricingSheet<Calculation>) => Array<Calculation>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PricingSheetParams<Calculation extends PricingCalculation> {
|
|
42
|
+
calculation?: Array<Calculation>;
|
|
43
|
+
currency?: string;
|
|
44
|
+
quantity?: number;
|
|
45
|
+
}
|
|
6
46
|
|
|
7
47
|
export const BasePricingSheet = <Calculation extends PricingCalculation>(
|
|
8
48
|
params: PricingSheetParams<Calculation>,
|
package/src/locale-helpers.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const { Locales, Locale } = localePkg;
|
|
1
|
+
import { Country } from '@unchainedshop/core-countries';
|
|
2
|
+
import { Currency } from '@unchainedshop/core-currencies';
|
|
3
|
+
import { resolveAcceptLanguage } from 'resolve-accept-language';
|
|
6
4
|
|
|
7
5
|
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH', UNCHAINED_CURRENCY = 'CHF' } = process.env;
|
|
8
6
|
|
|
9
|
-
export const systemLocale = new Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
7
|
+
export const systemLocale = new Intl.Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
10
8
|
|
|
11
9
|
export const resolveBestSupported = (
|
|
12
10
|
acceptLanguage: string,
|
|
13
|
-
supportedLocales:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
supportedLocales: Array<string>,
|
|
12
|
+
fallbackLocale: string,
|
|
13
|
+
): Intl.Locale => {
|
|
14
|
+
const { match } = resolveAcceptLanguage(acceptLanguage || '', supportedLocales, fallbackLocale, {
|
|
15
|
+
returnMatchType: true,
|
|
16
|
+
});
|
|
17
|
+
return new Intl.Locale(match);
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
export const resolveBestCountry = (
|
|
20
|
+
export const resolveBestCountry = (
|
|
21
|
+
localeCountry: string,
|
|
22
|
+
shopCountry: string,
|
|
23
|
+
countries: Array<Country>,
|
|
24
|
+
) => {
|
|
22
25
|
if (shopCountry) {
|
|
23
|
-
const resolvedCountry = countries.reduce((lastResolved, country) => {
|
|
26
|
+
const resolvedCountry = countries.reduce<string>((lastResolved, country) => {
|
|
24
27
|
if (shopCountry === country.isoCode) {
|
|
25
28
|
return country.isoCode;
|
|
26
29
|
}
|
|
@@ -30,10 +33,10 @@ export const resolveBestCountry = (localeCountry, shopCountry, countries) => {
|
|
|
30
33
|
return resolvedCountry;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
return localeCountry || systemLocale.
|
|
36
|
+
return localeCountry || systemLocale.region;
|
|
34
37
|
};
|
|
35
38
|
|
|
36
|
-
export const resolveBestCurrency = (localeCurrency, currencies: Array<Currency>) => {
|
|
39
|
+
export const resolveBestCurrency = (localeCurrency: string, currencies: Array<Currency>) => {
|
|
37
40
|
if (localeCurrency) {
|
|
38
41
|
const resolvedCurrency = currencies.find((currency) => currency.isoCode === localeCurrency);
|
|
39
42
|
if (resolvedCurrency) {
|
package/src/object-invert.ts
CHANGED
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"}
|
package/lib/schemas/index.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import SimpleSchema from 'simpl-schema';
|
|
2
|
-
declare const Schemas: {
|
|
3
|
-
timestampFields: {
|
|
4
|
-
created: {
|
|
5
|
-
type: DateConstructor;
|
|
6
|
-
required: boolean;
|
|
7
|
-
};
|
|
8
|
-
updated: {
|
|
9
|
-
type: DateConstructor;
|
|
10
|
-
};
|
|
11
|
-
deleted: {
|
|
12
|
-
type: DateConstructor;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
contextFields: {
|
|
16
|
-
context: {
|
|
17
|
-
type: ObjectConstructor;
|
|
18
|
-
blackbox: boolean;
|
|
19
|
-
required: boolean;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
logFields: {
|
|
23
|
-
log: ArrayConstructor;
|
|
24
|
-
'log.$': {
|
|
25
|
-
type: ObjectConstructor;
|
|
26
|
-
};
|
|
27
|
-
'log.$.date': {
|
|
28
|
-
type: DateConstructor;
|
|
29
|
-
};
|
|
30
|
-
'log.$.status': {
|
|
31
|
-
type: StringConstructor;
|
|
32
|
-
};
|
|
33
|
-
'log.$.info': {
|
|
34
|
-
type: StringConstructor;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
Address: SimpleSchema;
|
|
38
|
-
Contact: SimpleSchema;
|
|
39
|
-
User: SimpleSchema;
|
|
40
|
-
};
|
|
41
|
-
export { Schemas };
|
|
42
|
-
export type { SimpleSchema };
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAMxC,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOZ,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
package/lib/schemas/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { timestampFields, contextFields, logFields } from './commonSchemaFields.js';
|
|
2
|
-
import { AddressSchema } from './AddressSchema.js';
|
|
3
|
-
import { ContactSchema } from './ContactSchema.js';
|
|
4
|
-
import { UserSchema } from './UsersSchema.js';
|
|
5
|
-
const Schemas = {
|
|
6
|
-
timestampFields,
|
|
7
|
-
contextFields,
|
|
8
|
-
logFields,
|
|
9
|
-
Address: AddressSchema,
|
|
10
|
-
Contact: ContactSchema,
|
|
11
|
-
User: UserSchema,
|
|
12
|
-
};
|
|
13
|
-
export { Schemas };
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/lib/schemas/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG;IACd,eAAe;IACf,aAAa;IACb,SAAS;IACT,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import SimpleSchema from 'simpl-schema';
|
|
2
|
-
|
|
3
|
-
export const AddressSchema = new SimpleSchema(
|
|
4
|
-
{
|
|
5
|
-
firstName: String,
|
|
6
|
-
lastName: String,
|
|
7
|
-
company: String,
|
|
8
|
-
addressLine: String,
|
|
9
|
-
addressLine2: String,
|
|
10
|
-
city: String,
|
|
11
|
-
postalCode: String,
|
|
12
|
-
regionCode: String,
|
|
13
|
-
countryCode: String,
|
|
14
|
-
},
|
|
15
|
-
{ requiredByDefault: false },
|
|
16
|
-
);
|