@cloudcannon/configuration-types 0.0.41 → 0.0.43

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.
@@ -1,309 +1,32 @@
1
1
  import * as z from 'zod';
2
- import { CascadeSchema, EditorKeySchema, ReducedCascadeSchema } from './cascade';
3
- import { DocumentationSchema } from './documentation';
4
- import { IconSchema } from './icon';
5
- import { InputSchema } from './inputs';
2
+ import { CascadeSchema } from './cascade';
3
+ import { CollectionConfigSchema, CollectionGroupSchema } from './collections';
4
+ import { InputsSchema } from './inputs';
6
5
  import { MarkdownSettingsSchema } from './markdown';
7
6
  import { PathsSchema } from './paths';
8
- import { PreviewSchema } from './preview';
9
7
  import { SnippetConfigSchema } from './snippets';
10
8
  import { SnippetsImportsSchema } from './snippets';
11
9
  import { SourceEditorSchema } from './source-editor';
12
10
  import { TimezoneSchema } from './timezone';
13
11
 
14
- export const HrefAddOptionSchema = z
15
- .object({
16
- name: z.string().optional().meta({
17
- description: 'The text displayed for the menu item.',
18
- }),
19
- icon: IconSchema.default('add').optional().meta({
20
- description: 'The icon next to the text in the menu item.',
21
- }),
22
- href: z.string().meta({
23
- description:
24
- 'The link that opens when the option is clicked. Can either be an external or internal link. If internal, the link is relative to the current site.',
25
- }),
26
- })
27
- .meta({
28
- title: 'HREF Add Option',
29
- description: 'An option for the add menu that opens a link.',
30
- });
31
-
32
- export const AddOptionSchema = z
33
- .object({
34
- name: z.string().optional().meta({
35
- description:
36
- 'The text displayed for the menu item. Defaults to using name from the matching schema if set.',
37
- }),
38
- icon: IconSchema.optional().meta({
39
- description:
40
- 'The icon next to the text in the menu item. Defaults to using icon from the matching schema if set, then falls back to add.',
41
- }),
42
- editor: EditorKeySchema.optional().meta({
43
- description:
44
- "The editor to open the new file in. Defaults to an appropriate editor for new file's type if possible. If no default editor can be calculated, or the editor does not support the new file type, a warning is shown in place of the editor.",
45
- }),
46
- base_path: z.string().optional().meta({
47
- description:
48
- 'Enforces a path for new files to be created in, regardless of path the user is currently navigated to within the collection file list. Relative to the path of the collection defined in collection. Defaults to the path within the collection the user is currently navigated to.',
49
- }),
50
- collection: z.string().optional().meta({
51
- description:
52
- 'Sets which collection this action is creating a file in. This is used when matching the value for schema. Defaults to the containing collection these `add_options` are configured in.',
53
- }),
54
- schema: z.string().optional().meta({
55
- description:
56
- 'The schema that new files are created from with this action. This schema is not restricted to the containing collection, and is instead relative to the collection specified with collection. Defaults to default if schemas are configured for the collection.',
57
- }),
58
- default_content_file: z.string().optional().meta({
59
- description:
60
- 'The path to a file used to populate the initial contents of a new file if no schemas are configured. We recommend using schemas, and this is ignored if a schema is available.',
61
- }),
62
- })
63
- .meta({
64
- title: 'Add Option',
65
- description: 'An option for the add menu.',
66
- });
67
-
68
- export const SortSchema = z
69
- .object({
70
- key: z.string().meta({
71
- description:
72
- "Defines what field contains the value to sort on inside each collection item's data.",
73
- }),
74
- order: z.enum(['ascending', 'descending', 'asc', 'desc']).default('ascending').optional().meta({
75
- description: 'Controls which sort values come first.',
76
- }),
77
- })
78
- .meta({
79
- title: 'Sort',
80
- description: 'A sort for a Collection.',
81
- });
82
-
83
- export const SortOptionSchema = z
84
- .object({
85
- ...SortSchema.shape,
86
- label: z.string().optional().meta({
87
- description:
88
- 'The text to display in the sort option list. Defaults to a generated label from key and order.',
89
- }),
90
- })
91
- .meta({
92
- title: 'SortOption',
93
- description: 'A sort option for a Collection.',
94
- });
95
-
96
- export const CreateSchema = z
97
- .object({
98
- ...ReducedCascadeSchema.shape,
99
- path: z.string().optional().meta({
100
- description:
101
- "The raw template to be processed when creating files. Relative to the containing collection's path.",
102
- }),
103
- extra_data: z.record(z.string(), z.string()).optional().meta({
104
- description:
105
- 'Adds to the available data placeholders coming from the file. Entry values follow the same format as path, and are processed sequentially before path. These values are not saved back to your file.',
106
- }),
107
- publish_to: z.string().optional().meta({
108
- description:
109
- "Defines a target collection when publishing. When a file is published, the target collection's create definition is used instead.",
110
- }),
111
- })
112
- .meta({
113
- id: 'create',
114
- title: 'Create',
115
- description: 'Controls where new files are saved.',
116
- });
12
+ export const DataConfigEntrySchema = z.object({ path: z.string() }).meta({ id: 'DataConfigEntry' });
117
13
 
