@tinacms/graphql 1.5.17 → 1.5.19
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/bridge/filesystem.d.ts +1 -1
- package/dist/database/util.d.ts +6 -9
- package/dist/index.js +369 -397
- package/dist/index.mjs +251 -253
- package/dist/mdx/index.d.ts +2 -7
- package/dist/resolver/index.d.ts +5 -5
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -3019,7 +3019,7 @@ var validateField = async (field) => {
|
|
|
3019
3019
|
// package.json
|
|
3020
3020
|
var package_default = {
|
|
3021
3021
|
name: "@tinacms/graphql",
|
|
3022
|
-
version: "1.5.
|
|
3022
|
+
version: "1.5.19",
|
|
3023
3023
|
main: "dist/index.js",
|
|
3024
3024
|
module: "dist/index.mjs",
|
|
3025
3025
|
typings: "dist/index.d.ts",
|
|
@@ -3310,249 +3310,10 @@ import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError4 }
|
|
|
3310
3310
|
// src/resolver/index.ts
|
|
3311
3311
|
import path3 from "path";
|
|
3312
3312
|
import isValid from "date-fns/isValid/index.js";
|
|
3313
|
-
|
|
3314
|
-
// src/mdx/index.ts
|
|
3315
|
-
import { parseMDX, stringifyMDX } from "@tinacms/mdx";
|
|
3316
|
-
|
|
3317
|
-
// src/resolver/index.ts
|
|
3318
3313
|
import { JSONPath as JSONPath2 } from "jsonpath-plus";
|
|
3319
3314
|
|
|
3320
|
-
// src/
|
|
3321
|
-
|
|
3322
|
-
constructor(message, extensions) {
|
|
3323
|
-
super(message);
|
|
3324
|
-
if (!this.name) {
|
|
3325
|
-
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
3326
|
-
}
|
|
3327
|
-
this.extensions = { ...extensions };
|
|
3328
|
-
}
|
|
3329
|
-
};
|
|
3330
|
-
var TinaFetchError = class extends Error {
|
|
3331
|
-
constructor(message, args) {
|
|
3332
|
-
super(message);
|
|
3333
|
-
this.name = "TinaFetchError";
|
|
3334
|
-
this.collection = args.collection;
|
|
3335
|
-
this.stack = args.stack;
|
|
3336
|
-
this.file = args.file;
|
|
3337
|
-
this.originalError = args.originalError;
|
|
3338
|
-
}
|
|
3339
|
-
};
|
|
3340
|
-
var TinaQueryError = class extends TinaFetchError {
|
|
3341
|
-
constructor(args) {
|
|
3342
|
-
super(
|
|
3343
|
-
`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3344
|
-
args
|
|
3345
|
-
);
|
|
3346
|
-
}
|
|
3347
|
-
};
|
|
3348
|
-
var TinaParseDocumentError = class extends TinaFetchError {
|
|
3349
|
-
constructor(args) {
|
|
3350
|
-
super(
|
|
3351
|
-
`Error parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3352
|
-
args
|
|
3353
|
-
);
|
|
3354
|
-
}
|
|
3355
|
-
toString() {
|
|
3356
|
-
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
3357
|
-
}
|
|
3358
|
-
};
|
|
3359
|
-
var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
|
|
3360
|
-
var handleFetchErrorError = (e, verbose) => {
|
|
3361
|
-
if (e instanceof Error) {
|
|
3362
|
-
if (e instanceof TinaFetchError) {
|
|
3363
|
-
if (verbose) {
|
|
3364
|
-
console.log(e.toString());
|
|
3365
|
-
console.log(e);
|
|
3366
|
-
console.log(e.stack);
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
} else {
|
|
3370
|
-
console.error(e);
|
|
3371
|
-
}
|
|
3372
|
-
throw e;
|
|
3373
|
-
};
|
|
3374
|
-
|
|
3375
|
-
// src/resolver/filter-utils.ts
|
|
3376
|
-
var resolveReferences = async (filter, fields, resolver) => {
|
|
3377
|
-
for (const fieldKey of Object.keys(filter)) {
|
|
3378
|
-
const fieldDefinition = fields.find(
|
|
3379
|
-
(f) => f.name === fieldKey
|
|
3380
|
-
);
|
|
3381
|
-
if (fieldDefinition) {
|
|
3382
|
-
if (fieldDefinition.type === "reference") {
|
|
3383
|
-
const { edges, values } = await resolver(filter, fieldDefinition);
|
|
3384
|
-
if (edges.length === 1) {
|
|
3385
|
-
filter[fieldKey] = {
|
|
3386
|
-
eq: values[0]
|
|
3387
|
-
};
|
|
3388
|
-
} else if (edges.length > 1) {
|
|
3389
|
-
filter[fieldKey] = {
|
|
3390
|
-
in: values
|
|
3391
|
-
};
|
|
3392
|
-
} else {
|
|
3393
|
-
filter[fieldKey] = {
|
|
3394
|
-
eq: "___null___"
|
|
3395
|
-
};
|
|
3396
|
-
}
|
|
3397
|
-
} else if (fieldDefinition.type === "object") {
|
|
3398
|
-
if (fieldDefinition.templates) {
|
|
3399
|
-
for (const templateName of Object.keys(filter[fieldKey])) {
|
|
3400
|
-
const template = fieldDefinition.templates.find(
|
|
3401
|
-
(template2) => !(typeof template2 === "string") && template2.name === templateName
|
|
3402
|
-
);
|
|
3403
|
-
if (template) {
|
|
3404
|
-
await resolveReferences(
|
|
3405
|
-
filter[fieldKey][templateName],
|
|
3406
|
-
template.fields,
|
|
3407
|
-
resolver
|
|
3408
|
-
);
|
|
3409
|
-
} else {
|
|
3410
|
-
throw new Error(`Template ${templateName} not found`);
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
} else {
|
|
3414
|
-
await resolveReferences(
|
|
3415
|
-
filter[fieldKey],
|
|
3416
|
-
fieldDefinition.fields,
|
|
3417
|
-
resolver
|
|
3418
|
-
);
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
} else {
|
|
3422
|
-
throw new Error(`Unable to find field ${fieldKey}`);
|
|
3423
|
-
}
|
|
3424
|
-
}
|
|
3425
|
-
};
|
|
3426
|
-
var collectConditionsForChildFields = (filterNode, fields, pathExpression, collectCondition) => {
|
|
3427
|
-
for (const childFieldName of Object.keys(filterNode)) {
|
|
3428
|
-
const childField = fields.find((field) => field.name === childFieldName);
|
|
3429
|
-
if (!childField) {
|
|
3430
|
-
throw new Error(`Unable to find type for field ${childFieldName}`);
|
|
3431
|
-
}
|
|
3432
|
-
collectConditionsForField(
|
|
3433
|
-
childFieldName,
|
|
3434
|
-
childField,
|
|
3435
|
-
filterNode[childFieldName],
|
|
3436
|
-
pathExpression,
|
|
3437
|
-
collectCondition
|
|
3438
|
-
);
|
|
3439
|
-
}
|
|
3440
|
-
};
|
|
3441
|
-
var collectConditionsForObjectField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3442
|
-
if (field.list && field.templates) {
|
|
3443
|
-
for (const [filterKey, childFilterNode] of Object.entries(filterNode)) {
|
|
3444
|
-
const template = field.templates.find(
|
|
3445
|
-
(template2) => !(typeof template2 === "string") && template2.name === filterKey
|
|
3446
|
-
);
|
|
3447
|
-
const jsonPath = `${fieldName}[?(@._template=="${filterKey}")]`;
|
|
3448
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : jsonPath;
|
|
3449
|
-
collectConditionsForChildFields(
|
|
3450
|
-
childFilterNode,
|
|
3451
|
-
template.fields,
|
|
3452
|
-
filterPath,
|
|
3453
|
-
collectCondition
|
|
3454
|
-
);
|
|
3455
|
-
}
|
|
3456
|
-
} else {
|
|
3457
|
-
const jsonPath = `${fieldName}${field.list ? "[*]" : ""}`;
|
|
3458
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : `${jsonPath}`;
|
|
3459
|
-
collectConditionsForChildFields(
|
|
3460
|
-
filterNode,
|
|
3461
|
-
field.fields,
|
|
3462
|
-
filterPath,
|
|
3463
|
-
collectCondition
|
|
3464
|
-
);
|
|
3465
|
-
}
|
|
3466
|
-
};
|
|
3467
|
-
var collectConditionsForField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3468
|
-
if (field.type === "object") {
|
|
3469
|
-
collectConditionsForObjectField(
|
|
3470
|
-
fieldName,
|
|
3471
|
-
field,
|
|
3472
|
-
filterNode,
|
|
3473
|
-
pathExpression,
|
|
3474
|
-
collectCondition
|
|
3475
|
-
);
|
|
3476
|
-
} else {
|
|
3477
|
-
collectCondition({
|
|
3478
|
-
filterPath: pathExpression ? `${pathExpression}.${fieldName}` : fieldName,
|
|
3479
|
-
filterExpression: {
|
|
3480
|
-
_type: field.type,
|
|
3481
|
-
_list: !!field.list,
|
|
3482
|
-
...filterNode
|
|
3483
|
-
}
|
|
3484
|
-
});
|
|
3485
|
-
}
|
|
3486
|
-
};
|
|
3487
|
-
|
|
3488
|
-
// src/resolver/media-utils.ts
|
|
3489
|
-
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3490
|
-
if (config && value) {
|
|
3491
|
-
if (config.useRelativeMedia === true) {
|
|
3492
|
-
return value;
|
|
3493
|
-
}
|
|
3494
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3495
|
-
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
3496
|
-
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
3497
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3498
|
-
schema.config.media.tina.mediaRoot
|
|
3499
|
-
);
|
|
3500
|
-
const strippedURL = value.replace(assetsURL, "");
|
|
3501
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3502
|
-
}
|
|
3503
|
-
if (Array.isArray(value)) {
|
|
3504
|
-
return value.map((v) => {
|
|
3505
|
-
if (!v || typeof v !== "string") return v;
|
|
3506
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3507
|
-
schema.config.media.tina.mediaRoot
|
|
3508
|
-
);
|
|
3509
|
-
const strippedURL = v.replace(assetsURL, "");
|
|
3510
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3511
|
-
});
|
|
3512
|
-
}
|
|
3513
|
-
return value;
|
|
3514
|
-
}
|
|
3515
|
-
return value;
|
|
3516
|
-
} else {
|
|
3517
|
-
return value;
|
|
3518
|
-
}
|
|
3519
|
-
};
|
|
3520
|
-
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3521
|
-
if (config && value) {
|
|
3522
|
-
if (config.useRelativeMedia === true) {
|
|
3523
|
-
return value;
|
|
3524
|
-
}
|
|
3525
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3526
|
-
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
3527
|
-
if (typeof value === "string") {
|
|
3528
|
-
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
3529
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3530
|
-
}
|
|
3531
|
-
if (Array.isArray(value)) {
|
|
3532
|
-
return value.map((v) => {
|
|
3533
|
-
if (!v || typeof v !== "string") return v;
|
|
3534
|
-
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3535
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3536
|
-
});
|
|
3537
|
-
}
|
|
3538
|
-
}
|
|
3539
|
-
return value;
|
|
3540
|
-
} else {
|
|
3541
|
-
return value;
|
|
3542
|
-
}
|
|
3543
|
-
};
|
|
3544
|
-
var cleanUpSlashes = (path7) => {
|
|
3545
|
-
if (path7) {
|
|
3546
|
-
return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
|
|
3547
|
-
}
|
|
3548
|
-
return "";
|
|
3549
|
-
};
|
|
3550
|
-
var hasTinaMediaConfig = (schema) => {
|
|
3551
|
-
if (!schema.config?.media?.tina) return false;
|
|
3552
|
-
if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
|
|
3553
|
-
return false;
|
|
3554
|
-
return true;
|
|
3555
|
-
};
|
|
3315
|
+
// src/mdx/index.ts
|
|
3316
|
+
import { parseMDX, serializeMDX } from "@tinacms/mdx";
|
|
3556
3317
|
|
|
3557
3318
|
// src/resolver/index.ts
|
|
3558
3319
|
import { GraphQLError as GraphQLError2 } from "graphql";
|
|
@@ -3615,13 +3376,13 @@ import path2 from "path";
|
|
|
3615
3376
|
|
|
3616
3377
|
// src/database/util.ts
|
|
3617
3378
|
import toml from "@iarna/toml";
|
|
3618
|
-
import yaml from "js-yaml";
|
|
3619
|
-
import matter from "gray-matter";
|
|
3620
3379
|
import {
|
|
3621
3380
|
normalizePath
|
|
3622
3381
|
} from "@tinacms/schema-tools";
|
|
3623
|
-
import
|
|
3382
|
+
import matter from "gray-matter";
|
|
3383
|
+
import yaml from "js-yaml";
|
|
3624
3384
|
import path from "path";
|
|
3385
|
+
import micromatch from "micromatch";
|
|
3625
3386
|
|
|
3626
3387
|
// src/database/alias-utils.ts
|
|
3627
3388
|
var replaceBlockAliases = (template, item) => {
|
|
@@ -4609,6 +4370,243 @@ var stringEscaper = makeStringEscaper(
|
|
|
4609
4370
|
encodeURIComponent(INDEX_KEY_FIELD_SEPARATOR)
|
|
4610
4371
|
);
|
|
4611
4372
|
|
|
4373
|
+
// src/resolver/error.ts
|
|
4374
|
+
var TinaGraphQLError = class extends Error {
|
|
4375
|
+
constructor(message, extensions) {
|
|
4376
|
+
super(message);
|
|
4377
|
+
if (!this.name) {
|
|
4378
|
+
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
4379
|
+
}
|
|
4380
|
+
this.extensions = { ...extensions };
|
|
4381
|
+
}
|
|
4382
|
+
};
|
|
4383
|
+
var TinaFetchError = class extends Error {
|
|
4384
|
+
constructor(message, args) {
|
|
4385
|
+
super(message);
|
|
4386
|
+
this.name = "TinaFetchError";
|
|
4387
|
+
this.collection = args.collection;
|
|
4388
|
+
this.stack = args.stack;
|
|
4389
|
+
this.file = args.file;
|
|
4390
|
+
this.originalError = args.originalError;
|
|
4391
|
+
}
|
|
4392
|
+
};
|
|
4393
|
+
var TinaQueryError = class extends TinaFetchError {
|
|
4394
|
+
constructor(args) {
|
|
4395
|
+
super(
|
|
4396
|
+
`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
4397
|
+
args
|
|
4398
|
+
);
|
|
4399
|
+
}
|
|
4400
|
+
};
|
|
4401
|
+
var TinaParseDocumentError = class extends TinaFetchError {
|
|
4402
|
+
constructor(args) {
|
|
4403
|
+
super(
|
|
4404
|
+
`Error parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
4405
|
+
args
|
|
4406
|
+
);
|
|
4407
|
+
}
|
|
4408
|
+
toString() {
|
|
4409
|
+
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
4410
|
+
}
|
|
4411
|
+
};
|
|
4412
|
+
var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
|
|
4413
|
+
var handleFetchErrorError = (e, verbose) => {
|
|
4414
|
+
if (e instanceof Error) {
|
|
4415
|
+
if (e instanceof TinaFetchError) {
|
|
4416
|
+
if (verbose) {
|
|
4417
|
+
console.log(e.toString());
|
|
4418
|
+
console.log(e);
|
|
4419
|
+
console.log(e.stack);
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
} else {
|
|
4423
|
+
console.error(e);
|
|
4424
|
+
}
|
|
4425
|
+
throw e;
|
|
4426
|
+
};
|
|
4427
|
+
|
|
4428
|
+
// src/resolver/filter-utils.ts
|
|
4429
|
+
var resolveReferences = async (filter, fields, resolver) => {
|
|
4430
|
+
for (const fieldKey of Object.keys(filter)) {
|
|
4431
|
+
const fieldDefinition = fields.find(
|
|
4432
|
+
(f) => f.name === fieldKey
|
|
4433
|
+
);
|
|
4434
|
+
if (fieldDefinition) {
|
|
4435
|
+
if (fieldDefinition.type === "reference") {
|
|
4436
|
+
const { edges, values } = await resolver(filter, fieldDefinition);
|
|
4437
|
+
if (edges.length === 1) {
|
|
4438
|
+
filter[fieldKey] = {
|
|
4439
|
+
eq: values[0]
|
|
4440
|
+
};
|
|
4441
|
+
} else if (edges.length > 1) {
|
|
4442
|
+
filter[fieldKey] = {
|
|
4443
|
+
in: values
|
|
4444
|
+
};
|
|
4445
|
+
} else {
|
|
4446
|
+
filter[fieldKey] = {
|
|
4447
|
+
eq: "___null___"
|
|
4448
|
+
};
|
|
4449
|
+
}
|
|
4450
|
+
} else if (fieldDefinition.type === "object") {
|
|
4451
|
+
if (fieldDefinition.templates) {
|
|
4452
|
+
for (const templateName of Object.keys(filter[fieldKey])) {
|
|
4453
|
+
const template = fieldDefinition.templates.find(
|
|
4454
|
+
(template2) => !(typeof template2 === "string") && template2.name === templateName
|
|
4455
|
+
);
|
|
4456
|
+
if (template) {
|
|
4457
|
+
await resolveReferences(
|
|
4458
|
+
filter[fieldKey][templateName],
|
|
4459
|
+
template.fields,
|
|
4460
|
+
resolver
|
|
4461
|
+
);
|
|
4462
|
+
} else {
|
|
4463
|
+
throw new Error(`Template ${templateName} not found`);
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
} else {
|
|
4467
|
+
await resolveReferences(
|
|
4468
|
+
filter[fieldKey],
|
|
4469
|
+
fieldDefinition.fields,
|
|
4470
|
+
resolver
|
|
4471
|
+
);
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
} else {
|
|
4475
|
+
throw new Error(`Unable to find field ${fieldKey}`);
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
};
|
|
4479
|
+
var collectConditionsForChildFields = (filterNode, fields, pathExpression, collectCondition) => {
|
|
4480
|
+
for (const childFieldName of Object.keys(filterNode)) {
|
|
4481
|
+
const childField = fields.find((field) => field.name === childFieldName);
|
|
4482
|
+
if (!childField) {
|
|
4483
|
+
throw new Error(`Unable to find type for field ${childFieldName}`);
|
|
4484
|
+
}
|
|
4485
|
+
collectConditionsForField(
|
|
4486
|
+
childFieldName,
|
|
4487
|
+
childField,
|
|
4488
|
+
filterNode[childFieldName],
|
|
4489
|
+
pathExpression,
|
|
4490
|
+
collectCondition
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4493
|
+
};
|
|
4494
|
+
var collectConditionsForObjectField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
4495
|
+
if (field.list && field.templates) {
|
|
4496
|
+
for (const [filterKey, childFilterNode] of Object.entries(filterNode)) {
|
|
4497
|
+
const template = field.templates.find(
|
|
4498
|
+
(template2) => !(typeof template2 === "string") && template2.name === filterKey
|
|
4499
|
+
);
|
|
4500
|
+
const jsonPath = `${fieldName}[?(@._template=="${filterKey}")]`;
|
|
4501
|
+
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : jsonPath;
|
|
4502
|
+
collectConditionsForChildFields(
|
|
4503
|
+
childFilterNode,
|
|
4504
|
+
template.fields,
|
|
4505
|
+
filterPath,
|
|
4506
|
+
collectCondition
|
|
4507
|
+
);
|
|
4508
|
+
}
|
|
4509
|
+
} else {
|
|
4510
|
+
const jsonPath = `${fieldName}${field.list ? "[*]" : ""}`;
|
|
4511
|
+
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : `${jsonPath}`;
|
|
4512
|
+
collectConditionsForChildFields(
|
|
4513
|
+
filterNode,
|
|
4514
|
+
field.fields,
|
|
4515
|
+
filterPath,
|
|
4516
|
+
collectCondition
|
|
4517
|
+
);
|
|
4518
|
+
}
|
|
4519
|
+
};
|
|
4520
|
+
var collectConditionsForField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
4521
|
+
if (field.type === "object") {
|
|
4522
|
+
collectConditionsForObjectField(
|
|
4523
|
+
fieldName,
|
|
4524
|
+
field,
|
|
4525
|
+
filterNode,
|
|
4526
|
+
pathExpression,
|
|
4527
|
+
collectCondition
|
|
4528
|
+
);
|
|
4529
|
+
} else {
|
|
4530
|
+
collectCondition({
|
|
4531
|
+
filterPath: pathExpression ? `${pathExpression}.${fieldName}` : fieldName,
|
|
4532
|
+
filterExpression: {
|
|
4533
|
+
_type: field.type,
|
|
4534
|
+
_list: !!field.list,
|
|
4535
|
+
...filterNode
|
|
4536
|
+
}
|
|
4537
|
+
});
|
|
4538
|
+
}
|
|
4539
|
+
};
|
|
4540
|
+
|
|
4541
|
+
// src/resolver/media-utils.ts
|
|
4542
|
+
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
|
|
4543
|
+
if (config && value) {
|
|
4544
|
+
if (config.useRelativeMedia === true) {
|
|
4545
|
+
return value;
|
|
4546
|
+
}
|
|
4547
|
+
if (hasTinaMediaConfig(schema) === true) {
|
|
4548
|
+
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
4549
|
+
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
4550
|
+
const cleanMediaRoot = cleanUpSlashes(
|
|
4551
|
+
schema.config.media.tina.mediaRoot
|
|
4552
|
+
);
|
|
4553
|
+
const strippedURL = value.replace(assetsURL, "");
|
|
4554
|
+
return `${cleanMediaRoot}${strippedURL}`;
|
|
4555
|
+
}
|
|
4556
|
+
if (Array.isArray(value)) {
|
|
4557
|
+
return value.map((v) => {
|
|
4558
|
+
if (!v || typeof v !== "string") return v;
|
|
4559
|
+
const cleanMediaRoot = cleanUpSlashes(
|
|
4560
|
+
schema.config.media.tina.mediaRoot
|
|
4561
|
+
);
|
|
4562
|
+
const strippedURL = v.replace(assetsURL, "");
|
|
4563
|
+
return `${cleanMediaRoot}${strippedURL}`;
|
|
4564
|
+
});
|
|
4565
|
+
}
|
|
4566
|
+
return value;
|
|
4567
|
+
}
|
|
4568
|
+
return value;
|
|
4569
|
+
} else {
|
|
4570
|
+
return value;
|
|
4571
|
+
}
|
|
4572
|
+
};
|
|
4573
|
+
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
|
|
4574
|
+
if (config && value) {
|
|
4575
|
+
if (config.useRelativeMedia === true) {
|
|
4576
|
+
return value;
|
|
4577
|
+
}
|
|
4578
|
+
if (hasTinaMediaConfig(schema) === true) {
|
|
4579
|
+
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
4580
|
+
if (typeof value === "string") {
|
|
4581
|
+
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
4582
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
4583
|
+
}
|
|
4584
|
+
if (Array.isArray(value)) {
|
|
4585
|
+
return value.map((v) => {
|
|
4586
|
+
if (!v || typeof v !== "string") return v;
|
|
4587
|
+
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
4588
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
4589
|
+
});
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
return value;
|
|
4593
|
+
} else {
|
|
4594
|
+
return value;
|
|
4595
|
+
}
|
|
4596
|
+
};
|
|
4597
|
+
var cleanUpSlashes = (path7) => {
|
|
4598
|
+
if (path7) {
|
|
4599
|
+
return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
|
|
4600
|
+
}
|
|
4601
|
+
return "";
|
|
4602
|
+
};
|
|
4603
|
+
var hasTinaMediaConfig = (schema) => {
|
|
4604
|
+
if (!schema.config?.media?.tina) return false;
|
|
4605
|
+
if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
|
|
4606
|
+
return false;
|
|
4607
|
+
return true;
|
|
4608
|
+
};
|
|
4609
|
+
|
|
4612
4610
|
// src/resolver/index.ts
|
|
4613
4611
|
var createResolver = (args) => {
|
|
4614
4612
|
return new Resolver(args);
|
|
@@ -5574,7 +5572,7 @@ var Resolver = class {
|
|
|
5574
5572
|
}
|
|
5575
5573
|
break;
|
|
5576
5574
|
case "rich-text":
|
|
5577
|
-
accum[fieldName] =
|
|
5575
|
+
accum[fieldName] = serializeMDX(
|
|
5578
5576
|
fieldValue,
|
|
5579
5577
|
field,
|
|
5580
5578
|
(fieldValue2) => resolveMediaCloudToRelative(
|
|
@@ -7576,8 +7574,8 @@ import path6 from "path";
|
|
|
7576
7574
|
import normalize from "normalize-path";
|
|
7577
7575
|
var FilesystemBridge = class {
|
|
7578
7576
|
constructor(rootPath, outputPath) {
|
|
7579
|
-
this.rootPath = rootPath
|
|
7580
|
-
this.outputPath = outputPath
|
|
7577
|
+
this.rootPath = path6.resolve(rootPath);
|
|
7578
|
+
this.outputPath = outputPath ? path6.resolve(outputPath) : this.rootPath;
|
|
7581
7579
|
}
|
|
7582
7580
|
async glob(pattern, extension) {
|
|
7583
7581
|
const basePath = path6.join(this.outputPath, ...pattern.split("/"));
|
|
@@ -7589,19 +7587,19 @@ var FilesystemBridge = class {
|
|
|
7589
7587
|
}
|
|
7590
7588
|
);
|
|
7591
7589
|
const posixRootPath = normalize(this.outputPath);
|
|
7592
|
-
return items.map(
|
|
7593
|
-
|
|
7594
|
-
|
|
7590
|
+
return items.map(
|
|
7591
|
+
(item) => item.substring(posixRootPath.length).replace(/^\/|\/$/g, "")
|
|
7592
|
+
);
|
|
7595
7593
|
}
|
|
7596
7594
|
async delete(filepath) {
|
|
7597
7595
|
await fs2.remove(path6.join(this.outputPath, filepath));
|
|
7598
7596
|
}
|
|
7599
7597
|
async get(filepath) {
|
|
7600
|
-
return fs2.
|
|
7598
|
+
return (await fs2.readFile(path6.join(this.outputPath, filepath))).toString();
|
|
7601
7599
|
}
|
|
7602
7600
|
async put(filepath, data, basePathOverride) {
|
|
7603
7601
|
const basePath = basePathOverride || this.outputPath;
|
|
7604
|
-
await fs2.
|
|
7602
|
+
await fs2.outputFile(path6.join(basePath, filepath), data);
|
|
7605
7603
|
}
|
|
7606
7604
|
};
|
|
7607
7605
|
var AuditFileSystemBridge = class extends FilesystemBridge {
|
package/dist/mdx/index.d.ts
CHANGED
package/dist/resolver/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
*/
|
|
4
4
|
import { Database } from '../database';
|
|
5
|
-
import type { Collectable, Collection,
|
|
5
|
+
import type { Collectable, Collection, Template, TinaField, TinaSchema } from '@tinacms/schema-tools';
|
|
6
6
|
import type { GraphQLConfig } from '../types';
|
|
7
7
|
interface ResolverConfig {
|
|
8
8
|
config?: GraphQLConfig;
|
|
@@ -74,10 +74,10 @@ export declare class Resolver {
|
|
|
74
74
|
name: string;
|
|
75
75
|
}[];
|
|
76
76
|
}[];
|
|
77
|
-
format?: "
|
|
77
|
+
format?: import("@tinacms/schema-tools").ContentFormat;
|
|
78
78
|
ui?: import("@tinacms/schema-tools").UICollection;
|
|
79
79
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
80
|
-
frontmatterFormat?: "
|
|
80
|
+
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
81
81
|
frontmatterDelimiters?: [string, string] | string;
|
|
82
82
|
match?: {
|
|
83
83
|
include?: string;
|
|
@@ -102,10 +102,10 @@ export declare class Resolver {
|
|
|
102
102
|
name: string;
|
|
103
103
|
}[];
|
|
104
104
|
}[];
|
|
105
|
-
format?: "
|
|
105
|
+
format?: import("@tinacms/schema-tools").ContentFormat;
|
|
106
106
|
ui?: import("@tinacms/schema-tools").UICollection;
|
|
107
107
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
108
|
-
frontmatterFormat?: "
|
|
108
|
+
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
109
109
|
frontmatterDelimiters?: [string, string] | string;
|
|
110
110
|
match?: {
|
|
111
111
|
include?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.19",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"readable-stream": "^4.7.0",
|
|
45
45
|
"scmp": "^2.1.0",
|
|
46
46
|
"yup": "^0.32.11",
|
|
47
|
-
"@tinacms/mdx": "1.
|
|
48
|
-
"@tinacms/schema-tools": "1.
|
|
47
|
+
"@tinacms/mdx": "1.7.0",
|
|
48
|
+
"@tinacms/schema-tools": "1.8.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"registry": "https://registry.npmjs.org"
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"vite": "^4.5.9",
|
|
76
76
|
"vitest": "^0.32.4",
|
|
77
77
|
"zod": "^3.24.2",
|
|
78
|
-
"@tinacms/schema-tools": "1.
|
|
79
|
-
"@tinacms/scripts": "1.3.
|
|
78
|
+
"@tinacms/schema-tools": "1.8.0",
|
|
79
|
+
"@tinacms/scripts": "1.3.5"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"types": "pnpm tsc",
|