@webiny/api-headless-cms-ddb-es 0.0.0-mt-1

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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/configurations.d.ts +12 -0
  4. package/configurations.js +32 -0
  5. package/definitions/entry.d.ts +8 -0
  6. package/definitions/entry.js +91 -0
  7. package/definitions/entryElasticsearch.d.ts +8 -0
  8. package/definitions/entryElasticsearch.js +46 -0
  9. package/definitions/group.d.ts +8 -0
  10. package/definitions/group.js +74 -0
  11. package/definitions/model.d.ts +8 -0
  12. package/definitions/model.js +96 -0
  13. package/definitions/settings.d.ts +8 -0
  14. package/definitions/settings.js +62 -0
  15. package/definitions/system.d.ts +8 -0
  16. package/definitions/system.js +50 -0
  17. package/definitions/table.d.ts +8 -0
  18. package/definitions/table.js +24 -0
  19. package/definitions/tableElasticsearch.d.ts +8 -0
  20. package/definitions/tableElasticsearch.js +24 -0
  21. package/dynamoDb/index.d.ts +2 -0
  22. package/dynamoDb/index.js +18 -0
  23. package/dynamoDb/storage/date.d.ts +3 -0
  24. package/dynamoDb/storage/date.js +65 -0
  25. package/dynamoDb/storage/longText.d.ts +7 -0
  26. package/dynamoDb/storage/longText.js +83 -0
  27. package/dynamoDb/storage/richText.d.ts +8 -0
  28. package/dynamoDb/storage/richText.js +110 -0
  29. package/elasticsearch/index.d.ts +2 -0
  30. package/elasticsearch/index.js +16 -0
  31. package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
  32. package/elasticsearch/indexing/dateTimeIndexing.js +89 -0
  33. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
  34. package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
  35. package/elasticsearch/indexing/index.d.ts +2 -0
  36. package/elasticsearch/indexing/index.js +24 -0
  37. package/elasticsearch/indexing/longTextIndexing.d.ts +3 -0
  38. package/elasticsearch/indexing/longTextIndexing.js +36 -0
  39. package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
  40. package/elasticsearch/indexing/numberIndexing.js +48 -0
  41. package/elasticsearch/indexing/objectIndexing.d.ts +3 -0
  42. package/elasticsearch/indexing/objectIndexing.js +200 -0
  43. package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
  44. package/elasticsearch/indexing/richTextIndexing.js +34 -0
  45. package/elasticsearch/search/index.d.ts +3 -0
  46. package/elasticsearch/search/index.js +16 -0
  47. package/elasticsearch/search/refSearch.d.ts +3 -0
  48. package/elasticsearch/search/refSearch.js +24 -0
  49. package/elasticsearch/search/timeSearch.d.ts +3 -0
  50. package/elasticsearch/search/timeSearch.js +25 -0
  51. package/helpers/createElasticsearchQueryBody.d.ts +11 -0
  52. package/helpers/createElasticsearchQueryBody.js +375 -0
  53. package/helpers/entryIndexHelpers.d.ts +18 -0
  54. package/helpers/entryIndexHelpers.js +189 -0
  55. package/helpers/fields.d.ts +77 -0
  56. package/helpers/fields.js +174 -0
  57. package/helpers/index.d.ts +2 -0
  58. package/helpers/index.js +31 -0
  59. package/helpers/operatorPluginsList.d.ts +7 -0
  60. package/helpers/operatorPluginsList.js +30 -0
  61. package/helpers/searchPluginsList.d.ts +6 -0
  62. package/helpers/searchPluginsList.js +26 -0
  63. package/helpers/transformValueForSearch.d.ts +9 -0
  64. package/helpers/transformValueForSearch.js +26 -0
  65. package/index.d.ts +2 -0
  66. package/index.js +171 -0
  67. package/operations/entry/dataLoaders.d.ts +47 -0
  68. package/operations/entry/dataLoaders.js +347 -0
  69. package/operations/entry/elasticsearchFields.d.ts +2 -0
  70. package/operations/entry/elasticsearchFields.js +32 -0
  71. package/operations/entry/fields.d.ts +3 -0
  72. package/operations/entry/fields.js +60 -0
  73. package/operations/entry/index.d.ts +13 -0
  74. package/operations/entry/index.js +1152 -0
  75. package/operations/entry/keys.d.ts +12 -0
  76. package/operations/entry/keys.js +40 -0
  77. package/operations/group/index.d.ts +8 -0
  78. package/operations/group/index.js +202 -0
  79. package/operations/model/index.d.ts +8 -0
  80. package/operations/model/index.js +205 -0
  81. package/operations/settings/index.d.ts +6 -0
  82. package/operations/settings/index.js +141 -0
  83. package/operations/system/createElasticsearchTemplate.d.ts +5 -0
  84. package/operations/system/createElasticsearchTemplate.js +62 -0
  85. package/operations/system/index.d.ts +6 -0
  86. package/operations/system/index.js +105 -0
  87. package/package.json +73 -0
  88. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +17 -0
  89. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
  90. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
  91. package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
  92. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
  93. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
  94. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
  95. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
  96. package/types.d.ts +191 -0
  97. package/types.js +60 -0
  98. package/upgrades/index.d.ts +2 -0
  99. package/upgrades/index.js +16 -0
  100. package/upgrades/utils.d.ts +1 -0
  101. package/upgrades/utils.js +16 -0
  102. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +6 -0
  103. package/upgrades/v5.0.0/cleanDatabaseRecord.js +16 -0
  104. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +2 -0
  105. package/upgrades/v5.0.0/createOldVersionIndiceName.js +12 -0
  106. package/upgrades/v5.0.0/entryValueFixer.d.ts +4 -0
  107. package/upgrades/v5.0.0/entryValueFixer.js +124 -0
  108. package/upgrades/v5.0.0/fieldFinder.d.ts +6 -0
  109. package/upgrades/v5.0.0/fieldFinder.js +42 -0
  110. package/upgrades/v5.0.0/helpers.d.ts +4 -0
  111. package/upgrades/v5.0.0/helpers.js +57 -0
  112. package/upgrades/v5.0.0/index.d.ts +4 -0
  113. package/upgrades/v5.0.0/index.js +232 -0
  114. package/upgrades/v5.8.0/index.d.ts +4 -0
  115. package/upgrades/v5.8.0/index.js +426 -0
