@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
Files changed (150) hide show
  1. package/dist/admin/components/Initializer/index.d.ts +15 -0
  2. package/dist/admin/components/Initializer/index.js +25 -0
  3. package/dist/admin/components/PluginIcon/index.d.ts +8 -0
  4. package/dist/admin/components/PluginIcon/index.js +14 -0
  5. package/dist/admin/components/SubNavigation/index.d.ts +4 -0
  6. package/dist/admin/components/SubNavigation/index.js +40 -0
  7. package/dist/admin/index.d.ts +8 -0
  8. package/dist/admin/index.js +92 -0
  9. package/dist/admin/pages/App/index.d.ts +9 -0
  10. package/dist/admin/pages/App/index.js +29 -0
  11. package/dist/admin/pages/ConfigureCollection/index.d.ts +3 -0
  12. package/dist/admin/pages/ConfigureCollection/index.js +193 -0
  13. package/dist/admin/pages/ConfigureCollectionList/index.d.ts +3 -0
  14. package/dist/admin/pages/ConfigureCollectionList/index.js +228 -0
  15. package/dist/admin/pages/Homepage/index.d.ts +3 -0
  16. package/dist/admin/pages/Homepage/index.js +155 -0
  17. package/dist/admin/pages/ViewIndexingRunLog/index.d.ts +3 -0
  18. package/dist/admin/pages/ViewIndexingRunLog/index.js +125 -0
  19. package/dist/admin/pluginId.d.ts +2 -0
  20. package/dist/admin/pluginId.js +8 -0
  21. package/dist/admin/src/components/Initializer/index.d.ts +15 -0
  22. package/dist/admin/src/components/Initializer/index.js +25 -0
  23. package/dist/admin/src/components/PluginIcon/index.d.ts +8 -0
  24. package/dist/admin/src/components/PluginIcon/index.js +14 -0
  25. package/dist/admin/src/components/SubNavigation/index.d.ts +4 -0
  26. package/dist/admin/src/components/SubNavigation/index.js +40 -0
  27. package/dist/admin/src/index.d.ts +8 -0
  28. package/dist/admin/src/index.js +92 -0
  29. package/dist/admin/src/pages/App/index.d.ts +9 -0
  30. package/dist/admin/src/pages/App/index.js +29 -0
  31. package/dist/admin/src/pages/ConfigureCollection/index.d.ts +3 -0
  32. package/dist/admin/src/pages/ConfigureCollection/index.js +193 -0
  33. package/dist/admin/src/pages/ConfigureCollectionList/index.d.ts +3 -0
  34. package/dist/admin/src/pages/ConfigureCollectionList/index.js +228 -0
  35. package/dist/admin/src/pages/Homepage/index.d.ts +3 -0
  36. package/dist/admin/src/pages/Homepage/index.js +155 -0
  37. package/dist/admin/src/pages/ViewIndexingRunLog/index.d.ts +3 -0
  38. package/dist/admin/src/pages/ViewIndexingRunLog/index.js +125 -0
  39. package/dist/admin/src/pluginId.d.ts +2 -0
  40. package/dist/admin/src/pluginId.js +8 -0
  41. package/dist/admin/src/utils/apiUrls.d.ts +10 -0
  42. package/dist/admin/src/utils/apiUrls.js +20 -0
  43. package/dist/admin/src/utils/axiosInstance.d.ts +5 -0
  44. package/dist/admin/src/utils/axiosInstance.js +33 -0
  45. package/dist/admin/src/utils/getTrad.d.ts +2 -0
  46. package/dist/admin/src/utils/getTrad.js +8 -0
  47. package/dist/admin/utils/apiUrls.d.ts +10 -0
  48. package/dist/admin/utils/apiUrls.js +20 -0
  49. package/dist/admin/utils/axiosInstance.d.ts +5 -0
  50. package/dist/admin/utils/axiosInstance.js +33 -0
  51. package/dist/admin/utils/getTrad.d.ts +2 -0
  52. package/dist/admin/utils/getTrad.js +8 -0
  53. package/dist/server/bootstrap.js +125 -0
  54. package/dist/server/config/index.d.ts +0 -0
  55. package/dist/server/config/index.js +5 -0
  56. package/dist/server/content-types/index.d.ts +2 -0
  57. package/{server → dist/server}/content-types/index.js +7 -9
  58. package/dist/server/content-types/indexing-logs.d.ts +0 -0
  59. package/dist/server/content-types/indexing-logs.js +35 -0
  60. package/dist/server/content-types/name-prefix.d.ts +0 -0
  61. package/dist/server/content-types/name-prefix.js +1 -0
  62. package/dist/server/content-types/tasks.d.ts +0 -0
  63. package/dist/server/content-types/tasks.js +52 -0
  64. package/dist/server/controllers/configure-indexing.d.ts +0 -0
  65. package/dist/server/controllers/configure-indexing.js +58 -0
  66. package/dist/server/controllers/index.d.ts +5 -0
  67. package/{server → dist/server}/controllers/index.js +13 -15
  68. package/dist/server/controllers/log-indexing.d.ts +0 -0
  69. package/{server → dist/server}/controllers/log-indexing.js +10 -11
  70. package/dist/server/controllers/perform-indexing.d.ts +0 -0
  71. package/{server → dist/server}/controllers/perform-indexing.js +22 -28
  72. package/dist/server/controllers/perform-search.d.ts +1 -0
  73. package/dist/server/controllers/perform-search.js +29 -0
  74. package/dist/server/controllers/setup-info.d.ts +0 -0
  75. package/{server → dist/server}/controllers/setup-info.js +10 -14
  76. package/dist/server/destroy.d.ts +0 -0
  77. package/{server → dist/server}/destroy.js +4 -5
  78. package/dist/server/index.d.ts +10 -0
  79. package/{server → dist/server}/index.js +23 -25
  80. package/dist/server/middlewares/index.d.ts +0 -0
  81. package/{server → dist/server}/middlewares/index.js +2 -3
  82. package/dist/server/policies/index.d.ts +0 -0
  83. package/{server → dist/server}/policies/index.js +2 -3
  84. package/dist/server/register.d.ts +0 -0
  85. package/{server → dist/server}/register.js +4 -5
  86. package/dist/server/routes/configure-indexing.d.ts +0 -0
  87. package/dist/server/routes/configure-indexing.js +43 -0
  88. package/dist/server/routes/index.d.ts +5 -0
  89. package/{server → dist/server}/routes/index.js +13 -13
  90. package/dist/server/routes/perform-indexing.d.ts +0 -0
  91. package/dist/server/routes/perform-indexing.js +25 -0
  92. package/dist/server/routes/perform-search.d.ts +0 -0
  93. package/dist/server/routes/perform-search.js +15 -0
  94. package/dist/server/routes/run-log.d.ts +0 -0
  95. package/dist/server/routes/run-log.js +13 -0
  96. package/dist/server/routes/setup-info.d.ts +0 -0
  97. package/dist/server/routes/setup-info.js +13 -0
  98. package/dist/server/services/configure-indexing.d.ts +24 -0
  99. package/dist/server/services/configure-indexing.js +161 -0
  100. package/dist/server/services/es-interface.d.ts +4 -0
  101. package/dist/server/services/es-interface.js +161 -0
  102. package/dist/server/services/helper.d.ts +34 -0
  103. package/{server → dist/server}/services/helper.js +269 -305
  104. package/dist/server/services/index.d.ts +7 -0
  105. package/{server → dist/server}/services/index.js +17 -21
  106. package/dist/server/services/log-indexing.d.ts +0 -0
  107. package/{server → dist/server}/services/log-indexing.js +27 -26
  108. package/dist/server/services/perform-indexing.d.ts +0 -0
  109. package/{server → dist/server}/services/perform-indexing.js +147 -173
  110. package/dist/server/services/schedule-indexing.d.ts +0 -0
  111. package/{server → dist/server}/services/schedule-indexing.js +61 -65
  112. package/dist/server/services/transform-content.d.ts +2 -0
  113. package/{server → dist/server}/services/transform-content.js +21 -22
  114. package/dist/strapi-admin.d.ts +0 -0
  115. package/{strapi-admin.js → dist/strapi-admin.js} +2 -3
  116. package/dist/strapi-server.d.ts +0 -0
  117. package/{strapi-server.js → dist/strapi-server.js} +2 -3
  118. package/package.json +24 -3
  119. package/.prettierrc +0 -7
  120. package/.vscode/settings.json +0 -24
  121. package/admin/src/components/Initializer/index.js +0 -26
  122. package/admin/src/components/PluginIcon/index.js +0 -12
  123. package/admin/src/components/SubNavigation/index.js +0 -48
  124. package/admin/src/index.js +0 -63
  125. package/admin/src/pages/App/index.js +0 -29
  126. package/admin/src/pages/ConfigureCollection/index.js +0 -225
  127. package/admin/src/pages/ConfigureCollectionList/index.js +0 -266
  128. package/admin/src/pages/Homepage/index.js +0 -168
  129. package/admin/src/pages/ViewIndexingRunLog/index.js +0 -124
  130. package/admin/src/pluginId.js +0 -5
  131. package/admin/src/translations/en.json +0 -1
  132. package/admin/src/translations/fr.json +0 -1
  133. package/admin/src/utils/apiUrls.js +0 -14
  134. package/admin/src/utils/axiosInstance.js +0 -40
  135. package/admin/src/utils/getTrad.js +0 -5
  136. package/server/bootstrap.js +0 -142
  137. package/server/config/index.js +0 -6
  138. package/server/content-types/indexing-logs.js +0 -35
  139. package/server/content-types/tasks.js +0 -52
  140. package/server/controllers/configure-indexing.js +0 -66
  141. package/server/controllers/perform-search.js +0 -31
  142. package/server/routes/configure-indexing.js +0 -42
  143. package/server/routes/perform-indexing.js +0 -24
  144. package/server/routes/perform-search.js +0 -14
  145. package/server/routes/run-log.js +0 -12
  146. package/server/routes/setup-info.js +0 -12
  147. package/server/services/configure-indexing.js +0 -184
  148. package/server/services/es-interface.js +0 -187
  149. package/server/services/virtual-collections-registry.js +0 -346
  150. /package/{server/content-types/name-prefix.js → dist/server/bootstrap.d.ts} +0 -0
