@webiny/api-prerendering-service-so-ddb 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/queueJob.d.ts +6 -5
- package/definitions/queueJob.js +8 -16
- package/definitions/queueJob.js.map +1 -0
- package/definitions/render.d.ts +6 -5
- package/definitions/render.js +10 -24
- package/definitions/render.js.map +1 -0
- package/definitions/renderLegacy.d.ts +9 -0
- package/definitions/renderLegacy.js +48 -0
- package/definitions/renderLegacy.js.map +1 -0
- package/definitions/settings.d.ts +9 -0
- package/definitions/settings.js +36 -0
- package/definitions/settings.js.map +1 -0
- package/definitions/table.d.ts +7 -6
- package/definitions/table.js +13 -6
- package/definitions/table.js.map +1 -0
- package/definitions/tagPathLink.d.ts +56 -0
- package/definitions/tagPathLink.js +42 -0
- package/definitions/tagPathLink.js.map +1 -0
- package/definitions/tagPathLinkLegacy.d.ts +62 -0
- package/definitions/tagPathLinkLegacy.js +45 -0
- package/definitions/tagPathLinkLegacy.js.map +1 -0
- package/definitions/tenantEntity.d.ts +8 -0
- package/definitions/tenantEntity.js +39 -0
- package/definitions/tenantEntity.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +39 -38
- package/index.js.map +1 -0
- package/operations/queueJob.d.ts +6 -0
- package/operations/{queueJob/index.js → queueJob.js} +24 -43
- package/operations/queueJob.js.map +1 -0
- package/operations/render.d.ts +20 -0
- package/operations/render.js +330 -0
- package/operations/render.js.map +1 -0
- package/operations/settings.d.ts +6 -0
- package/operations/settings.js +68 -0
- package/operations/settings.js.map +1 -0
- package/operations/tenant.d.ts +6 -0
- package/operations/tenant.js +29 -0
- package/operations/tenant.js.map +1 -0
- package/package.json +16 -31
- package/types.d.ts +18 -12
- package/types.js +8 -6
- package/types.js.map +1 -0
- package/definitions/tagUrlLink.d.ts +0 -8
- package/definitions/tagUrlLink.js +0 -53
- package/operations/queueJob/index.d.ts +0 -6
- package/operations/render/index.d.ts +0 -16
- package/operations/render/index.js +0 -336
|
@@ -1,336 +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.createRenderStorageOperations = 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 _query = require("@webiny/db-dynamodb/utils/query");
|
|
17
|
-
|
|
18
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
19
|
-
|
|
20
|
-
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
21
|
-
|
|
22
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
const createRenderStorageOperations = params => {
|
|
29
|
-
const {
|
|
30
|
-
entity,
|
|
31
|
-
tagUrlLinkEntity
|
|
32
|
-
} = params;
|
|
33
|
-
|
|
34
|
-
const createRenderPartitionKey = namespace => {
|
|
35
|
-
/**
|
|
36
|
-
* For backwards compatibility remove the T# if it exists.
|
|
37
|
-
*/
|
|
38
|
-
if (namespace.startsWith("T#")) {
|
|
39
|
-
namespace = namespace.replace(/^T#/, "");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return `T#${namespace}#PS#RENDER`;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createRenderSortKey = url => {
|
|
46
|
-
return url;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const createRenderType = () => {
|
|
50
|
-
return "ps.render";
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const createTagUrlLinkPartitionKey = params => {
|
|
54
|
-
const {
|
|
55
|
-
tag
|
|
56
|
-
} = params;
|
|
57
|
-
let {
|
|
58
|
-
namespace
|
|
59
|
-
} = params;
|
|
60
|
-
|
|
61
|
-
if (namespace.startsWith("T#")) {
|
|
62
|
-
namespace = namespace.replace(/^T#/, "");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return `T#${namespace}#PS#TAG#${tag.key}`;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const createTagUrlLinkSortKey = params => {
|
|
69
|
-
const {
|
|
70
|
-
tag,
|
|
71
|
-
url
|
|
72
|
-
} = params;
|
|
73
|
-
const values = [tag.value];
|
|
74
|
-
|
|
75
|
-
if (url) {
|
|
76
|
-
values.push(url);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return values.join("#");
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const createTagUrlLinkType = () => {
|
|
83
|
-
return "ps.tagUrlLink";
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const getRender = async params => {
|
|
87
|
-
const {
|
|
88
|
-
where
|
|
89
|
-
} = params;
|
|
90
|
-
const keys = {
|
|
91
|
-
PK: createRenderPartitionKey(where.namespace),
|
|
92
|
-
SK: createRenderSortKey(where.url)
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const result = await (0, _get.get)({
|
|
97
|
-
entity,
|
|
98
|
-
keys
|
|
99
|
-
});
|
|
100
|
-
return (0, _cleanup.cleanupItem)(entity, result);
|
|
101
|
-
} catch (ex) {
|
|
102
|
-
throw new _error.default(ex.message || "Could not get render record by given key.", ex.code || "GET_RENDER_ERROR", {
|
|
103
|
-
keys,
|
|
104
|
-
params
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const createRender = async params => {
|
|
110
|
-
const {
|
|
111
|
-
render
|
|
112
|
-
} = params;
|
|
113
|
-
const keys = {
|
|
114
|
-
PK: createRenderPartitionKey(render.namespace),
|
|
115
|
-
SK: createRenderSortKey(render.url)
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
await entity.put(_objectSpread(_objectSpread(_objectSpread({}, render), keys), {}, {
|
|
120
|
-
TYPE: createRenderType()
|
|
121
|
-
}));
|
|
122
|
-
return render;
|
|
123
|
-
} catch (ex) {
|
|
124
|
-
throw new _error.default(ex.message || "Could not create render record.", ex.code || "CREATE_RENDER_ERROR", {
|
|
125
|
-
keys,
|
|
126
|
-
render
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const deleteRender = async params => {
|
|
132
|
-
const {
|
|
133
|
-
render
|
|
134
|
-
} = params;
|
|
135
|
-
const keys = {
|
|
136
|
-
PK: createRenderPartitionKey(render.namespace),
|
|
137
|
-
SK: createRenderSortKey(render.url)
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
await entity.delete(keys);
|
|
142
|
-
} catch (ex) {
|
|
143
|
-
throw new _error.default(ex.message || "Could not delete render record.", ex.code || "DELETE_RENDER_ERROR", {
|
|
144
|
-
keys,
|
|
145
|
-
render
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const listRendersByTag = async params => {
|
|
151
|
-
const {
|
|
152
|
-
where
|
|
153
|
-
} = params;
|
|
154
|
-
const {
|
|
155
|
-
namespace,
|
|
156
|
-
tag
|
|
157
|
-
} = where;
|
|
158
|
-
/**
|
|
159
|
-
* Possibly there is no tag.key so no need to go further
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
if (!tag || !tag.key) {
|
|
163
|
-
return [];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const links = await listTagUrlLinks({
|
|
167
|
-
where: {
|
|
168
|
-
namespace,
|
|
169
|
-
tag
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
const items = links.map(link => {
|
|
173
|
-
return entity.getBatch({
|
|
174
|
-
PK: createRenderPartitionKey(namespace),
|
|
175
|
-
SK: createRenderSortKey(link.url)
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
const results = await (0, _batchRead.batchReadAll)({
|
|
181
|
-
table: entity.table,
|
|
182
|
-
items
|
|
183
|
-
});
|
|
184
|
-
return (0, _cleanup.cleanupItems)(entity, results);
|
|
185
|
-
} catch (ex) {
|
|
186
|
-
throw new _error.default(ex.message || "Could not list render records after links.", ex.code || "LIST_LINKS_RENDER_ERROR", {
|
|
187
|
-
links
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const listRenders = async params => {
|
|
193
|
-
const {
|
|
194
|
-
where
|
|
195
|
-
} = params;
|
|
196
|
-
const {
|
|
197
|
-
namespace,
|
|
198
|
-
tag
|
|
199
|
-
} = where;
|
|
200
|
-
|
|
201
|
-
if (tag) {
|
|
202
|
-
return listRendersByTag(params);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const queryAllParams = {
|
|
206
|
-
entity,
|
|
207
|
-
partitionKey: createRenderPartitionKey(namespace),
|
|
208
|
-
options: {
|
|
209
|
-
gte: " "
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
const results = await (0, _query.queryAll)(queryAllParams);
|
|
215
|
-
return (0, _cleanup.cleanupItems)(entity, results);
|
|
216
|
-
} catch (ex) {
|
|
217
|
-
throw new _error.default(ex.message || "Could not list render records.", ex.code || "LIST_RENDER_ERROR", {
|
|
218
|
-
partitionKey: queryAllParams.partitionKey,
|
|
219
|
-
options: queryAllParams.options
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const createTagUrlLinks = async params => {
|
|
225
|
-
const {
|
|
226
|
-
tagUrlLinks
|
|
227
|
-
} = params;
|
|
228
|
-
const items = tagUrlLinks.map(item => {
|
|
229
|
-
return tagUrlLinkEntity.putBatch(_objectSpread(_objectSpread({}, item), {}, {
|
|
230
|
-
TYPE: createTagUrlLinkType(),
|
|
231
|
-
PK: createTagUrlLinkPartitionKey({
|
|
232
|
-
namespace: item.namespace,
|
|
233
|
-
tag: item
|
|
234
|
-
}),
|
|
235
|
-
SK: createTagUrlLinkSortKey({
|
|
236
|
-
tag: item,
|
|
237
|
-
url: item.url
|
|
238
|
-
})
|
|
239
|
-
}));
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
try {
|
|
243
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
244
|
-
table: tagUrlLinkEntity.table,
|
|
245
|
-
items
|
|
246
|
-
});
|
|
247
|
-
return tagUrlLinks;
|
|
248
|
-
} catch (ex) {
|
|
249
|
-
throw new _error.default(ex.message || "Could not create tagUrlLink records.", ex.code || "CREATE_URL_TAG_LINKS_ERROR", {
|
|
250
|
-
tagUrlLinks
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const deleteTagUrlLinks = async params => {
|
|
256
|
-
const {
|
|
257
|
-
namespace,
|
|
258
|
-
tags,
|
|
259
|
-
url
|
|
260
|
-
} = params;
|
|
261
|
-
const items = tags.map(tag => {
|
|
262
|
-
return tagUrlLinkEntity.deleteBatch({
|
|
263
|
-
PK: createTagUrlLinkPartitionKey({
|
|
264
|
-
tag,
|
|
265
|
-
namespace
|
|
266
|
-
}),
|
|
267
|
-
SK: createTagUrlLinkSortKey({
|
|
268
|
-
tag,
|
|
269
|
-
url
|
|
270
|
-
})
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
276
|
-
table: tagUrlLinkEntity.table,
|
|
277
|
-
items
|
|
278
|
-
});
|
|
279
|
-
} catch (ex) {
|
|
280
|
-
throw new _error.default(ex.message || "Could not delete tagUrlLink records.", ex.code || "DELETE_URL_TAG_LINKS_ERROR", {
|
|
281
|
-
tags,
|
|
282
|
-
namespace,
|
|
283
|
-
url
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const listTagUrlLinks = async params => {
|
|
289
|
-
const {
|
|
290
|
-
where
|
|
291
|
-
} = params;
|
|
292
|
-
const {
|
|
293
|
-
namespace,
|
|
294
|
-
tag
|
|
295
|
-
} = where;
|
|
296
|
-
const partitionKey = createTagUrlLinkPartitionKey({
|
|
297
|
-
namespace,
|
|
298
|
-
tag
|
|
299
|
-
});
|
|
300
|
-
const options = {};
|
|
301
|
-
|
|
302
|
-
if (tag.value) {
|
|
303
|
-
options.beginsWith = `${tag.value}#`;
|
|
304
|
-
} else {
|
|
305
|
-
options.gte = " ";
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const queryAllParams = {
|
|
309
|
-
entity: tagUrlLinkEntity,
|
|
310
|
-
partitionKey,
|
|
311
|
-
options
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
try {
|
|
315
|
-
const results = await (0, _query.queryAll)(queryAllParams);
|
|
316
|
-
return (0, _cleanup.cleanupItems)(tagUrlLinkEntity, results);
|
|
317
|
-
} catch (ex) {
|
|
318
|
-
throw new _error.default(ex.message || "Could not list tagUrlLink records.", ex.code || "LIST_TAG_URL_LINK_ERROR", {
|
|
319
|
-
partitionKey,
|
|
320
|
-
options
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
return {
|
|
326
|
-
createRender,
|
|
327
|
-
deleteRender,
|
|
328
|
-
listRenders,
|
|
329
|
-
getRender,
|
|
330
|
-
createTagUrlLinks,
|
|
331
|
-
deleteTagUrlLinks,
|
|
332
|
-
listTagUrlLinks
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
exports.createRenderStorageOperations = createRenderStorageOperations;
|