@webiny/api-headless-cms-ddb-es 6.0.0-beta.0 → 6.0.0-rc.1

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 (285) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +4 -5
  3. package/configurations.js +12 -24
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -5
  6. package/definitions/entry.js +5 -174
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -6
  9. package/definitions/group.js +5 -58
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -6
  12. package/definitions/model.js +5 -102
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +59 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +2 -2
  18. package/dynamoDb/index.js +5 -14
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/storage/longText.js +11 -18
  21. package/dynamoDb/storage/longText.js.map +1 -1
  22. package/dynamoDb/storage/richText.d.ts +0 -5
  23. package/dynamoDb/storage/richText.js +25 -80
  24. package/dynamoDb/storage/richText.js.map +1 -1
  25. package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
  26. package/elasticsearch/createElasticsearchIndex.js +7 -15
  27. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  28. package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
  29. package/elasticsearch/deleteElasticsearchIndex.js +3 -10
  30. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  31. package/elasticsearch/index.d.ts +1 -1
  32. package/elasticsearch/index.js +3 -11
  33. package/elasticsearch/index.js.map +1 -1
  34. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  35. package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
  36. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  37. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  38. package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
  39. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  40. package/elasticsearch/indexing/index.d.ts +1 -1
  41. package/elasticsearch/indexing/index.js +8 -16
  42. package/elasticsearch/indexing/index.js.map +1 -1
  43. package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
  44. package/elasticsearch/indexing/jsonIndexing.js +1 -8
  45. package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
  46. package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
  47. package/elasticsearch/indexing/longTextIndexing.js +1 -8
  48. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  49. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  50. package/elasticsearch/indexing/numberIndexing.js +1 -8
  51. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  52. package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
  53. package/elasticsearch/indexing/objectIndexing.js +6 -13
  54. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  55. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  56. package/elasticsearch/indexing/richTextIndexing.js +1 -8
  57. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  58. package/elasticsearch/indices/base.d.ts +1 -1
  59. package/elasticsearch/indices/base.js +4 -10
  60. package/elasticsearch/indices/base.js.map +1 -1
  61. package/elasticsearch/indices/index.d.ts +1 -1
  62. package/elasticsearch/indices/index.js +3 -11
  63. package/elasticsearch/indices/index.js.map +1 -1
  64. package/elasticsearch/search/index.d.ts +1 -1
  65. package/elasticsearch/search/index.js +4 -10
  66. package/elasticsearch/search/index.js.map +1 -1
  67. package/elasticsearch/search/refSearch.d.ts +1 -1
  68. package/elasticsearch/search/refSearch.js +3 -10
  69. package/elasticsearch/search/refSearch.js.map +1 -1
  70. package/elasticsearch/search/searchableJson.d.ts +2 -0
  71. package/elasticsearch/search/searchableJson.js +53 -0
  72. package/elasticsearch/search/searchableJson.js.map +1 -0
  73. package/elasticsearch/search/timeSearch.d.ts +1 -1
  74. package/elasticsearch/search/timeSearch.js +3 -10
  75. package/elasticsearch/search/timeSearch.js.map +1 -1
  76. package/helpers/entryIndexHelpers.d.ts +10 -10
  77. package/helpers/entryIndexHelpers.js +32 -26
  78. package/helpers/entryIndexHelpers.js.map +1 -1
  79. package/helpers/fieldIdentifier.d.ts +1 -1
  80. package/helpers/fieldIdentifier.js +2 -10
  81. package/helpers/fieldIdentifier.js.map +1 -1
  82. package/helpers/index.d.ts +2 -2
  83. package/helpers/index.js +2 -27
  84. package/helpers/index.js.map +1 -1
  85. package/index.d.ts +2 -2
  86. package/index.js +108 -134
  87. package/index.js.map +1 -1
  88. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
  89. package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
  90. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  91. package/operations/entry/dataLoader/constants.js +1 -7
  92. package/operations/entry/dataLoader/constants.js.map +1 -1
  93. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  94. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  95. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  96. package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
  97. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  98. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  99. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
  100. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  101. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  102. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
  103. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  104. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  105. package/operations/entry/dataLoader/getRevisionById.js +23 -35
  106. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  107. package/operations/entry/dataLoader/index.d.ts +5 -5
  108. package/operations/entry/dataLoader/index.js +10 -31
  109. package/operations/entry/dataLoader/index.js.map +1 -1
  110. package/operations/entry/dataLoader/types.d.ts +3 -4
  111. package/operations/entry/dataLoader/types.js +1 -5
  112. package/operations/entry/dataLoader/types.js.map +1 -1
  113. package/operations/entry/dataLoaders.d.ts +13 -13
  114. package/operations/entry/dataLoaders.js +15 -25
  115. package/operations/entry/dataLoaders.js.map +1 -1
  116. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  117. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
  118. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  119. package/operations/entry/elasticsearch/body.d.ts +3 -3
  120. package/operations/entry/elasticsearch/body.js +21 -28
  121. package/operations/entry/elasticsearch/body.js.map +1 -1
  122. package/operations/entry/elasticsearch/fields.d.ts +3 -3
  123. package/operations/entry/elasticsearch/fields.js +110 -24
  124. package/operations/entry/elasticsearch/fields.js.map +1 -1
  125. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
  126. package/operations/entry/elasticsearch/filtering/applyFiltering.js +10 -17
  127. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  128. package/operations/entry/elasticsearch/filtering/exec.d.ts +7 -6
  129. package/operations/entry/elasticsearch/filtering/exec.js +48 -45
  130. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  131. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  132. package/operations/entry/elasticsearch/filtering/index.js +1 -16
  133. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  134. package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
  135. package/operations/entry/elasticsearch/filtering/path.js +9 -17
  136. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  137. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
  138. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
  139. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  140. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
  141. package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
  142. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
  143. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
  144. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
  145. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  146. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
  147. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +15 -16
  148. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  149. package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
  150. package/operations/entry/elasticsearch/filtering/populated.js +1 -8
  151. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  152. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  153. package/operations/entry/elasticsearch/filtering/values.js +4 -12
  154. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
  156. package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
  157. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  158. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
  159. package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
  160. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  161. package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
  162. package/operations/entry/elasticsearch/initialQuery.js +9 -26
  163. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  164. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  165. package/operations/entry/elasticsearch/keyword.js +4 -9
  166. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  167. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +4 -4
  168. package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
  169. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
  170. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
  171. package/operations/entry/elasticsearch/plugins/operator.js +4 -19
  172. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  173. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +4 -4
  174. package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
  175. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
  176. package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
  177. package/operations/entry/elasticsearch/plugins/search.js +5 -13
  178. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  179. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +4 -4
  180. package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
  181. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
  182. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  183. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -0
  184. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  185. package/operations/entry/elasticsearch/sort.d.ts +4 -4
  186. package/operations/entry/elasticsearch/sort.js +57 -33
  187. package/operations/entry/elasticsearch/sort.js.map +1 -1
  188. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
  189. package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
  190. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  191. package/operations/entry/elasticsearch/types.d.ts +5 -5
  192. package/operations/entry/elasticsearch/types.js +1 -5
  193. package/operations/entry/elasticsearch/types.js.map +1 -1
  194. package/operations/entry/index.d.ts +7 -6
  195. package/operations/entry/index.js +634 -735
  196. package/operations/entry/index.js.map +1 -1
  197. package/operations/entry/keys.d.ts +31 -1
  198. package/operations/entry/keys.js +56 -19
  199. package/operations/entry/keys.js.map +1 -1
  200. package/operations/entry/recordType.js +3 -12
  201. package/operations/entry/recordType.js.map +1 -1
  202. package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
  203. package/operations/entry/transformations/convertEntryKeys.js +2 -10
  204. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  205. package/operations/entry/transformations/index.d.ts +17 -17
  206. package/operations/entry/transformations/index.js +22 -30
  207. package/operations/entry/transformations/index.js.map +1 -1
  208. package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
  209. package/operations/entry/transformations/modifyEntryValues.js +1 -8
  210. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  211. package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
  212. package/operations/entry/transformations/transformEntryKeys.js +4 -11
  213. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  214. package/operations/entry/transformations/transformEntryToIndex.d.ts +7 -7
  215. package/operations/entry/transformations/transformEntryToIndex.js +3 -10
  216. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  217. package/operations/group/index.d.ts +6 -5
  218. package/operations/group/index.js +39 -73
  219. package/operations/group/index.js.map +1 -1
  220. package/operations/model/index.d.ts +4 -4
  221. package/operations/model/index.js +38 -57
  222. package/operations/model/index.js.map +1 -1
  223. package/package.json +29 -41
  224. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
  225. package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
  226. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
  227. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
  228. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
  229. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  230. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
  231. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
  232. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
  233. package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
  234. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  235. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -2
  236. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
  237. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  238. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
  239. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
  240. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  241. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
  242. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
  243. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  244. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
  245. package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
  246. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
  247. package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
  248. package/plugins/CmsEntryFilterPlugin.js +2 -9
  249. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  250. package/plugins/index.d.ts +8 -8
  251. package/plugins/index.js +8 -93
  252. package/plugins/index.js.map +1 -1
  253. package/tasks/createIndexTaskPlugin.d.ts +2 -2
  254. package/tasks/createIndexTaskPlugin.js +36 -62
  255. package/tasks/createIndexTaskPlugin.js.map +1 -1
  256. package/types.d.ts +28 -33
  257. package/types.js +5 -8
  258. package/types.js.map +1 -1
  259. package/values/NoValueContainer.d.ts +5 -0
  260. package/values/NoValueContainer.js +13 -0
  261. package/values/NoValueContainer.js.map +1 -0
  262. package/definitions/entryElasticsearch.d.ts +0 -8
  263. package/definitions/entryElasticsearch.js +0 -38
  264. package/definitions/entryElasticsearch.js.map +0 -1
  265. package/definitions/system.d.ts +0 -8
  266. package/definitions/system.js +0 -42
  267. package/definitions/system.js.map +0 -1
  268. package/definitions/table.d.ts +0 -8
  269. package/definitions/table.js +0 -25
  270. package/definitions/table.js.map +0 -1
  271. package/definitions/tableElasticsearch.d.ts +0 -8
  272. package/definitions/tableElasticsearch.js +0 -25
  273. package/definitions/tableElasticsearch.js.map +0 -1
  274. package/dynamoDb/storage/date.d.ts +0 -3
  275. package/dynamoDb/storage/date.js +0 -84
  276. package/dynamoDb/storage/date.js.map +0 -1
  277. package/elasticsearch/indices/japanese.d.ts +0 -2
  278. package/elasticsearch/indices/japanese.js +0 -14
  279. package/elasticsearch/indices/japanese.js.map +0 -1
  280. package/operations/system/index.d.ts +0 -6
  281. package/operations/system/index.js +0 -94
  282. package/operations/system/index.js.map +0 -1
  283. package/operations/system/indexes.d.ts +0 -10
  284. package/operations/system/indexes.js +0 -41
  285. package/operations/system/indexes.js.map +0 -1
