@tinacms/graphql 0.0.0-00d7b85-20251222014449
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/LICENSE +176 -0
- package/README.md +144 -0
- package/dist/ast-builder/index.d.ts +179 -0
- package/dist/auth/utils.d.ts +22 -0
- package/dist/build.d.ts +16 -0
- package/dist/builder/index.d.ts +268 -0
- package/dist/builder/static-definitions.d.ts +4 -0
- package/dist/database/alias-utils.d.ts +3 -0
- package/dist/database/bridge/filesystem.d.ts +21 -0
- package/dist/database/bridge/index.d.ts +12 -0
- package/dist/database/bridge/isomorphic.d.ts +94 -0
- package/dist/database/datalayer.d.ts +80 -0
- package/dist/database/index.d.ts +203 -0
- package/dist/database/level.d.ts +28 -0
- package/dist/database/util.d.ts +33 -0
- package/dist/error.d.ts +4 -0
- package/dist/git/index.d.ts +23 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +8216 -0
- package/dist/level/tinaLevel.d.ts +7 -0
- package/dist/mdx/index.d.ts +3 -0
- package/dist/resolve.d.ts +21 -0
- package/dist/resolver/auth-fields.d.ts +31 -0
- package/dist/resolver/error.d.ts +39 -0
- package/dist/resolver/filter-utils.d.ts +13 -0
- package/dist/resolver/index.d.ts +387 -0
- package/dist/resolver/media-utils.d.ts +21 -0
- package/dist/schema/createSchema.d.ts +5 -0
- package/dist/schema/validate.d.ts +8 -0
- package/dist/sdkBuilder/index.d.ts +5 -0
- package/dist/spec/setup.d.ts +32 -0
- package/dist/types.d.ts +10 -0
- package/dist/util.d.ts +21 -0
- package/package.json +84 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { GraphQLConfig } from './types';
|
|
5
|
+
import type { Database } from './database';
|
|
6
|
+
export declare const resolve: ({ config, query, variables, database, silenceErrors, verbose, isAudit, ctxUser, }: {
|
|
7
|
+
config?: GraphQLConfig;
|
|
8
|
+
query: string;
|
|
9
|
+
variables: object;
|
|
10
|
+
database: Database;
|
|
11
|
+
silenceErrors?: boolean;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
isAudit?: boolean;
|
|
14
|
+
ctxUser?: {
|
|
15
|
+
sub: string;
|
|
16
|
+
};
|
|
17
|
+
}) => Promise<import("graphql").ExecutionResult<{
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TinaSchema } from '@tinacms/schema-tools';
|
|
2
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
3
|
+
import type { Resolver } from './index';
|
|
4
|
+
export declare function handleAuthenticate({ tinaSchema, resolver, sub, password, ctxUser, }: {
|
|
5
|
+
tinaSchema: TinaSchema;
|
|
6
|
+
resolver: Resolver;
|
|
7
|
+
sub?: string;
|
|
8
|
+
password: string;
|
|
9
|
+
info: GraphQLResolveInfo;
|
|
10
|
+
ctxUser?: {
|
|
11
|
+
sub?: string;
|
|
12
|
+
};
|
|
13
|
+
}): Promise<any>;
|
|
14
|
+
export declare function handleAuthorize({ tinaSchema, resolver, sub, ctxUser, }: {
|
|
15
|
+
tinaSchema: TinaSchema;
|
|
16
|
+
resolver: Resolver;
|
|
17
|
+
sub?: string;
|
|
18
|
+
info: GraphQLResolveInfo;
|
|
19
|
+
ctxUser?: {
|
|
20
|
+
sub?: string;
|
|
21
|
+
};
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
export declare function handleUpdatePassword({ tinaSchema, resolver, password, ctxUser, }: {
|
|
24
|
+
tinaSchema: TinaSchema;
|
|
25
|
+
resolver: Resolver;
|
|
26
|
+
password: string;
|
|
27
|
+
info: GraphQLResolveInfo;
|
|
28
|
+
ctxUser?: {
|
|
29
|
+
sub?: string;
|
|
30
|
+
};
|
|
31
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { ASTNode, GraphQLError, Source, SourceLocation } from 'graphql';
|
|
5
|
+
export declare class TinaGraphQLError extends Error implements GraphQLError {
|
|
6
|
+
extensions: Record<string, any>;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
|
9
|
+
readonly path: ReadonlyArray<string | number> | undefined;
|
|
10
|
+
readonly source: Source | undefined;
|
|
11
|
+
readonly positions: ReadonlyArray<number> | undefined;
|
|
12
|
+
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
|
13
|
+
originalError: Error | null | undefined;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
constructor(message: string, extensions?: Record<string, any>);
|
|
16
|
+
}
|
|
17
|
+
export type TypeFetchErrorArgs = {
|
|
18
|
+
/** @deprecated */
|
|
19
|
+
stack?: string;
|
|
20
|
+
file?: string;
|
|
21
|
+
includeAuditMessage?: boolean;
|
|
22
|
+
originalError: Error;
|
|
23
|
+
collection?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare class TinaFetchError extends Error {
|
|
26
|
+
collection?: string;
|
|
27
|
+
file?: string;
|
|
28
|
+
originalError: Error;
|
|
29
|
+
constructor(message: string, args: TypeFetchErrorArgs);
|
|
30
|
+
}
|
|
31
|
+
export declare class TinaQueryError extends TinaFetchError {
|
|
32
|
+
stack?: string;
|
|
33
|
+
constructor(args: TypeFetchErrorArgs);
|
|
34
|
+
}
|
|
35
|
+
export declare class TinaParseDocumentError extends TinaFetchError {
|
|
36
|
+
constructor(args: TypeFetchErrorArgs);
|
|
37
|
+
toString(): string;
|
|
38
|
+
}
|
|
39
|
+
export declare const handleFetchErrorError: (e: unknown, verbose: any) => never;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { ReferenceType, TinaField } from '@tinacms/schema-tools';
|
|
5
|
+
import { FilterCondition } from '../database/datalayer';
|
|
6
|
+
export type ReferenceResolver = (filter: Record<string, object>, fieldDefinition: ReferenceType) => Promise<{
|
|
7
|
+
edges: {
|
|
8
|
+
node: any;
|
|
9
|
+
}[];
|
|
10
|
+
values: any[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare const resolveReferences: (filter: any, fields: TinaField[], resolver: ReferenceResolver) => Promise<void>;
|
|
13
|
+
export declare const collectConditionsForField: (fieldName: string, field: TinaField, filterNode: Record<string, object>, pathExpression: string, collectCondition: (condition: FilterCondition) => void) => void;
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { Database } from '../database';
|
|
5
|
+
import type { Collectable, Collection, Template, TinaField, TinaSchema } from '@tinacms/schema-tools';
|
|
6
|
+
import type { GraphQLConfig } from '../types';
|
|
7
|
+
interface ResolverConfig {
|
|
8
|
+
config?: GraphQLConfig;
|
|
9
|
+
database: Database;
|
|
10
|
+
tinaSchema: TinaSchema;
|
|
11
|
+
isAudit: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const createResolver: (args: ResolverConfig) => Resolver;
|
|
14
|
+
export declare const transformDocumentIntoPayload: (fullPath: string, rawData: {
|
|
15
|
+
_collection: any;
|
|
16
|
+
_template: any;
|
|
17
|
+
}, tinaSchema: TinaSchema, config?: GraphQLConfig, isAudit?: boolean, hasReferences?: boolean) => Promise<{
|
|
18
|
+
_sys: {
|
|
19
|
+
title: any;
|
|
20
|
+
basename: string;
|
|
21
|
+
filename: string;
|
|
22
|
+
extension: string;
|
|
23
|
+
hasReferences: boolean;
|
|
24
|
+
path: string;
|
|
25
|
+
relativePath: string;
|
|
26
|
+
breadcrumbs: string[];
|
|
27
|
+
collection: Collection<true>;
|
|
28
|
+
template: string | number;
|
|
29
|
+
};
|
|
30
|
+
_values: {
|
|
31
|
+
_collection: any;
|
|
32
|
+
_template: any;
|
|
33
|
+
};
|
|
34
|
+
_rawData: {
|
|
35
|
+
_collection: any;
|
|
36
|
+
_template: any;
|
|
37
|
+
};
|
|
38
|
+
_collection: any;
|
|
39
|
+
_template: any;
|
|
40
|
+
__typename: string;
|
|
41
|
+
id: string;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Updates a property in an object using a JSONPath.
|
|
45
|
+
* @param obj - The object to update.
|
|
46
|
+
* @param path - The JSONPath string.
|
|
47
|
+
* @param newValue - The new value to set at the specified path.
|
|
48
|
+
* @returns the updated object.
|
|
49
|
+
*/
|
|
50
|
+
export declare const updateObjectWithJsonPath: (obj: any, path: string, oldValue: any, newValue: any) => {
|
|
51
|
+
object: any;
|
|
52
|
+
updated: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The resolver provides functions for all possible types of lookup
|
|
56
|
+
* values and retrieves them from the database
|
|
57
|
+
*/
|
|
58
|
+
export declare class Resolver {
|
|
59
|
+
init: ResolverConfig;
|
|
60
|
+
config: GraphQLConfig;
|
|
61
|
+
database: Database;
|
|
62
|
+
tinaSchema: TinaSchema;
|
|
63
|
+
isAudit: boolean;
|
|
64
|
+
constructor(init: ResolverConfig);
|
|
65
|
+
resolveCollection: (args: any, collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
66
|
+
fields: TinaField<true>[];
|
|
67
|
+
templates?: undefined;
|
|
68
|
+
label?: string;
|
|
69
|
+
name: string;
|
|
70
|
+
path: string;
|
|
71
|
+
indexes?: {
|
|
72
|
+
name: string;
|
|
73
|
+
fields: {
|
|
74
|
+
name: string;
|
|
75
|
+
}[];
|
|
76
|
+
}[];
|
|
77
|
+
format?: import("@tinacms/schema-tools").ContentFormat;
|
|
78
|
+
ui?: import("@tinacms/schema-tools").UICollection;
|
|
79
|
+
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
80
|
+
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
81
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
82
|
+
match?: {
|
|
83
|
+
include?: string;
|
|
84
|
+
exclude?: string;
|
|
85
|
+
};
|
|
86
|
+
isDetached?: boolean;
|
|
87
|
+
isAuthCollection?: boolean;
|
|
88
|
+
namespace: string[];
|
|
89
|
+
documents: {
|
|
90
|
+
collection: Collection<true>;
|
|
91
|
+
hasDocuments: boolean;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
templates: Template<true>[];
|
|
95
|
+
fields?: undefined;
|
|
96
|
+
label?: string;
|
|
97
|
+
name: string;
|
|
98
|
+
path: string;
|
|
99
|
+
indexes?: {
|
|
100
|
+
name: string;
|
|
101
|
+
fields: {
|
|
102
|
+
name: string;
|
|
103
|
+
}[];
|
|
104
|
+
}[];
|
|
105
|
+
format?: import("@tinacms/schema-tools").ContentFormat;
|
|
106
|
+
ui?: import("@tinacms/schema-tools").UICollection;
|
|
107
|
+
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
108
|
+
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
109
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
110
|
+
match?: {
|
|
111
|
+
include?: string;
|
|
112
|
+
exclude?: string;
|
|
113
|
+
};
|
|
114
|
+
isDetached?: boolean;
|
|
115
|
+
isAuthCollection?: boolean;
|
|
116
|
+
namespace: string[];
|
|
117
|
+
documents: {
|
|
118
|
+
collection: Collection<true>;
|
|
119
|
+
hasDocuments: boolean;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
getRaw: (fullPath: unknown) => Promise<{
|
|
123
|
+
_collection: string;
|
|
124
|
+
_template: string;
|
|
125
|
+
}>;
|
|
126
|
+
getDocumentOrDirectory: (fullPath: unknown) => Promise<{
|
|
127
|
+
_sys: {
|
|
128
|
+
title: any;
|
|
129
|
+
basename: string;
|
|
130
|
+
filename: string;
|
|
131
|
+
extension: string;
|
|
132
|
+
hasReferences: boolean;
|
|
133
|
+
path: string;
|
|
134
|
+
relativePath: string;
|
|
135
|
+
breadcrumbs: string[];
|
|
136
|
+
collection: Collection<true>;
|
|
137
|
+
template: string | number;
|
|
138
|
+
};
|
|
139
|
+
_values: {
|
|
140
|
+
_collection: any;
|
|
141
|
+
_template: any;
|
|
142
|
+
};
|
|
143
|
+
_rawData: {
|
|
144
|
+
_collection: any;
|
|
145
|
+
_template: any;
|
|
146
|
+
};
|
|
147
|
+
_collection: any;
|
|
148
|
+
_template: any;
|
|
149
|
+
__typename: string;
|
|
150
|
+
id: string;
|
|
151
|
+
} | {
|
|
152
|
+
__typename: string;
|
|
153
|
+
name: any;
|
|
154
|
+
path: any;
|
|
155
|
+
}>;
|
|
156
|
+
getDocument: (fullPath: unknown, opts?: {
|
|
157
|
+
collection?: Collection<true>;
|
|
158
|
+
checkReferences?: boolean;
|
|
159
|
+
}) => Promise<{
|
|
160
|
+
_sys: {
|
|
161
|
+
title: any;
|
|
162
|
+
basename: string;
|
|
163
|
+
filename: string;
|
|
164
|
+
extension: string;
|
|
165
|
+
hasReferences: boolean;
|
|
166
|
+
path: string;
|
|
167
|
+
relativePath: string;
|
|
168
|
+
breadcrumbs: string[];
|
|
169
|
+
collection: Collection<true>;
|
|
170
|
+
template: string | number;
|
|
171
|
+
};
|
|
172
|
+
_values: {
|
|
173
|
+
_collection: any;
|
|
174
|
+
_template: any;
|
|
175
|
+
};
|
|
176
|
+
_rawData: {
|
|
177
|
+
_collection: any;
|
|
178
|
+
_template: any;
|
|
179
|
+
};
|
|
180
|
+
_collection: any;
|
|
181
|
+
_template: any;
|
|
182
|
+
__typename: string;
|
|
183
|
+
id: string;
|
|
184
|
+
}>;
|
|
185
|
+
deleteDocument: (fullPath: unknown) => Promise<void>;
|
|
186
|
+
buildObjectMutations: (fieldValue: any, field: Collectable, existingData?: Record<string, any> | Record<string, any>[]) => Promise<{
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
} | {
|
|
189
|
+
[key: string]: unknown;
|
|
190
|
+
}[] | {
|
|
191
|
+
_template: string;
|
|
192
|
+
}[]>;
|
|
193
|
+
createResolveDocument: ({ collection, realPath, args, isAddPendingDocument, }: {
|
|
194
|
+
collection: Collection<true>;
|
|
195
|
+
realPath: string;
|
|
196
|
+
args: unknown;
|
|
197
|
+
isAddPendingDocument: boolean;
|
|
198
|
+
}) => Promise<{
|
|
199
|
+
_sys: {
|
|
200
|
+
title: any;
|
|
201
|
+
basename: string;
|
|
202
|
+
filename: string;
|
|
203
|
+
extension: string;
|
|
204
|
+
hasReferences: boolean;
|
|
205
|
+
path: string;
|
|
206
|
+
relativePath: string;
|
|
207
|
+
breadcrumbs: string[];
|
|
208
|
+
collection: Collection<true>;
|
|
209
|
+
template: string | number;
|
|
210
|
+
};
|
|
211
|
+
_values: {
|
|
212
|
+
_collection: any;
|
|
213
|
+
_template: any;
|
|
214
|
+
};
|
|
215
|
+
_rawData: {
|
|
216
|
+
_collection: any;
|
|
217
|
+
_template: any;
|
|
218
|
+
};
|
|
219
|
+
_collection: any;
|
|
220
|
+
_template: any;
|
|
221
|
+
__typename: string;
|
|
222
|
+
id: string;
|
|
223
|
+
}>;
|
|
224
|
+
updateResolveDocument: ({ collection, realPath, args, isAddPendingDocument, isCollectionSpecific, }: {
|
|
225
|
+
collection: Collection<true>;
|
|
226
|
+
realPath: string;
|
|
227
|
+
args: unknown;
|
|
228
|
+
isAddPendingDocument: boolean;
|
|
229
|
+
isCollectionSpecific: boolean;
|
|
230
|
+
}) => Promise<{
|
|
231
|
+
_sys: {
|
|
232
|
+
title: any;
|
|
233
|
+
basename: string;
|
|
234
|
+
filename: string;
|
|
235
|
+
extension: string;
|
|
236
|
+
hasReferences: boolean;
|
|
237
|
+
path: string;
|
|
238
|
+
relativePath: string;
|
|
239
|
+
breadcrumbs: string[];
|
|
240
|
+
collection: Collection<true>;
|
|
241
|
+
template: string | number;
|
|
242
|
+
};
|
|
243
|
+
_values: {
|
|
244
|
+
_collection: any;
|
|
245
|
+
_template: any;
|
|
246
|
+
};
|
|
247
|
+
_rawData: {
|
|
248
|
+
_collection: any;
|
|
249
|
+
_template: any;
|
|
250
|
+
};
|
|
251
|
+
_collection: any;
|
|
252
|
+
_template: any;
|
|
253
|
+
__typename: string;
|
|
254
|
+
id: string;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Returns top-level fields which are not defined in the collection, so their
|
|
258
|
+
* values are not eliminated from Tina when new values are saved
|
|
259
|
+
*/
|
|
260
|
+
resolveLegacyValues: (oldDoc: any, collection: Collection<true>) => {};
|
|
261
|
+
resolveDocument: ({ args, collection: collectionName, isMutation, isCreation, isDeletion, isFolderCreation, isAddPendingDocument, isCollectionSpecific, isUpdateName, }: {
|
|
262
|
+
args: unknown;
|
|
263
|
+
collection?: string;
|
|
264
|
+
isMutation: boolean;
|
|
265
|
+
isCreation?: boolean;
|
|
266
|
+
isDeletion?: boolean;
|
|
267
|
+
isFolderCreation?: boolean;
|
|
268
|
+
isAddPendingDocument?: boolean;
|
|
269
|
+
isCollectionSpecific?: boolean;
|
|
270
|
+
isUpdateName?: boolean;
|
|
271
|
+
}) => Promise<{
|
|
272
|
+
_sys: {
|
|
273
|
+
title: any;
|
|
274
|
+
basename: string;
|
|
275
|
+
filename: string;
|
|
276
|
+
extension: string;
|
|
277
|
+
hasReferences: boolean;
|
|
278
|
+
path: string;
|
|
279
|
+
relativePath: string;
|
|
280
|
+
breadcrumbs: string[];
|
|
281
|
+
collection: Collection<true>;
|
|
282
|
+
template: string | number;
|
|
283
|
+
};
|
|
284
|
+
_values: {
|
|
285
|
+
_collection: any;
|
|
286
|
+
_template: any;
|
|
287
|
+
};
|
|
288
|
+
_rawData: {
|
|
289
|
+
_collection: any;
|
|
290
|
+
_template: any;
|
|
291
|
+
};
|
|
292
|
+
_collection: any;
|
|
293
|
+
_template: any;
|
|
294
|
+
__typename: string;
|
|
295
|
+
id: string;
|
|
296
|
+
}>;
|
|
297
|
+
resolveCollectionConnections: ({ ids }: {
|
|
298
|
+
ids: string[];
|
|
299
|
+
}) => Promise<{
|
|
300
|
+
totalCount: number;
|
|
301
|
+
edges: {
|
|
302
|
+
node: {
|
|
303
|
+
_sys: {
|
|
304
|
+
title: any;
|
|
305
|
+
basename: string;
|
|
306
|
+
filename: string;
|
|
307
|
+
extension: string;
|
|
308
|
+
hasReferences: boolean;
|
|
309
|
+
path: string;
|
|
310
|
+
relativePath: string;
|
|
311
|
+
breadcrumbs: string[];
|
|
312
|
+
collection: Collection<true>;
|
|
313
|
+
template: string | number;
|
|
314
|
+
};
|
|
315
|
+
_values: {
|
|
316
|
+
_collection: any;
|
|
317
|
+
_template: any;
|
|
318
|
+
};
|
|
319
|
+
_rawData: {
|
|
320
|
+
_collection: any;
|
|
321
|
+
_template: any;
|
|
322
|
+
};
|
|
323
|
+
_collection: any;
|
|
324
|
+
_template: any;
|
|
325
|
+
__typename: string;
|
|
326
|
+
id: string;
|
|
327
|
+
};
|
|
328
|
+
}[];
|
|
329
|
+
}>;
|
|
330
|
+
private referenceResolver;
|
|
331
|
+
private resolveFilterConditions;
|
|
332
|
+
resolveCollectionConnection: ({ args, collection, hydrator, }: {
|
|
333
|
+
args: Record<string, Record<string, object> | string | number>;
|
|
334
|
+
collection: Collection<true>;
|
|
335
|
+
hydrator?: (string: any) => any;
|
|
336
|
+
}) => Promise<{
|
|
337
|
+
totalCount: number;
|
|
338
|
+
edges: {
|
|
339
|
+
node: any;
|
|
340
|
+
cursor: string;
|
|
341
|
+
}[];
|
|
342
|
+
pageInfo: {
|
|
343
|
+
hasPreviousPage: boolean;
|
|
344
|
+
hasNextPage: boolean;
|
|
345
|
+
startCursor: string;
|
|
346
|
+
endCursor: string;
|
|
347
|
+
};
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* Checks if a document has references to it
|
|
351
|
+
* @param id The id of the document to check for references
|
|
352
|
+
* @param c The collection to check for references
|
|
353
|
+
* @returns true if the document has references, false otherwise
|
|
354
|
+
*/
|
|
355
|
+
private hasReferences;
|
|
356
|
+
/**
|
|
357
|
+
* Finds references to a document
|
|
358
|
+
* @param id the id of the document to find references to
|
|
359
|
+
* @param c the collection to find references in
|
|
360
|
+
* @returns a map of references to the document
|
|
361
|
+
*/
|
|
362
|
+
private findReferences;
|
|
363
|
+
private buildFieldMutations;
|
|
364
|
+
/**
|
|
365
|
+
* A mutation looks nearly identical between updateDocument:
|
|
366
|
+
* ```graphql
|
|
367
|
+
* updateDocument(collection: $collection,relativePath: $path, params: {
|
|
368
|
+
* post: {
|
|
369
|
+
* title: "Hello, World"
|
|
370
|
+
* }
|
|
371
|
+
* })`
|
|
372
|
+
* ```
|
|
373
|
+
* and `updatePostDocument`:
|
|
374
|
+
* ```graphql
|
|
375
|
+
* updatePostDocument(relativePath: $path, params: {
|
|
376
|
+
* title: "Hello, World"
|
|
377
|
+
* })
|
|
378
|
+
* ```
|
|
379
|
+
* The problem here is that we don't know whether the payload came from `updateDocument`
|
|
380
|
+
* or `updatePostDocument` (we could, but for now it's easier not to pipe those details through),
|
|
381
|
+
* But we do know that when given a `args.collection` value, we can assume that
|
|
382
|
+
* this was a `updateDocument` request, and thus - should grab the data
|
|
383
|
+
* from the corresponding field name in the key
|
|
384
|
+
*/
|
|
385
|
+
private buildParams;
|
|
386
|
+
}
|
|
387
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { Schema } from '@tinacms/schema-tools';
|
|
5
|
+
import type { GraphQLConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Strips away the TinaCloud Asset URL from an `image` value
|
|
8
|
+
*
|
|
9
|
+
* @param {string | string[]} value
|
|
10
|
+
* @param {GraphQLConfig} config
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveMediaCloudToRelative: (value: string | string[], config: GraphQLConfig, schema: Schema<true>) => string | string[];
|
|
14
|
+
/**
|
|
15
|
+
* Adds TinaCloud Asset URL to an `image` value
|
|
16
|
+
*
|
|
17
|
+
* @param {string | string[]} value
|
|
18
|
+
* @param {GraphQLConfig} config
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveMediaRelativeToCloud: (value: string | string[], config: GraphQLConfig, schema: Schema<true>) => string | string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Schema, type Collection } from '@tinacms/schema-tools';
|
|
2
|
+
export declare const validateSchema: (schema: Schema) => Promise<{
|
|
3
|
+
collections: Collection<true>[];
|
|
4
|
+
config: import("@tinacms/schema-tools").Config<undefined, undefined, undefined, undefined, undefined>;
|
|
5
|
+
} | {
|
|
6
|
+
collections: Collection<true>[];
|
|
7
|
+
config?: undefined;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { Schema } from '@tinacms/schema-tools';
|
|
5
|
+
import { Database } from '../database';
|
|
6
|
+
import { Level } from '../database/level';
|
|
7
|
+
export declare const setup: (rootPath: string, schema: Schema, level: Level) => Promise<{
|
|
8
|
+
database: Database;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const print: (fixture: Fixture) => string;
|
|
11
|
+
export type Fixture = {
|
|
12
|
+
description?: string;
|
|
13
|
+
name: string;
|
|
14
|
+
assert: 'output';
|
|
15
|
+
message?: string;
|
|
16
|
+
expectError?: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
description?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
assert: 'file';
|
|
21
|
+
filename: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
expectError?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const setupFixture: (rootPath: string, schema: Schema, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
|
|
26
|
+
responses: string[];
|
|
27
|
+
expectedResponsePaths: string[];
|
|
28
|
+
}>;
|
|
29
|
+
export declare const setupFixture2: (rootPath: string, schema: Schema, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
|
|
30
|
+
responses: string[];
|
|
31
|
+
expectedResponsePaths: string[];
|
|
32
|
+
}>;
|
package/dist/types.d.ts
ADDED
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import * as yup from 'yup';
|
|
5
|
+
/**
|
|
6
|
+
* Iterate through an array of promises sequentially, ensuring the order
|
|
7
|
+
* is preserved.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* await sequential(templates, async (template) => {
|
|
11
|
+
* await doSomething(template)
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const sequential: <A, B>(items: A[] | undefined, callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
|
|
16
|
+
export declare function assertShape<T>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema, errorMessage?: string): asserts value is T;
|
|
17
|
+
export declare const atob: (b64Encoded: string) => string;
|
|
18
|
+
export declare const btoa: (string: string) => string;
|
|
19
|
+
export declare const lastItem: (arr: (number | string)[]) => string | number;
|
|
20
|
+
export declare const get: (obj: any, path: any, defaultValue?: any) => any;
|
|
21
|
+
export declare const flattenDeep: (arr: any) => any;
|