@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.0156a4c312
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/abstractions/CmsDdbDataLoaders.d.ts +5 -0
- package/abstractions/CmsDdbDataLoaders.js +5 -0
- package/abstractions/CmsDdbDataLoaders.js.map +1 -0
- package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
- package/abstractions/CmsDdbEntryEntity.js +5 -0
- package/abstractions/CmsDdbEntryEntity.js.map +1 -0
- package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
- package/abstractions/CmsDdbGroupEntity.js +5 -0
- package/abstractions/CmsDdbGroupEntity.js.map +1 -0
- package/abstractions/CmsDdbModelEntity.d.ts +5 -0
- package/abstractions/CmsDdbModelEntity.js +5 -0
- package/abstractions/CmsDdbModelEntity.js.map +1 -0
- package/abstractions/CmsDdbTable.d.ts +5 -0
- package/abstractions/CmsDdbTable.js +5 -0
- package/abstractions/CmsDdbTable.js.map +1 -0
- package/definitions/entry.d.ts +6 -6
- package/definitions/entry.js +9 -95
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +9 -72
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +9 -94
- package/definitions/model.js.map +1 -0
- package/definitions/table.d.ts +6 -7
- package/definitions/table.js +8 -30
- package/definitions/table.js.map +1 -0
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/index.d.ts +10 -2
- package/index.js +45 -123
- package/index.js.map +1 -0
- package/operations/entry/DdbCreateEntry.d.ts +16 -0
- package/operations/entry/DdbCreateEntry.js +77 -0
- package/operations/entry/DdbCreateEntry.js.map +1 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/DdbDeleteEntry.d.ts +16 -0
- package/operations/entry/DdbDeleteEntry.js +65 -0
- package/operations/entry/DdbDeleteEntry.js.map +1 -0
- package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
- package/operations/entry/DdbDeleteEntryRevision.js +91 -0
- package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
- package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
- package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
- package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetEntriesByIds.js +31 -0
- package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetEntry.d.ts +14 -0
- package/operations/entry/DdbGetEntry.js +27 -0
- package/operations/entry/DdbGetEntry.js.map +1 -0
- package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
- package/operations/entry/DdbGetPreviousRevision.js +53 -0
- package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetRevisionById.d.ts +14 -0
- package/operations/entry/DdbGetRevisionById.js +34 -0
- package/operations/entry/DdbGetRevisionById.js.map +1 -0
- package/operations/entry/DdbGetRevisions.d.ts +14 -0
- package/operations/entry/DdbGetRevisions.js +33 -0
- package/operations/entry/DdbGetRevisions.js.map +1 -0
- package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
- package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
- package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/DdbListEntries.d.ts +30 -0
- package/operations/entry/DdbListEntries.js +133 -0
- package/operations/entry/DdbListEntries.js.map +1 -0
- package/operations/entry/DdbMoveEntry.d.ts +16 -0
- package/operations/entry/DdbMoveEntry.js +63 -0
- package/operations/entry/DdbMoveEntry.js.map +1 -0
- package/operations/entry/DdbMoveToBin.d.ts +16 -0
- package/operations/entry/DdbMoveToBin.js +77 -0
- package/operations/entry/DdbMoveToBin.js.map +1 -0
- package/operations/entry/DdbPublishEntry.d.ts +18 -0
- package/operations/entry/DdbPublishEntry.js +162 -0
- package/operations/entry/DdbPublishEntry.js.map +1 -0
- package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
- package/operations/entry/DdbRestoreFromBin.js +78 -0
- package/operations/entry/DdbRestoreFromBin.js.map +1 -0
- package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
- package/operations/entry/DdbUnpublishEntry.js +112 -0
- package/operations/entry/DdbUnpublishEntry.js.map +1 -0
- package/operations/entry/DdbUpdateEntry.d.ts +17 -0
- package/operations/entry/DdbUpdateEntry.js +105 -0
- package/operations/entry/DdbUpdateEntry.js.map +1 -0
- 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 +20 -31
- package/operations/entry/dataLoaders.js +91 -296
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +53 -55
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/storageEntryUtils.d.ts +8 -0
- package/operations/entry/storageEntryUtils.js +25 -0
- package/operations/entry/storageEntryUtils.js.map +1 -0
- package/operations/group/DdbCreateGroup.d.ts +12 -0
- package/operations/group/DdbCreateGroup.js +35 -0
- package/operations/group/DdbCreateGroup.js.map +1 -0
- package/operations/group/DdbDeleteGroup.d.ts +12 -0
- package/operations/group/DdbDeleteGroup.js +31 -0
- package/operations/group/DdbDeleteGroup.js.map +1 -0
- package/operations/group/DdbGetGroup.d.ts +12 -0
- package/operations/group/DdbGetGroup.js +31 -0
- package/operations/group/DdbGetGroup.js.map +1 -0
- package/operations/group/DdbListGroups.d.ts +14 -0
- package/operations/group/DdbListGroups.js +52 -0
- package/operations/group/DdbListGroups.js.map +1 -0
- package/operations/group/DdbUpdateGroup.d.ts +12 -0
- package/operations/group/DdbUpdateGroup.js +35 -0
- package/operations/group/DdbUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/keys.d.ts +15 -0
- package/operations/group/keys.js +17 -0
- package/operations/group/keys.js.map +1 -0
- package/operations/model/DdbCreateModel.d.ts +12 -0
- package/operations/model/DdbCreateModel.js +37 -0
- package/operations/model/DdbCreateModel.js.map +1 -0
- package/operations/model/DdbDeleteModel.d.ts +12 -0
- package/operations/model/DdbDeleteModel.js +31 -0
- package/operations/model/DdbDeleteModel.js.map +1 -0
- package/operations/model/DdbGetModel.d.ts +12 -0
- package/operations/model/DdbGetModel.js +30 -0
- package/operations/model/DdbGetModel.js.map +1 -0
- package/operations/model/DdbListModels.d.ts +12 -0
- package/operations/model/DdbListModels.js +36 -0
- package/operations/model/DdbListModels.js.map +1 -0
- package/operations/model/DdbUpdateModel.d.ts +12 -0
- package/operations/model/DdbUpdateModel.js +36 -0
- package/operations/model/DdbUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/keys.d.ts +15 -0
- package/operations/model/keys.js +16 -0
- package/operations/model/keys.js.map +1 -0
- package/package.json +30 -34
- package/types.d.ts +12 -76
- package/types.js +8 -15
- package/types.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -50
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -24
- package/dynamoDb/path/plainObject.d.ts +0 -3
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/dynamoDb/storage/longText.d.ts +0 -7
- package/dynamoDb/storage/longText.js +0 -83
- package/dynamoDb/storage/richText.d.ts +0 -8
- package/dynamoDb/storage/richText.js +0 -110
- package/dynamoDb/transformValue/datetime.d.ts +0 -3
- package/dynamoDb/transformValue/datetime.js +0 -47
- package/operations/entry/index.d.ts +0 -8
- package/operations/entry/index.js +0 -823
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -50
- package/operations/entry/utils.d.ts +0 -31
- package/operations/entry/utils.js +0 -406
- package/operations/group/index.d.ts +0 -8
- package/operations/group/index.js +0 -198
- package/operations/model/index.d.ts +0 -6
- package/operations/model/index.js +0 -161
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -105
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createModelsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
|
-
const createPartitionKey = params => {
|
|
25
|
-
const {
|
|
26
|
-
tenant,
|
|
27
|
-
locale
|
|
28
|
-
} = params;
|
|
29
|
-
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const createSortKey = params => {
|
|
33
|
-
return params.modelId;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const createKeys = params => {
|
|
37
|
-
return {
|
|
38
|
-
PK: createPartitionKey(params),
|
|
39
|
-
SK: createSortKey(params)
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const createType = () => {
|
|
44
|
-
return "cms.model";
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const createModelsStorageOperations = params => {
|
|
48
|
-
const {
|
|
49
|
-
entity
|
|
50
|
-
} = params;
|
|
51
|
-
|
|
52
|
-
const create = async params => {
|
|
53
|
-
const {
|
|
54
|
-
model
|
|
55
|
-
} = params;
|
|
56
|
-
const keys = createKeys(model);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
await entity.put(_objectSpread(_objectSpread(_objectSpread({}, model), keys), {}, {
|
|
60
|
-
TYPE: createType()
|
|
61
|
-
}));
|
|
62
|
-
return model;
|
|
63
|
-
} catch (ex) {
|
|
64
|
-
throw new _error.default(`Could not create CMS Content Model.`, "CREATE_MODEL_ERROR", {
|
|
65
|
-
error: ex,
|
|
66
|
-
model,
|
|
67
|
-
keys
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const update = async params => {
|
|
73
|
-
const {
|
|
74
|
-
original,
|
|
75
|
-
model
|
|
76
|
-
} = params;
|
|
77
|
-
const keys = createKeys(model);
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
await entity.put(_objectSpread(_objectSpread(_objectSpread({}, model), keys), {}, {
|
|
81
|
-
TYPE: createType()
|
|
82
|
-
}));
|
|
83
|
-
return model;
|
|
84
|
-
} catch (ex) {
|
|
85
|
-
throw new _error.default(ex.messatge || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
86
|
-
error: ex,
|
|
87
|
-
model,
|
|
88
|
-
original,
|
|
89
|
-
keys
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const deleteModel = async params => {
|
|
95
|
-
const {
|
|
96
|
-
model
|
|
97
|
-
} = params;
|
|
98
|
-
const keys = createKeys(model);
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
await entity.delete(keys);
|
|
102
|
-
return model;
|
|
103
|
-
} catch (ex) {
|
|
104
|
-
throw new _error.default(ex.messatge || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
105
|
-
error: ex,
|
|
106
|
-
model,
|
|
107
|
-
keys
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const get = async params => {
|
|
113
|
-
const keys = createKeys(params);
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const item = await (0, _get.get)({
|
|
117
|
-
entity,
|
|
118
|
-
keys
|
|
119
|
-
});
|
|
120
|
-
return (0, _cleanup.cleanupItem)(entity, item);
|
|
121
|
-
} catch (ex) {
|
|
122
|
-
throw new _error.default(ex.messatge || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
123
|
-
error: ex,
|
|
124
|
-
keys
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const list = async params => {
|
|
130
|
-
const {
|
|
131
|
-
where
|
|
132
|
-
} = params;
|
|
133
|
-
const queryAllParams = {
|
|
134
|
-
entity,
|
|
135
|
-
partitionKey: createPartitionKey(where),
|
|
136
|
-
options: {
|
|
137
|
-
gte: " "
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
143
|
-
return (0, _cleanup.cleanupItems)(entity, items);
|
|
144
|
-
} catch (ex) {
|
|
145
|
-
throw new _error.default(ex.messatge || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
146
|
-
error: ex,
|
|
147
|
-
partitionKey: queryAllParams.partitionKey
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
create,
|
|
154
|
-
update,
|
|
155
|
-
delete: deleteModel,
|
|
156
|
-
get,
|
|
157
|
-
list
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
export interface Params {
|
|
4
|
-
entity: Entity<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const createSettingsStorageOperations: (params: Params) => CmsSettingsStorageOperations;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createSettingsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
const convertToDbData = settings => {
|
|
23
|
-
return _objectSpread(_objectSpread({}, settings), {}, {
|
|
24
|
-
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const convertFromDbData = settings => {
|
|
29
|
-
if (!settings) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let contentModelLastChange;
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
37
|
-
} catch {
|
|
38
|
-
contentModelLastChange = new Date();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return _objectSpread(_objectSpread({}, settings), {}, {
|
|
42
|
-
contentModelLastChange
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const createPartitionKey = ({
|
|
47
|
-
tenant,
|
|
48
|
-
locale
|
|
49
|
-
}) => {
|
|
50
|
-
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const createSortKey = () => {
|
|
54
|
-
return "settings";
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const createKeys = params => {
|
|
58
|
-
return {
|
|
59
|
-
PK: createPartitionKey(params),
|
|
60
|
-
SK: createSortKey()
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const createSettingsStorageOperations = params => {
|
|
65
|
-
const {
|
|
66
|
-
entity
|
|
67
|
-
} = params;
|
|
68
|
-
|
|
69
|
-
const create = async params => {
|
|
70
|
-
const {
|
|
71
|
-
settings
|
|
72
|
-
} = params;
|
|
73
|
-
const keys = createKeys(settings);
|
|
74
|
-
const dbSettings = convertToDbData(settings);
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
await entity.put(_objectSpread(_objectSpread({}, dbSettings), keys));
|
|
78
|
-
return settings;
|
|
79
|
-
} catch (ex) {
|
|
80
|
-
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
81
|
-
error: ex,
|
|
82
|
-
settings,
|
|
83
|
-
dbSettings,
|
|
84
|
-
keys
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const update = async params => {
|
|
90
|
-
const {
|
|
91
|
-
settings,
|
|
92
|
-
original
|
|
93
|
-
} = params;
|
|
94
|
-
const keys = createKeys(settings);
|
|
95
|
-
const dbSettings = convertToDbData(settings);
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
await entity.put(_objectSpread(_objectSpread({}, dbSettings), keys));
|
|
99
|
-
return settings;
|
|
100
|
-
} catch (ex) {
|
|
101
|
-
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
102
|
-
error: ex,
|
|
103
|
-
settings,
|
|
104
|
-
dbSettings,
|
|
105
|
-
original,
|
|
106
|
-
keys
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const get = async params => {
|
|
112
|
-
const keys = createKeys(params);
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
const record = await (0, _get.get)({
|
|
116
|
-
entity,
|
|
117
|
-
keys
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
if (!record) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
125
|
-
return convertFromDbData(settings);
|
|
126
|
-
} catch (ex) {
|
|
127
|
-
throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
|
|
128
|
-
error: ex,
|
|
129
|
-
keys
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
create,
|
|
136
|
-
get,
|
|
137
|
-
update
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
export interface Params {
|
|
4
|
-
entity: Entity<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const createSystemStorageOperations: (params: Params) => CmsSystemStorageOperations;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createSystemStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
const createPartitionKey = ({
|
|
23
|
-
tenant
|
|
24
|
-
}) => {
|
|
25
|
-
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const createSortKey = () => {
|
|
29
|
-
return "CMS";
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const createKeys = params => {
|
|
33
|
-
return {
|
|
34
|
-
PK: createPartitionKey(params),
|
|
35
|
-
SK: createSortKey()
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const createSystemStorageOperations = params => {
|
|
40
|
-
const {
|
|
41
|
-
entity
|
|
42
|
-
} = params;
|
|
43
|
-
|
|
44
|
-
const create = async ({
|
|
45
|
-
system
|
|
46
|
-
}) => {
|
|
47
|
-
const keys = createKeys(system);
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
await entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
51
|
-
return system;
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
54
|
-
error: ex,
|
|
55
|
-
system,
|
|
56
|
-
keys
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const update = async params => {
|
|
62
|
-
const {
|
|
63
|
-
system,
|
|
64
|
-
original
|
|
65
|
-
} = params;
|
|
66
|
-
const keys = createKeys(system);
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
await entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
70
|
-
return system;
|
|
71
|
-
} catch (ex) {
|
|
72
|
-
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
|
-
error: ex,
|
|
74
|
-
system,
|
|
75
|
-
original,
|
|
76
|
-
keys
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const get = async params => {
|
|
82
|
-
const keys = createKeys(params);
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
const system = await (0, _get.get)({
|
|
86
|
-
entity,
|
|
87
|
-
keys
|
|
88
|
-
});
|
|
89
|
-
return (0, _cleanup.cleanupItem)(entity, system);
|
|
90
|
-
} catch (ex) {
|
|
91
|
-
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
92
|
-
error: ex,
|
|
93
|
-
keys
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
create,
|
|
100
|
-
update,
|
|
101
|
-
get
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
exports.createSystemStorageOperations = createSystemStorageOperations;
|