@vendure/core 2.0.0-next.21 → 2.0.0-next.23

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 (104) hide show
  1. package/dist/api/api-internal-modules.d.ts +2 -1
  2. package/dist/api/api-internal-modules.js +2 -0
  3. package/dist/api/api-internal-modules.js.map +1 -1
  4. package/dist/api/config/configure-graphql-module.js +2 -0
  5. package/dist/api/config/configure-graphql-module.js.map +1 -1
  6. package/dist/api/config/generate-active-order-types.d.ts +14 -0
  7. package/dist/api/config/generate-active-order-types.js +91 -0
  8. package/dist/api/config/generate-active-order-types.js.map +1 -0
  9. package/dist/api/middleware/auth-guard.js +1 -1
  10. package/dist/api/middleware/auth-guard.js.map +1 -1
  11. package/dist/api/resolvers/admin/facet.resolver.d.ts +2 -1
  12. package/dist/api/resolvers/admin/facet.resolver.js +14 -0
  13. package/dist/api/resolvers/admin/facet.resolver.js.map +1 -1
  14. package/dist/api/resolvers/entity/job-entity.resolver.d.ts +2 -0
  15. package/dist/api/resolvers/entity/job-entity.resolver.js +36 -0
  16. package/dist/api/resolvers/entity/job-entity.resolver.js.map +1 -1
  17. package/dist/api/resolvers/entity/zone-entity.resolver.d.ts +8 -0
  18. package/dist/api/resolvers/entity/zone-entity.resolver.js +47 -0
  19. package/dist/api/resolvers/entity/zone-entity.resolver.js.map +1 -0
  20. package/dist/api/resolvers/shop/shop-order.resolver.d.ts +22 -18
  21. package/dist/api/resolvers/shop/shop-order.resolver.js +32 -27
  22. package/dist/api/resolvers/shop/shop-order.resolver.js.map +1 -1
  23. package/dist/api/schema/admin-api/facet.api.graphql +8 -0
  24. package/dist/api/schema/common/common-types.graphql +5 -0
  25. package/dist/common/types/common-types.d.ts +4 -0
  26. package/dist/config/config.module.js +4 -2
  27. package/dist/config/config.module.js.map +1 -1
  28. package/dist/config/default-config.js +3 -0
  29. package/dist/config/default-config.js.map +1 -1
  30. package/dist/config/index.d.ts +2 -0
  31. package/dist/config/index.js +2 -0
  32. package/dist/config/index.js.map +1 -1
  33. package/dist/config/order/active-order-strategy.d.ts +78 -0
  34. package/dist/config/order/active-order-strategy.js +5 -0
  35. package/dist/config/order/active-order-strategy.js.map +1 -0
  36. package/dist/config/order/default-active-order-strategy.d.ts +21 -0
  37. package/dist/config/order/default-active-order-strategy.js +74 -0
  38. package/dist/config/order/default-active-order-strategy.js.map +1 -0
  39. package/dist/config/vendure-config.d.ts +24 -0
  40. package/dist/connection/remove-custom-fields-with-eager-relations.d.ts +1 -1
  41. package/dist/connection/remove-custom-fields-with-eager-relations.js.map +1 -1
  42. package/dist/connection/transactional-connection.d.ts +5 -5
  43. package/dist/i18n/messages/de.json +3 -3
  44. package/dist/i18n/messages/en.json +3 -1
  45. package/dist/service/helpers/active-order/active-order.service.d.ts +18 -2
  46. package/dist/service/helpers/active-order/active-order.service.js +42 -5
  47. package/dist/service/helpers/active-order/active-order.service.js.map +1 -1
  48. package/dist/service/helpers/external-authentication/external-authentication.service.d.ts +5 -1
  49. package/dist/service/helpers/external-authentication/external-authentication.service.js +6 -2
  50. package/dist/service/helpers/external-authentication/external-authentication.service.js.map +1 -1
  51. package/dist/service/helpers/list-query-builder/parse-filter-params.js +5 -0
  52. package/dist/service/helpers/list-query-builder/parse-filter-params.js.map +1 -1
  53. package/dist/service/helpers/order-modifier/order-modifier.d.ts +7 -1
  54. package/dist/service/helpers/order-modifier/order-modifier.js +18 -26
  55. package/dist/service/helpers/order-modifier/order-modifier.js.map +1 -1
  56. package/dist/service/helpers/utils/get-user-channels-permissions.d.ts +6 -0
  57. package/dist/service/helpers/utils/get-user-channels-permissions.js +11 -3
  58. package/dist/service/helpers/utils/get-user-channels-permissions.js.map +1 -1
  59. package/dist/service/initializer.service.d.ts +3 -1
  60. package/dist/service/initializer.service.js +5 -1
  61. package/dist/service/initializer.service.js.map +1 -1
  62. package/dist/service/services/administrator.service.d.ts +9 -1
  63. package/dist/service/services/administrator.service.js +35 -6
  64. package/dist/service/services/administrator.service.js.map +1 -1
  65. package/dist/service/services/channel.service.js +2 -1
  66. package/dist/service/services/channel.service.js.map +1 -1
  67. package/dist/service/services/collection.service.js +4 -2
  68. package/dist/service/services/collection.service.js.map +1 -1
  69. package/dist/service/services/country.service.js +2 -1
  70. package/dist/service/services/country.service.js.map +1 -1
  71. package/dist/service/services/customer-group.service.js +2 -1
  72. package/dist/service/services/customer-group.service.js.map +1 -1
  73. package/dist/service/services/customer.service.js +2 -1
  74. package/dist/service/services/customer.service.js.map +1 -1
  75. package/dist/service/services/facet-value.service.d.ts +14 -2
  76. package/dist/service/services/facet-value.service.js +38 -6
  77. package/dist/service/services/facet-value.service.js.map +1 -1
  78. package/dist/service/services/facet.service.js +3 -1
  79. package/dist/service/services/facet.service.js.map +1 -1
  80. package/dist/service/services/history.service.d.ts +94 -4
  81. package/dist/service/services/history.service.js +94 -2
  82. package/dist/service/services/history.service.js.map +1 -1
  83. package/dist/service/services/order.service.js +3 -1
  84. package/dist/service/services/order.service.js.map +1 -1
  85. package/dist/service/services/payment-method.service.js +2 -1
  86. package/dist/service/services/payment-method.service.js.map +1 -1
  87. package/dist/service/services/payment.service.js +19 -7
  88. package/dist/service/services/payment.service.js.map +1 -1
  89. package/dist/service/services/product-option-group.service.js +2 -1
  90. package/dist/service/services/product-option-group.service.js.map +1 -1
  91. package/dist/service/services/product-option.service.js +2 -1
  92. package/dist/service/services/product-option.service.js.map +1 -1
  93. package/dist/service/services/product.service.js.map +1 -1
  94. package/dist/service/services/role.service.d.ts +14 -1
  95. package/dist/service/services/role.service.js +57 -12
  96. package/dist/service/services/role.service.js.map +1 -1
  97. package/dist/service/services/tax-category.service.js +2 -1
  98. package/dist/service/services/tax-category.service.js.map +1 -1
  99. package/dist/service/services/tax-rate.service.d.ts +13 -3
  100. package/dist/service/services/tax-rate.service.js +30 -8
  101. package/dist/service/services/tax-rate.service.js.map +1 -1
  102. package/dist/service/services/zone.service.js +2 -1
  103. package/dist/service/services/zone.service.js.map +1 -1
  104. package/package.json +3 -3
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.DefaultActiveOrderStrategy = void 0;
23
+ const errors_1 = require("../../common/error/errors");
24
+ const transactional_connection_1 = require("../../connection/transactional-connection");
25
+ const order_entity_1 = require("../../entity/order/order.entity");
26
+ /**
27
+ * @description
28
+ * The default {@link ActiveOrderStrategy}, which uses the current {@link Session} to determine
29
+ * the active Order, and requires no additional input in the Shop API since it is based on the
30
+ * session which is part of the RequestContext.
31
+ *
32
+ * @since 1.9.0
33
+ */
34
+ class DefaultActiveOrderStrategy {
35
+ async init(injector) {
36
+ this.connection = injector.get(transactional_connection_1.TransactionalConnection);
37
+ // Lazy import these dependencies to avoid a circular dependency issue in NestJS.
38
+ const { OrderService } = await Promise.resolve().then(() => __importStar(require('../../service/services/order.service')));
39
+ const { SessionService } = await Promise.resolve().then(() => __importStar(require('../../service/services/session.service')));
40
+ this.orderService = injector.get(OrderService);
41
+ this.sessionService = injector.get(SessionService);
42
+ }
43
+ createActiveOrder(ctx) {
44
+ return this.orderService.create(ctx, ctx.activeUserId);
45
+ }
46
+ async determineActiveOrder(ctx) {
47
+ if (!ctx.session) {
48
+ throw new errors_1.InternalServerError(`error.no-active-session`);
49
+ }
50
+ let order = ctx.session.activeOrderId
51
+ ? await this.connection
52
+ .getRepository(ctx, order_entity_1.Order)
53
+ .createQueryBuilder('order')
54
+ .leftJoin('order.channels', 'channel')
55
+ .where('order.id = :orderId', { orderId: ctx.session.activeOrderId })
56
+ .andWhere('channel.id = :channelId', { channelId: ctx.channelId })
57
+ .getOne()
58
+ : undefined;
59
+ if (order && order.active === false) {
60
+ // edge case where an inactive order may not have been
61
+ // removed from the session, i.e. the regular process was interrupted
62
+ await this.sessionService.unsetActiveOrder(ctx, ctx.session);
63
+ order = undefined;
64
+ }
65
+ if (!order) {
66
+ if (ctx.activeUserId) {
67
+ order = await this.orderService.getActiveOrderForUser(ctx, ctx.activeUserId);
68
+ }
69
+ }
70
+ return order || undefined;
71
+ }
72
+ }
73
+ exports.DefaultActiveOrderStrategy = DefaultActiveOrderStrategy;
74
+ //# sourceMappingURL=default-active-order-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-active-order-strategy.js","sourceRoot":"","sources":["../../../src/config/order/default-active-order-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,sDAAgE;AAEhE,wFAAoF;AACpF,kEAAwD;AAMxD;;;;;;;GAOG;AACH,MAAa,0BAA0B;IAOnC,KAAK,CAAC,IAAI,CAAC,QAAkB;QACzB,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,kDAAuB,CAAC,CAAC;QACxD,iFAAiF;QACjF,MAAM,EAAE,YAAY,EAAE,GAAG,wDAAa,sCAAsC,GAAC,CAAC;QAC9E,MAAM,EAAE,cAAc,EAAE,GAAG,wDAAa,wCAAwC,GAAC,CAAC;QAClF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,cAAc,GAAG,QAAQ,CAA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}
@@ -24,6 +24,7 @@ import { CustomFulfillmentProcess } from './fulfillment/custom-fulfillment-proce
24
24
  import { FulfillmentHandler } from './fulfillment/fulfillment-handler';
