@tinacms/graphql 2.2.3 → 2.2.5

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.
@@ -106,7 +106,7 @@ export declare class Database {
106
106
  defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
107
107
  previewSrc?: string;
108
108
  };
109
- fields: ((import("@tinacms/schema-tools").StringField | import("@tinacms/schema-tools").NumberField | import("@tinacms/schema-tools").BooleanField | import("@tinacms/schema-tools").DateTimeField | import("@tinacms/schema-tools").ImageField | import("@tinacms/schema-tools").ReferenceField | import("@tinacms/schema-tools").PasswordField | import("@tinacms/schema-tools").RichTextField<false> | import("@tinacms/schema-tools").ObjectField<false>) & {})[];
109
+ fields: ((import("@tinacms/schema-tools").StringField | import("@tinacms/schema-tools").NumberField | import("@tinacms/schema-tools").BooleanField | import("@tinacms/schema-tools").DateTimeField | import("@tinacms/schema-tools").ImageField | import("@tinacms/schema-tools").ReferenceField | import("@tinacms/schema-tools").PasswordField | import("@tinacms/schema-tools").DisplayOnlyField | import("@tinacms/schema-tools").RichTextField<false> | import("@tinacms/schema-tools").ObjectField<false>) & {})[];
110
110
  };
111
111
  info: CollectionTemplateable;
112
112
  }>;
@@ -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
@@ -1909,6 +1909,8 @@ var Builder = class {
1909
1909
  };
