@tinacms/graphql 0.60.6 → 0.60.7

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,15 @@
1
1
  # tina-graphql
2
2
 
3
+ ## 0.60.7
4
+
5
+ ### Patch Changes
6
+
7
+ - f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
8
+ - b1a4290e6: Use media config from the schema in the local media server
9
+ - 1955b8842: Uses new `schema.config` when resolving media/asset urls
10
+ - 8b81c3cf3: Added more context to error messages to help to user debug issues
11
+ - @tinacms/datalayer@0.1.1
12
+
3
13
  ## 0.60.6
4
14
 
5
15
  ### Patch Changes
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.60.7";
12684
12697
  var main = "dist/index.js";
12685
12698
  var typings = "dist/index.d.ts";
12686
12699
  var files = [
@@ -12822,15 +12835,52 @@ var package_default = {
12822
12835
  };
12823
12836
 
12824
12837
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
12825
- var TinaError = class extends Error {
12838
+ var TinaGraphQLError = class extends Error {
12826
12839
  constructor(message, extensions) {
12827
12840
  super(message);
12828
12841
  if (!this.name) {
12829
- Object.defineProperty(this, "name", { value: "TinaError" });
12842
+ Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
12830
12843
  }
12831
12844
  this.extensions = __spreadValues({}, extensions);
12832
12845
  }
12833
12846
  };
12847
+ var TinaFetchError = class extends Error {
12848
+ constructor(message, args) {
12849
+ super(message);
12850
+ this.name = "TinaFetchError";
12851
+ this.collection = args.collection;
12852
+ this.stack = args.stack;
12853
+ this.file = args.file;
12854
+ this.originalError = args.originalError;
12855
+ }
12856
+ };
12857
+ var TinaQueryError = class extends TinaFetchError {
12858
+ constructor(args) {
12859
+ super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12860
+ }
12861
+ };
12862
+ var TinaParseDocumentError = class extends TinaFetchError {
12863
+ constructor(args) {
12864
+ super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12865
+ }
12866
+ toString() {
12867
+ return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
12868
+ }
12869
+ };
12870
+ var handleFetchErrorError = (e, verbose) => {
12871
+ if (e instanceof Error) {
12872
+ if (e instanceof TinaFetchError) {
12873
+ if (verbose) {
12874
+ console.log(e.toString());
12875
+ console.log(e);
12876
+ console.log(e.stack);
12877
+ }
12878
+ }
12879
+ } else {
12880
+ console.error(e);
12881
+ }
12882
+ throw e;
12883
+ };
12834
12884
 
12835
12885
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
12836
12886
  var createSchema = async ({
@@ -12943,7 +12993,7 @@ var TinaSchema = class {
12943
12993
  assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
12944
12994
  const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
12945
12995
  if (!template) {
12946
- throw new TinaError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12996
+ throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12947
12997
  collection: lastItem(collection.namespace),
12948
12998
  possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
12949
12999
  data
@@ -20428,40 +20478,60 @@ var visit = function(tree, test, visitor, reverse) {
20428
20478
  var import_lodash4 = __toModule(require("lodash"));
20429
20479
 
20430
20480
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
20431
- var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }) => {
20481
+ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
20432
20482
  if (config && value) {
20433
20483
  if (config.useRelativeMedia === true) {
20434
20484
  return value;
20435
- } else {
20485
+ }
20486
+ if (hasTinaMediaConfig(schema) === true) {
20436
20487
  const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
20437
20488
  if (typeof value === "string" && value.includes(assetsURL)) {
20438
- return value.replace(assetsURL, "");
20439
- } else {
20440
- return value;
20489
+ const cleanSyncFolder = cleanUpSlashes(schema.config.media.tina.syncFolder);
20490
+ const strippedURL = value.replace(assetsURL, "");
20491
+ return `${cleanSyncFolder}${strippedURL}`;
20441
20492
  }
20493
+ return value;
20442
20494
  }
20495
+ return value;
20443
20496
  } else {
20444
20497
  return value;
20445
20498
  }
20446
20499
  };
20447
- var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }) => {
20500
+ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
20448
20501
  if (config && value) {
20449
20502
  if (config.useRelativeMedia === true) {
20450
20503
  return value;
20451
- } else {
20452
- return `https://${config.assetsHost}/${config.clientId}${value}`;
20453
20504
  }
20505
+ if (hasTinaMediaConfig(schema) === true) {
20506
+ const cleanSyncFolder = cleanUpSlashes(schema.config.media.tina.syncFolder);
20507
+ const strippedValue = value.replace(cleanSyncFolder, "");
20508
+ return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
20509
+ }
20510
+ return value;
20454
20511
  } else {
20455
20512
  return value;
20456
20513
  }
20457
20514
  };
20515
+ var cleanUpSlashes = (path6) => {
20516
+ if (path6) {
20517
+ return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
20518
+ }
20519
+ return "";
20520
+ };
20521
+ var hasTinaMediaConfig = (schema) => {
20522
+ var _a, _b, _c, _d, _e, _f;
20523
+ 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.syncFolder)) {
20524
+ return true;
20525
+ }
20526
+ return false;
20527
+ };
20458
20528
 
20459
20529
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20460
- var parseMDX = (value, field, graphQLconfig) => {
20530
+ var parseMDX = (value, field, graphQLconfig, schema) => {
20461
20531
  const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
20462
- return parseMDXInner(tree, field, graphQLconfig);
20532
+ return parseMDXInner(tree, field, graphQLconfig, schema);
20463
20533
  };
20464
- var parseMDXInner = (tree, field, graphQLconfig) => {
20534
+ var parseMDXInner = (tree, field, graphQLconfig, schema) => {
20465
20535
  visit(tree, (node) => {
20466
20536
  delete node.position;
20467
20537
  });
@@ -20469,7 +20539,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20469
20539
  var _a;
20470
20540
  let props = {};
20471
20541
  if (!node.name) {
20472
- props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig);
20542
+ props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig, schema);
20473
20543
  }
20474
20544
  const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
20475
20545
  const templateName = typeof template2 === "string" ? template2 : template2.name;
@@ -20500,7 +20570,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20500
20570
  if (!field2) {
20501
20571
  throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
20502
20572
  }
20503
- parseField(attribute, field2, props, graphQLconfig);
20573
+ parseField(attribute, field2, props, graphQLconfig, schema);
20504
20574
  }
20505
20575
  } else {
20506
20576
  console.log(`Not sure what this is, type: ${attribute.type}`);
@@ -20509,10 +20579,10 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
20509
20579
  delete node.attributes;
20510
20580
  node.props = props;
20511
20581
  });