118
- export const SchemaSchema = z
119
- .object({
120
- ...CascadeSchema.shape,
121
- preview: PreviewSchema.optional(),
122
- path: z.string().meta({
123
- description: 'The path to the schema file. Relative to the root folder of the site.',
124
- }),
125
- name: z.string().optional().meta({
126
- description:
127
- 'Displayed in the add menu when creating new files. Defaults to a formatted version of the key.',
128
- }),
129
- icon: IconSchema.default('notes').optional().meta({
130
- description:
131
- 'Displayed in the add menu when creating new files; also used as the icon for collection files if no other preview is found. Defaults to notes.',
132
- }),
133
- create: CreateSchema.optional(),
134
- new_preview_url: z.string().optional().meta({
135
- description:
136
- "Preview your unbuilt pages (e.g. drafts) to another page's output URL. The Visual Editor will load that URL, where Data Bindings and Previews are available to render your new page without saving.",
137
- }),
138
- reorder_inputs: z.boolean().default(true).optional().meta({
139
- description:
140
- 'If true, inputs are sorted to match when editing. Extra inputs are ordered after expected inputs, unless `remove_extra_inputs` is true. Defaults to true.',
141
- }),
142
- hide_extra_inputs: z.boolean().default(false).optional().meta({
143
- description:
144
- 'Hides unexpected inputs when editing. Has no effect if `remove_extra_inputs` is true. Defaults to false.',
145
- }),
146
- remove_empty_inputs: z.boolean().default(false).optional().meta({
147
- description:
148
- 'If checked, empty inputs are removed from the source file on save. Removed inputs will be available for editing again, provided they are in the matching schema/structure. Defaults to false.',
149
- }),
150
- remove_extra_inputs: z.boolean().default(true).optional().meta({
151
- description: 'If checked, extra inputs are removed when editing. Defaults to true.',
152
- }),
153
- })
154
- .meta({
155
- title: 'Schema',
156
- description:
157
- 'Definitions for your schemas, which are the structured data formats for your content files.',
158
- });
159
-
160
- export const CollectionConfigSchema = z
14
+ export const FileConfigEntrySchema = z
161
15
  .object({
162
- ...CascadeSchema.shape,
163
- preview: PreviewSchema.optional(),
164
- path: z.string().meta({
165
- id: 'path',
166
- description:
167
- 'This key defines the folder path for the collection key in which it is nested. The value for this key is relative to your Site `source`. Each Collection must have a unique path.',
168
- }),
169
16
  glob: z
170
- .union([z.array(z.string()), z.string()])
171
- .optional()
17
+ .union([
18
+ z.array(z.string()).meta({ title: 'Glob Array' }),
19
+ z.string().meta({ title: 'Glob' }),
20
+ ])
172
21
  .meta({
173
- id: 'glob',
174
- description:
175
- 'This key defines globs which filter the files visible in the _Collection browser_ for a given Collection. Values in this array are relative to the Collection `path`.',
22
+ description: 'The glob pattern(s) targeting a path to one or more files.',
176
23
  }),
177
- url: z.string().optional().meta({
178
- description:
179
- 'This key defines the output URL for files in a given Collection. CloudCannon uses the output URL in the Visual Editor, and when linking to your Testing Domain and Custom Domain.',
180
- }),
181
- disable_url: z.boolean().default(false).optional().meta({
182
- description:
183
- 'This key toggles whether CloudCannon will generate an output URL for a given Collection.',
184
- }),
185
- include_developer_files: z.boolean().default(false).optional().meta({
186
- description:
187
- 'This key toggles whether CloudCannon removes developer files from your _Collection browser_.',
188
- }),
189
- name: z.string().optional().meta({
190
- description:
191
- 'This key defines the display name for a Collection. The name appears in the _Site Navigation_ and at the top of the _Collection browser_.',
192
- }),
193
- description: z.string().optional().meta({
194
- description:
195
- 'This key defines the description text that appears on the _Collection browser_ page. Collection descriptions are useful for adding extra context for your team members.',
196
- }),
197
- icon: IconSchema.default('notes').optional().meta({
198
- description:
199
- 'This key defines the icon for a Collection. Collection icons appear in the _Site Navigation_ and are the default icon for Collection file Cards if you have not defined `preview.icon`.',
200
- }),
201
- documentation: DocumentationSchema.optional().meta({
202
- description:
203
- 'This key defines the documentation link at the top of a _Collection browser_. Collection documentation is useful for assisting your team members.',
204
- }),
205
- sort_options: z.array(SortOptionSchema).optional().meta({
206
- description:
207
- 'This key defines the options for the Sort dropdown in a _Collection browser_. The first option listed is used as the default sort.',
208
- }),
209
- view_options: z
210
- .array(z.enum(['card', 'list', 'gallery']))
211
- .optional()
212
- .meta({
213
- uniqueItems: true,
214
- description:
215
- 'This key defines the options for the View dropdown in a _Collection browser_. The first option listed is used as the default view.',
216
- }),
217
- singular_name: z.string().optional().meta({
218
- description:
219
- 'This key defines the singular noun for your Collection name. CloudCannon uses the singular noun in the _+ Add_ button in the top right of the _Collection browser_.',
220
- }),
221
- add_options: z
222
- .array(z.union([AddOptionSchema, HrefAddOptionSchema]))
223
- .optional()
224
- .meta({
225
- description:
226
- 'This key defines the options available in the _+ Add_ button dropdown at the top right of your _Collection browser_.',
227
- }),
228
- create: CreateSchema.optional(),
229
- disable_add: z.boolean().optional().meta({
230
- description:
231
- 'This key toggles whether team members can use the _+ Add_ button in the top right of the _Collection browser_ to add files to a Collection.',
232
- }),
233
- disable_add_folder: z.boolean().optional().meta({
234
- description:
235
- 'This key toggles whether team members can use the _+ Add_ button in the top right of the _Collection browser_ to add subfolders to a Collection.',
236
- }),
237
- disable_file_actions: z.boolean().optional().meta({
238
- description:
239
- 'This key toggles whether team members can use the _+ Add_ button in the top right of the _Collection browser_ to add files to a Collection.',
240
- }),
241
- new_preview_url: z.string().optional().meta({
242
- description:
243
- 'This key defines a new URL for previewing your unbuilt pages in the Visual Editor.',
244
- }),
245
- schemas: z.record(z.string(), SchemaSchema).optional().meta({
246
- description:
247
- 'This key defines which Schemas are available to populate files in this Collection.',
248
- }),
249
- schema_key: z.string().optional().meta({
250
- description:
251
- 'This key defines the name for the structured data key that references the Schema a file uses.',
252
- }),
253
- })
254
- .meta({
255
- title: 'CollectionConfig',
256
- description:
257
- 'Definitions for your Collections, which are the sets of content files for your site grouped by folder.',
258
- });
259
-
260
- export const CollectionGroupSchema = z
261
- .object({
262
- heading: z.string().meta({
263
- description: 'Short, descriptive label for this group of Collections.',
264
- }),
265
- collections: z.array(z.string()).meta({
266
- description:
267
- 'The collections shown in the sidebar for this group. Collections here are referenced by their key within `collections_config`.',
268
- }),
269
- })
270
- .meta({
271
- title: 'Collection Group',
272
- description:
273
- 'Defines which Collections are shown in the Site Navigation and how those Collections are grouped.',
274
- });
275
-
276
- export const DataConfigEntrySchema = z
277
- .object({
278
- path: z.string().meta({
279
- id: 'DataConfigEntry.path',
280
- description: 'The path to a file or folder of files containing data.',
281
- }),
282
- })
283
- .meta({
284
- id: 'DataConfigEntry',
285
- title: 'Data Config Entry',
286
- description: 'Controls what data sets are available to populate select and multiselect inputs.',
287
- });
288
-
289
- export const FileConfigEntrySchema = z
290
- .object({
291
24
  ...CascadeSchema.shape,
292
- glob: z.union([z.array(z.string()), z.string()]).meta({
293
- description: 'The glob pattern(s) targeting a path to one or more files.',
294
- }),
295
25
  })
