@webiny/api-headless-cms-ddb-es 0.0.0-ee-vpcs.549378cf03

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/configurations.d.ts +12 -0
  4. package/configurations.js +43 -0
  5. package/configurations.js.map +1 -0
  6. package/definitions/entry.d.ts +8 -0
  7. package/definitions/entry.js +90 -0
  8. package/definitions/entry.js.map +1 -0
  9. package/definitions/entryElasticsearch.d.ts +8 -0
  10. package/definitions/entryElasticsearch.js +42 -0
  11. package/definitions/entryElasticsearch.js.map +1 -0
  12. package/definitions/group.d.ts +8 -0
  13. package/definitions/group.js +70 -0
  14. package/definitions/group.js.map +1 -0
  15. package/definitions/model.d.ts +8 -0
  16. package/definitions/model.js +97 -0
  17. package/definitions/model.js.map +1 -0
  18. package/definitions/settings.d.ts +8 -0
  19. package/definitions/settings.js +58 -0
  20. package/definitions/settings.js.map +1 -0
  21. package/definitions/system.d.ts +8 -0
  22. package/definitions/system.js +46 -0
  23. package/definitions/system.js.map +1 -0
  24. package/definitions/table.d.ts +8 -0
  25. package/definitions/table.js +24 -0
  26. package/definitions/table.js.map +1 -0
  27. package/definitions/tableElasticsearch.d.ts +8 -0
  28. package/definitions/tableElasticsearch.js +24 -0
  29. package/definitions/tableElasticsearch.js.map +1 -0
  30. package/dynamoDb/index.d.ts +2 -0
  31. package/dynamoDb/index.js +16 -0
  32. package/dynamoDb/index.js.map +1 -0
  33. package/dynamoDb/storage/date.d.ts +3 -0
  34. package/dynamoDb/storage/date.js +99 -0
  35. package/dynamoDb/storage/date.js.map +1 -0
  36. package/dynamoDb/storage/longText.d.ts +10 -0
  37. package/dynamoDb/storage/longText.js +108 -0
  38. package/dynamoDb/storage/longText.js.map +1 -0
  39. package/dynamoDb/storage/richText.d.ts +7 -0
  40. package/dynamoDb/storage/richText.js +128 -0
  41. package/dynamoDb/storage/richText.js.map +1 -0
  42. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  43. package/elasticsearch/createElasticsearchIndex.js +60 -0
  44. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  45. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  46. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  47. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  48. package/elasticsearch/index.d.ts +2 -0
  49. package/elasticsearch/index.js +16 -0
  50. package/elasticsearch/index.js.map +1 -0
  51. package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
  52. package/elasticsearch/indexing/dateTimeIndexing.js +103 -0
  53. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
  55. package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
  56. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/index.d.ts +2 -0
  58. package/elasticsearch/indexing/index.js +24 -0
  59. package/elasticsearch/indexing/index.js.map +1 -0
  60. package/elasticsearch/indexing/longTextIndexing.d.ts +7 -0
  61. package/elasticsearch/indexing/longTextIndexing.js +52 -0
  62. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
  64. package/elasticsearch/indexing/numberIndexing.js +48 -0
  65. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  66. package/elasticsearch/indexing/objectIndexing.d.ts +12 -0
  67. package/elasticsearch/indexing/objectIndexing.js +223 -0
  68. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  69. package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
  70. package/elasticsearch/indexing/richTextIndexing.js +34 -0
  71. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  72. package/elasticsearch/indices/base.d.ts +2 -0
  73. package/elasticsearch/indices/base.js +15 -0
  74. package/elasticsearch/indices/base.js.map +1 -0
  75. package/elasticsearch/indices/index.d.ts +1 -0
  76. package/elasticsearch/indices/index.js +16 -0
  77. package/elasticsearch/indices/index.js.map +1 -0
  78. package/elasticsearch/indices/japanese.d.ts +2 -0
  79. package/elasticsearch/indices/japanese.js +16 -0
  80. package/elasticsearch/indices/japanese.js.map +1 -0
  81. package/elasticsearch/search/index.d.ts +3 -0
  82. package/elasticsearch/search/index.js +14 -0
  83. package/elasticsearch/search/index.js.map +1 -0
  84. package/elasticsearch/search/refSearch.d.ts +2 -0
  85. package/elasticsearch/search/refSearch.js +35 -0
  86. package/elasticsearch/search/refSearch.js.map +1 -0
  87. package/elasticsearch/search/timeSearch.d.ts +2 -0
  88. package/elasticsearch/search/timeSearch.js +33 -0
  89. package/elasticsearch/search/timeSearch.js.map +1 -0
  90. package/helpers/entryIndexHelpers.d.ts +18 -0
  91. package/helpers/entryIndexHelpers.js +204 -0
  92. package/helpers/entryIndexHelpers.js.map +1 -0
  93. package/helpers/index.d.ts +1 -0
  94. package/helpers/index.js +18 -0
  95. package/helpers/index.js.map +1 -0
  96. package/index.d.ts +3 -0
  97. package/index.js +275 -0
  98. package/index.js.map +1 -0
  99. package/operations/entry/dataLoaders.d.ts +51 -0
  100. package/operations/entry/dataLoaders.js +365 -0
  101. package/operations/entry/dataLoaders.js.map +1 -0
  102. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  103. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  104. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  105. package/operations/entry/elasticsearch/body.d.ts +13 -0
  106. package/operations/entry/elasticsearch/body.js +162 -0
  107. package/operations/entry/elasticsearch/body.js.map +1 -0
  108. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  109. package/operations/entry/elasticsearch/fields.js +248 -0
  110. package/operations/entry/elasticsearch/fields.js.map +1 -0
  111. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  112. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  113. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  114. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  115. package/operations/entry/elasticsearch/filtering/exec.js +215 -0
  116. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  117. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  118. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  119. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  120. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  121. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  122. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  127. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  128. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  129. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  130. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  131. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  132. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  133. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  134. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  135. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  136. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  137. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  139. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  140. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  141. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  142. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  143. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  144. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  145. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  146. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  147. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  148. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  149. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  150. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  151. package/operations/entry/elasticsearch/keyword.js +38 -0
  152. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  153. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  154. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  155. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  156. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  157. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  158. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  159. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  160. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  161. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  162. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  163. package/operations/entry/elasticsearch/plugins/search.js +30 -0
  164. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  165. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  166. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  167. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  168. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  169. package/operations/entry/elasticsearch/sort.js +92 -0
  170. package/operations/entry/elasticsearch/sort.js.map +1 -0
  171. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  172. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  173. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  174. package/operations/entry/elasticsearch/types.d.ts +41 -0
  175. package/operations/entry/elasticsearch/types.js +5 -0
  176. package/operations/entry/elasticsearch/types.js.map +1 -0
  177. package/operations/entry/elasticsearchFields.d.ts +2 -0
  178. package/operations/entry/elasticsearchFields.js +38 -0
  179. package/operations/entry/elasticsearchFields.js.map +1 -0
  180. package/operations/entry/index.d.ts +11 -0
  181. package/operations/entry/index.js +1251 -0
  182. package/operations/entry/index.js.map +1 -0
  183. package/operations/entry/keys.d.ts +12 -0
  184. package/operations/entry/keys.js +40 -0
  185. package/operations/entry/keys.js.map +1 -0
  186. package/operations/entry/recordType.d.ts +3 -0
  187. package/operations/entry/recordType.js +24 -0
  188. package/operations/entry/recordType.js.map +1 -0
  189. package/operations/group/index.d.ts +8 -0
  190. package/operations/group/index.js +195 -0
  191. package/operations/group/index.js.map +1 -0
  192. package/operations/model/index.d.ts +8 -0
  193. package/operations/model/index.js +204 -0
  194. package/operations/model/index.js.map +1 -0
  195. package/operations/settings/index.d.ts +6 -0
  196. package/operations/settings/index.js +135 -0
  197. package/operations/settings/index.js.map +1 -0
  198. package/operations/system/index.d.ts +6 -0
  199. package/operations/system/index.js +99 -0
  200. package/operations/system/index.js.map +1 -0
  201. package/package.json +68 -0
  202. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +20 -0
  203. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
  204. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
  206. package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
  207. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  209. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  210. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  211. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  212. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  213. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  214. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
  215. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
  216. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  217. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
  218. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
  219. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  220. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  221. package/plugins/CmsEntryFilterPlugin.js +31 -0
  222. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  223. package/plugins/index.d.ts +6 -0
  224. package/plugins/index.js +83 -0
  225. package/plugins/index.js.map +1 -0
  226. package/types.d.ts +164 -0
  227. package/types.js +47 -0
  228. package/types.js.map +1 -0
