@webiny/api-headless-cms-ddb 0.0.0-unstable.bca7b3e350 → 0.0.0-unstable.c27f4d8a31
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.
- package/README.md +6 -20
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +6 -89
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +6 -63
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +6 -90
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +7 -28
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +60 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +8 -20
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +34 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +6 -20
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/longText.js +13 -35
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +27 -88
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +7 -19
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +47 -111
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +31 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +4 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +19 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +35 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +50 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +50 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +56 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +19 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +3 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +14 -30
- package/operations/entry/dataLoaders.js +58 -271
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +5 -5
- package/operations/entry/filtering/createExpressions.js +30 -68
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +6 -4
- package/operations/entry/filtering/createFields.js +86 -103
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.d.ts +6 -6
- package/operations/entry/filtering/extractSort.js +39 -32
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +6 -6
- package/operations/entry/filtering/filter.js +36 -64
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
- package/operations/entry/filtering/fullTextSearch.js +6 -24
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +5 -27
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.d.ts +2 -2
- package/operations/entry/filtering/index.js +3 -20
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.d.ts +2 -2
- package/operations/entry/filtering/mapPlugins.js +4 -18
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +9 -20
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/filtering/plugins/index.js +7 -16
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +16 -39
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +21 -36
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +6 -6
- package/operations/entry/filtering/sort.js +17 -34
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.d.ts +2 -4
- package/operations/entry/filtering/systemFields.js +102 -43
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.d.ts +1 -1
- package/operations/entry/filtering/transform.js +2 -10
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +3 -3
- package/operations/entry/filtering/types.js +2 -4
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/filtering/values.d.ts +1 -1
- package/operations/entry/filtering/values.js +5 -17
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +5 -15
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +3 -4
- package/operations/entry/index.js +732 -410
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +40 -2
- package/operations/entry/keys.js +54 -47
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -4
- package/operations/group/index.js +44 -91
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +36 -70
- package/operations/model/index.js.map +1 -1
- package/package.json +22 -29
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +4 -3
- package/plugins/CmsEntryFieldFilterPathPlugin.js +14 -29
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
- package/plugins/CmsEntryFieldFilterPlugin.js +9 -19
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldSortingPlugin.js +5 -24
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +16 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -3
- package/plugins/index.js +5 -43
- package/plugins/index.js.map +1 -1
- package/types.d.ts +24 -19
- package/types.js +5 -13
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -58
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -46
- package/definitions/system.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -109
- package/dynamoDb/storage/date.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -74
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -135
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -99
- package/operations/system/index.js.map +0 -1
|
@@ -1,40 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createPlainObjectPathPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
|
|
13
|
-
|
|
14
1
|
/**
|
|
15
2
|
* File is @internal
|
|
16
3
|
*/
|
|
4
|
+
import WebinyError from "@webiny/error";
|
|
5
|
+
import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
17
6
|
const createPath = ({
|
|
18
7
|
field
|
|
19
8
|
}) => {
|
|
20
9
|
const {
|
|
21
10
|
path
|
|
22
11
|
} = field.settings || {};
|
|
23
|
-
|
|
24
12
|
if (!path) {
|
|
25
|
-
throw new
|
|
13
|
+
throw new WebinyError("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
26
14
|
field
|
|
27
15
|
});
|
|
28
16
|
}
|
|
29
|
-
|
|
30
17
|
return path;
|
|
31
18
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
|
|
19
|
+
export const createPlainObjectPathPlugin = () => {
|
|
20
|
+
return new CmsEntryFieldFilterPathPlugin({
|
|
35
21
|
fieldType: "plainObject",
|
|
36
22
|
path: createPath
|
|
37
23
|
});
|
|
38
24
|
};
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
//# sourceMappingURL=plainObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryFieldFilterPathPlugin","createPath","field","path","settings","createPlainObjectPathPlugin","fieldType"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,6BAA6B;AAEtC,MAAMC,UAA8B,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EAClD,MAAM;IAAEC;EAAK,CAAC,GAAGD,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;EACrC,IAAI,CAACD,IAAI,EAAE;IACP,MAAM,IAAIJ,WAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EG;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAED,OAAO,MAAME,2BAA2B,GAAGA,CAAA,KAAqC;EAC5E,OAAO,IAAIL,6BAA6B,CAAC;IACrCM,SAAS,EAAE,aAAa;IACxBH,IAAI,EAAEF;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createLongTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _gzip = require("@webiny/utils/compression/gzip");
|
|
13
|
-
|
|
14
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
1
|
/**
|
|
17
2
|
* File is @internal
|
|
18
3
|
*/
|
|
4
|
+
|
|
5
|
+
import WebinyError from "@webiny/error";
|
|
6
|
+
import { compress as gzip, decompress as ungzip } from "@webiny/utils/compression/gzip.js";
|
|
7
|
+
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
19
8
|
const GZIP = "gzip";
|
|
20
9
|
const TO_STORAGE_ENCODING = "base64";
|
|
21
10
|
const FROM_STORAGE_ENCODING = "utf8";
|
|
22
|
-
|
|
23
11
|
const convertToBuffer = value => {
|
|
24
12
|
if (typeof value === "string") {
|
|
25
13
|
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
26
14
|
}
|
|
27
|
-
|
|
28
15
|
return value;
|
|
29
16
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
export const createLongTextStorageTransformPlugin = () => {
|
|
18
|
+
return new StorageTransformPlugin({
|
|
19
|
+
name: "headless-cms.storage-transform.long-text.default",
|
|
33
20
|
fieldType: "long-text",
|
|
34
21
|
fromStorage: async ({
|
|
35
22
|
field,
|
|
36
23
|
value: storageValue
|
|
37
24
|
}) => {
|
|
38
25
|
const typeOf = typeof storageValue;
|
|
39
|
-
|
|
40
26
|
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
41
27
|
return storageValue;
|
|
42
28
|
} else if (typeOf !== "object") {
|
|
43
|
-
throw new
|
|
29
|
+
throw new WebinyError(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
44
30
|
}
|
|
45
|
-
|
|
46
31
|
const {
|
|
47
32
|
compression,
|
|
48
33
|
value,
|
|
@@ -51,25 +36,21 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
51
36
|
/**
|
|
52
37
|
* Check if possibly undefined, null, empty...
|
|
53
38
|
*/
|
|
54
|
-
|
|
55
39
|
if (!compression) {
|
|
56
|
-
throw new
|
|
40
|
+
throw new WebinyError(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
57
41
|
value: storageValue
|
|
58
42
|
});
|
|
59
43
|
} else if (compression !== GZIP) {
|
|
60
|
-
throw new
|
|
44
|
+
throw new WebinyError(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
61
45
|
compression
|
|
62
46
|
});
|
|
63
47
|
}
|
|
64
|
-
|
|
65
48
|
try {
|
|
66
|
-
const buf = await (
|
|
49
|
+
const buf = await ungzip(convertToBuffer(value));
|
|
67
50
|
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
68
|
-
|
|
69
51
|
if (!isArray) {
|
|
70
52
|
return result;
|
|
71
53
|
}
|
|
72
|
-
|
|
73
54
|
return JSON.parse(result);
|
|
74
55
|
} catch (ex) {
|
|
75
56
|
console.log("Error while transforming long-text.");
|
|
@@ -86,23 +67,20 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
86
67
|
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
87
68
|
return initialValue;
|
|
88
69
|
}
|
|
89
|
-
|
|
90
70
|
const isArray = Array.isArray(initialValue);
|
|
91
71
|
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
92
|
-
const compressedValue = await (
|
|
72
|
+
const compressedValue = await gzip(value);
|
|
93
73
|
const result = {
|
|
94
74
|
compression: GZIP,
|
|
95
75
|
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
96
76
|
};
|
|
97
|
-
|
|
98
77
|
if (!isArray) {
|
|
99
78
|
return result;
|
|
100
79
|
}
|
|
101
|
-
|
|
102
80
|
result.isArray = isArray;
|
|
103
81
|
return result;
|
|
104
82
|
}
|
|
105
83
|
});
|
|
106
84
|
};
|
|
107
85
|
|
|
108
|
-
|
|
86
|
+
//# sourceMappingURL=longText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","
|
|
1
|
+
{"version":3,"names":["WebinyError","compress","gzip","decompress","ungzip","StorageTransformPlugin","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","name","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","storageId","fieldId","compression","JSON","stringify","buf","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip.js\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":"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O,MAAM;MACjB;MACAA,MAAM,CAACP,OAAO,GAAGA,OAAO;MACxB,OAAOO,MAAM;IACjB;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,113 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createRichTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _jsonpack = _interopRequireDefault(require("jsonpack"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
1
|
/**
|
|
17
2
|
* File is @internal
|
|
18
3
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// TODO @ts-refactor figure better type
|
|
26
|
-
const transformArray = value => {
|
|
27
|
-
if (!value) {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let isArray = Array.isArray(value);
|
|
32
|
-
const shouldBeArray = value instanceof Array === false && isArray;
|
|
33
|
-
|
|
34
|
-
if (shouldBeArray) {
|
|
35
|
-
value = Array.from(value);
|
|
36
|
-
isArray = true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (typeof value === "object" || isArray) {
|
|
40
|
-
for (const k in value) {
|
|
41
|
-
value[k] = transformArray(value[k]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return value;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const createRichTextStorageTransformPlugin = () => {
|
|
49
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
4
|
+
import WebinyError from "@webiny/error";
|
|
5
|
+
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
6
|
+
import { CompressorPlugin } from "@webiny/api";
|
|
7
|
+
export const createRichTextStorageTransformPlugin = () => {
|
|
8
|
+
return new StorageTransformPlugin({
|
|
9
|
+
name: "headless-cms.storage-transform.rich-text.default",
|
|
50
10
|
fieldType: "rich-text",
|
|
51
11
|
fromStorage: async ({
|
|
52
12
|
field,
|
|
53
|
-
value: storageValue
|
|
13
|
+
value: storageValue,
|
|
14
|
+
plugins
|
|
54
15
|
}) => {
|
|
55
16
|
if (!storageValue) {
|
|
56
17
|
return storageValue;
|
|
57
18
|
} else if (typeof storageValue !== "object") {
|
|
58
|
-
throw new
|
|
19
|
+
throw new WebinyError(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
59
20
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (storageValue.hasOwnProperty("compression") === false) {
|
|
21
|
+
let compressor;
|
|
22
|
+
try {
|
|
23
|
+
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
24
|
+
} catch {
|
|
67
25
|
return storageValue;
|
|
68
26
|
}
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
compression,
|
|
72
|
-
value
|
|
73
|
-
} = storageValue;
|
|
74
|
-
|
|
75
|
-
if (!compression) {
|
|
76
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
77
|
-
value: storageValue
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (compression !== "jsonpack") {
|
|
82
|
-
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
83
|
-
compression
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
27
|
try {
|
|
88
|
-
return
|
|
28
|
+
return await compressor.getCompressor().decompress(storageValue);
|
|
89
29
|
} catch {
|
|
90
|
-
return
|
|
30
|
+
return storageValue;
|
|
91
31
|
}
|
|
92
32
|
},
|
|
93
33
|
toStorage: async ({
|
|
94
|
-
value
|
|
34
|
+
value,
|
|
35
|
+
plugins
|
|
95
36
|
}) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
37
|
+
let compressor;
|
|
38
|
+
try {
|
|
39
|
+
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
40
|
+
} catch {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return await compressor.getCompressor().compress(value);
|
|
45
|
+
} catch {
|
|
101
46
|
return value;
|
|
102
47
|
}
|
|
103
|
-
|
|
104
|
-
value = transformArray(value);
|
|
105
|
-
return {
|
|
106
|
-
compression: "jsonpack",
|
|
107
|
-
value: value ? _jsonpack.default.pack(value) : value
|
|
108
|
-
};
|
|
109
48
|
}
|
|
110
49
|
});
|
|
111
50
|
};
|
|
112
51
|
|
|
113
|
-
|
|
52
|
+
//# sourceMappingURL=richText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","StorageTransformPlugin","CompressorPlugin","createRichTextStorageTransformPlugin","name","fieldType","fromStorage","field","value","storageValue","plugins","storageId","fieldId","compressor","oneByType","type","getCompressor","decompress","toStorage","compress"],"sources":["richText.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport const createRichTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue, plugins }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return storageValue;\n }\n\n try {\n return await compressor.getCompressor().decompress(storageValue);\n } catch {\n return storageValue;\n }\n },\n toStorage: async ({ value, plugins }) => {\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gBAAgB,QAAQ,aAAa;AAE9C,OAAO,MAAMC,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAIF,sBAAsB,CAAC;IAC9BG,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEC,KAAK,EAAEC,YAAY;MAAEC;IAAQ,CAAC,KAAK;MAC5D,IAAI,CAACD,YAAY,EAAE;QACf,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;QACzC,MAAM,IAAIT,WAAW,CACjB,gFAAgFO,KAAK,CAACI,SAAS,OAAOJ,KAAK,CAACK,OAAO,GACvH,CAAC;MACL;MAEA,IAAIC,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGH,OAAO,CAACI,SAAS,CAAmBZ,gBAAgB,CAACa,IAAI,CAAC;MAC3E,CAAC,CAAC,MAAM;QACJ,OAAON,YAAY;MACvB;MAEA,IAAI;QACA,OAAO,MAAMI,UAAU,CAACG,aAAa,CAAC,CAAC,CAACC,UAAU,CAACR,YAAY,CAAC;MACpE,CAAC,CAAC,MAAM;QACJ,OAAOA,YAAY;MACvB;IACJ,CAAC;IACDS,SAAS,EAAE,MAAAA,CAAO;MAAEV,KAAK;MAAEE;IAAQ,CAAC,KAAK;MACrC,IAAIG,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGH,OAAO,CAACI,SAAS,CAAmBZ,gBAAgB,CAACa,IAAI,CAAC;MAC3E,CAAC,CAAC,MAAM;QACJ,OAAOP,KAAK;MAChB;MACA,IAAI;QACA,OAAO,MAAMK,UAAU,CAACG,aAAa,CAAC,CAAC,CAACG,QAAQ,CAACX,KAAK,CAAC;MAC3D,CAAC,CAAC,MAAM;QACJ,OAAOA,KAAK;MAChB;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* File is @internal
|
|
3
3
|
*/
|
|
4
|
-
import { CmsFieldFilterValueTransformPlugin } from "../../types";
|
|
4
|
+
import type { CmsFieldFilterValueTransformPlugin } from "../../types.js";
|
|
5
5
|
export declare const createDatetimeTransformValuePlugin: () => CmsFieldFilterValueTransformPlugin;
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDatetimeTransformValuePlugin = void 0;
|
|
7
|
-
|
|
8
|
-
var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
|
|
9
|
-
|
|
10
|
-
var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
|
|
11
|
-
|
|
12
1
|
/**
|
|
13
2
|
* File is @internal
|
|
14
3
|
*/
|
|
15
|
-
|
|
4
|
+
|
|
5
|
+
import { TimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js";
|
|
6
|
+
import { DateTimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js";
|
|
7
|
+
const timeTransformer = new TimeTransformPlugin({
|
|
16
8
|
fields: ["*"]
|
|
17
9
|
});
|
|
18
|
-
const dateTimeTransformer = new
|
|
10
|
+
const dateTimeTransformer = new DateTimeTransformPlugin({
|
|
19
11
|
fields: ["*"]
|
|
20
12
|
});
|
|
21
|
-
|
|
22
|
-
const createDatetimeTransformValuePlugin = () => {
|
|
13
|
+
export const createDatetimeTransformValuePlugin = () => {
|
|
23
14
|
return {
|
|
24
15
|
type: "cms-field-filter-value-transform",
|
|
25
16
|
name: "cms-field-value-filter-transform-datetime",
|
|
26
17
|
fieldType: "datetime",
|
|
27
|
-
|
|
28
18
|
/**
|
|
29
19
|
* Always transform into the milliseconds.
|
|
30
20
|
*/
|
|
@@ -35,13 +25,11 @@ const createDatetimeTransformValuePlugin = () => {
|
|
|
35
25
|
const {
|
|
36
26
|
type
|
|
37
27
|
} = field.settings || {};
|
|
38
|
-
|
|
39
28
|
if (type === "time") {
|
|
40
29
|
return timeTransformer.transform({
|
|
41
30
|
value
|
|
42
31
|
});
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
return dateTimeTransformer.transform({
|
|
46
34
|
value
|
|
47
35
|
});
|
|
@@ -49,4 +37,4 @@ const createDatetimeTransformValuePlugin = () => {
|
|
|
49
37
|
};
|
|
50
38
|
};
|
|
51
39
|
|
|
52
|
-
|
|
40
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["TimeTransformPlugin","DateTimeTransformPlugin","timeTransformer","fields","dateTimeTransformer","createDatetimeTransformValuePlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,mBAAmB,QAAQ,gEAAgE;AACpG,SAASC,uBAAuB,QAAQ,oEAAoE;AAE5G,MAAMC,eAAe,GAAG,IAAIF,mBAAmB,CAAC;EAC5CG,MAAM,EAAE,CAAC,GAAG;AAChB,CAAC,CAAC;AACF,MAAMC,mBAAmB,GAAG,IAAIH,uBAAuB,CAAC;EACpDE,MAAM,EAAE,CAAC,GAAG;AAChB,CAAC,CAAC;AAEF,OAAO,MAAME,kCAAkC,GAAGA,CAAA,KAA0C;EACxF,OAAO;IACHC,IAAI,EAAE,kCAAkC;IACxCC,IAAI,EAAE,2CAA2C;IACjDC,SAAS,EAAE,UAAU;IACrB;AACR;AACA;IACQC,SAAS,EAAEA,CAAC;MAAEC,KAAK;MAAEC;IAAM,CAAC,KAAK;MAC7B,MAAM;QAAEL;MAAK,CAAC,GAAGI,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;MACrC,IAAIN,IAAI,KAAK,MAAM,EAAE;QACjB,OAAOJ,eAAe,CAACO,SAAS,CAAC;UAC7BE;QACJ,CAAC,CAAC;MACN;MACA,OAAOP,mBAAmB,CAACK,SAAS,CAAC;QACjCE;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StorageOperationsFactory } from "./types";
|
|
2
|
-
export * from "./plugins";
|
|
1
|
+
import type { StorageOperationsFactory } from "./types.js";
|
|
2
|
+
export * from "./plugins/index.js";
|
|
3
3
|
export declare const createStorageOperations: StorageOperationsFactory;
|