@tinacms/graphql 0.0.0-ea204c9-20250318044256 → 0.0.0-eaa6ed5-20250729073245
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/builder/index.d.ts +2 -2
- package/dist/database/bridge/filesystem.d.ts +1 -1
- package/dist/database/util.d.ts +6 -9
- package/dist/index.js +544 -563
- package/dist/index.mjs +427 -420
- package/dist/mdx/index.d.ts +2 -7
- package/dist/resolver/index.d.ts +5 -5
- package/dist/resolver/media-utils.d.ts +3 -3
- package/dist/schema/createSchema.d.ts +0 -3
- package/dist/schema/validate.d.ts +0 -3
- package/package.json +5 -7
- package/readme.md +0 -194
package/dist/index.mjs
CHANGED
|
@@ -1847,7 +1847,7 @@ var Builder = class {
|
|
|
1847
1847
|
* ```
|
|
1848
1848
|
*
|
|
1849
1849
|
* @public
|
|
1850
|
-
* @param collection a
|
|
1850
|
+
* @param collection a TinaCloud collection
|
|
1851
1851
|
*/
|
|
1852
1852
|
this.collectionFragment = async (collection) => {
|
|
1853
1853
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -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.
|
|
3022
|
+
version: "1.6.0",
|
|
3023
3023
|
main: "dist/index.js",
|
|
3024
3024
|
module: "dist/index.mjs",
|
|
3025
3025
|
typings: "dist/index.d.ts",
|
|
@@ -3045,33 +3045,32 @@ 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
|
},
|
|
3052
3051
|
dependencies: {
|
|
3053
|
-
"@iarna/toml": "
|
|
3052
|
+
"@iarna/toml": "catalog:",
|
|
3054
3053
|
"@tinacms/mdx": "workspace:*",
|
|
3055
3054
|
"@tinacms/schema-tools": "workspace:*",
|
|
3056
|
-
"abstract-level": "
|
|
3055
|
+
"abstract-level": "catalog:",
|
|
3057
3056
|
"date-fns": "^2.30.0",
|
|
3058
|
-
"fast-glob": "
|
|
3059
|
-
"fs-extra": "
|
|
3060
|
-
"glob-parent": "
|
|
3057
|
+
"fast-glob": "catalog:",
|
|
3058
|
+
"fs-extra": "catalog:",
|
|
3059
|
+
"glob-parent": "catalog:",
|
|
3061
3060
|
graphql: "15.8.0",
|
|
3062
|
-
"gray-matter": "
|
|
3063
|
-
"isomorphic-git": "
|
|
3064
|
-
"js-sha1": "
|
|
3061
|
+
"gray-matter": "catalog:",
|
|
3062
|
+
"isomorphic-git": "catalog:",
|
|
3063
|
+
"js-sha1": "catalog:",
|
|
3065
3064
|
"js-yaml": "^3.14.1",
|
|
3066
|
-
"jsonpath-plus": "
|
|
3067
|
-
"lodash.clonedeep": "
|
|
3068
|
-
"lodash.set": "
|
|
3069
|
-
"lodash.uniqby": "
|
|
3070
|
-
"many-level": "
|
|
3071
|
-
micromatch: "
|
|
3072
|
-
"normalize-path": "
|
|
3073
|
-
"readable-stream": "
|
|
3074
|
-
scmp: "
|
|
3065
|
+
"jsonpath-plus": "catalog:",
|
|
3066
|
+
"lodash.clonedeep": "catalog:",
|
|
3067
|
+
"lodash.set": "catalog:",
|
|
3068
|
+
"lodash.uniqby": "catalog:",
|
|
3069
|
+
"many-level": "catalog:",
|
|
3070
|
+
micromatch: "catalog:",
|
|
3071
|
+
"normalize-path": "catalog:",
|
|
3072
|
+
"readable-stream": "catalog:",
|
|
3073
|
+
scmp: "catalog:",
|
|
3075
3074
|
yup: "^0.32.11"
|
|
3076
3075
|
},
|
|
3077
3076
|
publishConfig: {
|
|
@@ -3086,21 +3085,20 @@ var package_default = {
|
|
|
3086
3085
|
"@tinacms/scripts": "workspace:*",
|
|
3087
3086
|
"@types/cors": "^2.8.17",
|
|
3088
3087
|
"@types/estree": "^0.0.50",
|
|
3089
|
-
"@types/express": "
|
|
3088
|
+
"@types/express": "catalog:",
|
|
3090
3089
|
"@types/fs-extra": "^9.0.13",
|
|
3091
3090
|
"@types/js-yaml": "^3.12.10",
|
|
3092
|
-
"@types/lodash.camelcase": "
|
|
3093
|
-
"@types/lodash.upperfirst": "
|
|
3094
|
-
"@types/lru-cache": "
|
|
3095
|
-
"@types/mdast": "
|
|
3096
|
-
"@types/micromatch": "
|
|
3091
|
+
"@types/lodash.camelcase": "catalog:",
|
|
3092
|
+
"@types/lodash.upperfirst": "catalog:",
|
|
3093
|
+
"@types/lru-cache": "catalog:",
|
|
3094
|
+
"@types/mdast": "catalog:",
|
|
3095
|
+
"@types/micromatch": "catalog:",
|
|
3097
3096
|
"@types/node": "^22.13.1",
|
|
3098
|
-
"@types/normalize-path": "
|
|
3099
|
-
"@types/ws": "
|
|
3097
|
+
"@types/normalize-path": "catalog:",
|
|
3098
|
+
"@types/ws": "catalog:",
|
|
3100
3099
|
"@types/yup": "^0.29.14",
|
|
3101
3100
|
"jest-file-snapshot": "^0.5.0",
|
|
3102
|
-
"memory-level": "
|
|
3103
|
-
nodemon: "3.1.4",
|
|
3101
|
+
"memory-level": "catalog:",
|
|
3104
3102
|
typescript: "^5.7.3",
|
|
3105
3103
|
vite: "^4.5.9",
|
|
3106
3104
|
vitest: "^0.32.4",
|
|
@@ -3312,249 +3310,10 @@ import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError4 }
|
|
|
3312
3310
|
// src/resolver/index.ts
|
|
3313
3311
|
import path3 from "path";
|
|
3314
3312
|
import isValid from "date-fns/isValid/index.js";
|
|
3315
|
-
|
|
3316
|
-
// src/mdx/index.ts
|
|
3317
|
-
import { parseMDX, stringifyMDX } from "@tinacms/mdx";
|
|
3318
|
-
|
|
3319
|
-
// src/resolver/index.ts
|
|
3320
3313
|
import { JSONPath as JSONPath2 } from "jsonpath-plus";
|
|
3321
3314
|
|
|
3322
|
-
// src/
|
|
3323
|
-
|
|
3324
|
-
constructor(message, extensions) {
|
|
3325
|
-
super(message);
|
|
3326
|
-
if (!this.name) {
|
|
3327
|
-
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
3328
|
-
}
|
|
3329
|
-
this.extensions = { ...extensions };
|
|
3330
|
-
}
|
|
3331
|
-
};
|
|
3332
|
-
var TinaFetchError = class extends Error {
|
|
3333
|
-
constructor(message, args) {
|
|
3334
|
-
super(message);
|
|
3335
|
-
this.name = "TinaFetchError";
|
|
3336
|
-
this.collection = args.collection;
|
|
3337
|
-
this.stack = args.stack;
|
|
3338
|
-
this.file = args.file;
|
|
3339
|
-
this.originalError = args.originalError;
|
|
3340
|
-
}
|
|
3341
|
-
};
|
|
3342
|
-
var TinaQueryError = class extends TinaFetchError {
|
|
3343
|
-
constructor(args) {
|
|
3344
|
-
super(
|
|
3345
|
-
`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3346
|
-
args
|
|
3347
|
-
);
|
|
3348
|
-
}
|
|
3349
|
-
};
|
|
3350
|
-
var TinaParseDocumentError = class extends TinaFetchError {
|
|
3351
|
-
constructor(args) {
|
|
3352
|
-
super(
|
|
3353
|
-
`Error parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`,
|
|
3354
|
-
args
|
|
3355
|
-
);
|
|
3356
|
-
}
|
|
3357
|
-
toString() {
|
|
3358
|
-
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
3359
|
-
}
|
|
3360
|
-
};
|
|
3361
|
-
var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
|
|
3362
|
-
var handleFetchErrorError = (e, verbose) => {
|
|
3363
|
-
if (e instanceof Error) {
|
|
3364
|
-
if (e instanceof TinaFetchError) {
|
|
3365
|
-
if (verbose) {
|
|
3366
|
-
console.log(e.toString());
|
|
3367
|
-
console.log(e);
|
|
3368
|
-
console.log(e.stack);
|
|
3369
|
-
}
|
|
3370
|
-
}
|
|
3371
|
-
} else {
|
|
3372
|
-
console.error(e);
|
|
3373
|
-
}
|
|
3374
|
-
throw e;
|
|
3375
|
-
};
|
|
3376
|
-
|
|
3377
|
-
// src/resolver/filter-utils.ts
|
|
3378
|
-
var resolveReferences = async (filter, fields, resolver) => {
|
|
3379
|
-
for (const fieldKey of Object.keys(filter)) {
|
|
3380
|
-
const fieldDefinition = fields.find(
|
|
3381
|
-
(f) => f.name === fieldKey
|
|
3382
|
-
);
|
|
3383
|
-
if (fieldDefinition) {
|
|
3384
|
-
if (fieldDefinition.type === "reference") {
|
|
3385
|
-
const { edges, values } = await resolver(filter, fieldDefinition);
|
|
3386
|
-
if (edges.length === 1) {
|
|
3387
|
-
filter[fieldKey] = {
|
|
3388
|
-
eq: values[0]
|
|
3389
|
-
};
|
|
3390
|
-
} else if (edges.length > 1) {
|
|
3391
|
-
filter[fieldKey] = {
|
|
3392
|
-
in: values
|
|
3393
|
-
};
|
|
3394
|
-
} else {
|
|
3395
|
-
filter[fieldKey] = {
|
|
3396
|
-
eq: "___null___"
|
|
3397
|
-
};
|
|
3398
|
-
}
|
|
3399
|
-
} else if (fieldDefinition.type === "object") {
|
|
3400
|
-
if (fieldDefinition.templates) {
|
|
3401
|
-
for (const templateName of Object.keys(filter[fieldKey])) {
|
|
3402
|
-
const template = fieldDefinition.templates.find(
|
|
3403
|
-
(template2) => !(typeof template2 === "string") && template2.name === templateName
|
|
3404
|
-
);
|
|
3405
|
-
if (template) {
|
|
3406
|
-
await resolveReferences(
|
|
3407
|
-
filter[fieldKey][templateName],
|
|
3408
|
-
template.fields,
|
|
3409
|
-
resolver
|
|
3410
|
-
);
|
|
3411
|
-
} else {
|
|
3412
|
-
throw new Error(`Template ${templateName} not found`);
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
} else {
|
|
3416
|
-
await resolveReferences(
|
|
3417
|
-
filter[fieldKey],
|
|
3418
|
-
fieldDefinition.fields,
|
|
3419
|
-
resolver
|
|
3420
|
-
);
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
} else {
|
|
3424
|
-
throw new Error(`Unable to find field ${fieldKey}`);
|
|
3425
|
-
}
|
|
3426
|
-
}
|
|
3427
|
-
};
|
|
3428
|
-
var collectConditionsForChildFields = (filterNode, fields, pathExpression, collectCondition) => {
|
|
3429
|
-
for (const childFieldName of Object.keys(filterNode)) {
|
|
3430
|
-
const childField = fields.find((field) => field.name === childFieldName);
|
|
3431
|
-
if (!childField) {
|
|
3432
|
-
throw new Error(`Unable to find type for field ${childFieldName}`);
|
|
3433
|
-
}
|
|
3434
|
-
collectConditionsForField(
|
|
3435
|
-
childFieldName,
|
|
3436
|
-
childField,
|
|
3437
|
-
filterNode[childFieldName],
|
|
3438
|
-
pathExpression,
|
|
3439
|
-
collectCondition
|
|
3440
|
-
);
|
|
3441
|
-
}
|
|
3442
|
-
};
|
|
3443
|
-
var collectConditionsForObjectField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3444
|
-
if (field.list && field.templates) {
|
|
3445
|
-
for (const [filterKey, childFilterNode] of Object.entries(filterNode)) {
|
|
3446
|
-
const template = field.templates.find(
|
|
3447
|
-
(template2) => !(typeof template2 === "string") && template2.name === filterKey
|
|
3448
|
-
);
|
|
3449
|
-
const jsonPath = `${fieldName}[?(@._template=="${filterKey}")]`;
|
|
3450
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : jsonPath;
|
|
3451
|
-
collectConditionsForChildFields(
|
|
3452
|
-
childFilterNode,
|
|
3453
|
-
template.fields,
|
|
3454
|
-
filterPath,
|
|
3455
|
-
collectCondition
|
|
3456
|
-
);
|
|
3457
|
-
}
|
|
3458
|
-
} else {
|
|
3459
|
-
const jsonPath = `${fieldName}${field.list ? "[*]" : ""}`;
|
|
3460
|
-
const filterPath = pathExpression ? `${pathExpression}.${jsonPath}` : `${jsonPath}`;
|
|
3461
|
-
collectConditionsForChildFields(
|
|
3462
|
-
filterNode,
|
|
3463
|
-
field.fields,
|
|
3464
|
-
filterPath,
|
|
3465
|
-
collectCondition
|
|
3466
|
-
);
|
|
3467
|
-
}
|
|
3468
|
-
};
|
|
3469
|
-
var collectConditionsForField = (fieldName, field, filterNode, pathExpression, collectCondition) => {
|
|
3470
|
-
if (field.type === "object") {
|
|
3471
|
-
collectConditionsForObjectField(
|
|
3472
|
-
fieldName,
|
|
3473
|
-
field,
|
|
3474
|
-
filterNode,
|
|
3475
|
-
pathExpression,
|
|
3476
|
-
collectCondition
|
|
3477
|
-
);
|
|
3478
|
-
} else {
|
|
3479
|
-
collectCondition({
|
|
3480
|
-
filterPath: pathExpression ? `${pathExpression}.${fieldName}` : fieldName,
|
|
3481
|
-
filterExpression: {
|
|
3482
|
-
_type: field.type,
|
|
3483
|
-
_list: !!field.list,
|
|
3484
|
-
...filterNode
|
|
3485
|
-
}
|
|
3486
|
-
});
|
|
3487
|
-
}
|
|
3488
|
-
};
|
|
3489
|
-
|
|
3490
|
-
// src/resolver/media-utils.ts
|
|
3491
|
-
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3492
|
-
if (config && value) {
|
|
3493
|
-
if (config.useRelativeMedia === true) {
|
|
3494
|
-
return value;
|
|
3495
|
-
}
|
|
3496
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3497
|
-
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
3498
|
-
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
3499
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3500
|
-
schema.config.media.tina.mediaRoot
|
|
3501
|
-
);
|
|
3502
|
-
const strippedURL = value.replace(assetsURL, "");
|
|
3503
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3504
|
-
}
|
|
3505
|
-
if (Array.isArray(value)) {
|
|
3506
|
-
return value.map((v) => {
|
|
3507
|
-
if (!v || typeof v !== "string") return v;
|
|
3508
|
-
const cleanMediaRoot = cleanUpSlashes(
|
|
3509
|
-
schema.config.media.tina.mediaRoot
|
|
3510
|
-
);
|
|
3511
|
-
const strippedURL = v.replace(assetsURL, "");
|
|
3512
|
-
return `${cleanMediaRoot}${strippedURL}`;
|
|
3513
|
-
});
|
|
3514
|
-
}
|
|
3515
|
-
return value;
|
|
3516
|
-
}
|
|
3517
|
-
return value;
|
|
3518
|
-
} else {
|
|
3519
|
-
return value;
|
|
3520
|
-
}
|
|
3521
|
-
};
|
|
3522
|
-
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
|
|
3523
|
-
if (config && value) {
|
|
3524
|
-
if (config.useRelativeMedia === true) {
|
|
3525
|
-
return value;
|
|
3526
|
-
}
|
|
3527
|
-
if (hasTinaMediaConfig(schema) === true) {
|
|
3528
|
-
const cleanMediaRoot = cleanUpSlashes(schema.config.media.tina.mediaRoot);
|
|
3529
|
-
if (typeof value === "string") {
|
|
3530
|
-
const strippedValue = value.replace(cleanMediaRoot, "");
|
|
3531
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3532
|
-
}
|
|
3533
|
-
if (Array.isArray(value)) {
|
|
3534
|
-
return value.map((v) => {
|
|
3535
|
-
if (!v || typeof v !== "string") return v;
|
|
3536
|
-
const strippedValue = v.replace(cleanMediaRoot, "");
|
|
3537
|
-
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
3538
|
-
});
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
return value;
|
|
3542
|
-
} else {
|
|
3543
|
-
return value;
|
|
3544
|
-
}
|
|
3545
|
-
};
|
|
3546
|
-
var cleanUpSlashes = (path7) => {
|
|
3547
|
-
if (path7) {
|
|
3548
|
-
return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
|
|
3549
|
-
}
|
|
3550
|
-
return "";
|
|
3551
|
-
};
|
|
3552
|
-
var hasTinaMediaConfig = (schema) => {
|
|
3553
|
-
if (!schema.config?.media?.tina) return false;
|
|
3554
|
-
if (typeof schema.config?.media?.tina?.publicFolder !== "string" && typeof schema.config?.media?.tina?.mediaRoot !== "string")
|
|
3555
|
-
return false;
|
|
3556
|
-
return true;
|
|
3557
|
-
};
|
|
3315
|
+
// src/mdx/index.ts
|
|
3316
|
+
import { parseMDX, serializeMDX } from "@tinacms/mdx";
|
|
3558
3317
|
|
|
3559
3318
|
// src/resolver/index.ts
|
|
3560
3319
|
import { GraphQLError as GraphQLError2 } from "graphql";
|
|
@@ -3617,13 +3376,13 @@ import path2 from "path";
|
|
|
3617
3376
|
|
|
3618
3377
|
// src/database/util.ts
|
|
3619
3378
|
import toml from "@iarna/toml";
|
|
3620
|
-
import yaml from "js-yaml";
|
|
3621
|
-
import matter from "gray-matter";
|
|
3622
3379
|
import {
|
|
3623
3380
|
normalizePath
|
|
3624
3381
|
} from "@tinacms/schema-tools";
|
|
3625
|
-
import
|
|
3382
|
+
import matter from "gray-matter";
|
|
3383
|
+
import yaml from "js-yaml";
|
|
3626
3384
|
import path from "path";
|
|
3385
|
+
import micromatch from "micromatch";
|
|
3627
3386
|
|
|
3628
3387
|
// src/database/alias-utils.ts
|
|
3629
3388
|
var replaceBlockAliases = (template, item) => {
|
|
@@ -4510,106 +4269,343 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
|
|
|
4510
4269
|
});
|
|
4511
4270
|
}
|
|
4512
4271
|
}
|
|
4513
|
-
return result;
|
|
4272
|
+
return result;
|
|
4273
|
+
};
|
|
4274
|
+
var makeIndexOpsForDocument = (filepath, collection, indexDefinitions, data, opType, level, escapeStr = stringEscaper) => {
|
|
4275
|
+
const result = [];
|
|
4276
|
+
if (collection) {
|
|
4277
|
+
const collectionSublevel = level.sublevel(collection, SUBLEVEL_OPTIONS);
|
|
4278
|
+
for (const [sort, definition] of Object.entries(indexDefinitions)) {
|
|
4279
|
+
const indexedValue = makeKeyForField(definition, data, escapeStr);
|
|
4280
|
+
const indexSublevel = collectionSublevel.sublevel(sort, SUBLEVEL_OPTIONS);
|
|
4281
|
+
if (sort === DEFAULT_COLLECTION_SORT_KEY) {
|
|
4282
|
+
result.push({
|
|
4283
|
+
type: opType,
|
|
4284
|
+
key: filepath,
|
|
4285
|
+
sublevel: indexSublevel,
|
|
4286
|
+
value: opType === "put" ? {} : void 0
|
|
4287
|
+
});
|
|
4288
|
+
} else {
|
|
4289
|
+
if (indexedValue) {
|
|
4290
|
+
result.push({
|
|
4291
|
+
type: opType,
|
|
4292
|
+
key: `${indexedValue}${INDEX_KEY_FIELD_SEPARATOR}${filepath}`,
|
|
4293
|
+
sublevel: indexSublevel,
|
|
4294
|
+
value: opType === "put" ? {} : void 0
|
|
4295
|
+
});
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
return result;
|
|
4301
|
+
};
|
|
4302
|
+
var makeRefOpsForDocument = (filepath, collection, references, data, opType, level) => {
|
|
4303
|
+
const result = [];
|
|
4304
|
+
if (collection) {
|
|
4305
|
+
for (const [c, referencePaths] of Object.entries(references || {})) {
|
|
4306
|
+
if (!referencePaths.length) {
|
|
4307
|
+
continue;
|
|
4308
|
+
}
|
|
4309
|
+
const collectionSublevel = level.sublevel(c, SUBLEVEL_OPTIONS);
|
|
4310
|
+
const refSublevel = collectionSublevel.sublevel(
|
|
4311
|
+
REFS_COLLECTIONS_SORT_KEY,
|
|
4312
|
+
SUBLEVEL_OPTIONS
|
|
4313
|
+
);
|
|
4314
|
+
const references2 = {};
|
|
4315
|
+
for (const path7 of referencePaths) {
|
|
4316
|
+
const ref = JSONPath({ path: path7, json: data });
|
|
4317
|
+
if (!ref) {
|
|
4318
|
+
continue;
|
|
4319
|
+
}
|
|
4320
|
+
if (Array.isArray(ref)) {
|
|
4321
|
+
for (const r of ref) {
|
|
4322
|
+
if (!r) {
|
|
4323
|
+
continue;
|
|
4324
|
+
}
|
|
4325
|
+
if (references2[r]) {
|
|
4326
|
+
references2[r].push(path7);
|
|
4327
|
+
} else {
|
|
4328
|
+
references2[r] = [path7];
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
} else {
|
|
4332
|
+
if (references2[ref]) {
|
|
4333
|
+
references2[ref].push(path7);
|
|
4334
|
+
} else {
|
|
4335
|
+
references2[ref] = [path7];
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
for (const ref of Object.keys(references2)) {
|
|
4340
|
+
for (const path7 of references2[ref]) {
|
|
4341
|
+
result.push({
|
|
4342
|
+
type: opType,
|
|
4343
|
+
key: `${ref}${INDEX_KEY_FIELD_SEPARATOR}${path7}${INDEX_KEY_FIELD_SEPARATOR}${filepath}`,
|
|
4344
|
+
sublevel: refSublevel,
|
|
4345
|
+
value: opType === "put" ? {} : void 0
|
|
4346
|
+
});
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
}
|
|
4351
|
+
return result;
|
|
4352
|
+
};
|
|
4353
|
+
var makeStringEscaper = (regex, replacement) => {
|
|
4354
|
+
return (input) => {
|
|
4355
|
+
if (Array.isArray(input)) {
|
|
4356
|
+
return input.map(
|
|
4357
|
+
(val) => val.replace(regex, replacement)
|
|
4358
|
+
);
|
|
4359
|
+
} else {
|
|
4360
|
+
if (typeof input === "string") {
|
|
4361
|
+
return input.replace(regex, replacement);
|
|
4362
|
+
} else {
|
|
4363
|
+
return input;
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
};
|
|
4367
|
+
};
|
|
4368
|
+
var stringEscaper = makeStringEscaper(
|
|
4369
|
+
new RegExp(INDEX_KEY_FIELD_SEPARATOR, "gm"),
|
|
4370
|
+
encodeURIComponent(INDEX_KEY_FIELD_SEPARATOR)
|
|
4371
|
+
);
|
|
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
|
+
}
|
|
4514
4493
|
};
|
|
4515
|
-
var
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
const
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
} else {
|
|
4530
|
-
if (indexedValue) {
|
|
4531
|
-
result.push({
|
|
4532
|
-
type: opType,
|
|
4533
|
-
key: `${indexedValue}${INDEX_KEY_FIELD_SEPARATOR}${filepath}`,
|
|
4534
|
-
sublevel: indexSublevel,
|
|
4535
|
-
value: opType === "put" ? {} : void 0
|
|
4536
|
-
});
|
|
4537
|
-
}
|
|
4538
|
-
}
|
|
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
|
+
);
|
|
4539
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
|
+
);
|
|
4540
4518
|
}
|
|
4541
|
-
return result;
|
|
4542
4519
|
};
|
|
4543
|
-
var
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
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
|
|
4549
4536
|
}
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
} else {
|
|
4569
|
-
references2[r] = [path7];
|
|
4570
|
-
}
|
|
4571
|
-
}
|
|
4572
|
-
} else {
|
|
4573
|
-
if (references2[ref]) {
|
|
4574
|
-
references2[ref].push(path7);
|
|
4575
|
-
} else {
|
|
4576
|
-
references2[ref] = [path7];
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
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}`;
|
|
4579
4555
|
}
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
}
|
|
4588
|
-
}
|
|
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
|
+
});
|
|
4589
4565
|
}
|
|
4566
|
+
return value;
|
|
4590
4567
|
}
|
|
4568
|
+
return value;
|
|
4569
|
+
} else {
|
|
4570
|
+
return value;
|
|
4591
4571
|
}
|
|
4592
|
-
return result;
|
|
4593
4572
|
};
|
|
4594
|
-
var
|
|
4595
|
-
|
|
4596
|
-
if (
|
|
4597
|
-
return
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
if (typeof
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
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
|
+
});
|
|
4605
4590
|
}
|
|
4606
4591
|
}
|
|
4607
|
-
|
|
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
4608
|
};
|
|
4609
|
-
var stringEscaper = makeStringEscaper(
|
|
4610
|
-
new RegExp(INDEX_KEY_FIELD_SEPARATOR, "gm"),
|
|
4611
|
-
encodeURIComponent(INDEX_KEY_FIELD_SEPARATOR)
|
|
4612
|
-
);
|
|
4613
4609
|
|
|
4614
4610
|
// src/resolver/index.ts
|
|
4615
4611
|
var createResolver = (args) => {
|
|
@@ -5576,7 +5572,7 @@ var Resolver = class {
|
|
|
5576
5572
|
}
|
|
5577
5573
|
break;
|
|
5578
5574
|
case "rich-text":
|
|
5579
|
-
accum[fieldName] =
|
|
5575
|
+
accum[fieldName] = serializeMDX(
|
|
5580
5576
|
fieldValue,
|
|
5581
5577
|
field,
|
|
5582
5578
|
(fieldValue2) => resolveMediaCloudToRelative(
|
|
@@ -6986,13 +6982,14 @@ var Database = class {
|
|
|
6986
6982
|
documentPaths,
|
|
6987
6983
|
async (collection, documentPaths2) => {
|
|
6988
6984
|
if (collection && !collection.isDetached) {
|
|
6989
|
-
await _indexContent(
|
|
6990
|
-
this,
|
|
6991
|
-
this.contentLevel,
|
|
6992
|
-
documentPaths2,
|
|
6985
|
+
await _indexContent({
|
|
6986
|
+
database: this,
|
|
6987
|
+
level: this.contentLevel,
|
|
6988
|
+
documentPaths: documentPaths2,
|
|
6993
6989
|
enqueueOps,
|
|
6994
|
-
collection
|
|
6995
|
-
|
|
6990
|
+
collection,
|
|
6991
|
+
isPartialReindex: true
|
|
6992
|
+
});
|
|
6996
6993
|
}
|
|
6997
6994
|
}
|
|
6998
6995
|
);
|
|
@@ -7099,26 +7096,26 @@ var Database = class {
|
|
|
7099
7096
|
);
|
|
7100
7097
|
const doc = await level2.keys({ limit: 1 }).next();
|
|
7101
7098
|
if (!doc) {
|
|
7102
|
-
await _indexContent(
|
|
7103
|
-
this,
|
|
7104
|
-
level2,
|
|
7105
|
-
contentPaths,
|
|
7099
|
+
await _indexContent({
|
|
7100
|
+
database: this,
|
|
7101
|
+
level: level2,
|
|
7102
|
+
documentPaths: contentPaths,
|
|
7106
7103
|
enqueueOps,
|
|
7107
7104
|
collection,
|
|
7108
|
-
userFields.map((field) => [
|
|
7105
|
+
passwordFields: userFields.map((field) => [
|
|
7109
7106
|
...field.path,
|
|
7110
7107
|
field.passwordFieldName
|
|
7111
7108
|
])
|
|
7112
|
-
);
|
|
7109
|
+
});
|
|
7113
7110
|
}
|
|
7114
7111
|
} else {
|
|
7115
|
-
await _indexContent(
|
|
7116
|
-
this,
|
|
7112
|
+
await _indexContent({
|
|
7113
|
+
database: this,
|
|
7117
7114
|
level,
|
|
7118
|
-
contentPaths,
|
|
7115
|
+
documentPaths: contentPaths,
|
|
7119
7116
|
enqueueOps,
|
|
7120
7117
|
collection
|
|
7121
|
-
);
|
|
7118
|
+
});
|
|
7122
7119
|
}
|
|
7123
7120
|
}
|
|
7124
7121
|
);
|
|
@@ -7257,7 +7254,15 @@ var hashPasswordValues = async (data, passwordFields) => Promise.all(
|
|
|
7257
7254
|
)
|
|
7258
7255
|
);
|
|
7259
7256
|
var isGitKeep = (filepath, collection) => filepath.endsWith(`.gitkeep.${collection?.format || "md"}`);
|
|
7260
|
-
var _indexContent = async (
|
|
7257
|
+
var _indexContent = async ({
|
|
7258
|
+
database,
|
|
7259
|
+
level,
|
|
7260
|
+
documentPaths,
|
|
7261
|
+
enqueueOps,
|
|
7262
|
+
collection,
|
|
7263
|
+
passwordFields,
|
|
7264
|
+
isPartialReindex
|
|
7265
|
+
}) => {
|
|
7261
7266
|
let collectionIndexDefinitions;
|
|
7262
7267
|
let collectionPath;
|
|
7263
7268
|
if (collection) {
|
|
@@ -7298,40 +7303,42 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
7298
7303
|
normalizedPath,
|
|
7299
7304
|
collectionPath || ""
|
|
7300
7305
|
);
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7306
|
+
if (isPartialReindex) {
|
|
7307
|
+
const item = await rootSublevel.get(normalizedPath);
|
|
7308
|
+
if (item) {
|
|
7309
|
+
await database.contentLevel.batch([
|
|
7310
|
+
...makeRefOpsForDocument(
|
|
7311
|
+
normalizedPath,
|
|
7312
|
+
collection?.name,
|
|
7313
|
+
collectionReferences,
|
|
7314
|
+
item,
|
|
7315
|
+
"del",
|
|
7316
|
+
level
|
|
7317
|
+
),
|
|
7318
|
+
...makeIndexOpsForDocument(
|
|
7319
|
+
normalizedPath,
|
|
7320
|
+
collection.name,
|
|
7321
|
+
collectionIndexDefinitions,
|
|
7322
|
+
item,
|
|
7323
|
+
"del",
|
|
7324
|
+
level
|
|
7325
|
+
),
|
|
7326
|
+
// folder indices
|
|
7327
|
+
...makeIndexOpsForDocument(
|
|
7328
|
+
normalizedPath,
|
|
7329
|
+
`${collection.name}_${folderKey}`,
|
|
7330
|
+
collectionIndexDefinitions,
|
|
7331
|
+
item,
|
|
7332
|
+
"del",
|
|
7333
|
+
level
|
|
7334
|
+
),
|
|
7335
|
+
{
|
|
7336
|
+
type: "del",
|
|
7337
|
+
key: normalizedPath,
|
|
7338
|
+
sublevel: rootSublevel
|
|
7339
|
+
}
|
|
7340
|
+
]);
|
|
7341
|
+
}
|
|
7335
7342
|
}
|
|
7336
7343
|
if (!isGitKeep(filepath, collection)) {
|
|
7337
7344
|
await enqueueOps([
|
|
@@ -7567,8 +7574,8 @@ import path6 from "path";
|
|
|
7567
7574
|
import normalize from "normalize-path";
|
|
7568
7575
|
var FilesystemBridge = class {
|
|
7569
7576
|
constructor(rootPath, outputPath) {
|
|
7570
|
-
this.rootPath = rootPath
|
|
7571
|
-
this.outputPath = outputPath
|
|
7577
|
+
this.rootPath = path6.resolve(rootPath);
|
|
7578
|
+
this.outputPath = outputPath ? path6.resolve(outputPath) : this.rootPath;
|
|
7572
7579
|
}
|
|
7573
7580
|
async glob(pattern, extension) {
|
|
7574
7581
|
const basePath = path6.join(this.outputPath, ...pattern.split("/"));
|
|
@@ -7580,19 +7587,19 @@ var FilesystemBridge = class {
|
|
|
7580
7587
|
}
|
|
7581
7588
|
);
|
|
7582
7589
|
const posixRootPath = normalize(this.outputPath);
|
|
7583
|
-
return items.map(
|
|
7584
|
-
|
|
7585
|
-
|
|
7590
|
+
return items.map(
|
|
7591
|
+
(item) => item.substring(posixRootPath.length).replace(/^\/|\/$/g, "")
|
|
7592
|
+
);
|
|
7586
7593
|
}
|
|
7587
7594
|
async delete(filepath) {
|
|
7588
7595
|
await fs2.remove(path6.join(this.outputPath, filepath));
|
|
7589
7596
|
}
|
|
7590
7597
|
async get(filepath) {
|
|
7591
|
-
return fs2.
|
|
7598
|
+
return (await fs2.readFile(path6.join(this.outputPath, filepath))).toString();
|
|
7592
7599
|
}
|
|
7593
7600
|
async put(filepath, data, basePathOverride) {
|
|
7594
7601
|
const basePath = basePathOverride || this.outputPath;
|
|
7595
|
-
await fs2.
|
|
7602
|
+
await fs2.outputFile(path6.join(basePath, filepath), data);
|
|
7596
7603
|
}
|
|
7597
7604
|
};
|
|
7598
7605
|
var AuditFileSystemBridge = class extends FilesystemBridge {
|