@webiny/api-headless-cms-ddb-es 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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 (303) hide show
  1. package/configurations.d.ts +13 -6
  2. package/configurations.js +18 -12
  3. package/configurations.js.map +1 -1
  4. package/definitions/entry.d.ts +4 -3
  5. package/definitions/entry.js +108 -16
  6. package/definitions/entry.js.map +1 -1
  7. package/definitions/entryElasticsearch.d.ts +4 -3
  8. package/definitions/entryElasticsearch.js +11 -12
  9. package/definitions/entryElasticsearch.js.map +1 -1
  10. package/definitions/group.d.ts +4 -3
  11. package/definitions/group.js +8 -12
  12. package/definitions/group.js.map +1 -1
  13. package/definitions/model.d.ts +4 -3
  14. package/definitions/model.js +30 -12
  15. package/definitions/model.js.map +1 -1
  16. package/definitions/system.d.ts +4 -3
  17. package/definitions/system.js +8 -12
  18. package/definitions/system.js.map +1 -1
  19. package/definitions/table.d.ts +5 -5
  20. package/definitions/table.js +7 -6
  21. package/definitions/table.js.map +1 -1
  22. package/definitions/tableElasticsearch.d.ts +5 -5
  23. package/definitions/tableElasticsearch.js +7 -6
  24. package/definitions/tableElasticsearch.js.map +1 -1
  25. package/dynamoDb/index.d.ts +2 -1
  26. package/dynamoDb/index.js +8 -8
  27. package/dynamoDb/index.js.map +1 -1
  28. package/dynamoDb/storage/longText.d.ts +1 -1
  29. package/dynamoDb/storage/longText.js +13 -18
  30. package/dynamoDb/storage/longText.js.map +1 -1
  31. package/dynamoDb/storage/richText.d.ts +1 -6
  32. package/dynamoDb/storage/richText.js +26 -95
  33. package/dynamoDb/storage/richText.js.map +1 -1
  34. package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
  35. package/elasticsearch/createElasticsearchIndex.js +19 -39
  36. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  37. package/elasticsearch/deleteElasticsearchIndex.d.ts +3 -3
  38. package/elasticsearch/deleteElasticsearchIndex.js +5 -10
  39. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  40. package/elasticsearch/index.js +2 -5
  41. package/elasticsearch/index.js.map +1 -1
  42. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  43. package/elasticsearch/indexing/dateTimeIndexing.js +8 -23
  44. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  45. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  46. package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
  47. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  48. package/elasticsearch/indexing/index.js +4 -10
  49. package/elasticsearch/indexing/index.js.map +1 -1
  50. package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
  51. package/elasticsearch/indexing/jsonIndexing.js +28 -0
  52. package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
  53. package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
  54. package/elasticsearch/indexing/longTextIndexing.js +16 -10
  55. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  56. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  57. package/elasticsearch/indexing/numberIndexing.js +2 -9
  58. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  59. package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
  60. package/elasticsearch/indexing/objectIndexing.js +23 -45
  61. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  62. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  63. package/elasticsearch/indexing/richTextIndexing.js +2 -5
  64. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  65. package/elasticsearch/indices/base.js +3 -5
  66. package/elasticsearch/indices/base.js.map +1 -1
  67. package/elasticsearch/indices/index.js +2 -4
  68. package/elasticsearch/indices/index.js.map +1 -1
  69. package/elasticsearch/indices/japanese.js +3 -5
  70. package/elasticsearch/indices/japanese.js.map +1 -1
  71. package/elasticsearch/search/index.d.ts +1 -1
  72. package/elasticsearch/search/index.js +4 -5
  73. package/elasticsearch/search/index.js.map +1 -1
  74. package/elasticsearch/search/refSearch.js +6 -8
  75. package/elasticsearch/search/refSearch.js.map +1 -1
  76. package/elasticsearch/search/searchableJson.d.ts +2 -0
  77. package/elasticsearch/search/searchableJson.js +60 -0
  78. package/elasticsearch/search/searchableJson.js.map +1 -0
  79. package/elasticsearch/search/timeSearch.js +3 -9
  80. package/elasticsearch/search/timeSearch.js.map +1 -1
  81. package/helpers/entryIndexHelpers.d.ts +3 -3
  82. package/helpers/entryIndexHelpers.js +51 -65
  83. package/helpers/entryIndexHelpers.js.map +1 -1
  84. package/helpers/fieldIdentifier.d.ts +6 -0
  85. package/helpers/fieldIdentifier.js +43 -0
  86. package/helpers/fieldIdentifier.js.map +1 -0
  87. package/helpers/index.d.ts +1 -1
  88. package/helpers/index.js +11 -13
  89. package/helpers/index.js.map +1 -1
  90. package/index.d.ts +1 -1
  91. package/index.js +50 -93
  92. package/index.js.map +1 -1
  93. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  94. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  95. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  96. package/operations/entry/dataLoader/constants.d.ts +1 -0
  97. package/operations/entry/dataLoader/constants.js +10 -0
  98. package/operations/entry/dataLoader/constants.js.map +1 -0
  99. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  100. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  101. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  102. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  103. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  104. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  105. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  106. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -0
  107. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  108. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  109. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +52 -0
  110. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  111. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  112. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  113. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  114. package/operations/entry/dataLoader/index.d.ts +8 -0
  115. package/operations/entry/dataLoader/index.js +40 -0
  116. package/operations/entry/dataLoader/index.js.map +1 -0
  117. package/operations/entry/dataLoader/types.d.ts +6 -0
  118. package/operations/entry/dataLoader/types.js +7 -0
  119. package/operations/entry/dataLoader/types.js.map +1 -0
  120. package/operations/entry/dataLoaders.d.ts +16 -37
  121. package/operations/entry/dataLoaders.js +54 -303
  122. package/operations/entry/dataLoaders.js.map +1 -1
  123. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  124. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  125. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  126. package/operations/entry/elasticsearch/body.d.ts +13 -0
  127. package/operations/entry/elasticsearch/body.js +142 -0
  128. package/operations/entry/elasticsearch/body.js.map +1 -0
  129. package/operations/entry/elasticsearch/fields.d.ts +10 -0
  130. package/operations/entry/elasticsearch/fields.js +315 -0
  131. package/operations/entry/elasticsearch/fields.js.map +1 -0
  132. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  133. package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
  134. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  135. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  136. package/operations/entry/elasticsearch/filtering/exec.js +175 -0
  137. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  139. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  140. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  141. package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
  142. package/operations/entry/elasticsearch/filtering/path.js +48 -0
  143. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  144. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  145. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
  146. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  147. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  148. package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
  149. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  150. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  151. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
  152. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  153. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  154. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
  155. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  156. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  157. package/operations/entry/elasticsearch/filtering/populated.js +25 -0
  158. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  159. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  160. package/operations/entry/elasticsearch/filtering/values.js +24 -0
  161. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  162. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  163. package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
  164. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  165. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  166. package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
  167. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  168. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  169. package/operations/entry/elasticsearch/initialQuery.js +106 -0
  170. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  171. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  172. package/operations/entry/elasticsearch/keyword.js +36 -0
  173. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  174. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
  175. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
  176. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
  177. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  178. package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
  179. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  180. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  181. package/operations/entry/elasticsearch/plugins/operator.js +39 -0
  182. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  183. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  184. package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
  185. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  186. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  187. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -8
  188. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  189. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  190. package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
  191. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  192. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  193. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
  194. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  195. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  196. package/operations/entry/elasticsearch/sort.js +89 -0
  197. package/operations/entry/elasticsearch/sort.js.map +1 -0
  198. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  199. package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
  200. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  201. package/operations/entry/elasticsearch/types.d.ts +41 -0
  202. package/operations/entry/elasticsearch/types.js +7 -0
  203. package/operations/entry/elasticsearch/types.js.map +1 -0
  204. package/operations/entry/index.d.ts +4 -6
  205. package/operations/entry/index.js +1211 -596
  206. package/operations/entry/index.js.map +1 -1
  207. package/operations/entry/keys.js +2 -9
  208. package/operations/entry/keys.js.map +1 -1
  209. package/operations/entry/recordType.d.ts +3 -0
  210. package/operations/entry/recordType.js +20 -0
  211. package/operations/entry/recordType.js.map +1 -0
  212. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  213. package/operations/entry/transformations/convertEntryKeys.js +38 -0
  214. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  215. package/operations/entry/transformations/index.d.ts +29 -0
  216. package/operations/entry/transformations/index.js +127 -0
  217. package/operations/entry/transformations/index.js.map +1 -0
  218. package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
  219. package/operations/entry/transformations/modifyEntryValues.js +28 -0
  220. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  221. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  222. package/operations/entry/transformations/transformEntryKeys.js +27 -0
  223. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  224. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  225. package/operations/entry/transformations/transformEntryToIndex.js +31 -0
  226. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  227. package/operations/group/index.d.ts +3 -3
  228. package/operations/group/index.js +38 -54
  229. package/operations/group/index.js.map +1 -1
  230. package/operations/model/index.d.ts +3 -3
  231. package/operations/model/index.js +26 -47
  232. package/operations/model/index.js.map +1 -1
  233. package/operations/system/index.d.ts +2 -2
  234. package/operations/system/index.js +18 -23
  235. package/operations/system/index.js.map +1 -1
  236. package/operations/system/indexes.d.ts +10 -0
  237. package/operations/system/indexes.js +41 -0
  238. package/operations/system/indexes.js.map +1 -0
  239. package/package.json +37 -34
  240. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
  241. package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
  242. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
  243. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -2
  244. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +8 -11
  245. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  246. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  247. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
  248. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  249. package/plugins/CmsEntryElasticsearchIndexPlugin.js +5 -9
  250. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  251. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -1
  252. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +12 -15
  253. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  254. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -2
  255. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +8 -11
  256. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  257. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -2
  258. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +8 -11
  259. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  260. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
  261. package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
  262. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
  263. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  264. package/plugins/CmsEntryFilterPlugin.js +22 -0
  265. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  266. package/plugins/index.d.ts +3 -1
  267. package/plugins/index.js +36 -24
  268. package/plugins/index.js.map +1 -1
  269. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  270. package/tasks/createIndexTaskPlugin.js +67 -0
  271. package/tasks/createIndexTaskPlugin.js.map +1 -0
  272. package/types.d.ts +27 -22
  273. package/types.js +5 -10
  274. package/types.js.map +1 -1
  275. package/values/NoValueContainer.d.ts +5 -0
  276. package/values/NoValueContainer.js +20 -0
  277. package/values/NoValueContainer.js.map +1 -0
  278. package/definitions/settings.d.ts +0 -8
  279. package/definitions/settings.js +0 -58
  280. package/definitions/settings.js.map +0 -1
  281. package/dynamoDb/storage/date.d.ts +0 -2
  282. package/dynamoDb/storage/date.js +0 -99
  283. package/dynamoDb/storage/date.js.map +0 -1
  284. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  285. package/helpers/createElasticsearchQueryBody.js +0 -611
  286. package/helpers/createElasticsearchQueryBody.js.map +0 -1
  287. package/helpers/fields.d.ts +0 -19
  288. package/helpers/fields.js +0 -205
  289. package/helpers/fields.js.map +0 -1
  290. package/helpers/searchPluginsList.d.ts +0 -6
  291. package/helpers/searchPluginsList.js.map +0 -1
  292. package/helpers/transformValueForSearch.d.ts +0 -12
  293. package/helpers/transformValueForSearch.js +0 -29
  294. package/helpers/transformValueForSearch.js.map +0 -1
  295. package/operations/entry/elasticsearchFields.d.ts +0 -2
  296. package/operations/entry/elasticsearchFields.js +0 -38
  297. package/operations/entry/elasticsearchFields.js.map +0 -1
  298. package/operations/settings/index.d.ts +0 -6
  299. package/operations/settings/index.js +0 -135
  300. package/operations/settings/index.js.map +0 -1
  301. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  302. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  303. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
