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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/README.md +6 -30
  2. package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbEsDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
  7. package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
  8. package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbEsEntryEntity.js +5 -0
  10. package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
  11. package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbEsGroupEntity.js +5 -0
  13. package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
  14. package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
  15. package/abstractions/CmsDdbEsModelEntity.js +5 -0
  16. package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
  17. package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
  18. package/abstractions/CmsDdbEsOsTable.js +5 -0
  19. package/abstractions/CmsDdbEsOsTable.js.map +1 -0
  20. package/abstractions/CmsDdbEsTable.d.ts +5 -0
  21. package/abstractions/CmsDdbEsTable.js +5 -0
  22. package/abstractions/CmsDdbEsTable.js.map +1 -0
  23. package/debuggerNamespaces.d.ts +12 -0
  24. package/debuggerNamespaces.js +0 -0
  25. package/definitions/entry.d.ts +5 -6
  26. package/definitions/entry.js +9 -89
  27. package/definitions/entry.js.map +1 -0
  28. package/definitions/group.d.ts +6 -6
  29. package/definitions/group.js +9 -72
  30. package/definitions/group.js.map +1 -0
  31. package/definitions/model.d.ts +6 -6
  32. package/definitions/model.js +9 -94
  33. package/definitions/model.js.map +1 -0
  34. package/definitions/types.d.ts +65 -0
  35. package/definitions/types.js +0 -0
  36. package/feature.d.ts +10 -0
  37. package/feature.js +69 -0
  38. package/feature.js.map +1 -0
  39. package/index.d.ts +1 -2
  40. package/index.js +1 -171
  41. package/operations/entry/DdbEsCreateEntry.d.ts +24 -0
  42. package/operations/entry/DdbEsCreateEntry.js +134 -0
  43. package/operations/entry/DdbEsCreateEntry.js.map +1 -0
  44. package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +24 -0
  45. package/operations/entry/DdbEsCreateEntryRevisionFrom.js +139 -0
  46. package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
  47. package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
  48. package/operations/entry/DdbEsDeleteEntry.js +79 -0
  49. package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
  50. package/operations/entry/DdbEsDeleteEntryRevision.d.ts +24 -0
  51. package/operations/entry/DdbEsDeleteEntryRevision.js +136 -0
  52. package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
  53. package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
  54. package/operations/entry/DdbEsDeleteMultipleEntries.js +80 -0
  55. package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
  56. package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
  57. package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
  58. package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
  59. package/operations/entry/DdbEsGetEntry.d.ts +14 -0
  60. package/operations/entry/DdbEsGetEntry.js +27 -0
  61. package/operations/entry/DdbEsGetEntry.js.map +1 -0
  62. package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
  63. package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
  64. package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
  65. package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
  66. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
  67. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
  68. package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
  69. package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
  70. package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
  71. package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
  72. package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
  73. package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
  74. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
  75. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
  76. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
  77. package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
  78. package/operations/entry/DdbEsGetRevisionById.js +34 -0
  79. package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
  80. package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
  81. package/operations/entry/DdbEsGetRevisions.js +33 -0
  82. package/operations/entry/DdbEsGetRevisions.js.map +1 -0
  83. package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +18 -0
  84. package/operations/entry/DdbEsGetUniqueFieldValues.js +77 -0
  85. package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
  86. package/operations/entry/DdbEsListEntries.d.ts +28 -0
  87. package/operations/entry/DdbEsListEntries.js +110 -0
  88. package/operations/entry/DdbEsListEntries.js.map +1 -0
  89. package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
  90. package/operations/entry/DdbEsMoveEntry.js +113 -0
  91. package/operations/entry/DdbEsMoveEntry.js.map +1 -0
  92. package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
  93. package/operations/entry/DdbEsMoveToBin.js +137 -0
  94. package/operations/entry/DdbEsMoveToBin.js.map +1 -0
  95. package/operations/entry/DdbEsPublishEntry.d.ts +24 -0
  96. package/operations/entry/DdbEsPublishEntry.js +231 -0
  97. package/operations/entry/DdbEsPublishEntry.js.map +1 -0
  98. package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
  99. package/operations/entry/DdbEsRestoreFromBin.js +137 -0
  100. package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
  101. package/operations/entry/DdbEsUnpublishEntry.d.ts +24 -0
  102. package/operations/entry/DdbEsUnpublishEntry.js +127 -0
  103. package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
  104. package/operations/entry/DdbEsUpdateEntry.d.ts +24 -0
  105. package/operations/entry/DdbEsUpdateEntry.js +175 -0
  106. package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
  107. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  108. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  109. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  110. package/operations/entry/dataLoader/constants.d.ts +1 -0
  111. package/operations/entry/dataLoader/constants.js +5 -0
  112. package/operations/entry/dataLoader/constants.js.map +1 -0
  113. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  114. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  115. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  116. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  117. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  118. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  120. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  121. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  123. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  124. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  125. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  126. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  127. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  128. package/operations/entry/dataLoader/index.d.ts +8 -0
  129. package/operations/entry/dataLoader/index.js +18 -0
  130. package/operations/entry/dataLoader/index.js.map +1 -0
  131. package/operations/entry/dataLoader/types.d.ts +6 -0
  132. package/operations/entry/dataLoader/types.js +0 -0
  133. package/operations/entry/dataLoaders.d.ts +22 -39
  134. package/operations/entry/dataLoaders.js +90 -339
  135. package/operations/entry/dataLoaders.js.map +1 -0
  136. package/operations/entry/feature.d.ts +4 -0
  137. package/operations/entry/feature.js +55 -0
  138. package/operations/entry/feature.js.map +1 -0
  139. package/operations/entry/keys.d.ts +31 -1
  140. package/operations/entry/keys.js +45 -35
  141. package/operations/entry/keys.js.map +1 -0
  142. package/operations/entry/recordType.d.ts +3 -0
  143. package/operations/entry/recordType.js +6 -0
  144. package/operations/entry/recordType.js.map +1 -0
  145. package/operations/entry/storageEntryUtils.d.ts +7 -0
  146. package/operations/entry/storageEntryUtils.js +14 -0
  147. package/operations/entry/storageEntryUtils.js.map +1 -0
  148. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  149. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  150. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  151. package/operations/entry/transformations/index.d.ts +32 -0
  152. package/operations/entry/transformations/index.js +91 -0
  153. package/operations/entry/transformations/index.js.map +1 -0
  154. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  155. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  156. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  157. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  158. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  159. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  160. package/operations/group/DdbEsCreateGroup.d.ts +12 -0
  161. package/operations/group/DdbEsCreateGroup.js +35 -0
  162. package/operations/group/DdbEsCreateGroup.js.map +1 -0
  163. package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
  164. package/operations/group/DdbEsDeleteGroup.js +31 -0
  165. package/operations/group/DdbEsDeleteGroup.js.map +1 -0
  166. package/operations/group/DdbEsGetGroup.d.ts +12 -0
  167. package/operations/group/DdbEsGetGroup.js +31 -0
  168. package/operations/group/DdbEsGetGroup.js.map +1 -0
  169. package/operations/group/DdbEsListGroups.d.ts +14 -0
  170. package/operations/group/DdbEsListGroups.js +52 -0
  171. package/operations/group/DdbEsListGroups.js.map +1 -0
  172. package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
  173. package/operations/group/DdbEsUpdateGroup.js +35 -0
  174. package/operations/group/DdbEsUpdateGroup.js.map +1 -0
  175. package/operations/group/feature.d.ts +4 -0
  176. package/operations/group/feature.js +19 -0
  177. package/operations/group/feature.js.map +1 -0
  178. package/operations/group/keys.d.ts +15 -0
  179. package/operations/group/keys.js +17 -0
  180. package/operations/group/keys.js.map +1 -0
  181. package/operations/model/DdbEsCreateModel.d.ts +16 -0
  182. package/operations/model/DdbEsCreateModel.js +56 -0
  183. package/operations/model/DdbEsCreateModel.js.map +1 -0
  184. package/operations/model/DdbEsDeleteModel.d.ts +12 -0
  185. package/operations/model/DdbEsDeleteModel.js +31 -0
  186. package/operations/model/DdbEsDeleteModel.js.map +1 -0
  187. package/operations/model/DdbEsGetModel.d.ts +12 -0
  188. package/operations/model/DdbEsGetModel.js +30 -0
  189. package/operations/model/DdbEsGetModel.js.map +1 -0
  190. package/operations/model/DdbEsListModels.d.ts +12 -0
  191. package/operations/model/DdbEsListModels.js +36 -0
  192. package/operations/model/DdbEsListModels.js.map +1 -0
  193. package/operations/model/DdbEsUpdateModel.d.ts +12 -0
  194. package/operations/model/DdbEsUpdateModel.js +36 -0
  195. package/operations/model/DdbEsUpdateModel.js.map +1 -0
  196. package/operations/model/feature.d.ts +4 -0
  197. package/operations/model/feature.js +19 -0
  198. package/operations/model/feature.js.map +1 -0
  199. package/operations/model/keys.d.ts +15 -0
  200. package/operations/model/keys.js +17 -0
  201. package/operations/model/keys.js.map +1 -0
  202. package/package.json +49 -46
  203. package/registry/CmsEntitiesDbRegistryDecorator.d.ts +27 -0
  204. package/registry/CmsEntitiesDbRegistryDecorator.js +46 -0
  205. package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -0
  206. package/tasks/CreateElasticsearchIndexTask.d.ts +15 -0
  207. package/tasks/CreateElasticsearchIndexTask.js +49 -0
  208. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  209. package/types.d.ts +13 -182
  210. package/types.js +10 -60
  211. package/types.js.map +1 -0
  212. package/configurations.d.ts +0 -12
  213. package/configurations.js +0 -32
  214. package/definitions/entryElasticsearch.d.ts +0 -8
  215. package/definitions/entryElasticsearch.js +0 -46
  216. package/definitions/settings.d.ts +0 -8
  217. package/definitions/settings.js +0 -62
  218. package/definitions/system.d.ts +0 -8
  219. package/definitions/system.js +0 -50
  220. package/definitions/table.d.ts +0 -8
  221. package/definitions/table.js +0 -24
  222. package/definitions/tableElasticsearch.d.ts +0 -8
  223. package/definitions/tableElasticsearch.js +0 -24
  224. package/dynamoDb/index.d.ts +0 -2
  225. package/dynamoDb/index.js +0 -18
  226. package/dynamoDb/storage/date.d.ts +0 -3
  227. package/dynamoDb/storage/date.js +0 -65
  228. package/dynamoDb/storage/longText.d.ts +0 -7
  229. package/dynamoDb/storage/longText.js +0 -83
  230. package/dynamoDb/storage/richText.d.ts +0 -8
  231. package/dynamoDb/storage/richText.js +0 -110
  232. package/elasticsearch/index.d.ts +0 -2
  233. package/elasticsearch/index.js +0 -16
  234. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  235. package/elasticsearch/indexing/dateTimeIndexing.js +0 -89
  236. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  237. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -47
  238. package/elasticsearch/indexing/index.d.ts +0 -2
  239. package/elasticsearch/indexing/index.js +0 -24
  240. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -3
  241. package/elasticsearch/indexing/longTextIndexing.js +0 -36
  242. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  243. package/elasticsearch/indexing/numberIndexing.js +0 -48
  244. package/elasticsearch/indexing/objectIndexing.d.ts +0 -3
  245. package/elasticsearch/indexing/objectIndexing.js +0 -200
  246. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  247. package/elasticsearch/indexing/richTextIndexing.js +0 -34
  248. package/elasticsearch/search/index.d.ts +0 -3
  249. package/elasticsearch/search/index.js +0 -16
  250. package/elasticsearch/search/refSearch.d.ts +0 -3
  251. package/elasticsearch/search/refSearch.js +0 -24
  252. package/elasticsearch/search/timeSearch.d.ts +0 -3
  253. package/elasticsearch/search/timeSearch.js +0 -25
  254. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  255. package/helpers/createElasticsearchQueryBody.js +0 -375
  256. package/helpers/entryIndexHelpers.d.ts +0 -18
  257. package/helpers/entryIndexHelpers.js +0 -189
  258. package/helpers/fields.d.ts +0 -77
  259. package/helpers/fields.js +0 -174
  260. package/helpers/index.d.ts +0 -2
  261. package/helpers/index.js +0 -31
  262. package/helpers/operatorPluginsList.d.ts +0 -7
  263. package/helpers/operatorPluginsList.js +0 -30
  264. package/helpers/searchPluginsList.d.ts +0 -6
  265. package/helpers/searchPluginsList.js +0 -26
  266. package/helpers/transformValueForSearch.d.ts +0 -9
  267. package/helpers/transformValueForSearch.js +0 -26
  268. package/operations/entry/elasticsearchFields.d.ts +0 -2
  269. package/operations/entry/elasticsearchFields.js +0 -32
  270. package/operations/entry/fields.d.ts +0 -3
  271. package/operations/entry/fields.js +0 -60
  272. package/operations/entry/index.d.ts +0 -13
  273. package/operations/entry/index.js +0 -1152
  274. package/operations/group/index.d.ts +0 -8
  275. package/operations/group/index.js +0 -202
  276. package/operations/model/index.d.ts +0 -8
  277. package/operations/model/index.js +0 -205
  278. package/operations/settings/index.d.ts +0 -6
  279. package/operations/settings/index.js +0 -141
  280. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  281. package/operations/system/createElasticsearchTemplate.js +0 -62
  282. package/operations/system/index.d.ts +0 -6
  283. package/operations/system/index.js +0 -105
  284. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -17
  285. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -24
  286. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  287. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  288. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -17
  289. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -24
  290. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -17
  291. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -24
  292. package/upgrades/index.d.ts +0 -2
  293. package/upgrades/index.js +0 -16
  294. package/upgrades/utils.d.ts +0 -1
  295. package/upgrades/utils.js +0 -16
  296. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  297. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  298. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  299. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  300. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  301. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  302. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  303. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  304. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  305. package/upgrades/v5.0.0/helpers.js +0 -57
  306. package/upgrades/v5.0.0/index.d.ts +0 -4
  307. package/upgrades/v5.0.0/index.js +0 -232
  308. package/upgrades/v5.8.0/index.d.ts +0 -4
  309. package/upgrades/v5.8.0/index.js +0 -426
