@webiny/api-headless-cms-ddb 0.0.0-unstable.aa00eecd97 → 0.0.0-unstable.ac6ebf63c6
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 +7 -88
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +7 -59
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +7 -103
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +8 -26
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +7 -12
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +34 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +7 -14
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/longText.js +13 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +28 -71
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +7 -12
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +40 -82
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
- package/operations/entry/dataLoader/DataLoaderCache.js +8 -17
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +3 -8
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +13 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +24 -35
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +24 -35
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +26 -37
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +5 -5
- package/operations/entry/dataLoader/index.js +12 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +2 -4
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +11 -12
- package/operations/entry/dataLoaders.js +25 -34
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +5 -5
- package/operations/entry/filtering/createExpressions.js +29 -30
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +6 -4
- package/operations/entry/filtering/createFields.js +87 -86
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.d.ts +6 -6
- package/operations/entry/filtering/extractSort.js +40 -23
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +6 -6
- package/operations/entry/filtering/filter.js +36 -29
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
- package/operations/entry/filtering/fullTextSearch.js +8 -14
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +6 -10
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.d.ts +2 -2
- package/operations/entry/filtering/index.js +3 -18
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.d.ts +2 -2
- package/operations/entry/filtering/mapPlugins.js +5 -11
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +10 -14
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/filtering/plugins/index.js +8 -12
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +17 -19
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +22 -19
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +6 -6
- package/operations/entry/filtering/sort.js +18 -20
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.d.ts +2 -4
- package/operations/entry/filtering/systemFields.js +88 -42
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.d.ts +1 -1
- package/operations/entry/filtering/transform.js +3 -8
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +3 -3
- package/operations/entry/filtering/types.js +2 -4
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/filtering/values.d.ts +1 -1
- package/operations/entry/filtering/values.js +6 -12
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +6 -10
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +3 -4
- package/operations/entry/index.js +635 -339
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +40 -2
- package/operations/entry/keys.js +55 -30
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -4
- package/operations/group/index.js +44 -61
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +37 -46
- package/operations/model/index.js.map +1 -1
- package/package.json +21 -28
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +4 -3
- package/plugins/CmsEntryFieldFilterPathPlugin.js +15 -16
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
- package/plugins/CmsEntryFieldFilterPlugin.js +11 -14
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldSortingPlugin.js +6 -15
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +2 -2
- package/plugins/CmsFieldFilterValueTransformPlugin.js +5 -13
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +4 -4
- package/plugins/index.js +5 -48
- package/plugins/index.js.map +1 -1
- package/types.d.ts +18 -22
- package/types.js +5 -12
- 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/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.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
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.systemFields = void 0;
|
|
7
|
-
const createSystemField = field => {
|
|
8
|
-
return field;
|
|
9
|
-
};
|
|
10
|
-
const systemFields = {
|
|
11
|
-
id: createSystemField({
|
|
12
|
-
id: "id",
|
|
13
|
-
type: "text",
|
|
14
|
-
storageId: "id",
|
|
15
|
-
fieldId: "id"
|
|
16
|
-
}),
|
|
17
|
-
entryId: createSystemField({
|
|
18
|
-
id: "entryId",
|
|
19
|
-
type: "text",
|
|
20
|
-
storageId: "entryId",
|
|
21
|
-
fieldId: "entryId"
|
|
22
|
-
}),
|
|
23
|
-
createdOn: createSystemField({
|
|
24
|
-
id: "createdOn",
|
|
25
|
-
type: "datetime",
|
|
26
|
-
storageId: "createdOn",
|
|
27
|
-
fieldId: "createdOn"
|
|
28
|
-
}),
|
|
29
|
-
savedOn: createSystemField({
|
|
30
|
-
id: "savedOn",
|
|
31
|
-
type: "datetime",
|
|
32
|
-
storageId: "savedOn",
|
|
33
|
-
fieldId: "savedOn"
|
|
34
|
-
}),
|
|
35
|
-
createdBy: createSystemField({
|
|
36
|
-
id: "createdBy",
|
|
37
|
-
type: "plainObject",
|
|
38
|
-
storageId: "createdBy",
|
|
39
|
-
fieldId: "createdBy",
|
|
40
|
-
settings: {
|
|
41
|
-
path: "createdBy.id"
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
meta: createSystemField({
|
|
45
|
-
id: "meta",
|
|
46
|
-
type: "plainObject",
|
|
47
|
-
storageId: "meta",
|
|
48
|
-
fieldId: "meta"
|
|
49
|
-
}),
|
|
50
|
-
ownedBy: createSystemField({
|
|
51
|
-
id: "ownedBy",
|
|
52
|
-
type: "plainObject",
|
|
53
|
-
storageId: "ownedBy",
|
|
54
|
-
fieldId: "ownedBy",
|
|
55
|
-
settings: {
|
|
56
|
-
path: "ownedBy.id"
|
|
57
|
-
}
|
|
58
|
-
}),
|
|
59
|
-
version: createSystemField({
|
|
60
|
-
id: "version",
|
|
61
|
-
type: "number",
|
|
62
|
-
storageId: "version",
|
|
63
|
-
fieldId: "version"
|
|
64
|
-
}),
|
|
65
|
-
status: createSystemField({
|
|
66
|
-
id: "status",
|
|
67
|
-
type: "string",
|
|
68
|
-
storageId: "status",
|
|
69
|
-
fieldId: "status"
|
|
70
|
-
})
|
|
71
|
-
};
|
|
72
|
-
exports.systemFields = systemFields;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemField","field","systemFields","id","type","storageId","fieldId","entryId","createdOn","savedOn","createdBy","settings","path","meta","ownedBy","version","status"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype CmsModelFieldInput = Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">;\nconst createSystemField = (field: CmsModelFieldInput): CmsModelField => {\n return field as CmsModelField;\n};\n\nexport const systemFields: Record<string, CmsModelField> = {\n id: createSystemField({\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\"\n }),\n entryId: createSystemField({\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\"\n }),\n createdOn: createSystemField({\n id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\"\n }),\n savedOn: createSystemField({\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\"\n }),\n createdBy: createSystemField({\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n settings: {\n path: \"createdBy.id\"\n }\n }),\n meta: createSystemField({\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\"\n }),\n ownedBy: createSystemField({\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n settings: {\n path: \"ownedBy.id\"\n }\n }),\n version: createSystemField({\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\"\n }),\n status: createSystemField({\n id: \"status\",\n type: \"string\",\n storageId: \"status\",\n fieldId: \"status\"\n })\n};\n"],"mappings":";;;;;;AAIA,MAAMA,iBAAiB,GAAIC,KAAyB,IAAoB;EACpE,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,YAA2C,GAAG;EACvDC,EAAE,EAAEH,iBAAiB,CAAC;IAClBG,EAAE,EAAE,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE;EACb,CAAC,CAAC;EACFC,OAAO,EAAEP,iBAAiB,CAAC;IACvBG,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE;EACb,CAAC,CAAC;EACFE,SAAS,EAAER,iBAAiB,CAAC;IACzBG,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE;EACb,CAAC,CAAC;EACFG,OAAO,EAAET,iBAAiB,CAAC;IACvBG,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE;EACb,CAAC,CAAC;EACFI,SAAS,EAAEV,iBAAiB,CAAC;IACzBG,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBK,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,CAAC;EACFC,IAAI,EAAEb,iBAAiB,CAAC;IACpBG,EAAE,EAAE,MAAM;IACVC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE;EACb,CAAC,CAAC;EACFQ,OAAO,EAAEd,iBAAiB,CAAC;IACvBG,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBK,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,CAAC;EACFG,OAAO,EAAEf,iBAAiB,CAAC;IACvBG,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE;EACb,CAAC,CAAC;EACFU,MAAM,EAAEhB,iBAAiB,CAAC;IACtBG,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE;EACb,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
interface CreateSettingsStorageOperationsParams {
|
|
4
|
-
entity: Entity<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
|
|
7
|
-
export {};
|
|
@@ -1,111 +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.createSettingsStorageOperations = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
12
|
-
const convertToDbData = settings => {
|
|
13
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
14
|
-
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
const convertFromDbData = settings => {
|
|
18
|
-
if (!settings) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
let contentModelLastChange;
|
|
22
|
-
try {
|
|
23
|
-
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
24
|
-
} catch {
|
|
25
|
-
contentModelLastChange = new Date();
|
|
26
|
-
}
|
|
27
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
28
|
-
contentModelLastChange
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const createPartitionKey = ({
|
|
32
|
-
tenant,
|
|
33
|
-
locale
|
|
34
|
-
}) => {
|
|
35
|
-
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
36
|
-
};
|
|
37
|
-
const createSortKey = () => {
|
|
38
|
-
return "settings";
|
|
39
|
-
};
|
|
40
|
-
const createKeys = params => {
|
|
41
|
-
return {
|
|
42
|
-
PK: createPartitionKey(params),
|
|
43
|
-
SK: createSortKey()
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const createSettingsStorageOperations = params => {
|
|
47
|
-
const {
|
|
48
|
-
entity
|
|
49
|
-
} = params;
|
|
50
|
-
const create = async params => {
|
|
51
|
-
const {
|
|
52
|
-
settings
|
|
53
|
-
} = params;
|
|
54
|
-
const keys = createKeys(settings);
|
|
55
|
-
const dbSettings = convertToDbData(settings);
|
|
56
|
-
try {
|
|
57
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
58
|
-
return settings;
|
|
59
|
-
} catch (ex) {
|
|
60
|
-
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
61
|
-
error: ex,
|
|
62
|
-
settings,
|
|
63
|
-
dbSettings,
|
|
64
|
-
keys
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const update = async params => {
|
|
69
|
-
const {
|
|
70
|
-
settings
|
|
71
|
-
} = params;
|
|
72
|
-
const keys = createKeys(settings);
|
|
73
|
-
const dbSettings = convertToDbData(settings);
|
|
74
|
-
try {
|
|
75
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
76
|
-
return settings;
|
|
77
|
-
} catch (ex) {
|
|
78
|
-
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
79
|
-
error: ex,
|
|
80
|
-
settings,
|
|
81
|
-
dbSettings,
|
|
82
|
-
keys
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const get = async params => {
|
|
87
|
-
const keys = createKeys(params);
|
|
88
|
-
try {
|
|
89
|
-
const record = await (0, _get.get)({
|
|
90
|
-
entity,
|
|
91
|
-
keys
|
|
92
|
-
});
|
|
93
|
-
if (!record) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
97
|
-
return convertFromDbData(settings);
|
|
98
|
-
} catch (ex) {
|
|
99
|
-
throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
|
|
100
|
-
error: ex,
|
|
101
|
-
keys
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
create,
|
|
107
|
-
get,
|
|
108
|
-
update
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,mEACOA,QAAQ;IACXC,sBAAsB,EAAED,QAAQ,CAACC,sBAAsB,CAACC,WAAW;EAAE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,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
interface CreateSystemStorageOperationsParams {
|
|
4
|
-
entity: Entity<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
|
|
7
|
-
export {};
|
|
@@ -1,82 +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.createSystemStorageOperations = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
11
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
12
|
-
const createPartitionKey = ({
|
|
13
|
-
tenant
|
|
14
|
-
}) => {
|
|
15
|
-
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
16
|
-
};
|
|
17
|
-
const createSortKey = () => {
|
|
18
|
-
return "CMS";
|
|
19
|
-
};
|
|
20
|
-
const createKeys = params => {
|
|
21
|
-
return {
|
|
22
|
-
PK: createPartitionKey(params),
|
|
23
|
-
SK: createSortKey()
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const createSystemStorageOperations = params => {
|
|
27
|
-
const {
|
|
28
|
-
entity
|
|
29
|
-
} = params;
|
|
30
|
-
const create = async ({
|
|
31
|
-
system
|
|
32
|
-
}) => {
|
|
33
|
-
const keys = createKeys(system);
|
|
34
|
-
try {
|
|
35
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
36
|
-
return system;
|
|
37
|
-
} catch (ex) {
|
|
38
|
-
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
39
|
-
error: ex,
|
|
40
|
-
system,
|
|
41
|
-
keys
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const update = async params => {
|
|
46
|
-
const {
|
|
47
|
-
system
|
|
48
|
-
} = params;
|
|
49
|
-
const keys = createKeys(system);
|
|
50
|
-
try {
|
|
51
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
52
|
-
return system;
|
|
53
|
-
} catch (ex) {
|
|
54
|
-
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
55
|
-
error: ex,
|
|
56
|
-
system,
|
|
57
|
-
keys
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const get = async params => {
|
|
62
|
-
const keys = createKeys(params);
|
|
63
|
-
try {
|
|
64
|
-
const system = await (0, _get.get)({
|
|
65
|
-
entity,
|
|
66
|
-
keys
|
|
67
|
-
});
|
|
68
|
-
return (0, _cleanup.cleanupItem)(entity, system);
|
|
69
|
-
} catch (ex) {
|
|
70
|
-
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
71
|
-
error: ex,
|
|
72
|
-
keys
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
create,
|
|
78
|
-
update,
|
|
79
|
-
get
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAW,EAAG,SAAQ;AAC7C,CAAC;AACD,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAK;AAChB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa;EACrB,CAAC;AACL,CAAC;AAEM,MAAMK,6BAA6B,GACtCH,MAA2C,IACd;EAC7B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAA+C,CAAC,KAAK;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAC/B,IAAI;MACA,MAAMF,MAAM,CAACI,GAAG,6DACTF,MAAM,GACNC,IAAI,EACT;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTH,MAAM;QACNC;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMO,MAAM,GAAG,MAAOd,MAA8C,IAAK;IACrE,MAAM;MAAEM;IAAO,CAAC,GAAGN,MAAM;IAEzB,MAAMO,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAE/B,IAAI;MACA,MAAMF,MAAM,CAACI,GAAG,6DACTF,MAAM,GACNC,IAAI,EACT;M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