1910
1910
  _buildFieldNodeForFragments = async (field, depth) => {
1911
1911
  switch (field.type) {
1912
+ case "displayOnly":
1913
+ return false;
1912
1914
  case "string":
1913
1915
  case "image":
1914
1916
  case "datetime":
@@ -2350,6 +2352,8 @@ var Builder = class {
2350
2352
  };
2351
2353
  _buildFieldFilter = async (field) => {
2352
2354
  switch (field.type) {
2355
+ case "displayOnly":
2356
+ return void 0;
2353
2357
  case "boolean":
2354
2358
  return astBuilder.InputValueDefinition({
2355
2359
  name: field.name,
@@ -2511,6 +2515,8 @@ var Builder = class {
2511
2515
  };
2512
2516
  _buildFieldMutation = async (field) => {
2513
2517
  switch (field.type) {
2518
+ case "displayOnly":
2519
+ return void 0;
2514
2520
  case "boolean":
2515
2521
  return astBuilder.InputValueDefinition({
2516
2522
  name: field.name,
@@ -2739,6 +2745,8 @@ Visit https://tina.io/docs/r/content-fields/#list-fields/ for more information
2739
2745
 
2740
2746
  `;
2741
2747
  switch (field.type) {
2748
+ case "displayOnly":
2749
+ return void 0;
2742
2750
  case "boolean":
2743
2751
  case "datetime":
2744
2752
  case "number":
@@ -2884,7 +2892,8 @@ var FIELD_TYPES = [
2884
2892
  "reference",
2885
2893
  "object",
2886
2894
  "rich-text",
2887
- "password"
2895
+ "password",
2896
+ "displayOnly"
2888
2897
  ];
2889
2898
  var validateSchema = async (schema) => {
2890
2899
  const schema2 = addNamespaceToSchema(
@@ -3026,7 +3035,7 @@ var validateField = async (field) => {
3026
3035
  var package_default = {
3027
3036
  name: "@tinacms/graphql",
3028
3037
  type: "module",
3029
- version: "2.2.3",
3038
+ version: "2.2.5",
3030
3039
  main: "dist/index.js",
3031
3040
  module: "./dist/index.js",
3032
3041
  files: [
@@ -3676,7 +3685,7 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
3676
3685
  `"${path9}" Found in multiple collections: ${filesSeen.get(path9).map((collection2) => `"${collection2}"`).join(
3677
3686
  ", "
3678
3687
  )}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
3679
- 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
3680
3689
  `
3681
3690
  );
3682
3691
  });
@@ -3783,7 +3792,7 @@ var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo)
3783
3792
  const template = getTemplateForFile(templateInfo, data);
3784
3793
  if (!template) {
3785
3794
  console.warn(
3786
- `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.`
3787
3796
  );
3788
3797
  return;
3789
3798
  }
@@ -4701,6 +4710,8 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
4701
4710
  assertShape(rawData, (yup3) => yup3.object());
4702
4711
  const value = rawData[field.name];
4703
4712
  switch (field.type) {
4713
+ case "displayOnly":
4714
+ break;
4704
4715
  case "datetime":
4705
4716
  if (value instanceof Date) {
4706
4717
  accumulator[field.name] = value.toISOString();
@@ -5194,6 +5205,26 @@ var Resolver = class _Resolver {
5194
5205
  }
5195
5206
  return input.replace(/\\/g, "/");
5196
5207
  }
5208
+ /**
5209
+ * Validates that relativePath is non-empty and contains only allowed
5210
+ * characters: a-z, A-Z, 0-9, hyphens, underscores, periods, and
5211
+ * forward slashes.
5212
+ */
5213
+ static validateRelativePath(relativePath) {
5214
+ if (!relativePath.trim()) {
5215
+ throw new Error(
5216
+ "Invalid path: relativePath cannot be empty or whitespace"
5217
+ );
5218
+ }
5219
+ if (relativePath !== relativePath.trim()) {
5220
+ throw new Error(
5221
+ "Invalid path: relativePath cannot have leading or trailing whitespace"
5222
+ );
5223
+ }
5224
+ if (!/^[a-zA-Z0-9\-_./]+$/.test(relativePath)) {
5225
+ throw new Error("Invalid path: relativePath contains invalid characters");
5226
+ }
5227
+ }
5197
5228
  validatePath = (fullPath, collection, relativePath) => {
5198
5229
  if (fullPath.includes("\0")) {
5199
5230
  throw new Error("Invalid path: null bytes are not allowed");
@@ -5208,6 +5239,7 @@ var Resolver = class _Resolver {
5208
5239
  throw new Error(`Invalid path: absolute paths are not allowed`);
5209
5240
  }
5210
5241
  if (relativePath) {
5242
+ _Resolver.validateRelativePath(relativePath);
5211
5243
  const collectionFormat = collection.format || "md";
5212
5244
  const fileExtension = path3.extname(relativePath).toLowerCase().slice(1);
5213
5245
  if (fileExtension !== collectionFormat) {
@@ -5228,6 +5260,7 @@ var Resolver = class _Resolver {
5228
5260
  * @returns Object containing the collection and validated real path
5229
5261
  */
5230
5262
  getValidatedPath = (collectionName, relativePath, options) => {
5263
+ _Resolver.validateRelativePath(relativePath);
5231
5264
  const collection = this.getCollectionWithName(collectionName);
5232
5265
  const sanitizedRelativePath = _Resolver.sanitizePath(relativePath);
5233
5266
  const pathSegments = [collection.path, sanitizedRelativePath];
@@ -5267,6 +5300,7 @@ var Resolver = class _Resolver {
5267
5300
  relativePath
5268
5301
  }) => {
5269
5302
  const collection = this.getCollectionWithName(collectionName);
5303
+ _Resolver.validateRelativePath(relativePath);
5270
5304
  const realPath = path3.join(
5271
5305
  collection.path,
5272
5306
  relativePath,
@@ -5873,6 +5907,8 @@ var Resolver = class _Resolver {
5873
5907
  throw new Error(`Expected to find field by name ${fieldName}`);
5874
5908
  }
5875
5909
  switch (field.type) {
5910
+ case "displayOnly":
5911
+ break;
5876
5912
  case "datetime":
5877
5913
  accum[fieldName] = resolveDateInput(fieldValue, field);
5878
5914
  break;
@@ -236,6 +236,12 @@ export declare class Resolver {
236
236
  * outside of the intended collection.
237
237
  */
238
238
  private static sanitizePath;
239
+ /**
240
+ * Validates that relativePath is non-empty and contains only allowed
241
+ * characters: a-z, A-Z, 0-9, hyphens, underscores, periods, and
242
+ * forward slashes.
243
+ */
244
+ private static validateRelativePath;
239
245
  private validatePath;
240
246
  /**
241
247
  * Helper method to get collection and construct validated path.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.2.5",
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.1",
47
- "@tinacms/schema-tools": "2.7.1"
46
+ "@tinacms/mdx": "2.1.2",
47
+ "@tinacms/schema-tools": "2.7.2"
48
48
  },
49
49
  "publishConfig": {
50
50
  "registry": "https://registry.npmjs.org"
@@ -72,8 +72,8 @@
72
72
  "vite": "^4.5.9",
73
73
  "vitest": "^0.32.4",
74
74
  "zod": "^3.24.2",
75
- "@tinacms/schema-tools": "2.7.1",
76
- "@tinacms/scripts": "1.6.0"
75
+ "@tinacms/scripts": "1.6.0",
76
+ "@tinacms/schema-tools": "2.7.2"
77
77
  },
78
78
  "scripts": {
79
79
  "types": "pnpm tsc",