@tinacms/schema-tools 1.1.0 → 1.2.0

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.es.js CHANGED
@@ -626,7 +626,8 @@ const TinaFieldZod = z.lazy(() => {
626
626
  fields: z.array(TinaFieldZod),
627
627
  match: z.object({
628
628
  start: z.string(),
629
- end: z.string()
629
+ end: z.string(),
630
+ name: z.string().optional()
630
631
  }).optional()
631
632
  }).superRefine((val, ctx) => {
632
633
  const dups = findDuplicates(val == null ? void 0 : val.fields.map((x) => x.name));
@@ -756,7 +757,7 @@ const validateTinaCloudSchemaConfig = (config) => {
756
757
  const newConfig = tinaConfigZod.parse(config);
757
758
  return newConfig;
758
759
  };
759
- const FORMATS = ["json", "md", "markdown", "mdx"];
760
+ const FORMATS = ["json", "md", "markdown", "mdx", "toml", "yaml"];
760
761
  const Template = z.object({
761
762
  label: z.string({
762
763
  invalid_type_error: "label must be a string",
package/dist/index.js CHANGED
@@ -653,7 +653,8 @@
653
653
  fields: z.z.array(TinaFieldZod),
654
654
  match: z.z.object({
655
655
  start: z.z.string(),
656
- end: z.z.string()
656
+ end: z.z.string(),
657
+ name: z.z.string().optional()
657
658
  }).optional()
658
659
  }).superRefine((val, ctx) => {
659
660
  const dups = findDuplicates(val == null ? void 0 : val.fields.map((x) => x.name));
@@ -783,7 +784,7 @@ ${JSON.stringify(val, null, 2)}
783
784
  const newConfig = tinaConfigZod.parse(config);
784
785
  return newConfig;
785
786
  };
786
- const FORMATS = ["json", "md", "markdown", "mdx"];
787
+ const FORMATS = ["json", "md", "markdown", "mdx", "toml", "yaml"];
787
788
  const Template = z.z.object({
788
789
  label: z.z.string({
789
790
  invalid_type_error: "label must be a string",
@@ -123,6 +123,14 @@ interface BaseCollection {
123
123
  defaultItem?: DefaultItem<Record<string, any>>;
124
124
  indexes?: TinaIndex[];
125
125
  format?: FormatType;
126
+ /**
127
+ * This format will be used to parse the markdown frontmatter
128
+ */
129
+ frontmatterFormat?: 'yaml' | 'toml' | 'json';
130
+ /**
131
+ * The delimiters used to parse the frontmatter.
132
+ */
133
+ frontmatterDelimiters?: [string, string] | string;
126
134
  ui?: UICollection;
127
135
  match?: string;
128
136
  }
@@ -410,6 +418,7 @@ export declare type Template<WithNamespace extends boolean> = WithNamespace exte
410
418
  match?: {
411
419
  start: string;
412
420
  end: string;
421
+ name?: string;
413
422
  };
414
423
  ui?: object | (UIField<any, any> & {
415
424
  previewSrc: string;
@@ -425,6 +434,7 @@ export declare type Template<WithNamespace extends boolean> = WithNamespace exte
425
434
  match?: {
426
435
  start: string;
427
436
  end: string;
437
+ name?: string;
428
438
  };
429
439
  };
430
440
  export declare type CollectionTemplateableUnion = {
@@ -108,6 +108,7 @@ declare type Template = {
108
108
  match?: {
109
109
  start: string;
110
110
  end: string;
111
+ name?: string;
111
112
  };
112
113
  };
113
114
  declare type WithTemplates<Optional extends boolean = false> = Optional extends true ? {
@@ -245,6 +245,7 @@ export declare type RichTextField = (FieldGeneric<RichTextAst, undefined> | Fiel
245
245
  match?: {
246
246
  start: string;
247
247
  end: string;
248
+ name?: string;
248
249
  };
249
250
  })[];
250
251
  };
package/dist/types.d.ts CHANGED
@@ -109,6 +109,8 @@ declare type Component<Type, List> = (props: {
109
109
  meta: Meta;
110
110
  }) => any;
111
111
  declare type UIField<Type, List extends boolean> = {
112
+ max?: List extends true ? number : never;
113
+ min?: List extends true ? number : never;
112
114
  /**
113
115
  * Override the label from parent object
114
116
  */
@@ -273,6 +275,7 @@ export declare type RichTextField = (FieldGeneric<RichTextAst, undefined> | Fiel
273
275
  match?: {
274
276
  start: string;
275
277
  end: string;
278
+ name?: string;
276
279
  };
277
280
  })[];
278
281
  };
@@ -330,7 +333,15 @@ export interface FieldCollection {
330
333
  label?: string;
331
334
  name: string;
332
335
  path: string;
333
- format?: 'json' | 'md' | 'markdown' | 'mdx';
336
+ format?: 'json' | 'md' | 'markdown' | 'mdx' | 'yaml' | 'toml';
337
+ /**
338
+ * This format will be used to parse the markdown frontmatter
339
+ */
340
+ frontmatterFormat?: 'yaml' | 'toml' | 'json';
341
+ /**
342
+ * The delimiters used to parse the frontmatter.
343
+ */
344
+ frontmatterDelimiters?: [string, string] | string;
334
345
  ui?: UICollection & {
335
346
  defaultItem?: DefaultItem<Record<string, any>>;
336
347
  };
@@ -350,7 +361,7 @@ export interface TemplateCollection {
350
361
  label?: string;
351
362
  name: string;
352
363
  path: string;
353
- format?: 'json' | 'md' | 'markdown' | 'mdx';
364
+ format?: 'json' | 'md' | 'markdown' | 'mdx' | 'yaml' | 'toml';
354
365
  ui?: UICollection;
355
366
  /**
356
367
  * @deprecated - use `ui.defaultItem` on the each `template` instead
@@ -15,7 +15,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
15
15
  collections: z.ZodArray<z.ZodEffects<z.ZodObject<z.extendShape<{
16
16
  label: z.ZodOptional<z.ZodString>;
17
17
  name: z.ZodEffects<z.ZodString, string, string>;
18
- format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx"]>>;
18
+ format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx", "toml", "yaml"]>>;
19
19
  }, {
20
20
  fields: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodType<import("..").TinaFieldInner<false>, z.ZodTypeDef, import("..").TinaFieldInner<false>>, "many">>, import("..").TinaFieldInner<false>[], import("..").TinaFieldInner<false>[]>, import("..").TinaFieldInner<false>[], import("..").TinaFieldInner<false>[]>;
21
21
  templates: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -55,7 +55,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
55
55
  fields?: import("..").TinaFieldInner<false>[];
56
56
  label?: string;
57
57
  }[];
58
- format?: "json" | "md" | "markdown" | "mdx";
58
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
59
59
  label?: string;
60
60
  }, {
61
61
  name?: string;
@@ -65,7 +65,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
65
65
  fields?: import("..").TinaFieldInner<false>[];
66
66
  label?: string;
67
67
  }[];
68
- format?: "json" | "md" | "markdown" | "mdx";
68
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
69
69
  label?: string;
70
70
  }>, {
71
71
  name?: string;
@@ -75,7 +75,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
75
75
  fields?: import("..").TinaFieldInner<false>[];
76
76
  label?: string;
77
77
  }[];
78
- format?: "json" | "md" | "markdown" | "mdx";
78
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
79
79
  label?: string;
80
80
  }, {
81
81
  name?: string;
@@ -85,7 +85,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
85
85
  fields?: import("..").TinaFieldInner<false>[];
86
86
  label?: string;
87
87
  }[];
88
- format?: "json" | "md" | "markdown" | "mdx";
88
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
89
89
  label?: string;
90
90
  }>, "many">;
91
91
  config: z.ZodOptional<z.ZodObject<{
@@ -153,7 +153,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
153
153
  fields?: import("..").TinaFieldInner<false>[];
154
154
  label?: string;
155
155
  }[];
156
- format?: "json" | "md" | "markdown" | "mdx";
156
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
157
157
  label?: string;
158
158
  }[];
159
159
  config?: {
@@ -177,7 +177,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
177
177
  fields?: import("..").TinaFieldInner<false>[];
178
178
  label?: string;
179
179
  }[];
180
- format?: "json" | "md" | "markdown" | "mdx";
180
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
181
181
  label?: string;
182
182
  }[];
183
183
  config?: {
@@ -201,7 +201,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
201
201
  fields?: import("..").TinaFieldInner<false>[];
202
202
  label?: string;
203
203
  }[];
204
- format?: "json" | "md" | "markdown" | "mdx";
204
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
205
205
  label?: string;
206
206
  }[];
207
207
  config?: {
@@ -225,7 +225,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
225
225
  fields?: import("..").TinaFieldInner<false>[];
226
226
  label?: string;
227
227
  }[];
228
- format?: "json" | "md" | "markdown" | "mdx";
228
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "toml";
229
229
  label?: string;
230
230
  }[];
231
231
  config?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -31,7 +31,7 @@
31
31
  ]
32
32
  },
33
33
  "devDependencies": {
34
- "@tinacms/scripts": "1.0.0",
34
+ "@tinacms/scripts": "1.0.1",
35
35
  "@types/yup": "^0.29.10",
36
36
  "jest": "^27.0.6",
37
37
  "react": "17.0.2",