@tinacms/graphql 0.59.8 → 0.59.11
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 +62 -0
- package/dist/builder/index.d.ts +14 -0
- package/dist/database/bridge/index.d.ts +1 -0
- package/dist/database/index.d.ts +30 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +477 -189
- package/dist/mdx/parse.d.ts +1 -0
- package/dist/resolver/filter-utils.d.ts +22 -0
- package/dist/resolver/index.d.ts +19 -10
- package/dist/spec/setup.d.ts +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +4 -4
- package/dist/database/store/index.d.ts +0 -72
package/dist/mdx/parse.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
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 { ReferenceTypeInner, TinaFieldInner } from '../types';
|
|
14
|
+
import type { FilterCondition } from '@tinacms/datalayer';
|
|
15
|
+
export declare type ReferenceResolver = (filter: Record<string, object>, fieldDefinition: ReferenceTypeInner) => Promise<{
|
|
16
|
+
edges: {
|
|
17
|
+
node: any;
|
|
18
|
+
}[];
|
|
19
|
+
values: any[];
|
|
20
|
+
}>;
|
|
21
|
+
export declare const resolveReferences: (filter: any, fields: TinaFieldInner<false>[], resolver: ReferenceResolver) => Promise<void>;
|
|
22
|
+
export declare const collectConditionsForField: (fieldName: string, field: TinaFieldInner<false>, filterNode: Record<string, object>, pathExpression: string, collectCondition: (condition: FilterCondition) => void) => void;
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { TinaSchema } from '../schema';
|
|
14
|
-
import { Database
|
|
15
|
-
import type { Collectable, TinaCloudCollection } from '../types';
|
|
14
|
+
import { Database } from '../database';
|
|
15
|
+
import type { Collectable, ReferenceTypeWithNamespace, TinaCloudCollection } from '../types';
|
|
16
|
+
import { TinaFieldInner } from '../types';
|
|
16
17
|
interface ResolverConfig {
|
|
17
18
|
database: Database;
|
|
18
19
|
tinaSchema: TinaSchema;
|
|
@@ -28,32 +29,34 @@ export declare class Resolver {
|
|
|
28
29
|
tinaSchema: TinaSchema;
|
|
29
30
|
constructor(init: ResolverConfig);
|
|
30
31
|
resolveCollection: (collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
31
|
-
fields: string |
|
|
32
|
+
fields: string | TinaFieldInner<true>[];
|
|
32
33
|
templates?: undefined;
|
|
33
|
-
references?:
|
|
34
|
+
references?: ReferenceTypeWithNamespace[];
|
|
34
35
|
namespace: string[];
|
|
35
36
|
label?: string;
|
|
36
37
|
name: string;
|
|
37
38
|
path: string;
|
|
38
39
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
39
40
|
match?: string;
|
|
41
|
+
indexes?: import("../types").TinaIndex[];
|
|
40
42
|
documents: {};
|
|
41
43
|
} | {
|
|
42
44
|
templates: (string | {
|
|
43
45
|
label: string;
|
|
44
46
|
name: string;
|
|
45
|
-
fields:
|
|
47
|
+
fields: TinaFieldInner<true>[];
|
|
46
48
|
ui?: object;
|
|
47
49
|
namespace: string[];
|
|
48
50
|
})[];
|
|
49
51
|
fields?: undefined;
|
|
50
|
-
references?:
|
|
52
|
+
references?: ReferenceTypeWithNamespace[];
|
|
51
53
|
namespace: string[];
|
|
52
54
|
label?: string;
|
|
53
55
|
name: string;
|
|
54
56
|
path: string;
|
|
55
57
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
56
58
|
match?: string;
|
|
59
|
+
indexes?: import("../types").TinaIndex[];
|
|
57
60
|
documents: {};
|
|
58
61
|
}>;
|
|
59
62
|
getDocument: (fullPath: unknown) => Promise<{
|
|
@@ -87,6 +90,7 @@ export declare class Resolver {
|
|
|
87
90
|
fields: unknown[];
|
|
88
91
|
};
|
|
89
92
|
}>;
|
|
93
|
+
deleteDocument: (fullPath: unknown) => Promise<void>;
|
|
90
94
|
getDocumentFields: () => Promise<{}>;
|
|
91
95
|
buildObjectMutations: (fieldValue: any, field: Collectable) => {
|
|
92
96
|
[key: string]: unknown;
|
|
@@ -166,11 +170,12 @@ export declare class Resolver {
|
|
|
166
170
|
fields: unknown[];
|
|
167
171
|
};
|
|
168
172
|
}>;
|
|
169
|
-
resolveDocument: ({ args, collection: collectionName, isMutation, isCreation, isAddPendingDocument, isCollectionSpecific, }: {
|
|
173
|
+
resolveDocument: ({ args, collection: collectionName, isMutation, isCreation, isDeletion, isAddPendingDocument, isCollectionSpecific, }: {
|
|
170
174
|
args: unknown;
|
|
171
175
|
collection?: string;
|
|
172
176
|
isMutation: boolean;
|
|
173
177
|
isCreation?: boolean;
|
|
178
|
+
isDeletion?: boolean;
|
|
174
179
|
isAddPendingDocument?: boolean;
|
|
175
180
|
isCollectionSpecific?: boolean;
|
|
176
181
|
}) => Promise<{
|
|
@@ -243,12 +248,16 @@ export declare class Resolver {
|
|
|
243
248
|
}[];
|
|
244
249
|
}>;
|
|
245
250
|
getDocumentsForCollection: (collectionName: string) => Promise<string[]>;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
private referenceResolver;
|
|
252
|
+
private resolveFilterConditions;
|
|
253
|
+
resolveCollectionConnection: ({ args, collection, hydrator, }: {
|
|
254
|
+
args: Record<string, Record<string, object> | string | number>;
|
|
255
|
+
collection: TinaCloudCollection<true>;
|
|
256
|
+
hydrator?: (string: any) => any;
|
|
249
257
|
}) => Promise<{
|
|
250
258
|
totalCount: any;
|
|
251
259
|
edges: any;
|
|
260
|
+
pageInfo: any;
|
|
252
261
|
}>;
|
|
253
262
|
private buildFieldMutations;
|
|
254
263
|
private resolveFieldData;
|
package/dist/spec/setup.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ 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 { Store } from '
|
|
14
|
+
import type { Store } from '@tinacms/datalayer';
|
|
15
15
|
import type { TinaCloudSchema } from '../types';
|
|
16
16
|
export declare const setup: (rootPath: string, schema: TinaCloudSchema<false>, store: Store) => Promise<{
|
|
17
17
|
database: Database;
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ interface BaseCollection {
|
|
|
36
36
|
path: string;
|
|
37
37
|
format?: FormatType;
|
|
38
38
|
match?: string;
|
|
39
|
+
indexes?: TinaIndex[];
|
|
39
40
|
}
|
|
40
41
|
declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
|
|
41
42
|
interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
|
|
@@ -60,6 +61,12 @@ interface CollectionFieldsInner<WithNamespace extends boolean> extends BaseColle
|
|
|
60
61
|
templates?: undefined;
|
|
61
62
|
}
|
|
62
63
|
export declare type TinaFieldInner<WithNamespace extends boolean> = ScalarType<WithNamespace> | ObjectType<WithNamespace> | ReferenceType<WithNamespace> | RichType<WithNamespace>;
|
|
64
|
+
export declare type TinaIndex = {
|
|
65
|
+
name: string;
|
|
66
|
+
fields: {
|
|
67
|
+
name: string;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
63
70
|
export declare type TinaFieldBase = TinaFieldInner<false>;
|
|
64
71
|
export declare type TinaFieldEnriched = TinaFieldInner<true>;
|
|
65
72
|
interface TinaField {
|
|
@@ -68,6 +75,7 @@ interface TinaField {
|
|
|
68
75
|
description?: string;
|
|
69
76
|
required?: boolean;
|
|
70
77
|
list?: boolean;
|
|
78
|
+
indexed?: boolean;
|
|
71
79
|
/**
|
|
72
80
|
* Any items passed to the UI field will be passed to the underlying field.
|
|
73
81
|
* NOTE: only serializable values are supported, so functions like `validate`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
49
|
+
"@tinacms/datalayer": "0.1.1",
|
|
49
50
|
"body-parser": "^1.19.0",
|
|
50
51
|
"cors": "^2.8.5",
|
|
51
52
|
"dataloader": "^2.0.0",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"graphql-type-json": "^0.3.2",
|
|
62
63
|
"gray-matter": "^4.0.2",
|
|
63
64
|
"js-yaml": "^3.14.0",
|
|
65
|
+
"leveldown": "^6.1.0",
|
|
64
66
|
"lodash": "^4.17.20",
|
|
65
67
|
"mdast": "^3.0.0",
|
|
66
68
|
"mdast-util-from-markdown": "^1.0.0",
|
|
@@ -68,7 +70,6 @@
|
|
|
68
70
|
"mdast-util-mdx-expression": "^1.1.0",
|
|
69
71
|
"mdast-util-to-markdown": "^1.2.1",
|
|
70
72
|
"micromark-extension-mdxjs": "^1.0.0",
|
|
71
|
-
"mocha": "^9.1.1",
|
|
72
73
|
"normalize-path": "^3.0.0",
|
|
73
74
|
"prettier": "^2.2.1",
|
|
74
75
|
"rehype-format": "^3.1.0",
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
"directory": "packages/tina-graphql"
|
|
96
97
|
},
|
|
97
98
|
"devDependencies": {
|
|
98
|
-
"@tinacms/datalayer": "0.
|
|
99
|
+
"@tinacms/datalayer": "0.1.1",
|
|
99
100
|
"@tinacms/scripts": "0.50.7",
|
|
100
101
|
"@types/cors": "^2.8.7",
|
|
101
102
|
"@types/estree": "^0.0.50",
|
|
@@ -103,7 +104,6 @@
|
|
|
103
104
|
"@types/fs-extra": "^9.0.2",
|
|
104
105
|
"@types/jest": "^26.0.4",
|
|
105
106
|
"@types/js-yaml": "^3.12.5",
|
|
106
|
-
"@types/level": "^6.0.0",
|
|
107
107
|
"@types/lodash": "^4.14.161",
|
|
108
108
|
"@types/lodash.camelcase": "^4.3.6",
|
|
109
109
|
"@types/lodash.upperfirst": "^4.3.6",
|
|
@@ -1,72 +0,0 @@
|
|
|
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, keepTemplateKey?: boolean): Promise<void>;
|
|
72
|
-
}
|