@tinacms/graphql 0.0.0-202259143352 → 0.0.0-202261192534

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,10 +1,88 @@
1
1
  # tina-graphql
2
2
 
3
- ## 0.0.0-202259143352
3
+ ## 0.0.0-202261192534
4
+
5
+ ### Patch Changes
6
+
7
+ - b5b0dfd66: chore: migrate from fs.rmdir -> fs.rm
8
+ - Updated dependencies [ae23e9ad6]
9
+ - @tinacms/schema-tools@0.0.0-202261192534
10
+
11
+ ## 0.61.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 4daf15b36: Updated matching logic to only return the correct extension.
16
+
17
+ This means if you are using any other files besides `.md` the format must be provided in the schema.
18
+
19
+ ```ts
20
+ // .tina/schema.ts
21
+
22
+ import { defineSchema } from 'tinacms'
23
+
24
+ const schema = defineSchema({
25
+ collections: [
26
+ {
27
+ name: 'page',
28
+ path: 'content/page',
29
+ label: 'Page',
30
+ // Need to provide the format if the file being used (default is `.md`)
31
+ format: 'mdx',
32
+ fields: [
33
+ //...
34
+ ],
35
+ },
36
+ ],
37
+ })
38
+ //...
39
+
40
+ export default schema
41
+ ```
42
+
43
+ ### Patch Changes
44
+
45
+ - 2ef5a1f33: Use media config from the schema in the local media server
46
+ - 2ef5a1f33: Uses new `schema.config` when resolving media/asset urls
47
+ - b348f8b6b: Experimental isomorphic git bridge implementation
48
+ - fb73fb355: Renames syncFolder to a mediaRoot when configuring Repo-Based Media
49
+ - Updated dependencies [b348f8b6b]
50
+ - Updated dependencies [fb73fb355]
51
+ - Updated dependencies [4daf15b36]
52
+ - @tinacms/datalayer@0.2.0
53
+ - @tinacms/schema-tools@0.0.6
54
+
55
+ ## 0.60.8
56
+
57
+ ### Patch Changes
58
+
59
+ - 3325cd226: Make @tinacms/schema-tools a regular dependency of @tinacms/graphql
60
+
61
+ ## 0.60.7
62
+
63
+ ### Patch Changes
64
+
65
+ - f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
66
+ - b1a4290e6: Use media config from the schema in the local media server
67
+ - 1955b8842: Uses new `schema.config` when resolving media/asset urls
68
+ - 8b81c3cf3: Added more context to error messages to help to user debug issues
69
+ - @tinacms/datalayer@0.1.1
70
+
71
+ ## 0.60.6
4
72
 
5
73
  ### Patch Changes
6
74
 
7
75
  - e2aafcd93: Add more GraphQL variables to the generated queries.
76
+ - a20fed8b7: Resolve Cloud URLs to Relative URLs when saving TinaCloud's media
77
+
78
+ Introduces a pair of functions (inside `media-utils.ts`) for handling URLs provided by TinaCloud (`resolveMediaCloudToRelative` and `resolveMediaRelativeToCloud`).
79
+
80
+ These are used in conjuction with two pairs of functions:
81
+
82
+ - When providing data to the preview: `resolveFieldData` and `parseMDX`
83
+ - When saving data to the document: `buildFieldMutations` and `stringifyMDX`
84
+
85
+ I also introduced tests around `media-utils.ts` (`media-utils.test.ts`).
8
86
 
9
87
  ## 0.60.5
10
88
 
@@ -12,7 +12,7 @@ limitations under the License.
12
12
  */
