@unchainedshop/core-products 3.0.0-rc9 → 3.1.0

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 (91) hide show
  1. package/lib/db/ProductMediaSchema.d.ts +4 -0
  2. package/lib/db/ProductMediaSchema.d.ts.map +1 -0
  3. package/lib/db/ProductMediaSchema.js +22 -0
  4. package/lib/db/ProductMediaSchema.js.map +1 -0
  5. package/lib/db/ProductPriceRates.d.ts.map +1 -1
  6. package/lib/db/ProductPriceRates.js +0 -2
  7. package/lib/db/ProductPriceRates.js.map +1 -1
  8. package/lib/db/ProductReviewsSchema.d.ts +8 -0
  9. package/lib/db/ProductReviewsSchema.d.ts.map +1 -0
  10. package/lib/db/ProductReviewsSchema.js +31 -0
  11. package/lib/db/ProductReviewsSchema.js.map +1 -0
  12. package/lib/db/ProductStatus.d.ts +6 -0
  13. package/lib/db/ProductStatus.d.ts.map +1 -0
  14. package/lib/db/ProductStatus.js +7 -0
  15. package/lib/db/ProductStatus.js.map +1 -0
  16. package/lib/db/ProductVariationsCollection.d.ts +1 -1
  17. package/lib/db/ProductVariationsCollection.d.ts.map +1 -1
  18. package/lib/db/ProductVariationsSchema.d.ts +8 -0
  19. package/lib/db/ProductVariationsSchema.d.ts.map +1 -0
  20. package/lib/db/ProductVariationsSchema.js +28 -0
  21. package/lib/db/ProductVariationsSchema.js.map +1 -0
  22. package/lib/db/ProductsSchema.d.ts +11 -0
  23. package/lib/db/ProductsSchema.d.ts.map +1 -0
  24. package/lib/db/ProductsSchema.js +106 -0
  25. package/lib/db/ProductsSchema.js.map +1 -0
  26. package/lib/director/ProductDiscountAdapter.d.ts +4 -0
  27. package/lib/director/ProductDiscountAdapter.d.ts.map +1 -0
  28. package/lib/director/ProductDiscountAdapter.js +3 -0
  29. package/lib/director/ProductDiscountAdapter.js.map +1 -0
  30. package/lib/director/ProductDiscountConfiguration.d.ts +13 -0
  31. package/lib/director/ProductDiscountConfiguration.d.ts.map +1 -0
  32. package/lib/director/ProductDiscountConfiguration.js +2 -0
  33. package/lib/director/ProductDiscountConfiguration.js.map +1 -0
  34. package/lib/director/ProductDiscountDirector.d.ts +3 -0
  35. package/lib/director/ProductDiscountDirector.d.ts.map +1 -0
  36. package/lib/director/ProductDiscountDirector.js +3 -0
  37. package/lib/director/ProductDiscountDirector.js.map +1 -0
  38. package/lib/director/ProductPricingAdapter.d.ts +3 -0
  39. package/lib/director/ProductPricingAdapter.d.ts.map +1 -0
  40. package/lib/director/ProductPricingAdapter.js +25 -0
  41. package/lib/director/ProductPricingAdapter.js.map +1 -0
  42. package/lib/director/ProductPricingDirector.d.ts +3 -0
  43. package/lib/director/ProductPricingDirector.d.ts.map +1 -0
  44. package/lib/director/ProductPricingDirector.js +59 -0
  45. package/lib/director/ProductPricingDirector.js.map +1 -0
  46. package/lib/director/ProductPricingSheet.d.ts +4 -0
  47. package/lib/director/ProductPricingSheet.d.ts.map +1 -0
  48. package/lib/director/ProductPricingSheet.js +78 -0
  49. package/lib/director/ProductPricingSheet.js.map +1 -0
  50. package/lib/module/configureProductMediaModule.d.ts +13 -17
  51. package/lib/module/configureProductMediaModule.d.ts.map +1 -1
  52. package/lib/module/configureProductMediaModule.js +6 -7
  53. package/lib/module/configureProductMediaModule.js.map +1 -1
  54. package/lib/module/configureProductPrices.d.ts +54 -3
  55. package/lib/module/configureProductPrices.d.ts.map +1 -1
  56. package/lib/module/configureProductPrices.js +2 -2
  57. package/lib/module/configureProductPrices.js.map +1 -1
  58. package/lib/module/configureProductReviewsModule.d.ts +11 -17
  59. package/lib/module/configureProductReviewsModule.d.ts.map +1 -1
  60. package/lib/module/configureProductReviewsModule.js +10 -15
  61. package/lib/module/configureProductReviewsModule.js.map +1 -1
  62. package/lib/module/configureProductTextsModule.d.ts +17 -2
  63. package/lib/module/configureProductTextsModule.d.ts.map +1 -1
  64. package/lib/module/configureProductTextsModule.js +5 -5
  65. package/lib/module/configureProductTextsModule.js.map +1 -1
  66. package/lib/module/configureProductVariationsModule.d.ts +12 -17
  67. package/lib/module/configureProductVariationsModule.d.ts.map +1 -1
  68. package/lib/module/configureProductVariationsModule.js +6 -14
  69. package/lib/module/configureProductVariationsModule.js.map +1 -1
  70. package/lib/module/configureProductsModule.d.ts +153 -60
  71. package/lib/module/configureProductsModule.d.ts.map +1 -1
  72. package/lib/module/configureProductsModule.js +4 -4
  73. package/lib/module/configureProductsModule.js.map +1 -1
  74. package/lib/service/productServices.d.ts +3 -0
  75. package/lib/service/productServices.d.ts.map +1 -0
  76. package/lib/service/productServices.js +5 -0
  77. package/lib/service/productServices.js.map +1 -0
  78. package/lib/service/removeProductService.d.ts +3 -0
  79. package/lib/service/removeProductService.d.ts.map +1 -0
  80. package/lib/service/removeProductService.js +21 -0
  81. package/lib/service/removeProductService.js.map +1 -0
  82. package/package.json +6 -6
  83. package/src/db/ProductPriceRates.ts +1 -2
  84. package/src/db/ProductVariationsCollection.ts +1 -1
  85. package/src/db/ProductsCollection.ts +1 -1
  86. package/src/module/configureProductMediaModule.ts +55 -67
  87. package/src/module/configureProductPrices.ts +64 -15
  88. package/src/module/configureProductReviewsModule.ts +40 -77
  89. package/src/module/configureProductTextsModule.ts +33 -8
  90. package/src/module/configureProductVariationsModule.ts +59 -86
  91. package/src/module/configureProductsModule.ts +90 -244
