@tinacms/schema-tools 0.0.2 → 0.0.5

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/CHANGELOG.md CHANGED
@@ -1,18 +1,37 @@
1
1
  # @tinacms/schema-tools
2
2
 
3
+ ## 0.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
8
+
9
+ ## 0.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
14
+
15
+ ## 0.0.3
16
+
17
+ ### Patch Changes
18
+
19
+ - 921709a7e: Adds validation to the schema instead of only using typescript types
20
+
3
21
  ## 0.0.2
22
+
4
23
  ### Patch Changes
5
24
 
6
25
  - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
7
-
26
+
8
27
  ### How to migrate.
9
-
28
+
10
29
  If you gone though the `tinacms init` process there should be a file called `.tina/components/TinaProvider`. In that file you can import the schema from `schema.ts` and add it to the TinaCMS wrapper component.
11
-
30
+
12
31
  ```tsx
13
32
  import TinaCMS from 'tinacms'
14
33
  import schema, { tinaConfig } from '../schema.ts'
15
-
34
+
16
35
  // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
17
36
  // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
18
37
  /**
@@ -26,8 +45,9 @@
26
45
  </TinaCMS>
27
46
  )
28
47
  }
29
-
48
+
30
49
  export default TinaProvider
31
50
  ```
51
+
32
52
  - 801f39f62: Update types
33
53
  - e8b0de1f7: Add `parentTypename` to fields to allow us to disambiguate between fields which have the same field names but different types. Example, an event from field name of `blocks.0.title` could belong to a `Cta` block or a `Hero` block, both of which have a `title` field.
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@ limitations under the License.
12
12
  */
13
13
  export * from './schema';
14
14
  export * from './types';
15
+ export * from './validate';
package/dist/index.js CHANGED
@@ -36,8 +36,8 @@ var __objRest = (source, exclude) => {
36
36
  };
37
37
  var __export = (target, all) => {
38
38
  __markAsModule(target);
39
- for (var name in all)
40
- __defProp(target, name, { get: all[name], enumerable: true });
39
+ for (var name2 in all)
40
+ __defProp(target, name2, { get: all[name2], enumerable: true });
41
41
  };
