@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.13771d80a8

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 (252) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +13 -10
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +9 -12
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -12
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -12
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +25 -12
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -12
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -12
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js +0 -3
  24. package/definitions/table.js.map +1 -0
  25. package/definitions/tableElasticsearch.d.ts +2 -2
  26. package/definitions/tableElasticsearch.js +0 -3
  27. package/definitions/tableElasticsearch.js.map +1 -0
  28. package/dynamoDb/index.d.ts +1 -1
  29. package/dynamoDb/index.js +4 -11
  30. package/dynamoDb/index.js.map +1 -0
  31. package/dynamoDb/storage/date.d.ts +3 -3
  32. package/dynamoDb/storage/date.js +74 -53
  33. package/dynamoDb/storage/date.js.map +1 -0
  34. package/dynamoDb/storage/longText.d.ts +7 -4
  35. package/dynamoDb/storage/longText.js +73 -63
  36. package/dynamoDb/storage/longText.js.map +1 -0
  37. package/dynamoDb/storage/richText.d.ts +2 -3
  38. package/dynamoDb/storage/richText.js +77 -77
  39. package/dynamoDb/storage/richText.js.map +1 -0
  40. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  41. package/elasticsearch/createElasticsearchIndex.js +49 -0
  42. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  43. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  44. package/elasticsearch/deleteElasticsearchIndex.js +36 -0
  45. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  46. package/elasticsearch/index.d.ts +1 -1
  47. package/elasticsearch/index.js +1 -6
  48. package/elasticsearch/index.js.map +1 -0
  49. package/elasticsearch/indexing/dateTimeIndexing.js +17 -20
  50. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  51. package/elasticsearch/indexing/defaultFieldIndexing.js +15 -10
  52. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  53. package/elasticsearch/indexing/index.js +1 -10
  54. package/elasticsearch/indexing/index.js.map +1 -0
  55. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  56. package/elasticsearch/indexing/longTextIndexing.js +19 -9
  57. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  58. package/elasticsearch/indexing/numberIndexing.js +0 -9
  59. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  60. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  61. package/elasticsearch/indexing/objectIndexing.js +26 -30
  62. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/richTextIndexing.js +0 -5
  64. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  65. package/elasticsearch/indices/base.d.ts +2 -0
  66. package/elasticsearch/indices/base.js +12 -0
  67. package/elasticsearch/indices/base.js.map +1 -0
  68. package/elasticsearch/indices/index.d.ts +1 -0
  69. package/elasticsearch/indices/index.js +12 -0
  70. package/elasticsearch/indices/index.js.map +1 -0
  71. package/elasticsearch/indices/japanese.d.ts +2 -0
  72. package/elasticsearch/indices/japanese.js +13 -0
  73. package/elasticsearch/indices/japanese.js.map +1 -0
  74. package/elasticsearch/search/index.d.ts +2 -2
  75. package/elasticsearch/search/index.js +3 -9
  76. package/elasticsearch/search/index.js.map +1 -0
  77. package/elasticsearch/search/refSearch.d.ts +2 -3
  78. package/elasticsearch/search/refSearch.js +23 -18
  79. package/elasticsearch/search/refSearch.js.map +1 -0
  80. package/elasticsearch/search/timeSearch.d.ts +2 -3
  81. package/elasticsearch/search/timeSearch.js +18 -17
  82. package/elasticsearch/search/timeSearch.js.map +1 -0
  83. package/helpers/entryIndexHelpers.js +43 -57
  84. package/helpers/entryIndexHelpers.js.map +1 -0
  85. package/helpers/index.d.ts +0 -1
  86. package/helpers/index.js +0 -15
  87. package/helpers/index.js.map +1 -0
  88. package/index.d.ts +1 -0
  89. package/index.js +106 -63
  90. package/index.js.map +1 -0
  91. package/operations/entry/dataLoaders.d.ts +6 -2
  92. package/operations/entry/dataLoaders.js +27 -61
  93. package/operations/entry/dataLoaders.js.map +1 -0
  94. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  95. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
  96. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  97. package/operations/entry/elasticsearch/body.d.ts +13 -0
  98. package/operations/entry/elasticsearch/body.js +140 -0
  99. package/operations/entry/elasticsearch/body.js.map +1 -0
  100. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  101. package/operations/entry/elasticsearch/fields.js +229 -0
  102. package/operations/entry/elasticsearch/fields.js.map +1 -0
  103. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  104. package/operations/entry/elasticsearch/filtering/applyFiltering.js +57 -0
  105. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  106. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  107. package/operations/entry/elasticsearch/filtering/exec.js +172 -0
  108. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  109. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  110. package/operations/entry/elasticsearch/filtering/index.js +16 -0
  111. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  112. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  113. package/operations/entry/elasticsearch/filtering/path.js +44 -0
  114. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  115. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  116. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
  117. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  118. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  119. package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
  120. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  121. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  122. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  127. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  128. package/operations/entry/elasticsearch/filtering/populated.js +23 -0
  129. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  130. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  131. package/operations/entry/elasticsearch/filtering/values.js +22 -0
  132. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  133. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  134. package/operations/entry/elasticsearch/fullTextSearch.js +89 -0
  135. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  136. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  137. package/operations/entry/elasticsearch/fullTextSearchFields.js +25 -0
  138. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  139. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  140. package/operations/entry/elasticsearch/initialQuery.js +103 -0
  141. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  142. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  143. package/operations/entry/elasticsearch/keyword.js +34 -0
  144. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  145. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  146. package/operations/entry/elasticsearch/plugins/bodyModifier.js +16 -0
  147. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  148. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  149. package/operations/entry/elasticsearch/plugins/operator.js +37 -0
  150. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  151. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  152. package/operations/entry/elasticsearch/plugins/queryModifier.js +16 -0
  153. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  154. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  155. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -10
  156. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  157. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  158. package/operations/entry/elasticsearch/plugins/sortModifier.js +16 -0
  159. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  160. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  161. package/operations/entry/elasticsearch/sort.js +82 -0
  162. package/operations/entry/elasticsearch/sort.js.map +1 -0
  163. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  164. package/operations/entry/elasticsearch/transformValueForSearch.js +30 -0
  165. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  166. package/operations/entry/elasticsearch/types.d.ts +41 -0
  167. package/operations/entry/elasticsearch/types.js +5 -0
  168. package/operations/entry/elasticsearch/types.js.map +1 -0
  169. package/operations/entry/index.d.ts +2 -4
  170. package/operations/entry/index.js +457 -481
  171. package/operations/entry/index.js.map +1 -0
  172. package/operations/entry/keys.js +0 -9
  173. package/operations/entry/keys.js.map +1 -0
  174. package/operations/entry/recordType.d.ts +3 -0
  175. package/operations/entry/recordType.js +18 -0
  176. package/operations/entry/recordType.js.map +1 -0
  177. package/operations/group/index.d.ts +2 -2
  178. package/operations/group/index.js +10 -47
  179. package/operations/group/index.js.map +1 -0
  180. package/operations/model/index.d.ts +2 -2
  181. package/operations/model/index.js +34 -68
  182. package/operations/model/index.js.map +1 -0
  183. package/operations/settings/index.d.ts +2 -2
  184. package/operations/settings/index.js +7 -37
  185. package/operations/settings/index.js.map +1 -0
  186. package/operations/system/index.d.ts +2 -2
  187. package/operations/system/index.js +5 -28
  188. package/operations/system/index.js.map +1 -0
  189. package/package.json +24 -29
  190. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
  191. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +9 -11
  192. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  193. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  194. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -9
  195. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  196. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  197. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
  198. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  199. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  200. package/plugins/CmsEntryElasticsearchIndexPlugin.js +12 -0
  201. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  202. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +31 -0
  203. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +37 -0
  204. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
  206. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +9 -11
  207. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
  209. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +9 -11
  210. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  211. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  212. package/plugins/CmsEntryFilterPlugin.js +24 -0
  213. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  214. package/plugins/index.d.ts +7 -0
  215. package/plugins/index.js +82 -0
  216. package/plugins/index.js.map +1 -0
  217. package/types.d.ts +7 -34
  218. package/types.js +0 -18
  219. package/types.js.map +1 -0
  220. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  221. package/helpers/createElasticsearchQueryBody.js +0 -375
  222. package/helpers/fields.d.ts +0 -77
  223. package/helpers/fields.js +0 -174
  224. package/helpers/operatorPluginsList.d.ts +0 -7
  225. package/helpers/operatorPluginsList.js +0 -30
  226. package/helpers/searchPluginsList.d.ts +0 -6
  227. package/helpers/transformValueForSearch.d.ts +0 -9
  228. package/helpers/transformValueForSearch.js +0 -26
  229. package/operations/entry/elasticsearchFields.d.ts +0 -2
  230. package/operations/entry/elasticsearchFields.js +0 -32
  231. package/operations/entry/fields.d.ts +0 -3
  232. package/operations/entry/fields.js +0 -60
  233. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  234. package/operations/system/createElasticsearchTemplate.js +0 -62
  235. package/upgrades/index.d.ts +0 -2
  236. package/upgrades/index.js +0 -16
  237. package/upgrades/utils.d.ts +0 -1
  238. package/upgrades/utils.js +0 -16
  239. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  240. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  241. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  242. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  243. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  244. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  245. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  246. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  247. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  248. package/upgrades/v5.0.0/helpers.js +0 -57
  249. package/upgrades/v5.0.0/index.d.ts +0 -4
  250. package/upgrades/v5.0.0/index.js +0 -232
  251. package/upgrades/v5.8.0/index.d.ts +0 -4
  252. package/upgrades/v5.8.0/index.js +0 -426
