@tinacms/graphql 1.4.2 → 1.4.3
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/database/index.d.ts +1 -0
- package/dist/index.es.js +52 -12
- package/dist/index.js +52 -12
- package/package.json +7 -7
package/dist/database/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -2491,7 +2491,7 @@ var validateField = async (field) => {
|
|
|
2491
2491
|
// package.json
|
|
2492
2492
|
var package_default = {
|
|
2493
2493
|
name: "@tinacms/graphql",
|
|
2494
|
-
version: "1.4.
|
|
2494
|
+
version: "1.4.3",
|
|
2495
2495
|
main: "dist/index.js",
|
|
2496
2496
|
module: "dist/index.es.js",
|
|
2497
2497
|
typings: "dist/index.d.ts",
|
|
@@ -4494,12 +4494,29 @@ var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
|
4494
4494
|
};
|
|
4495
4495
|
|
|
4496
4496
|
// src/database/alias-utils.ts
|
|
4497
|
+
var replaceBlockAliases = (template, item) => {
|
|
4498
|
+
const output = { ...item };
|
|
4499
|
+
const templateKey = template.templateKey || "_template";
|
|
4500
|
+
const templateName = output[templateKey];
|
|
4501
|
+
const matchingTemplate = template.templates.find(
|
|
4502
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4503
|
+
);
|
|
4504
|
+
if (!matchingTemplate) {
|
|
4505
|
+
throw new Error(
|
|
4506
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4507
|
+
);
|
|
4508
|
+
}
|
|
4509
|
+
output._template = matchingTemplate.name;
|
|
4510
|
+
if (templateKey != "_template") {
|
|
4511
|
+
delete output[templateKey];
|
|
4512
|
+
}
|
|
4513
|
+
return output;
|
|
4514
|
+
};
|
|
4497
4515
|
var replaceNameOverrides = (template, obj) => {
|
|
4498
4516
|
if (template.list) {
|
|
4499
4517
|
return obj.map((item) => {
|
|
4500
|
-
if (isBlockField(template)
|
|
4501
|
-
item
|
|
4502
|
-
delete item[template.templateKey];
|
|
4518
|
+
if (isBlockField(template)) {
|
|
4519
|
+
item = replaceBlockAliases(template, item);
|
|
4503
4520
|
}
|
|
4504
4521
|
return _replaceNameOverrides(
|
|
4505
4522
|
getTemplateForData(template, item).fields,
|
|
@@ -4527,27 +4544,50 @@ var getTemplateForData = (field, data) => {
|
|
|
4527
4544
|
if (field.templates?.length) {
|
|
4528
4545
|
const templateKey = "_template";
|
|
4529
4546
|
if (data[templateKey]) {
|
|
4530
|
-
|
|
4531
|
-
(template) => template.name === data[templateKey]
|
|
4547
|
+
const result = field.templates.find(
|
|
4548
|
+
(template) => template.nameOverride === data[templateKey] || template.name === data[templateKey]
|
|
4549
|
+
);
|
|
4550
|
+
if (result) {
|
|
4551
|
+
return result;
|
|
4552
|
+
}
|
|
4553
|
+
throw new Error(
|
|
4554
|
+
`Template "${data[templateKey]}" is not defined for field "${field.name}"`
|
|
4532
4555
|
);
|
|
4533
4556
|
}
|
|
4534
4557
|
throw new Error(
|
|
4535
|
-
`Missing required key "${templateKey}" on field ${field.name}`
|
|
4558
|
+
`Missing required key "${templateKey}" on field "${field.name}"`
|
|
4536
4559
|
);
|
|
4537
4560
|
} else {
|
|
4538
4561
|
return field;
|
|
4539
4562
|
}
|
|
4540
4563
|
};
|
|
4564
|
+
var applyBlockAliases = (template, item) => {
|
|
4565
|
+
const output = { ...item };
|
|
4566
|
+
const templateKey = template.templateKey || "_template";
|
|
4567
|
+
const templateName = output._template;
|
|
4568
|
+
const matchingTemplate = template.templates.find(
|
|
4569
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4570
|
+
);
|
|
4571
|
+
if (!matchingTemplate) {
|
|
4572
|
+
throw new Error(
|
|
4573
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4574
|
+
);
|
|
4575
|
+
}
|
|
4576
|
+
output[templateKey] = matchingTemplate.nameOverride || matchingTemplate.name;
|
|
4577
|
+
if (templateKey != "_template") {
|
|
4578
|
+
delete output._template;
|
|
4579
|
+
}
|
|
4580
|
+
return output;
|
|
4581
|
+
};
|
|
4541
4582
|
var applyNameOverrides = (template, obj) => {
|
|
4542
4583
|
if (template.list) {
|
|
4543
4584
|
return obj.map((item) => {
|
|
4544
|
-
|
|
4585
|
+
let result = _applyNameOverrides(
|
|
4545
4586
|
getTemplateForData(template, item).fields,
|
|
4546
4587
|
item
|
|
4547
4588
|
);
|
|
4548
|
-
if (isBlockField(template)
|
|
4549
|
-
result
|
|
4550
|
-
delete result._template;
|
|
4589
|
+
if (isBlockField(template)) {
|
|
4590
|
+
result = applyBlockAliases(template, result);
|
|
4551
4591
|
}
|
|
4552
4592
|
return result;
|
|
4553
4593
|
});
|
|
@@ -5222,7 +5262,7 @@ var Database = class {
|
|
|
5222
5262
|
`"${path4}" Found in multiple collections: ${filesSeen.get(path4).map((collection2) => `"${collection2}"`).join(
|
|
5223
5263
|
", "
|
|
5224
5264
|
)}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
|
|
5225
|
-
This will be an error in the future.
|
|
5265
|
+
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
5226
5266
|
`
|
|
5227
5267
|
);
|
|
5228
5268
|
});
|
package/dist/index.js
CHANGED
|
@@ -2542,7 +2542,7 @@ var validateField = async (field) => {
|
|
|
2542
2542
|
// package.json
|
|
2543
2543
|
var package_default = {
|
|
2544
2544
|
name: "@tinacms/graphql",
|
|
2545
|
-
version: "1.4.
|
|
2545
|
+
version: "1.4.3",
|
|
2546
2546
|
main: "dist/index.js",
|
|
2547
2547
|
module: "dist/index.es.js",
|
|
2548
2548
|
typings: "dist/index.d.ts",
|
|
@@ -4545,12 +4545,29 @@ var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
|
4545
4545
|
};
|
|
4546
4546
|
|
|
4547
4547
|
// src/database/alias-utils.ts
|
|
4548
|
+
var replaceBlockAliases = (template, item) => {
|
|
4549
|
+
const output = { ...item };
|
|
4550
|
+
const templateKey = template.templateKey || "_template";
|
|
4551
|
+
const templateName = output[templateKey];
|
|
4552
|
+
const matchingTemplate = template.templates.find(
|
|
4553
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4554
|
+
);
|
|
4555
|
+
if (!matchingTemplate) {
|
|
4556
|
+
throw new Error(
|
|
4557
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4558
|
+
);
|
|
4559
|
+
}
|
|
4560
|
+
output._template = matchingTemplate.name;
|
|
4561
|
+
if (templateKey != "_template") {
|
|
4562
|
+
delete output[templateKey];
|
|
4563
|
+
}
|
|
4564
|
+
return output;
|
|
4565
|
+
};
|
|
4548
4566
|
var replaceNameOverrides = (template, obj) => {
|
|
4549
4567
|
if (template.list) {
|
|
4550
4568
|
return obj.map((item) => {
|
|
4551
|
-
if (isBlockField(template)
|
|
4552
|
-
item
|
|
4553
|
-
delete item[template.templateKey];
|
|
4569
|
+
if (isBlockField(template)) {
|
|
4570
|
+
item = replaceBlockAliases(template, item);
|
|
4554
4571
|
}
|
|
4555
4572
|
return _replaceNameOverrides(
|
|
4556
4573
|
getTemplateForData(template, item).fields,
|
|
@@ -4580,27 +4597,50 @@ var getTemplateForData = (field, data) => {
|
|
|
4580
4597
|
if ((_a = field.templates) == null ? void 0 : _a.length) {
|
|
4581
4598
|
const templateKey = "_template";
|
|
4582
4599
|
if (data[templateKey]) {
|
|
4583
|
-
|
|
4584
|
-
(template) => template.name === data[templateKey]
|
|
4600
|
+
const result = field.templates.find(
|
|
4601
|
+
(template) => template.nameOverride === data[templateKey] || template.name === data[templateKey]
|
|
4602
|
+
);
|
|
4603
|
+
if (result) {
|
|
4604
|
+
return result;
|
|
4605
|
+
}
|
|
4606
|
+
throw new Error(
|
|
4607
|
+
`Template "${data[templateKey]}" is not defined for field "${field.name}"`
|
|
4585
4608
|
);
|
|
4586
4609
|
}
|
|
4587
4610
|
throw new Error(
|
|
4588
|
-
`Missing required key "${templateKey}" on field ${field.name}`
|
|
4611
|
+
`Missing required key "${templateKey}" on field "${field.name}"`
|
|
4589
4612
|
);
|
|
4590
4613
|
} else {
|
|
4591
4614
|
return field;
|
|
4592
4615
|
}
|
|
4593
4616
|
};
|
|
4617
|
+
var applyBlockAliases = (template, item) => {
|
|
4618
|
+
const output = { ...item };
|
|
4619
|
+
const templateKey = template.templateKey || "_template";
|
|
4620
|
+
const templateName = output._template;
|
|
4621
|
+
const matchingTemplate = template.templates.find(
|
|
4622
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4623
|
+
);
|
|
4624
|
+
if (!matchingTemplate) {
|
|
4625
|
+
throw new Error(
|
|
4626
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4627
|
+
);
|
|
4628
|
+
}
|
|
4629
|
+
output[templateKey] = matchingTemplate.nameOverride || matchingTemplate.name;
|
|
4630
|
+
if (templateKey != "_template") {
|
|
4631
|
+
delete output._template;
|
|
4632
|
+
}
|
|
4633
|
+
return output;
|
|
4634
|
+
};
|
|
4594
4635
|
var applyNameOverrides = (template, obj) => {
|
|
4595
4636
|
if (template.list) {
|
|
4596
4637
|
return obj.map((item) => {
|
|
4597
|
-
|
|
4638
|
+
let result = _applyNameOverrides(
|
|
4598
4639
|
getTemplateForData(template, item).fields,
|
|
4599
4640
|
item
|
|
4600
4641
|
);
|
|
4601
|
-
if (isBlockField(template)
|
|
4602
|
-
result
|
|
4603
|
-
delete result._template;
|
|
4642
|
+
if (isBlockField(template)) {
|
|
4643
|
+
result = applyBlockAliases(template, result);
|
|
4604
4644
|
}
|
|
4605
4645
|
return result;
|
|
4606
4646
|
});
|
|
@@ -5280,7 +5320,7 @@ var Database = class {
|
|
|
5280
5320
|
`"${path4}" Found in multiple collections: ${filesSeen.get(path4).map((collection2) => `"${collection2}"`).join(
|
|
5281
5321
|
", "
|
|
5282
5322
|
)}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
|
|
5283
|
-
This will be an error in the future.
|
|
5323
|
+
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
5284
5324
|
`
|
|
5285
5325
|
);
|
|
5286
5326
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
27
27
|
"@iarna/toml": "^2.2.5",
|
|
28
|
-
"@tinacms/mdx": "1.3.7",
|
|
29
|
-
"@tinacms/schema-tools": "1.4.2",
|
|
30
28
|
"abstract-level": "^1.0.3",
|
|
31
29
|
"body-parser": "^1.19.0",
|
|
32
30
|
"cors": "^2.8.5",
|
|
@@ -73,7 +71,9 @@
|
|
|
73
71
|
"unist-util-visit": "^4.0.0",
|
|
74
72
|
"vfile": "^4.2.0",
|
|
75
73
|
"ws": "^7.3.1",
|
|
76
|
-
"yup": "^0.32.9"
|
|
74
|
+
"yup": "^0.32.9",
|
|
75
|
+
"@tinacms/mdx": "1.3.7",
|
|
76
|
+
"@tinacms/schema-tools": "1.4.2"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"registry": "https://registry.npmjs.org"
|
|
@@ -83,8 +83,6 @@
|
|
|
83
83
|
"directory": "packages/tina-graphql"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@tinacms/schema-tools": "1.4.2",
|
|
87
|
-
"@tinacms/scripts": "1.1.0",
|
|
88
86
|
"@types/cors": "^2.8.7",
|
|
89
87
|
"@types/estree": "^0.0.50",
|
|
90
88
|
"@types/express": "^4.17.8",
|
|
@@ -107,7 +105,9 @@
|
|
|
107
105
|
"jest-matcher-utils": "27.0.6",
|
|
108
106
|
"memory-level": "^1.0.0",
|
|
109
107
|
"nodemon": "2.0.19",
|
|
110
|
-
"typescript": "4.3.5"
|
|
108
|
+
"typescript": "4.3.5",
|
|
109
|
+
"@tinacms/schema-tools": "1.4.2",
|
|
110
|
+
"@tinacms/scripts": "1.1.0"
|
|
111
111
|
},
|
|
112
112
|
"scripts": {
|
|
113
113
|
"types": "pnpm tsc",
|