@webiny/api-headless-cms-ddb 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b

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 (158) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -6
  3. package/definitions/entry.js +8 -185
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -6
  6. package/definitions/group.js +8 -63
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -6
  9. package/definitions/model.js +8 -107
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +3 -5
  12. package/definitions/table.js +6 -29
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/dynamoDb/index.d.ts +1 -1
  17. package/dynamoDb/index.js +7 -13
  18. package/dynamoDb/index.js.map +1 -1
  19. package/index.d.ts +2 -3
  20. package/index.js +85 -121
  21. package/index.js.map +1 -1
  22. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
  23. package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
  24. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  25. package/operations/entry/dataLoader/constants.js +2 -7
  26. package/operations/entry/dataLoader/constants.js.map +1 -1
  27. package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
  28. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  29. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  30. package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
  31. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  32. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  33. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +36 -52
  34. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  35. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  36. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +36 -52
  37. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  38. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  39. package/operations/entry/dataLoader/getRevisionById.js +38 -58
  40. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  41. package/operations/entry/dataLoader/index.d.ts +3 -3
  42. package/operations/entry/dataLoader/index.js +13 -35
  43. package/operations/entry/dataLoader/index.js.map +1 -1
  44. package/operations/entry/dataLoader/types.d.ts +4 -4
  45. package/operations/entry/dataLoader/types.js +0 -7
  46. package/operations/entry/dataLoaders.d.ts +11 -12
  47. package/operations/entry/dataLoaders.js +83 -109
  48. package/operations/entry/dataLoaders.js.map +1 -1
  49. package/operations/entry/index.d.ts +4 -3
  50. package/operations/entry/index.js +908 -1277
  51. package/operations/entry/index.js.map +1 -1
  52. package/operations/entry/keys.d.ts +46 -2
  53. package/operations/entry/keys.js +52 -49
  54. package/operations/entry/keys.js.map +1 -1
  55. package/operations/group/index.d.ts +4 -5
  56. package/operations/group/index.js +113 -166
  57. package/operations/group/index.js.map +1 -1
  58. package/operations/model/index.d.ts +3 -3
  59. package/operations/model/index.js +99 -143
  60. package/operations/model/index.js.map +1 -1
  61. package/package.json +29 -25
  62. package/plugins/index.d.ts +2 -4
  63. package/plugins/index.js +1 -51
  64. package/types.d.ts +19 -42
  65. package/types.js +6 -12
  66. package/types.js.map +1 -1
  67. package/definitions/system.d.ts +0 -10
  68. package/definitions/system.js +0 -42
  69. package/definitions/system.js.map +0 -1
  70. package/dynamoDb/path/locationFolderId.d.ts +0 -2
  71. package/dynamoDb/path/locationFolderId.js +0 -43
  72. package/dynamoDb/path/locationFolderId.js.map +0 -1
  73. package/dynamoDb/path/plainObject.d.ts +0 -2
  74. package/dynamoDb/path/plainObject.js +0 -35
  75. package/dynamoDb/path/plainObject.js.map +0 -1
  76. package/dynamoDb/storage/longText.d.ts +0 -10
  77. package/dynamoDb/storage/longText.js +0 -94
  78. package/dynamoDb/storage/longText.js.map +0 -1
  79. package/dynamoDb/storage/richText.d.ts +0 -2
  80. package/dynamoDb/storage/richText.js +0 -61
  81. package/dynamoDb/storage/richText.js.map +0 -1
  82. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  83. package/dynamoDb/transformValue/datetime.js +0 -47
  84. package/dynamoDb/transformValue/datetime.js.map +0 -1
  85. package/operations/entry/dataLoader/types.js.map +0 -1
  86. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  87. package/operations/entry/filtering/createExpressions.js +0 -178
  88. package/operations/entry/filtering/createExpressions.js.map +0 -1
  89. package/operations/entry/filtering/createFields.d.ts +0 -16
  90. package/operations/entry/filtering/createFields.js +0 -108
  91. package/operations/entry/filtering/createFields.js.map +0 -1
  92. package/operations/entry/filtering/extractSort.d.ts +0 -17
  93. package/operations/entry/filtering/extractSort.js +0 -69
  94. package/operations/entry/filtering/extractSort.js.map +0 -1
  95. package/operations/entry/filtering/filter.d.ts +0 -15
  96. package/operations/entry/filtering/filter.js +0 -158
  97. package/operations/entry/filtering/filter.js.map +0 -1
  98. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  99. package/operations/entry/filtering/fullTextSearch.js +0 -50
  100. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  101. package/operations/entry/filtering/getValue.d.ts +0 -5
  102. package/operations/entry/filtering/getValue.js +0 -66
  103. package/operations/entry/filtering/getValue.js.map +0 -1
  104. package/operations/entry/filtering/index.d.ts +0 -2
  105. package/operations/entry/filtering/index.js +0 -21
  106. package/operations/entry/filtering/index.js.map +0 -1
  107. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  108. package/operations/entry/filtering/mapPlugins.js +0 -33
  109. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  110. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  111. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -45
  112. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  113. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  114. package/operations/entry/filtering/plugins/index.js +0 -16
  115. package/operations/entry/filtering/plugins/index.js.map +0 -1
  116. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  117. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -90
  118. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  119. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
  120. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -80
  121. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  122. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
  123. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -65
  124. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
  125. package/operations/entry/filtering/sort.d.ts +0 -12
  126. package/operations/entry/filtering/sort.js +0 -71
  127. package/operations/entry/filtering/sort.js.map +0 -1
  128. package/operations/entry/filtering/systemFields.d.ts +0 -4
  129. package/operations/entry/filtering/systemFields.js +0 -90
  130. package/operations/entry/filtering/systemFields.js.map +0 -1
  131. package/operations/entry/filtering/transform.d.ts +0 -6
  132. package/operations/entry/filtering/transform.js +0 -18
  133. package/operations/entry/filtering/transform.js.map +0 -1
  134. package/operations/entry/filtering/types.d.ts +0 -40
  135. package/operations/entry/filtering/types.js +0 -7
  136. package/operations/entry/filtering/types.js.map +0 -1
  137. package/operations/entry/filtering/values.d.ts +0 -2
  138. package/operations/entry/filtering/values.js +0 -24
  139. package/operations/entry/filtering/values.js.map +0 -1
  140. package/operations/entry/filtering/where.d.ts +0 -5
  141. package/operations/entry/filtering/where.js +0 -35
  142. package/operations/entry/filtering/where.js.map +0 -1
  143. package/operations/system/index.d.ts +0 -7
  144. package/operations/system/index.js +0 -94
  145. package/operations/system/index.js.map +0 -1
  146. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
  147. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -48
  148. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  149. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  150. package/plugins/CmsEntryFieldFilterPlugin.js +0 -27
  151. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  152. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  153. package/plugins/CmsEntryFieldSortingPlugin.js +0 -27
  154. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  155. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  156. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -23
  157. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  158. package/plugins/index.js.map +0 -1
