@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.40876133bb

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 (162) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +18 -7
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +6 -7
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -7
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -7
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +3 -7
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -7
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -7
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js.map +1 -0
  24. package/definitions/tableElasticsearch.d.ts +2 -2
  25. package/definitions/tableElasticsearch.js.map +1 -0
  26. package/dynamoDb/index.d.ts +1 -1
  27. package/dynamoDb/index.js +4 -6
  28. package/dynamoDb/index.js.map +1 -0
  29. package/dynamoDb/storage/date.d.ts +2 -3
  30. package/dynamoDb/storage/date.js +80 -46
  31. package/dynamoDb/storage/date.js.map +1 -0
  32. package/dynamoDb/storage/longText.d.ts +7 -4
  33. package/dynamoDb/storage/longText.js +72 -54
  34. package/dynamoDb/storage/longText.js.map +1 -0
  35. package/dynamoDb/storage/richText.d.ts +2 -3
  36. package/dynamoDb/storage/richText.js +85 -67
  37. package/dynamoDb/storage/richText.js.map +1 -0
  38. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  39. package/elasticsearch/createElasticsearchIndex.js +60 -0
  40. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  41. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  42. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  43. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  44. package/elasticsearch/index.d.ts +1 -1
  45. package/elasticsearch/index.js +1 -1
  46. package/elasticsearch/index.js.map +1 -0
  47. package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
  48. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  50. package/elasticsearch/indexing/index.js +1 -1
  51. package/elasticsearch/indexing/index.js.map +1 -0
  52. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  53. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  55. package/elasticsearch/indexing/objectIndexing.js +32 -9
  56. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  58. package/elasticsearch/indices/base.d.ts +2 -0
  59. package/elasticsearch/indices/base.js +15 -0
  60. package/elasticsearch/indices/base.js.map +1 -0
  61. package/elasticsearch/indices/index.d.ts +1 -0
  62. package/elasticsearch/indices/index.js +16 -0
  63. package/elasticsearch/indices/index.js.map +1 -0
  64. package/elasticsearch/indices/japanese.d.ts +2 -0
  65. package/elasticsearch/indices/japanese.js +16 -0
  66. package/elasticsearch/indices/japanese.js.map +1 -0
  67. package/elasticsearch/search/index.d.ts +2 -2
  68. package/elasticsearch/search/index.js +3 -5
  69. package/elasticsearch/search/index.js.map +1 -0
  70. package/elasticsearch/search/refSearch.d.ts +2 -3
  71. package/elasticsearch/search/refSearch.js +25 -16
  72. package/elasticsearch/search/refSearch.js.map +1 -0
  73. package/elasticsearch/search/timeSearch.d.ts +2 -3
  74. package/elasticsearch/search/timeSearch.js +22 -14
  75. package/elasticsearch/search/timeSearch.js.map +1 -0
  76. package/helpers/createElasticsearchQueryBody.js +320 -84
  77. package/helpers/createElasticsearchQueryBody.js.map +1 -0
  78. package/helpers/entryIndexHelpers.js +33 -18
  79. package/helpers/entryIndexHelpers.js.map +1 -0
  80. package/helpers/fields.d.ts +4 -62
  81. package/helpers/fields.js +39 -8
  82. package/helpers/fields.js.map +1 -0
  83. package/helpers/index.js.map +1 -0
  84. package/helpers/searchPluginsList.d.ts +2 -2
  85. package/helpers/searchPluginsList.js +1 -1
  86. package/helpers/searchPluginsList.js.map +1 -0
  87. package/helpers/transformValueForSearch.d.ts +5 -2
  88. package/helpers/transformValueForSearch.js +3 -0
  89. package/helpers/transformValueForSearch.js.map +1 -0
  90. package/index.d.ts +1 -0
  91. package/index.js +126 -29
  92. package/index.js.map +1 -0
  93. package/operations/entry/dataLoaders.d.ts +6 -2
  94. package/operations/entry/dataLoaders.js +31 -13
  95. package/operations/entry/dataLoaders.js.map +1 -0
  96. package/operations/entry/elasticsearchFields.js +6 -0
  97. package/operations/entry/elasticsearchFields.js.map +1 -0
  98. package/operations/entry/index.d.ts +2 -2
  99. package/operations/entry/index.js +445 -331
  100. package/operations/entry/index.js.map +1 -0
  101. package/operations/entry/keys.js.map +1 -0
  102. package/operations/group/index.d.ts +2 -2
  103. package/operations/group/index.js +8 -15
  104. package/operations/group/index.js.map +1 -0
  105. package/operations/model/index.d.ts +2 -2
  106. package/operations/model/index.js +38 -39
  107. package/operations/model/index.js.map +1 -0
  108. package/operations/settings/index.d.ts +2 -2
  109. package/operations/settings/index.js +7 -13
  110. package/operations/settings/index.js.map +1 -0
  111. package/operations/system/index.d.ts +2 -2
  112. package/operations/system/index.js +5 -11
  113. package/operations/system/index.js.map +1 -0
  114. package/package.json +24 -29
  115. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +6 -3
  116. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -3
  117. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  118. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  119. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
  120. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  121. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  122. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  123. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  124. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  125. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  126. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  127. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
  128. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -3
  129. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  130. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
  131. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -3
  132. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  133. package/plugins/index.d.ts +6 -0
  134. package/plugins/index.js +83 -0
  135. package/plugins/index.js.map +1 -0
  136. package/types.d.ts +7 -34
  137. package/types.js +0 -13
  138. package/types.js.map +1 -0
  139. package/helpers/operatorPluginsList.d.ts +0 -7
  140. package/helpers/operatorPluginsList.js +0 -30
  141. package/operations/entry/fields.d.ts +0 -3
  142. package/operations/entry/fields.js +0 -60
  143. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  144. package/operations/system/createElasticsearchTemplate.js +0 -62
  145. package/upgrades/index.d.ts +0 -2
  146. package/upgrades/index.js +0 -16
  147. package/upgrades/utils.d.ts +0 -1
  148. package/upgrades/utils.js +0 -16
  149. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  150. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  151. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  152. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  153. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  154. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  155. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  156. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  157. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  158. package/upgrades/v5.0.0/helpers.js +0 -57
  159. package/upgrades/v5.0.0/index.d.ts +0 -4
  160. package/upgrades/v5.0.0/index.js +0 -232
  161. package/upgrades/v5.8.0/index.d.ts +0 -4
  162. package/upgrades/v5.8.0/index.js +0 -426
