@tinacms/schema-tools 0.0.0-00d7b85-20251222014449

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.
@@ -0,0 +1,971 @@
1
+ import type { FC } from 'react';
2
+ import type React from 'react';
3
+ export declare const CONTENT_FORMATS: readonly ["mdx", "md", "markdown", "json", "yaml", "yml", "toml"];
4
+ export type ContentFormat = (typeof CONTENT_FORMATS)[number];
5
+ export type ContentFrontmatterFormat = 'yaml' | 'toml' | 'json';
6
+ export type Parser = {
7
+ type: 'mdx';
8
+ } | {
9
+ type: 'markdown';
10
+ /**
11
+ * Tina will escape entities like `<` and `[` by default. You can choose to turn
12
+ * off all escaping, or specify HTML, so `<div>` will not be turned into `\<div>`
13
+ */
14
+ skipEscaping?: 'all' | 'html' | 'none';
15
+ } | {
16
+ /**
17
+ * Experimental: Returns the native Slate.js document as JSON. Ideal to retain the pure editor content structure.
18
+ */
19
+ type: 'slatejson';
20
+ };
21
+ type Meta = {
22
+ active?: boolean;
23
+ dirty?: boolean;
24
+ error?: any;
25
+ };
26
+ type FilterValue = string[] | string;
27
+ type Component<Type, List> = (props: {
28
+ field: TinaField & {
29
+ namespace: string[];
30
+ };
31
+ input: {
32
+ /**
33
+ * The full name of the field, for fields nested inside object
34
+ * fields, this will be the full path:
35
+ *
36
+ * `myObject.0.title`
37
+ */
38
+ name: string;
39
+ onBlur: (event?: React.FocusEvent<Type>) => void;
40
+ /**
41
+ * The value provided will be saved to the form so it
42
+ * should match the configured type:
43
+ *
44
+ * `input.onChange('some string')`
45
+ */
46
+ onChange: (event: React.ChangeEvent<Type>) => void;
47
+ onFocus: (event?: React.FocusEvent<Type>) => void;
48
+ type?: string;
49
+ value: List extends true ? Type[] : Type;
50
+ };
51
+ meta: Meta;
52
+ }) => any;
53
+ export type UIField<Type, List extends boolean> = {
54
+ max?: List extends true ? number : never;
55
+ min?: List extends true ? number : never;
56
+ /**
57
+ * Override the label from parent object
58
+ */
59
+ label?: string;
60
+ /**
61
+ * Override the description from parent object
62
+ */
63
+ description?: string;
64
+ /**
65
+ * A React component which will be used in the Tina form. Be sure
66
+ * to import React into the config file.
67
+ *
68
+ * Note: Any Tailwind classes provided here will be compiled as part
69
+ * of the Tina stylesheet
70
+ *
71
+ * eg:
72
+ * ```tsx
73
+ * component: (props) => {
74
+ * const { input, field } = props
75
+ * return (
76
+ * <div className="my-4">
77
+ * <label
78
+ * htmlFor={input.name}
79
+ * className="block text-sm font-medium"
80
+ * >
81
+ * {field.name}
82
+ * </label>
83
+ * <div className="mt-1">
84
+ * <input
85
+ * id={input.name}
86
+ * className="py-2 px-4 block"
87
+ * type="text"
88
+ * {...input}
89
+ * />
90
+ * </div>
91
+ * </div>
92
+ * )
93
+ * }
94
+ * ```
95
+ *
96
+ * Note: If the form has already been registered with the cms, you
97
+ * can provide it's name here (eg. `textarea`)
98
+ */
99
+ component?: Component<Type, List> | string | null;
100
+ /**
101
+ * Optional: Prepare data for use in the component. This is useful
102
+ * if you don't have access to the component directly
103
+ */
104
+ parse?: (value: List extends true ? Type[] : Type, name: string, field: Field) => List extends true ? Type[] : Type;
105
+ /**
106
+ * Optional: Prepare data for saving. This is useful
107
+ * if you don't have access to the component directly
108
+ */
109
+ format?: (value: Type, name: string, field: Field) => List extends true ? Type[] : Type;
110
+ /**
111
+ * Optional: Return undefined when valid. Return a string or an object when there are errors.
112
+ *
113
+ * ```ts
114
+ * validate: (value) => {
115
+ * if(value.length > 40){
116
+ * return 'Title cannot be more than 40 characters long'
117
+ * }
118
+ * }
119
+ * ```
120
+ */
121
+ validate?(value: List extends true ? Type[] : Type, allValues: {
122
+ [key: string]: any;
123
+ }, meta: Meta, field: UIField<Type, List>): string | undefined | void;
124
+ /**
125
+ * @deprecated use `defaultItem` at the collection level instead
126
+ */
127
+ defaultValue?: List extends true ? Type[] : Type;
128
+ /**
129
+ * The color format for the color picker component.
130
+ * Can be 'hex' or 'rgb'.
131
+ */
132
+ colorFormat?: 'hex' | 'rgb';
133
+ /**
134
+ * The widget style for the color picker component.
135
+ * Can be 'sketch' or 'block'.
136
+ */
137
+ widget?: 'sketch' | 'block';
138
+ /**
139
+ * The width of the color picker component.
140
+ * Accepts CSS width values (e.g., '350px').
141
+ */
142
+ width?: string;
143
+ /**
144
+ * Preset colors for the color picker component.
145
+ * An array of color strings (e.g., ['#D0021B', '#F5A623']).
146
+ */
147
+ colors?: string[];
148
+ };
149
+ type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
150
+ list: true;
151
+ ui?: UIField<Type, true> & ExtraFieldUIProps;
152
+ /**
153
+ * Defines where new items will be added in the list.
154
+ * If not specified, defaults to `append`.
155
+ */
156
+ addItemBehavior?: 'append' | 'prepend';
157
+ } : List extends false ? {
158
+ list?: false;
159
+ ui?: UIField<Type, false> & ExtraFieldUIProps;
160
+ } : {
161
+ list?: undefined;
162
+ ui?: UIField<Type, false> & ExtraFieldUIProps;
163
+ };
164
+ type SearchableTextField = {
165
+ maxSearchIndexFieldLength?: number;
166
+ };
167
+ export interface BaseField {
168
+ label?: string | boolean;
169
+ required?: boolean;
170
+ indexed?: boolean;
171
+ name: string;
172
+ nameOverride?: string;
173
+ description?: string;
174
+ searchable?: boolean;
175
+ uid?: boolean;
176
+ }
177
+ export type StringField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & SearchableTextField & {
178
+ type: 'string';
179
+ isTitle?: boolean;
180
+ isBody?: boolean;
181
+ options?: Option[];
182
+ };
183
+ export type NumberField = (FieldGeneric<number, undefined> | FieldGeneric<number, true> | FieldGeneric<number, false>) & BaseField & {
184
+ type: 'number';
185
+ };
186
+ export type BooleanField = (FieldGeneric<boolean, undefined> | FieldGeneric<boolean, true> | FieldGeneric<boolean, false>) & BaseField & {
187
+ type: 'boolean';
188
+ };
189
+ type DateFormatProps = {
190
+ /**
191
+ * Customize the way the format is rendered
192
+ * ```
193
+ * dateFormat: 'YYYY MM DD'
194
+ * ```
195
+ */
196
+ dateFormat?: string | boolean;
197
+ timeFormat?: string | boolean;
198
+ };
199
+ export type DateTimeField = (FieldGeneric<string, undefined, DateFormatProps> | FieldGeneric<string, true, DateFormatProps> | FieldGeneric<string, false, DateFormatProps>) & BaseField & {
200
+ type: 'datetime';
201
+ };
202
+ export type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
203
+ type: 'image';
204
+ /**
205
+ * A function that returns the upload directory path based on the form values.
206
+ * This is used to organize uploaded images into specific folders.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * uploadDir: (formValues) => `uploads/${formValues.category}`
211
+ * ```
212
+ */
213
+ uploadDir?: (formValues: Record<string, any>) => string;
214
+ };
215
+ type ReferenceFieldOptions = {
216
+ optionComponent?: OptionComponent;
217
+ /**
218
+ * @deprecated use `collectionFilter` instead as experimental___Filter will be removed in a future release
219
+ */
220
+ experimental___filter?: (list: Array<any>, searchQuery: string) => Array<any>;
221
+ collectionFilter?: Record<string, Record<string, FilterValue>> | (() => Record<string, Record<string, FilterValue>>);
222
+ };
223
+ type OptionComponent<P = Record<string, unknown>, S = Document['_sys']> = (props: P, _internalSys: S) => React.ReactNode | Element | undefined;
224
+ export type ReferenceField = (FieldGeneric<string, undefined, ReferenceFieldOptions> | FieldGeneric<string, false, ReferenceFieldOptions>) & BaseField & {
225
+ type: 'reference';
226
+ /**
227
+ * The names of the collections this field can use as a reference
228
+ * ```ts
229
+ * {
230
+ * type: 'reference',
231
+ * name: 'author',
232
+ * collections: ['author'],
233
+ * }
234
+ * ```
235
+ */
236
+ collections: string[];
237
+ };
238
+ export type PasswordField = (FieldGeneric<string, undefined> | FieldGeneric<string, false>) & BaseField & {
239
+ type: 'password';
240
+ };
241
+ type ToolbarOverrideType = 'heading' | 'link' | 'image' | 'quote' | 'ul' | 'ol' | 'code' | 'codeBlock' | 'bold' | 'italic' | 'raw' | 'embed' | 'mermaid' | 'table';
242
+ type RichTextAst = {
243
+ type: 'root';
244
+ children: Record<string, unknown>[];
245
+ };
246
+ export type RichTextField<WithNamespace extends boolean = false> = (FieldGeneric<RichTextAst, undefined> | FieldGeneric<RichTextAst, false>) & BaseField & SearchableTextField & {
247
+ type: 'rich-text';
248
+ /**
249
+ * When using Markdown or MDX formats, this field's value
250
+ * will be saved to the markdown body, while all other values
251
+ * will be stored as frontmatter
252
+ */
253
+ isBody?: boolean;
254
+ /**@deprecated use overrides.toolbar */
255
+ toolbarOverride?: ToolbarOverrideType[];
256
+ templates?: RichTextTemplate<WithNamespace>[];
257
+ overrides?: {
258
+ toolbar?: ToolbarOverrideType[];
259
+ /**Default set to true */
260
+ showFloatingToolbar?: boolean;
261
+ };
262
+ /**
263
+ * By default, Tina parses markdown with MDX, this is a more strict parser
264
+ * that allows you to use structured content inside markdown (via `templates`).
265
+ *
266
+ * Specify `"markdown"` if you're having problems with Tina parsing your content.
267
+ */
268
+ parser?: Parser;
269
+ };
270
+ export type RichTextTemplate<WithNamespace extends boolean = false> = Template<WithNamespace> & {
271
+ inline?: boolean;
272
+ /**
273
+ * If you have some custom shortcode logic in your markdown,
274
+ * you can specify it in the 'match' property and Tina will
275
+ * handle it as if it were a jsx element:
276
+ *
277
+ * ```
278
+ * # This is my markdown, it uses some custom shortcode
279
+ * syntax {{ myshortcode title="hello!" }}.
280
+ *
281
+ * {
282
+ * match: {
283
+ * start: "{{"
284
+ * end: "}}"
285
+ * }
286
+ * }
287
+ * ```
288
+ */
289
+ match?: {
290
+ start: string;
291
+ end: string;
292
+ name?: string;
293
+ };
294
+ };
295
+ type ObjectUiProps = {
296
+ visualSelector?: boolean;
297
+ };
298
+ export type ObjectField<WithNamespace extends boolean = false> = (FieldGeneric<string, undefined, ObjectUiProps> | FieldGeneric<string, true, ObjectUiProps> | FieldGeneric<string, false, ObjectUiProps>) & MaybeNamespace<WithNamespace> & BaseField & ({
299
+ type: 'object';
300
+ fields: Field<WithNamespace>[];
301
+ templates?: undefined;
302
+ ui?: Template['ui'];
303
+ } | {
304
+ type: 'object';
305
+ fields?: undefined;
306
+ templates: Template<WithNamespace>[];
307
+ templateKey?: string;
308
+ });
309
+ type Field<WithNamespace extends boolean = false> = (StringField | NumberField | BooleanField | DateTimeField | ImageField | ReferenceField | RichTextField<WithNamespace> | ObjectField<WithNamespace> | PasswordField) & MaybeNamespace<WithNamespace>;
310
+ export type TinaField<WithNamespace extends boolean = false> = Field<WithNamespace> & MaybeNamespace<WithNamespace>;
311
+ type MaybeNamespace<WithNamespace extends boolean = false> = WithNamespace extends true ? {
312
+ namespace: string[];
313
+ } : {};
314
+ export type Template<WithNamespace extends boolean = false> = {
315
+ label?: string | boolean;
316
+ name: string;
317
+ nameOverride?: string;
318
+ ui?: {
319
+ /**
320
+ * Override the properties passed to the field
321
+ * component. This is mostly useful for controlling
322
+ * the display value via callback on `itemProps.label`
323
+ */
324
+ itemProps?(item: Record<string, any>): {
325
+ key?: string;
326
+ /**
327
+ * Control the display value when object
328
+ * items are shown in a compact list, eg:
329
+ *
330
+ * ```ts
331
+ * itemProps: (values) => ({
332
+ * label: values?.title || 'Showcase Item',
333
+ * }),
334
+ * ```
335
+ */
336
+ label?: string | boolean;
337
+ };
338
+ defaultItem?: DefaultItem<Record<string, any>>;
339
+ /**
340
+ * When used in relation to the `visualSelector`,
341
+ * provide an image URL to be used as the preview
342
+ * in the blocks selector menu
343
+ */
344
+ previewSrc?: string;
345
+ };
346
+ fields: Field<WithNamespace>[];
347
+ } & MaybeNamespace<WithNamespace>;
348
+ type TokenObject = {
349
+ id_token: string;
350
+ access_token?: string;
351
+ refresh_token?: string;
352
+ };
353
+ export type LoginStrategy = 'UsernamePassword' | 'Redirect' | 'LoginScreen';
354
+ export type LoginScreenProps = {
355
+ handleAuthenticate: (props?: Record<string, string>) => Promise<void>;
356
+ };
357
+ export interface AuthProvider {
358
+ /**
359
+ * Used for getting the token from the custom auth provider
360
+ *
361
+ * @returns {Promise<TokenObject | null>}
362
+ **/
363
+ getToken: () => Promise<TokenObject | null>;
364
+ /**
365
+ * Used to logout from the custom auth provider
366
+ *
367
+ **/
368
+ logout: () => Promise<void>;
369
+ /**
370
+ * 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.
371
+ *
372
+ * If this returns a falsy value, the user will be logged out and the CMS will be disabled.
373
+ *
374
+ **/
375
+ getUser: () => Promise<any | null | boolean>;
376
+ /**
377
+ * Used to authorize the user with the custom auth provider.
378
+ *
379
+ * If this returns a truthy value, the user will be logged in and the CMS will be enabled.
380
+ *
381
+ * If not provided, the existence of a user will be enough to authorize the user.
382
+ *
383
+ * @param context
384
+ */
385
+ authorize: (context?: any) => Promise<any | null>;
386
+ /**
387
+ * Used to authenticate the user with the custom auth provider. This is called when the user clicks the login button.
388
+ *
389
+ **/
390
+ authenticate: (props?: Record<string, any>) => Promise<any | null>;
391
+ fetchWithToken: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
392
+ isAuthorized: (context?: any) => Promise<boolean>;
393
+ isAuthenticated: () => Promise<boolean>;
394
+ getLoginStrategy: () => LoginStrategy;
395
+ getLoginScreen: () => FC<LoginScreenProps> | null;
396
+ getSessionProvider: () => FC<{
397
+ basePath?: string;
398
+ children?: React.ReactNode;
399
+ }>;
400
+ }
401
+ interface AuthHooks {
402
+ onLogin?: (args: {
403
+ token: TokenObject;
404
+ }) => Promise<void>;
405
+ onLogout?: () => Promise<void>;
406
+ }
407
+ type AuthOptions = AuthHooks & AuthProvider;
408
+ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined, SearchClient = undefined> {
409
+ contentApiUrlOverride?: string;
410
+ authProvider?: AuthProvider;
411
+ admin?: {
412
+ /**
413
+ * @deprecated use `authProvider`and admin.authHooks instead
414
+ */
415
+ auth?: AuthOptions;
416
+ /**
417
+ * Hook functions that can be used to run logic when certain events happen
418
+ */
419
+ authHooks?: AuthHooks;
420
+ };
421
+ /**
422
+ * The Schema is used to define the shape of the content.
423
+ *
424
+ * https://tina.io/docs/r/the-config-file/
425
+ */
426
+ schema: Schema;
427
+ /**
428
+ * The base branch to pull content from.
429
+ *
430
+ * Note: This is ignored and not needed for local development or when self-hosting
431
+ */
432
+ branch?: string | null;
433
+ /**
434
+ * Your clientId from app.tina.io
435
+ *
436
+ * Note: This is ignored and not needed for local development or when self-hosting
437
+ */
438
+ clientId?: string | null;
439
+ /**
440
+ * Your read only token from app.tina.io
441
+ *
442
+ * Note: This is ignored and not needed for local development or when self-hosting
443
+ */
444
+ token?: string | null;
445
+ ui?: {
446
+ /**
447
+ * When using TinaCloud's branching feature, provide the URL for your given branch
448
+ *
449
+ * Eg. If you're deplying to Vercel, and your repo name is 'my-app',
450
+ * Vercel's preview URL would be based on the branch:
451
+ *
452
+ * ```js
453
+ * previewUrl: (context) => {
454
+ * const repoName = 'my-app'
455
+ * // `https://<project-name>-git-<branch-name>.vercel.app`
456
+ * return { url: `https://my-app-git-${context.branch}` }
457
+ * }
458
+ * ```
459
+ * [more info](https://vercel.com/docs/concepts/deployments/generated-urls#url-with-git-branch)
460
+ */
461
+ previewUrl?: (context: {
462
+ branch: string;
463
+ }) => {
464
+ url: string;
465
+ };
466
+ /**
467
+ * Opt out of update checks - this will prevent the CMS for checking for new versions
468
+ * If true, the CMS will not check for updates.
469
+ * Defaults to false if not specified.
470
+ */
471
+ optOutOfUpdateCheck?: boolean;
472
+ /**
473
+ * Regular expression pattern that folder names must match when creating new folders.
474
+ * Only applies to newly created folders, not existing ones.
475
+ *
476
+ * @example "^[a-z0-9-]+$" - allows lowercase letters, numbers, and hyphens only
477
+ * @example "^[A-Za-z0-9_-]+$" - allows letters, numbers, underscores, and hyphens
478
+ */
479
+ regexValidation?: {
480
+ folderNameRegex?: string;
481
+ };
482
+ };
483
+ /**
484
+ * Configurations for the autogenerated GraphQL HTTP client
485
+ */
486
+ client?: {
487
+ /**
488
+ * Skip building the autogenerated client
489
+ */
490
+ skip?: boolean;
491
+ /**
492
+ * Autogenerated queries will traverse references to a given depth
493
+ * @default 2
494
+ */
495
+ referenceDepth?: number;
496
+ /**
497
+ * Determines how the client will handle errors. If it is set to `throw` the client will throw an error when a query fails. If it is set to `include` the client will return the error in the response.
498
+ *
499
+ * @default 'throw'
500
+ */
501
+ errorPolicy?: 'throw' | 'include';
502
+ };
503
+ /**
504
+ *
505
+ * Tina supports serving content from a separate Git repo. To enable this during local development, point
506
+ * this config at the root of the content repo.
507
+ *
508
+ * 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
509
+ * location to the path.
510
+ *
511
+ * ```ts
512
+ * localContentPath: process.env.REMOTE_ROOT_PATH // eg. '../../my-content-repo'
513
+ * ```
514
+ */
515
+ localContentPath?: string;
516
+ /**
517
+ * Tina is compiled as a single-page app and placed in the public directory
518
+ * of your application.
519
+ */
520
+ build: {
521
+ /**
522
+ * The folder where your application stores assets, eg. `"public"`
523
+ */
524
+ publicFolder: string;
525
+ /**
526
+ * The value specified here will determine the path when visiting the TinaCMS dashboard.
527
+ *
528
+ * Eg. `"admin"` will be viewable at `[your-development-url]/admin/index.html`
529
+ *
530
+ * 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)
531
+ */
532
+ outputFolder: string;
533
+ /**
534
+ * The host option for the vite config. This is useful when trying to run tinacms dev in a docker container.
535
+ *
536
+ * See https://vitejs.dev/config/server-options.html#server-host for more details
537
+ */
538
+ host?: string | boolean;
539
+ /**
540
+ * If your site will be served at a sub-path like `my-domain.com/my-site`, provide `"my-site"`
541
+ */
542
+ basePath?: string;
543
+ };
544
+ media?: {
545
+ /**
546
+ * Load a media store like Cloudinary
547
+ *
548
+ * ```ts
549
+ * loadCustomStore = async () => {
550
+ * const pack = await import("next-tinacms-cloudinary");
551
+ * return pack.TinaCloudCloudinaryMediaStore;
552
+ * }
553
+ * ```
554
+ */
555
+ loadCustomStore: () => Promise<Store>;
556
+ tina?: never;
557
+ accept?: string | string[];
558
+ } | {
559
+ /**
560
+ * Use Git-backed assets for media, these values will
561
+ * [Learn more](https://tina.io/docs/r/repo-based-media/)
562
+ */
563
+ tina: {
564
+ /**
565
+ * The folder where your application stores assets, eg. `"public"`
566
+ */
567
+ publicFolder: string;
568
+ /**
569
+ * The root folder for media managed by Tina. For example, `"uploads"`
570
+ * would store content in `"<my-public-folder>/uploads"`
571
+ */
572
+ mediaRoot: string;
573
+ /**
574
+ * Indicates that media files cannot be uploaded or removed by editors
575
+ */
576
+ static?: boolean;
577
+ };
578
+ loadCustomStore?: never;
579
+ accept?: string | string[];
580
+ };
581
+ /**
582
+ * Configuration for repository-related UI features.
583
+ *
584
+ * This allows you to configure how the CMS displays repository information
585
+ * and generates links to view file history in your Git provider (e.g., GitHub, GitLab).
586
+ *
587
+ * @example
588
+ *
589
+ * repoProvider: {
590
+ * defaultBranchName: 'main',
591
+ * historyUrl: ({ relativePath, branch }) => ({
592
+ * url: `https://github.com/owner/repo/commits/${branch}/${relativePath}`
593
+ * })
594
+ * }
595
+ * */
596
+ repoProvider?: {
597
+ /**
598
+ * The default branch name to use when in local mode or when no branch is specified.
599
+ * When not in local mode, TinaCMS will use the branch selected in the editor.
600
+ *
601
+ * This is typically your main/master branch name (e.g., "main", "master").
602
+ */
603
+ defaultBranchName?: string;
604
+ /**
605
+ * A function that generates a URL to view the commit history for a specific file.
606
+ *
607
+ * This URL is used to link to your Git provider's history view (e.g., GitHub's commits page).
608
+ * The function receives the file's relative path and current branch, and should return
609
+ * a URL object with the full URL to the history page.
610
+ *
611
+ * @param context - Context object containing file and branch information
612
+ * @param context.relativePath - The relative path of the file from the repository root
613
+ * @param context.branch - The current branch name
614
+ * @returns An object with a `url` property containing the full URL to the history page
615
+ *
616
+ * @example
617
+ *s
618
+ * historyUrl: ({ relativePath, branch }) => ({
619
+ * url: `https://github.com/tinacms/tinacms/commits/${branch}/examples/next-2024/${relativePath}`
620
+ * })
621
+ * */
622
+ historyUrl?: (context: {
623
+ relativePath: string;
624
+ branch: string;
625
+ }) => {
626
+ url: string;
627
+ };
628
+ };
629
+ search?: ({
630
+ /**
631
+ * An instance of a search client like Algolia
632
+ */
633
+ searchClient: SearchClient;
634
+ tina?: never;
635
+ } | {
636
+ searchClient?: never;
637
+ /**
638
+ * Use the TinaCloud search index
639
+ */
640
+ tina: {
641
+ /**
642
+ * Search index token with permissions to write to search index. Only used by CLI.
643
+ */
644
+ indexerToken?: string;
645
+ /**
646
+ * stopword languages to use (default: eng)
647
+ */
648
+ stopwordLanguages?: string[];
649
+ /**
650
+ * regex used for splitting tokens (default: /[\p{L}\d_]+/)
651
+ */
652
+ tokenSplitRegex?: string;
653
+ /**
654
+ * Enable fuzzy search by default (default: true)
655
+ */
656
+ fuzzyEnabled?: boolean;
657
+ /**
658
+ * Fuzzy search options
659
+ */
660
+ fuzzyOptions?: {
661
+ /** Maximum edit distance for fuzzy matching (default: 2) */
662
+ maxDistance?: number;
663
+ /** Minimum similarity score 0-1 for matches (default: 0.6) */
664
+ minSimilarity?: number;
665
+ /** Maximum number of fuzzy matches to return per term (default: 10) */
666
+ maxResults?: number;
667
+ /** Use Damerau-Levenshtein (allows transpositions) (default: true) */
668
+ useTranspositions?: boolean;
669
+ /** Case sensitive matching (default: false) */
670
+ caseSensitive?: boolean;
671
+ };
672
+ };
673
+ }) & {
674
+ /**
675
+ * The number of documents to index per PUT request
676
+ */
677
+ indexBatchSize?: number;
678
+ /**
679
+ * The maximum length of a string field that will be indexed for search
680
+ */
681
+ maxSearchIndexFieldLength?: number;
682
+ };
683
+ /**
684
+ * Used to override the default TinaCloud API URL
685
+ *
686
+ * [mostly for internal use only]
687
+ */
688
+ tinaioConfig?: {
689
+ assetsApiUrlOverride?: string;
690
+ frontendUrlOverride?: string;
691
+ identityApiUrlOverride?: string;
692
+ contentApiUrlOverride?: string;
693
+ };
694
+ cmsCallback?: CMSCallback;
695
+ formifyCallback?: FormifyCallback;
696
+ documentCreatorCallback?: DocumentCreatorCallback;
697
+ }
698
+ export type TinaCMSConfig<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> = Config<CMSCallback, FormifyCallback, DocumentCreatorCallback, Store>;
699
+ export interface Schema<WithNamespace extends boolean = false> {
700
+ /**
701
+ * 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).
702
+ *
703
+ * https://tina.io/docs/r/content-modelling-collections/
704
+ */
705
+ collections: Collection<WithNamespace>[];
706
+ /**
707
+ * @deprecated use `defineConfig` in a config.{js,ts} file instead
708
+ */
709
+ config?: Config;
710
+ }
711
+ export type Collection<WithNamespace extends boolean = false> = FieldCollection<WithNamespace> | TemplateCollection<WithNamespace>;
712
+ interface BaseCollection {
713
+ label?: string;
714
+ name: string;
715
+ path: string;
716
+ indexes?: IndexType[];
717
+ format?: ContentFormat;
718
+ ui?: UICollection;
719
+ /**
720
+ * @deprecated - use `ui.defaultItem` on the each `template` instead
721
+ */
722
+ defaultItem?: DefaultItem<Record<string, any>>;
723
+ /**
724
+ * This format will be used to parse the markdown frontmatter
725
+ */
726
+ frontmatterFormat?: ContentFrontmatterFormat;
727
+ /**
728
+ * The delimiters used to parse the frontmatter.
729
+ */
730
+ frontmatterDelimiters?: [string, string] | string;
731
+ match?: {
732
+ include?: string;
733
+ exclude?: string;
734
+ };
735
+ isDetached?: boolean;
736
+ isAuthCollection?: boolean;
737
+ }
738
+ type TemplateCollection<WithNamespace extends boolean = false> = {
739
+ /**
740
+ * 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".
741
+ *
742
+ * https://tina.io/docs/r/content-modelling-templates/
743
+ */
744
+ templates: Template<WithNamespace>[];
745
+ fields?: undefined;
746
+ } & BaseCollection & MaybeNamespace<WithNamespace>;
747
+ type FieldCollection<WithNamespace extends boolean = false> = {
748
+ /**
749
+ * Fields define the shape of the content and the user input.
750
+ *
751
+ * https://tina.io/docs/r/string-fields/
752
+ */
753
+ fields: TinaField<WithNamespace>[];
754
+ templates?: undefined;
755
+ } & BaseCollection & MaybeNamespace<WithNamespace>;
756
+ type Document = {
757
+ _sys: {
758
+ title?: string;
759
+ template: string;
760
+ breadcrumbs: string[];
761
+ path: string;
762
+ basename: string;
763
+ relativePath: string;
764
+ filename: string;
765
+ extension: string;
766
+ hasReferences?: boolean;
767
+ };
768
+ };
769
+ export interface UICollection<Form = any, CMS = any, TinaForm = any> {
770
+ /**
771
+ * Customize the way filenames are generated during content creation
772
+ */
773
+ filename?: {
774
+ /**
775
+ * A callback which receives form values as an argument. The return value
776
+ * here will be used as the filename (the extension is not necessary)
777
+ *
778
+ * eg:
779
+ * ```ts
780
+ * slugify: (values) => values.title.toLowerCase().split(" ").join("-")
781
+ * ```
782
+ */
783
+ slugify?: (values: Record<string, any>, meta: {
784
+ collection: Collection;
785
+ template: Template;
786
+ }) => string;
787
+ /**
788
+ * When set to `true`, editors won't be able to modify the filename
789
+ */
790
+ readonly?: boolean;
791
+ /**
792
+ * When set to `true`, the filename will be shown first in the form
793
+ * @default false
794
+ */
795
+ showFirst?: boolean;
796
+ /**
797
+ * Sets the description for the filename field
798
+ */
799
+ description?: string;
800
+ };
801
+ /**
802
+ * Determines whether or not this collection can accept new docments
803
+ * or allow documents to be deleted from the CMS.
804
+ */
805
+ allowedActions?: {
806
+ create?: boolean;
807
+ delete?: boolean;
808
+ createFolder?: boolean;
809
+ createNestedFolder?: boolean;
810
+ };
811
+ /**
812
+ * Forms for this collection will be editable from the global sidebar rather than the form panel
813
+ */
814
+ global?: boolean | {
815
+ icon?: any;
816
+ layout: 'fullscreen' | 'popup';
817
+ };
818
+ /**
819
+ * Provide the path that your document is viewable on your site
820
+ *
821
+ * eg:
822
+ * ```ts
823
+ * router: ({ document }) => {
824
+ * return `blog-posts/${document._sys.filename}`;
825
+ * }
826
+ * ```
827
+ */
828
+ router?: (args: {
829
+ document: Document;
830
+ collection: Collection<true>;
831
+ }) => Promise<string | undefined> | string | undefined;
832
+ /**
833
+ * This function is called before a document is created or updated. It can be used to modify the values that are saved to the CMS. It can also be used to perform side effects such as sending a notification or triggering a build.
834
+ *
835
+ * @example
836
+ *
837
+ *
838
+ *```js
839
+ * beforeSubmit: async ({ values }) => {
840
+ * return {
841
+ * ...values,
842
+ * lastUpdated: new Date().toISOString(),
843
+ * };
844
+ * },
845
+ *```
846
+ *
847
+ *
848
+ *
849
+ */
850
+ beforeSubmit?: (arg: {
851
+ values: Record<string, unknown>;
852
+ cms: CMS;
853
+ form: TinaForm;
854
+ }) => Promise<void | Record<string, unknown>>;
855
+ }
856
+ export type DefaultItem<ReturnType> = ReturnType | (() => ReturnType);
857
+ type IndexType = {
858
+ name: string;
859
+ fields: {
860
+ name: string;
861
+ }[];
862
+ };
863
+ export type Option = string | {
864
+ label?: string;
865
+ icon?: FC;
866
+ value: string;
867
+ };
868
+ export type UITemplate = {
869
+ /**
870
+ * Override the properties passed to the field
871
+ * component. This is mostly useful for controlling
872
+ * the display value via callback on `itemProps.label`
873
+ */
874
+ itemProps?(item: Record<string, any>): {
875
+ key?: string;
876
+ /**
877
+ * Control the display value when object
878
+ * items are shown in a compact list, eg:
879
+ *
880
+ * ```ts
881
+ * itemProps: (values) => ({
882
+ * label: values?.title || 'Showcase Item',
883
+ * }),
884
+ * ```
885
+ */
886
+ label?: string | boolean;
887
+ };
888
+ defaultItem?: DefaultItem<Record<string, any>>;
889
+ /**
890
+ * When used in relation to the `visualSelector`,
891
+ * provide an image URL to be used as the preview
892
+ * in the blocks selector menu
893
+ */
894
+ previewSrc?: string;
895
+ };
896
+ export type CollectionTemplateableUnion = {
897
+ namespace: string[];
898
+ type: 'union';
899
+ templates: Template<true>[];
900
+ };
901
+ export type CollectionTemplateableObject = {
902
+ namespace: string[];
903
+ type: 'object';
904
+ visualSelector?: boolean;
905
+ ui?: UIField<any, any> & {
906
+ itemProps?(item: Record<string, any>): {
907
+ key?: string;
908
+ label?: string | boolean;
909
+ };
910
+ defaultItem?: DefaultItem<Record<string, any>>;
911
+ };
912
+ required?: false;
913
+ template: Template<true>;
914
+ };
915
+ export type CollectionTemplateable = CollectionTemplateableUnion | CollectionTemplateableObject;
916
+ export type Collectable = Pick<Collection<true>, 'namespace' | 'templates' | 'fields' | 'name'> & {
917
+ label?: string | boolean;
918
+ };
919
+ /**
920
+ * @deprecated use Config instead
921
+ */
922
+ export type TinaCloudSchemaConfig<DeleteMe = undefined> = Config;
923
+ /** @deprecated use Schema instead */
924
+ export type TinaCloudSchema<WithNamespace extends boolean = false> = Schema<WithNamespace>;
925
+ /** @deprecated use Schema instead */
926
+ export type TinaCloudSchemaBase = TinaCloudSchema;
927
+ /** @deprecated use Schema instead */
928
+ export type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
929
+ /** @deprecated use Schema instead */
930
+ export type TinaCloudSchemaWithNamespace = TinaCloudSchema<true>;
931
+ /** @deprecated use Collection instead */
932
+ export type TinaCloudCollection<WithNamespace extends boolean = false> = Collection<WithNamespace>;
933
+ /** @deprecated use Collection instead */
934
+ export type TinaCloudCollectionBase = TinaCloudCollection;
935
+ /** @deprecated use Collection instead */
936
+ export type TinaCloudCollectionEnriched = TinaCloudCollection<true>;
937
+ /** @deprecated use Template instead */
938
+ export type TinaTemplate = Template;
939
+ /** @deprecated use Template instead */
940
+ export type TinaCloudTemplateBase = Template;
941
+ /** @deprecated use Template instead */
942
+ export type TinaCloudTemplateEnriched = Template<true>;
943
+ /** @deprecated use Collection instead */
944
+ export type CollectionFieldsWithNamespace = FieldCollection<true>;
945
+ /** @deprecated use Collection instead */
946
+ export type CollectionTemplates = TemplateCollection;
947
+ /** @deprecated use Collection instead */
948
+ export type CollectionTemplatesWithNamespace = TemplateCollection<true>;
949
+ /** @deprecated use Template instead */
950
+ export type GlobalTemplate = Template;
951
+ /** @deprecated use TinaField instead */
952
+ export type TinaFieldBase = TinaField;
953
+ /** @deprecated use TinaField instead */
954
+ export type TinaFieldInner = TinaField;
955
+ /** @deprecated use TinaField instead */
956
+ export type TinaFieldEnriched = TinaField<true>;
957
+ /** @deprecated use ObjectField instead */
958
+ export type ObjectType<WithNamespace extends boolean = false> = ObjectField<WithNamespace>;
959
+ /** @deprecated use RichTextField instead */
960
+ export type RichTextType<WithNamespace extends boolean = false> = RichTextField<WithNamespace>;
961
+ /** @deprecated use ReferenceField instead */
962
+ export type ReferenceType<WithNamespace extends boolean = false> = ReferenceField & MaybeNamespace<WithNamespace>;
963
+ /** @deprecated use ReferenceField instead */
964
+ export type ReferenceTypeInner = ReferenceType;
965
+ /** @deprecated use ReferenceField instead */
966
+ export type ReferenceTypeWithNamespace = ReferenceType<true>;
967
+ /** @deprecated use RichTextField instead */
968
+ export type RichTypeWithNamespace = RichTextField<true>;
969
+ /** @deprecated use TinaField instead */
970
+ export type SchemaField<WithNamespace extends boolean = false> = TinaField<WithNamespace>;
971
+ export {};