@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/index.es.js +36 -35
- package/dist/index.js +36 -35
- package/dist/schema/TinaSchema.d.ts +11 -21
- package/dist/schema/resolveField.d.ts +3 -9
- package/dist/schema/resolveForm.d.ts +152 -2
- package/dist/types/index.d.ts +666 -5
- package/dist/validate/fields.d.ts +2 -2
- package/dist/validate/index.d.ts +3 -7
- package/dist/validate/schema.d.ts +57 -32
- package/dist/validate/tinaCloudSchemaConfig.d.ts +2 -2
- package/package.json +2 -10
- package/dist/types/SchemaTypes.d.ts +0 -475
- package/dist/types/config.d.ts +0 -40
- package/dist/types/schema2.d.ts +0 -127
- package/dist/types/types2.d.ts +0 -445
- package/dist/types.d.ts +0 -556
- package/dist/types.es.js +0 -1
- package/dist/types.js +0 -5
package/dist/types/types2.d.ts
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export interface UICollection {
|
|
8
|
-
/**
|
|
9
|
-
* Customize the way filenames are generated during content creation
|
|
10
|
-
*/
|
|
11
|
-
filename?: {
|
|
12
|
-
/**
|
|
13
|
-
* A callback which receives form values as an argument. The return value
|
|
14
|
-
* here will be used as the filename (the extension is not necessary)
|
|
15
|
-
*
|
|
16
|
-
* eg:
|
|
17
|
-
* ```ts
|
|
18
|
-
* slugify: (values) => values.title.toLowerCase().split(" ").join("-")
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
slugify?: (values: Record<string, any>) => string;
|
|
22
|
-
/**
|
|
23
|
-
* When set to `true`, editors won't be able to modify the filename
|
|
24
|
-
*/
|
|
25
|
-
readonly?: boolean;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Forms for this collection will be editable from the global sidebar rather than the form panel
|
|
29
|
-
*/
|
|
30
|
-
global?: boolean | {
|
|
31
|
-
icon?: any;
|
|
32
|
-
layout: 'fullscreen' | 'popup';
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Provide the path that your document is viewable on your site
|
|
36
|
-
*
|
|
37
|
-
* eg:
|
|
38
|
-
* ```ts
|
|
39
|
-
* router: ({ document }) => {
|
|
40
|
-
* return `blog-posts/${document._sys.filename}`;
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
router?: (args: {
|
|
45
|
-
document: Document;
|
|
46
|
-
collection: Collection;
|
|
47
|
-
}) => string | undefined;
|
|
48
|
-
}
|
|
49
|
-
export declare type Option = string | {
|
|
50
|
-
label: string;
|
|
51
|
-
value: string;
|
|
52
|
-
};
|
|
53
|
-
import type React from 'react';
|
|
54
|
-
declare type Meta = {
|
|
55
|
-
active?: boolean;
|
|
56
|
-
dirty?: boolean;
|
|
57
|
-
error?: any;
|
|
58
|
-
};
|
|
59
|
-
declare type Component<Type, List> = (props: {
|
|
60
|
-
field: SchemaField & {
|
|
61
|
-
namespace: string[];
|
|
62
|
-
};
|
|
63
|
-
input: {
|
|
64
|
-
/**
|
|
65
|
-
* The full name of the field, for fields nested inside object
|
|
66
|
-
* fields, this will be the full path:
|
|
67
|
-
*
|
|
68
|
-
* `myObject.0.title`
|
|
69
|
-
*/
|
|
70
|
-
name: string;
|
|
71
|
-
onBlur: (event?: React.FocusEvent<Type>) => void;
|
|
72
|
-
/**
|
|
73
|
-
* The value provided will be saved to the form so it
|
|
74
|
-
* should match the configured type:
|
|
75
|
-
*
|
|
76
|
-
* `input.onChange('some string')`
|
|
77
|
-
*/
|
|
78
|
-
onChange: (event: React.ChangeEvent<Type>) => void;
|
|
79
|
-
onFocus: (event?: React.FocusEvent<Type>) => void;
|
|
80
|
-
type?: string;
|
|
81
|
-
value: List extends true ? Type[] : Type;
|
|
82
|
-
};
|
|
83
|
-
meta: Meta;
|
|
84
|
-
}) => any;
|
|
85
|
-
declare type UIField<Type, List extends boolean> = {
|
|
86
|
-
/**
|
|
87
|
-
* Override the label from parent object
|
|
88
|
-
*/
|
|
89
|
-
label?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Override the description from parent object
|
|
92
|
-
*/
|
|
93
|
-
description?: string;
|
|
94
|
-
/**
|
|
95
|
-
* A React component which will be used in the Tina form. Be sure
|
|
96
|
-
* to import React into the config file.
|
|
97
|
-
*
|
|
98
|
-
* Note: Any Tailwind classes provided here will be compiled as part
|
|
99
|
-
* of the Tina stylesheet
|
|
100
|
-
*
|
|
101
|
-
* eg:
|
|
102
|
-
* ```tsx
|
|
103
|
-
* component: (props) => {
|
|
104
|
-
* const { input, field } = props
|
|
105
|
-
* return (
|
|
106
|
-
* <div className="my-4">
|
|
107
|
-
* <label
|
|
108
|
-
* htmlFor={input.name}
|
|
109
|
-
* className="block text-sm font-medium"
|
|
110
|
-
* >
|
|
111
|
-
* {field.name}
|
|
112
|
-
* </label>
|
|
113
|
-
* <div className="mt-1">
|
|
114
|
-
* <input
|
|
115
|
-
* id={input.name}
|
|
116
|
-
* className="py-2 px-4 block"
|
|
117
|
-
* type="text"
|
|
118
|
-
* {...input}
|
|
119
|
-
* />
|
|
120
|
-
* </div>
|
|
121
|
-
* </div>
|
|
122
|
-
* )
|
|
123
|
-
* }
|
|
124
|
-
* ```
|
|
125
|
-
*
|
|
126
|
-
* Note: If the form has already been registered with the cms, you
|
|
127
|
-
* can provide it's name here (eg. `textarea`)
|
|
128
|
-
*/
|
|
129
|
-
component?: Component<Type, List> | string | null;
|
|
130
|
-
/**
|
|
131
|
-
* Optional: Prepare data for use in the component. This is useful
|
|
132
|
-
* if you don't have access to the component directly
|
|
133
|
-
*/
|
|
134
|
-
parse?: (value: List extends true ? Type[] : Type, name: string, field: Field) => List extends true ? Type[] : Type;
|
|
135
|
-
/**
|
|
136
|
-
* Optional: Prepare data for saving. This is useful
|
|
137
|
-
* if you don't have access to the component directly
|
|
138
|
-
*/
|
|
139
|
-
format?: (value: Type, name: string, field: Field) => List extends true ? Type[] : Type;
|
|
140
|
-
/**
|
|
141
|
-
* Optional: Return undefined when valid. Return a string or an object when there are errors.
|
|
142
|
-
*
|
|
143
|
-
* ```ts
|
|
144
|
-
* validate: (value) => {
|
|
145
|
-
* if(value.length > 40){
|
|
146
|
-
* return 'Title cannot be more than 40 characters long'
|
|
147
|
-
* }
|
|
148
|
-
* }
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
validate?(value: List extends true ? Type[] : Type, allValues: {
|
|
152
|
-
[key: string]: any;
|
|
153
|
-
}, meta: Meta, field: UIField<Type, List>): (List extends true ? Type[] : Type) | undefined | void;
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated use `defaultItem` at the collection level instead
|
|
156
|
-
*/
|
|
157
|
-
defaultValue?: List extends true ? Type[] : Type;
|
|
158
|
-
};
|
|
159
|
-
declare type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
|
|
160
|
-
list: true;
|
|
161
|
-
ui?: UIField<Type, true> & ExtraFieldUIProps;
|
|
162
|
-
} : List extends false ? {
|
|
163
|
-
list: false;
|
|
164
|
-
ui?: UIField<Type, false> & ExtraFieldUIProps;
|
|
165
|
-
} : {
|
|
166
|
-
list?: never;
|
|
167
|
-
ui?: UIField<Type, false> & ExtraFieldUIProps;
|
|
168
|
-
};
|
|
169
|
-
export interface BaseField {
|
|
170
|
-
label?: string;
|
|
171
|
-
required?: boolean;
|
|
172
|
-
name: string;
|
|
173
|
-
}
|
|
174
|
-
export declare type StringField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
175
|
-
type: 'string';
|
|
176
|
-
isTitle?: boolean;
|
|
177
|
-
options?: Option[];
|
|
178
|
-
};
|
|
179
|
-
export declare type NumberField = (FieldGeneric<number, undefined> | FieldGeneric<number, true> | FieldGeneric<number, false>) & BaseField & {
|
|
180
|
-
type: 'number';
|
|
181
|
-
};
|
|
182
|
-
export declare type BooleanField = (FieldGeneric<boolean, undefined> | FieldGeneric<boolean, true> | FieldGeneric<boolean, false>) & BaseField & {
|
|
183
|
-
type: 'boolean';
|
|
184
|
-
};
|
|
185
|
-
export declare type DateTimeField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
186
|
-
type: 'datetime';
|
|
187
|
-
};
|
|
188
|
-
export declare type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
189
|
-
type: 'image';
|
|
190
|
-
};
|
|
191
|
-
export declare type ReferenceField = (FieldGeneric<string, undefined> | FieldGeneric<string, false>) & BaseField & {
|
|
192
|
-
type: 'reference';
|
|
193
|
-
/**
|
|
194
|
-
* The names of the collections this field can use as a reference
|
|
195
|
-
* ```ts
|
|
196
|
-
* {
|
|
197
|
-
* type: 'reference',
|
|
198
|
-
* name: 'author',
|
|
199
|
-
* collections: ['author'],
|
|
200
|
-
* }
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
collections: string[];
|
|
204
|
-
};
|
|
205
|
-
declare type RichTextAst = {
|
|
206
|
-
type: 'root';
|
|
207
|
-
children: Record<string, unknown>[];
|
|
208
|
-
};
|
|
209
|
-
export declare type RichTextField = (FieldGeneric<RichTextAst, undefined> | FieldGeneric<RichTextAst, false>) & BaseField & {
|
|
210
|
-
type: 'rich-text';
|
|
211
|
-
/**
|
|
212
|
-
* When using Markdown or MDX formats, this field's value
|
|
213
|
-
* will be saved to the markdown body, while all other values
|
|
214
|
-
* will be stored as frontmatter
|
|
215
|
-
*/
|
|
216
|
-
isBody?: boolean;
|
|
217
|
-
templates?: (Template & {
|
|
218
|
-
inline?: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* If you have some custom shortcode logic in your markdown,
|
|
221
|
-
* you can specify it in the 'match' property and Tina will
|
|
222
|
-
* handle it as if it were a jsx element:
|
|
223
|
-
*
|
|
224
|
-
* ```
|
|
225
|
-
* # This is my markdown, it uses some custom shortcode
|
|
226
|
-
* syntax {{ myshortcode title="hello!" }}.
|
|
227
|
-
*
|
|
228
|
-
* {
|
|
229
|
-
* match: {
|
|
230
|
-
* start: "{{"
|
|
231
|
-
* end: "}}"
|
|
232
|
-
* }
|
|
233
|
-
* }
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
match?: {
|
|
237
|
-
start: string;
|
|
238
|
-
end: string;
|
|
239
|
-
name?: string;
|
|
240
|
-
};
|
|
241
|
-
})[];
|
|
242
|
-
};
|
|
243
|
-
declare type DefaultItem<ReturnType> = ReturnType | (() => ReturnType);
|
|
244
|
-
declare type ExtraFieldUIProps = {
|
|
245
|
-
/**
|
|
246
|
-
* Override the properties passed to the field
|
|
247
|
-
* component. This is mostly useful for controlling
|
|
248
|
-
* the display value via callback on `itemProps.label`
|
|
249
|
-
*/
|
|
250
|
-
itemProps?(item: Record<string, any>): {
|
|
251
|
-
key?: string;
|
|
252
|
-
/**
|
|
253
|
-
* Control the display value when object
|
|
254
|
-
* items are shown in a compact list, eg:
|
|
255
|
-
*
|
|
256
|
-
* ```ts
|
|
257
|
-
* itemProps: (values) => ({
|
|
258
|
-
* label: values?.title || 'Showcase Item',
|
|
259
|
-
* }),
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
label?: string;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* The value will be used when a new object is inserted, eg:
|
|
266
|
-
*
|
|
267
|
-
* ```ts
|
|
268
|
-
* {
|
|
269
|
-
* title: "My Headline",
|
|
270
|
-
* description: "Some description"
|
|
271
|
-
* }
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* Note: when supplying a value for a `rich-text` field, you must supply
|
|
275
|
-
* the the value as an object.
|
|
276
|
-
* ```ts
|
|
277
|
-
* {
|
|
278
|
-
* title: "My Headline",
|
|
279
|
-
* description: "Some description"
|
|
280
|
-
* // This is field a rich-text field
|
|
281
|
-
* body: {
|
|
282
|
-
* type: "root",
|
|
283
|
-
* children: [{
|
|
284
|
-
* type: "p",
|
|
285
|
-
* children: [{
|
|
286
|
-
* type: "text",
|
|
287
|
-
* value: "This is some placeholder text"
|
|
288
|
-
* }]
|
|
289
|
-
* }]
|
|
290
|
-
* }
|
|
291
|
-
* }
|
|
292
|
-
* ```
|
|
293
|
-
*
|
|
294
|
-
*/
|
|
295
|
-
defaultItem?: DefaultItem<Record<string, any>>;
|
|
296
|
-
};
|
|
297
|
-
export declare type ObjectField = (FieldGeneric<string, undefined> | FieldGeneric<string, true, ExtraFieldUIProps> | FieldGeneric<string, false>) & BaseField & ({
|
|
298
|
-
type: 'object';
|
|
299
|
-
fields: Field[];
|
|
300
|
-
templates?: undefined;
|
|
301
|
-
} | {
|
|
302
|
-
type: 'object';
|
|
303
|
-
fields?: undefined;
|
|
304
|
-
templates: Template[];
|
|
305
|
-
});
|
|
306
|
-
declare type Field = StringField | NumberField | BooleanField | DateTimeField | ImageField | ReferenceField | RichTextField | ObjectField;
|
|
307
|
-
declare type SchemaField = Field;
|
|
308
|
-
export type { SchemaField };
|
|
309
|
-
export interface Template {
|
|
310
|
-
label?: string;
|
|
311
|
-
name: string;
|
|
312
|
-
fields: Field[];
|
|
313
|
-
}
|
|
314
|
-
export interface FieldCollection {
|
|
315
|
-
label?: string;
|
|
316
|
-
name: string;
|
|
317
|
-
path: string;
|
|
318
|
-
format?: 'json' | 'md' | 'markdown' | 'mdx';
|
|
319
|
-
ui?: UICollection;
|
|
320
|
-
templates?: never;
|
|
321
|
-
/**
|
|
322
|
-
* Fields define the shape of the content and the user input.
|
|
323
|
-
*
|
|
324
|
-
* https://tina.io/docs/reference/fields/
|
|
325
|
-
*/
|
|
326
|
-
fields: Field[];
|
|
327
|
-
}
|
|
328
|
-
export interface TemplateCollection {
|
|
329
|
-
label?: string;
|
|
330
|
-
name: string;
|
|
331
|
-
path: string;
|
|
332
|
-
format?: 'json' | 'md' | 'markdown' | 'mdx';
|
|
333
|
-
ui?: UICollection;
|
|
334
|
-
/**
|
|
335
|
-
* 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".
|
|
336
|
-
*
|
|
337
|
-
* https://tina.io/docs/reference/templates/
|
|
338
|
-
*/
|
|
339
|
-
templates?: Template[];
|
|
340
|
-
fields?: never;
|
|
341
|
-
}
|
|
342
|
-
export declare type Collection = FieldCollection | TemplateCollection;
|
|
343
|
-
export interface Schema {
|
|
344
|
-
/**
|
|
345
|
-
* 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).
|
|
346
|
-
*
|
|
347
|
-
* https://tina.io/docs/reference/collections/
|
|
348
|
-
*/
|
|
349
|
-
collections: Collection[];
|
|
350
|
-
}
|
|
351
|
-
export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> {
|
|
352
|
-
/**
|
|
353
|
-
* The Schema is used to define the shape of the content.
|
|
354
|
-
*
|
|
355
|
-
* https://tina.io/docs/reference/schema/
|
|
356
|
-
*/
|
|
357
|
-
schema: Schema;
|
|
358
|
-
/**
|
|
359
|
-
* The base branch to pull content from. Note that this is ignored for local development
|
|
360
|
-
*/
|
|
361
|
-
branch: string | null;
|
|
362
|
-
/**
|
|
363
|
-
* Your clientId from app.tina.io
|
|
364
|
-
*/
|
|
365
|
-
clientId: string | null;
|
|
366
|
-
/**
|
|
367
|
-
* Your read only token from app.tina.io
|
|
368
|
-
*/
|
|
369
|
-
token: string | null;
|
|
370
|
-
/**
|
|
371
|
-
* Configurations for the autogenerated GraphQL HTTP client
|
|
372
|
-
*/
|
|
373
|
-
client?: {
|
|
374
|
-
/**
|
|
375
|
-
* Autogenerated queries will traverse references to a given depth
|
|
376
|
-
* @default 2
|
|
377
|
-
*/
|
|
378
|
-
referenceDepth?: number;
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Tina is compiled as a single-page app and placed in the public directory
|
|
382
|
-
* of your application.
|
|
383
|
-
*/
|
|
384
|
-
build: {
|
|
385
|
-
/**
|
|
386
|
-
* The folder where your application stores assets, eg. `"public"`
|
|
387
|
-
*/
|
|
388
|
-
publicFolder: string;
|
|
389
|
-
/**
|
|
390
|
-
* The value specified here will determine the path when visiting the TinaCMS dashboard.
|
|
391
|
-
*
|
|
392
|
-
* Eg. `"admin"` will be viewable at `[your-development-url]/admin/index.html`
|
|
393
|
-
*
|
|
394
|
-
* 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)
|
|
395
|
-
*/
|
|
396
|
-
outputFolder: string;
|
|
397
|
-
};
|
|
398
|
-
media?: {
|
|
399
|
-
/**
|
|
400
|
-
* Load a media store like Cloudinary
|
|
401
|
-
*
|
|
402
|
-
* ```ts
|
|
403
|
-
* loadCustomStore = async () => {
|
|
404
|
-
* const pack = await import("next-tinacms-cloudinary");
|
|
405
|
-
* return pack.TinaCloudCloudinaryMediaStore;
|
|
406
|
-
* }
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
loadCustomStore: () => Promise<Store>;
|
|
410
|
-
tina?: never;
|
|
411
|
-
} | {
|
|
412
|
-
/**
|
|
413
|
-
* Use Git-backed assets for media, these values will
|
|
414
|
-
* [Learn more](https://tina.io/docs/reference/media/repo-based/)
|
|
415
|
-
*/
|
|
416
|
-
tina: {
|
|
417
|
-
/**
|
|
418
|
-
* The folder where your application stores assets, eg. `"public"`
|
|
419
|
-
*/
|
|
420
|
-
publicFolder: string;
|
|
421
|
-
/**
|
|
422
|
-
* The root folder for media managed by Tina. For example, `"uploads"`
|
|
423
|
-
* would store content in `"<my-public-folder>/uploads"`
|
|
424
|
-
*/
|
|
425
|
-
mediaRoot: string;
|
|
426
|
-
};
|
|
427
|
-
loadCustomStore?: never;
|
|
428
|
-
};
|
|
429
|
-
/**
|
|
430
|
-
* Used to override the default Tina Cloud API URL
|
|
431
|
-
*
|
|
432
|
-
* [mostly for internal use only]
|
|
433
|
-
*/
|
|
434
|
-
tinaioConfig?: {
|
|
435
|
-
assetsApiUrlOverride?: string;
|
|
436
|
-
frontendUrlOverride?: string;
|
|
437
|
-
identityApiUrlOverride?: string;
|
|
438
|
-
contentApiUrlOverride?: string;
|
|
439
|
-
};
|
|
440
|
-
cmsCallback?: CMSCallback;
|
|
441
|
-
formifyCallback?: FormifyCallback;
|
|
442
|
-
documentCreatorCallback?: DocumentCreatorCallback;
|
|
443
|
-
}
|
|
444
|
-
export declare type TinaCMSConfig<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> = Config<CMSCallback, FormifyCallback, DocumentCreatorCallback, Store>;
|
|
445
|
-
export {};
|