@@ -1,56 +1,40 @@
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 => {
15
- const {
16
- entity,
17
- locale,
18
- tenant
19
- } = 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)({
24
- tenant,
25
- locale,
26
- id
27
- });
28
- if (collection[partitionKey]) {
29
- return collection;
30
- }
31
- collection[partitionKey] = entity.getBatch({
32
- PK: partitionKey,
33
- SK: latestKey
34
- });
35
- return collection;
36
- }, {});
37
- const records = await (0, _dbDynamodb.batchReadAll)({
38
- table: entity.table,
39
- items: Object.values(queries)
40
- });
41
- const items = (0, _cleanup.cleanupItems)(entity, records);
42
- return ids.map(id => {
43
- const {
44
- id: entryId
45
- } = (0, _utils.parseIdentifier)(id);
46
- return items.filter(item => {
47
- return entryId === item.entryId;
48
- });
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
+ 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()
49
36
  });
50
- }, {
51
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
- });
53
37
  };
54
- exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
38
+ export { createGetLatestRevisionByEntryId };
55
39
 
56
40
  //# 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,KAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEO,MAAMM,gCAAgC,GAAIC,MAAwB,IAAK;EAC1E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,MAAMI,SAAS,GAAG,IAAAC,yBAAmB,EAAC,CAAC;EAEvC,OAAO,IAAIC,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CAAsB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChE,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,EAAE,CAAC,CAAC,CAAC;IAEN,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,gCAAA,GAAAA,gCAAA","ignoreList":[]}
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,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,40 @@
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 => {
15
- const {
16
- entity,
17
- locale,
18
- tenant
19
- } = 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)({
24
- tenant,
25
- locale,
26
- id
27
- });
28
- if (collection[partitionKey]) {
29
- return collection;
30
- }
31
- collection[partitionKey] = entity.getBatch({
32
- PK: partitionKey,
33
- SK: publishedKey
34
- });
35
- return collection;
36
- }, {});
37
- const records = await (0, _dbDynamodb.batchReadAll)({
38
- table: entity.table,
39
- items: Object.values(queries)
40
- });
41
- const items = (0, _cleanup.cleanupItems)(entity, records);
42
- return ids.map(id => {
43
- const {
44
- id: entryId
45
- } = (0, _utils.parseIdentifier)(id);
46
- return items.filter(item => {
47
- return entryId === item.entryId;
48
- });
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
+ 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()
49
36
  });
