@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f

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 (255) hide show
  1. package/configurations.d.ts +3 -3
  2. package/configurations.js +13 -10
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +9 -12
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -12
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -12
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +25 -12
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -12
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -12
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js +0 -3
  24. package/definitions/table.js.map +1 -0
  25. package/definitions/tableElasticsearch.d.ts +2 -2
  26. package/definitions/tableElasticsearch.js +0 -3
  27. package/definitions/tableElasticsearch.js.map +1 -0
  28. package/dynamoDb/index.d.ts +1 -1
  29. package/dynamoDb/index.js +4 -11
  30. package/dynamoDb/index.js.map +1 -0
  31. package/dynamoDb/storage/date.d.ts +3 -3
  32. package/dynamoDb/storage/date.js +74 -53
  33. package/dynamoDb/storage/date.js.map +1 -0
  34. package/dynamoDb/storage/longText.d.ts +7 -4
  35. package/dynamoDb/storage/longText.js +73 -63
  36. package/dynamoDb/storage/longText.js.map +1 -0
  37. package/dynamoDb/storage/richText.d.ts +2 -3
  38. package/dynamoDb/storage/richText.js +77 -77
  39. package/dynamoDb/storage/richText.js.map +1 -0
  40. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  41. package/elasticsearch/createElasticsearchIndex.js +49 -0
  42. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  43. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  44. package/elasticsearch/deleteElasticsearchIndex.js +36 -0
  45. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  46. package/elasticsearch/index.d.ts +1 -1
  47. package/elasticsearch/index.js +1 -6
  48. package/elasticsearch/index.js.map +1 -0
  49. package/elasticsearch/indexing/dateTimeIndexing.js +17 -20
  50. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  51. package/elasticsearch/indexing/defaultFieldIndexing.js +15 -10
  52. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  53. package/elasticsearch/indexing/index.js +1 -10
  54. package/elasticsearch/indexing/index.js.map +1 -0
  55. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  56. package/elasticsearch/indexing/longTextIndexing.js +14 -10
  57. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  58. package/elasticsearch/indexing/numberIndexing.js +0 -9
  59. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  60. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  61. package/elasticsearch/indexing/objectIndexing.js +26 -30
  62. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/richTextIndexing.js +0 -5
  64. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  65. package/elasticsearch/indices/base.d.ts +2 -0
  66. package/elasticsearch/indices/base.js +12 -0
  67. package/elasticsearch/indices/base.js.map +1 -0
  68. package/elasticsearch/indices/index.d.ts +1 -0
  69. package/elasticsearch/indices/index.js +12 -0
  70. package/elasticsearch/indices/index.js.map +1 -0
  71. package/elasticsearch/indices/japanese.d.ts +2 -0
  72. package/elasticsearch/indices/japanese.js +13 -0
  73. package/elasticsearch/indices/japanese.js.map +1 -0
  74. package/elasticsearch/search/index.d.ts +2 -2
  75. package/elasticsearch/search/index.js +3 -9
  76. package/elasticsearch/search/index.js.map +1 -0
  77. package/elasticsearch/search/refSearch.d.ts +2 -3
  78. package/elasticsearch/search/refSearch.js +23 -18
  79. package/elasticsearch/search/refSearch.js.map +1 -0
  80. package/elasticsearch/search/timeSearch.d.ts +2 -3
  81. package/elasticsearch/search/timeSearch.js +18 -17
  82. package/elasticsearch/search/timeSearch.js.map +1 -0
  83. package/helpers/entryIndexHelpers.js +43 -57
  84. package/helpers/entryIndexHelpers.js.map +1 -0
  85. package/helpers/index.d.ts +0 -1
  86. package/helpers/index.js +0 -15
  87. package/helpers/index.js.map +1 -0
  88. package/index.d.ts +1 -0
  89. package/index.js +107 -63
  90. package/index.js.map +1 -0
  91. package/operations/entry/dataLoaders.d.ts +6 -2
  92. package/operations/entry/dataLoaders.js +27 -61
  93. package/operations/entry/dataLoaders.js.map +1 -0
  94. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  95. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
  96. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  97. package/operations/entry/elasticsearch/body.d.ts +13 -0
  98. package/operations/entry/elasticsearch/body.js +140 -0
  99. package/operations/entry/elasticsearch/body.js.map +1 -0
  100. package/operations/entry/elasticsearch/fields.d.ts +10 -0
  101. package/operations/entry/elasticsearch/fields.js +261 -0
  102. package/operations/entry/elasticsearch/fields.js.map +1 -0
  103. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  104. package/operations/entry/elasticsearch/filtering/applyFiltering.js +57 -0
  105. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  106. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  107. package/operations/entry/elasticsearch/filtering/exec.js +172 -0
  108. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  109. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  110. package/operations/entry/elasticsearch/filtering/index.js +16 -0
  111. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  112. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  113. package/operations/entry/elasticsearch/filtering/path.js +44 -0
  114. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  115. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  116. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
  117. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  118. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  119. package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
  120. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  121. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  122. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  127. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  128. package/operations/entry/elasticsearch/filtering/populated.js +23 -0
  129. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  130. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  131. package/operations/entry/elasticsearch/filtering/values.js +22 -0
  132. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  133. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  134. package/operations/entry/elasticsearch/fullTextSearch.js +89 -0
  135. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  136. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  137. package/operations/entry/elasticsearch/fullTextSearchFields.js +25 -0
  138. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  139. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  140. package/operations/entry/elasticsearch/initialQuery.js +103 -0
  141. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  142. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  143. package/operations/entry/elasticsearch/keyword.js +34 -0
  144. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  145. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  146. package/operations/entry/elasticsearch/plugins/bodyModifier.js +16 -0
  147. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  148. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  149. package/operations/entry/elasticsearch/plugins/operator.js +37 -0
  150. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  151. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  152. package/operations/entry/elasticsearch/plugins/queryModifier.js +16 -0
  153. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  154. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  155. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -10
  156. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  157. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  158. package/operations/entry/elasticsearch/plugins/sortModifier.js +16 -0
  159. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  160. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  161. package/operations/entry/elasticsearch/sort.js +81 -0
  162. package/operations/entry/elasticsearch/sort.js.map +1 -0
  163. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  164. package/operations/entry/elasticsearch/transformValueForSearch.js +30 -0
  165. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  166. package/operations/entry/elasticsearch/types.d.ts +41 -0
  167. package/operations/entry/elasticsearch/types.js +5 -0
  168. package/operations/entry/elasticsearch/types.js.map +1 -0
  169. package/operations/entry/index.d.ts +2 -4
  170. package/operations/entry/index.js +502 -496
  171. package/operations/entry/index.js.map +1 -0
  172. package/operations/entry/keys.js +0 -9
  173. package/operations/entry/keys.js.map +1 -0
  174. package/operations/entry/recordType.d.ts +3 -0
  175. package/operations/entry/recordType.js +18 -0
  176. package/operations/entry/recordType.js.map +1 -0
  177. package/operations/group/index.d.ts +2 -2
  178. package/operations/group/index.js +10 -47
  179. package/operations/group/index.js.map +1 -0
  180. package/operations/model/index.d.ts +2 -2
  181. package/operations/model/index.js +34 -68
  182. package/operations/model/index.js.map +1 -0
  183. package/operations/settings/index.d.ts +2 -2
  184. package/operations/settings/index.js +7 -37
  185. package/operations/settings/index.js.map +1 -0
  186. package/operations/system/index.d.ts +2 -2
  187. package/operations/system/index.js +5 -28
  188. package/operations/system/index.js.map +1 -0
  189. package/package.json +31 -29
  190. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
  191. package/plugins/CmsElasticsearchModelFieldPlugin.js +48 -0
  192. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
  193. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
  194. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +9 -11
  195. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  196. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  197. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
  198. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  199. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  200. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
  201. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  202. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  203. package/plugins/CmsEntryElasticsearchIndexPlugin.js +12 -0
  204. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +31 -0
  206. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +37 -0
  207. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
  209. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +9 -11
  210. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  211. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
  212. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +9 -11
  213. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  214. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  215. package/plugins/CmsEntryFilterPlugin.js +24 -0
  216. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  217. package/plugins/index.d.ts +7 -0
  218. package/plugins/index.js +82 -0
  219. package/plugins/index.js.map +1 -0
  220. package/types.d.ts +8 -35
  221. package/types.js +0 -18
  222. package/types.js.map +1 -0
  223. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  224. package/helpers/createElasticsearchQueryBody.js +0 -375
  225. package/helpers/fields.d.ts +0 -77
  226. package/helpers/fields.js +0 -174
  227. package/helpers/operatorPluginsList.d.ts +0 -7
  228. package/helpers/operatorPluginsList.js +0 -30
  229. package/helpers/searchPluginsList.d.ts +0 -6
  230. package/helpers/transformValueForSearch.d.ts +0 -9
  231. package/helpers/transformValueForSearch.js +0 -26
  232. package/operations/entry/elasticsearchFields.d.ts +0 -2
  233. package/operations/entry/elasticsearchFields.js +0 -32
  234. package/operations/entry/fields.d.ts +0 -3
  235. package/operations/entry/fields.js +0 -60
  236. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  237. package/operations/system/createElasticsearchTemplate.js +0 -62
  238. package/upgrades/index.d.ts +0 -2
  239. package/upgrades/index.js +0 -16
  240. package/upgrades/utils.d.ts +0 -1
  241. package/upgrades/utils.js +0 -16
  242. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  243. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  244. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  245. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  246. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  247. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  248. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  249. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  250. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  251. package/upgrades/v5.0.0/helpers.js +0 -57
  252. package/upgrades/v5.0.0/index.d.ts +0 -4
  253. package/upgrades/v5.0.0/index.js +0 -232
  254. package/upgrades/v5.8.0/index.d.ts +0 -4
  255. package/upgrades/v5.8.0/index.js +0 -426
