@webiny/api-headless-cms-ddb 0.0.0-mt-3 → 0.0.0-unstable.3386f66516

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 (133) hide show
  1. package/definitions/entry.d.ts +2 -1
  2. package/definitions/entry.js +6 -7
  3. package/definitions/entry.js.map +1 -0
  4. package/definitions/group.d.ts +2 -1
  5. package/definitions/group.js +3 -7
  6. package/definitions/group.js.map +1 -0
  7. package/definitions/model.d.ts +2 -1
  8. package/definitions/model.js +8 -7
  9. package/definitions/model.js.map +1 -0
  10. package/definitions/settings.d.ts +2 -1
  11. package/definitions/settings.js +3 -7
  12. package/definitions/settings.js.map +1 -0
  13. package/definitions/system.d.ts +2 -1
  14. package/definitions/system.js +3 -7
  15. package/definitions/system.js.map +1 -0
  16. package/definitions/table.d.ts +2 -1
  17. package/definitions/table.js.map +1 -0
  18. package/dynamoDb/index.d.ts +1 -1
  19. package/dynamoDb/index.js +6 -10
  20. package/dynamoDb/index.js.map +1 -0
  21. package/dynamoDb/path/plainObject.d.ts +2 -3
  22. package/dynamoDb/path/plainObject.js +29 -22
  23. package/dynamoDb/path/plainObject.js.map +1 -0
  24. package/dynamoDb/storage/date.d.ts +3 -3
  25. package/dynamoDb/storage/date.js +90 -46
  26. package/dynamoDb/storage/date.js.map +1 -0
  27. package/dynamoDb/storage/longText.d.ts +7 -4
  28. package/dynamoDb/storage/longText.js +79 -54
  29. package/dynamoDb/storage/longText.js.map +1 -0
  30. package/dynamoDb/storage/richText.d.ts +2 -8
  31. package/dynamoDb/storage/richText.js +70 -67
  32. package/dynamoDb/storage/richText.js.map +1 -0
  33. package/dynamoDb/transformValue/datetime.d.ts +4 -2
  34. package/dynamoDb/transformValue/datetime.js +31 -26
  35. package/dynamoDb/transformValue/datetime.js.map +1 -0
  36. package/index.d.ts +1 -0
  37. package/index.js +54 -23
  38. package/index.js.map +1 -0
  39. package/operations/entry/dataLoaders.d.ts +12 -8
  40. package/operations/entry/dataLoaders.js +31 -13
  41. package/operations/entry/dataLoaders.js.map +1 -0
  42. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  43. package/operations/entry/filtering/createExpressions.js +213 -0
  44. package/operations/entry/filtering/createExpressions.js.map +1 -0
  45. package/operations/entry/filtering/createFields.d.ts +14 -0
  46. package/operations/entry/filtering/createFields.js +123 -0
  47. package/operations/entry/filtering/createFields.js.map +1 -0
  48. package/operations/entry/filtering/extractSort.d.ts +17 -0
  49. package/operations/entry/filtering/extractSort.js +77 -0
  50. package/operations/entry/filtering/extractSort.js.map +1 -0
  51. package/operations/entry/filtering/filter.d.ts +15 -0
  52. package/operations/entry/filtering/filter.js +178 -0
  53. package/operations/entry/filtering/filter.js.map +1 -0
  54. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  55. package/operations/entry/filtering/fullTextSearch.js +60 -0
  56. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  57. package/operations/entry/filtering/getValue.d.ts +5 -0
  58. package/operations/entry/filtering/getValue.js +81 -0
  59. package/operations/entry/filtering/getValue.js.map +1 -0
  60. package/operations/entry/filtering/index.d.ts +2 -0
  61. package/operations/entry/filtering/index.js +21 -0
  62. package/operations/entry/filtering/index.js.map +1 -0
  63. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  64. package/operations/entry/filtering/mapPlugins.js +39 -0
  65. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  66. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  67. package/operations/entry/filtering/plugins/defaultFilterCreate.js +48 -0
  68. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  69. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  70. package/operations/entry/filtering/plugins/index.js +18 -0
  71. package/operations/entry/filtering/plugins/index.js.map +1 -0
  72. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  73. package/operations/entry/filtering/plugins/objectFilterCreate.js +107 -0
  74. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  75. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
  76. package/operations/entry/filtering/plugins/refFilterCreate.js +89 -0
  77. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  78. package/operations/entry/filtering/sort.d.ts +12 -0
  79. package/operations/entry/filtering/sort.js +84 -0
  80. package/operations/entry/filtering/sort.js.map +1 -0
  81. package/operations/entry/filtering/systemFields.d.ts +4 -0
  82. package/operations/entry/filtering/systemFields.js +72 -0
  83. package/operations/entry/filtering/systemFields.js.map +1 -0
  84. package/operations/entry/filtering/transform.d.ts +6 -0
  85. package/operations/entry/filtering/transform.js +19 -0
  86. package/operations/entry/filtering/transform.js.map +1 -0
  87. package/operations/entry/filtering/types.d.ts +40 -0
  88. package/operations/entry/filtering/types.js +5 -0
  89. package/operations/entry/filtering/types.js.map +1 -0
  90. package/operations/entry/filtering/values.d.ts +2 -0
  91. package/operations/entry/filtering/values.js +28 -0
  92. package/operations/entry/filtering/values.js.map +1 -0
  93. package/operations/entry/filtering/where.d.ts +5 -0
  94. package/operations/entry/filtering/where.js +38 -0
  95. package/operations/entry/filtering/where.js.map +1 -0
  96. package/operations/entry/index.d.ts +2 -2
  97. package/operations/entry/index.js +278 -227
  98. package/operations/entry/index.js.map +1 -0
  99. package/operations/entry/keys.js +11 -0
  100. package/operations/entry/keys.js.map +1 -0
  101. package/operations/entry/systemFields.js +24 -0
  102. package/operations/entry/systemFields.js.map +1 -0
  103. package/operations/group/index.d.ts +3 -2
  104. package/operations/group/index.js +7 -13
  105. package/operations/group/index.js.map +1 -0
  106. package/operations/model/index.d.ts +3 -2
  107. package/operations/model/index.js +15 -14
  108. package/operations/model/index.js.map +1 -0
  109. package/operations/settings/index.d.ts +3 -2
  110. package/operations/settings/index.js +7 -13
  111. package/operations/settings/index.js.map +1 -0
  112. package/operations/system/index.d.ts +3 -2
  113. package/operations/system/index.js +5 -11
  114. package/operations/system/index.js.map +1 -0
  115. package/package.json +22 -23
  116. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
  117. package/plugins/CmsEntryFieldFilterPathPlugin.js +55 -0
  118. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  119. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  120. package/plugins/CmsEntryFieldFilterPlugin.js +31 -0
  121. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  122. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  123. package/plugins/CmsEntryFieldSortingPlugin.js +38 -0
  124. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  125. package/plugins/index.d.ts +3 -0
  126. package/plugins/index.js +44 -0
  127. package/plugins/index.js.map +1 -0
  128. package/types.d.ts +2 -33
  129. package/types.js.map +1 -0
  130. package/dynamoDb/path/ref.d.ts +0 -3
  131. package/dynamoDb/path/ref.js +0 -27
  132. package/operations/entry/utils.d.ts +0 -31
  133. package/operations/entry/utils.js +0 -406
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.createLongTextStorageTransformPlugin = void 0;
9
9
 
