@vendure/core 3.1.0-next.3 → 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 (194) hide show
  1. package/cli/populate.js +3 -1
  2. package/cli/populate.js.map +1 -1
  3. package/dist/api/common/request-context.d.ts +1 -1
  4. package/dist/api/common/request-context.js +1 -1
  5. package/dist/api/common/validate-custom-field-value.js +28 -0
  6. package/dist/api/common/validate-custom-field-value.js.map +1 -1
  7. package/dist/api/config/generate-active-order-types.js +2 -0
  8. package/dist/api/config/generate-active-order-types.js.map +1 -1
  9. package/dist/api/config/generate-resolvers.d.ts +10 -4
  10. package/dist/api/config/generate-resolvers.js +73 -7
  11. package/dist/api/config/generate-resolvers.js.map +1 -1
  12. package/dist/api/config/get-custom-fields-config-without-interfaces.d.ts +2 -0
  13. package/dist/api/config/get-custom-fields-config-without-interfaces.js +16 -11
  14. package/dist/api/config/get-custom-fields-config-without-interfaces.js.map +1 -1
  15. package/dist/api/config/graphql-custom-fields.js +116 -22
  16. package/dist/api/config/graphql-custom-fields.js.map +1 -1
  17. package/dist/api/resolvers/admin/draft-order.resolver.d.ts +3 -1
  18. package/dist/api/resolvers/admin/draft-order.resolver.js +26 -0
  19. package/dist/api/resolvers/admin/draft-order.resolver.js.map +1 -1
  20. package/dist/api/resolvers/admin/global-settings.resolver.d.ts +2 -0
  21. package/dist/api/resolvers/admin/global-settings.resolver.js +12 -0
  22. package/dist/api/resolvers/admin/global-settings.resolver.js.map +1 -1
  23. package/dist/api/resolvers/entity/order-line-entity.resolver.js +7 -3
  24. package/dist/api/resolvers/entity/order-line-entity.resolver.js.map +1 -1
  25. package/dist/api/resolvers/shop/shop-order.resolver.d.ts +2 -0
  26. package/dist/api/resolvers/shop/shop-order.resolver.js +38 -0
  27. package/dist/api/resolvers/shop/shop-order.resolver.js.map +1 -1
  28. package/dist/api/schema/admin-api/order.api.graphql +14 -12
  29. package/dist/api/schema/common/common-error-results.graphql +9 -0
  30. package/dist/api/schema/common/common-types.graphql +2 -1
  31. package/dist/api/schema/common/custom-field-types.graphql +99 -0
  32. package/dist/api/schema/shop-api/shop.api.graphql +30 -13
  33. package/dist/bootstrap.d.ts +56 -3
  34. package/dist/bootstrap.js +36 -6
  35. package/dist/bootstrap.js.map +1 -1
  36. package/dist/cache/cache-ttl-provider.d.ts +38 -0
  37. package/dist/cache/cache-ttl-provider.js +39 -0
  38. package/dist/cache/cache-ttl-provider.js.map +1 -0
  39. package/dist/cache/cache.d.ts +88 -0
  40. package/dist/cache/cache.js +79 -0
  41. package/dist/cache/cache.js.map +1 -0
  42. package/dist/cache/cache.service.d.ts +15 -0
  43. package/dist/cache/cache.service.js +25 -0
  44. package/dist/cache/cache.service.js.map +1 -1
  45. package/dist/cache/index.d.ts +2 -0
  46. package/dist/cache/index.js +2 -0
  47. package/dist/cache/index.js.map +1 -1
  48. package/dist/cache/request-context-cache.service.d.ts +14 -0
  49. package/dist/cache/request-context-cache.service.js +9 -0
  50. package/dist/cache/request-context-cache.service.js.map +1 -1
  51. package/dist/common/error/generated-graphql-admin-errors.d.ts +9 -0
  52. package/dist/common/error/generated-graphql-admin-errors.js +12 -2
  53. package/dist/common/error/generated-graphql-admin-errors.js.map +1 -1
  54. package/dist/common/error/generated-graphql-shop-errors.d.ts +9 -0
  55. package/dist/common/error/generated-graphql-shop-errors.js +12 -2
  56. package/dist/common/error/generated-graphql-shop-errors.js.map +1 -1
  57. package/dist/common/ttl-cache.d.ts +3 -0
  58. package/dist/common/ttl-cache.js +3 -0
  59. package/dist/common/ttl-cache.js.map +1 -1
  60. package/dist/common/types/entity-relation-paths.d.ts +2 -1
  61. package/dist/common/utils.d.ts +1 -1
  62. package/dist/common/utils.js +1 -1
  63. package/dist/common/utils.js.map +1 -1
  64. package/dist/config/catalog/default-stock-location-strategy.d.ts +15 -8
  65. package/dist/config/catalog/default-stock-location-strategy.js +30 -22
  66. package/dist/config/catalog/default-stock-location-strategy.js.map +1 -1
  67. package/dist/config/catalog/multi-channel-stock-location-strategy.d.ts +55 -0
  68. package/dist/config/catalog/multi-channel-stock-location-strategy.js +144 -0
  69. package/dist/config/catalog/multi-channel-stock-location-strategy.js.map +1 -0
  70. package/dist/config/config.module.js +2 -1
  71. package/dist/config/config.module.js.map +1 -1
  72. package/dist/config/custom-field/custom-field-types.d.ts +69 -5
  73. package/dist/config/default-config.js +12 -4
  74. package/dist/config/default-config.js.map +1 -1
  75. package/dist/config/index.d.ts +4 -0
  76. package/dist/config/index.js +4 -0
  77. package/dist/config/index.js.map +1 -1
  78. package/dist/config/order/order-interceptor.d.ts +233 -0
  79. package/dist/config/order/order-interceptor.js +3 -0
  80. package/dist/config/order/order-interceptor.js.map +1 -0
  81. package/dist/config/promotion/conditions/customer-group-condition.js +17 -12
  82. package/dist/config/promotion/conditions/customer-group-condition.js.map +1 -1
  83. package/dist/config/session-cache/default-session-cache-strategy.d.ts +34 -0
  84. package/dist/config/session-cache/default-session-cache-strategy.js +63 -0
  85. package/dist/config/session-cache/default-session-cache-strategy.js.map +1 -0
  86. package/dist/config/session-cache/session-cache-strategy.d.ts +13 -4
  87. package/dist/config/shipping-method/shipping-eligibility-checker.d.ts +4 -2
  88. package/dist/config/shipping-method/shipping-eligibility-checker.js +8 -5
  89. package/dist/config/shipping-method/shipping-eligibility-checker.js.map +1 -1
  90. package/dist/config/system/cache-strategy.d.ts +12 -0
  91. package/dist/config/system/in-memory-cache-strategy.d.ts +8 -0
  92. package/dist/config/system/in-memory-cache-strategy.js +26 -3
  93. package/dist/config/system/in-memory-cache-strategy.js.map +1 -1
  94. package/dist/config/tax/address-based-tax-zone-strategy.d.ts +24 -0
  95. package/dist/config/tax/address-based-tax-zone-strategy.js +39 -0
  96. package/dist/config/tax/address-based-tax-zone-strategy.js.map +1 -0
  97. package/dist/config/vendure-config.d.ts +15 -6
  98. package/dist/data-import/providers/importer/importer.js +8 -0
  99. package/dist/data-import/providers/importer/importer.js.map +1 -1
  100. package/dist/data-import/providers/populator/populator.js +0 -1
  101. package/dist/data-import/providers/populator/populator.js.map +1 -1
  102. package/dist/entity/custom-entity-fields.d.ts +14 -0
  103. package/dist/entity/custom-entity-fields.js +22 -1
  104. package/dist/entity/custom-entity-fields.js.map +1 -1
  105. package/dist/entity/history-entry/history-entry.entity.d.ts +4 -1
  106. package/dist/entity/history-entry/history-entry.entity.js +5 -0
  107. package/dist/entity/history-entry/history-entry.entity.js.map +1 -1
  108. package/dist/entity/payment/payment.entity.d.ts +4 -1
  109. package/dist/entity/payment/payment.entity.js +5 -0
  110. package/dist/entity/payment/payment.entity.js.map +1 -1
  111. package/dist/entity/refund/refund.entity.d.ts +4 -1
  112. package/dist/entity/refund/refund.entity.js +5 -0
  113. package/dist/entity/refund/refund.entity.js.map +1 -1
  114. package/dist/entity/register-custom-entity-fields.js +17 -2
  115. package/dist/entity/register-custom-entity-fields.js.map +1 -1
  116. package/dist/entity/session/session.entity.d.ts +4 -1
  117. package/dist/entity/session/session.entity.js +5 -0
  118. package/dist/entity/session/session.entity.js.map +1 -1
  119. package/dist/entity/shipping-line/shipping-line.entity.d.ts +5 -2
  120. package/dist/entity/shipping-line/shipping-line.entity.js +7 -2
  121. package/dist/entity/shipping-line/shipping-line.entity.js.map +1 -1
  122. package/dist/entity/stock-level/stock-level.entity.d.ts +4 -1
  123. package/dist/entity/stock-level/stock-level.entity.js +5 -0
  124. package/dist/entity/stock-level/stock-level.entity.js.map +1 -1
  125. package/dist/entity/stock-movement/stock-movement.entity.d.ts +4 -1
  126. package/dist/entity/stock-movement/stock-movement.entity.js +5 -0
  127. package/dist/entity/stock-movement/stock-movement.entity.js.map +1 -1
  128. package/dist/event-bus/events/stock-location-event.d.ts +18 -0
  129. package/dist/event-bus/events/stock-location-event.js +19 -0
  130. package/dist/event-bus/events/stock-location-event.js.map +1 -0
  131. package/dist/event-bus/index.d.ts +1 -0
  132. package/dist/event-bus/index.js +1 -0
  133. package/dist/event-bus/index.js.map +1 -1
  134. package/dist/i18n/messages/de.json +1 -0
  135. package/dist/i18n/messages/en.json +2 -0
  136. package/dist/plugin/default-cache-plugin/cache-item.entity.d.ts +1 -0
  137. package/dist/plugin/default-cache-plugin/cache-item.entity.js +4 -0
  138. package/dist/plugin/default-cache-plugin/cache-item.entity.js.map +1 -1
  139. package/dist/plugin/default-cache-plugin/cache-tag.entity.d.ts +9 -0
  140. package/dist/plugin/default-cache-plugin/cache-tag.entity.js +41 -0
  141. package/dist/plugin/default-cache-plugin/cache-tag.entity.js.map +1 -0
  142. package/dist/plugin/default-cache-plugin/default-cache-plugin.d.ts +21 -0
  143. package/dist/plugin/default-cache-plugin/default-cache-plugin.js +13 -1
  144. package/dist/plugin/default-cache-plugin/default-cache-plugin.js.map +1 -1
  145. package/dist/plugin/default-cache-plugin/sql-cache-strategy.d.ts +7 -6
  146. package/dist/plugin/default-cache-plugin/sql-cache-strategy.js +57 -13
  147. package/dist/plugin/default-cache-plugin/sql-cache-strategy.js.map +1 -1
  148. package/dist/plugin/default-search-plugin/default-search-plugin.js +4 -0
  149. package/dist/plugin/default-search-plugin/default-search-plugin.js.map +1 -1
  150. package/dist/plugin/default-search-plugin/indexer/indexer.controller.js +1 -0
  151. package/dist/plugin/default-search-plugin/indexer/indexer.controller.js.map +1 -1
  152. package/dist/plugin/index.d.ts +3 -0
  153. package/dist/plugin/index.js +3 -0
  154. package/dist/plugin/index.js.map +1 -1
  155. package/dist/plugin/redis-cache-plugin/constants.d.ts +4 -0
  156. package/dist/plugin/redis-cache-plugin/constants.js +8 -0
  157. package/dist/plugin/redis-cache-plugin/constants.js.map +1 -0
  158. package/dist/plugin/redis-cache-plugin/redis-cache-plugin.d.ts +14 -0
  159. package/dist/plugin/redis-cache-plugin/redis-cache-plugin.js +47 -0
  160. package/dist/plugin/redis-cache-plugin/redis-cache-plugin.js.map +1 -0
  161. package/dist/plugin/redis-cache-plugin/redis-cache-strategy.d.ts +24 -0
  162. package/dist/plugin/redis-cache-plugin/redis-cache-strategy.js +104 -0
  163. package/dist/plugin/redis-cache-plugin/redis-cache-strategy.js.map +1 -0
  164. package/dist/plugin/redis-cache-plugin/types.d.ts +12 -0
  165. package/dist/plugin/redis-cache-plugin/types.js +3 -0
  166. package/dist/plugin/redis-cache-plugin/types.js.map +1 -0
  167. package/dist/plugin/vendure-plugin.d.ts +5 -0
  168. package/dist/plugin/vendure-plugin.js.map +1 -1
  169. package/dist/service/helpers/external-authentication/external-authentication.service.d.ts +1 -1
  170. package/dist/service/helpers/external-authentication/external-authentication.service.js +1 -1
  171. package/dist/service/helpers/facet-value-checker/facet-value-checker.d.ts +3 -4
  172. package/dist/service/helpers/facet-value-checker/facet-value-checker.js +11 -17
  173. package/dist/service/helpers/facet-value-checker/facet-value-checker.js.map +1 -1
  174. package/dist/service/helpers/order-modifier/order-modifier.js +14 -6
  175. package/dist/service/helpers/order-modifier/order-modifier.js.map +1 -1
  176. package/dist/service/helpers/utils/tree-relations-qb-joiner.js +1 -1
  177. package/dist/service/helpers/utils/tree-relations-qb-joiner.js.map +1 -1
  178. package/dist/service/services/channel.service.js +5 -0
  179. package/dist/service/services/channel.service.js.map +1 -1
  180. package/dist/service/services/order.service.d.ts +71 -1
  181. package/dist/service/services/order.service.js +270 -83
  182. package/dist/service/services/order.service.js.map +1 -1
  183. package/dist/service/services/payment.service.js +6 -4
  184. package/dist/service/services/payment.service.js.map +1 -1
  185. package/dist/service/services/product-variant.service.js +1 -1
  186. package/dist/service/services/product-variant.service.js.map +1 -1
  187. package/dist/service/services/promotion.service.js +1 -0
  188. package/dist/service/services/promotion.service.js.map +1 -1
  189. package/dist/service/services/role.service.js +6 -5
  190. package/dist/service/services/role.service.js.map +1 -1
  191. package/dist/service/services/stock-location.service.d.ts +3 -1
  192. package/dist/service/services/stock-location.service.js +9 -2
  193. package/dist/service/services/stock-location.service.js.map +1 -1
  194. package/package.json +22 -22
