@webiny/api-headless-cms-ddb-es 0.0.0-unstable.2af142b57e → 0.0.0-unstable.3bc8100a7f

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 (276) hide show
  1. package/configurations.d.ts +13 -6
  2. package/configurations.js +18 -4
  3. package/configurations.js.map +1 -1
  4. package/definitions/entry.d.ts +4 -3
  5. package/definitions/entry.js +109 -12
  6. package/definitions/entry.js.map +1 -1
  7. package/definitions/entryElasticsearch.d.ts +4 -3
  8. package/definitions/entryElasticsearch.js +12 -8
  9. package/definitions/entryElasticsearch.js.map +1 -1
  10. package/definitions/group.d.ts +4 -3
  11. package/definitions/group.js +9 -8
  12. package/definitions/group.js.map +1 -1
  13. package/definitions/model.d.ts +4 -3
  14. package/definitions/model.js +26 -8
  15. package/definitions/model.js.map +1 -1
  16. package/definitions/system.d.ts +4 -3
  17. package/definitions/system.js +9 -8
  18. package/definitions/system.js.map +1 -1
  19. package/definitions/table.d.ts +5 -5
  20. package/definitions/table.js +8 -4
  21. package/definitions/table.js.map +1 -1
  22. package/definitions/tableElasticsearch.d.ts +5 -5
  23. package/definitions/tableElasticsearch.js +8 -4
  24. package/definitions/tableElasticsearch.js.map +1 -1
  25. package/dynamoDb/index.d.ts +1 -0
  26. package/dynamoDb/index.js +9 -4
  27. package/dynamoDb/index.js.map +1 -1
  28. package/dynamoDb/storage/longText.js +7 -2
  29. package/dynamoDb/storage/longText.js.map +1 -1
  30. package/dynamoDb/storage/richText.d.ts +0 -5
  31. package/dynamoDb/storage/richText.js +27 -74
  32. package/dynamoDb/storage/richText.js.map +1 -1
  33. package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
  34. package/elasticsearch/createElasticsearchIndex.js +20 -29
  35. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  36. package/elasticsearch/deleteElasticsearchIndex.d.ts +3 -3
  37. package/elasticsearch/deleteElasticsearchIndex.js +6 -4
  38. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  39. package/elasticsearch/index.js +3 -1
  40. package/elasticsearch/index.js.map +1 -1
  41. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  42. package/elasticsearch/indexing/dateTimeIndexing.js +5 -3
  43. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  44. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  45. package/elasticsearch/indexing/defaultFieldIndexing.js +13 -2
  46. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  47. package/elasticsearch/indexing/index.js +5 -2
  48. package/elasticsearch/indexing/index.js.map +1 -1
  49. package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
  50. package/elasticsearch/indexing/jsonIndexing.js +28 -0
  51. package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
  52. package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
  53. package/elasticsearch/indexing/longTextIndexing.js +5 -9
  54. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  55. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  56. package/elasticsearch/indexing/numberIndexing.js +3 -1
  57. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  58. package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
  59. package/elasticsearch/indexing/objectIndexing.js +23 -18
  60. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  61. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  62. package/elasticsearch/indexing/richTextIndexing.js +3 -1
  63. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  64. package/elasticsearch/indices/base.js +3 -2
  65. package/elasticsearch/indices/base.js.map +1 -1
  66. package/elasticsearch/indices/index.js +3 -1
  67. package/elasticsearch/indices/index.js.map +1 -1
  68. package/elasticsearch/indices/japanese.js +3 -2
  69. package/elasticsearch/indices/japanese.js.map +1 -1
  70. package/elasticsearch/search/index.d.ts +1 -1
  71. package/elasticsearch/search/index.js +3 -1
  72. package/elasticsearch/search/index.js.map +1 -1
  73. package/elasticsearch/search/refSearch.js +3 -1
  74. package/elasticsearch/search/refSearch.js.map +1 -1
  75. package/elasticsearch/search/timeSearch.js +4 -3
  76. package/elasticsearch/search/timeSearch.js.map +1 -1
  77. package/helpers/entryIndexHelpers.d.ts +3 -3
  78. package/helpers/entryIndexHelpers.js +36 -21
  79. package/helpers/entryIndexHelpers.js.map +1 -1
  80. package/helpers/fieldIdentifier.d.ts +6 -0
  81. package/helpers/fieldIdentifier.js +43 -0
  82. package/helpers/fieldIdentifier.js.map +1 -0
  83. package/helpers/index.d.ts +1 -0
  84. package/helpers/index.js +14 -1
  85. package/helpers/index.js.map +1 -1
  86. package/index.d.ts +1 -1
  87. package/index.js +44 -52
  88. package/index.js.map +1 -1
  89. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  90. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  91. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  92. package/operations/entry/dataLoader/constants.d.ts +1 -0
  93. package/operations/entry/dataLoader/constants.js +10 -0
  94. package/operations/entry/dataLoader/constants.js.map +1 -0
  95. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  96. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  97. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  98. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  99. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  100. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  101. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  102. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -0
  103. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  104. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  105. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +52 -0
  106. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  107. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  108. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  109. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  110. package/operations/entry/dataLoader/index.d.ts +8 -0
  111. package/operations/entry/dataLoader/index.js +40 -0
  112. package/operations/entry/dataLoader/index.js.map +1 -0
  113. package/operations/entry/dataLoader/types.d.ts +6 -0
  114. package/operations/entry/dataLoader/types.js +7 -0
  115. package/operations/entry/dataLoader/types.js.map +1 -0
  116. package/operations/entry/dataLoaders.d.ts +16 -37
  117. package/operations/entry/dataLoaders.js +56 -253
  118. package/operations/entry/dataLoaders.js.map +1 -1
  119. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  120. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +3 -1
  121. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  122. package/operations/entry/elasticsearch/body.d.ts +3 -3
  123. package/operations/entry/elasticsearch/body.js +4 -2
  124. package/operations/entry/elasticsearch/body.js.map +1 -1
  125. package/operations/entry/elasticsearch/fields.d.ts +6 -5
  126. package/operations/entry/elasticsearch/fields.js +177 -91
  127. package/operations/entry/elasticsearch/fields.js.map +1 -1
  128. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
  129. package/operations/entry/elasticsearch/filtering/applyFiltering.js +4 -2
  130. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  131. package/operations/entry/elasticsearch/filtering/exec.d.ts +4 -4
  132. package/operations/entry/elasticsearch/filtering/exec.js +8 -5
  133. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  134. package/operations/entry/elasticsearch/filtering/index.js +3 -1
  135. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  136. package/operations/entry/elasticsearch/filtering/path.d.ts +1 -1
  137. package/operations/entry/elasticsearch/filtering/path.js +4 -2
  138. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  139. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +4 -2
  140. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  141. package/operations/entry/elasticsearch/filtering/plugins/index.js +3 -1
  142. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
  143. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +6 -2
  144. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  145. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +12 -3
  146. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  147. package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
  148. package/operations/entry/elasticsearch/filtering/populated.js +4 -2
  149. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  150. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  151. package/operations/entry/elasticsearch/filtering/values.js +3 -1
  152. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  153. package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
  154. package/operations/entry/elasticsearch/fullTextSearch.js +3 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  156. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
  157. package/operations/entry/elasticsearch/fullTextSearchFields.js +3 -1
  158. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  159. package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
  160. package/operations/entry/elasticsearch/initialQuery.js +5 -2
  161. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  162. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  163. package/operations/entry/elasticsearch/keyword.js +3 -1
  164. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  165. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
  166. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
  167. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
  168. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +3 -3
  169. package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -1
  170. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
  171. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
  172. package/operations/entry/elasticsearch/plugins/operator.js +3 -1
  173. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  174. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +3 -3
  175. package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -1
  176. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
  177. package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
  178. package/operations/entry/elasticsearch/plugins/search.js +3 -1
  179. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  180. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +3 -3
  181. package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -1
  182. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
  183. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  184. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
  185. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  186. package/operations/entry/elasticsearch/sort.d.ts +4 -4
  187. package/operations/entry/elasticsearch/sort.js +13 -8
  188. package/operations/entry/elasticsearch/sort.js.map +1 -1
  189. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
  190. package/operations/entry/elasticsearch/transformValueForSearch.js +3 -1
  191. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  192. package/operations/entry/elasticsearch/types.d.ts +8 -8
  193. package/operations/entry/elasticsearch/types.js +3 -1
  194. package/operations/entry/elasticsearch/types.js.map +1 -1
  195. package/operations/entry/index.d.ts +4 -4
  196. package/operations/entry/index.js +1207 -454
  197. package/operations/entry/index.js.map +1 -1
  198. package/operations/entry/keys.js +3 -1
  199. package/operations/entry/keys.js.map +1 -1
  200. package/operations/entry/recordType.js +3 -1
  201. package/operations/entry/recordType.js.map +1 -1
  202. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  203. package/operations/entry/transformations/convertEntryKeys.js +38 -0
  204. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  205. package/operations/entry/transformations/index.d.ts +29 -0
  206. package/operations/entry/transformations/index.js +127 -0
  207. package/operations/entry/transformations/index.js.map +1 -0
  208. package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
  209. package/operations/entry/transformations/modifyEntryValues.js +28 -0
  210. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  211. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  212. package/operations/entry/transformations/transformEntryKeys.js +27 -0
  213. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  214. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  215. package/operations/entry/transformations/transformEntryToIndex.js +31 -0
  216. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  217. package/operations/group/index.d.ts +3 -3
  218. package/operations/group/index.js +38 -24
  219. package/operations/group/index.js.map +1 -1
  220. package/operations/model/index.d.ts +3 -3
  221. package/operations/model/index.js +27 -15
  222. package/operations/model/index.js.map +1 -1
  223. package/operations/system/index.d.ts +2 -2
  224. package/operations/system/index.js +19 -7
  225. package/operations/system/index.js.map +1 -1
  226. package/operations/system/indexes.d.ts +10 -0
  227. package/operations/system/indexes.js +41 -0
  228. package/operations/system/indexes.js.map +1 -0
  229. package/package.json +37 -34
  230. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
  231. package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
  232. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
  233. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
  234. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +4 -5
  235. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  236. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
  237. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +4 -5
  238. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
  239. package/plugins/CmsEntryElasticsearchIndexPlugin.js +5 -4
  240. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  241. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +2 -1
  242. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +12 -5
  243. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  244. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
  245. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +4 -5
  246. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  247. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
  248. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +4 -5
  249. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  250. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
  251. package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
  252. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
  253. package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
  254. package/plugins/CmsEntryFilterPlugin.js +4 -6
  255. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  256. package/plugins/index.d.ts +2 -1
  257. package/plugins/index.js +25 -12
  258. package/plugins/index.js.map +1 -1
  259. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  260. package/tasks/createIndexTaskPlugin.js +67 -0
  261. package/tasks/createIndexTaskPlugin.js.map +1 -0
  262. package/types.d.ts +27 -22
  263. package/types.js +5 -5
  264. package/types.js.map +1 -1
  265. package/definitions/settings.d.ts +0 -8
  266. package/definitions/settings.js +0 -53
  267. package/definitions/settings.js.map +0 -1
  268. package/dynamoDb/storage/date.d.ts +0 -3
  269. package/dynamoDb/storage/date.js +0 -84
  270. package/dynamoDb/storage/date.js.map +0 -1
  271. package/operations/settings/index.d.ts +0 -6
  272. package/operations/settings/index.js +0 -111
  273. package/operations/settings/index.js.map +0 -1
  274. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  275. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -18
  276. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
