@webiny/api-headless-cms-ddb-es 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9

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 (411) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +13 -6
  3. package/configurations.js +28 -40
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -5
  6. package/definitions/entry.js +9 -88
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -6
  9. package/definitions/group.js +9 -68
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -6
  12. package/definitions/model.js +9 -90
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/elasticsearch/createElasticsearchIndex.d.ts +5 -5
  17. package/elasticsearch/createElasticsearchIndex.js +53 -56
  18. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  19. package/elasticsearch/deleteElasticsearchIndex.d.ts +3 -3
  20. package/elasticsearch/deleteElasticsearchIndex.js +20 -40
  21. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  22. package/exports/api/cms/opensearch.d.ts +9 -0
  23. package/exports/api/cms/opensearch.js +9 -0
  24. package/feature.d.ts +1 -0
  25. package/feature.js +179 -0
  26. package/feature.js.map +1 -0
  27. package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
  28. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +5 -0
  29. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
  30. package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
  31. package/features/CmsEntryOpenSearchBodyModifier/index.js +1 -0
  32. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +14 -0
  33. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +42 -0
  34. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  35. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +32 -0
  36. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +5 -0
  37. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -0
  38. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +11 -0
  39. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +5 -0
  40. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  41. package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
  42. package/features/CmsEntryOpenSearchFieldIndex/constants.js +4 -0
  43. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
  44. package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +4 -0
  45. package/features/CmsEntryOpenSearchFieldIndex/feature.js +29 -0
  46. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
  47. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
  48. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +60 -0
  49. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +13 -0
  51. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +33 -0
  52. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -0
  53. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +10 -0
  54. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +21 -0
  55. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -0
  56. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +10 -0
  57. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +22 -0
  58. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
  59. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
  60. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +32 -0
  61. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
  62. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +12 -0
  63. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +107 -0
  64. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
  65. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
  66. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +21 -0
  67. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
  68. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +15 -0
  69. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +40 -0
  70. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
  71. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.d.ts +15 -0
  72. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +40 -0
  73. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -0
  74. package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
  75. package/features/CmsEntryOpenSearchFieldIndex/index.js +3 -0
  76. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
  77. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +36 -0
  78. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  79. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
  80. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +5 -0
  81. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -0
  82. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +9 -0
  83. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +5 -0
  84. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  85. package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
  86. package/features/CmsEntryOpenSearchFilter/constants.js +4 -0
  87. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
  88. package/features/CmsEntryOpenSearchFilter/feature.d.ts +4 -0
  89. package/features/CmsEntryOpenSearchFilter/feature.js +17 -0
  90. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
  91. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
  92. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +26 -0
  93. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -0
  94. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +9 -0
  95. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +43 -0
  96. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -0
  97. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +9 -0
  98. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +36 -0
  99. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
  100. package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
  101. package/features/CmsEntryOpenSearchFilter/index.js +3 -0
  102. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
  103. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +5 -0
  104. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
  105. package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
  106. package/features/CmsEntryOpenSearchFullTextSearch/index.js +1 -0
  107. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.d.ts +11 -0
  108. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +17 -0
  109. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -0
  110. package/features/CmsEntryOpenSearchIndex/abstractions.d.ts +14 -0
  111. package/features/CmsEntryOpenSearchIndex/abstractions.js +5 -0
  112. package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -0
  113. package/features/CmsEntryOpenSearchIndex/feature.d.ts +4 -0
  114. package/features/CmsEntryOpenSearchIndex/feature.js +11 -0
  115. package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -0
  116. package/features/CmsEntryOpenSearchIndex/index.d.ts +3 -0
  117. package/features/CmsEntryOpenSearchIndex/index.js +3 -0
  118. package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
  119. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +5 -0
  120. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
  121. package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
  122. package/features/CmsEntryOpenSearchQueryModifier/index.js +1 -0
  123. package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
  124. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +5 -0
  125. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
  126. package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
  127. package/features/CmsEntryOpenSearchSortModifier/index.js +1 -0
  128. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
  129. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +31 -0
  130. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  131. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
  132. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +5 -0
  133. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -0
  134. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +10 -0
  135. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +5 -0
  136. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  137. package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +4 -0
  138. package/features/CmsEntryOpenSearchValueSearch/feature.js +17 -0
  139. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
  140. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
  141. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +21 -0
  142. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -0
  143. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +10 -0
  144. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +44 -0
  145. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -0
  146. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +10 -0
  147. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +22 -0
  148. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
  149. package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
  150. package/features/CmsEntryOpenSearchValueSearch/index.js +3 -0
  151. package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
  152. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +5 -0
  153. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
  154. package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
  155. package/features/CmsEntryOpenSearchValuesModifier/index.js +1 -0
  156. package/helpers/entryIndexHelpers.d.ts +13 -11
  157. package/helpers/entryIndexHelpers.js +72 -196
  158. package/helpers/entryIndexHelpers.js.map +1 -1
  159. package/helpers/fieldIdentifier.d.ts +6 -0
  160. package/helpers/fieldIdentifier.js +23 -0
  161. package/helpers/fieldIdentifier.js.map +1 -0
  162. package/helpers/index.d.ts +2 -2
  163. package/helpers/index.js +2 -31
  164. package/index.d.ts +1 -3
  165. package/index.js +1 -268
  166. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  167. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  168. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  169. package/operations/entry/dataLoader/constants.d.ts +1 -0
  170. package/operations/entry/dataLoader/constants.js +5 -0
  171. package/operations/entry/dataLoader/constants.js.map +1 -0
  172. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  173. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  174. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  175. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  176. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  177. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  178. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  179. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  180. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  181. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  182. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  183. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  184. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  185. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  186. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  187. package/operations/entry/dataLoader/index.d.ts +8 -0
  188. package/operations/entry/dataLoader/index.js +18 -0
  189. package/operations/entry/dataLoader/index.js.map +1 -0
  190. package/operations/entry/dataLoader/types.d.ts +6 -0
  191. package/operations/entry/dataLoader/types.js +0 -0
  192. package/operations/entry/dataLoaders.d.ts +17 -38
  193. package/operations/entry/dataLoaders.js +82 -357
  194. package/operations/entry/dataLoaders.js.map +1 -1
  195. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  196. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +9 -0
  197. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  198. package/operations/entry/elasticsearch/body.d.ts +29 -0
  199. package/operations/entry/elasticsearch/body.js +87 -0
  200. package/operations/entry/elasticsearch/body.js.map +1 -0
  201. package/operations/entry/elasticsearch/fields/createSystemField.d.ts +4 -0
  202. package/operations/entry/elasticsearch/fields/createSystemField.js +9 -0
  203. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -0
  204. package/operations/entry/elasticsearch/fields/live.d.ts +2 -0
  205. package/operations/entry/elasticsearch/fields/live.js +50 -0
  206. package/operations/entry/elasticsearch/fields/live.js.map +1 -0
  207. package/operations/entry/elasticsearch/fields/location.d.ts +2 -0
  208. package/operations/entry/elasticsearch/fields/location.js +50 -0
  209. package/operations/entry/elasticsearch/fields/location.js.map +1 -0
  210. package/operations/entry/elasticsearch/fields/state.d.ts +2 -0
  211. package/operations/entry/elasticsearch/fields/state.js +104 -0
  212. package/operations/entry/elasticsearch/fields/state.js.map +1 -0
  213. package/operations/entry/elasticsearch/fields.d.ts +12 -0
  214. package/operations/entry/elasticsearch/fields.js +207 -0
  215. package/operations/entry/elasticsearch/fields.js.map +1 -0
  216. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +9 -0
  217. package/operations/entry/elasticsearch/filtering/applyFiltering.js +39 -0
  218. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  219. package/operations/entry/elasticsearch/filtering/exec.d.ts +22 -0
  220. package/operations/entry/elasticsearch/filtering/exec.js +96 -0
  221. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  222. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  223. package/operations/entry/elasticsearch/filtering/index.js +1 -0
  224. package/operations/entry/elasticsearch/filtering/path.d.ts +17 -0
  225. package/operations/entry/elasticsearch/filtering/path.js +27 -0
  226. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  227. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  228. package/operations/entry/elasticsearch/filtering/populated.js +12 -0
  229. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  230. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  231. package/operations/entry/elasticsearch/filtering/values.js +15 -0
  232. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  233. package/operations/entry/elasticsearch/fullTextSearch.d.ts +13 -0
  234. package/operations/entry/elasticsearch/fullTextSearch.js +51 -0
  235. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  236. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  237. package/operations/entry/elasticsearch/fullTextSearchFields.js +10 -0
  238. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  239. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  240. package/operations/entry/elasticsearch/initialQuery.js +45 -0
  241. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  242. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  243. package/operations/entry/elasticsearch/keyword.js +17 -0
  244. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  245. package/operations/entry/elasticsearch/plugins/operator.d.ts +7 -0
  246. package/operations/entry/elasticsearch/plugins/operator.js +13 -0
  247. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  248. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  249. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +8 -0
  250. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  251. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  252. package/operations/entry/elasticsearch/sort.js +80 -0
  253. package/operations/entry/elasticsearch/sort.js.map +1 -0
  254. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +9 -0
  255. package/operations/entry/elasticsearch/transformValueForSearch.js +12 -0
  256. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  257. package/operations/entry/elasticsearch/types.d.ts +34 -0
  258. package/operations/entry/elasticsearch/types.js +0 -0
  259. package/operations/entry/index.d.ts +27 -8
  260. package/operations/entry/index.js +1344 -1245
  261. package/operations/entry/index.js.map +1 -1
  262. package/operations/entry/keys.d.ts +31 -1
  263. package/operations/entry/keys.js +45 -35
  264. package/operations/entry/keys.js.map +1 -1
  265. package/operations/entry/recordType.d.ts +3 -0
  266. package/operations/entry/recordType.js +6 -0
  267. package/operations/entry/recordType.js.map +1 -0
  268. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  269. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  270. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  271. package/operations/entry/transformations/index.d.ts +33 -0
  272. package/operations/entry/transformations/index.js +91 -0
  273. package/operations/entry/transformations/index.js.map +1 -0
  274. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  275. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  276. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  277. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  278. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  279. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  280. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  281. package/operations/entry/transformations/transformEntryToIndex.js +20 -0
  282. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  283. package/operations/group/index.d.ts +7 -6
  284. package/operations/group/index.js +116 -190
  285. package/operations/group/index.js.map +1 -1
  286. package/operations/model/index.d.ts +4 -4
  287. package/operations/model/index.js +130 -199
  288. package/operations/model/index.js.map +1 -1
  289. package/package.json +44 -41
  290. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  291. package/tasks/createIndexTaskPlugin.js +45 -0
  292. package/tasks/createIndexTaskPlugin.js.map +1 -0
  293. package/types.d.ts +34 -137
  294. package/types.js +10 -47
  295. package/types.js.map +1 -1
  296. package/values/NoValueContainer.d.ts +5 -0
  297. package/values/NoValueContainer.js +11 -0
  298. package/values/NoValueContainer.js.map +1 -0
  299. package/definitions/entryElasticsearch.d.ts +0 -8
  300. package/definitions/entryElasticsearch.js +0 -42
  301. package/definitions/entryElasticsearch.js.map +0 -1
  302. package/definitions/settings.d.ts +0 -8
  303. package/definitions/settings.js +0 -58
  304. package/definitions/settings.js.map +0 -1
  305. package/definitions/system.d.ts +0 -8
  306. package/definitions/system.js +0 -46
  307. package/definitions/system.js.map +0 -1
  308. package/definitions/table.d.ts +0 -8
  309. package/definitions/table.js +0 -24
  310. package/definitions/table.js.map +0 -1
  311. package/definitions/tableElasticsearch.d.ts +0 -8
  312. package/definitions/tableElasticsearch.js +0 -24
  313. package/definitions/tableElasticsearch.js.map +0 -1
  314. package/dynamoDb/index.d.ts +0 -2
  315. package/dynamoDb/index.js +0 -16
  316. package/dynamoDb/index.js.map +0 -1
  317. package/dynamoDb/storage/date.d.ts +0 -2
  318. package/dynamoDb/storage/date.js +0 -99
  319. package/dynamoDb/storage/date.js.map +0 -1
  320. package/dynamoDb/storage/longText.d.ts +0 -10
  321. package/dynamoDb/storage/longText.js +0 -101
  322. package/dynamoDb/storage/longText.js.map +0 -1
  323. package/dynamoDb/storage/richText.d.ts +0 -7
  324. package/dynamoDb/storage/richText.js +0 -128
  325. package/dynamoDb/storage/richText.js.map +0 -1
  326. package/elasticsearch/index.d.ts +0 -2
  327. package/elasticsearch/index.js +0 -16
  328. package/elasticsearch/index.js.map +0 -1
  329. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  330. package/elasticsearch/indexing/dateTimeIndexing.js +0 -103
  331. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  332. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  333. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -47
  334. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  335. package/elasticsearch/indexing/index.d.ts +0 -2
  336. package/elasticsearch/indexing/index.js +0 -24
  337. package/elasticsearch/indexing/index.js.map +0 -1
  338. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -3
  339. package/elasticsearch/indexing/longTextIndexing.js +0 -36
  340. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  341. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  342. package/elasticsearch/indexing/numberIndexing.js +0 -48
  343. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  344. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  345. package/elasticsearch/indexing/objectIndexing.js +0 -223
  346. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  347. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  348. package/elasticsearch/indexing/richTextIndexing.js +0 -34
  349. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  350. package/elasticsearch/indices/base.d.ts +0 -2
  351. package/elasticsearch/indices/base.js +0 -15
  352. package/elasticsearch/indices/base.js.map +0 -1
  353. package/elasticsearch/indices/index.d.ts +0 -1
  354. package/elasticsearch/indices/index.js +0 -16
  355. package/elasticsearch/indices/index.js.map +0 -1
  356. package/elasticsearch/indices/japanese.d.ts +0 -2
  357. package/elasticsearch/indices/japanese.js +0 -16
  358. package/elasticsearch/indices/japanese.js.map +0 -1
  359. package/elasticsearch/search/index.d.ts +0 -3
  360. package/elasticsearch/search/index.js +0 -14
  361. package/elasticsearch/search/index.js.map +0 -1
  362. package/elasticsearch/search/refSearch.d.ts +0 -2
  363. package/elasticsearch/search/refSearch.js +0 -33
  364. package/elasticsearch/search/refSearch.js.map +0 -1
  365. package/elasticsearch/search/timeSearch.d.ts +0 -2
  366. package/elasticsearch/search/timeSearch.js +0 -33
  367. package/elasticsearch/search/timeSearch.js.map +0 -1
  368. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  369. package/helpers/createElasticsearchQueryBody.js +0 -611
  370. package/helpers/createElasticsearchQueryBody.js.map +0 -1
  371. package/helpers/fields.d.ts +0 -19
  372. package/helpers/fields.js +0 -205
  373. package/helpers/fields.js.map +0 -1
  374. package/helpers/index.js.map +0 -1
  375. package/helpers/searchPluginsList.d.ts +0 -6
  376. package/helpers/searchPluginsList.js +0 -26
  377. package/helpers/searchPluginsList.js.map +0 -1
  378. package/helpers/transformValueForSearch.d.ts +0 -12
  379. package/helpers/transformValueForSearch.js +0 -29
  380. package/helpers/transformValueForSearch.js.map +0 -1
  381. package/index.js.map +0 -1
  382. package/operations/entry/elasticsearchFields.d.ts +0 -2
  383. package/operations/entry/elasticsearchFields.js +0 -38
  384. package/operations/entry/elasticsearchFields.js.map +0 -1
  385. package/operations/settings/index.d.ts +0 -6
  386. package/operations/settings/index.js +0 -135
  387. package/operations/settings/index.js.map +0 -1
  388. package/operations/system/index.d.ts +0 -6
  389. package/operations/system/index.js +0 -99
  390. package/operations/system/index.js.map +0 -1
  391. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -20
  392. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -24
  393. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  394. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  395. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  396. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
  397. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  398. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -17
  399. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  400. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -30
  401. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -43
  402. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  403. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -17
  404. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -24
  405. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  406. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -17
  407. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -24
  408. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  409. package/plugins/index.d.ts +0 -6
  410. package/plugins/index.js +0 -83
  411. package/plugins/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","TYPE","ex","message","code","error","update","deleteGroup","delete","get","getRecord","cleanupItem","list","sort","where","initialWhere","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","filterItems","items","fields","sortItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\nexport interface CreateGroupsStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n ...group,\n TYPE: createType(),\n ...keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n ...group,\n TYPE: createType(),\n ...keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n // TODO make sure that group has locale and tenant on it - add it in the crud just in case\n const keys = createKeys(group);\n\n try {\n await entity.delete(keys);\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const group = await getRecord<CmsGroup>({\n entity,\n keys\n });\n\n return cleanupItem(entity, group);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where: initialWhere } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let records: CmsGroup[] = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where: initialWhere\n }\n );\n }\n\n const where: Partial<CmsGroupStorageOperationsListParams[\"where\"]> = {\n ...initialWhere\n };\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n const filteredItems = filterItems({\n items: records,\n where,\n fields: [],\n plugins\n });\n\n if (!sort || sort.length === 0 || filteredItems.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: []\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;;;;AAUA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAMA,MAAMA,kBAAkB,GAAIC,MAAD,IAAwC;EAC/D,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAqBF,MAA3B;EACA,OAAQ,KAAIC,MAAO,MAAKC,MAAO,UAA/B;AACH,CAHD;;AAQA,MAAMC,cAAc,GAAIH,MAAD,IAAmC;EACtD,MAAM;IAAEI;EAAF,IAASJ,MAAf;EACA,OAAOI,EAAP;AACH,CAHD;;AASA,MAAMC,UAAU,GAAIL,MAAD,IAAsD;EACrE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAD,CADnB;IAEHO,EAAE,EAAEJ,cAAc,CAACH,MAAD;EAFf,CAAP;AAIH,CALD;;AAOA,MAAMQ,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAP;AACH,CAFD;;AAQO,MAAMC,6BAA6B,GACtCT,MADyC,IAEb;EAC5B,MAAM;IAAEU,MAAF;IAAUC;EAAV,IAAsBX,MAA5B;EAEA,MAAMY,gBAAgB,GAAGD,OAAO,CAACE,MAAR,CAAkCC,oCAAA,CAAkBC,IAApD,CAAzB;;EACA,IAAIH,gBAAgB,CAACI,MAAjB,KAA4B,CAAhC,EAAmC;IAC/B,MAAM,IAAIC,cAAJ,CACF,wCADE,EAEF,oCAFE,CAAN;EAIH;;EAED,MAAMC,MAAM,GAAG,MAAOlB,MAAP,IAAyD;IACpE,MAAM;MAAEmB;IAAF,IAAYnB,MAAlB;IACA,MAAM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mCAC3DC,YAD2D,CAAlE;IAGA,OAAOD,KAAK,CAAC,QAAD,CAAZ;IACA,OAAOA,KAAK,CAAC,QAAD,CAAZ;IAEA,MAAMQ,aAAa,GAAG,IAAAC,mBAAA,EAAY;MAC9BC,KAAK,EAAEJ,OADuB;MAE9BN,KAF8B;MAG9BW,MAAM,EAAE,EAHsB;MAI9BnC;IAJ8B,CAAZ,CAAtB;;IAOA,IAAI,CAACuB,IAAD,IAASA,IAAI,CAAClB,MAAL,KAAgB,CAAzB,IAA8B2B,aAAa,CAAC3B,MAAd,KAAyB,CAA3D,EAA8D;MAC1D,OAAO2B,aAAP;IACH;;IACD,OAAO,IAAAI,eAAA,EAAU;MACbF,KAAK,EAAEF,aADM;MAEbT,IAFa;MAGbY,MAAM,EAAE;IAHK,CAAV,CAAP;EAKH,CAhDD;;EAkDA,OAAO;IACH5B,MADG;IAEHS,MAFG;IAGHE,MAAM,EAAED,WAHL;IAIHE,GAJG;IAKHG;EALG,CAAP;AAOH,CA5JM"}