13
13
  export interface Bridge {
14
14
  rootPath: string;
15
- glob(pattern: string): Promise<string[]>;
15
+ glob(pattern: string, extension: string): Promise<string[]>;
16
16
  get(filepath: string): Promise<string>;
17
17
  put(filepath: string, data: string): Promise<void>;
18
18
  delete(filepath: string): Promise<void>;
@@ -28,6 +28,7 @@ declare type CreateDatabase = {
28
28
  export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
29
29
  /** Options for {@link Database.query} **/
30
30
  export declare type QueryOptions = {
31
+ fileExtension?: string;
31
32
  collection: string;
32
33
  filterChain?: (BinaryFilter | TernaryFilter)[];
33
34
  sort?: string;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ limitations under the License.
12
12
  */
13
13
  export { indexDB } from './build';
14
14
  export { resolve } from './resolve';
15
+ export * from './resolver/error';
15
16
  export { createDatabase } from './database';
16
17
  export type { QueryOptions } from './database';
17
18
  import type { Database } from './database';
package/dist/index.js CHANGED
@@ -10384,9 +10384,14 @@ var require_remark_mdx = __commonJS({
10384
10384
 
10385
10385
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
10386
10386
  __export(exports, {
10387
+ TinaFetchError: () => TinaFetchError,
10388
+ TinaGraphQLError: () => TinaGraphQLError,
10389
+ TinaParseDocumentError: () => TinaParseDocumentError,
10390
+ TinaQueryError: () => TinaQueryError,
10387
10391
  assertShape: () => assertShape,
10388
10392
  buildSchema: () => buildSchema,
10389
10393
  createDatabase: () => createDatabase,
10394
+ handleFetchErrorError: () => handleFetchErrorError,
10390
10395
  indexDB: () => indexDB,
10391
10396
  parseFile: () => parseFile,
10392
10397
  resolve: () => resolve,
@@ -12575,6 +12580,7 @@ var filterSelections = (arr) => {
12575
12580
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/validate.ts
12576
12581
  var import_lodash2 = __toModule(require("lodash"));
12577
12582
  var yup2 = __toModule(require("yup"));
12583
+ var import_schema_tools = __toModule(require("@tinacms/schema-tools"));
12578
12584
  var FIELD_TYPES = [
12579
12585
  "string",
12580
12586
  "number",
@@ -12589,6 +12595,13 @@ var validateSchema = async (schema) => {
12589
12595
  const schema2 = addNamespaceToSchema(import_lodash2.default.cloneDeep(schema));
12590
12596
  const collections = await sequential(schema2.collections, async (collection) => validateCollection(collection));
12591
12597
  validationCollectionsPathAndMatch(collections);
12598
+ if (schema2.config) {
12599
+ const config = (0, import_schema_tools.validateTinaCloudSchemaConfig)(schema2.config);
12600
+ return {
12601
+ collections,
12602
+ config
12603
+ };
12604
+ }
12592
12605
  return {
12593
12606
  collections
12594
12607
  };
@@ -12680,7 +12693,7 @@ var validateField = async (field) => {
12680
12693
 
12681
12694
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
12682
12695
  var name = "@tinacms/graphql";
12683
- var version = "0.60.5";
12696
+ var version = "0.61.0";
12684
12697
  var main = "dist/index.js";
12685
12698
  var typings = "dist/index.d.ts";
12686
12699
  var files = [
@@ -12728,6 +12741,7 @@ var scripts = {
12728
12741
  var dependencies = {
12729
12742
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
12730
12743
  "@tinacms/datalayer": "workspace:*",
12744
+ "@tinacms/schema-tools": "workspace:*",
12731
12745
  "body-parser": "^1.19.0",
12732
12746
  cors: "^2.8.5",
12733
12747
  dataloader: "^2.0.0",
@@ -12802,9 +12816,6 @@ var devDependencies = {
12802
12816
  nodemon: "^2.0.4",
12803
12817
  typescript: "^4.3.5"
12804
12818
  };
12805
- var peerDependencies = {
12806
- "@tinacms/schema-tools": "*"
12807
- };
12808
12819
  var package_default = {
12809
12820
  name,
12810
12821
  version,
@@ -12817,20 +12828,56 @@ var package_default = {
12817
12828
  dependencies,
12818
12829
  publishConfig,
12819
12830
  repository,
12820
- devDependencies,
12821
- peerDependencies
12831
+ devDependencies
12822
12832
  };
12823
12833
 
12824
12834
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
12825
- var TinaError = class extends Error {
12835
+ var TinaGraphQLError = class extends Error {
12826
12836
  constructor(message, extensions) {
12827
12837
  super(message);
12828
12838
  if (!this.name) {
12829
- Object.defineProperty(this, "name", { value: "TinaError" });
12839
+ Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
12830
12840
  }
12831
12841
  this.extensions = __spreadValues({}, extensions);
12832
12842
  }
12833
12843
  };
12844
+ var TinaFetchError = class extends Error {
12845
+ constructor(message, args) {
12846
+ super(message);
12847
+ this.name = "TinaFetchError";
12848
+ this.collection = args.collection;
12849
+ this.stack = args.stack;
12850
+ this.file = args.file;
12851
+ this.originalError = args.originalError;
12852
+ }
12853
+ };
12854
+ var TinaQueryError = class extends TinaFetchError {
12855
+ constructor(args) {
12856
+ super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12857
+ }
12858
+ };
12859
+ var TinaParseDocumentError = class extends TinaFetchError {
12860
+ constructor(args) {
12861
+ super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
12862
+ }
12863
+ toString() {
12864
+ return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
12865
+ }
12866
+ };
12867
+ var handleFetchErrorError = (e, verbose) => {
12868
+ if (e instanceof Error) {
12869
+ if (e instanceof TinaFetchError) {
12870
+ if (verbose) {
12871
+ console.log(e.toString());
12872
+ console.log(e);
12873
+ console.log(e.stack);
12874
+ }
12875
+ }
12876
+ } else {
12877
+ console.error(e);
12878
+ }
12879
+ throw e;
12880
+ };
12834
12881
 
12835
12882
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
12836
12883
  var createSchema = async ({
@@ -12943,7 +12990,7 @@ var TinaSchema = class {
12943
12990
  assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
12944
12991
  const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
12945
12992
  if (!template) {
12946
- throw new TinaError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12993
+ throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
12947
12994
  collection: lastItem(collection.namespace),
12948
12995
  possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
12949
12996
  data
@@ -13044,7 +13091,7 @@ var _buildFragments = async (builder, tinaSchema, rootPath) => {
13044
13091
  definitions: import_lodash3.default.uniqBy(extractInlineTypes(fragmentDefinitionsFields), (node) => node.name.value)
13045
13092
  };
13046
13093
  const fragPath = import_path.default.join(rootPath, ".tina", "__generated__");
13047
- await import_fs_extra.default.outputFileSync(import_path.default.join(fragPath, "frags.gql"), (0, import_graphql2.print)(fragDoc));
13094
+ await import_fs_extra.default.outputFile(import_path.default.join(fragPath, "frags.gql"), (0, import_graphql2.print)(fragDoc));
13048
13095
  };
13049
13096
  var _buildQueries = async (builder, tinaSchema, rootPath) => {
13050
13097
  const operationsDefinitions = [];
@@ -13068,7 +13115,7 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
13068
13115
  definitions: import_lodash3.default.uniqBy(extractInlineTypes(operationsDefinitions), (node) => node.name.value)
13069
13116
  };
13070
13117
  const fragPath = import_path.default.join(rootPath, ".tina", "__generated__");
13071
- await import_fs_extra.default.outputFileSync(import_path.default.join(fragPath, "queries.gql"), (0, import_graphql2.print)(queryDoc));
13118
+ await import_fs_extra.default.outputFile(import_path.default.join(fragPath, "queries.gql"), (0, import_graphql2.print)(queryDoc));
13072
13119
  };
13073
13120
  var _buildSchema = async (builder, tinaSchema) => {
13074
13121
  const definitions = [];
@@ -20426,11 +20473,62 @@ var visit = function(tree, test, visitor, reverse) {
20426
20473
 
20427
20474
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20428
20475
  var import_lodash4 = __toModule(require("lodash"));
20429
- var parseMDX = (value, field) => {
20476
+
20477
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
20478
+ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
20479
+ if (config && value) {
20480
+ if (config.useRelativeMedia === true) {
20481
+ return value;
20482
+ }
20483
+ if (hasTinaMediaConfig(schema) === true) {
20484
+ const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
20485
+ if (typeof value === "string" && value.includes(assetsURL)) {
20486
+ const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
20487
+ const strippedURL = value.replace(assetsURL, "");
20488
+ return `${cleanMediaRoot}${strippedURL}`;
20489
+ }
20490
+ return value;
20491
+ }
20492
+ return value;
20493
+ } else {
20494
+ return value;
20495
+ }
20496
+ };
20497
+ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
20498
+ if (config && value) {
20499
+ if (config.useRelativeMedia === true) {
20500
+ return value;
20501
+ }
20502
+ if (hasTinaMediaConfig(schema) === true) {
20503
+ const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
20504
+ const strippedValue = value.replace(cleanMediaRoot, "");
20505
+ return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
20506
+ }
20507
+ return value;
20508
+ } else {
20509
+ return value;
20510
+ }
20511
+ };
20512
+ var cleanUpSlashes = (path6) => {
20513
+ if (path6) {
20514
+ return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
20515
+ }
20516
+ return "";
20517
+ };
20518
+ var hasTinaMediaConfig = (schema) => {
20519
+ var _a, _b, _c, _d, _e, _f;
20520
+ if (((_c = (_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina) == null ? void 0 : _c.publicFolder) && ((_f = (_e = (_d = schema.config) == null ? void 0 : _d.media) == null ? void 0 : _e.tina) == null ? void 0 : _f.mediaRoot)) {
20521
+ return true;
20522
+ }
20523
+ return false;
20524
+ };
20525
+
20526
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
20527
+ var parseMDX = (value, field, graphQLconfig, schema) => {
20430
20528
  const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
20431
- return parseMDXInner(tree, field);
20529
+ return parseMDXInner(tree, field, graphQLconfig, schema);
20432
20530
  };
20433
- var parseMDXInner = (tree, field) => {
20531
+ var parseMDXInner = (tree, field, graphQLconfig, schema) => {
20434
20532
  visit(tree, (node) => {
20435
20533
  delete node.position;
20436
20534
  });
@@ -20438,7 +20536,7 @@ var parseMDXInner = (tree, field) => {
20438
20536
  var _a;
20439
20537
  let props = {};
20440
20538
  if (!node.name) {
20441
- props = parseMDXInner({ type: "root", children: node.children }, field);
20539
+ props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig, schema);
20442
20540
  }
20443
20541
  const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
20444
20542
  const templateName = typeof template2 === "string" ? template2 : template2.name;
@@ -20469,7 +20567,7 @@ var parseMDXInner = (tree, field) => {
20469
20567
  if (!field2) {
20470
20568
  throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
20471
20569
  }
20472
- parseField(attribute, field2, props);
20570
+ parseField(attribute, field2, props, graphQLconfig, schema);
20473
20571
  }
20474
20572
  } else {
20475
20573
  console.log(`Not sure what this is, type: ${attribute.type}`);
@@ -20478,15 +20576,19 @@ var parseMDXInner = (tree, field) => {
20478
20576
  delete node.attributes;
20479
20577
  node.props = props;
20480
20578
  });
20481
- const slateTree = tree.children.map(remarkToSlate);
20579
+ const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig, schema));
20482
20580
  return { type: "root", children: slateTree };
20483
20581
  };
20484
- var parseField = (attribute, field, props) => {
20582
+ var parseField = (attribute, field, props, graphQLconfig, schema) => {
20485
20583
  var _a, _b;
20486
20584
  switch (field.type) {
20487
20585
  case "boolean":
20488
20586
  case "datetime":
20587
+ props[field.name] = attribute.value;
20588
+ break;
20489
20589
  case "image":
20590
+ props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig, schema);
20591
+ break;
20490
20592
  case "number":
20491
20593
  case "string":
20492
20594
  if (field.list) {
@@ -20548,7 +20650,7 @@ var parseField = (attribute, field, props) => {
20548
20650
  throw new Error(`Global fields not supported at this time`);
20549
20651
  }
20550
20652
  field.fields.forEach((field2) => {
20551
- parseField(property, field2, objectProps);
20653
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20552
20654
  });
20553
20655
  }
20554
20656
  });
@@ -20570,7 +20672,7 @@ var parseField = (attribute, field, props) => {
20570
20672
  throw new Error(`Global fields not supported at this time`);
20571
20673
  }
20572
20674
  field.fields.forEach((field2) => {
20573
- parseField(property, field2, objectProps);
20675
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20574
20676
  });
20575
20677
  }
20576
20678
  if (field.templates) {
@@ -20579,7 +20681,7 @@ var parseField = (attribute, field, props) => {
20579
20681
  throw new Error(`Global fields not supported at this time`);
20580
20682
  }
20581
20683
  fieldTemplate.fields.forEach((field2) => {
20582
- parseField(property, field2, objectProps);
20684
+ parseField(property, field2, objectProps, graphQLconfig, schema);
20583
20685
  });
20584
20686
  });
20585
20687
  }
@@ -20602,13 +20704,13 @@ var parseField = (attribute, field, props) => {
20602
20704
  if (attribute.value) {
20603
20705
  if (field.name === "children") {
20604
20706
  if (Array.isArray(attribute.value)) {
20605
- props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field);
20707
+ props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig, schema);
20606
20708
  } else {
20607
20709
  throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
20608
20710
  }
20609
20711
  } else {
20610
20712
  try {
20611
- const mdx2 = parseMDX(attribute.value.value, field);
20713
+ const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig, schema);
20612
20714
  props[field.name] = mdx2.children[0].props;
20613
20715
  } catch (e) {
20614
20716
  console.log(e);
@@ -20679,7 +20781,7 @@ var defaultNodeTypes = {
20679
20781
  break: "break",
20680
20782
  image: plateElements.ELEMENT_IMAGE
20681
20783
  };
20682
- function remarkToSlate(node) {
20784
+ function remarkToSlate(node, graphQLconfig, schema) {
20683
20785
  const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
20684
20786
  heading: __spreadValues({}, defaultNodeTypes.heading)
20685
20787
  });
@@ -20687,12 +20789,12 @@ function remarkToSlate(node) {
20687
20789
  case "heading":
20688
20790
  return {
20689
20791
  type: types.heading[node.depth],
20690
- children: node.children.map(remarkToSlate)
20792
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20691
20793
  };
20692
20794
  case "list":
20693
20795
  return {
20694
20796
  type: node.ordered ? types.ol_list : types.ul_list,
20695
- children: node.children.map(remarkToSlate)
20797
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20696
20798
  };
20697
20799
  case "listItem":
20698
20800
  const realChildren = [];
@@ -20700,12 +20802,12 @@ function remarkToSlate(node) {
20700
20802
  if (child.type === "list") {
20701
20803
  realChildren.push({
20702
20804
  type: child.ordered ? types.ol_list : types.ul_list,
20703
- children: child.children.map(remarkToSlate)
20805
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20704
20806
  });
20705
20807
  } else {
20706
20808
  realChildren.push({
20707
20809
  type: plateElements.ELEMENT_LIC,
20708
- children: child.children.map(remarkToSlate)
20810
+ children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20709
20811
  });
20710
20812
  }
20711
20813
  });
@@ -20716,25 +20818,26 @@ function remarkToSlate(node) {
20716
20818
  case "paragraph":
20717
20819
  return {
20718
20820
  type: types.paragraph,
20719
- children: node.children.map(remarkToSlate)
20821
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20720
20822
  };
20721
20823
  case "link":
20722
20824
  return {
20723
20825
  type: types.link,
20724
20826
  url: node.url,
20725
- children: node.children.map(remarkToSlate)
20827
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20726
20828
  };
20727
20829
  case "image":
20830
+ const url = resolveMediaRelativeToCloud(node.url, graphQLconfig, schema);
20728
20831
  return {
20729
20832
  type: types.image,
20730
- url: node.url,
20833
+ url,
20731
20834
  alt: node.alt,
20732
20835
  caption: node.title
20733
20836
  };
20734
20837
  case "blockquote":
20735
20838
  return {
20736
20839
  type: types.block_quote,
20737
- children: node.children.map(remarkToSlate)
20840
+ children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
20738
20841
  };
20739
20842
  case "code":
20740
20843
  return {
@@ -22195,10 +22298,10 @@ var mdxToMarkdown = {
22195
22298
  };
22196
22299
 
22197
22300
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
22198
- var stringifyMDX = (value, field) => {
22301
+ var stringifyMDX = (value, field, graphQLconfig, schema) => {
22199
22302
  const slateTree = value.children;
22200
22303
  try {
22201
- const tree = stringifyChildren(slateTree, field);
22304
+ const tree = stringifyChildren(slateTree, field, graphQLconfig, schema);
22202
22305
  const out = toMarkdown({
22203
22306
  type: "root",
22204
22307
  children: tree
@@ -22216,13 +22319,13 @@ var allChildrenEmpty = (children) => {
22216
22319
  }
22217
22320
  return false;
22218
22321
  };
22219
- var stringifyChildren = (children, field) => {
22322
+ var stringifyChildren = (children, field, graphQLconfig, schema) => {
22220
22323
  if (!children) {
22221
22324
  return [];
22222
22325
  }
22223
- return children.map((child) => stringify(child, field)).filter(Boolean);
22326
+ return children.map((child) => stringify(child, field, graphQLconfig, schema)).filter(Boolean);
22224
22327
  };
22225
- var stringify = (node, field) => {
22328
+ var stringify = (node, field, graphQLconfig, schema) => {
22226
22329
  var _a;
22227
22330
  if (!node.type) {
22228
22331
  if (node == null ? void 0 : node.code) {
@@ -22248,40 +22351,40 @@ var stringify = (node, field) => {
22248
22351
  return {
22249
22352
  type: "heading",
22250
22353
  depth: 1,
22251
- children: stringifyChildren(node.children, field)
22354
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22252
22355
  };
22253
22356
  case plateElements.ELEMENT_H2:
22254
22357
  return {
22255
22358
  type: "heading",
22256
22359
  depth: 2,
22257
- children: stringifyChildren(node.children, field)
22360
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22258
22361
  };
22259
22362
  case plateElements.ELEMENT_H3:
22260
22363
  return {
22261
22364
  type: "heading",
22262
22365
  depth: 3,
22263
- children: stringifyChildren(node.children, field)
22366
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22264
22367
  };
22265
22368
  case plateElements.ELEMENT_H4:
22266
22369
  return {
22267
22370
  type: "heading",
22268
22371
  depth: 4,
22269
- children: stringifyChildren(node.children, field)
22372
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22270
22373
  };
22271
22374
  case plateElements.ELEMENT_H5:
22272
22375
  return {
22273
22376
  type: "heading",
22274
22377
  depth: 5,
22275
- children: stringifyChildren(node.children, field)
22378
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22276
22379
  };
22277
22380
  case plateElements.ELEMENT_H6:
22278
22381
  return {
22279
22382
  type: "heading",
22280
22383
  depth: 6,
22281
- children: stringifyChildren(node.children, field)
22384
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22282
22385
  };
22283
22386
  case plateElements.ELEMENT_PARAGRAPH:
22284
- const children = stringifyChildren(node.children, field);
22387
+ const children = stringifyChildren(node.children, field, graphQLconfig, schema);
22285
22388
  if (allChildrenEmpty(children)) {
22286
22389
  return false;
22287
22390
  }
@@ -22301,7 +22404,7 @@ var stringify = (node, field) => {
22301
22404
  ordered: false,
22302
22405
  spread: false,
22303
22406
  check: null,
22304
- children: stringifyChildren(node.children, field)
22407
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22305
22408
  };
22306
22409
  case plateElements.ELEMENT_OL:
22307
22410
  return {
@@ -22309,7 +22412,7 @@ var stringify = (node, field) => {
22309
22412
  ordered: true,
22310
22413
  spread: false,
22311
22414
  check: null,
22312
- children: stringifyChildren(node.children, field)
22415
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22313
22416
  };
22314
22417
  case plateElements.ELEMENT_LI:
22315
22418
  const realChildren = [];
@@ -22332,21 +22435,22 @@ var stringify = (node, field) => {
22332
22435
  spread: false,
22333
22436
  check: null,
22334
22437
  children: [
22335
- ...stringifyChildren([p], field),
22336
- ...stringifyChildren(extraChildren, field)
22438
+ ...stringifyChildren([p], field, graphQLconfig, schema),
22439
+ ...stringifyChildren(extraChildren, field, graphQLconfig, schema)
22337
22440
  ]
22338
22441
  };
22339
22442
  case plateElements.ELEMENT_LIC:
22340
22443
  return {
22341
22444
  type: "paragraph",
22342
- children: stringifyChildren(node.children, field)
22445
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22343
22446
  };
22344
22447
  case plateElements.ELEMENT_IMAGE:
22448
+ const url = resolveMediaCloudToRelative(node.url, graphQLconfig, schema);
22345
22449
  return {
22346
22450
  type: "image",
22347
22451
  title: node.caption,
22348
22452
  alt: node.alt,
22349
- url: node.url
22453
+ url
22350
22454
  };
22351
22455
  case plateElements.ELEMENT_HR:
22352
22456
  return {
@@ -22357,12 +22461,12 @@ var stringify = (node, field) => {
22357
22461
  type: "link",
22358
22462
  url: node.url,
22359
22463
  title: node.title,
22360
- children: stringifyChildren(node.children, field)
22464
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22361
22465
  };
22362
22466
  case plateElements.ELEMENT_BLOCKQUOTE:
22363
22467
  return {
22364
22468
  type: "blockquote",
22365
- children: stringifyChildren(node.children, field)
22469
+ children: stringifyChildren(node.children, field, graphQLconfig, schema)
22366
22470
  };
22367
22471
  case "mdxJsxTextElement":
22368
22472
  case "mdxJsxFlowElement":
@@ -22527,7 +22631,7 @@ var stringify = (node, field) => {
22527
22631
  }
22528
22632
  break;
22529
22633
  case "rich-text":
22530
- const tree = stringifyChildren(value.children, field2);
22634
+ const tree = stringifyChildren(value.children, field2, graphQLconfig, schema);
22531
22635
  if (field2.name === "children") {
22532
22636
  children2 = tree;
22533
22637
  } else {
@@ -22730,7 +22834,18 @@ var Resolver = class {
22730
22834
  _collection: rawData._collection,
22731
22835
  _template: rawData._template
22732
22836
  };
22733
- await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
22837
+ try {
22838
+ await sequential(template.fields, async (field) => {
22839
+ return this.resolveFieldData(field, rawData, data);
22840
+ });
22841
+ } catch (e) {
22842
+ throw new TinaParseDocumentError({
22843
+ originalError: e,
22844
+ collection: collection.name,
22845
+ file: relativePath,
22846
+ stack: e.stack
22847
+ });
22848
+ }
22734
22849
  const titleField = template.fields.find((x) => {
22735
22850
  if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
22736
22851
  return true;
@@ -22756,8 +22871,8 @@ var Resolver = class {
22756
22871
  _values: data
22757
22872
  });
22758
22873
  } catch (e) {
22759
- if (e instanceof TinaError) {
22760
- throw new TinaError(e.message, __spreadValues({
22874
+ if (e instanceof TinaGraphQLError) {
22875
+ throw new TinaGraphQLError(e.message, __spreadValues({
22761
22876
  requestedDocument: fullPath
22762
22877
  }, e.extensions));
22763
22878
  }
@@ -23014,7 +23129,8 @@ var Resolver = class {
23014
23129
  edges = result.edges;
23015
23130
  pageInfo = result.pageInfo;
23016
23131
  } else {
23017
- edges = (await this.database.store.glob(collection.path, this.getDocument)).map((document3) => ({
23132
+ const ext = (collection == null ? void 0 : collection.format) || ".md";
23133
+ edges = (await this.database.store.glob(collection.path, this.getDocument, ext)).map((document3) => ({
23018
23134
  node: document3
23019
23135
  }));
23020
23136
  }
@@ -23048,15 +23164,16 @@ var Resolver = class {
23048
23164
  case "string":
23049
23165
  case "boolean":
23050
23166
  case "number":
23051
- case "image":
23052
23167
  accum[fieldName] = fieldValue;
23053
23168
  break;
23169
+ case "image":
23170
+ accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config, this.tinaSchema.schema);
23171
+ break;
23054
23172
  case "object":
23055
23173
  accum[fieldName] = this.buildObjectMutations(fieldValue, field);
23056
23174
  break;
23057
23175
  case "rich-text":
23058
- field;
23059
- accum[fieldName] = stringifyMDX(fieldValue, field);
23176
+ accum[fieldName] = stringifyMDX(fieldValue, field, this.config, this.tinaSchema.schema);
23060
23177
  break;
23061
23178
  case "reference":
23062
23179
  accum[fieldName] = fieldValue;
@@ -23089,18 +23206,10 @@ var Resolver = class {
23089
23206
  accumulator[field.name] = value;
23090
23207
  break;
23091
23208
  case "image":
23092
- if (this.config) {
23093
- if (this.config.useRelativeMedia === true) {
23094
- accumulator[field.name] = value;
23095
- } else {
23096
- accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
23097
- }
23098
- } else {
23099
- accumulator[field.name] = value;
23100
- }
23209
+ accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config, this.tinaSchema.schema);
23101
23210
  break;
23102
23211
  case "rich-text":
23103
- const tree = parseMDX(value, field);
23212
+ const tree = parseMDX(value, field, this.config, this.tinaSchema.schema);
23104
23213
  accumulator[field.name] = tree;
23105
23214
  break;
23106
23215
  case "object":
@@ -23205,10 +23314,12 @@ var resolve = async ({
23205
23314
  query,
23206
23315
  variables,
23207
23316
  database,
23208
- silenceErrors
23317
+ silenceErrors,
23318
+ verbose
23209
23319
  }) => {
23210
23320
  var _a;
23211
23321
  try {
23322
+ const verboseValue = verbose != null ? verbose : true;
23212
23323
  const graphQLSchemaAst = await database.getGraphQLSchema();
23213
23324
  const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
23214
23325
  const tinaConfig = await database.getTinaSchema();
@@ -23236,141 +23347,152 @@ var resolve = async ({
23236
23347
  }
23237
23348
  },
23238
23349
  fieldResolver: async (source = {}, _args = {}, _context, info) => {
23239
- const args = JSON.parse(JSON.stringify(_args));
23240
- const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23241
- const lookup = await database.getLookup(returnType);
23242
- const isMutation = info.parentType.toString() === "Mutation";
23243
- const value = source[info.fieldName];
23244
- if (returnType === "Collection") {
23245
- if (value) {
23246
- return value;
23247
- }
23248
- if (info.fieldName === "collections") {
23249
- const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23250
- const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23251
- var _a2;
23252
- return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23253
- });
23254
- return tinaSchema.getCollections().map((collection) => {
23255
- return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23256
- });
23257
- }
23258
- const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23259
- const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23260
- var _a2;
23261
- return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23262
- });
23263
- return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23264
- }
23265
- if (info.fieldName === "getOptimizedQuery") {
23266
- try {
23267
- const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23268
- assumeValid: true,
23269
- includeFragments: false,
23270
- noLocation: true
23271
- });
23272
- return (0, import_graphql3.print)(optimizedQuery);
23273
- } catch (e) {
23274
- throw new Error(`Invalid query provided, Error message: ${e.message}`);
23275
- }
23276
- }
23277
- if (!lookup) {
23278
- return value;
23279
- }
23280
- const isCreation = lookup[info.fieldName] === "create";
23281
- switch (lookup.resolveType) {
23282
- case "nodeDocument":
23283
- assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23284
- return resolver2.getDocument(args.id);
23285
- case "multiCollectionDocument":
23286
- if (typeof value === "string") {
23287
- return resolver2.getDocument(value);
23350
+ try {
23351
+ const args = JSON.parse(JSON.stringify(_args));
23352
+ const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
23353
+ const lookup = await database.getLookup(returnType);
23354
+ const isMutation = info.parentType.toString() === "Mutation";
23355
+ const value = source[info.fieldName];
23356
+ if (returnType === "Collection") {
23357
+ if (value) {
23358
+ return value;
23288
23359
  }
23289
- if (args && args.collection && info.fieldName === "addPendingDocument") {
23290
- return resolver2.resolveDocument({
23291
- args: __spreadProps(__spreadValues({}, args), { params: {} }),
23292
- collection: args.collection,
23293
- isMutation,
23294
- isCreation: true,
23295
- isAddPendingDocument: true
23360
+ if (info.fieldName === "collections") {
23361
+ const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
23362
+ const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23363
+ var _a2;
23364
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23296
23365
  });
23297
- }
23298
- if ([
23299
- NAMER.documentQueryName(),
23300
- "createDocument",
23301
- "updateDocument",
23302
- "deleteDocument"
23303
- ].includes(info.fieldName)) {
23304
- const result2 = await resolver2.resolveDocument({
23305
- args,
23306
- collection: args.collection,
23307
- isMutation,
23308
- isCreation,
23309
- isDeletion: info.fieldName === "deleteDocument",
23310
- isAddPendingDocument: false,
23311
- isCollectionSpecific: false
23366
+ return tinaSchema.getCollections().map((collection) => {
23367
+ return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
23312
23368
  });
23313
- return result2;
23314
23369
  }
23315
- return value;
23316
- case "multiCollectionDocumentList":
23317
- if (Array.isArray(value)) {
23318
- return {
23319
- totalCount: value.length,
23320
- edges: value.map((document3) => {
23321
- return { node: document3 };
23322
- })
23323
- };
23324
- } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23325
- return resolver2.resolveCollectionConnection({
23326
- args,
23327
- collection: value.collection
23370
+ const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
23371
+ const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23372
+ var _a2;
23373
+ return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
23374
+ });
23375
+ return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
23376
+ }
23377
+ if (info.fieldName === "getOptimizedQuery") {
23378
+ try {
23379
+ const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
23380
+ assumeValid: true,
23381
+ includeFragments: false,
23382
+ noLocation: true
23328
23383
  });
23329
- } else {
23330
- throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23384
+ return (0, import_graphql3.print)(optimizedQuery);
23385
+ } catch (e) {
23386
+ throw new Error(`Invalid query provided, Error message: ${e.message}`);
23331
23387
  }
23332
- case "collectionDocument":
23333
- if (value) {
23334
- return value;
23335
- }
23336
- const result = value || await resolver2.resolveDocument({
23337
- args,
23338
- collection: lookup.collection,
23339
- isMutation,
23340
- isCreation,
23341
- isAddPendingDocument: false,
23342
- isCollectionSpecific: true
23343
- });
23344
- return result;
23345
- case "collectionDocumentList":
23346
- return resolver2.resolveCollectionConnection({
23347
- args,
23348
- collection: tinaSchema.getCollection(lookup.collection)
23349
- });
23350
- case "unionData":
23351
- if (!value) {
23352
- if (args.relativePath) {
23388
+ }
23389
+ if (!lookup) {
23390
+ return value;
23391
+ }
23392
+ const isCreation = lookup[info.fieldName] === "create";
23393
+ switch (lookup.resolveType) {
23394
+ case "nodeDocument":
23395
+ assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23396
+ return resolver2.getDocument(args.id);
23397
+ case "multiCollectionDocument":
23398
+ if (typeof value === "string") {
23399
+ return resolver2.getDocument(value);
23400
+ }
23401
+ if (args && args.collection && info.fieldName === "addPendingDocument") {
23402
+ return resolver2.resolveDocument({
23403
+ args: __spreadProps(__spreadValues({}, args), { params: {} }),
23404
+ collection: args.collection,
23405
+ isMutation,
23406
+ isCreation: true,
23407
+ isAddPendingDocument: true
23408
+ });
23409
+ }
23410
+ if ([
23411
+ NAMER.documentQueryName(),
23412
+ "createDocument",
23413
+ "updateDocument",
23414
+ "deleteDocument"
23415
+ ].includes(info.fieldName)) {
23353
23416
  const result2 = await resolver2.resolveDocument({
23354
23417
  args,
23355
- collection: lookup.collection,
23418
+ collection: args.collection,
23356
23419
  isMutation,
23357
23420
  isCreation,
23421
+ isDeletion: info.fieldName === "deleteDocument",
23358
23422
  isAddPendingDocument: false,
23359
- isCollectionSpecific: true
23423
+ isCollectionSpecific: false
23360
23424
  });
23361
23425
  return result2;
23362
23426
  }
23363
- }
23364
- return value;
23365
- default:
23366
- console.error(lookup);
23367
- throw new Error(`Unexpected resolve type`);
23427
+ return value;
23428
+ case "multiCollectionDocumentList":
23429
+ if (Array.isArray(value)) {
23430
+ return {
23431
+ totalCount: value.length,
23432
+ edges: value.map((document3) => {
23433
+ return { node: document3 };
23434
+ })
23435
+ };
23436
+ } else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
23437
+ return resolver2.resolveCollectionConnection({
23438
+ args,
23439
+ collection: value.collection
23440
+ });
23441
+ } else {
23442
+ throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
23443
+ }
23444
+ case "collectionDocument":
23445
+ if (value) {
23446
+ return value;
23447
+ }
23448
+ const result = value || await resolver2.resolveDocument({
23449
+ args,
23450
+ collection: lookup.collection,
23451
+ isMutation,
23452
+ isCreation,
23453
+ isAddPendingDocument: false,
23454
+ isCollectionSpecific: true
23455
+ });
23456
+ return result;
23457
+ case "collectionDocumentList":
23458
+ return resolver2.resolveCollectionConnection({
23459
+ args,
23460
+ collection: tinaSchema.getCollection(lookup.collection)
23461
+ });
23462
+ case "unionData":
23463
+ if (!value) {
23464
+ if (args.relativePath) {
23465
+ const result2 = await resolver2.resolveDocument({
23466
+ args,
23467
+ collection: lookup.collection,
23468
+ isMutation,
23469
+ isCreation,
23470
+ isAddPendingDocument: false,
23471
+ isCollectionSpecific: true
23472
+ });
23473
+ return result2;
23474
+ }
23475
+ }
23476
+ return value;
23477
+ default:
23478
+ console.error(lookup);
23479
+ throw new Error(`Unexpected resolve type`);
23480
+ }
23481
+ } catch (e) {
23482
+ handleFetchErrorError(e, verboseValue);
23368
23483
  }
23369
23484
  }
23370
23485
  });
23371
23486
  if (res.errors) {
23372
23487
  if (!silenceErrors) {
23373
- console.error(res.errors);
23488
+ res.errors.map((e) => {
23489
+ console.error(e.toString());
23490
+ if (verboseValue) {
23491
+ console.error("More error context below");
23492
+ console.error(e.message);
23493
+ console.error(e);
23494
+ }
23495
+ });
23374
23496
  }
23375
23497
  }
23376
23498
  return res;
@@ -23523,25 +23645,34 @@ var Database = class {
23523
23645
  });
23524
23646
  };
23525
23647
  this.put = async (filepath, data, collection) => {
23526
- if (SYSTEM_FILES.includes(filepath)) {
23527
- throw new Error(`Unexpected put for config file ${filepath}`);
23528
- } else {
23529
- let collectionIndexDefinitions;
23530
- if (collection) {
23531
- const indexDefinitions = await this.getIndexDefinitions();
23532
- collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23533
- }
23534
- const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23535
- if (this.store.supportsSeeding()) {
23536
- await this.bridge.put(normalizePath(filepath), stringifiedFile);
23648
+ try {
23649
+ if (SYSTEM_FILES.includes(filepath)) {
23650
+ throw new Error(`Unexpected put for config file ${filepath}`);
23651
+ } else {
23652
+ let collectionIndexDefinitions;
23653
+ if (collection) {
23654
+ const indexDefinitions = await this.getIndexDefinitions();
23655
+ collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
23656
+ }
23657
+ const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23658
+ if (this.store.supportsSeeding()) {
23659
+ await this.bridge.put(normalizePath(filepath), stringifiedFile);
23660
+ }
23661
+ await this.store.put(normalizePath(filepath), payload, {
23662
+ keepTemplateKey,
23663
+ collection,
23664
+ indexDefinitions: collectionIndexDefinitions
23665
+ });
23537
23666
  }
23538
- await this.store.put(normalizePath(filepath), payload, {
23539
- keepTemplateKey,
23667
+ return true;
23668
+ } catch (error) {
23669
+ throw new TinaFetchError(`Error in PUT for ${filepath}`, {
23670
+ originalError: error,
23671
+ file: filepath,
23540
23672
  collection,
23541
- indexDefinitions: collectionIndexDefinitions
23673
+ stack: error.stack
23542
23674
  });
23543
23675
  }
23544
- return true;
23545
23676
  };
23546
23677
  this.stringifyFile = async (filepath, data) => {
23547
23678
  if (SYSTEM_FILES.includes(filepath)) {
@@ -23717,11 +23848,24 @@ var Database = class {
23717
23848
  } = await this.store.query(storeQueryOptions);
23718
23849
  return {
23719
23850
  edges: await sequential(edges, async (edge) => {
23720
- const node = await hydrator(edge.path);
23721
- return {
23722
- node,
23723
- cursor: (0, import_datalayer2.btoa)(edge.cursor)
23724
- };
23851
+ try {
23852
+ const node = await hydrator(edge.path);
23853
+ return {
23854
+ node,
23855
+ cursor: (0, import_datalayer2.btoa)(edge.cursor)
23856
+ };
23857
+ } catch (error) {
23858
+ if (error instanceof Error) {
23859
+ throw new TinaQueryError({
23860
+ originalError: error,
23861
+ file: edge.path,
23862
+ collection,
23863
+ stack: error.stack
23864
+ });
23865
+ } else {
23866
+ throw error;
23867
+ }
23868
+ }
23725
23869
  }),
23726
23870
  pageInfo: {
23727
23871
  hasPreviousPage,
@@ -23793,7 +23937,7 @@ var Database = class {
23793
23937
  this._indexAllContent = async () => {
23794
23938
  const tinaSchema = await this.getSchema();
23795
23939
  await sequential(tinaSchema.getCollections(), async (collection) => {
23796
- const documentPaths = await this.bridge.glob(normalizePath(collection.path));
23940
+ const documentPaths = await this.bridge.glob(normalizePath(collection.path), collection.format || "md");
23797
23941
  await _indexContent(this, documentPaths, collection);
23798
23942
  });
23799
23943
  };
@@ -23868,10 +24012,19 @@ var _indexContent = async (database, documentPaths, collection) => {
23868
24012
  };
23869
24013
  }
23870
24014
  await sequential(documentPaths, async (filepath) => {
23871
- const dataString = await database.bridge.get(normalizePath(filepath));
23872
- const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23873
- if (database.store.supportsSeeding()) {
23874
- await database.store.seed(normalizePath(filepath), data, seedOptions);
24015
+ try {
24016
+ const dataString = await database.bridge.get(normalizePath(filepath));
24017
+ const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
24018
+ if (database.store.supportsSeeding()) {
24019
+ await database.store.seed(normalizePath(filepath), data, seedOptions);
24020
+ }
24021
+ } catch (error) {
24022
+ throw new TinaFetchError(`Unable to seed ${filepath}`, {
24023
+ originalError: error,
24024
+ file: filepath,
24025
+ collection: collection.name,
24026
+ stack: error.stack
24027
+ });
23875
24028
  }
23876
24029
  });
23877
24030
  };
@@ -23897,16 +24050,21 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
23897
24050
  var buildSchema = async (rootPath, database, flags) => {
23898
24051
  const tempConfig = import_path5.default.join(rootPath, ".tina", "__generated__", "config");
23899
24052
  const config = await import_fs_extra2.default.readFileSync(import_path5.default.join(tempConfig, "schema.json")).toString();
23900
- await import_fs_extra2.default.rmdir(tempConfig, { recursive: true });
24053
+ await import_fs_extra2.default.rm(tempConfig, { recursive: true });
23901
24054
  await indexDB({ database, config: JSON.parse(config), flags });
23902
24055
  const gqlAst = await database.getGraphQLSchemaFromBridge();
23903
24056
  return (0, import_graphql5.buildASTSchema)(gqlAst);
23904
24057
  };
23905
24058
  // Annotate the CommonJS export names for ESM import in node:
23906
24059
  0 && (module.exports = {
24060
+ TinaFetchError,
24061
+ TinaGraphQLError,
24062
+ TinaParseDocumentError,
24063
+ TinaQueryError,
23907
24064
  assertShape,
23908
24065
  buildSchema,
23909
24066
  createDatabase,
24067
+ handleFetchErrorError,
23910
24068
  indexDB,
23911
24069
  parseFile,
23912
24070
  resolve,
@@ -16,8 +16,9 @@ limitations under the License.
16
16
 
17
17
  */
18
18
  import type { Content } from 'mdast';
19
- import type { RichTypeInner } from '../types';
20
- export declare const parseMDX: (value: string, field: RichTypeInner) => {
19
+ import type { GraphQLConfig, RichTypeInner } from '../types';
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) => {
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) => {
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): any;
230
+ export default function remarkToSlate(node: MdxAstNode, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched): any;
230
231
  export {};
@@ -15,10 +15,11 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
 
17
17
  */
18
- import type { RichTypeInner } from '../types';
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) => 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) => 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;
@@ -0,0 +1,30 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import type { GraphQLConfig } from '../types';
14
+ import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
15
+ /**
16
+ * Strips away the Tina Cloud Asset URL from an `image` value
17
+ *
18
+ * @param {string} value
19
+ * @param {GraphQLConfig} config
20
+ * @returns {string}
21
+ */
22
+ export declare const resolveMediaCloudToRelative: (value: string, config: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
23
+ /**
24
+ * Adds Tina Cloud Asset URL to an `image` value
25
+ *
26
+ * @param {string} value
27
+ * @param {GraphQLConfig} config
28
+ * @returns {string}
29
+ */
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.0.0-202259143352",
3
+ "version": "0.0.0-202261192534",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -47,7 +47,8 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
50
- "@tinacms/datalayer": "0.1.1",
50
+ "@tinacms/datalayer": "0.2.0",
51
+ "@tinacms/schema-tools": "0.0.0-202261192534",
51
52
  "body-parser": "^1.19.0",
52
53
  "cors": "^2.8.5",
53
54
  "dataloader": "^2.0.0",
@@ -97,9 +98,9 @@
97
98
  "directory": "packages/tina-graphql"
98
99
  },
99
100
  "devDependencies": {
100
- "@tinacms/datalayer": "0.1.1",
101
- "@tinacms/schema-tools": "0.0.4",
102
- "@tinacms/scripts": "0.50.7",
101
+ "@tinacms/datalayer": "0.2.0",
102
+ "@tinacms/schema-tools": "0.0.0-202261192534",
103
+ "@tinacms/scripts": "0.50.9",
103
104
  "@types/cors": "^2.8.7",
104
105
  "@types/estree": "^0.0.50",
105
106
  "@types/express": "^4.17.8",
@@ -121,8 +122,5 @@
121
122
  "jest-matcher-utils": "27.0.6",
122
123
  "nodemon": "^2.0.4",
123
124
  "typescript": "^4.3.5"
124
- },
125
- "peerDependencies": {
126
- "@tinacms/schema-tools": "*"
127
125
  }
128
126
  }