@@ -0,0 +1,18 @@
1
+ import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
+ import { CmsIndexEntry } from "../types";
3
+ import { PluginsContainer } from "@webiny/plugins";
4
+ interface SetupEntriesIndexHelpersParams {
5
+ plugins: PluginsContainer;
6
+ }
7
+ interface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {
8
+ model: CmsModel;
9
+ entries: CmsIndexEntry[];
10
+ }
11
+ interface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {
12
+ model: CmsModel;
13
+ entry: CmsEntry;
14
+ storageEntry: CmsEntry;
15
+ }
16
+ export declare const prepareEntryToIndex: (params: PrepareElasticsearchDataParams) => CmsIndexEntry;
17
+ export declare const extractEntriesFromIndex: ({ plugins, entries, model }: ExtractEntriesFromIndexParams) => CmsEntry[];
18
+ export {};
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
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 prepareEntryToIndex = params => {
19
+ const {
20
+ plugins,
21
+ storageEntry,
22
+ entry,
23
+ model
24
+ } = params;
25
+ const {
26
+ fieldIndexPlugins,
27
+ defaultIndexFieldPlugin,
28
+ fieldTypePlugins
29
+ } = setupEntriesIndexHelpers({
30
+ plugins
31
+ });
32
+
33
+ function getFieldIndexPlugin(fieldType) {
34
+ return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
35
+ }
36
+
37
+ function getFieldTypePlugin(fieldType) {
38
+ const pl = fieldTypePlugins[fieldType];
39
+
40
+ if (pl) {
41
+ return pl;
42
+ }
43
+
44
+ throw new _error.default(`Missing field type plugin "${fieldType}". Prepare entry for index.`);
45
+ } // These objects will contain values processed by field index plugins
46
+
47
+
48
+ const values = {};
49
+ const rawValues = {}; // We're only interested in current model fields.
50
+
51
+ for (const field of model.fields) {
52
+ if (storageEntry.values.hasOwnProperty(field.fieldId) === false) {
53
+ continue;
54
+ }
55
+
56
+ const targetFieldPlugin = getFieldIndexPlugin(field.type); // TODO: remove this `if` once we convert this plugin to proper plugin class
57
+
58
+ if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
59
+ continue;
60
+ }
61
+
62
+ const {
63
+ value,
64
+ rawValue
65
+ } = targetFieldPlugin.toIndex({
66
+ plugins,
67
+ model,
68
+ field,
69
+ rawValue: entry.values[field.fieldId],
70
+ value: storageEntry.values[field.fieldId],
71
+ getFieldIndexPlugin,
72
+ getFieldTypePlugin
73
+ });
74
+
75
+ if (typeof value !== "undefined") {
76
+ values[field.fieldId] = value;
77
+ }
78
+
79
+ if (typeof rawValue !== "undefined") {
80
+ rawValues[field.fieldId] = rawValue;
81
+ }
82
+ }
83
+
84
+ return _objectSpread(_objectSpread({}, storageEntry), {}, {
85
+ values,
86
+ rawValues
87
+ });
88
+ };
89
+
90
+ exports.prepareEntryToIndex = prepareEntryToIndex;
91
+
92
+ const setupEntriesIndexHelpers = ({
93
+ plugins: pluginsContainer
94
+ }) => {
95
+ const plugins = pluginsContainer.byType("cms-model-field-to-elastic-search");
96
+ const fieldIndexPlugins = {};
97
+
98
+ for (const plugin of plugins.reverse()) {
99
+ if (fieldIndexPlugins[plugin.fieldType]) {
100
+ continue;
101
+ }
102
+
103
+ fieldIndexPlugins[plugin.fieldType] = plugin;
104
+ } // we will use this plugin if no targeted plugin found
105
+
106
+
107
+ const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === "*"); // CmsModelFieldToGraphQLPlugin plugins
108
+
109
+ const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => _objectSpread(_objectSpread({}, plugins), {}, {
110
+ [plugin.fieldType]: plugin
111
+ }), {});
112
+ return {
113
+ fieldIndexPlugins,
114
+ defaultIndexFieldPlugin,
115
+ fieldTypePlugins
116
+ };
117
+ };
118
+
119
+ const extractEntriesFromIndex = ({
120
+ plugins,
121
+ entries,
122
+ model
123
+ }) => {
124
+ const {
125
+ fieldIndexPlugins,
126
+ defaultIndexFieldPlugin,
127
+ fieldTypePlugins
128
+ } = setupEntriesIndexHelpers({
129
+ plugins
130
+ });
131
+
132
+ function getFieldIndexPlugin(fieldType) {
133
+ return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
134
+ }
135
+
136
+ function getFieldTypePlugin(fieldType) {
137
+ return fieldTypePlugins[fieldType];
138
+ }
139
+
140
+ const list = [];
141
+
142
+ for (const entry of entries) {
143
+ // This object will contain values processed by field index plugins
144
+ const indexValues = {}; // We only consider fields that are present in the model
145
+
146
+ for (const field of model.fields) {
147
+ const fieldTypePlugin = fieldTypePlugins[field.type];
148
+
149
+ if (!fieldTypePlugin) {
150
+ throw new _error.default(`Missing field type plugin "${field.type}". Extract entries from index.`);
151
+ }
152
+
153
+ const targetFieldPlugin = getFieldIndexPlugin(field.type);
154
+
155
+ if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
156
+ continue;
157
+ }
158
+
159
+ try {
160
+ indexValues[field.fieldId] = targetFieldPlugin.fromIndex({
161
+ plugins,
162
+ model,
163
+ field,
164
+ getFieldIndexPlugin,
165
+ getFieldTypePlugin,
166
+ value: entry.values[field.fieldId],
167
+
168
+ /**
169
+ * Possibly no rawValues so we must check for the existence of the field.
170
+ */
171
+ rawValue: entry.rawValues ? entry.rawValues[field.fieldId] : null
172
+ });
173
+ } catch (ex) {
174
+ throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
175
+ field,
176
+ entry
177
+ });
178
+ }
179
+ }
180
+
181
+ list.push(_objectSpread(_objectSpread({}, entry), {}, {
182
+ values: indexValues
183
+ }));
184
+ }
185
+
186
+ return list;
187
+ };
188
+
189
+ exports.extractEntriesFromIndex = extractEntriesFromIndex;
@@ -0,0 +1,77 @@
1
+ import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ declare type ModelFieldPath = string | ((value: string) => string);
4
+ export interface ModelField {
5
+ unmappedType?: string;
6
+ keyword?: boolean;
7
+ isSearchable: boolean;
8
+ isSortable: boolean;
9
+ type: string;
10
+ isSystemField?: boolean;
11
+ field: CmsModelField;
12
+ path?: ModelFieldPath;
13
+ }
14
+ export declare type ModelFields = Record<string, ModelField>;
15
+ export declare const systemFields: {
16
+ id: {
17
+ type: string;
18
+ isSystemField: boolean;
19
+ isSearchable: boolean;
20
+ isSortable: boolean;
21
+ field: CmsModelField;
22
+ };
23
+ entryId: {
24
+ type: string;
25
+ isSystemField: boolean;
26
+ isSearchable: boolean;
27
+ isSortable: boolean;
28
+ field: CmsModelField;
29
+ };
30
+ savedOn: {
31
+ type: string;
32
+ unmappedType: string;
33
+ keyword: boolean;
34
+ isSystemField: boolean;
35
+ isSearchable: boolean;
36
+ isSortable: boolean;
37
+ field: CmsModelField;
38
+ };
39
+ createdOn: {
40
+ type: string;
41
+ unmappedType: string;
42
+ keyword: boolean;
43
+ isSystemField: boolean;
44
+ isSearchable: boolean;
45
+ isSortable: boolean;
46
+ field: CmsModelField;
47
+ };
48
+ createdBy: {
49
+ type: string;
50
+ unmappedType: any;
51
+ isSystemField: boolean;
52
+ isSearchable: boolean;
53
+ isSortable: boolean;
54
+ path: string;
55
+ field: CmsModelField;
56
+ };
57
+ ownedBy: {
58
+ type: string;
59
+ unmappedType: any;
60
+ isSystemField: boolean;
61
+ isSearchable: boolean;
62
+ isSortable: boolean;
63
+ path: string;
64
+ field: CmsModelField;
65
+ };
66
+ version: {
67
+ type: string;
68
+ unmappedType: any;
69
+ keyword: boolean;
70
+ isSystemField: boolean;
71
+ isSearchable: boolean;
72
+ isSortable: boolean;
73
+ field: CmsModelField;
74
+ };
75
+ };
76
+ export declare const createModelFields: (plugins: PluginsContainer, model: CmsModel) => ModelFields;
77
+ export {};
@@ -0,0 +1,174 @@
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;
@@ -0,0 +1,2 @@
1
+ export * from "./createElasticsearchQueryBody";
2
+ export * from "./entryIndexHelpers";
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _createElasticsearchQueryBody = require("./createElasticsearchQueryBody");
8
+
9
+ Object.keys(_createElasticsearchQueryBody).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _createElasticsearchQueryBody[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _createElasticsearchQueryBody[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _entryIndexHelpers = require("./entryIndexHelpers");
21
+
22
+ Object.keys(_entryIndexHelpers).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _entryIndexHelpers[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _entryIndexHelpers[key];
29
+ }
30
+ });
31
+ });
@@ -0,0 +1,7 @@
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 {};
@@ -0,0 +1,30 @@
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;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.searchPluginsList = void 0;
9
+
10
+ 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) => {
14
+ if (plugins[plugin.fieldType]) {
15
+ throw new _error.default("There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.", "PLUGIN_ALREADY_EXISTS", {
16
+ fieldType: plugin.fieldType,
17
+ name: plugin.name || "unknown"
18
+ });
19
+ }
20
+
21
+ plugins[plugin.fieldType] = plugin;
22
+ return plugins;
23
+ }, {});
24
+ };
25
+
26
+ exports.searchPluginsList = searchPluginsList;
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,26 @@
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;
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { StorageOperationsFactory } from "./types";
2
+ export declare const createStorageOperations: StorageOperationsFactory;