@@ -0,0 +1 @@
1
+ {"version":3,"names":["type","name","fieldType","toIndex","value","rawValue","fromIndex"],"sources":["richTextIndexing.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-rich-text\",\n fieldType: \"rich-text\",\n toIndex({ value }) {\n // TODO: convert rich-text object to a searchable string to offer full-text search at some point\n\n /**\n * We want to store rich-text value as a \"rawValue\", meaning it wont' be indexed by ES.\n */\n return {\n rawValue: value\n };\n },\n fromIndex({ rawValue }) {\n return rawValue;\n }\n});\n"],"mappings":";;;;;;eAEe,OAA2C;EACtDA,IAAI,EAAE,mCAAmC;EACzCC,IAAI,EAAE,6CAA6C;EACnDC,SAAS,EAAE,WAAW;EACtBC,OAAO,CAAC;IAAEC;EAAM,CAAC,EAAE;IACf;;IAEA;AACR;AACA;IACQ,OAAO;MACHC,QAAQ,EAAED;IACd,CAAC;EACL,CAAC;EACDE,SAAS,CAAC;IAAED;EAAS,CAAC,EAAE;IACpB,OAAOA,QAAQ;EACnB;AACJ,CAAC,CAAC;AAAA"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryElasticsearchIndexPlugin } from "../../plugins/CmsEntryElasticsearchIndexPlugin";
2
+ export declare const base: CmsEntryElasticsearchIndexPlugin;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.base = void 0;
7
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
+ var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
9
+ const base = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
10
+ body: (0, _apiElasticsearch.getBaseConfiguration)()
11
+ });
12
+ exports.base = base;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["base","CmsEntryElasticsearchIndexPlugin","body","getBaseConfiguration"],"sources":["base.ts"],"sourcesContent":["import { getBaseConfiguration } from \"@webiny/api-elasticsearch\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\n\nexport const base = new CmsEntryElasticsearchIndexPlugin({\n body: getBaseConfiguration()\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEO,MAAMA,IAAI,GAAG,IAAIC,kEAAgC,CAAC;EACrDC,IAAI,EAAE,IAAAC,sCAAoB;AAC9B,CAAC,CAAC;AAAC"}
@@ -0,0 +1 @@
1
+ export declare const elasticsearchIndexPlugins: () => import("../..").CmsEntryElasticsearchIndexPlugin[];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elasticsearchIndexPlugins = void 0;
7
+ var _base = require("./base");
8
+ var _japanese = require("./japanese");
9
+ const elasticsearchIndexPlugins = () => {
10
+ return [_base.base, _japanese.japanese];
11
+ };
12
+ exports.elasticsearchIndexPlugins = elasticsearchIndexPlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["elasticsearchIndexPlugins","base","japanese"],"sources":["index.ts"],"sourcesContent":["import { base } from \"./base\";\nimport { japanese } from \"./japanese\";\n\nexport const elasticsearchIndexPlugins = () => {\n return [base, japanese];\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAACC,UAAI,EAAEC,kBAAQ,CAAC;AAC3B,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryElasticsearchIndexPlugin } from "../../plugins/CmsEntryElasticsearchIndexPlugin";
2
+ export declare const japanese: CmsEntryElasticsearchIndexPlugin;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.japanese = void 0;
7
+ var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
8
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
9
+ const japanese = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
10
+ body: (0, _apiElasticsearch.getJapaneseConfiguration)(),
11
+ locales: ["ja", "ja-jp"]
12
+ });
13
+ exports.japanese = japanese;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["japanese","CmsEntryElasticsearchIndexPlugin","body","getJapaneseConfiguration","locales"],"sources":["japanese.ts"],"sourcesContent":["import { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { getJapaneseConfiguration } from \"@webiny/api-elasticsearch\";\n\nexport const japanese = new CmsEntryElasticsearchIndexPlugin({\n body: getJapaneseConfiguration(),\n locales: [\"ja\", \"ja-jp\"]\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEO,MAAMA,QAAQ,GAAG,IAAIC,kEAAgC,CAAC;EACzDC,IAAI,EAAE,IAAAC,0CAAwB,GAAE;EAChCC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO;AAC3B,CAAC,CAAC;AAAC"}
@@ -1,3 +1,3 @@
1
- import { ElasticsearchQueryBuilderValueSearchPlugin } from "../../types";
2
- declare const _default: () => ElasticsearchQueryBuilderValueSearchPlugin[];
1
+ import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
2
+ declare const _default: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin[];
3
3
  export default _default;
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
-
10
- var _timeSearch = _interopRequireDefault(require("./timeSearch"));
11
-
12
- var _refSearch = _interopRequireDefault(require("./refSearch"));
13
-
14
- var _default = () => [(0, _timeSearch.default)(), (0, _refSearch.default)()];
15
-
7
+ var _timeSearch = require("./timeSearch");
8
+ var _refSearch = require("./refSearch");
9
+ var _default = () => [(0, _timeSearch.createTimeSearchPlugin)(), (0, _refSearch.createRefSearchPlugin)()];
16
10
  exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTimeSearchPlugin","createRefSearchPlugin"],"sources":["index.ts"],"sourcesContent":["import { createTimeSearchPlugin } from \"./timeSearch\";\nimport { createRefSearchPlugin } from \"./refSearch\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nexport default (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin[] => [\n createTimeSearchPlugin(),\n createRefSearchPlugin()\n];\n"],"mappings":";;;;;;AAAA;AACA;AAAoD,eAGrC,MAA4D,CACvE,IAAAA,kCAAsB,GAAE,EACxB,IAAAC,gCAAqB,GAAE,CAC1B;AAAA"}