1
+ {"version":3,"file":"operations/group/index.js","sources":["../../../src/operations/group/index.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { sortItems } from \"@webiny/db-dynamodb\";\nimport { IGroupEntity } from \"~/definitions/types.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/exports/api/db.js\";\nimport type { CmsContext } from \"~/types.js\";\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): IDynamoDbTableKeys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\ninterface CreateGroupsStorageOperationsParams {\n entity: IGroupEntity;\n container: CmsContext[\"container\"];\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, container } = params;\n\n const filterUtil = container.resolve(FilterUtil);\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where } = params;\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await entity.queryAll({\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n });\n records = ddbRecords.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where\n }\n );\n }\n\n const filteredItems = filterUtil.filter({\n items: records,\n where,\n fields: []\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n\n return sortItems({\n items: filteredItems,\n sort\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"names":["createPartitionKey","params","tenant","createSortKeys","id","createKeys","createType","createGroupsStorageOperations","entity","container","filterUtil","FilterUtil","create","group","keys","ex","WebinyError","update","deleteGroup","get","result","list","sort","where","records","ddbRecords","item","filteredItems","sortItems"],"mappings":";;;AAkBA,MAAMA,qBAAqB,CAACC;IACxB,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAO,CAAC,EAAE,EAAEC,OAAO,QAAQ,CAAC;AAChC;AAKA,MAAMC,iBAAiB,CAACF;IACpB,MAAM,EAAEG,EAAE,EAAE,GAAGH;IACf,OAAOG;AACX;AAOA,MAAMC,aAAa,CAACJ,SACT;QACH,IAAID,mBAAmBC;QACvB,IAAIE,eAAeF;QACnB,YAAYA,OAAO,MAAM;IAC7B;AAGJ,MAAMK,aAAa,IACR;AAOJ,MAAMC,gCAAgC,CACzCN;IAEA,MAAM,EAAEO,MAAM,EAAEC,SAAS,EAAE,GAAGR;IAE9B,MAAMS,aAAaD,UAAU,OAAO,CAACE;IAErC,MAAMC,SAAS,OAAOX;QAClB,MAAM,EAAEY,KAAK,EAAE,GAAGZ;QAClB,MAAMa,OAAOT,WAAWQ;QACxB,IAAI;YACA,MAAML,OAAO,GAAG,CAAC;gBACb,MAAMK;gBACN,MAAM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AO,QAAQ,CAAC;gBACrC,cAAcR,mBAAmBuB;gBACjC,SAAS;oBACL,KAAK;gBACT;YACJ;YACAC,UAAUC,WAAW,GAAG,CAACC,CAAAA,OAAQA,KAAK,IAAI;QAC9C,EAAE,OAAOX,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBACI,OAAOA;gBACP,GAAGd,MAAM;gBACTqB;gBACAC;YACJ;QAER;QAEA,MAAMI,gBAAgBjB,WAAW,MAAM,CAAC;YACpC,OAAOc;YACPD;YACA,QAAQ,EAAE;QACd;QACA,IAAI,CAACD,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EACpB,OAAOK;QAGX,OAAOC,UAAU;YACb,OAAOD;YACPL;QACJ;IACJ;IAEA,OAAO;QACHV;QACAK;QACA,QAAQC;QACRC;QACAE;IACJ;AACJ"}
@@ -1,8 +1,8 @@
1
- import { CmsModelStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- import { Client } from "@elastic/elasticsearch";
1
+ import type { CmsModelStorageOperations } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { Client } from "@webiny/api-opensearch";
3
+ import type { IModelEntity } from "../../definitions/types.js";
4
4
  export interface CreateModelsStorageOperationsParams {
5
- entity: Entity<any>;
5
+ entity: IModelEntity;
6
6
  elasticsearch: Client;
7
7
  }
8
8
  export declare const createModelsStorageOperations: (params: CreateModelsStorageOperationsParams) => CmsModelStorageOperations;
@@ -1,204 +1,135 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createModelsStorageOperations = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _configurations = require("../../configurations");
13
-
14
- var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
- var _get = require("@webiny/db-dynamodb/utils/get");
17
-
18
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
19
-
20
- var _query = require("@webiny/db-dynamodb/utils/query");
21
-
22
- const createPartitionKey = params => {
23
- const {
24
- tenant,
25
- locale
26
- } = params;
27
- return `T#${tenant}#L#${locale}#CMS#CM`;
28
- };
29
-
30
- const createSortKey = params => {
31
- return params.modelId;
1
+ import _webiny_error from "@webiny/error";
2
+ import { configurations } from "../../configurations.js";
3
+ const createPartitionKey = (params)=>{
4
+ const { tenant } = params;
5
+ return `T#${tenant}#CMS#CM`;
32
6
  };
33
-
34
- const createKeys = params => {
35
- return {
36
- PK: createPartitionKey(params),
37
- SK: createSortKey(params)
38
- };
39
- };
40
-
41
- const createType = () => {
42
- return "cms.model";
7
+ const createSortKey = (params)=>params.modelId;
8
+ const createKeys = (params)=>{
9
+ if (!params.tenant) throw new Error("Missing tenant when creating model keys!");
10
+ return {
11
+ PK: createPartitionKey(params),
12
+ SK: createSortKey(params),
13
+ GSI_TENANT: params.tenant
14
+ };
43
15
  };
44
-
45
- const createModelsStorageOperations = params => {
46
- const {
47
- entity,
48
- elasticsearch
49
- } = params;
50
-
51
- const create = async params => {
52
- const {
53
- model
54
- } = params;
55
-
56
- const {
57
- index
58
- } = _configurations.configurations.es({
59
- model
60
- });
61
-
62
- const keys = createKeys(model);
63
- let error;
64
-
65
- try {
66
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
67
- TYPE: createType()
68
- }));
69
- return model;
70
- } catch (ex) {
71
- error = ex;
72
- }
73
- /**
74
- * In case of DynamoDB error we need to remove the index we created.
75
- */
76
-
77
-
78
- try {
79
- await elasticsearch.indices.delete({
80
- index,
81
- ignore_unavailable: true
82
- });
83
- } catch (ex) {
84
- throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
85
- dynamodbError: error,
86
- elasticsearchError: ex
87
- });
88
- }
89
-
90
- throw error;
91
- };
92
-
93
- const update = async params => {
94
- const {
95
- model
96
- } = params;
97
- const keys = createKeys(model);
98
-
99
- try {
100
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
101
- TYPE: createType()
102
- }));
103
- return model;
104
- } catch (ex) {
105
- throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
106
- error: ex,
107
- model,
108
- keys
109
- });
110
- }
111
- };
112
-
113
- const deleteModel = async params => {
114
- const {
115
- model
116
- } = params;
117
- const keys = createKeys(model);
118
-
119
- const {
120
- index
121
- } = _configurations.configurations.es({
122
- model
123
- });
124
-
125
- try {
126
- await entity.delete(keys);
127
- } catch (ex) {
128
- throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
129
- error: ex,
130
- model,
131
- keys
132
- });
133
- }
134
- /**
135
- * Always delete the model index after deleting the model.
136
- */
137
-
138
-
139
- try {
140
- await elasticsearch.indices.delete({
141
- index,
142
- ignore_unavailable: true
143
- });
144
- } catch (ex) {
145
- throw new _error.default(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
146
- error: ex,
147
- index,
148
- model
149
- });
150
- }
151
-
152
- return model;
153
- };
154
-
155
- const get = async params => {
156
- const keys = createKeys(params);
157
-
158
- try {
159
- const item = await (0, _get.get)({
160
- entity,
161
- keys
162
- });
163
- return (0, _cleanup.cleanupItem)(entity, item);
164
- } catch (ex) {
165
- throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
166
- error: ex,
167
- keys
168
- });
169
- }
170
- };
171
-
172
- const list = async params => {
173
- const {
174
- where
175
- } = params;
176
- const queryAllParams = {
177
- entity,
178
- partitionKey: createPartitionKey(where),
179
- options: {
180
- gte: " "
181
- }
16
+ const createType = ()=>"cms.model";
17
+ const createModelsStorageOperations = (params)=>{
18
+ const { entity, elasticsearch } = params;
19
+ const create = async (params)=>{
20
+ const { model } = params;
21
+ const { index } = configurations.es({
22
+ model
23
+ });
24
+ const keys = createKeys(model);
25
+ let error;
26
+ try {
27
+ await entity.put({
28
+ data: model,
29
+ ...keys,
30
+ TYPE: createType()
31
+ });
32
+ return model;
33
+ } catch (ex) {
34
+ error = ex;
35
+ }
36
+ try {
37
+ await elasticsearch.indices.delete({
38
+ index,
39
+ ignore_unavailable: true
40
+ });
41
+ } catch (ex) {
42
+ throw new _webiny_error(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
43
+ dynamodbError: error,
44
+ elasticsearchError: ex
45
+ });
46
+ }
47
+ throw error;
48
+ };
49
+ const update = async (params)=>{
50
+ const { model } = params;
51
+ const keys = createKeys(model);
52
+ try {
53
+ await entity.put({
54
+ data: model,
55
+ ...keys,
56
+ TYPE: createType()
57
+ });
58
+ return model;
59
+ } catch (ex) {
60
+ throw new _webiny_error(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
61
+ error: ex,
62
+ model,
63
+ keys
64
+ });
65
+ }
66
+ };
67
+ const deleteModel = async (params)=>{
68
+ const { model } = params;
69
+ const keys = createKeys(model);
70
+ const { index } = configurations.es({
71
+ model
72
+ });
73
+ try {
74
+ await entity.delete(keys);
75
+ } catch (ex) {
76
+ throw new _webiny_error(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
77
+ error: ex,
78
+ model,
79
+ keys
80
+ });
81
+ }
82
+ try {
83
+ await elasticsearch.indices.delete({
84
+ index,
85
+ ignore_unavailable: true
86
+ });
87
+ } catch (ex) {
88
+ throw new _webiny_error(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
89
+ error: ex,
90
+ index,
91
+ model
92
+ });
93
+ }
94
+ };
95
+ const get = async (params)=>{
96
+ const keys = createKeys(params);
97
+ try {
98
+ const result = await entity.get(keys);
99
+ return result ? result.data : null;
100
+ } catch (ex) {
101
+ throw new _webiny_error(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
102
+ error: ex,
103
+ keys
104
+ });
105
+ }
106
+ };
107
+ const list = async (params)=>{
108
+ const { where } = params;
109
+ const partitionKey = createPartitionKey(where);
110
+ try {
111
+ const result = await entity.queryAll({
112
+ partitionKey,
113
+ options: {
114
+ gte: " "
115
+ }
116
+ });
117
+ return result ? result.map((item)=>item.data) : [];
118
+ } catch (ex) {
119
+ throw new _webiny_error(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
120
+ error: ex,
121
+ partitionKey
122
+ });
123
+ }
124
+ };
125
+ return {
126
+ create,
127
+ update,
128
+ delete: deleteModel,
129
+ get,
130
+ list
182
131
  };
