@tinacms/graphql 1.3.2 → 1.3.4

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.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
 
3
3
  */
4
- import type { ReferenceTypeInner, TinaFieldInner } from '@tinacms/schema-tools';
4
+ import type { ReferenceType, TinaField } from '@tinacms/schema-tools';
5
5
  import { FilterCondition } from '../database/datalayer';
6
- export declare type ReferenceResolver = (filter: Record<string, object>, fieldDefinition: ReferenceTypeInner) => Promise<{
6
+ export declare type ReferenceResolver = (filter: Record<string, object>, fieldDefinition: ReferenceType) => Promise<{
7
7
  edges: {
8
8
  node: any;
9
9
  }[];
10
10
  values: any[];
11
11
  }>;
12
- export declare const resolveReferences: (filter: any, fields: TinaFieldInner<false>[], resolver: ReferenceResolver) => Promise<void>;
13
- export declare const collectConditionsForField: (fieldName: string, field: TinaFieldInner<false>, filterNode: Record<string, object>, pathExpression: string, collectCondition: (condition: FilterCondition) => void) => void;
12
+ export declare const resolveReferences: (filter: any, fields: TinaField[], resolver: ReferenceResolver) => Promise<void>;
13
+ export declare const collectConditionsForField: (fieldName: string, field: TinaField, filterNode: Record<string, object>, pathExpression: string, collectCondition: (condition: FilterCondition) => void) => void;
@@ -2,7 +2,7 @@
2
2
 
3
3
  */
4
4
  import { Database } from '../database';
5
- import type { Collectable, ReferenceTypeWithNamespace, TinaCloudCollection, TinaFieldInner, TinaSchema } from '@tinacms/schema-tools';
5
+ import type { Collectable, Collection, TinaField, Template, TinaSchema } from '@tinacms/schema-tools';
6
6
  import type { GraphQLConfig } from '../types';
7
7
  interface ResolverConfig {
8
8
  config?: GraphQLConfig;
@@ -23,47 +23,49 @@ export declare class Resolver {
23
23
  isAudit: boolean;
24
24
  constructor(init: ResolverConfig);
25
25
  resolveCollection: (args: any, collectionName: string, hasDocuments?: boolean) => Promise<{
26
- fields: TinaFieldInner<true>[];
26
+ fields: TinaField<true>[];
27
27
  templates?: undefined;
28
- references?: ReferenceTypeWithNamespace[];
29
- namespace: string[];
30
28
  label?: string;
31
29
  name: string;
32
30
  path: string;
31
+ indexes?: {
32
+ name: string;
33
+ fields: {
34
+ name: string;
35
+ }[];
36
+ }[];
37
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "yml" | "toml";
38
+ ui?: import("@tinacms/schema-tools").UICollection;
33
39
  defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
34
- indexes?: import("@tinacms/schema-tools").TinaIndex[];
35
- format?: "json" | "md" | "markdown" | "mdx";
36
40
  frontmatterFormat?: "json" | "yaml" | "toml";
37
41
  frontmatterDelimiters?: string | [string, string];
38
- ui?: import("@tinacms/schema-tools").UICollection;
39
42
  match?: string;
43
+ namespace: string[];
40
44
  documents: {
41
- collection: TinaCloudCollection<true>;
45
+ collection: Collection<true>;
42
46
  hasDocuments: boolean;
43
47
  };
44
48
  } | {
45
- templates: (string | {
46
- label: string;
47
- name: string;
48
- ui?: import("@tinacms/schema-tools").UICollection;
49
- fields: TinaFieldInner<true>[];
50
- namespace: string[];
51
- })[];
49
+ templates: Template<true>[];
52
50
  fields?: undefined;
53
- references?: ReferenceTypeWithNamespace[];
54
- namespace: string[];
55
51
  label?: string;
56
52
  name: string;
57
53
  path: string;
54
+ indexes?: {
55
+ name: string;
56
+ fields: {
57
+ name: string;
58
+ }[];
59
+ }[];
60
+ format?: "json" | "md" | "markdown" | "mdx" | "yaml" | "yml" | "toml";
61
+ ui?: import("@tinacms/schema-tools").UICollection;
58
62
  defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
59
- indexes?: import("@tinacms/schema-tools").TinaIndex[];
60
- format?: "json" | "md" | "markdown" | "mdx";
61
63
  frontmatterFormat?: "json" | "yaml" | "toml";
62
64
  frontmatterDelimiters?: string | [string, string];
63
- ui?: import("@tinacms/schema-tools").UICollection;
64
65
  match?: string;
66
+ namespace: string[];
65
67
  documents: {
66
- collection: TinaCloudCollection<true>;
68
+ collection: Collection<true>;
67
69
  hasDocuments: boolean;
68
70
  };
69
71
  }>;
@@ -76,7 +78,7 @@ export declare class Resolver {
76
78
  path: string;
77
79
  relativePath: string;
78
80
  breadcrumbs: string[];
79
- collection: TinaCloudCollection<true>;
81
+ collection: Collection<true>;
80
82
  template: string | number;
81
83
  };
82
84
  _values: {
@@ -99,7 +101,7 @@ export declare class Resolver {
99
101
  [key: string]: unknown;
100
102
  }[];
101
103
  createResolveDocument: ({ collection, realPath, args, isAddPendingDocument, }: {
102
- collection: TinaCloudCollection<true>;
104
+ collection: Collection<true>;
103
105
  realPath: string;
104
106
  args: unknown;
105
107
  isAddPendingDocument: boolean;
@@ -112,7 +114,7 @@ export declare class Resolver {
112
114
  path: string;
113
115
  relativePath: string;
114
116
  breadcrumbs: string[];
115
- collection: TinaCloudCollection<true>;
117
+ collection: Collection<true>;
116
118
  template: string | number;
117
119
  };
118
120
  _values: {
@@ -129,7 +131,7 @@ export declare class Resolver {
129
131
  id: string;
130
132
  }>;
131
133
  updateResolveDocument: ({ collection, realPath, args, isAddPendingDocument, isCollectionSpecific, }: {
132
- collection: TinaCloudCollection<true>;
134
+ collection: Collection<true>;
133
135
  realPath: string;
134
136
  args: unknown;
135
137
  isAddPendingDocument: boolean;
@@ -143,7 +145,7 @@ export declare class Resolver {
143
145
  path: string;
144
146
  relativePath: string;
145
147
  breadcrumbs: string[];
146
- collection: TinaCloudCollection<true>;
148
+ collection: Collection<true>;
147
149
  template: string | number;
148
150
  };
149
151
  _values: {
@@ -177,7 +179,7 @@ export declare class Resolver {
177
179
  path: string;
178
180
  relativePath: string;
179
181
  breadcrumbs: string[];
180
- collection: TinaCloudCollection<true>;
182
+ collection: Collection<true>;
181
183
  template: string | number;
182
184
  };
183
185
  _values: {
@@ -207,7 +209,7 @@ export declare class Resolver {
207
209
  path: string;
208
210
  relativePath: string;
209
211
  breadcrumbs: string[];
210
- collection: TinaCloudCollection<true>;
212
+ collection: Collection<true>;
211
213
  template: string | number;
212
214
  };
213
215
  _values: {
@@ -229,7 +231,7 @@ export declare class Resolver {
229
231
  private resolveFilterConditions;
230
232
  resolveCollectionConnection: ({ args, collection, hydrator, }: {
231
233
  args: Record<string, Record<string, object> | string | number>;
232
- collection: TinaCloudCollection<true>;
234
+ collection: Collection<true>;
233
235
  hydrator?: (string: any) => any;
234
236
  }) => Promise<{
235
237
  totalCount: number;
@@ -2,7 +2,7 @@
2
2
 
3
3
  */
4
4
  import type { GraphQLConfig } from '../types';
5
- import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
5
+ import type { Schema } from '@tinacms/schema-tools';
6
6
  /**
7
7
  * Strips away the Tina Cloud Asset URL from an `image` value
8
8
  *
@@ -10,7 +10,7 @@ import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
10
10
  * @param {GraphQLConfig} config
11
11
  * @returns {string}
12
12
  */
13
- export declare const resolveMediaCloudToRelative: (value: string, config: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
13
+ export declare const resolveMediaCloudToRelative: (value: string, config: GraphQLConfig, schema: Schema<true>) => string;
14
14
  /**
15
15
  * Adds Tina Cloud Asset URL to an `image` value
16
16
  *
@@ -18,4 +18,4 @@ export declare const resolveMediaCloudToRelative: (value: string, config: GraphQ
18
18
  * @param {GraphQLConfig} config
19
19
  * @returns {string}
20
20
  */
21
- export declare const resolveMediaRelativeToCloud: (value: string, config: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
21
+ export declare const resolveMediaRelativeToCloud: (value: string, config: GraphQLConfig, schema: Schema<true>) => string;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
 
3
3
  */
4
- import { TinaSchema, TinaCloudSchemaBase } from '@tinacms/schema-tools';
4
+ import { TinaSchema, Schema } from '@tinacms/schema-tools';
5
5
  export declare const createSchema: ({ schema, flags, }: {
6
- schema: TinaCloudSchemaBase;
6
+ schema: Schema;
7
7
  flags?: string[];
8
8
  }) => Promise<TinaSchema>;
@@ -1,5 +1,11 @@
1
1
  /**
2
2
 
3
3
  */
4
- import { TinaCloudSchemaBase } from '@tinacms/schema-tools';
5
- export declare const validateSchema: (schema: TinaCloudSchemaBase) => Promise<TinaCloudSchemaBase>;
4
+ import { Schema, Collection } from '@tinacms/schema-tools';
5
+ export declare const validateSchema: (schema: Schema) => Promise<{
6
+ collections: Collection<true>[];
7
+ config: import("@tinacms/schema-tools").Config<undefined, undefined, undefined, undefined>;
8
+ } | {
9
+ collections: Collection<true>[];
10
+ config?: undefined;
11
+ }>;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
 
3
3
  */
4
- import type { TinaCloudSchema } from '@tinacms/schema-tools';
4
+ import type { Schema } from '@tinacms/schema-tools';
5
5
  import { Database } from '../database';
6
6
  import { Level } from '../database/level';
7
- export declare const setup: (rootPath: string, schema: TinaCloudSchema<false>, level: Level) => Promise<{
7
+ export declare const setup: (rootPath: string, schema: Schema, level: Level) => Promise<{
8
8
  database: Database;
9
9
  }>;
10
10
  export declare const print: (fixture: Fixture) => string;
@@ -22,11 +22,11 @@ export declare type Fixture = {
22
22
  message?: string;
23
23
  expectError?: boolean;
24
24
  };
25
- export declare const setupFixture: (rootPath: string, schema: TinaCloudSchema<false>, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
25
+ export declare const setupFixture: (rootPath: string, schema: Schema, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
26
26
  responses: string[];
27
27
  expectedResponsePaths: string[];
28
28
  }>;
29
- export declare const setupFixture2: (rootPath: string, schema: TinaCloudSchema<false>, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
29
+ export declare const setupFixture2: (rootPath: string, schema: Schema, level: Level, fixture: Fixture, suffix?: string, queryName?: string, folder?: string) => Promise<{
30
30
  responses: string[];
31
31
  expectedResponsePaths: string[];
32
32
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "typings": "dist/index.d.ts",
@@ -25,15 +25,15 @@
25
25
  "dependencies": {
26
26
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
27
27
  "@iarna/toml": "^2.2.5",
28
- "@tinacms/mdx": "1.3.1",
29
- "@tinacms/schema-tools": "1.3.2",
28
+ "@tinacms/mdx": "1.3.3",
29
+ "@tinacms/schema-tools": "1.3.3",
30
30
  "abstract-level": "^1.0.3",
31
31
  "body-parser": "^1.19.0",
32
32
  "cors": "^2.8.5",
33
33
  "dataloader": "^2.0.0",
34
34
  "date-fns": "^2.21.1",
35
35
  "encoding-down": "^7.1.0",
36
- "esbuild": "^0.12.25",
36
+ "esbuild": "^0.15.5",
37
37
  "esbuild-jest": "^0.5.0",
38
38
  "estree-walker": "^3.0.0",
39
39
  "fast-glob": "^3.2.5",
@@ -82,8 +82,8 @@
82
82
  "directory": "packages/tina-graphql"
83
83
  },
84
84
  "devDependencies": {
85
- "@tinacms/schema-tools": "1.3.2",
86
- "@tinacms/scripts": "1.0.2",
85
+ "@tinacms/schema-tools": "1.3.3",
86
+ "@tinacms/scripts": "1.0.4",
87
87
  "@types/cors": "^2.8.7",
88
88
  "@types/estree": "^0.0.50",
89
89
  "@types/express": "^4.17.8",
@@ -1,220 +0,0 @@
1
- /**
2
-
3
-
4
-
5
- */
6
- import type { RichTypeInner } from '@tinacms/schema-tools';
7
- import type { GraphQLConfig } from '../types';
8
- import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
9
- import type { Content } from 'mdast';
10
- export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => {
11
- type: string;
12
- children: any;
13
- };
14
- /**
15
- * ### Convert the MDXAST into an API-friendly format
16
- *
17
- * When we parse with Remark + MDX we get an AST which has a ton of JS capabilities, meaning
18
- * we could pass this back into a JS runtime and evaluate it. Ex.
19
- *
20
- * ```mdx
21
- * ## Hello world! The time and date is: {(new Date().toLocaleString())}
22
- * ```
23
- *
24
- * However, as an intentional constraint we don't want this information as part of our API, as
25
- * we don't intend to support the true JS runtime properties of MDX. Rather, we're using MDX for
26
- * it's expressive syntax and it's advanced tooling with how it parses JSX inside Markdown.
27
- *
28
- * Parsing here does 2 things:
29
- *
30
- * #### Remove non-literal uses of JSX
31
- * Things like <MyComponent myProp={() => alert("HI")} /> are not supported and will be ignored
32
- *
33
- * #### Convert remark nodes to slate-compatible nodes
34
- *
35
- * A remark node might look like this:
36
- * ```js
37
- * {
38
- * type: "heading",
39
- * depth: 1
40
- * children: [{type: 'text', value: 'Hello'}]
41
- * }
42
- * ```
43
- * A slate-compatible node would be:
44
- * ```js
45
- * {
46
- * type: "heading_one",
47
- * children: [{type: 'text', text: 'Hello'}]
48
- * }
49
- * ```
50
- * It's not a huge difference, but in general slate does better with less layers of indirection.
51
- *
52
- * While it may be desirable to ultimately serve a remark AST shape as part of the API response,
53
- * it's currently much easier to only support the shape that works with Slate. This is ok for now for 2
54
- * reasons.
55
- *
56
- * 1. Us providing the `TinaMarkdown` component on the frontend abstracts away an work the developer
57
- * would need to do, so it doesn't really matter what shape the response is as long as the external API
58
- * doesn't change
59
- *
60
- * 2. We don't need to do any client-side parsing. Since TinaMarkdown and the slate editor work with the same
61
- * format we can just allow Tina to do it's thing and update the form valuse with no additional work.
62
- */
63
- export declare const parseMDXInner: (tree: any, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => {
64
- type: string;
65
- children: any;
66
- };
67
- export interface NodeTypes {
68
- paragraph: string;
69
- block_quote: string;
70
- code_block: string;
71
- link: string;
72
- image: string;
73
- ul_list: string;
74
- ol_list: string;
75
- listItem: string;
76
- heading: {
77
- 1: string;
78
- 2: string;
79
- 3: string;
80
- 4: string;
81
- 5: string;
82
- 6: string;
83
- };
84
- emphasis_mark: string;
85
- strong_mark: string;
86
- delete_mark: string;
87
- inline_code_mark: string;
88
- thematic_break: string;
89
- break: string;
90
- }
91
- export declare type SlateNodeType = {
92
- type: 'heading_one';
93
- children: SlateNodeType[];
94
- } | {
95
- type: 'heading_two';
96
- children: SlateNodeType[];
97
- } | {
98
- type: 'heading_three';
99
- children: SlateNodeType[];
100
- } | {
101
- type: 'heading_four';
102
- children: SlateNodeType[];
103
- } | {
104
- type: 'heading_five';
105
- children: SlateNodeType[];
106
- } | {
107
- type: 'heading_six';
108
- children: SlateNodeType[];
109
- } | {
110
- type: 'paragraph';
111
- children: SlateNodeType[];
112
- } | {
113
- children: SlateNodeType[];
114
- link: string;
115
- type: 'link';
116
- } | {
117
- type: 'block_quote';
118
- children: SlateNodeType[];
119
- } | {
120
- type: 'text';
121
- text: string;
122
- } | {
123
- type: 'mdxJsxTextElement';
124
- props: object;
125
- children: SlateNodeType[];
126
- name: string;
127
- } | {
128
- type: 'mdxJsxFlowElement';
129
- props: object;
130
- children: SlateNodeType[];
131
- name: string;
132
- } | {
133
- type: 'block_quote';
134
- children: SlateNodeType[];
135
- } | {
136
- type: 'code_block';
137
- language: string;
138
- value: string;
139
- } | {
140
- type: 'image';
141
- link: string;
142
- caption: string;
143
- } | {
144
- type: 'thematic_break';
145
- };
146
- declare type RecursivePartial<T> = {
147
- [P in keyof T]?: RecursivePartial<T[P]>;
148
- };
149
- export interface OptionType {
150
- nodeTypes?: RecursivePartial<NodeTypes>;
151
- linkDestinationKey?: string;
152
- imageSourceKey?: string;
153
- imageCaptionKey?: string;
154
- }
155
- export interface MdastNode {
156
- type?: string;
157
- ordered?: boolean;
158
- value?: string;
159
- text?: string;
160
- children?: Array<MdastNode>;
161
- depth?: 1 | 2 | 3 | 4 | 5 | 6;
162
- url?: string;
163
- alt?: string;
164
- lang?: string;
165
- position?: any;
166
- spread?: any;
167
- checked?: any;
168
- indent?: any;
169
- }
170
- declare type MdxJsxFlowElement = {
171
- type: 'mdxJsxFlowElement';
172
- name: string;
173
- attributes: object;
174
- children: MdxAstNode[];
175
- };
176
- declare type MdxJsxTextElement = {
177
- type: 'mdxJsxTextElement';
178
- name: string;
179
- attributes: object;
180
- children: MdxAstNode[];
181
- };
182
- declare type MdxAstNode = Content | MdxJsxFlowElement | MdxJsxTextElement;
183
- export declare const plateElements: {
184
- ELEMENT_H1: string;
185
- ELEMENT_H2: string;
186
- ELEMENT_H3: string;
187
- ELEMENT_H4: string;
188
- ELEMENT_H5: string;
189
- ELEMENT_H6: string;
190
- ELEMENT_HR: string;
191
- ELEMENT_ALIGN_CENTER: string;
192
- ELEMENT_ALIGN_JUSTIFY: string;
193
- ELEMENT_ALIGN_LEFT: string;
194
- ELEMENT_ALIGN_RIGHT: string;
195
- ELEMENT_BLOCKQUOTE: string;
196
- ELEMENT_CODE_BLOCK: string;
197
- ELEMENT_CODE_LINE: string;
198
- ELEMENT_DEFAULT: string;
199
- ELEMENT_IMAGE: string;
200
- ELEMENT_LI: string;
201
- ELEMENT_LIC: string;
202
- ELEMENT_LINK: string;
203
- ELEMENT_MEDIA_EMBED: string;
204
- ELEMENT_MENTION: string;
205
- ELEMENT_OL: string;
206
- ELEMENT_PARAGRAPH: string;
207
- ELEMENT_TABLE: string;
208
- ELEMENT_TD: string;
209
- ELEMENT_TH: string;
210
- ELEMENT_TODO_LI: string;
211
- ELEMENT_TR: string;
212
- ELEMENT_UL: string;
213
- MARK_ITALIC: string;
214
- MARK_BOLD: string;
215
- MARK_STRIKETHROUGH: string;
216
- MARK_UNDERLINE: string;
217
- };
218
- export declare const defaultNodeTypes: NodeTypes;
219
- export default function remarkToSlate(node: MdxAstNode, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched): any;
220
- export {};
@@ -1,13 +0,0 @@
1
- /**
2
-
3
-
4
-
5
- */
6
- import type { GraphQLConfig } from '../types';
7
- import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
8
- import { plateElements } from './parse';
9
- import type { Content } from 'mdast';
10
- export declare const stringifyMDX: (value: unknown, field: any, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
11
- export declare const stringify: (node: {
12
- type: typeof plateElements;
13
- }, field: any, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => Content;