tinacms 1.2.2 → 1.3.1
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/admin/api.d.ts +3 -3
- package/dist/admin/components/FullscreenError.d.ts +5 -0
- package/dist/admin/components/GetCollection.d.ts +3 -3
- package/dist/admin/components/GetCollections.d.ts +1 -1
- package/dist/admin/plugins/route-mapping.d.ts +3 -3
- package/dist/admin/types.d.ts +3 -3
- package/dist/hooks/use-graphql-forms.d.ts +0 -12
- package/dist/index.d.ts +11 -20
- package/dist/index.es.js +335 -2425
- package/dist/index.js +337 -2428
- package/dist/internalClient/index.d.ts +3 -7
- package/dist/style.css +212 -188
- package/dist/tina-cms.d.ts +0 -5
- package/dist/types/cms.d.ts +3 -3
- package/dist/utils/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist/hooks/formify/formify-utils.d.ts +0 -81
- package/dist/hooks/formify/formify.d.ts +0 -13
- package/dist/hooks/formify/index.d.ts +0 -16
- package/dist/hooks/formify/reducer.d.ts +0 -18
- package/dist/hooks/formify/spec/runner.d.ts +0 -4
- package/dist/hooks/formify/spec/schema.d.ts +0 -3
- package/dist/hooks/formify/spec/util.d.ts +0 -16
- package/dist/hooks/formify/types.d.ts +0 -166
- package/dist/hooks/formify/util.d.ts +0 -139
package/dist/tina-cms.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
*/
|
|
4
4
|
/// <reference types="react" />
|
|
5
|
-
import type { formifyCallback } from './hooks/use-graphql-forms';
|
|
6
5
|
import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
|
|
7
6
|
import { TinaCMSProviderDefaultProps } from './types/cms';
|
|
8
7
|
/**
|
|
@@ -12,10 +11,6 @@ import { TinaCMSProviderDefaultProps } from './types/cms';
|
|
|
12
11
|
*/
|
|
13
12
|
export declare const TinaCMSProvider2: ({ query, documentCreatorCallback, formifyCallback, schema, ...props }: TinaCMSProviderDefaultProps) => JSX.Element;
|
|
14
13
|
export declare type DocumentCreatorCallback = Parameters<typeof useDocumentCreatorPlugin>[0];
|
|
15
|
-
export declare const TinaDataProvider: ({ children, formifyCallback, }: {
|
|
16
|
-
children: any;
|
|
17
|
-
formifyCallback: formifyCallback;
|
|
18
|
-
}) => JSX.Element;
|
|
19
14
|
/**
|
|
20
15
|
* @deprecated v0.62.0: Use `staticRequest` and a "try catch" block instead. see https://tina.io/docs/features/data-fetching/#querying-tina-content-in-nextjs for more details
|
|
21
16
|
*
|
package/dist/types/cms.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/// <reference types="react" />
|
|
5
5
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
6
|
-
import type {
|
|
6
|
+
import type { Schema, Config } from '@tinacms/schema-tools';
|
|
7
7
|
import type { TinaCloudMediaStoreClass } from '../auth';
|
|
8
8
|
import type { useDocumentCreatorPlugin } from '../hooks/use-content-creator';
|
|
9
9
|
import type { formifyCallback } from '../hooks/use-graphql-forms';
|
|
@@ -30,7 +30,7 @@ interface BaseProviderProps {
|
|
|
30
30
|
/** TinaCMS media store instance */
|
|
31
31
|
mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
|
|
32
32
|
tinaioConfig?: TinaIOConfig;
|
|
33
|
-
schema?:
|
|
33
|
+
schema?: Schema;
|
|
34
34
|
}
|
|
35
35
|
declare type QueryProviderProps = {
|
|
36
36
|
/** Your React page component */
|
|
@@ -51,5 +51,5 @@ declare type QueryProviderProps = {
|
|
|
51
51
|
/** The `data` from getStaticProps */
|
|
52
52
|
data?: never;
|
|
53
53
|
};
|
|
54
|
-
export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps &
|
|
54
|
+
export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps & Config;
|
|
55
55
|
export {};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Client } from '../internalClient';
|
|
5
5
|
import type { TinaIOConfig } from '../internalClient';
|
|
6
6
|
import * as yup from 'yup';
|
|
7
|
-
import {
|
|
7
|
+
import { Schema } from '@tinacms/schema-tools';
|
|
8
8
|
export interface CreateClientProps {
|
|
9
9
|
clientId?: string;
|
|
10
10
|
isLocalClient?: boolean;
|
|
@@ -12,7 +12,7 @@ export interface CreateClientProps {
|
|
|
12
12
|
owner?: string;
|
|
13
13
|
repo?: string;
|
|
14
14
|
branch?: string;
|
|
15
|
-
schema?:
|
|
15
|
+
schema?: Schema;
|
|
16
16
|
apiUrl?: string;
|
|
17
17
|
}
|
|
18
18
|
export declare const createClient: ({ clientId, isLocalClient, branch, tinaioConfig, schema, apiUrl, }: CreateClientProps) => Client;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"exports": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@headlessui/react": "^1.5.0",
|
|
57
57
|
"@heroicons/react": "^1.0.4",
|
|
58
58
|
"@react-hook/window-size": "^3.0.7",
|
|
59
|
-
"@tinacms/schema-tools": "1.3.
|
|
59
|
+
"@tinacms/schema-tools": "1.3.3",
|
|
60
60
|
"@tinacms/sharedctx": "1.0.1",
|
|
61
|
-
"@tinacms/toolkit": "1.
|
|
61
|
+
"@tinacms/toolkit": "1.5.0",
|
|
62
62
|
"crypto-js": "^4.0.0",
|
|
63
63
|
"encoding": "0.1.13",
|
|
64
64
|
"fetch-ponyfill": "^7.1.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@testing-library/react": "^12.0.0",
|
|
79
79
|
"@testing-library/react-hooks": "^7.0.2",
|
|
80
80
|
"@testing-library/user-event": "^12.7.0",
|
|
81
|
-
"@tinacms/scripts": "1.0.
|
|
81
|
+
"@tinacms/scripts": "1.0.4",
|
|
82
82
|
"@types/jest": "^27.0.1",
|
|
83
83
|
"@types/lodash": "^4.14.169",
|
|
84
84
|
"@types/node": "^14.0.13",
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import * as G from 'graphql';
|
|
5
|
-
import type { BlueprintPath } from './types';
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* This check ensures that at type is a Document, but only one
|
|
9
|
-
* that can be "formified". When using `Node` or `Document`, those
|
|
10
|
-
* query fields should not have forms generated since they can't contain
|
|
11
|
-
* fields.
|
|
12
|
-
*
|
|
13
|
-
* ```graphql
|
|
14
|
-
* # Can be formified
|
|
15
|
-
* {
|
|
16
|
-
* getPostDocument(relativePath: "") {
|
|
17
|
-
* data {
|
|
18
|
-
* title
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* ```graphql
|
|
25
|
-
* # cannot be formified, even though it is a document field
|
|
26
|
-
* {
|
|
27
|
-
* getPostDocument(relativePath: "") {
|
|
28
|
-
* ...on Document {
|
|
29
|
-
* id
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare const isFormifiableDocument: (t: G.GraphQLOutputType) => boolean;
|
|
36
|
-
export declare const isScalarType: (t: G.GraphQLOutputType) => boolean;
|
|
37
|
-
export declare const isConnectionField: (t: G.GraphQLOutputType) => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Selects the appropriate field from a GraphQLObject based on the selection's name
|
|
40
|
-
*/
|
|
41
|
-
export declare const getObjectField: (object: G.GraphQLOutputType, selectionNode: G.FieldNode) => G.GraphQLField<any, any, {
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* Selects the appropriate type from a union based on the selection's typeCondition
|
|
46
|
-
*
|
|
47
|
-
* ```graphql
|
|
48
|
-
* post {
|
|
49
|
-
* # would return PostDocument
|
|
50
|
-
* ...on PostDocument { ... }
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare const getSelectedUnionType: (unionType: G.GraphQLOutputType, selectionNode: G.InlineFragmentNode) => any;
|
|
55
|
-
/**
|
|
56
|
-
* Checks if the given type is a list type. Even though
|
|
57
|
-
* this function is built-in to GraphQL it doesn't handle
|
|
58
|
-
* the scenario where the list type is wrapped in a non-null
|
|
59
|
-
* type, so the extra check here is needed.
|
|
60
|
-
*/
|
|
61
|
-
export declare function isListType(type: unknown): boolean;
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* Throws an error if the provided type is not a GraphQLUnionType
|
|
65
|
-
*/
|
|
66
|
-
export declare function ensureOperationDefinition(type: G.DefinitionNode): asserts type is G.OperationDefinitionNode;
|
|
67
|
-
/**
|
|
68
|
-
* Generates the name and alias information for a given field node
|
|
69
|
-
* and appends it to a shallow copy of the path provided
|
|
70
|
-
*/
|
|
71
|
-
export declare function buildPath({ fieldNode, type, parentTypename, path, }: {
|
|
72
|
-
fieldNode: G.FieldNode;
|
|
73
|
-
type: G.GraphQLOutputType;
|
|
74
|
-
parentTypename?: string;
|
|
75
|
-
path?: BlueprintPath[];
|
|
76
|
-
}): BlueprintPath[];
|
|
77
|
-
export declare const metaFields: G.SelectionNode[];
|
|
78
|
-
export declare const getRelativeBlueprint: (path: BlueprintPath[]) => string;
|
|
79
|
-
export declare const isSysField: (fieldNode: G.FieldNode) => boolean;
|
|
80
|
-
export declare const getBlueprintId: (path: BlueprintPath[]) => string;
|
|
81
|
-
export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import * as G from 'graphql';
|
|
5
|
-
import type { DocumentBlueprint } from './types';
|
|
6
|
-
export declare const formify: ({ schema, query, getOptimizedQuery, }: {
|
|
7
|
-
schema: G.GraphQLSchema;
|
|
8
|
-
query: string;
|
|
9
|
-
getOptimizedQuery: (query: G.DocumentNode) => Promise<G.DocumentNode>;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
formifiedQuery: G.DocumentNode;
|
|
12
|
-
blueprints: DocumentBlueprint[];
|
|
13
|
-
}>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import type { TinaCMS } from '@tinacms/toolkit';
|
|
5
|
-
import { formify } from './formify';
|
|
6
|
-
import { onSubmitArgs } from '../use-graphql-forms';
|
|
7
|
-
import type { OnChangeEvent, State } from './types';
|
|
8
|
-
export { formify };
|
|
9
|
-
export declare const useFormify: ({ query, cms, variables, onSubmit, formify: formifyFunc, eventList, }: {
|
|
10
|
-
query?: string;
|
|
11
|
-
cms: TinaCMS;
|
|
12
|
-
variables: object;
|
|
13
|
-
onSubmit?: (args: onSubmitArgs) => void;
|
|
14
|
-
formify: any;
|
|
15
|
-
eventList?: OnChangeEvent[];
|
|
16
|
-
}) => State;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { FormNode, State, Action, OnChangeEvent } from './types';
|
|
5
|
-
export declare function reducer(state: State, action: Action): State;
|
|
6
|
-
export declare const buildChangeSet: (event: OnChangeEvent, formNode: FormNode) => {
|
|
7
|
-
fieldDefinition: {
|
|
8
|
-
name: string;
|
|
9
|
-
type: "string" | "object" | "reference";
|
|
10
|
-
list?: boolean;
|
|
11
|
-
parentTypename: string;
|
|
12
|
-
};
|
|
13
|
-
name: string;
|
|
14
|
-
formId: string;
|
|
15
|
-
mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
|
|
16
|
-
value: unknown;
|
|
17
|
-
formNode: FormNode;
|
|
18
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const schema: any;
|
|
2
|
-
export declare const tinaConfig: import("@tinacms/schema-tools/dist/types").Config<(cms: import("@tinacms/toolkit/dist/tina-cms").TinaCMS) => import("@tinacms/toolkit/dist/tina-cms").TinaCMS, import("../../use-graphql-forms").formifyCallback, import("../../use-content-creator").DocumentCreatorArgs, undefined>;
|
|
3
|
-
export default schema;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { TinaCMS } from '@tinacms/toolkit';
|
|
5
|
-
import 'isomorphic-fetch';
|
|
6
|
-
/**
|
|
7
|
-
* We're just mocking the tina api so we can mimic the real-world getSchema
|
|
8
|
-
*/
|
|
9
|
-
declare const cms: TinaCMS;
|
|
10
|
-
export declare const printOutput: (event: any, previous: any, after: any) => string;
|
|
11
|
-
export { printState } from '../util';
|
|
12
|
-
export declare function sleep(ms: any): Promise<unknown>;
|
|
13
|
-
export { cms };
|
|
14
|
-
export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
|
|
15
|
-
export declare const buildFileOutput: (dirname: any) => string;
|
|
16
|
-
export declare const buildMarkdownOutput: (dirname: any, counter: any) => string;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="react" />
|
|
5
|
-
import type * as G from 'graphql';
|
|
6
|
-
import type { Form } from '@tinacms/toolkit';
|
|
7
|
-
export declare type Action = {
|
|
8
|
-
type: 'start';
|
|
9
|
-
value: {
|
|
10
|
-
query: string;
|
|
11
|
-
};
|
|
12
|
-
} | {
|
|
13
|
-
type: 'setData';
|
|
14
|
-
value: object;
|
|
15
|
-
} | {
|
|
16
|
-
type: 'addDocumentBlueprints';
|
|
17
|
-
value: {
|
|
18
|
-
blueprints: DocumentBlueprint[];
|
|
19
|
-
formifiedQuery: G.DocumentNode;
|
|
20
|
-
};
|
|
21
|
-
} | {
|
|
22
|
-
type: 'addOrReplaceDocumentFormNode';
|
|
23
|
-
value: {
|
|
24
|
-
formNode: FormNode;
|
|
25
|
-
documentForm?: DocumentForm;
|
|
26
|
-
};
|
|
27
|
-
} | {
|
|
28
|
-
type: 'onFieldChange';
|
|
29
|
-
value: {
|
|
30
|
-
event: OnChangeEvent;
|
|
31
|
-
form?: Form;
|
|
32
|
-
};
|
|
33
|
-
} | {
|
|
34
|
-
type: 'formOnReset';
|
|
35
|
-
value: {
|
|
36
|
-
event: OnChangeEvent;
|
|
37
|
-
form?: Form;
|
|
38
|
-
};
|
|
39
|
-
} | {
|
|
40
|
-
type: 'ready';
|
|
41
|
-
} | {
|
|
42
|
-
type: 'done';
|
|
43
|
-
} | {
|
|
44
|
-
type: 'setIn';
|
|
45
|
-
value: Pick<ChangeSet, 'path' | 'value' | 'displaceIndex'>;
|
|
46
|
-
};
|
|
47
|
-
export declare type Dispatch = React.Dispatch<Action>;
|
|
48
|
-
export declare type FormifiedDocumentNode = {
|
|
49
|
-
id: string;
|
|
50
|
-
_internalSys: {
|
|
51
|
-
path: string;
|
|
52
|
-
relativePath: string;
|
|
53
|
-
collection: {
|
|
54
|
-
name: any;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
_values: object;
|
|
58
|
-
};
|
|
59
|
-
export declare type ChangeMutation = {
|
|
60
|
-
type: 'change';
|
|
61
|
-
};
|
|
62
|
-
export declare type ReferenceChangeMutation = {
|
|
63
|
-
type: 'referenceChange';
|
|
64
|
-
};
|
|
65
|
-
export declare type InsertMutation = {
|
|
66
|
-
type: 'insert';
|
|
67
|
-
at: number;
|
|
68
|
-
};
|
|
69
|
-
export declare type MoveMutation = {
|
|
70
|
-
type: 'move';
|
|
71
|
-
from: number;
|
|
72
|
-
to: number;
|
|
73
|
-
};
|
|
74
|
-
export declare type RemoveMutation = {
|
|
75
|
-
type: 'remove';
|
|
76
|
-
at: number;
|
|
77
|
-
};
|
|
78
|
-
export declare type ResetMutation = {
|
|
79
|
-
type: 'reset';
|
|
80
|
-
};
|
|
81
|
-
export declare type GlobalMutation = {
|
|
82
|
-
type: 'global';
|
|
83
|
-
};
|
|
84
|
-
declare type MutationType = ChangeMutation | ReferenceChangeMutation | InsertMutation | MoveMutation | RemoveMutation | ResetMutation | GlobalMutation;
|
|
85
|
-
export declare type OnChangeEvent = {
|
|
86
|
-
type: 'forms:fields:onChange' | 'forms:reset';
|
|
87
|
-
value: unknown;
|
|
88
|
-
previousValue: unknown;
|
|
89
|
-
mutationType: MutationType;
|
|
90
|
-
formId: string;
|
|
91
|
-
field: {
|
|
92
|
-
data: {
|
|
93
|
-
tinaField: {
|
|
94
|
-
name: string;
|
|
95
|
-
type: 'string' | 'reference' | 'object';
|
|
96
|
-
list?: boolean;
|
|
97
|
-
parentTypename: string;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
name: string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export declare type ChangeSet = {
|
|
104
|
-
path: string;
|
|
105
|
-
value: unknown;
|
|
106
|
-
formId: string;
|
|
107
|
-
fieldDefinition: {
|
|
108
|
-
name: string;
|
|
109
|
-
type: 'string' | 'reference' | 'object';
|
|
110
|
-
list?: boolean;
|
|
111
|
-
};
|
|
112
|
-
mutationType: MutationType;
|
|
113
|
-
name: string;
|
|
114
|
-
displaceIndex?: boolean;
|
|
115
|
-
formNode: FormNode;
|
|
116
|
-
};
|
|
117
|
-
export declare type BlueprintPath = {
|
|
118
|
-
name: string;
|
|
119
|
-
alias: string;
|
|
120
|
-
parentTypename?: string;
|
|
121
|
-
list?: boolean;
|
|
122
|
-
isNode?: boolean;
|
|
123
|
-
};
|
|
124
|
-
export declare type DocumentBlueprint = {
|
|
125
|
-
/** The stringified representation of a path relative to root or it's parent document */
|
|
126
|
-
id: string;
|
|
127
|
-
/** The path to a field node */
|
|
128
|
-
path: BlueprintPath[];
|
|
129
|
-
/** The GraphQL SelectionNode, useful for re-fetching the given node */
|
|
130
|
-
selection: G.SelectionNode;
|
|
131
|
-
fields: FieldBlueprint[];
|
|
132
|
-
/** For now, only top-level, non-list nodes will be shown in the sidebar */
|
|
133
|
-
showInSidebar: boolean;
|
|
134
|
-
/** these 2 are not traditional GraphQL fields but need be kept in-sync regardless */
|
|
135
|
-
hasDataJSONField: boolean;
|
|
136
|
-
hasValuesField: boolean;
|
|
137
|
-
};
|
|
138
|
-
export declare type FieldBlueprint = {
|
|
139
|
-
/** The stringified representation of a path relative to root or it's parent document */
|
|
140
|
-
id: string;
|
|
141
|
-
documentBlueprintId: string;
|
|
142
|
-
/** The path to a field node */
|
|
143
|
-
path: BlueprintPath[];
|
|
144
|
-
};
|
|
145
|
-
export declare type FormNode = {
|
|
146
|
-
/** The stringified path with location values injected (eg. 'getBlockPageList.edges.0.node.data.social.1.relatedPage') */
|
|
147
|
-
documentFormId: string;
|
|
148
|
-
documentBlueprintId: string;
|
|
149
|
-
/** Coordinates for the DocumentBlueprint's '[]' values */
|
|
150
|
-
location: number[];
|
|
151
|
-
};
|
|
152
|
-
/** The document ID is the true ID 'content/pages/hello-world.md') */
|
|
153
|
-
declare type DocumentForm = Form;
|
|
154
|
-
export declare type State = {
|
|
155
|
-
schema: G.GraphQLSchema;
|
|
156
|
-
query: G.DocumentNode;
|
|
157
|
-
queryString: string;
|
|
158
|
-
status: 'idle' | 'initialized' | 'formified' | 'ready' | 'done';
|
|
159
|
-
count: number;
|
|
160
|
-
data: object;
|
|
161
|
-
changeSets: ChangeSet[];
|
|
162
|
-
blueprints: DocumentBlueprint[];
|
|
163
|
-
formNodes: FormNode[];
|
|
164
|
-
documentForms: DocumentForm[];
|
|
165
|
-
};
|
|
166
|
-
export {};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { Form, Field, TinaCMS } from '@tinacms/toolkit';
|
|
5
|
-
import type { DocumentBlueprint, FieldBlueprint, FormifiedDocumentNode, OnChangeEvent, FormNode, State, ChangeSet, BlueprintPath } from './types';
|
|
6
|
-
import { formifyCallback, onSubmitArgs } from '../use-graphql-forms';
|
|
7
|
-
interface RecursiveFormifiedDocumentNode<T extends object> extends Array<RecursiveFormifiedDocumentNode<T> | T> {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Gets the value from an object for a given blueprint for _all_ possible values.
|
|
11
|
-
* eg. If the blueprint is `getCollection.documents.edges.[].node` and the value is:
|
|
12
|
-
* ```
|
|
13
|
-
* {
|
|
14
|
-
* getCollection: {
|
|
15
|
-
* documents: {
|
|
16
|
-
* edges: [{
|
|
17
|
-
* node: valueA
|
|
18
|
-
* },
|
|
19
|
-
* {
|
|
20
|
-
* node: valueB
|
|
21
|
-
* }]
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
* The response would be an array containing `valueA` and `valueB`
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export declare const getValueForBlueprint: <T extends object>(state: object, path: string) => T | RecursiveFormifiedDocumentNode<T>;
|
|
30
|
-
/**
|
|
31
|
-
* Returns the name of the field. In the example query, `title` and `t` would both be blueprint fields
|
|
32
|
-
*
|
|
33
|
-
* ```graphql
|
|
34
|
-
* {
|
|
35
|
-
* getPostDocument(relativePath: $relativePath) {
|
|
36
|
-
* data {
|
|
37
|
-
* title,
|
|
38
|
-
* t: title # here `t` is an alias for title
|
|
39
|
-
* }
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare const getFieldNameOrAlias: (fieldBlueprint: FieldBlueprint) => string;
|
|
45
|
-
export declare const buildForm: (doc: FormifiedDocumentNode, cms: TinaCMS, formify: formifyCallback, showInSidebar?: boolean, onSubmit?: (args: onSubmitArgs) => void) => Form;
|
|
46
|
-
export declare const formNodeId: (formNode: FormNode) => string;
|
|
47
|
-
export declare const formNodePath: (formNode: FormNode) => string;
|
|
48
|
-
export declare const formNodeNotIn: (formNode: FormNode, formNodes: FormNode[]) => boolean;
|
|
49
|
-
export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
|
|
50
|
-
export declare const getFormNodesForField: (fieldBlueprint: FieldBlueprint, formNode: FormNode, event: OnChangeEvent, state: State) => {
|
|
51
|
-
pathToChange: string;
|
|
52
|
-
formNodes: FormNode[];
|
|
53
|
-
eventLocation: any[];
|
|
54
|
-
existing: any;
|
|
55
|
-
};
|
|
56
|
-
export declare const getBlueprintAliasPath: (blueprint: DocumentBlueprint) => string;
|
|
57
|
-
export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* Determines the appropriate fields which should recieve an update from a form change
|
|
61
|
-
*
|
|
62
|
-
* In cases where there's polymorphic blocks, it's possible that an update would affect
|
|
63
|
-
* multiple locations that it shouldn't.
|
|
64
|
-
*
|
|
65
|
-
* An OnChange event name can look like: `blocks.2.title`, but if there are 2 block elements
|
|
66
|
-
* with a field of the same name, an event name it wouldn't be enough information for us.
|
|
67
|
-
*
|
|
68
|
-
* To get around this, the event sends the current `typename` along with it, and we use that
|
|
69
|
-
* to determine where in our blueprint the value should be updated.
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
export declare const getBlueprintFieldsForEvent: (blueprint: DocumentBlueprint, event: OnChangeEvent) => FieldBlueprint[];
|
|
73
|
-
export declare const filterFieldBlueprintsByParentTypename: (fbp: FieldBlueprint, typename: any) => boolean;
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* Returns the human-readable path to a blueprint or blueprint field.
|
|
77
|
-
* Optionally, appends a disambiguator to the string where necessary.
|
|
78
|
-
*
|
|
79
|
-
* eg. if a blocks field is polymporphic, specifying `true` for the disambiguator
|
|
80
|
-
*
|
|
81
|
-
* ```
|
|
82
|
-
* getPageDocument.data.blocks[].PageBlocksCta.title
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare const getBlueprintNamePath: (blueprint: Pick<DocumentBlueprint, 'path'>, disambiguator?: boolean) => string;
|
|
86
|
-
export declare const stripIndices: (string: any) => any[];
|
|
87
|
-
export declare const replaceRealNum: (string: any) => any;
|
|
88
|
-
export declare const getMatchName: ({ field, prefix, blueprint }: {
|
|
89
|
-
field: any;
|
|
90
|
-
prefix: any;
|
|
91
|
-
blueprint: any;
|
|
92
|
-
}) => {
|
|
93
|
-
matchName: string;
|
|
94
|
-
fieldName: any;
|
|
95
|
-
};
|
|
96
|
-
export declare const getFormNodesFromEvent: (state: State, event: OnChangeEvent) => FormNode[];
|
|
97
|
-
export declare const printState: (state: State) => string;
|
|
98
|
-
export declare const printEvent: (event: OnChangeEvent) => {
|
|
99
|
-
type: "forms:fields:onChange" | "forms:reset";
|
|
100
|
-
value: unknown;
|
|
101
|
-
previousValue: unknown;
|
|
102
|
-
mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
|
|
103
|
-
formId: string;
|
|
104
|
-
field: {
|
|
105
|
-
data: {
|
|
106
|
-
tinaField: {
|
|
107
|
-
name: string;
|
|
108
|
-
type: "string" | "object" | "reference";
|
|
109
|
-
list?: boolean;
|
|
110
|
-
parentTypename: string;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
name: string;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
export declare const getFormNodeBlueprint: (formNode: FormNode, state: State) => DocumentBlueprint;
|
|
117
|
-
export declare const getMoveMapping: (existing: any, from: any, to: any) => {
|
|
118
|
-
[key: number]: number;
|
|
119
|
-
};
|
|
120
|
-
export declare const matchLocation: (eventLocation: number[], formNode: FormNode) => boolean;
|
|
121
|
-
export declare const bumpLocation: (location: number[]) => number[];
|
|
122
|
-
export declare const maybeLowerLocation: (location: number[], at: number) => number[];
|
|
123
|
-
export declare const matchesAt: (location: number[], at: number) => boolean;
|
|
124
|
-
export declare const swapLocation: (location: number[], mapping: {
|
|
125
|
-
[key: number]: number;
|
|
126
|
-
}) => number[];
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* Gets the sub-fields for an object field, if it's a polymorphic
|
|
130
|
-
* object then we also need to get the __typename, though
|
|
131
|
-
* we should probably supply that regardless. The current downside
|
|
132
|
-
* of this is that it needs to come from the server because we
|
|
133
|
-
* have no way of knowing what it would be from the client-side
|
|
134
|
-
*/
|
|
135
|
-
export declare const getSubFields: (changeSet: ChangeSet) => {
|
|
136
|
-
fields: Field[];
|
|
137
|
-
__typename: string;
|
|
138
|
-
};
|
|
139
|
-
export {};
|