@tinacms/schema-tools 0.0.0-c965b5f-20250426163441 → 0.0.0-ccab7a5-20251124054446
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 +41 -19
- package/dist/index.mjs +41 -19
- package/dist/types/index.d.ts +48 -19
- package/dist/util/normalizePath.d.ts +8 -0
- package/dist/validate/schema.d.ts +101 -36
- package/dist/validate/tinaCloudSchemaConfig.d.ts +37 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1664,6 +1664,9 @@
|
|
|
1664
1664
|
};
|
|
1665
1665
|
};
|
|
1666
1666
|
const normalizePath = (filepath) => filepath.replace(/\\/g, "/");
|
|
1667
|
+
const canonicalPath = (filepath) => {
|
|
1668
|
+
return normalizePath(filepath).split("/").filter((name2) => name2 !== "").join("/");
|
|
1669
|
+
};
|
|
1667
1670
|
class TinaSchema {
|
|
1668
1671
|
/**
|
|
1669
1672
|
* Create a schema class from a user defined schema object
|
|
@@ -1713,21 +1716,21 @@
|
|
|
1713
1716
|
};
|
|
1714
1717
|
this.getCollectionByFullPath = (filepath) => {
|
|
1715
1718
|
const fileExtension = filepath.split(".").pop();
|
|
1716
|
-
const
|
|
1719
|
+
const canonicalFilepath = canonicalPath(filepath);
|
|
1717
1720
|
const possibleCollections = this.getCollections().filter((collection) => {
|
|
1718
1721
|
var _a, _b;
|
|
1719
|
-
if (!
|
|
1722
|
+
if (!canonicalFilepath.endsWith(`.gitkeep.${collection.format || "md"}`) && fileExtension !== (collection.format || "md")) {
|
|
1720
1723
|
return false;
|
|
1721
1724
|
}
|
|
1722
1725
|
if (((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) || ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude)) {
|
|
1723
1726
|
const matches = this.getMatches({ collection });
|
|
1724
|
-
const match = picomatch$1.isMatch(
|
|
1727
|
+
const match = picomatch$1.isMatch(canonicalFilepath, matches);
|
|
1725
1728
|
if (!match) {
|
|
1726
1729
|
return false;
|
|
1727
1730
|
}
|
|
1728
1731
|
}
|
|
1729
|
-
const
|
|
1730
|
-
return
|
|
1732
|
+
const collectionPath = canonicalPath(collection.path);
|
|
1733
|
+
return collectionPath === "" || canonicalFilepath.startsWith(`${collectionPath}/`);
|
|
1731
1734
|
});
|
|
1732
1735
|
if (possibleCollections.length === 0) {
|
|
1733
1736
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
|
@@ -2060,16 +2063,16 @@
|
|
|
2060
2063
|
}) {
|
|
2061
2064
|
var _a, _b;
|
|
2062
2065
|
const collection = typeof collectionOrString === "string" ? this.getCollection(collectionOrString) : collectionOrString;
|
|
2063
|
-
const
|
|
2064
|
-
const pathSuffix =
|
|
2066
|
+
const collectionPath = canonicalPath(collection.path);
|
|
2067
|
+
const pathSuffix = collectionPath ? "/" : "";
|
|
2065
2068
|
const format = collection.format || "md";
|
|
2066
2069
|
const matches = [];
|
|
2067
2070
|
if ((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) {
|
|
2068
|
-
const match = `${
|
|
2071
|
+
const match = `${collectionPath}${pathSuffix}${collection.match.include}.${format}`;
|
|
2069
2072
|
matches.push(match);
|
|
2070
2073
|
}
|
|
2071
2074
|
if ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude) {
|
|
2072
|
-
const exclude = `!(${
|
|
2075
|
+
const exclude = `!(${collectionPath}${pathSuffix}${collection.match.exclude}.${format})`;
|
|
2073
2076
|
matches.push(exclude);
|
|
2074
2077
|
}
|
|
2075
2078
|
return matches;
|
|
@@ -2262,6 +2265,15 @@
|
|
|
2262
2265
|
})
|
|
2263
2266
|
};
|
|
2264
2267
|
};
|
|
2268
|
+
const CONTENT_FORMATS = [
|
|
2269
|
+
"mdx",
|
|
2270
|
+
"md",
|
|
2271
|
+
"markdown",
|
|
2272
|
+
"json",
|
|
2273
|
+
"yaml",
|
|
2274
|
+
"yml",
|
|
2275
|
+
"toml"
|
|
2276
|
+
];
|
|
2265
2277
|
const parseZodError = ({ zodError }) => {
|
|
2266
2278
|
var _a, _b, _c, _d;
|
|
2267
2279
|
const errors = zodError.flatten((issue) => {
|
|
@@ -2565,21 +2577,29 @@ ${stringifiedField}`
|
|
|
2565
2577
|
searchClient: z.any().optional(),
|
|
2566
2578
|
indexBatchSize: z.number().gte(1).optional(),
|
|
2567
2579
|
maxSearchIndexFieldLength: z.number().gte(1).optional()
|
|
2580
|
+
}).optional(),
|
|
2581
|
+
ui: z.object({
|
|
2582
|
+
previewUrl: z.function().optional(),
|
|
2583
|
+
optOutOfUpdateCheck: z.boolean().optional(),
|
|
2584
|
+
regexValidation: z.object({
|
|
2585
|
+
folderNameRegex: z.string().refine(
|
|
2586
|
+
(val) => {
|
|
2587
|
+
try {
|
|
2588
|
+
new RegExp(val);
|
|
2589
|
+
return true;
|
|
2590
|
+
} catch (error) {
|
|
2591
|
+
return false;
|
|
2592
|
+
}
|
|
2593
|
+
},
|
|
2594
|
+
{ message: "folderNameRegex is not a valid regex pattern" }
|
|
2595
|
+
).optional()
|
|
2596
|
+
}).optional()
|
|
2568
2597
|
}).optional()
|
|
2569
2598
|
});
|
|
2570
2599
|
const validateTinaCloudSchemaConfig = (config) => {
|
|
2571
2600
|
const newConfig = tinaConfigZod.parse(config);
|
|
2572
2601
|
return newConfig;
|
|
2573
2602
|
};
|
|
2574
|
-
const FORMATS = [
|
|
2575
|
-
"json",
|
|
2576
|
-
"md",
|
|
2577
|
-
"markdown",
|
|
2578
|
-
"mdx",
|
|
2579
|
-
"toml",
|
|
2580
|
-
"yaml",
|
|
2581
|
-
"yml"
|
|
2582
|
-
];
|
|
2583
2603
|
const Template = z.z.object({
|
|
2584
2604
|
label: z.z.string({
|
|
2585
2605
|
invalid_type_error: "Invalid data type for property `label`. Must be of type `string`",
|
|
@@ -2615,7 +2635,7 @@ ${stringifiedField}`
|
|
|
2615
2635
|
});
|
|
2616
2636
|
}
|
|
2617
2637
|
}),
|
|
2618
|
-
format: z.z.enum(
|
|
2638
|
+
format: z.z.enum(CONTENT_FORMATS).optional(),
|
|
2619
2639
|
isAuthCollection: z.z.boolean().optional(),
|
|
2620
2640
|
isDetached: z.z.boolean().optional()
|
|
2621
2641
|
});
|
|
@@ -2734,11 +2754,13 @@ ${stringifiedField}`
|
|
|
2734
2754
|
throw new Error(e);
|
|
2735
2755
|
}
|
|
2736
2756
|
};
|
|
2757
|
+
exports2.CONTENT_FORMATS = CONTENT_FORMATS;
|
|
2737
2758
|
exports2.NAMER = NAMER;
|
|
2738
2759
|
exports2.TINA_HOST = TINA_HOST;
|
|
2739
2760
|
exports2.TinaSchema = TinaSchema;
|
|
2740
2761
|
exports2.TinaSchemaValidationError = TinaSchemaValidationError;
|
|
2741
2762
|
exports2.addNamespaceToSchema = addNamespaceToSchema;
|
|
2763
|
+
exports2.canonicalPath = canonicalPath;
|
|
2742
2764
|
exports2.normalizePath = normalizePath;
|
|
2743
2765
|
exports2.parseURL = parseURL;
|
|
2744
2766
|
exports2.resolveField = resolveField;
|
package/dist/index.mjs
CHANGED
|
@@ -1646,6 +1646,9 @@ const parseURL = (url) => {
|
|
|
1646
1646
|
};
|
|
1647
1647
|
};
|
|
1648
1648
|
const normalizePath = (filepath) => filepath.replace(/\\/g, "/");
|
|
1649
|
+
const canonicalPath = (filepath) => {
|
|
1650
|
+
return normalizePath(filepath).split("/").filter((name2) => name2 !== "").join("/");
|
|
1651
|
+
};
|
|
1649
1652
|
class TinaSchema {
|
|
1650
1653
|
/**
|
|
1651
1654
|
* Create a schema class from a user defined schema object
|
|
@@ -1695,21 +1698,21 @@ class TinaSchema {
|
|
|
1695
1698
|
};
|
|
1696
1699
|
this.getCollectionByFullPath = (filepath) => {
|
|
1697
1700
|
const fileExtension = filepath.split(".").pop();
|
|
1698
|
-
const
|
|
1701
|
+
const canonicalFilepath = canonicalPath(filepath);
|
|
1699
1702
|
const possibleCollections = this.getCollections().filter((collection) => {
|
|
1700
1703
|
var _a, _b;
|
|
1701
|
-
if (!
|
|
1704
|
+
if (!canonicalFilepath.endsWith(`.gitkeep.${collection.format || "md"}`) && fileExtension !== (collection.format || "md")) {
|
|
1702
1705
|
return false;
|
|
1703
1706
|
}
|
|
1704
1707
|
if (((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) || ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude)) {
|
|
1705
1708
|
const matches = this.getMatches({ collection });
|
|
1706
|
-
const match = picomatch$1.isMatch(
|
|
1709
|
+
const match = picomatch$1.isMatch(canonicalFilepath, matches);
|
|
1707
1710
|
if (!match) {
|
|
1708
1711
|
return false;
|
|
1709
1712
|
}
|
|
1710
1713
|
}
|
|
1711
|
-
const
|
|
1712
|
-
return
|
|
1714
|
+
const collectionPath = canonicalPath(collection.path);
|
|
1715
|
+
return collectionPath === "" || canonicalFilepath.startsWith(`${collectionPath}/`);
|
|
1713
1716
|
});
|
|
1714
1717
|
if (possibleCollections.length === 0) {
|
|
1715
1718
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
|
@@ -2042,16 +2045,16 @@ class TinaSchema {
|
|
|
2042
2045
|
}) {
|
|
2043
2046
|
var _a, _b;
|
|
2044
2047
|
const collection = typeof collectionOrString === "string" ? this.getCollection(collectionOrString) : collectionOrString;
|
|
2045
|
-
const
|
|
2046
|
-
const pathSuffix =
|
|
2048
|
+
const collectionPath = canonicalPath(collection.path);
|
|
2049
|
+
const pathSuffix = collectionPath ? "/" : "";
|
|
2047
2050
|
const format = collection.format || "md";
|
|
2048
2051
|
const matches = [];
|
|
2049
2052
|
if ((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) {
|
|
2050
|
-
const match = `${
|
|
2053
|
+
const match = `${collectionPath}${pathSuffix}${collection.match.include}.${format}`;
|
|
2051
2054
|
matches.push(match);
|
|
2052
2055
|
}
|
|
2053
2056
|
if ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude) {
|
|
2054
|
-
const exclude = `!(${
|
|
2057
|
+
const exclude = `!(${collectionPath}${pathSuffix}${collection.match.exclude}.${format})`;
|
|
2055
2058
|
matches.push(exclude);
|
|
2056
2059
|
}
|
|
2057
2060
|
return matches;
|
|
@@ -2244,6 +2247,15 @@ const resolveForm = ({
|
|
|
2244
2247
|
})
|
|
2245
2248
|
};
|
|
2246
2249
|
};
|
|
2250
|
+
const CONTENT_FORMATS = [
|
|
2251
|
+
"mdx",
|
|
2252
|
+
"md",
|
|
2253
|
+
"markdown",
|
|
2254
|
+
"json",
|
|
2255
|
+
"yaml",
|
|
2256
|
+
"yml",
|
|
2257
|
+
"toml"
|
|
2258
|
+
];
|
|
2247
2259
|
const parseZodError = ({ zodError }) => {
|
|
2248
2260
|
var _a, _b, _c, _d;
|
|
2249
2261
|
const errors = zodError.flatten((issue) => {
|
|
@@ -2547,21 +2559,29 @@ const tinaConfigZod = z$1.object({
|
|
|
2547
2559
|
searchClient: z$1.any().optional(),
|
|
2548
2560
|
indexBatchSize: z$1.number().gte(1).optional(),
|
|
2549
2561
|
maxSearchIndexFieldLength: z$1.number().gte(1).optional()
|
|
2562
|
+
}).optional(),
|
|
2563
|
+
ui: z$1.object({
|
|
2564
|
+
previewUrl: z$1.function().optional(),
|
|
2565
|
+
optOutOfUpdateCheck: z$1.boolean().optional(),
|
|
2566
|
+
regexValidation: z$1.object({
|
|
2567
|
+
folderNameRegex: z$1.string().refine(
|
|
2568
|
+
(val) => {
|
|
2569
|
+
try {
|
|
2570
|
+
new RegExp(val);
|
|
2571
|
+
return true;
|
|
2572
|
+
} catch (error) {
|
|
2573
|
+
return false;
|
|
2574
|
+
}
|
|
2575
|
+
},
|
|
2576
|
+
{ message: "folderNameRegex is not a valid regex pattern" }
|
|
2577
|
+
).optional()
|
|
2578
|
+
}).optional()
|
|
2550
2579
|
}).optional()
|
|
2551
2580
|
});
|
|
2552
2581
|
const validateTinaCloudSchemaConfig = (config) => {
|
|
2553
2582
|
const newConfig = tinaConfigZod.parse(config);
|
|
2554
2583
|
return newConfig;
|
|
2555
2584
|
};
|
|
2556
|
-
const FORMATS = [
|
|
2557
|
-
"json",
|
|
2558
|
-
"md",
|
|
2559
|
-
"markdown",
|
|
2560
|
-
"mdx",
|
|
2561
|
-
"toml",
|
|
2562
|
-
"yaml",
|
|
2563
|
-
"yml"
|
|
2564
|
-
];
|
|
2565
2585
|
const Template = z.object({
|
|
2566
2586
|
label: z.string({
|
|
2567
2587
|
invalid_type_error: "Invalid data type for property `label`. Must be of type `string`",
|
|
@@ -2597,7 +2617,7 @@ const CollectionBaseSchema = z.object({
|
|
|
2597
2617
|
});
|
|
2598
2618
|
}
|
|
2599
2619
|
}),
|
|
2600
|
-
format: z.enum(
|
|
2620
|
+
format: z.enum(CONTENT_FORMATS).optional(),
|
|
2601
2621
|
isAuthCollection: z.boolean().optional(),
|
|
2602
2622
|
isDetached: z.boolean().optional()
|
|
2603
2623
|
});
|
|
@@ -2717,11 +2737,13 @@ const validateSchema = ({ schema }) => {
|
|
|
2717
2737
|
}
|
|
2718
2738
|
};
|
|
2719
2739
|
export {
|
|
2740
|
+
CONTENT_FORMATS,
|
|
2720
2741
|
NAMER,
|
|
2721
2742
|
TINA_HOST,
|
|
2722
2743
|
TinaSchema,
|
|
2723
2744
|
TinaSchemaValidationError,
|
|
2724
2745
|
addNamespaceToSchema,
|
|
2746
|
+
canonicalPath,
|
|
2725
2747
|
normalizePath,
|
|
2726
2748
|
parseURL,
|
|
2727
2749
|
resolveField,
|
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;
|
|
@@ -111,6 +129,11 @@ export type UIField<Type, List extends boolean> = {
|
|
|
111
129
|
type FieldGeneric<Type, List extends boolean | undefined, ExtraFieldUIProps = {}> = List extends true ? {
|
|
112
130
|
list: true;
|
|
113
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';
|
|
114
137
|
} : List extends false ? {
|
|
115
138
|
list?: false;
|
|
116
139
|
ui?: UIField<Type, false> & ExtraFieldUIProps;
|
|
@@ -212,16 +235,7 @@ export type RichTextField<WithNamespace extends boolean = false> = (FieldGeneric
|
|
|
212
235
|
*
|
|
213
236
|
* Specify `"markdown"` if you're having problems with Tina parsing your content.
|
|
214
237
|
*/
|
|
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
|
-
};
|
|
238
|
+
parser?: Parser;
|
|
225
239
|
};
|
|
226
240
|
export type RichTextTemplate<WithNamespace extends boolean = false> = Template<WithNamespace> & {
|
|
227
241
|
inline?: boolean;
|
|
@@ -363,7 +377,6 @@ interface AuthHooks {
|
|
|
363
377
|
type AuthOptions = AuthHooks & AuthProvider;
|
|
364
378
|
export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined, SearchClient = undefined> {
|
|
365
379
|
contentApiUrlOverride?: string;
|
|
366
|
-
oauth2?: boolean;
|
|
367
380
|
authProvider?: AuthProvider;
|
|
368
381
|
admin?: {
|
|
369
382
|
/**
|
|
@@ -378,7 +391,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
378
391
|
/**
|
|
379
392
|
* The Schema is used to define the shape of the content.
|
|
380
393
|
*
|
|
381
|
-
* https://tina.io/docs/
|
|
394
|
+
* https://tina.io/docs/r/the-config-file/
|
|
382
395
|
*/
|
|
383
396
|
schema: Schema;
|
|
384
397
|
/**
|
|
@@ -415,11 +428,27 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
415
428
|
* ```
|
|
416
429
|
* [more info](https://vercel.com/docs/concepts/deployments/generated-urls#url-with-git-branch)
|
|
417
430
|
*/
|
|
418
|
-
previewUrl
|
|
431
|
+
previewUrl?: (context: {
|
|
419
432
|
branch: string;
|
|
420
433
|
}) => {
|
|
421
434
|
url: string;
|
|
422
435
|
};
|
|
436
|
+
/**
|
|
437
|
+
* Opt out of update checks - this will prevent the CMS for checking for new versions
|
|
438
|
+
* If true, the CMS will not check for updates.
|
|
439
|
+
* Defaults to false if not specified.
|
|
440
|
+
*/
|
|
441
|
+
optOutOfUpdateCheck?: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* Regular expression pattern that folder names must match when creating new folders.
|
|
444
|
+
* Only applies to newly created folders, not existing ones.
|
|
445
|
+
*
|
|
446
|
+
* @example "^[a-z0-9-]+$" - allows lowercase letters, numbers, and hyphens only
|
|
447
|
+
* @example "^[A-Za-z0-9_-]+$" - allows letters, numbers, underscores, and hyphens
|
|
448
|
+
*/
|
|
449
|
+
regexValidation?: {
|
|
450
|
+
folderNameRegex?: string;
|
|
451
|
+
};
|
|
423
452
|
};
|
|
424
453
|
/**
|
|
425
454
|
* Configurations for the autogenerated GraphQL HTTP client
|
|
@@ -499,7 +528,7 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
499
528
|
} | {
|
|
500
529
|
/**
|
|
501
530
|
* Use Git-backed assets for media, these values will
|
|
502
|
-
* [Learn more](https://tina.io/docs/
|
|
531
|
+
* [Learn more](https://tina.io/docs/r/repo-based-media/)
|
|
503
532
|
*/
|
|
504
533
|
tina: {
|
|
505
534
|
/**
|
|
@@ -574,7 +603,7 @@ export interface Schema<WithNamespace extends boolean = false> {
|
|
|
574
603
|
/**
|
|
575
604
|
* 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
605
|
*
|
|
577
|
-
* https://tina.io/docs/
|
|
606
|
+
* https://tina.io/docs/r/content-modelling-collections/
|
|
578
607
|
*/
|
|
579
608
|
collections: Collection<WithNamespace>[];
|
|
580
609
|
/**
|
|
@@ -588,7 +617,7 @@ interface BaseCollection {
|
|
|
588
617
|
name: string;
|
|
589
618
|
path: string;
|
|
590
619
|
indexes?: IndexType[];
|
|
591
|
-
format?:
|
|
620
|
+
format?: ContentFormat;
|
|
592
621
|
ui?: UICollection;
|
|
593
622
|
/**
|
|
594
623
|
* @deprecated - use `ui.defaultItem` on the each `template` instead
|
|
@@ -597,7 +626,7 @@ interface BaseCollection {
|
|
|
597
626
|
/**
|
|
598
627
|
* This format will be used to parse the markdown frontmatter
|
|
599
628
|
*/
|
|
600
|
-
frontmatterFormat?:
|
|
629
|
+
frontmatterFormat?: ContentFrontmatterFormat;
|
|
601
630
|
/**
|
|
602
631
|
* The delimiters used to parse the frontmatter.
|
|
603
632
|
*/
|
|
@@ -613,7 +642,7 @@ type TemplateCollection<WithNamespace extends boolean = false> = {
|
|
|
613
642
|
/**
|
|
614
643
|
* 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
644
|
*
|
|
616
|
-
* https://tina.io/docs/
|
|
645
|
+
* https://tina.io/docs/r/content-modelling-templates/
|
|
617
646
|
*/
|
|
618
647
|
templates: Template<WithNamespace>[];
|
|
619
648
|
fields?: undefined;
|
|
@@ -622,7 +651,7 @@ type FieldCollection<WithNamespace extends boolean = false> = {
|
|
|
622
651
|
/**
|
|
623
652
|
* Fields define the shape of the content and the user input.
|
|
624
653
|
*
|
|
625
|
-
* https://tina.io/docs/
|
|
654
|
+
* https://tina.io/docs/r/string-fields/
|
|
626
655
|
*/
|
|
627
656
|
fields: TinaField<WithNamespace>[];
|
|
628
657
|
templates?: undefined;
|
|
@@ -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;
|
|
@@ -3,21 +3,21 @@ export declare const CollectionBaseSchema: z.ZodObject<{
|
|
|
3
3
|
label: z.ZodOptional<z.ZodString>;
|
|
4
4
|
name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
5
5
|
path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
6
|
-
format: z.ZodOptional<z.ZodEnum<["
|
|
6
|
+
format: z.ZodOptional<z.ZodEnum<["mdx", "md", "markdown", "json", "yaml", "yml", "toml"]>>;
|
|
7
7
|
isAuthCollection: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
isDetached: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
name?: string;
|
|
11
11
|
label?: string;
|
|
12
12
|
path?: string;
|
|
13
|
-
format?: "
|
|
13
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
14
14
|
isDetached?: boolean;
|
|
15
15
|
isAuthCollection?: boolean;
|
|
16
16
|
}, {
|
|
17
17
|
name?: string;
|
|
18
18
|
label?: string;
|
|
19
19
|
path?: string;
|
|
20
|
-
format?: "
|
|
20
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
21
21
|
isDetached?: boolean;
|
|
22
22
|
isAuthCollection?: boolean;
|
|
23
23
|
}>;
|
|
@@ -26,90 +26,90 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
26
26
|
label: z.ZodOptional<z.ZodString>;
|
|
27
27
|
name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
28
28
|
path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
29
|
-
format: z.ZodOptional<z.ZodEnum<["
|
|
29
|
+
format: z.ZodOptional<z.ZodEnum<["mdx", "md", "markdown", "json", "yaml", "yml", "toml"]>>;
|
|
30
30
|
isAuthCollection: z.ZodOptional<z.ZodBoolean>;
|
|
31
31
|
isDetached: z.ZodOptional<z.ZodBoolean>;
|
|
32
32
|
}, {
|
|
33
|
-
fields: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodType<import("
|
|
33
|
+
fields: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodType<import("../types/index").TinaField, z.ZodTypeDef, import("../types/index").TinaField>, "many">>, import("../types/index").TinaField[], import("../types/index").TinaField[]>, import("../types/index").TinaField[], import("../types/index").TinaField[]>, import("../types/index").TinaField[], import("../types/index").TinaField[]>, import("../types/index").TinaField[], import("../types/index").TinaField[]>;
|
|
34
34
|
templates: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
35
35
|
label: z.ZodString;
|
|
36
36
|
name: z.ZodEffects<z.ZodString, string, string>;
|
|
37
|
-
fields: z.ZodArray<z.ZodType<import("
|
|
37
|
+
fields: z.ZodArray<z.ZodType<import("../types/index").TinaField, z.ZodTypeDef, import("../types/index").TinaField>, "many">;
|
|
38
38
|
}, "strip", z.ZodTypeAny, {
|
|
39
39
|
name?: string;
|
|
40
|
-
fields?: import("
|
|
40
|
+
fields?: import("../types/index").TinaField[];
|
|
41
41
|
label?: string;
|
|
42
42
|
}, {
|
|
43
43
|
name?: string;
|
|
44
|
-
fields?: import("
|
|
44
|
+
fields?: import("../types/index").TinaField[];
|
|
45
45
|
label?: string;
|
|
46
46
|
}>, {
|
|
47
47
|
name?: string;
|
|
48
|
-
fields?: import("
|
|
48
|
+
fields?: import("../types/index").TinaField[];
|
|
49
49
|
label?: string;
|
|
50
50
|
}, {
|
|
51
51
|
name?: string;
|
|
52
|
-
fields?: import("
|
|
52
|
+
fields?: import("../types/index").TinaField[];
|
|
53
53
|
label?: string;
|
|
54
54
|
}>, "many">>, {
|
|
55
55
|
name?: string;
|
|
56
|
-
fields?: import("
|
|
56
|
+
fields?: import("../types/index").TinaField[];
|
|
57
57
|
label?: string;
|
|
58
58
|
}[], {
|
|
59
59
|
name?: string;
|
|
60
|
-
fields?: import("
|
|
60
|
+
fields?: import("../types/index").TinaField[];
|
|
61
61
|
label?: string;
|
|
62
62
|
}[]>;
|
|
63
63
|
}>, "strip", z.ZodTypeAny, {
|
|
64
64
|
name?: string;
|
|
65
65
|
templates?: {
|
|
66
66
|
name?: string;
|
|
67
|
-
fields?: import("
|
|
67
|
+
fields?: import("../types/index").TinaField[];
|
|
68
68
|
label?: string;
|
|
69
69
|
}[];
|
|
70
|
-
fields?: import("
|
|
70
|
+
fields?: import("../types/index").TinaField[];
|
|
71
71
|
label?: string;
|
|
72
72
|
path?: string;
|
|
73
|
-
format?: "
|
|
73
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
74
74
|
isDetached?: boolean;
|
|
75
75
|
isAuthCollection?: boolean;
|
|
76
76
|
}, {
|
|
77
77
|
name?: string;
|
|
78
78
|
templates?: {
|
|
79
79
|
name?: string;
|
|
80
|
-
fields?: import("
|
|
80
|
+
fields?: import("../types/index").TinaField[];
|
|
81
81
|
label?: string;
|
|
82
82
|
}[];
|
|
83
|
-
fields?: import("
|
|
83
|
+
fields?: import("../types/index").TinaField[];
|
|
84
84
|
label?: string;
|
|
85
85
|
path?: string;
|
|
86
|
-
format?: "
|
|
86
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
87
87
|
isDetached?: boolean;
|
|
88
88
|
isAuthCollection?: boolean;
|
|
89
89
|
}>, {
|
|
90
90
|
name?: string;
|
|
91
91
|
templates?: {
|
|
92
92
|
name?: string;
|
|
93
|
-
fields?: import("
|
|
93
|
+
fields?: import("../types/index").TinaField[];
|
|
94
94
|
label?: string;
|
|
95
95
|
}[];
|
|
96
|
-
fields?: import("
|
|
96
|
+
fields?: import("../types/index").TinaField[];
|
|
97
97
|
label?: string;
|
|
98
98
|
path?: string;
|
|
99
|
-
format?: "
|
|
99
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
100
100
|
isDetached?: boolean;
|
|
101
101
|
isAuthCollection?: boolean;
|
|
102
102
|
}, {
|
|
103
103
|
name?: string;
|
|
104
104
|
templates?: {
|
|
105
105
|
name?: string;
|
|
106
|
-
fields?: import("
|
|
106
|
+
fields?: import("../types/index").TinaField[];
|
|
107
107
|
label?: string;
|
|
108
108
|
}[];
|
|
109
|
-
fields?: import("
|
|
109
|
+
fields?: import("../types/index").TinaField[];
|
|
110
110
|
label?: string;
|
|
111
111
|
path?: string;
|
|
112
|
-
format?: "
|
|
112
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
113
113
|
isDetached?: boolean;
|
|
114
114
|
isAuthCollection?: boolean;
|
|
115
115
|
}>, "many">;
|
|
@@ -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
|
};
|
|
@@ -237,13 +274,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
237
274
|
name?: string;
|
|
238
275
|
templates?: {
|
|
239
276
|
name?: string;
|
|
240
|
-
fields?: import("
|
|
277
|
+
fields?: import("../types/index").TinaField[];
|
|
241
278
|
label?: string;
|
|
242
279
|
}[];
|
|
243
|
-
fields?: import("
|
|
280
|
+
fields?: import("../types/index").TinaField[];
|
|
244
281
|
label?: string;
|
|
245
282
|
path?: string;
|
|
246
|
-
format?: "
|
|
283
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
247
284
|
isDetached?: boolean;
|
|
248
285
|
isAuthCollection?: boolean;
|
|
249
286
|
}[];
|
|
@@ -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
|
};
|
|
@@ -275,13 +319,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
275
319
|
name?: string;
|
|
276
320
|
templates?: {
|
|
277
321
|
name?: string;
|
|
278
|
-
fields?: import("
|
|
322
|
+
fields?: import("../types/index").TinaField[];
|
|
279
323
|
label?: string;
|
|
280
324
|
}[];
|
|
281
|
-
fields?: import("
|
|
325
|
+
fields?: import("../types/index").TinaField[];
|
|
282
326
|
label?: string;
|
|
283
327
|
path?: string;
|
|
284
|
-
format?: "
|
|
328
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
285
329
|
isDetached?: boolean;
|
|
286
330
|
isAuthCollection?: boolean;
|
|
287
331
|
}[];
|
|
@@ -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
|
};
|
|
@@ -313,13 +364,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
313
364
|
name?: string;
|
|
314
365
|
templates?: {
|
|
315
366
|
name?: string;
|
|
316
|
-
fields?: import("
|
|
367
|
+
fields?: import("../types/index").TinaField[];
|
|
317
368
|
label?: string;
|
|
318
369
|
}[];
|
|
319
|
-
fields?: import("
|
|
370
|
+
fields?: import("../types/index").TinaField[];
|
|
320
371
|
label?: string;
|
|
321
372
|
path?: string;
|
|
322
|
-
format?: "
|
|
373
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
323
374
|
isDetached?: boolean;
|
|
324
375
|
isAuthCollection?: boolean;
|
|
325
376
|
}[];
|
|
@@ -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
|
};
|
|
@@ -351,13 +409,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
351
409
|
name?: string;
|
|
352
410
|
templates?: {
|
|
353
411
|
name?: string;
|
|
354
|
-
fields?: import("
|
|
412
|
+
fields?: import("../types/index").TinaField[];
|
|
355
413
|
label?: string;
|
|
356
414
|
}[];
|
|
357
|
-
fields?: import("
|
|
415
|
+
fields?: import("../types/index").TinaField[];
|
|
358
416
|
label?: string;
|
|
359
417
|
path?: string;
|
|
360
|
-
format?: "
|
|
418
|
+
format?: "mdx" | "md" | "markdown" | "json" | "yaml" | "yml" | "toml";
|
|
361
419
|
isDetached?: boolean;
|
|
362
420
|
isAuthCollection?: boolean;
|
|
363
421
|
}[];
|
|
@@ -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-ccab7a5-20251124054446",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"ts-jest": "^29.2.5",
|
|
33
33
|
"typescript": "^5.7.3",
|
|
34
34
|
"yup": "^0.32.11",
|
|
35
|
-
"@tinacms/scripts": "
|
|
35
|
+
"@tinacms/scripts": "0.0.0-ccab7a5-20251124054446"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=16.14.0",
|