@unchainedshop/core 3.0.0-rc1 → 3.0.0-rc11
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/directors/BaseDiscountAdapter.d.ts +9 -11
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/BaseDiscountAdapter.js.map +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts +7 -4
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
- package/lib/directors/BaseDiscountDirector.js.map +1 -1
- package/lib/directors/BasePricingAdapter.d.ts +1 -6
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
- package/lib/directors/BasePricingAdapter.js.map +1 -1
- package/lib/directors/BasePricingDirector.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.js +1 -1
- package/lib/directors/BasePricingDirector.js.map +1 -1
- package/lib/directors/EnrollmentAdapter.d.ts +1 -1
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
- package/lib/directors/EnrollmentAdapter.js +2 -2
- package/lib/directors/EnrollmentAdapter.js.map +1 -1
- package/lib/directors/FilterDirector.d.ts.map +1 -1
- package/lib/directors/FilterDirector.js +11 -7
- package/lib/directors/FilterDirector.js.map +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/OrderDiscountDirector.d.ts +1 -1
- package/lib/directors/OrderDiscountDirector.d.ts.map +1 -1
- package/lib/directors/OrderDiscountDirector.js.map +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/ProductDiscountDirector.d.ts +1 -1
- package/lib/directors/ProductDiscountDirector.d.ts.map +1 -1
- package/lib/directors/ProductDiscountDirector.js.map +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts +2 -0
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
- package/lib/directors/ProductPricingAdapter.js.map +1 -1
- package/lib/directors/ProductPricingSheet.d.ts +2 -5
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
- package/lib/directors/ProductPricingSheet.js.map +1 -1
- package/lib/directors/WarehousingDirector.d.ts +4 -1
- package/lib/directors/WarehousingDirector.d.ts.map +1 -1
- package/lib/directors/WarehousingDirector.js.map +1 -1
- package/lib/modules.d.ts +0 -2
- package/lib/modules.d.ts.map +1 -1
- package/lib/modules.js +0 -6
- package/lib/modules.js.map +1 -1
- package/lib/services/activateEnrollment.js +1 -1
- package/lib/services/activateEnrollment.js.map +1 -1
- package/lib/services/deleteUser.js +2 -2
- package/lib/services/deleteUser.js.map +1 -1
- package/lib/services/findOrInitCart.d.ts +9 -0
- package/lib/services/findOrInitCart.d.ts.map +1 -0
- package/lib/services/findOrInitCart.js +15 -0
- package/lib/services/findOrInitCart.js.map +1 -0
- package/lib/services/index.d.ts +9 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +8 -0
- package/lib/services/index.js.map +1 -1
- package/lib/services/initializeEnrollment.js +1 -1
- package/lib/services/initializeEnrollment.js.map +1 -1
- package/lib/services/loadFilterOptions.d.ts.map +1 -1
- package/lib/services/loadFilterOptions.js +1 -2
- package/lib/services/loadFilterOptions.js.map +1 -1
- package/lib/services/loadFilters.js +2 -2
- package/lib/services/loadFilters.js.map +1 -1
- package/lib/services/migrateOrderCart.js +2 -2
- package/lib/services/migrateOrderCart.js.map +1 -1
- package/lib/services/nextUserCart.d.ts +1 -1
- package/lib/services/nextUserCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.js +1 -1
- package/lib/services/nextUserCart.js.map +1 -1
- package/lib/services/processQuotation.js +1 -1
- package/lib/services/processQuotation.js.map +1 -1
- package/lib/services/simulateProductDispatching.d.ts +15 -0
- package/lib/services/simulateProductDispatching.d.ts.map +1 -0
- package/lib/services/simulateProductDispatching.js +30 -0
- package/lib/services/simulateProductDispatching.js.map +1 -0
- package/lib/services/simulateProductInventory.d.ts +15 -0
- package/lib/services/simulateProductInventory.d.ts.map +1 -0
- package/lib/services/simulateProductInventory.js +29 -0
- package/lib/services/simulateProductInventory.js.map +1 -0
- package/lib/services/simulateProductPricing.d.ts +12 -0
- package/lib/services/simulateProductPricing.d.ts.map +1 -0
- package/lib/services/simulateProductPricing.js +8 -0
- package/lib/services/simulateProductPricing.js.map +1 -0
- package/lib/services/terminateEnrollment.js +1 -1
- package/lib/services/terminateEnrollment.js.map +1 -1
- package/package.json +24 -23
- package/src/directors/BaseDiscountAdapter.ts +7 -8
- package/src/directors/BaseDiscountDirector.ts +8 -7
- package/src/directors/BasePricingAdapter.ts +1 -3
- package/src/directors/BasePricingDirector.ts +3 -2
- package/src/directors/EnrollmentAdapter.ts +7 -3
- package/src/directors/FilterDirector.ts +11 -7
- package/src/directors/OrderDiscountAdapter.ts +1 -1
- package/src/directors/OrderDiscountDirector.ts +2 -3
- package/src/directors/ProductDiscountAdapter.ts +1 -1
- package/src/directors/ProductDiscountDirector.ts +2 -3
- package/src/directors/ProductPricingAdapter.ts +2 -0
- package/src/directors/ProductPricingSheet.ts +2 -5
- package/src/directors/WarehousingDirector.ts +2 -1
- package/src/modules.ts +0 -7
- package/src/services/activateEnrollment.ts +1 -1
- package/src/services/deleteUser.ts +2 -2
- package/src/services/findOrInitCart.ts +29 -0
- package/src/services/index.ts +15 -1
- package/src/services/initializeEnrollment.ts +1 -1
- package/src/services/loadFilterOptions.ts +1 -2
- package/src/services/loadFilters.ts +2 -2
- package/src/services/migrateOrderCart.ts +2 -2
- package/src/services/nextUserCart.ts +2 -2
- package/src/services/processQuotation.ts +1 -1
- package/src/services/simulateProductDispatching.ts +59 -0
- package/src/services/simulateProductInventory.ts +56 -0
- package/src/services/simulateProductPricing.ts +20 -0
- package/src/services/terminateEnrollment.ts +1 -1
- package/lib/core-index_BACKUP_57582.d.ts +0 -26
- package/lib/core-index_BACKUP_57582.d.ts.map +0 -1
- package/lib/core-index_BACKUP_57582.js +0 -30
- package/lib/core-index_BACKUP_57582.js.map +0 -1
- package/lib/core-index_BASE_57582.d.ts +0 -74
- package/lib/core-index_BASE_57582.d.ts.map +0 -1
- package/lib/core-index_BASE_57582.js +0 -145
- package/lib/core-index_BASE_57582.js.map +0 -1
- package/lib/core-index_LOCAL_57582.d.ts +0 -26
- package/lib/core-index_LOCAL_57582.d.ts.map +0 -1
- package/lib/core-index_LOCAL_57582.js +0 -31
- package/lib/core-index_LOCAL_57582.js.map +0 -1
- package/lib/core-index_REMOTE_57582.d.ts +0 -74
- package/lib/core-index_REMOTE_57582.d.ts.map +0 -1
- package/lib/core-index_REMOTE_57582.js +0 -146
- package/lib/core-index_REMOTE_57582.js.map +0 -1
- package/lib/services/createDownloadStreamService.d.ts +0 -11
- package/lib/services/createDownloadStreamService.d.ts.map +0 -1
- package/lib/services/createDownloadStreamService.js +0 -9
- package/lib/services/createDownloadStreamService.js.map +0 -1
- package/lib/services/createSignedURLService.d.ts +0 -13
- package/lib/services/createSignedURLService.d.ts.map +0 -1
- package/lib/services/createSignedURLService.js +0 -14
- package/lib/services/createSignedURLService.js.map +0 -1
- package/lib/services/deleteUserCartService.d.ts +0 -6
- package/lib/services/deleteUserCartService.d.ts.map +0 -1
- package/lib/services/deleteUserCartService.js +0 -20
- package/lib/services/deleteUserCartService.js.map +0 -1
- package/lib/services/deleteUserCarts.d.ts +0 -5
- package/lib/services/deleteUserCarts.d.ts.map +0 -1
- package/lib/services/deleteUserCarts.js +0 -18
- package/lib/services/deleteUserCarts.js.map +0 -1
- package/lib/services/deleteUserCartsService.d.ts +0 -5
- package/lib/services/deleteUserCartsService.d.ts.map +0 -1
- package/lib/services/deleteUserCartsService.js +0 -18
- package/lib/services/deleteUserCartsService.js.map +0 -1
- package/lib/services/index_BACKUP_58089.d.ts +0 -246
- package/lib/services/index_BACKUP_58089.d.ts.map +0 -1
- package/lib/services/index_BACKUP_58089.js +0 -103
- package/lib/services/index_BACKUP_58089.js.map +0 -1
- package/lib/services/index_BASE_58089.d.ts +0 -31
- package/lib/services/index_BASE_58089.d.ts.map +0 -1
- package/lib/services/index_BASE_58089.js +0 -42
- package/lib/services/index_BASE_58089.js.map +0 -1
- package/lib/services/index_LOCAL_58089.d.ts +0 -246
- package/lib/services/index_LOCAL_58089.d.ts.map +0 -1
- package/lib/services/index_LOCAL_58089.js +0 -103
- package/lib/services/index_LOCAL_58089.js.map +0 -1
- package/lib/services/index_REMOTE_58089.d.ts +0 -34
- package/lib/services/index_REMOTE_58089.d.ts.map +0 -1
- package/lib/services/index_REMOTE_58089.js +0 -44
- package/lib/services/index_REMOTE_58089.js.map +0 -1
- package/lib/services/migrateBookmarksService.d.ts +0 -13
- package/lib/services/migrateBookmarksService.d.ts.map +0 -1
- package/lib/services/migrateBookmarksService.js +0 -26
- package/lib/services/migrateBookmarksService.js.map +0 -1
- package/lib/services/migrateOrderCartService.d.ts +0 -23
- package/lib/services/migrateOrderCartService.d.ts.map +0 -1
- package/lib/services/migrateOrderCartService.js +0 -32
- package/lib/services/migrateOrderCartService.js.map +0 -1
- package/lib/services/migrateUserDataService.d.ts +0 -19
- package/lib/services/migrateUserDataService.d.ts.map +0 -1
- package/lib/services/migrateUserDataService.js +0 -18
- package/lib/services/migrateUserDataService.js.map +0 -1
- package/lib/services/nextUserCartService.d.ts +0 -22
- package/lib/services/nextUserCartService.d.ts.map +0 -1
- package/lib/services/nextUserCartService.js +0 -35
- package/lib/services/nextUserCartService.js.map +0 -1
- package/lib/services/removeFilesService.d.ts +0 -10
- package/lib/services/removeFilesService.d.ts.map +0 -1
- package/lib/services/removeFilesService.js +0 -20
- package/lib/services/removeFilesService.js.map +0 -1
- package/lib/services/removeProductService.d.ts +0 -20
- package/lib/services/removeProductService.d.ts.map +0 -1
- package/lib/services/removeProductService.js +0 -27
- package/lib/services/removeProductService.js.map +0 -1
- package/lib/services/updateCalculationService.d.ts +0 -17
- package/lib/services/updateCalculationService.d.ts.map +0 -1
- package/lib/services/updateCalculationService.js +0 -68
- package/lib/services/updateCalculationService.js.map +0 -1
- package/lib/services/updateUserAvatarAfterUploadService.d.ts +0 -18
- package/lib/services/updateUserAvatarAfterUploadService.d.ts.map +0 -1
- package/lib/services/updateUserAvatarAfterUploadService.js +0 -25
- package/lib/services/updateUserAvatarAfterUploadService.js.map +0 -1
- package/lib/services/uploadFileFromStreamService.d.ts +0 -12
- package/lib/services/uploadFileFromStreamService.d.ts.map +0 -1
- package/lib/services/uploadFileFromStreamService.js +0 -10
- package/lib/services/uploadFileFromStreamService.js.map +0 -1
- package/lib/services/uploadFileFromURLService.d.ts +0 -17
- package/lib/services/uploadFileFromURLService.d.ts.map +0 -1
- package/lib/services/uploadFileFromURLService.js +0 -10
- package/lib/services/uploadFileFromURLService.js.map +0 -1
- package/lib/types.d.ts +0 -4
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc11",
|
|
4
4
|
"main": "lib/core-index.js",
|
|
5
5
|
"types": "lib/core-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
"ecommerce",
|
|
22
22
|
"core"
|
|
23
23
|
],
|
|
24
|
-
"
|
|
24
|
+
"authors": [
|
|
25
|
+
"Joël Meiller",
|
|
26
|
+
"Pascal Kaufmann"
|
|
27
|
+
],
|
|
25
28
|
"license": "EUPL-1.2",
|
|
26
29
|
"bugs": {
|
|
27
30
|
"url": "https://github.com/unchainedshop/unchained/issues"
|
|
@@ -29,27 +32,25 @@
|
|
|
29
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
30
33
|
"dependencies": {
|
|
31
34
|
"@breejs/later": "^4.2.0",
|
|
32
|
-
"@unchainedshop/core-assortments": "^3.0.0-
|
|
33
|
-
"@unchainedshop/core-bookmarks": "^3.0.0-
|
|
34
|
-
"@unchainedshop/core-countries": "^3.0.0-
|
|
35
|
-
"@unchainedshop/core-currencies": "^3.0.0-
|
|
36
|
-
"@unchainedshop/core-delivery": "^3.0.0-
|
|
37
|
-
"@unchainedshop/core-enrollments": "^3.0.0-
|
|
38
|
-
"@unchainedshop/core-events": "^3.0.0-
|
|
39
|
-
"@unchainedshop/core-files": "^3.0.0-
|
|
40
|
-
"@unchainedshop/core-filters": "^3.0.0-
|
|
41
|
-
"@unchainedshop/core-languages": "^3.0.0-
|
|
42
|
-
"@unchainedshop/core-
|
|
43
|
-
"@unchainedshop/core-
|
|
44
|
-
"@unchainedshop/core-
|
|
45
|
-
"@unchainedshop/core-
|
|
46
|
-
"@unchainedshop/core-
|
|
47
|
-
"@unchainedshop/core-
|
|
48
|
-
"@unchainedshop/core-
|
|
49
|
-
"@unchainedshop/
|
|
50
|
-
"@unchainedshop/
|
|
51
|
-
"@unchainedshop/utils": "^3.0.0-rc1",
|
|
52
|
-
"date-fns": "^4.1.0"
|
|
35
|
+
"@unchainedshop/core-assortments": "^3.0.0-rc11",
|
|
36
|
+
"@unchainedshop/core-bookmarks": "^3.0.0-rc11",
|
|
37
|
+
"@unchainedshop/core-countries": "^3.0.0-rc11",
|
|
38
|
+
"@unchainedshop/core-currencies": "^3.0.0-rc11",
|
|
39
|
+
"@unchainedshop/core-delivery": "^3.0.0-rc11",
|
|
40
|
+
"@unchainedshop/core-enrollments": "^3.0.0-rc11",
|
|
41
|
+
"@unchainedshop/core-events": "^3.0.0-rc11",
|
|
42
|
+
"@unchainedshop/core-files": "^3.0.0-rc11",
|
|
43
|
+
"@unchainedshop/core-filters": "^3.0.0-rc11",
|
|
44
|
+
"@unchainedshop/core-languages": "^3.0.0-rc11",
|
|
45
|
+
"@unchainedshop/core-orders": "^3.0.0-rc11",
|
|
46
|
+
"@unchainedshop/core-payment": "^3.0.0-rc11",
|
|
47
|
+
"@unchainedshop/core-products": "^3.0.0-rc11",
|
|
48
|
+
"@unchainedshop/core-quotations": "^3.0.0-rc11",
|
|
49
|
+
"@unchainedshop/core-users": "^3.0.0-rc11",
|
|
50
|
+
"@unchainedshop/core-warehousing": "^3.0.0-rc11",
|
|
51
|
+
"@unchainedshop/core-worker": "^3.0.0-rc11",
|
|
52
|
+
"@unchainedshop/logger": "^3.0.0-rc11",
|
|
53
|
+
"@unchainedshop/utils": "^3.0.0-rc11"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/node": "^22.10.2",
|
|
@@ -2,20 +2,22 @@ import { log, LogLevel } from '@unchainedshop/logger';
|
|
|
2
2
|
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
3
3
|
import { IPricingSheet } from './BasePricingSheet.js';
|
|
4
4
|
import { PricingCalculation } from '@unchainedshop/utils';
|
|
5
|
+
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
6
|
+
import { Modules } from '../modules.js';
|
|
5
7
|
export interface DiscountContext {
|
|
6
8
|
code?: string;
|
|
7
|
-
orderDiscount?:
|
|
8
|
-
order?:
|
|
9
|
+
orderDiscount?: OrderDiscount;
|
|
10
|
+
order?: Order;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export type IDiscountAdapter<DiscountConfiguration
|
|
13
|
+
export type IDiscountAdapter<DiscountConfiguration> = IBaseAdapter & {
|
|
12
14
|
orderIndex: number;
|
|
13
15
|
|
|
14
16
|
isManualAdditionAllowed: (code: string) => Promise<boolean>;
|
|
15
17
|
isManualRemovalAllowed: () => Promise<boolean>;
|
|
16
18
|
|
|
17
19
|
actions: (params: {
|
|
18
|
-
context: DiscountContext &
|
|
20
|
+
context: DiscountContext & { modules: Modules };
|
|
19
21
|
}) => Promise<DiscountAdapterActions<DiscountConfiguration>>;
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -32,10 +34,7 @@ export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
|
32
34
|
release: () => Promise<void>;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
export const BaseDiscountAdapter: Omit<
|
|
36
|
-
IDiscountAdapter<unknown, unknown>,
|
|
37
|
-
'key' | 'label' | 'version'
|
|
38
|
-
> = {
|
|
37
|
+
export const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label' | 'version'> = {
|
|
39
38
|
orderIndex: 0,
|
|
40
39
|
|
|
41
40
|
isManualAdditionAllowed: async () => {
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.js';
|
|
3
|
+
import { Modules } from '../modules.js';
|
|
3
4
|
|
|
4
|
-
export type IDiscountDirector<DiscountConfiguration
|
|
5
|
-
IDiscountAdapter<DiscountConfiguration
|
|
5
|
+
export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<
|
|
6
|
+
IDiscountAdapter<DiscountConfiguration>
|
|
6
7
|
> & {
|
|
7
8
|
actions: (
|
|
8
9
|
discountContext: DiscountContext,
|
|
9
|
-
unchainedAPI:
|
|
10
|
+
unchainedAPI: { modules: Modules },
|
|
10
11
|
) => Promise<{
|
|
11
12
|
resolveDiscountAdapterFromStaticCode: (params: {
|
|
12
13
|
code: string;
|
|
13
|
-
}) => Promise<IDiscountAdapter<DiscountConfiguration
|
|
14
|
+
}) => Promise<IDiscountAdapter<DiscountConfiguration>>;
|
|
14
15
|
findSystemDiscounts: () => Promise<Array<string>>;
|
|
15
16
|
}>;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export const BaseDiscountDirector = <DiscountConfigurationType
|
|
19
|
+
export const BaseDiscountDirector = <DiscountConfigurationType>(
|
|
19
20
|
directorName: string,
|
|
20
|
-
): IDiscountDirector<DiscountConfigurationType
|
|
21
|
-
const baseDirector = BaseDirector<IDiscountAdapter<DiscountConfigurationType
|
|
21
|
+
): IDiscountDirector<DiscountConfigurationType> => {
|
|
22
|
+
const baseDirector = BaseDirector<IDiscountAdapter<DiscountConfigurationType>>(directorName, {
|
|
22
23
|
adapterSortKey: 'orderIndex',
|
|
23
24
|
});
|
|
24
25
|
|
|
@@ -2,12 +2,10 @@ import { createLogger } from '@unchainedshop/logger';
|
|
|
2
2
|
import { IPricingSheet } from './BasePricingSheet.js';
|
|
3
3
|
import { IBaseAdapter, PricingCalculation } from '@unchainedshop/utils';
|
|
4
4
|
import { Discount } from './BasePricingDirector.js';
|
|
5
|
+
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
6
|
|
|
6
7
|
const logger = createLogger('unchained:core');
|
|
7
8
|
|
|
8
|
-
type Order = { _id?: string };
|
|
9
|
-
type OrderDiscount = { _id?: string };
|
|
10
|
-
|
|
11
9
|
interface IDiscountableItem {
|
|
12
10
|
_id?: string;
|
|
13
11
|
orderId?: string;
|
|
@@ -73,7 +73,7 @@ export const BasePricingDirector = <
|
|
|
73
73
|
throw new Error('Method not implemented');
|
|
74
74
|
},
|
|
75
75
|
|
|
76
|
-
async rebuildCalculation(pricingContext, unchainedAPI) {
|
|
76
|
+
async rebuildCalculation(this: typeof director, pricingContext, unchainedAPI) {
|
|
77
77
|
const context = await this.buildPricingContext(pricingContext, unchainedAPI);
|
|
78
78
|
|
|
79
79
|
let calculation: Array<Calculation> = [];
|
|
@@ -95,6 +95,7 @@ export const BasePricingDirector = <
|
|
|
95
95
|
});
|
|
96
96
|
const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
97
97
|
if (!DiscountAdapter) return null;
|
|
98
|
+
|
|
98
99
|
const adapter = await DiscountAdapter.actions({
|
|
99
100
|
context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
|
|
100
101
|
});
|
|
@@ -115,7 +116,7 @@ export const BasePricingDirector = <
|
|
|
115
116
|
const adapter = Adapter.actions({
|
|
116
117
|
context,
|
|
117
118
|
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
118
|
-
discounts: discounts.filter((
|
|
119
|
+
discounts: discounts.filter((d) => d?.configuration !== null),
|
|
119
120
|
});
|
|
120
121
|
|
|
121
122
|
const nextCalculationResult = await adapter.calculate();
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
2
2
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Enrollment,
|
|
5
|
+
EnrollmentPeriod,
|
|
6
|
+
EnrollmentPlan,
|
|
7
|
+
addToDate,
|
|
8
|
+
} from '@unchainedshop/core-enrollments';
|
|
5
9
|
import type { Product, ProductPlan } from '@unchainedshop/core-products';
|
|
6
10
|
import type { OrderPosition } from '@unchainedshop/core-orders';
|
|
7
11
|
|
|
@@ -41,7 +45,7 @@ export const periodForReferenceDate = (referenceDate: Date, intervalCount = 1, i
|
|
|
41
45
|
|
|
42
46
|
return {
|
|
43
47
|
start,
|
|
44
|
-
end:
|
|
48
|
+
end: addToDate(start, {
|
|
45
49
|
[lowerCaseInterval]: intervalCount,
|
|
46
50
|
}),
|
|
47
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { BaseDirector, IBaseDirector
|
|
2
|
+
import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
|
|
3
3
|
import { FilterAdapterActions, FilterContext, IFilterAdapter } from './FilterAdapter.js';
|
|
4
4
|
import {
|
|
5
5
|
Filter,
|
|
@@ -185,10 +185,14 @@ export const FilterDirector: IFilterDirector = {
|
|
|
185
185
|
values,
|
|
186
186
|
Object.keys(keyToProductIdMap),
|
|
187
187
|
);
|
|
188
|
-
|
|
188
|
+
const result = [];
|
|
189
|
+
for (const key of filteredKeys) {
|
|
189
190
|
const additionalValues = key === undefined ? allProductIds : keyToProductIdMap[key];
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
if (additionalValues) {
|
|
192
|
+
result.push(...additionalValues);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
192
196
|
},
|
|
193
197
|
|
|
194
198
|
async productFacetedSearch(
|
|
@@ -227,7 +231,7 @@ export const FilterDirector: IFilterDirector = {
|
|
|
227
231
|
unchainedAPI,
|
|
228
232
|
);
|
|
229
233
|
|
|
230
|
-
return
|
|
234
|
+
return productIdSet.intersection(new Set(filterOptionProductIds));
|
|
231
235
|
},
|
|
232
236
|
Promise.resolve(new Set(productIds)),
|
|
233
237
|
);
|
|
@@ -252,7 +256,7 @@ export const FilterDirector: IFilterDirector = {
|
|
|
252
256
|
unchainedAPI,
|
|
253
257
|
);
|
|
254
258
|
|
|
255
|
-
const examinedProductIdSet =
|
|
259
|
+
const examinedProductIdSet = new Set(allProductIds).intersection(new Set(filteredProductIds));
|
|
256
260
|
const values = filterQueryParsed[filter.key];
|
|
257
261
|
|
|
258
262
|
// The filteredProductIdSet is a set of product id's that:
|
|
@@ -275,7 +279,7 @@ export const FilterDirector: IFilterDirector = {
|
|
|
275
279
|
},
|
|
276
280
|
unchainedAPI,
|
|
277
281
|
);
|
|
278
|
-
return
|
|
282
|
+
return productIdSet.intersection(new Set(otherFilterProductIds));
|
|
279
283
|
},
|
|
280
284
|
Promise.resolve(new Set(examinedProductIdSet)),
|
|
281
285
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseDiscountDirector } from './BaseDiscountDirector.js';
|
|
2
2
|
import { OrderDiscountConfiguration } from './OrderDiscountConfiguration.js';
|
|
3
3
|
|
|
4
|
-
export const OrderDiscountDirector =
|
|
5
|
-
'OrderDiscountDirector'
|
|
6
|
-
);
|
|
4
|
+
export const OrderDiscountDirector =
|
|
5
|
+
BaseDiscountDirector<OrderDiscountConfiguration>('OrderDiscountDirector');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseDiscountDirector, ProductDiscountConfiguration } from '../directors/index.js';
|
|
2
2
|
|
|
3
|
-
export const ProductDiscountDirector =
|
|
4
|
-
'ProductDiscountDirector'
|
|
5
|
-
);
|
|
3
|
+
export const ProductDiscountDirector =
|
|
4
|
+
BaseDiscountDirector<ProductDiscountConfiguration>('ProductDiscountDirector');
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
IPricingAdapter,
|
|
10
10
|
} from '../directors/index.js';
|
|
11
11
|
import { Modules } from '../modules.js';
|
|
12
|
+
import { User } from '@unchainedshop/core-users';
|
|
12
13
|
|
|
13
14
|
export interface ProductPricingAdapterContext extends BasePricingAdapterContext {
|
|
14
15
|
country: string;
|
|
@@ -17,6 +18,7 @@ export interface ProductPricingAdapterContext extends BasePricingAdapterContext
|
|
|
17
18
|
quantity: number;
|
|
18
19
|
configuration: Array<ProductConfiguration>;
|
|
19
20
|
order?: Order;
|
|
21
|
+
user?: User;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type IProductPricingAdapter<DiscountConfiguration = unknown> = IPricingAdapter<
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PricingCalculation } from '@unchainedshop/utils';
|
|
1
|
+
import { Price, PricingCalculation } from '@unchainedshop/utils';
|
|
2
2
|
|
|
3
3
|
import { BasePricingSheet, IPricingSheet, PricingSheetParams } from '../directors/index.js';
|
|
4
4
|
|
|
@@ -33,10 +33,7 @@ export interface IProductPricingSheet extends IPricingSheet<ProductPricingCalcul
|
|
|
33
33
|
meta?: any;
|
|
34
34
|
}) => void;
|
|
35
35
|
|
|
36
|
-
unitPrice: (params?: { useNetPrice: boolean }) =>
|
|
37
|
-
amount: number;
|
|
38
|
-
currency: string;
|
|
39
|
-
};
|
|
36
|
+
unitPrice: (params?: { useNetPrice: boolean }) => Price;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
export const ProductPricingSheet = (
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
WarehousingContext,
|
|
11
11
|
WarehousingError,
|
|
12
12
|
} from '../directors/index.js';
|
|
13
|
+
import { Modules } from '../modules.js';
|
|
13
14
|
|
|
14
15
|
export type EstimatedDispatch = {
|
|
15
16
|
shipping?: Date;
|
|
@@ -40,7 +41,7 @@ export type IWarehousingDirector = IBaseDirector<IWarehousingAdapter> & {
|
|
|
40
41
|
actions: (
|
|
41
42
|
warehousingProvider: WarehousingProvider,
|
|
42
43
|
warehousingContext: WarehousingContext,
|
|
43
|
-
unchainedAPI,
|
|
44
|
+
unchainedAPI: { modules: Modules },
|
|
44
45
|
) => Promise<{
|
|
45
46
|
configurationError: () => WarehousingError;
|
|
46
47
|
isActive: () => boolean;
|
package/src/modules.ts
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
FiltersSettingsOptions,
|
|
25
25
|
} from '@unchainedshop/core-filters';
|
|
26
26
|
import { configureLanguagesModule, LanguagesModule } from '@unchainedshop/core-languages';
|
|
27
|
-
import { configureMessagingModule, MessagingModule } from '@unchainedshop/core-messaging';
|
|
28
27
|
import { configureOrdersModule, OrdersModule, OrdersSettingsOptions } from '@unchainedshop/core-orders';
|
|
29
28
|
import {
|
|
30
29
|
configurePaymentModule,
|
|
@@ -57,7 +56,6 @@ export interface Modules {
|
|
|
57
56
|
files: FilesModule;
|
|
58
57
|
filters: FiltersModule;
|
|
59
58
|
languages: LanguagesModule;
|
|
60
|
-
messaging: MessagingModule;
|
|
61
59
|
orders: OrdersModule;
|
|
62
60
|
payment: PaymentModule;
|
|
63
61
|
products: ProductsModule;
|
|
@@ -143,10 +141,6 @@ const initModules = async (
|
|
|
143
141
|
db,
|
|
144
142
|
migrationRepository,
|
|
145
143
|
});
|
|
146
|
-
const messaging = await configureMessagingModule({
|
|
147
|
-
db,
|
|
148
|
-
migrationRepository,
|
|
149
|
-
});
|
|
150
144
|
const orders = await configureOrdersModule({
|
|
151
145
|
db,
|
|
152
146
|
options: options.orders,
|
|
@@ -192,7 +186,6 @@ const initModules = async (
|
|
|
192
186
|
files,
|
|
193
187
|
filters,
|
|
194
188
|
languages,
|
|
195
|
-
messaging,
|
|
196
189
|
orders,
|
|
197
190
|
payment,
|
|
198
191
|
products,
|
|
@@ -11,13 +11,13 @@ export async function deleteUserService(this: Modules, { userId }: { userId: str
|
|
|
11
11
|
|
|
12
12
|
const carts = await this.orders.findOrders({ userId, status: null });
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
await Array.fromAsync(carts, async (userCart) => {
|
|
15
15
|
await this.orders.positions.deleteOrderPositions(userCart?._id);
|
|
16
16
|
await this.orders.payments.deleteOrderPayments(userCart?._id);
|
|
17
17
|
await this.orders.deliveries.deleteOrderDeliveries(userCart?._id);
|
|
18
18
|
await this.orders.discounts.deleteOrderDiscounts(userCart?._id);
|
|
19
19
|
await this.orders.delete(userCart?._id);
|
|
20
|
-
}
|
|
20
|
+
});
|
|
21
21
|
|
|
22
22
|
const ordersCount = await this.orders.count({ userId, includeCarts: true });
|
|
23
23
|
const quotationsCount = await this.quotations.count({ userId });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { User } from '@unchainedshop/core-users';
|
|
2
|
+
import { Order } from '@unchainedshop/core-orders';
|
|
3
|
+
import { Modules } from '../modules.js';
|
|
4
|
+
import { nextUserCartService } from './nextUserCart.js';
|
|
5
|
+
|
|
6
|
+
export async function findOrInitCartService(
|
|
7
|
+
this: Modules,
|
|
8
|
+
{
|
|
9
|
+
user,
|
|
10
|
+
countryCode,
|
|
11
|
+
orderId,
|
|
12
|
+
}: {
|
|
13
|
+
user: User;
|
|
14
|
+
countryCode: string;
|
|
15
|
+
orderId?: string;
|
|
16
|
+
},
|
|
17
|
+
) {
|
|
18
|
+
if (orderId) {
|
|
19
|
+
const order = await this.orders.findOrder({ orderId });
|
|
20
|
+
if (!order) return null;
|
|
21
|
+
return order;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return nextUserCartService.bind(this)({
|
|
25
|
+
user,
|
|
26
|
+
countryCode,
|
|
27
|
+
forceCartCreation: true,
|
|
28
|
+
}) as Order;
|
|
29
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Modules } from '../modules.js';
|
|
1
2
|
import { migrateUserDataService } from './migrateUserData.js';
|
|
2
3
|
import { updateUserAvatarAfterUploadService } from './updateUserAvatarAfterUpload.js';
|
|
3
4
|
import { linkFileService } from './linkFileService.js';
|
|
@@ -39,7 +40,10 @@ import { verifyQuotationService } from './verifyQuotation.js';
|
|
|
39
40
|
import { loadFiltersService } from './loadFilters.js';
|
|
40
41
|
import { loadFilterOptionsService } from './loadFilterOptions.js';
|
|
41
42
|
import { ercMetadataService } from './ercMetadata.js';
|
|
42
|
-
import {
|
|
43
|
+
import { simulateProductPricingService } from './simulateProductPricing.js';
|
|
44
|
+
import { simulateProductDispatchingService } from './simulateProductDispatching.js';
|
|
45
|
+
import { simulateProductInventoryService } from './simulateProductInventory.js';
|
|
46
|
+
import { findOrInitCartService } from './findOrInitCart.js';
|
|
43
47
|
|
|
44
48
|
// TODO: Auto-Inject Unchained API as last parameter
|
|
45
49
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
|
@@ -89,6 +93,7 @@ export default function initServices(
|
|
|
89
93
|
>,
|
|
90
94
|
migrateOrderCarts: migrateOrderCartsService as Bound<typeof migrateOrderCartsService>,
|
|
91
95
|
nextUserCart: nextUserCartService as Bound<typeof nextUserCartService>,
|
|
96
|
+
findOrInitCart: findOrInitCartService as Bound<typeof findOrInitCartService>,
|
|
92
97
|
initCartProviders: initCartProvidersService as Bound<typeof initCartProvidersService>,
|
|
93
98
|
updateCalculation: updateCalculationService as Bound<typeof updateCalculationService>,
|
|
94
99
|
supportedDeliveryProviders: supportedDeliveryProvidersService as Bound<
|
|
@@ -110,6 +115,15 @@ export default function initServices(
|
|
|
110
115
|
>,
|
|
111
116
|
},
|
|
112
117
|
products: {
|
|
118
|
+
simulateProductPricing: simulateProductPricingService as Bound<
|
|
119
|
+
typeof simulateProductPricingService
|
|
120
|
+
>,
|
|
121
|
+
simulateProductDispatching: simulateProductDispatchingService as Bound<
|
|
122
|
+
typeof simulateProductDispatchingService
|
|
123
|
+
>,
|
|
124
|
+
simulateProductInventory: simulateProductInventoryService as Bound<
|
|
125
|
+
typeof simulateProductInventoryService
|
|
126
|
+
>,
|
|
113
127
|
removeProduct: removeProductService as Bound<typeof removeProductService>,
|
|
114
128
|
},
|
|
115
129
|
users: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FilterType, Filter, SearchQuery } from '@unchainedshop/core-filters';
|
|
2
|
-
import { intersectSet } from '@unchainedshop/utils';
|
|
3
2
|
import { Modules } from '../modules.js';
|
|
4
3
|
import { FilterDirector, parseQueryArray } from '../directors/FilterDirector.js';
|
|
5
4
|
|
|
@@ -28,7 +27,7 @@ export async function loadFilterOptionsService(
|
|
|
28
27
|
},
|
|
29
28
|
{ modules: this },
|
|
30
29
|
);
|
|
31
|
-
const filteredProductIdSet =
|
|
30
|
+
const filteredProductIdSet = productIdSet.intersection(new Set(filterOptionProductIds));
|
|
32
31
|
|
|
33
32
|
const normalizedValues = values && this.filters.parse(filter, values, [value]);
|
|
34
33
|
const isSelected = normalizedValues && normalizedValues.indexOf(value) !== -1;
|
|
@@ -19,7 +19,7 @@ export async function loadFiltersService(
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const extractedFilterIds = (filterSelector?._id as any)?.$in || [];
|
|
22
|
-
const sortedFilters = otherFilters.
|
|
22
|
+
const sortedFilters = otherFilters.toSorted((left, right) => {
|
|
23
23
|
const leftIndex = extractedFilterIds.indexOf(left._id);
|
|
24
24
|
const rightIndex = extractedFilterIds.indexOf(right._id);
|
|
25
25
|
return leftIndex - rightIndex;
|
|
@@ -34,7 +34,7 @@ export async function loadFiltersService(
|
|
|
34
34
|
searchQuery,
|
|
35
35
|
forceLiveCollection,
|
|
36
36
|
allProductIds: productIds,
|
|
37
|
-
otherFilters,
|
|
37
|
+
otherFilters: sortedFilters,
|
|
38
38
|
},
|
|
39
39
|
{ modules: this },
|
|
40
40
|
);
|
|
@@ -16,11 +16,11 @@ export async function migrateOrderCartsService(
|
|
|
16
16
|
},
|
|
17
17
|
) {
|
|
18
18
|
const fromCart = await this.orders.cart({
|
|
19
|
-
countryContext,
|
|
19
|
+
countryCode: countryContext,
|
|
20
20
|
userId: fromUserId,
|
|
21
21
|
});
|
|
22
22
|
const toCart = await this.orders.cart({
|
|
23
|
-
countryContext,
|
|
23
|
+
countryCode: countryContext,
|
|
24
24
|
userId: toUserId,
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -14,12 +14,12 @@ export async function nextUserCartService(
|
|
|
14
14
|
}: {
|
|
15
15
|
user: User;
|
|
16
16
|
orderNumber?: string;
|
|
17
|
-
countryCode
|
|
17
|
+
countryCode: string;
|
|
18
18
|
forceCartCreation?: boolean;
|
|
19
19
|
},
|
|
20
20
|
) {
|
|
21
21
|
const cart = await this.orders.cart({
|
|
22
|
-
|
|
22
|
+
countryCode,
|
|
23
23
|
orderNumber,
|
|
24
24
|
userId: user._id,
|
|
25
25
|
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
+
import { Modules } from '../modules.js';
|
|
3
|
+
import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
|
|
4
|
+
import { Product } from '@unchainedshop/core-products';
|
|
5
|
+
import { EstimatedDispatch, WarehousingDirector } from '../directors/WarehousingDirector.js';
|
|
6
|
+
import { WarehousingContext } from '../directors/WarehousingAdapter.js';
|
|
7
|
+
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
8
|
+
|
|
9
|
+
export async function simulateProductDispatchingService(
|
|
10
|
+
this: Modules,
|
|
11
|
+
{
|
|
12
|
+
deliveryProviders,
|
|
13
|
+
product,
|
|
14
|
+
quantity,
|
|
15
|
+
referenceDate,
|
|
16
|
+
}: {
|
|
17
|
+
product: Product;
|
|
18
|
+
deliveryProviders: DeliveryProvider[];
|
|
19
|
+
quantity?: number;
|
|
20
|
+
referenceDate?: Date;
|
|
21
|
+
},
|
|
22
|
+
) {
|
|
23
|
+
return deliveryProviders.reduce<
|
|
24
|
+
Promise<Array<WarehousingContext & EstimatedDispatch & { warehousingProvider: WarehousingProvider }>>
|
|
25
|
+
>(async (oldResult, deliveryProvider) => {
|
|
26
|
+
const result = await oldResult;
|
|
27
|
+
|
|
28
|
+
const warehousingProviders: WarehousingProvider[] = await supportedWarehousingProvidersService.bind(
|
|
29
|
+
this,
|
|
30
|
+
)({
|
|
31
|
+
product,
|
|
32
|
+
deliveryProvider,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const mappedWarehousingProviders = await Promise.all(
|
|
36
|
+
warehousingProviders.map(async (warehousingProvider) => {
|
|
37
|
+
const warehousingContext: WarehousingContext = {
|
|
38
|
+
deliveryProvider,
|
|
39
|
+
product,
|
|
40
|
+
quantity,
|
|
41
|
+
referenceDate,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const director = await WarehousingDirector.actions(warehousingProvider, warehousingContext, {
|
|
45
|
+
modules: this,
|
|
46
|
+
});
|
|
47
|
+
const dispatch = await director.estimatedDispatch();
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
warehousingProvider,
|
|
51
|
+
...warehousingContext,
|
|
52
|
+
...dispatch,
|
|
53
|
+
};
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return result.concat(result, mappedWarehousingProviders);
|
|
58
|
+
}, Promise.resolve([]));
|
|
59
|
+
}
|