25
25
  import { JobQueueStrategy } from './job-queue/job-queue-strategy';
26
26
  import { VendureLogger } from './logger/vendure-logger';
27
+ import { ActiveOrderStrategy } from './order/active-order-strategy';
27
28
  import { ChangedPriceHandlingStrategy } from './order/changed-price-handling-strategy';
28
29
  import { CustomOrderProcess } from './order/custom-order-process';
29
30
  import { OrderByCodeAccessStrategy } from './order/order-by-code-access-strategy';
@@ -542,6 +543,18 @@ export interface OrderOptions {
542
543
  * @default DefaultOrderPlacedStrategy
543
544
  */
544
545
  orderPlacedStrategy?: OrderPlacedStrategy;
546
+ /**
547
+ * @description
548
+ * Defines the strategy used to determine the active Order when interacting with Shop API operations
549
+ * such as `activeOrder` and `addItemToOrder`. By default, the strategy uses the active Session.
550
+ *
551
+ * Note that if multiple strategies are defined, they will be checked in order and the first one that
552
+ * returns an Order will be used.
553
+ *
554
+ * @since 1.9.0
555
+ * @default DefaultActiveOrderStrategy
556
+ */
557
+ activeOrderStrategy?: ActiveOrderStrategy | ActiveOrderStrategy[];
545
558
  }
