@vendure/stellate-plugin 2.1.4

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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # Vendure Stellate Plugin
2
+
3
+ Integrates your Vendure server with the [Stellate](TaxRateEvent) GraphQL API cache.
4
+
5
+ `npm install @vendure/stellate-plugin`
6
+
7
+ For documentation, see [docs.vendure.io/typescript-api/core-plugins/stellate-plugin/](https://docs.vendure.io/typescript-api/core-plugins/stellate-plugin/)
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './src/stellate-plugin';
2
+ export * from './src/service/stellate.service';
3
+ export * from './src/default-purge-rules';
4
+ export * from './src/purge-rule';
5
+ export * from './src/types';
6
+ export * from './src/constants';
package/lib/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./src/stellate-plugin"), exports);
18
+ __exportStar(require("./src/service/stellate.service"), exports);
19
+ __exportStar(require("./src/default-purge-rules"), exports);
20
+ __exportStar(require("./src/purge-rule"), exports);
21
+ __exportStar(require("./src/types"), exports);
22
+ __exportStar(require("./src/constants"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,iEAA+C;AAC/C,4DAA0C;AAC1C,mDAAiC;AACjC,8CAA4B;AAC5B,kDAAgC"}
@@ -0,0 +1 @@
1
+ export declare const shopApiExtensions: import("graphql").DocumentNode;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.shopApiExtensions = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.shopApiExtensions = (0, graphql_tag_1.default) `
9
+ """
10
+ This type is here to allow us to easily purge the Stellate cache
11
+ of any search results where the collectionSlug is used. We cannot rely on
12
+ simply purging the SearchResult type, because in the case of an empty 'items'
13
+ array, Stellate cannot know that that particular query now needs to be purged.
14
+ """
15
+ type SearchResponseCacheIdentifier {
16
+ collectionSlug: String
17
+ }
18
+
19
+ extend type SearchResponse {
20
+ cacheIdentifier: SearchResponseCacheIdentifier
21
+ }
22
+ `;
23
+ //# sourceMappingURL=api-extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-extensions.js","sourceRoot":"","sources":["../../../src/api/api-extensions.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA8B;AAEjB,QAAA,iBAAiB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;CAcnC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { GraphQLResolveInfo } from 'graphql/type';
2
+ export declare class SearchResponseFieldResolver {
3
+ cacheIdentifier(info: GraphQLResolveInfo): {
4
+ collectionSlug: any;
5
+ };
6
+ }
@@ -0,0 +1,35 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SearchResponseFieldResolver = void 0;
16
+ const graphql_1 = require("@nestjs/graphql");
17
+ let SearchResponseFieldResolver = class SearchResponseFieldResolver {
18
+ cacheIdentifier(info) {
19
+ var _a;
20
+ const collectionSlug = (_a = info.variableValues.input) === null || _a === void 0 ? void 0 : _a.collectionSlug;
21
+ return { collectionSlug };
22
+ }
23
+ };
24
+ __decorate([
25
+ (0, graphql_1.ResolveField)(),
26
+ __param(0, (0, graphql_1.Info)()),
27
+ __metadata("design:type", Function),
28
+ __metadata("design:paramtypes", [Object]),
29
+ __metadata("design:returntype", void 0)
30
+ ], SearchResponseFieldResolver.prototype, "cacheIdentifier", null);
31
+ SearchResponseFieldResolver = __decorate([
32
+ (0, graphql_1.Resolver)('SearchResponse')
33
+ ], SearchResponseFieldResolver);
34
+ exports.SearchResponseFieldResolver = SearchResponseFieldResolver;
35
+ //# sourceMappingURL=search-response.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-response.resolver.js","sourceRoot":"","sources":["../../../src/api/search-response.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA+D;AAIxD,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAEpC,eAAe,CAAS,IAAwB;;QAC5C,MAAM,cAAc,GAAG,MAAC,IAAI,CAAC,cAAc,CAAC,KAAa,0CAAE,cAAc,CAAC;QAC1E,OAAO,EAAE,cAAc,EAAE,CAAC;IAC9B,CAAC;CACJ,CAAA;AALG;IAAC,IAAA,sBAAY,GAAE;IACE,WAAA,IAAA,cAAI,GAAE,CAAA;;;;kEAGtB;AALQ,2BAA2B;IADvC,IAAA,kBAAQ,EAAC,gBAAgB,CAAC;GACd,2BAA2B,CAMvC;AANY,kEAA2B"}
@@ -0,0 +1,2 @@
1
+ export declare const STELLATE_PLUGIN_OPTIONS = "STELLATE_PLUGIN_OPTIONS";
2
+ export declare const loggerCtx = "StellatePlugin";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loggerCtx = exports.STELLATE_PLUGIN_OPTIONS = void 0;
4
+ exports.STELLATE_PLUGIN_OPTIONS = 'STELLATE_PLUGIN_OPTIONS';
5
+ exports.loggerCtx = 'StellatePlugin';
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,SAAS,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { CollectionEvent, CollectionModificationEvent, ProductChannelEvent, ProductEvent, ProductVariantChannelEvent, ProductVariantEvent, StockMovementEvent, TaxRateEvent } from '@vendure/core';
2
+ import { PurgeRule } from './purge-rule';
3
+ export declare const purgeProductsOnProductEvent: PurgeRule<ProductEvent>;
4
+ export declare const purgeProductVariantsOnProductVariantEvent: PurgeRule<ProductVariantEvent>;
5
+ export declare const purgeProductsOnChannelEvent: PurgeRule<ProductChannelEvent>;
6
+ export declare const purgeProductVariantsOnChannelEvent: PurgeRule<ProductVariantChannelEvent>;
7
+ export declare const purgeProductVariantsOnStockMovementEvent: PurgeRule<StockMovementEvent>;
8
+ export declare const purgeCollectionsOnCollectionModificationEvent: PurgeRule<CollectionModificationEvent>;
9
+ export declare const purgeCollectionsOnCollectionEvent: PurgeRule<CollectionEvent>;
10
+ export declare const purgeAllOnTaxRateEvent: PurgeRule<TaxRateEvent>;
11
+ export declare const defaultPurgeRules: (PurgeRule<ProductEvent> | PurgeRule<ProductVariantEvent> | PurgeRule<ProductChannelEvent> | PurgeRule<ProductVariantChannelEvent> | PurgeRule<StockMovementEvent> | PurgeRule<CollectionModificationEvent> | PurgeRule<CollectionEvent> | PurgeRule<TaxRateEvent>)[];
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPurgeRules = exports.purgeAllOnTaxRateEvent = exports.purgeCollectionsOnCollectionEvent = exports.purgeCollectionsOnCollectionModificationEvent = exports.purgeProductVariantsOnStockMovementEvent = exports.purgeProductVariantsOnChannelEvent = exports.purgeProductsOnChannelEvent = exports.purgeProductVariantsOnProductVariantEvent = exports.purgeProductsOnProductEvent = void 0;
4
+ /* eslint-disable @typescript-eslint/no-floating-promises */
5
+ const core_1 = require("@vendure/core");
6
+ const constants_1 = require("./constants");
7
+ const purge_rule_1 = require("./purge-rule");
8
+ exports.purgeProductsOnProductEvent = new purge_rule_1.PurgeRule({
9
+ eventType: core_1.ProductEvent,
10
+ handler: ({ events, stellateService }) => {
11
+ const products = events.map(e => e.product);
12
+ stellateService.purgeProducts(products);
13
+ stellateService.purgeSearchResults(products);
14
+ },
15
+ });
16
+ exports.purgeProductVariantsOnProductVariantEvent = new purge_rule_1.PurgeRule({
17
+ eventType: core_1.ProductVariantEvent,
18
+ handler: ({ events, stellateService }) => {
19
+ const variants = events.map(e => e.variants).flat();
20
+ stellateService.purgeProductVariants(variants);
21
+ stellateService.purgeSearchResults(variants);
22
+ },
23
+ });
24
+ exports.purgeProductsOnChannelEvent = new purge_rule_1.PurgeRule({
25
+ eventType: core_1.ProductChannelEvent,
26
+ handler: ({ events, stellateService }) => {
27
+ const products = events.map(e => e.product);
28
+ stellateService.purgeProducts(products);
29
+ stellateService.purgeSearchResults(products);
30
+ },
31
+ });
32
+ exports.purgeProductVariantsOnChannelEvent = new purge_rule_1.PurgeRule({
33
+ eventType: core_1.ProductVariantChannelEvent,
34
+ handler: ({ events, stellateService }) => {
35
+ const variants = events.map(e => e.productVariant);
36
+ stellateService.purgeProductVariants(variants);
37
+ stellateService.purgeSearchResults(variants);
38
+ },
39
+ });
40
+ exports.purgeProductVariantsOnStockMovementEvent = new purge_rule_1.PurgeRule({
41
+ eventType: core_1.StockMovementEvent,
42
+ handler: ({ events, stellateService }) => {
43
+ const variants = events.map(e => e.stockMovements.map(m => m.productVariant)).flat();
44
+ stellateService.purgeProductVariants(variants);
45
+ stellateService.purgeSearchResults(variants);
46
+ },
47
+ });
48
+ exports.purgeCollectionsOnCollectionModificationEvent = new purge_rule_1.PurgeRule({
49
+ eventType: core_1.CollectionModificationEvent,
50
+ handler: ({ events, stellateService }) => {
51
+ const collectionsToPurge = events.filter(e => e.productVariantIds.length).map(e => e.collection);
52
+ core_1.Logger.debug(`purgeCollectionsOnCollectionModificationEvent, collectionsToPurge: ${collectionsToPurge
53
+ .map(c => c.id)
54
+ .join(', ')}`, constants_1.loggerCtx);
55
+ if (collectionsToPurge.length) {
56
+ stellateService.purgeCollections(collectionsToPurge);
57
+ stellateService.purgeSearchResponseCacheIdentifiers(collectionsToPurge);
58
+ }
59
+ },
60
+ });
61
+ exports.purgeCollectionsOnCollectionEvent = new purge_rule_1.PurgeRule({
62
+ eventType: core_1.CollectionEvent,
63
+ handler: ({ events, stellateService }) => {
64
+ const collections = events.map(e => e.entity);
65
+ stellateService.purgeCollections(collections);
66
+ },
67
+ });
68
+ exports.purgeAllOnTaxRateEvent = new purge_rule_1.PurgeRule({
69
+ eventType: core_1.TaxRateEvent,
70
+ handler: ({ stellateService }) => {
71
+ stellateService.purgeAllOfType('ProductVariant');
72
+ stellateService.purgeAllOfType('Product');
73
+ stellateService.purgeAllOfType('SearchResponse');
74
+ },
75
+ });
76
+ exports.defaultPurgeRules = [
77
+ exports.purgeAllOnTaxRateEvent,
78
+ exports.purgeCollectionsOnCollectionEvent,
79
+ exports.purgeCollectionsOnCollectionModificationEvent,
80
+ exports.purgeProductsOnChannelEvent,
81
+ exports.purgeProductsOnProductEvent,
82
+ exports.purgeProductVariantsOnChannelEvent,
83
+ exports.purgeProductVariantsOnProductVariantEvent,
84
+ exports.purgeProductVariantsOnStockMovementEvent,
85
+ ];
86
+ //# sourceMappingURL=default-purge-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-purge-rules.js","sourceRoot":"","sources":["../../src/default-purge-rules.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,wCAUuB;AAEvB,2CAAwC;AACxC,6CAAyC;AAE5B,QAAA,2BAA2B,GAAG,IAAI,sBAAS,CAAC;IACrD,SAAS,EAAE,mBAAY;IACvB,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5C,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ,CAAC,CAAC;AAEU,QAAA,yCAAyC,GAAG,IAAI,sBAAS,CAAC;IACnE,SAAS,EAAE,0BAAmB;IAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACpD,eAAe,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/C,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,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CAAC,CAAC;QAC1C,eAAe,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC;CACJ,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG;IAC7B,8BAAsB;IACtB,yCAAiC;IACjC,qDAA6C;IAC7C,mCAA2B;IAC3B,mCAA2B;IAC3B,0CAAkC;IAClC,iDAAyC;IACzC,gDAAwC;CAC3C,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { Type } from '@vendure/common/lib/shared-types';
2
+ import { VendureEvent, Injector } from '@vendure/core';
3
+ import { StellateService } from './service/stellate.service';
4
+ /**
5
+ * @description
6
+ * Configures a {@link PurgeRule}.
7
+ *
8
+ * @docsCategory core plugins/StellatePlugin
9
+ * @docsPage PurgeRule
10
+ */
11
+ export interface PurgeRuleConfig<Event extends VendureEvent> {
12
+ /**
13
+ * @description
14
+ * Specifies which VendureEvent will trigger this purge rule.
15
+ */
16
+ eventType: Type<Event>;
17
+ /**
18
+ * @description
19
+ * How long to buffer events for in milliseconds before executing the handler. This allows
20
+ * us to efficiently batch calls to the Stellate Purge API.
21
+ *
22
+ * @default 5000
23
+ */
24
+ bufferTime?: number;
25
+ /**
26
+ * @description
27
+ * The function to invoke when the specified event is published. This function should use the
28
+ * {@link StellateService} instance to call the Stellate Purge API.
29
+ */
30
+ handler: (handlerArgs: {
31
+ events: Event[];
32
+ stellateService: StellateService;
33
+ injector: Injector;
34
+ }) => void | Promise<void>;
35
+ }
36
+ /**
37
+ * @description
38
+ * Defines a rule that listens for a particular VendureEvent and uses that to
39
+ * make calls to the [Stellate Purging API](https://docs.stellate.co/docs/purging-api) via
40
+ * the provided {@link StellateService} instance.
41
+ *
42
+ * @docsCategory core plugins/StellatePlugin
43
+ * @docsPage PurgeRule
44
+ * @docsWeight 0
45
+ */
46
+ export declare class PurgeRule<Event extends VendureEvent = VendureEvent> {
47
+ private config;
48
+ get eventType(): Type<Event>;
49
+ get bufferTimeMs(): number | undefined;
50
+ handle(handlerArgs: {
51
+ events: Event[];
52
+ stellateService: StellateService;
53
+ injector: Injector;
54
+ }): void | Promise<void>;
55
+ constructor(config: PurgeRuleConfig<Event>);
56
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PurgeRule = void 0;
4
+ /**
5
+ * @description
6
+ * Defines a rule that listens for a particular VendureEvent and uses that to
7
+ * make calls to the [Stellate Purging API](https://docs.stellate.co/docs/purging-api) via
8
+ * the provided {@link StellateService} instance.
9
+ *
10
+ * @docsCategory core plugins/StellatePlugin
11
+ * @docsPage PurgeRule
12
+ * @docsWeight 0
13
+ */
14
+ class PurgeRule {
15
+ get eventType() {
16
+ return this.config.eventType;
17
+ }
18
+ get bufferTimeMs() {
19
+ return this.config.bufferTime;
20
+ }
21
+ handle(handlerArgs) {
22
+ return this.config.handler(handlerArgs);
23
+ }
24
+ constructor(config) {
25
+ this.config = config;
26
+ }
27
+ }
28
+ exports.PurgeRule = PurgeRule;
29
+ //# sourceMappingURL=purge-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purge-rule.js","sourceRoot":"","sources":["../../src/purge-rule.ts"],"names":[],"mappings":";;;AAsCA;;;;;;;;;GASG;AACH,MAAa,SAAS;IAClB,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IACjC,CAAC;IACD,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,WAAsF;QACzF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IACD,YAAoB,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;IAAG,CAAC;CACzD;AAXD,8BAWC"}
@@ -0,0 +1,50 @@
1
+ import { Collection, ID, Product, ProductVariant } from '@vendure/core';
2
+ import { StellatePluginOptions } from '../types';
3
+ type CachedType = 'Product' | 'ProductVariant' | 'Collection' | 'SearchResponse' | 'SearchResult' | 'SearchResponseCacheIdentifier' | string;
4
+ /**
5
+ * @description
6
+ * The StellateService is used to purge the Stellate cache when certain events occur.
7
+ *
8
+ * @docsCategory core plugins/StellatePlugin
9
+ */
10
+ export declare class StellateService {
11
+ private options;
12
+ private readonly purgeApiUrl;
13
+ constructor(options: StellatePluginOptions);
14
+ /**
15
+ * @description
16
+ * Purges the cache for the given Products.
17
+ */
18
+ purgeProducts(products: Product[]): Promise<void>;
19
+ /**
20
+ * @description
21
+ * Purges the cache for the given ProductVariants.
22
+ */
23
+ purgeProductVariants(productVariants: ProductVariant[]): Promise<void>;
24
+ /**
25
+ * @description
26
+ * Purges the cache for SearchResults which contain the given Products or ProductVariants.
27
+ */
28
+ purgeSearchResults(items: Array<ProductVariant | Product>): Promise<void>;
29
+ /**
30
+ * @description
31
+ * Purges the entire cache for the given type.
32
+ */
33
+ purgeAllOfType(type: CachedType): Promise<void>;
34
+ /**
35
+ * @description
36
+ * Purges the cache for the given Collections.
37
+ */
38
+ purgeCollections(collections: Collection[]): Promise<void>;
39
+ /**
40
+ * @description
41
+ * Purges the cache of SearchResults for the given Collections based on slug.
42
+ */
43
+ purgeSearchResponseCacheIdentifiers(collections: Collection[]): Promise<void>;
44
+ /**
45
+ * @description
46
+ * Purges the cache for the given type and keys.
47
+ */
48
+ purge(type: CachedType, keys?: ID[], keyName?: string): Promise<void> | undefined;
49
+ }
50
+ export {};
@@ -0,0 +1,145 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.StellateService = void 0;
19
+ const common_1 = require("@nestjs/common");
20
+ const core_1 = require("@vendure/core");
21
+ const node_fetch_1 = __importDefault(require("node-fetch"));
22
+ const constants_1 = require("../constants");
23
+ /**
24
+ * @description
25
+ * The StellateService is used to purge the Stellate cache when certain events occur.
26
+ *
27
+ * @docsCategory core plugins/StellatePlugin
28
+ */
29
+ let StellateService = class StellateService {
30
+ constructor(options) {
31
+ this.options = options;
32
+ this.purgeApiUrl = `https://admin.stellate.co/${options.serviceName}`;
33
+ }
34
+ /**
35
+ * @description
36
+ * Purges the cache for the given Products.
37
+ */
38
+ async purgeProducts(products) {
39
+ core_1.Logger.verbose(`Purging cache: Product(${products.map(p => p.id).join(', ')})`, constants_1.loggerCtx);
40
+ await this.purge('Product', products.map(p => p.id));
41
+ }
42
+ /**
43
+ * @description
44
+ * Purges the cache for the given ProductVariants.
45
+ */
46
+ async purgeProductVariants(productVariants) {
47
+ core_1.Logger.verbose(`Purging cache: ProductVariant(${productVariants.map(p => p.id).join(', ')})`, constants_1.loggerCtx);
48
+ await this.purge('ProductVariant', productVariants.map(p => p.id));
49
+ }
50
+ /**
51
+ * @description
52
+ * Purges the cache for SearchResults which contain the given Products or ProductVariants.
53
+ */
54
+ async purgeSearchResults(items) {
55
+ const productIds = items.map(item => (item instanceof core_1.Product ? item.id : item.productId));
56
+ core_1.Logger.verbose(`Purging cache: SearchResult(${productIds.join(', ')})`, constants_1.loggerCtx);
57
+ await this.purge('SearchResult', productIds, 'productId');
58
+ }
59
+ /**
60
+ * @description
61
+ * Purges the entire cache for the given type.
62
+ */
63
+ async purgeAllOfType(type) {
64
+ core_1.Logger.verbose(`Purging cache: All ${type}s`, constants_1.loggerCtx);
65
+ await this.purge(type);
66
+ }
67
+ /**
68
+ * @description
69
+ * Purges the cache for the given Collections.
70
+ */
71
+ async purgeCollections(collections) {
72
+ core_1.Logger.verbose(`Purging cache: Collection(${collections.map(c => c.id).join(', ')})`, constants_1.loggerCtx);
73
+ await this.purge('Collection', collections.map(p => p.id));
74
+ }
75
+ /**
76
+ * @description
77
+ * Purges the cache of SearchResults for the given Collections based on slug.
78
+ */
79
+ async purgeSearchResponseCacheIdentifiers(collections) {
80
+ const slugs = collections.map(c => { var _a, _b, _c; return (_a = c.slug) !== null && _a !== void 0 ? _a : (_c = (_b = c.translations) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.slug; });
81
+ if (slugs.length) {
82
+ core_1.Logger.verbose(`Purging cache: SearchResponseCacheIdentifier(${slugs.join(', ')})`, constants_1.loggerCtx);
83
+ await this.purge('SearchResponseCacheIdentifier', slugs);
84
+ }
85
+ }
86
+ /**
87
+ * @description
88
+ * Purges the cache for the given type and keys.
89
+ */
90
+ purge(type, keys, keyName = 'id') {
91
+ var _a, _b, _c;
92
+ const payload = {
93
+ query: `
94
+ mutation PurgeType($type: String!, $keyFields: [KeyFieldInput!]) {
95
+ _purgeType(type: $type, keyFields: $keyFields)
96
+ }
97
+ `,
98
+ variables: {
99
+ type,
100
+ keyFields: keys === null || keys === void 0 ? void 0 : keys.filter(id => !!id).map(id => ({ name: keyName, value: id.toString() })),
101
+ },
102
+ };
103
+ if (this.options.debugLogging === true) {
104
+ const keyFieldsLength = (_b = (_a = payload.variables.keyFields) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
105
+ if (5 < keyFieldsLength) {
106
+ payload.variables.keyFields = (_c = payload.variables.keyFields) === null || _c === void 0 ? void 0 : _c.slice(0, 5);
107
+ }
108
+ core_1.Logger.debug('Purge arguments:\n' + JSON.stringify(payload.variables, null, 2), constants_1.loggerCtx);
109
+ if (5 < keyFieldsLength) {
110
+ core_1.Logger.debug(`(A further ${keyFieldsLength - 5} keyFields truncated)`, constants_1.loggerCtx);
111
+ }
112
+ }
113
+ if (this.options.devMode === true) {
114
+ // no-op
115
+ }
116
+ else {
117
+ return (0, node_fetch_1.default)(this.purgeApiUrl, {
118
+ method: 'POST',
119
+ headers: {
120
+ 'Content-Type': 'application/json',
121
+ 'stellate-token': this.options.apiToken,
122
+ },
123
+ body: JSON.stringify(payload),
124
+ timeout: 5000,
125
+ })
126
+ .then(res => res.json())
127
+ .then(json => {
128
+ var _a, _b, _c;
129
+ if (((_a = json.data) === null || _a === void 0 ? void 0 : _a._purgeType) !== true) {
130
+ const errors = (_b = json.errors) === null || _b === void 0 ? void 0 : _b.map((e) => e.message);
131
+ core_1.Logger.error(`Purge failed: ${(_c = errors.join(', ')) !== null && _c !== void 0 ? _c : JSON.stringify(json)}`, constants_1.loggerCtx);
132
+ }
133
+ })
134
+ .catch((err) => {
135
+ core_1.Logger.error(`Purge error: ${err.message}`, constants_1.loggerCtx);
136
+ });
137
+ }
138
+ }
139
+ };
140
+ StellateService = __decorate([
141
+ __param(0, (0, common_1.Inject)(constants_1.STELLATE_PLUGIN_OPTIONS)),
142
+ __metadata("design:paramtypes", [Object])
143
+ ], StellateService);
144
+ exports.StellateService = StellateService;
145
+ //# sourceMappingURL=stellate.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stellate.service.js","sourceRoot":"","sources":["../../../src/service/stellate.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,wCAAgF;AAChF,4DAA+B;AAE/B,4CAAkE;AAYlE;;;;;GAKG;AACI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGxB,YAAqD,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;QAC/E,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,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;iBACvB,IAAI,CAAC,IAAI,CAAC,EAAE;;gBACT,IAAI,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,UAAU,MAAK,IAAI,EAAE;oBAChC,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAa,CAAC;oBACnE,aAAM,CAAC,KAAK,CAAC,iBAAiB,MAAA,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,qBAAS,CAAC,CAAC;iBACzF;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;gBAChB,aAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,OAAiB,EAAE,EAAE,qBAAS,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC;SACV;IACL,CAAC;CACJ,CAAA;AA/HY,eAAe;IAGX,WAAA,IAAA,eAAM,EAAC,mCAAuB,CAAC,CAAA;;GAHnC,eAAe,CA+H3B;AA/HY,0CAAe"}
@@ -0,0 +1,244 @@
1
+ import { OnApplicationBootstrap } from '@nestjs/common';
2
+ import { ModuleRef } from '@nestjs/core';
3
+ import { EventBus } from '@vendure/core';
4
+ import { StellateService } from './service/stellate.service';
5
+ import { StellatePluginOptions } from './types';
6
+ /**
7
+ * @description
8
+ * A plugin to integrate the [Stellate](https://stellate.co/) GraphQL caching service with your Vendure server.
9
+ * The main purpose of this plugin is to ensure that cached data gets correctly purged in
10
+ * response to events inside Vendure. For example, changes to a Product's description should
11
+ * purge any associated record for that Product in Stellate's cache.
12
+ *
13
+ * ## Pre-requisites
14
+ *
15
+ * You will first need to [set up a free Stellate account](https://stellate.co/signup).
16
+ *
17
+ * You will also need to generate an **API token** for the Stellate Purging API. For instructions on how to generate the token,
18
+ * see the [Stellate Purging API docs](https://docs.stellate.co/docs/purging-api#authentication).
19
+ *
20
+ * ## Installation
21
+ *
22
+ * ```
23
+ * npm install \@vendure/stellate-plugin
24
+ * ```
25
+ *
26
+ * ## Configuration
27
+ *
28
+ * The plugin is configured via the `StellatePlugin.init()` method. This method accepts an options object
29
+ * which defines the Stellate service name and API token, as well as an array of {@link PurgeRule}s which
30
+ * define how the plugin will respond to Vendure events in order to trigger calls to the
31
+ * Stellate [Purging API](https://stellate.co/docs/graphql-edge-cache/purging-api).
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { StellatePlugin, defaultPurgeRules } from '\@vendure/stellate-plugin';
36
+ * import { VendureConfig } from '\@vendure/core';
37
+ *
38
+ * export const config: VendureConfig = {
39
+ * // ...
40
+ * plugins: [
41
+ * StellatePlugin.init({
42
+ * // The Stellate service name, i.e. `<serviceName>.stellate.sh`
43
+ * serviceName: 'my-service',
44
+ * // The API token for the Stellate Purging API. See the "pre-requisites" section above.
45
+ * apiToken: process.env.STELLATE_PURGE_API_TOKEN,
46
+ * debugMode: !isProd || process.env.STELLATE_DEBUG_MODE ? true : false,
47
+ * debugLogging: process.env.STELLATE_DEBUG_MODE ? true : false,
48
+ * purgeRules: [
49
+ * ...defaultPurgeRules,
50
+ * // custom purge rules can be added here
51
+ * ],
52
+ * }),
53
+ * ],
54
+ * };
55
+ * ```
56
+ *
57
+ * In your Stellate dashboard, you can use the following configuration example as a sensible default for a
58
+ * Vendure application:
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { Config } from "stellate";
63
+ *
64
+ * const config: Config = {
65
+ * config: {
66
+ * name: "my-vendure-server",
67
+ * originUrl: "https://my-vendure-server.com/shop-api",
68
+ * ignoreOriginCacheControl: true,
69
+ * passThroughOnly: false,
70
+ * scopes: {
71
+ * SESSION_BOUND: "header:authorization|cookie:session",
72
+ * },
73
+ * headers: {
74
+ * "access-control-expose-headers": "vendure-auth-token",
75
+ * },
76
+ * rootTypeNames: {
77
+ * query: "Query",
78
+ * mutation: "Mutation",
79
+ * },
80
+ * keyFields: {
81
+ * types: {
82
+ * SearchResult: ["productId"],
83
+ * SearchResponseCacheIdentifier: ["collectionSlug"],
84
+ * },
85
+ * },
86
+ * rules: [
87
+ * {
88
+ * types: [
89
+ * "Product",
90
+ * "Collection",
91
+ * "ProductVariant",
92
+ * "SearchResponse",
93
+ * ],
94
+ * maxAge: 900,
95
+ * swr: 900,
96
+ * description: "Cache Products & Collections",
97
+ * },
98
+ * {
99
+ * types: ["Channel"],
100
+ * maxAge: 9000,
101
+ * swr: 9000,
102
+ * description: "Cache active channel",
103
+ * },
104
+ * {
105
+ * types: ["Order", "Customer", "User"],
106
+ * maxAge: 0,
107
+ * swr: 0,
108
+ * description: "Do not cache user data",
109
+ * },
110
+ * ],
111
+ * },
112
+ * };
113
+ * export default config;
114
+ * ```
115
+ *
116
+ * ## Storefront setup
117
+ *
118
+ * In your storefront, you should point your GraphQL client to the Stellate GraphQL API endpoint, which is
119
+ * `https://<service-name>.stellate.sh`.
120
+ *
121
+ * Wherever you are using the `search` query (typically in product listing & search pages), you should also add the
122
+ * `cacheIdentifier` field to the query. This will ensure that the Stellate cache is correctly purged when
123
+ * a Product or Collection is updated.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { graphql } from '../generated/gql';
128
+ *
129
+ * export const searchProductsDocument = graphql(`
130
+ * query SearchProducts($input: SearchInput!) {
131
+ * search(input: $input) {
132
+ * // highlight-start
133
+ * cacheIdentifier {
134
+ * collectionSlug
135
+ * }
136
+ * // highlight-end
137
+ * items {
138
+ * # ...
139
+ * }
140
+ * }
141
+ * }
142
+ * }`);
143
+ * ```
144
+ *
145
+ * ## Custom PurgeRules
146
+ *
147
+ * The configuration above only accounts for caching of some of the built-in Vendure entity types. If you have
148
+ * custom entity types, you may well want to add them to the Stellate cache. In this case, you'll also need a way to
149
+ * purge those entities from the cache when they are updated. This is where the {@link PurgeRule} comes in.
150
+ *
151
+ * Let's imagine that you have built a simple CMS plugin for Vendure which exposes an `Article` entity in your Shop API, and
152
+ * you have added this to your Stellate configuration:
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { Config } from "stellate";
157
+ *
158
+ * const config: Config = {
159
+ * config: {
160
+ * // ...
161
+ * rules: [
162
+ * // ...
163
+ * {
164
+ * types: ["Article"],
165
+ * maxAge: 900,
166
+ * swr: 900,
167
+ * description: "Cache Articles",
168
+ * },
169
+ * ],
170
+ * },
171
+ * // ...
172
+ * };
173
+ * export default config;
174
+ * ```
175
+ *
176
+ * You can then add a custom {@link PurgeRule} to the StellatePlugin configuration:
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * import { StellatePlugin, defaultPurgeRules } from "\@vendure/stellate-plugin";
181
+ * import { VendureConfig } from "\@vendure/core";
182
+ * import { ArticleEvent } from "./plugins/cms/events/article-event";
183
+ *
184
+ * export const config: VendureConfig = {
185
+ * // ...
186
+ * plugins: [
187
+ * StellatePlugin.init({
188
+ * // ...
189
+ * purgeRules: [
190
+ * ...defaultPurgeRules,
191
+ * new PurgeRule({
192
+ * eventType: ArticleEvent,
193
+ * handler: async ({ events, stellateService }) => {
194
+ * const articleIds = events.map((e) => e.article.id);
195
+ * stellateService.purge("Article", articleIds);
196
+ * },
197
+ * }),
198
+ * ],
199
+ * }),
200
+ * ],
201
+ * };
202
+ * ```
203
+ *
204
+ * ## DevMode & Debug Logging
205
+ *
206
+ * In development, you can set `devMode: true`, which will prevent any calls being made to the Stellate Purging API.
207
+ *
208
+ * If you want to log the calls that _would_ be made to the Stellate Purge API when in devMode, you can set `debugLogging: true`.
209
+ * Note that debugLogging generates a lot of debug-level logging, so it is recommended to only enable this when needed.
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * import { StellatePlugin, defaultPurgeRules } from '\@vendure/stellate-plugin';
214
+ * import { VendureConfig } from '\@vendure/core';
215
+ *
216
+ * export const config: VendureConfig = {
217
+ * // ...
218
+ * plugins: [
219
+ * StellatePlugin.init({
220
+ * // ...
221
+ * devMode: !process.env.PRODUCTION,
222
+ * debugLogging: process.env.STELLATE_DEBUG_MODE ? true : false,
223
+ * purgeRules: [
224
+ * ...defaultPurgeRules,
225
+ * ],
226
+ * }),
227
+ * ],
228
+ * };
229
+ * ```
230
+ *
231
+ *
232
+ * @since 2.1.5
233
+ * @docsCategory core plugins/StellatePlugin
234
+ */
235
+ export declare class StellatePlugin implements OnApplicationBootstrap {
236
+ private options;
237
+ private eventBus;
238
+ private stellateService;
239
+ private moduleRef;
240
+ static options: StellatePluginOptions;
241
+ static init(options: StellatePluginOptions): typeof StellatePlugin;
242
+ constructor(options: StellatePluginOptions, eventBus: EventBus, stellateService: StellateService, moduleRef: ModuleRef);
243
+ onApplicationBootstrap(): void;
244
+ }
@@ -0,0 +1,295 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.StellatePlugin = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const core_1 = require("@nestjs/core");
18
+ const core_2 = require("@vendure/core");
19
+ const operators_1 = require("rxjs/operators");
20
+ const api_extensions_1 = require("./api/api-extensions");
21
+ const search_response_resolver_1 = require("./api/search-response.resolver");
22
+ const constants_1 = require("./constants");
23
+ const stellate_service_1 = require("./service/stellate.service");
24
+ const StellateOptionsProvider = {
25
+ provide: constants_1.STELLATE_PLUGIN_OPTIONS,
26
+ useFactory: () => StellatePlugin.options,
27
+ };
28
+ /**
29
+ * @description
30
+ * A plugin to integrate the [Stellate](https://stellate.co/) GraphQL caching service with your Vendure server.
31
+ * The main purpose of this plugin is to ensure that cached data gets correctly purged in
32
+ * response to events inside Vendure. For example, changes to a Product's description should
33
+ * purge any associated record for that Product in Stellate's cache.
34
+ *
35
+ * ## Pre-requisites
36
+ *
37
+ * You will first need to [set up a free Stellate account](https://stellate.co/signup).
38
+ *
39
+ * You will also need to generate an **API token** for the Stellate Purging API. For instructions on how to generate the token,
40
+ * see the [Stellate Purging API docs](https://docs.stellate.co/docs/purging-api#authentication).
41
+ *
42
+ * ## Installation
43
+ *
44
+ * ```
45
+ * npm install \@vendure/stellate-plugin
46
+ * ```
47
+ *
48
+ * ## Configuration
49
+ *
50
+ * The plugin is configured via the `StellatePlugin.init()` method. This method accepts an options object
51
+ * which defines the Stellate service name and API token, as well as an array of {@link PurgeRule}s which
52
+ * define how the plugin will respond to Vendure events in order to trigger calls to the
53
+ * Stellate [Purging API](https://stellate.co/docs/graphql-edge-cache/purging-api).
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { StellatePlugin, defaultPurgeRules } from '\@vendure/stellate-plugin';
58
+ * import { VendureConfig } from '\@vendure/core';
59
+ *
60
+ * export const config: VendureConfig = {
61
+ * // ...
62
+ * plugins: [
63
+ * StellatePlugin.init({
64
+ * // The Stellate service name, i.e. `<serviceName>.stellate.sh`
65
+ * serviceName: 'my-service',
66
+ * // The API token for the Stellate Purging API. See the "pre-requisites" section above.
67
+ * apiToken: process.env.STELLATE_PURGE_API_TOKEN,
68
+ * debugMode: !isProd || process.env.STELLATE_DEBUG_MODE ? true : false,
69
+ * debugLogging: process.env.STELLATE_DEBUG_MODE ? true : false,
70
+ * purgeRules: [
71
+ * ...defaultPurgeRules,
72
+ * // custom purge rules can be added here
73
+ * ],
74
+ * }),
75
+ * ],
76
+ * };
77
+ * ```
78
+ *
79
+ * In your Stellate dashboard, you can use the following configuration example as a sensible default for a
80
+ * Vendure application:
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { Config } from "stellate";
85
+ *
86
+ * const config: Config = {
87
+ * config: {
88
+ * name: "my-vendure-server",
89
+ * originUrl: "https://my-vendure-server.com/shop-api",
90
+ * ignoreOriginCacheControl: true,
91
+ * passThroughOnly: false,
92
+ * scopes: {
93
+ * SESSION_BOUND: "header:authorization|cookie:session",
94
+ * },
95
+ * headers: {
96
+ * "access-control-expose-headers": "vendure-auth-token",
97
+ * },
98
+ * rootTypeNames: {
99
+ * query: "Query",
100
+ * mutation: "Mutation",
101
+ * },
102
+ * keyFields: {
103
+ * types: {
104
+ * SearchResult: ["productId"],
105
+ * SearchResponseCacheIdentifier: ["collectionSlug"],
106
+ * },
107
+ * },
108
+ * rules: [
109
+ * {
110
+ * types: [
111
+ * "Product",
112
+ * "Collection",
113
+ * "ProductVariant",
114
+ * "SearchResponse",
115
+ * ],
116
+ * maxAge: 900,
117
+ * swr: 900,
118
+ * description: "Cache Products & Collections",
119
+ * },
120
+ * {
121
+ * types: ["Channel"],
122
+ * maxAge: 9000,
123
+ * swr: 9000,
124
+ * description: "Cache active channel",
125
+ * },
126
+ * {
127
+ * types: ["Order", "Customer", "User"],
128
+ * maxAge: 0,
129
+ * swr: 0,
130
+ * description: "Do not cache user data",
131
+ * },
132
+ * ],
133
+ * },
134
+ * };
135
+ * export default config;
136
+ * ```
137
+ *
138
+ * ## Storefront setup
139
+ *
140
+ * In your storefront, you should point your GraphQL client to the Stellate GraphQL API endpoint, which is
141
+ * `https://<service-name>.stellate.sh`.
142
+ *
143
+ * Wherever you are using the `search` query (typically in product listing & search pages), you should also add the
144
+ * `cacheIdentifier` field to the query. This will ensure that the Stellate cache is correctly purged when
145
+ * a Product or Collection is updated.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * import { graphql } from '../generated/gql';
150
+ *
151
+ * export const searchProductsDocument = graphql(`
152
+ * query SearchProducts($input: SearchInput!) {
153
+ * search(input: $input) {
154
+ * // highlight-start
155
+ * cacheIdentifier {
156
+ * collectionSlug
157
+ * }
158
+ * // highlight-end
159
+ * items {
160
+ * # ...
161
+ * }
162
+ * }
163
+ * }
164
+ * }`);
165
+ * ```
166
+ *
167
+ * ## Custom PurgeRules
168
+ *
169
+ * The configuration above only accounts for caching of some of the built-in Vendure entity types. If you have
170
+ * custom entity types, you may well want to add them to the Stellate cache. In this case, you'll also need a way to
171
+ * purge those entities from the cache when they are updated. This is where the {@link PurgeRule} comes in.
172
+ *
173
+ * Let's imagine that you have built a simple CMS plugin for Vendure which exposes an `Article` entity in your Shop API, and
174
+ * you have added this to your Stellate configuration:
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { Config } from "stellate";
179
+ *
180
+ * const config: Config = {
181
+ * config: {
182
+ * // ...
183
+ * rules: [
184
+ * // ...
185
+ * {
186
+ * types: ["Article"],
187
+ * maxAge: 900,
188
+ * swr: 900,
189
+ * description: "Cache Articles",
190
+ * },
191
+ * ],
192
+ * },
193
+ * // ...
194
+ * };
195
+ * export default config;
196
+ * ```
197
+ *
198
+ * You can then add a custom {@link PurgeRule} to the StellatePlugin configuration:
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * import { StellatePlugin, defaultPurgeRules } from "\@vendure/stellate-plugin";
203
+ * import { VendureConfig } from "\@vendure/core";
204
+ * import { ArticleEvent } from "./plugins/cms/events/article-event";
205
+ *
206
+ * export const config: VendureConfig = {
207
+ * // ...
208
+ * plugins: [
209
+ * StellatePlugin.init({
210
+ * // ...
211
+ * purgeRules: [
212
+ * ...defaultPurgeRules,
213
+ * new PurgeRule({
214
+ * eventType: ArticleEvent,
215
+ * handler: async ({ events, stellateService }) => {
216
+ * const articleIds = events.map((e) => e.article.id);
217
+ * stellateService.purge("Article", articleIds);
218
+ * },
219
+ * }),
220
+ * ],
221
+ * }),
222
+ * ],
223
+ * };
224
+ * ```
225
+ *
226
+ * ## DevMode & Debug Logging
227
+ *
228
+ * In development, you can set `devMode: true`, which will prevent any calls being made to the Stellate Purging API.
229
+ *
230
+ * If you want to log the calls that _would_ be made to the Stellate Purge API when in devMode, you can set `debugLogging: true`.
231
+ * Note that debugLogging generates a lot of debug-level logging, so it is recommended to only enable this when needed.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * import { StellatePlugin, defaultPurgeRules } from '\@vendure/stellate-plugin';
236
+ * import { VendureConfig } from '\@vendure/core';
237
+ *
238
+ * export const config: VendureConfig = {
239
+ * // ...
240
+ * plugins: [
241
+ * StellatePlugin.init({
242
+ * // ...
243
+ * devMode: !process.env.PRODUCTION,
244
+ * debugLogging: process.env.STELLATE_DEBUG_MODE ? true : false,
245
+ * purgeRules: [
246
+ * ...defaultPurgeRules,
247
+ * ],
248
+ * }),
249
+ * ],
250
+ * };
251
+ * ```
252
+ *
253
+ *
254
+ * @since 2.1.5
255
+ * @docsCategory core plugins/StellatePlugin
256
+ */
257
+ let StellatePlugin = class StellatePlugin {
258
+ static init(options) {
259
+ this.options = options;
260
+ return this;
261
+ }
262
+ constructor(options, eventBus, stellateService, moduleRef) {
263
+ this.options = options;
264
+ this.eventBus = eventBus;
265
+ this.stellateService = stellateService;
266
+ this.moduleRef = moduleRef;
267
+ }
268
+ onApplicationBootstrap() {
269
+ var _a, _b, _c;
270
+ const injector = new core_2.Injector(this.moduleRef);
271
+ for (const purgeRule of (_a = this.options.purgeRules) !== null && _a !== void 0 ? _a : []) {
272
+ const source$ = this.eventBus.ofType(purgeRule.eventType);
273
+ source$
274
+ .pipe((0, operators_1.buffer)(source$.pipe((0, operators_1.debounceTime)((_c = (_b = purgeRule.bufferTimeMs) !== null && _b !== void 0 ? _b : this.options.defaultBufferTimeMs) !== null && _c !== void 0 ? _c : 2000))))
275
+ .subscribe(events => purgeRule.handle({ events, injector, stellateService: this.stellateService }));
276
+ }
277
+ }
278
+ };
279
+ StellatePlugin = __decorate([
280
+ (0, core_2.VendurePlugin)({
281
+ imports: [core_2.PluginCommonModule],
282
+ providers: [StellateOptionsProvider, stellate_service_1.StellateService],
283
+ shopApiExtensions: {
284
+ schema: api_extensions_1.shopApiExtensions,
285
+ resolvers: [search_response_resolver_1.SearchResponseFieldResolver],
286
+ },
287
+ compatibility: '^2.0.0',
288
+ }),
289
+ __param(0, (0, common_1.Inject)(constants_1.STELLATE_PLUGIN_OPTIONS)),
290
+ __metadata("design:paramtypes", [Object, core_2.EventBus,
291
+ stellate_service_1.StellateService,
292
+ core_1.ModuleRef])
293
+ ], StellatePlugin);
294
+ exports.StellatePlugin = StellatePlugin;
295
+ //# sourceMappingURL=stellate-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stellate-plugin.js","sourceRoot":"","sources":["../../src/stellate-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,uCAAyC;AACzC,wCAAsF;AACtF,8CAAsD;AAEtD,yDAAyD;AACzD,6EAA6E;AAC7E,2CAAsD;AACtD,iEAA6D;AAG7D,MAAM,uBAAuB,GAAG;IAC5B,OAAO,EAAE,mCAAuB;IAChC,UAAU,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoOG;AAUI,IAAM,cAAc,GAApB,MAAM,cAAc;IAGvB,MAAM,CAAC,IAAI,CAAC,OAA8B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAA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C1B;AAjCY,wCAAc"}
@@ -0,0 +1,51 @@
1
+ import { PurgeRule } from './purge-rule';
2
+ /**
3
+ * @description
4
+ * Configuration options for the StellatePlugin.
5
+ *
6
+ * @docsCategory core plugins/StellatePlugin
7
+ */
8
+ export interface StellatePluginOptions {
9
+ /**
10
+ * @description
11
+ * The Stellate service name, i.e. `<service-name>.stellate.sh`
12
+ */
13
+ serviceName: string;
14
+ /**
15
+ * @description
16
+ * The Stellate Purging API token. For instructions on how to generate the token,
17
+ * see the [Stellate docs](https://docs.stellate.co/docs/purging-api#authentication)
18
+ */
19
+ apiToken: string;
20
+ /**
21
+ * @description
22
+ * An array of {@link PurgeRule} instances which are used to define how the plugin will
23
+ * respond to Vendure events in order to trigger calls to the Stellate Purging API.
24
+ */
25
+ purgeRules: PurgeRule[];
26
+ /**
27
+ * @description
28
+ * When events are published, the PurgeRules will buffer those events in order to efficiently
29
+ * batch requests to the Stellate Purging API. You may wish to change the default, e.g. if you are
30
+ * running in a serverless environment and cannot introduce pauses after the main request has completed.
31
+ *
32
+ * @default 2000
33
+ */
34
+ defaultBufferTimeMs?: number;
35
+ /**
36
+ * @description
37
+ * When set to `true`, calls will not be made to the Stellate Purge API.
38
+ *
39
+ * @default false
40
+ */
41
+ devMode?: boolean;
42
+ /**
43
+ * @description
44
+ * If set to true, the plugin will log the calls that would be made
45
+ * to the Stellate Purge API. Note, this generates a
46
+ * lot of debug-level logging.
47
+ *
48
+ * @default false
49
+ */
50
+ debugLogging?: boolean;
51
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@vendure/stellate-plugin",
3
+ "version": "2.1.4",
4
+ "license": "MIT",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/**/*"
9
+ ],
10
+ "scripts": {
11
+ "watch": "tsc -p ./tsconfig.build.json --watch",
12
+ "build": "rimraf lib && tsc -p ./tsconfig.build.json",
13
+ "lint": "eslint --fix ."
14
+ },
15
+ "homepage": "https://www.vendure.io",
16
+ "funding": "https://github.com/sponsors/michaelbromley",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "node-fetch": "^2.7.0"
22
+ },
23
+ "devDependencies": {
24
+ "@vendure/common": "^2.1.4",
25
+ "@vendure/core": "^2.1.4"
26
+ }
27
+ }