10
10
  var _error = _interopRequireDefault(require("@webiny/error"));
11
11
 
12
12
  var _gzip = require("@webiny/utils/compression/gzip");
13
13
 
14
- var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
14
+ var _apiHeadlessCms = require("@webiny/api-headless-cms");
15
15
 
16
+ /**
17
+ * File is @internal
18
+ */
16
19
  const GZIP = "gzip";
17
20
  const TO_STORAGE_ENCODING = "base64";
18
21
  const FROM_STORAGE_ENCODING = "utf8";
@@ -25,59 +28,81 @@ const convertToBuffer = value => {
25
28
  return value;
26
29
  };
27
30
 
28
- const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
29
- fieldType: "long-text",
30
- fromStorage: async ({
31
- field,
32
- value: storageValue
33
- }) => {
34
- const typeOf = typeof storageValue;
35
-
36
- if (!storageValue || typeOf === "string" || typeOf === "number") {
37
- return storageValue;
38
- } else if (typeof storageValue !== "object") {
39
- throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.fieldId}".`);
40
- }
31
+ const createLongTextStorageTransformPlugin = () => {
32
+ return new _apiHeadlessCms.StorageTransformPlugin({
33
+ fieldType: "long-text",
34
+ fromStorage: async ({
35
+ field,
36
+ value: storageValue
37
+ }) => {
38
+ const typeOf = typeof storageValue;
41
39
 
42
- const {
43
- compression,
44
- value
45
- } = storageValue;
46
- /**
47
- * Check if possibly undefined, null, empty...
48
- */
49
-
50
- if (!compression) {
51
- throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
52
- value: storageValue
53
- });
54
- } else if (compression !== GZIP) {
55
- throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
56
- compression
57
- });
58
- }
40
+ if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
41
+ return storageValue;
42
+ } else if (typeOf !== "object") {
43
+ throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
44
+ }
59
45
 
