@tinacms/graphql 1.4.2 → 1.4.4
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 +75 -14
- package/dist/index.js +75 -14
- package/dist/resolver/media-utils.d.ts +4 -4
- package/package.json +1 -1
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.4",
|
|
2495
2495
|
main: "dist/index.js",
|
|
2496
2496
|
module: "dist/index.es.js",
|
|
2497
2497
|
typings: "dist/index.d.ts",
|
|
@@ -3000,6 +3000,17 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
|
|
|
3000
3000
|
const strippedURL = value.replace(assetsURL, "");
|
|
3001
3001
|
return `${cleanMediaRoot}${strippedURL}`;
|
|
3002
3002
|
}
|
|
3003
|
+
if (Array.isArray(value)) {
|
|
3004
|
+
return value.map((v) => {
|
|
3005
|
+
if (!v || typeof v !== "string")
|
|
3006
|
+
return v;
|
|
3007
|
+
const cleanMediaRoot = cleanUpSlashes(
|
|
3008
|
+
schema.config.media.tina.mediaRoot
|
|
3009
|
+
);
|
|
3010
|
+
const strippedURL = v.replace(assetsURL, "");
|
|
3011
|
+
return `${cleanMediaRoot}${strippedURL}`;
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3003
3014
|
return value;
|
|
3004
3015
|
}
|
|
3005
3016
|
return value;
|
|
@@ -3014,8 +3025,18 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3014
3025
|
}
|
|
3015
3026
|
if (hasTinaMediaConfig(schema) === true) {
|
|
3016
3027
|
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
3017
|
-
|
|
3018
|
-
|
|
3028
|
+
if (typeof value === "string") {
|
|
3029
|
+
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
3030
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3031
|
+
}
|
|
3032
|
+
if (Array.isArray(value)) {
|
|
3033
|
+
return value.map((v) => {
|
|
3034
|
+
if (!v || typeof v !== "string")
|
|
3035
|
+
return v;
|
|
3036
|
+
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3037
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3019
3040
|
}
|
|
3020
3041
|
return value;
|
|
3021
3042
|
} else {
|
|
@@ -4494,12 +4515,29 @@ var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
|
4494
4515
|
};
|
|
4495
4516
|
|
|
4496
4517
|
// src/database/alias-utils.ts
|
|
4518
|
+
var replaceBlockAliases = (template, item) => {
|
|
4519
|
+
const output = { ...item };
|
|
4520
|
+
const templateKey = template.templateKey || "_template";
|
|
4521
|
+
const templateName = output[templateKey];
|
|
4522
|
+
const matchingTemplate = template.templates.find(
|
|
4523
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4524
|
+
);
|
|
4525
|
+
if (!matchingTemplate) {
|
|
4526
|
+
throw new Error(
|
|
4527
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4528
|
+
);
|
|
4529
|
+
}
|
|
4530
|
+
output._template = matchingTemplate.name;
|
|
4531
|
+
if (templateKey != "_template") {
|
|
4532
|
+
delete output[templateKey];
|
|
4533
|
+
}
|
|
4534
|
+
return output;
|
|
4535
|
+
};
|
|
4497
4536
|
var replaceNameOverrides = (template, obj) => {
|
|
4498
4537
|
if (template.list) {
|
|
4499
4538
|
return obj.map((item) => {
|
|
4500
|
-
if (isBlockField(template)
|
|
4501
|
-
item
|
|
4502
|
-
delete item[template.templateKey];
|
|
4539
|
+
if (isBlockField(template)) {
|
|
4540
|
+
item = replaceBlockAliases(template, item);
|
|
4503
4541
|
}
|
|
4504
4542
|
return _replaceNameOverrides(
|
|
4505
4543
|
getTemplateForData(template, item).fields,
|
|
@@ -4527,27 +4565,50 @@ var getTemplateForData = (field, data) => {
|
|
|
4527
4565
|
if (field.templates?.length) {
|
|
4528
4566
|
const templateKey = "_template";
|
|
4529
4567
|
if (data[templateKey]) {
|
|
4530
|
-
|
|
4531
|
-
(template) => template.name === data[templateKey]
|
|
4568
|
+
const result = field.templates.find(
|
|
4569
|
+
(template) => template.nameOverride === data[templateKey] || template.name === data[templateKey]
|
|
4570
|
+
);
|
|
4571
|
+
if (result) {
|
|
4572
|
+
return result;
|
|
4573
|
+
}
|
|
4574
|
+
throw new Error(
|
|
4575
|
+
`Template "${data[templateKey]}" is not defined for field "${field.name}"`
|
|
4532
4576
|
);
|
|
4533
4577
|
}
|
|
4534
4578
|
throw new Error(
|
|
4535
|
-
`Missing required key "${templateKey}" on field ${field.name}`
|
|
4579
|
+
`Missing required key "${templateKey}" on field "${field.name}"`
|
|
4536
4580
|
);
|
|
4537
4581
|
} else {
|
|
4538
4582
|
return field;
|
|
4539
4583
|
}
|
|
4540
4584
|
};
|
|
4585
|
+
var applyBlockAliases = (template, item) => {
|
|
4586
|
+
const output = { ...item };
|
|
4587
|
+
const templateKey = template.templateKey || "_template";
|
|
4588
|
+
const templateName = output._template;
|
|
4589
|
+
const matchingTemplate = template.templates.find(
|
|
4590
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4591
|
+
);
|
|
4592
|
+
if (!matchingTemplate) {
|
|
4593
|
+
throw new Error(
|
|
4594
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4595
|
+
);
|
|
4596
|
+
}
|
|
4597
|
+
output[templateKey] = matchingTemplate.nameOverride || matchingTemplate.name;
|
|
4598
|
+
if (templateKey != "_template") {
|
|
4599
|
+
delete output._template;
|
|
4600
|
+
}
|
|
4601
|
+
return output;
|
|
4602
|
+
};
|
|
4541
4603
|
var applyNameOverrides = (template, obj) => {
|
|
4542
4604
|
if (template.list) {
|
|
4543
4605
|
return obj.map((item) => {
|
|
4544
|
-
|
|
4606
|
+
let result = _applyNameOverrides(
|
|
4545
4607
|
getTemplateForData(template, item).fields,
|
|
4546
4608
|
item
|
|
4547
4609
|
);
|
|
4548
|
-
if (isBlockField(template)
|
|
4549
|
-
result
|
|
4550
|
-
delete result._template;
|
|
4610
|
+
if (isBlockField(template)) {
|
|
4611
|
+
result = applyBlockAliases(template, result);
|
|
4551
4612
|
}
|
|
4552
4613
|
return result;
|
|
4553
4614
|
});
|
|
@@ -5222,7 +5283,7 @@ var Database = class {
|
|
|
5222
5283
|
`"${path4}" Found in multiple collections: ${filesSeen.get(path4).map((collection2) => `"${collection2}"`).join(
|
|
5223
5284
|
", "
|
|
5224
5285
|
)}. 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.
|
|
5286
|
+
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
5226
5287
|
`
|
|
5227
5288
|
);
|
|
5228
5289
|
});
|
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.4",
|
|
2546
2546
|
main: "dist/index.js",
|
|
2547
2547
|
module: "dist/index.es.js",
|
|
2548
2548
|
typings: "dist/index.d.ts",
|
|
@@ -3045,6 +3045,17 @@ var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, s
|
|
|
3045
3045
|
const strippedURL = value.replace(assetsURL, "");
|
|
3046
3046
|
return `${cleanMediaRoot}${strippedURL}`;
|
|
3047
3047
|
}
|
|
3048
|
+
if (Array.isArray(value)) {
|
|
3049
|
+
return value.map((v) => {
|
|
3050
|
+
if (!v || typeof v !== "string")
|
|
3051
|
+
return v;
|
|
3052
|
+
const cleanMediaRoot = cleanUpSlashes(
|
|
3053
|
+
schema.config.media.tina.mediaRoot
|
|
3054
|
+
);
|
|
3055
|
+
const strippedURL = v.replace(assetsURL, "");
|
|
3056
|
+
return `${cleanMediaRoot}${strippedURL}`;
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3048
3059
|
return value;
|
|
3049
3060
|
}
|
|
3050
3061
|
return value;
|
|
@@ -3059,8 +3070,18 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3059
3070
|
}
|
|
3060
3071
|
if (hasTinaMediaConfig(schema) === true) {
|
|
3061
3072
|
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
3062
|
-
|
|
3063
|
-
|
|
3073
|
+
if (typeof value === "string") {
|
|
3074
|
+
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
3075
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3076
|
+
}
|
|
3077
|
+
if (Array.isArray(value)) {
|
|
3078
|
+
return value.map((v) => {
|
|
3079
|
+
if (!v || typeof v !== "string")
|
|
3080
|
+
return v;
|
|
3081
|
+
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3082
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3083
|
+
});
|
|
3084
|
+
}
|
|
3064
3085
|
}
|
|
3065
3086
|
return value;
|
|
3066
3087
|
} else {
|
|
@@ -4545,12 +4566,29 @@ var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
|
4545
4566
|
};
|
|
4546
4567
|
|
|
4547
4568
|
// src/database/alias-utils.ts
|
|
4569
|
+
var replaceBlockAliases = (template, item) => {
|
|
4570
|
+
const output = { ...item };
|
|
4571
|
+
const templateKey = template.templateKey || "_template";
|
|
4572
|
+
const templateName = output[templateKey];
|
|
4573
|
+
const matchingTemplate = template.templates.find(
|
|
4574
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4575
|
+
);
|
|
4576
|
+
if (!matchingTemplate) {
|
|
4577
|
+
throw new Error(
|
|
4578
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4579
|
+
);
|
|
4580
|
+
}
|
|
4581
|
+
output._template = matchingTemplate.name;
|
|
4582
|
+
if (templateKey != "_template") {
|
|
4583
|
+
delete output[templateKey];
|
|
4584
|
+
}
|
|
4585
|
+
return output;
|
|
4586
|
+
};
|
|
4548
4587
|
var replaceNameOverrides = (template, obj) => {
|
|
4549
4588
|
if (template.list) {
|
|
4550
4589
|
return obj.map((item) => {
|
|
4551
|
-
if (isBlockField(template)
|
|
4552
|
-
item
|
|
4553
|
-
delete item[template.templateKey];
|
|
4590
|
+
if (isBlockField(template)) {
|
|
4591
|
+
item = replaceBlockAliases(template, item);
|
|
4554
4592
|
}
|
|
4555
4593
|
return _replaceNameOverrides(
|
|
4556
4594
|
getTemplateForData(template, item).fields,
|
|
@@ -4580,27 +4618,50 @@ var getTemplateForData = (field, data) => {
|
|
|
4580
4618
|
if ((_a = field.templates) == null ? void 0 : _a.length) {
|
|
4581
4619
|
const templateKey = "_template";
|
|
4582
4620
|
if (data[templateKey]) {
|
|
4583
|
-
|
|
4584
|
-
(template) => template.name === data[templateKey]
|
|
4621
|
+
const result = field.templates.find(
|
|
4622
|
+
(template) => template.nameOverride === data[templateKey] || template.name === data[templateKey]
|
|
4623
|
+
);
|
|
4624
|
+
if (result) {
|
|
4625
|
+
return result;
|
|
4626
|
+
}
|
|
4627
|
+
throw new Error(
|
|
4628
|
+
`Template "${data[templateKey]}" is not defined for field "${field.name}"`
|
|
4585
4629
|
);
|
|
4586
4630
|
}
|
|
4587
4631
|
throw new Error(
|
|
4588
|
-
`Missing required key "${templateKey}" on field ${field.name}`
|
|
4632
|
+
`Missing required key "${templateKey}" on field "${field.name}"`
|
|
4589
4633
|
);
|
|
4590
4634
|
} else {
|
|
4591
4635
|
return field;
|
|
4592
4636
|
}
|
|
4593
4637
|
};
|
|
4638
|
+
var applyBlockAliases = (template, item) => {
|
|
4639
|
+
const output = { ...item };
|
|
4640
|
+
const templateKey = template.templateKey || "_template";
|
|
4641
|
+
const templateName = output._template;
|
|
4642
|
+
const matchingTemplate = template.templates.find(
|
|
4643
|
+
(t) => t.nameOverride == templateName || t.name == templateName
|
|
4644
|
+
);
|
|
4645
|
+
if (!matchingTemplate) {
|
|
4646
|
+
throw new Error(
|
|
4647
|
+
`Block template "${templateName}" is not defined for field "${template.name}"`
|
|
4648
|
+
);
|
|
4649
|
+
}
|
|
4650
|
+
output[templateKey] = matchingTemplate.nameOverride || matchingTemplate.name;
|
|
4651
|
+
if (templateKey != "_template") {
|
|
4652
|
+
delete output._template;
|
|
4653
|
+
}
|
|
4654
|
+
return output;
|
|
4655
|
+
};
|
|
4594
4656
|
var applyNameOverrides = (template, obj) => {
|
|
4595
4657
|
if (template.list) {
|
|
4596
4658
|
return obj.map((item) => {
|
|
4597
|
-
|
|
4659
|
+
let result = _applyNameOverrides(
|
|
4598
4660
|
getTemplateForData(template, item).fields,
|
|
4599
4661
|
item
|
|
4600
4662
|
);
|
|
4601
|
-
if (isBlockField(template)
|
|
4602
|
-
result
|
|
4603
|
-
delete result._template;
|
|
4663
|
+
if (isBlockField(template)) {
|
|
4664
|
+
result = applyBlockAliases(template, result);
|
|
4604
4665
|
}
|
|
4605
4666
|
return result;
|
|
4606
4667
|
});
|
|
@@ -5280,7 +5341,7 @@ var Database = class {
|
|
|
5280
5341
|
`"${path4}" Found in multiple collections: ${filesSeen.get(path4).map((collection2) => `"${collection2}"`).join(
|
|
5281
5342
|
", "
|
|
5282
5343
|
)}. 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.
|
|
5344
|
+
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
5284
5345
|
`
|
|
5285
5346
|
);
|
|
5286
5347
|
});
|
|
@@ -6,16 +6,16 @@ import type { Schema } from '@tinacms/schema-tools';
|
|
|
6
6
|
/**
|
|
7
7
|
* Strips away the Tina Cloud Asset URL from an `image` value
|
|
8
8
|
*
|
|
9
|
-
* @param {string} value
|
|
9
|
+
* @param {string | string[]} value
|
|
10
10
|
* @param {GraphQLConfig} config
|
|
11
11
|
* @returns {string}
|
|
12
12
|
*/
|
|
13
|
-
export declare const resolveMediaCloudToRelative: (value: string, config: GraphQLConfig, schema: Schema<true>) => string;
|
|
13
|
+
export declare const resolveMediaCloudToRelative: (value: string | string[], config: GraphQLConfig, schema: Schema<true>) => string | string[];
|
|
14
14
|
/**
|
|
15
15
|
* Adds Tina Cloud Asset URL to an `image` value
|
|
16
16
|
*
|
|
17
|
-
* @param {string} value
|
|
17
|
+
* @param {string | string[]} value
|
|
18
18
|
* @param {GraphQLConfig} config
|
|
19
19
|
* @returns {string}
|
|
20
20
|
*/
|
|
21
|
-
export declare const resolveMediaRelativeToCloud: (value: string, config: GraphQLConfig, schema: Schema<true>) => string;
|
|
21
|
+
export declare const resolveMediaRelativeToCloud: (value: string | string[], config: GraphQLConfig, schema: Schema<true>) => string | string[];
|