@vendure/core 3.1.0-next.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/populate.js +3 -1
- package/cli/populate.js.map +1 -1
- package/dist/api/common/request-context.d.ts +1 -1
- package/dist/api/common/request-context.js +1 -1
- package/dist/api/common/validate-custom-field-value.js +28 -0
- package/dist/api/common/validate-custom-field-value.js.map +1 -1
- package/dist/api/config/generate-active-order-types.js +2 -0
- package/dist/api/config/generate-active-order-types.js.map +1 -1
- package/dist/api/config/generate-resolvers.d.ts +10 -4
- package/dist/api/config/generate-resolvers.js +73 -7
- package/dist/api/config/generate-resolvers.js.map +1 -1
- package/dist/api/config/get-custom-fields-config-without-interfaces.d.ts +2 -0
- package/dist/api/config/get-custom-fields-config-without-interfaces.js +16 -11
- package/dist/api/config/get-custom-fields-config-without-interfaces.js.map +1 -1
- package/dist/api/config/graphql-custom-fields.js +116 -22
- package/dist/api/config/graphql-custom-fields.js.map +1 -1
- package/dist/api/resolvers/admin/draft-order.resolver.d.ts +3 -1
- package/dist/api/resolvers/admin/draft-order.resolver.js +26 -0
- package/dist/api/resolvers/admin/draft-order.resolver.js.map +1 -1
- package/dist/api/resolvers/admin/global-settings.resolver.d.ts +2 -0
- package/dist/api/resolvers/admin/global-settings.resolver.js +12 -0
- package/dist/api/resolvers/admin/global-settings.resolver.js.map +1 -1
- package/dist/api/resolvers/entity/order-line-entity.resolver.js +7 -3
- package/dist/api/resolvers/entity/order-line-entity.resolver.js.map +1 -1
- package/dist/api/resolvers/shop/shop-order.resolver.d.ts +2 -0
- package/dist/api/resolvers/shop/shop-order.resolver.js +38 -0
- package/dist/api/resolvers/shop/shop-order.resolver.js.map +1 -1
- package/dist/api/schema/admin-api/order.api.graphql +14 -12
- package/dist/api/schema/common/common-error-results.graphql +9 -0
- package/dist/api/schema/common/common-types.graphql +2 -1
- package/dist/api/schema/common/custom-field-types.graphql +99 -0
- package/dist/api/schema/shop-api/shop.api.graphql +30 -13
- package/dist/bootstrap.d.ts +56 -3
- package/dist/bootstrap.js +36 -6
- package/dist/bootstrap.js.map +1 -1
- package/dist/cache/cache-ttl-provider.d.ts +38 -0
- package/dist/cache/cache-ttl-provider.js +39 -0
- package/dist/cache/cache-ttl-provider.js.map +1 -0
- package/dist/cache/cache.d.ts +88 -0
- package/dist/cache/cache.js +79 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/cache.service.d.ts +15 -0
- package/dist/cache/cache.service.js +25 -0
- package/dist/cache/cache.service.js.map +1 -1
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.js +2 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/request-context-cache.service.d.ts +14 -0
- package/dist/cache/request-context-cache.service.js +9 -0
- package/dist/cache/request-context-cache.service.js.map +1 -1
- package/dist/common/error/generated-graphql-admin-errors.d.ts +9 -0
- package/dist/common/error/generated-graphql-admin-errors.js +12 -2
- package/dist/common/error/generated-graphql-admin-errors.js.map +1 -1
- package/dist/common/error/generated-graphql-shop-errors.d.ts +9 -0
- package/dist/common/error/generated-graphql-shop-errors.js +12 -2
- package/dist/common/error/generated-graphql-shop-errors.js.map +1 -1
- package/dist/common/ttl-cache.d.ts +3 -0
- package/dist/common/ttl-cache.js +3 -0
- package/dist/common/ttl-cache.js.map +1 -1
- package/dist/common/types/entity-relation-paths.d.ts +2 -1
- package/dist/common/utils.d.ts +1 -1
- package/dist/common/utils.js +1 -1
- package/dist/common/utils.js.map +1 -1
- package/dist/config/catalog/default-stock-location-strategy.d.ts +15 -8
- package/dist/config/catalog/default-stock-location-strategy.js +30 -22
- package/dist/config/catalog/default-stock-location-strategy.js.map +1 -1
- package/dist/config/catalog/multi-channel-stock-location-strategy.d.ts +55 -0
- package/dist/config/catalog/multi-channel-stock-location-strategy.js +144 -0
- package/dist/config/catalog/multi-channel-stock-location-strategy.js.map +1 -0
- package/dist/config/config.module.js +2 -1
- package/dist/config/config.module.js.map +1 -1
- package/dist/config/custom-field/custom-field-types.d.ts +69 -5
- package/dist/config/default-config.js +12 -4
- package/dist/config/default-config.js.map +1 -1
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +4 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/order/order-interceptor.d.ts +233 -0
- package/dist/config/order/order-interceptor.js +3 -0
- package/dist/config/order/order-interceptor.js.map +1 -0
- package/dist/config/promotion/conditions/customer-group-condition.js +17 -12
- package/dist/config/promotion/conditions/customer-group-condition.js.map +1 -1
- package/dist/config/session-cache/default-session-cache-strategy.d.ts +34 -0
- package/dist/config/session-cache/default-session-cache-strategy.js +63 -0
- package/dist/config/session-cache/default-session-cache-strategy.js.map +1 -0
- package/dist/config/session-cache/session-cache-strategy.d.ts +13 -4
- package/dist/config/shipping-method/shipping-eligibility-checker.d.ts +4 -2
- package/dist/config/shipping-method/shipping-eligibility-checker.js +8 -5
- package/dist/config/shipping-method/shipping-eligibility-checker.js.map +1 -1
- package/dist/config/system/cache-strategy.d.ts +12 -0
- package/dist/config/system/in-memory-cache-strategy.d.ts +8 -0
- package/dist/config/system/in-memory-cache-strategy.js +26 -3
- package/dist/config/system/in-memory-cache-strategy.js.map +1 -1
- package/dist/config/tax/address-based-tax-zone-strategy.d.ts +24 -0
- package/dist/config/tax/address-based-tax-zone-strategy.js +39 -0
- package/dist/config/tax/address-based-tax-zone-strategy.js.map +1 -0
- package/dist/config/vendure-config.d.ts +15 -6
- package/dist/data-import/providers/importer/importer.js +8 -0
- package/dist/data-import/providers/importer/importer.js.map +1 -1
- package/dist/data-import/providers/populator/populator.js +0 -1
- package/dist/data-import/providers/populator/populator.js.map +1 -1
- package/dist/entity/custom-entity-fields.d.ts +14 -0
- package/dist/entity/custom-entity-fields.js +22 -1
- package/dist/entity/custom-entity-fields.js.map +1 -1
- package/dist/entity/history-entry/history-entry.entity.d.ts +4 -1
- package/dist/entity/history-entry/history-entry.entity.js +5 -0
- package/dist/entity/history-entry/history-entry.entity.js.map +1 -1
- package/dist/entity/payment/payment.entity.d.ts +4 -1
- package/dist/entity/payment/payment.entity.js +5 -0
- package/dist/entity/payment/payment.entity.js.map +1 -1
- package/dist/entity/refund/refund.entity.d.ts +4 -1
- package/dist/entity/refund/refund.entity.js +5 -0
- package/dist/entity/refund/refund.entity.js.map +1 -1
- package/dist/entity/register-custom-entity-fields.js +17 -2
- package/dist/entity/register-custom-entity-fields.js.map +1 -1
- package/dist/entity/session/session.entity.d.ts +4 -1
- package/dist/entity/session/session.entity.js +5 -0
- package/dist/entity/session/session.entity.js.map +1 -1
- package/dist/entity/shipping-line/shipping-line.entity.d.ts +5 -2
- package/dist/entity/shipping-line/shipping-line.entity.js +7 -2
- package/dist/entity/shipping-line/shipping-line.entity.js.map +1 -1
- package/dist/entity/stock-level/stock-level.entity.d.ts +4 -1
- package/dist/entity/stock-level/stock-level.entity.js +5 -0
- package/dist/entity/stock-level/stock-level.entity.js.map +1 -1
- package/dist/entity/stock-movement/stock-movement.entity.d.ts +4 -1
- package/dist/entity/stock-movement/stock-movement.entity.js +5 -0
- package/dist/entity/stock-movement/stock-movement.entity.js.map +1 -1
- package/dist/event-bus/events/stock-location-event.d.ts +18 -0
- package/dist/event-bus/events/stock-location-event.js +19 -0
- package/dist/event-bus/events/stock-location-event.js.map +1 -0
- package/dist/event-bus/index.d.ts +1 -0
- package/dist/event-bus/index.js +1 -0
- package/dist/event-bus/index.js.map +1 -1
- package/dist/i18n/messages/de.json +1 -0
- package/dist/i18n/messages/en.json +2 -0
- package/dist/plugin/default-cache-plugin/cache-item.entity.d.ts +1 -0
- package/dist/plugin/default-cache-plugin/cache-item.entity.js +4 -0
- package/dist/plugin/default-cache-plugin/cache-item.entity.js.map +1 -1
- package/dist/plugin/default-cache-plugin/cache-tag.entity.d.ts +9 -0
- package/dist/plugin/default-cache-plugin/cache-tag.entity.js +41 -0
- package/dist/plugin/default-cache-plugin/cache-tag.entity.js.map +1 -0
- package/dist/plugin/default-cache-plugin/default-cache-plugin.d.ts +21 -0
- package/dist/plugin/default-cache-plugin/default-cache-plugin.js +13 -1
- package/dist/plugin/default-cache-plugin/default-cache-plugin.js.map +1 -1
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.d.ts +7 -6
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.js +57 -13
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.js.map +1 -1
- package/dist/plugin/default-search-plugin/default-search-plugin.js +4 -0
- package/dist/plugin/default-search-plugin/default-search-plugin.js.map +1 -1
- package/dist/plugin/default-search-plugin/indexer/indexer.controller.js +1 -0
- package/dist/plugin/default-search-plugin/indexer/indexer.controller.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +3 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/redis-cache-plugin/constants.d.ts +4 -0
- package/dist/plugin/redis-cache-plugin/constants.js +8 -0
- package/dist/plugin/redis-cache-plugin/constants.js.map +1 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-plugin.d.ts +14 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-plugin.js +47 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-plugin.js.map +1 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-strategy.d.ts +24 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-strategy.js +104 -0
- package/dist/plugin/redis-cache-plugin/redis-cache-strategy.js.map +1 -0
- package/dist/plugin/redis-cache-plugin/types.d.ts +12 -0
- package/dist/plugin/redis-cache-plugin/types.js +3 -0
- package/dist/plugin/redis-cache-plugin/types.js.map +1 -0
- package/dist/plugin/vendure-plugin.d.ts +5 -0
- package/dist/plugin/vendure-plugin.js.map +1 -1
- package/dist/service/helpers/external-authentication/external-authentication.service.d.ts +1 -1
- package/dist/service/helpers/external-authentication/external-authentication.service.js +1 -1
- package/dist/service/helpers/facet-value-checker/facet-value-checker.d.ts +3 -4
- package/dist/service/helpers/facet-value-checker/facet-value-checker.js +11 -17
- package/dist/service/helpers/facet-value-checker/facet-value-checker.js.map +1 -1
- package/dist/service/helpers/order-modifier/order-modifier.js +14 -6
- package/dist/service/helpers/order-modifier/order-modifier.js.map +1 -1
- package/dist/service/helpers/utils/tree-relations-qb-joiner.js +1 -1
- package/dist/service/helpers/utils/tree-relations-qb-joiner.js.map +1 -1
- package/dist/service/services/channel.service.js +5 -0
- package/dist/service/services/channel.service.js.map +1 -1
- package/dist/service/services/order.service.d.ts +71 -1
- package/dist/service/services/order.service.js +270 -83
- package/dist/service/services/order.service.js.map +1 -1
- package/dist/service/services/payment.service.js +6 -4
- package/dist/service/services/payment.service.js.map +1 -1
- package/dist/service/services/product-variant.service.js +1 -1
- package/dist/service/services/product-variant.service.js.map +1 -1
- package/dist/service/services/promotion.service.js +1 -0
- package/dist/service/services/promotion.service.js.map +1 -1
- package/dist/service/services/role.service.js +6 -5
- package/dist/service/services/role.service.js.map +1 -1
- package/dist/service/services/stock-location.service.d.ts +3 -1
- package/dist/service/services/stock-location.service.js +9 -2
- package/dist/service/services/stock-location.service.js.map +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-config.js","sourceRoot":"","sources":["../../src/config/default-config.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,2EAK8C;AAC9C,mCAAqC;AAErC,iGAA2F;AAC3F,4FAAqF;AACrF,yHAAiH;AAEjH,yGAAmG;AACnG,yGAAmG;AACnG,kGAA4F;AAC5F,kGAA4F;AAC5F,8FAAwF;AACxF,sGAAgG;AAChG,0FAAqF;AACrF,qFAAgF;AAChF,qIAA6H;AAC7H,iIAAyH;AACzH,2HAAmH;AACnH,6FAAuF;
|
|
1
|
+
{"version":3,"file":"default-config.js","sourceRoot":"","sources":["../../src/config/default-config.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,2EAK8C;AAC9C,mCAAqC;AAErC,iGAA2F;AAC3F,4FAAqF;AACrF,yHAAiH;AAEjH,yGAAmG;AACnG,yGAAmG;AACnG,k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;QACX,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,EAAE;QAClB,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,EAAE;QACjB,aAAa,EAAE,EAAE;QACjB,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;KACX;IACD,OAAO,EAAE,EAAE;IACX,aAAa,EAAE;QACX,aAAa,EAAE,IAAI,gDAAqB,CAAC,EAAE,SAAS,EAAE,KAAM,EAAE,CAAC;QAC/D,YAAY,EAAE,CAAC,IAAI,0DAA0B,EAAE,CAAC;QAChD,aAAa,EAAE,EAAE;KACpB;CACJ,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './catalog/default-product-variant-price-selection-strategy';
|
|
|
15
15
|
export * from './catalog/default-product-variant-price-update-strategy';
|
|
16
16
|
export * from './catalog/default-stock-display-strategy';
|
|
17
17
|
export * from './catalog/default-stock-location-strategy';
|
|
18
|
+
export * from './catalog/multi-channel-stock-location-strategy';
|
|
18
19
|
export * from './catalog/product-variant-price-calculation-strategy';
|
|
19
20
|
export * from './catalog/product-variant-price-selection-strategy';
|
|
20
21
|
export * from './catalog/product-variant-price-update-strategy';
|
|
@@ -57,6 +58,7 @@ export * from './order/guest-checkout-strategy';
|
|
|
57
58
|
export * from './order/merge-orders-strategy';
|
|
58
59
|
export * from './order/order-by-code-access-strategy';
|
|
59
60
|
export * from './order/order-code-strategy';
|
|
61
|
+
export * from './order/order-interceptor';
|
|
60
62
|
export * from './order/order-item-price-calculation-strategy';
|
|
61
63
|
export * from './order/order-merge-strategy';
|
|
62
64
|
export * from './order/order-placed-strategy';
|
|
@@ -73,6 +75,7 @@ export * from './payment/payment-method-eligibility-checker';
|
|
|
73
75
|
export * from './payment/payment-method-handler';
|
|
74
76
|
export * from './payment/payment-process';
|
|
75
77
|
export * from './promotion';
|
|
78
|
+
export * from './session-cache/default-session-cache-strategy';
|
|
76
79
|
export * from './session-cache/in-memory-session-cache-strategy';
|
|
77
80
|
export * from './session-cache/noop-session-cache-strategy';
|
|
78
81
|
export * from './session-cache/session-cache-strategy';
|
|
@@ -86,6 +89,7 @@ export * from './system/health-check-strategy';
|
|
|
86
89
|
export * from './system/error-handler-strategy';
|
|
87
90
|
export * from './tax/default-tax-line-calculation-strategy';
|
|
88
91
|
export * from './tax/default-tax-zone-strategy';
|
|
92
|
+
export * from './tax/address-based-tax-zone-strategy';
|
|
89
93
|
export * from './tax/tax-line-calculation-strategy';
|
|
90
94
|
export * from './tax/tax-zone-strategy';
|
|
91
95
|
export * from './vendure-config';
|
package/dist/config/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./catalog/default-product-variant-price-selection-strategy
|
|
|
31
31
|
__exportStar(require("./catalog/default-product-variant-price-update-strategy"), exports);
|
|
32
32
|
__exportStar(require("./catalog/default-stock-display-strategy"), exports);
|
|
33
33
|
__exportStar(require("./catalog/default-stock-location-strategy"), exports);
|
|
34
|
+
__exportStar(require("./catalog/multi-channel-stock-location-strategy"), exports);
|
|
34
35
|
__exportStar(require("./catalog/product-variant-price-calculation-strategy"), exports);
|
|
35
36
|
__exportStar(require("./catalog/product-variant-price-selection-strategy"), exports);
|
|
36
37
|
__exportStar(require("./catalog/product-variant-price-update-strategy"), exports);
|
|
@@ -73,6 +74,7 @@ __exportStar(require("./order/guest-checkout-strategy"), exports);
|
|
|
73
74
|
__exportStar(require("./order/merge-orders-strategy"), exports);
|
|
74
75
|
__exportStar(require("./order/order-by-code-access-strategy"), exports);
|
|
75
76
|
__exportStar(require("./order/order-code-strategy"), exports);
|
|
77
|
+
__exportStar(require("./order/order-interceptor"), exports);
|
|
76
78
|
__exportStar(require("./order/order-item-price-calculation-strategy"), exports);
|
|
77
79
|
__exportStar(require("./order/order-merge-strategy"), exports);
|
|
78
80
|
__exportStar(require("./order/order-placed-strategy"), exports);
|
|
@@ -89,6 +91,7 @@ __exportStar(require("./payment/payment-method-eligibility-checker"), exports);
|
|
|
89
91
|
__exportStar(require("./payment/payment-method-handler"), exports);
|
|
90
92
|
__exportStar(require("./payment/payment-process"), exports);
|
|
91
93
|
__exportStar(require("./promotion"), exports);
|
|
94
|
+
__exportStar(require("./session-cache/default-session-cache-strategy"), exports);
|
|
92
95
|
__exportStar(require("./session-cache/in-memory-session-cache-strategy"), exports);
|
|
93
96
|
__exportStar(require("./session-cache/noop-session-cache-strategy"), exports);
|
|
94
97
|
__exportStar(require("./session-cache/session-cache-strategy"), exports);
|
|
@@ -102,6 +105,7 @@ __exportStar(require("./system/health-check-strategy"), exports);
|
|
|
102
105
|
__exportStar(require("./system/error-handler-strategy"), exports);
|
|
103
106
|
__exportStar(require("./tax/default-tax-line-calculation-strategy"), exports);
|
|
104
107
|
__exportStar(require("./tax/default-tax-zone-strategy"), exports);
|
|
108
|
+
__exportStar(require("./tax/address-based-tax-zone-strategy"), exports);
|
|
105
109
|
__exportStar(require("./tax/tax-line-calculation-strategy"), exports);
|
|
106
110
|
__exportStar(require("./tax/tax-zone-strategy"), exports);
|
|
107
111
|
__exportStar(require("./vendure-config"), exports);
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gFAA8D;AAC9D,gFAA8D;AAC9D,wFAAsE;AACtE,kFAAgE;AAChE,kFAAgE;AAChE,iEAA+C;AAC/C,0EAAwD;AACxD,8EAA4D;AAC5D,wEAAsD;AACtD,mEAAiD;AACjD,sEAAoD;AACpD,8DAA4C;AAC5C,uEAAqD;AACrD,6FAA2E;AAC3E,0FAAwE;AACxE,2EAAyD;AACzD,4EAA0D;AAC1D,uFAAqE;AACrE,qFAAmE;AACnE,kFAAgE;AAChE,mEAAiD;AACjD,oEAAkD;AAClD,kDAAgC;AAChC,mDAAiC;AACjC,mDAAiC;AACjC,oEAAkD;AAClD,mDAAiC;AACjC,sEAAoD;AACpD,kEAAgD;AAChD,6DAA2C;AAC3C,oEAAkD;AAClD,iEAA+C;AAC/C,8DAA4C;AAC5C,0DAAwC;AACxC,4DAA0C;AAC1C,6EAA2D;AAC3D,4EAA0D;AAC1D,oEAAkD;AAClD,oEAAkD;AAClD,2EAAyD;AACzD,6EAA2D;AAC3D,iEAA+C;AAC/C,0DAAwC;AACxC,uDAAqC;AACrC,0DAAwC;AACxC,iDAA+B;AAC/B,gEAA8C;AAC9C,0EAAwD;AACxD,wEAAsD;AACtD,kFAAgE;AAChE,wEAAsD;AACtD,gEAA8C;AAC9C,wEAAsD;AACtD,4EAA0D;AAC1D,0EAAwD;AACxD,kEAAgD;AAChD,gEAA8C;AAC9C,wEAAsD;AACtD,8DAA4C;AAC5C,gFAA8D;AAC9D,+DAA6C;AAC7C,gEAA8C;AAC9C,wDAAsC;AACtC,gEAA8C;AAC9C,oEAAkD;AAClD,gEAA8C;AAC9C,+EAA6D;AAC7D,6DAA2C;AAC3C,oEAAkD;AAClD,yEAAuD;AACvD,2EAAyD;AACzD,+EAA6D;AAC7D,mEAAiD;AACjD,4DAA0C;AAC1C,8CAA4B;AAC5B,mFAAiE;AACjE,8EAA4D;AAC5D,yEAAuD;AACvD,gFAA8D;AAC9D,yFAAuE;AACvE,8FAA4E;AAC5E,wEAAsD;AACtD,iFAA+D;AAC/D,sFAAoE;AACpE,iEAA+C;AAC/C,kEAAgD;AAChD,8EAA4D;AAC5D,kEAAgD;AAChD,sEAAoD;AACpD,0DAAwC;AACxC,mDAAiC;AACjC,kEAAgD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gFAA8D;AAC9D,gFAA8D;AAC9D,wFAAsE;AACtE,kFAAgE;AAChE,kFAAgE;AAChE,iEAA+C;AAC/C,0EAAwD;AACxD,8EAA4D;AAC5D,wEAAsD;AACtD,mEAAiD;AACjD,sEAAoD;AAC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AAwC;AACxC,mDAAiC;AACjC,kEAAgD"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { RequestContext } from '../../api/common/request-context';
|
|
2
|
+
import { InjectableStrategy } from '../../common/types/injectable-strategy';
|
|
3
|
+
import { CustomOrderLineFields, Order, OrderLine, ProductVariant } from '../../entity/index';
|
|
4
|
+
export interface WillAddItemToOrderInput {
|
|
5
|
+
productVariant: ProductVariant;
|
|
6
|
+
quantity: number;
|
|
7
|
+
customFields?: CustomOrderLineFields;
|
|
8
|
+
}
|
|
9
|
+
export interface WillAdjustOrderLineInput {
|
|
10
|
+
orderLine: OrderLine;
|
|
11
|
+
quantity: number;
|
|
12
|
+
customFields?: CustomOrderLineFields;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @description
|
|
16
|
+
* An OrderInterceptor is a class which can be used to intercept and modify the behavior of order-related
|
|
17
|
+
* operations.
|
|
18
|
+
*
|
|
19
|
+
* It does this by providing methods which are called whenever the contents of an order are about
|
|
20
|
+
* to get changed. These methods are able to prevent the operation from proceeding by returning a string
|
|
21
|
+
* error message.
|
|
22
|
+
*
|
|
23
|
+
* Examples of use-cases for an OrderInterceptor include:
|
|
24
|
+
*
|
|
25
|
+
* * Preventing certain products from being added to the order based on some criteria, e.g. if the
|
|
26
|
+
* product is already in another active order.
|
|
27
|
+
* * Enforcing a minimum or maximum quantity of a given product in the order
|
|
28
|
+
* * Using a CAPTCHA to prevent automated order creation
|
|
29
|
+
*
|
|
30
|
+
* :::info
|
|
31
|
+
*
|
|
32
|
+
* This is configured via the `orderOptions.orderInterceptors` property of
|
|
33
|
+
* your VendureConfig.
|
|
34
|
+
*
|
|
35
|
+
* :::
|
|
36
|
+
*
|
|
37
|
+
* OrderInterceptors are executed when the following mutations are called:
|
|
38
|
+
*
|
|
39
|
+
* - `addItemToOrder`
|
|
40
|
+
* - `adjustOrderLine`
|
|
41
|
+
* - `removeItemFromOrder`
|
|
42
|
+
*
|
|
43
|
+
* Additionally, if you are working directly with the {@link OrderService}, the following methods will trigger
|
|
44
|
+
* any registered OrderInterceptors:
|
|
45
|
+
*
|
|
46
|
+
* - `addItemToOrder`
|
|
47
|
+
* - `addItemsToOrder`
|
|
48
|
+
* - `adjustOrderLine`
|
|
49
|
+
* - `adjustOrderLines`
|
|
50
|
+
* - `removeItemFromOrder`
|
|
51
|
+
* - `removeItemsFromOrder`
|
|
52
|
+
*
|
|
53
|
+
* When an OrderInterceptor is registered, it will be called in the order in which it was registered.
|
|
54
|
+
* If an interceptor method resolves to a string, the operation will be prevented and the string will be used as the error message.
|
|
55
|
+
*
|
|
56
|
+
* When multiple interceptors are registered, the first interceptor to resolve to a string will prevent the operation from proceeding.
|
|
57
|
+
*
|
|
58
|
+
* Errors returned by OrderInterceptors are surfaced to the GraphQL API as an `OrderInterceptorError` and can be
|
|
59
|
+
* queried like this:
|
|
60
|
+
*
|
|
61
|
+
* ```graphql
|
|
62
|
+
* mutation AddItemToOrder($productVariantId: ID!, $quantity: Int!) {
|
|
63
|
+
* addItemToOrder(productVariantId: $productVariantId, quantity: $quantity) {
|
|
64
|
+
* ... on Order {
|
|
65
|
+
* id
|
|
66
|
+
* code
|
|
67
|
+
* # ... other Order fields
|
|
68
|
+
* }
|
|
69
|
+
* ... on ErrorResult {
|
|
70
|
+
* errorCode
|
|
71
|
+
* message
|
|
72
|
+
* }
|
|
73
|
+
* // highlight-start
|
|
74
|
+
* ... on OrderInterceptorError {
|
|
75
|
+
* interceptorError
|
|
76
|
+
* }
|
|
77
|
+
* // highlight-end
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* In the above example, the error message returned by the OrderInterceptor would be available in the `interceptorError` field.
|
|
83
|
+
*
|
|
84
|
+
* ## Example: Min/max order quantity
|
|
85
|
+
*
|
|
86
|
+
* Let's say we want to allow ProductVariants to specify the minimum or maximum amount which may be added
|
|
87
|
+
* to an order. We can define custom fields to store this information and
|
|
88
|
+
* then use this custom field value to prevent an order line from being added to the order if the quantity
|
|
89
|
+
* is below the minimum.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import {
|
|
94
|
+
* EntityHydrator,
|
|
95
|
+
* Injector,
|
|
96
|
+
* LanguageCode,
|
|
97
|
+
* Order,
|
|
98
|
+
* OrderInterceptor,
|
|
99
|
+
* ProductVariant,
|
|
100
|
+
* RequestContext,
|
|
101
|
+
* TranslatorService,
|
|
102
|
+
* VendurePlugin,
|
|
103
|
+
* WillAddItemToOrderInput,
|
|
104
|
+
* WillAdjustOrderLineInput,
|
|
105
|
+
* } from '\@vendure/core';
|
|
106
|
+
*
|
|
107
|
+
* declare module '\@vendure/core/dist/entity/custom-entity-fields' {
|
|
108
|
+
* interface CustomProductVariantFields {
|
|
109
|
+
* minOrderQuantity?: number;
|
|
110
|
+
* maxOrderQuantity?: number;
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* // This OrderInterceptor enforces minimum and maximum order quantities on ProductVariants.
|
|
115
|
+
* export class MinMaxOrderInterceptor implements OrderInterceptor {
|
|
116
|
+
* private entityHydrator: EntityHydrator;
|
|
117
|
+
* private translatorService: TranslatorService;
|
|
118
|
+
*
|
|
119
|
+
* init(injector: Injector) {
|
|
120
|
+
* this.entityHydrator = injector.get(EntityHydrator);
|
|
121
|
+
* this.translatorService = injector.get(TranslatorService);
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* willAddItemToOrder(
|
|
125
|
+
* ctx: RequestContext,
|
|
126
|
+
* order: Order,
|
|
127
|
+
* input: WillAddItemToOrderInput,
|
|
128
|
+
* ): Promise<void | string> | void | string {
|
|
129
|
+
* const { productVariant, quantity } = input;
|
|
130
|
+
* const min = productVariant.customFields?.minOrderQuantity;
|
|
131
|
+
* const max = productVariant.customFields?.maxOrderQuantity;
|
|
132
|
+
* if (min && quantity < min) {
|
|
133
|
+
* return this.minErrorMessage(ctx, productVariant, min);
|
|
134
|
+
* }
|
|
135
|
+
* if (max && quantity > max) {
|
|
136
|
+
* return this.maxErrorMessage(ctx, productVariant, max);
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
*
|
|
140
|
+
* willAdjustOrderLine(
|
|
141
|
+
* ctx: RequestContext,
|
|
142
|
+
* order: Order,
|
|
143
|
+
* input: WillAdjustOrderLineInput,
|
|
144
|
+
* ): Promise<void | string> | void | string {
|
|
145
|
+
* const { orderLine, quantity } = input;
|
|
146
|
+
* const min = orderLine.productVariant.customFields?.minOrderQuantity;
|
|
147
|
+
* const max = orderLine.productVariant.customFields?.maxOrderQuantity;
|
|
148
|
+
* if (min && quantity < min) {
|
|
149
|
+
* return this.minErrorMessage(ctx, orderLine.productVariant, min);
|
|
150
|
+
* }
|
|
151
|
+
* if (max && quantity > max) {
|
|
152
|
+
* return this.maxErrorMessage(ctx, orderLine.productVariant, max);
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
*
|
|
156
|
+
* private async minErrorMessage(ctx: RequestContext, variant: ProductVariant, min: number) {
|
|
157
|
+
* const variantName = await this.getTranslatedVariantName(ctx, variant);
|
|
158
|
+
* return `Minimum order quantity for "${variantName}" is ${min}`;
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* private async maxErrorMessage(ctx: RequestContext, variant: ProductVariant, max: number) {
|
|
162
|
+
* const variantName = await this.getTranslatedVariantName(ctx, variant);
|
|
163
|
+
* return `Maximum order quantity for "${variantName}" is ${max}`;
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* private async getTranslatedVariantName(ctx: RequestContext, variant: ProductVariant) {
|
|
167
|
+
* await this.entityHydrator.hydrate(ctx, variant, { relations: ['translations'] });
|
|
168
|
+
* const translated = this.translatorService.translate(variant, ctx);
|
|
169
|
+
* return translated.name;
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
172
|
+
*
|
|
173
|
+
* // This plugin enforces minimum and maximum order quantities on ProductVariants.
|
|
174
|
+
* // It adds two new custom fields to ProductVariant:
|
|
175
|
+
* // - minOrderQuantity
|
|
176
|
+
* // - maxOrderQuantity
|
|
177
|
+
* //
|
|
178
|
+
* // It also adds an OrderInterceptor which enforces these limits.
|
|
179
|
+
* \@VendurePlugin({
|
|
180
|
+
* configuration: config => {
|
|
181
|
+
* // Here we add the custom fields to the ProductVariant entity
|
|
182
|
+
* config.customFields.ProductVariant.push({
|
|
183
|
+
* type: 'int',
|
|
184
|
+
* min: 0,
|
|
185
|
+
* name: 'minOrderQuantity',
|
|
186
|
+
* label: [{ languageCode: LanguageCode.en, value: 'Minimum order quantity' }],
|
|
187
|
+
* nullable: true,
|
|
188
|
+
* });
|
|
189
|
+
* config.customFields.ProductVariant.push({
|
|
190
|
+
* type: 'int',
|
|
191
|
+
* min: 0,
|
|
192
|
+
* name: 'maxOrderQuantity',
|
|
193
|
+
* label: [{ languageCode: LanguageCode.en, value: 'Maximum order quantity' }],
|
|
194
|
+
* nullable: true,
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* // Here we add the MinMaxOrderInterceptor to the orderInterceptors array
|
|
198
|
+
* config.orderOptions.orderInterceptors.push(new MinMaxOrderInterceptor());
|
|
199
|
+
* return config;
|
|
200
|
+
* },
|
|
201
|
+
* })
|
|
202
|
+
* export class OrderQuantityLimitsPlugin {}
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
*
|
|
206
|
+
* @docsCategory orders
|
|
207
|
+
* @docsPage OrderInterceptor
|
|
208
|
+
* @docsWeight 0
|
|
209
|
+
* @since 3.1.0
|
|
210
|
+
*/
|
|
211
|
+
export interface OrderInterceptor extends InjectableStrategy {
|
|
212
|
+
/**
|
|
213
|
+
* @description
|
|
214
|
+
* Called when a new item is about to be added to the order,
|
|
215
|
+
* as in the `addItemToOrder` mutation or the `addItemToOrder()` / `addItemsToOrder()` method
|
|
216
|
+
* of the {@link OrderService}.
|
|
217
|
+
*/
|
|
218
|
+
willAddItemToOrder?(ctx: RequestContext, order: Order, input: WillAddItemToOrderInput): Promise<void | string> | void | string;
|
|
219
|
+
/**
|
|
220
|
+
* @description
|
|
221
|
+
* Called when an existing order line is about to be adjusted,
|
|
222
|
+
* as in the `adjustOrderLine` mutation or the `adjustOrderLine()` / `adjustOrderLines()` method
|
|
223
|
+
* of the {@link OrderService}.
|
|
224
|
+
*/
|
|
225
|
+
willAdjustOrderLine?(ctx: RequestContext, order: Order, input: WillAdjustOrderLineInput): Promise<void | string> | void | string;
|
|
226
|
+
/**
|
|
227
|
+
* @description
|
|
228
|
+
* Called when an item is about to be removed from the order,
|
|
229
|
+
* as in the `removeItemFromOrder` mutation or the `removeItemFromOrder()` / `removeItemsFromOrder()` method
|
|
230
|
+
* of the {@link OrderService}.
|
|
231
|
+
*/
|
|
232
|
+
willRemoveItemFromOrder?(ctx: RequestContext, order: Order, orderLine: OrderLine): Promise<void | string> | void | string;
|
|
233
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-interceptor.js","sourceRoot":"","sources":["../../../src/config/order/order-interceptor.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.customerGroup = void 0;
|
|
4
7
|
const generated_types_1 = require("@vendure/common/lib/generated-types");
|
|
5
|
-
const
|
|
8
|
+
const ms_1 = __importDefault(require("ms"));
|
|
6
9
|
const utils_1 = require("../../../common/utils");
|
|
7
10
|
const event_bus_1 = require("../../../event-bus/event-bus");
|
|
8
11
|
const customer_group_change_event_1 = require("../../../event-bus/events/customer-group-change-event");
|
|
9
12
|
const promotion_condition_1 = require("../promotion-condition");
|
|
10
13
|
let customerService;
|
|
14
|
+
let cacheService;
|
|
11
15
|
let subscription;
|
|
12
|
-
|
|
13
|
-
const cache = new ttl_cache_1.TtlCache({ ttl: fiveMinutes });
|
|
16
|
+
let groupIdCache;
|
|
14
17
|
exports.customerGroup = new promotion_condition_1.PromotionCondition({
|
|
15
18
|
code: 'customer_group',
|
|
16
19
|
description: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Customer is a member of the specified group' }],
|
|
@@ -24,16 +27,20 @@ exports.customerGroup = new promotion_condition_1.PromotionCondition({
|
|
|
24
27
|
async init(injector) {
|
|
25
28
|
// Lazily-imported to avoid circular dependency issues.
|
|
26
29
|
const { CustomerService } = await import('../../../service/services/customer.service.js');
|
|
30
|
+
const { CacheService } = await import('../../../cache/cache.service.js');
|
|
27
31
|
customerService = injector.get(CustomerService);
|
|
32
|
+
cacheService = injector.get(CacheService);
|
|
33
|
+
groupIdCache = cacheService.createCache({
|
|
34
|
+
getKey: id => `PromotionCondition:customer_group:${id}`,
|
|
35
|
+
options: { ttl: (0, ms_1.default)('1 week') },
|
|
36
|
+
});
|
|
28
37
|
subscription = injector
|
|
29
38
|
.get(event_bus_1.EventBus)
|
|
30
39
|
.ofType(customer_group_change_event_1.CustomerGroupChangeEvent)
|
|
31
|
-
.subscribe(event => {
|
|
40
|
+
.subscribe(async (event) => {
|
|
32
41
|
// When a customer is added to or removed from a group, we need
|
|
33
42
|
// to invalidate the cache for that customer id
|
|
34
|
-
|
|
35
|
-
cache.delete(customer.id);
|
|
36
|
-
}
|
|
43
|
+
await groupIdCache.delete(event.customers.map(c => c.id));
|
|
37
44
|
});
|
|
38
45
|
},
|
|
39
46
|
destroy() {
|
|
@@ -44,12 +51,10 @@ exports.customerGroup = new promotion_condition_1.PromotionCondition({
|
|
|
44
51
|
return false;
|
|
45
52
|
}
|
|
46
53
|
const customerId = order.customer.id;
|
|
47
|
-
|
|
48
|
-
if (!groupIds) {
|
|
54
|
+
const groupIds = await groupIdCache.get(customerId, async () => {
|
|
49
55
|
const groups = await customerService.getCustomerGroups(ctx, customerId);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
56
|
+
return groups.map(g => g.id);
|
|
57
|
+
});
|
|
53
58
|
return !!groupIds.find(id => (0, utils_1.idsAreEqual)(id, args.customerGroupId));
|
|
54
59
|
},
|
|
55
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer-group-condition.js","sourceRoot":"","sources":["../../../../src/config/promotion/conditions/customer-group-condition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customer-group-condition.js","sourceRoot":"","sources":["../../../../src/config/promotion/conditions/customer-group-condition.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAmE;AACnE,4CAAoB;AAIpB,iDAAoD;AACpD,4DAAwD;AACxD,uGAAiG;AACjG,gEAA4D;AAE5D,IAAI,eAAqF,CAAC;AAC1F,IAAI,YAAiE,CAAC;AACtE,IAAI,YAAsC,CAAC;AAE3C,IAAI,YAAmB,CAAC;AAEX,QAAA,aAAa,GAAG,IAAI,wCAAkB,CAAC;IAChD,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,8BAAY,CAAC,EAAE,EAAE,KAAK,EAAE,6CAA6C,EAAE,CAAC;IACtG,IAAI,EAAE;QACF,eAAe,EAAE;YACb,IAAI,EAAE,IAAI;YACV,EAAE,EAAE,EAAE,SAAS,EAAE,2BAA2B,EAAE;YAC9C,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,8BAAY,CAAC,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;SACtE;KACJ;IACD,KAAK,CAAC,IAAI,CAAC,QAAQ;QACf,uDAAuD;QACvD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,+CAA+C,CAAC,CAAC;QAC1F,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,iCAAiC,CAAC,CAAC;QACzE,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAe,CA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AAE,CAAC,EAAE,CAAC,IAAA,mBAAW,EAAC,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IACxE,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CacheService } from '../../cache/index';
|
|
2
|
+
import { Injector } from '../../common/injector';
|
|
3
|
+
import { CachedSession, SessionCacheStrategy } from './session-cache-strategy';
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* The default {@link SessionCacheStrategy} delegates to the configured
|
|
7
|
+
* {@link CacheStrategy} to store the session data. This should be suitable
|
|
8
|
+
* for most use-cases, assuming you select a suitable {@link CacheStrategy}
|
|
9
|
+
*
|
|
10
|
+
* @since 3.1.0
|
|
11
|
+
* @docsCategory auth
|
|
12
|
+
*/
|
|
13
|
+
export declare class DefaultSessionCacheStrategy implements SessionCacheStrategy {
|
|
14
|
+
private options?;
|
|
15
|
+
protected cacheService: CacheService;
|
|
16
|
+
private readonly tags;
|
|
17
|
+
constructor(options?: {
|
|
18
|
+
ttl?: number | undefined;
|
|
19
|
+
cachePrefix?: string | undefined;
|
|
20
|
+
} | undefined);
|
|
21
|
+
init(injector: Injector): void;
|
|
22
|
+
set(session: CachedSession): Promise<void>;
|
|
23
|
+
get(sessionToken: string): Promise<CachedSession | undefined>;
|
|
24
|
+
delete(sessionToken: string): void | Promise<void>;
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* The `CachedSession` interface includes a `Date` object, which we need to
|
|
29
|
+
* manually serialize/deserialize to/from JSON.
|
|
30
|
+
*/
|
|
31
|
+
private serializeDates;
|
|
32
|
+
private deserializeDates;
|
|
33
|
+
private getCacheKey;
|
|
34
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultSessionCacheStrategy = void 0;
|
|
4
|
+
const index_1 = require("../../cache/index");
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* The default {@link SessionCacheStrategy} delegates to the configured
|
|
8
|
+
* {@link CacheStrategy} to store the session data. This should be suitable
|
|
9
|
+
* for most use-cases, assuming you select a suitable {@link CacheStrategy}
|
|
10
|
+
*
|
|
11
|
+
* @since 3.1.0
|
|
12
|
+
* @docsCategory auth
|
|
13
|
+
*/
|
|
14
|
+
class DefaultSessionCacheStrategy {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.tags = ['DefaultSessionCacheStrategy'];
|
|
18
|
+
}
|
|
19
|
+
init(injector) {
|
|
20
|
+
this.cacheService = injector.get(index_1.CacheService);
|
|
21
|
+
}
|
|
22
|
+
set(session) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return this.cacheService.set(this.getCacheKey(session.token), this.serializeDates(session), {
|
|
25
|
+
tags: this.tags,
|
|
26
|
+
ttl: (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.ttl) !== null && _b !== void 0 ? _b : 24 * 60 * 60 * 1000,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async get(sessionToken) {
|
|
30
|
+
const cacheKey = this.getCacheKey(sessionToken);
|
|
31
|
+
const item = await this.cacheService.get(cacheKey);
|
|
32
|
+
return item ? this.deserializeDates(item) : undefined;
|
|
33
|
+
}
|
|
34
|
+
delete(sessionToken) {
|
|
35
|
+
return this.cacheService.delete(this.getCacheKey(sessionToken));
|
|
36
|
+
}
|
|
37
|
+
clear() {
|
|
38
|
+
var _a;
|
|
39
|
+
// We use the `?` here because there is a case where in the SessionService,
|
|
40
|
+
// the clearSessionCacheOnDataChange() method may be invoked during bootstrap prior to
|
|
41
|
+
// the cacheService being initialized in the `init()` method above.
|
|
42
|
+
// This is an edge-case limited to seeding initial data as in e2e tests or a
|
|
43
|
+
// @vendure/create installation, so it is safe to not invalidate the cache in this case.
|
|
44
|
+
return (_a = this.cacheService) === null || _a === void 0 ? void 0 : _a.invalidateTags(this.tags);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* The `CachedSession` interface includes a `Date` object, which we need to
|
|
49
|
+
* manually serialize/deserialize to/from JSON.
|
|
50
|
+
*/
|
|
51
|
+
serializeDates(session) {
|
|
52
|
+
return Object.assign(Object.assign({}, session), { expires: session.expires.toISOString() });
|
|
53
|
+
}
|
|
54
|
+
deserializeDates(session) {
|
|
55
|
+
return Object.assign(Object.assign({}, session), { expires: new Date(session.expires) });
|
|
56
|
+
}
|
|
57
|
+
getCacheKey(sessionToken) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
return `${(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.cachePrefix) !== null && _b !== void 0 ? _b : 'vendure-session-cache'}:${sessionToken}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DefaultSessionCacheStrategy = DefaultSessionCacheStrategy;
|
|
63
|
+
//# sourceMappingURL=default-session-cache-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-session-cache-strategy.js","sourceRoot":"","sources":["../../../src/config/session-cache/default-session-cache-strategy.ts"],"names":[],"mappings":";;;AAEA,6CAAiD;AAKjD;;;;;;;;GAQG;AACH,MAAa,2BAA2B;IAIpC,YACY,OAGP;QAHO,YAAO,GAAP,OAAO,CAGd;QANY,SAAI,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAOrD,CAAC;IAEJ,IAAI,CAAC,QAAkB;QACnB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;IACnD,CAAC;IAED,GAAG,CAAC,OAAsB;;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YACxF,IAAI,EA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 export type CachedSession = {
|
|
|
46
46
|
* SQL query each time. Therefore, we cache the session data only perform the SQL query once and upon
|
|
47
47
|
* invalidation of the cache.
|
|
48
48
|
*
|
|
49
|
-
* The Vendure default is to use a the {@link
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* The Vendure default from v3.1+ is to use a the {@link DefaultSessionCacheStrategy}, which delegates
|
|
50
|
+
* to the configured {@link CacheStrategy} to store the session data. This should be suitable
|
|
51
|
+
* for most use-cases.
|
|
52
|
+
*
|
|
53
|
+
* :::note
|
|
54
|
+
*
|
|
55
|
+
* If you are using v3.1 or later, you should not normally need to implement a custom `SessionCacheStrategy`,
|
|
56
|
+
* since this is now handled by the {@link DefaultSessionCacheStrategy}.
|
|
57
|
+
*
|
|
58
|
+
* :::
|
|
59
|
+
*
|
|
60
|
+
* Prior to v3.1, the default was to use the {@link InMemorySessionCacheStrategy}, which is fast but suitable for
|
|
61
|
+
* single-instance deployments.
|
|
53
62
|
*
|
|
54
63
|
* :::info
|
|
55
64
|
*
|
|
@@ -2,7 +2,8 @@ import { ConfigArg } from '@vendure/common/lib/generated-types';
|
|
|
2
2
|
import { Json } from '@vendure/common/lib/shared-types';
|
|
3
3
|
import { RequestContext } from '../../api/common/request-context';
|
|
4
4
|
import { ConfigArgs, ConfigArgValues, ConfigurableOperationDef, ConfigurableOperationDefOptions } from '../../common/configurable-operation';
|
|
5
|
-
import {
|
|
5
|
+
import { Injector } from '../../common/index';
|
|
6
|
+
import { Order, ShippingMethod } from '../../entity';
|
|
6
7
|
/**
|
|
7
8
|
* @description
|
|
8
9
|
* Configuration passed into the constructor of a {@link ShippingEligibilityChecker} to
|
|
@@ -39,8 +40,9 @@ export interface ShippingEligibilityCheckerConfig<T extends ConfigArgs> extends
|
|
|
39
40
|
export declare class ShippingEligibilityChecker<T extends ConfigArgs = ConfigArgs> extends ConfigurableOperationDef<T> {
|
|
40
41
|
private readonly checkFn;
|
|
41
42
|
private readonly shouldRunCheckFn?;
|
|
42
|
-
private
|
|
43
|
+
private cacheService;
|
|
43
44
|
constructor(config: ShippingEligibilityCheckerConfig<T>);
|
|
45
|
+
init(injector: Injector): Promise<void>;
|
|
44
46
|
/**
|
|
45
47
|
* @description
|
|
46
48
|
* Check the given Order to determine whether it is eligible.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShippingEligibilityChecker = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
|
+
const index_1 = require("../../cache/index");
|
|
5
6
|
const configurable_operation_1 = require("../../common/configurable-operation");
|
|
6
|
-
const ttl_cache_1 = require("../../common/ttl-cache");
|
|
7
7
|
/**
|
|
8
8
|
* @description
|
|
9
9
|
* The ShippingEligibilityChecker class is used to check whether an order qualifies for a
|
|
@@ -29,10 +29,13 @@ const ttl_cache_1 = require("../../common/ttl-cache");
|
|
|
29
29
|
class ShippingEligibilityChecker extends configurable_operation_1.ConfigurableOperationDef {
|
|
30
30
|
constructor(config) {
|
|
31
31
|
super(config);
|
|
32
|
-
this.shouldRunCheckCache = new ttl_cache_1.TtlCache({ cacheSize: 5000, ttl: 1000 * 60 * 60 * 5 });
|
|
33
32
|
this.checkFn = config.check;
|
|
34
33
|
this.shouldRunCheckFn = config.shouldRunCheck;
|
|
35
34
|
}
|
|
35
|
+
async init(injector) {
|
|
36
|
+
await super.init(injector);
|
|
37
|
+
this.cacheService = injector.get(index_1.CacheService);
|
|
38
|
+
}
|
|
36
39
|
/**
|
|
37
40
|
* @description
|
|
38
41
|
* Check the given Order to determine whether it is eligible.
|
|
@@ -50,14 +53,14 @@ class ShippingEligibilityChecker extends configurable_operation_1.ConfigurableOp
|
|
|
50
53
|
async shouldRunCheck(ctx, order, args, method) {
|
|
51
54
|
var _a;
|
|
52
55
|
if (typeof this.shouldRunCheckFn === 'function') {
|
|
53
|
-
const cacheKey = (_a = ctx.session) === null || _a === void 0 ? void 0 : _a.id
|
|
56
|
+
const cacheKey = ((_a = ctx.session) === null || _a === void 0 ? void 0 : _a.id) && `ShippingEligibilityChecker:shouldRunCheck:${this.code}:${ctx.session.id}`;
|
|
54
57
|
if (cacheKey) {
|
|
55
58
|
const checkResult = await this.shouldRunCheckFn(ctx, order, this.argsArrayToHash(args), method);
|
|
56
59
|
const checkResultHash = (0, crypto_1.createHash)('sha1')
|
|
57
60
|
.update(JSON.stringify(checkResult))
|
|
58
61
|
.digest('base64');
|
|
59
|
-
const lastResultHash = this.
|
|
60
|
-
this.
|
|
62
|
+
const lastResultHash = await this.cacheService.get(cacheKey);
|
|
63
|
+
await this.cacheService.set(cacheKey, checkResultHash, { ttl: 1000 * 60 * 60 * 5 });
|
|
61
64
|
if (checkResultHash === lastResultHash) {
|
|
62
65
|
return false;
|
|
63
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shipping-eligibility-checker.js","sourceRoot":"","sources":["../../../src/config/shipping-method/shipping-eligibility-checker.ts"],"names":[],"mappings":";;;AAEA,mCAAoC;AAGpC,
|
|
1
|
+
{"version":3,"file":"shipping-eligibility-checker.js","sourceRoot":"","sources":["../../../src/config/shipping-method/shipping-eligibility-checker.ts"],"names":[],"mappings":";;;AAEA,mCAAoC;AAGpC,6CAAiD;AACjD,gFAK6C;AAgB7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,0BAEX,SAAQ,iDAA2B;IAKjC,YAAY,MAA2C;QACnD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAkB;QACzB,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;IACnD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