@@ -1,3 +1,2 @@
1
- import { ElasticsearchQueryBuilderValueSearchPlugin } from "../../types";
2
- declare const _default: () => ElasticsearchQueryBuilderValueSearchPlugin;
3
- export default _default;
1
+ import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
2
+ export declare const createRefSearchPlugin: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
@@ -3,22 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
8
- var _default = () => ({
9
- type: "cms-elastic-search-query-builder-value-search",
10
- name: "cms-elastic-search-query-builder-value-search-ref-field",
11
- fieldType: "ref",
12
- transform: ({
13
- value
14
- }) => {
15
- return value;
16
- },
17
- createPath: ({
18
- field
19
- }) => {
20
- return `values.${field.fieldId}.entryId`;
6
+ exports.createRefSearchPlugin = void 0;
7
+ var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
8
+ const createPath = ({
9
+ field,
10
+ key
11
+ }) => {
12
+ if (key && key.match("entryId") === null) {
13
+ return `${field.storageId}.id`;
21
14
  }
22
- });
23
-
24
- exports.default = _default;
15
+ return `${field.storageId}.entryId`;
16
+ };
17
+ const transform = ({
18
+ value
19
+ }) => {
20
+ return value;
21
+ };
22
+ const createRefSearchPlugin = () => {
23
+ return new _CmsEntryElasticsearchQueryBuilderValueSearchPlugin.CmsEntryElasticsearchQueryBuilderValueSearchPlugin({
24
+ fieldType: "ref",
25
+ path: createPath,
26
+ transform
27
+ });
28
+ };
29
+ exports.createRefSearchPlugin = createRefSearchPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPath","field","key","match","storageId","transform","value","createRefSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","path"],"sources":["refSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallable,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst createPath: CreatePathCallable<string> = ({ field, key }) => {\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n};\n\nconst transform: TransformCallable = ({ value }) => {\n return value;\n};\n\nexport const createRefSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"ref\",\n path: createPath,\n transform\n });\n};\n"],"mappings":";;;;;;AAAA;AAMA,MAAMA,UAAsC,GAAG,CAAC;EAAEC,KAAK;EAAEC;AAAI,CAAC,KAAK;EAC/D,IAAIA,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;IACtC,OAAQ,GAAEF,KAAK,CAACG,SAAU,KAAI;EAClC;EACA,OAAQ,GAAEH,KAAK,CAACG,SAAU,UAAS;AACvC,CAAC;AAED,MAAMC,SAA4B,GAAG,CAAC;EAAEC;AAAM,CAAC,KAAK;EAChD,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,qBAAqB,GAAG,MAA0D;EAC3F,OAAO,IAAIC,sGAAkD,CAAC;IAC1DC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEV,UAAU;IAChBK;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,3 +1,2 @@
1
- import { ElasticsearchQueryBuilderValueSearchPlugin } from "../../types";
2
- declare const _default: () => ElasticsearchQueryBuilderValueSearchPlugin;
3
- export default _default;
1
+ import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
2
+ export declare const createTimeSearchPlugin: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
@@ -3,23 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
8
- var _default = () => ({
9
- type: "cms-elastic-search-query-builder-value-search",
10
- name: "elastic-search-query-builder-value-search-time",
11
- fieldType: "datetime",
12
- transform: ({
6
+ exports.createTimeSearchPlugin = void 0;
7
+ var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
8
+ const transform = params => {
9
+ var _field$settings;
10
+ const {
13
11
  field,
14
12
  value
15
- }) => {
16
- if (field.settings.type !== "time") {
17
- return value;
18
- }
19
-
20
- const [hours, minutes, seconds = 0] = value.split(":").map(Number);
21
- return hours * 60 * 60 + minutes * 60 + seconds;
13
+ } = params;
14
+ if (!value || ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.type) !== "time") {
15
+ return value;
22
16
  }
23
- });
24
-
25
- exports.default = _default;
17
+ const [hours, minutes, seconds = 0] = value.split(":").map(Number);
18
+ return hours * 60 * 60 + minutes * 60 + seconds;
19
+ };
20
+ const createTimeSearchPlugin = () => {
21
+ return new _CmsEntryElasticsearchQueryBuilderValueSearchPlugin.CmsEntryElasticsearchQueryBuilderValueSearchPlugin({
22
+ fieldType: "datetime",
23
+ transform
24
+ });
25
+ };
26
+ exports.createTimeSearchPlugin = createTimeSearchPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["transform","params","field","value","settings","type","hours","minutes","seconds","split","map","Number","createTimeSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType"],"sources":["timeSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst transform: TransformCallable = params => {\n const { field, value } = params;\n if (!value || field.settings?.type !== \"time\") {\n return value;\n }\n const [hours, minutes, seconds = 0] = value.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nexport const createTimeSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"datetime\",\n transform\n });\n};\n"],"mappings":";;;;;;AAAA;AAKA,MAAMA,SAA4B,GAAGC,MAAM,IAAI;EAAA;EAC3C,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAC/B,IAAI,CAACE,KAAK,IAAI,oBAAAD,KAAK,CAACE,QAAQ,oDAAd,gBAAgBC,IAAI,MAAK,MAAM,EAAE;IAC3C,OAAOF,KAAK;EAChB;EACA,MAAM,CAACG,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGL,KAAK,CAACM,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAClE,OAAOL,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,GAAGC,OAAO;AACnD,CAAC;AAEM,MAAMI,sBAAsB,GAAG,MAA0D;EAC5F,OAAO,IAAIC,sGAAkD,CAAC;IAC1DC,SAAS,EAAE,UAAU;IACrBd;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
10
  const prepareEntryToIndex = params => {
19
11
  const {
20
12
  plugins,
@@ -29,36 +21,32 @@ const prepareEntryToIndex = params => {
29
21
  } = setupEntriesIndexHelpers({
30
22
  plugins
31
23
  });
32
-
33
24
  function getFieldIndexPlugin(fieldType) {
34
25
  return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
35
26
  }
36
-
37
27
  function getFieldTypePlugin(fieldType) {
38
28
  const pl = fieldTypePlugins[fieldType];
39
-
40
29
  if (pl) {
41
30
  return pl;
42
31
  }
43
-
44
32
  throw new _error.default(`Missing field type plugin "${fieldType}". Prepare entry for index.`);
45
- } // These objects will contain values processed by field index plugins
46
-
33
+ }
47
34
 
35
+ // These objects will contain values processed by field index plugins
48
36
  const values = {};
49
- const rawValues = {}; // We're only interested in current model fields.
37
+ const rawValues = {};
50
38
 
39
+ // We're only interested in current model fields.
51
40
  for (const field of model.fields) {
52
- if (storageEntry.values.hasOwnProperty(field.fieldId) === false) {
41
+ if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
53
42
  continue;
54
43
  }
44
+ const targetFieldPlugin = getFieldIndexPlugin(field.type);
55
45
 
56
- const targetFieldPlugin = getFieldIndexPlugin(field.type); // TODO: remove this `if` once we convert this plugin to proper plugin class
57
-
46
+ // TODO: remove this `if` once we convert this plugin to proper plugin class
58
47
  if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
59
48
  continue;
60
49
  }
61
-
62
50
  const {
63
51
  value,
64
52
  rawValue
@@ -66,47 +54,40 @@ const prepareEntryToIndex = params => {
66
54
  plugins,
67
55
  model,
68
56
  field,
69
- rawValue: entry.values[field.fieldId],
70
- value: storageEntry.values[field.fieldId],
57
+ rawValue: entry.values[field.storageId],
58
+ value: storageEntry.values[field.storageId],
71
59
  getFieldIndexPlugin,
72
60
  getFieldTypePlugin
73
61
  });
74
-
75
62
  if (typeof value !== "undefined") {
76
- values[field.fieldId] = value;
63
+ values[field.storageId] = value;
77
64
  }
78
-
79
65
  if (typeof rawValue !== "undefined") {
80
- rawValues[field.fieldId] = rawValue;
66
+ rawValues[field.storageId] = rawValue;
81
67
  }
82
68
  }