296
- .meta({
297
- title: 'FileConfigEntry',
298
- description:
299
- 'Provides scope to configure at a file level, without adding configuration to files.',
300
- });
26
+ .meta({ id: 'FileConfigEntry' });
301
27
 
302
28
  export const EditorSchema = z.object({
303
- default_path: z.string().default('/').meta({
304
- description:
305
- 'The URL used for the dashboard screenshot, and where the editor opens to when clicking the dashboard "Edit Home" button.',
306
- }),
29
+ default_path: z.string().default('/').meta({ id: 'editor.default_path' }),
307
30
  });
308
31
 
309
32
  export const CommitTemplateSchema = z
@@ -320,10 +43,7 @@ export const CommitTemplateSchema = z
320
43
  description:
321
44
  'Sets the path for a file containing your commit template. The file path should be relative to the root directory.',
322
45
  }),
323
- _inputs: z.record(z.string(), InputSchema).optional().meta({
324
- title: 'Inputs',
325
- description: 'Define inputs used to populate data placeholders in the commit template.',
326
- }),
46
+ _inputs: InputsSchema.optional(),
327
47
  extra_data: z.record(z.string(), z.string()).optional().meta({
328
48
  description: 'Define additional template strings, for building nested templates.',
329
49
  }),
@@ -336,89 +56,72 @@ export const CommitTemplateSchema = z
336
56
  description: 'A template for commit messages when saving changes.',