package/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ var _exportNames = {
9
+ createStorageOperations: true
10
+ };
8
11
  exports.createStorageOperations = void 0;
9
12
 
10
13
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
@@ -39,25 +42,42 @@ var _system2 = require("./definitions/system");
39
42
 
40
43
  var _settings2 = require("./definitions/settings");
41
44
 
42
- var _createElasticsearchTemplate = require("./operations/system/createElasticsearchTemplate");
45
+ var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
43
46
 
44
47
  var _plugins = require("@webiny/plugins");
45
48
 
46
49
  var _group2 = require("./operations/group");
47
50
 
48
- var _operators = require("@webiny/api-elasticsearch/operators");
51
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
49
52
 
50
53
  var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
51
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
+
52
73
  const createStorageOperations = params => {
53
74
  const {
54
- attributes = {},
75
+ attributes,
55
76
  table,
56
77
  esTable,
57
78
  documentClient,
58
79
  elasticsearch,
59
- plugins: customPlugins,
60
- modelFieldToGraphQLPlugins
80
+ plugins: userPlugins
61
81
  } = params;
62
82
  const tableInstance = (0, _table.createTable)({
63
83
  table,
@@ -71,43 +91,39 @@ const createStorageOperations = params => {
71
91
  settings: (0, _settings2.createSettingsEntity)({
72
92
  entityName: _types.ENTITIES.SETTINGS,
73
93
  table: tableInstance,
74
- attributes: attributes[_types.ENTITIES.SETTINGS]
94
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
75
95
  }),
76
96
  system: (0, _system2.createSystemEntity)({
77
97
  entityName: _types.ENTITIES.SYSTEM,
78
98
  table: tableInstance,
79
- attributes: attributes[_types.ENTITIES.SYSTEM]
99
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
80
100
  }),
81
101
  groups: (0, _group.createGroupEntity)({
82
102
  entityName: _types.ENTITIES.GROUPS,
83
103
  table: tableInstance,
84
- attributes: attributes[_types.ENTITIES.GROUPS]
104
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
85
105
  }),
86
106
  models: (0, _model2.createModelEntity)({
87
107
  entityName: _types.ENTITIES.MODELS,
88
108
  table: tableInstance,
89
- attributes: attributes[_types.ENTITIES.MODELS]
109
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
90
110
  }),
91
111
  entries: (0, _entry2.createEntryEntity)({
92
112
  entityName: _types.ENTITIES.ENTRIES,
93
113
  table: tableInstance,
94
- attributes: attributes[_types.ENTITIES.ENTRIES]
114
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
95
115
  }),
96
116
  entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
97
117
  entityName: _types.ENTITIES.ENTRIES_ES,
98
118
  table: tableElasticsearchInstance,
99
- attributes: attributes[_types.ENTITIES.ENTRIES_ES]
119
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
100
120
  })
101
121
  };
102
122
  const plugins = new _plugins.PluginsContainer([
103
- /**
104
- * User defined custom plugins.
105
- */
106
- ...(customPlugins || []),
107
123
  /**
108
124
  * Plugins of type CmsModelFieldToGraphQLPlugin.
109
125
  */
110
- modelFieldToGraphQLPlugins,
126
+
111
127
  /**
112
128
  * Elasticsearch field definitions for the entry record.
113
129
  */
@@ -119,7 +135,7 @@ const createStorageOperations = params => {
119
135
  /**
120
136
  * Elasticsearch operators.
121
137
  */
122
- (0, _operators.getElasticsearchOperators)(),
138
+ (0, _apiElasticsearch.getElasticsearchOperators)(),
123
139
  /**
124
140
  * Field plugins for DynamoDB.
125
141
  */
@@ -127,21 +143,102 @@ const createStorageOperations = params => {
127
143
  /**
128
144
  * Field plugins for Elasticsearch.
129
145
  */
130
- (0, _elasticsearch.default)()]);
146
+ (0, _elasticsearch.default)(),
147
+ /**
148
+ * Built-in Elasticsearch index templates.
149
+ */
150
+ (0, _indices.elasticsearchIndexPlugins)(),
151
+ /**
152
+ * User defined custom plugins.
153
+ * They are at the end because we can then override existing plugins.
154
+ */
155
+ ...(userPlugins || [])]);
131
156
  return {
132
- init: async cms => {
133
- cms.onBeforeSystemInstall.subscribe(async () => {
134
- await (0, _createElasticsearchTemplate.createElasticsearchTemplate)({
135
- elasticsearch
157
+ beforeInit: async context => {
158
+ /**
159
+ * Attach the elasticsearch into context if it is not already attached.
160
+ */
161
+ if (!context.elasticsearch) {
162
+ context.elasticsearch = elasticsearch;
163
+ }
164
+ /**
165
+ * Collect all required plugins from parent context.
166
+ */
167
+
168
+
169
+ const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
170
+ plugins.register(fieldPlugins);
171
+ /**
172
+ * We need to get all the operator plugins from the main plugin container.
173
+ */
174
+
175
+ const elasticsearchOperatorPlugins = context.plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type);
176
+ plugins.register(elasticsearchOperatorPlugins);
177
+ /**
178
+ * We need to get all the query modifier plugins
179
+ */
180
+
181
+ const queryModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchQueryModifierPlugin.type);
182
+ plugins.register(queryModifierPlugins);
183
+ /**
184
+ * We need to get all the sort modifier plugins
185
+ */
186
+
187
+ const sortModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchSortModifierPlugin.type);
188
+ plugins.register(sortModifierPlugins);
189
+ /**
190
+ * We need to get all the body modifier plugins
191
+ */
192
+
193
+ const bodyModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchBodyModifierPlugin.type);
194
+ plugins.register(bodyModifierPlugins);
195
+ /**
196
+ * Pass the plugins to the parent context.
197
+ */
198
+
199
+ context.plugins.register([(0, _dynamoDb.default)()]);
200
+ },
201
+ init: async context => {
202
+ /**
203
+ * We need to create indexes on before model create and on clone (create from).
204
+ * Other apps create indexes on locale creation.
205
+ */
206
+ context.cms.onModelBeforeCreate.subscribe(async ({
207
+ model
208
+ }) => {
209
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
210
+ elasticsearch,
211
+ model,
212
+ plugins
213
+ });
214
+ });
215
+ context.cms.onModelBeforeCreateFrom.subscribe(async ({
216
+ model
217
+ }) => {
218
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
219
+ elasticsearch,
220
+ model,
221
+ plugins
222
+ });
223
+ });
224
+ context.cms.onModelAfterDelete.subscribe(async ({
225
+ model
226
+ }) => {
227
+ await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
228
+ elasticsearch,
229
+ model
230
+ });
231
+ });
232
+ context.cms.onModelInitialize.subscribe(async ({
233
+ model
234
+ }) => {
235
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
236
+ elasticsearch,
237
+ model,
238
+ plugins
136
239
  });
