@webiny/api-headless-cms-ddb-es 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +35 -0
- package/configurations.d.ts +12 -0
- package/configurations.js +43 -0
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +8 -0
- package/definitions/entry.js +90 -0
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +8 -0
- package/definitions/entryElasticsearch.js +42 -0
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +8 -0
- package/definitions/group.js +70 -0
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +8 -0
- package/definitions/model.js +97 -0
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +8 -0
- package/definitions/settings.js +58 -0
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +8 -0
- package/definitions/system.js +46 -0
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +8 -0
- package/definitions/table.js +24 -0
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +8 -0
- package/definitions/tableElasticsearch.js +24 -0
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -0
- package/dynamoDb/index.js +16 -0
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +3 -0
- package/dynamoDb/storage/date.js +99 -0
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +10 -0
- package/dynamoDb/storage/longText.js +108 -0
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +7 -0
- package/dynamoDb/storage/richText.js +128 -0
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +43 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +2 -0
- package/elasticsearch/index.js +16 -0
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +103 -0
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.d.ts +2 -0
- package/elasticsearch/indexing/index.js +24 -0
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +7 -0
- package/elasticsearch/indexing/longTextIndexing.js +52 -0
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
- package/elasticsearch/indexing/numberIndexing.js +48 -0
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +12 -0
- package/elasticsearch/indexing/objectIndexing.js +223 -0
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
- package/elasticsearch/indexing/richTextIndexing.js +34 -0
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +15 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +16 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +3 -0
- package/elasticsearch/search/index.js +14 -0
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -0
- package/elasticsearch/search/refSearch.js +35 -0
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -0
- package/elasticsearch/search/timeSearch.js +33 -0
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.d.ts +18 -0
- package/helpers/entryIndexHelpers.js +204 -0
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +18 -0
- package/helpers/index.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +275 -0
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +51 -0
- package/operations/entry/dataLoaders.js +365 -0
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +162 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +9 -0
- package/operations/entry/elasticsearch/fields.js +248 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +215 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
- package/operations/entry/elasticsearch/filtering/path.js +52 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +30 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +28 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +117 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +38 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +45 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/operations/entry/elasticsearch/plugins/search.js +30 -0
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +92 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +5 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/elasticsearchFields.d.ts +2 -0
- package/operations/entry/elasticsearchFields.js +38 -0
- package/operations/entry/elasticsearchFields.js.map +1 -0
- package/operations/entry/index.d.ts +11 -0
- package/operations/entry/index.js +1251 -0
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.d.ts +12 -0
- package/operations/entry/keys.js +40 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +24 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/group/index.d.ts +8 -0
- package/operations/group/index.js +195 -0
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +8 -0
- package/operations/model/index.js +204 -0
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +6 -0
- package/operations/settings/index.js +135 -0
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +6 -0
- package/operations/system/index.js +99 -0
- package/operations/system/index.js.map +1 -0
- package/package.json +68 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +20 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +31 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +164 -0
- package/types.js +47 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createModelsStorageOperations = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _configurations = require("../../configurations");
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
17
|
+
|
|
18
|
+
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
19
|
+
|
|
20
|
+
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
21
|
+
|
|
22
|
+
const createPartitionKey = params => {
|
|
23
|
+
const {
|
|
24
|
+
tenant,
|
|
25
|
+
locale
|
|
26
|
+
} = params;
|
|
27
|
+
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const createSortKey = params => {
|
|
31
|
+
return params.modelId;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const createKeys = params => {
|
|
35
|
+
return {
|
|
36
|
+
PK: createPartitionKey(params),
|
|
37
|
+
SK: createSortKey(params)
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const createType = () => {
|
|
42
|
+
return "cms.model";
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const createModelsStorageOperations = params => {
|
|
46
|
+
const {
|
|
47
|
+
entity,
|
|
48
|
+
elasticsearch
|
|
49
|
+
} = params;
|
|
50
|
+
|
|
51
|
+
const create = async params => {
|
|
52
|
+
const {
|
|
53
|
+
model
|
|
54
|
+
} = params;
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
index
|
|
58
|
+
} = _configurations.configurations.es({
|
|
59
|
+
model
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const keys = createKeys(model);
|
|
63
|
+
let error;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
67
|
+
TYPE: createType()
|
|
68
|
+
}));
|
|
69
|
+
return model;
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
error = ex;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In case of DynamoDB error we need to remove the index we created.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await elasticsearch.indices.delete({
|
|
80
|
+
index,
|
|
81
|
+
ignore_unavailable: true
|
|
82
|
+
});
|
|
83
|
+
} catch (ex) {
|
|
84
|
+
throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
85
|
+
dynamodbError: error,
|
|
86
|
+
elasticsearchError: ex
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
throw error;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const update = async params => {
|
|
94
|
+
const {
|
|
95
|
+
model
|
|
96
|
+
} = params;
|
|
97
|
+
const keys = createKeys(model);
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
101
|
+
TYPE: createType()
|
|
102
|
+
}));
|
|
103
|
+
return model;
|
|
104
|
+
} catch (ex) {
|
|
105
|
+
throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
106
|
+
error: ex,
|
|
107
|
+
model,
|
|
108
|
+
keys
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const deleteModel = async params => {
|
|
114
|
+
const {
|
|
115
|
+
model
|
|
116
|
+
} = params;
|
|
117
|
+
const keys = createKeys(model);
|
|
118
|
+
|
|
119
|
+
const {
|
|
120
|
+
index
|
|
121
|
+
} = _configurations.configurations.es({
|
|
122
|
+
model
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await entity.delete(keys);
|
|
127
|
+
} catch (ex) {
|
|
128
|
+
throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
129
|
+
error: ex,
|
|
130
|
+
model,
|
|
131
|
+
keys
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Always delete the model index after deleting the model.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
await elasticsearch.indices.delete({
|
|
141
|
+
index,
|
|
142
|
+
ignore_unavailable: true
|
|
143
|
+
});
|
|
144
|
+
} catch (ex) {
|
|
145
|
+
throw new _error.default(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
146
|
+
error: ex,
|
|
147
|
+
index,
|
|
148
|
+
model
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return model;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const get = async params => {
|
|
156
|
+
const keys = createKeys(params);
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
const item = await (0, _get.get)({
|
|
160
|
+
entity,
|
|
161
|
+
keys
|
|
162
|
+
});
|
|
163
|
+
return (0, _cleanup.cleanupItem)(entity, item);
|
|
164
|
+
} catch (ex) {
|
|
165
|
+
throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
166
|
+
error: ex,
|
|
167
|
+
keys
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const list = async params => {
|
|
173
|
+
const {
|
|
174
|
+
where
|
|
175
|
+
} = params;
|
|
176
|
+
const queryAllParams = {
|
|
177
|
+
entity,
|
|
178
|
+
partitionKey: createPartitionKey(where),
|
|
179
|
+
options: {
|
|
180
|
+
gte: " "
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const items = await (0, _query.queryAll)(queryAllParams);
|
|
186
|
+
return (0, _cleanup.cleanupItems)(entity, items);
|
|
187
|
+
} catch (ex) {
|
|
188
|
+
throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
189
|
+
error: ex,
|
|
190
|
+
partitionKey: queryAllParams.partitionKey
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
create,
|
|
197
|
+
update,
|
|
198
|
+
delete: deleteModel,
|
|
199
|
+
get,
|
|
200
|
+
list
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { configurations } from \"~/configurations\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;;;;AAUA;;AACA;;AAEA;;AACA;;AACA;;AAMA,MAAMA,kBAAkB,GAAIC,MAAD,IAAyC;EAChE,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAqBF,MAA3B;EACA,OAAQ,KAAIC,MAAO,MAAKC,MAAO,SAA/B;AACH,CAHD;;AAQA,MAAMC,aAAa,GAAIH,MAAD,IAAmC;EACrD,OAAOA,MAAM,CAACI,OAAd;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIL,MAAD,IAAuD;EACtE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAD,CADnB;IAEHO,EAAE,EAAEJ,aAAa,CAACH,MAAD;EAFd,CAAP;AAIH,CALD;;AAOA,MAAMQ,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAP;AACH,CAFD;;AAQO,MAAMC,6BAA6B,GACtCT,MADyC,IAEb;EAC5B,MAAM;IAAEU,MAAF;IAAUC;EAAV,IAA4BX,MAAlC;;EAEA,MAAMY,MAAM,GAAG,MAAOZ,MAAP,IAAyD;IACpE,MAAM;MAAEa;IAAF,IAAYb,MAAlB;;IAEA,MAAM;MAAEc;IAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;MAChCH;IADgC,CAAlB,CAAlB;;IAIA,MAAMI,IAAI,GAAGZ,UAAU,CAACQ,KAAD,CAAvB;IAEA,IAAIK,KAAJ;;IACA,IAAI;MACA,MAAMR,MAAM,CAACS,GAAP,yFACC,IAAAC,oBAAA,EAAYV,MAAZ,EAAoBG,KAApB,CADD,GAECI,IAFD;QAGFI,IAAI,EAAEb,UAAU;MAHd,G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EnC6B,YAAY,EAAExC,kBAAkB,CAACsC,KAAD,CAFG;MAGnCG,OAAO,EAAE;QACLC,GAAG,EAAE;MADA;IAH0B,CAAvC;;IAOA,IAAI;MACA,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAA,EAAmBL,cAAnB,CAApB;MAEA,OAAO,IAAAM,qBAAA,EAAalC,MAAb,EAAqBgC,KAArB,CAAP;IACH,CAJD,CAIE,OAAOpB,EAAP,EAAW;MACT,MAAM,IAAII,cAAJ,CACFJ,EAAE,CAACQ,OAAH,IAAc,wBADZ,EAEFR,EAAE,CAACS,IAAH,IAAW,kBAFT,EAGF;QACIb,KAAK,EAAEI,EADX;QAEIiB,YAAY,EAAED,cAAc,CAACC;MAFjC,CAHE,CAAN;IAQH;EACJ,CAvBD;;EAyBA,OAAO;IACH3B,MADG;IAEHiB,MAFG;IAGHL,MAAM,EAAEQ,WAHL;IAIHC,GAJG;IAKHG;EALG,CAAP;AAOH,CAxKM"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Entity } from "dynamodb-toolbox";
|
|
3
|
+
export interface CreateSettingsStorageOperationsParams {
|
|
4
|
+
entity: Entity<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSettingsStorageOperations = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
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
|
+
const convertToDbData = settings => {
|
|
19
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
20
|
+
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const convertFromDbData = settings => {
|
|
25
|
+
if (!settings) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let contentModelLastChange;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
33
|
+
} catch {
|
|
34
|
+
contentModelLastChange = new Date();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
38
|
+
contentModelLastChange
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const createPartitionKey = ({
|
|
43
|
+
tenant,
|
|
44
|
+
locale
|
|
45
|
+
}) => {
|
|
46
|
+
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const createSortKey = () => {
|
|
50
|
+
return "settings";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const createKeys = params => {
|
|
54
|
+
return {
|
|
55
|
+
PK: createPartitionKey(params),
|
|
56
|
+
SK: createSortKey()
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const createSettingsStorageOperations = params => {
|
|
61
|
+
const {
|
|
62
|
+
entity
|
|
63
|
+
} = params;
|
|
64
|
+
|
|
65
|
+
const create = async params => {
|
|
66
|
+
const {
|
|
67
|
+
settings
|
|
68
|
+
} = params;
|
|
69
|
+
const keys = createKeys(settings);
|
|
70
|
+
const dbSettings = convertToDbData(settings);
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
74
|
+
return settings;
|
|
75
|
+
} catch (ex) {
|
|
76
|
+
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
77
|
+
error: ex,
|
|
78
|
+
settings,
|
|
79
|
+
dbSettings,
|
|
80
|
+
keys
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const update = async params => {
|
|
86
|
+
const {
|
|
87
|
+
settings
|
|
88
|
+
} = params;
|
|
89
|
+
const keys = createKeys(settings);
|
|
90
|
+
const dbSettings = convertToDbData(settings);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
94
|
+
return settings;
|
|
95
|
+
} catch (ex) {
|
|
96
|
+
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
97
|
+
error: ex,
|
|
98
|
+
settings,
|
|
99
|
+
dbSettings,
|
|
100
|
+
keys
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const get = async params => {
|
|
106
|
+
const keys = createKeys(params);
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
const record = await (0, _get.get)({
|
|
110
|
+
entity,
|
|
111
|
+
keys
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (!record) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
119
|
+
return convertFromDbData(settings);
|
|
120
|
+
} catch (ex) {
|
|
121
|
+
throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
|
|
122
|
+
error: ex,
|
|
123
|
+
keys
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
create,
|
|
130
|
+
get,
|
|
131
|
+
update
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
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\nexport interface 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,QAAD,IAA0C;EAC9D,mEACOA,QADP;IAEIC,sBAAsB,E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wBA,OAAO;IACHD,MADG;IAEHU,GAFG;IAGHD;EAHG,CAAP;AAKH,CAvFM"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Entity } from "dynamodb-toolbox";
|
|
3
|
+
export interface CreateSystemStorageOperationsParams {
|
|
4
|
+
entity: Entity<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSystemStorageOperations = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
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
|
+
const createPartitionKey = ({
|
|
19
|
+
tenant
|
|
20
|
+
}) => {
|
|
21
|
+
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const createSortKey = () => {
|
|
25
|
+
return "CMS";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const createKeys = params => {
|
|
29
|
+
return {
|
|
30
|
+
PK: createPartitionKey(params),
|
|
31
|
+
SK: createSortKey()
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const createSystemStorageOperations = params => {
|
|
36
|
+
const {
|
|
37
|
+
entity
|
|
38
|
+
} = params;
|
|
39
|
+
|
|
40
|
+
const create = async ({
|
|
41
|
+
system
|
|
42
|
+
}) => {
|
|
43
|
+
const keys = createKeys(system);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
47
|
+
return system;
|
|
48
|
+
} catch (ex) {
|
|
49
|
+
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
50
|
+
error: ex,
|
|
51
|
+
system,
|
|
52
|
+
keys
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const update = async params => {
|
|
58
|
+
const {
|
|
59
|
+
system
|
|
60
|
+
} = params;
|
|
61
|
+
const keys = createKeys(system);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
65
|
+
return system;
|
|
66
|
+
} catch (ex) {
|
|
67
|
+
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
68
|
+
error: ex,
|
|
69
|
+
system,
|
|
70
|
+
keys
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const get = async params => {
|
|
76
|
+
const keys = createKeys(params);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const system = await (0, _get.get)({
|
|
80
|
+
entity,
|
|
81
|
+
keys
|
|
82
|
+
});
|
|
83
|
+
return (0, _cleanup.cleanupItem)(entity, system);
|
|
84
|
+
} catch (ex) {
|
|
85
|
+
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
86
|
+
error: ex,
|
|
87
|
+
keys
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
create,
|
|
94
|
+
update,
|
|
95
|
+
get
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
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\nexport interface 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;AAAF,CAAD,KAA4C;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;IAEHE,EAAE,EAAEJ,aAAa;EAFd,CAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;EAC7B,MAAM;IAAEI;EAAF,IAAaJ,MAAnB;;EAEA,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAAF,CAAP,KAA8D;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;IACA,IAAI;MACA,MAAMF,MAAM,CAACI,GAAP,6DACCF,MADD,GAECC,IAFD,EAAN;MAIA,OAAOD,MAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,0BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIH,MAFJ;QAGIC;MAHJ,CAHE,C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ny/api-headless-cms",
|
|
7
|
+
"storage-operations",
|
|
8
|
+
"dynamodb",
|
|
9
|
+
"elasticsearch",
|
|
10
|
+
"cms:ddb-es"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
15
|
+
"directory": "packages/api-headless-cms-ddb-es"
|
|
16
|
+
},
|
|
17
|
+
"description": "DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.",
|
|
18
|
+
"contributors": [
|
|
19
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
20
|
+
"Sven Al Hamad <sven@webiny.com>",
|
|
21
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@babel/runtime": "7.19.0",
|
|
26
|
+
"@webiny/api": "0.0.0-ee-vpcs.549378cf03",
|
|
27
|
+
"@webiny/api-elasticsearch": "0.0.0-ee-vpcs.549378cf03",
|
|
28
|
+
"@webiny/api-headless-cms": "0.0.0-ee-vpcs.549378cf03",
|
|
29
|
+
"@webiny/db-dynamodb": "0.0.0-ee-vpcs.549378cf03",
|
|
30
|
+
"@webiny/error": "0.0.0-ee-vpcs.549378cf03",
|
|
31
|
+
"@webiny/handler-db": "0.0.0-ee-vpcs.549378cf03",
|
|
32
|
+
"@webiny/plugins": "0.0.0-ee-vpcs.549378cf03",
|
|
33
|
+
"@webiny/utils": "0.0.0-ee-vpcs.549378cf03",
|
|
34
|
+
"dataloader": "2.1.0",
|
|
35
|
+
"dynamodb-toolbox": "0.3.5",
|
|
36
|
+
"jsonpack": "1.1.5",
|
|
37
|
+
"lodash": "4.17.21"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/cli": "^7.19.3",
|
|
41
|
+
"@babel/core": "^7.19.3",
|
|
42
|
+
"@babel/preset-env": "^7.19.4",
|
|
43
|
+
"@elastic/elasticsearch": "7.12.0",
|
|
44
|
+
"@types/jsonpack": "^1.1.0",
|
|
45
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-ee-vpcs.549378cf03",
|
|
46
|
+
"@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
|
|
47
|
+
"@webiny/handler-aws": "^0.0.0-ee-vpcs.549378cf03",
|
|
48
|
+
"@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
|
|
49
|
+
"jest": "^28.1.0",
|
|
50
|
+
"jest-dynalite": "^3.2.0",
|
|
51
|
+
"jest-environment-node": "^27.2.4",
|
|
52
|
+
"mdbid": "^1.0.0",
|
|
53
|
+
"prettier": "^2.3.2",
|
|
54
|
+
"rimraf": "^3.0.2",
|
|
55
|
+
"sinon": "^9.0.2",
|
|
56
|
+
"ttypescript": "^1.5.12",
|
|
57
|
+
"typescript": "4.7.4"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"directory": "dist"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "yarn webiny run build",
|
|
65
|
+
"watch": "yarn webiny run watch"
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElasticsearchBodyModifierPlugin, ModifyBodyCallable, ModifyBodyParams as BaseModifyBodyParams } from "@webiny/api-elasticsearch";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface ModifyBodyParams extends BaseModifyBodyParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
where: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface CmsEntryElasticsearchBodyModifierPluginConfig {
|
|
10
|
+
modifyBody: ModifyBodyCallable<ModifyBodyParams>;
|
|
11
|
+
/**
|
|
12
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
13
|
+
*/
|
|
14
|
+
modelId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {
|
|
17
|
+
static readonly type: string;
|
|
18
|
+
readonly modelId?: string;
|
|
19
|
+
constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig);
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsEntryElasticsearchBodyModifierPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchBodyModifierPlugin extends _apiElasticsearch.ElasticsearchBodyModifierPlugin {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config.modifyBody);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = config.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchBodyModifierPlugin = CmsEntryElasticsearchBodyModifierPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchBodyModifierPlugin, "type", "cms.elasticsearch.modifier.body.entry");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin","constructor","config","modifyBody","modelId"],"sources":["CmsEntryElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import {\n ElasticsearchBodyModifierPlugin,\n ModifyBodyCallable,\n ModifyBodyParams as BaseModifyBodyParams\n} from \"@webiny/api-elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface ModifyBodyParams extends BaseModifyBodyParams {\n model: CmsModel;\n where: {\n [key: string]: any;\n };\n}\n\nexport interface CmsEntryElasticsearchBodyModifierPluginConfig {\n modifyBody: ModifyBodyCallable<ModifyBodyParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.body.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig) {\n super(config.modifyBody);\n\n this.modelId = config.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAsBO,MAAMA,uCAAN,SAAsDC,iDAAtD,CAAwG;EAKpGC,WAAW,CAACC,MAAD,EAAwD;IACtE,MAAMA,MAAM,CAACC,UAAb;IADsE;IAGtE,KAAKC,OAAL,GAAeF,MAAM,CAACE,OAAtB;EACH;;AAT0G;;;8BAAlGL,uC,UACsC,uC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElasticsearchFieldPlugin, ElasticsearchFieldPluginParams as ElasticsearchFieldPluginParamsBaseParams } from "@webiny/api-elasticsearch";
|
|
2
|
+
export interface CmsEntryElasticsearchFieldPluginParams extends ElasticsearchFieldPluginParamsBaseParams {
|
|
3
|
+
/**
|
|
4
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
5
|
+
*/
|
|
6
|
+
modelId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class CmsEntryElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
|
|
9
|
+
static readonly type: string;
|
|
10
|
+
readonly modelId?: string;
|
|
11
|
+
constructor(params: CmsEntryElasticsearchFieldPluginParams);
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsEntryElasticsearchFieldPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchFieldPlugin extends _apiElasticsearch.ElasticsearchFieldPlugin {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super(params);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = params.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchFieldPlugin = CmsEntryElasticsearchFieldPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchFieldPlugin, "type", "elasticsearch.fieldDefinition.cms.entry");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchFieldPlugin","ElasticsearchFieldPlugin","constructor","params","modelId"],"sources":["CmsEntryElasticsearchFieldPlugin.ts"],"sourcesContent":["import {\n ElasticsearchFieldPlugin,\n ElasticsearchFieldPluginParams as ElasticsearchFieldPluginParamsBaseParams\n} from \"@webiny/api-elasticsearch\";\n\nexport interface CmsEntryElasticsearchFieldPluginParams\n extends ElasticsearchFieldPluginParamsBaseParams {\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\nexport class CmsEntryElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {\n public static override readonly type: string = \"elasticsearch.fieldDefinition.cms.entry\";\n\n public readonly modelId?: string;\n\n public constructor(params: CmsEntryElasticsearchFieldPluginParams) {\n super(params);\n\n this.modelId = params.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAYO,MAAMA,gCAAN,SAA+CC,0CAA/C,CAAwE;EAKpEC,WAAW,CAACC,MAAD,EAAiD;IAC/D,MAAMA,MAAN;IAD+D;IAG/D,KAAKC,OAAL,GAAeD,MAAM,CAACC,OAAtB;EACH;;AAT0E;;;8BAAlEJ,gC,UACsC,yC"}
|