@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.0156a4c312

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 (309) hide show
  1. package/README.md +6 -30
  2. package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbEsDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
  7. package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
  8. package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbEsEntryEntity.js +5 -0
  10. package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
  11. package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbEsGroupEntity.js +5 -0
  13. package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
  14. package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
  15. package/abstractions/CmsDdbEsModelEntity.js +5 -0
  16. package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
  17. package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
  18. package/abstractions/CmsDdbEsOsTable.js +5 -0
  19. package/abstractions/CmsDdbEsOsTable.js.map +1 -0
  20. package/abstractions/CmsDdbEsTable.d.ts +5 -0
  21. package/abstractions/CmsDdbEsTable.js +5 -0
  22. package/abstractions/CmsDdbEsTable.js.map +1 -0
  23. package/debuggerNamespaces.d.ts +12 -0
  24. package/debuggerNamespaces.js +0 -0
  25. package/definitions/entry.d.ts +5 -6
  26. package/definitions/entry.js +9 -89
  27. package/definitions/entry.js.map +1 -0
  28. package/definitions/group.d.ts +6 -6
  29. package/definitions/group.js +9 -72
  30. package/definitions/group.js.map +1 -0
  31. package/definitions/model.d.ts +6 -6
  32. package/definitions/model.js +9 -94
  33. package/definitions/model.js.map +1 -0
  34. package/definitions/types.d.ts +65 -0
  35. package/definitions/types.js +0 -0
  36. package/feature.d.ts +10 -0
  37. package/feature.js +69 -0
  38. package/feature.js.map +1 -0
  39. package/index.d.ts +1 -2
  40. package/index.js +1 -171
  41. package/operations/entry/DdbEsCreateEntry.d.ts +24 -0
  42. package/operations/entry/DdbEsCreateEntry.js +134 -0
  43. package/operations/entry/DdbEsCreateEntry.js.map +1 -0
  44. package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +24 -0
  45. package/operations/entry/DdbEsCreateEntryRevisionFrom.js +139 -0
  46. package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
  47. package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
  48. package/operations/entry/DdbEsDeleteEntry.js +79 -0
  49. package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
  50. package/operations/entry/DdbEsDeleteEntryRevision.d.ts +24 -0
  51. package/operations/entry/DdbEsDeleteEntryRevision.js +136 -0
  52. package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
  53. package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
  54. package/operations/entry/DdbEsDeleteMultipleEntries.js +80 -0
  55. package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
  56. package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
  57. package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
  58. package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
  59. package/operations/entry/DdbEsGetEntry.d.ts +14 -0
  60. package/operations/entry/DdbEsGetEntry.js +27 -0
  61. package/operations/entry/DdbEsGetEntry.js.map +1 -0
  62. package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
  63. package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
  64. package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
  65. package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
  66. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
  67. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
  68. package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
  69. package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
  70. package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
  71. package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
  72. package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
  73. package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
  74. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
  75. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
  76. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
  77. package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
  78. package/operations/entry/DdbEsGetRevisionById.js +34 -0
  79. package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
  80. package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
  81. package/operations/entry/DdbEsGetRevisions.js +33 -0
  82. package/operations/entry/DdbEsGetRevisions.js.map +1 -0
  83. package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +18 -0
  84. package/operations/entry/DdbEsGetUniqueFieldValues.js +77 -0
  85. package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
  86. package/operations/entry/DdbEsListEntries.d.ts +28 -0
  87. package/operations/entry/DdbEsListEntries.js +110 -0
  88. package/operations/entry/DdbEsListEntries.js.map +1 -0
  89. package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
  90. package/operations/entry/DdbEsMoveEntry.js +113 -0
  91. package/operations/entry/DdbEsMoveEntry.js.map +1 -0
  92. package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
  93. package/operations/entry/DdbEsMoveToBin.js +137 -0
  94. package/operations/entry/DdbEsMoveToBin.js.map +1 -0
  95. package/operations/entry/DdbEsPublishEntry.d.ts +24 -0
  96. package/operations/entry/DdbEsPublishEntry.js +231 -0
  97. package/operations/entry/DdbEsPublishEntry.js.map +1 -0
  98. package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
  99. package/operations/entry/DdbEsRestoreFromBin.js +137 -0
  100. package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
  101. package/operations/entry/DdbEsUnpublishEntry.d.ts +24 -0
  102. package/operations/entry/DdbEsUnpublishEntry.js +127 -0
  103. package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
  104. package/operations/entry/DdbEsUpdateEntry.d.ts +24 -0
  105. package/operations/entry/DdbEsUpdateEntry.js +175 -0
  106. package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
  107. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  108. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  109. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  110. package/operations/entry/dataLoader/constants.d.ts +1 -0
  111. package/operations/entry/dataLoader/constants.js +5 -0
  112. package/operations/entry/dataLoader/constants.js.map +1 -0
  113. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  114. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  115. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  116. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  117. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  118. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  120. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  121. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  123. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  124. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  125. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  126. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  127. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  128. package/operations/entry/dataLoader/index.d.ts +8 -0
  129. package/operations/entry/dataLoader/index.js +18 -0
  130. package/operations/entry/dataLoader/index.js.map +1 -0
  131. package/operations/entry/dataLoader/types.d.ts +6 -0
  132. package/operations/entry/dataLoader/types.js +0 -0
  133. package/operations/entry/dataLoaders.d.ts +22 -39
  134. package/operations/entry/dataLoaders.js +90 -339
  135. package/operations/entry/dataLoaders.js.map +1 -0
  136. package/operations/entry/feature.d.ts +4 -0
  137. package/operations/entry/feature.js +55 -0
  138. package/operations/entry/feature.js.map +1 -0
  139. package/operations/entry/keys.d.ts +31 -1
  140. package/operations/entry/keys.js +45 -35
  141. package/operations/entry/keys.js.map +1 -0
  142. package/operations/entry/recordType.d.ts +3 -0
  143. package/operations/entry/recordType.js +6 -0
  144. package/operations/entry/recordType.js.map +1 -0
  145. package/operations/entry/storageEntryUtils.d.ts +7 -0
  146. package/operations/entry/storageEntryUtils.js +14 -0
  147. package/operations/entry/storageEntryUtils.js.map +1 -0
  148. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  149. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  150. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  151. package/operations/entry/transformations/index.d.ts +32 -0
  152. package/operations/entry/transformations/index.js +91 -0
  153. package/operations/entry/transformations/index.js.map +1 -0
  154. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  155. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  156. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  157. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  158. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  159. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  160. package/operations/group/DdbEsCreateGroup.d.ts +12 -0
  161. package/operations/group/DdbEsCreateGroup.js +35 -0
  162. package/operations/group/DdbEsCreateGroup.js.map +1 -0
  163. package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
  164. package/operations/group/DdbEsDeleteGroup.js +31 -0
  165. package/operations/group/DdbEsDeleteGroup.js.map +1 -0
  166. package/operations/group/DdbEsGetGroup.d.ts +12 -0
  167. package/operations/group/DdbEsGetGroup.js +31 -0
  168. package/operations/group/DdbEsGetGroup.js.map +1 -0
  169. package/operations/group/DdbEsListGroups.d.ts +14 -0
  170. package/operations/group/DdbEsListGroups.js +52 -0
  171. package/operations/group/DdbEsListGroups.js.map +1 -0
  172. package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
  173. package/operations/group/DdbEsUpdateGroup.js +35 -0
  174. package/operations/group/DdbEsUpdateGroup.js.map +1 -0
  175. package/operations/group/feature.d.ts +4 -0
  176. package/operations/group/feature.js +19 -0
  177. package/operations/group/feature.js.map +1 -0
  178. package/operations/group/keys.d.ts +15 -0
  179. package/operations/group/keys.js +17 -0
  180. package/operations/group/keys.js.map +1 -0
  181. package/operations/model/DdbEsCreateModel.d.ts +16 -0
  182. package/operations/model/DdbEsCreateModel.js +56 -0
  183. package/operations/model/DdbEsCreateModel.js.map +1 -0
  184. package/operations/model/DdbEsDeleteModel.d.ts +12 -0
  185. package/operations/model/DdbEsDeleteModel.js +31 -0
  186. package/operations/model/DdbEsDeleteModel.js.map +1 -0
  187. package/operations/model/DdbEsGetModel.d.ts +12 -0
  188. package/operations/model/DdbEsGetModel.js +30 -0
  189. package/operations/model/DdbEsGetModel.js.map +1 -0
  190. package/operations/model/DdbEsListModels.d.ts +12 -0
  191. package/operations/model/DdbEsListModels.js +36 -0
  192. package/operations/model/DdbEsListModels.js.map +1 -0
  193. package/operations/model/DdbEsUpdateModel.d.ts +12 -0
  194. package/operations/model/DdbEsUpdateModel.js +36 -0
  195. package/operations/model/DdbEsUpdateModel.js.map +1 -0
  196. package/operations/model/feature.d.ts +4 -0
  197. package/operations/model/feature.js +19 -0
  198. package/operations/model/feature.js.map +1 -0
  199. package/operations/model/keys.d.ts +15 -0
  200. package/operations/model/keys.js +17 -0
  201. package/operations/model/keys.js.map +1 -0
  202. package/package.json +49 -46
  203. package/registry/CmsEntitiesDbRegistryDecorator.d.ts +27 -0
  204. package/registry/CmsEntitiesDbRegistryDecorator.js +46 -0
  205. package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -0
  206. package/tasks/CreateElasticsearchIndexTask.d.ts +15 -0
  207. package/tasks/CreateElasticsearchIndexTask.js +49 -0
  208. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  209. package/types.d.ts +13 -182
  210. package/types.js +10 -60
  211. package/types.js.map +1 -0
  212. package/configurations.d.ts +0 -12
  213. package/configurations.js +0 -32
  214. package/definitions/entryElasticsearch.d.ts +0 -8
  215. package/definitions/entryElasticsearch.js +0 -46
  216. package/definitions/settings.d.ts +0 -8
  217. package/definitions/settings.js +0 -62
  218. package/definitions/system.d.ts +0 -8
  219. package/definitions/system.js +0 -50
  220. package/definitions/table.d.ts +0 -8
  221. package/definitions/table.js +0 -24
  222. package/definitions/tableElasticsearch.d.ts +0 -8
  223. package/definitions/tableElasticsearch.js +0 -24
  224. package/dynamoDb/index.d.ts +0 -2
  225. package/dynamoDb/index.js +0 -18
  226. package/dynamoDb/storage/date.d.ts +0 -3
  227. package/dynamoDb/storage/date.js +0 -65
  228. package/dynamoDb/storage/longText.d.ts +0 -7
  229. package/dynamoDb/storage/longText.js +0 -83
  230. package/dynamoDb/storage/richText.d.ts +0 -8
  231. package/dynamoDb/storage/richText.js +0 -110
  232. package/elasticsearch/index.d.ts +0 -2
  233. package/elasticsearch/index.js +0 -16
  234. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  235. package/elasticsearch/indexing/dateTimeIndexing.js +0 -89
  236. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  237. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -47
  238. package/elasticsearch/indexing/index.d.ts +0 -2
  239. package/elasticsearch/indexing/index.js +0 -24
  240. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -3
  241. package/elasticsearch/indexing/longTextIndexing.js +0 -36
  242. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  243. package/elasticsearch/indexing/numberIndexing.js +0 -48
  244. package/elasticsearch/indexing/objectIndexing.d.ts +0 -3
  245. package/elasticsearch/indexing/objectIndexing.js +0 -200
  246. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  247. package/elasticsearch/indexing/richTextIndexing.js +0 -34
  248. package/elasticsearch/search/index.d.ts +0 -3
  249. package/elasticsearch/search/index.js +0 -16
  250. package/elasticsearch/search/refSearch.d.ts +0 -3
  251. package/elasticsearch/search/refSearch.js +0 -24
  252. package/elasticsearch/search/timeSearch.d.ts +0 -3
  253. package/elasticsearch/search/timeSearch.js +0 -25
  254. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  255. package/helpers/createElasticsearchQueryBody.js +0 -375
  256. package/helpers/entryIndexHelpers.d.ts +0 -18
  257. package/helpers/entryIndexHelpers.js +0 -189
  258. package/helpers/fields.d.ts +0 -77
  259. package/helpers/fields.js +0 -174
  260. package/helpers/index.d.ts +0 -2
  261. package/helpers/index.js +0 -31
  262. package/helpers/operatorPluginsList.d.ts +0 -7
  263. package/helpers/operatorPluginsList.js +0 -30
  264. package/helpers/searchPluginsList.d.ts +0 -6
  265. package/helpers/searchPluginsList.js +0 -26
  266. package/helpers/transformValueForSearch.d.ts +0 -9
  267. package/helpers/transformValueForSearch.js +0 -26
  268. package/operations/entry/elasticsearchFields.d.ts +0 -2
  269. package/operations/entry/elasticsearchFields.js +0 -32
  270. package/operations/entry/fields.d.ts +0 -3
  271. package/operations/entry/fields.js +0 -60
  272. package/operations/entry/index.d.ts +0 -13
  273. package/operations/entry/index.js +0 -1152
  274. package/operations/group/index.d.ts +0 -8
  275. package/operations/group/index.js +0 -202
  276. package/operations/model/index.d.ts +0 -8
  277. package/operations/model/index.js +0 -205
  278. package/operations/settings/index.d.ts +0 -6
  279. package/operations/settings/index.js +0 -141
  280. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  281. package/operations/system/createElasticsearchTemplate.js +0 -62
  282. package/operations/system/index.d.ts +0 -6
  283. package/operations/system/index.js +0 -105
  284. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -17
  285. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -24
  286. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  287. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  288. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -17
  289. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -24
  290. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -17
  291. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -24
  292. package/upgrades/index.d.ts +0 -2
  293. package/upgrades/index.js +0 -16
  294. package/upgrades/utils.d.ts +0 -1
  295. package/upgrades/utils.js +0 -16
  296. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  297. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  298. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  299. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  300. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  301. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  302. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  303. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  304. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  305. package/upgrades/v5.0.0/helpers.js +0 -57
  306. package/upgrades/v5.0.0/index.d.ts +0 -4
  307. package/upgrades/v5.0.0/index.js +0 -232
  308. package/upgrades/v5.8.0/index.d.ts +0 -4
  309. package/upgrades/v5.8.0/index.js +0 -426