60
- try {
61
- const buf = await (0, _gzip.decompress)(convertToBuffer(value));
62
- return buf.toString(FROM_STORAGE_ENCODING);
63
- } catch (ex) {
64
- console.log(ex.message);
65
- return null;
66
- }
67
- },
68
- toStorage: async ({
69
- value
70
- }) => {
71
- const compressedValue = await (0, _gzip.compress)(value);
72
- return {
73
- compression: GZIP,
74
- value: compressedValue.toString(TO_STORAGE_ENCODING)
75
- };
76
- }
77
- });
46
+ const {
47
+ compression,
48
+ value,
49
+ isArray
50
+ } = storageValue;
51
+ /**
52
+ * Check if possibly undefined, null, empty...
53
+ */
54
+
55
+ if (!compression) {
56
+ throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
57
+ value: storageValue
58
+ });
59
+ } else if (compression !== GZIP) {
60
+ throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
61
+ compression
62
+ });
63
+ }
78
64
 
79
- var _default = () => {
80
- return plugin;
65
+ try {
66
+ const buf = await (0, _gzip.decompress)(convertToBuffer(value));
67
+ const result = buf.toString(FROM_STORAGE_ENCODING);
68
+
69
+ if (!isArray) {
70
+ return result;
71
+ }
72
+
73
+ return JSON.parse(result);
74
+ } catch (ex) {
75
+ console.log("Error while transforming long-text.");
76
+ console.log(ex.message);
77
+ return "";
78
+ }
79
+ },
80
+ toStorage: async ({
81
+ value: initialValue
82
+ }) => {
83
+ /**
84
+ * There is a possibility that we are trying to compress already compressed value.
85
+ */
86
+ if (initialValue && initialValue.hasOwnProperty("compression") === true) {
87
+ return initialValue;
88
+ }
89
+
90
+ const isArray = Array.isArray(initialValue);
91
+ const value = isArray ? JSON.stringify(initialValue) : initialValue;
92
+ const compressedValue = await (0, _gzip.compress)(value);
93
+ const result = {
94
+ compression: GZIP,
95
+ value: compressedValue.toString(TO_STORAGE_ENCODING)
96
+ };
97
+
98
+ if (!isArray) {
99
+ return result;
100
+ }
101
+
102
+ result.isArray = isArray;
103
+ return result;
104
+ }
105
+ });
81
106
  };
82
107
 
