@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,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { LookupMapType } from '../database';
|
|
5
|
+
import type { FieldDefinitionNode, InlineFragmentNode, ObjectTypeDefinitionNode } from 'graphql';
|
|
6
|
+
import type { Collection, Template } from '@tinacms/schema-tools';
|
|
7
|
+
import { TinaSchema } from '@tinacms/schema-tools';
|
|
8
|
+
export declare const createBuilder: ({ tinaSchema, }: {
|
|
9
|
+
tinaSchema: TinaSchema;
|
|
10
|
+
}) => Promise<Builder>;
|
|
11
|
+
/**
|
|
12
|
+
* The builder class is responsible for creating GraphQL AST definitions
|
|
13
|
+
* for a given portion of the Tina schema. In some cases that will also mean
|
|
14
|
+
* storing a reference to how we can resolve that type when we come across it.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Builder {
|
|
17
|
+
config: {
|
|
18
|
+
tinaSchema: TinaSchema;
|
|
19
|
+
};
|
|
20
|
+
private maxDepth;
|
|
21
|
+
tinaSchema: TinaSchema;
|
|
22
|
+
lookupMap: Record<string, LookupMapType>;
|
|
23
|
+
constructor(config: {
|
|
24
|
+
tinaSchema: TinaSchema;
|
|
25
|
+
});
|
|
26
|
+
private addToLookupMap;
|
|
27
|
+
/**
|
|
28
|
+
* ```graphql
|
|
29
|
+
* # ex.
|
|
30
|
+
* {
|
|
31
|
+
* getCollection(collection: $collection) {
|
|
32
|
+
* name
|
|
33
|
+
* documents {...}
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param collections
|
|
39
|
+
*/
|
|
40
|
+
buildCollectionDefinition: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
41
|
+
/**
|
|
42
|
+
* ```graphql
|
|
43
|
+
* # ex.
|
|
44
|
+
* {
|
|
45
|
+
* getCollections {
|
|
46
|
+
* name
|
|
47
|
+
* documents {...}
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param collections
|
|
53
|
+
*/
|
|
54
|
+
buildMultiCollectionDefinition: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
55
|
+
/**
|
|
56
|
+
* ```graphql
|
|
57
|
+
* # ex.
|
|
58
|
+
* {
|
|
59
|
+
* node(id: $id) {
|
|
60
|
+
* id
|
|
61
|
+
* data {...}
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
multiNodeDocument: () => Promise<FieldDefinitionNode>;
|
|
67
|
+
/**
|
|
68
|
+
* ```graphql
|
|
69
|
+
* # ex.
|
|
70
|
+
* {
|
|
71
|
+
* getDocument(collection: $collection, relativePath: $relativePath) {
|
|
72
|
+
* id
|
|
73
|
+
* data {...}
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @param collections
|
|
79
|
+
*/
|
|
80
|
+
multiCollectionDocument: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
81
|
+
/**
|
|
82
|
+
* ```graphql
|
|
83
|
+
* # ex.
|
|
84
|
+
* {
|
|
85
|
+
* addPendingDocument(collection: $collection, relativePath: $relativePath, params: $params) {
|
|
86
|
+
* id
|
|
87
|
+
* data {...}
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param collections
|
|
93
|
+
*/
|
|
94
|
+
addMultiCollectionDocumentMutation: () => Promise<FieldDefinitionNode>;
|
|
95
|
+
/**
|
|
96
|
+
* ```graphql
|
|
97
|
+
* # ex.
|
|
98
|
+
* {
|
|
99
|
+
* createDocument(relativePath: $relativePath, params: $params) {
|
|
100
|
+
* id
|
|
101
|
+
* data {...}
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @param collections
|
|
107
|
+
*/
|
|
108
|
+
buildCreateCollectionDocumentMutation: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
109
|
+
/**
|
|
110
|
+
* ```graphql
|
|
111
|
+
* # ex.
|
|
112
|
+
* {
|
|
113
|
+
* updateDocument(relativePath: $relativePath, params: $params) {
|
|
114
|
+
* id
|
|
115
|
+
* data {...}
|
|
116
|
+
* }
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @param collections
|
|
121
|
+
*/
|
|
122
|
+
buildUpdateCollectionDocumentMutation: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
123
|
+
/**
|
|
124
|
+
* ```graphql
|
|
125
|
+
* # ex.
|
|
126
|
+
* {
|
|
127
|
+
* deleteDocument(relativePath: $relativePath, params: $params) {
|
|
128
|
+
* id
|
|
129
|
+
* data {...}
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @param collections
|
|
135
|
+
*/
|
|
136
|
+
buildDeleteCollectionDocumentMutation: (collections: Collection<true>[]) => Promise<FieldDefinitionNode>;
|
|
137
|
+
/**
|
|
138
|
+
* ```graphql
|
|
139
|
+
* # ex.
|
|
140
|
+
* {
|
|
141
|
+
* createFolder(folderName: $folderName, params: $params) {
|
|
142
|
+
* id
|
|
143
|
+
* data {...}
|
|
144
|
+
* }
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @param collections
|
|
149
|
+
*/
|
|
150
|
+
buildCreateCollectionFolderMutation: () => Promise<FieldDefinitionNode>;
|
|
151
|
+
/**
|
|
152
|
+
* ```graphql
|
|
153
|
+
* # ex.
|
|
154
|
+
* {
|
|
155
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
156
|
+
* id
|
|
157
|
+
* data {...}
|
|
158
|
+
* }
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @param collection
|
|
163
|
+
*/
|
|
164
|
+
collectionDocument: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
165
|
+
authenticationCollectionDocument: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
166
|
+
updatePasswordMutation: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
167
|
+
authorizationCollectionDocument: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
168
|
+
/**
|
|
169
|
+
* Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
|
|
170
|
+
* ```graphql
|
|
171
|
+
* # ex.
|
|
172
|
+
* fragment AuthorsParts on Authors {
|
|
173
|
+
* name
|
|
174
|
+
* avatar
|
|
175
|
+
* ...
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @public
|
|
180
|
+
* @param collection a TinaCloud collection
|
|
181
|
+
*/
|
|
182
|
+
collectionFragment: (collection: Collection<true>) => Promise<import("graphql").FragmentDefinitionNode>;
|
|
183
|
+
/**
|
|
184
|
+
* Given a collection this function returns its selections set. For example for Post this would return
|
|
185
|
+
*
|
|
186
|
+
* "
|
|
187
|
+
* body
|
|
188
|
+
* title
|
|
189
|
+
* ... on Author {
|
|
190
|
+
* name
|
|
191
|
+
* heroImg
|
|
192
|
+
* }
|
|
193
|
+
*
|
|
194
|
+
* But in the AST format
|
|
195
|
+
*
|
|
196
|
+
* */
|
|
197
|
+
private _getCollectionFragmentSelections;
|
|
198
|
+
private _buildFieldNodeForFragments;
|
|
199
|
+
buildTemplateFragments(template: Template<true>, depth: number): Promise<InlineFragmentNode | boolean>;
|
|
200
|
+
/**
|
|
201
|
+
* ```graphql
|
|
202
|
+
* # ex.
|
|
203
|
+
* mutation {
|
|
204
|
+
* updatePostDocument(relativePath: $relativePath, params: $params) {
|
|
205
|
+
* id
|
|
206
|
+
* data {...}
|
|
207
|
+
* }
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @param collection
|
|
212
|
+
*/
|
|
213
|
+
updateCollectionDocumentMutation: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
214
|
+
/**
|
|
215
|
+
* ```graphql
|
|
216
|
+
* # ex.
|
|
217
|
+
* mutation {
|
|
218
|
+
* createPostDocument(relativePath: $relativePath, params: $params) {
|
|
219
|
+
* id
|
|
220
|
+
* data {...}
|
|
221
|
+
* }
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @param collection
|
|
226
|
+
*/
|
|
227
|
+
createCollectionDocumentMutation: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
228
|
+
/**
|
|
229
|
+
* ```graphql
|
|
230
|
+
* # ex.
|
|
231
|
+
* {
|
|
232
|
+
* getPostList(first: 10) {
|
|
233
|
+
* edges {
|
|
234
|
+
* node {
|
|
235
|
+
* id
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* }
|
|
239
|
+
* }
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* @param collection
|
|
243
|
+
*/
|
|
244
|
+
collectionDocumentList: (collection: Collection<true>) => Promise<FieldDefinitionNode>;
|
|
245
|
+
/**
|
|
246
|
+
* GraphQL type definitions which remain unchanged regardless
|
|
247
|
+
* of the supplied Tina schema. Ex. "node" interface
|
|
248
|
+
*/
|
|
249
|
+
buildStaticDefinitions: () => (import("graphql").ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode[])[];
|
|
250
|
+
private _buildCollectionDocumentType;
|
|
251
|
+
private _buildAuthDocumentType;
|
|
252
|
+
private _filterCollectionDocumentType;
|
|
253
|
+
private _buildTemplateFilter;
|
|
254
|
+
private _updateCollectionDocumentMutationType;
|
|
255
|
+
private _buildTemplateMutation;
|
|
256
|
+
private _buildMultiCollectionDocumentDefinition;
|
|
257
|
+
private _buildMultiCollectionDocumentListDefinition;
|
|
258
|
+
private _buildFieldFilter;
|
|
259
|
+
private _buildFieldMutation;
|
|
260
|
+
private _buildReferenceMutation;
|
|
261
|
+
private _buildPasswordMutation;
|
|
262
|
+
private _buildUpdateDocumentMutationParams;
|
|
263
|
+
private _buildObjectOrUnionData;
|
|
264
|
+
private _connectionFilterBuilder;
|
|
265
|
+
private _connectionFieldBuilder;
|
|
266
|
+
private _buildDataField;
|
|
267
|
+
private _buildTemplateData;
|
|
268
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Bridge } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* This is the bridge from whatever datasource we need for I/O.
|
|
4
|
+
* The basic example here is for the filesystem, one is needed
|
|
5
|
+
* for GitHub has well.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FilesystemBridge implements Bridge {
|
|
8
|
+
rootPath: string;
|
|
9
|
+
outputPath: string;
|
|
10
|
+
constructor(rootPath: string, outputPath?: string);
|
|
11
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
12
|
+
delete(filepath: string): Promise<void>;
|
|
13
|
+
get(filepath: string): Promise<string>;
|
|
14
|
+
put(filepath: string, data: string, basePathOverride?: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Same as the `FileSystemBridge` except it does not save files
|
|
18
|
+
*/
|
|
19
|
+
export declare class AuditFileSystemBridge extends FilesystemBridge {
|
|
20
|
+
put(filepath: string, data: string): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Bridge {
|
|
2
|
+
rootPath: string;
|
|
3
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
4
|
+
delete(filepath: string): Promise<void>;
|
|
5
|
+
get(filepath: string): Promise<string>;
|
|
6
|
+
put(filepath: string, data: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Optionally, the bridge can perform
|
|
9
|
+
* operations in a separate path.
|
|
10
|
+
*/
|
|
11
|
+
outputPath?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
|
|
2
|
+
import type { Bridge } from './index';
|
|
3
|
+
export type IsomorphicGitBridgeOptions = {
|
|
4
|
+
gitRoot: string;
|
|
5
|
+
fsModule?: CallbackFsClient | PromiseFsClient;
|
|
6
|
+
commitMessage?: string;
|
|
7
|
+
author: {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
};
|
|
11
|
+
committer?: {
|
|
12
|
+
name: string;
|
|
13
|
+
email: string;
|
|
14
|
+
};
|
|
15
|
+
ref?: string;
|
|
16
|
+
onPut?: (filepath: string, data: string) => Promise<void>;
|
|
17
|
+
onDelete?: (filepath: string) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Bridge backed by isomorphic-git
|
|
21
|
+
*/
|
|
22
|
+
export declare class IsomorphicBridge implements Bridge {
|
|
23
|
+
rootPath: string;
|
|
24
|
+
relativePath: string;
|
|
25
|
+
gitRoot: string;
|
|
26
|
+
fsModule: CallbackFsClient | PromiseFsClient;
|
|
27
|
+
isomorphicConfig: {
|
|
28
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
29
|
+
dir: string;
|
|
30
|
+
};
|
|
31
|
+
commitMessage: string;
|
|
32
|
+
author: {
|
|
33
|
+
name: string;
|
|
34
|
+
email: string;
|
|
35
|
+
};
|
|
36
|
+
committer: {
|
|
37
|
+
name: string;
|
|
38
|
+
email: string;
|
|
39
|
+
};
|
|
40
|
+
ref: string | undefined;
|
|
41
|
+
private readonly onPut;
|
|
42
|
+
private readonly onDelete;
|
|
43
|
+
private cache;
|
|
44
|
+
constructor(rootPath: string, { gitRoot, author, committer, fsModule, commitMessage, ref, onPut, onDelete, }: IsomorphicGitBridgeOptions);
|
|
45
|
+
private getAuthor;
|
|
46
|
+
private getCommitter;
|
|
47
|
+
/**
|
|
48
|
+
* Recursively populate paths matching `pattern` for the given `entry`
|
|
49
|
+
*
|
|
50
|
+
* @param pattern - pattern to filter paths by
|
|
51
|
+
* @param entry - TreeEntry to start building list from
|
|
52
|
+
* @param path - base path
|
|
53
|
+
* @param results
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private listEntries;
|
|
57
|
+
/**
|
|
58
|
+
* For the specified path, returns an object with an array containing the parts of the path (pathParts)
|
|
59
|
+
* and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
|
|
60
|
+
* pathEntries are placeholders for non-existent entries.
|
|
61
|
+
*
|
|
62
|
+
* @param path - path being resolved
|
|
63
|
+
* @param ref - ref to resolve path entries for
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private resolvePathEntries;
|
|
67
|
+
/**
|
|
68
|
+
* Updates tree entry and associated parent tree entries
|
|
69
|
+
*
|
|
70
|
+
* @param existingOid - the existing OID
|
|
71
|
+
* @param updatedOid - the updated OID
|
|
72
|
+
* @param path - the path of the entry being updated
|
|
73
|
+
* @param type - the type of the entry being updated (blob or tree)
|
|
74
|
+
* @param pathEntries - parent path entries
|
|
75
|
+
* @param pathParts - parent path parts
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private updateTreeHierarchy;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a commit for the specified tree and updates the specified ref to point to the commit
|
|
81
|
+
*
|
|
82
|
+
* @param treeSha - sha of the new tree
|
|
83
|
+
* @param ref - the ref that should be updated
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private commitTree;
|
|
87
|
+
private getRef;
|
|
88
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
89
|
+
delete(filepath: string): Promise<void>;
|
|
90
|
+
private qualifyPath;
|
|
91
|
+
private unqualifyPath;
|
|
92
|
+
get(filepath: string): Promise<string>;
|
|
93
|
+
put(filepath: string, data: string): Promise<void>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { BatchOp, Level } from './level';
|
|
5
|
+
import type { Collection } from '@tinacms/schema-tools';
|
|
6
|
+
export declare enum OP {
|
|
7
|
+
EQ = "eq",
|
|
8
|
+
GT = "gt",
|
|
9
|
+
LT = "lt",
|
|
10
|
+
GTE = "gte",
|
|
11
|
+
LTE = "lte",
|
|
12
|
+
STARTS_WITH = "startsWith",
|
|
13
|
+
IN = "in"
|
|
14
|
+
}
|
|
15
|
+
export type BinaryFilter = {
|
|
16
|
+
pathExpression: string;
|
|
17
|
+
rightOperand: FilterOperand;
|
|
18
|
+
operator: OP.EQ | OP.GT | OP.LT | OP.GTE | OP.LTE | OP.STARTS_WITH | OP.IN;
|
|
19
|
+
type: string;
|
|
20
|
+
pad?: PadDefinition;
|
|
21
|
+
list: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type TernaryFilter = {
|
|
24
|
+
pathExpression: string;
|
|
25
|
+
leftOperand: FilterOperand;
|
|
26
|
+
rightOperand: FilterOperand;
|
|
27
|
+
leftOperator: OP.GTE | OP.GT;
|
|
28
|
+
rightOperator: OP.LT | OP.LTE;
|
|
29
|
+
type: string;
|
|
30
|
+
pad?: PadDefinition;
|
|
31
|
+
list: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type IndexDefinition = {
|
|
34
|
+
fields: {
|
|
35
|
+
name: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
pad?: PadDefinition;
|
|
38
|
+
list: boolean;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
export type PadDefinition = {
|
|
42
|
+
fillString: string;
|
|
43
|
+
maxLength: number;
|
|
44
|
+
};
|
|
45
|
+
export type FilterOperand = string | number | boolean | string[] | number[];
|
|
46
|
+
export type FilterCondition = {
|
|
47
|
+
filterExpression: Record<string, FilterOperand>;
|
|
48
|
+
filterPath: string;
|
|
49
|
+
};
|
|
50
|
+
type StringEscaper = <T extends string | string[]>(input: T) => T;
|
|
51
|
+
export declare const DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
|
|
52
|
+
export declare const REFS_COLLECTIONS_SORT_KEY = "__refs__";
|
|
53
|
+
export declare const REFS_REFERENCE_FIELD = "__tina_ref__";
|
|
54
|
+
export declare const REFS_PATH_FIELD = "__tina_ref_path__";
|
|
55
|
+
export declare const DEFAULT_NUMERIC_LPAD = 4;
|
|
56
|
+
export declare const coerceFilterChainOperands: (filterChain: (BinaryFilter | TernaryFilter)[], escapeString?: StringEscaper) => (BinaryFilter | TernaryFilter)[];
|
|
57
|
+
export declare const makeFilter: ({ filterChain, }: {
|
|
58
|
+
filterChain?: (BinaryFilter | TernaryFilter)[];
|
|
59
|
+
}) => ((values: Record<string, object | FilterOperand>) => boolean);
|
|
60
|
+
export declare const makeFilterChain: ({ conditions, }: {
|
|
61
|
+
conditions: FilterCondition[];
|
|
62
|
+
}) => (BinaryFilter | TernaryFilter)[];
|
|
63
|
+
export declare const makeFilterSuffixes: (filterChain: (BinaryFilter | TernaryFilter)[], index: IndexDefinition) => {
|
|
64
|
+
left?: string;
|
|
65
|
+
right?: string;
|
|
66
|
+
} | undefined;
|
|
67
|
+
export declare const FOLDER_ROOT = "~";
|
|
68
|
+
type FolderTree = Record<string, Set<string>>;
|
|
69
|
+
export declare class FolderTreeBuilder {
|
|
70
|
+
_tree: FolderTree;
|
|
71
|
+
constructor();
|
|
72
|
+
get tree(): FolderTree;
|
|
73
|
+
update(documentPath: string, collectionPath: string): any;
|
|
74
|
+
}
|
|
75
|
+
export declare const makeFolderOpsForCollection: <T extends object>(folderTree: FolderTree, collection: Collection<true>, indexDefinitions: Record<string, IndexDefinition>, opType: "put" | "del", level: Level, escapeStr?: StringEscaper) => BatchOp[];
|
|
76
|
+
export declare const makeIndexOpsForDocument: <T extends object>(filepath: string, collection: string | undefined, indexDefinitions: Record<string, IndexDefinition>, data: T, opType: "put" | "del", level: Level, escapeStr?: StringEscaper) => BatchOp[];
|
|
77
|
+
export declare const makeRefOpsForDocument: <T extends object>(filepath: string, collection: string | undefined, references: Record<string, string[]> | undefined | null, data: T, opType: "put" | "del", level: Level) => BatchOp[];
|
|
78
|
+
export declare const makeStringEscaper: (regex: RegExp, replacement: string) => StringEscaper;
|
|
79
|
+
export declare const stringEscaper: StringEscaper;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { DocumentNode } from 'graphql';
|
|
2
|
+
import type { Collection, CollectionTemplateable, Schema, TinaSchema } from '@tinacms/schema-tools';
|
|
3
|
+
import type { Bridge } from './bridge';
|
|
4
|
+
import { type BinaryFilter, type IndexDefinition, type TernaryFilter } from './datalayer';
|
|
5
|
+
import { type Level } from './level';
|
|
6
|
+
type IndexStatusEvent = {
|
|
7
|
+
status: 'inprogress' | 'complete' | 'failed';
|
|
8
|
+
error?: Error;
|
|
9
|
+
};
|
|
10
|
+
type IndexStatusCallback = (event: IndexStatusEvent) => Promise<void>;
|
|
11
|
+
export type OnPutCallback = (key: string, value: any) => Promise<void>;
|
|
12
|
+
export type OnDeleteCallback = (key: string) => Promise<void>;
|
|
13
|
+
export interface DatabaseArgs {
|
|
14
|
+
bridge?: Bridge;
|
|
15
|
+
level: Level;
|
|
16
|
+
onPut?: (key: string, value: any) => Promise<void>;
|
|
17
|
+
onDelete?: (key: string) => Promise<void>;
|
|
18
|
+
tinaDirectory?: string;
|
|
19
|
+
indexStatusCallback?: IndexStatusCallback;
|
|
20
|
+
version?: boolean;
|
|
21
|
+
namespace?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GitProvider {
|
|
24
|
+
onPut: (key: string, value: string) => Promise<void>;
|
|
25
|
+
onDelete: (key: string) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export type CreateDatabase = Omit<DatabaseArgs, 'level' | 'onPut' | 'onDelete'> & {
|
|
28
|
+
databaseAdapter: Level;
|
|
29
|
+
gitProvider: GitProvider;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use databaseAdapter instead
|
|
32
|
+
*/
|
|
33
|
+
level?: Level;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use gitProvider instead
|
|
36
|
+
*/
|
|
37
|
+
onPut?: OnPutCallback;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use gitProvider instead
|
|
40
|
+
*/
|
|
41
|
+
onDelete?: OnDeleteCallback;
|
|
42
|
+
};
|
|
43
|
+
export type CreateLocalDatabaseArgs = Omit<DatabaseArgs, 'level'> & {
|
|
44
|
+
port?: number;
|
|
45
|
+
rootPath?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const createLocalDatabase: (config?: CreateLocalDatabaseArgs) => Database;
|
|
48
|
+
export declare const createDatabase: (config: CreateDatabase) => Database;
|
|
49
|
+
export declare const createDatabaseInternal: (config: DatabaseArgs) => Database;
|
|
50
|
+
/** Options for {@link Database.query} **/
|
|
51
|
+
export type QueryOptions = {
|
|
52
|
+
fileExtension?: string;
|
|
53
|
+
collection: string;
|
|
54
|
+
filterChain?: (BinaryFilter | TernaryFilter)[];
|
|
55
|
+
sort?: string;
|
|
56
|
+
first?: number;
|
|
57
|
+
last?: number;
|
|
58
|
+
after?: string;
|
|
59
|
+
before?: string;
|
|
60
|
+
folder?: string;
|
|
61
|
+
};
|
|
62
|
+
export declare class Database {
|
|
63
|
+
config: DatabaseArgs;
|
|
64
|
+
bridge?: Bridge;
|
|
65
|
+
rootLevel: Level;
|
|
66
|
+
appLevel: Level | undefined;
|
|
67
|
+
contentLevel: Level | undefined;
|
|
68
|
+
tinaDirectory: string;
|
|
69
|
+
indexStatusCallback: IndexStatusCallback | undefined;
|
|
70
|
+
private readonly onPut;
|
|
71
|
+
private readonly onDelete;
|
|
72
|
+
private tinaSchema;
|
|
73
|
+
private contentNamespace;
|
|
74
|
+
private collectionIndexDefinitions;
|
|
75
|
+
private collectionReferences;
|
|
76
|
+
private _lookup;
|
|
77
|
+
constructor(config: DatabaseArgs);
|
|
78
|
+
private collectionForPath;
|
|
79
|
+
private getGeneratedFolder;
|
|
80
|
+
private updateDatabaseVersion;
|
|
81
|
+
private getDatabaseVersion;
|
|
82
|
+
private initLevel;
|
|
83
|
+
getMetadata: (key: string) => Promise<any>;
|
|
84
|
+
setMetadata: (key: string, value: string) => Promise<void>;
|
|
85
|
+
get: <T extends object>(filepath: string) => Promise<T>;
|
|
86
|
+
addPendingDocument: (filepath: string, data: {
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}) => Promise<void>;
|
|
89
|
+
put: (filepath: string, data: {
|
|
90
|
+
[key: string]: unknown;
|
|
91
|
+
}, collectionName?: string) => Promise<boolean>;
|
|
92
|
+
getTemplateDetailsForFile(collection: Collection<true>, data: {
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
template: {
|
|
96
|
+
label?: string | boolean;
|
|
97
|
+
name: string;
|
|
98
|
+
nameOverride?: string;
|
|
99
|
+
ui?: {
|
|
100
|
+
itemProps?(item: Record<string, any>): {
|
|
101
|
+
key?: string;
|
|
102
|
+
label?: string | boolean;
|
|
103
|
+
};
|
|
104
|
+
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
105
|
+
previewSrc?: string;
|
|
106
|
+
};
|
|
107
|
+
fields: ((import("@tinacms/schema-tools").StringField | import("@tinacms/schema-tools").NumberField | import("@tinacms/schema-tools").BooleanField | import("@tinacms/schema-tools").DateTimeField | import("@tinacms/schema-tools").ImageField | import("@tinacms/schema-tools").ReferenceField | import("@tinacms/schema-tools").PasswordField | import("@tinacms/schema-tools").RichTextField<false> | import("@tinacms/schema-tools").ObjectField<false>) & {})[];
|
|
108
|
+
};
|
|
109
|
+
info: CollectionTemplateable;
|
|
110
|
+
}>;
|
|
111
|
+
formatBodyOnPayload: (filepath: string, data: {
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
}) => Promise<{
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}>;
|
|
116
|
+
stringifyFile: (filepath: string, payload: {
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}, collection: Collection<true>) => Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
121
|
+
*/
|
|
122
|
+
clearCache(): void;
|
|
123
|
+
flush: (filepath: string) => Promise<string>;
|
|
124
|
+
getLookup: (returnType?: string) => Promise<LookupMapType | Record<string, LookupMapType>>;
|
|
125
|
+
getGraphQLSchema: () => Promise<DocumentNode>;
|
|
126
|
+
getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
|
|
127
|
+
getTinaSchema: (level?: Level) => Promise<Schema>;
|
|
128
|
+
getSchema: (level?: Level, existingSchema?: Schema) => Promise<TinaSchema>;
|
|
129
|
+
getCollectionReferences: (level?: Level) => Promise<Record<string, Record<string, string[]>>>;
|
|
130
|
+
getIndexDefinitions: (level?: Level) => Promise<Record<string, Record<string, IndexDefinition>>>;
|
|
131
|
+
documentExists: (fullpath: unknown) => Promise<boolean>;
|
|
132
|
+
query: (queryOptions: QueryOptions, hydrator: any) => Promise<{
|
|
133
|
+
edges: {
|
|
134
|
+
node: any;
|
|
135
|
+
cursor: string;
|
|
136
|
+
}[];
|
|
137
|
+
pageInfo: {
|
|
138
|
+
hasPreviousPage: boolean;
|
|
139
|
+
hasNextPage: boolean;
|
|
140
|
+
startCursor: string;
|
|
141
|
+
endCursor: string;
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
private indexStatusCallbackWrapper;
|
|
145
|
+
indexContent: ({ graphQLSchema, tinaSchema, lookup: lookupFromLockFile, }: {
|
|
146
|
+
graphQLSchema: DocumentNode;
|
|
147
|
+
tinaSchema: TinaSchema;
|
|
148
|
+
lookup?: object;
|
|
149
|
+
}) => Promise<{
|
|
150
|
+
warnings: string[];
|
|
151
|
+
}>;
|
|
152
|
+
deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
153
|
+
indexContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
154
|
+
delete: (filepath: string) => Promise<void>;
|
|
155
|
+
_indexAllContent: (level: Level, schema?: Schema) => Promise<{
|
|
156
|
+
warnings: string[];
|
|
157
|
+
}>;
|
|
158
|
+
}
|
|
159
|
+
export type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | CollectionFolderLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
|
|
160
|
+
type NodeDocument = {
|
|
161
|
+
type: string;
|
|
162
|
+
resolveType: 'nodeDocument';
|
|
163
|
+
};
|
|
164
|
+
type GlobalDocumentLookup = {
|
|
165
|
+
type: string;
|
|
166
|
+
resolveType: 'globalDocument';
|
|
167
|
+
collection: string;
|
|
168
|
+
};
|
|
169
|
+
type CollectionDocumentLookup = {
|
|
170
|
+
type: string;
|
|
171
|
+
resolveType: 'collectionDocument';
|
|
172
|
+
collection: string;
|
|
173
|
+
};
|
|
174
|
+
type CollectionFolderLookup = {
|
|
175
|
+
type: string;
|
|
176
|
+
resolveType: 'collectionFolder';
|
|
177
|
+
collection: string;
|
|
178
|
+
};
|
|
179
|
+
type MultiCollectionDocumentLookup = {
|
|
180
|
+
type: string;
|
|
181
|
+
resolveType: 'multiCollectionDocument';
|
|
182
|
+
createDocument: 'create';
|
|
183
|
+
updateDocument: 'update';
|
|
184
|
+
};
|
|
185
|
+
type MultiCollectionDocumentListLookup = {
|
|
186
|
+
type: string;
|
|
187
|
+
resolveType: 'multiCollectionDocumentList';
|
|
188
|
+
collections: string[];
|
|
189
|
+
};
|
|
190
|
+
export type CollectionDocumentListLookup = {
|
|
191
|
+
type: string;
|
|
192
|
+
resolveType: 'collectionDocumentList';
|
|
193
|
+
collection: string;
|
|
194
|
+
};
|
|
195
|
+
type UnionDataLookup = {
|
|
196
|
+
type: string;
|
|
197
|
+
resolveType: 'unionData';
|
|
198
|
+
collection?: string;
|
|
199
|
+
typeMap: {
|
|
200
|
+
[templateName: string]: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
export {};
|