@@ -0,0 +1,155 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const react_1 = __importStar(require("react"));
40
+ const SubNavigation_1 = require("../../components/SubNavigation");
41
+ ;
42
+ const design_system_1 = require("@strapi/design-system");
43
+ const design_system_2 = require("@strapi/design-system");
44
+ const apiUrls_1 = require("../../utils/apiUrls");
45
+ const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
46
+ const design_system_3 = require("@strapi/design-system");
47
+ const design_system_4 = require("@strapi/design-system");
48
+ const icons_1 = require("@strapi/icons");
49
+ const design_system_5 = require("@strapi/design-system");
50
+ const design_system_6 = require("@strapi/design-system");
51
+ const helper_plugin_1 = require("@strapi/helper-plugin");
52
+ const loadElasticsearchSetupInfo = () => {
53
+ return axiosInstance_1.default.get(apiUrls_1.apiGetElasticsearchSetupInfo)
54
+ .then((resp) => resp.data)
55
+ .then((data) => {
56
+ return data;
57
+ });
58
+ };
59
+ const Homepage = () => {
60
+ const [setupInfo, setSetupInfo] = (0, react_1.useState)(null);
61
+ const [isInProgress, setIsInProgress] = (0, react_1.useState)(false);
62
+ const toggleNotification = (0, helper_plugin_1.useNotification)();
63
+ const displayLabels = { 'connected': 'Connected',
64
+ 'elasticCertificate': 'Certificate',
65
+ 'elasticHost': 'Elasticsearch host',
66
+ 'elasticIndexAlias': 'Elasticsearch index Alias name',
67
+ 'elasticUserName': 'Elasticsearch username',
68
+ 'indexingCronSchedule': 'Indexing cron schedule',
69
+ 'initialized': 'Elasticsearch configuration loaded' };
70
+ const reloadElasticsearchSetupInfo = ({ showNotification }) => {
71
+ setIsInProgress(true);
72
+ loadElasticsearchSetupInfo()
73
+ .then(setSetupInfo)
74
+ .then(() => {
75
+ if (showNotification)
76
+ toggleNotification({
77
+ type: "success", message: "Elasticsearch setup information reloaded.", timeout: 5000
78
+ });
79
+ })
80
+ .finally(() => setIsInProgress(false));
81
+ };
82
+ const requestFullSiteReindexing = () => {
83
+ setIsInProgress(true);
84
+ return axiosInstance_1.default.get(apiUrls_1.apiRequestReIndexing)
85
+ .then(() => {
86
+ toggleNotification({
87
+ type: "success", message: "Rebuilding the index is triggered.", timeout: 5000
88
+ });
89
+ })
90
+ .catch(() => {
91
+ toggleNotification({
92
+ type: "warning", message: "An error was encountered.", timeout: 5000
93
+ });
94
+ })
95
+ .finally(() => setIsInProgress(false));
96
+ };
97
+ const triggerIndexingRun = () => {
98
+ setIsInProgress(true);
99
+ return axiosInstance_1.default.get(apiUrls_1.apiTriggerIndexing)
100
+ .then(() => {
101
+ toggleNotification({
102
+ type: "success", message: "The indexing job to process the pending tasks is started.", timeout: 5000
103
+ });
104
+ })
105
+ .catch(() => {
106
+ toggleNotification({
107
+ type: "warning", message: "An error was encountered.", timeout: 5000
108
+ });
109
+ })
110
+ .finally(() => setIsInProgress(false));
111
+ };
112
+ (0, react_1.useEffect)(() => {
113
+ reloadElasticsearchSetupInfo({ showNotification: false });
114
+ }, []);
115
+ if (setupInfo === null)
116
+ return react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null);
117
+ else
118
+ return (react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
119
+ react_1.default.createElement(SubNavigation_1.SubNavigation, null),
120
+ react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100", width: "100%" },
121
+ react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
122
+ react_1.default.createElement(design_system_2.Typography, { variant: "alpha" }, "Setup Information")),
123
+ react_1.default.createElement(design_system_1.Box, { width: "100%", paddingBottom: 4 },
124
+ react_1.default.createElement(design_system_5.TwoColsLayout, { startCol: react_1.default.createElement(react_1.default.Fragment, null,
125
+ react_1.default.createElement(design_system_4.Table, null, setupInfo && (Object.keys(setupInfo).map((k, idx) => {
126
+ return (react_1.default.createElement(design_system_4.Tr, { key: idx },
127
+ react_1.default.createElement(design_system_4.Td, null,
128
+ react_1.default.createElement(design_system_1.Box, { padding: 2 },
129
+ react_1.default.createElement(design_system_2.Typography, { textColor: "neutral600" },
130
+ displayLabels[k],
131
+ " :"))),
132
+ react_1.default.createElement(design_system_4.Td, null,
133
+ react_1.default.createElement(design_system_1.Box, { padding: 2 },
134
+ react_1.default.createElement(design_system_6.Grid, null,
135
+ react_1.default.createElement(design_system_6.GridItem, { padding: 2 },
136
+ k === 'connected' && setupInfo[k] === true &&
137
+ (react_1.default.createElement(design_system_2.Typography, { fontWeight: "bold", textColor: "success500" }, "Yes")),
138
+ k === 'connected' && setupInfo[k] === false &&
139
+ (react_1.default.createElement(design_system_2.Typography, { fontWeight: "bold", textColor: "danger500" }, "No")),
140
+ k !== 'connected' &&
141
+ (react_1.default.createElement(design_system_2.Typography, { textColor: "neutral600" }, String(setupInfo[k])))),
142
+ react_1.default.createElement(design_system_6.GridItem, { padding: 1 }, k === 'connected' ?
143
+ react_1.default.createElement(design_system_3.IconButton, { disabled: isInProgress, onClick: () => reloadElasticsearchSetupInfo({ showNotification: true }), label: "Refresh", icon: react_1.default.createElement(icons_1.Refresh, null) }) : null))))));
144
+ })))), endCol: react_1.default.createElement(react_1.default.Fragment, null,
145
+ react_1.default.createElement(design_system_1.Box, { paddingLeft: 2, paddingRight: 2, paddingTop: 4, paddingBottom: 4 },
146
+ react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
147
+ react_1.default.createElement(design_system_2.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral600" }, "ACTIONS")),
148
+ react_1.default.createElement(design_system_6.Divider, null),
149
+ react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
150
+ react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
151
+ react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: requestFullSiteReindexing }, "Rebuild Index")),
152
+ react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
153
+ react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: triggerIndexingRun }, "Trigger Indexing"))))) })))));
154
+ };
155
+ exports.default = Homepage;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ViewIndexingRunLog: () => React.JSX.Element;
3
+ export default ViewIndexingRunLog;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /*
3
+ *
4
+ * HomePage
5
+ *
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ const react_1 = __importStar(require("react"));
45
+ const SubNavigation_1 = require("../../components/SubNavigation");
46
+ ;
47
+ const design_system_1 = require("@strapi/design-system");
48
+ const apiUrls_1 = require("../../utils/apiUrls");
49
+ const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
50
+ const design_system_2 = require("@strapi/design-system");
51
+ const design_system_3 = require("@strapi/design-system");
52
+ const helper_plugin_1 = require("@strapi/helper-plugin");
53
+ const loadRecentIndexingRuns = () => {
54
+ return axiosInstance_1.default.get(apiUrls_1.apiFetchRecentIndexingRunLog)
55
+ .then((resp) => resp.data)
56
+ .then((data) => {
57
+ return data;
58
+ });
59
+ };
60
+ const formattedDate = (dateString) => {
61
+ const date = new Date(dateString);
62
+ const options = {
63
+ weekday: 'long',
64
+ year: 'numeric',
65
+ month: 'numeric',
66
+ day: 'numeric',
67
+ hour: 'numeric',
68
+ minute: 'numeric',
69
+ };
70
+ const dateTimeFormat = new Intl.DateTimeFormat('en-US', options);
71
+ const parts = dateTimeFormat.formatToParts(date);
72
+ let formattedDate = '';
73
+ parts.forEach((part) => {
74
+ if (part.type === "weekday")
75
+ formattedDate += `${part.value}, `;
76
+ if (part.type === "day")
77
+ formattedDate += `${part.value}/`;
78
+ if (part.type === "month")
79
+ formattedDate += `${part.value}/`;
80
+ if (part.type === "year")
81
+ formattedDate += `${part.value} `;
82
+ if (part.type === "hour")
83
+ formattedDate += `${part.value}:`;
84
+ if (part.type === "minute")
85
+ formattedDate += `${part.value}`;
86
+ });
87
+ return formattedDate;
88
+ };
89
+ const ViewIndexingRunLog = () => {
90
+ const [logTable, setLogTable] = (0, react_1.useState)(null);
91
+ (0, react_1.useEffect)(() => {
92
+ loadRecentIndexingRuns()
93
+ .then(setLogTable);
94
+ }, []);
95
+ if (logTable === null)
96
+ return react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null);
97
+ else
98
+ return (react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
99
+ react_1.default.createElement(SubNavigation_1.SubNavigation, null),
100
+ react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100", width: "100%" },
101
+ react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
102
+ react_1.default.createElement(design_system_3.Typography, { variant: "alpha" }, "Recent Indexing Run Logs")),
103
+ logTable && logTable.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
104
+ react_1.default.createElement(design_system_2.Table, { colCount: 3, rowCount: logTable.length },
105
+ react_1.default.createElement(design_system_2.Thead, null,
106
+ react_1.default.createElement(design_system_2.Tr, null,
107
+ react_1.default.createElement(design_system_2.Th, null,
108
+ react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Date")),
109
+ react_1.default.createElement(design_system_2.Th, null,
110
+ react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Status")),
111
+ react_1.default.createElement(design_system_2.Th, null,
112
+ react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Details")))),
113
+ react_1.default.createElement(design_system_2.Tbody, null, logTable.map((data, index) => {
114
+ return (react_1.default.createElement(design_system_2.Tr, { key: index },
115
+ react_1.default.createElement(design_system_2.Td, null,
116
+ react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, formattedDate(data.createdAt))),
117
+ react_1.default.createElement(design_system_2.Td, null,
118
+ react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, data.status)),
119
+ react_1.default.createElement(design_system_2.Td, null,
120
+ react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, data.details))));
121
+ }))),
122
+ react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
123
+ react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, "This view lists the details of the 50 recent-most indexing runs.")))))));
124
+ };
125
+ exports.default = ViewIndexingRunLog;
@@ -0,0 +1,2 @@
1
+ declare const pluginId: any;
2
+ export default pluginId;
@@ -0,0 +1,8 @@
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
+ const package_json_1 = __importDefault(require("../../package.json"));
7
+ const pluginId = package_json_1.default.strapi.name;
8
+ exports.default = pluginId;
@@ -0,0 +1,10 @@
1
+ export declare const apiGetContentConfig: string;
2
+ export declare const apiGetCollectionConfig: (collectionName: any) => string;
3
+ export declare const apiSaveCollectionConfig: (collectionName: any) => string;
4
+ export declare const apiGetElasticsearchSetupInfo: string;
5
+ export declare const apiFetchRecentIndexingRunLog: string;
6
+ export declare const apiRequestReIndexing: string;
7
+ export declare const apiRequestCollectionIndexing: (collectionName: any) => string;
8
+ export declare const apiTriggerIndexing: string;
9
+ export declare const apiExportContentConfig: string;
10
+ export declare const apiImportContentConfig: string;
@@ -0,0 +1,20 @@
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.apiImportContentConfig = exports.apiExportContentConfig = exports.apiTriggerIndexing = exports.apiRequestCollectionIndexing = exports.apiRequestReIndexing = exports.apiFetchRecentIndexingRunLog = exports.apiGetElasticsearchSetupInfo = exports.apiSaveCollectionConfig = exports.apiGetCollectionConfig = exports.apiGetContentConfig = void 0;
7
+ const pluginId_1 = __importDefault(require("../pluginId"));
8
+ exports.apiGetContentConfig = `/${pluginId_1.default}/content-config/`;
9
+ const apiGetCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
10
+ exports.apiGetCollectionConfig = apiGetCollectionConfig;
11
+ const apiSaveCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
12
+ exports.apiSaveCollectionConfig = apiSaveCollectionConfig;
13
+ exports.apiGetElasticsearchSetupInfo = `/${pluginId_1.default}/setup-info`;
14
+ exports.apiFetchRecentIndexingRunLog = `/${pluginId_1.default}/indexing-run-log`;
15
+ exports.apiRequestReIndexing = `/${pluginId_1.default}/reindex`;
16
+ const apiRequestCollectionIndexing = (collectionName) => `/${pluginId_1.default}/collection-reindex/${collectionName}`;
17
+ exports.apiRequestCollectionIndexing = apiRequestCollectionIndexing;
18
+ exports.apiTriggerIndexing = `/${pluginId_1.default}/trigger-indexing/`;
19
+ exports.apiExportContentConfig = `/${pluginId_1.default}/export-content-config/`;
20
+ exports.apiImportContentConfig = `/${pluginId_1.default}/import-content-config/`;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * axios with a custom config.
3
+ */
4
+ declare const instance: import("axios").AxiosInstance;
5
+ export default instance;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * axios with a custom config.
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const helper_plugin_1 = require("@strapi/helper-plugin");
11
+ const instance = axios_1.default.create({
12
+ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
13
+ });
14
+ instance.interceptors.request.use(async (config) => {
15
+ config.headers = {
16
+ Authorization: `Bearer ${helper_plugin_1.auth.getToken()}`,
17
+ Accept: 'application/json',
18
+ 'Content-Type': 'application/json',
19
+ };
20
+ return config;
21
+ }, error => {
22
+ Promise.reject(error);
23
+ });
24
+ instance.interceptors.response.use(response => response, error => {
25
+ var _a;
26
+ // whatever you want to do with the error
27
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
28
+ helper_plugin_1.auth.clearAppStorage();
29
+ window.location.reload();
30
+ }
31
+ throw error;
32
+ });
33
+ exports.default = instance;
@@ -0,0 +1,2 @@
1
+ declare const getTrad: (id: any) => string;
2
+ export default getTrad;
@@ -0,0 +1,8 @@
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
+ const pluginId_1 = __importDefault(require("../pluginId"));
7
+ const getTrad = (id) => `${pluginId_1.default}.${id}`;
8
+ exports.default = getTrad;
@@ -0,0 +1,10 @@
1
+ export declare const apiGetContentConfig: string;
2
+ export declare const apiGetCollectionConfig: (collectionName: any) => string;
3
+ export declare const apiSaveCollectionConfig: (collectionName: any) => string;
4
+ export declare const apiGetElasticsearchSetupInfo: string;
5
+ export declare const apiFetchRecentIndexingRunLog: string;
6
+ export declare const apiRequestReIndexing: string;
7
+ export declare const apiRequestCollectionIndexing: (collectionName: any) => string;
8
+ export declare const apiTriggerIndexing: string;
9
+ export declare const apiExportContentConfig: string;
10
+ export declare const apiImportContentConfig: string;
@@ -0,0 +1,20 @@
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.apiImportContentConfig = exports.apiExportContentConfig = exports.apiTriggerIndexing = exports.apiRequestCollectionIndexing = exports.apiRequestReIndexing = exports.apiFetchRecentIndexingRunLog = exports.apiGetElasticsearchSetupInfo = exports.apiSaveCollectionConfig = exports.apiGetCollectionConfig = exports.apiGetContentConfig = void 0;
7
+ const pluginId_1 = __importDefault(require("../pluginId"));
8
+ exports.apiGetContentConfig = `/${pluginId_1.default}/content-config/`;
9
+ const apiGetCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
10
+ exports.apiGetCollectionConfig = apiGetCollectionConfig;
11
+ const apiSaveCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
12
+ exports.apiSaveCollectionConfig = apiSaveCollectionConfig;
13
+ exports.apiGetElasticsearchSetupInfo = `/${pluginId_1.default}/setup-info`;
14
+ exports.apiFetchRecentIndexingRunLog = `/${pluginId_1.default}/indexing-run-log`;
15
+ exports.apiRequestReIndexing = `/${pluginId_1.default}/reindex`;
16
+ const apiRequestCollectionIndexing = (collectionName) => `/${pluginId_1.default}/collection-reindex/${collectionName}`;
17
+ exports.apiRequestCollectionIndexing = apiRequestCollectionIndexing;
18
+ exports.apiTriggerIndexing = `/${pluginId_1.default}/trigger-indexing/`;
19
+ exports.apiExportContentConfig = `/${pluginId_1.default}/export-content-config/`;
20
+ exports.apiImportContentConfig = `/${pluginId_1.default}/import-content-config/`;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * axios with a custom config.
3
+ */
4
+ declare const instance: import("axios").AxiosInstance;
5
+ export default instance;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * axios with a custom config.
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const helper_plugin_1 = require("@strapi/helper-plugin");
11
+ const instance = axios_1.default.create({
12
+ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
13
+ });
14
+ instance.interceptors.request.use(async (config) => {
15
+ config.headers = {
16
+ Authorization: `Bearer ${helper_plugin_1.auth.getToken()}`,
17
+ Accept: 'application/json',
18
+ 'Content-Type': 'application/json',
19
+ };
20
+ return config;
21
+ }, error => {
22
+ Promise.reject(error);
23
+ });
24
+ instance.interceptors.response.use(response => response, error => {
25
+ var _a;
26
+ // whatever you want to do with the error
27
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
28
+ helper_plugin_1.auth.clearAppStorage();
29
+ window.location.reload();
30
+ }
31
+ throw error;
32
+ });
33
+ exports.default = instance;
@@ -0,0 +1,2 @@
1
+ declare const getTrad: (id: any) => string;
2
+ export default getTrad;
@@ -0,0 +1,8 @@
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
+ const pluginId_1 = __importDefault(require("../pluginId"));
7
+ const getTrad = (id) => `${pluginId_1.default}.${id}`;
8
+ exports.default = getTrad;
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+ console.log('strapi-plugin-elasticsearch : 00 Initializing strapi-plugin-elasticsearch plugin.');
3
+ module.exports = async ({ strapi }) => {
4
+ const pluginConfig = await strapi.config.get('plugin.elasticsearch');
5
+ const configureIndexingService = strapi.plugins['elasticsearch'].services.configureIndexing;
6
+ const scheduleIndexingService = strapi.plugins['elasticsearch'].services.scheduleIndexing;
7
+ const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
8
+ const indexer = strapi.plugins['elasticsearch'].services.indexer;
9
+ const helper = strapi.plugins['elasticsearch'].services.helper;
10
+ try {
11
+ console.log('strapi-plugin-elasticsearch 1: Initializing strapi-plugin-elasticsearch plugin.');
12
+ await configureIndexingService.initializeStrapiElasticsearch();
13
+ if (!Object.keys(pluginConfig).includes('indexingCronSchedule'))
14
+ console.warn('The plugin strapi-plugin-elasticsearch is enabled but the indexingCronSchedule is not configured.');
15
+ else if (!Object.keys(pluginConfig).includes('searchConnector'))
16
+ console.warn('The plugin strapi-plugin-elasticsearch is enabled but the searchConnector is not configured.');
17
+ else {
18
+ const connector = pluginConfig['searchConnector'];
19
+ await esInterface.initializeSearchEngine({
20
+ host: connector.host,
21
+ uname: connector.username,
22
+ password: connector.password,
23
+ cert: connector.certificate,
24
+ });
25
+ strapi.cron.add({
26
+ elasticsearchIndexing: {
27
+ task: async ({ strapi }) => {
28
+ await indexer.indexPendingData();
29
+ },
30
+ options: {
31
+ rule: pluginConfig['indexingCronSchedule'],
32
+ },
33
+ },
34
+ });
35
+ if (await esInterface.checkESConnection()) {
36
+ //Attach the alias to the current index:
37
+ const idxName = await helper.getCurrentIndexName();
38
+ await esInterface.attachAliasToIndex(idxName);
39
+ }
40
+ }
41
+ strapi.db.lifecycles.subscribe(async (event) => {
42
+ if (event.action === 'afterCreate' || event.action === 'afterUpdate') {
43
+ if (strapi.elasticsearch.collections.includes(event.model.uid)) {
44
+ //collection without draft-publish
45
+ if (typeof event.model.attributes.publishedAt === 'undefined') {
46
+ await scheduleIndexingService.addItemToIndex({
47
+ collectionUid: event.model.uid,
48
+ recordId: event.result.id,
49
+ });
50
+ }
51
+ else if (event.model.attributes.publishedAt) {
52
+ if (event.result.publishedAt) {
53
+ await scheduleIndexingService.addItemToIndex({
54
+ collectionUid: event.model.uid,
55
+ recordId: event.result.id,
56
+ });
57
+ }
58
+ else {
59
+ //unpublish
60
+ await scheduleIndexingService.removeItemFromIndex({
61
+ collectionUid: event.model.uid,
62
+ recordId: event.result.id,
63
+ });
64
+ }
65
+ }
66
+ }
67
+ }
68
+ //bulk publish-unpublish from list view
69
+ if (event.action === 'afterCreateMany' || event.action === 'afterUpdateMany') {
70
+ if (strapi.elasticsearch.collections.includes(event.model.uid)) {
71
+ if (Object.keys(event.params.where.id).includes('$in')) {
72
+ const updatedItemIds = event.params.where.id['$in'];
73
+ //bulk unpublish
74
+ if (typeof event.params.data.publishedAt === 'undefined' ||
75
+ event.params.data.publishedAt === null) {
76
+ for (let k = 0; k < updatedItemIds.length; k++) {
77
+ await scheduleIndexingService.removeItemFromIndex({
78
+ collectionUid: event.model.uid,
79
+ recordId: updatedItemIds[k],
80
+ });
81
+ }
82
+ }
83
+ else {
84
+ for (let k = 0; k < updatedItemIds.length; k++) {
85
+ await scheduleIndexingService.addItemToIndex({
86
+ collectionUid: event.model.uid,
87
+ recordId: updatedItemIds[k],
88
+ });
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ if (event.action === 'afterDelete') {
95
+ if (strapi.elasticsearch.collections.includes(event.model.uid)) {
96
+ await scheduleIndexingService.removeItemFromIndex({
97
+ collectionUid: event.model.uid,
98
+ recordId: event.result.id,
99
+ });
100
+ }
101
+ }
102
+ if (event.action === 'afterDeleteMany') {
103
+ if (strapi.elasticsearch.collections.includes(event.model.uid)) {
104
+ if (Object.keys(event.params.where).includes('$and') &&
105
+ Array.isArray(event.params.where['$and']) &&
106
+ Object.keys(event.params.where['$and'][0]).includes('id') &&
107
+ Object.keys(event.params.where['$and'][0]['id']).includes('$in')) {
108
+ const deletedItemIds = event.params.where['$and'][0]['id']['$in'];
109
+ for (let k = 0; k < deletedItemIds.length; k++) {
110
+ await scheduleIndexingService.removeItemFromIndex({
111
+ collectionUid: event.model.uid,
112
+ recordId: deletedItemIds[k],
113
+ });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ });
119
+ configureIndexingService.markInitialized();
120
+ }
121
+ catch (err) {
122
+ console.error('An error was encountered while initializing the strapi-plugin-elasticsearch plugin.');
123
+ console.error(err);
124
+ }
125
+ };
File without changes
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ default: {},
4
+ validator() { },
5
+ };
@@ -0,0 +1,2 @@
1
+ declare const task: any;
2
+ declare const indexingLog: any;
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
- const task = require('./tasks');
4
- const indexingLog = require('./indexing-logs');
5
-
6
- module.exports = {
7
- 'task' : {schema : task},
8
- 'indexing-log' : {schema: indexingLog}
9
- };
1
+ 'use strict';
2
+ const task = require('./tasks');
3
+ const indexingLog = require('./indexing-logs');
4
+ module.exports = {
5
+ 'task': { schema: task },
6
+ 'indexing-log': { schema: indexingLog }
7
+ };
File without changes