@tinacms/graphql 0.0.0-202198235220 → 0.0.0-202201022290
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 +122 -2
- package/dist/{primitives/ast-builder → ast-builder}/index.d.ts +42 -2
- package/dist/build.d.ts +19 -0
- package/dist/{primitives/builder → builder}/index.d.ts +60 -3
- package/dist/{primitives/builder → builder}/static-definitions.d.ts +0 -0
- package/dist/{primitives/database/bridge.d.ts → database/bridge/index.d.ts} +6 -12
- package/dist/{primitives/database → database}/index.d.ts +28 -16
- package/dist/database/store/index.d.ts +74 -0
- package/dist/database/util.d.ts +16 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +2556 -1301
- package/dist/{primitives/mdx → mdx}/index.d.ts +0 -0
- package/dist/{primitives/mdx → mdx}/parse.d.ts +1 -1
- package/dist/{primitives/mdx → mdx}/stringify.d.ts +0 -0
- package/dist/{primitives/resolve.d.ts → resolve.d.ts} +0 -0
- package/dist/{primitives/resolver → resolver}/error.d.ts +12 -0
- package/dist/{primitives/resolver → resolver}/index.d.ts +92 -42
- package/dist/{primitives/schema → schema}/index.d.ts +24 -3
- package/dist/schema/validate.d.ts +14 -0
- package/dist/{primitives/build.d.ts → sdkBuilder/index.d.ts} +2 -4
- package/dist/{primitives/spec → spec}/setup.d.ts +24 -30
- package/dist/{primitives/types.d.ts → types.d.ts} +3 -2
- package/dist/{primitives/util.d.ts → util.d.ts} +0 -0
- package/package.json +13 -22
- package/dist/cache/lru.d.ts +0 -26
- package/dist/cache/s3.d.ts +0 -31
- package/dist/primitives/database/github.d.ts +0 -52
- package/dist/primitives/index.d.ts +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,130 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-202201022290
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- b66aefde1: Fixed issue where one could not add a title and then a bold text
|
|
8
|
+
|
|
9
|
+
## 0.59.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 34cd3a44a: Fix issue where frontmatter parser would return a Date object which would be cast to epoch format
|
|
14
|
+
- b006a5ab9: Added delete button to image field
|
|
15
|
+
- a324b9c37: Export utilities for working with the data layer
|
|
16
|
+
- 80732bd97: Create a @tinacms/datalayer package which houses the logic for data management for the GraphQL API. This simplifies the @tinacms/graphql package and allows for a clearer separation.
|
|
17
|
+
- 0bec208e2: validate the schema for `path` and `matches`
|
|
18
|
+
- 5c070a83f: feat: Add UI banner for when in localMode
|
|
19
|
+
|
|
20
|
+
## 0.59.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 212685fc3: Allow indexDB to skip building the query and fragment generation files
|
|
25
|
+
|
|
26
|
+
## 0.59.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- f46c6f987: Fix type definitions for schema metadata so they're optional
|
|
31
|
+
|
|
32
|
+
## 0.59.0
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- 62bea7019: #2323: fix saving bold and italic text in rich-text editor
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- bd4e1f802: Pin version number from @tinacms/graphql during schema compilation. This can be used to ensure the proper version is provided when working with Tina Cloud
|
|
41
|
+
|
|
42
|
+
## 0.58.2
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- fffce3af8: Don't cache graphql schema during resolution, this was causing the schema to go stale, while updating the schema.gql, so GraphQL tooling thought the value was updated, but the server was still holding on to the cached version
|
|
47
|
+
|
|
48
|
+
## 0.58.1
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 4700d7ae4: Patch fix to ensure builds include latest dependencies
|
|
53
|
+
|
|
54
|
+
## 0.58.0
|
|
55
|
+
|
|
56
|
+
### Minor Changes
|
|
57
|
+
|
|
58
|
+
- fa7a0419f: Adds experimental support for a data layer between file-based content and the GraphQL API. This allows documents to be indexed so the CMS can behave more like a traditional CMS, with the ability enforce foreign reference constraints and filtering/pagination capabilities.
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- eb5fbfac7: Ensure GraphQL resolve doesn't access "bridge" documents
|
|
63
|
+
- 47d126029: Fix support of objects in a list for MDX templates
|
|
64
|
+
|
|
65
|
+
## 0.57.2
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- edb2f4011: Trim path property on collections during compilation
|
|
70
|
+
|
|
71
|
+
## 0.57.1
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- 60729f60c: Adds a `reference` field
|
|
76
|
+
|
|
77
|
+
## 0.57.0
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- ed277e3bd: Remove aws dependency and cache logic from GithubBridge
|
|
82
|
+
- d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- 138ceb8c4: Clean up dependencies
|
|
87
|
+
- 577d6a5ad: Adds collection arg back for generic queries as optional
|
|
88
|
+
|
|
89
|
+
## 0.56.1
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- 4b7795612: Adds support for collection.templates to TinaAdmin
|
|
94
|
+
|
|
95
|
+
## 0.56.0
|
|
96
|
+
|
|
97
|
+
### Minor Changes
|
|
98
|
+
|
|
99
|
+
- b99baebf1: Add rich-text editor based on mdx, bump React dependency requirement to 16.14
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- 891623c7c: Adds support for List and Update to TinaAdmin
|
|
104
|
+
|
|
105
|
+
## 0.55.2
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- 9ecb392ca: Fix bug which would set markdown body to undefined when the payload was emptry"
|
|
110
|
+
|
|
111
|
+
## 0.55.1
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- ff4446c8e: Adds `getDocumentFields()` query for use with Tina Admin
|
|
116
|
+
- 667c33e2a: Add support for rich-text field, update build script to work with unified packages, which are ESM-only
|
|
117
|
+
|
|
118
|
+
## 0.55.0
|
|
119
|
+
|
|
120
|
+
### Minor Changes
|
|
121
|
+
|
|
122
|
+
- f3bddeb4a: Added new warning messages for list UI that we do not support by default
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- 2908f8176: Fixes an issue where nested reference fields weren't updated properly when their values changed.
|
|
127
|
+
- 5d83643b2: Adds create document mutations
|
|
8
128
|
|
|
9
129
|
## 0.54.3
|
|
10
130
|
|
|
@@ -10,7 +10,7 @@ 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 { FieldDefinitionNode, ScalarTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, UnionTypeDefinitionNode, TypeDefinitionNode, DirectiveNode, EnumTypeDefinitionNode, InputObjectTypeDefinitionNode, DocumentNode } from 'graphql';
|
|
13
|
+
import { FieldDefinitionNode, ScalarTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, UnionTypeDefinitionNode, TypeDefinitionNode, DirectiveNode, EnumTypeDefinitionNode, InputObjectTypeDefinitionNode, DocumentNode, FragmentDefinitionNode, SelectionNode, FieldNode, InlineFragmentNode, OperationDefinitionNode } from 'graphql';
|
|
14
14
|
/**
|
|
15
15
|
* the `gql` module provides functions and types which can be
|
|
16
16
|
* used to build up the GraphQL AST. The primary reason for us using
|
|
@@ -45,6 +45,13 @@ export declare const astBuilder: {
|
|
|
45
45
|
required?: boolean;
|
|
46
46
|
values: string[];
|
|
47
47
|
}) => EnumTypeDefinitionNode;
|
|
48
|
+
FieldNodeDefinition: ({ name, type, args, list, required, }: {
|
|
49
|
+
name: string;
|
|
50
|
+
type: string | TypeDefinitionNode;
|
|
51
|
+
required?: boolean;
|
|
52
|
+
list?: boolean;
|
|
53
|
+
args?: InputValueDefinitionNode[];
|
|
54
|
+
}) => FieldNode;
|
|
48
55
|
FieldDefinition: ({ name, type, args, list, required, }: {
|
|
49
56
|
name: string;
|
|
50
57
|
type: string | TypeDefinitionNode;
|
|
@@ -75,6 +82,29 @@ export declare const astBuilder: {
|
|
|
75
82
|
directives?: DirectiveNode[];
|
|
76
83
|
args?: NamedTypeNode[];
|
|
77
84
|
}) => ObjectTypeDefinitionNode;
|
|
85
|
+
FieldWithSelectionSetDefinition: ({ name, selections, }: {
|
|
86
|
+
name: string;
|
|
87
|
+
selections: SelectionNode[];
|
|
88
|
+
}) => {
|
|
89
|
+
name: {
|
|
90
|
+
kind: "Name";
|
|
91
|
+
value: string;
|
|
92
|
+
};
|
|
93
|
+
kind: "Field";
|
|
94
|
+
selectionSet: {
|
|
95
|
+
kind: "SelectionSet";
|
|
96
|
+
selections: SelectionNode[];
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
InlineFragmentDefinition: ({ name, selections, }: {
|
|
100
|
+
name: string;
|
|
101
|
+
selections: SelectionNode[];
|
|
102
|
+
}) => InlineFragmentNode;
|
|
103
|
+
FragmentDefinition: ({ name, fragmentName, selections, }: {
|
|
104
|
+
name: string;
|
|
105
|
+
fragmentName: string;
|
|
106
|
+
selections: SelectionNode[];
|
|
107
|
+
}) => FragmentDefinitionNode;
|
|
78
108
|
TYPES: {
|
|
79
109
|
Scalar: (type: scalarNames) => string;
|
|
80
110
|
MultiCollectionDocument: string;
|
|
@@ -92,6 +122,14 @@ export declare const astBuilder: {
|
|
|
92
122
|
Number: string;
|
|
93
123
|
Document: string;
|
|
94
124
|
};
|
|
125
|
+
QueryOperationDefinition: ({ queryName, fragName, }: {
|
|
126
|
+
queryName: string;
|
|
127
|
+
fragName: string;
|
|
128
|
+
}) => OperationDefinitionNode;
|
|
129
|
+
ListQueryOperationDefinition: ({ queryName, fragName, }: {
|
|
130
|
+
queryName: string;
|
|
131
|
+
fragName: string;
|
|
132
|
+
}) => OperationDefinitionNode;
|
|
95
133
|
toGraphQLAst: (ast: {
|
|
96
134
|
globalTemplates: TypeDefinitionNode[];
|
|
97
135
|
query: TypeDefinitionNode;
|
|
@@ -107,9 +145,11 @@ export declare const NAMER: {
|
|
|
107
145
|
dataFilterTypeName: (namespace: string[]) => string;
|
|
108
146
|
dataMutationTypeNameOn: (namespace: string[]) => string;
|
|
109
147
|
dataMutationTypeName: (namespace: string[]) => string;
|
|
110
|
-
|
|
148
|
+
updateName: (namespace: string[]) => string;
|
|
149
|
+
createName: (namespace: string[]) => string;
|
|
111
150
|
queryName: (namespace: string[]) => string;
|
|
112
151
|
generateQueryListName: (namespace: string[]) => string;
|
|
152
|
+
fragmentName: (namespace: string[]) => string;
|
|
113
153
|
collectionTypeName: (namespace: string[]) => string;
|
|
114
154
|
documentTypeName: (namespace: string[]) => string;
|
|
115
155
|
dataTypeName: (namespace: string[]) => string;
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 type { TinaSchema } from './schema';
|
|
14
|
+
import { Database } from './database';
|
|
15
|
+
export declare const indexDB: ({ database, config, buildSDK, }: {
|
|
16
|
+
database: Database;
|
|
17
|
+
config: TinaSchema['config'];
|
|
18
|
+
buildSDK?: boolean;
|
|
19
|
+
}) => Promise<void>;
|
|
@@ -11,8 +11,8 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { Database } from '../database';
|
|
14
|
-
import type { ObjectTypeDefinitionNode } from 'graphql';
|
|
15
|
-
import type { TinaCloudCollectionEnriched } from '../types';
|
|
14
|
+
import type { ObjectTypeDefinitionNode, InlineFragmentNode } from 'graphql';
|
|
15
|
+
import type { TinaCloudCollectionEnriched, Template } from '../types';
|
|
16
16
|
import { TinaSchema } from '../schema';
|
|
17
17
|
export declare const createBuilder: ({ database, tinaSchema, }: {
|
|
18
18
|
database: Database;
|
|
@@ -88,6 +88,14 @@ export declare class Builder {
|
|
|
88
88
|
* @param collections
|
|
89
89
|
*/
|
|
90
90
|
multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
|
|
91
|
+
/**
|
|
92
|
+
* ```graphql
|
|
93
|
+
* {
|
|
94
|
+
* getDocumentFields()
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
multiCollectionDocumentFields: () => Promise<import("graphql").FieldDefinitionNode>;
|
|
91
99
|
/**
|
|
92
100
|
* ```graphql
|
|
93
101
|
* # ex.
|
|
@@ -102,6 +110,20 @@ export declare class Builder {
|
|
|
102
110
|
* @param collections
|
|
103
111
|
*/
|
|
104
112
|
addMultiCollectionDocumentMutation: () => Promise<import("graphql").FieldDefinitionNode>;
|
|
113
|
+
/**
|
|
114
|
+
* ```graphql
|
|
115
|
+
* # ex.
|
|
116
|
+
* {
|
|
117
|
+
* createDocument(relativePath: $relativePath, params: $params) {
|
|
118
|
+
* id
|
|
119
|
+
* data {...}
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @param collections
|
|
125
|
+
*/
|
|
126
|
+
buildCreateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
|
|
105
127
|
/**
|
|
106
128
|
* ```graphql
|
|
107
129
|
* # ex.
|
|
@@ -115,7 +137,7 @@ export declare class Builder {
|
|
|
115
137
|
*
|
|
116
138
|
* @param collections
|
|
117
139
|
*/
|
|
118
|
-
|
|
140
|
+
buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
|
|
119
141
|
/**
|
|
120
142
|
* ```graphql
|
|
121
143
|
* # ex.
|
|
@@ -147,6 +169,23 @@ export declare class Builder {
|
|
|
147
169
|
* @param collection
|
|
148
170
|
*/
|
|
149
171
|
collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
|
|
172
|
+
/**
|
|
173
|
+
* Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
|
|
174
|
+
* ```graphql
|
|
175
|
+
* # ex.
|
|
176
|
+
* fragment AuthorsParts on Authors {
|
|
177
|
+
* name
|
|
178
|
+
* avatar
|
|
179
|
+
* ...
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
* @param collection a Tina Cloud collection
|
|
185
|
+
*/
|
|
186
|
+
collectionFragment: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FragmentDefinitionNode>;
|
|
187
|
+
private _buildFieldNodeForFragments;
|
|
188
|
+
buildTemplateFragments(template: Template<true>): Promise<InlineFragmentNode>;
|
|
150
189
|
/**
|
|
151
190
|
* ```graphql
|
|
152
191
|
* # ex.
|
|
@@ -161,6 +200,20 @@ export declare class Builder {
|
|
|
161
200
|
* @param collection
|
|
162
201
|
*/
|
|
163
202
|
updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
|
|
203
|
+
/**
|
|
204
|
+
* ```graphql
|
|
205
|
+
* # ex.
|
|
206
|
+
* mutation {
|
|
207
|
+
* createPostDocument(relativePath: $relativePath, params: $params) {
|
|
208
|
+
* id
|
|
209
|
+
* data {...}
|
|
210
|
+
* }
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @param collection
|
|
215
|
+
*/
|
|
216
|
+
createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
|
|
164
217
|
/**
|
|
165
218
|
* ```graphql
|
|
166
219
|
* # ex.
|
|
@@ -184,13 +237,17 @@ export declare class Builder {
|
|
|
184
237
|
*/
|
|
185
238
|
buildStaticDefinitions: () => (import("graphql").ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode[])[];
|
|
186
239
|
private _buildCollectionDocumentType;
|
|
240
|
+
private _filterCollectionDocumentType;
|
|
241
|
+
private _buildTemplateFilter;
|
|
187
242
|
private _updateCollectionDocumentMutationType;
|
|
188
243
|
private _buildTemplateMutation;
|
|
189
244
|
private _buildMultiCollectionDocumentDefinition;
|
|
190
245
|
private _buildMultiCollectionDocumentListDefinition;
|
|
246
|
+
private _buildFieldFilter;
|
|
191
247
|
private _buildFieldMutation;
|
|
192
248
|
private _buildReferenceMutation;
|
|
193
249
|
private _buildObjectOrUnionData;
|
|
250
|
+
private _connectionFilterBuilder;
|
|
194
251
|
private _connectionFieldBuilder;
|
|
195
252
|
private _buildDataField;
|
|
196
253
|
private _buildTemplateData;
|
|
File without changes
|
|
@@ -10,20 +10,14 @@ 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
|
-
/**
|
|
14
|
-
* This is the bridge from whatever datasource we need for I/O.
|
|
15
|
-
* The basic example here is for the filesystem, one is needed
|
|
16
|
-
* for Github has well.
|
|
17
|
-
*/
|
|
18
|
-
export declare class FilesystemBridge implements Bridge {
|
|
19
|
-
rootPath: string;
|
|
20
|
-
constructor(rootPath: string);
|
|
21
|
-
glob(pattern: string): Promise<string[]>;
|
|
22
|
-
get(filepath: string): Promise<string>;
|
|
23
|
-
put(filepath: string, data: string): Promise<void>;
|
|
24
|
-
}
|
|
25
13
|
export interface Bridge {
|
|
14
|
+
rootPath: string;
|
|
26
15
|
glob(pattern: string): Promise<string[]>;
|
|
27
16
|
get(filepath: string): Promise<string>;
|
|
28
17
|
put(filepath: string, data: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Whether this bridge supports the ability to build the schema.
|
|
20
|
+
*/
|
|
21
|
+
supportsBuilding(): boolean;
|
|
22
|
+
putConfig(filepath: string, data: string): Promise<void>;
|
|
29
23
|
}
|
|
@@ -10,43 +10,53 @@ 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 {
|
|
13
|
+
import type { DocumentNode } from 'graphql';
|
|
14
|
+
import type { TinaSchema } from '../schema';
|
|
14
15
|
import type { TinaCloudSchemaBase } from '../types';
|
|
15
|
-
import {
|
|
16
|
+
import type { Store } from './store';
|
|
17
|
+
import type { Bridge } from './bridge';
|
|
16
18
|
declare type CreateDatabase = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
bridge: Bridge;
|
|
20
|
+
store: Store;
|
|
19
21
|
};
|
|
20
22
|
export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
|
|
21
23
|
export declare class Database {
|
|
22
24
|
config: CreateDatabase;
|
|
23
25
|
bridge: Bridge;
|
|
26
|
+
store: Store;
|
|
24
27
|
private tinaSchema;
|
|
25
28
|
private _lookup;
|
|
26
29
|
private _graphql;
|
|
27
30
|
private _tinaSchema;
|
|
28
31
|
constructor(config: CreateDatabase);
|
|
29
32
|
get: <T extends object>(filepath: string) => Promise<T>;
|
|
33
|
+
addPendingDocument: (filepath: string, data: {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}) => Promise<void>;
|
|
30
36
|
put: (filepath: string, data: {
|
|
31
37
|
[key: string]: unknown;
|
|
32
38
|
}) => Promise<boolean>;
|
|
39
|
+
stringifyFile: (filepath: string, data: {
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
stringifiedFile: string;
|
|
43
|
+
payload: {
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
flush: (filepath: string) => Promise<string>;
|
|
33
48
|
getLookup: (returnType: string) => Promise<LookupMapType>;
|
|
34
49
|
getGraphQLSchema: () => Promise<DocumentNode>;
|
|
50
|
+
getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
|
|
35
51
|
getTinaSchema: () => Promise<TinaCloudSchemaBase>;
|
|
36
|
-
|
|
37
|
-
getDocument: (fullPath: unknown) => Promise<{
|
|
38
|
-
__typename: string;
|
|
39
|
-
id: string;
|
|
40
|
-
data: {
|
|
41
|
-
_collection: string;
|
|
42
|
-
_template: string;
|
|
43
|
-
};
|
|
44
|
-
}>;
|
|
52
|
+
getSchema: () => Promise<TinaSchema>;
|
|
45
53
|
documentExists: (fullpath: unknown) => Promise<boolean>;
|
|
46
|
-
|
|
54
|
+
query: (queryStrings: string[], hydrator: any) => Promise<object[]>;
|
|
55
|
+
indexData: ({ graphQLSchema, tinaSchema, }: {
|
|
56
|
+
graphQLSchema: DocumentNode;
|
|
57
|
+
tinaSchema: TinaSchema;
|
|
58
|
+
}) => Promise<void>;
|
|
47
59
|
addToLookupMap: (lookup: LookupMapType) => Promise<void>;
|
|
48
|
-
private stringifyFile;
|
|
49
|
-
private parseFile;
|
|
50
60
|
}
|
|
51
61
|
export declare type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
|
|
52
62
|
declare type NodeDocument = {
|
|
@@ -66,6 +76,8 @@ declare type CollectionDocumentLookup = {
|
|
|
66
76
|
declare type MultiCollectionDocumentLookup = {
|
|
67
77
|
type: string;
|
|
68
78
|
resolveType: 'multiCollectionDocument';
|
|
79
|
+
createDocument: 'create';
|
|
80
|
+
updateDocument: 'update';
|
|
69
81
|
};
|
|
70
82
|
declare type MultiCollectionDocumentListLookup = {
|
|
71
83
|
type: string;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
export interface Store {
|
|
14
|
+
glob(pattern: string, hydrator?: (fullPath: string) => Promise<object>): Promise<string[]>;
|
|
15
|
+
get<T extends object>(filepath: string): Promise<T>;
|
|
16
|
+
clear(): void;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param queryStrings
|
|
20
|
+
* Queries are currently structured as prefixed keys where that last portion
|
|
21
|
+
* of the key is the value provided by the query
|
|
22
|
+
* ```graphql
|
|
23
|
+
* {
|
|
24
|
+
* getPostsList(filter: {
|
|
25
|
+
* title: {
|
|
26
|
+
* eq: "Hello, World"
|
|
27
|
+
* }
|
|
28
|
+
* }) {
|
|
29
|
+
* ...
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
* Would equate to a query string of:
|
|
34
|
+
* ```
|
|
35
|
+
* __attribute__#posts#posts#title#Hello, World
|
|
36
|
+
* ```
|
|
37
|
+
* This can be used by a data store as a secondary index of sorts
|
|
38
|
+
*
|
|
39
|
+
* It's important to note that for now each query string acts as an "AND" clause,
|
|
40
|
+
* meaning the resulting records need to be present in _each_ query string.
|
|
41
|
+
*
|
|
42
|
+
* @param hydrator
|
|
43
|
+
* hydrator is an optional callback, which may be useful depending on the storage mechanism.
|
|
44
|
+
* For example, the in-memory storage only stores the path to its records as its value,
|
|
45
|
+
* but in something like DynamoDB the query strings may be used to look up the full record,
|
|
46
|
+
* meaning there's no need to "hydrate" the return value
|
|
47
|
+
*/
|
|
48
|
+
query(queryStrings: string[], hydrator?: (fullPath: string) => Promise<object>): Promise<object[]>;
|
|
49
|
+
/**
|
|
50
|
+
* In this context, seeding is the act of putting records and indexing data into an ephemeral
|
|
51
|
+
* storage layer for use during the GraphQL runtime. What might seem suprising is that some stores
|
|
52
|
+
* don't support seeding, this is because they're behaving more like a "bridge" (GithubStore and FilesystemStore).
|
|
53
|
+
* Currently they're acting as a way to swap out true data-layer behavior with a backwards-compatible
|
|
54
|
+
* "store". In the future, all stores should be able to query and seed data.
|
|
55
|
+
*
|
|
56
|
+
* At this time it seems that it would never make sense to be able to "query" without "seed"-ing, and
|
|
57
|
+
* there'd be no value in "seeding" without "query"-ing.
|
|
58
|
+
*/
|
|
59
|
+
seed(filepath: string, data: object, options?: {
|
|
60
|
+
includeTemplate?: boolean;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
supportsSeeding(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether this store supports the ability to index data.
|
|
65
|
+
* Indexing data requires writing arbitrary keys/values to
|
|
66
|
+
* the external service, so is not advisable to use for
|
|
67
|
+
* something like Github, which would write commits to the
|
|
68
|
+
* user's repo.
|
|
69
|
+
*/
|
|
70
|
+
supportsIndexing(): boolean;
|
|
71
|
+
put(filepath: string, data: object, options?: {
|
|
72
|
+
includeTemplate?: boolean;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 yup from 'yup';
|
|
14
|
+
export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean) => string;
|
|
15
|
+
export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>) => T;
|
|
16
|
+
export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
|
package/dist/index.d.ts
CHANGED
|
@@ -10,13 +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
|
-
export {
|
|
14
|
-
export
|
|
15
|
-
export {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
|
|
13
|
+
export { indexDB } from './build';
|
|
14
|
+
export { resolve } from './resolve';
|
|
15
|
+
export { createDatabase } from './database';
|
|
16
|
+
import type { Database } from './database';
|
|
17
|
+
export type { Store } from './database/store';
|
|
18
|
+
export type { Bridge } from './database/bridge';
|
|
19
|
+
export { stringifyFile, parseFile } from './database/util';
|
|
20
|
+
export { sequential } from './util';
|
|
21
|
+
export declare const buildSchema: (rootPath: string, database: Database) => Promise<import("graphql").GraphQLSchema>;
|
|
22
|
+
import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
|
|
20
23
|
export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
|
|
21
24
|
export declare type TinaSchema = TinaCloudSchema;
|
|
22
25
|
export declare type TinaCloudCollection = TinaCloudCollectionBase<false>;
|