@@ -1,60 +1,40 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createElasticsearchIndex = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
7
  var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin");
13
-
14
8
  var _apiElasticsearch = require("@webiny/api-elasticsearch");
15
-
16
9
  var _configurations = require("../configurations");
17
-
18
10
  const createElasticsearchIndex = async params => {
19
11
  const {
20
- elasticsearch,
21
- plugins: container,
12
+ client,
13
+ plugins,
22
14
  model
23
15
  } = params;
24
- const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
25
- container,
26
- type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
27
- locale: model.locale
28
- });
29
-
30
16
  const {
31
17
  index
32
18
  } = _configurations.configurations.es({
33
19
  model
34
20
  });
35
-
36
- try {
37
- const response = await elasticsearch.indices.exists({
38
- index
39
- });
40
-
41
- if (response.body) {
42
- return;
21
+ await (0, _apiElasticsearch.createIndex)({
22
+ client,
23
+ index,
24
+ type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
25
+ tenant: model.tenant,
26
+ locale: model.locale,
27
+ plugins,
28
+ onExists: () => {
29
+ console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
30
+ },
31
+ onError: ex => {
32
+ console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
33
+ console.error(ex);
34
+ return ex;
43
35
  }
44
-
45
- await elasticsearch.indices.create({
46
- index,
47
- body: plugin.body
48
- });
49
- } catch (ex) {
50
- throw new _error.default(ex.message || "Could not create Elasticsearch index for the Headless CMS model.", ex.code || "CMS_ELASTICSEARCH_INDEX_ERROR", {
51
- error: ex,
52
- type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
53
- locale: model.locale,
54
- tenant: model.tenant,
55
- body: plugin.body
56
- });
57
- }
36
+ });
58
37
  };
