@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.5e7233243f

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 (152) 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 +5 -2
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +2 -2
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +2 -2
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +2 -2
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +2 -2
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +2 -2
  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 +79 -45
  31. package/dynamoDb/storage/date.js.map +1 -0
  32. package/dynamoDb/storage/longText.d.ts +7 -4
  33. package/dynamoDb/storage/longText.js +71 -53
  34. package/dynamoDb/storage/longText.js.map +1 -0
  35. package/dynamoDb/storage/richText.d.ts +2 -3
  36. package/dynamoDb/storage/richText.js +84 -66
  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.map +1 -0
  46. package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
  47. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  48. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/index.js.map +1 -0
  50. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  51. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  52. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  53. package/elasticsearch/indexing/objectIndexing.js +32 -9
  54. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  55. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  56. package/elasticsearch/indices/base.d.ts +2 -0
  57. package/elasticsearch/indices/base.js +23 -0
  58. package/elasticsearch/indices/base.js.map +1 -0
  59. package/elasticsearch/indices/index.d.ts +1 -0
  60. package/elasticsearch/indices/index.js +16 -0
  61. package/elasticsearch/indices/index.js.map +1 -0
  62. package/elasticsearch/indices/japanese.d.ts +2 -0
  63. package/elasticsearch/indices/japanese.js +24 -0
  64. package/elasticsearch/indices/japanese.js.map +1 -0
  65. package/elasticsearch/search/index.d.ts +2 -2
  66. package/elasticsearch/search/index.js +3 -5
  67. package/elasticsearch/search/index.js.map +1 -0
  68. package/elasticsearch/search/refSearch.d.ts +2 -3
  69. package/elasticsearch/search/refSearch.js +25 -16
  70. package/elasticsearch/search/refSearch.js.map +1 -0
  71. package/elasticsearch/search/timeSearch.d.ts +2 -3
  72. package/elasticsearch/search/timeSearch.js +22 -14
  73. package/elasticsearch/search/timeSearch.js.map +1 -0
  74. package/helpers/createElasticsearchQueryBody.js +312 -67
  75. package/helpers/createElasticsearchQueryBody.js.map +1 -0
  76. package/helpers/entryIndexHelpers.js +32 -12
  77. package/helpers/entryIndexHelpers.js.map +1 -0
  78. package/helpers/fields.d.ts +4 -62
  79. package/helpers/fields.js +27 -5
  80. package/helpers/fields.js.map +1 -0
  81. package/helpers/index.js.map +1 -0
  82. package/helpers/searchPluginsList.d.ts +2 -2
  83. package/helpers/searchPluginsList.js.map +1 -0
  84. package/helpers/transformValueForSearch.d.ts +5 -2
  85. package/helpers/transformValueForSearch.js +3 -0
  86. package/helpers/transformValueForSearch.js.map +1 -0
  87. package/index.js +61 -23
  88. package/index.js.map +1 -0
  89. package/operations/entry/dataLoaders.d.ts +6 -2
  90. package/operations/entry/dataLoaders.js +26 -6
  91. package/operations/entry/dataLoaders.js.map +1 -0
  92. package/operations/entry/elasticsearchFields.js +3 -0
  93. package/operations/entry/elasticsearchFields.js.map +1 -0
  94. package/operations/entry/index.d.ts +2 -2
  95. package/operations/entry/index.js +475 -162
  96. package/operations/entry/index.js.map +1 -0
  97. package/operations/entry/keys.js.map +1 -0
  98. package/operations/group/index.d.ts +2 -2
  99. package/operations/group/index.js +3 -5
  100. package/operations/group/index.js.map +1 -0
  101. package/operations/model/index.d.ts +2 -2
  102. package/operations/model/index.js +38 -35
  103. package/operations/model/index.js.map +1 -0
  104. package/operations/settings/index.d.ts +2 -2
  105. package/operations/settings/index.js +3 -5
  106. package/operations/settings/index.js.map +1 -0
  107. package/operations/system/index.d.ts +2 -2
  108. package/operations/system/index.js +3 -5
  109. package/operations/system/index.js.map +1 -0
  110. package/package.json +25 -29
  111. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +2 -2
  112. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  113. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  114. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  115. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  116. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  117. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  118. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  119. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  120. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  121. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +2 -2
  122. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  123. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +2 -2
  124. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  125. package/types.d.ts +2 -32
  126. package/types.js +0 -13
  127. package/types.js.map +1 -0
  128. package/upgrades/index.d.ts +1 -1
  129. package/upgrades/index.js +1 -7
  130. package/upgrades/index.js.map +1 -0
  131. package/helpers/operatorPluginsList.d.ts +0 -7
  132. package/helpers/operatorPluginsList.js +0 -30
  133. package/operations/entry/fields.d.ts +0 -3
  134. package/operations/entry/fields.js +0 -60
  135. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  136. package/operations/system/createElasticsearchTemplate.js +0 -62
  137. package/upgrades/utils.d.ts +0 -1
  138. package/upgrades/utils.js +0 -16
  139. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  140. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  141. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  142. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  143. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  144. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  145. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  146. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  147. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  148. package/upgrades/v5.0.0/helpers.js +0 -57
  149. package/upgrades/v5.0.0/index.d.ts +0 -4
  150. package/upgrades/v5.0.0/index.js +0 -232
  151. package/upgrades/v5.8.0/index.d.ts +0 -4
  152. package/upgrades/v5.8.0/index.js +0 -426
