@tinacms/graphql 0.0.0-20225819424 → 0.0.0-20225820237
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 -12
- package/dist/database/index.d.ts +2 -4
- package/dist/index.js +96 -70
- package/dist/mdx/parse.d.ts +4 -4
- package/dist/mdx/stringify.d.ts +3 -3
- package/dist/resolver/index.d.ts +1 -0
- package/dist/resolver/media-utils.d.ts +29 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20225820237
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- @tinacms/schema-tools@0.0.0-20225819424
|
|
9
|
-
- @tinacms/datalayer@0.0.0-20225819424
|
|
7
|
+
- 24d6feda6: Handles Cloud URLs to Relative URLs when saving to document
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Introduces a pair of function (resolveMediaRelativeToCloud and resolveMediaCloudToRelative) that takes a URL and GraphQLConfig and returns a modified URL.
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- 57f09bdd7: Always use the query function when the dataLayer in enabled
|
|
11
|
+
These are used in conjuction with two pairs of functions:
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
13
|
+
buildFieldMutations and resolveFieldData
|
|
14
|
+
stringifyMDX and parseMDX
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
I also added tests to use those functions.
|
|
22
17
|
|
|
23
18
|
## 0.60.3
|
|
24
19
|
|
package/dist/database/index.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export declare class Database {
|
|
|
44
44
|
private tinaSchema;
|
|
45
45
|
private collectionIndexDefinitions;
|
|
46
46
|
private _lookup;
|
|
47
|
+
private _graphql;
|
|
48
|
+
private _tinaSchema;
|
|
47
49
|
constructor(config: CreateDatabase);
|
|
48
50
|
private collectionForPath;
|
|
49
51
|
private partitionPathsByCollection;
|
|
@@ -63,10 +65,6 @@ export declare class Database {
|
|
|
63
65
|
};
|
|
64
66
|
keepTemplateKey: boolean;
|
|
65
67
|
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
68
|
-
*/
|
|
69
|
-
clearCache(): void;
|
|
70
68
|
flush: (filepath: string) => Promise<string>;
|
|
71
69
|
getLookup: (returnType: string) => Promise<LookupMapType>;
|
|
72
70
|
getGraphQLSchema: () => Promise<DocumentNode>;
|
package/dist/index.js
CHANGED
|
@@ -12480,7 +12480,7 @@ var validateField = async (field) => {
|
|
|
12480
12480
|
|
|
12481
12481
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12482
12482
|
var name = "@tinacms/graphql";
|
|
12483
|
-
var version = "0.60.
|
|
12483
|
+
var version = "0.60.3";
|
|
12484
12484
|
var main = "dist/index.js";
|
|
12485
12485
|
var typings = "dist/index.d.ts";
|
|
12486
12486
|
var files = [
|
|
@@ -20222,11 +20222,42 @@ var visit = function(tree, test, visitor, reverse) {
|
|
|
20222
20222
|
|
|
20223
20223
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20224
20224
|
var import_lodash4 = __toModule(require("lodash"));
|
|
20225
|
-
|
|
20225
|
+
|
|
20226
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
|
|
20227
|
+
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }) => {
|
|
20228
|
+
if (config) {
|
|
20229
|
+
if (config.useRelativeMedia === true) {
|
|
20230
|
+
return value;
|
|
20231
|
+
} else {
|
|
20232
|
+
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
20233
|
+
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
20234
|
+
return value.replace(assetsURL, "");
|
|
20235
|
+
} else {
|
|
20236
|
+
return value;
|
|
20237
|
+
}
|
|
20238
|
+
}
|
|
20239
|
+
} else {
|
|
20240
|
+
return value;
|
|
20241
|
+
}
|
|
20242
|
+
};
|
|
20243
|
+
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }) => {
|
|
20244
|
+
if (config) {
|
|
20245
|
+
if (config.useRelativeMedia === true) {
|
|
20246
|
+
return value;
|
|
20247
|
+
} else {
|
|
20248
|
+
return `https://${config.assetsHost}/${config.clientId}${value}`;
|
|
20249
|
+
}
|
|
20250
|
+
} else {
|
|
20251
|
+
return value;
|
|
20252
|
+
}
|
|
20253
|
+
};
|
|
20254
|
+
|
|
20255
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20256
|
+
var parseMDX = (value, field, graphQLconfig) => {
|
|
20226
20257
|
const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
|
|
20227
|
-
return parseMDXInner(tree, field);
|
|
20258
|
+
return parseMDXInner(tree, field, graphQLconfig);
|
|
20228
20259
|
};
|
|
20229
|
-
var parseMDXInner = (tree, field) => {
|
|
20260
|
+
var parseMDXInner = (tree, field, graphQLconfig) => {
|
|
20230
20261
|
visit(tree, (node) => {
|
|
20231
20262
|
delete node.position;
|
|
20232
20263
|
});
|
|
@@ -20234,7 +20265,7 @@ var parseMDXInner = (tree, field) => {
|
|
|
20234
20265
|
var _a;
|
|
20235
20266
|
let props = {};
|
|
20236
20267
|
if (!node.name) {
|
|
20237
|
-
props = parseMDXInner({ type: "root", children: node.children }, field);
|
|
20268
|
+
props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig);
|
|
20238
20269
|
}
|
|
20239
20270
|
const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
|
|
20240
20271
|
const templateName = typeof template2 === "string" ? template2 : template2.name;
|
|
@@ -20265,7 +20296,7 @@ var parseMDXInner = (tree, field) => {
|
|
|
20265
20296
|
if (!field2) {
|
|
20266
20297
|
throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
|
|
20267
20298
|
}
|
|
20268
|
-
parseField(attribute, field2, props);
|
|
20299
|
+
parseField(attribute, field2, props, graphQLconfig);
|
|
20269
20300
|
}
|
|
20270
20301
|
} else {
|
|
20271
20302
|
console.log(`Not sure what this is, type: ${attribute.type}`);
|
|
@@ -20274,15 +20305,19 @@ var parseMDXInner = (tree, field) => {
|
|
|
20274
20305
|
delete node.attributes;
|
|
20275
20306
|
node.props = props;
|
|
20276
20307
|
});
|
|
20277
|
-
const slateTree = tree.children.map(remarkToSlate);
|
|
20308
|
+
const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig));
|
|
20278
20309
|
return { type: "root", children: slateTree };
|
|
20279
20310
|
};
|
|
20280
|
-
var parseField = (attribute, field, props) => {
|
|
20311
|
+
var parseField = (attribute, field, props, graphQLconfig) => {
|
|
20281
20312
|
var _a, _b;
|
|
20282
20313
|
switch (field.type) {
|
|
20283
20314
|
case "boolean":
|
|
20284
20315
|
case "datetime":
|
|
20316
|
+
props[field.name] = attribute.value;
|
|
20317
|
+
break;
|
|
20285
20318
|
case "image":
|
|
20319
|
+
props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig);
|
|
20320
|
+
break;
|
|
20286
20321
|
case "number":
|
|
20287
20322
|
case "string":
|
|
20288
20323
|
if (field.list) {
|
|
@@ -20344,7 +20379,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20344
20379
|
throw new Error(`Global fields not supported at this time`);
|
|
20345
20380
|
}
|
|
20346
20381
|
field.fields.forEach((field2) => {
|
|
20347
|
-
parseField(property, field2, objectProps);
|
|
20382
|
+
parseField(property, field2, objectProps, graphQLconfig);
|
|
20348
20383
|
});
|
|
20349
20384
|
}
|
|
20350
20385
|
});
|
|
@@ -20366,7 +20401,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20366
20401
|
throw new Error(`Global fields not supported at this time`);
|
|
20367
20402
|
}
|
|
20368
20403
|
field.fields.forEach((field2) => {
|
|
20369
|
-
parseField(property, field2, objectProps);
|
|
20404
|
+
parseField(property, field2, objectProps, graphQLconfig);
|
|
20370
20405
|
});
|
|
20371
20406
|
}
|
|
20372
20407
|
if (field.templates) {
|
|
@@ -20375,7 +20410,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20375
20410
|
throw new Error(`Global fields not supported at this time`);
|
|
20376
20411
|
}
|
|
20377
20412
|
fieldTemplate.fields.forEach((field2) => {
|
|
20378
|
-
parseField(property, field2, objectProps);
|
|
20413
|
+
parseField(property, field2, objectProps, graphQLconfig);
|
|
20379
20414
|
});
|
|
20380
20415
|
});
|
|
20381
20416
|
}
|
|
@@ -20398,13 +20433,13 @@ var parseField = (attribute, field, props) => {
|
|
|
20398
20433
|
if (attribute.value) {
|
|
20399
20434
|
if (field.name === "children") {
|
|
20400
20435
|
if (Array.isArray(attribute.value)) {
|
|
20401
|
-
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field);
|
|
20436
|
+
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig);
|
|
20402
20437
|
} else {
|
|
20403
20438
|
throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
|
|
20404
20439
|
}
|
|
20405
20440
|
} else {
|
|
20406
20441
|
try {
|
|
20407
|
-
const mdx2 = parseMDX(attribute.value.value, field);
|
|
20442
|
+
const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig);
|
|
20408
20443
|
props[field.name] = mdx2.children[0].props;
|
|
20409
20444
|
} catch (e) {
|
|
20410
20445
|
console.log(e);
|
|
@@ -20475,7 +20510,7 @@ var defaultNodeTypes = {
|
|
|
20475
20510
|
break: "break",
|
|
20476
20511
|
image: plateElements.ELEMENT_IMAGE
|
|
20477
20512
|
};
|
|
20478
|
-
function remarkToSlate(node) {
|
|
20513
|
+
function remarkToSlate(node, graphQLconfig) {
|
|
20479
20514
|
const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
|
|
20480
20515
|
heading: __spreadValues({}, defaultNodeTypes.heading)
|
|
20481
20516
|
});
|
|
@@ -20483,12 +20518,12 @@ function remarkToSlate(node) {
|
|
|
20483
20518
|
case "heading":
|
|
20484
20519
|
return {
|
|
20485
20520
|
type: types.heading[node.depth],
|
|
20486
|
-
children: node.children.map(remarkToSlate)
|
|
20521
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20487
20522
|
};
|
|
20488
20523
|
case "list":
|
|
20489
20524
|
return {
|
|
20490
20525
|
type: node.ordered ? types.ol_list : types.ul_list,
|
|
20491
|
-
children: node.children.map(remarkToSlate)
|
|
20526
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20492
20527
|
};
|
|
20493
20528
|
case "listItem":
|
|
20494
20529
|
const realChildren = [];
|
|
@@ -20496,12 +20531,12 @@ function remarkToSlate(node) {
|
|
|
20496
20531
|
if (child.type === "list") {
|
|
20497
20532
|
realChildren.push({
|
|
20498
20533
|
type: child.ordered ? types.ol_list : types.ul_list,
|
|
20499
|
-
children: child.children.map(remarkToSlate)
|
|
20534
|
+
children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20500
20535
|
});
|
|
20501
20536
|
} else {
|
|
20502
20537
|
realChildren.push({
|
|
20503
20538
|
type: plateElements.ELEMENT_LIC,
|
|
20504
|
-
children: child.children.map(remarkToSlate)
|
|
20539
|
+
children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20505
20540
|
});
|
|
20506
20541
|
}
|
|
20507
20542
|
});
|
|
@@ -20512,25 +20547,26 @@ function remarkToSlate(node) {
|
|
|
20512
20547
|
case "paragraph":
|
|
20513
20548
|
return {
|
|
20514
20549
|
type: types.paragraph,
|
|
20515
|
-
children: node.children.map(remarkToSlate)
|
|
20550
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20516
20551
|
};
|
|
20517
20552
|
case "link":
|
|
20518
20553
|
return {
|
|
20519
20554
|
type: types.link,
|
|
20520
20555
|
url: node.url,
|
|
20521
|
-
children: node.children.map(remarkToSlate)
|
|
20556
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20522
20557
|
};
|
|
20523
20558
|
case "image":
|
|
20559
|
+
const url = resolveMediaRelativeToCloud(node.url, graphQLconfig);
|
|
20524
20560
|
return {
|
|
20525
20561
|
type: types.image,
|
|
20526
|
-
url
|
|
20562
|
+
url,
|
|
20527
20563
|
alt: node.alt,
|
|
20528
20564
|
caption: node.title
|
|
20529
20565
|
};
|
|
20530
20566
|
case "blockquote":
|
|
20531
20567
|
return {
|
|
20532
20568
|
type: types.block_quote,
|
|
20533
|
-
children: node.children.map(remarkToSlate)
|
|
20569
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig))
|
|
20534
20570
|
};
|
|
20535
20571
|
case "code":
|
|
20536
20572
|
return {
|
|
@@ -21991,10 +22027,10 @@ var mdxToMarkdown = {
|
|
|
21991
22027
|
};
|
|
21992
22028
|
|
|
21993
22029
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
|
|
21994
|
-
var stringifyMDX = (value, field) => {
|
|
22030
|
+
var stringifyMDX = (value, field, graphQLconfig) => {
|
|
21995
22031
|
const slateTree = value.children;
|
|
21996
22032
|
try {
|
|
21997
|
-
const tree = stringifyChildren(slateTree, field);
|
|
22033
|
+
const tree = stringifyChildren(slateTree, field, graphQLconfig);
|
|
21998
22034
|
const out = toMarkdown({
|
|
21999
22035
|
type: "root",
|
|
22000
22036
|
children: tree
|
|
@@ -22012,13 +22048,13 @@ var allChildrenEmpty = (children) => {
|
|
|
22012
22048
|
}
|
|
22013
22049
|
return false;
|
|
22014
22050
|
};
|
|
22015
|
-
var stringifyChildren = (children, field) => {
|
|
22051
|
+
var stringifyChildren = (children, field, graphQLconfig) => {
|
|
22016
22052
|
if (!children) {
|
|
22017
22053
|
return [];
|
|
22018
22054
|
}
|
|
22019
|
-
return children.map((child) => stringify(child, field)).filter(Boolean);
|
|
22055
|
+
return children.map((child) => stringify(child, field, graphQLconfig)).filter(Boolean);
|
|
22020
22056
|
};
|
|
22021
|
-
var stringify = (node, field) => {
|
|
22057
|
+
var stringify = (node, field, graphQLconfig) => {
|
|
22022
22058
|
var _a;
|
|
22023
22059
|
if (!node.type) {
|
|
22024
22060
|
if (node == null ? void 0 : node.code) {
|
|
@@ -22044,40 +22080,40 @@ var stringify = (node, field) => {
|
|
|
22044
22080
|
return {
|
|
22045
22081
|
type: "heading",
|
|
22046
22082
|
depth: 1,
|
|
22047
|
-
children: stringifyChildren(node.children, field)
|
|
22083
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22048
22084
|
};
|
|
22049
22085
|
case plateElements.ELEMENT_H2:
|
|
22050
22086
|
return {
|
|
22051
22087
|
type: "heading",
|
|
22052
22088
|
depth: 2,
|
|
22053
|
-
children: stringifyChildren(node.children, field)
|
|
22089
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22054
22090
|
};
|
|
22055
22091
|
case plateElements.ELEMENT_H3:
|
|
22056
22092
|
return {
|
|
22057
22093
|
type: "heading",
|
|
22058
22094
|
depth: 3,
|
|
22059
|
-
children: stringifyChildren(node.children, field)
|
|
22095
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22060
22096
|
};
|
|
22061
22097
|
case plateElements.ELEMENT_H4:
|
|
22062
22098
|
return {
|
|
22063
22099
|
type: "heading",
|
|
22064
22100
|
depth: 4,
|
|
22065
|
-
children: stringifyChildren(node.children, field)
|
|
22101
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22066
22102
|
};
|
|
22067
22103
|
case plateElements.ELEMENT_H5:
|
|
22068
22104
|
return {
|
|
22069
22105
|
type: "heading",
|
|
22070
22106
|
depth: 5,
|
|
22071
|
-
children: stringifyChildren(node.children, field)
|
|
22107
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22072
22108
|
};
|
|
22073
22109
|
case plateElements.ELEMENT_H6:
|
|
22074
22110
|
return {
|
|
22075
22111
|
type: "heading",
|
|
22076
22112
|
depth: 6,
|
|
22077
|
-
children: stringifyChildren(node.children, field)
|
|
22113
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22078
22114
|
};
|
|
22079
22115
|
case plateElements.ELEMENT_PARAGRAPH:
|
|
22080
|
-
const children = stringifyChildren(node.children, field);
|
|
22116
|
+
const children = stringifyChildren(node.children, field, graphQLconfig);
|
|
22081
22117
|
if (allChildrenEmpty(children)) {
|
|
22082
22118
|
return false;
|
|
22083
22119
|
}
|
|
@@ -22097,7 +22133,7 @@ var stringify = (node, field) => {
|
|
|
22097
22133
|
ordered: false,
|
|
22098
22134
|
spread: false,
|
|
22099
22135
|
check: null,
|
|
22100
|
-
children: stringifyChildren(node.children, field)
|
|
22136
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22101
22137
|
};
|
|
22102
22138
|
case plateElements.ELEMENT_OL:
|
|
22103
22139
|
return {
|
|
@@ -22105,7 +22141,7 @@ var stringify = (node, field) => {
|
|
|
22105
22141
|
ordered: true,
|
|
22106
22142
|
spread: false,
|
|
22107
22143
|
check: null,
|
|
22108
|
-
children: stringifyChildren(node.children, field)
|
|
22144
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22109
22145
|
};
|
|
22110
22146
|
case plateElements.ELEMENT_LI:
|
|
22111
22147
|
const realChildren = [];
|
|
@@ -22128,21 +22164,22 @@ var stringify = (node, field) => {
|
|
|
22128
22164
|
spread: false,
|
|
22129
22165
|
check: null,
|
|
22130
22166
|
children: [
|
|
22131
|
-
...stringifyChildren([p], field),
|
|
22132
|
-
...stringifyChildren(extraChildren, field)
|
|
22167
|
+
...stringifyChildren([p], field, graphQLconfig),
|
|
22168
|
+
...stringifyChildren(extraChildren, field, graphQLconfig)
|
|
22133
22169
|
]
|
|
22134
22170
|
};
|
|
22135
22171
|
case plateElements.ELEMENT_LIC:
|
|
22136
22172
|
return {
|
|
22137
22173
|
type: "paragraph",
|
|
22138
|
-
children: stringifyChildren(node.children, field)
|
|
22174
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22139
22175
|
};
|
|
22140
22176
|
case plateElements.ELEMENT_IMAGE:
|
|
22177
|
+
const url = resolveMediaCloudToRelative(node.url, graphQLconfig);
|
|
22141
22178
|
return {
|
|
22142
22179
|
type: "image",
|
|
22143
22180
|
title: node.caption,
|
|
22144
22181
|
alt: node.alt,
|
|
22145
|
-
url
|
|
22182
|
+
url
|
|
22146
22183
|
};
|
|
22147
22184
|
case plateElements.ELEMENT_HR:
|
|
22148
22185
|
return {
|
|
@@ -22153,12 +22190,12 @@ var stringify = (node, field) => {
|
|
|
22153
22190
|
type: "link",
|
|
22154
22191
|
url: node.url,
|
|
22155
22192
|
title: node.title,
|
|
22156
|
-
children: stringifyChildren(node.children, field)
|
|
22193
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22157
22194
|
};
|
|
22158
22195
|
case plateElements.ELEMENT_BLOCKQUOTE:
|
|
22159
22196
|
return {
|
|
22160
22197
|
type: "blockquote",
|
|
22161
|
-
children: stringifyChildren(node.children, field)
|
|
22198
|
+
children: stringifyChildren(node.children, field, graphQLconfig)
|
|
22162
22199
|
};
|
|
22163
22200
|
case "mdxJsxTextElement":
|
|
22164
22201
|
case "mdxJsxFlowElement":
|
|
@@ -22323,7 +22360,7 @@ var stringify = (node, field) => {
|
|
|
22323
22360
|
}
|
|
22324
22361
|
break;
|
|
22325
22362
|
case "rich-text":
|
|
22326
|
-
const tree = stringifyChildren(value.children, field2);
|
|
22363
|
+
const tree = stringifyChildren(value.children, field2, graphQLconfig);
|
|
22327
22364
|
if (field2.name === "children") {
|
|
22328
22365
|
children2 = tree;
|
|
22329
22366
|
} else {
|
|
@@ -22751,6 +22788,10 @@ var Resolver = class {
|
|
|
22751
22788
|
})
|
|
22752
22789
|
};
|
|
22753
22790
|
};
|
|
22791
|
+
this.getDocumentsForCollection = async (collectionName) => {
|
|
22792
|
+
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22793
|
+
return this.database.store.glob(collection.path, this.getDocument);
|
|
22794
|
+
};
|
|
22754
22795
|
this.referenceResolver = async (filter, fieldDefinition) => {
|
|
22755
22796
|
const referencedCollection = this.tinaSchema.getCollection(fieldDefinition.collections[0]);
|
|
22756
22797
|
if (!referencedCollection) {
|
|
@@ -22775,11 +22816,9 @@ var Resolver = class {
|
|
|
22775
22816
|
collection,
|
|
22776
22817
|
hydrator
|
|
22777
22818
|
}) => {
|
|
22778
|
-
var _a, _b, _c, _d;
|
|
22779
22819
|
let edges;
|
|
22780
22820
|
let pageInfo;
|
|
22781
|
-
|
|
22782
|
-
if (useDataLayer) {
|
|
22821
|
+
if (args.filter || args.sort) {
|
|
22783
22822
|
let conditions;
|
|
22784
22823
|
if (args.filter) {
|
|
22785
22824
|
if (collection.fields) {
|
|
@@ -22844,15 +22883,16 @@ var Resolver = class {
|
|
|
22844
22883
|
case "string":
|
|
22845
22884
|
case "boolean":
|
|
22846
22885
|
case "number":
|
|
22847
|
-
case "image":
|
|
22848
22886
|
accum[fieldName] = fieldValue;
|
|
22849
22887
|
break;
|
|
22888
|
+
case "image":
|
|
22889
|
+
accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config);
|
|
22890
|
+
break;
|
|
22850
22891
|
case "object":
|
|
22851
22892
|
accum[fieldName] = this.buildObjectMutations(fieldValue, field);
|
|
22852
22893
|
break;
|
|
22853
22894
|
case "rich-text":
|
|
22854
|
-
field;
|
|
22855
|
-
accum[fieldName] = stringifyMDX(fieldValue, field);
|
|
22895
|
+
accum[fieldName] = stringifyMDX(fieldValue, field, this.config);
|
|
22856
22896
|
break;
|
|
22857
22897
|
case "reference":
|
|
22858
22898
|
accum[fieldName] = fieldValue;
|
|
@@ -22885,18 +22925,10 @@ var Resolver = class {
|
|
|
22885
22925
|
accumulator[field.name] = value;
|
|
22886
22926
|
break;
|
|
22887
22927
|
case "image":
|
|
22888
|
-
|
|
22889
|
-
if (this.config.useRelativeMedia === true) {
|
|
22890
|
-
accumulator[field.name] = value;
|
|
22891
|
-
} else {
|
|
22892
|
-
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22893
|
-
}
|
|
22894
|
-
} else {
|
|
22895
|
-
accumulator[field.name] = value;
|
|
22896
|
-
}
|
|
22928
|
+
accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config);
|
|
22897
22929
|
break;
|
|
22898
22930
|
case "rich-text":
|
|
22899
|
-
const tree = parseMDX(value, field);
|
|
22931
|
+
const tree = parseMDX(value, field, this.config);
|
|
22900
22932
|
accumulator[field.name] = tree;
|
|
22901
22933
|
break;
|
|
22902
22934
|
case "object":
|
|
@@ -23003,14 +23035,12 @@ var resolve = async ({
|
|
|
23003
23035
|
database,
|
|
23004
23036
|
silenceErrors
|
|
23005
23037
|
}) => {
|
|
23006
|
-
var _a;
|
|
23007
23038
|
try {
|
|
23008
23039
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
23009
23040
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
23010
23041
|
const tinaConfig = await database.getTinaSchema();
|
|
23011
23042
|
const tinaSchema = await createSchema({
|
|
23012
|
-
schema: tinaConfig
|
|
23013
|
-
flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
|
|
23043
|
+
schema: tinaConfig
|
|
23014
23044
|
});
|
|
23015
23045
|
const resolver2 = await createResolver2({ config, database, tinaSchema });
|
|
23016
23046
|
const res = await (0, import_graphql3.graphql)({
|
|
@@ -23044,8 +23074,8 @@ var resolve = async ({
|
|
|
23044
23074
|
if (info.fieldName === "collections") {
|
|
23045
23075
|
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
23046
23076
|
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23047
|
-
var
|
|
23048
|
-
return ((
|
|
23077
|
+
var _a;
|
|
23078
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
23049
23079
|
});
|
|
23050
23080
|
return tinaSchema.getCollections().map((collection) => {
|
|
23051
23081
|
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
@@ -23053,8 +23083,8 @@ var resolve = async ({
|
|
|
23053
23083
|
}
|
|
23054
23084
|
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
23055
23085
|
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23056
|
-
var
|
|
23057
|
-
return ((
|
|
23086
|
+
var _a;
|
|
23087
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
23058
23088
|
});
|
|
23059
23089
|
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
23060
23090
|
}
|
|
@@ -23628,10 +23658,6 @@ var Database = class {
|
|
|
23628
23658
|
}
|
|
23629
23659
|
return { pathsByCollection, nonCollectionPaths, collections };
|
|
23630
23660
|
}
|
|
23631
|
-
clearCache() {
|
|
23632
|
-
this.tinaSchema = null;
|
|
23633
|
-
this._lookup = null;
|
|
23634
|
-
}
|
|
23635
23661
|
async indexStatusCallbackWrapper(fn) {
|
|
23636
23662
|
await this.indexStatusCallback({ status: "inprogress" });
|
|
23637
23663
|
try {
|
package/dist/mdx/parse.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ limitations under the License.
|
|
|
16
16
|
|
|
17
17
|
*/
|
|
18
18
|
import type { Content } from 'mdast';
|
|
19
|
-
import type { RichTypeInner } from '../types';
|
|
20
|
-
export declare const parseMDX: (value: string, field: RichTypeInner) => {
|
|
19
|
+
import type { GraphQLConfig, RichTypeInner } from '../types';
|
|
20
|
+
export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconfig: GraphQLConfig) => {
|
|
21
21
|
type: string;
|
|
22
22
|
children: any;
|
|
23
23
|
};
|
|
@@ -70,7 +70,7 @@ export declare const parseMDX: (value: string, field: RichTypeInner) => {
|
|
|
70
70
|
* 2. We don't need to do any client-side parsing. Since TinaMarkdown and the slate editor work with the same
|
|
71
71
|
* format we can just allow Tina to do it's thing and update the form valuse with no additional work.
|
|
72
72
|
*/
|
|
73
|
-
export declare const parseMDXInner: (tree: any, field: RichTypeInner) => {
|
|
73
|
+
export declare const parseMDXInner: (tree: any, field: RichTypeInner, graphQLconfig: GraphQLConfig) => {
|
|
74
74
|
type: string;
|
|
75
75
|
children: any;
|
|
76
76
|
};
|
|
@@ -226,5 +226,5 @@ export declare const plateElements: {
|
|
|
226
226
|
MARK_UNDERLINE: string;
|
|
227
227
|
};
|
|
228
228
|
export declare const defaultNodeTypes: NodeTypes;
|
|
229
|
-
export default function remarkToSlate(node: MdxAstNode): any;
|
|
229
|
+
export default function remarkToSlate(node: MdxAstNode, graphQLconfig: GraphQLConfig): any;
|
|
230
230
|
export {};
|
package/dist/mdx/stringify.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
|
|
17
17
|
*/
|
|
18
|
-
import type { RichTypeInner } from '../types';
|
|
18
|
+
import type { GraphQLConfig, RichTypeInner } from '../types';
|
|
19
19
|
import { plateElements } from './parse';
|
|
20
20
|
import type { Content } from 'mdast';
|
|
21
|
-
export declare const stringifyMDX: (value: unknown, field: RichTypeInner) => string;
|
|
21
|
+
export declare const stringifyMDX: (value: unknown, field: RichTypeInner, graphQLconfig: GraphQLConfig) => string;
|
|
22
22
|
export declare const stringify: (node: {
|
|
23
23
|
type: typeof plateElements;
|
|
24
|
-
}, field: RichTypeInner) => Content;
|
|
24
|
+
}, field: RichTypeInner, graphQLconfig: GraphQLConfig) => Content;
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -203,6 +203,7 @@ export declare class Resolver {
|
|
|
203
203
|
};
|
|
204
204
|
}[];
|
|
205
205
|
}>;
|
|
206
|
+
getDocumentsForCollection: (collectionName: string) => Promise<string[]>;
|
|
206
207
|
private referenceResolver;
|
|
207
208
|
private resolveFilterConditions;
|
|
208
209
|
resolveCollectionConnection: ({ args, collection, hydrator, }: {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import { GraphQLConfig } from '../types';
|
|
14
|
+
/**
|
|
15
|
+
* Strips away the Tina Cloud Asset URL from an `image` value
|
|
16
|
+
*
|
|
17
|
+
* @param {string} value
|
|
18
|
+
* @param {GraphQLConfig} config
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveMediaCloudToRelative: (value: string, config?: GraphQLConfig) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Adds Tina Cloud Asset URL to an `image` value
|
|
24
|
+
*
|
|
25
|
+
* @param {string} value
|
|
26
|
+
* @param {GraphQLConfig} config
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
export declare const resolveMediaRelativeToCloud: (value: string, config?: GraphQLConfig) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20225820237",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
50
|
-
"@tinacms/datalayer": "0.
|
|
50
|
+
"@tinacms/datalayer": "0.1.1",
|
|
51
51
|
"body-parser": "^1.19.0",
|
|
52
52
|
"cors": "^2.8.5",
|
|
53
53
|
"dataloader": "^2.0.0",
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"directory": "packages/tina-graphql"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@tinacms/datalayer": "0.
|
|
101
|
-
"@tinacms/schema-tools": "0.0.
|
|
102
|
-
"@tinacms/scripts": "0.
|
|
100
|
+
"@tinacms/datalayer": "0.1.1",
|
|
101
|
+
"@tinacms/schema-tools": "0.0.4",
|
|
102
|
+
"@tinacms/scripts": "0.50.7",
|
|
103
103
|
"@types/cors": "^2.8.7",
|
|
104
104
|
"@types/estree": "^0.0.50",
|
|
105
105
|
"@types/express": "^4.17.8",
|