@webiny/api-headless-cms-ddb 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.9bd236cf5e

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 (154) hide show
  1. package/definitions/entry.d.ts +4 -3
  2. package/definitions/entry.js +104 -13
  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 +9 -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 +4 -3
  17. package/dynamoDb/index.js.map +1 -1
  18. package/dynamoDb/path/locationFolderId.js +4 -2
  19. package/dynamoDb/path/locationFolderId.js.map +1 -1
  20. package/dynamoDb/path/plainObject.js +3 -1
  21. package/dynamoDb/path/plainObject.js.map +1 -1
  22. package/dynamoDb/storage/longText.js +4 -1
  23. package/dynamoDb/storage/longText.js.map +1 -1
  24. package/dynamoDb/storage/richText.js +24 -58
  25. package/dynamoDb/storage/richText.js.map +1 -1
  26. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  27. package/dynamoDb/transformValue/datetime.js +3 -1
  28. package/dynamoDb/transformValue/datetime.js.map +1 -1
  29. package/index.d.ts +1 -1
  30. package/index.js +5 -12
  31. package/index.js.map +1 -1
  32. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -1
  33. package/operations/entry/dataLoader/DataLoaderCache.js +7 -9
  34. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  35. package/operations/entry/dataLoader/constants.js +3 -2
  36. package/operations/entry/dataLoader/constants.js.map +1 -1
  37. package/operations/entry/dataLoader/createBatchScheduleFn.js +3 -1
  38. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  39. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +2 -2
  40. package/operations/entry/dataLoader/getAllEntryRevisions.js +3 -1
  41. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  42. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +2 -2
  43. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +5 -6
  44. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  45. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +2 -2
  46. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +5 -6
  47. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  48. package/operations/entry/dataLoader/getRevisionById.d.ts +2 -2
  49. package/operations/entry/dataLoader/getRevisionById.js +5 -6
  50. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  51. package/operations/entry/dataLoader/index.d.ts +3 -3
  52. package/operations/entry/dataLoader/index.js +3 -1
  53. package/operations/entry/dataLoader/index.js.map +1 -1
  54. package/operations/entry/dataLoader/types.d.ts +1 -1
  55. package/operations/entry/dataLoader/types.js +3 -1
  56. package/operations/entry/dataLoader/types.js.map +1 -1
  57. package/operations/entry/dataLoaders.d.ts +3 -3
  58. package/operations/entry/dataLoaders.js +15 -14
  59. package/operations/entry/dataLoaders.js.map +1 -1
  60. package/operations/entry/filtering/createExpressions.d.ts +4 -4
  61. package/operations/entry/filtering/createExpressions.js +3 -1
  62. package/operations/entry/filtering/createExpressions.js.map +1 -1
  63. package/operations/entry/filtering/createFields.d.ts +3 -3
  64. package/operations/entry/filtering/createFields.js +12 -9
  65. package/operations/entry/filtering/createFields.js.map +1 -1
  66. package/operations/entry/filtering/extractSort.d.ts +3 -3
  67. package/operations/entry/filtering/extractSort.js +3 -1
  68. package/operations/entry/filtering/extractSort.js.map +1 -1
  69. package/operations/entry/filtering/filter.d.ts +3 -3
  70. package/operations/entry/filtering/filter.js +24 -9
  71. package/operations/entry/filtering/filter.js.map +1 -1
  72. package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
  73. package/operations/entry/filtering/fullTextSearch.js +3 -1
  74. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  75. package/operations/entry/filtering/getValue.js +6 -3
  76. package/operations/entry/filtering/getValue.js.map +1 -1
  77. package/operations/entry/filtering/index.js +3 -1
  78. package/operations/entry/filtering/index.js.map +1 -1
  79. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  80. package/operations/entry/filtering/mapPlugins.js +3 -1
  81. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  82. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
  83. package/operations/entry/filtering/plugins/defaultFilterCreate.js +3 -1
  84. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  85. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  86. package/operations/entry/filtering/plugins/index.js +5 -2
  87. package/operations/entry/filtering/plugins/index.js.map +1 -1
  88. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
  89. package/operations/entry/filtering/plugins/objectFilterCreate.js +3 -1
  90. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  91. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -1
  92. package/operations/entry/filtering/plugins/refFilterCreate.js +9 -2
  93. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  94. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  95. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
  96. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  97. package/operations/entry/filtering/sort.d.ts +3 -3
  98. package/operations/entry/filtering/sort.js +5 -3
  99. package/operations/entry/filtering/sort.js.map +1 -1
  100. package/operations/entry/filtering/systemFields.d.ts +2 -2
  101. package/operations/entry/filtering/systemFields.js +34 -32
  102. package/operations/entry/filtering/systemFields.js.map +1 -1
  103. package/operations/entry/filtering/transform.d.ts +1 -1
  104. package/operations/entry/filtering/transform.js +3 -1
  105. package/operations/entry/filtering/transform.js.map +1 -1
  106. package/operations/entry/filtering/types.d.ts +2 -2
  107. package/operations/entry/filtering/types.js +3 -1
  108. package/operations/entry/filtering/types.js.map +1 -1
  109. package/operations/entry/filtering/values.d.ts +1 -1
  110. package/operations/entry/filtering/values.js +3 -1
  111. package/operations/entry/filtering/values.js.map +1 -1
  112. package/operations/entry/filtering/where.js +3 -1
  113. package/operations/entry/filtering/where.js.map +1 -1
  114. package/operations/entry/index.d.ts +3 -3
  115. package/operations/entry/index.js +585 -197
  116. package/operations/entry/index.js.map +1 -1
  117. package/operations/entry/keys.js +3 -1
  118. package/operations/entry/keys.js.map +1 -1
  119. package/operations/group/index.d.ts +3 -3
  120. package/operations/group/index.js +33 -21
  121. package/operations/group/index.js.map +1 -1
  122. package/operations/model/index.d.ts +2 -2
  123. package/operations/model/index.js +26 -13
  124. package/operations/model/index.js.map +1 -1
  125. package/operations/system/index.d.ts +2 -2
  126. package/operations/system/index.js +19 -7
  127. package/operations/system/index.js.map +1 -1
  128. package/package.json +19 -24
  129. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +1 -1
  130. package/plugins/CmsEntryFieldFilterPathPlugin.js +8 -3
  131. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  132. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  133. package/plugins/CmsEntryFieldFilterPlugin.js +9 -6
  134. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  135. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  136. package/plugins/CmsEntryFieldSortingPlugin.js +4 -5
  137. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  138. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +2 -2
  139. package/plugins/CmsFieldFilterValueTransformPlugin.js +3 -4
  140. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
  141. package/plugins/index.js +3 -1
  142. package/plugins/index.js.map +1 -1
  143. package/types.d.ts +11 -13
  144. package/types.js +5 -5
  145. package/types.js.map +1 -1
  146. package/definitions/settings.d.ts +0 -9
  147. package/definitions/settings.js +0 -53
  148. package/definitions/settings.js.map +0 -1
  149. package/dynamoDb/storage/date.d.ts +0 -3
  150. package/dynamoDb/storage/date.js +0 -82
  151. package/dynamoDb/storage/date.js.map +0 -1
  152. package/operations/settings/index.d.ts +0 -7
  153. package/operations/settings/index.js +0 -111
  154. package/operations/settings/index.js.map +0 -1