@@ -1,375 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createElasticsearchQueryBody = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
- var _operatorPluginsList = require("./operatorPluginsList");
15
-
16
- var _transformValueForSearch = require("./transformValueForSearch");
17
-
18
- var _searchPluginsList = require("./searchPluginsList");
19
-
20
- var _cursors = require("@webiny/api-elasticsearch/cursors");
21
-
22
- var _sort = require("@webiny/api-elasticsearch/sort");
23
-
24
- var _fields = require("./fields");
25
-
26
- var _CmsEntryElasticsearchFieldPlugin = require("../plugins/CmsEntryElasticsearchFieldPlugin");
27
-
28
- var _where = require("@webiny/api-elasticsearch/where");
29
-
30
- var _entry = require("../operations/entry");
31
-
32
- var _CmsEntryElasticsearchQueryModifierPlugin = require("../plugins/CmsEntryElasticsearchQueryModifierPlugin");
33
-
34
- var _CmsEntryElasticsearchSortModifierPlugin = require("../plugins/CmsEntryElasticsearchSortModifierPlugin");
35
-
36
- var _CmsEntryElasticsearchBodyModifierPlugin = require("../plugins/CmsEntryElasticsearchBodyModifierPlugin");
37
-
38
- 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; }
39
-
40
- 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; }
41
-
42
- const specialFields = ["published", "latest", "locale", "tenant"];
43
- const noKeywordFields = ["date", "number", "boolean"];
44
-
45
- const createElasticsearchSortParams = args => {
46
- const {
47
- sort,
48
- modelFields,
49
- parentPath,
50
- searchPlugins
51
- } = args;
52
-
53
- if (!sort || sort.length === 0) {
54
- return undefined;
55
- }
56
-
57
- const sortPlugins = Object.values(modelFields).reduce((plugins, modelField) => {
58
- const searchPlugin = searchPlugins[modelField.type];
59
- plugins[modelField.field.fieldId] = new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
60
- unmappedType: modelField.unmappedType,
61
- keyword: hasKeyword(modelField),
62
- sortable: modelField.isSortable,
63
- searchable: modelField.isSearchable,
64
- field: modelField.field.fieldId,
65
- path: createFieldPath({
66
- parentPath,
67
- modelField: modelField,
68
- searchPlugin
69
- })
70
- });
71
- return plugins;
72
- }, {});
73
- return (0, _sort.createSort)({
74
- fieldPlugins: sortPlugins,
75
- sort
76
- });
77
- };
78
- /**
79
- * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
80
- * We allow either published or either latest.
81
- * Latest is used in the manage API and published in the read API.
82
- */
83
-
84
-
85
- const createInitialQueryValue = args => {
86
- const {
87
- where
88
- } = args;
89
- const query = {
90
- must: [],
91
- must_not: [],
92
- should: [],
93
- filter: []
94
- }; // When ES index is shared between tenants, we need to filter records by tenant ID
95
-
96
- const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
97
-
98
- if (sharedIndex) {
99
- query.must.push({
100
- term: {
101
- "tenant.keyword": where.tenant
102
- }
103
- });
104
- }
105
-
106
- delete where["tenant"];
107
-
108
- if (where.locale) {
109
- query.must.push({
110
- term: {
111
- "locale.keyword": where.locale
112
- }
113
- });
114
- }
115
-
116
- delete where["locale"];
117
- /**
118
- * We must transform published and latest where args into something that is understandable by our Elasticsearch
119
- */
120
-
121
- if (where.published === true) {
122
- query.must.push({
123
- term: {
124
- "__type.keyword": (0, _entry.createPublishedType)()
125
- }
126
- });
127
- } else if (where.latest === true) {
128
- query.must.push({
129
- term: {
130
- "__type.keyword": (0, _entry.createLatestType)()
131
- }
132
- });
133
- } // we do not allow not published and not latest
134
- else if (where.published === false) {
135
- throw new _error.default(`Cannot call Elasticsearch query with "published" set at false.`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
136
- where
137
- });
138
- } else if (where.latest === false) {
139
- throw new _error.default(`Cannot call Elasticsearch query with "latest" set at false.`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
140
- where
141
- });
142
- } //
143
-
144
-
145
- return query;
146
- };
147
-
148
- const createFieldPath = ({
149
- modelField,
150
- searchPlugin,
151
- parentPath
152
- }) => {
153
- let path;
154
-
155
- if (searchPlugin && typeof searchPlugin.createPath === "function") {
156
- path = searchPlugin.createPath({
157
- field: modelField.field
158
- });
159
- } else if (typeof modelField.path === "function") {
160
- path = modelField.path(modelField.field.fieldId);
161
- }
162
-
163
- if (!path) {
164
- path = modelField.path || modelField.field.fieldId || modelField.field.id;
165
- }
166
-
167
- return modelField.isSystemField || !parentPath || path.match(parentPath) ? path : `${parentPath}.${path}`;
168
- };
169
-
170
- const hasKeyword = modelField => {
171
- /**
172
- * We defined some field types that MUST have no keyword added to the field path
173
- */
174
- if (noKeywordFields.includes(modelField.type)) {
175
- return false;
176
- } else if (modelField.unmappedType) {
177
- /**
178
- * If modelField has unmapped type defined, do not add keyword.
179
- */
180
- return false;
181
- } else if (modelField.keyword === false) {
182
- /**
183
- * And if specifically defined that modelField has no keyword, do not add it.
184
- */
185
- return false;
186
- }
187
- /**
188
- * All other fields have keyword added.
189
- */
190
-
191
-
192
- return true;
193
- };
194
- /*
195
- * Iterate through where keys and apply plugins where necessary
196
- */
197
-
198
-
199
- const execElasticsearchBuildQueryPlugins = params => {
200
- const {
201
- where: initialWhere,
202
- modelFields,
203
- parentPath,
204
- plugins,
205
- searchPlugins
206
- } = params;
207
-
208
- const where = _objectSpread({}, initialWhere);
209
-
210
- const query = createInitialQueryValue(_objectSpread(_objectSpread({}, params), {}, {
211
- where
212
- }));
213
- /**
214
- * Always remove special fields, as these do not exist in Elasticsearch.
215
- */
216
-
217
- for (const sf of specialFields) {
218
- delete where[sf];
219
- }
220
-
221
- if (Object.keys(where).length === 0) {
222
- return query;
223
- }
224
-
225
- const operatorPlugins = (0, _operatorPluginsList.operatorPluginsList)(plugins);
226
-
227
- for (const key in where) {
228
- if (where.hasOwnProperty(key) === false) {
229
- continue;
230
- }
231
- /**
232
- * We do not need to go further if value is undefined.
233
- * There are few hardcoded possibilities when value is undefined, for example, ownedBy.
234
- */
235
-
236
-
237
- if (where[key] === undefined) {
238
- continue;
239
- }
240
-
241
- const {
242
- field,
243
- operator
244
- } = (0, _where.parseWhereKey)(key);
245
- const modelField = modelFields[field];
246
-
247
- if (!modelField) {
248
- throw new _error.default(`There is no field "${field}".`);
249
- }
250
-
251
- const {
252
- isSearchable = false,
253
- field: cmsField
254
- } = modelField;
255
-
256
- if (!isSearchable) {
257
- throw new _error.default(`Field "${field}" is not searchable.`);
258
- }
259
-
260
- const plugin = operatorPlugins[operator];
261
-
262
- if (!plugin) {
263
- throw new _error.default("Operator plugin missing.", "PLUGIN_MISSING", {
264
- operator
265
- });
266
- }
267
-
268
- const fieldSearchPlugin = searchPlugins[modelField.type];
269
- const value = (0, _transformValueForSearch.transformValueForSearch)({
270
- plugins: searchPlugins,
271
- field: cmsField,
272
- value: where[key]
273
- });
274
- const fieldPath = createFieldPath({
275
- searchPlugin: fieldSearchPlugin,
276
- modelField,
277
- parentPath: parentPath
278
- });
279
- const keyword = hasKeyword(modelField);
280
- plugin.apply(query, {
281
- basePath: fieldPath,
282
- path: keyword ? `${fieldPath}.keyword` : fieldPath,
283
- value,
284
- keyword
285
- });
286
- }
287
-
288
- return query;
289
- };
290
-
291
- const createElasticsearchQueryBody = params => {
292
- const {
293
- plugins,
294
- model,
295
- args,
296
- parentPath = null
297
- } = params;
298
- const {
299
- where,
300
- after,
301
- limit,
302
- sort: initialSort
303
- } = args;
304
- const modelFields = (0, _fields.createModelFields)(plugins, model);
305
- const searchPlugins = (0, _searchPluginsList.searchPluginsList)(plugins);
306
- const query = execElasticsearchBuildQueryPlugins({
307
- model,
308
- plugins,
309
- where,
310
- modelFields,
311
- parentPath,
312
- searchPlugins
313
- });
314
- const queryPlugins = plugins.byType(_CmsEntryElasticsearchQueryModifierPlugin.CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
315
- return !pl.modelId || pl.modelId === model.modelId;
316
- });
317
-
318
- for (const pl of queryPlugins) {
319
- pl.modifyQuery({
320
- query,
321
- model,
322
- where
323
- });
324
- }
325
-
326
- const sort = createElasticsearchSortParams({
327
- plugins,
328
- sort: initialSort,
329
- modelFields,
330
- parentPath,
331
- model,
332
- searchPlugins
333
- });
334
- const sortPlugins = plugins.byType(_CmsEntryElasticsearchSortModifierPlugin.CmsEntryElasticsearchSortModifierPlugin.type).filter(pl => {
335
- return !pl.modelId || pl.modelId === model.modelId;
336
- });
337
-
338
- for (const pl of sortPlugins) {
339
- pl.modifySort({
340
- sort,
341
- model
342
- });
343
- }
344
-
345
- const body = {
346
- query: {
347
- bool: {
348
- must: query.must.length > 0 ? query.must : undefined,
349
- must_not: query.must_not.length > 0 ? query.must_not : undefined,
350
- should: query.should.length > 0 ? query.should : undefined,
351
- filter: query.filter.length > 0 ? query.filter : undefined
352
- }
353
- },
354
- sort,
355
- size: limit + 1,
356
- // eslint-disable-next-line
357
- search_after: (0, _cursors.decodeCursor)(after),
358
- // eslint-disable-next-line
359
- track_total_hits: true
360
- };
361
- const bodyPlugins = plugins.byType(_CmsEntryElasticsearchBodyModifierPlugin.CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
362
- return !pl.modelId || pl.modelId === model.modelId;
363
- });
364
-
365
- for (const pl of bodyPlugins) {
366
- pl.modifyBody({
367
- body,
368
- model
369
- });
370
- }
371
-
372
- return body;
373
- };
374
-
375
- exports.createElasticsearchQueryBody = createElasticsearchQueryBody;
@@ -1,18 +0,0 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- import { CmsIndexEntry } from "../types";
3
- import { PluginsContainer } from "@webiny/plugins";
4
- interface SetupEntriesIndexHelpersParams {
5
- plugins: PluginsContainer;
6
- }
7
- interface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {
8
- model: CmsModel;
9
- entries: CmsIndexEntry[];
10
- }
11
- interface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {
12
- model: CmsModel;
13
- entry: CmsEntry;
14
- storageEntry: CmsEntry;
15
- }
16
- export declare const prepareEntryToIndex: (params: PrepareElasticsearchDataParams) => CmsIndexEntry;
17
- export declare const extractEntriesFromIndex: ({ plugins, entries, model }: ExtractEntriesFromIndexParams) => CmsEntry[];
18
- export {};
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- 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
- const prepareEntryToIndex = params => {
19
- const {
20
- plugins,
21
- storageEntry,
22
- entry,
23
- model
24
- } = params;
25
- const {
26
- fieldIndexPlugins,
27
- defaultIndexFieldPlugin,
28
- fieldTypePlugins
29
- } = setupEntriesIndexHelpers({
30
- plugins
31
- });
32
-
33
- function getFieldIndexPlugin(fieldType) {
34
- return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
35
- }
36
-
37
- function getFieldTypePlugin(fieldType) {
38
- const pl = fieldTypePlugins[fieldType];
39
-
40
- if (pl) {
41
- return pl;
42
- }
43
-
44
- 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
-
47
-
48
- const values = {};
49
- const rawValues = {}; // We're only interested in current model fields.
50
-
51
- for (const field of model.fields) {
52
- if (storageEntry.values.hasOwnProperty(field.fieldId) === false) {
53
- continue;
54
- }
55
-
56
- const targetFieldPlugin = getFieldIndexPlugin(field.type); // TODO: remove this `if` once we convert this plugin to proper plugin class
57
-
58
- if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
59
- continue;
60
- }
61
-
62
- const {
63
- value,
64
- rawValue
65
- } = targetFieldPlugin.toIndex({
66
- plugins,
67
- model,
68
- field,
69
- rawValue: entry.values[field.fieldId],
70
- value: storageEntry.values[field.fieldId],
71
- getFieldIndexPlugin,
72
- getFieldTypePlugin
73
- });
74
-
75
- if (typeof value !== "undefined") {
76
- values[field.fieldId] = value;
77
- }
78
-
79
- if (typeof rawValue !== "undefined") {
80
- rawValues[field.fieldId] = rawValue;
81
- }
82
- }
83
-
84
- return _objectSpread(_objectSpread({}, storageEntry), {}, {
85
- values,
86
- rawValues
87
- });
88
- };
89
-
90
- exports.prepareEntryToIndex = prepareEntryToIndex;
91
-
92
- const setupEntriesIndexHelpers = ({
93
- plugins: pluginsContainer
94
- }) => {
95
- const plugins = pluginsContainer.byType("cms-model-field-to-elastic-search");
96
- const fieldIndexPlugins = {};
97
-
98
- for (const plugin of plugins.reverse()) {
99
- if (fieldIndexPlugins[plugin.fieldType]) {
100
- continue;
101
- }
102
-
103
- 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
108
-
109
- const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => _objectSpread(_objectSpread({}, plugins), {}, {
110
- [plugin.fieldType]: plugin
111
- }), {});
112
- return {
113
- fieldIndexPlugins,
114
- defaultIndexFieldPlugin,
115
- fieldTypePlugins
116
- };
117
- };
118
-
119
- const extractEntriesFromIndex = ({
120
- plugins,
121
- entries,
122
- model
123
- }) => {
124
- const {
125
- fieldIndexPlugins,
126
- defaultIndexFieldPlugin,
127
- fieldTypePlugins
128
- } = setupEntriesIndexHelpers({
129
- plugins
130
- });
131
-
132
- function getFieldIndexPlugin(fieldType) {
133
- return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
134
- }
135
-
136
- function getFieldTypePlugin(fieldType) {
137
- return fieldTypePlugins[fieldType];
138
- }
139
-
140
- const list = [];
141
-
142
- for (const entry of entries) {
143
- // This object will contain values processed by field index plugins
144
- const indexValues = {}; // We only consider fields that are present in the model
145
-
146
- for (const field of model.fields) {
147
- const fieldTypePlugin = fieldTypePlugins[field.type];
148
-
149
- if (!fieldTypePlugin) {
150
- throw new _error.default(`Missing field type plugin "${field.type}". Extract entries from index.`);
151
- }
152
-
153
- const targetFieldPlugin = getFieldIndexPlugin(field.type);
154
-
155
- if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
156
- continue;
157
- }
158
-
159
- try {
160
- indexValues[field.fieldId] = targetFieldPlugin.fromIndex({
161
- plugins,
162
- model,
163
- field,
164
- getFieldIndexPlugin,
165
- getFieldTypePlugin,
166
- value: entry.values[field.fieldId],
167
-
168
- /**
169
- * Possibly no rawValues so we must check for the existence of the field.
170
- */
171
- rawValue: entry.rawValues ? entry.rawValues[field.fieldId] : null
172
- });
173
- } catch (ex) {
174
- throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
175
- field,
176
- entry
177
- });
178
- }
179
- }
180
-
181
- list.push(_objectSpread(_objectSpread({}, entry), {}, {
182
- values: indexValues
183
- }));
184
- }
185
-
186
- return list;
187
- };
188
-
189
- exports.extractEntriesFromIndex = extractEntriesFromIndex;
@@ -1,77 +0,0 @@
1
- import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- declare type ModelFieldPath = string | ((value: string) => string);
4
- export interface ModelField {
5
- unmappedType?: string;
6
- keyword?: boolean;
7
- isSearchable: boolean;
8
- isSortable: boolean;
9
- type: string;
10
- isSystemField?: boolean;
11
- field: CmsModelField;
12
- path?: ModelFieldPath;
13
- }
14
- export declare type ModelFields = Record<string, ModelField>;
15
- export declare const systemFields: {
16
- id: {
17
- type: string;
18
- isSystemField: boolean;
19
- isSearchable: boolean;
20
- isSortable: boolean;
21
- field: CmsModelField;
22
- };
23
- entryId: {
24
- type: string;
25
- isSystemField: boolean;
26
- isSearchable: boolean;
27
- isSortable: boolean;
28
- field: CmsModelField;
29
- };
30
- savedOn: {
31
- type: string;
32
- unmappedType: string;
33
- keyword: boolean;
34
- isSystemField: boolean;
35
- isSearchable: boolean;
36
- isSortable: boolean;
37
- field: CmsModelField;
38
- };
39
- createdOn: {
40
- type: string;
41
- unmappedType: string;
42
- keyword: boolean;
43
- isSystemField: boolean;
44
- isSearchable: boolean;
45
- isSortable: boolean;
46
- field: CmsModelField;
47
- };
48
- createdBy: {
49
- type: string;
50
- unmappedType: any;
51
- isSystemField: boolean;
52
- isSearchable: boolean;
53
- isSortable: boolean;
54
- path: string;
55
- field: CmsModelField;
56
- };
57
- ownedBy: {
58
- type: string;
59
- unmappedType: any;
60
- isSystemField: boolean;
61
- isSearchable: boolean;
62
- isSortable: boolean;
63
- path: string;
64
- field: CmsModelField;
65
- };
66
- version: {
67
- type: string;
68
- unmappedType: any;
69
- keyword: boolean;
70
- isSystemField: boolean;
71
- isSearchable: boolean;
72
- isSortable: boolean;
73
- field: CmsModelField;
74
- };
75
- };
76
- export declare const createModelFields: (plugins: PluginsContainer, model: CmsModel) => ModelFields;
77
- export {};