8
  var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _fieldIdentifier = require("./fieldIdentifier");
10
10
  const prepareEntryToIndex = params => {
11
11
  const {
12
12
  plugins,
@@ -38,7 +38,8 @@ const prepareEntryToIndex = params => {
38
38
 
39
39
  // We're only interested in current model fields.
40
40
  for (const field of model.fields) {
41
- if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
41
+ const identifier = (0, _fieldIdentifier.getFieldIdentifier)(storageEntry.values, field);
42
+ if (!identifier) {
42
43
  continue;
43
44
  }
44
45
  const targetFieldPlugin = getFieldIndexPlugin(field.type);
@@ -54,22 +55,23 @@ const prepareEntryToIndex = params => {
54
55
  plugins,
55
56
  model,
56
57
  field,
57
- rawValue: entry.values[field.storageId],
58
- value: storageEntry.values[field.storageId],
58
+ rawValue: entry.values[identifier],
59
+ value: storageEntry.values[identifier],
59
60
  getFieldIndexPlugin,
60
61
  getFieldTypePlugin
61
62
  });
62
63
  if (typeof value !== "undefined") {
63
- values[field.storageId] = value;
64
+ values[identifier] = value;
64
65
  }
65
66
  if (typeof rawValue !== "undefined") {
66
- rawValues[field.storageId] = rawValue;
67
+ rawValues[identifier] = rawValue;
67
68
  }
68
69
  }
69
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
70
+ return {
71
+ ...storageEntry,
70
72
  values,
71
73
  rawValues
72
- });
74
+ };
73
75
  };
