@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.06b2ede40f

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 (325) hide show
  1. package/configurations.d.ts +15 -8
  2. package/configurations.js +29 -12
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +6 -5
  5. package/definitions/entry.js +111 -20
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +6 -5
  8. package/definitions/entryElasticsearch.js +11 -16
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +6 -5
  11. package/definitions/group.js +8 -16
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +6 -5
  14. package/definitions/model.js +30 -16
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/system.d.ts +6 -5
  17. package/definitions/system.js +8 -16
  18. package/definitions/system.js.map +1 -0
  19. package/definitions/table.d.ts +6 -6
  20. package/definitions/table.js +7 -6
  21. package/definitions/table.js.map +1 -0
  22. package/definitions/tableElasticsearch.d.ts +6 -6
  23. package/definitions/tableElasticsearch.js +7 -6
  24. package/definitions/tableElasticsearch.js.map +1 -0
  25. package/dynamoDb/index.d.ts +2 -1
  26. package/dynamoDb/index.js +10 -12
  27. package/dynamoDb/index.js.map +1 -0
  28. package/dynamoDb/storage/longText.d.ts +7 -4
  29. package/dynamoDb/storage/longText.js +75 -62
  30. package/dynamoDb/storage/longText.js.map +1 -0
  31. package/dynamoDb/storage/richText.d.ts +2 -8
  32. package/dynamoDb/storage/richText.js +49 -100
  33. package/dynamoDb/storage/richText.js.map +1 -0
  34. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  35. package/elasticsearch/createElasticsearchIndex.js +40 -0
  36. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  37. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  38. package/elasticsearch/deleteElasticsearchIndex.js +38 -0
  39. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  40. package/elasticsearch/index.d.ts +1 -1
  41. package/elasticsearch/index.js +3 -6
  42. package/elasticsearch/index.js.map +1 -0
  43. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  44. package/elasticsearch/indexing/dateTimeIndexing.js +21 -22
  45. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  46. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  47. package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
  48. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/index.js +5 -11
  50. package/elasticsearch/indexing/index.js.map +1 -0
  51. package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
  52. package/elasticsearch/indexing/jsonIndexing.js +28 -0
  53. package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
  55. package/elasticsearch/indexing/longTextIndexing.js +16 -10
  56. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  58. package/elasticsearch/indexing/numberIndexing.js +2 -9
  59. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  60. package/elasticsearch/indexing/objectIndexing.d.ts +10 -1
  61. package/elasticsearch/indexing/objectIndexing.js +37 -36
  62. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  64. package/elasticsearch/indexing/richTextIndexing.js +2 -5
  65. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  66. package/elasticsearch/indices/base.d.ts +2 -0
  67. package/elasticsearch/indices/base.js +13 -0
  68. package/elasticsearch/indices/base.js.map +1 -0
  69. package/elasticsearch/indices/index.d.ts +1 -0
  70. package/elasticsearch/indices/index.js +14 -0
  71. package/elasticsearch/indices/index.js.map +1 -0
  72. package/elasticsearch/indices/japanese.d.ts +2 -0
  73. package/elasticsearch/indices/japanese.js +14 -0
  74. package/elasticsearch/indices/japanese.js.map +1 -0
  75. package/elasticsearch/search/index.d.ts +2 -2
  76. package/elasticsearch/search/index.js +6 -9
  77. package/elasticsearch/search/index.js.map +1 -0
  78. package/elasticsearch/search/refSearch.d.ts +2 -3
  79. package/elasticsearch/search/refSearch.js +24 -17
  80. package/elasticsearch/search/refSearch.js.map +1 -0
  81. package/elasticsearch/search/searchableJson.d.ts +2 -0
  82. package/elasticsearch/search/searchableJson.js +60 -0
  83. package/elasticsearch/search/searchableJson.js.map +1 -0
  84. package/elasticsearch/search/timeSearch.d.ts +2 -3
  85. package/elasticsearch/search/timeSearch.js +18 -16
  86. package/elasticsearch/search/timeSearch.js.map +1 -0
  87. package/helpers/entryIndexHelpers.d.ts +3 -3
  88. package/helpers/entryIndexHelpers.js +59 -58
  89. package/helpers/entryIndexHelpers.js.map +1 -0
  90. package/helpers/fieldIdentifier.d.ts +6 -0
  91. package/helpers/fieldIdentifier.js +43 -0
  92. package/helpers/fieldIdentifier.js.map +1 -0
  93. package/helpers/index.d.ts +1 -1
  94. package/helpers/index.js +11 -13
  95. package/helpers/index.js.map +1 -0
  96. package/index.d.ts +2 -1
  97. package/index.js +132 -78
  98. package/index.js.map +1 -0
  99. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  100. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  101. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  102. package/operations/entry/dataLoader/constants.d.ts +1 -0
  103. package/operations/entry/dataLoader/constants.js +10 -0
  104. package/operations/entry/dataLoader/constants.js.map +1 -0
  105. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  106. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  107. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  108. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  109. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  110. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  111. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -0
  113. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  114. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  115. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +52 -0
  116. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  117. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  118. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  119. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  120. package/operations/entry/dataLoader/index.d.ts +8 -0
  121. package/operations/entry/dataLoader/index.js +40 -0
  122. package/operations/entry/dataLoader/index.js.map +1 -0
  123. package/operations/entry/dataLoader/types.d.ts +6 -0
  124. package/operations/entry/dataLoader/types.js +7 -0
  125. package/operations/entry/dataLoader/types.js.map +1 -0
  126. package/operations/entry/dataLoaders.d.ts +21 -38
  127. package/operations/entry/dataLoaders.js +59 -290
  128. package/operations/entry/dataLoaders.js.map +1 -0
  129. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  130. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  131. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  132. package/operations/entry/elasticsearch/body.d.ts +13 -0
  133. package/operations/entry/elasticsearch/body.js +142 -0
  134. package/operations/entry/elasticsearch/body.js.map +1 -0
  135. package/operations/entry/elasticsearch/fields.d.ts +10 -0
  136. package/operations/entry/elasticsearch/fields.js +315 -0
  137. package/operations/entry/elasticsearch/fields.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  139. package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
  140. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  141. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  142. package/operations/entry/elasticsearch/filtering/exec.js +175 -0
  143. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  144. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  145. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  146. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  147. package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
  148. package/operations/entry/elasticsearch/filtering/path.js +48 -0
  149. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  150. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  151. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
  152. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  153. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  154. package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
  155. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  156. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  157. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
  158. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  159. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  160. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
  161. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  162. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  163. package/operations/entry/elasticsearch/filtering/populated.js +25 -0
  164. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  165. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  166. package/operations/entry/elasticsearch/filtering/values.js +24 -0
  167. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  168. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  169. package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
  170. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  171. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  172. package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
  173. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  174. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  175. package/operations/entry/elasticsearch/initialQuery.js +106 -0
  176. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  177. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  178. package/operations/entry/elasticsearch/keyword.js +36 -0
  179. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  180. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
  181. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
  182. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
  183. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  184. package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
  185. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  186. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  187. package/operations/entry/elasticsearch/plugins/operator.js +39 -0
  188. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  189. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  190. package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
  191. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  192. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  193. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -9
  194. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  195. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  196. package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
  197. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  198. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  199. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
  200. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  201. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  202. package/operations/entry/elasticsearch/sort.js +89 -0
  203. package/operations/entry/elasticsearch/sort.js.map +1 -0
  204. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  205. package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
  206. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  207. package/operations/entry/elasticsearch/types.d.ts +41 -0
  208. package/operations/entry/elasticsearch/types.js +7 -0
  209. package/operations/entry/elasticsearch/types.js.map +1 -0
  210. package/operations/entry/index.d.ts +6 -8
  211. package/operations/entry/index.js +1422 -693
  212. package/operations/entry/index.js.map +1 -0
  213. package/operations/entry/keys.js +2 -9
  214. package/operations/entry/keys.js.map +1 -0
  215. package/operations/entry/recordType.d.ts +3 -0
  216. package/operations/entry/recordType.js +20 -0
  217. package/operations/entry/recordType.js.map +1 -0
  218. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  219. package/operations/entry/transformations/convertEntryKeys.js +38 -0
  220. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  221. package/operations/entry/transformations/index.d.ts +29 -0
  222. package/operations/entry/transformations/index.js +127 -0
  223. package/operations/entry/transformations/index.js.map +1 -0
  224. package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
  225. package/operations/entry/transformations/modifyEntryValues.js +28 -0
  226. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  227. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  228. package/operations/entry/transformations/transformEntryKeys.js +27 -0
  229. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  230. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  231. package/operations/entry/transformations/transformEntryToIndex.js +31 -0
  232. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  233. package/operations/group/index.d.ts +5 -5
  234. package/operations/group/index.js +40 -63
  235. package/operations/group/index.js.map +1 -0
  236. package/operations/model/index.d.ts +5 -5
  237. package/operations/model/index.js +56 -78
  238. package/operations/model/index.js.map +1 -0
  239. package/operations/system/index.d.ts +4 -4
  240. package/operations/system/index.js +20 -31
  241. package/operations/system/index.js.map +1 -0
  242. package/operations/system/indexes.d.ts +10 -0
  243. package/operations/system/indexes.js +41 -0
  244. package/operations/system/indexes.js.map +1 -0
  245. package/package.json +38 -40
  246. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
  247. package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
  248. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
  249. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +9 -4
  250. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +10 -13
  251. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  252. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  253. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
  254. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  255. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  256. package/plugins/CmsEntryElasticsearchIndexPlugin.js +13 -0
  257. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  258. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +32 -0
  259. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +40 -0
  260. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  261. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +6 -4
  262. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +10 -13
  263. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  264. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +6 -4
  265. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +10 -13
  266. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  267. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
  268. package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
  269. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
  270. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  271. package/plugins/CmsEntryFilterPlugin.js +22 -0
  272. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  273. package/plugins/index.d.ts +8 -0
  274. package/plugins/index.js +95 -0
  275. package/plugins/index.js.map +1 -0
  276. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  277. package/tasks/createIndexTaskPlugin.js +67 -0
  278. package/tasks/createIndexTaskPlugin.js.map +1 -0
  279. package/types.d.ts +30 -52
  280. package/types.js +5 -23
  281. package/types.js.map +1 -0
  282. package/values/NoValueContainer.d.ts +5 -0
  283. package/values/NoValueContainer.js +20 -0
  284. package/values/NoValueContainer.js.map +1 -0
  285. package/definitions/settings.d.ts +0 -8
  286. package/definitions/settings.js +0 -62
  287. package/dynamoDb/storage/date.d.ts +0 -3
  288. package/dynamoDb/storage/date.js +0 -65
  289. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  290. package/helpers/createElasticsearchQueryBody.js +0 -375
  291. package/helpers/fields.d.ts +0 -77
  292. package/helpers/fields.js +0 -174
  293. package/helpers/operatorPluginsList.d.ts +0 -7
  294. package/helpers/operatorPluginsList.js +0 -30
  295. package/helpers/searchPluginsList.d.ts +0 -6
  296. package/helpers/transformValueForSearch.d.ts +0 -9
  297. package/helpers/transformValueForSearch.js +0 -26
  298. package/operations/entry/elasticsearchFields.d.ts +0 -2
  299. package/operations/entry/elasticsearchFields.js +0 -32
  300. package/operations/entry/fields.d.ts +0 -3
  301. package/operations/entry/fields.js +0 -60
  302. package/operations/settings/index.d.ts +0 -6
  303. package/operations/settings/index.js +0 -141
  304. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  305. package/operations/system/createElasticsearchTemplate.js +0 -62
  306. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  307. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  308. package/upgrades/index.d.ts +0 -2
  309. package/upgrades/index.js +0 -16
  310. package/upgrades/utils.d.ts +0 -1
  311. package/upgrades/utils.js +0 -16
  312. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  313. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  314. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  315. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  316. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  317. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  318. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  319. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  320. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  321. package/upgrades/v5.0.0/helpers.js +0 -57
  322. package/upgrades/v5.0.0/index.d.ts +0 -4
  323. package/upgrades/v5.0.0/index.js +0 -232
  324. package/upgrades/v5.8.0/index.d.ts +0 -4
  325. package/upgrades/v5.8.0/index.js +0 -426
