@tinacms/graphql 0.59.9 → 0.60.0
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 +183 -0
- package/dist/ast-builder/index.d.ts +4 -0
- package/dist/builder/index.d.ts +16 -27
- package/dist/database/bridge/index.d.ts +1 -0
- package/dist/database/index.d.ts +6 -1
- package/dist/index.js +338 -674
- package/dist/resolver/filter-utils.d.ts +11 -11
- package/dist/resolver/index.d.ts +34 -89
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -603,10 +603,10 @@ var require_util_events_to_acorn = __commonJS({
|
|
|
603
603
|
}
|
|
604
604
|
if (estree) {
|
|
605
605
|
estree.comments = comments;
|
|
606
|
-
|
|
606
|
+
visit2(estree);
|
|
607
607
|
}
|
|
608
608
|
return { estree, error: exception, swallow };
|
|
609
|
-
function
|
|
609
|
+
function visit2(esnode) {
|
|
610
610
|
var point3;
|
|
611
611
|
var key2;
|
|
612
612
|
var index3;
|
|
@@ -632,10 +632,10 @@ var require_util_events_to_acorn = __commonJS({
|
|
|
632
632
|
if ("length" in esnode[key2]) {
|
|
633
633
|
index3 = -1;
|
|
634
634
|
while (++index3 < esnode[key2].length) {
|
|
635
|
-
|
|
635
|
+
visit2(esnode[key2][index3]);
|
|
636
636
|
}
|
|
637
637
|
} else {
|
|
638
|
-
|
|
638
|
+
visit2(esnode[key2]);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
}
|
|
@@ -10244,7 +10244,7 @@ var require_to_markdown2 = __commonJS({
|
|
|
10244
10244
|
var phrasing = require_container_phrasing();
|
|
10245
10245
|
var checkQuote2 = require_check_quote();
|
|
10246
10246
|
var eol2 = /\r?\n|\r/g;
|
|
10247
|
-
function mdxElement2(node,
|
|
10247
|
+
function mdxElement2(node, _4, context) {
|
|
10248
10248
|
var selfClosing = node.name && (!node.children || !node.children.length);
|
|
10249
10249
|
var quote = checkQuote2(context);
|
|
10250
10250
|
var exit2 = context.enter(node.type);
|
|
@@ -10404,11 +10404,49 @@ var import_graphql2 = __toModule(require("graphql"));
|
|
|
10404
10404
|
|
|
10405
10405
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/ast-builder/index.ts
|
|
10406
10406
|
var import_lodash = __toModule(require("lodash"));
|
|
10407
|
+
|
|
10408
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/util.ts
|
|
10409
|
+
var yup = __toModule(require("yup"));
|
|
10410
|
+
var import_graphql = __toModule(require("graphql"));
|
|
10411
|
+
var sequential = async (items, callback) => {
|
|
10412
|
+
const accum = [];
|
|
10413
|
+
if (!items) {
|
|
10414
|
+
return [];
|
|
10415
|
+
}
|
|
10416
|
+
const reducePromises = async (previous2, endpoint) => {
|
|
10417
|
+
const prev = await previous2;
|
|
10418
|
+
if (prev) {
|
|
10419
|
+
accum.push(prev);
|
|
10420
|
+
}
|
|
10421
|
+
return callback(endpoint, accum.length);
|
|
10422
|
+
};
|
|
10423
|
+
const result = await items.reduce(reducePromises, Promise.resolve());
|
|
10424
|
+
if (result) {
|
|
10425
|
+
accum.push(result);
|
|
10426
|
+
}
|
|
10427
|
+
return accum;
|
|
10428
|
+
};
|
|
10429
|
+
function assertShape(value, yupSchema, errorMessage) {
|
|
10430
|
+
const shape = yupSchema(yup);
|
|
10431
|
+
try {
|
|
10432
|
+
shape.validateSync(value);
|
|
10433
|
+
} catch (e) {
|
|
10434
|
+
const message = errorMessage || `Failed to assertShape - ${e.message}`;
|
|
10435
|
+
throw new import_graphql.GraphQLError(message, null, null, null, null, null, {
|
|
10436
|
+
stack: e.stack
|
|
10437
|
+
});
|
|
10438
|
+
}
|
|
10439
|
+
}
|
|
10440
|
+
var lastItem = (arr) => {
|
|
10441
|
+
return arr[arr.length - 1];
|
|
10442
|
+
};
|
|
10443
|
+
|
|
10444
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/ast-builder/index.ts
|
|
10407
10445
|
var SysFieldDefinition = {
|
|
10408
10446
|
kind: "Field",
|
|
10409
10447
|
name: {
|
|
10410
10448
|
kind: "Name",
|
|
10411
|
-
value: "
|
|
10449
|
+
value: "_sys"
|
|
10412
10450
|
},
|
|
10413
10451
|
arguments: [],
|
|
10414
10452
|
directives: [],
|
|
@@ -10884,26 +10922,12 @@ var astBuilder = {
|
|
|
10884
10922
|
directives: []
|
|
10885
10923
|
},
|
|
10886
10924
|
{
|
|
10887
|
-
kind: "
|
|
10925
|
+
kind: "FragmentSpread",
|
|
10888
10926
|
name: {
|
|
10889
10927
|
kind: "Name",
|
|
10890
|
-
value:
|
|
10928
|
+
value: fragName
|
|
10891
10929
|
},
|
|
10892
|
-
|
|
10893
|
-
directives: [],
|
|
10894
|
-
selectionSet: {
|
|
10895
|
-
kind: "SelectionSet",
|
|
10896
|
-
selections: [
|
|
10897
|
-
{
|
|
10898
|
-
kind: "FragmentSpread",
|
|
10899
|
-
name: {
|
|
10900
|
-
kind: "Name",
|
|
10901
|
-
value: fragName
|
|
10902
|
-
},
|
|
10903
|
-
directives: []
|
|
10904
|
-
}
|
|
10905
|
-
]
|
|
10906
|
-
}
|
|
10930
|
+
directives: []
|
|
10907
10931
|
}
|
|
10908
10932
|
]
|
|
10909
10933
|
}
|
|
@@ -10981,26 +11005,12 @@ var astBuilder = {
|
|
|
10981
11005
|
},
|
|
10982
11006
|
SysFieldDefinition,
|
|
10983
11007
|
{
|
|
10984
|
-
kind: "
|
|
11008
|
+
kind: "FragmentSpread",
|
|
10985
11009
|
name: {
|
|
10986
11010
|
kind: "Name",
|
|
10987
|
-
value:
|
|
11011
|
+
value: fragName
|
|
10988
11012
|
},
|
|
10989
|
-
|
|
10990
|
-
directives: [],
|
|
10991
|
-
selectionSet: {
|
|
10992
|
-
kind: "SelectionSet",
|
|
10993
|
-
selections: [
|
|
10994
|
-
{
|
|
10995
|
-
kind: "FragmentSpread",
|
|
10996
|
-
name: {
|
|
10997
|
-
kind: "Name",
|
|
10998
|
-
value: fragName
|
|
10999
|
-
},
|
|
11000
|
-
directives: []
|
|
11001
|
-
}
|
|
11002
|
-
]
|
|
11003
|
-
}
|
|
11013
|
+
directives: []
|
|
11004
11014
|
}
|
|
11005
11015
|
]
|
|
11006
11016
|
}
|
|
@@ -11125,16 +11135,28 @@ var NAMER = {
|
|
|
11125
11135
|
return generateNamespacedFieldName(namespace, "Mutation");
|
|
11126
11136
|
},
|
|
11127
11137
|
updateName: (namespace) => {
|
|
11128
|
-
return
|
|
11138
|
+
return `update${generateNamespacedFieldName(namespace)}`;
|
|
11129
11139
|
},
|
|
11130
11140
|
createName: (namespace) => {
|
|
11131
|
-
return
|
|
11141
|
+
return `create${generateNamespacedFieldName(namespace)}`;
|
|
11142
|
+
},
|
|
11143
|
+
documentQueryName: () => {
|
|
11144
|
+
return "document";
|
|
11145
|
+
},
|
|
11146
|
+
documentConnectionQueryName: () => {
|
|
11147
|
+
return "documentConnection";
|
|
11148
|
+
},
|
|
11149
|
+
collectionQueryName: () => {
|
|
11150
|
+
return "collection";
|
|
11151
|
+
},
|
|
11152
|
+
collectionListQueryName: () => {
|
|
11153
|
+
return "collections";
|
|
11132
11154
|
},
|
|
11133
11155
|
queryName: (namespace) => {
|
|
11134
|
-
return
|
|
11156
|
+
return String(lastItem(namespace));
|
|
11135
11157
|
},
|
|
11136
11158
|
generateQueryListName: (namespace) => {
|
|
11137
|
-
return
|
|
11159
|
+
return `${lastItem(namespace)}Connection`;
|
|
11138
11160
|
},
|
|
11139
11161
|
fragmentName: (namespace) => {
|
|
11140
11162
|
return generateNamespacedFieldName(namespace, "") + "Parts";
|
|
@@ -11143,7 +11165,7 @@ var NAMER = {
|
|
|
11143
11165
|
return generateNamespacedFieldName(namespace, "Collection");
|
|
11144
11166
|
},
|
|
11145
11167
|
documentTypeName: (namespace) => {
|
|
11146
|
-
return generateNamespacedFieldName(namespace
|
|
11168
|
+
return generateNamespacedFieldName(namespace);
|
|
11147
11169
|
},
|
|
11148
11170
|
dataTypeName: (namespace) => {
|
|
11149
11171
|
return generateNamespacedFieldName(namespace, "");
|
|
@@ -11156,42 +11178,6 @@ var NAMER = {
|
|
|
11156
11178
|
}
|
|
11157
11179
|
};
|
|
11158
11180
|
|
|
11159
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/util.ts
|
|
11160
|
-
var yup = __toModule(require("yup"));
|
|
11161
|
-
var import_graphql = __toModule(require("graphql"));
|
|
11162
|
-
var sequential = async (items, callback) => {
|
|
11163
|
-
const accum = [];
|
|
11164
|
-
if (!items) {
|
|
11165
|
-
return [];
|
|
11166
|
-
}
|
|
11167
|
-
const reducePromises = async (previous2, endpoint) => {
|
|
11168
|
-
const prev = await previous2;
|
|
11169
|
-
if (prev) {
|
|
11170
|
-
accum.push(prev);
|
|
11171
|
-
}
|
|
11172
|
-
return callback(endpoint, accum.length);
|
|
11173
|
-
};
|
|
11174
|
-
const result = await items.reduce(reducePromises, Promise.resolve());
|
|
11175
|
-
if (result) {
|
|
11176
|
-
accum.push(result);
|
|
11177
|
-
}
|
|
11178
|
-
return accum;
|
|
11179
|
-
};
|
|
11180
|
-
function assertShape(value, yupSchema, errorMessage) {
|
|
11181
|
-
const shape = yupSchema(yup);
|
|
11182
|
-
try {
|
|
11183
|
-
shape.validateSync(value);
|
|
11184
|
-
} catch (e) {
|
|
11185
|
-
const message = errorMessage || `Failed to assertShape - ${e.message}`;
|
|
11186
|
-
throw new import_graphql.GraphQLError(message, null, null, null, null, null, {
|
|
11187
|
-
stack: e.stack
|
|
11188
|
-
});
|
|
11189
|
-
}
|
|
11190
|
-
}
|
|
11191
|
-
var lastItem = (arr) => {
|
|
11192
|
-
return arr[arr.length - 1];
|
|
11193
|
-
};
|
|
11194
|
-
|
|
11195
11181
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/builder/static-definitions.ts
|
|
11196
11182
|
var interfaceDefinitions = [
|
|
11197
11183
|
astBuilder.InterfaceTypeDefinition({
|
|
@@ -11207,22 +11193,17 @@ var interfaceDefinitions = [
|
|
|
11207
11193
|
astBuilder.InterfaceTypeDefinition({
|
|
11208
11194
|
name: "Document",
|
|
11209
11195
|
fields: [
|
|
11210
|
-
astBuilder.FieldDefinition({
|
|
11211
|
-
name: "sys",
|
|
11212
|
-
type: astBuilder.TYPES.SystemInfo
|
|
11213
|
-
}),
|
|
11214
11196
|
astBuilder.FieldDefinition({
|
|
11215
11197
|
name: "id",
|
|
11216
11198
|
type: astBuilder.TYPES.ID,
|
|
11217
11199
|
required: true
|
|
11218
11200
|
}),
|
|
11219
11201
|
astBuilder.FieldDefinition({
|
|
11220
|
-
name: "
|
|
11221
|
-
type: astBuilder.TYPES.
|
|
11222
|
-
required: true
|
|
11202
|
+
name: "_sys",
|
|
11203
|
+
type: astBuilder.TYPES.SystemInfo
|
|
11223
11204
|
}),
|
|
11224
11205
|
astBuilder.FieldDefinition({
|
|
11225
|
-
name: "
|
|
11206
|
+
name: "_values",
|
|
11226
11207
|
type: astBuilder.TYPES.JSON,
|
|
11227
11208
|
required: true
|
|
11228
11209
|
})
|
|
@@ -11236,6 +11217,35 @@ var interfaceDefinitions = [
|
|
|
11236
11217
|
name: "totalCount",
|
|
11237
11218
|
required: true,
|
|
11238
11219
|
type: astBuilder.TYPES.Number
|
|
11220
|
+
}),
|
|
11221
|
+
astBuilder.FieldDefinition({
|
|
11222
|
+
name: "pageInfo",
|
|
11223
|
+
required: true,
|
|
11224
|
+
type: astBuilder.ObjectTypeDefinition({
|
|
11225
|
+
name: "PageInfo",
|
|
11226
|
+
fields: [
|
|
11227
|
+
astBuilder.FieldDefinition({
|
|
11228
|
+
name: "hasPreviousPage",
|
|
11229
|
+
required: true,
|
|
11230
|
+
type: astBuilder.TYPES.Boolean
|
|
11231
|
+
}),
|
|
11232
|
+
astBuilder.FieldDefinition({
|
|
11233
|
+
name: "hasNextPage",
|
|
11234
|
+
required: true,
|
|
11235
|
+
type: astBuilder.TYPES.Boolean
|
|
11236
|
+
}),
|
|
11237
|
+
astBuilder.FieldDefinition({
|
|
11238
|
+
name: "startCursor",
|
|
11239
|
+
required: true,
|
|
11240
|
+
type: astBuilder.TYPES.String
|
|
11241
|
+
}),
|
|
11242
|
+
astBuilder.FieldDefinition({
|
|
11243
|
+
name: "endCursor",
|
|
11244
|
+
required: true,
|
|
11245
|
+
type: astBuilder.TYPES.String
|
|
11246
|
+
})
|
|
11247
|
+
]
|
|
11248
|
+
})
|
|
11239
11249
|
})
|
|
11240
11250
|
]
|
|
11241
11251
|
})
|
|
@@ -11337,7 +11347,7 @@ var Builder = class {
|
|
|
11337
11347
|
constructor(config) {
|
|
11338
11348
|
this.config = config;
|
|
11339
11349
|
this.buildCollectionDefinition = async (collections) => {
|
|
11340
|
-
const name2 = "
|
|
11350
|
+
const name2 = "collection";
|
|
11341
11351
|
const typeName = "Collection";
|
|
11342
11352
|
const args = [
|
|
11343
11353
|
astBuilder.InputValueDefinition({
|
|
@@ -11398,10 +11408,15 @@ var Builder = class {
|
|
|
11398
11408
|
documentsType
|
|
11399
11409
|
]
|
|
11400
11410
|
});
|
|
11401
|
-
return astBuilder.FieldDefinition({
|
|
11411
|
+
return astBuilder.FieldDefinition({
|
|
11412
|
+
type,
|
|
11413
|
+
name: name2,
|
|
11414
|
+
args,
|
|
11415
|
+
required: true
|
|
11416
|
+
});
|
|
11402
11417
|
};
|
|
11403
11418
|
this.buildMultiCollectionDefinition = async (collections) => {
|
|
11404
|
-
const name2 = "
|
|
11419
|
+
const name2 = "collections";
|
|
11405
11420
|
const typeName = "Collection";
|
|
11406
11421
|
return astBuilder.FieldDefinition({
|
|
11407
11422
|
type: typeName,
|
|
@@ -11431,7 +11446,7 @@ var Builder = class {
|
|
|
11431
11446
|
});
|
|
11432
11447
|
};
|
|
11433
11448
|
this.multiCollectionDocument = async (collections) => {
|
|
11434
|
-
const name2 = "
|
|
11449
|
+
const name2 = "document";
|
|
11435
11450
|
const args = [
|
|
11436
11451
|
astBuilder.InputValueDefinition({
|
|
11437
11452
|
name: "collection",
|
|
@@ -11454,13 +11469,6 @@ var Builder = class {
|
|
|
11454
11469
|
required: true
|
|
11455
11470
|
});
|
|
11456
11471
|
};
|
|
11457
|
-
this.multiCollectionDocumentFields = async () => {
|
|
11458
|
-
return astBuilder.FieldDefinition({
|
|
11459
|
-
name: "getDocumentFields",
|
|
11460
|
-
required: true,
|
|
11461
|
-
type: "JSON"
|
|
11462
|
-
});
|
|
11463
|
-
};
|
|
11464
11472
|
this.addMultiCollectionDocumentMutation = async () => {
|
|
11465
11473
|
return astBuilder.FieldDefinition({
|
|
11466
11474
|
name: "addPendingDocument",
|
|
@@ -11539,13 +11547,23 @@ var Builder = class {
|
|
|
11539
11547
|
type: astBuilder.TYPES.MultiCollectionDocument
|
|
11540
11548
|
});
|
|
11541
11549
|
};
|
|
11542
|
-
this.
|
|
11543
|
-
return
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11550
|
+
this.buildDeleteCollectionDocumentMutation = async (collections) => {
|
|
11551
|
+
return astBuilder.FieldDefinition({
|
|
11552
|
+
name: "deleteDocument",
|
|
11553
|
+
args: [
|
|
11554
|
+
astBuilder.InputValueDefinition({
|
|
11555
|
+
name: "collection",
|
|
11556
|
+
required: false,
|
|
11557
|
+
type: astBuilder.TYPES.String
|
|
11558
|
+
}),
|
|
11559
|
+
astBuilder.InputValueDefinition({
|
|
11560
|
+
name: "relativePath",
|
|
11561
|
+
required: true,
|
|
11562
|
+
type: astBuilder.TYPES.String
|
|
11563
|
+
})
|
|
11564
|
+
],
|
|
11565
|
+
required: true,
|
|
11566
|
+
type: astBuilder.TYPES.MultiCollectionDocument
|
|
11549
11567
|
});
|
|
11550
11568
|
};
|
|
11551
11569
|
this.collectionDocument = async (collection) => {
|
|
@@ -11719,42 +11737,59 @@ var Builder = class {
|
|
|
11719
11737
|
});
|
|
11720
11738
|
};
|
|
11721
11739
|
this.buildStaticDefinitions = () => staticDefinitions;
|
|
11722
|
-
this._buildCollectionDocumentType = async (collection) => {
|
|
11740
|
+
this._buildCollectionDocumentType = async (collection, suffix = "", extraFields = [], extraInterfaces = []) => {
|
|
11723
11741
|
const documentTypeName = NAMER.documentTypeName(collection.namespace);
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
|
|
11728
|
-
astBuilder.NamedType({ name: astBuilder.TYPES.Document })
|
|
11729
|
-
],
|
|
11730
|
-
fields: [
|
|
11742
|
+
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
11743
|
+
if (templateInfo.type === "union") {
|
|
11744
|
+
return this._buildObjectOrUnionData(__spreadValues({}, templateInfo), [
|
|
11731
11745
|
astBuilder.FieldDefinition({
|
|
11732
11746
|
name: "id",
|
|
11733
11747
|
required: true,
|
|
11734
11748
|
type: astBuilder.TYPES.ID
|
|
11735
11749
|
}),
|
|
11736
11750
|
astBuilder.FieldDefinition({
|
|
11737
|
-
name: "
|
|
11751
|
+
name: "_sys",
|
|
11738
11752
|
required: true,
|
|
11739
11753
|
type: astBuilder.TYPES.SystemInfo
|
|
11740
11754
|
}),
|
|
11755
|
+
...extraFields,
|
|
11741
11756
|
astBuilder.FieldDefinition({
|
|
11742
|
-
name: "
|
|
11757
|
+
name: "_values",
|
|
11743
11758
|
required: true,
|
|
11744
|
-
type:
|
|
11745
|
-
})
|
|
11759
|
+
type: "JSON"
|
|
11760
|
+
})
|
|
11761
|
+
], [
|
|
11762
|
+
astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
|
|
11763
|
+
astBuilder.NamedType({ name: astBuilder.TYPES.Document }),
|
|
11764
|
+
...extraInterfaces
|
|
11765
|
+
], collection);
|
|
11766
|
+
}
|
|
11767
|
+
const fields = templateInfo.template.fields;
|
|
11768
|
+
const templateFields = await sequential(fields, async (field) => {
|
|
11769
|
+
return this._buildDataField(field);
|
|
11770
|
+
});
|
|
11771
|
+
return astBuilder.ObjectTypeDefinition({
|
|
11772
|
+
name: documentTypeName + suffix,
|
|
11773
|
+
interfaces: [
|
|
11774
|
+
astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
|
|
11775
|
+
astBuilder.NamedType({ name: astBuilder.TYPES.Document }),
|
|
11776
|
+
...extraInterfaces
|
|
11777
|
+
],
|
|
11778
|
+
fields: [
|
|
11779
|
+
...templateFields,
|
|
11746
11780
|
astBuilder.FieldDefinition({
|
|
11747
|
-
name: "
|
|
11781
|
+
name: "id",
|
|
11748
11782
|
required: true,
|
|
11749
|
-
type:
|
|
11783
|
+
type: astBuilder.TYPES.ID
|
|
11750
11784
|
}),
|
|
11751
11785
|
astBuilder.FieldDefinition({
|
|
11752
|
-
name: "
|
|
11786
|
+
name: "_sys",
|
|
11753
11787
|
required: true,
|
|
11754
|
-
type:
|
|
11788
|
+
type: astBuilder.TYPES.SystemInfo
|
|
11755
11789
|
}),
|
|
11790
|
+
...extraFields,
|
|
11756
11791
|
astBuilder.FieldDefinition({
|
|
11757
|
-
name: "
|
|
11792
|
+
name: "_values",
|
|
11758
11793
|
required: true,
|
|
11759
11794
|
type: "JSON"
|
|
11760
11795
|
})
|
|
@@ -11817,9 +11852,21 @@ var Builder = class {
|
|
|
11817
11852
|
fieldName,
|
|
11818
11853
|
collections
|
|
11819
11854
|
}) => {
|
|
11820
|
-
const types =
|
|
11821
|
-
|
|
11822
|
-
|
|
11855
|
+
const types = [];
|
|
11856
|
+
collections.forEach((collection) => {
|
|
11857
|
+
if (collection.fields) {
|
|
11858
|
+
const typeName = NAMER.documentTypeName(collection.namespace);
|
|
11859
|
+
types.push(typeName);
|
|
11860
|
+
}
|
|
11861
|
+
if (collection.templates) {
|
|
11862
|
+
collection.templates.forEach((template) => {
|
|
11863
|
+
if (typeof template === "string") {
|
|
11864
|
+
throw new Error("Global templates not yet supported");
|
|
11865
|
+
}
|
|
11866
|
+
const typeName = NAMER.documentTypeName(template.namespace);
|
|
11867
|
+
types.push(typeName);
|
|
11868
|
+
});
|
|
11869
|
+
}
|
|
11823
11870
|
});
|
|
11824
11871
|
const type = astBuilder.UnionTypeDefinition({
|
|
11825
11872
|
name: fieldName,
|
|
@@ -12068,18 +12115,19 @@ var Builder = class {
|
|
|
12068
12115
|
})
|
|
12069
12116
|
});
|
|
12070
12117
|
};
|
|
12071
|
-
this._buildObjectOrUnionData = async (collectableTemplate) => {
|
|
12118
|
+
this._buildObjectOrUnionData = async (collectableTemplate, extraFields = [], extraInterfaces = [], collection) => {
|
|
12072
12119
|
if (collectableTemplate.type === "union") {
|
|
12073
12120
|
const name2 = NAMER.dataTypeName(collectableTemplate.namespace);
|
|
12074
12121
|
const typeMap = {};
|
|
12075
12122
|
const types = await sequential(collectableTemplate.templates, async (template) => {
|
|
12076
|
-
const type = await this._buildTemplateData(template);
|
|
12123
|
+
const type = await this._buildTemplateData(template, extraFields, extraInterfaces);
|
|
12077
12124
|
typeMap[template.namespace[template.namespace.length - 1]] = type.name.value;
|
|
12078
12125
|
return type;
|
|
12079
12126
|
});
|
|
12080
12127
|
await this.database.addToLookupMap({
|
|
12081
12128
|
type: name2,
|
|
12082
12129
|
resolveType: "unionData",
|
|
12130
|
+
collection: collection == null ? void 0 : collection.name,
|
|
12083
12131
|
typeMap
|
|
12084
12132
|
});
|
|
12085
12133
|
return astBuilder.UnionTypeDefinition({ name: name2, types });
|
|
@@ -12101,7 +12149,7 @@ var Builder = class {
|
|
|
12101
12149
|
fields: await sequential(collections, async (collection2) => {
|
|
12102
12150
|
return astBuilder.InputValueDefinition({
|
|
12103
12151
|
name: collection2.name,
|
|
12104
|
-
type:
|
|
12152
|
+
type: NAMER.dataFilterTypeName(collection2.namespace)
|
|
12105
12153
|
});
|
|
12106
12154
|
})
|
|
12107
12155
|
})
|
|
@@ -12144,6 +12192,7 @@ var Builder = class {
|
|
|
12144
12192
|
fields: [
|
|
12145
12193
|
astBuilder.FieldDefinition({
|
|
12146
12194
|
name: "pageInfo",
|
|
12195
|
+
required: true,
|
|
12147
12196
|
type: astBuilder.TYPES.PageInfo
|
|
12148
12197
|
}),
|
|
12149
12198
|
astBuilder.FieldDefinition({
|
|
@@ -12159,6 +12208,7 @@ var Builder = class {
|
|
|
12159
12208
|
fields: [
|
|
12160
12209
|
astBuilder.FieldDefinition({
|
|
12161
12210
|
name: "cursor",
|
|
12211
|
+
required: true,
|
|
12162
12212
|
type: astBuilder.TYPES.String
|
|
12163
12213
|
}),
|
|
12164
12214
|
astBuilder.FieldDefinition({ name: "node", type: nodeType })
|
|
@@ -12232,12 +12282,16 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
12232
12282
|
}
|
|
12233
12283
|
}
|
|
12234
12284
|
};
|
|
12235
|
-
this._buildTemplateData = async ({ namespace, fields }) => {
|
|
12285
|
+
this._buildTemplateData = async ({ namespace, fields }, extraFields = [], extraInterfaces = []) => {
|
|
12236
12286
|
return astBuilder.ObjectTypeDefinition({
|
|
12237
12287
|
name: NAMER.dataTypeName(namespace),
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12288
|
+
interfaces: extraInterfaces || [],
|
|
12289
|
+
fields: [
|
|
12290
|
+
...await sequential(fields, async (field) => {
|
|
12291
|
+
return this._buildDataField(field);
|
|
12292
|
+
}),
|
|
12293
|
+
...extraFields
|
|
12294
|
+
]
|
|
12241
12295
|
});
|
|
12242
12296
|
};
|
|
12243
12297
|
this.tinaSchema = config.tinaSchema;
|
|
@@ -12389,7 +12443,7 @@ var validateField = async (field) => {
|
|
|
12389
12443
|
|
|
12390
12444
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12391
12445
|
var name = "@tinacms/graphql";
|
|
12392
|
-
var version = "0.
|
|
12446
|
+
var version = "0.60.0";
|
|
12393
12447
|
var main = "dist/index.js";
|
|
12394
12448
|
var typings = "dist/index.d.ts";
|
|
12395
12449
|
var files = [
|
|
@@ -12790,9 +12844,8 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
12790
12844
|
queryTypeDefinitionFields.push(await builder.multiCollectionDocument(collections));
|
|
12791
12845
|
mutationTypeDefinitionFields.push(await builder.addMultiCollectionDocumentMutation());
|
|
12792
12846
|
mutationTypeDefinitionFields.push(await builder.buildUpdateCollectionDocumentMutation(collections));
|
|
12847
|
+
mutationTypeDefinitionFields.push(await builder.buildDeleteCollectionDocumentMutation(collections));
|
|
12793
12848
|
mutationTypeDefinitionFields.push(await builder.buildCreateCollectionDocumentMutation(collections));
|
|
12794
|
-
queryTypeDefinitionFields.push(await builder.multiCollectionDocumentList(collections));
|
|
12795
|
-
queryTypeDefinitionFields.push(await builder.multiCollectionDocumentFields());
|
|
12796
12849
|
await sequential(collections, async (collection) => {
|
|
12797
12850
|
queryTypeDefinitionFields.push(await builder.collectionDocument(collection));
|
|
12798
12851
|
mutationTypeDefinitionFields.push(await builder.updateCollectionDocumentMutation(collection));
|
|
@@ -12815,11 +12868,9 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
12815
12868
|
};
|
|
12816
12869
|
|
|
12817
12870
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
|
|
12818
|
-
var import_lodash6 = __toModule(require("lodash"));
|
|
12819
12871
|
var import_graphql3 = __toModule(require("graphql"));
|
|
12820
12872
|
|
|
12821
12873
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/index.ts
|
|
12822
|
-
var import_lodash5 = __toModule(require("lodash"));
|
|
12823
12874
|
var import_path3 = __toModule(require("path"));
|
|
12824
12875
|
var import_isValid = __toModule(require_isValid());
|
|
12825
12876
|
|
|
@@ -18926,7 +18977,7 @@ function createTokenizer(parser, initialize, from) {
|
|
|
18926
18977
|
function onsuccessfulconstruct(construct, info) {
|
|
18927
18978
|
addResult(construct, info.from);
|
|
18928
18979
|
}
|
|
18929
|
-
function onsuccessfulcheck(
|
|
18980
|
+
function onsuccessfulcheck(_4, info) {
|
|
18930
18981
|
info.restore();
|
|
18931
18982
|
}
|
|
18932
18983
|
function constructFactory(onreturn, fields) {
|
|
@@ -20069,12 +20120,12 @@ var visitParents = function(tree, test, visitor, reverse) {
|
|
|
20069
20120
|
let name2;
|
|
20070
20121
|
if (typeof value.type === "string") {
|
|
20071
20122
|
name2 = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
|
|
20072
|
-
Object.defineProperty(
|
|
20123
|
+
Object.defineProperty(visit2, "name", {
|
|
20073
20124
|
value: "node (" + color(value.type + (name2 ? "<" + name2 + ">" : "")) + ")"
|
|
20074
20125
|
});
|
|
20075
20126
|
}
|
|
20076
|
-
return
|
|
20077
|
-
function
|
|
20127
|
+
return visit2;
|
|
20128
|
+
function visit2() {
|
|
20078
20129
|
let result = [];
|
|
20079
20130
|
let subresult;
|
|
20080
20131
|
let offset;
|
|
@@ -20147,7 +20198,7 @@ var parseMDXInner = (tree, field) => {
|
|
|
20147
20198
|
if (!template) {
|
|
20148
20199
|
if ((0, import_lodash4.isNull)(node.name)) {
|
|
20149
20200
|
} else {
|
|
20150
|
-
throw new Error(`Found unregistered JSX or HTML: <${node.name}>. Please ensure all structured elements have been registered with your schema
|
|
20201
|
+
throw new Error(`Found unregistered JSX or HTML: <${node.name}>. Please ensure all structured elements have been registered with your schema. https://tina.io/docs/editing/mdx/`);
|
|
20151
20202
|
}
|
|
20152
20203
|
}
|
|
20153
20204
|
if (node.children.length > 0) {
|
|
@@ -20617,13 +20668,13 @@ function indentLines(value, map3) {
|
|
|
20617
20668
|
}
|
|
20618
20669
|
|
|
20619
20670
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
|
|
20620
|
-
function blockquote(node,
|
|
20671
|
+
function blockquote(node, _4, context) {
|
|
20621
20672
|
const exit2 = context.enter("blockquote");
|
|
20622
20673
|
const value = indentLines(containerFlow(node, context), map);
|
|
20623
20674
|
exit2();
|
|
20624
20675
|
return value;
|
|
20625
20676
|
}
|
|
20626
|
-
function map(line,
|
|
20677
|
+
function map(line, _4, blank) {
|
|
20627
20678
|
return ">" + (blank ? "" : " ") + line;
|
|
20628
20679
|
}
|
|
20629
20680
|
|
|
@@ -20648,7 +20699,7 @@ function listInScope(stack, list3, none) {
|
|
|
20648
20699
|
}
|
|
20649
20700
|
|
|
20650
20701
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/break.js
|
|
20651
|
-
function hardBreak(
|
|
20702
|
+
function hardBreak(_4, _1, context, safe2) {
|
|
20652
20703
|
let index2 = -1;
|
|
20653
20704
|
while (++index2 < context.unsafe.length) {
|
|
20654
20705
|
if (context.unsafe[index2].character === "\n" && patternInScope(context.stack, context.unsafe[index2])) {
|
|
@@ -20788,7 +20839,7 @@ function escapeBackslashes(value, after) {
|
|
|
20788
20839
|
}
|
|
20789
20840
|
|
|
20790
20841
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/code.js
|
|
20791
|
-
function code(node,
|
|
20842
|
+
function code(node, _4, context) {
|
|
20792
20843
|
const marker = checkFence(context);
|
|
20793
20844
|
const raw = node.value || "";
|
|
20794
20845
|
const suffix = marker === "`" ? "GraveAccent" : "Tilde";
|
|
@@ -20829,7 +20880,7 @@ function code(node, _6, context) {
|
|
|
20829
20880
|
exit2();
|
|
20830
20881
|
return value;
|
|
20831
20882
|
}
|
|
20832
|
-
function map2(line,
|
|
20883
|
+
function map2(line, _4, blank) {
|
|
20833
20884
|
return (blank ? "" : " ") + line;
|
|
20834
20885
|
}
|
|
20835
20886
|
|
|
@@ -20851,7 +20902,7 @@ function checkQuote(context) {
|
|
|
20851
20902
|
}
|
|
20852
20903
|
|
|
20853
20904
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/definition.js
|
|
20854
|
-
function definition2(node,
|
|
20905
|
+
function definition2(node, _4, context) {
|
|
20855
20906
|
const marker = checkQuote(context);
|
|
20856
20907
|
const suffix = marker === '"' ? "Quote" : "Apostrophe";
|
|
20857
20908
|
const exit2 = context.enter("definition");
|
|
@@ -20920,7 +20971,7 @@ function containerPhrasing(parent, context, safeOptions) {
|
|
|
20920
20971
|
|
|
20921
20972
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
20922
20973
|
emphasis.peek = emphasisPeek;
|
|
20923
|
-
function emphasis(node,
|
|
20974
|
+
function emphasis(node, _4, context) {
|
|
20924
20975
|
const marker = checkEmphasis(context);
|
|
20925
20976
|
const exit2 = context.enter("emphasis");
|
|
20926
20977
|
const value = containerPhrasing(node, context, {
|
|
@@ -20930,7 +20981,7 @@ function emphasis(node, _6, context) {
|
|
|
20930
20981
|
exit2();
|
|
20931
20982
|
return marker + value + marker;
|
|
20932
20983
|
}
|
|
20933
|
-
function emphasisPeek(
|
|
20984
|
+
function emphasisPeek(_4, _1, context) {
|
|
20934
20985
|
return context.options.emphasis || "*";
|
|
20935
20986
|
}
|
|
20936
20987
|
|
|
@@ -20947,7 +20998,7 @@ function formatHeadingAsSetext(node, context) {
|
|
|
20947
20998
|
}
|
|
20948
20999
|
|
|
20949
21000
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
20950
|
-
function heading(node,
|
|
21001
|
+
function heading(node, _4, context) {
|
|
20951
21002
|
const rank = Math.max(Math.min(6, node.depth || 1), 1);
|
|
20952
21003
|
if (formatHeadingAsSetext(node, context)) {
|
|
20953
21004
|
const exit3 = context.enter("headingSetext");
|
|
@@ -20984,7 +21035,7 @@ function htmlPeek() {
|
|
|
20984
21035
|
|
|
20985
21036
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/image.js
|
|
20986
21037
|
image.peek = imagePeek;
|
|
20987
|
-
function image(node,
|
|
21038
|
+
function image(node, _4, context) {
|
|
20988
21039
|
const quote = checkQuote(context);
|
|
20989
21040
|
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
20990
21041
|
const exit2 = context.enter("image");
|
|
@@ -21017,7 +21068,7 @@ function imagePeek() {
|
|
|
21017
21068
|
|
|
21018
21069
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
|
|
21019
21070
|
imageReference.peek = imageReferencePeek;
|
|
21020
|
-
function imageReference(node,
|
|
21071
|
+
function imageReference(node, _4, context) {
|
|
21021
21072
|
const type = node.referenceType;
|
|
21022
21073
|
const exit2 = context.enter("imageReference");
|
|
21023
21074
|
let subexit = context.enter("label");
|
|
@@ -21044,7 +21095,7 @@ function imageReferencePeek() {
|
|
|
21044
21095
|
|
|
21045
21096
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
|
|
21046
21097
|
inlineCode.peek = inlineCodePeek;
|
|
21047
|
-
function inlineCode(node,
|
|
21098
|
+
function inlineCode(node, _4, context) {
|
|
21048
21099
|
let value = node.value || "";
|
|
21049
21100
|
let sequence = "`";
|
|
21050
21101
|
let index2 = -1;
|
|
@@ -21082,7 +21133,7 @@ function formatLinkAsAutolink(node, context) {
|
|
|
21082
21133
|
|
|
21083
21134
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/link.js
|
|
21084
21135
|
link.peek = linkPeek;
|
|
21085
|
-
function link(node,
|
|
21136
|
+
function link(node, _4, context) {
|
|
21086
21137
|
const quote = checkQuote(context);
|
|
21087
21138
|
const suffix = quote === '"' ? "Quote" : "Apostrophe";
|
|
21088
21139
|
let exit2;
|
|
@@ -21121,13 +21172,13 @@ function link(node, _6, context) {
|
|
|
21121
21172
|
exit2();
|
|
21122
21173
|
return value;
|
|
21123
21174
|
}
|
|
21124
|
-
function linkPeek(node,
|
|
21175
|
+
function linkPeek(node, _4, context) {
|
|
21125
21176
|
return formatLinkAsAutolink(node, context) ? "<" : "[";
|
|
21126
21177
|
}
|
|
21127
21178
|
|
|
21128
21179
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
|
|
21129
21180
|
linkReference.peek = linkReferencePeek;
|
|
21130
|
-
function linkReference(node,
|
|
21181
|
+
function linkReference(node, _4, context) {
|
|
21131
21182
|
const type = node.referenceType;
|
|
21132
21183
|
const exit2 = context.enter("linkReference");
|
|
21133
21184
|
let subexit = context.enter("label");
|
|
@@ -21285,7 +21336,7 @@ function listItem(node, parent, context) {
|
|
|
21285
21336
|
}
|
|
21286
21337
|
|
|
21287
21338
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
|
|
21288
|
-
function paragraph(node,
|
|
21339
|
+
function paragraph(node, _4, context) {
|
|
21289
21340
|
const exit2 = context.enter("paragraph");
|
|
21290
21341
|
const subexit = context.enter("phrasing");
|
|
21291
21342
|
const value = containerPhrasing(node, context, { before: "\n", after: "\n" });
|
|
@@ -21295,7 +21346,7 @@ function paragraph(node, _6, context) {
|
|
|
21295
21346
|
}
|
|
21296
21347
|
|
|
21297
21348
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/root.js
|
|
21298
|
-
function root(node,
|
|
21349
|
+
function root(node, _4, context) {
|
|
21299
21350
|
return containerFlow(node, context);
|
|
21300
21351
|
}
|
|
21301
21352
|
|
|
@@ -21310,7 +21361,7 @@ function checkStrong(context) {
|
|
|
21310
21361
|
|
|
21311
21362
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/strong.js
|
|
21312
21363
|
strong.peek = strongPeek;
|
|
21313
|
-
function strong(node,
|
|
21364
|
+
function strong(node, _4, context) {
|
|
21314
21365
|
const marker = checkStrong(context);
|
|
21315
21366
|
const exit2 = context.enter("strong");
|
|
21316
21367
|
const value = containerPhrasing(node, context, {
|
|
@@ -21320,12 +21371,12 @@ function strong(node, _6, context) {
|
|
|
21320
21371
|
exit2();
|
|
21321
21372
|
return marker + marker + value + marker + marker;
|
|
21322
21373
|
}
|
|
21323
|
-
function strongPeek(
|
|
21374
|
+
function strongPeek(_4, _1, context) {
|
|
21324
21375
|
return context.options.strong || "*";
|
|
21325
21376
|
}
|
|
21326
21377
|
|
|
21327
21378
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/text.js
|
|
21328
|
-
function text3(node,
|
|
21379
|
+
function text3(node, _4, context, safeOptions) {
|
|
21329
21380
|
return safe(context, node.value, safeOptions);
|
|
21330
21381
|
}
|
|
21331
21382
|
|
|
@@ -21339,7 +21390,7 @@ function checkRuleRepetition(context) {
|
|
|
21339
21390
|
}
|
|
21340
21391
|
|
|
21341
21392
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
|
|
21342
|
-
function thematicBreak2(
|
|
21393
|
+
function thematicBreak2(_4, _1, context) {
|
|
21343
21394
|
const value = (checkRule(context) + (context.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(context));
|
|
21344
21395
|
return context.options.ruleSpaces ? value.slice(0, -1) : value;
|
|
21345
21396
|
}
|
|
@@ -21842,7 +21893,7 @@ var mdxJsxToMarkdown = {
|
|
|
21842
21893
|
fences: true,
|
|
21843
21894
|
resourceLink: true
|
|
21844
21895
|
};
|
|
21845
|
-
function mdxElement(node,
|
|
21896
|
+
function mdxElement(node, _4, context) {
|
|
21846
21897
|
const selfClosing = node.name && (!node.children || node.children.length === 0);
|
|
21847
21898
|
const quote = checkQuote(context);
|
|
21848
21899
|
const exit2 = context.enter(node.type);
|
|
@@ -21878,7 +21929,7 @@ function peekElement() {
|
|
|
21878
21929
|
}
|
|
21879
21930
|
function indent(value) {
|
|
21880
21931
|
return indentLines(value, map3);
|
|
21881
|
-
function map3(line,
|
|
21932
|
+
function map3(line, _4, blank) {
|
|
21882
21933
|
return (blank ? "" : " ") + line;
|
|
21883
21934
|
}
|
|
21884
21935
|
}
|
|
@@ -22430,22 +22481,16 @@ var Resolver = class {
|
|
|
22430
22481
|
} = import_path3.default.parse(fullPath);
|
|
22431
22482
|
const relativePath = fullPath.replace("\\", "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
|
|
22432
22483
|
const breadcrumbs = relativePath.replace(extension2, "").split("/");
|
|
22433
|
-
const form = {
|
|
22434
|
-
label: collection.label,
|
|
22435
|
-
name: basename,
|
|
22436
|
-
fields: await sequential(template.fields, async (field) => {
|
|
22437
|
-
return this.resolveField(field);
|
|
22438
|
-
})
|
|
22439
|
-
};
|
|
22440
22484
|
const data = {
|
|
22441
22485
|
_collection: rawData._collection,
|
|
22442
22486
|
_template: rawData._template
|
|
22443
22487
|
};
|
|
22444
22488
|
await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
|
|
22445
|
-
return {
|
|
22446
|
-
__typename: NAMER.documentTypeName(
|
|
22447
|
-
id: fullPath
|
|
22448
|
-
|
|
22489
|
+
return __spreadProps(__spreadValues({
|
|
22490
|
+
__typename: collection.fields ? NAMER.documentTypeName(collection.namespace) : NAMER.documentTypeName(template.namespace),
|
|
22491
|
+
id: fullPath
|
|
22492
|
+
}, data), {
|
|
22493
|
+
_sys: {
|
|
22449
22494
|
basename,
|
|
22450
22495
|
filename,
|
|
22451
22496
|
extension: extension2,
|
|
@@ -22455,11 +22500,8 @@ var Resolver = class {
|
|
|
22455
22500
|
collection,
|
|
22456
22501
|
template: lastItem(template.namespace)
|
|
22457
22502
|
},
|
|
22458
|
-
data
|
|
22459
|
-
|
|
22460
|
-
dataJSON: data,
|
|
22461
|
-
form
|
|
22462
|
-
};
|
|
22503
|
+
_values: data
|
|
22504
|
+
});
|
|
22463
22505
|
} catch (e) {
|
|
22464
22506
|
if (e instanceof TinaError) {
|
|
22465
22507
|
throw new TinaError(e.message, __spreadValues({
|
|
@@ -22469,50 +22511,11 @@ var Resolver = class {
|
|
|
22469
22511
|
throw e;
|
|
22470
22512
|
}
|
|
22471
22513
|
};
|
|
22472
|
-
this.
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
const collections = await this.tinaSchema.getCollections();
|
|
22476
|
-
await sequential(collections, async (collection) => {
|
|
22477
|
-
const collectable = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
22478
|
-
switch (collectable.type) {
|
|
22479
|
-
case "object":
|
|
22480
|
-
if (collectable.required) {
|
|
22481
|
-
console.warn("WARNING: `{type: 'object', required: true}` is unsupported by our User Interface and could result in errors");
|
|
22482
|
-
}
|
|
22483
|
-
response[collection.name] = {
|
|
22484
|
-
collection,
|
|
22485
|
-
fields: await sequential(collectable.template.fields, async (field) => {
|
|
22486
|
-
return this.resolveField(field);
|
|
22487
|
-
}),
|
|
22488
|
-
mutationInfo: {
|
|
22489
|
-
includeCollection: true,
|
|
22490
|
-
includeTemplate: false
|
|
22491
|
-
}
|
|
22492
|
-
};
|
|
22493
|
-
break;
|
|
22494
|
-
case "union":
|
|
22495
|
-
const templates = {};
|
|
22496
|
-
await sequential(collectable.templates, async (template) => {
|
|
22497
|
-
templates[lastItem(template.namespace)] = {
|
|
22498
|
-
template,
|
|
22499
|
-
fields: await sequential(template.fields, async (field) => {
|
|
22500
|
-
return this.resolveField(field);
|
|
22501
|
-
})
|
|
22502
|
-
};
|
|
22503
|
-
});
|
|
22504
|
-
response[collection.name] = {
|
|
22505
|
-
collection,
|
|
22506
|
-
templates,
|
|
22507
|
-
mutationInfo: { includeCollection: true, includeTemplate: true }
|
|
22508
|
-
};
|
|
22509
|
-
break;
|
|
22510
|
-
}
|
|
22511
|
-
});
|
|
22512
|
-
return response;
|
|
22513
|
-
} catch (e) {
|
|
22514
|
-
throw e;
|
|
22514
|
+
this.deleteDocument = async (fullPath) => {
|
|
22515
|
+
if (typeof fullPath !== "string") {
|
|
22516
|
+
throw new Error(`fullPath must be of type string for getDocument request`);
|
|
22515
22517
|
}
|
|
22518
|
+
await this.database.delete(fullPath);
|
|
22516
22519
|
};
|
|
22517
22520
|
this.buildObjectMutations = (fieldValue, field) => {
|
|
22518
22521
|
if (field.fields) {
|
|
@@ -22593,7 +22596,7 @@ var Resolver = class {
|
|
|
22593
22596
|
return this.getDocument(realPath);
|
|
22594
22597
|
}
|
|
22595
22598
|
const params = this.buildObjectMutations(args.params[collection.name], collection);
|
|
22596
|
-
await this.database.put(realPath, params);
|
|
22599
|
+
await this.database.put(realPath, params, collection.name);
|
|
22597
22600
|
return this.getDocument(realPath);
|
|
22598
22601
|
};
|
|
22599
22602
|
this.updateResolveDocument = async ({
|
|
@@ -22610,7 +22613,7 @@ var Resolver = class {
|
|
|
22610
22613
|
case "object":
|
|
22611
22614
|
if (params2) {
|
|
22612
22615
|
const values = this.buildFieldMutations(params2, templateInfo.template);
|
|
22613
|
-
await this.database.put(realPath, values);
|
|
22616
|
+
await this.database.put(realPath, values, collection.name);
|
|
22614
22617
|
}
|
|
22615
22618
|
break;
|
|
22616
22619
|
case "union":
|
|
@@ -22623,14 +22626,14 @@ var Resolver = class {
|
|
|
22623
22626
|
const values = __spreadProps(__spreadValues({}, this.buildFieldMutations(templateParams, template)), {
|
|
22624
22627
|
_template: lastItem(template.namespace)
|
|
22625
22628
|
});
|
|
22626
|
-
await this.database.put(realPath, values);
|
|
22629
|
+
await this.database.put(realPath, values, collection.name);
|
|
22627
22630
|
}
|
|
22628
22631
|
});
|
|
22629
22632
|
}
|
|
22630
22633
|
return this.getDocument(realPath);
|
|
22631
22634
|
}
|
|
22632
22635
|
const params = this.buildObjectMutations(isCollectionSpecific ? args.params : args.params[collection.name], collection);
|
|
22633
|
-
await this.database.put(realPath, params);
|
|
22636
|
+
await this.database.put(realPath, params, collection.name);
|
|
22634
22637
|
return this.getDocument(realPath);
|
|
22635
22638
|
};
|
|
22636
22639
|
this.resolveDocument = async ({
|
|
@@ -22638,6 +22641,7 @@ var Resolver = class {
|
|
|
22638
22641
|
collection: collectionName,
|
|
22639
22642
|
isMutation,
|
|
22640
22643
|
isCreation,
|
|
22644
|
+
isDeletion,
|
|
22641
22645
|
isAddPendingDocument,
|
|
22642
22646
|
isCollectionSpecific
|
|
22643
22647
|
}) => {
|
|
@@ -22665,6 +22669,14 @@ var Resolver = class {
|
|
|
22665
22669
|
isAddPendingDocument
|
|
22666
22670
|
});
|
|
22667
22671
|
}
|
|
22672
|
+
if (isDeletion) {
|
|
22673
|
+
if (!alreadyExists) {
|
|
22674
|
+
throw new Error(`Unable to delete document, ${realPath} does not exist`);
|
|
22675
|
+
}
|
|
22676
|
+
const doc = await this.getDocument(realPath);
|
|
22677
|
+
await this.deleteDocument(realPath);
|
|
22678
|
+
return doc;
|
|
22679
|
+
}
|
|
22668
22680
|
if (alreadyExists === false) {
|
|
22669
22681
|
throw new Error(`Unable to update document, ${realPath} does not exist`);
|
|
22670
22682
|
}
|
|
@@ -22891,137 +22903,6 @@ var Resolver = class {
|
|
|
22891
22903
|
}));
|
|
22892
22904
|
return args.params;
|
|
22893
22905
|
};
|
|
22894
|
-
this.resolveField = async (_c) => {
|
|
22895
|
-
var _d = _c, {
|
|
22896
|
-
namespace
|
|
22897
|
-
} = _d, field = __objRest(_d, [
|
|
22898
|
-
"namespace"
|
|
22899
|
-
]);
|
|
22900
|
-
field.parentTypename = NAMER.dataTypeName(namespace.filter((_6, i) => i < namespace.length - 1));
|
|
22901
|
-
const extraFields = field.ui || {};
|
|
22902
|
-
switch (field.type) {
|
|
22903
|
-
case "number":
|
|
22904
|
-
return __spreadValues(__spreadValues({
|
|
22905
|
-
component: "number"
|
|
22906
|
-
}, field), extraFields);
|
|
22907
|
-
case "datetime":
|
|
22908
|
-
return __spreadValues(__spreadValues({
|
|
22909
|
-
component: "date"
|
|
22910
|
-
}, field), extraFields);
|
|
22911
|
-
case "boolean":
|
|
22912
|
-
return __spreadValues(__spreadValues({
|
|
22913
|
-
component: "toggle"
|
|
22914
|
-
}, field), extraFields);
|
|
22915
|
-
case "image":
|
|
22916
|
-
return __spreadValues(__spreadValues({
|
|
22917
|
-
component: "image",
|
|
22918
|
-
clearable: true
|
|
22919
|
-
}, field), extraFields);
|
|
22920
|
-
case "string":
|
|
22921
|
-
if (field.options) {
|
|
22922
|
-
if (field.list) {
|
|
22923
|
-
return __spreadProps(__spreadValues(__spreadValues({
|
|
22924
|
-
component: "checkbox-group"
|
|
22925
|
-
}, field), extraFields), {
|
|
22926
|
-
options: field.options
|
|
22927
|
-
});
|
|
22928
|
-
}
|
|
22929
|
-
return __spreadProps(__spreadValues(__spreadValues({
|
|
22930
|
-
component: "select"
|
|
22931
|
-
}, field), extraFields), {
|
|
22932
|
-
options: [
|
|
22933
|
-
{ label: `Choose an option`, value: "" },
|
|
22934
|
-
...field.options
|
|
22935
|
-
]
|
|
22936
|
-
});
|
|
22937
|
-
}
|
|
22938
|
-
if (field.list) {
|
|
22939
|
-
return __spreadValues(__spreadValues({
|
|
22940
|
-
component: "list",
|
|
22941
|
-
field: {
|
|
22942
|
-
component: "text"
|
|
22943
|
-
}
|
|
22944
|
-
}, field), extraFields);
|
|
22945
|
-
}
|
|
22946
|
-
return __spreadValues(__spreadValues({
|
|
22947
|
-
component: "text"
|
|
22948
|
-
}, field), extraFields);
|
|
22949
|
-
case "object":
|
|
22950
|
-
const templateInfo = this.tinaSchema.getTemplatesForCollectable(__spreadProps(__spreadValues({}, field), {
|
|
22951
|
-
namespace
|
|
22952
|
-
}));
|
|
22953
|
-
if (templateInfo.type === "object") {
|
|
22954
|
-
return __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
22955
|
-
component: field.list ? "group-list" : "group",
|
|
22956
|
-
fields: await sequential(templateInfo.template.fields, async (field2) => await this.resolveField(field2))
|
|
22957
|
-
}), extraFields);
|
|
22958
|
-
} else if (templateInfo.type === "union") {
|
|
22959
|
-
const templates2 = {};
|
|
22960
|
-
const typeMap2 = {};
|
|
22961
|
-
await sequential(templateInfo.templates, async (template) => {
|
|
22962
|
-
const extraFields2 = template.ui || {};
|
|
22963
|
-
const templateName = lastItem(template.namespace);
|
|
22964
|
-
typeMap2[templateName] = NAMER.dataTypeName(template.namespace);
|
|
22965
|
-
templates2[lastItem(template.namespace)] = __spreadValues({
|
|
22966
|
-
label: template.label || templateName,
|
|
22967
|
-
key: templateName,
|
|
22968
|
-
fields: await sequential(template.fields, async (field2) => await this.resolveField(field2))
|
|
22969
|
-
}, extraFields2);
|
|
22970
|
-
return true;
|
|
22971
|
-
});
|
|
22972
|
-
return __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
22973
|
-
typeMap: typeMap2,
|
|
22974
|
-
component: field.list ? "blocks" : "not-implemented",
|
|
22975
|
-
templates: templates2
|
|
22976
|
-
}), extraFields);
|
|
22977
|
-
} else {
|
|
22978
|
-
throw new Error(`Unknown object for resolveField function`);
|
|
22979
|
-
}
|
|
22980
|
-
case "rich-text":
|
|
22981
|
-
const templates = {};
|
|
22982
|
-
const typeMap = {};
|
|
22983
|
-
await sequential(field.templates, async (template) => {
|
|
22984
|
-
if (typeof template === "string") {
|
|
22985
|
-
throw new Error(`Global templates not yet supported for rich-text`);
|
|
22986
|
-
} else {
|
|
22987
|
-
const extraFields2 = template.ui || {};
|
|
22988
|
-
const templateName = lastItem(template.namespace);
|
|
22989
|
-
typeMap[templateName] = NAMER.dataTypeName(template.namespace);
|
|
22990
|
-
templates[lastItem(template.namespace)] = __spreadValues({
|
|
22991
|
-
label: template.label || templateName,
|
|
22992
|
-
key: templateName,
|
|
22993
|
-
inline: template.inline,
|
|
22994
|
-
name: templateName,
|
|
22995
|
-
fields: await sequential(template.fields, async (field2) => await this.resolveField(field2))
|
|
22996
|
-
}, extraFields2);
|
|
22997
|
-
return true;
|
|
22998
|
-
}
|
|
22999
|
-
});
|
|
23000
|
-
return __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
23001
|
-
templates: Object.values(templates),
|
|
23002
|
-
component: "rich-text"
|
|
23003
|
-
}), extraFields);
|
|
23004
|
-
case "reference":
|
|
23005
|
-
const documents = import_lodash5.default.flatten(await sequential(field.collections, async (collectionName) => {
|
|
23006
|
-
const collection = this.tinaSchema.getCollection(collectionName);
|
|
23007
|
-
return this.database.store.glob(collection.path);
|
|
23008
|
-
}));
|
|
23009
|
-
return __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
23010
|
-
component: "reference",
|
|
23011
|
-
options: [
|
|
23012
|
-
{ label: "Choose an option", value: "" },
|
|
23013
|
-
...documents.map((document3) => {
|
|
23014
|
-
return {
|
|
23015
|
-
value: document3,
|
|
23016
|
-
label: document3
|
|
23017
|
-
};
|
|
23018
|
-
})
|
|
23019
|
-
]
|
|
23020
|
-
}), extraFields);
|
|
23021
|
-
default:
|
|
23022
|
-
throw new Error(`Unknown field type ${field.type}`);
|
|
23023
|
-
}
|
|
23024
|
-
};
|
|
23025
22906
|
this.database = init.database;
|
|
23026
22907
|
this.tinaSchema = init.tinaSchema;
|
|
23027
22908
|
}
|
|
@@ -23069,46 +22950,6 @@ var resolve = async ({
|
|
|
23069
22950
|
const config = await database.getTinaSchema();
|
|
23070
22951
|
const tinaSchema = await createSchema({ schema: config });
|
|
23071
22952
|
const resolver2 = await createResolver2({ database, tinaSchema });
|
|
23072
|
-
const paths = [];
|
|
23073
|
-
const mutationPaths = [];
|
|
23074
|
-
const ast = (0, import_graphql3.parse)(query);
|
|
23075
|
-
const typeInfo = new import_graphql3.TypeInfo(graphQLSchema);
|
|
23076
|
-
const referencePathVisitor = () => {
|
|
23077
|
-
return {
|
|
23078
|
-
leave: {
|
|
23079
|
-
Field(node, key2, parent, path6, ancestors) {
|
|
23080
|
-
const type = typeInfo.getType();
|
|
23081
|
-
if (type) {
|
|
23082
|
-
const realType = (0, import_graphql3.getNamedType)(type);
|
|
23083
|
-
if (realType instanceof import_graphql3.GraphQLUnionType) {
|
|
23084
|
-
const hasNodeInterface = !!realType.getTypes().find((objectType) => objectType.getInterfaces().find((intfc) => intfc.name === "Node"));
|
|
23085
|
-
if (hasNodeInterface) {
|
|
23086
|
-
const p = [];
|
|
23087
|
-
ancestors.forEach((item, index2) => {
|
|
23088
|
-
var _a;
|
|
23089
|
-
const activePath = path6[index2];
|
|
23090
|
-
const result = item[activePath];
|
|
23091
|
-
if ((_a = result == null ? void 0 : result.name) == null ? void 0 : _a.value) {
|
|
23092
|
-
if (result.kind === "Field") {
|
|
23093
|
-
p.push(result.name.value);
|
|
23094
|
-
}
|
|
23095
|
-
}
|
|
23096
|
-
});
|
|
23097
|
-
const referenceQuery = buildReferenceQuery(node, [
|
|
23098
|
-
...p,
|
|
23099
|
-
node.name.value
|
|
23100
|
-
]);
|
|
23101
|
-
if (referenceQuery) {
|
|
23102
|
-
paths.push(referenceQuery);
|
|
23103
|
-
}
|
|
23104
|
-
}
|
|
23105
|
-
}
|
|
23106
|
-
}
|
|
23107
|
-
}
|
|
23108
|
-
}
|
|
23109
|
-
};
|
|
23110
|
-
};
|
|
23111
|
-
(0, import_graphql3.visit)(ast, (0, import_graphql3.visitWithTypeInfo)(typeInfo, referencePathVisitor()));
|
|
23112
22953
|
const res = await (0, import_graphql3.graphql)({
|
|
23113
22954
|
schema: graphQLSchema,
|
|
23114
22955
|
source: query,
|
|
@@ -23137,9 +22978,9 @@ var resolve = async ({
|
|
|
23137
22978
|
if (value) {
|
|
23138
22979
|
return value;
|
|
23139
22980
|
}
|
|
23140
|
-
if (info.fieldName === "
|
|
23141
|
-
const
|
|
23142
|
-
const hasDocuments2 =
|
|
22981
|
+
if (info.fieldName === "collections") {
|
|
22982
|
+
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
22983
|
+
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23143
22984
|
var _a;
|
|
23144
22985
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
23145
22986
|
});
|
|
@@ -23147,16 +22988,13 @@ var resolve = async ({
|
|
|
23147
22988
|
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
23148
22989
|
});
|
|
23149
22990
|
}
|
|
23150
|
-
const
|
|
23151
|
-
const hasDocuments =
|
|
22991
|
+
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
22992
|
+
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23152
22993
|
var _a;
|
|
23153
22994
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
23154
22995
|
});
|
|
23155
22996
|
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
23156
22997
|
}
|
|
23157
|
-
if (info.fieldName === "getDocumentFields") {
|
|
23158
|
-
return resolver2.getDocumentFields();
|
|
23159
|
-
}
|
|
23160
22998
|
if (info.fieldName === "getOptimizedQuery") {
|
|
23161
22999
|
try {
|
|
23162
23000
|
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
@@ -23190,23 +23028,21 @@ var resolve = async ({
|
|
|
23190
23028
|
isAddPendingDocument: true
|
|
23191
23029
|
});
|
|
23192
23030
|
}
|
|
23193
|
-
if ([
|
|
23031
|
+
if ([
|
|
23032
|
+
NAMER.documentQueryName(),
|
|
23033
|
+
"createDocument",
|
|
23034
|
+
"updateDocument",
|
|
23035
|
+
"deleteDocument"
|
|
23036
|
+
].includes(info.fieldName)) {
|
|
23194
23037
|
const result2 = await resolver2.resolveDocument({
|
|
23195
23038
|
args,
|
|
23196
23039
|
collection: args.collection,
|
|
23197
23040
|
isMutation,
|
|
23198
23041
|
isCreation,
|
|
23042
|
+
isDeletion: info.fieldName === "deleteDocument",
|
|
23199
23043
|
isAddPendingDocument: false,
|
|
23200
23044
|
isCollectionSpecific: false
|
|
23201
23045
|
});
|
|
23202
|
-
if (!isMutation) {
|
|
23203
|
-
const mutationPath = buildMutationPath(info, {
|
|
23204
|
-
relativePath: result2.sys.relativePath
|
|
23205
|
-
});
|
|
23206
|
-
if (mutationPath) {
|
|
23207
|
-
mutationPaths.push(mutationPath);
|
|
23208
|
-
}
|
|
23209
|
-
}
|
|
23210
23046
|
return result2;
|
|
23211
23047
|
}
|
|
23212
23048
|
return value;
|
|
@@ -23233,15 +23069,6 @@ var resolve = async ({
|
|
|
23233
23069
|
isAddPendingDocument: false,
|
|
23234
23070
|
isCollectionSpecific: true
|
|
23235
23071
|
});
|
|
23236
|
-
if (!isMutation) {
|
|
23237
|
-
const mutationPath = buildMutationPath(info, {
|
|
23238
|
-
collection: tinaSchema.getCollection(lookup.collection),
|
|
23239
|
-
relativePath: result.sys.relativePath
|
|
23240
|
-
});
|
|
23241
|
-
if (mutationPath) {
|
|
23242
|
-
mutationPaths.push(mutationPath);
|
|
23243
|
-
}
|
|
23244
|
-
}
|
|
23245
23072
|
return result;
|
|
23246
23073
|
case "collectionDocumentList":
|
|
23247
23074
|
return resolver2.resolveCollectionConnection({
|
|
@@ -23249,6 +23076,19 @@ var resolve = async ({
|
|
|
23249
23076
|
collection: tinaSchema.getCollection(lookup.collection)
|
|
23250
23077
|
});
|
|
23251
23078
|
case "unionData":
|
|
23079
|
+
if (!value) {
|
|
23080
|
+
if (args.relativePath) {
|
|
23081
|
+
const result2 = await resolver2.resolveDocument({
|
|
23082
|
+
args,
|
|
23083
|
+
collection: lookup.collection,
|
|
23084
|
+
isMutation,
|
|
23085
|
+
isCreation,
|
|
23086
|
+
isAddPendingDocument: false,
|
|
23087
|
+
isCollectionSpecific: true
|
|
23088
|
+
});
|
|
23089
|
+
return result2;
|
|
23090
|
+
}
|
|
23091
|
+
}
|
|
23252
23092
|
return value;
|
|
23253
23093
|
default:
|
|
23254
23094
|
console.error(lookup);
|
|
@@ -23256,18 +23096,6 @@ var resolve = async ({
|
|
|
23256
23096
|
}
|
|
23257
23097
|
}
|
|
23258
23098
|
});
|
|
23259
|
-
paths.forEach((p) => {
|
|
23260
|
-
const item = import_lodash6.default.get(res, p.path.slice(0, 3));
|
|
23261
|
-
if (item) {
|
|
23262
|
-
item.paths = [...item.paths || [], p];
|
|
23263
|
-
}
|
|
23264
|
-
});
|
|
23265
|
-
mutationPaths.forEach((mutationPath) => {
|
|
23266
|
-
const item = import_lodash6.default.get(res, mutationPath.path);
|
|
23267
|
-
if (item) {
|
|
23268
|
-
item.mutationInfo = mutationPath;
|
|
23269
|
-
}
|
|
23270
|
-
});
|
|
23271
23099
|
if (res.errors) {
|
|
23272
23100
|
if (!silenceErrors) {
|
|
23273
23101
|
console.error(res.errors);
|
|
@@ -23287,213 +23115,6 @@ var resolve = async ({
|
|
|
23287
23115
|
}
|
|
23288
23116
|
}
|
|
23289
23117
|
};
|
|
23290
|
-
var buildPath = (path6, accum) => {
|
|
23291
|
-
if (path6.prev) {
|
|
23292
|
-
buildPath(path6.prev, accum);
|
|
23293
|
-
}
|
|
23294
|
-
accum.push(path6.key);
|
|
23295
|
-
return accum;
|
|
23296
|
-
};
|
|
23297
|
-
var buildReferenceQuery = (fieldNode, path6) => {
|
|
23298
|
-
if (fieldNode) {
|
|
23299
|
-
const p = path6.map((item) => item === "data" ? "form" : item);
|
|
23300
|
-
const dataPath = path6;
|
|
23301
|
-
const newNode = __spreadProps(__spreadValues({}, fieldNode), {
|
|
23302
|
-
name: { kind: "Name", value: "node" },
|
|
23303
|
-
arguments: [
|
|
23304
|
-
{
|
|
23305
|
-
kind: "Argument",
|
|
23306
|
-
name: {
|
|
23307
|
-
kind: "Name",
|
|
23308
|
-
value: "id"
|
|
23309
|
-
},
|
|
23310
|
-
value: {
|
|
23311
|
-
kind: "Variable",
|
|
23312
|
-
name: {
|
|
23313
|
-
kind: "Name",
|
|
23314
|
-
value: "id"
|
|
23315
|
-
}
|
|
23316
|
-
}
|
|
23317
|
-
}
|
|
23318
|
-
]
|
|
23319
|
-
});
|
|
23320
|
-
const q = {
|
|
23321
|
-
kind: "OperationDefinition",
|
|
23322
|
-
operation: "query",
|
|
23323
|
-
name: {
|
|
23324
|
-
value: "GetNode",
|
|
23325
|
-
kind: "Name"
|
|
23326
|
-
},
|
|
23327
|
-
variableDefinitions: [
|
|
23328
|
-
{
|
|
23329
|
-
kind: "VariableDefinition",
|
|
23330
|
-
variable: {
|
|
23331
|
-
kind: "Variable",
|
|
23332
|
-
name: {
|
|
23333
|
-
kind: "Name",
|
|
23334
|
-
value: "id"
|
|
23335
|
-
}
|
|
23336
|
-
},
|
|
23337
|
-
type: {
|
|
23338
|
-
kind: "NonNullType",
|
|
23339
|
-
type: {
|
|
23340
|
-
kind: "NamedType",
|
|
23341
|
-
name: {
|
|
23342
|
-
kind: "Name",
|
|
23343
|
-
value: "String"
|
|
23344
|
-
}
|
|
23345
|
-
}
|
|
23346
|
-
}
|
|
23347
|
-
}
|
|
23348
|
-
],
|
|
23349
|
-
selectionSet: {
|
|
23350
|
-
kind: "SelectionSet",
|
|
23351
|
-
selections: [newNode]
|
|
23352
|
-
}
|
|
23353
|
-
};
|
|
23354
|
-
const queryString = (0, import_graphql3.print)(q);
|
|
23355
|
-
return {
|
|
23356
|
-
path: ["data", ...p.slice(0, -1)],
|
|
23357
|
-
dataPath,
|
|
23358
|
-
queryString
|
|
23359
|
-
};
|
|
23360
|
-
}
|
|
23361
|
-
};
|
|
23362
|
-
var buildMutationPath = (info, {
|
|
23363
|
-
collection,
|
|
23364
|
-
relativePath
|
|
23365
|
-
}) => {
|
|
23366
|
-
var _a, _b, _c;
|
|
23367
|
-
const queryNode = info.fieldNodes.find((fn) => fn.name.value === info.fieldName);
|
|
23368
|
-
if (!queryNode) {
|
|
23369
|
-
throw new Error(`exptected to find field node for ${info.fieldName}`);
|
|
23370
|
-
}
|
|
23371
|
-
const mutationName = collection ? NAMER.updateName([collection.name]) : "updateDocument";
|
|
23372
|
-
const mutations = JSON.parse(JSON.stringify((_a = info.schema.getMutationType()) == null ? void 0 : _a.getFields()));
|
|
23373
|
-
const mutation = mutations[mutationName];
|
|
23374
|
-
if (!mutation) {
|
|
23375
|
-
throw new Error(`exptected to find mutation for ${mutationName}`);
|
|
23376
|
-
}
|
|
23377
|
-
const mutationNode = mutations[mutationName].astNode;
|
|
23378
|
-
const newNode = __spreadProps(__spreadValues({}, queryNode), {
|
|
23379
|
-
name: { kind: "Name", value: mutation.name },
|
|
23380
|
-
arguments: (_b = mutationNode == null ? void 0 : mutationNode.arguments) == null ? void 0 : _b.map((argument) => {
|
|
23381
|
-
if (argument.name.value === "relativePath") {
|
|
23382
|
-
return {
|
|
23383
|
-
kind: "Argument",
|
|
23384
|
-
name: {
|
|
23385
|
-
kind: "Name",
|
|
23386
|
-
value: argument.name.value
|
|
23387
|
-
},
|
|
23388
|
-
value: {
|
|
23389
|
-
kind: "StringValue",
|
|
23390
|
-
value: relativePath
|
|
23391
|
-
}
|
|
23392
|
-
};
|
|
23393
|
-
}
|
|
23394
|
-
return {
|
|
23395
|
-
kind: "Argument",
|
|
23396
|
-
name: {
|
|
23397
|
-
kind: "Name",
|
|
23398
|
-
value: argument.name.value
|
|
23399
|
-
},
|
|
23400
|
-
value: {
|
|
23401
|
-
kind: "Variable",
|
|
23402
|
-
name: {
|
|
23403
|
-
kind: "Name",
|
|
23404
|
-
value: argument.name.value
|
|
23405
|
-
}
|
|
23406
|
-
}
|
|
23407
|
-
};
|
|
23408
|
-
})
|
|
23409
|
-
});
|
|
23410
|
-
const paramArgs = (_c = mutationNode == null ? void 0 : mutationNode.arguments) == null ? void 0 : _c.find((arg) => arg.name.value === "params");
|
|
23411
|
-
if (!paramArgs) {
|
|
23412
|
-
throw new Error(`Expected to find argument named params for mutation ${mutationName}`);
|
|
23413
|
-
}
|
|
23414
|
-
const q = {
|
|
23415
|
-
kind: "OperationDefinition",
|
|
23416
|
-
operation: "mutation",
|
|
23417
|
-
name: {
|
|
23418
|
-
value: "UpdateDocument",
|
|
23419
|
-
kind: "Name"
|
|
23420
|
-
},
|
|
23421
|
-
variableDefinitions: [
|
|
23422
|
-
{
|
|
23423
|
-
kind: "VariableDefinition",
|
|
23424
|
-
variable: {
|
|
23425
|
-
kind: "Variable",
|
|
23426
|
-
name: {
|
|
23427
|
-
kind: "Name",
|
|
23428
|
-
value: "params"
|
|
23429
|
-
}
|
|
23430
|
-
},
|
|
23431
|
-
type: paramArgs == null ? void 0 : paramArgs.type
|
|
23432
|
-
}
|
|
23433
|
-
],
|
|
23434
|
-
selectionSet: {
|
|
23435
|
-
kind: "SelectionSet",
|
|
23436
|
-
selections: [newNode]
|
|
23437
|
-
}
|
|
23438
|
-
};
|
|
23439
|
-
const mutationString = addFragmentsToQuery(info, newNode, q);
|
|
23440
|
-
return {
|
|
23441
|
-
path: ["data", ...buildPath(info.path, []), "form"],
|
|
23442
|
-
string: mutationString,
|
|
23443
|
-
includeCollection: collection ? false : true,
|
|
23444
|
-
includeTemplate: collection ? !!collection.templates : false
|
|
23445
|
-
};
|
|
23446
|
-
};
|
|
23447
|
-
function addFragmentsToQuery(info, fieldNode, q) {
|
|
23448
|
-
const fragmentSpreadVisitor = (frag) => {
|
|
23449
|
-
return {
|
|
23450
|
-
leave: {
|
|
23451
|
-
FragmentSpread(node) {
|
|
23452
|
-
frag.subFrags.push(node.name.value);
|
|
23453
|
-
}
|
|
23454
|
-
}
|
|
23455
|
-
};
|
|
23456
|
-
};
|
|
23457
|
-
const frags = [];
|
|
23458
|
-
Object.entries(info.fragments).map(([fragmentName, fragmentDefinition]) => {
|
|
23459
|
-
const frag = {
|
|
23460
|
-
name: fragmentName,
|
|
23461
|
-
node: fragmentDefinition,
|
|
23462
|
-
subFrags: []
|
|
23463
|
-
};
|
|
23464
|
-
frags.push(frag);
|
|
23465
|
-
(0, import_graphql3.visit)(fragmentDefinition, fragmentSpreadVisitor(frag));
|
|
23466
|
-
});
|
|
23467
|
-
const n = {
|
|
23468
|
-
query: (0, import_graphql3.print)(fieldNode),
|
|
23469
|
-
fragments: []
|
|
23470
|
-
};
|
|
23471
|
-
const visitor = {
|
|
23472
|
-
leave: {
|
|
23473
|
-
FragmentSpread(node) {
|
|
23474
|
-
n.fragments.push(node.name.value);
|
|
23475
|
-
}
|
|
23476
|
-
}
|
|
23477
|
-
};
|
|
23478
|
-
(0, import_graphql3.visit)(fieldNode, visitor);
|
|
23479
|
-
const getFrags = (fragNames, accum) => {
|
|
23480
|
-
fragNames.forEach((fragName) => {
|
|
23481
|
-
const frag = frags.find((f) => f.name === fragName);
|
|
23482
|
-
if (!frag) {
|
|
23483
|
-
throw new Error(`Unable to find fragment ${fragName}`);
|
|
23484
|
-
}
|
|
23485
|
-
accum.push(frag.node);
|
|
23486
|
-
if (frag.subFrags) {
|
|
23487
|
-
getFrags(frag.subFrags, accum);
|
|
23488
|
-
}
|
|
23489
|
-
});
|
|
23490
|
-
return accum;
|
|
23491
|
-
};
|
|
23492
|
-
const fragss = getFrags(n.fragments, []);
|
|
23493
|
-
const queryString = `${fragss.map((f) => (0, import_graphql3.print)(f)).join("\n")}
|
|
23494
|
-
${(0, import_graphql3.print)(q)}`;
|
|
23495
|
-
return queryString;
|
|
23496
|
-
}
|
|
23497
23118
|
|
|
23498
23119
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
|
|
23499
23120
|
var import_path4 = __toModule(require("path"));
|
|
@@ -23568,6 +23189,11 @@ var GENERATED_FOLDER = import_path4.default.join(".tina", "__generated__");
|
|
|
23568
23189
|
var Database = class {
|
|
23569
23190
|
constructor(config) {
|
|
23570
23191
|
this.config = config;
|
|
23192
|
+
this.collectionForPath = async (filepath) => {
|
|
23193
|
+
const tinaSchema = await this.getSchema();
|
|
23194
|
+
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23195
|
+
return collection;
|
|
23196
|
+
};
|
|
23571
23197
|
this.get = async (filepath) => {
|
|
23572
23198
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
23573
23199
|
throw new Error(`Unexpected get for config file ${filepath}`);
|
|
@@ -23607,8 +23233,7 @@ var Database = class {
|
|
|
23607
23233
|
};
|
|
23608
23234
|
this.addPendingDocument = async (filepath, data) => {
|
|
23609
23235
|
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23610
|
-
const
|
|
23611
|
-
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23236
|
+
const collection = await this.collectionForPath(filepath);
|
|
23612
23237
|
let collectionIndexDefinitions;
|
|
23613
23238
|
if (collection) {
|
|
23614
23239
|
const indexDefinitions = await this.getIndexDefinitions();
|
|
@@ -23619,20 +23244,18 @@ var Database = class {
|
|
|
23619
23244
|
}
|
|
23620
23245
|
await this.store.put(filepath, payload, {
|
|
23621
23246
|
keepTemplateKey,
|
|
23622
|
-
collection: collection.name,
|
|
23247
|
+
collection: collection == null ? void 0 : collection.name,
|
|
23623
23248
|
indexDefinitions: collectionIndexDefinitions
|
|
23624
23249
|
});
|
|
23625
23250
|
};
|
|
23626
|
-
this.put = async (filepath, data) => {
|
|
23251
|
+
this.put = async (filepath, data, collection) => {
|
|
23627
23252
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
23628
23253
|
throw new Error(`Unexpected put for config file ${filepath}`);
|
|
23629
23254
|
} else {
|
|
23630
|
-
const tinaSchema = await this.getSchema();
|
|
23631
|
-
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23632
23255
|
let collectionIndexDefinitions;
|
|
23633
23256
|
if (collection) {
|
|
23634
23257
|
const indexDefinitions = await this.getIndexDefinitions();
|
|
23635
|
-
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection
|
|
23258
|
+
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
|
|
23636
23259
|
}
|
|
23637
23260
|
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23638
23261
|
if (this.store.supportsSeeding()) {
|
|
@@ -23640,7 +23263,7 @@ var Database = class {
|
|
|
23640
23263
|
}
|
|
23641
23264
|
await this.store.put(filepath, payload, {
|
|
23642
23265
|
keepTemplateKey,
|
|
23643
|
-
collection
|
|
23266
|
+
collection,
|
|
23644
23267
|
indexDefinitions: collectionIndexDefinitions
|
|
23645
23268
|
});
|
|
23646
23269
|
}
|
|
@@ -23839,8 +23462,8 @@ var Database = class {
|
|
|
23839
23462
|
tinaSchema
|
|
23840
23463
|
}) => {
|
|
23841
23464
|
if (this.bridge.supportsBuilding()) {
|
|
23842
|
-
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`), JSON.stringify(graphQLSchema
|
|
23843
|
-
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_schema.json`), JSON.stringify(tinaSchema.schema
|
|
23465
|
+
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`), JSON.stringify(graphQLSchema));
|
|
23466
|
+
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_schema.json`), JSON.stringify(tinaSchema.schema));
|
|
23844
23467
|
}
|
|
23845
23468
|
};
|
|
23846
23469
|
this.indexContent = async ({
|
|
@@ -23849,7 +23472,7 @@ var Database = class {
|
|
|
23849
23472
|
}) => {
|
|
23850
23473
|
const lookup = JSON.parse(await this.bridge.get(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")));
|
|
23851
23474
|
if (this.store.supportsSeeding()) {
|
|
23852
|
-
this.store.clear();
|
|
23475
|
+
await this.store.clear();
|
|
23853
23476
|
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_graphql.json"), graphQLSchema);
|
|
23854
23477
|
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_schema.json"), tinaSchema.schema);
|
|
23855
23478
|
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"), lookup);
|
|
@@ -23860,28 +23483,34 @@ var Database = class {
|
|
|
23860
23483
|
}
|
|
23861
23484
|
}
|
|
23862
23485
|
};
|
|
23863
|
-
this.
|
|
23864
|
-
const pathsByCollection =
|
|
23865
|
-
const
|
|
23866
|
-
|
|
23867
|
-
const tinaSchema = await this.getSchema();
|
|
23868
|
-
for (const documentPath of documentPaths) {
|
|
23869
|
-
const collection = tinaSchema.schema.collections.find((collection2) => documentPath.startsWith(collection2.path));
|
|
23870
|
-
if (collection) {
|
|
23871
|
-
if (!pathsByCollection[collection.name]) {
|
|
23872
|
-
pathsByCollection[collection.name] = [];
|
|
23873
|
-
}
|
|
23874
|
-
collections[collection.name] = collection;
|
|
23875
|
-
pathsByCollection[collection.name].push(documentPath);
|
|
23876
|
-
} else {
|
|
23877
|
-
nonCollectionPaths.push(documentPath);
|
|
23878
|
-
}
|
|
23486
|
+
this.deleteContentByPaths = async (documentPaths) => {
|
|
23487
|
+
const { pathsByCollection, nonCollectionPaths, collections } = await this.partitionPathsByCollection(documentPaths);
|
|
23488
|
+
for (const collection of Object.keys(pathsByCollection)) {
|
|
23489
|
+
await _deleteIndexContent(this, pathsByCollection[collection], collections[collection]);
|
|
23879
23490
|
}
|
|
23491
|
+
await _deleteIndexContent(this, nonCollectionPaths, null);
|
|
23492
|
+
};
|
|
23493
|
+
this.indexContentByPaths = async (documentPaths) => {
|
|
23494
|
+
const { pathsByCollection, nonCollectionPaths, collections } = await this.partitionPathsByCollection(documentPaths);
|
|
23880
23495
|
for (const collection of Object.keys(pathsByCollection)) {
|
|
23881
23496
|
await _indexContent(this, pathsByCollection[collection], collections[collection]);
|
|
23882
23497
|
}
|
|
23883
23498
|
await _indexContent(this, nonCollectionPaths);
|
|
23884
23499
|
};
|
|
23500
|
+
this.delete = async (filepath) => {
|
|
23501
|
+
const tinaSchema = await this.getSchema();
|
|
23502
|
+
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23503
|
+
let collectionIndexDefinitions;
|
|
23504
|
+
if (collection) {
|
|
23505
|
+
const indexDefinitions = await this.getIndexDefinitions();
|
|
23506
|
+
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23507
|
+
}
|
|
23508
|
+
await this.store.delete(filepath, {
|
|
23509
|
+
collection: collection.name,
|
|
23510
|
+
indexDefinitions: collectionIndexDefinitions
|
|
23511
|
+
});
|
|
23512
|
+
await this.bridge.delete(filepath);
|
|
23513
|
+
};
|
|
23885
23514
|
this._indexAllContent = async () => {
|
|
23886
23515
|
const tinaSchema = await this.getSchema();
|
|
23887
23516
|
await sequential(tinaSchema.getCollections(), async (collection) => {
|
|
@@ -23900,11 +23529,29 @@ var Database = class {
|
|
|
23900
23529
|
const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
|
|
23901
23530
|
[lookup.type]: lookup
|
|
23902
23531
|
});
|
|
23903
|
-
await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup
|
|
23532
|
+
await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup));
|
|
23904
23533
|
};
|
|
23905
23534
|
this.bridge = config.bridge;
|
|
23906
23535
|
this.store = config.store;
|
|
23907
23536
|
}
|
|
23537
|
+
async partitionPathsByCollection(documentPaths) {
|
|
23538
|
+
const pathsByCollection = {};
|
|
23539
|
+
const nonCollectionPaths = [];
|
|
23540
|
+
const collections = {};
|
|
23541
|
+
for (const documentPath of documentPaths) {
|
|
23542
|
+
const collection = await this.collectionForPath(documentPath);
|
|
23543
|
+
if (collection) {
|
|
23544
|
+
if (!pathsByCollection[collection.name]) {
|
|
23545
|
+
pathsByCollection[collection.name] = [];
|
|
23546
|
+
}
|
|
23547
|
+
collections[collection.name] = collection;
|
|
23548
|
+
pathsByCollection[collection.name].push(documentPath);
|
|
23549
|
+
} else {
|
|
23550
|
+
nonCollectionPaths.push(documentPath);
|
|
23551
|
+
}
|
|
23552
|
+
}
|
|
23553
|
+
return { pathsByCollection, nonCollectionPaths, collections };
|
|
23554
|
+
}
|
|
23908
23555
|
};
|
|
23909
23556
|
function hasOwnProperty2(obj, prop) {
|
|
23910
23557
|
return obj.hasOwnProperty(prop);
|
|
@@ -23934,6 +23581,23 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23934
23581
|
}
|
|
23935
23582
|
});
|
|
23936
23583
|
};
|
|
23584
|
+
var _deleteIndexContent = async (database, documentPaths, collection) => {
|
|
23585
|
+
let deleteOptions = void 0;
|
|
23586
|
+
if (collection) {
|
|
23587
|
+
const indexDefinitions = await database.getIndexDefinitions();
|
|
23588
|
+
const collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23589
|
+
if (!collectionIndexDefinitions) {
|
|
23590
|
+
throw new Error(`No indexDefinitions for collection ${collection.name}`);
|
|
23591
|
+
}
|
|
23592
|
+
deleteOptions = {
|
|
23593
|
+
collection: collection.name,
|
|
23594
|
+
indexDefinitions: collectionIndexDefinitions
|
|
23595
|
+
};
|
|
23596
|
+
}
|
|
23597
|
+
await sequential(documentPaths, async (filepath) => {
|
|
23598
|
+
database.store.delete(filepath, deleteOptions);
|
|
23599
|
+
});
|
|
23600
|
+
};
|
|
23937
23601
|
|
|
23938
23602
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
23939
23603
|
var buildSchema = async (rootPath, database) => {
|