@tinacms/graphql 0.0.0-d69e892-20241003042309 → 0.0.0-d7c5ec1-20250219020924

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
@@ -17,14 +17,18 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
23
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
28
 
25
29
  // src/index.ts
26
- var src_exports = {};
27
- __export(src_exports, {
30
+ var index_exports = {};
31
+ __export(index_exports, {
28
32
  AuditFileSystemBridge: () => AuditFileSystemBridge,
29
33
  Database: () => Database,
30
34
  FilesystemBridge: () => FilesystemBridge,
@@ -58,7 +62,7 @@ __export(src_exports, {
58
62
  transformDocument: () => transformDocument,
59
63
  transformDocumentIntoPayload: () => transformDocumentIntoPayload
60
64
  });
61
- module.exports = __toCommonJS(src_exports);
65
+ module.exports = __toCommonJS(index_exports);
62
66
 
63
67
  // src/build.ts
64
68
  var import_graphql2 = require("graphql");
@@ -130,6 +134,15 @@ var SysFieldDefinition = {
130
134
  selectionSet: {
131
135
  kind: "SelectionSet",
132
136
  selections: [
137
+ // {
138
+ // kind: 'Field' as const,
139
+ // name: {
140
+ // kind: 'Name' as const,
141
+ // value: 'title',
142
+ // },
143
+ // arguments: [],
144
+ // directives: [],
145
+ // },
133
146
  {
134
147
  kind: "Field",
135
148
  name: {
@@ -148,6 +161,15 @@ var SysFieldDefinition = {
148
161
  arguments: [],
149
162
  directives: []
150
163
  },
164
+ {
165
+ kind: "Field",
166
+ name: {
167
+ kind: "Name",
168
+ value: "hasReferences"
169
+ },
170
+ arguments: [],
171
+ directives: []
172
+ },
151
173
  {
152
174
  kind: "Field",
153
175
  name: {
@@ -188,6 +210,10 @@ var SysFieldDefinition = {
188
210
  }
189
211
  };
190
212
  var astBuilder = {
213
+ /**
214
+ * `FormFieldBuilder` acts as a shortcut to building an entire `ObjectTypeDefinition`, we use this
215
+ * because all Tina field objects share a common set of fields ('name', 'label', 'component')
216
+ */
191
217
  FormFieldBuilder: ({
192
218
  name,
193
219
  additionalFields
@@ -411,6 +437,8 @@ var astBuilder = {
411
437
  kind: "Name",
412
438
  value: name
413
439
  },
440
+ // @ts-ignore FIXME; this is being handled properly but we're lying to
441
+ // ts and then fixing it in the `extractInlineTypes` function
414
442
  fields
415
443
  }),
416
444
  UnionTypeDefinition: ({
@@ -423,6 +451,8 @@ var astBuilder = {
423
451
  value: name
424
452
  },
425
453
  directives: [],
454
+ // @ts-ignore FIXME; this is being handled properly but we're lying to
455
+ // ts and then fixing it in the `extractInlineTypes` function
426
456
  types: types.map((name2) => ({
427
457
  kind: "NamedType",
428
458
  name: {
@@ -519,8 +549,11 @@ var astBuilder = {
519
549
  string: "String",
520
550
  boolean: "Boolean",
521
551
  number: "Float",
552
+ // FIXME - needs to be float or int
522
553
  datetime: "String",
554
+ // FIXME
523
555
  image: "String",
556
+ // FIXME
524
557
  text: "String"
525
558
  };
526
559
  return scalars[type];
@@ -1019,8 +1052,7 @@ var astBuilder = {
1019
1052
  }
1020
1053
  };
1021
1054
  var capitalize = (s) => {
1022
- if (typeof s !== "string")
1023
- return "";
1055
+ if (typeof s !== "string") return "";
1024
1056
  return s.charAt(0).toUpperCase() + s.slice(1);
1025
1057
  };
1026
1058
  var extractInlineTypes = (item) => {
@@ -1063,41 +1095,6 @@ function* walk(maybeNode, visited = /* @__PURE__ */ new WeakSet()) {
1063
1095
  yield maybeNode;
1064
1096
  visited.add(maybeNode);
1065
1097
  }
1066
- function addNamespaceToSchema(maybeNode, namespace = []) {
1067
- if (typeof maybeNode === "string") {
1068
- return maybeNode;
1069
- }
1070
- if (typeof maybeNode === "boolean") {
1071
- return maybeNode;
1072
- }
1073
- const newNode = maybeNode;
1074
- const keys = Object.keys(maybeNode);
1075
- Object.values(maybeNode).map((m, index) => {
1076
- const key = keys[index];
1077
- if (Array.isArray(m)) {
1078
- newNode[key] = m.map((element) => {
1079
- if (!element) {
1080
- return;
1081
- }
1082
- if (!element.hasOwnProperty("name")) {
1083
- return element;
1084
- }
1085
- const value = element.name || element.value;
1086
- return addNamespaceToSchema(element, [...namespace, value]);
1087
- });
1088
- } else {
1089
- if (!m) {
1090
- return;
1091
- }
1092
- if (!m.hasOwnProperty("name")) {
1093
- newNode[key] = m;
1094
- } else {
1095
- newNode[key] = addNamespaceToSchema(m, [...namespace, m.name]);
1096
- }
1097
- }
1098
- });
1099
- return { ...newNode, namespace };
1100
- }
1101
1098
  var generateNamespacedFieldName = (names, suffix = "") => {
1102
1099
  return (suffix ? [...names, suffix] : names).map(capitalize).join("");
1103
1100
  };
@@ -1257,6 +1254,11 @@ var scalarDefinitions = [
1257
1254
  required: true,
1258
1255
  type: astBuilder.TYPES.String
1259
1256
  }),
1257
+ astBuilder.FieldDefinition({
1258
+ name: "hasReferences",
1259
+ required: false,
1260
+ type: astBuilder.TYPES.Boolean
1261
+ }),
1260
1262
  astBuilder.FieldDefinition({
1261
1263
  name: "breadcrumbs",
1262
1264
  required: true,
@@ -1471,6 +1473,19 @@ var Builder = class {
1471
1473
  this.addToLookupMap = (lookup) => {
1472
1474
  this.lookupMap[lookup.type] = lookup;
1473
1475
  };
1476
+ /**
1477
+ * ```graphql
1478
+ * # ex.
1479
+ * {
1480
+ * getCollection(collection: $collection) {
1481
+ * name
1482
+ * documents {...}
1483
+ * }
1484
+ * }
1485
+ * ```
1486
+ *
1487
+ * @param collections
1488
+ */
1474
1489
  this.buildCollectionDefinition = async (collections) => {
1475
1490
  const name = "collection";
1476
1491
  const typeName = "Collection";
@@ -1541,6 +1556,19 @@ var Builder = class {
1541
1556
  required: true
1542
1557
  });
1543
1558
  };
1559
+ /**
1560
+ * ```graphql
1561
+ * # ex.
1562
+ * {
1563
+ * getCollections {
1564
+ * name
1565
+ * documents {...}
1566
+ * }
1567
+ * }
1568
+ * ```
1569
+ *
1570
+ * @param collections
1571
+ */
1544
1572
  this.buildMultiCollectionDefinition = async (collections) => {
1545
1573
  const name = "collections";
1546
1574
  const typeName = "Collection";
@@ -1551,6 +1579,17 @@ var Builder = class {
1551
1579
  required: true
1552
1580
  });
1553
1581
  };
1582
+ /**
1583
+ * ```graphql
1584
+ * # ex.
1585
+ * {
1586
+ * node(id: $id) {
1587
+ * id
1588
+ * data {...}
1589
+ * }
1590
+ * }
1591
+ * ```
1592
+ */
1554
1593
  this.multiNodeDocument = async () => {
1555
1594
  const name = "node";
1556
1595
  const args = [
@@ -1571,6 +1610,19 @@ var Builder = class {
1571
1610
  required: true
1572
1611
  });
1573
1612
  };
1613
+ /**
1614
+ * ```graphql
1615
+ * # ex.
1616
+ * {
1617
+ * getDocument(collection: $collection, relativePath: $relativePath) {
1618
+ * id
1619
+ * data {...}
1620
+ * }
1621
+ * }
1622
+ * ```
1623
+ *
1624
+ * @param collections
1625
+ */
1574
1626
  this.multiCollectionDocument = async (collections) => {
1575
1627
  const name = "document";
1576
1628
  const args = [
@@ -1596,6 +1648,19 @@ var Builder = class {
1596
1648
  required: true
1597
1649
  });
1598
1650
  };
1651
+ /**
1652
+ * ```graphql
1653
+ * # ex.
1654
+ * {
1655
+ * addPendingDocument(collection: $collection, relativePath: $relativePath, params: $params) {
1656
+ * id
1657
+ * data {...}
1658
+ * }
1659
+ * }
1660
+ * ```
1661
+ *
1662
+ * @param collections
1663
+ */
1599
1664
  this.addMultiCollectionDocumentMutation = async () => {
1600
1665
  return astBuilder.FieldDefinition({
1601
1666
  name: "addPendingDocument",
@@ -1620,6 +1685,19 @@ var Builder = class {
1620
1685
  type: astBuilder.TYPES.MultiCollectionDocument
1621
1686
  });
1622
1687
  };
1688
+ /**
1689
+ * ```graphql
1690
+ * # ex.
1691
+ * {
1692
+ * createDocument(relativePath: $relativePath, params: $params) {
1693
+ * id
1694
+ * data {...}
1695
+ * }
1696
+ * }
1697
+ * ```
1698
+ *
1699
+ * @param collections
1700
+ */
1623
1701
  this.buildCreateCollectionDocumentMutation = async (collections) => {
1624
1702
  return astBuilder.FieldDefinition({
1625
1703
  name: "createDocument",
@@ -1647,6 +1725,19 @@ var Builder = class {
1647
1725
  type: astBuilder.TYPES.MultiCollectionDocument
1648
1726
  });
1649
1727
  };
1728
+ /**
1729
+ * ```graphql
1730
+ * # ex.
1731
+ * {
1732
+ * updateDocument(relativePath: $relativePath, params: $params) {
1733
+ * id
1734
+ * data {...}
1735
+ * }
1736
+ * }
1737
+ * ```
1738
+ *
1739
+ * @param collections
1740
+ */
1650
1741
  this.buildUpdateCollectionDocumentMutation = async (collections) => {
1651
1742
  return astBuilder.FieldDefinition({
1652
1743
  name: "updateDocument",
@@ -1674,6 +1765,19 @@ var Builder = class {
1674
1765
  type: astBuilder.TYPES.MultiCollectionDocument
1675
1766
  });
1676
1767
  };
1768
+ /**
1769
+ * ```graphql
1770
+ * # ex.
1771
+ * {
1772
+ * deleteDocument(relativePath: $relativePath, params: $params) {
1773
+ * id
1774
+ * data {...}
1775
+ * }
1776
+ * }
1777
+ * ```
1778
+ *
1779
+ * @param collections
1780
+ */
1677
1781
  this.buildDeleteCollectionDocumentMutation = async (collections) => {
1678
1782
  return astBuilder.FieldDefinition({
1679
1783
  name: "deleteDocument",
@@ -1693,6 +1797,19 @@ var Builder = class {
1693
1797
  type: astBuilder.TYPES.MultiCollectionDocument
1694
1798
  });
1695
1799
  };
1800
+ /**
1801
+ * ```graphql
1802
+ * # ex.
1803
+ * {
1804
+ * createFolder(folderName: $folderName, params: $params) {
1805
+ * id
1806
+ * data {...}
1807
+ * }
1808
+ * }
1809
+ * ```
1810
+ *
1811
+ * @param collections
1812
+ */
1696
1813
  this.buildCreateCollectionFolderMutation = async () => {
1697
1814
  return astBuilder.FieldDefinition({
1698
1815
  name: "createFolder",
@@ -1712,6 +1829,19 @@ var Builder = class {
1712
1829
  type: astBuilder.TYPES.MultiCollectionDocument
1713
1830
  });
1714
1831
  };
1832
+ /**
1833
+ * ```graphql
1834
+ * # ex.
1835
+ * {
1836
+ * getPostDocument(relativePath: $relativePath) {
1837
+ * id
1838
+ * data {...}
1839
+ * }
1840
+ * }
1841
+ * ```
1842
+ *
1843
+ * @param collection
1844
+ */
1715
1845
  this.collectionDocument = async (collection) => {
1716
1846
  const name = NAMER.queryName([collection.name]);
1717
1847
  const type = await this._buildCollectionDocumentType(collection);
@@ -1772,6 +1902,20 @@ var Builder = class {
1772
1902
  const args = [];
1773
1903
  return astBuilder.FieldDefinition({ type, name, args, required: false });
1774
1904
  };
1905
+ /**
1906
+ * Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
1907
+ * ```graphql
1908
+ * # ex.
1909
+ * fragment AuthorsParts on Authors {
1910
+ * name
1911
+ * avatar
1912
+ * ...
1913
+ * }
1914
+ * ```
1915
+ *
1916
+ * @public
1917
+ * @param collection a Tina Cloud collection
1918
+ */
1775
1919
  this.collectionFragment = async (collection) => {
1776
1920
  const name = NAMER.dataTypeName(collection.namespace);
1777
1921
  const fragmentName = NAMER.fragmentName(collection.namespace);
@@ -1785,6 +1929,20 @@ var Builder = class {
1785
1929
  selections: filterSelections(selections)
1786
1930
  });
1787
1931
  };
1932
+ /**
1933
+ * Given a collection this function returns its selections set. For example for Post this would return
1934
+ *
1935
+ * "
1936
+ * body
1937
+ * title
1938
+ * ... on Author {
1939
+ * name
1940
+ * heroImg
1941
+ * }
1942
+ *
1943
+ * But in the AST format
1944
+ *
1945
+ * */
1788
1946
  this._getCollectionFragmentSelections = async (collection, depth) => {
1789
1947
  var _a;
1790
1948
  const selections = [];
@@ -1868,9 +2026,9 @@ var Builder = class {
1868
2026
  ]
1869
2027
  });
1870
2028
  }
2029
+ // TODO: Should we throw here?
1871
2030
  case "reference":
1872
- if (depth >= this.maxDepth)
1873
- return false;
2031
+ if (depth >= this.maxDepth) return false;
1874
2032
  if (!("collections" in field)) {
1875
2033
  return false;
1876
2034
  }
@@ -1902,6 +2060,7 @@ var Builder = class {
1902
2060
  name: field.name,
1903
2061
  selections: [
1904
2062
  ...selections,
2063
+ // This is ... on Document { id }
1905
2064
  {
1906
2065
  kind: "InlineFragment",
1907
2066
  typeCondition: {
@@ -1932,6 +2091,19 @@ var Builder = class {
1932
2091
  });
1933
2092
  }
1934
2093
  };
2094
+ /**
2095
+ * ```graphql
2096
+ * # ex.
2097
+ * mutation {
2098
+ * updatePostDocument(relativePath: $relativePath, params: $params) {
2099
+ * id
2100
+ * data {...}
2101
+ * }
2102
+ * }
2103
+ * ```
2104
+ *
2105
+ * @param collection
2106
+ */
1935
2107
  this.updateCollectionDocumentMutation = async (collection) => {
1936
2108
  return astBuilder.FieldDefinition({
1937
2109
  type: await this._buildCollectionDocumentType(collection),
@@ -1951,6 +2123,19 @@ var Builder = class {
1951
2123
  ]
1952
2124
  });
1953
2125
  };
2126
+ /**
2127
+ * ```graphql
2128
+ * # ex.
2129
+ * mutation {
2130
+ * createPostDocument(relativePath: $relativePath, params: $params) {
2131
+ * id
2132
+ * data {...}
2133
+ * }
2134
+ * }
2135
+ * ```
2136
+ *
2137
+ * @param collection
2138
+ */
1954
2139
  this.createCollectionDocumentMutation = async (collection) => {
1955
2140
  return astBuilder.FieldDefinition({
1956
2141
  type: await this._buildCollectionDocumentType(collection),
@@ -1970,6 +2155,22 @@ var Builder = class {
1970
2155
  ]
1971
2156
  });
1972
2157
  };
2158
+ /**
2159
+ * ```graphql
2160
+ * # ex.
2161
+ * {
2162
+ * getPostList(first: 10) {
2163
+ * edges {
2164
+ * node {
2165
+ * id
2166
+ * }
2167
+ * }
2168
+ * }
2169
+ * }
2170
+ * ```
2171
+ *
2172
+ * @param collection
2173
+ */
1973
2174
  this.collectionDocumentList = async (collection) => {
1974
2175
  const connectionName = NAMER.referenceConnectionType(collection.namespace);
1975
2176
  this.addToLookupMap({
@@ -1985,6 +2186,10 @@ var Builder = class {
1985
2186
  collection
1986
2187
  });
1987
2188
  };
2189
+ /**
2190
+ * GraphQL type definitions which remain unchanged regardless
2191
+ * of the supplied Tina schema. Ex. "node" interface
2192
+ */
1988
2193
  this.buildStaticDefinitions = () => staticDefinitions;
1989
2194
  this._buildCollectionDocumentType = async (collection, suffix = "", extraFields = [], extraInterfaces = []) => {
1990
2195
  const documentTypeName = NAMER.documentTypeName(collection.namespace);
@@ -2489,6 +2694,7 @@ var Builder = class {
2489
2694
  name: NAMER.dataFilterTypeName(namespace),
2490
2695
  fields: await sequential(collections, async (collection2) => {
2491
2696
  return astBuilder.InputValueDefinition({
2697
+ // @ts-ignore
2492
2698
  name: collection2.name,
2493
2699
  type: NAMER.dataFilterTypeName(collection2.namespace)
2494
2700
  });
@@ -2678,7 +2884,8 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
2678
2884
  });
2679
2885
  };
2680
2886
  var _a, _b, _c, _d;
2681
- this.maxDepth = (_d = (_c = (_b = (_a = config == null ? void 0 : config.tinaSchema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.client) == null ? void 0 : _c.referenceDepth) != null ? _d : 2;
2887
+ this.maxDepth = // @ts-ignore
2888
+ (_d = (_c = (_b = (_a = config == null ? void 0 : config.tinaSchema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.client) == null ? void 0 : _c.referenceDepth) != null ? _d : 2;
2682
2889
  this.tinaSchema = config.tinaSchema;
2683
2890
  this.lookupMap = {};
2684
2891
  }
@@ -2689,8 +2896,7 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
2689
2896
  selections.push(field);
2690
2897
  });
2691
2898
  const filteredSelections = filterSelections(selections);
2692
- if (!filteredSelections.length)
2693
- return false;
2899
+ if (!filteredSelections.length) return false;
2694
2900
  return astBuilder.InlineFragmentDefinition({
2695
2901
  selections: filteredSelections,
2696
2902
  name: NAMER.dataTypeName(template.namespace)
@@ -2724,12 +2930,13 @@ var filterSelections = (arr) => {
2724
2930
  };
2725
2931
 
2726
2932
  // src/schema/createSchema.ts
2727
- var import_schema_tools2 = require("@tinacms/schema-tools");
2933
+ var import_schema_tools3 = require("@tinacms/schema-tools");
2728
2934
 
2729
2935
  // src/schema/validate.ts
2936
+ var import_schema_tools = require("@tinacms/schema-tools");
2730
2937
  var import_lodash2 = __toESM(require("lodash.clonedeep"));
2731
2938
  var yup2 = __toESM(require("yup"));
2732
- var import_schema_tools = require("@tinacms/schema-tools");
2939
+ var import_schema_tools2 = require("@tinacms/schema-tools");
2733
2940
  var FIELD_TYPES = [
2734
2941
  "string",
2735
2942
  "number",
@@ -2742,7 +2949,7 @@ var FIELD_TYPES = [
2742
2949
  "password"
2743
2950
  ];
2744
2951
  var validateSchema = async (schema) => {
2745
- const schema2 = addNamespaceToSchema(
2952
+ const schema2 = (0, import_schema_tools.addNamespaceToSchema)(
2746
2953
  (0, import_lodash2.default)(schema)
2747
2954
  );
2748
2955
  const collections = await sequential(
@@ -2751,7 +2958,7 @@ var validateSchema = async (schema) => {
2751
2958
  );
2752
2959
  validationCollectionsPathAndMatch(collections);
2753
2960
  if (schema2.config) {
2754
- const config = (0, import_schema_tools.validateTinaCloudSchemaConfig)(schema2.config);
2961
+ const config = (0, import_schema_tools2.validateTinaCloudSchemaConfig)(schema2.config);
2755
2962
  return {
2756
2963
  collections,
2757
2964
  config
@@ -2771,6 +2978,7 @@ var validationCollectionsPathAndMatch = (collections) => {
2771
2978
  }).map((x) => `${x.path}${x.format || "md"}`);
2772
2979
  if (noMatchCollections.length !== new Set(noMatchCollections).size) {
2773
2980
  throw new Error(
2981
+ // TODO: add a link to the docs
2774
2982
  "Two collections without match can not have the same `path`. Please make the `path` unique or add a matches property to the collection."
2775
2983
  );
2776
2984
  }
@@ -2882,7 +3090,7 @@ var validateField = async (field) => {
2882
3090
  // package.json
2883
3091
  var package_default = {
2884
3092
  name: "@tinacms/graphql",
2885
- version: "1.5.4",
3093
+ version: "1.5.12",
2886
3094
  main: "dist/index.js",
2887
3095
  module: "dist/index.mjs",
2888
3096
  typings: "dist/index.d.ts",
@@ -2909,8 +3117,8 @@ var package_default = {
2909
3117
  build: "tinacms-scripts build",
2910
3118
  docs: "pnpm typedoc",
2911
3119
  serve: "pnpm nodemon dist/server.js",
2912
- test: "jest",
2913
- "test-watch": "jest --watch"
3120
+ test: "vitest run",
3121
+ "test-watch": "vitest"
2914
3122
  },
2915
3123
  dependencies: {
2916
3124
  "@iarna/toml": "^2.2.5",
@@ -2918,22 +3126,22 @@ var package_default = {
2918
3126
  "@tinacms/schema-tools": "workspace:*",
2919
3127
  "abstract-level": "^1.0.4",
2920
3128
  "date-fns": "^2.30.0",
2921
- "fast-glob": "^3.3.2",
2922
- "fs-extra": "^11.2.0",
3129
+ "fast-glob": "^3.3.3",
3130
+ "fs-extra": "^11.3.0",
2923
3131
  "glob-parent": "^6.0.2",
2924
3132
  graphql: "15.8.0",
2925
3133
  "gray-matter": "^4.0.3",
2926
- "isomorphic-git": "^1.27.1",
3134
+ "isomorphic-git": "^1.29.0",
2927
3135
  "js-sha1": "^0.6.0",
2928
3136
  "js-yaml": "^3.14.1",
2929
- "jsonpath-plus": "^6.0.1",
3137
+ "jsonpath-plus": "10.1.0",
2930
3138
  "lodash.clonedeep": "^4.5.0",
2931
3139
  "lodash.set": "^4.3.2",
2932
3140
  "lodash.uniqby": "^4.7.0",
2933
3141
  "many-level": "^2.0.0",
2934
3142
  micromatch: "4.0.8",
2935
3143
  "normalize-path": "^3.0.0",
2936
- "readable-stream": "^4.5.2",
3144
+ "readable-stream": "^4.7.0",
2937
3145
  scmp: "^2.1.0",
2938
3146
  yup: "^0.32.11"
2939
3147
  },
@@ -2951,24 +3159,23 @@ var package_default = {
2951
3159
  "@types/estree": "^0.0.50",
2952
3160
  "@types/express": "^4.17.21",
2953
3161
  "@types/fs-extra": "^9.0.13",
2954
- "@types/jest": "^26.0.24",
2955
3162
  "@types/js-yaml": "^3.12.10",
2956
3163
  "@types/lodash.camelcase": "^4.3.9",
2957
3164
  "@types/lodash.upperfirst": "^4.3.9",
2958
3165
  "@types/lru-cache": "^5.1.1",
2959
3166
  "@types/mdast": "^3.0.15",
2960
3167
  "@types/micromatch": "^4.0.9",
2961
- "@types/node": "^22.7.4",
3168
+ "@types/node": "^22.13.1",
2962
3169
  "@types/normalize-path": "^3.0.2",
2963
3170
  "@types/ws": "^7.4.7",
2964
3171
  "@types/yup": "^0.29.14",
2965
- jest: "^29.7.0",
2966
- "jest-diff": "^29.7.0",
2967
3172
  "jest-file-snapshot": "^0.5.0",
2968
- "jest-matcher-utils": "^29.7.0",
2969
3173
  "memory-level": "^1.0.0",
2970
3174
  nodemon: "3.1.4",
2971
- typescript: "^5.6.2"
3175
+ typescript: "^5.7.3",
3176
+ vite: "^4.5.9",
3177
+ vitest: "^0.32.4",
3178
+ zod: "^3.24.2"
2972
3179
  }
2973
3180
  };
2974
3181
 
@@ -2983,7 +3190,7 @@ var createSchema = async ({
2983
3190
  if (flags && flags.length > 0) {
2984
3191
  meta["flags"] = flags;
2985
3192
  }
2986
- return new import_schema_tools2.TinaSchema({
3193
+ return new import_schema_tools3.TinaSchema({
2987
3194
  version: {
2988
3195
  fullVersion: package_default.version,
2989
3196
  major,
@@ -3039,6 +3246,7 @@ var _buildFragments = async (builder, tinaSchema) => {
3039
3246
  const fragDoc = {
3040
3247
  kind: "Document",
3041
3248
  definitions: (0, import_lodash3.default)(
3249
+ // @ts-ignore
3042
3250
  extractInlineTypes(fragmentDefinitionsFields),
3043
3251
  (node) => node.name.value
3044
3252
  )
@@ -3062,6 +3270,7 @@ var _buildQueries = async (builder, tinaSchema) => {
3062
3270
  fragName,
3063
3271
  queryName: queryListName,
3064
3272
  filterType: queryFilterTypeName,
3273
+ // look for flag to see if the data layer is enabled
3065
3274
  dataLayer: Boolean(
3066
3275
  (_c = (_b = (_a = tinaSchema.config) == null ? void 0 : _a.meta) == null ? void 0 : _b.flags) == null ? void 0 : _c.find((x) => x === "experimentalData")
3067
3276
  )
@@ -3071,6 +3280,7 @@ var _buildQueries = async (builder, tinaSchema) => {
3071
3280
  const queryDoc = {
3072
3281
  kind: "Document",
3073
3282
  definitions: (0, import_lodash3.default)(
3283
+ // @ts-ignore
3074
3284
  extractInlineTypes(operationsDefinitions),
3075
3285
  (node) => node.name.value
3076
3286
  )
@@ -3159,6 +3369,7 @@ var _buildSchema = async (builder, tinaSchema) => {
3159
3369
  return {
3160
3370
  kind: "Document",
3161
3371
  definitions: (0, import_lodash3.default)(
3372
+ // @ts-ignore
3162
3373
  extractInlineTypes(definitions),
3163
3374
  (node) => node.name.value
3164
3375
  )
@@ -3175,6 +3386,9 @@ var import_isValid = __toESM(require("date-fns/isValid/index.js"));
3175
3386
  // src/mdx/index.ts
3176
3387
  var import_mdx = require("@tinacms/mdx");
3177
3388
 
3389
+ // src/resolver/index.ts
3390
+ var import_jsonpath_plus2 = require("jsonpath-plus");
3391
+
3178
3392
  // src/resolver/error.ts
3179
3393
  var TinaGraphQLError = class extends Error {
3180
3394
  constructor(message, extensions) {
@@ -3360,8 +3574,7 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
3360
3574
  }
3361
3575
  if (Array.isArray(value)) {
3362
3576
  return value.map((v) => {
3363
- if (!v || typeof v !== "string")
3364
- return v;
3577
+ if (!v || typeof v !== "string") return v;
3365
3578
  const cleanMediaRoot = cleanUpSlashes(
3366
3579
  schema.config.media.tina.mediaRoot
3367
3580
  );
@@ -3389,8 +3602,7 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
3389
3602
  }
3390
3603
  if (Array.isArray(value)) {
3391
3604
  return value.map((v) => {
3392
- if (!v || typeof v !== "string")
3393
- return v;
3605
+ if (!v || typeof v !== "string") return v;
3394
3606
  const strippedValue = v.replace(cleanMediaRoot, "");
3395
3607
  return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
3396
3608
  });
@@ -3409,8 +3621,7 @@ var cleanUpSlashes = (path7) => {
3409
3621
  };
3410
3622
  var hasTinaMediaConfig = (schema) => {
3411
3623
  var _a, _b, _c, _d, _e, _f, _g, _h;
3412
- if (!((_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina))
3413
- return false;
3624
+ if (!((_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina)) return false;
3414
3625
  if (typeof ((_e = (_d = (_c = schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.tina) == null ? void 0 : _e.publicFolder) !== "string" && typeof ((_h = (_g = (_f = schema.config) == null ? void 0 : _f.media) == null ? void 0 : _g.tina) == null ? void 0 : _h.mediaRoot) !== "string")
3415
3626
  return false;
3416
3627
  return true;
@@ -3454,6 +3665,7 @@ var LevelProxyHandler = {
3454
3665
  } else if (property === "sublevel") {
3455
3666
  return (...args) => {
3456
3667
  return new Proxy(
3668
+ // eslint-disable-next-line prefer-spread
3457
3669
  target[property].apply(target, args),
3458
3670
  LevelProxyHandler
3459
3671
  );
@@ -3476,7 +3688,7 @@ var import_path2 = __toESM(require("path"));
3476
3688
  var import_toml = __toESM(require("@iarna/toml"));
3477
3689
  var import_js_yaml = __toESM(require("js-yaml"));
3478
3690
  var import_gray_matter = __toESM(require("gray-matter"));
3479
- var import_schema_tools3 = require("@tinacms/schema-tools");
3691
+ var import_schema_tools4 = require("@tinacms/schema-tools");
3480
3692
  var import_micromatch = __toESM(require("micromatch"));
3481
3693
  var import_path = __toESM(require("path"));
3482
3694
 
@@ -3689,7 +3901,7 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
3689
3901
  const filesSeen = /* @__PURE__ */ new Map();
3690
3902
  const duplicateFiles = /* @__PURE__ */ new Set();
3691
3903
  await sequential(tinaSchema.getCollections(), async (collection) => {
3692
- const normalPath = (0, import_schema_tools3.normalizePath)(collection.path);
3904
+ const normalPath = (0, import_schema_tools4.normalizePath)(collection.path);
3693
3905
  const format = collection.format || "md";
3694
3906
  const documentPaths = await bridge.glob(normalPath, format);
3695
3907
  const matches = tinaSchema.getMatches({ collection });
@@ -3801,7 +4013,7 @@ var getTemplateForFile = (templateInfo, data) => {
3801
4013
  throw new Error(`Unable to determine template`);
3802
4014
  };
3803
4015
  var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo) => {
3804
- const dataString = await bridge.get((0, import_schema_tools3.normalizePath)(filepath));
4016
+ const dataString = await bridge.get((0, import_schema_tools4.normalizePath)(filepath));
3805
4017
  const data = parseFile(
3806
4018
  dataString,
3807
4019
  import_path.default.extname(filepath),
@@ -4280,7 +4492,7 @@ var FolderTreeBuilder = class {
4280
4492
  return this._tree;
4281
4493
  }
4282
4494
  update(documentPath, collectionPath) {
4283
- let folderPath = import_path2.default.dirname((0, import_schema_tools3.normalizePath)(documentPath));
4495
+ let folderPath = import_path2.default.dirname((0, import_schema_tools4.normalizePath)(documentPath));
4284
4496
  if (folderPath === ".") {
4285
4497
  folderPath = "";
4286
4498
  }
@@ -4293,7 +4505,7 @@ var FolderTreeBuilder = class {
4293
4505
  if (!this._tree[current2]) {
4294
4506
  this._tree[current2] = /* @__PURE__ */ new Set();
4295
4507
  }
4296
- this._tree[current2].add((0, import_schema_tools3.normalizePath)(import_path2.default.join(current2, part)));
4508
+ this._tree[current2].add((0, import_schema_tools4.normalizePath)(import_path2.default.join(current2, part)));
4297
4509
  parent.push(part);
4298
4510
  });
4299
4511
  const current = parent.join("/");
@@ -4332,6 +4544,7 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
4332
4544
  result.push({
4333
4545
  type: opType,
4334
4546
  key: `${collection.path}/${subFolderKey}.${collection.format}`,
4547
+ // replace the root with the collection path
4335
4548
  sublevel: indexSublevel,
4336
4549
  value: {}
4337
4550
  });
@@ -4447,6 +4660,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
4447
4660
  case "password":
4448
4661
  accumulator[field.name] = {
4449
4662
  value: void 0,
4663
+ // never resolve the password hash
4450
4664
  passwordChangeRequired: (_a = value["passwordChangeRequired"]) != null ? _a : false
4451
4665
  };
4452
4666
  break;
@@ -4541,7 +4755,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
4541
4755
  }
4542
4756
  return accumulator;
4543
4757
  };
4544
- var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit) => {
4758
+ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config, isAudit, hasReferences) => {
4545
4759
  const collection = tinaSchema.getCollection(rawData._collection);
4546
4760
  try {
4547
4761
  const template = tinaSchema.getTemplateForData({
@@ -4595,6 +4809,7 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4595
4809
  basename,
4596
4810
  filename,
4597
4811
  extension,
4812
+ hasReferences,
4598
4813
  path: fullPath,
4599
4814
  relativePath,
4600
4815
  breadcrumbs,
@@ -4614,6 +4829,25 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
4614
4829
  throw e;
4615
4830
  }
4616
4831
  };
4832
+ var updateObjectWithJsonPath = (obj, path7, newValue) => {
4833
+ if (!path7.includes(".") && !path7.includes("[")) {
4834
+ if (path7 in obj) {
4835
+ obj[path7] = newValue;
4836
+ }
4837
+ return obj;
4838
+ }
4839
+ const parentPath = path7.replace(/\.[^.]+$/, "");
4840
+ const keyToUpdate = path7.match(/[^.]+$/)[0];
4841
+ const parents = (0, import_jsonpath_plus2.JSONPath)({ path: parentPath, json: obj, resultType: "value" });
4842
+ if (parents.length > 0) {
4843
+ parents.forEach((parent) => {
4844
+ if (parent && typeof parent === "object" && keyToUpdate in parent) {
4845
+ parent[keyToUpdate] = newValue;
4846
+ }
4847
+ });
4848
+ }
4849
+ return obj;
4850
+ };
4617
4851
  var Resolver = class {
4618
4852
  constructor(init) {
4619
4853
  this.init = init;
@@ -4621,6 +4855,7 @@ var Resolver = class {
4621
4855
  const collection = this.tinaSchema.getCollection(collectionName);
4622
4856
  const extraFields = {};
4623
4857
  return {
4858
+ // return the collection and hasDocuments to resolve documents at a lower level
4624
4859
  documents: { collection, hasDocuments },
4625
4860
  ...collection,
4626
4861
  ...extraFields
@@ -4655,17 +4890,19 @@ var Resolver = class {
4655
4890
  );
4656
4891
  }
4657
4892
  };
4658
- this.getDocument = async (fullPath) => {
4893
+ this.getDocument = async (fullPath, opts = {}) => {
4659
4894
  if (typeof fullPath !== "string") {
4660
4895
  throw new Error(`fullPath must be of type string for getDocument request`);
4661
4896
  }
4662
4897
  const rawData = await this.getRaw(fullPath);
4898
+ const hasReferences = (opts == null ? void 0 : opts.checkReferences) ? await this.hasReferences(fullPath, opts.collection) : void 0;
4663
4899
  return transformDocumentIntoPayload(
4664
4900
  fullPath,
4665
4901
  rawData,
4666
4902
  this.tinaSchema,
4667
4903
  this.config,
4668
- this.isAudit
4904
+ this.isAudit,
4905
+ hasReferences
4669
4906
  );
4670
4907
  };
4671
4908
  this.deleteDocument = async (fullPath) => {
@@ -4705,7 +4942,9 @@ var Resolver = class {
4705
4942
  );
4706
4943
  } else {
4707
4944
  return this.buildFieldMutations(
4945
+ // @ts-ignore FIXME Argument of type 'string | object' is not assignable to parameter of type '{ [fieldName: string]: string | object | (string | object)[]; }'
4708
4946
  fieldValue,
4947
+ //@ts-ignore
4709
4948
  objectTemplate,
4710
4949
  existingData
4711
4950
  );
@@ -4717,6 +4956,7 @@ var Resolver = class {
4717
4956
  fieldValue.map(async (item) => {
4718
4957
  if (typeof item === "string") {
4719
4958
  throw new Error(
4959
+ //@ts-ignore
4720
4960
  `Expected object for template value for field ${field.name}`
4721
4961
  );
4722
4962
  }
@@ -4725,16 +4965,19 @@ var Resolver = class {
4725
4965
  });
4726
4966
  const [templateName] = Object.entries(item)[0];
4727
4967
  const template = templates.find(
4968
+ //@ts-ignore
4728
4969
  (template2) => template2.name === templateName
4729
4970
  );
4730
4971
  if (!template) {
4731
4972
  throw new Error(`Expected to find template ${templateName}`);
4732
4973
  }
4733
4974
  return {
4975
+ // @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
4734
4976
  ...await this.buildFieldMutations(
4735
4977
  item[template.name],
4736
4978
  template
4737
4979
  ),
4980
+ //@ts-ignore
4738
4981
  _template: template.name
4739
4982
  };
4740
4983
  })
@@ -4742,6 +4985,7 @@ var Resolver = class {
4742
4985
  } else {
4743
4986
  if (typeof fieldValue === "string") {
4744
4987
  throw new Error(
4988
+ //@ts-ignore
4745
4989
  `Expected object for template value for field ${field.name}`
4746
4990
  );
4747
4991
  }
@@ -4750,16 +4994,19 @@ var Resolver = class {
4750
4994
  });
4751
4995
  const [templateName] = Object.entries(fieldValue)[0];
4752
4996
  const template = templates.find(
4997
+ //@ts-ignore
4753
4998
  (template2) => template2.name === templateName
4754
4999
  );
4755
5000
  if (!template) {
4756
5001
  throw new Error(`Expected to find template ${templateName}`);
4757
5002
  }
4758
5003
  return {
5004
+ // @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
4759
5005
  ...await this.buildFieldMutations(
4760
5006
  fieldValue[template.name],
4761
5007
  template
4762
5008
  ),
5009
+ //@ts-ignore
4763
5010
  _template: template.name
4764
5011
  };
4765
5012
  }
@@ -4799,6 +5046,7 @@ var Resolver = class {
4799
5046
  return this.getDocument(realPath);
4800
5047
  }
4801
5048
  const params = await this.buildObjectMutations(
5049
+ // @ts-ignore
4802
5050
  args.params[collection.name],
4803
5051
  collection
4804
5052
  );
@@ -4844,6 +5092,7 @@ var Resolver = class {
4844
5092
  const values = {
4845
5093
  ...oldDoc,
4846
5094
  ...await this.buildFieldMutations(
5095
+ // @ts-ignore FIXME: failing on unknown, which we don't need to know because it's recursive
4847
5096
  templateParams,
4848
5097
  template,
4849
5098
  doc == null ? void 0 : doc._rawData
@@ -4857,6 +5106,7 @@ var Resolver = class {
4857
5106
  return this.getDocument(realPath);
4858
5107
  }
4859
5108
  const params = await this.buildObjectMutations(
5109
+ //@ts-ignore
4860
5110
  isCollectionSpecific ? args.params : args.params[collection.name],
4861
5111
  collection,
4862
5112
  doc == null ? void 0 : doc._rawData
@@ -4864,6 +5114,10 @@ var Resolver = class {
4864
5114
  await this.database.put(realPath, { ...oldDoc, ...params }, collection.name);
4865
5115
  return this.getDocument(realPath);
4866
5116
  };
5117
+ /**
5118
+ * Returns top-level fields which are not defined in the collection, so their
5119
+ * values are not eliminated from Tina when new values are saved
5120
+ */
4867
5121
  this.resolveLegacyValues = (oldDoc, collection) => {
4868
5122
  const legacyValues = {};
4869
5123
  Object.entries(oldDoc).forEach(([key, value]) => {
@@ -4969,6 +5223,22 @@ var Resolver = class {
4969
5223
  if (isDeletion) {
4970
5224
  const doc = await this.getDocument(realPath);
4971
5225
  await this.deleteDocument(realPath);
5226
+ if (await this.hasReferences(realPath, collection)) {
5227
+ const collRefs = await this.findReferences(realPath, collection);
5228
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
5229
+ for (const [refPath, refs] of Object.entries(refFields)) {
5230
+ let refDoc = await this.getRaw(refPath);
5231
+ for (const ref of refs) {
5232
+ refDoc = updateObjectWithJsonPath(
5233
+ refDoc,
5234
+ ref.path.join("."),
5235
+ null
5236
+ );
5237
+ }
5238
+ await this.database.put(refPath, refDoc, collection2);
5239
+ }
5240
+ }
5241
+ }
4972
5242
  return doc;
4973
5243
  }
4974
5244
  if (isUpdateName) {
@@ -4985,8 +5255,25 @@ var Resolver = class {
4985
5255
  collection == null ? void 0 : collection.path,
4986
5256
  args.params.relativePath
4987
5257
  );
5258
+ if (newRealPath === realPath) {
5259
+ return doc;
5260
+ }
4988
5261
  await this.database.put(newRealPath, doc._rawData, collection.name);
4989
5262
  await this.deleteDocument(realPath);
5263
+ const collRefs = await this.findReferences(realPath, collection);
5264
+ for (const [collection2, refFields] of Object.entries(collRefs)) {
5265
+ for (const [refPath, refs] of Object.entries(refFields)) {
5266
+ let refDoc = await this.getRaw(refPath);
5267
+ for (const ref of refs) {
5268
+ refDoc = updateObjectWithJsonPath(
5269
+ refDoc,
5270
+ ref.path.join("."),
5271
+ newRealPath
5272
+ );
5273
+ }
5274
+ await this.database.put(refPath, refDoc, collection2);
5275
+ }
5276
+ }
4990
5277
  return this.getDocument(newRealPath);
4991
5278
  }
4992
5279
  if (alreadyExists === false) {
@@ -5000,7 +5287,10 @@ var Resolver = class {
5000
5287
  isCollectionSpecific
5001
5288
  });
5002
5289
  } else {
5003
- return this.getDocument(realPath);
5290
+ return this.getDocument(realPath, {
5291
+ collection,
5292
+ checkReferences: true
5293
+ });
5004
5294
  }
5005
5295
  };
5006
5296
  this.resolveCollectionConnections = async ({ ids }) => {
@@ -5037,6 +5327,7 @@ var Resolver = class {
5037
5327
  },
5038
5328
  collection: referencedCollection,
5039
5329
  hydrator: (path7) => path7
5330
+ // just return the path
5040
5331
  }
5041
5332
  );
5042
5333
  const { edges } = resolvedCollectionConnection;
@@ -5104,6 +5395,92 @@ var Resolver = class {
5104
5395
  }
5105
5396
  };
5106
5397
  };
5398
+ /**
5399
+ * Checks if a document has references to it
5400
+ * @param id The id of the document to check for references
5401
+ * @param c The collection to check for references
5402
+ * @returns true if the document has references, false otherwise
5403
+ */
5404
+ this.hasReferences = async (id, c) => {
5405
+ let count = 0;
5406
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5407
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5408
+ for (const ref of refs) {
5409
+ await this.database.query(
5410
+ {
5411
+ collection,
5412
+ filterChain: makeFilterChain({
5413
+ conditions: [
5414
+ {
5415
+ filterPath: ref.path.join("."),
5416
+ filterExpression: {
5417
+ _type: "reference",
5418
+ _list: false,
5419
+ eq: id
5420
+ }
5421
+ }
5422
+ ]
5423
+ }),
5424
+ sort: ref.field.name
5425
+ },
5426
+ (refId) => {
5427
+ count++;
5428
+ return refId;
5429
+ }
5430
+ );
5431
+ if (count) {
5432
+ return true;
5433
+ }
5434
+ }
5435
+ }
5436
+ return false;
5437
+ };
5438
+ /**
5439
+ * Finds references to a document
5440
+ * @param id the id of the document to find references to
5441
+ * @param c the collection to find references in
5442
+ * @returns references to the document in the form of a map of collection names to a list of fields that reference the document
5443
+ */
5444
+ this.findReferences = async (id, c) => {
5445
+ const references = {};
5446
+ const deepRefs = this.tinaSchema.findReferences(c.name);
5447
+ for (const [collection, refs] of Object.entries(deepRefs)) {
5448
+ for (const ref of refs) {
5449
+ await this.database.query(
5450
+ {
5451
+ collection,
5452
+ filterChain: makeFilterChain({
5453
+ conditions: [
5454
+ {
5455
+ filterPath: ref.path.join("."),
5456
+ filterExpression: {
5457
+ _type: "reference",
5458
+ _list: false,
5459
+ eq: id
5460
+ }
5461
+ }
5462
+ ]
5463
+ }),
5464
+ sort: ref.field.name
5465
+ },
5466
+ (refId) => {
5467
+ if (!references[collection]) {
5468
+ references[collection] = {};
5469
+ }
5470
+ if (!references[collection][refId]) {
5471
+ references[collection][refId] = [];
5472
+ }
5473
+ references[collection][refId].push({
5474
+ path: ref.path,
5475
+ field: ref.field
5476
+ });
5477
+ return refId;
5478
+ }
5479
+ );
5480
+ }
5481
+ }
5482
+ return references;
5483
+ };
5107
5484
  this.buildFieldMutations = async (fieldParams, template, existingData) => {
5108
5485
  var _a;
5109
5486
  const accum = {};
@@ -5191,6 +5568,27 @@ var Resolver = class {
5191
5568
  }
5192
5569
  return accum;
5193
5570
  };
5571
+ /**
5572
+ * A mutation looks nearly identical between updateDocument:
5573
+ * ```graphql
5574
+ * updateDocument(collection: $collection,relativePath: $path, params: {
5575
+ * post: {
5576
+ * title: "Hello, World"
5577
+ * }
5578
+ * })`
5579
+ * ```
5580
+ * and `updatePostDocument`:
5581
+ * ```graphql
5582
+ * updatePostDocument(relativePath: $path, params: {
5583
+ * title: "Hello, World"
5584
+ * })
5585
+ * ```
5586
+ * The problem here is that we don't know whether the payload came from `updateDocument`
5587
+ * or `updatePostDocument` (we could, but for now it's easier not to pipe those details through),
5588
+ * But we do know that when given a `args.collection` value, we can assume that
5589
+ * this was a `updateDocument` request, and thus - should grab the data
5590
+ * from the corresponding field name in the key
5591
+ */
5194
5592
  this.buildParams = (args) => {
5195
5593
  try {
5196
5594
  assertShape(
@@ -5291,7 +5689,10 @@ var resolve = async ({
5291
5689
  const graphQLSchema = (0, import_graphql5.buildASTSchema)(graphQLSchemaAst);
5292
5690
  const tinaConfig = await database.getTinaSchema();
5293
5691
  const tinaSchema = await createSchema({
5692
+ // TODO: please update all the types to import from @tinacms/schema-tools
5693
+ // @ts-ignore
5294
5694
  schema: tinaConfig,
5695
+ // @ts-ignore
5295
5696
  flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
5296
5697
  });
5297
5698
  const resolver = createResolver({
@@ -5308,8 +5709,7 @@ var resolve = async ({
5308
5709
  database
5309
5710
  },
5310
5711
  typeResolver: async (source, _args, info) => {
5311
- if (source.__typename)
5312
- return source.__typename;
5712
+ if (source.__typename) return source.__typename;
5313
5713
  const namedType = (0, import_graphql5.getNamedType)(info.returnType).toString();
5314
5714
  const lookup = await database.getLookup(namedType);
5315
5715
  if (lookup.resolveType === "unionData") {
@@ -5461,11 +5861,13 @@ var resolve = async ({
5461
5861
  (0, import_lodash4.default)(
5462
5862
  params,
5463
5863
  userField.path.slice(1),
5864
+ // remove _rawData from users path
5464
5865
  users.map((u) => {
5465
5866
  if (user[idFieldName] === u[idFieldName]) {
5466
5867
  return user;
5467
5868
  }
5468
5869
  return {
5870
+ // don't overwrite other users' passwords
5469
5871
  ...u,
5470
5872
  [passwordFieldName]: {
5471
5873
  ...u[passwordFieldName],
@@ -5488,6 +5890,9 @@ var resolve = async ({
5488
5890
  }
5489
5891
  const isCreation = lookup[info.fieldName] === "create";
5490
5892
  switch (lookup.resolveType) {
5893
+ /**
5894
+ * `node(id: $id)`
5895
+ */
5491
5896
  case "nodeDocument":
5492
5897
  assertShape(
5493
5898
  args,
@@ -5519,6 +5924,7 @@ var resolve = async ({
5519
5924
  collection: args.collection,
5520
5925
  isMutation,
5521
5926
  isCreation,
5927
+ // Right now this is the only case for deletion
5522
5928
  isDeletion: info.fieldName === "deleteDocument",
5523
5929
  isFolderCreation: info.fieldName === "createFolder",
5524
5930
  isUpdateName: Boolean((_a2 = args == null ? void 0 : args.params) == null ? void 0 : _a2.relativePath),
@@ -5528,6 +5934,9 @@ var resolve = async ({
5528
5934
  return result;
5529
5935
  }
5530
5936
  return value;
5937
+ /**
5938
+ * eg `getMovieDocument.data.actors`
5939
+ */
5531
5940
  case "multiCollectionDocumentList":
5532
5941
  if (Array.isArray(value)) {
5533
5942
  return {
@@ -5539,7 +5948,15 @@ var resolve = async ({
5539
5948
  }
5540
5949
  if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
5541
5950
  let filter = args.filter;
5542
- if (typeof (args == null ? void 0 : args.filter) !== "undefined" && (args == null ? void 0 : args.filter) !== null && typeof ((_b = value == null ? void 0 : value.collection) == null ? void 0 : _b.name) === "string" && Object.keys(args.filter).includes((_c = value == null ? void 0 : value.collection) == null ? void 0 : _c.name) && typeof args.filter[(_d = value == null ? void 0 : value.collection) == null ? void 0 : _d.name] !== "undefined") {
5951
+ if (
5952
+ // 1. Make sure that the filter exists
5953
+ typeof (args == null ? void 0 : args.filter) !== "undefined" && (args == null ? void 0 : args.filter) !== null && // 2. Make sure that the collection name exists
5954
+ // @ts-ignore
5955
+ typeof ((_b = value == null ? void 0 : value.collection) == null ? void 0 : _b.name) === "string" && // 3. Make sure that the collection name is in the filter and is not undefined
5956
+ // @ts-ignore
5957
+ Object.keys(args.filter).includes((_c = value == null ? void 0 : value.collection) == null ? void 0 : _c.name) && // @ts-ignore
5958
+ typeof args.filter[(_d = value == null ? void 0 : value.collection) == null ? void 0 : _d.name] !== "undefined"
5959
+ ) {
5543
5960
  filter = args.filter[value.collection.name];
5544
5961
  }
5545
5962
  return resolver.resolveCollectionConnection({
@@ -5547,12 +5964,20 @@ var resolve = async ({
5547
5964
  ...args,
5548
5965
  filter
5549
5966
  },
5967
+ // @ts-ignore
5550
5968
  collection: value.collection
5551
5969
  });
5552
5970
  }
5553
5971
  throw new Error(
5554
5972
  `Expected an array for result of ${info.fieldName} at ${info.path}`
5555
5973
  );
5974
+ /**
5975
+ * Collections-specific getter
5976
+ * eg. `getPostDocument`/`createPostDocument`/`updatePostDocument`
5977
+ *
5978
+ * if coming from a query result
5979
+ * the field will be `node`
5980
+ */
5556
5981
  case "collectionDocument": {
5557
5982
  if (value) {
5558
5983
  return value;
@@ -5567,11 +5992,32 @@ var resolve = async ({
5567
5992
  });
5568
5993
  return result;
5569
5994
  }
5995
+ /**
5996
+ * Collections-specific list getter
5997
+ * eg. `getPageList`
5998
+ */
5570
5999
  case "collectionDocumentList":
5571
6000
  return resolver.resolveCollectionConnection({
5572
6001
  args,
5573
6002
  collection: tinaSchema.getCollection(lookup.collection)
5574
6003
  });
6004
+ /**
6005
+ * A polymorphic data set, it can be from a document's data
6006
+ * of any nested object which can be one of many shapes
6007
+ *
6008
+ * ```graphql
6009
+ * getPostDocument(relativePath: $relativePath) {
6010
+ * data {...} <- this part
6011
+ * }
6012
+ * ```
6013
+ * ```graphql
6014
+ * getBlockDocument(relativePath: $relativePath) {
6015
+ * data {
6016
+ * blocks {...} <- or this part
6017
+ * }
6018
+ * }
6019
+ * ```
6020
+ */
5575
6021
  case "unionData":
5576
6022
  if (!value) {
5577
6023
  if (args.relativePath) {
@@ -5636,8 +6082,7 @@ var TinaLevelClient = class extends import_many_level.ManyLevelGuest {
5636
6082
  this.port = port || 9e3;
5637
6083
  }
5638
6084
  openConnection() {
5639
- if (this._connected)
5640
- return;
6085
+ if (this._connected) return;
5641
6086
  const socket = (0, import_net.connect)(this.port);
5642
6087
  (0, import_readable_stream.pipeline)(socket, this.createRpcStream(), socket, () => {
5643
6088
  this._connected = false;
@@ -5757,7 +6202,7 @@ var Database = class {
5757
6202
  const contentObject = await level.sublevel(
5758
6203
  CONTENT_ROOT_PREFIX,
5759
6204
  SUBLEVEL_OPTIONS
5760
- ).get((0, import_schema_tools3.normalizePath)(filepath));
6205
+ ).get((0, import_schema_tools4.normalizePath)(filepath));
5761
6206
  if (!contentObject) {
5762
6207
  throw new NotFoundError(`Unable to find record ${filepath}`);
5763
6208
  }
@@ -5782,7 +6227,7 @@ var Database = class {
5782
6227
  );
5783
6228
  const indexDefinitions = await this.getIndexDefinitions(this.contentLevel);
5784
6229
  const collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
5785
- const normalizedPath = (0, import_schema_tools3.normalizePath)(filepath);
6230
+ const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
5786
6231
  if (!(collection == null ? void 0 : collection.isDetached)) {
5787
6232
  if (this.bridge) {
5788
6233
  await this.bridge.put(normalizedPath, stringifiedFile);
@@ -5818,6 +6263,7 @@ var Database = class {
5818
6263
  "put",
5819
6264
  level
5820
6265
  ),
6266
+ // folder indices
5821
6267
  ...makeIndexOpsForDocument(
5822
6268
  normalizedPath,
5823
6269
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -5840,6 +6286,7 @@ var Database = class {
5840
6286
  "del",
5841
6287
  level
5842
6288
  ),
6289
+ // folder indices
5843
6290
  ...makeIndexOpsForDocument(
5844
6291
  normalizedPath,
5845
6292
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -5879,7 +6326,7 @@ var Database = class {
5879
6326
  );
5880
6327
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collectionName];
5881
6328
  }
5882
- const normalizedPath = (0, import_schema_tools3.normalizePath)(filepath);
6329
+ const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
5883
6330
  const dataFields = await this.formatBodyOnPayload(filepath, data);
5884
6331
  const collection = await this.collectionForPath(filepath);
5885
6332
  if (!collection) {
@@ -5934,6 +6381,7 @@ var Database = class {
5934
6381
  "put",
5935
6382
  level
5936
6383
  ),
6384
+ // folder indices
5937
6385
  ...makeIndexOpsForDocument(
5938
6386
  normalizedPath,
5939
6387
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -5956,6 +6404,7 @@ var Database = class {
5956
6404
  "del",
5957
6405
  level
5958
6406
  ),
6407
+ // folder indices
5959
6408
  ...makeIndexOpsForDocument(
5960
6409
  normalizedPath,
5961
6410
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -6033,6 +6482,7 @@ var Database = class {
6033
6482
  aliasedData,
6034
6483
  extension,
6035
6484
  writeTemplateKey,
6485
+ //templateInfo.type === 'union',
6036
6486
  {
6037
6487
  frontmatterFormat: collection == null ? void 0 : collection.frontmatterFormat,
6038
6488
  frontmatterDelimiters: collection == null ? void 0 : collection.frontmatterDelimiters
@@ -6050,7 +6500,7 @@ var Database = class {
6050
6500
  };
6051
6501
  this.getLookup = async (returnType) => {
6052
6502
  await this.initLevel();
6053
- const lookupPath = (0, import_schema_tools3.normalizePath)(
6503
+ const lookupPath = (0, import_schema_tools4.normalizePath)(
6054
6504
  import_node_path.default.join(this.getGeneratedFolder(), `_lookup.json`)
6055
6505
  );
6056
6506
  if (!this._lookup) {
@@ -6063,7 +6513,7 @@ var Database = class {
6063
6513
  };
6064
6514
  this.getGraphQLSchema = async () => {
6065
6515
  await this.initLevel();
6066
- const graphqlPath = (0, import_schema_tools3.normalizePath)(
6516
+ const graphqlPath = (0, import_schema_tools4.normalizePath)(
6067
6517
  import_node_path.default.join(this.getGeneratedFolder(), `_graphql.json`)
6068
6518
  );
6069
6519
  return await this.contentLevel.sublevel(
@@ -6071,11 +6521,12 @@ var Database = class {
6071
6521
  SUBLEVEL_OPTIONS
6072
6522
  ).get(graphqlPath);
6073
6523
  };
6524
+ //TODO - is there a reason why the database fetches some config with "bridge.get", and some with "store.get"?
6074
6525
  this.getGraphQLSchemaFromBridge = async () => {
6075
6526
  if (!this.bridge) {
6076
6527
  throw new Error(`No bridge configured`);
6077
6528
  }
6078
- const graphqlPath = (0, import_schema_tools3.normalizePath)(
6529
+ const graphqlPath = (0, import_schema_tools4.normalizePath)(
6079
6530
  import_node_path.default.join(this.getGeneratedFolder(), `_graphql.json`)
6080
6531
  );
6081
6532
  const _graphql = await this.bridge.get(graphqlPath);
@@ -6083,7 +6534,7 @@ var Database = class {
6083
6534
  };
6084
6535
  this.getTinaSchema = async (level) => {
6085
6536
  await this.initLevel();
6086
- const schemaPath = (0, import_schema_tools3.normalizePath)(
6537
+ const schemaPath = (0, import_schema_tools4.normalizePath)(
6087
6538
  import_node_path.default.join(this.getGeneratedFolder(), `_schema.json`)
6088
6539
  );
6089
6540
  return await (level || this.contentLevel).sublevel(
@@ -6099,7 +6550,7 @@ var Database = class {
6099
6550
  const schema = existingSchema || await this.getTinaSchema(level || this.contentLevel);
6100
6551
  if (!schema) {
6101
6552
  throw new Error(
6102
- `Unable to get schema from level db: ${(0, import_schema_tools3.normalizePath)(
6553
+ `Unable to get schema from level db: ${(0, import_schema_tools4.normalizePath)(
6103
6554
  import_node_path.default.join(this.getGeneratedFolder(), `_schema.json`)
6104
6555
  )}`
6105
6556
  );
@@ -6117,6 +6568,7 @@ var Database = class {
6117
6568
  for (const collection of collections) {
6118
6569
  const indexDefinitions = {
6119
6570
  [DEFAULT_COLLECTION_SORT_KEY]: { fields: [] }
6571
+ // provide a default sort key which is the file sort
6120
6572
  };
6121
6573
  if (collection.fields) {
6122
6574
  for (const field of collection.fields) {
@@ -6315,7 +6767,7 @@ var Database = class {
6315
6767
  try {
6316
6768
  lookup = lookupFromLockFile || JSON.parse(
6317
6769
  await this.bridge.get(
6318
- (0, import_schema_tools3.normalizePath)(
6770
+ (0, import_schema_tools4.normalizePath)(
6319
6771
  import_node_path.default.join(this.getGeneratedFolder(), "_lookup.json")
6320
6772
  )
6321
6773
  )
@@ -6340,15 +6792,15 @@ var Database = class {
6340
6792
  }
6341
6793
  const contentRootLevel = nextLevel.sublevel(CONTENT_ROOT_PREFIX, SUBLEVEL_OPTIONS);
6342
6794
  await contentRootLevel.put(
6343
- (0, import_schema_tools3.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_graphql.json")),
6795
+ (0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_graphql.json")),
6344
6796
  graphQLSchema
6345
6797
  );
6346
6798
  await contentRootLevel.put(
6347
- (0, import_schema_tools3.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_schema.json")),
6799
+ (0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_schema.json")),
6348
6800
  tinaSchema.schema
6349
6801
  );
6350
6802
  await contentRootLevel.put(
6351
- (0, import_schema_tools3.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_lookup.json")),
6803
+ (0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_lookup.json")),
6352
6804
  lookup
6353
6805
  );
6354
6806
  const result = await this._indexAllContent(
@@ -6441,12 +6893,12 @@ var Database = class {
6441
6893
  if (collection == null ? void 0 : collection.isDetached) {
6442
6894
  level = this.appLevel.sublevel(collection == null ? void 0 : collection.name, SUBLEVEL_OPTIONS);
6443
6895
  }
6444
- const itemKey = (0, import_schema_tools3.normalizePath)(filepath);
6896
+ const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
6445
6897
  const rootSublevel = level.sublevel(
6446
6898
  CONTENT_ROOT_PREFIX,
6447
6899
  SUBLEVEL_OPTIONS
6448
6900
  );
6449
- const item = await rootSublevel.get(itemKey);
6901
+ const item = await rootSublevel.get(normalizedPath);
6450
6902
  if (item) {
6451
6903
  const folderTreeBuilder = new FolderTreeBuilder();
6452
6904
  const folderKey = folderTreeBuilder.update(
@@ -6455,15 +6907,16 @@ var Database = class {
6455
6907
  );
6456
6908
  await this.contentLevel.batch([
6457
6909
  ...makeIndexOpsForDocument(
6458
- filepath,
6910
+ normalizedPath,
6459
6911
  collection.name,
6460
6912
  collectionIndexDefinitions,
6461
6913
  item,
6462
6914
  "del",
6463
6915
  level
6464
6916
  ),
6917
+ // folder indices
6465
6918
  ...makeIndexOpsForDocument(
6466
- filepath,
6919
+ normalizedPath,
6467
6920
  `${collection.name}_${folderKey}`,
6468
6921
  collectionIndexDefinitions,
6469
6922
  item,
@@ -6472,17 +6925,17 @@ var Database = class {
6472
6925
  ),
6473
6926
  {
6474
6927
  type: "del",
6475
- key: itemKey,
6928
+ key: normalizedPath,
6476
6929
  sublevel: rootSublevel
6477
6930
  }
6478
6931
  ]);
6479
6932
  }
6480
6933
  if (!(collection == null ? void 0 : collection.isDetached)) {
6481
6934
  if (this.bridge) {
6482
- await this.bridge.delete((0, import_schema_tools3.normalizePath)(filepath));
6935
+ await this.bridge.delete(normalizedPath);
6483
6936
  }
6484
6937
  try {
6485
- await this.onDelete((0, import_schema_tools3.normalizePath)(filepath));
6938
+ await this.onDelete(normalizedPath);
6486
6939
  } catch (e) {
6487
6940
  throw new import_graphql6.GraphQLError(
6488
6941
  `Error running onDelete hook for ${filepath}: ${e}`,
@@ -6616,6 +7069,9 @@ var Database = class {
6616
7069
  info: templateInfo
6617
7070
  };
6618
7071
  }
7072
+ /**
7073
+ * Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
7074
+ */
6619
7075
  clearCache() {
6620
7076
  this.tinaSchema = null;
6621
7077
  this._lookup = null;
@@ -6697,11 +7153,42 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
6697
7153
  if (passwordFields == null ? void 0 : passwordFields.length) {
6698
7154
  await hashPasswordValues(aliasedData, passwordFields);
6699
7155
  }
6700
- const normalizedPath = (0, import_schema_tools3.normalizePath)(filepath);
7156
+ const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
7157
+ const rootSublevel = level.sublevel(
7158
+ CONTENT_ROOT_PREFIX,
7159
+ SUBLEVEL_OPTIONS
7160
+ );
6701
7161
  const folderKey = folderTreeBuilder.update(
6702
7162
  normalizedPath,
6703
7163
  collectionPath || ""
6704
7164
  );
7165
+ const item = await rootSublevel.get(normalizedPath);
7166
+ if (item) {
7167
+ await database.contentLevel.batch([
7168
+ ...makeIndexOpsForDocument(
7169
+ normalizedPath,
7170
+ collection.name,
7171
+ collectionIndexDefinitions,
7172
+ item,
7173
+ "del",
7174
+ level
7175
+ ),
7176
+ // folder indices
7177
+ ...makeIndexOpsForDocument(
7178
+ normalizedPath,
7179
+ `${collection.name}_${folderKey}`,
7180
+ collectionIndexDefinitions,
7181
+ item,
7182
+ "del",
7183
+ level
7184
+ ),
7185
+ {
7186
+ type: "del",
7187
+ key: normalizedPath,
7188
+ sublevel: rootSublevel
7189
+ }
7190
+ ]);
7191
+ }
6705
7192
  if (!isGitKeep(filepath, collection)) {
6706
7193
  await enqueueOps([
6707
7194
  ...makeIndexOpsForDocument(
@@ -6712,6 +7199,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
6712
7199
  "put",
6713
7200
  level
6714
7201
  ),
7202
+ // folder indexes
6715
7203
  ...makeIndexOpsForDocument(
6716
7204
  normalizedPath,
6717
7205
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -6777,7 +7265,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
6777
7265
  );
6778
7266
  const folderTreeBuilder = new FolderTreeBuilder();
6779
7267
  await sequential(documentPaths, async (filepath) => {
6780
- const itemKey = (0, import_schema_tools3.normalizePath)(filepath);
7268
+ const itemKey = (0, import_schema_tools4.normalizePath)(filepath);
6781
7269
  const item = await rootLevel.get(itemKey);
6782
7270
  if (item) {
6783
7271
  const folderKey = folderTreeBuilder.update(
@@ -6797,6 +7285,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
6797
7285
  "del",
6798
7286
  database.contentLevel
6799
7287
  ),
7288
+ // folder indexes
6800
7289
  ...makeIndexOpsForDocument(
6801
7290
  itemKey,
6802
7291
  `${collection == null ? void 0 : collection.name}_${folderKey}`,
@@ -6863,14 +7352,14 @@ var getChangedFiles = async ({
6863
7352
  const rootDir = await findGitRoot(dir);
6864
7353
  let pathPrefix = "";
6865
7354
  if (rootDir !== dir) {
6866
- pathPrefix = (0, import_schema_tools3.normalizePath)(dir.substring(rootDir.length + 1));
7355
+ pathPrefix = (0, import_schema_tools4.normalizePath)(dir.substring(rootDir.length + 1));
6867
7356
  }
6868
7357
  await import_isomorphic_git.default.walk({
6869
7358
  fs: fs4,
6870
7359
  dir: rootDir,
6871
7360
  trees: [import_isomorphic_git.default.TREE({ ref: from }), import_isomorphic_git.default.TREE({ ref: to })],
6872
7361
  map: async function(filename, [A, B]) {
6873
- const relativePath = (0, import_schema_tools3.normalizePath)(filename).substring(pathPrefix.length);
7362
+ const relativePath = (0, import_schema_tools4.normalizePath)(filename).substring(pathPrefix.length);
6874
7363
  let matches = false;
6875
7364
  for (const [key, matcher] of Object.entries(pathFilter)) {
6876
7365
  if (relativePath.startsWith(key)) {
@@ -7012,17 +7501,26 @@ var IsomorphicBridge = class {
7012
7501
  getAuthor() {
7013
7502
  return {
7014
7503
  ...this.author,
7015
- timestamp: Math.round(new Date().getTime() / 1e3),
7504
+ timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
7016
7505
  timezoneOffset: 0
7017
7506
  };
7018
7507
  }
7019
7508
  getCommitter() {
7020
7509
  return {
7021
7510
  ...this.committer,
7022
- timestamp: Math.round(new Date().getTime() / 1e3),
7511
+ timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
7023
7512
  timezoneOffset: 0
7024
7513
  };
7025
7514
  }
7515
+ /**
7516
+ * Recursively populate paths matching `pattern` for the given `entry`
7517
+ *
7518
+ * @param pattern - pattern to filter paths by
7519
+ * @param entry - TreeEntry to start building list from
7520
+ * @param path - base path
7521
+ * @param results
7522
+ * @private
7523
+ */
7026
7524
  async listEntries({
7027
7525
  pattern,
7028
7526
  entry,
@@ -7055,6 +7553,15 @@ var IsomorphicBridge = class {
7055
7553
  });
7056
7554
  }
7057
7555
  }
7556
+ /**
7557
+ * For the specified path, returns an object with an array containing the parts of the path (pathParts)
7558
+ * and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
7559
+ * pathEntries are placeholders for non-existent entries.
7560
+ *
7561
+ * @param path - path being resolved
7562
+ * @param ref - ref to resolve path entries for
7563
+ * @private
7564
+ */
7058
7565
  async resolvePathEntries(path7, ref) {
7059
7566
  let pathParts = path7.split("/");
7060
7567
  const result = await import_isomorphic_git2.default.walk({
@@ -7085,6 +7592,17 @@ var IsomorphicBridge = class {
7085
7592
  }
7086
7593
  return { pathParts, pathEntries };
7087
7594
  }
7595
+ /**
7596
+ * Updates tree entry and associated parent tree entries
7597
+ *
7598
+ * @param existingOid - the existing OID
7599
+ * @param updatedOid - the updated OID
7600
+ * @param path - the path of the entry being updated
7601
+ * @param type - the type of the entry being updated (blob or tree)
7602
+ * @param pathEntries - parent path entries
7603
+ * @param pathParts - parent path parts
7604
+ * @private
7605
+ */
7088
7606
  async updateTreeHierarchy(existingOid, updatedOid, path7, type, pathEntries, pathParts) {
7089
7607
  const lastIdx = pathEntries.length - 1;
7090
7608
  const parentEntry = pathEntries[lastIdx];
@@ -7140,6 +7658,13 @@ var IsomorphicBridge = class {
7140
7658
  );
7141
7659
  }
7142
7660
  }
7661
+ /**
7662
+ * Creates a commit for the specified tree and updates the specified ref to point to the commit
7663
+ *
7664
+ * @param treeSha - sha of the new tree
7665
+ * @param ref - the ref that should be updated
7666
+ * @private
7667
+ */
7143
7668
  async commitTree(treeSha, ref) {
7144
7669
  const commitSha = await import_isomorphic_git2.default.writeCommit({
7145
7670
  ...this.isomorphicConfig,
@@ -7152,6 +7677,7 @@ var IsomorphicBridge = class {
7152
7677
  })
7153
7678
  ],
7154
7679
  message: this.commitMessage,
7680
+ // TODO these should be configurable
7155
7681
  author: this.getAuthor(),
7156
7682
  committer: this.getCommitter()
7157
7683
  }
@@ -7390,5 +7916,5 @@ var buildSchema = async (config, flags) => {
7390
7916
  transformDocument,
7391
7917
  transformDocumentIntoPayload
7392
7918
  });
7393
- //! Replaces _.flattenDeep()
7394
7919
  //! Replaces _.get()
7920
+ //! Replaces _.flattenDeep()