@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.
Files changed (157) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -6
  3. package/definitions/entry.js +5 -180
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -6
  6. package/definitions/group.js +5 -58
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -6
  9. package/definitions/model.js +5 -102
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +3 -5
  12. package/definitions/table.js +6 -28
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +61 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +1 -1
  18. package/dynamoDb/index.js +4 -13
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/path/locationFolderId.d.ts +1 -1
  21. package/dynamoDb/path/locationFolderId.js +5 -14
  22. package/dynamoDb/path/locationFolderId.js.map +1 -1
  23. package/dynamoDb/path/plainObject.d.ts +1 -1
  24. package/dynamoDb/path/plainObject.js +5 -14
  25. package/dynamoDb/path/plainObject.js.map +1 -1
  26. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  27. package/dynamoDb/transformValue/datetime.js +5 -12
  28. package/dynamoDb/transformValue/datetime.js.map +1 -1
  29. package/index.d.ts +2 -3
  30. package/index.js +62 -92
  31. package/index.js.map +1 -1
  32. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
  33. package/operations/entry/dataLoader/DataLoaderCache.js +3 -13
  34. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  35. package/operations/entry/dataLoader/constants.js +1 -7
  36. package/operations/entry/dataLoader/constants.js.map +1 -1
  37. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  38. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  39. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  40. package/operations/entry/dataLoader/getAllEntryRevisions.js +16 -26
  41. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  42. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  43. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -33
  44. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  45. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  46. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -33
  47. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  48. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  49. package/operations/entry/dataLoader/getRevisionById.js +29 -35
  50. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  51. package/operations/entry/dataLoader/index.d.ts +3 -3
  52. package/operations/entry/dataLoader/index.js +10 -31
  53. package/operations/entry/dataLoader/index.js.map +1 -1
  54. package/operations/entry/dataLoader/types.d.ts +4 -4
  55. package/operations/entry/dataLoader/types.js +1 -5
  56. package/operations/entry/dataLoader/types.js.map +1 -1
  57. package/operations/entry/dataLoaders.d.ts +11 -12
  58. package/operations/entry/dataLoaders.js +16 -24
  59. package/operations/entry/dataLoaders.js.map +1 -1
  60. package/operations/entry/filtering/createExpressions.d.ts +7 -6
  61. package/operations/entry/filtering/createExpressions.js +29 -35
  62. package/operations/entry/filtering/createExpressions.js.map +1 -1
  63. package/operations/entry/filtering/createFields.d.ts +2 -2
  64. package/operations/entry/filtering/createFields.js +20 -22
  65. package/operations/entry/filtering/createFields.js.map +1 -1
  66. package/operations/entry/filtering/extractSort.d.ts +5 -5
  67. package/operations/entry/filtering/extractSort.js +38 -23
  68. package/operations/entry/filtering/extractSort.js.map +1 -1
  69. package/operations/entry/filtering/filter.d.ts +7 -6
  70. package/operations/entry/filtering/filter.js +22 -27
  71. package/operations/entry/filtering/filter.js.map +1 -1
  72. package/operations/entry/filtering/fullTextSearch.d.ts +4 -4
  73. package/operations/entry/filtering/fullTextSearch.js +7 -15
  74. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  75. package/operations/entry/filtering/getValue.js +1 -8
  76. package/operations/entry/filtering/getValue.js.map +1 -1
  77. package/operations/entry/filtering/index.d.ts +2 -2
  78. package/operations/entry/filtering/index.js +2 -19
  79. package/operations/entry/filtering/index.js.map +1 -1
  80. package/operations/entry/filtering/mapPlugins.d.ts +1 -1
  81. package/operations/entry/filtering/mapPlugins.js +3 -11
  82. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  83. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
  84. package/operations/entry/filtering/plugins/defaultFilterCreate.js +10 -18
  85. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  86. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  87. package/operations/entry/filtering/plugins/index.js +6 -13
  88. package/operations/entry/filtering/plugins/index.js.map +1 -1
  89. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
  90. package/operations/entry/filtering/plugins/objectFilterCreate.js +15 -21
  91. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  92. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -2
  93. package/operations/entry/filtering/plugins/refFilterCreate.js +16 -22
  94. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  95. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +1 -1
  96. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +14 -17
  97. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
  98. package/operations/entry/filtering/sort.d.ts +5 -5
  99. package/operations/entry/filtering/sort.js +15 -19
  100. package/operations/entry/filtering/sort.js.map +1 -1
  101. package/operations/entry/filtering/systemFields.d.ts +2 -4
  102. package/operations/entry/filtering/systemFields.js +70 -29
  103. package/operations/entry/filtering/systemFields.js.map +1 -1
  104. package/operations/entry/filtering/transform.d.ts +1 -1
  105. package/operations/entry/filtering/transform.js +1 -8
  106. package/operations/entry/filtering/transform.js.map +1 -1
  107. package/operations/entry/filtering/types.d.ts +4 -4
  108. package/operations/entry/filtering/types.js +1 -5
  109. package/operations/entry/filtering/types.js.map +1 -1
  110. package/operations/entry/filtering/values.d.ts +1 -1
  111. package/operations/entry/filtering/values.js +4 -12
  112. package/operations/entry/filtering/values.js.map +1 -1
  113. package/operations/entry/filtering/where.js +1 -8
  114. package/operations/entry/filtering/where.js.map +1 -1
  115. package/operations/entry/index.d.ts +4 -3
  116. package/operations/entry/index.js +279 -388
  117. package/operations/entry/index.js.map +1 -1
  118. package/operations/entry/keys.d.ts +40 -2
  119. package/operations/entry/keys.js +53 -30
  120. package/operations/entry/keys.js.map +1 -1
  121. package/operations/group/index.d.ts +4 -5
  122. package/operations/group/index.js +37 -69
  123. package/operations/group/index.js.map +1 -1
  124. package/operations/model/index.d.ts +3 -3
  125. package/operations/model/index.js +36 -59
  126. package/operations/model/index.js.map +1 -1
  127. package/package.json +24 -20
  128. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
  129. package/plugins/CmsEntryFieldFilterPathPlugin.js +4 -12
  130. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  131. package/plugins/CmsEntryFieldFilterPlugin.d.ts +5 -5
  132. package/plugins/CmsEntryFieldFilterPlugin.js +2 -8
  133. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  134. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  135. package/plugins/CmsEntryFieldSortingPlugin.js +3 -11
  136. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  137. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +1 -1
  138. package/plugins/CmsFieldFilterValueTransformPlugin.js +2 -9
  139. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
  140. package/plugins/index.d.ts +4 -4
  141. package/plugins/index.js +4 -49
  142. package/plugins/index.js.map +1 -1
  143. package/types.d.ts +20 -20
  144. package/types.js +1 -8
  145. package/types.js.map +1 -1
  146. package/definitions/system.d.ts +0 -10
  147. package/definitions/system.js +0 -42
  148. package/definitions/system.js.map +0 -1
  149. package/dynamoDb/storage/longText.d.ts +0 -10
  150. package/dynamoDb/storage/longText.js +0 -94
  151. package/dynamoDb/storage/longText.js.map +0 -1
  152. package/dynamoDb/storage/richText.d.ts +0 -2
  153. package/dynamoDb/storage/richText.js +0 -61
  154. package/dynamoDb/storage/richText.js.map +0 -1
  155. package/operations/system/index.d.ts +0 -7
  156. package/operations/system/index.js +0 -94
  157. package/operations/system/index.js.map +0 -1