546
559
  /**
547
560
  * @description
@@ -858,6 +871,17 @@ export interface EntityOptions {
858
871
  * @default 30000
859
872
  */
860
873
  zoneCacheTtl?: number;
874
+ /**
875
+ * @description
876
+ * TaxRates get cached in-memory as they are accessed very frequently. This
877
+ * setting determines how long the cache lives (in ms) until it is considered stale and
878
+ * refreshed. For multi-instance deployments (e.g. serverless, load-balanced), a
879
+ * smaller value here will prevent data inconsistencies between instances.
880
+ *
881
+ * @since 1.9.0
882
+ * @default 30000
883
+ */
884
+ taxRateCacheTtl?: number;
861
885
  /**
862
886
  * @description
863
887
  * Allows the metadata of the built-in TypeORM entities to be manipulated. This allows you
@@ -31,4 +31,4 @@ import { SelectQueryBuilder } from 'typeorm';
31
31
  *
32
32
  * TODO: Ideally create a minimal reproduction case and report in the TypeORM repo for an upstream fix.
33
33
  */
34
- export declare function removeCustomFieldsWithEagerRelations(qb: SelectQueryBuilder<any>, relations?: string[]): string[];
34
+ export declare function removeCustomFieldsWithEagerRelations<T extends string>(qb: SelectQueryBuilder<any>, relations?: T[]): T[];
@@ -1 +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,CAAC,QAAQ,CAAC,EAAE;YAC5F,OAAO,CACH,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;gBAC7E,QAAQ,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,CACzC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,KAAK,cAAc,IAAI,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CACpF,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;QACH,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;AA9BD,oFA8BC"}
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,YAAiB,EAAE;IAEnB,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,CAAC,QAAQ,CAAC,EAAE;YAC5F,OAAO,CACH,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;gBAC7E,QAAQ,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,CACzC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,KAAK,cAAc,IAAI,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CACpF,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;QACH,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;AA9BD,oFA8BC"}
@@ -67,18 +67,18 @@ export declare class TransactionalConnection {
67
67
  * @example
68
68
  * ```TypeScript
69
69
  * private async transferCredit(outerCtx: RequestContext, fromId: ID, toId: ID, amount: number) {
70
- * await this.connection.withTransaction(outerCtx, ctx => {
71
- * await this.giftCardService.updateCustomerCredit(fromId, -amount);
72
- *
73
- * // Note you must not use outerCtx here, instead use ctx. Otherwise this query
70
+ * await this.connection.withTransaction(outerCtx, async ctx => {
71
+ * // Note you must not use `outerCtx` here, instead use `ctx`. Otherwise, this query
74
72
  * // will be executed outside of transaction
73
+ * await this.giftCardService.updateCustomerCredit(ctx, fromId, -amount);
74
+ *
75
75
  * await this.connection.getRepository(ctx, GiftCard).update(fromId, { transferred: true })
76
76
  *
77
77
  * // If some intermediate logic here throws an Error,
78
78
  * // then all DB transactions will be rolled back and neither Customer's
79
79
  * // credit balance will have changed.
80
80
  *
81
- * await this.giftCardService.updateCustomerCredit(toId, amount);
81
+ * await this.giftCardService.updateCustomerCredit(ctx, toId, amount);
82
82
  * })
83
83
  * }
84
84
  * ```
@@ -70,7 +70,7 @@
70
70
  "NO_ACTIVE_ORDER_ERROR": "Es gibt keine aktive Bestellung in der aktuellen Sitzung",
71
71
  "NOTHING_TO_REFUND_ERROR": "Es gibt nichts zurückzuerstatten",
72
72
  "NOT_VERIFIED_ERROR": "Bitte bestätige deine E-Mail-Adresse, bevor du dich anmeldest",
73
- "ORDER_LIMIT_ERROR": "Der Artikel konnte nicht hinzugefügt werden. Eine Bestellung kann maximal { maxItems } Artikel enthalten",
73
+ "ORDER_LIMIT_ERROR": "Der Artikel konnte nicht hinzugefügt werden. Eine Bestellung kann maximal { maxItems } Artikel enthalten",
74
74
  "ORDER_MODIFICATION_ERROR": "Der Inhalt der Bestellung kann nur im Status \"AddingItems\" geändert werden",
75
75
  "ORDER_PAYMENT_STATE_ERROR": "Eine Zahlung kann nur im Status \"ArrangingPayment\" hinzugefügt werden",
76
76
  "ORDER_STATE_TRANSITION_ERROR": "Der Status der Bestellung kan nicht von \"{ fromState }\" zu \"{ toState }\" geändert werden",
@@ -108,9 +108,9 @@
108
108
  "facet-force-deleted": "Die Facette wurde gelöscht und ihre FacetValues wurden von {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvariantem}} entfernt",
109
109
  "facet-used": "Die ausgewählte Facette enthält FacetValues, die {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen sind",
110
110
  "facet-value-force-deleted": "Der gewählte FacetValue wurde von {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} entfernt und gelöscht",
111
- "facet-value-used": "Der gewählte FacetValue wurde {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen",
111
+ "facet-value-used": "Der FacetValue \"{ facetValueCode }\" wurde {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen",
112
112
  "payment-method-used-in-channels": "Die gewählte Zahlungsmethode wird von den folgenden Kanälen verwendet: { channelCodes }. Mit \"force: true\" wird sie von allen Kanälen entfernt.",
113
113
  "zone-used-in-channels": "Die ausgewählte Zone kann nicht gelöscht werden, da sie als Standard in den folgenden Kanälen verwendet wird: { channelCodes }",
114
114
  "zone-used-in-tax-rates": "Die ausgewählte Zone kann nicht gelöscht werden, da sie in den folgenden Steuersätzen verwendet wird: { taxRateNames }"
115
115
  }