@@ -0,0 +1,27 @@
1
+ import { DbRegistry } from "@webiny/db/exports/api/db.js";
2
+ import { CmsDdbEsEntryEntity } from "../abstractions/CmsDdbEsEntryEntity.js";
3
+ import { CmsDdbEsEntriesEsEntity } from "../abstractions/CmsDdbEsEntriesEsEntity.js";
4
+ /**
5
+ * Adds the CMS entities to every request's DbRegistry.
6
+ *
7
+ * DbRegistry is container scoped: each request (child) container builds its own, empty registry. The
8
+ * DDB to OpenSearch sync looks up two CMS entities in it (the DynamoDB entries entity and the
9
+ * OpenSearch entries entity), so every one of those registries needs them.
10
+ *
11
+ * The CMS storage feature runs once, in the root, before any request exists, so it can't register into
12
+ * per-request registries directly. Instead it registers this decorator in the root. Decorators on a
13
+ * container-scoped registration apply to every instance as it is built, so this constructor runs once
14
+ * per request registry and adds the two entities. Every other call passes through to the registry.
15
+ */
16
+ declare class CmsEntitiesDbRegistryDecoratorImpl implements DbRegistry.Interface {
17
+ private readonly decoratee;
18
+ constructor(entryEntity: CmsDdbEsEntryEntity.Interface, entriesEsEntity: CmsDdbEsEntriesEsEntity.Interface, decoratee: DbRegistry.Interface);
19
+ register<T = unknown>(params: DbRegistry.RegisterParams<T>): void;
20
+ getOneItem<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T>;
21
+ getItem<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T> | null;
22
+ getItems<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T>[];
23
+ }
24
+ export declare const CmsEntitiesDbRegistryDecorator: typeof CmsEntitiesDbRegistryDecoratorImpl & {
25
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/db/features/DbRegistry/abstractions").IRegistry>;
26
+ };
27
+ export {};
@@ -0,0 +1,46 @@
1
+ import { DbRegistry } from "@webiny/db/exports/api/db.js";
2
+ import { CmsDdbEsEntryEntity } from "../abstractions/CmsDdbEsEntryEntity.js";
3
+ import { CmsDdbEsEntriesEsEntity } from "../abstractions/CmsDdbEsEntriesEsEntity.js";
4
+ class CmsEntitiesDbRegistryDecoratorImpl {
5
+ constructor(entryEntity, entriesEsEntity, decoratee){
6
+ this.decoratee = decoratee;
7
+ decoratee.register({
8
+ item: entryEntity,
9
+ app: "cms",
10
+ tags: [
11
+ "regular",
12
+ entryEntity.name
13
+ ]
14
+ });
15
+ decoratee.register({
16
+ item: entriesEsEntity,
17
+ app: "cms",
18
+ tags: [
19
+ "es",
20
+ entriesEsEntity.name
21
+ ]
22
+ });
23
+ }
24
+ register(params) {
25
+ this.decoratee.register(params);
26
+ }
27
+ getOneItem(cb) {
28
+ return this.decoratee.getOneItem(cb);
29
+ }
30
+ getItem(cb) {
31
+ return this.decoratee.getItem(cb);
32
+ }
33
+ getItems(cb) {
34
+ return this.decoratee.getItems(cb);
35
+ }
36
+ }
37
+ const CmsEntitiesDbRegistryDecorator = DbRegistry.createDecorator({
38
+ decorator: CmsEntitiesDbRegistryDecoratorImpl,
39
+ dependencies: [
40
+ CmsDdbEsEntryEntity,
41
+ CmsDdbEsEntriesEsEntity
42
+ ]
43
+ });
44
+ export { CmsEntitiesDbRegistryDecorator };
45
+
46
+ //# sourceMappingURL=CmsEntitiesDbRegistryDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry/CmsEntitiesDbRegistryDecorator.js","sources":["../../src/registry/CmsEntitiesDbRegistryDecorator.ts"],"sourcesContent":["import { DbRegistry } from \"@webiny/db/exports/api/db.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\n\n/**\n * Adds the CMS entities to every request's DbRegistry.\n *\n * DbRegistry is container scoped: each request (child) container builds its own, empty registry. The\n * DDB to OpenSearch sync looks up two CMS entities in it (the DynamoDB entries entity and the\n * OpenSearch entries entity), so every one of those registries needs them.\n *\n * The CMS storage feature runs once, in the root, before any request exists, so it can't register into\n * per-request registries directly. Instead it registers this decorator in the root. Decorators on a\n * container-scoped registration apply to every instance as it is built, so this constructor runs once\n * per request registry and adds the two entities. Every other call passes through to the registry.\n */\nclass CmsEntitiesDbRegistryDecoratorImpl implements DbRegistry.Interface {\n public constructor(\n entryEntity: CmsDdbEsEntryEntity.Interface,\n entriesEsEntity: CmsDdbEsEntriesEsEntity.Interface,\n private readonly decoratee: DbRegistry.Interface\n ) {\n decoratee.register({\n item: entryEntity,\n app: \"cms\",\n tags: [\"regular\", entryEntity.name]\n });\n decoratee.register({\n item: entriesEsEntity,\n app: \"cms\",\n tags: [\"es\", entriesEsEntity.name]\n });\n }\n\n public register<T = unknown>(params: DbRegistry.RegisterParams<T>): void {\n this.decoratee.register(params);\n }\n\n public getOneItem<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T> {\n return this.decoratee.getOneItem(cb);\n }\n\n public getItem<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T> | null {\n return this.decoratee.getItem(cb);\n }\n\n public getItems<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T>[] {\n return this.decoratee.getItems(cb);\n }\n}\n\nexport const CmsEntitiesDbRegistryDecorator = DbRegistry.createDecorator({\n decorator: CmsEntitiesDbRegistryDecoratorImpl,\n dependencies: [CmsDdbEsEntryEntity, CmsDdbEsEntriesEsEntity]\n});\n"],"names":["CmsEntitiesDbRegistryDecoratorImpl","entryEntity","entriesEsEntity","decoratee","params","cb","CmsEntitiesDbRegistryDecorator","DbRegistry","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity"],"mappings":";;;AAgBA,MAAMA;IACF,YACIC,WAA0C,EAC1CC,eAAkD,EACjCC,SAA+B,CAClD;aADmBA,SAAS,GAATA;QAEjBA,UAAU,QAAQ,CAAC;YACf,MAAMF;YACN,KAAK;YACL,MAAM;gBAAC;gBAAWA,YAAY,IAAI;aAAC;QACvC;QACAE,UAAU,QAAQ,CAAC;YACf,MAAMD;YACN,KAAK;YACL,MAAM;gBAAC;gBAAMA,gBAAgB,IAAI;aAAC;QACtC;IACJ;IAEO,SAAsBE,MAAoC,EAAQ;QACrE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACA;IAC5B;IAEO,WACHC,EAAiD,EACvB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAACA;IACrC;IAEO,QACHA,EAAiD,EAChB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;IAClC;IAEO,SACHA,EAAiD,EACrB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACA;IACnC;AACJ;AAEO,MAAMC,iCAAiCC,WAAW,eAAe,CAAC;IACrE,WAAWP;IACX,cAAc;QAACQ;QAAqBC;KAAwB;AAChE"}
@@ -0,0 +1,15 @@
1
+ import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
3
+ import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
4
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
5
+ declare class CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {
6
+ private readonly indexProvider;
7
+ private listModels;
8
+ private readonly logger;
9
+ constructor(indexProvider: CmsModelOpenSearchIndexProvider.Interface, listModels: ListModelsUseCase.Interface, logger: Logger.Interface);
10
+ getIndexList(tenant: TenantIndexFactory.Tenant): Promise<TenantIndexFactory.IndexConfig[]>;
11
+ }
12
+ export declare const CreateElasticsearchIndexTask: typeof CreateElasticsearchIndexTaskImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-search-index-tasks/abstractions/TenantIndexFactory").ITenantIndexFactory>;
14
+ };
15
+ export {};
@@ -0,0 +1,49 @@
1
+ import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
3
+ import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
4
+ import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
5
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
6
+ class CreateElasticsearchIndexTaskImpl {
7
+ constructor(indexProvider, listModels, logger){
8
+ this.indexProvider = indexProvider;
9
+ this.listModels = listModels;
10
+ this.logger = logger;
11
+ }
12
+ async getIndexList(tenant) {
13
+ const result = await this.listModels.execute();
14
+ if (result.isFail()) {
15
+ this.logger.error({
16
+ error: result.error
17
+ }, "Failed to list models for index creation.");
18
+ return [];
19
+ }
20
+ const models = result.value;
21
+ if (0 === models.length) return [];
22
+ const configurations = createConfigurations(this.indexProvider);
23
+ const indices = [];
24
+ for (const model of models){
25
+ const { index, settings } = await configurations.es({
26
+ model: {
27
+ ...model,
28
+ tenant: tenant.id
29
+ }
30
+ });
31
+ indices.push({
32
+ index,
33
+ settings
34
+ });
35
+ }
36
+ return indices;
37
+ }
38
+ }
39
+ const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({
40
+ implementation: CreateElasticsearchIndexTaskImpl,
41
+ dependencies: [
42
+ CmsModelOpenSearchIndexProvider,
43
+ ListModelsUseCase,
44
+ Logger
45
+ ]
46
+ });
47
+ export { CreateElasticsearchIndexTask };
48
+
49
+ //# sourceMappingURL=CreateElasticsearchIndexTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks/CreateElasticsearchIndexTask.js","sources":["../../src/tasks/CreateElasticsearchIndexTask.ts"],"sourcesContent":["import { TenantIndexFactory } from \"@webiny/api-search-index-tasks\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\nclass CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {\n constructor(\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private listModels: ListModelsUseCase.Interface,\n private readonly logger: Logger.Interface\n ) {}\n\n async getIndexList(\n tenant: TenantIndexFactory.Tenant\n ): Promise<TenantIndexFactory.IndexConfig[]> {\n const result = await this.listModels.execute();\n if (result.isFail()) {\n this.logger.error({ error: result.error }, \"Failed to list models for index creation.\");\n return [];\n }\n const models = result.value;\n\n if (models.length === 0) {\n return [];\n }\n\n const configurations = createConfigurations(this.indexProvider);\n\n const indices: TenantIndexFactory.IndexConfig[] = [];\n for (const model of models) {\n const { index, settings } = await configurations.es({\n model: {\n ...model,\n tenant: tenant.id\n }\n });\n indices.push({ index, settings });\n }\n return indices;\n }\n}\n\nexport const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({\n implementation: CreateElasticsearchIndexTaskImpl,\n dependencies: [CmsModelOpenSearchIndexProvider, ListModelsUseCase, Logger]\n});\n"],"names":["CreateElasticsearchIndexTaskImpl","indexProvider","listModels","logger","tenant","result","models","configurations","createConfigurations","indices","model","index","settings","CreateElasticsearchIndexTask","TenantIndexFactory","CmsModelOpenSearchIndexProvider","ListModelsUseCase","Logger"],"mappings":";;;;;AAMA,MAAMA;IACF,YACqBC,aAAwD,EACjEC,UAAuC,EAC9BC,MAAwB,CAC3C;aAHmBF,aAAa,GAAbA;aACTC,UAAU,GAAVA;aACSC,MAAM,GAANA;IAClB;IAEH,MAAM,aACFC,MAAiC,EACQ;QACzC,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5C,IAAIA,OAAO,MAAM,IAAI;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAOA,OAAO,KAAK;YAAC,GAAG;YAC3C,OAAO,EAAE;QACb;QACA,MAAMC,SAASD,OAAO,KAAK;QAE3B,IAAIC,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,EAAE;QAGb,MAAMC,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAE9D,MAAMC,UAA4C,EAAE;QACpD,KAAK,MAAMC,SAASJ,OAAQ;YACxB,MAAM,EAAEK,KAAK,EAAEC,QAAQ,EAAE,GAAG,MAAML,eAAe,EAAE,CAAC;gBAChD,OAAO;oBACH,GAAGG,KAAK;oBACR,QAAQN,OAAO,EAAE;gBACrB;YACJ;YACAK,QAAQ,IAAI,CAAC;gBAAEE;gBAAOC;YAAS;QACnC;QACA,OAAOH;IACX;AACJ;AAEO,MAAMI,+BAA+BC,mBAAmB,oBAAoB,CAAC;IAChF,gBAAgBd;IAChB,cAAc;QAACe;QAAiCC;QAAmBC;KAAO;AAC9E"}
package/types.d.ts CHANGED
@@ -1,191 +1,22 @@
1
- import { Plugin } from "@webiny/plugins/types";
2
- import { CmsEntry, CmsModel, CmsModelField, CmsModelFieldToGraphQLPlugin, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
- import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
4
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
5
- import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
6
- import { Client } from "@elastic/elasticsearch";
7
- import { Entity, Table } from "dynamodb-toolbox";
8
- import { PluginsContainer } from "@webiny/plugins";
9
- /**
10
- * Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
11
- *
12
- * @see ElasticsearchQueryBuilderValueSearchPlugin.transform
13
- */
14
- interface ElasticsearchQueryBuilderValueSearchPluginArgs {
15
- field: CmsModelField;
16
- value: any;
17
- }
18
- /**
19
- * A plugin definition for transforming the search value for Elasticsearch.
20
- *
21
- * @category Plugin
22
- * @category Elasticsearch
23
- */
24
- export interface ElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
25
- /**
26
- * A plugin type.
27
- */
28
- type: "cms-elastic-search-query-builder-value-search";
29
- /**
30
- * A field type for plugin to target.
31
- */
32
- fieldType: string;
33
- /**
34
- * Transform value that is going to be searched for in the Elasticsearch.
35
- */
36
- transform: (args: ElasticsearchQueryBuilderValueSearchPluginArgs) => any;
37
- }
38
- /**
39
- * A definition of the entry that is being prepared for the Elasticsearch.
40
- *
41
- * @category Elasticsearch
42
- * @category CmsEntry
43
- */
44
- export interface CmsIndexEntry extends CmsEntry {
45
- /**
46
- * Values that are not going to be indexed.
47
- */
48
- rawValues: Record<string, any>;
49
- /**
50
- * A first part of the ID, without the revision.
51
- * For example, we can search for all the revisions of the given entry.
52
- */
53
- primaryId: string;
54
- /**
55
- * Dev can add what ever keys they want and need. Just need to be careful not to break the entry.
56
- */
57
- [key: string]: any;
58
- }
59
- /**
60
- * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.
61
- *
62
- * @category Elasticsearch
63
- * @category CmsEntry
64
- */
65
- interface CmsModelFieldToElasticsearchToParams {
66
- plugins: PluginsContainer;
67
- model: CmsModel;
68
- field: CmsModelField;
69
- /**
70
- * Raw value on the entry - before prepare for storage.
71
- */
72
- rawValue: any;
73
- /**
74
- * Value prepared for storage received from base api-headless-cms package.
75
- */
76
- value: any;
77
- getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;
78
- getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;
79
- }
80
- /**
81
- * Arguments for the method that is transforming content entry from Elasticsearch into the original one.
82
- *
83
- * @category Elasticsearch
84
- * @category CmsEntry
85
- */
86
- interface CmsModelFieldToElasticsearchFromParams {
87
- plugins: PluginsContainer;
88
- model: CmsModel;
89
- field: CmsModelField;
90
- value: any;
91
- rawValue: any;
92
- getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;
93
- getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;
94
- }
95
- interface ToIndexValue {
96
- /**
97
- * Use this key to store value for indexing.
98
- */
99
- value?: any;
100
- /**
101
- * Use this key to tell ES that this value should not be indexed.
102
- */
103
- rawValue?: any;
104
- }
105
- /**
106
- * A plugin defining transformation of entry for Elasticsearch.
107
- *
108
- * @category Plugin
109
- * @category ContentModelField
110
- * @category CmsEntry
111
- * @category Elasticsearch
112
- */
113
- export interface CmsModelFieldToElasticsearchPlugin extends Plugin {
114
- /**
115
- * A plugin type
116
- */
117
- type: "cms-model-field-to-elastic-search";
118
- /**
119
- * A unique identifier of the field type (text, number, json, myField, ...).
120
- *
121
- * ```ts
122
- * fieldType: "myField"
123
- * ```
124
- */
125
- fieldType: string;
126
- /**
127
- * If you need to define a type when building an Elasticsearch query.
128
- * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.
129
- *
130
- * ```ts
131
- * unmappedType: "date"
132
- * ```
133
- */
134
- unmappedType?: (field: CmsModelField) => string;
135
- /**
136
- * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.
137
- * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.
138
- *
139
- * ```ts
140
- * toIndex({ value }) {
141
- * return {
142
- * value: value, // This will be stored and indexed
143
- * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing
144
- * };
145
- * }
146
- * ```
147
- */
148
- toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;
149
- /**
150
- * This is meant to revert a transformation done in the `toIndex` method.
151
- * You have access to "value" or a "rawValue", depending on what you returned from `toIndex`.
152
- *
153
- * ```ts
154
- * fromIndex({ value, rawValue }) {
155
- * return JSON.parse(rawValue);
156
- * }
157
- * ```
158
- */
159
- fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;
160
- }
161
- export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
162
- export declare type Attributes = Record<string, AttributeDefinition>;
1
+ import type { CmsContext, CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
2
+ export { CmsContext };
163
3
  export declare enum ENTITIES {
164
- SYSTEM = "CmsSystem",
165
- SETTINGS = "CmsSettings",
166
4
  GROUPS = "CmsGroups",
167
5
  MODELS = "CmsModels",
168
6
  ENTRIES = "CmsEntries",
169
7
  ENTRIES_ES = "CmsEntriesElasticsearch"
170
8
  }
171
- export interface TableModifier {
172
- (table: TableConstructor): TableConstructor;
173
- }
174
- export interface StorageOperationsFactoryParams {
175
- documentClient: DocumentClient;
176
- elasticsearch: Client;
177
- table?: TableModifier;
178
- esTable?: TableModifier;
179
- modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];
180
- attributes?: Record<ENTITIES, Attributes>;
181
- plugins?: Plugin[] | Plugin[][];
9
+ export interface DataLoadersHandlerInterfaceClearAllParams {
10
+ tenant: string;
182
11
  }
183
- export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
184
- getTable: () => Table;
185
- getEsTable: () => Table;
186
- getEntities: () => Record<"system" | "settings" | "groups" | "models" | "entries" | "entriesEs", Entity<any>>;
12
+ export interface DataLoadersHandlerDataLoaderParams {
13
+ model: Pick<CmsModel, "tenant" | "modelId">;
14
+ ids: readonly string[];
187
15
  }
188
- export interface StorageOperationsFactory {
189
- (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
16
+ export interface IDataLoadersHandler {
17
+ getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
18
+ getRevisionById<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
19
+ getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
20
+ getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
21
+ clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
190
22
  }
191
- export {};
package/types.js CHANGED
@@ -1,60 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ENTITIES = void 0;
7
-
8
- /**
9
- * Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
10
- *
11
- * @see ElasticsearchQueryBuilderValueSearchPlugin.transform
12
- */
13
-
14
- /**
15
- * A plugin definition for transforming the search value for Elasticsearch.
16
- *
17
- * @category Plugin
18
- * @category Elasticsearch
19
- */
20
-
21
- /**
22
- * A definition of the entry that is being prepared for the Elasticsearch.
23
- *
24
- * @category Elasticsearch
25
- * @category CmsEntry
26
- */
27
-
28
- /**
29
- * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.
30
- *
31
- * @category Elasticsearch
32
- * @category CmsEntry
33
- */
34
-
35
- /**
36
- * Arguments for the method that is transforming content entry from Elasticsearch into the original one.
37
- *
38
- * @category Elasticsearch
39
- * @category CmsEntry
40
- */
41
-
42
- /**
43
- * A plugin defining transformation of entry for Elasticsearch.
44
- *
45
- * @category Plugin
46
- * @category ContentModelField
47
- * @category CmsEntry
48
- * @category Elasticsearch
49
- */
50
- let ENTITIES;
51
- exports.ENTITIES = ENTITIES;
52
-
53
- (function (ENTITIES) {
54
- ENTITIES["SYSTEM"] = "CmsSystem";
55
- ENTITIES["SETTINGS"] = "CmsSettings";
56
- ENTITIES["GROUPS"] = "CmsGroups";
57
- ENTITIES["MODELS"] = "CmsModels";
58
- ENTITIES["ENTRIES"] = "CmsEntries";
59
- ENTITIES["ENTRIES_ES"] = "CmsEntriesElasticsearch";
60
- })(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
1
+ var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
2
+ ENTITIES["GROUPS"] = "CmsGroups";
3
+ ENTITIES["MODELS"] = "CmsModels";
4
+ ENTITIES["ENTRIES"] = "CmsEntries";
5
+ ENTITIES["ENTRIES_ES"] = "CmsEntriesElasticsearch";
6
+ return ENTITIES;
7
+ }({});
8
+ export { types_ENTITIES as ENTITIES };
9
+
10
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n CmsContext,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport { CmsContext };\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\n\nexport interface DataLoadersHandlerDataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\nexport interface IDataLoadersHandler {\n getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AASO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;;WAARA"}
@@ -1,12 +0,0 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- interface ElasticsearchConfig {
3
- index: string;
4
- }
5
- interface CmsElasticsearchParams {
6
- model: CmsModel;
7
- }
8
- interface Configurations {
9
- es: (params: CmsElasticsearchParams) => ElasticsearchConfig;
10
- }
11
- declare const configurations: Configurations;
12
- export default configurations;
package/configurations.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- const configurations = {
8
- es({
9
- model
10
- }) {
11
- const {
12
- tenant,
13
- locale
14
- } = model;
15
- const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
16
- const index = [sharedIndex ? "root" : tenant, "headless-cms", locale, model.modelId].join("-").toLowerCase();
17
- const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX;
18
-
19
- if (prefix) {
20
- return {
21
- index: prefix + index
22
- };
23
- }
24
-
25
- return {
26
- index
27
- };
28
- }
29
-
30
- };
31
- var _default = configurations;
32
- exports.default = _default;
@@ -1,8 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- export interface Params {
4
- table: Table;
5
- entityName: string;
6
- attributes: Attributes;
7
- }
8
- export declare const createEntryElasticsearchEntity: (params: Params) => Entity<any>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createEntryElasticsearchEntity = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _dynamodbToolbox = require("dynamodb-toolbox");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
- const createEntryElasticsearchEntity = params => {
19
- const {
20
- table,
21
- entityName,
22
- attributes
23
- } = params;
24
- return new _dynamodbToolbox.Entity({
25
- name: entityName,
26
- table,
27
- attributes: _objectSpread({
28
- PK: {
29
- type: "string",
30
- partitionKey: true
31
- },
32
- SK: {
33
- type: "string",
34
- sortKey: true
35
- },
36
- index: {
37
- type: "string"
38
- },
39
- data: {
40
- type: "map"
41
- }
42
- }, attributes || {})
43
- });
44
- };
45
-
46
- exports.createEntryElasticsearchEntity = createEntryElasticsearchEntity;
@@ -1,8 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- export interface Params {
4
- table: Table;
5
- entityName: string;
6
- attributes: Attributes;
7
- }
8
- export declare const createSettingsEntity: (params: Params) => Entity<any>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createSettingsEntity = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _dynamodbToolbox = require("dynamodb-toolbox");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
- const createSettingsEntity = params => {
19
- const {
20
- entityName,
21
- table,
22
- attributes
23
- } = params;
24
- return new _dynamodbToolbox.Entity({
25
- name: entityName,
26
- table,
27
- attributes: _objectSpread({
28
- PK: {
29
- partitionKey: true
30
- },
31
- SK: {
32
- sortKey: true
33
- },
34
- TYPE: {
35
- type: "string"
36
- },
37
- key: {
38
- type: "string"
39
- },
40
- uploadMinFileSize: {
41
- type: "number"
42
- },
43
- uploadMaxFileSize: {
44
- type: "number"
45
- },
46
- srcPrefix: {
47
- type: "string"
48
- },
49
- contentModelLastChange: {
50
- type: "string"
51
- },
52
- tenant: {
53
- type: "string"
54
- },
55
- locale: {
56
- type: "string"
57
- }
58
- }, attributes || {})
59
- });
60
- };
61
-
62
- exports.createSettingsEntity = createSettingsEntity;
@@ -1,8 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- export interface Params {
4
- table: Table;
5
- entityName: string;
6
- attributes: Attributes;
7
- }
8
- export declare const createSystemEntity: (params: Params) => Entity<any>;