@tinacms/graphql 1.5.8 → 1.5.10
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 +437 -90
- package/dist/index.mjs +408 -65
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -17,6 +17,10 @@ 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
|
));
|
|
@@ -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: {
|
|
@@ -197,6 +210,10 @@ var SysFieldDefinition = {
|
|
|
197
210
|
}
|
|
198
211
|
};
|
|
199
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
|
+
*/
|
|
200
217
|
FormFieldBuilder: ({
|
|
201
218
|
name,
|
|
202
219
|
additionalFields
|
|
@@ -420,6 +437,8 @@ var astBuilder = {
|
|
|
420
437
|
kind: "Name",
|
|
421
438
|
value: name
|
|
422
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
|
|
423
442
|
fields
|
|
424
443
|
}),
|
|
425
444
|
UnionTypeDefinition: ({
|
|
@@ -432,6 +451,8 @@ var astBuilder = {
|
|
|
432
451
|
value: name
|
|
433
452
|
},
|
|
434
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
|
|
435
456
|
types: types.map((name2) => ({
|
|
436
457
|
kind: "NamedType",
|
|
437
458
|
name: {
|
|
@@ -528,8 +549,11 @@ var astBuilder = {
|
|
|
528
549
|
string: "String",
|
|
529
550
|
boolean: "Boolean",
|
|
530
551
|
number: "Float",
|
|
552
|
+
// FIXME - needs to be float or int
|
|
531
553
|
datetime: "String",
|
|
554
|
+
// FIXME
|
|
532
555
|
image: "String",
|
|
556
|
+
// FIXME
|
|
533
557
|
text: "String"
|
|
534
558
|
};
|
|
535
559
|
return scalars[type];
|
|
@@ -1028,8 +1052,7 @@ var astBuilder = {
|
|
|
1028
1052
|
}
|
|
1029
1053
|
};
|
|
1030
1054
|
var capitalize = (s) => {
|
|
1031
|
-
if (typeof s !== "string")
|
|
1032
|
-
return "";
|
|
1055
|
+
if (typeof s !== "string") return "";
|
|
1033
1056
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
1034
1057
|
};
|
|
1035
1058
|
var extractInlineTypes = (item) => {
|
|
@@ -1072,41 +1095,6 @@ function* walk(maybeNode, visited = /* @__PURE__ */ new WeakSet()) {
|
|
|
1072
1095
|
yield maybeNode;
|
|
1073
1096
|
visited.add(maybeNode);
|
|
1074
1097
|
}
|
|
1075
|
-
function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
1076
|
-
if (typeof maybeNode === "string") {
|
|
1077
|
-
return maybeNode;
|
|
1078
|
-
}
|
|
1079
|
-
if (typeof maybeNode === "boolean") {
|
|
1080
|
-
return maybeNode;
|
|
1081
|
-
}
|
|
1082
|
-
const newNode = maybeNode;
|
|
1083
|
-
const keys = Object.keys(maybeNode);
|
|
1084
|
-
Object.values(maybeNode).map((m, index) => {
|
|
1085
|
-
const key = keys[index];
|
|
1086
|
-
if (Array.isArray(m)) {
|
|
1087
|
-
newNode[key] = m.map((element) => {
|
|
1088
|
-
if (!element) {
|
|
1089
|
-
return;
|
|
1090
|
-
}
|
|
1091
|
-
if (!element.hasOwnProperty("name")) {
|
|
1092
|
-
return element;
|
|
1093
|
-
}
|
|
1094
|
-
const value = element.name || element.value;
|
|
1095
|
-
return addNamespaceToSchema(element, [...namespace, value]);
|
|
1096
|
-
});
|
|
1097
|
-
} else {
|
|
1098
|
-
if (!m) {
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
if (!m.hasOwnProperty("name")) {
|
|
1102
|
-
newNode[key] = m;
|
|
1103
|
-
} else {
|
|
1104
|
-
newNode[key] = addNamespaceToSchema(m, [...namespace, m.name]);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
return { ...newNode, namespace };
|
|
1109
|
-
}
|
|
1110
1098
|
var generateNamespacedFieldName = (names, suffix = "") => {
|
|
1111
1099
|
return (suffix ? [...names, suffix] : names).map(capitalize).join("");
|
|
1112
1100
|
};
|
|
@@ -1485,6 +1473,19 @@ var Builder = class {
|
|
|
1485
1473
|
this.addToLookupMap = (lookup) => {
|
|
1486
1474
|
this.lookupMap[lookup.type] = lookup;
|
|
1487
1475
|
};
|
|
1476
|
+
/**
|
|
1477
|
+
* ```graphql
|
|
1478
|
+
* # ex.
|
|
1479
|
+
* {
|
|
1480
|
+
* getCollection(collection: $collection) {
|
|
1481
|
+
* name
|
|
1482
|
+
* documents {...}
|
|
1483
|
+
* }
|
|
1484
|
+
* }
|
|
1485
|
+
* ```
|
|
1486
|
+
*
|
|
1487
|
+
* @param collections
|
|
1488
|
+
*/
|
|
1488
1489
|
this.buildCollectionDefinition = async (collections) => {
|
|
1489
1490
|
const name = "collection";
|
|
1490
1491
|
const typeName = "Collection";
|
|
@@ -1555,6 +1556,19 @@ var Builder = class {
|
|
|
1555
1556
|
required: true
|
|
1556
1557
|
});
|
|
1557
1558
|
};
|
|
1559
|
+
/**
|
|
1560
|
+
* ```graphql
|
|
1561
|
+
* # ex.
|
|
1562
|
+
* {
|
|
1563
|
+
* getCollections {
|
|
1564
|
+
* name
|
|
1565
|
+
* documents {...}
|
|
1566
|
+
* }
|
|
1567
|
+
* }
|
|
1568
|
+
* ```
|
|
1569
|
+
*
|
|
1570
|
+
* @param collections
|
|
1571
|
+
*/
|
|
1558
1572
|
this.buildMultiCollectionDefinition = async (collections) => {
|
|
1559
1573
|
const name = "collections";
|
|
1560
1574
|
const typeName = "Collection";
|
|
@@ -1565,6 +1579,17 @@ var Builder = class {
|
|
|
1565
1579
|
required: true
|
|
1566
1580
|
});
|
|
1567
1581
|
};
|
|
1582
|
+
/**
|
|
1583
|
+
* ```graphql
|
|
1584
|
+
* # ex.
|
|
1585
|
+
* {
|
|
1586
|
+
* node(id: $id) {
|
|
1587
|
+
* id
|
|
1588
|
+
* data {...}
|
|
1589
|
+
* }
|
|
1590
|
+
* }
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1568
1593
|
this.multiNodeDocument = async () => {
|
|
1569
1594
|
const name = "node";
|
|
1570
1595
|
const args = [
|
|
@@ -1585,6 +1610,19 @@ var Builder = class {
|
|
|
1585
1610
|
required: true
|
|
1586
1611
|
});
|
|
1587
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
|
+
*/
|
|
1588
1626
|
this.multiCollectionDocument = async (collections) => {
|
|
1589
1627
|
const name = "document";
|
|
1590
1628
|
const args = [
|
|
@@ -1610,6 +1648,19 @@ var Builder = class {
|
|
|
1610
1648
|
required: true
|
|
1611
1649
|
});
|
|
1612
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
|
+
*/
|
|
1613
1664
|
this.addMultiCollectionDocumentMutation = async () => {
|
|
1614
1665
|
return astBuilder.FieldDefinition({
|
|
1615
1666
|
name: "addPendingDocument",
|
|
@@ -1634,6 +1685,19 @@ var Builder = class {
|
|
|
1634
1685
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1635
1686
|
});
|
|
1636
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
|
+
*/
|
|
1637
1701
|
this.buildCreateCollectionDocumentMutation = async (collections) => {
|
|
1638
1702
|
return astBuilder.FieldDefinition({
|
|
1639
1703
|
name: "createDocument",
|
|
@@ -1661,6 +1725,19 @@ var Builder = class {
|
|
|
1661
1725
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1662
1726
|
});
|
|
1663
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
|
+
*/
|
|
1664
1741
|
this.buildUpdateCollectionDocumentMutation = async (collections) => {
|
|
1665
1742
|
return astBuilder.FieldDefinition({
|
|
1666
1743
|
name: "updateDocument",
|
|
@@ -1688,6 +1765,19 @@ var Builder = class {
|
|
|
1688
1765
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1689
1766
|
});
|
|
1690
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
|
+
*/
|
|
1691
1781
|
this.buildDeleteCollectionDocumentMutation = async (collections) => {
|
|
1692
1782
|
return astBuilder.FieldDefinition({
|
|
1693
1783
|
name: "deleteDocument",
|
|
@@ -1707,6 +1797,19 @@ var Builder = class {
|
|
|
1707
1797
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1708
1798
|
});
|
|
1709
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
|
+
*/
|
|
1710
1813
|
this.buildCreateCollectionFolderMutation = async () => {
|
|
1711
1814
|
return astBuilder.FieldDefinition({
|
|
1712
1815
|
name: "createFolder",
|
|
@@ -1726,6 +1829,19 @@ var Builder = class {
|
|
|
1726
1829
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
1727
1830
|
});
|
|
1728
1831
|
};
|
|
1832
|
+
/**
|
|
1833
|
+
* ```graphql
|
|
1834
|
+
* # ex.
|
|
1835
|
+
* {
|
|
1836
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
1837
|
+
* id
|
|
1838
|
+
* data {...}
|
|
1839
|
+
* }
|
|
1840
|
+
* }
|
|
1841
|
+
* ```
|
|
1842
|
+
*
|
|
1843
|
+
* @param collection
|
|
1844
|
+
*/
|
|
1729
1845
|
this.collectionDocument = async (collection) => {
|
|
1730
1846
|
const name = NAMER.queryName([collection.name]);
|
|
1731
1847
|
const type = await this._buildCollectionDocumentType(collection);
|
|
@@ -1786,6 +1902,20 @@ var Builder = class {
|
|
|
1786
1902
|
const args = [];
|
|
1787
1903
|
return astBuilder.FieldDefinition({ type, name, args, required: false });
|
|
1788
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
|
+
*/
|
|
1789
1919
|
this.collectionFragment = async (collection) => {
|
|
1790
1920
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
1791
1921
|
const fragmentName = NAMER.fragmentName(collection.namespace);
|
|
@@ -1799,6 +1929,20 @@ var Builder = class {
|
|
|
1799
1929
|
selections: filterSelections(selections)
|
|
1800
1930
|
});
|
|
1801
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
|
+
* */
|
|
1802
1946
|
this._getCollectionFragmentSelections = async (collection, depth) => {
|
|
1803
1947
|
var _a;
|
|
1804
1948
|
const selections = [];
|
|
@@ -1882,9 +2026,9 @@ var Builder = class {
|
|
|
1882
2026
|
]
|
|
1883
2027
|
});
|
|
1884
2028
|
}
|
|
2029
|
+
// TODO: Should we throw here?
|
|
1885
2030
|
case "reference":
|
|
1886
|
-
if (depth >= this.maxDepth)
|
|
1887
|
-
return false;
|
|
2031
|
+
if (depth >= this.maxDepth) return false;
|
|
1888
2032
|
if (!("collections" in field)) {
|
|
1889
2033
|
return false;
|
|
1890
2034
|
}
|
|
@@ -1916,6 +2060,7 @@ var Builder = class {
|
|
|
1916
2060
|
name: field.name,
|
|
1917
2061
|
selections: [
|
|
1918
2062
|
...selections,
|
|
2063
|
+
// This is ... on Document { id }
|
|
1919
2064
|
{
|
|
1920
2065
|
kind: "InlineFragment",
|
|
1921
2066
|
typeCondition: {
|
|
@@ -1946,6 +2091,19 @@ var Builder = class {
|
|
|
1946
2091
|
});
|
|
1947
2092
|
}
|
|
1948
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
|
+
*/
|
|
1949
2107
|
this.updateCollectionDocumentMutation = async (collection) => {
|
|
1950
2108
|
return astBuilder.FieldDefinition({
|
|
1951
2109
|
type: await this._buildCollectionDocumentType(collection),
|
|
@@ -1965,6 +2123,19 @@ var Builder = class {
|
|
|
1965
2123
|
]
|
|
1966
2124
|
});
|
|
1967
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
|
+
*/
|
|
1968
2139
|
this.createCollectionDocumentMutation = async (collection) => {
|
|
1969
2140
|
return astBuilder.FieldDefinition({
|
|
1970
2141
|
type: await this._buildCollectionDocumentType(collection),
|
|
@@ -1984,6 +2155,22 @@ var Builder = class {
|
|
|
1984
2155
|
]
|
|
1985
2156
|
});
|
|
1986
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
|
+
*/
|
|
1987
2174
|
this.collectionDocumentList = async (collection) => {
|
|
1988
2175
|
const connectionName = NAMER.referenceConnectionType(collection.namespace);
|
|
1989
2176
|
this.addToLookupMap({
|
|
@@ -1999,6 +2186,10 @@ var Builder = class {
|
|
|
1999
2186
|
collection
|
|
2000
2187
|
});
|
|
2001
2188
|
};
|
|
2189
|
+
/**
|
|
2190
|
+
* GraphQL type definitions which remain unchanged regardless
|
|
2191
|
+
* of the supplied Tina schema. Ex. "node" interface
|
|
2192
|
+
*/
|
|
2002
2193
|
this.buildStaticDefinitions = () => staticDefinitions;
|
|
2003
2194
|
this._buildCollectionDocumentType = async (collection, suffix = "", extraFields = [], extraInterfaces = []) => {
|
|
2004
2195
|
const documentTypeName = NAMER.documentTypeName(collection.namespace);
|
|
@@ -2503,6 +2694,7 @@ var Builder = class {
|
|
|
2503
2694
|
name: NAMER.dataFilterTypeName(namespace),
|
|
2504
2695
|
fields: await sequential(collections, async (collection2) => {
|
|
2505
2696
|
return astBuilder.InputValueDefinition({
|
|
2697
|
+
// @ts-ignore
|
|
2506
2698
|
name: collection2.name,
|
|
2507
2699
|
type: NAMER.dataFilterTypeName(collection2.namespace)
|
|
2508
2700
|
});
|
|
@@ -2692,7 +2884,8 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
2692
2884
|
});
|
|
2693
2885
|
};
|
|
2694
2886
|
var _a, _b, _c, _d;
|
|
2695
|
-
this.maxDepth =
|
|
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;
|
|
2696
2889
|
this.tinaSchema = config.tinaSchema;
|
|
2697
2890
|
this.lookupMap = {};
|
|
2698
2891
|
}
|
|
@@ -2703,8 +2896,7 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
2703
2896
|
selections.push(field);
|
|
2704
2897
|
});
|
|
2705
2898
|
const filteredSelections = filterSelections(selections);
|
|
2706
|
-
if (!filteredSelections.length)
|
|
2707
|
-
return false;
|
|
2899
|
+
if (!filteredSelections.length) return false;
|
|
2708
2900
|
return astBuilder.InlineFragmentDefinition({
|
|
2709
2901
|
selections: filteredSelections,
|
|
2710
2902
|
name: NAMER.dataTypeName(template.namespace)
|
|
@@ -2738,12 +2930,13 @@ var filterSelections = (arr) => {
|
|
|
2738
2930
|
};
|
|
2739
2931
|
|
|
2740
2932
|
// src/schema/createSchema.ts
|
|
2741
|
-
var
|
|
2933
|
+
var import_schema_tools3 = require("@tinacms/schema-tools");
|
|
2742
2934
|
|
|
2743
2935
|
// src/schema/validate.ts
|
|
2936
|
+
var import_schema_tools = require("@tinacms/schema-tools");
|
|
2744
2937
|
var import_lodash2 = __toESM(require("lodash.clonedeep"));
|
|
2745
2938
|
var yup2 = __toESM(require("yup"));
|
|
2746
|
-
var
|
|
2939
|
+
var import_schema_tools2 = require("@tinacms/schema-tools");
|
|
2747
2940
|
var FIELD_TYPES = [
|
|
2748
2941
|
"string",
|
|
2749
2942
|
"number",
|
|
@@ -2756,7 +2949,7 @@ var FIELD_TYPES = [
|
|
|
2756
2949
|
"password"
|
|
2757
2950
|
];
|
|
2758
2951
|
var validateSchema = async (schema) => {
|
|
2759
|
-
const schema2 = addNamespaceToSchema(
|
|
2952
|
+
const schema2 = (0, import_schema_tools.addNamespaceToSchema)(
|
|
2760
2953
|
(0, import_lodash2.default)(schema)
|
|
2761
2954
|
);
|
|
2762
2955
|
const collections = await sequential(
|
|
@@ -2765,7 +2958,7 @@ var validateSchema = async (schema) => {
|
|
|
2765
2958
|
);
|
|
2766
2959
|
validationCollectionsPathAndMatch(collections);
|
|
2767
2960
|
if (schema2.config) {
|
|
2768
|
-
const config = (0,
|
|
2961
|
+
const config = (0, import_schema_tools2.validateTinaCloudSchemaConfig)(schema2.config);
|
|
2769
2962
|
return {
|
|
2770
2963
|
collections,
|
|
2771
2964
|
config
|
|
@@ -2785,6 +2978,7 @@ var validationCollectionsPathAndMatch = (collections) => {
|
|
|
2785
2978
|
}).map((x) => `${x.path}${x.format || "md"}`);
|
|
2786
2979
|
if (noMatchCollections.length !== new Set(noMatchCollections).size) {
|
|
2787
2980
|
throw new Error(
|
|
2981
|
+
// TODO: add a link to the docs
|
|
2788
2982
|
"Two collections without match can not have the same `path`. Please make the `path` unique or add a matches property to the collection."
|
|
2789
2983
|
);
|
|
2790
2984
|
}
|
|
@@ -2896,7 +3090,7 @@ var validateField = async (field) => {
|
|
|
2896
3090
|
// package.json
|
|
2897
3091
|
var package_default = {
|
|
2898
3092
|
name: "@tinacms/graphql",
|
|
2899
|
-
version: "1.5.
|
|
3093
|
+
version: "1.5.10",
|
|
2900
3094
|
main: "dist/index.js",
|
|
2901
3095
|
module: "dist/index.mjs",
|
|
2902
3096
|
typings: "dist/index.d.ts",
|
|
@@ -2997,7 +3191,7 @@ var createSchema = async ({
|
|
|
2997
3191
|
if (flags && flags.length > 0) {
|
|
2998
3192
|
meta["flags"] = flags;
|
|
2999
3193
|
}
|
|
3000
|
-
return new
|
|
3194
|
+
return new import_schema_tools3.TinaSchema({
|
|
3001
3195
|
version: {
|
|
3002
3196
|
fullVersion: package_default.version,
|
|
3003
3197
|
major,
|
|
@@ -3053,6 +3247,7 @@ var _buildFragments = async (builder, tinaSchema) => {
|
|
|
3053
3247
|
const fragDoc = {
|
|
3054
3248
|
kind: "Document",
|
|
3055
3249
|
definitions: (0, import_lodash3.default)(
|
|
3250
|
+
// @ts-ignore
|
|
3056
3251
|
extractInlineTypes(fragmentDefinitionsFields),
|
|
3057
3252
|
(node) => node.name.value
|
|
3058
3253
|
)
|
|
@@ -3076,6 +3271,7 @@ var _buildQueries = async (builder, tinaSchema) => {
|
|
|
3076
3271
|
fragName,
|
|
3077
3272
|
queryName: queryListName,
|
|
3078
3273
|
filterType: queryFilterTypeName,
|
|
3274
|
+
// look for flag to see if the data layer is enabled
|
|
3079
3275
|
dataLayer: Boolean(
|
|
3080
3276
|
(_c = (_b = (_a = tinaSchema.config) == null ? void 0 : _a.meta) == null ? void 0 : _b.flags) == null ? void 0 : _c.find((x) => x === "experimentalData")
|
|
3081
3277
|
)
|
|
@@ -3085,6 +3281,7 @@ var _buildQueries = async (builder, tinaSchema) => {
|
|
|
3085
3281
|
const queryDoc = {
|
|
3086
3282
|
kind: "Document",
|
|
3087
3283
|
definitions: (0, import_lodash3.default)(
|
|
3284
|
+
// @ts-ignore
|
|
3088
3285
|
extractInlineTypes(operationsDefinitions),
|
|
3089
3286
|
(node) => node.name.value
|
|
3090
3287
|
)
|
|
@@ -3173,6 +3370,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
3173
3370
|
return {
|
|
3174
3371
|
kind: "Document",
|
|
3175
3372
|
definitions: (0, import_lodash3.default)(
|
|
3373
|
+
// @ts-ignore
|
|
3176
3374
|
extractInlineTypes(definitions),
|
|
3177
3375
|
(node) => node.name.value
|
|
3178
3376
|
)
|
|
@@ -3377,8 +3575,7 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
|
|
|
3377
3575
|
}
|
|
3378
3576
|
if (Array.isArray(value)) {
|
|
3379
3577
|
return value.map((v) => {
|
|
3380
|
-
if (!v || typeof v !== "string")
|
|
3381
|
-
return v;
|
|
3578
|
+
if (!v || typeof v !== "string") return v;
|
|
3382
3579
|
const cleanMediaRoot = cleanUpSlashes(
|
|
3383
3580
|
schema.config.media.tina.mediaRoot
|
|
3384
3581
|
);
|
|
@@ -3406,8 +3603,7 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3406
3603
|
}
|
|
3407
3604
|
if (Array.isArray(value)) {
|
|
3408
3605
|
return value.map((v) => {
|
|
3409
|
-
if (!v || typeof v !== "string")
|
|
3410
|
-
return v;
|
|
3606
|
+
if (!v || typeof v !== "string") return v;
|
|
3411
3607
|
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3412
3608
|
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3413
3609
|
});
|
|
@@ -3426,8 +3622,7 @@ var cleanUpSlashes = (path7) => {
|
|
|
3426
3622
|
};
|
|
3427
3623
|
var hasTinaMediaConfig = (schema) => {
|
|
3428
3624
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3429
|
-
if (!((_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina))
|
|
3430
|
-
return false;
|
|
3625
|
+
if (!((_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina)) return false;
|
|
3431
3626
|
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")
|
|
3432
3627
|
return false;
|
|
3433
3628
|
return true;
|
|
@@ -3471,6 +3666,7 @@ var LevelProxyHandler = {
|
|
|
3471
3666
|
} else if (property === "sublevel") {
|
|
3472
3667
|
return (...args) => {
|
|
3473
3668
|
return new Proxy(
|
|
3669
|
+
// eslint-disable-next-line prefer-spread
|
|
3474
3670
|
target[property].apply(target, args),
|
|
3475
3671
|
LevelProxyHandler
|
|
3476
3672
|
);
|
|
@@ -3493,7 +3689,7 @@ var import_path2 = __toESM(require("path"));
|
|
|
3493
3689
|
var import_toml = __toESM(require("@iarna/toml"));
|
|
3494
3690
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
3495
3691
|
var import_gray_matter = __toESM(require("gray-matter"));
|
|
3496
|
-
var
|
|
3692
|
+
var import_schema_tools4 = require("@tinacms/schema-tools");
|
|
3497
3693
|
var import_micromatch = __toESM(require("micromatch"));
|
|
3498
3694
|
var import_path = __toESM(require("path"));
|
|
3499
3695
|
|
|
@@ -3706,7 +3902,7 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
|
3706
3902
|
const filesSeen = /* @__PURE__ */ new Map();
|
|
3707
3903
|
const duplicateFiles = /* @__PURE__ */ new Set();
|
|
3708
3904
|
await sequential(tinaSchema.getCollections(), async (collection) => {
|
|
3709
|
-
const normalPath = (0,
|
|
3905
|
+
const normalPath = (0, import_schema_tools4.normalizePath)(collection.path);
|
|
3710
3906
|
const format = collection.format || "md";
|
|
3711
3907
|
const documentPaths = await bridge.glob(normalPath, format);
|
|
3712
3908
|
const matches = tinaSchema.getMatches({ collection });
|
|
@@ -3818,7 +4014,7 @@ var getTemplateForFile = (templateInfo, data) => {
|
|
|
3818
4014
|
throw new Error(`Unable to determine template`);
|
|
3819
4015
|
};
|
|
3820
4016
|
var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo) => {
|
|
3821
|
-
const dataString = await bridge.get((0,
|
|
4017
|
+
const dataString = await bridge.get((0, import_schema_tools4.normalizePath)(filepath));
|
|
3822
4018
|
const data = parseFile(
|
|
3823
4019
|
dataString,
|
|
3824
4020
|
import_path.default.extname(filepath),
|
|
@@ -4297,7 +4493,7 @@ var FolderTreeBuilder = class {
|
|
|
4297
4493
|
return this._tree;
|
|
4298
4494
|
}
|
|
4299
4495
|
update(documentPath, collectionPath) {
|
|
4300
|
-
let folderPath = import_path2.default.dirname((0,
|
|
4496
|
+
let folderPath = import_path2.default.dirname((0, import_schema_tools4.normalizePath)(documentPath));
|
|
4301
4497
|
if (folderPath === ".") {
|
|
4302
4498
|
folderPath = "";
|
|
4303
4499
|
}
|
|
@@ -4310,7 +4506,7 @@ var FolderTreeBuilder = class {
|
|
|
4310
4506
|
if (!this._tree[current2]) {
|
|
4311
4507
|
this._tree[current2] = /* @__PURE__ */ new Set();
|
|
4312
4508
|
}
|
|
4313
|
-
this._tree[current2].add((0,
|
|
4509
|
+
this._tree[current2].add((0, import_schema_tools4.normalizePath)(import_path2.default.join(current2, part)));
|
|
4314
4510
|
parent.push(part);
|
|
4315
4511
|
});
|
|
4316
4512
|
const current = parent.join("/");
|
|
@@ -4349,6 +4545,7 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
|
|
|
4349
4545
|
result.push({
|
|
4350
4546
|
type: opType,
|
|
4351
4547
|
key: `${collection.path}/${subFolderKey}.${collection.format}`,
|
|
4548
|
+
// replace the root with the collection path
|
|
4352
4549
|
sublevel: indexSublevel,
|
|
4353
4550
|
value: {}
|
|
4354
4551
|
});
|
|
@@ -4464,6 +4661,7 @@ var resolveFieldData = async ({ namespace, ...field }, rawData, accumulator, tin
|
|
|
4464
4661
|
case "password":
|
|
4465
4662
|
accumulator[field.name] = {
|
|
4466
4663
|
value: void 0,
|
|
4664
|
+
// never resolve the password hash
|
|
4467
4665
|
passwordChangeRequired: (_a = value["passwordChangeRequired"]) != null ? _a : false
|
|
4468
4666
|
};
|
|
4469
4667
|
break;
|
|
@@ -4658,6 +4856,7 @@ var Resolver = class {
|
|
|
4658
4856
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
4659
4857
|
const extraFields = {};
|
|
4660
4858
|
return {
|
|
4859
|
+
// return the collection and hasDocuments to resolve documents at a lower level
|
|
4661
4860
|
documents: { collection, hasDocuments },
|
|
4662
4861
|
...collection,
|
|
4663
4862
|
...extraFields
|
|
@@ -4744,7 +4943,9 @@ var Resolver = class {
|
|
|
4744
4943
|
);
|
|
4745
4944
|
} else {
|
|
4746
4945
|
return this.buildFieldMutations(
|
|
4946
|
+
// @ts-ignore FIXME Argument of type 'string | object' is not assignable to parameter of type '{ [fieldName: string]: string | object | (string | object)[]; }'
|
|
4747
4947
|
fieldValue,
|
|
4948
|
+
//@ts-ignore
|
|
4748
4949
|
objectTemplate,
|
|
4749
4950
|
existingData
|
|
4750
4951
|
);
|
|
@@ -4756,6 +4957,7 @@ var Resolver = class {
|
|
|
4756
4957
|
fieldValue.map(async (item) => {
|
|
4757
4958
|
if (typeof item === "string") {
|
|
4758
4959
|
throw new Error(
|
|
4960
|
+
//@ts-ignore
|
|
4759
4961
|
`Expected object for template value for field ${field.name}`
|
|
4760
4962
|
);
|
|
4761
4963
|
}
|
|
@@ -4764,16 +4966,19 @@ var Resolver = class {
|
|
|
4764
4966
|
});
|
|
4765
4967
|
const [templateName] = Object.entries(item)[0];
|
|
4766
4968
|
const template = templates.find(
|
|
4969
|
+
//@ts-ignore
|
|
4767
4970
|
(template2) => template2.name === templateName
|
|
4768
4971
|
);
|
|
4769
4972
|
if (!template) {
|
|
4770
4973
|
throw new Error(`Expected to find template ${templateName}`);
|
|
4771
4974
|
}
|
|
4772
4975
|
return {
|
|
4976
|
+
// @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
|
|
4773
4977
|
...await this.buildFieldMutations(
|
|
4774
4978
|
item[template.name],
|
|
4775
4979
|
template
|
|
4776
4980
|
),
|
|
4981
|
+
//@ts-ignore
|
|
4777
4982
|
_template: template.name
|
|
4778
4983
|
};
|
|
4779
4984
|
})
|
|
@@ -4781,6 +4986,7 @@ var Resolver = class {
|
|
|
4781
4986
|
} else {
|
|
4782
4987
|
if (typeof fieldValue === "string") {
|
|
4783
4988
|
throw new Error(
|
|
4989
|
+
//@ts-ignore
|
|
4784
4990
|
`Expected object for template value for field ${field.name}`
|
|
4785
4991
|
);
|
|
4786
4992
|
}
|
|
@@ -4789,16 +4995,19 @@ var Resolver = class {
|
|
|
4789
4995
|
});
|
|
4790
4996
|
const [templateName] = Object.entries(fieldValue)[0];
|
|
4791
4997
|
const template = templates.find(
|
|
4998
|
+
//@ts-ignore
|
|
4792
4999
|
(template2) => template2.name === templateName
|
|
4793
5000
|
);
|
|
4794
5001
|
if (!template) {
|
|
4795
5002
|
throw new Error(`Expected to find template ${templateName}`);
|
|
4796
5003
|
}
|
|
4797
5004
|
return {
|
|
5005
|
+
// @ts-ignore FIXME Argument of type 'unknown' is not assignable to parameter of type '{ [fieldName: string]: string | { [key: string]: unknown; } | (string | { [key: string]: unknown; })[]; }'
|
|
4798
5006
|
...await this.buildFieldMutations(
|
|
4799
5007
|
fieldValue[template.name],
|
|
4800
5008
|
template
|
|
4801
5009
|
),
|
|
5010
|
+
//@ts-ignore
|
|
4802
5011
|
_template: template.name
|
|
4803
5012
|
};
|
|
4804
5013
|
}
|
|
@@ -4838,6 +5047,7 @@ var Resolver = class {
|
|
|
4838
5047
|
return this.getDocument(realPath);
|
|
4839
5048
|
}
|
|
4840
5049
|
const params = await this.buildObjectMutations(
|
|
5050
|
+
// @ts-ignore
|
|
4841
5051
|
args.params[collection.name],
|
|
4842
5052
|
collection
|
|
4843
5053
|
);
|
|
@@ -4883,6 +5093,7 @@ var Resolver = class {
|
|
|
4883
5093
|
const values = {
|
|
4884
5094
|
...oldDoc,
|
|
4885
5095
|
...await this.buildFieldMutations(
|
|
5096
|
+
// @ts-ignore FIXME: failing on unknown, which we don't need to know because it's recursive
|
|
4886
5097
|
templateParams,
|
|
4887
5098
|
template,
|
|
4888
5099
|
doc == null ? void 0 : doc._rawData
|
|
@@ -4896,6 +5107,7 @@ var Resolver = class {
|
|
|
4896
5107
|
return this.getDocument(realPath);
|
|
4897
5108
|
}
|
|
4898
5109
|
const params = await this.buildObjectMutations(
|
|
5110
|
+
//@ts-ignore
|
|
4899
5111
|
isCollectionSpecific ? args.params : args.params[collection.name],
|
|
4900
5112
|
collection,
|
|
4901
5113
|
doc == null ? void 0 : doc._rawData
|
|
@@ -4903,6 +5115,10 @@ var Resolver = class {
|
|
|
4903
5115
|
await this.database.put(realPath, { ...oldDoc, ...params }, collection.name);
|
|
4904
5116
|
return this.getDocument(realPath);
|
|
4905
5117
|
};
|
|
5118
|
+
/**
|
|
5119
|
+
* Returns top-level fields which are not defined in the collection, so their
|
|
5120
|
+
* values are not eliminated from Tina when new values are saved
|
|
5121
|
+
*/
|
|
4906
5122
|
this.resolveLegacyValues = (oldDoc, collection) => {
|
|
4907
5123
|
const legacyValues = {};
|
|
4908
5124
|
Object.entries(oldDoc).forEach(([key, value]) => {
|
|
@@ -5109,6 +5325,7 @@ var Resolver = class {
|
|
|
5109
5325
|
},
|
|
5110
5326
|
collection: referencedCollection,
|
|
5111
5327
|
hydrator: (path7) => path7
|
|
5328
|
+
// just return the path
|
|
5112
5329
|
}
|
|
5113
5330
|
);
|
|
5114
5331
|
const { edges } = resolvedCollectionConnection;
|
|
@@ -5176,6 +5393,12 @@ var Resolver = class {
|
|
|
5176
5393
|
}
|
|
5177
5394
|
};
|
|
5178
5395
|
};
|
|
5396
|
+
/**
|
|
5397
|
+
* Checks if a document has references to it
|
|
5398
|
+
* @param id The id of the document to check for references
|
|
5399
|
+
* @param c The collection to check for references
|
|
5400
|
+
* @returns true if the document has references, false otherwise
|
|
5401
|
+
*/
|
|
5179
5402
|
this.hasReferences = async (id, c) => {
|
|
5180
5403
|
let count = 0;
|
|
5181
5404
|
const deepRefs = this.tinaSchema.findReferences(c.name);
|
|
@@ -5210,6 +5433,12 @@ var Resolver = class {
|
|
|
5210
5433
|
}
|
|
5211
5434
|
return false;
|
|
5212
5435
|
};
|
|
5436
|
+
/**
|
|
5437
|
+
* Finds references to a document
|
|
5438
|
+
* @param id the id of the document to find references to
|
|
5439
|
+
* @param c the collection to find references in
|
|
5440
|
+
* @returns references to the document in the form of a map of collection names to a list of fields that reference the document
|
|
5441
|
+
*/
|
|
5213
5442
|
this.findReferences = async (id, c) => {
|
|
5214
5443
|
const references = {};
|
|
5215
5444
|
const deepRefs = this.tinaSchema.findReferences(c.name);
|
|
@@ -5337,6 +5566,27 @@ var Resolver = class {
|
|
|
5337
5566
|
}
|
|
5338
5567
|
return accum;
|
|
5339
5568
|
};
|
|
5569
|
+
/**
|
|
5570
|
+
* A mutation looks nearly identical between updateDocument:
|
|
5571
|
+
* ```graphql
|
|
5572
|
+
* updateDocument(collection: $collection,relativePath: $path, params: {
|
|
5573
|
+
* post: {
|
|
5574
|
+
* title: "Hello, World"
|
|
5575
|
+
* }
|
|
5576
|
+
* })`
|
|
5577
|
+
* ```
|
|
5578
|
+
* and `updatePostDocument`:
|
|
5579
|
+
* ```graphql
|
|
5580
|
+
* updatePostDocument(relativePath: $path, params: {
|
|
5581
|
+
* title: "Hello, World"
|
|
5582
|
+
* })
|
|
5583
|
+
* ```
|
|
5584
|
+
* The problem here is that we don't know whether the payload came from `updateDocument`
|
|
5585
|
+
* or `updatePostDocument` (we could, but for now it's easier not to pipe those details through),
|
|
5586
|
+
* But we do know that when given a `args.collection` value, we can assume that
|
|
5587
|
+
* this was a `updateDocument` request, and thus - should grab the data
|
|
5588
|
+
* from the corresponding field name in the key
|
|
5589
|
+
*/
|
|
5340
5590
|
this.buildParams = (args) => {
|
|
5341
5591
|
try {
|
|
5342
5592
|
assertShape(
|
|
@@ -5437,7 +5687,10 @@ var resolve = async ({
|
|
|
5437
5687
|
const graphQLSchema = (0, import_graphql5.buildASTSchema)(graphQLSchemaAst);
|
|
5438
5688
|
const tinaConfig = await database.getTinaSchema();
|
|
5439
5689
|
const tinaSchema = await createSchema({
|
|
5690
|
+
// TODO: please update all the types to import from @tinacms/schema-tools
|
|
5691
|
+
// @ts-ignore
|
|
5440
5692
|
schema: tinaConfig,
|
|
5693
|
+
// @ts-ignore
|
|
5441
5694
|
flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
|
|
5442
5695
|
});
|
|
5443
5696
|
const resolver = createResolver({
|
|
@@ -5454,8 +5707,7 @@ var resolve = async ({
|
|
|
5454
5707
|
database
|
|
5455
5708
|
},
|
|
5456
5709
|
typeResolver: async (source, _args, info) => {
|
|
5457
|
-
if (source.__typename)
|
|
5458
|
-
return source.__typename;
|
|
5710
|
+
if (source.__typename) return source.__typename;
|
|
5459
5711
|
const namedType = (0, import_graphql5.getNamedType)(info.returnType).toString();
|
|
5460
5712
|
const lookup = await database.getLookup(namedType);
|
|
5461
5713
|
if (lookup.resolveType === "unionData") {
|
|
@@ -5607,11 +5859,13 @@ var resolve = async ({
|
|
|
5607
5859
|
(0, import_lodash4.default)(
|
|
5608
5860
|
params,
|
|
5609
5861
|
userField.path.slice(1),
|
|
5862
|
+
// remove _rawData from users path
|
|
5610
5863
|
users.map((u) => {
|
|
5611
5864
|
if (user[idFieldName] === u[idFieldName]) {
|
|
5612
5865
|
return user;
|
|
5613
5866
|
}
|
|
5614
5867
|
return {
|
|
5868
|
+
// don't overwrite other users' passwords
|
|
5615
5869
|
...u,
|
|
5616
5870
|
[passwordFieldName]: {
|
|
5617
5871
|
...u[passwordFieldName],
|
|
@@ -5634,6 +5888,9 @@ var resolve = async ({
|
|
|
5634
5888
|
}
|
|
5635
5889
|
const isCreation = lookup[info.fieldName] === "create";
|
|
5636
5890
|
switch (lookup.resolveType) {
|
|
5891
|
+
/**
|
|
5892
|
+
* `node(id: $id)`
|
|
5893
|
+
*/
|
|
5637
5894
|
case "nodeDocument":
|
|
5638
5895
|
assertShape(
|
|
5639
5896
|
args,
|
|
@@ -5665,6 +5922,7 @@ var resolve = async ({
|
|
|
5665
5922
|
collection: args.collection,
|
|
5666
5923
|
isMutation,
|
|
5667
5924
|
isCreation,
|
|
5925
|
+
// Right now this is the only case for deletion
|
|
5668
5926
|
isDeletion: info.fieldName === "deleteDocument",
|
|
5669
5927
|
isFolderCreation: info.fieldName === "createFolder",
|
|
5670
5928
|
isUpdateName: Boolean((_a2 = args == null ? void 0 : args.params) == null ? void 0 : _a2.relativePath),
|
|
@@ -5674,6 +5932,9 @@ var resolve = async ({
|
|
|
5674
5932
|
return result;
|
|
5675
5933
|
}
|
|
5676
5934
|
return value;
|
|
5935
|
+
/**
|
|
5936
|
+
* eg `getMovieDocument.data.actors`
|
|
5937
|
+
*/
|
|
5677
5938
|
case "multiCollectionDocumentList":
|
|
5678
5939
|
if (Array.isArray(value)) {
|
|
5679
5940
|
return {
|
|
@@ -5685,7 +5946,15 @@ var resolve = async ({
|
|
|
5685
5946
|
}
|
|
5686
5947
|
if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
5687
5948
|
let filter = args.filter;
|
|
5688
|
-
if (
|
|
5949
|
+
if (
|
|
5950
|
+
// 1. Make sure that the filter exists
|
|
5951
|
+
typeof (args == null ? void 0 : args.filter) !== "undefined" && (args == null ? void 0 : args.filter) !== null && // 2. Make sure that the collection name exists
|
|
5952
|
+
// @ts-ignore
|
|
5953
|
+
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
|
|
5954
|
+
// @ts-ignore
|
|
5955
|
+
Object.keys(args.filter).includes((_c = value == null ? void 0 : value.collection) == null ? void 0 : _c.name) && // @ts-ignore
|
|
5956
|
+
typeof args.filter[(_d = value == null ? void 0 : value.collection) == null ? void 0 : _d.name] !== "undefined"
|
|
5957
|
+
) {
|
|
5689
5958
|
filter = args.filter[value.collection.name];
|
|
5690
5959
|
}
|
|
5691
5960
|
return resolver.resolveCollectionConnection({
|
|
@@ -5693,12 +5962,20 @@ var resolve = async ({
|
|
|
5693
5962
|
...args,
|
|
5694
5963
|
filter
|
|
5695
5964
|
},
|
|
5965
|
+
// @ts-ignore
|
|
5696
5966
|
collection: value.collection
|
|
5697
5967
|
});
|
|
5698
5968
|
}
|
|
5699
5969
|
throw new Error(
|
|
5700
5970
|
`Expected an array for result of ${info.fieldName} at ${info.path}`
|
|
5701
5971
|
);
|
|
5972
|
+
/**
|
|
5973
|
+
* Collections-specific getter
|
|
5974
|
+
* eg. `getPostDocument`/`createPostDocument`/`updatePostDocument`
|
|
5975
|
+
*
|
|
5976
|
+
* if coming from a query result
|
|
5977
|
+
* the field will be `node`
|
|
5978
|
+
*/
|
|
5702
5979
|
case "collectionDocument": {
|
|
5703
5980
|
if (value) {
|
|
5704
5981
|
return value;
|
|
@@ -5713,11 +5990,32 @@ var resolve = async ({
|
|
|
5713
5990
|
});
|
|
5714
5991
|
return result;
|
|
5715
5992
|
}
|
|
5993
|
+
/**
|
|
5994
|
+
* Collections-specific list getter
|
|
5995
|
+
* eg. `getPageList`
|
|
5996
|
+
*/
|
|
5716
5997
|
case "collectionDocumentList":
|
|
5717
5998
|
return resolver.resolveCollectionConnection({
|
|
5718
5999
|
args,
|
|
5719
6000
|
collection: tinaSchema.getCollection(lookup.collection)
|
|
5720
6001
|
});
|
|
6002
|
+
/**
|
|
6003
|
+
* A polymorphic data set, it can be from a document's data
|
|
6004
|
+
* of any nested object which can be one of many shapes
|
|
6005
|
+
*
|
|
6006
|
+
* ```graphql
|
|
6007
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
6008
|
+
* data {...} <- this part
|
|
6009
|
+
* }
|
|
6010
|
+
* ```
|
|
6011
|
+
* ```graphql
|
|
6012
|
+
* getBlockDocument(relativePath: $relativePath) {
|
|
6013
|
+
* data {
|
|
6014
|
+
* blocks {...} <- or this part
|
|
6015
|
+
* }
|
|
6016
|
+
* }
|
|
6017
|
+
* ```
|
|
6018
|
+
*/
|
|
5721
6019
|
case "unionData":
|
|
5722
6020
|
if (!value) {
|
|
5723
6021
|
if (args.relativePath) {
|
|
@@ -5782,8 +6080,7 @@ var TinaLevelClient = class extends import_many_level.ManyLevelGuest {
|
|
|
5782
6080
|
this.port = port || 9e3;
|
|
5783
6081
|
}
|
|
5784
6082
|
openConnection() {
|
|
5785
|
-
if (this._connected)
|
|
5786
|
-
return;
|
|
6083
|
+
if (this._connected) return;
|
|
5787
6084
|
const socket = (0, import_net.connect)(this.port);
|
|
5788
6085
|
(0, import_readable_stream.pipeline)(socket, this.createRpcStream(), socket, () => {
|
|
5789
6086
|
this._connected = false;
|
|
@@ -5903,7 +6200,7 @@ var Database = class {
|
|
|
5903
6200
|
const contentObject = await level.sublevel(
|
|
5904
6201
|
CONTENT_ROOT_PREFIX,
|
|
5905
6202
|
SUBLEVEL_OPTIONS
|
|
5906
|
-
).get((0,
|
|
6203
|
+
).get((0, import_schema_tools4.normalizePath)(filepath));
|
|
5907
6204
|
if (!contentObject) {
|
|
5908
6205
|
throw new NotFoundError(`Unable to find record ${filepath}`);
|
|
5909
6206
|
}
|
|
@@ -5928,7 +6225,7 @@ var Database = class {
|
|
|
5928
6225
|
);
|
|
5929
6226
|
const indexDefinitions = await this.getIndexDefinitions(this.contentLevel);
|
|
5930
6227
|
const collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
5931
|
-
const normalizedPath = (0,
|
|
6228
|
+
const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
|
|
5932
6229
|
if (!(collection == null ? void 0 : collection.isDetached)) {
|
|
5933
6230
|
if (this.bridge) {
|
|
5934
6231
|
await this.bridge.put(normalizedPath, stringifiedFile);
|
|
@@ -5964,6 +6261,7 @@ var Database = class {
|
|
|
5964
6261
|
"put",
|
|
5965
6262
|
level
|
|
5966
6263
|
),
|
|
6264
|
+
// folder indices
|
|
5967
6265
|
...makeIndexOpsForDocument(
|
|
5968
6266
|
normalizedPath,
|
|
5969
6267
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -5986,6 +6284,7 @@ var Database = class {
|
|
|
5986
6284
|
"del",
|
|
5987
6285
|
level
|
|
5988
6286
|
),
|
|
6287
|
+
// folder indices
|
|
5989
6288
|
...makeIndexOpsForDocument(
|
|
5990
6289
|
normalizedPath,
|
|
5991
6290
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -6025,7 +6324,7 @@ var Database = class {
|
|
|
6025
6324
|
);
|
|
6026
6325
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collectionName];
|
|
6027
6326
|
}
|
|
6028
|
-
const normalizedPath = (0,
|
|
6327
|
+
const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
|
|
6029
6328
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
6030
6329
|
const collection = await this.collectionForPath(filepath);
|
|
6031
6330
|
if (!collection) {
|
|
@@ -6080,6 +6379,7 @@ var Database = class {
|
|
|
6080
6379
|
"put",
|
|
6081
6380
|
level
|
|
6082
6381
|
),
|
|
6382
|
+
// folder indices
|
|
6083
6383
|
...makeIndexOpsForDocument(
|
|
6084
6384
|
normalizedPath,
|
|
6085
6385
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -6102,6 +6402,7 @@ var Database = class {
|
|
|
6102
6402
|
"del",
|
|
6103
6403
|
level
|
|
6104
6404
|
),
|
|
6405
|
+
// folder indices
|
|
6105
6406
|
...makeIndexOpsForDocument(
|
|
6106
6407
|
normalizedPath,
|
|
6107
6408
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -6179,6 +6480,7 @@ var Database = class {
|
|
|
6179
6480
|
aliasedData,
|
|
6180
6481
|
extension,
|
|
6181
6482
|
writeTemplateKey,
|
|
6483
|
+
//templateInfo.type === 'union',
|
|
6182
6484
|
{
|
|
6183
6485
|
frontmatterFormat: collection == null ? void 0 : collection.frontmatterFormat,
|
|
6184
6486
|
frontmatterDelimiters: collection == null ? void 0 : collection.frontmatterDelimiters
|
|
@@ -6196,7 +6498,7 @@ var Database = class {
|
|
|
6196
6498
|
};
|
|
6197
6499
|
this.getLookup = async (returnType) => {
|
|
6198
6500
|
await this.initLevel();
|
|
6199
|
-
const lookupPath = (0,
|
|
6501
|
+
const lookupPath = (0, import_schema_tools4.normalizePath)(
|
|
6200
6502
|
import_node_path.default.join(this.getGeneratedFolder(), `_lookup.json`)
|
|
6201
6503
|
);
|
|
6202
6504
|
if (!this._lookup) {
|
|
@@ -6209,7 +6511,7 @@ var Database = class {
|
|
|
6209
6511
|
};
|
|
6210
6512
|
this.getGraphQLSchema = async () => {
|
|
6211
6513
|
await this.initLevel();
|
|
6212
|
-
const graphqlPath = (0,
|
|
6514
|
+
const graphqlPath = (0, import_schema_tools4.normalizePath)(
|
|
6213
6515
|
import_node_path.default.join(this.getGeneratedFolder(), `_graphql.json`)
|
|
6214
6516
|
);
|
|
6215
6517
|
return await this.contentLevel.sublevel(
|
|
@@ -6217,11 +6519,12 @@ var Database = class {
|
|
|
6217
6519
|
SUBLEVEL_OPTIONS
|
|
6218
6520
|
).get(graphqlPath);
|
|
6219
6521
|
};
|
|
6522
|
+
//TODO - is there a reason why the database fetches some config with "bridge.get", and some with "store.get"?
|
|
6220
6523
|
this.getGraphQLSchemaFromBridge = async () => {
|
|
6221
6524
|
if (!this.bridge) {
|
|
6222
6525
|
throw new Error(`No bridge configured`);
|
|
6223
6526
|
}
|
|
6224
|
-
const graphqlPath = (0,
|
|
6527
|
+
const graphqlPath = (0, import_schema_tools4.normalizePath)(
|
|
6225
6528
|
import_node_path.default.join(this.getGeneratedFolder(), `_graphql.json`)
|
|
6226
6529
|
);
|
|
6227
6530
|
const _graphql = await this.bridge.get(graphqlPath);
|
|
@@ -6229,7 +6532,7 @@ var Database = class {
|
|
|
6229
6532
|
};
|
|
6230
6533
|
this.getTinaSchema = async (level) => {
|
|
6231
6534
|
await this.initLevel();
|
|
6232
|
-
const schemaPath = (0,
|
|
6535
|
+
const schemaPath = (0, import_schema_tools4.normalizePath)(
|
|
6233
6536
|
import_node_path.default.join(this.getGeneratedFolder(), `_schema.json`)
|
|
6234
6537
|
);
|
|
6235
6538
|
return await (level || this.contentLevel).sublevel(
|
|
@@ -6245,7 +6548,7 @@ var Database = class {
|
|
|
6245
6548
|
const schema = existingSchema || await this.getTinaSchema(level || this.contentLevel);
|
|
6246
6549
|
if (!schema) {
|
|
6247
6550
|
throw new Error(
|
|
6248
|
-
`Unable to get schema from level db: ${(0,
|
|
6551
|
+
`Unable to get schema from level db: ${(0, import_schema_tools4.normalizePath)(
|
|
6249
6552
|
import_node_path.default.join(this.getGeneratedFolder(), `_schema.json`)
|
|
6250
6553
|
)}`
|
|
6251
6554
|
);
|
|
@@ -6263,6 +6566,7 @@ var Database = class {
|
|
|
6263
6566
|
for (const collection of collections) {
|
|
6264
6567
|
const indexDefinitions = {
|
|
6265
6568
|
[DEFAULT_COLLECTION_SORT_KEY]: { fields: [] }
|
|
6569
|
+
// provide a default sort key which is the file sort
|
|
6266
6570
|
};
|
|
6267
6571
|
if (collection.fields) {
|
|
6268
6572
|
for (const field of collection.fields) {
|
|
@@ -6461,7 +6765,7 @@ var Database = class {
|
|
|
6461
6765
|
try {
|
|
6462
6766
|
lookup = lookupFromLockFile || JSON.parse(
|
|
6463
6767
|
await this.bridge.get(
|
|
6464
|
-
(0,
|
|
6768
|
+
(0, import_schema_tools4.normalizePath)(
|
|
6465
6769
|
import_node_path.default.join(this.getGeneratedFolder(), "_lookup.json")
|
|
6466
6770
|
)
|
|
6467
6771
|
)
|
|
@@ -6486,15 +6790,15 @@ var Database = class {
|
|
|
6486
6790
|
}
|
|
6487
6791
|
const contentRootLevel = nextLevel.sublevel(CONTENT_ROOT_PREFIX, SUBLEVEL_OPTIONS);
|
|
6488
6792
|
await contentRootLevel.put(
|
|
6489
|
-
(0,
|
|
6793
|
+
(0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_graphql.json")),
|
|
6490
6794
|
graphQLSchema
|
|
6491
6795
|
);
|
|
6492
6796
|
await contentRootLevel.put(
|
|
6493
|
-
(0,
|
|
6797
|
+
(0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_schema.json")),
|
|
6494
6798
|
tinaSchema.schema
|
|
6495
6799
|
);
|
|
6496
6800
|
await contentRootLevel.put(
|
|
6497
|
-
(0,
|
|
6801
|
+
(0, import_schema_tools4.normalizePath)(import_node_path.default.join(this.getGeneratedFolder(), "_lookup.json")),
|
|
6498
6802
|
lookup
|
|
6499
6803
|
);
|
|
6500
6804
|
const result = await this._indexAllContent(
|
|
@@ -6587,12 +6891,12 @@ var Database = class {
|
|
|
6587
6891
|
if (collection == null ? void 0 : collection.isDetached) {
|
|
6588
6892
|
level = this.appLevel.sublevel(collection == null ? void 0 : collection.name, SUBLEVEL_OPTIONS);
|
|
6589
6893
|
}
|
|
6590
|
-
const
|
|
6894
|
+
const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
|
|
6591
6895
|
const rootSublevel = level.sublevel(
|
|
6592
6896
|
CONTENT_ROOT_PREFIX,
|
|
6593
6897
|
SUBLEVEL_OPTIONS
|
|
6594
6898
|
);
|
|
6595
|
-
const item = await rootSublevel.get(
|
|
6899
|
+
const item = await rootSublevel.get(normalizedPath);
|
|
6596
6900
|
if (item) {
|
|
6597
6901
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
6598
6902
|
const folderKey = folderTreeBuilder.update(
|
|
@@ -6601,15 +6905,16 @@ var Database = class {
|
|
|
6601
6905
|
);
|
|
6602
6906
|
await this.contentLevel.batch([
|
|
6603
6907
|
...makeIndexOpsForDocument(
|
|
6604
|
-
|
|
6908
|
+
normalizedPath,
|
|
6605
6909
|
collection.name,
|
|
6606
6910
|
collectionIndexDefinitions,
|
|
6607
6911
|
item,
|
|
6608
6912
|
"del",
|
|
6609
6913
|
level
|
|
6610
6914
|
),
|
|
6915
|
+
// folder indices
|
|
6611
6916
|
...makeIndexOpsForDocument(
|
|
6612
|
-
|
|
6917
|
+
normalizedPath,
|
|
6613
6918
|
`${collection.name}_${folderKey}`,
|
|
6614
6919
|
collectionIndexDefinitions,
|
|
6615
6920
|
item,
|
|
@@ -6618,17 +6923,17 @@ var Database = class {
|
|
|
6618
6923
|
),
|
|
6619
6924
|
{
|
|
6620
6925
|
type: "del",
|
|
6621
|
-
key:
|
|
6926
|
+
key: normalizedPath,
|
|
6622
6927
|
sublevel: rootSublevel
|
|
6623
6928
|
}
|
|
6624
6929
|
]);
|
|
6625
6930
|
}
|
|
6626
6931
|
if (!(collection == null ? void 0 : collection.isDetached)) {
|
|
6627
6932
|
if (this.bridge) {
|
|
6628
|
-
await this.bridge.delete(
|
|
6933
|
+
await this.bridge.delete(normalizedPath);
|
|
6629
6934
|
}
|
|
6630
6935
|
try {
|
|
6631
|
-
await this.onDelete(
|
|
6936
|
+
await this.onDelete(normalizedPath);
|
|
6632
6937
|
} catch (e) {
|
|
6633
6938
|
throw new import_graphql6.GraphQLError(
|
|
6634
6939
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
@@ -6762,6 +7067,9 @@ var Database = class {
|
|
|
6762
7067
|
info: templateInfo
|
|
6763
7068
|
};
|
|
6764
7069
|
}
|
|
7070
|
+
/**
|
|
7071
|
+
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
7072
|
+
*/
|
|
6765
7073
|
clearCache() {
|
|
6766
7074
|
this.tinaSchema = null;
|
|
6767
7075
|
this._lookup = null;
|
|
@@ -6843,7 +7151,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
6843
7151
|
if (passwordFields == null ? void 0 : passwordFields.length) {
|
|
6844
7152
|
await hashPasswordValues(aliasedData, passwordFields);
|
|
6845
7153
|
}
|
|
6846
|
-
const normalizedPath = (0,
|
|
7154
|
+
const normalizedPath = (0, import_schema_tools4.normalizePath)(filepath);
|
|
6847
7155
|
const folderKey = folderTreeBuilder.update(
|
|
6848
7156
|
normalizedPath,
|
|
6849
7157
|
collectionPath || ""
|
|
@@ -6858,6 +7166,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
6858
7166
|
"put",
|
|
6859
7167
|
level
|
|
6860
7168
|
),
|
|
7169
|
+
// folder indexes
|
|
6861
7170
|
...makeIndexOpsForDocument(
|
|
6862
7171
|
normalizedPath,
|
|
6863
7172
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -6923,7 +7232,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
|
|
|
6923
7232
|
);
|
|
6924
7233
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
6925
7234
|
await sequential(documentPaths, async (filepath) => {
|
|
6926
|
-
const itemKey = (0,
|
|
7235
|
+
const itemKey = (0, import_schema_tools4.normalizePath)(filepath);
|
|
6927
7236
|
const item = await rootLevel.get(itemKey);
|
|
6928
7237
|
if (item) {
|
|
6929
7238
|
const folderKey = folderTreeBuilder.update(
|
|
@@ -6943,6 +7252,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
|
|
|
6943
7252
|
"del",
|
|
6944
7253
|
database.contentLevel
|
|
6945
7254
|
),
|
|
7255
|
+
// folder indexes
|
|
6946
7256
|
...makeIndexOpsForDocument(
|
|
6947
7257
|
itemKey,
|
|
6948
7258
|
`${collection == null ? void 0 : collection.name}_${folderKey}`,
|
|
@@ -7009,14 +7319,14 @@ var getChangedFiles = async ({
|
|
|
7009
7319
|
const rootDir = await findGitRoot(dir);
|
|
7010
7320
|
let pathPrefix = "";
|
|
7011
7321
|
if (rootDir !== dir) {
|
|
7012
|
-
pathPrefix = (0,
|
|
7322
|
+
pathPrefix = (0, import_schema_tools4.normalizePath)(dir.substring(rootDir.length + 1));
|
|
7013
7323
|
}
|
|
7014
7324
|
await import_isomorphic_git.default.walk({
|
|
7015
7325
|
fs: fs4,
|
|
7016
7326
|
dir: rootDir,
|
|
7017
7327
|
trees: [import_isomorphic_git.default.TREE({ ref: from }), import_isomorphic_git.default.TREE({ ref: to })],
|
|
7018
7328
|
map: async function(filename, [A, B]) {
|
|
7019
|
-
const relativePath = (0,
|
|
7329
|
+
const relativePath = (0, import_schema_tools4.normalizePath)(filename).substring(pathPrefix.length);
|
|
7020
7330
|
let matches = false;
|
|
7021
7331
|
for (const [key, matcher] of Object.entries(pathFilter)) {
|
|
7022
7332
|
if (relativePath.startsWith(key)) {
|
|
@@ -7158,17 +7468,26 @@ var IsomorphicBridge = class {
|
|
|
7158
7468
|
getAuthor() {
|
|
7159
7469
|
return {
|
|
7160
7470
|
...this.author,
|
|
7161
|
-
timestamp: Math.round(new Date().getTime() / 1e3),
|
|
7471
|
+
timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
7162
7472
|
timezoneOffset: 0
|
|
7163
7473
|
};
|
|
7164
7474
|
}
|
|
7165
7475
|
getCommitter() {
|
|
7166
7476
|
return {
|
|
7167
7477
|
...this.committer,
|
|
7168
|
-
timestamp: Math.round(new Date().getTime() / 1e3),
|
|
7478
|
+
timestamp: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
7169
7479
|
timezoneOffset: 0
|
|
7170
7480
|
};
|
|
7171
7481
|
}
|
|
7482
|
+
/**
|
|
7483
|
+
* Recursively populate paths matching `pattern` for the given `entry`
|
|
7484
|
+
*
|
|
7485
|
+
* @param pattern - pattern to filter paths by
|
|
7486
|
+
* @param entry - TreeEntry to start building list from
|
|
7487
|
+
* @param path - base path
|
|
7488
|
+
* @param results
|
|
7489
|
+
* @private
|
|
7490
|
+
*/
|
|
7172
7491
|
async listEntries({
|
|
7173
7492
|
pattern,
|
|
7174
7493
|
entry,
|
|
@@ -7201,6 +7520,15 @@ var IsomorphicBridge = class {
|
|
|
7201
7520
|
});
|
|
7202
7521
|
}
|
|
7203
7522
|
}
|
|
7523
|
+
/**
|
|
7524
|
+
* For the specified path, returns an object with an array containing the parts of the path (pathParts)
|
|
7525
|
+
* and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
|
|
7526
|
+
* pathEntries are placeholders for non-existent entries.
|
|
7527
|
+
*
|
|
7528
|
+
* @param path - path being resolved
|
|
7529
|
+
* @param ref - ref to resolve path entries for
|
|
7530
|
+
* @private
|
|
7531
|
+
*/
|
|
7204
7532
|
async resolvePathEntries(path7, ref) {
|
|
7205
7533
|
let pathParts = path7.split("/");
|
|
7206
7534
|
const result = await import_isomorphic_git2.default.walk({
|
|
@@ -7231,6 +7559,17 @@ var IsomorphicBridge = class {
|
|
|
7231
7559
|
}
|
|
7232
7560
|
return { pathParts, pathEntries };
|
|
7233
7561
|
}
|
|
7562
|
+
/**
|
|
7563
|
+
* Updates tree entry and associated parent tree entries
|
|
7564
|
+
*
|
|
7565
|
+
* @param existingOid - the existing OID
|
|
7566
|
+
* @param updatedOid - the updated OID
|
|
7567
|
+
* @param path - the path of the entry being updated
|
|
7568
|
+
* @param type - the type of the entry being updated (blob or tree)
|
|
7569
|
+
* @param pathEntries - parent path entries
|
|
7570
|
+
* @param pathParts - parent path parts
|
|
7571
|
+
* @private
|
|
7572
|
+
*/
|
|
7234
7573
|
async updateTreeHierarchy(existingOid, updatedOid, path7, type, pathEntries, pathParts) {
|
|
7235
7574
|
const lastIdx = pathEntries.length - 1;
|
|
7236
7575
|
const parentEntry = pathEntries[lastIdx];
|
|
@@ -7286,6 +7625,13 @@ var IsomorphicBridge = class {
|
|
|
7286
7625
|
);
|
|
7287
7626
|
}
|
|
7288
7627
|
}
|
|
7628
|
+
/**
|
|
7629
|
+
* Creates a commit for the specified tree and updates the specified ref to point to the commit
|
|
7630
|
+
*
|
|
7631
|
+
* @param treeSha - sha of the new tree
|
|
7632
|
+
* @param ref - the ref that should be updated
|
|
7633
|
+
* @private
|
|
7634
|
+
*/
|
|
7289
7635
|
async commitTree(treeSha, ref) {
|
|
7290
7636
|
const commitSha = await import_isomorphic_git2.default.writeCommit({
|
|
7291
7637
|
...this.isomorphicConfig,
|
|
@@ -7298,6 +7644,7 @@ var IsomorphicBridge = class {
|
|
|
7298
7644
|
})
|
|
7299
7645
|
],
|
|
7300
7646
|
message: this.commitMessage,
|
|
7647
|
+
// TODO these should be configurable
|
|
7301
7648
|
author: this.getAuthor(),
|
|
7302
7649
|
committer: this.getCommitter()
|
|
7303
7650
|
}
|
|
@@ -7536,5 +7883,5 @@ var buildSchema = async (config, flags) => {
|
|
|
7536
7883
|
transformDocument,
|
|
7537
7884
|
transformDocumentIntoPayload
|
|
7538
7885
|
});
|
|
7539
|
-
//! Replaces _.flattenDeep()
|
|
7540
7886
|
//! Replaces _.get()
|
|
7887
|
+
//! Replaces _.flattenDeep()
|