@webiny/api-headless-cms-ddb 5.17.4 → 5.18.0-beta.3
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/definitions/entry.d.ts +6 -4
- package/definitions/entry.js +19 -8
- package/definitions/group.d.ts +8 -0
- package/definitions/group.js +74 -0
- package/definitions/model.d.ts +8 -0
- package/definitions/model.js +96 -0
- package/definitions/settings.d.ts +8 -0
- package/definitions/settings.js +62 -0
- package/definitions/system.d.ts +8 -0
- package/definitions/system.js +50 -0
- package/definitions/table.d.ts +6 -12
- package/definitions/table.js +15 -15
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -3
- package/dynamoDb/path/plainObject.js +1 -2
- package/dynamoDb/path/ref.js +1 -2
- package/dynamoDb/storage/date.d.ts +2 -2
- package/dynamoDb/storage/date.js +17 -21
- package/dynamoDb/storage/longText.d.ts +7 -0
- package/dynamoDb/storage/longText.js +83 -0
- package/dynamoDb/storage/richText.d.ts +2 -2
- package/dynamoDb/storage/richText.js +69 -67
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +1 -2
- package/index.d.ts +2 -6
- package/index.js +108 -13
- package/operations/entry/dataLoaders.d.ts +34 -19
- package/operations/entry/dataLoaders.js +158 -138
- package/operations/entry/index.d.ts +8 -4
- package/operations/entry/index.js +812 -16
- package/operations/entry/keys.d.ts +25 -0
- package/operations/entry/keys.js +62 -0
- package/operations/entry/systemFields.d.ts +2 -2
- package/operations/entry/systemFields.js +1 -2
- package/operations/entry/utils.d.ts +13 -9
- package/operations/entry/utils.js +62 -18
- package/operations/group/index.d.ts +8 -0
- package/operations/group/index.js +198 -0
- package/operations/model/index.d.ts +6 -3
- package/operations/model/index.js +153 -18
- package/operations/settings/index.d.ts +6 -3
- package/operations/settings/index.js +132 -16
- package/operations/system/index.d.ts +6 -3
- package/operations/system/index.js +94 -14
- package/package.json +11 -11
- package/types.d.ts +38 -8
- package/types.js +11 -1
- package/configurations.d.ts +0 -18
- package/configurations.js +0 -24
- package/configurations.js.map +0 -1
- package/definitions/entry.js.map +0 -1
- package/definitions/table.js.map +0 -1
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/path/ref.js.map +0 -1
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/index.js.map +0 -1
- package/operations/entry/CmsContentEntryDynamo.d.ts +0 -86
- package/operations/entry/CmsContentEntryDynamo.js +0 -972
- package/operations/entry/CmsContentEntryDynamo.js.map +0 -1
- package/operations/entry/dataLoaders.js.map +0 -1
- package/operations/entry/index.js.map +0 -1
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/entry/utils.js.map +0 -1
- package/operations/helpers.d.ts +0 -5
- package/operations/helpers.js +0 -96
- package/operations/helpers.js.map +0 -1
- package/operations/model/CmsContentModelDynamo.d.ts +0 -18
- package/operations/model/CmsContentModelDynamo.js +0 -234
- package/operations/model/CmsContentModelDynamo.js.map +0 -1
- package/operations/model/index.js.map +0 -1
- package/operations/modelGroup/CmsContentModelGroupDynamo.d.ts +0 -42
- package/operations/modelGroup/CmsContentModelGroupDynamo.js +0 -230
- package/operations/modelGroup/CmsContentModelGroupDynamo.js.map +0 -1
- package/operations/modelGroup/index.d.ts +0 -3
- package/operations/modelGroup/index.js +0 -26
- package/operations/modelGroup/index.js.map +0 -1
- package/operations/settings/CmsSettingsDynamo.d.ts +0 -16
- package/operations/settings/CmsSettingsDynamo.js +0 -145
- package/operations/settings/CmsSettingsDynamo.js.map +0 -1
- package/operations/settings/index.js.map +0 -1
- package/operations/system/CmsSystemDynamo.d.ts +0 -16
- package/operations/system/CmsSystemDynamo.js +0 -126
- package/operations/system/CmsSystemDynamo.js.map +0 -1
- package/operations/system/index.js.map +0 -1
- package/types.js.map +0 -1
- package/utils.d.ts +0 -5
- package/utils.js +0 -62
- package/utils.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageTransformPlugin } from "@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin";
|
|
2
2
|
export declare type OriginalValue = Record<string, any> | any[];
|
|
3
3
|
export interface StorageValue {
|
|
4
4
|
compression: string;
|
|
5
5
|
value: any;
|
|
6
6
|
}
|
|
7
|
-
declare const _default: () =>
|
|
7
|
+
declare const _default: () => StorageTransformPlugin<any, any>;
|
|
8
8
|
export default _default;
|
|
@@ -11,12 +11,18 @@ var _jsonpack = _interopRequireDefault(require("jsonpack"));
|
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
14
|
+
var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* Remove when jsonpack gets PR with a fix merged
|
|
16
18
|
* https://github.com/rgcl/jsonpack/pull/25/files
|
|
17
19
|
* NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
|
|
18
20
|
*/
|
|
19
21
|
const transformArray = value => {
|
|
22
|
+
if (!value) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
let isArray = Array.isArray(value);
|
|
21
27
|
const shouldBeArray = value instanceof Array === false && isArray;
|
|
22
28
|
|
|
@@ -34,75 +40,71 @@ const transformArray = value => {
|
|
|
34
40
|
return value;
|
|
35
41
|
};
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const {
|
|
63
|
-
compression,
|
|
64
|
-
value
|
|
65
|
-
} = storageValue;
|
|
66
|
-
|
|
67
|
-
if (!compression) {
|
|
68
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
69
|
-
value: storageValue
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (compression !== "jsonpack") {
|
|
74
|
-
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
75
|
-
compression
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
return _jsonpack.default.unpack(value);
|
|
81
|
-
} catch {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
async toStorage({
|
|
43
|
+
const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
|
|
44
|
+
fieldType: "rich-text",
|
|
45
|
+
fromStorage: async ({
|
|
46
|
+
field,
|
|
47
|
+
value: storageValue
|
|
48
|
+
}) => {
|
|
49
|
+
if (!storageValue) {
|
|
50
|
+
return storageValue;
|
|
51
|
+
} else if (typeof storageValue !== "object") {
|
|
52
|
+
throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.fieldId}".`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This is to circumvent a bug introduced with 5.8.0 storage operations.
|
|
56
|
+
* Do not remove.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if (storageValue.hasOwnProperty("compression") === false) {
|
|
61
|
+
return storageValue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
compression,
|
|
87
66
|
value
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return value;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
value = transformArray(value);
|
|
98
|
-
return {
|
|
99
|
-
compression: "jsonpack",
|
|
100
|
-
value: value ? _jsonpack.default.pack(value) : value
|
|
101
|
-
};
|
|
67
|
+
} = storageValue;
|
|
68
|
+
|
|
69
|
+
if (!compression) {
|
|
70
|
+
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
71
|
+
value: storageValue
|
|
72
|
+
});
|
|
102
73
|
}
|
|
103
74
|
|
|
104
|
-
|
|
75
|
+
if (compression !== "jsonpack") {
|
|
76
|
+
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
77
|
+
compression
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
return _jsonpack.default.unpack(value);
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
toStorage: async ({
|
|
88
|
+
value
|
|
89
|
+
}) => {
|
|
90
|
+
/**
|
|
91
|
+
* There is a possibility that we are trying to compress already compressed value.
|
|
92
|
+
* Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
|
|
93
|
+
*/
|
|
94
|
+
if (value && value.hasOwnProperty("compression") === true) {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
value = transformArray(value);
|
|
99
|
+
return {
|
|
100
|
+
compression: "jsonpack",
|
|
101
|
+
value: value ? _jsonpack.default.pack(value) : value
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
var _default = () => {
|
|
107
|
+
return plugin;
|
|
105
108
|
};
|
|
106
109
|
|
|
107
|
-
exports.default = _default;
|
|
108
|
-
//# sourceMappingURL=richText.js.map
|
|
110
|
+
exports.default = _default;
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
entry?: CmsContentEntryConfiguration;
|
|
4
|
-
}
|
|
5
|
-
declare const _default: (configuration?: Configuration) => (import("@webiny/api-headless-cms/types").CmsContentModelGroupStorageOperationsProvider | import("@webiny/api-headless-cms/types").CmsContentModelStorageOperationsProvider | import("@webiny/api-headless-cms/types").CmsContentEntryStorageOperationsProvider | import("@webiny/api-headless-cms/types").CmsSettingsStorageOperationsProviderPlugin | import("@webiny/api-headless-cms/types").CmsSystemStorageOperationsProviderPlugin | (import("./types").CmsFieldFilterPathPlugin | import("@webiny/api-headless-cms/types").CmsModelFieldToStoragePlugin<import("./dynamoDb/storage/richText").OriginalValue, import("./dynamoDb/storage/richText").StorageValue> | import("@webiny/api-headless-cms/types").CmsModelFieldToStoragePlugin<string | Date, string> | import("./types").CmsFieldFilterValueTransformPlugin<string | number | Date, number>)[])[];
|
|
6
|
-
export default _default;
|
|
1
|
+
import { StorageOperationsFactory } from "./types";
|
|
2
|
+
export declare const createStorageOperations: StorageOperationsFactory;
|
package/index.js
CHANGED
|
@@ -5,26 +5,121 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.createStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _types = require("./types");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _table = require("./definitions/table");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _settings = require("./definitions/settings");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _system = require("./definitions/system");
|
|
21
|
+
|
|
22
|
+
var _group = require("./definitions/group");
|
|
23
|
+
|
|
24
|
+
var _model = require("./definitions/model");
|
|
25
|
+
|
|
26
|
+
var _entry = require("./definitions/entry");
|
|
27
|
+
|
|
28
|
+
var _plugins = require("@webiny/plugins");
|
|
29
|
+
|
|
30
|
+
var _system2 = require("./operations/system");
|
|
31
|
+
|
|
32
|
+
var _settings2 = require("./operations/settings");
|
|
33
|
+
|
|
34
|
+
var _group2 = require("./operations/group");
|
|
35
|
+
|
|
36
|
+
var _model2 = require("./operations/model");
|
|
37
|
+
|
|
38
|
+
var _entry2 = require("./operations/entry");
|
|
21
39
|
|
|
22
|
-
|
|
40
|
+
const createStorageOperations = params => {
|
|
23
41
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
42
|
+
attributes = {},
|
|
43
|
+
table,
|
|
44
|
+
documentClient,
|
|
45
|
+
plugins: customPlugins,
|
|
46
|
+
modelFieldToGraphQLPlugins
|
|
47
|
+
} = params;
|
|
48
|
+
const tableInstance = (0, _table.createTable)({
|
|
49
|
+
table,
|
|
50
|
+
documentClient
|
|
51
|
+
});
|
|
52
|
+
const entities = {
|
|
53
|
+
settings: (0, _settings.createSettingsEntity)({
|
|
54
|
+
entityName: _types.ENTITIES.SETTINGS,
|
|
55
|
+
table: tableInstance,
|
|
56
|
+
attributes: attributes[_types.ENTITIES.SETTINGS]
|
|
57
|
+
}),
|
|
58
|
+
system: (0, _system.createSystemEntity)({
|
|
59
|
+
entityName: _types.ENTITIES.SYSTEM,
|
|
60
|
+
table: tableInstance,
|
|
61
|
+
attributes: attributes[_types.ENTITIES.SYSTEM]
|
|
62
|
+
}),
|
|
63
|
+
groups: (0, _group.createGroupEntity)({
|
|
64
|
+
entityName: _types.ENTITIES.GROUPS,
|
|
65
|
+
table: tableInstance,
|
|
66
|
+
attributes: attributes[_types.ENTITIES.GROUPS]
|
|
67
|
+
}),
|
|
68
|
+
models: (0, _model.createModelEntity)({
|
|
69
|
+
entityName: _types.ENTITIES.MODELS,
|
|
70
|
+
table: tableInstance,
|
|
71
|
+
attributes: attributes[_types.ENTITIES.MODELS]
|
|
72
|
+
}),
|
|
73
|
+
entries: (0, _entry.createEntryEntity)({
|
|
74
|
+
entityName: _types.ENTITIES.ENTRIES,
|
|
75
|
+
table: tableInstance,
|
|
76
|
+
attributes: attributes[_types.ENTITIES.ENTRIES]
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
const plugins = new _plugins.PluginsContainer([
|
|
80
|
+
/**
|
|
81
|
+
* User defined custom plugins.
|
|
82
|
+
*/
|
|
83
|
+
...(customPlugins || []),
|
|
84
|
+
/**
|
|
85
|
+
* Plugins of type CmsModelFieldToGraphQLPlugin.
|
|
86
|
+
*/
|
|
87
|
+
modelFieldToGraphQLPlugins,
|
|
88
|
+
/**
|
|
89
|
+
* DynamoDB filter plugins for the where conditions.
|
|
90
|
+
*/
|
|
91
|
+
(0, _filters.default)(),
|
|
92
|
+
/**
|
|
93
|
+
* Field plugins for DynamoDB.
|
|
94
|
+
*/
|
|
95
|
+
(0, _dynamoDb.default)()]);
|
|
96
|
+
return {
|
|
97
|
+
plugins: [
|
|
98
|
+
/**
|
|
99
|
+
* Field plugins for DynamoDB.
|
|
100
|
+
* We must pass them to the base application.
|
|
101
|
+
*/
|
|
102
|
+
(0, _dynamoDb.default)()],
|
|
103
|
+
getEntities: () => entities,
|
|
104
|
+
getTable: () => tableInstance,
|
|
105
|
+
system: (0, _system2.createSystemStorageOperations)({
|
|
106
|
+
entity: entities.system
|
|
107
|
+
}),
|
|
108
|
+
settings: (0, _settings2.createSettingsStorageOperations)({
|
|
109
|
+
entity: entities.settings
|
|
110
|
+
}),
|
|
111
|
+
groups: (0, _group2.createGroupsStorageOperations)({
|
|
112
|
+
entity: entities.groups,
|
|
113
|
+
plugins
|
|
114
|
+
}),
|
|
115
|
+
models: (0, _model2.createModelsStorageOperations)({
|
|
116
|
+
entity: entities.models
|
|
117
|
+
}),
|
|
118
|
+
entries: (0, _entry2.createEntriesStorageOperations)({
|
|
119
|
+
entity: entities.entries,
|
|
120
|
+
plugins
|
|
121
|
+
})
|
|
122
|
+
};
|
|
27
123
|
};
|
|
28
124
|
|
|
29
|
-
exports.
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
125
|
+
exports.createStorageOperations = createStorageOperations;
|
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Entity } from "dynamodb-toolbox";
|
|
3
|
+
export interface GetAllEntryRevisionsParams {
|
|
4
|
+
ids: readonly string[];
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
}
|
|
7
|
+
export interface GetRevisionByIdParams {
|
|
8
|
+
ids: readonly string[];
|
|
9
|
+
model: CmsModel;
|
|
10
|
+
}
|
|
11
|
+
export interface GetPublishedRevisionByEntryIdParams {
|
|
12
|
+
ids: readonly string[];
|
|
13
|
+
model: CmsModel;
|
|
14
|
+
}
|
|
15
|
+
export interface GetLatestRevisionByEntryIdParams {
|
|
16
|
+
ids: readonly string[];
|
|
17
|
+
model: CmsModel;
|
|
18
|
+
}
|
|
19
|
+
interface ClearLoaderParams {
|
|
20
|
+
model: CmsModel;
|
|
21
|
+
entry?: CmsEntry;
|
|
22
|
+
}
|
|
23
|
+
export interface Params {
|
|
24
|
+
entity: Entity<any>;
|
|
25
|
+
}
|
|
3
26
|
export declare class DataLoadersHandler {
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
clearRevisionById(model: CmsContentModel, entry?: CmsContentEntry): void;
|
|
12
|
-
getPublishedRevisionByEntryId(model: CmsContentModel, ids: readonly string[]): Promise<CmsContentEntry[]>;
|
|
13
|
-
clearPublishedRevisionByEntryId(model: CmsContentModel, entry?: CmsContentEntry): void;
|
|
14
|
-
getLatestRevisionByEntryId(model: CmsContentModel, ids: readonly string[]): Promise<CmsContentEntry[]>;
|
|
15
|
-
clearLatestRevisionByEntryId(model: CmsContentModel, entry?: CmsContentEntry): void;
|
|
27
|
+
private readonly loaders;
|
|
28
|
+
private readonly entity;
|
|
29
|
+
constructor(params: any);
|
|
30
|
+
getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]>;
|
|
31
|
+
getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]>;
|
|
32
|
+
getPublishedRevisionByEntryId(params: GetPublishedRevisionByEntryIdParams): Promise<CmsEntry[]>;
|
|
33
|
+
getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsEntry[]>;
|
|
16
34
|
private getLoader;
|
|
17
35
|
private loadMany;
|
|
18
|
-
|
|
19
|
-
* Helper to clear the cache for certain data loader.
|
|
20
|
-
* If entry is passed then clear target key only.
|
|
21
|
-
*/
|
|
22
|
-
private clear;
|
|
36
|
+
clearAll(params: Omit<ClearLoaderParams, "entry">): void;
|
|
23
37
|
}
|
|
38
|
+
export {};
|