@webiny/api-headless-cms-ddb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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 +9 -94
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +9 -68
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +9 -90
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +8 -30
- 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 +11 -20
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +21 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +13 -37
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +27 -50
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +83 -139
- 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 +83 -314
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +27 -0
- package/operations/entry/filtering/createExpressions.js +124 -0
- package/operations/entry/filtering/createExpressions.js.map +1 -0
- package/operations/entry/filtering/createFields.d.ts +16 -0
- package/operations/entry/filtering/createFields.js +93 -0
- package/operations/entry/filtering/createFields.js.map +1 -0
- package/operations/entry/filtering/extractSort.d.ts +17 -0
- package/operations/entry/filtering/extractSort.js +60 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +16 -0
- package/operations/entry/filtering/filter.js +85 -0
- package/operations/entry/filtering/filter.js.map +1 -0
- package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
- package/operations/entry/filtering/fullTextSearch.js +25 -0
- package/operations/entry/filtering/fullTextSearch.js.map +1 -0
- package/operations/entry/filtering/getValue.d.ts +5 -0
- package/operations/entry/filtering/getValue.js +37 -0
- package/operations/entry/filtering/getValue.js.map +1 -0
- package/operations/entry/filtering/index.d.ts +2 -0
- package/operations/entry/filtering/index.js +2 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +18 -0
- package/operations/entry/filtering/mapPlugins.js.map +1 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +33 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/filtering/plugins/index.js +13 -0
- package/operations/entry/filtering/plugins/index.js.map +1 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js +68 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +63 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +49 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +41 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +2 -0
- package/operations/entry/filtering/systemFields.js +149 -0
- package/operations/entry/filtering/systemFields.js.map +1 -0
- package/operations/entry/filtering/transform.d.ts +6 -0
- package/operations/entry/filtering/transform.js +7 -0
- package/operations/entry/filtering/transform.js.map +1 -0
- package/operations/entry/filtering/types.d.ts +40 -0
- package/operations/entry/filtering/types.js +0 -0
- package/operations/entry/filtering/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +15 -0
- package/operations/entry/filtering/values.js.map +1 -0
- package/operations/entry/filtering/where.d.ts +5 -0
- package/operations/entry/filtering/where.js +22 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +931 -845
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +53 -66
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +116 -187
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +102 -158
- package/operations/model/index.js.map +1 -1
- package/package.json +34 -33
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +5 -4
- package/plugins/CmsEntryFieldFilterPathPlugin.js +25 -50
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +20 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +20 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +19 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -1
- package/plugins/index.js +4 -18
- package/types.d.ts +28 -21
- package/types.js +8 -15
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -58
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -46
- package/definitions/system.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -2
- package/dynamoDb/storage/date.js +0 -99
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -101
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -113
- package/dynamoDb/storage/richText.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -74
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/entry/utils.d.ts +0 -36
- package/operations/entry/utils.js +0 -680
- package/operations/entry/utils.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -135
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -99
- package/operations/system/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.createPlainObjectPathPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* File is @internal
|
|
16
|
-
*/
|
|
17
|
-
const createPath = ({
|
|
18
|
-
field
|
|
19
|
-
}) => {
|
|
20
|
-
const {
|
|
21
|
-
path
|
|
22
|
-
} = field.settings || {};
|
|
23
|
-
|
|
24
|
-
if (!path) {
|
|
25
|
-
throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
26
|
-
field
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
3
|
+
const createPath = ({ field })=>{
|
|
4
|
+
const { path } = field.settings || {};
|
|
5
|
+
if (!path) throw new error("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
6
|
+
field
|
|
27
7
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return path;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const createPlainObjectPathPlugin = () => {
|
|
34
|
-
return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
|
|
35
|
-
fieldType: "plainObject",
|
|
36
|
-
path: createPath
|
|
37
|
-
});
|
|
8
|
+
return path;
|
|
38
9
|
};
|
|
10
|
+
const createPlainObjectPathPlugin = ()=>new CmsEntryFieldFilterPathPlugin({
|
|
11
|
+
fieldType: "plainObject",
|
|
12
|
+
path: createPath
|
|
13
|
+
});
|
|
14
|
+
export { createPlainObjectPathPlugin };
|
|
39
15
|
|
|
40
|
-
|
|
16
|
+
//# sourceMappingURL=plainObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dynamoDb/path/plainObject.js","sources":["../../../src/dynamoDb/path/plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"names":["createPath","field","path","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin"],"mappings":";;AAOA,MAAMA,aAAiC,CAAC,EAAEC,KAAK,EAAE;IAC7C,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAM,QAAQ,IAAI,CAAC;IACpC,IAAI,CAACC,MACD,MAAM,IAAIC,MAAY,gCAAgC,wBAAwB;QAC1EF;IACJ;IAEJ,OAAOC;AACX;AAEO,MAAME,8BAA8B,IAChC,IAAIC,8BAA8B;QACrC,WAAW;QACX,MAAML;IACV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* File is @internal
|
|
3
3
|
*/
|
|
4
|
-
import { CmsFieldFilterValueTransformPlugin } from "../../types";
|
|
4
|
+
import type { CmsFieldFilterValueTransformPlugin } from "../../types.js";
|
|
5
5
|
export declare const createDatetimeTransformValuePlugin: () => CmsFieldFilterValueTransformPlugin;
|
|
@@ -1,52 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
|
|
9
|
-
|
|
10
|
-
var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* File is @internal
|
|
14
|
-
*/
|
|
15
|
-
const timeTransformer = new _TimeTransformPlugin.TimeTransformPlugin({
|
|
16
|
-
fields: ["*"]
|
|
1
|
+
import { TimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js";
|
|
2
|
+
import { DateTimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js";
|
|
3
|
+
const timeTransformer = new TimeTransformPlugin({
|
|
4
|
+
fields: [
|
|
5
|
+
"*"
|
|
6
|
+
]
|
|
17
7
|
});
|
|
18
|
-
const dateTimeTransformer = new
|
|
19
|
-
|
|
8
|
+
const dateTimeTransformer = new DateTimeTransformPlugin({
|
|
9
|
+
fields: [
|
|
10
|
+
"*"
|
|
11
|
+
]
|
|
20
12
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (type === "time") {
|
|
40
|
-
return timeTransformer.transform({
|
|
41
|
-
value
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return dateTimeTransformer.transform({
|
|
46
|
-
value
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
exports.createDatetimeTransformValuePlugin = createDatetimeTransformValuePlugin;
|
|
13
|
+
const createDatetimeTransformValuePlugin = ()=>({
|
|
14
|
+
type: "cms-field-filter-value-transform",
|
|
15
|
+
name: "cms-field-value-filter-transform-datetime",
|
|
16
|
+
fieldType: "datetime",
|
|
17
|
+
transform: ({ field, value })=>{
|
|
18
|
+
const { type } = field.settings || {};
|
|
19
|
+
if ("time" === type) return timeTransformer.transform({
|
|
20
|
+
value
|
|
21
|
+
});
|
|
22
|
+
return dateTimeTransformer.transform({
|
|
23
|
+
value
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export { createDatetimeTransformValuePlugin };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dynamoDb/transformValue/datetime.js","sources":["../../../src/dynamoDb/transformValue/datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"names":["timeTransformer","TimeTransformPlugin","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","field","value","type"],"mappings":";;AAOA,MAAMA,kBAAkB,IAAIC,oBAAoB;IAC5C,QAAQ;QAAC;KAAI;AACjB;AACA,MAAMC,sBAAsB,IAAIC,wBAAwB;IACpD,QAAQ;QAAC;KAAI;AACjB;AAEO,MAAMC,qCAAqC,IACvC;QACH,MAAM;QACN,MAAM;QACN,WAAW;QAIX,WAAW,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE;YACxB,MAAM,EAAEC,IAAI,EAAE,GAAGF,MAAM,QAAQ,IAAI,CAAC;YACpC,IAAIE,AAAS,WAATA,MACA,OAAOP,gBAAgB,SAAS,CAAC;gBAC7BM;YACJ;YAEJ,OAAOJ,oBAAoB,SAAS,CAAC;gBACjCI;YACJ;QACJ;IACJ"}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare const createStorageOperations: StorageOperationsFactory;
|
|
1
|
+
export * from "./plugins/index.js";
|
|
2
|
+
export declare const registerDynamoDbStorageOperations: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>[];
|
package/index.js
CHANGED
|
@@ -1,143 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { registerExtension } from "@webiny/db-dynamodb";
|
|
2
|
+
import dynamoDb from "./dynamoDb/index.js";
|
|
3
|
+
import { ENTITIES } from "./types.js";
|
|
4
|
+
import { createGroupEntity } from "./definitions/group.js";
|
|
5
|
+
import { createModelEntity } from "./definitions/model.js";
|
|
6
|
+
import { createEntryEntity } from "./definitions/entry.js";
|
|
7
|
+
import { createGroupsStorageOperations } from "./operations/group/index.js";
|
|
8
|
+
import { createModelsStorageOperations } from "./operations/model/index.js";
|
|
9
|
+
import { createEntriesStorageOperations } from "./operations/entry/index.js";
|
|
10
|
+
import { createFilterCreatePlugins } from "./operations/entry/filtering/plugins/index.js";
|
|
11
|
+
import { createTable } from "./definitions/table.js";
|
|
12
|
+
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
13
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
14
|
+
import { StorageOperationsFactory } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
15
|
+
export * from "./plugins/index.js";
|
|
16
|
+
const createDynamoDbStorageOperations = (params)=>{
|
|
17
|
+
const { table, documentClient, plugins, container } = params;
|
|
18
|
+
const tableInstance = createTable({
|
|
19
|
+
name: table,
|
|
20
|
+
documentClient
|
|
21
|
+
});
|
|
22
|
+
const entities = {
|
|
23
|
+
groups: createGroupEntity({
|
|
24
|
+
entityName: ENTITIES.GROUPS,
|
|
25
|
+
table: tableInstance
|
|
26
|
+
}),
|
|
27
|
+
models: createModelEntity({
|
|
28
|
+
entityName: ENTITIES.MODELS,
|
|
29
|
+
table: tableInstance
|
|
30
|
+
}),
|
|
31
|
+
entries: createEntryEntity({
|
|
32
|
+
entityName: ENTITIES.ENTRIES,
|
|
33
|
+
table: tableInstance
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
plugins.register([
|
|
37
|
+
dynamoDb(),
|
|
38
|
+
createFilterCreatePlugins()
|
|
39
|
+
]);
|
|
40
|
+
const entries = createEntriesStorageOperations({
|
|
41
|
+
entity: entities.entries,
|
|
42
|
+
container,
|
|
43
|
+
plugins
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
name: "dynamodb",
|
|
47
|
+
beforeInit: async ()=>{
|
|
48
|
+
entries.dataLoaders.clearAll();
|
|
49
|
+
},
|
|
50
|
+
getEntities: ()=>entities,
|
|
51
|
+
getTable: ()=>tableInstance,
|
|
52
|
+
groups: createGroupsStorageOperations({
|
|
53
|
+
entity: entities.groups,
|
|
54
|
+
container
|
|
55
|
+
}),
|
|
56
|
+
models: createModelsStorageOperations({
|
|
57
|
+
entity: entities.models
|
|
58
|
+
}),
|
|
59
|
+
entries
|
|
60
|
+
};
|
|
10
61
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _table = require("./definitions/table");
|
|
20
|
-
|
|
21
|
-
var _settings = require("./definitions/settings");
|
|
22
|
-
|
|
23
|
-
var _system = require("./definitions/system");
|
|
24
|
-
|
|
25
|
-
var _group = require("./definitions/group");
|
|
26
|
-
|
|
27
|
-
var _model = require("./definitions/model");
|
|
28
|
-
|
|
29
|
-
var _entry = require("./definitions/entry");
|
|
30
|
-
|
|
31
|
-
var _plugins = require("@webiny/plugins");
|
|
32
|
-
|
|
33
|
-
var _system2 = require("./operations/system");
|
|
34
|
-
|
|
35
|
-
var _settings2 = require("./operations/settings");
|
|
36
|
-
|
|
37
|
-
var _group2 = require("./operations/group");
|
|
38
|
-
|
|
39
|
-
var _model2 = require("./operations/model");
|
|
40
|
-
|
|
41
|
-
var _entry2 = require("./operations/entry");
|
|
42
|
-
|
|
43
|
-
var _plugins2 = require("./plugins");
|
|
44
|
-
|
|
45
|
-
Object.keys(_plugins2).forEach(function (key) {
|
|
46
|
-
if (key === "default" || key === "__esModule") return;
|
|
47
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
48
|
-
if (key in exports && exports[key] === _plugins2[key]) return;
|
|
49
|
-
Object.defineProperty(exports, key, {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return _plugins2[key];
|
|
62
|
+
class DynamoDbStorageOperationsFactoryImpl {
|
|
63
|
+
async create(context) {
|
|
64
|
+
return createDynamoDbStorageOperations({
|
|
65
|
+
documentClient: context.db.driver.getClient(),
|
|
66
|
+
plugins: context.plugins,
|
|
67
|
+
container: context.container
|
|
68
|
+
});
|
|
53
69
|
}
|
|
54
|
-
|
|
70
|
+
}
|
|
71
|
+
const DynamoDbStorageOperationsFactory = StorageOperationsFactory.createImplementation({
|
|
72
|
+
implementation: DynamoDbStorageOperationsFactoryImpl,
|
|
73
|
+
dependencies: []
|
|
55
74
|
});
|
|
75
|
+
const storageOperationsFeature = createFeature({
|
|
76
|
+
name: "cms.storageOperations.openSearch",
|
|
77
|
+
register: (container)=>{
|
|
78
|
+
container.register(DynamoDbStorageOperationsFactory).inSingletonScope();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const registerDynamoDbStorageOperations = ()=>[
|
|
82
|
+
registerExtension(),
|
|
83
|
+
createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container))
|
|
84
|
+
];
|
|
85
|
+
export { registerDynamoDbStorageOperations };
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
attributes,
|
|
60
|
-
table,
|
|
61
|
-
documentClient,
|
|
62
|
-
plugins: userPlugins
|
|
63
|
-
} = params;
|
|
64
|
-
const tableInstance = (0, _table.createTable)({
|
|
65
|
-
table,
|
|
66
|
-
documentClient
|
|
67
|
-
});
|
|
68
|
-
const entities = {
|
|
69
|
-
settings: (0, _settings.createSettingsEntity)({
|
|
70
|
-
entityName: _types.ENTITIES.SETTINGS,
|
|
71
|
-
table: tableInstance,
|
|
72
|
-
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
73
|
-
}),
|
|
74
|
-
system: (0, _system.createSystemEntity)({
|
|
75
|
-
entityName: _types.ENTITIES.SYSTEM,
|
|
76
|
-
table: tableInstance,
|
|
77
|
-
attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
|
|
78
|
-
}),
|
|
79
|
-
groups: (0, _group.createGroupEntity)({
|
|
80
|
-
entityName: _types.ENTITIES.GROUPS,
|
|
81
|
-
table: tableInstance,
|
|
82
|
-
attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
|
|
83
|
-
}),
|
|
84
|
-
models: (0, _model.createModelEntity)({
|
|
85
|
-
entityName: _types.ENTITIES.MODELS,
|
|
86
|
-
table: tableInstance,
|
|
87
|
-
attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
|
|
88
|
-
}),
|
|
89
|
-
entries: (0, _entry.createEntryEntity)({
|
|
90
|
-
entityName: _types.ENTITIES.ENTRIES,
|
|
91
|
-
table: tableInstance,
|
|
92
|
-
attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
|
|
93
|
-
})
|
|
94
|
-
};
|
|
95
|
-
const plugins = new _plugins.PluginsContainer([
|
|
96
|
-
/**
|
|
97
|
-
* DynamoDB filter plugins for the where conditions.
|
|
98
|
-
*/
|
|
99
|
-
(0, _filters.default)(),
|
|
100
|
-
/**
|
|
101
|
-
* Field plugins for DynamoDB.
|
|
102
|
-
*/
|
|
103
|
-
(0, _dynamoDb.default)(),
|
|
104
|
-
/**
|
|
105
|
-
* User defined custom plugins.
|
|
106
|
-
*/
|
|
107
|
-
...(userPlugins || [])]);
|
|
108
|
-
return {
|
|
109
|
-
beforeInit: async context => {
|
|
110
|
-
/**
|
|
111
|
-
* Collect all required plugins from parent context.
|
|
112
|
-
*/
|
|
113
|
-
const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
|
|
114
|
-
plugins.register(fieldPlugins);
|
|
115
|
-
/**
|
|
116
|
-
* Pass the plugins to the parent context.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
context.plugins.register([(0, _dynamoDb.default)()]);
|
|
120
|
-
},
|
|
121
|
-
getEntities: () => entities,
|
|
122
|
-
getTable: () => tableInstance,
|
|
123
|
-
system: (0, _system2.createSystemStorageOperations)({
|
|
124
|
-
entity: entities.system
|
|
125
|
-
}),
|
|
126
|
-
settings: (0, _settings2.createSettingsStorageOperations)({
|
|
127
|
-
entity: entities.settings
|
|
128
|
-
}),
|
|
129
|
-
groups: (0, _group2.createGroupsStorageOperations)({
|
|
130
|
-
entity: entities.groups,
|
|
131
|
-
plugins
|
|
132
|
-
}),
|
|
133
|
-
models: (0, _model2.createModelsStorageOperations)({
|
|
134
|
-
entity: entities.models
|
|
135
|
-
}),
|
|
136
|
-
entries: (0, _entry2.createEntriesStorageOperations)({
|
|
137
|
-
entity: entities.entries,
|
|
138
|
-
plugins
|
|
139
|
-
})
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
exports.createStorageOperations = createStorageOperations;
|
|
87
|
+
//# 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 { registerExtension as registerDynamoDbExtension } from \"@webiny/db-dynamodb\";\nimport 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 \"~/operations/entry/filtering/plugins/index.js\";\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 type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport * from \"./plugins/index.js\";\n\nconst createDynamoDbStorageOperations: StorageOperationsFactory = params => {\n const { table, documentClient, plugins, container } = params;\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 documentClient: context.db.driver.getClient() as DynamoDBDocument,\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 return [\n registerDynamoDbExtension(),\n createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n })\n ];\n};\n"],"names":["createDynamoDbStorageOperations","params","table","documentClient","plugins","container","tableInstance","createTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","dynamoDbPlugins","createFilterCreatePlugins","entries","createEntriesStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","DynamoDbStorageOperationsFactoryImpl","context","DynamoDbStorageOperationsFactory","StorageOperationsFactoryAbstraction","storageOperationsFeature","createFeature","registerDynamoDbStorageOperations","registerDynamoDbExtension","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,kCAA4DC,CAAAA;IAC9D,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;IAEtD,MAAMK,gBAAgBC,YAAY;QAC9B,MAAML;QACNC;IACJ;IAEA,MAAMK,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;IAEAF,QAAQ,QAAQ,CAAC;QAIbS;QAIAC;KACH;IAED,MAAMC,UAAUC,+BAA+B;QAC3C,QAAQR,SAAS,OAAO;QACxBH;QACAD;IACJ;IAEA,OAAO;QACH,MAAM;QACN,YAAY;YACRW,QAAQ,WAAW,CAAC,QAAQ;QAChC;QACA,aAAa,IAAMP;QACnB,UAAU,IAAMF;QAChB,QAAQW,8BAA8B;YAClC,QAAQT,SAAS,MAAM;YACvBH;QACJ;QACA,QAAQa,8BAA8B;YAClC,QAAQV,SAAS,MAAM;QAC3B;QACAO;IACJ;AACJ;AAEA,MAAMI;IAGF,MAAa,OAAOC,OAAmB,EAAE;QACrC,OAAOpB,gCAAgC;YACnC,gBAAgBoB,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS;YAC3C,SAASA,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,UAAUnB,CAAAA;QACNA,UAAU,QAAQ,CAACgB,kCAAkC,gBAAgB;IACzE;AACJ;AAEO,MAAMI,oCAAoC,IACtC;QACHC;QACAC,8BAA8BP,CAAAA,UACnBG,yBAAyB,QAAQ,CAACH,QAAQ,SAAS;KAEjE"}
|
|
@@ -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"}
|