@webiny/api-headless-cms-ddb 0.0.0-unstable.2af142b57e → 0.0.0-unstable.3bc8100a7f

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 (161) hide show
  1. package/definitions/entry.d.ts +4 -3
  2. package/definitions/entry.js +109 -12
  3. package/definitions/entry.js.map +1 -1
  4. package/definitions/group.d.ts +4 -3
  5. package/definitions/group.js +9 -8
  6. package/definitions/group.js.map +1 -1
  7. package/definitions/model.d.ts +4 -3
  8. package/definitions/model.js +26 -8
  9. package/definitions/model.js.map +1 -1
  10. package/definitions/system.d.ts +4 -3
  11. package/definitions/system.js +9 -8
  12. package/definitions/system.js.map +1 -1
  13. package/definitions/table.d.ts +5 -5
  14. package/definitions/table.js +8 -4
  15. package/definitions/table.js.map +1 -1
  16. package/dynamoDb/index.js +5 -3
  17. package/dynamoDb/index.js.map +1 -1
  18. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  19. package/dynamoDb/path/locationFolderId.js +43 -0
  20. package/dynamoDb/path/locationFolderId.js.map +1 -0
  21. package/dynamoDb/path/plainObject.js +3 -1
  22. package/dynamoDb/path/plainObject.js.map +1 -1
  23. package/dynamoDb/storage/longText.js +4 -1
  24. package/dynamoDb/storage/longText.js.map +1 -1
  25. package/dynamoDb/storage/richText.js +24 -58
  26. package/dynamoDb/storage/richText.js.map +1 -1
  27. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  28. package/dynamoDb/transformValue/datetime.js +3 -1
  29. package/dynamoDb/transformValue/datetime.js.map +1 -1
  30. package/index.d.ts +1 -1
  31. package/index.js +16 -23
  32. package/index.js.map +1 -1
  33. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  34. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  35. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  36. package/operations/entry/dataLoader/constants.d.ts +1 -0
  37. package/operations/entry/dataLoader/constants.js +10 -0
  38. package/operations/entry/dataLoader/constants.js.map +1 -0
  39. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  40. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  41. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  42. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  43. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  44. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  45. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  46. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +56 -0
  47. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  48. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  49. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +56 -0
  50. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  51. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  52. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  53. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  54. package/operations/entry/dataLoader/index.d.ts +8 -0
  55. package/operations/entry/dataLoader/index.js +40 -0
  56. package/operations/entry/dataLoader/index.js.map +1 -0
  57. package/operations/entry/dataLoader/types.d.ts +6 -0
  58. package/operations/entry/dataLoader/types.js +7 -0
  59. package/operations/entry/dataLoader/types.js.map +1 -0
  60. package/operations/entry/dataLoaders.d.ts +12 -27
  61. package/operations/entry/dataLoaders.js +55 -217
  62. package/operations/entry/dataLoaders.js.map +1 -1
  63. package/operations/entry/filtering/createExpressions.d.ts +4 -4
  64. package/operations/entry/filtering/createExpressions.js +3 -1
  65. package/operations/entry/filtering/createExpressions.js.map +1 -1
  66. package/operations/entry/filtering/createFields.d.ts +6 -4
  67. package/operations/entry/filtering/createFields.js +77 -74
  68. package/operations/entry/filtering/createFields.js.map +1 -1
  69. package/operations/entry/filtering/extractSort.d.ts +3 -3
  70. package/operations/entry/filtering/extractSort.js +3 -1
  71. package/operations/entry/filtering/extractSort.js.map +1 -1
  72. package/operations/entry/filtering/filter.d.ts +3 -3
  73. package/operations/entry/filtering/filter.js +24 -9
  74. package/operations/entry/filtering/filter.js.map +1 -1
  75. package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
  76. package/operations/entry/filtering/fullTextSearch.js +3 -1
  77. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  78. package/operations/entry/filtering/getValue.js +6 -3
  79. package/operations/entry/filtering/getValue.js.map +1 -1
  80. package/operations/entry/filtering/index.js +3 -1
  81. package/operations/entry/filtering/index.js.map +1 -1
  82. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  83. package/operations/entry/filtering/mapPlugins.js +3 -1
  84. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  85. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
  86. package/operations/entry/filtering/plugins/defaultFilterCreate.js +6 -2
  87. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  88. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  89. package/operations/entry/filtering/plugins/index.js +5 -2
  90. package/operations/entry/filtering/plugins/index.js.map +1 -1
  91. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
  92. package/operations/entry/filtering/plugins/objectFilterCreate.js +6 -2
  93. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  94. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -1
  95. package/operations/entry/filtering/plugins/refFilterCreate.js +12 -3
  96. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  97. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  98. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
  99. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  100. package/operations/entry/filtering/sort.d.ts +3 -3
  101. package/operations/entry/filtering/sort.js +5 -3
  102. package/operations/entry/filtering/sort.js.map +1 -1
  103. package/operations/entry/filtering/systemFields.d.ts +2 -2
  104. package/operations/entry/filtering/systemFields.js +49 -29
  105. package/operations/entry/filtering/systemFields.js.map +1 -1
  106. package/operations/entry/filtering/transform.d.ts +1 -1
  107. package/operations/entry/filtering/transform.js +3 -1
  108. package/operations/entry/filtering/transform.js.map +1 -1
  109. package/operations/entry/filtering/types.d.ts +2 -2
  110. package/operations/entry/filtering/types.js +3 -1
  111. package/operations/entry/filtering/types.js.map +1 -1
  112. package/operations/entry/filtering/values.d.ts +1 -1
  113. package/operations/entry/filtering/values.js +3 -1
  114. package/operations/entry/filtering/values.js.map +1 -1
  115. package/operations/entry/filtering/where.js +6 -3
  116. package/operations/entry/filtering/where.js.map +1 -1
  117. package/operations/entry/index.d.ts +3 -3
  118. package/operations/entry/index.js +712 -193
  119. package/operations/entry/index.js.map +1 -1
  120. package/operations/entry/keys.js +3 -1
  121. package/operations/entry/keys.js.map +1 -1
  122. package/operations/group/index.d.ts +3 -3
  123. package/operations/group/index.js +33 -21
  124. package/operations/group/index.js.map +1 -1
  125. package/operations/model/index.d.ts +2 -2
  126. package/operations/model/index.js +26 -13
  127. package/operations/model/index.js.map +1 -1
  128. package/operations/system/index.d.ts +2 -2
  129. package/operations/system/index.js +19 -7
  130. package/operations/system/index.js.map +1 -1
  131. package/package.json +21 -26
  132. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +3 -2
  133. package/plugins/CmsEntryFieldFilterPathPlugin.js +11 -4
  134. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  135. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  136. package/plugins/CmsEntryFieldFilterPlugin.js +9 -6
  137. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  138. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  139. package/plugins/CmsEntryFieldSortingPlugin.js +4 -5
  140. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  141. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  142. package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
  143. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  144. package/plugins/index.d.ts +1 -0
  145. package/plugins/index.js +14 -1
  146. package/plugins/index.js.map +1 -1
  147. package/types.d.ts +20 -13
  148. package/types.js +5 -5
  149. package/types.js.map +1 -1
  150. package/definitions/settings.d.ts +0 -9
  151. package/definitions/settings.js +0 -53
  152. package/definitions/settings.js.map +0 -1
  153. package/dynamoDb/storage/date.d.ts +0 -3
  154. package/dynamoDb/storage/date.js +0 -91
  155. package/dynamoDb/storage/date.js.map +0 -1
  156. package/operations/entry/systemFields.d.ts +0 -2
  157. package/operations/entry/systemFields.js +0 -72
  158. package/operations/entry/systemFields.js.map +0 -1
  159. package/operations/settings/index.d.ts +0 -7
  160. package/operations/settings/index.js +0 -111
  161. package/operations/settings/index.js.map +0 -1
