@tinacms/graphql 0.0.0-c72bb45-20241118014046 → 0.0.0-c852462-20250131014229
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/ast-builder/index.d.ts +0 -1
- package/dist/index.js +519 -147
- package/dist/index.mjs +489 -122
- package/dist/resolver/index.d.ts +13 -4
- package/package.json +10 -11
package/dist/index.mjs
CHANGED
|
@@ -68,6 +68,15 @@ var SysFieldDefinition = {
|
|
|
68
68
|
selectionSet: {
|
|
69
69
|
kind: "SelectionSet",
|
|
70
70
|
selections: [
|
|
71
|
+
// {
|
|
72
|
+
// kind: 'Field' as const,
|
|
73
|
+
// name: {
|
|
74
|
+
// kind: 'Name' as const,
|
|
75
|
+
// value: 'title',
|
|
76
|
+
// },
|
|
77
|
+
// arguments: [],
|
|
78
|
+
// directives: [],
|
|
79
|
+
// },
|
|
71
80
|
{
|
|
72
81
|
kind: "Field",
|
|
73
82
|
name: {
|
|
@@ -135,6 +144,10 @@ var SysFieldDefinition = {
|
|
|
135
144
|
}
|
|
136
145
|
};
|
|
137
146
|
var astBuilder = {
|
|
147
|
+
/**
|
|
148
|
+
* `FormFieldBuilder` acts as a shortcut to building an entire `ObjectTypeDefinition`, we use this
|
|
149
|
+
* because all Tina field objects share a common set of fields ('name', 'label', 'component')
|
|
150
|
+
*/
|
|
138
151
|
FormFieldBuilder: ({
|
|
139
152
|
name,
|
|
140
153
|
additionalFields
|
|
@@ -358,6 +371,8 @@ var astBuilder = {
|
|
|
358
371
|
kind: "Name",
|
|
359
372
|
value: name
|
|
360
373
|
},
|
|
374
|
+
// @ts-ignore FIXME; this is being handled properly but we're lying to
|
|
375
|
+
// ts and then fixing it in the `extractInlineTypes` function
|
|
361
376
|
fields
|
|
362
377
|
}),
|
|
363
378
|
UnionTypeDefinition: ({
|
|
@@ -370,6 +385,8 @@ var astBuilder = {
|
|
|
370
385
|
value: name
|
|
371
386
|
},
|
|
372
387
|
directives: [],
|
|
388
|
+
// @ts-ignore FIXME; this is being handled properly but we're lying to
|
|
389
|
+
// ts and then fixing it in the `extractInlineTypes` function
|
|
373
390
|
types: types.map((name2) => ({
|
|
374
391
|
kind: "NamedType",
|
|
375
392
|
name: {
|
|
@@ -466,8 +483,11 @@ var astBuilder = {
|
|
|
466
483
|
string: "String",
|
|
467
484
|
boolean: "Boolean",
|
|
468
485
|
number: "Float",
|
|
486
|
+
// FIXME - needs to be float or int
|
|
469
487
|
datetime: "String",
|
|
488
|
+
// FIXME
|
|
470
489
|
image: "String",
|
|
490
|
+
// FIXME
|
|
471
491
|
text: "String"
|
|
472
492
|
};
|
|
473
493
|
return scalars[type];
|
|
@@ -966,8 +986,7 @@ var astBuilder = {
|
|
|
966
986
|
}
|
|
967
987
|
};
|
|
968
988
|
var capitalize = (s) => {
|
|
969
|
-
if (typeof s !== "string")
|
|
970
|
-
return "";
|
|
989
|
+
if (typeof s !== "string") return "";
|
|
971
990
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
972
991
|
};
|
|
973
992
|
var extractInlineTypes = (item) => {
|
|
@@ -1010,41 +1029,6 @@ function* walk(maybeNode, visited = /* @__PURE__ */ new WeakSet()) {
|
|
|
1010
1029
|
yield maybeNode;
|
|
1011
1030
|
visited.add(maybeNode);
|
|
1012
1031
|
}
|
|
1013
|
-
function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
1014
|
-
if (typeof maybeNode === "string") {
|
|
1015
|
-
return maybeNode;
|
|
1016
|
-
}
|
|
1017
|
-
if (typeof maybeNode === "boolean") {
|
|
1018
|
-
return maybeNode;
|
|
1019
|
-
}
|
|
1020
|
-
const newNode = maybeNode;
|
|
1021
|
-
const keys = Object.keys(maybeNode);
|
|
1022
|
-
Object.values(maybeNode).map((m, index) => {
|
|
1023
|
-
const key = keys[index];
|
|
1024
|
-
if (Array.isArray(m)) {
|
|
1025
|
-
newNode[key] = m.map((element) => {
|
|
1026
|
-
if (!element) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
if (!element.hasOwnProperty("name")) {
|
|
1030
|
-
return element;
|
|
1031
|
-
}
|
|
1032
|
-
const value = element.name || element.value;
|
|
1033
|
-
return addNamespaceToSchema(element, [...namespace, value]);
|
|
1034
|
-
});
|
|
1035
|
-
} else {
|
|
1036
|
-
if (!m) {
|
|
1037
|
-
return;
|
|
1038
|
-
}
|
|
1039
|
-
if (!m.hasOwnProperty("name")) {
|
|
1040
|
-
newNode[key] = m;
|
|
1041
|
-
} else {
|
|
1042
|
-
newNode[key] = addNamespaceToSchema(m, [...namespace, m.name]);
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
return { ...newNode, namespace };
|
|
1047
|
-
}
|
|
1048
1032
|
var generateNamespacedFieldName = (names, suffix = "") => {
|
|
1049
1033
|
return (suffix ? [...names, suffix] : names).map(capitalize).join("");
|
|
1050
1034
|
};
|
|
@@ -1422,6 +1406,19 @@ var Builder = class {
|
|
|
1422
1406
|
this.addToLookupMap = (lookup) => {
|
|
1423
1407
|
this.lookupMap[lookup.type] = lookup;
|
|
1424
1408
|
};
|
|
1409
|
+
/**
|
|
1410
|
+
* ```graphql
|
|
1411
|
+
* # ex.
|
|
1412
|
+
* {
|
|
1413
|
+
* getCollection(collection: $collection) {
|
|
1414
|
+
* name
|
|
1415
|
+
* documents {...}
|
|
1416
|
+
* }
|
|
1417
|
+
* }
|
|
1418
|
+
* ```
|
|
1419
|
+
*
|
|
1420
|
+
* @param collections
|
|
1421
|
+
*/
|
|
1425
1422
|
this.buildCollectionDefinition = async (collections) => {
|
|
1426
1423
|
const name = "collection";
|
|
1427
1424
|
const typeName = "Collection";
|
|
@@ -1492,6 +1489,19 @@ var Builder = class {
|
|
|
1492
1489
|
required: true
|
|
1493
1490
|
});
|
|
1494
1491
|
};
|
|
1492
|
+
/**
|
|
1493
|
+
* ```graphql
|
|
1494
|
+
* # ex.
|
|
1495
|
+
* {
|
|
1496
|
+
* getCollections {
|
|
1497
|
+
* name
|
|
1498
|
+
* documents {...}
|
|
1499
|
+
* }
|
|
1500
|
+
* }
|
|
1501
|
+
* ```
|
|
1502
|
+
*
|
|
1503
|
+
* @param collections
|
|
1504
|
+
*/
|
|
1495
1505
|
this.buildMultiCollectionDefinition = async (collections) => {
|
|
1496
1506
|
const name = "collections";
|
|
1497
1507
|
const typeName = "Collection";
|
|
@@ -1502,6 +1512,17 @@ var Builder = class {
|
|
|
1502
1512
|
required: true
|
|
1503
1513
|
});
|
|
1504
1514
|
};
|
|
1515
|
+
/**
|
|
1516
|
+
* ```graphql
|
|
1517
|
+
* # ex.
|
|
1518
|
+
* {
|
|
1519
|
+
* node(id: $id) {
|
|
1520
|
+
* id
|
|
1521
|
+
* data {...}
|
|
1522
|
+
* }
|
|
1523
|
+
* }
|
|
1524
|
+
* ```
|
|
1525
|
+
*/
|
|
1505
1526
|
this.multiNodeDocument = async () => {
|
|
1506
1527
|
const name = "node";
|
|
1507
1528
|
const args = [
|
|
@@ -1522,6 +1543,19 @@ var Builder = class {
|
|
|
1522
1543
|
required: true
|
|
1523
1544
|
});
|
|
1524
1545
|
};
|
|
1546
|
+
/**
|
|
1547
|
+
* ```graphql
|
|
1548
|
+
* # ex.
|
|
1549
|
+
* {
|
|
1550
|
+
* getDocument(collection: $collection, relativePath: $relativePath) {
|
|
1551
|
+
* id
|
|
1552
|
+
* data {...}
|
|
1553
|
+
* }
|
|
1554
|
+
* }
|
|
1555
|
+
* ```
|
|
1556
|
+
*
|
|
1557
|
+
* @param collections
|
|
1558
|
+
*/
|
|
1525
1559
|
this.multiCollectionDocument = async (collections) => {
|
|
1526
1560
|
const name = "document";
|
|
1527
1561
|
const args = [
|
|
@@ -1547,6 +1581,19 @@ var Builder = class {
|
|
|
1547
1581
|
required: true
|
|
1548
1582
|
});
|
|
1549
1583
|
};
|
|
1584
|
+
/**
|
|
1585
|
+
* ```graphql
|
|
1586
|
+
* # ex.
|
|
1587
|
+
* {
|
|
1588
|
+
* addPendingDocument(collection: $collection, relativePath: $relativePath, params: $params) {
|
|
1589
|
+
* id
|
|
1590
|
+
* data {...}
|
|
1591
|
+
* }
|
|
1592
|
+
* }
|
|
1593
|
+
* ```
|
|
1594
|
+
*
|
|
1595
|
+
* @param collections
|
|
1596
|
+
*/
|
|
1550
1597
|
this.addMultiCollectionDocumentMutation = async () => {
|
|
1551
1598
|
return astBuilder.FieldDefinition({
|
|
1552
1599
|
name: "addPendingDocument",
|
|
@@ -1571,6 +1618,19 @@ var Builder = class {
|
|
|
1571
1618
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1572
1619
|
});
|
|
1573
1620
|
};
|
|
1621
|
+
/**
|
|
1622
|
+
* ```graphql
|
|
1623
|
+
* # ex.
|
|
1624
|
+
* {
|
|
1625
|
+
* createDocument(relativePath: $relativePath, params: $params) {
|
|
1626
|
+
* id
|
|
1627
|
+
* data {...}
|
|
1628
|
+
* }
|
|
1629
|
+
* }
|
|
1630
|
+
* ```
|
|
1631
|
+
*
|
|
1632
|
+
* @param collections
|
|
1633
|
+
*/
|
|
1574
1634
|
this.buildCreateCollectionDocumentMutation = async (collections) => {
|
|
1575
1635
|
return astBuilder.FieldDefinition({
|
|
1576
1636
|
name: "createDocument",
|
|
@@ -1598,6 +1658,19 @@ var Builder = class {
|
|
|
1598
1658
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1599
1659
|
});
|
|
1600
1660
|
};
|
|
1661
|
+
/**
|
|
1662
|
+
* ```graphql
|
|
1663
|
+
* # ex.
|
|
1664
|
+
* {
|
|
1665
|
+
* updateDocument(relativePath: $relativePath, params: $params) {
|
|
1666
|
+
* id
|
|
1667
|
+
* data {...}
|
|
1668
|
+
* }
|
|
1669
|
+
* }
|
|
1670
|
+
* ```
|
|
1671
|
+
*
|
|
1672
|
+
* @param collections
|
|
1673
|
+
*/
|
|
1601
1674
|
this.buildUpdateCollectionDocumentMutation = async (collections) => {
|
|
1602
1675
|
return astBuilder.FieldDefinition({
|
|
1603
1676
|
name: "updateDocument",
|
|
@@ -1625,6 +1698,19 @@ var Builder = class {
|
|
|
1625
1698
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1626
1699
|
});
|
|
1627
1700
|
};
|
|
1701
|
+
/**
|
|
1702
|
+
* ```graphql
|
|
1703
|
+
* # ex.
|
|
1704
|
+
* {
|
|
1705
|
+
* deleteDocument(relativePath: $relativePath, params: $params) {
|
|
1706
|
+
* id
|
|
1707
|
+
* data {...}
|
|
1708
|
+
* }
|
|
1709
|
+
* }
|
|
1710
|
+
* ```
|
|
1711
|
+
*
|
|
1712
|
+
* @param collections
|
|
1713
|
+
*/
|
|
1628
1714
|
this.buildDeleteCollectionDocumentMutation = async (collections) => {
|
|
1629
1715
|
return astBuilder.FieldDefinition({
|
|
1630
1716
|
name: "deleteDocument",
|
|
@@ -1644,6 +1730,19 @@ var Builder = class {
|
|
|
1644
1730
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1645
1731
|
});
|
|
1646
1732
|
};
|
|
1733
|
+
/**
|
|
1734
|
+
* ```graphql
|
|
1735
|
+
* # ex.
|
|
1736
|
+
* {
|
|
1737
|
+
* createFolder(folderName: $folderName, params: $params) {
|
|
1738
|
+
* id
|
|
1739
|
+
* data {...}
|
|
1740
|
+
* }
|
|
1741
|
+
* }
|
|
1742
|
+
* ```
|
|
1743
|
+
*
|
|
1744
|
+
* @param collections
|
|
1745
|
+
*/
|
|
1647
1746
|
this.buildCreateCollectionFolderMutation = async () => {
|
|
1648
1747
|
return astBuilder.FieldDefinition({
|
|
1649
1748
|
name: "createFolder",
|
|
@@ -1663,6 +1762,19 @@ var Builder = class {
|
|
|
1663
1762
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1664
1763
|
});
|
|
1665
1764
|
};
|
|
1765
|
+
/**
|
|
1766
|
+
* ```graphql
|
|
1767
|
+
* # ex.
|
|
1768
|
+
* {
|
|
1769
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
1770
|
+
* id
|
|
1771
|
+
* data {...}
|
|
1772
|
+
* }
|
|
1773
|
+
* }
|
|
1774
|
+
* ```
|
|
1775
|
+
*
|
|
1776
|
+
* @param collection
|
|
1777
|
+
*/
|
|
1666
1778
|
this.collectionDocument = async (collection) => {
|
|
1667
1779
|
const name = NAMER.queryName([collection.name]);
|
|
1668
1780
|
const type = await this._buildCollectionDocumentType(collection);
|
|
@@ -1723,6 +1835,20 @@ var Builder = class {
|
|
|
1723
1835
|
const args = [];
|
|
1724
1836
|
return astBuilder.FieldDefinition({ type, name, args, required: false });
|
|
1725
1837
|
};
|
|
1838
|
+
/**
|
|
1839
|
+
* Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
|
|
1840
|
+
* ```graphql
|
|
1841
|
+
* # ex.
|
|
1842
|
+
* fragment AuthorsParts on Authors {
|
|
1843
|
+
* name
|
|
1844
|
+
* avatar
|
|
1845
|
+
* ...
|
|
1846
|
+
* }
|
|
1847
|
+
* ```
|
|
1848
|
+
*
|
|
1849
|
+
* @public
|
|
1850
|
+
* @param collection a Tina Cloud collection
|
|
1851
|
+
*/
|
|
1726
1852
|
this.collectionFragment = async (collection) => {
|
|
1727
1853
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
1728
1854
|
const fragmentName = NAMER.fragmentName(collection.namespace);
|
|
@@ -1736,6 +1862,20 @@ var Builder = class {
|
|
|
1736
1862
|
selections: filterSelections(selections)
|
|
1737
1863
|
});
|
|
1738
1864
|
};
|
|
1865
|
+
/**
|
|
1866
|
+
* Given a collection this function returns its selections set. For example for Post this would return
|
|
1867
|
+
*
|
|
1868
|
+
* "
|
|
1869
|
+
* body
|
|
1870
|
+
* title
|
|
1871
|
+
* ... on Author {
|
|
1872
|
+
* name
|
|
1873
|
+
* heroImg
|
|
1874
|
+
* }
|
|
1875
|
+
*
|
|
1876
|
+
* But in the AST format
|
|
1877
|
+
*
|
|
1878
|
+
* */
|
|
1739
1879
|
this._getCollectionFragmentSelections = async (collection, depth) => {
|
|
1740
1880
|
const selections = [];
|
|
1741
1881
|
selections.push({
|
|
@@ -1817,9 +1957,9 @@ var Builder = class {
|
|
|
1817
1957
|
]
|
|
1818
1958
|
});
|
|
1819
1959
|
}
|
|
1960
|
+
// TODO: Should we throw here?
|
|
1820
1961
|
case "reference":
|
|
1821
|
-
if (depth >= this.maxDepth)
|
|
1822
|
-
return false;
|
|
1962
|
+
if (depth >= this.maxDepth) return false;
|
|
1823
1963
|
if (!("collections" in field)) {
|
|
1824
1964
|
return false;
|
|
1825
1965
|
}
|
|
@@ -1851,6 +1991,7 @@ var Builder = class {
|
|
|
1851
1991
|
name: field.name,
|
|
1852
1992
|
selections: [
|
|
1853
1993
|
...selections,
|
|
1994
|
+
// This is ... on Document { id }
|
|
1854
1995
|
{
|
|
1855
1996
|
kind: "InlineFragment",
|
|
1856
1997
|
typeCondition: {
|
|
@@ -1881,6 +2022,19 @@ var Builder = class {
|
|
|
1881
2022
|
});
|
|
1882
2023
|
}
|
|
1883
2024
|
};
|
|
2025
|
+
/**
|
|
2026
|
+
* ```graphql
|
|
2027
|
+
* # ex.
|
|
2028
|
+
* mutation {
|
|
2029
|
+
* updatePostDocument(relativePath: $relativePath, params: $params) {
|
|
2030
|
+
* id
|
|
2031
|
+
* data {...}
|
|
2032
|
+
* }
|
|
2033
|
+
* }
|
|
2034
|
+
* ```
|
|
2035
|
+
*
|
|
2036
|
+
* @param collection
|
|
2037
|
+
*/
|
|
1884
2038
|
this.updateCollectionDocumentMutation = async (collection) => {
|
|
1885
2039
|
return astBuilder.FieldDefinition({
|
|
1886
2040
|
type: await this._buildCollectionDocumentType(collection),
|
|
@@ -1900,6 +2054,19 @@ var Builder = class {
|
|
|
1900
2054
|
]
|
|
1901
2055
|
});
|
|
1902
2056
|
};
|
|
2057
|
+
/**
|
|
2058
|
+
* ```graphql
|
|
2059
|
+
* # ex.
|
|
2060
|
+
* mutation {
|
|
2061
|
+
* createPostDocument(relativePath: $relativePath, params: $params) {
|
|
2062
|
+
* id
|
|
2063
|
+
* data {...}
|
|
2064
|
+
* }
|
|
2065
|
+
* }
|
|
2066
|
+
* ```
|
|
2067
|
+
*
|
|
2068
|
+
* @param collection
|
|
2069
|
+
*/
|
|
1903
2070
|
this.createCollectionDocumentMutation = async (collection) => {
|
|
1904
2071
|
return astBuilder.FieldDefinition({
|
|
1905
2072
|
type: await this._buildCollectionDocumentType(collection),
|
|
@@ -1919,6 +2086,22 @@ var Builder = class {
|
|
|
1919
2086
|
]
|
|
1920
2087
|
});
|
|
1921
2088
|
};
|
|
2089
|
+
/**
|
|
2090
|
+
* ```graphql
|
|
2091
|
+
* # ex.
|
|
2092
|
+
* {
|
|
2093
|
+
* getPostList(first: 10) {
|
|
2094
|
+
* edges {
|
|
2095
|
+
* node {
|
|
2096
|
+
* id
|
|
2097
|
+
* }
|
|
2098
|
+
* }
|
|
2099
|
+
* }
|
|
2100
|
+
* }
|
|
2101
|
+
* ```
|
|
2102
|
+
*
|
|
2103
|
+
* @param collection
|
|
2104
|
+
*/
|
|
1922
2105
|
this.collectionDocumentList = async (collection) => {
|
|
1923
2106
|
const connectionName = NAMER.referenceConnectionType(collection.namespace);
|
|
1924
2107
|
this.addToLookupMap({
|
|
@@ -1934,6 +2117,10 @@ var Builder = class {
|
|
|
1934
2117
|
collection
|
|
1935
2118
|
});
|
|
1936
2119
|
};
|
|
2120
|
+
/**
|
|
2121
|
+
* GraphQL type definitions which remain unchanged regardless
|
|
2122
|
+
* of the supplied Tina schema. Ex. "node" interface
|
|
2123
|
+
*/
|
|
1937
2124
|
this.buildStaticDefinitions = () => staticDefinitions;
|
|
1938
2125
|
this._buildCollectionDocumentType = async (collection, suffix = "", extraFields = [], extraInterfaces = []) => {
|
|
1939
2126
|
const documentTypeName = NAMER.documentTypeName(collection.namespace);
|
|
@@ -2438,6 +2625,7 @@ var Builder = class {
|
|
|
2438
2625
|
name: NAMER.dataFilterTypeName(namespace),
|
|
2439
2626
|
fields: await sequential(collections, async (collection2) => {
|
|
2440
2627
|
return astBuilder.InputValueDefinition({
|
|
2628
|
+
// @ts-ignore
|
|
2441
2629
|
name: collection2.name,
|
|
2442
2630
|
type: NAMER.dataFilterTypeName(collection2.namespace)
|
|
2443
2631
|
});
|
|
@@ -2626,7 +2814,8 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
2626
2814
|
]
|
|
2627
2815
|
});
|
|
2628
2816
|
};
|
|
2629
|
-
this.maxDepth =
|
|
2817
|
+
this.maxDepth = // @ts-ignore
|
|
2818
|
+
config?.tinaSchema.schema?.config?.client?.referenceDepth ?? 2;
|
|
2630
2819
|
this.tinaSchema = config.tinaSchema;
|
|
2631
2820
|
this.lookupMap = {};
|
|
2632
2821
|
}
|
|
@@ -2637,8 +2826,7 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
2637
2826
|
selections.push(field);
|
|
2638
2827
|
});
|
|
2639
2828
|
const filteredSelections = filterSelections(selections);
|
|
2640
|
-
if (!filteredSelections.length)
|
|
2641
|
-
return false;
|
|
2829
|
+
if (!filteredSelections.length) return false;
|
|
2642
2830
|
return astBuilder.InlineFragmentDefinition({
|
|
2643
2831
|
selections: filteredSelections,
|
|
2644
2832
|
name: NAMER.dataTypeName(template.namespace)
|
|
@@ -2675,6 +2863,7 @@ var filterSelections = (arr) => {
|
|
|
2675
2863
|
import { TinaSchema } from "@tinacms/schema-tools";
|
|
2676
2864
|
|
|
2677
2865
|
// src/schema/validate.ts
|
|
2866
|
+
import { addNamespaceToSchema } from "@tinacms/schema-tools";
|
|
2678
2867
|
import deepClone from "lodash.clonedeep";
|
|
2679
2868
|
import * as yup2 from "yup";
|
|
2680
2869
|
import {
|
|
@@ -2721,6 +2910,7 @@ var validationCollectionsPathAndMatch = (collections) => {
|
|
|
2721
2910
|
}).map((x) => `${x.path}${x.format || "md"}`);
|
|
2722
2911
|
if (noMatchCollections.length !== new Set(noMatchCollections).size) {
|
|
2723
2912
|
throw new Error(
|
|
2913
|
+
// TODO: add a link to the docs
|
|
2724
2914
|
"Two collections without match can not have the same `path`. Please make the `path` unique or add a matches property to the collection."
|
|
2725
2915
|
);
|
|
2726
2916
|
}
|
|
@@ -2829,7 +3019,7 @@ var validateField = async (field) => {
|
|
|
2829
3019
|
// package.json
|
|
2830
3020
|
var package_default = {
|
|
2831
3021
|
name: "@tinacms/graphql",
|
|
2832
|
-
version: "1.5.
|
|
3022
|
+
version: "1.5.11",
|
|
2833
3023
|
main: "dist/index.js",
|
|
2834
3024
|
module: "dist/index.mjs",
|
|
2835
3025
|
typings: "dist/index.d.ts",
|
|
@@ -2856,8 +3046,8 @@ var package_default = {
|
|
|
2856
3046
|
build: "tinacms-scripts build",
|
|
2857
3047
|
docs: "pnpm typedoc",
|
|
2858
3048
|
serve: "pnpm nodemon dist/server.js",
|
|
2859
|
-
test: "
|
|
2860
|
-
"test-watch": "
|
|
3049
|
+
test: "vitest run",
|
|
3050
|
+
"test-watch": "vitest"
|
|
2861
3051
|
},
|
|
2862
3052
|
dependencies: {
|
|
2863
3053
|
"@iarna/toml": "^2.2.5",
|
|
@@ -2898,7 +3088,6 @@ var package_default = {
|
|
|
2898
3088
|
"@types/estree": "^0.0.50",
|
|
2899
3089
|
"@types/express": "^4.17.21",
|
|
2900
3090
|
"@types/fs-extra": "^9.0.13",
|
|
2901
|
-
"@types/jest": "^26.0.24",
|
|
2902
3091
|
"@types/js-yaml": "^3.12.10",
|
|
2903
3092
|
"@types/lodash.camelcase": "^4.3.9",
|
|
2904
3093
|
"@types/lodash.upperfirst": "^4.3.9",
|
|
@@ -2909,13 +3098,13 @@ var package_default = {
|
|
|
2909
3098
|
"@types/normalize-path": "^3.0.2",
|
|
2910
3099
|
"@types/ws": "^7.4.7",
|
|
2911
3100
|
"@types/yup": "^0.29.14",
|
|
2912
|
-
jest: "^29.7.0",
|
|
2913
|
-
"jest-diff": "^29.7.0",
|
|
2914
3101
|
"jest-file-snapshot": "^0.5.0",
|
|
2915
|
-
"jest-matcher-utils": "^29.7.0",
|
|
2916
3102
|
"memory-level": "^1.0.0",
|
|
2917
3103
|
nodemon: "3.1.4",
|
|
2918
|
-
typescript: "^5.6.3"
|
|
3104
|
+
typescript: "^5.6.3",
|
|
3105
|
+
vite: "^4.3.9",
|
|
3106
|
+
vitest: "^0.32.2",
|
|
3107
|
+
zod: "^3.23.8"
|
|
2919
3108
|
}
|
|
2920
3109
|
};
|
|
2921
3110
|
|
|
@@ -2986,6 +3175,7 @@ var _buildFragments = async (builder, tinaSchema) => {
|
|
|
2986
3175
|
const fragDoc = {
|
|
2987
3176
|
kind: "Document",
|
|
2988
3177
|
definitions: uniqBy2(
|
|
3178
|
+
// @ts-ignore
|
|
2989
3179
|
extractInlineTypes(fragmentDefinitionsFields),
|
|
2990
3180
|
(node) => node.name.value
|
|
2991
3181
|
)
|
|
@@ -3008,6 +3198,7 @@ var _buildQueries = async (builder, tinaSchema) => {
|
|
|
3008
3198
|
fragName,
|
|
3009
3199
|
queryName: queryListName,
|
|
3010
3200
|
filterType: queryFilterTypeName,
|
|
3201
|
+
// look for flag to see if the data layer is enabled
|
|
3011
3202
|
dataLayer: Boolean(
|
|
3012
3203
|
tinaSchema.config?.meta?.flags?.find((x) => x === "experimentalData")
|
|
3013
3204
|
)
|
|
@@ -3017,6 +3208,7 @@ var _buildQueries = async (builder, tinaSchema) => {
|
|
|
3017
3208
|
const queryDoc = {
|
|
3018
3209
|
kind: "Document",
|
|
3019
3210
|
definitions: uniqBy2(
|
|
3211
|
+
// @ts-ignore
|
|
3020
3212
|
extractInlineTypes(operationsDefinitions),
|
|
3021
3213
|
(node) => node.name.value
|
|
3022
3214
|
)
|
|
@@ -3105,6 +3297,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
3105
3297
|
return {
|
|
3106
3298
|
kind: "Document",
|
|
3107
3299
|
definitions: uniqBy2(
|
|
3300
|
+
// @ts-ignore
|
|
3108
3301
|
extractInlineTypes(definitions),
|
|
3109
3302
|
(node) => node.name.value
|
|
3110
3303
|
)
|
|
@@ -3309,8 +3502,7 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
|
|
|
3309
3502
|
}
|
|
3310
3503
|
if (Array.isArray(value)) {
|
|
3311
3504
|
return value.map((v) => {
|
|
3312
|
-
if (!v || typeof v !== "string")
|
|
3313
|
-
return v;
|
|
3505
|
+
if (!v || typeof v !== "string") return v;
|
|
3314
3506
|
const cleanMediaRoot = cleanUpSlashes(
|
|
3315
3507
|
schema.config.media.tina.mediaRoot
|
|
3316
3508
|
);
|
|
@@ -3338,8 +3530,7 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3338
3530
|
}
|
|
3339
3531
|
if (Array.isArray(value)) {
|
|
3340
3532
|
return value.map((v) => {
|
|
3341
|
-
if (!v || typeof v !== "string")
|
|
3342
|
-
return v;
|
|
3533
|
+
if (!v || typeof v !== "string") return v;
|
|
3343
3534
|
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3344
3535
|
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3345
3536
|
});
|
|
@@ -3357,8 +3548,7 @@ var cleanUpSlashes = (path7) => {
|
|
|
3357
3548
|
return "";
|
|
3358
3549
|
};
|
|
3359
3550
|
var hasTinaMediaConfig = (schema) => {
|
|
3360
|
-
if (!schema.config?.media?.tina)
|
|
3361
|
-
return false;
|
|
3551
|
+
if (!schema.config?.media?.tina) return false;
|
|
3362
3552
|
if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
|
|
3363
3553
|
return false;
|
|
3364
3554
|
return true;
|
|
@@ -3402,6 +3592,7 @@ var LevelProxyHandler = {
|
|
|
3402
3592
|
} else if (property === "sublevel") {
|
|
3403
3593
|
return (...args) => {
|
|
3404
3594
|
return new Proxy(
|
|
3595
|
+
// eslint-disable-next-line prefer-spread
|
|
3405
3596
|
target[property].apply(target, args),
|
|
3406
3597
|
LevelProxyHandler
|
|
3407
3598
|
);
|
|
@@ -4278,6 +4469,7 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
|
|
|
4278
4469
|
result.push({
|
|
4279
4470
|
type: opType,
|
|
4280
4471
|
key: `${collection.path}/${subFolderKey}.${collection.format}`,
|
|
4472
|
+
// replace the root with the collection path
|
|
4281
4473
|
sublevel: indexSublevel,
|
|
4282
4474
|
value: {}
|
|
4283
4475
|
});
|
|
@@ -4365,7 +4557,16 @@ var stringEscaper = makeStringEscaper(
|
|
|
4365
4557
|
var createResolver = (args) => {
|
|
4366
4558
|
return new Resolver(args);
|
|
4367
4559
|
};
|
|
4368
|
-
var resolveFieldData = async (
|
|
4560
|
+
var resolveFieldData = async (args) => {
|
|
4561
|
+
const {
|
|
4562
|
+
field: { namespace, ...field },
|
|
4563
|
+
rawData,
|
|
4564
|
+
accumulator,
|
|
4565
|
+
tinaSchema,
|
|
4566
|
+
config,
|
|
4567
|
+
isAudit,
|
|
4568
|
+
context
|
|
4569
|
+
} = args;
|
|
4369
4570
|
if (!rawData) {
|
|
4370
4571
|
return void 0;
|
|
4371
4572
|
}
|
|
@@ -4392,6 +4593,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4392
4593
|
case "password":
|
|
4393
4594
|
accumulator[field.name] = {
|
|
4394
4595
|
value: void 0,
|
|
4596
|
+
// never resolve the password hash
|
|
4395
4597
|
passwordChangeRequired: value["passwordChangeRequired"] ?? false
|
|
4396
4598
|
};
|
|
4397
4599
|
break;
|
|
@@ -4404,9 +4606,11 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4404
4606
|
break;
|
|
4405
4607
|
case "rich-text":
|
|
4406
4608
|
const tree = parseMDX(
|
|
4609
|
+
// @ts-ignore value is unknown
|
|
4407
4610
|
value,
|
|
4408
4611
|
field,
|
|
4409
|
-
(value2) => resolveMediaRelativeToCloud(value2, config, tinaSchema.schema)
|
|
4612
|
+
(value2) => resolveMediaRelativeToCloud(value2, config, tinaSchema.schema),
|
|
4613
|
+
context
|
|
4410
4614
|
);
|
|
4411
4615
|
if (tree?.children[0]?.type === "invalid_markdown") {
|
|
4412
4616
|
if (isAudit) {
|
|
@@ -4437,14 +4641,15 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4437
4641
|
});
|
|
4438
4642
|
const payload = {};
|
|
4439
4643
|
await sequential(template.fields, async (field2) => {
|
|
4440
|
-
await resolveFieldData(
|
|
4441
|
-
field2,
|
|
4442
|
-
item,
|
|
4443
|
-
payload,
|
|
4644
|
+
await resolveFieldData({
|
|
4645
|
+
field: field2,
|
|
4646
|
+
rawData: item,
|
|
4647
|
+
accumulator: payload,
|
|
4444
4648
|
tinaSchema,
|
|
4445
4649
|
config,
|
|
4446
|
-
isAudit
|
|
4447
|
-
|
|
4650
|
+
isAudit,
|
|
4651
|
+
context
|
|
4652
|
+
});
|
|
4448
4653
|
});
|
|
4449
4654
|
const isUnion = !!field.templates;
|
|
4450
4655
|
return isUnion ? {
|
|
@@ -4465,14 +4670,15 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4465
4670
|
});
|
|
4466
4671
|
const payload = {};
|
|
4467
4672
|
await sequential(template.fields, async (field2) => {
|
|
4468
|
-
await resolveFieldData(
|
|
4469
|
-
field2,
|
|
4470
|
-
value,
|
|
4471
|
-
payload,
|
|
4673
|
+
await resolveFieldData({
|
|
4674
|
+
field: field2,
|
|
4675
|
+
rawData: value,
|
|
4676
|
+
accumulator: payload,
|
|
4472
4677
|
tinaSchema,
|
|
4473
4678
|
config,
|
|
4474
|
-
isAudit
|
|
4475
|
-
|
|
4679
|
+
isAudit,
|
|
4680
|
+
context
|
|
4681
|
+
});
|
|
4476
4682
|
});
|
|
4477
4683
|
const isUnion = !!field.templates;
|
|
4478
4684
|
accumulator[field.name] = isUnion ? {
|
|
@@ -4486,7 +4692,8 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4486
4692
|
}
|
|
4487
4693
|
return accumulator;
|
|
4488
4694
|
};
|
|
4489
|
-
var transformDocumentIntoPayload = async (
|
|
4695
|
+
var transformDocumentIntoPayload = async (args) => {
|
|
4696
|
+
const { fullPath, rawData, tinaSchema, config, isAudit, context } = args;
|
|
4490
4697
|
const collection = tinaSchema.getCollection(rawData._collection);
|
|
4491
4698
|
try {
|
|
4492
4699
|
const template = tinaSchema.getTemplateForData({
|
|
@@ -4506,14 +4713,15 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
|
|
|
4506
4713
|
};
|
|
4507
4714
|
try {
|
|
4508
4715
|
await sequential(template.fields, async (field) => {
|
|
4509
|
-
return resolveFieldData(
|
|
4716
|
+
return resolveFieldData({
|
|
4510
4717
|
field,
|
|
4511
4718
|
rawData,
|
|
4512
|
-
data,
|
|
4719
|
+
accumulator: data,
|
|
4513
4720
|
tinaSchema,
|
|
4514
4721
|
config,
|
|
4515
|
-
isAudit
|
|
4516
|
-
|
|
4722
|
+
isAudit,
|
|
4723
|
+
context
|
|
4724
|
+
});
|
|
4517
4725
|
});
|
|
4518
4726
|
} catch (e) {
|
|
4519
4727
|
throw new TinaParseDocumentError({
|
|
@@ -4540,7 +4748,7 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
|
|
|
4540
4748
|
basename,
|
|
4541
4749
|
filename,
|
|
4542
4750
|
extension,
|
|
4543
|
-
hasReferences,
|
|
4751
|
+
hasReferences: args.hasReferences,
|
|
4544
4752
|
path: fullPath,
|
|
4545
4753
|
relativePath,
|
|
4546
4754
|
breadcrumbs,
|
|
@@ -4582,10 +4790,12 @@ var updateObjectWithJsonPath = (obj, path7, newValue) => {
|
|
|
4582
4790
|
var Resolver = class {
|
|
4583
4791
|
constructor(init) {
|
|
4584
4792
|
this.init = init;
|
|
4793
|
+
this.context = {};
|
|
4585
4794
|
this.resolveCollection = async (args, collectionName, hasDocuments) => {
|
|
4586
4795
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
4587
4796
|
const extraFields = {};
|
|
4588
4797
|
return {
|
|
4798
|
+
// return the collection and hasDocuments to resolve documents at a lower level
|
|
4589
4799
|
documents: { collection, hasDocuments },
|
|
4590
4800
|
...collection,
|
|
4591
4801
|
...extraFields
|
|
@@ -4611,13 +4821,15 @@ var Resolver = class {
|
|
|
4611
4821
|
path: rawData["__folderPath"]
|
|
4612
4822
|
};
|
|
4613
4823
|
} else {
|
|
4614
|
-
|
|
4824
|
+
this.context = { ...rawData };
|
|
4825
|
+
return transformDocumentIntoPayload({
|
|
4615
4826
|
fullPath,
|
|
4616
4827
|
rawData,
|
|
4617
|
-
this.tinaSchema,
|
|
4618
|
-
this.config,
|
|
4619
|
-
this.isAudit
|
|
4620
|
-
|
|
4828
|
+
tinaSchema: this.tinaSchema,
|
|
4829
|
+
config: this.config,
|
|
4830
|
+
isAudit: this.isAudit,
|
|
4831
|
+
context: this.context
|
|
4832
|
+
});
|
|
4621
4833
|
}
|
|
4622
4834
|
};
|
|
4623
4835
|
this.getDocument = async (fullPath, opts = {}) => {
|
|
@@ -4625,15 +4837,17 @@ var Resolver = class {
|
|
|
4625
4837
|
throw new Error(`fullPath must be of type string for getDocument request`);
|
|
4626
4838
|
}
|
|
4627
4839
|
const rawData = await this.getRaw(fullPath);
|
|
4840
|
+
this.context = { ...rawData };
|
|
4628
4841
|
const hasReferences = opts?.checkReferences ? await this.hasReferences(fullPath, opts.collection) : void 0;
|
|
4629
|
-
return transformDocumentIntoPayload(
|
|
4842
|
+
return transformDocumentIntoPayload({
|
|
4630
4843
|
fullPath,
|
|
4631
4844
|
rawData,
|
|
4632
|
-
this.tinaSchema,
|
|
4633
|
-
this.config,
|
|
4634
|
-
this.isAudit,
|
|
4845
|
+
tinaSchema: this.tinaSchema,
|
|
4846
|
+
config: this.config,
|
|
4847
|
+
isAudit: this.isAudit,
|
|
4848
|
+
context: this.context,
|
|
4635
4849
|
hasReferences
|
|
4636
|
-
);
|
|
4850
|
+
});
|
|
4637
4851
|
};
|
|
4638
4852
|
this.deleteDocument = async (fullPath) => {
|
|
4639
4853
|
if (typeof fullPath !== "string") {
|
|
@@ -4672,7 +4886,9 @@ var Resolver = class {
|
|
|
4672
4886
|
);
|
|
4673
4887
|
} else {
|
|
4674
4888
|
return this.buildFieldMutations(
|
|
4889
|
+
// @ts-ignore FIXME Argument of type 'string | object' is not assignable to parameter of type '{ [fieldName: string]: string | object | (string | object)[]; }'
|
|
4675
4890
|
fieldValue,
|
|
4891
|
+
//@ts-ignore
|
|
4676
4892
|
objectTemplate,
|
|
4677
4893
|
existingData
|
|
4678
4894
|
);
|
|
@@ -4684,6 +4900,7 @@ var Resolver = class {
|
|
|
4684
4900
|
fieldValue.map(async (item) => {
|
|
4685
4901
|
if (typeof item === "string") {
|
|
4686
4902
|
throw new Error(
|
|
4903
|
+
//@ts-ignore
|
|
4687
4904
|
`Expected object for template value for field ${field.name}`
|
|
4688
4905
|
);
|
|
4689
4906
|
}
|
|
@@ -4692,16 +4909,19 @@ var Resolver = class {
|
|
|
4692
4909
|
});
|
|
4693
4910
|
const [templateName] = Object.entries(item)[0];
|
|
4694
4911
|
const template = templates.find(
|
|
4912
|
+
//@ts-ignore
|
|
4695
4913
|
(template2) => template2.name === templateName
|
|
4696
4914
|
);
|
|
4697
4915
|
if (!template) {
|
|
4698
4916
|
throw new Error(`Expected to find template ${templateName}`);
|
|
4699
4917
|
}
|
|
4700
4918
|
return {
|
|
4919
|
+
// @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
|
|
4701
4920
|
...await this.buildFieldMutations(
|
|
4702
4921
|
item[template.name],
|
|
4703
4922
|
template
|
|
4704
4923
|
),
|
|
4924
|
+
//@ts-ignore
|
|
4705
4925
|
_template: template.name
|
|
4706
4926
|
};
|
|
4707
4927
|
})
|
|
@@ -4709,6 +4929,7 @@ var Resolver = class {
|
|
|
4709
4929
|
} else {
|
|
4710
4930
|
if (typeof fieldValue === "string") {
|
|
4711
4931
|
throw new Error(
|
|
4932
|
+
//@ts-ignore
|
|
4712
4933
|
`Expected object for template value for field ${field.name}`
|
|
4713
4934
|
);
|
|
4714
4935
|
}
|
|
@@ -4717,16 +4938,19 @@ var Resolver = class {
|
|
|
4717
4938
|
});
|
|
4718
4939
|
const [templateName] = Object.entries(fieldValue)[0];
|
|
4719
4940
|
const template = templates.find(
|
|
4941
|
+
//@ts-ignore
|
|
4720
4942
|
(template2) => template2.name === templateName
|
|
4721
4943
|
);
|
|
4722
4944
|
if (!template) {
|
|
4723
4945
|
throw new Error(`Expected to find template ${templateName}`);
|
|
4724
4946
|
}
|
|
4725
4947
|
return {
|
|
4948
|
+
// @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
|
|
4726
4949
|
...await this.buildFieldMutations(
|
|
4727
4950
|
fieldValue[template.name],
|
|
4728
4951
|
template
|
|
4729
4952
|
),
|
|
4953
|
+
//@ts-ignore
|
|
4730
4954
|
_template: template.name
|
|
4731
4955
|
};
|
|
4732
4956
|
}
|
|
@@ -4766,6 +4990,7 @@ var Resolver = class {
|
|
|
4766
4990
|
return this.getDocument(realPath);
|
|
4767
4991
|
}
|
|
4768
4992
|
const params = await this.buildObjectMutations(
|
|
4993
|
+
// @ts-ignore
|
|
4769
4994
|
args.params[collection.name],
|
|
4770
4995
|
collection
|
|
4771
4996
|
);
|
|
@@ -4781,56 +5006,65 @@ var Resolver = class {
|
|
|
4781
5006
|
}) => {
|
|
4782
5007
|
const doc = await this.getDocument(realPath);
|
|
4783
5008
|
const oldDoc = this.resolveLegacyValues(doc?._rawData || {}, collection);
|
|
5009
|
+
let values;
|
|
4784
5010
|
if (isAddPendingDocument === true) {
|
|
4785
5011
|
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
4786
|
-
const
|
|
5012
|
+
const params = this.buildParams(args);
|
|
4787
5013
|
switch (templateInfo.type) {
|
|
4788
5014
|
case "object":
|
|
4789
|
-
if (
|
|
4790
|
-
const
|
|
4791
|
-
|
|
5015
|
+
if (params) {
|
|
5016
|
+
const mutationValues = await this.buildFieldMutations(
|
|
5017
|
+
params,
|
|
4792
5018
|
templateInfo.template,
|
|
4793
5019
|
doc?._rawData
|
|
4794
5020
|
);
|
|
4795
|
-
|
|
4796
|
-
realPath,
|
|
4797
|
-
{ ...oldDoc, ...values },
|
|
4798
|
-
collection.name
|
|
4799
|
-
);
|
|
5021
|
+
values = { ...oldDoc, ...mutationValues };
|
|
4800
5022
|
}
|
|
4801
5023
|
break;
|
|
4802
|
-
case "union":
|
|
5024
|
+
case "union": {
|
|
4803
5025
|
await sequential(templateInfo.templates, async (template) => {
|
|
4804
|
-
const templateParams =
|
|
5026
|
+
const templateParams = params[lastItem(template.namespace)];
|
|
4805
5027
|
if (templateParams) {
|
|
4806
5028
|
if (typeof templateParams === "string") {
|
|
4807
5029
|
throw new Error(
|
|
4808
5030
|
`Expected to find an object for template params, but got string`
|
|
4809
5031
|
);
|
|
4810
5032
|
}
|
|
4811
|
-
|
|
5033
|
+
values = {
|
|
4812
5034
|
...oldDoc,
|
|
4813
5035
|
...await this.buildFieldMutations(
|
|
5036
|
+
// @ts-ignore FIXME: failing on unknown, which we don't need to know because it's recursive
|
|
4814
5037
|
templateParams,
|
|
4815
5038
|
template,
|
|
4816
5039
|
doc?._rawData
|
|
4817
5040
|
),
|
|
4818
5041
|
_template: lastItem(template.namespace)
|
|
4819
5042
|
};
|
|
4820
|
-
await this.database.put(realPath, values, collection.name);
|
|
4821
5043
|
}
|
|
4822
5044
|
});
|
|
5045
|
+
}
|
|
4823
5046
|
}
|
|
4824
|
-
|
|
5047
|
+
} else {
|
|
5048
|
+
const params = await this.buildObjectMutations(
|
|
5049
|
+
//@ts-expect-error FIXME: Argument of type 'unknown' is not assignable to parameter of type 'FieldParams'
|
|
5050
|
+
isCollectionSpecific ? args.params : args.params[collection.name],
|
|
5051
|
+
collection,
|
|
5052
|
+
doc?._rawData
|
|
5053
|
+
);
|
|
5054
|
+
values = { ...oldDoc, ...params };
|
|
4825
5055
|
}
|
|
4826
|
-
const
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
5056
|
+
const _tinaEmbeds = this.context?._tinaEmbeds ? { _tinaEmbeds: this.context._tinaEmbeds } : {};
|
|
5057
|
+
await this.database.put(
|
|
5058
|
+
realPath,
|
|
5059
|
+
{ ...values, ..._tinaEmbeds },
|
|
5060
|
+
collection.name
|
|
4830
5061
|
);
|
|
4831
|
-
await this.database.put(realPath, { ...oldDoc, ...params }, collection.name);
|
|
4832
5062
|
return this.getDocument(realPath);
|
|
4833
5063
|
};
|
|
5064
|
+
/**
|
|
5065
|
+
* Returns top-level fields which are not defined in the collection, so their
|
|
5066
|
+
* values are not eliminated from Tina when new values are saved
|
|
5067
|
+
*/
|
|
4834
5068
|
this.resolveLegacyValues = (oldDoc, collection) => {
|
|
4835
5069
|
const legacyValues = {};
|
|
4836
5070
|
Object.entries(oldDoc).forEach(([key, value]) => {
|
|
@@ -5036,6 +5270,7 @@ var Resolver = class {
|
|
|
5036
5270
|
},
|
|
5037
5271
|
collection: referencedCollection,
|
|
5038
5272
|
hydrator: (path7) => path7
|
|
5273
|
+
// just return the path
|
|
5039
5274
|
}
|
|
5040
5275
|
);
|
|
5041
5276
|
const { edges } = resolvedCollectionConnection;
|
|
@@ -5103,6 +5338,12 @@ var Resolver = class {
|
|
|
5103
5338
|
}
|
|
5104
5339
|
};
|
|
5105
5340
|
};
|
|
5341
|
+
/**
|
|
5342
|
+
* Checks if a document has references to it
|
|
5343
|
+
* @param id The id of the document to check for references
|
|
5344
|
+
* @param c The collection to check for references
|
|
5345
|
+
* @returns true if the document has references, false otherwise
|
|
5346
|
+
*/
|
|
5106
5347
|
this.hasReferences = async (id, c) => {
|
|
5107
5348
|
let count = 0;
|
|
5108
5349
|
const deepRefs = this.tinaSchema.findReferences(c.name);
|
|
@@ -5137,6 +5378,12 @@ var Resolver = class {
|
|
|
5137
5378
|
}
|
|
5138
5379
|
return false;
|
|
5139
5380
|
};
|
|
5381
|
+
/**
|
|
5382
|
+
* Finds references to a document
|
|
5383
|
+
* @param id the id of the document to find references to
|
|
5384
|
+
* @param c the collection to find references in
|
|
5385
|
+
* @returns references to the document in the form of a map of collection names to a list of fields that reference the document
|
|
5386
|
+
*/
|
|
5140
5387
|
this.findReferences = async (id, c) => {
|
|
5141
5388
|
const references = {};
|
|
5142
5389
|
const deepRefs = this.tinaSchema.findReferences(c.name);
|
|
@@ -5245,13 +5492,15 @@ var Resolver = class {
|
|
|
5245
5492
|
break;
|
|
5246
5493
|
case "rich-text":
|
|
5247
5494
|
accum[fieldName] = stringifyMDX(
|
|
5495
|
+
// @ts-ignore
|
|
5248
5496
|
fieldValue,
|
|
5249
5497
|
field,
|
|
5250
5498
|
(fieldValue2) => resolveMediaCloudToRelative(
|
|
5251
5499
|
fieldValue2,
|
|
5252
5500
|
this.config,
|
|
5253
5501
|
this.tinaSchema.schema
|
|
5254
|
-
)
|
|
5502
|
+
),
|
|
5503
|
+
this.context
|
|
5255
5504
|
);
|
|
5256
5505
|
break;
|
|
5257
5506
|
case "reference":
|
|
@@ -5263,6 +5512,27 @@ var Resolver = class {
|
|
|
5263
5512
|
}
|
|
5264
5513
|
return accum;
|
|
5265
5514
|
};
|
|
5515
|
+
/**
|
|
5516
|
+
* A mutation looks nearly identical between updateDocument:
|
|
5517
|
+
* ```graphql
|
|
5518
|
+
* updateDocument(collection: $collection,relativePath: $path, params: {
|
|
5519
|
+
* post: {
|
|
5520
|
+
* title: "Hello, World"
|
|
5521
|
+
* }
|
|
5522
|
+
* })`
|
|
5523
|
+
* ```
|
|
5524
|
+
* and `updatePostDocument`:
|
|
5525
|
+
* ```graphql
|
|
5526
|
+
* updatePostDocument(relativePath: $path, params: {
|
|
5527
|
+
* title: "Hello, World"
|
|
5528
|
+
* })
|
|
5529
|
+
* ```
|
|
5530
|
+
* The problem here is that we don't know whether the payload came from `updateDocument`
|
|
5531
|
+
* or `updatePostDocument` (we could, but for now it's easier not to pipe those details through),
|
|
5532
|
+
* But we do know that when given a `args.collection` value, we can assume that
|
|
5533
|
+
* this was a `updateDocument` request, and thus - should grab the data
|
|
5534
|
+
* from the corresponding field name in the key
|
|
5535
|
+
*/
|
|
5266
5536
|
this.buildParams = (args) => {
|
|
5267
5537
|
try {
|
|
5268
5538
|
assertShape(
|
|
@@ -5362,7 +5632,10 @@ var resolve = async ({
|
|
|
5362
5632
|
const graphQLSchema = buildASTSchema(graphQLSchemaAst);
|
|
5363
5633
|
const tinaConfig = await database.getTinaSchema();
|
|
5364
5634
|
const tinaSchema = await createSchema({
|
|
5635
|
+
// TODO: please update all the types to import from @tinacms/schema-tools
|
|
5636
|
+
// @ts-ignore
|
|
5365
5637
|
schema: tinaConfig,
|
|
5638
|
+
// @ts-ignore
|
|
5366
5639
|
flags: tinaConfig?.meta?.flags
|
|
5367
5640
|
});
|
|
5368
5641
|
const resolver = createResolver({
|
|
@@ -5379,8 +5652,7 @@ var resolve = async ({
|
|
|
5379
5652
|
database
|
|
5380
5653
|
},
|
|
5381
5654
|
typeResolver: async (source, _args, info) => {
|
|
5382
|
-
if (source.__typename)
|
|
5383
|
-
return source.__typename;
|
|
5655
|
+
if (source.__typename) return source.__typename;
|
|
5384
5656
|
const namedType = getNamedType(info.returnType).toString();
|
|
5385
5657
|
const lookup = await database.getLookup(namedType);
|
|
5386
5658
|
if (lookup.resolveType === "unionData") {
|
|
@@ -5529,11 +5801,13 @@ var resolve = async ({
|
|
|
5529
5801
|
set(
|
|
5530
5802
|
params,
|
|
5531
5803
|
userField.path.slice(1),
|
|
5804
|
+
// remove _rawData from users path
|
|
5532
5805
|
users.map((u) => {
|
|
5533
5806
|
if (user[idFieldName] === u[idFieldName]) {
|
|
5534
5807
|
return user;
|
|
5535
5808
|
}
|
|
5536
5809
|
return {
|
|
5810
|
+
// don't overwrite other users' passwords
|
|
5537
5811
|
...u,
|
|
5538
5812
|
[passwordFieldName]: {
|
|
5539
5813
|
...u[passwordFieldName],
|
|
@@ -5556,6 +5830,9 @@ var resolve = async ({
|
|
|
5556
5830
|
}
|
|
5557
5831
|
const isCreation = lookup[info.fieldName] === "create";
|
|
5558
5832
|
switch (lookup.resolveType) {
|
|
5833
|
+
/**
|
|
5834
|
+
* `node(id: $id)`
|
|
5835
|
+
*/
|
|
5559
5836
|
case "nodeDocument":
|
|
5560
5837
|
assertShape(
|
|
5561
5838
|
args,
|
|
@@ -5587,6 +5864,7 @@ var resolve = async ({
|
|
|
5587
5864
|
collection: args.collection,
|
|
5588
5865
|
isMutation,
|
|
5589
5866
|
isCreation,
|
|
5867
|
+
// Right now this is the only case for deletion
|
|
5590
5868
|
isDeletion: info.fieldName === "deleteDocument",
|
|
5591
5869
|
isFolderCreation: info.fieldName === "createFolder",
|
|
5592
5870
|
isUpdateName: Boolean(args?.params?.relativePath),
|
|
@@ -5596,6 +5874,9 @@ var resolve = async ({
|
|
|
5596
5874
|
return result;
|
|
5597
5875
|
}
|
|
5598
5876
|
return value;
|
|
5877
|
+
/**
|
|
5878
|
+
* eg `getMovieDocument.data.actors`
|
|
5879
|
+
*/
|
|
5599
5880
|
case "multiCollectionDocumentList":
|
|
5600
5881
|
if (Array.isArray(value)) {
|
|
5601
5882
|
return {
|
|
@@ -5607,7 +5888,15 @@ var resolve = async ({
|
|
|
5607
5888
|
}
|
|
5608
5889
|
if (info.fieldName === "documents" && value?.collection && value?.hasDocuments) {
|
|
5609
5890
|
let filter = args.filter;
|
|
5610
|
-
if (
|
|
5891
|
+
if (
|
|
5892
|
+
// 1. Make sure that the filter exists
|
|
5893
|
+
typeof args?.filter !== "undefined" && args?.filter !== null && // 2. Make sure that the collection name exists
|
|
5894
|
+
// @ts-ignore
|
|
5895
|
+
typeof value?.collection?.name === "string" && // 3. Make sure that the collection name is in the filter and is not undefined
|
|
5896
|
+
// @ts-ignore
|
|
5897
|
+
Object.keys(args.filter).includes(value?.collection?.name) && // @ts-ignore
|
|
5898
|
+
typeof args.filter[value?.collection?.name] !== "undefined"
|
|
5899
|
+
) {
|
|
5611
5900
|
filter = args.filter[value.collection.name];
|
|
5612
5901
|
}
|
|
5613
5902
|
return resolver.resolveCollectionConnection({
|
|
@@ -5615,12 +5904,20 @@ var resolve = async ({
|
|
|
5615
5904
|
...args,
|
|
5616
5905
|
filter
|
|
5617
5906
|
},
|
|
5907
|
+
// @ts-ignore
|
|
5618
5908
|
collection: value.collection
|
|
5619
5909
|
});
|
|
5620
5910
|
}
|
|
5621
5911
|
throw new Error(
|
|
5622
5912
|
`Expected an array for result of ${info.fieldName} at ${info.path}`
|
|
5623
5913
|
);
|
|
5914
|
+
/**
|
|
5915
|
+
* Collections-specific getter
|
|
5916
|
+
* eg. `getPostDocument`/`createPostDocument`/`updatePostDocument`
|
|
5917
|
+
*
|
|
5918
|
+
* if coming from a query result
|
|
5919
|
+
* the field will be `node`
|
|
5920
|
+
*/
|
|
5624
5921
|
case "collectionDocument": {
|
|
5625
5922
|
if (value) {
|
|
5626
5923
|
return value;
|
|
@@ -5635,11 +5932,32 @@ var resolve = async ({
|
|
|
5635
5932
|
});
|
|
5636
5933
|
return result;
|
|
5637
5934
|
}
|
|
5935
|
+
/**
|
|
5936
|
+
* Collections-specific list getter
|
|
5937
|
+
* eg. `getPageList`
|
|
5938
|
+
*/
|
|
5638
5939
|
case "collectionDocumentList":
|
|
5639
5940
|
return resolver.resolveCollectionConnection({
|
|
5640
5941
|
args,
|
|
5641
5942
|
collection: tinaSchema.getCollection(lookup.collection)
|
|
5642
5943
|
});
|
|
5944
|
+
/**
|
|
5945
|
+
* A polymorphic data set, it can be from a document's data
|
|
5946
|
+
* of any nested object which can be one of many shapes
|
|
5947
|
+
*
|
|
5948
|
+
* ```graphql
|
|
5949
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
5950
|
+
* data {...} <- this part
|
|
5951
|
+
* }
|
|
5952
|
+
* ```
|
|
5953
|
+
* ```graphql
|
|
5954
|
+
* getBlockDocument(relativePath: $relativePath) {
|
|
5955
|
+
* data {
|
|
5956
|
+
* blocks {...} <- or this part
|
|
5957
|
+
* }
|
|
5958
|
+
* }
|
|
5959
|
+
* ```
|
|
5960
|
+
*/
|
|
5643
5961
|
case "unionData":
|
|
5644
5962
|
if (!value) {
|
|
5645
5963
|
if (args.relativePath) {
|
|
@@ -5704,8 +6022,7 @@ var TinaLevelClient = class extends ManyLevelGuest {
|
|
|
5704
6022
|
this.port = port || 9e3;
|
|
5705
6023
|
}
|
|
5706
6024
|
openConnection() {
|
|
5707
|
-
if (this._connected)
|
|
5708
|
-
return;
|
|
6025
|
+
if (this._connected) return;
|
|
5709
6026
|
const socket = connect(this.port);
|
|
5710
6027
|
pipeline(socket, this.createRpcStream(), socket, () => {
|
|
5711
6028
|
this._connected = false;
|
|
@@ -5715,7 +6032,7 @@ var TinaLevelClient = class extends ManyLevelGuest {
|
|
|
5715
6032
|
};
|
|
5716
6033
|
|
|
5717
6034
|
// src/database/index.ts
|
|
5718
|
-
import path4 from "path";
|
|
6035
|
+
import path4 from "node:path";
|
|
5719
6036
|
import { GraphQLError as GraphQLError5 } from "graphql";
|
|
5720
6037
|
import micromatch2 from "micromatch";
|
|
5721
6038
|
import sha2 from "js-sha1";
|
|
@@ -5886,6 +6203,7 @@ var Database = class {
|
|
|
5886
6203
|
"put",
|
|
5887
6204
|
level
|
|
5888
6205
|
),
|
|
6206
|
+
// folder indices
|
|
5889
6207
|
...makeIndexOpsForDocument(
|
|
5890
6208
|
normalizedPath,
|
|
5891
6209
|
`${collection?.name}_${folderKey}`,
|
|
@@ -5908,6 +6226,7 @@ var Database = class {
|
|
|
5908
6226
|
"del",
|
|
5909
6227
|
level
|
|
5910
6228
|
),
|
|
6229
|
+
// folder indices
|
|
5911
6230
|
...makeIndexOpsForDocument(
|
|
5912
6231
|
normalizedPath,
|
|
5913
6232
|
`${collection?.name}_${folderKey}`,
|
|
@@ -6001,6 +6320,7 @@ var Database = class {
|
|
|
6001
6320
|
"put",
|
|
6002
6321
|
level
|
|
6003
6322
|
),
|
|
6323
|
+
// folder indices
|
|
6004
6324
|
...makeIndexOpsForDocument(
|
|
6005
6325
|
normalizedPath,
|
|
6006
6326
|
`${collection?.name}_${folderKey}`,
|
|
@@ -6023,6 +6343,7 @@ var Database = class {
|
|
|
6023
6343
|
"del",
|
|
6024
6344
|
level
|
|
6025
6345
|
),
|
|
6346
|
+
// folder indices
|
|
6026
6347
|
...makeIndexOpsForDocument(
|
|
6027
6348
|
normalizedPath,
|
|
6028
6349
|
`${collection?.name}_${folderKey}`,
|
|
@@ -6100,6 +6421,7 @@ var Database = class {
|
|
|
6100
6421
|
aliasedData,
|
|
6101
6422
|
extension,
|
|
6102
6423
|
writeTemplateKey,
|
|
6424
|
+
//templateInfo.type === 'union',
|
|
6103
6425
|
{
|
|
6104
6426
|
frontmatterFormat: collection?.frontmatterFormat,
|
|
6105
6427
|
frontmatterDelimiters: collection?.frontmatterDelimiters
|
|
@@ -6138,6 +6460,7 @@ var Database = class {
|
|
|
6138
6460
|
SUBLEVEL_OPTIONS
|
|
6139
6461
|
).get(graphqlPath);
|
|
6140
6462
|
};
|
|
6463
|
+
//TODO - is there a reason why the database fetches some config with "bridge.get", and some with "store.get"?
|
|
6141
6464
|
this.getGraphQLSchemaFromBridge = async () => {
|
|
6142
6465
|
if (!this.bridge) {
|
|
6143
6466
|
throw new Error(`No bridge configured`);
|
|
@@ -6184,6 +6507,7 @@ var Database = class {
|
|
|
6184
6507
|
for (const collection of collections) {
|
|
6185
6508
|
const indexDefinitions = {
|
|
6186
6509
|
[DEFAULT_COLLECTION_SORT_KEY]: { fields: [] }
|
|
6510
|
+
// provide a default sort key which is the file sort
|
|
6187
6511
|
};
|
|
6188
6512
|
if (collection.fields) {
|
|
6189
6513
|
for (const field of collection.fields) {
|
|
@@ -6507,12 +6831,12 @@ var Database = class {
|
|
|
6507
6831
|
if (collection?.isDetached) {
|
|
6508
6832
|
level = this.appLevel.sublevel(collection?.name, SUBLEVEL_OPTIONS);
|
|
6509
6833
|
}
|
|
6510
|
-
const
|
|
6834
|
+
const normalizedPath = normalizePath(filepath);
|
|
6511
6835
|
const rootSublevel = level.sublevel(
|
|
6512
6836
|
CONTENT_ROOT_PREFIX,
|
|
6513
6837
|
SUBLEVEL_OPTIONS
|
|
6514
6838
|
);
|
|
6515
|
-
const item = await rootSublevel.get(
|
|
6839
|
+
const item = await rootSublevel.get(normalizedPath);
|
|
6516
6840
|
if (item) {
|
|
6517
6841
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
6518
6842
|
const folderKey = folderTreeBuilder.update(
|
|
@@ -6521,15 +6845,16 @@ var Database = class {
|
|
|
6521
6845
|
);
|
|
6522
6846
|
await this.contentLevel.batch([
|
|
6523
6847
|
...makeIndexOpsForDocument(
|
|
6524
|
-
|
|
6848
|
+
normalizedPath,
|
|
6525
6849
|
collection.name,
|
|
6526
6850
|
collectionIndexDefinitions,
|
|
6527
6851
|
item,
|
|
6528
6852
|
"del",
|
|
6529
6853
|
level
|
|
6530
6854
|
),
|
|
6855
|
+
// folder indices
|
|
6531
6856
|
...makeIndexOpsForDocument(
|
|
6532
|
-
|
|
6857
|
+
normalizedPath,
|
|
6533
6858
|
`${collection.name}_${folderKey}`,
|
|
6534
6859
|
collectionIndexDefinitions,
|
|
6535
6860
|
item,
|
|
@@ -6538,17 +6863,17 @@ var Database = class {
|
|
|
6538
6863
|
),
|
|
6539
6864
|
{
|
|
6540
6865
|
type: "del",
|
|
6541
|
-
key:
|
|
6866
|
+
key: normalizedPath,
|
|
6542
6867
|
sublevel: rootSublevel
|
|
6543
6868
|
}
|
|
6544
6869
|
]);
|
|
6545
6870
|
}
|
|
6546
6871
|
if (!collection?.isDetached) {
|
|
6547
6872
|
if (this.bridge) {
|
|
6548
|
-
await this.bridge.delete(
|
|
6873
|
+
await this.bridge.delete(normalizedPath);
|
|
6549
6874
|
}
|
|
6550
6875
|
try {
|
|
6551
|
-
await this.onDelete(
|
|
6876
|
+
await this.onDelete(normalizedPath);
|
|
6552
6877
|
} catch (e) {
|
|
6553
6878
|
throw new GraphQLError5(
|
|
6554
6879
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
@@ -6682,6 +7007,9 @@ var Database = class {
|
|
|
6682
7007
|
info: templateInfo
|
|
6683
7008
|
};
|
|
6684
7009
|
}
|
|
7010
|
+
/**
|
|
7011
|
+
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
7012
|
+
*/
|
|
6685
7013
|
clearCache() {
|
|
6686
7014
|
this.tinaSchema = null;
|
|
6687
7015
|
this._lookup = null;
|
|
@@ -6778,6 +7106,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
6778
7106
|
"put",
|
|
6779
7107
|
level
|
|
6780
7108
|
),
|
|
7109
|
+
// folder indexes
|
|
6781
7110
|
...makeIndexOpsForDocument(
|
|
6782
7111
|
normalizedPath,
|
|
6783
7112
|
`${collection?.name}_${folderKey}`,
|
|
@@ -6863,6 +7192,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
|
|
|
6863
7192
|
"del",
|
|
6864
7193
|
database.contentLevel
|
|
6865
7194
|
),
|
|
7195
|
+
// folder indexes
|
|
6866
7196
|
...makeIndexOpsForDocument(
|
|
6867
7197
|
itemKey,
|
|
6868
7198
|
`${collection?.name}_${folderKey}`,
|
|
@@ -7078,17 +7408,26 @@ var IsomorphicBridge = class {
|
|
|
7078
7408
|
getAuthor() {
|
|
7079
7409
|
return {
|
|
7080
7410
|
...this.author,
|
|
7081
|
-
timestamp: Math.round(new Date().getTime() / 1e3),
|
|
7411
|
+
timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
7082
7412
|
timezoneOffset: 0
|
|
7083
7413
|
};
|
|
7084
7414
|
}
|
|
7085
7415
|
getCommitter() {
|
|
7086
7416
|
return {
|
|
7087
7417
|
...this.committer,
|
|
7088
|
-
timestamp: Math.round(new Date().getTime() / 1e3),
|
|
7418
|
+
timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
7089
7419
|
timezoneOffset: 0
|
|
7090
7420
|
};
|
|
7091
7421
|
}
|
|
7422
|
+
/**
|
|
7423
|
+
* Recursively populate paths matching `pattern` for the given `entry`
|
|
7424
|
+
*
|
|
7425
|
+
* @param pattern - pattern to filter paths by
|
|
7426
|
+
* @param entry - TreeEntry to start building list from
|
|
7427
|
+
* @param path - base path
|
|
7428
|
+
* @param results
|
|
7429
|
+
* @private
|
|
7430
|
+
*/
|
|
7092
7431
|
async listEntries({
|
|
7093
7432
|
pattern,
|
|
7094
7433
|
entry,
|
|
@@ -7121,6 +7460,15 @@ var IsomorphicBridge = class {
|
|
|
7121
7460
|
});
|
|
7122
7461
|
}
|
|
7123
7462
|
}
|
|
7463
|
+
/**
|
|
7464
|
+
* For the specified path, returns an object with an array containing the parts of the path (pathParts)
|
|
7465
|
+
* and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
|
|
7466
|
+
* pathEntries are placeholders for non-existent entries.
|
|
7467
|
+
*
|
|
7468
|
+
* @param path - path being resolved
|
|
7469
|
+
* @param ref - ref to resolve path entries for
|
|
7470
|
+
* @private
|
|
7471
|
+
*/
|
|
7124
7472
|
async resolvePathEntries(path7, ref) {
|
|
7125
7473
|
let pathParts = path7.split("/");
|
|
7126
7474
|
const result = await git2.walk({
|
|
@@ -7151,6 +7499,17 @@ var IsomorphicBridge = class {
|
|
|
7151
7499
|
}
|
|
7152
7500
|
return { pathParts, pathEntries };
|
|
7153
7501
|
}
|
|
7502
|
+
/**
|
|
7503
|
+
* Updates tree entry and associated parent tree entries
|
|
7504
|
+
*
|
|
7505
|
+
* @param existingOid - the existing OID
|
|
7506
|
+
* @param updatedOid - the updated OID
|
|
7507
|
+
* @param path - the path of the entry being updated
|
|
7508
|
+
* @param type - the type of the entry being updated (blob or tree)
|
|
7509
|
+
* @param pathEntries - parent path entries
|
|
7510
|
+
* @param pathParts - parent path parts
|
|
7511
|
+
* @private
|
|
7512
|
+
*/
|
|
7154
7513
|
async updateTreeHierarchy(existingOid, updatedOid, path7, type, pathEntries, pathParts) {
|
|
7155
7514
|
const lastIdx = pathEntries.length - 1;
|
|
7156
7515
|
const parentEntry = pathEntries[lastIdx];
|
|
@@ -7206,6 +7565,13 @@ var IsomorphicBridge = class {
|
|
|
7206
7565
|
);
|
|
7207
7566
|
}
|
|
7208
7567
|
}
|
|
7568
|
+
/**
|
|
7569
|
+
* Creates a commit for the specified tree and updates the specified ref to point to the commit
|
|
7570
|
+
*
|
|
7571
|
+
* @param treeSha - sha of the new tree
|
|
7572
|
+
* @param ref - the ref that should be updated
|
|
7573
|
+
* @private
|
|
7574
|
+
*/
|
|
7209
7575
|
async commitTree(treeSha, ref) {
|
|
7210
7576
|
const commitSha = await git2.writeCommit({
|
|
7211
7577
|
...this.isomorphicConfig,
|
|
@@ -7218,6 +7584,7 @@ var IsomorphicBridge = class {
|
|
|
7218
7584
|
})
|
|
7219
7585
|
],
|
|
7220
7586
|
message: this.commitMessage,
|
|
7587
|
+
// TODO these should be configurable
|
|
7221
7588
|
author: this.getAuthor(),
|
|
7222
7589
|
committer: this.getCommitter()
|
|
7223
7590
|
}
|
|
@@ -7455,5 +7822,5 @@ export {
|
|
|
7455
7822
|
transformDocument,
|
|
7456
7823
|
transformDocumentIntoPayload
|
|
7457
7824
|
};
|
|
7458
|
-
//! Replaces _.flattenDeep()
|
|
7459
7825
|
//! Replaces _.get()
|
|
7826
|
+
//! Replaces _.flattenDeep()
|