@webiny/api-headless-cms-ddb 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b
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 -6
- package/definitions/entry.js +8 -185
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -6
- package/definitions/group.js +8 -63
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -6
- package/definitions/model.js +8 -107
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +3 -5
- package/definitions/table.js +6 -29
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +7 -13
- package/dynamoDb/index.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +85 -121
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +36 -52
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +36 -52
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +38 -58
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +3 -3
- package/operations/entry/dataLoader/index.js +13 -35
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +4 -4
- package/operations/entry/dataLoader/types.js +0 -7
- package/operations/entry/dataLoaders.d.ts +11 -12
- package/operations/entry/dataLoaders.js +83 -109
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/index.d.ts +4 -3
- package/operations/entry/index.js +908 -1277
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +52 -49
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +113 -166
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +99 -143
- package/operations/model/index.js.map +1 -1
- package/package.json +29 -25
- package/plugins/index.d.ts +2 -4
- package/plugins/index.js +1 -51
- package/types.d.ts +19 -42
- package/types.js +6 -12
- package/types.js.map +1 -1
- package/definitions/system.d.ts +0 -10
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/dynamoDb/path/locationFolderId.d.ts +0 -2
- package/dynamoDb/path/locationFolderId.js +0 -43
- package/dynamoDb/path/locationFolderId.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -35
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -94
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -61
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -47
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -178
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -16
- package/operations/entry/filtering/createFields.js +0 -108
- package/operations/entry/filtering/createFields.js.map +0 -1
- package/operations/entry/filtering/extractSort.d.ts +0 -17
- package/operations/entry/filtering/extractSort.js +0 -69
- package/operations/entry/filtering/extractSort.js.map +0 -1
- package/operations/entry/filtering/filter.d.ts +0 -15
- package/operations/entry/filtering/filter.js +0 -158
- package/operations/entry/filtering/filter.js.map +0 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
- package/operations/entry/filtering/fullTextSearch.js +0 -50
- package/operations/entry/filtering/fullTextSearch.js.map +0 -1
- package/operations/entry/filtering/getValue.d.ts +0 -5
- package/operations/entry/filtering/getValue.js +0 -66
- package/operations/entry/filtering/getValue.js.map +0 -1
- package/operations/entry/filtering/index.d.ts +0 -2
- package/operations/entry/filtering/index.js +0 -21
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/mapPlugins.d.ts +0 -8
- package/operations/entry/filtering/mapPlugins.js +0 -33
- package/operations/entry/filtering/mapPlugins.js.map +0 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -45
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/filtering/plugins/index.js +0 -16
- package/operations/entry/filtering/plugins/index.js.map +0 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -90
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -80
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -65
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -71
- package/operations/entry/filtering/sort.js.map +0 -1
- package/operations/entry/filtering/systemFields.d.ts +0 -4
- package/operations/entry/filtering/systemFields.js +0 -90
- package/operations/entry/filtering/systemFields.js.map +0 -1
- package/operations/entry/filtering/transform.d.ts +0 -6
- package/operations/entry/filtering/transform.js +0 -18
- package/operations/entry/filtering/transform.js.map +0 -1
- package/operations/entry/filtering/types.d.ts +0 -40
- package/operations/entry/filtering/types.js +0 -7
- package/operations/entry/filtering/types.js.map +0 -1
- package/operations/entry/filtering/values.d.ts +0 -2
- package/operations/entry/filtering/values.js +0 -24
- package/operations/entry/filtering/values.js.map +0 -1
- package/operations/entry/filtering/where.d.ts +0 -5
- package/operations/entry/filtering/where.js +0 -35
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -48
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -27
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -27
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -23
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.a4f3e4ea8b",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"keywords": [
|
|
6
10
|
"@webiny/api-headless-cms",
|
|
7
11
|
"storage-operations",
|
|
@@ -22,34 +26,34 @@
|
|
|
22
26
|
],
|
|
23
27
|
"license": "MIT",
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@webiny/api": "0.0.0-unstable.
|
|
26
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"@webiny/
|
|
31
|
-
"@webiny/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
29
|
+
"@webiny/api": "0.0.0-unstable.a4f3e4ea8b",
|
|
30
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.a4f3e4ea8b",
|
|
31
|
+
"@webiny/api-headless-cms-storage": "0.0.0-unstable.a4f3e4ea8b",
|
|
32
|
+
"@webiny/aws-sdk": "0.0.0-unstable.a4f3e4ea8b",
|
|
33
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.a4f3e4ea8b",
|
|
34
|
+
"@webiny/db-utils": "0.0.0-unstable.a4f3e4ea8b",
|
|
35
|
+
"@webiny/error": "0.0.0-unstable.a4f3e4ea8b",
|
|
36
|
+
"@webiny/feature": "0.0.0-unstable.a4f3e4ea8b",
|
|
37
|
+
"@webiny/handler": "0.0.0-unstable.a4f3e4ea8b",
|
|
38
|
+
"@webiny/handler-db": "0.0.0-unstable.a4f3e4ea8b",
|
|
39
|
+
"@webiny/plugins": "0.0.0-unstable.a4f3e4ea8b",
|
|
40
|
+
"@webiny/utils": "0.0.0-unstable.a4f3e4ea8b",
|
|
41
|
+
"dataloader": "2.2.3"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
|
-
"@types/dot-object": "2.1.6",
|
|
39
44
|
"@types/jsonpack": "1.1.6",
|
|
40
|
-
"@webiny/
|
|
41
|
-
"@webiny/
|
|
42
|
-
"
|
|
45
|
+
"@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
|
|
46
|
+
"@webiny/di": "1.0.2",
|
|
47
|
+
"@webiny/project-utils": "0.0.0-unstable.a4f3e4ea8b",
|
|
43
48
|
"jest-dynalite": "3.6.1",
|
|
44
|
-
"typescript": "
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"vitest": "4.1.10"
|
|
45
51
|
},
|
|
46
52
|
"publishConfig": {
|
|
47
|
-
"access": "public"
|
|
48
|
-
"directory": "dist"
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "node ../cli/bin.js run build",
|
|
52
|
-
"watch": "node ../cli/bin.js run watch"
|
|
53
|
+
"access": "public"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
56
|
+
"webiny": {
|
|
57
|
+
"publishFrom": "dist"
|
|
58
|
+
}
|
|
55
59
|
}
|
package/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from "./CmsEntryFieldFilterPlugin";
|
|
4
|
-
export * from "./CmsFieldFilterValueTransformPlugin";
|
|
1
|
+
export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldSortingPlugin, createCmsEntryFieldSortingPlugin, CmsEntryFieldFilterPlugin, CmsFieldFilterValueTransformPlugin } from "@webiny/api-headless-cms-storage";
|
|
2
|
+
export type { CreatePathCallable, CmsEntryFieldFilterPluginCreateResponse } from "@webiny/api-headless-cms-storage";
|
package/plugins/index.js
CHANGED
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
|
|
7
|
-
Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _CmsEntryFieldFilterPathPlugin[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _CmsEntryFieldSortingPlugin = require("./CmsEntryFieldSortingPlugin");
|
|
18
|
-
Object.keys(_CmsEntryFieldSortingPlugin).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _CmsEntryFieldSortingPlugin[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _CmsEntryFieldSortingPlugin[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _CmsEntryFieldFilterPlugin = require("./CmsEntryFieldFilterPlugin");
|
|
29
|
-
Object.keys(_CmsEntryFieldFilterPlugin).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _CmsEntryFieldFilterPlugin[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _CmsEntryFieldFilterPlugin[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _CmsFieldFilterValueTransformPlugin = require("./CmsFieldFilterValueTransformPlugin");
|
|
40
|
-
Object.keys(_CmsFieldFilterValueTransformPlugin).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _CmsFieldFilterValueTransformPlugin[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _CmsFieldFilterValueTransformPlugin[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin, createCmsEntryFieldSortingPlugin } from "@webiny/api-headless-cms-storage";
|
package/types.d.ts
CHANGED
|
@@ -1,60 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { CmsEntryStorageOperations as BaseCmsEntryStorageOperations,
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interface CmsFieldFilterValueTransformParams {
|
|
8
|
-
/**
|
|
9
|
-
* A field which value we are transforming.
|
|
10
|
-
*/
|
|
11
|
-
field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
|
|
12
|
-
value: any;
|
|
13
|
-
}
|
|
14
|
-
export interface CmsFieldFilterValueTransformPlugin extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* A plugin type.
|
|
17
|
-
*/
|
|
18
|
-
type: "cms-field-filter-value-transform";
|
|
19
|
-
/**
|
|
20
|
-
* A field type this plugin is for.
|
|
21
|
-
*/
|
|
22
|
-
fieldType: string;
|
|
23
|
-
/**
|
|
24
|
-
* Transform method which expect field definition and value to transform.
|
|
25
|
-
*/
|
|
26
|
-
transform: (params: CmsFieldFilterValueTransformParams) => any;
|
|
27
|
-
}
|
|
28
|
-
export type Attributes = Record<string, AttributeDefinition>;
|
|
1
|
+
import { PluginsContainer } from "@webiny/plugins/types.js";
|
|
2
|
+
import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
|
|
4
|
+
import type { ITable } from "@webiny/db-dynamodb";
|
|
5
|
+
export type { CmsContext };
|
|
6
|
+
export type { IGroupEntity, IModelEntity, IEntryEntity };
|
|
29
7
|
export declare enum ENTITIES {
|
|
30
|
-
SYSTEM = "CmsSystem",
|
|
31
8
|
GROUPS = "CmsGroups",
|
|
32
9
|
MODELS = "CmsModels",
|
|
33
10
|
ENTRIES = "CmsEntries"
|
|
34
11
|
}
|
|
35
|
-
export interface TableModifier {
|
|
36
|
-
(table: TableConstructor<string, string, string>): TableConstructor<string, string, string>;
|
|
37
|
-
}
|
|
38
12
|
export interface StorageOperationsFactoryParams {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
table?: string;
|
|
14
|
+
plugins: PluginsContainer;
|
|
15
|
+
container: CmsContext["container"];
|
|
16
|
+
}
|
|
17
|
+
export interface IHeadlessCmsStorageOperationsGetEntitiesResult {
|
|
18
|
+
groups: IGroupEntity;
|
|
19
|
+
models: IModelEntity;
|
|
20
|
+
entries: IEntryEntity;
|
|
43
21
|
}
|
|
44
22
|
export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
|
|
45
|
-
getTable: () =>
|
|
46
|
-
getEntities: () =>
|
|
23
|
+
getTable: () => ITable;
|
|
24
|
+
getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;
|
|
47
25
|
}
|
|
48
26
|
export interface StorageOperationsFactory {
|
|
49
27
|
(params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
|
|
50
28
|
}
|
|
51
29
|
export interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {
|
|
52
|
-
dataLoaders:
|
|
30
|
+
dataLoaders: IDataLoadersHandler;
|
|
53
31
|
}
|
|
54
32
|
export interface DataLoadersHandlerInterfaceClearAllParams {
|
|
55
|
-
|
|
33
|
+
tenant: string;
|
|
56
34
|
}
|
|
57
|
-
export interface
|
|
35
|
+
export interface IDataLoadersHandler {
|
|
58
36
|
clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
|
|
59
37
|
}
|
|
60
|
-
export {};
|
package/types.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.ENTITIES = void 0;
|
|
7
|
-
let ENTITIES = exports.ENTITIES = /*#__PURE__*/function (ENTITIES) {
|
|
8
|
-
ENTITIES["SYSTEM"] = "CmsSystem";
|
|
9
|
-
ENTITIES["GROUPS"] = "CmsGroups";
|
|
10
|
-
ENTITIES["MODELS"] = "CmsModels";
|
|
11
|
-
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
12
|
-
return ENTITIES;
|
|
1
|
+
var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
|
|
2
|
+
ENTITIES["GROUPS"] = "CmsGroups";
|
|
3
|
+
ENTITIES["MODELS"] = "CmsModels";
|
|
4
|
+
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
5
|
+
return ENTITIES;
|
|
13
6
|
}({});
|
|
7
|
+
export { types_ENTITIES as ENTITIES };
|
|
14
8
|
|
|
15
9
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\nexport type { CmsContext };\n\nexport type { IGroupEntity, IModelEntity, IEntryEntity };\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface StorageOperationsFactoryParams {\n table?: string;\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n}\n\nexport interface IHeadlessCmsStorageOperationsGetEntitiesResult {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => ITable;\n getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAaO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
|
package/definitions/system.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
-
import { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
-
import type { Attributes } from "../types";
|
|
4
|
-
interface Params {
|
|
5
|
-
table: Table<string, string, string>;
|
|
6
|
-
entityName: string;
|
|
7
|
-
attributes: Attributes;
|
|
8
|
-
}
|
|
9
|
-
export declare const createSystemEntity: (params: Params) => Entity<any>;
|
|
10
|
-
export {};
|
package/definitions/system.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSystemEntity = void 0;
|
|
7
|
-
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
|
-
const createSystemEntity = params => {
|
|
9
|
-
const {
|
|
10
|
-
entityName,
|
|
11
|
-
attributes,
|
|
12
|
-
table
|
|
13
|
-
} = params;
|
|
14
|
-
return new _toolbox.Entity({
|
|
15
|
-
name: entityName,
|
|
16
|
-
table,
|
|
17
|
-
attributes: {
|
|
18
|
-
PK: {
|
|
19
|
-
partitionKey: true
|
|
20
|
-
},
|
|
21
|
-
SK: {
|
|
22
|
-
sortKey: true
|
|
23
|
-
},
|
|
24
|
-
version: {
|
|
25
|
-
type: "string"
|
|
26
|
-
},
|
|
27
|
-
locale: {
|
|
28
|
-
type: "string"
|
|
29
|
-
},
|
|
30
|
-
tenant: {
|
|
31
|
-
type: "string"
|
|
32
|
-
},
|
|
33
|
-
readAPIKey: {
|
|
34
|
-
type: "string"
|
|
35
|
-
},
|
|
36
|
-
...(attributes || {})
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.createSystemEntity = createSystemEntity;
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=system.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey","exports"],"sources":["system.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n readAPIKey: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,UAAU,EAAE;QACRH,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createLocationFolderIdPathPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
|
|
10
|
-
/**
|
|
11
|
-
* File is @internal
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const createPath = ({
|
|
15
|
-
field
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
path
|
|
19
|
-
} = field.settings || {};
|
|
20
|
-
if (!path) {
|
|
21
|
-
throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
22
|
-
field
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return path;
|
|
26
|
-
};
|
|
27
|
-
const createLocationFolderIdPathPlugin = () => {
|
|
28
|
-
return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
|
|
29
|
-
fieldType: "text",
|
|
30
|
-
path: createPath,
|
|
31
|
-
canUse: (field, parents) => {
|
|
32
|
-
if (field.fieldId !== "folderId") {
|
|
33
|
-
return false;
|
|
34
|
-
} else if (!parents?.length) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return parents[0] === "wbyAco_location";
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.createLocationFolderIdPathPlugin = createLocationFolderIdPathPlugin;
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=locationFolderId.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPathPlugin","createPath","field","path","settings","WebinyError","createLocationFolderIdPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType","canUse","parents","fieldId","length","exports"],"sources":["locationFolderId.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\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 createLocationFolderIdPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"text\",\n path: createPath,\n canUse: (field, parents) => {\n if (field.fieldId !== \"folderId\") {\n return false;\n } else if (!parents?.length) {\n return false;\n }\n return parents[0] === \"wbyAco_location\";\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,8BAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA,MAAME,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,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,gCAAgC,GAAGA,CAAA,KAAqC;EACjF,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,MAAM;IACjBL,IAAI,EAAEF,UAAU;IAChBQ,MAAM,EAAEA,CAACP,KAAK,EAAEQ,OAAO,KAAK;MACxB,IAAIR,KAAK,CAACS,OAAO,KAAK,UAAU,EAAE;QAC9B,OAAO,KAAK;MAChB,CAAC,MAAM,IAAI,CAACD,OAAO,EAAEE,MAAM,EAAE;QACzB,OAAO,KAAK;MAChB;MACA,OAAOF,OAAO,CAAC,CAAC,CAAC,KAAK,iBAAiB;IAC3C;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAAP,gCAAA,GAAAA,gCAAA","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createPlainObjectPathPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
|
|
10
|
-
/**
|
|
11
|
-
* File is @internal
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const createPath = ({
|
|
15
|
-
field
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
path
|
|
19
|
-
} = field.settings || {};
|
|
20
|
-
if (!path) {
|
|
21
|
-
throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
22
|
-
field
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return path;
|
|
26
|
-
};
|
|
27
|
-
const createPlainObjectPathPlugin = () => {
|
|
28
|
-
return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
|
|
29
|
-
fieldType: "plainObject",
|
|
30
|
-
path: createPath
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
exports.createPlainObjectPathPlugin = createPlainObjectPathPlugin;
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=plainObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPathPlugin","createPath","field","path","settings","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType","exports"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\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":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,8BAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA,MAAME,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,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,2BAA2B,GAAGA,CAAA,KAAqC;EAC5E,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,aAAa;IACxBL,IAAI,EAAEF;EACV,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAH,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File is @internal
|
|
3
|
-
*/
|
|
4
|
-
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
5
|
-
export interface StorageValue {
|
|
6
|
-
compression: string;
|
|
7
|
-
value: string;
|
|
8
|
-
isArray?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createLongTextStorageTransformPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _gzip = require("@webiny/utils/compression/gzip");
|
|
10
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
11
|
-
/**
|
|
12
|
-
* File is @internal
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const GZIP = "gzip";
|
|
16
|
-
const TO_STORAGE_ENCODING = "base64";
|
|
17
|
-
const FROM_STORAGE_ENCODING = "utf8";
|
|
18
|
-
const convertToBuffer = value => {
|
|
19
|
-
if (typeof value === "string") {
|
|
20
|
-
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
const createLongTextStorageTransformPlugin = () => {
|
|
25
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
26
|
-
name: "headless-cms.storage-transform.long-text.default",
|
|
27
|
-
fieldType: "long-text",
|
|
28
|
-
fromStorage: async ({
|
|
29
|
-
field,
|
|
30
|
-
value: storageValue
|
|
31
|
-
}) => {
|
|
32
|
-
const typeOf = typeof storageValue;
|
|
33
|
-
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
34
|
-
return storageValue;
|
|
35
|
-
} else if (typeOf !== "object") {
|
|
36
|
-
throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
37
|
-
}
|
|
38
|
-
const {
|
|
39
|
-
compression,
|
|
40
|
-
value,
|
|
41
|
-
isArray
|
|
42
|
-
} = storageValue;
|
|
43
|
-
/**
|
|
44
|
-
* Check if possibly undefined, null, empty...
|
|
45
|
-
*/
|
|
46
|
-
if (!compression) {
|
|
47
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
48
|
-
value: storageValue
|
|
49
|
-
});
|
|
50
|
-
} else if (compression !== GZIP) {
|
|
51
|
-
throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
52
|
-
compression
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const buf = await (0, _gzip.decompress)(convertToBuffer(value));
|
|
57
|
-
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
58
|
-
if (!isArray) {
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
return JSON.parse(result);
|
|
62
|
-
} catch (ex) {
|
|
63
|
-
console.log("Error while transforming long-text.");
|
|
64
|
-
console.log(ex.message);
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
toStorage: async ({
|
|
69
|
-
value: initialValue
|
|
70
|
-
}) => {
|
|
71
|
-
/**
|
|
72
|
-
* There is a possibility that we are trying to compress already compressed value.
|
|
73
|
-
*/
|
|
74
|
-
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
75
|
-
return initialValue;
|
|
76
|
-
}
|
|
77
|
-
const isArray = Array.isArray(initialValue);
|
|
78
|
-
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
79
|
-
const compressedValue = await (0, _gzip.compress)(value);
|
|
80
|
-
const result = {
|
|
81
|
-
compression: GZIP,
|
|
82
|
-
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
83
|
-
};
|
|
84
|
-
if (!isArray) {
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
result.isArray = isArray;
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
|
|
93
|
-
|
|
94
|
-
//# sourceMappingURL=longText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","name","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip","exports"],"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\";\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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","ignoreList":[]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createRichTextStorageTransformPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
10
|
-
var _api = require("@webiny/api");
|
|
11
|
-
/**
|
|
12
|
-
* File is @internal
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const createRichTextStorageTransformPlugin = () => {
|
|
16
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
17
|
-
name: "headless-cms.storage-transform.rich-text.default",
|
|
18
|
-
fieldType: "rich-text",
|
|
19
|
-
fromStorage: async ({
|
|
20
|
-
field,
|
|
21
|
-
value: storageValue,
|
|
22
|
-
plugins
|
|
23
|
-
}) => {
|
|
24
|
-
if (!storageValue) {
|
|
25
|
-
return storageValue;
|
|
26
|
-
} else if (typeof storageValue !== "object") {
|
|
27
|
-
throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
28
|
-
}
|
|
29
|
-
let compressor;
|
|
30
|
-
try {
|
|
31
|
-
compressor = plugins.oneByType(_api.CompressorPlugin.type);
|
|
32
|
-
} catch (ex) {
|
|
33
|
-
return storageValue;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
return await compressor.getCompressor().decompress(storageValue);
|
|
37
|
-
} catch {
|
|
38
|
-
return storageValue;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
toStorage: async ({
|
|
42
|
-
value,
|
|
43
|
-
plugins
|
|
44
|
-
}) => {
|
|
45
|
-
let compressor;
|
|
46
|
-
try {
|
|
47
|
-
compressor = plugins.oneByType(_api.CompressorPlugin.type);
|
|
48
|
-
} catch (ex) {
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
return await compressor.getCompressor().compress(value);
|
|
53
|
-
} catch {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=richText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","_api","createRichTextStorageTransformPlugin","StorageTransformPlugin","name","fieldType","fromStorage","field","value","storageValue","plugins","WebinyError","storageId","fieldId","compressor","oneByType","CompressorPlugin","type","ex","getCompressor","decompress","toStorage","compress","exports"],"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 (ex) {\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 (ex) {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKO,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAIC,sCAAsB,CAAC;IAC9BC,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,IAAIE,cAAW,CACjB,gFAAgFJ,KAAK,CAACK,SAAS,OAAOL,KAAK,CAACM,OAAO,GACvH,CAAC;MACL;MAEA,IAAIC,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGJ,OAAO,CAACK,SAAS,CAAmBC,qBAAgB,CAACC,IAAI,CAAC;MAC3E,CAAC,CAAC,OAAOC,EAAE,EAAE;QACT,OAAOT,YAAY;MACvB;MAEA,IAAI;QACA,OAAO,MAAMK,UAAU,CAACK,aAAa,CAAC,CAAC,CAACC,UAAU,CAACX,YAAY,CAAC;MACpE,CAAC,CAAC,MAAM;QACJ,OAAOA,YAAY;MACvB;IACJ,CAAC;IACDY,SAAS,EAAE,MAAAA,CAAO;MAAEb,KAAK;MAAEE;IAAQ,CAAC,KAAK;MACrC,IAAII,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGJ,OAAO,CAACK,SAAS,CAAmBC,qBAAgB,CAACC,IAAI,CAAC;MAC3E,CAAC,CAAC,OAAOC,EAAE,EAAE;QACT,OAAOV,KAAK;MAChB;MACA,IAAI;QACA,OAAO,MAAMM,UAAU,CAACK,aAAa,CAAC,CAAC,CAACG,QAAQ,CAACd,KAAK,CAAC;MAC3D,CAAC,CAAC,MAAM;QACJ,OAAOA,KAAK;MAChB;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACe,OAAA,CAAArB,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|