@tinacms/graphql 0.60.6 → 0.61.0

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 CHANGED
@@ -1,5 +1,65 @@
1
1
  # tina-graphql
2
2
 
3
+ ## 0.61.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4daf15b36: Updated matching logic to only return the correct extension.
8
+
9
+ This means if you are using any other files besides `.md` the format must be provided in the schema.
10
+
11
+ ```ts
12
+ // .tina/schema.ts
13
+
14
+ import { defineSchema } from 'tinacms'
15
+
16
+ const schema = defineSchema({
17
+ collections: [
18
+ {
19
+ name: 'page',
20
+ path: 'content/page',
21
+ label: 'Page',
22
+ // Need to provide the format if the file being used (default is `.md`)
23
+ format: 'mdx',
24
+ fields: [
25
+ //...
26
+ ],
27
+ },
28
+ ],
29
+ })
30
+ //...
31
+
32
+ export default schema
33
+ ```
34
+
35
+ ### Patch Changes
36
+
37
+ - 2ef5a1f33: Use media config from the schema in the local media server
38
+ - 2ef5a1f33: Uses new `schema.config` when resolving media/asset urls
39
+ - b348f8b6b: Experimental isomorphic git bridge implementation
40
+ - fb73fb355: Renames syncFolder to a mediaRoot when configuring Repo-Based Media
41
+ - Updated dependencies [b348f8b6b]
42
+ - Updated dependencies [fb73fb355]
43
+ - Updated dependencies [4daf15b36]
44
+ - @tinacms/datalayer@0.2.0
45
+ - @tinacms/schema-tools@0.0.6
46
+
47
+ ## 0.60.8
48
+
49
+ ### Patch Changes
50
+
51
+ - 3325cd226: Make @tinacms/schema-tools a regular dependency of @tinacms/graphql
52
+
53
+ ## 0.60.7
54
+
55
+ ### Patch Changes
56
+
57
+ - f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
58
+ - b1a4290e6: Use media config from the schema in the local media server
59
+ - 1955b8842: Uses new `schema.config` when resolving media/asset urls
60
+ - 8b81c3cf3: Added more context to error messages to help to user debug issues
61
+ - @tinacms/datalayer@0.1.1
62
+
3
63
  ## 0.60.6
4
64
 
5
65
  ### Patch Changes
@@ -12,7 +12,7 @@ limitations under the License.
12
12
  */