83
-
84
- return _objectSpread(_objectSpread({}, storageEntry), {}, {
69
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
85
70
  values,
86
71
  rawValues
87
72
  });
88
73
  };
89
-
90
74
  exports.prepareEntryToIndex = prepareEntryToIndex;
91
-
92
75
  const setupEntriesIndexHelpers = ({
93
76
  plugins: pluginsContainer
94
77
  }) => {
95
78
  const plugins = pluginsContainer.byType("cms-model-field-to-elastic-search");
96
79
  const fieldIndexPlugins = {};
97
-
98
80
  for (const plugin of plugins.reverse()) {
99
81
  if (fieldIndexPlugins[plugin.fieldType]) {
100
82
  continue;
101
83
  }
102
-
103
84
  fieldIndexPlugins[plugin.fieldType] = plugin;
104
- } // we will use this plugin if no targeted plugin found
105
-
106
-
107
- const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === "*"); // CmsModelFieldToGraphQLPlugin plugins
85
+ }
86
+ // we will use this plugin if no targeted plugin found
87
+ const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === "*");
108
88
 
109
- const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => _objectSpread(_objectSpread({}, plugins), {}, {
89
+ // CmsModelFieldToGraphQLPlugin plugins
90
+ const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, plugins), {}, {
110
91
  [plugin.fieldType]: plugin
111
92
  }), {});
