@webiny/api-headless-cms-ddb 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7
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 -6
- package/definitions/entry.js +5 -180
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -6
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -6
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +3 -5
- package/definitions/table.js +6 -28
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +61 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -13
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +1 -1
- package/dynamoDb/path/locationFolderId.js +5 -14
- package/dynamoDb/path/locationFolderId.js.map +1 -1
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +5 -14
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +5 -12
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +62 -92
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +3 -13
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +1 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +16 -26
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -33
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -33
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +29 -35
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +3 -3
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +4 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +11 -12
- package/operations/entry/dataLoaders.js +16 -24
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +7 -6
- package/operations/entry/filtering/createExpressions.js +29 -35
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +2 -2
- package/operations/entry/filtering/createFields.js +20 -22
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.d.ts +5 -5
- package/operations/entry/filtering/extractSort.js +38 -23
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +7 -6
- package/operations/entry/filtering/filter.js +22 -27
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +4 -4
- package/operations/entry/filtering/fullTextSearch.js +7 -15
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +1 -8
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.d.ts +2 -2
- package/operations/entry/filtering/index.js +2 -19
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.d.ts +1 -1
- package/operations/entry/filtering/mapPlugins.js +3 -11
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +10 -18
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/filtering/plugins/index.js +6 -13
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +15 -21
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +16 -22
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +14 -17
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
- package/operations/entry/filtering/sort.d.ts +5 -5
- package/operations/entry/filtering/sort.js +15 -19
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.d.ts +2 -4
- package/operations/entry/filtering/systemFields.js +70 -29
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.d.ts +1 -1
- package/operations/entry/filtering/transform.js +1 -8
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +4 -4
- package/operations/entry/filtering/types.js +1 -5
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/filtering/values.d.ts +1 -1
- package/operations/entry/filtering/values.js +4 -12
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +1 -8
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +4 -3
- package/operations/entry/index.js +279 -388
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +40 -2
- package/operations/entry/keys.js +53 -30
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +37 -69
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +36 -59
- package/operations/model/index.js.map +1 -1
- package/package.json +24 -20
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js +4 -12
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +5 -5
- package/plugins/CmsEntryFieldFilterPlugin.js +2 -8
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldSortingPlugin.js +3 -11
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.js +2 -9
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +4 -4
- package/plugins/index.js +4 -49
- package/plugins/index.js.map +1 -1
- package/types.d.ts +20 -20
- package/types.js +1 -8
- package/types.js.map +1 -1
- package/definitions/system.d.ts +0 -10
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -94
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -61
- package/dynamoDb/storage/richText.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createGetAllEntryRevisions = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
10
|
-
var _keys = require("../keys");
|
|
11
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
12
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
13
|
-
const createGetAllEntryRevisions = params => {
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { createPartitionKey } from "../keys.js";
|
|
3
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
|
+
export const createGetAllEntryRevisions = params => {
|
|
14
5
|
const {
|
|
15
6
|
entity,
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
tenant,
|
|
8
|
+
modelId
|
|
18
9
|
} = params;
|
|
19
|
-
return new
|
|
10
|
+
return new DataLoader(async ids => {
|
|
20
11
|
const results = {};
|
|
21
12
|
for (const id of ids) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
13
|
+
results[id] = (await entity.queryAllClean({
|
|
14
|
+
partitionKey: createPartitionKey({
|
|
25
15
|
tenant,
|
|
26
|
-
locale,
|
|
27
16
|
id
|
|
28
17
|
}),
|
|
29
18
|
options: {
|
|
30
19
|
beginsWith: "REV#"
|
|
31
20
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
})).map(result => {
|
|
22
|
+
return result.data;
|
|
23
|
+
});
|
|
35
24
|
}
|
|
36
25
|
return ids.map(id => {
|
|
37
|
-
return results[id] || []
|
|
26
|
+
return (results[id] || []).filter(item => {
|
|
27
|
+
return item.modelId === modelId;
|
|
28
|
+
});
|
|
38
29
|
});
|
|
39
30
|
}, {
|
|
40
|
-
batchScheduleFn:
|
|
31
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
41
32
|
});
|
|
42
33
|
};
|
|
43
|
-
exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
|
|
44
34
|
|
|
45
35
|
//# sourceMappingURL=getAllEntryRevisions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","modelId","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","result","data","filter","item","batchScheduleFn"],"sources":["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"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAC1C,OAAO,IAAIJ,UAAU,CACjB,MAAMQ,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAML,MAAM,CAACM,aAAa,CAAC;QACvBC,YAAY,EAAEX,kBAAkB,CAAC;UAC7BK,MAAM;UACNI;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,MAAM,IAAI;QACZ,OAAOA,MAAM,CAACC,IAAI;MACtB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACL,EAAE,IAAI;MACjB,OAAO,CAACD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE,EAAEQ,MAAM,CAACC,IAAI,IAAI;QACtC,OAAOA,IAAI,CAACZ,OAAO,KAAKA,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIa,eAAe,EAAElB,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DataLoader from "dataloader";
|
|
2
|
-
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import type {
|
|
4
|
-
export declare const createGetLatestRevisionByEntryId: (params:
|
|
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>;
|
|
@@ -1,56 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.createGetLatestRevisionByEntryId = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
12
|
-
var _keys = require("../keys");
|
|
13
|
-
var _utils = require("@webiny/utils");
|
|
14
|
-
const createGetLatestRevisionByEntryId = params => {
|
|
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
|
+
export const createGetLatestRevisionByEntryId = params => {
|
|
15
7
|
const {
|
|
16
8
|
entity,
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
tenant,
|
|
10
|
+
modelId
|
|
19
11
|
} = params;
|
|
20
|
-
const latestKey =
|
|
21
|
-
return new
|
|
22
|
-
const
|
|
23
|
-
|
|
12
|
+
const latestKey = createLatestSortKey();
|
|
13
|
+
return new DataLoader(async ids => {
|
|
14
|
+
const reader = entity.createEntityReader();
|
|
15
|
+
const keys = new Set();
|
|
16
|
+
for (const id of ids) {
|
|
17
|
+
const partitionKey = createPartitionKey({
|
|
24
18
|
tenant,
|
|
25
|
-
locale,
|
|
26
19
|
id
|
|
27
20
|
});
|
|
28
|
-
if (
|
|
29
|
-
|
|
21
|
+
if (keys.has(partitionKey)) {
|
|
22
|
+
continue;
|
|
30
23
|
}
|
|
31
|
-
|
|
24
|
+
keys.add(partitionKey);
|
|
25
|
+
reader.get({
|
|
32
26
|
PK: partitionKey,
|
|
33
27
|
SK: latestKey
|
|
34
28
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
items: Object.values(queries)
|
|
29
|
+
}
|
|
30
|
+
const records = await reader.execute();
|
|
31
|
+
const items = cleanupItems(entity.entity, records).map(item => {
|
|
32
|
+
return item.data;
|
|
40
33
|
});
|
|
41
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
42
34
|
return ids.map(id => {
|
|
43
35
|
const {
|
|
44
36
|
id: entryId
|
|
45
|
-
} =
|
|
37
|
+
} = parseIdentifier(id);
|
|
46
38
|
return items.filter(item => {
|
|
39
|
+
if (item.modelId !== modelId) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
47
42
|
return entryId === item.entryId;
|
|
48
43
|
});
|
|
49
44
|
});
|
|
50
45
|
}, {
|
|
51
|
-
batchScheduleFn:
|
|
46
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
52
47
|
});
|
|
53
48
|
};
|
|
54
|
-
exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
|
|
55
49
|
|
|
56
50
|
//# sourceMappingURL=getLatestRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","cleanupItems","createBatchScheduleFn","createLatestSortKey","createPartitionKey","parseIdentifier","createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["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"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,MAAMI,SAAS,GAAGR,mBAAmB,CAAC,CAAC;EAEvC,OAAO,IAAIH,UAAU,CACjB,MAAMY,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGL,MAAM,CAACM,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGd,kBAAkB,CAAC;QACpCK,MAAM;QACNQ;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MAEtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,OAAO,GAAG,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAGzB,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEgB,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOjB,GAAG,CAACe,GAAG,CAACV,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEa;MAAQ,CAAC,GAAGzB,eAAe,CAACY,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,IAAIA,IAAI,CAAClB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOoB,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE9B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DataLoader from "dataloader";
|
|
2
|
-
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import type {
|
|
4
|
-
export declare const createGetPublishedRevisionByEntryId: (params:
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetPublishedRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -1,56 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.createGetPublishedRevisionByEntryId = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _keys = require("../keys");
|
|
12
|
-
var _utils = require("@webiny/utils");
|
|
13
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
14
|
-
const createGetPublishedRevisionByEntryId = params => {
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
|
+
import { createPartitionKey, createPublishedSortKey } from "../keys.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
+
export const createGetPublishedRevisionByEntryId = params => {
|
|
15
7
|
const {
|
|
16
8
|
entity,
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
tenant,
|
|
10
|
+
modelId
|
|
19
11
|
} = params;
|
|
20
|
-
const publishedKey =
|
|
21
|
-
return new
|
|
22
|
-
const
|
|
23
|
-
|
|
12
|
+
const publishedKey = createPublishedSortKey();
|
|
13
|
+
return new DataLoader(async ids => {
|
|
14
|
+
const reader = entity.createEntityReader();
|
|
15
|
+
const keys = new Set();
|
|
16
|
+
for (const id of ids) {
|
|
17
|
+
const partitionKey = createPartitionKey({
|
|
24
18
|
tenant,
|
|
25
|
-
locale,
|
|
26
19
|
id
|
|
27
20
|
});
|
|
28
|
-
if (
|
|
29
|
-
|
|
21
|
+
if (keys.has(partitionKey)) {
|
|
22
|
+
continue;
|
|
30
23
|
}
|
|
31
|
-
|
|
24
|
+
keys.add(partitionKey);
|
|
25
|
+
reader.get({
|
|
32
26
|
PK: partitionKey,
|
|
33
27
|
SK: publishedKey
|
|
34
28
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
items: Object.values(queries)
|
|
29
|
+
}
|
|
30
|
+
const records = await reader.execute();
|
|
31
|
+
const items = cleanupItems(entity.entity, records).map(item => {
|
|
32
|
+
return item.data;
|
|
40
33
|
});
|
|
41
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
42
34
|
return ids.map(id => {
|
|
43
35
|
const {
|
|
44
36
|
id: entryId
|
|
45
|
-
} =
|
|
37
|
+
} = parseIdentifier(id);
|
|
46
38
|
return items.filter(item => {
|
|
39
|
+
if (item.modelId !== modelId) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
47
42
|
return entryId === item.entryId;
|
|
48
43
|
});
|
|
49
44
|
});
|
|
50
45
|
}, {
|
|
51
|
-
batchScheduleFn:
|
|
46
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
52
47
|
});
|
|
53
48
|
};
|
|
54
|
-
exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
|
|
55
49
|
|
|
56
50
|
//# sourceMappingURL=getPublishedRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createPublishedSortKey","parseIdentifier","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","modelId","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,kBAAkB,EAAEC,sBAAsB;AAEnD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,mCAAmC,GAAIC,MAAyB,IAAK;EAC9E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,MAAMI,YAAY,GAAGR,sBAAsB,CAAC,CAAC;EAC7C,OAAO,IAAIH,UAAU,CACjB,MAAMY,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGL,MAAM,CAACM,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGhB,kBAAkB,CAAC;QACpCO,MAAM;QACNQ;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MACtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,OAAO,GAAG,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAGzB,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEgB,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOjB,GAAG,CAACe,GAAG,CAACV,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEa;MAAQ,CAAC,GAAG1B,eAAe,CAACa,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,IAAIA,IAAI,CAAClB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOoB,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE3B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DataLoader from "dataloader";
|
|
2
|
-
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import type {
|
|
4
|
-
export declare const createGetRevisionById: (params:
|
|
2
|
+
import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
4
|
+
export declare const createGetRevisionById: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
|
|
@@ -1,62 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.createGetRevisionById = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _keys = require("../keys");
|
|
12
|
-
var _utils = require("@webiny/utils");
|
|
13
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
14
|
-
const createGetRevisionById = params => {
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
|
+
import { createPartitionKey, createRevisionSortKey } from "../keys.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
+
export const createGetRevisionById = params => {
|
|
15
7
|
const {
|
|
16
8
|
entity,
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
tenant,
|
|
10
|
+
modelId
|
|
19
11
|
} = params;
|
|
20
|
-
return new
|
|
21
|
-
const
|
|
22
|
-
|
|
12
|
+
return new DataLoader(async ids => {
|
|
13
|
+
const reader = entity.createEntityReader();
|
|
14
|
+
const keys = new Set();
|
|
15
|
+
for (const id of ids) {
|
|
16
|
+
const partitionKey = createPartitionKey({
|
|
23
17
|
tenant,
|
|
24
|
-
locale,
|
|
25
18
|
id
|
|
26
19
|
});
|
|
27
20
|
const {
|
|
28
21
|
version
|
|
29
|
-
} =
|
|
22
|
+
} = parseIdentifier(id);
|
|
30
23
|
if (version === null) {
|
|
31
|
-
|
|
24
|
+
continue;
|
|
32
25
|
}
|
|
33
|
-
const sortKey =
|
|
26
|
+
const sortKey = createRevisionSortKey({
|
|
34
27
|
version
|
|
35
28
|
});
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
29
|
+
const key = `${partitionKey}__${sortKey}`;
|
|
30
|
+
if (keys.has(key)) {
|
|
31
|
+
continue;
|
|
39
32
|
}
|
|
40
|
-
|
|
33
|
+
keys.add(key);
|
|
34
|
+
reader.get({
|
|
41
35
|
PK: partitionKey,
|
|
42
36
|
SK: sortKey
|
|
43
37
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
items: Object.values(queries)
|
|
38
|
+
}
|
|
39
|
+
const records = await reader.execute();
|
|
40
|
+
const items = cleanupItems(entity.entity, records).map(item => {
|
|
41
|
+
return item.data;
|
|
49
42
|
});
|
|
50
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
51
43
|
return ids.map(id => {
|
|
52
44
|
return items.filter(item => {
|
|
45
|
+
if (item.modelId !== modelId) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
53
48
|
return id === item.id;
|
|
54
49
|
});
|
|
55
50
|
});
|
|
56
51
|
}, {
|
|
57
|
-
batchScheduleFn:
|
|
52
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
58
53
|
});
|
|
59
54
|
};
|
|
60
|
-
exports.createGetRevisionById = createGetRevisionById;
|
|
61
55
|
|
|
62
56
|
//# sourceMappingURL=getRevisionById.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","modelId","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","records","execute","items","map","item","data","filter","batchScheduleFn"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,sCAAsC;AACnE,SAASC,kBAAkB,EAAEC,qBAAqB;AAElD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,qBAAqB,GAAIC,MAAyB,IAAK;EAChE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,OAAO,IAAIP,UAAU,CACjB,MAAMW,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGJ,MAAM,CAACK,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGf,kBAAkB,CAAC;QACpCO,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,MAAM;QAAEE;MAAQ,CAAC,GAAGd,eAAe,CAACY,EAAE,CAAC;MACvC,IAAIE,OAAO,KAAK,IAAI,EAAE;QAClB;MACJ;MACA,MAAMC,OAAO,GAAGhB,qBAAqB,CAAC;QAClCe;MACJ,CAAC,CAAC;MACF,MAAME,GAAG,GAAG,GAAGH,YAAY,KAAKE,OAAO,EAAE;MACzC,IAAIL,IAAI,CAACO,GAAG,CAACD,GAAG,CAAC,EAAE;QACf;MACJ;MACAN,IAAI,CAACQ,GAAG,CAACF,GAAG,CAAC;MAEbR,MAAM,CAACW,GAAG,CAAC;QACPC,EAAE,EAAEP,YAAY;QAChBQ,EAAE,EAAEN;MACR,CAAC,CAAC;IACN;IAEA,MAAMO,OAAO,GAAG,MAAMd,MAAM,CAACe,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAG3B,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEkB,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOpB,GAAG,CAACkB,GAAG,CAACb,EAAE,IAAI;MACjB,OAAOY,KAAK,CAACI,MAAM,CAACF,IAAI,IAAI;QACxB,IAAIA,IAAI,CAACpB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOM,EAAE,KAAKc,IAAI,CAACd,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIiB,eAAe,EAAE5B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type DataLoader from "dataloader";
|
|
2
|
-
import type {
|
|
3
|
-
export * from "./DataLoaderCache";
|
|
2
|
+
import type { IDataLoaderParams } from "./types.js";
|
|
3
|
+
export * from "./DataLoaderCache.js";
|
|
4
4
|
interface Callable {
|
|
5
|
-
(params:
|
|
5
|
+
(params: IDataLoaderParams): DataLoader<any, any>;
|
|
6
6
|
}
|
|
7
7
|
export type DataLoaders = "getAllEntryRevisions" | "getRevisionById" | "getPublishedRevisionByEntryId" | "getLatestRevisionByEntryId";
|
|
8
8
|
export declare const getDataLoaderFactory: (name: string) => Callable;
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
});
|
|
1
|
+
import { createGetAllEntryRevisions } from "./getAllEntryRevisions.js";
|
|
2
|
+
import { createGetLatestRevisionByEntryId } from "./getLatestRevisionByEntryId.js";
|
|
3
|
+
import { createGetPublishedRevisionByEntryId } from "./getPublishedRevisionByEntryId.js";
|
|
4
|
+
import { createGetRevisionById } from "./getRevisionById.js";
|
|
5
|
+
export * from "./DataLoaderCache.js";
|
|
26
6
|
const dataLoaders = {
|
|
27
|
-
getAllEntryRevisions:
|
|
28
|
-
getLatestRevisionByEntryId:
|
|
29
|
-
getPublishedRevisionByEntryId:
|
|
30
|
-
getRevisionById:
|
|
7
|
+
getAllEntryRevisions: createGetAllEntryRevisions,
|
|
8
|
+
getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,
|
|
9
|
+
getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,
|
|
10
|
+
getRevisionById: createGetRevisionById
|
|
31
11
|
};
|
|
32
|
-
const getDataLoaderFactory = name => {
|
|
12
|
+
export const getDataLoaderFactory = name => {
|
|
33
13
|
if (!dataLoaders[name]) {
|
|
34
14
|
throw new Error(`Missing data loader "${name}".`);
|
|
35
15
|
}
|
|
36
16
|
return dataLoaders[name];
|
|
37
17
|
};
|
|
38
|
-
exports.getDataLoaderFactory = getDataLoaderFactory;
|
|
39
18
|
|
|
40
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createGetAllEntryRevisions","createGetLatestRevisionByEntryId","createGetPublishedRevisionByEntryId","createGetRevisionById","dataLoaders","getAllEntryRevisions","getLatestRevisionByEntryId","getPublishedRevisionByEntryId","getRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions.js\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId.js\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId.js\";\nimport { createGetRevisionById } from \"./getRevisionById.js\";\n\nexport * from \"./DataLoaderCache.js\";\n\ninterface Callable {\n (params: IDataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"mappings":"AAEA,SAASA,0BAA0B;AACnC,SAASC,gCAAgC;AACzC,SAASC,mCAAmC;AAC5C,SAASC,qBAAqB;AAE9B;AAMA,MAAMC,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEL,0BAA0B;EAChDM,0BAA0B,EAAEL,gCAAgC;EAC5DM,6BAA6B,EAAEL,mCAAmC;EAClEM,eAAe,EAAEL;AACrB,CAAC;AAQD,OAAO,MAAMM,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACN,WAAW,CAACM,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,CAAC,wBAAwBD,IAAI,IAAI,CAAC;EACrD;EACA,OAAON,WAAW,CAACM,IAAI,CAAC;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface
|
|
3
|
-
entity:
|
|
1
|
+
import type { IEntryEntity } from "../../../definitions/types.js";
|
|
2
|
+
export interface IDataLoaderParams {
|
|
3
|
+
entity: IEntryEntity;
|
|
4
4
|
tenant: string;
|
|
5
|
-
|
|
5
|
+
modelId: string;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntryEntity } from \"~/definitions/types.js\";\n\nexport interface IDataLoaderParams {\n entity: IEntryEntity;\n tenant: string;\n modelId: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import type { CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type {
|
|
3
|
-
import type { DataLoadersHandlerInterface, DataLoadersHandlerInterfaceClearAllParams } from "../../types";
|
|
1
|
+
import type { CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler, IEntryEntity } from "../../types.js";
|
|
4
3
|
interface DataLoaderParams {
|
|
5
|
-
model: Pick<CmsModel, "tenant" | "
|
|
4
|
+
model: Pick<CmsModel, "tenant" | "modelId">;
|
|
6
5
|
ids: readonly string[];
|
|
7
6
|
}
|
|
8
|
-
interface
|
|
9
|
-
entity:
|
|
7
|
+
interface IDataLoadersHandlerParams {
|
|
8
|
+
entity: IEntryEntity;
|
|
10
9
|
}
|
|
11
|
-
export declare class DataLoadersHandler implements
|
|
10
|
+
export declare class DataLoadersHandler implements IDataLoadersHandler {
|
|
12
11
|
private readonly entity;
|
|
13
12
|
private readonly cache;
|
|
14
|
-
constructor(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[]>;
|
|
13
|
+
constructor(params: IDataLoadersHandlerParams);
|
|
14
|
+
getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
15
|
+
getRevisionById<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
16
|
+
getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
17
|
+
getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
19
18
|
/**
|
|
20
19
|
* TODO @ts-refactor
|
|
21
20
|
* Maybe pass on the generics to DataLoader definition?
|