@webiny/api-headless-cms-ddb 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee

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 (165) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -5
  3. package/definitions/entry.js +10 -93
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +10 -64
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +10 -108
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +4 -6
  12. package/definitions/table.js +7 -26
  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 +8 -12
  18. package/dynamoDb/index.js.map +1 -1
  19. package/index.d.ts +2 -3
  20. package/index.js +87 -128
  21. package/index.js.map +1 -1
  22. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  23. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  24. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  25. package/operations/entry/dataLoader/constants.d.ts +1 -0
  26. package/operations/entry/dataLoader/constants.js +5 -0
  27. package/operations/entry/dataLoader/constants.js.map +1 -0
  28. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  29. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  30. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  31. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  32. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  33. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  34. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  35. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
  36. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  37. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  38. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
  39. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  40. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  41. package/operations/entry/dataLoader/getRevisionById.js +42 -0
  42. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  43. package/operations/entry/dataLoader/index.d.ts +8 -0
  44. package/operations/entry/dataLoader/index.js +18 -0
  45. package/operations/entry/dataLoader/index.js.map +1 -0
  46. package/operations/entry/dataLoader/types.d.ts +6 -0
  47. package/operations/entry/dataLoader/types.js +0 -0
  48. package/operations/entry/dataLoaders.d.ts +14 -30
  49. package/operations/entry/dataLoaders.js +84 -272
  50. package/operations/entry/dataLoaders.js.map +1 -1
  51. package/operations/entry/index.d.ts +5 -4
  52. package/operations/entry/index.js +899 -807
  53. package/operations/entry/index.js.map +1 -1
  54. package/operations/entry/keys.d.ts +46 -2
  55. package/operations/entry/keys.js +54 -49
  56. package/operations/entry/keys.js.map +1 -1
  57. package/operations/group/index.d.ts +4 -5
  58. package/operations/group/index.js +117 -158
  59. package/operations/group/index.js.map +1 -1
  60. package/operations/model/index.d.ts +3 -3
  61. package/operations/model/index.js +103 -134
  62. package/operations/model/index.js.map +1 -1
  63. package/package.json +32 -33
  64. package/plugins/index.d.ts +2 -4
  65. package/plugins/index.js +1 -49
  66. package/types.d.ts +25 -41
  67. package/types.js +8 -14
  68. package/types.js.map +1 -1
  69. package/definitions/settings.d.ts +0 -9
  70. package/definitions/settings.js +0 -53
  71. package/definitions/settings.js.map +0 -1
  72. package/definitions/system.d.ts +0 -9
  73. package/definitions/system.js +0 -41
  74. package/definitions/system.js.map +0 -1
  75. package/dynamoDb/path/plainObject.d.ts +0 -2
  76. package/dynamoDb/path/plainObject.js +0 -33
  77. package/dynamoDb/path/plainObject.js.map +0 -1
  78. package/dynamoDb/storage/date.d.ts +0 -3
  79. package/dynamoDb/storage/date.js +0 -91
  80. package/dynamoDb/storage/date.js.map +0 -1
  81. package/dynamoDb/storage/longText.d.ts +0 -10
  82. package/dynamoDb/storage/longText.js +0 -91
  83. package/dynamoDb/storage/longText.js.map +0 -1
  84. package/dynamoDb/storage/richText.d.ts +0 -2
  85. package/dynamoDb/storage/richText.js +0 -95
  86. package/dynamoDb/storage/richText.js.map +0 -1
  87. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  88. package/dynamoDb/transformValue/datetime.js +0 -45
  89. package/dynamoDb/transformValue/datetime.js.map +0 -1
  90. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  91. package/operations/entry/filtering/createExpressions.js +0 -176
  92. package/operations/entry/filtering/createExpressions.js.map +0 -1
  93. package/operations/entry/filtering/createFields.d.ts +0 -14
  94. package/operations/entry/filtering/createFields.js +0 -105
  95. package/operations/entry/filtering/createFields.js.map +0 -1
  96. package/operations/entry/filtering/extractSort.d.ts +0 -17
  97. package/operations/entry/filtering/extractSort.js +0 -67
  98. package/operations/entry/filtering/extractSort.js.map +0 -1
  99. package/operations/entry/filtering/filter.d.ts +0 -15
  100. package/operations/entry/filtering/filter.js +0 -143
  101. package/operations/entry/filtering/filter.js.map +0 -1
  102. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  103. package/operations/entry/filtering/fullTextSearch.js +0 -48
  104. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  105. package/operations/entry/filtering/getValue.d.ts +0 -5
  106. package/operations/entry/filtering/getValue.js +0 -63
  107. package/operations/entry/filtering/getValue.js.map +0 -1
  108. package/operations/entry/filtering/index.d.ts +0 -2
  109. package/operations/entry/filtering/index.js +0 -19
  110. package/operations/entry/filtering/index.js.map +0 -1
  111. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  112. package/operations/entry/filtering/mapPlugins.js +0 -31
  113. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  114. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  115. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
  116. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  117. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  118. package/operations/entry/filtering/plugins/index.js +0 -13
  119. package/operations/entry/filtering/plugins/index.js.map +0 -1
  120. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  121. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
  122. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  123. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
  124. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
  125. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  126. package/operations/entry/filtering/sort.d.ts +0 -12
  127. package/operations/entry/filtering/sort.js +0 -69
  128. package/operations/entry/filtering/sort.js.map +0 -1
  129. package/operations/entry/filtering/systemFields.d.ts +0 -4
  130. package/operations/entry/filtering/systemFields.js +0 -70
  131. package/operations/entry/filtering/systemFields.js.map +0 -1
  132. package/operations/entry/filtering/transform.d.ts +0 -6
  133. package/operations/entry/filtering/transform.js +0 -16
  134. package/operations/entry/filtering/transform.js.map +0 -1
  135. package/operations/entry/filtering/types.d.ts +0 -40
  136. package/operations/entry/filtering/types.js +0 -5
  137. package/operations/entry/filtering/types.js.map +0 -1
  138. package/operations/entry/filtering/values.d.ts +0 -2
  139. package/operations/entry/filtering/values.js +0 -22
  140. package/operations/entry/filtering/values.js.map +0 -1
  141. package/operations/entry/filtering/where.d.ts +0 -5
  142. package/operations/entry/filtering/where.js +0 -32
  143. package/operations/entry/filtering/where.js.map +0 -1
  144. package/operations/entry/systemFields.d.ts +0 -2
  145. package/operations/entry/systemFields.js +0 -72
  146. package/operations/entry/systemFields.js.map +0 -1
  147. package/operations/settings/index.d.ts +0 -7
  148. package/operations/settings/index.js +0 -111
  149. package/operations/settings/index.js.map +0 -1
  150. package/operations/system/index.d.ts +0 -7
  151. package/operations/system/index.js +0 -82
  152. package/operations/system/index.js.map +0 -1
  153. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
  154. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
  155. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  156. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  157. package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
  158. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  159. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  160. package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
  161. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  162. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  163. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
  164. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  165. package/plugins/index.js.map +0 -1
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb",
3
- "version": "0.0.0-unstable.b14eaecf38",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.b6d7105cee",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "keywords": [
6
10
  "@webiny/api-headless-cms",
