@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.d.ts +6 -4
- package/definitions/entry.js +111 -20
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -4
- package/definitions/group.js +8 -16
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -4
- package/definitions/model.js +30 -16
- package/definitions/model.js.map +1 -0
- package/definitions/system.d.ts +6 -4
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +7 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +9 -18
- package/dynamoDb/index.js.map +1 -0
- 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.d.ts +2 -3
- package/dynamoDb/path/plainObject.js +26 -24
- package/dynamoDb/path/plainObject.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +74 -63
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +49 -98
- package/dynamoDb/storage/richText.js.map +1 -0
- package/dynamoDb/transformValue/datetime.d.ts +5 -3
- package/dynamoDb/transformValue/datetime.js +29 -29
- package/dynamoDb/transformValue/datetime.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +56 -54
- package/index.js.map +1 -0
- 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 +18 -29
- package/operations/entry/dataLoaders.js +59 -246
- package/operations/entry/dataLoaders.js.map +1 -0
- 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 +5 -5
- package/operations/entry/index.js +920 -437
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +9 -14
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +35 -59
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +5 -4
- package/operations/model/index.js +35 -46
- package/operations/model/index.js.map +1 -0
- package/operations/system/index.d.ts +5 -4
- package/operations/system/index.js +20 -31
- package/operations/system/index.js.map +1 -0
- package/package.json +23 -29
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +23 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js +48 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
- 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 +4 -0
- package/plugins/index.js +51 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +21 -45
- package/types.js +5 -6
- package/types.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -50
- package/operations/entry/utils.d.ts +0 -31
- package/operations/entry/utils.js +0 -406
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
|
@@ -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,38 +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
|
}
|
|
7
|
-
|
|
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?: CmsEntry;
|
|
22
|
-
}
|
|
23
|
-
export interface Params {
|
|
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;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
private readonly cache;
|
|
14
|
+
constructor(params: DataLoadersHandlerParams);
|
|
15
|
+
getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
16
|
+
getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
17
|
+
getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
18
|
+
getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
19
|
+
/**
|
|
20
|
+
* TODO @ts-refactor
|
|
21
|
+
* Maybe pass on the generics to DataLoader definition?
|
|
22
|
+
*/
|
|
34
23
|
private getLoader;
|
|
35
24
|
private loadMany;
|
|
36
|
-
clearAll(params
|
|
25
|
+
clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void;
|
|
37
26
|
}
|
|
38
27
|
export {};
|
|
@@ -1,303 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DataLoadersHandler = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
13
|
-
|
|
14
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _keys = require("./keys");
|
|
19
|
-
|
|
20
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
21
|
-
|
|
9
|
+
var _DataLoaderCache = require("./dataLoader/DataLoaderCache");
|
|
10
|
+
var _dataLoader = require("./dataLoader");
|
|
22
11
|
var _utils = require("@webiny/utils");
|
|
23
|
-
|
|
24
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
|
-
const getAllEntryRevisions = params => {
|
|
31
|
-
const {
|
|
32
|
-
entity,
|
|
33
|
-
model
|
|
34
|
-
} = params;
|
|
35
|
-
const {
|
|
36
|
-
tenant,
|
|
37
|
-
locale
|
|
38
|
-
} = model;
|
|
39
|
-
return new _dataloader.default(async ids => {
|
|
40
|
-
const results = [];
|
|
41
|
-
|
|
42
|
-
for (const id of ids) {
|
|
43
|
-
const queryAllParams = {
|
|
44
|
-
entity,
|
|
45
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
46
|
-
tenant,
|
|
47
|
-
locale,
|
|
48
|
-
id
|
|
49
|
-
}),
|
|
50
|
-
options: {
|
|
51
|
-
beginsWith: "REV#"
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
55
|
-
const entries = (0, _cleanup.cleanupItems)(entity, items);
|
|
56
|
-
results.push(entries);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return results;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const getRevisionById = params => {
|
|
64
|
-
const {
|
|
65
|
-
entity,
|
|
66
|
-
model
|
|
67
|
-
} = params;
|
|
68
|
-
const {
|
|
69
|
-
locale,
|
|
70
|
-
tenant
|
|
71
|
-
} = model;
|
|
72
|
-
return new _dataloader.default(async ids => {
|
|
73
|
-
const queries = ids.reduce((collection, id) => {
|
|
74
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
75
|
-
tenant,
|
|
76
|
-
locale,
|
|
77
|
-
id
|
|
78
|
-
});
|
|
79
|
-
const {
|
|
80
|
-
version
|
|
81
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
82
|
-
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
83
|
-
version
|
|
84
|
-
});
|
|
85
|
-
const keys = `${partitionKey}__${sortKey}`;
|
|
86
|
-
|
|
87
|
-
if (collection[keys]) {
|
|
88
|
-
return collection;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
collection[keys] = entity.getBatch({
|
|
92
|
-
PK: partitionKey,
|
|
93
|
-
SK: sortKey
|
|
94
|
-
});
|
|
95
|
-
return collection;
|
|
96
|
-
}, {});
|
|
97
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
98
|
-
table: entity.table,
|
|
99
|
-
items: Object.values(queries)
|
|
100
|
-
});
|
|
101
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
102
|
-
return ids.map(id => {
|
|
103
|
-
return items.filter(item => {
|
|
104
|
-
return id === item.id;
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const getPublishedRevisionByEntryId = params => {
|
|
111
|
-
const {
|
|
112
|
-
entity,
|
|
113
|
-
model
|
|
114
|
-
} = params;
|
|
115
|
-
const {
|
|
116
|
-
locale,
|
|
117
|
-
tenant
|
|
118
|
-
} = model;
|
|
119
|
-
const publishedKey = (0, _keys.createPublishedSortKey)();
|
|
120
|
-
return new _dataloader.default(async ids => {
|
|
121
|
-
const queries = ids.reduce((collection, id) => {
|
|
122
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
123
|
-
tenant,
|
|
124
|
-
locale,
|
|
125
|
-
id
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
if (collection[partitionKey]) {
|
|
129
|
-
return collection;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
collection[partitionKey] = entity.getBatch({
|
|
133
|
-
PK: partitionKey,
|
|
134
|
-
SK: publishedKey
|
|
135
|
-
});
|
|
136
|
-
return collection;
|
|
137
|
-
}, {});
|
|
138
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
139
|
-
table: entity.table,
|
|
140
|
-
items: Object.values(queries)
|
|
141
|
-
});
|
|
142
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
143
|
-
return ids.map(id => {
|
|
144
|
-
const {
|
|
145
|
-
id: entryId
|
|
146
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
147
|
-
return items.filter(item => {
|
|
148
|
-
return entryId === item.entryId;
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const getLatestRevisionByEntryId = params => {
|
|
155
|
-
const {
|
|
156
|
-
entity,
|
|
157
|
-
model
|
|
158
|
-
} = params;
|
|
159
|
-
const {
|
|
160
|
-
locale,
|
|
161
|
-
tenant
|
|
162
|
-
} = model;
|
|
163
|
-
const latestKey = (0, _keys.createLatestSortKey)();
|
|
164
|
-
return new _dataloader.default(async ids => {
|
|
165
|
-
const queries = ids.reduce((collection, id) => {
|
|
166
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
167
|
-
tenant,
|
|
168
|
-
locale,
|
|
169
|
-
id
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (collection[partitionKey]) {
|
|
173
|
-
return collection;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
collection[partitionKey] = entity.getBatch({
|
|
177
|
-
PK: partitionKey,
|
|
178
|
-
SK: latestKey
|
|
179
|
-
});
|
|
180
|
-
return collection;
|
|
181
|
-
}, {});
|
|
182
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
183
|
-
table: entity.table,
|
|
184
|
-
items: Object.values(queries)
|
|
185
|
-
});
|
|
186
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
187
|
-
return ids.map(id => {
|
|
188
|
-
const {
|
|
189
|
-
id: entryId
|
|
190
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
191
|
-
return items.filter(item => {
|
|
192
|
-
return entryId === item.entryId;
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const dataLoaders = {
|
|
199
|
-
getAllEntryRevisions,
|
|
200
|
-
getRevisionById,
|
|
201
|
-
getPublishedRevisionByEntryId,
|
|
202
|
-
getLatestRevisionByEntryId
|
|
203
|
-
};
|
|
204
|
-
const loaderNames = Object.keys(dataLoaders);
|
|
205
|
-
|
|
206
12
|
class DataLoadersHandler {
|
|
13
|
+
cache = new _DataLoaderCache.DataLoaderCache();
|
|
207
14
|
constructor(params) {
|
|
208
|
-
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
209
|
-
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
210
15
|
this.entity = params.entity;
|
|
211
16
|
}
|
|
212
|
-
|
|
213
17
|
async getAllEntryRevisions(params) {
|
|
214
|
-
|
|
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);
|
|
215
25
|
}
|
|
216
|
-
|
|
217
26
|
async getRevisionById(params) {
|
|
218
27
|
return await this.loadMany("getRevisionById", params, params.ids);
|
|
219
28
|
}
|
|
220
|
-
|
|
221
29
|
async getPublishedRevisionByEntryId(params) {
|
|
222
|
-
|
|
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);
|
|
223
37
|
}
|
|
224
|
-
|
|
225
38
|
async getLatestRevisionByEntryId(params) {
|
|
226
|
-
|
|
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);
|
|
227
46
|
}
|
|
228
47
|
|
|
48
|
+
/**
|
|
49
|
+
* TODO @ts-refactor
|
|
50
|
+
* Maybe pass on the generics to DataLoader definition?
|
|
51
|
+
*/
|
|
229
52
|
getLoader(name, params) {
|
|
230
|
-
if (!dataLoaders[name]) {
|
|
231
|
-
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
232
|
-
name
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
53
|
const {
|
|
237
54
|
model
|
|
238
55
|
} = params;
|
|
239
|
-
const {
|
|
240
|
-
tenant,
|
|
241
|
-
locale
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
entity: this.entity
|
|
248
|
-
})));
|
|
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;
|
|
249
64
|
}
|
|
250
|
-
|
|
251
|
-
|
|
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;
|
|
252
73
|
}
|
|
253
|
-
|
|
254
74
|
async loadMany(loader, params, ids) {
|
|
255
|
-
let results;
|
|
256
|
-
|
|
75
|
+
let results = [];
|
|
257
76
|
try {
|
|
258
77
|
results = await this.getLoader(loader, params).loadMany(ids);
|
|
259
|
-
|
|
260
78
|
if (Array.isArray(results) === true) {
|
|
261
79
|
return results.reduce((acc, res) => {
|
|
262
80
|
if (Array.isArray(res) === false) {
|
|
263
81
|
if (res && res.message) {
|
|
264
|
-
throw new _error.default(res.message, res.code,
|
|
82
|
+
throw new _error.default(res.message, res.code, {
|
|
83
|
+
...res,
|
|
265
84
|
data: JSON.stringify(res.data || {})
|
|
266
|
-
})
|
|
85
|
+
});
|
|
267
86
|
}
|
|
268
|
-
|
|
269
|
-
|
|
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,
|
|
270
89
|
loader
|
|
271
|
-
})
|
|
90
|
+
});
|
|
272
91
|
}
|
|
273
|
-
|
|
274
92
|
acc.push(...res);
|
|
275
93
|
return acc;
|
|
276
94
|
}, []);
|
|
277
95
|
}
|
|
278
96
|
} catch (ex) {
|
|
279
|
-
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR",
|
|
280
|
-
error: ex
|
|
281
|
-
|
|
97
|
+
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
|
|
98
|
+
error: ex,
|
|
99
|
+
...params,
|
|
282
100
|
loader,
|
|
283
101
|
ids
|
|
284
|
-
})
|
|
102
|
+
});
|
|
285
103
|
}
|
|
286
|
-
|
|
287
104
|
throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
|
|
288
105
|
loader,
|
|
289
106
|
ids,
|
|
290
107
|
results
|
|
291
108
|
});
|
|
292
109
|
}
|
|
293
|
-
|
|
294
110
|
clearAll(params) {
|
|
295
|
-
|
|
296
|
-
const loader = this.getLoader(name, params);
|
|
297
|
-
loader.clearAll();
|
|
298
|
-
}
|
|
111
|
+
this.cache.clearAll(params?.model);
|
|
299
112
|
}
|
|
300
|
-
|
|
301
113
|
}
|
|
114
|
+
exports.DataLoadersHandler = DataLoadersHandler;
|
|
302
115
|
|
|
303
|
-
|
|
116
|
+
//# sourceMappingURL=dataLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":"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","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 {};
|