137
240
  });
138
241
  },
139
- plugins: [
140
- /**
141
- * Field plugins for DynamoDB.
142
- * We must pass them to the base application.
143
- */
144
- (0, _dynamoDb.default)()],
145
242
  getEntities: () => entities,
146
243
  getTable: () => tableInstance,
147
244
  getEsTable: () => tableElasticsearchInstance,
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","beforeInit","context","fieldPlugins","byType","register","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\";\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 * 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 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 * 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 /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\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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AAE7D,QAAQ,CAACkB,SAFiB;MAGpCxB,OAHoC;MAIpCD;IAJoC,CAA/B;EAxGN,CAAP;AA+GH,CAtMM"}
@@ -20,13 +20,13 @@ interface ClearLoaderParams {
20
20
  model: CmsModel;
21
21
  entry?: CmsEntry;
22
22
  }
23
- export interface Params {
23
+ export interface DataLoadersHandlerParams {
24
24
  entity: Entity<any>;
25
25
  }
26
26
  export declare class DataLoadersHandler {
27
27
  private readonly loaders;
28
28
  private readonly entity;
29
- constructor(params: any);
29
+ constructor(params: DataLoadersHandlerParams);
30
30
  getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]>;
31
31
  clearAllEntryRevisions(params: ClearLoaderParams): void;
32
32
  getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]>;