@@ -1,28 +1,15 @@
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.createModelsStorageOperations = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _configurations = _interopRequireDefault(require("../../configurations"));
13
-
14
8
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
- var _get = require("@webiny/db-dynamodb/utils/get");
17
-
9
+ var _configurations = require("../../configurations");
18
10
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
19
-
20
11
  var _query = require("@webiny/db-dynamodb/utils/query");
21
-
22
- 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; }
23
-
24
- 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; }
25
-
12
+ var _dbDynamodb = require("@webiny/db-dynamodb");
26
13
  const createPartitionKey = params => {
27
14
  const {
28
15
  tenant,
@@ -30,66 +17,43 @@ const createPartitionKey = params => {
30
17
  } = params;
31
18
  return `T#${tenant}#L#${locale}#CMS#CM`;
32
19
  };
33
-
34
20
  const createSortKey = params => {
35
21
  return params.modelId;
36
22
  };
37
-
38
23
  const createKeys = params => {
39
24
  return {
40
25
  PK: createPartitionKey(params),
41
26
  SK: createSortKey(params)
42
27
  };
43
28
  };
44
-
45
29
  const createType = () => {
46
30
  return "cms.model";
47
31
  };
48
-
49
32
  const createModelsStorageOperations = params => {
50
33
  const {
51
34
  entity,
52
35
  elasticsearch
53
36
  } = params;
54
-
55
37
  const create = async params => {
56
38
  const {
57
39
  model
58
40
  } = params;
59
-
60
41
  const {
61
42
  index
62
- } = _configurations.default.es({
43
+ } = _configurations.configurations.es({
63
44
  model
64
45
  });
65
-
66
- try {
67
- const {
68
- body: exists
69
- } = await elasticsearch.indices.exists({
70
- index
71
- });
72
-
73
- if (!exists) {
74
- await elasticsearch.indices.create({
75
- index
76
- });
77
- }
78
- } catch (ex) {
79
- throw new _error.default("Could not create Elasticsearch indice.", "ELASTICSEARCH_INDICE_CREATE_ERROR", {
80
- error: ex,
81
- index,
82
- model
83
- });
84
- }
85
-
86
46
  const keys = createKeys(model);
87
47
  let error;
88
-
89
48
  try {
90
- await entity.put(_objectSpread(_objectSpread(_objectSpread({}, model), keys), {}, {
91
- TYPE: createType()
92
- }));
49
+ await (0, _dbDynamodb.put)({
50
+ entity,
51
+ item: {
52
+ ...(0, _cleanup.cleanupItem)(entity, model),
53
+ ...keys,
54
+ TYPE: createType()
55
+ }
56
+ });
93
57
  return model;
94
58
  } catch (ex) {
95
59
  error = ex;
@@ -97,79 +61,95 @@ const createModelsStorageOperations = params => {
97
61
  /**
98
62
  * In case of DynamoDB error we need to remove the index we created.
99
63
  */
100
-
101
-
102
64
  try {
103
65
  await elasticsearch.indices.delete({
104
- index
66
+ index,
67
+ ignore_unavailable: true
105
68
  });
106
69
  } catch (ex) {
107
- throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDICE_ERROR", {
70
+ throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
108
71
  dynamodbError: error,
109
72
  elasticsearchError: ex
110
73
  });
111
74
  }
112
-
113
75
  throw error;
114
76
  };
115
-
116
77
  const update = async params => {
117
78
  const {
118
- original,
119
79
  model
120
80
  } = params;
121
81
  const keys = createKeys(model);
122
-
123
82
  try {
124
- await entity.put(_objectSpread(_objectSpread(_objectSpread({}, model), keys), {}, {
125
- TYPE: createType()
126
- }));
83
+ await (0, _dbDynamodb.put)({
84
+ entity,
85
+ item: {
86
+ ...(0, _cleanup.cleanupItem)(entity, model),
87
+ ...keys,
88
+ TYPE: createType()
89
+ }
90
+ });
127
91
  return model;
128
92
  } catch (ex) {
129
- throw new _error.default(ex.messatge || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
93
+ throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
130
94
  error: ex,
131
95
  model,
132
- original,
133
96
  keys
134
97
  });
135
98
  }
136
99
  };
137
-
138
100
  const deleteModel = async params => {
139
101
  const {
140
102
  model
141
103
  } = params;
142
104
  const keys = createKeys(model);
143
-
105
+ const {
106
+ index
107
+ } = _configurations.configurations.es({
108
+ model
109
+ });
144
110
  try {
145
- await entity.delete(keys);
146
- return model;
111
+ await (0, _dbDynamodb.deleteItem)({
112
+ entity,
113
+ keys
114
+ });
147
115
  } catch (ex) {
148
- throw new _error.default(ex.messatge || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
116
+ throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
149
117
  error: ex,
150
118
  model,
151
119
  keys
152
120
  });
153
121
  }
122
+ /**
123
+ * Always delete the model index after deleting the model.
124
+ */
125
+ try {
126
+ await elasticsearch.indices.delete({
127
+ index,
128
+ ignore_unavailable: true
129
+ });
130
+ } catch (ex) {
131
+ throw new _error.default(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
132
+ error: ex,
133
+ index,
134
+ model
135
+ });
136
+ }
137
+ return model;
154
138
  };