7
11
  "storage-operations",
8
12
  "dynamodb",
13
+ "ddb",
9
14
  "cms:ddb"
10
15
  ],
11
16
  "repository": {
@@ -21,40 +26,34 @@
21
26
  ],
22
27
  "license": "MIT",
23
28
  "dependencies": {
24
- "@babel/runtime": "7.20.13",
25
- "@webiny/api-headless-cms": "0.0.0-unstable.b14eaecf38",
26
- "@webiny/db-dynamodb": "0.0.0-unstable.b14eaecf38",
27
- "@webiny/error": "0.0.0-unstable.b14eaecf38",
28
- "@webiny/handler-db": "0.0.0-unstable.b14eaecf38",
29
- "@webiny/utils": "0.0.0-unstable.b14eaecf38",
30
- "aws-sdk": "2.1310.0",
31
- "dataloader": "2.2.1",
32
- "dot-prop": "6.0.1",
33
- "dynamodb-toolbox": "0.3.5",
34
- "jsonpack": "1.1.5",
35
- "lodash": "4.17.21"
29
+ "@webiny/api": "0.0.0-unstable.b6d7105cee",
30
+ "@webiny/api-headless-cms": "0.0.0-unstable.b6d7105cee",
31
+ "@webiny/api-headless-cms-storage": "0.0.0-unstable.b6d7105cee",
32
+ "@webiny/aws-sdk": "0.0.0-unstable.b6d7105cee",
33
+ "@webiny/db-dynamodb": "0.0.0-unstable.b6d7105cee",
34
+ "@webiny/db-utils": "0.0.0-unstable.b6d7105cee",
35
+ "@webiny/error": "0.0.0-unstable.b6d7105cee",
36
+ "@webiny/feature": "0.0.0-unstable.b6d7105cee",
37
+ "@webiny/handler": "0.0.0-unstable.b6d7105cee",
38
+ "@webiny/handler-db": "0.0.0-unstable.b6d7105cee",
39
+ "@webiny/plugins": "0.0.0-unstable.b6d7105cee",
40
+ "@webiny/utils": "0.0.0-unstable.b6d7105cee",
41
+ "dataloader": "2.2.3"
36
42
  },