112
93
  return {
@@ -115,7 +96,6 @@ const setupEntriesIndexHelpers = ({
115
96
  fieldTypePlugins
116
97
  };
117
98
  };
118
-
119
99
  const extractEntriesFromIndex = ({
120
100
  plugins,
121
101
  entries,
@@ -128,47 +108,39 @@ const extractEntriesFromIndex = ({
128
108
  } = setupEntriesIndexHelpers({
129
109
  plugins
130
110
  });
131
-
132
111
  function getFieldIndexPlugin(fieldType) {
133
112
  return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
134
113
  }
135
-
136
114
  function getFieldTypePlugin(fieldType) {
137
115
  return fieldTypePlugins[fieldType];
138
116
  }
139
-
140
117
  const list = [];
141
-
142
118
  for (const entry of entries) {
143
119
  // This object will contain values processed by field index plugins
144
- const indexValues = {}; // We only consider fields that are present in the model
120
+ const indexValues = {};
145
121
 
122
+ // We only consider fields that are present in the model
146
123
  for (const field of model.fields) {
147
124
  const fieldTypePlugin = fieldTypePlugins[field.type];
148
-
149
125
  if (!fieldTypePlugin) {
150
126
  throw new _error.default(`Missing field type plugin "${field.type}". Extract entries from index.`);
151
127
  }
152
-
153
128
  const targetFieldPlugin = getFieldIndexPlugin(field.type);
154
-
155
129
  if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
156
130
  continue;
157
131
  }
158
-
159
132
  try {
160
- indexValues[field.fieldId] = targetFieldPlugin.fromIndex({
133
+ indexValues[field.storageId] = targetFieldPlugin.fromIndex({
161
134
  plugins,
162
135
  model,
163
136
  field,
164
137
  getFieldIndexPlugin,
165
138
  getFieldTypePlugin,
166
- value: entry.values[field.fieldId],
167
-
139
+ value: entry.values[field.storageId],
168
140
  /**
169
141
  * Possibly no rawValues so we must check for the existence of the field.
170
142
  */
171
- rawValue: entry.rawValues ? entry.rawValues[field.fieldId] : null
143
+ rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
172
144
  });
173
145
  } catch (ex) {
174
146
  throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
@@ -177,13 +149,27 @@ const extractEntriesFromIndex = ({
177
149
  });
178
150
  }
179
151
  }
180
-
181
- list.push(_objectSpread(_objectSpread({}, entry), {}, {
152
+ /**
153
+ * Let's have a new entry so we do not modify the original one.
154
+ */
155
+ const newEntry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
182
156
  values: indexValues
183
- }));
157
+ });
158
+ /**
159
+ * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
160
+ */
161
+ // @ts-ignore
162
+ delete newEntry["rawValues"];
163
+ // @ts-ignore
164
+ delete newEntry["TYPE"];
165
+ // @ts-ignore
166
+ delete newEntry["__type"];
167
+ // @ts-ignore
168
+ delete newEntry["latest"];
169
+ // @ts-ignore
170
+ delete newEntry["published"];
171
+ list.push((0, _objectSpread2.default)({}, newEntry));
184
172
  }
185
-
186
173
  return list;
187
174
  };
188
-
189
175
  exports.extractEntriesFromIndex = extractEntriesFromIndex;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","hasOwnProperty","storageId","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n if (storageEntry.values.hasOwnProperty(field.storageId) === false) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[field.storageId],\n value: storageEntry.values[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[field.storageId] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[field.storageId] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n try {\n indexValues[field.storageId] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[field.storageId],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":"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"}
@@ -1,2 +1 @@
1
- export * from "./createElasticsearchQueryBody";
2
1
  export * from "./entryIndexHelpers";
package/helpers/index.js CHANGED
@@ -3,22 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- var _createElasticsearchQueryBody = require("./createElasticsearchQueryBody");
8
-
9
- Object.keys(_createElasticsearchQueryBody).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _createElasticsearchQueryBody[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _createElasticsearchQueryBody[key];
16
- }
17
- });
18
- });
19
-
20
6
  var _entryIndexHelpers = require("./entryIndexHelpers");
21
-
22
7
  Object.keys(_entryIndexHelpers).forEach(function (key) {
23
8
  if (key === "default" || key === "__esModule") return;
24
9
  if (key in exports && exports[key] === _entryIndexHelpers[key]) return;
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { StorageOperationsFactory } from "./types";
2
+ export * from "./plugins";
2
3
  export declare const createStorageOperations: StorageOperationsFactory;