42
42
  var __reExport = (target, module2, desc) => {
43
43
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
@@ -54,9 +54,12 @@ var __toModule = (module2) => {
54
54
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/index.ts
55
55
  __export(exports, {
56
56
  TinaSchema: () => TinaSchema,
57
+ TinaSchemaValidationError: () => TinaSchemaValidationError,
57
58
  addNamespaceToSchema: () => addNamespaceToSchema,
58
59
  resolveField: () => resolveField,
59
- resolveForm: () => resolveForm
60
+ resolveForm: () => resolveForm,
61
+ validateSchema: () => validateSchema,
62
+ validateTinaCloudSchemaConfig: () => validateTinaCloudSchemaConfig
60
63
  });
61
64
 
62
65
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/addNamespaceToSchema.ts
@@ -170,10 +173,24 @@ var NAMER = {
170
173
  }
171
174
  };
172
175
 
176
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/util/hasDuplicates.ts
177
+ function hasDuplicates(array) {
178
+ if (!array) {
179
+ return false;
180
+ } else {
181
+ return new Set(array).size !== array.length;
182
+ }
183
+ }
184
+
173
185
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/TinaSchema.ts
174
186
  var TinaSchema = class {
175
187
  constructor(config) {
176
188
  this.config = config;
189
+ this.getIsTitleFieldName = (collection) => {
190
+ const col = this.getCollection(collection);
191
+ const field = col == null ? void 0 : col.fields.find((x) => x.type === "string" && x.isTitle);
192
+ return field == null ? void 0 : field.name;
193
+ };
177
194
  this.getCollectionsByName = (collectionNames) => {
178
195
  return this.schema.collections.filter((collection) => collectionNames.includes(collection.name));
179
196
  };
@@ -445,10 +462,304 @@ var resolveForm = ({
445
462
  })
446
463
  };
447
464
  };
465
+
466
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/index.ts
467
+ var import_zod5 = __toModule(require("zod"));
468
+
469
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/util/parseZodErrors.ts
470
+ var parseZodError = ({ zodError }) => {
471
+ var _a, _b;
472
+ const errors = zodError.flatten((issue) => {
473
+ const moreInfo = [];
474
+ if (issue.code === "invalid_union") {
475
+ issue.unionErrors.map((unionError) => {
476
+ moreInfo.push(parseZodError({ zodError: unionError }));
477
+ });
478
+ }
479
+ const errorMessage = `Error ${issue == null ? void 0 : issue.message} at path ${issue.path.join(".")}`;
480
+ const errorMessages = [errorMessage, ...moreInfo];
481
+ return {
482
+ errors: errorMessages
483
+ };
484
+ });
485
+ const formErrors = errors.formErrors.flatMap((x) => x.errors);
486
+ const parsedErrors = [
487
+ ...((_b = (_a = errors.fieldErrors) == null ? void 0 : _a.collections) == null ? void 0 : _b.flatMap((x) => x.errors)) || [],
488
+ ...formErrors
489
+ ];
490
+ return parsedErrors;
491
+ };
492
+
493
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/schema.ts
494
+ var import_zod4 = __toModule(require("zod"));
495
+
496
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/properties.ts
497
+ var import_zod = __toModule(require("zod"));
498
+ var name = import_zod.z.string({
499
+ required_error: "Name is required but not provided",
500
+ invalid_type_error: "Name must be a string"
501
+ });
502
+
503
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/fields.ts
504
+ var import_zod2 = __toModule(require("zod"));
505
+ var TypeName = [
506
+ "string",
507
+ "boolean",
508
+ "number",
509
+ "datetime",
510
+ "image",
511
+ "object",
512
+ "reference",
513
+ "rich-text"
514
+ ];
515
+ var typeTypeError = `type must be one of ${TypeName.join(", ")}`;
516
+ var typeRequiredError = `type is required and must be one of ${TypeName.join(", ")}`;
517
+ var nameProp = import_zod2.z.string({
518
+ required_error: "name must be provided",
519
+ invalid_type_error: "name must be a sting"
520
+ });
521
+ var Option = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.object({ label: import_zod2.z.string(), value: import_zod2.z.string() })], {
522
+ errorMap: () => {
523
+ return {
524
+ message: "Invalid option array. Must be a string[] or {label: string, value: string}[]"
525
+ };
526
+ }
527
+ });
528
+ var TinaField = import_zod2.z.object({
529
+ name: nameProp,
530
+ label: import_zod2.z.string().optional(),
531
+ description: import_zod2.z.string().optional(),
532
+ required: import_zod2.z.boolean().optional()
533
+ });
534
+ var FieldWithList = TinaField.extend({ list: import_zod2.z.boolean().optional() });
535
+ var TinaScalerBase = FieldWithList.extend({
536
+ options: import_zod2.z.array(Option).optional()
537
+ });
538
+ var StringField = TinaScalerBase.extend({
539
+ type: import_zod2.z.literal("string", {
540
+ invalid_type_error: typeTypeError,
541
+ required_error: typeRequiredError
542
+ }),
543
+ isTitle: import_zod2.z.boolean().optional()
544
+ });
545
+ var BooleanField = TinaScalerBase.extend({
546
+ type: import_zod2.z.literal("boolean", {
547
+ invalid_type_error: typeTypeError,
548
+ required_error: typeRequiredError
549
+ })
550
+ });
551
+ var NumberField = TinaScalerBase.extend({
552
+ type: import_zod2.z.literal("number", {
553
+ invalid_type_error: typeTypeError,
554
+ required_error: typeRequiredError
555
+ })
556
+ });
557
+ var ImageField = TinaScalerBase.extend({
558
+ type: import_zod2.z.literal("image", {
559
+ invalid_type_error: typeTypeError,
560
+ required_error: typeRequiredError
561
+ })
562
+ });
563
+ var DateTimeField = TinaScalerBase.extend({
564
+ type: import_zod2.z.literal("datetime", {
565
+ invalid_type_error: typeTypeError,
566
+ required_error: typeRequiredError
567
+ }),
568
+ dateFormat: import_zod2.z.string().optional(),
569
+ timeFormat: import_zod2.z.string().optional()
570
+ });
571
+ var ReferenceField = FieldWithList.extend({
572
+ type: import_zod2.z.literal("reference", {
573
+ invalid_type_error: typeTypeError,
574
+ required_error: typeRequiredError
575
+ })
576
+ });
577
+ var TinaFieldZod = import_zod2.z.lazy(() => {
578
+ const TemplateTemp = import_zod2.z.object({
579
+ label: import_zod2.z.string(),
580
+ name: nameProp,
581
+ fields: import_zod2.z.array(TinaFieldZod)
582
+ }).refine((val) => {
583
+ var _a;
584
+ return !hasDuplicates((_a = val.fields) == null ? void 0 : _a.map((x) => x.name));
585
+ }, {
586
+ message: "Fields must have a unique name"
587
+ });
588
+ const ObjectField = FieldWithList.extend({
589
+ type: import_zod2.z.literal("object", {
590
+ invalid_type_error: typeTypeError,
591
+ required_error: typeRequiredError
592
+ }),
593
+ fields: import_zod2.z.array(TinaFieldZod).min(1).optional().refine((val) => !hasDuplicates(val == null ? void 0 : val.map((x) => x.name)), {
594
+ message: "Fields must have a unique name"
595
+ }),
596
+ templates: import_zod2.z.array(TemplateTemp).min(1).optional().refine((val) => !hasDuplicates(val == null ? void 0 : val.map((x) => x.name)), {
597
+ message: "Templates must have a unique name"
598
+ })
599
+ });
600
+ const RichTextField = FieldWithList.extend({
601
+ type: import_zod2.z.literal("rich-text", {
602
+ invalid_type_error: typeTypeError,
603
+ required_error: typeRequiredError
604
+ }),
605
+ templates: import_zod2.z.array(TemplateTemp).optional().refine((val) => !hasDuplicates(val == null ? void 0 : val.map((x) => x.name)), {
606
+ message: "Templates must have a unique name"
607
+ })
608
+ });
609
+ return import_zod2.z.discriminatedUnion("type", [
610
+ StringField,
611
+ BooleanField,
612
+ NumberField,
613
+ ImageField,
614
+ DateTimeField,
615
+ ReferenceField,
616
+ ObjectField,
617
+ RichTextField
618
+ ], {
619
+ errorMap: (issue, ctx) => {
620
+ var _a;
621
+ if (issue.code === "invalid_union_discriminator") {
622
+ return {
623
+ message: `Invalid \`type\` property. In the schema is 'type: ${(_a = ctx.data) == null ? void 0 : _a.type}' and expected one of ${TypeName.join(", ")}`
624
+ };
625
+ }
626
+ return {
627
+ message: issue.message
628
+ };
629
+ }
630
+ }).superRefine((val, ctx) => {
631
+ if (val.type === "string") {
632
+ if (val.isTitle) {
633
+ if (val.list) {
634
+ ctx.addIssue({
635
+ code: import_zod2.z.ZodIssueCode.custom,
636
+ message: "You can not have `list: true` when using `isTitle`"
637
+ });
638
+ }
639
+ if (!val.required) {
640
+ ctx.addIssue({
641
+ code: import_zod2.z.ZodIssueCode.custom,
642
+ message: "You must have { required: true } when using `isTitle`"
643
+ });
644
+ }
645
+ }
646
+ }
647
+ if (val.type === "object") {
648
+ const message = "Must provide one of templates or fields in your collection";
649
+ let isValid = Boolean(val == null ? void 0 : val.templates) || Boolean(val == null ? void 0 : val.fields);
650
+ if (!isValid) {
651
+ ctx.addIssue({
652
+ code: import_zod2.z.ZodIssueCode.custom,
653
+ message
654
+ });
655
+ return false;
656
+ } else {
657
+ isValid = !((val == null ? void 0 : val.templates) && (val == null ? void 0 : val.fields));
658
+ if (!isValid) {
659
+ ctx.addIssue({
660
+ code: import_zod2.z.ZodIssueCode.custom,
661
+ message
662
+ });
663
+ }
664
+ return isValid;
665
+ }
666
+ }
667
+ return true;
668
+ });
669
+ });
670
+
671
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/tinaCloudSchemaConfig.ts
672
+ var import_zod3 = __toModule(require("zod"));
673
+ var tinaConfigKey = import_zod3.default.object({
674
+ publicFolder: import_zod3.default.string(),
675
+ syncFolder: import_zod3.default.string()
676
+ }).strict().optional();
677
+ var tinaConfigZod = import_zod3.default.object({
678
+ media: import_zod3.default.object({
679
+ tina: tinaConfigKey
680
+ }).optional()
681
+ });
682
+ var validateTinaCloudSchemaConfig = (config) => {
683
+ const newConfig = tinaConfigZod.parse(config);
684
+ return newConfig;
685
+ };
686
+
687
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/schema.ts
688
+ var FORMATS = ["json", "md", "markdown", "mdx"];
689
+ var Template = import_zod4.z.object({
690
+ label: import_zod4.z.string({
691
+ invalid_type_error: "label must be a string",
692
+ required_error: "label was not provided but is required"
693
+ }),
694
+ name,
695
+ fields: import_zod4.z.array(TinaFieldZod)
696
+ }).refine((val) => {
697
+ var _a;
698
+ return !hasDuplicates((_a = val.fields) == null ? void 0 : _a.map((x) => x.name));
699
+ }, {
700
+ message: "Fields must have a unique name"
701
+ });
702
+ var TinaCloudCollectionBase = import_zod4.z.object({
703
+ label: import_zod4.z.string().optional(),
704
+ name,
705
+ format: import_zod4.z.enum(FORMATS).optional()
706
+ });
707
+ var TinaCloudCollection = TinaCloudCollectionBase.extend({
708
+ fields: import_zod4.z.array(TinaFieldZod).min(1).optional().refine((val) => !hasDuplicates(val == null ? void 0 : val.map((x) => x.name)), {
709
+ message: "Fields must have a unique name"
710
+ }).refine((val) => {
711
+ const arr = (val == null ? void 0 : val.filter((x) => x.type === "string" && x.isTitle)) || [];
712
+ return arr.length < 2;
713
+ }, {
714
+ message: "Fields can only have one use of `isTitle`"
715
+ }),
716
+ templates: import_zod4.z.array(Template).min(1).optional().refine((val) => !hasDuplicates(val == null ? void 0 : val.map((x) => x.name)), {
717
+ message: "Templates must have a unique name"
718
+ })
719
+ }).refine((val) => {
720
+ let isValid = Boolean(val == null ? void 0 : val.templates) || Boolean(val == null ? void 0 : val.fields);
721
+ if (!isValid) {
722
+ return false;
723
+ } else {
724
+ isValid = !((val == null ? void 0 : val.templates) && (val == null ? void 0 : val.fields));
725
+ return isValid;
726
+ }
727
+ }, { message: "Must provide one of templates or fields in your collection" });
728
+ var TinaCloudSchemaZod = import_zod4.z.object({
729
+ collections: import_zod4.z.array(TinaCloudCollection),
730
+ config: tinaConfigZod.optional()
731
+ }).refine((val) => !hasDuplicates(val.collections.map((x) => x.name)), {
732
+ message: "can not have two collections with the same name"
733
+ });
734
+
735
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/validate/index.ts
736
+ var TinaSchemaValidationError = class extends Error {
737
+ constructor(message) {
738
+ super(message);
739
+ this.name = "TinaSchemaValidationError";
740
+ }
741
+ };
742
+ var validateSchema = ({
743
+ config
744
+ }) => {
745
+ try {
746
+ TinaCloudSchemaZod.parse(config);
747
+ } catch (e) {
748
+ if (e instanceof import_zod5.ZodError) {
749
+ const errors = parseZodError({ zodError: e });
750
+ throw new TinaSchemaValidationError(errors.join(", \n"));
751
+ } else {
752
+ throw new Error(e);
753
+ }
754
+ }
755
+ };
448
756
  // Annotate the CommonJS export names for ESM import in node:
