@tinacms/graphql 0.55.1 → 0.57.0-hotfix

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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # tina-graphql
2
2
 
3
+ ## 0.57.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ed277e3bd: Remove aws dependency and cache logic from GithubBridge
8
+ - d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
9
+
10
+ ### Patch Changes
11
+
12
+ - 138ceb8c4: Clean up dependencies
13
+ - 577d6a5ad: Adds collection arg back for generic queries as optional
14
+
15
+ ## 0.56.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 4b7795612: Adds support for collection.templates to TinaAdmin
20
+
21
+ ## 0.56.0
22
+
23
+ ### Minor Changes
24
+
25
+ - b99baebf1: Add rich-text editor based on mdx, bump React dependency requirement to 16.14
26
+
27
+ ### Patch Changes
28
+
29
+ - 891623c7c: Adds support for List and Update to TinaAdmin
30
+
31
+ ## 0.55.2
32
+
33
+ ### Patch Changes
34
+
35
+ - 9ecb392ca: Fix bug which would set markdown body to undefined when the payload was emptry"
36
+
3
37
  ## 0.55.1
4
38
 
5
39
  ### Patch Changes
@@ -0,0 +1,159 @@
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 { FieldDefinitionNode, ScalarTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, UnionTypeDefinitionNode, TypeDefinitionNode, DirectiveNode, EnumTypeDefinitionNode, InputObjectTypeDefinitionNode, DocumentNode, FragmentDefinitionNode, SelectionNode, FieldNode, InlineFragmentNode, OperationDefinitionNode } from 'graphql';
14
+ /**
15
+ * the `gql` module provides functions and types which can be
16
+ * used to build up the GraphQL AST. The primary reason for us using
17
+ * this instead of the [builders provided by the graphql package](https://graphql.org/graphql-js/type/#examples)
18
+ * is due to the dynamic and asynchronous nature of our needs.
19
+ *
20
+ * The tradeoff is a low-level API that's often more verbose, and it's
21
+ * not a complete match of the GraphQL spec, so additional properties will likely
22
+ * be needed as our needs grow.
23
+ */
24
+ export declare const astBuilder: {
25
+ /**
26
+ * `FormFieldBuilder` acts as a shortcut to building an entire `ObjectTypeDefinition`, we use this
27
+ * because all Tina field objects share a common set of fields ('name', 'label', 'component')
28
+ */
29
+ FormFieldBuilder: ({ name, additionalFields, }: {
30
+ name: string;
31
+ additionalFields?: FieldDefinitionNode[];
32
+ }) => ObjectTypeDefinitionNode;
33
+ ScalarTypeDefinition: ({ name, description, }: {
34
+ name: string;
35
+ description?: string;
36
+ }) => ScalarTypeDefinitionNode;
37
+ InputValueDefinition: ({ name, type, list, required, }: {
38
+ name: string;
39
+ type: string | InputObjectTypeDefinitionNode | EnumTypeDefinitionNode;
40
+ list?: boolean;
41
+ required?: boolean;
42
+ }) => InputValueDefinitionNode;
43
+ EnumDefinition: (props: {
44
+ name: string;
45
+ required?: boolean;
46
+ values: string[];
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;
55
+ FieldDefinition: ({ name, type, args, list, required, }: {
56
+ name: string;
57
+ type: string | TypeDefinitionNode;
58
+ required?: boolean;
59
+ list?: boolean;
60
+ args?: InputValueDefinitionNode[];
61
+ }) => FieldDefinitionNode;
62
+ InterfaceTypeDefinition: ({ name, fields, description, }: {
63
+ name: string;
64
+ description?: string;
65
+ fields: FieldDefinitionNode[];
66
+ }) => InterfaceTypeDefinitionNode;
67
+ InputObjectTypeDefinition: ({ name, fields, }: {
68
+ name: string;
69
+ fields: InputValueDefinitionNode[] | ObjectTypeDefinitionNode[];
70
+ }) => InputObjectTypeDefinitionNode;
71
+ UnionTypeDefinition: ({ name, types, }: {
72
+ name: string;
73
+ types: (string | TypeDefinitionNode)[];
74
+ }) => UnionTypeDefinitionNode;
75
+ NamedType: ({ name }: {
76
+ name: string;
77
+ }) => NamedTypeNode;
78
+ ObjectTypeDefinition: ({ name, fields, interfaces, directives, args, }: {
79
+ name: string;
80
+ fields: FieldDefinitionNode[];
81
+ interfaces?: NamedTypeNode[];
82
+ directives?: DirectiveNode[];
83
+ args?: NamedTypeNode[];
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;
108
+ TYPES: {
109
+ Scalar: (type: scalarNames) => string;
110
+ MultiCollectionDocument: string;
111
+ CollectionDocumentUnion: string;
112
+ String: string;
113
+ Reference: string;
114
+ Collection: string;
115
+ ID: string;
116
+ SystemInfo: string;
117
+ Boolean: string;
118
+ JSON: string;
119
+ Node: string;
120
+ PageInfo: string;
121
+ Connection: string;
122
+ Number: string;
123
+ Document: string;
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;
133
+ toGraphQLAst: (ast: {
134
+ globalTemplates: TypeDefinitionNode[];
135
+ query: TypeDefinitionNode;
136
+ definitions: TypeDefinitionNode[];
137
+ }) => DocumentNode;
138
+ };
139
+ declare type scalarNames = 'string' | 'boolean' | 'datetime' | 'image' | 'text' | 'number';
140
+ export declare const extractInlineTypes: (item: TypeDefinitionNode | TypeDefinitionNode[]) => TypeDefinitionNode[];
141
+ export declare function walk(maybeNode: TypeDefinitionNode, visited?: WeakSet<object>): IterableIterator<TypeDefinitionNode>;
142
+ export declare function addNamespaceToSchema<T extends object | string>(maybeNode: T, namespace?: string[]): T;
143
+ export declare const NAMER: {
144
+ dataFilterTypeNameOn: (namespace: string[]) => string;
145
+ dataFilterTypeName: (namespace: string[]) => string;
146
+ dataMutationTypeNameOn: (namespace: string[]) => string;
147
+ dataMutationTypeName: (namespace: string[]) => string;
148
+ updateName: (namespace: string[]) => string;
149
+ createName: (namespace: string[]) => string;
150
+ queryName: (namespace: string[]) => string;
151
+ generateQueryListName: (namespace: string[]) => string;
152
+ fragmentName: (namespace: string[]) => string;
153
+ collectionTypeName: (namespace: string[]) => string;
154
+ documentTypeName: (namespace: string[]) => string;
155
+ dataTypeName: (namespace: string[]) => string;
156
+ referenceConnectionType: (namespace: string[]) => string;
157
+ referenceConnectionEdgesTypeName: (namespace: string[]) => string;
158
+ };
159
+ export {};
@@ -10,22 +10,10 @@ 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 { S3 } from 'aws-sdk';
14
- export declare const clearCacheWith: (cache: S3) => ({ owner, repo, ref, path, }: {
15
- owner: string;
16
- repo: string;
17
- ref: string;
18
- path?: string;
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
19
  }) => Promise<void>;
20
- export declare const s3CacheWith: (cache: S3) => {
21
- get: (keyName: string, setter: () => Promise<any>) => Promise<any>;
22
- };
23
- export declare const clearCache: ({ owner, repo, ref, path, }: {
24
- owner: string;
25
- repo: string;
26
- ref: string;
27
- path?: string;
28
- }) => Promise<void>;
29
- export declare const s3Cache: {
30
- get: (keyName: string, setter: () => Promise<any>) => Promise<any>;
31
- };
@@ -0,0 +1,254 @@
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 { Database } from '../database';
14
+ import type { ObjectTypeDefinitionNode, InlineFragmentNode } from 'graphql';
15
+ import type { TinaCloudCollectionEnriched, Template } from '../types';
16
+ import { TinaSchema } from '../schema';
17
+ export declare const createBuilder: ({ database, tinaSchema, }: {
18
+ database: Database;
19
+ tinaSchema: TinaSchema;
20
+ }) => Promise<Builder>;
21
+ /**
22
+ * The builder class is responsible for creating GraphQL AST definitions
23
+ * for a given portion of the Tina schema. In some cases that will also mean
24
+ * storing a reference to how we can resolve that type when we come across it.
25
+ */
26
+ export declare class Builder {
27
+ config: {
28
+ database: Database;
29
+ tinaSchema: TinaSchema;
30
+ };
31
+ tinaSchema: TinaSchema;
32
+ database: Database;
33
+ constructor(config: {
34
+ database: Database;
35
+ tinaSchema: TinaSchema;
36
+ });
37
+ /**
38
+ * ```graphql
39
+ * # ex.
40
+ * {
41
+ * getCollection(collection: $collection) {
42
+ * name
43
+ * documents {...}
44
+ * }
45
+ * }
46
+ * ```
47
+ *
48
+ * @param collections
49
+ */
50
+ buildCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
51
+ /**
52
+ * ```graphql
53
+ * # ex.
54
+ * {
55
+ * getCollections {
56
+ * name
57
+ * documents {...}
58
+ * }
59
+ * }
60
+ * ```
61
+ *
62
+ * @param collections
63
+ */
64
+ buildMultiCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
65
+ /**
66
+ * ```graphql
67
+ * # ex.
68
+ * {
69
+ * node(id: $id) {
70
+ * id
71
+ * data {...}
72
+ * }
73
+ * }
74
+ * ```
75
+ */
76
+ multiNodeDocument: () => Promise<import("graphql").FieldDefinitionNode>;
77
+ /**
78
+ * ```graphql
79
+ * # ex.
80
+ * {
81
+ * getDocument(collection: $collection, relativePath: $relativePath) {
82
+ * id
83
+ * data {...}
84
+ * }
85
+ * }
86
+ * ```
87
+ *
88
+ * @param collections
89
+ */
90
+ multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
91
+ /**
92
+ * ```graphql
93
+ * {
94
+ * getDocumentFields()
95
+ * }
96
+ * ```
97
+ */
98
+ multiCollectionDocumentFields: () => Promise<import("graphql").FieldDefinitionNode>;
99
+ /**
100
+ * ```graphql
101
+ * # ex.
102
+ * {
103
+ * addPendingDocument(collection: $collection, relativePath: $relativePath, params: $params) {
104
+ * id
105
+ * data {...}
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @param collections
111
+ */
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>;
127
+ /**
128
+ * ```graphql
129
+ * # ex.
130
+ * {
131
+ * updateDocument(relativePath: $relativePath, params: $params) {
132
+ * id
133
+ * data {...}
134
+ * }
135
+ * }
136
+ * ```
137
+ *
138
+ * @param collections
139
+ */
140
+ buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
141
+ /**
142
+ * ```graphql
143
+ * # ex.
144
+ * {
145
+ * getDocumentList(first: 10) {
146
+ * edges {
147
+ * node {
148
+ * id
149
+ * }
150
+ * }
151
+ * }
152
+ * }
153
+ * ```
154
+ *
155
+ * @param collections
156
+ */
157
+ multiCollectionDocumentList: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
158
+ /**
159
+ * ```graphql
160
+ * # ex.
161
+ * {
162
+ * getPostDocument(relativePath: $relativePath) {
163
+ * id
164
+ * data {...}
165
+ * }
166
+ * }
167
+ * ```
168
+ *
169
+ * @param collection
170
+ */
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>;
189
+ /**
190
+ * ```graphql
191
+ * # ex.
192
+ * mutation {
193
+ * updatePostDocument(relativePath: $relativePath, params: $params) {
194
+ * id
195
+ * data {...}
196
+ * }
197
+ * }
198
+ * ```
199
+ *
200
+ * @param collection
201
+ */
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>;
217
+ /**
218
+ * ```graphql
219
+ * # ex.
220
+ * {
221
+ * getPostList(first: 10) {
222
+ * edges {
223
+ * node {
224
+ * id
225
+ * }
226
+ * }
227
+ * }
228
+ * }
229
+ * ```
230
+ *
231
+ * @param collection
232
+ */
233
+ collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
234
+ /**
235
+ * GraphQL type definitions which remain unchanged regardless
236
+ * of the supplied Tina schema. Ex. "node" interface
237
+ */
238
+ buildStaticDefinitions: () => (import("graphql").ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode[])[];
239
+ private _buildCollectionDocumentType;
240
+ private _filterCollectionDocumentType;
241
+ private _buildTemplateFilter;
242
+ private _updateCollectionDocumentMutationType;
243
+ private _buildTemplateMutation;
244
+ private _buildMultiCollectionDocumentDefinition;
245
+ private _buildMultiCollectionDocumentListDefinition;
246
+ private _buildFieldFilter;
247
+ private _buildFieldMutation;
248
+ private _buildReferenceMutation;
249
+ private _buildObjectOrUnionData;
250
+ private _connectionFilterBuilder;
251
+ private _connectionFieldBuilder;
252
+ private _buildDataField;
253
+ private _buildTemplateData;
254
+ }
@@ -0,0 +1,13 @@
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 declare const staticDefinitions: (import("graphql").ScalarTypeDefinitionNode | import("graphql").ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode[])[];
@@ -0,0 +1,23 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ export interface Bridge {
14
+ rootPath: string;
15
+ glob(pattern: string): Promise<string[]>;
16
+ get(filepath: string): Promise<string>;
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>;
23
+ }
@@ -0,0 +1,99 @@
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 { DocumentNode } from 'graphql';
14
+ import type { TinaSchema } from '../schema';
15
+ import type { TinaCloudSchemaBase } from '../types';
16
+ import type { Store } from './store';
17
+ import type { Bridge } from './bridge';
18
+ declare type CreateDatabase = {
19
+ bridge: Bridge;
20
+ store: Store;
21
+ };
22
+ export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
23
+ export declare class Database {
24
+ config: CreateDatabase;
25
+ bridge: Bridge;
26
+ store: Store;
27
+ private tinaSchema;
28
+ private _lookup;
29
+ private _graphql;
30
+ private _tinaSchema;
31
+ constructor(config: CreateDatabase);
32
+ get: <T extends object>(filepath: string) => Promise<T>;
33
+ addPendingDocument: (filepath: string, data: {
34
+ [key: string]: unknown;
35
+ }) => Promise<void>;
36
+ put: (filepath: string, data: {
37
+ [key: string]: unknown;
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>;
48
+ getLookup: (returnType: string) => Promise<LookupMapType>;
49
+ getGraphQLSchema: () => Promise<DocumentNode>;
50
+ getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
51
+ getTinaSchema: () => Promise<TinaCloudSchemaBase>;
52
+ getSchema: () => Promise<TinaSchema>;
53
+ documentExists: (fullpath: unknown) => Promise<boolean>;
54
+ query: (queryStrings: string[], hydrator: any) => Promise<object[]>;
55
+ indexData: ({ graphQLSchema, tinaSchema, }: {
56
+ graphQLSchema: DocumentNode;
57
+ tinaSchema: TinaSchema;
58
+ }) => Promise<void>;
59
+ addToLookupMap: (lookup: LookupMapType) => Promise<void>;
60
+ }
61
+ export declare type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
62
+ declare type NodeDocument = {
63
+ type: string;
64
+ resolveType: 'nodeDocument';
65
+ };
66
+ declare type GlobalDocumentLookup = {
67
+ type: string;
68
+ resolveType: 'globalDocument';
69
+ collection: string;
70
+ };
71
+ declare type CollectionDocumentLookup = {
72
+ type: string;
73
+ resolveType: 'collectionDocument';
74
+ collection: string;
75
+ };
76
+ declare type MultiCollectionDocumentLookup = {
77
+ type: string;
78
+ resolveType: 'multiCollectionDocument';
79
+ createDocument: 'create';
80
+ updateDocument: 'update';
81
+ };
82
+ declare type MultiCollectionDocumentListLookup = {
83
+ type: string;
84
+ resolveType: 'multiCollectionDocumentList';
85
+ collections: string[];
86
+ };
87
+ export declare type CollectionDocumentListLookup = {
88
+ type: string;
89
+ resolveType: 'collectionDocumentList';
90
+ collection: string;
91
+ };
92
+ declare type UnionDataLookup = {
93
+ type: string;
94
+ resolveType: 'unionData';
95
+ typeMap: {
96
+ [templateName: string]: string;
97
+ };
98
+ };
99
+ export {};
@@ -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
+ }