@webiny/api-headless-cms-ddb-es 0.0.0-unstable.40876133bb → 0.0.0-unstable.496cf268ac

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 (204) hide show
  1. package/configurations.js +0 -8
  2. package/configurations.js.map +1 -1
  3. package/definitions/entry.js +3 -5
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/entryElasticsearch.js +0 -5
  6. package/definitions/entryElasticsearch.js.map +1 -1
  7. package/definitions/group.js +0 -5
  8. package/definitions/group.js.map +1 -1
  9. package/definitions/model.js +22 -5
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/settings.js +0 -5
  12. package/definitions/settings.js.map +1 -1
  13. package/definitions/system.js +0 -5
  14. package/definitions/system.js.map +1 -1
  15. package/definitions/table.js +0 -3
  16. package/definitions/table.js.map +1 -1
  17. package/definitions/tableElasticsearch.js +0 -3
  18. package/definitions/tableElasticsearch.js.map +1 -1
  19. package/dynamoDb/index.d.ts +1 -1
  20. package/dynamoDb/index.js +0 -5
  21. package/dynamoDb/index.js.map +1 -1
  22. package/dynamoDb/storage/date.d.ts +2 -1
  23. package/dynamoDb/storage/date.js +4 -17
  24. package/dynamoDb/storage/date.js.map +1 -1
  25. package/dynamoDb/storage/longText.d.ts +1 -1
  26. package/dynamoDb/storage/longText.js +10 -18
  27. package/dynamoDb/storage/longText.js.map +1 -1
  28. package/dynamoDb/storage/richText.d.ts +1 -1
  29. package/dynamoDb/storage/richText.js +12 -30
  30. package/dynamoDb/storage/richText.js.map +1 -1
  31. package/elasticsearch/createElasticsearchIndex.js +0 -11
  32. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  33. package/elasticsearch/deleteElasticsearchIndex.js +0 -7
  34. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  35. package/elasticsearch/index.js +0 -5
  36. package/elasticsearch/index.js.map +1 -1
  37. package/elasticsearch/indexing/dateTimeIndexing.js +4 -21
  38. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  39. package/elasticsearch/indexing/defaultFieldIndexing.js +15 -10
  40. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  41. package/elasticsearch/indexing/index.js +0 -9
  42. package/elasticsearch/indexing/index.js.map +1 -1
  43. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  44. package/elasticsearch/indexing/longTextIndexing.js +19 -9
  45. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  46. package/elasticsearch/indexing/numberIndexing.js +0 -9
  47. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  48. package/elasticsearch/indexing/objectIndexing.js +3 -30
  49. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  50. package/elasticsearch/indexing/richTextIndexing.js +0 -5
  51. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  52. package/elasticsearch/indices/base.js +0 -3
  53. package/elasticsearch/indices/base.js.map +1 -1
  54. package/elasticsearch/indices/index.js +0 -4
  55. package/elasticsearch/indices/index.js.map +1 -1
  56. package/elasticsearch/indices/japanese.js +0 -3
  57. package/elasticsearch/indices/japanese.js.map +1 -1
  58. package/elasticsearch/search/index.js +0 -4
  59. package/elasticsearch/search/index.js.map +1 -1
  60. package/elasticsearch/search/refSearch.js +4 -8
  61. package/elasticsearch/search/refSearch.js.map +1 -1
  62. package/elasticsearch/search/timeSearch.js +0 -7
  63. package/elasticsearch/search/timeSearch.js.map +1 -1
  64. package/helpers/entryIndexHelpers.js +20 -49
  65. package/helpers/entryIndexHelpers.js.map +1 -1
  66. package/helpers/index.d.ts +0 -1
  67. package/helpers/index.js +0 -15
  68. package/helpers/index.js.map +1 -1
  69. package/index.js +19 -73
  70. package/index.js.map +1 -1
  71. package/operations/entry/dataLoaders.js +0 -52
  72. package/operations/entry/dataLoaders.js.map +1 -1
  73. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  74. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
  75. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  76. package/operations/entry/elasticsearch/body.d.ts +13 -0
  77. package/operations/entry/elasticsearch/body.js +140 -0
  78. package/operations/entry/elasticsearch/body.js.map +1 -0
  79. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  80. package/operations/entry/elasticsearch/fields.js +229 -0
  81. package/operations/entry/elasticsearch/fields.js.map +1 -0
  82. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  83. package/operations/entry/elasticsearch/filtering/applyFiltering.js +57 -0
  84. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  85. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  86. package/operations/entry/elasticsearch/filtering/exec.js +172 -0
  87. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  88. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  89. package/operations/entry/elasticsearch/filtering/index.js +16 -0
  90. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  91. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  92. package/operations/entry/elasticsearch/filtering/path.js +44 -0
  93. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  94. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  95. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
  96. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  97. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  98. package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
  99. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  100. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  101. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
  102. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  103. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  104. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
  105. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  106. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  107. package/operations/entry/elasticsearch/filtering/populated.js +23 -0
  108. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  109. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  110. package/operations/entry/elasticsearch/filtering/values.js +22 -0
  111. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  112. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  113. package/operations/entry/elasticsearch/fullTextSearch.js +89 -0
  114. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  115. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  116. package/operations/entry/elasticsearch/fullTextSearchFields.js +25 -0
  117. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  118. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  119. package/operations/entry/elasticsearch/initialQuery.js +103 -0
  120. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  121. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  122. package/operations/entry/elasticsearch/keyword.js +34 -0
  123. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  124. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  125. package/operations/entry/elasticsearch/plugins/bodyModifier.js +16 -0
  126. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  127. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  128. package/operations/entry/elasticsearch/plugins/operator.js +37 -0
  129. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  130. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  131. package/operations/entry/elasticsearch/plugins/queryModifier.js +16 -0
  132. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  133. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  134. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +7 -9
  135. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  136. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  137. package/operations/entry/elasticsearch/plugins/sortModifier.js +16 -0
  138. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  139. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  140. package/operations/entry/elasticsearch/sort.js +82 -0
  141. package/operations/entry/elasticsearch/sort.js.map +1 -0
  142. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  143. package/{helpers → operations/entry/elasticsearch}/transformValueForSearch.js +7 -6
  144. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  145. package/operations/entry/elasticsearch/types.d.ts +41 -0
  146. package/operations/entry/elasticsearch/types.js +5 -0
  147. package/operations/entry/elasticsearch/types.js.map +1 -0
  148. package/operations/entry/index.d.ts +0 -2
  149. package/operations/entry/index.js +72 -210
  150. package/operations/entry/index.js.map +1 -1
  151. package/operations/entry/keys.js +0 -9
  152. package/operations/entry/keys.js.map +1 -1
  153. package/operations/entry/recordType.d.ts +3 -0
  154. package/operations/entry/recordType.js +18 -0
  155. package/operations/entry/recordType.js.map +1 -0
  156. package/operations/group/index.js +2 -32
  157. package/operations/group/index.js.map +1 -1
  158. package/operations/model/index.js +1 -34
  159. package/operations/model/index.js.map +1 -1
  160. package/operations/settings/index.js +0 -24
  161. package/operations/settings/index.js.map +1 -1
  162. package/operations/system/index.js +0 -17
  163. package/operations/system/index.js.map +1 -1
  164. package/package.json +16 -16
  165. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +1 -0
  166. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +6 -8
  167. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  168. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -6
  169. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
  170. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  171. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
  172. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  173. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -5
  174. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  175. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +1 -0
  176. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +6 -12
  177. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  178. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -0
  179. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +6 -8
  180. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  181. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -0
  182. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +6 -8
  183. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  184. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  185. package/plugins/CmsEntryFilterPlugin.js +24 -0
  186. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  187. package/plugins/index.d.ts +1 -0
  188. package/plugins/index.js +11 -12
  189. package/plugins/index.js.map +1 -1
  190. package/types.js +0 -5
  191. package/types.js.map +1 -1
  192. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  193. package/helpers/createElasticsearchQueryBody.js +0 -611
  194. package/helpers/createElasticsearchQueryBody.js.map +0 -1
  195. package/helpers/fields.d.ts +0 -19
  196. package/helpers/fields.js +0 -205
  197. package/helpers/fields.js.map +0 -1
  198. package/helpers/searchPluginsList.d.ts +0 -6
  199. package/helpers/searchPluginsList.js.map +0 -1
  200. package/helpers/transformValueForSearch.d.ts +0 -12
  201. package/helpers/transformValueForSearch.js.map +0 -1
  202. package/operations/entry/elasticsearchFields.d.ts +0 -2
  203. package/operations/entry/elasticsearchFields.js +0 -38
  204. package/operations/entry/elasticsearchFields.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ElasticsearchQueryBuilderOperatorPlugins } from "../types";
