@tinacms/graphql 1.4.10 → 1.4.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/dist/build.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  /**
2
2
 
3
3
  */
4
- import { DocumentNode } from 'graphql';
5
4
  import { TinaSchema, Config } from '@tinacms/schema-tools';
6
- import { Database } from './database';
7
- export declare const buildDotTinaFiles: ({ database, config, flags, buildSDK, }: {
8
- database: Database;
5
+ import { LookupMapType } from './database';
6
+ export declare const buildDotTinaFiles: ({ config, flags, buildSDK, }: {
9
7
  config: Config;
10
8
  flags?: string[];
11
9
  buildSDK?: boolean;
12
10
  }) => Promise<{
13
- graphQLSchema: DocumentNode;
11
+ graphQLSchema: {
12
+ kind: "Document";
13
+ definitions: import("graphql").TypeDefinitionNode[];
14
+ };
14
15
  tinaSchema: TinaSchema;
16
+ lookup: Record<string, LookupMapType>;
15
17
  fragDoc: string;
16
18
  queryDoc: string;
17
19
  }>;
@@ -1,12 +1,11 @@
1
1
  /**
2
2
 
3
3
  */
4
- import { Database } from '../database';
4
+ import { LookupMapType } from '../database';
5
5
  import type { ObjectTypeDefinitionNode, InlineFragmentNode, FieldDefinitionNode } from 'graphql';
6
6
  import type { Collection, Template } from '@tinacms/schema-tools';
7
7
  import { TinaSchema } from '@tinacms/schema-tools';
8
- export declare const createBuilder: ({ database, tinaSchema, }: {
9
- database: Database;
8
+ export declare const createBuilder: ({ tinaSchema, }: {
10
9
  tinaSchema: TinaSchema;
11
10
  }) => Promise<Builder>;
12
11
  /**
@@ -16,16 +15,15 @@ export declare const createBuilder: ({ database, tinaSchema, }: {
16
15
  */
17
16
  export declare class Builder {
18
17
  config: {
19
- database: Database;
20
18
  tinaSchema: TinaSchema;
21
19
  };
22
20
  private maxDepth;
23
21
  tinaSchema: TinaSchema;
24
- database: Database;
22
+ lookupMap: Record<string, LookupMapType>;
25
23
  constructor(config: {
26
- database: Database;
27
24
  tinaSchema: TinaSchema;
28
25
  });
26
+ private addToLookupMap;
29
27
  /**
30
28
  * ```graphql
31
29
  * # ex.
@@ -9,10 +9,8 @@ export declare class FilesystemBridge implements Bridge {
9
9
  outputPath?: string;
10
10
  constructor(rootPath: string, outputPath?: string);
11
11
  glob(pattern: string, extension: string): Promise<string[]>;
12
- supportsBuilding(): boolean;
13
12
  delete(filepath: string): Promise<void>;
14
13
  get(filepath: string): Promise<string>;
15
- putConfig(filepath: string, data: string): Promise<void>;
16
14
  put(filepath: string, data: string, basePathOverride?: string): Promise<void>;
17
15
  }
18
16
  /**
@@ -4,15 +4,9 @@ export interface Bridge {
4
4
  delete(filepath: string): Promise<void>;
5
5
  get(filepath: string): Promise<string>;
6
6
  put(filepath: string, data: string): Promise<void>;
7
- /**
8
- * Whether this bridge supports the ability to build the schema.
9
- */
10
- supportsBuilding(): boolean;
11
- putConfig(filepath: string, data: string): Promise<void>;
12
7
  /**
13
8
  * Optionally, the bridge can perform
14
9
  * operations in a separate path.
15
10
  */
16
11
  outputPath?: string;
17
- addOutputPath?(outputPath: string): void;
18
12
  }
@@ -86,11 +86,9 @@ export declare class IsomorphicBridge implements Bridge {
86
86
  private commitTree;
87
87
  private getRef;
88
88
  glob(pattern: string, extension: string): Promise<string[]>;
89
- supportsBuilding(): boolean;
90
89
  delete(filepath: string): Promise<void>;
91
90
  private qualifyPath;
92
91
  private unqualifyPath;
93
92
  get(filepath: string): Promise<string>;
94
- putConfig(filepath: string, data: string): Promise<void>;
95
93
  put(filepath: string, data: string): Promise<void>;
96
94
  }
@@ -109,10 +109,6 @@ export declare class Database {
109
109
  endCursor: string;
110
110
  };
111
111
  }>;
112
- putConfigFiles: ({ graphQLSchema, tinaSchema, }: {
113
- graphQLSchema: DocumentNode;
114
- tinaSchema: TinaSchema;
115
- }) => Promise<void>;
116
112
  private indexStatusCallbackWrapper;
117
113
  indexContent: ({ graphQLSchema, tinaSchema, lookup: lookupFromLockFile, }: {
118
114
  graphQLSchema: DocumentNode;
@@ -127,7 +123,6 @@ export declare class Database {
127
123
  _indexAllContent: (level: Level, schema?: Schema) => Promise<{
128
124
  warnings: string[];
129
125
  }>;
130
- addToLookupMap: (lookup: LookupMapType) => Promise<void>;
131
126
  }
132
127
  export declare type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | CollectionFolderLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
133
128
  declare type NodeDocument = {
package/dist/index.d.ts CHANGED
@@ -5,20 +5,22 @@ export * from './resolver/error';
5
5
  export { createDatabase } from './database';
6
6
  export { TinaLevelClient } from './level/tinaLevel';
7
7
  export type { QueryOptions, Database, OnDeleteCallback, OnPutCallback, CreateDatabase, } from './database';
8
- import type { Database } from './database';
9
8
  import type { Config } from '@tinacms/schema-tools';
10
9
  export { sequential, assertShape } from './util';
11
10
  export { stringifyFile, parseFile } from './database/util';
12
11
  export { createSchema } from './schema/createSchema';
13
12
  export { buildDotTinaFiles };
14
13
  export declare type DummyType = unknown;
15
- export declare const buildSchema: (database: Database, config: Config, flags?: string[]) => Promise<{
16
- graphQLSchema: import("graphql").DocumentNode;
14
+ export declare const buildSchema: (config: Config, flags?: string[]) => Promise<{
15
+ graphQLSchema: {
16
+ kind: "Document";
17
+ definitions: import("graphql").TypeDefinitionNode[];
18
+ };
17
19
  tinaSchema: import("@tinacms/schema-tools").TinaSchema;
20
+ lookup: Record<string, import("./database").LookupMapType>;
18
21
  fragDoc: string;
19
22
  queryDoc: string;
20
23
  }>;
21
- export declare const getASTSchema: (database: Database) => Promise<import("graphql").GraphQLSchema>;
22
24
  export declare type TinaSchema = Schema;
23
25
  export type { TinaTemplate, Schema, Collection };
24
26
  export { FilesystemBridge, AuditFileSystemBridge, } from './database/bridge/filesystem';
package/dist/index.es.js CHANGED
@@ -1,6 +1,3 @@
1
- // src/index.ts
2
- import { buildASTSchema as buildASTSchema2 } from "graphql";
3
-
4
1
  // src/build.ts
5
2
  import _3 from "lodash";
6
3
  import { print } from "graphql";
@@ -1273,14 +1270,16 @@ var staticDefinitions = [...scalarDefinitions, interfaceDefinitions];
1273
1270
 
1274
1271
  // src/builder/index.ts
1275
1272
  var createBuilder = async ({
1276
- database,
1277
1273
  tinaSchema
1278
1274
  }) => {
1279
- return new Builder({ database, tinaSchema });
1275
+ return new Builder({ tinaSchema });
1280
1276
  };
1281
1277
  var Builder = class {
1282
1278
  constructor(config) {
1283
1279
  this.config = config;
1280
+ this.addToLookupMap = (lookup) => {
1281
+ this.lookupMap[lookup.type] = lookup;
1282
+ };
1284
1283
  this.buildCollectionDefinition = async (collections) => {
1285
1284
  const name = "collection";
1286
1285
  const typeName = "Collection";
@@ -1369,7 +1368,7 @@ var Builder = class {
1369
1368
  type: astBuilder.TYPES.String
1370
1369
  })
1371
1370
  ];
1372
- await this.database.addToLookupMap({
1371
+ await this.addToLookupMap({
1373
1372
  type: astBuilder.TYPES.Node,
1374
1373
  resolveType: "nodeDocument"
1375
1374
  });
@@ -1512,7 +1511,7 @@ var Builder = class {
1512
1511
  type: astBuilder.TYPES.String
1513
1512
  })
1514
1513
  ];
1515
- await this.database.addToLookupMap({
1514
+ await this.addToLookupMap({
1516
1515
  type: type.name.value,
1517
1516
  resolveType: "collectionDocument",
1518
1517
  collection: collection.name,
@@ -1691,7 +1690,7 @@ var Builder = class {
1691
1690
  };
1692
1691
  this.collectionDocumentList = async (collection) => {
1693
1692
  const connectionName = NAMER.referenceConnectionType(collection.namespace);
1694
- await this.database.addToLookupMap({
1693
+ this.addToLookupMap({
1695
1694
  type: connectionName,
1696
1695
  resolveType: "collectionDocumentList",
1697
1696
  collection: collection.name
@@ -1848,7 +1847,7 @@ var Builder = class {
1848
1847
  name: fieldName,
1849
1848
  types
1850
1849
  });
1851
- await this.database.addToLookupMap({
1850
+ this.addToLookupMap({
1852
1851
  type: type.name.value,
1853
1852
  resolveType: "multiCollectionDocument",
1854
1853
  createDocument: "create",
@@ -1865,7 +1864,7 @@ var Builder = class {
1865
1864
  includeFolderFilter
1866
1865
  }) => {
1867
1866
  const connectionName = NAMER.referenceConnectionType(namespace);
1868
- await this.database.addToLookupMap({
1867
+ this.addToLookupMap({
1869
1868
  type: connectionName,
1870
1869
  resolveType: "multiCollectionDocumentList",
1871
1870
  collections: collections.map((collection) => collection.name)
@@ -2135,7 +2134,7 @@ var Builder = class {
2135
2134
  return type;
2136
2135
  }
2137
2136
  );
2138
- await this.database.addToLookupMap({
2137
+ this.addToLookupMap({
2139
2138
  type: name,
2140
2139
  resolveType: "unionData",
2141
2140
  collection: collection?.name,
@@ -2326,7 +2325,7 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
2326
2325
  };
2327
2326
  this.maxDepth = config?.tinaSchema.schema?.config?.client?.referenceDepth ?? 2;
2328
2327
  this.tinaSchema = config.tinaSchema;
2329
- this.database = config.database;
2328
+ this.lookupMap = {};
2330
2329
  }
2331
2330
  async buildTemplateFragments(template, depth) {
2332
2331
  const selections = [];
@@ -2526,7 +2525,7 @@ var validateField = async (field) => {
2526
2525
  // package.json
2527
2526
  var package_default = {
2528
2527
  name: "@tinacms/graphql",
2529
- version: "1.4.10",
2528
+ version: "1.4.11",
2530
2529
  main: "dist/index.js",
2531
2530
  module: "dist/index.es.js",
2532
2531
  typings: "dist/index.d.ts",
@@ -2671,7 +2670,6 @@ var createSchema = async ({
2671
2670
 
2672
2671
  // src/build.ts
2673
2672
  var buildDotTinaFiles = async ({
2674
- database,
2675
2673
  config,
2676
2674
  flags = [],
2677
2675
  buildSDK = true
@@ -2685,35 +2683,24 @@ var buildDotTinaFiles = async ({
2685
2683
  flags
2686
2684
  });
2687
2685
  const builder = await createBuilder({
2688
- database,
2689
2686
  tinaSchema
2690
2687
  });
2691
- let graphQLSchema;
2692
- if (database.bridge.supportsBuilding()) {
2693
- graphQLSchema = await _buildSchema(builder, tinaSchema);
2694
- await database.putConfigFiles({ graphQLSchema, tinaSchema });
2695
- } else {
2696
- graphQLSchema = JSON.parse(
2697
- await database.bridge.get(".tina/__generated__/_graphql.json")
2698
- );
2699
- }
2688
+ const graphQLSchema = await _buildSchema(builder, tinaSchema);
2700
2689
  let fragDoc = "";
2701
2690
  let queryDoc = "";
2702
2691
  if (buildSDK) {
2703
- fragDoc = await _buildFragments(
2704
- builder,
2705
- tinaSchema,
2706
- database.bridge.rootPath
2707
- );
2708
- queryDoc = await _buildQueries(
2709
- builder,
2710
- tinaSchema,
2711
- database.bridge.rootPath
2712
- );
2692
+ fragDoc = await _buildFragments(builder, tinaSchema);
2693
+ queryDoc = await _buildQueries(builder, tinaSchema);
2713
2694
  }
2714
- return { graphQLSchema, tinaSchema, fragDoc, queryDoc };
2695
+ return {
2696
+ graphQLSchema,
2697
+ tinaSchema,
2698
+ lookup: builder.lookupMap,
2699
+ fragDoc,
2700
+ queryDoc
2701
+ };
2715
2702
  };
2716
- var _buildFragments = async (builder, tinaSchema, rootPath) => {
2703
+ var _buildFragments = async (builder, tinaSchema) => {
2717
2704
  const fragmentDefinitionsFields = [];
2718
2705
  const collections = tinaSchema.getCollections();
2719
2706
  await sequential(collections, async (collection) => {
@@ -2731,7 +2718,7 @@ var _buildFragments = async (builder, tinaSchema, rootPath) => {
2731
2718
  };
2732
2719
  return print(fragDoc);
2733
2720
  };
2734
- var _buildQueries = async (builder, tinaSchema, rootPath) => {
2721
+ var _buildQueries = async (builder, tinaSchema) => {
2735
2722
  const operationsDefinitions = [];
2736
2723
  const collections = tinaSchema.getCollections();
2737
2724
  await sequential(collections, async (collection) => {
@@ -2764,7 +2751,7 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
2764
2751
  };
2765
2752
  var _buildSchema = async (builder, tinaSchema) => {
2766
2753
  const definitions = [];
2767
- definitions.push(await builder.buildStaticDefinitions());
2754
+ definitions.push(builder.buildStaticDefinitions());
2768
2755
  const queryTypeDefinitionFields = [];
2769
2756
  const mutationTypeDefinitionFields = [];
2770
2757
  const collections = tinaSchema.getCollections();
@@ -2827,14 +2814,13 @@ var _buildSchema = async (builder, tinaSchema) => {
2827
2814
  fields: mutationTypeDefinitionFields
2828
2815
  })
2829
2816
  );
2830
- const doc = {
2817
+ return {
2831
2818
  kind: "Document",
2832
2819
  definitions: _3.uniqBy(
2833
2820
  extractInlineTypes(definitions),
2834
2821
  (node) => node.name.value
2835
2822
  )
2836
2823
  };
2837
- return doc;
2838
2824
  };
2839
2825
 
2840
2826
  // src/resolve.ts
@@ -3086,10 +3072,11 @@ var cleanUpSlashes = (path5) => {
3086
3072
  return "";
3087
3073
  };
3088
3074
  var hasTinaMediaConfig = (schema) => {
3089
- if (schema.config?.media?.tina?.publicFolder && schema.config?.media?.tina?.mediaRoot) {
3090
- return true;
3091
- }
3092
- return false;
3075
+ if (!schema.config?.media?.tina)
3076
+ return false;
3077
+ if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
3078
+ return false;
3079
+ return true;
3093
3080
  };
3094
3081
 
3095
3082
  // src/resolver/index.ts
@@ -5329,21 +5316,6 @@ var Database = class {
5329
5316
  }
5330
5317
  };
5331
5318
  };
5332
- this.putConfigFiles = async ({
5333
- graphQLSchema,
5334
- tinaSchema
5335
- }) => {
5336
- if (this.bridge && this.bridge.supportsBuilding()) {
5337
- await this.bridge.putConfig(
5338
- normalizePath(path3.join(this.getGeneratedFolder(), `_graphql.json`)),
5339
- JSON.stringify(graphQLSchema)
5340
- );
5341
- await this.bridge.putConfig(
5342
- normalizePath(path3.join(this.getGeneratedFolder(), `_schema.json`)),
5343
- JSON.stringify(tinaSchema.schema)
5344
- );
5345
- }
5346
- };
5347
5319
  this.indexContent = async ({
5348
5320
  graphQLSchema,
5349
5321
  tinaSchema,
@@ -5553,26 +5525,6 @@ This will be an error in the future. See https://tina.io/docs/errors/file-in-mut
5553
5525
  }
5554
5526
  return { warnings };
5555
5527
  };
5556
- this.addToLookupMap = async (lookup) => {
5557
- if (!this.bridge) {
5558
- throw new Error("No bridge configured");
5559
- }
5560
- const lookupPath = path3.join(this.getGeneratedFolder(), `_lookup.json`);
5561
- let lookupMap;
5562
- try {
5563
- lookupMap = JSON.parse(await this.bridge.get(normalizePath(lookupPath)));
5564
- } catch (e) {
5565
- lookupMap = {};
5566
- }
5567
- const updatedLookup = {
5568
- ...lookupMap,
5569
- [lookup.type]: lookup
5570
- };
5571
- await this.bridge.putConfig(
5572
- normalizePath(lookupPath),
5573
- JSON.stringify(updatedLookup)
5574
- );
5575
- };
5576
5528
  this.tinaDirectory = config.tinaDirectory || ".tina";
5577
5529
  this.bridge = config.bridge;
5578
5530
  this.rootLevel = config.level && new LevelProxy(config.level);
@@ -5897,23 +5849,12 @@ var FilesystemBridge = class {
5897
5849
  return item.replace(posixRootPath, "").replace(/^\/|\/$/g, "");
5898
5850
  });
5899
5851
  }
5900
- supportsBuilding() {
5901
- return true;
5902
- }
5903
5852
  async delete(filepath) {
5904
5853
  await fs.remove(path4.join(this.outputPath, filepath));
5905
5854
  }
5906
5855
  async get(filepath) {
5907
5856
  return fs.readFileSync(path4.join(this.outputPath, filepath)).toString();
5908
5857
  }
5909
- async putConfig(filepath, data) {
5910
- if (this.rootPath !== this.outputPath) {
5911
- await this.put(filepath, data);
5912
- await this.put(filepath, data, this.rootPath);
5913
- } else {
5914
- await this.put(filepath, data);
5915
- }
5916
- }
5917
5858
  async put(filepath, data, basePathOverride) {
5918
5859
  const basePath = basePathOverride || this.outputPath;
5919
5860
  await fs.outputFileSync(path4.join(basePath, filepath), data);
@@ -5924,7 +5865,10 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
5924
5865
  if ([
5925
5866
  ".tina/__generated__/_lookup.json",
5926
5867
  ".tina/__generated__/_schema.json",
5927
- ".tina/__generated__/_graphql.json"
5868
+ ".tina/__generated__/_graphql.json",
5869
+ "tina/__generated__/_lookup.json",
5870
+ "tina/__generated__/_schema.json",
5871
+ "tina/__generated__/_graphql.json"
5928
5872
  ].includes(filepath)) {
5929
5873
  return super.put(filepath, data);
5930
5874
  }
@@ -6192,9 +6136,6 @@ var IsomorphicBridge = class {
6192
6136
  });
6193
6137
  return results.map((path5) => this.unqualifyPath(path5)).filter((path5) => path5.endsWith(extension));
6194
6138
  }
6195
- supportsBuilding() {
6196
- return true;
6197
- }
6198
6139
  async delete(filepath) {
6199
6140
  const ref = await this.getRef();
6200
6141
  const { pathParts, pathEntries } = await this.resolvePathEntries(
@@ -6280,9 +6221,6 @@ var IsomorphicBridge = class {
6280
6221
  });
6281
6222
  return Buffer.from(blob).toString("utf8");
6282
6223
  }
6283
- async putConfig(filepath, data) {
6284
- await this.put(filepath, data);
6285
- }
6286
6224
  async put(filepath, data) {
6287
6225
  const ref = await this.getRef();
6288
6226
  const { pathParts, pathEntries } = await this.resolvePathEntries(
@@ -6326,17 +6264,12 @@ var IsomorphicBridge = class {
6326
6264
  };
6327
6265
 
6328
6266
  // src/index.ts
6329
- var buildSchema = async (database, config, flags) => {
6267
+ var buildSchema = async (config, flags) => {
6330
6268
  return buildDotTinaFiles({
6331
- database,
6332
6269
  config,
6333
6270
  flags
6334
6271
  });
6335
6272
  };
6336
- var getASTSchema = async (database) => {
6337
- const gqlAst = await database.getGraphQLSchemaFromBridge();
6338
- return buildASTSchema2(gqlAst);
6339
- };
6340
6273
  export {
6341
6274
  AuditFileSystemBridge,
6342
6275
  FilesystemBridge,
@@ -6351,7 +6284,6 @@ export {
6351
6284
  buildSchema,
6352
6285
  createDatabase,
6353
6286
  createSchema,
6354
- getASTSchema,
6355
6287
  handleFetchErrorError,
6356
6288
  parseFile,
6357
6289
  resolve,
package/dist/index.js CHANGED
@@ -38,7 +38,6 @@ __export(src_exports, {
38
38
  buildSchema: () => buildSchema,
39
39
  createDatabase: () => createDatabase,
40
40
  createSchema: () => createSchema,
41
- getASTSchema: () => getASTSchema,
42
41
  handleFetchErrorError: () => handleFetchErrorError,
43
42
  parseFile: () => parseFile,
44
43
  resolve: () => resolve,
@@ -46,7 +45,6 @@ __export(src_exports, {
46
45
  stringifyFile: () => stringifyFile
47
46
  });
48
47
  module.exports = __toCommonJS(src_exports);
49
- var import_graphql7 = require("graphql");
50
48
 
51
49
  // src/build.ts
52
50
  var import_lodash3 = __toESM(require("lodash"));
@@ -1320,14 +1318,16 @@ var staticDefinitions = [...scalarDefinitions, interfaceDefinitions];
1320
1318
 
1321
1319
  // src/builder/index.ts
1322
1320
  var createBuilder = async ({
1323
- database,
1324
1321
  tinaSchema
1325
1322
  }) => {
1326
- return new Builder({ database, tinaSchema });
1323
+ return new Builder({ tinaSchema });
1327
1324
  };
1328
1325
  var Builder = class {
1329
1326
  constructor(config) {
1330
1327
  this.config = config;
1328
+ this.addToLookupMap = (lookup) => {
1329
+ this.lookupMap[lookup.type] = lookup;
1330
+ };
1331
1331
  this.buildCollectionDefinition = async (collections) => {
1332
1332
  const name = "collection";
1333
1333
  const typeName = "Collection";
@@ -1416,7 +1416,7 @@ var Builder = class {
1416
1416
  type: astBuilder.TYPES.String
1417
1417
  })
1418
1418
  ];
1419
- await this.database.addToLookupMap({
1419
+ await this.addToLookupMap({
1420
1420
  type: astBuilder.TYPES.Node,
1421
1421
  resolveType: "nodeDocument"
1422
1422
  });
@@ -1559,7 +1559,7 @@ var Builder = class {
1559
1559
  type: astBuilder.TYPES.String
1560
1560
  })
1561
1561
  ];
1562
- await this.database.addToLookupMap({
1562
+ await this.addToLookupMap({
1563
1563
  type: type.name.value,
1564
1564
  resolveType: "collectionDocument",
1565
1565
  collection: collection.name,
@@ -1740,7 +1740,7 @@ var Builder = class {
1740
1740
  };
1741
1741
  this.collectionDocumentList = async (collection) => {
1742
1742
  const connectionName = NAMER.referenceConnectionType(collection.namespace);
1743
- await this.database.addToLookupMap({
1743
+ this.addToLookupMap({
1744
1744
  type: connectionName,
1745
1745
  resolveType: "collectionDocumentList",
1746
1746
  collection: collection.name
@@ -1897,7 +1897,7 @@ var Builder = class {
1897
1897
  name: fieldName,
1898
1898
  types
1899
1899
  });
1900
- await this.database.addToLookupMap({
1900
+ this.addToLookupMap({
1901
1901
  type: type.name.value,
1902
1902
  resolveType: "multiCollectionDocument",
1903
1903
  createDocument: "create",
@@ -1914,7 +1914,7 @@ var Builder = class {
1914
1914
  includeFolderFilter
1915
1915
  }) => {
1916
1916
  const connectionName = NAMER.referenceConnectionType(namespace);
1917
- await this.database.addToLookupMap({
1917
+ this.addToLookupMap({
1918
1918
  type: connectionName,
1919
1919
  resolveType: "multiCollectionDocumentList",
1920
1920
  collections: collections.map((collection) => collection.name)
@@ -2184,7 +2184,7 @@ var Builder = class {
2184
2184
  return type;
2185
2185
  }
2186
2186
  );
2187
- await this.database.addToLookupMap({
2187
+ this.addToLookupMap({
2188
2188
  type: name,
2189
2189
  resolveType: "unionData",
2190
2190
  collection: collection == null ? void 0 : collection.name,
@@ -2376,7 +2376,7 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
2376
2376
  var _a, _b, _c, _d;
2377
2377
  this.maxDepth = (_d = (_c = (_b = (_a = config == null ? void 0 : config.tinaSchema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.client) == null ? void 0 : _c.referenceDepth) != null ? _d : 2;
2378
2378
  this.tinaSchema = config.tinaSchema;
2379
- this.database = config.database;
2379
+ this.lookupMap = {};
2380
2380
  }
2381
2381
  async buildTemplateFragments(template, depth) {
2382
2382
  const selections = [];
@@ -2577,7 +2577,7 @@ var validateField = async (field) => {
2577
2577
  // package.json
2578
2578
  var package_default = {
2579
2579
  name: "@tinacms/graphql",
2580
- version: "1.4.10",
2580
+ version: "1.4.11",
2581
2581
  main: "dist/index.js",
2582
2582
  module: "dist/index.es.js",
2583
2583
  typings: "dist/index.d.ts",
@@ -2722,7 +2722,6 @@ var createSchema = async ({
2722
2722
 
2723
2723
  // src/build.ts
2724
2724
  var buildDotTinaFiles = async ({
2725
- database,
2726
2725
  config,
2727
2726
  flags = [],
2728
2727
  buildSDK = true
@@ -2736,35 +2735,24 @@ var buildDotTinaFiles = async ({
2736
2735
  flags
2737
2736
  });
2738
2737
  const builder = await createBuilder({
2739
- database,
2740
2738
  tinaSchema
2741
2739
  });
2742
- let graphQLSchema;
2743
- if (database.bridge.supportsBuilding()) {
2744
- graphQLSchema = await _buildSchema(builder, tinaSchema);
2745
- await database.putConfigFiles({ graphQLSchema, tinaSchema });
2746
- } else {
2747
- graphQLSchema = JSON.parse(
2748
- await database.bridge.get(".tina/__generated__/_graphql.json")
2749
- );
2750
- }
2740
+ const graphQLSchema = await _buildSchema(builder, tinaSchema);
2751
2741
  let fragDoc = "";
2752
2742
  let queryDoc = "";
2753
2743
  if (buildSDK) {
2754
- fragDoc = await _buildFragments(
2755
- builder,
2756
- tinaSchema,
2757
- database.bridge.rootPath
2758
- );
2759
- queryDoc = await _buildQueries(
2760
- builder,
2761
- tinaSchema,
2762
- database.bridge.rootPath
2763
- );
2744
+ fragDoc = await _buildFragments(builder, tinaSchema);
2745
+ queryDoc = await _buildQueries(builder, tinaSchema);
2764
2746
  }
2765
- return { graphQLSchema, tinaSchema, fragDoc, queryDoc };
2747
+ return {
2748
+ graphQLSchema,
2749
+ tinaSchema,
2750
+ lookup: builder.lookupMap,
2751
+ fragDoc,
2752
+ queryDoc
2753
+ };
2766
2754
  };
2767
- var _buildFragments = async (builder, tinaSchema, rootPath) => {
2755
+ var _buildFragments = async (builder, tinaSchema) => {
2768
2756
  const fragmentDefinitionsFields = [];
2769
2757
  const collections = tinaSchema.getCollections();
2770
2758
  await sequential(collections, async (collection) => {
@@ -2782,7 +2770,7 @@ var _buildFragments = async (builder, tinaSchema, rootPath) => {
2782
2770
  };
2783
2771
  return (0, import_graphql2.print)(fragDoc);
2784
2772
  };
2785
- var _buildQueries = async (builder, tinaSchema, rootPath) => {
2773
+ var _buildQueries = async (builder, tinaSchema) => {
2786
2774
  const operationsDefinitions = [];
2787
2775
  const collections = tinaSchema.getCollections();
2788
2776
  await sequential(collections, async (collection) => {
@@ -2816,7 +2804,7 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
2816
2804
  };
2817
2805
  var _buildSchema = async (builder, tinaSchema) => {
2818
2806
  const definitions = [];
2819
- definitions.push(await builder.buildStaticDefinitions());
2807
+ definitions.push(builder.buildStaticDefinitions());
2820
2808
  const queryTypeDefinitionFields = [];
2821
2809
  const mutationTypeDefinitionFields = [];
2822
2810
  const collections = tinaSchema.getCollections();
@@ -2879,14 +2867,13 @@ var _buildSchema = async (builder, tinaSchema) => {
2879
2867
  fields: mutationTypeDefinitionFields
2880
2868
  })
2881
2869
  );
2882
- const doc = {
2870
+ return {
2883
2871
  kind: "Document",
2884
2872
  definitions: import_lodash3.default.uniqBy(
2885
2873
  extractInlineTypes(definitions),
2886
2874
  (node) => node.name.value
2887
2875
  )
2888
2876
  };
2889
- return doc;
2890
2877
  };
2891
2878
 
2892
2879
  // src/resolve.ts
@@ -3131,11 +3118,12 @@ var cleanUpSlashes = (path5) => {
3131
3118
  return "";
3132
3119
  };
3133
3120
  var hasTinaMediaConfig = (schema) => {
3134
- var _a, _b, _c, _d, _e, _f;
3135
- if (((_c = (_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina) == null ? void 0 : _c.publicFolder) && ((_f = (_e = (_d = schema.config) == null ? void 0 : _d.media) == null ? void 0 : _e.tina) == null ? void 0 : _f.mediaRoot)) {
3136
- return true;
3137
- }
3138
- return false;
3121
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3122
+ if (!((_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina))
3123
+ return false;
3124
+ if (typeof ((_e = (_d = (_c = schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.tina) == null ? void 0 : _e.publicFolder) !== "string" && typeof ((_h = (_g = (_f = schema.config) == null ? void 0 : _f.media) == null ? void 0 : _g.tina) == null ? void 0 : _h.mediaRoot) !== "string")
3125
+ return false;
3126
+ return true;
3139
3127
  };
3140
3128
 
3141
3129
  // src/resolver/index.ts
@@ -5389,21 +5377,6 @@ var Database = class {
5389
5377
  }
5390
5378
  };
5391
5379
  };
5392
- this.putConfigFiles = async ({
5393
- graphQLSchema,
5394
- tinaSchema
5395
- }) => {
5396
- if (this.bridge && this.bridge.supportsBuilding()) {
5397
- await this.bridge.putConfig(
5398
- (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), `_graphql.json`)),
5399
- JSON.stringify(graphQLSchema)
5400
- );
5401
- await this.bridge.putConfig(
5402
- (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), `_schema.json`)),
5403
- JSON.stringify(tinaSchema.schema)
5404
- );
5405
- }
5406
- };
5407
5380
  this.indexContent = async ({
5408
5381
  graphQLSchema,
5409
5382
  tinaSchema,
@@ -5613,26 +5586,6 @@ This will be an error in the future. See https://tina.io/docs/errors/file-in-mut
5613
5586
  }
5614
5587
  return { warnings };
5615
5588
  };
5616
- this.addToLookupMap = async (lookup) => {
5617
- if (!this.bridge) {
5618
- throw new Error("No bridge configured");
5619
- }
5620
- const lookupPath = import_path3.default.join(this.getGeneratedFolder(), `_lookup.json`);
5621
- let lookupMap;
5622
- try {
5623
- lookupMap = JSON.parse(await this.bridge.get((0, import_schema_tools3.normalizePath)(lookupPath)));
5624
- } catch (e) {
5625
- lookupMap = {};
5626
- }
5627
- const updatedLookup = {
5628
- ...lookupMap,
5629
- [lookup.type]: lookup
5630
- };
5631
- await this.bridge.putConfig(
5632
- (0, import_schema_tools3.normalizePath)(lookupPath),
5633
- JSON.stringify(updatedLookup)
5634
- );
5635
- };
5636
5589
  this.tinaDirectory = config.tinaDirectory || ".tina";
5637
5590
  this.bridge = config.bridge;
5638
5591
  this.rootLevel = config.level && new LevelProxy(config.level);
@@ -5957,23 +5910,12 @@ var FilesystemBridge = class {
5957
5910
  return item.replace(posixRootPath, "").replace(/^\/|\/$/g, "");
5958
5911
  });
5959
5912
  }
5960
- supportsBuilding() {
5961
- return true;
5962
- }
5963
5913
  async delete(filepath) {
5964
5914
  await import_fs_extra.default.remove(import_path4.default.join(this.outputPath, filepath));
5965
5915
  }
5966
5916
  async get(filepath) {
5967
5917
  return import_fs_extra.default.readFileSync(import_path4.default.join(this.outputPath, filepath)).toString();
5968
5918
  }
5969
- async putConfig(filepath, data) {
5970
- if (this.rootPath !== this.outputPath) {
5971
- await this.put(filepath, data);
5972
- await this.put(filepath, data, this.rootPath);
5973
- } else {
5974
- await this.put(filepath, data);
5975
- }
5976
- }
5977
5919
  async put(filepath, data, basePathOverride) {
5978
5920
  const basePath = basePathOverride || this.outputPath;
5979
5921
  await import_fs_extra.default.outputFileSync(import_path4.default.join(basePath, filepath), data);
@@ -5984,7 +5926,10 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
5984
5926
  if ([
5985
5927
  ".tina/__generated__/_lookup.json",
5986
5928
  ".tina/__generated__/_schema.json",
5987
- ".tina/__generated__/_graphql.json"
5929
+ ".tina/__generated__/_graphql.json",
5930
+ "tina/__generated__/_lookup.json",
5931
+ "tina/__generated__/_schema.json",
5932
+ "tina/__generated__/_graphql.json"
5988
5933
  ].includes(filepath)) {
5989
5934
  return super.put(filepath, data);
5990
5935
  }
@@ -6252,9 +6197,6 @@ var IsomorphicBridge = class {
6252
6197
  });
6253
6198
  return results.map((path5) => this.unqualifyPath(path5)).filter((path5) => path5.endsWith(extension));
6254
6199
  }
6255
- supportsBuilding() {
6256
- return true;
6257
- }
6258
6200
  async delete(filepath) {
6259
6201
  const ref = await this.getRef();
6260
6202
  const { pathParts, pathEntries } = await this.resolvePathEntries(
@@ -6340,9 +6282,6 @@ var IsomorphicBridge = class {
6340
6282
  });
6341
6283
  return Buffer.from(blob).toString("utf8");
6342
6284
  }
6343
- async putConfig(filepath, data) {
6344
- await this.put(filepath, data);
6345
- }
6346
6285
  async put(filepath, data) {
6347
6286
  const ref = await this.getRef();
6348
6287
  const { pathParts, pathEntries } = await this.resolvePathEntries(
@@ -6386,17 +6325,12 @@ var IsomorphicBridge = class {
6386
6325
  };
6387
6326
 
6388
6327
  // src/index.ts
6389
- var buildSchema = async (database, config, flags) => {
6328
+ var buildSchema = async (config, flags) => {
6390
6329
  return buildDotTinaFiles({
6391
- database,
6392
6330
  config,
6393
6331
  flags
6394
6332
  });
6395
6333
  };
6396
- var getASTSchema = async (database) => {
6397
- const gqlAst = await database.getGraphQLSchemaFromBridge();
6398
- return (0, import_graphql7.buildASTSchema)(gqlAst);
6399
- };
6400
6334
  // Annotate the CommonJS export names for ESM import in node:
6401
6335
  0 && (module.exports = {
6402
6336
  AuditFileSystemBridge,
@@ -6412,7 +6346,6 @@ var getASTSchema = async (database) => {
6412
6346
  buildSchema,
6413
6347
  createDatabase,
6414
6348
  createSchema,
6415
- getASTSchema,
6416
6349
  handleFetchErrorError,
6417
6350
  parseFile,
6418
6351
  resolve,
@@ -1,6 +1,3 @@
1
- /**
2
-
3
- */
4
1
  import { ManyLevelGuest } from 'many-level';
5
2
  export declare class TinaLevelClient extends ManyLevelGuest<string, Record<string, any>> {
6
3
  private port;
@@ -8,21 +5,3 @@ export declare class TinaLevelClient extends ManyLevelGuest<string, Record<strin
8
5
  constructor(port?: number);
9
6
  openConnection(): void;
10
7
  }
11
- export interface Bridge {
12
- rootPath: string;
13
- glob(pattern: string, extension: string): Promise<string[]>;
14
- get(filepath: string): Promise<string>;
15
- put(filepath: string, data: string): Promise<void>;
16
- delete(filepath: string): Promise<void>;
17
- /**
18
- * Whether this bridge supports the ability to build the schema.
19
- */
20
- supportsBuilding(): boolean;
21
- putConfig(filepath: string, data: string): Promise<void>;
22
- /**
23
- * Optionally, the bridge can perform
24
- * operations in a separate path.
25
- */
26
- outputPath?: string;
27
- addOutputPath?(outputPath: string): void;
28
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "typings": "dist/index.d.ts",