@@ -35,6 +35,10 @@ export declare class DataLoadersHandler {
35
35
  clearPublishedRevisionByEntryId(params: ClearLoaderParams): void;
36
36
  getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsEntry[]>;
37
37
  clearLatestRevisionByEntryId(params: ClearLoaderParams): void;
38
+ /**
39
+ * TODO @ts-refactor
40
+ * Maybe pass on the generics to DataLoader definition?
41
+ */
38
42
  private getLoader;
39
43
  private loadMany;
40
44
  clearAll(params: Omit<ClearLoaderParams, "entry">): void;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.DataLoadersHandler = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _dataloader = _interopRequireDefault(require("dataloader"));
@@ -23,10 +25,6 @@ var _utils = require("@webiny/utils");
23
25
 
24
26
  var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
25
27
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
-
30
28
  const getAllEntryRevisions = params => {
31
29
  const {
32
30
  entity,
@@ -37,7 +35,7 @@ const getAllEntryRevisions = params => {
37
35
  locale
38
36
  } = model;
39
37
  return new _dataloader.default(async ids => {
40
- const results = [];
38
+ const results = {};
41
39
 
42
40
  for (const id of ids) {
43
41
  const queryAllParams = {
@@ -52,11 +50,12 @@ const getAllEntryRevisions = params => {
52
50
  }
53
51
  };
54
52
  const items = await (0, _query.queryAll)(queryAllParams);
55
- const entries = (0, _cleanup.cleanupItems)(entity, items);
56
- results.push(entries);
53
+ results[id] = (0, _cleanup.cleanupItems)(entity, items);
57
54
  }
58
55
 
59
- return results;
56
+ return ids.map(id => {
57
+ return results[id] || [];
58
+ });
60
59
  });
61
60
  };
62
61
 
@@ -79,6 +78,11 @@ const getRevisionById = params => {
79
78
  const {
80
79
  version
81
80
  } = (0, _utils.parseIdentifier)(id);
81
+
82
+ if (!version) {
83
+ return collection;
84
+ }
85
+
82
86
  const sortKey = (0, _keys.createRevisionSortKey)({
83
87
  version
84
88
  });
@@ -93,6 +97,9 @@ const getRevisionById = params => {
93
97
  SK: sortKey
94
98
  });
95
99
  return collection;
100
+ /**
101
+ * We use any because there is no type for the return type.
102
+ */
96
103
  }, {});
