@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.3386f66516

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 (243) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +18 -7
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +6 -7
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -7
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -7
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +8 -7
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -7
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -7
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js.map +1 -0
  24. package/definitions/tableElasticsearch.d.ts +2 -2
  25. package/definitions/tableElasticsearch.js.map +1 -0
  26. package/dynamoDb/index.d.ts +1 -1
  27. package/dynamoDb/index.js +4 -6
  28. package/dynamoDb/index.js.map +1 -0
  29. package/dynamoDb/storage/date.d.ts +3 -3
  30. package/dynamoDb/storage/date.js +80 -46
  31. package/dynamoDb/storage/date.js.map +1 -0
  32. package/dynamoDb/storage/longText.d.ts +7 -4
  33. package/dynamoDb/storage/longText.js +79 -54
  34. package/dynamoDb/storage/longText.js.map +1 -0
  35. package/dynamoDb/storage/richText.d.ts +2 -3
  36. package/dynamoDb/storage/richText.js +85 -67
  37. package/dynamoDb/storage/richText.js.map +1 -0
  38. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  39. package/elasticsearch/createElasticsearchIndex.js +60 -0
  40. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  41. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  42. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  43. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  44. package/elasticsearch/index.d.ts +1 -1
  45. package/elasticsearch/index.js +1 -1
  46. package/elasticsearch/index.js.map +1 -0
  47. package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
  48. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  50. package/elasticsearch/indexing/index.js +1 -1
  51. package/elasticsearch/indexing/index.js.map +1 -0
  52. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  53. package/elasticsearch/indexing/longTextIndexing.js +20 -4
  54. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  55. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  56. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  57. package/elasticsearch/indexing/objectIndexing.js +32 -9
  58. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  59. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  60. package/elasticsearch/indices/base.d.ts +2 -0
  61. package/elasticsearch/indices/base.js +15 -0
  62. package/elasticsearch/indices/base.js.map +1 -0
  63. package/elasticsearch/indices/index.d.ts +1 -0
  64. package/elasticsearch/indices/index.js +16 -0
  65. package/elasticsearch/indices/index.js.map +1 -0
  66. package/elasticsearch/indices/japanese.d.ts +2 -0
  67. package/elasticsearch/indices/japanese.js +16 -0
  68. package/elasticsearch/indices/japanese.js.map +1 -0
  69. package/elasticsearch/search/index.d.ts +2 -2
  70. package/elasticsearch/search/index.js +3 -5
  71. package/elasticsearch/search/index.js.map +1 -0
  72. package/elasticsearch/search/refSearch.d.ts +2 -3
  73. package/elasticsearch/search/refSearch.js +27 -16
  74. package/elasticsearch/search/refSearch.js.map +1 -0
  75. package/elasticsearch/search/timeSearch.d.ts +2 -3
  76. package/elasticsearch/search/timeSearch.js +22 -14
  77. package/elasticsearch/search/timeSearch.js.map +1 -0
  78. package/helpers/entryIndexHelpers.js +33 -18
  79. package/helpers/entryIndexHelpers.js.map +1 -0
  80. package/helpers/index.d.ts +0 -1
  81. package/helpers/index.js +0 -13
  82. package/helpers/index.js.map +1 -0
  83. package/index.d.ts +1 -0
  84. package/index.js +132 -34
  85. package/index.js.map +1 -0
  86. package/operations/entry/dataLoaders.d.ts +6 -2
  87. package/operations/entry/dataLoaders.js +31 -13
  88. package/operations/entry/dataLoaders.js.map +1 -0
  89. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  90. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  91. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  92. package/operations/entry/elasticsearch/body.d.ts +13 -0
  93. package/operations/entry/elasticsearch/body.js +162 -0
  94. package/operations/entry/elasticsearch/body.js.map +1 -0
  95. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  96. package/operations/entry/elasticsearch/fields.js +248 -0
  97. package/operations/entry/elasticsearch/fields.js.map +1 -0
  98. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  99. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  100. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  101. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  102. package/operations/entry/elasticsearch/filtering/exec.js +215 -0
  103. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  104. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  105. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  106. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  107. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  108. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  109. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  110. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  111. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  112. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  113. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  114. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  115. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  116. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  117. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  118. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  119. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  120. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  121. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  122. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  123. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  124. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  125. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  126. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  127. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  128. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  129. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  130. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  131. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  132. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  133. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  134. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  135. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  136. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  137. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  138. package/operations/entry/elasticsearch/keyword.js +38 -0
  139. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  140. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  141. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  142. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  143. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  144. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  145. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  146. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  147. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  148. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  149. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  150. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -5
  151. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  152. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  153. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  154. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  155. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  156. package/operations/entry/elasticsearch/sort.js +97 -0
  157. package/operations/entry/elasticsearch/sort.js.map +1 -0
  158. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  159. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  160. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  161. package/operations/entry/elasticsearch/types.d.ts +41 -0
  162. package/operations/entry/elasticsearch/types.js +5 -0
  163. package/operations/entry/elasticsearch/types.js.map +1 -0
  164. package/operations/entry/index.d.ts +2 -4
  165. package/operations/entry/index.js +473 -374
  166. package/operations/entry/index.js.map +1 -0
  167. package/operations/entry/keys.js.map +1 -0
  168. package/operations/entry/recordType.d.ts +3 -0
  169. package/operations/entry/recordType.js +24 -0
  170. package/operations/entry/recordType.js.map +1 -0
  171. package/operations/group/index.d.ts +2 -2
  172. package/operations/group/index.js +8 -15
  173. package/operations/group/index.js.map +1 -0
  174. package/operations/model/index.d.ts +2 -2
  175. package/operations/model/index.js +38 -39
  176. package/operations/model/index.js.map +1 -0
  177. package/operations/settings/index.d.ts +2 -2
  178. package/operations/settings/index.js +7 -13
  179. package/operations/settings/index.js.map +1 -0
  180. package/operations/system/index.d.ts +2 -2
  181. package/operations/system/index.js +5 -11
  182. package/operations/system/index.js.map +1 -0
  183. package/package.json +24 -29
  184. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
  185. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +11 -5
  186. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  187. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  188. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
  189. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  190. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  191. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  192. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  193. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  194. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  195. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  196. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
  197. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +11 -5
  198. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  199. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
  200. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +11 -5
  201. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  202. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  203. package/plugins/CmsEntryFilterPlugin.js +31 -0
  204. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  205. package/plugins/index.d.ts +6 -0
  206. package/plugins/index.js +83 -0
  207. package/plugins/index.js.map +1 -0
  208. package/types.d.ts +7 -34
  209. package/types.js +0 -13
  210. package/types.js.map +1 -0
  211. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  212. package/helpers/createElasticsearchQueryBody.js +0 -375
  213. package/helpers/fields.d.ts +0 -77
  214. package/helpers/fields.js +0 -174
  215. package/helpers/operatorPluginsList.d.ts +0 -7
  216. package/helpers/operatorPluginsList.js +0 -30
  217. package/helpers/searchPluginsList.d.ts +0 -6
  218. package/helpers/transformValueForSearch.d.ts +0 -9
  219. package/helpers/transformValueForSearch.js +0 -26
  220. package/operations/entry/elasticsearchFields.d.ts +0 -2
  221. package/operations/entry/elasticsearchFields.js +0 -32
  222. package/operations/entry/fields.d.ts +0 -3
  223. package/operations/entry/fields.js +0 -60
  224. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  225. package/operations/system/createElasticsearchTemplate.js +0 -62
  226. package/upgrades/index.d.ts +0 -2
  227. package/upgrades/index.js +0 -16
  228. package/upgrades/utils.d.ts +0 -1
  229. package/upgrades/utils.js +0 -16
  230. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  231. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  232. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  233. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  234. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  235. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  236. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  237. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  238. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  239. package/upgrades/v5.0.0/helpers.js +0 -57
  240. package/upgrades/v5.0.0/index.d.ts +0 -4
  241. package/upgrades/v5.0.0/index.js +0 -232
  242. package/upgrades/v5.8.0/index.d.ts +0 -4
  243. package/upgrades/v5.8.0/index.js +0 -426
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createElasticsearchSort = void 0;
7
+
8
+ var _plugins = require("../../../plugins");
9
+
10
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
11
+
12
+ var _keyword = require("./keyword");
13
+
14
+ var _search = require("./plugins/search");
15
+
16
+ var _path = require("./filtering/path");
17
+
18
+ const createElasticsearchSort = params => {
19
+ const {
20
+ sort,
21
+ modelFields,
22
+ plugins
23
+ } = params;
24
+
25
+ if (!sort || sort.length === 0) {
26
+ return [];
27
+ }
28
+
29
+ const searchPlugins = (0, _search.createSearchPluginList)({
30
+ plugins
31
+ });
32
+ const createFieldPath = (0, _path.createFieldPathFactory)({
33
+ plugins: searchPlugins
34
+ });
35
+ const fieldIdToStorageIdIdMap = {};
36
+ const sortPlugins = Object.values(modelFields).reduce((plugins, field) => {
37
+ /**
38
+ * We do not support sorting by nested fields.
39
+ */
40
+ if (field.parents.length > 0) {
41
+ return plugins;
42
+ }
43
+
44
+ const {
45
+ fieldId,
46
+ storageId
47
+ } = field.field;
48
+ fieldIdToStorageIdIdMap[fieldId] = fieldId;
49
+ const {
50
+ path
51
+ } = createFieldPath({
52
+ key: storageId,
53
+ field,
54
+ value: "",
55
+ keyword: false
56
+ });
57
+ /**
58
+ * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
59
+ */
60
+
61
+ plugins[fieldId] = new _plugins.CmsEntryElasticsearchFieldPlugin({
62
+ unmappedType: field.unmappedType,
63
+ keyword: (0, _keyword.hasKeyword)(field),
64
+ sortable: field.isSortable,
65
+ searchable: field.isSearchable,
66
+ field: fieldId,
67
+ path
68
+ });
69
+ return plugins;
70
+ }, {
71
+ ["*"]: new _plugins.CmsEntryElasticsearchFieldPlugin({
72
+ field: _plugins.CmsEntryElasticsearchFieldPlugin.ALL,
73
+ keyword: false
74
+ })
75
+ });
76
+ const transformedSort = sort.map(value => {
77
+ const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
78
+
79
+ if (!matched) {
80
+ return null;
81
+ }
82
+
83
+ const [, fieldId, order] = matched;
84
+
85
+ if (fieldIdToStorageIdIdMap[fieldId]) {
86
+ return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;
87
+ }
88
+
89
+ return value;
90
+ }).filter(Boolean);
91
+ return (0, _apiElasticsearch.createSort)({
92
+ fieldPlugins: sortPlugins,
93
+ sort: transformedSort
94
+ });
95
+ };
96
+
97
+ 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,MAAD,IAA4B;EAC/D,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC;EAArB,IAAiCH,MAAvC;;EAEA,IAAI,CAACC,IAAD,IAASA,IAAI,CAACG,MAAL,KAAgB,CAA7B,EAAgC;IAC5B,OAAO,EAAP;EACH;;EAED,MAAMC,aAAa,GAAG,IAAAC,8BAAA,EAAuB;IACzCH;EADyC,CAAvB,CAAtB;EAIA,MAAMI,eAAe,GAAG,IAAAC,4BAAA,EAAuB;IAC3CL,OAAO,EAAEE;EADkC,CAAvB,CAAxB;EAIA,MAAMI,uBAA+C,GAAG,EAAxD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAAcV,WAAd,EAA2BW,MAA3B,CAGhB,CAACV,OAAD,EAAUW,KAAV,KAAoB;IAChB;AACZ;AACA;IACY,IAAIA,KAAK,CAACC,OAAN,CAAcX,MAAd,GAAuB,CAA3B,EAA8B;MAC1B,OAAOD,OAAP;IACH;;IACD,MAAM;MAAEa,OAAF;MAAWC;IAAX,IAAyBH,KAAK,CAACA,KAArC;IAEAL,uBAAuB,CAACO,OAAD,CAAvB,GAAmCA,OAAnC;IAEA,MAAM;MAAEE;IAAF,IAAWX,eAAe,CAAC;MAC7BY,GAAG,EAAEF,SADwB;MAE7BH,KAF6B;MAG7BM,KAAK,EAAE,EAHsB;MAI7BC,OAAO,EAAE;IAJoB,CAAD,CAAhC;IAMA;AACZ;AACA;;IACYlB,OAAO,CAACa,OAAD,CAAP,GAAmB,IAAIM,yCAAJ,CAAqC;MACpDC,YAAY,EAAET,KAAK,CAACS,YADgC;MAEpDF,OAAO,EAAE,IAAAG,mBAAA,EAAWV,KAAX,CAF2C;MAGpDW,QAAQ,EAAEX,KAAK,CAACY,UAHoC;MAIpDC,UAAU,EAAEb,KAAK,CAACc,YAJkC;MAKpDd,KAAK,EAAEE,OAL6C;MAMpDE;IANoD,CAArC,CAAnB;IAQA,OAAOf,OAAP;EACH,CAhCe,EAiChB;IACI,CAAC,GAAD,GAAO,IAAImB,yCAAJ,CAAqC;MACxCR,KAAK,EAAEQ,yCAAA,CAAiCO,GADA;MAExCR,OAAO,EAAE;IAF+B,CAArC;EADX,CAjCgB,CAApB;EAyCA,MAAMS,eAAe,GAAG7B,IAAI,CACvB8B,GADmB,CACfX,KAAK,IAAI;IACV,MAAMY,OAAO,GAAGZ,KAAK,CAACa,KAAN,CAAY,+BAAZ,CAAhB;;IACA,IAAI,CAACD,OAAL,EAAc;MACV,OAAO,IAAP;IACH;;IACD,MAAM,GAAGhB,OAAH,EAAYkB,KAAZ,IAAqBF,OAA3B;;IACA,IAAIvB,uBAAuB,CAACO,OAAD,CAA3B,EAAsC;MAClC,OAAQ,GAAEP,uBAAuB,CAACO,OAAD,CAAU,IAAGkB,KAAM,EAApD;IACH;;IAED,OAAOd,KAAP;EACH,CAZmB,EAanBe,MAbmB,CAaZC,OAbY,CAAxB;EAcA,OAAO,IAAAC,4BAAA,EAAW;IACdC,YAAY,EAAE5B,WADA;IAEdT,IAAI,EAAE6B;EAFQ,CAAX,CAAP;AAIH,CA5EM"}
@@ -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 {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transformValueForSearch = void 0;
7
+
8
+ /**
9
+ * We use any for input and output because they really can be anything.
10
+ * Plugin, if exists, makes sure that response value is correct.
11
+ */
12
+
13
+ /**
14
+ * Transformed value can be anything.
15
+ */
16
+ const transformValueForSearch = params => {
17
+ const {
18
+ field,
19
+ plugins,
20
+ value
21
+ } = params;
22
+ const plugin = plugins[field.type];
23
+
24
+ if (!plugin) {
25
+ return value;
26
+ }
27
+
28
+ return plugin.transform({
29
+ field,
30
+ value
31
+ });
32
+ };
33
+
34
+ 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,MAAD,IAAyB;EAC5D,MAAM;IAAEC,KAAF;IAASC,OAAT;IAAkBC;EAAlB,IAA4BH,MAAlC;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"}
@@ -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,12 +2,10 @@ 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
- export interface Params {
5
+ export interface CreateEntriesStorageOperationsParams {
8
6
  entity: Entity<any>;
9
7
  esEntity: Entity<any>;
10
8
  elasticsearch: Client;
11
9
  plugins: PluginsContainer;
12
10
  }
13
- export declare const createEntriesStorageOperations: (params: Params) => CmsEntryStorageOperations;
11
+ export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;