183
-
184
- try {
185
- const items = await (0, _query.queryAll)(queryAllParams);
186
- return (0, _cleanup.cleanupItems)(entity, items);
187
- } catch (ex) {
188
- throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
189
- error: ex,
190
- partitionKey: queryAllParams.partitionKey
191
- });
192
- }
193
- };
194
-
195
- return {
196
- create,
197
- update,
198
- delete: deleteModel,
199
- get,
200
- list
201
- };
202
132
  };
133
+ export { createModelsStorageOperations };
203
134
 
204
- exports.createModelsStorageOperations = createModelsStorageOperations;
135
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { configurations } from \"~/configurations\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\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}\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\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}\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 entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\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 entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\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 entity.delete(keys);\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 const item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\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 const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\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\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ApB;MAEA,OAAO,IAAAM,qBAAA,EAAalC,MAAb,EAAqBgC,KAArB,CAAP;IACH,CAJD,CAIE,OAAOpB,EAAP,EAAW;MACT,MAAM,IAAII,cAAJ,CACFJ,EAAE,CAACQ,OAAH,IAAc,wBADZ,EAEFR,EAAE,CAACS,IAAH,IAAW,kBAFT,EAGF;QACIb,KAAK,EAAEI,EADX;QAEIiB,YAAY,EAAED,cAAc,CAACC;MAFjC,CAHE,CAAN;IAQH;EACJ,CAvBD;;EAyBA,OAAO;IACH3B,MADG;IAEHiB,MAFG;IAGHL,MAAM,EAAEQ,WAHL;IAIHC,GAJG;IAKHG;EALG,CAAP;AAOH,CAxKM"}
1
+ {"version":3,"file":"operations/model/index.js","sources":["../../../src/operations/model/index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\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 entity.put({\n data: model,\n ...keys,\n TYPE: createType()\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 entity.put({\n data: model,\n ...keys,\n TYPE: createType()\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): Promise<void> => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\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\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\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 partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\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\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"names":["createPartitionKey","params","tenant","createSortKey","createKeys","Error","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","keys","error","ex","WebinyError","update","deleteModel","get","result","list","where","partitionKey","item"],"mappings":";;AAiBA,MAAMA,qBAAqB,CAACC;IACxB,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAO,CAAC,EAAE,EAAEC,OAAO,OAAO,CAAC;AAC/B;AAMA,MAAMC,gBAAgB,CAACF,SACZA,OAAO,OAAO;AASzB,MAAMG,aAAa,CAACH;IAChB,IAAI,CAACA,OAAO,MAAM,EACd,MAAM,IAAII,MAAM;IAEpB,OAAO;QACH,IAAIL,mBAAmBC;QACvB,IAAIE,cAAcF;QAClB,YAAYA,OAAO,MAAM;IAC7B;AACJ;AAEA,MAAMK,aAAa,IACR;AAQJ,MAAMC,gCAAgC,CACzCN;IAEA,MAAM,EAAEO,MAAM,EAAEC,aAAa,EAAE,GAAGR;IAElC,MAAMS,SAAS,OAAOT;QAClB,MAAM,EAAEU,KAAK,EAAE,GAAGV;QAElB,MAAM,EAAEW,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;YAChCF;QACJ;QAEA,MAAMG,OAAOV,WAAWO;QAExB,IA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AM,4BAA4B,CAAC,EAC5E,4BACA;gBACI,OAAOI;gBACPJ;gBACAD;YACJ;QAER;IACJ;IAEA,MAAMS,MAAM,OAAOnB;QACf,MAAMa,OAAOV,WAAWH;QAExB,IAAI;YACA,MAAMoB,SAAS,MAAMb,OAAO,GAAG,CAACM;YAEhC,OAAOO,SAASA,OAAO,IAAI,GAAG;QAClC,EAAE,OAAOL,IAAI;YACT,MAAM,IAAIC,cACND,GAAG,OAAO,IAAI,wBACdA,GAAG,IAAI,IAAI,mBACX;gBACI,OAAOA;gBACPF;YACJ;QAER;IACJ;IAEA,MAAMQ,OAAO,OAAOrB;QAChB,MAAM,EAAEsB,KAAK,EAAE,GAAGtB;QAClB,MAAMuB,eAAexB,mBAAmBuB;QACxC,IAAI;YACA,MAAMF,SAAS,MAAMb,OAAO,QAAQ,CAAC;gBACjCgB;gBACA,SAAS;oBACL,KAAK;gBACT;YACJ;YACA,OAAOH,SAASA,OAAO,GAAG,CAACI,CAAAA,OAAQA,KAAK,IAAI,IAAI,EAAE;QACtD,EAAE,OAAOT,IAAI;YACT,MAAM,IAAIC,cACND,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBACI,OAAOA;gBACPQ;YACJ;QAER;IACJ;IAEA,OAAO;QACHd;QACAQ;QACA,QAAQC;QACRC;QACAE;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "0.0.0-unstable.78f581c1d2",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.7be00a75a9",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "keywords": [
6
10
  "@webiny/api-headless-cms",
7
11
  "storage-operations",
8
12
  "dynamodb",
9
13
  "elasticsearch",
10
- "cms:ddb-es"
14
+ "ddb-es",
15
+ "cms:ddb-es",
16
+ "opensearch",
17
+ "ddb-os",
18
+ "cms:ddb-os"
11
19
  ],
12
20
  "repository": {
13
21
  "type": "git",
@@ -22,47 +30,42 @@
22
30
  ],
23
31
  "license": "MIT",
24
32
  "dependencies": {
25
- "@babel/runtime": "7.19.0",
26
- "@webiny/api": "0.0.0-unstable.78f581c1d2",
27
- "@webiny/api-elasticsearch": "0.0.0-unstable.78f581c1d2",
28
- "@webiny/api-headless-cms": "0.0.0-unstable.78f581c1d2",
29
- "@webiny/db-dynamodb": "0.0.0-unstable.78f581c1d2",
30
- "@webiny/error": "0.0.0-unstable.78f581c1d2",
31
- "@webiny/handler-db": "0.0.0-unstable.78f581c1d2",
32
- "@webiny/plugins": "0.0.0-unstable.78f581c1d2",
33
- "@webiny/utils": "0.0.0-unstable.78f581c1d2",
34
- "dataloader": "2.1.0",
35
- "dynamodb-toolbox": "0.3.5",
36
- "jsonpack": "1.1.5",
37
- "lodash": "4.17.21"
33
+ "@webiny/api": "0.0.0-unstable.7be00a75a9",
34
+ "@webiny/api-elasticsearch-tasks": "0.0.0-unstable.7be00a75a9",
35
+ "@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
36
+ "@webiny/api-opensearch": "0.0.0-unstable.7be00a75a9",
37
+ "@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
38
+ "@webiny/db-dynamodb": "0.0.0-unstable.7be00a75a9",
39
+ "@webiny/error": "0.0.0-unstable.7be00a75a9",
40
+ "@webiny/feature": "0.0.0-unstable.7be00a75a9",
41
+ "@webiny/handler-db": "0.0.0-unstable.7be00a75a9",
42
+ "@webiny/plugins": "0.0.0-unstable.7be00a75a9",
43
+ "@webiny/utils": "0.0.0-unstable.7be00a75a9",
44
+ "dataloader": "2.2.3",
45
+ "lodash": "4.18.1"
38
46
  },
39
47
  "devDependencies": {
40
- "@babel/cli": "^7.19.3",
41
- "@babel/core": "^7.19.3",
42
- "@babel/preset-env": "^7.19.4",
43
- "@elastic/elasticsearch": "7.12.0",
44
- "@types/jsonpack": "^1.1.0",
45
- "@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.78f581c1d2",
46
- "@webiny/cli": "^0.0.0-unstable.78f581c1d2",
47
- "@webiny/handler-aws": "^0.0.0-unstable.78f581c1d2",
48
- "@webiny/project-utils": "^0.0.0-unstable.78f581c1d2",
49
- "jest": "^28.1.0",
50
- "jest-dynalite": "^3.2.0",
51
- "jest-environment-node": "^27.2.4",
52
- "mdbid": "^1.0.0",
53
- "prettier": "^2.3.2",
54
- "rimraf": "^3.0.2",
55
- "sinon": "^9.0.2",
56
- "ttypescript": "^1.5.12",
57
- "typescript": "4.7.4"
48
+ "@types/jsonpack": "1.1.6",
49
+ "@webiny/api-core": "0.0.0-unstable.7be00a75a9",
50
+ "@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.7be00a75a9",
51
+ "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
52
+ "@webiny/di": "0.0.0-unstable.7be00a75a9",
53
+ "@webiny/handler": "0.0.0-unstable.7be00a75a9",
54
+ "@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
55
+ "@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9",
56
+ "@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
57
+ "@webiny/tasks": "0.0.0-unstable.7be00a75a9",
58
+ "@webiny/wcp": "0.0.0-unstable.7be00a75a9",
59
+ "jest-dynalite": "3.6.1",
60
+ "rimraf": "6.1.3",
61
+ "typescript": "6.0.3",
62
+ "vitest": "4.1.7"
58
63
  },
59
64
  "publishConfig": {
60
- "access": "public",
61
- "directory": "dist"
62
- },
63
- "scripts": {
64
- "build": "yarn webiny run build",
65
- "watch": "yarn webiny run watch"
65
+ "access": "public"
66
66
  },
67
- "gitHead": "78f581c1d2e5e6936aa11b9452a66d2a3652a1b2"
67
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
68
+ "webiny": {
69
+ "publishFrom": "dist"
70
+ }
68
71
  }
