@tinacms/schema-tools 0.0.9 → 0.1.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
@@ -374,6 +374,7 @@ const resolveField = ({ namespace, ...field }, schema) => {
374
374
  key: templateName,
375
375
  inline: template.inline,
376
376
  name: templateName,
377
+ match: template.match,
377
378
  fields: template.fields.map((field2) => resolveField(field2, schema)),
378
379
  ...extraFields2
379
380
  };
@@ -521,7 +522,11 @@ const TinaFieldZod = z.lazy(() => {
521
522
  const TemplateTemp = z.object({
522
523
  label: z.string(),
523
524
  name: nameProp,
524
- fields: z.array(TinaFieldZod)
525
+ fields: z.array(TinaFieldZod),
526
+ match: z.object({
527
+ start: z.string(),
528
+ end: z.string()
529
+ }).optional()
525
530
  }).refine((val) => {
526
531
  var _a;
527
532
  return !hasDuplicates((_a = val.fields) == null ? void 0 : _a.map((x) => x.name));
package/dist/index.js CHANGED
@@ -401,6 +401,7 @@
401
401
  key: templateName,
402
402
  inline: template.inline,
403
403
  name: templateName,
404
+ match: template.match,
404
405
  fields: template.fields.map((field2) => resolveField(field2, schema)),
405
406
  ...extraFields2
406
407
  };
@@ -548,7 +549,11 @@
548
549
  const TemplateTemp = z.z.object({
549
550
  label: z.z.string(),
550
551
  name: nameProp,
551
- fields: z.z.array(TinaFieldZod)
552
+ fields: z.z.array(TinaFieldZod),
553
+ match: z.z.object({
554
+ start: z.z.string(),
555
+ end: z.z.string()
556
+ }).optional()
552
557
  }).refine((val) => {
553
558
  var _a;
554
559
  return !hasDuplicates((_a = val.fields) == null ? void 0 : _a.map((x) => x.name));
@@ -10,8 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import { TinaSchema } from '../schema';
14
13
  import type { FC } from 'react';
14
+ import { TinaSchema } from '../schema';
15
+ import type { TinaCloudSchemaConfig } from './config';
15
16
  export declare type UIField<F extends UIField = any, Shape = any> = {
16
17
  label?: string;
17
18
  description?: string;
@@ -21,21 +22,6 @@ export declare type UIField<F extends UIField = any, Shape = any> = {
21
22
  validate?(value: Shape, allValues: any, meta: any, field: UIField<F, Shape>): string | object | undefined | void;
22
23
  defaultValue?: Shape;
23
24
  };
24
- export interface TinaCloudSchemaConfig<Store = any> {
25
- client?: {
26
- referenceDepth?: number;
27
- };
28
- clientId: string;
29
- branch: string;
30
- token: string;
31
- media?: {
32
- loadCustomStore?: () => Promise<Store>;
33
- tina?: {
34
- publicFolder: string;
35
- mediaRoot: string;
36
- };
37
- };
38
- }
39
25
  export interface TinaCloudSchema<WithNamespace extends boolean, Store = any> {
40
26
  templates?: GlobalTemplate<WithNamespace>[];
41
27
  collections: TinaCloudCollection<WithNamespace>[];
@@ -323,6 +309,10 @@ export declare type Template<WithNamespace extends boolean> = WithNamespace exte
323
309
  label: string;
324
310
  name: string;
325
311
  fields: TinaFieldInner<WithNamespace>[];
312
+ match?: {
313
+ start: string;
314
+ end: string;
315
+ };
326
316
  ui?: object | (UIField<any, any> & {
327
317
  previewSrc: string;
328
318
  });
@@ -334,6 +324,10 @@ export declare type Template<WithNamespace extends boolean> = WithNamespace exte
334
324
  previewSrc: string;
335
325
  });
336
326
  fields: TinaFieldInner<WithNamespace>[];
327
+ match?: {
328
+ start: string;
329
+ end: string;
330
+ };
337
331
  };
338
332
  export declare type CollectionTemplateableUnion = {
339
333
  namespace: string[];
@@ -366,4 +360,4 @@ export declare type ResolveFormArgs = {
366
360
  template: Templateable;
367
361
  schema: TinaSchema;
368
362
  };
369
- export {};
363
+ export * from './config';
@@ -0,0 +1,40 @@
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 interface TinaCloudSchemaConfig<Store = any> {
14
+ client?: {
15
+ referenceDepth?: number;
16
+ };
17
+ build?: {
18
+ publicFolder: string;
19
+ outputFolder: string;
20
+ };
21
+ /**
22
+ * The base branch to pull content from. Note that this is ignored for local development
23
+ */
24
+ branch?: string;
25
+ /**
26
+ * Your clientId from app.tina.io
27
+ */
28
+ clientId?: string;
29
+ /**
30
+ * Your read only token from app.tina.io
31
+ */
32
+ token?: string;
33
+ media?: {
34
+ loadCustomStore?: () => Promise<Store>;
35
+ tina?: {
36
+ publicFolder: string;
37
+ mediaRoot: string;
38
+ };
39
+ };
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  ]
24
24
  },
25
25
  "devDependencies": {
26
- "@tinacms/scripts": "0.50.9",
26
+ "@tinacms/scripts": "0.51.0",
27
27
  "@types/yup": "^0.29.10",
28
28
  "jest": "^27.0.6",
29
29
  "react": "17.0.2",