83
- exports.default = _default;
108
+ exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as any;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":";;;;;;;;;AAIA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,MAAb;AACA,MAAMC,mBAAmB,GAAG,QAA5B;AACA,MAAMC,qBAAqB,GAAG,MAA9B;;AAEA,MAAMC,eAAe,GAAIC,KAAD,IAAoC;EACxD,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC3B,OAAOC,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBH,mBAAnB,CAAP;EACH;;EACD,OAAOG,KAAP;AACH,CALD;;AAaO,MAAMG,oCAAoC,GAAG,MAAM;EACtD,OAAO,IAAIC,sCAAJ,CAA4D;IAC/DC,SAAS,EAAE,WADoD;IAE/DC,WAAW,EAAE,OAAO;MAAEC,KAAF;MAASP,KAAK,EAAEQ;IAAhB,CAAP,KAA0C;MACnD,MAAMC,MAAM,GAAG,OAAOD,YAAtB;;MACA,IACI,CAACA,YAAD,IACAC,MAAM,KAAK,QADX,IAEAA,MAAM,KAAK,QAFX,IAGAC,KAAK,CAACC,OAAN,CAAcH,YAAd,MAAgC,IAJpC,EAKE;QACE,OAAOA,YAAP;MACH,CAPD,MAOO,IAAIC,MAAM,KAAK,QAAf,EAAyB;QAC5B,MAAM,IAAIG,cAAJ,CACD,gFAA+EL,KAAK,CAACM,SAAU,OAAMN,KAAK,CAACO,OAAQ,GADlH,CAAN;MAGH;;MACD,MAAM;QAAEC,WAAF;QAAef,KAAf;QAAsBW;MAAtB,IAAkCH,YA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MoB,MAAoB,GAAG;QACzBL,WAAW,EAAEnB,IADY;QAEzBI,KAAK,EAAE8B,eAAe,CAACT,QAAhB,CAAyBxB,mBAAzB;MAFkB,CAA7B;;MAIA,IAAI,CAACc,OAAL,EAAc;QACV,OAAOS,MAAP;MACH;;MACDA,MAAM,CAACT,OAAP,GAAiBA,OAAjB;MACA,OAAOS,MAAP;IACH;EAxE8D,CAA5D,CAAP;AA0EH,CA3EM"}
@@ -1,8 +1,2 @@
1
- import { StorageTransformPlugin } from "@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin";
2
- export declare type OriginalValue = Record<string, any> | any[];
3
- export interface StorageValue {
4
- compression: string;
5
- value: any;
6
- }
7
- declare const _default: () => StorageTransformPlugin<any, any>;
8
- export default _default;
1
+ import { StorageTransformPlugin } from "@webiny/api-headless-cms";
2
+ export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>;
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.createRichTextStorageTransformPlugin = void 0;
9
9
 
10
10
  var _jsonpack = _interopRequireDefault(require("jsonpack"));
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
- var _StorageTransformPlugin = require("@webiny/api-headless-cms/content/plugins/storage/StorageTransformPlugin");
14
+ var _apiHeadlessCms = require("@webiny/api-headless-cms");
15
+
16
+ /**
17
+ * File is @internal
18
+ */
15
19
 
16
20
  /**
17
21
  * Remove when jsonpack gets PR with a fix merged
18
22
  * https://github.com/rgcl/jsonpack/pull/25/files
19
23
  * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
20
24
  */