package/types.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Plugin } from "@webiny/plugins/types";
2
- import { CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, 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";
1
+ import type { Plugin } from "@webiny/plugins/types";
2
+ import type { CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
+ import type { TableConstructor } from "@webiny/db-dynamodb/toolbox";
4
+ import type { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
5
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
6
+ import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
7
7
  interface CmsFieldFilterValueTransformParams {
8
8
  /**
9
9
  * A field which value we are transforming.
@@ -25,27 +25,25 @@ export interface CmsFieldFilterValueTransformPlugin extends Plugin {
25
25
  */
26
26
  transform: (params: CmsFieldFilterValueTransformParams) => any;
27
27
  }
28
- export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
29
- export declare type Attributes = Record<string, AttributeDefinition>;
28
+ export type Attributes = Record<string, AttributeDefinition>;
30
29
  export declare enum ENTITIES {
31
30
  SYSTEM = "CmsSystem",
32
- SETTINGS = "CmsSettings",
33
31
  GROUPS = "CmsGroups",
34
32
  MODELS = "CmsModels",
35
33
  ENTRIES = "CmsEntries"
36
34
  }
37
35
  export interface TableModifier {
38
- (table: TableConstructor): TableConstructor;
36
+ (table: TableConstructor<string, string, string>): TableConstructor<string, string, string>;
39
37
  }
40
38
  export interface StorageOperationsFactoryParams {
41
- documentClient: DocumentClient;
39
+ documentClient: DynamoDBDocument;
42
40
  table?: TableModifier;
43
41
  attributes?: Record<ENTITIES, Attributes>;
44
42
  plugins?: Plugin[] | Plugin[][];
45
43
  }
46
44
  export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
47
- getTable: () => Table;
48
- getEntities: () => Record<"system" | "settings" | "groups" | "models" | "entries", Entity<any>>;
45
+ getTable: () => Table<string, string, string>;
46
+ getEntities: () => Record<"system" | "groups" | "models" | "entries", Entity<any>>;
49
47
  }
50
48
  export interface StorageOperationsFactory {
51
49
  (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
package/types.js CHANGED
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ENTITIES = void 0;
7
- let ENTITIES;
8
- exports.ENTITIES = ENTITIES;
9
- (function (ENTITIES) {
7
+ let ENTITIES = exports.ENTITIES = /*#__PURE__*/function (ENTITIES) {
10
8
  ENTITIES["SYSTEM"] = "CmsSystem";
11
- ENTITIES["SETTINGS"] = "CmsSettings";
12
9
  ENTITIES["GROUPS"] = "CmsGroups";
13
10
  ENTITIES["MODELS"] = "CmsModels";
14
11
  ENTITIES["ENTRIES"] = "CmsEntries";
15
- })(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
12
+ return ENTITIES;
13
+ }({});
14
+
15
+ //# 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 CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\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\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: DataLoadersHandlerInterface;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\">;\n}\nexport interface DataLoadersHandlerInterface {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":";;;;;;IA2CYA,QAAQ;AAAA;AAAA,WAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;AAAA,GAARA,QAAQ,wBAARA,QAAQ"}
1
+ {"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport type {\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport type { TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\nimport type { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity, Table } from \"@webiny/db-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 Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor<string, string, string>): TableConstructor<string, string, string>;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table<string, string, string>;\n getEntities: () => Record<\"system\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: DataLoadersHandlerInterface;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\">;\n}\nexport interface DataLoadersHandlerInterface {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":";;;;;;IAsCYA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
@@ -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,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,82 +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 instanceof Date || 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
- return convertValueToStorage(field, value);
79
- }
80
- });
81
- };
82
- 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 instanceof Date || (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 return convertValueToStorage(field, value);\n }\n });\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAKA,MAAMA,YAAY,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC;AAErD,MAAMC,kBAAkB,GAAG,CACvBC,KAA4C,EAC5CC,KAAwB,KACvB;EACD,IAAI;IACA,IAAID,KAAK,CAACE,cAAc,EAAE;MACtB,MAAMC,MAAc,GAAG,EAAE;MACzB,KAAK,MAAMC,CAAC,IAAIH,KAAK,EAAE;QACnB,IAAI,CAACG,CAAC,EAAE;UACJ;QACJ;QACA,IAAI;UACAD,MAAM,CAACE,IAA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Q,IAAI,CAAC,CAAC;MACrC,IAAI,CAAClB,KAAK,IAAI,CAACiB,IAAI,IAAIpB,YAAY,CAACsB,QAAQ,CAACF,IAAI,CAAC,EAAE;QAChD,OAAOjB,KAAK;MAChB;MACA,IAAID,KAAK,CAACE,cAAc,EAAE;QACtB,MAAMA,cAAc,GAAGD,KAA6C;QACpE,OAAO,CAACC,cAAc,IAAI,EAAE,EACvBoB,MAAM,CAAClB,CAAC,IAAI,CAAC,CAACA,CAAC,CAAC,CAChBmB,GAAG,CAACnB,CAAC,IAAI;UACN,OAAOK,qBAAqB,CAACT,KAAK,EAAEI,CAAC,CAAC;QAC1C,CAAC,CAAC;MACV;MACA,OAAOK,qBAAqB,CAACT,KAAK,EAAEC,KAAK,CAAC;IAC9C;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,7 +0,0 @@
1
- import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- interface CreateSettingsStorageOperationsParams {
4
- entity: Entity<any>;
5
- }
6
- export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
7
- export {};
@@ -1,111 +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.createSettingsStorageOperations = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _get = require("@webiny/db-dynamodb/utils/get");
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- const convertToDbData = settings => {
13
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
14
- contentModelLastChange: settings.contentModelLastChange.toISOString()
15
- });
16
- };
17
- const convertFromDbData = settings => {
18
- if (!settings) {
19
- return null;
20
- }
21
- let contentModelLastChange;
22
- try {
23
- contentModelLastChange = new Date(settings.contentModelLastChange);
24
- } catch {
25
- contentModelLastChange = new Date();
26
- }
27
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
28
- contentModelLastChange
29
- });
30
- };
31
- const createPartitionKey = ({
32
- tenant,
33
- locale
34
- }) => {
35
- return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
36
- };
37
- const createSortKey = () => {
38
- return "settings";
39
- };
40
- const createKeys = params => {
41
- return {
42
- PK: createPartitionKey(params),
43
- SK: createSortKey()
44
- };
45
- };
46
- const createSettingsStorageOperations = params => {
47
- const {
48
- entity
49
- } = params;
50
- const create = async params => {
51
- const {
52
- settings
53
- } = params;
54
- const keys = createKeys(settings);
55
- const dbSettings = convertToDbData(settings);
56
- try {
57
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
58
- return settings;
59
- } catch (ex) {
60
- throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
61
- error: ex,
62
- settings,
63
- dbSettings,
64
- keys
65
- });
66
- }
67
- };
68
- const update = async params => {
69
- const {
70
- settings
71
- } = params;
72
- const keys = createKeys(settings);
73
- const dbSettings = convertToDbData(settings);
74
- try {
75
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
76
- return settings;
77
- } catch (ex) {
78
- throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
79
- error: ex,
80
- settings,
81
- dbSettings,
82
- keys
83
- });
84
- }
85
- };
86
- const get = async params => {
87
- const keys = createKeys(params);
88
- try {
89
- const record = await (0, _get.get)({
90
- entity,
91
- keys
92
- });
93
- if (!record) {
94
- return null;
95
- }
96
- const settings = (0, _cleanup.cleanupItem)(entity, record);
97
- return convertFromDbData(settings);
98
- } catch (ex) {
99
- throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
100
- error: ex,
101
- keys
102
- });
103
- }
104
- };
105
- return {
106
- create,
107
- get,
108
- update
109
- };
110
- };
111
- exports.createSettingsStorageOperations = createSettingsStorageOperations;
@@ -1 +0,0 @@
1
- {"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,mEACOA,QAAQ;IACXC,sBAAsB,EAAED,QAAQ,CAACC,sBAAsB,CAACC,WAAW;EAAE;AAE7E,CAAC;AAED,MAAMC,iBAAiB,GAAIH,QAAwB,IAAyB;EACxE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,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