package/index.js ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ var _exportNames = {
9
+ createStorageOperations: true
10
+ };
11
+ exports.createStorageOperations = void 0;
12
+
13
+ var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
14
+
15
+ var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
16
+
17
+ var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
18
+
19
+ var _settings = require("./operations/settings");
20
+
21
+ var _system = require("./operations/system");
22
+
23
+ var _model = require("./operations/model");
24
+
25
+ var _entry = require("./operations/entry");
26
+
27
+ var _types = require("./types");
28
+
29
+ var _table = require("./definitions/table");
30
+
31
+ var _tableElasticsearch = require("./definitions/tableElasticsearch");
32
+
33
+ var _group = require("./definitions/group");
34
+
35
+ var _model2 = require("./definitions/model");
36
+
37
+ var _entry2 = require("./definitions/entry");
38
+
39
+ var _entryElasticsearch = require("./definitions/entryElasticsearch");
40
+
41
+ var _system2 = require("./definitions/system");
42
+
43
+ var _settings2 = require("./definitions/settings");
44
+
45
+ var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
46
+
47
+ var _plugins = require("@webiny/plugins");
48
+
49
+ var _group2 = require("./operations/group");
50
+
51
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
52
+
53
+ var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
54
+
55
+ var _indices = require("./elasticsearch/indices");
56
+
57
+ var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
58
+
59
+ var _plugins2 = require("./plugins");
60
+
61
+ Object.keys(_plugins2).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
+ if (key in exports && exports[key] === _plugins2[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _plugins2[key];
69
+ }
70
+ });
71
+ });
72
+
73
+ var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
74
+
75
+ const createStorageOperations = params => {
76
+ const {
77
+ attributes,
78
+ table,
79
+ esTable,
80
+ documentClient,
81
+ elasticsearch,
82
+ plugins: userPlugins
83
+ } = params;
84
+ const tableInstance = (0, _table.createTable)({
85
+ table,
86
+ documentClient
87
+ });
88
+ const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
89
+ table: esTable,
90
+ documentClient
91
+ });
92
+ const entities = {
93
+ settings: (0, _settings2.createSettingsEntity)({
94
+ entityName: _types.ENTITIES.SETTINGS,
95
+ table: tableInstance,
96
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
97
+ }),
98
+ system: (0, _system2.createSystemEntity)({
99
+ entityName: _types.ENTITIES.SYSTEM,
100
+ table: tableInstance,
101
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
102
+ }),
103
+ groups: (0, _group.createGroupEntity)({
104
+ entityName: _types.ENTITIES.GROUPS,
105
+ table: tableInstance,
106
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
107
+ }),
108
+ models: (0, _model2.createModelEntity)({
109
+ entityName: _types.ENTITIES.MODELS,
110
+ table: tableInstance,
111
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
112
+ }),
113
+ entries: (0, _entry2.createEntryEntity)({
114
+ entityName: _types.ENTITIES.ENTRIES,
115
+ table: tableInstance,
116
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
117
+ }),
118
+ entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
119
+ entityName: _types.ENTITIES.ENTRIES_ES,
120
+ table: tableElasticsearchInstance,
121
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
122
+ })
123
+ };
124
+ const plugins = new _plugins.PluginsContainer([
125
+ /**
126
+ * Plugins of type CmsModelFieldToGraphQLPlugin.
127
+ */
128
+
129
+ /**
130
+ * Elasticsearch field definitions for the entry record.
131
+ */
132
+ _elasticsearchFields.elasticsearchFields,
133
+ /**
134
+ * DynamoDB filter plugins for the where conditions.
135
+ */
136
+ (0, _filters.default)(),
137
+ /**
138
+ * Elasticsearch operators.
139
+ */
140
+ (0, _apiElasticsearch.getElasticsearchOperators)(),
141
+ /**
142
+ * Field plugins for DynamoDB.
143
+ */
144
+ (0, _dynamoDb.default)(),
145
+ /**
146
+ * Field plugins for Elasticsearch.
147
+ */
148
+ (0, _elasticsearch.default)(),
149
+ /**
150
+ * Built-in Elasticsearch index templates.
151
+ */
152
+ (0, _indices.elasticsearchIndexPlugins)(),
153
+ /**
154
+ * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
155
+ */
156
+ (0, _plugins3.createFilterPlugins)(),
157
+ /**
158
+ * User defined custom plugins.
159
+ * They are at the end because we can then override existing plugins.
160
+ */
161
+ ...(userPlugins || [])]);
162
+ return {
163
+ name: "dynamodb:elasticsearch",
164
+ beforeInit: async context => {
165
+ /**
166
+ * Attach the elasticsearch into context if it is not already attached.
167
+ */
168
+ if (!context.elasticsearch) {
169
+ context.elasticsearch = elasticsearch;
170
+ }
171
+ /**
172
+ * Pass the plugins to the parent context.
173
+ */
174
+
175
+
176
+ context.plugins.register([(0, _dynamoDb.default)()]);
177
+ /**
178
+ * Collect all required plugins from parent context.
179
+ */
180
+
181
+ const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
182
+ plugins.register(fieldPlugins);
183
+ /**
184
+ * We need to get all the operator plugins from the main plugin container.
185
+ */
186
+
187
+ const elasticsearchOperatorPlugins = context.plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type);
188
+ plugins.register(elasticsearchOperatorPlugins);
189
+ /**
190
+ * We need to get all the query modifier plugins
191
+ */
192
+
193
+ const queryModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchQueryModifierPlugin.type);
194
+ plugins.register(queryModifierPlugins);
195
+ /**
196
+ * We need to get all the sort modifier plugins
197
+ */
198
+
199
+ const sortModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchSortModifierPlugin.type);
200
+ plugins.register(sortModifierPlugins);
201
+ /**
202
+ * We need to get all the body modifier plugins
203
+ */
204
+
205
+ const bodyModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchBodyModifierPlugin.type);
206
+ plugins.register(bodyModifierPlugins);
207
+ },
208
+ init: async context => {
209
+ /**
210
+ * We need to create indexes on before model create and on clone (create from).
211
+ * Other apps create indexes on locale creation.
212
+ */
213
+ context.cms.onModelBeforeCreate.subscribe(async ({
214
+ model
215
+ }) => {
216
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
217
+ elasticsearch,
218
+ model,
219
+ plugins
220
+ });
221
+ });
222
+ context.cms.onModelBeforeCreateFrom.subscribe(async ({
223
+ model
224
+ }) => {
225
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
226
+ elasticsearch,
227
+ model,
228
+ plugins
229
+ });
230
+ });
231
+ context.cms.onModelAfterDelete.subscribe(async ({
232
+ model
233
+ }) => {
234
+ await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
235
+ elasticsearch,
236
+ model
237
+ });
238
+ });
239
+ context.cms.onModelInitialize.subscribe(async ({
240
+ model
241
+ }) => {
242
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
243
+ elasticsearch,
244
+ model,
245
+ plugins
246
+ });
247
+ });
248
+ },
249
+ getEntities: () => entities,
250
+ getTable: () => tableInstance,
251
+ getEsTable: () => tableElasticsearchInstance,
252
+ system: (0, _system.createSystemStorageOperations)({
253
+ entity: entities.system
254
+ }),
255
+ settings: (0, _settings.createSettingsStorageOperations)({
256
+ entity: entities.settings
257
+ }),
258
+ groups: (0, _group2.createGroupsStorageOperations)({
259
+ entity: entities.groups,
260
+ plugins
261
+ }),
262
+ models: (0, _model.createModelsStorageOperations)({
263
+ entity: entities.models,
264
+ elasticsearch
265
+ }),
266
+ entries: (0, _entry.createEntriesStorageOperations)({
267
+ entity: entities.entries,
268
+ esEntity: entities.entriesEs,
269
+ plugins,
270
+ elasticsearch
271
+ })
272
+ };
273
+ };
274
+
275
+ exports.createStorageOperations = createStorageOperations;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","cmsEntryElasticsearchFields","dynamoDbValueFilters","getElasticsearchOperators","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","name","beforeInit","context","register","fieldPlugins","byType","elasticsearchOperatorPlugins","ElasticsearchQueryBuilderOperatorPlugin","type","queryModifierPlugins","CmsEntryElasticsearchQueryModifierPlugin","sortModifierPlugins","CmsEntryElasticsearchSortModifierPlugin","bodyModifierPlugins","CmsEntryElasticsearchBodyModifierPlugin","init","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\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 { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugin,\n getElasticsearchOperators\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchFields as cmsEntryElasticsearchFields } from \"~/operations/entry/elasticsearchFields\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport {\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\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 settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\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 * Plugins of type CmsModelFieldToGraphQLPlugin.\n */\n /**\n * Elasticsearch field definitions for the entry record.\n */\n cmsEntryElasticsearchFields,\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\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 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([dynamoDbPlugins()]);\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n /**\n * We need to get all the operator plugins from the main plugin container.\n */\n const elasticsearchOperatorPlugins =\n context.plugins.byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n );\n plugins.register(elasticsearchOperatorPlugins);\n /**\n * We need to get all the query modifier plugins\n */\n const queryModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n );\n plugins.register(queryModifierPlugins);\n /**\n * We need to get all the sort modifier plugins\n */\n const sortModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n );\n plugins.register(sortModifierPlugins);\n /**\n * We need to get all the body modifier plugins\n */\n const bodyModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n );\n plugins.register(bodyModifierPlugins);\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 context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n 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 settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AAOA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAFA;;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UADE;IAEFC,KAFE;IAGFC,OAHE;IAIFC,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;UAE3BuD;QAF2B,CAAzB,CAAN;MAIH,CALD;MAOAjB,OAAO,CAACc,GAAR,CAAYQ,iBAAZ,CAA8BN,SAA9B,CAAwC,OAAO;QAAEC;MAAF,CAAP,KAAqB;QACzD,MAAM,IAAAC,kDAAA,EAAyB;UAC3BxD,aAD2B;UAE3BuD,KAF2B;UAG3BtD;QAH2B,CAAzB,CAAN;MAKH,CAND;IAOH,CAtFE;IAuFH4D,WAAW,EAAE,MAAMtD,QAvFhB;IAwFHuD,QAAQ,EAAE,MAAM3D,aAxFb;IAyFH4D,UAAU,EAAE,MAAM1D,0BAzFf;IA0FHQ,MAAM,EAAE,IAAAmD,qCAAA,EAA8B;MAClCC,MAAM,EAAE1D,QAAQ,CAACM;IADiB,CAA9B,CA1FL;IA6FHL,QAAQ,EAAE,IAAA0D,yCAAA,EAAgC;MACtCD,MAAM,EAAE1D,QAAQ,CAACC;IADqB,CAAhC,CA7FP;IAgGHQ,MAAM,EAAE,IAAAmD,qCAAA,EAA8B;MAClCF,MAAM,EAAE1D,QAAQ,CAACS,MADiB;MAElCf;IAFkC,CAA9B,CAhGL;IAoGHkB,MAAM,EAAE,IAAAiD,oCAAA,EAA8B;MAClCH,MAAM,EAAE1D,QAAQ,CAACY,MADiB;MAElCnB;IAFkC,CAA9B,CApGL;IAwGHsB,OAAO,EAAE,IAAA+C,qCAAA,EAA+B;MACpCJ,MAAM,EAAE1D,QAAQ,CAACe,OADmB;MAEpCgD,QAAQ,EAAE/D,QAAQ,CAACkB,SAFiB;MAGpCxB,OAHoC;MAIpCD;IAJoC,CAA/B;EAxGN,CAAP;AA+GH,CA1MM"}
@@ -0,0 +1,51 @@
1
+ import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
+ import { Entity } from "dynamodb-toolbox";
3
+ export interface GetAllEntryRevisionsParams {
4
+ ids: readonly string[];
5
+ model: CmsModel;
6
+ }
7
+ export interface GetRevisionByIdParams {
8
+ ids: readonly string[];
9
+ model: CmsModel;
10
+ }
11
+ export interface GetPublishedRevisionByEntryIdParams {
12
+ ids: readonly string[];
13
+ model: CmsModel;
14
+ }
15
+ export interface GetLatestRevisionByEntryIdParams {
16
+ ids: readonly string[];
17
+ model: CmsModel;
18
+ }
19
+ interface ClearLoaderParams {
20
+ model: CmsModel;
21
+ entry?: CmsEntry;
22
+ }
23
+ export interface DataLoadersHandlerParams {
24
+ entity: Entity<any>;
25
+ }
26
+ export declare class DataLoadersHandler {
27
+ private readonly loaders;
28
+ private readonly entity;
29
+ constructor(params: DataLoadersHandlerParams);
30
+ getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]>;
31
+ clearAllEntryRevisions(params: ClearLoaderParams): void;
32
+ getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]>;
33
+ clearRevisionById(params: ClearLoaderParams): void;
34
+ getPublishedRevisionByEntryId(params: GetPublishedRevisionByEntryIdParams): Promise<CmsEntry[]>;
35
+ clearPublishedRevisionByEntryId(params: ClearLoaderParams): void;
36
+ getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsEntry[]>;
37
+ clearLatestRevisionByEntryId(params: ClearLoaderParams): void;
38
+ /**
39
+ * TODO @ts-refactor
40
+ * Maybe pass on the generics to DataLoader definition?
41
+ */
42
+ private getLoader;
43
+ private loadMany;
44
+ clearAll(params: Omit<ClearLoaderParams, "entry">): void;
45
+ /**
46
+ * Helper to clear the cache for certain data loader.
47
+ * If entry is passed then clear target key only.
48
+ */
49
+ private clear;
50
+ }
51
+ export {};