@tinacms/schema-tools 0.0.0-dbef36f-20250616005720 → 0.0.0-dd2089d-20251128055623
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.js +19 -1
- package/dist/index.mjs +19 -1
- package/dist/types/index.d.ts +37 -6
- package/dist/validate/schema.d.ts +65 -0
- package/dist/validate/tinaCloudSchemaConfig.d.ts +37 -0
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -2395,7 +2395,8 @@ ${formattedTypes}`;
|
|
|
2395
2395
|
type: z.z.literal("image", {
|
|
2396
2396
|
invalid_type_error: typeTypeError,
|
|
2397
2397
|
required_error: typeRequiredError
|
|
2398
|
-
})
|
|
2398
|
+
}),
|
|
2399
|
+
uploadDir: z.z.function().args(z.z.any()).returns(z.z.string()).optional()
|
|
2399
2400
|
});
|
|
2400
2401
|
const DateTimeField = TinaScalerBase.extend({
|
|
2401
2402
|
type: z.z.literal("datetime", {
|
|
@@ -2577,6 +2578,23 @@ ${stringifiedField}`
|
|
|
2577
2578
|
searchClient: z.any().optional(),
|
|
2578
2579
|
indexBatchSize: z.number().gte(1).optional(),
|
|
2579
2580
|
maxSearchIndexFieldLength: z.number().gte(1).optional()
|
|
2581
|
+
}).optional(),
|
|
2582
|
+
ui: z.object({
|
|
2583
|
+
previewUrl: z.function().optional(),
|
|
2584
|
+
optOutOfUpdateCheck: z.boolean().optional(),
|
|
2585
|
+
regexValidation: z.object({
|
|
2586
|
+
folderNameRegex: z.string().refine(
|
|
2587
|
+
(val) => {
|
|
2588
|
+
try {
|
|
2589
|
+
new RegExp(val);
|
|
2590
|
+
return true;
|
|
2591
|
+
} catch (error) {
|
|
2592
|
+
return false;
|
|
2593
|
+
}
|
|
2594
|
+
},
|
|
2595
|
+
{ message: "folderNameRegex is not a valid regex pattern" }
|
|
2596
|
+
).optional()
|
|
2597
|
+
}).optional()
|
|
2580
2598
|
}).optional()
|
|
2581
2599
|
});
|
|
2582
2600
|
const validateTinaCloudSchemaConfig = (config) => {
|
package/dist/index.mjs
CHANGED
|
@@ -2377,7 +2377,8 @@ const ImageField = TinaScalerBase.extend({
|
|
|
2377
2377
|
type: z.literal("image", {
|
|
2378
2378
|
invalid_type_error: typeTypeError,
|
|
2379
2379
|
required_error: typeRequiredError
|
|
2380
|
-
})
|
|
2380
|
+
}),
|
|
2381
|
+
uploadDir: z.function().args(z.any()).returns(z.string()).optional()
|
|
2381
2382
|
});
|
|
2382
2383
|
const DateTimeField = TinaScalerBase.extend({
|
|
2383
2384
|
type: z.literal("datetime", {
|
|
@@ -2559,6 +2560,23 @@ const tinaConfigZod = z$1.object({
|
|
|
2559
2560
|
searchClient: z$1.any().optional(),
|
|
2560
2561
|
indexBatchSize: z$1.number().gte(1).optional(),
|
|
2561
2562
|
maxSearchIndexFieldLength: z$1.number().gte(1).optional()
|
|
2563
|
+
}).optional(),
|
|
2564
|
+
ui: z$1.object({
|
|
2565
|
+
previewUrl: z$1.function().optional(),
|
|
2566
|
+
optOutOfUpdateCheck: z$1.boolean().optional(),
|
|
2567
|
+
regexValidation: z$1.object({
|
|
2568
|
+
folderNameRegex: z$1.string().refine(
|
|
2569
|
+
(val) => {
|
|
2570
|
+
try {
|
|
2571
|
+
new RegExp(val);
|
|
2572
|
+
return true;
|
|
2573
|
+
} catch (error) {
|
|
2574
|
+
return false;
|
|
2575
|
+
}
|
|
2576
|
+
},
|
|
2577
|
+
{ message: "folderNameRegex is not a valid regex pattern" }
|
|
2578
|
+
).optional()
|
|
2579
|
+
}).optional()
|
|
2562
2580
|
}).optional()
|
|
2563
2581
|
});
|
|
2564
2582
|
const validateTinaCloudSchemaConfig = (config) => {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -129,6 +129,11 @@ export type UIField<Type, List extends boolean> = {
|
|
|
129
129
|
type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
|
|
130
130
|
list: true;
|
|
131
131
|
ui?: UIField<Type, true> & ExtraFieldUIProps;
|
|
132
|
+
/**
|
|
133
|
+
* Defines where new items will be added in the list.
|
|
134
|
+
* If not specified, defaults to `append`.
|
|
135
|
+
*/
|
|
136
|
+
addItemBehavior?: 'append' | 'prepend';
|
|
132
137
|
} : List extends false ? {
|
|
133
138
|
list?: false;
|
|
134
139
|
ui?: UIField<Type, false> & ExtraFieldUIProps;
|
|
@@ -176,6 +181,16 @@ export type DateTimeField = (FieldGeneric<string, undefined, DateFormatProps> |
|
|
|
176
181
|
};
|
|
177
182
|
export type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
178
183
|
type: 'image';
|
|
184
|
+
/**
|
|
185
|
+
* A function that returns the upload directory path based on the form values.
|
|
186
|
+
* This is used to organize uploaded images into specific folders.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* uploadDir: (formValues) => `uploads/${formValues.category}`
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
uploadDir?: (formValues: Record<string, any>) => string;
|
|
179
194
|
};
|
|
180
195
|
type ReferenceFieldOptions = {
|
|
181
196
|
optionComponent?: OptionComponent;
|
|
@@ -386,7 +401,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
386
401
|
/**
|
|
387
402
|
* The Schema is used to define the shape of the content.
|
|
388
403
|
*
|
|
389
|
-
* https://tina.io/docs/
|
|
404
|
+
* https://tina.io/docs/r/the-config-file/
|
|
390
405
|
*/
|
|
391
406
|
schema: Schema;
|
|
392
407
|
/**
|
|
@@ -423,11 +438,27 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
423
438
|
* ```
|
|
424
439
|
* [more info](https://vercel.com/docs/concepts/deployments/generated-urls#url-with-git-branch)
|
|
425
440
|
*/
|
|
426
|
-
previewUrl
|
|
441
|
+
previewUrl?: (context: {
|
|
427
442
|
branch: string;
|
|
428
443
|
}) => {
|
|
429
444
|
url: string;
|
|
430
445
|
};
|
|
446
|
+
/**
|
|
447
|
+
* Opt out of update checks - this will prevent the CMS for checking for new versions
|
|
448
|
+
* If true, the CMS will not check for updates.
|
|
449
|
+
* Defaults to false if not specified.
|
|
450
|
+
*/
|
|
451
|
+
optOutOfUpdateCheck?: boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Regular expression pattern that folder names must match when creating new folders.
|
|
454
|
+
* Only applies to newly created folders, not existing ones.
|
|
455
|
+
*
|
|
456
|
+
* @example "^[a-z0-9-]+$" - allows lowercase letters, numbers, and hyphens only
|
|
457
|
+
* @example "^[A-Za-z0-9_-]+$" - allows letters, numbers, underscores, and hyphens
|
|
458
|
+
*/
|
|
459
|
+
regexValidation?: {
|
|
460
|
+
folderNameRegex?: string;
|
|
461
|
+
};
|
|
431
462
|
};
|
|
432
463
|
/**
|
|
433
464
|
* Configurations for the autogenerated GraphQL HTTP client
|
|
@@ -507,7 +538,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
507
538
|
} | {
|
|
508
539
|
/**
|
|
509
540
|
* Use Git-backed assets for media, these values will
|
|
510
|
-
* [Learn more](https://tina.io/docs/
|
|
541
|
+
* [Learn more](https://tina.io/docs/r/repo-based-media/)
|
|
511
542
|
*/
|
|
512
543
|
tina: {
|
|
513
544
|
/**
|
|
@@ -582,7 +613,7 @@ export interface Schema<WithNamespace extends boolean = false> {
|
|
|
582
613
|
/**
|
|
583
614
|
* 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).
|
|
584
615
|
*
|
|
585
|
-
* https://tina.io/docs/
|
|
616
|
+
* https://tina.io/docs/r/content-modelling-collections/
|
|
586
617
|
*/
|
|
587
618
|
collections: Collection<WithNamespace>[];
|
|
588
619
|
/**
|
|
@@ -621,7 +652,7 @@ type TemplateCollection<WithNamespace extends boolean = false> = {
|
|
|
621
652
|
/**
|
|
622
653
|
* 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".
|
|
623
654
|
*
|
|
624
|
-
* https://tina.io/docs/
|
|
655
|
+
* https://tina.io/docs/r/content-modelling-templates/
|
|
625
656
|
*/
|
|
626
657
|
templates: Template<WithNamespace>[];
|
|
627
658
|
fields?: undefined;
|
|
@@ -630,7 +661,7 @@ type FieldCollection<WithNamespace extends boolean = false> = {
|
|
|
630
661
|
/**
|
|
631
662
|
* Fields define the shape of the content and the user input.
|
|
632
663
|
*
|
|
633
|
-
* https://tina.io/docs/
|
|
664
|
+
* https://tina.io/docs/r/string-fields/
|
|
634
665
|
*/
|
|
635
666
|
fields: TinaField<WithNamespace>[];
|
|
636
667
|
templates?: undefined;
|
|
@@ -187,6 +187,29 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
187
187
|
searchClient?: any;
|
|
188
188
|
indexBatchSize?: number;
|
|
189
189
|
}>>;
|
|
190
|
+
ui: z.ZodOptional<z.ZodObject<{
|
|
191
|
+
previewUrl: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
192
|
+
optOutOfUpdateCheck: z.ZodOptional<z.ZodBoolean>;
|
|
193
|
+
regexValidation: z.ZodOptional<z.ZodObject<{
|
|
194
|
+
folderNameRegex: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
folderNameRegex?: string;
|
|
197
|
+
}, {
|
|
198
|
+
folderNameRegex?: string;
|
|
199
|
+
}>>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
202
|
+
optOutOfUpdateCheck?: boolean;
|
|
203
|
+
regexValidation?: {
|
|
204
|
+
folderNameRegex?: string;
|
|
205
|
+
};
|
|
206
|
+
}, {
|
|
207
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
208
|
+
optOutOfUpdateCheck?: boolean;
|
|
209
|
+
regexValidation?: {
|
|
210
|
+
folderNameRegex?: string;
|
|
211
|
+
};
|
|
212
|
+
}>>;
|
|
190
213
|
}, "strip", z.ZodTypeAny, {
|
|
191
214
|
search?: {
|
|
192
215
|
maxSearchIndexFieldLength?: number;
|
|
@@ -198,6 +221,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
198
221
|
searchClient?: any;
|
|
199
222
|
indexBatchSize?: number;
|
|
200
223
|
};
|
|
224
|
+
ui?: {
|
|
225
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
226
|
+
optOutOfUpdateCheck?: boolean;
|
|
227
|
+
regexValidation?: {
|
|
228
|
+
folderNameRegex?: string;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
201
231
|
client?: {
|
|
202
232
|
referenceDepth?: number;
|
|
203
233
|
};
|
|
@@ -220,6 +250,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
220
250
|
searchClient?: any;
|
|
221
251
|
indexBatchSize?: number;
|
|
222
252
|
};
|
|
253
|
+
ui?: {
|
|
254
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
255
|
+
optOutOfUpdateCheck?: boolean;
|
|
256
|
+
regexValidation?: {
|
|
257
|
+
folderNameRegex?: string;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
223
260
|
client?: {
|
|
224
261
|
referenceDepth?: number;
|
|
225
262
|
};
|
|
@@ -258,6 +295,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
258
295
|
searchClient?: any;
|
|
259
296
|
indexBatchSize?: number;
|
|
260
297
|
};
|
|
298
|
+
ui?: {
|
|
299
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
300
|
+
optOutOfUpdateCheck?: boolean;
|
|
301
|
+
regexValidation?: {
|
|
302
|
+
folderNameRegex?: string;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
261
305
|
client?: {
|
|
262
306
|
referenceDepth?: number;
|
|
263
307
|
};
|
|
@@ -296,6 +340,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
296
340
|
searchClient?: any;
|
|
297
341
|
indexBatchSize?: number;
|
|
298
342
|
};
|
|
343
|
+
ui?: {
|
|
344
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
345
|
+
optOutOfUpdateCheck?: boolean;
|
|
346
|
+
regexValidation?: {
|
|
347
|
+
folderNameRegex?: string;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
299
350
|
client?: {
|
|
300
351
|
referenceDepth?: number;
|
|
301
352
|
};
|
|
@@ -334,6 +385,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
334
385
|
searchClient?: any;
|
|
335
386
|
indexBatchSize?: number;
|
|
336
387
|
};
|
|
388
|
+
ui?: {
|
|
389
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
390
|
+
optOutOfUpdateCheck?: boolean;
|
|
391
|
+
regexValidation?: {
|
|
392
|
+
folderNameRegex?: string;
|
|
393
|
+
};
|
|
394
|
+
};
|
|
337
395
|
client?: {
|
|
338
396
|
referenceDepth?: number;
|
|
339
397
|
};
|
|
@@ -372,6 +430,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
372
430
|
searchClient?: any;
|
|
373
431
|
indexBatchSize?: number;
|
|
374
432
|
};
|
|
433
|
+
ui?: {
|
|
434
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
435
|
+
optOutOfUpdateCheck?: boolean;
|
|
436
|
+
regexValidation?: {
|
|
437
|
+
folderNameRegex?: string;
|
|
438
|
+
};
|
|
439
|
+
};
|
|
375
440
|
client?: {
|
|
376
441
|
referenceDepth?: number;
|
|
377
442
|
};
|
|
@@ -77,6 +77,29 @@ export declare const tinaConfigZod: z.ZodObject<{
|
|
|
77
77
|
searchClient?: any;
|
|
78
78
|
indexBatchSize?: number;
|
|
79
79
|
}>>;
|
|
80
|
+
ui: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
previewUrl: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
82
|
+
optOutOfUpdateCheck: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
regexValidation: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
folderNameRegex: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
folderNameRegex?: string;
|
|
87
|
+
}, {
|
|
88
|
+
folderNameRegex?: string;
|
|
89
|
+
}>>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
92
|
+
optOutOfUpdateCheck?: boolean;
|
|
93
|
+
regexValidation?: {
|
|
94
|
+
folderNameRegex?: string;
|
|
95
|
+
};
|
|
96
|
+
}, {
|
|
97
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
98
|
+
optOutOfUpdateCheck?: boolean;
|
|
99
|
+
regexValidation?: {
|
|
100
|
+
folderNameRegex?: string;
|
|
101
|
+
};
|
|
102
|
+
}>>;
|
|
80
103
|
}, "strip", z.ZodTypeAny, {
|
|
81
104
|
search?: {
|
|
82
105
|
maxSearchIndexFieldLength?: number;
|
|
@@ -88,6 +111,13 @@ export declare const tinaConfigZod: z.ZodObject<{
|
|
|
88
111
|
searchClient?: any;
|
|
89
112
|
indexBatchSize?: number;
|
|
90
113
|
};
|
|
114
|
+
ui?: {
|
|
115
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
116
|
+
optOutOfUpdateCheck?: boolean;
|
|
117
|
+
regexValidation?: {
|
|
118
|
+
folderNameRegex?: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
91
121
|
client?: {
|
|
92
122
|
referenceDepth?: number;
|
|
93
123
|
};
|
|
@@ -110,6 +140,13 @@ export declare const tinaConfigZod: z.ZodObject<{
|
|
|
110
140
|
searchClient?: any;
|
|
111
141
|
indexBatchSize?: number;
|
|
112
142
|
};
|
|
143
|
+
ui?: {
|
|
144
|
+
previewUrl?: (...args: unknown[]) => unknown;
|
|
145
|
+
optOutOfUpdateCheck?: boolean;
|
|
146
|
+
regexValidation?: {
|
|
147
|
+
folderNameRegex?: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
113
150
|
client?: {
|
|
114
151
|
referenceDepth?: number;
|
|
115
152
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/schema-tools",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-dd2089d-20251128055623",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -26,17 +26,16 @@
|
|
|
26
26
|
"@types/jest": "^29.5.14",
|
|
27
27
|
"@types/micromatch": "^4.0.9",
|
|
28
28
|
"@types/react": "^18.3.18",
|
|
29
|
-
"@types/yup": "^0.29.14",
|
|
30
29
|
"jest": "^29.7.0",
|
|
31
30
|
"react": "^18.3.1",
|
|
32
31
|
"ts-jest": "^29.2.5",
|
|
33
32
|
"typescript": "^5.7.3",
|
|
34
|
-
"yup": "^
|
|
35
|
-
"@tinacms/scripts": "1.
|
|
33
|
+
"yup": "^1.6.1",
|
|
34
|
+
"@tinacms/scripts": "1.4.1"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|
|
38
37
|
"react": ">=16.14.0",
|
|
39
|
-
"yup": "^0.
|
|
38
|
+
"yup": "^1.0.0"
|
|
40
39
|
},
|
|
41
40
|
"publishConfig": {
|
|
42
41
|
"registry": "https://registry.npmjs.org"
|