@tinacms/graphql 0.0.0-bdc07c1-20250506013835 → 0.0.0-be4681c-20250619070932
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/README.md +144 -0
- package/dist/database/bridge/filesystem.d.ts +1 -1
- package/dist/database/util.d.ts +2 -5
- package/dist/index.d.ts +32 -1
- package/dist/index.js +368 -401
- package/dist/index.mjs +249 -256
- package/dist/resolver/index.d.ts +5 -5
- package/dist/schema/createSchema.d.ts +0 -3
- package/dist/schema/validate.d.ts +0 -3
- package/package.json +5 -10
- package/readme.md +0 -194
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.18",
|
|
3023
3023
|
main: "dist/index.js",
|
|
3024
3024
|
module: "dist/index.mjs",
|
|
3025
3025
|
typings: "dist/index.d.ts",
|
|
@@ -3045,7 +3045,6 @@ var package_default = {
|
|
|
3045
3045
|
types: "pnpm tsc",
|
|
3046
3046
|
build: "tinacms-scripts build",
|
|
3047
3047
|
docs: "pnpm typedoc",
|
|
3048
|
-
serve: "pnpm nodemon dist/server.js",
|
|
3049
3048
|
test: "vitest run",
|
|
3050
3049
|
"test-watch": "vitest"
|
|
3051
3050
|
},
|
|
@@ -3074,9 +3073,6 @@ var package_default = {
|
|
|
3074
3073
|
scmp: "^2.1.0",
|
|
3075
3074
|
yup: "^0.32.11"
|
|
3076
3075
|
},
|
|
3077
|
-
peerDependencies: {
|
|
3078
|
-
"@tinacms/common": "workspace:*"
|
|
3079
|
-
},
|
|
3080
3076
|
publishConfig: {
|
|
3081
3077
|
registry: "https://registry.npmjs.org"
|
|
3082
3078
|
},
|
|
@@ -3103,7 +3099,6 @@ var package_default = {
|
|
|
3103
3099
|
"@types/yup": "^0.29.14",
|
|
3104
3100
|
"jest-file-snapshot": "^0.5.0",
|
|
3105
3101
|
"memory-level": "^1.0.0",
|
|
3106
|
-
nodemon: "3.1.4",
|
|
3107
3102
|
typescript: "^5.7.3",
|
|
3108
3103
|
vite: "^4.5.9",
|
|
3109
3104
|
vitest: "^0.32.4",
|
|
@@ -3315,250 +3310,11 @@ import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError4 }
|
|
|
3315
3310
|
// src/resolver/index.ts
|
|
3316
3311
|
import path3 from "path";
|
|
3317
3312
|
import isValid from "date-fns/isValid/index.js";
|
|
3313
|
+
import { JSONPath as JSONPath2 } from "jsonpath-plus";
|
|
3318
3314
|
|
|
3319
3315
|
// src/mdx/index.ts
|
|
3320
3316
|
import { parseMDX, stringifyMDX } from "@tinacms/mdx";
|
|
3321
3317
|
|
|
3322
|
-
// src/resolver/index.ts
|
|
3323
|
-
import { JSONPath as JSONPath2 } from "jsonpath-plus";
|
|
3324
|
-
|
|
3325
|
-
// src/resolver/error.ts
|
|
3326
|
-
var TinaGraphQLError = class extends Error {
|
|
3327
|
-
constructor(message, extensions) {
|
|
3328
|
-
super(message);
|
|
3329
|
-
if (!this.name) {
|
|
3330
|
-
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
3331
|
-
}
|
|
3332
|
-
this.extensions = { ...extensions };
|
|
3333
|
-
}
|
|
3334
|
-
};
|
|
3335
|
-
var TinaFetchError = class extends Error {
|
|
3336
|
-
constructor(message, args) {
|
|
3337
|
-
super(message);
|
|
3338
|
-
this.name = "TinaFetchError";
|
|
3339
|
-
this.collection = args.collection;
|
|
3340
|
-
this.stack = args.stack;
|
|
3341
|
-
this.file = args.file;
|
|
3342
|
-
this.originalError = args.originalError;
|
|
3343
|
-
}
|
|
3344
|
-
};
|
|
3345
|
-
var TinaQueryError = class extends TinaFetchError {
|
|
3346
|
-
constructor(args) {
|
|
3347
|
-
super(
|
|
3348
|
-
`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3349
|
-
args
|
|
3350
|
-
);
|
|
3351
|
-
}
|
|
3352
|
-
};
|
|
3353
|
-
var TinaParseDocumentError = class extends TinaFetchError {
|
|
3354
|
-
constructor(args) {
|
|
3355
|
-
super(
|
|
3356
|
-
`Error parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3357
|
-
args
|
|
3358
|
-
);
|
|
3359
|
-
}
|
|
3360
|
-
toString() {
|
|
3361
|
-
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
3362
|
-
}
|
|
3363
|
-
};
|
|
3364
|
-
var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
|
|
3365
|
-
var handleFetchErrorError = (e, verbose) => {
|
|
3366
|
-
if (e instanceof Error) {
|
|
3367
|
-
if (e instanceof TinaFetchError) {
|
|
3368
|
-
if (verbose) {
|
|
3369
|
-
console.log(e.toString());
|
|
3370
|
-
console.log(e);
|
|
3371
|
-
console.log(e.stack);
|
|
3372
|
-
}
|
|
3373
|
-
}
|
|
3374
|
-
} else {
|
|
3375
|
-
console.error(e);
|
|
3376
|
-
}
|
|
3377
|
-
throw e;
|
|
3378
|
-
};
|
|
3379
|
-
|
|
3380
|
-
// src/resolver/filter-utils.ts
|
|
3381
|
-
var resolveReferences = async (filter, fields, resolver) => {
|
|
3382
|
-
for (const fieldKey of Object.keys(filter)) {
|
|
3383
|
-
const fieldDefinition = fields.find(
|
|
3384
|
-
(f) => f.name === fieldKey
|
|
3385
|
-
);
|
|
3386
|
-
if (fieldDefinition) {
|
|
3387
|
-
if (fieldDefinition.type === "reference") {
|
|
3388
|
-
const { edges, values } = await resolver(filter, fieldDefinition);
|
|
3389
|
-
if (edges.length === 1) {
|
|
3390
|
-
filter[fieldKey] = {
|
|
3391
|
-
eq: values[0]
|
|
3392
|
-
};
|
|
3393
|
-
} else if (edges.length > 1) {
|
|
3394
|
-
filter[fieldKey] = {
|
|
3395
|
-
in: values
|
|
3396
|
-
};
|
|
3397
|
-
} else {
|
|
3398
|
-
filter[fieldKey] = {
|
|
3399
|
-
eq: "___null___"
|
|
3400
|
-
};
|
|
3401
|
-
}
|
|
3402
|
-
} else if (fieldDefinition.type === "object") {
|
|
3403
|
-
if (fieldDefinition.templates) {
|
|
3404
|
-
for (const templateName of Object.keys(filter[fieldKey])) {
|
|
3405
|
-
const template = fieldDefinition.templates.find(
|
|
3406
|
-
(template2) => !(typeof template2 === "string") && template2.name === templateName
|
|
3407
|
-
);
|
|
3408
|
-
if (template) {
|
|
3409
|
-
await resolveReferences(
|
|
3410
|
-
filter[fieldKey][templateName],
|
|
3411
|
-
template.fields,
|
|
3412
|
-
resolver
|
|
3413
|
-
);
|
|
3414
|
-
} else {
|
|
3415
|
-
throw new Error(`Template ${templateName} not found`);
|
|
3416
|
-
}
|
|
3417
|
-
}
|
|
3418
|
-
} else {
|
|
3419
|
-
await resolveReferences(
|
|
3420
|
-
filter[fieldKey],
|
|
3421
|
-
fieldDefinition.fields,
|
|
3422
|
-
resolver
|
|
3423
|
-
);
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
} else {
|
|
3427
|
-
throw new Error(`Unable to find field ${fieldKey}`);
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
};
|
|
3431
|
-
var collectConditionsForChildFields = (filterNode, fields, pathExpression, collectCondition) => {
|
|
3432
|
-
for (const childFieldName of Object.keys(filterNode)) {
|
|
3433
|
-
const childField = fields.find((field) => field.name === childFieldName);
|
|
3434
|
-
if (!childField) {
|
|
3435
|
-
throw new Error(`Unable to find type for field ${childFieldName}`);
|
|
3436
|
-
}
|
|
3437
|
-
collectConditionsForField(
|
|
3438
|
-
childFieldName,
|
|
3439
|
-
childField,
|
|
3440
|
-
filterNode[childFieldName],
|
|
3441
|
-
pathExpression,
|
|
3442
|
-
collectCondition
|
|
3443
|
-
);
|
|
3444
|
-
}
|
|
3445
|
-
};
|
|
3446
|
-
var collectConditionsForObjectField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3447
|
-
if (field.list && field.templates) {
|
|
3448
|
-
for (const [filterKey, childFilterNode] of Object.entries(filterNode)) {
|
|
3449
|
-
const template = field.templates.find(
|
|
3450
|
-
(template2) => !(typeof template2 === "string") && template2.name === filterKey
|
|
3451
|
-
);
|
|
3452
|
-
const jsonPath = `${fieldName}[?(@._template=="${filterKey}")]`;
|
|
3453
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : jsonPath;
|
|
3454
|
-
collectConditionsForChildFields(
|
|
3455
|
-
childFilterNode,
|
|
3456
|
-
template.fields,
|
|
3457
|
-
filterPath,
|
|
3458
|
-
collectCondition
|
|
3459
|
-
);
|
|
3460
|
-
}
|
|
3461
|
-
} else {
|
|
3462
|
-
const jsonPath = `${fieldName}${field.list ? "[*]" : ""}`;
|
|
3463
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : `${jsonPath}`;
|
|
3464
|
-
collectConditionsForChildFields(
|
|
3465
|
-
filterNode,
|
|
3466
|
-
field.fields,
|
|
3467
|
-
filterPath,
|
|
3468
|
-
collectCondition
|
|
3469
|
-
);
|
|
3470
|
-
}
|
|
3471
|
-
};
|
|
3472
|
-
var collectConditionsForField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3473
|
-
if (field.type === "object") {
|
|
3474
|
-
collectConditionsForObjectField(
|
|
3475
|
-
fieldName,
|
|
3476
|
-
field,
|
|
3477
|
-
filterNode,
|
|
3478
|
-
pathExpression,
|
|
3479
|
-
collectCondition
|
|
3480
|
-
);
|
|
3481
|
-
} else {
|
|
3482
|
-
collectCondition({
|
|
3483
|
-
filterPath: pathExpression ? `${pathExpression}.${fieldName}` : fieldName,
|
|
3484
|
-
filterExpression: {
|
|
3485
|
-
_type: field.type,
|
|
3486
|
-
_list: !!field.list,
|
|
3487
|
-
...filterNode
|
|
3488
|
-
}
|
|
3489
|
-
});
|
|
3490
|
-
}
|
|
3491
|
-
};
|
|
3492
|
-
|
|
3493
|
-
// src/resolver/media-utils.ts
|
|
3494
|
-
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3495
|
-
if (config && value) {
|
|
3496
|
-
if (config.useRelativeMedia === true) {
|
|
3497
|
-
return value;
|
|
3498
|
-
}
|
|
3499
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3500
|
-
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
3501
|
-
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
3502
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3503
|
-
schema.config.media.tina.mediaRoot
|
|
3504
|
-
);
|
|
3505
|
-
const strippedURL = value.replace(assetsURL, "");
|
|
3506
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3507
|
-
}
|
|
3508
|
-
if (Array.isArray(value)) {
|
|
3509
|
-
return value.map((v) => {
|
|
3510
|
-
if (!v || typeof v !== "string") return v;
|
|
3511
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3512
|
-
schema.config.media.tina.mediaRoot
|
|
3513
|
-
);
|
|
3514
|
-
const strippedURL = v.replace(assetsURL, "");
|
|
3515
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3516
|
-
});
|
|
3517
|
-
}
|
|
3518
|
-
return value;
|
|
3519
|
-
}
|
|
3520
|
-
return value;
|
|
3521
|
-
} else {
|
|
3522
|
-
return value;
|
|
3523
|
-
}
|
|
3524
|
-
};
|
|
3525
|
-
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3526
|
-
if (config && value) {
|
|
3527
|
-
if (config.useRelativeMedia === true) {
|
|
3528
|
-
return value;
|
|
3529
|
-
}
|
|
3530
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3531
|
-
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
3532
|
-
if (typeof value === "string") {
|
|
3533
|
-
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
3534
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3535
|
-
}
|
|
3536
|
-
if (Array.isArray(value)) {
|
|
3537
|
-
return value.map((v) => {
|
|
3538
|
-
if (!v || typeof v !== "string") return v;
|
|
3539
|
-
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3540
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3541
|
-
});
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
return value;
|
|
3545
|
-
} else {
|
|
3546
|
-
return value;
|
|
3547
|
-
}
|
|
3548
|
-
};
|
|
3549
|
-
var cleanUpSlashes = (path7) => {
|
|
3550
|
-
if (path7) {
|
|
3551
|
-
return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
|
|
3552
|
-
}
|
|
3553
|
-
return "";
|
|
3554
|
-
};
|
|
3555
|
-
var hasTinaMediaConfig = (schema) => {
|
|
3556
|
-
if (!schema.config?.media?.tina) return false;
|
|
3557
|
-
if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
|
|
3558
|
-
return false;
|
|
3559
|
-
return true;
|
|
3560
|
-
};
|
|
3561
|
-
|
|
3562
3318
|
// src/resolver/index.ts
|
|
3563
3319
|
import { GraphQLError as GraphQLError2 } from "graphql";
|
|
3564
3320
|
|
|
@@ -3620,13 +3376,13 @@ import path2 from "path";
|
|
|
3620
3376
|
|
|
3621
3377
|
// src/database/util.ts
|
|
3622
3378
|
import toml from "@iarna/toml";
|
|
3623
|
-
import yaml from "js-yaml";
|
|
3624
|
-
import matter from "gray-matter";
|
|
3625
3379
|
import {
|
|
3626
3380
|
normalizePath
|
|
3627
3381
|
} from "@tinacms/schema-tools";
|
|
3628
|
-
import
|
|
3382
|
+
import matter from "gray-matter";
|
|
3383
|
+
import yaml from "js-yaml";
|
|
3629
3384
|
import path from "path";
|
|
3385
|
+
import micromatch from "micromatch";
|
|
3630
3386
|
|
|
3631
3387
|
// src/database/alias-utils.ts
|
|
3632
3388
|
var replaceBlockAliases = (template, item) => {
|
|
@@ -4614,6 +4370,243 @@ var stringEscaper = makeStringEscaper(
|
|
|
4614
4370
|
encodeURIComponent(INDEX_KEY_FIELD_SEPARATOR)
|
|
4615
4371
|
);
|
|
4616
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
|
+
|
|
4617
4610
|
// src/resolver/index.ts
|
|
4618
4611
|
var createResolver = (args) => {
|
|
4619
4612
|
return new Resolver(args);
|
|
@@ -7581,8 +7574,8 @@ import path6 from "path";
|
|
|
7581
7574
|
import normalize from "normalize-path";
|
|
7582
7575
|
var FilesystemBridge = class {
|
|
7583
7576
|
constructor(rootPath, outputPath) {
|
|
7584
|
-
this.rootPath = rootPath
|
|
7585
|
-
this.outputPath = outputPath
|
|
7577
|
+
this.rootPath = path6.resolve(rootPath);
|
|
7578
|
+
this.outputPath = outputPath ? path6.resolve(outputPath) : this.rootPath;
|
|
7586
7579
|
}
|
|
7587
7580
|
async glob(pattern, extension) {
|
|
7588
7581
|
const basePath = path6.join(this.outputPath, ...pattern.split("/"));
|
|
@@ -7594,19 +7587,19 @@ var FilesystemBridge = class {
|
|
|
7594
7587
|
}
|
|
7595
7588
|
);
|
|
7596
7589
|
const posixRootPath = normalize(this.outputPath);
|
|
7597
|
-
return items.map(
|
|
7598
|
-
|
|
7599
|
-
|
|
7590
|
+
return items.map(
|
|
7591
|
+
(item) => item.substring(posixRootPath.length).replace(/^\/|\/$/g, "")
|
|
7592
|
+
);
|
|
7600
7593
|
}
|
|
7601
7594
|
async delete(filepath) {
|
|
7602
7595
|
await fs2.remove(path6.join(this.outputPath, filepath));
|
|
7603
7596
|
}
|
|
7604
7597
|
async get(filepath) {
|
|
7605
|
-
return fs2.
|
|
7598
|
+
return (await fs2.readFile(path6.join(this.outputPath, filepath))).toString();
|
|
7606
7599
|
}
|
|
7607
7600
|
async put(filepath, data, basePathOverride) {
|
|
7608
7601
|
const basePath = basePathOverride || this.outputPath;
|
|
7609
|
-
await fs2.
|
|
7602
|
+
await fs2.outputFile(path6.join(basePath, filepath), data);
|
|
7610
7603
|
}
|
|
7611
7604
|
};
|
|
7612
7605
|
var AuditFileSystemBridge = class extends FilesystemBridge {
|
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?: import("@tinacms/
|
|
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?: import("@tinacms/
|
|
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?: import("@tinacms/
|
|
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?: import("@tinacms/
|
|
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": "0.0.0-
|
|
3
|
+
"version": "0.0.0-be4681c-20250619070932",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -44,11 +44,8 @@
|
|
|
44
44
|
"readable-stream": "^4.7.0",
|
|
45
45
|
"scmp": "^2.1.0",
|
|
46
46
|
"yup": "^0.32.11",
|
|
47
|
-
"@tinacms/mdx": "0.0.0-
|
|
48
|
-
"@tinacms/schema-tools": "0.0.0-
|
|
49
|
-
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"@tinacms/common": "0.0.0-bdc07c1-20250506013835"
|
|
47
|
+
"@tinacms/mdx": "0.0.0-be4681c-20250619070932",
|
|
48
|
+
"@tinacms/schema-tools": "0.0.0-be4681c-20250619070932"
|
|
52
49
|
},
|
|
53
50
|
"publishConfig": {
|
|
54
51
|
"registry": "https://registry.npmjs.org"
|
|
@@ -74,19 +71,17 @@
|
|
|
74
71
|
"@types/yup": "^0.29.14",
|
|
75
72
|
"jest-file-snapshot": "^0.5.0",
|
|
76
73
|
"memory-level": "^1.0.0",
|
|
77
|
-
"nodemon": "3.1.4",
|
|
78
74
|
"typescript": "^5.7.3",
|
|
79
75
|
"vite": "^4.5.9",
|
|
80
76
|
"vitest": "^0.32.4",
|
|
81
77
|
"zod": "^3.24.2",
|
|
82
|
-
"@tinacms/schema-tools": "0.0.0-
|
|
83
|
-
"@tinacms/scripts": "1.3.
|
|
78
|
+
"@tinacms/schema-tools": "0.0.0-be4681c-20250619070932",
|
|
79
|
+
"@tinacms/scripts": "1.3.5"
|
|
84
80
|
},
|
|
85
81
|
"scripts": {
|
|
86
82
|
"types": "pnpm tsc",
|
|
87
83
|
"build": "tinacms-scripts build",
|
|
88
84
|
"docs": "pnpm typedoc",
|
|
89
|
-
"serve": "pnpm nodemon dist/server.js",
|
|
90
85
|
"test": "vitest run",
|
|
91
86
|
"test-watch": "vitest"
|
|
92
87
|
}
|