74
76
  exports.prepareEntryToIndex = prepareEntryToIndex;
75
77
  const setupEntriesIndexHelpers = ({
@@ -87,7 +89,8 @@ const setupEntriesIndexHelpers = ({
87
89
  const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === "*");
88
90
 
89
91
  // CmsModelFieldToGraphQLPlugin plugins
90
- const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, plugins), {}, {
92
+ const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => ({
93
+ ...plugins,
91
94
  [plugin.fieldType]: plugin
92
95
  }), {});
93
96
  return {
@@ -129,18 +132,25 @@ const extractEntriesFromIndex = ({
129
132
  if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
130
133
  continue;
131
134
  }
135
+ /**
136
+ * We can safely cast as the code will not continue in case of no identifiers.
137
+ */
138
+ const identifiers = (0, _fieldIdentifier.getFieldIdentifiers)(entry.values, entry.rawValues, field);
139
+ if (!identifiers) {
140
+ continue;
141
+ }
132
142
  try {
133
- indexValues[field.storageId] = targetFieldPlugin.fromIndex({
143
+ indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({
134
144
  plugins,
135
145
  model,
136
146
  field,
137
147
  getFieldIndexPlugin,
138
148
  getFieldTypePlugin,
139
- value: entry.values[field.storageId],
149
+ value: entry.values[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
140
150
  /**
141
151
  * Possibly no rawValues so we must check for the existence of the field.
142
152
  */
143
- rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
153
+ rawValue: entry.rawValues ? entry.rawValues[identifiers.rawValueIdentifier || identifiers.valueIdentifier] : null
144
154
  });
145
155
  } catch (ex) {
146
156
  throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
@@ -152,24 +162,29 @@ const extractEntriesFromIndex = ({
152
162
  /**
153
163
  * Let's have a new entry so we do not modify the original one.
154
164
  */
155
- const newEntry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
165
+ const newEntry = {
166
+ ...entry,
156
167
  values: indexValues
157
- });
168
+ };
158
169
  /**
159
170
  * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
160
171
  */
161
- // @ts-ignore
172
+ // @ts-expect-error
162
173
  delete newEntry["rawValues"];
163
- // @ts-ignore
174
+ // @ts-expect-error
164
175
  delete newEntry["TYPE"];
165
- // @ts-ignore
176
+ // @ts-expect-error
166
177
  delete newEntry["__type"];
167
- // @ts-ignore
178
+ // @ts-expect-error
168
179
  delete newEntry["latest"];
169
- // @ts-ignore
180
+ // @ts-expect-error
170
181
  delete newEntry["published"];
171
- list.push((0, _objectSpread2.default)({}, newEntry));
182
+ list.push({
183
+ ...newEntry
184
+ });
172
185
  }
173
186
  return list;
174
187
  };
175
- exports.extractEntriesFromIndex = extractEntriesFromIndex;
188
+ exports.extractEntriesFromIndex = extractEntriesFromIndex;
189
+
190
+ //# sourceMappingURL=entryIndexHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","hasOwnProperty","storageId","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n if (storageEntry.values.hasOwnProperty(field.storageId) === false) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[field.storageId],\n value: storageEntry.values[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[field.storageId] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[field.storageId] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n try {\n indexValues[field.storageId] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[field.storageId],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;;AAAA;AAoBO,MAAMA,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmB,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkB,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,c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IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_fieldIdentifier","prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","identifier","getFieldIdentifier","targetFieldPlugin","type","toIndex","value","rawValue","exports","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","identifiers","getFieldIdentifiers","valueIdentifier","rawValueIdentifier","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsEntry,\n CmsModel,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport type { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field);\n if (!identifier) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n\n try {\n indexValues[identifiers.valueIdentifier] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues\n ? entry.rawValues[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ]\n : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQA,IAAAC,gBAAA,GAAAD,OAAA;AAiBO,MAAME,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmBA,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkBA,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,cAAW,CAAC,8BAA8BH,SAAS,6BAA6B,CAAC;EAC/F;;EAEA;EACA,MAAMI,MAA8B,GAAG,CAAC,CAAC;EACzC,MAAMC,SAAiC,GAAG,CAAC,CAAC;;EAE5C;EACA,KAAK,MAAMC,KAAK,IAAIZ,KAAK,CAACa,MAAM,EAAE;IAC9B,MAAMC,UAAU,GAAG,IAAAC,mCAAkB,EAACjB,YAAY,CAACY,MAAM,EAAEE,KAAK,CAAC;IACjE,IAAI,CAACE,UAAU,EAAE;MACb;IACJ;IAEA,MAAME,iBAAiB,GAAGX,mBAAmB,CAACO,KAAK,CAACK,IAAI,CAAC;;IAEzD;IACA,IAAI,CAACD,iBAAiB,IAAI,CAACA,iBAAiB,CAACE,OAAO,EAAE;MAClD;IACJ;IAEA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W,EAAE;QACd;MACJ;MAEA,IAAI;QACAH,WAAW,CAACG,WAAW,CAACE,eAAe,CAAC,GAAGpB,iBAAiB,CAACiB,SAAS,CAAC;UACnEpC,OAAO;UACPG,KAAK;UACLY,KAAK;UACLP,mBAAmB;UACnBE,kBAAkB;UAClBY,KAAK,EAAEpB,KAAK,CAACW,MAAM,CACfwB,WAAW,CAACE,eAAe,IAAIF,WAAW,CAACG,kBAAkB,CAChE;UACD;AACpB;AACA;UACoBjB,QAAQ,EAAErB,KAAK,CAACY,SAAS,GACnBZ,KAAK,CAACY,SAAS,CACXuB,WAAW,CAACG,kBAAkB,IAAIH,WAAW,CAACE,eAAe,CAChE,GACD;QACV,CAAC,CAAC;MACN,CAAC,CAAC,OAAOE,EAAE,EAAE;QACT,MAAM,IAAI7B,cAAW,CACjB6B,EAAE,CAACC,OAAO,IAAI,6CAA6C,EAC3DD,EAAE,CAACE,IAAI,IAAI,wBAAwB,EACnC;UACI5B,KAAK;UACLb;QACJ,CACJ,CAAC;MACL;IACJ;IACA;AACR;AACA;IACQ,MAAM0C,QAAkB,GAAG;MACvB,GAAG1C,KAAK;MACRW,MAAM,EAAEqB;IACZ,CAAC;IACD;AACR;AACA;IACQ;IACA,OAAOU,QAAQ,CAAC,WAAW,CAAC;IAC5B;IACA,OAAOA,QAAQ,CAAC,MAAM,CAAC;IACvB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,WAAW,CAAC;IAC5BX,IAAI,CAACY,IAAI,CAAC;MAAE,GAAGD;IAAS,CAAC,CAAC;EAC9B;EAEA,OAAOX,IAAI;AACf,CAAC;AAACT,OAAA,CAAAO,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { CmsEntryValues, CmsModelField } from "@webiny/api-headless-cms/types";
2
+ export declare const getFieldIdentifier: (values: CmsEntryValues | null | undefined, field: CmsModelField) => string | undefined;
3
+ export declare const getFieldIdentifiers: (values: CmsEntryValues, rawValues: CmsEntryValues | null | undefined, field: CmsModelField) => {
4
+ valueIdentifier: string;
5
+ rawValueIdentifier: string;
6
+ } | null;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFieldIdentifiers = exports.getFieldIdentifier = void 0;
7
+ const hasOwnProperty = (values = {}, property) => {
8
+ if (!values) {
9
+ return false;
10
+ } else if (values.hasOwnProperty) {
11
+ return values.hasOwnProperty(property);
12
+ }
13
+ return values[property] !== undefined;
14
+ };
15
+ const getFieldIdentifier = (values, field) => {
16
+ if (field.storageId && hasOwnProperty(values, field.storageId)) {
17
+ return field.storageId;
18
+ } else if (hasOwnProperty(values, field.fieldId)) {
19
+ return field.fieldId;
20
+ }
21
+ return undefined;
22
+ };
23
+ exports.getFieldIdentifier = getFieldIdentifier;
24
+ const getFieldIdentifiers = (values, rawValues, field) => {
25
+ let valueIdentifier = getFieldIdentifier(values, field);
26
+ let rawValueIdentifier = getFieldIdentifier(rawValues, field);
27
+ if (!valueIdentifier && !rawValueIdentifier) {
28
+ return null;
29
+ }
30
+ if (!valueIdentifier) {
31
+ valueIdentifier = rawValueIdentifier;
32
+ }
33
+ if (!rawValueIdentifier) {
34
+ rawValueIdentifier = valueIdentifier;
35
+ }
36
+ return {
37
+ valueIdentifier,
38
+ rawValueIdentifier
39
+ };
40
+ };
41
+ exports.getFieldIdentifiers = getFieldIdentifiers;
42
+
43
+ //# sourceMappingURL=fieldIdentifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","storageId","fieldId","exports","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"sources":["fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"mappings":";;;;;;AAEA,MAAMA,cAAc,GAAGA,CACnBC,MAAyC,GAAG,CAAC,CAAC,EAC9CC,QAAgB,KACN;EACV,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIA,MAAM,CAACD,cAAc,EAAE;IAC9B,OAAOC,MAAM,CAACD,cAAc,CAACE,QAAQ,CAAC;EAC1C;EACA,OAAOD,MAAM,CAACC,QAAQ,CAAC,KAAKC,SAAS;AACzC,CAAC;AAEM,MAAMC,kBAAkB,GAAGA,CAC9BH,MAAyC,EACzCI,KAAoB,KACC;EACrB,IAAIA,KAAK,CAACC,SAAS,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACC,SAAS,CAAC,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS;EAC1B,CAAC,MAAM,IAAIN,cAAc,CAACC,MAAM,EAAEI,KAAK,CAACE,OAAO,CAAC,EAAE;IAC9C,OAAOF,KAAK,CAACE,OAAO;EACxB;EACA,OAAOJ,SAAS;AACpB,CAAC;AAACK,OAAA,CAAAJ,kBAAA,GAAAA,kBAAA;AAEK,MAAMK,mBAAmB,GAAGA,CAC/BR,MAAsB,EACtBS,SAA4C,EAC5CL,KAAoB,KACnB;EACD,IAAIM,eAAe,GAAGP,kBAAkB,CAACH,MAAM,EAAEI,KAAK,CAAC;EACvD,IAAIO,kBAAkB,GAAGR,kBAAkB,CAACM,SAAS,EAAEL,KAAK,CAAC;EAC7D,IAAI,CAACM,eAAe,IAAI,CAACC,kBAAkB,EAAE;IACzC,OAAO,IAAI;EACf;EACA,IAAI,CAACD,eAAe,EAAE;IAClBA,eAAe,GAAGC,kBAA4B;EAClD;EACA,IAAI,CAACA,kBAAkB,EAAE;IACrBA,kBAAkB,GAAGD,eAAyB;EAClD;EACA,OAAO;IACHA,eAAe;IACfC;EACJ,CAAC;AACL,CAAC;AAACJ,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1 +1,2 @@
1
1
  export * from "./entryIndexHelpers";
2
+ export * from "./fieldIdentifier";
package/helpers/index.js CHANGED
@@ -13,4 +13,17 @@ Object.keys(_entryIndexHelpers).forEach(function (key) {
13
13
  return _entryIndexHelpers[key];
14
14
  }
15
15
  });
16
- });
16
+ });
17
+ var _fieldIdentifier = require("./fieldIdentifier");
18
+ Object.keys(_fieldIdentifier).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _fieldIdentifier[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _fieldIdentifier[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_entryIndexHelpers","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_fieldIdentifier"],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\nexport * from \"./fieldIdentifier\";\n"],"mappings":";;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { StorageOperationsFactory } from "./types";
1
+ import type { StorageOperationsFactory } from "./types";
2
2
  export * from "./plugins";
3
3
  export declare const createStorageOperations: StorageOperationsFactory;
package/index.js CHANGED
@@ -11,7 +11,6 @@ exports.createStorageOperations = void 0;
11
11
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
12
12
  var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
13
13
  var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
14
- var _settings = require("./operations/settings");
15
14
  var _system = require("./operations/system");
16
15
  var _model = require("./operations/model");
17
16
  var _entry = require("./operations/entry");
@@ -23,7 +22,6 @@ var _model2 = require("./definitions/model");
23
22
  var _entry2 = require("./definitions/entry");
24
23
  var _entryElasticsearch = require("./definitions/entryElasticsearch");
25
24
  var _system2 = require("./definitions/system");
26
- var _settings2 = require("./definitions/settings");
27
25
  var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
28
26
  var _plugins = require("@webiny/plugins");
29
27
  var _group2 = require("./operations/group");
@@ -43,6 +41,11 @@ Object.keys(_plugins2).forEach(function (key) {
43
41
  });
44
42
  });