97
104
  const records = await (0, _batchRead.batchReadAll)({
98
105
  table: entity.table,
@@ -134,6 +141,9 @@ const getPublishedRevisionByEntryId = params => {
134
141
  SK: publishedKey
135
142
  });
136
143
  return collection;
144
+ /**
145
+ * We use any because there is no type for the return type.
146
+ */
137
147
  }, {});
138
148
  const records = await (0, _batchRead.batchReadAll)({
139
149
  table: entity.table,
@@ -178,6 +188,9 @@ const getLatestRevisionByEntryId = params => {
178
188
  SK: latestKey
179
189
  });
180
190
  return collection;
191
+ /**
192
+ * We use any because there is no type for the return type.
193
+ */
181
194
  }, {});
182
195
  const records = await (0, _batchRead.batchReadAll)({
183
196
  table: entity.table,
@@ -241,6 +254,11 @@ class DataLoadersHandler {
241
254
  clearLatestRevisionByEntryId(params) {
242
255
  this.clear("getLatestRevisionByEntryId", params);
243
256
  }
257
+ /**
258
+ * TODO @ts-refactor
259
+ * Maybe pass on the generics to DataLoader definition?
260
+ */
261
+
244
262
 
245
263
  getLoader(name, params) {
246
264
  if (!dataLoaders[name]) {
@@ -259,7 +277,7 @@ class DataLoadersHandler {
259
277
  const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
260
278
 
261
279
  if (!this.loaders.has(loaderKey)) {
262
- this.loaders.set(loaderKey, dataLoaders[name](_objectSpread(_objectSpread({}, params), {}, {
280
+ this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
263
281
  entity: this.entity
264
282
  })));
265
283
  }
@@ -277,12 +295,12 @@ class DataLoadersHandler {
277
295
  return results.reduce((acc, res) => {
278
296
  if (Array.isArray(res) === false) {
279
297
  if (res && res.message) {
280
- throw new _error.default(res.message, res.code, _objectSpread(_objectSpread({}, res), {}, {
298
+ throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
281
299
  data: JSON.stringify(res.data || {})
282
300
  }));
283
301
  }
284
302
 
285
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", _objectSpread(_objectSpread({}, params), {}, {
303
+ throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
286
304
  loader
287
305
  }));
288
306
  }
@@ -292,7 +310,7 @@ class DataLoadersHandler {
292
310
  }, []);
293
311
  }
294
312
  } catch (ex) {
295
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", _objectSpread(_objectSpread({
313
+ throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
296
314
  error: ex
297
315
  }, params), {}, {
298
316
  loader,
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","clearAllEntryRevisions","clear","clearRevisionById","clearPublishedRevisionByEntryId","clearLatestRevisionByEntryId","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll","entry"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsEntry[]> = {};\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<CmsEntry>(queryAllParams);\n\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (!version) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\nexport interface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public clearAllEntryRevisions(params: ClearLoaderParams): void {\n this.clear(\"getAllEntryRevisions\", params);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public clearRevisionById(params: ClearLoaderParams): void {\n this.clear(\"getRevisionById\", params);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n public clearPublishedRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getPublishedRevisionByEntryId\", params);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n public clearLatestRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getLatestRevisionByEntryId\", params);\n }\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n /**\n * Helper to clear the cache for certain data loader.\n * If entry is passed then clear target key only.\n */\n private clear(name: Loaders, params: ClearLoaderParams): void {\n const { entry } = params;\n const loader = this.getLoader(name, params);\n if (!entry) {\n loader.clearAll();\n return;\n }\n loader.clear(entry.id);\n const { tenant, locale } = params.model;\n loader.clear(\n createPartitionKey({\n tenant,\n locale,\n id: entry.id\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;AAEA,MAAMA,oB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;;AAlJ2B"}
@@ -22,6 +22,12 @@ const elasticsearchFields = [new _CmsEntryElasticsearchFieldPlugin.CmsEntryElast
22
22
  }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
23
23
  field: "createdBy",
24
24
  path: "createdBy.id"
25
+ }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
26
+ field: "version",
27
+ path: "version"
28
+ }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
29
+ field: "status",
30
+ path: "status"
25
31
  }),
