@vendure/core 2.0.0-next.11 → 2.0.0-next.15

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 (154) hide show
  1. package/dist/api/common/custom-field-relation-resolver.service.d.ts +3 -1
  2. package/dist/api/common/custom-field-relation-resolver.service.js +7 -5
  3. package/dist/api/common/custom-field-relation-resolver.service.js.map +1 -1
  4. package/dist/api/config/generate-resolvers.d.ts +3 -0
  5. package/dist/api/resolvers/admin/collection.resolver.js +8 -2
  6. package/dist/api/resolvers/admin/collection.resolver.js.map +1 -1
  7. package/dist/api/resolvers/admin/order.resolver.d.ts +2 -1
  8. package/dist/api/resolvers/admin/order.resolver.js +13 -0
  9. package/dist/api/resolvers/admin/order.resolver.js.map +1 -1
  10. package/dist/api/resolvers/admin/product-option.resolver.d.ts +2 -1
  11. package/dist/api/resolvers/admin/product-option.resolver.js +13 -0
  12. package/dist/api/resolvers/admin/product-option.resolver.js.map +1 -1
  13. package/dist/api/resolvers/base/base-auth.resolver.d.ts +2 -2
  14. package/dist/api/resolvers/base/base-auth.resolver.js.map +1 -1
  15. package/dist/api/resolvers/entity/fulfillment-entity.resolver.d.ts +8 -2
  16. package/dist/api/resolvers/entity/fulfillment-entity.resolver.js +17 -3
  17. package/dist/api/resolvers/entity/fulfillment-entity.resolver.js.map +1 -1
  18. package/dist/api/resolvers/entity/order-item-entity.resolver.d.ts +3 -1
  19. package/dist/api/resolvers/entity/order-item-entity.resolver.js +9 -3
  20. package/dist/api/resolvers/entity/order-item-entity.resolver.js.map +1 -1
  21. package/dist/api/resolvers/entity/order-line-entity.resolver.d.ts +5 -3
  22. package/dist/api/resolvers/entity/order-line-entity.resolver.js +19 -2
  23. package/dist/api/resolvers/entity/order-line-entity.resolver.js.map +1 -1
  24. package/dist/api/resolvers/entity/payment-entity.resolver.d.ts +3 -1
  25. package/dist/api/resolvers/entity/payment-entity.resolver.js +6 -3
  26. package/dist/api/resolvers/entity/payment-entity.resolver.js.map +1 -1
  27. package/dist/api/resolvers/entity/product-option-group-entity.resolver.js +8 -3
  28. package/dist/api/resolvers/entity/product-option-group-entity.resolver.js.map +1 -1
  29. package/dist/api/resolvers/shop/shop-order.resolver.js +3 -11
  30. package/dist/api/resolvers/shop/shop-order.resolver.js.map +1 -1
  31. package/dist/api/resolvers/shop/shop-products.resolver.js +8 -2
  32. package/dist/api/resolvers/shop/shop-products.resolver.js.map +1 -1
  33. package/dist/api/schema/admin-api/order.api.graphql +9 -0
  34. package/dist/api/schema/admin-api/product-option-group.api.graphql +2 -0
  35. package/dist/api/schema/common/order.type.graphql +7 -0
  36. package/dist/common/configurable-operation.js +9 -4
  37. package/dist/common/configurable-operation.js.map +1 -1
  38. package/dist/common/error/generated-graphql-admin-errors.d.ts +12 -0
  39. package/dist/common/error/generated-graphql-admin-errors.js +17 -2
  40. package/dist/common/error/generated-graphql-admin-errors.js.map +1 -1
  41. package/dist/config/entity-id-strategy/entity-id-strategy.d.ts +7 -0
  42. package/dist/config/payment/dummy-payment-method-handler.js +8 -0
  43. package/dist/config/payment/dummy-payment-method-handler.js.map +1 -1
  44. package/dist/config/payment/payment-method-handler.d.ts +66 -0
  45. package/dist/config/payment/payment-method-handler.js +11 -1
  46. package/dist/config/payment/payment-method-handler.js.map +1 -1
  47. package/dist/config/promotion/actions/order-fixed-discount-action.js +1 -1
  48. package/dist/config/promotion/actions/order-fixed-discount-action.js.map +1 -1
  49. package/dist/config/vendure-config.d.ts +9 -0
  50. package/dist/connection/remove-custom-fields-with-eager-relations.d.ts +34 -0
  51. package/dist/connection/remove-custom-fields-with-eager-relations.js +55 -0
  52. package/dist/connection/remove-custom-fields-with-eager-relations.js.map +1 -0
  53. package/dist/connection/transactional-connection.d.ts +0 -33
  54. package/dist/connection/transactional-connection.js +21 -53
  55. package/dist/connection/transactional-connection.js.map +1 -1
  56. package/dist/entity/product-option/product-option-translation.entity.js.map +1 -1
  57. package/dist/entity/product-option-group/product-option-group-translation.entity.js.map +1 -1
  58. package/dist/event-bus/events/product-option-event.d.ts +1 -1
  59. package/dist/event-bus/events/product-option-event.js.map +1 -1
  60. package/dist/event-bus/events/product-option-group-event.d.ts +1 -1
  61. package/dist/event-bus/events/product-option-group-event.js.map +1 -1
  62. package/dist/i18n/messages/en.json +3 -0
  63. package/dist/migrate.js +14 -0
  64. package/dist/migrate.js.map +1 -1
  65. package/dist/plugin/default-search-plugin/search-strategy/mysql-search-strategy.js +34 -34
  66. package/dist/plugin/default-search-plugin/search-strategy/mysql-search-strategy.js.map +1 -1
  67. package/dist/plugin/default-search-plugin/search-strategy/postgres-search-strategy.js +12 -12
  68. package/dist/plugin/default-search-plugin/search-strategy/postgres-search-strategy.js.map +1 -1
  69. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-common.d.ts +1 -0
  70. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-common.js +8 -1
  71. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-common.js.map +1 -1
  72. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-utils.d.ts +11 -1
  73. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-utils.js +31 -1
  74. package/dist/plugin/default-search-plugin/search-strategy/search-strategy-utils.js.map +1 -1
  75. package/dist/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.js +30 -30
  76. package/dist/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.js.map +1 -1
  77. package/dist/service/helpers/config-arg/config-arg.service.d.ts +1 -0
  78. package/dist/service/helpers/config-arg/config-arg.service.js +12 -1
  79. package/dist/service/helpers/config-arg/config-arg.service.js.map +1 -1
  80. package/dist/service/helpers/entity-hydrator/entity-hydrator.service.d.ts +3 -1
  81. package/dist/service/helpers/entity-hydrator/entity-hydrator.service.js +6 -4
  82. package/dist/service/helpers/entity-hydrator/entity-hydrator.service.js.map +1 -1
  83. package/dist/service/helpers/locale-string-hydrator/locale-string-hydrator.d.ts +3 -1
  84. package/dist/service/helpers/locale-string-hydrator/locale-string-hydrator.js +6 -4
  85. package/dist/service/helpers/locale-string-hydrator/locale-string-hydrator.js.map +1 -1
  86. package/dist/service/helpers/order-modifier/order-modifier.d.ts +3 -1
  87. package/dist/service/helpers/order-modifier/order-modifier.js +15 -8
  88. package/dist/service/helpers/order-modifier/order-modifier.js.map +1 -1
  89. package/dist/service/helpers/order-state-machine/order-state-machine.js +1 -1
  90. package/dist/service/helpers/order-state-machine/order-state-machine.js.map +1 -1
  91. package/dist/service/helpers/slug-validator/slug-validator.js +3 -1
  92. package/dist/service/helpers/slug-validator/slug-validator.js.map +1 -1
  93. package/dist/service/helpers/translator/translator.service.d.ts +10 -0
  94. package/dist/service/helpers/translator/translator.service.js +29 -0
  95. package/dist/service/helpers/translator/translator.service.js.map +1 -0
  96. package/dist/service/helpers/utils/translate-entity.d.ts +3 -3
  97. package/dist/service/helpers/utils/translate-entity.js +11 -2
  98. package/dist/service/helpers/utils/translate-entity.js.map +1 -1
  99. package/dist/service/index.d.ts +1 -0
  100. package/dist/service/index.js +1 -0
  101. package/dist/service/index.js.map +1 -1
  102. package/dist/service/service.module.js +2 -0
  103. package/dist/service/service.module.js.map +1 -1
  104. package/dist/service/services/collection.service.d.ts +3 -1
  105. package/dist/service/services/collection.service.js +14 -12
  106. package/dist/service/services/collection.service.js.map +1 -1
  107. package/dist/service/services/country.service.d.ts +3 -1
  108. package/dist/service/services/country.service.js +9 -7
  109. package/dist/service/services/country.service.js.map +1 -1
  110. package/dist/service/services/customer.service.d.ts +12 -1
  111. package/dist/service/services/customer.service.js +39 -6
  112. package/dist/service/services/customer.service.js.map +1 -1
  113. package/dist/service/services/facet-value.service.d.ts +3 -1
  114. package/dist/service/services/facet-value.service.js +9 -5
  115. package/dist/service/services/facet-value.service.js.map +1 -1
  116. package/dist/service/services/facet.service.d.ts +3 -1
  117. package/dist/service/services/facet.service.js +9 -5
  118. package/dist/service/services/facet.service.js.map +1 -1
  119. package/dist/service/services/fulfillment.service.d.ts +9 -0
  120. package/dist/service/services/fulfillment.service.js +48 -8
  121. package/dist/service/services/fulfillment.service.js.map +1 -1
  122. package/dist/service/services/order-testing.service.d.ts +3 -1
  123. package/dist/service/services/order-testing.service.js +6 -4
  124. package/dist/service/services/order-testing.service.js.map +1 -1
  125. package/dist/service/services/order.service.d.ts +10 -2
  126. package/dist/service/services/order.service.js +48 -27
  127. package/dist/service/services/order.service.js.map +1 -1
  128. package/dist/service/services/payment.service.d.ts +2 -0
  129. package/dist/service/services/payment.service.js +30 -10
  130. package/dist/service/services/payment.service.js.map +1 -1
  131. package/dist/service/services/product-option-group.service.d.ts +24 -2
  132. package/dist/service/services/product-option-group.service.js +92 -6
  133. package/dist/service/services/product-option-group.service.js.map +1 -1
  134. package/dist/service/services/product-option.service.d.ts +15 -2
  135. package/dist/service/services/product-option.service.js +66 -5
  136. package/dist/service/services/product-option.service.js.map +1 -1
  137. package/dist/service/services/product-variant.service.d.ts +3 -1
  138. package/dist/service/services/product-variant.service.js +13 -22
  139. package/dist/service/services/product-variant.service.js.map +1 -1
  140. package/dist/service/services/product.service.d.ts +5 -1
  141. package/dist/service/services/product.service.js +45 -13
  142. package/dist/service/services/product.service.js.map +1 -1
  143. package/dist/service/services/shipping-method.service.d.ts +3 -1
  144. package/dist/service/services/shipping-method.service.js +8 -6
  145. package/dist/service/services/shipping-method.service.js.map +1 -1
  146. package/dist/service/services/stock-movement.service.js +8 -7
  147. package/dist/service/services/stock-movement.service.js.map +1 -1
  148. package/dist/service/services/user.service.d.ts +1 -1
  149. package/dist/service/services/user.service.js +5 -0
  150. package/dist/service/services/user.service.js.map +1 -1
  151. package/dist/service/services/zone.service.d.ts +3 -1
  152. package/dist/service/services/zone.service.js +8 -6
  153. package/dist/service/services/zone.service.js.map +1 -1
  154. package/package.json +3 -3