116
- }
116
+ }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "error": {
3
+ "active-user-does-not-have-sufficient-permissions": "Active user does not have sufficient permissions",
3
4
  "cannot-delete-role": "The role '{ roleCode }' cannot be deleted",
4
5
  "cannot-delete-sole-superadmin": "The sole SuperAdmin cannot be deleted",
5
6
  "cannot-locate-customer-for-user": "Cannot locate a Customer for the user",
@@ -37,6 +38,7 @@
37
38
  "no-configurable-operation-def-with-code-found": "No { type } with the code '{ code }' could be found",
38
39
  "no-price-found-for-channel": "No price information was found for ProductVariant ID '{ variantId}' in the Channel '{ channel }'.",
39
40
  "no-search-plugin-configured": "No search plugin has been configured",
41
+ "order-could-not-be-determined-or-created": "No active Order could be determined nor created",
40
42
  "order-does-not-contain-line-with-id": "This order does not contain an OrderLine with the id { id }",
41
43
  "pending-identifier-missing": "Could not find the pending email address to update",
42
44
  "permission-invalid": "The permission \"{ permission }\" may not be assigned",
@@ -120,7 +122,7 @@
120
122
  "facet-force-deleted": "The Facet was deleted and its FacetValues were removed from {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
121
123
  "facet-used": "The Facet \"{ facetCode }\" includes FacetValues which are assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
122
124
  "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",
123
- "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}}",
125
+ "facet-value-used": "The FacetValue \"{ facetValueCode }\" is assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
124
126
  "payment-method-used-in-channels": "The selected PaymentMethod is assigned to the following Channels: { channelCodes }. Set \"force: true\" to delete from all Channels.",
125
127
  "product-option-used": "Cannot delete the option \"{code}\" as it is being used by {count, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
126
128
  "zone-used-in-channels": "The selected Zone cannot be deleted as it used as a default in the following Channels: { channelCodes }",
@@ -1,5 +1,6 @@
1
1
  import { RequestContext } from '../../../api/common/request-context';
2
- import { TransactionalConnection } from '../../../connection/transactional-connection';
2
+ import { ConfigService } from '../../../config/index';
3
+ import { TransactionalConnection } from '../../../connection/index';
3
4
  import { Order } from '../../../entity/order/order.entity';
4
5
  import { OrderService } from '../../services/order.service';
5
6
  import { SessionService } from '../../services/session.service';
@@ -13,7 +14,8 @@ export declare class ActiveOrderService {
13
14
  private sessionService;
14
15
  private orderService;
15
16
  private connection;
16
- constructor(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection);
17
+ private configService;
18
+ constructor(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection, configService: ConfigService);
17
19
  /**
18
20
  * @description
19
21
  * Gets the active Order object from the current Session. Optionally can create a new Order if
@@ -21,7 +23,21 @@ export declare class ActiveOrderService {
21
23
  *
22
24
  * Intended to be used at the Resolver layer for those resolvers that depend upon an active Order
23
25
  * being present.
26
+ *
27
+ * @deprecated From v1.9.0, use the `getActiveOrder` method which uses any configured ActiveOrderStrategies
24
28
  */
25
29
  getOrderFromContext(ctx: RequestContext): Promise<Order | undefined>;
26
30
  getOrderFromContext(ctx: RequestContext, createIfNotExists: true): Promise<Order>;
31
+ /**
32
+ * @description
33
+ * Retrieves the active Order based on the configured {@link ActiveOrderStrategy}.
34
+ *
35
+ * @since 1.9.0
36
+ */
37
+ getActiveOrder(ctx: RequestContext, input: {
38
+ [strategyName: string]: any;
39
+ } | undefined): Promise<Order | undefined>;
40
+ getActiveOrder(ctx: RequestContext, input: {
41
+ [strategyName: string]: any;
42
+ } | undefined, createIfNotExists: true): Promise<Order>;
27
43
  }
@@ -11,8 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ActiveOrderService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
- const errors_1 = require("../../../common/error/errors");
15
- const transactional_connection_1 = require("../../../connection/transactional-connection");
14
+ const index_1 = require("../../../common/index");
15
+ const index_2 = require("../../../config/index");
16
+ const index_3 = require("../../../connection/index");
16
17
  const order_entity_1 = require("../../../entity/order/order.entity");
17
18
  const order_service_1 = require("../../services/order.service");
18
19
  const session_service_1 = require("../../services/session.service");
@@ -23,14 +24,15 @@ const session_service_1 = require("../../services/session.service");
23
24
  * @docsCategory orders
24
25
  */
25
26
  let ActiveOrderService = class ActiveOrderService {
26
- constructor(sessionService, orderService, connection) {
27
+ constructor(sessionService, orderService, connection, configService) {
27
28
  this.sessionService = sessionService;
28
29
  this.orderService = orderService;
29
30
  this.connection = connection;
31
+ this.configService = configService;
30
32
  }
31
33
  async getOrderFromContext(ctx, createIfNotExists = false) {
32
34
  if (!ctx.session) {
33
- throw new errors_1.InternalServerError(`error.no-active-session`);
35
+ throw new index_1.InternalServerError(`error.no-active-session`);
34
36
  }
35
37
  let order = ctx.session.activeOrderId
36
38
  ? await this.connection
@@ -60,12 +62,47 @@ let ActiveOrderService = class ActiveOrderService {
60
62
  }
61
63
  return order || undefined;
62
64
  }
65
+ async getActiveOrder(ctx, input, createIfNotExists = false) {
66
+ var _a;
67
+ let order;
68
+ if (!order) {
69
+ const { activeOrderStrategy } = this.configService.orderOptions;
70
+ const strategyArray = Array.isArray(activeOrderStrategy)
71
+ ? activeOrderStrategy
72
+ : [activeOrderStrategy];
73
+ for (const strategy of strategyArray) {
74
+ const strategyInput = (_a = input === null || input === void 0 ? void 0 : input[strategy.name]) !== null && _a !== void 0 ? _a : {};
75
+ order = await strategy.determineActiveOrder(ctx, strategyInput);
76
+ if (order) {
77
+ break;
78
+ }
79
+ if (createIfNotExists && typeof strategy.createActiveOrder === 'function') {
80
+ order = await strategy.createActiveOrder(ctx, input);
81
+ }
82
+ if (order) {
83
+ break;
84
+ }
85
+ }
86
+ if (!order && createIfNotExists) {
87
+ // No order has been found, and none could be created, which indicates that
88
+ // none of the configured strategies have a `createActiveOrder` method defined.
89
+ // In this case, we should throw an error because it is assumed that such a configuration
90
+ // indicates that an external order creation mechanism should be defined.
91
+ throw new index_1.UserInputError('error.order-could-not-be-determined-or-created');
92
+ }
93
+ if (order && ctx.session) {
94
+ await this.sessionService.setActiveOrder(ctx, ctx.session, order);
95
+ }
96
+ }
97
+ return order || undefined;
98
+ }
63
99
  };
64
100
  ActiveOrderService = __decorate([
65
101
  (0, common_1.Injectable)(),
66
102
  __metadata("design:paramtypes", [session_service_1.SessionService,
67
103
  order_service_1.OrderService,
68
- transactional_connection_1.TransactionalConnection])
104
+ index_3.TransactionalConnection,
105
+ index_2.ConfigService])
69
106
  ], ActiveOrderService);