26
32
  /**
27
33
  * Always add the ALL fields plugin because of the keyword/path build.
@@ -0,0 +1 @@
1
+ {"version":3,"names":["elasticsearchFields","CmsEntryElasticsearchFieldPlugin","field","unmappedType","path","ALL"],"sources":["elasticsearchFields.ts"],"sourcesContent":["import { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\n\nexport const elasticsearchFields = [\n new CmsEntryElasticsearchFieldPlugin({\n field: \"createdOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"savedOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"publishedOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"version\",\n path: \"version\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"status\",\n path: \"status\"\n }),\n /**\n * Always add the ALL fields plugin because of the keyword/path build.\n */\n new CmsEntryElasticsearchFieldPlugin({\n field: CmsEntryElasticsearchFieldPlugin.ALL\n })\n];\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,mBAAmB,GAAG,CAC/B,IAAIC,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,WAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAD+B,EAK/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAL+B,EAS/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,aAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAT+B,EAa/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAb+B,EAiB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,WAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAjB+B,EAqB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CArB+B,EAyB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,QAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAzB+B;AA6B/B;AACJ;AACA;AACI,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAED,kEAAA,CAAiCI;AADP,CAArC,CAhC+B,CAA5B"}
@@ -4,10 +4,10 @@ import { Client } from "@elastic/elasticsearch";
4
4
  import { PluginsContainer } from "@webiny/plugins";
5
5
  export declare const createLatestType: () => string;
6
6
  export declare const createPublishedType: () => string;
7
- export interface Params {
7
+ export interface CreateEntriesStorageOperationsParams {
8
8
  entity: Entity<any>;
9
9
  esEntity: Entity<any>;
10
10
  elasticsearch: Client;
11
11
  plugins: PluginsContainer;
12
12
  }
13
- export declare const createEntriesStorageOperations: (params: Params) => CmsEntryStorageOperations;
13
+ export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;