@@ -0,0 +1,4 @@
1
+ import SimpleSchema from 'simpl-schema';
2
+ export declare const ProductMediaSchema: SimpleSchema;
3
+ export declare const ProductMediaTextsSchema: SimpleSchema;
4
+ //# sourceMappingURL=ProductMediaSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductMediaSchema.d.ts","sourceRoot":"","sources":["../../src/db/ProductMediaSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,kBAAkB,cAW9B,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAYnC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+ export const ProductMediaSchema = new SimpleSchema({
4
+ mediaId: { type: String, required: true },
5
+ productId: { type: String, required: true },
6
+ sortKey: { type: Number, required: true },
7
+ tags: Array,
8
+ 'tags.$': String,
9
+ meta: { type: Object, blackbox: true },
10
+ ...Schemas.timestampFields,
11
+ }, { requiredByDefault: false });
12
+ export const ProductMediaTextsSchema = new SimpleSchema({
13
+ productMediaId: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ locale: String,
18
+ title: String,
19
+ subtitle: String,
20
+ ...Schemas.timestampFields,
21
+ }, { requiredByDefault: false });
22
+ //# sourceMappingURL=ProductMediaSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductMediaSchema.js","sourceRoot":"","sources":["../../src/db/ProductMediaSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,YAAY,CAChD;IACE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3C,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,YAAY,CACrD;IACE,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPriceRates.d.ts","sourceRoot":"","sources":["../../src/db/ProductPriceRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,wBAAwB,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,OAAc,OAAO,CAAC,EAAE;;EAcrD,CAAC"}
1
+ {"version":3,"file":"ProductPriceRates.d.ts","sourceRoot":"","sources":["../../src/db/ProductPriceRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,wBAAwB,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,OAAc,OAAO,CAAC,EAAE;;EAarD,CAAC"}
@@ -1,8 +1,6 @@
1
1
  import { buildDbIndexes } from '@unchainedshop/mongodb';
2
2
  export const ProductPriceRates = async (db) => {
3
3
  const ProductRates = db.collection('product_rates');
4
- // ProductRates Indexes
5
- // TODO: Time-Series Data in MongoDb 5.0!
6
4
  await buildDbIndexes(ProductRates, [
7
5
  { index: { baseCurrency: 1 } },
8
6
  { index: { quoteCurrency: 1 } },
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPriceRates.js","sourceRoot":"","sources":["../../src/db/ProductPriceRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAUjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IACxD,MAAM,YAAY,GAAG,EAAE,CAAC,UAAU,CAAmB,eAAe,CAAC,CAAC;IACtE,uBAAuB;IACvB,yCAAyC;IACzC,MAAM,cAAc,CAAC,YAAY,EAAE;QACjC,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE;QAC9B,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE;QAC/B,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1C,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE;KAC3E,CAAC,CAAC;IAEH,OAAO;QACL,YAAY;KACb,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"ProductPriceRates.js","sourceRoot":"","sources":["../../src/db/ProductPriceRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAUjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IACxD,MAAM,YAAY,GAAG,EAAE,CAAC,UAAU,CAAmB,eAAe,CAAC,CAAC;IAEtE,MAAM,cAAc,CAAC,YAAY,EAAE;QACjC,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE;QAC9B,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE;QAC/B,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1C,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE;KAC3E,CAAC,CAAC;IAEH,OAAO;QACL,YAAY;KACb,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import SimpleSchema from 'simpl-schema';
2
+ export declare const ProductReviewVoteTypes: {
3
+ UPVOTE: string;
4
+ DOWNVOTE: string;
5
+ REPORT: string;
6
+ };
7
+ export declare const ProductReviewsSchema: SimpleSchema;
8
+ //# sourceMappingURL=ProductReviewsSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductReviewsSchema.d.ts","sourceRoot":"","sources":["../../src/db/ProductReviewsSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAyBhC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+ export const ProductReviewVoteTypes = {
4
+ UPVOTE: 'UPVOTE',
5
+ DOWNVOTE: 'DOWNVOTE',
6
+ REPORT: 'REPORT',
7
+ };
8
+ export const ProductReviewsSchema = new SimpleSchema({
9
+ productId: { type: String, required: true },
10
+ authorId: { type: String, required: true },
11
+ rating: {
12
+ type: SimpleSchema.Integer,
13
+ min: 1,
14
+ max: 100,
15
+ },
16
+ title: String,
17
+ review: String,
18
+ meta: { type: Object, blackbox: true },
19
+ votes: Array,
20
+ 'votes.$': { type: Object, required: true },
21
+ 'votes.$.timestamp': { type: Date, required: true },
22
+ 'votes.$.userId': { type: String, required: true },
23
+ 'votes.$.type': {
24
+ type: String,
25
+ required: true,
26
+ allowedValues: Object.values(ProductReviewVoteTypes),
27
+ },
28
+ 'votes.$.meta': { type: Object, blackbox: true },
29
+ ...Schemas.timestampFields,
30
+ }, { requiredByDefault: false });
31
+ //# sourceMappingURL=ProductReviewsSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductReviewsSchema.js","sourceRoot":"","sources":["../../src/db/ProductReviewsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAClD;IACE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3C,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1C,MAAM,EAAE;QACN,IAAI,EAAE,YAAY,CAAC,OAAO;QAC1B,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG;KACT;IACD,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3C,mBAAmB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACnD,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClD,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC;KACrD;IACD,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAChD,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare enum ProductStatus {
2
+ DRAFT = "DRAFT",
3
+ ACTIVE = "ACTIVE",
4
+ DELETED = "DELETED"
5
+ }
6
+ //# sourceMappingURL=ProductStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductStatus.d.ts","sourceRoot":"","sources":["../../src/db/ProductStatus.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB"}
@@ -0,0 +1,7 @@
1
+ export var ProductStatus;
2
+ (function (ProductStatus) {
3
+ ProductStatus["DRAFT"] = "DRAFT";
4
+ ProductStatus["ACTIVE"] = "ACTIVE";
5
+ ProductStatus["DELETED"] = "DELETED";
6
+ })(ProductStatus || (ProductStatus = {}));
7
+ //# sourceMappingURL=ProductStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductStatus.js","sourceRoot":"","sources":["../../src/db/ProductStatus.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;AACrB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
@@ -20,7 +20,7 @@ export type ProductVariationText = {
20
20
  title?: string;
21
21
  } & TimestampFields;
22
22
  export type ProductVariationOption = {
23
- _id: string;
23
+ _id?: string;
24
24
  texts: ProductVariationText;
25
25
  value: string;
26
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ProductVariationsCollection.d.ts","sourceRoot":"","sources":["../../src/db/ProductVariationsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElF,oBAAY,oBAAoB;IAC9B,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,oBAAoB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AACF,eAAO,MAAM,2BAA2B,OAAc,OAAO,CAAC,EAAE;;;EAe/D,CAAC"}
1
+ {"version":3,"file":"ProductVariationsCollection.d.ts","sourceRoot":"","sources":["../../src/db/ProductVariationsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElF,oBAAY,oBAAoB;IAC9B,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,oBAAoB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AACF,eAAO,MAAM,2BAA2B,OAAc,OAAO,CAAC,EAAE;;;EAe/D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import SimpleSchema from 'simpl-schema';
2
+ export declare const ProductVariationType: {
3
+ COLOR: string;
4
+ TEXT: string;
5
+ };
6
+ export declare const ProductVariationsSchema: SimpleSchema;
7
+ export declare const ProductVariationTextsSchema: SimpleSchema;
8
+ //# sourceMappingURL=ProductVariationsSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductVariationsSchema.d.ts","sourceRoot":"","sources":["../../src/db/ProductVariationsSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAYnC,CAAC;AAEF,eAAO,MAAM,2BAA2B,cAavC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+ export const ProductVariationType = {
4
+ COLOR: 'COLOR',
5
+ TEXT: 'TEXT',
6
+ };
7
+ export const ProductVariationsSchema = new SimpleSchema({
8
+ productId: { type: String, required: true },
9
+ key: String,
10
+ type: String,
11
+ tags: Array,
12
+ 'tags.$': String,
13
+ options: Array,
14
+ 'options.$': String,
15
+ ...Schemas.timestampFields,
16
+ }, { requiredByDefault: false });
17
+ export const ProductVariationTextsSchema = new SimpleSchema({
18
+ productVariationId: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ productVariationOptionValue: String,
23
+ locale: String,
24
+ title: String,
25
+ subtitle: String,
26
+ ...Schemas.timestampFields,
27
+ }, { requiredByDefault: false });
28
+ //# sourceMappingURL=ProductVariationsSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductVariationsSchema.js","sourceRoot":"","sources":["../../src/db/ProductVariationsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,YAAY,CACrD;IACE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3C,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,MAAM;IACnB,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,YAAY,CACzD;IACE,kBAAkB,EAAE;QAClB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,2BAA2B,EAAE,MAAM;IACnC,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import SimpleSchema from 'simpl-schema';
2
+ export declare const ProductTypes: {
3
+ SimpleProduct: string;
4
+ ConfigurableProduct: string;
5
+ BundleProduct: string;
6
+ PlanProduct: string;
7
+ TokenizedProduct: string;
8
+ };
9
+ export declare const ProductsSchema: SimpleSchema;
10
+ export declare const ProductTextsSchema: SimpleSchema;
11
+ //# sourceMappingURL=ProductsSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductsSchema.d.ts","sourceRoot":"","sources":["../../src/db/ProductsSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAoFF,eAAO,MAAM,cAAc,cA6B1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAe9B,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+ export const ProductTypes = {
4
+ SimpleProduct: 'SIMPLE_PRODUCT',
5
+ ConfigurableProduct: 'CONFIGURABLE_PRODUCT',
6
+ BundleProduct: 'BUNDLE_PRODUCT',
7
+ PlanProduct: 'PLAN_PRODUCT',
8
+ TokenizedProduct: 'TOKENIZED_PRODUCT',
9
+ };
10
+ const ProductCommerceSchema = new SimpleSchema({
11
+ salesUnit: String,
12
+ salesQuantityPerUnit: String,
13
+ defaultOrderQuantity: Number,
14
+ pricing: Array,
15
+ 'pricing.$': Object,
16
+ 'pricing.$.isTaxable': Boolean,
17
+ 'pricing.$.isNetPrice': Boolean,
18
+ 'pricing.$.countryCode': String,
19
+ 'pricing.$.currencyCode': String,
20
+ 'pricing.$.amount': Number,
21
+ 'pricing.$.maxQuantity': Number,
22
+ }, { requiredByDefault: false });
23
+ const ProductWarehousingSchema = new SimpleSchema({
24
+ baseUnit: String,
25
+ sku: String,
26
+ }, { requiredByDefault: false });
27
+ const ProductTokenizationSchema = new SimpleSchema({
28
+ contractAddress: String,
29
+ contractStandard: String,
30
+ ercMetadataProperties: { type: Object, blackbox: true, optional: true },
31
+ tokenId: String,
32
+ supply: Number,
33
+ }, { requiredByDefault: true });
34
+ const ProductSupplySchema = new SimpleSchema({
35
+ weightInGram: Number,
36
+ heightInMillimeters: Number,
37
+ lengthInMillimeters: Number,
38
+ widthInMillimeters: Number,
39
+ }, { requiredByDefault: false });
40
+ const ProductPlanSchema = new SimpleSchema({
41
+ billingInterval: String,
42
+ billingIntervalCount: Number,
43
+ usageCalculationType: String,
44
+ trialInterval: String,
45
+ trialIntervalCount: Number,
46
+ }, { requiredByDefault: false });
47
+ const ProductProxySchema = new SimpleSchema({
48
+ assignments: Array,
49
+ 'assignments.$': Object,
50
+ 'assignments.$.vector': { type: Object, blackbox: true },
51
+ 'assignments.$.productId': String,
52
+ }, { requiredByDefault: false });
53
+ const ProductConfigurationSchema = new SimpleSchema({
54
+ key: String,
55
+ value: String,
56
+ });
57
+ const ProductBundleItemSchema = new SimpleSchema({
58
+ productId: String,
59
+ quantity: Number,
60
+ configuration: {
61
+ type: Array,
62
+ defaultValue: [],
63
+ },
64
+ 'configuration.$': ProductConfigurationSchema,
65
+ });
66
+ export const ProductsSchema = new SimpleSchema({
67
+ sequence: { type: Number, required: true },
68
+ slugs: Array,
69
+ 'slugs.$': String,
70
+ type: {
71
+ type: String,
72
+ allowedValues: Object.values(ProductTypes),
73
+ required: true,
74
+ },
75
+ status: String,
76
+ published: Date,
77
+ tags: Array,
78
+ 'tags.$': String,
79
+ commerce: ProductCommerceSchema,
80
+ warehousing: ProductWarehousingSchema,
81
+ supply: ProductSupplySchema,
82
+ proxy: ProductProxySchema,
83
+ plan: ProductPlanSchema,
84
+ bundleItems: {
85
+ type: Array,
86
+ optional: true,
87
+ },
88
+ 'bundleItems.$': ProductBundleItemSchema,
89
+ meta: { type: Object, blackbox: true },
90
+ tokenization: ProductTokenizationSchema,
91
+ ...Schemas.timestampFields,
92
+ }, { requiredByDefault: false });
93
+ export const ProductTextsSchema = new SimpleSchema({
94
+ productId: { type: String, required: true },
95
+ locale: { type: String, required: true },
96
+ vendor: String,
97
+ brand: String,
98
+ title: String,
99
+ slug: String,
100
+ subtitle: String,
101
+ description: String,
102
+ labels: Array,
103
+ 'labels.$': String,
104
+ ...Schemas.timestampFields,
105
+ }, { requiredByDefault: false });
106
+ //# sourceMappingURL=ProductsSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductsSchema.js","sourceRoot":"","sources":["../../src/db/ProductsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE,gBAAgB;IAC/B,mBAAmB,EAAE,sBAAsB;IAC3C,aAAa,EAAE,gBAAgB;IAC/B,WAAW,EAAE,cAAc;IAC3B,gBAAgB,EAAE,mBAAmB;CACtC,CAAC;AAEF,MAAM,qBAAqB,GAAG,IAAI,YAAY,CAC5C;IACE,SAAS,EAAE,MAAM;IACjB,oBAAoB,EAAE,MAAM;IAC5B,oBAAoB,EAAE,MAAM;IAC5B,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,MAAM;IACnB,qBAAqB,EAAE,OAAO;IAC9B,sBAAsB,EAAE,OAAO;IAC/B,uBAAuB,EAAE,MAAM;IAC/B,wBAAwB,EAAE,MAAM;IAChC,kBAAkB,EAAE,MAAM;IAC1B,uBAAuB,EAAE,MAAM;CAChC,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,wBAAwB,GAAG,IAAI,YAAY,CAC/C;IACE,QAAQ,EAAE,MAAM;IAChB,GAAG,EAAE,MAAM;CACZ,EACD,EA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ACZ,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,MAAM;IAClB,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
2
+ import { ProductDiscountConfiguration } from './ProductDiscountConfiguration.js';
3
+ export declare const ProductDiscountAdapter: Omit<IDiscountAdapter<ProductDiscountConfiguration>, 'key' | 'label' | 'version'>;
4
+ //# sourceMappingURL=ProductDiscountAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountAdapter.d.ts","sourceRoot":"","sources":["../../src/director/ProductDiscountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,eAAO,MAAM,sBAAsB,EAAE,IAAI,CACvC,gBAAgB,CAAC,4BAA4B,CAAC,EAC9C,KAAK,GAAG,OAAO,GAAG,SAAS,CACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { BaseDiscountAdapter } from '@unchainedshop/utils';
2
+ export const ProductDiscountAdapter = BaseDiscountAdapter;
3
+ //# sourceMappingURL=ProductDiscountAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountAdapter.js","sourceRoot":"","sources":["../../src/director/ProductDiscountAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,CAAC,MAAM,sBAAsB,GAG/B,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Product, ProductConfiguration } from '@unchainedshop/types/products.js';
2
+ type ResolvedConfiguration = {
3
+ fixedRate?: number;
4
+ rate?: number;
5
+ isNetPrice?: boolean;
6
+ taxRate?: number;
7
+ } & Record<string, any>;
8
+ export type PriceConfigurationResolver = (product: Product, quantity: number, configuration: Array<ProductConfiguration>) => ResolvedConfiguration | null;
9
+ export interface ProductDiscountConfiguration extends ResolvedConfiguration {
10
+ customPriceConfigurationResolver?: PriceConfigurationResolver;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=ProductDiscountConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountConfiguration.d.ts","sourceRoot":"","sources":["../../src/director/ProductDiscountConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,MAAM,MAAM,0BAA0B,GAAG,CACvC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,KAAK,CAAC,oBAAoB,CAAC,KACvC,qBAAqB,GAAG,IAAI,CAAC;AAElC,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,gCAAgC,CAAC,EAAE,0BAA0B,CAAC;CAC/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ProductDiscountConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountConfiguration.js","sourceRoot":"","sources":["../../src/director/ProductDiscountConfiguration.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { ProductDiscountConfiguration } from './ProductDiscountConfiguration.js';
2
+ export declare const ProductDiscountDirector: import("@unchainedshop/types/discount.js").IDiscountDirector<ProductDiscountConfiguration>;
3
+ //# sourceMappingURL=ProductDiscountDirector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountDirector.d.ts","sourceRoot":"","sources":["../../src/director/ProductDiscountDirector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,eAAO,MAAM,uBAAuB,4FAC2C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { BaseDiscountDirector } from '@unchainedshop/utils';
2
+ export const ProductDiscountDirector = BaseDiscountDirector('ProductDiscountDirector');
3
+ //# sourceMappingURL=ProductDiscountDirector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductDiscountDirector.js","sourceRoot":"","sources":["../../src/director/ProductDiscountDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,CAAC,MAAM,uBAAuB,GAClC,oBAAoB,CAA+B,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { IProductPricingAdapter } from '@unchainedshop/types/products.pricing.js';
2
+ export declare const ProductPricingAdapter: IProductPricingAdapter;
3
+ //# sourceMappingURL=ProductPricingAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingAdapter.d.ts","sourceRoot":"","sources":["../../src/director/ProductPricingAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACvB,MAAM,0CAA0C,CAAC;AAMlD,eAAO,MAAM,qBAAqB,EAAE,sBAyBnC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { BasePricingAdapter } from '@unchainedshop/utils';
2
+ import { ProductPricingSheet } from './ProductPricingSheet.js';
3
+ const basePricingAdapter = BasePricingAdapter();
4
+ export const ProductPricingAdapter = {
5
+ ...basePricingAdapter,
6
+ isActivatedFor: () => {
7
+ return false;
8
+ },
9
+ actions: (params) => {
10
+ const { context } = params;
11
+ const { currency, quantity } = context;
12
+ const baseActions = basePricingAdapter.actions(params);
13
+ const resultSheet = ProductPricingSheet({ currency, quantity });
14
+ return {
15
+ ...baseActions,
16
+ calculate: async () => {
17
+ const resultRaw = resultSheet.getRawPricingSheet();
18
+ resultRaw.forEach(({ amount, category }) => basePricingAdapter.log(`Product Item Calculation -> ${category} ${amount}`));
19
+ return resultRaw;
20
+ },
21
+ resultSheet: () => resultSheet,
22
+ };
23
+ },
24
+ };
25
+ //# sourceMappingURL=ProductPricingAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingAdapter.js","sourceRoot":"","sources":["../../src/director/ProductPricingAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,kBAAkB,EAA2D,CAAC;AAEzG,MAAM,CAAC,MAAM,qBAAqB,GAA2B;IAC3D,GAAG,kBAAkB;IAErB,cAAc,EAAE,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;QAClB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QACvC,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,WAAW,GAAG,mBAAmB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEhE,OAAO;YACL,GAAG,WAAW;YACd,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,MAAM,SAAS,GAAG,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBACnD,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CACzC,kBAAkB,CAAC,GAAG,CAAC,+BAA+B,QAAQ,IAAI,MAAM,EAAE,CAAC,CAC5E,CAAC;gBACF,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW;SAC/B,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { IProductPricingDirector } from '@unchainedshop/types/products.pricing.js';
2
+ export declare const ProductPricingDirector: IProductPricingDirector;
3
+ //# sourceMappingURL=ProductPricingDirector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingDirector.d.ts","sourceRoot":"","sources":["../../src/director/ProductPricingDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EAIxB,MAAM,0CAA0C,CAAC;AAWlD,eAAO,MAAM,sBAAsB,EAAE,uBA2DpC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { BasePricingDirector } from '@unchainedshop/utils';
2
+ import { ProductPricingSheet } from './ProductPricingSheet.js';
3
+ const baseDirector = BasePricingDirector('ProductPricingDirector');
4
+ export const ProductPricingDirector = {
5
+ ...baseDirector,
6
+ async buildPricingContext(context, unchainedAPI) {
7
+ const { modules } = unchainedAPI;
8
+ if ('item' in context) {
9
+ const { item } = context;
10
+ const product = await modules.products.findProduct({
11
+ productId: item.productId,
12
+ });
13
+ const order = await modules.orders.findOrder({
14
+ orderId: item.orderId,
15
+ });
16
+ const user = await modules.users.findUserById(order.userId);
17
+ const discounts = await modules.orders.discounts.findOrderDiscounts({
18
+ orderId: item.orderId,
19
+ });
20
+ return {
21
+ ...unchainedAPI,
22
+ country: order.countryCode,
23
+ currency: order.currency,
24
+ discounts,
25
+ order,
26
+ product,
27
+ quantity: item.quantity,
28
+ configuration: item.configuration,
29
+ user,
30
+ };
31
+ }
32
+ return {
33
+ ...unchainedAPI,
34
+ country: context.country,
35
+ currency: context.currency,
36
+ discounts: [],
37
+ order: context.order,
38
+ product: context.product,
39
+ quantity: context.quantity,
40
+ configuration: context.configuration,
41
+ user: context.user,
42
+ };
43
+ },
44
+ async actions(pricingContext, unchainedAPI) {
45
+ const actions = await baseDirector.actions(pricingContext, unchainedAPI, this.buildPricingContext);
46
+ return {
47
+ ...actions,
48
+ calculationSheet() {
49
+ const context = actions.getContext();
50
+ return ProductPricingSheet({
51
+ calculation: actions.getCalculation(),
52
+ currency: context.currency,
53
+ quantity: context.quantity,
54
+ });
55
+ },
56
+ };
57
+ },
58
+ };
59
+ //# sourceMappingURL=ProductPricingDirector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingDirector.js","sourceRoot":"","sources":["../../src/director/ProductPricingDirector.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,YAAY,GAAG,mBAAmB,CAKtC,wBAAwB,CAAC,CAAC;AAE5B,MAAM,CAAC,MAAM,sBAAsB,GAA4B;IAC7D,GAAG,YAAY;IAEf,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY;QAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;QAEjC,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;YACtB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;YACzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACjD,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;gBAC3C,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC5D,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC;gBAClE,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,YAAY;gBACf,OAAO,EAAE,KAAK,CAAC,WAAW;gBAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS;gBACT,KAAK;gBACL,OAAO;gBACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,IAAI;aACL,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,EAAE;YACb,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,YAAY;QACxC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACnG,OAAO;YACL,GAAG,OAAO;YACV,gBAAgB;gBACd,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;gBACrC,OAAO,mBAAmB,CAAC;oBACzB,WAAW,EAAE,OAAO,CAAC,cAAc,EAAE;oBACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;iBAC3B,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ProductPricingCalculation, IProductPricingSheet } from '@unchainedshop/types/products.pricing.js';
2
+ import { PricingSheetParams } from '@unchainedshop/types/pricing.js';
3
+ export declare const ProductPricingSheet: (params: PricingSheetParams<ProductPricingCalculation>) => IProductPricingSheet;
4
+ //# sourceMappingURL=ProductPricingSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingSheet.d.ts","sourceRoot":"","sources":["../../src/director/ProductPricingSheet.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EAEzB,oBAAoB,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,mBAAmB,WACtB,kBAAkB,CAAC,yBAAyB,CAAC,KACpD,oBAmFF,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { BasePricingSheet } from '@unchainedshop/utils';
2
+ import { ProductPricingRowCategory, } from '@unchainedshop/types/products.pricing.js';
3
+ export const ProductPricingSheet = (params) => {
4
+ const basePricingSheet = BasePricingSheet(params);
5
+ const pricingSheet = {
6
+ ...basePricingSheet,
7
+ addDiscount({ amount, isTaxable, isNetPrice, discountId, meta }) {
8
+ basePricingSheet.calculation.push({
9
+ category: ProductPricingRowCategory.Discount,
10
+ amount,
11
+ isTaxable,
12
+ isNetPrice,
13
+ discountId,
14
+ meta,
15
+ });
16
+ },
17
+ addItem({ amount, isTaxable, isNetPrice, meta }) {
18
+ basePricingSheet.calculation.push({
19
+ category: ProductPricingRowCategory.Item,
20
+ amount,
21
+ isTaxable,
22
+ isNetPrice,
23
+ meta,
24
+ });
25
+ },
26
+ addTax({ amount, baseCategory, rate, meta, discountId }) {
27
+ basePricingSheet.calculation.push({
28
+ category: ProductPricingRowCategory.Tax,
29
+ baseCategory,
30
+ discountId,
31
+ amount,
32
+ isTaxable: false,
33
+ isNetPrice: false,
34
+ rate,
35
+ meta,
36
+ });
37
+ },
38
+ taxSum(filter) {
39
+ return basePricingSheet.sum({
40
+ category: ProductPricingRowCategory.Tax,
41
+ ...(filter || {}),
42
+ });
43
+ },
44
+ unitPrice(unitPriceParams) {
45
+ const amount = unitPriceParams?.useNetPrice ? this.net() : this.gross();
46
+ return {
47
+ amount: Math.round(amount / this.quantity),
48
+ currency: this.currency,
49
+ };
50
+ },
51
+ discountPrices(explicitDiscountId) {
52
+ const discountIds = pricingSheet
53
+ .filterBy({
54
+ category: ProductPricingRowCategory.Discount,
55
+ discountId: explicitDiscountId,
56
+ })
57
+ .map(({ discountId }) => discountId);
58
+ return [...new Set(discountIds)]
59
+ .map((discountId) => {
60
+ const amount = basePricingSheet.sum({
61
+ category: ProductPricingRowCategory.Discount,
62
+ discountId,
63
+ });
64
+ if (!amount) {
65
+ return null;
66
+ }
67
+ return {
68
+ discountId,
69
+ amount: Math.round(amount),
70
+ currency: basePricingSheet.currency,
71
+ };
72
+ })
73
+ .filter(Boolean);
74
+ },
75
+ };
76
+ return pricingSheet;
77
+ };
78
+ //# sourceMappingURL=ProductPricingSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPricingSheet.js","sourceRoot":"","sources":["../../src/director/ProductPricingSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAEL,yBAAyB,GAE1B,MAAM,0CAA0C,CAAC;AAGlD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAAqD,EAC/B,EAAE;IACxB,MAAM,gBAAgB,GAAG,gBAAgB,CAA4B,MAAM,CAAC,CAAC;IAE7E,MAAM,YAAY,GAAyB;QACzC,GAAG,gBAAgB;QAEnB,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;YAC7D,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC;gBAChC,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;gBAC5C,MAAM;gBACN,SAAS;gBACT,UAAU;gBACV,UAAU;gBACV,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QAED,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS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