@tinacms/graphql 1.4.26 → 1.4.28
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/error.d.ts +4 -0
- package/dist/index.js +83 -62
- package/dist/index.mjs +79 -58
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@ import type { Bridge } from './index';
|
|
|
2
2
|
/**
|
|
3
3
|
* This is the bridge from whatever datasource we need for I/O.
|
|
4
4
|
* The basic example here is for the filesystem, one is needed
|
|
5
|
-
* for
|
|
5
|
+
* for GitHub has well.
|
|
6
6
|
*/
|
|
7
7
|
export declare class FilesystemBridge implements Bridge {
|
|
8
8
|
rootPath: string;
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ASTNode, GraphQLError, GraphQLErrorExtensions, Source } from 'graphql';
|
|
2
|
+
export declare class NotFoundError extends GraphQLError {
|
|
3
|
+
constructor(message: string, nodes?: ASTNode | readonly ASTNode[], source?: Source, positions?: readonly number[], path?: readonly (string | number)[], originalError?: Error, extensions?: GraphQLErrorExtensions);
|
|
4
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1574,7 +1574,12 @@ var Builder = class {
|
|
|
1574
1574
|
[NAMER.createName([collection.name])]: "create",
|
|
1575
1575
|
[NAMER.updateName([collection.name])]: "update"
|
|
1576
1576
|
});
|
|
1577
|
-
return astBuilder.FieldDefinition({
|
|
1577
|
+
return astBuilder.FieldDefinition({
|
|
1578
|
+
type,
|
|
1579
|
+
name,
|
|
1580
|
+
args,
|
|
1581
|
+
required: true
|
|
1582
|
+
});
|
|
1578
1583
|
};
|
|
1579
1584
|
this.collectionFragment = async (collection) => {
|
|
1580
1585
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -2590,7 +2595,7 @@ var validateField = async (field) => {
|
|
|
2590
2595
|
// package.json
|
|
2591
2596
|
var package_default = {
|
|
2592
2597
|
name: "@tinacms/graphql",
|
|
2593
|
-
version: "1.4.
|
|
2598
|
+
version: "1.4.28",
|
|
2594
2599
|
main: "dist/index.js",
|
|
2595
2600
|
module: "dist/index.mjs",
|
|
2596
2601
|
typings: "dist/index.d.ts",
|
|
@@ -2863,7 +2868,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
2863
2868
|
};
|
|
2864
2869
|
|
|
2865
2870
|
// src/resolve.ts
|
|
2866
|
-
var
|
|
2871
|
+
var import_graphql5 = require("graphql");
|
|
2867
2872
|
|
|
2868
2873
|
// src/resolver/index.ts
|
|
2869
2874
|
var import_path3 = __toESM(require("path"));
|
|
@@ -3342,40 +3347,44 @@ ${$_body}`,
|
|
|
3342
3347
|
};
|
|
3343
3348
|
var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
3344
3349
|
var _a, _b;
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3350
|
+
try {
|
|
3351
|
+
switch (format) {
|
|
3352
|
+
case ".markdown":
|
|
3353
|
+
case ".mdx":
|
|
3354
|
+
case ".md":
|
|
3355
|
+
const contentJSON = (0, import_gray_matter.default)(content || "", {
|
|
3356
|
+
language: (_a = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) != null ? _a : "yaml",
|
|
3357
|
+
delimiters: (_b = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) != null ? _b : "---",
|
|
3358
|
+
engines: matterEngines
|
|
3359
|
+
});
|
|
3360
|
+
const markdownData = {
|
|
3361
|
+
...contentJSON.data,
|
|
3362
|
+
$_body: contentJSON.content
|
|
3363
|
+
};
|
|
3364
|
+
assertShape(markdownData, yupSchema);
|
|
3365
|
+
return markdownData;
|
|
3366
|
+
case ".json":
|
|
3367
|
+
if (!content) {
|
|
3368
|
+
return {};
|
|
3369
|
+
}
|
|
3370
|
+
return JSON.parse(content);
|
|
3371
|
+
case ".toml":
|
|
3372
|
+
if (!content) {
|
|
3373
|
+
return {};
|
|
3374
|
+
}
|
|
3375
|
+
return import_toml.default.parse(content);
|
|
3376
|
+
case ".yaml":
|
|
3377
|
+
case ".yml":
|
|
3378
|
+
if (!content) {
|
|
3379
|
+
return {};
|
|
3380
|
+
}
|
|
3381
|
+
return import_js_yaml.default.safeLoad(content);
|
|
3382
|
+
}
|
|
3383
|
+
} catch (e) {
|
|
3384
|
+
console.error(e);
|
|
3385
|
+
throw e;
|
|
3378
3386
|
}
|
|
3387
|
+
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3379
3388
|
};
|
|
3380
3389
|
var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
3381
3390
|
const warnings = [];
|
|
@@ -3507,7 +3516,7 @@ var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo)
|
|
|
3507
3516
|
const template = getTemplateForFile(templateInfo, data);
|
|
3508
3517
|
if (!template) {
|
|
3509
3518
|
console.warn(
|
|
3510
|
-
`Document: ${filepath} has an ambiguous template, skipping from indexing
|
|
3519
|
+
`Document: ${filepath} has an ambiguous template, skipping from indexing. See https://tina.io/docs/errors/ambiguous-template/ for more info.`
|
|
3511
3520
|
);
|
|
3512
3521
|
return;
|
|
3513
3522
|
}
|
|
@@ -4858,6 +4867,15 @@ var resolveDateInput = (value) => {
|
|
|
4858
4867
|
return date;
|
|
4859
4868
|
};
|
|
4860
4869
|
|
|
4870
|
+
// src/error.ts
|
|
4871
|
+
var import_graphql4 = require("graphql");
|
|
4872
|
+
var NotFoundError = class extends import_graphql4.GraphQLError {
|
|
4873
|
+
constructor(message, nodes, source, positions, path7, originalError, extensions) {
|
|
4874
|
+
super(message, nodes, source, positions, path7, originalError, extensions);
|
|
4875
|
+
this.name = "NotFoundError";
|
|
4876
|
+
}
|
|
4877
|
+
};
|
|
4878
|
+
|
|
4861
4879
|
// src/resolve.ts
|
|
4862
4880
|
var resolve = async ({
|
|
4863
4881
|
config,
|
|
@@ -4873,9 +4891,9 @@ var resolve = async ({
|
|
|
4873
4891
|
const verboseValue = verbose != null ? verbose : true;
|
|
4874
4892
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
4875
4893
|
if (!graphQLSchemaAst) {
|
|
4876
|
-
throw new
|
|
4894
|
+
throw new import_graphql5.GraphQLError(`GraphQL schema not found`);
|
|
4877
4895
|
}
|
|
4878
|
-
const graphQLSchema = (0,
|
|
4896
|
+
const graphQLSchema = (0, import_graphql5.buildASTSchema)(graphQLSchemaAst);
|
|
4879
4897
|
const tinaConfig = await database.getTinaSchema();
|
|
4880
4898
|
const tinaSchema = await createSchema({
|
|
4881
4899
|
schema: tinaConfig,
|
|
@@ -4887,7 +4905,7 @@ var resolve = async ({
|
|
|
4887
4905
|
tinaSchema,
|
|
4888
4906
|
isAudit: isAudit || false
|
|
4889
4907
|
});
|
|
4890
|
-
const res = await (0,
|
|
4908
|
+
const res = await (0, import_graphql5.graphql)({
|
|
4891
4909
|
schema: graphQLSchema,
|
|
4892
4910
|
source: query,
|
|
4893
4911
|
variableValues: variables,
|
|
@@ -4897,7 +4915,7 @@ var resolve = async ({
|
|
|
4897
4915
|
typeResolver: async (source, _args, info) => {
|
|
4898
4916
|
if (source.__typename)
|
|
4899
4917
|
return source.__typename;
|
|
4900
|
-
const namedType = (0,
|
|
4918
|
+
const namedType = (0, import_graphql5.getNamedType)(info.returnType).toString();
|
|
4901
4919
|
const lookup = await database.getLookup(namedType);
|
|
4902
4920
|
if (lookup.resolveType === "unionData") {
|
|
4903
4921
|
return lookup.typeMap[source._template];
|
|
@@ -4909,7 +4927,7 @@ var resolve = async ({
|
|
|
4909
4927
|
var _a2, _b, _c, _d;
|
|
4910
4928
|
try {
|
|
4911
4929
|
const args = JSON.parse(JSON.stringify(_args));
|
|
4912
|
-
const returnType = (0,
|
|
4930
|
+
const returnType = (0, import_graphql5.getNamedType)(info.returnType).toString();
|
|
4913
4931
|
const lookup = await database.getLookup(returnType);
|
|
4914
4932
|
const isMutation = info.parentType.toString() === "Mutation";
|
|
4915
4933
|
const value = source[info.fieldName];
|
|
@@ -5072,11 +5090,14 @@ var resolve = async ({
|
|
|
5072
5090
|
if (res.errors) {
|
|
5073
5091
|
if (!silenceErrors) {
|
|
5074
5092
|
res.errors.map((e) => {
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
console.error(
|
|
5078
|
-
|
|
5079
|
-
|
|
5093
|
+
if (e instanceof NotFoundError) {
|
|
5094
|
+
} else {
|
|
5095
|
+
console.error(e.toString());
|
|
5096
|
+
if (verboseValue) {
|
|
5097
|
+
console.error("More error context below");
|
|
5098
|
+
console.error(e.message);
|
|
5099
|
+
console.error(e);
|
|
5100
|
+
}
|
|
5080
5101
|
}
|
|
5081
5102
|
});
|
|
5082
5103
|
}
|
|
@@ -5086,7 +5107,7 @@ var resolve = async ({
|
|
|
5086
5107
|
if (!silenceErrors) {
|
|
5087
5108
|
console.error(e);
|
|
5088
5109
|
}
|
|
5089
|
-
if (e instanceof
|
|
5110
|
+
if (e instanceof import_graphql5.GraphQLError) {
|
|
5090
5111
|
return {
|
|
5091
5112
|
errors: [e]
|
|
5092
5113
|
};
|
|
@@ -5098,7 +5119,7 @@ var resolve = async ({
|
|
|
5098
5119
|
|
|
5099
5120
|
// src/database/index.ts
|
|
5100
5121
|
var import_path4 = __toESM(require("path"));
|
|
5101
|
-
var
|
|
5122
|
+
var import_graphql6 = require("graphql");
|
|
5102
5123
|
var import_micromatch2 = __toESM(require("micromatch"));
|
|
5103
5124
|
var import_js_sha12 = __toESM(require("js-sha1"));
|
|
5104
5125
|
var createDatabase = (config) => {
|
|
@@ -5144,7 +5165,7 @@ var Database = class {
|
|
|
5144
5165
|
SUBLEVEL_OPTIONS
|
|
5145
5166
|
).get((0, import_schema_tools3.normalizePath)(filepath));
|
|
5146
5167
|
if (!contentObject) {
|
|
5147
|
-
throw new
|
|
5168
|
+
throw new NotFoundError(`Unable to find record ${filepath}`);
|
|
5148
5169
|
}
|
|
5149
5170
|
return transformDocument(
|
|
5150
5171
|
filepath,
|
|
@@ -5158,7 +5179,7 @@ var Database = class {
|
|
|
5158
5179
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5159
5180
|
const collection = await this.collectionForPath(filepath);
|
|
5160
5181
|
if (!collection) {
|
|
5161
|
-
throw new
|
|
5182
|
+
throw new import_graphql6.GraphQLError(`Unable to find collection for ${filepath}`);
|
|
5162
5183
|
}
|
|
5163
5184
|
const stringifiedFile = await this.stringifyFile(
|
|
5164
5185
|
filepath,
|
|
@@ -5174,7 +5195,7 @@ var Database = class {
|
|
|
5174
5195
|
try {
|
|
5175
5196
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5176
5197
|
} catch (e) {
|
|
5177
|
-
throw new
|
|
5198
|
+
throw new import_graphql6.GraphQLError(
|
|
5178
5199
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5179
5200
|
null,
|
|
5180
5201
|
null,
|
|
@@ -5256,13 +5277,13 @@ var Database = class {
|
|
|
5256
5277
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5257
5278
|
const collection = await this.collectionForPath(filepath);
|
|
5258
5279
|
if (!collection) {
|
|
5259
|
-
throw new
|
|
5280
|
+
throw new import_graphql6.GraphQLError(`Unable to find collection for ${filepath}.`);
|
|
5260
5281
|
}
|
|
5261
5282
|
if (((_a = collection.match) == null ? void 0 : _a.exclude) || ((_b = collection.match) == null ? void 0 : _b.include)) {
|
|
5262
5283
|
const matches = this.tinaSchema.getMatches({ collection });
|
|
5263
5284
|
const match = import_micromatch2.default.isMatch(filepath, matches);
|
|
5264
5285
|
if (!match) {
|
|
5265
|
-
throw new
|
|
5286
|
+
throw new import_graphql6.GraphQLError(
|
|
5266
5287
|
`File ${filepath} does not match collection ${collection.name} glob ${matches.join(
|
|
5267
5288
|
","
|
|
5268
5289
|
)}. Please change the filename or update matches for ${collection.name} in your config file.`
|
|
@@ -5280,7 +5301,7 @@ var Database = class {
|
|
|
5280
5301
|
try {
|
|
5281
5302
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5282
5303
|
} catch (e) {
|
|
5283
|
-
throw new
|
|
5304
|
+
throw new import_graphql6.GraphQLError(
|
|
5284
5305
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5285
5306
|
null,
|
|
5286
5307
|
null,
|
|
@@ -5351,7 +5372,7 @@ var Database = class {
|
|
|
5351
5372
|
}
|
|
5352
5373
|
return true;
|
|
5353
5374
|
} catch (error) {
|
|
5354
|
-
if (error instanceof
|
|
5375
|
+
if (error instanceof import_graphql6.GraphQLError) {
|
|
5355
5376
|
throw error;
|
|
5356
5377
|
}
|
|
5357
5378
|
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
@@ -5859,7 +5880,7 @@ var Database = class {
|
|
|
5859
5880
|
try {
|
|
5860
5881
|
await this.onDelete((0, import_schema_tools3.normalizePath)(filepath));
|
|
5861
5882
|
} catch (e) {
|
|
5862
|
-
throw new
|
|
5883
|
+
throw new import_graphql6.GraphQLError(
|
|
5863
5884
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
5864
5885
|
null,
|
|
5865
5886
|
null,
|
|
@@ -5925,7 +5946,7 @@ var Database = class {
|
|
|
5925
5946
|
this.level = this.rootLevel.sublevel(version, SUBLEVEL_OPTIONS);
|
|
5926
5947
|
}
|
|
5927
5948
|
if (!this.level) {
|
|
5928
|
-
throw new
|
|
5949
|
+
throw new import_graphql6.GraphQLError("Error initializing LevelDB instance");
|
|
5929
5950
|
}
|
|
5930
5951
|
}
|
|
5931
5952
|
async getTemplateDetailsForFile(collection, data) {
|
|
@@ -5987,7 +6008,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
5987
6008
|
const tinaSchema = await database.getSchema();
|
|
5988
6009
|
let templateInfo = null;
|
|
5989
6010
|
if (collection) {
|
|
5990
|
-
templateInfo =
|
|
6011
|
+
templateInfo = tinaSchema.getTemplatesForCollectable(collection);
|
|
5991
6012
|
}
|
|
5992
6013
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
5993
6014
|
await sequential(documentPaths, async (filepath) => {
|
|
@@ -6287,7 +6308,7 @@ var import_isomorphic_git2 = __toESM(require("isomorphic-git"));
|
|
|
6287
6308
|
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
6288
6309
|
var import_glob_parent = __toESM(require("glob-parent"));
|
|
6289
6310
|
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
6290
|
-
var
|
|
6311
|
+
var import_graphql7 = require("graphql");
|
|
6291
6312
|
var import_path7 = require("path");
|
|
6292
6313
|
var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
|
|
6293
6314
|
var toUint8Array = (buf) => {
|
|
@@ -6493,7 +6514,7 @@ var IsomorphicBridge = class {
|
|
|
6493
6514
|
fullname: true
|
|
6494
6515
|
});
|
|
6495
6516
|
if (!ref) {
|
|
6496
|
-
throw new
|
|
6517
|
+
throw new import_graphql7.GraphQLError(
|
|
6497
6518
|
`Unable to determine current branch from HEAD`,
|
|
6498
6519
|
null,
|
|
6499
6520
|
null,
|
|
@@ -6584,7 +6605,7 @@ var IsomorphicBridge = class {
|
|
|
6584
6605
|
await this.commitTree(updatedRootTreeOid, ref);
|
|
6585
6606
|
break;
|
|
6586
6607
|
} else {
|
|
6587
|
-
throw new
|
|
6608
|
+
throw new import_graphql7.GraphQLError(
|
|
6588
6609
|
`Unable to resolve path: ${filepath}`,
|
|
6589
6610
|
null,
|
|
6590
6611
|
null,
|
package/dist/index.mjs
CHANGED
|
@@ -1518,7 +1518,12 @@ var Builder = class {
|
|
|
1518
1518
|
[NAMER.createName([collection.name])]: "create",
|
|
1519
1519
|
[NAMER.updateName([collection.name])]: "update"
|
|
1520
1520
|
});
|
|
1521
|
-
return astBuilder.FieldDefinition({
|
|
1521
|
+
return astBuilder.FieldDefinition({
|
|
1522
|
+
type,
|
|
1523
|
+
name,
|
|
1524
|
+
args,
|
|
1525
|
+
required: true
|
|
1526
|
+
});
|
|
1522
1527
|
};
|
|
1523
1528
|
this.collectionFragment = async (collection) => {
|
|
1524
1529
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -2530,7 +2535,7 @@ var validateField = async (field) => {
|
|
|
2530
2535
|
// package.json
|
|
2531
2536
|
var package_default = {
|
|
2532
2537
|
name: "@tinacms/graphql",
|
|
2533
|
-
version: "1.4.
|
|
2538
|
+
version: "1.4.28",
|
|
2534
2539
|
main: "dist/index.js",
|
|
2535
2540
|
module: "dist/index.mjs",
|
|
2536
2541
|
typings: "dist/index.d.ts",
|
|
@@ -2802,7 +2807,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
2802
2807
|
};
|
|
2803
2808
|
|
|
2804
2809
|
// src/resolve.ts
|
|
2805
|
-
import { graphql, buildASTSchema, getNamedType, GraphQLError as
|
|
2810
|
+
import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError4 } from "graphql";
|
|
2806
2811
|
|
|
2807
2812
|
// src/resolver/index.ts
|
|
2808
2813
|
import path3 from "path";
|
|
@@ -3278,40 +3283,44 @@ ${$_body}`,
|
|
|
3278
3283
|
}
|
|
3279
3284
|
};
|
|
3280
3285
|
var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3286
|
+
try {
|
|
3287
|
+
switch (format) {
|
|
3288
|
+
case ".markdown":
|
|
3289
|
+
case ".mdx":
|
|
3290
|
+
case ".md":
|
|
3291
|
+
const contentJSON = matter(content || "", {
|
|
3292
|
+
language: markdownParseConfig?.frontmatterFormat ?? "yaml",
|
|
3293
|
+
delimiters: markdownParseConfig?.frontmatterDelimiters ?? "---",
|
|
3294
|
+
engines: matterEngines
|
|
3295
|
+
});
|
|
3296
|
+
const markdownData = {
|
|
3297
|
+
...contentJSON.data,
|
|
3298
|
+
$_body: contentJSON.content
|
|
3299
|
+
};
|
|
3300
|
+
assertShape(markdownData, yupSchema);
|
|
3301
|
+
return markdownData;
|
|
3302
|
+
case ".json":
|
|
3303
|
+
if (!content) {
|
|
3304
|
+
return {};
|
|
3305
|
+
}
|
|
3306
|
+
return JSON.parse(content);
|
|
3307
|
+
case ".toml":
|
|
3308
|
+
if (!content) {
|
|
3309
|
+
return {};
|
|
3310
|
+
}
|
|
3311
|
+
return toml.parse(content);
|
|
3312
|
+
case ".yaml":
|
|
3313
|
+
case ".yml":
|
|
3314
|
+
if (!content) {
|
|
3315
|
+
return {};
|
|
3316
|
+
}
|
|
3317
|
+
return yaml.safeLoad(content);
|
|
3318
|
+
}
|
|
3319
|
+
} catch (e) {
|
|
3320
|
+
console.error(e);
|
|
3321
|
+
throw e;
|
|
3314
3322
|
}
|
|
3323
|
+
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3315
3324
|
};
|
|
3316
3325
|
var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
3317
3326
|
const warnings = [];
|
|
@@ -3443,7 +3452,7 @@ var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo)
|
|
|
3443
3452
|
const template = getTemplateForFile(templateInfo, data);
|
|
3444
3453
|
if (!template) {
|
|
3445
3454
|
console.warn(
|
|
3446
|
-
`Document: ${filepath} has an ambiguous template, skipping from indexing
|
|
3455
|
+
`Document: ${filepath} has an ambiguous template, skipping from indexing. See https://tina.io/docs/errors/ambiguous-template/ for more info.`
|
|
3447
3456
|
);
|
|
3448
3457
|
return;
|
|
3449
3458
|
}
|
|
@@ -4792,6 +4801,15 @@ var resolveDateInput = (value) => {
|
|
|
4792
4801
|
return date;
|
|
4793
4802
|
};
|
|
4794
4803
|
|
|
4804
|
+
// src/error.ts
|
|
4805
|
+
import { GraphQLError as GraphQLError3 } from "graphql";
|
|
4806
|
+
var NotFoundError = class extends GraphQLError3 {
|
|
4807
|
+
constructor(message, nodes, source, positions, path7, originalError, extensions) {
|
|
4808
|
+
super(message, nodes, source, positions, path7, originalError, extensions);
|
|
4809
|
+
this.name = "NotFoundError";
|
|
4810
|
+
}
|
|
4811
|
+
};
|
|
4812
|
+
|
|
4795
4813
|
// src/resolve.ts
|
|
4796
4814
|
var resolve = async ({
|
|
4797
4815
|
config,
|
|
@@ -4806,7 +4824,7 @@ var resolve = async ({
|
|
|
4806
4824
|
const verboseValue = verbose ?? true;
|
|
4807
4825
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
4808
4826
|
if (!graphQLSchemaAst) {
|
|
4809
|
-
throw new
|
|
4827
|
+
throw new GraphQLError4(`GraphQL schema not found`);
|
|
4810
4828
|
}
|
|
4811
4829
|
const graphQLSchema = buildASTSchema(graphQLSchemaAst);
|
|
4812
4830
|
const tinaConfig = await database.getTinaSchema();
|
|
@@ -5002,11 +5020,14 @@ var resolve = async ({
|
|
|
5002
5020
|
if (res.errors) {
|
|
5003
5021
|
if (!silenceErrors) {
|
|
5004
5022
|
res.errors.map((e) => {
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
console.error(
|
|
5008
|
-
|
|
5009
|
-
|
|
5023
|
+
if (e instanceof NotFoundError) {
|
|
5024
|
+
} else {
|
|
5025
|
+
console.error(e.toString());
|
|
5026
|
+
if (verboseValue) {
|
|
5027
|
+
console.error("More error context below");
|
|
5028
|
+
console.error(e.message);
|
|
5029
|
+
console.error(e);
|
|
5030
|
+
}
|
|
5010
5031
|
}
|
|
5011
5032
|
});
|
|
5012
5033
|
}
|
|
@@ -5016,7 +5037,7 @@ var resolve = async ({
|
|
|
5016
5037
|
if (!silenceErrors) {
|
|
5017
5038
|
console.error(e);
|
|
5018
5039
|
}
|
|
5019
|
-
if (e instanceof
|
|
5040
|
+
if (e instanceof GraphQLError4) {
|
|
5020
5041
|
return {
|
|
5021
5042
|
errors: [e]
|
|
5022
5043
|
};
|
|
@@ -5028,7 +5049,7 @@ var resolve = async ({
|
|
|
5028
5049
|
|
|
5029
5050
|
// src/database/index.ts
|
|
5030
5051
|
import path4 from "path";
|
|
5031
|
-
import { GraphQLError as
|
|
5052
|
+
import { GraphQLError as GraphQLError5 } from "graphql";
|
|
5032
5053
|
import micromatch2 from "micromatch";
|
|
5033
5054
|
import sha2 from "js-sha1";
|
|
5034
5055
|
var createDatabase = (config) => {
|
|
@@ -5074,7 +5095,7 @@ var Database = class {
|
|
|
5074
5095
|
SUBLEVEL_OPTIONS
|
|
5075
5096
|
).get(normalizePath(filepath));
|
|
5076
5097
|
if (!contentObject) {
|
|
5077
|
-
throw new
|
|
5098
|
+
throw new NotFoundError(`Unable to find record ${filepath}`);
|
|
5078
5099
|
}
|
|
5079
5100
|
return transformDocument(
|
|
5080
5101
|
filepath,
|
|
@@ -5088,7 +5109,7 @@ var Database = class {
|
|
|
5088
5109
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5089
5110
|
const collection = await this.collectionForPath(filepath);
|
|
5090
5111
|
if (!collection) {
|
|
5091
|
-
throw new
|
|
5112
|
+
throw new GraphQLError5(`Unable to find collection for ${filepath}`);
|
|
5092
5113
|
}
|
|
5093
5114
|
const stringifiedFile = await this.stringifyFile(
|
|
5094
5115
|
filepath,
|
|
@@ -5104,7 +5125,7 @@ var Database = class {
|
|
|
5104
5125
|
try {
|
|
5105
5126
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5106
5127
|
} catch (e) {
|
|
5107
|
-
throw new
|
|
5128
|
+
throw new GraphQLError5(
|
|
5108
5129
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5109
5130
|
null,
|
|
5110
5131
|
null,
|
|
@@ -5185,13 +5206,13 @@ var Database = class {
|
|
|
5185
5206
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5186
5207
|
const collection = await this.collectionForPath(filepath);
|
|
5187
5208
|
if (!collection) {
|
|
5188
|
-
throw new
|
|
5209
|
+
throw new GraphQLError5(`Unable to find collection for ${filepath}.`);
|
|
5189
5210
|
}
|
|
5190
5211
|
if (collection.match?.exclude || collection.match?.include) {
|
|
5191
5212
|
const matches = this.tinaSchema.getMatches({ collection });
|
|
5192
5213
|
const match = micromatch2.isMatch(filepath, matches);
|
|
5193
5214
|
if (!match) {
|
|
5194
|
-
throw new
|
|
5215
|
+
throw new GraphQLError5(
|
|
5195
5216
|
`File ${filepath} does not match collection ${collection.name} glob ${matches.join(
|
|
5196
5217
|
","
|
|
5197
5218
|
)}. Please change the filename or update matches for ${collection.name} in your config file.`
|
|
@@ -5209,7 +5230,7 @@ var Database = class {
|
|
|
5209
5230
|
try {
|
|
5210
5231
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5211
5232
|
} catch (e) {
|
|
5212
|
-
throw new
|
|
5233
|
+
throw new GraphQLError5(
|
|
5213
5234
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5214
5235
|
null,
|
|
5215
5236
|
null,
|
|
@@ -5280,7 +5301,7 @@ var Database = class {
|
|
|
5280
5301
|
}
|
|
5281
5302
|
return true;
|
|
5282
5303
|
} catch (error) {
|
|
5283
|
-
if (error instanceof
|
|
5304
|
+
if (error instanceof GraphQLError5) {
|
|
5284
5305
|
throw error;
|
|
5285
5306
|
}
|
|
5286
5307
|
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
@@ -5787,7 +5808,7 @@ var Database = class {
|
|
|
5787
5808
|
try {
|
|
5788
5809
|
await this.onDelete(normalizePath(filepath));
|
|
5789
5810
|
} catch (e) {
|
|
5790
|
-
throw new
|
|
5811
|
+
throw new GraphQLError5(
|
|
5791
5812
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
5792
5813
|
null,
|
|
5793
5814
|
null,
|
|
@@ -5853,7 +5874,7 @@ var Database = class {
|
|
|
5853
5874
|
this.level = this.rootLevel.sublevel(version, SUBLEVEL_OPTIONS);
|
|
5854
5875
|
}
|
|
5855
5876
|
if (!this.level) {
|
|
5856
|
-
throw new
|
|
5877
|
+
throw new GraphQLError5("Error initializing LevelDB instance");
|
|
5857
5878
|
}
|
|
5858
5879
|
}
|
|
5859
5880
|
async getTemplateDetailsForFile(collection, data) {
|
|
@@ -5915,7 +5936,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
5915
5936
|
const tinaSchema = await database.getSchema();
|
|
5916
5937
|
let templateInfo = null;
|
|
5917
5938
|
if (collection) {
|
|
5918
|
-
templateInfo =
|
|
5939
|
+
templateInfo = tinaSchema.getTemplatesForCollectable(collection);
|
|
5919
5940
|
}
|
|
5920
5941
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
5921
5942
|
await sequential(documentPaths, async (filepath) => {
|
|
@@ -6215,7 +6236,7 @@ import git2 from "isomorphic-git";
|
|
|
6215
6236
|
import fs3 from "fs-extra";
|
|
6216
6237
|
import globParent from "glob-parent";
|
|
6217
6238
|
import normalize2 from "normalize-path";
|
|
6218
|
-
import { GraphQLError as
|
|
6239
|
+
import { GraphQLError as GraphQLError6 } from "graphql";
|
|
6219
6240
|
import { dirname } from "path";
|
|
6220
6241
|
var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
|
|
6221
6242
|
var toUint8Array = (buf) => {
|
|
@@ -6421,7 +6442,7 @@ var IsomorphicBridge = class {
|
|
|
6421
6442
|
fullname: true
|
|
6422
6443
|
});
|
|
6423
6444
|
if (!ref) {
|
|
6424
|
-
throw new
|
|
6445
|
+
throw new GraphQLError6(
|
|
6425
6446
|
`Unable to determine current branch from HEAD`,
|
|
6426
6447
|
null,
|
|
6427
6448
|
null,
|
|
@@ -6512,7 +6533,7 @@ var IsomorphicBridge = class {
|
|
|
6512
6533
|
await this.commitTree(updatedRootTreeOid, ref);
|
|
6513
6534
|
break;
|
|
6514
6535
|
} else {
|
|
6515
|
-
throw new
|
|
6536
|
+
throw new GraphQLError6(
|
|
6516
6537
|
`Unable to resolve path: ${filepath}`,
|
|
6517
6538
|
null,
|
|
6518
6539
|
null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.28",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@iarna/toml": "^2.2.5",
|
|
27
|
-
"@tinacms/mdx": "1.3.
|
|
28
|
-
"@tinacms/schema-tools": "1.4.
|
|
27
|
+
"@tinacms/mdx": "1.3.21",
|
|
28
|
+
"@tinacms/schema-tools": "1.4.13",
|
|
29
29
|
"abstract-level": "^1.0.3",
|
|
30
30
|
"body-parser": "^1.19.0",
|
|
31
31
|
"cors": "^2.8.5",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"directory": "packages/tina-graphql"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tinacms/schema-tools": "1.4.
|
|
60
|
+
"@tinacms/schema-tools": "1.4.13",
|
|
61
61
|
"@tinacms/scripts": "1.1.2",
|
|
62
62
|
"@types/cors": "^2.8.7",
|
|
63
63
|
"@types/estree": "^0.0.50",
|