155
-
156
139
  const get = async params => {
157
140
  const keys = createKeys(params);
158
-
159
141
  try {
160
- const item = await (0, _get.get)({
142
+ return await (0, _dbDynamodb.getClean)({
161
143
  entity,
162
144
  keys
163
145
  });
164
- return (0, _cleanup.cleanupItem)(entity, item);
165
146
  } catch (ex) {
166
- throw new _error.default(ex.messatge || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
147
+ throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
167
148
  error: ex,
168
149
  keys
169
150
  });
170
151
  }
171
152
  };
172
-
173
153
  const list = async params => {
174
154
  const {
175
155
  where
@@ -181,18 +161,15 @@ const createModelsStorageOperations = params => {
181
161
  gte: " "
182
162
  }
183
163
  };
184
-
185
164
  try {
186
- const items = await (0, _query.queryAll)(queryAllParams);
187
- return (0, _cleanup.cleanupItems)(entity, items);
165
+ return await (0, _query.queryAllClean)(queryAllParams);
188
166
  } catch (ex) {
189
- throw new _error.default(ex.messatge || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
167
+ throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
190
168
  error: ex,
191
169
  partitionKey: queryAllParams.partitionKey
192
170
  });
193
171
  }
194
172
  };
195
-
196
173
  return {
197
174
  create,
198
175
  update,
@@ -201,5 +178,6 @@ const createModelsStorageOperations = params => {
201
178
  list
202
179
  };
203
180
  };
