@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.3 → 0.2.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/dist/admin/index.js +4 -4
- package/dist/admin/pluginId.js +1 -1
- package/dist/admin/src/components/Initializer/index.js +2 -1
- package/dist/admin/src/components/SubNavigation/index.js +10 -8
- package/dist/admin/src/pages/ConfigureCollectionList/index.js +40 -28
- package/dist/admin/src/pages/Homepage/index.js +20 -21
- package/dist/admin/src/pluginId.d.ts +1 -1
- package/dist/admin/src/utils/apiUrls.js +1 -0
- package/dist/admin/src/utils/axiosInstance.js +3 -4
- package/dist/package.json +64 -0
- package/dist/server/bootstrap.d.ts +4 -0
- package/dist/server/bootstrap.js +31 -5
- package/dist/server/config/index.d.ts +5 -0
- package/dist/server/config/index.js +2 -1
- package/dist/server/content-types/index.d.ts +83 -2
- package/dist/server/content-types/index.js +9 -5
- package/dist/server/content-types/indexing-logs.d.ts +32 -0
- package/dist/server/content-types/indexing-logs.js +22 -24
- package/dist/server/content-types/tasks.d.ts +46 -0
- package/dist/server/content-types/tasks.js +33 -38
- package/dist/server/controllers/configure-indexing.d.ts +11 -0
- package/dist/server/controllers/configure-indexing.js +3 -2
- package/dist/server/controllers/index.d.ts +33 -5
- package/dist/server/controllers/index.js +15 -11
- package/dist/server/controllers/log-indexing.d.ts +6 -0
- package/dist/server/controllers/log-indexing.js +3 -2
- package/dist/server/controllers/perform-indexing.d.ts +8 -0
- package/dist/server/controllers/perform-indexing.js +3 -2
- package/dist/server/controllers/perform-search.d.ts +4 -1
- package/dist/server/controllers/perform-search.js +11 -8
- package/dist/server/controllers/setup-info.d.ts +6 -0
- package/dist/server/controllers/setup-info.js +2 -1
- package/dist/server/destroy.d.ts +4 -0
- package/dist/server/destroy.js +2 -1
- package/dist/server/index.d.ts +296 -10
- package/dist/server/index.js +40 -21
- package/dist/server/middlewares/index.d.ts +2 -0
- package/dist/server/middlewares/index.js +2 -1
- package/dist/server/policies/index.d.ts +2 -0
- package/dist/server/policies/index.js +2 -1
- package/dist/server/register.d.ts +4 -0
- package/dist/server/register.js +2 -1
- package/dist/server/routes/configure-indexing.d.ts +12 -0
- package/dist/server/routes/configure-indexing.js +2 -1
- package/dist/server/routes/index.d.ts +58 -5
- package/dist/server/routes/index.js +15 -11
- package/dist/server/routes/perform-indexing.d.ts +12 -0
- package/dist/server/routes/perform-indexing.js +2 -1
- package/dist/server/routes/perform-search.d.ts +12 -0
- package/dist/server/routes/perform-search.js +4 -3
- package/dist/server/routes/run-log.d.ts +12 -0
- package/dist/server/routes/run-log.js +3 -2
- package/dist/server/routes/setup-info.d.ts +12 -0
- package/dist/server/routes/setup-info.js +3 -2
- package/dist/server/services/configure-indexing.d.ts +23 -23
- package/dist/server/services/configure-indexing.js +32 -20
- package/dist/server/services/es-interface.d.ts +5 -4
- package/dist/server/services/es-interface.js +19 -20
- package/dist/server/services/helper.d.ts +34 -33
- package/dist/server/services/helper.js +65 -61
- package/dist/server/services/index.d.ts +107 -7
- package/dist/server/services/index.js +23 -15
- package/dist/server/services/log-indexing.d.ts +8 -0
- package/dist/server/services/log-indexing.js +8 -7
- package/dist/server/services/perform-indexing.d.ts +8 -0
- package/dist/server/services/perform-indexing.js +35 -17
- package/dist/server/services/schedule-indexing.d.ts +19 -0
- package/dist/server/services/schedule-indexing.js +13 -12
- package/dist/server/services/transform-content.d.ts +7 -2
- package/dist/server/services/transform-content.js +4 -3
- package/dist/server/services/virtual-collections-indexer.d.ts +8 -0
- package/dist/server/services/virtual-collections-indexer.js +142 -0
- package/dist/server/services/virtual-collections-registry.d.ts +8 -0
- package/dist/server/services/virtual-collections-registry.js +32 -0
- package/dist/server/types/esInterface.type.d.ts +70 -0
- package/dist/server/types/esInterface.type.js +2 -0
- package/dist/server/types/index.d.ts +2 -0
- package/dist/server/types/index.js +18 -0
- package/dist/server/types/virtual-collections.d.ts +30 -0
- package/dist/server/types/virtual-collections.js +2 -0
- package/dist/server/types/virtual-collections.type.d.ts +57 -0
- package/dist/server/types/virtual-collections.type.js +2 -0
- package/package.json +6 -3
- package/dist/admin/components/Initializer/index.d.ts +0 -15
- package/dist/admin/components/Initializer/index.js +0 -25
- package/dist/admin/components/PluginIcon/index.d.ts +0 -8
- package/dist/admin/components/PluginIcon/index.js +0 -14
- package/dist/admin/components/SubNavigation/index.d.ts +0 -4
- package/dist/admin/components/SubNavigation/index.js +0 -40
- package/dist/admin/pages/App/index.d.ts +0 -9
- package/dist/admin/pages/App/index.js +0 -29
- package/dist/admin/pages/ConfigureCollection/index.d.ts +0 -3
- package/dist/admin/pages/ConfigureCollection/index.js +0 -193
- package/dist/admin/pages/ConfigureCollectionList/index.d.ts +0 -3
- package/dist/admin/pages/ConfigureCollectionList/index.js +0 -228
- package/dist/admin/pages/Homepage/index.d.ts +0 -3
- package/dist/admin/pages/Homepage/index.js +0 -155
- package/dist/admin/pages/ViewIndexingRunLog/index.d.ts +0 -3
- package/dist/admin/pages/ViewIndexingRunLog/index.js +0 -125
- package/dist/admin/utils/apiUrls.d.ts +0 -10
- package/dist/admin/utils/apiUrls.js +0 -20
- package/dist/admin/utils/axiosInstance.d.ts +0 -5
- package/dist/admin/utils/axiosInstance.js +0 -33
- package/dist/admin/utils/getTrad.d.ts +0 -2
- package/dist/admin/utils/getTrad.js +0 -8
- package/dist/strapi-admin.d.ts +0 -0
- package/dist/strapi-admin.js +0 -2
- package/dist/strapi-server.d.ts +0 -0
- package/dist/strapi-server.js +0 -2
@@ -1,24 +1,24 @@
|
|
1
|
-
declare const
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}>): Promise<void>;
|
1
|
+
declare const _default: ({ strapi }: {
|
2
|
+
strapi: any;
|
3
|
+
}) => {
|
4
|
+
initializeStrapiElasticsearch(): Promise<void>;
|
5
|
+
markInitialized(): Promise<void>;
|
6
|
+
isInitialized(): any;
|
7
|
+
cacheConfig(): Promise<void>;
|
8
|
+
getCollectionConfig({ collectionName }: {
|
9
|
+
collectionName: any;
|
10
|
+
}): Promise<{} | null>;
|
11
|
+
getCollectionsConfiguredForIndexing(): Promise<string[]>;
|
12
|
+
isCollectionConfiguredToBeIndexed({ collectionName }: {
|
13
|
+
collectionName: any;
|
14
|
+
}): Promise<boolean>;
|
15
|
+
getContentConfig(): Promise<any>;
|
16
|
+
importContentConfig({ config }: {
|
17
|
+
config: any;
|
18
|
+
}): Promise<any>;
|
19
|
+
setContentConfig({ collection, config }: {
|
20
|
+
collection: any;
|
21
|
+
config: any;
|
22
|
+
}): Promise<any>;
|
24
23
|
};
|
24
|
+
export default _default;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
'use strict';
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2
3
|
const getPluginStore = () => {
|
3
4
|
return strapi.store({
|
4
5
|
environment: '',
|
@@ -6,7 +7,7 @@ const getPluginStore = () => {
|
|
6
7
|
name: 'elasticsearch',
|
7
8
|
});
|
8
9
|
};
|
9
|
-
|
10
|
+
exports.default = ({ strapi }) => ({
|
10
11
|
async initializeStrapiElasticsearch() {
|
11
12
|
await this.cacheConfig();
|
12
13
|
},
|
@@ -16,8 +17,7 @@ module.exports = ({ strapi }) => ({
|
|
16
17
|
strapi.elasticsearch.initialized = true;
|
17
18
|
},
|
18
19
|
isInitialized() {
|
19
|
-
|
20
|
-
return ((_a = strapi.elasticsearch) === null || _a === void 0 ? void 0 : _a.initialized) || false;
|
20
|
+
return strapi.elasticsearch?.initialized || false;
|
21
21
|
},
|
22
22
|
async cacheConfig() {
|
23
23
|
if (!strapi.elasticsearch)
|
@@ -57,7 +57,14 @@ module.exports = ({ strapi }) => ({
|
|
57
57
|
return collectionsToIndex.includes(collectionName);
|
58
58
|
},
|
59
59
|
async getContentConfig() {
|
60
|
-
const fieldsToExclude = [
|
60
|
+
const fieldsToExclude = [
|
61
|
+
'createdAt',
|
62
|
+
'createdBy',
|
63
|
+
'publishedAt',
|
64
|
+
'publishedBy',
|
65
|
+
'updatedAt',
|
66
|
+
'updatedBy',
|
67
|
+
];
|
61
68
|
const pluginStore = getPluginStore();
|
62
69
|
const settings = await pluginStore.get({ key: 'configsettings' });
|
63
70
|
const contentTypes = strapi.contentTypes;
|
@@ -69,16 +76,18 @@ module.exports = ({ strapi }) => ({
|
|
69
76
|
const listOfAttributes = Object.keys(collectionAttributes).filter((i) => fieldsToExclude.includes(i) === false);
|
70
77
|
for (let k = 0; k < listOfAttributes.length; k++) {
|
71
78
|
const currentAttribute = listOfAttributes[k];
|
72
|
-
let attributeType =
|
73
|
-
if (typeof collectionAttributes[currentAttribute][
|
74
|
-
|
75
|
-
if (collectionAttributes[currentAttribute][
|
76
|
-
attributeType =
|
77
|
-
else if (collectionAttributes[currentAttribute][
|
78
|
-
attributeType =
|
79
|
+
let attributeType = 'regular';
|
80
|
+
if (typeof collectionAttributes[currentAttribute]['type'] !== 'undefined' &&
|
81
|
+
collectionAttributes[currentAttribute]['type'] !== null) {
|
82
|
+
if (collectionAttributes[currentAttribute]['type'] === 'component')
|
83
|
+
attributeType = 'component';
|
84
|
+
else if (collectionAttributes[currentAttribute]['type'] === 'dynamiczone')
|
85
|
+
attributeType = 'dynamiczone';
|
79
86
|
}
|
80
|
-
apiContentConfig[apiContentTypes[r]][listOfAttributes[k]] = {
|
81
|
-
|
87
|
+
apiContentConfig[apiContentTypes[r]][listOfAttributes[k]] = {
|
88
|
+
index: false,
|
89
|
+
type: attributeType,
|
90
|
+
};
|
82
91
|
}
|
83
92
|
}
|
84
93
|
if (settings) {
|
@@ -90,12 +99,15 @@ module.exports = ({ strapi }) => ({
|
|
90
99
|
const attribsForCollection = Object.keys(apiContentConfig[collections[r]]);
|
91
100
|
for (let s = 0; s < attribsForCollection.length; s++) {
|
92
101
|
if (!Object.keys(objSettings['contentConfig'][collections[r]]).includes(attribsForCollection[s])) {
|
93
|
-
objSettings['contentConfig'][collections[r]][attribsForCollection[s]] = {
|
94
|
-
|
102
|
+
objSettings['contentConfig'][collections[r]][attribsForCollection[s]] = {
|
103
|
+
index: false,
|
104
|
+
type: apiContentConfig[collections[r]][attribsForCollection[s]].type,
|
105
|
+
};
|
95
106
|
}
|
96
107
|
else {
|
97
108
|
if (!Object.keys(objSettings['contentConfig'][collections[r]][attribsForCollection[s]]).includes('type'))
|
98
|
-
objSettings['contentConfig'][collections[r]][attribsForCollection[s]]['type'] =
|
109
|
+
objSettings['contentConfig'][collections[r]][attribsForCollection[s]]['type'] =
|
110
|
+
apiContentConfig[collections[r]][attribsForCollection[s]].type;
|
99
111
|
}
|
100
112
|
}
|
101
113
|
}
|
@@ -112,7 +124,7 @@ module.exports = ({ strapi }) => ({
|
|
112
124
|
},
|
113
125
|
async importContentConfig({ config }) {
|
114
126
|
const pluginStore = getPluginStore();
|
115
|
-
const settings = await pluginStore.get({ key: 'configsettings' });
|
127
|
+
const settings = (await pluginStore.get({ key: 'configsettings' }));
|
116
128
|
if (settings) {
|
117
129
|
const objSettings = JSON.parse(settings);
|
118
130
|
objSettings['contentConfig'] = JSON.parse(config);
|
@@ -120,7 +132,7 @@ module.exports = ({ strapi }) => ({
|
|
120
132
|
await pluginStore.set({ key: 'configsettings', value: stringifySettings });
|
121
133
|
}
|
122
134
|
else {
|
123
|
-
const newSettings = JSON.stringify({
|
135
|
+
const newSettings = JSON.stringify({ contentConfig: config });
|
124
136
|
await pluginStore.set({ key: 'configsettings', value: newSettings });
|
125
137
|
}
|
126
138
|
const updatedSettings = await pluginStore.get({ key: 'configsettings' });
|
@@ -132,7 +144,7 @@ module.exports = ({ strapi }) => ({
|
|
132
144
|
},
|
133
145
|
async setContentConfig({ collection, config }) {
|
134
146
|
const pluginStore = getPluginStore();
|
135
|
-
const settings = await pluginStore.get({ key: 'configsettings' });
|
147
|
+
const settings = (await pluginStore.get({ key: 'configsettings' }));
|
136
148
|
if (settings) {
|
137
149
|
const objSettings = JSON.parse(settings);
|
138
150
|
if (Object.keys(objSettings).includes('contentConfig')) {
|
@@ -148,7 +160,7 @@ module.exports = ({ strapi }) => ({
|
|
148
160
|
await pluginStore.set({ key: 'configsettings', value: stringifySettings });
|
149
161
|
}
|
150
162
|
else {
|
151
|
-
const newSettings = JSON.stringify({
|
163
|
+
const newSettings = JSON.stringify({ contentConfig: config });
|
152
164
|
await pluginStore.set({ key: 'configsettings', value: newSettings });
|
153
165
|
}
|
154
166
|
const updatedSettings = await pluginStore.get({ key: 'configsettings' });
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
2
|
-
declare const
|
3
|
-
|
4
|
-
|
1
|
+
import { EsInterfaceService } from '../types';
|
2
|
+
declare const _default: ({ strapi }: {
|
3
|
+
strapi: any;
|
4
|
+
}) => EsInterfaceService;
|
5
|
+
export default _default;
|
@@ -1,25 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
const
|
4
|
-
const path = require('path');
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const elasticsearch_1 = require("@elastic/elasticsearch");
|
5
4
|
let client = null;
|
6
|
-
|
5
|
+
exports.default = ({ strapi }) => ({
|
7
6
|
async initializeSearchEngine({ host, uname, password, cert }) {
|
8
7
|
try {
|
9
|
-
client = new Client({
|
8
|
+
client = new elasticsearch_1.Client({
|
10
9
|
node: host,
|
11
10
|
auth: {
|
12
11
|
username: uname,
|
13
|
-
password: password
|
12
|
+
password: password,
|
14
13
|
},
|
15
14
|
tls: {
|
16
15
|
ca: cert,
|
17
|
-
rejectUnauthorized: false
|
18
|
-
}
|
16
|
+
rejectUnauthorized: false,
|
17
|
+
},
|
19
18
|
});
|
20
19
|
}
|
21
20
|
catch (err) {
|
22
|
-
if (err
|
21
|
+
if (err?.message?.includes('ECONNREFUSED')) {
|
23
22
|
console.error('strapi-plugin-elasticsearch : Connection to ElasticSearch at ', host, ' refused.');
|
24
23
|
console.error(err);
|
25
24
|
}
|
@@ -27,7 +26,7 @@ module.exports = ({ strapi }) => ({
|
|
27
26
|
console.error('strapi-plugin-elasticsearch : Error while initializing connection to ElasticSearch.');
|
28
27
|
console.error(err);
|
29
28
|
}
|
30
|
-
throw
|
29
|
+
throw err;
|
31
30
|
}
|
32
31
|
},
|
33
32
|
async createIndex(indexName) {
|
@@ -41,7 +40,7 @@ module.exports = ({ strapi }) => ({
|
|
41
40
|
}
|
42
41
|
}
|
43
42
|
catch (err) {
|
44
|
-
if (err
|
43
|
+
if (err?.message?.includes('ECONNREFUSED')) {
|
45
44
|
console.log('strapi-plugin-elasticsearch : Error while creating index - connection to ElasticSearch refused.');
|
46
45
|
console.log(err);
|
47
46
|
}
|
@@ -54,11 +53,11 @@ module.exports = ({ strapi }) => ({
|
|
54
53
|
async deleteIndex(indexName) {
|
55
54
|
try {
|
56
55
|
await client.indices.delete({
|
57
|
-
index: indexName
|
56
|
+
index: indexName,
|
58
57
|
});
|
59
58
|
}
|
60
59
|
catch (err) {
|
61
|
-
if (err
|
60
|
+
if (err?.message?.includes('ECONNREFUSED')) {
|
62
61
|
console.log('strapi-plugin-elasticsearch : Connection to ElasticSearch refused.');
|
63
62
|
console.log(err);
|
64
63
|
}
|
@@ -84,7 +83,7 @@ module.exports = ({ strapi }) => ({
|
|
84
83
|
await client.indices.putAlias({ index: indexName, name: aliasName });
|
85
84
|
}
|
86
85
|
catch (err) {
|
87
|
-
if (err
|
86
|
+
if (err?.message?.includes('ECONNREFUSED')) {
|
88
87
|
console.log('strapi-plugin-elasticsearch : Attaching alias to the index - Connection to ElasticSearch refused.');
|
89
88
|
console.log(err);
|
90
89
|
}
|
@@ -98,7 +97,7 @@ module.exports = ({ strapi }) => ({
|
|
98
97
|
if (!client)
|
99
98
|
return false;
|
100
99
|
try {
|
101
|
-
await client
|
100
|
+
await client?.ping();
|
102
101
|
return true;
|
103
102
|
}
|
104
103
|
catch (error) {
|
@@ -112,7 +111,7 @@ module.exports = ({ strapi }) => ({
|
|
112
111
|
await client.index({
|
113
112
|
index: iName,
|
114
113
|
id: itemId,
|
115
|
-
document: itemData
|
114
|
+
document: itemData,
|
116
115
|
});
|
117
116
|
await client.indices.refresh({ index: iName });
|
118
117
|
}
|
@@ -131,12 +130,12 @@ module.exports = ({ strapi }) => ({
|
|
131
130
|
try {
|
132
131
|
await client.delete({
|
133
132
|
index: pluginConfig.indexAliasName,
|
134
|
-
id: itemId
|
133
|
+
id: itemId,
|
135
134
|
});
|
136
135
|
await client.indices.refresh({ index: pluginConfig.indexAliasName });
|
137
136
|
}
|
138
137
|
catch (err) {
|
139
|
-
if (err
|
138
|
+
if (err?.meta?.statusCode === 404)
|
140
139
|
console.error('strapi-plugin-elasticsearch : The entry to be removed from the index already does not exist.');
|
141
140
|
else {
|
142
141
|
console.error('strapi-plugin-elasticsearch : Error encountered while removing indexed data from ElasticSearch.');
|
@@ -149,7 +148,7 @@ module.exports = ({ strapi }) => ({
|
|
149
148
|
const pluginConfig = await strapi.config.get('plugin.elasticsearch');
|
150
149
|
const result = await client.search({
|
151
150
|
index: pluginConfig.indexAliasName,
|
152
|
-
...searchQuery
|
151
|
+
...searchQuery,
|
153
152
|
});
|
154
153
|
return result;
|
155
154
|
}
|
@@ -157,5 +156,5 @@ module.exports = ({ strapi }) => ({
|
|
157
156
|
console.log('Search : elasticClient.searchData : Error encountered while making a search request to ElasticSearch.');
|
158
157
|
throw err;
|
159
158
|
}
|
160
|
-
}
|
159
|
+
},
|
161
160
|
});
|
@@ -1,34 +1,35 @@
|
|
1
|
-
declare const
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
declare const _default: ({ strapi }: {
|
2
|
+
strapi: any;
|
3
|
+
}) => {
|
4
|
+
getElasticsearchInfo(): Promise<{
|
5
|
+
indexingCronSchedule: any;
|
6
|
+
elasticHost: any;
|
7
|
+
elasticUserName: any;
|
8
|
+
elasticCertificate: any;
|
9
|
+
elasticIndexAlias: any;
|
10
|
+
connected: any;
|
11
|
+
initialized: any;
|
12
|
+
}>;
|
13
|
+
isCollectionDraftPublish({ collectionName }: {
|
14
|
+
collectionName: any;
|
15
|
+
}): boolean;
|
16
|
+
getPopulateAttribute({ collectionName }: {
|
17
|
+
collectionName: any;
|
18
|
+
}): true | {
|
19
|
+
populate: never;
|
20
|
+
} | undefined;
|
21
|
+
getIndexItemId({ collectionName, itemId }: {
|
22
|
+
collectionName: any;
|
23
|
+
itemId: any;
|
24
|
+
}): string;
|
25
|
+
getCurrentIndexName(): Promise<string>;
|
26
|
+
getIncrementedIndexName(): Promise<string>;
|
27
|
+
storeCurrentIndexName(indexName: any): Promise<void>;
|
28
|
+
modifySubfieldsConfigForExtractor(collectionConfig: any): any;
|
29
|
+
extractDataToIndex({ collectionName, data, collectionConfig }: {
|
30
|
+
collectionName: any;
|
31
|
+
data: any;
|
32
|
+
collectionConfig: any;
|
33
|
+
}): {};
|
26
34
|
};
|
27
|
-
|
28
|
-
declare const getFullPopulateObject: (modelUid: any, maxDepth: number | undefined, ignore: any) => true | {
|
29
|
-
populate: {};
|
30
|
-
} | undefined;
|
31
|
-
declare function extractSubfieldData({ config, data }: {
|
32
|
-
config: any;
|
33
|
-
data: any;
|
34
|
-
}): string;
|
35
|
+
export default _default;
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
///START : via https://raw.githubusercontent.com/Barelydead/strapi-plugin-populate-deep/main/server/helpers/index.js
|
3
|
-
|
4
|
-
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
const fp_1 = require("lodash/fp");
|
8
|
+
const transform_content_1 = __importDefault(require("./transform-content"));
|
5
9
|
const getPluginStore = () => {
|
6
10
|
return strapi.store({
|
7
11
|
environment: '',
|
@@ -21,39 +25,40 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
|
|
21
25
|
if (maxDepth <= 1) {
|
22
26
|
return true;
|
23
27
|
}
|
24
|
-
if (modelUid ===
|
28
|
+
if (modelUid === 'admin::user' && skipCreatorFields) {
|
25
29
|
return undefined;
|
26
30
|
}
|
27
31
|
const populate = {};
|
28
32
|
const model = strapi.getModel(modelUid);
|
29
33
|
if (ignore && !ignore.includes(model.collectionName))
|
30
34
|
ignore.push(model.collectionName);
|
31
|
-
for (const [key,
|
32
|
-
if (ignore
|
35
|
+
for (const [key, valueRaw] of Object.entries(getModelPopulationAttributes(model))) {
|
36
|
+
if (ignore?.includes(key))
|
33
37
|
continue;
|
38
|
+
const value = valueRaw;
|
34
39
|
if (value) {
|
35
|
-
if (value.type ===
|
40
|
+
if (value.type === 'component') {
|
36
41
|
populate[key] = getFullPopulateObject(value.component, maxDepth - 1);
|
37
42
|
}
|
38
|
-
else if (value.type ===
|
39
|
-
const dynamicPopulate = value.components
|
43
|
+
else if (value.type === 'dynamiczone') {
|
44
|
+
const dynamicPopulate = value.components?.reduce((prev, cur) => {
|
40
45
|
const curPopulate = getFullPopulateObject(cur, maxDepth - 1);
|
41
|
-
return curPopulate === true ? prev : merge(prev, curPopulate);
|
46
|
+
return curPopulate === true ? prev : (0, fp_1.merge)(prev, curPopulate);
|
42
47
|
}, {});
|
43
|
-
populate[key] = isEmpty(dynamicPopulate) ? true : dynamicPopulate;
|
48
|
+
populate[key] = (0, fp_1.isEmpty)(dynamicPopulate) ? true : dynamicPopulate;
|
44
49
|
}
|
45
|
-
else if (value.type ===
|
46
|
-
const relationPopulate = getFullPopulateObject(value.target,
|
50
|
+
else if (value.type === 'relation') {
|
51
|
+
const relationPopulate = getFullPopulateObject(value.target, key === 'localizations' && maxDepth > 2 ? 1 : maxDepth - 1, ignore);
|
47
52
|
if (relationPopulate) {
|
48
53
|
populate[key] = relationPopulate;
|
49
54
|
}
|
50
55
|
}
|
51
|
-
else if (value.type ===
|
56
|
+
else if (value.type === 'media') {
|
52
57
|
populate[key] = true;
|
53
58
|
}
|
54
59
|
}
|
55
60
|
}
|
56
|
-
return isEmpty(populate) ? true : { populate };
|
61
|
+
return (0, fp_1.isEmpty)(populate) ? true : { populate };
|
57
62
|
};
|
58
63
|
///END : via https://raw.githubusercontent.com/Barelydead/strapi-plugin-populate-deep/main/server/helpers/index.js
|
59
64
|
/*
|
@@ -104,75 +109,75 @@ function extractSubfieldData({ config, data }) {
|
|
104
109
|
if (Object.keys(extractItem).includes('__component')) {
|
105
110
|
if (conf.component === extractItem.__component &&
|
106
111
|
!Object.keys(conf).includes('subfields') &&
|
107
|
-
typeof extractItem[conf['field']] !==
|
112
|
+
typeof extractItem[conf['field']] !== 'undefined' &&
|
108
113
|
extractItem[conf['field']]) {
|
109
114
|
let val = extractItem[conf['field']];
|
110
|
-
if (Object.keys(conf).includes('transform')
|
111
|
-
|
112
|
-
val = transformServiceProvider.transform({ content: val, from: 'markdown' });
|
115
|
+
if (Object.keys(conf).includes('transform') && conf['transform'] === 'markdown')
|
116
|
+
val = transform_content_1.default.transform({ content: val, from: 'markdown' });
|
113
117
|
returnData = returnData + '\n' + val;
|
114
118
|
}
|
115
|
-
else if (conf.component === extractItem.__component &&
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
else if (conf.component === extractItem.__component && Object.keys(conf).includes('subfields')) {
|
120
|
+
returnData =
|
121
|
+
returnData +
|
122
|
+
'\n' +
|
123
|
+
extractSubfieldData({
|
124
|
+
config: conf['subfields'],
|
125
|
+
data: extractItem[conf['field']],
|
126
|
+
});
|
120
127
|
}
|
121
128
|
}
|
122
129
|
else {
|
123
|
-
if (!Object.keys(conf).includes('subfields') &&
|
124
|
-
typeof extractItem[conf['field']] !== "undefined" &&
|
125
|
-
extractItem[conf['field']]) {
|
130
|
+
if (!Object.keys(conf).includes('subfields') && typeof extractItem[conf['field']] !== 'undefined' && extractItem[conf['field']]) {
|
126
131
|
let val = extractItem[conf['field']];
|
127
|
-
if (Object.keys(conf).includes('transform')
|
128
|
-
|
129
|
-
val = transformServiceProvider.transform({ content: val, from: 'markdown' });
|
132
|
+
if (Object.keys(conf).includes('transform') && conf['transform'] === 'markdown')
|
133
|
+
val = transform_content_1.default.transform({ content: val, from: 'markdown' });
|
130
134
|
returnData = returnData + '\n' + val;
|
131
135
|
}
|
132
136
|
else if (Object.keys(conf).includes('subfields')) {
|
133
|
-
returnData =
|
134
|
-
|
135
|
-
|
137
|
+
returnData =
|
138
|
+
returnData +
|
139
|
+
'\n' +
|
140
|
+
extractSubfieldData({
|
141
|
+
config: conf['subfields'],
|
142
|
+
data: extractItem[conf['field']],
|
143
|
+
});
|
136
144
|
}
|
137
145
|
}
|
138
146
|
}
|
139
147
|
}
|
140
|
-
}
|
141
|
-
else
|
142
|
-
{
|
148
|
+
} //for single component as a field
|
149
|
+
else {
|
143
150
|
for (let s = 0; s < config.length; s++) {
|
144
151
|
const conf = config[s];
|
145
|
-
if (!Object.keys(conf).includes('subfields') &&
|
146
|
-
typeof data[conf['field']] !== "undefined" &&
|
147
|
-
data[conf['field']])
|
152
|
+
if (!Object.keys(conf).includes('subfields') && typeof data[conf['field']] !== 'undefined' && data[conf['field']])
|
148
153
|
returnData = returnData + '\n' + data[conf['field']];
|
149
154
|
else if (Object.keys(conf).includes('subfields')) {
|
150
|
-
returnData =
|
151
|
-
|
152
|
-
|
155
|
+
returnData =
|
156
|
+
returnData +
|
157
|
+
'\n' +
|
158
|
+
extractSubfieldData({
|
159
|
+
config: conf['subfields'],
|
160
|
+
data: data[conf['field']],
|
161
|
+
});
|
153
162
|
}
|
154
163
|
}
|
155
164
|
}
|
156
165
|
return returnData;
|
157
166
|
}
|
158
|
-
|
167
|
+
exports.default = ({ strapi }) => ({
|
159
168
|
async getElasticsearchInfo() {
|
160
169
|
const configureService = strapi.plugins['elasticsearch'].services.configureIndexing;
|
161
170
|
const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
|
162
171
|
const pluginConfig = await strapi.config.get('plugin.elasticsearch');
|
163
|
-
const connected = pluginConfig.searchConnector && pluginConfig.searchConnector.host
|
164
|
-
? await esInterface.checkESConnection() : false;
|
172
|
+
const connected = pluginConfig.searchConnector && pluginConfig.searchConnector.host ? await esInterface.checkESConnection() : false;
|
165
173
|
return {
|
166
|
-
indexingCronSchedule: pluginConfig.indexingCronSchedule ||
|
167
|
-
elasticHost: pluginConfig.searchConnector ?
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
elasticCertificate: pluginConfig.searchConnector ?
|
172
|
-
pluginConfig.searchConnector.certificate || "Not configured" : "Not configured",
|
173
|
-
elasticIndexAlias: pluginConfig.indexAliasName || "Not configured",
|
174
|
+
indexingCronSchedule: pluginConfig.indexingCronSchedule || 'Not configured',
|
175
|
+
elasticHost: pluginConfig.searchConnector ? pluginConfig.searchConnector.host || 'Not configured' : 'Not configured',
|
176
|
+
elasticUserName: pluginConfig.searchConnector ? pluginConfig.searchConnector.username || 'Not configured' : 'Not configured',
|
177
|
+
elasticCertificate: pluginConfig.searchConnector ? pluginConfig.searchConnector.certificate || 'Not configured' : 'Not configured',
|
178
|
+
elasticIndexAlias: pluginConfig.indexAliasName || 'Not configured',
|
174
179
|
connected: connected,
|
175
|
-
initialized: configureService.isInitialized()
|
180
|
+
initialized: configureService.isInitialized(),
|
176
181
|
};
|
177
182
|
},
|
178
183
|
isCollectionDraftPublish({ collectionName }) {
|
@@ -189,7 +194,7 @@ module.exports = ({ strapi }) => ({
|
|
189
194
|
},
|
190
195
|
async getCurrentIndexName() {
|
191
196
|
const pluginStore = getPluginStore();
|
192
|
-
const settings = await pluginStore.get({ key: 'configsettings' });
|
197
|
+
const settings = (await pluginStore.get({ key: 'configsettings' }));
|
193
198
|
let indexName = 'strapi-plugin-elasticsearch-index_000001';
|
194
199
|
if (settings) {
|
195
200
|
const objSettings = JSON.parse(settings);
|
@@ -207,14 +212,14 @@ module.exports = ({ strapi }) => ({
|
|
207
212
|
},
|
208
213
|
async storeCurrentIndexName(indexName) {
|
209
214
|
const pluginStore = getPluginStore();
|
210
|
-
const settings = await pluginStore.get({ key: 'configsettings' });
|
215
|
+
const settings = (await pluginStore.get({ key: 'configsettings' }));
|
211
216
|
if (settings) {
|
212
217
|
const objSettings = JSON.parse(settings);
|
213
|
-
objSettings['indexConfig'] = {
|
218
|
+
objSettings['indexConfig'] = { name: indexName };
|
214
219
|
await pluginStore.set({ key: 'configsettings', value: JSON.stringify(objSettings) });
|
215
220
|
}
|
216
221
|
else {
|
217
|
-
const newSettings = JSON.stringify({
|
222
|
+
const newSettings = JSON.stringify({ indexConfig: { name: indexName } });
|
218
223
|
await pluginStore.set({ key: 'configsettings', value: newSettings });
|
219
224
|
}
|
220
225
|
},
|
@@ -254,9 +259,8 @@ module.exports = ({ strapi }) => ({
|
|
254
259
|
}
|
255
260
|
else {
|
256
261
|
val = data[fti[k]];
|
257
|
-
if (Object.keys(fieldConfig).includes('transform') &&
|
258
|
-
|
259
|
-
val = transformServiceProvider.transform({ content: val, from: 'markdown' });
|
262
|
+
if (Object.keys(fieldConfig).includes('transform') && fieldConfig['transform'] === 'markdown')
|
263
|
+
val = transform_content_1.default.transform({ content: val, from: 'markdown' });
|
260
264
|
}
|
261
265
|
if (Object.keys(fieldConfig).includes('searchFieldName'))
|
262
266
|
document[fieldConfig['searchFieldName']] = val;
|
@@ -265,5 +269,5 @@ module.exports = ({ strapi }) => ({
|
|
265
269
|
}
|
266
270
|
}
|
267
271
|
return document;
|
268
|
-
}
|
272
|
+
},
|
269
273
|
});
|