wabe 0.6.0 → 0.6.1
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 +180 -275
- package/dist/index.js +620 -508
- package/generated/wabe.ts +239 -1804
- 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,55 @@ class DatabaseController2 {
|
|
|
62443
62406
|
].filter(notEmpty)
|
|
62444
62407
|
};
|
|
62445
62408
|
}
|
|
62409
|
+
async _getFinalObjectWithPointerAndRelation({
|
|
62410
|
+
pointers,
|
|
62411
|
+
context,
|
|
62412
|
+
originClassName,
|
|
62413
|
+
object
|
|
62414
|
+
}) {
|
|
62415
|
+
return Object.entries(pointers).reduce(async (acc, [pointerField, { className: currentClassName, select: currentSelect }]) => {
|
|
62416
|
+
const accObject = await acc;
|
|
62417
|
+
const isPointer = this._isPointerField(originClassName, context, currentClassName);
|
|
62418
|
+
if (isPointer) {
|
|
62419
|
+
if (!object[pointerField]) {
|
|
62420
|
+
return {
|
|
62421
|
+
...accObject,
|
|
62422
|
+
[pointerField]: null
|
|
62423
|
+
};
|
|
62424
|
+
}
|
|
62425
|
+
const objectOfPointerClass = await this.getObject({
|
|
62426
|
+
className: currentClassName,
|
|
62427
|
+
id: object[pointerField],
|
|
62428
|
+
context,
|
|
62429
|
+
select: currentSelect,
|
|
62430
|
+
skipHooks: true
|
|
62431
|
+
});
|
|
62432
|
+
return {
|
|
62433
|
+
...accObject,
|
|
62434
|
+
[pointerField]: objectOfPointerClass
|
|
62435
|
+
};
|
|
62436
|
+
}
|
|
62437
|
+
const isRelation = this._isRelationField(originClassName, context, currentClassName);
|
|
62438
|
+
if (isRelation) {
|
|
62439
|
+
const relationObjects = await this.getObjects({
|
|
62440
|
+
className: currentClassName,
|
|
62441
|
+
select: currentSelect,
|
|
62442
|
+
where: { id: { in: object[pointerField] } },
|
|
62443
|
+
context
|
|
62444
|
+
});
|
|
62445
|
+
return {
|
|
62446
|
+
...acc,
|
|
62447
|
+
[pointerField]: {
|
|
62448
|
+
totalCount: relationObjects.length,
|
|
62449
|
+
edges: relationObjects.map((object2) => ({
|
|
62450
|
+
node: object2
|
|
62451
|
+
}))
|
|
62452
|
+
}
|
|
62453
|
+
};
|
|
62454
|
+
}
|
|
62455
|
+
return accObject;
|
|
62456
|
+
}, Promise.resolve({}));
|
|
62457
|
+
}
|
|
62446
62458
|
connect() {
|
|
62447
62459
|
return this.adapter.connect();
|
|
62448
62460
|
}
|
|
@@ -62459,30 +62471,32 @@ class DatabaseController2 {
|
|
|
62459
62471
|
await this.adapter.clearDatabase();
|
|
62460
62472
|
}
|
|
62461
62473
|
async getObject({
|
|
62462
|
-
|
|
62474
|
+
select,
|
|
62463
62475
|
className,
|
|
62464
62476
|
context,
|
|
62465
62477
|
skipHooks,
|
|
62466
62478
|
id,
|
|
62467
62479
|
where
|
|
62468
62480
|
}) {
|
|
62469
|
-
const
|
|
62470
|
-
|
|
62481
|
+
const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
|
|
62482
|
+
className,
|
|
62483
|
+
context,
|
|
62484
|
+
select
|
|
62485
|
+
});
|
|
62471
62486
|
const hook = !skipHooks ? initializeHook({
|
|
62472
62487
|
className,
|
|
62473
62488
|
context,
|
|
62474
|
-
|
|
62489
|
+
select: selectWithoutPointers
|
|
62475
62490
|
}) : undefined;
|
|
62476
62491
|
await hook?.runOnSingleObject({
|
|
62477
62492
|
operationType: "beforeRead" /* BeforeRead */,
|
|
62478
62493
|
id
|
|
62479
62494
|
});
|
|
62480
62495
|
const whereWithACLCondition = this._buildWhereWithACL(where || {}, context, "read");
|
|
62481
|
-
const
|
|
62482
|
-
|
|
62483
|
-
|
|
62484
|
-
|
|
62485
|
-
];
|
|
62496
|
+
const selectWithPointersAndRelationsToGetId = Object.keys(pointers).reduce((acc, fieldName) => {
|
|
62497
|
+
acc[fieldName] = true;
|
|
62498
|
+
return acc;
|
|
62499
|
+
}, selectWithoutPointers);
|
|
62486
62500
|
await hook?.runOnSingleObject({
|
|
62487
62501
|
operationType: "afterRead" /* AfterRead */,
|
|
62488
62502
|
id
|
|
@@ -62491,15 +62505,23 @@ class DatabaseController2 {
|
|
|
62491
62505
|
className,
|
|
62492
62506
|
id,
|
|
62493
62507
|
context,
|
|
62494
|
-
|
|
62508
|
+
select: !select ? undefined : selectWithPointersAndRelationsToGetId,
|
|
62495
62509
|
where: whereWithACLCondition,
|
|
62496
62510
|
skipHooks: true
|
|
62497
62511
|
});
|
|
62498
|
-
return
|
|
62512
|
+
return {
|
|
62513
|
+
...objectToReturn,
|
|
62514
|
+
...await this._getFinalObjectWithPointerAndRelation({
|
|
62515
|
+
context,
|
|
62516
|
+
originClassName: className,
|
|
62517
|
+
pointers,
|
|
62518
|
+
object: objectToReturn
|
|
62519
|
+
})
|
|
62520
|
+
};
|
|
62499
62521
|
}
|
|
62500
62522
|
async getObjects({
|
|
62501
62523
|
className,
|
|
62502
|
-
|
|
62524
|
+
select,
|
|
62503
62525
|
context,
|
|
62504
62526
|
where,
|
|
62505
62527
|
skipHooks,
|
|
@@ -62507,24 +62529,26 @@ class DatabaseController2 {
|
|
|
62507
62529
|
offset,
|
|
62508
62530
|
order
|
|
62509
62531
|
}) {
|
|
62510
|
-
const
|
|
62511
|
-
|
|
62512
|
-
|
|
62532
|
+
const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
|
|
62533
|
+
className,
|
|
62534
|
+
context,
|
|
62535
|
+
select
|
|
62536
|
+
});
|
|
62513
62537
|
const whereWithPointer = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
62514
|
-
const whereWithACLCondition = this._buildWhereWithACL(whereWithPointer, context, "read");
|
|
62538
|
+
const whereWithACLCondition = this._buildWhereWithACL(whereWithPointer || {}, context, "read");
|
|
62539
|
+
const selectWithPointersAndRelationsToGetId = Object.keys(pointers).reduce((acc, fieldName) => {
|
|
62540
|
+
acc[fieldName] = true;
|
|
62541
|
+
return acc;
|
|
62542
|
+
}, selectWithoutPointers);
|
|
62515
62543
|
const hook = !skipHooks ? initializeHook({
|
|
62516
62544
|
className,
|
|
62517
|
-
|
|
62545
|
+
select: selectWithoutPointers,
|
|
62518
62546
|
context
|
|
62519
62547
|
}) : undefined;
|
|
62520
62548
|
await hook?.runOnMultipleObjects({
|
|
62521
62549
|
operationType: "beforeRead" /* BeforeRead */,
|
|
62522
62550
|
where: whereWithACLCondition
|
|
62523
62551
|
});
|
|
62524
|
-
const fieldsWithPointerFields = [
|
|
62525
|
-
...fieldsWithoutPointers,
|
|
62526
|
-
...pointersFieldsId || []
|
|
62527
|
-
];
|
|
62528
62552
|
await hook?.runOnMultipleObjects({
|
|
62529
62553
|
operationType: "afterRead" /* AfterRead */,
|
|
62530
62554
|
where: whereWithACLCondition
|
|
@@ -62535,23 +62559,31 @@ class DatabaseController2 {
|
|
|
62535
62559
|
first,
|
|
62536
62560
|
offset,
|
|
62537
62561
|
where: whereWithACLCondition,
|
|
62538
|
-
|
|
62562
|
+
select: !select ? undefined : selectWithPointersAndRelationsToGetId,
|
|
62539
62563
|
order,
|
|
62540
62564
|
skipHooks: true
|
|
62541
62565
|
});
|
|
62542
|
-
return Promise.all(objectsToReturn.map((object) =>
|
|
62566
|
+
return Promise.all(objectsToReturn.map(async (object) => ({
|
|
62567
|
+
...object,
|
|
62568
|
+
...await this._getFinalObjectWithPointerAndRelation({
|
|
62569
|
+
object,
|
|
62570
|
+
context,
|
|
62571
|
+
originClassName: className,
|
|
62572
|
+
pointers
|
|
62573
|
+
})
|
|
62574
|
+
})));
|
|
62543
62575
|
}
|
|
62544
62576
|
async createObject({
|
|
62545
62577
|
className,
|
|
62546
62578
|
context,
|
|
62547
62579
|
data,
|
|
62548
|
-
|
|
62580
|
+
select
|
|
62549
62581
|
}) {
|
|
62550
62582
|
const hook = initializeHook({
|
|
62551
62583
|
className,
|
|
62552
62584
|
context,
|
|
62553
62585
|
newData: data,
|
|
62554
|
-
|
|
62586
|
+
select
|
|
62555
62587
|
});
|
|
62556
62588
|
const { newData } = await hook.runOnSingleObject({
|
|
62557
62589
|
operationType: "beforeCreate" /* BeforeCreate */
|
|
@@ -62559,26 +62591,26 @@ class DatabaseController2 {
|
|
|
62559
62591
|
const { id } = await this.adapter.createObject({
|
|
62560
62592
|
className,
|
|
62561
62593
|
context,
|
|
62562
|
-
|
|
62594
|
+
select,
|
|
62563
62595
|
data: newData
|
|
62564
62596
|
});
|
|
62565
62597
|
await hook.runOnSingleObject({
|
|
62566
62598
|
operationType: "afterCreate" /* AfterCreate */,
|
|
62567
62599
|
id
|
|
62568
62600
|
});
|
|
62569
|
-
if (
|
|
62601
|
+
if (select && Object.keys(select).length === 0)
|
|
62570
62602
|
return null;
|
|
62571
62603
|
return this.getObject({
|
|
62572
62604
|
className,
|
|
62573
62605
|
context: contextWithRoot(context),
|
|
62574
|
-
|
|
62606
|
+
select,
|
|
62575
62607
|
id,
|
|
62576
62608
|
skipHooks: true
|
|
62577
62609
|
});
|
|
62578
62610
|
}
|
|
62579
62611
|
async createObjects({
|
|
62580
62612
|
data,
|
|
62581
|
-
|
|
62613
|
+
select,
|
|
62582
62614
|
className,
|
|
62583
62615
|
context,
|
|
62584
62616
|
first,
|
|
@@ -62591,14 +62623,14 @@ class DatabaseController2 {
|
|
|
62591
62623
|
className,
|
|
62592
62624
|
context,
|
|
62593
62625
|
newData,
|
|
62594
|
-
|
|
62626
|
+
select
|
|
62595
62627
|
})));
|
|
62596
62628
|
const arrayOfComputedData = await Promise.all(hooks.map(async (hook) => (await hook.runOnMultipleObjects({
|
|
62597
62629
|
operationType: "beforeCreate" /* BeforeCreate */
|
|
62598
62630
|
}))?.newData[0]));
|
|
62599
62631
|
const listOfIds = await this.adapter.createObjects({
|
|
62600
62632
|
className,
|
|
62601
|
-
|
|
62633
|
+
select,
|
|
62602
62634
|
context,
|
|
62603
62635
|
data: arrayOfComputedData,
|
|
62604
62636
|
first,
|
|
@@ -62610,12 +62642,12 @@ class DatabaseController2 {
|
|
|
62610
62642
|
operationType: "afterCreate" /* AfterCreate */,
|
|
62611
62643
|
ids
|
|
62612
62644
|
})));
|
|
62613
|
-
if (
|
|
62645
|
+
if (select && Object.keys(select).length === 0)
|
|
62614
62646
|
return [];
|
|
62615
62647
|
return this.getObjects({
|
|
62616
62648
|
className,
|
|
62617
62649
|
context,
|
|
62618
|
-
|
|
62650
|
+
select,
|
|
62619
62651
|
where: { id: { in: ids } },
|
|
62620
62652
|
skipHooks: true,
|
|
62621
62653
|
first,
|
|
@@ -62628,14 +62660,14 @@ class DatabaseController2 {
|
|
|
62628
62660
|
className,
|
|
62629
62661
|
context,
|
|
62630
62662
|
data,
|
|
62631
|
-
|
|
62663
|
+
select,
|
|
62632
62664
|
skipHooks
|
|
62633
62665
|
}) {
|
|
62634
62666
|
const hook = !skipHooks ? initializeHook({
|
|
62635
62667
|
className,
|
|
62636
62668
|
context,
|
|
62637
62669
|
newData: data,
|
|
62638
|
-
|
|
62670
|
+
select
|
|
62639
62671
|
}) : undefined;
|
|
62640
62672
|
const resultsAfterBeforeUpdate = await hook?.runOnSingleObject({
|
|
62641
62673
|
operationType: "beforeUpdate" /* BeforeUpdate */,
|
|
@@ -62644,7 +62676,7 @@ class DatabaseController2 {
|
|
|
62644
62676
|
const whereWithACLCondition = this._buildWhereWithACL({}, context, "write");
|
|
62645
62677
|
await this.adapter.updateObject({
|
|
62646
62678
|
className,
|
|
62647
|
-
|
|
62679
|
+
select,
|
|
62648
62680
|
id,
|
|
62649
62681
|
context,
|
|
62650
62682
|
data: resultsAfterBeforeUpdate?.newData || data,
|
|
@@ -62655,12 +62687,12 @@ class DatabaseController2 {
|
|
|
62655
62687
|
id,
|
|
62656
62688
|
originalObject: resultsAfterBeforeUpdate?.object
|
|
62657
62689
|
});
|
|
62658
|
-
if (
|
|
62690
|
+
if (select && Object.keys(select).length === 0)
|
|
62659
62691
|
return null;
|
|
62660
62692
|
return this.getObject({
|
|
62661
62693
|
className,
|
|
62662
62694
|
context,
|
|
62663
|
-
|
|
62695
|
+
select,
|
|
62664
62696
|
id,
|
|
62665
62697
|
skipHooks: true
|
|
62666
62698
|
});
|
|
@@ -62669,7 +62701,7 @@ class DatabaseController2 {
|
|
|
62669
62701
|
className,
|
|
62670
62702
|
where,
|
|
62671
62703
|
context,
|
|
62672
|
-
|
|
62704
|
+
select,
|
|
62673
62705
|
data,
|
|
62674
62706
|
first,
|
|
62675
62707
|
offset,
|
|
@@ -62681,7 +62713,7 @@ class DatabaseController2 {
|
|
|
62681
62713
|
className,
|
|
62682
62714
|
context,
|
|
62683
62715
|
newData: data,
|
|
62684
|
-
|
|
62716
|
+
select
|
|
62685
62717
|
}) : undefined;
|
|
62686
62718
|
const whereWithACLCondition = this._buildWhereWithACL(whereObject, context, "write");
|
|
62687
62719
|
const resultsAfterBeforeUpdate = await hook?.runOnMultipleObjects({
|
|
@@ -62691,7 +62723,7 @@ class DatabaseController2 {
|
|
|
62691
62723
|
const objects = await this.adapter.updateObjects({
|
|
62692
62724
|
className,
|
|
62693
62725
|
context,
|
|
62694
|
-
|
|
62726
|
+
select,
|
|
62695
62727
|
data: resultsAfterBeforeUpdate?.newData[0] || data,
|
|
62696
62728
|
where: whereWithACLCondition,
|
|
62697
62729
|
first,
|
|
@@ -62704,12 +62736,12 @@ class DatabaseController2 {
|
|
|
62704
62736
|
ids: objectsId,
|
|
62705
62737
|
originalObjects: resultsAfterBeforeUpdate?.objects || []
|
|
62706
62738
|
});
|
|
62707
|
-
if (
|
|
62739
|
+
if (select && Object.keys(select).length === 0)
|
|
62708
62740
|
return [];
|
|
62709
62741
|
return this.getObjects({
|
|
62710
62742
|
className,
|
|
62711
62743
|
context,
|
|
62712
|
-
|
|
62744
|
+
select,
|
|
62713
62745
|
where: { id: { in: objectsId } },
|
|
62714
62746
|
skipHooks: true,
|
|
62715
62747
|
first,
|
|
@@ -62721,19 +62753,19 @@ class DatabaseController2 {
|
|
|
62721
62753
|
context,
|
|
62722
62754
|
className,
|
|
62723
62755
|
id,
|
|
62724
|
-
|
|
62756
|
+
select
|
|
62725
62757
|
}) {
|
|
62726
62758
|
const hook = initializeHook({
|
|
62727
62759
|
className,
|
|
62728
62760
|
context,
|
|
62729
|
-
|
|
62761
|
+
select
|
|
62730
62762
|
});
|
|
62731
62763
|
const whereWithACLCondition = this._buildWhereWithACL({}, context, "write");
|
|
62732
62764
|
let objectBeforeDelete = null;
|
|
62733
|
-
if (
|
|
62765
|
+
if (select && Object.keys(select).length > 0)
|
|
62734
62766
|
objectBeforeDelete = await this.getObject({
|
|
62735
62767
|
className,
|
|
62736
|
-
|
|
62768
|
+
select,
|
|
62737
62769
|
id,
|
|
62738
62770
|
context,
|
|
62739
62771
|
skipHooks: true
|
|
@@ -62745,7 +62777,7 @@ class DatabaseController2 {
|
|
|
62745
62777
|
await this.adapter.deleteObject({
|
|
62746
62778
|
className,
|
|
62747
62779
|
context,
|
|
62748
|
-
|
|
62780
|
+
select,
|
|
62749
62781
|
id,
|
|
62750
62782
|
where: whereWithACLCondition
|
|
62751
62783
|
});
|
|
@@ -62758,7 +62790,7 @@ class DatabaseController2 {
|
|
|
62758
62790
|
async deleteObjects({
|
|
62759
62791
|
className,
|
|
62760
62792
|
context,
|
|
62761
|
-
|
|
62793
|
+
select,
|
|
62762
62794
|
where,
|
|
62763
62795
|
first,
|
|
62764
62796
|
offset,
|
|
@@ -62768,15 +62800,15 @@ class DatabaseController2 {
|
|
|
62768
62800
|
const hook = initializeHook({
|
|
62769
62801
|
className,
|
|
62770
62802
|
context,
|
|
62771
|
-
|
|
62803
|
+
select
|
|
62772
62804
|
});
|
|
62773
62805
|
const whereWithACLCondition = this._buildWhereWithACL(whereObject, context, "write");
|
|
62774
62806
|
let objectsBeforeDelete = [];
|
|
62775
|
-
if (
|
|
62807
|
+
if (select && Object.keys(select).length > 0)
|
|
62776
62808
|
objectsBeforeDelete = await this.getObjects({
|
|
62777
62809
|
className,
|
|
62778
62810
|
where,
|
|
62779
|
-
|
|
62811
|
+
select,
|
|
62780
62812
|
context,
|
|
62781
62813
|
first,
|
|
62782
62814
|
offset,
|
|
@@ -62790,7 +62822,7 @@ class DatabaseController2 {
|
|
|
62790
62822
|
await this.adapter.deleteObjects({
|
|
62791
62823
|
className,
|
|
62792
62824
|
context,
|
|
62793
|
-
|
|
62825
|
+
select,
|
|
62794
62826
|
first,
|
|
62795
62827
|
offset,
|
|
62796
62828
|
where: whereWithACLCondition,
|
|
@@ -62844,15 +62876,34 @@ class Session {
|
|
|
62844
62876
|
where: {
|
|
62845
62877
|
accessToken: { equalTo: accessToken }
|
|
62846
62878
|
},
|
|
62879
|
+
select: {
|
|
62880
|
+
id: true,
|
|
62881
|
+
user: true
|
|
62882
|
+
},
|
|
62847
62883
|
first: 1,
|
|
62848
|
-
fields: ["user.*", "user.role.*", "id"],
|
|
62849
62884
|
context
|
|
62850
62885
|
});
|
|
62851
62886
|
if (sessions.length === 0)
|
|
62852
62887
|
return { sessionId: null, user: null };
|
|
62853
62888
|
const session = sessions[0];
|
|
62854
62889
|
const user = session?.user;
|
|
62855
|
-
|
|
62890
|
+
if (!user)
|
|
62891
|
+
return { sessionId: session?.id ?? null, user: null };
|
|
62892
|
+
const userWithRole = await context.wabe.controllers.database.getObject({
|
|
62893
|
+
className: "User",
|
|
62894
|
+
select: {
|
|
62895
|
+
role: true
|
|
62896
|
+
},
|
|
62897
|
+
context,
|
|
62898
|
+
id: user.id
|
|
62899
|
+
});
|
|
62900
|
+
return {
|
|
62901
|
+
sessionId: session?.id ?? null,
|
|
62902
|
+
user: {
|
|
62903
|
+
...user,
|
|
62904
|
+
role: userWithRole?.role
|
|
62905
|
+
}
|
|
62906
|
+
};
|
|
62856
62907
|
}
|
|
62857
62908
|
async create(userId, context) {
|
|
62858
62909
|
this.accessToken = import_jsonwebtoken.default.sign({
|
|
@@ -62875,7 +62926,7 @@ class Session {
|
|
|
62875
62926
|
refreshTokenExpiresAt: this.getRefreshTokenExpireAt(context.wabe.config),
|
|
62876
62927
|
user: userId
|
|
62877
62928
|
},
|
|
62878
|
-
|
|
62929
|
+
select: { id: true }
|
|
62879
62930
|
});
|
|
62880
62931
|
if (!res)
|
|
62881
62932
|
throw new Error("Session not created");
|
|
@@ -62892,7 +62943,7 @@ class Session {
|
|
|
62892
62943
|
className: "_Session",
|
|
62893
62944
|
context: contextWithRoot(context),
|
|
62894
62945
|
id: context.sessionId,
|
|
62895
|
-
|
|
62946
|
+
select: {}
|
|
62896
62947
|
});
|
|
62897
62948
|
}
|
|
62898
62949
|
_isRefreshTokenExpired(userRefreshTokenExpiresAt, refreshTokenAgeInMs) {
|
|
@@ -62906,7 +62957,18 @@ class Session {
|
|
|
62906
62957
|
where: {
|
|
62907
62958
|
accessToken: { equalTo: accessToken }
|
|
62908
62959
|
},
|
|
62909
|
-
|
|
62960
|
+
select: {
|
|
62961
|
+
id: true,
|
|
62962
|
+
user: {
|
|
62963
|
+
id: true,
|
|
62964
|
+
role: {
|
|
62965
|
+
id: true,
|
|
62966
|
+
name: true
|
|
62967
|
+
}
|
|
62968
|
+
},
|
|
62969
|
+
refreshToken: true,
|
|
62970
|
+
refreshTokenExpiresAt: true
|
|
62971
|
+
},
|
|
62910
62972
|
context: contextWithRoot(context)
|
|
62911
62973
|
});
|
|
62912
62974
|
if (!session.length)
|
|
@@ -62922,10 +62984,10 @@ class Session {
|
|
|
62922
62984
|
refreshToken: databaseRefreshToken,
|
|
62923
62985
|
id
|
|
62924
62986
|
} = session[0];
|
|
62925
|
-
if (refreshTokenExpiresAt < new Date(Date.now()))
|
|
62987
|
+
if (new Date(refreshTokenExpiresAt) < new Date(Date.now()))
|
|
62926
62988
|
throw new Error("Refresh token expired");
|
|
62927
62989
|
const expiresInMs = this._getRefreshTokenExpiresInMs(context.wabe.config);
|
|
62928
|
-
if (!this._isRefreshTokenExpired(refreshTokenExpiresAt, expiresInMs))
|
|
62990
|
+
if (!this._isRefreshTokenExpired(new Date(refreshTokenExpiresAt), expiresInMs))
|
|
62929
62991
|
return {
|
|
62930
62992
|
accessToken,
|
|
62931
62993
|
refreshToken
|
|
@@ -62958,7 +63020,7 @@ class Session {
|
|
|
62958
63020
|
refreshToken: newRefreshToken,
|
|
62959
63021
|
refreshTokenExpiresAt: this.getRefreshTokenExpireAt(context.wabe.config)
|
|
62960
63022
|
},
|
|
62961
|
-
|
|
63023
|
+
select: {}
|
|
62962
63024
|
});
|
|
62963
63025
|
return {
|
|
62964
63026
|
accessToken: newAccessToken,
|
|
@@ -63017,7 +63079,7 @@ var signUpWithResolver = async (_, {
|
|
|
63017
63079
|
authentication: input.authentication
|
|
63018
63080
|
},
|
|
63019
63081
|
context,
|
|
63020
|
-
|
|
63082
|
+
select: { id: true }
|
|
63021
63083
|
});
|
|
63022
63084
|
const createdUserId = res?.id;
|
|
63023
63085
|
const session = new Session;
|
|
@@ -63232,6 +63294,8 @@ var verifyChallengeResolver = async (_, {
|
|
|
63232
63294
|
|
|
63233
63295
|
// src/schema/resolvers/meResolver.ts
|
|
63234
63296
|
var meResolver = (_, __, context) => {
|
|
63297
|
+
if (!context.user?.id)
|
|
63298
|
+
return { user: undefined };
|
|
63235
63299
|
return {
|
|
63236
63300
|
user: context.user
|
|
63237
63301
|
};
|
|
@@ -63284,7 +63348,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
|
|
|
63284
63348
|
equalTo: email
|
|
63285
63349
|
}
|
|
63286
63350
|
},
|
|
63287
|
-
|
|
63351
|
+
select: { id: true },
|
|
63288
63352
|
first: 1,
|
|
63289
63353
|
context: contextWithRoot(context)
|
|
63290
63354
|
});
|
|
@@ -63310,7 +63374,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
|
|
|
63310
63374
|
}
|
|
63311
63375
|
}
|
|
63312
63376
|
},
|
|
63313
|
-
|
|
63377
|
+
select: {},
|
|
63314
63378
|
context: contextWithRoot(context)
|
|
63315
63379
|
});
|
|
63316
63380
|
return true;
|
|
@@ -63450,7 +63514,7 @@ var sendOtpCodeResolver = async (_, { input }, context) => {
|
|
|
63450
63514
|
equalTo: input.email
|
|
63451
63515
|
}
|
|
63452
63516
|
},
|
|
63453
|
-
|
|
63517
|
+
select: { id: true },
|
|
63454
63518
|
first: 1,
|
|
63455
63519
|
context: contextWithRoot(context)
|
|
63456
63520
|
});
|
|
@@ -66604,7 +66668,7 @@ var GraphqlParser = ({ scalars, enums }) => ({
|
|
|
66604
66668
|
const graphqlType2 = getGraphqlType({
|
|
66605
66669
|
type: currentField.type,
|
|
66606
66670
|
typeValue: currentField.typeValue,
|
|
66607
|
-
isWhereType
|
|
66671
|
+
isWhereType,
|
|
66608
66672
|
requiredValue: currentField.requiredValue
|
|
66609
66673
|
});
|
|
66610
66674
|
acc[key] = {
|
|
@@ -66883,7 +66947,7 @@ var createAndLink = async ({
|
|
|
66883
66947
|
const res = await context.wabe.controllers.database.createObject({
|
|
66884
66948
|
className: classInSchema.fields[fieldName].class,
|
|
66885
66949
|
data: createAndLink2,
|
|
66886
|
-
|
|
66950
|
+
select: { id: true },
|
|
66887
66951
|
context
|
|
66888
66952
|
});
|
|
66889
66953
|
return res?.id;
|
|
@@ -66898,7 +66962,7 @@ var createAndAdd = async ({
|
|
|
66898
66962
|
const result2 = await context.wabe.controllers.database.createObjects({
|
|
66899
66963
|
className: classInSchema.fields[fieldName].class,
|
|
66900
66964
|
data: createAndAdd2,
|
|
66901
|
-
|
|
66965
|
+
select: { id: true },
|
|
66902
66966
|
context
|
|
66903
66967
|
});
|
|
66904
66968
|
return result2.map((object) => object.id);
|
|
@@ -66920,16 +66984,16 @@ var add = async ({
|
|
|
66920
66984
|
const currentValue = await context.wabe.controllers.database.getObject({
|
|
66921
66985
|
className,
|
|
66922
66986
|
id,
|
|
66923
|
-
|
|
66987
|
+
select: { id: true },
|
|
66924
66988
|
context
|
|
66925
66989
|
});
|
|
66926
|
-
return [
|
|
66990
|
+
return [currentValue?.id, ...add2];
|
|
66927
66991
|
}
|
|
66928
66992
|
if (typeOfExecution === "updateMany" && where) {
|
|
66929
66993
|
const allObjectsMatchedWithWhere = await context.wabe.controllers.database.getObjects({
|
|
66930
66994
|
className: fieldInClass.class,
|
|
66931
66995
|
where,
|
|
66932
|
-
|
|
66996
|
+
select: { [fieldName]: true },
|
|
66933
66997
|
context
|
|
66934
66998
|
});
|
|
66935
66999
|
await Promise.all(allObjectsMatchedWithWhere.map((object) => {
|
|
@@ -66941,7 +67005,7 @@ var add = async ({
|
|
|
66941
67005
|
[fieldName]: [...currentValue || [], ...add2]
|
|
66942
67006
|
},
|
|
66943
67007
|
context,
|
|
66944
|
-
|
|
67008
|
+
select: {}
|
|
66945
67009
|
});
|
|
66946
67010
|
}));
|
|
66947
67011
|
}
|
|
@@ -66961,17 +67025,17 @@ var remove = async ({
|
|
|
66961
67025
|
const currentValue = await context.wabe.controllers.database.getObject({
|
|
66962
67026
|
className,
|
|
66963
67027
|
id,
|
|
66964
|
-
|
|
67028
|
+
select: { id: true },
|
|
66965
67029
|
context
|
|
66966
67030
|
});
|
|
66967
|
-
const olderValues = currentValue?.
|
|
67031
|
+
const olderValues = [currentValue?.id || ""];
|
|
66968
67032
|
return olderValues.filter((olderValue) => !remove2.includes(olderValue));
|
|
66969
67033
|
}
|
|
66970
67034
|
if (typeOfExecution === "updateMany" && where) {
|
|
66971
67035
|
const allObjectsMatchedWithWhere = await context.wabe.controllers.database.getObjects({
|
|
66972
67036
|
className,
|
|
66973
67037
|
where,
|
|
66974
|
-
|
|
67038
|
+
select: { id: true },
|
|
66975
67039
|
context
|
|
66976
67040
|
});
|
|
66977
67041
|
await Promise.all(allObjectsMatchedWithWhere.map(async (object) => {
|
|
@@ -66983,7 +67047,7 @@ var remove = async ({
|
|
|
66983
67047
|
[fieldName]: olderValues.filter((olderValue) => !remove2.includes(olderValue))
|
|
66984
67048
|
},
|
|
66985
67049
|
context,
|
|
66986
|
-
|
|
67050
|
+
select: {}
|
|
66987
67051
|
});
|
|
66988
67052
|
}));
|
|
66989
67053
|
}
|
|
@@ -66994,16 +67058,23 @@ var extractFieldsFromSetNode = (selectionSet, className) => {
|
|
|
66994
67058
|
const ignoredFields = ["edges", "node"];
|
|
66995
67059
|
if (className)
|
|
66996
67060
|
ignoredFields.push(firstLetterInLowerCase(className));
|
|
66997
|
-
return selectionSet.selections?.
|
|
67061
|
+
return selectionSet.selections?.reduce((acc, selection) => {
|
|
66998
67062
|
const currentValue = selection.name.value;
|
|
66999
67063
|
if (selection.selectionSet?.selections && selection.selectionSet?.selections?.length > 0) {
|
|
67000
67064
|
const res = extractFieldsFromSetNode(selection.selectionSet, className);
|
|
67001
67065
|
if (ignoredFields.indexOf(currentValue) === -1)
|
|
67002
|
-
return
|
|
67003
|
-
|
|
67066
|
+
return {
|
|
67067
|
+
...acc,
|
|
67068
|
+
[currentValue]: res
|
|
67069
|
+
};
|
|
67070
|
+
return {
|
|
67071
|
+
...acc,
|
|
67072
|
+
...res
|
|
67073
|
+
};
|
|
67004
67074
|
}
|
|
67005
|
-
|
|
67006
|
-
|
|
67075
|
+
acc[currentValue] = true;
|
|
67076
|
+
return acc;
|
|
67077
|
+
}, {});
|
|
67007
67078
|
};
|
|
67008
67079
|
var getFieldsFromInfo = (info, className) => {
|
|
67009
67080
|
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
@@ -67014,24 +67085,6 @@ var getFieldsFromInfo = (info, className) => {
|
|
|
67014
67085
|
throw new Error("No fields provided");
|
|
67015
67086
|
return fields;
|
|
67016
67087
|
};
|
|
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
67088
|
var executeRelationOnFields = ({
|
|
67036
67089
|
className,
|
|
67037
67090
|
fields,
|
|
@@ -67099,27 +67152,27 @@ var transformOrder = (order) => order?.reduce((acc, currentOrder) => {
|
|
|
67099
67152
|
return acc;
|
|
67100
67153
|
}, {}) || {};
|
|
67101
67154
|
var queryForOneObject = (_, { id }, context, info, className) => {
|
|
67102
|
-
const
|
|
67155
|
+
const select = getFieldsFromInfo(info, className);
|
|
67103
67156
|
return context.wabe.controllers.database.getObject({
|
|
67104
67157
|
className,
|
|
67105
67158
|
id,
|
|
67106
|
-
|
|
67159
|
+
select,
|
|
67107
67160
|
context
|
|
67108
67161
|
});
|
|
67109
67162
|
};
|
|
67110
67163
|
var queryForMultipleObject = async (_, { where, offset, first, order }, context, info, className) => {
|
|
67111
|
-
const
|
|
67164
|
+
const select = getFieldsFromInfo(info, className);
|
|
67112
67165
|
const objects = await context.wabe.controllers.database.getObjects({
|
|
67113
67166
|
className,
|
|
67114
67167
|
where,
|
|
67115
|
-
|
|
67168
|
+
select,
|
|
67116
67169
|
offset,
|
|
67117
67170
|
first,
|
|
67118
67171
|
context,
|
|
67119
67172
|
order: transformOrder(order)
|
|
67120
67173
|
});
|
|
67121
67174
|
return {
|
|
67122
|
-
totalCount:
|
|
67175
|
+
totalCount: select.totalCount ? await context.wabe.controllers.database.count({
|
|
67123
67176
|
className,
|
|
67124
67177
|
where,
|
|
67125
67178
|
context
|
|
@@ -67130,11 +67183,7 @@ var queryForMultipleObject = async (_, { where, offset, first, order }, context,
|
|
|
67130
67183
|
};
|
|
67131
67184
|
};
|
|
67132
67185
|
var mutationToCreateObject = async (_, args, context, info, className) => {
|
|
67133
|
-
const
|
|
67134
|
-
fields: getFieldsFromInfo(info, className),
|
|
67135
|
-
className,
|
|
67136
|
-
context
|
|
67137
|
-
});
|
|
67186
|
+
const select = getFieldsFromInfo(info, className);
|
|
67138
67187
|
const updatedFieldsToCreate = await executeRelationOnFields({
|
|
67139
67188
|
className,
|
|
67140
67189
|
fields: args.input?.fields,
|
|
@@ -67144,14 +67193,14 @@ var mutationToCreateObject = async (_, args, context, info, className) => {
|
|
|
67144
67193
|
[firstLetterInLowerCase(className)]: await context.wabe.controllers.database.createObject({
|
|
67145
67194
|
className,
|
|
67146
67195
|
data: updatedFieldsToCreate,
|
|
67147
|
-
|
|
67196
|
+
select,
|
|
67148
67197
|
context
|
|
67149
67198
|
}),
|
|
67150
|
-
...
|
|
67199
|
+
...select.ok ? { ok: true } : {}
|
|
67151
67200
|
};
|
|
67152
67201
|
};
|
|
67153
67202
|
var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first, order } }, context, info, className) => {
|
|
67154
|
-
const
|
|
67203
|
+
const select = getFieldsFromInfo(info, className);
|
|
67155
67204
|
const inputFields = fields;
|
|
67156
67205
|
const updatedFieldsToCreate = await Promise.all(inputFields.map((inputField) => executeRelationOnFields({
|
|
67157
67206
|
className,
|
|
@@ -67161,7 +67210,7 @@ var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first
|
|
|
67161
67210
|
const objects = await context.wabe.controllers.database.createObjects({
|
|
67162
67211
|
className,
|
|
67163
67212
|
data: updatedFieldsToCreate,
|
|
67164
|
-
|
|
67213
|
+
select,
|
|
67165
67214
|
offset,
|
|
67166
67215
|
first,
|
|
67167
67216
|
context,
|
|
@@ -67172,11 +67221,7 @@ var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first
|
|
|
67172
67221
|
};
|
|
67173
67222
|
};
|
|
67174
67223
|
var mutationToUpdateObject = async (_, args, context, info, className) => {
|
|
67175
|
-
const
|
|
67176
|
-
fields: getFieldsFromInfo(info, className),
|
|
67177
|
-
className,
|
|
67178
|
-
context
|
|
67179
|
-
});
|
|
67224
|
+
const select = getFieldsFromInfo(info, className);
|
|
67180
67225
|
const updatedFields = await executeRelationOnFields({
|
|
67181
67226
|
className,
|
|
67182
67227
|
fields: args.input?.fields,
|
|
@@ -67189,14 +67234,14 @@ var mutationToUpdateObject = async (_, args, context, info, className) => {
|
|
|
67189
67234
|
className,
|
|
67190
67235
|
id: args.input?.id,
|
|
67191
67236
|
data: updatedFields,
|
|
67192
|
-
|
|
67237
|
+
select,
|
|
67193
67238
|
context
|
|
67194
67239
|
}),
|
|
67195
|
-
...
|
|
67240
|
+
...select.ok ? { ok: true } : {}
|
|
67196
67241
|
};
|
|
67197
67242
|
};
|
|
67198
67243
|
var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset, first, order } }, context, info, className) => {
|
|
67199
|
-
const
|
|
67244
|
+
const select = getFieldsFromInfo(info, className);
|
|
67200
67245
|
const updatedFields = await executeRelationOnFields({
|
|
67201
67246
|
className,
|
|
67202
67247
|
fields,
|
|
@@ -67208,7 +67253,7 @@ var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset
|
|
|
67208
67253
|
className,
|
|
67209
67254
|
where,
|
|
67210
67255
|
data: updatedFields,
|
|
67211
|
-
|
|
67256
|
+
select,
|
|
67212
67257
|
offset,
|
|
67213
67258
|
first,
|
|
67214
67259
|
context,
|
|
@@ -67219,27 +67264,23 @@ var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset
|
|
|
67219
67264
|
};
|
|
67220
67265
|
};
|
|
67221
67266
|
var mutationToDeleteObject = async (_, args, context, info, className) => {
|
|
67222
|
-
const
|
|
67223
|
-
fields: getFieldsFromInfo(info, className),
|
|
67224
|
-
className,
|
|
67225
|
-
context
|
|
67226
|
-
});
|
|
67267
|
+
const select = getFieldsFromInfo(info, className);
|
|
67227
67268
|
return {
|
|
67228
67269
|
[firstLetterInLowerCase(className)]: await context.wabe.controllers.database.deleteObject({
|
|
67229
67270
|
className,
|
|
67230
67271
|
id: args.input?.id,
|
|
67231
|
-
|
|
67272
|
+
select,
|
|
67232
67273
|
context
|
|
67233
67274
|
}),
|
|
67234
|
-
...
|
|
67275
|
+
...select.ok ? { ok: true } : {}
|
|
67235
67276
|
};
|
|
67236
67277
|
};
|
|
67237
67278
|
var mutationToDeleteMultipleObjects = async (_, { input: { where, offset, first, order } }, context, info, className) => {
|
|
67238
|
-
const
|
|
67279
|
+
const select = getFieldsFromInfo(info, className);
|
|
67239
67280
|
const objects = await context.wabe.controllers.database.deleteObjects({
|
|
67240
67281
|
className,
|
|
67241
67282
|
where,
|
|
67242
|
-
|
|
67283
|
+
select,
|
|
67243
67284
|
offset,
|
|
67244
67285
|
first,
|
|
67245
67286
|
context,
|
|
@@ -68056,130 +68097,198 @@ var defaultRoutes = () => {
|
|
|
68056
68097
|
// src/server/generateCodegen.ts
|
|
68057
68098
|
var import_graphql6 = __toESM(require_graphql2(), 1);
|
|
68058
68099
|
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" }
|
|
68100
|
+
var wabePrimaryTypesToTypescriptTypes = {
|
|
68101
|
+
Boolean: "boolean",
|
|
68102
|
+
Int: "number",
|
|
68103
|
+
Float: "number",
|
|
68104
|
+
String: "string",
|
|
68105
|
+
Email: "string",
|
|
68106
|
+
Phone: "string",
|
|
68107
|
+
Date: "Date",
|
|
68108
|
+
File: "{url: string, name: string}"
|
|
68071
68109
|
};
|
|
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
|
-
for (const field of node.fields || []) {
|
|
68097
|
-
const fieldName = field.name.value;
|
|
68098
|
-
const fieldType = getFieldType(field.type, false);
|
|
68099
|
-
const isOptional = field.type.kind !== "NonNullType";
|
|
68100
|
-
fieldsCode += ` ${fieldName}${isOptional ? "?" : ""}: ${fieldType};
|
|
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};
|
|
68110
|
+
var wabeTypesToTypescriptTypes = (field) => {
|
|
68111
|
+
switch (field.type) {
|
|
68112
|
+
case "Boolean":
|
|
68113
|
+
case "Int":
|
|
68114
|
+
case "Float":
|
|
68115
|
+
case "String":
|
|
68116
|
+
case "Email":
|
|
68117
|
+
case "Phone":
|
|
68118
|
+
case "Date":
|
|
68119
|
+
case "File":
|
|
68120
|
+
return wabePrimaryTypesToTypescriptTypes[field.type];
|
|
68121
|
+
case "Array":
|
|
68122
|
+
if (field.typeValue === "Object")
|
|
68123
|
+
return `Array<${field.object.name}>`;
|
|
68124
|
+
return `Array<${wabePrimaryTypesToTypescriptTypes[field.typeValue]}>`;
|
|
68125
|
+
case "Pointer":
|
|
68126
|
+
return field.class;
|
|
68127
|
+
case "Relation":
|
|
68128
|
+
return "Array<string>";
|
|
68129
|
+
case "Object":
|
|
68130
|
+
return `${field.object.name}`;
|
|
68131
|
+
default:
|
|
68132
|
+
return field.type;
|
|
68133
|
+
}
|
|
68116
68134
|
};
|
|
68117
|
-
|
|
68118
|
-
|
|
68119
|
-
|
|
68120
|
-
|
|
68121
|
-
|
|
68122
|
-
|
|
68123
|
-
|
|
68124
|
-
|
|
68125
|
-
|
|
68126
|
-
|
|
68127
|
-
|
|
68128
|
-
|
|
68129
|
-
|
|
68135
|
+
var generateWabeObject = (object, prefix = "") => {
|
|
68136
|
+
const objectName = object.name;
|
|
68137
|
+
return Object.entries(object.fields).reduce((acc, [fieldName, field]) => {
|
|
68138
|
+
const type = wabeTypesToTypescriptTypes(field);
|
|
68139
|
+
const objectNameWithPrefix = `${prefix}${firstLetterUpperCase(objectName)}`;
|
|
68140
|
+
if (field.type === "Object" || field.type === "Array" && field.typeValue === "Object") {
|
|
68141
|
+
const subObject = generateWabeObject(field.object, objectNameWithPrefix);
|
|
68142
|
+
const isArray = field.type === "Array";
|
|
68143
|
+
return {
|
|
68144
|
+
...acc,
|
|
68145
|
+
...subObject,
|
|
68146
|
+
...{
|
|
68147
|
+
[objectNameWithPrefix]: {
|
|
68148
|
+
...acc[objectNameWithPrefix],
|
|
68149
|
+
[`${fieldName}${field.required ? "" : "undefined"}`]: `${isArray ? "Array<" : ""}${objectNameWithPrefix}${firstLetterUpperCase(field.object.name)}${isArray ? ">" : ""}`
|
|
68130
68150
|
}
|
|
68131
68151
|
}
|
|
68152
|
+
};
|
|
68153
|
+
}
|
|
68154
|
+
return {
|
|
68155
|
+
...acc,
|
|
68156
|
+
...{
|
|
68157
|
+
[objectNameWithPrefix]: {
|
|
68158
|
+
...acc[objectNameWithPrefix],
|
|
68159
|
+
[`${fieldName}${field.required ? "" : "undefined"}`]: `${type}`
|
|
68160
|
+
}
|
|
68132
68161
|
}
|
|
68133
|
-
}
|
|
68134
|
-
|
|
68135
|
-
|
|
68136
|
-
|
|
68137
|
-
|
|
68138
|
-
|
|
68139
|
-
|
|
68140
|
-
|
|
68141
|
-
|
|
68142
|
-
|
|
68162
|
+
};
|
|
68163
|
+
}, {});
|
|
68164
|
+
};
|
|
68165
|
+
var generateWabeTypes = (classes) => {
|
|
68166
|
+
const wabeTypes = classes.reduce((acc, classType) => {
|
|
68167
|
+
const { name, fields } = classType;
|
|
68168
|
+
const objectsToLoad = [];
|
|
68169
|
+
const currentClass = Object.entries(fields).reduce((acc2, [name2, field]) => {
|
|
68170
|
+
const type = wabeTypesToTypescriptTypes(field);
|
|
68171
|
+
if (field.type === "Object") {
|
|
68172
|
+
const wabeObject = generateWabeObject(field.object);
|
|
68173
|
+
objectsToLoad.push(wabeObject);
|
|
68143
68174
|
}
|
|
68144
|
-
|
|
68145
|
-
|
|
68146
|
-
${
|
|
68147
|
-
|
|
68175
|
+
return {
|
|
68176
|
+
...acc2,
|
|
68177
|
+
[`${name2}${field.required ? "" : "undefined"}`]: type
|
|
68178
|
+
};
|
|
68179
|
+
}, {});
|
|
68180
|
+
const objects = objectsToLoad.reduce((acc2, object) => {
|
|
68181
|
+
return {
|
|
68182
|
+
...acc2,
|
|
68183
|
+
...object
|
|
68184
|
+
};
|
|
68185
|
+
}, {});
|
|
68186
|
+
return {
|
|
68187
|
+
...acc,
|
|
68188
|
+
...objects,
|
|
68189
|
+
[name]: { id: "string", ...currentClass }
|
|
68190
|
+
};
|
|
68191
|
+
}, {});
|
|
68192
|
+
return wabeTypes;
|
|
68193
|
+
};
|
|
68194
|
+
var generateWabeEnumTypes = (enums) => {
|
|
68195
|
+
return Object.values(enums).reduce((acc, { name, values }) => {
|
|
68196
|
+
return {
|
|
68197
|
+
...acc,
|
|
68198
|
+
[name]: values
|
|
68199
|
+
};
|
|
68200
|
+
}, {});
|
|
68201
|
+
};
|
|
68202
|
+
var generateWabeScalarTypes = (scalars) => {
|
|
68203
|
+
return Object.values(scalars).reduce((acc, { name }) => {
|
|
68204
|
+
return {
|
|
68205
|
+
...acc,
|
|
68206
|
+
[name]: "string"
|
|
68207
|
+
};
|
|
68208
|
+
}, {});
|
|
68209
|
+
};
|
|
68210
|
+
var generateWabeMutationOrQueryInput = (mutationOrQueryName, resolver, isMutation) => {
|
|
68211
|
+
const objectsToLoad = [];
|
|
68212
|
+
const mutationNameWithFirstLetterUpperCase = firstLetterUpperCase(mutationOrQueryName);
|
|
68213
|
+
const mutationObject = Object.entries((isMutation ? resolver.args?.input : resolver.args) || {}).reduce((acc, [name, field]) => {
|
|
68214
|
+
let type = wabeTypesToTypescriptTypes(field);
|
|
68215
|
+
if (field.type === "Object") {
|
|
68216
|
+
type = firstLetterInUpperCase(name);
|
|
68217
|
+
const wabeObject = generateWabeObject({
|
|
68218
|
+
...field.object,
|
|
68219
|
+
name: type
|
|
68220
|
+
}, mutationNameWithFirstLetterUpperCase);
|
|
68221
|
+
objectsToLoad.push(wabeObject);
|
|
68222
|
+
return {
|
|
68223
|
+
...acc,
|
|
68224
|
+
[`${name}${field.required ? "" : "undefined"}`]: `${mutationNameWithFirstLetterUpperCase}${type}`
|
|
68225
|
+
};
|
|
68226
|
+
}
|
|
68227
|
+
return {
|
|
68228
|
+
...acc,
|
|
68229
|
+
[`${name}${field.required ? "" : "undefined"}`]: type
|
|
68230
|
+
};
|
|
68231
|
+
}, {});
|
|
68232
|
+
const objects = objectsToLoad.reduce((acc2, object) => {
|
|
68233
|
+
return {
|
|
68234
|
+
...acc2,
|
|
68235
|
+
...object
|
|
68236
|
+
};
|
|
68237
|
+
}, {});
|
|
68238
|
+
return {
|
|
68239
|
+
[`${firstLetterInUpperCase(mutationOrQueryName)}Input`]: mutationObject,
|
|
68240
|
+
[`${isMutation ? "Mutation" : "Query"}${firstLetterInUpperCase(mutationOrQueryName)}Args`]: {
|
|
68241
|
+
input: `${firstLetterInUpperCase(mutationOrQueryName)}Input`
|
|
68148
68242
|
},
|
|
68149
|
-
|
|
68150
|
-
|
|
68151
|
-
|
|
68152
|
-
|
|
68153
|
-
|
|
68154
|
-
|
|
68155
|
-
|
|
68243
|
+
...objects
|
|
68244
|
+
};
|
|
68245
|
+
};
|
|
68246
|
+
var generateWabeMutationsAndQueriesTypes = (resolver) => {
|
|
68247
|
+
const mutationsObject = Object.entries(resolver.mutations || {}).reduce((acc, [mutationName, mutation]) => {
|
|
68248
|
+
return {
|
|
68249
|
+
...acc,
|
|
68250
|
+
...generateWabeMutationOrQueryInput(mutationName, mutation, true)
|
|
68251
|
+
};
|
|
68252
|
+
}, {});
|
|
68253
|
+
const queriesObject = Object.entries(resolver.queries || {}).reduce((acc, [queryName, query]) => {
|
|
68254
|
+
return {
|
|
68255
|
+
...acc,
|
|
68256
|
+
...generateWabeMutationOrQueryInput(queryName, query, false)
|
|
68257
|
+
};
|
|
68258
|
+
}, {});
|
|
68259
|
+
return {
|
|
68260
|
+
...mutationsObject,
|
|
68261
|
+
...queriesObject
|
|
68262
|
+
};
|
|
68263
|
+
};
|
|
68264
|
+
var wabeClassRecordToString = (wabeClass) => {
|
|
68265
|
+
return Object.entries(wabeClass).reduce((acc, [className, fields]) => {
|
|
68266
|
+
return `${acc}export type ${className} = {
|
|
68267
|
+
${Object.entries(fields).map(([fieldName, fieldType]) => ` ${fieldName.replace("undefined", "?")}: ${fieldType}`).join(`,
|
|
68268
|
+
`)}
|
|
68156
68269
|
}
|
|
68270
|
+
|
|
68157
68271
|
`;
|
|
68158
|
-
|
|
68159
|
-
});
|
|
68160
|
-
return typescriptCode;
|
|
68272
|
+
}, "");
|
|
68161
68273
|
};
|
|
68162
|
-
var
|
|
68163
|
-
|
|
68164
|
-
|
|
68165
|
-
|
|
68166
|
-
|
|
68167
|
-
|
|
68168
|
-
|
|
68169
|
-
|
|
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
|
-
}
|
|
68274
|
+
var wabeEnumRecordToString = (wabeEnum) => {
|
|
68275
|
+
return Object.entries(wabeEnum).reduce((acc, [enumName, values]) => {
|
|
68276
|
+
return `${acc}export enum ${enumName} {
|
|
68277
|
+
${Object.entries(values).map(([valueName, value]) => ` ${valueName} = "${value}"`).join(`,
|
|
68278
|
+
`)}
|
|
68279
|
+
}
|
|
68280
|
+
|
|
68281
|
+
`;
|
|
68282
|
+
}, "");
|
|
68181
68283
|
};
|
|
68182
|
-
var
|
|
68284
|
+
var wabeScalarRecordToString = (wabeScalar) => {
|
|
68285
|
+
return Object.entries(wabeScalar).reduce((acc, [scalarName, scalarType]) => {
|
|
68286
|
+
return `${acc}export type ${scalarName} = ${scalarType}
|
|
68287
|
+
|
|
68288
|
+
`;
|
|
68289
|
+
}, "");
|
|
68290
|
+
};
|
|
68291
|
+
var generateWabeDevTypes = ({
|
|
68183
68292
|
scalars,
|
|
68184
68293
|
enums,
|
|
68185
68294
|
classes
|
|
@@ -68204,27 +68313,32 @@ ${globalWabeTypeString}`;
|
|
|
68204
68313
|
};
|
|
68205
68314
|
var generateCodegen = async ({
|
|
68206
68315
|
schema,
|
|
68207
|
-
path,
|
|
68316
|
+
path: path2,
|
|
68208
68317
|
graphqlSchema
|
|
68209
68318
|
}) => {
|
|
68210
68319
|
const graphqlSchemaContent = import_graphql6.printSchema(graphqlSchema);
|
|
68211
|
-
const
|
|
68212
|
-
const
|
|
68320
|
+
const wabeClasses = generateWabeTypes(schema.classes || []);
|
|
68321
|
+
const mutationsAndQueries = generateWabeMutationsAndQueriesTypes(schema.resolvers || {});
|
|
68322
|
+
const wabeEnumsInString = wabeEnumRecordToString(generateWabeEnumTypes(schema.enums || []));
|
|
68323
|
+
const wabeScalarsInString = wabeScalarRecordToString(generateWabeScalarTypes(schema.scalars || []));
|
|
68324
|
+
const wabeObjectsInString = wabeClassRecordToString({
|
|
68325
|
+
...wabeClasses,
|
|
68326
|
+
...mutationsAndQueries
|
|
68327
|
+
});
|
|
68328
|
+
const wabeDevTypes = generateWabeDevTypes({
|
|
68213
68329
|
scalars: schema.scalars,
|
|
68214
68330
|
enums: schema.enums,
|
|
68215
68331
|
classes: schema.classes || []
|
|
68216
68332
|
});
|
|
68217
|
-
const wabeTsContent = `${
|
|
68218
|
-
|
|
68219
|
-
${wabeOutput}`;
|
|
68333
|
+
const wabeTsContent = `${wabeEnumsInString}${wabeScalarsInString}${wabeObjectsInString}${wabeDevTypes}`;
|
|
68220
68334
|
try {
|
|
68221
|
-
const contentOfGraphqlSchema = (await readFile(`${
|
|
68335
|
+
const contentOfGraphqlSchema = (await readFile(`${path2}/schema.graphql`)).toString();
|
|
68222
68336
|
if (!process.env.CODEGEN && contentOfGraphqlSchema === graphqlSchemaContent.toString())
|
|
68223
68337
|
return;
|
|
68224
68338
|
} catch {
|
|
68225
68339
|
}
|
|
68226
|
-
await writeFile2(`${
|
|
68227
|
-
await writeFile2(`${
|
|
68340
|
+
await writeFile2(`${path2}/wabe.ts`, wabeTsContent);
|
|
68341
|
+
await writeFile2(`${path2}/schema.graphql`, graphqlSchemaContent);
|
|
68228
68342
|
};
|
|
68229
68343
|
|
|
68230
68344
|
// src/authentication/providers/EmailPassword.ts
|
|
@@ -68244,7 +68358,7 @@ class EmailPassword {
|
|
|
68244
68358
|
}
|
|
68245
68359
|
},
|
|
68246
68360
|
context: contextWithRoot(context),
|
|
68247
|
-
|
|
68361
|
+
select: { id: true, authentication: true },
|
|
68248
68362
|
first: 1
|
|
68249
68363
|
});
|
|
68250
68364
|
if (users.length === 0)
|
|
@@ -68299,7 +68413,7 @@ class EmailPassword {
|
|
|
68299
68413
|
}
|
|
68300
68414
|
},
|
|
68301
68415
|
context,
|
|
68302
|
-
|
|
68416
|
+
select: { authentication: true }
|
|
68303
68417
|
});
|
|
68304
68418
|
if (users.length === 0)
|
|
68305
68419
|
throw new Error("User not found");
|
|
@@ -68336,7 +68450,7 @@ class Google3 {
|
|
|
68336
68450
|
},
|
|
68337
68451
|
context: contextWithRoot(context),
|
|
68338
68452
|
first: 1,
|
|
68339
|
-
|
|
68453
|
+
select: { id: true }
|
|
68340
68454
|
});
|
|
68341
68455
|
const authenticationDataToSave = {
|
|
68342
68456
|
email,
|
|
@@ -68352,8 +68466,7 @@ class Google3 {
|
|
|
68352
68466
|
google: authenticationDataToSave
|
|
68353
68467
|
}
|
|
68354
68468
|
},
|
|
68355
|
-
context: contextWithRoot(context)
|
|
68356
|
-
fields: ["*", "id"]
|
|
68469
|
+
context: contextWithRoot(context)
|
|
68357
68470
|
});
|
|
68358
68471
|
if (!createdUser)
|
|
68359
68472
|
throw new Error("User not found");
|
|
@@ -68396,7 +68509,7 @@ class GitHub2 {
|
|
|
68396
68509
|
},
|
|
68397
68510
|
context: contextWithRoot(context),
|
|
68398
68511
|
first: 1,
|
|
68399
|
-
|
|
68512
|
+
select: { id: true }
|
|
68400
68513
|
});
|
|
68401
68514
|
const authenticationDataToSave = {
|
|
68402
68515
|
email,
|
|
@@ -68413,8 +68526,7 @@ class GitHub2 {
|
|
|
68413
68526
|
github: authenticationDataToSave
|
|
68414
68527
|
}
|
|
68415
68528
|
},
|
|
68416
|
-
context: contextWithRoot(context)
|
|
68417
|
-
fields: ["*", "id"]
|
|
68529
|
+
context: contextWithRoot(context)
|
|
68418
68530
|
});
|
|
68419
68531
|
if (!createdUser)
|
|
68420
68532
|
throw new Error("User not found");
|
|
@@ -68452,7 +68564,7 @@ class PhonePassword {
|
|
|
68452
68564
|
}
|
|
68453
68565
|
},
|
|
68454
68566
|
context: contextWithRoot(context),
|
|
68455
|
-
|
|
68567
|
+
select: { id: true, authentication: true },
|
|
68456
68568
|
first: 1
|
|
68457
68569
|
});
|
|
68458
68570
|
if (users.length === 0)
|
|
@@ -68507,7 +68619,7 @@ class PhonePassword {
|
|
|
68507
68619
|
}
|
|
68508
68620
|
},
|
|
68509
68621
|
context,
|
|
68510
|
-
|
|
68622
|
+
select: { authentication: true }
|
|
68511
68623
|
});
|
|
68512
68624
|
if (users.length === 0)
|
|
68513
68625
|
throw new Error("User not found");
|
|
@@ -68631,8 +68743,8 @@ import { createServer as createHttpsServer } from "https";
|
|
|
68631
68743
|
class RadixTree {
|
|
68632
68744
|
root = { name: "/", children: [] };
|
|
68633
68745
|
isOptimized = false;
|
|
68634
|
-
addRoute(method,
|
|
68635
|
-
const pathParts =
|
|
68746
|
+
addRoute(method, path2, handler) {
|
|
68747
|
+
const pathParts = path2.split("/").filter(Boolean);
|
|
68636
68748
|
let currentNode = this.root;
|
|
68637
68749
|
for (let i = 0;i < pathParts.length; i++) {
|
|
68638
68750
|
const pathPart = pathParts[i];
|
|
@@ -68640,7 +68752,7 @@ class RadixTree {
|
|
|
68640
68752
|
const isWildcardNode = pathPart[0] === "*";
|
|
68641
68753
|
let foundNode = currentNode.children.find((node) => node.name === (i === 0 ? "" : "/") + pathPart && (node.method === method || !node.method));
|
|
68642
68754
|
if (foundNode && foundNode.method === method && i === pathParts.length - 1)
|
|
68643
|
-
throw new Error(`Route ${method} ${
|
|
68755
|
+
throw new Error(`Route ${method} ${path2} already exists`);
|
|
68644
68756
|
if (!foundNode) {
|
|
68645
68757
|
foundNode = {
|
|
68646
68758
|
name: (i === 0 ? "" : "/") + pathPart,
|
|
@@ -68682,11 +68794,11 @@ class RadixTree {
|
|
|
68682
68794
|
break;
|
|
68683
68795
|
}
|
|
68684
68796
|
}
|
|
68685
|
-
addHook(hook,
|
|
68797
|
+
addHook(hook, path2, handler, method, node) {
|
|
68686
68798
|
if (this.isOptimized)
|
|
68687
68799
|
throw new Error("Cannot add hooks after the tree has been optimized");
|
|
68688
68800
|
let currentNode = node || this.root;
|
|
68689
|
-
if (
|
|
68801
|
+
if (path2 === "*") {
|
|
68690
68802
|
const addHookToChildren = (node2) => {
|
|
68691
68803
|
for (let i = 0;i < node2.children.length; i++) {
|
|
68692
68804
|
const child = node2.children[i];
|
|
@@ -68705,7 +68817,7 @@ class RadixTree {
|
|
|
68705
68817
|
}
|
|
68706
68818
|
return;
|
|
68707
68819
|
}
|
|
68708
|
-
const pathParts =
|
|
68820
|
+
const pathParts = path2.split("/").filter(Boolean);
|
|
68709
68821
|
for (let i = 0;i < pathParts.length; i++) {
|
|
68710
68822
|
const pathPart = pathParts[i];
|
|
68711
68823
|
const isWildcardNode = pathPart[0] === "*";
|
|
@@ -68724,10 +68836,10 @@ class RadixTree {
|
|
|
68724
68836
|
}
|
|
68725
68837
|
this._addHookToNode(currentNode, hook, handler);
|
|
68726
68838
|
}
|
|
68727
|
-
findRoute(method,
|
|
68728
|
-
let localPath =
|
|
68729
|
-
if (
|
|
68730
|
-
localPath = "/" +
|
|
68839
|
+
findRoute(method, path2) {
|
|
68840
|
+
let localPath = path2;
|
|
68841
|
+
if (path2[0] !== "/")
|
|
68842
|
+
localPath = "/" + path2;
|
|
68731
68843
|
const { length: pathLength } = localPath;
|
|
68732
68844
|
if (pathLength === 1 && localPath === "/")
|
|
68733
68845
|
return this.root;
|
|
@@ -68815,7 +68927,7 @@ class WobeResponse {
|
|
|
68815
68927
|
if (options) {
|
|
68816
68928
|
const {
|
|
68817
68929
|
httpOnly,
|
|
68818
|
-
path,
|
|
68930
|
+
path: path2,
|
|
68819
68931
|
domain,
|
|
68820
68932
|
expires,
|
|
68821
68933
|
sameSite,
|
|
@@ -68824,8 +68936,8 @@ class WobeResponse {
|
|
|
68824
68936
|
} = options;
|
|
68825
68937
|
if (httpOnly)
|
|
68826
68938
|
cookie = `${cookie} HttpOnly;`;
|
|
68827
|
-
if (
|
|
68828
|
-
cookie = `${cookie} Path=${
|
|
68939
|
+
if (path2)
|
|
68940
|
+
cookie = `${cookie} Path=${path2};`;
|
|
68829
68941
|
if (domain)
|
|
68830
68942
|
cookie = `${cookie} Domain=${domain};`;
|
|
68831
68943
|
if (expires)
|
|
@@ -68907,7 +69019,7 @@ var extractPathnameAndSearchParams = (url) => {
|
|
|
68907
69019
|
const queryIndex = url.indexOf("?", 8);
|
|
68908
69020
|
const urlLength = url.length;
|
|
68909
69021
|
const isQueryContainsSearchParams = queryIndex !== -1;
|
|
68910
|
-
const
|
|
69022
|
+
const path2 = url.slice(url.indexOf("/", 8), !isQueryContainsSearchParams ? urlLength : queryIndex);
|
|
68911
69023
|
if (isQueryContainsSearchParams) {
|
|
68912
69024
|
const searchParams = {};
|
|
68913
69025
|
let indexOfLastParam = queryIndex + 1;
|
|
@@ -68923,9 +69035,9 @@ var extractPathnameAndSearchParams = (url) => {
|
|
|
68923
69035
|
indexOfLastParam = i + 1;
|
|
68924
69036
|
}
|
|
68925
69037
|
}
|
|
68926
|
-
return { pathName:
|
|
69038
|
+
return { pathName: path2, searchParams };
|
|
68927
69039
|
}
|
|
68928
|
-
return { pathName:
|
|
69040
|
+
return { pathName: path2 };
|
|
68929
69041
|
};
|
|
68930
69042
|
|
|
68931
69043
|
class Context {
|
|
@@ -69134,53 +69246,53 @@ class Wobe {
|
|
|
69134
69246
|
this.server = null;
|
|
69135
69247
|
this.router = new RadixTree;
|
|
69136
69248
|
}
|
|
69137
|
-
get(
|
|
69249
|
+
get(path2, handler, hook) {
|
|
69138
69250
|
if (hook)
|
|
69139
|
-
this._addHook("beforeHandler", "GET")(
|
|
69140
|
-
this.router.addRoute("GET",
|
|
69251
|
+
this._addHook("beforeHandler", "GET")(path2, hook);
|
|
69252
|
+
this.router.addRoute("GET", path2, handler);
|
|
69141
69253
|
return this;
|
|
69142
69254
|
}
|
|
69143
|
-
post(
|
|
69255
|
+
post(path2, handler, hook) {
|
|
69144
69256
|
if (hook)
|
|
69145
|
-
this._addHook("beforeHandler", "POST")(
|
|
69146
|
-
this.router.addRoute("POST",
|
|
69257
|
+
this._addHook("beforeHandler", "POST")(path2, hook);
|
|
69258
|
+
this.router.addRoute("POST", path2, handler);
|
|
69147
69259
|
return this;
|
|
69148
69260
|
}
|
|
69149
|
-
put(
|
|
69261
|
+
put(path2, handler, hook) {
|
|
69150
69262
|
if (hook)
|
|
69151
|
-
this._addHook("beforeHandler", "PUT")(
|
|
69152
|
-
this.router.addRoute("PUT",
|
|
69263
|
+
this._addHook("beforeHandler", "PUT")(path2, hook);
|
|
69264
|
+
this.router.addRoute("PUT", path2, handler);
|
|
69153
69265
|
return this;
|
|
69154
69266
|
}
|
|
69155
|
-
delete(
|
|
69267
|
+
delete(path2, handler, hook) {
|
|
69156
69268
|
if (hook)
|
|
69157
|
-
this._addHook("beforeHandler", "DELETE")(
|
|
69158
|
-
this.router.addRoute("DELETE",
|
|
69269
|
+
this._addHook("beforeHandler", "DELETE")(path2, hook);
|
|
69270
|
+
this.router.addRoute("DELETE", path2, handler);
|
|
69159
69271
|
return this;
|
|
69160
69272
|
}
|
|
69161
|
-
options(
|
|
69273
|
+
options(path2, handler, hook) {
|
|
69162
69274
|
if (hook)
|
|
69163
|
-
this._addHook("beforeHandler", "OPTIONS")(
|
|
69164
|
-
this.router.addRoute("OPTIONS",
|
|
69275
|
+
this._addHook("beforeHandler", "OPTIONS")(path2, hook);
|
|
69276
|
+
this.router.addRoute("OPTIONS", path2, handler);
|
|
69165
69277
|
return this;
|
|
69166
69278
|
}
|
|
69167
|
-
all(
|
|
69279
|
+
all(path2, handler, hook) {
|
|
69168
69280
|
if (hook) {
|
|
69169
|
-
this.httpMethods.map((method) => this._addHook("beforeHandler", method)(
|
|
69281
|
+
this.httpMethods.map((method) => this._addHook("beforeHandler", method)(path2, hook));
|
|
69170
69282
|
}
|
|
69171
|
-
this.router.addRoute("ALL",
|
|
69283
|
+
this.router.addRoute("ALL", path2, handler);
|
|
69172
69284
|
return this;
|
|
69173
69285
|
}
|
|
69174
69286
|
_addHook = (hook, method) => (arg1, ...handlers) => {
|
|
69175
|
-
let
|
|
69287
|
+
let path2 = arg1;
|
|
69176
69288
|
if (typeof arg1 !== "string") {
|
|
69177
|
-
|
|
69289
|
+
path2 = "*";
|
|
69178
69290
|
handlers.unshift(arg1);
|
|
69179
69291
|
}
|
|
69180
69292
|
handlers.map((handler) => {
|
|
69181
|
-
if (typeof
|
|
69293
|
+
if (typeof path2 === "string")
|
|
69182
69294
|
this.hooks.push({
|
|
69183
|
-
pathname:
|
|
69295
|
+
pathname: path2,
|
|
69184
69296
|
handler,
|
|
69185
69297
|
hook,
|
|
69186
69298
|
method
|
|
@@ -70320,11 +70432,11 @@ function pushComment(node, entity, field, argument) {
|
|
|
70320
70432
|
keys.push(argument);
|
|
70321
70433
|
}
|
|
70322
70434
|
}
|
|
70323
|
-
const
|
|
70324
|
-
if (!commentsRegistry[
|
|
70325
|
-
commentsRegistry[
|
|
70435
|
+
const path2 = keys.join(".");
|
|
70436
|
+
if (!commentsRegistry[path2]) {
|
|
70437
|
+
commentsRegistry[path2] = [];
|
|
70326
70438
|
}
|
|
70327
|
-
commentsRegistry[
|
|
70439
|
+
commentsRegistry[path2].push(comment);
|
|
70328
70440
|
}
|
|
70329
70441
|
function printComment(comment) {
|
|
70330
70442
|
return `
|
|
@@ -70339,9 +70451,9 @@ function hasMultilineItems(maybeArray) {
|
|
|
70339
70451
|
`)) ?? false;
|
|
70340
70452
|
}
|
|
70341
70453
|
function addDescription(cb) {
|
|
70342
|
-
return (node, _key, _parent,
|
|
70454
|
+
return (node, _key, _parent, path2, ancestors) => {
|
|
70343
70455
|
const keys = [];
|
|
70344
|
-
const parent =
|
|
70456
|
+
const parent = path2.reduce((prev, key2) => {
|
|
70345
70457
|
if (["fields", "arguments", "values"].includes(key2) && prev.name) {
|
|
70346
70458
|
keys.push(prev.name.value);
|
|
70347
70459
|
}
|
|
@@ -70352,7 +70464,7 @@ function addDescription(cb) {
|
|
|
70352
70464
|
if (node.kind.includes("Definition") && commentsRegistry[key]) {
|
|
70353
70465
|
items.push(...commentsRegistry[key]);
|
|
70354
70466
|
}
|
|
70355
|
-
return join([...items.map(printComment), node.description, cb(node, _key, _parent,
|
|
70467
|
+
return join([...items.map(printComment), node.description, cb(node, _key, _parent, path2, ancestors)], `
|
|
70356
70468
|
`);
|
|
70357
70469
|
};
|
|
70358
70470
|
}
|
|
@@ -71781,17 +71893,17 @@ function isDocumentNode(object) {
|
|
|
71781
71893
|
function addPath(prev, key, typename) {
|
|
71782
71894
|
return { prev, key, typename };
|
|
71783
71895
|
}
|
|
71784
|
-
function pathToArray(
|
|
71896
|
+
function pathToArray(path2) {
|
|
71785
71897
|
const flattened = [];
|
|
71786
|
-
let curr =
|
|
71898
|
+
let curr = path2;
|
|
71787
71899
|
while (curr) {
|
|
71788
71900
|
flattened.push(curr.key);
|
|
71789
71901
|
curr = curr.prev;
|
|
71790
71902
|
}
|
|
71791
71903
|
return flattened.reverse();
|
|
71792
71904
|
}
|
|
71793
|
-
function printPathArray(
|
|
71794
|
-
return
|
|
71905
|
+
function printPathArray(path2) {
|
|
71906
|
+
return path2.map((key) => typeof key === "number" ? "[" + key.toString() + "]" : "." + key).join("");
|
|
71795
71907
|
}
|
|
71796
71908
|
// ../../node_modules/graphql-yoga/esm/error.js
|
|
71797
71909
|
function isAggregateError(obj) {
|
|
@@ -73302,7 +73414,7 @@ function throwEngineFunctionError(name) {
|
|
|
73302
73414
|
function createEnvelopOrchestrator({ plugins }) {
|
|
73303
73415
|
let schema = null;
|
|
73304
73416
|
let initDone = false;
|
|
73305
|
-
const
|
|
73417
|
+
const parse4 = () => throwEngineFunctionError("parse");
|
|
73306
73418
|
const validate = () => throwEngineFunctionError("validate");
|
|
73307
73419
|
const execute = () => throwEngineFunctionError("execute");
|
|
73308
73420
|
const subscribe = () => throwEngineFunctionError("subscribe");
|
|
@@ -73367,7 +73479,7 @@ function createEnvelopOrchestrator({ plugins }) {
|
|
|
73367
73479
|
};
|
|
73368
73480
|
const customParse = beforeCallbacks.parse.length ? (initialContext) => (source, parseOptions) => {
|
|
73369
73481
|
let result2 = null;
|
|
73370
|
-
let parseFn =
|
|
73482
|
+
let parseFn = parse4;
|
|
73371
73483
|
const context = initialContext;
|
|
73372
73484
|
const afterCalls = [];
|
|
73373
73485
|
for (const onParse of beforeCallbacks.parse) {
|
|
@@ -73414,7 +73526,7 @@ function createEnvelopOrchestrator({ plugins }) {
|
|
|
73414
73526
|
}
|
|
73415
73527
|
documentStringMap.set(result2, source.toString());
|
|
73416
73528
|
return result2;
|
|
73417
|
-
} : () =>
|
|
73529
|
+
} : () => parse4;
|
|
73418
73530
|
const customValidate = beforeCallbacks.validate.length ? (initialContext) => (schema2, documentAST, rules, typeInfo, validationOptions) => {
|
|
73419
73531
|
let actualRules = rules ? [...rules] : undefined;
|
|
73420
73532
|
let validateFn = validate;
|
|
@@ -74019,10 +74131,10 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
|
74019
74131
|
}));
|
|
74020
74132
|
continue;
|
|
74021
74133
|
}
|
|
74022
|
-
coercedValues[varName] = import_graphql42.coerceInputValue(value, varType, (
|
|
74134
|
+
coercedValues[varName] = import_graphql42.coerceInputValue(value, varType, (path2, invalidValue, error) => {
|
|
74023
74135
|
let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
|
|
74024
|
-
if (
|
|
74025
|
-
prefix += ` at "${varName}${printPathArray(
|
|
74136
|
+
if (path2.length > 0) {
|
|
74137
|
+
prefix += ` at "${varName}${printPathArray(path2)}"`;
|
|
74026
74138
|
}
|
|
74027
74139
|
onError(createGraphQLError(prefix + "; " + error.message, {
|
|
74028
74140
|
nodes: varDefNode,
|
|
@@ -74163,22 +74275,22 @@ function executeOperation(exeContext) {
|
|
|
74163
74275
|
});
|
|
74164
74276
|
}
|
|
74165
74277
|
const { fields: rootFields, patches } = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet);
|
|
74166
|
-
const
|
|
74278
|
+
const path2 = undefined;
|
|
74167
74279
|
let result2;
|
|
74168
74280
|
if (operation.operation === "mutation") {
|
|
74169
|
-
result2 = executeFieldsSerially(exeContext, rootType, rootValue,
|
|
74281
|
+
result2 = executeFieldsSerially(exeContext, rootType, rootValue, path2, rootFields);
|
|
74170
74282
|
} else {
|
|
74171
|
-
result2 = executeFields(exeContext, rootType, rootValue,
|
|
74283
|
+
result2 = executeFields(exeContext, rootType, rootValue, path2, rootFields);
|
|
74172
74284
|
}
|
|
74173
74285
|
for (const patch of patches) {
|
|
74174
74286
|
const { label, fields: patchFields } = patch;
|
|
74175
|
-
executeDeferredFragment(exeContext, rootType, rootValue, patchFields, label,
|
|
74287
|
+
executeDeferredFragment(exeContext, rootType, rootValue, patchFields, label, path2);
|
|
74176
74288
|
}
|
|
74177
74289
|
return result2;
|
|
74178
74290
|
}
|
|
74179
|
-
function executeFieldsSerially(exeContext, parentType, sourceValue,
|
|
74291
|
+
function executeFieldsSerially(exeContext, parentType, sourceValue, path2, fields2) {
|
|
74180
74292
|
return promiseReduce(fields2, (results, [responseName, fieldNodes]) => {
|
|
74181
|
-
const fieldPath = addPath(
|
|
74293
|
+
const fieldPath = addPath(path2, responseName, parentType.name);
|
|
74182
74294
|
if (exeContext.signal?.aborted) {
|
|
74183
74295
|
throw exeContext.signal.reason;
|
|
74184
74296
|
}
|
|
@@ -74191,7 +74303,7 @@ function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields
|
|
|
74191
74303
|
});
|
|
74192
74304
|
}, Object.create(null)).resolve();
|
|
74193
74305
|
}
|
|
74194
|
-
function executeFields(exeContext, parentType, sourceValue,
|
|
74306
|
+
function executeFields(exeContext, parentType, sourceValue, path2, fields2, asyncPayloadRecord) {
|
|
74195
74307
|
const results = Object.create(null);
|
|
74196
74308
|
let containsPromise = false;
|
|
74197
74309
|
try {
|
|
@@ -74199,7 +74311,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields2, async
|
|
|
74199
74311
|
if (exeContext.signal?.aborted) {
|
|
74200
74312
|
throw exeContext.signal.reason;
|
|
74201
74313
|
}
|
|
74202
|
-
const fieldPath = addPath(
|
|
74314
|
+
const fieldPath = addPath(path2, responseName, parentType.name);
|
|
74203
74315
|
const result2 = executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath, asyncPayloadRecord);
|
|
74204
74316
|
if (result2 !== undefined) {
|
|
74205
74317
|
results[responseName] = result2;
|
|
@@ -74221,7 +74333,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields2, async
|
|
|
74221
74333
|
}
|
|
74222
74334
|
return promiseForObject(results, exeContext.signal);
|
|
74223
74335
|
}
|
|
74224
|
-
function executeField(exeContext, parentType, source, fieldNodes,
|
|
74336
|
+
function executeField(exeContext, parentType, source, fieldNodes, path2, asyncPayloadRecord) {
|
|
74225
74337
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74226
74338
|
const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]);
|
|
74227
74339
|
if (!fieldDef) {
|
|
@@ -74229,32 +74341,32 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
74229
74341
|
}
|
|
74230
74342
|
const returnType = fieldDef.type;
|
|
74231
74343
|
const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
|
|
74232
|
-
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType,
|
|
74344
|
+
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path2);
|
|
74233
74345
|
try {
|
|
74234
74346
|
const args = getArgumentValues(fieldDef, fieldNodes[0], exeContext.variableValues);
|
|
74235
74347
|
const contextValue = exeContext.contextValue;
|
|
74236
74348
|
const result2 = resolveFn(source, args, contextValue, info);
|
|
74237
74349
|
let completed;
|
|
74238
74350
|
if (isPromise(result2)) {
|
|
74239
|
-
completed = result2.then((resolved) => completeValue(exeContext, returnType, fieldNodes, info,
|
|
74351
|
+
completed = result2.then((resolved) => completeValue(exeContext, returnType, fieldNodes, info, path2, resolved, asyncPayloadRecord));
|
|
74240
74352
|
} else {
|
|
74241
|
-
completed = completeValue(exeContext, returnType, fieldNodes, info,
|
|
74353
|
+
completed = completeValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74242
74354
|
}
|
|
74243
74355
|
if (isPromise(completed)) {
|
|
74244
74356
|
return completed.then(undefined, (rawError) => {
|
|
74245
74357
|
if (rawError instanceof AggregateError) {
|
|
74246
74358
|
return new AggregateError(rawError.errors.map((rawErrorItem) => {
|
|
74247
74359
|
rawErrorItem = coerceError(rawErrorItem);
|
|
74248
|
-
const error2 = import_graphql43.locatedError(rawErrorItem, fieldNodes, pathToArray(
|
|
74360
|
+
const error2 = import_graphql43.locatedError(rawErrorItem, fieldNodes, pathToArray(path2));
|
|
74249
74361
|
const handledError2 = handleFieldError(error2, returnType, errors2);
|
|
74250
|
-
filterSubsequentPayloads(exeContext,
|
|
74362
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74251
74363
|
return handledError2;
|
|
74252
74364
|
}));
|
|
74253
74365
|
}
|
|
74254
74366
|
rawError = coerceError(rawError);
|
|
74255
|
-
const error = import_graphql43.locatedError(rawError, fieldNodes, pathToArray(
|
|
74367
|
+
const error = import_graphql43.locatedError(rawError, fieldNodes, pathToArray(path2));
|
|
74256
74368
|
const handledError = handleFieldError(error, returnType, errors2);
|
|
74257
|
-
filterSubsequentPayloads(exeContext,
|
|
74369
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74258
74370
|
return handledError;
|
|
74259
74371
|
});
|
|
74260
74372
|
}
|
|
@@ -74263,24 +74375,24 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
74263
74375
|
if (rawError instanceof AggregateError) {
|
|
74264
74376
|
return new AggregateError(rawError.errors.map((rawErrorItem) => {
|
|
74265
74377
|
const coercedError2 = coerceError(rawErrorItem);
|
|
74266
|
-
const error2 = import_graphql43.locatedError(coercedError2, fieldNodes, pathToArray(
|
|
74378
|
+
const error2 = import_graphql43.locatedError(coercedError2, fieldNodes, pathToArray(path2));
|
|
74267
74379
|
return handleFieldError(error2, returnType, errors2);
|
|
74268
74380
|
}));
|
|
74269
74381
|
}
|
|
74270
74382
|
const coercedError = coerceError(rawError);
|
|
74271
|
-
const error = import_graphql43.locatedError(coercedError, fieldNodes, pathToArray(
|
|
74383
|
+
const error = import_graphql43.locatedError(coercedError, fieldNodes, pathToArray(path2));
|
|
74272
74384
|
const handledError = handleFieldError(error, returnType, errors2);
|
|
74273
|
-
filterSubsequentPayloads(exeContext,
|
|
74385
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74274
74386
|
return handledError;
|
|
74275
74387
|
}
|
|
74276
74388
|
}
|
|
74277
|
-
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType,
|
|
74389
|
+
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path2) {
|
|
74278
74390
|
return {
|
|
74279
74391
|
fieldName: fieldDef.name,
|
|
74280
74392
|
fieldNodes,
|
|
74281
74393
|
returnType: fieldDef.type,
|
|
74282
74394
|
parentType,
|
|
74283
|
-
path,
|
|
74395
|
+
path: path2,
|
|
74284
74396
|
schema: exeContext.schema,
|
|
74285
74397
|
fragments: exeContext.fragments,
|
|
74286
74398
|
rootValue: exeContext.rootValue,
|
|
@@ -74299,12 +74411,12 @@ function handleFieldError(error, returnType, errors2) {
|
|
|
74299
74411
|
errors2.push(error);
|
|
74300
74412
|
return null;
|
|
74301
74413
|
}
|
|
74302
|
-
function completeValue(exeContext, returnType, fieldNodes, info,
|
|
74414
|
+
function completeValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74303
74415
|
if (result2 instanceof Error) {
|
|
74304
74416
|
throw result2;
|
|
74305
74417
|
}
|
|
74306
74418
|
if (import_graphql43.isNonNullType(returnType)) {
|
|
74307
|
-
const completed = completeValue(exeContext, returnType.ofType, fieldNodes, info,
|
|
74419
|
+
const completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74308
74420
|
if (completed === null) {
|
|
74309
74421
|
throw new Error(`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`);
|
|
74310
74422
|
}
|
|
@@ -74314,21 +74426,21 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result2,
|
|
|
74314
74426
|
return null;
|
|
74315
74427
|
}
|
|
74316
74428
|
if (import_graphql43.isListType(returnType)) {
|
|
74317
|
-
return completeListValue(exeContext, returnType, fieldNodes, info,
|
|
74429
|
+
return completeListValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74318
74430
|
}
|
|
74319
74431
|
if (import_graphql43.isLeafType(returnType)) {
|
|
74320
74432
|
return completeLeafValue(returnType, result2);
|
|
74321
74433
|
}
|
|
74322
74434
|
if (import_graphql43.isAbstractType(returnType)) {
|
|
74323
|
-
return completeAbstractValue(exeContext, returnType, fieldNodes, info,
|
|
74435
|
+
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74324
74436
|
}
|
|
74325
74437
|
if (import_graphql43.isObjectType(returnType)) {
|
|
74326
|
-
return completeObjectValue(exeContext, returnType, fieldNodes, info,
|
|
74438
|
+
return completeObjectValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74327
74439
|
}
|
|
74328
74440
|
console.assert(false, "Cannot complete value of unexpected output type: " + inspect(returnType));
|
|
74329
74441
|
}
|
|
74330
|
-
function getStreamValues(exeContext, fieldNodes,
|
|
74331
|
-
if (typeof
|
|
74442
|
+
function getStreamValues(exeContext, fieldNodes, path2) {
|
|
74443
|
+
if (typeof path2.key === "number") {
|
|
74332
74444
|
return;
|
|
74333
74445
|
}
|
|
74334
74446
|
const stream = import_graphql43.getDirectiveValues(GraphQLStreamDirective, fieldNodes[0], exeContext.variableValues);
|
|
@@ -74345,21 +74457,21 @@ function getStreamValues(exeContext, fieldNodes, path) {
|
|
|
74345
74457
|
label: typeof stream["label"] === "string" ? stream["label"] : undefined
|
|
74346
74458
|
};
|
|
74347
74459
|
}
|
|
74348
|
-
async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info,
|
|
74460
|
+
async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path2, iterator, asyncPayloadRecord) {
|
|
74349
74461
|
exeContext.signal?.addEventListener("abort", () => {
|
|
74350
74462
|
iterator.return?.();
|
|
74351
74463
|
});
|
|
74352
74464
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74353
|
-
const stream = getStreamValues(exeContext, fieldNodes,
|
|
74465
|
+
const stream = getStreamValues(exeContext, fieldNodes, path2);
|
|
74354
74466
|
let containsPromise = false;
|
|
74355
74467
|
const completedResults = [];
|
|
74356
74468
|
let index = 0;
|
|
74357
74469
|
while (true) {
|
|
74358
74470
|
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
74359
|
-
executeStreamIterator(index, iterator, exeContext, fieldNodes, info, itemType,
|
|
74471
|
+
executeStreamIterator(index, iterator, exeContext, fieldNodes, info, itemType, path2, stream.label, asyncPayloadRecord);
|
|
74360
74472
|
break;
|
|
74361
74473
|
}
|
|
74362
|
-
const itemPath = addPath(
|
|
74474
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74363
74475
|
let iteration;
|
|
74364
74476
|
try {
|
|
74365
74477
|
iteration = await iterator.next();
|
|
@@ -74379,25 +74491,25 @@ async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info
|
|
|
74379
74491
|
}
|
|
74380
74492
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
74381
74493
|
}
|
|
74382
|
-
function completeListValue(exeContext, returnType, fieldNodes, info,
|
|
74494
|
+
function completeListValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74383
74495
|
const itemType = returnType.ofType;
|
|
74384
74496
|
const errors2 = asyncPayloadRecord?.errors ?? exeContext.errors;
|
|
74385
74497
|
if (isAsyncIterable(result2)) {
|
|
74386
74498
|
const iterator = result2[Symbol.asyncIterator]();
|
|
74387
|
-
return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info,
|
|
74499
|
+
return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path2, iterator, asyncPayloadRecord);
|
|
74388
74500
|
}
|
|
74389
74501
|
if (!isIterableObject(result2)) {
|
|
74390
74502
|
throw createGraphQLError(`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`);
|
|
74391
74503
|
}
|
|
74392
|
-
const stream = getStreamValues(exeContext, fieldNodes,
|
|
74504
|
+
const stream = getStreamValues(exeContext, fieldNodes, path2);
|
|
74393
74505
|
let containsPromise = false;
|
|
74394
74506
|
let previousAsyncPayloadRecord = asyncPayloadRecord;
|
|
74395
74507
|
const completedResults = [];
|
|
74396
74508
|
let index = 0;
|
|
74397
74509
|
for (const item of result2) {
|
|
74398
|
-
const itemPath = addPath(
|
|
74510
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74399
74511
|
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
74400
|
-
previousAsyncPayloadRecord = executeStreamField(
|
|
74512
|
+
previousAsyncPayloadRecord = executeStreamField(path2, itemPath, item, exeContext, fieldNodes, info, itemType, stream.label, previousAsyncPayloadRecord);
|
|
74401
74513
|
index++;
|
|
74402
74514
|
continue;
|
|
74403
74515
|
}
|
|
@@ -74451,14 +74563,14 @@ function completeLeafValue(returnType, result2) {
|
|
|
74451
74563
|
}
|
|
74452
74564
|
return serializedResult;
|
|
74453
74565
|
}
|
|
74454
|
-
function completeAbstractValue(exeContext, returnType, fieldNodes, info,
|
|
74566
|
+
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74455
74567
|
const resolveTypeFn = returnType.resolveType ?? exeContext.typeResolver;
|
|
74456
74568
|
const contextValue = exeContext.contextValue;
|
|
74457
74569
|
const runtimeType = resolveTypeFn(result2, contextValue, info, returnType);
|
|
74458
74570
|
if (isPromise(runtimeType)) {
|
|
74459
|
-
return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info,
|
|
74571
|
+
return runtimeType.then((resolvedRuntimeType) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info, path2, result2, asyncPayloadRecord));
|
|
74460
74572
|
}
|
|
74461
|
-
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info,
|
|
74573
|
+
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result2), fieldNodes, info, path2, result2, asyncPayloadRecord);
|
|
74462
74574
|
}
|
|
74463
74575
|
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNodes, info, result2) {
|
|
74464
74576
|
if (runtimeTypeName == null) {
|
|
@@ -74485,7 +74597,7 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNo
|
|
|
74485
74597
|
}
|
|
74486
74598
|
return runtimeType;
|
|
74487
74599
|
}
|
|
74488
|
-
function completeObjectValue(exeContext, returnType, fieldNodes, info,
|
|
74600
|
+
function completeObjectValue(exeContext, returnType, fieldNodes, info, path2, result2, asyncPayloadRecord) {
|
|
74489
74601
|
if (returnType.isTypeOf) {
|
|
74490
74602
|
const isTypeOf = returnType.isTypeOf(result2, exeContext.contextValue, info);
|
|
74491
74603
|
if (isPromise(isTypeOf)) {
|
|
@@ -74493,26 +74605,26 @@ function completeObjectValue(exeContext, returnType, fieldNodes, info, path, res
|
|
|
74493
74605
|
if (!resolvedIsTypeOf) {
|
|
74494
74606
|
throw invalidReturnTypeError(returnType, result2, fieldNodes);
|
|
74495
74607
|
}
|
|
74496
|
-
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74608
|
+
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord);
|
|
74497
74609
|
});
|
|
74498
74610
|
}
|
|
74499
74611
|
if (!isTypeOf) {
|
|
74500
74612
|
throw invalidReturnTypeError(returnType, result2, fieldNodes);
|
|
74501
74613
|
}
|
|
74502
74614
|
}
|
|
74503
|
-
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74615
|
+
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord);
|
|
74504
74616
|
}
|
|
74505
74617
|
function invalidReturnTypeError(returnType, result2, fieldNodes) {
|
|
74506
74618
|
return createGraphQLError(`Expected value of type "${returnType.name}" but got: ${inspect(result2)}.`, {
|
|
74507
74619
|
nodes: fieldNodes
|
|
74508
74620
|
});
|
|
74509
74621
|
}
|
|
74510
|
-
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes,
|
|
74622
|
+
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path2, result2, asyncPayloadRecord) {
|
|
74511
74623
|
const { fields: subFieldNodes, patches: subPatches } = collectSubfields2(exeContext, returnType, fieldNodes);
|
|
74512
|
-
const subFields = executeFields(exeContext, returnType, result2,
|
|
74624
|
+
const subFields = executeFields(exeContext, returnType, result2, path2, subFieldNodes, asyncPayloadRecord);
|
|
74513
74625
|
for (const subPatch of subPatches) {
|
|
74514
74626
|
const { label, fields: subPatchFieldNodes } = subPatch;
|
|
74515
|
-
executeDeferredFragment(exeContext, returnType, result2, subPatchFieldNodes, label,
|
|
74627
|
+
executeDeferredFragment(exeContext, returnType, result2, subPatchFieldNodes, label, path2, asyncPayloadRecord);
|
|
74516
74628
|
}
|
|
74517
74629
|
return subFields;
|
|
74518
74630
|
}
|
|
@@ -74662,8 +74774,8 @@ function executeSubscription(exeContext) {
|
|
|
74662
74774
|
nodes: fieldNodes
|
|
74663
74775
|
});
|
|
74664
74776
|
}
|
|
74665
|
-
const
|
|
74666
|
-
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, rootType,
|
|
74777
|
+
const path2 = addPath(undefined, responseName, rootType.name);
|
|
74778
|
+
const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, rootType, path2);
|
|
74667
74779
|
try {
|
|
74668
74780
|
const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues);
|
|
74669
74781
|
const contextValue = exeContext.contextValue;
|
|
@@ -74671,12 +74783,12 @@ function executeSubscription(exeContext) {
|
|
|
74671
74783
|
const result2 = resolveFn(rootValue, args, contextValue, info);
|
|
74672
74784
|
if (isPromise(result2)) {
|
|
74673
74785
|
return result2.then(assertEventStream).then(undefined, (error) => {
|
|
74674
|
-
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(
|
|
74786
|
+
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(path2));
|
|
74675
74787
|
});
|
|
74676
74788
|
}
|
|
74677
74789
|
return assertEventStream(result2, exeContext.signal);
|
|
74678
74790
|
} catch (error) {
|
|
74679
|
-
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(
|
|
74791
|
+
throw import_graphql43.locatedError(error, fieldNodes, pathToArray(path2));
|
|
74680
74792
|
}
|
|
74681
74793
|
}
|
|
74682
74794
|
function assertEventStream(result2, signal) {
|
|
@@ -74696,16 +74808,16 @@ function assertEventStream(result2, signal) {
|
|
|
74696
74808
|
}
|
|
74697
74809
|
};
|
|
74698
74810
|
}
|
|
74699
|
-
function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, label,
|
|
74811
|
+
function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, label, path2, parentContext) {
|
|
74700
74812
|
const asyncPayloadRecord = new DeferredFragmentRecord({
|
|
74701
74813
|
label,
|
|
74702
|
-
path,
|
|
74814
|
+
path: path2,
|
|
74703
74815
|
parentContext,
|
|
74704
74816
|
exeContext
|
|
74705
74817
|
});
|
|
74706
74818
|
let promiseOrData;
|
|
74707
74819
|
try {
|
|
74708
|
-
promiseOrData = executeFields(exeContext, parentType, sourceValue,
|
|
74820
|
+
promiseOrData = executeFields(exeContext, parentType, sourceValue, path2, fields2, asyncPayloadRecord);
|
|
74709
74821
|
if (isPromise(promiseOrData)) {
|
|
74710
74822
|
promiseOrData = promiseOrData.then(null, (e) => {
|
|
74711
74823
|
asyncPayloadRecord.errors.push(e);
|
|
@@ -74718,7 +74830,7 @@ function executeDeferredFragment(exeContext, parentType, sourceValue, fields2, l
|
|
|
74718
74830
|
}
|
|
74719
74831
|
asyncPayloadRecord.addData(promiseOrData);
|
|
74720
74832
|
}
|
|
74721
|
-
function executeStreamField(
|
|
74833
|
+
function executeStreamField(path2, itemPath, item, exeContext, fieldNodes, info, itemType, label, parentContext) {
|
|
74722
74834
|
const asyncPayloadRecord = new StreamRecord({
|
|
74723
74835
|
label,
|
|
74724
74836
|
path: itemPath,
|
|
@@ -74750,7 +74862,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldNodes, info,
|
|
|
74750
74862
|
}
|
|
74751
74863
|
} catch (error) {
|
|
74752
74864
|
asyncPayloadRecord.errors.push(error);
|
|
74753
|
-
filterSubsequentPayloads(exeContext,
|
|
74865
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74754
74866
|
asyncPayloadRecord.addItems(null);
|
|
74755
74867
|
return asyncPayloadRecord;
|
|
74756
74868
|
}
|
|
@@ -74758,7 +74870,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldNodes, info,
|
|
|
74758
74870
|
if (isPromise(completedItem)) {
|
|
74759
74871
|
completedItems = completedItem.then((value) => [value], (error) => {
|
|
74760
74872
|
asyncPayloadRecord.errors.push(error);
|
|
74761
|
-
filterSubsequentPayloads(exeContext,
|
|
74873
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74762
74874
|
return null;
|
|
74763
74875
|
});
|
|
74764
74876
|
} else {
|
|
@@ -74801,11 +74913,11 @@ async function executeStreamIteratorItem(iterator, exeContext, fieldNodes, info,
|
|
|
74801
74913
|
return { done: false, value };
|
|
74802
74914
|
}
|
|
74803
74915
|
}
|
|
74804
|
-
async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType,
|
|
74916
|
+
async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType, path2, label, parentContext) {
|
|
74805
74917
|
let index = initialIndex;
|
|
74806
74918
|
let previousAsyncPayloadRecord = parentContext ?? undefined;
|
|
74807
74919
|
while (true) {
|
|
74808
|
-
const itemPath = addPath(
|
|
74920
|
+
const itemPath = addPath(path2, index, undefined);
|
|
74809
74921
|
const asyncPayloadRecord = new StreamRecord({
|
|
74810
74922
|
label,
|
|
74811
74923
|
path: itemPath,
|
|
@@ -74818,7 +74930,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
|
|
|
74818
74930
|
iteration = await executeStreamIteratorItem(iterator, exeContext, fieldNodes, info, itemType, asyncPayloadRecord, itemPath);
|
|
74819
74931
|
} catch (error) {
|
|
74820
74932
|
asyncPayloadRecord.errors.push(error);
|
|
74821
|
-
filterSubsequentPayloads(exeContext,
|
|
74933
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74822
74934
|
asyncPayloadRecord.addItems(null);
|
|
74823
74935
|
if (iterator?.return) {
|
|
74824
74936
|
iterator.return().catch(() => {
|
|
@@ -74831,7 +74943,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
|
|
|
74831
74943
|
if (isPromise(completedItem)) {
|
|
74832
74944
|
completedItems = completedItem.then((value) => [value], (error) => {
|
|
74833
74945
|
asyncPayloadRecord.errors.push(error);
|
|
74834
|
-
filterSubsequentPayloads(exeContext,
|
|
74946
|
+
filterSubsequentPayloads(exeContext, path2, asyncPayloadRecord);
|
|
74835
74947
|
return null;
|
|
74836
74948
|
});
|
|
74837
74949
|
} else {
|
|
@@ -78605,7 +78717,7 @@ var initializeRoles = async (wabe) => {
|
|
|
78605
78717
|
isRoot: true,
|
|
78606
78718
|
wabe
|
|
78607
78719
|
},
|
|
78608
|
-
|
|
78720
|
+
select: { name: true },
|
|
78609
78721
|
where: {
|
|
78610
78722
|
name: {
|
|
78611
78723
|
in: roles
|
|
@@ -78623,7 +78735,7 @@ var initializeRoles = async (wabe) => {
|
|
|
78623
78735
|
wabe
|
|
78624
78736
|
},
|
|
78625
78737
|
data: objectsToCreate,
|
|
78626
|
-
|
|
78738
|
+
select: {}
|
|
78627
78739
|
});
|
|
78628
78740
|
};
|
|
78629
78741
|
|