181
+ exports.createModelsStorageOperations = createModelsStorageOperations;
204
182
 
205
- exports.createModelsStorageOperations = createModelsStorageOperations;
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_configurations","_cleanup","_query","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","item","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","deleteItem","get","getClean","list","where","queryAllParams","partitionKey","options","gte","queryAllClean","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { configurations } from \"~/configurations\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } from \"@webiny/db-dynamodb/utils/query\";\nimport { deleteItem, getClean, put } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsModel>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n return await queryAllClean<CmsModel>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,eAAA,GAAAD,OA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,oBAAa,EAAWJ,cAAc,CAAC;IACxD,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,wBAAwB,EACtCR,EAAE,CAACS,IAAI,IAAI,kBAAkB,EAC7B;QACId,KAAK,EAAEK,EAAE;QACTiB,YAAY,EAAED,cAAc,CAACC;MACjC,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH5B,MAAM;IACNkB,MAAM;IACNL,MAAM,EAAEQ,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAnC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- export interface Params {
1
+ import type { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
2
+ import type { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ export interface CreateSystemStorageOperationsParams {
4
4
  entity: Entity<any>;
5
5
  }
6
- export declare const createSystemStorageOperations: (params: Params) => CmsSystemStorageOperations;
6
+ export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
@@ -1,53 +1,43 @@
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.createSystemStorageOperations = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
8
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
9
  var _get = require("@webiny/db-dynamodb/utils/get");
15
-
16
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
17
-
18
- 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; }
19
-
20
- 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; }
21
-
10
+ var _dbDynamodb = require("@webiny/db-dynamodb");
22
11
  const createPartitionKey = ({
23
12
  tenant
24
13
  }) => {
25
14
  return `T#${tenant.toLowerCase()}#SYSTEM`;
26
15
  };