449
757
  0 && (module.exports = {
450
758
  TinaSchema,
759
+ TinaSchemaValidationError,
451
760
  addNamespaceToSchema,
452
761
  resolveField,
453
- resolveForm
762
+ resolveForm,
763
+ validateSchema,
764
+ validateTinaCloudSchemaConfig
454
765
  });
@@ -41,6 +41,7 @@ export declare class TinaSchema {
41
41
  version?: Version;
42
42
  meta?: Meta;
43
43
  } & TinaCloudSchemaBase);
44
+ getIsTitleFieldName: (collection: string) => string;
44
45
  getCollectionsByName: (collectionNames: string[]) => TinaCloudCollection<true>[];
45
46
  getAllCollectionPaths: () => string[];
46
47
  getCollection: (collectionName: string) => TinaCloudCollection<true>;
@@ -21,9 +21,18 @@ export declare type UIField<F extends UIField = any, Shape = any> = {
21
21
  validate?(value: Shape, allValues: any, meta: any, field: UIField<F, Shape>): string | object | undefined | void;
22
22
  defaultValue?: Shape;
23
23
  };
24
+ export interface TinaCloudSchemaConfig {
25
+ media?: {
26
+ tina?: {
27
+ publicFolder: string;
28
+ syncFolder: string;
29
+ };
30
+ };
31
+ }
24
32
  export interface TinaCloudSchema<WithNamespace extends boolean> {
25
33
  templates?: GlobalTemplate<WithNamespace>[];
26
34
  collections: TinaCloudCollection<WithNamespace>[];
35
+ config?: TinaCloudSchemaConfig;
27
36
  }