25
+ // TODO @ts-refactor figure better type
21
26
  const transformArray = value => {
22
27
  if (!value) {
23
28
  return value;
@@ -40,71 +45,69 @@ const transformArray = value => {
40
45
  return value;
41
46
  };
42
47
 
43
- const plugin = new _StorageTransformPlugin.StorageTransformPlugin({
44
- fieldType: "rich-text",
45
- fromStorage: async ({
46
- field,
47
- value: storageValue
48
- }) => {
49
- if (!storageValue) {
50
- return storageValue;
51
- } else if (typeof storageValue !== "object") {
52
- throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.fieldId}".`);
53
- }
54
- /**
55
- * This is to circumvent a bug introduced with 5.8.0 storage operations.
56
- * Do not remove.
57
- */
58
-
59
-
60
- if (storageValue.hasOwnProperty("compression") === false) {
61
- return storageValue;
62
- }
63
-
64
- const {
65
- compression,
48
+ const createRichTextStorageTransformPlugin = () => {
49
+ return new _apiHeadlessCms.StorageTransformPlugin({
50
+ fieldType: "rich-text",
51
+ fromStorage: async ({
52
+ field,
53
+ value: storageValue
54
+ }) => {
55
+ if (!storageValue) {
56
+ return storageValue;
57
+ } else if (typeof storageValue !== "object") {
58
+ throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
59
+ }
60
+ /**
61
+ * This is to circumvent a bug introduced with 5.8.0 storage operations.
62
+ * Do not remove.
63
+ */
64
+
65
+
66
+ if (storageValue.hasOwnProperty("compression") === false) {
67
+ return storageValue;
68
+ }
69
+
70
+ const {
71
+ compression,
72
+ value
73
+ } = storageValue;
74
+
75
+ if (!compression) {
76
+ throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
77
+ value: storageValue
78
+ });
79
+ }
80
+
81
+ if (compression !== "jsonpack") {
82
+ throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
83
+ compression
84
+ });
85
+ }
86
+
87
+ try {
88
+ return _jsonpack.default.unpack(value);
89
+ } catch {
90
+ return null;
91
+ }
92
+ },
93
+ toStorage: async ({
66
94
  value
67
- } = storageValue;
68
-
69
- if (!compression) {
70
- throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
71
- value: storageValue
72
- });
95
+ }) => {
96
+ /**
97
+ * There is a possibility that we are trying to compress already compressed value.
98
+ * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
99
+ */
100
+ if (value && value.hasOwnProperty("compression") === true) {
101
+ return value;
102
+ }
103
+
104
+ value = transformArray(value);
105
+ return {
106
+ compression: "jsonpack",
107
+ value: value ? _jsonpack.default.pack(value) : value
108
+ };
73
109
  }
74
-
75
- if (compression !== "jsonpack") {
76
- throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
77
- compression
78
- });
79
- }
80
-
81
- try {
82
- return _jsonpack.default.unpack(value);
83
- } catch {
84
- return null;
85
- }
86
- },
87
- toStorage: async ({
88
- value
89
- }) => {
90
- /**
91
- * There is a possibility that we are trying to compress already compressed value.
92
- * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
93
- */
94
- if (value && value.hasOwnProperty("compression") === true) {
95
- return value;
96
- }
97
-
98
- value = transformArray(value);
99
- return {
100
- compression: "jsonpack",
101
- value: value ? _jsonpack.default.pack(value) : value
102
- };
103
- }
104
- });
105
-
106
- var _default = () => {
107
- return plugin;
110
+ });
108
111
  };
109
112
 
