@tinacms/schema-tools 0.0.0-c6915ea-20250421012527 → 0.0.0-c706b9f-20251222081038
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.d.ts +6 -1
- package/dist/index.js +2467 -2427
- package/dist/schema/resolveForm.d.ts +1 -1
- package/dist/types/index.d.ts +148 -21
- package/dist/util/normalizePath.d.ts +8 -0
- package/dist/validate/schema.d.ts +180 -15
- package/dist/validate/tinaCloudSchemaConfig.d.ts +105 -0
- package/package.json +6 -14
- package/dist/index.mjs +0 -2731
|
@@ -13,7 +13,7 @@ export declare const resolveForm: ({ collection, basename, template, schema, }:
|
|
|
13
13
|
fields: {
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
name: string;
|
|
16
|
-
component: NonNullable<import("
|
|
16
|
+
component: NonNullable<import("..").TinaField<true>["ui"]>["component"];
|
|
17
17
|
type: string;
|
|
18
18
|
}[];
|
|
19
19
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
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
|
+
};
|
|
3
21
|
type Meta = {
|
|
4
22
|
active?: boolean;
|
|
5
23
|
dirty?: boolean;
|
|
@@ -107,10 +125,35 @@ export type UIField<Type, List extends boolean> = {
|
|
|
107
125
|
* @deprecated use `defaultItem` at the collection level instead
|
|
108
126
|
*/
|
|
109
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[];
|
|
110
148
|
};
|
|
111
149
|
type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
|
|
112
150
|
list: true;
|
|
113
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';
|
|
114
157
|
} : List extends false ? {
|
|
115
158
|
list?: false;
|
|
116
159
|
ui?: UIField<Type, false> & ExtraFieldUIProps;
|
|
@@ -150,14 +193,24 @@ type DateFormatProps = {
|
|
|
150
193
|
* dateFormat: 'YYYY MM DD'
|
|
151
194
|
* ```
|
|
152
195
|
*/
|
|
153
|
-
dateFormat?: string;
|
|
154
|
-
timeFormat?: string;
|
|
196
|
+
dateFormat?: string | boolean;
|
|
197
|
+
timeFormat?: string | boolean;
|
|
155
198
|
};
|
|
156
199
|
export type DateTimeField = (FieldGeneric<string, undefined, DateFormatProps> | FieldGeneric<string, true, DateFormatProps> | FieldGeneric<string, false, DateFormatProps>) & BaseField & {
|
|
157
200
|
type: 'datetime';
|
|
158
201
|
};
|
|
159
202
|
export type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
160
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;
|
|
161
214
|
};
|
|
162
215
|
type ReferenceFieldOptions = {
|
|
163
216
|
optionComponent?: OptionComponent;
|
|
@@ -212,16 +265,7 @@ export type RichTextField<WithNamespace extends boolean = false> = (FieldGeneric
|
|
|
212
265
|
*
|
|
213
266
|
* Specify `"markdown"` if you're having problems with Tina parsing your content.
|
|
214
267
|
*/
|
|
215
|
-
parser?:
|
|
216
|
-
type: 'markdown';
|
|
217
|
-
/**
|
|
218
|
-
* Tina will escape entities like `<` and `[` by default. You can choose to turn
|
|
219
|
-
* off all escaping, or specify HTML, so `<div>` will not be turned into `\<div>`
|
|
220
|
-
*/
|
|
221
|
-
skipEscaping?: 'all' | 'html' | 'none';
|
|
222
|
-
} | {
|
|
223
|
-
type: 'mdx';
|
|
224
|
-
};
|
|
268
|
+
parser?: Parser;
|
|
225
269
|
};
|
|
226
270
|
export type RichTextTemplate<WithNamespace extends boolean = false> = Template<WithNamespace> & {
|
|
227
271
|
inline?: boolean;
|
|
@@ -363,7 +407,6 @@ interface AuthHooks {
|
|
|
363
407
|
type AuthOptions = AuthHooks & AuthProvider;
|
|
364
408
|
export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined, SearchClient = undefined> {
|
|
365
409
|
contentApiUrlOverride?: string;
|
|
366
|
-
oauth2?: boolean;
|
|
367
410
|
authProvider?: AuthProvider;
|
|
368
411
|
admin?: {
|
|
369
412
|
/**
|
|
@@ -378,7 +421,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
378
421
|
/**
|
|
379
422
|
* The Schema is used to define the shape of the content.
|
|
380
423
|
*
|
|
381
|
-
* https://tina.io/docs/
|
|
424
|
+
* https://tina.io/docs/r/the-config-file/
|
|
382
425
|
*/
|
|
383
426
|
schema: Schema;
|
|
384
427
|
/**
|
|
@@ -415,11 +458,27 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
415
458
|
* ```
|
|
416
459
|
* [more info](https://vercel.com/docs/concepts/deployments/generated-urls#url-with-git-branch)
|
|
417
460
|
*/
|
|
418
|
-
previewUrl
|
|
461
|
+
previewUrl?: (context: {
|
|
419
462
|
branch: string;
|
|
420
463
|
}) => {
|
|
421
464
|
url: string;
|
|
422
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
|
+
};
|
|
423
482
|
};
|
|
424
483
|
/**
|
|
425
484
|
* Configurations for the autogenerated GraphQL HTTP client
|
|
@@ -499,7 +558,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
499
558
|
} | {
|
|
500
559
|
/**
|
|
501
560
|
* Use Git-backed assets for media, these values will
|
|
502
|
-
* [Learn more](https://tina.io/docs/
|
|
561
|
+
* [Learn more](https://tina.io/docs/r/repo-based-media/)
|
|
503
562
|
*/
|
|
504
563
|
tina: {
|
|
505
564
|
/**
|
|
@@ -519,6 +578,54 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
519
578
|
loadCustomStore?: never;
|
|
520
579
|
accept?: string | string[];
|
|
521
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
|
+
};
|
|
522
629
|
search?: ({
|
|
523
630
|
/**
|
|
524
631
|
* An instance of a search client like Algolia
|
|
@@ -543,6 +650,25 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
543
650
|
* regex used for splitting tokens (default: /[\p{L}\d_]+/)
|
|
544
651
|
*/
|
|
545
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
|
+
};
|
|
546
672
|
};
|
|
547
673
|
}) & {
|
|
548
674
|
/**
|
|
@@ -574,7 +700,7 @@ export interface Schema<WithNamespace extends boolean = false> {
|
|
|
574
700
|
/**
|
|
575
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).
|
|
576
702
|
*
|
|
577
|
-
* https://tina.io/docs/
|
|
703
|
+
* https://tina.io/docs/r/content-modelling-collections/
|
|
578
704
|
*/
|
|
579
705
|
collections: Collection<WithNamespace>[];
|
|
580
706
|
/**
|
|
@@ -588,7 +714,7 @@ interface BaseCollection {
|
|
|
588
714
|
name: string;
|
|
589
715
|
path: string;
|
|
590
716
|
indexes?: IndexType[];
|
|
591
|
-
format?:
|
|
717
|
+
format?: ContentFormat;
|
|
592
718
|
ui?: UICollection;
|
|
593
719
|
/**
|
|
594
720
|
* @deprecated - use `ui.defaultItem` on the each `template` instead
|
|
@@ -597,7 +723,7 @@ interface BaseCollection {
|
|
|
597
723
|
/**
|
|
598
724
|
* This format will be used to parse the markdown frontmatter
|
|
599
725
|
*/
|
|
600
|
-
frontmatterFormat?:
|
|
726
|
+
frontmatterFormat?: ContentFrontmatterFormat;
|
|
601
727
|
/**
|
|
602
728
|
* The delimiters used to parse the frontmatter.
|
|
603
729
|
*/
|
|
@@ -613,7 +739,7 @@ type TemplateCollection<WithNamespace extends boolean = false> = {
|
|
|
613
739
|
/**
|
|
614
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".
|
|
615
741
|
*
|
|
616
|
-
* https://tina.io/docs/
|
|
742
|
+
* https://tina.io/docs/r/content-modelling-templates/
|
|
617
743
|
*/
|
|
618
744
|
templates: Template<WithNamespace>[];
|
|
619
745
|
fields?: undefined;
|
|
@@ -622,7 +748,7 @@ type FieldCollection<WithNamespace extends boolean = false> = {
|
|
|
622
748
|
/**
|
|
623
749
|
* Fields define the shape of the content and the user input.
|
|
624
750
|
*
|
|
625
|
-
* https://tina.io/docs/
|
|
751
|
+
* https://tina.io/docs/r/string-fields/
|
|
626
752
|
*/
|
|
627
753
|
fields: TinaField<WithNamespace>[];
|
|
628
754
|
templates?: undefined;
|
|
@@ -679,6 +805,7 @@ export interface UICollection<Form = any, CMS = any, TinaForm = any> {
|
|
|
679
805
|
allowedActions?: {
|
|
680
806
|
create?: boolean;
|
|
681
807
|
delete?: boolean;
|
|
808
|
+
createFolder?: boolean;
|
|
682
809
|
createNestedFolder?: boolean;
|
|
683
810
|
};
|
|
684
811
|
/**
|
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export declare const normalizePath: (filepath: string) => string;
|
|
2
|
+
/**
|
|
3
|
+
* Returns the given path such that:
|
|
4
|
+
* - The path separator is converted from '\' to '/' if necessary.
|
|
5
|
+
* - Duplicate '/' are removed
|
|
6
|
+
* - Leading and trailing '/' are cleared
|
|
7
|
+
* @param filepath Filepath to convert to its canonical form
|
|
8
|
+
*/
|
|
9
|
+
export declare const canonicalPath: (filepath: string) => string;
|