20512
- const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig));
20582
+ const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig, schema));
20513
20583
  return { type: "root", children: slateTree };
20514
20584
  };
20515
- var parseField = (attribute, field, props, graphQLconfig) => {
20585
+ var parseField = (attribute, field, props, graphQLconfig, schema) => {
20516
20586
  var _a, _b;
20517
20587
  switch (field.type) {
20518
20588
  case "boolean":
@@ -20520,7 +20590,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20520
20590
  props[field.name] = attribute.value;
20521
20591
  break;
20522
20592
  case "image":
20523
- props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig);
20593
+ props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig, schema);
20524
20594
  break;
20525
20595
  case "number":
20526
20596
  case "string":
@@ -20583,7 +20653,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20583
20653
  throw new Error(`Global fields not supported at this time`);
20584
20654
  }
20585
20655
  field.fields.forEach((field2) => {
20586
- parseField(property, field2, objectProps, graphQLconfig);
20656
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20587
20657
  });
20588
20658
  }
20589
20659
  });
@@ -20605,7 +20675,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20605
20675
  throw new Error(`Global fields not supported at this time`);
20606
20676
  }
20607
20677
  field.fields.forEach((field2) => {
20608
- parseField(property, field2, objectProps, graphQLconfig);
20678
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20609
20679
  });
