@webiny/api-headless-cms-ddb 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.js +7 -9
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +7 -9
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +7 -9
- package/definitions/model.js.map +1 -1
- package/definitions/table.js +6 -7
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +11 -5
- package/definitions/types.js +0 -3
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +6 -3
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.js +16 -29
- package/dynamoDb/path/locationFolderId.js.map +1 -1
- package/dynamoDb/path/plainObject.js +11 -21
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/transformValue/datetime.js +21 -32
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +74 -79
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +22 -29
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -1
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -26
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +32 -38
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +32 -38
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +34 -44
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js +8 -9
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -0
- package/operations/entry/dataLoader/types.js +0 -3
- package/operations/entry/dataLoaders.js +81 -97
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +6 -5
- package/operations/entry/filtering/createExpressions.js +110 -161
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.js +83 -96
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.js +50 -74
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +5 -4
- package/operations/entry/filtering/filter.js +73 -138
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +2 -2
- package/operations/entry/filtering/fullTextSearch.js +21 -38
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +31 -53
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.js +0 -2
- package/operations/entry/filtering/mapPlugins.js +15 -22
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +29 -33
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.js +7 -3
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +60 -76
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +55 -66
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +43 -51
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
- package/operations/entry/filtering/sort.js +34 -60
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.js +144 -111
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.js +4 -8
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +2 -2
- package/operations/entry/filtering/types.js +0 -3
- package/operations/entry/filtering/values.js +11 -12
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +17 -23
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +2 -0
- package/operations/entry/index.js +896 -1149
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +6 -0
- package/operations/entry/keys.js +57 -77
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +2 -3
- package/operations/group/index.js +115 -139
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +100 -122
- package/operations/model/index.js.map +1 -1
- package/package.json +27 -19
- package/plugins/CmsEntryFieldFilterPathPlugin.js +23 -33
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFieldFilterPlugin.js +16 -17
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.js +16 -15
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.js +15 -12
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
- package/plugins/index.js +0 -2
- package/types.d.ts +5 -3
- package/types.js +6 -5
- package/types.js.map +1 -1
- package/definitions/types.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -86
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -52
- package/dynamoDb/storage/richText.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/types.js.map +0 -1
- package/plugins/index.js.map +0 -1
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return this.cache[key] || null;
|
|
6
|
-
}
|
|
7
|
-
setDataLoader(params, dataLoader) {
|
|
8
|
-
const key = this.createKey(params);
|
|
9
|
-
this.cache[key] = dataLoader;
|
|
10
|
-
}
|
|
11
|
-
clearAll(params) {
|
|
12
|
-
if (!params) {
|
|
13
|
-
for (const current in this.cache) {
|
|
14
|
-
this.cache[current].clearAll();
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
1
|
+
class DataLoaderCache {
|
|
2
|
+
getDataLoader(params) {
|
|
3
|
+
const key = this.createKey(params);
|
|
4
|
+
return this.cache[key] || null;
|
|
17
5
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
setDataLoader(params, dataLoader) {
|
|
7
|
+
const key = this.createKey(params);
|
|
8
|
+
this.cache[key] = dataLoader;
|
|
9
|
+
}
|
|
10
|
+
clearAll(params) {
|
|
11
|
+
if (!params) {
|
|
12
|
+
for(const current in this.cache)this.cache[current].clearAll();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const key = `${params.tenant}_`;
|
|
16
|
+
for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
|
|
17
|
+
}
|
|
18
|
+
createKey(params) {
|
|
19
|
+
return `${params.tenant}_${params.modelId}_${params.name}`;
|
|
20
|
+
}
|
|
21
|
+
constructor(){
|
|
22
|
+
this.cache = {};
|
|
27
23
|
}
|
|
28
|
-
}
|
|
29
|
-
createKey(params) {
|
|
30
|
-
return `${params.tenant}_${params.name}`;
|
|
31
|
-
}
|
|
32
24
|
}
|
|
25
|
+
export { DataLoaderCache };
|
|
33
26
|
|
|
34
27
|
//# sourceMappingURL=DataLoaderCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
|
|
2
|
-
|
|
2
|
+
const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
|
|
3
|
+
export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* https://github.com/graphql/dataloader#batch-scheduling
|
|
9
|
-
*/
|
|
10
|
-
export const createBatchScheduleFn = () => {
|
|
11
|
-
if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
return callback => {
|
|
15
|
-
setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
|
|
16
|
-
};
|
|
2
|
+
const createBatchScheduleFn = ()=>{
|
|
3
|
+
if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) return;
|
|
4
|
+
return (callback)=>{
|
|
5
|
+
setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
|
|
6
|
+
};
|
|
17
7
|
};
|
|
8
|
+
export { createBatchScheduleFn };
|
|
18
9
|
|
|
19
10
|
//# sourceMappingURL=createBatchScheduleFn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/createBatchScheduleFn.js","sources":["../../../../src/operations/entry/dataLoader/createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants.js\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"names":["createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","callback","setTimeout"],"mappings":";AASO,MAAMA,wBAAwB;IACjC,IAAIC,iCAAiC,GACjC;IAEJ,OAAO,CAACC;QACJC,WAAWD,UAAUD;IACzB;AACJ"}
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
2
|
import { createPartitionKey } from "../keys.js";
|
|
3
3
|
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})).map(result => {
|
|
21
|
-
return result.data;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return ids.map(id => {
|
|
25
|
-
return results[id] || [];
|
|
4
|
+
const createGetAllEntryRevisions = (params)=>{
|
|
5
|
+
const { entity, tenant, modelId } = params;
|
|
6
|
+
return new dataloader(async (ids)=>{
|
|
7
|
+
const results = {};
|
|
8
|
+
for (const id of ids)results[id] = (await entity.queryAllClean({
|
|
9
|
+
partitionKey: createPartitionKey({
|
|
10
|
+
tenant,
|
|
11
|
+
id
|
|
12
|
+
}),
|
|
13
|
+
options: {
|
|
14
|
+
beginsWith: "REV#"
|
|
15
|
+
}
|
|
16
|
+
})).map((result)=>result.data);
|
|
17
|
+
return ids.map((id)=>(results[id] || []).filter((item)=>item.modelId === modelId));
|
|
18
|
+
}, {
|
|
19
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
26
20
|
});
|
|
27
|
-
}, {
|
|
28
|
-
batchScheduleFn: createBatchScheduleFn()
|
|
29
|
-
});
|
|
30
21
|
};
|
|
22
|
+
export { createGetAllEntryRevisions };
|
|
31
23
|
|
|
32
24
|
//# sourceMappingURL=getAllEntryRevisions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getAllEntryRevisions.js","sources":["../../../../src/operations/entry/dataLoader/getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(result => {\n return result.data;\n });\n }\n\n return ids.map(id => {\n return (results[id] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetAllEntryRevisions","params","entity","tenant","modelId","DataLoader","ids","results","id","createPartitionKey","result","item","createBatchScheduleFn"],"mappings":";;;AAMO,MAAMA,6BAA6B,CAACC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IACpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,UAA6C,CAAC;QAEpD,KAAK,MAAMC,MAAMF,IACbC,OAAO,CAACC,GAAG,GACP,OAAMN,OAAO,aAAa,CAAC;YACvB,cAAcO,mBAAmB;gBAC7BN;gBACAK;YACJ;YACA,SAAS;gBACL,YAAY;YAChB;QACJ,EAAC,EACH,GAAG,CAACE,CAAAA,SACKA,OAAO,IAAI;QAI1B,OAAOJ,IAAI,GAAG,CAACE,CAAAA,KACHD,AAAAA,CAAAA,OAAO,CAACC,GAAG,IAAI,EAAC,EAAG,MAAM,CAACG,CAAAA,OACvBA,KAAK,OAAO,KAAKP;IAGpC,GACA;QACI,iBAAiBQ;IACrB;AAER"}
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
2
|
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
3
|
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
4
4
|
import { createLatestSortKey, createPartitionKey } from "../keys.js";
|
|
5
5
|
import { parseIdentifier } from "@webiny/utils";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
const createGetLatestRevisionByEntryId = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
const latestKey = createLatestSortKey();
|
|
9
|
+
return new dataloader(async (ids)=>{
|
|
10
|
+
const reader = entity.createEntityReader();
|
|
11
|
+
const keys = new Set();
|
|
12
|
+
for (const id of ids){
|
|
13
|
+
const partitionKey = createPartitionKey({
|
|
14
|
+
tenant,
|
|
15
|
+
id
|
|
16
|
+
});
|
|
17
|
+
if (!keys.has(partitionKey)) {
|
|
18
|
+
keys.add(partitionKey);
|
|
19
|
+
reader.get({
|
|
20
|
+
PK: partitionKey,
|
|
21
|
+
SK: latestKey
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const records = await reader.execute();
|
|
26
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
27
|
+
return ids.map((id)=>{
|
|
28
|
+
const { id: entryId } = parseIdentifier(id);
|
|
29
|
+
return items.filter((item)=>{
|
|
30
|
+
if (item.modelId !== modelId) return false;
|
|
31
|
+
return entryId === item.entryId;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
32
36
|
});
|
|
33
|
-
return ids.map(id => {
|
|
34
|
-
const {
|
|
35
|
-
id: entryId
|
|
36
|
-
} = parseIdentifier(id);
|
|
37
|
-
return items.filter(item => {
|
|
38
|
-
return entryId === item.entryId;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
42
|
-
batchScheduleFn: createBatchScheduleFn()
|
|
43
|
-
});
|
|
44
37
|
};
|
|
38
|
+
export { createGetLatestRevisionByEntryId };
|
|
45
39
|
|
|
46
40
|
//# sourceMappingURL=getLatestRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getLatestRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","createLatestSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","records","items","cleanupItems","item","entryId","parseIdentifier","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,mCAAmC,CAACC;IAC7C,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,YAAYC;IAElB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBAETJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,UAAU,MAAMN,OAAO,OAAO;QACpC,MAAMO,QAAQC,aAAaf,OAAO,MAAM,EAAEa,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOV,IAAI,GAAG,CAACI,CAAAA;YACX,MAAM,EAAE,IAAIO,OAAO,EAAE,GAAGC,gBAAgBR;YACxC,OAAOI,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKd,SACjB,OAAO;gBAEX,OAAOe,YAAYD,KAAK,OAAO;YACnC;QACJ;IACJ,GACA;QACI,iBAAiBG;IACrB;AAER"}
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
2
|
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
3
|
import { createPartitionKey, createPublishedSortKey } from "../keys.js";
|
|
4
4
|
import { parseIdentifier } from "@webiny/utils";
|
|
5
5
|
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
const createGetPublishedRevisionByEntryId = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
const publishedKey = createPublishedSortKey();
|
|
9
|
+
return new dataloader(async (ids)=>{
|
|
10
|
+
const reader = entity.createEntityReader();
|
|
11
|
+
const keys = new Set();
|
|
12
|
+
for (const id of ids){
|
|
13
|
+
const partitionKey = createPartitionKey({
|
|
14
|
+
tenant,
|
|
15
|
+
id
|
|
16
|
+
});
|
|
17
|
+
if (!keys.has(partitionKey)) {
|
|
18
|
+
keys.add(partitionKey);
|
|
19
|
+
reader.get({
|
|
20
|
+
PK: partitionKey,
|
|
21
|
+
SK: publishedKey
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const records = await reader.execute();
|
|
26
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
27
|
+
return ids.map((id)=>{
|
|
28
|
+
const { id: entryId } = parseIdentifier(id);
|
|
29
|
+
return items.filter((item)=>{
|
|
30
|
+
if (item.modelId !== modelId) return false;
|
|
31
|
+
return entryId === item.entryId;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
32
36
|
});
|
|
33
|
-
return ids.map(id => {
|
|
34
|
-
const {
|
|
35
|
-
id: entryId
|
|
36
|
-
} = parseIdentifier(id);
|
|
37
|
-
return items.filter(item => {
|
|
38
|
-
return entryId === item.entryId;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
42
|
-
batchScheduleFn: createBatchScheduleFn()
|
|
43
|
-
});
|
|
44
37
|
};
|
|
38
|
+
export { createGetPublishedRevisionByEntryId };
|
|
45
39
|
|
|
46
40
|
//# sourceMappingURL=getPublishedRevisionByEntryId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getPublishedRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/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"],"names":["createGetPublishedRevisionByEntryId","params","entity","tenant","modelId","publishedKey","createPublishedSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","records","items","cleanupItems","item","entryId","parseIdentifier","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,sCAAsC,CAACC;IAChD,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,eAAeC;IACrB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBACTJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,UAAU,MAAMN,OAAO,OAAO;QACpC,MAAMO,QAAQC,aAAaf,OAAO,MAAM,EAAEa,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOV,IAAI,GAAG,CAACI,CAAAA;YACX,MAAM,EAAE,IAAIO,OAAO,EAAE,GAAGC,gBAAgBR;YACxC,OAAOI,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKd,SACjB,OAAO;gBAEX,OAAOe,YAAYD,KAAK,OAAO;YACnC;QACJ;IACJ,GACA;QACI,iBAAiBG;IACrB;AAER"}
|
|
@@ -1,52 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dataloader from "dataloader";
|
|
2
2
|
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
|
|
3
3
|
import { createPartitionKey, createRevisionSortKey } from "../keys.js";
|
|
4
4
|
import { parseIdentifier } from "@webiny/utils";
|
|
5
5
|
import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const records = await reader.execute();
|
|
39
|
-
const items = cleanupItems(entity.entity, records).map(item => {
|
|
40
|
-
return item.data;
|
|
6
|
+
const createGetRevisionById = (params)=>{
|
|
7
|
+
const { entity, tenant, modelId } = params;
|
|
8
|
+
return new dataloader(async (ids)=>{
|
|
9
|
+
const reader = entity.createEntityReader();
|
|
10
|
+
const keys = new Set();
|
|
11
|
+
for (const id of ids){
|
|
12
|
+
const partitionKey = createPartitionKey({
|
|
13
|
+
tenant,
|
|
14
|
+
id
|
|
15
|
+
});
|
|
16
|
+
const { version } = parseIdentifier(id);
|
|
17
|
+
if (null === version) continue;
|
|
18
|
+
const sortKey = createRevisionSortKey({
|
|
19
|
+
version
|
|
20
|
+
});
|
|
21
|
+
const key = `${partitionKey}__${sortKey}`;
|
|
22
|
+
if (!keys.has(key)) {
|
|
23
|
+
keys.add(key);
|
|
24
|
+
reader.get({
|
|
25
|
+
PK: partitionKey,
|
|
26
|
+
SK: sortKey
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const records = await reader.execute();
|
|
31
|
+
const items = cleanupItems(entity.entity, records).map((item)=>item.data);
|
|
32
|
+
return ids.map((id)=>items.filter((item)=>{
|
|
33
|
+
if (item.modelId !== modelId) return false;
|
|
34
|
+
return id === item.id;
|
|
35
|
+
}));
|
|
36
|
+
}, {
|
|
37
|
+
batchScheduleFn: createBatchScheduleFn()
|
|
41
38
|
});
|
|
42
|
-
return ids.map(id => {
|
|
43
|
-
return items.filter(item => {
|
|
44
|
-
return id === item.id;
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}, {
|
|
48
|
-
batchScheduleFn: createBatchScheduleFn()
|
|
49
|
-
});
|
|
50
39
|
};
|
|
40
|
+
export { createGetRevisionById };
|
|
51
41
|
|
|
52
42
|
//# sourceMappingURL=getRevisionById.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/getRevisionById.js","sources":["../../../../src/operations/entry/dataLoader/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"],"names":["createGetRevisionById","params","entity","tenant","modelId","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","key","records","items","cleanupItems","item","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,SAASL,OAAO,kBAAkB;QAExC,MAAMM,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCT;gBACAO;YACJ;YACA,MAAM,EAAEG,OAAO,EAAE,GAAGC,gBAAgBJ;YACpC,IAAIG,AAAY,SAAZA,SACA;YAEJ,MAAME,UAAUC,sBAAsB;gBAClCH;YACJ;YACA,MAAMI,MAAM,GAAGN,aAAa,EAAE,EAAEI,SAAS;YACzC,KAAIP,KAAK,GAAG,CAACS;gBAGbT,KAAK,GAAG,CAACS;gBAETV,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAII;gBACR;;QACJ;QAEA,MAAMG,UAAU,MAAMX,OAAO,OAAO;QACpC,MAAMY,QAAQC,aAAalB,OAAO,MAAM,EAAEgB,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOf,IAAI,GAAG,CAACI,CAAAA,KACJS,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKjB,SACjB,OAAO;gBAEX,OAAOM,OAAOW,KAAK,EAAE;YACzB;IAER,GACA;QACI,iBAAiBC;IACrB;AAER"}
|
|
@@ -4,16 +4,15 @@ import { createGetPublishedRevisionByEntryId } from "./getPublishedRevisionByEnt
|
|
|
4
4
|
import { createGetRevisionById } from "./getRevisionById.js";
|
|
5
5
|
export * from "./DataLoaderCache.js";
|
|
6
6
|
const dataLoaders = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
getAllEntryRevisions: createGetAllEntryRevisions,
|
|
8
|
+
getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,
|
|
9
|
+
getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,
|
|
10
|
+
getRevisionById: createGetRevisionById
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return dataLoaders[name];
|
|
12
|
+
const getDataLoaderFactory = (name)=>{
|
|
13
|
+
if (!dataLoaders[name]) throw new Error(`Missing data loader "${name}".`);
|
|
14
|
+
return dataLoaders[name];
|
|
17
15
|
};
|
|
16
|
+
export { getDataLoaderFactory };
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/index.js","sources":["../../../../src/operations/entry/dataLoader/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"],"names":["dataLoaders","createGetAllEntryRevisions","createGetLatestRevisionByEntryId","createGetPublishedRevisionByEntryId","createGetRevisionById","getDataLoaderFactory","name","Error"],"mappings":";;;;;AAaA,MAAMA,cAAwC;IAC1C,sBAAsBC;IACtB,4BAA4BC;IAC5B,+BAA+BC;IAC/B,iBAAiBC;AACrB;AAQO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACN,WAAW,CAACM,KAAK,EAClB,MAAM,IAAIC,MAAM,CAAC,qBAAqB,EAAED,KAAK,EAAE,CAAC;IAEpD,OAAON,WAAW,CAACM,KAAK;AAC5B"}
|