@webiny/api-headless-cms-ddb 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.d.ts +4 -3
- package/definitions/entry.js +108 -16
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -3
- package/definitions/group.js +8 -12
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -3
- package/definitions/model.js +30 -12
- package/definitions/model.js.map +1 -1
- package/definitions/system.d.ts +4 -3
- package/definitions/system.js +8 -12
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +5 -5
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -9
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +43 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.js +3 -8
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +10 -17
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -1
- package/dynamoDb/storage/richText.js +23 -75
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +3 -8
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +25 -41
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -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 +10 -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 +25 -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 +45 -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 +56 -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 +56 -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 +62 -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 +40 -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 +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +12 -27
- package/operations/entry/dataLoaders.js +55 -260
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +178 -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 +108 -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 +69 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +15 -0
- package/operations/entry/filtering/filter.js +158 -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 +50 -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 +66 -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 +21 -0
- package/operations/entry/filtering/index.js.map +1 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +33 -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 +45 -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 +16 -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 +90 -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 +80 -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 +65 -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 +71 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +4 -0
- package/operations/entry/filtering/systemFields.js +90 -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 +18 -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 +7 -0
- package/operations/entry/filtering/types.js.map +1 -0
- package/operations/entry/filtering/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +24 -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 +35 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +3 -3
- package/operations/entry/index.js +733 -284
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +2 -18
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +3 -3
- package/operations/group/index.js +33 -51
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +25 -37
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +18 -23
- package/operations/system/index.js.map +1 -1
- package/package.json +21 -26
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +4 -3
- package/plugins/CmsEntryFieldFilterPathPlugin.js +11 -18
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +27 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +27 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +36 -3
- package/plugins/index.js.map +1 -1
- package/types.d.ts +21 -14
- package/types.js +5 -6
- 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/dynamoDb/storage/date.d.ts +0 -2
- package/dynamoDb/storage/date.js +0 -99
- package/dynamoDb/storage/date.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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getDataLoaderFactory: true
|
|
8
|
+
};
|
|
9
|
+
exports.getDataLoaderFactory = void 0;
|
|
10
|
+
var _getAllEntryRevisions = require("./getAllEntryRevisions");
|
|
11
|
+
var _getLatestRevisionByEntryId = require("./getLatestRevisionByEntryId");
|
|
12
|
+
var _getPublishedRevisionByEntryId = require("./getPublishedRevisionByEntryId");
|
|
13
|
+
var _getRevisionById = require("./getRevisionById");
|
|
14
|
+
var _DataLoaderCache = require("./DataLoaderCache");
|
|
15
|
+
Object.keys(_DataLoaderCache).forEach(function (key) {
|
|
16
|
+
if (key === "default" || key === "__esModule") return;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
+
if (key in exports && exports[key] === _DataLoaderCache[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _DataLoaderCache[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
const dataLoaders = {
|
|
27
|
+
getAllEntryRevisions: _getAllEntryRevisions.createGetAllEntryRevisions,
|
|
28
|
+
getLatestRevisionByEntryId: _getLatestRevisionByEntryId.createGetLatestRevisionByEntryId,
|
|
29
|
+
getPublishedRevisionByEntryId: _getPublishedRevisionByEntryId.createGetPublishedRevisionByEntryId,
|
|
30
|
+
getRevisionById: _getRevisionById.createGetRevisionById
|
|
31
|
+
};
|
|
32
|
+
const getDataLoaderFactory = name => {
|
|
33
|
+
if (!dataLoaders[name]) {
|
|
34
|
+
throw new Error(`Missing data loader "${name}".`);
|
|
35
|
+
}
|
|
36
|
+
return dataLoaders[name];
|
|
37
|
+
};
|
|
38
|
+
exports.getDataLoaderFactory = getDataLoaderFactory;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_getAllEntryRevisions","require","_getLatestRevisionByEntryId","_getPublishedRevisionByEntryId","_getRevisionById","_DataLoaderCache","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","dataLoaders","getAllEntryRevisions","createGetAllEntryRevisions","getLatestRevisionByEntryId","createGetLatestRevisionByEntryId","getPublishedRevisionByEntryId","createGetPublishedRevisionByEntryId","getRevisionById","createGetRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId\";\nimport { createGetRevisionById } from \"./getRevisionById\";\n\nexport * from \"./DataLoaderCache\";\n\ninterface Callable {\n (params: DataLoaderParams): 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"],"mappings":";;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAMA,MAAMS,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEC,gDAA0B;EAChDC,0BAA0B,EAAEC,4DAAgC;EAC5DC,6BAA6B,EAAEC,kEAAmC;EAClEC,eAAe,EAAEC;AACrB,CAAC;AAQM,MAAMC,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACV,WAAW,CAACU,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,CAAC,wBAAwBD,IAAI,IAAI,CAAC;EACrD;EACA,OAAOV,WAAW,CAACU,IAAI,CAAC;AAC5B,CAAC;AAACd,OAAA,CAAAa,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\nexport interface DataLoaderParams {\n entity: Entity<any>;\n tenant: string;\n locale: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,42 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Entity } from "dynamodb
|
|
3
|
-
|
|
1
|
+
import type { CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
import type { DataLoadersHandlerInterface, DataLoadersHandlerInterfaceClearAllParams } from "../../types";
|
|
4
|
+
interface DataLoaderParams {
|
|
5
|
+
model: Pick<CmsModel, "tenant" | "locale" | "modelId">;
|
|
4
6
|
ids: readonly string[];
|
|
5
|
-
model: CmsModel;
|
|
6
|
-
}
|
|
7
|
-
export interface GetRevisionByIdParams {
|
|
8
|
-
ids: readonly string[];
|
|
9
|
-
model: CmsModel;
|
|
10
|
-
}
|
|
11
|
-
export interface GetPublishedRevisionByEntryIdParams {
|
|
12
|
-
ids: readonly string[];
|
|
13
|
-
model: CmsModel;
|
|
14
|
-
}
|
|
15
|
-
export interface GetLatestRevisionByEntryIdParams {
|
|
16
|
-
ids: readonly string[];
|
|
17
|
-
model: CmsModel;
|
|
18
|
-
}
|
|
19
|
-
interface ClearLoaderParams {
|
|
20
|
-
model: CmsModel;
|
|
21
|
-
entry?: CmsStorageEntry;
|
|
22
7
|
}
|
|
23
8
|
interface DataLoadersHandlerParams {
|
|
24
9
|
entity: Entity<any>;
|
|
25
10
|
}
|
|
26
|
-
export declare class DataLoadersHandler {
|
|
27
|
-
private readonly loaders;
|
|
11
|
+
export declare class DataLoadersHandler implements DataLoadersHandlerInterface {
|
|
28
12
|
private readonly entity;
|
|
13
|
+
private readonly cache;
|
|
29
14
|
constructor(params: DataLoadersHandlerParams);
|
|
30
|
-
getAllEntryRevisions(params:
|
|
31
|
-
getRevisionById(params:
|
|
32
|
-
getPublishedRevisionByEntryId(params:
|
|
33
|
-
getLatestRevisionByEntryId(params:
|
|
15
|
+
getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
16
|
+
getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
17
|
+
getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
18
|
+
getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
34
19
|
/**
|
|
35
20
|
* TODO @ts-refactor
|
|
36
21
|
* Maybe pass on the generics to DataLoader definition?
|
|
37
22
|
*/
|
|
38
23
|
private getLoader;
|
|
39
24
|
private loadMany;
|
|
40
|
-
clearAll(params
|
|
25
|
+
clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void;
|
|
41
26
|
}
|
|
42
27
|
export {};
|
|
@@ -1,321 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DataLoadersHandler = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
15
|
-
|
|
16
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _keys = require("./keys");
|
|
21
|
-
|
|
22
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
23
|
-
|
|
9
|
+
var _DataLoaderCache = require("./dataLoader/DataLoaderCache");
|
|
10
|
+
var _dataLoader = require("./dataLoader");
|
|
24
11
|
var _utils = require("@webiny/utils");
|
|
25
|
-
|
|
26
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
27
|
-
|
|
28
|
-
const getAllEntryRevisions = params => {
|
|
29
|
-
const {
|
|
30
|
-
entity,
|
|
31
|
-
model
|
|
32
|
-
} = params;
|
|
33
|
-
const {
|
|
34
|
-
tenant,
|
|
35
|
-
locale
|
|
36
|
-
} = model;
|
|
37
|
-
return new _dataloader.default(async ids => {
|
|
38
|
-
const results = {};
|
|
39
|
-
|
|
40
|
-
for (const id of ids) {
|
|
41
|
-
const queryAllParams = {
|
|
42
|
-
entity,
|
|
43
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
44
|
-
tenant,
|
|
45
|
-
locale,
|
|
46
|
-
id
|
|
47
|
-
}),
|
|
48
|
-
options: {
|
|
49
|
-
beginsWith: "REV#"
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
53
|
-
results[id] = (0, _cleanup.cleanupItems)(entity, items);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return ids.map(id => {
|
|
57
|
-
return results[id] || [];
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const getRevisionById = params => {
|
|
63
|
-
const {
|
|
64
|
-
entity,
|
|
65
|
-
model
|
|
66
|
-
} = params;
|
|
67
|
-
const {
|
|
68
|
-
locale,
|
|
69
|
-
tenant
|
|
70
|
-
} = model;
|
|
71
|
-
return new _dataloader.default(async ids => {
|
|
72
|
-
const queries = ids.reduce((collection, id) => {
|
|
73
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
74
|
-
tenant,
|
|
75
|
-
locale,
|
|
76
|
-
id
|
|
77
|
-
});
|
|
78
|
-
const {
|
|
79
|
-
version
|
|
80
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
81
|
-
|
|
82
|
-
if (version === null) {
|
|
83
|
-
return collection;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
87
|
-
version
|
|
88
|
-
});
|
|
89
|
-
const keys = `${partitionKey}__${sortKey}`;
|
|
90
|
-
|
|
91
|
-
if (collection[keys]) {
|
|
92
|
-
return collection;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
collection[keys] = entity.getBatch({
|
|
96
|
-
PK: partitionKey,
|
|
97
|
-
SK: sortKey
|
|
98
|
-
});
|
|
99
|
-
return collection;
|
|
100
|
-
/**
|
|
101
|
-
* We cast as any because there is no return type defined.
|
|
102
|
-
*/
|
|
103
|
-
}, {});
|
|
104
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
105
|
-
table: entity.table,
|
|
106
|
-
items: Object.values(queries)
|
|
107
|
-
});
|
|
108
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
109
|
-
return ids.map(id => {
|
|
110
|
-
return items.filter(item => {
|
|
111
|
-
return id === item.id;
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const getPublishedRevisionByEntryId = params => {
|
|
118
|
-
const {
|
|
119
|
-
entity,
|
|
120
|
-
model
|
|
121
|
-
} = params;
|
|
122
|
-
const {
|
|
123
|
-
locale,
|
|
124
|
-
tenant
|
|
125
|
-
} = model;
|
|
126
|
-
const publishedKey = (0, _keys.createPublishedSortKey)();
|
|
127
|
-
return new _dataloader.default(async ids => {
|
|
128
|
-
const queries = ids.reduce((collection, id) => {
|
|
129
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
130
|
-
tenant,
|
|
131
|
-
locale,
|
|
132
|
-
id
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (collection[partitionKey]) {
|
|
136
|
-
return collection;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
collection[partitionKey] = entity.getBatch({
|
|
140
|
-
PK: partitionKey,
|
|
141
|
-
SK: publishedKey
|
|
142
|
-
});
|
|
143
|
-
return collection;
|
|
144
|
-
/**
|
|
145
|
-
* We cast as any because there is no return type defined.
|
|
146
|
-
*/
|
|
147
|
-
}, {});
|
|
148
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
149
|
-
table: entity.table,
|
|
150
|
-
items: Object.values(queries)
|
|
151
|
-
});
|
|
152
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
153
|
-
return ids.map(id => {
|
|
154
|
-
const {
|
|
155
|
-
id: entryId
|
|
156
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
157
|
-
return items.filter(item => {
|
|
158
|
-
return entryId === item.entryId;
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const getLatestRevisionByEntryId = params => {
|
|
165
|
-
const {
|
|
166
|
-
entity,
|
|
167
|
-
model
|
|
168
|
-
} = params;
|
|
169
|
-
const {
|
|
170
|
-
locale,
|
|
171
|
-
tenant
|
|
172
|
-
} = model;
|
|
173
|
-
const latestKey = (0, _keys.createLatestSortKey)();
|
|
174
|
-
return new _dataloader.default(async ids => {
|
|
175
|
-
const queries = ids.reduce((collection, id) => {
|
|
176
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
177
|
-
tenant,
|
|
178
|
-
locale,
|
|
179
|
-
id
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
if (collection[partitionKey]) {
|
|
183
|
-
return collection;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
collection[partitionKey] = entity.getBatch({
|
|
187
|
-
PK: partitionKey,
|
|
188
|
-
SK: latestKey
|
|
189
|
-
});
|
|
190
|
-
return collection;
|
|
191
|
-
/**
|
|
192
|
-
* We cast as any because there is no return type defined.
|
|
193
|
-
*/
|
|
194
|
-
}, {});
|
|
195
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
196
|
-
table: entity.table,
|
|
197
|
-
items: Object.values(queries)
|
|
198
|
-
});
|
|
199
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
200
|
-
return ids.map(id => {
|
|
201
|
-
const {
|
|
202
|
-
id: entryId
|
|
203
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
204
|
-
return items.filter(item => {
|
|
205
|
-
return entryId === item.entryId;
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const dataLoaders = {
|
|
212
|
-
getAllEntryRevisions,
|
|
213
|
-
getRevisionById,
|
|
214
|
-
getPublishedRevisionByEntryId,
|
|
215
|
-
getLatestRevisionByEntryId
|
|
216
|
-
};
|
|
217
|
-
const loaderNames = Object.keys(dataLoaders);
|
|
218
|
-
|
|
219
12
|
class DataLoadersHandler {
|
|
13
|
+
cache = new _DataLoaderCache.DataLoaderCache();
|
|
220
14
|
constructor(params) {
|
|
221
|
-
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
222
|
-
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
223
15
|
this.entity = params.entity;
|
|
224
16
|
}
|
|
225
|
-
|
|
226
17
|
async getAllEntryRevisions(params) {
|
|
227
|
-
|
|
18
|
+
const ids = params.ids.map(id => {
|
|
19
|
+
const {
|
|
20
|
+
id: entryId
|
|
21
|
+
} = (0, _utils.parseIdentifier)(id);
|
|
22
|
+
return entryId;
|
|
23
|
+
});
|
|
24
|
+
return await this.loadMany("getAllEntryRevisions", params, ids);
|
|
228
25
|
}
|
|
229
|
-
|
|
230
26
|
async getRevisionById(params) {
|
|
231
27
|
return await this.loadMany("getRevisionById", params, params.ids);
|
|
232
28
|
}
|
|
233
|
-
|
|
234
29
|
async getPublishedRevisionByEntryId(params) {
|
|
235
|
-
|
|
30
|
+
const ids = params.ids.map(id => {
|
|
31
|
+
const {
|
|
32
|
+
id: entryId
|
|
33
|
+
} = (0, _utils.parseIdentifier)(id);
|
|
34
|
+
return entryId;
|
|
35
|
+
});
|
|
36
|
+
return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
|
|
236
37
|
}
|
|
237
|
-
|
|
238
38
|
async getLatestRevisionByEntryId(params) {
|
|
239
|
-
|
|
39
|
+
const ids = params.ids.map(id => {
|
|
40
|
+
const {
|
|
41
|
+
id: entryId
|
|
42
|
+
} = (0, _utils.parseIdentifier)(id);
|
|
43
|
+
return entryId;
|
|
44
|
+
});
|
|
45
|
+
return await this.loadMany("getLatestRevisionByEntryId", params, ids);
|
|
240
46
|
}
|
|
47
|
+
|
|
241
48
|
/**
|
|
242
49
|
* TODO @ts-refactor
|
|
243
50
|
* Maybe pass on the generics to DataLoader definition?
|
|
244
51
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
52
|
getLoader(name, params) {
|
|
248
|
-
if (!dataLoaders[name]) {
|
|
249
|
-
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
250
|
-
name
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
53
|
const {
|
|
255
54
|
model
|
|
256
55
|
} = params;
|
|
257
|
-
const {
|
|
258
|
-
tenant,
|
|
259
|
-
locale
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
entity: this.entity
|
|
266
|
-
})));
|
|
56
|
+
const cacheParams = {
|
|
57
|
+
tenant: model.tenant,
|
|
58
|
+
locale: model.locale,
|
|
59
|
+
name
|
|
60
|
+
};
|
|
61
|
+
let loader = this.cache.getDataLoader(cacheParams);
|
|
62
|
+
if (loader) {
|
|
63
|
+
return loader;
|
|
267
64
|
}
|
|
268
|
-
|
|
269
|
-
|
|
65
|
+
const factory = (0, _dataLoader.getDataLoaderFactory)(name);
|
|
66
|
+
loader = factory({
|
|
67
|
+
entity: this.entity,
|
|
68
|
+
tenant: model.tenant,
|
|
69
|
+
locale: model.locale
|
|
70
|
+
});
|
|
71
|
+
this.cache.setDataLoader(cacheParams, loader);
|
|
72
|
+
return loader;
|
|
270
73
|
}
|
|
271
|
-
|
|
272
74
|
async loadMany(loader, params, ids) {
|
|
273
|
-
let results;
|
|
274
|
-
|
|
75
|
+
let results = [];
|
|
275
76
|
try {
|
|
276
77
|
results = await this.getLoader(loader, params).loadMany(ids);
|
|
277
|
-
|
|
278
78
|
if (Array.isArray(results) === true) {
|
|
279
79
|
return results.reduce((acc, res) => {
|
|
280
80
|
if (Array.isArray(res) === false) {
|
|
281
81
|
if (res && res.message) {
|
|
282
|
-
throw new _error.default(res.message, res.code,
|
|
82
|
+
throw new _error.default(res.message, res.code, {
|
|
83
|
+
...res,
|
|
283
84
|
data: JSON.stringify(res.data || {})
|
|
284
|
-
})
|
|
85
|
+
});
|
|
285
86
|
}
|
|
286
|
-
|
|
287
|
-
|
|
87
|
+
throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
|
|
88
|
+
...params,
|
|
288
89
|
loader
|
|
289
|
-
})
|
|
90
|
+
});
|
|
290
91
|
}
|
|
291
|
-
|
|
292
92
|
acc.push(...res);
|
|
293
93
|
return acc;
|
|
294
94
|
}, []);
|
|
295
95
|
}
|
|
296
96
|
} catch (ex) {
|
|
297
|
-
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR",
|
|
298
|
-
error: ex
|
|
299
|
-
|
|
97
|
+
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
|
|
98
|
+
error: ex,
|
|
99
|
+
...params,
|
|
300
100
|
loader,
|
|
301
101
|
ids
|
|
302
|
-
})
|
|
102
|
+
});
|
|
303
103
|
}
|
|
304
|
-
|
|
305
104
|
throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
|
|
306
105
|
loader,
|
|
307
106
|
ids,
|
|
308
107
|
results
|
|
309
108
|
});
|
|
310
109
|
}
|
|
311
|
-
|
|
312
110
|
clearAll(params) {
|
|
313
|
-
|
|
314
|
-
const loader = this.getLoader(name, params);
|
|
315
|
-
loader.clearAll();
|
|
316
|
-
}
|
|
111
|
+
this.cache.clearAll(params?.model);
|
|
317
112
|
}
|
|
318
|
-
|
|
319
113
|
}
|
|
114
|
+
exports.DataLoadersHandler = DataLoadersHandler;
|
|
320
115
|
|
|
321
|
-
|
|
116
|
+
//# sourceMappingURL=dataLoaders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsStorageEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsStorageEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(\n params: GetAllEntryRevisionsParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;AAEA,MAAMA,oBAAoB,GAAIC,MAAD,IAA0B;EACnD,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBF,MAA1B;EACA,MAAM;IAAEG,MAAF;IAAUC;EAAV,IAAqBF,KAA3B;EACA,OAAO,IAAIG,mBAAJ,CAA0C,MAAOC,GAAP,IAAkC;IAC/E,MAAMC,OAA0C,GAAG,EAAnD;;IACA,KAAK,MAAMC,EAAX,IAAiBF,GAAjB,EAAsB;MAClB,MAAMG,cAA8B,GAAG;QACnCR,MADmC;QAEnCS,YAAY,EAAE,IAAAC,wBAAA,EAAmB;UAC7BR,MAD6B;UAE7BC,MAF6B;UAG7BI;QAH6B,CAAnB,CAFqB;QAOnCI,OAAO,EAAE;UACLC,UAAU,EAAE;QADP;MAP0B,CAAvC;MAWA,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAA,EAA0BN,cAA1B,CAApB;MACAF,OAAO,CAACC,EAAD,CAAP,GAAc,IAAAQ,qBAAA,EAAaf,MAAb,EAAqBa,KAArB,CAAd;IACH;;IAED,OAAOR,GAAG,CAACW,GAAJ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f,EAAwB;cACpB,MAAM,IAAIZ,cAAJ,CAAgBW,GAAG,CAACC,OAApB,EAA6BD,GAAG,CAACE,IAAjC,8DACCF,GADD;gBAEFG,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAeL,GAAG,CAACG,IAAJ,IAAY,EAA3B;cAFJ,GAAN;YAIH;;YACD,MAAM,IAAId,cAAJ,CACF,uFADE,EAEF,2BAFE,8DAIKpD,MAJL;cAKE2D;YALF,GAAN;UAQH;;UACDG,GAAG,CAACO,IAAJ,CAAS,GAAGN,GAAZ;UACA,OAAOD,GAAP;QACH,CAnBM,EAmBJ,EAnBI,CAAP;MAoBH;IACJ,CAxBD,CAwBE,OAAOQ,EAAP,EAAW;MACT,MAAM,IAAIlB,cAAJ,CACFkB,EAAE,CAACN,OAAH,IAAc,oBADZ,EAEFM,EAAE,CAACL,IAAH,IAAW,mBAFT;QAIEM,KAAK,EAAED;MAJT,GAKKtE,MALL;QAME2D,MANF;QAOErD;MAPF,GAAN;IAUH;;IACD,MAAM,IAAI8C,cAAJ,CACD,2DADC,EAEF,4BAFE,EAGF;MACIO,MADJ;MAEIrD,GAFJ;MAGIC;IAHJ,CAHE,CAAN;EASH;;EAEMiE,QAAQ,CAACxE,MAAD,EAAiD;IAC5D,KAAK,MAAMmD,IAAX,IAAmBN,WAAnB,EAAgC;MAC5B,MAAMc,MAAM,GAAG,KAAKT,SAAL,CAAeC,IAAf,EAAqBnD,MAArB,CAAf;MACA2D,MAAM,CAACa,QAAP;IACH;EACJ;;AAjH2B"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_DataLoaderCache","_dataLoader","_utils","DataLoadersHandler","cache","DataLoaderCache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","parseIdentifier","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","locale","loader","getDataLoader","factory","getDataLoaderFactory","setDataLoader","results","Array","isArray","reduce","acc","res","message","WebinyError","code","data","JSON","stringify","push","ex","error","clearAll","exports"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsModel, CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type {\n DataLoadersHandlerInterface,\n DataLoadersHandlerInterfaceClearAllParams\n} from \"~/types\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\n\nexport class DataLoadersHandler implements DataLoadersHandlerInterface {\n private readonly entity: Entity<any>;\n private readonly cache: DataLoaderCache = new DataLoaderCache();\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n locale: model.locale,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n locale: model.locale\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAD,OA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AAK,EAAE;YAC9B,IAAIA,GAAG,IAAIA,GAAG,CAACC,OAAO,EAAE;cACpB,MAAM,IAAIC,cAAW,CAACF,GAAG,CAACC,OAAO,EAAED,GAAG,CAACG,IAAI,EAAE;gBACzC,GAAGH,GAAG;gBACNI,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACN,GAAG,CAACI,IAAI,IAAI,CAAC,CAAC;cACvC,CAAC,CAAC;YACN;YACA,MAAM,IAAIF,cAAW,CACjB,uFAAuF,EACvF,2BAA2B,EAC3B;cACI,GAAG9B,MAAM;cACTkB;YACJ,CACJ,CAAC;UACL;UACAS,GAAG,CAACQ,IAAI,CAAC,GAAGP,GAAG,CAAC;UAChB,OAAOD,GAAG;QACd,CAAC,EAAE,EAAE,CAAC;MACV;IACJ,CAAC,CAAC,OAAOS,EAAE,EAAE;MACT,MAAM,IAAIN,cAAW,CACjBM,EAAE,CAACP,OAAO,IAAI,oBAAoB,EAClCO,EAAE,CAACL,IAAI,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGpC,MAAM;QACTkB,MAAM;QACNf;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAI2B,cAAW,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIZ,MAAM;MACNf,GAAG;MACHoB;IACJ,CACJ,CAAC;EACL;EAEOe,QAAQA,CAACtC,MAAkD,EAAQ;IACtE,IAAI,CAACH,KAAK,CAACyC,QAAQ,CAACtC,MAAM,EAAEc,KAAK,CAAC;EACtC;AACJ;AAACyB,OAAA,CAAA3C,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
3
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
import type { Field } from "./types";
|
|
5
|
+
interface Params {
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
where: Partial<CmsEntryListWhere>;
|
|
8
|
+
fields: Record<string, Field>;
|
|
9
|
+
}
|
|
10
|
+
export type ExpressionCondition = "AND" | "OR";
|
|
11
|
+
export interface Expression {
|
|
12
|
+
expressions: Expression[];
|
|
13
|
+
filters: Filter[];
|
|
14
|
+
condition: ExpressionCondition;
|
|
15
|
+
}
|
|
16
|
+
export interface Filter {
|
|
17
|
+
field: Field;
|
|
18
|
+
path: string;
|
|
19
|
+
fieldPathId: string;
|
|
20
|
+
plugin: ValueFilterPlugin;
|
|
21
|
+
negate: boolean;
|
|
22
|
+
compareValue: any;
|
|
23
|
+
transformValue: <I = any, O = any>(value: I) => O;
|
|
24
|
+
}
|
|
25
|
+
export declare const createExpressions: (params: Params) => Expression;
|
|
26
|
+
export {};
|