37
43
  "devDependencies": {
38
- "@babel/cli": "^7.19.3",
39
- "@babel/core": "^7.19.3",
40
- "@babel/preset-env": "^7.19.4",
41
- "@types/jsonpack": "^1.1.0",
42
- "@webiny/cli": "^0.0.0-unstable.b14eaecf38",
43
- "@webiny/plugins": "^0.0.0-unstable.b14eaecf38",
44
- "@webiny/project-utils": "^0.0.0-unstable.b14eaecf38",
45
- "jest": "^28.1.0",
46
- "jest-dynalite": "^3.2.0",
47
- "jest-environment-node": "^27.2.4",
48
- "ttypescript": "^1.5.12",
49
- "typescript": "4.7.4"
44
+ "@types/jsonpack": "1.1.6",
45
+ "@webiny/build-tools": "0.0.0-unstable.b6d7105cee",
46
+ "@webiny/di": "1.0.2",
47
+ "@webiny/project-utils": "0.0.0-unstable.b6d7105cee",
48
+ "jest-dynalite": "3.6.1",
49
+ "typescript": "7.0.2",
50
+ "vitest": "4.1.10"
50
51
  },
51
52
  "publishConfig": {
52
- "access": "public",
53
- "directory": "dist"
54
- },
55
- "scripts": {
56
- "build": "yarn webiny run build",
57
- "watch": "yarn webiny run watch"
53
+ "access": "public"
58
54
  },
59
- "gitHead": "b14eaecf387253ed23cb96f8d31b7d16b5061936"
55
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
56
+ "webiny": {
57
+ "publishFrom": "dist"
58
+ }
60
59
  }