45
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
+ var _api = require("@webiny/api");
46
49
  const createStorageOperations = params => {
47
50
  const {
48
51
  attributes,
@@ -61,11 +64,6 @@ const createStorageOperations = params => {
61
64
  documentClient
62
65
  });
63
66
  const entities = {
64
- settings: (0, _settings2.createSettingsEntity)({
65
- entityName: _types.ENTITIES.SETTINGS,
66
- table: tableInstance,
67
- attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
68
- }),
69
67
  system: (0, _system2.createSystemEntity)({
70
68
  entityName: _types.ENTITIES.SYSTEM,
71
69
  table: tableInstance,
@@ -93,17 +91,10 @@ const createStorageOperations = params => {
93
91
  })
94
92
  };
95
93
  const plugins = new _plugins.PluginsContainer([
96
- /**
97
- * Plugins of type CmsModelFieldToGraphQLPlugin.
98
- */
99
94
  /**
100
95
  * DynamoDB filter plugins for the where conditions.
101
96
  */
102
97
  (0, _filters.default)(),
103
- /**
104
- * Elasticsearch operators.
105
- */
106
- (0, _apiElasticsearch.getElasticsearchOperators)(),
107
98
  /**
108
99
  * Field plugins for DynamoDB.
109
100
  */
@@ -125,9 +116,25 @@ const createStorageOperations = params => {
125
116
  * They are at the end because we can then override existing plugins.
126
117
  */
127
118
  ...(userPlugins || [])]);
119
+ const entries = (0, _entry.createEntriesStorageOperations)({
120
+ entity: entities.entries,
121
+ esEntity: entities.entriesEs,
122
+ plugins,
123
+ elasticsearch
124
+ });
128
125
  return {
129
126
  name: "dynamodb:elasticsearch",
130
127
  beforeInit: async context => {
128
+ context.db.registry.register({
129
+ item: entities.entries,
130
+ app: "cms",
131
+ tags: ["regular", entities.entries.name]
132
+ });
133
+ context.db.registry.register({
134
+ item: entities.entriesEs,
135
+ app: "cms",
136
+ tags: ["es", entities.entriesEs.name]
137
+ });
131
138
  /**
132
139
  * Attach the elasticsearch into context if it is not already attached.
133
140
  */
@@ -137,43 +144,34 @@ const createStorageOperations = params => {
137
144
  /**
138
145
  * Pass the plugins to the parent context.
139
146
  */
140
- context.plugins.register([(0, _dynamoDb.default)()]);
147
+ context.plugins.register([(0, _dynamoDb.default)(), (0, _createIndexTaskPlugin.createIndexTaskPluginTest)(), (0, _indices.elasticsearchIndexPlugins)()]);
141
148
  /**
142
- * Collect all required plugins from parent context.
149
+ * We need to fetch all the plugin types in the list from the main container.
150
+ * This way we do not need to register plugins in the storage plugins contains.
143
151
  */
144
- const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
145
- plugins.register(fieldPlugins);
146
- /**
147
- * We need to get all the operator plugins from the main plugin container.
148
- */
149
- const elasticsearchOperatorPlugins = context.plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type);
150
- plugins.register(elasticsearchOperatorPlugins);
151
- /**
152
- * We need to get all the query modifier plugins
153
- */
154
- const queryModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchQueryModifierPlugin.type);
155
- plugins.register(queryModifierPlugins);
156
- /**
157
- * We need to get all the sort modifier plugins
158
- */
159
- const sortModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchSortModifierPlugin.type);
160
- plugins.register(sortModifierPlugins);
161
- /**
162
- * We need to get all the body modifier plugins
163
- */
164
- const bodyModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchBodyModifierPlugin.type);
165
- plugins.register(bodyModifierPlugins);
152
+ const types = [_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
153
+ // Headless CMS
154
+ "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, _apiHeadlessCms.StorageTransformPlugin.type, _plugins2.CmsEntryElasticsearchValuesModifier.type, _api.CompressorPlugin.type];
155
+ for (const type of types) {
156
+ plugins.mergeByType(context.plugins, type);
157
+ }
158
+ entries.dataLoaders.clearAll();
166
159
  },
167
160
  init: async context => {
168
161
  /**
169
162
  * We need to create indexes on before model create and on clone (create from).
170
163
  * Other apps create indexes on locale creation.
171
164
  */
165
+ await (0, _indexes.createElasticsearchIndexesOnLocaleAfterCreate)({
166
+ context,
167
+ client: elasticsearch,
168
+ plugins
169
+ });
172
170
  context.cms.onModelBeforeCreate.subscribe(async ({
173
171
  model
174
172
  }) => {
175
173
  await (0, _createElasticsearchIndex.createElasticsearchIndex)({
176
- elasticsearch,
174
+ client: elasticsearch,
177
175
  model,
178
176
  plugins
179
177
  });
@@ -182,7 +180,7 @@ const createStorageOperations = params => {
182
180
  model
183
181
  }) => {
184
182
  await (0, _createElasticsearchIndex.createElasticsearchIndex)({
185
- elasticsearch,
183
+ client: elasticsearch,
186
184
  model,
187
185
  plugins
188
186
  });
@@ -191,7 +189,7 @@ const createStorageOperations = params => {
191
189
  model
192
190
  }) => {
193
191
  await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
194
- elasticsearch,
192
+ client: elasticsearch,
195
193
  model
196
194
  });
197
195
  });
@@ -199,7 +197,7 @@ const createStorageOperations = params => {
199
197
  model
200
198
  }) => {
201
199
  await (0, _createElasticsearchIndex.createElasticsearchIndex)({
202
- elasticsearch,
200
+ client: elasticsearch,
203
201
  model,
204
202
  plugins
205
203
  });
@@ -211,9 +209,6 @@ const createStorageOperations = params => {
211
209
  system: (0, _system.createSystemStorageOperations)({
212
210
  entity: entities.system
213
211
  }),
214
- settings: (0, _settings.createSettingsStorageOperations)({
215
- entity: entities.settings
216
- }),
217
212
  groups: (0, _group2.createGroupsStorageOperations)({
218
213
  entity: entities.groups,
219
214
  plugins
@@ -222,12 +217,9 @@ const createStorageOperations = params => {
222
217
  entity: entities.models,
223
218
  elasticsearch
224
219
  }),
225
- entries: (0, _entry.createEntriesStorageOperations)({
226
- entity: entities.entries,
227
- esEntity: entities.entriesEs,
228
- plugins,
229
- elasticsearch
230
- })
220
+ entries
231
221
  };
232
222
  };
233
- exports.createStorageOperations = createStorageOperations;
223
+ exports.createStorageOperations = createStorageOperations;
224
+
225
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +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","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 { 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 * 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;AAEA;AAOA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAFA;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UAAU;IACVC,KAAK;IACLC,OAAO;IACPC,cAAc;IACdC,aAAa;IACbC,OAAO,EAAEC;EACb,CAAC,GAAGP,MAAM;EAEV,MAAMQ,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BP,KAAK;IACLE;EACJ,CAAC,CAAC;EACF,MAAMM,0BAA0B,GAAG,IAAAC,4CAAwB,EAAC;IACxDT,KAAK,EAAEC,OAAO;IACdC;EACJ,CAAC,CAAC;EAEF,MAAMQ,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,+BAAoB,EAAC;MAC3BC,UAAU,EAAEC,eAAQ,CAACC,QAAQ;MAC7Bf,KAAK,EAAEM,aAAa;MACpBP,UAAU,EAAEA,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AyD,yCAA+B,EAAC;MACtCD,MAAM,EAAEzD,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFQ,MAAM,EAAE,IAAAkD,qCAA6B,EAAC;MAClCF,MAAM,EAAEzD,QAAQ,CAACS,MAAM;MACvBf;IACJ,CAAC,CAAC;IACFkB,MAAM,EAAE,IAAAgD,oCAA6B,EAAC;MAClCH,MAAM,EAAEzD,QAAQ,CAACY,MAAM;MACvBnB;IACJ,CAAC,CAAC;IACFsB,OAAO,EAAE,IAAA8C,qCAA8B,EAAC;MACpCJ,MAAM,EAAEzD,QAAQ,CAACe,OAAO;MACxB+C,QAAQ,EAAE9D,QAAQ,CAACkB,SAAS;MAC5BxB,OAAO;MACPD;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
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","_api","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","db","registry","register","item","app","tags","createIndexTaskPluginTest","types","ElasticsearchQueryBuilderOperatorPlugin","type","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsElasticsearchModelFieldPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","CmsEntryElasticsearchValuesModifier","CompressorPlugin","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 type { StorageOperationsFactory } from \"~/types\";\nimport { ENTITIES } 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 { ElasticsearchQueryBuilderOperatorPlugin } 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, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createElasticsearchIndexesOnLocaleAfterCreate } from \"~/operations/system/indexes\";\nimport { createIndexTaskPluginTest } from \"~/tasks/createIndexTaskPlugin\";\nimport { CompressorPlugin } from \"@webiny/api\";\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 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 * 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 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 * 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 models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,G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S,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QAC1D,MAAM,IAAAI,kDAAwB,EAAC;UAC3BR,MAAM,EAAEhE,aAAa;UACrBoE;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;MAEFhC,OAAO,CAAC6B,GAAG,CAACQ,iBAAiB,CAACN,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QACzD,MAAM,IAAAC,kDAAwB,EAAC;UAC3BL,MAAM,EAAEhE,aAAa;UACrBoE,KAAK;UACLnE;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC;IACDyE,WAAW,EAAEA,CAAA,KAAMnE,QAAQ;IAC3BoE,QAAQ,EAAEA,CAAA,KAAMxE,aAAa;IAC7ByE,UAAU,EAAEA,CAAA,KAAMvE,0BAA0B;IAC5CG,MAAM,EAAE,IAAAqE,qCAA6B,EAAC;MAClC7C,MAAM,EAAEzB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAAiE,qCAA6B,EAAC;MAClC9C,MAAM,EAAEzB,QAAQ,CAACM,MAAM;MACvBZ;IACJ,CAAC,CAAC;IACFe,MAAM,EAAE,IAAA+D,oCAA6B,EAAC;MAClC/C,MAAM,EAAEzB,QAAQ,CAACS,MAAM;MACvBhB;IACJ,CAAC,CAAC;IACFmB;EACJ,CAAC;AACL,CAAC;AAACnC,OAAA,CAAAU,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type DataLoader from "dataloader";
2
+ export interface CacheKeyParams {
3
+ name: string;
4
+ tenant: string;
5
+ locale: string;
6
+ }
7
+ export interface ClearAllParams {
8
+ tenant: string;
9
+ locale: string;
10
+ }
11
+ export declare class DataLoaderCache {
12
+ private readonly cache;
13
+ getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
14
+ setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
15
+ clearAll(params?: ClearAllParams): void;
16
+ private createKey;
17
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataLoaderCache = void 0;
7
+ class DataLoaderCache {
8
+ cache = {};
9
+ getDataLoader(params) {
10
+ const key = this.createKey(params);
11
+ return this.cache[key] || null;
12
+ }
13
+ setDataLoader(params, dataLoader) {
14
+ const key = this.createKey(params);
15
+ this.cache[key] = dataLoader;
16
+ }
17
+ clearAll(params) {
18
+ if (!params) {
19
+ for (const current in this.cache) {
20
+ this.cache[current].clearAll();
21
+ }
22
+ return;
23
+ }
24
+ const key = this.createKey({
25
+ ...params,
26
+ name: ""
27
+ });
28
+ for (const current in this.cache) {
29
+ if (current.startsWith(key) === false) {
30
+ continue;
31
+ }
32
+ this.cache[current].clearAll();
33
+ }
34
+ }
35
+ createKey(params) {
36
+ return `${params.tenant}_${params.locale}_${params.name}`;
37
+ }
38
+ }
39
+ exports.DataLoaderCache = DataLoaderCache;
40
+
41
+ //# sourceMappingURL=DataLoaderCache.js.map
@@ -0,0 +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 type 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,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACU,MAAM,IAAIV,MAAM,CAACO,IAAI,EAAE;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
+ 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;
9
+
10
+ //# sourceMappingURL=constants.js.map