@webiny/api-headless-cms 0.0.0-mt-1

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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/content/contextSetup.d.ts +4 -0
  4. package/content/contextSetup.js +65 -0
  5. package/content/graphQLHandlerFactory.d.ts +5 -0
  6. package/content/graphQLHandlerFactory.js +173 -0
  7. package/content/plugins/CmsGroupPlugin.d.ts +11 -0
  8. package/content/plugins/CmsGroupPlugin.js +24 -0
  9. package/content/plugins/CmsModelPlugin.d.ts +11 -0
  10. package/content/plugins/CmsModelPlugin.js +24 -0
  11. package/content/plugins/buildSchemaPlugins.d.ts +7 -0
  12. package/content/plugins/buildSchemaPlugins.js +29 -0
  13. package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
  14. package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
  15. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
  16. package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
  17. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
  18. package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
  19. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +4 -0
  20. package/content/plugins/crud/contentEntry/entryDataValidation.js +188 -0
  21. package/content/plugins/crud/contentEntry/markLockedFields.d.ts +12 -0
  22. package/content/plugins/crud/contentEntry/markLockedFields.js +117 -0
  23. package/content/plugins/crud/contentEntry.crud.d.ts +17 -0
  24. package/content/plugins/crud/contentEntry.crud.js +931 -0
  25. package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
  26. package/content/plugins/crud/contentModel/afterCreate.js +18 -0
  27. package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
  28. package/content/plugins/crud/contentModel/afterDelete.js +18 -0
  29. package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
  30. package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
  31. package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
  32. package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
  33. package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
  34. package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
  35. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
  36. package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
  37. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
  38. package/content/plugins/crud/contentModel/contentModelManagerFactory.js +29 -0
  39. package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -0
  40. package/content/plugins/crud/contentModel/createFieldModels.js +22 -0
  41. package/content/plugins/crud/contentModel/idValidation.d.ts +2 -0
  42. package/content/plugins/crud/contentModel/idValidation.js +22 -0
  43. package/content/plugins/crud/contentModel/models.d.ts +3 -0
  44. package/content/plugins/crud/contentModel/models.js +141 -0
  45. package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -0
  46. package/content/plugins/crud/contentModel/validateLayout.js +38 -0
  47. package/content/plugins/crud/contentModel.crud.d.ts +12 -0
  48. package/content/plugins/crud/contentModel.crud.js +425 -0
  49. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
  50. package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
  51. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
  52. package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
  53. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
  54. package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
  55. package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -0
  56. package/content/plugins/crud/contentModelGroup.crud.js +351 -0
  57. package/content/plugins/crud/index.d.ts +6 -0
  58. package/content/plugins/crud/index.js +100 -0
  59. package/content/plugins/graphqlFields/boolean.d.ts +3 -0
  60. package/content/plugins/graphqlFields/boolean.js +69 -0
  61. package/content/plugins/graphqlFields/datetime.d.ts +3 -0
  62. package/content/plugins/graphqlFields/datetime.js +83 -0
  63. package/content/plugins/graphqlFields/file.d.ts +3 -0
  64. package/content/plugins/graphqlFields/file.js +49 -0
  65. package/content/plugins/graphqlFields/index.d.ts +2 -0
  66. package/content/plugins/graphqlFields/index.js +30 -0
  67. package/content/plugins/graphqlFields/longText.d.ts +3 -0
  68. package/content/plugins/graphqlFields/longText.js +62 -0
  69. package/content/plugins/graphqlFields/number.d.ts +3 -0
  70. package/content/plugins/graphqlFields/number.js +75 -0
  71. package/content/plugins/graphqlFields/object.d.ts +3 -0
  72. package/content/plugins/graphqlFields/object.js +180 -0
  73. package/content/plugins/graphqlFields/ref.d.ts +3 -0
  74. package/content/plugins/graphqlFields/ref.js +205 -0
  75. package/content/plugins/graphqlFields/richText.d.ts +3 -0
  76. package/content/plugins/graphqlFields/richText.js +55 -0
  77. package/content/plugins/graphqlFields/text.d.ts +3 -0
  78. package/content/plugins/graphqlFields/text.js +72 -0
  79. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +8 -0
  80. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +54 -0
  81. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +7 -0
  82. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +35 -0
  83. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
  84. package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
  85. package/content/plugins/modelManager/index.d.ts +3 -0
  86. package/content/plugins/modelManager/index.js +20 -0
  87. package/content/plugins/schema/baseSchema.d.ts +4 -0
  88. package/content/plugins/schema/baseSchema.js +98 -0
  89. package/content/plugins/schema/contentEntries.d.ts +4 -0
  90. package/content/plugins/schema/contentEntries.js +166 -0
  91. package/content/plugins/schema/contentModelGroups.d.ts +4 -0
  92. package/content/plugins/schema/contentModelGroups.js +153 -0
  93. package/content/plugins/schema/contentModels.d.ts +4 -0
  94. package/content/plugins/schema/contentModels.js +225 -0
  95. package/content/plugins/schema/createFieldResolvers.d.ts +19 -0
  96. package/content/plugins/schema/createFieldResolvers.js +92 -0
  97. package/content/plugins/schema/createManageResolvers.d.ts +11 -0
  98. package/content/plugins/schema/createManageResolvers.js +135 -0
  99. package/content/plugins/schema/createManageSDL.d.ts +9 -0
  100. package/content/plugins/schema/createManageSDL.js +153 -0
  101. package/content/plugins/schema/createPreviewResolvers.d.ts +10 -0
  102. package/content/plugins/schema/createPreviewResolvers.js +55 -0
  103. package/content/plugins/schema/createReadResolvers.d.ts +10 -0
  104. package/content/plugins/schema/createReadResolvers.js +55 -0
  105. package/content/plugins/schema/createReadSDL.d.ts +9 -0
  106. package/content/plugins/schema/createReadSDL.js +96 -0
  107. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +6 -0
  108. package/content/plugins/schema/resolvers/commonFieldResolvers.js +14 -0
  109. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +6 -0
  110. package/content/plugins/schema/resolvers/manage/resolveCreate.js +23 -0
  111. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +7 -0
  112. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +23 -0
  113. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +2 -0
  114. package/content/plugins/schema/resolvers/manage/resolveDelete.js +30 -0
  115. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +2 -0
  116. package/content/plugins/schema/resolvers/manage/resolveGet.js +21 -0
  117. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +2 -0
  118. package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +23 -0
  119. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -0
  120. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +23 -0
  121. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +2 -0
  122. package/content/plugins/schema/resolvers/manage/resolveList.js +23 -0
  123. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +2 -0
  124. package/content/plugins/schema/resolvers/manage/resolvePublish.js +21 -0
  125. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +6 -0
  126. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +23 -0
  127. package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +6 -0
  128. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +23 -0
  129. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +2 -0
  130. package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +21 -0
  131. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +7 -0
  132. package/content/plugins/schema/resolvers/manage/resolveUpdate.js +23 -0
  133. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +2 -0
  134. package/content/plugins/schema/resolvers/preview/resolveGet.js +38 -0
  135. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +2 -0
  136. package/content/plugins/schema/resolvers/preview/resolveList.js +23 -0
  137. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +2 -0
  138. package/content/plugins/schema/resolvers/read/resolveGet.js +38 -0
  139. package/content/plugins/schema/resolvers/read/resolveList.d.ts +2 -0
  140. package/content/plugins/schema/resolvers/read/resolveList.js +23 -0
  141. package/content/plugins/schema/schemaPlugins.d.ts +3 -0
  142. package/content/plugins/schema/schemaPlugins.js +92 -0
  143. package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
  144. package/content/plugins/storage/StorageTransformPlugin.js +36 -0
  145. package/content/plugins/storage/default.d.ts +3 -0
  146. package/content/plugins/storage/default.js +28 -0
  147. package/content/plugins/storage/object.d.ts +3 -0
  148. package/content/plugins/storage/object.js +119 -0
  149. package/content/plugins/utils/createTypeName.d.ts +3 -0
  150. package/content/plugins/utils/createTypeName.js +28 -0
  151. package/content/plugins/utils/entryStorage.d.ts +17 -0
  152. package/content/plugins/utils/entryStorage.js +125 -0
  153. package/content/plugins/utils/getEntryTitle.d.ts +2 -0
  154. package/content/plugins/utils/getEntryTitle.js +42 -0
  155. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +11 -0
  156. package/content/plugins/utils/getSchemaFromFieldPlugins.js +30 -0
  157. package/content/plugins/utils/pluralizedTypeName.d.ts +1 -0
  158. package/content/plugins/utils/pluralizedTypeName.js +26 -0
  159. package/content/plugins/utils/renderFields.d.ts +16 -0
  160. package/content/plugins/utils/renderFields.js +51 -0
  161. package/content/plugins/utils/renderGetFilterFields.d.ts +9 -0
  162. package/content/plugins/utils/renderGetFilterFields.js +41 -0
  163. package/content/plugins/utils/renderInputFields.d.ts +14 -0
  164. package/content/plugins/utils/renderInputFields.js +53 -0
  165. package/content/plugins/utils/renderListFilterFields.d.ts +10 -0
  166. package/content/plugins/utils/renderListFilterFields.js +39 -0
  167. package/content/plugins/utils/renderSortEnum.d.ts +9 -0
  168. package/content/plugins/utils/renderSortEnum.js +32 -0
  169. package/content/plugins/validators/dateGte.d.ts +3 -0
  170. package/content/plugins/validators/dateGte.js +37 -0
  171. package/content/plugins/validators/dateLte.d.ts +3 -0
  172. package/content/plugins/validators/dateLte.js +37 -0
  173. package/content/plugins/validators/gte.d.ts +3 -0
  174. package/content/plugins/validators/gte.js +32 -0
  175. package/content/plugins/validators/in.d.ts +3 -0
  176. package/content/plugins/validators/in.js +32 -0
  177. package/content/plugins/validators/index.d.ts +2 -0
  178. package/content/plugins/validators/index.js +36 -0
  179. package/content/plugins/validators/lte.d.ts +3 -0
  180. package/content/plugins/validators/lte.js +32 -0
  181. package/content/plugins/validators/maxLength.d.ts +3 -0
  182. package/content/plugins/validators/maxLength.js +32 -0
  183. package/content/plugins/validators/minLength.d.ts +3 -0
  184. package/content/plugins/validators/minLength.js +32 -0
  185. package/content/plugins/validators/pattern.d.ts +3 -0
  186. package/content/plugins/validators/pattern.js +47 -0
  187. package/content/plugins/validators/patternPlugins/email.d.ts +3 -0
  188. package/content/plugins/validators/patternPlugins/email.js +17 -0
  189. package/content/plugins/validators/patternPlugins/index.d.ts +2 -0
  190. package/content/plugins/validators/patternPlugins/index.js +19 -0
  191. package/content/plugins/validators/patternPlugins/lowerCase.d.ts +3 -0
  192. package/content/plugins/validators/patternPlugins/lowerCase.js +17 -0
  193. package/content/plugins/validators/patternPlugins/upperCase.d.ts +3 -0
  194. package/content/plugins/validators/patternPlugins/upperCase.js +17 -0
  195. package/content/plugins/validators/patternPlugins/url.d.ts +3 -0
  196. package/content/plugins/validators/patternPlugins/url.js +17 -0
  197. package/content/plugins/validators/required.d.ts +3 -0
  198. package/content/plugins/validators/required.js +25 -0
  199. package/content/plugins/validators/timeGte.d.ts +3 -0
  200. package/content/plugins/validators/timeGte.js +32 -0
  201. package/content/plugins/validators/timeLte.d.ts +3 -0
  202. package/content/plugins/validators/timeLte.js +32 -0
  203. package/index.d.ts +12 -0
  204. package/index.js +66 -0
  205. package/migrateCMSPermissions.d.ts +17 -0
  206. package/migrateCMSPermissions.js +193 -0
  207. package/package.json +80 -0
  208. package/plugins/context.d.ts +4 -0
  209. package/plugins/context.js +34 -0
  210. package/plugins/crud/index.d.ts +6 -0
  211. package/plugins/crud/index.js +100 -0
  212. package/plugins/crud/settings.crud.d.ts +10 -0
  213. package/plugins/crud/settings.crud.js +93 -0
  214. package/plugins/crud/system.crud.d.ts +10 -0
  215. package/plugins/crud/system.crud.js +182 -0
  216. package/plugins/graphql/system.d.ts +17 -0
  217. package/plugins/graphql/system.js +72 -0
  218. package/plugins/graphql.d.ts +2 -0
  219. package/plugins/graphql.js +79 -0
  220. package/plugins/upgrades/index.d.ts +2 -0
  221. package/plugins/upgrades/index.js +14 -0
  222. package/plugins/upgrades/v5.5.0/helpers.d.ts +6 -0
  223. package/plugins/upgrades/v5.5.0/helpers.js +10 -0
  224. package/plugins/upgrades/v5.5.0/index.d.ts +4 -0
  225. package/plugins/upgrades/v5.5.0/index.js +129 -0
  226. package/transformers.d.ts +2 -0
  227. package/transformers.js +25 -0
  228. package/types.d.ts +2149 -0
  229. package/types.js +366 -0
  230. package/utils.d.ts +25 -0
  231. package/utils.js +251 -0