70
107
  exports.ActiveOrderService = ActiveOrderService;
71
108
  //# sourceMappingURL=active-order.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"active-order.service.js","sourceRoot":"","sources":["../../../../src/service/helpers/active-order/active-order.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,yDAAmE;AACnE,2FAAuF;AACvF,qEAA2D;AAC3D,gEAA4D;AAC5D,oEAAgE;AAEhE;;;;;GAKG;AAEH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC3B,YACY,cAA8B,EAC9B,YAA0B,EAC1B,UAAmC;QAFnC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAyB;IAC5C,CAAC;IAYJ,KAAK,CAAC,mBAAmB,CAAC,GAAmB,EAAE,iBAAiB,GAAG,KAAK;QACpE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YACd,MAAM,IAAI,4BAAmB,CAAC,yBAAyB,CAAC,CAAC;SAC5D;QACD,IAAI,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa;YACjC,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU;iBAChB,aAAa,CAAC,GAAG,EAAE,oBAAK,CAAC;iBACzB,kBAAkB,CAAC,OAAO,CAAC;iBAC3B,QAAQ,CAAC,gBAAgB,EAAE,SAAS,CAAC;iBACrC,KAAK,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;iBACpE,QAAQ,CAAC,yBAAyB,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;iBACjE,MAAM,EAAE;YACf,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,EAAE;YACjC,sDAAsD;YACtD,qEAAqE;YACrE,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7D,KAAK,GAAG,SAAS,CAAC;SACrB;QACD,IAAI,CAAC,KAAK,EAAE;YACR,IAAI,GAAG,CAAC,YAAY,EAAE;gBAClB,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;aAChF;YAED,IAAI,CAAC,KAAK,IAAI,iBAAiB,EAAE;gBAC7B,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;aACjE;YAED,IAAI,KAAK,EAAE;gBACP,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;aACrE;SACJ;QACD,OAAO,KAAK,IAAI,SAAS,CAAC;IAC9B,CAAC;CACJ,CAAA;AAnDY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAGmB,gCAAc;QAChB,4BAAY;QACd,kDAAuB;GAJtC,kBAAkB,CAmD9B;AAnDY,gDAAkB"}
