@tinacms/graphql 0.59.6 → 0.59.7
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/CHANGELOG.md +7 -0
- package/dist/index.js +46 -27
- package/dist/resolver/index.d.ts +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -12370,7 +12370,7 @@ var validateField = async (field) => {
|
|
|
12370
12370
|
|
|
12371
12371
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12372
12372
|
var name = "@tinacms/graphql";
|
|
12373
|
-
var version = "0.59.
|
|
12373
|
+
var version = "0.59.7";
|
|
12374
12374
|
var main = "dist/index.js";
|
|
12375
12375
|
var typings = "dist/index.d.ts";
|
|
12376
12376
|
var files = [
|
|
@@ -21995,7 +21995,7 @@ var stringify = (node, field) => {
|
|
|
21995
21995
|
spread: false,
|
|
21996
21996
|
check: null,
|
|
21997
21997
|
children: [
|
|
21998
|
-
|
|
21998
|
+
...stringifyChildren([p], field),
|
|
21999
21999
|
...stringifyChildren(extraChildren, field)
|
|
22000
22000
|
]
|
|
22001
22001
|
};
|
|
@@ -22019,12 +22019,13 @@ var stringify = (node, field) => {
|
|
|
22019
22019
|
return {
|
|
22020
22020
|
type: "link",
|
|
22021
22021
|
url: node.url,
|
|
22022
|
-
|
|
22022
|
+
title: node.title,
|
|
22023
|
+
children: stringifyChildren(node.children, field)
|
|
22023
22024
|
};
|
|
22024
22025
|
case plateElements.ELEMENT_BLOCKQUOTE:
|
|
22025
22026
|
return {
|
|
22026
22027
|
type: "blockquote",
|
|
22027
|
-
children: node.children
|
|
22028
|
+
children: stringifyChildren(node.children, field)
|
|
22028
22029
|
};
|
|
22029
22030
|
case "mdxJsxTextElement":
|
|
22030
22031
|
case "mdxJsxFlowElement":
|
|
@@ -22189,12 +22190,7 @@ var stringify = (node, field) => {
|
|
|
22189
22190
|
}
|
|
22190
22191
|
break;
|
|
22191
22192
|
case "rich-text":
|
|
22192
|
-
const tree = value.children
|
|
22193
|
-
if (item.type === "text" && !item.text) {
|
|
22194
|
-
return false;
|
|
22195
|
-
}
|
|
22196
|
-
return true;
|
|
22197
|
-
});
|
|
22193
|
+
const tree = stringifyChildren(value.children, field2);
|
|
22198
22194
|
if (field2.name === "children") {
|
|
22199
22195
|
children2 = tree;
|
|
22200
22196
|
} else {
|
|
@@ -22269,10 +22265,13 @@ var createResolver2 = (args) => {
|
|
|
22269
22265
|
var Resolver = class {
|
|
22270
22266
|
constructor(init) {
|
|
22271
22267
|
this.init = init;
|
|
22272
|
-
this.resolveCollection = async (collectionName) => {
|
|
22268
|
+
this.resolveCollection = async (collectionName, hasDocuments) => {
|
|
22273
22269
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22274
22270
|
const extraFields = {};
|
|
22275
|
-
|
|
22271
|
+
let documents = {};
|
|
22272
|
+
if (hasDocuments) {
|
|
22273
|
+
documents = await this.getDocumentsForCollection(collectionName);
|
|
22274
|
+
}
|
|
22276
22275
|
return __spreadValues(__spreadValues({
|
|
22277
22276
|
documents
|
|
22278
22277
|
}, collection), extraFields);
|
|
@@ -22948,11 +22947,21 @@ var resolve = async ({
|
|
|
22948
22947
|
return value;
|
|
22949
22948
|
}
|
|
22950
22949
|
if (info.fieldName === "getCollections") {
|
|
22950
|
+
const getCollectionNode2 = info.fieldNodes.find((x) => x.name.value === "getCollections");
|
|
22951
|
+
const hasDocuments2 = getCollectionNode2.selectionSet.selections.find((x) => {
|
|
22952
|
+
var _a;
|
|
22953
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22954
|
+
});
|
|
22951
22955
|
return tinaSchema.getCollections().map((collection) => {
|
|
22952
|
-
return resolver2.resolveCollection(collection.name);
|
|
22956
|
+
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
22953
22957
|
});
|
|
22954
22958
|
}
|
|
22955
|
-
|
|
22959
|
+
const getCollectionNode = info.fieldNodes.find((x) => x.name.value === "getCollection");
|
|
22960
|
+
const hasDocuments = getCollectionNode.selectionSet.selections.find((x) => {
|
|
22961
|
+
var _a;
|
|
22962
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22963
|
+
});
|
|
22964
|
+
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
22956
22965
|
}
|
|
22957
22966
|
if (info.fieldName === "getDocumentFields") {
|
|
22958
22967
|
return resolver2.getDocumentFields();
|
|
@@ -23583,21 +23592,31 @@ var indexDocument = async ({
|
|
|
23583
23592
|
data,
|
|
23584
23593
|
database
|
|
23585
23594
|
}) => {
|
|
23595
|
+
var _a;
|
|
23586
23596
|
const schema = await database.getSchema();
|
|
23587
23597
|
const collection = await schema.getCollectionByFullPath(filepath);
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
}
|
|
23596
|
-
|
|
23597
|
-
const
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23598
|
+
let existingData;
|
|
23599
|
+
try {
|
|
23600
|
+
existingData = await database.get(filepath);
|
|
23601
|
+
} catch (err) {
|
|
23602
|
+
if (((_a = err.extensions) == null ? void 0 : _a["status"]) !== 404) {
|
|
23603
|
+
throw err;
|
|
23604
|
+
}
|
|
23605
|
+
}
|
|
23606
|
+
if (existingData) {
|
|
23607
|
+
const attributesToFilterOut = await _indexCollectable({
|
|
23608
|
+
record: filepath,
|
|
23609
|
+
value: existingData,
|
|
23610
|
+
field: collection,
|
|
23611
|
+
prefix: collection.name,
|
|
23612
|
+
database
|
|
23613
|
+
});
|
|
23614
|
+
await sequential(attributesToFilterOut, async (attribute) => {
|
|
23615
|
+
const records = await database.store.get(attribute) || [];
|
|
23616
|
+
await database.store.put(attribute, records.filter((item) => item !== filepath));
|
|
23617
|
+
return true;
|
|
23618
|
+
});
|
|
23619
|
+
}
|
|
23601
23620
|
const attributes = await _indexCollectable({
|
|
23602
23621
|
record: filepath,
|
|
23603
23622
|
field: collection,
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class Resolver {
|
|
|
27
27
|
database: Database;
|
|
28
28
|
tinaSchema: TinaSchema;
|
|
29
29
|
constructor(init: ResolverConfig);
|
|
30
|
-
resolveCollection: (collectionName: string) => Promise<{
|
|
30
|
+
resolveCollection: (collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
31
31
|
fields: string | import("../types").TinaFieldInner<true>[];
|
|
32
32
|
templates?: undefined;
|
|
33
33
|
references?: import("../types").ReferenceTypeWithNamespace[];
|
|
@@ -37,7 +37,7 @@ export declare class Resolver {
|
|
|
37
37
|
path: string;
|
|
38
38
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
39
39
|
match?: string;
|
|
40
|
-
documents:
|
|
40
|
+
documents: {};
|
|
41
41
|
} | {
|
|
42
42
|
templates: (string | {
|
|
43
43
|
label: string;
|
|
@@ -54,7 +54,7 @@ export declare class Resolver {
|
|
|
54
54
|
path: string;
|
|
55
55
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
56
56
|
match?: string;
|
|
57
|
-
documents:
|
|
57
|
+
documents: {};
|
|
58
58
|
}>;
|
|
59
59
|
getDocument: (fullPath: unknown) => Promise<{
|
|
60
60
|
__typename: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@tinacms/datalayer": "0.0.2",
|
|
98
|
-
"@tinacms/scripts": "0.50.
|
|
98
|
+
"@tinacms/scripts": "0.50.6",
|
|
99
99
|
"@types/cors": "^2.8.7",
|
|
100
100
|
"@types/estree": "^0.0.50",
|
|
101
101
|
"@types/express": "^4.17.8",
|