@webiny/api-headless-cms-ddb-es 6.0.0-beta.0 → 6.0.0-rc.0
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 -30
- package/configurations.d.ts +4 -5
- package/configurations.js +12 -24
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +5 -174
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -2
- package/dynamoDb/index.js +5 -14
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.js +11 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +0 -5
- package/dynamoDb/storage/richText.js +25 -80
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/createElasticsearchIndex.js +7 -15
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
- package/elasticsearch/deleteElasticsearchIndex.js +3 -10
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -11
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.d.ts +1 -1
- package/elasticsearch/indexing/index.js +8 -16
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
- package/elasticsearch/indexing/jsonIndexing.js +1 -8
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +1 -8
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +1 -8
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +6 -13
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +1 -8
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +1 -1
- package/elasticsearch/indices/base.js +4 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/index.js +3 -11
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +4 -10
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.d.ts +1 -1
- package/elasticsearch/search/refSearch.js +3 -10
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +53 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +1 -1
- package/elasticsearch/search/timeSearch.js +3 -10
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +10 -10
- package/helpers/entryIndexHelpers.js +32 -26
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +1 -1
- package/helpers/fieldIdentifier.js +2 -10
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.d.ts +2 -2
- package/helpers/index.js +2 -27
- package/helpers/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +108 -134
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
- 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 +11 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +23 -35
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +5 -5
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +13 -13
- package/operations/entry/dataLoaders.js +15 -25
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +3 -3
- package/operations/entry/elasticsearch/body.js +21 -28
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +3 -3
- package/operations/entry/elasticsearch/fields.js +110 -24
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +10 -17
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +7 -6
- package/operations/entry/elasticsearch/filtering/exec.js +48 -45
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +1 -16
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
- package/operations/entry/elasticsearch/filtering/path.js +9 -17
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +15 -16
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +1 -8
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +4 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
- package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js +9 -26
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +4 -9
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
- package/operations/entry/elasticsearch/plugins/operator.js +4 -19
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/search.js +5 -13
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +4 -4
- package/operations/entry/elasticsearch/sort.js +57 -33
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +5 -5
- package/operations/entry/elasticsearch/types.js +1 -5
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +7 -6
- package/operations/entry/index.js +634 -735
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +56 -19
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +3 -12
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
- package/operations/entry/transformations/convertEntryKeys.js +2 -10
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +17 -17
- package/operations/entry/transformations/index.js +22 -30
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
- package/operations/entry/transformations/modifyEntryValues.js +1 -8
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
- package/operations/entry/transformations/transformEntryKeys.js +4 -11
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +7 -7
- package/operations/entry/transformations/transformEntryToIndex.js +3 -10
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +39 -73
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +4 -4
- package/operations/model/index.js +38 -57
- package/operations/model/index.js.map +1 -1
- package/package.json +29 -41
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js +2 -9
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +8 -8
- package/plugins/index.js +8 -93
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -2
- package/tasks/createIndexTaskPlugin.js +36 -62
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +28 -33
- package/types.js +5 -8
- package/types.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +13 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +0 -8
- package/definitions/entryElasticsearch.js +0 -38
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -25
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -25
- package/definitions/tableElasticsearch.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -84
- package/dynamoDb/storage/date.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -14
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/operations/system/indexes.d.ts +0 -10
- package/operations/system/indexes.js +0 -41
- package/operations/system/indexes.js.map +0 -1
|
@@ -1,52 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createGetLatestRevisionByEntryId = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
12
|
-
var _keys = require("../keys");
|
|
13
|
-
const createGetLatestRevisionByEntryId = params => {
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
3
|
+
import { createLatestSortKey, createPartitionKey } from "../keys.js";
|
|
4
|
+
export const createGetLatestRevisionByEntryId = params => {
|
|
14
5
|
const {
|
|
15
6
|
entity,
|
|
16
|
-
locale,
|
|
17
7
|
tenant
|
|
18
8
|
} = params;
|
|
19
|
-
const latestKey =
|
|
20
|
-
return new
|
|
21
|
-
const
|
|
22
|
-
|
|
9
|
+
const latestKey = createLatestSortKey();
|
|
10
|
+
return new DataLoader(async ids => {
|
|
11
|
+
const reader = entity.createEntityReader();
|
|
12
|
+
const keys = new Set();
|
|
13
|
+
for (const id of ids) {
|
|
14
|
+
const partitionKey = createPartitionKey({
|
|
23
15
|
tenant,
|
|
24
|
-
locale,
|
|
25
16
|
id
|
|
26
17
|
});
|
|
27
|
-
if (
|
|
28
|
-
|
|
18
|
+
if (keys.has(partitionKey)) {
|
|
19
|
+
continue;
|
|
29
20
|
}
|
|
30
|
-
|
|
21
|
+
keys.add(partitionKey);
|
|
22
|
+
reader.get({
|
|
31
23
|
PK: partitionKey,
|
|
32
24
|
SK: latestKey
|
|
33
25
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
table: entity.table,
|
|
38
|
-
items: Object.values(queries)
|
|
26
|
+
}
|
|
27
|
+
const items = (await reader.execute()).map(item => {
|
|
28
|
+
return item.data;
|
|
39
29
|
});
|
|
40
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
41
30
|
return ids.map(entryId => {
|
|
42
31
|
return items.filter(item => {
|
|
43
32
|
return entryId === item.entryId;
|
|
44
33
|
});
|
|
45
34
|
});
|
|
46
35
|
}, {
|
|
47
|
-
batchScheduleFn:
|
|
36
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
48
37
|
});
|
|
49
38
|
};
|
|
50
|
-
exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
|
|
51
39
|
|
|
52
40
|
//# sourceMappingURL=getLatestRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","createBatchScheduleFn","createLatestSortKey","createPartitionKey","createGetLatestRevisionByEntryId","params","entity","tenant","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\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\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = 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 reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAGhD,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,MAAMG,SAAS,GAAGN,mBAAmB,CAAC,CAAC;EAEvC,OAAO,IAAIF,UAAU,CACjB,MAAMS,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,GAAGZ,kBAAkB,CAAC;QACpCI,MAAM;QACNO;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,KAAK,GAAG,CAAC,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI,IAAI;MAC/C,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOhB,GAAG,CAACc,GAAG,CAACG,OAAO,IAAI;MACtB,OAAOL,KAAK,CAACM,MAAM,CAACH,IAAI,IAAI;QACxB,OAAOE,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 { CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import {
|
|
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,52 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createGetPublishedRevisionByEntryId = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _keys = require("../keys");
|
|
12
|
-
var _createBatchScheduleFn = require("./createBatchScheduleFn");
|
|
13
|
-
const createGetPublishedRevisionByEntryId = params => {
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { createPartitionKey, createPublishedSortKey } from "../keys.js";
|
|
3
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
|
+
export const createGetPublishedRevisionByEntryId = params => {
|
|
14
5
|
const {
|
|
15
6
|
entity,
|
|
16
|
-
locale,
|
|
17
7
|
tenant
|
|
18
8
|
} = params;
|
|
19
|
-
const publishedKey =
|
|
20
|
-
return new
|
|
21
|
-
const
|
|
22
|
-
|
|
9
|
+
const publishedKey = createPublishedSortKey();
|
|
10
|
+
return new DataLoader(async ids => {
|
|
11
|
+
const reader = entity.createEntityReader();
|
|
12
|
+
const keys = new Set();
|
|
13
|
+
for (const id of ids) {
|
|
14
|
+
const partitionKey = createPartitionKey({
|
|
23
15
|
tenant,
|
|
24
|
-
locale,
|
|
25
16
|
id
|
|
26
17
|
});
|
|
27
|
-
if (
|
|
28
|
-
|
|
18
|
+
if (keys.has(partitionKey)) {
|
|
19
|
+
continue;
|
|
29
20
|
}
|
|
30
|
-
|
|
21
|
+
keys.add(partitionKey);
|
|
22
|
+
reader.get({
|
|
31
23
|
PK: partitionKey,
|
|
32
24
|
SK: publishedKey
|
|
33
25
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
table: entity.table,
|
|
38
|
-
items: Object.values(queries)
|
|
26
|
+
}
|
|
27
|
+
const items = (await reader.execute()).map(item => {
|
|
28
|
+
return item.data;
|
|
39
29
|
});
|
|
40
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
41
30
|
return ids.map(entryId => {
|
|
42
31
|
return items.filter(item => {
|
|
43
32
|
return entryId === item.entryId;
|
|
44
33
|
});
|
|
45
34
|
});
|
|
46
35
|
}, {
|
|
47
|
-
batchScheduleFn:
|
|
36
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
48
37
|
});
|
|
49
38
|
};
|
|
50
|
-
exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
|
|
51
39
|
|
|
52
40
|
//# sourceMappingURL=getPublishedRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createPublishedSortKey","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\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 { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = 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 items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB,EAAEC,sBAAsB;AAEnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,mCAAmC,GAAIC,MAAyB,IAAK;EAC9E,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,MAAMG,YAAY,GAAGN,sBAAsB,CAAC,CAAC;EAC7C,OAAO,IAAIF,UAAU,CACjB,MAAMS,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,GAAGd,kBAAkB,CAAC;QACpCM,MAAM;QACNO;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,KAAK,GAAG,CAAC,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI,IAAI;MAC/C,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOhB,GAAG,CAACc,GAAG,CAACG,OAAO,IAAI;MACtB,OAAOL,KAAK,CAACM,MAAM,CAACH,IAAI,IAAI;QACxB,OAAOE,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAEzB,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DataLoader from "dataloader";
|
|
2
|
-
import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import {
|
|
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,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.createGetRevisionById = void 0;
|
|
8
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
9
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
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 { createPartitionKey, createRevisionSortKey } from "../keys.js";
|
|
3
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
4
|
+
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
5
|
+
export const createGetRevisionById = params => {
|
|
15
6
|
const {
|
|
16
7
|
entity,
|
|
17
|
-
tenant
|
|
18
|
-
locale
|
|
8
|
+
tenant
|
|
19
9
|
} = params;
|
|
20
|
-
return new
|
|
21
|
-
const
|
|
22
|
-
|
|
10
|
+
return new DataLoader(async ids => {
|
|
11
|
+
const reader = entity.createEntityReader();
|
|
12
|
+
const keys = new Set();
|
|
13
|
+
for (const id of ids) {
|
|
14
|
+
const partitionKey = createPartitionKey({
|
|
23
15
|
tenant,
|
|
24
|
-
locale,
|
|
25
16
|
id
|
|
26
17
|
});
|
|
27
18
|
const {
|
|
28
19
|
version
|
|
29
|
-
} =
|
|
20
|
+
} = parseIdentifier(id);
|
|
30
21
|
if (version === null) {
|
|
31
|
-
|
|
22
|
+
continue;
|
|
32
23
|
}
|
|
33
|
-
const sortKey =
|
|
24
|
+
const sortKey = createRevisionSortKey({
|
|
34
25
|
version
|
|
35
26
|
});
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
27
|
+
const key = `${partitionKey}__${sortKey}`;
|
|
28
|
+
if (keys.has(key)) {
|
|
29
|
+
continue;
|
|
39
30
|
}
|
|
40
|
-
|
|
31
|
+
keys.add(key);
|
|
32
|
+
reader.get({
|
|
41
33
|
PK: partitionKey,
|
|
42
34
|
SK: sortKey
|
|
43
35
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
table: entity.table,
|
|
48
|
-
items: Object.values(queries)
|
|
36
|
+
}
|
|
37
|
+
const items = (await reader.execute()).map(item => {
|
|
38
|
+
return item.data;
|
|
49
39
|
});
|
|
50
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
51
40
|
return ids.map(id => {
|
|
52
41
|
return items.filter(item => {
|
|
53
42
|
return id === item.id;
|
|
54
43
|
});
|
|
55
44
|
});
|
|
56
45
|
}, {
|
|
57
|
-
batchScheduleFn:
|
|
46
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
58
47
|
});
|
|
59
48
|
};
|
|
60
|
-
exports.createGetRevisionById = createGetRevisionById;
|
|
61
49
|
|
|
62
50
|
//# sourceMappingURL=getRevisionById.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","items","execute","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 { 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 } = 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 items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,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;EAAO,CAAC,GAAGF,MAAM;EAEjC,OAAO,IAAIN,UAAU,CACjB,MAAMS,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGH,MAAM,CAACI,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGd,kBAAkB,CAAC;QACpCO,MAAM;QACNM;MACJ,CAAC,CAAC;MACF,MAAM;QAAEE;MAAQ,CAAC,GAAGb,eAAe,CAACW,EAAE,CAAC;MACvC,IAAIE,OAAO,KAAK,IAAI,EAAE;QAClB;MACJ;MACA,MAAMC,OAAO,GAAGf,qBAAqB,CAAC;QAClCc;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,KAAK,GAAG,CAAC,MAAMd,MAAM,CAACe,OAAO,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI,IAAI;MAC/C,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOnB,GAAG,CAACiB,GAAG,CAACZ,EAAE,IAAI;MACjB,OAAOU,KAAK,CAACK,MAAM,CAACF,IAAI,IAAI;QACxB,OAAOb,EAAE,KAAKa,IAAI,CAACb,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIgB,eAAe,EAAE1B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import DataLoader from "dataloader";
|
|
2
|
-
import {
|
|
3
|
-
export * from "./DataLoaderCache";
|
|
1
|
+
import type DataLoader from "dataloader";
|
|
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
|
-
export
|
|
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,5 @@
|
|
|
1
|
-
import {
|
|
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
|
-
locale: string;
|
|
6
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {
|
|
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}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from "../../types.js";
|
|
3
|
+
import type { IEntryEntity } from "../../definitions/types.js";
|
|
4
4
|
interface DataLoaderParams {
|
|
5
|
-
model: Pick<CmsModel, "tenant" | "
|
|
5
|
+
model: Pick<CmsModel, "tenant" | "modelId">;
|
|
6
6
|
ids: readonly string[];
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
9
|
-
entity:
|
|
8
|
+
interface IDataLoadersHandlerParams {
|
|
9
|
+
entity: IEntryEntity;
|
|
10
10
|
}
|
|
11
11
|
export interface ClearAllParams {
|
|
12
|
-
model: Pick<CmsModel, "tenant" | "
|
|
12
|
+
model: Pick<CmsModel, "tenant" | "modelId">;
|
|
13
13
|
}
|
|
14
|
-
export declare class DataLoadersHandler implements
|
|
14
|
+
export declare class DataLoadersHandler implements IDataLoadersHandler {
|
|
15
15
|
private readonly entity;
|
|
16
16
|
private readonly cache;
|
|
17
|
-
constructor(params:
|
|
18
|
-
getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
19
|
-
getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
20
|
-
getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
21
|
-
getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
|
|
17
|
+
constructor(params: IDataLoadersHandlerParams);
|
|
18
|
+
getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
19
|
+
getRevisionById<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
20
|
+
getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
21
|
+
getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
|
|
22
22
|
/**
|
|
23
23
|
* TODO @ts-refactor
|
|
24
24
|
* Maybe pass on the generics to DataLoader definition?
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.DataLoadersHandler = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _DataLoaderCache = require("./dataLoader/DataLoaderCache");
|
|
10
|
-
var _dataLoader = require("./dataLoader");
|
|
11
|
-
var _utils = require("@webiny/utils");
|
|
12
|
-
class DataLoadersHandler {
|
|
13
|
-
cache = new _DataLoaderCache.DataLoaderCache();
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
|
|
3
|
+
import { getDataLoaderFactory } from "./dataLoader/index.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
export class DataLoadersHandler {
|
|
6
|
+
cache = new DataLoaderCache();
|
|
14
7
|
constructor(params) {
|
|
15
8
|
this.entity = params.entity;
|
|
16
9
|
}
|
|
@@ -18,7 +11,7 @@ class DataLoadersHandler {
|
|
|
18
11
|
const ids = params.ids.map(id => {
|
|
19
12
|
const {
|
|
20
13
|
id: entryId
|
|
21
|
-
} =
|
|
14
|
+
} = parseIdentifier(id);
|
|
22
15
|
return entryId;
|
|
23
16
|
});
|
|
24
17
|
return await this.loadMany("getAllEntryRevisions", params, ids);
|
|
@@ -30,7 +23,7 @@ class DataLoadersHandler {
|
|
|
30
23
|
const ids = params.ids.map(id => {
|
|
31
24
|
const {
|
|
32
25
|
id: entryId
|
|
33
|
-
} =
|
|
26
|
+
} = parseIdentifier(id);
|
|
34
27
|
return entryId;
|
|
35
28
|
});
|
|
36
29
|
return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
|
|
@@ -39,7 +32,7 @@ class DataLoadersHandler {
|
|
|
39
32
|
const ids = params.ids.map(id => {
|
|
40
33
|
const {
|
|
41
34
|
id: entryId
|
|
42
|
-
} =
|
|
35
|
+
} = parseIdentifier(id);
|
|
43
36
|
return entryId;
|
|
44
37
|
});
|
|
45
38
|
return await this.loadMany("getLatestRevisionByEntryId", params, ids);
|
|
@@ -55,18 +48,16 @@ class DataLoadersHandler {
|
|
|
55
48
|
} = params;
|
|
56
49
|
const cacheParams = {
|
|
57
50
|
tenant: model.tenant,
|
|
58
|
-
locale: model.locale,
|
|
59
51
|
name
|
|
60
52
|
};
|
|
61
53
|
let loader = this.cache.getDataLoader(cacheParams);
|
|
62
54
|
if (loader) {
|
|
63
55
|
return loader;
|
|
64
56
|
}
|
|
65
|
-
const factory =
|
|
57
|
+
const factory = getDataLoaderFactory(name);
|
|
66
58
|
loader = factory({
|
|
67
59
|
entity: this.entity,
|
|
68
|
-
tenant: model.tenant
|
|
69
|
-
locale: model.locale
|
|
60
|
+
tenant: model.tenant
|
|
70
61
|
});
|
|
71
62
|
this.cache.setDataLoader(cacheParams, loader);
|
|
72
63
|
return loader;
|
|
@@ -79,12 +70,12 @@ class DataLoadersHandler {
|
|
|
79
70
|
return results.reduce((acc, res) => {
|
|
80
71
|
if (Array.isArray(res) === false) {
|
|
81
72
|
if (res && res.message) {
|
|
82
|
-
throw new
|
|
73
|
+
throw new WebinyError(res.message, res.code, {
|
|
83
74
|
...res,
|
|
84
75
|
data: JSON.stringify(res.data || {})
|
|
85
76
|
});
|
|
86
77
|
}
|
|
87
|
-
throw new
|
|
78
|
+
throw new WebinyError("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
|
|
88
79
|
...params,
|
|
89
80
|
loader
|
|
90
81
|
});
|
|
@@ -94,14 +85,14 @@ class DataLoadersHandler {
|
|
|
94
85
|
}, []);
|
|
95
86
|
}
|
|
96
87
|
} catch (ex) {
|
|
97
|
-
throw new
|
|
88
|
+
throw new WebinyError(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
|
|
98
89
|
error: ex,
|
|
99
90
|
...params,
|
|
100
91
|
loader,
|
|
101
92
|
ids
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
throw new
|
|
95
|
+
throw new WebinyError(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
|
|
105
96
|
loader,
|
|
106
97
|
ids,
|
|
107
98
|
results
|
|
@@ -111,6 +102,5 @@ class DataLoadersHandler {
|
|
|
111
102
|
this.cache.clearAll(params?.model);
|
|
112
103
|
}
|
|
113
104
|
}
|
|
114
|
-
exports.DataLoadersHandler = DataLoadersHandler;
|
|
115
105
|
|
|
116
106
|
//# sourceMappingURL=dataLoaders.js.map
|