@@ -0,0 +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.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
+ });
49
+ });
50
+ }, {
51
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
+ });
53
+ };
54
+ exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
55
+
56
+ //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +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.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
+ });
49
+ });
50
+ }, {
51
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
+ });
53
+ };
54
+ exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
55
+
56
+ //# sourceMappingURL=getPublishedRevisionByEntryId.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,62 @@
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
+ });
55
+ });
56
+ }, {
57
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
58
+ });
59
+ };
60
+ exports.createGetRevisionById = createGetRevisionById;
61
+
62
+ //# sourceMappingURL=getRevisionById.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,8 @@
1
+ import type DataLoader from "dataloader";
2
+ import type { DataLoaderParams } from "./types";
3
+ export * from "./DataLoaderCache";
4
+ interface Callable {
5
+ (params: DataLoaderParams): DataLoader<any, any>;
6
+ }
7
+ export type DataLoaders = "getAllEntryRevisions" | "getRevisionById" | "getPublishedRevisionByEntryId" | "getLatestRevisionByEntryId";
8
+ export declare const getDataLoaderFactory: (name: string) => Callable;
@@ -0,0 +1,40 @@
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
+ });
26
+ const dataLoaders = {
27
+ getAllEntryRevisions: _getAllEntryRevisions.createGetAllEntryRevisions,
28
+ getLatestRevisionByEntryId: _getLatestRevisionByEntryId.createGetLatestRevisionByEntryId,
29
+ getPublishedRevisionByEntryId: _getPublishedRevisionByEntryId.createGetPublishedRevisionByEntryId,
30
+ getRevisionById: _getRevisionById.createGetRevisionById
31
+ };
32
+ const getDataLoaderFactory = name => {
33
+ if (!dataLoaders[name]) {
34
+ throw new Error(`Missing data loader "${name}".`);
35
+ }
36
+ return dataLoaders[name];
37
+ };
38
+ exports.getDataLoaderFactory = getDataLoaderFactory;
39
+
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,6 @@
1
+ import type { Entity } from "@webiny/db-dynamodb/toolbox";
2
+ export interface DataLoaderParams {
3
+ entity: Entity<any>;
4
+ tenant: string;
5
+ locale: string;
6
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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,42 +1,27 @@
1
- import { CmsStorageEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- export interface GetAllEntryRevisionsParams {
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";
4
+ interface DataLoaderParams {
5
+ model: Pick<CmsModel, "tenant" | "locale" | "modelId">;
4
6
  ids: readonly string[];
5
- model: CmsModel;
6
- }
7
- export interface GetRevisionByIdParams {
8
- ids: readonly string[];
9
- model: CmsModel;
10
- }
11
- export interface GetPublishedRevisionByEntryIdParams {
12
- ids: readonly string[];
13
- model: CmsModel;
14
- }
15
- export interface GetLatestRevisionByEntryIdParams {
16
- ids: readonly string[];
17
- model: CmsModel;
18
- }
19
- interface ClearLoaderParams {
20
- model: CmsModel;
21
- entry?: CmsStorageEntry;
22
7
  }
23
8
  interface DataLoadersHandlerParams {
24
9
  entity: Entity<any>;
25
10
  }
26
- export declare class DataLoadersHandler {
27
- private readonly loaders;
11
+ export declare class DataLoadersHandler implements DataLoadersHandlerInterface {
28
12
  private readonly entity;
13
+ private readonly cache;
29
14
  constructor(params: DataLoadersHandlerParams);
30
- getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsStorageEntry[]>;
31
- getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]>;
32
- getPublishedRevisionByEntryId(params: GetPublishedRevisionByEntryIdParams): Promise<CmsStorageEntry[]>;
33
- getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsStorageEntry[]>;
15
+ getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
16
+ getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
17
+ getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
18
+ getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
34
19
  /**
35
20
  * TODO @ts-refactor
36
21
  * Maybe pass on the generics to DataLoader definition?
37
22
  */
38
23
  private getLoader;
39
24
  private loadMany;
40
- clearAll(params: Omit<ClearLoaderParams, "entry">): void;
25
+ clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void;
41
26
  }
42
27
  export {};