27
-
28
16
  const createSortKey = () => {
29
17
  return "CMS";
30
18
  };
31
-
32
19
  const createKeys = params => {
33
20
  return {
34
21
  PK: createPartitionKey(params),
35
22
  SK: createSortKey()
36
23
  };
37
24
  };
38
-
39
25
  const createSystemStorageOperations = params => {
40
26
  const {
41
27
  entity
42
28
  } = params;
43
-
44
29
  const create = async ({
45
30
  system
46
31
  }) => {
47
32
  const keys = createKeys(system);
48
-
49
33
  try {
50
- await entity.put(_objectSpread(_objectSpread({}, system), keys));
34
+ await (0, _dbDynamodb.put)({
35
+ entity,
36
+ item: {
37
+ ...system,
38
+ ...keys
39
+ }
40
+ });
51
41
  return system;
52
42
  } catch (ex) {
53
43
  throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
@@ -57,36 +47,35 @@ const createSystemStorageOperations = params => {
57
47
  });
58
48
  }
59
49
  };
60
-
61
50
  const update = async params => {
62
51
  const {
63
- system,
64
- original
52
+ system
65
53
  } = params;
66
54
  const keys = createKeys(system);
67
-
68
55
  try {
69
- await entity.put(_objectSpread(_objectSpread({}, system), keys));
56
+ await (0, _dbDynamodb.put)({
57
+ entity,
58
+ item: {
59
+ ...system,
60
+ ...keys
61
+ }
62
+ });
70
63
  return system;
71
64
  } catch (ex) {
72
65
  throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
73
66
  error: ex,
74
67
  system,
75
- original,
76
68
  keys
77
69
  });