@@ -11,9 +11,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
15
 
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
17
 
18
18
  const prepareEntryToIndex = params => {
19
19
  const {
@@ -49,7 +49,7 @@ const prepareEntryToIndex = params => {
49
49
  const rawValues = {}; // We're only interested in current model fields.
50
50
 
51
51
  for (const field of model.fields) {
52
- if (storageEntry.values.hasOwnProperty(field.fieldId) === false) {
52
+ if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
53
53
  continue;
54
54
  }
55
55
 
@@ -66,18 +66,18 @@ const prepareEntryToIndex = params => {
66
66
  plugins,
67
67
  model,
68
68
  field,
69
- rawValue: entry.values[field.fieldId],
70
- value: storageEntry.values[field.fieldId],
69
+ rawValue: entry.values[field.storageId],
70
+ value: storageEntry.values[field.storageId],
71
71
  getFieldIndexPlugin,
72
72
  getFieldTypePlugin
73
73
  });
74
74
 
75
75
  if (typeof value !== "undefined") {
76
- values[field.fieldId] = value;
76
+ values[field.storageId] = value;
77
77
  }
78
78
 
79
79
  if (typeof rawValue !== "undefined") {
80
- rawValues[field.fieldId] = rawValue;
80
+ rawValues[field.storageId] = rawValue;
81
81
  }
82
82
  }
83
83
 
@@ -157,18 +157,18 @@ const extractEntriesFromIndex = ({
157
157
  }
158
158
 
159
159
  try {
160
- indexValues[field.fieldId] = targetFieldPlugin.fromIndex({
160
+ indexValues[field.storageId] = targetFieldPlugin.fromIndex({
161
161
  plugins,
162
162
  model,
163
163
  field,
164
164
  getFieldIndexPlugin,
165
165
  getFieldTypePlugin,
166
- value: entry.values[field.fieldId],
166
+ value: entry.values[field.storageId],
167
167
 
168
168
  /**
169
169
  * Possibly no rawValues so we must check for the existence of the field.
170
170
  */
171
- rawValue: entry.rawValues ? entry.rawValues[field.fieldId] : null
171
+ rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
172
172
  });
173
173
  } catch (ex) {
174
174
  throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
@@ -177,10 +177,30 @@ const extractEntriesFromIndex = ({
177
177
  });
178
178
  }
179
179
  }
180
+ /**
181
+ * Let's have a new entry so we do not modify the original one.
182
+ */
180
183
 
181
- list.push(_objectSpread(_objectSpread({}, entry), {}, {
184
+
185
+ const newEntry = _objectSpread(_objectSpread({}, entry), {}, {
182
186
  values: indexValues
183
- }));
187
+ });
188
+ /**
189
+ * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
190
+ */
191
+ // @ts-ignore
192
+
193
+
194
+ delete newEntry["rawValues"]; // @ts-ignore
195
+
196
+ delete newEntry["TYPE"]; // @ts-ignore
197
+
198
+ delete newEntry["__type"]; // @ts-ignore
199
+
200
+ delete newEntry["latest"]; // @ts-ignore
201
+
202
+ delete newEntry["published"];
203
+ list.push(_objectSpread({}, newEntry));
184
204
  }
185
205
 
186
206
  return list;
@@ -0,0 +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,MAAD,IAA2D;EAC1F,MAAM;IAAEC,OAAF;IAAWC,YAAX;IAAyBC,KAAzB;IAAgCC;EAAhC,IAA0CJ,MAAhD;EACA,MAAM;IAAEK,iBAAF;IAAqBC,uBAArB;IAA8CC;EAA9C,IACFC,wBAAwB,CAAC;IAAEP;EAAF,CAAD,CAD5B;;EAGA,SAASQ,mBAAT,CAA6BC,SAA7B,EAAgD;IAC5C,OAAOL,iBAAiB,CAACK,SAAD,CAAjB,IAAgCJ,uBAAvC;EACH;;EAED,SAASK,kBAAT,CAA4BD,SAA5B,EAA+C;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAD,CAA3B;;IACA,IAAIE,EAAJ,EAAQ;MACJ,OAAOA,EAAP;IACH;;IACD,MAAM,IAAIC,cAAJ,CAAiB,8BAA6BH,SAAU,6BAAxD,CAAN;EACH,CAfyF,CAiB1F;;;EACA,MAAMI,MAA8B,GAAG,EAAvC;EACA,MAAMC,SAAiC,GAAG,EAA1C,CAnB0F,CAqB1F;;EACA,KAAK,MAAMC,KAAX,IAAoBZ,KAAK,CAACa,MAA1B,EAAkC;IAC9B,IAAIf,YAAY,CAACY,MAAb,CAAoBI,cAApB,CAAmCF,KAAK,CAACG,SAAzC,MAAwD,KAA5D,EAAmE;MAC/D;IACH;;IAED,MAAMC,iBAAiB,GAAGX,mBAAmB,CAACO,KAAK,CAACK,IAAP,CAA7C,CAL8B,CAO9B;;IACA,IAAI,CAACD,iBAAD,IAAsB,CAACA,iBAAiB,CAACE,OAA7C,EAAsD;MAClD;IACH;;IAED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D;UAEvDG,KAFuD;UAGvDY,KAHuD;UAIvDP,mBAJuD;UAKvDE,kBALuD;UAMvDY,KAAK,EAAEpB,KAAK,CAACW,MAAN,CAAaE,KAAK,CAACG,SAAnB,CANgD;;UAOvD;AACpB;AACA;UACoBK,QAAQ,EAAErB,KAAK,CAACY,SAAN,GAAkBZ,KAAK,CAACY,SAAN,CAAgBC,KAAK,CAACG,SAAtB,CAAlB,GAAqD;QAVR,CAA5B,CAA/B;MAYH,CAbD,CAaE,OAAOkB,EAAP,EAAW;QACT,MAAM,IAAIxB,cAAJ,CACFwB,EAAE,CAACC,OAAH,IAAc,6CADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,wBAFT,EAGF;UACIvB,KADJ;UAEIb;QAFJ,CAHE,CAAN;MAQH;IACJ;IACD;AACR;AACA;;;IACQ,MAAMqC,QAAkB,mCACjBrC,KADiB;MAEpBW,MAAM,EAAEoB;IAFY,EAAxB;IAIA;AACR;AACA;IACQ;;;IACA,OAAOM,QAAQ,CAAC,WAAD,CAAf,CApDyB,CAqDzB;;IACA,OAAOA,QAAQ,CAAC,MAAD,CAAf,CAtDyB,CAuDzB;;IACA,OAAOA,QAAQ,CAAC,QAAD,CAAf,CAxDyB,CAyDzB;;IACA,OAAOA,QAAQ,CAAC,QAAD,CAAf,CA1DyB,CA2DzB;;IACA,OAAOA,QAAQ,CAAC,WAAD,CAAf;IACAP,IAAI,CAACQ,IAAL,mBAAeD,QAAf;EACH;;EAED,OAAOP,IAAP;AACH,CAnFM"}
@@ -11,67 +11,9 @@ export interface ModelField {
11
11
  field: CmsModelField;
12
12
  path?: ModelFieldPath;
13
13
  }
14
- export declare type ModelFields = Record<string, ModelField>;
15
- export declare const systemFields: {
16
- id: {
17
- type: string;
18
- isSystemField: boolean;
19
- isSearchable: boolean;
20
- isSortable: boolean;
21
- field: CmsModelField;
22
- };
23
- entryId: {
24
- type: string;
25
- isSystemField: boolean;
26
- isSearchable: boolean;
27
- isSortable: boolean;
28
- field: CmsModelField;
29
- };
30
- savedOn: {
31
- type: string;
32
- unmappedType: string;
33
- keyword: boolean;
34
- isSystemField: boolean;
35
- isSearchable: boolean;
36
- isSortable: boolean;
37
- field: CmsModelField;
38
- };
39
- createdOn: {
40
- type: string;
41
- unmappedType: string;
42
- keyword: boolean;
43
- isSystemField: boolean;
44
- isSearchable: boolean;
45
- isSortable: boolean;
46
- field: CmsModelField;
47
- };
48
- createdBy: {
49
- type: string;
50
- unmappedType: any;
51
- isSystemField: boolean;
52
- isSearchable: boolean;
53
- isSortable: boolean;
54
- path: string;
55
- field: CmsModelField;
56
- };
57
- ownedBy: {
58
- type: string;
59
- unmappedType: any;
60
- isSystemField: boolean;
61
- isSearchable: boolean;
62
- isSortable: boolean;
63
- path: string;
64
- field: CmsModelField;
65
- };
66
- version: {
67
- type: string;
68
- unmappedType: any;
69
- keyword: boolean;
70
- isSystemField: boolean;
71
- isSearchable: boolean;
72
- isSortable: boolean;
73
- field: CmsModelField;
74
- };
75
- };
14
+ export interface ModelFields {
15
+ [fieldId: string]: ModelField;
16
+ }
17
+ export declare const systemFields: ModelFields;
76
18
  export declare const createModelFields: (plugins: PluginsContainer, model: CmsModel) => ModelFields;
77
19
  export {};
package/helpers/fields.js CHANGED
@@ -7,11 +7,23 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.systemFields = exports.createModelFields = void 0;
9
9
 
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
10
12
  var _error = _interopRequireDefault(require("@webiny/error"));
11
13
 
14
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
12
20
  const createSystemField = field => {
13
- if (!field.fieldId) {
14
- throw new _error.default(`When creating system field it must have a "entryId".`, "SYSTEM_FIELD_ERROR", {
21
+ if (!field.storageId) {
22
+ throw new _error.default(`When creating system field it must have a "storageId".`, "SYSTEM_FIELD_ERROR", {
23
+ field
24
+ });
25
+ } else if (!field.fieldId) {
26
+ throw new _error.default(`When creating system field it must have a "fieldId".`, "SYSTEM_FIELD_ERROR", {
15
27
  field
16
28
  });
17
29
  } else if (!field.type) {
@@ -20,7 +32,10 @@ const createSystemField = field => {
20
32
  });
21
33
  }
22
34
 
23
- return field;
35
+ return _objectSpread(_objectSpread({}, field), {}, {
36
+ id: field.fieldId,
37
+ label: field.fieldId
38
+ });
24
39
  };
25
40
 
26
41
  const systemFields = {
@@ -30,6 +45,7 @@ const systemFields = {
30
45
  isSearchable: true,
31
46
  isSortable: true,
32
47
  field: createSystemField({
48
+ storageId: "id",
33
49
  fieldId: "id",
34
50
  type: "text"
35
51
  })
@@ -40,6 +56,7 @@ const systemFields = {
40
56
  isSearchable: true,
41
57
  isSortable: true,
42
58
  field: createSystemField({
59
+ storageId: "entryId",
43
60
  fieldId: "entryId",
44
61
  type: "text"
45
62
  })
@@ -52,8 +69,9 @@ const systemFields = {
52
69
  isSearchable: true,
53
70
  isSortable: true,
54
71
  field: createSystemField({
72
+ storageId: "savedOn",
55
73
  fieldId: "savedOn",
56
- type: "date",
74
+ type: "datetime",
57
75
  settings: {
58
76
  type: "dateTimeWithoutTimezone"
59
77
  }
@@ -67,6 +85,7 @@ const systemFields = {
67
85
  isSearchable: true,
68
86
  isSortable: true,
69
87
  field: createSystemField({
88
+ storageId: "createdOn",
70
89
  fieldId: "createdOn",
71
90
  type: "text",
72
91
  settings: {
@@ -82,6 +101,7 @@ const systemFields = {
82
101
  isSortable: false,
83
102
  path: "createdBy.id",
84
103
  field: createSystemField({
104
+ storageId: "createdBy",
85
105
  fieldId: "createdBy",
86
106
  type: "text"
87
107
  })
@@ -94,6 +114,7 @@ const systemFields = {
94
114
  isSortable: false,
95
115
  path: "ownedBy.id",
96
116
  field: createSystemField({
117
+ storageId: "ownedBy",
97
118
  fieldId: "ownedBy",
98
119
  type: "text"
99
120
  })
@@ -106,6 +127,7 @@ const systemFields = {
106
127
  isSearchable: true,
107
128
  isSortable: true,
108
129
  field: createSystemField({
130
+ storageId: "version",
109
131
  fieldId: "version",
110
132
  type: "number"
111
133
  })
@@ -168,7 +190,7 @@ const createModelFields = (plugins, model) => {
168
190
  field
169
191
  };
170
192
  return fields;
171
- }, systemFields);
193
+ }, (0, _cloneDeep.default)(systemFields));
172
194
  };
173
195
 
174
196
  exports.createModelFields = createModelFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSystemField","field","storageId","WebinyError","fieldId","type","id","label","systemFields","isSystemField","isSearchable","isSortable","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","createModelFields","plugins","model","unmappedTypes","byType","reduce","acc","plugin","fieldType","fieldTypePlugins","types","fields","lodashCloneDeep"],"sources":["fields.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport lodashCloneDeep from \"lodash/cloneDeep\";\n\ntype ModelFieldPath = string | ((value: string) => string);\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: string;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\ntype UnmappedFieldTypes = {\n [type: string]: (field: CmsModelField) => string | undefined;\n};\n\ninterface FieldTypePlugin {\n unmappedType?: (field: CmsModelField) => string | undefined;\n isSearchable: boolean;\n isSortable: boolean;\n}\ntype FieldTypePlugins = Record<string, FieldTypePlugin>;\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n if (!field.storageId) {\n throw new WebinyError(\n `When creating system field it must have a \"storageId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.fieldId) {\n throw new WebinyError(\n `When creating system field it must have a \"fieldId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.type) {\n throw new WebinyError(\n `When creating system field it must have a \"type\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n }\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nexport const systemFields: ModelFields = {\n id: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n })\n },\n entryId: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n })\n },\n savedOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n type: \"datetime\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"createdBy.id\",\n field: createSystemField({\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n type: \"text\"\n })\n },\n ownedBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"ownedBy.id\",\n field: createSystemField({\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n type: \"text\"\n })\n },\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n })\n }\n};\n\n/*\n * Create an object with key fieldType and options for that field\n */\nexport const createModelFields = (plugins: PluginsContainer, model: CmsModel): ModelFields => {\n // collect all unmappedType from elastic plugins\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {} as UnmappedFieldTypes);\n /**\n * collect all field types from the plugins\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((types, plugin) => {\n const { fieldType, isSearchable, isSortable } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n isSearchable: isSearchable === true,\n isSortable: isSortable === true\n };\n return types;\n }, {} as FieldTypePlugins);\n\n return model.fields.reduce((fields, field) => {\n const { fieldId, type } = field;\n if (!fieldTypePlugins[type]) {\n throw new WebinyError(`There is no plugin for field type \"${type}\".`);\n }\n const { isSearchable, isSortable, unmappedType } = fieldTypePlugins[type];\n fields[fieldId] = {\n type,\n isSearchable,\n isSortable,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n isSystemField: false,\n field\n };\n\n return fields;\n }, lodashCloneDeep(systemFields));\n};\n"],"mappings":";;;;;;;;;;;AAKA;;AAGA;;;;;;AA+BA,MAAMA,iBAAiB,GAAIC,KAAD,IAAgD;EACtE,IAAI,CAACA,KAAK,CAACC,SAAX,EAAsB;IAClB,MAAM,IAAIC,cAAJ,CACD,wDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARD,MAQO,IAAI,CAACA,KAAK,CAACG,OAAX,EAAoB;IACvB,MAAM,IAAID,cAAJ,CACD,sDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARM,MAQA,IAAI,CAACA,KAAK,CAACI,IAAX,EAAiB;IACpB,MAAM,IAAIF,cAAJ,CACD,mDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH;;EACD,uCACOA,KADP;IAEIK,EAAE,EAAEL,KAAK,CAACG,OAFd;IAGIG,KAAK,EAAEN,KAAK,CAACG;EAHjB;AAKH,CA/BD;;AAiCO,MAAMI,YAAyB,GAAG;EACrCF,EAAE,EAAE;IACAD,IAAI,EAAE,MADN;IAEAI,aAAa,EAAE,IAFf;IAGAC,YAAY,EAAE,IAHd;IAIAC,UAAU,EAAE,IAJZ;IAKAV,KAAK,EAAED,iBAAiB,CAAC;MACrBE,SAAS,EAAE,IADU;MAErBE,OAAO,EAAE,IAFY;MAGrBC,IAAI,EAAE;IAHe,CAAD;EALxB,CADiC;EAYrCO,OAAO,EAAE;IACLP,IAAI,EAAE,MADD;IAELI,aAAa,EAAE,IAFV;IAGLC,YAAY,EAAE,IAHT;IAILC,UAAU,EAAE,IAJP;IAKLV,KAAK,EAAED,iBAAiB,CAAC;MACrBE,SAAS,EAAE,SADU;MAErBE,OAAO,EAAE,SAFY;MAGrBC,IAAI,EAAE;IAHe,CAAD;EALnB,CAZ4B;EAuBrCQ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AAb,CAAoB,CAACM,MAAD,EAASjC,KAAT,KAAmB;IAC1C,MAAM;MAAEG,OAAF;MAAWC;IAAX,IAAoBJ,KAA1B;;IACA,IAAI,CAAC+B,gBAAgB,CAAC3B,IAAD,CAArB,EAA6B;MACzB,MAAM,IAAIF,cAAJ,CAAiB,sCAAqCE,IAAK,IAA3D,CAAN;IACH;;IACD,MAAM;MAAEK,YAAF;MAAgBC,UAAhB;MAA4BG;IAA5B,IAA6CkB,gBAAgB,CAAC3B,IAAD,CAAnE;IACA6B,MAAM,CAAC9B,OAAD,CAAN,GAAkB;MACdC,IADc;MAEdK,YAFc;MAGdC,UAHc;MAIdG,YAAY,EAAE,OAAOA,YAAP,KAAwB,UAAxB,GAAqCA,YAAY,CAACb,KAAD,CAAjD,GAA2DkB,SAJ3D;MAKdV,aAAa,EAAE,KALD;MAMdR;IANc,CAAlB;IASA,OAAOiC,MAAP;EACH,CAhBM,EAgBJ,IAAAC,kBAAA,EAAgB3B,YAAhB,CAhBI,CAAP;AAiBH,CA3CM"}
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createElasticsearchQueryBody\";\nexport * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1,6 +1,6 @@
1
- import { ElasticsearchQueryBuilderValueSearchPlugin } from "../types";
2
1
  import { PluginsContainer } from "@webiny/plugins";
2
+ import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
3
3
  export interface ElasticsearchQuerySearchValuePlugins {
4
- [fieldType: string]: ElasticsearchQueryBuilderValueSearchPlugin;
4
+ [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
5
5
  }
6
6
  export declare const searchPluginsList: (plugins: PluginsContainer) => ElasticsearchQuerySearchValuePlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["searchPluginsList","plugins","byType","reduce","plugin","fieldType","WebinyError","name"],"sources":["searchPluginsList.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n\nexport const searchPluginsList = (\n plugins: PluginsContainer\n): ElasticsearchQuerySearchValuePlugins => {\n return plugins\n .byType<CmsEntryElasticsearchQueryBuilderValueSearchPlugin>(\n \"cms-elastic-search-query-builder-value-search\"\n )\n .reduce((plugins, plugin) => {\n if (plugins[plugin.fieldType]) {\n throw new WebinyError(\n \"There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.\",\n \"PLUGIN_ALREADY_EXISTS\",\n {\n fieldType: plugin.fieldType,\n name: plugin.name || \"unknown\"\n }\n );\n }\n plugins[plugin.fieldType] = plugin;\n\n return plugins;\n }, {} as ElasticsearchQuerySearchValuePlugins);\n};\n"],"mappings":";;;;;;;;;AAAA;;AAQO,MAAMA,iBAAiB,GAC1BC,OAD6B,IAEU;EACvC,OAAOA,OAAO,CACTC,MADE,CAEC,+CAFD,EAIFC,MAJE,CAIK,CAACF,OAAD,EAAUG,MAAV,KAAqB;IACzB,IAAIH,OAAO,CAACG,MAAM,CAACC,SAAR,CAAX,EAA+B;MAC3B,MAAM,IAAIC,cAAJ,CACF,mFADE,EAEF,uBAFE,EAGF;QACID,SAAS,EAAED,MAAM,CAACC,SADtB;QAEIE,IAAI,EAAEH,MAAM,CAACG,IAAP,IAAe;MAFzB,CAHE,CAAN;IAQH;;IACDN,OAAO,CAACG,MAAM,CAACC,SAAR,CAAP,GAA4BD,MAA5B;IAEA,OAAOH,OAAP;EACH,CAlBE,EAkBA,EAlBA,CAAP;AAmBH,CAtBM"}
@@ -1,9 +1,12 @@
1
1
  import { ElasticsearchQuerySearchValuePlugins } from "./searchPluginsList";
2
2
  import { CmsModelField } from "@webiny/api-headless-cms/types";
3
- interface Params {
3
+ interface TransformValueForSearchParams {
4
4
  plugins: ElasticsearchQuerySearchValuePlugins;
5
5
  field: CmsModelField;
6
6
  value: any;
7
7
  }
8
- export declare const transformValueForSearch: (args: Params) => any;
8
+ /**
9
+ * Transformed can be anything.
10
+ */
11
+ export declare const transformValueForSearch: (args: TransformValueForSearchParams) => any;
9
12
  export {};
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.transformValueForSearch = void 0;
7
7
 
8
+ /**
9
+ * Transformed can be anything.
10
+ */
8
11
  const transformValueForSearch = args => {
9
12
  const {
10
13
  field,
@@ -0,0 +1 @@
1
+ {"version":3,"names":["transformValueForSearch","args","field","plugins","value","plugin","type","transform"],"sources":["transformValueForSearch.ts"],"sourcesContent":["import { ElasticsearchQuerySearchValuePlugins } from \"./searchPluginsList\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ninterface TransformValueForSearchParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed can be anything.\n */\nexport const transformValueForSearch = (args: TransformValueForSearchParams): any => {\n const { field, plugins, value } = args;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;;AASA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,IAAD,IAA8C;EACjF,MAAM;IAAEC,KAAF;IAASC,OAAT;IAAkBC;EAAlB,IAA4BH,IAAlC;EACA,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAP,CAAtB;;EACA,IAAI,CAACD,MAAL,EAAa;IACT,OAAOD,KAAP;EACH;;EACD,OAAOC,MAAM,CAACE,SAAP,CAAiB;IAAEL,KAAF;IAASE;EAAT,CAAjB,CAAP;AACH,CAPM"}
package/index.js CHANGED
@@ -39,7 +39,7 @@ var _system2 = require("./definitions/system");
39
39
 
40
40
  var _settings2 = require("./definitions/settings");
41
41
 
42
- var _createElasticsearchTemplate = require("./operations/system/createElasticsearchTemplate");
42
+ var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
43
43
 
44
44
  var _plugins = require("@webiny/plugins");
45
45
 
@@ -49,15 +49,18 @@ var _operators = require("@webiny/api-elasticsearch/operators");
49
49
 
50
50
  var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
51
51
 
52
+ var _indices = require("./elasticsearch/indices");
53
+
54
+ var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
55
+
52
56
  const createStorageOperations = params => {
53
57
  const {
54
- attributes = {},
58
+ attributes,
55
59
  table,
56
60
  esTable,
57
61
  documentClient,
58
62
  elasticsearch,
59
- plugins: customPlugins,
60
- modelFieldToGraphQLPlugins
63
+ plugins: userPlugins
61
64
  } = params;
62
65
  const tableInstance = (0, _table.createTable)({
63
66
  table,
@@ -71,43 +74,43 @@ const createStorageOperations = params => {
71
74
  settings: (0, _settings2.createSettingsEntity)({
72
75
  entityName: _types.ENTITIES.SETTINGS,
73
76
  table: tableInstance,
74
- attributes: attributes[_types.ENTITIES.SETTINGS]
77
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
75
78
  }),
76
79
  system: (0, _system2.createSystemEntity)({
77
80
  entityName: _types.ENTITIES.SYSTEM,
78
81
  table: tableInstance,
79
- attributes: attributes[_types.ENTITIES.SYSTEM]
82
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
80
83
  }),
81
84
  groups: (0, _group.createGroupEntity)({
82
85
  entityName: _types.ENTITIES.GROUPS,
83
86
  table: tableInstance,
84
- attributes: attributes[_types.ENTITIES.GROUPS]
87
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
85
88
  }),
86
89
  models: (0, _model2.createModelEntity)({
87
90
  entityName: _types.ENTITIES.MODELS,
88
91
  table: tableInstance,
89
- attributes: attributes[_types.ENTITIES.MODELS]
92
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
90
93
  }),
91
94
  entries: (0, _entry2.createEntryEntity)({
92
95
  entityName: _types.ENTITIES.ENTRIES,
93
96
  table: tableInstance,
94
- attributes: attributes[_types.ENTITIES.ENTRIES]
97
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
95
98
  }),
96
99
  entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
97
100
  entityName: _types.ENTITIES.ENTRIES_ES,
98
101
  table: tableElasticsearchInstance,
99
- attributes: attributes[_types.ENTITIES.ENTRIES_ES]
102
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
100
103
  })
101
104
  };
102
105
  const plugins = new _plugins.PluginsContainer([
103
106
  /**
104
107
  * User defined custom plugins.
105
108
  */
106
- ...(customPlugins || []),
109
+ ...(userPlugins || []),
107
110
  /**
108
111
  * Plugins of type CmsModelFieldToGraphQLPlugin.
109
112
  */
110
- modelFieldToGraphQLPlugins,
113
+
111
114
  /**
112
115
  * Elasticsearch field definitions for the entry record.
113
116
  */
@@ -127,21 +130,56 @@ const createStorageOperations = params => {
127
130
  /**
128
131
  * Field plugins for Elasticsearch.
129
132
  */
130
- (0, _elasticsearch.default)()]);
133
+ (0, _elasticsearch.default)(),
134
+ /**
135
+ * Built-in Elasticsearch index templates.
136
+ */
137
+ (0, _indices.elasticsearchIndexPlugins)()]);
131
138
  return {
132
- init: async cms => {
133
- cms.onBeforeSystemInstall.subscribe(async () => {
134
- await (0, _createElasticsearchTemplate.createElasticsearchTemplate)({
135
- elasticsearch
139
+ beforeInit: async context => {
140
+ /**
141
+ * Collect all required plugins from parent context.
142
+ */
143
+ const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
144
+ plugins.register(fieldPlugins);
145
+ /**
146
+ * Pass the plugins to the parent context.
147
+ */
148
+
149
+ context.plugins.register([(0, _dynamoDb.default)()]);
150
+ },
151
+ init: async context => {
152
+ /**
153
+ * We need to create indexes on before model create and on clone (create from).
154
+ * Other apps create indexes on locale creation.
155
+ */
156
+ context.cms.onBeforeModelCreate.subscribe(async ({
157
+ model
158
+ }) => {
159
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
160
+ elasticsearch,
161
+ model,
162
+ plugins
163
+ });
164
+ });
165
+ context.cms.onBeforeModelCreateFrom.subscribe(async ({
166
+ model
167
+ }) => {
168
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
169
+ elasticsearch,
170
+ model,
171
+ plugins
172
+ });
173
+ });
174
+ context.cms.onAfterModelDelete.subscribe(async ({
175
+ model
176
+ }) => {
177
+ await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
178
+ elasticsearch,
179
+ model
136
180
  });
137
181
  });
138
182
  },
139
- plugins: [
140
- /**
141
- * Field plugins for DynamoDB.
142
- * We must pass them to the base application.
143
- */
144
- (0, _dynamoDb.default)()],
145
183
  getEntities: () => entities,
146
184
  getTable: () => tableInstance,
147
185
  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","init","cms","onBeforeModelCreate","subscribe","model","createElasticsearchIndex","onBeforeModelCreateFrom","onAfterModelDelete","deleteElasticsearchIndex","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 { getElasticsearchOperators } from \"@webiny/api-elasticsearch/operators\";\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\";\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 * User defined custom plugins.\n */\n ...(userPlugins || []),\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\n return {\n beforeInit: async context => {\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 /**\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.onBeforeModelCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onBeforeModelCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onAfterModelDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\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;;AACA;;AACA;;AACA;;AAGO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UADE;IAEFC,KAFE;IAGFC,OAHE;IAIFC,cAJE;IAKFC,aALE;IAMFC,OAAO,EAAEC;EANP,IAOFP,MAPJ;EASA,MAAMQ,aAAa,GAAG,IAAAC,kBAAA,EAAY;IAC9BP,KAD8B;IAE9BE;EAF8B,CAAZ,CAAtB;EAIA,MAAMM,0BAA0B,GAAG,IAAAC,4CAAA,EAAyB;IACxDT,KAAK,EAAEC,OADiD;IAExDC;EAFwD,CAAzB,CAAnC;EAKA,MAAMQ,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,+BAAA,EAAqB;MAC3BC,UAAU,EAAEC,eAAA,CAASC,QADM;MAE3Bf,KAAK,EAAEM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EAAyB;UAC3BhD,aAD2B;UAE3B4C;QAF2B,CAAzB,CAAN;MAIH,CALD;IAMH,CAxCE;IAyCHK,WAAW,EAAE,MAAM1C,QAzChB;IA0CH2C,QAAQ,EAAE,MAAM/C,aA1Cb;IA2CHgD,UAAU,EAAE,MAAM9C,0BA3Cf;IA4CHQ,MAAM,EAAE,IAAAuC,qCAAA,EAA8B;MAClCC,MAAM,EAAE9C,QAAQ,CAACM;IADiB,CAA9B,CA5CL;IA+CHL,QAAQ,EAAE,IAAA8C,yCAAA,EAAgC;MACtCD,MAAM,EAAE9C,QAAQ,CAACC;IADqB,CAAhC,CA/CP;IAkDHQ,MAAM,EAAE,IAAAuC,qCAAA,EAA8B;MAClCF,MAAM,EAAE9C,QAAQ,CAACS,MADiB;MAElCf;IAFkC,CAA9B,CAlDL;IAsDHkB,MAAM,EAAE,IAAAqC,oCAAA,EAA8B;MAClCH,MAAM,EAAE9C,QAAQ,CAACY,MADiB;MAElCnB;IAFkC,CAA9B,CAtDL;IA0DHsB,OAAO,EAAE,IAAAmC,qCAAA,EAA+B;MACpCJ,MAAM,EAAE9C,QAAQ,CAACe,OADmB;MAEpCoC,QAAQ,EAAEnD,QAAQ,CAACkB,SAFiB;MAGpCxB,OAHoC;MAIpCD;IAJoC,CAA/B;EA1DN,CAAP;AAiEH,CAvJM"}
@@ -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;