@tinacms/graphql 0.60.5 → 0.60.8
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/CHANGELOG.md +32 -0
- package/dist/ast-builder/index.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +573 -212
- package/dist/mdx/parse.d.ts +5 -4
- package/dist/mdx/stringify.d.ts +4 -3
- package/dist/resolve.d.ts +2 -1
- package/dist/resolver/error.d.ts +30 -1
- package/dist/resolver/media-utils.d.ts +30 -0
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -10384,9 +10384,14 @@ var require_remark_mdx = __commonJS({
|
|
|
10384
10384
|
|
|
10385
10385
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
10386
10386
|
__export(exports, {
|
|
10387
|
+
TinaFetchError: () => TinaFetchError,
|
|
10388
|
+
TinaGraphQLError: () => TinaGraphQLError,
|
|
10389
|
+
TinaParseDocumentError: () => TinaParseDocumentError,
|
|
10390
|
+
TinaQueryError: () => TinaQueryError,
|
|
10387
10391
|
assertShape: () => assertShape,
|
|
10388
10392
|
buildSchema: () => buildSchema,
|
|
10389
10393
|
createDatabase: () => createDatabase,
|
|
10394
|
+
handleFetchErrorError: () => handleFetchErrorError,
|
|
10390
10395
|
indexDB: () => indexDB,
|
|
10391
10396
|
parseFile: () => parseFile,
|
|
10392
10397
|
resolve: () => resolve,
|
|
@@ -10954,8 +10959,208 @@ var astBuilder = {
|
|
|
10954
10959
|
},
|
|
10955
10960
|
ListQueryOperationDefinition: ({
|
|
10956
10961
|
queryName,
|
|
10957
|
-
fragName
|
|
10962
|
+
fragName,
|
|
10963
|
+
filterType,
|
|
10964
|
+
dataLayer
|
|
10958
10965
|
}) => {
|
|
10966
|
+
const variableDefinitions = [
|
|
10967
|
+
{
|
|
10968
|
+
kind: "VariableDefinition",
|
|
10969
|
+
variable: {
|
|
10970
|
+
kind: "Variable",
|
|
10971
|
+
name: {
|
|
10972
|
+
kind: "Name",
|
|
10973
|
+
value: "before"
|
|
10974
|
+
}
|
|
10975
|
+
},
|
|
10976
|
+
type: {
|
|
10977
|
+
kind: "NamedType",
|
|
10978
|
+
name: {
|
|
10979
|
+
kind: "Name",
|
|
10980
|
+
value: "String"
|
|
10981
|
+
}
|
|
10982
|
+
},
|
|
10983
|
+
directives: []
|
|
10984
|
+
},
|
|
10985
|
+
{
|
|
10986
|
+
kind: "VariableDefinition",
|
|
10987
|
+
variable: {
|
|
10988
|
+
kind: "Variable",
|
|
10989
|
+
name: {
|
|
10990
|
+
kind: "Name",
|
|
10991
|
+
value: "after"
|
|
10992
|
+
}
|
|
10993
|
+
},
|
|
10994
|
+
type: {
|
|
10995
|
+
kind: "NamedType",
|
|
10996
|
+
name: {
|
|
10997
|
+
kind: "Name",
|
|
10998
|
+
value: "String"
|
|
10999
|
+
}
|
|
11000
|
+
},
|
|
11001
|
+
directives: []
|
|
11002
|
+
},
|
|
11003
|
+
{
|
|
11004
|
+
kind: "VariableDefinition",
|
|
11005
|
+
variable: {
|
|
11006
|
+
kind: "Variable",
|
|
11007
|
+
name: {
|
|
11008
|
+
kind: "Name",
|
|
11009
|
+
value: "first"
|
|
11010
|
+
}
|
|
11011
|
+
},
|
|
11012
|
+
type: {
|
|
11013
|
+
kind: "NamedType",
|
|
11014
|
+
name: {
|
|
11015
|
+
kind: "Name",
|
|
11016
|
+
value: "Float"
|
|
11017
|
+
}
|
|
11018
|
+
},
|
|
11019
|
+
directives: []
|
|
11020
|
+
},
|
|
11021
|
+
{
|
|
11022
|
+
kind: "VariableDefinition",
|
|
11023
|
+
variable: {
|
|
11024
|
+
kind: "Variable",
|
|
11025
|
+
name: {
|
|
11026
|
+
kind: "Name",
|
|
11027
|
+
value: "last"
|
|
11028
|
+
}
|
|
11029
|
+
},
|
|
11030
|
+
type: {
|
|
11031
|
+
kind: "NamedType",
|
|
11032
|
+
name: {
|
|
11033
|
+
kind: "Name",
|
|
11034
|
+
value: "Float"
|
|
11035
|
+
}
|
|
11036
|
+
},
|
|
11037
|
+
directives: []
|
|
11038
|
+
},
|
|
11039
|
+
{
|
|
11040
|
+
kind: "VariableDefinition",
|
|
11041
|
+
variable: {
|
|
11042
|
+
kind: "Variable",
|
|
11043
|
+
name: {
|
|
11044
|
+
kind: "Name",
|
|
11045
|
+
value: "sort"
|
|
11046
|
+
}
|
|
11047
|
+
},
|
|
11048
|
+
type: {
|
|
11049
|
+
kind: "NamedType",
|
|
11050
|
+
name: {
|
|
11051
|
+
kind: "Name",
|
|
11052
|
+
value: "String"
|
|
11053
|
+
}
|
|
11054
|
+
},
|
|
11055
|
+
directives: []
|
|
11056
|
+
}
|
|
11057
|
+
];
|
|
11058
|
+
const queryArguments = [
|
|
11059
|
+
{
|
|
11060
|
+
kind: "Argument",
|
|
11061
|
+
name: {
|
|
11062
|
+
kind: "Name",
|
|
11063
|
+
value: "before"
|
|
11064
|
+
},
|
|
11065
|
+
value: {
|
|
11066
|
+
kind: "Variable",
|
|
11067
|
+
name: {
|
|
11068
|
+
kind: "Name",
|
|
11069
|
+
value: "before"
|
|
11070
|
+
}
|
|
11071
|
+
}
|
|
11072
|
+
},
|
|
11073
|
+
{
|
|
11074
|
+
kind: "Argument",
|
|
11075
|
+
name: {
|
|
11076
|
+
kind: "Name",
|
|
11077
|
+
value: "after"
|
|
11078
|
+
},
|
|
11079
|
+
value: {
|
|
11080
|
+
kind: "Variable",
|
|
11081
|
+
name: {
|
|
11082
|
+
kind: "Name",
|
|
11083
|
+
value: "after"
|
|
11084
|
+
}
|
|
11085
|
+
}
|
|
11086
|
+
},
|
|
11087
|
+
{
|
|
11088
|
+
kind: "Argument",
|
|
11089
|
+
name: {
|
|
11090
|
+
kind: "Name",
|
|
11091
|
+
value: "first"
|
|
11092
|
+
},
|
|
11093
|
+
value: {
|
|
11094
|
+
kind: "Variable",
|
|
11095
|
+
name: {
|
|
11096
|
+
kind: "Name",
|
|
11097
|
+
value: "first"
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
},
|
|
11101
|
+
{
|
|
11102
|
+
kind: "Argument",
|
|
11103
|
+
name: {
|
|
11104
|
+
kind: "Name",
|
|
11105
|
+
value: "last"
|
|
11106
|
+
},
|
|
11107
|
+
value: {
|
|
11108
|
+
kind: "Variable",
|
|
11109
|
+
name: {
|
|
11110
|
+
kind: "Name",
|
|
11111
|
+
value: "last"
|
|
11112
|
+
}
|
|
11113
|
+
}
|
|
11114
|
+
},
|
|
11115
|
+
{
|
|
11116
|
+
kind: "Argument",
|
|
11117
|
+
name: {
|
|
11118
|
+
kind: "Name",
|
|
11119
|
+
value: "sort"
|
|
11120
|
+
},
|
|
11121
|
+
value: {
|
|
11122
|
+
kind: "Variable",
|
|
11123
|
+
name: {
|
|
11124
|
+
kind: "Name",
|
|
11125
|
+
value: "sort"
|
|
11126
|
+
}
|
|
11127
|
+
}
|
|
11128
|
+
}
|
|
11129
|
+
];
|
|
11130
|
+
if (dataLayer) {
|
|
11131
|
+
queryArguments.push({
|
|
11132
|
+
kind: "Argument",
|
|
11133
|
+
name: {
|
|
11134
|
+
kind: "Name",
|
|
11135
|
+
value: "filter"
|
|
11136
|
+
},
|
|
11137
|
+
value: {
|
|
11138
|
+
kind: "Variable",
|
|
11139
|
+
name: {
|
|
11140
|
+
kind: "Name",
|
|
11141
|
+
value: "filter"
|
|
11142
|
+
}
|
|
11143
|
+
}
|
|
11144
|
+
});
|
|
11145
|
+
variableDefinitions.push({
|
|
11146
|
+
kind: "VariableDefinition",
|
|
11147
|
+
variable: {
|
|
11148
|
+
kind: "Variable",
|
|
11149
|
+
name: {
|
|
11150
|
+
kind: "Name",
|
|
11151
|
+
value: "filter"
|
|
11152
|
+
}
|
|
11153
|
+
},
|
|
11154
|
+
type: {
|
|
11155
|
+
kind: "NamedType",
|
|
11156
|
+
name: {
|
|
11157
|
+
kind: "Name",
|
|
11158
|
+
value: filterType
|
|
11159
|
+
}
|
|
11160
|
+
},
|
|
11161
|
+
directives: []
|
|
11162
|
+
});
|
|
11163
|
+
}
|
|
10959
11164
|
return {
|
|
10960
11165
|
kind: "OperationDefinition",
|
|
10961
11166
|
operation: "query",
|
|
@@ -10963,7 +11168,7 @@ var astBuilder = {
|
|
|
10963
11168
|
kind: "Name",
|
|
10964
11169
|
value: queryName
|
|
10965
11170
|
},
|
|
10966
|
-
variableDefinitions
|
|
11171
|
+
variableDefinitions,
|
|
10967
11172
|
directives: [],
|
|
10968
11173
|
selectionSet: {
|
|
10969
11174
|
kind: "SelectionSet",
|
|
@@ -10974,7 +11179,7 @@ var astBuilder = {
|
|
|
10974
11179
|
kind: "Name",
|
|
10975
11180
|
value: queryName
|
|
10976
11181
|
},
|
|
10977
|
-
arguments:
|
|
11182
|
+
arguments: queryArguments,
|
|
10978
11183
|
directives: [],
|
|
10979
11184
|
selectionSet: {
|
|
10980
11185
|
kind: "SelectionSet",
|
|
@@ -12375,6 +12580,7 @@ var filterSelections = (arr) => {
|
|
|
12375
12580
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/validate.ts
|
|
12376
12581
|
var import_lodash2 = __toModule(require("lodash"));
|
|
12377
12582
|
var yup2 = __toModule(require("yup"));
|
|
12583
|
+
var import_schema_tools = __toModule(require("@tinacms/schema-tools"));
|
|
12378
12584
|
var FIELD_TYPES = [
|
|
12379
12585
|
"string",
|
|
12380
12586
|
"number",
|
|
@@ -12389,6 +12595,13 @@ var validateSchema = async (schema) => {
|
|
|
12389
12595
|
const schema2 = addNamespaceToSchema(import_lodash2.default.cloneDeep(schema));
|
|
12390
12596
|
const collections = await sequential(schema2.collections, async (collection) => validateCollection(collection));
|
|
12391
12597
|
validationCollectionsPathAndMatch(collections);
|
|
12598
|
+
if (schema2.config) {
|
|
12599
|
+
const config = (0, import_schema_tools.validateTinaCloudSchemaConfig)(schema2.config);
|
|
12600
|
+
return {
|
|
12601
|
+
collections,
|
|
12602
|
+
config
|
|
12603
|
+
};
|
|
12604
|
+
}
|
|
12392
12605
|
return {
|
|
12393
12606
|
collections
|
|
12394
12607
|
};
|
|
@@ -12480,7 +12693,7 @@ var validateField = async (field) => {
|
|
|
12480
12693
|
|
|
12481
12694
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12482
12695
|
var name = "@tinacms/graphql";
|
|
12483
|
-
var version = "0.60.
|
|
12696
|
+
var version = "0.60.8";
|
|
12484
12697
|
var main = "dist/index.js";
|
|
12485
12698
|
var typings = "dist/index.d.ts";
|
|
12486
12699
|
var files = [
|
|
@@ -12528,6 +12741,7 @@ var scripts = {
|
|
|
12528
12741
|
var dependencies = {
|
|
12529
12742
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
12530
12743
|
"@tinacms/datalayer": "workspace:*",
|
|
12744
|
+
"@tinacms/schema-tools": "workspace:*",
|
|
12531
12745
|
"body-parser": "^1.19.0",
|
|
12532
12746
|
cors: "^2.8.5",
|
|
12533
12747
|
dataloader: "^2.0.0",
|
|
@@ -12602,9 +12816,6 @@ var devDependencies = {
|
|
|
12602
12816
|
nodemon: "^2.0.4",
|
|
12603
12817
|
typescript: "^4.3.5"
|
|
12604
12818
|
};
|
|
12605
|
-
var peerDependencies = {
|
|
12606
|
-
"@tinacms/schema-tools": "*"
|
|
12607
|
-
};
|
|
12608
12819
|
var package_default = {
|
|
12609
12820
|
name,
|
|
12610
12821
|
version,
|
|
@@ -12617,20 +12828,56 @@ var package_default = {
|
|
|
12617
12828
|
dependencies,
|
|
12618
12829
|
publishConfig,
|
|
12619
12830
|
repository,
|
|
12620
|
-
devDependencies
|
|
12621
|
-
peerDependencies
|
|
12831
|
+
devDependencies
|
|
12622
12832
|
};
|
|
12623
12833
|
|
|
12624
12834
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
|
|
12625
|
-
var
|
|
12835
|
+
var TinaGraphQLError = class extends Error {
|
|
12626
12836
|
constructor(message, extensions) {
|
|
12627
12837
|
super(message);
|
|
12628
12838
|
if (!this.name) {
|
|
12629
|
-
Object.defineProperty(this, "name", { value: "
|
|
12839
|
+
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
12630
12840
|
}
|
|
12631
12841
|
this.extensions = __spreadValues({}, extensions);
|
|
12632
12842
|
}
|
|
12633
12843
|
};
|
|
12844
|
+
var TinaFetchError = class extends Error {
|
|
12845
|
+
constructor(message, args) {
|
|
12846
|
+
super(message);
|
|
12847
|
+
this.name = "TinaFetchError";
|
|
12848
|
+
this.collection = args.collection;
|
|
12849
|
+
this.stack = args.stack;
|
|
12850
|
+
this.file = args.file;
|
|
12851
|
+
this.originalError = args.originalError;
|
|
12852
|
+
}
|
|
12853
|
+
};
|
|
12854
|
+
var TinaQueryError = class extends TinaFetchError {
|
|
12855
|
+
constructor(args) {
|
|
12856
|
+
super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
|
|
12857
|
+
}
|
|
12858
|
+
};
|
|
12859
|
+
var TinaParseDocumentError = class extends TinaFetchError {
|
|
12860
|
+
constructor(args) {
|
|
12861
|
+
super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
|
|
12862
|
+
}
|
|
12863
|
+
toString() {
|
|
12864
|
+
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
12865
|
+
}
|
|
12866
|
+
};
|
|
12867
|
+
var handleFetchErrorError = (e, verbose) => {
|
|
12868
|
+
if (e instanceof Error) {
|
|
12869
|
+
if (e instanceof TinaFetchError) {
|
|
12870
|
+
if (verbose) {
|
|
12871
|
+
console.log(e.toString());
|
|
12872
|
+
console.log(e);
|
|
12873
|
+
console.log(e.stack);
|
|
12874
|
+
}
|
|
12875
|
+
}
|
|
12876
|
+
} else {
|
|
12877
|
+
console.error(e);
|
|
12878
|
+
}
|
|
12879
|
+
throw e;
|
|
12880
|
+
};
|
|
12634
12881
|
|
|
12635
12882
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
|
|
12636
12883
|
var createSchema = async ({
|
|
@@ -12743,7 +12990,7 @@ var TinaSchema = class {
|
|
|
12743
12990
|
assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
|
|
12744
12991
|
const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
|
|
12745
12992
|
if (!template) {
|
|
12746
|
-
throw new
|
|
12993
|
+
throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
|
|
12747
12994
|
collection: lastItem(collection.namespace),
|
|
12748
12995
|
possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
|
|
12749
12996
|
data
|
|
@@ -12850,13 +13097,17 @@ var _buildQueries = async (builder, tinaSchema, rootPath) => {
|
|
|
12850
13097
|
const operationsDefinitions = [];
|
|
12851
13098
|
const collections = tinaSchema.getCollections();
|
|
12852
13099
|
await sequential(collections, async (collection) => {
|
|
13100
|
+
var _a, _b, _c;
|
|
12853
13101
|
const queryName = NAMER.queryName(collection.namespace);
|
|
12854
13102
|
const queryListName = NAMER.generateQueryListName(collection.namespace);
|
|
13103
|
+
const queryFilterTypeName = NAMER.dataFilterTypeName(collection.namespace);
|
|
12855
13104
|
const fragName = NAMER.fragmentName(collection.namespace);
|
|
12856
13105
|
operationsDefinitions.push(astBuilder.QueryOperationDefinition({ fragName, queryName }));
|
|
12857
13106
|
operationsDefinitions.push(astBuilder.ListQueryOperationDefinition({
|
|
12858
13107
|
fragName,
|
|
12859
|
-
queryName: queryListName
|
|
13108
|
+
queryName: queryListName,
|
|
13109
|
+
filterType: queryFilterTypeName,
|
|
13110
|
+
dataLayer: Boolean((_c = (_b = (_a = tinaSchema.config) == null ? void 0 : _a.meta) == null ? void 0 : _b.flags) == null ? void 0 : _c.find((x) => x === "experimentalData"))
|
|
12860
13111
|
}));
|
|
12861
13112
|
});
|
|
12862
13113
|
const queryDoc = {
|
|
@@ -20222,11 +20473,62 @@ var visit = function(tree, test, visitor, reverse) {
|
|
|
20222
20473
|
|
|
20223
20474
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20224
20475
|
var import_lodash4 = __toModule(require("lodash"));
|
|
20225
|
-
|
|
20476
|
+
|
|
20477
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/media-utils.ts
|
|
20478
|
+
var resolveMediaCloudToRelative = (value, config = { useRelativeMedia: true }, schema) => {
|
|
20479
|
+
if (config && value) {
|
|
20480
|
+
if (config.useRelativeMedia === true) {
|
|
20481
|
+
return value;
|
|
20482
|
+
}
|
|
20483
|
+
if (hasTinaMediaConfig(schema) === true) {
|
|
20484
|
+
const assetsURL = `https://${config.assetsHost}/${config.clientId}`;
|
|
20485
|
+
if (typeof value === "string" && value.includes(assetsURL)) {
|
|
20486
|
+
const cleanSyncFolder = cleanUpSlashes(schema.config.media.tina.syncFolder);
|
|
20487
|
+
const strippedURL = value.replace(assetsURL, "");
|
|
20488
|
+
return `${cleanSyncFolder}${strippedURL}`;
|
|
20489
|
+
}
|
|
20490
|
+
return value;
|
|
20491
|
+
}
|
|
20492
|
+
return value;
|
|
20493
|
+
} else {
|
|
20494
|
+
return value;
|
|
20495
|
+
}
|
|
20496
|
+
};
|
|
20497
|
+
var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, schema) => {
|
|
20498
|
+
if (config && value) {
|
|
20499
|
+
if (config.useRelativeMedia === true) {
|
|
20500
|
+
return value;
|
|
20501
|
+
}
|
|
20502
|
+
if (hasTinaMediaConfig(schema) === true) {
|
|
20503
|
+
const cleanSyncFolder = cleanUpSlashes(schema.config.media.tina.syncFolder);
|
|
20504
|
+
const strippedValue = value.replace(cleanSyncFolder, "");
|
|
20505
|
+
return `https://${config.assetsHost}/${config.clientId}${strippedValue}`;
|
|
20506
|
+
}
|
|
20507
|
+
return value;
|
|
20508
|
+
} else {
|
|
20509
|
+
return value;
|
|
20510
|
+
}
|
|
20511
|
+
};
|
|
20512
|
+
var cleanUpSlashes = (path6) => {
|
|
20513
|
+
if (path6) {
|
|
20514
|
+
return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
|
|
20515
|
+
}
|
|
20516
|
+
return "";
|
|
20517
|
+
};
|
|
20518
|
+
var hasTinaMediaConfig = (schema) => {
|
|
20519
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20520
|
+
if (((_c = (_b = (_a = schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina) == null ? void 0 : _c.publicFolder) && ((_f = (_e = (_d = schema.config) == null ? void 0 : _d.media) == null ? void 0 : _e.tina) == null ? void 0 : _f.syncFolder)) {
|
|
20521
|
+
return true;
|
|
20522
|
+
}
|
|
20523
|
+
return false;
|
|
20524
|
+
};
|
|
20525
|
+
|
|
20526
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/parse.ts
|
|
20527
|
+
var parseMDX = (value, field, graphQLconfig, schema) => {
|
|
20226
20528
|
const tree = unified().use(remark_parse_default).use(import_remark_mdx.default).parse(value);
|
|
20227
|
-
return parseMDXInner(tree, field);
|
|
20529
|
+
return parseMDXInner(tree, field, graphQLconfig, schema);
|
|
20228
20530
|
};
|
|
20229
|
-
var parseMDXInner = (tree, field) => {
|
|
20531
|
+
var parseMDXInner = (tree, field, graphQLconfig, schema) => {
|
|
20230
20532
|
visit(tree, (node) => {
|
|
20231
20533
|
delete node.position;
|
|
20232
20534
|
});
|
|
@@ -20234,7 +20536,7 @@ var parseMDXInner = (tree, field) => {
|
|
|
20234
20536
|
var _a;
|
|
20235
20537
|
let props = {};
|
|
20236
20538
|
if (!node.name) {
|
|
20237
|
-
props = parseMDXInner({ type: "root", children: node.children }, field);
|
|
20539
|
+
props = parseMDXInner({ type: "root", children: node.children }, field, graphQLconfig, schema);
|
|
20238
20540
|
}
|
|
20239
20541
|
const template = (_a = field.templates) == null ? void 0 : _a.find((template2) => {
|
|
20240
20542
|
const templateName = typeof template2 === "string" ? template2 : template2.name;
|
|
@@ -20265,7 +20567,7 @@ var parseMDXInner = (tree, field) => {
|
|
|
20265
20567
|
if (!field2) {
|
|
20266
20568
|
throw new Error(`Unknown property '${attribute.name}' for embedded structure '${node.name}'`);
|
|
20267
20569
|
}
|
|
20268
|
-
parseField(attribute, field2, props);
|
|
20570
|
+
parseField(attribute, field2, props, graphQLconfig, schema);
|
|
20269
20571
|
}
|
|
20270
20572
|
} else {
|
|
20271
20573
|
console.log(`Not sure what this is, type: ${attribute.type}`);
|
|
@@ -20274,15 +20576,19 @@ var parseMDXInner = (tree, field) => {
|
|
|
20274
20576
|
delete node.attributes;
|
|
20275
20577
|
node.props = props;
|
|
20276
20578
|
});
|
|
20277
|
-
const slateTree = tree.children.map(remarkToSlate);
|
|
20579
|
+
const slateTree = tree.children.map((node) => remarkToSlate(node, graphQLconfig, schema));
|
|
20278
20580
|
return { type: "root", children: slateTree };
|
|
20279
20581
|
};
|
|
20280
|
-
var parseField = (attribute, field, props) => {
|
|
20582
|
+
var parseField = (attribute, field, props, graphQLconfig, schema) => {
|
|
20281
20583
|
var _a, _b;
|
|
20282
20584
|
switch (field.type) {
|
|
20283
20585
|
case "boolean":
|
|
20284
20586
|
case "datetime":
|
|
20587
|
+
props[field.name] = attribute.value;
|
|
20588
|
+
break;
|
|
20285
20589
|
case "image":
|
|
20590
|
+
props[field.name] = resolveMediaRelativeToCloud(attribute.value, graphQLconfig, schema);
|
|
20591
|
+
break;
|
|
20286
20592
|
case "number":
|
|
20287
20593
|
case "string":
|
|
20288
20594
|
if (field.list) {
|
|
@@ -20344,7 +20650,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20344
20650
|
throw new Error(`Global fields not supported at this time`);
|
|
20345
20651
|
}
|
|
20346
20652
|
field.fields.forEach((field2) => {
|
|
20347
|
-
parseField(property, field2, objectProps);
|
|
20653
|
+
parseField(property, field2, objectProps, graphQLconfig, schema);
|
|
20348
20654
|
});
|
|
20349
20655
|
}
|
|
20350
20656
|
});
|
|
@@ -20366,7 +20672,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20366
20672
|
throw new Error(`Global fields not supported at this time`);
|
|
20367
20673
|
}
|
|
20368
20674
|
field.fields.forEach((field2) => {
|
|
20369
|
-
parseField(property, field2, objectProps);
|
|
20675
|
+
parseField(property, field2, objectProps, graphQLconfig, schema);
|
|
20370
20676
|
});
|
|
20371
20677
|
}
|
|
20372
20678
|
if (field.templates) {
|
|
@@ -20375,7 +20681,7 @@ var parseField = (attribute, field, props) => {
|
|
|
20375
20681
|
throw new Error(`Global fields not supported at this time`);
|
|
20376
20682
|
}
|
|
20377
20683
|
fieldTemplate.fields.forEach((field2) => {
|
|
20378
|
-
parseField(property, field2, objectProps);
|
|
20684
|
+
parseField(property, field2, objectProps, graphQLconfig, schema);
|
|
20379
20685
|
});
|
|
20380
20686
|
});
|
|
20381
20687
|
}
|
|
@@ -20398,13 +20704,13 @@ var parseField = (attribute, field, props) => {
|
|
|
20398
20704
|
if (attribute.value) {
|
|
20399
20705
|
if (field.name === "children") {
|
|
20400
20706
|
if (Array.isArray(attribute.value)) {
|
|
20401
|
-
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field);
|
|
20707
|
+
props[field.name] = parseMDXInner({ type: "root", children: attribute.value }, field, graphQLconfig, schema);
|
|
20402
20708
|
} else {
|
|
20403
20709
|
throw Error(`Expected an array of MDX strings for rich-text field with the special name 'children'`);
|
|
20404
20710
|
}
|
|
20405
20711
|
} else {
|
|
20406
20712
|
try {
|
|
20407
|
-
const mdx2 = parseMDX(attribute.value.value, field);
|
|
20713
|
+
const mdx2 = parseMDX(attribute.value.value, field, graphQLconfig, schema);
|
|
20408
20714
|
props[field.name] = mdx2.children[0].props;
|
|
20409
20715
|
} catch (e) {
|
|
20410
20716
|
console.log(e);
|
|
@@ -20475,7 +20781,7 @@ var defaultNodeTypes = {
|
|
|
20475
20781
|
break: "break",
|
|
20476
20782
|
image: plateElements.ELEMENT_IMAGE
|
|
20477
20783
|
};
|
|
20478
|
-
function remarkToSlate(node) {
|
|
20784
|
+
function remarkToSlate(node, graphQLconfig, schema) {
|
|
20479
20785
|
const types = __spreadProps(__spreadValues({}, defaultNodeTypes), {
|
|
20480
20786
|
heading: __spreadValues({}, defaultNodeTypes.heading)
|
|
20481
20787
|
});
|
|
@@ -20483,12 +20789,12 @@ function remarkToSlate(node) {
|
|
|
20483
20789
|
case "heading":
|
|
20484
20790
|
return {
|
|
20485
20791
|
type: types.heading[node.depth],
|
|
20486
|
-
children: node.children.map(remarkToSlate)
|
|
20792
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20487
20793
|
};
|
|
20488
20794
|
case "list":
|
|
20489
20795
|
return {
|
|
20490
20796
|
type: node.ordered ? types.ol_list : types.ul_list,
|
|
20491
|
-
children: node.children.map(remarkToSlate)
|
|
20797
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20492
20798
|
};
|
|
20493
20799
|
case "listItem":
|
|
20494
20800
|
const realChildren = [];
|
|
@@ -20496,12 +20802,12 @@ function remarkToSlate(node) {
|
|
|
20496
20802
|
if (child.type === "list") {
|
|
20497
20803
|
realChildren.push({
|
|
20498
20804
|
type: child.ordered ? types.ol_list : types.ul_list,
|
|
20499
|
-
children: child.children.map(remarkToSlate)
|
|
20805
|
+
children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20500
20806
|
});
|
|
20501
20807
|
} else {
|
|
20502
20808
|
realChildren.push({
|
|
20503
20809
|
type: plateElements.ELEMENT_LIC,
|
|
20504
|
-
children: child.children.map(remarkToSlate)
|
|
20810
|
+
children: child.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20505
20811
|
});
|
|
20506
20812
|
}
|
|
20507
20813
|
});
|
|
@@ -20512,25 +20818,26 @@ function remarkToSlate(node) {
|
|
|
20512
20818
|
case "paragraph":
|
|
20513
20819
|
return {
|
|
20514
20820
|
type: types.paragraph,
|
|
20515
|
-
children: node.children.map(remarkToSlate)
|
|
20821
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20516
20822
|
};
|
|
20517
20823
|
case "link":
|
|
20518
20824
|
return {
|
|
20519
20825
|
type: types.link,
|
|
20520
20826
|
url: node.url,
|
|
20521
|
-
children: node.children.map(remarkToSlate)
|
|
20827
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20522
20828
|
};
|
|
20523
20829
|
case "image":
|
|
20830
|
+
const url = resolveMediaRelativeToCloud(node.url, graphQLconfig, schema);
|
|
20524
20831
|
return {
|
|
20525
20832
|
type: types.image,
|
|
20526
|
-
url
|
|
20833
|
+
url,
|
|
20527
20834
|
alt: node.alt,
|
|
20528
20835
|
caption: node.title
|
|
20529
20836
|
};
|
|
20530
20837
|
case "blockquote":
|
|
20531
20838
|
return {
|
|
20532
20839
|
type: types.block_quote,
|
|
20533
|
-
children: node.children.map(remarkToSlate)
|
|
20840
|
+
children: node.children.map((node2) => remarkToSlate(node2, graphQLconfig, schema))
|
|
20534
20841
|
};
|
|
20535
20842
|
case "code":
|
|
20536
20843
|
return {
|
|
@@ -21991,10 +22298,10 @@ var mdxToMarkdown = {
|
|
|
21991
22298
|
};
|
|
21992
22299
|
|
|
21993
22300
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/mdx/stringify.ts
|
|
21994
|
-
var stringifyMDX = (value, field) => {
|
|
22301
|
+
var stringifyMDX = (value, field, graphQLconfig, schema) => {
|
|
21995
22302
|
const slateTree = value.children;
|
|
21996
22303
|
try {
|
|
21997
|
-
const tree = stringifyChildren(slateTree, field);
|
|
22304
|
+
const tree = stringifyChildren(slateTree, field, graphQLconfig, schema);
|
|
21998
22305
|
const out = toMarkdown({
|
|
21999
22306
|
type: "root",
|
|
22000
22307
|
children: tree
|
|
@@ -22012,13 +22319,13 @@ var allChildrenEmpty = (children) => {
|
|
|
22012
22319
|
}
|
|
22013
22320
|
return false;
|
|
22014
22321
|
};
|
|
22015
|
-
var stringifyChildren = (children, field) => {
|
|
22322
|
+
var stringifyChildren = (children, field, graphQLconfig, schema) => {
|
|
22016
22323
|
if (!children) {
|
|
22017
22324
|
return [];
|
|
22018
22325
|
}
|
|
22019
|
-
return children.map((child) => stringify(child, field)).filter(Boolean);
|
|
22326
|
+
return children.map((child) => stringify(child, field, graphQLconfig, schema)).filter(Boolean);
|
|
22020
22327
|
};
|
|
22021
|
-
var stringify = (node, field) => {
|
|
22328
|
+
var stringify = (node, field, graphQLconfig, schema) => {
|
|
22022
22329
|
var _a;
|
|
22023
22330
|
if (!node.type) {
|
|
22024
22331
|
if (node == null ? void 0 : node.code) {
|
|
@@ -22044,40 +22351,40 @@ var stringify = (node, field) => {
|
|
|
22044
22351
|
return {
|
|
22045
22352
|
type: "heading",
|
|
22046
22353
|
depth: 1,
|
|
22047
|
-
children: stringifyChildren(node.children, field)
|
|
22354
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22048
22355
|
};
|
|
22049
22356
|
case plateElements.ELEMENT_H2:
|
|
22050
22357
|
return {
|
|
22051
22358
|
type: "heading",
|
|
22052
22359
|
depth: 2,
|
|
22053
|
-
children: stringifyChildren(node.children, field)
|
|
22360
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22054
22361
|
};
|
|
22055
22362
|
case plateElements.ELEMENT_H3:
|
|
22056
22363
|
return {
|
|
22057
22364
|
type: "heading",
|
|
22058
22365
|
depth: 3,
|
|
22059
|
-
children: stringifyChildren(node.children, field)
|
|
22366
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22060
22367
|
};
|
|
22061
22368
|
case plateElements.ELEMENT_H4:
|
|
22062
22369
|
return {
|
|
22063
22370
|
type: "heading",
|
|
22064
22371
|
depth: 4,
|
|
22065
|
-
children: stringifyChildren(node.children, field)
|
|
22372
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22066
22373
|
};
|
|
22067
22374
|
case plateElements.ELEMENT_H5:
|
|
22068
22375
|
return {
|
|
22069
22376
|
type: "heading",
|
|
22070
22377
|
depth: 5,
|
|
22071
|
-
children: stringifyChildren(node.children, field)
|
|
22378
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22072
22379
|
};
|
|
22073
22380
|
case plateElements.ELEMENT_H6:
|
|
22074
22381
|
return {
|
|
22075
22382
|
type: "heading",
|
|
22076
22383
|
depth: 6,
|
|
22077
|
-
children: stringifyChildren(node.children, field)
|
|
22384
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22078
22385
|
};
|
|
22079
22386
|
case plateElements.ELEMENT_PARAGRAPH:
|
|
22080
|
-
const children = stringifyChildren(node.children, field);
|
|
22387
|
+
const children = stringifyChildren(node.children, field, graphQLconfig, schema);
|
|
22081
22388
|
if (allChildrenEmpty(children)) {
|
|
22082
22389
|
return false;
|
|
22083
22390
|
}
|
|
@@ -22097,7 +22404,7 @@ var stringify = (node, field) => {
|
|
|
22097
22404
|
ordered: false,
|
|
22098
22405
|
spread: false,
|
|
22099
22406
|
check: null,
|
|
22100
|
-
children: stringifyChildren(node.children, field)
|
|
22407
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22101
22408
|
};
|
|
22102
22409
|
case plateElements.ELEMENT_OL:
|
|
22103
22410
|
return {
|
|
@@ -22105,7 +22412,7 @@ var stringify = (node, field) => {
|
|
|
22105
22412
|
ordered: true,
|
|
22106
22413
|
spread: false,
|
|
22107
22414
|
check: null,
|
|
22108
|
-
children: stringifyChildren(node.children, field)
|
|
22415
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22109
22416
|
};
|
|
22110
22417
|
case plateElements.ELEMENT_LI:
|
|
22111
22418
|
const realChildren = [];
|
|
@@ -22128,21 +22435,22 @@ var stringify = (node, field) => {
|
|
|
22128
22435
|
spread: false,
|
|
22129
22436
|
check: null,
|
|
22130
22437
|
children: [
|
|
22131
|
-
...stringifyChildren([p], field),
|
|
22132
|
-
...stringifyChildren(extraChildren, field)
|
|
22438
|
+
...stringifyChildren([p], field, graphQLconfig, schema),
|
|
22439
|
+
...stringifyChildren(extraChildren, field, graphQLconfig, schema)
|
|
22133
22440
|
]
|
|
22134
22441
|
};
|
|
22135
22442
|
case plateElements.ELEMENT_LIC:
|
|
22136
22443
|
return {
|
|
22137
22444
|
type: "paragraph",
|
|
22138
|
-
children: stringifyChildren(node.children, field)
|
|
22445
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22139
22446
|
};
|
|
22140
22447
|
case plateElements.ELEMENT_IMAGE:
|
|
22448
|
+
const url = resolveMediaCloudToRelative(node.url, graphQLconfig, schema);
|
|
22141
22449
|
return {
|
|
22142
22450
|
type: "image",
|
|
22143
22451
|
title: node.caption,
|
|
22144
22452
|
alt: node.alt,
|
|
22145
|
-
url
|
|
22453
|
+
url
|
|
22146
22454
|
};
|
|
22147
22455
|
case plateElements.ELEMENT_HR:
|
|
22148
22456
|
return {
|
|
@@ -22153,12 +22461,12 @@ var stringify = (node, field) => {
|
|
|
22153
22461
|
type: "link",
|
|
22154
22462
|
url: node.url,
|
|
22155
22463
|
title: node.title,
|
|
22156
|
-
children: stringifyChildren(node.children, field)
|
|
22464
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22157
22465
|
};
|
|
22158
22466
|
case plateElements.ELEMENT_BLOCKQUOTE:
|
|
22159
22467
|
return {
|
|
22160
22468
|
type: "blockquote",
|
|
22161
|
-
children: stringifyChildren(node.children, field)
|
|
22469
|
+
children: stringifyChildren(node.children, field, graphQLconfig, schema)
|
|
22162
22470
|
};
|
|
22163
22471
|
case "mdxJsxTextElement":
|
|
22164
22472
|
case "mdxJsxFlowElement":
|
|
@@ -22323,7 +22631,7 @@ var stringify = (node, field) => {
|
|
|
22323
22631
|
}
|
|
22324
22632
|
break;
|
|
22325
22633
|
case "rich-text":
|
|
22326
|
-
const tree = stringifyChildren(value.children, field2);
|
|
22634
|
+
const tree = stringifyChildren(value.children, field2, graphQLconfig, schema);
|
|
22327
22635
|
if (field2.name === "children") {
|
|
22328
22636
|
children2 = tree;
|
|
22329
22637
|
} else {
|
|
@@ -22526,7 +22834,18 @@ var Resolver = class {
|
|
|
22526
22834
|
_collection: rawData._collection,
|
|
22527
22835
|
_template: rawData._template
|
|
22528
22836
|
};
|
|
22529
|
-
|
|
22837
|
+
try {
|
|
22838
|
+
await sequential(template.fields, async (field) => {
|
|
22839
|
+
return this.resolveFieldData(field, rawData, data);
|
|
22840
|
+
});
|
|
22841
|
+
} catch (e) {
|
|
22842
|
+
throw new TinaParseDocumentError({
|
|
22843
|
+
originalError: e,
|
|
22844
|
+
collection: collection.name,
|
|
22845
|
+
file: relativePath,
|
|
22846
|
+
stack: e.stack
|
|
22847
|
+
});
|
|
22848
|
+
}
|
|
22530
22849
|
const titleField = template.fields.find((x) => {
|
|
22531
22850
|
if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
|
|
22532
22851
|
return true;
|
|
@@ -22552,8 +22871,8 @@ var Resolver = class {
|
|
|
22552
22871
|
_values: data
|
|
22553
22872
|
});
|
|
22554
22873
|
} catch (e) {
|
|
22555
|
-
if (e instanceof
|
|
22556
|
-
throw new
|
|
22874
|
+
if (e instanceof TinaGraphQLError) {
|
|
22875
|
+
throw new TinaGraphQLError(e.message, __spreadValues({
|
|
22557
22876
|
requestedDocument: fullPath
|
|
22558
22877
|
}, e.extensions));
|
|
22559
22878
|
}
|
|
@@ -22844,15 +23163,16 @@ var Resolver = class {
|
|
|
22844
23163
|
case "string":
|
|
22845
23164
|
case "boolean":
|
|
22846
23165
|
case "number":
|
|
22847
|
-
case "image":
|
|
22848
23166
|
accum[fieldName] = fieldValue;
|
|
22849
23167
|
break;
|
|
23168
|
+
case "image":
|
|
23169
|
+
accum[fieldName] = resolveMediaCloudToRelative(fieldValue, this.config, this.tinaSchema.schema);
|
|
23170
|
+
break;
|
|
22850
23171
|
case "object":
|
|
22851
23172
|
accum[fieldName] = this.buildObjectMutations(fieldValue, field);
|
|
22852
23173
|
break;
|
|
22853
23174
|
case "rich-text":
|
|
22854
|
-
field;
|
|
22855
|
-
accum[fieldName] = stringifyMDX(fieldValue, field);
|
|
23175
|
+
accum[fieldName] = stringifyMDX(fieldValue, field, this.config, this.tinaSchema.schema);
|
|
22856
23176
|
break;
|
|
22857
23177
|
case "reference":
|
|
22858
23178
|
accum[fieldName] = fieldValue;
|
|
@@ -22885,18 +23205,10 @@ var Resolver = class {
|
|
|
22885
23205
|
accumulator[field.name] = value;
|
|
22886
23206
|
break;
|
|
22887
23207
|
case "image":
|
|
22888
|
-
|
|
22889
|
-
if (this.config.useRelativeMedia === true) {
|
|
22890
|
-
accumulator[field.name] = value;
|
|
22891
|
-
} else {
|
|
22892
|
-
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22893
|
-
}
|
|
22894
|
-
} else {
|
|
22895
|
-
accumulator[field.name] = value;
|
|
22896
|
-
}
|
|
23208
|
+
accumulator[field.name] = resolveMediaRelativeToCloud(value, this.config, this.tinaSchema.schema);
|
|
22897
23209
|
break;
|
|
22898
23210
|
case "rich-text":
|
|
22899
|
-
const tree = parseMDX(value, field);
|
|
23211
|
+
const tree = parseMDX(value, field, this.config, this.tinaSchema.schema);
|
|
22900
23212
|
accumulator[field.name] = tree;
|
|
22901
23213
|
break;
|
|
22902
23214
|
case "object":
|
|
@@ -23001,10 +23313,12 @@ var resolve = async ({
|
|
|
23001
23313
|
query,
|
|
23002
23314
|
variables,
|
|
23003
23315
|
database,
|
|
23004
|
-
silenceErrors
|
|
23316
|
+
silenceErrors,
|
|
23317
|
+
verbose
|
|
23005
23318
|
}) => {
|
|
23006
23319
|
var _a;
|
|
23007
23320
|
try {
|
|
23321
|
+
const verboseValue = verbose != null ? verbose : true;
|
|
23008
23322
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
23009
23323
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
23010
23324
|
const tinaConfig = await database.getTinaSchema();
|
|
@@ -23032,141 +23346,152 @@ var resolve = async ({
|
|
|
23032
23346
|
}
|
|
23033
23347
|
},
|
|
23034
23348
|
fieldResolver: async (source = {}, _args = {}, _context, info) => {
|
|
23035
|
-
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
if (
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
if (info.fieldName === "collections") {
|
|
23045
|
-
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
23046
|
-
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23047
|
-
var _a2;
|
|
23048
|
-
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23049
|
-
});
|
|
23050
|
-
return tinaSchema.getCollections().map((collection) => {
|
|
23051
|
-
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
23052
|
-
});
|
|
23053
|
-
}
|
|
23054
|
-
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
23055
|
-
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23056
|
-
var _a2;
|
|
23057
|
-
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23058
|
-
});
|
|
23059
|
-
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
23060
|
-
}
|
|
23061
|
-
if (info.fieldName === "getOptimizedQuery") {
|
|
23062
|
-
try {
|
|
23063
|
-
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
23064
|
-
assumeValid: true,
|
|
23065
|
-
includeFragments: false,
|
|
23066
|
-
noLocation: true
|
|
23067
|
-
});
|
|
23068
|
-
return (0, import_graphql3.print)(optimizedQuery);
|
|
23069
|
-
} catch (e) {
|
|
23070
|
-
throw new Error(`Invalid query provided, Error message: ${e.message}`);
|
|
23071
|
-
}
|
|
23072
|
-
}
|
|
23073
|
-
if (!lookup) {
|
|
23074
|
-
return value;
|
|
23075
|
-
}
|
|
23076
|
-
const isCreation = lookup[info.fieldName] === "create";
|
|
23077
|
-
switch (lookup.resolveType) {
|
|
23078
|
-
case "nodeDocument":
|
|
23079
|
-
assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
|
|
23080
|
-
return resolver2.getDocument(args.id);
|
|
23081
|
-
case "multiCollectionDocument":
|
|
23082
|
-
if (typeof value === "string") {
|
|
23083
|
-
return resolver2.getDocument(value);
|
|
23349
|
+
try {
|
|
23350
|
+
const args = JSON.parse(JSON.stringify(_args));
|
|
23351
|
+
const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
|
|
23352
|
+
const lookup = await database.getLookup(returnType);
|
|
23353
|
+
const isMutation = info.parentType.toString() === "Mutation";
|
|
23354
|
+
const value = source[info.fieldName];
|
|
23355
|
+
if (returnType === "Collection") {
|
|
23356
|
+
if (value) {
|
|
23357
|
+
return value;
|
|
23084
23358
|
}
|
|
23085
|
-
if (
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
isCreation: true,
|
|
23091
|
-
isAddPendingDocument: true
|
|
23359
|
+
if (info.fieldName === "collections") {
|
|
23360
|
+
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
23361
|
+
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23362
|
+
var _a2;
|
|
23363
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23092
23364
|
});
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
NAMER.documentQueryName(),
|
|
23096
|
-
"createDocument",
|
|
23097
|
-
"updateDocument",
|
|
23098
|
-
"deleteDocument"
|
|
23099
|
-
].includes(info.fieldName)) {
|
|
23100
|
-
const result2 = await resolver2.resolveDocument({
|
|
23101
|
-
args,
|
|
23102
|
-
collection: args.collection,
|
|
23103
|
-
isMutation,
|
|
23104
|
-
isCreation,
|
|
23105
|
-
isDeletion: info.fieldName === "deleteDocument",
|
|
23106
|
-
isAddPendingDocument: false,
|
|
23107
|
-
isCollectionSpecific: false
|
|
23365
|
+
return tinaSchema.getCollections().map((collection) => {
|
|
23366
|
+
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
23108
23367
|
});
|
|
23109
|
-
return result2;
|
|
23110
23368
|
}
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
return
|
|
23115
|
-
|
|
23116
|
-
|
|
23117
|
-
|
|
23118
|
-
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23369
|
+
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
23370
|
+
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23371
|
+
var _a2;
|
|
23372
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23373
|
+
});
|
|
23374
|
+
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
23375
|
+
}
|
|
23376
|
+
if (info.fieldName === "getOptimizedQuery") {
|
|
23377
|
+
try {
|
|
23378
|
+
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
23379
|
+
assumeValid: true,
|
|
23380
|
+
includeFragments: false,
|
|
23381
|
+
noLocation: true
|
|
23124
23382
|
});
|
|
23125
|
-
|
|
23126
|
-
|
|
23383
|
+
return (0, import_graphql3.print)(optimizedQuery);
|
|
23384
|
+
} catch (e) {
|
|
23385
|
+
throw new Error(`Invalid query provided, Error message: ${e.message}`);
|
|
23127
23386
|
}
|
|
23128
|
-
|
|
23129
|
-
|
|
23130
|
-
|
|
23131
|
-
|
|
23132
|
-
|
|
23133
|
-
|
|
23134
|
-
|
|
23135
|
-
|
|
23136
|
-
|
|
23137
|
-
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23144
|
-
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
|
-
|
|
23387
|
+
}
|
|
23388
|
+
if (!lookup) {
|
|
23389
|
+
return value;
|
|
23390
|
+
}
|
|
23391
|
+
const isCreation = lookup[info.fieldName] === "create";
|
|
23392
|
+
switch (lookup.resolveType) {
|
|
23393
|
+
case "nodeDocument":
|
|
23394
|
+
assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
|
|
23395
|
+
return resolver2.getDocument(args.id);
|
|
23396
|
+
case "multiCollectionDocument":
|
|
23397
|
+
if (typeof value === "string") {
|
|
23398
|
+
return resolver2.getDocument(value);
|
|
23399
|
+
}
|
|
23400
|
+
if (args && args.collection && info.fieldName === "addPendingDocument") {
|
|
23401
|
+
return resolver2.resolveDocument({
|
|
23402
|
+
args: __spreadProps(__spreadValues({}, args), { params: {} }),
|
|
23403
|
+
collection: args.collection,
|
|
23404
|
+
isMutation,
|
|
23405
|
+
isCreation: true,
|
|
23406
|
+
isAddPendingDocument: true
|
|
23407
|
+
});
|
|
23408
|
+
}
|
|
23409
|
+
if ([
|
|
23410
|
+
NAMER.documentQueryName(),
|
|
23411
|
+
"createDocument",
|
|
23412
|
+
"updateDocument",
|
|
23413
|
+
"deleteDocument"
|
|
23414
|
+
].includes(info.fieldName)) {
|
|
23149
23415
|
const result2 = await resolver2.resolveDocument({
|
|
23150
23416
|
args,
|
|
23151
|
-
collection:
|
|
23417
|
+
collection: args.collection,
|
|
23152
23418
|
isMutation,
|
|
23153
23419
|
isCreation,
|
|
23420
|
+
isDeletion: info.fieldName === "deleteDocument",
|
|
23154
23421
|
isAddPendingDocument: false,
|
|
23155
|
-
isCollectionSpecific:
|
|
23422
|
+
isCollectionSpecific: false
|
|
23156
23423
|
});
|
|
23157
23424
|
return result2;
|
|
23158
23425
|
}
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
|
|
23162
|
-
|
|
23163
|
-
|
|
23426
|
+
return value;
|
|
23427
|
+
case "multiCollectionDocumentList":
|
|
23428
|
+
if (Array.isArray(value)) {
|
|
23429
|
+
return {
|
|
23430
|
+
totalCount: value.length,
|
|
23431
|
+
edges: value.map((document3) => {
|
|
23432
|
+
return { node: document3 };
|
|
23433
|
+
})
|
|
23434
|
+
};
|
|
23435
|
+
} else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
23436
|
+
return resolver2.resolveCollectionConnection({
|
|
23437
|
+
args,
|
|
23438
|
+
collection: value.collection
|
|
23439
|
+
});
|
|
23440
|
+
} else {
|
|
23441
|
+
throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
|
|
23442
|
+
}
|
|
23443
|
+
case "collectionDocument":
|
|
23444
|
+
if (value) {
|
|
23445
|
+
return value;
|
|
23446
|
+
}
|
|
23447
|
+
const result = value || await resolver2.resolveDocument({
|
|
23448
|
+
args,
|
|
23449
|
+
collection: lookup.collection,
|
|
23450
|
+
isMutation,
|
|
23451
|
+
isCreation,
|
|
23452
|
+
isAddPendingDocument: false,
|
|
23453
|
+
isCollectionSpecific: true
|
|
23454
|
+
});
|
|
23455
|
+
return result;
|
|
23456
|
+
case "collectionDocumentList":
|
|
23457
|
+
return resolver2.resolveCollectionConnection({
|
|
23458
|
+
args,
|
|
23459
|
+
collection: tinaSchema.getCollection(lookup.collection)
|
|
23460
|
+
});
|
|
23461
|
+
case "unionData":
|
|
23462
|
+
if (!value) {
|
|
23463
|
+
if (args.relativePath) {
|
|
23464
|
+
const result2 = await resolver2.resolveDocument({
|
|
23465
|
+
args,
|
|
23466
|
+
collection: lookup.collection,
|
|
23467
|
+
isMutation,
|
|
23468
|
+
isCreation,
|
|
23469
|
+
isAddPendingDocument: false,
|
|
23470
|
+
isCollectionSpecific: true
|
|
23471
|
+
});
|
|
23472
|
+
return result2;
|
|
23473
|
+
}
|
|
23474
|
+
}
|
|
23475
|
+
return value;
|
|
23476
|
+
default:
|
|
23477
|
+
console.error(lookup);
|
|
23478
|
+
throw new Error(`Unexpected resolve type`);
|
|
23479
|
+
}
|
|
23480
|
+
} catch (e) {
|
|
23481
|
+
handleFetchErrorError(e, verboseValue);
|
|
23164
23482
|
}
|
|
23165
23483
|
}
|
|
23166
23484
|
});
|
|
23167
23485
|
if (res.errors) {
|
|
23168
23486
|
if (!silenceErrors) {
|
|
23169
|
-
|
|
23487
|
+
res.errors.map((e) => {
|
|
23488
|
+
console.error(e.toString());
|
|
23489
|
+
if (verboseValue) {
|
|
23490
|
+
console.error("More error context below");
|
|
23491
|
+
console.error(e.message);
|
|
23492
|
+
console.error(e);
|
|
23493
|
+
}
|
|
23494
|
+
});
|
|
23170
23495
|
}
|
|
23171
23496
|
}
|
|
23172
23497
|
return res;
|
|
@@ -23319,25 +23644,34 @@ var Database = class {
|
|
|
23319
23644
|
});
|
|
23320
23645
|
};
|
|
23321
23646
|
this.put = async (filepath, data, collection) => {
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23647
|
+
try {
|
|
23648
|
+
if (SYSTEM_FILES.includes(filepath)) {
|
|
23649
|
+
throw new Error(`Unexpected put for config file ${filepath}`);
|
|
23650
|
+
} else {
|
|
23651
|
+
let collectionIndexDefinitions;
|
|
23652
|
+
if (collection) {
|
|
23653
|
+
const indexDefinitions = await this.getIndexDefinitions();
|
|
23654
|
+
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
|
|
23655
|
+
}
|
|
23656
|
+
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23657
|
+
if (this.store.supportsSeeding()) {
|
|
23658
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23659
|
+
}
|
|
23660
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23661
|
+
keepTemplateKey,
|
|
23662
|
+
collection,
|
|
23663
|
+
indexDefinitions: collectionIndexDefinitions
|
|
23664
|
+
});
|
|
23333
23665
|
}
|
|
23334
|
-
|
|
23335
|
-
|
|
23666
|
+
return true;
|
|
23667
|
+
} catch (error) {
|
|
23668
|
+
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
23669
|
+
originalError: error,
|
|
23670
|
+
file: filepath,
|
|
23336
23671
|
collection,
|
|
23337
|
-
|
|
23672
|
+
stack: error.stack
|
|
23338
23673
|
});
|
|
23339
23674
|
}
|
|
23340
|
-
return true;
|
|
23341
23675
|
};
|
|
23342
23676
|
this.stringifyFile = async (filepath, data) => {
|
|
23343
23677
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
@@ -23513,11 +23847,24 @@ var Database = class {
|
|
|
23513
23847
|
} = await this.store.query(storeQueryOptions);
|
|
23514
23848
|
return {
|
|
23515
23849
|
edges: await sequential(edges, async (edge) => {
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23850
|
+
try {
|
|
23851
|
+
const node = await hydrator(edge.path);
|
|
23852
|
+
return {
|
|
23853
|
+
node,
|
|
23854
|
+
cursor: (0, import_datalayer2.btoa)(edge.cursor)
|
|
23855
|
+
};
|
|
23856
|
+
} catch (error) {
|
|
23857
|
+
if (error instanceof Error) {
|
|
23858
|
+
throw new TinaQueryError({
|
|
23859
|
+
originalError: error,
|
|
23860
|
+
file: edge.path,
|
|
23861
|
+
collection,
|
|
23862
|
+
stack: error.stack
|
|
23863
|
+
});
|
|
23864
|
+
} else {
|
|
23865
|
+
throw error;
|
|
23866
|
+
}
|
|
23867
|
+
}
|
|
23521
23868
|
}),
|
|
23522
23869
|
pageInfo: {
|
|
23523
23870
|
hasPreviousPage,
|
|
@@ -23664,10 +24011,19 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23664
24011
|
};
|
|
23665
24012
|
}
|
|
23666
24013
|
await sequential(documentPaths, async (filepath) => {
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
24014
|
+
try {
|
|
24015
|
+
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
24016
|
+
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
24017
|
+
if (database.store.supportsSeeding()) {
|
|
24018
|
+
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
24019
|
+
}
|
|
24020
|
+
} catch (error) {
|
|
24021
|
+
throw new TinaFetchError(`Unable to seed ${filepath}`, {
|
|
24022
|
+
originalError: error,
|
|
24023
|
+
file: filepath,
|
|
24024
|
+
collection: collection.name,
|
|
24025
|
+
stack: error.stack
|
|
24026
|
+
});
|
|
23671
24027
|
}
|
|
23672
24028
|
});
|
|
23673
24029
|
};
|
|
@@ -23700,9 +24056,14 @@ var buildSchema = async (rootPath, database, flags) => {
|
|
|
23700
24056
|
};
|
|
23701
24057
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23702
24058
|
0 && (module.exports = {
|
|
24059
|
+
TinaFetchError,
|
|
24060
|
+
TinaGraphQLError,
|
|
24061
|
+
TinaParseDocumentError,
|
|
24062
|
+
TinaQueryError,
|
|
23703
24063
|
assertShape,
|
|
23704
24064
|
buildSchema,
|
|
23705
24065
|
createDatabase,
|
|
24066
|
+
handleFetchErrorError,
|
|
23706
24067
|
indexDB,
|
|
23707
24068
|
parseFile,
|
|
23708
24069
|
resolve,
|