1
+ {"version":3,"file":"active-order.service.js","sourceRoot":"","sources":["../../../../src/service/helpers/active-order/active-order.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,iDAA4E;AAC5E,iDAAsD;AACtD,qDAAoE;AACpE,qEAA2D;AAC3D,gEAA4D;AAC5D,oEAAgE;AAEhE;;;;;GAKG;AAEH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC3B,YACY,cAA8B,EAC9B,YAA0B,EAC1B,UAAmC,EACnC,aAA4B;QAH5B,mBAAc,GAAd,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,CAAC;aAC9E;YAED,IAAI,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE;gBACtB,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;aACrE;SACJ;QACD,OAAO,KAAK,IAAI,SAAS,CAAC;IAC9B,CAAC;CACJ,CAAA;AA7GY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAGmB,gCAAc;QAChB,4BAAY;QACd,+BAAuB;QACpB,qBAAa;GAL/B,kBAAkB,CA6G9B;AA7GY,gDAAkB"}
@@ -26,8 +26,12 @@ export declare class ExternalAuthenticationService {
26
26
  * @description
27
27
  * Looks up a User based on their identifier from an external authentication
28
28
  * provider, ensuring this User is associated with a Customer account.
29
+ *
30
+ * By default, only customers in the currently-active Channel will be checked.
31
+ * By passing `false` as the `checkCurrentChannelOnly` argument, _all_ channels
32
+ * will be checked.
29
33
  */
30
- findCustomerUser(ctx: RequestContext, strategy: string, externalIdentifier: string): Promise<User | undefined>;
34
+ findCustomerUser(ctx: RequestContext, strategy: string, externalIdentifier: string, checkCurrentChannelOnly?: boolean): Promise<User | undefined>;
31
35
  /**
32
36
  * @description
33
37
  * Looks up a User based on their identifier from an external authentication
@@ -42,12 +42,16 @@ let ExternalAuthenticationService = class ExternalAuthenticationService {
42
42
  * @description
43
43
  * Looks up a User based on their identifier from an external authentication
44
44
  * provider, ensuring this User is associated with a Customer account.
45
+ *
46
+ * By default, only customers in the currently-active Channel will be checked.
47
+ * By passing `false` as the `checkCurrentChannelOnly` argument, _all_ channels
48
+ * will be checked.
45
49
  */
46
- async findCustomerUser(ctx, strategy, externalIdentifier) {
50
+ async findCustomerUser(ctx, strategy, externalIdentifier, checkCurrentChannelOnly = true) {
47
51
  const user = await this.findUser(ctx, strategy, externalIdentifier);
48
52
  if (user) {
49
53
  // Ensure this User is associated with a Customer
50
- const customer = await this.customerService.findOneByUserId(ctx, user.id);
54
+ const customer = await this.customerService.findOneByUserId(ctx, user.id, checkCurrentChannelOnly);
51
55
  if (customer) {
52
56
  return user;
53
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"external-authentication.service.js","sourceRoot":"","sources":["../../../../src/service/helpers/external-authentication/external-authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yEAAuE;AAGvE,2FAAuF;AACvF,6FAAmF;AACnF,uIAA2H;AAC3H,8EAAoE;AAEpE,kEAAwD;AACxD,gFAA4E;AAC5E,oEAAgE;AAChE,sEAAkE;AAClE,oEAAgE;AAChE,8DAA0D;AAE1D;;;;;;GAMG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IACtC,YACY,UAAmC,EACnC,WAAwB,EACxB,cAA8B,EAC9B,eAAgC,EAChC,oBAA0C,EAC1C,cAA8B;QAL9B,eAAU,GAAV,UAAU,CAAyB;QACnC,gBAAW,GAAX,WAAW,CAAa;QACxB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,oBAAe,GAAf,eAAe,CAAiB;QAChC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,mBAAc,GAAd,cAAc,CAAgB;IACvC,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAClB,GAAmB,EACnB,QAAgB,EAChB,kBAA0B;QAE1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAEpE,IAAI,IAAI,EAAE;YACN,iDAAiD;YACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1E,IAAI,QAAQ,EAAE;gBACV,OAAO,IAAI,CAAC;aACf;SACJ;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,qBAAqB,CACvB,GAAmB,EACnB,QAAgB,EAChB,kBAA0B;QAE1B,MAA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AAQ,CAAC,qDAAqD,EAAE,EAAE,kBAAkB,EAAE,CAAC;aACvF,QAAQ,CAAC,wBAAwB,CAAC;aAClC,OAAO,EAAE,CAAC;QAEf,MAAM,YAAY,GAAG,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAC3B,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,oEAA4B,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAC5E,CACJ,CAAC;QAEF,OAAO,YAAY,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,sCAAsC,CAAC,GAAmB,EAAE,YAAoB;QAC1F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU;aACjC,aAAa,CAAC,GAAG,EAAE,0BAAQ,CAAC;aAC5B,kBAAkB,CAAC,UAAU,CAAC;aAC9B,iBAAiB,CAAC,eAAe,EAAE,MAAM,CAAC;aAC1C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,CAAC;aACxC,iBAAiB,CAAC,4BAA4B,EAAE,YAAY,CAAC;aAC7D,QAAQ,CAAC,uCAAuC,EAAE,EAAE,YAAY,EAAE,CAAC;aACnE,QAAQ,CAAC,wBAAwB,CAAC;aAClC,MAAM,EAAE,CAAC;QAEd,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;IAC1B,CAAC;CACJ,CAAA;AArNY,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAGe,kDAAuB;QACtB,0BAAW;QACR,gCAAc;QACb,kCAAe;QACV,4CAAoB;QAC1B,gCAAc;GAPjC,6BAA6B,CAqNzC;AArNY,sEAA6B"}
1
+ {"version":3,"file":"external-authentication.service.js","sourceRoot":"","sources":["../../../../src/service/helpers/external-authentication/external-authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yEAAuE;AAGvE,2FAAuF;AACvF,6FAAmF;AACnF,uIAA2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,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,oEAA4B,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAC5E,CACJ,CAAC;QAEF,OAAO,YAAY,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,sCAAsC,CAAC,GAAmB,EAAE,YAAoB;QAC1F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU;aACjC,aAAa,CAAC,GAAG,EAAE,0BAAQ,CAAC;aAC5B,kBAAkB,CAAC,UAAU,CAAC;aAC9B,iBAAiB,CAAC,eAAe,EAAE,MAAM,CAAC;aAC1C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,CAAC;aACxC,iBAAiB,CAAC,4BAA4B,EAAE,YAAY,CAAC;aAC7D,QAAQ,CAAC,uCAAuC,EAAE,EAAE,YAAY,EAAE,CAAC;aACnE,QAAQ,CAAC,wBAAwB,CAAC;aAClC,MAAM,EAAE,CAAC;QAEd,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;IAC1B,CAAC;CACJ,CAAA;AA9NY,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAGe,kDAAuB;QACtB,0BAAW;QACR,gCAAc;QACb,kCAAe;QACV,4CAAoB;QAC1B,gCAAc;GAPjC,6BAA6B,CA8NzC;AA9NY,sEAA6B"}
@@ -122,6 +122,11 @@ function buildWhereCondition(fieldName, operator, operand, argIndex, dbType) {
122
122
  [`arg${argIndex}_b`]: convertDate(operand.end),
123
123
  },
124
124
  };
125
+ case 'isNull':
126
+ return {
127
+ clause: operand === true ? `${fieldName} IS NULL` : `${fieldName} IS NOT NULL`,
128
+ parameters: {},
129
+ };
125
130
  default:
126
131
  (0, shared_utils_1.assertNever)(operator);
127
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-filter-params.js","sourceRoot":"","sources":["../../../../src/service/helpers/list-query-builder/parse-filter-params.ts"],"names":[],"mappings":";;;AACA,mEAA+D;AAE/D,sDAAmD;AA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AAO;QACH,MAAM,EAAE,GAAG;QACX,UAAU,EAAE,EAAE;KACjB,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,KAA6B;IAC9C,IAAI,KAAK,YAAY,IAAI,EAAE;QACvB,OAAO,qBAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;KACxD;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,SAAiB,EAAE,QAAgB,EAAE,MAAiC;IAC3F,QAAQ,MAAM,EAAE;QACZ,KAAK,SAAS,CAAC;QACf,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,gBAAgB,CAAC;QACtB,KAAK,iBAAiB;YAClB,OAAO,GAAG,SAAS,eAAe,QAAQ,EAAE,CAAC;QACjD,KAAK,UAAU,CAAC;QAChB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,aAAa;YACd,OAAO,GAAG,SAAS,WAAW,QAAQ,EAAE,CAAC;QAC7C,kEAAkE;QAClE,wDAAwD;QACxD,kEAAkE;QAClE,KAAK,QAAQ,CAAC;QACd;YACI,MAAM,IAAI,4BAAmB,CACzB,uDAAuD,MAAM,UAAU,CAC1E,CAAC;KACT;AACL,CAAC"}
1
+ {"version":3,"file":"parse-filter-params.js","sourceRoot":"","sources":["../../../../src/service/helpers/list-query-builder/parse-filter-params.ts"],"names":[],"mappings":";;;AACA,mEAA+D;AAE/D,sDAAmD;AAEnD,yDAAmF;AAYnF,yDAAyF;AACzF,qEAAgE;AAUhE,SAAgB,iBAAiB,CAC7B,UAAsB,EACtB,MAAe,EACf,YAAuD,EACvD,iBAA8C,EAC9C,WAAoB;IAEpB,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,EAAE,CAAC;KACb;IACD,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAA,oCAAiB,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC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Y,IAAI,EAAE;QACvB,OAAO,qBAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;KACxD;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,SAAiB,EAAE,QAAgB,EAAE,MAAiC;IAC3F,QAAQ,MAAM,EAAE;QACZ,KAAK,SAAS,CAAC;QACf,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,gBAAgB,CAAC;QACtB,KAAK,iBAAiB;YAClB,OAAO,GAAG,SAAS,eAAe,QAAQ,EAAE,CAAC;QACjD,KAAK,UAAU,CAAC;QAChB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,aAAa;YACd,OAAO,GAAG,SAAS,WAAW,QAAQ,EAAE,CAAC;QAC7C,kEAAkE;QAClE,wDAAwD;QACxD,kEAAkE;QAClE,KAAK,QAAQ,CAAC;QACd;YACI,MAAM,IAAI,4BAAmB,CACzB,uDAAuD,MAAM,UAAU,CAC1E,CAAC;KACT;AACL,CAAC"}
@@ -81,7 +81,13 @@ export declare class OrderModifier {
81
81
  modification: OrderModification;
82
82
  }>;
83
83
  private noChangesSpecified;
84
- private getAdjustmentFromNewlyAppliedPromotions;
84
+ /**
85
+ * @description
86
+ * Because a Refund's amount is calculated based on the orderItems changed, plus shipping change,
87
+ * we need to make sure the amount gets adjusted to match any changes caused by other factors,
88
+ * i.e. promotions that were previously active but are no longer.
89
+ */
90
+ private calculateRefundAdjustment;
85
91
  private getOrderPayments;
86
92
  private customFieldsAreEqual;
87
93
  /**
@@ -17,7 +17,6 @@ const error_result_1 = require("../../../common/error/error-result");
17
17
  const errors_1 = require("../../../common/error/errors");
18
18
  const generated_graphql_admin_errors_1 = require("../../../common/error/generated-graphql-admin-errors");
19
19
  const generated_graphql_shop_errors_1 = require("../../../common/error/generated-graphql-shop-errors");
20
- const adjustment_source_1 = require("../../../common/types/adjustment-source");
21
20
  const utils_1 = require("../../../common/utils");
22
21
  const config_service_1 = require("../../../config/config.service");
23
22
  const transactional_connection_1 = require("../../../connection/transactional-connection");
@@ -163,7 +162,7 @@ let OrderModifier = class OrderModifier {
163
162
  newOrderItems.forEach((item, i) => (item.id = identifiers[i].id));
164
163
  orderLine.items = await this.connection
165
164
  .getRepository(ctx, order_item_entity_1.OrderItem)
166
- .find({ where: { line: orderLine } });
165
+ .find({ where: { line: orderLine }, order: { createdAt: 'ASC' } });
167
166
  if (!order.active && order.state !== 'Draft') {
168
167
  await this.stockMovementService.createAllocationsForOrderLines(ctx, [
169
168
  {
@@ -174,7 +173,7 @@ let OrderModifier = class OrderModifier {
174
173
  }
175
174
  }
176
175
  else if (quantity < currentQuantity) {
177
- if (order.active) {
176
+ if (order.active || order.state === 'Draft') {
178
177
  // When an Order is still active, it is fine to just delete
179
178
  // any OrderItems that are no longer needed
180
179
  const keepItems = orderLine.items.slice(0, quantity);
@@ -379,7 +378,7 @@ let OrderModifier = class OrderModifier {
379
378
  const updatedOrderLines = order.lines.filter(l => updatedOrderLineIds.includes(l.id));
380
379
  const promotions = await this.promotionService.getActivePromotionsInChannel(ctx);
381
380
  const activePromotionsPre = await this.promotionService.getActivePromotionsOnOrder(ctx, order.id);
382
- await this.orderCalculator.applyPriceAdjustments(ctx, order, promotions, updatedOrderLines, {
381
+ const updatedOrderItems = await this.orderCalculator.applyPriceAdjustments(ctx, order, promotions, updatedOrderLines, {
383
382
  recalculateShipping: (_g = input.options) === null || _g === void 0 ? void 0 : _g.recalculateShipping,
384
383
  });
385
384
  const orderCustomFields = input.customFields;
@@ -401,7 +400,7 @@ let OrderModifier = class OrderModifier {
401
400
  if (shippingDelta < 0) {
402
401
  refundInput.shipping = shippingDelta * -1;
403
402
  }
404
- refundInput.adjustment += await this.getAdjustmentFromNewlyAppliedPromotions(ctx, order, activePromotionsPre);
403
+ refundInput.adjustment += this.calculateRefundAdjustment(delta, refundInput);
405
404
  const existingPayments = await this.getOrderPayments(ctx, order.id);
406
405
  const payment = existingPayments.find(p => { var _a; return (0, utils_1.idsAreEqual)(p.id, (_a = input.refund) === null || _a === void 0 ? void 0 : _a.paymentId); });
407
406
  if (payment) {
@@ -427,9 +426,10 @@ let OrderModifier = class OrderModifier {
427
426
  }
428
427
  else {
429
428
  // Otherwise, just save those OrderItems that were specifically added/removed
429
+ // or updated when applying `OrderCalculator.applyPriceAdjustments()`
430
430
  await this.connection
431
431
  .getRepository(ctx, order_item_entity_1.OrderItem)
432
- .save(modification.orderItems, { reload: false });
432
+ .save([...modification.orderItems, ...updatedOrderItems], { reload: false });
433
433
  }
434
434
  await this.connection.getRepository(ctx, shipping_line_entity_1.ShippingLine).save(order.shippingLines, { reload: false });
435
435
  return { order, modification: createdModification };
@@ -445,26 +445,18 @@ let OrderModifier = class OrderModifier {
445
445
  !input.customFields;
446
446
  return noChanges;
447
447
  }
448
- async getAdjustmentFromNewlyAppliedPromotions(ctx, order, promotionsPre) {
449
- const newPromotionDiscounts = order.discounts
450
- .filter(discount => {
451
- const promotionId = adjustment_source_1.AdjustmentSource.decodeSourceId(discount.adjustmentSource).id;
452
- return !promotionsPre.find(p => (0, utils_1.idsAreEqual)(p.id, promotionId));
453
- })
454
- .filter(discount => {
455
- // Filter out any discounts that originate from ShippingLine discounts,
456
- // since they are already correctly accounted for in the refund calculation.
457
- for (const shippingLine of order.shippingLines) {
458
- if (shippingLine.discounts.find(shippingDiscount => shippingDiscount.adjustmentSource === discount.adjustmentSource)) {
459
- return false;
460
- }
461
- }
462
- return true;
463
- });
464
- if (newPromotionDiscounts.length) {
465
- return -(0, shared_utils_1.summate)(newPromotionDiscounts, 'amountWithTax');
466
- }
467
- return 0;
448
+ /**
449
+ * @description
450
+ * Because a Refund's amount is calculated based on the orderItems changed, plus shipping change,
451
+ * we need to make sure the amount gets adjusted to match any changes caused by other factors,
452
+ * i.e. promotions that were previously active but are no longer.
453
+ */
454
+ calculateRefundAdjustment(delta, refundInput) {
455
+ const existingAdjustment = refundInput.adjustment;
456
+ const itemAmount = (0, shared_utils_1.summate)(refundInput.orderItems, 'proratedUnitPriceWithTax');
457
+ const calculatedDelta = itemAmount + refundInput.shipping + existingAdjustment;
458
+ const absDelta = Math.abs(delta);
459
+ return absDelta !== calculatedDelta ? absDelta - calculatedDelta : 0;
468
460
  }
469
461
  getOrderPayments(ctx, orderId) {
470
462
  return this.connection.getRepository(ctx, payment_entity_1.Payment).find({