tinacms 0.66.6 → 0.66.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/CHANGELOG.md +35 -0
- package/dist/admin/api.d.ts +2 -0
- package/dist/edit-state.es.js +5 -1
- package/dist/edit-state.js +5 -1
- package/dist/hooks/formify/formify.d.ts +23 -0
- package/dist/hooks/formify/index.d.ts +11 -43
- package/dist/hooks/formify/reducer.d.ts +26 -0
- package/dist/hooks/formify/test/{to-be-similar-to.d.ts → runner.d.ts} +1 -1
- package/dist/hooks/formify/test/util.d.ts +25 -0
- package/dist/hooks/formify/types.d.ts +176 -0
- package/dist/hooks/formify/util.d.ts +103 -2
- package/dist/hooks/use-graphql-forms.d.ts +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +2378 -1137
- package/dist/index.js +2518 -1276
- package/dist/rich-text.es.js +4 -11
- package/dist/rich-text.js +4 -11
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# tinacms
|
|
2
2
|
|
|
3
|
+
## 0.66.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 91d5a6073: Allow "." in file names
|
|
8
|
+
- 11d55f441: Add experimental useGraphQLForms hook
|
|
9
|
+
- f41bd62ea: Ensure client-side Tina code only runs on the browser. Without this check, we'd see a server/client mismatch like:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
warning.js:33 Warning: Expected server HTML to contain a matching <div> in <body>.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [e9a0c82cf]
|
|
16
|
+
- Updated dependencies [d4fdeaa9f]
|
|
17
|
+
- Updated dependencies [ed85f2594]
|
|
18
|
+
- Updated dependencies [d86e515ba]
|
|
19
|
+
- Updated dependencies [db0dab1d4]
|
|
20
|
+
- @tinacms/toolkit@0.56.18
|
|
21
|
+
|
|
22
|
+
## 0.66.8
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 4923a2d66: Checks isAuthenticated() before making requests to the GraphQL client
|
|
27
|
+
- Updated dependencies [106549814]
|
|
28
|
+
- Updated dependencies [4923a2d66]
|
|
29
|
+
- Updated dependencies [a07ff39bb]
|
|
30
|
+
- @tinacms/toolkit@0.56.17
|
|
31
|
+
|
|
32
|
+
## 0.66.7
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- bfada9a09: Used success messaging when creating/updating a Document in the CMS
|
|
37
|
+
|
|
3
38
|
## 0.66.6
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/admin/api.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export declare class TinaAdminApi {
|
|
|
17
17
|
request: (query: string, { variables }: {
|
|
18
18
|
variables: object;
|
|
19
19
|
}) => any;
|
|
20
|
+
isAuthenticated: () => boolean;
|
|
20
21
|
};
|
|
21
22
|
constructor(cms: TinaCMS);
|
|
23
|
+
isAuthenticated(): Promise<boolean>;
|
|
22
24
|
fetchCollections(): Promise<{
|
|
23
25
|
getCollections: Collection[];
|
|
24
26
|
}>;
|
package/dist/edit-state.es.js
CHANGED
|
@@ -97,7 +97,11 @@ const ToggleButton = () => {
|
|
|
97
97
|
};
|
|
98
98
|
const TinaEditProviderInner = ({ children, editMode }) => {
|
|
99
99
|
const { edit } = useEditState();
|
|
100
|
-
|
|
100
|
+
const [isBrowser, setIsBrowser] = React.useState(false);
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
setIsBrowser(true);
|
|
103
|
+
}, []);
|
|
104
|
+
if (edit && isBrowser) {
|
|
101
105
|
return editMode;
|
|
102
106
|
}
|
|
103
107
|
return children;
|
package/dist/edit-state.js
CHANGED
|
@@ -102,7 +102,11 @@ var __objRest = (source, exclude) => {
|
|
|
102
102
|
};
|
|
103
103
|
const TinaEditProviderInner = ({ children, editMode }) => {
|
|
104
104
|
const { edit } = sharedctx.useEditState();
|
|
105
|
-
|
|
105
|
+
const [isBrowser, setIsBrowser] = React__default["default"].useState(false);
|
|
106
|
+
React__default["default"].useEffect(() => {
|
|
107
|
+
setIsBrowser(true);
|
|
108
|
+
}, []);
|
|
109
|
+
if (edit && isBrowser) {
|
|
106
110
|
return editMode;
|
|
107
111
|
}
|
|
108
112
|
return children;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 * as G from 'graphql';
|
|
14
|
+
import type { DocumentBlueprint } from './types';
|
|
15
|
+
export declare const DATA_NODE_NAME = "data";
|
|
16
|
+
export declare const formify: ({ schema, query, getOptimizedQuery, }: {
|
|
17
|
+
schema: G.GraphQLSchema;
|
|
18
|
+
query: string;
|
|
19
|
+
getOptimizedQuery: (query: G.DocumentNode) => Promise<G.DocumentNode>;
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
formifiedQuery: G.DocumentNode;
|
|
22
|
+
blueprints: DocumentBlueprint[];
|
|
23
|
+
}>;
|
|
@@ -10,48 +10,16 @@ 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 { GraphQLSchema, DocumentNode } from 'graphql';
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import * as G from 'graphql';
|
|
16
13
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} | {
|
|
24
|
-
type: 'addNode';
|
|
25
|
-
value: DocNode;
|
|
26
|
-
};
|
|
27
|
-
export declare type DocNode = {
|
|
28
|
-
path: readonly (string | number)[];
|
|
29
|
-
};
|
|
30
|
-
export declare type Dispatch = React.Dispatch<Action>;
|
|
31
|
-
/**
|
|
32
|
-
* TODO: this is currently only used for testing, `formify` is where the primary logic is housed
|
|
33
|
-
*/
|
|
34
|
-
export declare const useFormify: ({ query, cms }: {
|
|
35
|
-
query: string;
|
|
14
|
+
import { formify } from './formify';
|
|
15
|
+
import { onSubmitArgs } from '../use-graphql-forms';
|
|
16
|
+
import type { OnChangeEvent, State } from './types';
|
|
17
|
+
export { formify };
|
|
18
|
+
export declare const useFormify: ({ query, cms, variables, onSubmit, formify: formifyFunc, eventList, }: {
|
|
19
|
+
query?: string;
|
|
36
20
|
cms: TinaCMS;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
declare type TinaDocumentNode = {
|
|
43
|
-
path: {
|
|
44
|
-
name: string;
|
|
45
|
-
alias: string;
|
|
46
|
-
list?: boolean;
|
|
47
|
-
}[];
|
|
48
|
-
};
|
|
49
|
-
export declare const formify: ({ schema, query, getOptimizedQuery, }: {
|
|
50
|
-
schema: GraphQLSchema;
|
|
51
|
-
query: string;
|
|
52
|
-
getOptimizedQuery: (query: DocumentNode) => Promise<DocumentNode>;
|
|
53
|
-
}) => Promise<{
|
|
54
|
-
formifiedQuery: DocumentNode;
|
|
55
|
-
nodes: TinaDocumentNode[];
|
|
56
|
-
}>;
|
|
57
|
-
export {};
|
|
21
|
+
variables: object;
|
|
22
|
+
onSubmit?: (args: onSubmitArgs) => void;
|
|
23
|
+
formify: any;
|
|
24
|
+
eventList?: OnChangeEvent[];
|
|
25
|
+
}) => State;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { FormNode, State, Action, OnChangeEvent } from './types';
|
|
14
|
+
export declare function reducer(state: State, action: Action): State;
|
|
15
|
+
export declare const buildChangeSet: (event: OnChangeEvent, formNode: FormNode) => {
|
|
16
|
+
fieldDefinition: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: "string" | "object" | "reference";
|
|
19
|
+
list?: boolean;
|
|
20
|
+
};
|
|
21
|
+
name: string;
|
|
22
|
+
formId: string;
|
|
23
|
+
mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
|
|
24
|
+
value: unknown;
|
|
25
|
+
formNode: FormNode;
|
|
26
|
+
};
|
|
@@ -10,4 +10,4 @@ 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
|
-
export
|
|
13
|
+
export declare const testRunner: (query: any, events: any, dirname: any) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { TinaCMS } from '@tinacms/toolkit';
|
|
14
|
+
import 'isomorphic-fetch';
|
|
15
|
+
/**
|
|
16
|
+
* We're just mocking the tina api so we can mimic the real-world getSchema
|
|
17
|
+
*/
|
|
18
|
+
declare const cms: TinaCMS;
|
|
19
|
+
export declare const printOutput: (event: any, previous: any, after: any) => string;
|
|
20
|
+
export { printState } from '../util';
|
|
21
|
+
export declare function sleep(ms: any): Promise<unknown>;
|
|
22
|
+
export { cms };
|
|
23
|
+
export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
|
|
24
|
+
export declare const buildFileOutput: (dirname: any) => string;
|
|
25
|
+
export declare const buildMarkdownOutput: (dirname: any, counter: any) => string;
|
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
14
|
+
import type * as G from 'graphql';
|
|
15
|
+
import type { Form, Field } from '@tinacms/toolkit';
|
|
16
|
+
export declare type Action = {
|
|
17
|
+
type: 'setData';
|
|
18
|
+
value: object;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'addDocumentBlueprints';
|
|
21
|
+
value: {
|
|
22
|
+
blueprints: DocumentBlueprint[];
|
|
23
|
+
formifiedQuery: G.DocumentNode;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
type: 'addOrReplaceDocumentFormNode';
|
|
27
|
+
value: {
|
|
28
|
+
formNode: FormNode;
|
|
29
|
+
documentForm?: DocumentForm;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
type: 'onFieldChange';
|
|
33
|
+
value: {
|
|
34
|
+
event: OnChangeEvent;
|
|
35
|
+
form?: Form;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
type: 'formOnReset';
|
|
39
|
+
value: {
|
|
40
|
+
event: OnChangeEvent;
|
|
41
|
+
form?: Form;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
type: 'ready';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'done';
|
|
47
|
+
} | {
|
|
48
|
+
type: 'setIn';
|
|
49
|
+
value: Pick<ChangeSet, 'path' | 'value' | 'displaceIndex'>;
|
|
50
|
+
};
|
|
51
|
+
export declare type Dispatch = React.Dispatch<Action>;
|
|
52
|
+
export declare type FormifiedDocumentNode = {
|
|
53
|
+
id: string;
|
|
54
|
+
_internalSys: {
|
|
55
|
+
path: string;
|
|
56
|
+
};
|
|
57
|
+
collection: {
|
|
58
|
+
name: any;
|
|
59
|
+
};
|
|
60
|
+
form: {
|
|
61
|
+
mutationInfo: {
|
|
62
|
+
string: string;
|
|
63
|
+
includeCollection?: boolean;
|
|
64
|
+
includeTemplate?: boolean;
|
|
65
|
+
};
|
|
66
|
+
label: string;
|
|
67
|
+
fields: Field[];
|
|
68
|
+
};
|
|
69
|
+
values: object;
|
|
70
|
+
};
|
|
71
|
+
export declare type ChangeMutation = {
|
|
72
|
+
type: 'change';
|
|
73
|
+
};
|
|
74
|
+
export declare type ReferenceChangeMutation = {
|
|
75
|
+
type: 'referenceChange';
|
|
76
|
+
};
|
|
77
|
+
export declare type InsertMutation = {
|
|
78
|
+
type: 'insert';
|
|
79
|
+
at: number;
|
|
80
|
+
};
|
|
81
|
+
export declare type MoveMutation = {
|
|
82
|
+
type: 'move';
|
|
83
|
+
from: number;
|
|
84
|
+
to: number;
|
|
85
|
+
};
|
|
86
|
+
export declare type RemoveMutation = {
|
|
87
|
+
type: 'remove';
|
|
88
|
+
at: number;
|
|
89
|
+
};
|
|
90
|
+
export declare type ResetMutation = {
|
|
91
|
+
type: 'reset';
|
|
92
|
+
};
|
|
93
|
+
export declare type GlobalMutation = {
|
|
94
|
+
type: 'global';
|
|
95
|
+
};
|
|
96
|
+
declare type MutationType = ChangeMutation | ReferenceChangeMutation | InsertMutation | MoveMutation | RemoveMutation | ResetMutation | GlobalMutation;
|
|
97
|
+
export declare type OnChangeEvent = {
|
|
98
|
+
type: 'forms:fields:onChange' | 'forms:reset';
|
|
99
|
+
value: unknown;
|
|
100
|
+
previousValue: unknown;
|
|
101
|
+
mutationType: MutationType;
|
|
102
|
+
formId: string;
|
|
103
|
+
field: {
|
|
104
|
+
data: {
|
|
105
|
+
tinaField: {
|
|
106
|
+
name: string;
|
|
107
|
+
type: 'string' | 'reference' | 'object';
|
|
108
|
+
list?: boolean;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
name: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export declare type ChangeSet = {
|
|
115
|
+
path: string;
|
|
116
|
+
value: unknown;
|
|
117
|
+
formId: string;
|
|
118
|
+
fieldDefinition: {
|
|
119
|
+
name: string;
|
|
120
|
+
type: 'string' | 'reference' | 'object';
|
|
121
|
+
list?: boolean;
|
|
122
|
+
};
|
|
123
|
+
mutationType: MutationType;
|
|
124
|
+
name: string;
|
|
125
|
+
displaceIndex?: boolean;
|
|
126
|
+
formNode: FormNode;
|
|
127
|
+
};
|
|
128
|
+
export declare type BlueprintPath = {
|
|
129
|
+
name: string;
|
|
130
|
+
alias: string;
|
|
131
|
+
list?: boolean;
|
|
132
|
+
isNode?: boolean;
|
|
133
|
+
};
|
|
134
|
+
export declare type DocumentBlueprint = {
|
|
135
|
+
/** The stringified representation of a path relative to root or it's parent document */
|
|
136
|
+
id: string;
|
|
137
|
+
/** The path to a field node */
|
|
138
|
+
path: BlueprintPath[];
|
|
139
|
+
/** The GraphQL SelectionNode, useful for re-fetching the given node */
|
|
140
|
+
selection: G.SelectionNode;
|
|
141
|
+
fields: FieldBlueprint[];
|
|
142
|
+
/** For now, only top-level, non-list nodes will be shown in the sidebar */
|
|
143
|
+
showInSidebar: boolean;
|
|
144
|
+
/** these 2 are not traditional GraphQL fields but need be kept in-sync regardless */
|
|
145
|
+
hasDataJSONField: boolean;
|
|
146
|
+
hasValuesField: boolean;
|
|
147
|
+
};
|
|
148
|
+
export declare type FieldBlueprint = {
|
|
149
|
+
/** The stringified representation of a path relative to root or it's parent document */
|
|
150
|
+
id: string;
|
|
151
|
+
documentBlueprintId: string;
|
|
152
|
+
/** The path to a field node */
|
|
153
|
+
path: BlueprintPath[];
|
|
154
|
+
};
|
|
155
|
+
export declare type FormNode = {
|
|
156
|
+
/** The stringified path with location values injected (eg. 'getBlockPageList.edges.0.node.data.social.1.relatedPage') */
|
|
157
|
+
documentFormId: string;
|
|
158
|
+
documentBlueprintId: string;
|
|
159
|
+
/** Coordinates for the DocumentBlueprint's '[]' values */
|
|
160
|
+
location: number[];
|
|
161
|
+
};
|
|
162
|
+
/** The document ID is the true ID 'content/pages/hello-world.md') */
|
|
163
|
+
declare type DocumentForm = Form;
|
|
164
|
+
export declare type State = {
|
|
165
|
+
schema: G.GraphQLSchema;
|
|
166
|
+
query: G.DocumentNode;
|
|
167
|
+
queryString: string;
|
|
168
|
+
status: 'initialized' | 'formified' | 'ready' | 'done';
|
|
169
|
+
count: number;
|
|
170
|
+
data: object;
|
|
171
|
+
changeSets: ChangeSet[];
|
|
172
|
+
blueprints: DocumentBlueprint[];
|
|
173
|
+
formNodes: FormNode[];
|
|
174
|
+
documentForms: DocumentForm[];
|
|
175
|
+
};
|
|
176
|
+
export {};
|
|
@@ -11,8 +11,12 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import * as G from 'graphql';
|
|
14
|
+
import { Form, Field, TinaCMS } from '@tinacms/toolkit';
|
|
15
|
+
import type { DocumentBlueprint, FieldBlueprint, BlueprintPath, FormifiedDocumentNode, OnChangeEvent, FormNode, State, ChangeSet } from './types';
|
|
16
|
+
import { formifyCallback, onSubmitArgs } from '../use-graphql-forms';
|
|
17
|
+
interface RecursiveFormifiedDocumentNode<T extends object> extends Array<RecursiveFormifiedDocumentNode<T> | T> {
|
|
18
|
+
}
|
|
14
19
|
export declare const isNodeField: (type: G.GraphQLNamedType) => boolean;
|
|
15
|
-
export declare const isCollectionField: (type: G.GraphQLNamedType) => boolean;
|
|
16
20
|
export declare const isConnectionField: (type: G.GraphQLNamedType) => boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Selects the appropriate field from a GraphQLObject based on the selection's name
|
|
@@ -31,6 +35,13 @@ export declare const getObjectField: (object: G.GraphQLObjectType<any, any>, sel
|
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
37
|
export declare const getSelectedUnionType: (unionType: G.GraphQLUnionType, selectionNode: G.InlineFragmentNode) => G.GraphQLObjectType<any, any>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the given type is a list type. Even though
|
|
40
|
+
* this function is built-in to GraphQL it doesn't handle
|
|
41
|
+
* the scenario where the list type is wrapped in a non-null
|
|
42
|
+
* type, so the extra check here is needed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isListType(type: unknown): boolean;
|
|
34
45
|
/**
|
|
35
46
|
*
|
|
36
47
|
* Throws an error if the provided type is no a GraphQLUnionType
|
|
@@ -51,9 +62,99 @@ export declare function ensureObjectType(type: unknown): asserts type is G.Graph
|
|
|
51
62
|
* Throws an error if the provided type is no a GraphQLUnionType
|
|
52
63
|
*/
|
|
53
64
|
export declare function ensureOperationDefinition(type: G.DefinitionNode): asserts type is G.OperationDefinitionNode;
|
|
54
|
-
export declare function getNameAndAlias(fieldNode: G.FieldNode, list
|
|
65
|
+
export declare function getNameAndAlias(fieldNode: G.FieldNode, list: boolean, isNode: boolean): {
|
|
55
66
|
name: string;
|
|
56
67
|
alias: string;
|
|
57
68
|
list: boolean;
|
|
69
|
+
isNode: boolean;
|
|
58
70
|
};
|
|
59
71
|
export declare const metaFields: G.SelectionNode[];
|
|
72
|
+
export declare const getRelativeBlueprint: (path: BlueprintPath[]) => string;
|
|
73
|
+
export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* ./index utilities
|
|
78
|
+
*
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
export declare const getIn2: <T extends object>(state: object, path: string) => T | RecursiveFormifiedDocumentNode<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the name of the field. In the example query, `title` and `t` would both be blueprint fields
|
|
84
|
+
*
|
|
85
|
+
* ```graphql
|
|
86
|
+
* {
|
|
87
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
88
|
+
* data {
|
|
89
|
+
* title,
|
|
90
|
+
* t: title # here `t` is an alias for title
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare const getFieldNameOrAlias: (fieldBlueprint: FieldBlueprint) => string;
|
|
97
|
+
export declare const buildForm: (doc: FormifiedDocumentNode, cms: TinaCMS, formify: formifyCallback, showInSidebar?: boolean, onSubmit?: (args: onSubmitArgs) => void) => Form;
|
|
98
|
+
export declare const formNodeId: (formNode: FormNode) => string;
|
|
99
|
+
export declare const formNodePath: (formNode: FormNode) => string;
|
|
100
|
+
export declare const formNodeNotIn: (formNode: FormNode, formNodes: FormNode[]) => boolean;
|
|
101
|
+
export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
|
|
102
|
+
export declare const getBlueprintId: (path: BlueprintPath[]) => string;
|
|
103
|
+
export declare const getFormNodesForField: (fieldBlueprint: FieldBlueprint, formNode: FormNode, event: OnChangeEvent, state: State) => {
|
|
104
|
+
pathToChange: string;
|
|
105
|
+
formNodes: FormNode[];
|
|
106
|
+
eventLocation: any[];
|
|
107
|
+
existing: any;
|
|
108
|
+
};
|
|
109
|
+
export declare const matchLocation: (eventLocation: number[], formNode: FormNode) => boolean;
|
|
110
|
+
export declare const bumpLocation: (location: number[]) => number[];
|
|
111
|
+
export declare const maybeLowerLocation: (location: number[], at: number) => number[];
|
|
112
|
+
export declare const matchesAt: (location: number[], at: number) => boolean;
|
|
113
|
+
export declare const swapLocation: (location: number[], mapping: {
|
|
114
|
+
[key: number]: number;
|
|
115
|
+
}) => number[];
|
|
116
|
+
export declare const getBlueprintAliasPath: (blueprint: DocumentBlueprint) => string;
|
|
117
|
+
export declare const getBlueprintFieldsForEvent: (blueprint: DocumentBlueprint, event: OnChangeEvent) => FieldBlueprint[];
|
|
118
|
+
export declare const getBlueprintNamePath: (blueprint: Pick<DocumentBlueprint, 'path'>) => string;
|
|
119
|
+
export declare const stripIndices: (string: any) => any[];
|
|
120
|
+
export declare const replaceRealNum: (string: any) => any;
|
|
121
|
+
export declare const getFormNodesFromEvent: (state: State, event: OnChangeEvent) => FormNode[];
|
|
122
|
+
export declare const printState: (state: State) => string;
|
|
123
|
+
export declare const printEvent: (event: OnChangeEvent) => {
|
|
124
|
+
type: "forms:fields:onChange" | "forms:reset";
|
|
125
|
+
value: unknown;
|
|
126
|
+
previousValue: unknown;
|
|
127
|
+
mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
|
|
128
|
+
formId: string;
|
|
129
|
+
field: {
|
|
130
|
+
data: {
|
|
131
|
+
tinaField: {
|
|
132
|
+
name: string;
|
|
133
|
+
type: "string" | "object" | "reference";
|
|
134
|
+
list?: boolean;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
name: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
export declare const getFormNodeBlueprint: (formNode: FormNode, state: State) => DocumentBlueprint;
|
|
141
|
+
export declare const getMoveMapping: (existing: any, from: any, to: any) => {
|
|
142
|
+
[key: number]: number;
|
|
143
|
+
};
|
|
144
|
+
export declare const getPathsToChange: (event: OnChangeEvent, state: State) => {
|
|
145
|
+
formNode: FormNode;
|
|
146
|
+
pathToChange: string;
|
|
147
|
+
}[];
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* Gets the sub-fields for an object field, if it's a polymorphic
|
|
151
|
+
* object then we also need to get the __typename, though
|
|
152
|
+
* we should probably supply that regardless. The current downside
|
|
153
|
+
* of this is that it needs to come from the server because we
|
|
154
|
+
* have no way of knowing what it would be from the client-side
|
|
155
|
+
*/
|
|
156
|
+
export declare const getSubFields: (changeSet: ChangeSet) => {
|
|
157
|
+
fields: Field[];
|
|
158
|
+
__typename: string;
|
|
159
|
+
};
|
|
160
|
+
export {};
|
|
@@ -12,6 +12,18 @@ limitations under the License.
|
|
|
12
12
|
*/
|
|
13
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, }: {
|
|
16
|
+
query: string;
|
|
17
|
+
variables: object;
|
|
18
|
+
onSubmit?: (args: onSubmitArgs) => void;
|
|
19
|
+
formify?: formifyCallback;
|
|
20
|
+
/**
|
|
21
|
+
* This is a test utility which allows us to keep track of all the events
|
|
22
|
+
* received by this hook. See `experimental-examples/unit-test-example/pages/index.js
|
|
23
|
+
* for usage.
|
|
24
|
+
*/
|
|
25
|
+
eventList?: [];
|
|
26
|
+
}): [T, Boolean];
|
|
15
27
|
export declare function useGraphqlForms<T extends object>({ variables, onSubmit, formify, query, }: {
|
|
16
28
|
query: string;
|
|
17
29
|
variables: object;
|
|
@@ -27,7 +39,16 @@ export declare const transformDocumentIntoMutationRequestPayload: (document: {
|
|
|
27
39
|
includeCollection?: boolean;
|
|
28
40
|
includeTemplate?: boolean;
|
|
29
41
|
}) => any;
|
|
42
|
+
export declare const generateFormCreatorsUnstable: (cms: TinaCMS, showInSidebar?: boolean) => {
|
|
43
|
+
createForm: (formConfig: any) => Form<any, import("@tinacms/toolkit").AnyField>;
|
|
44
|
+
createGlobalForm: GlobalFormCreator;
|
|
45
|
+
};
|
|
30
46
|
declare type FormCreator = (formConfig: FormOptions<any>) => Form;
|
|
47
|
+
declare type GlobalFormCreator = (formConfig: FormOptions<any>, options?: GlobalFormOptions) => Form;
|
|
48
|
+
interface GlobalFormOptions {
|
|
49
|
+
icon?: any;
|
|
50
|
+
layout: 'fullscreen' | 'popup';
|
|
51
|
+
}
|
|
31
52
|
export interface FormifyArgs {
|
|
32
53
|
formConfig: FormOptions<any>;
|
|
33
54
|
createForm: FormCreator;
|
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 } from './hooks/use-graphql-forms';
|
|
17
|
+
export { useGraphqlForms, useGraphqlFormsUnstable, } 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';
|