package/index.js CHANGED
@@ -1,121 +1,90 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- createStorageOperations: true
9
- };
10
- exports.createStorageOperations = void 0;
11
- var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
12
- var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
13
- var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
14
- var _system = require("./operations/system");
15
- var _model = require("./operations/model");
16
- var _entry = require("./operations/entry");
17
- var _types = require("./types");
18
- var _table = require("./definitions/table");
19
- var _tableElasticsearch = require("./definitions/tableElasticsearch");
20
- var _group = require("./definitions/group");
21
- var _model2 = require("./definitions/model");
22
- var _entry2 = require("./definitions/entry");
23
- var _entryElasticsearch = require("./definitions/entryElasticsearch");
24
- var _system2 = require("./definitions/system");
25
- var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
26
- var _plugins = require("@webiny/plugins");
27
- var _group2 = require("./operations/group");
28
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
29
- var _indices = require("./elasticsearch/indices");
30
- var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
31
- var _plugins2 = require("./plugins");
32
- Object.keys(_plugins2).forEach(function (key) {
33
- if (key === "default" || key === "__esModule") return;
34
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
- if (key in exports && exports[key] === _plugins2[key]) return;
36
- Object.defineProperty(exports, key, {
37
- enumerable: true,
38
- get: function () {
39
- return _plugins2[key];
40
- }
41
- });
42
- });
43
- var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
44
- var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
45
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
46
- var _indexes = require("./operations/system/indexes");
47
- var _createIndexTaskPlugin = require("./tasks/createIndexTaskPlugin");
48
- const createStorageOperations = params => {
1
+ import dynamoDbValueFilters from "@webiny/db-dynamodb/plugins/filters/index.js";
2
+ import elasticsearchPlugins from "./elasticsearch/index.js";
3
+ import dynamoDbPlugins from "./dynamoDb/index.js";
4
+ import { createModelsStorageOperations } from "./operations/model/index.js";
5
+ import { createEntriesStorageOperations } from "./operations/entry/index.js";
6
+ import { ENTITIES } from "./types.js";
7
+ import { createGroupEntity } from "./definitions/group.js";
8
+ import { createModelEntity } from "./definitions/model.js";
9
+ import { createEntryEntity } from "./definitions/entry.js";
10
+ import { createElasticsearchIndex } from "./elasticsearch/createElasticsearchIndex.js";
11
+ import { PluginsContainer } from "@webiny/plugins";
12
+ import { createGroupsStorageOperations } from "./operations/group/index.js";
13
+ import { createElasticsearchEntity, createElasticsearchTable, ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
14
+ import { elasticsearchIndexPlugins } from "./elasticsearch/indices/index.js";
15
+ import { deleteElasticsearchIndex } from "./elasticsearch/deleteElasticsearchIndex.js";
16
+ import { CmsElasticsearchModelFieldPlugin, CmsEntryElasticsearchBodyModifierPlugin, CmsEntryElasticsearchFullTextSearchPlugin, CmsEntryElasticsearchIndexPlugin, CmsEntryElasticsearchQueryBuilderValueSearchPlugin, CmsEntryElasticsearchQueryModifierPlugin, CmsEntryElasticsearchSortModifierPlugin, CmsEntryElasticsearchValuesModifier } from "./plugins/index.js";
17
+ import { createFilterPlugins } from "./operations/entry/elasticsearch/filtering/plugins/index.js";
18
+ import { CmsEntryFilterPlugin } from "./plugins/CmsEntryFilterPlugin.js";
19
+ import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";
20
+ import { createCreateIndexTask } from "./tasks/createIndexTaskPlugin.js";
21
+ import { CompressorPlugin } from "@webiny/api";
22
+ import { ModelAfterCreateEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModel/index.js";
23
+ import { ModelAfterCreateFromEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js";
24
+ import { ModelAfterDeleteEventHandler } from "@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js";
25
+ import { createTable } from "@webiny/db-dynamodb";
26
+ export * from "./plugins/index.js";
27
+ export const createStorageOperations = params => {
49
28
  const {
50
- attributes,
51
29
  table,
52
30
  esTable,
53
31
  documentClient,
54
32
  elasticsearch,
55
33
  plugins: userPlugins
56
34
  } = params;
57
- const tableInstance = (0, _table.createTable)({
58
- table,
35
+ const tableInstance = createTable({
36
+ name: table || process.env.DB_TABLE,
59
37
  documentClient
60
38
  });
61
- const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
62
- table: esTable,
39
+ const tableElasticsearchInstance = createElasticsearchTable({
40
+ name: esTable,
63
41
  documentClient
64
42
  });
65
43
  const entities = {
66
- system: (0, _system2.createSystemEntity)({
67
- entityName: _types.ENTITIES.SYSTEM,
68
- table: tableInstance,
69
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
70
- }),
71
- groups: (0, _group.createGroupEntity)({
72
- entityName: _types.ENTITIES.GROUPS,
73
- table: tableInstance,
74
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
44
+ groups: createGroupEntity({
45
+ entityName: ENTITIES.GROUPS,
46
+ table: tableInstance
75
47
  }),
76
- models: (0, _model2.createModelEntity)({
77
- entityName: _types.ENTITIES.MODELS,
78
- table: tableInstance,
79
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
48
+ models: createModelEntity({
49
+ entityName: ENTITIES.MODELS,
50
+ table: tableInstance
80
51
  }),
81
- entries: (0, _entry2.createEntryEntity)({
82
- entityName: _types.ENTITIES.ENTRIES,
83
- table: tableInstance,
84
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
52
+ entries: createEntryEntity({
53
+ entityName: ENTITIES.ENTRIES,
54
+ table: tableInstance
85
55
  }),
86
- entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
87
- entityName: _types.ENTITIES.ENTRIES_ES,
88
- table: tableElasticsearchInstance,
89
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
56
+ entriesEs: createElasticsearchEntity({
57
+ entityName: ENTITIES.ENTRIES_ES,
58
+ table: tableElasticsearchInstance
90
59
  })
91
60
  };
92
- const plugins = new _plugins.PluginsContainer([
61
+ const plugins = new PluginsContainer([
93
62
  /**
94
63
  * DynamoDB filter plugins for the where conditions.
95
64
  */
96
- (0, _filters.default)(),
65
+ dynamoDbValueFilters(),
97
66
  /**
98
67
  * Field plugins for DynamoDB.
99
68
  */
100
- (0, _dynamoDb.default)(),
69
+ dynamoDbPlugins(),
101
70
  /**
102
71
  * Field plugins for Elasticsearch.
103
72
  */
104
- (0, _elasticsearch.default)(),
73
+ elasticsearchPlugins(),
105
74
  /**
106
75
  * Built-in Elasticsearch index templates.
107
76
  */
108
- (0, _indices.elasticsearchIndexPlugins)(),
77
+ elasticsearchIndexPlugins(),
109
78
  /**
110
79
  * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
111
80
  */
112
- (0, _plugins3.createFilterPlugins)(),
81
+ createFilterPlugins(),
113
82
  /**
114
83
  * User defined custom plugins.
115
84
  * They are at the end because we can then override existing plugins.
116
85
  */
117
86
  ...(userPlugins || [])]);
118
- const entries = (0, _entry.createEntriesStorageOperations)({
87
+ const entries = createEntriesStorageOperations({
119
88
  entity: entities.entries,
120
89
  esEntity: entities.entriesEs,
121
90
  plugins,
@@ -124,25 +93,39 @@ const createStorageOperations = params => {
124
93
  return {
125
94
  name: "dynamodb:elasticsearch",
126
95
  beforeInit: async context => {
96
+ context.db.registry.register({
97
+ item: entities.entries,
98
+ app: "cms",
99
+ tags: ["regular", entities.entries.name]
100
+ });
101
+ context.db.registry.register({
102
+ item: entities.entriesEs,
103
+ app: "cms",
104
+ tags: ["es", entities.entriesEs.name]
105
+ });
127
106
  /**
128
107
  * Attach the elasticsearch into context if it is not already attached.
129
108
  */
130
109
  if (!context.elasticsearch) {
131
110
  context.elasticsearch = elasticsearch;
132
111
  }
112
+
113
+ /**
114
+ * This registers the task implementation
115
+ */
116
+ createCreateIndexTask(context);
117
+
133
118
  /**
134
119
  * Pass the plugins to the parent context.
135
120
  */
136
- context.plugins.register([(0, _dynamoDb.default)(), (0, _createIndexTaskPlugin.createIndexTaskPluginTest)(), (0, _indices.elasticsearchIndexPlugins)()]);
121
+ context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);
137
122
  /**
138
123
  * We need to fetch all the plugin types in the list from the main container.
139
124
  * This way we do not need to register plugins in the storage plugins contains.
140
125
  */
141
- const types = [
142
- // Elasticsearch
143
- _apiElasticsearch.CompressionPlugin.type, _apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
126
+ const types = [ElasticsearchQueryBuilderOperatorPlugin.type,
144
127
  // Headless CMS
145
- "cms-model-field-to-graphql", _CmsEntryFilterPlugin.CmsEntryFilterPlugin.type, _plugins2.CmsEntryElasticsearchBodyModifierPlugin.type, _plugins2.CmsEntryElasticsearchFullTextSearchPlugin.type, _plugins2.CmsEntryElasticsearchIndexPlugin.type, _plugins2.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, _plugins2.CmsEntryElasticsearchQueryModifierPlugin.type, _plugins2.CmsEntryElasticsearchSortModifierPlugin.type, _plugins2.CmsElasticsearchModelFieldPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type, _plugins2.CmsEntryElasticsearchValuesModifier.type];
128
+ "cms-model-field-to-graphql", CmsEntryFilterPlugin.type, CmsEntryElasticsearchBodyModifierPlugin.type, CmsEntryElasticsearchFullTextSearchPlugin.type, CmsEntryElasticsearchIndexPlugin.type, CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, CmsEntryElasticsearchQueryModifierPlugin.type, CmsEntryElasticsearchSortModifierPlugin.type, CmsElasticsearchModelFieldPlugin.type, StorageOperationsCmsModelPlugin.type, StorageTransformPlugin.type, CmsEntryElasticsearchValuesModifier.type, CompressorPlugin.type];
146
129
  for (const type of types) {
147
130
  plugins.mergeByType(context.plugins, type);
148
131
  }
@@ -150,67 +133,58 @@ const createStorageOperations = params => {
150
133
  },
151
134
  init: async context => {
152
135
  /**
153
- * We need to create indexes on before model create and on clone (create from).
154
- * Other apps create indexes on locale creation.
136
+ * TODO @pavel
137
+ * Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.
155
138
  */
156
- await (0, _indexes.createElasticsearchIndexesOnLocaleAfterCreate)({
157
- context,
158
- client: elasticsearch,
159
- plugins
160
- });
161
- context.cms.onModelBeforeCreate.subscribe(async ({
162
- model
163
- }) => {
164
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
165
- client: elasticsearch,
166
- model,
167
- plugins
168
- });
169
- });
170
- context.cms.onModelBeforeCreateFrom.subscribe(async ({
171
- model
172
- }) => {
173
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
174
- client: elasticsearch,
175
- model,
176
- plugins
177
- });
178
- });
179
- context.cms.onModelAfterDelete.subscribe(async ({
180
- model
181
- }) => {
182
- await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
183
- client: elasticsearch,
184
- model
185
- });
186
- });
187
- context.cms.onModelInitialize.subscribe(async ({
188
- model
189
- }) => {
190
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
191
- client: elasticsearch,
192
- model,
193
- plugins
194
- });
195
- });
139
+ context.container.registerFactory(ModelAfterCreateEventHandler, () => ({
140
+ async handle(event) {
141
+ const {
142
+ model
143
+ } = event.payload;
144
+ await createElasticsearchIndex({
145
+ client: elasticsearch,
146
+ model,
147
+ plugins
148
+ });
149
+ }
150
+ }));
151
+ context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({
152
+ async handle(event) {
153
+ const {
154
+ model
155
+ } = event.payload;
156
+ await createElasticsearchIndex({
157
+ client: elasticsearch,
158
+ model,
159
+ plugins
160
+ });
161
+ }
162
+ }));
163
+ context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({
164
+ async handle(event) {
165
+ const {
166
+ model
167
+ } = event.payload;
168
+ await deleteElasticsearchIndex({
169
+ client: elasticsearch,
170
+ model
171
+ });
172
+ }
173
+ }));
196
174
  },
197
175
  getEntities: () => entities,
198
176
  getTable: () => tableInstance,
199
177
  getEsTable: () => tableElasticsearchInstance,
200
- system: (0, _system.createSystemStorageOperations)({
201
- entity: entities.system
202
- }),
203
- groups: (0, _group2.createGroupsStorageOperations)({
178
+ groups: createGroupsStorageOperations({
204
179
  entity: entities.groups,
205
180
  plugins
206
181
  }),
207
- models: (0, _model.createModelsStorageOperations)({
182
+ models: createModelsStorageOperations({
208
183
  entity: entities.models,
209
184
  elasticsearch
210
185
  }),
211
186
  entries
212
187
  };
213
188
  };
214
- exports.createStorageOperations = createStorageOperations;
215
189
 
216
190
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearch","_dynamoDb","_system","_model","_entry","_types","_table","_tableElasticsearch","_group","_model2","_entry2","_entryElasticsearch","_system2","_createElasticsearchIndex","_plugins","_group2","_apiElasticsearch","_indices","_deleteElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins3","_CmsEntryFilterPlugin","_apiHeadlessCms","_indexes","_createIndexTaskPlugin","createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","createEntriesStorageOperations","entity","esEntity","name","beforeInit","context","register","createIndexTaskPluginTest","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsElasticsearchModelFieldPlugin","StorageOperationsCmsModelPlugin","CmsEntryElasticsearchValuesModifier","mergeByType","dataLoaders","clearAll","init","createElasticsearchIndexesOnLocaleAfterCreate","client","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { createElasticsearchIndexesOnLocaleAfterCreate } from \"~/operations/system/indexes\";\nimport { createIndexTaskPluginTest } from \"~/tasks/createIndexTaskPlugin\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([\n dynamoDbPlugins(),\n createIndexTaskPluginTest(),\n elasticsearchIndexPlugins()\n ]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n CmsEntryElasticsearchValuesModifier.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n await createElasticsearchIndexesOnLocaleAfterCreate({\n context,\n client: elasticsearch,\n plugins\n });\n\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n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GAAG,CAACM,kBAAkB,CAACJ,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QAC1D,MAAM,IAAAI,kDAAwB,EAAC;UAC3BR,MAAM,EAAE1D,aAAa;UACrB8D;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;MAEF1B,OAAO,CAACuB,GAAG,CAACQ,iBAAiB,CAACN,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QACzD,MAAM,IAAAC,kDAAwB,EAAC;UAC3BL,MAAM,EAAE1D,aAAa;UACrB8D,KAAK;UACL7D;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC;IACDmE,WAAW,EAAEA,CAAA,KAAM7D,QAAQ;IAC3B8D,QAAQ,EAAEA,CAAA,KAAMlE,aAAa;IAC7BmE,UAAU,EAAEA,CAAA,KAAMjE,0BAA0B;IAC5CG,MAAM,EAAE,IAAA+D,qCAA6B,EAAC;MAClCvC,MAAM,EAAEzB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAA2D,qCAA6B,EAAC;MAClCxC,MAAM,EAAEzB,QAAQ,CAACM,MAAM;MACvBZ;IACJ,CAAC,CAAC;IACFe,MAAM,EAAE,IAAAyD,oCAA6B,EAAC;MAClCzC,MAAM,EAAEzB,QAAQ,CAACS,MAAM;MACvBhB;IACJ,CAAC,CAAC;IACFmB;EACJ,CAAC;AACL,CAAC;AAAClC,OAAA,CAAAS,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["dynamoDbValueFilters","elasticsearchPlugins","dynamoDbPlugins","createModelsStorageOperations","createEntriesStorageOperations","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","createElasticsearchIndex","PluginsContainer","createGroupsStorageOperations","createElasticsearchEntity","createElasticsearchTable","ElasticsearchQueryBuilderOperatorPlugin","elasticsearchIndexPlugins","deleteElasticsearchIndex","CmsElasticsearchModelFieldPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchValuesModifier","createFilterPlugins","CmsEntryFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","createCreateIndexTask","CompressorPlugin","ModelAfterCreateEventHandler","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","createTable","createStorageOperations","params","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","name","process","env","DB_TABLE","tableElasticsearchInstance","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entriesEs","ENTRIES_ES","entity","esEntity","beforeInit","context","db","registry","register","item","app","tags","types","type","mergeByType","dataLoaders","clearAll","init","container","registerFactory","handle","event","model","payload","client","getEntities","getTable","getEsTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport elasticsearchPlugins from \"./elasticsearch/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport type { StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport {\n createElasticsearchEntity,\n createElasticsearchTable,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices/index.js\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins/index.js\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins/index.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createCreateIndexTask } from \"~/tasks/createIndexTaskPlugin.js\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { createTable } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, esTable, documentClient, elasticsearch, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n\n /**\n * This registers the task implementation\n */\n createCreateIndexTask(context);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CmsEntryElasticsearchValuesModifier.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * TODO @pavel\n * Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.\n */\n context.container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n }\n }));\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,oBAAoB;AAC3B,OAAOC,eAAe;AACtB,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AAEvC,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,6BAA6B;AACtC,SACIC,yBAAyB,EACzBC,wBAAwB,EACxBC,uCAAuC,QACpC,2BAA2B;AAClC,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;AACjC,SACIC,gCAAgC,EAChCC,uCAAuC,EACvCC,yCAAyC,EACzCC,gCAAgC,EAChCC,kDAAkD,EAClDC,wCAAwC,EACxCC,uCAAuC,EACvCC,mCAAmC;AAEvC,SAASC,mBAAmB;AAC5B,SAASC,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AAK;YACLtC;UACJ,CAAC,CAAC;QACN;MACJ,CAAC,CAAC,CAAC;MAEHqB,OAAO,CAACa,SAAS,CAACC,eAAe,CAAC3C,4BAA4B,EAAE,OAAO;QACnE,MAAM4C,MAAMA,CAACC,KAAK,EAAE;UAChB,MAAM;YAAEC;UAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;UAC/B,MAAMhE,wBAAwB,CAAC;YAC3BiE,MAAM,EAAEzC,aAAa;YACrBuC;UACJ,CAAC,CAAC;QACN;MACJ,CAAC,CAAC,CAAC;IACP,CAAC;IACDG,WAAW,EAAEA,CAAA,KAAMjC,QAAQ;IAC3BkC,QAAQ,EAAEA,CAAA,KAAMxC,aAAa;IAC7ByC,UAAU,EAAEA,CAAA,KAAMpC,0BAA0B;IAC5CE,MAAM,EAAEvC,6BAA6B,CAAC;MAClCgD,MAAM,EAAEV,QAAQ,CAACC,MAAM;MACvBT;IACJ,CAAC,CAAC;IACFY,MAAM,EAAElD,6BAA6B,CAAC;MAClCwD,MAAM,EAAEV,QAAQ,CAACI,MAAM;MACvBb;IACJ,CAAC,CAAC;IACFe;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,12 +1,10 @@
1
- import DataLoader from "dataloader";
1
+ import type DataLoader from "dataloader";
2
2
  export interface CacheKeyParams {
3
3
  name: string;
4
4
  tenant: string;
5
- locale: string;
6
5
  }
7
6
  export interface ClearAllParams {
8
7
  tenant: string;
9
- locale: string;
10
8
  }
11
9
  export declare class DataLoaderCache {
12
10
  private readonly cache;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DataLoaderCache = void 0;
7
- class DataLoaderCache {
1
+ export class DataLoaderCache {
8
2
  cache = {};
9
3
  getDataLoader(params) {
10
4
  const key = this.createKey(params);
@@ -33,9 +27,8 @@ class DataLoaderCache {
33
27
  }
34
28
  }
35
29
  createKey(params) {
36
- return `${params.tenant}_${params.locale}_${params.name}`;
30
+ return `${params.tenant}_${params.name}`;
37
31
  }
38
32
  }
39
- exports.DataLoaderCache = DataLoaderCache;
40
33
 
41
34
  //# sourceMappingURL=DataLoaderCache.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAQ,GAAEA,MAAM,CAACS,MAAO,IAAGT,MAAM,CAACU,MAAO,IAAGV,MAAM,CAACO,IAAK,EAAC;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.name}`;\n }\n}\n"],"mappings":"AAWA,OAAO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACO,IAAI,EAAE;EAC5C;AACJ","ignoreList":[]}
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
1
  const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
8
- const CMS_ENTRY_BATCH_SCHEDULE_WAIT = exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
2
+ export const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
9
3
 
10
4
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["batchScheduleWaitEnv","Number","process","env","WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT","CMS_ENTRY_BATCH_SCHEDULE_WAIT","exports","isNaN"],"sources":["constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"mappings":";;;;;;AAAA,MAAMA,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,wCAAwC,IAAI,GAAG,CAAC;AACzF,MAAMC,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAGE,KAAK,CAACP,oBAAoB,CAAC,GAAG,CAAC,GAAGA,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["batchScheduleWaitEnv","Number","process","env","WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"sources":["constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"mappings":"AAAA,MAAMA,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,wCAAwC,IAAI,GAAG,CAAC;AAChG,OAAO,MAAMC,6BAA6B,GAAGC,KAAK,CAACN,oBAAoB,CAAC,GAAG,CAAC,GAAGA,oBAAoB","ignoreList":[]}
@@ -1,10 +1,5 @@
1
- "use strict";
1
+ import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBatchScheduleFn = void 0;
7
- var _constants = require("./constants");
8
3
  /**
9
4
  * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
10
5
  * Intended to be used internally or for a specific user case.
@@ -12,14 +7,13 @@ var _constants = require("./constants");
12
7
  *
13
8
  * https://github.com/graphql/dataloader#batch-scheduling
14
9
  */
15
- const createBatchScheduleFn = () => {
16
- if (_constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
10
+ export const createBatchScheduleFn = () => {
11
+ if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
17
12
  return undefined;
18
13
  }
19
14
  return callback => {
20
- setTimeout(callback, _constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT);
15
+ setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
21
16
  };
22
17
  };
23
- exports.createBatchScheduleFn = createBatchScheduleFn;
24
18
 
25
19
  //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","undefined","callback","setTimeout","exports"],"sources":["createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,IAAIC,wCAA6B,IAAI,CAAC,EAAE;IACpC,OAAOC,SAAS;EACpB;EACA,OAAQC,QAAoB,IAAK;IAC7BC,UAAU,CAACD,QAAQ,EAAEF,wCAA6B,CAAC;EACvD,CAAC;AACL,CAAC;AAACI,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CMS_ENTRY_BATCH_SCHEDULE_WAIT","createBatchScheduleFn","undefined","callback","setTimeout"],"sources":["createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants.js\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"mappings":"AAAA,SAASA,6BAA6B;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,IAAID,6BAA6B,IAAI,CAAC,EAAE;IACpC,OAAOE,SAAS;EACpB;EACA,OAAQC,QAAoB,IAAK;IAC7BC,UAAU,CAACD,QAAQ,EAAEH,6BAA6B,CAAC;EACvD,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import { DataLoaderParams } from "./types";
4
- export declare const createGetAllEntryRevisions: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetAllEntryRevisions: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -1,45 +1,32 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createGetAllEntryRevisions = void 0;
8
- var _dataloader = _interopRequireDefault(require("dataloader"));
9
- var _query = require("@webiny/db-dynamodb/utils/query");
10
- var _keys = require("../keys");
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- var _createBatchScheduleFn = require("./createBatchScheduleFn");
13
- const createGetAllEntryRevisions = params => {
1
+ import DataLoader from "dataloader";
2
+ import { createPartitionKey } from "../keys.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ export const createGetAllEntryRevisions = params => {
14
5
  const {
15
6
  entity,
16
- locale,
17
7
  tenant
18
8
  } = params;
19
- return new _dataloader.default(async ids => {
9
+ return new DataLoader(async ids => {
20
10
  const results = {};
21
11
  for (const id of ids) {
22
- const queryAllParams = {
23
- entity,
24
- partitionKey: (0, _keys.createPartitionKey)({
12
+ results[id] = (await entity.queryAllClean({
13
+ partitionKey: createPartitionKey({
25
14
  tenant,
26
- locale,
27
15
  id
28
16
  }),
29
17
  options: {
30
18
  beginsWith: "REV#"
31
19
  }
32
- };
33
- const items = await (0, _query.queryAll)(queryAllParams);
34
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
20
+ })).map(item => {
21
+ return item.data;
22
+ });
35
23
  }
36
24
  return ids.map(entryId => {
37
25
  return results[entryId] || [];
38
26
  });
39
27
  }, {
40
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
28
+ batchScheduleFn: createBatchScheduleFn()
41
29
  });
42
30
  };
43
- exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
44
31
 
45
32
  //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_query","_keys","_cleanup","_createBatchScheduleFn","createGetAllEntryRevisions","params","entity","locale","tenant","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","entryId","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { createPartitionKey } from \"~/operations/entry/keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { DataLoaderParams } from \"./types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetAllEntryRevisions = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(entryId => {\n return results[entryId] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAEO,MAAMK,0BAA0B,GAAIC,MAAwB,IAAK;EACpE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCP,MAAM;QACNQ,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BP,MAAM;UACND,MAAM;UACNK;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAkBN,cAAc,CAAC;MAC7DF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACd,MAAM,EAAEY,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACC,OAAO,IAAI;MACtB,OAAOX,OAAO,CAACW,OAAO,CAAC,IAAI,EAAE;IACjC,CAAC,CAAC;EACN,CAAC,EACD;IACIC,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAArB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","item","data","entryId","batchScheduleFn"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(item => {\n return item.data;\n });\n }\n\n return ids.map(entryId => {\n return results[entryId] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,IAAIJ,UAAU,CACjB,MAAMO,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAMJ,MAAM,CAACK,aAAa,CAAC;QACvBC,YAAY,EAAEV,kBAAkB,CAAC;UAC7BK,MAAM;UACNG;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,IAAI,IAAI;QACV,OAAOA,IAAI,CAACC,IAAI;MACpB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACG,OAAO,IAAI;MACtB,OAAOT,OAAO,CAACS,OAAO,CAAC,IAAI,EAAE;IACjC,CAAC,CAAC;EACN,CAAC,EACD;IACIC,eAAe,EAAEhB,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import { DataLoaderParams } from "./types";
4
- export declare const createGetLatestRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetLatestRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;