337
57
  });
338
58
 
59
+ export const PullRequestTemplateSchema = z.object({
60
+ label: z.string().optional().meta({
61
+ description:
62
+ 'Used to identify a pull request template when multiple pull request templates are available.',
63
+ }),
64
+ title: z.string().optional().meta({
65
+ description: 'The default value for the pull request title.',
66
+ }),
67
+ body: z.string().optional().meta({
68
+ description: 'The default value for the pull request body.',
69
+ }),
70
+ template_path: z.string().optional().meta({
71
+ description:
72
+ 'Used to specify a file on the Site whose contents will be used as the default value for the pull request body. This has no effect if `body` is defined.',
73
+ }),
74
+ _inputs: InputsSchema.optional(),
75
+ });
76
+
339
77
  export const ConfigurationSchema = z
340
78
  .object({
341
- ...CascadeSchema.shape,
342
79
  paths: PathsSchema.optional(),
343
- version: z.literal('latest').optional().meta({
344
- description:
345
- 'Controls which schema this file is validated against. Defaults to the latest schema.',
346
- }),
347
- source: z
348
- .string()
80
+ version: z.literal('latest').optional().meta({ id: 'version', excludeFromDocumentation: true }),
81
+ source: z.string().optional().meta({ id: 'source' }),
82
+ collections_config: z
83
+ .record(z.string(), CollectionConfigSchema)
349
84
  .optional()
350
- .meta({
351
- description: `This key defines the base path for your source files, relative to the root folder of your
352
- repository. Unless you use a nested folder as the source for your Site you can leave this key
353
- empty or set it to \`/\`.
354
-
355
- By default, this key is empty.
356
-
357
- https://cloudcannon.com/documentation/articles/configuration-file-reference/#source',`,
358
- }),
359
- collections_config: z.record(z.string(), CollectionConfigSchema).optional().meta({
360
- description:
361
- 'Definitions for your collections, which are the sets of content files for your site grouped by folder.',
362
- }),
363
- collection_groups: z.array(CollectionGroupSchema).optional().meta({
364
- description:
365
- 'Defines which collections are shown in the site navigation and how those collections are grouped.',
366
- }),
367
- base_url: z.string().optional().meta({
368
- description: 'The subpath where your output files are hosted.',
369
- }),
370
- data_config: z.record(z.string(), DataConfigEntrySchema).optional().meta({
371
- description:
372
- 'Controls what data sets are available to populate select and multiselect inputs.',
373
- }),
374
- file_config: z.array(FileConfigEntrySchema).optional().meta({
375
- description:
376
- 'Provides scope to configure at a file level, without adding configuration to files.',
377
- }),
378
- editor: EditorSchema.optional().meta({
379
- description: 'Contains settings for the default editor actions on your site.',
380
- }),
381
- source_editor: SourceEditorSchema.optional().meta({
382
- title: 'Source Editor',
383
- description:
384
- 'This key defines the appearance and behavior of the Source Editor. The following nested keys are available:\n\n- `tab_size`\n- `show_gutter`\n- `theme`\n\nThis key has no default.\n\nhttps://cloudcannon.com/documentation/articles/the-source-editor/#source_editor',
385
- }),
386
- commit_templates: z.array(CommitTemplateSchema).optional().meta({
387
- description: 'Templates for commit messages when saving changes.',
388
- }),
389
- upstream_commit_template: z.string().optional().meta({
390
- description: 'The commit template to use when pulling changes from the upstream repository.',
391
- }),
392
- markdown: MarkdownSettingsSchema.optional().meta({
393
- description: 'Contains settings for various Markdown engines.',
394
- }),
395
- timezone: TimezoneSchema.default('Etc/UTC').optional().meta({
396
- description: 'Specifies the time zone that dates are displayed and edited in.',
397
- }),
85
+ .meta({ id: 'collections_config' }),
86
+ collection_groups: z
87
+ .array(CollectionGroupSchema)
88
+ .optional()
89
+ .meta({ id: 'collection_groups', title: 'Collection Groups' }),
90
+ base_url: z.string().optional().meta({ id: 'base_url' }),
91
+ data_config: z.record(z.string(), DataConfigEntrySchema).optional().meta({ id: 'data_config' }),
92
+ file_config: z.array(FileConfigEntrySchema).optional().meta({ id: 'file_config' }),
93
+ editor: EditorSchema.optional().meta({ id: 'editor' }),
94
+ source_editor: SourceEditorSchema.optional().meta({ id: 'source_editor' }),
95
+ pull_request_templates: z.array(PullRequestTemplateSchema).optional().meta({
96
+ description: 'Templates for pull requests.',
97
+ }),
98
+ commit_templates: z.array(CommitTemplateSchema).optional().meta({ id: 'commit_templates' }),
99
+ upstream_commit_template: z.string().optional().meta({ id: 'upstream_commit_template' }),
100
+ markdown: MarkdownSettingsSchema.optional().meta({ id: 'markdown' }),
101
+ timezone: TimezoneSchema.default('Etc/UTC').optional(),
102
+ ...CascadeSchema.shape,
398
103
  _snippets: z.record(z.string(), SnippetConfigSchema).optional().meta({
104
+ id: 'type._snippets',
105
+ title: 'Snippets',
399
106
  description: 'Configuration for custom snippets.',
400
107
  }),
401
108
  _snippets_imports: SnippetsImportsSchema.optional(),
402
109
  _snippets_templates: z.record(z.string(), SnippetConfigSchema).optional().meta({
110
+ id: 'type._snippets_templates',
111
+ title: 'Snippets Templates',
403
112
  description: 'Extended option used when creating more complex custom snippets.',
404
113
  }),
405
- _snippets_definitions: z.record(z.string(), SnippetConfigSchema).optional().meta({
114
+ _snippets_definitions: z.record(z.string(), z.unknown()).optional().meta({
115
+ id: 'type._snippets_definitions',
116
+ title: 'Snippets Definitions',
406
117
  description: 'Extended option used when creating more complex custom snippets.',
407
118
  }),
408
119
  })
409
120
  .meta({
410
121
  title: 'Configuration',
411
- description: 'The main CloudCannon configuration schema.',
122
+ description: 'The main CloudCannon configuration.',
412
123
  });
413
124
 
414
- export type HrefAddOption = z.infer<typeof HrefAddOptionSchema>;
415
- export type AddOption = z.infer<typeof AddOptionSchema>;
416
- export type Sort = z.infer<typeof SortSchema>;
417
- export type SortOption = z.infer<typeof SortOptionSchema>;
418
- export type Create = z.infer<typeof CreateSchema>;
419
- export type Schema = z.infer<typeof SchemaSchema>;
420
- export type CollectionConfig = z.infer<typeof CollectionConfigSchema>;
421
- export type CollectionGroup = z.infer<typeof CollectionGroupSchema>;
422
125
  export type DataConfigEntry = z.infer<typeof DataConfigEntrySchema>;
423
126
  export type FileConfigEntry = z.infer<typeof FileConfigEntrySchema>;
424
127
  export type Editor = z.infer<typeof EditorSchema>;
package/src/editables.ts CHANGED
@@ -215,22 +215,32 @@ export const LinkEditableSchema = z.object({
215
215
 
216
216
  export const EditablesSchema = z.object({
217
217
  content: BlockEditableSchema.optional().meta({
218
+ id: 'ContentEditable',
219
+ title: 'Content Editable',
218
220
  description: 'Contains input options for the Content Editor.',
219
221
  }),
220
222
 
221
223
  block: BlockEditableSchema.optional().meta({
224
+ id: 'BlockEditable',
225
+ title: 'Block Editable',
222
226
  description: 'Contains input options for block Editable Regions.',
223
227
  }),
224
228
 
225
229
  link: LinkEditableSchema.optional().meta({
230
+ id: 'LinkEditable',
231
+ title: 'Link Editable',
226
232
  description: 'Contains input options for link Editable Regions.',
227
233
  }),
228
234
 
229
235
  image: ImageEditableSchema.optional().meta({
236
+ id: 'ImageEditable',
237
+ title: 'Image Editable',
230
238
  description: 'Contains input options for image Editable Regions.',
231
239
  }),
232
240
 
233
241
  text: TextEditableSchema.optional().meta({
242
+ id: 'TextEditable',
243
+ title: 'Text Editable',
234
244
  description: 'Contains input options for text Editable Regions.',
235
245
  }),
236
246
  });
package/src/icon.ts CHANGED
@@ -3591,7 +3591,7 @@ export const IconSchema = z
3591
3591
  id: 'icon',
3592
3592
  title: 'Icon',
3593
3593
  description:
3594
- 'Material Design icon names available in CloudCannon for UI elements and content previews.',
3594
+ 'Material Symbol icon names available in CloudCannon for UI elements and content previews.',
3595
3595
  });
3596
3596
 
3597
3597
  export type Icon = z.infer<typeof IconSchema>;
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import * as z from 'zod';
3
3
  export * from './build-coupled';
4
4
  export * from './cascade';
5
5
  export * from './configuration';
6
+ export * from './collections';
6
7
  export * from './documentation';
7
8
  export * from './editables';
8
9
  export * from './icon';