78
70
  }
79
71
  };
80
-
81
72
  const get = async params => {
82
73
  const keys = createKeys(params);
83
-
84
74
  try {
85
- const system = await (0, _get.get)({
75
+ return await (0, _get.getClean)({
86
76
  entity,
87
77
  keys
88
78
  });
89
- return (0, _cleanup.cleanupItem)(entity, system);
90
79
  } catch (ex) {
91
80
  throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
92
81
  error: ex,
@@ -94,12 +83,12 @@ const createSystemStorageOperations = params => {
94
83
  });
95
84
  }
96
85
  };
97
-
98
86
  return {
99
87
  create,
100
88
  update,
101
89
  get
102
90
  };
103
91
  };
92
+ exports.createSystemStorageOperations = createSystemStorageOperations;
104
93
 
105
- exports.createSystemStorageOperations = createSystemStorageOperations;
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","item","ex","WebinyError","message","code","error","update","get","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsSystem>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,MAAMG,kBAAkB,GAAGA,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAO,KAAKA,MAAM,CAAC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CF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTJ,MAAM;QACNC;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOhB,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAiB,aAAQ,EAAY;QAC7Bb,MAAM;QACNG;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNU,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAAf,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { CmsContext } from "../../types";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { Client } from "@elastic/elasticsearch";
4
+ interface Params {
5
+ context: CmsContext;
6
+ client: Client;
7
+ plugins: PluginsContainer;
8
+ }
9
+ export declare const createElasticsearchIndexesOnLocaleAfterCreate: (params: Params) => Promise<void>;
10
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createElasticsearchIndexesOnLocaleAfterCreate = void 0;
7
+ var _createElasticsearchIndex = require("../../elasticsearch/createElasticsearchIndex");
8
+ const createElasticsearchIndexesOnLocaleAfterCreate = async params => {
9
+ const {
10
+ context,
11
+ client,
12
+ plugins
13
+ } = params;
14
+ context.i18n.locales.onLocaleAfterCreate.subscribe(async ({
15
+ locale,
16
+ tenant
17
+ }) => {
18
+ /**
19
+ * Get all the code models and create the indexes for them.
20
+ */
21
+ const models = await context.security.withoutAuthorization(async () => {
22
+ return (await context.cms.listModels()).map(model => {
23
+ return {
24
+ ...model,
25
+ tenant,
26
+ locale: locale.code
27
+ };
28
+ });
29
+ });
30
+ for (const model of models) {
31
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
32
+ client,
33
+ plugins,
34
+ model
35
+ });
36
+ }
37
+ });
38
+ };
39
+ exports.createElasticsearchIndexesOnLocaleAfterCreate = createElasticsearchIndexesOnLocaleAfterCreate;
40
+
41
+ //# sourceMappingURL=indexes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_createElasticsearchIndex","require","createElasticsearchIndexesOnLocaleAfterCreate","params","context","client","plugins","i18n","locales","onLocaleAfterCreate","subscribe","locale","tenant","models","security","withoutAuthorization","cms","listModels","map","model","code","createElasticsearchIndex","exports"],"sources":["indexes.ts"],"sourcesContent":["import type { CmsContext } from \"~/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\n\ninterface Params {\n context: CmsContext;\n client: Client;\n plugins: PluginsContainer;\n}\n\nexport const createElasticsearchIndexesOnLocaleAfterCreate = async (params: Params) => {\n const { context, client, plugins } = params;\n\n context.i18n.locales.onLocaleAfterCreate.subscribe(async ({ locale, tenant }) => {\n /**\n * Get all the code models and create the indexes for them.\n */\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).map(model => {\n return {\n ...model,\n tenant,\n locale: locale.code\n };\n });\n });\n\n for (const model of models) {\n await createElasticsearchIndex({\n client,\n plugins,\n model\n });\n }\n });\n};\n"],"mappings":";;;;;;AAGA,IAAAA,yBAAA,GAAAC,OAAA;AAQO,MAAMC,6CAA6C,GAAG,MAAOC,MAAc,IAAK;EACnF,MAAM;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE3CC,OAAO,CAACG,IAAI,CAACC,OAAO,CAACC,mBAAmB,CAACC,SAAS,CAAC,OAAO;IAAEC,MAAM;IAAEC;EAAO,CAAC,KAAK;IAC7E;AACR;AACA;IACQ,MAAMC,MAAM,GAAG,MAAMT,OAAO,CAACU,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAO,CAAC,MAAMX,OAAO,CAACY,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,GAAG,CAACC,KAAK,IAAI;QACjD,OAAO;UACH,GAAGA,KAAK;UACRP,MAAM;UACND,MAAM,EAAEA,MAAM,CAACS;QACnB,CAAC;MACL,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,KAAK,MAAMD,KAAK,IAAIN,MAAM,EAAE;MACxB,MAAM,IAAAQ,kDAAwB,EAAC;QAC3BhB,MAAM;QACNC,OAAO;QACPa;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAApB,6CAAA,GAAAA,6CAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "0.0.0-mt-3",
3
+ "version": "0.0.0-unstable.06b2ede40f",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
7
7
  "storage-operations",