@@ -1,4 +1,5 @@
1
1
  import { VendureEntity } from '../../entity/base/base.entity';
2
+ import { Translation } from './locale-types';
2
3
  /**
3
4
  * @description
4
5
  * This type allows type-safe access to entity relations using strings with dot notation.
@@ -21,7 +22,7 @@ import { VendureEntity } from '../../entity/base/base.entity';
21
22
  */
22
23
  export type EntityRelationPaths<T extends VendureEntity> = `customFields.${string}` | PathsToStringProps1<T> | Join<PathsToStringProps2<T>, '.'> | TripleDotPath;
23
24
  export type EntityRelationKeys<T extends VendureEntity> = {
24
- [K in Extract<keyof T, string>]: Required<T>[K] extends VendureEntity | null ? K : Required<T>[K] extends VendureEntity[] ? K : never;
25
+ [K in Extract<keyof T, string>]: Required<T>[K] extends VendureEntity | Translation<VendureEntity> | null ? K : Required<T>[K] extends VendureEntity[] | Array<Translation<VendureEntity>> ? K : never;
25
26
  }[Extract<keyof T, string>];
26
27
  export type EntityRelations<T extends VendureEntity> = {
27
28
  [K in EntityRelationKeys<T>]: T[K];
@@ -24,7 +24,7 @@ export declare function assertFound<T>(promise: Promise<T | undefined | null>):
24
24
  * Compare ID values for equality, taking into account the fact that they may not be of matching types
25
25
  * (string or number).
26
26
  */
27
- export declare function idsAreEqual(id1?: ID, id2?: ID): boolean;
27
+ export declare function idsAreEqual(id1?: ID | null, id2?: ID | null): boolean;
28
28
  /**
29
29
  * Returns the AssetType based on the mime type.
30
30
  */
@@ -33,7 +33,7 @@ exports.assertFound = assertFound;
33
33
  * (string or number).
34
34
  */
35
35
  function idsAreEqual(id1, id2) {
36
- if (id1 === undefined || id2 === undefined) {
36
+ if (id1 == null || id2 == null) {
37
37
  return false;
38
38
  }
39
39
  return id1.toString() === id2.toString();
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA,yEAAgE;AAEhE,+BAA2D;AAM3D;;GAEG;AACH,SAAgB,GAAG,CAAC,SAAsC;IACtD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;AACnD,CAAC;AAFD,kBAEC;AAED;;;GAGG;AAC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AC,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAlBD,oDAkBC"}
@@ -6,21 +6,28 @@ import { OrderLine } from '../../entity/order-line/order-line.entity';
6
6
  import { StockLevel } from '../../entity/stock-level/stock-level.entity';
7
7
  import { StockLocation } from '../../entity/stock-location/stock-location.entity';
8
8
  import { AvailableStock, LocationWithQuantity, StockLocationStrategy } from './stock-location-strategy';
9
+ export declare abstract class BaseStockLocationStrategy implements StockLocationStrategy {
10
+ protected connection: TransactionalConnection;
11
+ init(injector: Injector): void;
12
+ abstract getAvailableStock(ctx: RequestContext, productVariantId: ID, stockLevels: StockLevel[]): AvailableStock | Promise<AvailableStock>;
13
+ abstract forAllocation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): LocationWithQuantity[] | Promise<LocationWithQuantity[]>;
14
+ forCancellation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
15
+ forRelease(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
16
+ forSale(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
17
+ private getLocationsBasedOnAllocations;
18
+ }
9
19
  /**
10
20
  * @description
11
- * The DefaultStockLocationStrategy is the default implementation of the {@link StockLocationStrategy}.
12
- * It assumes only a single StockLocation and that all stock is allocated from that location.
21
+ * The DefaultStockLocationStrategy was the default implementation of the {@link StockLocationStrategy}
22
+ * prior to the introduction of the {@link MultiChannelStockLocationStrategy}.
23
+ * It assumes only a single StockLocation and that all stock is allocated from that location. When
24
+ * more than one StockLocation or Channel is used, it will not behave as expected.
13
25
  *
14
26
  * @docsCategory products & stock
15
27
  * @since 2.0.0
16
28
  */
17
- export declare class DefaultStockLocationStrategy implements StockLocationStrategy {
18
- protected connection: TransactionalConnection;
29
+ export declare class DefaultStockLocationStrategy extends BaseStockLocationStrategy {
19
30
  init(injector: Injector): void;
20
31
  getAvailableStock(ctx: RequestContext, productVariantId: ID, stockLevels: StockLevel[]): AvailableStock;
21
32
  forAllocation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): LocationWithQuantity[] | Promise<LocationWithQuantity[]>;
22
- forCancellation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
23
- forRelease(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
24
- forSale(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
25
- private getLocationsBasedOnAllocations;
26
33
  }
@@ -1,33 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultStockLocationStrategy = void 0;
3
+ exports.DefaultStockLocationStrategy = exports.BaseStockLocationStrategy = void 0;
4
4
  const utils_1 = require("../../common/utils");
5
5
  const transactional_connection_1 = require("../../connection/transactional-connection");
6
6
  const allocation_entity_1 = require("../../entity/stock-movement/allocation.entity");
7
- /**
8
- * @description
9
- * The DefaultStockLocationStrategy is the default implementation of the {@link StockLocationStrategy}.
10
- * It assumes only a single StockLocation and that all stock is allocated from that location.
11
- *
12
- * @docsCategory products & stock
13
- * @since 2.0.0
14
- */
15
- class DefaultStockLocationStrategy {
7
+ class BaseStockLocationStrategy {
16
8
  init(injector) {
17
9
  this.connection = injector.get(transactional_connection_1.TransactionalConnection);
18
10
  }
19
- getAvailableStock(ctx, productVariantId, stockLevels) {
20
- let stockOnHand = 0;
21
- let stockAllocated = 0;
22
- for (const stockLevel of stockLevels) {
23
- stockOnHand += stockLevel.stockOnHand;
24
- stockAllocated += stockLevel.stockAllocated;
25
- }
26
- return { stockOnHand, stockAllocated };
27
- }
28
- forAllocation(ctx, stockLocations, orderLine, quantity) {
29
- return [{ location: stockLocations[0], quantity }];
30
- }
31
11
  async forCancellation(ctx, stockLocations, orderLine, quantity) {
32
12
  return this.getLocationsBasedOnAllocations(ctx, stockLocations, orderLine, quantity);
33
13
  }
@@ -66,5 +46,33 @@ class DefaultStockLocationStrategy {
66
46
  }));
67
47
  }
68
48
  }
49
+ exports.BaseStockLocationStrategy = BaseStockLocationStrategy;
50
+ /**
51
+ * @description
52
+ * The DefaultStockLocationStrategy was the default implementation of the {@link StockLocationStrategy}
53
+ * prior to the introduction of the {@link MultiChannelStockLocationStrategy}.
54
+ * It assumes only a single StockLocation and that all stock is allocated from that location. When
55
+ * more than one StockLocation or Channel is used, it will not behave as expected.
56
+ *
57
+ * @docsCategory products & stock
58
+ * @since 2.0.0
59
+ */
60
+ class DefaultStockLocationStrategy extends BaseStockLocationStrategy {
61
+ init(injector) {
62
+ super.init(injector);
63
+ }
64
+ getAvailableStock(ctx, productVariantId, stockLevels) {
65
+ let stockOnHand = 0;
66
+ let stockAllocated = 0;
67
+ for (const stockLevel of stockLevels) {
68
+ stockOnHand += stockLevel.stockOnHand;
69
+ stockAllocated += stockLevel.stockAllocated;
70
+ }
71
+ return { stockOnHand, stockAllocated };
72
+ }
73
+ forAllocation(ctx, stockLocations, orderLine, quantity) {
74
+ return [{ location: stockLocations[0], quantity }];
75
+ }
76
+ }
69
77
  exports.DefaultStockLocationStrategy = DefaultStockLocationStrategy;
70
78
  //# sourceMappingURL=default-stock-location-strategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-stock-location-strategy.js","sourceRoot":"","sources":["../../../src/config/catalog/default-stock-location-strategy.ts"],"names":[],"mappings":";;;AAIA,8CAAiD;AACjD,wFAAoF;AAIpF,qFAA2E;AAI3E;;;;;;;GAOG;AACH,MAAa,4BAA4B;IAGrC,IAAI,CAAC,QAAkB;QACnB,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,kDAAuB,CAAC,CAAC;IAC5D,CAAC;IAED,iBAAiB,CAAC,GAAmB,EAAE,gB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,SAAS,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE;aAClC;SACJ,CAAC,CAAC;QACH,IAAI,WAAW,GAAG,QAAQ,CAAC;QAC3B,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;QACnD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACnC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;gBACnB,MAAM;YACV,CAAC;YACD,MAAM,aAAa,GAAG,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC5D,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBACxB,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,aAAa,GAAG,QAAQ,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACJ,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;YACnE,CAAC;YACD,WAAW,IAAI,QAAQ,CAAC;QAC5B,CAAC;QACD,OAAO,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YACnE,oEAAoE;YACpE,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,mBAAW,EAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAE;YAClE,QAAQ,EAAE,GAAG;SAChB,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AArFD,oEAqFC"}
1
+ {"version":3,"file":"default-stock-location-strategy.js","sourceRoot":"","sources":["../../../src/config/catalog/default-stock-location-strategy.ts"],"names":[],"mappings":";;;AAIA,8CAAiD;AACjD,wFAAoF;AAI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Ac,EAAE,CAAC;IAC3C,CAAC;IAED,aAAa,CACT,GAAmB,EACnB,cAA+B,EAC/B,SAAoB,EACpB,QAAgB;QAEhB,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;CACJ;AAvBD,oEAuBC"}
@@ -0,0 +1,55 @@
1
+ import type { GlobalSettingsService } from '../../service/index';
2
+ import { ID } from '@vendure/common/lib/shared-types';
3
+ import { RequestContext } from '../../api/common/request-context';
4
+ import { Cache, CacheService, RequestContextCacheService } from '../../cache/index';
5
+ import { Injector } from '../../common/injector';
6
+ import { OrderLine } from '../../entity/order-line/order-line.entity';
7
+ import { StockLevel } from '../../entity/stock-level/stock-level.entity';
8
+ import { StockLocation } from '../../entity/stock-location/stock-location.entity';
9
+ import { EventBus } from '../../event-bus/index';
10
+ import { BaseStockLocationStrategy } from './default-stock-location-strategy';
11
+ import { AvailableStock, LocationWithQuantity } from './stock-location-strategy';
12
+ /**
13
+ * @description
14
+ * The MultiChannelStockLocationStrategy is an implementation of the {@link StockLocationStrategy}.
15
+ * which is suitable for both single- and multichannel setups. It takes into account the active
16
+ * channel when determining stock levels, and also ensures that allocations are made only against
17
+ * stock locations which are associated with the active channel.
18
+ *
19
+ * This strategy became the default in Vendure 3.1.0. If you want to use the previous strategy which
20
+ * does not take channels into account, update your VendureConfig to use to {@link DefaultStockLocationStrategy}.
21
+ *
22
+ * @docsCategory products & stock
23
+ * @since 3.1.0
24
+ */
25
+ export declare class MultiChannelStockLocationStrategy extends BaseStockLocationStrategy {
26
+ protected cacheService: CacheService;
27
+ protected channelIdCache: Cache;
28
+ protected eventBus: EventBus;
29
+ protected globalSettingsService: GlobalSettingsService;
30
+ protected requestContextCache: RequestContextCacheService;
31
+ /** @internal */
32
+ init(injector: Injector): Promise<void>;
33
+ /**
34
+ * @description
35
+ * Returns the available stock for the given ProductVariant, taking into account the active Channel.
36
+ */
37
+ getAvailableStock(ctx: RequestContext, productVariantId: ID, stockLevels: StockLevel[]): Promise<AvailableStock>;
38
+ /**
39
+ * @description
40
+ * This method takes into account whether the stock location is applicable to the active channel.
41
+ * It furthermore respects the `trackInventory` and `outOfStockThreshold` settings of the ProductVariant,
42
+ * in order to allocate stock only from locations which are relevant to the active channel and which
43
+ * have sufficient stock available.
44
+ */
45
+ forAllocation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number): Promise<LocationWithQuantity[]>;
46
+ /**
47
+ * @description
48
+ * Determines whether the given StockLevel applies to the active Channel. Uses a cache to avoid
49
+ * repeated DB queries.
50
+ */
51
+ private stockLevelAppliesToActiveChannel;
52
+ private getCacheKey;
53
+ private getStockLevelsForVariant;
54
+ private getVariantStockSettings;
55
+ }
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MultiChannelStockLocationStrategy = void 0;
7
+ const generated_types_1 = require("@vendure/common/lib/generated-types");
8
+ const ms_1 = __importDefault(require("ms"));
9
+ const operators_1 = require("rxjs/operators");
10
+ const index_1 = require("../../cache/index");
11
+ const index_2 = require("../../entity/index");
12
+ const stock_level_entity_1 = require("../../entity/stock-level/stock-level.entity");
13
+ const stock_location_entity_1 = require("../../entity/stock-location/stock-location.entity");
14
+ const index_3 = require("../../event-bus/index");
15
+ const default_stock_location_strategy_1 = require("./default-stock-location-strategy");
16
+ /**
17
+ * @description
18
+ * The MultiChannelStockLocationStrategy is an implementation of the {@link StockLocationStrategy}.
19
+ * which is suitable for both single- and multichannel setups. It takes into account the active
20
+ * channel when determining stock levels, and also ensures that allocations are made only against
21
+ * stock locations which are associated with the active channel.
22
+ *
23
+ * This strategy became the default in Vendure 3.1.0. If you want to use the previous strategy which
24
+ * does not take channels into account, update your VendureConfig to use to {@link DefaultStockLocationStrategy}.
25
+ *
26
+ * @docsCategory products & stock
27
+ * @since 3.1.0
28
+ */
29
+ class MultiChannelStockLocationStrategy extends default_stock_location_strategy_1.BaseStockLocationStrategy {
30
+ /** @internal */
31
+ async init(injector) {
32
+ super.init(injector);
33
+ this.eventBus = injector.get(index_3.EventBus);
34
+ this.cacheService = injector.get(index_1.CacheService);
35
+ this.requestContextCache = injector.get(index_1.RequestContextCacheService);
36
+ // Dynamically import the GlobalSettingsService to avoid circular dependency
37
+ const GlobalSettingsService = (await import('../../service/services/global-settings.service.js'))
38
+ .GlobalSettingsService;
39
+ this.globalSettingsService = injector.get(GlobalSettingsService);
40
+ this.channelIdCache = this.cacheService.createCache({
41
+ options: {
42
+ ttl: (0, ms_1.default)('7 days'),
43
+ tags: ['StockLocation'],
44
+ },
45
+ getKey: id => this.getCacheKey(id),
46
+ });
47
+ // When a StockLocation is updated, we need to invalidate the cache
48
+ this.eventBus
49
+ .ofType(index_3.StockLocationEvent)
50
+ .pipe((0, operators_1.filter)(event => event.type !== 'created'))
51
+ .subscribe(({ entity }) => this.channelIdCache.delete(this.getCacheKey(entity.id)));
52
+ }
53
+ /**
54
+ * @description
55
+ * Returns the available stock for the given ProductVariant, taking into account the active Channel.
56
+ */
57
+ async getAvailableStock(ctx, productVariantId, stockLevels) {
58
+ let stockOnHand = 0;
59
+ let stockAllocated = 0;
60
+ for (const stockLevel of stockLevels) {
61
+ const applies = await this.stockLevelAppliesToActiveChannel(ctx, stockLevel);
62
+ if (applies) {
63
+ stockOnHand += stockLevel.stockOnHand;
64
+ stockAllocated += stockLevel.stockAllocated;
65
+ }
66
+ }
67
+ return { stockOnHand, stockAllocated };
68
+ }
69
+ /**
70
+ * @description
71
+ * This method takes into account whether the stock location is applicable to the active channel.
72
+ * It furthermore respects the `trackInventory` and `outOfStockThreshold` settings of the ProductVariant,
73
+ * in order to allocate stock only from locations which are relevant to the active channel and which
74
+ * have sufficient stock available.
75
+ */
76
+ async forAllocation(ctx, stockLocations, orderLine, quantity) {
77
+ const stockLevels = await this.getStockLevelsForVariant(ctx, orderLine.productVariantId);
78
+ const variant = await this.connection.getEntityOrThrow(ctx, index_2.ProductVariant, orderLine.productVariantId, { loadEagerRelations: false });
79
+ let totalAllocated = 0;
80
+ const locations = [];
81
+ const { inventoryNotTracked, effectiveOutOfStockThreshold } = await this.getVariantStockSettings(ctx, variant);
82
+ for (const stockLocation of stockLocations) {
83
+ const stockLevel = stockLevels.find(sl => sl.stockLocationId === stockLocation.id);
84
+ if (stockLevel && (await this.stockLevelAppliesToActiveChannel(ctx, stockLevel))) {
85
+ const quantityAvailable = inventoryNotTracked
86
+ ? Number.MAX_SAFE_INTEGER
87
+ : stockLevel.stockOnHand - stockLevel.stockAllocated - effectiveOutOfStockThreshold;
88
+ if (quantityAvailable > 0) {
89
+ const quantityToAllocate = Math.min(quantity, quantityAvailable);
90
+ locations.push({
91
+ location: stockLocation,
92
+ quantity: quantityToAllocate,
93
+ });
94
+ totalAllocated += quantityToAllocate;
95
+ }
96
+ }
97
+ if (totalAllocated >= quantity) {
98
+ break;
99
+ }
100
+ }
101
+ return locations;
102
+ }
103
+ /**
104
+ * @description
105
+ * Determines whether the given StockLevel applies to the active Channel. Uses a cache to avoid
106
+ * repeated DB queries.
107
+ */
108
+ async stockLevelAppliesToActiveChannel(ctx, stockLevel) {
109
+ const channelIds = await this.channelIdCache.get(stockLevel.stockLocationId, async () => {
110
+ const stockLocation = await this.connection.getEntityOrThrow(ctx, stock_location_entity_1.StockLocation, stockLevel.stockLocationId, {
111
+ relations: {
112
+ channels: true,
113
+ },
114
+ });
115
+ return stockLocation.channels.map(c => c.id);
116
+ });
117
+ return channelIds.includes(ctx.channelId);
118
+ }
119
+ getCacheKey(stockLocationId) {
120
+ return `MultiChannelStockLocationStrategy:StockLocationChannelIds:${stockLocationId}`;
121
+ }
122
+ getStockLevelsForVariant(ctx, productVariantId) {
123
+ return this.requestContextCache.get(ctx, `MultiChannelStockLocationStrategy.stockLevels.${productVariantId}`, () => this.connection.getRepository(ctx, stock_level_entity_1.StockLevel).find({
124
+ where: {
125
+ productVariantId,
126
+ },
127
+ loadEagerRelations: false,
128
+ }));
129
+ }
130
+ async getVariantStockSettings(ctx, variant) {
131
+ const { outOfStockThreshold, trackInventory } = await this.globalSettingsService.getSettings(ctx);
132
+ const inventoryNotTracked = variant.trackInventory === generated_types_1.GlobalFlag.FALSE ||
133
+ (variant.trackInventory === generated_types_1.GlobalFlag.INHERIT && trackInventory === false);
134
+ const effectiveOutOfStockThreshold = variant.useGlobalOutOfStockThreshold
135
+ ? outOfStockThreshold
136
+ : variant.outOfStockThreshold;
137
+ return {
138
+ inventoryNotTracked,
139
+ effectiveOutOfStockThreshold,
140
+ };
141
+ }
142
+ }
143
+ exports.MultiChannelStockLocationStrategy = MultiChannelStockLocationStrategy;
144
+ //# sourceMappingURL=multi-channel-stock-location-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-channel-stock-location-strategy.js","sourceRoot":"","sources":["../../../src/config/catalog/multi-channel-stock-location-strategy.ts"],"names":[],"mappings":";;;;;;AACA,yEAAiE;AAEjE,4CAAoB;AACpB,8CAAwC;AAGxC,6CAAoF;AAEpF,8CAAoD;AAEpD,oFAAyE;AACzE,6FAAkF;AAClF,iDAAqE;AAErE,uFAA8E;AAG9E;;;;;;;;;;;;GAYG;AACH,MAAa,iCAAkC,SAAQ,2DAAyB;IAO5E,gBAAgB;IAChB,KAAK,CAAC,IAAI,CAAC,QAAkB;QACzB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,gBAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,kCAA0B,CAAC,CAAC;QACpE,4EAA4E;QAC5E,MAAM,qBAAqB,GAAG,C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AmB,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAElG,MAAM,mBAAmB,GACrB,OAAO,CAAC,cAAc,KAAK,4BAAU,CAAC,KAAK;YAC3C,CAAC,OAAO,CAAC,cAAc,KAAK,4BAAU,CAAC,OAAO,IAAI,cAAc,KAAK,KAAK,CAAC,CAAC;QAChF,MAAM,4BAA4B,GAAG,OAAO,CAAC,4BAA4B;YACrE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAElC,OAAO;YACH,mBAAmB;YACnB,4BAA4B;SAC/B,CAAC;IACN,CAAC;CACJ;AA/JD,8EA+JC"}
@@ -68,7 +68,7 @@ let ConfigModule = class ConfigModule {
68
68
  const { adminAuthenticationStrategy, shopAuthenticationStrategy, sessionCacheStrategy, passwordHashingStrategy, passwordValidationStrategy, } = this.configService.authOptions;
69
69
  const { taxZoneStrategy, taxLineCalculationStrategy } = this.configService.taxOptions;
70
70
  const { jobQueueStrategy, jobBufferStorageStrategy } = this.configService.jobQueueOptions;
71
- const { mergeStrategy, checkoutMergeStrategy, orderItemPriceCalculationStrategy, process: orderProcess, orderCodeStrategy, orderByCodeAccessStrategy, stockAllocationStrategy, activeOrderStrategy, changedPriceHandlingStrategy, orderSellerStrategy, guestCheckoutStrategy, } = this.configService.orderOptions;
71
+ const { mergeStrategy, checkoutMergeStrategy, orderItemPriceCalculationStrategy, process: orderProcess, orderCodeStrategy, orderByCodeAccessStrategy, stockAllocationStrategy, activeOrderStrategy, changedPriceHandlingStrategy, orderSellerStrategy, guestCheckoutStrategy, orderInterceptors, } = this.configService.orderOptions;
72
72
  const { customFulfillmentProcess, process: fulfillmentProcess, shippingLineAssignmentStrategy, } = this.configService.shippingOptions;
73
73
  const { customPaymentProcess, process: paymentProcess } = this.configService.paymentOptions;
74
74
  const { entityIdStrategy: entityIdStrategyDeprecated } = this.configService;
@@ -118,6 +118,7 @@ let ConfigModule = class ConfigModule {
118
118
  guestCheckoutStrategy,
119
119
  ...refundProcess,
120
120
  cacheStrategy,
121
+ ...orderInterceptors,
121
122
  ];
122
123
  }
123
124
  getConfigurableOperations() {
@@ -1 +1 @@
1
- {"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../src/config/config.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuF;AACvF,uCAAyC;AAIzC,iDAA8C;AAG9C,qDAA+C;AAC/C,qDAAiD;AAM1C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACrB,YACY,aAA4B,EAC5B,SAAoB;QADpB,kBAAa,GAAb,aAAa,CAAe;QAC5B,cAAS,GAAT,SAAS,CAAW;IAC7B,CAAC;IAEJ,KAAK,CAAC,sBAAsB;QACxB,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACtC,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,MAAe;QACvC,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACzC,MAAM,IAAI,CAAC,6BAA6B,EAAE,CAAC;QAC3C;;;;;;WAMG;QACH,IAAA,4BAAW,GAAE,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,wBAAwB;QAClC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;YACpD,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACtC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;QACL,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,2BAA2B;QACrC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;YACpD,IAAI,OAAO,QAAQ,CAAC,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,IAAI,EAAE,CAAC;YAC9B,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC;SAC/B,CAAC;IACN,CAAC;CACJ,CAAA;AAnKY,oCAAY;uBAAZ,YAAY;IAJxB,IAAA,eAAM,EAAC;QACJ,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KAC3B,CAAC;qCAG6B,8BAAa;QACjB,gBAAS;GAHvB,YAAY,CAmKxB"}
@@ -1,9 +1,9 @@
1
- import { BooleanCustomFieldConfig as GraphQLBooleanCustomFieldConfig, CustomField, DateTimeCustomFieldConfig as GraphQLDateTimeCustomFieldConfig, FloatCustomFieldConfig as GraphQLFloatCustomFieldConfig, IntCustomFieldConfig as GraphQLIntCustomFieldConfig, LocaleStringCustomFieldConfig as GraphQLLocaleStringCustomFieldConfig, LocaleTextCustomFieldConfig as GraphQLLocaleTextCustomFieldConfig, LocalizedString, Permission, RelationCustomFieldConfig as GraphQLRelationCustomFieldConfig, StringCustomFieldConfig as GraphQLStringCustomFieldConfig, TextCustomFieldConfig as GraphQLTextCustomFieldConfig } from '@vendure/common/lib/generated-types';
2
- import { CustomFieldsObject, CustomFieldType, DefaultFormComponentId, Type, UiComponentConfig } from '@vendure/common/lib/shared-types';
1
+ import { BooleanCustomFieldConfig as GraphQLBooleanCustomFieldConfig, CustomField, DateTimeCustomFieldConfig as GraphQLDateTimeCustomFieldConfig, FloatCustomFieldConfig as GraphQLFloatCustomFieldConfig, IntCustomFieldConfig as GraphQLIntCustomFieldConfig, LocaleStringCustomFieldConfig as GraphQLLocaleStringCustomFieldConfig, LocaleTextCustomFieldConfig as GraphQLLocaleTextCustomFieldConfig, LocalizedString, Permission, RelationCustomFieldConfig as GraphQLRelationCustomFieldConfig, StringCustomFieldConfig as GraphQLStringCustomFieldConfig, TextCustomFieldConfig as GraphQLTextCustomFieldConfig, StructCustomFieldConfig as GraphQLStructCustomFieldConfig, StructField as GraphQLStructField, StringStructFieldConfig as GraphQLStringStructFieldConfig, IntStructFieldConfig as GraphQLIntStructFieldConfig, TextStructFieldConfig as GraphQLTextStructFieldConfig, FloatStructFieldConfig as GraphQLFloatStructFieldConfig, BooleanStructFieldConfig as GraphQLBooleanStructFieldConfig, DateTimeStructFieldConfig as GraphQLDateTimeStructFieldConfig } from '@vendure/common/lib/generated-types';
2
+ import { CustomFieldsObject, CustomFieldType, DefaultFormComponentId, Type, UiComponentConfig, StructFieldType } from '@vendure/common/lib/shared-types';
3
3
  import { RequestContext } from '../../api/common/request-context';
4
4
  import { Injector } from '../../common/injector';
5
5
  import { VendureEntity } from '../../entity/base/base.entity';
6
- export type DefaultValueType<T extends CustomFieldType> = T extends 'string' | 'localeString' | 'text' | 'localeText' ? string : T extends 'int' | 'float' ? number : T extends 'boolean' ? boolean : T extends 'datetime' ? Date : T extends 'relation' ? any : never;
6
+ export type DefaultValueType<T extends CustomFieldType | StructFieldType> = T extends 'string' | 'localeString' | 'text' | 'localeText' ? string : T extends 'int' | 'float' ? number : T extends 'boolean' ? boolean : T extends 'datetime' ? Date : T extends 'relation' ? any : never;
7
7
  export type BaseTypedCustomFieldConfig<T extends CustomFieldType, C extends CustomField> = Omit<C, '__typename' | 'list' | 'requiresPermission'> & {
8
8
  type: T;
9
9
  /**
@@ -39,7 +39,7 @@ export type TypedCustomSingleFieldConfig<T extends CustomFieldType, C extends Cu
39
39
  export type TypedCustomListFieldConfig<T extends CustomFieldType, C extends CustomField> = BaseTypedCustomFieldConfig<T, C> & {
40
40
  list?: true;
41
41
  defaultValue?: Array<DefaultValueType<T>>;
42
- validate?: (value: Array<DefaultValueType<T>>) => string | LocalizedString[] | void;
42
+ validate?: (value: Array<DefaultValueType<T>>) => string | LocalizedString[] | void | Promise<string | LocalizedString[] | void>;
43
43
  };
44
44
  export type TypedCustomFieldConfig<T extends CustomFieldType, C extends CustomField> = BaseTypedCustomFieldConfig<T, C> & (TypedCustomSingleFieldConfig<T, C> | TypedCustomListFieldConfig<T, C>);
45
45
  export type StringCustomFieldConfig = TypedCustomFieldConfig<'string', GraphQLStringCustomFieldConfig>;
@@ -56,13 +56,70 @@ export type RelationCustomFieldConfig = TypedCustomFieldConfig<'relation', Omit<
56
56
  eager?: boolean;
57
57
  inverseSide?: string | ((object: any) => any);
58
58
  };
59
+ export type BaseTypedStructFieldConfig<T extends StructFieldType, C extends GraphQLStructField> = Omit<C, '__typename' | 'list'> & {
60
+ type: T;
61
+ ui?: UiComponentConfig<DefaultFormComponentId | string>;
62
+ };
63
+ export type TypedStructSingleFieldConfig<T extends StructFieldType, C extends GraphQLStructField> = BaseTypedStructFieldConfig<T, C> & {
64
+ list?: false;
65
+ validate?: (value: DefaultValueType<T>, injector: Injector, ctx: RequestContext) => string | LocalizedString[] | void | Promise<string | LocalizedString[] | void>;
66
+ };
67
+ export type TypedStructListFieldConfig<T extends StructFieldType, C extends GraphQLStructField> = BaseTypedStructFieldConfig<T, C> & {
68
+ list?: true;
69
+ validate?: (value: Array<DefaultValueType<T>>) => string | LocalizedString[] | void | Promise<string | LocalizedString[] | void>;
70
+ };
71
+ export type TypedStructFieldConfig<T extends StructFieldType, C extends GraphQLStructField> = BaseTypedStructFieldConfig<T, C> & (TypedStructSingleFieldConfig<T, C> | TypedStructListFieldConfig<T, C>);
72
+ export type StringStructFieldConfig = TypedStructFieldConfig<'string', GraphQLStringStructFieldConfig>;
73
+ export type TextStructFieldConfig = TypedStructFieldConfig<'text', GraphQLTextStructFieldConfig>;
74
+ export type IntStructFieldConfig = TypedStructFieldConfig<'int', GraphQLIntStructFieldConfig>;
75
+ export type FloatStructFieldConfig = TypedStructFieldConfig<'float', GraphQLFloatStructFieldConfig>;
76
+ export type BooleanStructFieldConfig = TypedStructFieldConfig<'boolean', GraphQLBooleanStructFieldConfig>;
77
+ export type DateTimeStructFieldConfig = TypedStructFieldConfig<'datetime', GraphQLDateTimeStructFieldConfig>;
78
+ /**
79
+ * @description
80
+ * Configures an individual field of a "struct" custom field. The individual fields share
81
+ * the same API as the top-level custom fields, with the exception that they do not support the
82
+ * `readonly`, `internal`, `nullable`, `unique` and `requiresPermission` options.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const customFields: CustomFields = {
87
+ * Product: [
88
+ * {
89
+ * name: 'specifications',
90
+ * type: 'struct',
91
+ * fields: [
92
+ * { name: 'processor', type: 'string' },
93
+ * { name: 'ram', type: 'string' },
94
+ * { name: 'screenSize', type: 'float' },
95
+ * ],
96
+ * },
97
+ * ],
98
+ * };
99
+ * ```
100
+ *
101
+ *
102
+ * @docsCategory custom-fields
103
+ * @since 3.1.0
104
+ */
105
+ export type StructFieldConfig = StringStructFieldConfig | TextStructFieldConfig | IntStructFieldConfig | FloatStructFieldConfig | BooleanStructFieldConfig | DateTimeStructFieldConfig;
106
+ /**
107
+ * @description
108
+ * Configures a "struct" custom field.
109
+ *
110
+ * @docsCategory custom-fields
111
+ * @since 3.1.0
112
+ */
113
+ export type StructCustomFieldConfig = TypedCustomFieldConfig<'struct', Omit<GraphQLStructCustomFieldConfig, 'fields'>> & {
114
+ fields: StructFieldConfig[];
115
+ };
59
116
  /**
60
117
  * @description
61
118
  * An object used to configure a custom field.
62
119
  *
63
120
  * @docsCategory custom-fields
64
121
  */
65
- export type CustomFieldConfig = StringCustomFieldConfig | LocaleStringCustomFieldConfig | TextCustomFieldConfig | LocaleTextCustomFieldConfig | IntCustomFieldConfig | FloatCustomFieldConfig | BooleanCustomFieldConfig | DateTimeCustomFieldConfig | RelationCustomFieldConfig;
122
+ export type CustomFieldConfig = StringCustomFieldConfig | LocaleStringCustomFieldConfig | TextCustomFieldConfig | LocaleTextCustomFieldConfig | IntCustomFieldConfig | FloatCustomFieldConfig | BooleanCustomFieldConfig | DateTimeCustomFieldConfig | RelationCustomFieldConfig | StructCustomFieldConfig;
66
123
  /**
67
124
  * @description
68
125
  * Most entities can have additional fields added to them by defining an array of {@link CustomFieldConfig}
@@ -99,8 +156,10 @@ export type CustomFields = {
99
156
  FacetValue?: CustomFieldConfig[];
100
157
  Fulfillment?: CustomFieldConfig[];
101
158
  GlobalSettings?: CustomFieldConfig[];
159
+ HistoryEntry?: CustomFieldConfig[];
102
160
  Order?: CustomFieldConfig[];
103
161
  OrderLine?: CustomFieldConfig[];
162
+ Payment?: CustomFieldConfig[];
104
163
  PaymentMethod?: CustomFieldConfig[];
105
164
  Product?: CustomFieldConfig[];
106
165
  ProductOption?: CustomFieldConfig[];
@@ -108,10 +167,15 @@ export type CustomFields = {
108
167
  ProductVariant?: CustomFieldConfig[];
109
168
  ProductVariantPrice?: CustomFieldConfig[];
110
169
  Promotion?: CustomFieldConfig[];
170
+ Refund?: CustomFieldConfig[];
111
171
  Region?: CustomFieldConfig[];
112
172
  Seller?: CustomFieldConfig[];
173
+ Session?: CustomFieldConfig[];
174
+ ShippingLine?: CustomFieldConfig[];
113
175
  ShippingMethod?: CustomFieldConfig[];
176
+ StockLevel?: CustomFieldConfig[];
114
177
  StockLocation?: CustomFieldConfig[];
178
+ StockMovement?: CustomFieldConfig[];
115
179
  TaxCategory?: CustomFieldConfig[];
116
180
  TaxRate?: CustomFieldConfig[];
117
181
  User?: CustomFieldConfig[];
@@ -19,7 +19,7 @@ const default_product_variant_price_calculation_strategy_1 = require("./catalog/
19
19
  const default_product_variant_price_selection_strategy_1 = require("./catalog/default-product-variant-price-selection-strategy");
20
20
  const default_product_variant_price_update_strategy_1 = require("./catalog/default-product-variant-price-update-strategy");
21
21
  const default_stock_display_strategy_1 = require("./catalog/default-stock-display-strategy");
22
- const default_stock_location_strategy_1 = require("./catalog/default-stock-location-strategy");
22
+ const multi_channel_stock_location_strategy_1 = require("./catalog/multi-channel-stock-location-strategy");
23
23
  const auto_increment_id_strategy_1 = require("./entity/auto-increment-id-strategy");
24
24
  const default_money_strategy_1 = require("./entity/default-money-strategy");
25
25
  const index_1 = require("./entity/entity-duplicators/index");
@@ -41,7 +41,7 @@ const use_guest_strategy_1 = require("./order/use-guest-strategy");
41
41
  const default_payment_process_1 = require("./payment/default-payment-process");
42
42
  const promotion_1 = require("./promotion");
43
43
  const default_refund_process_1 = require("./refund/default-refund-process");
44
- const in_memory_session_cache_strategy_1 = require("./session-cache/in-memory-session-cache-strategy");
44
+ const default_session_cache_strategy_1 = require("./session-cache/default-session-cache-strategy");
45
45
  const default_shipping_calculator_1 = require("./shipping-method/default-shipping-calculator");
46
46
  const default_shipping_eligibility_checker_1 = require("./shipping-method/default-shipping-eligibility-checker");
47
47
  const default_shipping_line_assignment_strategy_1 = require("./shipping-method/default-shipping-line-assignment-strategy");
@@ -91,7 +91,7 @@ exports.defaultConfig = {
91
91
  },
92
92
  authTokenHeaderKey: shared_constants_1.DEFAULT_AUTH_TOKEN_HEADER_KEY,
93
93
  sessionDuration: '1y',
94
- sessionCacheStrategy: new in_memory_session_cache_strategy_1.InMemorySessionCacheStrategy(),
94
+ sessionCacheStrategy: new default_session_cache_strategy_1.DefaultSessionCacheStrategy(),
95
95
  sessionCacheTTL: 300,
96
96
  requireVerification: true,
97
97
  verificationTokenDuration: '7d',
@@ -113,7 +113,7 @@ exports.defaultConfig = {
113
113
  syncPricesAcrossChannels: false,
114
114
  }),
115
115
  stockDisplayStrategy: new default_stock_display_strategy_1.DefaultStockDisplayStrategy(),
116
- stockLocationStrategy: new default_stock_location_strategy_1.DefaultStockLocationStrategy(),
116
+ stockLocationStrategy: new multi_channel_stock_location_strategy_1.MultiChannelStockLocationStrategy(),
117
117
  },
118
118
  assetOptions: {
119
119
  assetNamingStrategy: new default_asset_naming_strategy_1.DefaultAssetNamingStrategy(),
@@ -162,6 +162,7 @@ exports.defaultConfig = {
162
162
  activeOrderStrategy: new default_active_order_strategy_1.DefaultActiveOrderStrategy(),
163
163
  orderSellerStrategy: new default_order_seller_strategy_1.DefaultOrderSellerStrategy(),
164
164
  guestCheckoutStrategy: new default_guest_checkout_strategy_1.DefaultGuestCheckoutStrategy(),
165
+ orderInterceptors: [],
165
166
  },
166
167
  paymentOptions: {
167
168
  paymentMethodEligibilityCheckers: [],
@@ -196,8 +197,10 @@ exports.defaultConfig = {
196
197
  FacetValue: [],
197
198
  Fulfillment: [],
198
199
  GlobalSettings: [],
200
+ HistoryEntry: [],
199
201
  Order: [],
200
202
  OrderLine: [],
203
+ Payment: [],
201
204
  PaymentMethod: [],
202
205
  Product: [],
203
206
  ProductOption: [],
@@ -205,10 +208,15 @@ exports.defaultConfig = {
205
208
  ProductVariant: [],
206
209
  ProductVariantPrice: [],
207
210
  Promotion: [],
211
+ Refund: [],
208
212
  Region: [],
209
213
  Seller: [],
214
+ Session: [],
215
+ ShippingLine: [],
210
216
  ShippingMethod: [],
217
+ StockLevel: [],
211
218
  StockLocation: [],
219
+ StockMovement: [],
212
220
  TaxCategory: [],
213
221
  TaxRate: [],
214
222
  User: [],