38
+ exports.createElasticsearchIndex = createElasticsearchIndex;
59
39
 
60
- exports.createElasticsearchIndex = createElasticsearchIndex;
40
+ //# sourceMappingURL=createElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","model","plugin","getLastAddedIndexPlugin","type","CmsEntryElasticsearchIndexPlugin","locale","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error","tenant"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n elasticsearch: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { elasticsearch, plugins: container, model } = params;\n\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale\n });\n\n const { index } = configurations.es({\n model\n });\n\n try {\n const response = await elasticsearch.indices.exists({\n index\n });\n if (response.body) {\n return;\n }\n await elasticsearch.indices.create({\n index,\n body: plugin.body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index for the Headless CMS model.\",\n ex.code || \"CMS_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: ex,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale,\n tenant: model.tenant,\n body: plugin.body\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGA;;AACA;;AACA;;AASO,MAAMA,wBAAwB,GAAG,MAAOC,MAAP,IAAkD;EACtF,MAAM;IAAEC,aAAF;IAAiBC,OAAO,EAAEC,SAA1B;IAAqCC;EAArC,IAA+CJ,MAArD;EAEA,MAAMK,MAAM,GAAG,IAAAC,yCAAA,EAA0D;IACrEH,SADqE;IAErEI,IAAI,EAAEC,kEAAA,CAAiCD,IAF8B;IAGrEE,MAAM,EAAEL,KAAK,CAACK;EAHuD,CAA1D,CAAf;;EAMA,MAAM;IAAEC;EAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;IAChCR;EADgC,CAAlB,CAAlB;;EAIA,IAAI;IACA,MAAMS,QAAQ,GAAG,MAAMZ,aAAa,CAACa,OAAd,CAAsBC,MAAtB,CAA6B;MAChDL;IADgD,CAA7B,CAAvB;;IAGA,IAAIG,QAAQ,CAACG,IAAb,EAAmB;MACf;IACH;;IACD,MAAMf,aAAa,CAACa,OAAd,CAAsBG,MAAtB,CAA6B;MAC/BP,KAD+B;MAE/BM,IAAI,EAAEX,MAAM,CAACW;IAFkB,CAA7B,CAAN;EAIH,CAXD,CAWE,OAAOE,EAAP,EAAW;IACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,kEADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,+BAFT,EAGF;MACIC,KAAK,EAAEJ,EADX;MAEIX,IAAI,EAAEC,kEAAA,CAAiCD,IAF3C;MAGIE,MAAM,EAAEL,KAAK,CAACK,MAHlB;MAIIc,MAAM,EAAEnB,KAAK,CAACmB,MAJlB;MAKIP,IAAI,EAAEX,MAAM,CAACW;IALjB,CAHE,CAAN;EAWH;AACJ,CArCM"}
1
+ {"version":3,"names":["_CmsEntryElasticsearchIndexPlugin","require","_apiElasticsearch","_configurations","createElasticsearchIndex","params","client","plugins","model","index","configurations","es","createIndex","type","CmsEntryElasticsearchIndexPlugin","tenant","locale","onExists","console","log","name","onError","ex","error","exports"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n locale: model.locale,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,iCAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASO,MAAMG,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EAEF,MAAM,IAAAI,6BAAW,EAAC;IACdN,MAAM;IACNG,KAAK;IACLI,IAAI,EAAEC,kEAAgC,CAACD,IAAI;IAC3CE,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpBT,OAAO;IACPU,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACP,wBAAwBV,KAAK,wBAAwBD,KAAK,CAACY,IAAI,mBACnE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACT,yCAAyCd,KAAK,wBAAwBD,KAAK,CAACY,IAAI,IACpF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- import { CmsModel } from "@webiny/api-headless-cms/types";
1
+ import type { Client } from "@elastic/elasticsearch";
2
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
3
3
  interface DeleteElasticsearchIndexParams {
4
- elasticsearch: Client;
4
+ client: Client;
5
5
  model: CmsModel;
6
6
  }
7
7
  export declare const deleteElasticsearchIndex: (params: DeleteElasticsearchIndexParams) => Promise<void>;
@@ -4,33 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteElasticsearchIndex = void 0;
7
-
8
7
  var _configurations = require("../configurations");
9
-
10
8
  const deleteElasticsearchIndex = async params => {
11
9
  const {
12
- elasticsearch,
10
+ client,
13
11
  model
14
12
  } = params;
15
-
16
13
  const {
17
14
  index
18
15
  } = _configurations.configurations.es({
19
16
  model
20
17
  });
21
-
22
18
  const {
23
19
  body: exists
24
- } = await elasticsearch.indices.exists({
20
+ } = await client.indices.exists({
25
21
  index
26
22
  });
27
-
28
23
  if (!exists) {
29
24
  return;
30
25
  }
31
-
32
26
  try {
33
- await elasticsearch.indices.delete({
27
+ await client.indices.delete({
34
28
  index,
35
29
  ignore_unavailable: true
36
30
  });
@@ -39,5 +33,6 @@ const deleteElasticsearchIndex = async params => {
39
33
  console.log(ex.message);
40
34
  }
41
35
  };
36
+ exports.deleteElasticsearchIndex = deleteElasticsearchIndex;
42
37
 
43
- exports.deleteElasticsearchIndex = deleteElasticsearchIndex;
38
+ //# sourceMappingURL=deleteElasticsearchIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["deleteElasticsearchIndex","params","elasticsearch","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\n\ninterface DeleteElasticsearchIndexParams {\n elasticsearch: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { elasticsearch, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await elasticsearch.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,wBAAwB,GAAG,MACpCC,MADoC,IAEpB;EAChB,MAAM;IAAEC,aAAF;IAAiBC;EAAjB,IAA2BF,MAAjC;;EAEA,MAAM;IAAEG;EAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;IAChCH;EADgC,CAAlB,CAAlB;;EAGA,MAAM;IAAEI,IAAI,EAAEC;EAAR,IAAmB,MAAMN,aAAa,CAACO,OAAd,CAAsBD,MAAtB,CAA6B;IACxDJ;EADwD,CAA7B,CAA/B;;EAGA,IAAI,CAACI,MAAL,EAAa;IACT;EACH;;EAED,IAAI;IACA,MAAMN,aAAa,CAACO,OAAd,CAAsBC,MAAtB,CAA6B;MAC/BN,KAD+B;MAE/BO,kBAAkB,EAAE;IAFW,CAA7B,CAAN;EAIH,CALD,CAKE,OAAOC,EAAP,EAAW;IACTC,OAAO,CAACC,GAAR,CAAa,yCAAwCV,KAAM,2BAA3D;IACAS,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;EACH;AACJ,CAxBM"}
1
+ {"version":3,"names":["_configurations","require","deleteElasticsearchIndex","params","client","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message","exports"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EACF,MAAM;IAAEI,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAMN,MAAM,CAACO,OAAO,CAACD,MAAM,CAAC;IACjDJ;EACJ,CAAC,CAAC;EACF,IAAI,CAACI,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAMN,MAAM,CAACO,OAAO,CAACC,MAAM,CAAC;MACxBN,KAAK;MACLO,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,yCAAyCV,KAAK,2BAA2B,CAAC;IACtFS,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC;AAACC,OAAA,CAAAhB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _indexing = _interopRequireDefault(require("./indexing"));
11
-
12
9
  var _search = _interopRequireDefault(require("./search"));
13
-
14
10
  var _default = () => [(0, _indexing.default)(), (0, _search.default)()];
11
+ exports.default = _default;
15
12
 
16
- exports.default = _default;
13
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["elasticsearchIndexingPlugins","elasticsearchSearchPlugins"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing\";\nimport elasticsearchSearchPlugins from \"./search\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":";;;;;;;;;AAAA;;AACA;;eAEe,MAAM,CAAC,IAAAA,iBAAA,GAAD,EAAiC,IAAAC,eAAA,GAAjC,C"}
1
+ {"version":3,"names":["_indexing","_interopRequireDefault","require","_search","_default","elasticsearchIndexingPlugins","elasticsearchSearchPlugins","exports","default"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing\";\nimport elasticsearchSearchPlugins from \"./search\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAkD,IAAAE,QAAA,GAEnCA,CAAA,KAAM,CAAC,IAAAC,iBAA4B,EAAC,CAAC,EAAE,IAAAC,eAA0B,EAAC,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { CmsModelFieldToElasticsearchPlugin } from "../../types";
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
2
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
3
  export default _default;
@@ -4,37 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  const convertTimeToNumber = time => {
9
8
  if (!time) {
10
9
  return null;
11
10
  }
12
-
13
11
  const [hours, minutes, seconds = 0] = time.split(":").map(Number);
14
12
  return hours * 60 * 60 + minutes * 60 + seconds;
15
13
  };
16
-
17
14
  const convertNumberToTime = value => {
18
15
  if (value === undefined || value === null) {
19
16
  return null;
20
- } // TODO remove when v5 goes out
17
+ }
18
+ // TODO remove when v5 goes out
21
19
  // this is a fix for pre beta.5
22
-
23
-
24
20
  if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {
25
21
  return String(value);
26
- } //
27
-
28
-
22
+ }
23
+ //
29
24
  const hours = Math.floor(value / 60 / 60);
30
25
  const minutes = Math.floor((value - hours * 60 * 60) / 60);
31
26
  const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);
32
27
  return [hours, minutes, seconds].map(v => String(v).padStart(2, "0")).join(":");
33
28
  };
34
-
35
29
  const convertValueFromIndex = (value, field) => {
36
- const type = field.settings.type;
37
-
30
+ const type = field.settings?.type;
38
31
  if (type === "time") {
39
32
  return convertNumberToTime(value);
40
33
  } else if (!value) {
@@ -45,20 +38,16 @@ const convertValueFromIndex = (value, field) => {
45
38
  const dateValue = new Date(value);
46
39
  return dateValue.toISOString().slice(0, 10);
47
40
  }
48
-
49
41
  return new Date(value).toISOString();
50
42
  };
51
-
52
43
  const convertValueToIndex = (value, field) => {
53
44
  if (!value) {
54
45
  return null;
55
- } else if (field.settings.type === "time") {
46
+ } else if (field.settings?.type === "time") {
56
47
  return convertTimeToNumber(value);
57
48
  }
58
-
59
49
  return value;
60
50
  };
61
-
62
51
  var _default = () => ({
63
52
  type: "cms-model-field-to-elastic-search",
64
53
  name: "cms-model-field-to-elastic-search-datetime",
@@ -66,7 +55,6 @@ var _default = () => ({
66
55
  unmappedType: () => {
67
56
  return "date";
68
57
  },
69
-
70
58
  toIndex({
71
59
  field,
72
60
  value
@@ -78,13 +66,11 @@ var _default = () => ({
78
66
  })
79
67
  };
80
68
  }
81
-
82
69
  const dateValue = convertValueToIndex(value, field);
83
70
  return {
84
71
  value: dateValue
85
72
  };
86
73
  },
87
-
88
74
  fromIndex({
89
75
  field,
90
76
  value
@@ -94,10 +80,9 @@ var _default = () => ({
94
80
  return convertValueFromIndex(v, field);
95
81
  });
96
82
  }
97
-
98
83
  return convertValueFromIndex(value, field);
99
84
  }
100
-
101
85
  });
86
+ exports.default = _default;
102
87
 
103
- exports.default = _default;
88
+ //# sourceMappingURL=dateTimeIndexing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","name","fieldType","unmappedType","toIndex","Array","isArray","fromIndex"],"sources":["dateTimeIndexing.ts"],"sourcesContent":["import { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n // TODO remove when v5 goes out\n // this is a fix for pre beta.5\n if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {\n return String(value);\n }\n //\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n if (Array.isArray(value)) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"],"mappings":";;;;;;;AAGA,MAAMA,mBAAmB,GAAIC,IAAD,IAAkC;EAC1D,IAAI,CAACA,IAAL,EAAW;IACP,OAAO,IAAP;EACH;;EAC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,KAAK,EAAEa;IADJ,CAAP;EAGH,CAnBqD;;EAoBtDW,SAAS,CAAC;IAAEd,KAAF;IAASV;EAAT,CAAD,EAAmB;IACxB,IAAIsB,KAAK,CAACC,OAAN,CAAcvB,KAAd,CAAJ,EAA0B;MACtB,OAAOA,KAAK,CAACH,GAAN,CAAWS,CAAD,IAAe;QAC5B,OAAOG,qBAAqB,CAACH,CAAD,EAAII,KAAJ,CAA5B;MACH,CAFM,CAAP;IAGH;;IACD,OAAOD,qBAAqB,CAACT,KAAD,EAAQU,KAAR,CAA5B;EACH;;AA3BqD,CAA3C,C"}
1
+ {"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","_default","name","fieldType","unmappedType","toIndex","Array","isArray","fromIndex","exports","default"],"sources":["dateTimeIndexing.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types\";\nimport type { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n // TODO remove when v5 goes out\n // this is a fix for pre beta.5\n if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {\n return String(value);\n }\n //\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n if (Array.isArray(value)) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"],"mappings":";;;;;;AAGA,MAAMA,mBAAmB,GAAIC,IAAa,IAAoB;EAC1D,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAM,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EACjE,OAAOL,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,GAAGC,OAAO;AACnD,CAAC;AAED,MAAMI,mBAAmB,GAAIC,KAAc,IAAoB;EAC3D,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,IAAI;EACf;EACA;EACA;EACA,IAAIE,MAAM,CAACF,KAAK,CAAC,CAACG,KAAK,CAAC,wBAAwB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ToElasticsearchPlugin } from "../../types";
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
2
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
3
  export default _default;
@@ -4,32 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _default = () => ({
9
8
  type: "cms-model-field-to-elastic-search",
10
9
  name: "cms-model-field-to-elastic-search-default",
11
10
  fieldType: "*",
12
-
13
11
  toIndex({
14
12
  field,
15
13
  getFieldTypePlugin,
16
14
  value
17
15
  }) {
18
- const fieldTypePlugin = getFieldTypePlugin(field.type); // when field is searchable, assign it to `values`
16
+ const fieldTypePlugin = getFieldTypePlugin(field.type);
19
17
 
18
+ // when field is searchable, assign it to `values`
20
19
  if (fieldTypePlugin.isSearchable === true) {
21
20
  return {
22
21
  value
23
22
  };
24
- } // when field is not searchable, move its value to `rawValues`.
25
- // `rawValues` is a field in ES index that's not being indexed.
26
-
23
+ }
27
24
 
25
+ // when field is not searchable, move its value to `rawValues`.
26
+ // `rawValues` is a field in ES index that's not being indexed.
28
27
  return {
29
28
  rawValue: value
30
29
  };
31
30
  },
32
-
33
31
  fromIndex({
34
32
  field,
35
33
  getFieldTypePlugin,
@@ -39,9 +37,18 @@ var _default = () => ({
39
37
  const {
40
38
  isSearchable
41
39
  } = getFieldTypePlugin(field.type);
42
- return isSearchable === true ? value : rawValue;
40
+ /**
41
+ * We will return the rawValue in case if not searchable and value in case of not searchable field.
42
+ * This is to make sure that changed isSearchable parameter does not make the data to be null / undefined.
43
+ *
44
+ * Users can change isSearchable parameter at any time on the GraphQL field - and that could create a problem for them.
45
+ */
46
+ if (isSearchable) {
47
+ return value === undefined ? rawValue : value;
48
+ }
49
+ return rawValue === undefined ? value : rawValue;
43
50
  }
44
-
45
51
  });
52
+ exports.default = _default;
46
53
 
47
- exports.default = _default;
54
+ //# sourceMappingURL=defaultFieldIndexing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["type","name","fieldType","toIndex","field","getFieldTypePlugin","value","fieldTypePlugin","isSearchable","rawValue","fromIndex"],"sources":["defaultFieldIndexing.ts"],"sourcesContent":["import { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-default\",\n fieldType: \"*\",\n toIndex({ field, getFieldTypePlugin, value }) {\n const fieldTypePlugin = getFieldTypePlugin(field.type);\n\n // when field is searchable, assign it to `values`\n if (fieldTypePlugin.isSearchable === true) {\n return { value };\n }\n\n // when field is not searchable, move its value to `rawValues`.\n // `rawValues` is a field in ES index that's not being indexed.\n return { rawValue: value };\n },\n fromIndex({ field, getFieldTypePlugin, value, rawValue }) {\n const { isSearchable } = getFieldTypePlugin(field.type);\n\n return isSearchable === true ? value : rawValue;\n }\n});\n"],"mappings":";;;;;;;eAEe,OAA2C;EACtDA,IAAI,EAAE,mCADgD;EAEtDC,IAAI,EAAE,2CAFgD;EAGtDC,SAAS,EAAE,GAH2C;;EAItDC,OAAO,CAAC;IAAEC,KAAF;IAASC,kBAAT;IAA6BC;EAA7B,CAAD,EAAuC;IAC1C,MAAMC,eAAe,GAAGF,kBAAkB,CAACD,KAAK,CAACJ,IAAP,CAA1C,CAD0C,CAG1C;;IACA,IAAIO,eAAe,CAACC,YAAhB,KAAiC,IAArC,EAA2C;MACvC,OAAO;QAAEF;MAAF,CAAP;IACH,CANyC,CAQ1C;IACA;;;IACA,OAAO;MAAEG,QAAQ,EAAEH;IAAZ,CAAP;EACH,CAfqD;;EAgBtDI,SAAS,CAAC;IAAEN,KAAF;IAASC,kBAAT;IAA6BC,KAA7B;IAAoCG;EAApC,CAAD,EAAiD;IACtD,MAAM;MAAED;IAAF,IAAmBH,kBAAkB,CAACD,KAAK,CAACJ,IAAP,CAA3C;IAEA,OAAOQ,YAAY,KAAK,IAAjB,GAAwBF,KAAxB,GAAgCG,QAAvC;EACH;;AApBqD,CAA3C,C"}
1
+ {"version":3,"names":["_default","type","name","fieldType","toIndex","field","getFieldTypePlugin","value","fieldTypePlugin","isSearchable","rawValue","fromIndex","undefined","exports","default"],"sources":["defaultFieldIndexing.ts"],"sourcesContent":["import type { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-default\",\n fieldType: \"*\",\n toIndex({ field, getFieldTypePlugin, value }) {\n const fieldTypePlugin = getFieldTypePlugin(field.type);\n\n // when field is searchable, assign it to `values`\n if (fieldTypePlugin.isSearchable === true) {\n return { value };\n }\n\n // when field is not searchable, move its value to `rawValues`.\n // `rawValues` is a field in ES index that's not being indexed.\n return { rawValue: value };\n },\n fromIndex({ field, getFieldTypePlugin, value, rawValue }) {\n const { isSearchable } = getFieldTypePlugin(field.type);\n /**\n * We will return the rawValue in case if not searchable and value in case of not searchable field.\n * This is to make sure that changed isSearchable parameter does not make the data to be null / undefined.\n *\n * Users can change isSearchable parameter at any time on the GraphQL field - and that could create a problem for them.\n */\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n});\n"],"mappings":";;;;;;eAEeA,CAAA,MAA2C;EACtDC,IAAI,EAAE,mCAAmC;EACzCC,IAAI,EAAE,2CAA2C;EACjDC,SAAS,EAAE,GAAG;EACdC,OAAOA,CAAC;IAAEC,KAAK;IAAEC,kBAAkB;IAAEC;EAAM,CAAC,EAAE;IAC1C,MAAMC,eAAe,GAAGF,kBAAkB,CAACD,KAAK,CAACJ,IAAI,CAAC;;IAEtD;IACA,IAAIO,eAAe,CAACC,YAAY,KAAK,IAAI,EAAE;MACvC,OAAO;QAAEF;MAAM,CAAC;IACpB;;IAEA;IACA;IACA,OAAO;MAAEG,QAAQ,EAAEH;IAAM,CAAC;EAC9B,CAAC;EACDI,SAASA,CAAC;IAAEN,KAAK;IAAEC,kBAAkB;IAAEC,KAAK;IAAEG;EAAS,CAAC,EAAE;IACtD,MAAM;MAAED;IAAa,CAAC,GAAGH,kBAAkB,CAACD,KAAK,CAACJ,IAAI,CAAC;IACvD;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIQ,YAAY,EAAE;MACd,OAAOF,KAAK,KAAKK,SAAS,GAAGF,QAAQ,GAAGH,KAAK;IACjD;IACA,OAAOG,QAAQ,KAAKE,SAAS,GAAGL,KAAK,GAAGG,QAAQ;EACpD;AACJ,CAAC,CAAC;AAAAG,OAAA,CAAAC,OAAA,GAAAd,QAAA","ignoreList":[]}
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _richTextIndexing = _interopRequireDefault(require("./richTextIndexing"));
11
-
12
9
  var _longTextIndexing = _interopRequireDefault(require("./longTextIndexing"));
13
-
14
10
  var _defaultFieldIndexing = _interopRequireDefault(require("./defaultFieldIndexing"));
15
-
16
11
  var _dateTimeIndexing = _interopRequireDefault(require("./dateTimeIndexing"));
17
-
18
12
  var _numberIndexing = _interopRequireDefault(require("./numberIndexing"));
19
-
20
13
  var _objectIndexing = _interopRequireDefault(require("./objectIndexing"));
14
+ var _jsonIndexing = require("./jsonIndexing");
15
+ var _default = () => [(0, _dateTimeIndexing.default)(), (0, _richTextIndexing.default)(), (0, _longTextIndexing.default)(), (0, _defaultFieldIndexing.default)(), (0, _numberIndexing.default)(), (0, _objectIndexing.default)(), (0, _jsonIndexing.createJsonIndexing)()];
16
+ exports.default = _default;
21
17
 
22
- var _default = () => [(0, _dateTimeIndexing.default)(), (0, _richTextIndexing.default)(), (0, _longTextIndexing.default)(), (0, _defaultFieldIndexing.default)(), (0, _numberIndexing.default)(), (0, _objectIndexing.default)()];
23
-
24
- exports.default = _default;
18
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["dateTimeIndexing","richTextIndexing","longTextIndexing","defaultFieldIndexing","numberIndexing","objectIndexing"],"sources":["index.ts"],"sourcesContent":["import richTextIndexing from \"./richTextIndexing\";\nimport longTextIndexing from \"./longTextIndexing\";\nimport defaultFieldIndexing from \"./defaultFieldIndexing\";\nimport dateTimeIndexing from \"./dateTimeIndexing\";\nimport numberIndexing from \"./numberIndexing\";\nimport objectIndexing from \"./objectIndexing\";\n\nexport default () => [\n dateTimeIndexing(),\n richTextIndexing(),\n longTextIndexing(),\n defaultFieldIndexing(),\n numberIndexing(),\n objectIndexing()\n];\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;eAEe,MAAM,CACjB,IAAAA,yBAAA,GADiB,EAEjB,IAAAC,yBAAA,GAFiB,EAGjB,IAAAC,yBAAA,GAHiB,EAIjB,IAAAC,6BAAA,GAJiB,EAKjB,IAAAC,uBAAA,GALiB,EAMjB,IAAAC,uBAAA,GANiB,C"}
1
+ {"version":3,"names":["_richTextIndexing","_interopRequireDefault","require","_longTextIndexing","_defaultFieldIndexing","_dateTimeIndexing","_numberIndexing","_objectIndexing","_jsonIndexing","_default","dateTimeIndexing","richTextIndexing","longTextIndexing","defaultFieldIndexing","numberIndexing","objectIndexing","createJsonIndexing","exports","default"],"sources":["index.ts"],"sourcesContent":["import richTextIndexing from \"./richTextIndexing\";\nimport longTextIndexing from \"./longTextIndexing\";\nimport defaultFieldIndexing from \"./defaultFieldIndexing\";\nimport dateTimeIndexing from \"./dateTimeIndexing\";\nimport numberIndexing from \"./numberIndexing\";\nimport objectIndexing from \"./objectIndexing\";\nimport { createJsonIndexing } from \"./jsonIndexing\";\n\nexport default () => [\n dateTimeIndexing(),\n richTextIndexing(),\n longTextIndexing(),\n defaultFieldIndexing(),\n numberIndexing(),\n objectIndexing(),\n createJsonIndexing()\n];\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,eAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAoD,IAAAO,QAAA,GAErCA,CAAA,KAAM,CACjB,IAAAC,yBAAgB,EAAC,CAAC,EAClB,IAAAC,yBAAgB,EAAC,CAAC,EAClB,IAAAC,yBAAgB,EAAC,CAAC,EAClB,IAAAC,6BAAoB,EAAC,CAAC,EACtB,IAAAC,uBAAc,EAAC,CAAC,EAChB,IAAAC,uBAAc,EAAC,CAAC,EAChB,IAAAC,gCAAkB,EAAC,CAAC,CACvB;AAAAC,OAAA,CAAAC,OAAA,GAAAT,QAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ export declare const createJsonIndexing: () => CmsModelFieldToElasticsearchPlugin;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createJsonIndexing = void 0;
7
+ const createJsonIndexing = () => {
8
+ return {
9
+ type: "cms-model-field-to-elastic-search",
10
+ name: "cms-model-field-to-elastic-search-json",
11
+ fieldType: "json",
12
+ toIndex({
13
+ value
14
+ }) {
15
+ return {
16
+ rawValue: value
17
+ };
18
+ },
19
+ fromIndex({
20
+ rawValue
21
+ }) {
22
+ return rawValue;
23
+ }
24
+ };
25
+ };
26
+ exports.createJsonIndexing = createJsonIndexing;
27
+
28
+ //# sourceMappingURL=jsonIndexing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createJsonIndexing","type","name","fieldType","toIndex","value","rawValue","fromIndex","exports"],"sources":["jsonIndexing.ts"],"sourcesContent":["import type { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nexport const createJsonIndexing = (): CmsModelFieldToElasticsearchPlugin => {\n return {\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-json\",\n fieldType: \"json\",\n toIndex({ value }) {\n return {\n rawValue: value\n };\n },\n fromIndex({ rawValue }) {\n return rawValue;\n }\n };\n};\n"],"mappings":";;;;;;AAEO,MAAMA,kBAAkB,GAAGA,CAAA,KAA0C;EACxE,OAAO;IACHC,IAAI,EAAE,mCAAmC;IACzCC,IAAI,EAAE,wCAAwC;IAC9CC,SAAS,EAAE,MAAM;IACjBC,OAAOA,CAAC;MAAEC;IAAM,CAAC,EAAE;MACf,OAAO;QACHC,QAAQ,EAAED;MACd,CAAC;IACL,CAAC;IACDE,SAASA,CAAC;MAAED;IAAS,CAAC,EAAE;MACpB,OAAOA,QAAQ;IACnB;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAAR,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,3 +1,7 @@
1
- import { CmsModelFieldToElasticsearchPlugin } from "../../types";
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ /**
3
+ * The long-text indexing plugin must take in consideration that users might have list of long-text fields.
4
+ * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.
5
+ */
2
6
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
7
  export default _default;
@@ -4,33 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
7
+ /**
8
+ * The long-text indexing plugin must take in consideration that users might have list of long-text fields.
9
+ * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.
10
+ */
8
11
  var _default = () => ({
9
12
  type: "cms-model-field-to-elastic-search",
10
13
  name: "cms-model-field-to-elastic-search-long-text",
11
14
  fieldType: "long-text",
12
-
13
15
  toIndex({
14
16
  rawValue
15
17
  }) {
16
18
  /**
17
- * We want to store the value (rawValue) from entry before it was prepared for storage as value to be searched on.
18
- * And we want to store prepared value into rawValue so it is not indexed.
19
+ * We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.
19
20
  */
20
21
  return {
21
- value: rawValue ? encodeURIComponent(rawValue) : ""
22
+ value: Array.isArray(rawValue) ? rawValue : rawValue || ""
22
23
  };
23
24
  },
24
-
25
25
  /**
26
- * When extracting from index, we can return the value that was stored to be searched - and then no decompression will be required.
26
+ * When taking value from the index, we can return the original value.
27
+ * At that point the `transformFromStorage` does not need to do anything.
28
+ *
29
+ * We need to decode to support older systems.
27
30
  */
28
31
  fromIndex({
29
32
  value
30
33
  }) {
31
- return value ? decodeURIComponent(value) : "";
34
+ if (Array.isArray(value)) {
35
+ return value;
36
+ }
37
+ return value || "";
32
38
  }
33
-
34
39
  });
40
+ exports.default = _default;
35
41
 
36
- exports.default = _default;
42
+ //# sourceMappingURL=longTextIndexing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["type","name","fieldType","toIndex","rawValue","value","encodeURIComponent","fromIndex","decodeURIComponent"],"sources":["longTextIndexing.ts"],"sourcesContent":["import { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-long-text\",\n fieldType: \"long-text\",\n toIndex({ rawValue }) {\n /**\n * We want to store the value (rawValue) from entry before it was prepared for storage as value to be searched on.\n * And we want to store prepared value into rawValue so it is not indexed.\n */\n return {\n value: rawValue ? encodeURIComponent(rawValue) : \"\"\n };\n },\n /**\n * When extracting from index, we can return the value that was stored to be searched - and then no decompression will be required.\n */\n fromIndex({ value }) {\n return value ? decodeURIComponent(value) : \"\";\n }\n});\n"],"mappings":";;;;;;;eAEe,OAA2C;EACtDA,IAAI,EAAE,mCADgD;EAEtDC,IAAI,EAAE,6CAFgD;EAGtDC,SAAS,EAAE,WAH2C;;EAItDC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAAe;IAClB;AACR;AACA;AACA;IACQ,OAAO;MACHC,KAAK,EAAED,QAAQ,GAAGE,kBAAkB,CAACF,QAAD,CAArB,GAAkC;IAD9C,CAAP;EAGH,CAZqD;;EAatD;AACJ;AACA;EACIG,SAAS,CAAC;IAAEF;EAAF,CAAD,EAAY;IACjB,OAAOA,KAAK,GAAGG,kBAAkB,CAACH,KAAD,CAArB,GAA+B,EAA3C;EACH;;AAlBqD,CAA3C,C"}
1
+ {"version":3,"names":["_default","type","name","fieldType","toIndex","rawValue","value","Array","isArray","fromIndex","exports","default"],"sources":["longTextIndexing.ts"],"sourcesContent":["import type { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\n/**\n * The long-text indexing plugin must take in consideration that users might have list of long-text fields.\n * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.\n */\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-long-text\",\n fieldType: \"long-text\",\n toIndex({ rawValue }) {\n /**\n * We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.\n */\n return {\n value: Array.isArray(rawValue) ? rawValue : rawValue || \"\"\n };\n },\n /**\n * When taking value from the index, we can return the original value.\n * At that point the `transformFromStorage` does not need to do anything.\n *\n * We need to decode to support older systems.\n */\n fromIndex({ value }) {\n if (Array.isArray(value)) {\n return value;\n }\n return value || \"\";\n }\n});\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AAHA,IAAAA,QAAA,GAIeA,CAAA,MAA2C;EACtDC,IAAI,EAAE,mCAAmC;EACzCC,IAAI,EAAE,6CAA6C;EACnDC,SAAS,EAAE,WAAW;EACtBC,OAAOA,CAAC;IAAEC;EAAS,CAAC,EAAE;IAClB;AACR;AACA;IACQ,OAAO;MACHC,KAAK,EAAEC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,GAAGA,QAAQ,GAAGA,QAAQ,IAAI;IAC5D,CAAC;EACL,CAAC;EACD;AACJ;AACA;AACA;AACA;AACA;EACII,SAASA,CAAC;IAAEH;EAAM,CAAC,EAAE;IACjB,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK;IAChB;IACA,OAAOA,KAAK,IAAI,EAAE;EACtB;AACJ,CAAC,CAAC;AAAAI,OAAA,CAAAC,OAAA,GAAAX,QAAA","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { CmsModelFieldToElasticsearchPlugin } from "../../types";
1
+ import type { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
2
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
3
  export default _default;