8
8
  "dynamodb",
9
9
  "elasticsearch",
10
- "cms:ddb-es"
10
+ "ddb-es",
11
+ "cms:ddb-es",
12
+ "opensearch",
13
+ "ddb-os",
14
+ "cms:ddb-os"
11
15
  ],
12
16
  "repository": {
13
17
  "type": "git",
@@ -22,52 +26,46 @@
22
26
  ],
23
27
  "license": "MIT",
24
28
  "dependencies": {
25
- "@babel/runtime": "7.15.4",
26
- "@webiny/api-headless-cms": "0.0.0-mt-3",
27
- "@webiny/api-upgrade": "0.0.0-mt-3",
28
- "@webiny/db-dynamodb": "0.0.0-mt-3",
29
- "@webiny/error": "0.0.0-mt-3",
30
- "@webiny/handler": "0.0.0-mt-3",
31
- "@webiny/handler-aws": "0.0.0-mt-3",
32
- "@webiny/handler-db": "0.0.0-mt-3",
33
- "@webiny/plugins": "0.0.0-mt-3",
34
- "@webiny/utils": "0.0.0-mt-3",
35
- "dataloader": "2.0.0",
36
- "dynamodb-toolbox": "0.3.4",
37
- "jsonpack": "1.1.5",
38
- "lodash.chunk": "4.2.0",
39
- "lodash.clonedeep": "4.5.0",
40
- "lodash.omit": "4.5.0"
29
+ "@webiny/api": "0.0.0-unstable.06b2ede40f",
30
+ "@webiny/api-elasticsearch": "0.0.0-unstable.06b2ede40f",
31
+ "@webiny/api-elasticsearch-tasks": "0.0.0-unstable.06b2ede40f",
32
+ "@webiny/api-headless-cms": "0.0.0-unstable.06b2ede40f",
33
+ "@webiny/aws-sdk": "0.0.0-unstable.06b2ede40f",
34
+ "@webiny/db-dynamodb": "0.0.0-unstable.06b2ede40f",
35
+ "@webiny/error": "0.0.0-unstable.06b2ede40f",
36
+ "@webiny/handler-db": "0.0.0-unstable.06b2ede40f",
37
+ "@webiny/plugins": "0.0.0-unstable.06b2ede40f",
38
+ "@webiny/utils": "0.0.0-unstable.06b2ede40f",
39
+ "dataloader": "2.2.3",
40
+ "lodash": "4.17.21"
41
41
  },
