@tinacms/schema-tools 1.4.1 → 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 CHANGED
@@ -1,6 +1,3 @@
1
- /**
2
-
3
- */
4
1
  export * from './schema';
5
2
  export * from './types/index';
6
3
  export * from './validate';
package/dist/index.es.js CHANGED
@@ -213,7 +213,8 @@ class TinaSchema {
213
213
  return false;
214
214
  }
215
215
  }
216
- return filepath.replace(/\\/g, "/").startsWith(collection.path.replace(/\/?$/, "/"));
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}/${collection.match.include}.${format}`;
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}/${collection.match.exclude}.${format})`;
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
- return filepath.replace(/\\/g, "/").startsWith(collection.path.replace(/\/?$/, "/"));
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}/${collection.match.include}.${format}`;
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}/${collection.match.exclude}.${format})`;
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({
@@ -234,6 +234,7 @@ export declare type ObjectField<WithNamespace extends boolean = false> = (FieldG
234
234
  type: 'object';
235
235
  fields?: undefined;
236
236
  templates: Template<WithNamespace>[];
237
+ templateKey?: string;
237
238
  });
238
239
  declare type Field<WithNamespace extends boolean = false> = (StringField | NumberField | BooleanField | DateTimeField | ImageField | ReferenceField | RichTextField<WithNamespace> | ObjectField<WithNamespace>) & MaybeNamespace<WithNamespace>;
239
240
  export declare type TinaField<WithNamespace extends boolean = false> = Field<WithNamespace> & MaybeNamespace<WithNamespace>;
@@ -243,6 +244,7 @@ declare type MaybeNamespace<WithNamespace extends boolean = false> = WithNamespa
243
244
  export declare type Template<WithNamespace extends boolean = false> = {
244
245
  label?: string | boolean;
245
246
  name: string;
247
+ nameOverride?: string;
246
248
  ui?: {
247
249
  /**
248
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>[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {