@tinacms/graphql 2.2.4 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,6 @@ yupSchema: (args: typeof yup) => yup.ObjectSchema<any>, markdownParseConfig?: {
16
16
  lineWidth?: number;
17
17
  frontmatterDelimiters?: [string, string] | string;
18
18
  }) => T;
19
- export declare const atob: (b64Encoded: string) => string;
20
- export declare const btoa: (string: string) => string;
21
19
  export declare const scanAllContent: (tinaSchema: TinaSchema, bridge: Bridge, callback: (collection: Collection<true>, contentPaths: string[]) => Promise<void>) => Promise<string[]>;
22
20
  export declare const scanContentByPaths: (tinaSchema: TinaSchema, documentPaths: string[], callback: (collection: Collection<true> | undefined, documentPaths: string[]) => Promise<void>) => Promise<void>;
23
21
  export declare const partitionPathsByCollection: (tinaSchema: TinaSchema, documentPaths: string[]) => Promise<{
package/dist/index.js CHANGED
@@ -3035,7 +3035,7 @@ var validateField = async (field) => {
3035
3035
  var package_default = {
3036
3036
  name: "@tinacms/graphql",
3037
3037
  type: "module",
3038
- version: "2.2.4",
3038
+ version: "2.3.0",
3039
3039
  main: "dist/index.js",
3040
3040
  module: "./dist/index.js",
3041
3041
  files: [
@@ -3685,7 +3685,7 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
3685
3685
  `"${path9}" Found in multiple collections: ${filesSeen.get(path9).map((collection2) => `"${collection2}"`).join(
3686
3686
  ", "
3687
3687
  )}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
3688
- This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
3688
+ This will be an error in the future. See https://tina.io/docs/r/content-modelling-collections#path-matching
3689
3689
  `
3690
3690
  );
3691
3691
  });
@@ -3792,7 +3792,7 @@ var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo)
3792
3792
  const template = getTemplateForFile(templateInfo, data);
3793
3793
  if (!template) {
3794
3794
  console.warn(
3795
- `Document: ${filepath} has an ambiguous template, skipping from indexing. See https://tina.io/docs/errors/ambiguous-template/ for more info.`
3795
+ `Document: ${filepath} has an ambiguous template, skipping from indexing. See https://tina.io/docs/r/ambiguous-template for more info.`
3796
3796
  );
3797
3797
  return;
3798
3798
  }
@@ -4638,21 +4638,17 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
4638
4638
  }
4639
4639
  if (hasTinaMediaConfig(schema) === true) {
4640
4640
  const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
4641
+ const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
4641
4642
  if (typeof value === "string" && value.includes(assetsURL)) {
4642
- const cleanMediaRoot = cleanUpSlashes(
4643
- schema.config.media.tina.mediaRoot
4644
- );
4645
- const strippedURL = value.replace(assetsURL, "");
4646
- return `${cleanMediaRoot}${strippedURL}`;
4643
+ return `${cleanMediaRoot}${stripStagingPrefix(
4644
+ value.replace(assetsURL, "")
4645
+ )}`;
4647
4646
  }
4648
4647
  if (Array.isArray(value)) {
4649
4648
  return value.map((v) => {
4650
4649
  if (!v || typeof v !== "string") return v;
4651
- const cleanMediaRoot = cleanUpSlashes(
4652
- schema.config.media.tina.mediaRoot
4653
- );
4654
4650
  const strippedURL = v.replace(assetsURL, "");
4655
- return `${cleanMediaRoot}${strippedURL}`;
4651
+ return `${cleanMediaRoot}${stripStagingPrefix(strippedURL)}`;
4656
4652
  });
4657
4653
  }
4658
4654
  return value;
@@ -4669,15 +4665,16 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
4669
4665
  }
4670
4666
  if (hasTinaMediaConfig(schema) === true) {
4671
4667
  const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
4668
+ const prefix = stagingPrefix(config);
4672
4669
  if (typeof value === "string") {
4673
4670
  const strippedValue = value.replace(cleanMediaRoot, "");
4674
- return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
4671
+ return `https://${config.assetsHost}/${config.clientId}${prefix}${strippedValue}`;
4675
4672
  }
4676
4673
  if (Array.isArray(value)) {
4677
4674
  return value.map((v) => {
4678
4675
  if (!v || typeof v !== "string") return v;
4679
4676
  const strippedValue = v.replace(cleanMediaRoot, "");
4680
- return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
4677
+ return `https://${config.assetsHost}/${config.clientId}${prefix}${strippedValue}`;
4681
4678
  });
4682
4679
  }
4683
4680
  }
@@ -4686,6 +4683,12 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
4686
4683
  return value;
4687
4684
  }
4688
4685
  };
4686
+ var stagingPrefix = (config) => config.branch && config.branch !== config.mediaBranch ? `/__staging/${encodeURIComponent(config.branch)}` : "";
4687
+ var STAGING_SEGMENT = /^\/__staging\/[^/]+(\/.*)$/;
4688
+ var stripStagingPrefix = (path9) => {
4689
+ const match = path9.match(STAGING_SEGMENT);
4690
+ return match ? match[1] : path9;
4691
+ };
4689
4692
  var cleanUpSlashes = (path9) => {
4690
4693
  if (path9) {
4691
4694
  return `/${path9.replace(/^\/+|\/+$/gm, "")}`;
@@ -8648,3 +8651,8 @@ export {
8648
8651
  };
8649
8652
  //! Replaces _.get()
8650
8653
  //! Replaces _.flattenDeep()
8654
+ /**
8655
+ * @license
8656
+ * Copyright 2023 Forestry.io Holdings, Inc.
8657
+ * SPDX-License-Identifier: Apache-2.0
8658
+ */
@@ -1,6 +1,8 @@
1
1
  /**
2
-
3
- */
2
+ * @license
3
+ * Copyright 2023 Forestry.io Holdings, Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
4
6
  import type { Schema } from '@tinacms/schema-tools';
5
7
  import type { GraphQLConfig } from '../types';
6
8
  /**
package/dist/types.d.ts CHANGED
@@ -7,4 +7,6 @@ export type GraphQLConfig = {
7
7
  useRelativeMedia: false;
8
8
  clientId: string;
9
9
  assetsHost: string;
10
+ branch?: string;
11
+ mediaBranch?: string;
10
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
3
  "type": "module",
4
- "version": "2.2.4",
4
+ "version": "2.3.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "files": [
@@ -43,8 +43,8 @@
43
43
  "normalize-path": "^3.0.0",
44
44
  "readable-stream": "^4.7.0",
45
45
  "yup": "^1.6.1",
46
- "@tinacms/mdx": "2.1.2",
47
- "@tinacms/schema-tools": "2.7.2"
46
+ "@tinacms/schema-tools": "2.7.3",
47
+ "@tinacms/mdx": "2.1.3"
48
48
  },
49
49
  "publishConfig": {
50
50
  "registry": "https://registry.npmjs.org"
@@ -72,7 +72,7 @@
72
72
  "vite": "^4.5.9",
73
73
  "vitest": "^0.32.4",
74
74
  "zod": "^3.24.2",
75
- "@tinacms/schema-tools": "2.7.2",
75
+ "@tinacms/schema-tools": "2.7.3",
76
76
  "@tinacms/scripts": "1.6.0"
77
77
  },
78
78
  "scripts": {