@tinacms/graphql 0.0.0-202251016285 → 0.0.0-202251020263
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 +4 -12
- package/dist/ast-builder/index.d.ts +1 -3
- package/dist/index.js +63 -293
- package/dist/mdx/parse.d.ts +4 -4
- package/dist/mdx/stringify.d.ts +3 -3
- package/package.json +3 -3
- package/dist/resolver/media-utils.d.ts +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-202251020263
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
Introduces a pair of functions (inside `media-utils.ts`) for handling URLs provided by TinaCloud (`resolveMediaCloudToRelative` and `resolveMediaRelativeToCloud`).
|
|
11
|
-
|
|
12
|
-
These are used in conjuction with two pairs of functions:
|
|
13
|
-
|
|
14
|
-
- When providing data to the preview: `resolveFieldData` and `parseMDX`
|
|
15
|
-
- When saving data to the document: `buildFieldMutations` and `stringifyMDX`
|
|
16
|
-
|
|
17
|
-
I also introduced tests around `media-utils.ts` (`media-utils.test.ts`).
|
|
7
|
+
- 7194aa3a0: Experimental isomorphic git bridge implementation
|
|
8
|
+
- Updated dependencies [7194aa3a0]
|
|
9
|
+
- @tinacms/datalayer@0.0.0-202251020263
|
|
18
10
|
|
|
19
11
|
## 0.60.5
|
|
20
12
|
|
|
@@ -126,11 +126,9 @@ export declare const astBuilder: {
|
|
|
126
126
|
queryName: string;
|
|
127
127
|
fragName: string;
|
|
128
128
|
}) => OperationDefinitionNode;
|
|
129
|
-
ListQueryOperationDefinition: ({ queryName, fragName,
|
|
129
|
+
ListQueryOperationDefinition: ({ queryName, fragName, }: {
|
|
130
130
|
queryName: string;
|
|
131
131
|
fragName: string;
|
|
132
|
-
filterType: string;
|
|
133
|
-
dataLayer: boolean;
|
|
134
132
|
}) => OperationDefinitionNode;
|
|
135
133
|
toGraphQLAst: (ast: {
|
|
136
134
|
globalTemplates: TypeDefinitionNode[];
|
package/dist/index.js
CHANGED
|
@@ -10954,208 +10954,8 @@ var astBuilder = {
|
|
|
10954
10954
|
},
|
|
10955
10955
|
ListQueryOperationDefinition: ({
|
|
10956
10956
|
queryName,
|
|
10957
|
-
fragName
|
|
10958
|
-
filterType,
|
|
10959
|
-
dataLayer
|
|
10957
|
+
fragName
|
|
10960
10958
|
}) => {
|
|
10961
|
-
const variableDefinitions = [
|
|
10962
|
-
{
|
|
10963
|
-
kind: "VariableDefinition",
|
|
10964
|
-
variable: {
|
|
10965
|
-
kind: "Variable",
|
|
10966
|
-
name: {
|
|
10967
|
-
kind: "Name",
|
|
10968
|
-
value: "before"
|
|
10969
|
-
}
|
|
10970
|
-
},
|
|
10971
|
-
type: {
|
|
10972
|
-
kind: "NamedType",
|
|
10973
|
-
name: {
|
|
10974
|
-
kind: "Name",
|
|
10975
|
-
value: "String"
|
|
10976
|
-
}
|
|
10977
|
-
},
|
|
10978
|
-
directives: []
|
|
10979
|
-
},
|
|
10980
|
-
{
|
|
10981
|
-
kind: "VariableDefinition",
|
|
10982
|
-
variable: {
|
|
10983
|
-
kind: "Variable",
|
|
10984
|
-
name: {
|
|
10985
|
-
kind: "Name",
|
|
10986
|
-
value: "after"
|
|
10987
|
-
}
|
|
10988
|
-
},
|
|
10989
|
-
type: {
|
|
10990
|
-
kind: "NamedType",
|
|
10991
|
-
name: {
|
|
10992
|
-
kind: "Name",
|
|
10993
|
-
value: "String"
|
|
10994
|
-
}
|
|
10995
|
-
},
|
|
10996
|
-
directives: []
|
|
10997
|
-
},
|
|
10998
|
-
{
|
|
10999
|
-
kind: "VariableDefinition",
|
|
11000
|
-
variable: {
|
|
11001
|
-
kind: "Variable",
|
|
11002
|
-
name: {
|
|
11003
|
-
kind: "Name",
|
|
11004
|
-
value: "first"
|
|
11005
|
-
}
|
|
11006
|
-
},
|
|
11007
|
-
type: {
|
|
11008
|
-
kind: "NamedType",
|
|
11009
|
-
name: {
|
|
11010
|
-
kind: "Name",
|
|
11011
|
-
value: "Float"
|
|
11012
|
-
}
|
|
11013
|
-
},
|
|
11014
|
-
directives: []
|
|
11015
|
-
},
|
|
11016
|
-
{
|
|
11017
|
-
kind: "VariableDefinition",
|
|
11018
|
-
variable: {
|
|
11019
|
-
kind: "Variable",
|
|
11020
|
-
name: {
|
|
11021
|
-
kind: "Name",
|
|
11022
|
-
value: "last"
|
|
11023
|
-
}
|
|
11024
|
-
},
|
|
11025
|
-
type: {
|
|
11026
|
-
kind: "NamedType",
|
|
11027
|
-
name: {
|
|
11028
|
-
kind: "Name",
|
|
11029
|
-
value: "Float"
|
|
11030
|
-
}
|
|
11031
|
-
},
|
|
11032
|
-
directives: []
|
|
11033
|
-
},
|
|
11034
|
-
{
|
|
11035
|
-
kind: "VariableDefinition",
|
|
11036
|
-
variable: {
|
|
11037
|
-
kind: "Variable",
|
|
11038
|
-
name: {
|
|
11039
|
-
kind: "Name",
|
|
11040
|
-
value: "sort"
|
|
11041
|
-
}
|
|
11042
|
-
},
|
|
11043
|
-
type: {
|
|
11044
|
-
kind: "NamedType",
|
|
11045
|
-
name: {
|
|
11046
|
-
kind: "Name",
|
|
11047
|
-
value: "String"
|
|
11048
|
-
}
|
|
11049
|
-
},
|
|
11050
|
-
directives: []
|
|
11051
|
-
}
|
|
11052
|
-
];
|
|
11053
|
-
const queryArguments = [
|
|
11054
|
-
{
|
|
11055
|
-
kind: "Argument",
|
|
11056
|
-
name: {
|
|
11057
|
-
kind: "Name",
|
|
11058
|
-
value: "before"
|
|
11059
|
-
},
|
|
11060
|
-
value: {
|
|
11061
|
-
kind: "Variable",
|
|
11062
|
-
name: {
|
|
11063
|
-
kind: "Name",
|
|
11064
|
-
value: "before"
|
|
11065
|
-
}
|
|
11066
|
-
}
|
|
11067
|
-
},
|
|
11068
|
-
{
|
|
11069
|
-
kind: "Argument",
|
|
11070
|
-
name: {
|
|
11071
|
-
kind: "Name",
|
|
11072
|
-
value: "after"
|
|
11073
|
-
},
|
|
11074
|
-
value: {
|
|
11075
|
-
kind: "Variable",
|
|
11076
|
-
name: {
|
|
11077
|
-
kind: "Name",
|
|
11078
|
-
value: "after"
|
|
11079
|
-
}
|
|
11080
|
-
}
|
|
11081
|
-
},
|
|
11082
|
-
{
|
|
11083
|
-
kind: "Argument",
|
|
11084
|
-
name: {
|
|
11085
|
-
kind: "Name",
|
|
11086
|
-
value: "first"
|
|
11087
|
-
},
|
|
11088
|
-
value: {
|
|
11089
|
-
kind: "Variable",
|
|
11090
|
-
name: {
|
|
11091
|
-
kind: "Name",
|
|
11092
|
-
value: "first"
|
|
11093
|
-
}
|
|
11094
|
-
}
|
|
11095
|
-
},
|
|
11096
|
-
{
|
|
11097
|
-
kind: "Argument",
|
|
11098
|
-
name: {
|
|
11099
|
-
kind: "Name",
|
|
11100
|
-
value: "last"
|
|
11101
|
-
},
|
|
11102
|
-
value: {
|
|
11103
|
-
kind: "Variable",
|
|
11104
|
-
name: {
|
|
11105
|
-
kind: "Name",
|
|
11106
|
-
value: "last"
|
|
11107
|
-
}
|
|
11108
|
-
}
|
|
11109
|
-
},
|
|
11110
|
-
{
|
|
11111
|
-
kind: "Argument",
|
|
11112
|
-
name: {
|
|
11113
|
-
kind: "Name",
|
|
11114
|
-
value: "sort"
|
|
11115
|
-
},
|
|
11116
|
-
value: {
|
|
11117
|
-
kind: "Variable",
|
|
11118
|
-
name: {
|
|
11119
|
-
kind: "Name",
|
|
11120
|
-
value: "sort"
|
|
11121
|
-
}
|
|
11122
|
-
}
|
|
11123
|
-
}
|
|
11124
|
-
];
|
|
11125
|
-
if (dataLayer) {
|
|
11126
|
-
queryArguments.push({
|
|
11127
|
-
kind: "Argument",
|
|
11128
|
-
name: {
|
|
11129
|
-
kind: "Name",
|
|
11130
|
-
value: "filter"
|
|
11131
|
-
},
|
|
11132
|
-
value: {
|
|
11133
|
-
kind: "Variable",
|
|
11134
|
-
name: {
|
|
11135
|
-
kind: "Name",
|
|
11136
|
-
value: "filter"
|
|
11137
|
-
}
|
|
11138
|
-
}
|
|
11139
|
-
});
|
|
11140
|
-
variableDefinitions.push({
|
|
11141
|
-
kind: "VariableDefinition",
|
|
11142
|
-
variable: {
|
|
11143
|
-
kind: "Variable",
|
|
11144
|
-
name: {
|
|
11145
|
-
kind: "Name",
|
|
11146
|
-
value: "filter"
|
|
11147
|
-
}
|
|
11148
|
-
},
|
|
11149
|
-
type: {
|
|
11150
|
-
kind: "NamedType",
|
|
11151
|
-
name: {
|
|
11152
|
-
kind: "Name",
|
|
11153
|
-
value: filterType
|
|
11154
|
-
}
|
|
11155
|
-
},
|
|
11156
|
-
directives: []
|
|
11157
|
-
});
|
|
11158
|
-
}
|
|
11159
10959
|
return {
|
|
11160
10960
|
kind: "OperationDefinition",
|
|
11161
10961
|
operation: "query",
|
|
@@ -11163,7 +10963,7 @@ var astBuilder = {
|
|
|
11163
10963
|
kind: "Name",
|
|
11164
10964
|
value: queryName
|
|
11165
10965
|
},
|
|
11166
|
-
variableDefinitions,
|
|
10966
|
+
variableDefinitions: [],
|
|
11167
10967
|
directives: [],
|
|
11168
10968
|
selectionSet: {
|
|
11169
10969
|
kind: "SelectionSet",
|
|
@@ -11174,7 +10974,7 @@ var astBuilder = {
|
|
|
11174
10974
|
kind: "Name",
|
|
11175
10975
|
value: queryName
|
|
11176
10976
|
},
|
|
11177
|
-
arguments:
|
|
10977
|
+
arguments: [],
|
|
11178
10978
|
directives: [],
|
|
11179
10979
|
selectionSet: {
|
|
11180
10980
|
kind: "SelectionSet",
|
|
@@ -13013,6 +12813,9 @@ var indexDB = async ({
|
|
|
13013
12813
|
if (flags.indexOf("experimentalData") === -1) {
|
|
13014
12814
|
flags.push("experimentalData");
|
|
13015
12815
|
}
|
|
12816
|
+
if (flags.indexOf("isomorphicGitBridge") === -1) {
|
|
12817
|
+
flags.push("isomorphicGitBridge");
|
|
12818
|
+
}
|
|
13016
12819
|
}
|
|
13017
12820
|
const tinaSchema = await createSchema({ schema: config, flags });
|
|
13018
12821
|
const builder = await createBuilder({
|
|
@@ -13050,17 +12853,13 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
|
|
|
13050
12853
|
const operationsDefinitions = [];
|
|
13051
12854
|
const collections = tinaSchema.getCollections();
|
|
13052
12855
|
await sequential(collections, async (collection) => {
|
|
13053
|
-
var _a, _b, _c;
|
|
13054
12856
|
const queryName = NAMER.queryName(collection.namespace);
|
|
13055
12857
|
const queryListName = NAMER.generateQueryListName(collection.namespace);
|
|
13056
|
-
const queryFilterTypeName = NAMER.dataFilterTypeName(collection.namespace);
|
|
13057
12858
|
const fragName = NAMER.fragmentName(collection.namespace);
|
|
13058
12859
|
operationsDefinitions.push(astBuilder.QueryOperationDefinition({ fragName, queryName }));
|
|
13059
12860
|
operationsDefinitions.push(astBuilder.ListQueryOperationDefinition({
|
|
13060
12861
|
fragName,
|
|
13061
|
-
queryName: queryListName
|
|
13062
|
-
filterType: queryFilterTypeName,
|
|
13063
|
-
dataLayer: Boolean((_c = (_b = (_a = tinaSchema.config) == null ? void 0 : _a.meta) == null ? void 0 : _b.flags) == null ? void 0 : _c.find((x) => x === "experimentalData"))
|
|
12862
|
+
queryName: queryListName
|
|
13064
12863
|
}));
|
|
13065
12864
|
});
|
|
13066
12865
|
const queryDoc = {
|
|
@@ -20426,42 +20225,11 @@ var visit = function(tree, test, visitor, reverse) {
|
|
|
20426
20225
|
|
|
20427
20226
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20428
20227
|
var import_lodash4 = __toModule(require("lodash"));
|
|
20429
|
-
|
|
20430
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
|
|
20431
|
-
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }) => {
|
|
20432
|
-
if (config && value) {
|
|
20433
|
-
if (config.useRelativeMedia === true) {
|
|
20434
|
-
return value;
|
|
20435
|
-
} else {
|
|
20436
|
-
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
20437
|
-
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
20438
|
-
return value.replace(assetsURL, "");
|
|
20439
|
-
} else {
|
|
20440
|
-
return value;
|
|
20441
|
-
}
|
|
20442
|
-
}
|
|
20443
|
-
} else {
|
|
20444
|
-
return value;
|
|
20445
|
-
}
|
|
20446
|
-
};
|
|
20447
|
-
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }) => {
|
|
20448
|
-
if (config && value) {
|
|
20449
|
-
if (config.useRelativeMedia === true) {
|
|
20450
|
-
return value;
|
|
20451
|
-
} else {
|
|
20452
|
-
return `https://${config.assetsHost}/${config.clientId}${value}`;
|
|
20453
|
-
}
|
|
20454
|
-
} else {
|
|
20455
|
-
return value;
|
|
20456
|
-
}
|
|
20457
|
-
};
|
|
20458
|
-
|
|
20459
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20460
|
-
var parseMDX = (value, field, graphQLconfig) => {
|
|
20228
|
+
var parseMDX = (value, field) => {
|
|
20461
20229
|
const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
|
|
20462
|
-
return parseMDXInner(tree, field
|
|
20230
|
+
return parseMDXInner(tree, field);
|
|
20463
20231
|
};
|
|
20464
|
-
var parseMDXInner = (tree, field
|
|
20232
|
+
var parseMDXInner = (tree, field) => {
|
|
20465
20233
|
visit(tree, (node) => {
|
|
20466
20234
|
delete node.position;
|
|
20467
20235
|
});
|
|
@@ -20469,7 +20237,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
|
|
|
20469
20237
|
var _a;
|
|
20470
20238
|
let props = {};
|
|
20471
20239
|
if (!node.name) {
|
|
20472
|
-
props = parseMDXInner({ type: "root", children: node.children }, field
|
|
20240
|
+
props = parseMDXInner({ type: "root", children: node.children }, field);
|
|
20473
20241
|
}
|
|
20474
20242
|
const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
|
|
20475
20243
|
const templateName = typeof template2 === "string" ? template2 : template2.name;
|
|
@@ -20500,7 +20268,7 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
|
|
|
20500
20268
|
if (!field2) {
|
|
20501
20269
|
throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
|
|
20502
20270
|
}
|
|
20503
|
-
parseField(attribute, field2, props
|
|
20271
|
+
parseField(attribute, field2, props);
|
|
20504
20272
|
}
|
|
20505
20273
|
} else {
|
|
20506
20274
|
console.log(`Not sure what this is, type: ${attribute.type}`);
|
|
@@ -20509,19 +20277,15 @@ var parseMDXInner = (tree, field, graphQLconfig) => {
|
|
|
20509
20277
|
delete node.attributes;
|
|
20510
20278
|
node.props = props;
|
|
20511
20279
|
});
|
|
20512
|
-
const slateTree = tree.children.map(
|
|
20280
|
+
const slateTree = tree.children.map(remarkToSlate);
|
|
20513
20281
|
return { type: "root", children: slateTree };
|
|
20514
20282
|
};
|
|
20515
|
-
var parseField = (attribute, field, props
|
|
20283
|
+
var parseField = (attribute, field, props) => {
|
|
20516
20284
|
var _a, _b;
|
|
20517
20285
|
switch (field.type) {
|
|
20518
20286
|
case "boolean":
|
|
20519
20287
|
case "datetime":
|
|
20520
|
-
props[field.name] = attribute.value;
|
|
20521
|
-
break;
|
|
20522
20288
|
case "image":
|
|
20523
|
-
props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig);
|
|
20524
|
-
break;
|
|
20525
20289
|
case "number":
|
|
20526
20290
|
case "string":
|
|
20527
20291
|
if (field.list) {
|
|
@@ -20583,7 +20347,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
|
|
|
20583
20347
|
throw new Error(`Global fields not supported at this time`);
|
|
20584
20348
|
}
|
|
20585
20349
|
field.fields.forEach((field2) => {
|
|
20586
|
-
parseField(property, field2, objectProps
|
|
20350
|
+
parseField(property, field2, objectProps);
|
|
20587
20351
|
});
|
|
20588
20352
|
}
|
|
20589
20353
|
});
|
|
@@ -20605,7 +20369,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
|
|
|
20605
20369
|
throw new Error(`Global fields not supported at this time`);
|
|
20606
20370
|
}
|
|
20607
20371
|
field.fields.forEach((field2) => {
|
|
20608
|
-
parseField(property, field2, objectProps
|
|
20372
|
+
parseField(property, field2, objectProps);
|
|
20609
20373
|
});
|
|
20610
20374
|
}
|
|
20611
20375
|
if (field.templates) {
|
|
@@ -20614,7 +20378,7 @@ var parseField = (attribute, field, props, graphQLconfig) => {
|
|
|
20614
20378
|
throw new Error(`Global fields not supported at this time`);
|
|
20615
20379
|
}
|
|
20616
20380
|
fieldTemplate.fields.forEach((field2) => {
|
|
20617
|
-
parseField(property, field2, objectProps
|
|
20381
|
+
parseField(property, field2, objectProps);
|
|
20618
20382
|
});
|
|
20619
20383
|
});
|
|
20620
20384
|
}
|
|
@@ -20637,13 +20401,13 @@ var parseField = (attribute, field, props, graphQLconfig) => {
|
|
|
20637
20401
|
if (attribute.value) {
|
|
20638
20402
|
if (field.name === "children") {
|
|
20639
20403
|
if (Array.isArray(attribute.value)) {
|
|
20640
|
-
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field
|
|
20404
|
+
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field);
|
|
20641
20405
|
} else {
|
|
20642
20406
|
throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
|
|
20643
20407
|
}
|
|
20644
20408
|
} else {
|
|
20645
20409
|
try {
|
|
20646
|
-
const mdx2 = parseMDX(attribute.value.value, field
|
|
20410
|
+
const mdx2 = parseMDX(attribute.value.value, field);
|
|
20647
20411
|
props[field.name] = mdx2.children[0].props;
|
|
20648
20412
|
} catch (e) {
|
|
20649
20413
|
console.log(e);
|
|
@@ -20714,7 +20478,7 @@ var defaultNodeTypes = {
|
|
|
20714
20478
|
break: "break",
|
|
20715
20479
|
image: plateElements.ELEMENT_IMAGE
|
|
20716
20480
|
};
|
|
20717
|
-
function remarkToSlate(node
|
|
20481
|
+
function remarkToSlate(node) {
|
|
20718
20482
|
const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
|
|
20719
20483
|
heading: __spreadValues({}, defaultNodeTypes.heading)
|
|
20720
20484
|
});
|
|
@@ -20722,12 +20486,12 @@ function remarkToSlate(node, graphQLconfig) {
|
|
|
20722
20486
|
case "heading":
|
|
20723
20487
|
return {
|
|
20724
20488
|
type: types.heading[node.depth],
|
|
20725
|
-
children: node.children.map(
|
|
20489
|
+
children: node.children.map(remarkToSlate)
|
|
20726
20490
|
};
|
|
20727
20491
|
case "list":
|
|
20728
20492
|
return {
|
|
20729
20493
|
type: node.ordered ? types.ol_list : types.ul_list,
|
|
20730
|
-
children: node.children.map(
|
|
20494
|
+
children: node.children.map(remarkToSlate)
|
|
20731
20495
|
};
|
|
20732
20496
|
case "listItem":
|
|
20733
20497
|
const realChildren = [];
|
|
@@ -20735,12 +20499,12 @@ function remarkToSlate(node, graphQLconfig) {
|
|
|
20735
20499
|
if (child.type === "list") {
|
|
20736
20500
|
realChildren.push({
|
|
20737
20501
|
type: child.ordered ? types.ol_list : types.ul_list,
|
|
20738
|
-
children: child.children.map(
|
|
20502
|
+
children: child.children.map(remarkToSlate)
|
|
20739
20503
|
});
|
|
20740
20504
|
} else {
|
|
20741
20505
|
realChildren.push({
|
|
20742
20506
|
type: plateElements.ELEMENT_LIC,
|
|
20743
|
-
children: child.children.map(
|
|
20507
|
+
children: child.children.map(remarkToSlate)
|
|
20744
20508
|
});
|
|
20745
20509
|
}
|
|
20746
20510
|
});
|
|
@@ -20751,26 +20515,25 @@ function remarkToSlate(node, graphQLconfig) {
|
|
|
20751
20515
|
case "paragraph":
|
|
20752
20516
|
return {
|
|
20753
20517
|
type: types.paragraph,
|
|
20754
|
-
children: node.children.map(
|
|
20518
|
+
children: node.children.map(remarkToSlate)
|
|
20755
20519
|
};
|
|
20756
20520
|
case "link":
|
|
20757
20521
|
return {
|
|
20758
20522
|
type: types.link,
|
|
20759
20523
|
url: node.url,
|
|
20760
|
-
children: node.children.map(
|
|
20524
|
+
children: node.children.map(remarkToSlate)
|
|
20761
20525
|
};
|
|
20762
20526
|
case "image":
|
|
20763
|
-
const url = resolveMediaRelativeToCloud(node.url, graphQLconfig);
|
|
20764
20527
|
return {
|
|
20765
20528
|
type: types.image,
|
|
20766
|
-
url,
|
|
20529
|
+
url: node.url,
|
|
20767
20530
|
alt: node.alt,
|
|
20768
20531
|
caption: node.title
|
|
20769
20532
|
};
|
|
20770
20533
|
case "blockquote":
|
|
20771
20534
|
return {
|
|
20772
20535
|
type: types.block_quote,
|
|
20773
|
-
children: node.children.map(
|
|
20536
|
+
children: node.children.map(remarkToSlate)
|
|
20774
20537
|
};
|
|
20775
20538
|
case "code":
|
|
20776
20539
|
return {
|
|
@@ -22231,10 +21994,10 @@ var mdxToMarkdown = {
|
|
|
22231
21994
|
};
|
|
22232
21995
|
|
|
22233
21996
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
|
|
22234
|
-
var stringifyMDX = (value, field
|
|
21997
|
+
var stringifyMDX = (value, field) => {
|
|
22235
21998
|
const slateTree = value.children;
|
|
22236
21999
|
try {
|
|
22237
|
-
const tree = stringifyChildren(slateTree, field
|
|
22000
|
+
const tree = stringifyChildren(slateTree, field);
|
|
22238
22001
|
const out = toMarkdown({
|
|
22239
22002
|
type: "root",
|
|
22240
22003
|
children: tree
|
|
@@ -22252,13 +22015,13 @@ var allChildrenEmpty = (children) => {
|
|
|
22252
22015
|
}
|
|
22253
22016
|
return false;
|
|
22254
22017
|
};
|
|
22255
|
-
var stringifyChildren = (children, field
|
|
22018
|
+
var stringifyChildren = (children, field) => {
|
|
22256
22019
|
if (!children) {
|
|
22257
22020
|
return [];
|
|
22258
22021
|
}
|
|
22259
|
-
return children.map((child) => stringify(child, field
|
|
22022
|
+
return children.map((child) => stringify(child, field)).filter(Boolean);
|
|
22260
22023
|
};
|
|
22261
|
-
var stringify = (node, field
|
|
22024
|
+
var stringify = (node, field) => {
|
|
22262
22025
|
var _a;
|
|
22263
22026
|
if (!node.type) {
|
|
22264
22027
|
if (node == null ? void 0 : node.code) {
|
|
@@ -22284,40 +22047,40 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22284
22047
|
return {
|
|
22285
22048
|
type: "heading",
|
|
22286
22049
|
depth: 1,
|
|
22287
|
-
children: stringifyChildren(node.children, field
|
|
22050
|
+
children: stringifyChildren(node.children, field)
|
|
22288
22051
|
};
|
|
22289
22052
|
case plateElements.ELEMENT_H2:
|
|
22290
22053
|
return {
|
|
22291
22054
|
type: "heading",
|
|
22292
22055
|
depth: 2,
|
|
22293
|
-
children: stringifyChildren(node.children, field
|
|
22056
|
+
children: stringifyChildren(node.children, field)
|
|
22294
22057
|
};
|
|
22295
22058
|
case plateElements.ELEMENT_H3:
|
|
22296
22059
|
return {
|
|
22297
22060
|
type: "heading",
|
|
22298
22061
|
depth: 3,
|
|
22299
|
-
children: stringifyChildren(node.children, field
|
|
22062
|
+
children: stringifyChildren(node.children, field)
|
|
22300
22063
|
};
|
|
22301
22064
|
case plateElements.ELEMENT_H4:
|
|
22302
22065
|
return {
|
|
22303
22066
|
type: "heading",
|
|
22304
22067
|
depth: 4,
|
|
22305
|
-
children: stringifyChildren(node.children, field
|
|
22068
|
+
children: stringifyChildren(node.children, field)
|
|
22306
22069
|
};
|
|
22307
22070
|
case plateElements.ELEMENT_H5:
|
|
22308
22071
|
return {
|
|
22309
22072
|
type: "heading",
|
|
22310
22073
|
depth: 5,
|
|
22311
|
-
children: stringifyChildren(node.children, field
|
|
22074
|
+
children: stringifyChildren(node.children, field)
|
|
22312
22075
|
};
|
|
22313
22076
|
case plateElements.ELEMENT_H6:
|
|
22314
22077
|
return {
|
|
22315
22078
|
type: "heading",
|
|
22316
22079
|
depth: 6,
|
|
22317
|
-
children: stringifyChildren(node.children, field
|
|
22080
|
+
children: stringifyChildren(node.children, field)
|
|
22318
22081
|
};
|
|
22319
22082
|
case plateElements.ELEMENT_PARAGRAPH:
|
|
22320
|
-
const children = stringifyChildren(node.children, field
|
|
22083
|
+
const children = stringifyChildren(node.children, field);
|
|
22321
22084
|
if (allChildrenEmpty(children)) {
|
|
22322
22085
|
return false;
|
|
22323
22086
|
}
|
|
@@ -22337,7 +22100,7 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22337
22100
|
ordered: false,
|
|
22338
22101
|
spread: false,
|
|
22339
22102
|
check: null,
|
|
22340
|
-
children: stringifyChildren(node.children, field
|
|
22103
|
+
children: stringifyChildren(node.children, field)
|
|
22341
22104
|
};
|
|
22342
22105
|
case plateElements.ELEMENT_OL:
|
|
22343
22106
|
return {
|
|
@@ -22345,7 +22108,7 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22345
22108
|
ordered: true,
|
|
22346
22109
|
spread: false,
|
|
22347
22110
|
check: null,
|
|
22348
|
-
children: stringifyChildren(node.children, field
|
|
22111
|
+
children: stringifyChildren(node.children, field)
|
|
22349
22112
|
};
|
|
22350
22113
|
case plateElements.ELEMENT_LI:
|
|
22351
22114
|
const realChildren = [];
|
|
@@ -22368,22 +22131,21 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22368
22131
|
spread: false,
|
|
22369
22132
|
check: null,
|
|
22370
22133
|
children: [
|
|
22371
|
-
...stringifyChildren([p], field
|
|
22372
|
-
...stringifyChildren(extraChildren, field
|
|
22134
|
+
...stringifyChildren([p], field),
|
|
22135
|
+
...stringifyChildren(extraChildren, field)
|
|
22373
22136
|
]
|
|
22374
22137
|
};
|
|
22375
22138
|
case plateElements.ELEMENT_LIC:
|
|
22376
22139
|
return {
|
|
22377
22140
|
type: "paragraph",
|
|
22378
|
-
children: stringifyChildren(node.children, field
|
|
22141
|
+
children: stringifyChildren(node.children, field)
|
|
22379
22142
|
};
|
|
22380
22143
|
case plateElements.ELEMENT_IMAGE:
|
|
22381
|
-
const url = resolveMediaCloudToRelative(node.url, graphQLconfig);
|
|
22382
22144
|
return {
|
|
22383
22145
|
type: "image",
|
|
22384
22146
|
title: node.caption,
|
|
22385
22147
|
alt: node.alt,
|
|
22386
|
-
url
|
|
22148
|
+
url: node.url
|
|
22387
22149
|
};
|
|
22388
22150
|
case plateElements.ELEMENT_HR:
|
|
22389
22151
|
return {
|
|
@@ -22394,12 +22156,12 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22394
22156
|
type: "link",
|
|
22395
22157
|
url: node.url,
|
|
22396
22158
|
title: node.title,
|
|
22397
|
-
children: stringifyChildren(node.children, field
|
|
22159
|
+
children: stringifyChildren(node.children, field)
|
|
22398
22160
|
};
|
|
22399
22161
|
case plateElements.ELEMENT_BLOCKQUOTE:
|
|
22400
22162
|
return {
|
|
22401
22163
|
type: "blockquote",
|
|
22402
|
-
children: stringifyChildren(node.children, field
|
|
22164
|
+
children: stringifyChildren(node.children, field)
|
|
22403
22165
|
};
|
|
22404
22166
|
case "mdxJsxTextElement":
|
|
22405
22167
|
case "mdxJsxFlowElement":
|
|
@@ -22564,7 +22326,7 @@ var stringify = (node, field, graphQLconfig) => {
|
|
|
22564
22326
|
}
|
|
22565
22327
|
break;
|
|
22566
22328
|
case "rich-text":
|
|
22567
|
-
const tree = stringifyChildren(value.children, field2
|
|
22329
|
+
const tree = stringifyChildren(value.children, field2);
|
|
22568
22330
|
if (field2.name === "children") {
|
|
22569
22331
|
children2 = tree;
|
|
22570
22332
|
} else {
|
|
@@ -23085,16 +22847,15 @@ var Resolver = class {
|
|
|
23085
22847
|
case "string":
|
|
23086
22848
|
case "boolean":
|
|
23087
22849
|
case "number":
|
|
23088
|
-
accum[fieldName] = fieldValue;
|
|
23089
|
-
break;
|
|
23090
22850
|
case "image":
|
|
23091
|
-
accum[fieldName] =
|
|
22851
|
+
accum[fieldName] = fieldValue;
|
|
23092
22852
|
break;
|
|
23093
22853
|
case "object":
|
|
23094
22854
|
accum[fieldName] = this.buildObjectMutations(fieldValue, field);
|
|
23095
22855
|
break;
|
|
23096
22856
|
case "rich-text":
|
|
23097
|
-
|
|
22857
|
+
field;
|
|
22858
|
+
accum[fieldName] = stringifyMDX(fieldValue, field);
|
|
23098
22859
|
break;
|
|
23099
22860
|
case "reference":
|
|
23100
22861
|
accum[fieldName] = fieldValue;
|
|
@@ -23127,10 +22888,18 @@ var Resolver = class {
|
|
|
23127
22888
|
accumulator[field.name] = value;
|
|
23128
22889
|
break;
|
|
23129
22890
|
case "image":
|
|
23130
|
-
|
|
22891
|
+
if (this.config) {
|
|
22892
|
+
if (this.config.useRelativeMedia === true) {
|
|
22893
|
+
accumulator[field.name] = value;
|
|
22894
|
+
} else {
|
|
22895
|
+
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22896
|
+
}
|
|
22897
|
+
} else {
|
|
22898
|
+
accumulator[field.name] = value;
|
|
22899
|
+
}
|
|
23131
22900
|
break;
|
|
23132
22901
|
case "rich-text":
|
|
23133
|
-
const tree = parseMDX(value, field
|
|
22902
|
+
const tree = parseMDX(value, field);
|
|
23134
22903
|
accumulator[field.name] = tree;
|
|
23135
22904
|
break;
|
|
23136
22905
|
case "object":
|
|
@@ -23838,6 +23607,7 @@ var Database = class {
|
|
|
23838
23607
|
const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
|
|
23839
23608
|
[lookup.type]: lookup
|
|
23840
23609
|
});
|
|
23610
|
+
console.log("adding ", lookup.type, " to lookup map");
|
|
23841
23611
|
await this.bridge.putConfig(normalizePath(lookupPath), JSON.stringify(updatedLookup));
|
|
23842
23612
|
};
|
|
23843
23613
|
this.bridge = config.bridge;
|
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 {
|
|
20
|
-
export declare const parseMDX: (value: string, field: RichTypeInner
|
|
19
|
+
import type { RichTypeInner } from '../types';
|
|
20
|
+
export declare const parseMDX: (value: string, field: RichTypeInner) => {
|
|
21
21
|
type: string;
|
|
22
22
|
children: any;
|
|
23
23
|
};
|
|
@@ -70,7 +70,7 @@ export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconf
|
|
|
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) => {
|
|
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
|
|
229
|
+
export default function remarkToSlate(node: MdxAstNode): 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 {
|
|
18
|
+
import type { 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
|
|
21
|
+
export declare const stringifyMDX: (value: unknown, field: RichTypeInner) => string;
|
|
22
22
|
export declare const stringify: (node: {
|
|
23
23
|
type: typeof plateElements;
|
|
24
|
-
}, field: RichTypeInner
|
|
24
|
+
}, field: RichTypeInner) => Content;
|
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-202251020263",
|
|
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.0.0-202251020263",
|
|
51
51
|
"body-parser": "^1.19.0",
|
|
52
52
|
"cors": "^2.8.5",
|
|
53
53
|
"dataloader": "^2.0.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"directory": "packages/tina-graphql"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@tinacms/datalayer": "0.
|
|
100
|
+
"@tinacms/datalayer": "0.0.0-202251020263",
|
|
101
101
|
"@tinacms/schema-tools": "0.0.4",
|
|
102
102
|
"@tinacms/scripts": "0.50.7",
|
|
103
103
|
"@types/cors": "^2.8.7",
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|