@vendure/core 3.0.2 → 3.1.0-next.1

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 (73) hide show
  1. package/dist/api/common/request-context.d.ts +34 -0
  2. package/dist/api/common/request-context.js +36 -0
  3. package/dist/api/common/request-context.js.map +1 -1
  4. package/dist/cache/cache.module.js +5 -2
  5. package/dist/cache/cache.module.js.map +1 -1
  6. package/dist/cache/cache.service.d.ts +37 -0
  7. package/dist/cache/cache.service.js +83 -0
  8. package/dist/cache/cache.service.js.map +1 -0
  9. package/dist/config/config.module.js +2 -0
  10. package/dist/config/config.module.js.map +1 -1
  11. package/dist/config/default-config.js +2 -0
  12. package/dist/config/default-config.js.map +1 -1
  13. package/dist/config/entity/default-money-strategy.js +1 -1
  14. package/dist/config/entity/default-money-strategy.js.map +1 -1
  15. package/dist/config/entity/money-strategy.d.ts +1 -1
  16. package/dist/config/promotion/actions/facet-values-percentage-discount-action.js +2 -3
  17. package/dist/config/promotion/actions/facet-values-percentage-discount-action.js.map +1 -1
  18. package/dist/config/promotion/actions/order-line-fixed-discount-action.d.ts +9 -0
  19. package/dist/config/promotion/actions/order-line-fixed-discount-action.js +21 -0
  20. package/dist/config/promotion/actions/order-line-fixed-discount-action.js.map +1 -0
  21. package/dist/config/promotion/conditions/has-facet-values-condition.js +2 -3
  22. package/dist/config/promotion/conditions/has-facet-values-condition.js.map +1 -1
  23. package/dist/config/promotion/index.d.ts +7 -1
  24. package/dist/config/promotion/index.js +2 -1
  25. package/dist/config/promotion/index.js.map +1 -1
  26. package/dist/config/promotion/promotion-action.d.ts +53 -1
  27. package/dist/config/promotion/promotion-action.js +36 -1
  28. package/dist/config/promotion/promotion-action.js.map +1 -1
  29. package/dist/config/system/cache-strategy.d.ts +47 -0
  30. package/dist/config/system/cache-strategy.js +3 -0
  31. package/dist/config/system/cache-strategy.js.map +1 -0
  32. package/dist/config/system/in-memory-cache-strategy.d.ts +26 -0
  33. package/dist/config/system/in-memory-cache-strategy.js +56 -0
  34. package/dist/config/system/in-memory-cache-strategy.js.map +1 -0
  35. package/dist/config/vendure-config.d.ts +10 -0
  36. package/dist/connection/transactional-connection.d.ts +13 -2
  37. package/dist/connection/transactional-connection.js +23 -3
  38. package/dist/connection/transactional-connection.js.map +1 -1
  39. package/dist/entity/promotion/promotion.entity.d.ts +5 -1
  40. package/dist/entity/promotion/promotion.entity.js +10 -1
  41. package/dist/entity/promotion/promotion.entity.js.map +1 -1
  42. package/dist/plugin/default-cache-plugin/cache-item.entity.d.ts +8 -0
  43. package/dist/plugin/default-cache-plugin/cache-item.entity.js +38 -0
  44. package/dist/plugin/default-cache-plugin/cache-item.entity.js.map +1 -0
  45. package/dist/plugin/default-cache-plugin/constants.d.ts +1 -0
  46. package/dist/plugin/default-cache-plugin/constants.js +5 -0
  47. package/dist/plugin/default-cache-plugin/constants.js.map +1 -0
  48. package/dist/plugin/default-cache-plugin/default-cache-plugin.d.ts +7 -0
  49. package/dist/plugin/default-cache-plugin/default-cache-plugin.js +40 -0
  50. package/dist/plugin/default-cache-plugin/default-cache-plugin.js.map +1 -0
  51. package/dist/plugin/default-cache-plugin/sql-cache-strategy.d.ts +26 -0
  52. package/dist/plugin/default-cache-plugin/sql-cache-strategy.js +91 -0
  53. package/dist/plugin/default-cache-plugin/sql-cache-strategy.js.map +1 -0
  54. package/dist/plugin/index.d.ts +2 -0
  55. package/dist/plugin/index.js +2 -0
  56. package/dist/plugin/index.js.map +1 -1
  57. package/dist/service/helpers/external-authentication/external-authentication.service.d.ts +12 -0
  58. package/dist/service/helpers/external-authentication/external-authentication.service.js +23 -0
  59. package/dist/service/helpers/external-authentication/external-authentication.service.js.map +1 -1
  60. package/dist/{config/promotion/utils → service/helpers/facet-value-checker}/facet-value-checker.d.ts +21 -5
  61. package/dist/service/helpers/facet-value-checker/facet-value-checker.js +151 -0
  62. package/dist/service/helpers/facet-value-checker/facet-value-checker.js.map +1 -0
  63. package/dist/service/helpers/order-calculator/order-calculator.d.ts +2 -0
  64. package/dist/service/helpers/order-calculator/order-calculator.js +2 -1
  65. package/dist/service/helpers/order-calculator/order-calculator.js.map +1 -1
  66. package/dist/service/index.d.ts +1 -0
  67. package/dist/service/index.js +1 -0
  68. package/dist/service/index.js.map +1 -1
  69. package/dist/service/service.module.js +2 -0
  70. package/dist/service/service.module.js.map +1 -1
  71. package/package.json +3 -3
  72. package/dist/config/promotion/utils/facet-value-checker.js +0 -76
  73. package/dist/config/promotion/utils/facet-value-checker.js.map +0 -1
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FacetValueChecker = void 0;
4
- const unique_1 = require("@vendure/common/lib/unique");
5
- const ttl_cache_1 = require("../../../common/ttl-cache");
6
- const utils_1 = require("../../../common/utils");
7
- const product_variant_entity_1 = require("../../../entity/product-variant/product-variant.entity");
8
- /**
9
- * @description
10
- * The FacetValueChecker is a helper class used to determine whether a given OrderLine consists
11
- * of ProductVariants containing the given FacetValues.
12
- *
13
- * @example
14
- * ```ts
15
- * import { FacetValueChecker, LanguageCode, PromotionCondition, TransactionalConnection } from '\@vendure/core';
16
- *
17
- * let facetValueChecker: FacetValueChecker;
18
- *
19
- * export const hasFacetValues = new PromotionCondition({
20
- * code: 'at_least_n_with_facets',
21
- * description: [
22
- * { languageCode: LanguageCode.en, value: 'Buy at least { minimum } products with the given facets' },
23
- * ],
24
- * args: {
25
- * minimum: { type: 'int' },
26
- * facets: { type: 'ID', list: true, ui: { component: 'facet-value-form-input' } },
27
- * },
28
- * init(injector) {
29
- * facetValueChecker = new FacetValueChecker(injector.get(TransactionalConnection));
30
- * },
31
- * async check(ctx, order, args) {
32
- * let matches = 0;
33
- * for (const line of order.lines) {
34
- * if (await facetValueChecker.hasFacetValues(line, args.facets)) {
35
- * matches += line.quantity;
36
- * }
37
- * }
38
- * return args.minimum <= matches;
39
- * },
40
- * });
41
- * ```
42
- *
43
- * @docsCategory Promotions
44
- */
45
- class FacetValueChecker {
46
- constructor(connection) {
47
- this.connection = connection;
48
- this.variantCache = new ttl_cache_1.TtlCache({ ttl: 5000 });
49
- }
50
- /**
51
- * @description
52
- * Checks a given {@link OrderLine} against the facetValueIds and returns
53
- * `true` if the associated {@link ProductVariant} & {@link Product} together
54
- * have *all* the specified {@link FacetValue}s.
55
- */
56
- async hasFacetValues(orderLine, facetValueIds, ctx) {
57
- let variant = this.variantCache.get(orderLine.productVariant.id);
58
- if (!variant) {
59
- variant = await this.connection
60
- .getRepository(ctx, product_variant_entity_1.ProductVariant)
61
- .findOne({
62
- where: { id: orderLine.productVariant.id },
63
- relations: ['product', 'product.facetValues', 'facetValues'],
64
- })
65
- .then(result => result !== null && result !== void 0 ? result : undefined);
66
- if (!variant) {
67
- return false;
68
- }
69
- this.variantCache.set(variant.id, variant);
70
- }
71
- const allFacetValues = (0, unique_1.unique)([...variant.facetValues, ...variant.product.facetValues], 'id');
72
- return facetValueIds.reduce((result, id) => result && !!allFacetValues.find(fv => (0, utils_1.idsAreEqual)(fv.id, id)), true);
73
- }
74
- }
75
- exports.FacetValueChecker = FacetValueChecker;
76
- //# sourceMappingURL=facet-value-checker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"facet-value-checker.js","sourceRoot":"","sources":["../../../../src/config/promotion/utils/facet-value-checker.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAGpD,yDAAqD;AACrD,iDAAoD;AAGpD,mGAAwF;AAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,iBAAiB;IAG1B,YAAoB,UAAmC;QAAnC,eAAU,GAAV,UAAU,CAAyB;QAF/C,iBAAY,GAAG,IAAI,oBAAQ,CAAqB,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAEb,CAAC;IAC3D;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,SAAoB,EAAE,aAAmB,EAAE,GAAoB;QAChF,IAAI,OAAO,GAAG,IAAI,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