@webiny/api-headless-cms-ddb 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee
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 +10 -93
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +10 -64
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +10 -108
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +7 -26
- 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 +8 -12
- package/dynamoDb/index.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +87 -128
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -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 +5 -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 +10 -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 +24 -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 +40 -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 +40 -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 +42 -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 +18 -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 +0 -0
- package/operations/entry/dataLoaders.d.ts +14 -30
- package/operations/entry/dataLoaders.js +84 -272
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +899 -807
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +54 -49
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +117 -158
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +103 -134
- package/operations/model/index.js.map +1 -1
- package/package.json +32 -33
- package/plugins/index.d.ts +2 -4
- package/plugins/index.js +1 -49
- package/types.d.ts +25 -41
- package/types.js +8 -14
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -41
- package/definitions/system.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -91
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -95
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -45
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -176
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -14
- package/operations/entry/filtering/createFields.js +0 -105
- 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 -67
- 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 -143
- 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 -48
- 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 -63
- 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 -19
- 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 -31
- 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 -41
- 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 -13
- 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 -86
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -69
- 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 -70
- 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 -16
- 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 -5
- 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 -22
- 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 -32
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -72
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -82
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.b6d7105cee",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"keywords": [
|
|
6
10
|
"@webiny/api-headless-cms",
|
|
7
11
|
"storage-operations",
|
|
8
12
|
"dynamodb",
|
|
13
|
+
"ddb",
|
|
9
14
|
"cms:ddb"
|
|
10
15
|
],
|
|
11
16
|
"repository": {
|
|
@@ -21,40 +26,34 @@
|
|
|
21
26
|
],
|
|
22
27
|
"license": "MIT",
|
|
23
28
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
29
|
+
"@webiny/api": "0.0.0-unstable.b6d7105cee",
|
|
30
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.b6d7105cee",
|
|
31
|
+
"@webiny/api-headless-cms-storage": "0.0.0-unstable.b6d7105cee",
|
|
32
|
+
"@webiny/aws-sdk": "0.0.0-unstable.b6d7105cee",
|
|
33
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.b6d7105cee",
|
|
34
|
+
"@webiny/db-utils": "0.0.0-unstable.b6d7105cee",
|
|
35
|
+
"@webiny/error": "0.0.0-unstable.b6d7105cee",
|
|
36
|
+
"@webiny/feature": "0.0.0-unstable.b6d7105cee",
|
|
37
|
+
"@webiny/handler": "0.0.0-unstable.b6d7105cee",
|
|
38
|
+
"@webiny/handler-db": "0.0.0-unstable.b6d7105cee",
|
|
39
|
+
"@webiny/plugins": "0.0.0-unstable.b6d7105cee",
|
|
40
|
+
"@webiny/utils": "0.0.0-unstable.b6d7105cee",
|
|
41
|
+
"dataloader": "2.2.3"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"jest": "^28.1.0",
|
|
46
|
-
"jest-dynalite": "^3.2.0",
|
|
47
|
-
"jest-environment-node": "^27.2.4",
|
|
48
|
-
"ttypescript": "^1.5.12",
|
|
49
|
-
"typescript": "4.7.4"
|
|
44
|
+
"@types/jsonpack": "1.1.6",
|
|
45
|
+
"@webiny/build-tools": "0.0.0-unstable.b6d7105cee",
|
|
46
|
+
"@webiny/di": "1.0.2",
|
|
47
|
+
"@webiny/project-utils": "0.0.0-unstable.b6d7105cee",
|
|
48
|
+
"jest-dynalite": "3.6.1",
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"vitest": "4.1.10"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
53
|
-
"directory": "dist"
|
|
54
|
-
},
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "yarn webiny run build",
|
|
57
|
-
"watch": "yarn webiny run watch"
|
|
53
|
+
"access": "public"
|
|
58
54
|
},
|
|
59
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
56
|
+
"webiny": {
|
|
57
|
+
"publishFrom": "dist"
|
|
58
|
+
}
|
|
60
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,49 +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
|
-
});
|
|
1
|
+
export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin, createCmsEntryFieldSortingPlugin } from "@webiny/api-headless-cms-storage";
|
package/types.d.ts
CHANGED
|
@@ -1,53 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
|
|
29
|
-
export declare 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 };
|
|
30
7
|
export declare enum ENTITIES {
|
|
31
|
-
SYSTEM = "CmsSystem",
|
|
32
|
-
SETTINGS = "CmsSettings",
|
|
33
8
|
GROUPS = "CmsGroups",
|
|
34
9
|
MODELS = "CmsModels",
|
|
35
10
|
ENTRIES = "CmsEntries"
|
|
36
11
|
}
|
|
37
|
-
export interface TableModifier {
|
|
38
|
-
(table: TableConstructor): TableConstructor;
|
|
39
|
-
}
|
|
40
12
|
export interface StorageOperationsFactoryParams {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
13
|
+
table?: string;
|
|
14
|
+
plugins: PluginsContainer;
|
|
15
|
+
container: CmsContext["container"];
|
|
16
|
+
}
|
|
17
|
+
export interface IHeadlessCmsStorageOperationsGetEntitiesResult {
|
|
18
|
+
groups: IGroupEntity;
|
|
19
|
+
models: IModelEntity;
|
|
20
|
+
entries: IEntryEntity;
|
|
45
21
|
}
|
|
46
22
|
export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
|
|
47
|
-
getTable: () =>
|
|
48
|
-
getEntities: () =>
|
|
23
|
+
getTable: () => ITable;
|
|
24
|
+
getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;
|
|
49
25
|
}
|
|
50
26
|
export interface StorageOperationsFactory {
|
|
51
27
|
(params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
|
|
52
28
|
}
|
|
53
|
-
export {
|
|
29
|
+
export interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {
|
|
30
|
+
dataLoaders: IDataLoadersHandler;
|
|
31
|
+
}
|
|
32
|
+
export interface DataLoadersHandlerInterfaceClearAllParams {
|
|
33
|
+
tenant: string;
|
|
34
|
+
}
|
|
35
|
+
export interface IDataLoadersHandler {
|
|
36
|
+
clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
|
|
37
|
+
}
|
package/types.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
|
|
2
|
+
ENTITIES["GROUPS"] = "CmsGroups";
|
|
3
|
+
ENTITIES["MODELS"] = "CmsModels";
|
|
4
|
+
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
5
|
+
return ENTITIES;
|
|
6
|
+
}({});
|
|
7
|
+
export { types_ENTITIES as ENTITIES };
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ENTITIES = void 0;
|
|
7
|
-
let ENTITIES;
|
|
8
|
-
exports.ENTITIES = ENTITIES;
|
|
9
|
-
(function (ENTITIES) {
|
|
10
|
-
ENTITIES["SYSTEM"] = "CmsSystem";
|
|
11
|
-
ENTITIES["SETTINGS"] = "CmsSettings";
|
|
12
|
-
ENTITIES["GROUPS"] = "CmsGroups";
|
|
13
|
-
ENTITIES["MODELS"] = "CmsModels";
|
|
14
|
-
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
15
|
-
})(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
|
|
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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
|
-
import { Attributes } from "../types";
|
|
3
|
-
interface Params {
|
|
4
|
-
table: Table;
|
|
5
|
-
entityName: string;
|
|
6
|
-
attributes: Attributes;
|
|
7
|
-
}
|
|
8
|
-
export declare const createSettingsEntity: (params: Params) => Entity<any>;
|
|
9
|
-
export {};
|
package/definitions/settings.js
DELETED
|
@@ -1,53 +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.createSettingsEntity = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
10
|
-
const createSettingsEntity = params => {
|
|
11
|
-
const {
|
|
12
|
-
entityName,
|
|
13
|
-
table,
|
|
14
|
-
attributes
|
|
15
|
-
} = params;
|
|
16
|
-
return new _dynamodbToolbox.Entity({
|
|
17
|
-
name: entityName,
|
|
18
|
-
table,
|
|
19
|
-
attributes: (0, _objectSpread2.default)({
|
|
20
|
-
PK: {
|
|
21
|
-
partitionKey: true
|
|
22
|
-
},
|
|
23
|
-
SK: {
|
|
24
|
-
sortKey: true
|
|
25
|
-
},
|
|
26
|
-
TYPE: {
|
|
27
|
-
type: "string"
|
|
28
|
-
},
|
|
29
|
-
key: {
|
|
30
|
-
type: "string"
|
|
31
|
-
},
|
|
32
|
-
uploadMinFileSize: {
|
|
33
|
-
type: "number"
|
|
34
|
-
},
|
|
35
|
-
uploadMaxFileSize: {
|
|
36
|
-
type: "number"
|
|
37
|
-
},
|
|
38
|
-
srcPrefix: {
|
|
39
|
-
type: "string"
|
|
40
|
-
},
|
|
41
|
-
contentModelLastChange: {
|
|
42
|
-
type: "string"
|
|
43
|
-
},
|
|
44
|
-
tenant: {
|
|
45
|
-
type: "string"
|
|
46
|
-
},
|
|
47
|
-
locale: {
|
|
48
|
-
type: "string"
|
|
49
|
-
}
|
|
50
|
-
}, attributes || {})
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.createSettingsEntity = createSettingsEntity;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createSettingsEntity","params","entityName","table","attributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix","contentModelLastChange","tenant","locale"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, table, attributes } = 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 TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n contentModelLastChange: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AASO,MAAMA,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBC,KAAK;IACLC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,GAAG,EAAE;QACDD,IAAI,EAAE;MACV,CAAC;MACDE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MACV,CAAC;MACDG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MACV,CAAC;MACDI,SAAS,EAAE;QACPJ,IAAI,EAAE;MACV,CAAC;MACDK,sBAAsB,EAAE;QACpBL,IAAI,EAAE;MACV,CAAC;MACDM,MAAM,EAAE;QACJN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV;IAAC,GACGR,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/definitions/system.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
|
-
import { Attributes } from "../types";
|
|
3
|
-
interface Params {
|
|
4
|
-
table: Table;
|
|
5
|
-
entityName: string;
|
|
6
|
-
attributes: Attributes;
|
|
7
|
-
}
|
|
8
|
-
export declare const createSystemEntity: (params: Params) => Entity<any>;
|
|
9
|
-
export {};
|
package/definitions/system.js
DELETED
|
@@ -1,41 +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.createSystemEntity = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
10
|
-
const createSystemEntity = params => {
|
|
11
|
-
const {
|
|
12
|
-
entityName,
|
|
13
|
-
attributes,
|
|
14
|
-
table
|
|
15
|
-
} = params;
|
|
16
|
-
return new _dynamodbToolbox.Entity({
|
|
17
|
-
name: entityName,
|
|
18
|
-
table,
|
|
19
|
-
attributes: (0, _objectSpread2.default)({
|
|
20
|
-
PK: {
|
|
21
|
-
partitionKey: true
|
|
22
|
-
},
|
|
23
|
-
SK: {
|
|
24
|
-
sortKey: true
|
|
25
|
-
},
|
|
26
|
-
version: {
|
|
27
|
-
type: "string"
|
|
28
|
-
},
|
|
29
|
-
locale: {
|
|
30
|
-
type: "string"
|
|
31
|
-
},
|
|
32
|
-
tenant: {
|
|
33
|
-
type: "string"
|
|
34
|
-
},
|
|
35
|
-
readAPIKey: {
|
|
36
|
-
type: "string"
|
|
37
|
-
}
|
|
38
|
-
}, attributes || {})
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.createSystemEntity = createSystemEntity;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\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":";;;;;;;;AAAA;AASO,MAAMA,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU;MACNI,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;IAAC,GACGT,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,33 +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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPath","field","path","settings","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} 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;AACA;AAJA;AACA;AACA;;AAOA,MAAMA,UAA8B,GAAG,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,GAAG,MAAqC;EAC5E,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,aAAa;IACxBL,IAAI,EAAEF;EACV,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/dynamoDb/storage/date.js
DELETED
|
@@ -1,91 +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.createDateStorageTransformPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
10
|
-
/**
|
|
11
|
-
* File is @internal
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const excludeTypes = ["time", "dateTimeWithTimezone"];
|
|
15
|
-
const convertFromStorage = (field, value) => {
|
|
16
|
-
try {
|
|
17
|
-
if (field.multipleValues) {
|
|
18
|
-
const result = [];
|
|
19
|
-
for (const v of value) {
|
|
20
|
-
if (!v) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
result.push(new Date(v));
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
return new Date(value);
|
|
30
|
-
} catch {
|
|
31
|
-
console.log(`Could not transform from storage for field type`);
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const convertValueToStorage = (field, value) => {
|
|
36
|
-
if (value.toISOString) {
|
|
37
|
-
return value.toISOString();
|
|
38
|
-
} else if (typeof value === "string") {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
|
|
42
|
-
value: value,
|
|
43
|
-
fieldId: field.fieldId,
|
|
44
|
-
storageId: field.storageId
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const createDateStorageTransformPlugin = () => {
|
|
48
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
49
|
-
fieldType: "datetime",
|
|
50
|
-
fromStorage: async ({
|
|
51
|
-
value,
|
|
52
|
-
field
|
|
53
|
-
}) => {
|
|
54
|
-
const {
|
|
55
|
-
type
|
|
56
|
-
} = field.settings || {};
|
|
57
|
-
if (!value || !type || excludeTypes.includes(type)) {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
return convertFromStorage(field, value);
|
|
61
|
-
},
|
|
62
|
-
toStorage: async ({
|
|
63
|
-
value,
|
|
64
|
-
field
|
|
65
|
-
}) => {
|
|
66
|
-
const {
|
|
67
|
-
type
|
|
68
|
-
} = field.settings || {};
|
|
69
|
-
if (!value || !type || excludeTypes.includes(type)) {
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
if (field.multipleValues) {
|
|
73
|
-
const multipleValues = value;
|
|
74
|
-
return (multipleValues || []).filter(v => !!v).map(v => {
|
|
75
|
-
return convertValueToStorage(field, v);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (value.toISOString) {
|
|
79
|
-
return value.toISOString();
|
|
80
|
-
} else if (typeof value === "string") {
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
|
|
84
|
-
value,
|
|
85
|
-
fieldId: field.fieldId,
|
|
86
|
-
storageId: field.storageId
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
exports.createDateStorageTransformPlugin = createDateStorageTransformPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","result","v","push","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","filter","map"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (\n field: Pick<CmsModelField, \"multipleValues\">,\n value: string | string[]\n) => {\n try {\n if (field.multipleValues) {\n const result: Date[] = [];\n for (const v of value) {\n if (!v) {\n continue;\n }\n try {\n result.push(new Date(v));\n } catch {}\n }\n return result;\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n};\n"],"mappings":"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"}
|
|
@@ -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,91 +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
|
-
fieldType: "long-text",
|
|
27
|
-
fromStorage: async ({
|
|
28
|
-
field,
|
|
29
|
-
value: storageValue
|
|
30
|
-
}) => {
|
|
31
|
-
const typeOf = typeof storageValue;
|
|
32
|
-
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
33
|
-
return storageValue;
|
|
34
|
-
} else if (typeOf !== "object") {
|
|
35
|
-
throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
36
|
-
}
|
|
37
|
-
const {
|
|
38
|
-
compression,
|
|
39
|
-
value,
|
|
40
|
-
isArray
|
|
41
|
-
} = storageValue;
|
|
42
|
-
/**
|
|
43
|
-
* Check if possibly undefined, null, empty...
|
|
44
|
-
*/
|
|
45
|
-
if (!compression) {
|
|
46
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
47
|
-
value: storageValue
|
|
48
|
-
});
|
|
49
|
-
} else if (compression !== GZIP) {
|
|
50
|
-
throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
51
|
-
compression
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const buf = await (0, _gzip.decompress)(convertToBuffer(value));
|
|
56
|
-
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
57
|
-
if (!isArray) {
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
return JSON.parse(result);
|
|
61
|
-
} catch (ex) {
|
|
62
|
-
console.log("Error while transforming long-text.");
|
|
63
|
-
console.log(ex.message);
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
toStorage: async ({
|
|
68
|
-
value: initialValue
|
|
69
|
-
}) => {
|
|
70
|
-
/**
|
|
71
|
-
* There is a possibility that we are trying to compress already compressed value.
|
|
72
|
-
*/
|
|
73
|
-
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
74
|
-
return initialValue;
|
|
75
|
-
}
|
|
76
|
-
const isArray = Array.isArray(initialValue);
|
|
77
|
-
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
78
|
-
const compressedValue = await (0, _gzip.compress)(value);
|
|
79
|
-
const result = {
|
|
80
|
-
compression: GZIP,
|
|
81
|
-
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
82
|
-
};
|
|
83
|
-
if (!isArray) {
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
result.isArray = isArray;
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
|