42
42
  "devDependencies": {
43
- "@babel/cli": "^7.5.5",
44
- "@babel/core": "^7.5.5",
45
- "@babel/preset-env": "^7.5.5",
46
- "@babel/preset-flow": "^7.0.0",
47
43
  "@elastic/elasticsearch": "7.12.0",
48
- "@shelf/jest-elasticsearch": "^1.0.0",
49
- "@types/jsonpack": "^1.1.0",
50
- "@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-mt-3",
51
- "@webiny/api-elasticsearch": "^0.0.0-mt-3",
52
- "@webiny/cli": "^0.0.0-mt-3",
53
- "@webiny/project-utils": "^0.0.0-mt-3",
54
- "jest": "^26.6.3",
55
- "jest-dynalite": "^3.2.0",
56
- "jest-environment-node": "^26.6.2",
57
- "mdbid": "^1.0.0",
58
- "prettier": "^2.3.2",
59
- "rimraf": "^3.0.2",
60
- "sinon": "^9.0.2",
61
- "ttypescript": "^1.5.12",
62
- "typescript": "^4.1.3"
44
+ "@types/jsonpack": "1.1.6",
45
+ "@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.06b2ede40f",
46
+ "@webiny/api-i18n": "0.0.0-unstable.06b2ede40f",
47
+ "@webiny/api-log": "0.0.0-unstable.06b2ede40f",
48
+ "@webiny/api-security": "0.0.0-unstable.06b2ede40f",
49
+ "@webiny/api-tenancy": "0.0.0-unstable.06b2ede40f",
50
+ "@webiny/api-wcp": "0.0.0-unstable.06b2ede40f",
51
+ "@webiny/handler": "0.0.0-unstable.06b2ede40f",
52
+ "@webiny/handler-aws": "0.0.0-unstable.06b2ede40f",
53
+ "@webiny/handler-graphql": "0.0.0-unstable.06b2ede40f",
54
+ "@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
55
+ "@webiny/tasks": "0.0.0-unstable.06b2ede40f",
56
+ "jest": "29.7.0",
57
+ "jest-dynalite": "3.6.1",
58
+ "prettier": "2.8.8",
59
+ "rimraf": "6.0.1",
60
+ "typescript": "5.3.3"
63
61
  },
64
62
  "publishConfig": {
65
63
  "access": "public",
66
64
  "directory": "dist"
67
65
  },
68
66
  "scripts": {
69
- "build": "yarn webiny run build",
70
- "watch": "yarn webiny run watch"
67
+ "build": "node ../cli/bin.js run build",
68
+ "watch": "node ../cli/bin.js run watch"
71
69
  },
72
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
70
+ "gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
73
71
  }
@@ -0,0 +1,69 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import type { CmsModelFieldType } from "@webiny/api-headless-cms/types";
3
+ /**
4
+ * A plugin which allows you to map a custom GraphQL field to an Elasticsearch field.
5
+ *
6
+ * This is useful when you want to create a custom field in the CMS GraphQL Schema, and you want to map it to an Elasticsearch field.
7
+ */
8
+ export interface CmsModelFieldPluginParams {
9
+ /**
10
+ * The type of the field.
11
+ * Can be something custom, like "my-field-type".
12
+ */
13
+ fieldType: CmsModelFieldType;
14
+ /**
15
+ * The ID of the field on the GraphQL side
16
+ */
17
+ fieldId: string;
18
+ /**
19
+ * The path to the field in the Elasticsearch document.
20
+ */
21
+ path: string;
22
+ /**
23
+ * If the field should be applied only to specific models.
24
+ * Or excluded from the specific models.
25
+ *
26
+ * The default is to apply to all models.
27
+ */
28
+ models?: {
29
+ include?: string[];
30
+ exclude?: string[];
31
+ };
32
+ /**
33
+ * The unmapped type of the field.
34
+ * In most cases, this will be undefined.
35
+ * When does it need to be set?
36
+ *
37
+ * When you are using a custom field type, other than the ones that are defined in the CMS.
38
+ * Let's say you create a field of type `my-field-type`, in which you want to store dates. By the default, it will, in most cases be set as string - if you did not specify the value transformer.
39
+ * If you want to be able to sort/filter properly by this field, you need to specify the unmapped type as "date".
40
+ */
41
+ unmappedType?: string;
42
+ /**
43
+ * Is this field searchable?
44
+ * If set to false, an error will be thrown when trying to search/filter by this field.
45
+ */
46
+ searchable?: boolean;
47
+ /**
48
+ * Is this field sortable?
49
+ * If set to false, an error will be thrown when trying to sort by this field.
50
+ */
51
+ sortable?: boolean;
52
+ /**
53
+ * If the .keyword should be applied when doing the filtering or sorting on the field.
54
+ */
55
+ keyword?: boolean;
56
+ }
57
+ export declare class CmsElasticsearchModelFieldPlugin extends Plugin {
58
+ static readonly type: string;
59
+ private readonly field;
60
+ get fieldType(): string;
61
+ get fieldId(): string;
62
+ get path(): string;
63
+ get unmappedType(): string | undefined;
64
+ get searchable(): boolean | undefined;
65
+ get sortable(): boolean | undefined;
66
+ get keyword(): boolean | undefined;
67
+ constructor(field: CmsModelFieldPluginParams);
68
+ canBeApplied(modelId: string): boolean;
69
+ }