50
- }, {
51
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
- });
53
37
  };
54
- exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
38
+ export { createGetPublishedRevisionByEntryId };
55
39
 
56
40
  //# 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,"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,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 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,42 @@
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 => {
15
- const {
16
- entity,
17
- locale,
18
- tenant
19
- } = params;
20
- return new _dataloader.default(async ids => {
21
- const queries = ids.reduce((collection, id) => {
22
- const partitionKey = (0, _keys.createPartitionKey)({
23
- tenant,
24
- locale,
25
- id
26
- });
27
- const {
28
- version
29
- } = (0, _utils.parseIdentifier)(id);
30
- if (version === null) {
31
- return collection;
32
- }
33
- const sortKey = (0, _keys.createRevisionSortKey)({
34
- version
35
- });
36
- const keys = `${partitionKey}__${sortKey}`;
37
- if (collection[keys]) {
38
- return collection;
39
- }
40
- collection[keys] = entity.getBatch({
41
- PK: partitionKey,
42
- SK: sortKey
43
- });
44
- return collection;
45
- }, {});
46
- const records = await (0, _dbDynamodb.batchReadAll)({
47
- table: entity.table,
48
- items: Object.values(queries)
49
- });
50
- const items = (0, _cleanup.cleanupItems)(entity, records);
51
- return ids.map(id => {
52
- return items.filter(item => {
53
- return id === item.id;
54
- });
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
+ 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()
55
38
  });
56
- }, {
57
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
58
- });
59
39
  };
60
- exports.createGetRevisionById = createGetRevisionById;
40
+ export { createGetRevisionById };
61
41
 
62
42
  //# 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,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCR,MAAM;QACND,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,MAAM;QAAEG;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACJ,EAAE,CAAC;MACvC,IAAIG,OAAO,KAAK,IAAI,EAAE;QAClB,OAAOJ,UAAU;MACrB;MACA,MAAMM,OAAO,GAAG,IAAAC,2BAAqB,EAAC;QAClCH;MACJ,CAAC,CAAC;MACF,MAAMI,IAAI,GAAG,GAAGN,YAAY,KAAKI,OAAO,EAAE;MAC1C,IAAIN,UAAU,CAACQ,IAAI,CAAC,EAAE;QAClB,OAAOR,UAAU;MACrB;MAEAA,UAAU,CAACQ,IAAI,CAAC,GAAGf,MAAM,CAACgB,QAAQ,CAAC;QAC/BC,EAAE,EAAER,YAAY;QAChBS,EAAE,EAAEL;MACR,CAAC,CAAC;MAEF,OAAON,UAAU;IACrB,CAAC,EACD,CAAC,CACL,CAAC;IAED,MAAMY,OAAO,GAAG,MAAM,IAAAC,wBAAY,EAAkB;MAChDC,KAAK,EAAErB,MAAM,CAACqB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACnB,OAAO;IAChC,CAAC,CAAC;IACF,MAAMiB,KAAK,GAAG,IAAAG,qBAAY,EAACzB,MAAM,EAAEmB,OAAO,CAAC;IAE3C,OAAOf,GAAG,CAACsB,GAAG,CAAClB,EAAE,IAAI;MACjB,OAAOc,KAAK,CAACK,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOpB,EAAE,KAAKoB,IAAI,CAACpB,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIqB,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAjC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
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"}
@@ -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,18 @@
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 => {
33
- if (!dataLoaders[name]) {
34
- throw new Error(`Missing data loader "${name}".`);
35
- }
36
- return dataLoaders[name];
12
+ const getDataLoaderFactory = (name)=>{
13
+ if (!dataLoaders[name]) throw new Error(`Missing data loader "${name}".`);
14
+ return dataLoaders[name];
37
15
  };
38
- exports.getDataLoaderFactory = getDataLoaderFactory;
16
+ export { getDataLoaderFactory };
39
17
 
40
18
  //# 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,"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"}
@@ -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 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
@@ -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?