@@ -814,6 +814,8 @@ export interface JobQueueOptions {
814
814
  *
815
815
  * @since 1.3.0
816
816
  * @docsCategory configuration
817
+ * @docsPage EntityOptions
818
+ * @docsWeight 0
817
819
  */
818
820
  export interface EntityOptions {
819
821
  /**
@@ -823,6 +825,13 @@ export interface EntityOptions {
823
825
  * entities via the API. The default uses a simple auto-increment integer
824
826
  * strategy.
825
827
  *
828
+ * {{% alert "warning" %}}
829
+ * Note: changing from an integer-based strategy to a uuid-based strategy
830
+ * on an existing Vendure database will lead to problems with broken foreign-key
831
+ * references. To change primary key types like this, you'll need to start with
832
+ * a fresh database.
833
+ * {{% /alert %}}
834
+ *
826
835
  * @since 1.3.0
827
836
  * @default AutoIncrementIdStrategy
828
837
  */
@@ -0,0 +1,34 @@
1
+ import { SelectQueryBuilder } from 'typeorm';
2
+ /**
3
+ * This is a work-around for this issue: https://github.com/vendure-ecommerce/vendure/issues/1664
4
+ *
5
+ * Explanation:
6
+ * When calling `FindOptionsUtils.joinEagerRelations()`, there appears to be a bug in TypeORM whereby
7
+ * it will throw the following error *if* the `options.relations` array contains any customField relations
8
+ * where the related entity itself has eagerly-loaded relations.
9
+ *
10
+ * For example, let's say we define a custom field on the Product entity like this:
11
+ * ```
12
+ * Product: [{
13
+ * name: 'featuredFacet',
14
+ * type: 'relation',
15
+ * entity: Facet,
16
+ * }],
17
+ * ```
18
+ * and then we pass into `TransactionalConnection.findOneInChannel()` an options array of:
19
+ *
20
+ * ```
21
+ * { relations: ['customFields.featuredFacet'] }
22
+ * ```
23
+ * it will throw an error because the `Facet` entity itself has eager relations (namely the `translations` property).
24
+ * This will cause TypeORM to throw the error:
25
+ * ```
26
+ * TypeORMError: "entity__customFields" alias was not found. Maybe you forgot to join it?
27
+ * ```
28
+ *
29
+ * So this method introspects the QueryBuilder metadata and checks for any custom field relations which
30
+ * themselves have eager relations. If found, it removes those items from the `options.relations` array.
31
+ *
32
+ * TODO: Ideally create a minimal reproduction case and report in the TypeORM repo for an upstream fix.
33
+ */
34
+ export declare function removeCustomFieldsWithEagerRelations(qb: SelectQueryBuilder<any>, relations?: string[]): string[];
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeCustomFieldsWithEagerRelations = void 0;
4
+ const index_1 = require("../config/index");
5
+ /**
6
+ * This is a work-around for this issue: https://github.com/vendure-ecommerce/vendure/issues/1664
7
+ *
8
+ * Explanation:
9
+ * When calling `FindOptionsUtils.joinEagerRelations()`, there appears to be a bug in TypeORM whereby
10
+ * it will throw the following error *if* the `options.relations` array contains any customField relations
11
+ * where the related entity itself has eagerly-loaded relations.
12
+ *
13
+ * For example, let's say we define a custom field on the Product entity like this:
14
+ * ```
15
+ * Product: [{
16
+ * name: 'featuredFacet',
17
+ * type: 'relation',
18
+ * entity: Facet,
19
+ * }],
20
+ * ```
21
+ * and then we pass into `TransactionalConnection.findOneInChannel()` an options array of:
22
+ *
23
+ * ```
24
+ * { relations: ['customFields.featuredFacet'] }
25
+ * ```
26
+ * it will throw an error because the `Facet` entity itself has eager relations (namely the `translations` property).
27
+ * This will cause TypeORM to throw the error:
28
+ * ```
29
+ * TypeORMError: "entity__customFields" alias was not found. Maybe you forgot to join it?
30
+ * ```
31
+ *
32
+ * So this method introspects the QueryBuilder metadata and checks for any custom field relations which
33
+ * themselves have eager relations. If found, it removes those items from the `options.relations` array.
34
+ *
35
+ * TODO: Ideally create a minimal reproduction case and report in the TypeORM repo for an upstream fix.
36
+ */
37
+ function removeCustomFieldsWithEagerRelations(qb, relations = []) {
38
+ let resultingRelations = relations;
39
+ const mainAlias = qb.expressionMap.mainAlias;
40
+ const customFieldsMetadata = mainAlias === null || mainAlias === void 0 ? void 0 : mainAlias.metadata.embeddeds.find(metadata => metadata.propertyName === 'customFields');
41
+ if (customFieldsMetadata) {
42
+ const customFieldRelationsWithEagerRelations = customFieldsMetadata.relations.filter(relation => !!relation.inverseEntityMetadata.ownRelations.find(or => or.isEager === true));
43
+ for (const relation of customFieldRelationsWithEagerRelations) {
44
+ const propertyName = relation.propertyName;
45
+ const relationsToRemove = relations.filter(r => r.startsWith(`customFields.${propertyName}`));
46
+ if (relationsToRemove.length) {
47
+ index_1.Logger.debug(`TransactionalConnection.findOneInChannel cannot automatically join relation [${mainAlias === null || mainAlias === void 0 ? void 0 : mainAlias.metadata.name}.customFields.${propertyName}]`);
48
+ resultingRelations = relations.filter(r => !r.startsWith(`customFields.${propertyName}`));
49
+ }
50
+ }
51
+ }
52
+ return resultingRelations;
53
+ }
54
+ exports.removeCustomFieldsWithEagerRelations = removeCustomFieldsWithEagerRelations;
55
+ //# sourceMappingURL=remove-custom-fields-with-eager-relations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-custom-fields-with-eager-relations.js","sourceRoot":"","sources":["../../src/connection/remove-custom-fields-with-eager-relations.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,SAAgB,oCAAoC,CAChD,EAA2B,EAC3B,YAAsB,EAAE;IAExB,IAAI,kBAAkB,GAAG,SAAS,CAAC;IACnC,MAAM,SAAS,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC;IAC7C,MAAM,oBAAoB,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,CAC3D,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,cAAc,CACvD,CAAC;IACF,IAAI,oBAAoB,EAAE;QACtB,MAAM,sCAAsC,GAAG,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAChF,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC,CAC5F,CAAC;QACF,KAAK,MAAM,QAAQ,IAAI,sCAAsC,EAAE;YAC3D,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;YAC3C,MAAM,iBAAiB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC,CAAC;YAC9F,IAAI,iBAAiB,CAAC,MAAM,EAAE;gBAC1B,cAAM,CAAC,KAAK,CACR,gFAAgF,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,IAAI,iBAAiB,YAAY,GAAG,CAC3I,CAAC;gBACF,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC,CAAC;aAC7F;SACJ;KACJ;IACD,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAzBD,oFAyBC"}
@@ -121,39 +121,6 @@ export declare class TransactionalConnection {
121
121
  * the given Channel.
122
122
  */
123
123
  findOneInChannel<T extends ChannelAware & VendureEntity>(ctx: RequestContext, entity: Type<T>, id: ID, channelId: ID, options?: FindOneOptions): Promise<T | undefined>;
124
- /**
125
- * This is a work-around for this issue: https://github.com/vendure-ecommerce/vendure/issues/1664
126
- *
127
- * Explanation:
128
- * When calling `FindOptionsUtils.joinEagerRelations()`, there appears to be a bug in TypeORM whereby
129
- * it will throw the following error *if* the `options.relations` array contains any customField relations
130
- * where the related entity itself has eagerly-loaded relations.
131
- *
132
- * For example, let's say we define a custom field on the Product entity like this:
133
- * ```
134
- * Product: [{
135
- * name: 'featuredFacet',
136
- * type: 'relation',
137
- * entity: Facet,
138
- * }],
139
- * ```
140
- * and then we pass into `TransactionalConnection.findOneInChannel()` an options array of:
141
- *
142
- * ```
143
- * { relations: ['customFields.featuredFacet'] }
144
- * ```
145
- * it will throw an error because the `Facet` entity itself has eager relations (namely the `translations` property).
146
- * This will cause TypeORM to throw the error:
147
- * ```
148
- * TypeORMError: "entity__customFields" alias was not found. Maybe you forgot to join it?
149
- * ```
150
- *
151
- * So this method introspects the QueryBuilder metadata and checks for any custom field relations which
152
- * themselves have eager relations. If found, it removes those items from the `options.relations` array.
153
- *
154
- * TODO: Ideally create a minimal reproduction case and report in the TypeORM repo for an upstream fix.
155
- */
156
- private removeCustomFieldsWithEagerRelations;
157
124
  /**
158
125
  * @description
159
126
  * Like the TypeOrm `Repository.findByIds()` method, but limits the results to
@@ -31,6 +31,7 @@ const request_context_1 = require("../api/common/request-context");
31
31
  const constants_1 = require("../common/constants");
32
32
  const errors_1 = require("../common/error/errors");
33
33
  const index_1 = require("../config/index");
34
+ const remove_custom_fields_with_eager_relations_1 = require("./remove-custom-fields-with-eager-relations");
34
35
  const transaction_wrapper_1 = require("./transaction-wrapper");
35
36
  /**
36
37
  * @description
@@ -180,10 +181,26 @@ let TransactionalConnection = class TransactionalConnection {
180
181
  * the given Channel.
181
182
  */
182
183
  findOneInChannel(ctx, entity, id, channelId, options = {}) {
183
- const qb = this.getRepository(ctx, entity).createQueryBuilder('entity');
184
- options.relations = this.removeCustomFieldsWithEagerRelations(qb, options.relations);
185
- typeorm_2.FindOptionsUtils.applyFindManyOptionsOrConditionsToQueryBuilder(qb, options);
186
- if (options.loadEagerRelations !== false) {
184
+ let qb = this.getRepository(ctx, entity).createQueryBuilder('entity');
185
+ options.relations = (0, remove_custom_fields_with_eager_relations_1.removeCustomFieldsWithEagerRelations)(qb, options.relations);
186
+ let skipEagerRelations = false;
187
+ try {
188
+ typeorm_2.FindOptionsUtils.applyFindManyOptionsOrConditionsToQueryBuilder(qb, options);
189
+ }
190
+ catch (e) {
191
+ // https://github.com/vendure-ecommerce/vendure/issues/1664
192
+ // This is a failsafe to catch edge cases related to the TypeORM
193
+ // bug described in the doc block of `removeCustomFieldsWithEagerRelations`.
194
+ // In this case, a nested custom field relation has an eager-loaded relation,
195
+ // and is throwing an error. In this case we throw our hands up and say
196
+ // "sod it!", refuse to load _any_ relations at all, and rely on the
197
+ // GraphQL entity resolvers to take care of them.
198
+ index_1.Logger.debug(`TransactionalConnection.findOneInChannel ran into issues joining nested custom field relations. Running the query without joining any relations instead.`);
199
+ qb = this.getRepository(ctx, entity).createQueryBuilder('entity');
200
+ typeorm_2.FindOptionsUtils.applyFindManyOptionsOrConditionsToQueryBuilder(qb, Object.assign(Object.assign({}, options), { relations: [], loadEagerRelations: false }));
201
+ skipEagerRelations = true;
202
+ }
203
+ if (options.loadEagerRelations !== false && !skipEagerRelations) {
187
204
  // tslint:disable-next-line:no-non-null-assertion
188
205
  typeorm_2.FindOptionsUtils.joinEagerRelations(qb, qb.alias, qb.expressionMap.mainAlias.metadata);
189
206
  }
@@ -193,55 +210,6 @@ let TransactionalConnection = class TransactionalConnection {
193
210
  .andWhere('channel.id = :channelId', { channelId })
194
211
  .getOne();
195
212
  }
196
- /**
197
- * This is a work-around for this issue: https://github.com/vendure-ecommerce/vendure/issues/1664
198
- *
199
- * Explanation:
200
- * When calling `FindOptionsUtils.joinEagerRelations()`, there appears to be a bug in TypeORM whereby
201
- * it will throw the following error *if* the `options.relations` array contains any customField relations
202
- * where the related entity itself has eagerly-loaded relations.
203
- *
204
- * For example, let's say we define a custom field on the Product entity like this:
205
- * ```
206
- * Product: [{
207
- * name: 'featuredFacet',
208
- * type: 'relation',
209
- * entity: Facet,
210
- * }],
211
- * ```
212
- * and then we pass into `TransactionalConnection.findOneInChannel()` an options array of:
213
- *
214
- * ```
215
- * { relations: ['customFields.featuredFacet'] }
216
- * ```
217
- * it will throw an error because the `Facet` entity itself has eager relations (namely the `translations` property).
218
- * This will cause TypeORM to throw the error:
219
- * ```
220
- * TypeORMError: "entity__customFields" alias was not found. Maybe you forgot to join it?
221
- * ```
222
- *
223
- * So this method introspects the QueryBuilder metadata and checks for any custom field relations which
224
- * themselves have eager relations. If found, it removes those items from the `options.relations` array.
225
- *
226
- * TODO: Ideally create a minimal reproduction case and report in the TypeORM repo for an upstream fix.
227
- */
228
- removeCustomFieldsWithEagerRelations(qb, relations = []) {
229
- let resultingRelations = relations;
230
- const mainAlias = qb.expressionMap.mainAlias;
231
- const customFieldsMetadata = mainAlias === null || mainAlias === void 0 ? void 0 : mainAlias.metadata.embeddeds.find(metadata => metadata.propertyName === 'customFields');
232
- if (customFieldsMetadata) {
233
- const customFieldRelationsWithEagerRelations = customFieldsMetadata.relations.filter(relation => !!relation.inverseEntityMetadata.ownRelations.find(or => or.isEager === true));
234
- for (const relation of customFieldRelationsWithEagerRelations) {
235
- const propertyName = relation.propertyName;
236
- const relationsToRemove = relations.filter(r => r.startsWith(`customFields.${propertyName}`));
237
- if (relationsToRemove.length) {
238
- index_1.Logger.debug(`TransactionalConnection.findOneInChannel cannot automatically join relation [${mainAlias === null || mainAlias === void 0 ? void 0 : mainAlias.metadata.name}.customFields.${propertyName}]`);
239
- resultingRelations = relations.filter(r => !r.startsWith(`customFields.${propertyName}`));
240
- }
241
- }
242
- }
243
- return resultingRelations;
244
- }
245
213
  /**
246
214
  * @description
247
215
  * Like the TypeOrm `Repository.findByIds()` method, but limits the results to
@@ -1 +1 @@
1
- {"version":3,"file":"transactional-connection.js","sourceRoot":"","sources":["../../src/connection/transactional-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AAEnD,qCASiB;AAEjB,mEAA+D;AAC/D,mDAA8D;AAC9D,mDAA6D;AAE7D,2CAAyC;AAGzC,+DAA2D;AAG3D;;;;;;;;;;;GAWG;AAEH,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAChC,YACgC,UAAsB,EAC1C,kBAAsC;QADlB,eAAU,GAAV,UAAU,CAAY;QAC1C,uBAAkB,GAAlB,kBAAkB,CAAoB;IAC/C,CAAC;IAEJ;;;;;OAKG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAqBD,aAAa,CACT,WAA4F,EAC5F,WAAgE;QAEhE,IAAI,WAAW,YAAY,gCAAc,EAAE;YACvC,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;YACnE,IAAI,kBAAkB,EAAE;gBACpB,iDAAiD;gBACjD,OAAO,kB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,CAAC,wBAAwB,EAAE,EAAE,GAAG,EAAE,CAAC;aAC3C,QAAQ,CAAC,yBAAyB,EAAE,EAAE,SAAS,EAAE,CAAC;aAClD,OAAO,EAAE,CAAC;IACnB,CAAC;IAEO,qBAAqB,CAAC,GAAmB;QAC7C,OAAQ,GAAW,CAAC,mCAAuB,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AA/UY,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,GAAE,CAAA;qCAAqB,oBAAU;QACtB,wCAAkB;GAHzC,uBAAuB,CA+UnC;AA/UY,0DAAuB"}
1
+ {"version":3,"file":"transactional-connection.js","sourceRoot":"","sources":["../../src/connection/transactional-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AAEnD,qCASiB;AAEjB,mEAA+D;AAC/D,mDAA8D;AAC9D,mDAA6D;AAE7D,2CAAyC;AAGzC,2GAAmG;AACnG,+DAA2D;AAG3D;;;;;;;;;;;GAWG;AAEH,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAChC,YACgC,UAAsB,EAC1C,kBAAsC;QADlB,eAAU,GAAV,UAAU,CAAY;QAC1C,uBAAkB,GAAlB,kBAAkB,CAAoB;IAC/C,CAAC;IAEJ;;;;;OAKG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAqBD,aAAa,CACT,WAA4F,EAC5F,WAAgE;QAEhE,IAAI,WAAW,YAAY,gCAAc,EAAE;YACvC,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;YACnE,IAAI,kBAAkB,EAAE;gBACpB,iDAAiD;gBACjD,OAAO,kBAAkB,CAAC,aAAa,CAAC,WAAY,CAAC,CAAC;aACzD;iBAAM;gBACH,iDAAiD;gBACjD,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,W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G,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACxE,0BAAgB,CAAC,8CAA8C,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAC7E,IAAI,OAAO,CAAC,kBAAkB,KAAK,KAAK,EAAE;YACtC,iDAAiD;YACjD,0BAAgB,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,SAAU,CAAC,QAAQ,CAAC,CAAC;SAC3F;QACD,OAAO,EAAE;aACJ,QAAQ,CAAC,iBAAiB,EAAE,SAAS,CAAC;aACtC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,GAAG,EAAE,CAAC;aAC3C,QAAQ,CAAC,yBAAyB,EAAE,EAAE,SAAS,EAAE,CAAC;aAClD,OAAO,EAAE,CAAC;IACnB,CAAC;IAEO,qBAAqB,CAAC,GAAmB;QAC7C,OAAQ,GAAW,CAAC,mCAAuB,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AAzSY,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,GAAE,CAAA;qCAAqB,oBAAU;QACtB,wCAAkB;GAHzC,uBAAuB,CAySnC;AAzSY,0DAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"product-option-translation.entity.js","sourceRoot":"","sources":["../../../src/entity/product-option/product-option-translation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAmE;AAEnE,qCAA2D;AAI3D,qDAAoD;AACpD,kEAA+E;AAE/E,mEAAwD;AAGxD,IAAa,wBAAwB,GAArC,MAAa,wBACT,SAAQ,2BAAa;IAGrB,YAAY,KAA+C;QACvD,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CAYJ,CAAA;AAVsB;IAAlB,IAAA,gBAAM,EAAC,SAAS,CAAC;;8DAA4B;AAEpC;IAAT,IAAA,gBAAM,GAAE;;sDAAc;AAIvB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,qCAAa,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;8BACtD,qCAAa;sDAAC;AAGpB;IADC,IAAA,gBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,2DAAoC,CAAC;8BACvC,2DAAoC;8DAAC;AAjB1C,wBAAwB;IADpC,IAAA,gBAAM,GAAE;;GACI,wBAAwB,CAkBpC;AAlBY,4DAAwB"}
1
+ {"version":3,"file":"product-option-translation.entity.js","sourceRoot":"","sources":["../../../src/entity/product-option/product-option-translation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAmE;AAEnE,qCAA2D;AAI3D,qDAAoD;AACpD,kEAA+E;AAE/E,mEAAwD;AAGxD,IAAa,wBAAwB,GAArC,MAAa,wBACT,SAAQ,2BAAa;IAGrB,YAAY,KAA+C;QACvD,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CAaJ,CAAA;AAXsB;IAAlB,IAAA,gBAAM,EAAC,SAAS,CAAC;;8DAA4B;AAEpC;IAAT,IAAA,gBAAM,GAAE;;sDAAc;AAKvB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,qCAAa,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;8BACtD,qCAAa;sDAAC;AAGpB;IADC,IAAA,gBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,2DAAoC,CAAC;8BACvC,2DAAoC;8DAAC;AAlB1C,wBAAwB;IADpC,IAAA,gBAAM,GAAE;;GACI,wBAAwB,CAmBpC;AAnBY,4DAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"product-option-group-translation.entity.js","sourceRoot":"","sources":["../../../src/entity/product-option-group/product-option-group-translation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAmE;AAEnE,qCAA2D;AAI3D,qDAAoD;AACpD,kEAAoF;AAEpF,+EAAmE;AAGnE,IAAa,6BAA6B,GAA1C,MAAa,6BACT,SAAQ,2BAAa;IAGrB,YAAY,KAAoD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CAYJ,CAAA;AAVsB;IAAlB,IAAA,gBAAM,EAAC,SAAS,CAAC;;mEAA4B;AAEpC;IAAT,IAAA,gBAAM,GAAE;;2DAAc;AAIvB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gDAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;8BAC3D,gDAAkB;2DAAC;AAGzB;IADC,IAAA,gBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,gEAAyC,CAAC;8BAC5C,gEAAyC;mEAAC;AAjB/C,6BAA6B;IADzC,IAAA,gBAAM,GAAE;;GACI,6BAA6B,CAkBzC;AAlBY,sEAA6B"}
1
+ {"version":3,"file":"product-option-group-translation.entity.js","sourceRoot":"","sources":["../../../src/entity/product-option-group/product-option-group-translation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAmE;AAEnE,qCAA2D;AAI3D,qDAAoD;AACpD,kEAAoF;AAEpF,+EAAmE;AAGnE,IAAa,6BAA6B,GAA1C,MAAa,6BACT,SAAQ,2BAAa;IAGrB,YAAY,KAAoD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CAaJ,CAAA;AAXsB;IAAlB,IAAA,gBAAM,EAAC,SAAS,CAAC;;mEAA4B;AAEpC;IAAT,IAAA,gBAAM,GAAE;;2DAAc;AAKvB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gDAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;8BAC3D,gDAAkB;2DAAC;AAGzB;IADC,IAAA,gBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,gEAAyC,CAAC;8BAC5C,gEAAyC;mEAAC;AAlB/C,6BAA6B;IADzC,IAAA,gBAAM,GAAE;;GACI,6BAA6B,CAmBzC;AAnBY,sEAA6B"}
@@ -13,6 +13,6 @@ declare type ProductOptionInputTypes = CreateGroupOptionInput | CreateProductOpt
13
13
  * @since 1.4
14
14
  */
15
15
  export declare class ProductOptionEvent extends VendureEntityEvent<ProductOption, ProductOptionInputTypes> {
16
- constructor(ctx: RequestContext, entity: ProductOption, type: 'created' | 'updated', input?: ProductOptionInputTypes);
16
+ constructor(ctx: RequestContext, entity: ProductOption, type: 'created' | 'updated' | 'deleted', input?: ProductOptionInputTypes);
17
17
  }
18
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"product-option-event.js","sourceRoot":"","sources":["../../../src/event-bus/events/product-option-event.ts"],"names":[],"mappings":";;;AASA,kEAA6D;AAQ7D;;;;;;;GAOG;AACH,MAAa,kBAAmB,SAAQ,yCAA0D;IAC9F,YACI,GAAmB,EACnB,MAAqB,EACrB,IAA2B,EAC3B,KAA+B;QAE/B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AATD,gDASC"}
1
+ {"version":3,"file":"product-option-event.js","sourceRoot":"","sources":["../../../src/event-bus/events/product-option-event.ts"],"names":[],"mappings":";;;AASA,kEAA6D;AAQ7D;;;;;;;GAOG;AACH,MAAa,kBAAmB,SAAQ,yCAA0D;IAC9F,YACI,GAAmB,EACnB,MAAqB,EACrB,IAAuC,EACvC,KAA+B;QAE/B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AATD,gDASC"}
@@ -13,6 +13,6 @@ declare type ProductOptionGroupInputTypes = CreateProductOptionGroupInput | Upda
13
13
  * @since 1.4
14
14
  */
15
15
  export declare class ProductOptionGroupEvent extends VendureEntityEvent<ProductOptionGroup, ProductOptionGroupInputTypes> {
16
- constructor(ctx: RequestContext, entity: ProductOptionGroup, type: 'created' | 'updated', input?: ProductOptionGroupInputTypes);
16
+ constructor(ctx: RequestContext, entity: ProductOptionGroup, type: 'created' | 'updated' | 'deleted', input?: ProductOptionGroupInputTypes);
17
17
  }
18
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"product-option-group-event.js","sourceRoot":"","sources":["../../../src/event-bus/events/product-option-group-event.ts"],"names":[],"mappings":";;;AAQA,kEAA6D;AAI7D;;;;;;;GAOG;AACH,MAAa,uBAAwB,SAAQ,yCAG5C;IACG,YACI,GAAmB,EACnB,MAA0B,EAC1B,IAA2B,EAC3B,KAAoC;QAEpC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AAZD,0DAYC"}
1
+ {"version":3,"file":"product-option-group-event.js","sourceRoot":"","sources":["../../../src/event-bus/events/product-option-group-event.ts"],"names":[],"mappings":";;;AAQA,kEAA6D;AAI7D;;;;;;;GAOG;AACH,MAAa,uBAAwB,SAAQ,yCAG5C;IACG,YACI,GAAmB,EACnB,MAA0B,EAC1B,IAAuC,EACvC,KAAoC;QAEpC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACJ;AAZD,0DAYC"}
@@ -40,6 +40,7 @@
40
40
  "products-cannot-be-removed-from-default-channel": "Products cannot be removed from the default Channel",
41
41
  "product-id-or-slug-must-be-provided": "Either the Product id or slug must be provided",
42
42
  "product-id-slug-mismatch": "The provided id and slug refer to different Products",
43
+ "product-option-group-already-assigned": "The ProductOptionGroup \"{ groupCode }\" is already assigned to the Product \"{ productName }\"",
43
44
  "product-variant-option-ids-not-compatible": "ProductVariant optionIds must include one optionId from each of the groups: {groupNames}",
44
45
  "product-variant-options-combination-already-exists": "A ProductVariant with the selected options already exists: {variantName}",
45
46
  "promotion-channels-can-only-be-changed-from-default-channel": "Promotions channels may only be changed from the Default Channel",
@@ -51,6 +52,7 @@
51
52
  "ALREADY_LOGGED_IN_ERROR": "Cannot set a Customer for the Order when already logged in",
52
53
  "ALREADY_REFUNDED_ERROR": "Cannot refund an OrderItem which has already been refunded",
53
54
  "CANCEL_ACTIVE_ORDER_ERROR": "Cannot cancel OrderLines from an Order in the \"{ orderState }\" state",
55
+ "CANCEL_PAYMENT_ERROR": "Cancelling the payment failed",
54
56
  "CHANNEL_DEFAULT_LANGUAGE_ERROR": "Cannot make language \"{ language }\" unavailable as it is used as the defaultLanguage by the channel \"{ channelCode }\"",
55
57
  "COUPON_CODE_EXPIRED_ERROR": "Coupon code \"{ couponCode }\" has expired",
56
58
  "COUPON_CODE_INVALID_ERROR": "Coupon code \"{ couponCode }\" is not valid",
@@ -116,6 +118,7 @@
116
118
  "facet-value-force-deleted": "The selected FacetValue was removed from {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}} and deleted",
117
119
  "facet-value-used": "The selected FacetValue is assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
118
120
  "payment-method-used-in-channels": "The selected PaymentMethod is assigned to the following Channels: { channelCodes }. Set \"force: true\" to delete from all Channels.",
121
+ "product-option-used": "Cannot delete the option \"{code}\" as it is being used by {count, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
119
122
  "zone-used-in-channels": "The selected Zone cannot be deleted as it used as a default in the following Channels: { channelCodes }",
120
123
  "zone-used-in-tax-rates": "The selected Zone cannot be deleted as it is used in the following TaxRates: { taxRateNames }"
121
124
  }
package/dist/migrate.js CHANGED
@@ -12,6 +12,7 @@ const typeorm_1 = require("typeorm");
12
12
  const MysqlDriver_1 = require("typeorm/driver/mysql/MysqlDriver");
13
13
  const StringUtils_1 = require("typeorm/util/StringUtils");
14
14
  const bootstrap_1 = require("./bootstrap");
15
+ const config_helpers_1 = require("./config/config-helpers");
15
16
  /**
16
17
  * @description
17
18
  * Runs any pending database migrations. See [TypeORM migration docs](https://typeorm.io/#/migrations)
@@ -34,10 +35,21 @@ async function runMigrations(userConfig) {
34
35
  process.exitCode = 1;
35
36
  }
36
37
  finally {
38
+ await checkMigrationStatus(connection);
37
39
  await connection.close();
40
+ (0, config_helpers_1.resetConfig)();
38
41
  }
39
42
  }
40
43
  exports.runMigrations = runMigrations;
44
+ async function checkMigrationStatus(connection) {
45
+ const builderLog = await connection.driver.createSchemaBuilder().log();
46
+ if (builderLog.upQueries.length) {
47
+ console.log(chalk_1.default.yellow(`Your database schema does not match your current configuration. Generate a new migration for the following changes:`));
48
+ for (const query of builderLog.upQueries) {
49
+ console.log(' - ' + chalk_1.default.yellow(query.query));
50
+ }
51
+ }
52
+ }
41
53
  /**
42
54
  * @description
43
55
  * Reverts the last applied database migration. See [TypeORM migration docs](https://typeorm.io/#/migrations)
@@ -58,6 +70,7 @@ async function revertLastMigration(userConfig) {
58
70
  }
59
71
  finally {
60
72
  await connection.close();
73
+ (0, config_helpers_1.resetConfig)();
61
74
  }
62
75
  }
63
76
  exports.revertLastMigration = revertLastMigration;
@@ -129,6 +142,7 @@ async function generateMigration(userConfig, options) {
129
142
  console.log(chalk_1.default.yellow(`No changes in database schema were found - cannot generate a migration.`));
130
143
  }
131
144
  await connection.close();
145
+ (0, config_helpers_1.resetConfig)();
132
146
  }
133
147
  exports.generateMigration = generateMigration;
134
148
  function createConnectionOptions(userConfig) {
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kDAA0B;AAC1B,wDAA0B;AAC1B,gDAAwB;AACxB,qCAA0E;AAC1E,kEAA+D;AAC/D,0DAAqD;AAErD,2CAAiD;AAuBjD;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,UAAkC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,SAAS,WAAW,CAAC,IAAY,EAAE,SAAiB,EAAE,MAAgB,EAAE,QAAkB;IACtF,OAAO;;eAEI,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS;;;EAG9C,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;;CAID,CAAC;AACF,CAAC"}
@@ -24,8 +24,8 @@ class MysqlSearchStrategy {
24
24
  const facetValuesQb = this.connection
25
25
  .getRepository(ctx, search_index_item_entity_1.SearchIndexItem)
26
26
  .createQueryBuilder('si')
27
- .select(['MIN(productId)', 'MIN(productVariantId)'])
28
- .addSelect('GROUP_CONCAT(facetValueIds)', 'facetValues');
27
+ .select(['MIN(si.productId)', 'MIN(si.productVariantId)'])
28
+ .addSelect('GROUP_CONCAT(si.facetValueIds)', 'facetValues');
29
29
  this.applyTermAndFilters(ctx, facetValuesQb, Object.assign(Object.assign({}, input), { groupByProduct: true }));
30
30
  if (!input.groupByProduct) {
31
31
  facetValuesQb.groupBy('productVariantId');
@@ -40,11 +40,11 @@ class MysqlSearchStrategy {
40
40
  const collectionsQb = this.connection
41
41
  .getRepository(ctx, search_index_item_entity_1.SearchIndexItem)
42
42
  .createQueryBuilder('si')
43
- .select(['MIN(productId)', 'MIN(productVariantId)'])
44
- .addSelect('GROUP_CONCAT(collectionIds)', 'collections');
43
+ .select(['MIN(si.productId)', 'MIN(si.productVariantId)'])
44
+ .addSelect('GROUP_CONCAT(si.collectionIds)', 'collections');
45
45
  this.applyTermAndFilters(ctx, collectionsQb, input);
46
46
  if (!input.groupByProduct) {
47
- collectionsQb.groupBy('productVariantId');
47
+ collectionsQb.groupBy('si.productVariantId');
48
48
  }
49
49
  if (enabledOnly) {
50
50
  collectionsQb.andWhere('si.enabled = :enabled', { enabled: true });
@@ -61,18 +61,18 @@ class MysqlSearchStrategy {
61
61
  .createQueryBuilder('si')
62
62
  .select(this.createMysqlSelect(!!input.groupByProduct));
63
63
  if (input.groupByProduct) {
64
- qb.addSelect('MIN(price)', 'minPrice')
65
- .addSelect('MAX(price)', 'maxPrice')
66
- .addSelect('MIN(priceWithTax)', 'minPriceWithTax')
67
- .addSelect('MAX(priceWithTax)', 'maxPriceWithTax');
64
+ qb.addSelect('MIN(si.price)', 'minPrice')
65
+ .addSelect('MAX(si.price)', 'maxPrice')
66
+ .addSelect('MIN(si.priceWithTax)', 'minPriceWithTax')
67
+ .addSelect('MAX(si.priceWithTax)', 'maxPriceWithTax');
68
68
  }
69
69
  this.applyTermAndFilters(ctx, qb, input);
70
70
  if (sort) {
71
71
  if (sort.name) {
72
- qb.addOrderBy(input.groupByProduct ? 'MIN(productName)' : 'productName', sort.name);
72
+ qb.addOrderBy(input.groupByProduct ? 'MIN(si.productName)' : 'si.productName', sort.name);
73
73
  }
74
74
  if (sort.price) {
75
- qb.addOrderBy(input.groupByProduct ? 'MIN(price)' : 'price', sort.price);
75
+ qb.addOrderBy(input.groupByProduct ? 'MIN(si.price)' : 'si.price', sort.price);
76
76
  }
77
77
  }
78
78
  else {
@@ -84,8 +84,8 @@ class MysqlSearchStrategy {
84
84
  qb.andWhere('si.enabled = :enabled', { enabled: true });
85
85
  }
86
86
  return qb
87
- .take(take)
88
- .skip(skip)
87
+ .limit(take)
88
+ .offset(skip)
89
89
  .getRawMany()
90
90
  .then(res => res.map(r => (0, search_strategy_utils_1.mapToSearchResult)(r, ctx.channel.currencyCode)));
91
91
  }
@@ -112,18 +112,18 @@ class MysqlSearchStrategy {
112
112
  .createQueryBuilder('si_inner')
113
113
  .select('si_inner.productId', 'inner_productId')
114
114
  .addSelect('si_inner.productVariantId', 'inner_productVariantId')
115
- .addSelect(`IF (sku LIKE :like_term, 10, 0)`, 'sku_score')
116
- .addSelect(`(SELECT sku_score) +
117
- MATCH (productName) AGAINST (:term IN BOOLEAN MODE) * 2 +
118
- MATCH (productVariantName) AGAINST (:term IN BOOLEAN MODE) * 1.5 +
119
- MATCH (description) AGAINST (:term IN BOOLEAN MODE) * 1`, 'score')
115
+ .addSelect(`IF (si_inner.sku LIKE :like_term, 10, 0)`, 'sku_score')
116
+ .addSelect(`(SELECT sku_score) +
117
+ MATCH (si_inner.productName) AGAINST (:term IN BOOLEAN MODE) * 2 +
118
+ MATCH (si_inner.productVariantName) AGAINST (:term IN BOOLEAN MODE) * 1.5 +
119
+ MATCH (si_inner.description) AGAINST (:term IN BOOLEAN MODE) * 1`, 'score')
120
120
  .where(new typeorm_1.Brackets(qb1 => {
121
- qb1.where('sku LIKE :like_term')
122
- .orWhere('MATCH (productName) AGAINST (:term IN BOOLEAN MODE)')
123
- .orWhere('MATCH (productVariantName) AGAINST (:term IN BOOLEAN MODE)')
124
- .orWhere('MATCH (description) AGAINST (:term IN BOOLEAN MODE)');
121
+ qb1.where('si_inner.sku LIKE :like_term')
122
+ .orWhere('MATCH (si_inner.productName) AGAINST (:term IN BOOLEAN MODE)')
123
+ .orWhere('MATCH (si_inner.productVariantName) AGAINST (:term IN BOOLEAN MODE)')
124
+ .orWhere('MATCH (si_inner.description) AGAINST (:term IN BOOLEAN MODE)');
125
125
  }))
126
- .andWhere('channelId = :channelId')
126
+ .andWhere('si_inner.channelId = :channelId')
127
127
  .setParameters({ term: `${term}*`, like_term: `%${term}%`, channelId: ctx.channelId });
128
128
  qb.innerJoin(`(${termScoreQuery.getQuery()})`, 'term_result', 'inner_productId = si.productId')
129
129
  .addSelect(input.groupByProduct ? 'MAX(term_result.score)' : 'term_result.score', 'score')
@@ -135,17 +135,17 @@ class MysqlSearchStrategy {
135
135
  }
136
136
  if (input.inStock != null) {
137
137
  if (input.groupByProduct) {
138
- qb.andWhere('productInStock = :inStock', { inStock: input.inStock });
138
+ qb.andWhere('si.productInStock = :inStock', { inStock: input.inStock });
139
139
  }
140
140
  else {
141
- qb.andWhere('inStock = :inStock', { inStock: input.inStock });
141
+ qb.andWhere('si.inStock = :inStock', { inStock: input.inStock });
142
142
  }
143
143
  }
144
144
  if (facetValueIds === null || facetValueIds === void 0 ? void 0 : facetValueIds.length) {
145
145
  qb.andWhere(new typeorm_1.Brackets(qb1 => {
146
146
  for (const id of facetValueIds) {
147
147
  const placeholder = (0, search_strategy_utils_1.createPlaceholderFromId)(id);
148
- const clause = `FIND_IN_SET(:${placeholder}, facetValueIds)`;
148
+ const clause = `FIND_IN_SET(:${placeholder}, si.facetValueIds)`;
149
149
  const params = { [placeholder]: id };
150
150
  if (facetValueOperator === generated_types_1.LogicalOperator.AND) {
151
151
  qb1.andWhere(clause, params);
@@ -166,14 +166,14 @@ class MysqlSearchStrategy {
166
166
  }
167
167
  if (facetValueFilter.and) {
168
168
  const placeholder = (0, search_strategy_utils_1.createPlaceholderFromId)(facetValueFilter.and);
169
- const clause = `FIND_IN_SET(:${placeholder}, facetValueIds)`;
169
+ const clause = `FIND_IN_SET(:${placeholder}, si.facetValueIds)`;
170
170
  const params = { [placeholder]: facetValueFilter.and };
171
171
  qb2.where(clause, params);
172
172
  }
173
173
  if ((_b = facetValueFilter.or) === null || _b === void 0 ? void 0 : _b.length) {
174
174
  for (const id of facetValueFilter.or) {
175
175
  const placeholder = (0, search_strategy_utils_1.createPlaceholderFromId)(id);
176
- const clause = `FIND_IN_SET(:${placeholder}, facetValueIds)`;
176
+ const clause = `FIND_IN_SET(:${placeholder}, si.facetValueIds)`;
177
177
  const params = { [placeholder]: id };
178
178
  qb2.orWhere(clause, params);
179
179
  }
@@ -183,16 +183,16 @@ class MysqlSearchStrategy {
183
183
  }));
184
184
  }
185
185
  if (collectionId) {
186
- qb.andWhere(`FIND_IN_SET (:collectionId, collectionIds)`, { collectionId });
186
+ qb.andWhere(`FIND_IN_SET (:collectionId, si.collectionIds)`, { collectionId });
187
187
  }
188
188
  if (collectionSlug) {
189
- qb.andWhere(`FIND_IN_SET (:collectionSlug, collectionSlugs)`, { collectionSlug });
189
+ qb.andWhere(`FIND_IN_SET (:collectionSlug, si.collectionSlugs)`, { collectionSlug });
190
190
  }
191
- qb.andWhere('languageCode = :languageCode', { languageCode: ctx.languageCode });
192
- qb.andWhere('channelId = :channelId', { channelId: ctx.channelId });
191
+ (0, search_strategy_utils_1.applyLanguageConstraints)(qb, ctx.languageCode, ctx.channel.defaultLanguageCode);
192
+ qb.andWhere('si.channelId = :channelId', { channelId: ctx.channelId });
193
193
  if (input.groupByProduct === true) {
194
- qb.groupBy('productId');
195
- qb.addSelect('BIT_OR(enabled)', 'productEnabled');
194
+ qb.groupBy('si.productId');
195
+ qb.addSelect('BIT_OR(si.enabled)', 'productEnabled');
196
196
  }
197
197
  return qb;
198
198
  }