@tinacms/graphql 0.63.5 → 0.63.8

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/dist/build.d.ts CHANGED
@@ -13,17 +13,7 @@ limitations under the License.
13
13
  import { DocumentNode } from 'graphql';
14
14
  import type { TinaSchema } from './schema';
15
15
  import { Database } from './database';
16
- /**
17
- *
18
- * This will build the files (_schema.json, _lookup.json, _graphQL.json)
19
- */
20
- export declare const indexDB: (args: {
21
- database: Database;
22
- config: TinaSchema['config'];
23
- flags?: string[];
24
- buildSDK?: boolean;
25
- }) => Promise<void>;
26
- export declare const buildFiles: ({ database, config, flags, buildSDK, }: {
16
+ export declare const buildDotTinaFiles: ({ database, config, flags, buildSDK, }: {
27
17
  database: Database;
28
18
  config: TinaSchema['config'];
29
19
  flags?: string[];
package/dist/index.d.ts CHANGED
@@ -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
- export { indexDB } from './build';
13
+ import { buildDotTinaFiles } from './build';
14
14
  export { resolve } from './resolve';
15
15
  export * from './resolver/error';
16
16
  export { createDatabase } from './database';
@@ -21,8 +21,14 @@ export type { Store } from '@tinacms/datalayer';
21
21
  export type { Bridge } from './database/bridge';
22
22
  export { sequential, assertShape } from './util';
23
23
  export { stringifyFile, parseFile } from './database/util';
24
+ export { createSchema } from './schema';
25
+ export { buildDotTinaFiles };
24
26
  export declare type DummyType = unknown;
25
- export declare const buildSchema: (rootPath: string, database: Database, flags?: string[], skipIndexing?: boolean) => Promise<import("graphql").GraphQLSchema>;
27
+ export declare const buildSchema: (rootPath: string, database: Database, flags?: string[]) => Promise<{
28
+ graphQLSchema: import("graphql").DocumentNode;
29
+ tinaSchema: import("./schema").TinaSchema;
30
+ }>;
31
+ export declare const getASTSchema: (database: Database) => Promise<import("graphql").GraphQLSchema>;
26
32
  import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
27
33
  export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
28
34
  export declare type TinaSchema = TinaCloudSchema;
package/dist/index.js CHANGED
@@ -58,10 +58,12 @@ __export(exports, {
58
58
  TinaParseDocumentError: () => TinaParseDocumentError,
59
59
  TinaQueryError: () => TinaQueryError,
60
60
  assertShape: () => assertShape,
61
+ buildDotTinaFiles: () => buildDotTinaFiles,
61
62
  buildSchema: () => buildSchema,
62
63
  createDatabase: () => createDatabase,
64
+ createSchema: () => createSchema,
65
+ getASTSchema: () => getASTSchema,
63
66
  handleFetchErrorError: () => handleFetchErrorError,
64
- indexDB: () => indexDB,
65
67
  parseFile: () => parseFile,
66
68
  resolve: () => resolve,
67
69
  sequential: () => sequential,
@@ -2437,7 +2439,7 @@ var validateField = async (field) => {
2437
2439
 
2438
2440
  // package.json
2439
2441
  var name = "@tinacms/graphql";
2440
- var version = "0.63.5";
2442
+ var version = "0.63.8";
2441
2443
  var main = "dist/index.js";
2442
2444
  var typings = "dist/index.d.ts";
2443
2445
  var files = [
@@ -2668,9 +2670,9 @@ var TinaSchema = class {
2668
2670
  }
2669
2671
  return globalTemplate;
2670
2672
  };
2671
- this.getCollectionByFullPath = async (filepath) => {
2673
+ this.getCollectionByFullPath = (filepath) => {
2672
2674
  const collection = this.getCollections().find((collection2) => {
2673
- return filepath.replace("\\", "/").startsWith(collection2.path);
2675
+ return filepath.replace("\\", "/").startsWith(collection2.path.replace(/\/?$/, "/"));
2674
2676
  });
2675
2677
  if (!collection) {
2676
2678
  throw new Error(`Unable to find collection for file at ${filepath}`);
@@ -2679,12 +2681,7 @@ var TinaSchema = class {
2679
2681
  };
2680
2682
  this.getCollectionAndTemplateByFullPath = (filepath, templateName) => {
2681
2683
  let template;
2682
- const collection = this.getCollections().find((collection2) => {
2683
- return filepath.replace("\\", "/").startsWith(collection2.path);
2684
- });
2685
- if (!collection) {
2686
- throw new Error(`Unable to find collection for file at ${filepath}`);
2687
- }
2684
+ const collection = this.getCollectionByFullPath(filepath);
2688
2685
  const templates = this.getTemplatesForCollectable(collection);
2689
2686
  if (templates.type === "union") {
2690
2687
  if (templateName) {
@@ -2776,11 +2773,7 @@ var TinaSchema = class {
2776
2773
 
2777
2774
  // src/build.ts
2778
2775
  var import_path = __toModule(require("path"));
2779
- var indexDB = async (args) => {
2780
- const { graphQLSchema, tinaSchema } = await buildFiles(args);
2781
- await args.database.indexContent({ graphQLSchema, tinaSchema });
2782
- };
2783
- var buildFiles = async ({
2776
+ var buildDotTinaFiles = async ({
2784
2777
  database,
2785
2778
  config,
2786
2779
  flags = [],
@@ -3853,7 +3846,7 @@ var Database = class {
3853
3846
  this.config = config;
3854
3847
  this.collectionForPath = async (filepath) => {
3855
3848
  const tinaSchema = await this.getSchema();
3856
- const collection = await tinaSchema.getCollectionByFullPath(filepath);
3849
+ const collection = tinaSchema.getCollectionByFullPath(filepath);
3857
3850
  return collection;
3858
3851
  };
3859
3852
  this.get = async (filepath) => {
@@ -3945,7 +3938,7 @@ var Database = class {
3945
3938
  throw new Error(`Unexpected put for config file ${filepath}`);
3946
3939
  } else {
3947
3940
  const tinaSchema = await this.getSchema();
3948
- const collection = await tinaSchema.getCollectionByFullPath(filepath);
3941
+ const collection = tinaSchema.getCollectionByFullPath(filepath);
3949
3942
  const templateInfo = await tinaSchema.getTemplatesForCollectable(collection);
3950
3943
  let template;
3951
3944
  if (templateInfo.type === "object") {
@@ -4313,15 +4306,18 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
4313
4306
  };
4314
4307
 
4315
4308
  // src/index.ts
4316
- var buildSchema = async (rootPath, database, flags, skipIndexing) => {
4309
+ var buildSchema = async (rootPath, database, flags) => {
4317
4310
  const tempConfig = import_path4.default.join(rootPath, ".tina", "__generated__", "config");
4318
4311
  const config = await import_fs_extra2.default.readFileSync(import_path4.default.join(tempConfig, "schema.json")).toString();
4319
4312
  await import_fs_extra2.default.rm(tempConfig, { recursive: true });
4320
- if (skipIndexing != null ? skipIndexing : false) {
4321
- await buildFiles({ database, config: JSON.parse(config), flags });
4322
- } else {
4323
- await indexDB({ database, config: JSON.parse(config), flags });
4324
- }
4313
+ const { graphQLSchema, tinaSchema } = await buildDotTinaFiles({
4314
+ database,
4315
+ config: JSON.parse(config),
4316
+ flags
4317
+ });
4318
+ return { graphQLSchema, tinaSchema };
4319
+ };
4320
+ var getASTSchema = async (database) => {
4325
4321
  const gqlAst = await database.getGraphQLSchemaFromBridge();
4326
4322
  return (0, import_graphql6.buildASTSchema)(gqlAst);
4327
4323
  };
@@ -4332,10 +4328,12 @@ var buildSchema = async (rootPath, database, flags, skipIndexing) => {
4332
4328
  TinaParseDocumentError,
4333
4329
  TinaQueryError,
4334
4330
  assertShape,
4331
+ buildDotTinaFiles,
4335
4332
  buildSchema,
4336
4333
  createDatabase,
4334
+ createSchema,
4335
+ getASTSchema,
4337
4336
  handleFetchErrorError,
4338
- indexDB,
4339
4337
  parseFile,
4340
4338
  resolve,
4341
4339
  sequential,
@@ -40,6 +40,27 @@ export declare class Resolver {
40
40
  name: string;
41
41
  path: string;
42
42
  format?: "json" | "md" | "markdown" | "mdx";
43
+ ui?: {
44
+ global?: boolean | {
45
+ icon?: any;
46
+ layout: "fullscreen" | "popup";
47
+ };
48
+ router?: (args: {
49
+ document: {
50
+ _sys: {
51
+ title?: string;
52
+ template: string;
53
+ breadcrumbs: string[];
54
+ path: string;
55
+ basename: string;
56
+ relativePath: string;
57
+ filename: string;
58
+ extension: string;
59
+ };
60
+ };
61
+ collection: TinaCloudCollection<true>;
62
+ }) => string;
63
+ };
43
64
  match?: string;
44
65
  documents: {
45
66
  collection: TinaCloudCollection<true>;
@@ -66,6 +87,27 @@ export declare class Resolver {
66
87
  name: string;
67
88
  path: string;
68
89
  format?: "json" | "md" | "markdown" | "mdx";
90
+ ui?: {
91
+ global?: boolean | {
92
+ icon?: any;
93
+ layout: "fullscreen" | "popup";
94
+ };
95
+ router?: (args: {
96
+ document: {
97
+ _sys: {
98
+ title?: string;
99
+ template: string;
100
+ breadcrumbs: string[];
101
+ path: string;
102
+ basename: string;
103
+ relativePath: string;
104
+ filename: string;
105
+ extension: string;
106
+ };
107
+ };
108
+ collection: TinaCloudCollection<true>;
109
+ }) => string;
110
+ };
69
111
  match?: string;
70
112
  documents: {
71
113
  collection: TinaCloudCollection<true>;
@@ -52,7 +52,7 @@ export declare class TinaSchema {
52
52
  fields: import("../types").TinaFieldInner<true>[];
53
53
  namespace: string[];
54
54
  };
55
- getCollectionByFullPath: (filepath: string) => Promise<TinaCloudCollection<true>>;
55
+ getCollectionByFullPath: (filepath: string) => TinaCloudCollection<true>;
56
56
  getCollectionAndTemplateByFullPath: (filepath: string, templateName?: string) => {
57
57
  collection: TinaCloudCollection<true>;
58
58
  template: Templateable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.63.5",
3
+ "version": "0.63.8",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
22
22
  "@tinacms/datalayer": "0.2.3",
23
- "@tinacms/schema-tools": "0.1.0",
24
- "@tinacms/mdx": "0.61.4",
23
+ "@tinacms/schema-tools": "0.1.2",
24
+ "@tinacms/mdx": "0.61.6",
25
25
  "body-parser": "^1.19.0",
26
26
  "cors": "^2.8.5",
27
27
  "dataloader": "^2.0.0",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@tinacms/datalayer": "0.2.3",
75
- "@tinacms/schema-tools": "0.1.0",
75
+ "@tinacms/schema-tools": "0.1.2",
76
76
  "@tinacms/scripts": "0.51.1",
77
77
  "@types/cors": "^2.8.7",
78
78
  "@types/estree": "^0.0.50",