package/types.d.ts ADDED
@@ -0,0 +1,2149 @@
1
+ import { Plugin } from "@webiny/plugins/types";
2
+ import { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
3
+ import { ContextInterface } from "@webiny/handler/types";
4
+ import { TenancyContext } from "@webiny/api-tenancy/types";
5
+ import { GraphQLFieldResolver, GraphQLSchemaDefinition, Resolvers } from "@webiny/handler-graphql/types";
6
+ import { BaseI18NContentContext } from "@webiny/api-i18n-content/types";
7
+ import { SecurityPermission } from "@webiny/api-security/types";
8
+ import { HttpContext } from "@webiny/handler-http/types";
9
+ import { DbContext } from "@webiny/handler-db/types";
10
+ import { FileManagerContext } from "@webiny/api-file-manager/types";
11
+ import { UpgradePlugin } from "@webiny/api-upgrade/types";
12
+ import { Topic } from "@webiny/pubsub/types";
13
+ export interface HeadlessCms extends CmsSettingsContext, CmsSystemContext, CmsGroupContext, CmsModelContext, CmsEntryContext {
14
+ /**
15
+ * API type
16
+ */
17
+ type: "manage" | "preview" | "read" | string;
18
+ /**
19
+ * Requested locale
20
+ */
21
+ locale: string;
22
+ /**
23
+ * returns an instance of current locale
24
+ */
25
+ getLocale: () => I18NLocale;
26
+ /**
27
+ * Means this request is a READ API
28
+ */
29
+ READ: boolean;
30
+ /**
31
+ * Means this request is a MANAGE API
32
+ */
33
+ MANAGE: boolean;
34
+ /**
35
+ * Means this request is a PREVIEW API
36
+ */
37
+ PREVIEW: boolean;
38
+ /**
39
+ * The storage operations loaded for current context.
40
+ */
41
+ storageOperations: HeadlessCmsStorageOperations;
42
+ }
43
+ /**
44
+ * @description This combines all contexts used in the CMS into a single one.
45
+ *
46
+ * @category Context
47
+ */
48
+ export interface CmsContext extends ContextInterface, DbContext, HttpContext, I18NContext, FileManagerContext, BaseI18NContentContext, TenancyContext {
49
+ cms: HeadlessCms;
50
+ }
51
+ interface CmsModelFieldPredefinedValuesValue {
52
+ value: string;
53
+ label: string;
54
+ }
55
+ /**
56
+ * Object containing content model field predefined options and values.
57
+ *
58
+ * @category CmsModelField
59
+ */
60
+ export interface CmsModelFieldPredefinedValues {
61
+ /**
62
+ * Are predefined field values enabled?
63
+ */
64
+ enabled: boolean;
65
+ /**
66
+ * Predefined values array.
67
+ */
68
+ values: CmsModelFieldPredefinedValuesValue[];
69
+ }
70
+ /**
71
+ * Object containing content model field renderer options.
72
+ *
73
+ * @category CmsModelField
74
+ */
75
+ interface CmsModelFieldRenderer {
76
+ /**
77
+ * Name of the field renderer. Must have one in field renderer plugins.
78
+ * Can be blank to let automatically determine the renderer.
79
+ */
80
+ name: string;
81
+ }
82
+ /**
83
+ * A definition for content model field. This type exists on the app side as well.
84
+ *
85
+ * @category ModelField
86
+ * @category Database model
87
+ */
88
+ export interface CmsModelField {
89
+ /**
90
+ * A generated ID for the model field
91
+ */
92
+ id: string;
93
+ /**
94
+ * A type of the field
95
+ */
96
+ type: string;
97
+ /**
98
+ * A unique field ID for mapping values
99
+ */
100
+ fieldId: string;
101
+ /**
102
+ * A label for the field
103
+ */
104
+ label: string;
105
+ /**
106
+ * Text below the field to clarify what is it meant to be in the field value
107
+ */
108
+ helpText?: string;
109
+ /**
110
+ * Text to be displayed in the field
111
+ */
112
+ placeholderText?: string;
113
+ /**
114
+ * Are predefined values enabled? And list of them
115
+ */
116
+ predefinedValues?: CmsModelFieldPredefinedValues;
117
+ /**
118
+ * Field renderer. Blank if determined automatically.
119
+ */
120
+ renderer?: CmsModelFieldRenderer;
121
+ /**
122
+ * List of validations for the field
123
+ *
124
+ * @default []
125
+ */
126
+ validation?: CmsModelFieldValidation[];
127
+ /**
128
+ * List of validations for the list of values, when a field is set to accept a list of values.
129
+ * These validations will be applied to the entire list, and `validation` (see above) will be applied
130
+ * to each individual value in the list.
131
+ *
132
+ * @default []
133
+ */
134
+ listValidation?: CmsModelFieldValidation[];
135
+ /**
136
+ * Is this a multiple values field?
137
+ *
138
+ */
139
+ multipleValues?: boolean;
140
+ /**
141
+ * Any user defined settings.
142
+ *
143
+ * @default {}
144
+ */
145
+ settings?: {
146
+ [key: string]: any;
147
+ };
148
+ }
149
+ /**
150
+ * A definition for dateTime field to show possible type of the field in settings.
151
+ */
152
+ export interface CmsModelDateTimeField extends CmsModelField {
153
+ /**
154
+ * Settings object for the field. Contains type property.
155
+ */
156
+ settings: {
157
+ type: "time" | "date" | "dateTimeWithoutTimezone" | "dateTimeWithTimezone";
158
+ };
159
+ }
160
+ /**
161
+ * Arguments for the field validator validate method.
162
+ *
163
+ * @category ModelField
164
+ * @category FieldValidation
165
+ */
166
+ export interface CmsModelFieldValidatorValidateParams {
167
+ /**
168
+ * A value to be validated.
169
+ */
170
+ value: any;
171
+ /**
172
+ * Options from the CmsModelField validations.
173
+ *
174
+ * @see CmsModelField.validation
175
+ * @see CmsModelField.listValidation
176
+ */
177
+ validator: CmsModelFieldValidation;
178
+ /**
179
+ * An instance of the current context.
180
+ */
181
+ context: CmsContext;
182
+ /**
183
+ * Field being validated.
184
+ */
185
+ field: CmsModelField;
186
+ /**
187
+ * An instance of the content model being validated.
188
+ */
189
+ contentModel: CmsModel;
190
+ }
191
+ /**
192
+ * Definition for the field validator.
193
+ *
194
+ * @category Plugin
195
+ * @category ModelField
196
+ * @category FieldValidation
197
+ */
198
+ export interface CmsModelFieldValidatorPlugin extends Plugin {
199
+ /**
200
+ * A plugin type.
201
+ */
202
+ type: "cms-model-field-validator";
203
+ /**
204
+ * Actual validator definition.
205
+ */
206
+ validator: {
207
+ /**
208
+ * Name of the validator.
209
+ */
210
+ name: string;
211
+ /**
212
+ * Validation method.
213
+ */
214
+ validate(params: CmsModelFieldValidatorValidateParams): Promise<boolean>;
215
+ };
216
+ }
217
+ /**
218
+ * A pattern validator for the content entry field value.
219
+ *
220
+ * @category Plugin
221
+ * @category ModelField
222
+ * @category FieldValidation
223
+ */
224
+ export interface CmsModelFieldPatternValidatorPlugin extends Plugin {
225
+ /**
226
+ * A plugin type
227
+ */
228
+ type: "cms-model-field-validator-pattern";
229
+ /**
230
+ * A pattern object for the validator.
231
+ */
232
+ pattern: {
233
+ /**
234
+ * name of the pattern.
235
+ */
236
+ name: string;
237
+ /**
238
+ * RegExp of the validator.
239
+ */
240
+ regex: string;
241
+ /**
242
+ * RegExp flags
243
+ */
244
+ flags: string;
245
+ };
246
+ }
247
+ /**
248
+ * Locked field in the content model
249
+ *
250
+ * @see CmsModel.lockedFields
251
+ *
252
+ * @category ModelField
253
+ */
254
+ export interface LockedField {
255
+ /**
256
+ * Locked field ID - one used for mapping values.
257
+ */
258
+ fieldId: string;
259
+ /**
260
+ * Is the field multiple values field?
261
+ */
262
+ multipleValues: boolean;
263
+ /**
264
+ * Field type.
265
+ */
266
+ type: string;
267
+ [key: string]: any;
268
+ }
269
+ /**
270
+ * Cms Model defining an entry.
271
+ *
272
+ * @category Database model
273
+ * @category CmsModel
274
+ */
275
+ export interface CmsModel {
276
+ /**
277
+ * Name of the content model.
278
+ */
279
+ name: string;
280
+ /**
281
+ * Unique ID for the content model. Created from name if not defined by user.
282
+ */
283
+ modelId: string;
284
+ /**
285
+ * Locale this model belongs to.
286
+ */
287
+ locale: string;
288
+ /**
289
+ * Cms Group reference object.
290
+ */
291
+ group: {
292
+ /**
293
+ * Generated ID of the group
294
+ */
295
+ id: string;
296
+ /**
297
+ * Name of the group
298
+ */
299
+ name: string;
300
+ };
301
+ /**
302
+ * Description for the content model.
303
+ */
304
+ description?: string;
305
+ /**
306
+ * Date created
307
+ */
308
+ createdOn?: Date;
309
+ /**
310
+ * Date saved. Changes on both save and create.
311
+ */
312
+ savedOn?: Date;
313
+ /**
314
+ * CreatedBy object wrapper. Contains id, name and type of the user.
315
+ */
316
+ createdBy?: CreatedBy;
317
+ /**
318
+ * List of fields defining entry values.
319
+ */
320
+ fields: CmsModelField[];
321
+ /**
322
+ * Admin UI field layout
323
+ *
324
+ * ```ts
325
+ * layout: [
326
+ * [field1id, field2id],
327
+ * [field3id]
328
+ * ]
329
+ * ```
330
+ */
331
+ layout: string[][];
332
+ /**
333
+ * List of locked fields. Updated when entry is saved and a field has been used.
334
+ */
335
+ lockedFields?: LockedField[];
336
+ /**
337
+ * The field that is being displayed as entry title.
338
+ * It is picked as first available text field. Or user can select own field.
339
+ */
340
+ titleFieldId: string;
341
+ /**
342
+ * The version of Webiny which this record was stored with.
343
+ */
344
+ webinyVersion: string;
345
+ /**
346
+ * Model tenant.
347
+ */
348
+ tenant: string;
349
+ }
350
+ /**
351
+ * @category ModelField
352
+ */
353
+ export interface CmsModelFieldDefinition {
354
+ fields: string;
355
+ typeDefs?: string;
356
+ }
357
+ export interface CmsModelFieldToGraphQLCreateResolver {
358
+ (params: {
359
+ models: CmsModel[];
360
+ model: CmsModel;
361
+ graphQLType: string;
362
+ field: CmsModelField;
363
+ createFieldResolvers: any;
364
+ }): GraphQLFieldResolver | {
365
+ resolver: GraphQLFieldResolver;
366
+ typeResolvers: Resolvers<CmsContext>;
367
+ };
368
+ }
369
+ /**
370
+ * @category Plugin
371
+ * @category ModelField
372
+ * @category GraphQL
373
+ */
374
+ export interface CmsModelFieldToGraphQLPlugin extends Plugin {
375
+ /**
376
+ * A plugin type
377
+ */
378
+ type: "cms-model-field-to-graphql";
379
+ /**
380
+ * Field type name which must be exact as the one in `CmsEditorFieldTypePlugin` plugin.
381
+ *
382
+ * ```ts
383
+ * fieldType: "myField"
384
+ * ```
385
+ */
386
+ fieldType: string;
387
+ /**
388
+ * Is the field searchable via the GraphQL?
389
+ *
390
+ * ```ts
391
+ * isSearchable: false
392
+ * ```
393
+ */
394
+ isSearchable: boolean;
395
+ /**
396
+ * Is the field sortable via the GraphQL?
397
+ *
398
+ * ```ts
399
+ * isSortable: true
400
+ * ```
401
+ */
402
+ isSortable: boolean;
403
+ read: {
404
+ /**
405
+ * Definition for get filtering for GraphQL.
406
+ *
407
+ * ```ts
408
+ * read: {
409
+ * createGetFilters({ field }) {
410
+ * return `${field.fieldId}: MyField`;
411
+ * }
412
+ * }
413
+ * ```
414
+ */
415
+ createGetFilters?(params: {
416
+ model: CmsModel;
417
+ field: CmsModelField;
418
+ }): string;
419
+ /**
420
+ * Definition for list filtering for GraphQL.
421
+ *
422
+ * ```ts
423
+ * read: {
424
+ * createListFilters({ field }) {
425
+ * return `
426
+ * ${field.fieldId}: MyType
427
+ * ${field.fieldId}_not: MyType
428
+ * ${field.fieldId}_in: [MyType]
429
+ * ${field.fieldId}_not_in: [MyType]
430
+ * `;
431
+ * }
432
+ * }
433
+ * ```
434
+ */
435
+ createListFilters?(params: {
436
+ model: CmsModel;
437
+ field: CmsModelField;
438
+ }): string;
439
+ /**
440
+ * Definition of the field type for GraphQL - be aware if multiple values is selected.
441
+ *
442
+ * ```ts
443
+ * read: {
444
+ * createTypeField({ field }) {
445
+ * if (field.multipleValues) {
446
+ * return `${field.fieldId}: [MyFieldType]`;
447
+ * }
448
+ *
449
+ * return `${field.fieldId}: MyField`;
450
+ * }
451
+ * }
452
+ * ```
453
+ */
454
+ createTypeField(params: {
455
+ model: CmsModel;
456
+ field: CmsModelField;
457
+ fieldTypePlugins: CmsFieldTypePlugins;
458
+ }): CmsModelFieldDefinition | string;
459
+ /**
460
+ * Definition for field resolver.
461
+ * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.
462
+ *
463
+ * ```ts
464
+ * read: {
465
+ * createResolver({ field }) {
466
+ * return instance => {
467
+ * return instance.values[field.fieldId];
468
+ * };
469
+ * }
470
+ * }
471
+ * ```
472
+ */
473
+ createResolver?: CmsModelFieldToGraphQLCreateResolver;
474
+ /**
475
+ * Read API schema definitions for the field and resolvers for them.
476
+ *
477
+ * ```ts
478
+ * read: {
479
+ * createSchema() {
480
+ * return {
481
+ * typeDefs: `
482
+ * myField {
483
+ * id
484
+ * date
485
+ * }
486
+ * `,
487
+ * resolvers: {}
488
+ * }
489
+ * }
490
+ * }
491
+ * ```
492
+ */
493
+ createSchema?: (params: {
494
+ models: CmsModel[];
495
+ model: CmsModel;
496
+ }) => GraphQLSchemaDefinition<CmsContext>;
497
+ };
498
+ manage: {
499
+ /**
500
+ * Definition for list filtering for GraphQL.
501
+ *
502
+ * ```ts
503
+ * manage: {
504
+ * createListFilters({ field }) {
505
+ * return `
506
+ * ${field.fieldId}: MyType
507
+ * ${field.fieldId}_not: MyType
508
+ * ${field.fieldId}_in: [MyType]
509
+ * ${field.fieldId}_not_in: [MyType]
510
+ * `;
511
+ * }
512
+ * }
513
+ * ```
514
+ */
515
+ createListFilters?: (params: {
516
+ model: CmsModel;
517
+ field: CmsModelField;
518
+ }) => string;
519
+ /**
520
+ * Manage API schema definitions for the field and resolvers for them. Probably similar to `read.createSchema`.
521
+ *
522
+ * ```ts
523
+ * createSchema() {
524
+ * return {
525
+ * typeDefs: `
526
+ * myField {
527
+ * id
528
+ * date
529
+ * }
530
+ * `,
531
+ * resolvers: {}
532
+ * }
533
+ * }
534
+ * ```
535
+ */
536
+ createSchema?: (params: {
537
+ models: CmsModel[];
538
+ model: CmsModel;
539
+ }) => GraphQLSchemaDefinition<CmsContext>;
540
+ /**
541
+ * Definition of the field type for GraphQL - be aware if multiple values is selected. Probably same as `read.createTypeField`.
542
+ *
543
+ * ```ts
544
+ * manage: {
545
+ * createTypeField({ field }) {
546
+ * if (field.multipleValues) {
547
+ * return field.fieldId + ": [MyType]";
548
+ * }
549
+ *
550
+ * return field.fieldId + ": MyType";
551
+ * }
552
+ * }
553
+ * ```
554
+ */
555
+ createTypeField: (params: {
556
+ model: CmsModel;
557
+ field: CmsModelField;
558
+ fieldTypePlugins: CmsFieldTypePlugins;
559
+ }) => CmsModelFieldDefinition | string;
560
+ /**
561
+ * Definition for input GraphQL field type.
562
+ *
563
+ * ```ts
564
+ * manage: {
565
+ * createInputField({ field }) {
566
+ * if (field.multipleValues) {
567
+ * return field.fieldId + ": [MyField]";
568
+ * }
569
+ *
570
+ * return field.fieldId + ": MyField";
571
+ * }
572
+ * }
573
+ * ```
574
+ */
575
+ createInputField: (params: {
576
+ model: CmsModel;
577
+ field: CmsModelField;
578
+ fieldTypePlugins: CmsFieldTypePlugins;
579
+ }) => CmsModelFieldDefinition | string;
580
+ /**
581
+ * Definition for field resolver.
582
+ * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.
583
+ *
584
+ * ```ts
585
+ * manage: {
586
+ * createResolver({ field }) {
587
+ * return instance => {
588
+ * return instance.values[field.fieldId];
589
+ * };
590
+ * }
591
+ * }
592
+ * ```
593
+ */
594
+ createResolver?: CmsModelFieldToGraphQLCreateResolver;
595
+ };
596
+ }
597
+ /**
598
+ * Check for content model locked field.
599
+ * A custom plugin definable by the user.
600
+ *
601
+ * @category CmsModel
602
+ * @category Plugin
603
+ */
604
+ export interface CmsModelLockedFieldPlugin extends Plugin {
605
+ /**
606
+ * A plugin type
607
+ */
608
+ type: "cms-model-locked-field";
609
+ /**
610
+ * A unique identifier of the field type (text, number, json, myField, ...).
611
+ */
612
+ fieldType: string;
613
+ /**
614
+ * A method to check if field really is locked.
615
+ */
616
+ checkLockedField?: (params: {
617
+ lockedField: LockedField;
618
+ field: CmsModelField;
619
+ }) => void;
620
+ /**
621
+ * A method to get the locked field data.
622
+ */
623
+ getLockedFieldData?: (params: {
624
+ field: CmsModelField;
625
+ }) => Record<string, any>;
626
+ }
627
+ /**
628
+ * @category ModelField
629
+ */
630
+ export interface CmsFieldTypePlugins {
631
+ [key: string]: CmsModelFieldToGraphQLPlugin;
632
+ }
633
+ /**
634
+ * A interface describing the reference to a user that created some data in the database.
635
+ *
636
+ * @category General
637
+ */
638
+ export interface CreatedBy {
639
+ /**
640
+ * ID if the user.
641
+ */
642
+ id: string;
643
+ /**
644
+ * Full name of the user.
645
+ */
646
+ displayName: string;
647
+ /**
648
+ * Type of the user (admin, user)
649
+ */
650
+ type: string;
651
+ }
652
+ /**
653
+ * Representation of settings database model.
654
+ *
655
+ * @category Database model
656
+ */
657
+ export interface CmsSettings {
658
+ /**
659
+ * Last content model change. Used to cache GraphQL schema.
660
+ */
661
+ contentModelLastChange: Date;
662
+ /**
663
+ * Settings tenant.
664
+ */
665
+ tenant: string;
666
+ /**
667
+ * Settings locale.
668
+ */
669
+ locale: string;
670
+ }
671
+ /**
672
+ * Settings CRUD in context.
673
+ *
674
+ * @category Context
675
+ */
676
+ export interface CmsSettingsContext {
677
+ /**
678
+ * Gets settings model from the database.
679
+ */
680
+ getSettings: () => Promise<CmsSettings | null>;
681
+ /**
682
+ * Updates settings model with a new date.
683
+ */
684
+ updateModelLastChange: () => Promise<void>;
685
+ /**
686
+ * Get the datetime when content model last changed.
687
+ */
688
+ getModelLastChange: () => Promise<Date>;
689
+ }
690
+ export interface BeforeInstallTopicParams {
691
+ tenant: string;
692
+ }
693
+ export interface AfterInstallTopicParams {
694
+ tenant: string;
695
+ }
696
+ export declare type CmsSystemContext = {
697
+ getSystemVersion: () => Promise<string>;
698
+ setSystemVersion: (version: string) => Promise<void>;
699
+ getReadAPIKey(): Promise<string>;
700
+ installSystem: () => Promise<void>;
701
+ upgradeSystem: (version: string) => Promise<boolean>;
702
+ /**
703
+ * Events
704
+ */
705
+ onBeforeSystemInstall: Topic<BeforeInstallTopicParams>;
706
+ onAfterSystemInstall: Topic<AfterInstallTopicParams>;
707
+ };
708
+ /**
709
+ * A GraphQL params.data parameter received when creating content model group.
710
+ *
711
+ * @category CmsGroup
712
+ * @category GraphQL params
713
+ */
714
+ export interface CmsGroupCreateInput {
715
+ name: string;
716
+ slug?: string;
717
+ description?: string;
718
+ icon: string;
719
+ }
720
+ /**
721
+ * A GraphQL params.data parameter received when updating content model group.
722
+ *
723
+ * @category CmsGroup
724
+ * @category GraphQL params
725
+ */
726
+ export interface CmsGroupUpdateInput {
727
+ name?: string;
728
+ slug?: string;
729
+ description?: string;
730
+ icon?: string;
731
+ }
732
+ /**
733
+ * A representation of content model group in the database.
734
+ *
735
+ * @category CmsGroup
736
+ * @category Database model
737
+ */
738
+ export interface CmsGroup {
739
+ /**
740
+ * Generated ID.
741
+ */
742
+ id: string;
743
+ /**
744
+ * Name of the group.
745
+ */
746
+ name: string;
747
+ /**
748
+ * Slug for the group. Must be unique.
749
+ */
750
+ slug: string;
751
+ /**
752
+ * Locale this group belongs to.
753
+ */
754
+ locale: string;
755
+ /**
756
+ * Description for the group.
757
+ */
758
+ description?: string;
759
+ /**
760
+ * Icon for the group. In a form of "ico/ico".
761
+ */
762
+ icon?: string;
763
+ /**
764
+ * CreatedBy reference object.
765
+ */
766
+ createdBy?: CreatedBy;
767
+ /**
768
+ * Date group was created on.
769
+ */
770
+ createdOn?: string;
771
+ /**
772
+ * Date group was created or changed on.
773
+ */
774
+ savedOn?: string;
775
+ /**
776
+ * Which Webiny version was this record stored with.
777
+ */
778
+ webinyVersion: string;
779
+ /**
780
+ * Group tenant.
781
+ */
782
+ tenant: string;
783
+ }
784
+ /**
785
+ * A data.where parameter received when listing content model groups.
786
+ *
787
+ * @category CmsGroup
788
+ * @category GraphQL params
789
+ */
790
+ export interface CmsGroupListParams {
791
+ where: {
792
+ tenant: string;
793
+ locale: string;
794
+ [key: string]: any;
795
+ };
796
+ }
797
+ /**
798
+ * @category CmsGroup
799
+ * @category Topic
800
+ */
801
+ export interface BeforeGroupCreateTopicParams {
802
+ group: CmsGroup;
803
+ }
804
+ /**
805
+ * @category CmsGroup
806
+ * @category Topic
807
+ */
808
+ export interface AfterGroupCreateTopicParams {
809
+ group: CmsGroup;
810
+ }
811
+ /**
812
+ * @category CmsGroup
813
+ * @category Topic
814
+ */
815
+ export interface BeforeGroupUpdateTopicParams {
816
+ original: CmsGroup;
817
+ group: CmsGroup;
818
+ }
819
+ /**
820
+ * @category CmsGroup
821
+ * @category Topic
822
+ */
823
+ export interface AfterGroupUpdateTopicParams {
824
+ original: CmsGroup;
825
+ group: CmsGroup;
826
+ }
827
+ /**
828
+ * @category CmsGroup
829
+ * @category Topic
830
+ */
831
+ export interface BeforeGroupDeleteTopicParams {
832
+ group: CmsGroup;
833
+ }
834
+ /**
835
+ * @category CmsGroup
836
+ * @category Topic
837
+ */
838
+ export interface AfterGroupDeleteTopicParams {
839
+ group: CmsGroup;
840
+ }
841
+ /**
842
+ * Cms Group in context.
843
+ *
844
+ * @category Context
845
+ * @category CmsGroup
846
+ */
847
+ export interface CmsGroupContext {
848
+ /**
849
+ * Gets content model group by given id.
850
+ */
851
+ getGroup: (id: string) => Promise<CmsGroup | null>;
852
+ /**
853
+ * List all content model groups. Filterable via params.
854
+ */
855
+ listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;
856
+ /**
857
+ * Create a new content model group.
858
+ */
859
+ createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;
860
+ /**
861
+ * Update existing content model group.
862
+ */
863
+ updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;
864
+ /**
865
+ * Delete content model group by given id.
866
+ */
867
+ deleteGroup: (id: string) => Promise<boolean>;
868
+ /**
869
+ * Events.
870
+ */
871
+ onBeforeGroupCreate: Topic<BeforeGroupCreateTopicParams>;
872
+ onAfterGroupCreate: Topic<AfterGroupCreateTopicParams>;
873
+ onBeforeGroupUpdate: Topic<BeforeGroupUpdateTopicParams>;
874
+ onAfterGroupUpdate: Topic<AfterGroupUpdateTopicParams>;
875
+ onBeforeGroupDelete: Topic<BeforeGroupDeleteTopicParams>;
876
+ onAfterGroupDelete: Topic<AfterGroupDeleteTopicParams>;
877
+ }
878
+ /**
879
+ * Definition for content model field validator.
880
+ *
881
+ * @category ModelField
882
+ * @category FieldValidation
883
+ */
884
+ export interface CmsModelFieldValidation {
885
+ name: string;
886
+ message: string;
887
+ settings?: Record<string, any>;
888
+ }
889
+ /**
890
+ * A GraphQL params.data parameter received when creating content model.
891
+ *
892
+ * @category GraphQL params
893
+ * @category CmsModel
894
+ */
895
+ export interface CmsModelCreateInput {
896
+ /**
897
+ * Name of the content model.
898
+ */
899
+ name: string;
900
+ /**
901
+ * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.
902
+ */
903
+ modelId?: string;
904
+ /**
905
+ * Description of the content model.
906
+ */
907
+ description?: string;
908
+ }
909
+ /**
910
+ * A definition for content model field received from the user.
911
+ *
912
+ * Input type for `CmsModelField`.
913
+ * @see CmsModelField
914
+ *
915
+ * @category GraphQL params
916
+ * @category ModelField
917
+ */
918
+ export interface CmsModelFieldInput {
919
+ /**
920
+ * Generated ID.
921
+ */
922
+ id: string;
923
+ /**
924
+ * Type of the field. A plugin for the field must be defined.
925
+ * @see CmsModelFieldToGraphQLPlugin
926
+ */
927
+ type: string;
928
+ /**
929
+ * A unique ID for the field. Values will be mapped via this value.
930
+ */
931
+ fieldId: string;
932
+ /**
933
+ * Label for the field.
934
+ */
935
+ label: string;
936
+ /**
937
+ * Text to display below the field to help user what to write in the field.
938
+ */
939
+ helpText?: string;
940
+ /**
941
+ * Text to display in the field.
942
+ */
943
+ placeholderText?: string;
944
+ /**
945
+ * Are multiple values allowed?
946
+ */
947
+ multipleValues?: boolean;
948
+ /**
949
+ * Predefined values options for the field. Check the reference for more information.
950
+ */
951
+ predefinedValues?: CmsModelFieldPredefinedValues;
952
+ /**
953
+ * Renderer options for the field. Check the reference for more information.
954
+ */
955
+ renderer?: CmsModelFieldRenderer;
956
+ /**
957
+ * List of validations for the field.
958
+ */
959
+ validation?: CmsModelFieldValidation[];
960
+ /**
961
+ * @see CmsModelField.listValidation
962
+ */
963
+ listValidation: CmsModelFieldValidation[];
964
+ /**
965
+ * User defined settings.
966
+ */
967
+ settings?: Record<string, any>;
968
+ }
969
+ /**
970
+ * A GraphQL params.data parameter received when updating content model.
971
+ *
972
+ * @category GraphQL params
973
+ * @category CmsModel
974
+ */
975
+ export interface CmsModelUpdateInput {
976
+ /**
977
+ * A new content model name.
978
+ */
979
+ name?: string;
980
+ /**
981
+ * A new description of the content model.
982
+ */
983
+ description?: string;
984
+ /**
985
+ * A list of content model fields to define the entry values.
986
+ */
987
+ fields: CmsModelFieldInput[];
988
+ /**
989
+ * Admin UI field layout
990
+ *
991
+ * ```ts
992
+ * layout: [
993
+ * [field1id, field2id],
994
+ * [field3id]
995
+ * ]
996
+ * ```
997
+ */
998
+ layout: string[][];
999
+ /**
1000
+ * The field that is being displayed as entry title.
1001
+ * It is picked as first available text field. Or user can select own field.
1002
+ */
1003
+ titleFieldId?: string;
1004
+ }
1005
+ /**
1006
+ * A plugin to load a CmsModelManager.
1007
+ *
1008
+ * @see CmsModelManager
1009
+ *
1010
+ * @category Plugin
1011
+ * @category CmsModel
1012
+ * @category CmsEntry
1013
+ */
1014
+ export interface ModelManagerPlugin extends Plugin {
1015
+ /**
1016
+ * A plugin type.
1017
+ */
1018
+ type: "cms-content-model-manager";
1019
+ /**
1020
+ * Specific model CmsModelManager loader. Can target exact modelId(s).
1021
+ * Be aware that if you define multiple plugins without `modelId`, last one will run.
1022
+ */
1023
+ modelId?: string[] | string;
1024
+ /**
1025
+ * Create a CmsModelManager for specific type - or new default one.
1026
+ * For reference in how is this plugin run check [contentModelManagerFactory](https://github.com/webiny/webiny-js/blob/f15676/packages/api-headless-cms/src/content/plugins/CRUD/contentModel/contentModelManagerFactory.ts)
1027
+ */
1028
+ create: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;
1029
+ }
1030
+ /**
1031
+ * A content entry definition for and from the database.
1032
+ *
1033
+ * @category Database model
1034
+ * @category CmsEntry
1035
+ */
1036
+ export interface CmsEntry {
1037
+ /**
1038
+ * A version of the webiny this entry was created with.
1039
+ * This can be used when upgrading the system so we know which entries to update.
1040
+ */
1041
+ webinyVersion: string;
1042
+ /**
1043
+ * Tenant id which is this entry for. Can be used in case of shared storage.
1044
+ */
1045
+ tenant: string;
1046
+ /**
1047
+ * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.
1048
+ * So version 1, 2, ..., 2371 will have the same value in this field to link them together.
1049
+ */
1050
+ entryId: string;
1051
+ /**
1052
+ * Generated ID + version of the entry.
1053
+ */
1054
+ id: string;
1055
+ /**
1056
+ * CreatedBy object reference.
1057
+ */
1058
+ createdBy: CreatedBy;
1059
+ /**
1060
+ * OwnedBy object reference. Can be different from CreatedBy.
1061
+ */
1062
+ ownedBy: CreatedBy;
1063
+ /**
1064
+ * A string of Date.toISOString() type.
1065
+ * Populated on creation.
1066
+ */
1067
+ createdOn: string;
1068
+ /**
1069
+ * A string of Date.toISOString() type.
1070
+ * Populated every time entry is saved.
1071
+ */
1072
+ savedOn: string;
1073
+ /**
1074
+ * Model ID of the definition for the entry.
1075
+ * @see CmsModel
1076
+ */
1077
+ modelId: string;
1078
+ /**
1079
+ * A locale of the entry.
1080
+ * @see I18NLocale.code
1081
+ */
1082
+ locale: string;
1083
+ /**
1084
+ * A string of Date.toISOString() type - if published.
1085
+ * Populated when entry is published.
1086
+ */
1087
+ publishedOn?: string;
1088
+ /**
1089
+ * A revision version of the entry.
1090
+ */
1091
+ version: number;
1092
+ /**
1093
+ * Is the entry locked?
1094
+ */
1095
+ locked: boolean;
1096
+ /**
1097
+ * Status type of the entry.
1098
+ */
1099
+ status: CmsEntryStatus;
1100
+ /**
1101
+ * A mapped fieldId -> value object.
1102
+ *
1103
+ * @see CmsModelField
1104
+ */
1105
+ values: Record<string, any>;
1106
+ }
1107
+ export interface CmsStorageEntry extends CmsEntry {
1108
+ [key: string]: any;
1109
+ }
1110
+ /**
1111
+ * A definition for content model manager to be used in the code.
1112
+ * The default one uses `CmsEntryContext` methods internally, but devs can change to what every they want.
1113
+ *
1114
+ * @see CmsEntryContext
1115
+ *
1116
+ * @category Context
1117
+ * @category CmsEntry
1118
+ * @category CmsModel
1119
+ */
1120
+ export interface CmsModelManager {
1121
+ /**
1122
+ * List entries in this content model.
1123
+ */
1124
+ list: (params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1125
+ /**
1126
+ * List only published entries in the content model.
1127
+ */
1128
+ listPublished: (params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1129
+ /**
1130
+ * List latest entries in the content model. Used for administration.
1131
+ */
1132
+ listLatest: (params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1133
+ /**
1134
+ * Get a list of published entries by the ID list.
1135
+ */
1136
+ getPublishedByIds: (ids: string[]) => Promise<CmsEntry[]>;
1137
+ /**
1138
+ * Get a list of latest entries by the ID list.
1139
+ */
1140
+ getLatestByIds: (ids: string[]) => Promise<CmsEntry[]>;
1141
+ /**
1142
+ * Get an entry filtered by given params. Will always get one.
1143
+ */
1144
+ get: (id: string) => Promise<CmsEntry>;
1145
+ /**
1146
+ * Create a entry.
1147
+ */
1148
+ create: (data: Record<string, any>) => Promise<CmsEntry>;
1149
+ /**
1150
+ * Update a entry.
1151
+ */
1152
+ update: (id: string, data: Record<string, any>) => Promise<CmsEntry>;
1153
+ /**
1154
+ * Delete a entry.
1155
+ */
1156
+ delete: (id: string) => Promise<void>;
1157
+ }
1158
+ export interface BeforeModelCreateTopicParams {
1159
+ input: Partial<CmsModel>;
1160
+ model: CmsModel;
1161
+ }
1162
+ export interface AfterModelCreateTopicParams {
1163
+ input: Partial<CmsModel>;
1164
+ model: CmsModel;
1165
+ }
1166
+ export interface BeforeModelUpdateTopicParams {
1167
+ input: Partial<CmsModel>;
1168
+ original: CmsModel;
1169
+ model: CmsModel;
1170
+ }
1171
+ export interface AfterModelUpdateTopicParams {
1172
+ input: Partial<CmsModel>;
1173
+ original: CmsModel;
1174
+ model: CmsModel;
1175
+ }
1176
+ export interface BeforeModelDeleteTopicParams {
1177
+ model: CmsModel;
1178
+ }
1179
+ export interface AfterModelDeleteTopicParams {
1180
+ model: CmsModel;
1181
+ }
1182
+ export interface CmsModelUpdateDirectParams {
1183
+ model: CmsModel;
1184
+ original: CmsModel;
1185
+ }
1186
+ /**
1187
+ * Cms Model in the context.
1188
+ *
1189
+ * @category Context
1190
+ * @category CmsModel
1191
+ */
1192
+ export interface CmsModelContext {
1193
+ /**
1194
+ * A function defining usage of a method with authenticating the user but not throwing an error.
1195
+ */
1196
+ silentAuthModel: () => {
1197
+ /**
1198
+ * Get all content models.
1199
+ */
1200
+ list: () => Promise<CmsModel[]>;
1201
+ };
1202
+ /**
1203
+ * Get a single content model.
1204
+ */
1205
+ getModel: (modelId: string) => Promise<CmsModel | null>;
1206
+ /**
1207
+ * Get all content models.
1208
+ */
1209
+ listModels: () => Promise<CmsModel[]>;
1210
+ /**
1211
+ * Create a content model.
1212
+ */
1213
+ createModel: (data: CmsModelCreateInput) => Promise<CmsModel>;
1214
+ /**
1215
+ * Update content model without data validation. Used internally.
1216
+ *
1217
+ * @param model - existing content model
1218
+ * @param data - data to be updated
1219
+ *
1220
+ * @hidden
1221
+ */
1222
+ updateModelDirect: (params: CmsModelUpdateDirectParams) => Promise<CmsModel>;
1223
+ /**
1224
+ * Update content model.
1225
+ */
1226
+ updateModel: (modelId: string, data: CmsModelUpdateInput) => Promise<CmsModel>;
1227
+ /**
1228
+ * Delete content model. Should not allow deletion if there are entries connected to it.
1229
+ */
1230
+ deleteModel: (modelId: string) => Promise<void>;
1231
+ /**
1232
+ * Get a instance of CmsModelManager for given content modelId.
1233
+ *
1234
+ * @see CmsModelManager
1235
+ */
1236
+ getModelManager: (modelId: string) => Promise<CmsModelManager>;
1237
+ /**
1238
+ * Get all content model managers mapped by modelId.
1239
+ * @see CmsModelManager
1240
+ */
1241
+ getManagers: () => Map<string, CmsModelManager>;
1242
+ /**
1243
+ * Events.
1244
+ */
1245
+ onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;
1246
+ onAfterModelCreate: Topic<AfterModelCreateTopicParams>;
1247
+ onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;
1248
+ onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;
1249
+ onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;
1250
+ onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;
1251
+ }
1252
+ /**
1253
+ * Available statuses for content entry.
1254
+ *
1255
+ * @category CmsEntry
1256
+ */
1257
+ declare type CmsEntryStatus = "published" | "unpublished" | "reviewRequested" | "changesRequested" | "draft";
1258
+ /**
1259
+ * Entry listing where params.
1260
+ *
1261
+ * @category CmsEntry
1262
+ * @category GraphQL params
1263
+ */
1264
+ export interface CmsEntryListWhere {
1265
+ /**
1266
+ * Fields.
1267
+ */
1268
+ id?: string;
1269
+ id_in?: string[];
1270
+ id_not?: string;
1271
+ id_not_in?: string[];
1272
+ /**
1273
+ * Generated ID without the version.
1274
+ */
1275
+ entryId?: string;
1276
+ entryId_not?: string;
1277
+ entryId_in?: string[];
1278
+ entryId_not_in?: string[];
1279
+ /**
1280
+ * Entry is owned by whom?
1281
+ *
1282
+ * Can be sent via the API or set internal if user can see only their own entries.
1283
+ */
1284
+ ownedBy?: string;
1285
+ ownedBy_not?: string;
1286
+ ownedBy_in?: string[];
1287
+ ownedBy_not_in?: string[];
1288
+ /**
1289
+ * Who created the entry?
1290
+ */
1291
+ createdBy?: string;
1292
+ createdBy_not?: string;
1293
+ createdBy_in?: string[];
1294
+ createdBy_not_in?: string[];
1295
+ /**
1296
+ * Version of the entry.
1297
+ *
1298
+ * It is not meant to be used via the API.
1299
+ * @internal
1300
+ */
1301
+ version?: number;
1302
+ version_lt?: number;
1303
+ version_gt?: number;
1304
+ /**
1305
+ * Each operations implementation MUST determine how to use this field.
1306
+ * In SQL it can be published field and in DynamoDB can be a secondary key.
1307
+ *
1308
+ * It is not meant to be used via the API.
1309
+ * @internal
1310
+ */
1311
+ published?: boolean;
1312
+ /**
1313
+ * Each operations implementation MUST determine how to use this field.
1314
+ * In SQL it can be published field and in DynamoDB can be a secondary key.
1315
+ *
1316
+ * It is not meant to be used via the API.
1317
+ * @internal
1318
+ */
1319
+ latest?: boolean;
1320
+ [key: string]: any;
1321
+ }
1322
+ /**
1323
+ * Entry listing sort.
1324
+ *
1325
+ * @category CmsEntry
1326
+ * @category GraphQL params
1327
+ */
1328
+ export declare type CmsEntryListSort = string[];
1329
+ /**
1330
+ * Get entry GraphQL resolver params.
1331
+ *
1332
+ * @category CmsEntry
1333
+ * @category GraphQL params
1334
+ */
1335
+ export interface CmsEntryGetParams {
1336
+ where: CmsEntryListWhere;
1337
+ sort?: CmsEntryListSort;
1338
+ }
1339
+ /**
1340
+ * List entries GraphQL resolver params.
1341
+ *
1342
+ * @category CmsEntry
1343
+ * @category GraphQL params
1344
+ */
1345
+ export interface CmsEntryListParams {
1346
+ where: CmsEntryListWhere;
1347
+ sort?: CmsEntryListSort;
1348
+ limit?: number;
1349
+ after?: string;
1350
+ }
1351
+ /**
1352
+ * Meta information for GraphQL output.
1353
+ *
1354
+ * @category CmsEntry
1355
+ * @category GraphQL output
1356
+ */
1357
+ export interface CmsEntryMeta {
1358
+ /**
1359
+ * A cursor for pagination.
1360
+ */
1361
+ cursor: string;
1362
+ /**
1363
+ * Is there more items to load?
1364
+ */
1365
+ hasMoreItems: boolean;
1366
+ /**
1367
+ * Total count of the items in the storage.
1368
+ */
1369
+ totalCount: number;
1370
+ }
1371
+ export interface BeforeEntryCreateTopicParams {
1372
+ input: Partial<CmsEntry>;
1373
+ entry: CmsEntry;
1374
+ model: CmsModel;
1375
+ }
1376
+ export interface AfterEntryCreateTopicParams {
1377
+ input: Partial<CmsEntry>;
1378
+ entry: CmsEntry;
1379
+ model: CmsModel;
1380
+ storageEntry: CmsEntry;
1381
+ }
1382
+ export interface BeforeEntryRevisionCreateTopicParams {
1383
+ entry: CmsEntry;
1384
+ model: CmsModel;
1385
+ }
1386
+ export interface AfterEntryRevisionCreateTopicParams {
1387
+ entry: CmsEntry;
1388
+ model: CmsModel;
1389
+ storageEntry: CmsEntry;
1390
+ }
1391
+ export interface BeforeEntryUpdateTopicParams {
1392
+ input: Partial<CmsEntry>;
1393
+ original: CmsEntry;
1394
+ entry: CmsEntry;
1395
+ model: CmsModel;
1396
+ }
1397
+ export interface AfterEntryUpdateTopicParams {
1398
+ input: Partial<CmsEntry>;
1399
+ original: CmsEntry;
1400
+ entry: CmsEntry;
1401
+ model: CmsModel;
1402
+ storageEntry: CmsEntry;
1403
+ }
1404
+ export interface BeforeEntryPublishTopicParams {
1405
+ entry: CmsEntry;
1406
+ model: CmsModel;
1407
+ }
1408
+ export interface AfterEntryPublishTopicParams {
1409
+ entry: CmsEntry;
1410
+ model: CmsModel;
1411
+ storageEntry: CmsEntry;
1412
+ }
1413
+ export interface BeforeEntryUnpublishTopicParams {
1414
+ entry: CmsEntry;
1415
+ model: CmsModel;
1416
+ }
1417
+ export interface AfterEntryUnpublishTopicParams {
1418
+ entry: CmsEntry;
1419
+ model: CmsModel;
1420
+ storageEntry: CmsEntry;
1421
+ }
1422
+ export interface BeforeEntryRequestChangesTopicParams {
1423
+ entry: CmsEntry;
1424
+ model: CmsModel;
1425
+ }
1426
+ export interface AfterEntryRequestChangesTopicParams {
1427
+ entry: CmsEntry;
1428
+ model: CmsModel;
1429
+ storageEntry: CmsEntry;
1430
+ }
1431
+ export interface BeforeEntryRequestReviewTopicParams {
1432
+ entry: CmsEntry;
1433
+ model: CmsModel;
1434
+ }
1435
+ export interface AfterEntryRequestReviewTopicParams {
1436
+ entry: CmsEntry;
1437
+ model: CmsModel;
1438
+ storageEntry: CmsEntry;
1439
+ }
1440
+ export interface BeforeEntryDeleteTopicParams {
1441
+ entry: CmsEntry;
1442
+ model: CmsModel;
1443
+ }
1444
+ export interface AfterEntryDeleteTopicParams {
1445
+ entry: CmsEntry;
1446
+ model: CmsModel;
1447
+ }
1448
+ export interface BeforeEntryRevisionDeleteTopicParams {
1449
+ entry: CmsEntry;
1450
+ model: CmsModel;
1451
+ }
1452
+ export interface AfterEntryRevisionDeleteTopicParams {
1453
+ entry: CmsEntry;
1454
+ model: CmsModel;
1455
+ }
1456
+ export interface BeforeEntryGetTopicParams {
1457
+ model: CmsModel;
1458
+ where: CmsEntryListWhere;
1459
+ }
1460
+ export interface BeforeEntryListTopicParams {
1461
+ where: CmsEntryListWhere;
1462
+ model: CmsModel;
1463
+ }
1464
+ /**
1465
+ * Cms Entry CRUD methods in the context.
1466
+ *
1467
+ * @category Context
1468
+ * @category CmsEntry
1469
+ */
1470
+ export interface CmsEntryContext {
1471
+ /**
1472
+ * Get a single content entry for a model.
1473
+ */
1474
+ getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry | null>;
1475
+ /**
1476
+ * Get a list of entries for a model by a given ID (revision).
1477
+ */
1478
+ getEntriesByIds: (model: CmsModel, revisions: string[]) => Promise<CmsEntry[] | null>;
1479
+ /**
1480
+ * Get the entry for a model by a given ID.
1481
+ */
1482
+ getEntryById: (model: CmsModel, revision: string) => Promise<CmsEntry>;
1483
+ /**
1484
+ * List entries for a model. Internal method used by get, listLatest and listPublished.
1485
+ */
1486
+ listEntries: (model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1487
+ /**
1488
+ * Lists latest entries. Used for manage API.
1489
+ */
1490
+ listLatestEntries: (model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1491
+ /**
1492
+ * List published entries. Used for read API.
1493
+ */
1494
+ listPublishedEntries: (model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
1495
+ /**
1496
+ * List published entries by IDs.
1497
+ */
1498
+ getPublishedEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;
1499
+ /**
1500
+ * List latest entries by IDs.
1501
+ */
1502
+ getLatestEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;
1503
+ /**
1504
+ * Create a new content entry.
1505
+ */
1506
+ createEntry: (model: CmsModel, data: Record<string, any>) => Promise<CmsEntry>;
1507
+ /**
1508
+ * Create a new entry from already existing entry.
1509
+ */
1510
+ createEntryRevisionFrom: (model: CmsModel, id: string, data: Record<string, any>) => Promise<CmsEntry>;
1511
+ /**
1512
+ * Update existing entry.
1513
+ */
1514
+ updateEntry: (model: CmsModel, id: string, data?: Record<string, any>) => Promise<CmsEntry>;
1515
+ /**
1516
+ * Delete only a certain revision of the entry.
1517
+ */
1518
+ deleteEntryRevision: (model: CmsModel, id: string) => Promise<void>;
1519
+ /**
1520
+ * Delete entry with all its revisions.
1521
+ */
1522
+ deleteEntry: (model: CmsModel, id: string) => Promise<void>;
1523
+ /**
1524
+ * Publish entry.
1525
+ */
1526
+ publishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;
1527
+ /**
1528
+ * Unpublish entry.
1529
+ */
1530
+ unpublishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;
1531
+ /**
1532
+ * Request a review for the entry.
1533
+ */
1534
+ requestEntryReview: (model: CmsModel, id: string) => Promise<CmsEntry>;
1535
+ /**
1536
+ * Request changes for the entry.
1537
+ */
1538
+ requestEntryChanges: (model: CmsModel, id: string) => Promise<CmsEntry>;
1539
+ /**
1540
+ * Get all entry revisions.
1541
+ */
1542
+ getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;
1543
+ /**
1544
+ * Events.
1545
+ */
1546
+ onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;
1547
+ onAfterEntryCreate: Topic<AfterEntryCreateTopicParams>;
1548
+ onBeforeEntryRevisionCreate: Topic<BeforeEntryRevisionCreateTopicParams>;
1549
+ onAfterEntryRevisionCreate: Topic<AfterEntryRevisionCreateTopicParams>;
1550
+ onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;
1551
+ onAfterEntryUpdate: Topic<AfterEntryUpdateTopicParams>;
1552
+ onBeforeEntryDelete: Topic<BeforeEntryDeleteTopicParams>;
1553
+ onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;
1554
+ onBeforeEntryRevisionDelete: Topic<BeforeEntryRevisionDeleteTopicParams>;
1555
+ onAfterEntryRevisionDelete: Topic<AfterEntryRevisionDeleteTopicParams>;
1556
+ onBeforeEntryPublish: Topic<BeforeEntryPublishTopicParams>;
1557
+ onAfterEntryPublish: Topic<AfterEntryPublishTopicParams>;
1558
+ onBeforeEntryUnpublish: Topic<BeforeEntryUnpublishTopicParams>;
1559
+ onAfterEntryUnpublish: Topic<AfterEntryUnpublishTopicParams>;
1560
+ onBeforeEntryRequestChanges: Topic<BeforeEntryRequestChangesTopicParams>;
1561
+ onAfterEntryRequestChanges: Topic<AfterEntryRequestChangesTopicParams>;
1562
+ onBeforeEntryRequestReview: Topic<BeforeEntryRequestReviewTopicParams>;
1563
+ onAfterEntryRequestReview: Topic<AfterEntryRequestReviewTopicParams>;
1564
+ onBeforeEntryGet: Topic<BeforeEntryGetTopicParams>;
1565
+ onBeforeEntryList: Topic<BeforeEntryListTopicParams>;
1566
+ }
1567
+ /**
1568
+ * Parameters for CmsEntryResolverFactory.
1569
+ *
1570
+ * @category GraphQL resolver
1571
+ * @category CmsEntry
1572
+ */
1573
+ interface CmsEntryResolverFactoryParams {
1574
+ model: CmsModel;
1575
+ }
1576
+ /**
1577
+ * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.
1578
+ *
1579
+ * @category GraphQL resolver
1580
+ * @category CmsEntry
1581
+ */
1582
+ export declare type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {
1583
+ (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;
1584
+ };
1585
+ /**
1586
+ * Settings security permission.
1587
+ *
1588
+ * @category SecurityPermission
1589
+ */
1590
+ export interface CmsSettingsPermission extends SecurityPermission {
1591
+ }
1592
+ /**
1593
+ * A security permission for content model.
1594
+ *
1595
+ * @category SecurityPermission
1596
+ * @category CmsModel
1597
+ */
1598
+ export interface CmsModelPermission extends SecurityPermission {
1599
+ own: boolean;
1600
+ rwd: string;
1601
+ /**
1602
+ * A object representing `key: model.modelId` values where key is locale code.
1603
+ */
1604
+ models?: {
1605
+ [key: string]: string[];
1606
+ };
1607
+ /**
1608
+ * A object representing `key: group.id` values where key is locale code.
1609
+ */
1610
+ groups?: {
1611
+ [key: string]: string[];
1612
+ };
1613
+ }
1614
+ /**
1615
+ * The security permission for content model groups.
1616
+ *
1617
+ * @category SecurityPermission
1618
+ * @category CmsGroup
1619
+ */
1620
+ export interface CmsGroupPermission extends SecurityPermission {
1621
+ own: boolean;
1622
+ rwd: string;
1623
+ /**
1624
+ * A object representing `key: group.id` values where key is locale code.
1625
+ */
1626
+ groups?: {
1627
+ [key: string]: string[];
1628
+ };
1629
+ }
1630
+ /**
1631
+ * The security permission for content entry.
1632
+ *
1633
+ * @category SecurityPermission
1634
+ * @category CmsEntry
1635
+ */
1636
+ export interface CmsEntryPermission extends SecurityPermission {
1637
+ own: boolean;
1638
+ rwd: string;
1639
+ pw: string;
1640
+ /**
1641
+ * A object representing `key: model.modelId` values where key is locale code.
1642
+ */
1643
+ models?: {
1644
+ [key: string]: string[];
1645
+ };
1646
+ /**
1647
+ * A object representing `key: group.id` values where key is locale code.
1648
+ */
1649
+ groups?: {
1650
+ [key: string]: string[];
1651
+ };
1652
+ }
1653
+ export interface CmsGroupStorageOperationsGetParams {
1654
+ id: string;
1655
+ tenant: string;
1656
+ locale: string;
1657
+ }
1658
+ export interface CmsGroupStorageOperationsListWhereParams {
1659
+ tenant: string;
1660
+ locale: string;
1661
+ [key: string]: any;
1662
+ }
1663
+ export interface CmsGroupStorageOperationsListParams {
1664
+ where: CmsGroupStorageOperationsListWhereParams;
1665
+ sort?: string[];
1666
+ }
1667
+ export interface CmsGroupStorageOperationsCreateParams {
1668
+ input: CmsGroupCreateInput;
1669
+ group: CmsGroup;
1670
+ }
1671
+ export interface CmsGroupStorageOperationsUpdateParams {
1672
+ original: CmsGroup;
1673
+ group: CmsGroup;
1674
+ input: CmsGroupUpdateInput;
1675
+ }
1676
+ export interface CmsGroupStorageOperationsDeleteParams {
1677
+ group: CmsGroup;
1678
+ }
1679
+ /**
1680
+ * Description of the CmsGroup CRUD operations.
1681
+ * If user wants to add another database to the application, this is how it is done.
1682
+ * This is just plain read, update, write, delete and list - no authentication or permission checks.
1683
+ */
1684
+ export interface CmsGroupStorageOperations {
1685
+ /**
1686
+ * Gets content model group by given id.
1687
+ */
1688
+ get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;
1689
+ /**
1690
+ * List all content model groups. Filterable via params.
1691
+ */
1692
+ list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;
1693
+ /**
1694
+ * Create a new content model group.
1695
+ */
1696
+ create: (params: CmsGroupStorageOperationsCreateParams) => Promise<CmsGroup>;
1697
+ /**
1698
+ * Update existing content model group.
1699
+ */
1700
+ update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<CmsGroup>;
1701
+ /**
1702
+ * Delete the content model group.
1703
+ */
1704
+ delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<CmsGroup>;
1705
+ }
1706
+ export interface CmsModelStorageOperationsGetParams {
1707
+ tenant: string;
1708
+ locale: string;
1709
+ modelId: string;
1710
+ }
1711
+ export interface CmsModelStorageOperationsListWhereParams {
1712
+ tenant: string;
1713
+ locale: string;
1714
+ [key: string]: string;
1715
+ }
1716
+ export interface CmsModelStorageOperationsListParams {
1717
+ where: CmsModelStorageOperationsListWhereParams;
1718
+ }
1719
+ export interface CmsModelStorageOperationsCreateParams {
1720
+ input: CmsModelCreateInput;
1721
+ model: CmsModel;
1722
+ }
1723
+ export interface CmsModelStorageOperationsUpdateParams {
1724
+ original: CmsModel;
1725
+ model: CmsModel;
1726
+ input: CmsModelUpdateInput;
1727
+ }
1728
+ export interface CmsModelStorageOperationsDeleteParams {
1729
+ model: CmsModel;
1730
+ }
1731
+ /**
1732
+ * Description of the CmsModel storage operations.
1733
+ * If user wants to add another database to the application, this is how it is done.
1734
+ * This is just plain read, update, write, delete and list - no authentication or permission checks.
1735
+ */
1736
+ export interface CmsModelStorageOperations {
1737
+ /**
1738
+ * Gets content model by given id.
1739
+ */
1740
+ get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;
1741
+ /**
1742
+ * List all content models. Filterable via params.
1743
+ */
1744
+ list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;
1745
+ /**
1746
+ * Create a new content model.
1747
+ */
1748
+ create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;
1749
+ /**
1750
+ * Update existing content model.
1751
+ */
1752
+ update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;
1753
+ /**
1754
+ * Delete the content model.
1755
+ */
1756
+ delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;
1757
+ }
1758
+ export interface CmsEntryStorageOperationsGetParams {
1759
+ where: CmsEntryListWhere;
1760
+ sort?: CmsEntryListSort;
1761
+ limit?: number;
1762
+ }
1763
+ export interface CmsEntryStorageOperationsListParams {
1764
+ where: CmsEntryListWhere;
1765
+ sort?: CmsEntryListSort;
1766
+ limit?: number;
1767
+ after?: string;
1768
+ }
1769
+ export interface CmsEntryStorageOperationsCreateParams<T extends CmsStorageEntry = CmsStorageEntry> {
1770
+ /**
1771
+ * Input received from the user.
1772
+ */
1773
+ input: Record<string, any>;
1774
+ /**
1775
+ * Real entry, with no transformations on it.
1776
+ */
1777
+ entry: CmsEntry;
1778
+ /**
1779
+ * Entry prepared for the storage.
1780
+ */
1781
+ storageEntry: T;
1782
+ }
1783
+ export interface CmsEntryStorageOperationsCreateRevisionFromParams<T extends CmsStorageEntry = CmsStorageEntry> {
1784
+ /**
1785
+ * The entry we are creating new one from.
1786
+ */
1787
+ originalEntry: CmsEntry;
1788
+ /**
1789
+ * The entry we are creating new one from, directly from storage, with transformations on it.
1790
+ */
1791
+ originalStorageEntry: T;
1792
+ /**
1793
+ * Latest entry, used to calculate the new version.
1794
+ */
1795
+ latestEntry: CmsEntry;
1796
+ /**
1797
+ * Latest entry, used to calculate the new version, directly from storage, with transformations.
1798
+ */
1799
+ latestStorageEntry: T;
1800
+ /**
1801
+ * Real entry, with no transformations on it.
1802
+ */
1803
+ entry: CmsEntry;
1804
+ /**
1805
+ * Entry prepared for the storage.
1806
+ */
1807
+ storageEntry: T;
1808
+ }
1809
+ export interface CmsEntryStorageOperationsUpdateParams<T extends CmsStorageEntry = CmsStorageEntry> {
1810
+ /**
1811
+ * Input received from the user.
1812
+ */
1813
+ input: Record<string, any>;
1814
+ /**
1815
+ * Used to compare IDs, versions and passed into storage operations to be used if required.
1816
+ */
1817
+ originalEntry: CmsEntry;
1818
+ /**
1819
+ * Directly from storage, with transformations on it.
1820
+ */
1821
+ originalStorageEntry: T;
1822
+ /**
1823
+ * Real entry, with no transformations on it.
1824
+ */
1825
+ entry: CmsEntry;
1826
+ /**
1827
+ * Entry prepared for the storage.
1828
+ */
1829
+ storageEntry: T;
1830
+ }
1831
+ export interface CmsEntryStorageOperationsDeleteRevisionParams<T extends CmsStorageEntry = CmsStorageEntry> {
1832
+ /**
1833
+ * Entry that was deleted.
1834
+ */
1835
+ entryToDelete: CmsEntry;
1836
+ /**
1837
+ * Entry that was deleted, directly from storage, with transformations.
1838
+ */
1839
+ storageEntryToDelete: T;
1840
+ /**
1841
+ * Entry that was set as latest.
1842
+ */
1843
+ entryToSetAsLatest?: CmsEntry;
1844
+ /**
1845
+ * Entry that was set as latest, directly from storage, with transformations.
1846
+ */
1847
+ storageEntryToSetAsLatest?: T;
1848
+ }
1849
+ export interface CmsEntryStorageOperationsDeleteParams<T extends CmsStorageEntry = CmsStorageEntry> {
1850
+ /**
1851
+ * Entry that is going to be deleted.
1852
+ */
1853
+ entry: CmsEntry;
1854
+ /**
1855
+ * Entry that is going to be deleted, directly from storage.
1856
+ */
1857
+ storageEntry: T;
1858
+ }
1859
+ export interface CmsEntryStorageOperationsPublishParams<T extends CmsStorageEntry = CmsStorageEntry> {
1860
+ /**
1861
+ * The entry record before it was published.
1862
+ */
1863
+ originalEntry: CmsEntry;
1864
+ /**
1865
+ * Directly from storage, with transformations on it.
1866
+ */
1867
+ originalStorageEntry: T;
1868
+ /**
1869
+ * The modified entry that is going to be saved as published.
1870
+ * Entry is in its original form.
1871
+ */
1872
+ entry: CmsEntry;
1873
+ /**
1874
+ * The modified entry and prepared for the storage.
1875
+ */
1876
+ storageEntry: T;
1877
+ }
1878
+ export interface CmsEntryStorageOperationsUnpublishParams<T extends CmsStorageEntry = CmsStorageEntry> {
1879
+ /**
1880
+ * The entry record before it was unpublished.
1881
+ */
1882
+ originalEntry: CmsEntry;
1883
+ /**
1884
+ * The entry record before it was unpublished, with transformations on it.
1885
+ */
1886
+ originalStorageEntry: T;
1887
+ /**
1888
+ * The modified entry that is going to be saved as unpublished.
1889
+ */
1890
+ entry: CmsEntry;
1891
+ /**
1892
+ * The modified entry that is going to be saved as unpublished, with transformations on it.
1893
+ */
1894
+ storageEntry: T;
1895
+ }
1896
+ export interface CmsEntryStorageOperationsRequestChangesParams<T extends CmsStorageEntry = CmsStorageEntry> {
1897
+ /**
1898
+ * Entry data updated with the required properties.
1899
+ */
1900
+ entry: CmsEntry;
1901
+ /**
1902
+ * Entry that is prepared for the storageOperations, with the transformations.
1903
+ */
1904
+ storageEntry: T;
1905
+ /**
1906
+ * Original entry from the storage.
1907
+ */
1908
+ originalEntry: CmsEntry;
1909
+ /**
1910
+ * Original entry to be updated, directly from storage, with the transformations.
1911
+ */
1912
+ originalStorageEntry: T;
1913
+ }
1914
+ export interface CmsEntryStorageOperationsRequestReviewParams<T extends CmsStorageEntry = CmsStorageEntry> {
1915
+ /**
1916
+ * Entry that is prepared for the storageOperations.
1917
+ */
1918
+ entry: CmsEntry;
1919
+ /**
1920
+ * Entry that is prepared for the storageOperations, with the transformations.
1921
+ */
1922
+ storageEntry: T;
1923
+ /**
1924
+ * Original entry from the storage.
1925
+ */
1926
+ originalEntry: CmsEntry;
1927
+ /**
1928
+ * Original entry to be updated, directly from storage, with the transformations.
1929
+ */
1930
+ originalStorageEntry: T;
1931
+ }
1932
+ export interface CmsEntryStorageOperationsGetAllRevisionsParams {
1933
+ ids: readonly string[];
1934
+ }
1935
+ export interface CmsEntryStorageOperationsGetByIdsParams {
1936
+ ids: readonly string[];
1937
+ }
1938
+ export interface CmsEntryStorageOperationsGetLatestByIdsParams {
1939
+ ids: readonly string[];
1940
+ }
1941
+ export interface CmsEntryStorageOperationsGetPublishedByIdsParams {
1942
+ ids: readonly string[];
1943
+ }
1944
+ export interface CmsEntryStorageOperationsGetRevisionsParams {
1945
+ id: string;
1946
+ }
1947
+ export interface CmsEntryStorageOperationsGetRevisionParams {
1948
+ id: string;
1949
+ }
1950
+ export interface CmsEntryStorageOperationsGetPublishedRevisionParams {
1951
+ id: string;
1952
+ }
1953
+ export interface CmsEntryStorageOperationsGetLatestRevisionParams {
1954
+ id: string;
1955
+ }
1956
+ export interface CmsEntryStorageOperationsGetPreviousRevisionParams {
1957
+ entryId: string;
1958
+ version: number;
1959
+ }
1960
+ export interface CmsEntryStorageOperationsListResponse<T extends CmsStorageEntry = CmsStorageEntry> {
1961
+ /**
1962
+ * Has more items to load with the current filtering?
1963
+ */
1964
+ hasMoreItems: boolean;
1965
+ /**
1966
+ * Items loaded with current filtering.
1967
+ */
1968
+ items: T[];
1969
+ /**
1970
+ * Pointer for where to start the new item set.
1971
+ */
1972
+ cursor: string | null;
1973
+ /**
1974
+ * Total amount of items with the current filter.
1975
+ */
1976
+ totalCount: number;
1977
+ }
1978
+ /**
1979
+ * Description of the CmsModel storage operations.
1980
+ * If user wants to add another database to the application, this is how it is done.
1981
+ * This is just plain read, update, write, delete and list - no authentication or permission checks.
1982
+ *
1983
+ *
1984
+ * @category StorageOperations
1985
+ * @category CmsEntry
1986
+ */
1987
+ export interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorageEntry> {
1988
+ /**
1989
+ * Get all the entries of the ids.
1990
+ */
1991
+ getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;
1992
+ /**
1993
+ * Get all the published entries of the ids.
1994
+ */
1995
+ getPublishedByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetPublishedByIdsParams) => Promise<T[]>;
1996
+ /**
1997
+ * Get all the latest entries of the ids.
1998
+ */
1999
+ getLatestByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetLatestByIdsParams) => Promise<T[]>;
2000
+ /**
2001
+ * Get all revisions of the given entry id.
2002
+ */
2003
+ getRevisions: (model: CmsModel, params: CmsEntryStorageOperationsGetRevisionsParams) => Promise<T[]>;
2004
+ /**
2005
+ * Get all revisions of all of the given IDs.
2006
+ */
2007
+ getAllRevisionsByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetAllRevisionsParams) => Promise<T[]>;
2008
+ /**
2009
+ * Get the entry by the given revision id.
2010
+ */
2011
+ getRevisionById: (model: CmsModel, params: CmsEntryStorageOperationsGetRevisionParams) => Promise<T | null>;
2012
+ /**
2013
+ * Get the published entry by given entryId.
2014
+ */
2015
+ getPublishedRevisionByEntryId: (model: CmsModel, params: CmsEntryStorageOperationsGetPublishedRevisionParams) => Promise<T | null>;
2016
+ /**
2017
+ * Get the latest entry by given entryId.
2018
+ */
2019
+ getLatestRevisionByEntryId: (model: CmsModel, params: CmsEntryStorageOperationsGetLatestRevisionParams) => Promise<T | null>;
2020
+ /**
2021
+ * Get the revision of the entry before given one.
2022
+ */
2023
+ getPreviousRevision: (model: CmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams) => Promise<T | null>;
2024
+ /**
2025
+ * Gets entry by given params.
2026
+ */
2027
+ get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;
2028
+ /**
2029
+ * List all entries. Filterable via params.
2030
+ */
2031
+ list: (model: CmsModel, params: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<T>>;
2032
+ /**
2033
+ * Create a new entry.
2034
+ */
2035
+ create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;
2036
+ /**
2037
+ * Create a new entry from existing one.
2038
+ */
2039
+ createRevisionFrom: (model: CmsModel, params: CmsEntryStorageOperationsCreateRevisionFromParams<T>) => Promise<T>;
2040
+ /**
2041
+ * Update existing entry.
2042
+ */
2043
+ update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;
2044
+ /**
2045
+ * Delete the entry revision.
2046
+ */
2047
+ deleteRevision: (model: CmsModel, params: CmsEntryStorageOperationsDeleteRevisionParams<T>) => Promise<void>;
2048
+ /**
2049
+ * Delete the entry.
2050
+ */
2051
+ delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams<T>) => Promise<void>;
2052
+ /**
2053
+ * Publish the entry.
2054
+ */
2055
+ publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;
2056
+ /**
2057
+ * Unpublish the entry.
2058
+ */
2059
+ unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;
2060
+ /**
2061
+ * Request changes the entry.
2062
+ */
2063
+ requestChanges: (model: CmsModel, params: CmsEntryStorageOperationsRequestChangesParams<T>) => Promise<T>;
2064
+ /**
2065
+ * Request review the entry.
2066
+ */
2067
+ requestReview: (model: CmsModel, params: CmsEntryStorageOperationsRequestReviewParams<T>) => Promise<CmsEntry>;
2068
+ }
2069
+ export declare enum CONTENT_ENTRY_STATUS {
2070
+ DRAFT = "draft",
2071
+ PUBLISHED = "published",
2072
+ UNPUBLISHED = "unpublished",
2073
+ CHANGES_REQUESTED = "changesRequested",
2074
+ REVIEW_REQUESTED = "reviewRequested"
2075
+ }
2076
+ export interface CmsSettingsStorageOperationsGetParams {
2077
+ locale: string;
2078
+ tenant: string;
2079
+ }
2080
+ export interface CmsSettingsStorageOperationsCreateParams {
2081
+ settings: CmsSettings;
2082
+ }
2083
+ export interface CmsSettingsStorageOperationsUpdateParams {
2084
+ original: CmsSettings;
2085
+ settings: CmsSettings;
2086
+ }
2087
+ export interface CmsSettingsStorageOperations {
2088
+ /**
2089
+ * Get the settings from the storage.
2090
+ */
2091
+ get: (params: CmsSettingsStorageOperationsGetParams) => Promise<CmsSettings | null>;
2092
+ /**
2093
+ * Create settings in the storage.
2094
+ */
2095
+ create: (params: CmsSettingsStorageOperationsCreateParams) => Promise<CmsSettings>;
2096
+ /**
2097
+ * Update the settings in the storage.
2098
+ */
2099
+ update: (params: CmsSettingsStorageOperationsUpdateParams) => Promise<CmsSettings>;
2100
+ }
2101
+ export interface CmsSystem {
2102
+ version?: string;
2103
+ readAPIKey?: string;
2104
+ /**
2105
+ * System tenant.
2106
+ */
2107
+ tenant: string;
2108
+ }
2109
+ export interface CmsSystemStorageOperationsGetParams {
2110
+ tenant: string;
2111
+ }
2112
+ export interface CmsSystemStorageOperationsCreateParams {
2113
+ system: CmsSystem;
2114
+ }
2115
+ export interface CmsSystemStorageOperationsUpdateParams {
2116
+ system: CmsSystem;
2117
+ original: CmsSystem;
2118
+ }
2119
+ export interface CmsSystemStorageOperations {
2120
+ /**
2121
+ * Get the system data.
2122
+ */
2123
+ get: (params: CmsSystemStorageOperationsGetParams) => Promise<CmsSystem | null>;
2124
+ /**
2125
+ * Create the system info in the storage.
2126
+ */
2127
+ create: (params: CmsSystemStorageOperationsCreateParams) => Promise<CmsSystem>;
2128
+ /**
2129
+ * Update the system info in the storage.
2130
+ */
2131
+ update: (params: CmsSystemStorageOperationsUpdateParams) => Promise<CmsSystem>;
2132
+ }
2133
+ export interface HeadlessCmsStorageOperations {
2134
+ system: CmsSystemStorageOperations;
2135
+ settings: CmsSettingsStorageOperations;
2136
+ groups: CmsGroupStorageOperations;
2137
+ models: CmsModelStorageOperations;
2138
+ entries: CmsEntryStorageOperations;
2139
+ init?: (cms: HeadlessCms) => Promise<void>;
2140
+ /**
2141
+ * Plugins to be attached to the main context.
2142
+ */
2143
+ plugins?: Plugin[] | Plugin[][];
2144
+ /**
2145
+ * An upgrade to run if necessary.
2146
+ */
2147
+ upgrade?: UpgradePlugin | null;
2148
+ }
2149
+ export {};