@tinacms/graphql 0.63.5 → 0.63.6

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,6 @@ 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';
14
13
  export { resolve } from './resolve';
15
14
  export * from './resolver/error';
16
15
  export { createDatabase } from './database';
@@ -22,7 +21,11 @@ export type { Bridge } from './database/bridge';
22
21
  export { sequential, assertShape } from './util';
23
22
  export { stringifyFile, parseFile } from './database/util';
24
23
  export declare type DummyType = unknown;
25
- export declare const buildSchema: (rootPath: string, database: Database, flags?: string[], skipIndexing?: boolean) => Promise<import("graphql").GraphQLSchema>;
24
+ export declare const buildSchema: (rootPath: string, database: Database, flags?: string[]) => Promise<{
25
+ graphQLSchema: import("graphql").DocumentNode;
26
+ tinaSchema: import("./schema").TinaSchema;
27
+ }>;
28
+ export declare const getASTSchema: (database: Database) => Promise<import("graphql").GraphQLSchema>;
26
29
  import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
27
30
  export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
28
31
  export declare type TinaSchema = TinaCloudSchema;
package/dist/index.js CHANGED
@@ -60,8 +60,8 @@ __export(exports, {
60
60
  assertShape: () => assertShape,
61
61
  buildSchema: () => buildSchema,
62
62
  createDatabase: () => createDatabase,
63
+ getASTSchema: () => getASTSchema,
63
64
  handleFetchErrorError: () => handleFetchErrorError,
64
- indexDB: () => indexDB,
65
65
  parseFile: () => parseFile,
66
66
  resolve: () => resolve,
67
67
  sequential: () => sequential,
@@ -2437,7 +2437,7 @@ var validateField = async (field) => {
2437
2437
 
2438
2438
  // package.json
2439
2439
  var name = "@tinacms/graphql";
2440
- var version = "0.63.5";
2440
+ var version = "0.63.6";
2441
2441
  var main = "dist/index.js";
2442
2442
  var typings = "dist/index.d.ts";
2443
2443
  var files = [
@@ -2668,9 +2668,9 @@ var TinaSchema = class {
2668
2668
  }
2669
2669
  return globalTemplate;
2670
2670
  };
2671
- this.getCollectionByFullPath = async (filepath) => {
2671
+ this.getCollectionByFullPath = (filepath) => {
2672
2672
  const collection = this.getCollections().find((collection2) => {
2673
- return filepath.replace("\\", "/").startsWith(collection2.path);
2673
+ return filepath.replace("\\", "/").startsWith(collection2.path.replace(/\/?$/, "/"));
2674
2674
  });
2675
2675
  if (!collection) {
2676
2676
  throw new Error(`Unable to find collection for file at ${filepath}`);
@@ -2679,12 +2679,7 @@ var TinaSchema = class {
2679
2679
  };
2680
2680
  this.getCollectionAndTemplateByFullPath = (filepath, templateName) => {
2681
2681
  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
- }
2682
+ const collection = this.getCollectionByFullPath(filepath);
2688
2683
  const templates = this.getTemplatesForCollectable(collection);
2689
2684
  if (templates.type === "union") {
2690
2685
  if (templateName) {
@@ -2776,11 +2771,7 @@ var TinaSchema = class {
2776
2771
 
2777
2772
  // src/build.ts
2778
2773
  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 ({
2774
+ var buildDotTinaFiles = async ({
2784
2775
  database,
2785
2776
  config,
2786
2777
  flags = [],
@@ -3853,7 +3844,7 @@ var Database = class {
3853
3844
  this.config = config;
3854
3845
  this.collectionForPath = async (filepath) => {
3855
3846
  const tinaSchema = await this.getSchema();
3856
- const collection = await tinaSchema.getCollectionByFullPath(filepath);
3847
+ const collection = tinaSchema.getCollectionByFullPath(filepath);
3857
3848
  return collection;
3858
3849
  };
3859
3850
  this.get = async (filepath) => {
@@ -3945,7 +3936,7 @@ var Database = class {
3945
3936
  throw new Error(`Unexpected put for config file ${filepath}`);
3946
3937
  } else {
3947
3938
  const tinaSchema = await this.getSchema();
3948
- const collection = await tinaSchema.getCollectionByFullPath(filepath);
3939
+ const collection = tinaSchema.getCollectionByFullPath(filepath);
3949
3940
  const templateInfo = await tinaSchema.getTemplatesForCollectable(collection);
3950
3941
  let template;
3951
3942
  if (templateInfo.type === "object") {
@@ -4313,15 +4304,18 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
4313
4304
  };
4314
4305
 
4315
4306
  // src/index.ts
4316
- var buildSchema = async (rootPath, database, flags, skipIndexing) => {
4307
+ var buildSchema = async (rootPath, database, flags) => {
4317
4308
  const tempConfig = import_path4.default.join(rootPath, ".tina", "__generated__", "config");
4318
4309
  const config = await import_fs_extra2.default.readFileSync(import_path4.default.join(tempConfig, "schema.json")).toString();
4319
4310
  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
- }
4311
+ const { graphQLSchema, tinaSchema } = await buildDotTinaFiles({
4312
+ database,
4313
+ config: JSON.parse(config),
4314
+ flags
4315
+ });
4316
+ return { graphQLSchema, tinaSchema };
4317
+ };
4318
+ var getASTSchema = async (database) => {
4325
4319
  const gqlAst = await database.getGraphQLSchemaFromBridge();
4326
4320
  return (0, import_graphql6.buildASTSchema)(gqlAst);
4327
4321
  };
@@ -4334,8 +4328,8 @@ var buildSchema = async (rootPath, database, flags, skipIndexing) => {
4334
4328
  assertShape,
4335
4329
  buildSchema,
4336
4330
  createDatabase,
4331
+ getASTSchema,
4337
4332
  handleFetchErrorError,
4338
- indexDB,
4339
4333
  parseFile,
4340
4334
  resolve,
4341
4335
  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.6",
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.1",
24
+ "@tinacms/mdx": "0.61.5",
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.1",
76
76
  "@tinacms/scripts": "0.51.1",
77
77
  "@types/cors": "^2.8.7",
78
78
  "@types/estree": "^0.0.50",