@@ -1,4 +1,2 @@
1
- export * from "./CmsEntryFieldFilterPathPlugin";
2
- export * from "./CmsEntryFieldSortingPlugin";
3
- export * from "./CmsEntryFieldFilterPlugin";
4
- export * from "./CmsFieldFilterValueTransformPlugin";
1
+ export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldSortingPlugin, createCmsEntryFieldSortingPlugin, CmsEntryFieldFilterPlugin, CmsFieldFilterValueTransformPlugin } from "@webiny/api-headless-cms-storage";
2
+ export type { CreatePathCallable, CmsEntryFieldFilterPluginCreateResponse } from "@webiny/api-headless-cms-storage";
package/plugins/index.js CHANGED
@@ -1,49 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
7
- Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _CmsEntryFieldFilterPathPlugin[key];
14
- }
15
- });
16
- });
17
- var _CmsEntryFieldSortingPlugin = require("./CmsEntryFieldSortingPlugin");
18
- Object.keys(_CmsEntryFieldSortingPlugin).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _CmsEntryFieldSortingPlugin[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _CmsEntryFieldSortingPlugin[key];
25
- }
26
- });
27
- });
28
- var _CmsEntryFieldFilterPlugin = require("./CmsEntryFieldFilterPlugin");
29
- Object.keys(_CmsEntryFieldFilterPlugin).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _CmsEntryFieldFilterPlugin[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _CmsEntryFieldFilterPlugin[key];
36
- }
37
- });
38
- });
39
- var _CmsFieldFilterValueTransformPlugin = require("./CmsFieldFilterValueTransformPlugin");
40
- Object.keys(_CmsFieldFilterValueTransformPlugin).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _CmsFieldFilterValueTransformPlugin[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _CmsFieldFilterValueTransformPlugin[key];
47
- }
48
- });
49
- });
1
+ export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin, createCmsEntryFieldSortingPlugin } from "@webiny/api-headless-cms-storage";
package/types.d.ts CHANGED
@@ -1,53 +1,37 @@
1
- import { Plugin } from "@webiny/plugins/types";
2
- import { CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
- import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
4
- import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
5
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
6
- import { Entity, Table } from "dynamodb-toolbox";
7
- interface CmsFieldFilterValueTransformParams {
8
- /**
9
- * A field which value we are transforming.
10
- */
11
- field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
12
- value: any;
13
- }
14
- export interface CmsFieldFilterValueTransformPlugin extends Plugin {
15
- /**
16
- * A plugin type.
17
- */
18
- type: "cms-field-filter-value-transform";
19
- /**
20
- * A field type this plugin is for.
21
- */
22
- fieldType: string;
23
- /**
24
- * Transform method which expect field definition and value to transform.
25
- */
26
- transform: (params: CmsFieldFilterValueTransformParams) => any;
27
- }
28
- export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
29
- export declare type Attributes = Record<string, AttributeDefinition>;
1
+ import { PluginsContainer } from "@webiny/plugins/types.js";
2
+ import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
4
+ import type { ITable } from "@webiny/db-dynamodb";
5
+ export type { CmsContext };
6
+ export type { IGroupEntity, IModelEntity, IEntryEntity };
30
7
  export declare enum ENTITIES {
31
- SYSTEM = "CmsSystem",
32
- SETTINGS = "CmsSettings",
33
8
  GROUPS = "CmsGroups",
34
9
  MODELS = "CmsModels",
35
10
  ENTRIES = "CmsEntries"
36
11
  }
37
- export interface TableModifier {
38
- (table: TableConstructor): TableConstructor;
39
- }
40
12
  export interface StorageOperationsFactoryParams {
41
- documentClient: DocumentClient;
42
- table?: TableModifier;
43
- attributes?: Record<ENTITIES, Attributes>;
44
- plugins?: Plugin[] | Plugin[][];
13
+ table?: string;
14
+ plugins: PluginsContainer;
15
+ container: CmsContext["container"];
16
+ }
17
+ export interface IHeadlessCmsStorageOperationsGetEntitiesResult {
18
+ groups: IGroupEntity;
19
+ models: IModelEntity;
20
+ entries: IEntryEntity;
45
21
  }
46
22
  export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
47
- getTable: () => Table;
48
- getEntities: () => Record<"system" | "settings" | "groups" | "models" | "entries", Entity<any>>;
23
+ getTable: () => ITable;
24
+ getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;
49
25
  }
