@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
package/index.js
CHANGED
|
@@ -1,59 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createPrerenderingServiceStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _types = require("./types");
|
|
15
|
-
|
|
16
10
|
var _table = require("./definitions/table");
|
|
17
|
-
|
|
18
11
|
var _render = require("./definitions/render");
|
|
19
|
-
|
|
12
|
+
var _settings = require("./definitions/settings");
|
|
20
13
|
var _queueJob = require("./definitions/queueJob");
|
|
21
|
-
|
|
22
14
|
var _render2 = require("./operations/render");
|
|
23
|
-
|
|
15
|
+
var _tenant = require("./operations/tenant");
|
|
16
|
+
var _settings2 = require("./operations/settings");
|
|
24
17
|
var _queueJob2 = require("./operations/queueJob");
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
18
|
+
var _tagPathLink = require("./definitions/tagPathLink");
|
|
19
|
+
var _tenantEntity = require("./definitions/tenantEntity");
|
|
32
20
|
const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
|
|
33
|
-
|
|
34
21
|
const isReserved = name => {
|
|
35
22
|
if (reservedFields.includes(name) === false) {
|
|
36
23
|
return;
|
|
37
24
|
}
|
|
38
|
-
|
|
39
25
|
throw new _error.default(`Attribute name "${name}" is not allowed.`, "ATTRIBUTE_NOT_ALLOWED", {
|
|
40
26
|
name
|
|
41
27
|
});
|
|
42
28
|
};
|
|
43
|
-
|
|
44
29
|
const createPrerenderingServiceStorageOperations = params => {
|
|
45
30
|
const {
|
|
46
|
-
attributes
|
|
31
|
+
attributes,
|
|
47
32
|
table,
|
|
48
33
|
documentClient
|
|
49
34
|
} = params;
|
|
50
|
-
|
|
51
35
|
if (attributes) {
|
|
52
36
|
Object.values(attributes).forEach(attrs => {
|
|
53
37
|
Object.keys(attrs).forEach(isReserved);
|
|
54
38
|
});
|
|
55
39
|
}
|
|
56
|
-
|
|
57
40
|
const tableInstance = (0, _table.createTable)({
|
|
58
41
|
table,
|
|
59
42
|
documentClient
|
|
@@ -62,28 +45,46 @@ const createPrerenderingServiceStorageOperations = params => {
|
|
|
62
45
|
render: (0, _render.createRenderEntity)({
|
|
63
46
|
entityName: _types.ENTITIES.RENDER,
|
|
64
47
|
table: tableInstance,
|
|
65
|
-
attributes: attributes[_types.ENTITIES.RENDER]
|
|
48
|
+
attributes: attributes ? attributes[_types.ENTITIES.RENDER] : {}
|
|
49
|
+
}),
|
|
50
|
+
settings: (0, _settings.createSettingsEntity)({
|
|
51
|
+
entityName: _types.ENTITIES.SETTINGS,
|
|
52
|
+
table: tableInstance,
|
|
53
|
+
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
66
54
|
}),
|
|
67
55
|
queueJob: (0, _queueJob.createQueueJobEntity)({
|
|
68
56
|
entityName: _types.ENTITIES.QUEUE_JOB,
|
|
69
57
|
table: tableInstance,
|
|
70
|
-
attributes: attributes[_types.ENTITIES.QUEUE_JOB]
|
|
58
|
+
attributes: attributes ? attributes[_types.ENTITIES.QUEUE_JOB] : {}
|
|
71
59
|
}),
|
|
72
|
-
|
|
73
|
-
entityName: _types.ENTITIES.
|
|
60
|
+
tagPathLink: (0, _tagPathLink.createTagPathLinkEntity)({
|
|
61
|
+
entityName: _types.ENTITIES.TAG_PATH_LINK,
|
|
74
62
|
table: tableInstance,
|
|
75
|
-
attributes: attributes[_types.ENTITIES.
|
|
63
|
+
attributes: attributes ? attributes[_types.ENTITIES.TAG_PATH_LINK] : {}
|
|
64
|
+
}),
|
|
65
|
+
tenant: (0, _tenantEntity.createTenantEntity)({
|
|
66
|
+
entityName: _types.ENTITIES.TENANT,
|
|
67
|
+
table: tableInstance
|
|
76
68
|
})
|
|
77
69
|
};
|
|
78
|
-
return
|
|
70
|
+
return {
|
|
79
71
|
getTable: () => tableInstance,
|
|
80
|
-
getEntities: () => entities
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
getEntities: () => entities,
|
|
73
|
+
...(0, _render2.createRenderStorageOperations)({
|
|
74
|
+
entity: entities.render,
|
|
75
|
+
tagPathLinkEntity: entities.tagPathLink
|
|
76
|
+
}),
|
|
77
|
+
...(0, _queueJob2.createQueueJobStorageOperations)({
|
|
78
|
+
entity: entities.queueJob
|
|
79
|
+
}),
|
|
80
|
+
...(0, _settings2.createSettingsStorageOperations)({
|
|
81
|
+
entity: entities.settings
|
|
82
|
+
}),
|
|
83
|
+
...(0, _tenant.createTenantStorageOperations)({
|
|
84
|
+
entity: entities.tenant
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
87
|
};
|
|
88
|
+
exports.createPrerenderingServiceStorageOperations = createPrerenderingServiceStorageOperations;
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_table","_render","_settings","_queueJob","_render2","_tenant","_settings2","_queueJob2","_tagPathLink","_tenantEntity","reservedFields","isReserved","name","includes","WebinyError","createPrerenderingServiceStorageOperations","params","attributes","table","documentClient","Object","values","forEach","attrs","keys","tableInstance","createTable","entities","render","createRenderEntity","entityName","ENTITIES","RENDER","settings","createSettingsEntity","SETTINGS","queueJob","createQueueJobEntity","QUEUE_JOB","tagPathLink","createTagPathLinkEntity","TAG_PATH_LINK","tenant","createTenantEntity","TENANT","getTable","getEntities","createRenderStorageOperations","entity","tagPathLinkEntity","createQueueJobStorageOperations","createSettingsStorageOperations","createTenantStorageOperations","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { PrerenderingServiceFactory, PrerenderingServiceFactoryParams } from \"~/types\";\nimport { ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createRenderEntity } from \"~/definitions/render\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createQueueJobEntity } from \"~/definitions/queueJob\";\nimport { createRenderStorageOperations } from \"~/operations/render\";\nimport { createTenantStorageOperations } from \"~/operations/tenant\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createQueueJobStorageOperations } from \"~/operations/queueJob\";\nimport { createTagPathLinkEntity } from \"~/definitions/tagPathLink\";\nimport { createTenantEntity } from \"~/definitions/tenantEntity\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\", \"TYPE\", \"__type\", \"GSI1_PK\", \"GSI1_SK\"];\n\nconst isReserved = (name: string): void => {\n if (reservedFields.includes(name) === false) {\n return;\n }\n throw new WebinyError(`Attribute name \"${name}\" is not allowed.`, \"ATTRIBUTE_NOT_ALLOWED\", {\n name\n });\n};\n\nexport const createPrerenderingServiceStorageOperations: PrerenderingServiceFactory = (\n params: PrerenderingServiceFactoryParams\n) => {\n const { attributes, table, documentClient } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const tableInstance = createTable({ table, documentClient });\n\n const entities = {\n render: createRenderEntity({\n entityName: ENTITIES.RENDER,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.RENDER] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n queueJob: createQueueJobEntity({\n entityName: ENTITIES.QUEUE_JOB,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.QUEUE_JOB] : {}\n }),\n tagPathLink: createTagPathLinkEntity({\n entityName: ENTITIES.TAG_PATH_LINK,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.TAG_PATH_LINK] : {}\n }),\n tenant: createTenantEntity({\n entityName: ENTITIES.TENANT,\n table: tableInstance\n })\n };\n\n return {\n getTable: () => tableInstance,\n getEntities: () => entities,\n ...createRenderStorageOperations({\n entity: entities.render,\n tagPathLinkEntity: entities.tagPathLink\n }),\n ...createQueueJobStorageOperations({\n entity: entities.queueJob\n }),\n ...createSettingsStorageOperations({\n entity: entities.settings\n }),\n ...createTenantStorageOperations({\n entity: entities.tenant\n })\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAA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|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PrerenderingServiceQueueJobStorageOperations } from "@webiny/api-prerendering-service/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
export interface CreateQueueJobStorageOperationsParams {
|
|
4
|
+
entity: Entity<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const createQueueJobStorageOperations: (params: CreateQueueJobStorageOperationsParams) => PrerenderingServiceQueueJobStorageOperations;
|
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createQueueJobStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
15
|
-
|
|
9
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
16
10
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
17
|
-
|
|
18
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
11
|
const createQueueJobStorageOperations = params => {
|
|
25
12
|
const {
|
|
26
13
|
entity
|
|
27
14
|
} = params;
|
|
28
|
-
|
|
29
15
|
const createQueueJobPartitionKey = () => {
|
|
30
16
|
return "PS#Q#JOB";
|
|
31
17
|
};
|
|
32
|
-
|
|
33
18
|
const createQueueJobSortKey = id => {
|
|
34
19
|
return id;
|
|
35
20
|
};
|
|
36
|
-
|
|
37
21
|
const createQueueJobType = () => {
|
|
38
22
|
return "ps.queue.job";
|
|
39
23
|
};
|
|
40
|
-
|
|
41
24
|
const createQueueJob = async params => {
|
|
42
25
|
const {
|
|
43
26
|
queueJob
|
|
@@ -46,11 +29,15 @@ const createQueueJobStorageOperations = params => {
|
|
|
46
29
|
PK: createQueueJobPartitionKey(),
|
|
47
30
|
SK: createQueueJobSortKey(queueJob.id)
|
|
48
31
|
};
|
|
49
|
-
|
|
50
32
|
try {
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
await (0, _dbDynamodb.put)({
|
|
34
|
+
entity,
|
|
35
|
+
item: {
|
|
36
|
+
...queueJob,
|
|
37
|
+
...keys,
|
|
38
|
+
TYPE: createQueueJobType()
|
|
39
|
+
}
|
|
40
|
+
});
|
|
54
41
|
return queueJob;
|
|
55
42
|
} catch (ex) {
|
|
56
43
|
throw new _error.default(ex.message || "Could not create render record.", ex.code || "CREATE_RENDER_ERROR", {
|
|
@@ -58,10 +45,8 @@ const createQueueJobStorageOperations = params => {
|
|
|
58
45
|
queueJob
|
|
59
46
|
});
|
|
60
47
|
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const listQueueJobs = async _ => {
|
|
48
|
+
};
|
|
49
|
+
const listQueueJobs = async () => {
|
|
65
50
|
const queryAllParams = {
|
|
66
51
|
entity,
|
|
67
52
|
partitionKey: createQueueJobPartitionKey(),
|
|
@@ -69,10 +54,8 @@ const createQueueJobStorageOperations = params => {
|
|
|
69
54
|
gte: " "
|
|
70
55
|
}
|
|
71
56
|
};
|
|
72
|
-
|
|
73
57
|
try {
|
|
74
|
-
|
|
75
|
-
return (0, _cleanup.cleanupItems)(entity, results);
|
|
58
|
+
return await (0, _query.queryAllClean)(queryAllParams);
|
|
76
59
|
} catch (ex) {
|
|
77
60
|
throw new _error.default(ex.message || "Could not list queue jobs records.", ex.code || "LIST_QUEUE_JOBS_ERROR", {
|
|
78
61
|
partitionKey: queryAllParams.partitionKey,
|
|
@@ -80,23 +63,21 @@ const createQueueJobStorageOperations = params => {
|
|
|
80
63
|
});
|
|
81
64
|
}
|
|
82
65
|
};
|
|
83
|
-
|
|
84
66
|
const deleteQueueJobs = async params => {
|
|
85
67
|
const {
|
|
86
68
|
queueJobs
|
|
87
69
|
} = params;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
71
|
+
entity,
|
|
72
|
+
delete: queueJobs.map(job => {
|
|
73
|
+
return {
|
|
74
|
+
PK: createQueueJobPartitionKey(),
|
|
75
|
+
SK: createQueueJobSortKey(job.id)
|
|
76
|
+
};
|
|
77
|
+
})
|
|
93
78
|
});
|
|
94
|
-
|
|
95
79
|
try {
|
|
96
|
-
await (
|
|
97
|
-
table: entity.table,
|
|
98
|
-
items
|
|
99
|
-
});
|
|
80
|
+
await entityBatch.execute();
|
|
100
81
|
return queueJobs;
|
|
101
82
|
} catch (ex) {
|
|
102
83
|
throw new _error.default(ex.message || "Could not delete queue jobs records.", ex.code || "DELETE_QUEUE_JOBS_ERROR", {
|
|
@@ -104,12 +85,12 @@ const createQueueJobStorageOperations = params => {
|
|
|
104
85
|
});
|
|
105
86
|
}
|
|
106
87
|
};
|
|
107
|
-
|
|
108
88
|
return {
|
|
109
89
|
createQueueJob,
|
|
110
90
|
deleteQueueJobs,
|
|
111
91
|
listQueueJobs
|
|
112
92
|
};
|
|
113
93
|
};
|
|
94
|
+
exports.createQueueJobStorageOperations = createQueueJobStorageOperations;
|
|
114
95
|
|
|
115
|
-
|
|
96
|
+
//# sourceMappingURL=queueJob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","_query","createQueueJobStorageOperations","params","entity","createQueueJobPartitionKey","createQueueJobSortKey","id","createQueueJobType","createQueueJob","queueJob","keys","PK","SK","put","item","TYPE","ex","WebinyError","message","code","listQueueJobs","queryAllParams","partitionKey","options","gte","queryAllClean","deleteQueueJobs","queueJobs","entityBatch","createEntityWriteBatch","delete","map","job","execute","exports"],"sources":["queueJob.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n PrerenderingServiceQueueJobStorageOperations,\n PrerenderingServiceStorageOperationsCreateQueueJobParams,\n PrerenderingServiceStorageOperationsDeleteQueueJobsParams,\n QueueJob\n} from \"@webiny/api-prerendering-service/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { createEntityWriteBatch, put } from \"@webiny/db-dynamodb\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } from \"@webiny/db-dynamodb/utils/query\";\n\nexport interface CreateQueueJobStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createQueueJobStorageOperations = (\n params: CreateQueueJobStorageOperationsParams\n): PrerenderingServiceQueueJobStorageOperations => {\n const { entity } = params;\n\n const createQueueJobPartitionKey = (): string => {\n return \"PS#Q#JOB\";\n };\n const createQueueJobSortKey = (id: string): string => {\n return id;\n };\n\n const createQueueJobType = () => {\n return \"ps.queue.job\";\n };\n\n const createQueueJob = async (\n params: PrerenderingServiceStorageOperationsCreateQueueJobParams\n ): Promise<QueueJob> => {\n const { queueJob } = params;\n const keys = {\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(queueJob.id)\n };\n\n try {\n await put({\n entity,\n item: {\n ...queueJob,\n ...keys,\n TYPE: createQueueJobType()\n }\n });\n return queueJob;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create render record.\",\n ex.code || \"CREATE_RENDER_ERROR\",\n {\n keys,\n queueJob\n }\n );\n }\n };\n\n const listQueueJobs = async () => {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createQueueJobPartitionKey(),\n options: {\n gte: \" \"\n }\n };\n\n try {\n return await queryAllClean<QueueJob>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list queue jobs records.\",\n ex.code || \"LIST_QUEUE_JOBS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n };\n\n const deleteQueueJobs = async (\n params: PrerenderingServiceStorageOperationsDeleteQueueJobsParams\n ) => {\n const { queueJobs } = params;\n\n const entityBatch = createEntityWriteBatch({\n entity,\n delete: queueJobs.map(job => {\n return {\n PK: createQueueJobPartitionKey(),\n SK: createQueueJobSortKey(job.id)\n };\n })\n });\n\n try {\n await entityBatch.execute();\n return queueJobs;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete queue jobs records.\",\n ex.code || \"DELETE_QUEUE_JOBS_ERROR\",\n {\n queueJobs\n }\n );\n }\n };\n\n return {\n createQueueJob,\n deleteQueueJobs,\n listQueueJobs\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAMO,MAAMG,+BAA+B,GACxCC,MAA6C,IACE;EAC/C,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EAEzB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,CAACC,YAAY;QACzCC,OAAO,EAAEF,cAAc,CAACE;MAC5B,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMG,eAAe,GAAG,MACpBxB,MAAiE,IAChE;IACD,MAAM;MAAEyB;IAAU,CAAC,GAAGzB,MAAM;IAE5B,MAAM0B,WAAW,GAAG,IAAAC,kCAAsB,EAAC;MACvC1B,MAAM;MACN2B,MAAM,EAAEH,SAAS,CAACI,GAAG,CAACC,GAAG,IAAI;QACzB,OAAO;UACHrB,EAAE,EAAEP,0BAA0B,CAAC,CAAC;UAChCQ,EAAE,EAAEP,qBAAqB,CAAC2B,GAAG,CAAC1B,EAAE;QACpC,CAAC;MACL,CAAC;IACL,CAAC,CAAC;IAEF,IAAI;MACA,MAAMsB,WAAW,CAACK,OAAO,CAAC,CAAC;MAC3B,OAAON,SAAS;IACpB,CAAC,CAAC,OAAOX,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,sCAAsC,EACpDF,EAAE,CAACG,IAAI,IAAI,yBAAyB,EACpC;QACIQ;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHnB,cAAc;IACdkB,eAAe;IACfN;EACJ,CAAC;AACL,CAAC;AAACc,OAAA,CAAAjC,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PrerenderingServiceRenderStorageOperations, Tag } from "@webiny/api-prerendering-service/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
export interface CreateRenderStorageOperationsParams {
|
|
4
|
+
entity: Entity;
|
|
5
|
+
tagPathLinkEntity: Entity;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateTagPathLinkPartitionKeyParams {
|
|
8
|
+
tenant: string;
|
|
9
|
+
tag: Tag;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateTagPathLinkGSI1PartitionKeyParams {
|
|
13
|
+
tenant: string;
|
|
14
|
+
tag: Tag;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateTagPathLinkSortKeyParams {
|
|
17
|
+
tag: Tag;
|
|
18
|
+
path?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const createRenderStorageOperations: (params: CreateRenderStorageOperationsParams) => PrerenderingServiceRenderStorageOperations;
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createRenderStorageOperations = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
10
|
+
const createRenderStorageOperations = params => {
|
|
11
|
+
const {
|
|
12
|
+
entity,
|
|
13
|
+
tagPathLinkEntity
|
|
14
|
+
} = params;
|
|
15
|
+
const createRenderPartitionKey = (tenant, path) => {
|
|
16
|
+
/**
|
|
17
|
+
* For backwards compatibility remove the T# if it exists.
|
|
18
|
+
*/
|
|
19
|
+
if (tenant.startsWith("T#")) {
|
|
20
|
+
tenant = tenant.replace(/^T#/, "");
|
|
21
|
+
}
|
|
22
|
+
return `T#${tenant}#PS#RENDER#${path}`;
|
|
23
|
+
};
|
|
24
|
+
const createRenderSortKey = () => {
|
|
25
|
+
return "A";
|
|
26
|
+
};
|
|
27
|
+
const createRenderGSI1PartitionKey = tenant => {
|
|
28
|
+
return `T#${tenant}#PS#RENDER`;
|
|
29
|
+
};
|
|
30
|
+
const createRenderType = () => {
|
|
31
|
+
return "ps.render";
|
|
32
|
+
};
|
|
33
|
+
const createTagPathLinkPartitionKey = params => {
|
|
34
|
+
const {
|
|
35
|
+
tag,
|
|
36
|
+
path
|
|
37
|
+
} = params;
|
|
38
|
+
let {
|
|
39
|
+
tenant
|
|
40
|
+
} = params;
|
|
41
|
+
if (tenant.startsWith("T#")) {
|
|
42
|
+
tenant = tenant.replace(/^T#/, "");
|
|
43
|
+
}
|
|
44
|
+
return `T#${tenant}#PS#TAG#${tag.key}#${tag.value}#${path}`;
|
|
45
|
+
};
|
|
46
|
+
const createTagPathLinkSortKey = params => {
|
|
47
|
+
const {
|
|
48
|
+
tag,
|
|
49
|
+
path
|
|
50
|
+
} = params;
|
|
51
|
+
const values = [tag.value];
|
|
52
|
+
if (path) {
|
|
53
|
+
values.push(path);
|
|
54
|
+
}
|
|
55
|
+
return values.join("#");
|
|
56
|
+
};
|
|
57
|
+
const createTagPathLinkGSI1PartitionKey = params => {
|
|
58
|
+
let {
|
|
59
|
+
tenant
|
|
60
|
+
} = params;
|
|
61
|
+
if (tenant.startsWith("T#")) {
|
|
62
|
+
tenant = tenant.replace(/^T#/, "");
|
|
63
|
+
}
|
|
64
|
+
return `T#${tenant}#PS#TAG`;
|
|
65
|
+
};
|
|
66
|
+
const createTagPathLinkGSI1SortKey = params => {
|
|
67
|
+
const {
|
|
68
|
+
tag,
|
|
69
|
+
path
|
|
70
|
+
} = params;
|
|
71
|
+
return `${tag.key}#${tag.value}#${path}`;
|
|
72
|
+
};
|
|
73
|
+
const createTagPathLinkType = () => {
|
|
74
|
+
return "ps.tagPathLink";
|
|
75
|
+
};
|
|
76
|
+
const getRender = async params => {
|
|
77
|
+
const {
|
|
78
|
+
where
|
|
79
|
+
} = params;
|
|
80
|
+
const keys = {
|
|
81
|
+
PK: createRenderPartitionKey(where.tenant, where.path),
|
|
82
|
+
SK: createRenderSortKey()
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
const result = await (0, _dbDynamodb.get)({
|
|
86
|
+
entity,
|
|
87
|
+
keys
|
|
88
|
+
});
|
|
89
|
+
const dbItem = (0, _dbDynamodb.cleanupItem)(entity, result);
|
|
90
|
+
return dbItem ? dbItem.data : null;
|
|
91
|
+
} catch (ex) {
|
|
92
|
+
throw new _error.default(ex.message || "Could not get render record by given key.", ex.code || "GET_RENDER_ERROR", {
|
|
93
|
+
keys,
|
|
94
|
+
params
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const createRender = async params => {
|
|
99
|
+
const {
|
|
100
|
+
render
|
|
101
|
+
} = params;
|
|
102
|
+
const keys = {
|
|
103
|
+
PK: createRenderPartitionKey(render.tenant, render.path),
|
|
104
|
+
SK: createRenderSortKey()
|
|
105
|
+
};
|
|
106
|
+
try {
|
|
107
|
+
await (0, _dbDynamodb.put)({
|
|
108
|
+
entity,
|
|
109
|
+
item: {
|
|
110
|
+
...keys,
|
|
111
|
+
data: render,
|
|
112
|
+
TYPE: createRenderType(),
|
|
113
|
+
GSI1_PK: createRenderGSI1PartitionKey(render.tenant),
|
|
114
|
+
GSI1_SK: render.path
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return render;
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
throw new _error.default(ex.message || "Could not create render record.", ex.code || "CREATE_RENDER_ERROR", {
|
|
120
|
+
keys,
|
|
121
|
+
render
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const deleteRender = async params => {
|
|
126
|
+
const {
|
|
127
|
+
render
|
|
128
|
+
} = params;
|
|
129
|
+
const keys = {
|
|
130
|
+
PK: createRenderPartitionKey(render.tenant, render.path),
|
|
131
|
+
SK: createRenderSortKey()
|
|
132
|
+
};
|
|
133
|
+
try {
|
|
134
|
+
await (0, _dbDynamodb.deleteItem)({
|
|
135
|
+
entity,
|
|
136
|
+
keys
|
|
137
|
+
});
|
|
138
|
+
} catch (ex) {
|
|
139
|
+
throw new _error.default(ex.message || "Could not delete render record.", ex.code || "DELETE_RENDER_ERROR", {
|
|
140
|
+
keys,
|
|
141
|
+
render
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const listRendersByTag = async params => {
|
|
146
|
+
const {
|
|
147
|
+
where
|
|
148
|
+
} = params;
|
|
149
|
+
const {
|
|
150
|
+
tenant,
|
|
151
|
+
tag
|
|
152
|
+
} = where;
|
|
153
|
+
/**
|
|
154
|
+
* Possibly there is no tag.key so no need to go further
|
|
155
|
+
*/
|
|
156
|
+
if (!tag || !tag.key) {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const links = await listTagPathLinks({
|
|
160
|
+
where: {
|
|
161
|
+
tenant,
|
|
162
|
+
tag
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const items = links.map(link => {
|
|
166
|
+
return entity.getBatch({
|
|
167
|
+
PK: createRenderPartitionKey(tenant, link.path),
|
|
168
|
+
SK: createRenderSortKey()
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
try {
|
|
172
|
+
const results = await (0, _dbDynamodb.batchReadAll)({
|
|
173
|
+
table: entity.table,
|
|
174
|
+
items
|
|
175
|
+
});
|
|
176
|
+
return (0, _dbDynamodb.cleanupItems)(entity, results).map(item => item.data);
|
|
177
|
+
} catch (ex) {
|
|
178
|
+
throw new _error.default(ex.message || "Could not list render records after links.", ex.code || "LIST_LINKS_RENDER_ERROR", {
|
|
179
|
+
links
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const listRenders = async params => {
|
|
184
|
+
const {
|
|
185
|
+
where
|
|
186
|
+
} = params;
|
|
187
|
+
const {
|
|
188
|
+
tenant,
|
|
189
|
+
tag
|
|
190
|
+
} = where;
|
|
191
|
+
if (tag) {
|
|
192
|
+
return listRendersByTag(params);
|
|
193
|
+
}
|
|
194
|
+
const queryAllParams = {
|
|
195
|
+
entity,
|
|
196
|
+
partitionKey: createRenderGSI1PartitionKey(tenant),
|
|
197
|
+
options: {
|
|
198
|
+
index: "GSI1",
|
|
199
|
+
gte: " "
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
const results = await (0, _dbDynamodb.queryAllClean)(queryAllParams);
|
|
204
|
+
return results.map(item => item.data);
|
|
205
|
+
} catch (ex) {
|
|
206
|
+
throw new _error.default(ex.message || "Could not list render records.", ex.code || "LIST_RENDER_ERROR", {
|
|
207
|
+
partitionKey: queryAllParams.partitionKey,
|
|
208
|
+
options: queryAllParams.options
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const createTagPathLinks = async params => {
|
|
213
|
+
const {
|
|
214
|
+
tagPathLinks
|
|
215
|
+
} = params;
|
|
216
|
+
const tagPathLinksBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
217
|
+
entity: tagPathLinkEntity,
|
|
218
|
+
put: tagPathLinks.map(item => {
|
|
219
|
+
return {
|
|
220
|
+
data: item,
|
|
221
|
+
TYPE: createTagPathLinkType(),
|
|
222
|
+
PK: createTagPathLinkPartitionKey({
|
|
223
|
+
tenant: item.tenant,
|
|
224
|
+
tag: item,
|
|
225
|
+
path: item.path
|
|
226
|
+
}),
|
|
227
|
+
SK: createTagPathLinkSortKey({
|
|
228
|
+
tag: item,
|
|
229
|
+
path: item.path
|
|
230
|
+
}),
|
|
231
|
+
GSI1_PK: createTagPathLinkGSI1PartitionKey({
|
|
232
|
+
tag: item,
|
|
233
|
+
tenant: item.tenant
|
|
234
|
+
}),
|
|
235
|
+
GSI1_SK: createTagPathLinkGSI1SortKey({
|
|
236
|
+
tag: item,
|
|
237
|
+
path: item.path
|
|
238
|
+
})
|
|
239
|
+
};
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
try {
|
|
243
|
+
await tagPathLinksBatch.execute();
|
|
244
|
+
return tagPathLinks;
|
|
245
|
+
} catch (ex) {
|
|
246
|
+
throw new _error.default(ex.message || "Could not create tagPathLink records.", ex.code || "CREATE_URL_TAG_LINKS_ERROR", {
|
|
247
|
+
tagPathLinks
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const deleteTagPathLinks = async params => {
|
|
252
|
+
const {
|
|
253
|
+
tenant,
|
|
254
|
+
tags,
|
|
255
|
+
path
|
|
256
|
+
} = params;
|
|
257
|
+
const tagPathLinksBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
258
|
+
entity: tagPathLinkEntity,
|
|
259
|
+
delete: tags.map(tag => {
|
|
260
|
+
return {
|
|
261
|
+
PK: createTagPathLinkPartitionKey({
|
|
262
|
+
tag,
|
|
263
|
+
tenant,
|
|
264
|
+
path
|
|
265
|
+
}),
|
|
266
|
+
SK: createTagPathLinkSortKey({
|
|
267
|
+
tag,
|
|
268
|
+
path
|
|
269
|
+
})
|
|
270
|
+
};
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
try {
|
|
274
|
+
await tagPathLinksBatch.execute();
|
|
275
|
+
} catch (ex) {
|
|
276
|
+
throw new _error.default(ex.message || "Could not delete tagPathLink records.", ex.code || "DELETE_URL_TAG_LINKS_ERROR", {
|
|
277
|
+
tags,
|
|
278
|
+
tenant,
|
|
279
|
+
path
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const listTagPathLinks = async params => {
|
|
284
|
+
const {
|
|
285
|
+
where
|
|
286
|
+
} = params;
|
|
287
|
+
const {
|
|
288
|
+
tenant,
|
|
289
|
+
tag
|
|
290
|
+
} = where;
|
|
291
|
+
const partitionKey = createTagPathLinkGSI1PartitionKey({
|
|
292
|
+
tenant,
|
|
293
|
+
tag
|
|
294
|
+
});
|
|
295
|
+
const options = {
|
|
296
|
+
index: "GSI1"
|
|
297
|
+
};
|
|
298
|
+
if (tag.value) {
|
|
299
|
+
options.beginsWith = `${tag.key}#${tag.value}#`;
|
|
300
|
+
} else {
|
|
301
|
+
options.beginsWith = `${tag.key}#`;
|
|
302
|
+
}
|
|
303
|
+
const queryAllParams = {
|
|
304
|
+
entity: tagPathLinkEntity,
|
|
305
|
+
partitionKey,
|
|
306
|
+
options
|
|
307
|
+
};
|
|
308
|
+
try {
|
|
309
|
+
const results = await (0, _dbDynamodb.queryAll)(queryAllParams);
|
|
310
|
+
return (0, _dbDynamodb.cleanupItems)(tagPathLinkEntity, results).map(item => item.data);
|
|
311
|
+
} catch (ex) {
|
|
312
|
+
throw new _error.default(ex.message || "Could not list tagPathLink records.", ex.code || "LIST_TAG_PATH_LINK_ERROR", {
|
|
313
|
+
partitionKey,
|
|
314
|
+
options
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
createRender,
|
|
320
|
+
deleteRender,
|
|
321
|
+
listRenders,
|
|
322
|
+
getRender,
|
|
323
|
+
createTagPathLinks,
|
|
324
|
+
deleteTagPathLinks,
|
|
325
|
+
listTagPathLinks
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
exports.createRenderStorageOperations = createRenderStorageOperations;
|
|
329
|
+
|
|
330
|
+
//# sourceMappingURL=render.js.map
|