tinacms 0.67.2 → 0.68.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/CHANGELOG.md CHANGED
@@ -1,5 +1,191 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.68.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6a6f137ae: # Simplify GraphQL API
8
+
9
+ ## `schema` must be supplied to the `<TinaCMS>` component
10
+
11
+ Previously the `.tina/schema.ts` was only used by the Tina CLI to generate the GraphQL API. However it's now required as a prop to `<TinaCMS>`. This allows you to provide runtime logic in the `ui` property of field definitions. See the documentation on "Extending Tina" for examples.
12
+
13
+ ## The GraphQL API has been simplified
14
+
15
+ ### `get<collection name>` is now just the collection name
16
+
17
+ ```graphql
18
+ # old
19
+ {
20
+ getPostDocument(relativePath: $relativePath) { ... }
21
+ }
22
+
23
+ # new
24
+ {
25
+ post(relativePath: $relativePath) { ... }
26
+ }
27
+ ```
28
+
29
+ ### `get<collection name>List` is now `<collection name>Connection`
30
+
31
+ The use of the term `connection` is due to our adherence the the [relay cursor spec](https://relay.dev/graphql/connections.htm). We may offer a simplified list field in a future release
32
+
33
+ ```graphql
34
+ # old
35
+ {
36
+ getPostList { ... }
37
+ }
38
+
39
+ # new
40
+ {
41
+ postConnection { ... }
42
+ }
43
+ ```
44
+
45
+ ### `getCollection` and `getCollections` are now `collection` and `collections`
46
+
47
+ ```graphql
48
+ # old
49
+ {
50
+ getCollection(collection: "post") {...}
51
+ }
52
+ {
53
+ getCollections {...}
54
+ }
55
+
56
+ # new
57
+ {
58
+ collection(collection: "post") {...}
59
+ }
60
+ {
61
+ collections {...}
62
+ }
63
+ ```
64
+
65
+ ### No more `data` property
66
+
67
+ The `data` property was previously where all field definitions could be found. This has been moved on level up:
68
+
69
+ ```graphql
70
+ # old
71
+ {
72
+ getPostDocument(relativePath: $relativePath) {
73
+ data {
74
+ title
75
+ }
76
+ }
77
+ }
78
+
79
+ # new
80
+ {
81
+ post(relativePath: $relativePath) {
82
+ title
83
+ }
84
+ }
85
+ ```
86
+
87
+ #### The type for documents no longer includes "Document" at the end
88
+
89
+ ```graphql
90
+ # old
91
+ {
92
+ getPostDocument(relativePath: $relativePath) {
93
+ data {
94
+ author {
95
+ ... on AuthorDocument {
96
+ data {
97
+ name
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ # new
106
+ {
107
+ post(relativePath: $relativePath) {
108
+ author {
109
+ ... on Author {
110
+ name
111
+ }
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Meta fields are now underscored
118
+
119
+ Aside from `id`, other metadata is now underscored:
120
+
121
+ ```graphql
122
+ # old
123
+ {
124
+ getPostDocument(relativePath: $relativePath) {
125
+ sys {
126
+ relativePath
127
+ }
128
+ values
129
+ }
130
+ }
131
+
132
+ # new
133
+ {
134
+ post(relativePath: $relativePath) {
135
+ _sys {
136
+ relativePath
137
+ }
138
+ _values
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### `dataJSON` is gone
144
+
145
+ This is identical to `_values`
146
+
147
+ ### `form` is gone
148
+
149
+ `form` was used internally to generate forms for the given document, however that's now handled by providing your `schema` to `<TinaCMS>`.
150
+
151
+ ### `getDocumentList` is gone
152
+
153
+ It's no longer possible to query all documents at once, you can query for collection documents via the `collection` query:
154
+
155
+ ```graphql
156
+ {
157
+ collection {
158
+ documents {
159
+ edges {
160
+ node {...}
161
+ }
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies [6a6f137ae]
170
+ - @tinacms/toolkit@0.56.23
171
+
172
+ ## 0.67.4
173
+
174
+ ### Patch Changes
175
+
176
+ - 168f6cc6e: Update delete modal header
177
+ - 2a6060138: Fix url parsing issue when a branch name contained a `/`
178
+ - 3af3d6787: Fix issues with finding the template for multitemplate collections
179
+ - Updated dependencies [bf5fe0074]
180
+ - @tinacms/toolkit@0.56.22
181
+
182
+ ## 0.67.3
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies [d37562999]
187
+ - @tinacms/toolkit@0.56.21
188
+
3
189
  ## 0.67.2
4
190
 
5
191
  ### Patch Changes
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import type { TinaCMS } from '@tinacms/toolkit';
14
- import type { Collection, DocumentForm, GetDocumentFields } from './types';
14
+ import type { Collection, DocumentForm } from './types';
15
15
  export declare class TinaAdminApi {
16
16
  api: {
17
17
  request: (query: string, { variables }: {
@@ -19,22 +19,18 @@ export declare class TinaAdminApi {
19
19
  }) => any;
20
20
  isAuthenticated: () => boolean;
21
21
  };
22
+ schema: any;
22
23
  constructor(cms: TinaCMS);
23
24
  isAuthenticated(): Promise<boolean>;
24
- fetchCollections(): Promise<{
25
- getCollections: Collection[];
26
- }>;
25
+ fetchCollections(): Promise<Collection[]>;
27
26
  deleteDocument({ collection, relativePath, }: {
28
27
  collection: string;
29
28
  relativePath: string;
30
29
  }): Promise<void>;
31
- fetchCollection(collectionName: string, includeDocuments: boolean): Promise<{
32
- getCollection: Collection;
33
- }>;
30
+ fetchCollection(collectionName: string, includeDocuments: boolean): Promise<Collection>;
34
31
  fetchDocument(collectionName: string, relativePath: string): Promise<{
35
- getDocument: DocumentForm;
32
+ document: DocumentForm;
36
33
  }>;
37
- fetchDocumentFields(): Promise<GetDocumentFields>;
38
34
  createDocument(collectionName: string, relativePath: string, params: Object): Promise<any>;
39
35
  updateDocument(collectionName: string, relativePath: string, params: Object): Promise<any>;
40
36
  }
@@ -17,7 +17,7 @@ export interface Template {
17
17
  }
18
18
  export interface DocumentNode {
19
19
  node: {
20
- sys: {
20
+ _sys: {
21
21
  template: string;
22
22
  breadcrumbs: string[];
23
23
  path: string;
@@ -29,21 +29,10 @@ export interface DocumentNode {
29
29
  };
30
30
  }
31
31
  export interface DocumentForm {
32
- form: {
33
- label: string;
34
- name: string;
35
- fields: Object[];
36
- mutationInfo: {
37
- path: string[];
38
- string: string;
39
- includeCollection: boolean;
40
- includeTemplate: boolean;
41
- };
42
- };
43
- values: Object;
32
+ _values: Object;
44
33
  }
45
34
  export interface DocumentSys {
46
- sys: {
35
+ _sys: {
47
36
  template: string;
48
37
  breadcrumbs: string[];
49
38
  path: string;
@@ -56,6 +45,7 @@ export interface DocumentSys {
56
45
  export interface Collection {
57
46
  label: string;
58
47
  name: string;
48
+ slug: string;
59
49
  format?: string;
60
50
  templates?: Template[];
61
51
  documents?: {
@@ -63,10 +53,3 @@ export interface Collection {
63
53
  edges?: DocumentNode[];
64
54
  };
65
55
  }
66
- export interface GetDocumentFields {
67
- [collectionName: string]: {
68
- collection: Object;
69
- templates?: Object[];
70
- fields?: Object[];
71
- };
72
- }
@@ -85,5 +85,6 @@ export declare function buildPath({ fieldNode, type, parentTypename, path, }: {
85
85
  }): BlueprintPath[];
86
86
  export declare const metaFields: G.SelectionNode[];
87
87
  export declare const getRelativeBlueprint: (path: BlueprintPath[]) => string;
88
+ export declare const isSysField: (fieldNode: G.FieldNode) => boolean;
88
89
  export declare const getBlueprintId: (path: BlueprintPath[]) => string;
89
90
  export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
@@ -12,7 +12,6 @@ limitations under the License.
12
12
  */
13
13
  import * as G from 'graphql';
14
14
  import type { DocumentBlueprint } from './types';
15
- export declare const DATA_NODE_NAME = "data";
16
15
  export declare const formify: ({ schema, query, getOptimizedQuery, }: {
17
16
  schema: G.GraphQLSchema;
18
17
  query: string;
@@ -12,7 +12,7 @@ limitations under the License.
12
12
  */
13
13
  /// <reference types="react" />
14
14
  import type * as G from 'graphql';
15
- import type { Form, Field } from '@tinacms/toolkit';
15
+ import type { Form } from '@tinacms/toolkit';
16
16
  export declare type Action = {
17
17
  type: 'start';
18
18
  value: {
@@ -58,20 +58,12 @@ export declare type FormifiedDocumentNode = {
58
58
  id: string;
59
59
  _internalSys: {
60
60
  path: string;
61
+ relativePath: string;
61
62
  collection: {
62
63
  name: any;
63
64
  };
64
65
  };
65
- form: {
66
- mutationInfo: {
67
- string: string;
68
- includeCollection?: boolean;
69
- includeTemplate?: boolean;
70
- };
71
- label: string;
72
- fields: Field[];
73
- };
74
- values: object;
66
+ _values: object;
75
67
  };
76
68
  export declare type ChangeMutation = {
77
69
  type: 'change';
@@ -10,9 +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 { AnyField, Form } from '@tinacms/toolkit';
13
+ import { Form } from '@tinacms/toolkit';
14
14
  import type { FormOptions, TinaCMS } from '@tinacms/toolkit';
15
- export declare function useGraphqlFormsUnstable<T extends object>({ variables, onSubmit, query, formify, eventList, }: {
15
+ export declare function useGraphqlForms<T extends object>({ variables, onSubmit, query, formify, eventList, }: {
16
16
  query: string;
17
17
  variables: object;
18
18
  onSubmit?: (args: onSubmitArgs) => void;
@@ -24,12 +24,6 @@ export declare function useGraphqlFormsUnstable<T extends object>({ variables, o
24
24
  */
25
25
  eventList?: [];
26
26
  }): [T, Boolean];
27
- export declare function useGraphqlForms<T extends object>({ variables, onSubmit, formify, query, }: {
28
- query: string;
29
- variables: object;
30
- onSubmit?: (args: onSubmitArgs) => void;
31
- formify?: formifyCallback;
32
- }): [T, Boolean];
33
27
  export declare const transformDocumentIntoMutationRequestPayload: (document: {
34
28
  [key: string]: unknown;
35
29
  _collection: string;
@@ -39,8 +33,8 @@ export declare const transformDocumentIntoMutationRequestPayload: (document: {
39
33
  includeCollection?: boolean;
40
34
  includeTemplate?: boolean;
41
35
  }) => any;
42
- export declare const generateFormCreatorsUnstable: (cms: TinaCMS, showInSidebar?: boolean) => {
43
- createForm: (formConfig: any) => Form<any, AnyField>;
36
+ export declare const generateFormCreators: (cms: TinaCMS, showInSidebar?: boolean) => {
37
+ createForm: (formConfig: any) => Form<any, import("@tinacms/toolkit").AnyField>;
44
38
  createGlobalForm: GlobalFormCreator;
45
39
  };
46
40
  declare type FormCreator = (formConfig: FormOptions<any>) => Form;
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * from './client';
14
14
  export * from './auth';
15
15
  export * from './utils';
16
16
  export * from './tina-cms';
17
- export { useGraphqlForms, useGraphqlFormsUnstable, } from './hooks/use-graphql-forms';
17
+ export { useGraphqlForms } from './hooks/use-graphql-forms';
18
18
  export { useDocumentCreatorPlugin } from './hooks/use-content-creator';
19
19
  export * from '@tinacms/toolkit';
20
20
  export { TinaAdmin } from './admin';