110
- exports.default = _default;
113
+ exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","fieldId","hasOwnProperty","compression","JSON","stringify","jsonpack","unpack","toStorage","pack"],"sources":["richText.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (storageValue.hasOwnProperty(\"compression\") === false) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.fieldId\n }\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n }\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n return jsonpack.unpack(value);\n } catch {\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (value && value.hasOwnProperty(\"compression\") === true) {\n return value;\n }\n value = transformArray(value);\n return {\n compression: \"jsonpack\",\n value: value ? jsonpack.pack(value) : value\n };\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;A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AAJ,CACD,2DACGF,KAAK,CAACI,OACT,MAAKG,IAAI,CAACC,SAAL,CAAeP,YAAf,CAA6B,GAHjC,EAIF,qBAJE,EAKF;UACIX,KAAK,EAAEW;QADX,CALE,CAAN;MASH;;MACD,IAAIK,WAAW,KAAK,UAApB,EAAgC;QAC5B,MAAM,IAAIJ,cAAJ,CACD,oEADC,EAEF,mBAFE,EAGF;UACII;QADJ,CAHE,CAAN;MAOH;;MACD,IAAI;QACA,OAAOG,iBAAA,CAASC,MAAT,CAAgBpB,KAAhB,CAAP;MACH,CAFD,CAEE,MAAM;QACJ,OAAO,IAAP;MACH;IACJ,CA3C6B;IA4C9BqB,SAAS,EAAE,OAAO;MAAErB;IAAF,CAAP,KAAqB;MAC5B;AACZ;AACA;AACA;MACY,IAAIA,KAAK,IAAIA,KAAK,CAACe,cAAN,CAAqB,aAArB,MAAwC,IAArD,EAA2D;QACvD,OAAOf,KAAP;MACH;;MACDA,KAAK,GAAGD,cAAc,CAACC,KAAD,CAAtB;MACA,OAAO;QACHgB,WAAW,EAAE,UADV;QAEHhB,KAAK,EAAEA,KAAK,GAAGmB,iBAAA,CAASG,IAAT,CAActB,KAAd,CAAH,GAA0BA;MAFnC,CAAP;IAIH;EAzD6B,CAA3B,CAAP;AA2DH,CA5DM"}
@@ -1,3 +1,5 @@
1
+ /**
2
+ * File is @internal
3
+ */
1
4
  import { CmsFieldFilterValueTransformPlugin } from "../../types";
2
- declare const _default: () => CmsFieldFilterValueTransformPlugin;
3
- export default _default;
5
+ export declare const createDatetimeTransformValuePlugin: () => CmsFieldFilterValueTransformPlugin;
@@ -3,12 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.createDatetimeTransformValuePlugin = void 0;
7
7
 
8
8
  var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
9
9
 
10
10
  var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
11
11
 
12
+ /**
13
+ * File is @internal
14
+ */
12
15
  const timeTransformer = new _TimeTransformPlugin.TimeTransformPlugin({
13
16
  fields: ["*"]
14
17
  });
@@ -16,32 +19,34 @@ const dateTimeTransformer = new _DateTimeTransformPlugin.DateTimeTransformPlugin
16
19
  fields: ["*"]
17
20
  });
18
21
 
