@tinacms/schema-tools 0.0.8 → 0.0.9

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
@@ -113,8 +113,9 @@ class TinaSchema {
113
113
  constructor(config) {
114
114
  this.config = config;
115
115
  this.getIsTitleFieldName = (collection) => {
116
+ var _a;
116
117
  const col = this.getCollection(collection);
117
- const field = col == null ? void 0 : col.fields.find((x) => x.type === "string" && x.isTitle);
118
+ const field = (_a = col == null ? void 0 : col.fields) == null ? void 0 : _a.find((x) => x.type === "string" && x.isTitle);
118
119
  return field == null ? void 0 : field.name;
119
120
  };
120
121
  this.getCollectionsByName = (collectionNames) => {
@@ -452,6 +453,13 @@ const typeRequiredError = `type is required and must be one of ${TypeName.join("
452
453
  const nameProp = z.string({
453
454
  required_error: "name must be provided",
454
455
  invalid_type_error: "name must be a sting"
456
+ }).superRefine((val, ctx) => {
457
+ if (val.includes(" "))
458
+ ctx.addIssue({
459
+ message: "name cannot contain spaces",
460
+ code: z.ZodIssueCode.custom,
461
+ fatal: true
462
+ });
455
463
  });
456
464
  const Option = z.union([z.string(), z.object({ label: z.string(), value: z.string() })], {
457
465
  errorMap: () => {
@@ -607,6 +615,7 @@ const tinaConfigKey = z$1.object({
607
615
  mediaRoot: z$1.string()
608
616
  }).strict().optional();
609
617
  const tinaConfigZod = z$1.object({
618
+ client: z$1.object({ referenceDepth: z$1.number().optional() }).optional(),
610
619
  media: z$1.object({
611
620
  tina: tinaConfigKey,
612
621
  loadCustomStore: z$1.function().optional()
@@ -660,7 +669,7 @@ const TinaCloudSchemaZod = z.object({
660
669
  collections: z.array(TinaCloudCollection),
661
670
  config: tinaConfigZod.optional()
662
671
  }).superRefine((val, ctx) => {
663
- var _a;
672
+ var _a, _b;
664
673
  if (hasDuplicates(val.collections.map((x) => x.name))) {
665
674
  ctx.addIssue({
666
675
  code: z.ZodIssueCode.custom,
@@ -668,7 +677,12 @@ const TinaCloudSchemaZod = z.object({
668
677
  fatal: true
669
678
  });
670
679
  }
671
- const media = (_a = val == null ? void 0 : val.config) == null ? void 0 : _a.media;
680
+ (_a = val == null ? void 0 : val.collections) == null ? void 0 : _a.map((x) => {
681
+ if (!x.format) {
682
+ console.warn(`No format provided for collection ${x.name}, defaulting to .md`);
683
+ }
684
+ });
685
+ const media = (_b = val == null ? void 0 : val.config) == null ? void 0 : _b.media;
672
686
  if (media && media.tina && media.loadCustomStore) {
673
687
  ctx.addIssue({
674
688
  code: z.ZodIssueCode.custom,
package/dist/index.js CHANGED
@@ -140,8 +140,9 @@
140
140
  constructor(config) {
141
141
  this.config = config;
142
142
  this.getIsTitleFieldName = (collection) => {
143
+ var _a;
143
144
  const col = this.getCollection(collection);
144
- const field = col == null ? void 0 : col.fields.find((x) => x.type === "string" && x.isTitle);
145
+ const field = (_a = col == null ? void 0 : col.fields) == null ? void 0 : _a.find((x) => x.type === "string" && x.isTitle);
145
146
  return field == null ? void 0 : field.name;
146
147
  };
147
148
  this.getCollectionsByName = (collectionNames) => {
@@ -479,6 +480,13 @@
479
480
  const nameProp = z.z.string({
480
481
  required_error: "name must be provided",
481
482
  invalid_type_error: "name must be a sting"
483
+ }).superRefine((val, ctx) => {
484
+ if (val.includes(" "))
485
+ ctx.addIssue({
486
+ message: "name cannot contain spaces",
487
+ code: z.z.ZodIssueCode.custom,
488
+ fatal: true
489
+ });
482
490
  });
483
491
  const Option = z.z.union([z.z.string(), z.z.object({ label: z.z.string(), value: z.z.string() })], {
484
492
  errorMap: () => {
@@ -634,6 +642,7 @@
634
642
  mediaRoot: z__default["default"].string()
635
643
  }).strict().optional();
636
644
  const tinaConfigZod = z__default["default"].object({
645
+ client: z__default["default"].object({ referenceDepth: z__default["default"].number().optional() }).optional(),
637
646
  media: z__default["default"].object({
638
647
  tina: tinaConfigKey,
639
648
  loadCustomStore: z__default["default"].function().optional()
@@ -687,7 +696,7 @@
687
696
  collections: z.z.array(TinaCloudCollection),
688
697
  config: tinaConfigZod.optional()
689
698
  }).superRefine((val, ctx) => {
690
- var _a;
699
+ var _a, _b;
691
700
  if (hasDuplicates(val.collections.map((x) => x.name))) {
692
701
  ctx.addIssue({
693
702
  code: z.z.ZodIssueCode.custom,
@@ -695,7 +704,12 @@
695
704
  fatal: true
696
705
  });
697
706
  }
698
- const media = (_a = val == null ? void 0 : val.config) == null ? void 0 : _a.media;
707
+ (_a = val == null ? void 0 : val.collections) == null ? void 0 : _a.map((x) => {
708
+ if (!x.format) {
709
+ console.warn(`No format provided for collection ${x.name}, defaulting to .md`);
710
+ }
711
+ });
712
+ const media = (_b = val == null ? void 0 : val.config) == null ? void 0 : _b.media;
699
713
  if (media && media.tina && media.loadCustomStore) {
700
714
  ctx.addIssue({
701
715
  code: z.z.ZodIssueCode.custom,
@@ -22,6 +22,12 @@ export declare type UIField<F extends UIField = any, Shape = any> = {
22
22
  defaultValue?: Shape;
23
23
  };
24
24
  export interface TinaCloudSchemaConfig<Store = any> {
25
+ client?: {
26
+ referenceDepth?: number;
27
+ };
28
+ clientId: string;
29
+ branch: string;
30
+ token: string;
25
31
  media?: {
26
32
  loadCustomStore?: () => Promise<Store>;
27
33
  tina?: {
@@ -89,6 +89,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
89
89
  label?: string;
90
90
  }>, "many">;
91
91
  config: z.ZodOptional<z.ZodObject<{
92
+ client: z.ZodOptional<z.ZodObject<{
93
+ referenceDepth: z.ZodOptional<z.ZodNumber>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ referenceDepth?: number;
96
+ }, {
97
+ referenceDepth?: number;
98
+ }>>;
92
99
  media: z.ZodOptional<z.ZodObject<{
93
100
  tina: z.ZodOptional<z.ZodObject<{
94
101
  publicFolder: z.ZodString;
@@ -115,6 +122,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
115
122
  loadCustomStore?: (...args: unknown[]) => unknown;
116
123
  }>>;
117
124
  }, "strip", z.ZodTypeAny, {
125
+ client?: {
126
+ referenceDepth?: number;
127
+ };
118
128
  media?: {
119
129
  tina?: {
120
130
  publicFolder?: string;
@@ -123,6 +133,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
123
133
  loadCustomStore?: (...args: unknown[]) => unknown;
124
134
  };
125
135
  }, {
136
+ client?: {
137
+ referenceDepth?: number;
138
+ };
126
139
  media?: {
127
140
  tina?: {
128
141
  publicFolder?: string;
@@ -144,6 +157,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
144
157
  label?: string;
145
158
  }[];
146
159
  config?: {
160
+ client?: {
161
+ referenceDepth?: number;
162
+ };
147
163
  media?: {
148
164
  tina?: {
149
165
  publicFolder?: string;
@@ -165,6 +181,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
165
181
  label?: string;
166
182
  }[];
167
183
  config?: {
184
+ client?: {
185
+ referenceDepth?: number;
186
+ };
168
187
  media?: {
169
188
  tina?: {
170
189
  publicFolder?: string;
@@ -186,6 +205,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
186
205
  label?: string;
187
206
  }[];
188
207
  config?: {
208
+ client?: {
209
+ referenceDepth?: number;
210
+ };
189
211
  media?: {
190
212
  tina?: {
191
213
  publicFolder?: string;
@@ -207,6 +229,9 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
207
229
  label?: string;
208
230
  }[];
209
231
  config?: {
232
+ client?: {
233
+ referenceDepth?: number;
234
+ };
210
235
  media?: {
211
236
  tina?: {
212
237
  publicFolder?: string;
@@ -13,6 +13,13 @@ limitations under the License.
13
13
  import { TinaCloudSchemaConfig } from '../types';
14
14
  import z from 'zod';
15
15
  export declare const tinaConfigZod: z.ZodObject<{
16
+ client: z.ZodOptional<z.ZodObject<{
17
+ referenceDepth: z.ZodOptional<z.ZodNumber>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ referenceDepth?: number;
20
+ }, {
21
+ referenceDepth?: number;
22
+ }>>;
16
23
  media: z.ZodOptional<z.ZodObject<{
17
24
  tina: z.ZodOptional<z.ZodObject<{
18
25
  publicFolder: z.ZodString;
@@ -39,6 +46,9 @@ export declare const tinaConfigZod: z.ZodObject<{
39
46
  loadCustomStore?: (...args: unknown[]) => unknown;
40
47
  }>>;
41
48
  }, "strip", z.ZodTypeAny, {
49
+ client?: {
50
+ referenceDepth?: number;
51
+ };
42
52
  media?: {
43
53
  tina?: {
44
54
  publicFolder?: string;
@@ -47,6 +57,9 @@ export declare const tinaConfigZod: z.ZodObject<{
47
57
  loadCustomStore?: (...args: unknown[]) => unknown;
48
58
  };
49
59
  }, {
60
+ client?: {
61
+ referenceDepth?: number;
62
+ };
50
63
  media?: {
51
64
  tina?: {
52
65
  publicFolder?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {