@webiny/api-headless-cms-ddb 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -20
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +10 -93
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +10 -64
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +10 -108
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +7 -26
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +8 -12
- package/dynamoDb/index.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +87 -128
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +42 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +14 -30
- package/operations/entry/dataLoaders.js +84 -272
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +899 -807
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +54 -49
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +117 -158
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +103 -134
- package/operations/model/index.js.map +1 -1
- package/package.json +32 -33
- package/plugins/index.d.ts +2 -4
- package/plugins/index.js +1 -49
- package/types.d.ts +25 -41
- package/types.js +8 -14
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -41
- package/definitions/system.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -91
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -95
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -45
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -176
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -14
- package/operations/entry/filtering/createFields.js +0 -105
- package/operations/entry/filtering/createFields.js.map +0 -1
- package/operations/entry/filtering/extractSort.d.ts +0 -17
- package/operations/entry/filtering/extractSort.js +0 -67
- package/operations/entry/filtering/extractSort.js.map +0 -1
- package/operations/entry/filtering/filter.d.ts +0 -15
- package/operations/entry/filtering/filter.js +0 -143
- package/operations/entry/filtering/filter.js.map +0 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
- package/operations/entry/filtering/fullTextSearch.js +0 -48
- package/operations/entry/filtering/fullTextSearch.js.map +0 -1
- package/operations/entry/filtering/getValue.d.ts +0 -5
- package/operations/entry/filtering/getValue.js +0 -63
- package/operations/entry/filtering/getValue.js.map +0 -1
- package/operations/entry/filtering/index.d.ts +0 -2
- package/operations/entry/filtering/index.js +0 -19
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/mapPlugins.d.ts +0 -8
- package/operations/entry/filtering/mapPlugins.js +0 -31
- package/operations/entry/filtering/mapPlugins.js.map +0 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/filtering/plugins/index.js +0 -13
- package/operations/entry/filtering/plugins/index.js.map +0 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -69
- package/operations/entry/filtering/sort.js.map +0 -1
- package/operations/entry/filtering/systemFields.d.ts +0 -4
- package/operations/entry/filtering/systemFields.js +0 -70
- package/operations/entry/filtering/systemFields.js.map +0 -1
- package/operations/entry/filtering/transform.d.ts +0 -6
- package/operations/entry/filtering/transform.js +0 -16
- package/operations/entry/filtering/transform.js.map +0 -1
- package/operations/entry/filtering/types.d.ts +0 -40
- package/operations/entry/filtering/types.js +0 -5
- package/operations/entry/filtering/types.js.map +0 -1
- package/operations/entry/filtering/values.d.ts +0 -2
- package/operations/entry/filtering/values.js +0 -22
- package/operations/entry/filtering/values.js.map +0 -1
- package/operations/entry/filtering/where.d.ts +0 -5
- package/operations/entry/filtering/where.js +0 -32
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -72
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -82
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.js.map +0 -1
package/index.js
CHANGED
|
@@ -1,132 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import dynamoDb from "./dynamoDb/index.js";
|
|
2
|
+
import { ENTITIES } from "./types.js";
|
|
3
|
+
import { createGroupEntity } from "./definitions/group.js";
|
|
4
|
+
import { createModelEntity } from "./definitions/model.js";
|
|
5
|
+
import { createEntryEntity } from "./definitions/entry.js";
|
|
6
|
+
import { createGroupsStorageOperations } from "./operations/group/index.js";
|
|
7
|
+
import { createModelsStorageOperations } from "./operations/model/index.js";
|
|
8
|
+
import { createEntriesStorageOperations } from "./operations/entry/index.js";
|
|
9
|
+
import { createFilterCreatePlugins } from "@webiny/api-headless-cms-storage";
|
|
10
|
+
import { createTable } from "./definitions/table.js";
|
|
11
|
+
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
12
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
13
|
+
import { StorageOperationsFactory } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
14
|
+
import { DynamoDBClient } from "@webiny/db-dynamodb";
|
|
15
|
+
export * from "./plugins/index.js";
|
|
16
|
+
const createDynamoDbStorageOperations = (params)=>{
|
|
17
|
+
const { table, plugins, container } = params;
|
|
18
|
+
const db = container.resolve(DynamoDBClient);
|
|
19
|
+
const documentClient = db.client;
|
|
20
|
+
const tableInstance = createTable({
|
|
21
|
+
name: table,
|
|
22
|
+
documentClient
|
|
23
|
+
});
|
|
24
|
+
const entities = {
|
|
25
|
+
groups: createGroupEntity({
|
|
26
|
+
entityName: ENTITIES.GROUPS,
|
|
27
|
+
table: tableInstance
|
|
28
|
+
}),
|
|
29
|
+
models: createModelEntity({
|
|
30
|
+
entityName: ENTITIES.MODELS,
|
|
31
|
+
table: tableInstance
|
|
32
|
+
}),
|
|
33
|
+
entries: createEntryEntity({
|
|
34
|
+
entityName: ENTITIES.ENTRIES,
|
|
35
|
+
table: tableInstance
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
plugins.register([
|
|
39
|
+
dynamoDb(),
|
|
40
|
+
createFilterCreatePlugins()
|
|
41
|
+
]);
|
|
42
|
+
const entries = createEntriesStorageOperations({
|
|
43
|
+
entity: entities.entries,
|
|
44
|
+
container,
|
|
45
|
+
plugins
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
name: "dynamodb",
|
|
49
|
+
beforeInit: async ()=>{
|
|
50
|
+
entries.dataLoaders.clearAll();
|
|
51
|
+
},
|
|
52
|
+
getEntities: ()=>entities,
|
|
53
|
+
getTable: ()=>tableInstance,
|
|
54
|
+
groups: createGroupsStorageOperations({
|
|
55
|
+
entity: entities.groups,
|
|
56
|
+
container
|
|
57
|
+
}),
|
|
58
|
+
models: createModelsStorageOperations({
|
|
59
|
+
entity: entities.models
|
|
60
|
+
}),
|
|
61
|
+
entries
|
|
62
|
+
};
|
|
9
63
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _system = require("./definitions/system");
|
|
17
|
-
var _group = require("./definitions/group");
|
|
18
|
-
var _model = require("./definitions/model");
|
|
19
|
-
var _entry = require("./definitions/entry");
|
|
20
|
-
var _plugins = require("@webiny/plugins");
|
|
21
|
-
var _system2 = require("./operations/system");
|
|
22
|
-
var _settings2 = require("./operations/settings");
|
|
23
|
-
var _group2 = require("./operations/group");
|
|
24
|
-
var _model2 = require("./operations/model");
|
|
25
|
-
var _entry2 = require("./operations/entry");
|
|
26
|
-
var _plugins2 = require("./operations/entry/filtering/plugins");
|
|
27
|
-
var _plugins3 = require("./plugins");
|
|
28
|
-
Object.keys(_plugins3).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _plugins3[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _plugins3[key];
|
|
64
|
+
class DynamoDbStorageOperationsFactoryImpl {
|
|
65
|
+
async create(context) {
|
|
66
|
+
return createDynamoDbStorageOperations({
|
|
67
|
+
plugins: context.plugins,
|
|
68
|
+
container: context.container
|
|
69
|
+
});
|
|
36
70
|
}
|
|
37
|
-
|
|
71
|
+
}
|
|
72
|
+
const DynamoDbStorageOperationsFactory = StorageOperationsFactory.createImplementation({
|
|
73
|
+
implementation: DynamoDbStorageOperationsFactoryImpl,
|
|
74
|
+
dependencies: []
|
|
38
75
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
const entities = {
|
|
53
|
-
settings: (0, _settings.createSettingsEntity)({
|
|
54
|
-
entityName: _types.ENTITIES.SETTINGS,
|
|
55
|
-
table: tableInstance,
|
|
56
|
-
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
57
|
-
}),
|
|
58
|
-
system: (0, _system.createSystemEntity)({
|
|
59
|
-
entityName: _types.ENTITIES.SYSTEM,
|
|
60
|
-
table: tableInstance,
|
|
61
|
-
attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
|
|
62
|
-
}),
|
|
63
|
-
groups: (0, _group.createGroupEntity)({
|
|
64
|
-
entityName: _types.ENTITIES.GROUPS,
|
|
65
|
-
table: tableInstance,
|
|
66
|
-
attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
|
|
67
|
-
}),
|
|
68
|
-
models: (0, _model.createModelEntity)({
|
|
69
|
-
entityName: _types.ENTITIES.MODELS,
|
|
70
|
-
table: tableInstance,
|
|
71
|
-
attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
|
|
72
|
-
}),
|
|
73
|
-
entries: (0, _entry.createEntryEntity)({
|
|
74
|
-
entityName: _types.ENTITIES.ENTRIES,
|
|
75
|
-
table: tableInstance,
|
|
76
|
-
attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
|
|
77
|
-
})
|
|
78
|
-
};
|
|
79
|
-
const plugins = new _plugins.PluginsContainer([
|
|
80
|
-
/**
|
|
81
|
-
* DynamoDB filter plugins for the where conditions.
|
|
82
|
-
*/
|
|
83
|
-
(0, _filters.default)(),
|
|
84
|
-
/**
|
|
85
|
-
* Field plugins for DynamoDB.
|
|
86
|
-
*/
|
|
87
|
-
(0, _dynamoDb.default)(),
|
|
88
|
-
/**
|
|
89
|
-
* Filter create plugins.
|
|
90
|
-
*/
|
|
91
|
-
(0, _plugins2.createFilterCreatePlugins)(),
|
|
92
|
-
/**
|
|
93
|
-
* User defined custom plugins.
|
|
94
|
-
*/
|
|
95
|
-
...(userPlugins || [])]);
|
|
96
|
-
return {
|
|
97
|
-
name: "dynamodb",
|
|
98
|
-
beforeInit: async context => {
|
|
99
|
-
const types = ["cms-model-field-to-graphql", _plugins3.CmsEntryFieldFilterPathPlugin.type, _plugins3.CmsFieldFilterValueTransformPlugin.type, _plugins3.CmsEntryFieldFilterPlugin.type, _plugins3.CmsEntryFieldSortingPlugin.type, _ValueFilterPlugin.ValueFilterPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type];
|
|
100
|
-
/**
|
|
101
|
-
* Collect all required plugins from parent context.
|
|
102
|
-
*/
|
|
103
|
-
for (const type of types) {
|
|
104
|
-
plugins.mergeByType(context.plugins, type);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Pass the plugins to the parent context.
|
|
108
|
-
*/
|
|
109
|
-
context.plugins.register([(0, _dynamoDb.default)()]);
|
|
110
|
-
},
|
|
111
|
-
getEntities: () => entities,
|
|
112
|
-
getTable: () => tableInstance,
|
|
113
|
-
system: (0, _system2.createSystemStorageOperations)({
|
|
114
|
-
entity: entities.system
|
|
115
|
-
}),
|
|
116
|
-
settings: (0, _settings2.createSettingsStorageOperations)({
|
|
117
|
-
entity: entities.settings
|
|
118
|
-
}),
|
|
119
|
-
groups: (0, _group2.createGroupsStorageOperations)({
|
|
120
|
-
entity: entities.groups,
|
|
121
|
-
plugins
|
|
122
|
-
}),
|
|
123
|
-
models: (0, _model2.createModelsStorageOperations)({
|
|
124
|
-
entity: entities.models
|
|
125
|
-
}),
|
|
126
|
-
entries: (0, _entry2.createEntriesStorageOperations)({
|
|
127
|
-
entity: entities.entries,
|
|
128
|
-
plugins
|
|
129
|
-
})
|
|
130
|
-
};
|
|
76
|
+
const storageOperationsFeature = createFeature({
|
|
77
|
+
name: "cms.storageOperations.openSearch",
|
|
78
|
+
register: (container)=>{
|
|
79
|
+
container.register(DynamoDbStorageOperationsFactory).inSingletonScope();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const registerDynamoDbStorageOperations = ()=>{
|
|
83
|
+
const plugin = createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container));
|
|
84
|
+
plugin.name = "cms.registerDynamoDbStorageOperations";
|
|
85
|
+
return [
|
|
86
|
+
plugin
|
|
87
|
+
];
|
|
131
88
|
};
|
|
132
|
-
|
|
89
|
+
export { registerDynamoDbStorageOperations };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport type { CmsContext, StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createModelsStorageOperations } from \"~/operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport { createFilterCreatePlugins } from \"@webiny/api-headless-cms-storage\";\nimport { createTable } from \"~/definitions/table.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport { DynamoDBClient } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nconst createDynamoDbStorageOperations: StorageOperationsFactory = params => {\n const { table, plugins, container } = params;\n\n const db = container.resolve(DynamoDBClient);\n const documentClient = db.client;\n\n const tableInstance = createTable({\n name: table,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n })\n };\n\n plugins.register([\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins()\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n container,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async () => {\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n container\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n\nclass DynamoDbStorageOperationsFactoryImpl\n implements StorageOperationsFactoryAbstraction.Interface\n{\n public async create(context: CmsContext) {\n return createDynamoDbStorageOperations({\n plugins: context.plugins,\n container: context.container\n });\n }\n}\n\nconst DynamoDbStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation({\n implementation: DynamoDbStorageOperationsFactoryImpl,\n dependencies: []\n});\n\nconst storageOperationsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n container.register(DynamoDbStorageOperationsFactory).inSingletonScope();\n }\n});\n\nexport const registerDynamoDbStorageOperations = () => {\n const plugin = createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n });\n plugin.name = \"cms.registerDynamoDbStorageOperations\";\n\n return [plugin];\n};\n"],"names":["createDynamoDbStorageOperations","params","table","plugins","container","db","DynamoDBClient","documentClient","tableInstance","createTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","dynamoDbPlugins","createFilterCreatePlugins","entries","createEntriesStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","DynamoDbStorageOperationsFactoryImpl","context","DynamoDbStorageOperationsFactory","StorageOperationsFactoryAbstraction","storageOperationsFeature","createFeature","registerDynamoDbStorageOperations","plugin","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAMA,kCAA4DC,CAAAA;IAC9D,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGH;IAEtC,MAAMI,KAAKD,UAAU,OAAO,CAACE;IAC7B,MAAMC,iBAAiBF,GAAG,MAAM;IAEhC,MAAMG,gBAAgBC,YAAY;QAC9B,MAAMP;QACNK;IACJ;IAEA,MAAMG,WAAW;QACb,QAAQC,kBAAkB;YACtB,YAAYC,SAAS,MAAM;YAC3B,OAAOJ;QACX;QACA,QAAQK,kBAAkB;YACtB,YAAYD,SAAS,MAAM;YAC3B,OAAOJ;QACX;QACA,SAASM,kBAAkB;YACvB,YAAYF,SAAS,OAAO;YAC5B,OAAOJ;QACX;IACJ;IAEAL,QAAQ,QAAQ,CAAC;QAIbY;QAIAC;KACH;IAED,MAAMC,UAAUC,+BAA+B;QAC3C,QAAQR,SAAS,OAAO;QACxBN;QACAD;IACJ;IAEA,OAAO;QACH,MAAM;QACN,YAAY;YACRc,QAAQ,WAAW,CAAC,QAAQ;QAChC;QACA,aAAa,IAAMP;QACnB,UAAU,IAAMF;QAChB,QAAQW,8BAA8B;YAClC,QAAQT,SAAS,MAAM;YACvBN;QACJ;QACA,QAAQgB,8BAA8B;YAClC,QAAQV,SAAS,MAAM;QAC3B;QACAO;IACJ;AACJ;AAEA,MAAMI;IAGF,MAAa,OAAOC,OAAmB,EAAE;QACrC,OAAOtB,gCAAgC;YACnC,SAASsB,QAAQ,OAAO;YACxB,WAAWA,QAAQ,SAAS;QAChC;IACJ;AACJ;AAEA,MAAMC,mCAAmCC,yBAAAA,oBAAwD,CAAC;IAC9F,gBAAgBH;IAChB,cAAc,EAAE;AACpB;AAEA,MAAMI,2BAA2BC,cAAc;IAC3C,MAAM;IACN,UAAUtB,CAAAA;QACNA,UAAU,QAAQ,CAACmB,kCAAkC,gBAAgB;IACzE;AACJ;AAEO,MAAMI,oCAAoC;IAC7C,MAAMC,SAASC,8BAA8BP,CAAAA,UAClCG,yBAAyB,QAAQ,CAACH,QAAQ,SAAS;IAE9DM,OAAO,IAAI,GAAG;IAEd,OAAO;QAACA;KAAO;AACnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type DataLoader from "dataloader";
|
|
2
|
+
export interface CacheKeyParams {
|
|
3
|
+
name: string;
|
|
4
|
+
tenant: string;
|
|
5
|
+
modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ClearAllParams {
|
|
8
|
+
tenant: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class DataLoaderCache {
|
|
11
|
+
private readonly cache;
|
|
12
|
+
getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
|
|
13
|
+
setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
|
|
14
|
+
clearAll(params?: ClearAllParams): void;
|
|
15
|
+
private createKey;
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class DataLoaderCache {
|
|
2
|
+
getDataLoader(params) {
|
|
3
|
+
const key = this.createKey(params);
|
|
4
|
+
return this.cache[key] || null;
|
|
5
|
+
}
|
|
6
|
+
setDataLoader(params, dataLoader) {
|
|
7
|
+
const key = this.createKey(params);
|
|
8
|
+
this.cache[key] = dataLoader;
|
|
9
|
+
}
|
|
10
|
+
clearAll(params) {
|
|
11
|
+
if (!params) {
|
|
12
|
+
for(const current in this.cache)this.cache[current].clearAll();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const key = `${params.tenant}_`;
|
|
16
|
+
for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
|
|
17
|
+
}
|
|
18
|
+
createKey(params) {
|
|
19
|
+
return `${params.tenant}_${params.modelId}_${params.name}`;
|
|
20
|
+
}
|
|
21
|
+
constructor(){
|
|
22
|
+
this.cache = {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export { DataLoaderCache };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=DataLoaderCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
|
|
2
|
+
const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
|
|
3
|
+
export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
|
|
3
|
+
* Intended to be used internally or for a specific user case.
|
|
4
|
+
* Not to be documented and exposed to publish as it can slow the data loading a lot.
|
|
5
|
+
*
|
|
6
|
+
* https://github.com/graphql/dataloader#batch-scheduling
|
|
7
|
+
*/
|
|
8
|
+
export declare const createBatchScheduleFn: () => ((callback: () => void) => void) | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
|
|
2
|
+
const createBatchScheduleFn = ()=>{
|
|
3
|
+
if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) return;
|
|
4
|
+
return (callback)=>{
|
|
5
|
+
setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export { createBatchScheduleFn };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=createBatchScheduleFn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/createBatchScheduleFn.js","sources":["../../../../src/operations/entry/dataLoader/createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants.js\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"names":["createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","callback","setTimeout"],"mappings":";AASO,MAAMA,wBAAwB;IACjC,IAAIC,iCAAiC,GACjC;IAEJ,OAAO,CAACC;QACJC,WAAWD,UAAUD;IACzB;AACJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetAllEntryRevisions: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
|
+
import { createPartitionKey } from "../keys.js";
|
|
3
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
|
+
const createGetAllEntryRevisions = (params)=>{
|
|
5
|
+
const { entity, tenant, modelId } = params;
|
|
6
|
+
return new dataloader(async (ids)=>{
|
|
7
|
+
const results = {};
|
|
8
|
+
for (const id of ids)results[id] = (await entity.queryAllClean({
|
|
9
|
+
partitionKey: createPartitionKey({
|
|
10
|
+
tenant,
|
|
11
|
+
id
|
|
12
|
+
}),
|
|
13
|
+
options: {
|
|
14
|
+
beginsWith: "REV#"
|
|
15
|
+
}
|
|
16
|
+
})).map((result)=>result.data);
|
|
17
|
+
return ids.map((id)=>(results[id] || []).filter((item)=>item.modelId === modelId));
|
|
18
|
+
}, {
|
|
19
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export { createGetAllEntryRevisions };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=getAllEntryRevisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getAllEntryRevisions.js","sources":["../../../../src/operations/entry/dataLoader/getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(result => {\n return result.data;\n });\n }\n\n return ids.map(id => {\n return (results[id] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetAllEntryRevisions","params","entity","tenant","modelId","DataLoader","ids","results","id","createPartitionKey","result","item","createBatchScheduleFn"],"mappings":";;;AAMO,MAAMA,6BAA6B,CAACC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IACpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,UAA6C,CAAC;QAEpD,KAAK,MAAMC,MAAMF,IACbC,OAAO,CAACC,GAAG,GACP,OAAMN,OAAO,aAAa,CAAC;YACvB,cAAcO,mBAAmB;gBAC7BN;gBACAK;YACJ;YACA,SAAS;gBACL,YAAY;YAChB;QACJ,EAAC,EACH,GAAG,CAACE,CAAAA,SACKA,OAAO,IAAI;QAI1B,OAAOJ,IAAI,GAAG,CAACE,CAAAA,KACHD,AAAAA,CAAAA,OAAO,CAACC,GAAG,IAAI,EAAC,EAAG,MAAM,CAACG,CAAAA,OACvBA,KAAK,OAAO,KAAKP;IAGpC,GACA;QACI,iBAAiBQ;IACrB;AAER"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetLatestRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
|
+
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
|
+
import { createLatestSortKey, createPartitionKey } from "../keys.js";
|
|
5
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
6
|
+
const createGetLatestRevisionByEntryId = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
const latestKey = createLatestSortKey();
|
|
9
|
+
return new dataloader(async (ids)=>{
|
|
10
|
+
const reader = entity.createEntityReader();
|
|
11
|
+
const keys = new Set();
|
|
12
|
+
for (const id of ids){
|
|
13
|
+
const partitionKey = createPartitionKey({
|
|
14
|
+
tenant,
|
|
15
|
+
id
|
|
16
|
+
});
|
|
17
|
+
if (!keys.has(partitionKey)) {
|
|
18
|
+
keys.add(partitionKey);
|
|
19
|
+
reader.get({
|
|
20
|
+
PK: partitionKey,
|
|
21
|
+
SK: latestKey
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const records = await reader.execute();
|
|
26
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
27
|
+
return ids.map((id)=>{
|
|
28
|
+
const { id: entryId } = parseIdentifier(id);
|
|
29
|
+
return items.filter((item)=>{
|
|
30
|
+
if (item.modelId !== modelId) return false;
|
|
31
|
+
return entryId === item.entryId;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export { createGetLatestRevisionByEntryId };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=getLatestRevisionByEntryId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getLatestRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","createLatestSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","records","items","cleanupItems","item","entryId","parseIdentifier","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,mCAAmC,CAACC;IAC7C,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,YAAYC;IAElB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBAETJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,UAAU,MAAMN,OAAO,OAAO;QACpC,MAAMO,QAAQC,aAAaf,OAAO,MAAM,EAAEa,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOV,IAAI,GAAG,CAACI,CAAAA;YACX,MAAM,EAAE,IAAIO,OAAO,EAAE,GAAGC,gBAAgBR;YACxC,OAAOI,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKd,SACjB,OAAO;gBAEX,OAAOe,YAAYD,KAAK,OAAO;YACnC;QACJ;IACJ,GACA;QACI,iBAAiBG;IACrB;AAER"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetPublishedRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
|
+
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
|
+
import { createPartitionKey, createPublishedSortKey } from "../keys.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
+
const createGetPublishedRevisionByEntryId = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
const publishedKey = createPublishedSortKey();
|
|
9
|
+
return new dataloader(async (ids)=>{
|
|
10
|
+
const reader = entity.createEntityReader();
|
|
11
|
+
const keys = new Set();
|
|
12
|
+
for (const id of ids){
|
|
13
|
+
const partitionKey = createPartitionKey({
|
|
14
|
+
tenant,
|
|
15
|
+
id
|
|
16
|
+
});
|
|
17
|
+
if (!keys.has(partitionKey)) {
|
|
18
|
+
keys.add(partitionKey);
|
|
19
|
+
reader.get({
|
|
20
|
+
PK: partitionKey,
|
|
21
|
+
SK: publishedKey
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const records = await reader.execute();
|
|
26
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
27
|
+
return ids.map((id)=>{
|
|
28
|
+
const { id: entryId } = parseIdentifier(id);
|
|
29
|
+
return items.filter((item)=>{
|
|
30
|
+
if (item.modelId !== modelId) return false;
|
|
31
|
+
return entryId === item.entryId;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export { createGetPublishedRevisionByEntryId };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=getPublishedRevisionByEntryId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getPublishedRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetPublishedRevisionByEntryId","params","entity","tenant","modelId","publishedKey","createPublishedSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","records","items","cleanupItems","item","entryId","parseIdentifier","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,sCAAsC,CAACC;IAChD,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,eAAeC;IACrB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBACTJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,UAAU,MAAMN,OAAO,OAAO;QACpC,MAAMO,QAAQC,aAAaf,OAAO,MAAM,EAAEa,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOV,IAAI,GAAG,CAACI,CAAAA;YACX,MAAM,EAAE,IAAIO,OAAO,EAAE,GAAGC,gBAAgBR;YACxC,OAAOI,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKd,SACjB,OAAO;gBAEX,OAAOe,YAAYD,KAAK,OAAO;YACnC;QACJ;IACJ,GACA;QACI,iBAAiBG;IACrB;AAER"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetRevisionById: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
|
+
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
|
+
import { createPartitionKey, createRevisionSortKey } from "../keys.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
+
const createGetRevisionById = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
return new dataloader(async (ids)=>{
|
|
9
|
+
const reader = entity.createEntityReader();
|
|
10
|
+
const keys = new Set();
|
|
11
|
+
for (const id of ids){
|
|
12
|
+
const partitionKey = createPartitionKey({
|
|
13
|
+
tenant,
|
|
14
|
+
id
|
|
15
|
+
});
|
|
16
|
+
const { version } = parseIdentifier(id);
|
|
17
|
+
if (null === version) continue;
|
|
18
|
+
const sortKey = createRevisionSortKey({
|
|
19
|
+
version
|
|
20
|
+
});
|
|
21
|
+
const key = `${partitionKey}__${sortKey}`;
|
|
22
|
+
if (!keys.has(key)) {
|
|
23
|
+
keys.add(key);
|
|
24
|
+
reader.get({
|
|
25
|
+
PK: partitionKey,
|
|
26
|
+
SK: sortKey
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const records = await reader.execute();
|
|
31
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
32
|
+
return ids.map((id)=>items.filter((item)=>{
|
|
33
|
+
if (item.modelId !== modelId) return false;
|
|
34
|
+
return id === item.id;
|
|
35
|
+
}));
|
|
36
|
+
}, {
|
|
37
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export { createGetRevisionById };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=getRevisionById.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getRevisionById.js","sources":["../../../../src/operations/entry/dataLoader/getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetRevisionById","params","entity","tenant","modelId","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","key","records","items","cleanupItems","item","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,SAASL,OAAO,kBAAkB;QAExC,MAAMM,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCT;gBACAO;YACJ;YACA,MAAM,EAAEG,OAAO,EAAE,GAAGC,gBAAgBJ;YACpC,IAAIG,AAAY,SAAZA,SACA;YAEJ,MAAME,UAAUC,sBAAsB;gBAClCH;YACJ;YACA,MAAMI,MAAM,GAAGN,aAAa,EAAE,EAAEI,SAAS;YACzC,KAAIP,KAAK,GAAG,CAACS;gBAGbT,KAAK,GAAG,CAACS;gBAETV,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAII;gBACR;;QACJ;QAEA,MAAMG,UAAU,MAAMX,OAAO,OAAO;QACpC,MAAMY,QAAQC,aAAalB,OAAO,MAAM,EAAEgB,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOf,IAAI,GAAG,CAACI,CAAAA,KACJS,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKjB,SACjB,OAAO;gBAEX,OAAOM,OAAOW,KAAK,EAAE;YACzB;IAER,GACA;QACI,iBAAiBC;IACrB;AAER"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type DataLoader from "dataloader";
|
|
2
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
3
|
+
export * from "./DataLoaderCache.js";
|
|
4
|
+
interface Callable {
|
|
5
|
+
(params: IDataLoaderParams): DataLoader<any, any>;
|
|
6
|
+
}
|
|
7
|
+
export type DataLoaders = "getAllEntryRevisions" | "getRevisionById" | "getPublishedRevisionByEntryId" | "getLatestRevisionByEntryId";
|
|
8
|
+
export declare const getDataLoaderFactory: (name: string) => Callable;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createGetAllEntryRevisions } from "./getAllEntryRevisions.js";
|
|
2
|
+
import { createGetLatestRevisionByEntryId } from "./getLatestRevisionByEntryId.js";
|
|
3
|
+
import { createGetPublishedRevisionByEntryId } from "./getPublishedRevisionByEntryId.js";
|
|
4
|
+
import { createGetRevisionById } from "./getRevisionById.js";
|
|
5
|
+
export * from "./DataLoaderCache.js";
|
|
6
|
+
const dataLoaders = {
|
|
7
|
+
getAllEntryRevisions: createGetAllEntryRevisions,
|
|
8
|
+
getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,
|
|
9
|
+
getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,
|
|
10
|
+
getRevisionById: createGetRevisionById
|
|
11
|
+
};
|
|
12
|
+
const getDataLoaderFactory = (name)=>{
|
|
13
|
+
if (!dataLoaders[name]) throw new Error(`Missing data loader "${name}".`);
|
|
14
|
+
return dataLoaders[name];
|
|
15
|
+
};
|
|
16
|
+
export { getDataLoaderFactory };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/index.js","sources":["../../../../src/operations/entry/dataLoader/index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions.js\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId.js\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId.js\";\nimport { createGetRevisionById } from \"./getRevisionById.js\";\n\nexport * from \"./DataLoaderCache.js\";\n\ninterface Callable {\n (params: IDataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"names":["dataLoaders","createGetAllEntryRevisions","createGetLatestRevisionByEntryId","createGetPublishedRevisionByEntryId","createGetRevisionById","getDataLoaderFactory","name","Error"],"mappings":";;;;;AAaA,MAAMA,cAAwC;IAC1C,sBAAsBC;IACtB,4BAA4BC;IAC5B,+BAA+BC;IAC/B,iBAAiBC;AACrB;AAQO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACN,WAAW,CAACM,KAAK,EAClB,MAAM,IAAIC,MAAM,CAAC,qBAAqB,EAAED,KAAK,EAAE,CAAC;IAEpD,OAAON,WAAW,CAACM,KAAK;AAC5B"}
|
|
File without changes
|