@tinacms/graphql 1.5.7 → 1.5.8

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
@@ -148,6 +148,15 @@ var SysFieldDefinition = {
148
148
  arguments: [],
149
149
  directives: []
150
150
  },
151
+ {
152
+ kind: "Field",
153
+ name: {
154
+ kind: "Name",
155
+ value: "hasReferences"
156
+ },
157
+ arguments: [],
158
+ directives: []
159
+ },
151
160
  {
152
161
  kind: "Field",
153
162
  name: {
@@ -1257,6 +1266,11 @@ var scalarDefinitions = [
1257
1266
  required: true,
1258
1267
  type: astBuilder.TYPES.String
1259
1268
  }),
1269
+ astBuilder.FieldDefinition({
1270
+ name: "hasReferences",
1271
+ required: false,
1272
+ type: astBuilder.TYPES.Boolean
1273
+ }),
1260
1274
  astBuilder.FieldDefinition({
1261
1275
  name: "breadcrumbs",
1262
1276
  required: true,
@@ -2882,7 +2896,7 @@ var validateField = async (field) => {
2882
2896
  // package.json
2883
2897
  var package_default = {
2884
2898
  name: "@tinacms/graphql",
2885
- version: "1.5.7",
2899
+ version: "1.5.8",
2886
2900
  main: "dist/index.js",
2887
2901
  module: "dist/index.mjs",
2888
2902
  typings: "dist/index.d.ts",
@@ -2926,7 +2940,7 @@ var package_default = {
2926
2940
  "isomorphic-git": "^1.27.1",
2927
2941
  "js-sha1": "^0.6.0",
2928
2942
  "js-yaml": "^3.14.1",
2929
- "jsonpath-plus": "^6.0.1",
2943
+ "jsonpath-plus": "10.1.0",
2930
2944
  "lodash.clonedeep": "^4.5.0",
2931
2945
  "lodash.set": "^4.3.2",
2932
2946
  "lodash.uniqby": "^4.7.0",
@@ -2958,7 +2972,7 @@ var package_default = {
2958
2972
  "@types/lru-cache": "^5.1.1",
2959
2973
  "@types/mdast": "^3.0.15",
2960
2974
  "@types/micromatch": "^4.0.9",
2961
- "@types/node": "^22.7.4",
2975
+ "@types/node": "^22.9.0",
2962
2976
  "@types/normalize-path": "^3.0.2",
2963
2977
  "@types/ws": "^7.4.7",
2964
2978
  "@types/yup": "^0.29.14",
@@ -2968,7 +2982,7 @@ var package_default = {
2968
2982
  "jest-matcher-utils": "^29.7.0",
2969
2983
  "memory-level": "^1.0.0",
2970
2984
  nodemon: "3.1.4",
2971
- typescript: "^5.6.2"
2985
+ typescript: "^5.6.3"
2972
2986
  }
2973
2987
  };
2974
2988
 
@@ -3175,6 +3189,9 @@ var import_isValid = __toESM(require("date-fns/isValid/index.js"));
3175
3189
  // src/mdx/index.ts
3176
3190
  var import_mdx = require("@tinacms/mdx");
3177
3191
 
3192
+ // src/resolver/index.ts
3193
+ var import_jsonpath_plus2 = require("jsonpath-plus");
3194
+
3178
3195
  // src/resolver/error.ts
3179
3196
  var TinaGraphQLError = class extends Error {
3180
3197
  constructor(message, extensions) {
@@ -4541,7 +4558,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
4541
4558
  }
4542
4559
  return accumulator;
4543
4560
  };
4544
- var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit) => {
4561
+ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit, hasReferences) => {
4545
4562
  const collection = tinaSchema.getCollection(rawData._collection);
4546
4563
  try {
4547
4564
  const template = tinaSchema.getTemplateForData({
@@ -4595,6 +4612,7 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4595
4612
  basename,
4596
4613
  filename,
4597
4614
  extension,
4615
+ hasReferences,
4598
4616
  path: fullPath,
4599
4617
  relativePath,
4600
4618
  breadcrumbs,
@@ -4614,6 +4632,25 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4614
4632
  throw e;
4615
4633
  }
4616
4634
  };
4635
+ var updateObjectWithJsonPath = (obj, path7, newValue) => {
4636
+ if (!path7.includes(".") && !path7.includes("[")) {
4637
+ if (path7 in obj) {
4638
+ obj[path7] = newValue;
4639
+ }
4640
+ return obj;
4641
+ }
4642
+ const parentPath = path7.replace(/\.[^.]+$/, "");
4643
+ const keyToUpdate = path7.match(/[^.]+$/)[0];
4644
+ const parents = (0, import_jsonpath_plus2.JSONPath)({ path: parentPath, json: obj, resultType: "value" });
4645
+ if (parents.length > 0) {
4646
+ parents.forEach((parent) => {
4647
+ if (parent && typeof parent === "object" && keyToUpdate in parent) {
4648
+ parent[keyToUpdate] = newValue;
4649
+ }
4650
+ });
4651
+ }
4652
+ return obj;
4653
+ };
4617
4654
  var Resolver = class {
4618
4655
  constructor(init) {
4619
4656
  this.init = init;
@@ -4655,17 +4692,19 @@ var Resolver = class {
4655
4692
  );
4656
4693
  }
4657
4694
  };
4658
- this.getDocument = async (fullPath) => {
4695
+ this.getDocument = async (fullPath, opts = {}) => {
4659
4696
  if (typeof fullPath !== "string") {
4660
4697
  throw new Error(`fullPath must be of type string for getDocument request`);
4661
4698
  }
4662
4699
  const rawData = await this.getRaw(fullPath);
4700
+ const hasReferences = (opts == null ? void 0 : opts.checkReferences) ? await this.hasReferences(fullPath, opts.collection) : void 0;
4663
4701
  return transformDocumentIntoPayload(
4664
4702
  fullPath,
4665
4703
  rawData,
4666
4704
  this.tinaSchema,
4667
4705
  this.config,
4668
- this.isAudit
4706
+ this.isAudit,
4707
+ hasReferences
4669
4708
  );
4670
4709
  };
4671
4710
  this.deleteDocument = async (fullPath) => {
@@ -4969,6 +5008,22 @@ var Resolver = class {
4969
5008
  if (isDeletion) {
4970
5009
  const doc = await this.getDocument(realPath);
4971
5010
  await this.deleteDocument(realPath);
5011
+ if (await this.hasReferences(realPath, collection)) {
5012
+ const collRefs = await this.findReferences(realPath, collection);
5013
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
5014
+ for (const [refPath, refs] of Object.entries(refFields)) {
5015
+ let refDoc = await this.getRaw(refPath);
5016
+ for (const ref of refs) {
5017
+ refDoc = updateObjectWithJsonPath(
5018
+ refDoc,
5019
+ ref.path.join("."),
5020
+ null
5021
+ );
5022
+ }
5023
+ await this.database.put(refPath, refDoc, collection2);
5024
+ }
5025
+ }
5026
+ }
4972
5027
  return doc;
4973
5028
  }
4974
5029
  if (isUpdateName) {
@@ -4987,6 +5042,20 @@ var Resolver = class {
4987
5042
  );
4988
5043
  await this.database.put(newRealPath, doc._rawData, collection.name);
4989
5044
  await this.deleteDocument(realPath);
5045
+ const collRefs = await this.findReferences(realPath, collection);
5046
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
5047
+ for (const [refPath, refs] of Object.entries(refFields)) {
5048
+ let refDoc = await this.getRaw(refPath);
5049
+ for (const ref of refs) {
5050
+ refDoc = updateObjectWithJsonPath(
5051
+ refDoc,
5052
+ ref.path.join("."),
5053
+ newRealPath
5054
+ );
5055
+ }
5056
+ await this.database.put(refPath, refDoc, collection2);
5057
+ }
5058
+ }
4990
5059
  return this.getDocument(newRealPath);
4991
5060
  }
4992
5061
  if (alreadyExists === false) {
@@ -5000,7 +5069,10 @@ var Resolver = class {
5000
5069
  isCollectionSpecific
5001
5070
  });
5002
5071
  } else {
5003
- return this.getDocument(realPath);
5072
+ return this.getDocument(realPath, {
5073
+ collection,
5074
+ checkReferences: true
5075
+ });
5004
5076
  }
5005
5077
  };
5006
5078
  this.resolveCollectionConnections = async ({ ids }) => {
@@ -5104,6 +5176,80 @@ var Resolver = class {
5104
5176
  }
5105
5177
  };
5106
5178
  };
5179
+ this.hasReferences = async (id, c) => {
5180
+ let count = 0;
5181
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5182
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5183
+ for (const ref of refs) {
5184
+ await this.database.query(
5185
+ {
5186
+ collection,
5187
+ filterChain: makeFilterChain({
5188
+ conditions: [
5189
+ {
5190
+ filterPath: ref.path.join("."),
5191
+ filterExpression: {
5192
+ _type: "reference",
5193
+ _list: false,
5194
+ eq: id
5195
+ }
5196
+ }
5197
+ ]
5198
+ }),
5199
+ sort: ref.field.name
5200
+ },
5201
+ (refId) => {
5202
+ count++;
5203
+ return refId;
5204
+ }
5205
+ );
5206
+ if (count) {
5207
+ return true;
5208
+ }
5209
+ }
5210
+ }
5211
+ return false;
5212
+ };
5213
+ this.findReferences = async (id, c) => {
5214
+ const references = {};
5215
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5216
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5217
+ for (const ref of refs) {
5218
+ await this.database.query(
5219
+ {
5220
+ collection,
5221
+ filterChain: makeFilterChain({
5222
+ conditions: [
5223
+ {
5224
+ filterPath: ref.path.join("."),
5225
+ filterExpression: {
5226
+ _type: "reference",
5227
+ _list: false,
5228
+ eq: id
5229
+ }
5230
+ }
5231
+ ]
5232
+ }),
5233
+ sort: ref.field.name
5234
+ },
5235
+ (refId) => {
5236
+ if (!references[collection]) {
5237
+ references[collection] = {};
5238
+ }
5239
+ if (!references[collection][refId]) {
5240
+ references[collection][refId] = [];
5241
+ }
5242
+ references[collection][refId].push({
5243
+ path: ref.path,
5244
+ field: ref.field
5245
+ });
5246
+ return refId;
5247
+ }
5248
+ );
5249
+ }
5250
+ }
5251
+ return references;
5252
+ };
5107
5253
  this.buildFieldMutations = async (fieldParams, template, existingData) => {
5108
5254
  var _a;
5109
5255
  const accum = {};
package/dist/index.mjs CHANGED
@@ -86,6 +86,15 @@ var SysFieldDefinition = {
86
86
  arguments: [],
87
87
  directives: []
88
88
  },
89
+ {
90
+ kind: "Field",
91
+ name: {
92
+ kind: "Name",
93
+ value: "hasReferences"
94
+ },
95
+ arguments: [],
96
+ directives: []
97
+ },
89
98
  {
90
99
  kind: "Field",
91
100
  name: {
@@ -1195,6 +1204,11 @@ var scalarDefinitions = [
1195
1204
  required: true,
1196
1205
  type: astBuilder.TYPES.String
1197
1206
  }),
1207
+ astBuilder.FieldDefinition({
1208
+ name: "hasReferences",
1209
+ required: false,
1210
+ type: astBuilder.TYPES.Boolean
1211
+ }),
1198
1212
  astBuilder.FieldDefinition({
1199
1213
  name: "breadcrumbs",
1200
1214
  required: true,
@@ -2815,7 +2829,7 @@ var validateField = async (field) => {
2815
2829
  // package.json
2816
2830
  var package_default = {
2817
2831
  name: "@tinacms/graphql",
2818
- version: "1.5.7",
2832
+ version: "1.5.8",
2819
2833
  main: "dist/index.js",
2820
2834
  module: "dist/index.mjs",
2821
2835
  typings: "dist/index.d.ts",
@@ -2859,7 +2873,7 @@ var package_default = {
2859
2873
  "isomorphic-git": "^1.27.1",
2860
2874
  "js-sha1": "^0.6.0",
2861
2875
  "js-yaml": "^3.14.1",
2862
- "jsonpath-plus": "^6.0.1",
2876
+ "jsonpath-plus": "10.1.0",
2863
2877
  "lodash.clonedeep": "^4.5.0",
2864
2878
  "lodash.set": "^4.3.2",
2865
2879
  "lodash.uniqby": "^4.7.0",
@@ -2891,7 +2905,7 @@ var package_default = {
2891
2905
  "@types/lru-cache": "^5.1.1",
2892
2906
  "@types/mdast": "^3.0.15",
2893
2907
  "@types/micromatch": "^4.0.9",
2894
- "@types/node": "^22.7.4",
2908
+ "@types/node": "^22.9.0",
2895
2909
  "@types/normalize-path": "^3.0.2",
2896
2910
  "@types/ws": "^7.4.7",
2897
2911
  "@types/yup": "^0.29.14",
@@ -2901,7 +2915,7 @@ var package_default = {
2901
2915
  "jest-matcher-utils": "^29.7.0",
2902
2916
  "memory-level": "^1.0.0",
2903
2917
  nodemon: "3.1.4",
2904
- typescript: "^5.6.2"
2918
+ typescript: "^5.6.3"
2905
2919
  }
2906
2920
  };
2907
2921
 
@@ -3107,6 +3121,9 @@ import isValid from "date-fns/isValid/index.js";
3107
3121
  // src/mdx/index.ts
3108
3122
  import { parseMDX, stringifyMDX } from "@tinacms/mdx";
3109
3123
 
3124
+ // src/resolver/index.ts
3125
+ import { JSONPath as JSONPath2 } from "jsonpath-plus";
3126
+
3110
3127
  // src/resolver/error.ts
3111
3128
  var TinaGraphQLError = class extends Error {
3112
3129
  constructor(message, extensions) {
@@ -4469,7 +4486,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
4469
4486
  }
4470
4487
  return accumulator;
4471
4488
  };
4472
- var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit) => {
4489
+ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit, hasReferences) => {
4473
4490
  const collection = tinaSchema.getCollection(rawData._collection);
4474
4491
  try {
4475
4492
  const template = tinaSchema.getTemplateForData({
@@ -4523,6 +4540,7 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4523
4540
  basename,
4524
4541
  filename,
4525
4542
  extension,
4543
+ hasReferences,
4526
4544
  path: fullPath,
4527
4545
  relativePath,
4528
4546
  breadcrumbs,
@@ -4542,6 +4560,25 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4542
4560
  throw e;
4543
4561
  }
4544
4562
  };
4563
+ var updateObjectWithJsonPath = (obj, path7, newValue) => {
4564
+ if (!path7.includes(".") && !path7.includes("[")) {
4565
+ if (path7 in obj) {
4566
+ obj[path7] = newValue;
4567
+ }
4568
+ return obj;
4569
+ }
4570
+ const parentPath = path7.replace(/\.[^.]+$/, "");
4571
+ const keyToUpdate = path7.match(/[^.]+$/)[0];
4572
+ const parents = JSONPath2({ path: parentPath, json: obj, resultType: "value" });
4573
+ if (parents.length > 0) {
4574
+ parents.forEach((parent) => {
4575
+ if (parent && typeof parent === "object" && keyToUpdate in parent) {
4576
+ parent[keyToUpdate] = newValue;
4577
+ }
4578
+ });
4579
+ }
4580
+ return obj;
4581
+ };
4545
4582
  var Resolver = class {
4546
4583
  constructor(init) {
4547
4584
  this.init = init;
@@ -4583,17 +4620,19 @@ var Resolver = class {
4583
4620
  );
4584
4621
  }
4585
4622
  };
4586
- this.getDocument = async (fullPath) => {
4623
+ this.getDocument = async (fullPath, opts = {}) => {
4587
4624
  if (typeof fullPath !== "string") {
4588
4625
  throw new Error(`fullPath must be of type string for getDocument request`);
4589
4626
  }
4590
4627
  const rawData = await this.getRaw(fullPath);
4628
+ const hasReferences = opts?.checkReferences ? await this.hasReferences(fullPath, opts.collection) : void 0;
4591
4629
  return transformDocumentIntoPayload(
4592
4630
  fullPath,
4593
4631
  rawData,
4594
4632
  this.tinaSchema,
4595
4633
  this.config,
4596
- this.isAudit
4634
+ this.isAudit,
4635
+ hasReferences
4597
4636
  );
4598
4637
  };
4599
4638
  this.deleteDocument = async (fullPath) => {
@@ -4896,6 +4935,22 @@ var Resolver = class {
4896
4935
  if (isDeletion) {
4897
4936
  const doc = await this.getDocument(realPath);
4898
4937
  await this.deleteDocument(realPath);
4938
+ if (await this.hasReferences(realPath, collection)) {
4939
+ const collRefs = await this.findReferences(realPath, collection);
4940
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
4941
+ for (const [refPath, refs] of Object.entries(refFields)) {
4942
+ let refDoc = await this.getRaw(refPath);
4943
+ for (const ref of refs) {
4944
+ refDoc = updateObjectWithJsonPath(
4945
+ refDoc,
4946
+ ref.path.join("."),
4947
+ null
4948
+ );
4949
+ }
4950
+ await this.database.put(refPath, refDoc, collection2);
4951
+ }
4952
+ }
4953
+ }
4899
4954
  return doc;
4900
4955
  }
4901
4956
  if (isUpdateName) {
@@ -4914,6 +4969,20 @@ var Resolver = class {
4914
4969
  );
4915
4970
  await this.database.put(newRealPath, doc._rawData, collection.name);
4916
4971
  await this.deleteDocument(realPath);
4972
+ const collRefs = await this.findReferences(realPath, collection);
4973
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
4974
+ for (const [refPath, refs] of Object.entries(refFields)) {
4975
+ let refDoc = await this.getRaw(refPath);
4976
+ for (const ref of refs) {
4977
+ refDoc = updateObjectWithJsonPath(
4978
+ refDoc,
4979
+ ref.path.join("."),
4980
+ newRealPath
4981
+ );
4982
+ }
4983
+ await this.database.put(refPath, refDoc, collection2);
4984
+ }
4985
+ }
4917
4986
  return this.getDocument(newRealPath);
4918
4987
  }
4919
4988
  if (alreadyExists === false) {
@@ -4927,7 +4996,10 @@ var Resolver = class {
4927
4996
  isCollectionSpecific
4928
4997
  });
4929
4998
  } else {
4930
- return this.getDocument(realPath);
4999
+ return this.getDocument(realPath, {
5000
+ collection,
5001
+ checkReferences: true
5002
+ });
4931
5003
  }
4932
5004
  };
4933
5005
  this.resolveCollectionConnections = async ({ ids }) => {
@@ -5031,6 +5103,80 @@ var Resolver = class {
5031
5103
  }
5032
5104
  };
5033
5105
  };
5106
+ this.hasReferences = async (id, c) => {
5107
+ let count = 0;
5108
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5109
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5110
+ for (const ref of refs) {
5111
+ await this.database.query(
5112
+ {
5113
+ collection,
5114
+ filterChain: makeFilterChain({
5115
+ conditions: [
5116
+ {
5117
+ filterPath: ref.path.join("."),
5118
+ filterExpression: {
5119
+ _type: "reference",
5120
+ _list: false,
5121
+ eq: id
5122
+ }
5123
+ }
5124
+ ]
5125
+ }),
5126
+ sort: ref.field.name
5127
+ },
5128
+ (refId) => {
5129
+ count++;
5130
+ return refId;
5131
+ }
5132
+ );
5133
+ if (count) {
5134
+ return true;
5135
+ }
5136
+ }
5137
+ }
5138
+ return false;
5139
+ };
5140
+ this.findReferences = async (id, c) => {
5141
+ const references = {};
5142
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5143
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5144
+ for (const ref of refs) {
5145
+ await this.database.query(
5146
+ {
5147
+ collection,
5148
+ filterChain: makeFilterChain({
5149
+ conditions: [
5150
+ {
5151
+ filterPath: ref.path.join("."),
5152
+ filterExpression: {
5153
+ _type: "reference",
5154
+ _list: false,
5155
+ eq: id
5156
+ }
5157
+ }
5158
+ ]
5159
+ }),
5160
+ sort: ref.field.name
5161
+ },
5162
+ (refId) => {
5163
+ if (!references[collection]) {
5164
+ references[collection] = {};
5165
+ }
5166
+ if (!references[collection][refId]) {
5167
+ references[collection][refId] = [];
5168
+ }
5169
+ references[collection][refId].push({
5170
+ path: ref.path,
5171
+ field: ref.field
5172
+ });
5173
+ return refId;
5174
+ }
5175
+ );
5176
+ }
5177
+ }
5178
+ return references;
5179
+ };
5034
5180
  this.buildFieldMutations = async (fieldParams, template, existingData) => {
5035
5181
  const accum = {};
5036
5182
  for (const passwordField of template.fields.filter(
@@ -14,12 +14,13 @@ export declare const createResolver: (args: ResolverConfig) => Resolver;
14
14
  export declare const transformDocumentIntoPayload: (fullPath: string, rawData: {
15
15
  _collection: any;
16
16
  _template: any;
17
- }, tinaSchema: TinaSchema, config?: GraphQLConfig, isAudit?: boolean) => Promise<{
17
+ }, tinaSchema: TinaSchema, config?: GraphQLConfig, isAudit?: boolean, hasReferences?: boolean) => Promise<{
18
18
  _sys: {
19
19
  title: any;
20
20
  basename: string;
21
21
  filename: string;
22
22
  extension: string;
23
+ hasReferences: boolean;
23
24
  path: string;
24
25
  relativePath: string;
25
26
  breadcrumbs: string[];
@@ -117,6 +118,7 @@ export declare class Resolver {
117
118
  basename: string;
118
119
  filename: string;
119
120
  extension: string;
121
+ hasReferences: boolean;
120
122
  path: string;
121
123
  relativePath: string;
122
124
  breadcrumbs: string[];
@@ -140,12 +142,16 @@ export declare class Resolver {
140
142
  name: any;
141
143
  path: any;
142
144
  }>;
143
- getDocument: (fullPath: unknown) => Promise<{
145
+ getDocument: (fullPath: unknown, opts?: {
146
+ collection?: Collection<true>;
147
+ checkReferences?: boolean;
148
+ }) => Promise<{
144
149
  _sys: {
145
150
  title: any;
146
151
  basename: string;
147
152
  filename: string;
148
153
  extension: string;
154
+ hasReferences: boolean;
149
155
  path: string;
150
156
  relativePath: string;
151
157
  breadcrumbs: string[];
@@ -184,6 +190,7 @@ export declare class Resolver {
184
190
  basename: string;
185
191
  filename: string;
186
192
  extension: string;
193
+ hasReferences: boolean;
187
194
  path: string;
188
195
  relativePath: string;
189
196
  breadcrumbs: string[];
@@ -215,6 +222,7 @@ export declare class Resolver {
215
222
  basename: string;
216
223
  filename: string;
217
224
  extension: string;
225
+ hasReferences: boolean;
218
226
  path: string;
219
227
  relativePath: string;
220
228
  breadcrumbs: string[];
@@ -255,6 +263,7 @@ export declare class Resolver {
255
263
  basename: string;
256
264
  filename: string;
257
265
  extension: string;
266
+ hasReferences: boolean;
258
267
  path: string;
259
268
  relativePath: string;
260
269
  breadcrumbs: string[];
@@ -285,6 +294,7 @@ export declare class Resolver {
285
294
  basename: string;
286
295
  filename: string;
287
296
  extension: string;
297
+ hasReferences: boolean;
288
298
  path: string;
289
299
  relativePath: string;
290
300
  breadcrumbs: string[];
@@ -325,6 +335,20 @@ export declare class Resolver {
325
335
  endCursor: string;
326
336
  };
327
337
  }>;
338
+ /**
339
+ * Checks if a document has references to it
340
+ * @param id The id of the document to check for references
341
+ * @param c The collection to check for references
342
+ * @returns true if the document has references, false otherwise
343
+ */
344
+ private hasReferences;
345
+ /**
346
+ * Finds references to a document
347
+ * @param id the id of the document to find references to
348
+ * @param c the collection to find references in
349
+ * @returns references to the document in the form of a map of collection names to a list of fields that reference the document
350
+ */
351
+ private findReferences;
328
352
  private buildFieldMutations;
329
353
  /**
330
354
  * A mutation looks nearly identical between updateDocument:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "typings": "dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "isomorphic-git": "^1.27.1",
35
35
  "js-sha1": "^0.6.0",
36
36
  "js-yaml": "^3.14.1",
37
- "jsonpath-plus": "^6.0.1",
37
+ "jsonpath-plus": "10.1.0",
38
38
  "lodash.clonedeep": "^4.5.0",
39
39
  "lodash.set": "^4.3.2",
40
40
  "lodash.uniqby": "^4.7.0",
@@ -44,8 +44,8 @@
44
44
  "readable-stream": "^4.5.2",
45
45
  "scmp": "^2.1.0",
46
46
  "yup": "^0.32.11",
47
- "@tinacms/mdx": "1.5.1",
48
- "@tinacms/schema-tools": "1.6.7"
47
+ "@tinacms/mdx": "1.5.2",
48
+ "@tinacms/schema-tools": "1.6.8"
49
49
  },
50
50
  "publishConfig": {
51
51
  "registry": "https://registry.npmjs.org"
@@ -66,7 +66,7 @@
66
66
  "@types/lru-cache": "^5.1.1",
67
67
  "@types/mdast": "^3.0.15",
68
68
  "@types/micromatch": "^4.0.9",
69
- "@types/node": "^22.7.4",
69
+ "@types/node": "^22.9.0",
70
70
  "@types/normalize-path": "^3.0.2",
71
71
  "@types/ws": "^7.4.7",
72
72
  "@types/yup": "^0.29.14",
@@ -76,9 +76,9 @@
76
76
  "jest-matcher-utils": "^29.7.0",
77
77
  "memory-level": "^1.0.0",
78
78
  "nodemon": "3.1.4",
79
- "typescript": "^5.6.2",
80
- "@tinacms/scripts": "1.3.0",
81
- "@tinacms/schema-tools": "1.6.7"
79
+ "typescript": "^5.6.3",
80
+ "@tinacms/scripts": "1.3.1",
81
+ "@tinacms/schema-tools": "1.6.8"
82
82
  },
83
83
  "scripts": {
84
84
  "types": "pnpm tsc",