@tinacms/graphql 0.56.0 → 0.57.2
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 +30 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +842 -361
- package/dist/primitives/ast-builder/index.d.ts +40 -1
- package/dist/primitives/builder/index.d.ts +29 -2
- package/dist/primitives/database/github.d.ts +1 -22
- package/dist/primitives/index.d.ts +1 -3
- package/dist/primitives/resolver/index.d.ts +87 -7
- package/dist/{cache/lru.d.ts → primitives/schema/validate.d.ts} +2 -14
- package/dist/primitives/types.d.ts +1 -1
- package/dist/sdkBuilder/index.d.ts +14 -0
- package/package.json +3 -11
- package/dist/cache/s3.d.ts +0 -31
package/dist/index.js
CHANGED
|
@@ -6395,15 +6395,15 @@ var require_acorn_jsx = __commonJS({
|
|
|
6395
6395
|
}
|
|
6396
6396
|
return acornJsx;
|
|
6397
6397
|
}
|
|
6398
|
-
function getQualifiedJSXName(
|
|
6399
|
-
if (!
|
|
6400
|
-
return
|
|
6401
|
-
if (
|
|
6402
|
-
return
|
|
6403
|
-
if (
|
|
6404
|
-
return
|
|
6405
|
-
if (
|
|
6406
|
-
return getQualifiedJSXName(
|
|
6398
|
+
function getQualifiedJSXName(object2) {
|
|
6399
|
+
if (!object2)
|
|
6400
|
+
return object2;
|
|
6401
|
+
if (object2.type === "JSXIdentifier")
|
|
6402
|
+
return object2.name;
|
|
6403
|
+
if (object2.type === "JSXNamespacedName")
|
|
6404
|
+
return object2.namespace.name + ":" + object2.name.name;
|
|
6405
|
+
if (object2.type === "JSXMemberExpression")
|
|
6406
|
+
return getQualifiedJSXName(object2.object) + "." + getQualifiedJSXName(object2.property);
|
|
6407
6407
|
}
|
|
6408
6408
|
module2.exports = function(options) {
|
|
6409
6409
|
options = options || {};
|
|
@@ -6946,8 +6946,8 @@ var require_micromark_extension_mdxjs = __commonJS({
|
|
|
6946
6946
|
var require_min_indent = __commonJS({
|
|
6947
6947
|
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/min-indent-npm-1.0.1-77031f50e1-c3aeea46bc.zip/node_modules/min-indent/index.js"(exports, module2) {
|
|
6948
6948
|
"use strict";
|
|
6949
|
-
module2.exports = (
|
|
6950
|
-
const match =
|
|
6949
|
+
module2.exports = (string4) => {
|
|
6950
|
+
const match = string4.match(/^[ \t]*(?=\S)/gm);
|
|
6951
6951
|
if (!match) {
|
|
6952
6952
|
return 0;
|
|
6953
6953
|
}
|
|
@@ -6961,13 +6961,13 @@ var require_strip_indent = __commonJS({
|
|
|
6961
6961
|
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/strip-indent-npm-3.0.0-519e75a28d-4a7860e943.zip/node_modules/strip-indent/index.js"(exports, module2) {
|
|
6962
6962
|
"use strict";
|
|
6963
6963
|
var minIndent = require_min_indent();
|
|
6964
|
-
module2.exports = (
|
|
6965
|
-
const indent2 = minIndent(
|
|
6964
|
+
module2.exports = (string4) => {
|
|
6965
|
+
const indent2 = minIndent(string4);
|
|
6966
6966
|
if (indent2 === 0) {
|
|
6967
|
-
return
|
|
6967
|
+
return string4;
|
|
6968
6968
|
}
|
|
6969
6969
|
const regex = new RegExp(`^[ \\t]{${indent2}}`, "gm");
|
|
6970
|
-
return
|
|
6970
|
+
return string4.replace(regex, "");
|
|
6971
6971
|
};
|
|
6972
6972
|
}
|
|
6973
6973
|
});
|
|
@@ -10101,7 +10101,7 @@ var require_repeat_string = __commonJS({
|
|
|
10101
10101
|
"pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/repeat-string-npm-1.6.1-bc8e388655-99c431ba7b.zip/node_modules/repeat-string/index.js"(exports, module2) {
|
|
10102
10102
|
"use strict";
|
|
10103
10103
|
var res = "";
|
|
10104
|
-
var
|
|
10104
|
+
var cache;
|
|
10105
10105
|
module2.exports = repeat;
|
|
10106
10106
|
function repeat(str, num) {
|
|
10107
10107
|
if (typeof str !== "string") {
|
|
@@ -10112,8 +10112,8 @@ var require_repeat_string = __commonJS({
|
|
|
10112
10112
|
if (num === 2)
|
|
10113
10113
|
return str + str;
|
|
10114
10114
|
var max = str.length * num;
|
|
10115
|
-
if (
|
|
10116
|
-
|
|
10115
|
+
if (cache !== str || typeof cache === "undefined") {
|
|
10116
|
+
cache = str;
|
|
10117
10117
|
res = "";
|
|
10118
10118
|
} else if (res.length >= max) {
|
|
10119
10119
|
return res.substr(0, max);
|
|
@@ -10386,36 +10386,22 @@ var require_remark_mdx = __commonJS({
|
|
|
10386
10386
|
__export(exports, {
|
|
10387
10387
|
GithubBridge: () => GithubBridge,
|
|
10388
10388
|
buildSchema: () => buildSchema,
|
|
10389
|
-
clearCache: () => clearCache,
|
|
10390
10389
|
createBranch: () => createBranch,
|
|
10391
10390
|
createDatabase: () => createDatabase,
|
|
10392
10391
|
githubRoute: () => githubRoute,
|
|
10393
10392
|
gql: () => gql,
|
|
10394
10393
|
indexDB: () => indexDB,
|
|
10395
10394
|
listBranches: () => listBranches,
|
|
10396
|
-
|
|
10397
|
-
resolve: () => resolve,
|
|
10398
|
-
s3Cache: () => s3Cache,
|
|
10399
|
-
s3ClearCache: () => clearCache2,
|
|
10400
|
-
simpleCache: () => simpleCache2
|
|
10395
|
+
resolve: () => resolve
|
|
10401
10396
|
});
|
|
10402
10397
|
|
|
10403
10398
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/database/github.ts
|
|
10404
10399
|
var import_lodash = __toModule(require("lodash"));
|
|
10405
10400
|
var import_path = __toModule(require("path"));
|
|
10406
10401
|
var import_rest = __toModule(require("@octokit/rest"));
|
|
10407
|
-
var import_lru_cache = __toModule(require("lru-cache"));
|
|
10408
10402
|
var import_graphql = __toModule(require("graphql"));
|
|
10409
10403
|
var GithubBridge = class {
|
|
10410
|
-
constructor({
|
|
10411
|
-
rootPath,
|
|
10412
|
-
accessToken,
|
|
10413
|
-
owner,
|
|
10414
|
-
repo,
|
|
10415
|
-
ref,
|
|
10416
|
-
cache: cache3
|
|
10417
|
-
}) {
|
|
10418
|
-
this.cache = cache3 || simpleCache;
|
|
10404
|
+
constructor({ rootPath, accessToken, owner, repo, ref }) {
|
|
10419
10405
|
this.rootPath = rootPath;
|
|
10420
10406
|
this.repoConfig = {
|
|
10421
10407
|
owner,
|
|
@@ -10426,12 +10412,9 @@ var GithubBridge = class {
|
|
|
10426
10412
|
auth: accessToken
|
|
10427
10413
|
});
|
|
10428
10414
|
}
|
|
10429
|
-
generateKey(key2) {
|
|
10430
|
-
return `${this.repoConfig.owner}/${this.repoConfig.repo}/${this.repoConfig.ref}/${key2}`;
|
|
10431
|
-
}
|
|
10432
10415
|
async readDir(filepath) {
|
|
10433
10416
|
const fullPath = import_path.default.join(this.rootPath, filepath);
|
|
10434
|
-
|
|
10417
|
+
const repos = await this.appOctoKit.repos.getContent(__spreadProps(__spreadValues({}, this.repoConfig), {
|
|
10435
10418
|
path: fullPath
|
|
10436
10419
|
})).then(async (response) => {
|
|
10437
10420
|
if (Array.isArray(response.data)) {
|
|
@@ -10443,14 +10426,15 @@ var GithubBridge = class {
|
|
|
10443
10426
|
return import_path.default.join(d.path, nestedItem);
|
|
10444
10427
|
});
|
|
10445
10428
|
} else {
|
|
10446
|
-
throw new Error(
|
|
10429
|
+
throw new Error(`Expected items to be an array of strings for readDir at ${d.path}`);
|
|
10447
10430
|
}
|
|
10448
10431
|
}
|
|
10449
10432
|
return d.path;
|
|
10450
10433
|
}));
|
|
10451
10434
|
}
|
|
10452
10435
|
throw new Error(`Expected to return an array from Github directory ${import_path.default}`);
|
|
10453
|
-
})
|
|
10436
|
+
});
|
|
10437
|
+
return import_lodash.default.flatten(repos);
|
|
10454
10438
|
}
|
|
10455
10439
|
async glob(pattern) {
|
|
10456
10440
|
const results = await this.readDir(pattern);
|
|
@@ -10458,17 +10442,15 @@ var GithubBridge = class {
|
|
|
10458
10442
|
}
|
|
10459
10443
|
async get(filepath) {
|
|
10460
10444
|
const realpath = import_path.default.join(this.rootPath, filepath);
|
|
10461
|
-
return this.
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
throw new import_graphql.GraphQLError(`Unable to find record '${filepath}' in Github Repository: '${this.repoConfig.owner}/${this.repoConfig.repo}', Ref: '${this.repoConfig.ref}'`, null, null, null, null, e, { status: e.status });
|
|
10471
|
-
});
|
|
10445
|
+
return this.appOctoKit.repos.getContent(__spreadProps(__spreadValues({}, this.repoConfig), {
|
|
10446
|
+
path: realpath
|
|
10447
|
+
})).then((response) => {
|
|
10448
|
+
return Buffer.from(response.data.content, "base64").toString();
|
|
10449
|
+
}).catch((e) => {
|
|
10450
|
+
if (e.status === 401) {
|
|
10451
|
+
throw new import_graphql.GraphQLError(`Unauthorized request to Github Repository: '${this.repoConfig.owner}/${this.repoConfig.repo}', please ensure your access token is valid.`, null, null, null, null, e, { status: e.status });
|
|
10452
|
+
}
|
|
10453
|
+
throw new import_graphql.GraphQLError(`Unable to find record '${filepath}' in Github Repository: '${this.repoConfig.owner}/${this.repoConfig.repo}', Ref: '${this.repoConfig.ref}'`, null, null, null, null, e, { status: e.status });
|
|
10472
10454
|
});
|
|
10473
10455
|
}
|
|
10474
10456
|
async put(filepath, data) {
|
|
@@ -10491,36 +10473,87 @@ var GithubBridge = class {
|
|
|
10491
10473
|
}));
|
|
10492
10474
|
}
|
|
10493
10475
|
};
|
|
10494
|
-
var cache = new import_lru_cache.default({
|
|
10495
|
-
max: 1e3,
|
|
10496
|
-
length: function(v) {
|
|
10497
|
-
return v.length;
|
|
10498
|
-
}
|
|
10499
|
-
});
|
|
10500
|
-
var simpleCache = {
|
|
10501
|
-
get: async (keyName, setter) => {
|
|
10502
|
-
const value = cache.get(keyName);
|
|
10503
|
-
if (value) {
|
|
10504
|
-
console.log("getting from cache", keyName);
|
|
10505
|
-
return value;
|
|
10506
|
-
} else {
|
|
10507
|
-
const valueToCache = await setter();
|
|
10508
|
-
const isSet = cache.set(keyName, valueToCache);
|
|
10509
|
-
console.log("item not in cache, setting", keyName, isSet);
|
|
10510
|
-
return valueToCache;
|
|
10511
|
-
}
|
|
10512
|
-
}
|
|
10513
|
-
};
|
|
10514
10476
|
|
|
10515
10477
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/index.ts
|
|
10516
|
-
var
|
|
10517
|
-
var
|
|
10478
|
+
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
10479
|
+
var import_path7 = __toModule(require("path"));
|
|
10518
10480
|
|
|
10519
10481
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/build.ts
|
|
10520
10482
|
var import_lodash4 = __toModule(require("lodash"));
|
|
10483
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
10484
|
+
var import_path2 = __toModule(require("path"));
|
|
10485
|
+
var import_graphql3 = __toModule(require("graphql"));
|
|
10521
10486
|
|
|
10522
10487
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/ast-builder/index.ts
|
|
10523
10488
|
var import_lodash2 = __toModule(require("lodash"));
|
|
10489
|
+
var SysFieldDefinition = {
|
|
10490
|
+
kind: "Field",
|
|
10491
|
+
name: {
|
|
10492
|
+
kind: "Name",
|
|
10493
|
+
value: "sys"
|
|
10494
|
+
},
|
|
10495
|
+
arguments: [],
|
|
10496
|
+
directives: [],
|
|
10497
|
+
selectionSet: {
|
|
10498
|
+
kind: "SelectionSet",
|
|
10499
|
+
selections: [
|
|
10500
|
+
{
|
|
10501
|
+
kind: "Field",
|
|
10502
|
+
name: {
|
|
10503
|
+
kind: "Name",
|
|
10504
|
+
value: "filename"
|
|
10505
|
+
},
|
|
10506
|
+
arguments: [],
|
|
10507
|
+
directives: []
|
|
10508
|
+
},
|
|
10509
|
+
{
|
|
10510
|
+
kind: "Field",
|
|
10511
|
+
name: {
|
|
10512
|
+
kind: "Name",
|
|
10513
|
+
value: "basename"
|
|
10514
|
+
},
|
|
10515
|
+
arguments: [],
|
|
10516
|
+
directives: []
|
|
10517
|
+
},
|
|
10518
|
+
{
|
|
10519
|
+
kind: "Field",
|
|
10520
|
+
name: {
|
|
10521
|
+
kind: "Name",
|
|
10522
|
+
value: "breadcrumbs"
|
|
10523
|
+
},
|
|
10524
|
+
arguments: [],
|
|
10525
|
+
directives: []
|
|
10526
|
+
},
|
|
10527
|
+
{
|
|
10528
|
+
kind: "Field",
|
|
10529
|
+
name: {
|
|
10530
|
+
kind: "Name",
|
|
10531
|
+
value: "path"
|
|
10532
|
+
},
|
|
10533
|
+
arguments: [],
|
|
10534
|
+
directives: []
|
|
10535
|
+
},
|
|
10536
|
+
{
|
|
10537
|
+
kind: "Field",
|
|
10538
|
+
name: {
|
|
10539
|
+
kind: "Name",
|
|
10540
|
+
value: "relativePath"
|
|
10541
|
+
},
|
|
10542
|
+
arguments: [],
|
|
10543
|
+
directives: []
|
|
10544
|
+
},
|
|
10545
|
+
{
|
|
10546
|
+
kind: "Field",
|
|
10547
|
+
name: {
|
|
10548
|
+
kind: "Name",
|
|
10549
|
+
value: "extension"
|
|
10550
|
+
},
|
|
10551
|
+
arguments: [],
|
|
10552
|
+
directives: []
|
|
10553
|
+
}
|
|
10554
|
+
]
|
|
10555
|
+
}
|
|
10556
|
+
};
|
|
10524
10557
|
var astBuilder = {
|
|
10525
10558
|
FormFieldBuilder: ({
|
|
10526
10559
|
name,
|
|
@@ -10640,6 +10673,16 @@ var astBuilder = {
|
|
|
10640
10673
|
})
|
|
10641
10674
|
};
|
|
10642
10675
|
},
|
|
10676
|
+
FieldNodeDefinition: ({
|
|
10677
|
+
name,
|
|
10678
|
+
type,
|
|
10679
|
+
args = [],
|
|
10680
|
+
list: list3,
|
|
10681
|
+
required
|
|
10682
|
+
}) => ({
|
|
10683
|
+
name: { kind: "Name", value: name },
|
|
10684
|
+
kind: "Field"
|
|
10685
|
+
}),
|
|
10643
10686
|
FieldDefinition: ({
|
|
10644
10687
|
name,
|
|
10645
10688
|
type,
|
|
@@ -10772,6 +10815,63 @@ var astBuilder = {
|
|
|
10772
10815
|
},
|
|
10773
10816
|
fields
|
|
10774
10817
|
}),
|
|
10818
|
+
FieldWithSelectionSetDefinition: ({
|
|
10819
|
+
name,
|
|
10820
|
+
selections
|
|
10821
|
+
}) => {
|
|
10822
|
+
return {
|
|
10823
|
+
name: { kind: "Name", value: name },
|
|
10824
|
+
kind: "Field",
|
|
10825
|
+
selectionSet: {
|
|
10826
|
+
kind: "SelectionSet",
|
|
10827
|
+
selections
|
|
10828
|
+
}
|
|
10829
|
+
};
|
|
10830
|
+
},
|
|
10831
|
+
InlineFragmentDefinition: ({
|
|
10832
|
+
name,
|
|
10833
|
+
selections
|
|
10834
|
+
}) => {
|
|
10835
|
+
return {
|
|
10836
|
+
kind: "InlineFragment",
|
|
10837
|
+
selectionSet: {
|
|
10838
|
+
kind: "SelectionSet",
|
|
10839
|
+
selections
|
|
10840
|
+
},
|
|
10841
|
+
typeCondition: {
|
|
10842
|
+
kind: "NamedType",
|
|
10843
|
+
name: {
|
|
10844
|
+
kind: "Name",
|
|
10845
|
+
value: name
|
|
10846
|
+
}
|
|
10847
|
+
}
|
|
10848
|
+
};
|
|
10849
|
+
},
|
|
10850
|
+
FragmentDefinition: ({
|
|
10851
|
+
name,
|
|
10852
|
+
fragmentName,
|
|
10853
|
+
selections
|
|
10854
|
+
}) => {
|
|
10855
|
+
return {
|
|
10856
|
+
kind: "FragmentDefinition",
|
|
10857
|
+
name: {
|
|
10858
|
+
kind: "Name",
|
|
10859
|
+
value: fragmentName
|
|
10860
|
+
},
|
|
10861
|
+
typeCondition: {
|
|
10862
|
+
kind: "NamedType",
|
|
10863
|
+
name: {
|
|
10864
|
+
kind: "Name",
|
|
10865
|
+
value: name
|
|
10866
|
+
}
|
|
10867
|
+
},
|
|
10868
|
+
directives: [],
|
|
10869
|
+
selectionSet: {
|
|
10870
|
+
kind: "SelectionSet",
|
|
10871
|
+
selections
|
|
10872
|
+
}
|
|
10873
|
+
};
|
|
10874
|
+
},
|
|
10775
10875
|
TYPES: {
|
|
10776
10876
|
Scalar: (type) => {
|
|
10777
10877
|
const scalars = {
|
|
@@ -10799,6 +10899,204 @@ var astBuilder = {
|
|
|
10799
10899
|
Number: "Int",
|
|
10800
10900
|
Document: "Document"
|
|
10801
10901
|
},
|
|
10902
|
+
QueryOperationDefinition: ({
|
|
10903
|
+
queryName,
|
|
10904
|
+
fragName
|
|
10905
|
+
}) => {
|
|
10906
|
+
return {
|
|
10907
|
+
kind: "OperationDefinition",
|
|
10908
|
+
operation: "query",
|
|
10909
|
+
name: {
|
|
10910
|
+
kind: "Name",
|
|
10911
|
+
value: queryName
|
|
10912
|
+
},
|
|
10913
|
+
variableDefinitions: [
|
|
10914
|
+
{
|
|
10915
|
+
kind: "VariableDefinition",
|
|
10916
|
+
type: {
|
|
10917
|
+
kind: "NonNullType",
|
|
10918
|
+
type: {
|
|
10919
|
+
kind: "NamedType",
|
|
10920
|
+
name: { kind: "Name", value: "String" }
|
|
10921
|
+
}
|
|
10922
|
+
},
|
|
10923
|
+
variable: {
|
|
10924
|
+
kind: "Variable",
|
|
10925
|
+
name: { kind: "Name", value: "relativePath" }
|
|
10926
|
+
}
|
|
10927
|
+
}
|
|
10928
|
+
],
|
|
10929
|
+
selectionSet: {
|
|
10930
|
+
kind: "SelectionSet",
|
|
10931
|
+
selections: [
|
|
10932
|
+
{
|
|
10933
|
+
kind: "Field",
|
|
10934
|
+
name: {
|
|
10935
|
+
kind: "Name",
|
|
10936
|
+
value: queryName
|
|
10937
|
+
},
|
|
10938
|
+
arguments: [
|
|
10939
|
+
{
|
|
10940
|
+
kind: "Argument",
|
|
10941
|
+
name: {
|
|
10942
|
+
kind: "Name",
|
|
10943
|
+
value: "relativePath"
|
|
10944
|
+
},
|
|
10945
|
+
value: {
|
|
10946
|
+
kind: "Variable",
|
|
10947
|
+
name: {
|
|
10948
|
+
kind: "Name",
|
|
10949
|
+
value: "relativePath"
|
|
10950
|
+
}
|
|
10951
|
+
}
|
|
10952
|
+
}
|
|
10953
|
+
],
|
|
10954
|
+
directives: [],
|
|
10955
|
+
selectionSet: {
|
|
10956
|
+
kind: "SelectionSet",
|
|
10957
|
+
selections: [
|
|
10958
|
+
SysFieldDefinition,
|
|
10959
|
+
{
|
|
10960
|
+
kind: "Field",
|
|
10961
|
+
name: {
|
|
10962
|
+
kind: "Name",
|
|
10963
|
+
value: "id"
|
|
10964
|
+
},
|
|
10965
|
+
arguments: [],
|
|
10966
|
+
directives: []
|
|
10967
|
+
},
|
|
10968
|
+
{
|
|
10969
|
+
kind: "Field",
|
|
10970
|
+
name: {
|
|
10971
|
+
kind: "Name",
|
|
10972
|
+
value: "data"
|
|
10973
|
+
},
|
|
10974
|
+
arguments: [],
|
|
10975
|
+
directives: [],
|
|
10976
|
+
selectionSet: {
|
|
10977
|
+
kind: "SelectionSet",
|
|
10978
|
+
selections: [
|
|
10979
|
+
{
|
|
10980
|
+
kind: "FragmentSpread",
|
|
10981
|
+
name: {
|
|
10982
|
+
kind: "Name",
|
|
10983
|
+
value: fragName
|
|
10984
|
+
},
|
|
10985
|
+
directives: []
|
|
10986
|
+
}
|
|
10987
|
+
]
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
]
|
|
10991
|
+
}
|
|
10992
|
+
}
|
|
10993
|
+
]
|
|
10994
|
+
}
|
|
10995
|
+
};
|
|
10996
|
+
},
|
|
10997
|
+
ListQueryOperationDefinition: ({
|
|
10998
|
+
queryName,
|
|
10999
|
+
fragName
|
|
11000
|
+
}) => {
|
|
11001
|
+
return {
|
|
11002
|
+
kind: "OperationDefinition",
|
|
11003
|
+
operation: "query",
|
|
11004
|
+
name: {
|
|
11005
|
+
kind: "Name",
|
|
11006
|
+
value: queryName
|
|
11007
|
+
},
|
|
11008
|
+
variableDefinitions: [],
|
|
11009
|
+
directives: [],
|
|
11010
|
+
selectionSet: {
|
|
11011
|
+
kind: "SelectionSet",
|
|
11012
|
+
selections: [
|
|
11013
|
+
{
|
|
11014
|
+
kind: "Field",
|
|
11015
|
+
name: {
|
|
11016
|
+
kind: "Name",
|
|
11017
|
+
value: queryName
|
|
11018
|
+
},
|
|
11019
|
+
arguments: [],
|
|
11020
|
+
directives: [],
|
|
11021
|
+
selectionSet: {
|
|
11022
|
+
kind: "SelectionSet",
|
|
11023
|
+
selections: [
|
|
11024
|
+
{
|
|
11025
|
+
kind: "Field",
|
|
11026
|
+
name: {
|
|
11027
|
+
kind: "Name",
|
|
11028
|
+
value: "totalCount"
|
|
11029
|
+
},
|
|
11030
|
+
arguments: [],
|
|
11031
|
+
directives: []
|
|
11032
|
+
},
|
|
11033
|
+
{
|
|
11034
|
+
kind: "Field",
|
|
11035
|
+
name: {
|
|
11036
|
+
kind: "Name",
|
|
11037
|
+
value: "edges"
|
|
11038
|
+
},
|
|
11039
|
+
arguments: [],
|
|
11040
|
+
directives: [],
|
|
11041
|
+
selectionSet: {
|
|
11042
|
+
kind: "SelectionSet",
|
|
11043
|
+
selections: [
|
|
11044
|
+
{
|
|
11045
|
+
kind: "Field",
|
|
11046
|
+
name: {
|
|
11047
|
+
kind: "Name",
|
|
11048
|
+
value: "node"
|
|
11049
|
+
},
|
|
11050
|
+
arguments: [],
|
|
11051
|
+
directives: [],
|
|
11052
|
+
selectionSet: {
|
|
11053
|
+
kind: "SelectionSet",
|
|
11054
|
+
selections: [
|
|
11055
|
+
{
|
|
11056
|
+
kind: "Field",
|
|
11057
|
+
name: {
|
|
11058
|
+
kind: "Name",
|
|
11059
|
+
value: "id"
|
|
11060
|
+
},
|
|
11061
|
+
arguments: [],
|
|
11062
|
+
directives: []
|
|
11063
|
+
},
|
|
11064
|
+
SysFieldDefinition,
|
|
11065
|
+
{
|
|
11066
|
+
kind: "Field",
|
|
11067
|
+
name: {
|
|
11068
|
+
kind: "Name",
|
|
11069
|
+
value: "data"
|
|
11070
|
+
},
|
|
11071
|
+
arguments: [],
|
|
11072
|
+
directives: [],
|
|
11073
|
+
selectionSet: {
|
|
11074
|
+
kind: "SelectionSet",
|
|
11075
|
+
selections: [
|
|
11076
|
+
{
|
|
11077
|
+
kind: "FragmentSpread",
|
|
11078
|
+
name: {
|
|
11079
|
+
kind: "Name",
|
|
11080
|
+
value: fragName
|
|
11081
|
+
},
|
|
11082
|
+
directives: []
|
|
11083
|
+
}
|
|
11084
|
+
]
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
]
|
|
11088
|
+
}
|
|
11089
|
+
}
|
|
11090
|
+
]
|
|
11091
|
+
}
|
|
11092
|
+
}
|
|
11093
|
+
]
|
|
11094
|
+
}
|
|
11095
|
+
}
|
|
11096
|
+
]
|
|
11097
|
+
}
|
|
11098
|
+
};
|
|
11099
|
+
},
|
|
10802
11100
|
toGraphQLAst: (ast) => {
|
|
10803
11101
|
const definitions = import_lodash2.default.uniqBy([
|
|
10804
11102
|
...extractInlineTypes(ast.query),
|
|
@@ -10870,6 +11168,9 @@ function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
|
10870
11168
|
const key2 = keys2[index2];
|
|
10871
11169
|
if (Array.isArray(m)) {
|
|
10872
11170
|
newNode[key2] = m.map((element) => {
|
|
11171
|
+
if (!element) {
|
|
11172
|
+
return;
|
|
11173
|
+
}
|
|
10873
11174
|
if (!element.hasOwnProperty("name")) {
|
|
10874
11175
|
return element;
|
|
10875
11176
|
}
|
|
@@ -10877,6 +11178,9 @@ function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
|
10877
11178
|
return addNamespaceToSchema(element, [...namespace, value]);
|
|
10878
11179
|
});
|
|
10879
11180
|
} else {
|
|
11181
|
+
if (!m) {
|
|
11182
|
+
return;
|
|
11183
|
+
}
|
|
10880
11184
|
if (!m.hasOwnProperty("name")) {
|
|
10881
11185
|
newNode[key2] = m;
|
|
10882
11186
|
} else {
|
|
@@ -10914,6 +11218,9 @@ var NAMER = {
|
|
|
10914
11218
|
generateQueryListName: (namespace) => {
|
|
10915
11219
|
return "get" + generateNamespacedFieldName(namespace, "List");
|
|
10916
11220
|
},
|
|
11221
|
+
fragmentName: (namespace) => {
|
|
11222
|
+
return generateNamespacedFieldName(namespace, "") + "Parts";
|
|
11223
|
+
},
|
|
10917
11224
|
collectionTypeName: (namespace) => {
|
|
10918
11225
|
return generateNamespacedFieldName(namespace, "Collection");
|
|
10919
11226
|
},
|
|
@@ -11266,7 +11573,7 @@ var Builder = class {
|
|
|
11266
11573
|
args: [
|
|
11267
11574
|
astBuilder.InputValueDefinition({
|
|
11268
11575
|
name: "collection",
|
|
11269
|
-
required:
|
|
11576
|
+
required: false,
|
|
11270
11577
|
type: astBuilder.TYPES.String
|
|
11271
11578
|
}),
|
|
11272
11579
|
astBuilder.InputValueDefinition({
|
|
@@ -11293,7 +11600,7 @@ var Builder = class {
|
|
|
11293
11600
|
args: [
|
|
11294
11601
|
astBuilder.InputValueDefinition({
|
|
11295
11602
|
name: "collection",
|
|
11296
|
-
required:
|
|
11603
|
+
required: false,
|
|
11297
11604
|
type: astBuilder.TYPES.String
|
|
11298
11605
|
}),
|
|
11299
11606
|
astBuilder.InputValueDefinition({
|
|
@@ -11341,6 +11648,104 @@ var Builder = class {
|
|
|
11341
11648
|
});
|
|
11342
11649
|
return astBuilder.FieldDefinition({ type, name, args, required: true });
|
|
11343
11650
|
};
|
|
11651
|
+
this.collectionFragment = async (collection) => {
|
|
11652
|
+
const name = NAMER.dataTypeName(collection.namespace);
|
|
11653
|
+
const fragmentName = NAMER.fragmentName(collection.namespace);
|
|
11654
|
+
if (typeof collection.fields === "object") {
|
|
11655
|
+
const selections = [];
|
|
11656
|
+
await sequential(collection.fields, async (x) => {
|
|
11657
|
+
const field = await this._buildFieldNodeForFragments(x);
|
|
11658
|
+
selections.push(field);
|
|
11659
|
+
});
|
|
11660
|
+
return astBuilder.FragmentDefinition({
|
|
11661
|
+
name,
|
|
11662
|
+
fragmentName,
|
|
11663
|
+
selections: filterSelections(selections)
|
|
11664
|
+
});
|
|
11665
|
+
} else {
|
|
11666
|
+
const selections = [];
|
|
11667
|
+
await sequential(collection.templates, async (tem) => {
|
|
11668
|
+
if (typeof tem === "object") {
|
|
11669
|
+
selections.push(await this.buildTemplateFragments(tem));
|
|
11670
|
+
}
|
|
11671
|
+
});
|
|
11672
|
+
return astBuilder.FieldWithSelectionSetDefinition({
|
|
11673
|
+
name,
|
|
11674
|
+
selections: filterSelections(selections)
|
|
11675
|
+
});
|
|
11676
|
+
}
|
|
11677
|
+
};
|
|
11678
|
+
this._buildFieldNodeForFragments = async (field) => {
|
|
11679
|
+
switch (field.type) {
|
|
11680
|
+
case "string":
|
|
11681
|
+
case "image":
|
|
11682
|
+
case "datetime":
|
|
11683
|
+
case "number":
|
|
11684
|
+
case "boolean":
|
|
11685
|
+
case "rich-text":
|
|
11686
|
+
return astBuilder.FieldNodeDefinition(field);
|
|
11687
|
+
case "object":
|
|
11688
|
+
if (typeof field.fields === "object") {
|
|
11689
|
+
const selections = [];
|
|
11690
|
+
await sequential(field.fields, async (item) => {
|
|
11691
|
+
const field2 = await this._buildFieldNodeForFragments(item);
|
|
11692
|
+
selections.push(field2);
|
|
11693
|
+
});
|
|
11694
|
+
return astBuilder.FieldWithSelectionSetDefinition({
|
|
11695
|
+
name: field.name,
|
|
11696
|
+
selections: [
|
|
11697
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
11698
|
+
...filterSelections(selections)
|
|
11699
|
+
]
|
|
11700
|
+
});
|
|
11701
|
+
} else if (typeof field.templates === "object") {
|
|
11702
|
+
const selections = [];
|
|
11703
|
+
await sequential(field.templates, async (tem) => {
|
|
11704
|
+
if (typeof tem === "object") {
|
|
11705
|
+
selections.push(await this.buildTemplateFragments(tem));
|
|
11706
|
+
}
|
|
11707
|
+
});
|
|
11708
|
+
return astBuilder.FieldWithSelectionSetDefinition({
|
|
11709
|
+
name: field.name,
|
|
11710
|
+
selections: [
|
|
11711
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
11712
|
+
...filterSelections(selections)
|
|
11713
|
+
]
|
|
11714
|
+
});
|
|
11715
|
+
}
|
|
11716
|
+
case "reference":
|
|
11717
|
+
return astBuilder.FieldWithSelectionSetDefinition({
|
|
11718
|
+
name: field.name,
|
|
11719
|
+
selections: [
|
|
11720
|
+
{
|
|
11721
|
+
kind: "InlineFragment",
|
|
11722
|
+
typeCondition: {
|
|
11723
|
+
kind: "NamedType",
|
|
11724
|
+
name: {
|
|
11725
|
+
kind: "Name",
|
|
11726
|
+
value: "Document"
|
|
11727
|
+
}
|
|
11728
|
+
},
|
|
11729
|
+
directives: [],
|
|
11730
|
+
selectionSet: {
|
|
11731
|
+
kind: "SelectionSet",
|
|
11732
|
+
selections: [
|
|
11733
|
+
{
|
|
11734
|
+
kind: "Field",
|
|
11735
|
+
name: {
|
|
11736
|
+
kind: "Name",
|
|
11737
|
+
value: "id"
|
|
11738
|
+
},
|
|
11739
|
+
arguments: [],
|
|
11740
|
+
directives: []
|
|
11741
|
+
}
|
|
11742
|
+
]
|
|
11743
|
+
}
|
|
11744
|
+
}
|
|
11745
|
+
]
|
|
11746
|
+
});
|
|
11747
|
+
}
|
|
11748
|
+
};
|
|
11344
11749
|
this.updateCollectionDocumentMutation = async (collection) => {
|
|
11345
11750
|
return astBuilder.FieldDefinition({
|
|
11346
11751
|
type: await this._buildCollectionDocumentType(collection),
|
|
@@ -11687,6 +12092,17 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
|
|
|
11687
12092
|
this.tinaSchema = config.tinaSchema;
|
|
11688
12093
|
this.database = config.database;
|
|
11689
12094
|
}
|
|
12095
|
+
async buildTemplateFragments(template) {
|
|
12096
|
+
const selections = [];
|
|
12097
|
+
await sequential(template.fields || [], async (item) => {
|
|
12098
|
+
const field = await this._buildFieldNodeForFragments(item);
|
|
12099
|
+
selections.push(field);
|
|
12100
|
+
});
|
|
12101
|
+
return astBuilder.InlineFragmentDefinition({
|
|
12102
|
+
selections: filterSelections(selections),
|
|
12103
|
+
name: NAMER.dataTypeName(template.namespace)
|
|
12104
|
+
});
|
|
12105
|
+
}
|
|
11690
12106
|
};
|
|
11691
12107
|
var listArgs = [
|
|
11692
12108
|
astBuilder.InputValueDefinition({
|
|
@@ -11706,9 +12122,81 @@ var listArgs = [
|
|
|
11706
12122
|
type: astBuilder.TYPES.Number
|
|
11707
12123
|
})
|
|
11708
12124
|
];
|
|
12125
|
+
var filterSelections = (arr) => {
|
|
12126
|
+
return arr.filter(Boolean);
|
|
12127
|
+
};
|
|
11709
12128
|
|
|
11710
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/schema/
|
|
12129
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/schema/validate.ts
|
|
11711
12130
|
var import_lodash3 = __toModule(require("lodash"));
|
|
12131
|
+
var yup2 = __toModule(require("yup"));
|
|
12132
|
+
var FIELD_TYPES = [
|
|
12133
|
+
"string",
|
|
12134
|
+
"number",
|
|
12135
|
+
"boolean",
|
|
12136
|
+
"datetime",
|
|
12137
|
+
"image",
|
|
12138
|
+
"reference",
|
|
12139
|
+
"object",
|
|
12140
|
+
"rich-text"
|
|
12141
|
+
];
|
|
12142
|
+
var validateSchema = async (schema) => {
|
|
12143
|
+
const schema2 = addNamespaceToSchema(import_lodash3.default.cloneDeep(schema));
|
|
12144
|
+
const collections = await sequential(schema2.collections, async (collection) => validateCollection(collection));
|
|
12145
|
+
return {
|
|
12146
|
+
collections
|
|
12147
|
+
};
|
|
12148
|
+
};
|
|
12149
|
+
var validateCollection = async (collection) => {
|
|
12150
|
+
let templates = [];
|
|
12151
|
+
let fields = [];
|
|
12152
|
+
const messageName = collection.namespace.join(".");
|
|
12153
|
+
const collectionSchema = yup2.object({
|
|
12154
|
+
name: yup2.string().matches(/^[a-zA-Z0-9_]*$/, {
|
|
12155
|
+
message: (obj) => `Collection's "name" must match ${obj.regex} at ${messageName}`
|
|
12156
|
+
}).required(),
|
|
12157
|
+
label: yup2.string().required(),
|
|
12158
|
+
path: yup2.string().required().transform((value) => {
|
|
12159
|
+
return value.replace(/^\/|\/$/g, "");
|
|
12160
|
+
})
|
|
12161
|
+
});
|
|
12162
|
+
await collectionSchema.validate(collection);
|
|
12163
|
+
const validCollection = await collectionSchema.cast(collection);
|
|
12164
|
+
if (validCollection.templates) {
|
|
12165
|
+
templates = await sequential(validCollection.templates, async (template) => {
|
|
12166
|
+
if (typeof template === "string") {
|
|
12167
|
+
throw new Error(`Global templates are not yet supported`);
|
|
12168
|
+
}
|
|
12169
|
+
const fields2 = await sequential(template.fields, async (field) => {
|
|
12170
|
+
return validateField(field);
|
|
12171
|
+
});
|
|
12172
|
+
return __spreadValues(__spreadValues({}, validCollection), fields2);
|
|
12173
|
+
});
|
|
12174
|
+
}
|
|
12175
|
+
if (validCollection.fields) {
|
|
12176
|
+
if (typeof validCollection.fields === "string") {
|
|
12177
|
+
throw new Error(`Global templates are not yet supported`);
|
|
12178
|
+
}
|
|
12179
|
+
fields = await sequential(validCollection.fields, async (field) => {
|
|
12180
|
+
return validateField(field);
|
|
12181
|
+
});
|
|
12182
|
+
return __spreadProps(__spreadValues({}, validCollection), {
|
|
12183
|
+
fields
|
|
12184
|
+
});
|
|
12185
|
+
}
|
|
12186
|
+
return collection;
|
|
12187
|
+
};
|
|
12188
|
+
var validateField = async (field) => {
|
|
12189
|
+
const messageName = field.namespace.join(".");
|
|
12190
|
+
const schema = yup2.object({
|
|
12191
|
+
name: yup2.string().matches(/^[a-zA-Z0-9_]*$/, {
|
|
12192
|
+
message: (obj) => `Field's 'name' must match ${obj.regex} at ${messageName}`
|
|
12193
|
+
}).required(),
|
|
12194
|
+
label: yup2.string().required(),
|
|
12195
|
+
type: yup2.string().oneOf(FIELD_TYPES, (obj) => `'type' must be one of: ${obj.values}, but got '${obj.value}' at ${messageName}`)
|
|
12196
|
+
});
|
|
12197
|
+
await schema.validate(field);
|
|
12198
|
+
return field;
|
|
12199
|
+
};
|
|
11712
12200
|
|
|
11713
12201
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/resolver/error.ts
|
|
11714
12202
|
var TinaError = class extends Error {
|
|
@@ -11725,7 +12213,8 @@ var TinaError = class extends Error {
|
|
|
11725
12213
|
var createSchema = async ({
|
|
11726
12214
|
schema
|
|
11727
12215
|
}) => {
|
|
11728
|
-
|
|
12216
|
+
const validSchema = await validateSchema(schema);
|
|
12217
|
+
return new TinaSchema(validSchema);
|
|
11729
12218
|
};
|
|
11730
12219
|
var TinaSchema = class {
|
|
11731
12220
|
constructor(config) {
|
|
@@ -11810,7 +12299,7 @@ var TinaSchema = class {
|
|
|
11810
12299
|
case "object":
|
|
11811
12300
|
return templateInfo.template;
|
|
11812
12301
|
case "union":
|
|
11813
|
-
assertShape(data, (
|
|
12302
|
+
assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
|
|
11814
12303
|
const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
|
|
11815
12304
|
if (!template) {
|
|
11816
12305
|
throw new TinaError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
|
|
@@ -11867,7 +12356,7 @@ var TinaSchema = class {
|
|
|
11867
12356
|
}
|
|
11868
12357
|
}
|
|
11869
12358
|
};
|
|
11870
|
-
this.schema =
|
|
12359
|
+
this.schema = config;
|
|
11871
12360
|
}
|
|
11872
12361
|
};
|
|
11873
12362
|
|
|
@@ -11878,6 +12367,42 @@ var indexDB = async ({ database, config }) => {
|
|
|
11878
12367
|
const graphQLSchema = await _buildSchema(builder, tinaSchema);
|
|
11879
12368
|
await database.put("_graphql", graphQLSchema);
|
|
11880
12369
|
await database.put("_schema", tinaSchema.schema);
|
|
12370
|
+
await _buildFragments(builder, tinaSchema);
|
|
12371
|
+
await _buildQueries(builder, tinaSchema);
|
|
12372
|
+
};
|
|
12373
|
+
var _buildFragments = async (builder, tinaSchema) => {
|
|
12374
|
+
const fragmentDefinitionsFields = [];
|
|
12375
|
+
const collections = tinaSchema.getCollections();
|
|
12376
|
+
await sequential(collections, async (collection) => {
|
|
12377
|
+
const frag = await builder.collectionFragment(collection);
|
|
12378
|
+
fragmentDefinitionsFields.push(frag);
|
|
12379
|
+
});
|
|
12380
|
+
const fragDoc = {
|
|
12381
|
+
kind: "Document",
|
|
12382
|
+
definitions: import_lodash4.default.uniqBy(extractInlineTypes(fragmentDefinitionsFields), (node) => node.name.value)
|
|
12383
|
+
};
|
|
12384
|
+
const fragPath = import_path2.default.join(process.cwd(), ".tina", "__generated__");
|
|
12385
|
+
await import_fs_extra.default.outputFileSync(import_path2.default.join(fragPath, "frags.gql"), (0, import_graphql3.print)(fragDoc));
|
|
12386
|
+
};
|
|
12387
|
+
var _buildQueries = async (builder, tinaSchema) => {
|
|
12388
|
+
const operationsDefinitions = [];
|
|
12389
|
+
const collections = tinaSchema.getCollections();
|
|
12390
|
+
await sequential(collections, async (collection) => {
|
|
12391
|
+
const queryName = NAMER.queryName(collection.namespace);
|
|
12392
|
+
const queryListName = NAMER.generateQueryListName(collection.namespace);
|
|
12393
|
+
const fragName = NAMER.fragmentName(collection.namespace);
|
|
12394
|
+
operationsDefinitions.push(astBuilder.QueryOperationDefinition({ fragName, queryName }));
|
|
12395
|
+
operationsDefinitions.push(astBuilder.ListQueryOperationDefinition({
|
|
12396
|
+
fragName,
|
|
12397
|
+
queryName: queryListName
|
|
12398
|
+
}));
|
|
12399
|
+
});
|
|
12400
|
+
const queryDoc = {
|
|
12401
|
+
kind: "Document",
|
|
12402
|
+
definitions: import_lodash4.default.uniqBy(extractInlineTypes(operationsDefinitions), (node) => node.name.value)
|
|
12403
|
+
};
|
|
12404
|
+
const fragPath = import_path2.default.join(process.cwd(), ".tina", "__generated__");
|
|
12405
|
+
await import_fs_extra.default.outputFileSync(import_path2.default.join(fragPath, "queries.gql"), (0, import_graphql3.print)(queryDoc));
|
|
11881
12406
|
};
|
|
11882
12407
|
var _buildSchema = async (builder, tinaSchema) => {
|
|
11883
12408
|
const definitions = [];
|
|
@@ -11908,19 +12433,20 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
11908
12433
|
name: "Mutation",
|
|
11909
12434
|
fields: mutationTypeDefinitionFields
|
|
11910
12435
|
}));
|
|
11911
|
-
|
|
12436
|
+
const doc = {
|
|
11912
12437
|
kind: "Document",
|
|
11913
12438
|
definitions: import_lodash4.default.uniqBy(extractInlineTypes(definitions), (node) => node.name.value)
|
|
11914
12439
|
};
|
|
12440
|
+
return doc;
|
|
11915
12441
|
};
|
|
11916
12442
|
|
|
11917
12443
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/resolve.ts
|
|
11918
12444
|
var import_lodash7 = __toModule(require("lodash"));
|
|
11919
|
-
var
|
|
12445
|
+
var import_graphql4 = __toModule(require("graphql"));
|
|
11920
12446
|
|
|
11921
12447
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/resolver/index.ts
|
|
11922
12448
|
var import_lodash6 = __toModule(require("lodash"));
|
|
11923
|
-
var
|
|
12449
|
+
var import_path4 = __toModule(require("path"));
|
|
11924
12450
|
var import_isValid = __toModule(require_isValid());
|
|
11925
12451
|
|
|
11926
12452
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/bail-npm-2.0.1-faf99b7186-eab36a71a1.zip/node_modules/bail/index.js
|
|
@@ -12114,7 +12640,7 @@ VFileMessage.prototype.ruleId = null;
|
|
|
12114
12640
|
VFileMessage.prototype.position = null;
|
|
12115
12641
|
|
|
12116
12642
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/vfile-npm-5.1.0-4fbf325323-b36786f162.zip/node_modules/vfile/lib/minpath.js
|
|
12117
|
-
var
|
|
12643
|
+
var import_path3 = __toModule(require("path"));
|
|
12118
12644
|
|
|
12119
12645
|
// pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/vfile-npm-5.1.0-4fbf325323-b36786f162.zip/node_modules/vfile/lib/minproc.js
|
|
12120
12646
|
var import_process = __toModule(require("process"));
|
|
@@ -12166,32 +12692,32 @@ var VFile = class {
|
|
|
12166
12692
|
get path() {
|
|
12167
12693
|
return this.history[this.history.length - 1];
|
|
12168
12694
|
}
|
|
12169
|
-
set path(
|
|
12170
|
-
if (isUrl(
|
|
12171
|
-
|
|
12695
|
+
set path(path8) {
|
|
12696
|
+
if (isUrl(path8)) {
|
|
12697
|
+
path8 = (0, import_url.fileURLToPath)(path8);
|
|
12172
12698
|
}
|
|
12173
|
-
assertNonEmpty(
|
|
12174
|
-
if (this.path !==
|
|
12175
|
-
this.history.push(
|
|
12699
|
+
assertNonEmpty(path8, "path");
|
|
12700
|
+
if (this.path !== path8) {
|
|
12701
|
+
this.history.push(path8);
|
|
12176
12702
|
}
|
|
12177
12703
|
}
|
|
12178
12704
|
get dirname() {
|
|
12179
|
-
return typeof this.path === "string" ?
|
|
12705
|
+
return typeof this.path === "string" ? import_path3.default.dirname(this.path) : void 0;
|
|
12180
12706
|
}
|
|
12181
12707
|
set dirname(dirname) {
|
|
12182
12708
|
assertPath(this.basename, "dirname");
|
|
12183
|
-
this.path =
|
|
12709
|
+
this.path = import_path3.default.join(dirname || "", this.basename);
|
|
12184
12710
|
}
|
|
12185
12711
|
get basename() {
|
|
12186
|
-
return typeof this.path === "string" ?
|
|
12712
|
+
return typeof this.path === "string" ? import_path3.default.basename(this.path) : void 0;
|
|
12187
12713
|
}
|
|
12188
12714
|
set basename(basename) {
|
|
12189
12715
|
assertNonEmpty(basename, "basename");
|
|
12190
12716
|
assertPart(basename, "basename");
|
|
12191
|
-
this.path =
|
|
12717
|
+
this.path = import_path3.default.join(this.dirname || "", basename);
|
|
12192
12718
|
}
|
|
12193
12719
|
get extname() {
|
|
12194
|
-
return typeof this.path === "string" ?
|
|
12720
|
+
return typeof this.path === "string" ? import_path3.default.extname(this.path) : void 0;
|
|
12195
12721
|
}
|
|
12196
12722
|
set extname(extname) {
|
|
12197
12723
|
assertPart(extname, "extname");
|
|
@@ -12204,15 +12730,15 @@ var VFile = class {
|
|
|
12204
12730
|
throw new Error("`extname` cannot contain multiple dots");
|
|
12205
12731
|
}
|
|
12206
12732
|
}
|
|
12207
|
-
this.path =
|
|
12733
|
+
this.path = import_path3.default.join(this.dirname, this.stem + (extname || ""));
|
|
12208
12734
|
}
|
|
12209
12735
|
get stem() {
|
|
12210
|
-
return typeof this.path === "string" ?
|
|
12736
|
+
return typeof this.path === "string" ? import_path3.default.basename(this.path, this.extname) : void 0;
|
|
12211
12737
|
}
|
|
12212
12738
|
set stem(stem) {
|
|
12213
12739
|
assertNonEmpty(stem, "stem");
|
|
12214
12740
|
assertPart(stem, "stem");
|
|
12215
|
-
this.path =
|
|
12741
|
+
this.path = import_path3.default.join(this.dirname || "", stem + (this.extname || ""));
|
|
12216
12742
|
}
|
|
12217
12743
|
toString(encoding) {
|
|
12218
12744
|
return (this.value || "").toString(encoding);
|
|
@@ -12239,8 +12765,8 @@ var VFile = class {
|
|
|
12239
12765
|
}
|
|
12240
12766
|
};
|
|
12241
12767
|
function assertPart(part, name) {
|
|
12242
|
-
if (part && part.includes(
|
|
12243
|
-
throw new Error("`" + name + "` cannot be a path: did not expect `" +
|
|
12768
|
+
if (part && part.includes(import_path3.default.sep)) {
|
|
12769
|
+
throw new Error("`" + name + "` cannot be a path: did not expect `" + import_path3.default.sep + "`");
|
|
12244
12770
|
}
|
|
12245
12771
|
}
|
|
12246
12772
|
function assertNonEmpty(part, name) {
|
|
@@ -12248,8 +12774,8 @@ function assertNonEmpty(part, name) {
|
|
|
12248
12774
|
throw new Error("`" + name + "` cannot be empty");
|
|
12249
12775
|
}
|
|
12250
12776
|
}
|
|
12251
|
-
function assertPath(
|
|
12252
|
-
if (!
|
|
12777
|
+
function assertPath(path8, name) {
|
|
12778
|
+
if (!path8) {
|
|
12253
12779
|
throw new Error("Setting `" + name + "` requires `path` to be set too");
|
|
12254
12780
|
}
|
|
12255
12781
|
}
|
|
@@ -17770,7 +18296,7 @@ function initializeFlow(effects) {
|
|
|
17770
18296
|
var resolver = {
|
|
17771
18297
|
resolveAll: createResolver()
|
|
17772
18298
|
};
|
|
17773
|
-
var
|
|
18299
|
+
var string2 = initializeFactory("string");
|
|
17774
18300
|
var text = initializeFactory("text");
|
|
17775
18301
|
function initializeFactory(field) {
|
|
17776
18302
|
return {
|
|
@@ -18195,7 +18721,7 @@ __export(constructs_exports, {
|
|
|
18195
18721
|
flow: () => flow2,
|
|
18196
18722
|
flowInitial: () => flowInitial,
|
|
18197
18723
|
insideSpan: () => insideSpan,
|
|
18198
|
-
string: () =>
|
|
18724
|
+
string: () => string3,
|
|
18199
18725
|
text: () => text2
|
|
18200
18726
|
});
|
|
18201
18727
|
var document2 = {
|
|
@@ -18232,7 +18758,7 @@ var flow2 = {
|
|
|
18232
18758
|
[96]: codeFenced,
|
|
18233
18759
|
[126]: codeFenced
|
|
18234
18760
|
};
|
|
18235
|
-
var
|
|
18761
|
+
var string3 = {
|
|
18236
18762
|
[38]: characterReference,
|
|
18237
18763
|
[92]: characterEscape
|
|
18238
18764
|
};
|
|
@@ -18270,7 +18796,7 @@ function parse(options = {}) {
|
|
|
18270
18796
|
content: create(content),
|
|
18271
18797
|
document: create(document),
|
|
18272
18798
|
flow: create(flow),
|
|
18273
|
-
string: create(
|
|
18799
|
+
string: create(string2),
|
|
18274
18800
|
text: create(text)
|
|
18275
18801
|
};
|
|
18276
18802
|
return parser;
|
|
@@ -18863,9 +19389,9 @@ function compiler(options = {}) {
|
|
|
18863
19389
|
}
|
|
18864
19390
|
function onexitlabeltext(token) {
|
|
18865
19391
|
const ancestor = this.stack[this.stack.length - 2];
|
|
18866
|
-
const
|
|
18867
|
-
ancestor.label = decodeString(
|
|
18868
|
-
ancestor.identifier = normalizeIdentifier(
|
|
19392
|
+
const string4 = this.sliceSerialize(token);
|
|
19393
|
+
ancestor.label = decodeString(string4);
|
|
19394
|
+
ancestor.identifier = normalizeIdentifier(string4).toLowerCase();
|
|
18869
19395
|
}
|
|
18870
19396
|
function onexitlabel() {
|
|
18871
19397
|
const fragment = this.stack[this.stack.length - 1];
|
|
@@ -21379,8 +21905,8 @@ var Resolver = class {
|
|
|
21379
21905
|
data: rawData,
|
|
21380
21906
|
collection
|
|
21381
21907
|
});
|
|
21382
|
-
const basename =
|
|
21383
|
-
const extension2 =
|
|
21908
|
+
const basename = import_path4.default.basename(fullPath);
|
|
21909
|
+
const extension2 = import_path4.default.extname(fullPath);
|
|
21384
21910
|
const filename = basename.replace(extension2, "");
|
|
21385
21911
|
const relativePath = fullPath.replace("\\", "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
|
|
21386
21912
|
const breadcrumbs = filename.split("/");
|
|
@@ -21446,6 +21972,7 @@ var Resolver = class {
|
|
|
21446
21972
|
const templates = {};
|
|
21447
21973
|
await sequential(collectable.templates, async (template) => {
|
|
21448
21974
|
templates[lastItem(template.namespace)] = {
|
|
21975
|
+
template,
|
|
21449
21976
|
fields: await sequential(template.fields, async (field) => {
|
|
21450
21977
|
return this.resolveField(field);
|
|
21451
21978
|
})
|
|
@@ -21464,64 +21991,111 @@ var Resolver = class {
|
|
|
21464
21991
|
throw e;
|
|
21465
21992
|
}
|
|
21466
21993
|
};
|
|
21467
|
-
this.
|
|
21468
|
-
|
|
21469
|
-
|
|
21470
|
-
|
|
21471
|
-
|
|
21472
|
-
|
|
21473
|
-
|
|
21474
|
-
|
|
21475
|
-
|
|
21476
|
-
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
|
|
21483
|
-
|
|
21484
|
-
|
|
21485
|
-
}
|
|
21486
|
-
const templateInfo2 = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
21487
|
-
switch (templateInfo2.type) {
|
|
21488
|
-
case "object":
|
|
21489
|
-
await this.database.put(realPath, {});
|
|
21490
|
-
break;
|
|
21491
|
-
case "union":
|
|
21492
|
-
const templateString = args.template;
|
|
21493
|
-
const template = templateInfo2.templates.find((template2) => lastItem(template2.namespace) === templateString);
|
|
21494
|
-
if (!args.template) {
|
|
21495
|
-
throw new Error(`Must specify a template when creating content for a collection with multiple templates. Possible templates are: ${templateInfo2.templates.map((t) => lastItem(t.namespace)).join(" ")}`);
|
|
21496
|
-
}
|
|
21497
|
-
if (!template) {
|
|
21498
|
-
throw new Error(`Expected to find template named ${templateString} in collection "${collectionName}" but none was found. Possible templates are: ${templateInfo2.templates.map((t) => lastItem(t.namespace)).join(" ")}`);
|
|
21994
|
+
this.buildObjectMutations = (fieldValue, field) => {
|
|
21995
|
+
if (field.fields) {
|
|
21996
|
+
const objectTemplate = typeof field.fields === "string" ? this.tinaSchema.getGlobalTemplate(field.fields) : field;
|
|
21997
|
+
if (Array.isArray(fieldValue)) {
|
|
21998
|
+
return fieldValue.map((item) => this.buildFieldMutations(item, objectTemplate));
|
|
21999
|
+
} else {
|
|
22000
|
+
return this.buildFieldMutations(fieldValue, objectTemplate);
|
|
22001
|
+
}
|
|
22002
|
+
}
|
|
22003
|
+
if (field.templates) {
|
|
22004
|
+
if (Array.isArray(fieldValue)) {
|
|
22005
|
+
return fieldValue.map((item) => {
|
|
22006
|
+
if (typeof item === "string") {
|
|
22007
|
+
throw new Error(`Expected object for template value for field ${field.name}`);
|
|
22008
|
+
}
|
|
22009
|
+
const templates = field.templates.map((templateOrTemplateName) => {
|
|
22010
|
+
if (typeof templateOrTemplateName === "string") {
|
|
22011
|
+
return this.tinaSchema.getGlobalTemplate(templateOrTemplateName);
|
|
21499
22012
|
}
|
|
21500
|
-
|
|
21501
|
-
|
|
21502
|
-
|
|
21503
|
-
|
|
21504
|
-
|
|
22013
|
+
return templateOrTemplateName;
|
|
22014
|
+
});
|
|
22015
|
+
const [templateName] = Object.entries(item)[0];
|
|
22016
|
+
const template = templates.find((template2) => template2.name === templateName);
|
|
22017
|
+
if (!template) {
|
|
22018
|
+
throw new Error(`Expected to find template ${templateName}`);
|
|
22019
|
+
}
|
|
22020
|
+
return __spreadProps(__spreadValues({}, this.buildFieldMutations(item[template.name], template)), {
|
|
22021
|
+
_template: template.name
|
|
22022
|
+
});
|
|
22023
|
+
});
|
|
21505
22024
|
} else {
|
|
21506
|
-
if (
|
|
21507
|
-
throw new Error(`
|
|
22025
|
+
if (typeof fieldValue === "string") {
|
|
22026
|
+
throw new Error(`Expected object for template value for field ${field.name}`);
|
|
21508
22027
|
}
|
|
22028
|
+
const templates = field.templates.map((templateOrTemplateName) => {
|
|
22029
|
+
if (typeof templateOrTemplateName === "string") {
|
|
22030
|
+
return this.tinaSchema.getGlobalTemplate(templateOrTemplateName);
|
|
22031
|
+
}
|
|
22032
|
+
return templateOrTemplateName;
|
|
22033
|
+
});
|
|
22034
|
+
const [templateName] = Object.entries(fieldValue)[0];
|
|
22035
|
+
const template = templates.find((template2) => template2.name === templateName);
|
|
22036
|
+
if (!template) {
|
|
22037
|
+
throw new Error(`Expected to find template ${templateName}`);
|
|
22038
|
+
}
|
|
22039
|
+
return __spreadProps(__spreadValues({}, this.buildFieldMutations(fieldValue[template.name], template)), {
|
|
22040
|
+
_template: template.name
|
|
22041
|
+
});
|
|
21509
22042
|
}
|
|
22043
|
+
}
|
|
22044
|
+
};
|
|
22045
|
+
this.createResolveDocument = async ({
|
|
22046
|
+
collection,
|
|
22047
|
+
realPath,
|
|
22048
|
+
args,
|
|
22049
|
+
isAddPendingDocument
|
|
22050
|
+
}) => {
|
|
22051
|
+
if (isAddPendingDocument === true) {
|
|
22052
|
+
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
22053
|
+
switch (templateInfo.type) {
|
|
22054
|
+
case "object":
|
|
22055
|
+
await this.database.put(realPath, {});
|
|
22056
|
+
break;
|
|
22057
|
+
case "union":
|
|
22058
|
+
const templateString = args.template;
|
|
22059
|
+
const template = templateInfo.templates.find((template2) => lastItem(template2.namespace) === templateString);
|
|
22060
|
+
if (!args.template) {
|
|
22061
|
+
throw new Error(`Must specify a template when creating content for a collection with multiple templates. Possible templates are: ${templateInfo.templates.map((t) => lastItem(t.namespace)).join(" ")}`);
|
|
22062
|
+
}
|
|
22063
|
+
if (!template) {
|
|
22064
|
+
throw new Error(`Expected to find template named ${templateString} in collection "${collection.name}" but none was found. Possible templates are: ${templateInfo.templates.map((t) => lastItem(t.namespace)).join(" ")}`);
|
|
22065
|
+
}
|
|
22066
|
+
await this.database.put(realPath, {
|
|
22067
|
+
_template: lastItem(template.namespace)
|
|
22068
|
+
});
|
|
22069
|
+
}
|
|
22070
|
+
return this.getDocument(realPath);
|
|
22071
|
+
}
|
|
22072
|
+
const params = this.buildObjectMutations(args.params[collection.name], collection);
|
|
22073
|
+
await this.database.put(realPath, params);
|
|
22074
|
+
return this.getDocument(realPath);
|
|
22075
|
+
};
|
|
22076
|
+
this.updateResolveDocument = async ({
|
|
22077
|
+
collection,
|
|
22078
|
+
realPath,
|
|
22079
|
+
args,
|
|
22080
|
+
isAddPendingDocument,
|
|
22081
|
+
isCollectionSpecific
|
|
22082
|
+
}) => {
|
|
22083
|
+
if (isAddPendingDocument === true) {
|
|
21510
22084
|
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
21511
|
-
const
|
|
22085
|
+
const params2 = this.buildParams(args);
|
|
21512
22086
|
switch (templateInfo.type) {
|
|
21513
22087
|
case "object":
|
|
21514
|
-
if (
|
|
21515
|
-
const values = this.buildFieldMutations(
|
|
22088
|
+
if (params2) {
|
|
22089
|
+
const values = this.buildFieldMutations(params2, templateInfo.template);
|
|
21516
22090
|
await this.database.put(realPath, values);
|
|
21517
22091
|
}
|
|
21518
22092
|
break;
|
|
21519
22093
|
case "union":
|
|
21520
22094
|
await sequential(templateInfo.templates, async (template) => {
|
|
21521
|
-
const templateParams =
|
|
22095
|
+
const templateParams = params2[lastItem(template.namespace)];
|
|
21522
22096
|
if (templateParams) {
|
|
21523
22097
|
if (typeof templateParams === "string") {
|
|
21524
|
-
throw new Error(`Expected to find an
|
|
22098
|
+
throw new Error(`Expected to find an object for template params, but got string`);
|
|
21525
22099
|
}
|
|
21526
22100
|
const values = __spreadProps(__spreadValues({}, this.buildFieldMutations(templateParams, template)), {
|
|
21527
22101
|
_template: lastItem(template.namespace)
|
|
@@ -21530,9 +22104,58 @@ var Resolver = class {
|
|
|
21530
22104
|
}
|
|
21531
22105
|
});
|
|
21532
22106
|
}
|
|
22107
|
+
return this.getDocument(realPath);
|
|
21533
22108
|
}
|
|
22109
|
+
const params = this.buildObjectMutations(isCollectionSpecific ? args.params : args.params[collection.name], collection);
|
|
22110
|
+
await this.database.put(realPath, params);
|
|
21534
22111
|
return this.getDocument(realPath);
|
|
21535
22112
|
};
|
|
22113
|
+
this.resolveDocument = async ({
|
|
22114
|
+
args,
|
|
22115
|
+
collection: collectionName,
|
|
22116
|
+
isMutation,
|
|
22117
|
+
isCreation,
|
|
22118
|
+
isAddPendingDocument,
|
|
22119
|
+
isCollectionSpecific
|
|
22120
|
+
}) => {
|
|
22121
|
+
let collectionLookup = collectionName || void 0;
|
|
22122
|
+
if (!collectionLookup && isCollectionSpecific === false) {
|
|
22123
|
+
collectionLookup = Object.keys(args.params)[0];
|
|
22124
|
+
}
|
|
22125
|
+
const collectionNames = this.tinaSchema.getCollections().map((item) => item.name);
|
|
22126
|
+
assertShape(collectionLookup, (yup3) => {
|
|
22127
|
+
return yup3.mixed().oneOf(collectionNames);
|
|
22128
|
+
}, `"collection" must be one of: [${collectionNames.join(", ")}] but got ${collectionLookup}`);
|
|
22129
|
+
assertShape(args, (yup3) => yup3.object({ relativePath: yup3.string().required() }));
|
|
22130
|
+
const collection = await this.tinaSchema.getCollection(collectionLookup);
|
|
22131
|
+
const realPath = import_path4.default.join(collection == null ? void 0 : collection.path, args.relativePath);
|
|
22132
|
+
const alreadyExists = await this.database.documentExists(realPath);
|
|
22133
|
+
if (isMutation) {
|
|
22134
|
+
if (isCreation) {
|
|
22135
|
+
if (alreadyExists === true) {
|
|
22136
|
+
throw new Error(`Unable to add document, ${realPath} already exists`);
|
|
22137
|
+
}
|
|
22138
|
+
return this.createResolveDocument({
|
|
22139
|
+
collection,
|
|
22140
|
+
realPath,
|
|
22141
|
+
args,
|
|
22142
|
+
isAddPendingDocument
|
|
22143
|
+
});
|
|
22144
|
+
}
|
|
22145
|
+
if (alreadyExists === false) {
|
|
22146
|
+
throw new Error(`Unable to update document, ${realPath} does not exist`);
|
|
22147
|
+
}
|
|
22148
|
+
return this.updateResolveDocument({
|
|
22149
|
+
collection,
|
|
22150
|
+
realPath,
|
|
22151
|
+
args,
|
|
22152
|
+
isAddPendingDocument,
|
|
22153
|
+
isCollectionSpecific
|
|
22154
|
+
});
|
|
22155
|
+
} else {
|
|
22156
|
+
return this.getDocument(realPath);
|
|
22157
|
+
}
|
|
22158
|
+
};
|
|
21536
22159
|
this.resolveCollectionConnections = async ({ ids }) => {
|
|
21537
22160
|
return {
|
|
21538
22161
|
totalCount: ids.length,
|
|
@@ -21582,40 +22205,7 @@ var Resolver = class {
|
|
|
21582
22205
|
accum[fieldName] = fieldValue;
|
|
21583
22206
|
break;
|
|
21584
22207
|
case "object":
|
|
21585
|
-
|
|
21586
|
-
const objectTemplate = typeof field.fields === "string" ? this.tinaSchema.getGlobalTemplate(field.fields) : field;
|
|
21587
|
-
if (Array.isArray(fieldValue)) {
|
|
21588
|
-
accum[fieldName] = fieldValue.map((item) => this.buildFieldMutations(item, objectTemplate));
|
|
21589
|
-
} else {
|
|
21590
|
-
accum[fieldName] = this.buildFieldMutations(fieldValue, objectTemplate);
|
|
21591
|
-
}
|
|
21592
|
-
break;
|
|
21593
|
-
}
|
|
21594
|
-
if (field.templates) {
|
|
21595
|
-
if (Array.isArray(fieldValue)) {
|
|
21596
|
-
accum[fieldName] = fieldValue.map((item) => {
|
|
21597
|
-
if (typeof item === "string") {
|
|
21598
|
-
throw new Error(`Expected object for template value for field ${field.name}`);
|
|
21599
|
-
}
|
|
21600
|
-
const templates = field.templates.map((templateOrTemplateName) => {
|
|
21601
|
-
if (typeof templateOrTemplateName === "string") {
|
|
21602
|
-
return this.tinaSchema.getGlobalTemplate(templateOrTemplateName);
|
|
21603
|
-
}
|
|
21604
|
-
return templateOrTemplateName;
|
|
21605
|
-
});
|
|
21606
|
-
const [templateName] = Object.entries(item)[0];
|
|
21607
|
-
const template2 = templates.find((template3) => template3.name === templateName);
|
|
21608
|
-
if (!template2) {
|
|
21609
|
-
throw new Error(`Expected to find template ${templateName}`);
|
|
21610
|
-
}
|
|
21611
|
-
return __spreadProps(__spreadValues({}, this.buildFieldMutations(item[template2.name], template2)), {
|
|
21612
|
-
_template: template2.name
|
|
21613
|
-
});
|
|
21614
|
-
});
|
|
21615
|
-
} else {
|
|
21616
|
-
throw new Error("Not implement for polymorphic objects which are not lists");
|
|
21617
|
-
}
|
|
21618
|
-
}
|
|
22208
|
+
accum[fieldName] = this.buildObjectMutations(fieldValue, field);
|
|
21619
22209
|
break;
|
|
21620
22210
|
case "rich-text":
|
|
21621
22211
|
field;
|
|
@@ -21635,7 +22225,7 @@ var Resolver = class {
|
|
|
21635
22225
|
if (!rawData) {
|
|
21636
22226
|
return void 0;
|
|
21637
22227
|
}
|
|
21638
|
-
assertShape(rawData, (
|
|
22228
|
+
assertShape(rawData, (yup3) => yup3.object());
|
|
21639
22229
|
const value = rawData[field.name];
|
|
21640
22230
|
switch (field.type) {
|
|
21641
22231
|
case "string":
|
|
@@ -21659,7 +22249,7 @@ var Resolver = class {
|
|
|
21659
22249
|
if (!value) {
|
|
21660
22250
|
return;
|
|
21661
22251
|
}
|
|
21662
|
-
assertShape(value, (
|
|
22252
|
+
assertShape(value, (yup3) => yup3.array().of(yup3.object().required()));
|
|
21663
22253
|
accumulator[field.name] = await sequential(value, async (item) => {
|
|
21664
22254
|
const template = await this.tinaSchema.getTemplateForData({
|
|
21665
22255
|
data: item,
|
|
@@ -21703,15 +22293,15 @@ var Resolver = class {
|
|
|
21703
22293
|
};
|
|
21704
22294
|
this.buildParams = (args) => {
|
|
21705
22295
|
try {
|
|
21706
|
-
assertShape(args, (
|
|
21707
|
-
collection:
|
|
21708
|
-
params:
|
|
22296
|
+
assertShape(args, (yup3) => yup3.object({
|
|
22297
|
+
collection: yup3.string().required(),
|
|
22298
|
+
params: yup3.object().required()
|
|
21709
22299
|
}));
|
|
21710
22300
|
return args.params[args.collection];
|
|
21711
22301
|
} catch (e) {
|
|
21712
22302
|
}
|
|
21713
|
-
assertShape(args, (
|
|
21714
|
-
params:
|
|
22303
|
+
assertShape(args, (yup3) => yup3.object({
|
|
22304
|
+
params: yup3.object().required()
|
|
21715
22305
|
}));
|
|
21716
22306
|
return args.params;
|
|
21717
22307
|
};
|
|
@@ -21825,7 +22415,7 @@ var Resolver = class {
|
|
|
21825
22415
|
return this.database.getDocumentsForCollection(collectionName);
|
|
21826
22416
|
}));
|
|
21827
22417
|
return __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
21828
|
-
component: "
|
|
22418
|
+
component: "reference",
|
|
21829
22419
|
options: [
|
|
21830
22420
|
{ label: "Choose an option", value: "" },
|
|
21831
22421
|
...documents.map((filepath) => {
|
|
@@ -21860,28 +22450,28 @@ var resolve = async ({
|
|
|
21860
22450
|
}) => {
|
|
21861
22451
|
try {
|
|
21862
22452
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
21863
|
-
const graphQLSchema = (0,
|
|
22453
|
+
const graphQLSchema = (0, import_graphql4.buildASTSchema)(graphQLSchemaAst);
|
|
21864
22454
|
const config = await database.getTinaSchema();
|
|
21865
22455
|
const tinaSchema = await createSchema({ schema: config });
|
|
21866
22456
|
const resolver2 = await createResolver2({ database, tinaSchema });
|
|
21867
22457
|
const paths = [];
|
|
21868
22458
|
const mutationPaths = [];
|
|
21869
|
-
const ast = (0,
|
|
21870
|
-
const typeInfo = new
|
|
22459
|
+
const ast = (0, import_graphql4.parse)(query);
|
|
22460
|
+
const typeInfo = new import_graphql4.TypeInfo(graphQLSchema);
|
|
21871
22461
|
const referencePathVisitor = () => {
|
|
21872
22462
|
return {
|
|
21873
22463
|
leave: {
|
|
21874
|
-
Field(node, key2, parent,
|
|
22464
|
+
Field(node, key2, parent, path8, ancestors) {
|
|
21875
22465
|
const type = typeInfo.getType();
|
|
21876
22466
|
if (type) {
|
|
21877
|
-
const realType = (0,
|
|
21878
|
-
if (realType instanceof
|
|
22467
|
+
const realType = (0, import_graphql4.getNamedType)(type);
|
|
22468
|
+
if (realType instanceof import_graphql4.GraphQLUnionType) {
|
|
21879
22469
|
const hasNodeInterface = !!realType.getTypes().find((objectType) => objectType.getInterfaces().find((intfc) => intfc.name === "Node"));
|
|
21880
22470
|
if (hasNodeInterface) {
|
|
21881
22471
|
const p = [];
|
|
21882
22472
|
ancestors.forEach((item, index2) => {
|
|
21883
22473
|
var _a;
|
|
21884
|
-
const activePath =
|
|
22474
|
+
const activePath = path8[index2];
|
|
21885
22475
|
const result = item[activePath];
|
|
21886
22476
|
if ((_a = result == null ? void 0 : result.name) == null ? void 0 : _a.value) {
|
|
21887
22477
|
if (result.kind === "Field") {
|
|
@@ -21903,8 +22493,8 @@ var resolve = async ({
|
|
|
21903
22493
|
}
|
|
21904
22494
|
};
|
|
21905
22495
|
};
|
|
21906
|
-
(0,
|
|
21907
|
-
const res = await (0,
|
|
22496
|
+
(0, import_graphql4.visit)(ast, (0, import_graphql4.visitWithTypeInfo)(typeInfo, referencePathVisitor()));
|
|
22497
|
+
const res = await (0, import_graphql4.graphql)({
|
|
21908
22498
|
schema: graphQLSchema,
|
|
21909
22499
|
source: query,
|
|
21910
22500
|
variableValues: variables,
|
|
@@ -21914,7 +22504,7 @@ var resolve = async ({
|
|
|
21914
22504
|
typeResolver: async (source, _args, info) => {
|
|
21915
22505
|
if (source.__typename)
|
|
21916
22506
|
return source.__typename;
|
|
21917
|
-
const namedType = (0,
|
|
22507
|
+
const namedType = (0, import_graphql4.getNamedType)(info.returnType).toString();
|
|
21918
22508
|
const lookup = await database.getLookup(namedType);
|
|
21919
22509
|
if (lookup.resolveType === "unionData") {
|
|
21920
22510
|
return lookup.typeMap[source._template];
|
|
@@ -21924,7 +22514,7 @@ var resolve = async ({
|
|
|
21924
22514
|
},
|
|
21925
22515
|
fieldResolver: async (source = {}, _args = {}, _context, info) => {
|
|
21926
22516
|
const args = JSON.parse(JSON.stringify(_args));
|
|
21927
|
-
const returnType = (0,
|
|
22517
|
+
const returnType = (0, import_graphql4.getNamedType)(info.returnType).toString();
|
|
21928
22518
|
const lookup = await database.getLookup(returnType);
|
|
21929
22519
|
const isMutation = info.parentType.toString() === "Mutation";
|
|
21930
22520
|
const value = source[info.fieldName];
|
|
@@ -21948,7 +22538,7 @@ var resolve = async ({
|
|
|
21948
22538
|
const isCreation = lookup[info.fieldName] === "create";
|
|
21949
22539
|
switch (lookup.resolveType) {
|
|
21950
22540
|
case "nodeDocument":
|
|
21951
|
-
assertShape(args, (
|
|
22541
|
+
assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
|
|
21952
22542
|
return resolver2.getDocument(args.id);
|
|
21953
22543
|
case "multiCollectionDocument":
|
|
21954
22544
|
if (typeof value === "string") {
|
|
@@ -21956,20 +22546,21 @@ var resolve = async ({
|
|
|
21956
22546
|
}
|
|
21957
22547
|
if (args && args.collection && info.fieldName === "addPendingDocument") {
|
|
21958
22548
|
return resolver2.resolveDocument({
|
|
21959
|
-
value,
|
|
21960
22549
|
args: __spreadProps(__spreadValues({}, args), { params: {} }),
|
|
21961
22550
|
collection: args.collection,
|
|
21962
22551
|
isMutation,
|
|
21963
|
-
isCreation: true
|
|
22552
|
+
isCreation: true,
|
|
22553
|
+
isAddPendingDocument: true
|
|
21964
22554
|
});
|
|
21965
22555
|
}
|
|
21966
22556
|
if (["getDocument", "createDocument", "updateDocument"].includes(info.fieldName)) {
|
|
21967
22557
|
const result2 = await resolver2.resolveDocument({
|
|
21968
|
-
value,
|
|
21969
22558
|
args,
|
|
21970
22559
|
collection: args.collection,
|
|
21971
22560
|
isMutation,
|
|
21972
|
-
isCreation
|
|
22561
|
+
isCreation,
|
|
22562
|
+
isAddPendingDocument: false,
|
|
22563
|
+
isCollectionSpecific: false
|
|
21973
22564
|
});
|
|
21974
22565
|
if (!isMutation) {
|
|
21975
22566
|
const mutationPath = buildMutationPath(info, {
|
|
@@ -21983,7 +22574,7 @@ var resolve = async ({
|
|
|
21983
22574
|
}
|
|
21984
22575
|
return value;
|
|
21985
22576
|
case "multiCollectionDocumentList":
|
|
21986
|
-
assertShape(value, (
|
|
22577
|
+
assertShape(value, (yup3) => yup3.array().of(yup3.string()));
|
|
21987
22578
|
return resolver2.resolveCollectionConnections({
|
|
21988
22579
|
ids: value || []
|
|
21989
22580
|
});
|
|
@@ -21992,11 +22583,12 @@ var resolve = async ({
|
|
|
21992
22583
|
return value;
|
|
21993
22584
|
}
|
|
21994
22585
|
const result = value || await resolver2.resolveDocument({
|
|
21995
|
-
value,
|
|
21996
22586
|
args,
|
|
21997
22587
|
collection: lookup.collection,
|
|
21998
22588
|
isMutation,
|
|
21999
|
-
isCreation
|
|
22589
|
+
isCreation,
|
|
22590
|
+
isAddPendingDocument: false,
|
|
22591
|
+
isCollectionSpecific: true
|
|
22000
22592
|
});
|
|
22001
22593
|
if (!isMutation) {
|
|
22002
22594
|
const mutationPath = buildMutationPath(info, {
|
|
@@ -22032,7 +22624,7 @@ var resolve = async ({
|
|
|
22032
22624
|
});
|
|
22033
22625
|
return res;
|
|
22034
22626
|
} catch (e) {
|
|
22035
|
-
if (e instanceof
|
|
22627
|
+
if (e instanceof import_graphql4.GraphQLError) {
|
|
22036
22628
|
return {
|
|
22037
22629
|
errors: [e]
|
|
22038
22630
|
};
|
|
@@ -22041,17 +22633,17 @@ var resolve = async ({
|
|
|
22041
22633
|
}
|
|
22042
22634
|
}
|
|
22043
22635
|
};
|
|
22044
|
-
var buildPath = (
|
|
22045
|
-
if (
|
|
22046
|
-
buildPath(
|
|
22636
|
+
var buildPath = (path8, accum) => {
|
|
22637
|
+
if (path8.prev) {
|
|
22638
|
+
buildPath(path8.prev, accum);
|
|
22047
22639
|
}
|
|
22048
|
-
accum.push(
|
|
22640
|
+
accum.push(path8.key);
|
|
22049
22641
|
return accum;
|
|
22050
22642
|
};
|
|
22051
|
-
var buildReferenceQuery = (fieldNode,
|
|
22643
|
+
var buildReferenceQuery = (fieldNode, path8) => {
|
|
22052
22644
|
if (fieldNode) {
|
|
22053
|
-
const p =
|
|
22054
|
-
const dataPath =
|
|
22645
|
+
const p = path8.map((item) => item === "data" ? "form" : item);
|
|
22646
|
+
const dataPath = path8;
|
|
22055
22647
|
const newNode = __spreadProps(__spreadValues({}, fieldNode), {
|
|
22056
22648
|
name: { kind: "Name", value: "node" },
|
|
22057
22649
|
arguments: [
|
|
@@ -22105,7 +22697,7 @@ var buildReferenceQuery = (fieldNode, path7) => {
|
|
|
22105
22697
|
selections: [newNode]
|
|
22106
22698
|
}
|
|
22107
22699
|
};
|
|
22108
|
-
const queryString = (0,
|
|
22700
|
+
const queryString = (0, import_graphql4.print)(q);
|
|
22109
22701
|
return {
|
|
22110
22702
|
path: ["data", ...p.slice(0, -1)],
|
|
22111
22703
|
dataPath,
|
|
@@ -22216,10 +22808,10 @@ function addFragmentsToQuery(info, fieldNode, q) {
|
|
|
22216
22808
|
subFrags: []
|
|
22217
22809
|
};
|
|
22218
22810
|
frags.push(frag);
|
|
22219
|
-
(0,
|
|
22811
|
+
(0, import_graphql4.visit)(fragmentDefinition, fragmentSpreadVisitor(frag));
|
|
22220
22812
|
});
|
|
22221
22813
|
const n = {
|
|
22222
|
-
query: (0,
|
|
22814
|
+
query: (0, import_graphql4.print)(fieldNode),
|
|
22223
22815
|
fragments: []
|
|
22224
22816
|
};
|
|
22225
22817
|
const visitor = {
|
|
@@ -22229,7 +22821,7 @@ function addFragmentsToQuery(info, fieldNode, q) {
|
|
|
22229
22821
|
}
|
|
22230
22822
|
}
|
|
22231
22823
|
};
|
|
22232
|
-
(0,
|
|
22824
|
+
(0, import_graphql4.visit)(fieldNode, visitor);
|
|
22233
22825
|
const getFrags = (fragNames, accum) => {
|
|
22234
22826
|
fragNames.forEach((fragName) => {
|
|
22235
22827
|
const frag = frags.find((f) => f.name === fragName);
|
|
@@ -22244,73 +22836,30 @@ function addFragmentsToQuery(info, fieldNode, q) {
|
|
|
22244
22836
|
return accum;
|
|
22245
22837
|
};
|
|
22246
22838
|
const fragss = getFrags(n.fragments, []);
|
|
22247
|
-
const queryString = `${fragss.map((f) => (0,
|
|
22248
|
-
${(0,
|
|
22839
|
+
const queryString = `${fragss.map((f) => (0, import_graphql4.print)(f)).join("\n")}
|
|
22840
|
+
${(0, import_graphql4.print)(q)}`;
|
|
22249
22841
|
return queryString;
|
|
22250
22842
|
}
|
|
22251
22843
|
|
|
22252
22844
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/index.ts
|
|
22253
|
-
var
|
|
22254
|
-
|
|
22255
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/cache/lru.ts
|
|
22256
|
-
var import_lru_cache2 = __toModule(require("lru-cache"));
|
|
22257
|
-
var cache2 = new import_lru_cache2.default({
|
|
22258
|
-
max: 1e3,
|
|
22259
|
-
length: function(v, key2) {
|
|
22260
|
-
return v.length;
|
|
22261
|
-
}
|
|
22262
|
-
});
|
|
22263
|
-
var clearCache = ({
|
|
22264
|
-
owner,
|
|
22265
|
-
repo,
|
|
22266
|
-
ref,
|
|
22267
|
-
path: path7
|
|
22268
|
-
}) => {
|
|
22269
|
-
const repoPrefix = `${owner}/${repo}/${ref}/`;
|
|
22270
|
-
if (path7) {
|
|
22271
|
-
const key2 = `${repoPrefix}/${path7}`;
|
|
22272
|
-
console.log("[LRU cache]: clearing key ", key2);
|
|
22273
|
-
cache2.del(key2);
|
|
22274
|
-
} else {
|
|
22275
|
-
console.log("[LRU cache]: clearing all keys for repo ", repoPrefix);
|
|
22276
|
-
cache2.forEach((value, key2, cache3) => {
|
|
22277
|
-
if (key2.startsWith(repoPrefix)) {
|
|
22278
|
-
cache3.del(key2);
|
|
22279
|
-
}
|
|
22280
|
-
});
|
|
22281
|
-
}
|
|
22282
|
-
};
|
|
22283
|
-
var simpleCache2 = {
|
|
22284
|
-
get: async (keyName, setter) => {
|
|
22285
|
-
const value = cache2.get(keyName);
|
|
22286
|
-
if (value) {
|
|
22287
|
-
console.log("getting from cache", keyName);
|
|
22288
|
-
return value;
|
|
22289
|
-
} else {
|
|
22290
|
-
const valueToCache = await setter();
|
|
22291
|
-
const isSet = cache2.set(keyName, valueToCache);
|
|
22292
|
-
console.log("item not in cache, setting", keyName, isSet);
|
|
22293
|
-
return valueToCache;
|
|
22294
|
-
}
|
|
22295
|
-
}
|
|
22296
|
-
};
|
|
22845
|
+
var import_graphql6 = __toModule(require("graphql"));
|
|
22297
22846
|
|
|
22298
22847
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/database/index.ts
|
|
22299
22848
|
var import_gray_matter = __toModule(require("gray-matter"));
|
|
22300
|
-
var
|
|
22849
|
+
var import_path6 = __toModule(require("path"));
|
|
22301
22850
|
|
|
22302
22851
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/database/bridge.ts
|
|
22303
|
-
var
|
|
22852
|
+
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
22304
22853
|
var import_fast_glob = __toModule(require("fast-glob"));
|
|
22305
|
-
var
|
|
22854
|
+
var import_path5 = __toModule(require("path"));
|
|
22306
22855
|
var import_normalize_path = __toModule(require("normalize-path"));
|
|
22307
22856
|
var FilesystemBridge = class {
|
|
22308
22857
|
constructor(rootPath) {
|
|
22309
22858
|
this.rootPath = rootPath || "";
|
|
22310
22859
|
}
|
|
22311
22860
|
async glob(pattern) {
|
|
22312
|
-
const basePath =
|
|
22313
|
-
const items = await (0, import_fast_glob.default)(
|
|
22861
|
+
const basePath = import_path5.default.join(this.rootPath, ...pattern.split("/"));
|
|
22862
|
+
const items = await (0, import_fast_glob.default)(import_path5.default.join(basePath, "**", "/*").replace(/\\/g, "/"), {
|
|
22314
22863
|
dot: true
|
|
22315
22864
|
});
|
|
22316
22865
|
const posixRootPath = (0, import_normalize_path.default)(this.rootPath);
|
|
@@ -22319,20 +22868,20 @@ var FilesystemBridge = class {
|
|
|
22319
22868
|
});
|
|
22320
22869
|
}
|
|
22321
22870
|
async get(filepath) {
|
|
22322
|
-
return
|
|
22871
|
+
return import_fs_extra2.default.readFileSync(import_path5.default.join(this.rootPath, filepath)).toString();
|
|
22323
22872
|
}
|
|
22324
22873
|
async put(filepath, data) {
|
|
22325
|
-
await
|
|
22874
|
+
await import_fs_extra2.default.outputFileSync(import_path5.default.join(this.rootPath, filepath), data);
|
|
22326
22875
|
}
|
|
22327
22876
|
};
|
|
22328
22877
|
|
|
22329
22878
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/primitives/database/index.ts
|
|
22330
|
-
var
|
|
22879
|
+
var import_graphql5 = __toModule(require("graphql"));
|
|
22331
22880
|
var createDatabase = async (config) => {
|
|
22332
22881
|
return new Database(config);
|
|
22333
22882
|
};
|
|
22334
22883
|
var SYSTEM_FILES = ["_schema", "_graphql", "_lookup"];
|
|
22335
|
-
var GENERATED_FOLDER =
|
|
22884
|
+
var GENERATED_FOLDER = import_path6.default.join(".tina", "__generated__");
|
|
22336
22885
|
var Database = class {
|
|
22337
22886
|
constructor(config) {
|
|
22338
22887
|
this.config = config;
|
|
@@ -22340,20 +22889,20 @@ var Database = class {
|
|
|
22340
22889
|
var _a;
|
|
22341
22890
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
22342
22891
|
try {
|
|
22343
|
-
const dataString = await this.bridge.get(
|
|
22892
|
+
const dataString = await this.bridge.get(import_path6.default.join(GENERATED_FOLDER, `${filepath}.json`));
|
|
22344
22893
|
return JSON.parse(dataString);
|
|
22345
22894
|
} catch (err) {
|
|
22346
|
-
if (err instanceof
|
|
22347
|
-
throw new
|
|
22895
|
+
if (err instanceof import_graphql5.GraphQLError && ((_a = err.extensions) == null ? void 0 : _a.status) === 404) {
|
|
22896
|
+
throw new import_graphql5.GraphQLError(`${err.toString()}. Please confirm this location is correct and contains a '.tina' folder and a valid '.tina/schema.ts'.`);
|
|
22348
22897
|
} else {
|
|
22349
22898
|
throw err;
|
|
22350
22899
|
}
|
|
22351
22900
|
}
|
|
22352
22901
|
} else {
|
|
22353
22902
|
const tinaSchema = await this.getSchema();
|
|
22354
|
-
const extension2 =
|
|
22903
|
+
const extension2 = import_path6.default.extname(filepath);
|
|
22355
22904
|
const contentString = await this.bridge.get(filepath);
|
|
22356
|
-
const contentObject = this.parseFile(contentString, extension2, (
|
|
22905
|
+
const contentObject = this.parseFile(contentString, extension2, (yup3) => yup3.object({}));
|
|
22357
22906
|
const templateName = hasOwnProperty2(contentObject, "_template") && typeof contentObject._template === "string" ? contentObject._template : void 0;
|
|
22358
22907
|
const { collection, template } = await tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
|
|
22359
22908
|
const field = template.fields.find((field2) => {
|
|
@@ -22382,7 +22931,7 @@ var Database = class {
|
|
|
22382
22931
|
};
|
|
22383
22932
|
this.put = async (filepath, data) => {
|
|
22384
22933
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
22385
|
-
await this.bridge.put(
|
|
22934
|
+
await this.bridge.put(import_path6.default.join(GENERATED_FOLDER, `${filepath}.json`), JSON.stringify(data, null, 2));
|
|
22386
22935
|
} else {
|
|
22387
22936
|
const tinaSchema = await this.getSchema();
|
|
22388
22937
|
const collection = await tinaSchema.getCollectionByFullPath(filepath);
|
|
@@ -22420,7 +22969,7 @@ var Database = class {
|
|
|
22420
22969
|
} else {
|
|
22421
22970
|
payload = data;
|
|
22422
22971
|
}
|
|
22423
|
-
const extension2 =
|
|
22972
|
+
const extension2 = import_path6.default.extname(filepath);
|
|
22424
22973
|
const stringData = this.stringifyFile(payload, extension2, templateInfo.type === "union");
|
|
22425
22974
|
await this.bridge.put(filepath, stringData);
|
|
22426
22975
|
}
|
|
@@ -22553,19 +23102,16 @@ var githubRoute = async (_a) => {
|
|
|
22553
23102
|
rootPath = "",
|
|
22554
23103
|
query,
|
|
22555
23104
|
variables,
|
|
22556
|
-
cacheType = simpleCache2,
|
|
22557
23105
|
branch
|
|
22558
23106
|
} = _b, githubArgs = __objRest(_b, [
|
|
22559
23107
|
"rootPath",
|
|
22560
23108
|
"query",
|
|
22561
23109
|
"variables",
|
|
22562
|
-
"cacheType",
|
|
22563
23110
|
"branch"
|
|
22564
23111
|
]);
|
|
22565
23112
|
const gh = new GithubBridge(__spreadValues({
|
|
22566
23113
|
rootPath,
|
|
22567
|
-
ref: branch
|
|
22568
|
-
cache: cacheType
|
|
23114
|
+
ref: branch
|
|
22569
23115
|
}, githubArgs));
|
|
22570
23116
|
const database = await createDatabase({
|
|
22571
23117
|
bridge: gh
|
|
@@ -22577,74 +23123,14 @@ var githubRoute = async (_a) => {
|
|
|
22577
23123
|
});
|
|
22578
23124
|
};
|
|
22579
23125
|
var buildSchema = async (rootPath) => {
|
|
22580
|
-
const config = await
|
|
23126
|
+
const config = await import_fs_extra3.default.readFileSync(import_path7.default.join(rootPath, ".tina", "__generated__", "config", "schema.json")).toString();
|
|
22581
23127
|
const database = await createDatabase({
|
|
22582
23128
|
rootPath
|
|
22583
23129
|
});
|
|
22584
23130
|
await indexDB({ database, config: JSON.parse(config) });
|
|
22585
23131
|
const gqlAst = await database.getGraphQLSchema();
|
|
22586
|
-
return (0,
|
|
22587
|
-
};
|
|
22588
|
-
|
|
22589
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/cache/s3.ts
|
|
22590
|
-
var import_aws_sdk = __toModule(require("aws-sdk"));
|
|
22591
|
-
var bucketName = process.env.CACHE_S3_BUCKET_NAME || "tina-contentapi";
|
|
22592
|
-
var realCache = new import_aws_sdk.S3();
|
|
22593
|
-
var clearCacheWith = (cache3) => async ({
|
|
22594
|
-
owner,
|
|
22595
|
-
repo,
|
|
22596
|
-
ref,
|
|
22597
|
-
path: path7
|
|
22598
|
-
}) => {
|
|
22599
|
-
const repoPrefix = `${owner}/${repo}/${ref}`;
|
|
22600
|
-
if (path7) {
|
|
22601
|
-
const key2 = `${repoPrefix}/${path7}`;
|
|
22602
|
-
console.log("[S3 cache]: clearing key ", key2);
|
|
22603
|
-
await cache3.deleteObject({
|
|
22604
|
-
Bucket: bucketName,
|
|
22605
|
-
Key: key2
|
|
22606
|
-
}).promise();
|
|
22607
|
-
} else {
|
|
22608
|
-
console.log("[S3 cache]: clearing all keys for repo ", repoPrefix);
|
|
22609
|
-
const data = await cache3.listObjectsV2({
|
|
22610
|
-
Bucket: bucketName,
|
|
22611
|
-
Prefix: repoPrefix
|
|
22612
|
-
}).promise();
|
|
22613
|
-
if (data.Contents) {
|
|
22614
|
-
await cache3.deleteObjects({
|
|
22615
|
-
Bucket: bucketName,
|
|
22616
|
-
Delete: {
|
|
22617
|
-
Objects: data.Contents.map((key2) => ({ Key: key2.Key }))
|
|
22618
|
-
}
|
|
22619
|
-
}).promise();
|
|
22620
|
-
}
|
|
22621
|
-
}
|
|
23132
|
+
return (0, import_graphql6.buildASTSchema)(gqlAst);
|
|
22622
23133
|
};
|
|
22623
|
-
var s3CacheWith = (cache3) => ({
|
|
22624
|
-
get: async (keyName, setter) => {
|
|
22625
|
-
try {
|
|
22626
|
-
const value = await cache3.getObject({
|
|
22627
|
-
Bucket: bucketName,
|
|
22628
|
-
Key: keyName
|
|
22629
|
-
}).promise();
|
|
22630
|
-
console.log("getting from cache", keyName);
|
|
22631
|
-
return value.Body;
|
|
22632
|
-
} catch (error) {
|
|
22633
|
-
if (error.code != "NoSuchKey")
|
|
22634
|
-
throw error;
|
|
22635
|
-
const valueToCache = await setter();
|
|
22636
|
-
await cache3.upload({
|
|
22637
|
-
Bucket: bucketName,
|
|
22638
|
-
Key: keyName,
|
|
22639
|
-
Body: valueToCache.toString()
|
|
22640
|
-
}).promise();
|
|
22641
|
-
console.log("item not in cache, setting", keyName);
|
|
22642
|
-
return valueToCache;
|
|
22643
|
-
}
|
|
22644
|
-
}
|
|
22645
|
-
});
|
|
22646
|
-
var clearCache2 = clearCacheWith(realCache);
|
|
22647
|
-
var s3Cache = s3CacheWith(realCache);
|
|
22648
23134
|
|
|
22649
23135
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
22650
23136
|
var import_rest2 = __toModule(require("@octokit/rest"));
|
|
@@ -22676,18 +23162,13 @@ var createBranch = async ({ auth, owner, repo, name, baseBranch }) => {
|
|
|
22676
23162
|
0 && (module.exports = {
|
|
22677
23163
|
GithubBridge,
|
|
22678
23164
|
buildSchema,
|
|
22679
|
-
clearCache,
|
|
22680
23165
|
createBranch,
|
|
22681
23166
|
createDatabase,
|
|
22682
23167
|
githubRoute,
|
|
22683
23168
|
gql,
|
|
22684
23169
|
indexDB,
|
|
22685
23170
|
listBranches,
|
|
22686
|
-
|
|
22687
|
-
resolve,
|
|
22688
|
-
s3Cache,
|
|
22689
|
-
s3ClearCache,
|
|
22690
|
-
simpleCache
|
|
23171
|
+
resolve
|
|
22691
23172
|
});
|
|
22692
23173
|
/*!
|
|
22693
23174
|
* Determine if an object is a Buffer
|