50
26
  export interface StorageOperationsFactory {
51
27
  (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
52
28
  }
53
- export {};
29
+ export interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {
30
+ dataLoaders: IDataLoadersHandler;
31
+ }
32
+ export interface DataLoadersHandlerInterfaceClearAllParams {
33
+ tenant: string;
34
+ }
35
+ export interface IDataLoadersHandler {
36
+ clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
37
+ }
package/types.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
1
+ var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
2
+ ENTITIES["GROUPS"] = "CmsGroups";
3
+ ENTITIES["MODELS"] = "CmsModels";
4
+ ENTITIES["ENTRIES"] = "CmsEntries";
5
+ return ENTITIES;
6
+ }({});
7
+ export { types_ENTITIES as ENTITIES };
2
8
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ENTITIES = void 0;
7
- let ENTITIES;
8
- exports.ENTITIES = ENTITIES;
9
- (function (ENTITIES) {
10
- ENTITIES["SYSTEM"] = "CmsSystem";
11
- ENTITIES["SETTINGS"] = "CmsSettings";
12
- ENTITIES["GROUPS"] = "CmsGroups";
13
- ENTITIES["MODELS"] = "CmsModels";
14
- ENTITIES["ENTRIES"] = "CmsEntries";
15
- })(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
9
+ //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEntities: () => Record<\"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"],"mappings":";;;;;;IAyCYA,QAAQ;AAAA;AAAA,WAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;AAAA,GAARA,QAAQ,wBAARA,QAAQ"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\nexport type { CmsContext };\n\nexport type { IGroupEntity, IModelEntity, IEntryEntity };\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface StorageOperationsFactoryParams {\n table?: string;\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n}\n\nexport interface IHeadlessCmsStorageOperationsGetEntitiesResult {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => ITable;\n getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAaO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
@@ -1,9 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- interface Params {
4
- table: Table;
5
- entityName: string;
6
- attributes: Attributes;
7
- }
8
- export declare const createSettingsEntity: (params: Params) => Entity<any>;
9
- export {};
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createSettingsEntity = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _dynamodbToolbox = require("dynamodb-toolbox");
10
- const createSettingsEntity = params => {
11
- const {
12
- entityName,
13
- table,
14
- attributes
15
- } = params;
16
- return new _dynamodbToolbox.Entity({
17
- name: entityName,
18
- table,
19
- attributes: (0, _objectSpread2.default)({
20
- PK: {
21
- partitionKey: true
22
- },
23
- SK: {
24
- sortKey: true
25
- },
26
- TYPE: {
27
- type: "string"
28
- },
29
- key: {
30
- type: "string"
31
- },
32
- uploadMinFileSize: {
33
- type: "number"
34
- },
35
- uploadMaxFileSize: {
36
- type: "number"
37
- },
38
- srcPrefix: {
39
- type: "string"
40
- },
41
- contentModelLastChange: {
42
- type: "string"
43
- },
44
- tenant: {
45
- type: "string"
46
- },
47
- locale: {
48
- type: "string"
49
- }
50
- }, attributes || {})
51
- });
52
- };
53
- exports.createSettingsEntity = createSettingsEntity;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSettingsEntity","params","entityName","table","attributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix","contentModelLastChange","tenant","locale"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, table, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n contentModelLastChange: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AASO,MAAMA,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBC,KAAK;IACLC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,GAAG,EAAE;QACDD,IAAI,EAAE;MACV,CAAC;MACDE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MACV,CAAC;MACDG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MACV,CAAC;MACDI,SAAS,EAAE;QACPJ,IAAI,EAAE;MACV,CAAC;MACDK,sBAAsB,EAAE;QACpBL,IAAI,EAAE;MACV,CAAC;MACDM,MAAM,EAAE;QACJN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV;IAAC,GACGR,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,9 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- interface Params {
4
- table: Table;
5
- entityName: string;
6
- attributes: Attributes;
7
- }
8
- export declare const createSystemEntity: (params: Params) => Entity<any>;
9
- export {};
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createSystemEntity = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _dynamodbToolbox = require("dynamodb-toolbox");
10
- const createSystemEntity = params => {
11
- const {
12
- entityName,
13
- attributes,
14
- table
15
- } = params;
16
- return new _dynamodbToolbox.Entity({
17
- name: entityName,
18
- table,
19
- attributes: (0, _objectSpread2.default)({
20
- PK: {
21
- partitionKey: true
22
- },
23
- SK: {
24
- sortKey: true
25
- },
26
- version: {
27
- type: "string"
28
- },
29
- locale: {
30
- type: "string"
31
- },
32
- tenant: {
33
- type: "string"
34
- },
35
- readAPIKey: {
36
- type: "string"
37
- }
38
- }, attributes || {})
39
- });
40
- };
41
- exports.createSystemEntity = createSystemEntity;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n readAPIKey: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AASO,MAAMA,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,UAAU,EAAE;QACRH,IAAI,EAAE;MACV;IAAC,GACGT,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,2 +0,0 @@
1
- import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin";
2
- export declare const createPlainObjectPathPlugin: () => CmsEntryFieldFilterPathPlugin;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createPlainObjectPathPlugin = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
10
- /**
11
- * File is @internal
12
- */
13
-
14
- const createPath = ({
15
- field
16
- }) => {
17
- const {
18
- path
19
- } = field.settings || {};
20
- if (!path) {
21
- throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
22
- field
23
- });
24
- }
25
- return path;
26
- };
27
- const createPlainObjectPathPlugin = () => {
28
- return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
29
- fieldType: "plainObject",
30
- path: createPath
31
- });
32
- };
33
- exports.createPlainObjectPathPlugin = createPlainObjectPathPlugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createPath","field","path","settings","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAOA,MAAMA,UAA8B,GAAG,CAAC;EAAEC;AAAM,CAAC,KAAK;EAClD,MAAM;IAAEC;EAAK,CAAC,GAAGD,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;EACrC,IAAI,CAACD,IAAI,EAAE;IACP,MAAM,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,2BAA2B,GAAG,MAAqC;EAC5E,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,aAAa;IACxBL,IAAI,EAAEF;EACV,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,3 +0,0 @@
1
- import { StorageTransformPlugin } from "@webiny/api-headless-cms";
2
- import { CmsModelField } from "@webiny/api-headless-cms/types";
3
- export declare const createDateStorageTransformPlugin: () => StorageTransformPlugin<any, any, CmsModelField>;
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createDateStorageTransformPlugin = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
10
- /**
11
- * File is @internal
12
- */
13
-
14
- const excludeTypes = ["time", "dateTimeWithTimezone"];
15
- const convertFromStorage = (field, value) => {
16
- try {
17
- if (field.multipleValues) {
18
- const result = [];
19
- for (const v of value) {
20
- if (!v) {
21
- continue;
22
- }
23
- try {
24
- result.push(new Date(v));
25
- } catch {}
26
- }
27
- return result;
28
- }
29
- return new Date(value);
30
- } catch {
31
- console.log(`Could not transform from storage for field type`);
32
- return value;
33
- }
34
- };
35
- const convertValueToStorage = (field, value) => {
36
- if (value.toISOString) {
37
- return value.toISOString();
38
- } else if (typeof value === "string") {
39
- return value;
40
- }
41
- throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
42
- value: value,
43
- fieldId: field.fieldId,
44
- storageId: field.storageId
45
- });
46
- };
47
- const createDateStorageTransformPlugin = () => {
48
- return new _apiHeadlessCms.StorageTransformPlugin({
49
- fieldType: "datetime",
50
- fromStorage: async ({
51
- value,
52
- field
53
- }) => {
54
- const {
55
- type
56
- } = field.settings || {};
57
- if (!value || !type || excludeTypes.includes(type)) {
58
- return value;
59
- }
60
- return convertFromStorage(field, value);
61
- },
62
- toStorage: async ({
63
- value,
64
- field
65
- }) => {
66
- const {
67
- type
68
- } = field.settings || {};
69
- if (!value || !type || excludeTypes.includes(type)) {
70
- return value;
71
- }
72
- if (field.multipleValues) {
73
- const multipleValues = value;
74
- return (multipleValues || []).filter(v => !!v).map(v => {
75
- return convertValueToStorage(field, v);
76
- });
77
- }
78
- if (value.toISOString) {
79
- return value.toISOString();
80
- } else if (typeof value === "string") {
81
- return value;
82
- }
83
- throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
84
- value,
85
- fieldId: field.fieldId,
86
- storageId: field.storageId
87
- });
88
- }
89
- });
90
- };
91
- exports.createDateStorageTransformPlugin = createDateStorageTransformPlugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","result","v","push","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","filter","map"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (\n field: Pick<CmsModelField, \"multipleValues\">,\n value: string | string[]\n) => {\n try {\n if (field.multipleValues) {\n const result: Date[] = [];\n for (const v of value) {\n if (!v) {\n continue;\n }\n try {\n result.push(new Date(v));\n } catch {}\n }\n return result;\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n};\n"],"mappings":"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"}
@@ -1,10 +0,0 @@
1
- /**
2
- * File is @internal
3
- */
4
- import { StorageTransformPlugin } from "@webiny/api-headless-cms";
5
- export interface StorageValue {
6
- compression: string;
7
- value: string;
8
- isArray?: boolean;
9
- }
10
- export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createLongTextStorageTransformPlugin = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _gzip = require("@webiny/utils/compression/gzip");
10
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
11
- /**
12
- * File is @internal
13
- */
14
-
15
- const GZIP = "gzip";
16
- const TO_STORAGE_ENCODING = "base64";
17
- const FROM_STORAGE_ENCODING = "utf8";
18
- const convertToBuffer = value => {
19
- if (typeof value === "string") {
20
- return Buffer.from(value, TO_STORAGE_ENCODING);
21
- }
22
- return value;
23
- };
24
- const createLongTextStorageTransformPlugin = () => {
25
- return new _apiHeadlessCms.StorageTransformPlugin({
26
- fieldType: "long-text",
27
- fromStorage: async ({
28
- field,
29
- value: storageValue
30
- }) => {
31
- const typeOf = typeof storageValue;
32
- if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
33
- return storageValue;
34
- } else if (typeOf !== "object") {
35
- throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
36
- }
37
- const {
38
- compression,
39
- value,
40
- isArray
41
- } = storageValue;
42
- /**
43
- * Check if possibly undefined, null, empty...
44
- */
45
- if (!compression) {
46
- throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
47
- value: storageValue
48
- });
49
- } else if (compression !== GZIP) {
50
- throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
51
- compression
52
- });
53
- }
54
- try {
55
- const buf = await (0, _gzip.decompress)(convertToBuffer(value));
56
- const result = buf.toString(FROM_STORAGE_ENCODING);
57
- if (!isArray) {
58
- return result;
59
- }
60
- return JSON.parse(result);
61
- } catch (ex) {
62
- console.log("Error while transforming long-text.");
63
- console.log(ex.message);
64
- return "";
65
- }
66
- },
67
- toStorage: async ({
68
- value: initialValue
69
- }) => {
70
- /**
71
- * There is a possibility that we are trying to compress already compressed value.
72
- */
73
- if (initialValue && initialValue.hasOwnProperty("compression") === true) {
74
- return initialValue;
75
- }
76
- const isArray = Array.isArray(initialValue);
77
- const value = isArray ? JSON.stringify(initialValue) : initialValue;
78
- const compressedValue = await (0, _gzip.compress)(value);
79
- const result = {
80
- compression: GZIP,
81
- value: compressedValue.toString(TO_STORAGE_ENCODING)
82
- };
83
- if (!isArray) {
84
- return result;
85
- }
86
- result.isArray = isArray;
87
- return result;
88
- }
89
- });
90
- };
91
- exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;