13
13
  export interface Bridge {
14
14
  rootPath: string;
15
- glob(pattern: string): Promise<string[]>;
15
+ glob(pattern: string, extension: string): Promise<string[]>;
16
16
  get(filepath: string): Promise<string>;
17
17
  put(filepath: string, data: string): Promise<void>;
18
18
  delete(filepath: string): Promise<void>;
@@ -28,6 +28,7 @@ declare type CreateDatabase = {
28
28
  export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
29
29
  /** Options for {@link Database.query} **/
30
30
  export declare type QueryOptions = {
31
+ fileExtension?: string;
31
32
  collection: string;
32
33
  filterChain?: (BinaryFilter | TernaryFilter)[];
33
34
  sort?: string;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ limitations under the License.
12
12
  */
13
13
  export { indexDB } from './build';
14
14
  export { resolve } from './resolve';
15
+ export * from './resolver/error';
15
16
  export { createDatabase } from './database';
16
17
  export type { QueryOptions } from './database';
17
18
  import type { Database } from './database';
package/dist/index.js CHANGED
@@ -10384,9 +10384,14 @@ var require_remark_mdx = __commonJS({
10384
10384
 
10385
10385
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
10386
10386
  __export(exports, {
10387
+ TinaFetchError: () => TinaFetchError,
10388
+ TinaGraphQLError: () => TinaGraphQLError,
10389
+ TinaParseDocumentError: () => TinaParseDocumentError,
10390
+ TinaQueryError: () => TinaQueryError,
10387
10391
  assertShape: () => assertShape,
10388
10392
  buildSchema: () => buildSchema,
10389
10393
  createDatabase: () => createDatabase,
10394
+ handleFetchErrorError: () => handleFetchErrorError,
10390
10395
  indexDB: () => indexDB,
10391
10396
  parseFile: () => parseFile,
10392
10397
  resolve: () => resolve,
@@ -12575,6 +12580,7 @@ var filterSelections = (arr) => {
12575
12580
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/validate.ts
12576
12581
  var import_lodash2 = __toModule(require("lodash"));
12577
12582
  var yup2 = __toModule(require("yup"));
12583
+ var import_schema_tools = __toModule(require("@tinacms/schema-tools"));
12578
12584
  var FIELD_TYPES = [
12579
12585
  "string",
12580
12586
  "number",
@@ -12589,6 +12595,13 @@ var validateSchema = async (schema) => {
12589
12595
  const schema2 = addNamespaceToSchema(import_lodash2.default.cloneDeep(schema));
12590
12596
  const collections = await sequential(schema2.collections, async (collection) => validateCollection(collection));
12591
12597
  validationCollectionsPathAndMatch(collections);
12598
+ if (schema2.config) {
12599
+ const config = (0, import_schema_tools.validateTinaCloudSchemaConfig)(schema2.config);
12600
+ return {
12601
+ collections,
12602
+ config
12603
+ };
12604
+ }
12592
12605
  return {
12593
12606
  collections
12594
12607
  };
@@ -12680,7 +12693,7 @@ var validateField = async (field) => {
12680
12693
 
12681
12694
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
12682
12695
  var name = "@tinacms/graphql";
12683
- var version = "0.60.6";
12696
+ var version = "0.61.0";
12684
12697
  var main = "dist/index.js";
12685
12698
  var typings = "dist/index.d.ts";
12686
12699
  var files = [
@@ -12728,6 +12741,7 @@ var scripts = {
12728
12741
  var dependencies = {
12729
12742
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
12730
12743
  "@tinacms/datalayer": "workspace:*",
12744
+ "@tinacms/schema-tools": "workspace:*",
12731
12745
  "body-parser": "^1.19.0",
12732
12746
  cors: "^2.8.5",
12733
12747
  dataloader: "^2.0.0",
@@ -12802,9 +12816,6 @@ var devDependencies = {
12802
12816
  nodemon: "^2.0.4",
12803
12817
  typescript: "^4.3.5"
12804
12818
  };
12805
- var peerDependencies = {
12806
- "@tinacms/schema-tools": "*"
12807
- };
12808
12819
  var package_default = {
12809
12820
  name,
12810
12821
  version,
@@ -12817,20 +12828,56 @@ var package_default = {
12817
12828
  dependencies,
12818
12829
  publishConfig,
12819
12830
  repository,
12820
- devDependencies,
12821
- peerDependencies
12831
+ devDependencies
12822
12832
  };
12823
12833
 
12824
12834
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
12825
- var TinaError = class extends Error {
12835
+ var TinaGraphQLError = class extends Error {
12826
12836
  constructor(message, extensions) {
12827
12837
  super(message);
12828
12838
  if (!this.name) {
12829
- Object.defineProperty(this, "name", { value: "TinaError" });
12839
+ Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
12830
12840
  }
12831
12841
  this.extensions = __spreadValues({}, extensions);
12832
12842
  }
12833
12843
  };
12844
+ var TinaFetchError = class extends Error {
12845
+ constructor(message, args) {
12846
+ super(message);
12847
+ this.name = "TinaFetchError";
12848
+ this.collection = args.collection;
12849
+ this.stack = args.stack;
12850
+ this.file = args.file;
12851
+ this.originalError = args.originalError;
12852
+ }
12853
+ };
12854
+ var TinaQueryError = class extends TinaFetchError {
12855
+ constructor(args) {
12856
+ super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12857
+ }
12858
+ };
12859
+ var TinaParseDocumentError = class extends TinaFetchError {
12860
+ constructor(args) {
12861
+ super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12862
+ }
12863
+ toString() {
12864
+ return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
12865
+ }
12866
+ };
12867
+ var handleFetchErrorError = (e, verbose) => {
12868
+ if (e instanceof Error) {
12869
+ if (e instanceof TinaFetchError) {
12870
+ if (verbose) {
12871
+ console.log(e.toString());
12872
+ console.log(e);
12873
+ console.log(e.stack);
12874
+ }
12875
+ }
12876
+ } else {
12877
+ console.error(e);
12878
+ }
12879
+ throw e;
12880
+ };
12834
12881
 
12835
12882
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
12836
12883
  var createSchema = async ({
@@ -12943,7 +12990,7 @@ var TinaSchema = class {
12943
12990
  assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
12944
12991
  const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
12945
12992
  if (!template) {
12946
- throw new TinaError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12993
+ throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12947
12994
  collection: lastItem(collection.namespace),
12948
12995
  possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
12949
12996
  data
@@ -13044,7 +13091,7 @@ var _buildFragments = async (builder, tinaSchema, rootPath) => {
13044
13091
  definitions: import_lodash3.default.uniqBy(extractInlineTypes(fragmentDefinitionsFields), (node) => node.name.value)
13045
13092
  };
13046
13093
  const fragPath = import_path.default.join(rootPath, ".tina", "__generated__");
13047
- await import_fs_extra.default.outputFileSync(import_path.default.join(fragPath, "frags.gql"), (0, import_graphql2.print)(fragDoc));
13094
+ await import_fs_extra.default.outputFile(import_path.default.join(fragPath, "frags.gql"), (0, import_graphql2.print)(fragDoc));
13048
13095
  };
13049
13096
  var _buildQueries = async (builder, tinaSchema, rootPath) => {
13050
13097
  const operationsDefinitions = [];
@@ -13068,7 +13115,7 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
13068
13115
  definitions: import_lodash3.default.uniqBy(extractInlineTypes(operationsDefinitions), (node) => node.name.value)
13069
13116
  };
13070
13117
  const fragPath = import_path.default.join(rootPath, ".tina", "__generated__");
13071
- await import_fs_extra.default.outputFileSync(import_path.default.join(fragPath, "queries.gql"), (0, import_graphql2.print)(queryDoc));
13118
+ await import_fs_extra.default.outputFile(import_path.default.join(fragPath, "queries.gql"), (0, import_graphql2.print)(queryDoc));
13072
13119
  };
13073
13120
  var _buildSchema = async (builder, tinaSchema) => {
13074
13121
  const definitions = [];
@@ -20428,40 +20475,60 @@ var visit = function(tree, test, visitor, reverse) {
20428
20475
  var import_lodash4 = __toModule(require("lodash"));
20429
20476
 
20430
20477
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
20431
- var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }) => {
20478
+ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
20432
20479
  if (config && value) {
20433
20480
  if (config.useRelativeMedia === true) {
20434
20481
  return value;
20435
- } else {
20482
+ }
20483
+ if (hasTinaMediaConfig(schema) === true) {
20436
20484
  const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
20437
20485
  if (typeof value === "string" && value.includes(assetsURL)) {
20438
- return value.replace(assetsURL, "");
20439
- } else {
20440
- return value;
20486
+ const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
20487
+ const strippedURL = value.replace(assetsURL, "");
20488
+ return `${cleanMediaRoot}${strippedURL}`;
20441
20489
  }
20490
+ return value;
20442
20491
  }
20492
+ return value;
20443
20493
  } else {
20444
20494
  return value;
20445
20495
  }
20446
20496
  };
20447
- var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }) => {
20497
+ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
20448
20498
  if (config && value) {
20449
20499
  if (config.useRelativeMedia === true) {
20450
20500
  return value;
20451
- } else {
20452
- return `https://${config.assetsHost}/${config.clientId}${value}`;
20453
20501
  }
20502
+ if (hasTinaMediaConfig(schema) === true) {
20503
+ const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
20504
+ const strippedValue = value.replace(cleanMediaRoot, "");
20505
+ return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
20506
+ }
20507
+ return value;
20454
20508
  } else {
20455
20509
  return value;
20456
20510
  }
20457
20511
  };
20512
+ var cleanUpSlashes = (path6) => {
20513
+ if (path6) {
20514
+ return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
20515
+ }
20516
+ return "";
20517
+ };
20518
+ var hasTinaMediaConfig = (schema) => {
20519
+ var _a, _b, _c, _d, _e, _f;
20520
+ 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)) {
20521
+ return true;
20522
+ }
20523
+ return false;
20524
+ };
20458
20525
 
20459
20526
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20460
- var parseMDX = (value, field, graphQLconfig) => {
20527
+ var parseMDX = (value, field, graphQLconfig, schema) => {
20461
20528
  const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
20462
- return parseMDXInner(tree, field, graphQLconfig);
20529
+ return parseMDXInner(tree, field, graphQLconfig, schema);
20463
20530
  };
20464
- var parseMDXInner = (tree, field, graphQLconfig) => {
20531
+ var parseMDXInner = (tree, field, graphQLconfig, schema) => {
20465
20532
  visit(tree, (node) => {
20466
20533
  delete node.position;
20467
20534
  });
@@ -20469,7 +20536,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20469
20536
  var _a;
20470
20537
  let props = {};
20471
20538
  if (!node.name) {
20472
- props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig);
20539
+ props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig, schema);
20473
20540
  }
20474
20541
  const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
20475
20542
  const templateName = typeof template2 === "string" ? template2 : template2.name;
@@ -20500,7 +20567,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20500
20567
  if (!field2) {
20501
20568
  throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
20502
20569
  }
20503
- parseField(attribute, field2, props, graphQLconfig);
20570
+ parseField(attribute, field2, props, graphQLconfig, schema);
20504
20571
  }
20505
20572
  } else {
20506
20573
  console.log(`Not sure what this is, type: ${attribute.type}`);
@@ -20509,10 +20576,10 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20509
20576
  delete node.attributes;
20510
20577
  node.props = props;
20511
20578
  });
20512
- const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig));
20579
+ const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig, schema));
20513
20580
  return { type: "root", children: slateTree };
20514
20581
  };
20515
- var parseField = (attribute, field, props, graphQLconfig) => {
20582
+ var parseField = (attribute, field, props, graphQLconfig, schema) => {
20516
20583
  var _a, _b;
20517
20584
  switch (field.type) {
20518
20585
  case "boolean":
@@ -20520,7 +20587,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20520
20587
  props[field.name] = attribute.value;
20521
20588
  break;
20522
20589
  case "image":
20523
- props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig);
20590
+ props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig, schema);
20524
20591
  break;
20525
20592
  case "number":
20526
20593
  case "string":
@@ -20583,7 +20650,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20583
20650
  throw new Error(`Global fields not supported at this time`);
20584
20651
  }
20585
20652
  field.fields.forEach((field2) => {
20586
- parseField(property, field2, objectProps, graphQLconfig);
20653
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20587
20654
  });
20588
20655
  }
20589
20656
  });
@@ -20605,7 +20672,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20605
20672
  throw new Error(`Global fields not supported at this time`);
20606
20673
  }
20607
20674
  field.fields.forEach((field2) => {
20608
- parseField(property, field2, objectProps, graphQLconfig);
20675
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20609
20676
  });
20610
20677
  }
20611
20678
  if (field.templates) {
@@ -20614,7 +20681,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20614
20681
  throw new Error(`Global fields not supported at this time`);
20615
20682
  }
20616
20683
  fieldTemplate.fields.forEach((field2) => {
20617
- parseField(property, field2, objectProps, graphQLconfig);
20684
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20618
20685
  });
20619
20686
  });
