@tinacms/graphql 0.60.4 → 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/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,
@@ -10954,8 +10959,208 @@ var astBuilder = {
10954
10959
  },
10955
10960
  ListQueryOperationDefinition: ({
10956
10961
  queryName,
10957
- fragName
10962
+ fragName,
10963
+ filterType,
10964
+ dataLayer
10958
10965
  }) => {
10966
+ const variableDefinitions = [
10967
+ {
10968
+ kind: "VariableDefinition",
10969
+ variable: {
10970
+ kind: "Variable",
10971
+ name: {
10972
+ kind: "Name",
10973
+ value: "before"
10974
+ }
10975
+ },
10976
+ type: {
10977
+ kind: "NamedType",
10978
+ name: {
10979
+ kind: "Name",
10980
+ value: "String"
10981
+ }
10982
+ },
10983
+ directives: []
10984
+ },
10985
+ {
10986
+ kind: "VariableDefinition",
10987
+ variable: {
10988
+ kind: "Variable",
10989
+ name: {
10990
+ kind: "Name",
10991
+ value: "after"
10992
+ }
10993
+ },
10994
+ type: {
10995
+ kind: "NamedType",
10996
+ name: {
10997
+ kind: "Name",
10998
+ value: "String"
10999
+ }
11000
+ },
11001
+ directives: []
11002
+ },
11003
+ {
11004
+ kind: "VariableDefinition",
11005
+ variable: {
11006
+ kind: "Variable",
11007
+ name: {
11008
+ kind: "Name",
11009
+ value: "first"
11010
+ }
11011
+ },
11012
+ type: {
11013
+ kind: "NamedType",
11014
+ name: {
11015
+ kind: "Name",
11016
+ value: "Float"
11017
+ }
11018
+ },
11019
+ directives: []
11020
+ },
11021
+ {
11022
+ kind: "VariableDefinition",
11023
+ variable: {
11024
+ kind: "Variable",
11025
+ name: {
11026
+ kind: "Name",
11027
+ value: "last"
11028
+ }
11029
+ },
11030
+ type: {
11031
+ kind: "NamedType",
11032
+ name: {
11033
+ kind: "Name",
11034
+ value: "Float"
11035
+ }
11036
+ },
11037
+ directives: []
11038
+ },
11039
+ {
11040
+ kind: "VariableDefinition",
11041
+ variable: {
11042
+ kind: "Variable",
11043
+ name: {
11044
+ kind: "Name",
11045
+ value: "sort"
11046
+ }
11047
+ },
11048
+ type: {
11049
+ kind: "NamedType",
11050
+ name: {
11051
+ kind: "Name",
11052
+ value: "String"
11053
+ }
11054
+ },
11055
+ directives: []
11056
+ }
11057
+ ];
11058
+ const queryArguments = [
11059
+ {
11060
+ kind: "Argument",
11061
+ name: {
11062
+ kind: "Name",
11063
+ value: "before"
11064
+ },
11065
+ value: {
11066
+ kind: "Variable",
11067
+ name: {
11068
+ kind: "Name",
11069
+ value: "before"
11070
+ }
11071
+ }
11072
+ },
11073
+ {
11074
+ kind: "Argument",
11075
+ name: {
11076
+ kind: "Name",
11077
+ value: "after"
11078
+ },
11079
+ value: {
11080
+ kind: "Variable",
11081
+ name: {
11082
+ kind: "Name",
11083
+ value: "after"
11084
+ }
11085
+ }
11086
+ },
11087
+ {
11088
+ kind: "Argument",
11089
+ name: {
11090
+ kind: "Name",
11091
+ value: "first"
11092
+ },
11093
+ value: {
11094
+ kind: "Variable",
11095
+ name: {
11096
+ kind: "Name",
11097
+ value: "first"
11098
+ }
11099
+ }
11100
+ },
11101
+ {
11102
+ kind: "Argument",
11103
+ name: {
11104
+ kind: "Name",
11105
+ value: "last"
11106
+ },
11107
+ value: {
11108
+ kind: "Variable",
11109
+ name: {
11110
+ kind: "Name",
11111
+ value: "last"
11112
+ }
11113
+ }
11114
+ },
11115
+ {
11116
+ kind: "Argument",
11117
+ name: {
11118
+ kind: "Name",
11119
+ value: "sort"
11120
+ },
11121
+ value: {
11122
+ kind: "Variable",
11123
+ name: {
11124
+ kind: "Name",
11125
+ value: "sort"
11126
+ }
11127
+ }
11128
+ }
11129
+ ];
11130
+ if (dataLayer) {
11131
+ queryArguments.push({
11132
+ kind: "Argument",
11133
+ name: {
11134
+ kind: "Name",
11135
+ value: "filter"
11136
+ },
11137
+ value: {
11138
+ kind: "Variable",
11139
+ name: {
11140
+ kind: "Name",
11141
+ value: "filter"
11142
+ }
11143
+ }
11144
+ });
11145
+ variableDefinitions.push({
11146
+ kind: "VariableDefinition",
11147
+ variable: {
11148
+ kind: "Variable",
11149
+ name: {
11150
+ kind: "Name",
11151
+ value: "filter"
11152
+ }
11153
+ },
11154
+ type: {
11155
+ kind: "NamedType",
11156
+ name: {
11157
+ kind: "Name",
11158
+ value: filterType
11159
+ }
11160
+ },
11161
+ directives: []
11162
+ });
11163
+ }
10959
11164
  return {
10960
11165
  kind: "OperationDefinition",
10961
11166
  operation: "query",
@@ -10963,7 +11168,7 @@ var astBuilder = {
10963
11168
  kind: "Name",
10964
11169
  value: queryName
10965
11170
  },
10966
- variableDefinitions: [],
11171
+ variableDefinitions,
10967
11172
  directives: [],
10968
11173
  selectionSet: {
10969
11174
  kind: "SelectionSet",
@@ -10974,7 +11179,7 @@ var astBuilder = {
10974
11179
  kind: "Name",
10975
11180
  value: queryName
10976
11181
  },
10977
- arguments: [],
11182
+ arguments: queryArguments,
10978
11183
  directives: [],
10979
11184
  selectionSet: {
10980
11185
  kind: "SelectionSet",
@@ -12375,6 +12580,7 @@ var filterSelections = (arr) => {
12375
12580
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/validate.ts
12376
12581
  var import_lodash2 = __toModule(require("lodash"));
12377
12582
  var yup2 = __toModule(require("yup"));
12583
+ var import_schema_tools = __toModule(require("@tinacms/schema-tools"));
12378
12584
  var FIELD_TYPES = [
12379
12585
  "string",
12380
12586
  "number",
@@ -12389,6 +12595,13 @@ var validateSchema = async (schema) => {
12389
12595
  const schema2 = addNamespaceToSchema(import_lodash2.default.cloneDeep(schema));
12390
12596
  const collections = await sequential(schema2.collections, async (collection) => validateCollection(collection));
12391
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
+ }
12392
12605
  return {
12393
12606
  collections
12394
12607
  };
@@ -12480,7 +12693,7 @@ var validateField = async (field) => {
12480
12693
 
12481
12694
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
12482
12695
  var name = "@tinacms/graphql";
12483
- var version = "0.60.4";
12696
+ var version = "0.60.7";
12484
12697
  var main = "dist/index.js";
12485
12698
  var typings = "dist/index.d.ts";
12486
12699
  var files = [
@@ -12622,15 +12835,52 @@ var package_default = {
12622
12835
  };
12623
12836
 
12624
12837
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
12625
- var TinaError = class extends Error {
12838
+ var TinaGraphQLError = class extends Error {
12626
12839
  constructor(message, extensions) {
12627
12840
  super(message);
12628
12841
  if (!this.name) {
12629
- Object.defineProperty(this, "name", { value: "TinaError" });
12842
+ Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
12630
12843
  }
12631
12844
  this.extensions = __spreadValues({}, extensions);
12632
12845
  }
12633
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
+ };
12634
12884
 
12635
12885
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
12636
12886
  var createSchema = async ({
@@ -12743,7 +12993,7 @@ var TinaSchema = class {
12743
12993
  assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
12744
12994
  const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
12745
12995
  if (!template) {
12746
- 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)}'`, {
12747
12997
  collection: lastItem(collection.namespace),
12748
12998
  possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
12749
12999
  data
@@ -12850,13 +13100,17 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
12850
13100
  const operationsDefinitions = [];
12851
13101
  const collections = tinaSchema.getCollections();
12852
13102
  await sequential(collections, async (collection) => {
13103
+ var _a, _b, _c;
12853
13104
  const queryName = NAMER.queryName(collection.namespace);
12854
13105
  const queryListName = NAMER.generateQueryListName(collection.namespace);
13106
+ const queryFilterTypeName = NAMER.dataFilterTypeName(collection.namespace);
12855
13107
  const fragName = NAMER.fragmentName(collection.namespace);
12856
13108
  operationsDefinitions.push(astBuilder.QueryOperationDefinition({ fragName, queryName }));
12857
13109
  operationsDefinitions.push(astBuilder.ListQueryOperationDefinition({
12858
13110
  fragName,
12859
- queryName: queryListName
13111
+ queryName: queryListName,
13112
+ filterType: queryFilterTypeName,
13113
+ dataLayer: Boolean((_c = (_b = (_a = tinaSchema.config) == null ? void 0 : _a.meta) == null ? void 0 : _b.flags) == null ? void 0 : _c.find((x) => x === "experimentalData"))
12860
13114
  }));
12861
13115
  });
12862
13116
  const queryDoc = {
@@ -20222,11 +20476,62 @@ var visit = function(tree, test, visitor, reverse) {
20222
20476
 
20223
20477
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20224
20478
  var import_lodash4 = __toModule(require("lodash"));
20225
- var parseMDX = (value, field) => {
20479
+
20480
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
20481
+ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
20482
+ if (config && value) {
20483
+ if (config.useRelativeMedia === true) {
20484
+ return value;
20485
+ }
20486
+ if (hasTinaMediaConfig(schema) === true) {
20487
+ const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
20488
+ if (typeof value === "string" && value.includes(assetsURL)) {
20489
+ const cleanSyncFolder = cleanUpSlashes(schema.config.media.tina.syncFolder);
20490
+ const strippedURL = value.replace(assetsURL, "");
20491
+ return `${cleanSyncFolder}${strippedURL}`;
20492
+ }
20493
+ return value;
20494
+ }
20495
+ return value;
20496
+ } else {
20497
+ return value;
20498
+ }
20499
+ };
20500
+ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
20501
+ if (config && value) {
20502
+ if (config.useRelativeMedia === true) {
20503
+ return value;
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;
20511
+ } else {
20512
+ return value;
20513
+ }
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
+ };
20528
+
20529
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20530
+ var parseMDX = (value, field, graphQLconfig, schema) => {
20226
20531
  const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
20227
- return parseMDXInner(tree, field);
20532
+ return parseMDXInner(tree, field, graphQLconfig, schema);
20228
20533
  };
20229
- var parseMDXInner = (tree, field) => {
20534
+ var parseMDXInner = (tree, field, graphQLconfig, schema) => {
20230
20535
  visit(tree, (node) => {
20231
20536
  delete node.position;
20232
20537
  });
@@ -20234,7 +20539,7 @@ var parseMDXInner = (tree, field) => {
20234
20539
  var _a;
20235
20540
  let props = {};
20236
20541
  if (!node.name) {
20237
- props = parseMDXInner({ type: "root", children: node.children }, field);
20542
+ props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig, schema);
20238
20543
  }
20239
20544
  const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
20240
20545
  const templateName = typeof template2 === "string" ? template2 : template2.name;
@@ -20265,7 +20570,7 @@ var parseMDXInner = (tree, field) => {
20265
20570
  if (!field2) {
20266
20571
  throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
20267
20572
  }
20268
- parseField(attribute, field2, props);
20573
+ parseField(attribute, field2, props, graphQLconfig, schema);
20269
20574
  }
20270
20575
  } else {
20271
20576
  console.log(`Not sure what this is, type: ${attribute.type}`);
@@ -20274,15 +20579,19 @@ var parseMDXInner = (tree, field) => {
20274
20579
  delete node.attributes;
20275
20580
  node.props = props;
20276
20581
  });
20277
- const slateTree = tree.children.map(remarkToSlate);
20582
+ const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig, schema));
20278
20583
  return { type: "root", children: slateTree };
20279
20584
  };
20280
- var parseField = (attribute, field, props) => {
20585
+ var parseField = (attribute, field, props, graphQLconfig, schema) => {
20281
20586
  var _a, _b;
20282
20587
  switch (field.type) {
20283
20588
  case "boolean":
20284
20589
  case "datetime":
20590
+ props[field.name] = attribute.value;
20591
+ break;
20285
20592
  case "image":
20593
+ props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig, schema);
20594
+ break;
20286
20595
  case "number":
20287
20596
  case "string":
20288
20597
  if (field.list) {
@@ -20344,7 +20653,7 @@ var parseField = (attribute, field, props) => {
20344
20653
  throw new Error(`Global fields not supported at this time`);
20345
20654
  }
20346
20655
  field.fields.forEach((field2) => {
20347
- parseField(property, field2, objectProps);
20656
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20348
20657
  });
20349
20658
  }
20350
20659
  });
@@ -20366,7 +20675,7 @@ var parseField = (attribute, field, props) => {
20366
20675
  throw new Error(`Global fields not supported at this time`);
20367
20676
  }
20368
20677
  field.fields.forEach((field2) => {
20369
- parseField(property, field2, objectProps);
20678
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20370
20679
  });
20371
20680
  }
20372
20681
  if (field.templates) {
@@ -20375,7 +20684,7 @@ var parseField = (attribute, field, props) => {
20375
20684
  throw new Error(`Global fields not supported at this time`);
20376
20685
  }
20377
20686
  fieldTemplate.fields.forEach((field2) => {
20378
- parseField(property, field2, objectProps);
20687
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20379
20688
  });
20380
20689
  });
20381
20690
  }
@@ -20398,13 +20707,13 @@ var parseField = (attribute, field, props) => {
20398
20707
  if (attribute.value) {
20399
20708
  if (field.name === "children") {
20400
20709
  if (Array.isArray(attribute.value)) {
20401
- props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field);
20710
+ props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig, schema);
20402
20711
  } else {
20403
20712
  throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
20404
20713
  }
20405
20714
  } else {
20406
20715
  try {
20407
- const mdx2 = parseMDX(attribute.value.value, field);
20716
+ const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig, schema);
20408
20717
  props[field.name] = mdx2.children[0].props;
20409
20718
  } catch (e) {
20410
20719
  console.log(e);
@@ -20475,7 +20784,7 @@ var defaultNodeTypes = {
20475
20784
  break: "break",
20476
20785
  image: plateElements.ELEMENT_IMAGE
20477
20786
  };
20478
- function remarkToSlate(node) {
20787
+ function remarkToSlate(node, graphQLconfig, schema) {
20479
20788
  const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
20480
20789
  heading: __spreadValues({}, defaultNodeTypes.heading)
20481
20790
  });
@@ -20483,12 +20792,12 @@ function remarkToSlate(node) {
20483
20792
  case "heading":
20484
20793
  return {
20485
20794
  type: types.heading[node.depth],
20486
- children: node.children.map(remarkToSlate)
20795
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20487
20796
  };
20488
20797
  case "list":
20489
20798
  return {
20490
20799
  type: node.ordered ? types.ol_list : types.ul_list,
20491
- children: node.children.map(remarkToSlate)
20800
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20492
20801
  };
20493
20802
  case "listItem":
20494
20803
  const realChildren = [];
@@ -20496,12 +20805,12 @@ function remarkToSlate(node) {
20496
20805
  if (child.type === "list") {
20497
20806
  realChildren.push({
20498
20807
  type: child.ordered ? types.ol_list : types.ul_list,
20499
- children: child.children.map(remarkToSlate)
20808
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20500
20809
  });
20501
20810
  } else {
20502
20811
  realChildren.push({
20503
20812
  type: plateElements.ELEMENT_LIC,
20504
- children: child.children.map(remarkToSlate)
20813
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20505
20814
  });
20506
20815
  }
20507
20816
  });
@@ -20512,25 +20821,26 @@ function remarkToSlate(node) {
20512
20821
  case "paragraph":
20513
20822
  return {
20514
20823
  type: types.paragraph,
20515
- children: node.children.map(remarkToSlate)
20824
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20516
20825
  };
20517
20826
  case "link":
20518
20827
  return {
20519
20828
  type: types.link,
20520
20829
  url: node.url,
20521
- children: node.children.map(remarkToSlate)
20830
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20522
20831
  };
20523
20832
  case "image":
20833
+ const url = resolveMediaRelativeToCloud(node.url, graphQLconfig, schema);
20524
20834
  return {
20525
20835
  type: types.image,
20526
- url: node.url,
20836
+ url,
20527
20837
  alt: node.alt,
20528
20838
  caption: node.title
20529
20839
  };
20530
20840
  case "blockquote":
20531
20841
  return {
20532
20842
  type: types.block_quote,
20533
- children: node.children.map(remarkToSlate)
20843
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20534
20844
  };
20535
20845
  case "code":
20536
20846
  return {
@@ -21991,10 +22301,10 @@ var mdxToMarkdown = {
21991
22301
  };
21992
22302
 
21993
22303
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
21994
- var stringifyMDX = (value, field) => {
22304
+ var stringifyMDX = (value, field, graphQLconfig, schema) => {
21995
22305
  const slateTree = value.children;
21996
22306
  try {
21997
- const tree = stringifyChildren(slateTree, field);
22307
+ const tree = stringifyChildren(slateTree, field, graphQLconfig, schema);
21998
22308
  const out = toMarkdown({
21999
22309
  type: "root",
22000
22310
  children: tree
@@ -22012,13 +22322,13 @@ var allChildrenEmpty = (children) => {
22012
22322
  }
22013
22323
  return false;
22014
22324
  };
22015
- var stringifyChildren = (children, field) => {
22325
+ var stringifyChildren = (children, field, graphQLconfig, schema) => {
22016
22326
  if (!children) {
22017
22327
  return [];
22018
22328
  }
22019
- return children.map((child) => stringify(child, field)).filter(Boolean);
22329
+ return children.map((child) => stringify(child, field, graphQLconfig, schema)).filter(Boolean);
22020
22330
  };
22021
- var stringify = (node, field) => {
22331
+ var stringify = (node, field, graphQLconfig, schema) => {
22022
22332
  var _a;
22023
22333
  if (!node.type) {
22024
22334
  if (node == null ? void 0 : node.code) {
@@ -22044,40 +22354,40 @@ var stringify = (node, field) => {
22044
22354
  return {
22045
22355
  type: "heading",
22046
22356
  depth: 1,
22047
- children: stringifyChildren(node.children, field)
22357
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22048
22358
  };
22049
22359
  case plateElements.ELEMENT_H2:
22050
22360
  return {
22051
22361
  type: "heading",
22052
22362
  depth: 2,
22053
- children: stringifyChildren(node.children, field)
22363
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22054
22364
  };
22055
22365
  case plateElements.ELEMENT_H3:
22056
22366
  return {
22057
22367
  type: "heading",
22058
22368
  depth: 3,
22059
- children: stringifyChildren(node.children, field)
22369
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22060
22370
  };
22061
22371
  case plateElements.ELEMENT_H4:
22062
22372
  return {
22063
22373
  type: "heading",
22064
22374
  depth: 4,
22065
- children: stringifyChildren(node.children, field)
22375
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22066
22376
  };
22067
22377
  case plateElements.ELEMENT_H5:
22068
22378
  return {
22069
22379
  type: "heading",
22070
22380
  depth: 5,
22071
- children: stringifyChildren(node.children, field)
22381
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22072
22382
  };
22073
22383
  case plateElements.ELEMENT_H6:
22074
22384
  return {
22075
22385
  type: "heading",
22076
22386
  depth: 6,
22077
- children: stringifyChildren(node.children, field)
22387
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22078
22388
  };
22079
22389
  case plateElements.ELEMENT_PARAGRAPH:
22080
- const children = stringifyChildren(node.children, field);
22390
+ const children = stringifyChildren(node.children, field, graphQLconfig, schema);
22081
22391
  if (allChildrenEmpty(children)) {
22082
22392
  return false;
22083
22393
  }
@@ -22097,7 +22407,7 @@ var stringify = (node, field) => {
22097
22407
  ordered: false,
22098
22408
  spread: false,
22099
22409
  check: null,
22100
- children: stringifyChildren(node.children, field)
22410
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22101
22411
  };
22102
22412
  case plateElements.ELEMENT_OL:
22103
22413
  return {
@@ -22105,7 +22415,7 @@ var stringify = (node, field) => {
22105
22415
  ordered: true,
22106
22416
  spread: false,
22107
22417
  check: null,
22108
- children: stringifyChildren(node.children, field)
22418
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22109
22419
  };
22110
22420
  case plateElements.ELEMENT_LI:
22111
22421
  const realChildren = [];
@@ -22128,21 +22438,22 @@ var stringify = (node, field) => {
22128
22438
  spread: false,
22129
22439
  check: null,
22130
22440
  children: [
22131
- ...stringifyChildren([p], field),
22132
- ...stringifyChildren(extraChildren, field)
22441
+ ...stringifyChildren([p], field, graphQLconfig, schema),
22442
+ ...stringifyChildren(extraChildren, field, graphQLconfig, schema)
22133
22443
  ]
22134
22444
  };
22135
22445
  case plateElements.ELEMENT_LIC:
22136
22446
  return {
22137
22447
  type: "paragraph",
22138
- children: stringifyChildren(node.children, field)
22448
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22139
22449
  };
22140
22450
  case plateElements.ELEMENT_IMAGE:
22451
+ const url = resolveMediaCloudToRelative(node.url, graphQLconfig, schema);
22141
22452
  return {
22142
22453
  type: "image",
22143
22454
  title: node.caption,
22144
22455
  alt: node.alt,
22145
- url: node.url
22456
+ url
22146
22457
  };
22147
22458
  case plateElements.ELEMENT_HR:
22148
22459
  return {
@@ -22153,12 +22464,12 @@ var stringify = (node, field) => {
22153
22464
  type: "link",
22154
22465
  url: node.url,
22155
22466
  title: node.title,
22156
- children: stringifyChildren(node.children, field)
22467
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22157
22468
  };
22158
22469
  case plateElements.ELEMENT_BLOCKQUOTE:
22159
22470
  return {
22160
22471
  type: "blockquote",
22161
- children: stringifyChildren(node.children, field)
22472
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22162
22473
  };
22163
22474
  case "mdxJsxTextElement":
22164
22475
  case "mdxJsxFlowElement":
@@ -22323,7 +22634,7 @@ var stringify = (node, field) => {
22323
22634
  }
22324
22635
  break;
22325
22636
  case "rich-text":
22326
- const tree = stringifyChildren(value.children, field2);
22637
+ const tree = stringifyChildren(value.children, field2, graphQLconfig, schema);
22327
22638
  if (field2.name === "children") {
22328
22639
  children2 = tree;
22329
22640
  } else {
@@ -22526,7 +22837,18 @@ var Resolver = class {
22526
22837
  _collection: rawData._collection,
22527
22838
  _template: rawData._template
22528
22839
  };
22529
- 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
+ }
22530
22852
  const titleField = template.fields.find((x) => {
22531
22853
  if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
22532
22854
  return true;
@@ -22552,8 +22874,8 @@ var Resolver = class {
22552
22874
  _values: data
22553
22875
  });
22554
22876
  } catch (e) {
22555
- if (e instanceof TinaError) {
22556
- throw new TinaError(e.message, __spreadValues({
22877
+ if (e instanceof TinaGraphQLError) {
22878
+ throw new TinaGraphQLError(e.message, __spreadValues({
22557
22879
  requestedDocument: fullPath
22558
22880
  }, e.extensions));
22559
22881
  }
@@ -22751,10 +23073,6 @@ var Resolver = class {
22751
23073
  })
22752
23074
  };
22753
23075
  };
22754
- this.getDocumentsForCollection = async (collectionName) => {
22755
- const collection = this.tinaSchema.getCollection(collectionName);
22756
- return this.database.store.glob(collection.path, this.getDocument);
22757
- };
22758
23076
  this.referenceResolver = async (filter, fieldDefinition) => {
22759
23077
  const referencedCollection = this.tinaSchema.getCollection(fieldDefinition.collections[0]);
22760
23078
  if (!referencedCollection) {
@@ -22779,9 +23097,11 @@ var Resolver = class {
22779
23097
  collection,
22780
23098
  hydrator
22781
23099
  }) => {
23100
+ var _a, _b, _c, _d;
22782
23101
  let edges;
22783
23102
  let pageInfo;
22784
- if (args.filter || args.sort) {
23103
+ const useDataLayer = Boolean((_d = (_c = (_b = (_a = this.tinaSchema) == null ? void 0 : _a.config) == null ? void 0 : _b.meta) == null ? void 0 : _c.flags) == null ? void 0 : _d.find((x) => x === "experimentalData"));
23104
+ if (useDataLayer) {
22785
23105
  let conditions;
22786
23106
  if (args.filter) {
22787
23107
  if (collection.fields) {
@@ -22846,15 +23166,16 @@ var Resolver = class {
22846
23166
  case "string":
22847
23167
  case "boolean":
22848
23168
  case "number":
22849
- case "image":
22850
23169
  accum[fieldName] = fieldValue;
22851
23170
  break;
23171
+ case "image":
23172
+ accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config, this.tinaSchema.schema);
23173
+ break;
22852
23174
  case "object":
22853
23175
  accum[fieldName] = this.buildObjectMutations(fieldValue, field);
22854
23176
  break;
22855
23177
  case "rich-text":
22856
- field;
22857
- accum[fieldName] = stringifyMDX(fieldValue, field);
23178
+ accum[fieldName] = stringifyMDX(fieldValue, field, this.config, this.tinaSchema.schema);
22858
23179
  break;
22859
23180
  case "reference":
22860
23181
  accum[fieldName] = fieldValue;
@@ -22887,18 +23208,10 @@ var Resolver = class {
22887
23208
  accumulator[field.name] = value;
22888
23209
  break;
22889
23210
  case "image":
22890
- if (this.config) {
22891
- if (this.config.useRelativeMedia === true) {
22892
- accumulator[field.name] = value;
22893
- } else {
22894
- accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
22895
- }
22896
- } else {
22897
- accumulator[field.name] = value;
22898
- }
23211
+ accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config, this.tinaSchema.schema);
22899
23212
  break;
22900
23213
  case "rich-text":
22901
- const tree = parseMDX(value, field);
23214
+ const tree = parseMDX(value, field, this.config, this.tinaSchema.schema);
22902
23215
  accumulator[field.name] = tree;
22903
23216
  break;
22904
23217
  case "object":
@@ -23003,14 +23316,18 @@ var resolve = async ({
23003
23316
  query,
23004
23317
  variables,
23005
23318
  database,
23006
- silenceErrors
23319
+ silenceErrors,
23320
+ verbose
23007
23321
  }) => {
23322
+ var _a;
23008
23323
  try {
23324
+ const verboseValue = verbose != null ? verbose : true;
23009
23325
  const graphQLSchemaAst = await database.getGraphQLSchema();
23010
23326
  const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
23011
23327
  const tinaConfig = await database.getTinaSchema();
23012
23328
  const tinaSchema = await createSchema({
23013
- schema: tinaConfig
23329
+ schema: tinaConfig,
23330
+ flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
23014
23331
  });
23015
23332
  const resolver2 = await createResolver2({ config, database, tinaSchema });
23016
23333
  const res = await (0, import_graphql3.graphql)({
@@ -23032,141 +23349,152 @@ var resolve = async ({
23032
23349
  }
23033
23350
  },
23034
23351
  fieldResolver: async (source = {}, _args = {}, _context, info) => {
23035
- const args = JSON.parse(JSON.stringify(_args));
23036
- const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23037
- const lookup = await database.getLookup(returnType);
23038
- const isMutation = info.parentType.toString() === "Mutation";
23039
- const value = source[info.fieldName];
23040
- if (returnType === "Collection") {
23041
- if (value) {
23042
- return value;
23043
- }
23044
- if (info.fieldName === "collections") {
23045
- const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23046
- const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23047
- var _a;
23048
- return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
23049
- });
23050
- return tinaSchema.getCollections().map((collection) => {
23051
- return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23052
- });
23053
- }
23054
- const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23055
- const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23056
- var _a;
23057
- return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
23058
- });
23059
- return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23060
- }
23061
- if (info.fieldName === "getOptimizedQuery") {
23062
- try {
23063
- const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23064
- assumeValid: true,
23065
- includeFragments: false,
23066
- noLocation: true
23067
- });
23068
- return (0, import_graphql3.print)(optimizedQuery);
23069
- } catch (e) {
23070
- throw new Error(`Invalid query provided, Error message: ${e.message}`);
23071
- }
23072
- }
23073
- if (!lookup) {
23074
- return value;
23075
- }
23076
- const isCreation = lookup[info.fieldName] === "create";
23077
- switch (lookup.resolveType) {
23078
- case "nodeDocument":
23079
- assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23080
- return resolver2.getDocument(args.id);
23081
- case "multiCollectionDocument":
23082
- if (typeof value === "string") {
23083
- 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;
23084
23361
  }
23085
- if (args && args.collection && info.fieldName === "addPendingDocument") {
23086
- return resolver2.resolveDocument({
23087
- args: __spreadProps(__spreadValues({}, args), { params: {} }),
23088
- collection: args.collection,
23089
- isMutation,
23090
- isCreation: true,
23091
- 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";
23092
23367
  });
23093
- }
23094
- if ([
23095
- NAMER.documentQueryName(),
23096
- "createDocument",
23097
- "updateDocument",
23098
- "deleteDocument"
23099
- ].includes(info.fieldName)) {
23100
- const result2 = await resolver2.resolveDocument({
23101
- args,
23102
- collection: args.collection,
23103
- isMutation,
23104
- isCreation,
23105
- isDeletion: info.fieldName === "deleteDocument",
23106
- isAddPendingDocument: false,
23107
- isCollectionSpecific: false
23368
+ return tinaSchema.getCollections().map((collection) => {
23369
+ return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23108
23370
  });
23109
- return result2;
23110
23371
  }
23111
- return value;
23112
- case "multiCollectionDocumentList":
23113
- if (Array.isArray(value)) {
23114
- return {
23115
- totalCount: value.length,
23116
- edges: value.map((document3) => {
23117
- return { node: document3 };
23118
- })
23119
- };
23120
- } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23121
- return resolver2.resolveCollectionConnection({
23122
- args,
23123
- 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
23124
23385
  });
23125
- } else {
23126
- 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}`);
23127
23389
  }
23128
- case "collectionDocument":
23129
- if (value) {
23130
- return value;
23131
- }
23132
- const result = value || await resolver2.resolveDocument({
23133
- args,
23134
- collection: lookup.collection,
23135
- isMutation,
23136
- isCreation,
23137
- isAddPendingDocument: false,
23138
- isCollectionSpecific: true
23139
- });
23140
- return result;
23141
- case "collectionDocumentList":
23142
- return resolver2.resolveCollectionConnection({
23143
- args,
23144
- collection: tinaSchema.getCollection(lookup.collection)
23145
- });
23146
- case "unionData":
23147
- if (!value) {
23148
- 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)) {
23149
23418
  const result2 = await resolver2.resolveDocument({
23150
23419
  args,
23151
- collection: lookup.collection,
23420
+ collection: args.collection,
23152
23421
  isMutation,
23153
23422
  isCreation,
23423
+ isDeletion: info.fieldName === "deleteDocument",
23154
23424
  isAddPendingDocument: false,
23155
- isCollectionSpecific: true
23425
+ isCollectionSpecific: false
23156
23426
  });
23157
23427
  return result2;
23158
23428
  }
23159
- }
23160
- return value;
23161
- default:
23162
- console.error(lookup);
23163
- 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);
23164
23485
  }
23165
23486
  }
23166
23487
  });
23167
23488
  if (res.errors) {
23168
23489
  if (!silenceErrors) {
23169
- 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
+ });
23170
23498
  }
23171
23499
  }
23172
23500
  return res;
@@ -23319,25 +23647,34 @@ var Database = class {
23319
23647
  });
23320
23648
  };
23321
23649
  this.put = async (filepath, data, collection) => {
23322
- if (SYSTEM_FILES.includes(filepath)) {
23323
- throw new Error(`Unexpected put for config file ${filepath}`);
23324
- } else {
23325
- let collectionIndexDefinitions;
23326
- if (collection) {
23327
- const indexDefinitions = await this.getIndexDefinitions();
23328
- collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23329
- }
23330
- const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23331
- if (this.store.supportsSeeding()) {
23332
- 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
+ });
23333
23668
  }
23334
- await this.store.put(normalizePath(filepath), payload, {
23335
- keepTemplateKey,
23669
+ return true;
23670
+ } catch (error) {
23671
+ throw new TinaFetchError(`Error in PUT for ${filepath}`, {
23672
+ originalError: error,
23673
+ file: filepath,
23336
23674
  collection,
23337
- indexDefinitions: collectionIndexDefinitions
23675
+ stack: error.stack
23338
23676
  });
23339
23677
  }
23340
- return true;
23341
23678
  };
23342
23679
  this.stringifyFile = async (filepath, data) => {
23343
23680
  if (SYSTEM_FILES.includes(filepath)) {
@@ -23513,11 +23850,24 @@ var Database = class {
23513
23850
  } = await this.store.query(storeQueryOptions);
23514
23851
  return {
23515
23852
  edges: await sequential(edges, async (edge) => {
23516
- const node = await hydrator(edge.path);
23517
- return {
23518
- node,
23519
- cursor: (0, import_datalayer2.btoa)(edge.cursor)
23520
- };
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
+ }
23521
23871
  }),
23522
23872
  pageInfo: {
23523
23873
  hasPreviousPage,
@@ -23664,10 +24014,19 @@ var _indexContent = async (database, documentPaths, collection) => {
23664
24014
  };
23665
24015
  }
23666
24016
  await sequential(documentPaths, async (filepath) => {
23667
- const dataString = await database.bridge.get(normalizePath(filepath));
23668
- const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23669
- if (database.store.supportsSeeding()) {
23670
- 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
+ });
23671
24030
  }
23672
24031
  });
23673
24032
  };
@@ -23700,9 +24059,14 @@ var buildSchema = async (rootPath, database, flags) => {
23700
24059
  };
23701
24060
  // Annotate the CommonJS export names for ESM import in node:
23702
24061
  0 && (module.exports = {
24062
+ TinaFetchError,
24063
+ TinaGraphQLError,
24064
+ TinaParseDocumentError,
24065
+ TinaQueryError,
23703
24066
  assertShape,
23704
24067
  buildSchema,
23705
24068
  createDatabase,
24069
+ handleFetchErrorError,
23706
24070
  indexDB,
23707
24071
  parseFile,
23708
24072
  resolve,