19
- var _default = () => ({
20
- type: "cms-field-filter-value-transform",
21
- name: "cms-field-value-filter-transform-datetime",
22
- fieldType: "datetime",
23
-
24
- /**
25
- * Always transform into the milliseconds.
26
- */
27
- transform: ({
28
- field,
29
- value
30
- }) => {
31
- const {
32
- type
33
- } = field.settings || {};
34
-
35
- if (type === "time") {
36
- return timeTransformer.transform({
22
+ const createDatetimeTransformValuePlugin = () => {
23
+ return {
24
+ type: "cms-field-filter-value-transform",
25
+ name: "cms-field-value-filter-transform-datetime",
26
+ fieldType: "datetime",
27
+
28
+ /**
29
+ * Always transform into the milliseconds.
30
+ */
31
+ transform: ({
32
+ field,
33
+ value
34
+ }) => {
35
+ const {
36
+ type
37
+ } = field.settings || {};
38
+
39
+ if (type === "time") {
40
+ return timeTransformer.transform({
41
+ value
42
+ });
43
+ }
44
+
45
+ return dateTimeTransformer.transform({
37
46
  value
38
47
  });
39
48
  }
49
+ };
50
+ };
40
51
 
41
- return dateTimeTransformer.transform({
42
- value
43
- });
44
- }
45
- });
46
-
47
- exports.default = _default;
52
+ exports.createDatetimeTransformValuePlugin = createDatetimeTransformValuePlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["timeTransformer","TimeTransformPlugin","fields","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAIA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,eAAe,GAAG,IAAIC,wCAAJ,CAAwB;EAC5CC,MAAM,EAAE,CAAC,GAAD;AADoC,CAAxB,CAAxB;AAGA,MAAMC,mBAAmB,GAAG,IAAIC,gDAAJ,CAA4B;EACpDF,MAAM,EAAE,CAAC,GAAD;AAD4C,CAA5B,CAA5B;;AAIO,MAAMG,kCAAkC,GAAG,MAA0C;EACxF,OAAO;IACHC,IAAI,EAAE,kCADH;IAEHC,IAAI,EAAE,2CAFH;IAGHC,SAAS,EAAE,UAHR;;IAIH;AACR;AACA;IACQC,SAAS,EAAE,CAAC;MAAEC,KAAF;MAASC;IAAT,CAAD,KAAsB;MAC7B,MAAM;QAAEL;MAAF,IAAWI,KAAK,CAACE,QAAN,IAAkB,EAAnC;;MACA,IAAIN,IAAI,KAAK,MAAb,EAAqB;QACjB,OAAON,eAAe,CAACS,SAAhB,CAA0B;UAC7BE;QAD6B,CAA1B,CAAP;MAGH;;MACD,OAAOR,mBAAmB,CAACM,SAApB,CAA8B;QACjCE;MADiC,CAA9B,CAAP;IAGH;EAjBE,CAAP;AAmBH,CApBM"}
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { StorageOperationsFactory } from "./types";
2
+ export * from "./plugins";
2
3
  export declare const createStorageOperations: StorageOperationsFactory;
package/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ var _exportNames = {
9
+ createStorageOperations: true
10
+ };
8
11
  exports.createStorageOperations = void 0;
9
12
 
10
13
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
@@ -37,13 +40,28 @@ var _model2 = require("./operations/model");
37
40
 
38
41
  var _entry2 = require("./operations/entry");
39
42
 
43
+ var _plugins2 = require("./operations/entry/filtering/plugins");
44
+
45
+ var _plugins3 = require("./plugins");
46
+
47
+ Object.keys(_plugins3).forEach(function (key) {
48
+ if (key === "default" || key === "__esModule") return;
49
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
+ if (key in exports && exports[key] === _plugins3[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _plugins3[key];
55
+ }
56
+ });
57
+ });
58
+
40
59
  const createStorageOperations = params => {
41
60
  const {
42
- attributes = {},
61
+ attributes,
43
62
  table,
44
63
  documentClient,
45
- plugins: customPlugins,
46
- modelFieldToGraphQLPlugins
64
+ plugins: userPlugins
47
65
  } = params;
48
66
  const tableInstance = (0, _table.createTable)({
49
67
  table,
@@ -53,53 +71,66 @@ const createStorageOperations = params => {
53
71
  settings: (0, _settings.createSettingsEntity)({
54
72
  entityName: _types.ENTITIES.SETTINGS,
55
73
  table: tableInstance,
56
- attributes: attributes[_types.ENTITIES.SETTINGS]
74
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
57
75
  }),
58
76
  system: (0, _system.createSystemEntity)({
59
77
  entityName: _types.ENTITIES.SYSTEM,
60
78
  table: tableInstance,
61
- attributes: attributes[_types.ENTITIES.SYSTEM]
79
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
62
80
  }),
63
81
  groups: (0, _group.createGroupEntity)({
64
82
  entityName: _types.ENTITIES.GROUPS,
65
83
  table: tableInstance,
66
- attributes: attributes[_types.ENTITIES.GROUPS]
84
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
67
85
  }),
68
86
  models: (0, _model.createModelEntity)({
69
87
  entityName: _types.ENTITIES.MODELS,
70
88
  table: tableInstance,
71
- attributes: attributes[_types.ENTITIES.MODELS]
89
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
72
90
  }),
73
91
  entries: (0, _entry.createEntryEntity)({
74
92
  entityName: _types.ENTITIES.ENTRIES,
75
93
  table: tableInstance,
76
- attributes: attributes[_types.ENTITIES.ENTRIES]
94
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
77
95
  })
78
96
  };
79
97
  const plugins = new _plugins.PluginsContainer([
80
98
  /**
81
- * User defined custom plugins.
99
+ * DynamoDB filter plugins for the where conditions.
82
100
  */
83
- ...(customPlugins || []),
101
+ (0, _filters.default)(),
84
102
  /**
85
- * Plugins of type CmsModelFieldToGraphQLPlugin.
103
+ * Field plugins for DynamoDB.
86
104
  */
87
- modelFieldToGraphQLPlugins,
105
+ (0, _dynamoDb.default)(),
88
106
  /**
89
- * DynamoDB filter plugins for the where conditions.
107
+ * Filter create plugins.
90
108
  */
91
- (0, _filters.default)(),
109
+ (0, _plugins2.createFilterCreatePlugins)(),
92
110
  /**
93
- * Field plugins for DynamoDB.
111
+ * User defined custom plugins.
94
112
  */
95
- (0, _dynamoDb.default)()]);
113
+ ...(userPlugins || [])]);
96
114
  return {
97
- plugins: [
98
- /**
99
- * Field plugins for DynamoDB.
100
- * We must pass them to the base application.
101
- */
102
- (0, _dynamoDb.default)()],
115
+ name: "dynamodb",
116
+ beforeInit: async context => {
117
+ /**
118
+ * Collect all required plugins from parent context.
119
+ */
120
+ const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
121
+ plugins.register(fieldPlugins);
122
+ const filterPathPlugins = context.plugins.byType(_plugins3.CmsEntryFieldFilterPathPlugin.type);
123
+ plugins.register(filterPathPlugins);
124
+ const filterPlugins = context.plugins.byType(_plugins3.CmsEntryFieldFilterPlugin.type);
125
+ plugins.register(filterPlugins);
126
+ const sortingPlugins = context.plugins.byType(_plugins3.CmsEntryFieldSortingPlugin.type);
127
+ plugins.register(sortingPlugins);
128
+ /**
129
+ * Pass the plugins to the parent context.
130
+ */
131
+
132
+ context.plugins.register([(0, _dynamoDb.default)()]);
133
+ },
103
134
  getEntities: () => entities,
104
135
  getTable: () => tableInstance,
105
136
  system: (0, _system2.createSystemStorageOperations)({
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStorageOperations","params","attributes","table","documentClient","plugins","userPlugins","tableInstance","createTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","createFilterCreatePlugins","name","beforeInit","context","fieldPlugins","byType","register","filterPathPlugins","CmsEntryFieldFilterPathPlugin","type","filterPlugins","CmsEntryFieldFilterPlugin","sortingPlugins","CmsEntryFieldSortingPlugin","getEntities","getTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { createModelsStorageOperations } from \"~/operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin\n} from \"~/plugins\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { attributes, table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins(),\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || [])\n ]);\n\n return {\n name: \"dynamodb\",\n beforeInit: async context => {\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n\n const filterPathPlugins = context.plugins.byType<CmsEntryFieldFilterPathPlugin>(\n CmsEntryFieldFilterPathPlugin.type\n );\n plugins.register(filterPathPlugins);\n\n const filterPlugins = context.plugins.byType<CmsEntryFieldFilterPlugin>(\n CmsEntryFieldFilterPlugin.type\n );\n plugins.register(filterPlugins);\n\n const sortingPlugins = context.plugins.byType<CmsEntryFieldSortingPlugin>(\n CmsEntryFieldSortingPlugin.type\n );\n plugins.register(sortingPlugins);\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AAMA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IAAEC,UAAF;IAAcC,KAAd;IAAqBC,cAArB;IAAqCC,OAAO,EAAEC;EAA9C,IAA8DL,MAApE;EAEA,MAAMM,aAAa,GAAG,IAAAC,kBAAA,EAAY;IAC9BL,KAD8B;IAE9BC;EAF8B,CAAZ,CAAtB;EAKA,MAAMK,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,8BAAA,EAAqB;MAC3BC,UAAU,EAAEC,eAAA,CAASC,QADM;MAE3BX,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