@@ -1,45 +1,35 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
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
- locale,
17
- tenant
7
+ tenant,
8
+ modelId
18
9
  } = params;
19
- return new _dataloader.default(async ids => {
10
+ return new DataLoader(async ids => {
20
11
  const results = {};
21
12
  for (const id of ids) {
22
- const queryAllParams = {
23
- entity,
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
- const items = await (0, _query.queryAll)(queryAllParams);
34
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
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: (0, _createBatchScheduleFn.createBatchScheduleFn)()
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":["_dataloader","_interopRequireDefault","require","_query","_keys","_cleanup","_createBatchScheduleFn","createGetAllEntryRevisions","params","entity","locale","tenant","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { createPartitionKey } from \"~/operations/entry/keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetAllEntryRevisions = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAEO,MAAMK,0BAA0B,GAAIC,MAAwB,IAAK;EACpE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCP,MAAM;QACNQ,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BP,MAAM;UACND,MAAM;UACNK;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAkBN,cAAc,CAAC;MAC7DF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACd,MAAM,EAAEY,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACT,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,EACD;IACIU,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAApB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
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 { DataLoaderParams } from "./types";
4
- export declare const createGetLatestRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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
- locale,
18
- tenant
9
+ tenant,
10
+ modelId
19
11
  } = params;
20
- const latestKey = (0, _keys.createLatestSortKey)();
21
- return new _dataloader.default(async ids => {
22
- const queries = ids.reduce((collection, id) => {
23
- const partitionKey = (0, _keys.createPartitionKey)({
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 (collection[partitionKey]) {
29
- return collection;
21
+ if (keys.has(partitionKey)) {
22
+ continue;
30
23
  }
31
- collection[partitionKey] = entity.getBatch({
24
+ keys.add(partitionKey);
25
+ reader.get({
32
26
  PK: partitionKey,
33
27
  SK: latestKey
34
28
  });
35
- return collection;
36
- }, {});
37
- const records = await (0, _dbDynamodb.batchReadAll)({
38
- table: entity.table,
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
- } = (0, _utils.parseIdentifier)(id);
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: (0, _createBatchScheduleFn.createBatchScheduleFn)()
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":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_createBatchScheduleFn","_keys","_utils","createGetLatestRevisionByEntryId","params","entity","locale","tenant","latestKey","createLatestSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, any>>((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n }, {});\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,KAA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IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAhC,gCAAA,GAAAA,gCAAA","ignoreList":[]}
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,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AI,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 { DataLoaderParams } from "./types";
4
- export declare const createGetPublishedRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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
- locale,
18
- tenant
9
+ tenant,
10
+ modelId
19
11
  } = params;
20
- const publishedKey = (0, _keys.createPublishedSortKey)();
21
- return new _dataloader.default(async ids => {
22
- const queries = ids.reduce((collection, id) => {
23
- const partitionKey = (0, _keys.createPartitionKey)({
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 (collection[partitionKey]) {
29
- return collection;
21
+ if (keys.has(partitionKey)) {
22
+ continue;
30
23
  }
31
- collection[partitionKey] = entity.getBatch({
24
+ keys.add(partitionKey);
25
+ reader.get({
32
26
  PK: partitionKey,
33
27
  SK: publishedKey
34
28
  });
35
- return collection;
36
- }, {});
37
- const records = await (0, _dbDynamodb.batchReadAll)({
38
- table: entity.table,
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
- } = (0, _utils.parseIdentifier)(id);
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: (0, _createBatchScheduleFn.createBatchScheduleFn)()
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":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","locale","tenant","publishedKey","createPublishedSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetPublishedRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,mCAAmC,GAAIC,MAAwB,IAAK;EAC7E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,MAAMI,YAAY,GAAG,IAAAC,4BAAsB,EAAC,CAAC;EAC7C,OAAO,IAAIC,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCV,MAAM;QACND,MAAM;QACNS;MACJ,CAAC,CAAC;MACF,IAAID,UAAU,CAACE,YAAY,CAAC,EAAE;QAC1B,OAAOF,UAAU;MACrB;MACAA,UAAU,CAACE,YAAY,CAAC,GAAGX,MAAM,CAACa,QAAQ,CAAC;QACvCC,EAAE,EAAEH,YAAY;QAChBI,EAAE,EAAEZ;MACR,CAAC,CAAC;MACF,OAAOM,UAAU;IACrB,CAAC,EACD,CAAC,CACL,CAAC;IAED,MAAMO,OAAO,GAAG,MAAM,IAAAC,wBAAY,EAAkB;MAChDC,KAAK,EAAElB,MAAM,CAACkB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACd,OAAO;IAChC,CAAC,CAAC;IACF,MAAMY,KAAK,GAAG,IAAAG,qBAAY,EAACtB,MAAM,EAAEgB,OAAO,CAAC;IAE3C,OAAOV,GAAG,CAACiB,GAAG,CAACb,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEc;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACf,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACO,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOH,OAAO,KAAKG,IAAI,CAACH,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACII,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAhC,mCAAA,GAAAA,mCAAA","ignoreList":[]}
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;EA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,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetRevisionById: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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
- locale,
18
- tenant
9
+ tenant,
10
+ modelId
19
11
  } = params;
20
- return new _dataloader.default(async ids => {
21
- const queries = ids.reduce((collection, id) => {
22
- const partitionKey = (0, _keys.createPartitionKey)({
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
- } = (0, _utils.parseIdentifier)(id);
22
+ } = parseIdentifier(id);
30
23
  if (version === null) {
31
- return collection;
24
+ continue;
32
25
  }
33
- const sortKey = (0, _keys.createRevisionSortKey)({
26
+ const sortKey = createRevisionSortKey({
34
27
  version
35
28
  });
36
- const keys = `${partitionKey}__${sortKey}`;
37
- if (collection[keys]) {
38
- return collection;
29
+ const key = `${partitionKey}__${sortKey}`;
30
+ if (keys.has(key)) {
31
+ continue;
39
32
  }
40
- collection[keys] = entity.getBatch({
33
+ keys.add(key);
34
+ reader.get({
41
35
  PK: partitionKey,
42
36
  SK: sortKey
43
37
  });
44
- return collection;
45
- }, {});
46
- const records = await (0, _dbDynamodb.batchReadAll)({
47
- table: entity.table,
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: (0, _createBatchScheduleFn.createBatchScheduleFn)()
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":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetRevisionById","params","entity","locale","tenant","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetRevisionById = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,qBAAqB,GAAIC,MAAwB,IAAK;EAC/D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAE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ionSortKey","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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AC,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 { DataLoaderParams } from "./types";
3
- export * from "./DataLoaderCache";
2
+ import type { IDataLoaderParams } from "./types.js";
3
+ export * from "./DataLoaderCache.js";
4
4
  interface Callable {
5
- (params: DataLoaderParams): DataLoader<any, any>;
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- getDataLoaderFactory: true
8
- };
9
- exports.getDataLoaderFactory = void 0;
10
- var _getAllEntryRevisions = require("./getAllEntryRevisions");
11
- var _getLatestRevisionByEntryId = require("./getLatestRevisionByEntryId");
12
- var _getPublishedRevisionByEntryId = require("./getPublishedRevisionByEntryId");
13
- var _getRevisionById = require("./getRevisionById");
14
- var _DataLoaderCache = require("./DataLoaderCache");
15
- Object.keys(_DataLoaderCache).forEach(function (key) {
16
- if (key === "default" || key === "__esModule") return;
17
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
- if (key in exports && exports[key] === _DataLoaderCache[key]) return;
19
- Object.defineProperty(exports, key, {
20
- enumerable: true,
21
- get: function () {
22
- return _DataLoaderCache[key];
23
- }
24
- });
25
- });
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: _getAllEntryRevisions.createGetAllEntryRevisions,
28
- getLatestRevisionByEntryId: _getLatestRevisionByEntryId.createGetLatestRevisionByEntryId,
29
- getPublishedRevisionByEntryId: _getPublishedRevisionByEntryId.createGetPublishedRevisionByEntryId,
30
- getRevisionById: _getRevisionById.createGetRevisionById
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":["_getAllEntryRevisions","require","_getLatestRevisionByEntryId","_getPublishedRevisionByEntryId","_getRevisionById","_DataLoaderCache","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","dataLoaders","getAllEntryRevisions","createGetAllEntryRevisions","getLatestRevisionByEntryId","createGetLatestRevisionByEntryId","getPublishedRevisionByEntryId","createGetPublishedRevisionByEntryId","getRevisionById","createGetRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId\";\nimport { createGetRevisionById } from \"./getRevisionById\";\n\nexport * from \"./DataLoaderCache\";\n\ninterface Callable {\n (params: DataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAMA,MAAMS,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEC,gDAA0B;EAChDC,0BAA0B,EAAEC,4DAAgC;EAC5DC,6BAA6B,EAAEC,kEAAmC;EAClEC,eAAe,EAAEC;AACrB,CAAC;AAQM,MAAMC,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACV,WAAW,CAACU,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,CAAC,wBAAwBD,IAAI,IAAI,CAAC;EACrD;EACA,OAAOV,WAAW,CAACU,IAAI,CAAC;AAC5B,CAAC;AAACd,OAAA,CAAAa,oBAAA,GAAAA,oBAAA","ignoreList":[]}
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 { Entity } from "@webiny/db-dynamodb/toolbox";
2
- export interface DataLoaderParams {
3
- entity: Entity<any>;
1
+ import type { IEntryEntity } from "../../../definitions/types.js";
2
+ export interface IDataLoaderParams {
3
+ entity: IEntryEntity;
4
4
  tenant: string;
5
- locale: string;
5
+ modelId: string;
6
6
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\nexport interface DataLoaderParams {\n entity: Entity<any>;\n tenant: string;\n locale: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"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 { Entity } from "@webiny/db-dynamodb/toolbox";
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" | "locale" | "modelId">;
4
+ model: Pick<CmsModel, "tenant" | "modelId">;
6
5
  ids: readonly string[];
7
6
  }
8
- interface DataLoadersHandlerParams {
9
- entity: Entity<any>;
7
+ interface IDataLoadersHandlerParams {
8
+ entity: IEntryEntity;
10
9
  }
11
- export declare class DataLoadersHandler implements DataLoadersHandlerInterface {
10
+ export declare class DataLoadersHandler implements IDataLoadersHandler {
12
11
  private readonly entity;
13
12
  private readonly cache;
14
- constructor(params: DataLoadersHandlerParams);
15
- getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
16
- getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
17
- getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
18
- getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
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?