@unchainedshop/core 3.0.0-rc6 → 3.0.0-rc8

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.
Files changed (76) hide show
  1. package/lib/directors/BasePricingAdapter.d.ts +1 -6
  2. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  3. package/lib/directors/BasePricingAdapter.js.map +1 -1
  4. package/lib/directors/FilterDirector.d.ts.map +1 -1
  5. package/lib/directors/FilterDirector.js +4 -4
  6. package/lib/directors/FilterDirector.js.map +1 -1
  7. package/lib/directors/ProductPricingAdapter.d.ts +2 -0
  8. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  9. package/lib/directors/ProductPricingAdapter.js.map +1 -1
  10. package/lib/directors/ProductPricingSheet.d.ts +2 -5
  11. package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
  12. package/lib/directors/ProductPricingSheet.js.map +1 -1
  13. package/lib/directors/WarehousingDirector.d.ts +4 -1
  14. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  15. package/lib/directors/WarehousingDirector.js.map +1 -1
  16. package/lib/services/activateEnrollment.js +1 -1
  17. package/lib/services/activateEnrollment.js.map +1 -1
  18. package/lib/services/deleteUser.js +2 -2
  19. package/lib/services/deleteUser.js.map +1 -1
  20. package/lib/services/findOrInitCart.d.ts +9 -0
  21. package/lib/services/findOrInitCart.d.ts.map +1 -0
  22. package/lib/services/findOrInitCart.js +15 -0
  23. package/lib/services/findOrInitCart.js.map +1 -0
  24. package/lib/services/index.d.ts +9 -1
  25. package/lib/services/index.d.ts.map +1 -1
  26. package/lib/services/index.js +8 -0
  27. package/lib/services/index.js.map +1 -1
  28. package/lib/services/initializeEnrollment.js +1 -1
  29. package/lib/services/initializeEnrollment.js.map +1 -1
  30. package/lib/services/loadFilterOptions.d.ts.map +1 -1
  31. package/lib/services/loadFilterOptions.js +1 -2
  32. package/lib/services/loadFilterOptions.js.map +1 -1
  33. package/lib/services/loadFilters.js +2 -2
  34. package/lib/services/loadFilters.js.map +1 -1
  35. package/lib/services/migrateOrderCart.js +2 -2
  36. package/lib/services/migrateOrderCart.js.map +1 -1
  37. package/lib/services/nextUserCart.d.ts +1 -1
  38. package/lib/services/nextUserCart.d.ts.map +1 -1
  39. package/lib/services/nextUserCart.js +1 -1
  40. package/lib/services/nextUserCart.js.map +1 -1
  41. package/lib/services/processQuotation.js +1 -1
  42. package/lib/services/processQuotation.js.map +1 -1
  43. package/lib/services/simulateProductDispatching.d.ts +15 -0
  44. package/lib/services/simulateProductDispatching.d.ts.map +1 -0
  45. package/lib/services/simulateProductDispatching.js +30 -0
  46. package/lib/services/simulateProductDispatching.js.map +1 -0
  47. package/lib/services/simulateProductInventory.d.ts +15 -0
  48. package/lib/services/simulateProductInventory.d.ts.map +1 -0
  49. package/lib/services/simulateProductInventory.js +29 -0
  50. package/lib/services/simulateProductInventory.js.map +1 -0
  51. package/lib/services/simulateProductPricing.d.ts +12 -0
  52. package/lib/services/simulateProductPricing.d.ts.map +1 -0
  53. package/lib/services/simulateProductPricing.js +8 -0
  54. package/lib/services/simulateProductPricing.js.map +1 -0
  55. package/lib/services/terminateEnrollment.js +1 -1
  56. package/lib/services/terminateEnrollment.js.map +1 -1
  57. package/package.json +25 -22
  58. package/src/directors/BasePricingAdapter.ts +1 -3
  59. package/src/directors/FilterDirector.ts +4 -4
  60. package/src/directors/ProductPricingAdapter.ts +2 -0
  61. package/src/directors/ProductPricingSheet.ts +2 -5
  62. package/src/directors/WarehousingDirector.ts +2 -1
  63. package/src/services/activateEnrollment.ts +1 -1
  64. package/src/services/deleteUser.ts +2 -2
  65. package/src/services/findOrInitCart.ts +29 -0
  66. package/src/services/index.ts +15 -1
  67. package/src/services/initializeEnrollment.ts +1 -1
  68. package/src/services/loadFilterOptions.ts +1 -2
  69. package/src/services/loadFilters.ts +2 -2
  70. package/src/services/migrateOrderCart.ts +2 -2
  71. package/src/services/nextUserCart.ts +2 -2
  72. package/src/services/processQuotation.ts +1 -1
  73. package/src/services/simulateProductDispatching.ts +59 -0
  74. package/src/services/simulateProductInventory.ts +56 -0
  75. package/src/services/simulateProductPricing.ts +20 -0
  76. package/src/services/terminateEnrollment.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"processQuotation.js","sourceRoot":"","sources":["../../src/services/processQuotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,cAAc,GAAG,KAAK,EAAE,SAAoB,EAAE,OAAgB,EAA4B,EAAE;IAChG,IAAI,MAAM,GAAG,SAAS,CAAC,MAAyB,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAE7E,IAAI,MAAM,KAAK,eAAe,CAAC,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,mCAAmC,EAAE,CAAC,EAAE,CAAC;YAC5D,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC;QACtC,CAAC;IACH,CAAC;IACD,IAAI,MAAM,KAAK,eAAe,CAAC,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,wBAAwB,EAAE,CAAC,EAAE,CAAC;YACjD,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAE3C,gBAA2B,EAC3B,MAAkC;IAElC,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CAAC;IACzC,IAAI,SAAS,GAAG,gBAAgB,CAAC;IACjC,IAAI,UAAU,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,Q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AAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
2
+ import { Modules } from '../modules.js';
3
+ import { Product } from '@unchainedshop/core-products';
4
+ import { EstimatedDispatch } from '../directors/WarehousingDirector.js';
5
+ import { WarehousingContext } from '../directors/WarehousingAdapter.js';
6
+ import { WarehousingProvider } from '@unchainedshop/core-warehousing';
7
+ export declare function simulateProductDispatchingService(this: Modules, { deliveryProviders, product, quantity, referenceDate, }: {
8
+ product: Product;
9
+ deliveryProviders: DeliveryProvider[];
10
+ quantity?: number;
11
+ referenceDate?: Date;
12
+ }): Promise<(WarehousingContext & EstimatedDispatch & {
13
+ warehousingProvider: WarehousingProvider;
14
+ })[]>;
15
+ //# sourceMappingURL=simulateProductDispatching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductDispatching.d.ts","sourceRoot":"","sources":["../../src/services/simulateProductDispatching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAuB,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,OAAO,EACb,EACE,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,aAAa,GACd,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB;yBAG+E,mBAAmB;MAmCpG"}
@@ -0,0 +1,30 @@
1
+ import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
2
+ import { WarehousingDirector } from '../directors/WarehousingDirector.js';
3
+ export async function simulateProductDispatchingService({ deliveryProviders, product, quantity, referenceDate, }) {
4
+ return deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
5
+ const result = await oldResult;
6
+ const warehousingProviders = await supportedWarehousingProvidersService.bind(this)({
7
+ product,
8
+ deliveryProvider,
9
+ });
10
+ const mappedWarehousingProviders = await Promise.all(warehousingProviders.map(async (warehousingProvider) => {
11
+ const warehousingContext = {
12
+ deliveryProvider,
13
+ product,
14
+ quantity,
15
+ referenceDate,
16
+ };
17
+ const director = await WarehousingDirector.actions(warehousingProvider, warehousingContext, {
18
+ modules: this,
19
+ });
20
+ const dispatch = await director.estimatedDispatch();
21
+ return {
22
+ warehousingProvider,
23
+ ...warehousingContext,
24
+ ...dispatch,
25
+ };
26
+ }));
27
+ return result.concat(result, mappedWarehousingProviders);
28
+ }, Promise.resolve([]));
29
+ }
30
+ //# sourceMappingURL=simulateProductDispatching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductDispatching.js","sourceRoot":"","sources":["../../src/services/simulateProductDispatching.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,OAAO,EAAqB,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAI7F,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAErD,EACE,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,aAAa,GAMd;IAED,OAAO,iBAAiB,CAAC,MAAM,CAE7B,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAE/B,MAAM,oBAAoB,GAA0B,MAAM,oCAAoC,CAAC,IAAI,CACjG,IAAI,CACL,CAAC;YACA,OAAO;YACP,gBAAgB;SACjB,CAAC,CAAC;QAEH,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,GAAG,CAClD,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE;YACrD,MAAM,kBAAkB,GAAuB;gBAC7C,gBAAgB;gBAChB,OAAO;gBACP,QAAQ;gBACR,aAAa;aACd,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,EAAE,kBAAkB,EAAE;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;YAEpD,OAAO;gBACL,mBAAmB;gBACnB,GAAG,kBAAkB;gBACrB,GAAG,QAAQ;aACZ,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAC3D,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
2
+ import { Modules } from '../modules.js';
3
+ import { Product } from '@unchainedshop/core-products';
4
+ import { WarehousingContext } from '../directors/WarehousingAdapter.js';
5
+ import { WarehousingProvider } from '@unchainedshop/core-warehousing';
6
+ export declare function simulateProductInventoryService(this: Modules, { deliveryProviders, product, referenceDate, }: {
7
+ product: Product;
8
+ deliveryProviders: DeliveryProvider[];
9
+ referenceDate?: Date;
10
+ }): Promise<(WarehousingContext & {
11
+ quantity: number;
12
+ } & {
13
+ warehousingProvider: WarehousingProvider;
14
+ })[]>;
15
+ //# sourceMappingURL=simulateProductInventory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductInventory.d.ts","sourceRoot":"","sources":["../../src/services/simulateProductInventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,OAAO,EACb,EACE,iBAAiB,EACjB,OAAO,EACP,aAAa,GACd,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB;;;yBAG4E,mBAAmB;MAkCjG"}
@@ -0,0 +1,29 @@
1
+ import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
2
+ import { WarehousingDirector } from '../directors/WarehousingDirector.js';
3
+ export async function simulateProductInventoryService({ deliveryProviders, product, referenceDate, }) {
4
+ return deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
5
+ const result = await oldResult;
6
+ const warehousingProviders = await supportedWarehousingProvidersService.bind(this)({
7
+ product,
8
+ deliveryProvider,
9
+ });
10
+ const mappedWarehousingProviders = await Promise.all(warehousingProviders.map(async (warehousingProvider) => {
11
+ const warehousingContext = {
12
+ deliveryProvider,
13
+ product,
14
+ referenceDate,
15
+ };
16
+ const director = await WarehousingDirector.actions(warehousingProvider, warehousingContext, {
17
+ modules: this,
18
+ });
19
+ const stock = await director.estimatedStock();
20
+ return {
21
+ warehousingProvider,
22
+ ...warehousingContext,
23
+ ...stock,
24
+ };
25
+ }));
26
+ return result.concat(result, mappedWarehousingProviders);
27
+ }, Promise.resolve([]));
28
+ }
29
+ //# sourceMappingURL=simulateProductInventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductInventory.js","sourceRoot":"","sources":["../../src/services/simulateProductInventory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,OAAO,EAAkB,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAI1F,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAEnD,EACE,iBAAiB,EACjB,OAAO,EACP,aAAa,GAKd;IAED,OAAO,iBAAiB,CAAC,MAAM,CAE7B,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAE/B,MAAM,oBAAoB,GAA0B,MAAM,oCAAoC,CAAC,IAAI,CACjG,IAAI,CACL,CAAC;YACA,OAAO;YACP,gBAAgB;SACjB,CAAC,CAAC;QAEH,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,GAAG,CAClD,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE;YACrD,MAAM,kBAAkB,GAAuB;gBAC7C,gBAAgB;gBAChB,OAAO;gBACP,aAAa;aACd,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,EAAE,kBAAkB,EAAE;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAC;YAE9C,OAAO;gBACL,mBAAmB;gBACnB,GAAG,kBAAkB;gBACrB,GAAG,KAAK;aACT,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAC3D,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Product, ProductConfiguration } from '@unchainedshop/core-products';
2
+ import { User } from '@unchainedshop/core-users';
3
+ import { Modules } from '../modules.js';
4
+ export declare function simulateProductPricingService(this: Modules, pricingContext: {
5
+ product: Product;
6
+ user: User;
7
+ country: string;
8
+ currency: string;
9
+ quantity: number;
10
+ configuration?: Array<ProductConfiguration>;
11
+ }): Promise<import("../core-index.js").IProductPricingSheet>;
12
+ //# sourceMappingURL=simulateProductPricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductPricing.d.ts","sourceRoot":"","sources":["../../src/services/simulateProductPricing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,OAAO,EACb,cAAc,EAAE;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;CAC7C,4DAKF"}
@@ -0,0 +1,8 @@
1
+ import { ProductPricingDirector } from '../core-index.js';
2
+ export async function simulateProductPricingService(pricingContext) {
3
+ const calculated = await ProductPricingDirector.rebuildCalculation(pricingContext, { modules: this });
4
+ if (!calculated || !calculated.length)
5
+ return null;
6
+ return ProductPricingDirector.calculationSheet(pricingContext, calculated);
7
+ }
8
+ //# sourceMappingURL=simulateProductPricing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateProductPricing.js","sourceRoot":"","sources":["../../src/services/simulateProductPricing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI1D,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAEjD,cAOC;IAED,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC,kBAAkB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACtG,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,sBAAsB,CAAC,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC"}
@@ -15,7 +15,7 @@ export async function terminateEnrollmentService(enrollment) {
15
15
  retries: 0,
16
16
  input: {
17
17
  reason: 'status_change',
18
- locale,
18
+ locale: locale.baseName,
19
19
  template: 'ENROLLMENT_STATUS',
20
20
  enrollmentId: updatedEnrollment._id,
21
21
  },
@@ -1 +1 @@
1
- {"version":3,"file":"terminateEnrollment.js","sourceRoot":"","sources":["../../src/services/terminateEnrollment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,UAAsB;IACrE,IAAI,UAAU,CAAC,MAAM,KAAK,gBAAgB,CAAC,UAAU;QAAE,OAAO,UAAU,CAAC;IAEzE,IAAI,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE;QAC1E,MAAM,EAAE,gBAAgB,CAAC,UAAU;QACnC,IAAI,EAAE,qBAAqB;KAC5B,CAAC,CAAC;IAEH,iBAAiB,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAEjF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QACxB,IAAI,EAAE,SAAS;QACf,OA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AEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/core",
3
- "version": "3.0.0-rc6",
3
+ "version": "3.0.0-rc8",
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
- "author": "Joël Meiller",
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,26 +32,26 @@
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-rc6",
33
- "@unchainedshop/core-bookmarks": "^3.0.0-rc6",
34
- "@unchainedshop/core-countries": "^3.0.0-rc6",
35
- "@unchainedshop/core-currencies": "^3.0.0-rc6",
36
- "@unchainedshop/core-delivery": "^3.0.0-rc6",
37
- "@unchainedshop/core-enrollments": "^3.0.0-rc6",
38
- "@unchainedshop/core-events": "^3.0.0-rc6",
39
- "@unchainedshop/core-files": "^3.0.0-rc6",
40
- "@unchainedshop/core-filters": "^3.0.0-rc6",
41
- "@unchainedshop/core-languages": "^3.0.0-rc6",
42
- "@unchainedshop/core-messaging": "^3.0.0-rc6",
43
- "@unchainedshop/core-orders": "^3.0.0-rc6",
44
- "@unchainedshop/core-payment": "^3.0.0-rc6",
45
- "@unchainedshop/core-products": "^3.0.0-rc6",
46
- "@unchainedshop/core-quotations": "^3.0.0-rc6",
47
- "@unchainedshop/core-users": "^3.0.0-rc6",
48
- "@unchainedshop/core-warehousing": "^3.0.0-rc6",
49
- "@unchainedshop/core-worker": "^3.0.0-rc6",
50
- "@unchainedshop/logger": "^3.0.0-rc6",
51
- "@unchainedshop/utils": "^3.0.0-rc6"
35
+ "@unchainedshop/core-assortments": "^3.0.0-rc8",
36
+ "@unchainedshop/core-bookmarks": "^3.0.0-rc8",
37
+ "@unchainedshop/core-countries": "^3.0.0-rc8",
38
+ "@unchainedshop/core-currencies": "^3.0.0-rc8",
39
+ "@unchainedshop/core-delivery": "^3.0.0-rc8",
40
+ "@unchainedshop/core-enrollments": "^3.0.0-rc8",
41
+ "@unchainedshop/core-events": "^3.0.0-rc8",
42
+ "@unchainedshop/core-files": "^3.0.0-rc8",
43
+ "@unchainedshop/core-filters": "^3.0.0-rc8",
44
+ "@unchainedshop/core-languages": "^3.0.0-rc8",
45
+ "@unchainedshop/core-messaging": "^3.0.0-rc8",
46
+ "@unchainedshop/core-orders": "^3.0.0-rc8",
47
+ "@unchainedshop/core-payment": "^3.0.0-rc8",
48
+ "@unchainedshop/core-products": "^3.0.0-rc8",
49
+ "@unchainedshop/core-quotations": "^3.0.0-rc8",
50
+ "@unchainedshop/core-users": "^3.0.0-rc8",
51
+ "@unchainedshop/core-warehousing": "^3.0.0-rc8",
52
+ "@unchainedshop/core-worker": "^3.0.0-rc8",
53
+ "@unchainedshop/logger": "^3.0.0-rc8",
54
+ "@unchainedshop/utils": "^3.0.0-rc8"
52
55
  },
53
56
  "devDependencies": {
54
57
  "@types/node": "^22.10.2",
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { BaseDirector, IBaseDirector, intersectSet } from '@unchainedshop/utils';
2
+ import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
3
3
  import { FilterAdapterActions, FilterContext, IFilterAdapter } from './FilterAdapter.js';
4
4
  import {
5
5
  Filter,
@@ -227,7 +227,7 @@ export const FilterDirector: IFilterDirector = {
227
227
  unchainedAPI,
228
228
  );
229
229
 
230
- return intersectSet(productIdSet, new Set(filterOptionProductIds));
230
+ return productIdSet.intersection(new Set(filterOptionProductIds));
231
231
  },
232
232
  Promise.resolve(new Set(productIds)),
233
233
  );
@@ -252,7 +252,7 @@ export const FilterDirector: IFilterDirector = {
252
252
  unchainedAPI,
253
253
  );
254
254
 
255
- const examinedProductIdSet = intersectSet(new Set(allProductIds), new Set(filteredProductIds));
255
+ const examinedProductIdSet = new Set(allProductIds).intersection(new Set(filteredProductIds));
256
256
  const values = filterQueryParsed[filter.key];
257
257
 
258
258
  // The filteredProductIdSet is a set of product id's that:
@@ -275,7 +275,7 @@ export const FilterDirector: IFilterDirector = {
275
275
  },
276
276
  unchainedAPI,
277
277
  );
278
- return intersectSet(productIdSet, new Set(otherFilterProductIds));
278
+ return productIdSet.intersection(new Set(otherFilterProductIds));
279
279
  },