package/helpers/fields.js DELETED
@@ -1,174 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.systemFields = exports.createModelFields = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- const createSystemField = field => {
13
- if (!field.fieldId) {
14
- throw new _error.default(`When creating system field it must have a "entryId".`, "SYSTEM_FIELD_ERROR", {
15
- field
16
- });
17
- } else if (!field.type) {
18
- throw new _error.default(`When creating system field it must have a "type".`, "SYSTEM_FIELD_ERROR", {
19
- field
20
- });
21
- }
22
-
23
- return field;
24
- };
25
-
26
- const systemFields = {
27
- id: {
28
- type: "text",
29
- isSystemField: true,
30
- isSearchable: true,
31
- isSortable: true,
32
- field: createSystemField({
33
- fieldId: "id",
34
- type: "text"
35
- })
36
- },
37
- entryId: {
38
- type: "text",
39
- isSystemField: true,
40
- isSearchable: true,
41
- isSortable: true,
42
- field: createSystemField({
43
- fieldId: "entryId",
44
- type: "text"
45
- })
46
- },
47
- savedOn: {
48
- type: "date",
49
- unmappedType: "date",
50
- keyword: false,
51
- isSystemField: true,
52
- isSearchable: true,
53
- isSortable: true,
54
- field: createSystemField({
55
- fieldId: "savedOn",
56
- type: "date",
57
- settings: {
58
- type: "dateTimeWithoutTimezone"
59
- }
60
- })
61
- },
62
- createdOn: {
63
- type: "date",
64
- unmappedType: "date",
65
- keyword: false,
66
- isSystemField: true,
67
- isSearchable: true,
68
- isSortable: true,
69
- field: createSystemField({
70
- fieldId: "createdOn",
71
- type: "text",
72
- settings: {
73
- type: "dateTimeWithoutTimezone"
74
- }
75
- })
76
- },
77
- createdBy: {
78
- type: "text",
79
- unmappedType: undefined,
80
- isSystemField: true,
81
- isSearchable: true,
82
- isSortable: false,
83
- path: "createdBy.id",
84
- field: createSystemField({
85
- fieldId: "createdBy",
86
- type: "text"
87
- })
88
- },
89
- ownedBy: {
90
- type: "text",
91
- unmappedType: undefined,
92
- isSystemField: true,
93
- isSearchable: true,
94
- isSortable: false,
95
- path: "ownedBy.id",
96
- field: createSystemField({
97
- fieldId: "ownedBy",
98
- type: "text"
99
- })
100
- },
101
- version: {
102
- type: "number",
103
- unmappedType: undefined,
104
- keyword: false,
105
- isSystemField: true,
106
- isSearchable: true,
107
- isSortable: true,
108
- field: createSystemField({
109
- fieldId: "version",
110
- type: "number"
111
- })
112
- }
113
- };
114
- /*
115
- * Create an object with key fieldType and options for that field
116
- */
117
-
118
- exports.systemFields = systemFields;
119
-
120
- const createModelFields = (plugins, model) => {
121
- // collect all unmappedType from elastic plugins
122
- const unmappedTypes = plugins.byType("cms-model-field-to-elastic-search").reduce((acc, plugin) => {
123
- if (!plugin.unmappedType) {
124
- return acc;
125
- }
126
-
127
- acc[plugin.fieldType] = plugin.unmappedType;
128
- return acc;
129
- }, {});
130
- /**
131
- * collect all field types from the plugins
132
- */
133
-
134
- const fieldTypePlugins = plugins.byType("cms-model-field-to-graphql").reduce((types, plugin) => {
135
- const {
136
- fieldType,
137
- isSearchable,
138
- isSortable
139
- } = plugin;
140
- types[fieldType] = {
141
- unmappedType: unmappedTypes[fieldType],
142
- isSearchable: isSearchable === true,
143
- isSortable: isSortable === true
144
- };
145
- return types;
146
- }, {});
147
- return model.fields.reduce((fields, field) => {
148
- const {
149
- fieldId,
150
- type
151
- } = field;
152
-
153
- if (!fieldTypePlugins[type]) {
154
- throw new _error.default(`There is no plugin for field type "${type}".`);
155
- }
156
-
157
- const {
158
- isSearchable,
159
- isSortable,
160
- unmappedType
161
- } = fieldTypePlugins[type];
162
- fields[fieldId] = {
163
- type,
164
- isSearchable,
165
- isSortable,
166
- unmappedType: typeof unmappedType === "function" ? unmappedType(field) : undefined,
167
- isSystemField: false,
168
- field
169
- };
170
- return fields;
171
- }, systemFields);
172
- };
173
-
174
- exports.createModelFields = createModelFields;
@@ -1,7 +0,0 @@
1
- import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- interface OperatorPlugins {
4
- [operator: string]: ElasticsearchQueryBuilderOperatorPlugin;
5
- }
6
- export declare const operatorPluginsList: (plugins: PluginsContainer) => OperatorPlugins;
7
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.operatorPluginsList = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
13
-
14
- const operatorPluginsList = plugins => {
15
- return plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((plugins, plugin) => {
16
- const operator = plugin.getOperator();
17
-
18
- if (plugins[operator]) {
19
- throw new _error.default("There is a ElasticsearchQueryBuilderOperatorPlugin defined for the operator.", "PLUGIN_ALREADY_EXISTS", {
20
- operator: operator,
21
- name: plugin.name || "unknown"
22
- });
23
- }
24
-
25
- plugins[operator] = plugin;
26
- return plugins;
27
- }, {});
28
- };
29
-
30
- exports.operatorPluginsList = operatorPluginsList;
@@ -1,6 +0,0 @@
1
- import { ElasticsearchQueryBuilderValueSearchPlugin } from "../types";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- export interface ElasticsearchQuerySearchValuePlugins {
4
- [fieldType: string]: ElasticsearchQueryBuilderValueSearchPlugin;
5
- }
6
- export declare const searchPluginsList: (plugins: PluginsContainer) => ElasticsearchQuerySearchValuePlugins;
@@ -1,9 +0,0 @@
1
- import { ElasticsearchQuerySearchValuePlugins } from "./searchPluginsList";
2
- import { CmsModelField } from "@webiny/api-headless-cms/types";
3
- interface Params {
4
- plugins: ElasticsearchQuerySearchValuePlugins;
5
- field: CmsModelField;
6
- value: any;
7
- }
8
- export declare const transformValueForSearch: (args: Params) => any;
9
- export {};
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.transformValueForSearch = void 0;
7
-
8
- const transformValueForSearch = args => {
9
- const {
10
- field,
11
- plugins,
12
- value
13
- } = args;
14
- const plugin = plugins[field.type];
15
-
16
- if (!plugin) {
17
- return value;
18
- }
19
-
20
- return plugin.transform({
21
- field,
22
- value
23
- });
24
- };
25
-
26
- exports.transformValueForSearch = transformValueForSearch;
@@ -1,2 +0,0 @@
1
- import { CmsEntryElasticsearchFieldPlugin } from "../../plugins/CmsEntryElasticsearchFieldPlugin";
2
- export declare const elasticsearchFields: CmsEntryElasticsearchFieldPlugin[];
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.elasticsearchFields = void 0;
7
-
8
- var _CmsEntryElasticsearchFieldPlugin = require("../../plugins/CmsEntryElasticsearchFieldPlugin");
9
-
10
- const elasticsearchFields = [new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
11
- field: "createdOn",
12
- unmappedType: "date"
13
- }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
14
- field: "savedOn",
15
- unmappedType: "date"
16
- }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
17
- field: "publishedOn",
18
- unmappedType: "date"
19
- }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
20
- field: "ownedBy",
21
- path: "ownedBy.id"
22
- }), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
23
- field: "createdBy",
24
- path: "createdBy.id"
25
- }),
26
- /**
27
- * Always add the ALL fields plugin because of the keyword/path build.
28
- */
29
- new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
30
- field: _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin.ALL
31
- })];
32
- exports.elasticsearchFields = elasticsearchFields;
@@ -1,3 +0,0 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- import { CmsEntryElasticsearchFieldPlugin } from "../../plugins/CmsEntryElasticsearchFieldPlugin";
3
- export declare const createElasticsearchFields: (model: CmsModel) => Record<string, CmsEntryElasticsearchFieldPlugin>;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createElasticsearchFields = void 0;
7
-
8
- var _CmsEntryElasticsearchFieldPlugin = require("../../plugins/CmsEntryElasticsearchFieldPlugin");
9
-
10
- const fieldsWithKeywords = ["text", "long-text", "rich-text", "id", "ref"];
11
- /**
12
- * We need to map entry system fields that have different paths, no keyword or not sortable.
13
- */
14
-
15
- const systemFields = {
16
- createdBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
17
- field: "createdBy",
18
- path: "createdBy.id",
19
- searchable: true,
20
- keyword: true,
21
- sortable: false
22
- }),
23
- ownedBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
24
- field: "ownedBy",
25
- path: "ownedBy.id",
26
- searchable: true,
27
- keyword: true,
28
- sortable: false
29
- }),
30
- createdOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
31
- field: "createdOn",
32
- path: "createdOn",
33
- searchable: true,
34
- keyword: false,
35
- sortable: false,
36
- unmappedType: "date"
37
- }),
38
- savedOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
39
- field: "savedOn",
40
- path: "savedOn",
41
- searchable: true,
42
- keyword: false,
43
- sortable: false,
44
- unmappedType: "date"
45
- })
46
- };
47
-
48
- const createElasticsearchFields = model => {
49
- return model.fields.reduce((fields, field) => {
50
- fields[field.fieldId] = new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
51
- field: field.fieldId,
52
- path: `values.${field.fieldId}`,
53
- searchable: true,
54
- keyword: fieldsWithKeywords.includes(field.type)
55
- });
56
- return fields;
57
- }, systemFields);
58
- };
59
-
60
- exports.createElasticsearchFields = createElasticsearchFields;
@@ -1,5 +0,0 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- export interface Params {
3
- elasticsearch: Client;
4
- }
5
- export declare const createElasticsearchTemplate: (params: Params) => Promise<void>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createElasticsearchTemplate = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- const createElasticsearchTemplate = async params => {
13
- const {
14
- elasticsearch
15
- } = params;
16
- const options = {
17
- name: "headless-cms-entries-index",
18
- body: {
19
- index_patterns: ["*headless-cms*"],
20
- settings: {
21
- analysis: {
22
- analyzer: {
23
- lowercase_analyzer: {
24
- type: "custom",
25
- filter: ["lowercase", "trim"],
26
- tokenizer: "keyword"
27
- }
28
- }
29
- }
30
- },
31
- mappings: {
32
- properties: {
33
- property: {
34
- type: "text",
35
- fields: {
36
- keyword: {
37
- type: "keyword",
38
- ignore_above: 256
39
- }
40
- },
41
- analyzer: "lowercase_analyzer"
42
- },
43
- rawValues: {
44
- type: "object",
45
- enabled: false
46
- }
47
- }
48
- }
49
- }
50
- };
51
-
52
- try {
53
- await elasticsearch.indices.putTemplate(options);
54
- } catch (ex) {
55
- throw new _error.default(ex.message || "Could not create Elasticsearch index template for the Headless CMS.", ex.code || "CMS_ELASTICSEARCH_TEMPLATE_ERROR", {
56
- error: ex,
57
- options
58
- });
59
- }
60
- };
61
-
62
- exports.createElasticsearchTemplate = createElasticsearchTemplate;
@@ -1,2 +0,0 @@
1
- declare const _default: () => import("@webiny/api-upgrade").UpgradePlugin<import("@webiny/api-headless-cms/types").CmsContext>[];
2
- export default _default;
package/upgrades/index.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _index = _interopRequireDefault(require("./v5.0.0/index"));
11
-
12
- var _index2 = _interopRequireDefault(require("./v5.8.0/index"));
13
-
14
- var _default = () => [(0, _index.default)(), (0, _index2.default)()];
15
-
16
- exports.default = _default;
@@ -1 +0,0 @@
1
- export declare const paginateBatch: (items: any, perPage: any, execute: any) => Promise<void>;
package/upgrades/utils.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.paginateBatch = void 0;
7
-
8
- const paginateBatch = async (items, perPage, execute) => {
9
- const pages = Math.ceil(items.length / perPage);
10
-
11
- for (let i = 0; i < pages; i++) {
12
- await execute(items.slice(i * perPage, i * perPage + perPage));
13
- }
14
- };
15
-
16
- exports.paginateBatch = paginateBatch;
@@ -1,6 +0,0 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- export declare const cleanDatabaseRecord: <T extends CmsModel | CmsEntry>(record: T & {
3
- PK?: string;
4
- SK?: string;
5
- TYPE?: string;
6
- }) => T;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.cleanDatabaseRecord = void 0;
9
-
10
- var _lodash = _interopRequireDefault(require("lodash.omit"));
11
-
12
- const cleanDatabaseRecord = record => {
13
- return (0, _lodash.default)(record, ["PK", "SK", "TYPE"]);
14
- };
15
-
16
- exports.cleanDatabaseRecord = cleanDatabaseRecord;
@@ -1,2 +0,0 @@
1
- import { CmsContext } from "@webiny/api-headless-cms/types";
2
- export declare const createOldVersionIndiceName: (context: CmsContext) => string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOldVersionIndiceName = void 0;
7
-
8
- const createOldVersionIndiceName = context => {
9
- return `${context.tenancy.getCurrentTenant().id}-headless-cms`;
10
- };
11
-
12
- exports.createOldVersionIndiceName = createOldVersionIndiceName;
@@ -1,4 +0,0 @@
1
- import { ModelFieldFinder } from "./fieldFinder";
2
- import { CmsIndexEntry } from "../../types";
3
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
4
- export declare const entryValueFixer: (_: CmsModel, finder: ModelFieldFinder, target: CmsIndexEntry) => CmsEntry;
@@ -1,124 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.entryValueFixer = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _cleanDatabaseRecord = require("./cleanDatabaseRecord");
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; }
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; }
17
-
18
- const convertTimeToNumber = time => {
19
- if (!time) {
20
- return null;
21
- }
22
-
23
- const [hours, minutes, seconds = 0] = time.split(":").map(Number);
24
- return hours * 60 * 60 + minutes * 60 + seconds;
25
- };
26
-
27
- const fixRawValues = (target, finder) => {
28
- const entry = _objectSpread({}, target);
29
-
30
- for (const fieldId in entry.rawValues) {
31
- // if field is ref field then continue, otherwise break
32
- const field = finder.findById(target.modelId, fieldId);
33
-
34
- if (field.type !== "ref") {
35
- continue;
36
- }
37
-
38
- const existingValue = entry.values[fieldId];
39
- const rawValue = entry.rawValues[fieldId]; // always remove from rawValue
40
-
41
- delete entry.rawValues[fieldId]; // if there is something in values - do not switch it
42
-
43
- if (typeof existingValue !== "undefined" || rawValue === undefined || rawValue === null) {
44
- continue;
45
- }
46
-
47
- entry.values[fieldId] = rawValue;
48
- }
49
-
50
- return entry;
51
- };
52
-
53
- const fixTime = (field, time) => {
54
- if (isNaN(time) === false) {
55
- return parseInt(time);
56
- } // lets not reinvent the wheel
57
-
58
-
59
- try {
60
- return convertTimeToNumber(time);
61
- } catch (err) {
62
- console.log(`fixTime on field "${field.fieldId}" failed`, err);
63
- return null;
64
- }
65
- };
66
-
67
- const fixDateTime = (field, dateTime) => {
68
- switch (field.settings.type) {
69
- case "time":
70
- return fixTime(field, dateTime);
71
-
72
- case "date":
73
- return new Date(dateTime).toISOString();
74
-
75
- case "dateTimeWithoutTimezone":
76
- return new Date(dateTime).toISOString();
77
-
78
- default:
79
- return dateTime;
80
- }
81
- };
82
-
83
- const fixNumber = (_, value) => {
84
- if (value === undefined || value === null) {
85
- return null;
86
- }
87
-
88
- return parseFloat(value);
89
- };
90
-
91
- const fieldFixMethods = {
92
- datetime: fixDateTime,
93
- number: fixNumber
94
- };
95
-
96
- const fixFieldValues = (target, finder) => {
97
- const entry = _objectSpread({}, target);
98
-
99
- for (const fieldId in target.values) {
100
- const field = finder.findById(target.modelId, fieldId);
101
-
102
- if (!field) {
103
- continue;
104
- }
105
-
106
- const fixMethod = fieldFixMethods[field.type];
107
-
108
- if (!fixMethod) {
109
- continue;
110
- } else if (target.values[fieldId] === null || target.values[fieldId] === undefined) {
111
- continue;
112
- }
113
-
114
- target.values[fieldId] = fixMethod(field, target.values[fieldId]);
115
- }
116
-
117
- return entry;
118
- };
119
-
120
- const entryValueFixer = (_, finder, target) => {
121
- return (0, _cleanDatabaseRecord.cleanDatabaseRecord)(fixFieldValues(fixRawValues(target, finder), finder));
122
- };
123
-
124
- exports.entryValueFixer = entryValueFixer;
@@ -1,6 +0,0 @@
1
- import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
2
- export interface ModelFieldFinder {
3
- findById: (model: CmsModel | string, fieldId: string) => CmsModelField;
4
- findByType: (model: CmsModel | string, type: string) => CmsModelField[];
5
- }
6
- export declare const createFieldFinder: (models: CmsModel[]) => ModelFieldFinder;