28
37
  export declare type TinaCloudSchemaBase = TinaCloudSchema<false>;
29
38
  export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
@@ -35,6 +44,7 @@ export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
35
44
  export interface TinaCloudSchemaWithNamespace {
36
45
  templates?: GlobalTemplate<true>[];
37
46
  collections: TinaCloudCollection<true>[];
47
+ config?: TinaCloudSchemaConfig;
38
48
  namespace: string[];
39
49
  }
40
50
  export declare type TinaCloudCollection<WithNamespace extends boolean> = CollectionFields<WithNamespace> | CollectionTemplates<WithNamespace>;
@@ -108,11 +118,13 @@ declare type StringField = {
108
118
  type: 'string';
109
119
  isBody?: boolean;
110
120
  list?: false;
121
+ isTitle?: boolean;
111
122
  ui?: UIField<any, string>;
112
123
  } | {
113
124
  type: 'string';
114
125
  isBody?: boolean;
115
126
  list: true;
127
+ isTitle?: never;
116
128
  ui?: UIField<any, string[]>;
117
129
  };
118
130
  declare type BooleanField = {
@@ -0,0 +1,13 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ export declare function hasDuplicates<T = any>(array: T[]): boolean;
@@ -14,3 +14,4 @@ export * from './validate';
14
14
  export * from './lastItem';
15
15
  export * from './namer';
16
16
  export * from './sequential';
17
+ export * from './hasDuplicates';
@@ -0,0 +1,16 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import type { ZodError } from 'zod';
14
+ export declare const parseZodError: ({ zodError }: {
15
+ zodError: ZodError;
16
+ }) => string[];
@@ -11,5 +11,5 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import * as yup from 'yup';
14
- import type { Schema } from 'yup';
15
- export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => Schema<any, any>, errorMessage?: string): asserts value is T;
14
+ import type { AnySchema } from 'yup';
15
+ export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => AnySchema, errorMessage?: string): asserts value is T;
@@ -0,0 +1,15 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { z } from 'zod';
14
+ import { TinaFieldInner } from '../types/SchemaTypes';
15
+ export declare const TinaFieldZod: z.ZodType<TinaFieldInner<false>>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { TinaCloudSchema } from '../types';
14
+ export { validateTinaCloudSchemaConfig } from './tinaCloudSchemaConfig';
15
+ export declare class TinaSchemaValidationError extends Error {
16
+ constructor(message: any);
17
+ }
18
+ export declare const validateSchema: ({ config, }: {
19
+ config: TinaCloudSchema<false>;
20
+ }) => void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { z } from 'zod';
14
+ export declare const name: z.ZodString;
@@ -0,0 +1,209 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { z } from 'zod';
14
+ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
15
+ collections: z.ZodArray<z.ZodEffects<z.ZodObject<z.extendShape<{
16
+ label: z.ZodOptional<z.ZodString>;
17
+ name: z.ZodString;
18
+ format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx"]>>;
19
+ }, {
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
+ templates: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
22
+ label: z.ZodString;
23
+ name: z.ZodString;
24
+ fields: z.ZodArray<z.ZodType<import("..").TinaFieldInner<false>, z.ZodTypeDef, import("..").TinaFieldInner<false>>, "many">;
25
+ }, "strip", z.ZodTypeAny, {
26
+ name?: string;
27
+ fields?: import("..").TinaFieldInner<false>[];
28
+ label?: string;
29
+ }, {
30
+ name?: string;
31
+ fields?: import("..").TinaFieldInner<false>[];
32
+ label?: string;
33
+ }>, {
34
+ name?: string;
35
+ fields?: import("..").TinaFieldInner<false>[];
36
+ label?: string;
37
+ }, {
38
+ name?: string;
39
+ fields?: import("..").TinaFieldInner<false>[];
40
+ label?: string;
41
+ }>, "many">>, {
42
+ name?: string;
43
+ fields?: import("..").TinaFieldInner<false>[];
44
+ label?: string;
45
+ }[], {
46
+ name?: string;
47
+ fields?: import("..").TinaFieldInner<false>[];
48
+ label?: string;
49
+ }[]>;
50
+ }>, "strip", z.ZodTypeAny, {
51
+ name?: string;
52
+ fields?: import("..").TinaFieldInner<false>[];
53
+ templates?: {
54
+ name?: string;
55
+ fields?: import("..").TinaFieldInner<false>[];
56
+ label?: string;
57
+ }[];
58
+ format?: "json" | "md" | "markdown" | "mdx";
59
+ label?: string;
60
+ }, {
61
+ name?: string;
62
+ fields?: import("..").TinaFieldInner<false>[];
63
+ templates?: {
64
+ name?: string;
65
+ fields?: import("..").TinaFieldInner<false>[];
66
+ label?: string;
67
+ }[];
68
+ format?: "json" | "md" | "markdown" | "mdx";
69
+ label?: string;
70
+ }>, {
71
+ name?: string;
72
+ fields?: import("..").TinaFieldInner<false>[];
73
+ templates?: {
74
+ name?: string;
75
+ fields?: import("..").TinaFieldInner<false>[];
76
+ label?: string;
77
+ }[];
78
+ format?: "json" | "md" | "markdown" | "mdx";
79
+ label?: string;
80
+ }, {
81
+ name?: string;
82
+ fields?: import("..").TinaFieldInner<false>[];
83
+ templates?: {
84
+ name?: string;
85
+ fields?: import("..").TinaFieldInner<false>[];
86
+ label?: string;
87
+ }[];
88
+ format?: "json" | "md" | "markdown" | "mdx";
89
+ label?: string;
90
+ }>, "many">;
91
+ config: z.ZodOptional<z.ZodObject<{
92
+ media: z.ZodOptional<z.ZodObject<{
93
+ tina: z.ZodOptional<z.ZodObject<{
94
+ publicFolder: z.ZodString;
95
+ syncFolder: z.ZodString;
96
+ }, "strict", z.ZodTypeAny, {
97
+ publicFolder?: string;
98
+ syncFolder?: string;
99
+ }, {
100
+ publicFolder?: string;
101
+ syncFolder?: string;
102
+ }>>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ tina?: {
105
+ publicFolder?: string;
106
+ syncFolder?: string;
107
+ };
108
+ }, {
109
+ tina?: {
110
+ publicFolder?: string;
111
+ syncFolder?: string;
112
+ };
113
+ }>>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ media?: {
116
+ tina?: {
117
+ publicFolder?: string;
118
+ syncFolder?: string;
119
+ };
120
+ };
121
+ }, {
122
+ media?: {
123
+ tina?: {
124
+ publicFolder?: string;
125
+ syncFolder?: string;
126
+ };
127
+ };
128
+ }>>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ collections?: {
131
+ name?: string;
132
+ fields?: import("..").TinaFieldInner<false>[];
133
+ templates?: {
134
+ name?: string;
135
+ fields?: import("..").TinaFieldInner<false>[];
136
+ label?: string;
137
+ }[];
138
+ format?: "json" | "md" | "markdown" | "mdx";
139
+ label?: string;
140
+ }[];
141
+ config?: {
142
+ media?: {
143
+ tina?: {
144
+ publicFolder?: string;
145
+ syncFolder?: string;
146
+ };
147
+ };
148
+ };
149
+ }, {
150
+ collections?: {
151
+ name?: string;
152
+ fields?: import("..").TinaFieldInner<false>[];
153
+ templates?: {
154
+ name?: string;
155
+ fields?: import("..").TinaFieldInner<false>[];
156
+ label?: string;
157
+ }[];
158
+ format?: "json" | "md" | "markdown" | "mdx";
159
+ label?: string;
160
+ }[];
161
+ config?: {
162
+ media?: {
163
+ tina?: {
164
+ publicFolder?: string;
165
+ syncFolder?: string;
166
+ };
167
+ };
168
+ };
169
+ }>, {
170
+ collections?: {
171
+ name?: string;
172
+ fields?: import("..").TinaFieldInner<false>[];
173
+ templates?: {
174
+ name?: string;
175
+ fields?: import("..").TinaFieldInner<false>[];
176
+ label?: string;
177
+ }[];
178
+ format?: "json" | "md" | "markdown" | "mdx";
179
+ label?: string;
180
+ }[];
181
+ config?: {
182
+ media?: {
183
+ tina?: {
184
+ publicFolder?: string;
185
+ syncFolder?: string;
186
+ };
187
+ };
188
+ };
189
+ }, {
190
+ collections?: {
191
+ name?: string;
192
+ fields?: import("..").TinaFieldInner<false>[];
193
+ templates?: {
194
+ name?: string;
195
+ fields?: import("..").TinaFieldInner<false>[];
196
+ label?: string;
197
+ }[];
198
+ format?: "json" | "md" | "markdown" | "mdx";
199
+ label?: string;
200
+ }[];
201
+ config?: {
202
+ media?: {
203
+ tina?: {
204
+ publicFolder?: string;
205
+ syncFolder?: string;
206
+ };
207
+ };
208
+ };
209
+ }>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { TinaCloudSchemaConfig } from '../types';
14
+ import z from 'zod';
15
+ export declare const tinaConfigZod: z.ZodObject<{
16
+ media: z.ZodOptional<z.ZodObject<{
17
+ tina: z.ZodOptional<z.ZodObject<{
18
+ publicFolder: z.ZodString;
19
+ syncFolder: z.ZodString;
20
+ }, "strict", z.ZodTypeAny, {
21
+ publicFolder?: string;
22
+ syncFolder?: string;
23
+ }, {
24
+ publicFolder?: string;
25
+ syncFolder?: string;
26
+ }>>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ tina?: {
29
+ publicFolder?: string;
30
+ syncFolder?: string;
31
+ };
32
+ }, {
33
+ tina?: {
34
+ publicFolder?: string;
35
+ syncFolder?: string;
36
+ };
37
+ }>>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ media?: {
40
+ tina?: {
41
+ publicFolder?: string;
42
+ syncFolder?: string;
43
+ };
44
+ };
45
+ }, {
46
+ media?: {
47
+ tina?: {
48
+ publicFolder?: string;
49
+ syncFolder?: string;
50
+ };
51
+ };
52
+ }>;
53
+ export declare const validateTinaCloudSchemaConfig: (config: unknown) => TinaCloudSchemaConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -16,11 +16,12 @@
16
16
  ]
17
17
  },
18
18
  "devDependencies": {
19
- "@tinacms/scripts": "0.50.7",
19
+ "@tinacms/scripts": "0.50.8",
20
20
  "@types/yup": "^0.29.10",
21
21
  "jest": "^27.0.6",
22
22
  "react": "16.14.0",
23
- "typescript": "^4.3.5"
23
+ "typescript": "^4.3.5",
24
+ "yup": "^0.32.0"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "react": ">=16.14.0",
@@ -39,5 +40,8 @@
39
40
  "repository": {
40
41
  "url": "https://github.com/tinacms/tinacms.git",
41
42
  "directory": "packages/@tinacms/cli"
43
+ },
44
+ "dependencies": {
45
+ "zod": "^3.14.3"
42
46
  }
43
47
  }