280
280
  Promise.resolve(new Set(examinedProductIdSet)),
281
281
  );
@@ -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;
@@ -20,7 +20,7 @@ export async function activateEnrollmentService(this: Modules, enrollment: Enrol
20
20
  retries: 0,
21
21
  input: {
22
22
  reason: 'status_change',
23
- locale,
23
+ locale: locale.baseName,
24
24
  template: 'ENROLLMENT_STATUS',
25
25
  enrollmentId: updatedEnrollment._id,
26
26
  },
@@ -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
- for (const userCart of carts) {
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
+ }
@@ -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 { Modules } from '../modules.js';
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: {
@@ -28,7 +28,7 @@ export async function initializeEnrollmentService(
28
28
  retries: 0,
29
29
  input: {
30
30
  reason: params.reason || 'status_change',
31
- locale,
31
+ locale: locale.baseName,
32
32
  template: 'ENROLLMENT_STATUS',
33
33
  enrollmentId: processedEnrollment._id,
34
34
  },
@@ -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 = intersectSet(productIdSet, new Set(filterOptionProductIds));
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.sort((left, right) => {
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?: string;
17
+ countryCode: string;
18
18
  forceCartCreation?: boolean;
19
19
  },
20
20
  ) {
21
21
  const cart = await this.orders.cart({
22
- countryContext: countryCode || user.lastLogin?.countryCode,
22
+ countryCode,
23
23
  orderNumber,
24
24
  userId: user._id,
25
25
  });
@@ -65,7 +65,7 @@ export async function processQuotationService(
65
65
  type: 'MESSAGE',
66
66
  retries: 0,
67
67
  input: {
68
- locale,
68
+ locale: locale.baseName,
69
69
  template: 'QUOTATION_STATUS',
70
70
  quotationId: updatedQuotation._id,
71
71
  },
@@ -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
+ }