@@ -0,0 +1,2 @@
1
+ import type { CmsContext } from "../types.js";
2
+ export declare const createCreateIndexTask: (context: CmsContext) => void;
@@ -0,0 +1,45 @@
1
+ import { OpensearchTenantIndexFactory } from "@webiny/api-elasticsearch-tasks";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
3
+ import { configurations } from "../configurations.js";
4
+ import { CmsEntryOpenSearchIndex } from "../features/CmsEntryOpenSearchIndex/index.js";
5
+ class CreateElasticsearchIndexTask {
6
+ constructor(context, listModels){
7
+ this.context = context;
8
+ this.listModels = listModels;
9
+ }
10
+ async getIndexList(tenant) {
11
+ const result = await this.listModels.execute();
12
+ const models = result.value;
13
+ if (0 === models.length) return [];
14
+ const indexConfigs = this.context.container.resolveAll(CmsEntryOpenSearchIndex);
15
+ const indexes = models.map((model)=>{
16
+ const { index } = configurations.es({
17
+ model: {
18
+ modelId: model.modelId,
19
+ tenant: tenant.id
20
+ }
21
+ });
22
+ return {
23
+ index,
24
+ settings: configurations.indexSettings({
25
+ indexConfigs,
26
+ model: {
27
+ modelId: model.modelId,
28
+ tenant: tenant.id,
29
+ group: model.group
30
+ }
31
+ })
32
+ };
33
+ });
34
+ return indexes;
35
+ }
36
+ }
37
+ const createCreateIndexTask = (context)=>{
38
+ context.container.registerFactory(OpensearchTenantIndexFactory, ()=>{
39
+ const listModels = context.container.resolve(ListModelsUseCase);
40
+ return new CreateElasticsearchIndexTask(context, listModels);
41
+ });
42
+ };
43
+ export { createCreateIndexTask };
44
+
45
+ //# sourceMappingURL=createIndexTaskPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks/createIndexTaskPlugin.js","sources":["../../src/tasks/createIndexTaskPlugin.ts"],"sourcesContent":["import { OpensearchTenantIndexFactory } from \"@webiny/api-elasticsearch-tasks\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsContext } from \"~/types.js\";\nimport { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\nclass CreateElasticsearchIndexTask implements OpensearchTenantIndexFactory.Interface {\n constructor(\n private context: CmsContext,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async getIndexList(tenant: Tenant): Promise<OpensearchTenantIndexFactory.IndexConfig[]> {\n const result = await this.listModels.execute();\n const models = result.value;\n\n if (models.length === 0) {\n return [];\n }\n\n const indexConfigs = this.context.container.resolveAll(CmsEntryOpenSearchIndex);\n\n const indexes = models.map<OpensearchTenantIndexFactory.IndexConfig>(model => {\n const { index } = configurations.es({\n model: {\n modelId: model.modelId,\n tenant: tenant.id\n }\n });\n return {\n index,\n settings: configurations.indexSettings({\n indexConfigs,\n model: {\n modelId: model.modelId,\n tenant: tenant.id,\n group: model.group\n }\n })\n };\n });\n\n return indexes;\n }\n}\n\nexport const createCreateIndexTask = (context: CmsContext) => {\n context.container.registerFactory(OpensearchTenantIndexFactory, () => {\n const listModels = context.container.resolve(ListModelsUseCase);\n return new CreateElasticsearchIndexTask(context, listModels);\n });\n};\n"],"names":["CreateElasticsearchIndexTask","context","listModels","tenant","result","models","indexConfigs","CmsEntryOpenSearchIndex","indexes","model","index","configurations","createCreateIndexTask","OpensearchTenantIndexFactory","ListModelsUseCase"],"mappings":";;;;AAOA,MAAMA;IACF,YACYC,OAAmB,EACnBC,UAAuC,CACjD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,aAAaC,MAAc,EAAuD;QACpF,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5C,MAAMC,SAASD,OAAO,KAAK;QAE3B,IAAIC,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,EAAE;QAGb,MAAMC,eAAe,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAACC;QAEvD,MAAMC,UAAUH,OAAO,GAAG,CAA2CI,CAAAA;YACjE,MAAM,EAAEC,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;gBAChC,OAAO;oBACH,SAASF,MAAM,OAAO;oBACtB,QAAQN,OAAO,EAAE;gBACrB;YACJ;YACA,OAAO;gBACHO;gBACA,UAAUC,eAAe,aAAa,CAAC;oBACnCL;oBACA,OAAO;wBACH,SAASG,MAAM,OAAO;wBACtB,QAAQN,OAAO,EAAE;wBACjB,OAAOM,MAAM,KAAK;oBACtB;gBACJ;YACJ;QACJ;QAEA,OAAOD;IACX;AACJ;AAEO,MAAMI,wBAAwB,CAACX;IAClCA,QAAQ,SAAS,CAAC,eAAe,CAACY,8BAA8B;QAC5D,MAAMX,aAAaD,QAAQ,SAAS,CAAC,OAAO,CAACa;QAC7C,OAAO,IAAId,6BAA6BC,SAASC;IACrD;AACJ"}