20620
20687
  }
@@ -20637,13 +20704,13 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20637
20704
  if (attribute.value) {
20638
20705
  if (field.name === "children") {
20639
20706
  if (Array.isArray(attribute.value)) {
20640
- props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig);
20707
+ props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig, schema);
20641
20708
  } else {
20642
20709
  throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
20643
20710
  }
20644
20711
  } else {
20645
20712
  try {
20646
- const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig);
20713
+ const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig, schema);
20647
20714
  props[field.name] = mdx2.children[0].props;
20648
20715
  } catch (e) {
20649
20716
  console.log(e);
@@ -20714,7 +20781,7 @@ var defaultNodeTypes = {
20714
20781
  break: "break",
20715
20782
  image: plateElements.ELEMENT_IMAGE
20716
20783
  };
20717
- function remarkToSlate(node, graphQLconfig) {
20784
+ function remarkToSlate(node, graphQLconfig, schema) {
20718
20785
  const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
20719
20786
  heading: __spreadValues({}, defaultNodeTypes.heading)
20720
20787
  });
@@ -20722,12 +20789,12 @@ function remarkToSlate(node, graphQLconfig) {
20722
20789
  case "heading":
20723
20790
  return {
20724
20791
  type: types.heading[node.depth],
20725
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20792
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20726
20793
  };
20727
20794
  case "list":
20728
20795
  return {
20729
20796
  type: node.ordered ? types.ol_list : types.ul_list,
20730
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20797
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20731
20798
  };
20732
20799
  case "listItem":
20733
20800
  const realChildren = [];
@@ -20735,12 +20802,12 @@ function remarkToSlate(node, graphQLconfig) {
20735
20802
  if (child.type === "list") {
20736
20803
  realChildren.push({
20737
20804
  type: child.ordered ? types.ol_list : types.ul_list,
20738
- children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20805
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20739
20806
  });
20740
20807
  } else {
20741
20808
  realChildren.push({
20742
20809
  type: plateElements.ELEMENT_LIC,
20743
- children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20810
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20744
20811
  });
20745
20812
  }
20746
20813
  });
@@ -20751,16 +20818,16 @@ function remarkToSlate(node, graphQLconfig) {
20751
20818
  case "paragraph":
20752
20819
  return {
20753
20820
  type: types.paragraph,
20754
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20821
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20755
20822
  };
20756
20823
  case "link":
20757
20824
  return {
20758
20825
  type: types.link,
20759
20826
  url: node.url,
20760
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20827
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20761
20828
  };
20762
20829
  case "image":
20763
- const url = resolveMediaRelativeToCloud(node.url, graphQLconfig);
20830
+ const url = resolveMediaRelativeToCloud(node.url, graphQLconfig, schema);
20764
20831
  return {
20765
20832
  type: types.image,
20766
20833
  url,
@@ -20770,7 +20837,7 @@ function remarkToSlate(node, graphQLconfig) {
20770
20837
  case "blockquote":
20771
20838
  return {
20772
20839
  type: types.block_quote,
20773
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20840
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20774
20841
  };
20775
20842
  case "code":
20776
20843
  return {
@@ -22231,10 +22298,10 @@ var mdxToMarkdown = {
22231
22298
  };
22232
22299
 
22233
22300
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
22234
- var stringifyMDX = (value, field, graphQLconfig) => {
22301
+ var stringifyMDX = (value, field, graphQLconfig, schema) => {
22235
22302
  const slateTree = value.children;
22236
22303
  try {
22237
- const tree = stringifyChildren(slateTree, field, graphQLconfig);
22304
+ const tree = stringifyChildren(slateTree, field, graphQLconfig, schema);
22238
22305
  const out = toMarkdown({
22239
22306
  type: "root",
22240
22307
  children: tree
@@ -22252,13 +22319,13 @@ var allChildrenEmpty = (children) => {
22252
22319
  }
22253
22320
  return false;
22254
22321
  };
22255
- var stringifyChildren = (children, field, graphQLconfig) => {
22322
+ var stringifyChildren = (children, field, graphQLconfig, schema) => {
22256
22323
  if (!children) {
22257
22324
  return [];
22258
22325
  }
22259
- return children.map((child) => stringify(child, field, graphQLconfig)).filter(Boolean);
22326
+ return children.map((child) => stringify(child, field, graphQLconfig, schema)).filter(Boolean);
22260
22327
  };
22261
- var stringify = (node, field, graphQLconfig) => {
22328
+ var stringify = (node, field, graphQLconfig, schema) => {
22262
22329
  var _a;
22263
22330
  if (!node.type) {
22264
22331
  if (node == null ? void 0 : node.code) {
@@ -22284,40 +22351,40 @@ var stringify = (node, field, graphQLconfig) => {
22284
22351
  return {
22285
22352
  type: "heading",
22286
22353
  depth: 1,
22287
- children: stringifyChildren(node.children, field, graphQLconfig)
22354
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22288
22355
  };
22289
22356
  case plateElements.ELEMENT_H2:
22290
22357
  return {
22291
22358
  type: "heading",
22292
22359
  depth: 2,
22293
- children: stringifyChildren(node.children, field, graphQLconfig)
22360
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22294
22361
  };
22295
22362
  case plateElements.ELEMENT_H3:
22296
22363
  return {
22297
22364
  type: "heading",
22298
22365
  depth: 3,
22299
- children: stringifyChildren(node.children, field, graphQLconfig)
22366
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22300
22367
  };
22301
22368
  case plateElements.ELEMENT_H4:
22302
22369
  return {
22303
22370
  type: "heading",
22304
22371
  depth: 4,
22305
- children: stringifyChildren(node.children, field, graphQLconfig)
22372
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22306
22373
  };
22307
22374
  case plateElements.ELEMENT_H5:
22308
22375
  return {
22309
22376
  type: "heading",
22310
22377
  depth: 5,
22311
- children: stringifyChildren(node.children, field, graphQLconfig)
22378
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22312
22379
  };
22313
22380
  case plateElements.ELEMENT_H6:
22314
22381
  return {
22315
22382
  type: "heading",
22316
22383
  depth: 6,
22317
- children: stringifyChildren(node.children, field, graphQLconfig)
22384
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22318
22385
  };
22319
22386
  case plateElements.ELEMENT_PARAGRAPH:
22320
- const children = stringifyChildren(node.children, field, graphQLconfig);
22387
+ const children = stringifyChildren(node.children, field, graphQLconfig, schema);
22321
22388
  if (allChildrenEmpty(children)) {
22322
22389
  return false;
22323
22390
  }
@@ -22337,7 +22404,7 @@ var stringify = (node, field, graphQLconfig) => {
22337
22404
  ordered: false,
22338
22405
  spread: false,
22339
22406
  check: null,
22340
- children: stringifyChildren(node.children, field, graphQLconfig)
22407
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22341
22408
  };
22342
22409
  case plateElements.ELEMENT_OL:
22343
22410
  return {
@@ -22345,7 +22412,7 @@ var stringify = (node, field, graphQLconfig) => {
22345
22412
  ordered: true,
22346
22413
  spread: false,
22347
22414
  check: null,
22348
- children: stringifyChildren(node.children, field, graphQLconfig)
22415
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22349
22416
  };
22350
22417
  case plateElements.ELEMENT_LI:
22351
22418
  const realChildren = [];
@@ -22368,17 +22435,17 @@ var stringify = (node, field, graphQLconfig) => {
22368
22435
  spread: false,
22369
22436
  check: null,
22370
22437
  children: [
22371
- ...stringifyChildren([p], field, graphQLconfig),
22372
- ...stringifyChildren(extraChildren, field, graphQLconfig)
22438
+ ...stringifyChildren([p], field, graphQLconfig, schema),
22439
+ ...stringifyChildren(extraChildren, field, graphQLconfig, schema)
22373
22440
  ]
22374
22441
  };
22375
22442
  case plateElements.ELEMENT_LIC:
22376
22443
  return {
22377
22444
  type: "paragraph",
22378
- children: stringifyChildren(node.children, field, graphQLconfig)
22445
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22379
22446
  };
22380
22447
  case plateElements.ELEMENT_IMAGE:
22381
- const url = resolveMediaCloudToRelative(node.url, graphQLconfig);
22448
+ const url = resolveMediaCloudToRelative(node.url, graphQLconfig, schema);
22382
22449
  return {
22383
22450
  type: "image",
22384
22451
  title: node.caption,
@@ -22394,12 +22461,12 @@ var stringify = (node, field, graphQLconfig) => {
22394
22461
  type: "link",
22395
22462
  url: node.url,
22396
22463
  title: node.title,
22397
- children: stringifyChildren(node.children, field, graphQLconfig)
22464
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22398
22465
  };
22399
22466
  case plateElements.ELEMENT_BLOCKQUOTE:
22400
22467
  return {
22401
22468
  type: "blockquote",
22402
- children: stringifyChildren(node.children, field, graphQLconfig)
22469
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22403
22470
  };
22404
22471
  case "mdxJsxTextElement":
22405
22472
  case "mdxJsxFlowElement":
@@ -22564,7 +22631,7 @@ var stringify = (node, field, graphQLconfig) => {
22564
22631
  }
22565
22632
  break;
22566
22633
  case "rich-text":
22567
- const tree = stringifyChildren(value.children, field2, graphQLconfig);
22634
+ const tree = stringifyChildren(value.children, field2, graphQLconfig, schema);
22568
22635
  if (field2.name === "children") {
22569
22636
  children2 = tree;
22570
22637
  } else {
@@ -22767,7 +22834,18 @@ var Resolver = class {
22767
22834
  _collection: rawData._collection,
22768
22835
  _template: rawData._template
22769
22836
  };
22770
- await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
22837
+ try {
22838
+ await sequential(template.fields, async (field) => {
22839
+ return this.resolveFieldData(field, rawData, data);
22840
+ });
22841
+ } catch (e) {
22842
+ throw new TinaParseDocumentError({
22843
+ originalError: e,
22844
+ collection: collection.name,
22845
+ file: relativePath,
22846
+ stack: e.stack
22847
+ });
22848
+ }
22771
22849
  const titleField = template.fields.find((x) => {
22772
22850
  if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
22773
22851
  return true;
@@ -22793,8 +22871,8 @@ var Resolver = class {
22793
22871
  _values: data
22794
22872
  });
22795
22873
  } catch (e) {
22796
- if (e instanceof TinaError) {
22797
- throw new TinaError(e.message, __spreadValues({
22874
+ if (e instanceof TinaGraphQLError) {
22875
+ throw new TinaGraphQLError(e.message, __spreadValues({
22798
22876
  requestedDocument: fullPath
22799
22877
  }, e.extensions));
22800
22878
  }
@@ -23051,7 +23129,8 @@ var Resolver = class {
23051
23129
  edges = result.edges;
23052
23130
  pageInfo = result.pageInfo;
23053
23131
  } else {
23054
- edges = (await this.database.store.glob(collection.path, this.getDocument)).map((document3) => ({
23132
+ const ext = (collection == null ? void 0 : collection.format) || ".md";
23133
+ edges = (await this.database.store.glob(collection.path, this.getDocument, ext)).map((document3) => ({
23055
23134
  node: document3
23056
23135
  }));
23057
23136
  }
@@ -23088,13 +23167,13 @@ var Resolver = class {
23088
23167
  accum[fieldName] = fieldValue;
23089
23168
  break;
23090
23169
  case "image":
23091
- accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config);
23170
+ accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config, this.tinaSchema.schema);
23092
23171
  break;
23093
23172
  case "object":
23094
23173
  accum[fieldName] = this.buildObjectMutations(fieldValue, field);
23095
23174
  break;
23096
23175
  case "rich-text":
23097
- accum[fieldName] = stringifyMDX(fieldValue, field, this.config);
23176
+ accum[fieldName] = stringifyMDX(fieldValue, field, this.config, this.tinaSchema.schema);
23098
23177
  break;
23099
23178
  case "reference":
23100
23179
  accum[fieldName] = fieldValue;
@@ -23127,10 +23206,10 @@ var Resolver = class {
23127
23206
  accumulator[field.name] = value;
23128
23207
  break;
23129
23208
  case "image":
23130
- accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config);
23209
+ accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config, this.tinaSchema.schema);
23131
23210
  break;
23132
23211
  case "rich-text":
23133
- const tree = parseMDX(value, field, this.config);
23212
+ const tree = parseMDX(value, field, this.config, this.tinaSchema.schema);
23134
23213
  accumulator[field.name] = tree;
23135
23214
  break;
23136
23215
  case "object":
@@ -23235,10 +23314,12 @@ var resolve = async ({
23235
23314
  query,
23236
23315
  variables,
23237
23316
  database,
23238
- silenceErrors
23317
+ silenceErrors,
23318
+ verbose
23239
23319
  }) => {
23240
23320
  var _a;
23241
23321
  try {
23322
+ const verboseValue = verbose != null ? verbose : true;
23242
23323
  const graphQLSchemaAst = await database.getGraphQLSchema();
23243
23324
  const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
23244
23325
  const tinaConfig = await database.getTinaSchema();
@@ -23266,141 +23347,152 @@ var resolve = async ({
23266
23347
  }
23267
23348
  },
23268
23349
  fieldResolver: async (source = {}, _args = {}, _context, info) => {
23269
- const args = JSON.parse(JSON.stringify(_args));
23270
- const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23271
- const lookup = await database.getLookup(returnType);
23272
- const isMutation = info.parentType.toString() === "Mutation";
23273
- const value = source[info.fieldName];
23274
- if (returnType === "Collection") {
23275
- if (value) {
23276
- return value;
23277
- }
23278
- if (info.fieldName === "collections") {
23279
- const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23280
- const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23281
- var _a2;
23282
- return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23283
- });
23284
- return tinaSchema.getCollections().map((collection) => {
23285
- return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23286
- });
23287
- }
23288
- const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23289
- const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23290
- var _a2;
23291
- return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23292
- });
23293
- return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23294
- }
23295
- if (info.fieldName === "getOptimizedQuery") {
23296
- try {
23297
- const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23298
- assumeValid: true,
23299
- includeFragments: false,
23300
- noLocation: true
23301
- });
23302
- return (0, import_graphql3.print)(optimizedQuery);
23303
- } catch (e) {
23304
- throw new Error(`Invalid query provided, Error message: ${e.message}`);
23305
- }
23306
- }
23307
- if (!lookup) {
23308
- return value;
23309
- }
23310
- const isCreation = lookup[info.fieldName] === "create";
23311
- switch (lookup.resolveType) {
23312
- case "nodeDocument":
23313
- assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23314
- return resolver2.getDocument(args.id);
23315
- case "multiCollectionDocument":
23316
- if (typeof value === "string") {
23317
- return resolver2.getDocument(value);
23350
+ try {
23351
+ const args = JSON.parse(JSON.stringify(_args));
23352
+ const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23353
+ const lookup = await database.getLookup(returnType);
23354
+ const isMutation = info.parentType.toString() === "Mutation";
23355
+ const value = source[info.fieldName];
23356
+ if (returnType === "Collection") {
23357
+ if (value) {
23358
+ return value;
23318
23359
  }
23319
- if (args && args.collection && info.fieldName === "addPendingDocument") {
23320
- return resolver2.resolveDocument({
23321
- args: __spreadProps(__spreadValues({}, args), { params: {} }),
23322
- collection: args.collection,
23323
- isMutation,
23324
- isCreation: true,
23325
- isAddPendingDocument: true
23360
+ if (info.fieldName === "collections") {
23361
+ const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23362
+ const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23363
+ var _a2;
23364
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23326
23365
  });
23327
- }
23328
- if ([
23329
- NAMER.documentQueryName(),
23330
- "createDocument",
23331
- "updateDocument",
23332
- "deleteDocument"
23333
- ].includes(info.fieldName)) {
23334
- const result2 = await resolver2.resolveDocument({
23335
- args,
23336
- collection: args.collection,
23337
- isMutation,
23338
- isCreation,
23339
- isDeletion: info.fieldName === "deleteDocument",
23340
- isAddPendingDocument: false,
23341
- isCollectionSpecific: false
23366
+ return tinaSchema.getCollections().map((collection) => {
23367
+ return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23342
23368
  });
23343
- return result2;
23344
23369
  }
23345
- return value;
23346
- case "multiCollectionDocumentList":
23347
- if (Array.isArray(value)) {
23348
- return {
23349
- totalCount: value.length,
23350
- edges: value.map((document3) => {
23351
- return { node: document3 };
23352
- })
23353
- };
23354
- } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23355
- return resolver2.resolveCollectionConnection({
23356
- args,
23357
- collection: value.collection
23370
+ const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23371
+ const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23372
+ var _a2;
23373
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23374
+ });
23375
+ return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23376
+ }
23377
+ if (info.fieldName === "getOptimizedQuery") {
23378
+ try {
23379
+ const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23380
+ assumeValid: true,
23381
+ includeFragments: false,
23382
+ noLocation: true
23358
23383
  });
23359
- } else {
23360
- throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23384
+ return (0, import_graphql3.print)(optimizedQuery);
23385
+ } catch (e) {
23386
+ throw new Error(`Invalid query provided, Error message: ${e.message}`);
23361
23387
  }
23362
- case "collectionDocument":
23363
- if (value) {
23364
- return value;
23365
- }
23366
- const result = value || await resolver2.resolveDocument({
23367
- args,
23368
- collection: lookup.collection,
23369
- isMutation,
23370
- isCreation,
23371
- isAddPendingDocument: false,
23372
- isCollectionSpecific: true
23373
- });
23374
- return result;
23375
- case "collectionDocumentList":
23376
- return resolver2.resolveCollectionConnection({
23377
- args,
23378
- collection: tinaSchema.getCollection(lookup.collection)
23379
- });
23380
- case "unionData":
23381
- if (!value) {
23382
- if (args.relativePath) {
23388
+ }
23389
+ if (!lookup) {
23390
+ return value;
23391
+ }
23392
+ const isCreation = lookup[info.fieldName] === "create";
23393
+ switch (lookup.resolveType) {
23394
+ case "nodeDocument":
23395
+ assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23396
+ return resolver2.getDocument(args.id);
23397
+ case "multiCollectionDocument":
23398
+ if (typeof value === "string") {
23399
+ return resolver2.getDocument(value);
23400
+ }
23401
+ if (args && args.collection && info.fieldName === "addPendingDocument") {
23402
+ return resolver2.resolveDocument({
23403
+ args: __spreadProps(__spreadValues({}, args), { params: {} }),
23404
+ collection: args.collection,
23405
+ isMutation,
23406
+ isCreation: true,
23407
+ isAddPendingDocument: true
23408
+ });
23409
+ }
23410
+ if ([
23411
+ NAMER.documentQueryName(),
23412
+ "createDocument",
23413
+ "updateDocument",
23414
+ "deleteDocument"
23415
+ ].includes(info.fieldName)) {
23383
23416
  const result2 = await resolver2.resolveDocument({
23384
23417
  args,
23385
- collection: lookup.collection,
23418
+ collection: args.collection,
23386
23419
  isMutation,
23387
23420
  isCreation,
23421
+ isDeletion: info.fieldName === "deleteDocument",
23388
23422
  isAddPendingDocument: false,
23389
- isCollectionSpecific: true
23423
+ isCollectionSpecific: false
23390
23424
  });
23391
23425
  return result2;
23392
23426
  }
23393
- }
23394
- return value;
23395
- default:
23396
- console.error(lookup);
23397
- throw new Error(`Unexpected resolve type`);
23427
+ return value;
23428
+ case "multiCollectionDocumentList":
23429
+ if (Array.isArray(value)) {
23430
+ return {
23431
+ totalCount: value.length,
23432
+ edges: value.map((document3) => {
23433
+ return { node: document3 };
23434
+ })
23435
+ };
23436
+ } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23437
+ return resolver2.resolveCollectionConnection({
23438
+ args,
23439
+ collection: value.collection
23440
+ });
23441
+ } else {
23442
+ throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23443
+ }
23444
+ case "collectionDocument":
23445
+ if (value) {
23446
+ return value;
23447
+ }
23448
+ const result = value || await resolver2.resolveDocument({
23449
+ args,
23450
+ collection: lookup.collection,
23451
+ isMutation,
23452
+ isCreation,
23453
+ isAddPendingDocument: false,
23454
+ isCollectionSpecific: true
23455
+ });
23456
+ return result;
23457
+ case "collectionDocumentList":
23458
+ return resolver2.resolveCollectionConnection({
23459
+ args,
23460
+ collection: tinaSchema.getCollection(lookup.collection)
23461
+ });
23462
+ case "unionData":
23463
+ if (!value) {
23464
+ if (args.relativePath) {
23465
+ const result2 = await resolver2.resolveDocument({
23466
+ args,
23467
+ collection: lookup.collection,
23468
+ isMutation,
23469
+ isCreation,
23470
+ isAddPendingDocument: false,
23471
+ isCollectionSpecific: true
23472
+ });
23473
+ return result2;
23474
+ }
23475
+ }
23476
+ return value;
23477
+ default:
23478
+ console.error(lookup);
23479
+ throw new Error(`Unexpected resolve type`);
23480
+ }
23481
+ } catch (e) {
23482
+ handleFetchErrorError(e, verboseValue);
23398
23483
  }
23399
23484
  }
23400
23485
  });
23401
23486
  if (res.errors) {
23402
23487
  if (!silenceErrors) {
23403
- console.error(res.errors);
23488
+ res.errors.map((e) => {
23489
+ console.error(e.toString());
23490
+ if (verboseValue) {
23491
+ console.error("More error context below");
23492
+ console.error(e.message);
23493
+ console.error(e);
23494
+ }
23495
+ });
23404
23496
  }
23405
23497
  }
23406
23498
  return res;
@@ -23553,25 +23645,34 @@ var Database = class {
23553
23645
  });
23554
23646
  };
23555
23647
  this.put = async (filepath, data, collection) => {
23556
- if (SYSTEM_FILES.includes(filepath)) {
23557
- throw new Error(`Unexpected put for config file ${filepath}`);
23558
- } else {
23559
- let collectionIndexDefinitions;
23560
- if (collection) {
23561
- const indexDefinitions = await this.getIndexDefinitions();
23562
- collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23563
- }
23564
- const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23565
- if (this.store.supportsSeeding()) {
23566
- await this.bridge.put(normalizePath(filepath), stringifiedFile);
23648
+ try {
23649
+ if (SYSTEM_FILES.includes(filepath)) {
23650
+ throw new Error(`Unexpected put for config file ${filepath}`);
23651
+ } else {
23652
+ let collectionIndexDefinitions;
23653
+ if (collection) {
23654
+ const indexDefinitions = await this.getIndexDefinitions();
23655
+ collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23656
+ }
23657
+ const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23658
+ if (this.store.supportsSeeding()) {
23659
+ await this.bridge.put(normalizePath(filepath), stringifiedFile);
23660
+ }
23661
+ await this.store.put(normalizePath(filepath), payload, {
23662
+ keepTemplateKey,
23663
+ collection,
23664
+ indexDefinitions: collectionIndexDefinitions
23665
+ });
23567
23666
  }
23568
- await this.store.put(normalizePath(filepath), payload, {
23569
- keepTemplateKey,
23667
+ return true;
23668
+ } catch (error) {
23669
+ throw new TinaFetchError(`Error in PUT for ${filepath}`, {
23670
+ originalError: error,
23671
+ file: filepath,
23570
23672
  collection,
23571
- indexDefinitions: collectionIndexDefinitions
23673
+ stack: error.stack
23572
23674
  });
23573
23675
  }
23574
- return true;
23575
23676
  };
23576
23677
  this.stringifyFile = async (filepath, data) => {
23577
23678
  if (SYSTEM_FILES.includes(filepath)) {
@@ -23747,11 +23848,24 @@ var Database = class {
23747
23848
  } = await this.store.query(storeQueryOptions);
23748
23849
  return {
23749
23850
  edges: await sequential(edges, async (edge) => {
23750
- const node = await hydrator(edge.path);
23751
- return {
23752
- node,
23753
- cursor: (0, import_datalayer2.btoa)(edge.cursor)
23754
- };
23851
+ try {
23852
+ const node = await hydrator(edge.path);
23853
+ return {
23854
+ node,
23855
+ cursor: (0, import_datalayer2.btoa)(edge.cursor)
23856
+ };
23857
+ } catch (error) {
23858
+ if (error instanceof Error) {
23859
+ throw new TinaQueryError({
23860
+ originalError: error,
23861
+ file: edge.path,
23862
+ collection,
23863
+ stack: error.stack
23864
+ });
23865
+ } else {
23866
+ throw error;
23867
+ }
23868
+ }
23755
23869
  }),
23756
23870
  pageInfo: {
23757
23871
  hasPreviousPage,
@@ -23823,7 +23937,7 @@ var Database = class {
23823
23937
  this._indexAllContent = async () => {
23824
23938
  const tinaSchema = await this.getSchema();
23825
23939
  await sequential(tinaSchema.getCollections(), async (collection) => {
23826
- const documentPaths = await this.bridge.glob(normalizePath(collection.path));
23940
+ const documentPaths = await this.bridge.glob(normalizePath(collection.path), collection.format || "md");
23827
23941
  await _indexContent(this, documentPaths, collection);
23828
23942
  });
23829
23943
  };
@@ -23898,10 +24012,19 @@ var _indexContent = async (database, documentPaths, collection) => {
23898
24012
  };
23899
24013
  }
23900
24014
  await sequential(documentPaths, async (filepath) => {
23901
- const dataString = await database.bridge.get(normalizePath(filepath));
23902
- const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23903
- if (database.store.supportsSeeding()) {
23904
- await database.store.seed(normalizePath(filepath), data, seedOptions);
24015
+ try {
24016
+ const dataString = await database.bridge.get(normalizePath(filepath));
24017
+ const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
24018
+ if (database.store.supportsSeeding()) {
24019
+ await database.store.seed(normalizePath(filepath), data, seedOptions);
24020
+ }
24021
+ } catch (error) {
24022
+ throw new TinaFetchError(`Unable to seed ${filepath}`, {
24023
+ originalError: error,
24024
+ file: filepath,
24025
+ collection: collection.name,
24026
+ stack: error.stack
24027
+ });
23905
24028
  }
23906
24029
  });
23907
24030
  };
@@ -23934,9 +24057,14 @@ var buildSchema = async (rootPath, database, flags) => {
23934
24057
  };
23935
24058
  // Annotate the CommonJS export names for ESM import in node:
23936
24059
  0 && (module.exports = {
24060
+ TinaFetchError,
24061
+ TinaGraphQLError,
24062
+ TinaParseDocumentError,
24063
+ TinaQueryError,
23937
24064
  assertShape,
23938
24065
  buildSchema,
23939
24066
  createDatabase,
24067
+ handleFetchErrorError,
23940
24068
  indexDB,
23941
24069
  parseFile,
23942
24070
  resolve,
@@ -17,7 +17,8 @@ limitations under the License.
17
17
  */
18
18
  import type { Content } from 'mdast';
19
19
  import type { GraphQLConfig, RichTypeInner } from '../types';
20
- export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconfig: GraphQLConfig) => {
20
+ import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
21
+ export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => {
21
22
  type: string;
22
23
  children: any;
23
24
  };
@@ -70,7 +71,7 @@ export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconf
70
71
  * 2. We don't need to do any client-side parsing. Since TinaMarkdown and the slate editor work with the same
71
72
  * format we can just allow Tina to do it's thing and update the form valuse with no additional work.
72
73
  */
73
- export declare const parseMDXInner: (tree: any, field: RichTypeInner, graphQLconfig: GraphQLConfig) => {
74
+ export declare const parseMDXInner: (tree: any, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => {
74
75
  type: string;
75
76
  children: any;
76
77
  };
@@ -226,5 +227,5 @@ export declare const plateElements: {
226
227
  MARK_UNDERLINE: string;
227
228
  };
228
229
  export declare const defaultNodeTypes: NodeTypes;
229
- export default function remarkToSlate(node: MdxAstNode, graphQLconfig: GraphQLConfig): any;
230
+ export default function remarkToSlate(node: MdxAstNode, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched): any;
230
231
  export {};
@@ -16,9 +16,10 @@ limitations under the License.
16
16
 
17
17
  */
18
18
  import type { GraphQLConfig, RichTypeInner } from '../types';
19
+ import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
19
20
  import { plateElements } from './parse';
20
21
  import type { Content } from 'mdast';
21
- export declare const stringifyMDX: (value: unknown, field: RichTypeInner, graphQLconfig: GraphQLConfig) => string;
22
+ export declare const stringifyMDX: (value: unknown, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
22
23
  export declare const stringify: (node: {
23
24
  type: typeof plateElements;
24
- }, field: RichTypeInner, graphQLconfig: GraphQLConfig) => Content;
25
+ }, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => Content;
package/dist/resolve.d.ts CHANGED
@@ -12,12 +12,13 @@ limitations under the License.
12
12
  */
13
13
  import type { Database } from './database';
14
14
  import type { GraphQLConfig } from './types';
15
- export declare const resolve: ({ config, query, variables, database, silenceErrors, }: {
15
+ export declare const resolve: ({ config, query, variables, database, silenceErrors, verbose, }: {
16
16
  config?: GraphQLConfig;
17
17
  query: string;
18
18
  variables: object;
19
19
  database: Database;
20
20
  silenceErrors?: boolean;
21
+ verbose?: boolean;
21
22
  }) => Promise<import("graphql").ExecutionResult<{
22
23
  [key: string]: any;
23
24
  }, {
@@ -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 { ASTNode, GraphQLError, Source, SourceLocation } from 'graphql';
14
- export declare class TinaError extends Error implements GraphQLError {
14
+ export declare class TinaGraphQLError extends Error implements GraphQLError {
15
15
  extensions: Record<string, any>;
16
16
  readonly name: string;
17
17
  readonly locations: ReadonlyArray<SourceLocation> | undefined;
@@ -23,3 +23,32 @@ export declare class TinaError extends Error implements GraphQLError {
23
23
  [key: string]: any;
24
24
  constructor(message: string, extensions?: Record<string, any>);
25
25
  }
26
+ export declare type TypeFetchErrorArgs = {
27
+ stack?: string;
28
+ file?: string;
29
+ originalError: Error;
30
+ collection?: string;
31
+ };
32
+ export declare class TinaFetchError extends Error {
33
+ stack?: string;
34
+ collection?: string;
35
+ file?: string;
36
+ originalError: Error;
37
+ constructor(message: string, args: TypeFetchErrorArgs);
38
+ }
39
+ export declare class TinaQueryError extends TinaFetchError {
40
+ stack?: string;
41
+ collection?: string;
42
+ file?: string;
43
+ originalError: Error;
44
+ constructor(args: TypeFetchErrorArgs);
45
+ }
46
+ export declare class TinaParseDocumentError extends TinaFetchError {
47
+ stack?: string;
48
+ collection?: string;
49
+ file?: string;
50
+ originalError: Error;
51
+ constructor(args: TypeFetchErrorArgs);
52
+ toString(): string;
53
+ }
54
+ export declare const handleFetchErrorError: (e: unknown, verbose: any) => never;
@@ -10,7 +10,8 @@ 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
- import { GraphQLConfig } from '../types';
13
+ import type { GraphQLConfig } from '../types';
14
+ import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
14
15
  /**
15
16
  * Strips away the Tina Cloud Asset URL from an `image` value
16
17
  *
@@ -18,7 +19,7 @@ import { GraphQLConfig } from '../types';
18
19
  * @param {GraphQLConfig} config
19
20
  * @returns {string}
20
21
  */
21
- export declare const resolveMediaCloudToRelative: (value: string, config?: GraphQLConfig) => string;
22
+ export declare const resolveMediaCloudToRelative: (value: string, config: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
22
23
  /**
23
24
  * Adds Tina Cloud Asset URL to an `image` value
24
25
  *
@@ -26,4 +27,4 @@ export declare const resolveMediaCloudToRelative: (value: string, config?: Graph
26
27
  * @param {GraphQLConfig} config
27
28
  * @returns {string}
28
29
  */
29
- export declare const resolveMediaRelativeToCloud: (value: string, config?: GraphQLConfig) => string;
30
+ export declare const resolveMediaRelativeToCloud: (value: string, config: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.60.6",
3
+ "version": "0.61.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -47,7 +47,8 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
50
- "@tinacms/datalayer": "0.1.1",
50
+ "@tinacms/datalayer": "0.2.0",
51
+ "@tinacms/schema-tools": "0.0.6",
51
52
  "body-parser": "^1.19.0",
52
53
  "cors": "^2.8.5",
53
54
  "dataloader": "^2.0.0",
@@ -97,9 +98,9 @@
97
98
  "directory": "packages/tina-graphql"
98
99
  },
99
100
  "devDependencies": {
100
- "@tinacms/datalayer": "0.1.1",
101
- "@tinacms/schema-tools": "0.0.4",
102
- "@tinacms/scripts": "0.50.7",
101
+ "@tinacms/datalayer": "0.2.0",
102
+ "@tinacms/schema-tools": "0.0.6",
103
+ "@tinacms/scripts": "0.50.9",
103
104
  "@types/cors": "^2.8.7",
104
105
  "@types/estree": "^0.0.50",
105
106
  "@types/express": "^4.17.8",
@@ -121,8 +122,5 @@
121
122
  "jest-matcher-utils": "27.0.6",
122
123
  "nodemon": "^2.0.4",
123
124
  "typescript": "^4.3.5"
124
- },
125
- "peerDependencies": {
126
- "@tinacms/schema-tools": "*"
127
125
  }
128
126
  }