@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,3 @@
1
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin";
2
+ declare const _default: () => StorageTransformPlugin<any, any>;
3
+ export default _default;
@@ -0,0 +1,65 @@
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 _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
13
+
14
+ const excludeTypes = ["time", "dateTimeWithTimezone"];
15
+ const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
16
+ fieldType: "datetime",
17
+ fromStorage: async ({
18
+ value,
19
+ field
20
+ }) => {
21
+ const {
22
+ type
23
+ } = field.settings || {};
24
+
25
+ if (!value || !type || excludeTypes.includes(type)) {
26
+ return value;
27
+ }
28
+
29
+ try {
30
+ return new Date(value);
31
+ } catch {
32
+ console.log(`Could not transform from storage for field type`);
33
+ return value;
34
+ }
35
+ },
36
+ toStorage: async ({
37
+ value,
38
+ field
39
+ }) => {
40
+ const {
41
+ type
42
+ } = field.settings || {};
43
+
44
+ if (!value || !type || excludeTypes.includes(type)) {
45
+ return value;
46
+ }
47
+
48
+ if (value.toISOString) {
49
+ return value.toISOString();
50
+ } else if (typeof value === "string") {
51
+ return value;
52
+ }
53
+
54
+ throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
55
+ value,
56
+ fieldId: field.fieldId
57
+ });
58
+ }
59
+ });
60
+
61
+ var _default = () => {
62
+ return plugin;
63
+ };
64
+
65
+ exports.default = _default;
@@ -0,0 +1,7 @@
1
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin";
2
+ export interface StorageValue {
3
+ compression: string;
4
+ value: any;
5
+ }
6
+ declare const _default: () => StorageTransformPlugin<string, StorageValue>;
7
+ export default _default;
@@ -0,0 +1,83 @@
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 _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _gzip = require("@webiny/utils/compression/gzip");
13
+
14
+ var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
15
+
16
+ const GZIP = "gzip";
17
+ const TO_STORAGE_ENCODING = "base64";
18
+ const FROM_STORAGE_ENCODING = "utf8";
19
+
20
+ const convertToBuffer = value => {
21
+ if (typeof value === "string") {
22
+ return Buffer.from(value, TO_STORAGE_ENCODING);
23
+ }
24
+
25
+ return value;
26
+ };
27
+
28
+ const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
29
+ fieldType: "long-text",
30
+ fromStorage: async ({
31
+ field,
32
+ value: storageValue
33
+ }) => {
34
+ const typeOf = typeof storageValue;
35
+
36
+ if (!storageValue || typeOf === "string" || typeOf === "number") {
37
+ return storageValue;
38
+ } else if (typeof storageValue !== "object") {
39
+ throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.fieldId}".`);
40
+ }
41
+
42
+ const {
43
+ compression,
44
+ value
45
+ } = storageValue;
46
+ /**
47
+ * Check if possibly undefined, null, empty...
48
+ */
49
+
50
+ if (!compression) {
51
+ throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
52
+ value: storageValue
53
+ });
54
+ } else if (compression !== GZIP) {
55
+ throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
56
+ compression
57
+ });
58
+ }
59
+
60
+ try {
61
+ const buf = await (0, _gzip.decompress)(convertToBuffer(value));
62
+ return buf.toString(FROM_STORAGE_ENCODING);
63
+ } catch (ex) {
64
+ console.log(ex.message);
65
+ return null;
66
+ }
67
+ },
68
+ toStorage: async ({
69
+ value
70
+ }) => {
71
+ const compressedValue = await (0, _gzip.compress)(value);
72
+ return {
73
+ compression: GZIP,
74
+ value: compressedValue.toString(TO_STORAGE_ENCODING)
75
+ };
76
+ }
77
+ });
78
+
79
+ var _default = () => {
80
+ return plugin;
81
+ };
82
+
83
+ exports.default = _default;
@@ -0,0 +1,8 @@
1
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin";
2
+ export declare type OriginalValue = Record<string, any> | any[];
3
+ export interface StorageValue {
4
+ compression: string;
5
+ value: any;
6
+ }
7
+ declare const _default: () => StorageTransformPlugin<any, any>;
8
+ export default _default;
@@ -0,0 +1,110 @@
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 _jsonpack = _interopRequireDefault(require("jsonpack"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
15
+
16
+ /**
17
+ * Remove when jsonpack gets PR with a fix merged
18
+ * https://github.com/rgcl/jsonpack/pull/25/files
19
+ * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
20
+ */
21
+ const transformArray = value => {
22
+ if (!value) {
23
+ return value;
24
+ }
25
+
26
+ let isArray = Array.isArray(value);
27
+ const shouldBeArray = value instanceof Array === false && isArray;
28
+
29
+ if (shouldBeArray) {
30
+ value = Array.from(value);
31
+ isArray = true;
32
+ }
33
+
34
+ if (typeof value === "object" || isArray) {
35
+ for (const k in value) {
36
+ value[k] = transformArray(value[k]);
37
+ }
38
+ }
39
+
40
+ return value;
41
+ };
42
+
43
+ const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
44
+ fieldType: "rich-text",
45
+ fromStorage: async ({
46
+ field,
47
+ value: storageValue
48
+ }) => {
49
+ if (!storageValue) {
50
+ return storageValue;
51
+ } else if (typeof storageValue !== "object") {
52
+ throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.fieldId}".`);
53
+ }
54
+ /**
55
+ * This is to circumvent a bug introduced with 5.8.0 storage operations.
56
+ * Do not remove.
57
+ */
58
+
59
+
60
+ if (storageValue.hasOwnProperty("compression") === false) {
61
+ return storageValue;
62
+ }
63
+
64
+ const {
65
+ compression,
66
+ value
67
+ } = storageValue;
68
+
69
+ if (!compression) {
70
+ throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
71
+ value: storageValue
72
+ });
73
+ }
74
+
75
+ if (compression !== "jsonpack") {
76
+ throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
77
+ compression
78
+ });
79
+ }
80
+
81
+ try {
82
+ return _jsonpack.default.unpack(value);
83
+ } catch {
84
+ return null;
85
+ }
86
+ },
87
+ toStorage: async ({
88
+ value
89
+ }) => {
90
+ /**
91
+ * There is a possibility that we are trying to compress already compressed value.
92
+ * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
93
+ */
94
+ if (value && value.hasOwnProperty("compression") === true) {
95
+ return value;
96
+ }
97
+
98
+ value = transformArray(value);
99
+ return {
100
+ compression: "jsonpack",
101
+ value: value ? _jsonpack.default.pack(value) : value
102
+ };
103
+ }
104
+ });
105
+
106
+ var _default = () => {
107
+ return plugin;
108
+ };
109
+
110
+ exports.default = _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("../types").ElasticsearchQueryBuilderValueSearchPlugin[])[];
2
+ export default _default;
@@ -0,0 +1,16 @@
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 _indexing = _interopRequireDefault(require("./indexing"));
11
+
12
+ var _search = _interopRequireDefault(require("./search"));
13
+
14
+ var _default = () => [(0, _indexing.default)(), (0, _search.default)()];
15
+
16
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
+ export default _default;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ const convertTimeToNumber = time => {
9
+ if (!time) {
10
+ return null;
11
+ }
12
+
13
+ const [hours, minutes, seconds = 0] = time.split(":").map(Number);
14
+ return hours * 60 * 60 + minutes * 60 + seconds;
15
+ };
16
+
17
+ const convertNumberToTime = value => {
18
+ if (value === undefined || value === null) {
19
+ return null;
20
+ } // TODO remove when v5 goes out
21
+ // this is a fix for pre beta.5
22
+
23
+
24
+ if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {
25
+ return String(value);
26
+ } //
27
+
28
+
29
+ const hours = Math.floor(value / 60 / 60);
30
+ const minutes = Math.floor((value - hours * 60 * 60) / 60);
31
+ const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);
32
+ return [hours, minutes, seconds].map(v => String(v).padStart(2, "0")).join(":");
33
+ };
34
+
35
+ const convertValueFromIndex = (value, field) => {
36
+ const type = field.settings.type;
37
+
38
+ if (type === "time") {
39
+ return convertNumberToTime(value);
40
+ } else if (!value) {
41
+ return null;
42
+ } else if (type === "dateTimeWithTimezone") {
43
+ return value;
44
+ } else if (type === "date") {
45
+ const dateValue = new Date(value);
46
+ return dateValue.toISOString().substr(0, 10);
47
+ }
48
+
49
+ return new Date(value).toISOString();
50
+ };
51
+
52
+ const convertValueToIndex = (value, field) => {
53
+ if (!value) {
54
+ return null;
55
+ } else if (field.settings.type === "time") {
56
+ return convertTimeToNumber(value);
57
+ }
58
+
59
+ return value;
60
+ };
61
+
62
+ var _default = () => ({
63
+ type: "cms-model-field-to-elastic-search",
64
+ name: "cms-model-field-to-elastic-search-datetime",
65
+ fieldType: "datetime",
66
+ unmappedType: () => {
67
+ return "date";
68
+ },
69
+
70
+ toIndex({
71
+ field,
72
+ value
73
+ }) {
74
+ const dateValue = convertValueToIndex(value, field);
75
+ return {
76
+ value: dateValue
77
+ };
78
+ },
79
+
80
+ fromIndex({
81
+ field,
82
+ value
83
+ }) {
84
+ return convertValueFromIndex(value, field);
85
+ }
86
+
87
+ });
88
+
89
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
+ export default _default;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = () => ({
9
+ type: "cms-model-field-to-elastic-search",
10
+ name: "cms-model-field-to-elastic-search-default",
11
+ fieldType: "*",
12
+
13
+ toIndex({
14
+ field,
15
+ getFieldTypePlugin,
16
+ value
17
+ }) {
18
+ const fieldTypePlugin = getFieldTypePlugin(field.type); // when field is searchable, assign it to `values`
19
+
20
+ if (fieldTypePlugin.isSearchable === true) {
21
+ return {
22
+ value
23
+ };
24
+ } // when field is not searchable, move its value to `rawValues`.
25
+ // `rawValues` is a field in ES index that's not being indexed.
26
+
27
+
28
+ return {
29
+ rawValue: value
30
+ };
31
+ },
32
+
33
+ fromIndex({
34
+ field,
35
+ getFieldTypePlugin,
36
+ value,
37
+ rawValue
38
+ }) {
39
+ const {
40
+ isSearchable
41
+ } = getFieldTypePlugin(field.type);
42
+ return isSearchable === true ? value : rawValue;
43
+ }
44
+
45
+ });
46
+
47
+ exports.default = _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("../../types").CmsModelFieldToElasticsearchPlugin[];
2
+ export default _default;
@@ -0,0 +1,24 @@
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 _richTextIndexing = _interopRequireDefault(require("./richTextIndexing"));
11
+
12
+ var _longTextIndexing = _interopRequireDefault(require("./longTextIndexing"));
13
+
14
+ var _defaultFieldIndexing = _interopRequireDefault(require("./defaultFieldIndexing"));
15
+
16
+ var _dateTimeIndexing = _interopRequireDefault(require("./dateTimeIndexing"));
17
+
18
+ var _numberIndexing = _interopRequireDefault(require("./numberIndexing"));
19
+
20
+ var _objectIndexing = _interopRequireDefault(require("./objectIndexing"));
21
+
22
+ var _default = () => [(0, _dateTimeIndexing.default)(), (0, _richTextIndexing.default)(), (0, _longTextIndexing.default)(), (0, _defaultFieldIndexing.default)(), (0, _numberIndexing.default)(), (0, _objectIndexing.default)()];
23
+
24
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
+ export default _default;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = () => ({
9
+ type: "cms-model-field-to-elastic-search",
10
+ name: "cms-model-field-to-elastic-search-long-text",
11
+ fieldType: "long-text",
12
+
13
+ toIndex({
14
+ rawValue
15
+ }) {
16
+ /**
17
+ * We want to store the value (rawValue) from entry before it was prepared for storage as value to be searched on.
18
+ * And we want to store prepared value into rawValue so it is not indexed.
19
+ */
20
+ return {
21
+ value: rawValue ? encodeURIComponent(rawValue) : ""
22
+ };
23
+ },
24
+
25
+ /**
26
+ * When extracting from index, we can return the value that was stored to be searched - and then no decompression will be required.
27
+ */
28
+ fromIndex({
29
+ value
30
+ }) {
31
+ return value ? decodeURIComponent(value) : "";
32
+ }
33
+
34
+ });
35
+
36
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
+ export default _default;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ const convertToString = value => {
9
+ if (Array.isArray(value) === false) {
10
+ return value;
11
+ }
12
+
13
+ return value.map(String);
14
+ };
15
+
16
+ const convertToFloat = value => {
17
+ if (Array.isArray(value) === false) {
18
+ return typeof value === "string" ? parseFloat(value) : value;
19
+ }
20
+
21
+ return value.map(v => parseFloat(v));
22
+ };
23
+
24
+ var _default = () => ({
25
+ type: "cms-model-field-to-elastic-search",
26
+ name: "cms-model-field-to-elastic-search-number",
27
+ fieldType: "number",
28
+ unmappedType: () => {
29
+ return "float";
30
+ },
31
+
32
+ toIndex({
33
+ value
34
+ }) {
35
+ return {
36
+ value: convertToString(value)
37
+ };
38
+ },
39
+
40
+ fromIndex({
41
+ value
42
+ }) {
43
+ return convertToFloat(value);
44
+ }
45
+
46
+ });
47
+
48
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
+ export default _default;