@tinacms/schema-tools 1.4.2 → 1.4.3
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 +0 -3
- package/dist/index.es.js +13 -4
- package/dist/index.js +13 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/validate/schema.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -213,7 +213,8 @@ class TinaSchema {
|
|
|
213
213
|
return false;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
const path = collection.path ? collection.path.replace(/\/?$/, "/") : "";
|
|
217
|
+
return filepath.replace(/\\/g, "/").startsWith(path);
|
|
217
218
|
});
|
|
218
219
|
if (possibleCollections.length === 0) {
|
|
219
220
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
|
@@ -448,14 +449,15 @@ Visit https://tina.io/docs/reference/types/rich-text/#custom-shortcode-syntax to
|
|
|
448
449
|
var _a, _b;
|
|
449
450
|
const collection = typeof collectionOrString === "string" ? this.getCollection(collectionOrString) : collectionOrString;
|
|
450
451
|
const normalPath = normalizePath(collection.path);
|
|
452
|
+
const pathSuffix = normalPath ? "/" : "";
|
|
451
453
|
const format = collection.format || "md";
|
|
452
454
|
const matches = [];
|
|
453
455
|
if ((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) {
|
|
454
|
-
const match = `${normalPath}
|
|
456
|
+
const match = `${normalPath}${pathSuffix}${collection.match.include}.${format}`;
|
|
455
457
|
matches.push(match);
|
|
456
458
|
}
|
|
457
459
|
if ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude) {
|
|
458
|
-
const exclude = `!(${normalPath}
|
|
460
|
+
const exclude = `!(${normalPath}${pathSuffix}${collection.match.exclude}.${format})`;
|
|
459
461
|
matches.push(exclude);
|
|
460
462
|
}
|
|
461
463
|
return matches;
|
|
@@ -926,7 +928,14 @@ const CollectionBaseSchema = z.object({
|
|
|
926
928
|
});
|
|
927
929
|
}
|
|
928
930
|
}),
|
|
929
|
-
path: z.string().transform((val) => val.replace(/^\/|\/$/g, "")),
|
|
931
|
+
path: z.string().transform((val) => val.replace(/^\/|\/$/g, "")).superRefine((val, ctx) => {
|
|
932
|
+
if (val === ".") {
|
|
933
|
+
ctx.addIssue({
|
|
934
|
+
code: z.ZodIssueCode.custom,
|
|
935
|
+
message: `path cannot be '.'. Please use '/' or '' instead. `
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
}),
|
|
930
939
|
format: z.enum(FORMATS).optional()
|
|
931
940
|
});
|
|
932
941
|
const TinaCloudCollection = CollectionBaseSchema.extend({
|
package/dist/index.js
CHANGED
|
@@ -240,7 +240,8 @@
|
|
|
240
240
|
return false;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
const path = collection.path ? collection.path.replace(/\/?$/, "/") : "";
|
|
244
|
+
return filepath.replace(/\\/g, "/").startsWith(path);
|
|
244
245
|
});
|
|
245
246
|
if (possibleCollections.length === 0) {
|
|
246
247
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
|
@@ -475,14 +476,15 @@ Visit https://tina.io/docs/reference/types/rich-text/#custom-shortcode-syntax to
|
|
|
475
476
|
var _a, _b;
|
|
476
477
|
const collection = typeof collectionOrString === "string" ? this.getCollection(collectionOrString) : collectionOrString;
|
|
477
478
|
const normalPath = normalizePath(collection.path);
|
|
479
|
+
const pathSuffix = normalPath ? "/" : "";
|
|
478
480
|
const format = collection.format || "md";
|
|
479
481
|
const matches = [];
|
|
480
482
|
if ((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) {
|
|
481
|
-
const match = `${normalPath}
|
|
483
|
+
const match = `${normalPath}${pathSuffix}${collection.match.include}.${format}`;
|
|
482
484
|
matches.push(match);
|
|
483
485
|
}
|
|
484
486
|
if ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude) {
|
|
485
|
-
const exclude = `!(${normalPath}
|
|
487
|
+
const exclude = `!(${normalPath}${pathSuffix}${collection.match.exclude}.${format})`;
|
|
486
488
|
matches.push(exclude);
|
|
487
489
|
}
|
|
488
490
|
return matches;
|
|
@@ -953,7 +955,14 @@ ${JSON.stringify(val, null, 2)}
|
|
|
953
955
|
});
|
|
954
956
|
}
|
|
955
957
|
}),
|
|
956
|
-
path: z.z.string().transform((val) => val.replace(/^\/|\/$/g, "")),
|
|
958
|
+
path: z.z.string().transform((val) => val.replace(/^\/|\/$/g, "")).superRefine((val, ctx) => {
|
|
959
|
+
if (val === ".") {
|
|
960
|
+
ctx.addIssue({
|
|
961
|
+
code: z.z.ZodIssueCode.custom,
|
|
962
|
+
message: `path cannot be '.'. Please use '/' or '' instead. `
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}),
|
|
957
966
|
format: z.z.enum(FORMATS).optional()
|
|
958
967
|
});
|
|
959
968
|
const TinaCloudCollection = CollectionBaseSchema.extend({
|
package/dist/types/index.d.ts
CHANGED
|
@@ -244,6 +244,7 @@ declare type MaybeNamespace<WithNamespace extends boolean = false> = WithNamespa
|
|
|
244
244
|
export declare type Template<WithNamespace extends boolean = false> = {
|
|
245
245
|
label?: string | boolean;
|
|
246
246
|
name: string;
|
|
247
|
+
nameOverride?: string;
|
|
247
248
|
ui?: {
|
|
248
249
|
/**
|
|
249
250
|
* Override the properties passed to the field
|
|
@@ -5,7 +5,7 @@ import { z } from 'zod';
|
|
|
5
5
|
export declare const CollectionBaseSchema: z.ZodObject<{
|
|
6
6
|
label: z.ZodOptional<z.ZodString>;
|
|
7
7
|
name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
8
|
-
path: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
+
path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
9
9
|
format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx", "toml", "yaml", "yml"]>>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
name?: string;
|
|
@@ -22,7 +22,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
22
22
|
collections: z.ZodArray<z.ZodEffects<z.ZodObject<z.extendShape<{
|
|
23
23
|
label: z.ZodOptional<z.ZodString>;
|
|
24
24
|
name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
25
|
-
path: z.ZodEffects<z.ZodString, string, string>;
|
|
25
|
+
path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
26
26
|
format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx", "toml", "yaml", "yml"]>>;
|
|
27
27
|
}, {
|
|
28
28
|
fields: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodType<import("..").TinaField<false>, z.ZodTypeDef, import("..").TinaField<false>>, "many">>, import("..").TinaField<false>[], import("..").TinaField<false>[]>, import("..").TinaField<false>[], import("..").TinaField<false>[]>;
|