@tinacms/schema-tools 1.3.2 → 1.3.4

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.
package/dist/types.d.ts DELETED
@@ -1,556 +0,0 @@
1
- /**
2
-
3
- */
4
- declare type Doc = {
5
- _sys: {
6
- title?: string;
7
- template: string;
8
- breadcrumbs: string[];
9
- path: string;
10
- basename: string;
11
- relativePath: string;
12
- filename: string;
13
- extension: string;
14
- };
15
- };
16
- /**
17
- *
18
- */
19
- export interface UICollection {
20
- filename?: {
21
- /**
22
- * A callback which receives form values as an argument. The return value
23
- * here will be used as the filename (the extension is not necessary)
24
- *
25
- * eg:
26
- * ```ts
27
- * slugify: (values) => values.title.toLowerCase().split(" ").join("-")
28
- * ```
29
- */
30
- slugify?: (values: Record<string, any>) => string;
31
- /**
32
- * When set to `true`, editors won't be able to modify the filename
33
- */
34
- readonly?: boolean;
35
- };
36
- /**
37
- * Forms for this collection will be editable from the global sidebar rather than the form panel
38
- */
39
- global?: boolean | {
40
- icon?: any;
41
- layout: 'fullscreen' | 'popup';
42
- };
43
- /**
44
- * Provide the path that your document is viewable on your site
45
- *
46
- * eg:
47
- * ```ts
48
- * router: ({ document }) => {
49
- * return `blog-posts/${document._sys.filename}`;
50
- * }
51
- * ```
52
- */
53
- router?: (args: {
54
- document: Doc;
55
- collection: Collection;
56
- }) => string | undefined;
57
- /**
58
- * Determines whether or not this collection can accept new docments
59
- * or allow documents to be deleted from the CMS.
60
- */
61
- allowedActions?: {
62
- create?: boolean;
63
- delete?: boolean;
64
- };
65
- }
66
- export declare type Option = string | {
67
- label: string;
68
- value: string;
69
- };
70
- import type React from 'react';
71
- declare type Meta = {
72
- active?: boolean;
73
- dirty?: boolean;
74
- error?: any;
75
- };
76
- declare type Component<Type, List> = (props: {
77
- field: SchemaField & {
78
- namespace: string[];
79
- };
80
- input: {
81
- /**
82
- * The full name of the field, for fields nested inside object
83
- * fields, this will be the full path:
84
- *
85
- * `myObject.0.title`
86
- */
87
- name: string;
88
- onBlur: (event?: React.FocusEvent<Type>) => void;
89
- /**
90
- * The value provided will be saved to the form so it
91
- * should match the configured type:
92
- *
93
- * `input.onChange('some string')`
94
- */
95
- onChange: (event: React.ChangeEvent<Type>) => void;
96
- onFocus: (event?: React.FocusEvent<Type>) => void;
97
- type?: string;
98
- value: List extends true ? Type[] : Type;
99
- };
100
- meta: Meta;
101
- }) => any;
102
- declare type UIField<Type, List extends boolean> = {
103
- max?: List extends true ? number : never;
104
- min?: List extends true ? number : never;
105
- /**
106
- * Override the label from parent object
107
- */
108
- label?: string;
109
- /**
110
- * Override the description from parent object
111
- */
112
- description?: string;
113
- /**
114
- * A React component which will be used in the Tina form. Be sure
115
- * to import React into the config file.
116
- *
117
- * Note: Any Tailwind classes provided here will be compiled as part
118
- * of the Tina stylesheet
119
- *
120
- * eg:
121
- * ```tsx
122
- * component: (props) => {
123
- * const { input, field } = props
124
- * return (
125
- * <div className="my-4">
126
- * <label
127
- * htmlFor={input.name}
128
- * className="block text-sm font-medium"
129
- * >
130
- * {field.name}
131
- * </label>
132
- * <div className="mt-1">
133
- * <input
134
- * id={input.name}
135
- * className="py-2 px-4 block"
136
- * type="text"
137
- * {...input}
138
- * />
139
- * </div>
140
- * </div>
141
- * )
142
- * }
143
- * ```
144
- *
145
- * Note: If the form has already been registered with the cms, you
146
- * can provide it's name here (eg. `textarea`)
147
- */
148
- component?: Component<Type, List> | string | null;
149
- /**
150
- * Optional: Prepare data for use in the component. This is useful
151
- * if you don't have access to the component directly
152
- */
153
- parse?: (value: List extends true ? Type[] : Type, name: string, field: Field) => List extends true ? Type[] : Type;
154
- /**
155
- * Optional: Prepare data for saving. This is useful
156
- * if you don't have access to the component directly
157
- */
158
- format?: (value: Type, name: string, field: Field) => List extends true ? Type[] : Type;
159
- /**
160
- * Optional: Return undefined when valid. Return a string or an object when there are errors.
161
- *
162
- * ```ts
163
- * validate: (value) => {
164
- * if(value.length > 40){
165
- * return 'Title cannot be more than 40 characters long'
166
- * }
167
- * }
168
- * ```
169
- */
170
- validate?(value: List extends true ? Type[] : Type, allValues: {
171
- [key: string]: any;
172
- }, meta: Meta, field: UIField<Type, List>): string | void;
173
- /**
174
- * @deprecated use `defaultItem` at the collection level instead
175
- */
176
- defaultValue?: List extends true ? Type[] : Type;
177
- };
178
- declare type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
179
- list: true;
180
- ui?: UIField<Type, true> & ExtraFieldUIProps;
181
- } : List extends false ? {
182
- list?: false;
183
- ui?: UIField<Type, false> & ExtraFieldUIProps;
184
- } : {
185
- list?: undefined;
186
- ui?: UIField<Type, false> & ExtraFieldUIProps;
187
- };
188
- export interface BaseField {
189
- label?: string | boolean;
190
- required?: boolean;
191
- name: string;
192
- description?: string;
193
- }
194
- export declare type StringField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
195
- type: 'string';
196
- isTitle?: boolean;
197
- options?: Option[];
198
- };
199
- export declare type NumberField = (FieldGeneric<number, undefined> | FieldGeneric<number, true> | FieldGeneric<number, false>) & BaseField & {
200
- type: 'number';
201
- };
202
- export declare type BooleanField = (FieldGeneric<boolean, undefined> | FieldGeneric<boolean, true> | FieldGeneric<boolean, false>) & BaseField & {
203
- type: 'boolean';
204
- };
205
- declare type DateFormatProps = {
206
- /**
207
- * Customize the way the format is rendered
208
- * ```
209
- * dateFormat: 'YYYY MM DD'
210
- * ```
211
- */
212
- dateFormat?: string;
213
- timeFormat?: string;
214
- };
215
- export declare type DateTimeField = (FieldGeneric<string, undefined, DateFormatProps> | FieldGeneric<string, true, DateFormatProps> | FieldGeneric<string, false, DateFormatProps>) & BaseField & {
216
- type: 'datetime';
217
- };
218
- export declare type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
219
- type: 'image';
220
- };
221
- export declare type ReferenceField = (FieldGeneric<string, undefined> | FieldGeneric<string, false>) & BaseField & {
222
- type: 'reference';
223
- /**
224
- * The names of the collections this field can use as a reference
225
- * ```ts
226
- * {
227
- * type: 'reference',
228
- * name: 'author',
229
- * collections: ['author'],
230
- * }
231
- * ```
232
- */
233
- collections: string[];
234
- };
235
- declare type RichTextAst = {
236
- type: 'root';
237
- children: Record<string, unknown>[];
238
- };
239
- export declare type RichTextField = (FieldGeneric<RichTextAst, undefined> | FieldGeneric<RichTextAst, false>) & BaseField & {
240
- type: 'rich-text';
241
- /**
242
- * When using Markdown or MDX formats, this field's value
243
- * will be saved to the markdown body, while all other values
244
- * will be stored as frontmatter
245
- */
246
- isBody?: boolean;
247
- templates?: (Template & {
248
- inline?: boolean;
249
- /**
250
- * If you have some custom shortcode logic in your markdown,
251
- * you can specify it in the 'match' property and Tina will
252
- * handle it as if it were a jsx element:
253
- *
254
- * ```
255
- * # This is my markdown, it uses some custom shortcode
256
- * syntax {{ myshortcode title="hello!" }}.
257
- *
258
- * {
259
- * match: {
260
- * start: "{{"
261
- * end: "}}"
262
- * }
263
- * }
264
- * ```
265
- */
266
- match?: {
267
- start: string;
268
- end: string;
269
- name?: string;
270
- };
271
- })[];
272
- /**
273
- * By default, Tina parses markdown with MDX, this is a more strict parser
274
- * that allows you to use structured content inside markdown (via `templates`).
275
- *
276
- * Specify `"markdown"` if you're having problems with Tina parsing your content.
277
- */
278
- parser?: {
279
- type: 'markdown';
280
- /**
281
- * Tina will escape entities like `<` and `[` by default. You can choose to turn
282
- * off all escaping, or specify HTML, so `<div>` will not be turned into `\<div>`
283
- */
284
- skipEscaping?: 'all' | 'html' | 'none';
285
- } | {
286
- type: 'mdx';
287
- };
288
- };
289
- declare type DefaultItem<ReturnType> = ReturnType | (() => ReturnType);
290
- declare type ObjectUiProps = {
291
- visualSelector?: boolean;
292
- };
293
- export declare type ObjectField = (FieldGeneric<string, undefined, ObjectUiProps> | FieldGeneric<string, true, ObjectUiProps> | FieldGeneric<string, false, ObjectUiProps>) & BaseField & ({
294
- type: 'object';
295
- fields: Field[];
296
- templates?: undefined;
297
- ui?: Template['ui'];
298
- } | {
299
- type: 'object';
300
- fields?: undefined;
301
- templates: Template[];
302
- });
303
- declare type Field = StringField | NumberField | BooleanField | DateTimeField | ImageField | ReferenceField | RichTextField | ObjectField;
304
- declare type SchemaField = Field;
305
- export type { SchemaField };
306
- export interface Template {
307
- label?: string;
308
- name: string;
309
- ui?: {
310
- /**
311
- * Override the properties passed to the field
312
- * component. This is mostly useful for controlling
313
- * the display value via callback on `itemProps.label`
314
- */
315
- itemProps?(item: Record<string, any>): {
316
- key?: string;
317
- /**
318
- * Control the display value when object
319
- * items are shown in a compact list, eg:
320
- *
321
- * ```ts
322
- * itemProps: (values) => ({
323
- * label: values?.title || 'Showcase Item',
324
- * }),
325
- * ```
326
- */
327
- label?: string;
328
- };
329
- defaultItem?: DefaultItem<Record<string, any>>;
330
- /**
331
- * When used in relation to the `visualSelector`,
332
- * provide an image URL to be used as the preview
333
- * in the blocks selector menu
334
- */
335
- previewSrc?: string;
336
- };
337
- fields: Field[];
338
- }
339
- export interface FieldCollection {
340
- label?: string;
341
- name: string;
342
- path: string;
343
- format?: 'json' | 'md' | 'markdown' | 'mdx' | 'yaml' | 'yml' | 'toml';
344
- /**
345
- * This format will be used to parse the markdown frontmatter
346
- */
347
- frontmatterFormat?: 'yaml' | 'toml' | 'json';
348
- /**
349
- * The delimiters used to parse the frontmatter.
350
- */
351
- frontmatterDelimiters?: [string, string] | string;
352
- ui?: UICollection & {
353
- defaultItem?: DefaultItem<Record<string, any>>;
354
- };
355
- /**
356
- * @deprecated - use `ui.defaultItem` instead
357
- */
358
- defaultItem?: DefaultItem<Record<string, any>>;
359
- templates?: never;
360
- /**
361
- * Fields define the shape of the content and the user input.
362
- *
363
- * https://tina.io/docs/reference/fields/
364
- */
365
- fields: Field[];
366
- }
367
- export interface TemplateCollection {
368
- label?: string;
369
- name: string;
370
- path: string;
371
- format?: 'json' | 'md' | 'markdown' | 'mdx' | 'yaml' | 'yml' | 'toml';
372
- ui?: UICollection;
373
- /**
374
- * @deprecated - use `ui.defaultItem` on the each `template` instead
375
- */
376
- defaultItem?: DefaultItem<Record<string, any>>;
377
- /**
378
- * In most cases, just using fields is enough, however templates can be used when there are multiple variants of the same collection or object. For example in a "page" collection there might be a need for a marketing page template and a content page template, both under the collection "page".
379
- *
380
- * https://tina.io/docs/reference/templates/
381
- */
382
- templates?: Template[];
383
- fields?: never;
384
- }
385
- export declare type Collection = FieldCollection | TemplateCollection;
386
- export interface Schema {
387
- /**
388
- * Collections represent a type of content (EX, blog post, page, author, etc). We recommend using singular naming in a collection (Ex: use post and not posts).
389
- *
390
- * https://tina.io/docs/reference/collections/
391
- */
392
- collections: Collection[];
393
- }
394
- export declare type TokenObject = {
395
- id_token: string;
396
- access_token?: string;
397
- refresh_token?: string;
398
- };
399
- export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> {
400
- contentApiUrlOverride?: string;
401
- admin?: {
402
- auth?: {
403
- /**
404
- * If you wish to use the local auth provider, set this to true
405
- *
406
- * This will take precedence over the customAuth option (if set to true)
407
- *
408
- **/
409
- useLocalAuth?: boolean;
410
- /**
411
- * If you are using a custom auth provider, set this to true
412
- **/
413
- customAuth?: boolean;
414
- /**
415
- * Used for getting the token from the custom auth provider
416
- *
417
- * @returns {Promise<TokenObject | null>}
418
- **/
419
- getToken?: () => Promise<TokenObject | null>;
420
- /**
421
- * Used to logout from the custom auth provider
422
- *
423
- **/
424
- logout?: () => Promise<void>;
425
- /**
426
- * Used for getting the user from the custom auth provider. If this returns a truthy value, the user will be logged in and the CMS will be enabled.
427
- *
428
- * If this returns a falsy value, the user will be logged out and the CMS will be disabled.
429
- *
430
- **/
431
- getUser?: () => Promise<any | null>;
432
- /**
433
- * Used to authenticate the user with the custom auth provider. This is called when the user clicks the login button.
434
- *
435
- **/
436
- authenticate?: () => Promise<any | null>;
437
- onLogin?: (args: {
438
- token: TokenObject;
439
- }) => Promise<void>;
440
- onLogout?: () => Promise<void>;
441
- };
442
- };
443
- /**
444
- * The Schema is used to define the shape of the content.
445
- *
446
- * https://tina.io/docs/reference/schema/
447
- */
448
- schema: Schema;
449
- /**
450
- * The base branch to pull content from. Note that this is ignored for local development
451
- */
452
- branch: string | null;
453
- /**
454
- * Your clientId from app.tina.io
455
- */
456
- clientId: string | null;
457
- /**
458
- * Your read only token from app.tina.io
459
- */
460
- token: string | null;
461
- /**
462
- * Configurations for the autogenerated GraphQL HTTP client
463
- */
464
- client?: {
465
- /**
466
- * Autogenerated queries will traverse references to a given depth
467
- * @default 2
468
- */
469
- referenceDepth?: number;
470
- };
471
- /**
472
- *
473
- * Tina supports serving content from a separate Git repo. To enable this during local development, point
474
- * this config at the root of the content repo.
475
- *
476
- * NOTE: Relative paths are fine to use here, but you should use an environment variable for this, as each developer on your team may have a different
477
- * location to the path.
478
- *
479
- * ```ts
480
- * localContentPath: process.env.REMOTE_ROOT_PATH // eg. '../../my-content-repo'
481
- * ```
482
- */
483
- localContentPath?: string;
484
- /**
485
- * Tina is compiled as a single-page app and placed in the public directory
486
- * of your application.
487
- */
488
- build: {
489
- /**
490
- * The folder where your application stores assets, eg. `"public"`
491
- */
492
- publicFolder: string;
493
- /**
494
- * The value specified here will determine the path when visiting the TinaCMS dashboard.
495
- *
496
- * Eg. `"admin"` will be viewable at `[your-development-url]/admin/index.html`
497
- *
498
- * Note that for most framworks you can omit the `index.html` portion, for Next.js see the [rewrites section](https://nextjs.org/docs/api-reference/next.config.js/rewrites)
499
- */
500
- outputFolder: string;
501
- /**
502
- *
503
- * the host option for the vite config. This is useful when trying to run tinacms dev in a docker container.
504
- *
505
- * See https://vitejs.dev/config/server-options.html#server-host for more details
506
- */
507
- host?: string | boolean;
508
- };
509
- media?: {
510
- /**
511
- * Load a media store like Cloudinary
512
- *
513
- * ```ts
514
- * loadCustomStore = async () => {
515
- * const pack = await import("next-tinacms-cloudinary");
516
- * return pack.TinaCloudCloudinaryMediaStore;
517
- * }
518
- * ```
519
- */
520
- loadCustomStore: () => Promise<Store>;
521
- tina?: never;
522
- } | {
523
- /**
524
- * Use Git-backed assets for media, these values will
525
- * [Learn more](https://tina.io/docs/reference/media/repo-based/)
526
- */
527
- tina: {
528
- /**
529
- * The folder where your application stores assets, eg. `"public"`
530
- */
531
- publicFolder: string;
532
- /**
533
- * The root folder for media managed by Tina. For example, `"uploads"`
534
- * would store content in `"<my-public-folder>/uploads"`
535
- */
536
- mediaRoot: string;
537
- };
538
- loadCustomStore?: never;
539
- };
540
- /**
541
- * Used to override the default Tina Cloud API URL
542
- *
543
- * [mostly for internal use only]
544
- */
545
- tinaioConfig?: {
546
- assetsApiUrlOverride?: string;
547
- frontendUrlOverride?: string;
548
- identityApiUrlOverride?: string;
549
- contentApiUrlOverride?: string;
550
- };
551
- cmsCallback?: CMSCallback;
552
- formifyCallback?: FormifyCallback;
553
- documentCreatorCallback?: DocumentCreatorCallback;
554
- }
555
- export declare type TinaCMSConfig<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> = Config<CMSCallback, FormifyCallback, DocumentCreatorCallback, Store>;
556
- export {};
package/dist/types.es.js DELETED
@@ -1 +0,0 @@
1
-
package/dist/types.js DELETED
@@ -1,5 +0,0 @@
1
- (function(factory) {
2
- typeof define === "function" && define.amd ? define(factory) : factory();
3
- })(function() {
4
- "use strict";
5
- });