@vendure/core 3.0.2 → 3.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/common/request-context.d.ts +34 -0
- package/dist/api/common/request-context.js +36 -0
- package/dist/api/common/request-context.js.map +1 -1
- package/dist/cache/cache.module.js +5 -2
- package/dist/cache/cache.module.js.map +1 -1
- package/dist/cache/cache.service.d.ts +37 -0
- package/dist/cache/cache.service.js +83 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/config/config.module.js +2 -0
- package/dist/config/config.module.js.map +1 -1
- package/dist/config/default-config.js +2 -0
- package/dist/config/default-config.js.map +1 -1
- package/dist/config/entity/default-money-strategy.js +1 -1
- package/dist/config/entity/default-money-strategy.js.map +1 -1
- package/dist/config/entity/money-strategy.d.ts +1 -1
- package/dist/config/promotion/actions/facet-values-percentage-discount-action.js +2 -3
- package/dist/config/promotion/actions/facet-values-percentage-discount-action.js.map +1 -1
- package/dist/config/promotion/actions/order-line-fixed-discount-action.d.ts +9 -0
- package/dist/config/promotion/actions/order-line-fixed-discount-action.js +21 -0
- package/dist/config/promotion/actions/order-line-fixed-discount-action.js.map +1 -0
- package/dist/config/promotion/conditions/has-facet-values-condition.js +2 -3
- package/dist/config/promotion/conditions/has-facet-values-condition.js.map +1 -1
- package/dist/config/promotion/index.d.ts +7 -1
- package/dist/config/promotion/index.js +2 -1
- package/dist/config/promotion/index.js.map +1 -1
- package/dist/config/promotion/promotion-action.d.ts +53 -1
- package/dist/config/promotion/promotion-action.js +36 -1
- package/dist/config/promotion/promotion-action.js.map +1 -1
- package/dist/config/system/cache-strategy.d.ts +47 -0
- package/dist/config/system/cache-strategy.js +3 -0
- package/dist/config/system/cache-strategy.js.map +1 -0
- package/dist/config/system/in-memory-cache-strategy.d.ts +26 -0
- package/dist/config/system/in-memory-cache-strategy.js +56 -0
- package/dist/config/system/in-memory-cache-strategy.js.map +1 -0
- package/dist/config/vendure-config.d.ts +10 -0
- package/dist/connection/transactional-connection.d.ts +13 -2
- package/dist/connection/transactional-connection.js +23 -3
- package/dist/connection/transactional-connection.js.map +1 -1
- package/dist/entity/promotion/promotion.entity.d.ts +5 -1
- package/dist/entity/promotion/promotion.entity.js +10 -1
- package/dist/entity/promotion/promotion.entity.js.map +1 -1
- package/dist/plugin/default-cache-plugin/cache-item.entity.d.ts +8 -0
- package/dist/plugin/default-cache-plugin/cache-item.entity.js +38 -0
- package/dist/plugin/default-cache-plugin/cache-item.entity.js.map +1 -0
- package/dist/plugin/default-cache-plugin/constants.d.ts +1 -0
- package/dist/plugin/default-cache-plugin/constants.js +5 -0
- package/dist/plugin/default-cache-plugin/constants.js.map +1 -0
- package/dist/plugin/default-cache-plugin/default-cache-plugin.d.ts +7 -0
- package/dist/plugin/default-cache-plugin/default-cache-plugin.js +40 -0
- package/dist/plugin/default-cache-plugin/default-cache-plugin.js.map +1 -0
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.d.ts +26 -0
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.js +91 -0
- package/dist/plugin/default-cache-plugin/sql-cache-strategy.js.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/service/helpers/external-authentication/external-authentication.service.d.ts +12 -0
- package/dist/service/helpers/external-authentication/external-authentication.service.js +23 -0
- package/dist/service/helpers/external-authentication/external-authentication.service.js.map +1 -1
- package/dist/{config/promotion/utils → service/helpers/facet-value-checker}/facet-value-checker.d.ts +21 -5
- package/dist/service/helpers/facet-value-checker/facet-value-checker.js +151 -0
- package/dist/service/helpers/facet-value-checker/facet-value-checker.js.map +1 -0
- package/dist/service/helpers/order-calculator/order-calculator.d.ts +2 -0
- package/dist/service/helpers/order-calculator/order-calculator.js +2 -1
- package/dist/service/helpers/order-calculator/order-calculator.js.map +1 -1
- package/dist/service/index.d.ts +1 -0
- package/dist/service/index.js +1 -0
- package/dist/service/index.js.map +1 -1
- package/dist/service/service.module.js +2 -0
- package/dist/service/service.module.js.map +1 -1
- package/package.json +3 -3
- package/dist/config/promotion/utils/facet-value-checker.js +0 -76
- package/dist/config/promotion/utils/facet-value-checker.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PromotionShippingAction = exports.PromotionOrderAction = exports.PromotionItemAction = exports.PromotionAction = void 0;
|
|
3
|
+
exports.PromotionShippingAction = exports.PromotionOrderAction = exports.PromotionLineAction = exports.PromotionItemAction = exports.PromotionAction = void 0;
|
|
4
4
|
const pick_1 = require("@vendure/common/lib/pick");
|
|
5
5
|
const configurable_operation_1 = require("../../common/configurable-operation");
|
|
6
6
|
/**
|
|
@@ -67,6 +67,41 @@ class PromotionItemAction extends PromotionAction {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
exports.PromotionItemAction = PromotionItemAction;
|
|
70
|
+
/**
|
|
71
|
+
* @description
|
|
72
|
+
* Represents a PromotionAction which applies to individual {@link OrderLine}s.
|
|
73
|
+
* The difference from PromotionItemAction is that it applies regardless of the Quantity of the OrderLine.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* // Applies a percentage discount to each OrderLine
|
|
78
|
+
* const linePercentageDiscount = new PromotionLineAction({
|
|
79
|
+
* code: 'line_percentage_discount',
|
|
80
|
+
* args: { discount: 'percentage' },
|
|
81
|
+
* execute(ctx, orderLine, args) {
|
|
82
|
+
* return -orderLine.linePrice * (args.discount / 100);
|
|
83
|
+
* },
|
|
84
|
+
* description: 'Discount every line by { discount }%',
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @docsCategory promotions
|
|
89
|
+
* @docsPage promotion-action
|
|
90
|
+
*/
|
|
91
|
+
class PromotionLineAction extends PromotionAction {
|
|
92
|
+
constructor(config) {
|
|
93
|
+
super(config);
|
|
94
|
+
this.executeFn = config.execute;
|
|
95
|
+
}
|
|
96
|
+
/** @internal */
|
|
97
|
+
execute(ctx, orderLine, args, state, promotion) {
|
|
98
|
+
const actionState = this.conditions
|
|
99
|
+
? (0, pick_1.pick)(state, this.conditions.map(c => c.code))
|
|
100
|
+
: {};
|
|
101
|
+
return this.executeFn(ctx, orderLine, this.argsArrayToHash(args), actionState, promotion);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.PromotionLineAction = PromotionLineAction;
|
|
70
105
|
/**
|
|
71
106
|
* @description
|
|
72
107
|
* Represents a PromotionAction which applies to the {@link Order} as a whole.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotion-action.js","sourceRoot":"","sources":["../../../src/config/promotion/promotion-action.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAGhD,gFAK6C;
|
|
1
|
+
{"version":3,"file":"promotion-action.js","sourceRoot":"","sources":["../../../src/config/promotion/promotion-action.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAGhD,gFAK6C;AAsQ7C;;;;;;;;GAQG;AACH,MAAsB,eAGpB,SAAQ,iDAA2B;IAiBjC,YAAsB,MAAmC;QACrD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC;IAC9C,CAAC;IAKD,gBAAgB;IAChB,UAAU,CACN,GAAmB,EACnB,KAAY,EACZ,IAAiB,EACjB,SAAoB;;QAEpB,OAAO,MAAA,IAAI,CAAC,YAAY,qDAAG,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;IAClF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B,EACrB,SAAoB;QAEpB,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU;YAC/B,CAAC,CAAC,IAAA,WAAI,EACA,KAAK,EACL,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACnC;YACH,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,IAAI,CAAC,SAAS,CACjB,GAAG,EACH,YAAY,EACZ,KAAK,EACL,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAC1B,WAAgC,EAChC,SAAS,CACZ,CAAC;IACN,CAAC;CACJ;AAlCD,0DAkCC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { JsonCompatible } from '@vendure/common/lib/shared-types';
|
|
2
|
+
import { InjectableStrategy } from '../../common/types/injectable-strategy';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* Options available when setting the value in the cache.
|
|
6
|
+
*/
|
|
7
|
+
export interface SetCacheKeyOptions {
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* The time-to-live for the cache key in milliseconds. This means
|
|
11
|
+
* that after this time period, the key will be considered stale
|
|
12
|
+
* and will no longer be returned from the cache. Omitting
|
|
13
|
+
* this is equivalent to having an infinite ttl.
|
|
14
|
+
*/
|
|
15
|
+
ttl?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* The CacheStrategy defines how the underlying shared cache mechanism is implemented.
|
|
20
|
+
*
|
|
21
|
+
* It is used by the {@link CacheService} to take care of storage and retrieval of items
|
|
22
|
+
* from the cache.
|
|
23
|
+
*
|
|
24
|
+
* @since 3.1.0
|
|
25
|
+
*/
|
|
26
|
+
export interface CacheStrategy extends InjectableStrategy {
|
|
27
|
+
/**
|
|
28
|
+
* @description
|
|
29
|
+
* Gets an item from the cache, or returns undefined if the key is not found, or the
|
|
30
|
+
* item has expired.
|
|
31
|
+
*/
|
|
32
|
+
get<T extends JsonCompatible<T>>(key: string): Promise<T | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* Sets a key-value pair in the cache. The value must be serializable, so cannot contain
|
|
36
|
+
* things like functions, circular data structures, class instances etc.
|
|
37
|
+
*
|
|
38
|
+
* Optionally a "time to live" (ttl) can be specified, which means that the key will
|
|
39
|
+
* be considered stale after that many milliseconds.
|
|
40
|
+
*/
|
|
41
|
+
set<T extends JsonCompatible<T>>(key: string, value: T, options?: SetCacheKeyOptions): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* @description
|
|
44
|
+
* Deletes an item from the cache.
|
|
45
|
+
*/
|
|
46
|
+
delete(key: string): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-strategy.js","sourceRoot":"","sources":["../../../src/config/system/cache-strategy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JsonCompatible } from '@vendure/common/lib/shared-types';
|
|
2
|
+
import { CacheStrategy, SetCacheKeyOptions } from './cache-strategy';
|
|
3
|
+
export interface CacheItem<T> {
|
|
4
|
+
value: JsonCompatible<T>;
|
|
5
|
+
expires?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A {@link CacheStrategy} that stores the cache in memory using a simple
|
|
9
|
+
* JavaScript Map.
|
|
10
|
+
*
|
|
11
|
+
* **Caution** do not use this in a multi-instance deployment because
|
|
12
|
+
* cache invalidation will not propagate to other instances.
|
|
13
|
+
*
|
|
14
|
+
* @since 3.1.0
|
|
15
|
+
*/
|
|
16
|
+
export declare class InMemoryCacheStrategy implements CacheStrategy {
|
|
17
|
+
protected cache: Map<string, CacheItem<any>>;
|
|
18
|
+
protected cacheSize: number;
|
|
19
|
+
constructor(config?: {
|
|
20
|
+
cacheSize?: number;
|
|
21
|
+
});
|
|
22
|
+
get<T extends JsonCompatible<T>>(key: string): Promise<T | undefined>;
|
|
23
|
+
set<T extends JsonCompatible<T>>(key: string, value: T, options?: SetCacheKeyOptions): Promise<void>;
|
|
24
|
+
delete(key: string): Promise<void>;
|
|
25
|
+
private first;
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryCacheStrategy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A {@link CacheStrategy} that stores the cache in memory using a simple
|
|
6
|
+
* JavaScript Map.
|
|
7
|
+
*
|
|
8
|
+
* **Caution** do not use this in a multi-instance deployment because
|
|
9
|
+
* cache invalidation will not propagate to other instances.
|
|
10
|
+
*
|
|
11
|
+
* @since 3.1.0
|
|
12
|
+
*/
|
|
13
|
+
class InMemoryCacheStrategy {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.cache = new Map();
|
|
16
|
+
this.cacheSize = 10000;
|
|
17
|
+
if (config === null || config === void 0 ? void 0 : config.cacheSize) {
|
|
18
|
+
this.cacheSize = config.cacheSize;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async get(key) {
|
|
22
|
+
const hit = this.cache.get(key);
|
|
23
|
+
if (hit) {
|
|
24
|
+
const now = new Date().getTime();
|
|
25
|
+
if (!hit.expires || (hit.expires && now < hit.expires)) {
|
|
26
|
+
return hit.value;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.cache.delete(key);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async set(key, value, options) {
|
|
34
|
+
if (this.cache.has(key)) {
|
|
35
|
+
// delete key to put the item to the end of
|
|
36
|
+
// the cache, marking it as new again
|
|
37
|
+
this.cache.delete(key);
|
|
38
|
+
}
|
|
39
|
+
else if (this.cache.size === this.cacheSize) {
|
|
40
|
+
// evict oldest
|
|
41
|
+
this.cache.delete(this.first());
|
|
42
|
+
}
|
|
43
|
+
this.cache.set(key, {
|
|
44
|
+
value,
|
|
45
|
+
expires: (options === null || options === void 0 ? void 0 : options.ttl) ? new Date().getTime() + options.ttl : undefined,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async delete(key) {
|
|
49
|
+
this.cache.delete(key);
|
|
50
|
+
}
|
|
51
|
+
first() {
|
|
52
|
+
return this.cache.keys().next().value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.InMemoryCacheStrategy = InMemoryCacheStrategy;
|
|
56
|
+
//# sourceMappingURL=in-memory-cache-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-cache-strategy.js","sourceRoot":"","sources":["../../../src/config/system/in-memory-cache-strategy.ts"],"names":[],"mappings":";;;AASA;;;;;;;;GAQG;AACH,MAAa,qBAAqB;IAI9B,YAAY,MAA+B;QAHjC,UAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;QAC1C,cAAS,GAAG,KAAM,CAAC;QAGzB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QACtC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAA8B,GAAW;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,GAAG,EAAE,CAAC;YACN,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrD,OAAO,GAAG,CAAC,KAAK,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAA8B,GAAW,EAAE,KAAQ,EAAE,OAA4B;QACtF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,2CAA2C;YAC3C,qCAAqC;YACrC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5C,eAAe;YACf,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAChB,KAAK;YACL,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,EAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;SACzE,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEO,KAAK;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;IAC1C,CAAC;CACJ;AA5CD,sDA4CC"}
|
|
@@ -51,6 +51,7 @@ import { SessionCacheStrategy } from './session-cache/session-cache-strategy';
|
|
|
51
51
|
import { ShippingCalculator } from './shipping-method/shipping-calculator';
|
|
52
52
|
import { ShippingEligibilityChecker } from './shipping-method/shipping-eligibility-checker';
|
|
53
53
|
import { ShippingLineAssignmentStrategy } from './shipping-method/shipping-line-assignment-strategy';
|
|
54
|
+
import { CacheStrategy } from './system/cache-strategy';
|
|
54
55
|
import { ErrorHandlerStrategy } from './system/error-handler-strategy';
|
|
55
56
|
import { HealthCheckStrategy } from './system/health-check-strategy';
|
|
56
57
|
import { TaxLineCalculationStrategy } from './tax/tax-line-calculation-strategy';
|
|
@@ -1032,6 +1033,15 @@ export interface SystemOptions {
|
|
|
1032
1033
|
* @since 2.2.0
|
|
1033
1034
|
*/
|
|
1034
1035
|
errorHandlers?: ErrorHandlerStrategy[];
|
|
1036
|
+
/**
|
|
1037
|
+
* @description
|
|
1038
|
+
* Defines the underlying method used to store cache key-value pairs which powers the
|
|
1039
|
+
* {@link CacheService}.
|
|
1040
|
+
*
|
|
1041
|
+
* @since 3.1.0
|
|
1042
|
+
* @default InMemoryCacheStrategy
|
|
1043
|
+
*/
|
|
1044
|
+
cacheStrategy?: CacheStrategy;
|
|
1035
1045
|
}
|
|
1036
1046
|
/**
|
|
1037
1047
|
* @description
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ID, Type } from '@vendure/common/lib/shared-types';
|
|
2
|
-
import { DataSource, EntitySchema, FindManyOptions, FindOneOptions, ObjectLiteral, ObjectType, Repository } from 'typeorm';
|
|
2
|
+
import { DataSource, EntitySchema, FindManyOptions, FindOneOptions, ObjectLiteral, ObjectType, Repository, ReplicationMode } from 'typeorm';
|
|
3
3
|
import { RequestContext } from '../api/common/request-context';
|
|
4
4
|
import { TransactionIsolationLevel } from '../api/decorators/transaction.decorator';
|
|
5
5
|
import { ChannelAware } from '../common/types/common-types';
|
|
@@ -43,8 +43,19 @@ export declare class TransactionalConnection {
|
|
|
43
43
|
* Returns a TypeORM repository which is bound to any existing transactions. It is recommended to _always_ pass
|
|
44
44
|
* the RequestContext argument when possible, otherwise the queries will be executed outside of any
|
|
45
45
|
* ongoing transactions which have been started by the {@link Transaction} decorator.
|
|
46
|
+
*
|
|
47
|
+
* The `options` parameter allows specifying additional configurations, such as the `replicationMode`,
|
|
48
|
+
* which determines whether the repository should interact with the master or replica database.
|
|
49
|
+
*
|
|
50
|
+
* @param ctx - The RequestContext, which ensures the repository is aware of any existing transactions.
|
|
51
|
+
* @param target - The entity type or schema for which the repository is returned.
|
|
52
|
+
* @param options - Additional options for configuring the repository, such as the `replicationMode`.
|
|
53
|
+
*
|
|
54
|
+
* @returns A TypeORM repository for the specified entity type.
|
|
46
55
|
*/
|
|
47
|
-
getRepository<Entity extends ObjectLiteral>(ctx: RequestContext | undefined, target: ObjectType<Entity> | EntitySchema<Entity> | string
|
|
56
|
+
getRepository<Entity extends ObjectLiteral>(ctx: RequestContext | undefined, target: ObjectType<Entity> | EntitySchema<Entity> | string, options?: {
|
|
57
|
+
replicationMode?: ReplicationMode;
|
|
58
|
+
}): Repository<Entity>;
|
|
48
59
|
/**
|
|
49
60
|
* @description
|
|
50
61
|
* Allows database operations to be wrapped in a transaction, ensuring that in the event of an error being
|
|
@@ -59,19 +59,39 @@ let TransactionalConnection = class TransactionalConnection {
|
|
|
59
59
|
get rawConnection() {
|
|
60
60
|
return this.dataSource;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @description
|
|
64
|
+
* Returns a TypeORM repository. Depending on the parameters passed, it will either be transaction-aware
|
|
65
|
+
* or not. If `RequestContext` is provided, the repository is bound to any ongoing transactions. The
|
|
66
|
+
* `options` parameter allows further customization, such as selecting the replication mode (e.g., 'master').
|
|
67
|
+
*
|
|
68
|
+
* @param ctxOrTarget - Either the RequestContext, which binds the repository to ongoing transactions, or the entity type/schema.
|
|
69
|
+
* @param maybeTarget - The entity type or schema for which the repository is returned (if `ctxOrTarget` is a RequestContext).
|
|
70
|
+
* @param options - Additional options for configuring the repository, such as the `replicationMode`.
|
|
71
|
+
*
|
|
72
|
+
* @returns A TypeORM repository for the specified entity type.
|
|
73
|
+
*/
|
|
74
|
+
getRepository(ctxOrTarget, maybeTarget, options) {
|
|
63
75
|
if (ctxOrTarget instanceof request_context_1.RequestContext) {
|
|
64
76
|
const transactionManager = this.getTransactionManager(ctxOrTarget);
|
|
65
77
|
if (transactionManager) {
|
|
66
78
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
67
79
|
return transactionManager.getRepository(maybeTarget);
|
|
68
80
|
}
|
|
69
|
-
|
|
81
|
+
if (ctxOrTarget.replicationMode === 'master' || (options === null || options === void 0 ? void 0 : options.replicationMode) === 'master') {
|
|
70
82
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
71
|
-
return this.
|
|
83
|
+
return this.dataSource.createQueryRunner('master').manager.getRepository(maybeTarget);
|
|
72
84
|
}
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
86
|
+
return this.rawConnection.getRepository(maybeTarget);
|
|
73
87
|
}
|
|
74
88
|
else {
|
|
89
|
+
if ((options === null || options === void 0 ? void 0 : options.replicationMode) === 'master') {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
91
|
+
return this.dataSource
|
|
92
|
+
.createQueryRunner(options.replicationMode)
|
|
93
|
+
.manager.getRepository(maybeTarget);
|
|
94
|
+
}
|
|
75
95
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
76
96
|
return this.rawConnection.getRepository(ctxOrTarget !== null && ctxOrTarget !== void 0 ? ctxOrTarget : maybeTarget);
|
|
77
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactional-connection.js","sourceRoot":"","sources":["../../src/connection/transactional-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uFAAkF;AAElF,
|
|
1
|
+
{"version":3,"file":"transactional-connection.js","sourceRoot":"","sources":["../../src/connection/transactional-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uFAAkF;AAElF,qCAWiB;AAEjB,mEAA+D;AAE/D,mDAA8D;AAC9D,mDAA6D;AAG7D,gGAAiG;AAEjG,iFAA0E;AAC1E,+DAA2D;AAG3D;;;;;;;;;;;GAWG;AAEI,IAAM,uBAAuB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MAAM,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAExE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,MAAM,eAAe,GAAG,IAAA,uDAA4B,EAChD,EAAuC,EACvC,MAAM,EACN,OAAO,CAAC,SAAS,CACpB,CAAC;YACF,mGAAmG;YACnG,4BAA4B;YAC5B,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QACrG,CAAC;QAED,EAAE,CAAC,cAAc,iBACb,oBAAoB,EAAE,OAAO,IAC1B,OAAO,EACZ,CAAC;QAEH,OAAO,EAAE;aACJ,QAAQ,CAAC,iBAAiB,EAAE,SAAS,CAAC;aACtC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,GAAG,EAAE,CAAC;aAC3C,QAAQ,CAAC,yBAAyB,EAAE,EAAE,SAAS,EAAE,CAAC;aAClD,OAAO,EAAE,CAAC;IACnB,CAAC;IAEO,qBAAqB,CAAC,GAAmB;QAC7C,OAAQ,GAAW,CAAC,mCAAuB,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AA3VY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,qCAAgB,GAAE,CAAA;qCAAqB,oBAAU;QACtB,wCAAkB;GAHzC,uBAAuB,CA2VnC"}
|
|
@@ -15,6 +15,9 @@ import { ShippingLine } from '../shipping-line/shipping-line.entity';
|
|
|
15
15
|
export interface ApplyOrderItemActionArgs {
|
|
16
16
|
orderLine: OrderLine;
|
|
17
17
|
}
|
|
18
|
+
export interface ApplyOrderLineActionArgs {
|
|
19
|
+
orderLine: OrderLine;
|
|
20
|
+
}
|
|
18
21
|
export interface ApplyOrderActionArgs {
|
|
19
22
|
order: Order;
|
|
20
23
|
}
|
|
@@ -32,7 +35,7 @@ export type PromotionTestResult = boolean | PromotionState;
|
|
|
32
35
|
* will be applied to an Order.
|
|
33
36
|
*
|
|
34
37
|
* Each assigned {@link PromotionCondition} is checked against the Order, and if they all return `true`,
|
|
35
|
-
* then each assign {@link PromotionItemAction} / {@link PromotionOrderAction} is applied to the Order.
|
|
38
|
+
* then each assign {@link PromotionItemAction} / {@link PromotionLineAction} / {@link PromotionOrderAction} / {@link PromotionShippingAction} is applied to the Order.
|
|
36
39
|
*
|
|
37
40
|
* @docsCategory entities
|
|
38
41
|
*/
|
|
@@ -81,6 +84,7 @@ export declare class Promotion extends AdjustmentSource implements ChannelAware,
|
|
|
81
84
|
deactivate(ctx: RequestContext, order: Order): Promise<void>;
|
|
82
85
|
private isShippingAction;
|
|
83
86
|
private isOrderArg;
|
|
87
|
+
private isOrderLineArg;
|
|
84
88
|
private isOrderItemArg;
|
|
85
89
|
private isShippingArg;
|
|
86
90
|
}
|
|
@@ -26,7 +26,7 @@ const promotion_translation_entity_1 = require("./promotion-translation.entity")
|
|
|
26
26
|
* will be applied to an Order.
|
|
27
27
|
*
|
|
28
28
|
* Each assigned {@link PromotionCondition} is checked against the Order, and if they all return `true`,
|
|
29
|
-
* then each assign {@link PromotionItemAction} / {@link PromotionOrderAction} is applied to the Order.
|
|
29
|
+
* then each assign {@link PromotionItemAction} / {@link PromotionLineAction} / {@link PromotionOrderAction} / {@link PromotionShippingAction} is applied to the Order.
|
|
30
30
|
*
|
|
31
31
|
* @docsCategory entities
|
|
32
32
|
*/
|
|
@@ -48,6 +48,12 @@ let Promotion = class Promotion extends adjustment_source_1.AdjustmentSource {
|
|
|
48
48
|
const promotionAction = this.allActions[action.code];
|
|
49
49
|
if (promotionAction instanceof promotion_action_1.PromotionItemAction) {
|
|
50
50
|
if (this.isOrderItemArg(args)) {
|
|
51
|
+
const { orderLine } = args;
|
|
52
|
+
amount += (0, round_money_1.roundMoney)(await promotionAction.execute(ctx, orderLine, action.args, state, this), orderLine.quantity);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (promotionAction instanceof promotion_action_1.PromotionLineAction) {
|
|
56
|
+
if (this.isOrderLineArg(args)) {
|
|
51
57
|
const { orderLine } = args;
|
|
52
58
|
amount += (0, round_money_1.roundMoney)(await promotionAction.execute(ctx, orderLine, action.args, state, this));
|
|
53
59
|
}
|
|
@@ -119,6 +125,9 @@ let Promotion = class Promotion extends adjustment_source_1.AdjustmentSource {
|
|
|
119
125
|
isOrderArg(value) {
|
|
120
126
|
return !this.isOrderItemArg(value) && !this.isShippingArg(value);
|
|
121
127
|
}
|
|
128
|
+
isOrderLineArg(value) {
|
|
129
|
+
return value.hasOwnProperty('orderLine');
|
|
130
|
+
}
|
|
122
131
|
isOrderItemArg(value) {
|
|
123
132
|
return value.hasOwnProperty('orderLine');
|
|
124
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotion.entity.js","sourceRoot":"","sources":["../../../src/entity/promotion/promotion.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAwG;AAExG,qCAA2E;AAG3E,0DAAsD;AACtD,4EAAwE;AAGxE,gEAAwD;AAExD,
|
|
1
|
+
{"version":3,"file":"promotion.entity.js","sourceRoot":"","sources":["../../../src/entity/promotion/promotion.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAwG;AAExG,qCAA2E;AAG3E,0DAAsD;AACtD,4EAAwE;AAGxE,gEAAwD;AAExD,8EAMiD;AAEjD,8DAAoD;AACpD,kEAAgE;AAChE,wDAA8C;AAI9C,iFAAsE;AAyBtE;;;;;;;;;GASG;AAEI,IAAM,SAAS,GAAf,MAAM,SACT,SAAQ,oCAAgB;IAaxB,YACI,KAGC;QAED,KAAK,CAAC,KAAK,CAAC,CAAC;QAhBjB,SAAI,GAAG,gCAAc,CAAC,SAAS,CAAC;QACf,kBAAa,GAA2C,EA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IAAA,gBAAM,GAAE;;GACI,SAAS,CAoNrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DeepPartial } from '@vendure/common/lib/shared-types';
|
|
2
|
+
import { VendureEntity } from '../../entity/base/base.entity';
|
|
3
|
+
export declare class CacheItem extends VendureEntity {
|
|
4
|
+
constructor(input: DeepPartial<CacheItem>);
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
expiresAt?: Date;
|
|
8
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CacheItem = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_entity_1 = require("../../entity/base/base.entity");
|
|
15
|
+
let CacheItem = class CacheItem extends base_entity_1.VendureEntity {
|
|
16
|
+
constructor(input) {
|
|
17
|
+
super(input);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.CacheItem = CacheItem;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Index)('cache_item_key'),
|
|
23
|
+
(0, typeorm_1.Column)({ unique: true }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], CacheItem.prototype, "key", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)('text'),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], CacheItem.prototype, "value", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
32
|
+
__metadata("design:type", Date)
|
|
33
|
+
], CacheItem.prototype, "expiresAt", void 0);
|
|
34
|
+
exports.CacheItem = CacheItem = __decorate([
|
|
35
|
+
(0, typeorm_1.Entity)(),
|
|
36
|
+
__metadata("design:paramtypes", [Object])
|
|
37
|
+
], CacheItem);
|
|
38
|
+
//# sourceMappingURL=cache-item.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-item.entity.js","sourceRoot":"","sources":["../../../src/plugin/default-cache-plugin/cache-item.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAgD;AAEhD,+DAA8D;AAGvD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,2BAAa;IACxC,YAAY,KAA6B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CAWJ,CAAA;AAdY,8BAAS;AAOlB;IAFC,IAAA,eAAK,EAAC,gBAAgB,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;sCACb;AAGZ;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;wCACD;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;4CAAC;oBAbR,SAAS;IADrB,IAAA,gBAAM,GAAE;;GACI,SAAS,CAcrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_INIT_OPTIONS: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plugin/default-cache-plugin/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var DefaultCachePlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DefaultCachePlugin = void 0;
|
|
11
|
+
const plugin_common_module_1 = require("../plugin-common.module");
|
|
12
|
+
const vendure_plugin_1 = require("../vendure-plugin");
|
|
13
|
+
const cache_item_entity_1 = require("./cache-item.entity");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const sql_cache_strategy_1 = require("./sql-cache-strategy");
|
|
16
|
+
let DefaultCachePlugin = DefaultCachePlugin_1 = class DefaultCachePlugin {
|
|
17
|
+
static init(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
return DefaultCachePlugin_1;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.DefaultCachePlugin = DefaultCachePlugin;
|
|
23
|
+
DefaultCachePlugin.options = {
|
|
24
|
+
cacheSize: 10000,
|
|
25
|
+
};
|
|
26
|
+
exports.DefaultCachePlugin = DefaultCachePlugin = DefaultCachePlugin_1 = __decorate([
|
|
27
|
+
(0, vendure_plugin_1.VendurePlugin)({
|
|
28
|
+
imports: [plugin_common_module_1.PluginCommonModule],
|
|
29
|
+
entities: [cache_item_entity_1.CacheItem],
|
|
30
|
+
providers: [{ provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () => DefaultCachePlugin.options }],
|
|
31
|
+
configuration: config => {
|
|
32
|
+
config.systemOptions.cacheStrategy = new sql_cache_strategy_1.SqlCacheStrategy({
|
|
33
|
+
cacheSize: DefaultCachePlugin.options.cacheSize,
|
|
34
|
+
});
|
|
35
|
+
return config;
|
|
36
|
+
},
|
|
37
|
+
compatibility: '>0.0.0',
|
|
38
|
+
})
|
|
39
|
+
], DefaultCachePlugin);
|
|
40
|
+
//# sourceMappingURL=default-cache-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-cache-plugin.js","sourceRoot":"","sources":["../../../src/plugin/default-cache-plugin/default-cache-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,kEAA6D;AAC7D,sDAAkD;AAElD,2DAAgD;AAChD,2CAAkD;AAClD,6DAAwD;AAkBjD,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAK3B,MAAM,CAAC,IAAI,CAAC,OAAsC;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,oBAAkB,CAAC;IAC9B,CAAC;;AARQ,gDAAkB;AACpB,0BAAO,GAAkC;IAC5C,SAAS,EAAE,KAAM;CACpB,AAFa,CAEZ;6BAHO,kBAAkB;IAZ9B,IAAA,8BAAa,EAAC;QACX,OAAO,EAAE,CAAC,yCAAkB,CAAC;QAC7B,QAAQ,EAAE,CAAC,6BAAS,CAAC;QACrB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,+BAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAC3F,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,aAAa,CAAC,aAAa,GAAG,IAAI,qCAAgB,CAAC;gBACtD,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,SAAS;aAClD,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,aAAa,EAAE,QAAQ;KAC1B,CAAC;GACW,kBAAkB,CAS9B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JsonCompatible } from '@vendure/common/lib/shared-types';
|
|
2
|
+
import { Injector } from '../../common/index';
|
|
3
|
+
import { ConfigService } from '../../config/index';
|
|
4
|
+
import { CacheStrategy, SetCacheKeyOptions } from '../../config/system/cache-strategy';
|
|
5
|
+
import { TransactionalConnection } from '../../connection/index';
|
|
6
|
+
/**
|
|
7
|
+
* A {@link CacheStrategy} that stores the cache in memory using a simple
|
|
8
|
+
* JavaScript Map.
|
|
9
|
+
*
|
|
10
|
+
* **Caution** do not use this in a multi-instance deployment because
|
|
11
|
+
* cache invalidation will not propagate to other instances.
|
|
12
|
+
*
|
|
13
|
+
* @since 3.1.0
|
|
14
|
+
*/
|
|
15
|
+
export declare class SqlCacheStrategy implements CacheStrategy {
|
|
16
|
+
protected cacheSize: number;
|
|
17
|
+
constructor(config?: {
|
|
18
|
+
cacheSize?: number;
|
|
19
|
+
});
|
|
20
|
+
protected connection: TransactionalConnection;
|
|
21
|
+
protected configService: ConfigService;
|
|
22
|
+
init(injector: Injector): void;
|
|
23
|
+
get<T extends JsonCompatible<T>>(key: string): Promise<T | undefined>;
|
|
24
|
+
set<T extends JsonCompatible<T>>(key: string, value: T, options?: SetCacheKeyOptions): Promise<void>;
|
|
25
|
+
delete(key: string): Promise<void>;
|
|
26
|
+
}
|