wabe 0.6.0 → 0.6.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/dist/index.d.ts +214 -274
- package/dist/index.js +673 -528
- package/generated/schema.graphql +79 -9
- package/generated/wabe.ts +243 -1805
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -49426,13 +49426,13 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
49426
49426
|
}
|
|
49427
49427
|
return next();
|
|
49428
49428
|
};
|
|
49429
|
-
__rewriteRelativeImportExtension = function(
|
|
49430
|
-
if (typeof
|
|
49431
|
-
return
|
|
49429
|
+
__rewriteRelativeImportExtension = function(path2, preserveJsx) {
|
|
49430
|
+
if (typeof path2 === "string" && /^\.\.?\//.test(path2)) {
|
|
49431
|
+
return path2.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
49432
49432
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
49433
49433
|
});
|
|
49434
49434
|
}
|
|
49435
|
-
return
|
|
49435
|
+
return path2;
|
|
49436
49436
|
};
|
|
49437
49437
|
exporter("__extends", __extends);
|
|
49438
49438
|
exporter("__assign", __assign);
|
|
@@ -49839,18 +49839,18 @@ var require_utils4 = __commonJS((exports, module) => {
|
|
|
49839
49839
|
if (decode)
|
|
49840
49840
|
return decode(data, hint);
|
|
49841
49841
|
}
|
|
49842
|
-
function basename(
|
|
49843
|
-
if (typeof
|
|
49842
|
+
function basename(path2) {
|
|
49843
|
+
if (typeof path2 !== "string")
|
|
49844
49844
|
return "";
|
|
49845
|
-
for (let i =
|
|
49846
|
-
switch (
|
|
49845
|
+
for (let i = path2.length - 1;i >= 0; --i) {
|
|
49846
|
+
switch (path2.charCodeAt(i)) {
|
|
49847
49847
|
case 47:
|
|
49848
49848
|
case 92:
|
|
49849
|
-
|
|
49850
|
-
return
|
|
49849
|
+
path2 = path2.slice(i + 1);
|
|
49850
|
+
return path2 === ".." || path2 === "." ? "" : path2;
|
|
49851
49851
|
}
|
|
49852
49852
|
}
|
|
49853
|
-
return
|
|
49853
|
+
return path2 === ".." || path2 === "." ? "" : path2;
|
|
49854
49854
|
}
|
|
49855
49855
|
var TOKEN = [
|
|
49856
49856
|
0,
|
|
@@ -55458,7 +55458,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
55458
55458
|
var Empty = function() {
|
|
55459
55459
|
};
|
|
55460
55460
|
Empty.prototype = Object.create(null);
|
|
55461
|
-
function
|
|
55461
|
+
function parse4(input) {
|
|
55462
55462
|
const result2 = new Empty;
|
|
55463
55463
|
if (typeof input !== "string") {
|
|
55464
55464
|
return result2;
|
|
@@ -55538,7 +55538,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
55538
55538
|
}
|
|
55539
55539
|
return result2;
|
|
55540
55540
|
}
|
|
55541
|
-
module.exports =
|
|
55541
|
+
module.exports = parse4;
|
|
55542
55542
|
});
|
|
55543
55543
|
|
|
55544
55544
|
// ../../node_modules/fast-querystring/lib/internals/querystring.js
|
|
@@ -55778,15 +55778,15 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
55778
55778
|
|
|
55779
55779
|
// ../../node_modules/fast-querystring/lib/index.js
|
|
55780
55780
|
var require_lib7 = __commonJS((exports, module) => {
|
|
55781
|
-
var
|
|
55781
|
+
var parse4 = require_parse2();
|
|
55782
55782
|
var stringify = require_stringify();
|
|
55783
55783
|
var fastQuerystring = {
|
|
55784
|
-
parse:
|
|
55784
|
+
parse: parse4,
|
|
55785
55785
|
stringify
|
|
55786
55786
|
};
|
|
55787
55787
|
module.exports = fastQuerystring;
|
|
55788
55788
|
module.exports.default = fastQuerystring;
|
|
55789
|
-
module.exports.parse =
|
|
55789
|
+
module.exports.parse = parse4;
|
|
55790
55790
|
module.exports.stringify = stringify;
|
|
55791
55791
|
});
|
|
55792
55792
|
|
|
@@ -56447,13 +56447,13 @@ var require_urlparser = __commonJS((exports, module) => {
|
|
|
56447
56447
|
this.pathname = prePath === "" ? "/" : prePath;
|
|
56448
56448
|
return;
|
|
56449
56449
|
}
|
|
56450
|
-
var
|
|
56450
|
+
var path2;
|
|
56451
56451
|
if (escape2) {
|
|
56452
|
-
|
|
56452
|
+
path2 = this._getComponentEscaped(str, pathStart, pathEnd, false);
|
|
56453
56453
|
} else {
|
|
56454
|
-
|
|
56454
|
+
path2 = str.slice(pathStart, pathEnd + 1);
|
|
56455
56455
|
}
|
|
56456
|
-
this.pathname = prePath === "" ? this._prependSlash ? "/" +
|
|
56456
|
+
this.pathname = prePath === "" ? this._prependSlash ? "/" + path2 : path2 : prePath + path2;
|
|
56457
56457
|
};
|
|
56458
56458
|
Url.prototype._parseQuery = function Url$_parseQuery(str, start, end, disableAutoEscapeChars) {
|
|
56459
56459
|
var queryStart = start;
|
|
@@ -57051,8 +57051,8 @@ var require_fetch = __commonJS((exports) => {
|
|
|
57051
57051
|
var utils_js_1 = require_utils5();
|
|
57052
57052
|
var BASE64_SUFFIX = ";base64";
|
|
57053
57053
|
function getResponseForFile(url) {
|
|
57054
|
-
const
|
|
57055
|
-
const readable = (0, fs_1.createReadStream)(
|
|
57054
|
+
const path2 = (0, url_1.fileURLToPath)(url);
|
|
57055
|
+
const readable = (0, fs_1.createReadStream)(path2);
|
|
57056
57056
|
return new Response_js_1.PonyfillResponse(readable);
|
|
57057
57057
|
}
|
|
57058
57058
|
function getResponseForDataUri(url) {
|
|
@@ -59878,8 +59878,8 @@ var require_fetch2 = __commonJS((exports) => {
|
|
|
59878
59878
|
var utils_js_1 = require_utils6();
|
|
59879
59879
|
var BASE64_SUFFIX = ";base64";
|
|
59880
59880
|
function getResponseForFile(url) {
|
|
59881
|
-
const
|
|
59882
|
-
const readable = (0, fs_1.createReadStream)(
|
|
59881
|
+
const path2 = (0, url_1.fileURLToPath)(url);
|
|
59882
|
+
const readable = (0, fs_1.createReadStream)(path2);
|
|
59883
59883
|
return new Response_js_1.PonyfillResponse(readable);
|
|
59884
59884
|
}
|
|
59885
59885
|
function getResponseForDataUri(url) {
|
|
@@ -60553,8 +60553,6 @@ var require_create_node_ponyfill2 = __commonJS((exports, module) => {
|
|
|
60553
60553
|
|
|
60554
60554
|
// src/files/hookDeleteFile.ts
|
|
60555
60555
|
var deleteFile = async (hookObject) => {
|
|
60556
|
-
if (!hookObject.context.wabe.controllers.file)
|
|
60557
|
-
return;
|
|
60558
60556
|
const schema = hookObject.context.wabe.config.schema?.classes?.find((currentClass) => currentClass.name === hookObject.className);
|
|
60559
60557
|
if (!schema)
|
|
60560
60558
|
return;
|
|
@@ -60562,6 +60560,8 @@ var deleteFile = async (hookObject) => {
|
|
|
60562
60560
|
const fileName = hookObject.originalObject?.[fieldName]?.name;
|
|
60563
60561
|
if (!fileName)
|
|
60564
60562
|
return;
|
|
60563
|
+
if (!hookObject.context.wabe.controllers.file)
|
|
60564
|
+
throw new Error("No file adapter found");
|
|
60565
60565
|
await hookObject.context.wabe.controllers.file?.deleteFile(fileName);
|
|
60566
60566
|
});
|
|
60567
60567
|
};
|
|
@@ -60569,8 +60569,6 @@ var defaultAfterDeleteFile = (hookObject) => deleteFile(hookObject);
|
|
|
60569
60569
|
|
|
60570
60570
|
// src/files/hookReadFile.ts
|
|
60571
60571
|
var getFile = async (hookObject) => {
|
|
60572
|
-
if (!hookObject.context.wabe.controllers.file)
|
|
60573
|
-
return;
|
|
60574
60572
|
const schema = hookObject.context.wabe.config.schema?.classes?.find((currentClass) => currentClass.name === hookObject.className);
|
|
60575
60573
|
if (!schema)
|
|
60576
60574
|
return;
|
|
@@ -60580,9 +60578,13 @@ var getFile = async (hookObject) => {
|
|
|
60580
60578
|
if (!fileInfo)
|
|
60581
60579
|
return;
|
|
60582
60580
|
const fileName = fileInfo.name;
|
|
60581
|
+
if (!fileName && fileInfo.url)
|
|
60582
|
+
return fileInfo.url;
|
|
60583
60583
|
const fileUrlGeneratedAt = fileInfo.urlGeneratedAt;
|
|
60584
60584
|
if (fileUrlGeneratedAt && fileUrlGeneratedAt.getTime() + urlCacheInSeconds * 1000 > new Date().getTime())
|
|
60585
60585
|
return;
|
|
60586
|
+
if (!hookObject.context.wabe.controllers.file)
|
|
60587
|
+
throw new Error("No file adapter found");
|
|
60586
60588
|
const fileUrlFromBucket = await hookObject.context.wabe.controllers.file?.readFile(fileName);
|
|
60587
60589
|
return hookObject.context.wabe.controllers.database.updateObject({
|
|
60588
60590
|
className: hookObject.className,
|
|
@@ -60595,7 +60597,6 @@ var getFile = async (hookObject) => {
|
|
|
60595
60597
|
url: fileUrlFromBucket || fileInfo.url
|
|
60596
60598
|
}
|
|
60597
60599
|
},
|
|
60598
|
-
fields: ["*"],
|
|
60599
60600
|
skipHooks: true
|
|
60600
60601
|
});
|
|
60601
60602
|
}));
|
|
@@ -60604,21 +60605,23 @@ var defaultAfterReadFile = (hookObject) => getFile(hookObject);
|
|
|
60604
60605
|
|
|
60605
60606
|
// src/files/hookUploadFile.ts
|
|
60606
60607
|
var handleFile = async (hookObject) => {
|
|
60607
|
-
if (!hookObject.context.wabe.controllers.file)
|
|
60608
|
-
return;
|
|
60609
60608
|
const newData = hookObject.getNewData();
|
|
60610
60609
|
const schema = hookObject.context.wabe.config.schema?.classes?.find((currentClass) => currentClass.name === hookObject.className);
|
|
60611
60610
|
if (!schema)
|
|
60612
60611
|
return;
|
|
60613
60612
|
await Promise.all(Object.keys(newData).map(async (keyName) => {
|
|
60614
|
-
const file = newData[keyName]
|
|
60615
|
-
const url = newData[keyName]
|
|
60613
|
+
const file = newData[keyName]?.file;
|
|
60614
|
+
const url = newData[keyName]?.url;
|
|
60615
|
+
if (!file && !url)
|
|
60616
|
+
return;
|
|
60616
60617
|
if (url) {
|
|
60617
60618
|
hookObject.upsertNewData(keyName, { url, isPresignedUrl: false });
|
|
60618
60619
|
return;
|
|
60619
60620
|
}
|
|
60620
60621
|
if (schema.fields[keyName].type !== "File" || !(file instanceof File))
|
|
60621
60622
|
return;
|
|
60623
|
+
if (!hookObject.context.wabe.controllers.file)
|
|
60624
|
+
throw new Error("No file adapter found");
|
|
60622
60625
|
await hookObject.context.wabe.controllers.file?.uploadFile(file);
|
|
60623
60626
|
hookObject.upsertNewData(keyName, {
|
|
60624
60627
|
name: file.name,
|
|
@@ -60643,7 +60646,7 @@ class HookObject {
|
|
|
60643
60646
|
context;
|
|
60644
60647
|
object;
|
|
60645
60648
|
originalObject;
|
|
60646
|
-
|
|
60649
|
+
select;
|
|
60647
60650
|
constructor({
|
|
60648
60651
|
newData,
|
|
60649
60652
|
className,
|
|
@@ -60651,7 +60654,7 @@ class HookObject {
|
|
|
60651
60654
|
context,
|
|
60652
60655
|
object,
|
|
60653
60656
|
originalObject,
|
|
60654
|
-
|
|
60657
|
+
select
|
|
60655
60658
|
}) {
|
|
60656
60659
|
this.newData = newData;
|
|
60657
60660
|
this.className = className;
|
|
@@ -60659,7 +60662,7 @@ class HookObject {
|
|
|
60659
60662
|
this.context = context;
|
|
60660
60663
|
this.object = object;
|
|
60661
60664
|
this.originalObject = originalObject;
|
|
60662
|
-
this.
|
|
60665
|
+
this.select = Object.keys(select || {});
|
|
60663
60666
|
}
|
|
60664
60667
|
getUser() {
|
|
60665
60668
|
return this.context.user;
|
|
@@ -60687,8 +60690,7 @@ class HookObject {
|
|
|
60687
60690
|
context: {
|
|
60688
60691
|
...this.context,
|
|
60689
60692
|
isRoot: true
|
|
60690
|
-
}
|
|
60691
|
-
fields: ["*"]
|
|
60693
|
+
}
|
|
60692
60694
|
});
|
|
60693
60695
|
}
|
|
60694
60696
|
async addACL(type, options) {
|
|
@@ -60703,7 +60705,7 @@ class HookObject {
|
|
|
60703
60705
|
data: {
|
|
60704
60706
|
acl: newACLObject
|
|
60705
60707
|
},
|
|
60706
|
-
|
|
60708
|
+
select: {}
|
|
60707
60709
|
});
|
|
60708
60710
|
return;
|
|
60709
60711
|
}
|
|
@@ -60711,7 +60713,7 @@ class HookObject {
|
|
|
60711
60713
|
};
|
|
60712
60714
|
const result = this.className === "User" ? await this.context.wabe.controllers.database.getObject({
|
|
60713
60715
|
className: "User",
|
|
60714
|
-
|
|
60716
|
+
select: { acl: true },
|
|
60715
60717
|
id: this.object?.id,
|
|
60716
60718
|
context: {
|
|
60717
60719
|
...this.context,
|
|
@@ -60732,7 +60734,7 @@ class HookObject {
|
|
|
60732
60734
|
if (role) {
|
|
60733
60735
|
const result2 = await this.context.wabe.controllers.database.getObjects({
|
|
60734
60736
|
className: "Role",
|
|
60735
|
-
|
|
60737
|
+
select: { id: true },
|
|
60736
60738
|
where: {
|
|
60737
60739
|
name: {
|
|
60738
60740
|
equalTo: role
|
|
@@ -60817,6 +60819,10 @@ var defaultCallAuthenticationProviderOnBeforeUpdateUser = async (hookObject) =>
|
|
|
60817
60819
|
};
|
|
60818
60820
|
|
|
60819
60821
|
// src/utils/index.ts
|
|
60822
|
+
var firstLetterInUpperCase = (str) => {
|
|
60823
|
+
const indexOfFirstLetter = str.search(/[a-z]/i);
|
|
60824
|
+
return str.slice(0, indexOfFirstLetter) + str[indexOfFirstLetter].toUpperCase() + str.slice(indexOfFirstLetter + 1);
|
|
60825
|
+
};
|
|
60820
60826
|
var firstLetterInLowerCase = (str) => {
|
|
60821
60827
|
const indexOfFirstLetter = str.search(/[a-z]/i);
|
|
60822
60828
|
return str.slice(0, indexOfFirstLetter) + str[indexOfFirstLetter].toLowerCase() + str.slice(indexOfFirstLetter + 1);
|
|
@@ -60873,7 +60879,7 @@ var defaultDeleteSessionOnDeleteUser = async (object) => {
|
|
|
60873
60879
|
where: {
|
|
60874
60880
|
user: { id: { equalTo: userId } }
|
|
60875
60881
|
},
|
|
60876
|
-
|
|
60882
|
+
select: {}
|
|
60877
60883
|
});
|
|
60878
60884
|
};
|
|
60879
60885
|
|
|
@@ -60927,7 +60933,7 @@ var _checkCLP = async (object, operationType) => {
|
|
|
60927
60933
|
const res = await object.context.wabe.controllers.database.getObject({
|
|
60928
60934
|
className: "_Session",
|
|
60929
60935
|
id: sessionId,
|
|
60930
|
-
|
|
60936
|
+
select: { id: true, user: { id: true } },
|
|
60931
60937
|
context: {
|
|
60932
60938
|
...object.context,
|
|
60933
60939
|
isRoot: true
|
|
@@ -61698,19 +61704,14 @@ class MongoAdapter {
|
|
|
61698
61704
|
async getObject(params) {
|
|
61699
61705
|
if (!this.database)
|
|
61700
61706
|
throw new Error("Connection to database is not established");
|
|
61701
|
-
const { className, id,
|
|
61707
|
+
const { className, id, select, where, context } = params;
|
|
61702
61708
|
const whereBuilded = buildMongoWhereQuery(where);
|
|
61703
|
-
const objectOfFieldsToGet = fields?.reduce((acc, prev) => {
|
|
61704
|
-
acc[prev] = 1;
|
|
61705
|
-
return acc;
|
|
61706
|
-
}, {});
|
|
61707
61709
|
const collection = await this.createClassIfNotExist(className, context);
|
|
61708
61710
|
const res = await collection.findOne({ _id: new import_mongodb.ObjectId(id), ...whereBuilded }, {
|
|
61709
|
-
projection:
|
|
61711
|
+
projection: select ? { ...select, _id: 1 } : undefined
|
|
61710
61712
|
});
|
|
61711
|
-
if (!res)
|
|
61713
|
+
if (!res)
|
|
61712
61714
|
throw new Error("Object not found");
|
|
61713
|
-
}
|
|
61714
61715
|
const { _id, ...resultWithout_Id } = res;
|
|
61715
61716
|
return {
|
|
61716
61717
|
...resultWithout_Id,
|
|
@@ -61720,19 +61721,12 @@ class MongoAdapter {
|
|
|
61720
61721
|
async getObjects(params) {
|
|
61721
61722
|
if (!this.database)
|
|
61722
61723
|
throw new Error("Connection to database is not established");
|
|
61723
|
-
const { className,
|
|
61724
|
+
const { className, select, where, offset, first, context, order } = params;
|
|
61724
61725
|
const whereBuilded = buildMongoWhereQuery(where);
|
|
61725
61726
|
const orderBuilded = buildMongoOrderQuery(order);
|
|
61726
|
-
const objectOfFieldsToGet = fields?.reduce((acc, prev) => {
|
|
61727
|
-
acc[prev] = 1;
|
|
61728
|
-
return acc;
|
|
61729
|
-
}, {});
|
|
61730
61727
|
const collection = await this.createClassIfNotExist(className, context);
|
|
61731
61728
|
const res = await collection.find(whereBuilded, {
|
|
61732
|
-
projection:
|
|
61733
|
-
...objectOfFieldsToGet,
|
|
61734
|
-
_id: 1
|
|
61735
|
-
} : {}
|
|
61729
|
+
projection: select ? { ...select, _id: 1 } : undefined
|
|
61736
61730
|
}).limit(first || 0).skip(offset || 0).sort(orderBuilded).toArray();
|
|
61737
61731
|
return res.map((object) => {
|
|
61738
61732
|
const { _id, ...resultWithout_Id } = object;
|
|
@@ -61783,7 +61777,7 @@ class MongoAdapter {
|
|
|
61783
61777
|
const objectsBeforeUpdate = await context.wabe.controllers.database.getObjects({
|
|
61784
61778
|
className,
|
|
61785
61779
|
where,
|
|
61786
|
-
|
|
61780
|
+
select: { id: true },
|
|
61787
61781
|
offset,
|
|
61788
61782
|
first,
|
|
61789
61783
|
context: contextWithRoot(context),
|
|
@@ -61894,18 +61888,21 @@ var PaymentReccuringInterval;
|
|
|
61894
61888
|
})(PaymentReccuringInterval ||= {});
|
|
61895
61889
|
// src/files/FileDevAdapter.ts
|
|
61896
61890
|
import { writeFile, mkdir, rm, access, constants } from "node:fs/promises";
|
|
61891
|
+
import path from "node:path";
|
|
61897
61892
|
|
|
61898
61893
|
class FileDevAdapter {
|
|
61899
61894
|
basePath;
|
|
61895
|
+
rootPath = process.cwd();
|
|
61900
61896
|
constructor(basePath) {
|
|
61901
61897
|
this.basePath = basePath;
|
|
61902
61898
|
}
|
|
61903
61899
|
async uploadFile(file) {
|
|
61904
|
-
|
|
61905
|
-
await
|
|
61900
|
+
const fullPath = path.join(this.rootPath, this.basePath);
|
|
61901
|
+
await mkdir(fullPath, { recursive: true });
|
|
61902
|
+
await writeFile(path.join(fullPath, file.name), await file.text());
|
|
61906
61903
|
}
|
|
61907
61904
|
async readFile(fileName) {
|
|
61908
|
-
const filePath =
|
|
61905
|
+
const filePath = path.join(this.rootPath, this.basePath, fileName);
|
|
61909
61906
|
try {
|
|
61910
61907
|
await access(filePath, constants.F_OK);
|
|
61911
61908
|
return filePath;
|
|
@@ -61914,7 +61911,7 @@ class FileDevAdapter {
|
|
|
61914
61911
|
}
|
|
61915
61912
|
}
|
|
61916
61913
|
async deleteFile(fileName) {
|
|
61917
|
-
await rm(
|
|
61914
|
+
await rm(path.join(this.rootPath, this.basePath, fileName));
|
|
61918
61915
|
}
|
|
61919
61916
|
}
|
|
61920
61917
|
|
|
@@ -62047,7 +62044,7 @@ var initializeHook = ({
|
|
|
62047
62044
|
className,
|
|
62048
62045
|
newData,
|
|
62049
62046
|
context,
|
|
62050
|
-
|
|
62047
|
+
select
|
|
62051
62048
|
}) => {
|
|
62052
62049
|
const computeObject = ({
|
|
62053
62050
|
id
|
|
@@ -62058,8 +62055,7 @@ var initializeHook = ({
|
|
|
62058
62055
|
className,
|
|
62059
62056
|
context: contextWithRoot(context),
|
|
62060
62057
|
id,
|
|
62061
|
-
skipHooks: true
|
|
62062
|
-
fields: ["*"]
|
|
62058
|
+
skipHooks: true
|
|
62063
62059
|
});
|
|
62064
62060
|
};
|
|
62065
62061
|
const computeObjects = async ({
|
|
@@ -62072,7 +62068,6 @@ var initializeHook = ({
|
|
|
62072
62068
|
className,
|
|
62073
62069
|
context: contextWithRoot(context),
|
|
62074
62070
|
where: where ? where : { id: { in: ids } },
|
|
62075
|
-
fields: ["*"],
|
|
62076
62071
|
skipHooks: true
|
|
62077
62072
|
});
|
|
62078
62073
|
if (res.length === 0)
|
|
@@ -62094,7 +62089,7 @@ var initializeHook = ({
|
|
|
62094
62089
|
context,
|
|
62095
62090
|
object,
|
|
62096
62091
|
originalObject: options.originalObject,
|
|
62097
|
-
|
|
62092
|
+
select
|
|
62098
62093
|
});
|
|
62099
62094
|
await hooksOrderByPriorities.reduce(async (acc, priority) => {
|
|
62100
62095
|
await acc;
|
|
@@ -62125,7 +62120,7 @@ var initializeHook = ({
|
|
|
62125
62120
|
context,
|
|
62126
62121
|
object,
|
|
62127
62122
|
originalObject: originalObjectToUse,
|
|
62128
|
-
|
|
62123
|
+
select
|
|
62129
62124
|
});
|
|
62130
62125
|
await hooksOrderByPriorities.reduce(async (acc, priority) => {
|
|
62131
62126
|
await acc;
|
|
@@ -62258,32 +62253,38 @@ class DatabaseController2 {
|
|
|
62258
62253
|
constructor(adapter) {
|
|
62259
62254
|
this.adapter = adapter;
|
|
62260
62255
|
}
|
|
62261
|
-
|
|
62256
|
+
_getSelectMinusPointersAndRelations({
|
|
62257
|
+
className,
|
|
62258
|
+
context,
|
|
62259
|
+
select
|
|
62260
|
+
}) {
|
|
62262
62261
|
const realClass = context.wabe.config.schema?.classes?.find((c) => c.name.toLowerCase() === className.toLowerCase());
|
|
62263
62262
|
if (!realClass)
|
|
62264
62263
|
throw new Error("Class not found in schema");
|
|
62265
|
-
|
|
62266
|
-
|
|
62267
|
-
|
|
62268
|
-
|
|
62269
|
-
|
|
62270
|
-
|
|
62271
|
-
|
|
62264
|
+
if (!select)
|
|
62265
|
+
return { pointers: {}, selectWithoutPointers: {} };
|
|
62266
|
+
const pointerOrRelationFields = Object.keys(realClass.fields).filter((fieldName) => realClass.fields[fieldName].type === "Pointer" || realClass.fields[fieldName].type === "Relation");
|
|
62267
|
+
return Object.entries(select).reduce((acc, [fieldName, value]) => {
|
|
62268
|
+
if (!pointerOrRelationFields.includes(fieldName))
|
|
62269
|
+
return {
|
|
62270
|
+
...acc,
|
|
62271
|
+
selectWithoutPointers: {
|
|
62272
|
+
...acc.selectWithoutPointers,
|
|
62273
|
+
[fieldName]: true
|
|
62274
|
+
}
|
|
62275
|
+
};
|
|
62276
|
+
const classOfPointerOrRelation = realClass.fields[fieldName].class;
|
|
62272
62277
|
return {
|
|
62278
|
+
...acc,
|
|
62273
62279
|
pointers: {
|
|
62274
62280
|
...acc.pointers,
|
|
62275
|
-
[
|
|
62276
|
-
|
|
62277
|
-
|
|
62278
|
-
fieldsOfPointerClass: [
|
|
62279
|
-
...acc.pointers?.[pointerField]?.fieldsOfPointerClass || [],
|
|
62280
|
-
pointerFields
|
|
62281
|
-
]
|
|
62281
|
+
[fieldName]: {
|
|
62282
|
+
className: classOfPointerOrRelation,
|
|
62283
|
+
select: value === true ? undefined : value
|
|
62282
62284
|
}
|
|
62283
|
-
}
|
|
62284
|
-
pointersFieldsId: acc.pointersFieldsId?.includes(pointerField) ? acc.pointersFieldsId : [...acc.pointersFieldsId || [], pointerField]
|
|
62285
|
+
}
|
|
62285
62286
|
};
|
|
62286
|
-
}, { pointers: {} });
|
|
62287
|
+
}, { pointers: {}, selectWithoutPointers: {} });
|
|
62287
62288
|
}
|
|
62288
62289
|
_isRelationField(originClassName, context, pointerClassName) {
|
|
62289
62290
|
if (!pointerClassName)
|
|
@@ -62295,44 +62296,6 @@ class DatabaseController2 {
|
|
|
62295
62296
|
return false;
|
|
62296
62297
|
return context.wabe.config.schema?.classes?.some((c) => c.name.toLowerCase() === originClassName.toLowerCase() && Object.values(c.fields).find((field) => field.type === "Pointer" && field.class.toLowerCase() === pointerClassName.toLowerCase()));
|
|
62297
62298
|
}
|
|
62298
|
-
async _getFinalObjectWithPointer(objectData, pointersObject, originClassName, context) {
|
|
62299
|
-
return Object.entries(pointersObject).reduce(async (accPromise, [pointerField, { fieldsOfPointerClass, pointerClass }]) => {
|
|
62300
|
-
const acc = await accPromise;
|
|
62301
|
-
const isPointer = this._isPointerField(originClassName, context, pointerClass);
|
|
62302
|
-
if (isPointer && pointerClass && objectData?.[pointerField]) {
|
|
62303
|
-
const pointerObject = await this.getObject({
|
|
62304
|
-
className: pointerClass,
|
|
62305
|
-
fields: fieldsOfPointerClass,
|
|
62306
|
-
id: objectData[pointerField],
|
|
62307
|
-
context
|
|
62308
|
-
});
|
|
62309
|
-
return {
|
|
62310
|
-
...acc,
|
|
62311
|
-
[pointerField]: pointerObject
|
|
62312
|
-
};
|
|
62313
|
-
}
|
|
62314
|
-
const isRelation = this._isRelationField(originClassName, context, pointerClass);
|
|
62315
|
-
if (isRelation && pointerClass) {
|
|
62316
|
-
const relationObjects = await this.getObjects({
|
|
62317
|
-
className: pointerClass,
|
|
62318
|
-
fields: fieldsOfPointerClass,
|
|
62319
|
-
where: { id: { in: objectData[pointerField] } },
|
|
62320
|
-
context
|
|
62321
|
-
});
|
|
62322
|
-
return {
|
|
62323
|
-
...acc,
|
|
62324
|
-
[pointerField]: {
|
|
62325
|
-
edges: relationObjects.map((object) => ({
|
|
62326
|
-
node: object
|
|
62327
|
-
}))
|
|
62328
|
-
}
|
|
62329
|
-
};
|
|
62330
|
-
}
|
|
62331
|
-
return acc;
|
|
62332
|
-
}, Promise.resolve({
|
|
62333
|
-
...objectData
|
|
62334
|
-
}));
|
|
62335
|
-
}
|
|
62336
62299
|
async _getWhereObjectWithPointerOrRelation(className, where, context) {
|
|
62337
62300
|
const whereKeys = Object.keys(where);
|
|
62338
62301
|
const realClass = context.wabe.config.schema?.classes?.find((c) => c.name.toLowerCase() === className.toLowerCase());
|
|
@@ -62353,7 +62316,7 @@ class DatabaseController2 {
|
|
|
62353
62316
|
const defaultWhere = where[typedWhereKey];
|
|
62354
62317
|
const objects = await this.getObjects({
|
|
62355
62318
|
className: fieldTargetClass,
|
|
62356
|
-
|
|
62319
|
+
select: { id: true },
|
|
62357
62320
|
where: defaultWhere,
|
|
62358
62321
|
context
|
|
62359
62322
|
});
|
|
@@ -62443,6 +62406,56 @@ class DatabaseController2 {
|
|
|
62443
62406
|
].filter(notEmpty)
|
|
62444
62407
|
};
|
|
62445
62408
|
}
|
|
62409
|
+
_getFinalObjectWithPointerAndRelation({
|
|
62410
|
+
pointers,
|
|
62411
|
+
context,
|
|
62412
|
+
originClassName,
|
|
62413
|
+
object,
|
|
62414
|
+
isGraphQLCall
|
|
62415
|
+
}) {
|
|
62416
|
+
return Object.entries(pointers).reduce(async (acc, [pointerField, { className: currentClassName, select: currentSelect }]) => {
|
|
62417
|
+
const accObject = await acc;
|
|
62418
|
+
const isPointer = this._isPointerField(originClassName, context, currentClassName);
|
|
62419
|
+
if (isPointer) {
|
|
62420
|
+
if (!object[pointerField]) {
|
|
62421
|
+
return {
|
|
62422
|
+
...accObject,
|
|
62423
|
+
[pointerField]: null
|
|
62424
|
+
};
|
|
62425
|
+
}
|
|
62426
|
+
const objectOfPointerClass = await this.getObject({
|
|
62427
|
+
className: currentClassName,
|
|
62428
|
+
id: object[pointerField],
|
|
62429
|
+
context,
|
|
62430
|
+
select: currentSelect,
|
|
62431
|
+
skipHooks: true
|
|
62432
|
+
});
|
|
62433
|
+
return {
|
|
62434
|
+
...accObject,
|
|
62435
|
+
[pointerField]: objectOfPointerClass
|
|
62436
|
+
};
|
|
62437
|
+
}
|
|
62438
|
+
const isRelation = this._isRelationField(originClassName, context, currentClassName);
|
|
62439
|
+
if (isRelation) {
|
|
62440
|
+
const relationObjects = await this.getObjects({
|
|
62441
|
+
className: currentClassName,
|
|
62442
|
+
select: currentSelect,
|
|
62443
|
+
where: { id: { in: object[pointerField] } },
|
|
62444
|
+
context
|
|
62445
|
+
});
|
|
62446
|
+
return {
|
|
62447
|
+
...acc,
|
|
62448
|
+
[pointerField]: isGraphQLCall ? {
|
|
62449
|
+
totalCount: relationObjects.length,
|
|
62450
|
+
edges: relationObjects.map((object2) => ({
|
|
62451
|
+
node: object2
|
|
62452
|
+
}))
|
|
62453
|
+
} : relationObjects
|
|
62454
|
+
};
|
|
62455
|
+
}
|
|
62456
|
+
return accObject;
|
|
62457
|
+
}, Promise.resolve({}));
|
|
62458
|
+
}
|
|
62446
62459
|
connect() {
|
|
62447
62460
|
return this.adapter.connect();
|
|
62448
62461
|
}
|
|
@@ -62459,30 +62472,33 @@ class DatabaseController2 {
|
|
|
62459
62472
|
await this.adapter.clearDatabase();
|
|
62460
62473
|
}
|
|
62461
62474
|
async getObject({
|
|
62462
|
-
|
|
62475
|
+
select,
|
|
62463
62476
|
className,
|
|
62464
62477
|
context,
|
|
62465
62478
|
skipHooks,
|
|
62466
62479
|
id,
|
|
62467
|
-
where
|
|
62480
|
+
where,
|
|
62481
|
+
isGraphQLCall = false
|
|
62468
62482
|
}) {
|
|
62469
|
-
const
|
|
62470
|
-
|
|
62483
|
+
const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
|
|
62484
|
+
className,
|
|
62485
|
+
context,
|
|
62486
|
+
select
|
|
62487
|
+
});
|
|
62471
62488
|
const hook = !skipHooks ? initializeHook({
|
|
62472
62489
|
className,
|
|
62473
62490
|
context,
|
|
62474
|
-
|
|
62491
|
+
select: selectWithoutPointers
|
|
62475
62492
|
}) : undefined;
|
|
62476
62493
|
await hook?.runOnSingleObject({
|
|
62477
62494
|
operationType: "beforeRead" /* BeforeRead */,
|
|
62478
62495
|
id
|
|
62479
62496
|
});
|
|
62480
62497
|
const whereWithACLCondition = this._buildWhereWithACL(where || {}, context, "read");
|
|
62481
|
-
const
|
|
62482
|
-
|
|
62483
|
-
|
|
62484
|
-
|
|
62485
|
-
];
|
|
62498
|
+
const selectWithPointersAndRelationsToGetId = Object.keys(pointers).reduce((acc, fieldName) => {
|
|
62499
|
+
acc[fieldName] = true;
|
|
62500
|
+
return acc;
|
|
62501
|
+
}, selectWithoutPointers);
|
|
62486
62502
|
await hook?.runOnSingleObject({
|
|
62487
62503
|
operationType: "afterRead" /* AfterRead */,
|
|
62488
62504
|
id
|
|
@@ -62491,40 +62507,52 @@ class DatabaseController2 {
|
|
|
62491
62507
|
className,
|
|
62492
62508
|
id,
|
|
62493
62509
|
context,
|
|
62494
|
-
|
|
62510
|
+
select: !select ? undefined : selectWithPointersAndRelationsToGetId,
|
|
62495
62511
|
where: whereWithACLCondition,
|
|
62496
62512
|
skipHooks: true
|
|
62497
62513
|
});
|
|
62498
|
-
return
|
|
62514
|
+
return {
|
|
62515
|
+
...objectToReturn,
|
|
62516
|
+
...await this._getFinalObjectWithPointerAndRelation({
|
|
62517
|
+
context,
|
|
62518
|
+
originClassName: className,
|
|
62519
|
+
pointers,
|
|
62520
|
+
object: objectToReturn,
|
|
62521
|
+
isGraphQLCall
|
|
62522
|
+
})
|
|
62523
|
+
};
|
|
62499
62524
|
}
|
|
62500
62525
|
async getObjects({
|
|
62501
62526
|
className,
|
|
62502
|
-
|
|
62527
|
+
select,
|
|
62503
62528
|
context,
|
|
62504
62529
|
where,
|
|
62505
62530
|
skipHooks,
|
|
62506
62531
|
first,
|
|
62507
62532
|
offset,
|
|
62508
|
-
order
|
|
62533
|
+
order,
|
|
62534
|
+
isGraphQLCall = false
|
|
62509
62535
|
}) {
|
|
62510
|
-
const
|
|
62511
|
-
|
|
62512
|
-
|
|
62536
|
+
const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
|
|
62537
|
+
className,
|
|
62538
|
+
context,
|
|
62539
|
+
select
|
|
62540
|
+
});
|
|
62513
62541
|
const whereWithPointer = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
62514
|
-
const whereWithACLCondition = this._buildWhereWithACL(whereWithPointer, context, "read");
|
|
62542
|
+
const whereWithACLCondition = this._buildWhereWithACL(whereWithPointer || {}, context, "read");
|
|
62543
|
+
const selectWithPointersAndRelationsToGetId = Object.keys(pointers).reduce((acc, fieldName) => {
|
|
62544
|
+
acc[fieldName] = true;
|
|
62545
|
+
return acc;
|
|
62546
|
+
}, selectWithoutPointers);
|
|
62515
62547
|
const hook = !skipHooks ? initializeHook({
|
|
62516
62548
|
className,
|
|
62517
|
-
|
|
62549
|
+
select: selectWithoutPointers,
|
|
62518
62550
|
context
|
|
62519
62551
|
}) : undefined;
|
|
62520
62552
|
await hook?.runOnMultipleObjects({
|
|
62521
62553
|
operationType: "beforeRead" /* BeforeRead */,
|
|
62522
62554
|
where: whereWithACLCondition
|
|
62523
62555
|
});
|
|
62524
|
-
const fieldsWithPointerFields = [
|
|
62525
|
-
...fieldsWithoutPointers,
|
|
62526
|
-
...pointersFieldsId || []
|
|
62527
|
-
];
|
|
62528
62556
|
await hook?.runOnMultipleObjects({
|
|
62529
62557
|
operationType: "afterRead" /* AfterRead */,
|
|
62530
62558
|
where: whereWithACLCondition
|
|
@@ -62535,23 +62563,33 @@ class DatabaseController2 {
|
|
|
62535
62563
|
first,
|
|
62536
62564
|
offset,
|
|
62537
62565
|
where: whereWithACLCondition,
|
|
62538
|
-
|
|
62566
|
+
select: !select ? undefined : selectWithPointersAndRelationsToGetId,
|
|
62539
62567
|
order,
|
|
62540
62568
|
skipHooks: true
|
|
62541
62569
|
});
|
|
62542
|
-
return Promise.all(objectsToReturn.map((object) =>
|
|
62570
|
+
return Promise.all(objectsToReturn.map(async (object) => ({
|
|
62571
|
+
...object,
|
|
62572
|
+
...await this._getFinalObjectWithPointerAndRelation({
|
|
62573
|
+
object,
|
|
62574
|
+
context,
|
|
62575
|
+
originClassName: className,
|
|
62576
|
+
pointers,
|
|
62577
|
+
isGraphQLCall
|
|
62578
|
+
})
|
|
62579
|
+
})));
|
|
62543
62580
|
}
|
|
62544
62581
|
async createObject({
|
|
62545
62582
|
className,
|
|
62546
62583
|
context,
|
|
62547
62584
|
data,
|
|
62548
|
-
|
|
62585
|
+
select,
|
|
62586
|
+
isGraphQLCall = false
|
|
62549
62587
|
}) {
|
|
62550
62588
|
const hook = initializeHook({
|
|
62551
62589
|
className,
|
|
62552
62590
|
context,
|
|
62553
62591
|
newData: data,
|
|
62554
|
-
|
|
62592
|
+
select
|
|
62555
62593
|
});
|
|
62556
62594
|
const { newData } = await hook.runOnSingleObject({
|
|
62557
62595
|
operationType: "beforeCreate" /* BeforeCreate */
|
|
@@ -62559,31 +62597,33 @@ class DatabaseController2 {
|
|
|
62559
62597
|
const { id } = await this.adapter.createObject({
|
|
62560
62598
|
className,
|
|
62561
62599
|
context,
|
|
62562
|
-
|
|
62600
|
+
select,
|
|
62563
62601
|
data: newData
|
|
62564
62602
|
});
|
|
62565
62603
|
await hook.runOnSingleObject({
|
|
62566
62604
|
operationType: "afterCreate" /* AfterCreate */,
|
|
62567
62605
|
id
|
|
62568
62606
|
});
|
|
62569
|
-
if (
|
|
62607
|
+
if (select && Object.keys(select).length === 0)
|
|
62570
62608
|
return null;
|
|
62571
62609
|
return this.getObject({
|
|
62572
62610
|
className,
|
|
62573
62611
|
context: contextWithRoot(context),
|
|
62574
|
-
|
|
62612
|
+
select,
|
|
62575
62613
|
id,
|
|
62576
|
-
skipHooks: true
|
|
62614
|
+
skipHooks: true,
|
|
62615
|
+
isGraphQLCall
|
|
62577
62616
|
});
|
|
62578
62617
|
}
|
|
62579
62618
|
async createObjects({
|
|
62580
62619
|
data,
|
|
62581
|
-
|
|
62620
|
+
select,
|
|
62582
62621
|
className,
|
|
62583
62622
|
context,
|
|
62584
62623
|
first,
|
|
62585
62624
|
offset,
|
|
62586
|
-
order
|
|
62625
|
+
order,
|
|
62626
|
+
isGraphQLCall = false
|
|
62587
62627
|
}) {
|
|
62588
62628
|
if (data.length === 0)
|
|
62589
62629
|
return [];
|
|
@@ -62591,14 +62631,14 @@ class DatabaseController2 {
|
|
|
62591
62631
|
className,
|
|
62592
62632
|
context,
|
|
62593
62633
|
newData,
|
|
62594
|
-
|
|
62634
|
+
select
|
|
62595
62635
|
})));
|
|
62596
62636
|
const arrayOfComputedData = await Promise.all(hooks.map(async (hook) => (await hook.runOnMultipleObjects({
|
|
62597
62637
|
operationType: "beforeCreate" /* BeforeCreate */
|
|
62598
62638
|
}))?.newData[0]));
|
|
62599
62639
|
const listOfIds = await this.adapter.createObjects({
|
|
62600
62640
|
className,
|
|
62601
|
-
|
|
62641
|
+
select,
|
|
62602
62642
|
context,
|
|
62603
62643
|
data: arrayOfComputedData,
|
|
62604
62644
|
first,
|
|
@@ -62610,17 +62650,18 @@ class DatabaseController2 {
|
|
|
62610
62650
|
operationType: "afterCreate" /* AfterCreate */,
|
|
62611
62651
|
ids
|
|
62612
62652
|
})));
|
|
62613
|
-
if (
|
|
62653
|
+
if (select && Object.keys(select).length === 0)
|
|
62614
62654
|
return [];
|
|
62615
62655
|
return this.getObjects({
|
|
62616
62656
|
className,
|
|
62617
62657
|
context,
|
|
62618
|
-
|
|
62658
|
+
select,
|
|
62619
62659
|
where: { id: { in: ids } },
|
|
62620
62660
|
skipHooks: true,
|
|
62621
62661
|
first,
|
|
62622
62662
|
offset,
|
|
62623
|
-
order
|
|
62663
|
+
order,
|
|
62664
|
+
isGraphQLCall
|
|
62624
62665
|
});
|
|
62625
62666
|
}
|
|
62626
62667
|
async updateObject({
|
|
@@ -62628,14 +62669,15 @@ class DatabaseController2 {
|
|
|
62628
62669
|
className,
|
|
62629
62670
|
context,
|
|
62630
62671
|
data,
|
|
62631
|
-
|
|
62632
|
-
skipHooks
|
|
62672
|
+
select,
|
|
62673
|
+
skipHooks,
|
|
62674
|
+
isGraphQLCall = false
|
|
62633
62675
|
}) {
|
|
62634
62676
|
const hook = !skipHooks ? initializeHook({
|
|
62635
62677
|
className,
|
|
62636
62678
|
context,
|
|
62637
62679
|
newData: data,
|
|
62638
|
-
|
|
62680
|
+
select
|
|
62639
62681
|
}) : undefined;
|
|
62640
62682
|
const resultsAfterBeforeUpdate = await hook?.runOnSingleObject({
|
|
62641
62683
|
operationType: "beforeUpdate" /* BeforeUpdate */,
|
|
@@ -62644,7 +62686,7 @@ class DatabaseController2 {
|
|
|
62644
62686
|
const whereWithACLCondition = this._buildWhereWithACL({}, context, "write");
|
|
62645
62687
|
await this.adapter.updateObject({
|
|
62646
62688
|
className,
|
|
62647
|
-
|
|
62689
|
+
select,
|
|
62648
62690
|
id,
|
|
62649
62691
|
context,
|
|
62650
62692
|
data: resultsAfterBeforeUpdate?.newData || data,
|
|
@@ -62655,33 +62697,35 @@ class DatabaseController2 {
|
|
|
62655
62697
|
id,
|
|
62656
62698
|
originalObject: resultsAfterBeforeUpdate?.object
|
|
62657
62699
|
});
|
|
62658
|
-
if (
|
|
62700
|
+
if (select && Object.keys(select).length === 0)
|
|
62659
62701
|
return null;
|
|
62660
62702
|
return this.getObject({
|
|
62661
62703
|
className,
|
|
62662
62704
|
context,
|
|
62663
|
-
|
|
62705
|
+
select,
|
|
62664
62706
|
id,
|
|
62665
|
-
skipHooks: true
|
|
62707
|
+
skipHooks: true,
|
|
62708
|
+
isGraphQLCall
|
|
62666
62709
|
});
|
|
62667
62710
|
}
|
|
62668
62711
|
async updateObjects({
|
|
62669
62712
|
className,
|
|
62670
62713
|
where,
|
|
62671
62714
|
context,
|
|
62672
|
-
|
|
62715
|
+
select,
|
|
62673
62716
|
data,
|
|
62674
62717
|
first,
|
|
62675
62718
|
offset,
|
|
62676
62719
|
order,
|
|
62677
|
-
skipHooks
|
|
62720
|
+
skipHooks,
|
|
62721
|
+
isGraphQLCall = false
|
|
62678
62722
|
}) {
|
|
62679
62723
|
const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
62680
62724
|
const hook = !skipHooks ? initializeHook({
|
|
62681
62725
|
className,
|
|
62682
62726
|
context,
|
|
62683
62727
|
newData: data,
|
|
62684
|
-
|
|
62728
|
+
select
|
|
62685
62729
|
}) : undefined;
|
|
62686
62730
|
const whereWithACLCondition = this._buildWhereWithACL(whereObject, context, "write");
|
|
62687
62731
|
const resultsAfterBeforeUpdate = await hook?.runOnMultipleObjects({
|
|
@@ -62691,7 +62735,7 @@ class DatabaseController2 {
|
|
|
62691
62735
|
const objects = await this.adapter.updateObjects({
|
|
62692
62736
|
className,
|
|
62693
62737
|
context,
|
|
62694
|
-
|
|
62738
|
+
select,
|
|
62695
62739
|
data: resultsAfterBeforeUpdate?.newData[0] || data,
|
|
62696
62740
|
where: whereWithACLCondition,
|
|
62697
62741
|
first,
|
|
@@ -62704,39 +62748,42 @@ class DatabaseController2 {
|
|
|
62704
62748
|
ids: objectsId,
|
|
62705
62749
|
originalObjects: resultsAfterBeforeUpdate?.objects || []
|
|
62706
62750
|
});
|
|
62707
|
-
if (
|
|
62751
|
+
if (select && Object.keys(select).length === 0)
|
|
62708
62752
|
return [];
|
|
62709
62753
|
return this.getObjects({
|
|
62710
62754
|
className,
|
|
62711
62755
|
context,
|
|
62712
|
-
|
|
62756
|
+
select,
|
|
62713
62757
|
where: { id: { in: objectsId } },
|
|
62714
62758
|
skipHooks: true,
|
|
62715
62759
|
first,
|
|
62716
62760
|
offset,
|
|
62717
|
-
order
|
|
62761
|
+
order,
|
|
62762
|
+
isGraphQLCall
|
|
62718
62763
|
});
|
|
62719
62764
|
}
|
|
62720
62765
|
async deleteObject({
|
|
62721
62766
|
context,
|
|
62722
62767
|
className,
|
|
62723
62768
|
id,
|
|
62724
|
-
|
|
62769
|
+
select,
|
|
62770
|
+
isGraphQLCall = false
|
|
62725
62771
|
}) {
|
|
62726
62772
|
const hook = initializeHook({
|
|
62727
62773
|
className,
|
|
62728
62774
|
context,
|
|
62729
|
-
|
|
62775
|
+
select
|
|
62730
62776
|
});
|
|
62731
62777
|
const whereWithACLCondition = this._buildWhereWithACL({}, context, "write");
|
|
62732
62778
|
let objectBeforeDelete = null;
|
|
62733
|
-
if (
|
|
62779
|
+
if (select && Object.keys(select).length > 0)
|
|
62734
62780
|
objectBeforeDelete = await this.getObject({
|
|
62735
62781
|
className,
|
|
62736
|
-
|
|
62782
|
+
select,
|
|
62737
62783
|
id,
|
|
62738
62784
|
context,
|
|
62739
|
-
skipHooks: true
|
|
62785
|
+
skipHooks: true,
|
|
62786
|
+
isGraphQLCall
|
|
62740
62787
|
});
|
|
62741
62788
|
const resultOfBeforeDelete = await hook.runOnSingleObject({
|
|
62742
62789
|
operationType: "beforeDelete" /* BeforeDelete */,
|
|
@@ -62745,7 +62792,7 @@ class DatabaseController2 {
|
|
|
62745
62792
|
await this.adapter.deleteObject({
|
|
62746
62793
|
className,
|
|
62747
62794
|
context,
|
|
62748
|
-
|
|
62795
|
+
select,
|
|
62749
62796
|
id,
|
|
62750
62797
|
where: whereWithACLCondition
|
|
62751
62798
|
});
|
|
@@ -62758,30 +62805,32 @@ class DatabaseController2 {
|
|
|
62758
62805
|
async deleteObjects({
|
|
62759
62806
|
className,
|
|
62760
62807
|
context,
|
|
62761
|
-
|
|
62808
|
+
select,
|
|
62762
62809
|
where,
|
|
62763
62810
|
first,
|
|
62764
62811
|
offset,
|
|
62765
|
-
order
|
|
62812
|
+
order,
|
|
62813
|
+
isGraphQLCall = false
|
|
62766
62814
|
}) {
|
|
62767
62815
|
const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
62768
62816
|
const hook = initializeHook({
|
|
62769
62817
|
className,
|
|
62770
62818
|
context,
|
|
62771
|
-
|
|
62819
|
+
select
|
|
62772
62820
|
});
|
|
62773
62821
|
const whereWithACLCondition = this._buildWhereWithACL(whereObject, context, "write");
|
|
62774
62822
|
let objectsBeforeDelete = [];
|
|
62775
|
-
if (
|
|
62823
|
+
if (select && Object.keys(select).length > 0)
|
|
62776
62824
|
objectsBeforeDelete = await this.getObjects({
|
|
62777
62825
|
className,
|
|
62778
62826
|
where,
|
|
62779
|
-
|
|
62827
|
+
select,
|
|
62780
62828
|
context,
|
|
62781
62829
|
first,
|
|
62782
62830
|
offset,
|
|
62783
62831
|
order,
|
|
62784
|
-
skipHooks: true
|
|
62832
|
+
skipHooks: true,
|
|
62833
|
+
isGraphQLCall
|
|
62785
62834
|
});
|
|
62786
62835
|
const resultOfBeforeDelete = await hook.runOnMultipleObjects({
|
|
62787
62836
|
operationType: "beforeDelete" /* BeforeDelete */,
|
|
@@ -62790,7 +62839,7 @@ class DatabaseController2 {
|
|
|
62790
62839
|
await this.adapter.deleteObjects({
|
|
62791
62840
|
className,
|
|
62792
62841
|
context,
|
|
62793
|
-
|
|
62842
|
+
select,
|
|
62794
62843
|
first,
|
|
62795
62844
|
offset,
|
|
62796
62845
|
where: whereWithACLCondition,
|
|
@@ -62844,15 +62893,34 @@ class Session {
|
|
|
62844
62893
|
where: {
|
|
62845
62894
|
accessToken: { equalTo: accessToken }
|
|
62846
62895
|
},
|
|
62896
|
+
select: {
|
|
62897
|
+
id: true,
|
|
62898
|
+
user: true
|
|
62899
|
+
},
|
|
62847
62900
|
first: 1,
|
|
62848
|
-
fields: ["user.*", "user.role.*", "id"],
|
|
62849
62901
|
context
|
|
62850
62902
|
});
|
|
62851
62903
|
if (sessions.length === 0)
|
|
62852
62904
|
return { sessionId: null, user: null };
|
|
62853
62905
|
const session = sessions[0];
|
|
62854
62906
|
const user = session?.user;
|
|
62855
|
-
|
|
62907
|
+
if (!user)
|
|
62908
|
+
return { sessionId: session?.id ?? null, user: null };
|
|
62909
|
+
const userWithRole = await context.wabe.controllers.database.getObject({
|
|
62910
|
+
className: "User",
|
|
62911
|
+
select: {
|
|
62912
|
+
role: true
|
|
62913
|
+
},
|
|
62914
|
+
context,
|
|
62915
|
+
id: user.id
|
|
62916
|
+
});
|
|
62917
|
+
return {
|
|
62918
|
+
sessionId: session?.id ?? null,
|
|
62919
|
+
user: {
|
|
62920
|
+
...user,
|
|
62921
|
+
role: userWithRole?.role
|
|
62922
|
+
}
|
|
62923
|
+
};
|
|
62856
62924
|
}
|
|
62857
62925
|
async create(userId, context) {
|
|
62858
62926
|
this.accessToken = import_jsonwebtoken.default.sign({
|
|
@@ -62875,7 +62943,7 @@ class Session {
|
|
|
62875
62943
|
refreshTokenExpiresAt: this.getRefreshTokenExpireAt(context.wabe.config),
|
|
62876
62944
|
user: userId
|
|
62877
62945
|
},
|
|
62878
|
-
|
|
62946
|
+
select: { id: true }
|
|
62879
62947
|
});
|
|
62880
62948
|
if (!res)
|
|
62881
62949
|
throw new Error("Session not created");
|
|
@@ -62892,7 +62960,7 @@ class Session {
|
|
|
62892
62960
|
className: "_Session",
|
|
62893
62961
|
context: contextWithRoot(context),
|
|
62894
62962
|
id: context.sessionId,
|
|
62895
|
-
|
|
62963
|
+
select: {}
|
|
62896
62964
|
});
|
|
62897
62965
|
}
|
|
62898
62966
|
_isRefreshTokenExpired(userRefreshTokenExpiresAt, refreshTokenAgeInMs) {
|
|
@@ -62906,7 +62974,18 @@ class Session {
|
|
|
62906
62974
|
where: {
|
|
62907
62975
|
accessToken: { equalTo: accessToken }
|
|
62908
62976
|
},
|
|
62909
|
-
|
|
62977
|
+
select: {
|
|
62978
|
+
id: true,
|
|
62979
|
+
user: {
|
|
62980
|
+
id: true,
|
|
62981
|
+
role: {
|
|
62982
|
+
id: true,
|
|
62983
|
+
name: true
|
|
62984
|
+
}
|
|
62985
|
+
},
|
|
62986
|
+
refreshToken: true,
|
|
62987
|
+
refreshTokenExpiresAt: true
|
|
62988
|
+
},
|
|
62910
62989
|
context: contextWithRoot(context)
|
|
62911
62990
|
});
|
|
62912
62991
|
if (!session.length)
|
|
@@ -62922,10 +63001,10 @@ class Session {
|
|
|
62922
63001
|
refreshToken: databaseRefreshToken,
|
|
62923
63002
|
id
|
|
62924
63003
|
} = session[0];
|
|
62925
|
-
if (refreshTokenExpiresAt < new Date(Date.now()))
|
|
63004
|
+
if (new Date(refreshTokenExpiresAt) < new Date(Date.now()))
|
|
62926
63005
|
throw new Error("Refresh token expired");
|
|
62927
63006
|
const expiresInMs = this._getRefreshTokenExpiresInMs(context.wabe.config);
|
|
62928
|
-
if (!this._isRefreshTokenExpired(refreshTokenExpiresAt, expiresInMs))
|
|
63007
|
+
if (!this._isRefreshTokenExpired(new Date(refreshTokenExpiresAt), expiresInMs))
|
|
62929
63008
|
return {
|
|
62930
63009
|
accessToken,
|
|
62931
63010
|
refreshToken
|
|
@@ -62958,7 +63037,7 @@ class Session {
|
|
|
62958
63037
|
refreshToken: newRefreshToken,
|
|
62959
63038
|
refreshTokenExpiresAt: this.getRefreshTokenExpireAt(context.wabe.config)
|
|
62960
63039
|
},
|
|
62961
|
-
|
|
63040
|
+
select: {}
|
|
62962
63041
|
});
|
|
62963
63042
|
return {
|
|
62964
63043
|
accessToken: newAccessToken,
|
|
@@ -63017,7 +63096,7 @@ var signUpWithResolver = async (_, {
|
|
|
63017
63096
|
authentication: input.authentication
|
|
63018
63097
|
},
|
|
63019
63098
|
context,
|
|
63020
|
-
|
|
63099
|
+
select: { id: true }
|
|
63021
63100
|
});
|
|
63022
63101
|
const createdUserId = res?.id;
|
|
63023
63102
|
const session = new Session;
|
|
@@ -63232,6 +63311,8 @@ var verifyChallengeResolver = async (_, {
|
|
|
63232
63311
|
|
|
63233
63312
|
// src/schema/resolvers/meResolver.ts
|
|
63234
63313
|
var meResolver = (_, __, context) => {
|
|
63314
|
+
if (!context.user?.id)
|
|
63315
|
+
return { user: undefined };
|
|
63235
63316
|
return {
|
|
63236
63317
|
user: context.user
|
|
63237
63318
|
};
|
|
@@ -63284,7 +63365,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
|
|
|
63284
63365
|
equalTo: email
|
|
63285
63366
|
}
|
|
63286
63367
|
},
|
|
63287
|
-
|
|
63368
|
+
select: { id: true },
|
|
63288
63369
|
first: 1,
|
|
63289
63370
|
context: contextWithRoot(context)
|
|
63290
63371
|
});
|
|
@@ -63310,7 +63391,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
|
|
|
63310
63391
|
}
|
|
63311
63392
|
}
|
|
63312
63393
|
},
|
|
63313
|
-
|
|
63394
|
+
select: {},
|
|
63314
63395
|
context: contextWithRoot(context)
|
|
63315
63396
|
});
|
|
63316
63397
|
return true;
|
|
@@ -63450,7 +63531,7 @@ var sendOtpCodeResolver = async (_, { input }, context) => {
|
|
|
63450
63531
|
equalTo: input.email
|
|
63451
63532
|
}
|
|
63452
63533
|
},
|
|
63453
|
-
|
|
63534
|
+
select: { id: true },
|
|
63454
63535
|
first: 1,
|
|
63455
63536
|
context: contextWithRoot(context)
|
|
63456
63537
|
});
|
|
@@ -66604,7 +66685,7 @@ var GraphqlParser = ({ scalars, enums }) => ({
|
|
|
66604
66685
|
const graphqlType2 = getGraphqlType({
|
|
66605
66686
|
type: currentField.type,
|
|
66606
66687
|
typeValue: currentField.typeValue,
|
|
66607
|
-
isWhereType
|
|
66688
|
+
isWhereType,
|
|
66608
66689
|
requiredValue: currentField.requiredValue
|
|
66609
66690
|
});
|
|
66610
66691
|
acc[key] = {
|
|
@@ -66883,7 +66964,7 @@ var createAndLink = async ({
|
|
|
66883
66964
|
const res = await context.wabe.controllers.database.createObject({
|
|
66884
66965
|
className: classInSchema.fields[fieldName].class,
|
|
66885
66966
|
data: createAndLink2,
|
|
66886
|
-
|
|
66967
|
+
select: { id: true },
|
|
66887
66968
|
context
|
|
66888
66969
|
});
|
|
66889
66970
|
return res?.id;
|
|
@@ -66898,7 +66979,7 @@ var createAndAdd = async ({
|
|
|
66898
66979
|
const result2 = await context.wabe.controllers.database.createObjects({
|
|
66899
66980
|
className: classInSchema.fields[fieldName].class,
|
|
66900
66981
|
data: createAndAdd2,
|
|
66901
|
-
|
|
66982
|
+
select: { id: true },
|
|
66902
66983
|
context
|
|
66903
66984
|
});
|
|
66904
66985
|
return result2.map((object) => object.id);
|
|
@@ -66920,16 +67001,16 @@ var add = async ({
|
|
|
66920
67001
|
const currentValue = await context.wabe.controllers.database.getObject({
|
|
66921
67002
|
className,
|
|
66922
67003
|
id,
|
|
66923
|
-
|
|
67004
|
+
select: { id: true },
|
|
66924
67005
|
context
|
|
66925
67006
|
});
|
|
66926
|
-
return [
|
|
67007
|
+
return [currentValue?.id, ...add2];
|
|
66927
67008
|
}
|
|
66928
67009
|
if (typeOfExecution === "updateMany" && where) {
|
|
66929
67010
|
const allObjectsMatchedWithWhere = await context.wabe.controllers.database.getObjects({
|
|
66930
67011
|
className: fieldInClass.class,
|
|
66931
67012
|
where,
|
|
66932
|
-
|
|
67013
|
+
select: { [fieldName]: true },
|
|
66933
67014
|
context
|
|
66934
67015
|
});
|
|
66935
67016
|
await Promise.all(allObjectsMatchedWithWhere.map((object) => {
|
|
@@ -66941,7 +67022,7 @@ var add = async ({
|
|
|
66941
67022
|
[fieldName]: [...currentValue || [], ...add2]
|
|
66942
67023
|
},
|
|
66943
67024
|
context,
|
|
66944
|
-
|
|
67025
|
+
select: {}
|
|
66945
67026
|
});
|
|
66946
67027
|
}));
|
|
66947
67028
|
}
|
|
@@ -66961,17 +67042,17 @@ var remove = async ({
|
|
|
66961
67042
|
const currentValue = await context.wabe.controllers.database.getObject({
|
|
66962
67043
|
className,
|
|
66963
67044
|
id,
|
|
66964
|
-
|
|
67045
|
+
select: { id: true },
|
|
66965
67046
|
context
|
|
66966
67047
|
});
|
|
66967
|
-
const olderValues = currentValue?.
|
|
67048
|
+
const olderValues = [currentValue?.id || ""];
|
|
66968
67049
|
return olderValues.filter((olderValue) => !remove2.includes(olderValue));
|
|
66969
67050
|
}
|
|
66970
67051
|
if (typeOfExecution === "updateMany" && where) {
|
|
66971
67052
|
const allObjectsMatchedWithWhere = await context.wabe.controllers.database.getObjects({
|
|
66972
67053
|
className,
|
|
66973
67054
|
where,
|
|
66974
|
-
|
|
67055
|
+
select: { id: true },
|
|
66975
67056
|
context
|
|
66976
67057
|
});
|
|
66977
67058
|
await Promise.all(allObjectsMatchedWithWhere.map(async (object) => {
|
|
@@ -66983,7 +67064,7 @@ var remove = async ({
|
|
|
66983
67064
|
[fieldName]: olderValues.filter((olderValue) => !remove2.includes(olderValue))
|
|
66984
67065
|
},
|
|
66985
67066
|
context,
|
|
66986
|
-
|
|
67067
|
+
select: {}
|
|
66987
67068
|
});
|
|
66988
67069
|
}));
|
|
66989
67070
|
}
|
|
@@ -66994,16 +67075,23 @@ var extractFieldsFromSetNode = (selectionSet, className) => {
|
|
|
66994
67075
|
const ignoredFields = ["edges", "node"];
|
|
66995
67076
|
if (className)
|
|
66996
67077
|
ignoredFields.push(firstLetterInLowerCase(className));
|
|
66997
|
-
return selectionSet.selections?.
|
|
67078
|
+
return selectionSet.selections?.reduce((acc, selection) => {
|
|
66998
67079
|
const currentValue = selection.name.value;
|
|
66999
67080
|
if (selection.selectionSet?.selections && selection.selectionSet?.selections?.length > 0) {
|
|
67000
67081
|
const res = extractFieldsFromSetNode(selection.selectionSet, className);
|
|
67001
67082
|
if (ignoredFields.indexOf(currentValue) === -1)
|
|
67002
|
-
return
|
|
67003
|
-
|
|
67083
|
+
return {
|
|
67084
|
+
...acc,
|
|
67085
|
+
[currentValue]: res
|
|
67086
|
+
};
|
|
67087
|
+
return {
|
|
67088
|
+
...acc,
|
|
67089
|
+
...res
|
|
67090
|
+
};
|
|
67004
67091
|
}
|
|
67005
|
-
|
|
67006
|
-
|
|
67092
|
+
acc[currentValue] = true;
|
|
67093
|
+
return acc;
|
|
67094
|
+
}, {});
|
|
67007
67095
|
};
|
|
67008
67096
|
var getFieldsFromInfo = (info, className) => {
|
|
67009
67097
|
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
@@ -67014,24 +67102,6 @@ var getFieldsFromInfo = (info, className) => {
|
|
|
67014
67102
|
throw new Error("No fields provided");
|
|
67015
67103
|
return fields;
|
|
67016
67104
|
};
|
|
67017
|
-
var getFieldsOfClassName = ({
|
|
67018
|
-
fields,
|
|
67019
|
-
className,
|
|
67020
|
-
context
|
|
67021
|
-
}) => {
|
|
67022
|
-
const classFields = context.wabe.config.schema?.classes?.find((schemaClass) => schemaClass.name === className)?.fields;
|
|
67023
|
-
if (!classFields)
|
|
67024
|
-
return { classFields: [], othersFields: fields };
|
|
67025
|
-
const sameFieldsAsClass = fields.filter((field) => {
|
|
67026
|
-
if (classFields[field] || field === "id")
|
|
67027
|
-
return true;
|
|
67028
|
-
if (Object.keys(classFields).find((classField) => field.includes(classField)))
|
|
67029
|
-
return true;
|
|
67030
|
-
return false;
|
|
67031
|
-
});
|
|
67032
|
-
const othersFields = fields.filter((field) => !sameFieldsAsClass.includes(field));
|
|
67033
|
-
return { classFields: sameFieldsAsClass, othersFields };
|
|
67034
|
-
};
|
|
67035
67105
|
var executeRelationOnFields = ({
|
|
67036
67106
|
className,
|
|
67037
67107
|
fields,
|
|
@@ -67099,27 +67169,29 @@ var transformOrder = (order) => order?.reduce((acc, currentOrder) => {
|
|
|
67099
67169
|
return acc;
|
|
67100
67170
|
}, {}) || {};
|
|
67101
67171
|
var queryForOneObject = (_, { id }, context, info, className) => {
|
|
67102
|
-
const
|
|
67172
|
+
const select = getFieldsFromInfo(info, className);
|
|
67103
67173
|
return context.wabe.controllers.database.getObject({
|
|
67104
67174
|
className,
|
|
67105
67175
|
id,
|
|
67106
|
-
|
|
67107
|
-
context
|
|
67176
|
+
select,
|
|
67177
|
+
context,
|
|
67178
|
+
isGraphQLCall: true
|
|
67108
67179
|
});
|
|
67109
67180
|
};
|
|
67110
67181
|
var queryForMultipleObject = async (_, { where, offset, first, order }, context, info, className) => {
|
|
67111
|
-
const
|
|
67182
|
+
const select = getFieldsFromInfo(info, className);
|
|
67112
67183
|
const objects = await context.wabe.controllers.database.getObjects({
|
|
67113
67184
|
className,
|
|
67114
67185
|
where,
|
|
67115
|
-
|
|
67186
|
+
select,
|
|
67116
67187
|
offset,
|
|
67117
67188
|
first,
|
|
67118
67189
|
context,
|
|
67119
|
-
order: transformOrder(order)
|
|
67190
|
+
order: transformOrder(order),
|
|
67191
|
+
isGraphQLCall: true
|
|
67120
67192
|
});
|
|
67121
67193
|
return {
|
|
67122
|
-
totalCount:
|
|
67194
|
+
totalCount: select.totalCount ? await context.wabe.controllers.database.count({
|
|
67123
67195
|
className,
|
|
67124
67196
|
where,
|
|
67125
67197
|
context
|
|
@@ -67130,11 +67202,7 @@ var queryForMultipleObject = async (_, { where, offset, first, order }, context,
|
|
|
67130
67202
|
};
|
|
67131
67203
|
};
|
|
67132
67204
|
var mutationToCreateObject = async (_, args, context, info, className) => {
|
|
67133
|
-
const
|
|
67134
|
-
fields: getFieldsFromInfo(info, className),
|
|
67135
|
-
className,
|
|
67136
|
-
context
|
|
67137
|
-
});
|
|
67205
|
+
const select = getFieldsFromInfo(info, className);
|
|
67138
67206
|
const updatedFieldsToCreate = await executeRelationOnFields({
|
|
67139
67207
|
className,
|
|
67140
67208
|
fields: args.input?.fields,
|
|
@@ -67144,14 +67212,15 @@ var mutationToCreateObject = async (_, args, context, info, className) => {
|
|
|
67144
67212
|
[firstLetterInLowerCase(className)]: await context.wabe.controllers.database.createObject({
|
|
67145
67213
|
className,
|
|
67146
67214
|
data: updatedFieldsToCreate,
|
|
67147
|
-
|
|
67148
|
-
context
|
|
67215
|
+
select,
|
|
67216
|
+
context,
|
|
67217
|
+
isGraphQLCall: true
|
|
67149
67218
|
}),
|
|
67150
|
-
...
|
|
67219
|
+
...select.ok ? { ok: true } : {}
|
|
67151
67220
|
};
|
|
67152
67221
|
};
|
|
67153
67222
|
var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first, order } }, context, info, className) => {
|
|
67154
|
-
const
|
|
67223
|
+
const select = getFieldsFromInfo(info, className);
|
|
67155
67224
|
const inputFields = fields;
|
|
67156
67225
|
const updatedFieldsToCreate = await Promise.all(inputFields.map((inputField) => executeRelationOnFields({
|
|
67157
67226
|
className,
|
|
@@ -67161,22 +67230,19 @@ var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first
|
|
|
67161
67230
|
const objects = await context.wabe.controllers.database.createObjects({
|
|
67162
67231
|
className,
|
|
67163
67232
|
data: updatedFieldsToCreate,
|
|
67164
|
-
|
|
67233
|
+
select,
|
|
67165
67234
|
offset,
|
|
67166
67235
|
first,
|
|
67167
67236
|
context,
|
|
67168
|
-
order: transformOrder(order)
|
|
67237
|
+
order: transformOrder(order),
|
|
67238
|
+
isGraphQLCall: true
|
|
67169
67239
|
});
|
|
67170
67240
|
return {
|
|
67171
67241
|
edges: objects.map((object) => ({ node: object }))
|
|
67172
67242
|
};
|
|
67173
67243
|
};
|
|
67174
67244
|
var mutationToUpdateObject = async (_, args, context, info, className) => {
|
|
67175
|
-
const
|
|
67176
|
-
fields: getFieldsFromInfo(info, className),
|
|
67177
|
-
className,
|
|
67178
|
-
context
|
|
67179
|
-
});
|
|
67245
|
+
const select = getFieldsFromInfo(info, className);
|
|
67180
67246
|
const updatedFields = await executeRelationOnFields({
|
|
67181
67247
|
className,
|
|
67182
67248
|
fields: args.input?.fields,
|
|
@@ -67189,14 +67255,15 @@ var mutationToUpdateObject = async (_, args, context, info, className) => {
|
|
|
67189
67255
|
className,
|
|
67190
67256
|
id: args.input?.id,
|
|
67191
67257
|
data: updatedFields,
|
|
67192
|
-
|
|
67193
|
-
context
|
|
67258
|
+
select,
|
|
67259
|
+
context,
|
|
67260
|
+
isGraphQLCall: true
|
|
67194
67261
|
}),
|
|
67195
|
-
...
|
|
67262
|
+
...select.ok ? { ok: true } : {}
|
|
67196
67263
|
};
|
|
67197
67264
|
};
|
|
67198
67265
|
var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset, first, order } }, context, info, className) => {
|
|
67199
|
-
const
|
|
67266
|
+
const select = getFieldsFromInfo(info, className);
|
|
67200
67267
|
const updatedFields = await executeRelationOnFields({
|
|
67201
67268
|
className,
|
|
67202
67269
|
fields,
|
|
@@ -67208,42 +67275,41 @@ var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset
|
|
|
67208
67275
|
className,
|
|
67209
67276
|
where,
|
|
67210
67277
|
data: updatedFields,
|
|
67211
|
-
|
|
67278
|
+
select,
|
|
67212
67279
|
offset,
|
|
67213
67280
|
first,
|
|
67214
67281
|
context,
|
|
67215
|
-
order
|
|
67282
|
+
order,
|
|
67283
|
+
isGraphQLCall: true
|
|
67216
67284
|
});
|
|
67217
67285
|
return {
|
|
67218
67286
|
edges: objects.map((object) => ({ node: object }))
|
|
67219
67287
|
};
|
|
67220
67288
|
};
|
|
67221
67289
|
var mutationToDeleteObject = async (_, args, context, info, className) => {
|
|
67222
|
-
const
|
|
67223
|
-
fields: getFieldsFromInfo(info, className),
|
|
67224
|
-
className,
|
|
67225
|
-
context
|
|
67226
|
-
});
|
|
67290
|
+
const select = getFieldsFromInfo(info, className);
|
|
67227
67291
|
return {
|
|
67228
67292
|
[firstLetterInLowerCase(className)]: await context.wabe.controllers.database.deleteObject({
|
|
67229
67293
|
className,
|
|
67230
67294
|
id: args.input?.id,
|
|
67231
|
-
|
|
67232
|
-
context
|
|
67295
|
+
select,
|
|
67296
|
+
context,
|
|
67297
|
+
isGraphQLCall: true
|
|
67233
67298
|
}),
|
|
67234
|
-
...
|
|
67299
|
+
...select.ok ? { ok: true } : {}
|
|
67235
67300
|
};
|
|
67236
67301
|
};
|
|
67237
67302
|
var mutationToDeleteMultipleObjects = async (_, { input: { where, offset, first, order } }, context, info, className) => {
|
|
67238
|
-
const
|
|
67303
|
+
const select = getFieldsFromInfo(info, className);
|
|
67239
67304
|
const objects = await context.wabe.controllers.database.deleteObjects({
|
|
67240
67305
|
className,
|
|
67241
67306
|
where,
|
|
67242
|
-
|
|
67307
|
+
select,
|
|
67243
67308
|
offset,
|
|
67244
67309
|
first,
|
|
67245
67310
|
context,
|
|
67246
|
-
order
|
|
67311
|
+
order,
|
|
67312
|
+
isGraphQLCall: true
|
|
67247
67313
|
});
|
|
67248
67314
|
return {
|
|
67249
67315
|
edges: objects.map((object) => ({ node: object }))
|
|
@@ -68056,130 +68122,206 @@ var defaultRoutes = () => {
|
|
|
68056
68122
|
// src/server/generateCodegen.ts
|
|
68057
68123
|
var import_graphql6 = __toESM(require_graphql2(), 1);
|
|
68058
68124
|
import { writeFile as writeFile2, readFile } from "node:fs/promises";
|
|
68059
|
-
var
|
|
68060
|
-
|
|
68061
|
-
|
|
68062
|
-
|
|
68063
|
-
|
|
68064
|
-
|
|
68065
|
-
|
|
68066
|
-
|
|
68067
|
-
|
|
68068
|
-
Search: { input: "any", output: "any" },
|
|
68069
|
-
Any: { input: "any", output: "any" },
|
|
68070
|
-
File: { input: "any", output: "any" }
|
|
68125
|
+
var wabePrimaryTypesToTypescriptTypes = {
|
|
68126
|
+
Boolean: "boolean",
|
|
68127
|
+
Int: "number",
|
|
68128
|
+
Float: "number",
|
|
68129
|
+
String: "string",
|
|
68130
|
+
Email: "string",
|
|
68131
|
+
Phone: "string",
|
|
68132
|
+
Date: "Date",
|
|
68133
|
+
File: "{url: string, name: string}"
|
|
68071
68134
|
};
|
|
68072
|
-
var
|
|
68073
|
-
|
|
68074
|
-
|
|
68075
|
-
|
|
68076
|
-
|
|
68077
|
-
|
|
68078
|
-
|
|
68079
|
-
|
|
68080
|
-
|
|
68081
|
-
|
|
68082
|
-
|
|
68083
|
-
|
|
68084
|
-
|
|
68085
|
-
|
|
68086
|
-
|
|
68087
|
-
|
|
68088
|
-
|
|
68089
|
-
|
|
68090
|
-
|
|
68091
|
-
|
|
68092
|
-
|
|
68093
|
-
|
|
68094
|
-
|
|
68095
|
-
|
|
68096
|
-
|
|
68097
|
-
|
|
68098
|
-
|
|
68099
|
-
|
|
68100
|
-
|
|
68101
|
-
|
|
68102
|
-
}
|
|
68103
|
-
typescriptCode += `
|
|
68104
|
-
export type ${typeName} = {
|
|
68105
|
-
${fieldsCode}};
|
|
68106
|
-
`;
|
|
68107
|
-
if (typeName === "Mutation" || typeName === "Query") {
|
|
68108
|
-
for (const field of node.fields || []) {
|
|
68109
|
-
const fieldName = field.name.value;
|
|
68110
|
-
const args = field.arguments || [];
|
|
68111
|
-
if (args.length === 1 && args[0].name.value === "input") {
|
|
68112
|
-
const inputType = getFieldType(args[0].type, true);
|
|
68113
|
-
typescriptCode += `
|
|
68114
|
-
export type ${firstLetterUpperCase(typeName)}${firstLetterUpperCase(fieldName)}Args = {
|
|
68115
|
-
input: ${inputType};
|
|
68135
|
+
var wabeTypesToTypescriptTypes = ({
|
|
68136
|
+
field,
|
|
68137
|
+
isInput = false
|
|
68138
|
+
}) => {
|
|
68139
|
+
switch (field.type) {
|
|
68140
|
+
case "Date":
|
|
68141
|
+
if (isInput)
|
|
68142
|
+
return "Date";
|
|
68143
|
+
return "string";
|
|
68144
|
+
case "Boolean":
|
|
68145
|
+
case "Int":
|
|
68146
|
+
case "Float":
|
|
68147
|
+
case "String":
|
|
68148
|
+
case "Email":
|
|
68149
|
+
case "Phone":
|
|
68150
|
+
case "File":
|
|
68151
|
+
return wabePrimaryTypesToTypescriptTypes[field.type];
|
|
68152
|
+
case "Array":
|
|
68153
|
+
if (field.typeValue === "Object")
|
|
68154
|
+
return `Array<${field.object.name}>`;
|
|
68155
|
+
return `Array<${wabePrimaryTypesToTypescriptTypes[field.typeValue]}>`;
|
|
68156
|
+
case "Pointer":
|
|
68157
|
+
return field.class;
|
|
68158
|
+
case "Relation":
|
|
68159
|
+
return `Array<${field.class}>`;
|
|
68160
|
+
case "Object":
|
|
68161
|
+
return `${field.object.name}`;
|
|
68162
|
+
default:
|
|
68163
|
+
return field.type;
|
|
68164
|
+
}
|
|
68116
68165
|
};
|
|
68117
|
-
|
|
68118
|
-
|
|
68119
|
-
|
|
68120
|
-
|
|
68121
|
-
|
|
68122
|
-
|
|
68123
|
-
|
|
68124
|
-
|
|
68125
|
-
|
|
68126
|
-
|
|
68127
|
-
|
|
68128
|
-
|
|
68129
|
-
|
|
68166
|
+
var generateWabeObject = (object, prefix = "") => {
|
|
68167
|
+
const objectName = object.name;
|
|
68168
|
+
return Object.entries(object.fields).reduce((acc, [fieldName, field]) => {
|
|
68169
|
+
const type = wabeTypesToTypescriptTypes({ field });
|
|
68170
|
+
const objectNameWithPrefix = `${prefix}${firstLetterUpperCase(objectName)}`;
|
|
68171
|
+
if (field.type === "Object" || field.type === "Array" && field.typeValue === "Object") {
|
|
68172
|
+
const subObject = generateWabeObject(field.object, objectNameWithPrefix);
|
|
68173
|
+
const isArray = field.type === "Array";
|
|
68174
|
+
return {
|
|
68175
|
+
...acc,
|
|
68176
|
+
...subObject,
|
|
68177
|
+
...{
|
|
68178
|
+
[objectNameWithPrefix]: {
|
|
68179
|
+
...acc[objectNameWithPrefix],
|
|
68180
|
+
[`${fieldName}${field.required ? "" : "undefined"}`]: `${isArray ? "Array<" : ""}${objectNameWithPrefix}${firstLetterUpperCase(field.object.name)}${isArray ? ">" : ""}`
|
|
68130
68181
|
}
|
|
68131
68182
|
}
|
|
68183
|
+
};
|
|
68184
|
+
}
|
|
68185
|
+
return {
|
|
68186
|
+
...acc,
|
|
68187
|
+
...{
|
|
68188
|
+
[objectNameWithPrefix]: {
|
|
68189
|
+
...acc[objectNameWithPrefix],
|
|
68190
|
+
[`${fieldName}${field.required ? "" : "undefined"}`]: `${type}`
|
|
68191
|
+
}
|
|
68132
68192
|
}
|
|
68133
|
-
}
|
|
68134
|
-
|
|
68135
|
-
|
|
68136
|
-
|
|
68137
|
-
|
|
68138
|
-
|
|
68139
|
-
|
|
68140
|
-
|
|
68141
|
-
|
|
68142
|
-
|
|
68193
|
+
};
|
|
68194
|
+
}, {});
|
|
68195
|
+
};
|
|
68196
|
+
var generateWabeTypes = (classes) => {
|
|
68197
|
+
const wabeTypes = classes.reduce((acc, classType) => {
|
|
68198
|
+
const { name, fields } = classType;
|
|
68199
|
+
const objectsToLoad = [];
|
|
68200
|
+
const currentClass = Object.entries(fields).reduce((acc2, [name2, field]) => {
|
|
68201
|
+
const type = wabeTypesToTypescriptTypes({ field });
|
|
68202
|
+
if (field.type === "Object" || field.type === "Array" && field.typeValue === "Object") {
|
|
68203
|
+
const wabeObject = generateWabeObject(field.object);
|
|
68204
|
+
objectsToLoad.push(wabeObject);
|
|
68143
68205
|
}
|
|
68144
|
-
|
|
68145
|
-
|
|
68146
|
-
${
|
|
68206
|
+
return {
|
|
68207
|
+
...acc2,
|
|
68208
|
+
[`${name2}${field.required ? "" : "undefined"}`]: type
|
|
68209
|
+
};
|
|
68210
|
+
}, {});
|
|
68211
|
+
const objects = objectsToLoad.reduce((acc2, object) => {
|
|
68212
|
+
return {
|
|
68213
|
+
...acc2,
|
|
68214
|
+
...object
|
|
68215
|
+
};
|
|
68216
|
+
}, {});
|
|
68217
|
+
return {
|
|
68218
|
+
...acc,
|
|
68219
|
+
...objects,
|
|
68220
|
+
[name]: { id: "string", ...currentClass }
|
|
68221
|
+
};
|
|
68222
|
+
}, {});
|
|
68223
|
+
return wabeTypes;
|
|
68224
|
+
};
|
|
68225
|
+
var generateWabeEnumTypes = (enums) => {
|
|
68226
|
+
return Object.values(enums).reduce((acc, { name, values }) => {
|
|
68227
|
+
return {
|
|
68228
|
+
...acc,
|
|
68229
|
+
[name]: values
|
|
68230
|
+
};
|
|
68231
|
+
}, {});
|
|
68232
|
+
};
|
|
68233
|
+
var generateWabeScalarTypes = (scalars) => {
|
|
68234
|
+
return Object.values(scalars).reduce((acc, { name }) => {
|
|
68235
|
+
return {
|
|
68236
|
+
...acc,
|
|
68237
|
+
[name]: "string"
|
|
68238
|
+
};
|
|
68239
|
+
}, {});
|
|
68240
|
+
};
|
|
68241
|
+
var generateWabeMutationOrQueryInput = (mutationOrQueryName, resolver, isMutation) => {
|
|
68242
|
+
const objectsToLoad = [];
|
|
68243
|
+
const mutationNameWithFirstLetterUpperCase = firstLetterUpperCase(mutationOrQueryName);
|
|
68244
|
+
const mutationObject = Object.entries((isMutation ? resolver.args?.input : resolver.args) || {}).reduce((acc, [name, field]) => {
|
|
68245
|
+
let type = wabeTypesToTypescriptTypes({ field, isInput: true });
|
|
68246
|
+
if (field.type === "Object") {
|
|
68247
|
+
type = firstLetterInUpperCase(name);
|
|
68248
|
+
const wabeObject = generateWabeObject({
|
|
68249
|
+
...field.object,
|
|
68250
|
+
name: type
|
|
68251
|
+
}, mutationNameWithFirstLetterUpperCase);
|
|
68252
|
+
objectsToLoad.push(wabeObject);
|
|
68253
|
+
return {
|
|
68254
|
+
...acc,
|
|
68255
|
+
[`${name}${field.required ? "" : "undefined"}`]: `${mutationNameWithFirstLetterUpperCase}${type}`
|
|
68256
|
+
};
|
|
68257
|
+
}
|
|
68258
|
+
return {
|
|
68259
|
+
...acc,
|
|
68260
|
+
[`${name}${field.required ? "" : "undefined"}`]: type
|
|
68261
|
+
};
|
|
68262
|
+
}, {});
|
|
68263
|
+
const objects = objectsToLoad.reduce((acc2, object) => {
|
|
68264
|
+
return {
|
|
68265
|
+
...acc2,
|
|
68266
|
+
...object
|
|
68267
|
+
};
|
|
68268
|
+
}, {});
|
|
68269
|
+
return {
|
|
68270
|
+
...isMutation ? {
|
|
68271
|
+
[`${firstLetterInUpperCase(mutationOrQueryName)}Input`]: mutationObject
|
|
68272
|
+
} : {},
|
|
68273
|
+
[`${isMutation ? "Mutation" : "Query"}${firstLetterInUpperCase(mutationOrQueryName)}Args`]: isMutation ? {
|
|
68274
|
+
input: `${firstLetterInUpperCase(mutationOrQueryName)}Input`
|
|
68275
|
+
} : mutationObject,
|
|
68276
|
+
...objects
|
|
68277
|
+
};
|
|
68278
|
+
};
|
|
68279
|
+
var generateWabeMutationsAndQueriesTypes = (resolver) => {
|
|
68280
|
+
const mutationsObject = Object.entries(resolver.mutations || {}).reduce((acc, [mutationName, mutation]) => {
|
|
68281
|
+
return {
|
|
68282
|
+
...acc,
|
|
68283
|
+
...generateWabeMutationOrQueryInput(mutationName, mutation, true)
|
|
68284
|
+
};
|
|
68285
|
+
}, {});
|
|
68286
|
+
const queriesObject = Object.entries(resolver.queries || {}).reduce((acc, [queryName, query]) => {
|
|
68287
|
+
return {
|
|
68288
|
+
...acc,
|
|
68289
|
+
...generateWabeMutationOrQueryInput(queryName, query, false)
|
|
68290
|
+
};
|
|
68291
|
+
}, {});
|
|
68292
|
+
return {
|
|
68293
|
+
...mutationsObject,
|
|
68294
|
+
...queriesObject
|
|
68295
|
+
};
|
|
68296
|
+
};
|
|
68297
|
+
var wabeClassRecordToString = (wabeClass) => {
|
|
68298
|
+
return Object.entries(wabeClass).reduce((acc, [className, fields]) => {
|
|
68299
|
+
return `${acc}export type ${className} = {
|
|
68300
|
+
${Object.entries(fields).map(([fieldName, fieldType]) => ` ${fieldName.replace("undefined", "?")}: ${fieldType}`).join(`,
|
|
68301
|
+
`)}
|
|
68302
|
+
}
|
|
68303
|
+
|
|
68147
68304
|
`;
|
|
68148
|
-
|
|
68149
|
-
|
|
68150
|
-
|
|
68151
|
-
|
|
68152
|
-
|
|
68153
|
-
|
|
68154
|
-
|
|
68155
|
-
${values}
|
|
68305
|
+
}, "");
|
|
68306
|
+
};
|
|
68307
|
+
var wabeEnumRecordToString = (wabeEnum) => {
|
|
68308
|
+
return Object.entries(wabeEnum).reduce((acc, [enumName, values]) => {
|
|
68309
|
+
return `${acc}export enum ${enumName} {
|
|
68310
|
+
${Object.entries(values).map(([valueName, value]) => ` ${valueName} = "${value}"`).join(`,
|
|
68311
|
+
`)}
|
|
68156
68312
|
}
|
|
68313
|
+
|
|
68157
68314
|
`;
|
|
68158
|
-
|
|
68159
|
-
});
|
|
68160
|
-
return typescriptCode;
|
|
68315
|
+
}, "");
|
|
68161
68316
|
};
|
|
68162
|
-
var
|
|
68163
|
-
|
|
68164
|
-
|
|
68165
|
-
|
|
68166
|
-
|
|
68167
|
-
|
|
68168
|
-
return `Scalars['${typeName}']['${isInputField ? "input" : "output"}']`;
|
|
68169
|
-
return typeName;
|
|
68170
|
-
};
|
|
68171
|
-
switch (typeNode.kind) {
|
|
68172
|
-
case "NamedType":
|
|
68173
|
-
return getNamedType(typeNode);
|
|
68174
|
-
case "NonNullType":
|
|
68175
|
-
return getFieldType(typeNode.type, isInputField);
|
|
68176
|
-
case "ListType":
|
|
68177
|
-
return `${getFieldType(typeNode.type, isInputField)}[]`;
|
|
68178
|
-
default:
|
|
68179
|
-
return "any";
|
|
68180
|
-
}
|
|
68317
|
+
var wabeScalarRecordToString = (wabeScalar) => {
|
|
68318
|
+
return Object.entries(wabeScalar).reduce((acc, [scalarName, scalarType]) => {
|
|
68319
|
+
return `${acc}export type ${scalarName} = ${scalarType}
|
|
68320
|
+
|
|
68321
|
+
`;
|
|
68322
|
+
}, "");
|
|
68181
68323
|
};
|
|
68182
|
-
var
|
|
68324
|
+
var generateWabeDevTypes = ({
|
|
68183
68325
|
scalars,
|
|
68184
68326
|
enums,
|
|
68185
68327
|
classes
|
|
@@ -68204,27 +68346,32 @@ ${globalWabeTypeString}`;
|
|
|
68204
68346
|
};
|
|
68205
68347
|
var generateCodegen = async ({
|
|
68206
68348
|
schema,
|
|
68207
|
-
path,
|
|
68349
|
+
path: path2,
|
|
68208
68350
|
graphqlSchema
|
|
68209
68351
|
}) => {
|
|
68210
68352
|
const graphqlSchemaContent = import_graphql6.printSchema(graphqlSchema);
|
|
68211
|
-
const
|
|
68212
|
-
const
|
|
68353
|
+
const wabeClasses = generateWabeTypes(schema.classes || []);
|
|
68354
|
+
const mutationsAndQueries = generateWabeMutationsAndQueriesTypes(schema.resolvers || {});
|
|
68355
|
+
const wabeEnumsInString = wabeEnumRecordToString(generateWabeEnumTypes(schema.enums || []));
|
|
68356
|
+
const wabeScalarsInString = wabeScalarRecordToString(generateWabeScalarTypes(schema.scalars || []));
|
|
68357
|
+
const wabeObjectsInString = wabeClassRecordToString({
|
|
68358
|
+
...wabeClasses,
|
|
68359
|
+
...mutationsAndQueries
|
|
68360
|
+
});
|
|
68361
|
+
const wabeDevTypes = generateWabeDevTypes({
|
|
68213
68362
|
scalars: schema.scalars,
|
|
68214
68363
|
enums: schema.enums,
|
|
68215
68364
|
classes: schema.classes || []
|
|
68216
68365
|
});
|
|
68217
|
-
const wabeTsContent = `${
|
|
68218
|
-
|
|
68219
|
-
${wabeOutput}`;
|
|
68366
|
+
const wabeTsContent = `${wabeEnumsInString}${wabeScalarsInString}${wabeObjectsInString}${wabeDevTypes}`;
|
|
68220
68367
|
try {
|
|
68221
|
-
const contentOfGraphqlSchema = (await readFile(`${
|
|
68368
|
+
const contentOfGraphqlSchema = (await readFile(`${path2}/schema.graphql`)).toString();
|
|
68222
68369
|
if (!process.env.CODEGEN && contentOfGraphqlSchema === graphqlSchemaContent.toString())
|
|
68223
68370
|
return;
|
|
68224
68371
|
} catch {
|
|
68225
68372
|
}
|
|
68226
|
-
await writeFile2(`${
|
|
68227
|
-
await writeFile2(`${
|
|
68373
|
+
await writeFile2(`${path2}/wabe.ts`, wabeTsContent);
|
|
68374
|
+
await writeFile2(`${path2}/schema.graphql`, graphqlSchemaContent);
|
|
68228
68375
|
};
|
|
68229
68376
|
|
|
68230
68377
|
// src/authentication/providers/EmailPassword.ts
|
|
@@ -68244,7 +68391,7 @@ class EmailPassword {
|
|
|
68244
68391
|
}
|
|
68245
68392
|
},
|
|
68246
68393
|
context: contextWithRoot(context),
|
|
68247
|
-
|
|
68394
|
+
select: { id: true, authentication: true },
|
|
68248
68395
|
first: 1
|
|
68249
68396
|
});
|
|
68250
68397
|
if (users.length === 0)
|
|
@@ -68299,7 +68446,7 @@ class EmailPassword {
|
|
|
68299
68446
|
}
|
|
68300
68447
|
},
|
|
68301
68448
|
context,
|
|
68302
|
-
|
|
68449
|
+
select: { authentication: true }
|
|
68303
68450
|
});
|
|
68304
68451
|
if (users.length === 0)
|
|
68305
68452
|
throw new Error("User not found");
|
|
@@ -68336,7 +68483,7 @@ class Google3 {
|
|
|
68336
68483
|
},
|
|
68337
68484
|
context: contextWithRoot(context),
|
|
68338
68485
|
first: 1,
|
|
68339
|
-
|
|
68486
|
+
select: { id: true }
|
|
68340
68487
|
});
|
|
68341
68488
|
const authenticationDataToSave = {
|
|
68342
68489
|
email,
|
|
@@ -68352,8 +68499,7 @@ class Google3 {
|
|
|
68352
68499
|
google: authenticationDataToSave
|
|
68353
68500
|
}
|
|
68354
68501
|
},
|
|
68355
|
-
context: contextWithRoot(context)
|
|
68356
|
-
fields: ["*", "id"]
|
|
68502
|
+
context: contextWithRoot(context)
|
|
68357
68503
|
});
|
|
68358
68504
|
if (!createdUser)
|
|
68359
68505
|
throw new Error("User not found");
|
|
@@ -68396,7 +68542,7 @@ class GitHub2 {
|
|
|
68396
68542
|
},
|
|
68397
68543
|
context: contextWithRoot(context),
|
|
68398
68544
|
first: 1,
|
|
68399
|
-
|
|
68545
|
+
select: { id: true }
|
|
68400
68546
|
});
|
|
68401
68547
|
const authenticationDataToSave = {
|
|
68402
68548
|
email,
|
|
@@ -68413,8 +68559,7 @@ class GitHub2 {
|
|
|
68413
68559
|
github: authenticationDataToSave
|
|
68414
68560
|
}
|
|
68415
68561
|
},
|
|
68416
|
-
context: contextWithRoot(context)
|
|
68417
|
-
fields: ["*", "id"]
|
|
68562
|
+
context: contextWithRoot(context)
|
|
68418
68563
|
});
|
|
68419
68564
|
if (!createdUser)
|
|
68420
68565
|
throw new Error("User not found");
|
|
@@ -68452,7 +68597,7 @@ class PhonePassword {
|
|
|
68452
68597
|
}
|
|
68453
68598
|
},
|
|
68454
68599
|
context: contextWithRoot(context),
|
|
68455
|
-
|
|
68600
|
+
select: { id: true, authentication: true },
|
|
68456
68601
|
first: 1
|
|
68457
68602
|
});
|
|
68458
68603
|
if (users.length === 0)
|
|
@@ -68507,7 +68652,7 @@ class PhonePassword {
|
|
|
68507
68652
|
}
|
|
68508
68653
|
},
|
|
68509
68654
|
context,
|
|
68510
|
-
|
|
68655
|
+
select: { authentication: true }
|
|
68511
68656
|
});
|
|
68512
68657
|
if (users.length === 0)
|
|
68513
68658
|
throw new Error("User not found");
|
|
@@ -68631,8 +68776,8 @@ import { createServer as createHttpsServer } from "https";
|
|
|
68631
68776
|
class RadixTree {
|
|
68632
68777
|
root = { name: "/", children: [] };
|
|
68633
68778
|
isOptimized = false;
|
|
68634
|
-
addRoute(method,
|
|
68635
|
-
const pathParts =
|
|
68779
|
+
addRoute(method, path2, handler) {
|
|
68780
|
+
const pathParts = path2.split("/").filter(Boolean);
|
|
68636
68781
|
let currentNode = this.root;
|
|
68637
68782
|
for (let i = 0;i < pathParts.length; i++) {
|
|
68638
68783
|
const pathPart = pathParts[i];
|
|
@@ -68640,7 +68785,7 @@ class RadixTree {
|
|
|
68640
68785
|
const isWildcardNode = pathPart[0] === "*";
|
|
68641
68786
|
let foundNode = currentNode.children.find((node) => node.name === (i === 0 ? "" : "/") + pathPart && (node.method === method || !node.method));
|
|
68642
68787
|
if (foundNode && foundNode.method === method && i === pathParts.length - 1)
|
|
68643
|
-
throw new Error(`Route ${method} ${
|
|
68788
|
+
throw new Error(`Route ${method} ${path2} already exists`);
|
|
68644
68789
|
if (!foundNode) {
|
|
68645
68790
|
foundNode = {
|
|
68646
68791
|
name: (i === 0 ? "" : "/") + pathPart,
|
|
@@ -68682,11 +68827,11 @@ class RadixTree {
|
|
|
68682
68827
|
break;
|
|
68683
68828
|
}
|
|
68684
68829
|
}
|
|
68685
|
-
addHook(hook,
|
|
68830
|
+
addHook(hook, path2, handler, method, node) {
|
|
68686
68831
|
if (this.isOptimized)
|
|
68687
68832
|
throw new Error("Cannot add hooks after the tree has been optimized");
|
|
68688
68833
|
let currentNode = node || this.root;
|
|
68689
|
-
if (
|
|
68834
|
+
if (path2 === "*") {
|
|
68690
68835
|
const addHookToChildren = (node2) => {
|
|
68691
68836
|
for (let i = 0;i < node2.children.length; i++) {
|
|
68692
68837
|
const child = node2.children[i];
|
|
@@ -68705,7 +68850,7 @@ class RadixTree {
|
|
|
68705
68850
|
}
|
|
68706
68851
|
return;
|
|
68707
68852
|
}
|
|
68708
|
-
const pathParts =
|
|
68853
|
+
const pathParts = path2.split("/").filter(Boolean);
|
|
68709
68854
|
for (let i = 0;i < pathParts.length; i++) {
|
|
68710
68855
|
const pathPart = pathParts[i];
|
|
68711
68856
|
const isWildcardNode = pathPart[0] === "*";
|
|
@@ -68724,10 +68869,10 @@ class RadixTree {
|
|
|
68724
68869
|
}
|
|
68725
68870
|
this._addHookToNode(currentNode, hook, handler);
|
|
68726
68871
|
}
|
|
68727
|
-
findRoute(method,
|
|
68728
|
-
let localPath =
|
|
68729
|
-
if (
|
|
68730
|
-
localPath = "/" +
|
|
68872
|
+
findRoute(method, path2) {
|
|
68873
|
+
let localPath = path2;
|
|
68874
|
+
if (path2[0] !== "/")
|
|
68875
|
+
localPath = "/" + path2;
|
|
68731
68876
|
const { length: pathLength } = localPath;
|
|
68732
68877
|
if (pathLength === 1 && localPath === "/")
|
|
68733
68878
|
return this.root;
|
|
@@ -68815,7 +68960,7 @@ class WobeResponse {
|
|
|
68815
68960
|
if (options) {
|
|
68816
68961
|
const {
|
|
68817
68962
|
httpOnly,
|
|
68818
|
-
path,
|
|
68963
|
+
path: path2,
|
|
68819
68964
|
domain,
|
|
68820
68965
|
expires,
|
|
68821
68966
|
sameSite,
|
|
@@ -68824,8 +68969,8 @@ class WobeResponse {
|
|
|
68824
68969
|
} = options;
|
|
68825
68970
|
if (httpOnly)
|
|
68826
68971
|
cookie = `${cookie} HttpOnly;`;
|
|
68827
|
-
if (
|
|
68828
|
-
cookie = `${cookie} Path=${
|
|
68972
|
+
if (path2)
|
|
68973
|
+
cookie = `${cookie} Path=${path2};`;
|
|
68829
68974
|
if (domain)
|
|
68830
68975
|
cookie = `${cookie} Domain=${domain};`;
|
|
68831
68976
|
if (expires)
|
|
@@ -68907,7 +69052,7 @@ var extractPathnameAndSearchParams = (url) => {
|
|
|
68907
69052
|
const queryIndex = url.indexOf("?", 8);
|
|
68908
69053
|
const urlLength = url.length;
|
|
68909
69054
|
const isQueryContainsSearchParams = queryIndex !== -1;
|
|
68910
|
-
const
|
|
69055
|
+
const path2 = url.slice(url.indexOf("/", 8), !isQueryContainsSearchParams ? urlLength : queryIndex);
|
|
68911
69056
|
if (isQueryContainsSearchParams) {
|
|
68912
69057
|
const searchParams = {};
|
|
68913
69058
|
let indexOfLastParam = queryIndex + 1;
|
|
@@ -68923,9 +69068,9 @@ var extractPathnameAndSearchParams = (url) => {
|
|
|
68923
69068
|
indexOfLastParam = i + 1;
|
|
68924
69069
|
}
|
|
68925
69070
|
}
|
|
68926
|
-
return { pathName:
|
|
69071
|
+
return { pathName: path2, searchParams };
|
|
68927
69072
|
}
|
|
68928
|
-
return { pathName:
|
|
69073
|
+
return { pathName: path2 };
|
|
68929
69074
|
};
|
|
68930
69075
|
|
|
68931
69076
|
class Context {
|
|
@@ -69134,53 +69279,53 @@ class Wobe {
|
|
|
69134
69279
|
this.server = null;
|
|
69135
69280
|
this.router = new RadixTree;
|
|
69136
69281
|
}
|
|
69137
|
-
get(
|
|
69282
|
+
get(path2, handler, hook) {
|
|
69138
69283
|
if (hook)
|
|
69139
|
-
this._addHook("beforeHandler", "GET")(
|
|
69140
|
-
this.router.addRoute("GET",
|
|
69284
|
+
this._addHook("beforeHandler", "GET")(path2, hook);
|
|
69285
|
+
this.router.addRoute("GET", path2, handler);
|
|
69141
69286
|
return this;
|
|
69142
69287
|
}
|
|
69143
|
-
post(
|
|
69288
|
+
post(path2, handler, hook) {
|
|
69144
69289
|
if (hook)
|
|
69145
|
-
this._addHook("beforeHandler", "POST")(
|
|
69146
|
-
this.router.addRoute("POST",
|
|
69290
|
+
this._addHook("beforeHandler", "POST")(path2, hook);
|
|
69291
|
+
this.router.addRoute("POST", path2, handler);
|
|
69147
69292
|
return this;
|
|
69148
69293
|
}
|
|
69149
|
-
put(
|
|
69294
|
+
put(path2, handler, hook) {
|
|
69150
69295
|
if (hook)
|
|
69151
|
-
this._addHook("beforeHandler", "PUT")(
|
|
69152
|
-
this.router.addRoute("PUT",
|
|
69296
|
+
this._addHook("beforeHandler", "PUT")(path2, hook);
|
|
69297
|
+
this.router.addRoute("PUT", path2, handler);
|
|
69153
69298
|
return this;
|
|
69154
69299
|
}
|
|
69155
|
-
delete(
|
|
69300
|
+
delete(path2, handler, hook) {
|
|
69156
69301
|
if (hook)
|
|
69157
|
-
this._addHook("beforeHandler", "DELETE")(
|
|
69158
|
-
this.router.addRoute("DELETE",
|
|
69302
|
+
this._addHook("beforeHandler", "DELETE")(path2, hook);
|
|
69303
|
+
this.router.addRoute("DELETE", path2, handler);
|
|
69159
69304
|
return this;
|
|
69160
69305
|
}
|
|
69161
|
-
options(
|
|
69306
|
+
options(path2, handler, hook) {
|
|
69162
69307
|
if (hook)
|
|
69163
|
-
this._addHook("beforeHandler", "OPTIONS")(
|
|
69164
|
-
this.router.addRoute("OPTIONS",
|
|
69308
|
+
this._addHook("beforeHandler", "OPTIONS")(path2, hook);
|
|
69309
|
+
this.router.addRoute("OPTIONS", path2, handler);
|
|
69165
69310
|
return this;
|
|
69166
69311
|
}
|
|
69167
|
-
all(
|
|
69312
|
+
all(path2, handler, hook) {
|
|
69168
69313
|
if (hook) {
|
|
69169
|
-
this.httpMethods.map((method) => this._addHook("beforeHandler", method)(
|
|
69314
|
+
this.httpMethods.map((method) => this._addHook("beforeHandler", method)(path2, hook));
|
|
69170
69315
|
}
|
|
69171
|
-
this.router.addRoute("ALL",
|
|
69316
|
+
this.router.addRoute("ALL", path2, handler);
|
|
69172
69317
|
return this;
|
|
69173
69318
|
}
|
|
69174
69319
|
_addHook = (hook, method) => (arg1, ...handlers) => {
|
|
69175
|
-
let
|
|
69320
|
+
let path2 = arg1;
|
|
69176
69321
|
if (typeof arg1 !== "string") {
|
|
69177
|
-
|
|
69322
|
+
path2 = "*";
|
|
69178
69323
|
handlers.unshift(arg1);
|
|
69179
69324
|
}
|
|
69180
69325
|
handlers.map((handler) => {
|
|
69181
|
-
if (typeof
|
|
69326
|
+
if (typeof path2 === "string")
|
|
69182
69327
|
this.hooks.push({
|
|
69183
|
-
pathname:
|
|
69328
|
+
pathname: path2,
|
|
69184
69329
|
handler,
|
|
69185
69330
|
hook,
|
|
69186
69331
|
method
|
|
@@ -70320,11 +70465,11 @@ function pushComment(node, entity, field, argument) {
|
|
|
70320
70465
|
keys.push(argument);
|
|
70321
70466
|
}
|
|
70322
70467
|
}
|
|
70323
|
-
const
|
|
70324
|
-
if (!commentsRegistry[
|
|
70325
|
-
commentsRegistry[
|
|
70468
|
+
const path2 = keys.join(".");
|
|
70469
|
+
if (!commentsRegistry[path2]) {
|
|
70470
|
+
commentsRegistry[path2] = [];
|
|
70326
70471
|
}
|
|
70327
|
-
commentsRegistry[
|
|
70472
|
+
commentsRegistry[path2].push(comment);
|
|
70328
70473
|
}
|
|
70329
70474
|
function printComment(comment) {
|
|
70330
70475
|
return `
|
|
@@ -70339,9 +70484,9 @@ function hasMultilineItems(maybeArray) {
|
|
|
70339
70484
|
`)) ?? false;
|
|
70340
70485
|
}
|
|
70341
70486
|
function addDescription(cb) {
|
|
70342
|
-
return (node, _key, _parent,
|
|
70487
|
+
return (node, _key, _parent, path2, ancestors) => {
|
|
70343
70488
|
const keys = [];
|
|
70344
|
-
const parent =
|
|
70489
|
+
const parent = path2.reduce((prev, key2) => {
|
|
70345
70490
|
if (["fields", "arguments", "values"].includes(key2) && prev.name) {
|
|
70346
70491
|
keys.push(prev.name.value);
|
|
70347
70492
|
}
|
|
@@ -70352,7 +70497,7 @@ function addDescription(cb) {
|
|
|
70352
70497
|
if (node.kind.includes("Definition") && commentsRegistry[key]) {
|
|
70353
70498
|
items.push(...commentsRegistry[key]);
|
|
70354
70499
|
}
|
|
70355
|
-
return join([...items.map(printComment), node.description, cb(node, _key, _parent,
|
|
70500
|
+
return join([...items.map(printComment), node.description, cb(node, _key, _parent, path2, ancestors)], `
|
|
70356
70501
|
`);
|
|
70357
70502
|
};
|
|
70358
70503
|
}
|
|
@@ -71781,17 +71926,17 @@ function isDocumentNode(object) {
|
|
|
71781
71926
|
function addPath(prev, key, typename) {
|
|
71782
71927
|
return { prev, key, typename };
|
|
71783
71928
|
}
|
|
71784
|
-
function pathToArray(
|
|
71929
|
+
function pathToArray(path2) {
|
|
71785
71930
|
const flattened = [];
|
|
71786
|
-
let curr =
|
|
71931
|
+
let curr = path2;
|
|
71787
71932
|
while (curr) {
|
|
71788
71933
|
flattened.push(curr.key);
|
|
71789
71934
|
curr = curr.prev;
|
|
71790
71935
|
}
|
|
71791
71936
|
return flattened.reverse();
|
|
71792
71937
|
}
|
|
71793
|
-
function printPathArray(
|
|
71794
|
-
return
|
|
71938
|
+
function printPathArray(path2) {
|
|
71939
|
+
return path2.map((key) => typeof key === "number" ? "[" + key.toString() + "]" : "." + key).join("");
|
|
71795
71940
|
}
|
|
71796
71941
|
// ../../node_modules/graphql-yoga/esm/error.js
|
|
71797
71942
|
function isAggregateError(obj) {
|
|
@@ -73302,7 +73447,7 @@ function throwEngineFunctionError(name) {
|
|
|
73302
73447
|
function createEnvelopOrchestrator({ plugins }) {
|
|
73303
73448
|
let schema = null;
|
|
73304
73449
|
let initDone = false;
|
|
73305
|
-
const
|
|
73450
|
+
const parse4 = () => throwEngineFunctionError("parse");
|
|
73306
73451
|
const validate = () => throwEngineFunctionError("validate");
|
|
73307
73452
|
const execute = () => throwEngineFunctionError("execute");
|
|
73308
73453
|
const subscribe = () => throwEngineFunctionError("subscribe");
|
|
@@ -73367,7 +73512,7 @@ function createEnvelopOrchestrator({ plugins }) {
|
|
|
73367
73512
|
};
|
|
73368
73513
|
const customParse = beforeCallbacks.parse.length ? (initialContext) => (source, parseOptions) => {
|
|
73369
73514
|
let result2 = null;
|
|
73370
|
-
let parseFn =
|
|
73515
|
+
let parseFn = parse4;
|
|
73371
73516
|
const context = initialContext;
|
|
73372
73517
|
const afterCalls = [];
|
|
73373
73518
|
for (const onParse of beforeCallbacks.parse) {
|
|
@@ -73414,7 +73559,7 @@ function createEnvelopOrchestrator({ plugins }) {
|
|
|
73414
73559
|
}
|
|
73415
73560
|
documentStringMap.set(result2, source.toString());
|
|
73416
73561
|
return result2;
|
|
73417
|
-
} : () =>
|
|
73562
|
+
} : () => parse4;
|
|
73418
73563
|
const customValidate = beforeCallbacks.validate.length ? (initialContext) => (schema2, documentAST, rules, typeInfo, validationOptions) => {
|
|
73419
73564
|
let actualRules = rules ? [...rules] : undefined;
|
|
73420
73565
|
let validateFn = validate;
|
|
@@ -74019,10 +74164,10 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
74019
74164
|
}));
|
|
74020
74165
|
continue;
|
|
74021
74166
|
}
|
|
74022
|
-
coercedValues[varName] = import_graphql42.coerceInputValue(value, varType, (
|
|
74167
|
+
coercedValues[varName] = import_graphql42.coerceInputValue(value, varType, (path2, invalidValue, error) => {
|
|
74023
74168
|
let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
|
|
74024
|
-
if (
|
|
74025
|
-
prefix += ` at "${varName}${printPathArray(
|
|
74169
|
+
if (path2.length > 0) {
|
|
74170
|
+
prefix += ` at "${varName}${printPathArray(path2)}"`;
|
|
74026
74171
|
}
|
|
74027
74172
|
onError(createGraphQLError(prefix + "; " + error.message, {
|
|
74028
74173
|
nodes: varDefNode,
|
|
@@ -74163,22 +74308,22 @@ function executeOperation(exeContext) {
|
|
|
74163
74308
|
});
|
|
74164
74309
|
}
|
|
74165
74310
|
const { fields: rootFields, patches } = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet);
|
|
74166
|
-
const
|
|
74311
|
+
const path2 = undefined;
|
|
74167
74312
|
let result2;
|
|
74168
74313
|
if (operation.operation === "mutation") {
|
|
74169
|
-
result2 = executeFieldsSerially(exeContext, rootType, rootValue,
|
|
74314
|
+
result2 = executeFieldsSerially(exeContext, rootType, rootValue, path2, rootFields);
|
|
74170
74315
|
} else {
|
|
74171
|
-
result2 = executeFields(exeContext, rootType, rootValue,
|
|
74316
|
+
result2 = executeFields(exeContext, rootType, rootValue, path2, rootFields);
|
|
74172
74317
|
}
|
|
74173
74318
|
for (const patch of patches) {
|
|
74174
74319
|
const { label, fields: patchFields } = patch;
|
|
74175
|
-
executeDeferredFragment(exeContext, rootType, rootValue, patchFields, label,
|
|
74320
|
+
executeDeferredFragment(exeContext, rootType, rootValue, patchFields, label, path2);
|
|
74176
74321
|
}
|
|
74177
74322
|
return result2;
|
|
74178
74323
|
}
|
|
74179
|
-
function executeFieldsSerially(exeContext, parentType, sourceValue,
|
|
74324
|
+
function executeFieldsSerially(exeContext, parentType, sourceValue, path2, fields2) {
|
|
74180
74325
|
return promiseReduce(fields2, (results, [responseName, fieldNodes]) => {
|
|
74181
|
-
const fieldPath = addPath(
|
|
74326
|
+
const fieldPath = addPath(path2, responseName, parentType.name);
|
|
74182
74327
|
if (exeContext.signal?.aborted) {
|
|
74183
74328
|
throw exeContext.signal.reason;
|
|
74184
74329
|
}
|
|
@@ -74191,7 +74336,7 @@ function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields
|
|
|
74191
74336
|
});
|
|
74192
74337
|
}, Object.create(null)).resolve();
|
|
74193
74338
|
}
|
|
74194
|
-
function executeFields(exeContext, parentType, sourceValue,
|
|
74339
|
+
function executeFields(exeContext, parentType, sourceValue, path2, fields2, asyncPayloadRecord) {
|
|
74195
74340
|
const results = Object.create(null);
|
|
74196
74341
|
let containsPromise = false;
|
|
74197
74342
|
try {
|
|
@@ -74199,7 +74344,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields2, async
|
|
|
74199
74344
|
if (exeContext.signal?.aborted) {
|
|
74200
74345
|
throw exeContext.signal.reason;
|
|
74201
74346
|
}
|
|
74202
|
-
const fieldPath = addPath(
|
|
74347
|
+
const fieldPath = addPath(path2, responseName, parentType.name);
|
|
74203
74348
|
const result2 = executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath, asyncPayloadRecord);
|
|
74204
74349
|
if (result2 !== undefined) {
|
|
74205
74350
|
results[responseName] = result2;
|
|
@@ -74221,7 +74366,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields2, async
|
|
|
74221
74366
|
}
|
|
74222
74367
|
return promiseForObject(results, exeContext.signal);
|
|
74223
74368
|
}
|
|
74224
|
-
function executeField(exeContext, parentType, source, fieldNodes,
|
|
74369
|
+
function executeField(exeContext, parentType, source, fieldNodes, path2, asyncPayloadRecord) {
|
|
74225
74370
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74226
74371
|
const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]);
|
|
74227
74372
|
if (!fieldDef) {
|
|
@@ -74229,32 +74374,32 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
74229
74374
|
}
|
|
74230
74375
|
const returnType = fieldDef.type;
|
|
74231
74376
|
const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
|
|
74232
|
-
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType,
|
|
74377
|
+
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path2);
|
|
74233
74378
|
try {
|
|
74234
74379
|
const args = getArgumentValues(fieldDef, fieldNodes[0], exeContext.variableValues);
|
|
74235
74380
|
const contextValue = exeContext.contextValue;
|
|
74236
74381
|
const result2 = resolveFn(source, args, contextValue, info);
|
|
74237
74382
|
let completed;
|
|
74238
74383
|
if (isPromise(result2)) {
|
|
74239
|
-
completed = result2.then((resolved) => completeValue(exeContext, returnType, fieldNodes, info,
|
|
74384
|
+
completed = result2.then((resolved) => completeValue(exeContext, returnType, fieldNodes, info, path2, resolved, asyncPayloadRecord));
|
|
74240
74385
|
} else {
|
|
74241
|
-
completed = completeValue(exeContext, returnType, fieldNodes, info,
|
|
74386
|
+
completed = completeValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74242
74387
|
}
|
|
74243
74388
|
if (isPromise(completed)) {
|
|
74244
74389
|
return completed.then(undefined, (rawError) => {
|
|
74245
74390
|
if (rawError instanceof AggregateError) {
|
|
74246
74391
|
return new AggregateError(rawError.errors.map((rawErrorItem) => {
|
|
74247
74392
|
rawErrorItem = coerceError(rawErrorItem);
|
|
74248
|
-
const error2 = import_graphql43.locatedError(rawErrorItem, fieldNodes, pathToArray(
|
|
74393
|
+
const error2 = import_graphql43.locatedError(rawErrorItem, fieldNodes, pathToArray(path2));
|
|
74249
74394
|
const handledError2 = handleFieldError(error2, returnType, errors2);
|
|
74250
|
-
filterSubsequentPayloads(exeContext,
|
|
74395
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74251
74396
|
return handledError2;
|
|
74252
74397
|
}));
|
|
74253
74398
|
}
|
|
74254
74399
|
rawError = coerceError(rawError);
|
|
74255
|
-
const error = import_graphql43.locatedError(rawError, fieldNodes, pathToArray(
|
|
74400
|
+
const error = import_graphql43.locatedError(rawError, fieldNodes, pathToArray(path2));
|
|
74256
74401
|
const handledError = handleFieldError(error, returnType, errors2);
|
|
74257
|
-
filterSubsequentPayloads(exeContext,
|
|
74402
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74258
74403
|
return handledError;
|
|
74259
74404
|
});
|
|
74260
74405
|
}
|
|
@@ -74263,24 +74408,24 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
74263
74408
|
if (rawError instanceof AggregateError) {
|
|
74264
74409
|
return new AggregateError(rawError.errors.map((rawErrorItem) => {
|
|
74265
74410
|
const coercedError2 = coerceError(rawErrorItem);
|
|
74266
|
-
const error2 = import_graphql43.locatedError(coercedError2, fieldNodes, pathToArray(
|
|
74411
|
+
const error2 = import_graphql43.locatedError(coercedError2, fieldNodes, pathToArray(path2));
|
|
74267
74412
|
return handleFieldError(error2, returnType, errors2);
|
|
74268
74413
|
}));
|
|
74269
74414
|
}
|
|
74270
74415
|
const coercedError = coerceError(rawError);
|
|
74271
|
-
const error = import_graphql43.locatedError(coercedError, fieldNodes, pathToArray(
|
|
74416
|
+
const error = import_graphql43.locatedError(coercedError, fieldNodes, pathToArray(path2));
|
|
74272
74417
|
const handledError = handleFieldError(error, returnType, errors2);
|
|
74273
|
-
filterSubsequentPayloads(exeContext,
|
|
74418
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74274
74419
|
return handledError;
|
|
74275
74420
|
}
|
|
74276
74421
|
}
|
|
74277
|
-
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType,
|
|
74422
|
+
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path2) {
|
|
74278
74423
|
return {
|
|
74279
74424
|
fieldName: fieldDef.name,
|
|
74280
74425
|
fieldNodes,
|
|
74281
74426
|
returnType: fieldDef.type,
|
|
74282
74427
|
parentType,
|
|
74283
|
-
path,
|
|
74428
|
+
path: path2,
|
|
74284
74429
|
schema: exeContext.schema,
|
|
74285
74430
|
fragments: exeContext.fragments,
|
|
74286
74431
|
rootValue: exeContext.rootValue,
|
|
@@ -74299,12 +74444,12 @@ function handleFieldError(error, returnType, errors2) {
|
|
|
74299
74444
|
errors2.push(error);
|
|
74300
74445
|
return null;
|
|
74301
74446
|
}
|
|
74302
|
-
function completeValue(exeContext, returnType, fieldNodes, info,
|
|
74447
|
+
function completeValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74303
74448
|
if (result2 instanceof Error) {
|
|
74304
74449
|
throw result2;
|
|
74305
74450
|
}
|
|
74306
74451
|
if (import_graphql43.isNonNullType(returnType)) {
|
|
74307
|
-
const completed = completeValue(exeContext, returnType.ofType, fieldNodes, info,
|
|
74452
|
+
const completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74308
74453
|
if (completed === null) {
|
|
74309
74454
|
throw new Error(`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`);
|
|
74310
74455
|
}
|
|
@@ -74314,21 +74459,21 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result2,
|
|
|
74314
74459
|
return null;
|
|
74315
74460
|
}
|
|
74316
74461
|
if (import_graphql43.isListType(returnType)) {
|
|
74317
|
-
return completeListValue(exeContext, returnType, fieldNodes, info,
|
|
74462
|
+
return completeListValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74318
74463
|
}
|
|
74319
74464
|
if (import_graphql43.isLeafType(returnType)) {
|
|
74320
74465
|
return completeLeafValue(returnType, result2);
|
|
74321
74466
|
}
|
|
74322
74467
|
if (import_graphql43.isAbstractType(returnType)) {
|
|
74323
|
-
return completeAbstractValue(exeContext, returnType, fieldNodes, info,
|
|
74468
|
+
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74324
74469
|
}
|
|
74325
74470
|
if (import_graphql43.isObjectType(returnType)) {
|
|
74326
|
-
return completeObjectValue(exeContext, returnType, fieldNodes, info,
|
|
74471
|
+
return completeObjectValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74327
74472
|
}
|
|
74328
74473
|
console.assert(false, "Cannot complete value of unexpected output type: " + inspect(returnType));
|
|
74329
74474
|
}
|
|
74330
|
-
function getStreamValues(exeContext, fieldNodes,
|
|
74331
|
-
if (typeof
|
|
74475
|
+
function getStreamValues(exeContext, fieldNodes, path2) {
|
|
74476
|
+
if (typeof path2.key === "number") {
|
|
74332
74477
|
return;
|
|
74333
74478
|
}
|
|
74334
74479
|
const stream = import_graphql43.getDirectiveValues(GraphQLStreamDirective, fieldNodes[0], exeContext.variableValues);
|
|
@@ -74345,21 +74490,21 @@ function getStreamValues(exeContext, fieldNodes, path) {
|
|
|
74345
74490
|
label: typeof stream["label"] === "string" ? stream["label"] : undefined
|
|
74346
74491
|
};
|
|
74347
74492
|
}
|
|
74348
|
-
async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info,
|
|
74493
|
+
async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path2, iterator, asyncPayloadRecord) {
|
|
74349
74494
|
exeContext.signal?.addEventListener("abort", () => {
|
|
74350
74495
|
iterator.return?.();
|
|
74351
74496
|
});
|
|
74352
74497
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74353
|
-
const stream = getStreamValues(exeContext, fieldNodes,
|
|
74498
|
+
const stream = getStreamValues(exeContext, fieldNodes, path2);
|
|
74354
74499
|
let containsPromise = false;
|
|
74355
74500
|
const completedResults = [];
|
|
74356
74501
|
let index = 0;
|
|
74357
74502
|
while (true) {
|
|
74358
74503
|
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
74359
|
-
executeStreamIterator(index, iterator, exeContext, fieldNodes, info, itemType,
|
|
74504
|
+
executeStreamIterator(index, iterator, exeContext, fieldNodes, info, itemType, path2, stream.label, asyncPayloadRecord);
|
|
74360
74505
|
break;
|
|
74361
74506
|
}
|
|
74362
|
-
const itemPath = addPath(
|
|
74507
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74363
74508
|
let iteration;
|
|
74364
74509
|
try {
|
|
74365
74510
|
iteration = await iterator.next();
|
|
@@ -74379,25 +74524,25 @@ async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info
|
|
|
74379
74524
|
}
|
|
74380
74525
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
74381
74526
|
}
|
|
74382
|
-
function completeListValue(exeContext, returnType, fieldNodes, info,
|
|
74527
|
+
function completeListValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74383
74528
|
const itemType = returnType.ofType;
|
|
74384
74529
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74385
74530
|
if (isAsyncIterable(result2)) {
|
|
74386
74531
|
const iterator = result2[Symbol.asyncIterator]();
|
|
74387
|
-
return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info,
|
|
74532
|
+
return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path2, iterator, asyncPayloadRecord);
|
|
74388
74533
|
}
|
|
74389
74534
|
if (!isIterableObject(result2)) {
|
|
74390
74535
|
throw createGraphQLError(`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`);
|
|
74391
74536
|
}
|
|
74392
|
-
const stream = getStreamValues(exeContext, fieldNodes,
|
|
74537
|
+
const stream = getStreamValues(exeContext, fieldNodes, path2);
|
|
74393
74538
|
let containsPromise = false;
|
|
74394
74539
|
let previousAsyncPayloadRecord = asyncPayloadRecord;
|
|
74395
74540
|
const completedResults = [];
|
|
74396
74541
|
let index = 0;
|
|
74397
74542
|
for (const item of result2) {
|
|
74398
|
-
const itemPath = addPath(
|
|
74543
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74399
74544
|
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
74400
|
-
previousAsyncPayloadRecord = executeStreamField(
|
|
74545
|
+
previousAsyncPayloadRecord = executeStreamField(path2, itemPath, item, exeContext, fieldNodes, info, itemType, stream.label, previousAsyncPayloadRecord);
|
|
74401
74546
|
index++;
|
|
74402
74547
|
continue;
|
|
74403
74548
|
}
|
|
@@ -74451,14 +74596,14 @@ function completeLeafValue(returnType, result2) {
|
|
|
74451
74596
|
}
|
|
74452
74597
|
return serializedResult;
|
|
74453
74598
|
}
|
|
74454
|
-
function completeAbstractValue(exeContext, returnType, fieldNodes, info,
|
|
74599
|
+
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74455
74600
|
const resolveTypeFn = returnType.resolveType ?? exeContext.typeResolver;
|
|
74456
74601
|
const contextValue = exeContext.contextValue;
|
|
74457
74602
|
const runtimeType = resolveTypeFn(result2, contextValue, info, returnType);
|
|
74458
74603
|
if (isPromise(runtimeType)) {
|
|
74459
|
-
return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info,
|
|
74604
|
+
return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info, path2, result2, asyncPayloadRecord));
|
|
74460
74605
|
}
|
|
74461
|
-
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info,
|
|
74606
|
+
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74462
74607
|
}
|
|
74463
74608
|
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes, info, result2) {
|
|
74464
74609
|
if (runtimeTypeName == null) {
|
|
@@ -74485,7 +74630,7 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNo
|
|
|
74485
74630
|
}
|
|
74486
74631
|
return runtimeType;
|
|
74487
74632
|
}
|
|
74488
|
-
function completeObjectValue(exeContext, returnType, fieldNodes, info,
|
|
74633
|
+
function completeObjectValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74489
74634
|
if (returnType.isTypeOf) {
|
|
74490
74635
|
const isTypeOf = returnType.isTypeOf(result2, exeContext.contextValue, info);
|
|
74491
74636
|
if (isPromise(isTypeOf)) {
|
|
@@ -74493,26 +74638,26 @@ function completeObjectValue(exeContext, returnType, fieldNodes, info, path, res
|
|
|
74493
74638
|
if (!resolvedIsTypeOf) {
|
|
74494
74639
|
throw invalidReturnTypeError(returnType, result2, fieldNodes);
|
|
74495
74640
|
}
|
|
74496
|
-
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74641
|
+
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord);
|
|
74497
74642
|
});
|
|
74498
74643
|
}
|
|
74499
74644
|
if (!isTypeOf) {
|
|
74500
74645
|
throw invalidReturnTypeError(returnType, result2, fieldNodes);
|
|
74501
74646
|
}
|
|
74502
74647
|
}
|
|
74503
|
-
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74648
|
+
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord);
|
|
74504
74649
|
}
|
|
74505
74650
|
function invalidReturnTypeError(returnType, result2, fieldNodes) {
|
|
74506
74651
|
return createGraphQLError(`Expected value of type "${returnType.name}" but got: ${inspect(result2)}.`, {
|
|
74507
74652
|
nodes: fieldNodes
|
|
74508
74653
|
});
|
|
74509
74654
|
}
|
|
74510
|
-
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74655
|
+
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord) {
|
|
74511
74656
|
const { fields: subFieldNodes, patches: subPatches } = collectSubfields2(exeContext, returnType, fieldNodes);
|
|
74512
|
-
const subFields = executeFields(exeContext, returnType, result2,
|
|
74657
|
+
const subFields = executeFields(exeContext, returnType, result2, path2, subFieldNodes, asyncPayloadRecord);
|
|
74513
74658
|
for (const subPatch of subPatches) {
|
|
74514
74659
|
const { label, fields: subPatchFieldNodes } = subPatch;
|
|
74515
|
-
executeDeferredFragment(exeContext, returnType, result2, subPatchFieldNodes, label,
|
|
74660
|
+
executeDeferredFragment(exeContext, returnType, result2, subPatchFieldNodes, label, path2, asyncPayloadRecord);
|
|
74516
74661
|
}
|
|
74517
74662
|
return subFields;
|
|
74518
74663
|
}
|
|
@@ -74662,8 +74807,8 @@ function executeSubscription(exeContext) {
|
|
|
74662
74807
|
nodes: fieldNodes
|
|
74663
74808
|
});
|
|
74664
74809
|
}
|
|
74665
|
-
const
|
|
74666
|
-
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, rootType,
|
|
74810
|
+
const path2 = addPath(undefined, responseName, rootType.name);
|
|
74811
|
+
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, rootType, path2);
|
|
74667
74812
|
try {
|
|
74668
74813
|
const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues);
|
|
74669
74814
|
const contextValue = exeContext.contextValue;
|
|
@@ -74671,12 +74816,12 @@ function executeSubscription(exeContext) {
|
|
|
74671
74816
|
const result2 = resolveFn(rootValue, args, contextValue, info);
|
|
74672
74817
|
if (isPromise(result2)) {
|
|
74673
74818
|
return result2.then(assertEventStream).then(undefined, (error) => {
|
|
74674
|
-
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(
|
|
74819
|
+
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(path2));
|
|
74675
74820
|
});
|
|
74676
74821
|
}
|
|
74677
74822
|
return assertEventStream(result2, exeContext.signal);
|
|
74678
74823
|
} catch (error) {
|
|
74679
|
-
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(
|
|
74824
|
+
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(path2));
|
|
74680
74825
|
}
|
|
74681
74826
|
}
|
|
74682
74827
|
function assertEventStream(result2, signal) {
|
|
@@ -74696,16 +74841,16 @@ function assertEventStream(result2, signal) {
|
|
|
74696
74841
|
}
|
|
74697
74842
|
};
|
|
74698
74843
|
}
|
|
74699
|
-
function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, label,
|
|
74844
|
+
function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, label, path2, parentContext) {
|
|
74700
74845
|
const asyncPayloadRecord = new DeferredFragmentRecord({
|
|
74701
74846
|
label,
|
|
74702
|
-
path,
|
|
74847
|
+
path: path2,
|
|
74703
74848
|
parentContext,
|
|
74704
74849
|
exeContext
|
|
74705
74850
|
});
|
|
74706
74851
|
let promiseOrData;
|
|
74707
74852
|
try {
|
|
74708
|
-
promiseOrData = executeFields(exeContext, parentType, sourceValue,
|
|
74853
|
+
promiseOrData = executeFields(exeContext, parentType, sourceValue, path2, fields2, asyncPayloadRecord);
|
|
74709
74854
|
if (isPromise(promiseOrData)) {
|
|
74710
74855
|
promiseOrData = promiseOrData.then(null, (e) => {
|
|
74711
74856
|
asyncPayloadRecord.errors.push(e);
|
|
@@ -74718,7 +74863,7 @@ function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, l
|
|
|
74718
74863
|
}
|
|
74719
74864
|
asyncPayloadRecord.addData(promiseOrData);
|
|
74720
74865
|
}
|
|
74721
|
-
function executeStreamField(
|
|
74866
|
+
function executeStreamField(path2, itemPath, item, exeContext, fieldNodes, info, itemType, label, parentContext) {
|
|
74722
74867
|
const asyncPayloadRecord = new StreamRecord({
|
|
74723
74868
|
label,
|
|
74724
74869
|
path: itemPath,
|
|
@@ -74750,7 +74895,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldNodes, info,
|
|
|
74750
74895
|
}
|
|
74751
74896
|
} catch (error) {
|
|
74752
74897
|
asyncPayloadRecord.errors.push(error);
|
|
74753
|
-
filterSubsequentPayloads(exeContext,
|
|
74898
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74754
74899
|
asyncPayloadRecord.addItems(null);
|
|
74755
74900
|
return asyncPayloadRecord;
|
|
74756
74901
|
}
|
|
@@ -74758,7 +74903,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldNodes, info,
|
|
|
74758
74903
|
if (isPromise(completedItem)) {
|
|
74759
74904
|
completedItems = completedItem.then((value) => [value], (error) => {
|
|
74760
74905
|
asyncPayloadRecord.errors.push(error);
|
|
74761
|
-
filterSubsequentPayloads(exeContext,
|
|
74906
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74762
74907
|
return null;
|
|
74763
74908
|
});
|
|
74764
74909
|
} else {
|
|
@@ -74801,11 +74946,11 @@ async function executeStreamIteratorItem(iterator, exeContext, fieldNodes, info,
|
|
|
74801
74946
|
return { done: false, value };
|
|
74802
74947
|
}
|
|
74803
74948
|
}
|
|
74804
|
-
async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType,
|
|
74949
|
+
async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType, path2, label, parentContext) {
|
|
74805
74950
|
let index = initialIndex;
|
|
74806
74951
|
let previousAsyncPayloadRecord = parentContext ?? undefined;
|
|
74807
74952
|
while (true) {
|
|
74808
|
-
const itemPath = addPath(
|
|
74953
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74809
74954
|
const asyncPayloadRecord = new StreamRecord({
|
|
74810
74955
|
label,
|
|
74811
74956
|
path: itemPath,
|
|
@@ -74818,7 +74963,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
|
|
|
74818
74963
|
iteration = await executeStreamIteratorItem(iterator, exeContext, fieldNodes, info, itemType, asyncPayloadRecord, itemPath);
|
|
74819
74964
|
} catch (error) {
|
|
74820
74965
|
asyncPayloadRecord.errors.push(error);
|
|
74821
|
-
filterSubsequentPayloads(exeContext,
|
|
74966
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74822
74967
|
asyncPayloadRecord.addItems(null);
|
|
74823
74968
|
if (iterator?.return) {
|
|
74824
74969
|
iterator.return().catch(() => {
|
|
@@ -74831,7 +74976,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
|
|
|
74831
74976
|
if (isPromise(completedItem)) {
|
|
74832
74977
|
completedItems = completedItem.then((value) => [value], (error) => {
|
|
74833
74978
|
asyncPayloadRecord.errors.push(error);
|
|
74834
|
-
filterSubsequentPayloads(exeContext,
|
|
74979
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74835
74980
|
return null;
|
|
74836
74981
|
});
|
|
74837
74982
|
} else {
|
|
@@ -78605,7 +78750,7 @@ var initializeRoles = async (wabe) => {
|
|
|
78605
78750
|
isRoot: true,
|
|
78606
78751
|
wabe
|
|
78607
78752
|
},
|
|
78608
|
-
|
|
78753
|
+
select: { name: true },
|
|
78609
78754
|
where: {
|
|
78610
78755
|
name: {
|
|
78611
78756
|
in: roles
|
|
@@ -78623,7 +78768,7 @@ var initializeRoles = async (wabe) => {
|
|
|
78623
78768
|
wabe
|
|
78624
78769
|
},
|
|
78625
78770
|
data: objectsToCreate,
|
|
78626
|
-
|
|
78771
|
+
select: {}
|
|
78627
78772
|
});
|
|
78628
78773
|
};
|
|
78629
78774
|
|