3
+ interface Params {
4
+ plugins: PluginsContainer;
5
+ locale: string;
6
+ }
7
+ export declare const createOperatorPluginList: (params: Params) => ElasticsearchQueryBuilderOperatorPlugins;
8
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createOperatorPluginList = void 0;
7
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
+ const createOperatorPluginList = params => {
9
+ const {
10
+ plugins,
11
+ locale
12
+ } = params;
13
+ /**
14
+ * We always set the last one operator plugin added.
15
+ * This way user can override the plugins.
16
+ */
17
+ return plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
18
+ const operator = plugin.getOperator();
19
+ /**
20
+ * We only allow the plugins which can pass the locale test.
21
+ * The default plugins always return true.
22
+ */
23
+ if (plugin.isLocaleSupported(locale) === false) {
24
+ return acc;
25
+ }
26
+ /**
27
+ * We also only allow the override of the plugins if the new plugin is NOT a default one.
28
+ * If a user sets the plugin name ending with .default, we cannot do anything about it.
29
+ */
30
+ if (!!acc[operator] && (plugin.name || "").match(/\.default$/)) {
31
+ return acc;
32
+ }
33
+ acc[operator] = plugin;
34
+ return acc;
35
+ }, {});
36
+ };
37
+ exports.createOperatorPluginList = createOperatorPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createOperatorPluginList","params","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","operator","getOperator","isLocaleSupported","name","match"],"sources":["operator.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchQueryBuilderOperatorPlugins } from \"../types\";\n\ninterface Params {\n plugins: PluginsContainer;\n locale: string;\n}\nexport const createOperatorPluginList = (\n params: Params\n): ElasticsearchQueryBuilderOperatorPlugins => {\n const { plugins, locale } = params;\n /**\n * We always set the last one operator plugin added.\n * This way user can override the plugins.\n */\n return plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce<ElasticsearchQueryBuilderOperatorPlugins>((acc, plugin) => {\n const operator = plugin.getOperator();\n /**\n * We only allow the plugins which can pass the locale test.\n * The default plugins always return true.\n */\n if (plugin.isLocaleSupported(locale) === false) {\n return acc;\n }\n /**\n * We also only allow the override of the plugins if the new plugin is NOT a default one.\n * If a user sets the plugin name ending with .default, we cannot do anything about it.\n */\n if (!!acc[operator] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[operator] = plugin;\n return acc;\n }, {});\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,wBAAwB,GACjCC,MAAc,IAC6B;EAC3C,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAClC;AACJ;AACA;AACA;EACI,OAAOC,OAAO,CACTE,MAAM,CACHC,yDAAuC,CAACC,IAAI,CAC/C,CACAC,MAAM,CAA2C,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAW,EAAE;IACrC;AACZ;AACA;AACA;IACY,IAAIF,MAAM,CAACG,iBAAiB,CAACT,MAAM,CAAC,KAAK,KAAK,EAAE;MAC5C,OAAOK,GAAG;IACd;IACA;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACA,GAAG,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAACI,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MAC5D,OAAON,GAAG;IACd;IACAA,GAAG,CAACE,QAAQ,CAAC,GAAGD,MAAM;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC;AAAC"}
@@ -0,0 +1,9 @@
1
+ import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ }
8
+ export declare const createQueryModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchQueryModifierPlugin[];
9
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createQueryModifierPluginList = void 0;
7
+ var _plugins = require("../../../../plugins");
8
+ const createQueryModifierPluginList = ({
9
+ plugins,
10
+ model
11
+ }) => {
12
+ return plugins.byType(_plugins.CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
13
+ return !pl.modelId || pl.modelId === model.modelId;
14
+ });
15
+ };
16
+ exports.createQueryModifierPluginList = createQueryModifierPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createQueryModifierPluginList","plugins","model","byType","CmsEntryElasticsearchQueryModifierPlugin","type","filter","pl","modelId"],"sources":["queryModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createQueryModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;AAAA;AAQO,MAAMA,6BAA6B,GAAG,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACzE,OAAOD,OAAO,CACTE,MAAM,CACHC,iDAAwC,CAACC,IAAI,CAChD,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKN,KAAK,CAACM,OAAO;EACtD,CAAC,CAAC;AACV,CAAC;AAAC"}
@@ -0,0 +1,7 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ElasticsearchQuerySearchValuePlugins } from "../types";
3
+ interface Params {
4
+ plugins: PluginsContainer;
5
+ }
6
+ export declare const createSearchPluginList: ({ plugins }: Params) => ElasticsearchQuerySearchValuePlugins;
7
+ export {};
@@ -1,26 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.searchPluginsList = void 0;
9
-
7
+ exports.createSearchPluginList = void 0;
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- const searchPluginsList = plugins => {
13
- return plugins.byType("cms-elastic-search-query-builder-value-search").reduce((plugins, plugin) => {
9
+ var _plugins = require("../../../../plugins");
10
+ const createSearchPluginList = ({
11
+ plugins
12
+ }) => {
13
+ return plugins.byType(_plugins.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type).reduce((plugins, plugin) => {
14
14
  if (plugins[plugin.fieldType]) {
15
15
  throw new _error.default("There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.", "PLUGIN_ALREADY_EXISTS", {
16
16
  fieldType: plugin.fieldType,
17
17
  name: plugin.name || "unknown"
18
18
  });
19
19
  }
20
-
21
20
  plugins[plugin.fieldType] = plugin;
22
21
  return plugins;
23
22
  }, {});
24
23
  };
25
-
26
- exports.searchPluginsList = searchPluginsList;
24
+ exports.createSearchPluginList = createSearchPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSearchPluginList","plugins","byType","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","type","reduce","plugin","fieldType","WebinyError","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"../types\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createSearchPluginList = ({\n plugins\n}: Params): ElasticsearchQuerySearchValuePlugins => {\n return plugins\n .byType<CmsEntryElasticsearchQueryBuilderValueSearchPlugin>(\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type\n )\n .reduce<ElasticsearchQuerySearchValuePlugins>((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 }, {});\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAOO,MAAMA,sBAAsB,GAAG,CAAC;EACnCC;AACI,CAAC,KAA2C;EAChD,OAAOA,OAAO,CACTC,MAAM,CACHC,2DAAkD,CAACC,IAAI,CAC1D,CACAC,MAAM,CAAuC,CAACJ,OAAO,EAAEK,MAAM,KAAK;IAC/D,IAAIL,OAAO,CAACK,MAAM,CAACC,SAAS,CAAC,EAAE;MAC3B,MAAM,IAAIC,cAAW,CACjB,mFAAmF,EACnF,uBAAuB,EACvB;QACID,SAAS,EAAED,MAAM,CAACC,SAAS;QAC3BE,IAAI,EAAEH,MAAM,CAACG,IAAI,IAAI;MACzB,CAAC,CACJ;IACL;IACAR,OAAO,CAACK,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAElC,OAAOL,OAAO;EAClB,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC;AAAC"}
@@ -0,0 +1,9 @@
1
+ import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ }
8
+ export declare const createSortModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchSortModifierPlugin[];
9
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSortModifierPluginList = void 0;
7
+ var _plugins = require("../../../../plugins");
8
+ const createSortModifierPluginList = ({
9
+ plugins,
10
+ model
11
+ }) => {
12
+ return plugins.byType(_plugins.CmsEntryElasticsearchSortModifierPlugin.type).filter(pl => {
13
+ return !pl.modelId || pl.modelId === model.modelId;
14
+ });
15
+ };
16
+ exports.createSortModifierPluginList = createSortModifierPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSortModifierPluginList","plugins","model","byType","CmsEntryElasticsearchSortModifierPlugin","type","filter","pl","modelId"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createSortModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;AAAA;AAQO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHC,gDAAuC,CAACC,IAAI,CAC/C,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKN,KAAK,CAACM,OAAO;EACtD,CAAC,CAAC;AACV,CAAC;AAAC"}
@@ -0,0 +1,12 @@
1
+ import { Sort as esSort } from "@webiny/api-elasticsearch/types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
4
+ import { ModelFields } from "./types";
5
+ interface Params {
6
+ plugins: PluginsContainer;
7
+ sort?: CmsEntryListSort;
8
+ modelFields: ModelFields;
9
+ model: CmsModel;
10
+ }
11
+ export declare const createElasticsearchSort: (params: Params) => esSort;
12
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createElasticsearchSort = void 0;
7
+ var _plugins = require("../../../plugins");
8
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
9
+ var _keyword = require("./keyword");
10
+ var _search = require("./plugins/search");
11
+ var _path = require("./filtering/path");
12
+ const createElasticsearchSort = params => {
13
+ const {
14
+ sort,
15
+ modelFields,
16
+ plugins
17
+ } = params;
18
+ if (!sort || sort.length === 0) {
19
+ return [];
20
+ }
21
+ const searchPlugins = (0, _search.createSearchPluginList)({
22
+ plugins
23
+ });
24
+ const createFieldPath = (0, _path.createFieldPathFactory)({
25
+ plugins: searchPlugins
26
+ });
27
+ const fieldIdToStorageIdIdMap = {};
28
+ const sortPlugins = Object.values(modelFields).reduce((plugins, field) => {
29
+ /**
30
+ * We do not support sorting by nested fields.
31
+ */
32
+ if (field.parents.length > 0) {
33
+ return plugins;
34
+ }
35
+ const {
36
+ fieldId,
37
+ storageId
38
+ } = field.field;
39
+ fieldIdToStorageIdIdMap[fieldId] = fieldId;
40
+ const {
41
+ path
42
+ } = createFieldPath({
43
+ key: storageId,
44
+ field,
45
+ value: "",
46
+ keyword: false
47
+ });
48
+ /**
49
+ * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
50
+ */
51
+ plugins[fieldId] = new _plugins.CmsEntryElasticsearchFieldPlugin({
52
+ unmappedType: field.unmappedType,
53
+ keyword: (0, _keyword.hasKeyword)(field),
54
+ sortable: field.isSortable,
55
+ searchable: field.isSearchable,
56
+ field: fieldId,
57
+ path
58
+ });
59
+ return plugins;
60
+ }, {
61
+ ["*"]: new _plugins.CmsEntryElasticsearchFieldPlugin({
62
+ field: _plugins.CmsEntryElasticsearchFieldPlugin.ALL,
63
+ keyword: false
64
+ })
65
+ });
66
+ const transformedSort = sort.map(value => {
67
+ const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
68
+ if (!matched) {
69
+ return null;
70
+ }
71
+ const [, fieldId, order] = matched;
72
+ if (fieldIdToStorageIdIdMap[fieldId]) {
73
+ return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;
74
+ }
75
+ return value;
76
+ }).filter(Boolean);
77
+ return (0, _apiElasticsearch.createSort)({
78
+ fieldPlugins: sortPlugins,
79
+ sort: transformedSort
80
+ });
81
+ };
82
+ exports.createElasticsearchSort = createElasticsearchSort;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createElasticsearchSort","params","sort","modelFields","plugins","length","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","CmsEntryElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","isSortable","searchable","isSearchable","ALL","transformedSort","map","matched","match","order","filter","Boolean","createSort","fieldPlugins"],"sources":["sort.ts"],"sourcesContent":["import { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins\";\nimport { createSort } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<\n Record<string, CmsEntryElasticsearchFieldPlugin>\n >(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: \"\",\n keyword: false\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new CmsEntryElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.isSortable,\n searchable: field.isSearchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new CmsEntryElasticsearchFieldPlugin({\n field: CmsEntryElasticsearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;AACA;AACA;AAIA;AACA;AACA;AAQO,MAAMA,uBAAuB,GAAIC,MAAc,IAAa;EAC/D,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAO,EAAE;EACb;EAEA,MAAMC,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCH;EACJ,CAAC,CAAC;EAEF,MAAMI,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CL,OAAO,EAAEE;EACb,CAAC,CAAC;EAEF,MAAMI,uBAA+C,GAAG,CAAC,CAAC;EAE1D,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACV,WAAW,CAAC,CAACW,MAAM,CAGjD,CAACV,OAAO,EAAEW,KAAK,KAAK;IAChB;AACZ;AACA;IACY,IAAIA,KAAK,CAACC,OAAO,CAACX,MAAM,GAAG,CAAC,EAAE;MAC1B,OAAOD,OAAO;IAClB;IACA,MAAM;MAAEa,OAAO;MAAEC;IAAU,CAAC,GAAGH,KAAK,CAACA,KAAK;IAE1CL,uBAAuB,CAACO,OAAO,CAAC,GAAGA,OAAO;IAE1C,MAAM;MAAEE;IAAK,CAAC,GAAGX,eAAe,CAAC;MAC7BY,GAAG,EAAEF,SAAS;MACdH,KAAK;MACLM,KAAK,EAAE,EAAE;MACTC,OAAO,EAAE;IACb,CAAC,CAAC;IACF;AACZ;AACA;IACYlB,OAAO,CAACa,OAAO,CAAC,GAAG,IAAIM,yCAAgC,CAAC;MACpDC,YAAY,EAAET,KAAK,CAACS,YAAY;MAChCF,OAAO,EAAE,IAAAG,mBAAU,EAACV,KAAK,CAAC;MAC1BW,QAAQ,EAAEX,KAAK,CAACY,UAAU;MAC1BC,UAAU,EAAEb,KAAK,CAACc,YAAY;MAC9Bd,KAAK,EAAEE,OAAO;MACdE;IACJ,CAAC,CAAC;IACF,OAAOf,OAAO;EAClB,CAAC,EACD;IACI,CAAC,GAAG,GAAG,IAAImB,yCAAgC,CAAC;MACxCR,KAAK,EAAEQ,yCAAgC,CAACO,GAAG;MAC3CR,OAAO,EAAE;IACb,CAAC;EACL,CAAC,CACJ;EAED,MAAMS,eAAe,GAAG7B,IAAI,CACvB8B,GAAG,CAACX,KAAK,IAAI;IACV,MAAMY,OAAO,GAAGZ,KAAK,CAACa,KAAK,CAAC,+BAA+B,CAAC;IAC5D,IAAI,CAACD,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,MAAM,GAAGhB,OAAO,EAAEkB,KAAK,CAAC,GAAGF,OAAO;IAClC,IAAIvB,uBAAuB,CAACO,OAAO,CAAC,EAAE;MAClC,OAAQ,GAAEP,uBAAuB,CAACO,OAAO,CAAE,IAAGkB,KAAM,EAAC;IACzD;IAEA,OAAOd,KAAK;EAChB,CAAC,CAAC,CACDe,MAAM,CAACC,OAAO,CAAa;EAChC,OAAO,IAAAC,4BAAU,EAAC;IACdC,YAAY,EAAE5B,WAAW;IACzBT,IAAI,EAAE6B;EACV,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * We use any for input and output because they really can be anything.
3
+ * Plugin, if exists, makes sure that response value is correct.
4
+ */
5
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
6
+ import { ElasticsearchQuerySearchValuePlugins } from "./types";
7
+ interface Params {
8
+ plugins: ElasticsearchQuerySearchValuePlugins;
9
+ field: CmsModelField;
10
+ value: any;
11
+ }
12
+ /**
13
+ * Transformed value can be anything.
14
+ */
15
+ export declare const transformValueForSearch: (params: Params) => any;
16
+ export {};
@@ -4,26 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.transformValueForSearch = void 0;
7
+ /**
8
+ * We use any for input and output because they really can be anything.
9
+ * Plugin, if exists, makes sure that response value is correct.
10
+ */
7
11
 
8
12
  /**
9
- * Transformed can be anything.
13
+ * Transformed value can be anything.
10
14
  */
11
- const transformValueForSearch = args => {
15
+ const transformValueForSearch = params => {
12
16
  const {
13
17
  field,
14
18
  plugins,
15
19
  value
16
- } = args;
20
+ } = params;
17
21
  const plugin = plugins[field.type];
18
-
19
22
  if (!plugin) {
20
23
  return value;
21
24
  }
22
-
23
25
  return plugin.transform({
24
26
  field,
25
27
  value
26
28
  });
27
29
  };
28
-
29
30
  exports.transformValueForSearch = transformValueForSearch;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["transformValueForSearch","params","field","plugins","value","plugin","type","transform"],"sources":["transformValueForSearch.ts"],"sourcesContent":["/**\n * We use any for input and output because they really can be anything.\n * Plugin, if exists, makes sure that response value is correct.\n */\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"./types\";\n\ninterface Params {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed value can be anything.\n */\nexport const transformValueForSearch = (params: Params): any => {\n const { field, plugins, value } = params;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,MAAc,IAAU;EAC5D,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EACxC,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAI,CAAC;EAClC,IAAI,CAACD,MAAM,EAAE;IACT,OAAOD,KAAK;EAChB;EACA,OAAOC,MAAM,CAACE,SAAS,CAAC;IAAEL,KAAK;IAAEE;EAAM,CAAC,CAAC;AAC7C,CAAC;AAAC"}
@@ -0,0 +1,41 @@
1
+ import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../plugins";
2
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
3
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
4
+ /**
5
+ * ./fields
6
+ */
7
+ declare type ModelFieldPath = string | ((value: string) => string);
8
+ export declare type FieldType = "text" | "date" | "datetime" | "time" | "number" | "boolean" | string;
9
+ export interface ModelFieldParent {
10
+ fieldId: string;
11
+ storageId: string;
12
+ type: FieldType;
13
+ }
14
+ export interface ModelField {
15
+ unmappedType?: string;
16
+ keyword?: boolean;
17
+ isSearchable: boolean;
18
+ isSortable: boolean;
19
+ type: FieldType;
20
+ isSystemField?: boolean;
21
+ field: CmsModelField;
22
+ path?: ModelFieldPath;
23
+ fullTextSearch?: boolean;
24
+ parents: ModelFieldParent[];
25
+ }
26
+ export interface ModelFields {
27
+ [fieldId: string]: ModelField;
28
+ }
29
+ /**
30
+ * ./plugins/operator
31
+ */
32
+ export interface ElasticsearchQueryBuilderOperatorPlugins {
33
+ [key: string]: ElasticsearchQueryBuilderOperatorPlugin;
34
+ }
35
+ /**
36
+ * ./plugins/search
37
+ */
38
+ export interface ElasticsearchQuerySearchValuePlugins {
39
+ [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
40
+ }
41
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\n/**\n * ./fields\n */\ntype ModelFieldPath = string | ((value: string) => string);\n\nexport type FieldType = \"text\" | \"date\" | \"datetime\" | \"time\" | \"number\" | \"boolean\" | string;\n\nexport interface ModelFieldParent {\n fieldId: string;\n storageId: string;\n type: FieldType;\n}\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: FieldType;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n fullTextSearch?: boolean;\n parents: ModelFieldParent[];\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\n/**\n * ./plugins/operator\n */\nexport interface ElasticsearchQueryBuilderOperatorPlugins {\n [key: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n/**\n * ./plugins/search\n */\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n"],"mappings":""}
@@ -2,8 +2,6 @@ import { CmsEntryStorageOperations } from "@webiny/api-headless-cms/types";
2
2
  import { Entity } from "dynamodb-toolbox";
3
3
  import { Client } from "@elastic/elasticsearch";
4
4
  import { PluginsContainer } from "@webiny/plugins";
5
- export declare const createLatestType: () => string;
6
- export declare const createPublishedType: () => string;
7
5
  export interface CreateEntriesStorageOperationsParams {
8
6
  entity: Entity<any>;
9
7
  esEntity: Entity<any>;