@tinacms/schema-tools 0.1.4 → 0.1.6

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.
@@ -49,9 +49,7 @@ export declare class TinaSchema {
49
49
  getGlobalTemplate: (templateName: string) => {
50
50
  label: string;
51
51
  name: string;
52
- ui?: object | (import("../types").UIField<any, any> & {
53
- previewSrc: string;
54
- });
52
+ ui?: import("../types").UICollection;
55
53
  fields: import("../types").TinaFieldInner<true>[];
56
54
  namespace: string[];
57
55
  };
@@ -20,6 +20,9 @@ export declare type UIField<F extends UIField = any, Shape = any> = {
20
20
  parse?: (value: Shape, name: string, field: F) => any;
21
21
  format?: (value: Shape, name: string, field: F) => any;
22
22
  validate?(value: Shape, allValues: any, meta: any, field: UIField<F, Shape>): string | object | undefined | void;
23
+ /**
24
+ * @deprecated use `defaultItem` at the collection level instead
25
+ */
23
26
  defaultValue?: Shape;
24
27
  };
25
28
  export interface TinaCloudSchema<WithNamespace extends boolean, Store = any> {
@@ -62,44 +65,50 @@ export declare type TinaIndex = {
62
65
  name: string;
63
66
  }[];
64
67
  };
68
+ export interface UICollection {
69
+ filename?: {
70
+ slugify?: (values: unknown) => string;
71
+ disabled?: boolean;
72
+ };
73
+ /**
74
+ * Forms for this collection will be editable from the global sidebar rather than the form panel
75
+ */
76
+ global?: boolean | {
77
+ icon?: any;
78
+ layout: 'fullscreen' | 'popup';
79
+ };
80
+ /**
81
+ * Provide the path that your document is viewable on your site
82
+ *
83
+ * eg:
84
+ * ```ts
85
+ * router: ({ document }) => {
86
+ * return `blog-posts/${document._sys.filename}`;
87
+ * }
88
+ * ```
89
+ */
90
+ router?: (args: {
91
+ document: Document;
92
+ collection: TinaCloudCollection<true>;
93
+ }) => string | undefined;
94
+ }
65
95
  interface BaseCollection {
66
96
  label?: string;
67
97
  name: string;
68
98
  path: string;
99
+ defaultItem?: () => unknown | unknown;
69
100
  indexes?: TinaIndex[];
70
101
  format?: FormatType;
71
- ui?: {
72
- /**
73
- * Forms for this collection will be editable from the global sidebar rather than the form panel
74
- */
75
- global?: boolean | {
76
- icon?: any;
77
- layout: 'fullscreen' | 'popup';
78
- };
79
- /**
80
- * Provide the path that your document is viewable on your site
81
- *
82
- * eg:
83
- * ```ts
84
- * router: ({ document }) => {
85
- * return `blog-posts/${document._sys.filename}`;
86
- * }
87
- * ```
88
- */
89
- router?: (args: {
90
- document: Document;
91
- collection: TinaCloudCollection<true>;
92
- }) => string | undefined;
93
- };
102
+ ui?: UICollection;
94
103
  match?: string;
95
104
  }
96
105
  declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
97
106
  interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
98
- templates: (string | Template<WithNamespace>)[];
107
+ templates: (string | GlobalTemplate<WithNamespace>)[];
99
108
  fields?: undefined;
100
109
  }
101
110
  export interface CollectionTemplatesWithNamespace<WithNamespace extends boolean> extends BaseCollection {
102
- templates: (string | Template<WithNamespace>)[];
111
+ templates: (string | GlobalTemplate<WithNamespace>)[];
103
112
  fields?: undefined;
104
113
  references?: ReferenceType<WithNamespace>[];
105
114
  namespace: WithNamespace extends true ? string[] : undefined;
@@ -330,17 +339,13 @@ interface InnerObjectFieldsWithNamespace<WithNamespace extends boolean> extends
330
339
  export declare type GlobalTemplate<WithNamespace extends boolean> = WithNamespace extends true ? {
331
340
  label: string;
332
341
  name: string;
333
- ui?: object | (UIField<any, any> & {
334
- previewSrc: string;
335
- });
342
+ ui?: UICollection;
336
343
  fields: TinaFieldInner<WithNamespace>[];
337
344
  namespace: WithNamespace extends true ? string[] : undefined;
338
345
  } : {
339
346
  label: string;
340
347
  name: string;
341
- ui?: object | (UIField<any, any> & {
342
- previewSrc: string;
343
- });
348
+ ui?: UICollection;
344
349
  fields: TinaFieldInner<WithNamespace>[];
345
350
  };
346
351
  export declare type TinaCloudTemplateBase = GlobalTemplate<false>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {