@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.0 → 0.1.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegan-friendly/strapi-plugin-elasticsearch",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "A Strapi plugin to enable using Elasticsearch with Strapi CMS.",
5
5
  "homepage": "https://github.com/vegan-friendly/strapi-plugin-elasticsearch",
6
6
  "strapi": {
@@ -1,102 +1,3 @@
1
- /**
2
- * Service to manage virtual collections for Elasticsearch indexing
3
- */
4
- module.exports = ({ strapi }) => {
5
- // Registry to hold all virtual collection definitions
6
- const virtualCollections = new Map();
7
-
8
- return {
9
- /**
10
- * Initialize the registry from the plugin configuration
11
- */
12
- initialize() {
13
- // Get the plugin configuration
14
- const pluginConfig = strapi.config.get('plugin.elasticsearch') || {};
15
- const virtualCollectionsConfig = pluginConfig.virtualCollections || [];
16
-
17
- // Register each virtual collection from the config
18
- virtualCollectionsConfig.forEach((config) => {
19
- this.register(config);
20
- });
21
-
22
- strapi.log.info(
23
- `Initialized ${virtualCollections.size} virtual collections for Elasticsearch indexing`
24
- );
25
- },
26
-
27
- /**
28
- * Register a new virtual collection for indexing
29
- * @param {Object} config - Configuration for the virtual collection
30
- * @param {string} config.indexName - Name of the index in Elasticsearch
31
- * @param {string} config.collectionName - Name identifier for the virtual collection
32
- * @param {Function} config.extractData - Function that returns data to be indexed (with pagination)
33
- * @param {Array<Object>} config.triggers - Array of collection triggers that should cause reindexing
34
- * @param {Function} config.mapToIndex - Function that maps extracted data to Elasticsearch document
35
- */
36
- register(config) {
37
- if (!config.indexName || typeof config.indexName !== 'string') {
38
- throw new Error('Virtual collection must have an indexName');
39
- }
40
-
41
- if (!config.collectionName || typeof config.collectionName !== 'string') {
42
- throw new Error('Virtual collection must have a collectionName');
43
- }
44
-
45
- if (typeof config.extractData !== 'function') {
46
- throw new Error('Virtual collection must have an extractData function');
47
- }
48
-
49
- if (!Array.isArray(config.triggers)) {
50
- throw new Error('Virtual collection must have triggers defined');
51
- }
52
-
53
- if (typeof config.mapToIndex !== 'function') {
54
- throw new Error('Virtual collection must have a mapToIndex function');
55
- }
56
-
57
- virtualCollections.set(config.collectionName, config);
58
- strapi.log.info(
59
- `Registered virtual collection for Elasticsearch: ${config.collectionName} -> ${config.indexName}`
60
- );
61
-
62
- return this;
63
- },
64
-
65
- /**
66
- * Get all registered virtual collections
67
- */
68
- getAll() {
69
- return Array.from(virtualCollections.values());
70
- },
71
-
72
- /**
73
- * Get a specific virtual collection by name
74
- */
75
- get(collectionName) {
76
- return virtualCollections.get(collectionName);
77
- },
78
-
79
- /**
80
- * Find virtual collections that should be triggered when a specific collection changes
81
- */
82
- findTriggersByCollection(collectionUID) {
83
- const results = [];
84
-
85
- virtualCollections.forEach((config) => {
86
- const hasTrigger = config.triggers.some((trigger) => trigger.collection === collectionUID);
87
-
88
- if (hasTrigger) {
89
- results.push(config);
90
- }
91
- });
92
-
93
- return results;
94
- },
95
- };
96
- };
97
-
98
- // path: ./src/extensions/strapi-plugin-elasticsearch/services/virtual-collections-indexer.js
99
-
100
1
  /**
101
2
  * Service to handle indexing of virtual collections
102
3
  */