20610
20680
  }
20611
20681
  if (field.templates) {
@@ -20614,7 +20684,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20614
20684
  throw new Error(`Global fields not supported at this time`);
20615
20685
  }
20616
20686
  fieldTemplate.fields.forEach((field2) => {
20617
- parseField(property, field2, objectProps, graphQLconfig);
20687
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20618
20688
  });
20619
20689
  });
20620
20690
  }
@@ -20637,13 +20707,13 @@ var parseField = (attribute, field, props, graphQLconfig) => {
20637
20707
  if (attribute.value) {
20638
20708
  if (field.name === "children") {
20639
20709
  if (Array.isArray(attribute.value)) {
20640
- props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig);
20710
+ props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig, schema);
20641
20711
  } else {
20642
20712
  throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
20643
20713
  }
20644
20714
  } else {
20645
20715
  try {
20646
- const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig);
20716
+ const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig, schema);
20647
20717
  props[field.name] = mdx2.children[0].props;
20648
20718
  } catch (e) {
20649
20719
  console.log(e);
@@ -20714,7 +20784,7 @@ var defaultNodeTypes = {
20714
20784
  break: "break",
20715
20785
  image: plateElements.ELEMENT_IMAGE
20716
20786
  };
20717
- function remarkToSlate(node, graphQLconfig) {
20787
+ function remarkToSlate(node, graphQLconfig, schema) {
20718
20788
  const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
20719
20789
  heading: __spreadValues({}, defaultNodeTypes.heading)
20720
20790
  });
@@ -20722,12 +20792,12 @@ function remarkToSlate(node, graphQLconfig) {
20722
20792
  case "heading":
20723
20793
  return {
20724
20794
  type: types.heading[node.depth],
20725
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20795
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20726
20796
  };
20727
20797
  case "list":
20728
20798
  return {
20729
20799
  type: node.ordered ? types.ol_list : types.ul_list,
20730
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20800
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20731
20801
  };
20732
20802
  case "listItem":
20733
20803
  const realChildren = [];
@@ -20735,12 +20805,12 @@ function remarkToSlate(node, graphQLconfig) {
20735
20805
  if (child.type === "list") {
20736
20806
  realChildren.push({
20737
20807
  type: child.ordered ? types.ol_list : types.ul_list,
20738
- children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20808
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20739
20809
  });
20740
20810
  } else {
20741
20811
  realChildren.push({
20742
20812
  type: plateElements.ELEMENT_LIC,
20743
- children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20813
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20744
20814
  });
20745
20815
  }
20746
20816
  });
@@ -20751,16 +20821,16 @@ function remarkToSlate(node, graphQLconfig) {
20751
20821
  case "paragraph":
20752
20822
  return {
20753
20823
  type: types.paragraph,
20754
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20824
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20755
20825
  };
20756
20826
  case "link":
20757
20827
  return {
20758
20828
  type: types.link,
20759
20829
  url: node.url,
20760
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20830
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20761
20831
  };
20762
20832
  case "image":
20763
- const url = resolveMediaRelativeToCloud(node.url, graphQLconfig);
20833
+ const url = resolveMediaRelativeToCloud(node.url, graphQLconfig, schema);
20764
20834
  return {
20765
20835
  type: types.image,
20766
20836
  url,
@@ -20770,7 +20840,7 @@ function remarkToSlate(node, graphQLconfig) {
20770
20840
  case "blockquote":
20771
20841
  return {
20772
20842
  type: types.block_quote,
20773
- children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
20843
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20774
20844
  };
20775
20845
  case "code":
20776
20846
  return {
@@ -22231,10 +22301,10 @@ var mdxToMarkdown = {
22231
22301
  };
22232
22302
 
22233
22303
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
22234
- var stringifyMDX = (value, field, graphQLconfig) => {
22304
+ var stringifyMDX = (value, field, graphQLconfig, schema) => {
22235
22305
  const slateTree = value.children;
22236
22306
  try {
22237
- const tree = stringifyChildren(slateTree, field, graphQLconfig);
22307
+ const tree = stringifyChildren(slateTree, field, graphQLconfig, schema);
22238
22308
  const out = toMarkdown({
22239
22309
  type: "root",
22240
22310
  children: tree
@@ -22252,13 +22322,13 @@ var allChildrenEmpty = (children) => {
22252
22322
  }
22253
22323
  return false;
22254
22324
  };
22255
- var stringifyChildren = (children, field, graphQLconfig) => {
22325
+ var stringifyChildren = (children, field, graphQLconfig, schema) => {
22256
22326
  if (!children) {
22257
22327
  return [];
22258
22328
  }
22259
- return children.map((child) => stringify(child, field, graphQLconfig)).filter(Boolean);
22329
+ return children.map((child) => stringify(child, field, graphQLconfig, schema)).filter(Boolean);
22260
22330
  };
22261
- var stringify = (node, field, graphQLconfig) => {
22331
+ var stringify = (node, field, graphQLconfig, schema) => {
22262
22332
  var _a;
22263
22333
  if (!node.type) {
22264
22334
  if (node == null ? void 0 : node.code) {
@@ -22284,40 +22354,40 @@ var stringify = (node, field, graphQLconfig) => {
22284
22354
  return {
22285
22355
  type: "heading",
22286
22356
  depth: 1,
22287
- children: stringifyChildren(node.children, field, graphQLconfig)
22357
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22288
22358
  };
22289
22359
  case plateElements.ELEMENT_H2:
22290
22360
  return {
22291
22361
  type: "heading",
22292
22362
  depth: 2,
22293
- children: stringifyChildren(node.children, field, graphQLconfig)
22363
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22294
22364
  };
22295
22365
  case plateElements.ELEMENT_H3:
22296
22366
  return {
22297
22367
  type: "heading",
22298
22368
  depth: 3,
22299
- children: stringifyChildren(node.children, field, graphQLconfig)
22369
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22300
22370
  };
22301
22371
  case plateElements.ELEMENT_H4:
22302
22372
  return {
22303
22373
  type: "heading",
22304
22374
  depth: 4,
22305
- children: stringifyChildren(node.children, field, graphQLconfig)
22375
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22306
22376
  };
22307
22377
  case plateElements.ELEMENT_H5:
22308
22378
  return {
22309
22379
  type: "heading",
22310
22380
  depth: 5,
22311
- children: stringifyChildren(node.children, field, graphQLconfig)
22381
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22312
22382
  };
22313
22383
  case plateElements.ELEMENT_H6:
22314
22384
  return {
22315
22385
  type: "heading",
22316
22386
  depth: 6,
22317
- children: stringifyChildren(node.children, field, graphQLconfig)
22387
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22318
22388
  };
22319
22389
  case plateElements.ELEMENT_PARAGRAPH:
22320
- const children = stringifyChildren(node.children, field, graphQLconfig);
22390
+ const children = stringifyChildren(node.children, field, graphQLconfig, schema);
22321
22391
  if (allChildrenEmpty(children)) {
22322
22392
  return false;
22323
22393
  }
@@ -22337,7 +22407,7 @@ var stringify = (node, field, graphQLconfig) => {
22337
22407
  ordered: false,
22338
22408
  spread: false,
22339
22409
  check: null,
22340
- children: stringifyChildren(node.children, field, graphQLconfig)
22410
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22341
22411
  };
22342
22412
  case plateElements.ELEMENT_OL:
22343
22413
  return {
@@ -22345,7 +22415,7 @@ var stringify = (node, field, graphQLconfig) => {
22345
22415
  ordered: true,
22346
22416
  spread: false,
22347
22417
  check: null,
22348
- children: stringifyChildren(node.children, field, graphQLconfig)
22418
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22349
22419
  };
22350
22420
  case plateElements.ELEMENT_LI:
22351
22421
  const realChildren = [];
@@ -22368,17 +22438,17 @@ var stringify = (node, field, graphQLconfig) => {
22368
22438
  spread: false,
22369
22439
  check: null,
22370
22440
  children: [
22371
- ...stringifyChildren([p], field, graphQLconfig),
22372
- ...stringifyChildren(extraChildren, field, graphQLconfig)
22441
+ ...stringifyChildren([p], field, graphQLconfig, schema),
22442
+ ...stringifyChildren(extraChildren, field, graphQLconfig, schema)
22373
22443
  ]
22374
22444
  };
22375
22445
  case plateElements.ELEMENT_LIC:
22376
22446
  return {
22377
22447
  type: "paragraph",
22378
- children: stringifyChildren(node.children, field, graphQLconfig)
22448
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22379
22449
  };
22380
22450
  case plateElements.ELEMENT_IMAGE:
22381
- const url = resolveMediaCloudToRelative(node.url, graphQLconfig);
22451
+ const url = resolveMediaCloudToRelative(node.url, graphQLconfig, schema);
22382
22452
  return {
22383
22453
  type: "image",
22384
22454
  title: node.caption,
@@ -22394,12 +22464,12 @@ var stringify = (node, field, graphQLconfig) => {
22394
22464
  type: "link",
22395
22465
  url: node.url,
22396
22466
  title: node.title,
22397
- children: stringifyChildren(node.children, field, graphQLconfig)
22467
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22398
22468
  };
22399
22469
  case plateElements.ELEMENT_BLOCKQUOTE:
22400
22470
  return {
22401
22471
  type: "blockquote",
22402
- children: stringifyChildren(node.children, field, graphQLconfig)
22472
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22403
22473
  };
22404
22474
  case "mdxJsxTextElement":
22405
22475
  case "mdxJsxFlowElement":
@@ -22564,7 +22634,7 @@ var stringify = (node, field, graphQLconfig) => {
22564
22634
  }
22565
22635
  break;
22566
22636
  case "rich-text":
22567
- const tree = stringifyChildren(value.children, field2, graphQLconfig);
22637
+ const tree = stringifyChildren(value.children, field2, graphQLconfig, schema);
22568
22638
  if (field2.name === "children") {
22569
22639
  children2 = tree;
22570
22640
  } else {
@@ -22767,7 +22837,18 @@ var Resolver = class {
22767
22837
  _collection: rawData._collection,
22768
22838
  _template: rawData._template
22769
22839
  };
22770
- await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
22840
+ try {
22841
+ await sequential(template.fields, async (field) => {
22842
+ return this.resolveFieldData(field, rawData, data);
22843
+ });
22844
+ } catch (e) {
22845
+ throw new TinaParseDocumentError({
22846
+ originalError: e,
22847
+ collection: collection.name,
22848
+ file: relativePath,
22849
+ stack: e.stack
22850
+ });
22851
+ }
22771
22852
  const titleField = template.fields.find((x) => {
22772
22853
  if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
22773
22854
  return true;
@@ -22793,8 +22874,8 @@ var Resolver = class {
22793
22874
  _values: data
22794
22875
  });
22795
22876
  } catch (e) {
22796
- if (e instanceof TinaError) {
22797
- throw new TinaError(e.message, __spreadValues({
22877
+ if (e instanceof TinaGraphQLError) {
22878
+ throw new TinaGraphQLError(e.message, __spreadValues({
22798
22879
  requestedDocument: fullPath
22799
22880
  }, e.extensions));
22800
22881
  }
@@ -23088,13 +23169,13 @@ var Resolver = class {
23088
23169
  accum[fieldName] = fieldValue;
23089
23170
  break;
23090
23171
  case "image":
23091
- accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config);
23172
+ accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config, this.tinaSchema.schema);
23092
23173
  break;
23093
23174
  case "object":
23094
23175
  accum[fieldName] = this.buildObjectMutations(fieldValue, field);
23095
23176
  break;
23096
23177
  case "rich-text":
23097
- accum[fieldName] = stringifyMDX(fieldValue, field, this.config);
23178
+ accum[fieldName] = stringifyMDX(fieldValue, field, this.config, this.tinaSchema.schema);
23098
23179
  break;
23099
23180
  case "reference":
23100
23181
  accum[fieldName] = fieldValue;
@@ -23127,10 +23208,10 @@ var Resolver = class {
23127
23208
  accumulator[field.name] = value;
23128
23209
  break;
23129
23210
  case "image":
23130
- accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config);
23211
+ accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config, this.tinaSchema.schema);
23131
23212
  break;
23132
23213
  case "rich-text":
23133
- const tree = parseMDX(value, field, this.config);
23214
+ const tree = parseMDX(value, field, this.config, this.tinaSchema.schema);
23134
23215
  accumulator[field.name] = tree;
23135
23216
  break;
23136
23217
  case "object":
@@ -23235,10 +23316,12 @@ var resolve = async ({
23235
23316
  query,
23236
23317
  variables,
23237
23318
  database,
23238
- silenceErrors
23319
+ silenceErrors,
23320
+ verbose
23239
23321
  }) => {
23240
23322
  var _a;
23241
23323
  try {
23324
+ const verboseValue = verbose != null ? verbose : true;
23242
23325
  const graphQLSchemaAst = await database.getGraphQLSchema();
23243
23326
  const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
23244
23327
  const tinaConfig = await database.getTinaSchema();
@@ -23266,141 +23349,152 @@ var resolve = async ({
23266
23349
  }
23267
23350
  },
23268
23351
  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);
23352
+ try {
23353
+ const args = JSON.parse(JSON.stringify(_args));
23354
+ const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23355
+ const lookup = await database.getLookup(returnType);
23356
+ const isMutation = info.parentType.toString() === "Mutation";
23357
+ const value = source[info.fieldName];
23358
+ if (returnType === "Collection") {
23359
+ if (value) {
23360
+ return value;
23318
23361
  }
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
23362
+ if (info.fieldName === "collections") {
23363
+ const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23364
+ const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23365
+ var _a2;
23366
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23326
23367
  });
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
23368
+ return tinaSchema.getCollections().map((collection) => {
23369
+ return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23342
23370
  });
23343
- return result2;
23344
23371
  }
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
23372
+ const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23373
+ const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23374
+ var _a2;
23375
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23376
+ });
23377
+ return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23378
+ }
23379
+ if (info.fieldName === "getOptimizedQuery") {
23380
+ try {
23381
+ const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23382
+ assumeValid: true,
23383
+ includeFragments: false,
23384
+ noLocation: true
23358
23385
  });
23359
- } else {
23360
- throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23386
+ return (0, import_graphql3.print)(optimizedQuery);
23387
+ } catch (e) {
23388
+ throw new Error(`Invalid query provided, Error message: ${e.message}`);
23361
23389
  }
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) {
23390
+ }
23391
+ if (!lookup) {
23392
+ return value;
23393
+ }
23394
+ const isCreation = lookup[info.fieldName] === "create";
23395
+ switch (lookup.resolveType) {
23396
+ case "nodeDocument":
23397
+ assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23398
+ return resolver2.getDocument(args.id);
23399
+ case "multiCollectionDocument":
23400
+ if (typeof value === "string") {
23401
+ return resolver2.getDocument(value);
23402
+ }
23403
+ if (args && args.collection && info.fieldName === "addPendingDocument") {
23404
+ return resolver2.resolveDocument({
23405
+ args: __spreadProps(__spreadValues({}, args), { params: {} }),
23406
+ collection: args.collection,
23407
+ isMutation,
23408
+ isCreation: true,
23409
+ isAddPendingDocument: true
23410
+ });
23411
+ }
23412
+ if ([
23413
+ NAMER.documentQueryName(),
23414
+ "createDocument",
23415
+ "updateDocument",
23416
+ "deleteDocument"
23417
+ ].includes(info.fieldName)) {
23383
23418
  const result2 = await resolver2.resolveDocument({
23384
23419
  args,
23385
- collection: lookup.collection,
23420
+ collection: args.collection,
23386
23421
  isMutation,
23387
23422
  isCreation,
23423
+ isDeletion: info.fieldName === "deleteDocument",
23388
23424
  isAddPendingDocument: false,
23389
- isCollectionSpecific: true
23425
+ isCollectionSpecific: false
23390
23426
  });
23391
23427
  return result2;
23392
23428
  }
23393
- }
23394
- return value;
23395
- default:
23396
- console.error(lookup);
23397
- throw new Error(`Unexpected resolve type`);
23429
+ return value;
23430
+ case "multiCollectionDocumentList":
23431
+ if (Array.isArray(value)) {
23432
+ return {
23433
+ totalCount: value.length,
23434
+ edges: value.map((document3) => {
23435
+ return { node: document3 };
23436
+ })
23437
+ };
23438
+ } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23439
+ return resolver2.resolveCollectionConnection({
23440
+ args,
23441
+ collection: value.collection
23442
+ });
23443
+ } else {
23444
+ throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23445
+ }
23446
+ case "collectionDocument":
23447
+ if (value) {
23448
+ return value;
23449
+ }
23450
+ const result = value || await resolver2.resolveDocument({
23451
+ args,
23452
+ collection: lookup.collection,
23453
+ isMutation,
23454
+ isCreation,
23455
+ isAddPendingDocument: false,
23456
+ isCollectionSpecific: true
23457
+ });
23458
+ return result;
23459
+ case "collectionDocumentList":
23460
+ return resolver2.resolveCollectionConnection({
23461
+ args,
23462
+ collection: tinaSchema.getCollection(lookup.collection)
23463
+ });
23464
+ case "unionData":
23465
+ if (!value) {
23466
+ if (args.relativePath) {
23467
+ const result2 = await resolver2.resolveDocument({
23468
+ args,
23469
+ collection: lookup.collection,
23470
+ isMutation,
23471
+ isCreation,
23472
+ isAddPendingDocument: false,
23473
+ isCollectionSpecific: true
23474
+ });
23475
+ return result2;
23476
+ }
23477
+ }
23478
+ return value;
23479
+ default:
23480
+ console.error(lookup);
23481
+ throw new Error(`Unexpected resolve type`);
23482
+ }
23483
+ } catch (e) {
23484
+ handleFetchErrorError(e, verboseValue);
23398
23485
  }
23399
23486
  }
23400
23487
  });
23401
23488
  if (res.errors) {
23402
23489
  if (!silenceErrors) {
23403
- console.error(res.errors);
23490
+ res.errors.map((e) => {
23491
+ console.error(e.toString());
23492
+ if (verboseValue) {
23493
+ console.error("More error context below");
23494
+ console.error(e.message);
23495
+ console.error(e);
23496
+ }
23497
+ });
23404
23498
  }
23405
23499
  }
23406
23500
  return res;
@@ -23553,25 +23647,34 @@ var Database = class {
23553
23647
  });
23554
23648
  };
23555
23649
  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);
23650
+ try {
23651
+ if (SYSTEM_FILES.includes(filepath)) {
23652
+ throw new Error(`Unexpected put for config file ${filepath}`);
23653
+ } else {
23654
+ let collectionIndexDefinitions;
23655
+ if (collection) {
23656
+ const indexDefinitions = await this.getIndexDefinitions();
23657
+ collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23658
+ }
23659
+ const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23660
+ if (this.store.supportsSeeding()) {
23661
+ await this.bridge.put(normalizePath(filepath), stringifiedFile);
23662
+ }
23663
+ await this.store.put(normalizePath(filepath), payload, {
23664
+ keepTemplateKey,
23665
+ collection,
23666
+ indexDefinitions: collectionIndexDefinitions
23667
+ });
23567
23668
  }
23568
- await this.store.put(normalizePath(filepath), payload, {
23569
- keepTemplateKey,
23669
+ return true;
23670
+ } catch (error) {
23671
+ throw new TinaFetchError(`Error in PUT for ${filepath}`, {
23672
+ originalError: error,
23673
+ file: filepath,
23570
23674
  collection,
23571
- indexDefinitions: collectionIndexDefinitions
23675
+ stack: error.stack
23572
23676
  });
23573
23677
  }
23574
- return true;
23575
23678
  };
23576
23679
  this.stringifyFile = async (filepath, data) => {
23577
23680
  if (SYSTEM_FILES.includes(filepath)) {
@@ -23747,11 +23850,24 @@ var Database = class {
23747
23850
  } = await this.store.query(storeQueryOptions);
23748
23851
  return {
23749
23852
  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
- };
23853
+ try {
23854
+ const node = await hydrator(edge.path);
23855
+ return {
23856
+ node,
23857
+ cursor: (0, import_datalayer2.btoa)(edge.cursor)
23858
+ };
23859
+ } catch (error) {
23860
+ if (error instanceof Error) {
23861
+ throw new TinaQueryError({
23862
+ originalError: error,
23863
+ file: edge.path,
23864
+ collection,
23865
+ stack: error.stack
23866
+ });
23867
+ } else {
23868
+ throw error;
23869
+ }
23870
+ }
23755
23871
  }),
23756
23872
  pageInfo: {
23757
23873
  hasPreviousPage,
@@ -23898,10 +24014,19 @@ var _indexContent = async (database, documentPaths, collection) => {
23898
24014
  };
23899
24015
  }
23900
24016
  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);
24017
+ try {
24018
+ const dataString = await database.bridge.get(normalizePath(filepath));
24019
+ const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
24020
+ if (database.store.supportsSeeding()) {
24021
+ await database.store.seed(normalizePath(filepath), data, seedOptions);
24022
+ }
24023
+ } catch (error) {
24024
+ throw new TinaFetchError(`Unable to seed ${filepath}`, {
24025
+ originalError: error,
24026
+ file: filepath,
24027
+ collection: collection.name,
24028
+ stack: error.stack
24029
+ });
23905
24030
  }
23906
24031
  });
23907
24032
  };
@@ -23934,9 +24059,14 @@ var buildSchema = async (rootPath, database, flags) => {
23934
24059
  };
23935
24060
  // Annotate the CommonJS export names for ESM import in node:
23936
24061
  0 && (module.exports = {
24062
+ TinaFetchError,
24063
+ TinaGraphQLError,
24064
+ TinaParseDocumentError,
24065
+ TinaQueryError,
23937
24066
  assertShape,
23938
24067
  buildSchema,
23939
24068
  createDatabase,
24069
+ handleFetchErrorError,
23940
24070
  indexDB,
23941
24071
  parseFile,
23942
24072
  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.60.7",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -98,8 +98,8 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@tinacms/datalayer": "0.1.1",
101
- "@tinacms/schema-tools": "0.0.4",
102
- "@tinacms/scripts": "0.50.7",
101
+ "@tinacms/schema-tools": "0.0.5",
102
+ "@tinacms/scripts": "0.50.8",
103
103
  "@types/cors": "^2.8.7",
104
104
  "@types/estree": "^0.0.50",
105
105
  "@types/express": "^4.17.8",