wabe 0.5.1 → 0.5.3
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/generated/wabe.d.ts +394 -1
- package/dist/index.d.ts +261 -33
- package/dist/index.js +625 -554
- package/generated/schema.graphql +396 -4
- package/generated/wabe.ts +463 -2
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -58734,361 +58734,6 @@ var require_dist24 = __commonJS((exports) => {
|
|
|
58734
58734
|
exports.isLowerCase = isLowerCase1.isLowerCase;
|
|
58735
58735
|
});
|
|
58736
58736
|
|
|
58737
|
-
// ../../node_modules/@phc/format/index.js
|
|
58738
|
-
var require_format = __commonJS((exports, module) => {
|
|
58739
|
-
function objToKeyVal(obj) {
|
|
58740
|
-
return objectKeys(obj).map((k) => [k, obj[k]].join("=")).join(",");
|
|
58741
|
-
}
|
|
58742
|
-
function keyValtoObj(str) {
|
|
58743
|
-
const obj = {};
|
|
58744
|
-
str.split(",").forEach((ps) => {
|
|
58745
|
-
const pss = ps.split("=");
|
|
58746
|
-
if (pss.length < 2) {
|
|
58747
|
-
throw new TypeError(`params must be in the format name=value`);
|
|
58748
|
-
}
|
|
58749
|
-
obj[pss.shift()] = pss.join("=");
|
|
58750
|
-
});
|
|
58751
|
-
return obj;
|
|
58752
|
-
}
|
|
58753
|
-
function objectKeys(object) {
|
|
58754
|
-
return Object.keys(object);
|
|
58755
|
-
}
|
|
58756
|
-
function objectValues(object) {
|
|
58757
|
-
if (typeof Object.values === "function")
|
|
58758
|
-
return Object.values(object);
|
|
58759
|
-
return objectKeys(object).map((k) => object[k]);
|
|
58760
|
-
}
|
|
58761
|
-
function serialize(opts) {
|
|
58762
|
-
const fields5 = [""];
|
|
58763
|
-
if (typeof opts !== "object" || opts === null) {
|
|
58764
|
-
throw new TypeError("opts must be an object");
|
|
58765
|
-
}
|
|
58766
|
-
if (typeof opts.id !== "string") {
|
|
58767
|
-
throw new TypeError("id must be a string");
|
|
58768
|
-
}
|
|
58769
|
-
if (!idRegex.test(opts.id)) {
|
|
58770
|
-
throw new TypeError(`id must satisfy ${idRegex}`);
|
|
58771
|
-
}
|
|
58772
|
-
fields5.push(opts.id);
|
|
58773
|
-
if (typeof opts.version !== "undefined") {
|
|
58774
|
-
if (typeof opts.version !== "number" || opts.version < 0 || !Number.isInteger(opts.version)) {
|
|
58775
|
-
throw new TypeError("version must be a positive integer number");
|
|
58776
|
-
}
|
|
58777
|
-
fields5.push(`v=${opts.version}`);
|
|
58778
|
-
}
|
|
58779
|
-
if (typeof opts.params !== "undefined") {
|
|
58780
|
-
if (typeof opts.params !== "object" || opts.params === null) {
|
|
58781
|
-
throw new TypeError("params must be an object");
|
|
58782
|
-
}
|
|
58783
|
-
const pk = objectKeys(opts.params);
|
|
58784
|
-
if (!pk.every((p) => nameRegex.test(p))) {
|
|
58785
|
-
throw new TypeError(`params names must satisfy ${nameRegex}`);
|
|
58786
|
-
}
|
|
58787
|
-
pk.forEach((k) => {
|
|
58788
|
-
if (typeof opts.params[k] === "number") {
|
|
58789
|
-
opts.params[k] = opts.params[k].toString();
|
|
58790
|
-
} else if (Buffer.isBuffer(opts.params[k])) {
|
|
58791
|
-
opts.params[k] = opts.params[k].toString("base64").split("=")[0];
|
|
58792
|
-
}
|
|
58793
|
-
});
|
|
58794
|
-
const pv = objectValues(opts.params);
|
|
58795
|
-
if (!pv.every((v) => typeof v === "string")) {
|
|
58796
|
-
throw new TypeError("params values must be strings");
|
|
58797
|
-
}
|
|
58798
|
-
if (!pv.every((v) => valueRegex.test(v))) {
|
|
58799
|
-
throw new TypeError(`params values must satisfy ${valueRegex}`);
|
|
58800
|
-
}
|
|
58801
|
-
const strpar = objToKeyVal(opts.params);
|
|
58802
|
-
fields5.push(strpar);
|
|
58803
|
-
}
|
|
58804
|
-
if (typeof opts.salt !== "undefined") {
|
|
58805
|
-
if (!Buffer.isBuffer(opts.salt)) {
|
|
58806
|
-
throw new TypeError("salt must be a Buffer");
|
|
58807
|
-
}
|
|
58808
|
-
fields5.push(opts.salt.toString("base64").split("=")[0]);
|
|
58809
|
-
if (typeof opts.hash !== "undefined") {
|
|
58810
|
-
if (!Buffer.isBuffer(opts.hash)) {
|
|
58811
|
-
throw new TypeError("hash must be a Buffer");
|
|
58812
|
-
}
|
|
58813
|
-
fields5.push(opts.hash.toString("base64").split("=")[0]);
|
|
58814
|
-
}
|
|
58815
|
-
}
|
|
58816
|
-
const phcstr = fields5.join("$");
|
|
58817
|
-
return phcstr;
|
|
58818
|
-
}
|
|
58819
|
-
function deserialize(phcstr) {
|
|
58820
|
-
if (typeof phcstr !== "string" || phcstr === "") {
|
|
58821
|
-
throw new TypeError("pchstr must be a non-empty string");
|
|
58822
|
-
}
|
|
58823
|
-
if (phcstr[0] !== "$") {
|
|
58824
|
-
throw new TypeError("pchstr must contain a $ as first char");
|
|
58825
|
-
}
|
|
58826
|
-
const fields5 = phcstr.split("$");
|
|
58827
|
-
fields5.shift();
|
|
58828
|
-
let maxf = 5;
|
|
58829
|
-
if (!versionRegex.test(fields5[1]))
|
|
58830
|
-
maxf--;
|
|
58831
|
-
if (fields5.length > maxf) {
|
|
58832
|
-
throw new TypeError(`pchstr contains too many fileds: ${fields5.length}/${maxf}`);
|
|
58833
|
-
}
|
|
58834
|
-
const id = fields5.shift();
|
|
58835
|
-
if (!idRegex.test(id)) {
|
|
58836
|
-
throw new TypeError(`id must satisfy ${idRegex}`);
|
|
58837
|
-
}
|
|
58838
|
-
let version;
|
|
58839
|
-
if (versionRegex.test(fields5[0])) {
|
|
58840
|
-
version = parseInt(fields5.shift().match(versionRegex)[1], 10);
|
|
58841
|
-
}
|
|
58842
|
-
let hash;
|
|
58843
|
-
let salt;
|
|
58844
|
-
if (b64Regex.test(fields5[fields5.length - 1])) {
|
|
58845
|
-
if (fields5.length > 1 && b64Regex.test(fields5[fields5.length - 2])) {
|
|
58846
|
-
hash = Buffer.from(fields5.pop(), "base64");
|
|
58847
|
-
salt = Buffer.from(fields5.pop(), "base64");
|
|
58848
|
-
} else {
|
|
58849
|
-
salt = Buffer.from(fields5.pop(), "base64");
|
|
58850
|
-
}
|
|
58851
|
-
}
|
|
58852
|
-
let params;
|
|
58853
|
-
if (fields5.length > 0) {
|
|
58854
|
-
const parstr = fields5.pop();
|
|
58855
|
-
params = keyValtoObj(parstr);
|
|
58856
|
-
if (!objectKeys(params).every((p) => nameRegex.test(p))) {
|
|
58857
|
-
throw new TypeError(`params names must satisfy ${nameRegex}`);
|
|
58858
|
-
}
|
|
58859
|
-
const pv = objectValues(params);
|
|
58860
|
-
if (!pv.every((v) => valueRegex.test(v))) {
|
|
58861
|
-
throw new TypeError(`params values must satisfy ${valueRegex}`);
|
|
58862
|
-
}
|
|
58863
|
-
const pk = objectKeys(params);
|
|
58864
|
-
pk.forEach((k) => {
|
|
58865
|
-
params[k] = decimalRegex.test(params[k]) ? parseInt(params[k], 10) : params[k];
|
|
58866
|
-
});
|
|
58867
|
-
}
|
|
58868
|
-
if (fields5.length > 0) {
|
|
58869
|
-
throw new TypeError(`pchstr contains unrecognized fileds: ${fields5}`);
|
|
58870
|
-
}
|
|
58871
|
-
const phcobj = { id };
|
|
58872
|
-
if (version)
|
|
58873
|
-
phcobj.version = version;
|
|
58874
|
-
if (params)
|
|
58875
|
-
phcobj.params = params;
|
|
58876
|
-
if (salt)
|
|
58877
|
-
phcobj.salt = salt;
|
|
58878
|
-
if (hash)
|
|
58879
|
-
phcobj.hash = hash;
|
|
58880
|
-
return phcobj;
|
|
58881
|
-
}
|
|
58882
|
-
var idRegex = /^[a-z0-9-]{1,32}$/;
|
|
58883
|
-
var nameRegex = /^[a-z0-9-]{1,32}$/;
|
|
58884
|
-
var valueRegex = /^[a-zA-Z0-9/+.-]+$/;
|
|
58885
|
-
var b64Regex = /^([a-zA-Z0-9/+.-]+|)$/;
|
|
58886
|
-
var decimalRegex = /^((-)?[1-9]\d*|0)$/;
|
|
58887
|
-
var versionRegex = /^v=(\d+)$/;
|
|
58888
|
-
module.exports = {
|
|
58889
|
-
serialize,
|
|
58890
|
-
deserialize
|
|
58891
|
-
};
|
|
58892
|
-
});
|
|
58893
|
-
|
|
58894
|
-
// ../../node_modules/node-gyp-build/node-gyp-build.js
|
|
58895
|
-
var require_node_gyp_build = __commonJS((exports, module) => {
|
|
58896
|
-
function load(dir) {
|
|
58897
|
-
return runtimeRequire(load.resolve(dir));
|
|
58898
|
-
}
|
|
58899
|
-
function readdirSync(dir) {
|
|
58900
|
-
try {
|
|
58901
|
-
return fs.readdirSync(dir);
|
|
58902
|
-
} catch (err) {
|
|
58903
|
-
return [];
|
|
58904
|
-
}
|
|
58905
|
-
}
|
|
58906
|
-
function getFirst(dir, filter) {
|
|
58907
|
-
var files = readdirSync(dir).filter(filter);
|
|
58908
|
-
return files[0] && path.join(dir, files[0]);
|
|
58909
|
-
}
|
|
58910
|
-
function matchBuild(name) {
|
|
58911
|
-
return /\.node$/.test(name);
|
|
58912
|
-
}
|
|
58913
|
-
function parseTuple(name) {
|
|
58914
|
-
var arr = name.split("-");
|
|
58915
|
-
if (arr.length !== 2)
|
|
58916
|
-
return;
|
|
58917
|
-
var platform2 = arr[0];
|
|
58918
|
-
var architectures = arr[1].split("+");
|
|
58919
|
-
if (!platform2)
|
|
58920
|
-
return;
|
|
58921
|
-
if (!architectures.length)
|
|
58922
|
-
return;
|
|
58923
|
-
if (!architectures.every(Boolean))
|
|
58924
|
-
return;
|
|
58925
|
-
return { name, platform: platform2, architectures };
|
|
58926
|
-
}
|
|
58927
|
-
function matchTuple(platform2, arch2) {
|
|
58928
|
-
return function(tuple) {
|
|
58929
|
-
if (tuple == null)
|
|
58930
|
-
return false;
|
|
58931
|
-
if (tuple.platform !== platform2)
|
|
58932
|
-
return false;
|
|
58933
|
-
return tuple.architectures.includes(arch2);
|
|
58934
|
-
};
|
|
58935
|
-
}
|
|
58936
|
-
function compareTuples(a, b) {
|
|
58937
|
-
return a.architectures.length - b.architectures.length;
|
|
58938
|
-
}
|
|
58939
|
-
function parseTags(file) {
|
|
58940
|
-
var arr = file.split(".");
|
|
58941
|
-
var extension = arr.pop();
|
|
58942
|
-
var tags = { file, specificity: 0 };
|
|
58943
|
-
if (extension !== "node")
|
|
58944
|
-
return;
|
|
58945
|
-
for (var i = 0;i < arr.length; i++) {
|
|
58946
|
-
var tag = arr[i];
|
|
58947
|
-
if (tag === "node" || tag === "electron" || tag === "node-webkit") {
|
|
58948
|
-
tags.runtime = tag;
|
|
58949
|
-
} else if (tag === "napi") {
|
|
58950
|
-
tags.napi = true;
|
|
58951
|
-
} else if (tag.slice(0, 3) === "abi") {
|
|
58952
|
-
tags.abi = tag.slice(3);
|
|
58953
|
-
} else if (tag.slice(0, 2) === "uv") {
|
|
58954
|
-
tags.uv = tag.slice(2);
|
|
58955
|
-
} else if (tag.slice(0, 4) === "armv") {
|
|
58956
|
-
tags.armv = tag.slice(4);
|
|
58957
|
-
} else if (tag === "glibc" || tag === "musl") {
|
|
58958
|
-
tags.libc = tag;
|
|
58959
|
-
} else {
|
|
58960
|
-
continue;
|
|
58961
|
-
}
|
|
58962
|
-
tags.specificity++;
|
|
58963
|
-
}
|
|
58964
|
-
return tags;
|
|
58965
|
-
}
|
|
58966
|
-
function matchTags(runtime2, abi2) {
|
|
58967
|
-
return function(tags) {
|
|
58968
|
-
if (tags == null)
|
|
58969
|
-
return false;
|
|
58970
|
-
if (tags.runtime && tags.runtime !== runtime2 && !runtimeAgnostic(tags))
|
|
58971
|
-
return false;
|
|
58972
|
-
if (tags.abi && tags.abi !== abi2 && !tags.napi)
|
|
58973
|
-
return false;
|
|
58974
|
-
if (tags.uv && tags.uv !== uv)
|
|
58975
|
-
return false;
|
|
58976
|
-
if (tags.armv && tags.armv !== armv)
|
|
58977
|
-
return false;
|
|
58978
|
-
if (tags.libc && tags.libc !== libc)
|
|
58979
|
-
return false;
|
|
58980
|
-
return true;
|
|
58981
|
-
};
|
|
58982
|
-
}
|
|
58983
|
-
function runtimeAgnostic(tags) {
|
|
58984
|
-
return tags.runtime === "node" && tags.napi;
|
|
58985
|
-
}
|
|
58986
|
-
function compareTags(runtime2) {
|
|
58987
|
-
return function(a, b) {
|
|
58988
|
-
if (a.runtime !== b.runtime) {
|
|
58989
|
-
return a.runtime === runtime2 ? -1 : 1;
|
|
58990
|
-
} else if (a.abi !== b.abi) {
|
|
58991
|
-
return a.abi ? -1 : 1;
|
|
58992
|
-
} else if (a.specificity !== b.specificity) {
|
|
58993
|
-
return a.specificity > b.specificity ? -1 : 1;
|
|
58994
|
-
} else {
|
|
58995
|
-
return 0;
|
|
58996
|
-
}
|
|
58997
|
-
};
|
|
58998
|
-
}
|
|
58999
|
-
function isNwjs() {
|
|
59000
|
-
return !!(process.versions && process.versions.nw);
|
|
59001
|
-
}
|
|
59002
|
-
function isElectron() {
|
|
59003
|
-
if (process.versions && process.versions.electron)
|
|
59004
|
-
return true;
|
|
59005
|
-
if (process.env.ELECTRON_RUN_AS_NODE)
|
|
59006
|
-
return true;
|
|
59007
|
-
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
|
|
59008
|
-
}
|
|
59009
|
-
function isAlpine(platform2) {
|
|
59010
|
-
return platform2 === "linux" && fs.existsSync("/etc/alpine-release");
|
|
59011
|
-
}
|
|
59012
|
-
var fs = __require("fs");
|
|
59013
|
-
var path = __require("path");
|
|
59014
|
-
var os = __require("os");
|
|
59015
|
-
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
59016
|
-
var vars = process.config && process.config.variables || {};
|
|
59017
|
-
var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
|
|
59018
|
-
var abi = process.versions.modules;
|
|
59019
|
-
var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
|
|
59020
|
-
var arch = process.env.npm_config_arch || os.arch();
|
|
59021
|
-
var platform = process.env.npm_config_platform || os.platform();
|
|
59022
|
-
var libc = process.env.LIBC || (isAlpine(platform) ? "musl" : "glibc");
|
|
59023
|
-
var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
|
|
59024
|
-
var uv = (process.versions.uv || "").split(".")[0];
|
|
59025
|
-
module.exports = load;
|
|
59026
|
-
load.resolve = load.path = function(dir) {
|
|
59027
|
-
dir = path.resolve(dir || ".");
|
|
59028
|
-
try {
|
|
59029
|
-
var name = runtimeRequire(path.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
|
|
59030
|
-
if (process.env[name + "_PREBUILD"])
|
|
59031
|
-
dir = process.env[name + "_PREBUILD"];
|
|
59032
|
-
} catch (err) {
|
|
59033
|
-
}
|
|
59034
|
-
if (!prebuildsOnly) {
|
|
59035
|
-
var release = getFirst(path.join(dir, "build/Release"), matchBuild);
|
|
59036
|
-
if (release)
|
|
59037
|
-
return release;
|
|
59038
|
-
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
59039
|
-
if (debug)
|
|
59040
|
-
return debug;
|
|
59041
|
-
}
|
|
59042
|
-
var prebuild = resolve3(dir);
|
|
59043
|
-
if (prebuild)
|
|
59044
|
-
return prebuild;
|
|
59045
|
-
var nearby = resolve3(path.dirname(process.execPath));
|
|
59046
|
-
if (nearby)
|
|
59047
|
-
return nearby;
|
|
59048
|
-
var target = [
|
|
59049
|
-
"platform=" + platform,
|
|
59050
|
-
"arch=" + arch,
|
|
59051
|
-
"runtime=" + runtime,
|
|
59052
|
-
"abi=" + abi,
|
|
59053
|
-
"uv=" + uv,
|
|
59054
|
-
armv ? "armv=" + armv : "",
|
|
59055
|
-
"libc=" + libc,
|
|
59056
|
-
"node=" + process.versions.node,
|
|
59057
|
-
process.versions.electron ? "electron=" + process.versions.electron : "",
|
|
59058
|
-
typeof __webpack_require__ === "function" ? "webpack=true" : ""
|
|
59059
|
-
].filter(Boolean).join(" ");
|
|
59060
|
-
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
59061
|
-
function resolve3(dir2) {
|
|
59062
|
-
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
59063
|
-
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
59064
|
-
if (!tuple)
|
|
59065
|
-
return;
|
|
59066
|
-
var prebuilds = path.join(dir2, "prebuilds", tuple.name);
|
|
59067
|
-
var parsed = readdirSync(prebuilds).map(parseTags);
|
|
59068
|
-
var candidates = parsed.filter(matchTags(runtime, abi));
|
|
59069
|
-
var winner = candidates.sort(compareTags(runtime))[0];
|
|
59070
|
-
if (winner)
|
|
59071
|
-
return path.join(prebuilds, winner.file);
|
|
59072
|
-
}
|
|
59073
|
-
};
|
|
59074
|
-
load.parseTags = parseTags;
|
|
59075
|
-
load.matchTags = matchTags;
|
|
59076
|
-
load.compareTags = compareTags;
|
|
59077
|
-
load.parseTuple = parseTuple;
|
|
59078
|
-
load.matchTuple = matchTuple;
|
|
59079
|
-
load.compareTuples = compareTuples;
|
|
59080
|
-
});
|
|
59081
|
-
|
|
59082
|
-
// ../../node_modules/node-gyp-build/index.js
|
|
59083
|
-
var require_node_gyp_build2 = __commonJS((exports, module) => {
|
|
59084
|
-
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
59085
|
-
if (typeof runtimeRequire.addon === "function") {
|
|
59086
|
-
module.exports = runtimeRequire.addon.bind(runtimeRequire);
|
|
59087
|
-
} else {
|
|
59088
|
-
module.exports = require_node_gyp_build();
|
|
59089
|
-
}
|
|
59090
|
-
});
|
|
59091
|
-
|
|
59092
58737
|
// ../../node_modules/value-or-promise/build/main/ValueOrPromise.js
|
|
59093
58738
|
var require_ValueOrPromise = __commonJS((exports) => {
|
|
59094
58739
|
function isPromiseLike(object) {
|
|
@@ -62351,12 +61996,12 @@ var require_multipart = __commonJS((exports, module) => {
|
|
|
62351
61996
|
emitClose: true,
|
|
62352
61997
|
highWaterMark: typeof cfg.fileHwm === "number" ? cfg.fileHwm : undefined
|
|
62353
61998
|
};
|
|
62354
|
-
const
|
|
62355
|
-
const fieldSizeLimit =
|
|
62356
|
-
const fileSizeLimit =
|
|
62357
|
-
const filesLimit =
|
|
62358
|
-
const fieldsLimit =
|
|
62359
|
-
const partsLimit =
|
|
61999
|
+
const limits = cfg.limits;
|
|
62000
|
+
const fieldSizeLimit = limits && typeof limits.fieldSize === "number" ? limits.fieldSize : 1 * 1024 * 1024;
|
|
62001
|
+
const fileSizeLimit = limits && typeof limits.fileSize === "number" ? limits.fileSize : Infinity;
|
|
62002
|
+
const filesLimit = limits && typeof limits.files === "number" ? limits.files : Infinity;
|
|
62003
|
+
const fieldsLimit = limits && typeof limits.fields === "number" ? limits.fields : Infinity;
|
|
62004
|
+
const partsLimit = limits && typeof limits.parts === "number" ? limits.parts : Infinity;
|
|
62360
62005
|
let parts = -1;
|
|
62361
62006
|
let fields5 = 0;
|
|
62362
62007
|
let files = 0;
|
|
@@ -63226,10 +62871,10 @@ var require_urlencoded2 = __commonJS((exports, module) => {
|
|
|
63226
62871
|
if (cfg.conType.params && typeof cfg.conType.params.charset === "string")
|
|
63227
62872
|
charset = cfg.conType.params.charset;
|
|
63228
62873
|
this.charset = charset;
|
|
63229
|
-
const
|
|
63230
|
-
this.fieldSizeLimit =
|
|
63231
|
-
this.fieldsLimit =
|
|
63232
|
-
this.fieldNameSizeLimit =
|
|
62874
|
+
const limits = cfg.limits;
|
|
62875
|
+
this.fieldSizeLimit = limits && typeof limits.fieldSize === "number" ? limits.fieldSize : 1 * 1024 * 1024;
|
|
62876
|
+
this.fieldsLimit = limits && typeof limits.fields === "number" ? limits.fields : Infinity;
|
|
62877
|
+
this.fieldNameSizeLimit = limits && typeof limits.fieldNameSize === "number" ? limits.fieldNameSize : 100;
|
|
63233
62878
|
this._inKey = true;
|
|
63234
62879
|
this._keyTrunc = false;
|
|
63235
62880
|
this._valTrunc = false;
|
|
@@ -68057,6 +67702,19 @@ var gql = (chunks, ...variables) => {
|
|
|
68057
67702
|
|
|
68058
67703
|
// src/database/adapters/MongoAdapter.ts
|
|
68059
67704
|
var import_mongodb = __toESM(require_lib5(), 1);
|
|
67705
|
+
var buildMongoOrderQuery = (order) => {
|
|
67706
|
+
if (!order)
|
|
67707
|
+
return {};
|
|
67708
|
+
const objectKeys = Object.keys(order);
|
|
67709
|
+
return objectKeys.reduce((acc, key) => {
|
|
67710
|
+
const value = order[key];
|
|
67711
|
+
if (value === "ASC")
|
|
67712
|
+
acc[key] = 1;
|
|
67713
|
+
if (value === "DESC")
|
|
67714
|
+
acc[key] = -1;
|
|
67715
|
+
return acc;
|
|
67716
|
+
}, {});
|
|
67717
|
+
};
|
|
68060
67718
|
var buildMongoWhereQuery = (where) => {
|
|
68061
67719
|
if (!where)
|
|
68062
67720
|
return {};
|
|
@@ -68176,8 +67834,9 @@ class MongoAdapter {
|
|
|
68176
67834
|
async getObjects(params) {
|
|
68177
67835
|
if (!this.database)
|
|
68178
67836
|
throw new Error("Connection to database is not established");
|
|
68179
|
-
const { className, fields, where, offset, first, context } = params;
|
|
67837
|
+
const { className, fields, where, offset, first, context, order } = params;
|
|
68180
67838
|
const whereBuilded = buildMongoWhereQuery(where);
|
|
67839
|
+
const orderBuilded = buildMongoOrderQuery(order);
|
|
68181
67840
|
const objectOfFieldsToGet = fields?.reduce((acc, prev) => {
|
|
68182
67841
|
acc[prev] = 1;
|
|
68183
67842
|
return acc;
|
|
@@ -68188,7 +67847,7 @@ class MongoAdapter {
|
|
|
68188
67847
|
...objectOfFieldsToGet,
|
|
68189
67848
|
_id: 1
|
|
68190
67849
|
} : {}
|
|
68191
|
-
}).limit(first || 0).skip(offset || 0).toArray();
|
|
67850
|
+
}).limit(first || 0).skip(offset || 0).sort(orderBuilded).toArray();
|
|
68192
67851
|
return res.map((object) => {
|
|
68193
67852
|
const { _id, ...resultWithout_Id } = object;
|
|
68194
67853
|
return {
|
|
@@ -68214,7 +67873,7 @@ class MongoAdapter {
|
|
|
68214
67873
|
async createObjects(params) {
|
|
68215
67874
|
if (!this.database)
|
|
68216
67875
|
throw new Error("Connection to database is not established");
|
|
68217
|
-
const { className, data, fields, offset, first, context } = params;
|
|
67876
|
+
const { className, data, fields, offset, first, context, order } = params;
|
|
68218
67877
|
const collection = await this.createClassIfNotExist(className, context);
|
|
68219
67878
|
const res = await collection.insertMany(data, {});
|
|
68220
67879
|
const orStatement = Object.entries(res.insertedIds).map(([, value]) => ({
|
|
@@ -68226,7 +67885,8 @@ class MongoAdapter {
|
|
|
68226
67885
|
fields,
|
|
68227
67886
|
offset,
|
|
68228
67887
|
first,
|
|
68229
|
-
context
|
|
67888
|
+
context,
|
|
67889
|
+
order
|
|
68230
67890
|
});
|
|
68231
67891
|
return allObjects;
|
|
68232
67892
|
}
|
|
@@ -68255,7 +67915,7 @@ class MongoAdapter {
|
|
|
68255
67915
|
async updateObjects(params) {
|
|
68256
67916
|
if (!this.database)
|
|
68257
67917
|
throw new Error("Connection to database is not established");
|
|
68258
|
-
const { className, where, data, fields, offset, first, context } = params;
|
|
67918
|
+
const { className, where, data, fields, offset, first, context, order } = params;
|
|
68259
67919
|
const whereBuilded = buildMongoWhereQuery(where);
|
|
68260
67920
|
const collection = await this.createClassIfNotExist(className, context);
|
|
68261
67921
|
const objectsBeforeUpdate = await context.wabe.controllers.database.getObjects({
|
|
@@ -68264,7 +67924,8 @@ class MongoAdapter {
|
|
|
68264
67924
|
fields: ["id"],
|
|
68265
67925
|
offset,
|
|
68266
67926
|
first,
|
|
68267
|
-
context
|
|
67927
|
+
context,
|
|
67928
|
+
order
|
|
68268
67929
|
});
|
|
68269
67930
|
if (objectsBeforeUpdate.length === 0)
|
|
68270
67931
|
throw new Error("Object not found");
|
|
@@ -68955,7 +68616,8 @@ class DatabaseController2 {
|
|
|
68955
68616
|
where,
|
|
68956
68617
|
skipHooks,
|
|
68957
68618
|
first,
|
|
68958
|
-
offset
|
|
68619
|
+
offset,
|
|
68620
|
+
order
|
|
68959
68621
|
}) {
|
|
68960
68622
|
const typedFields = fields;
|
|
68961
68623
|
const { pointersFieldsId, pointers } = this._getPointerObject(className, typedFields, context);
|
|
@@ -68980,7 +68642,8 @@ class DatabaseController2 {
|
|
|
68980
68642
|
first,
|
|
68981
68643
|
offset,
|
|
68982
68644
|
where: whereWithACLCondition,
|
|
68983
|
-
fields: fieldsWithPointerFields
|
|
68645
|
+
fields: fieldsWithPointerFields,
|
|
68646
|
+
order
|
|
68984
68647
|
});
|
|
68985
68648
|
objects.map((object) => this.inMemoryCache.set(this._buildCacheKey(className, object.id, fieldsWithPointerFields), object));
|
|
68986
68649
|
await hook?.runOnMultipleObjects({
|
|
@@ -68993,7 +68656,8 @@ class DatabaseController2 {
|
|
|
68993
68656
|
first,
|
|
68994
68657
|
offset,
|
|
68995
68658
|
where: whereWithACLCondition,
|
|
68996
|
-
fields: fieldsWithPointerFields
|
|
68659
|
+
fields: fieldsWithPointerFields,
|
|
68660
|
+
order
|
|
68997
68661
|
});
|
|
68998
68662
|
return Promise.all(objectsToReturn.map((object) => this._getFinalObjectWithPointer(object, pointers, className, context)));
|
|
68999
68663
|
}
|
|
@@ -69035,7 +68699,8 @@ class DatabaseController2 {
|
|
|
69035
68699
|
className,
|
|
69036
68700
|
context,
|
|
69037
68701
|
first,
|
|
69038
|
-
offset
|
|
68702
|
+
offset,
|
|
68703
|
+
order
|
|
69039
68704
|
}) {
|
|
69040
68705
|
if (data.length === 0)
|
|
69041
68706
|
return [];
|
|
@@ -69053,7 +68718,8 @@ class DatabaseController2 {
|
|
|
69053
68718
|
context,
|
|
69054
68719
|
data: arrayOfComputedData,
|
|
69055
68720
|
first,
|
|
69056
|
-
offset
|
|
68721
|
+
offset,
|
|
68722
|
+
order
|
|
69057
68723
|
});
|
|
69058
68724
|
const objectsId = objects.map((object) => object.id);
|
|
69059
68725
|
for (const id of objectsId) {
|
|
@@ -69073,7 +68739,8 @@ class DatabaseController2 {
|
|
|
69073
68739
|
where: { id: { in: objectsId } },
|
|
69074
68740
|
skipHooks: true,
|
|
69075
68741
|
first,
|
|
69076
|
-
offset
|
|
68742
|
+
offset,
|
|
68743
|
+
order
|
|
69077
68744
|
});
|
|
69078
68745
|
return objectsToReturn;
|
|
69079
68746
|
}
|
|
@@ -69120,7 +68787,8 @@ class DatabaseController2 {
|
|
|
69120
68787
|
fields,
|
|
69121
68788
|
data,
|
|
69122
68789
|
first,
|
|
69123
|
-
offset
|
|
68790
|
+
offset,
|
|
68791
|
+
order
|
|
69124
68792
|
}) {
|
|
69125
68793
|
const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
69126
68794
|
const hook = initializeHook({
|
|
@@ -69140,7 +68808,8 @@ class DatabaseController2 {
|
|
|
69140
68808
|
data: newData[0],
|
|
69141
68809
|
where: whereWithACLCondition,
|
|
69142
68810
|
first,
|
|
69143
|
-
offset
|
|
68811
|
+
offset,
|
|
68812
|
+
order
|
|
69144
68813
|
});
|
|
69145
68814
|
const objectsId = objects.map((object) => object.id);
|
|
69146
68815
|
for (const id of objectsId) {
|
|
@@ -69160,7 +68829,8 @@ class DatabaseController2 {
|
|
|
69160
68829
|
where: { id: { in: objectsId } },
|
|
69161
68830
|
skipHooks: true,
|
|
69162
68831
|
first,
|
|
69163
|
-
offset
|
|
68832
|
+
offset,
|
|
68833
|
+
order
|
|
69164
68834
|
});
|
|
69165
68835
|
return objectsToReturn;
|
|
69166
68836
|
}
|
|
@@ -69199,7 +68869,8 @@ class DatabaseController2 {
|
|
|
69199
68869
|
fields,
|
|
69200
68870
|
where,
|
|
69201
68871
|
first,
|
|
69202
|
-
offset
|
|
68872
|
+
offset,
|
|
68873
|
+
order
|
|
69203
68874
|
}) {
|
|
69204
68875
|
const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
|
|
69205
68876
|
const hook = initializeHook({
|
|
@@ -69213,7 +68884,8 @@ class DatabaseController2 {
|
|
|
69213
68884
|
fields,
|
|
69214
68885
|
context,
|
|
69215
68886
|
first,
|
|
69216
|
-
offset
|
|
68887
|
+
offset,
|
|
68888
|
+
order
|
|
69217
68889
|
});
|
|
69218
68890
|
const { objects } = await hook.runOnMultipleObjects({
|
|
69219
68891
|
operationType: "beforeDelete" /* BeforeDelete */,
|
|
@@ -69225,7 +68897,8 @@ class DatabaseController2 {
|
|
|
69225
68897
|
fields,
|
|
69226
68898
|
first,
|
|
69227
68899
|
offset,
|
|
69228
|
-
where: whereWithACLCondition
|
|
68900
|
+
where: whereWithACLCondition,
|
|
68901
|
+
order
|
|
69229
68902
|
});
|
|
69230
68903
|
await hook.runOnMultipleObjects({
|
|
69231
68904
|
operationType: "afterDelete" /* AfterDelete */,
|
|
@@ -69656,6 +69329,89 @@ var verifyChallengeResolver = async (_, {
|
|
|
69656
69329
|
return true;
|
|
69657
69330
|
};
|
|
69658
69331
|
|
|
69332
|
+
// src/payment/interface.ts
|
|
69333
|
+
var Currency;
|
|
69334
|
+
((Currency2) => {
|
|
69335
|
+
Currency2["EUR"] = "eur";
|
|
69336
|
+
Currency2["USD"] = "usd";
|
|
69337
|
+
})(Currency ||= {});
|
|
69338
|
+
var PaymentMode;
|
|
69339
|
+
((PaymentMode2) => {
|
|
69340
|
+
PaymentMode2["Payment"] = "payment";
|
|
69341
|
+
PaymentMode2["Subscription"] = "subscription";
|
|
69342
|
+
})(PaymentMode ||= {});
|
|
69343
|
+
var PaymentReccuringInterval;
|
|
69344
|
+
((PaymentReccuringInterval2) => {
|
|
69345
|
+
PaymentReccuringInterval2["Month"] = "month";
|
|
69346
|
+
PaymentReccuringInterval2["Year"] = "year";
|
|
69347
|
+
})(PaymentReccuringInterval ||= {});
|
|
69348
|
+
// src/schema/resolvers/cancelSubscription.ts
|
|
69349
|
+
var cancelSubscriptionResolver = async (_, { input }, context) => {
|
|
69350
|
+
if (!context.user && !context.isRoot)
|
|
69351
|
+
throw new Error("Permission denied");
|
|
69352
|
+
const paymentController = context.wabe.controllers.payment;
|
|
69353
|
+
if (!paymentController)
|
|
69354
|
+
throw new Error("Payment adapter not defined");
|
|
69355
|
+
return paymentController.cancelSubscription(input);
|
|
69356
|
+
};
|
|
69357
|
+
|
|
69358
|
+
// src/schema/resolvers/makePayment.ts
|
|
69359
|
+
var makePaymentResolver = async (_, { input }, context) => {
|
|
69360
|
+
if (!context.user && !context.isRoot)
|
|
69361
|
+
throw new Error("Permission denied");
|
|
69362
|
+
const paymentController = context.wabe.controllers.payment;
|
|
69363
|
+
if (!paymentController)
|
|
69364
|
+
throw new Error("Payment adapter not defined");
|
|
69365
|
+
const {
|
|
69366
|
+
cancelUrl,
|
|
69367
|
+
successUrl,
|
|
69368
|
+
customerEmail,
|
|
69369
|
+
paymentMode,
|
|
69370
|
+
automaticTax,
|
|
69371
|
+
recurringInterval,
|
|
69372
|
+
products
|
|
69373
|
+
} = input;
|
|
69374
|
+
const email = customerEmail || context.user?.email;
|
|
69375
|
+
if (!email)
|
|
69376
|
+
throw new Error("Customer email is required");
|
|
69377
|
+
const userWithEmail = await context.wabe.controllers.database.getObjects({
|
|
69378
|
+
className: "User",
|
|
69379
|
+
context: {
|
|
69380
|
+
...context,
|
|
69381
|
+
isRoot: true
|
|
69382
|
+
},
|
|
69383
|
+
fields: ["id"],
|
|
69384
|
+
where: {
|
|
69385
|
+
email: {
|
|
69386
|
+
equalTo: email
|
|
69387
|
+
}
|
|
69388
|
+
},
|
|
69389
|
+
first: 1
|
|
69390
|
+
});
|
|
69391
|
+
if (!userWithEmail.length)
|
|
69392
|
+
throw new Error("User not found");
|
|
69393
|
+
const url = await paymentController.createPayment({
|
|
69394
|
+
cancelUrl,
|
|
69395
|
+
successUrl,
|
|
69396
|
+
customerEmail: email,
|
|
69397
|
+
paymentMode,
|
|
69398
|
+
automaticTax: automaticTax ?? false,
|
|
69399
|
+
recurringInterval: recurringInterval ?? "month",
|
|
69400
|
+
products
|
|
69401
|
+
});
|
|
69402
|
+
return url;
|
|
69403
|
+
};
|
|
69404
|
+
|
|
69405
|
+
// src/schema/resolvers/getInvoices.ts
|
|
69406
|
+
var getInvoicesResolver = async (_, { email }, context) => {
|
|
69407
|
+
if (!context.user && !context.isRoot)
|
|
69408
|
+
throw new Error("Permission denied");
|
|
69409
|
+
const paymentController = context.wabe.controllers.payment;
|
|
69410
|
+
if (!paymentController)
|
|
69411
|
+
throw new Error("Payment adapter not defined");
|
|
69412
|
+
return paymentController.getInvoices({ email });
|
|
69413
|
+
};
|
|
69414
|
+
|
|
69659
69415
|
// src/schema/resolvers/meResolver.ts
|
|
69660
69416
|
var meResolver = async (_, __, context) => {
|
|
69661
69417
|
return {
|
|
@@ -69677,6 +69433,166 @@ var sendEmailResolver = async (_, { input }, context) => {
|
|
|
69677
69433
|
});
|
|
69678
69434
|
};
|
|
69679
69435
|
|
|
69436
|
+
// src/schema/defaultResolvers.ts
|
|
69437
|
+
var defaultQueries = {
|
|
69438
|
+
me: {
|
|
69439
|
+
type: "Object",
|
|
69440
|
+
outputObject: {
|
|
69441
|
+
name: "MeOutput",
|
|
69442
|
+
fields: {
|
|
69443
|
+
user: {
|
|
69444
|
+
type: "Pointer",
|
|
69445
|
+
class: "User"
|
|
69446
|
+
}
|
|
69447
|
+
}
|
|
69448
|
+
},
|
|
69449
|
+
resolve: meResolver
|
|
69450
|
+
},
|
|
69451
|
+
getInvoices: {
|
|
69452
|
+
type: "Array",
|
|
69453
|
+
typeValue: "Object",
|
|
69454
|
+
required: true,
|
|
69455
|
+
outputObject: {
|
|
69456
|
+
name: "Invoice",
|
|
69457
|
+
fields: {
|
|
69458
|
+
amountDue: {
|
|
69459
|
+
type: "Int",
|
|
69460
|
+
required: true
|
|
69461
|
+
},
|
|
69462
|
+
amountPaid: {
|
|
69463
|
+
type: "Int",
|
|
69464
|
+
required: true
|
|
69465
|
+
},
|
|
69466
|
+
currency: {
|
|
69467
|
+
type: "Currency",
|
|
69468
|
+
required: true
|
|
69469
|
+
},
|
|
69470
|
+
id: {
|
|
69471
|
+
type: "String",
|
|
69472
|
+
required: true
|
|
69473
|
+
},
|
|
69474
|
+
created: {
|
|
69475
|
+
type: "Int",
|
|
69476
|
+
required: true
|
|
69477
|
+
},
|
|
69478
|
+
invoiceUrl: {
|
|
69479
|
+
type: "String",
|
|
69480
|
+
required: true
|
|
69481
|
+
},
|
|
69482
|
+
isPaid: {
|
|
69483
|
+
type: "Boolean",
|
|
69484
|
+
required: true
|
|
69485
|
+
}
|
|
69486
|
+
}
|
|
69487
|
+
},
|
|
69488
|
+
description: "Get invoices of a customer",
|
|
69489
|
+
args: {
|
|
69490
|
+
email: {
|
|
69491
|
+
type: "Email",
|
|
69492
|
+
required: true
|
|
69493
|
+
}
|
|
69494
|
+
},
|
|
69495
|
+
resolve: getInvoicesResolver
|
|
69496
|
+
}
|
|
69497
|
+
};
|
|
69498
|
+
var defaultMutations = {
|
|
69499
|
+
makePayment: {
|
|
69500
|
+
type: "String",
|
|
69501
|
+
description: "Create a payment with the payment provider. Returns the url to redirect the user to pay",
|
|
69502
|
+
args: {
|
|
69503
|
+
input: {
|
|
69504
|
+
customerEmail: {
|
|
69505
|
+
type: "Email",
|
|
69506
|
+
description: "The payer's email, if not provided, the payer's email will be the user's email that call the mutation."
|
|
69507
|
+
},
|
|
69508
|
+
paymentMode: {
|
|
69509
|
+
type: "PaymentMode",
|
|
69510
|
+
required: true
|
|
69511
|
+
},
|
|
69512
|
+
successUrl: {
|
|
69513
|
+
type: "String",
|
|
69514
|
+
required: true
|
|
69515
|
+
},
|
|
69516
|
+
cancelUrl: {
|
|
69517
|
+
type: "String",
|
|
69518
|
+
required: true
|
|
69519
|
+
},
|
|
69520
|
+
products: {
|
|
69521
|
+
type: "Array",
|
|
69522
|
+
typeValue: "Object",
|
|
69523
|
+
object: {
|
|
69524
|
+
name: "Product",
|
|
69525
|
+
fields: {
|
|
69526
|
+
name: {
|
|
69527
|
+
type: "String",
|
|
69528
|
+
required: true
|
|
69529
|
+
},
|
|
69530
|
+
unitAmount: {
|
|
69531
|
+
type: "Int",
|
|
69532
|
+
required: true
|
|
69533
|
+
},
|
|
69534
|
+
quantity: {
|
|
69535
|
+
type: "Int",
|
|
69536
|
+
required: true
|
|
69537
|
+
}
|
|
69538
|
+
}
|
|
69539
|
+
},
|
|
69540
|
+
required: true,
|
|
69541
|
+
requiredValue: true
|
|
69542
|
+
},
|
|
69543
|
+
automaticTax: {
|
|
69544
|
+
type: "Boolean"
|
|
69545
|
+
},
|
|
69546
|
+
recurringInterval: {
|
|
69547
|
+
type: "PaymentReccuringInterval"
|
|
69548
|
+
}
|
|
69549
|
+
}
|
|
69550
|
+
},
|
|
69551
|
+
resolve: makePaymentResolver
|
|
69552
|
+
},
|
|
69553
|
+
cancelSubscription: {
|
|
69554
|
+
type: "Boolean",
|
|
69555
|
+
args: {
|
|
69556
|
+
input: {
|
|
69557
|
+
email: {
|
|
69558
|
+
type: "Email",
|
|
69559
|
+
required: true
|
|
69560
|
+
}
|
|
69561
|
+
}
|
|
69562
|
+
},
|
|
69563
|
+
resolve: cancelSubscriptionResolver
|
|
69564
|
+
},
|
|
69565
|
+
sendEmail: {
|
|
69566
|
+
type: "String",
|
|
69567
|
+
description: "Send basic email with text and html, returns the id of the email",
|
|
69568
|
+
args: {
|
|
69569
|
+
input: {
|
|
69570
|
+
from: {
|
|
69571
|
+
type: "String",
|
|
69572
|
+
required: true
|
|
69573
|
+
},
|
|
69574
|
+
to: {
|
|
69575
|
+
type: "Array",
|
|
69576
|
+
typeValue: "String",
|
|
69577
|
+
required: true,
|
|
69578
|
+
requiredValue: true
|
|
69579
|
+
},
|
|
69580
|
+
subject: {
|
|
69581
|
+
type: "String",
|
|
69582
|
+
required: true
|
|
69583
|
+
},
|
|
69584
|
+
text: {
|
|
69585
|
+
type: "String"
|
|
69586
|
+
},
|
|
69587
|
+
html: {
|
|
69588
|
+
type: "String"
|
|
69589
|
+
}
|
|
69590
|
+
}
|
|
69591
|
+
},
|
|
69592
|
+
resolve: sendEmailResolver
|
|
69593
|
+
}
|
|
69594
|
+
};
|
|
69595
|
+
|
|
69680
69596
|
// src/schema/Schema.ts
|
|
69681
69597
|
class Schema {
|
|
69682
69598
|
schema;
|
|
@@ -69701,18 +69617,30 @@ class Schema {
|
|
|
69701
69617
|
values: {
|
|
69702
69618
|
EmailOTP: "emailOTP"
|
|
69703
69619
|
}
|
|
69620
|
+
},
|
|
69621
|
+
{
|
|
69622
|
+
name: "PaymentMode",
|
|
69623
|
+
values: Object.fromEntries(Object.values(PaymentMode).map((key) => [key, key]))
|
|
69624
|
+
},
|
|
69625
|
+
{
|
|
69626
|
+
name: "PaymentReccuringInterval",
|
|
69627
|
+
values: Object.fromEntries(Object.values(PaymentReccuringInterval).map((key) => [key, key]))
|
|
69628
|
+
},
|
|
69629
|
+
{
|
|
69630
|
+
name: "Currency",
|
|
69631
|
+
values: Object.fromEntries(Object.values(Currency).map((key) => [key, key]))
|
|
69704
69632
|
}
|
|
69705
69633
|
];
|
|
69706
69634
|
}
|
|
69707
|
-
mergeResolvers(
|
|
69635
|
+
mergeResolvers(defaultResolvers2) {
|
|
69708
69636
|
return {
|
|
69709
69637
|
mutations: {
|
|
69710
69638
|
...this.config.schema?.resolvers?.mutations || {},
|
|
69711
|
-
...
|
|
69639
|
+
...defaultResolvers2.mutations
|
|
69712
69640
|
},
|
|
69713
69641
|
queries: {
|
|
69714
69642
|
...this.config.schema?.resolvers?.queries || {},
|
|
69715
|
-
...
|
|
69643
|
+
...defaultResolvers2.queries
|
|
69716
69644
|
}
|
|
69717
69645
|
};
|
|
69718
69646
|
}
|
|
@@ -69768,51 +69696,9 @@ class Schema {
|
|
|
69768
69696
|
}
|
|
69769
69697
|
};
|
|
69770
69698
|
return {
|
|
69771
|
-
queries:
|
|
69772
|
-
me: {
|
|
69773
|
-
type: "Object",
|
|
69774
|
-
outputObject: {
|
|
69775
|
-
name: "MeOutput",
|
|
69776
|
-
fields: {
|
|
69777
|
-
user: {
|
|
69778
|
-
type: "Pointer",
|
|
69779
|
-
class: "User"
|
|
69780
|
-
}
|
|
69781
|
-
}
|
|
69782
|
-
},
|
|
69783
|
-
resolve: meResolver
|
|
69784
|
-
}
|
|
69785
|
-
},
|
|
69699
|
+
queries: defaultQueries,
|
|
69786
69700
|
mutations: {
|
|
69787
|
-
|
|
69788
|
-
type: "String",
|
|
69789
|
-
description: "Send basic email with text and html, returns the id of the email",
|
|
69790
|
-
args: {
|
|
69791
|
-
input: {
|
|
69792
|
-
from: {
|
|
69793
|
-
type: "String",
|
|
69794
|
-
required: true
|
|
69795
|
-
},
|
|
69796
|
-
to: {
|
|
69797
|
-
type: "Array",
|
|
69798
|
-
typeValue: "String",
|
|
69799
|
-
required: true,
|
|
69800
|
-
requiredValue: true
|
|
69801
|
-
},
|
|
69802
|
-
subject: {
|
|
69803
|
-
type: "String",
|
|
69804
|
-
required: true
|
|
69805
|
-
},
|
|
69806
|
-
text: {
|
|
69807
|
-
type: "String"
|
|
69808
|
-
},
|
|
69809
|
-
html: {
|
|
69810
|
-
type: "String"
|
|
69811
|
-
}
|
|
69812
|
-
}
|
|
69813
|
-
},
|
|
69814
|
-
resolve: sendEmailResolver
|
|
69815
|
-
},
|
|
69701
|
+
...defaultMutations,
|
|
69816
69702
|
...customAuthenticationConfig.length > 0 ? {
|
|
69817
69703
|
signInWith: {
|
|
69818
69704
|
type: "Object",
|
|
@@ -69933,6 +69819,26 @@ class Schema {
|
|
|
69933
69819
|
}
|
|
69934
69820
|
};
|
|
69935
69821
|
}
|
|
69822
|
+
paymentClass() {
|
|
69823
|
+
return {
|
|
69824
|
+
name: "Payment",
|
|
69825
|
+
fields: {
|
|
69826
|
+
user: {
|
|
69827
|
+
type: "Pointer",
|
|
69828
|
+
class: "User",
|
|
69829
|
+
required: true
|
|
69830
|
+
},
|
|
69831
|
+
amount: {
|
|
69832
|
+
type: "Int",
|
|
69833
|
+
required: true
|
|
69834
|
+
},
|
|
69835
|
+
currency: {
|
|
69836
|
+
type: "Currency",
|
|
69837
|
+
required: true
|
|
69838
|
+
}
|
|
69839
|
+
}
|
|
69840
|
+
};
|
|
69841
|
+
}
|
|
69936
69842
|
roleClass() {
|
|
69937
69843
|
return {
|
|
69938
69844
|
name: "Role",
|
|
@@ -70102,7 +70008,8 @@ class Schema {
|
|
|
70102
70008
|
...schema?.classes || [],
|
|
70103
70009
|
this.userClass(),
|
|
70104
70010
|
this.sessionClass(),
|
|
70105
|
-
this.roleClass()
|
|
70011
|
+
this.roleClass(),
|
|
70012
|
+
this.paymentClass()
|
|
70106
70013
|
]);
|
|
70107
70014
|
}
|
|
70108
70015
|
}
|
|
@@ -70779,8 +70686,8 @@ var remove = async ({
|
|
|
70779
70686
|
};
|
|
70780
70687
|
|
|
70781
70688
|
// src/graphql/resolvers.ts
|
|
70782
|
-
var ignoredFields = ["edges", "node"];
|
|
70783
70689
|
var extractFieldsFromSetNode = (selectionSet, className) => {
|
|
70690
|
+
const ignoredFields = ["edges", "node"];
|
|
70784
70691
|
if (className)
|
|
70785
70692
|
ignoredFields.push(firstLetterInLowerCase(className));
|
|
70786
70693
|
return selectionSet.selections?.flatMap((selection) => {
|
|
@@ -70862,6 +70769,11 @@ var executeRelationOnFields = async ({
|
|
|
70862
70769
|
return newAcc;
|
|
70863
70770
|
}, Promise.resolve({}));
|
|
70864
70771
|
};
|
|
70772
|
+
var transformOrder = (order) => order?.reduce((acc, currentOrder) => {
|
|
70773
|
+
const [key, value] = Object.entries(currentOrder)[0];
|
|
70774
|
+
acc[key] = value;
|
|
70775
|
+
return acc;
|
|
70776
|
+
}, {}) || {};
|
|
70865
70777
|
var queryForOneObject = (_, { id }, context, info, className) => {
|
|
70866
70778
|
const fields = getFieldsFromInfo(info, className);
|
|
70867
70779
|
return context.wabe.controllers.database.getObject({
|
|
@@ -70871,7 +70783,7 @@ var queryForOneObject = (_, { id }, context, info, className) => {
|
|
|
70871
70783
|
context
|
|
70872
70784
|
});
|
|
70873
70785
|
};
|
|
70874
|
-
var queryForMultipleObject = async (_, { where, offset, first }, context, info, className) => {
|
|
70786
|
+
var queryForMultipleObject = async (_, { where, offset, first, order }, context, info, className) => {
|
|
70875
70787
|
const fields = getFieldsFromInfo(info, className);
|
|
70876
70788
|
const objects = await context.wabe.controllers.database.getObjects({
|
|
70877
70789
|
className,
|
|
@@ -70879,7 +70791,8 @@ var queryForMultipleObject = async (_, { where, offset, first }, context, info,
|
|
|
70879
70791
|
fields,
|
|
70880
70792
|
offset,
|
|
70881
70793
|
first,
|
|
70882
|
-
context
|
|
70794
|
+
context,
|
|
70795
|
+
order: transformOrder(order)
|
|
70883
70796
|
});
|
|
70884
70797
|
return {
|
|
70885
70798
|
totalCount: fields.includes("totalCount") ? await context.wabe.controllers.database.count({
|
|
@@ -70908,9 +70821,9 @@ var mutationToCreateObject = async (_, args, context, info, className) => {
|
|
|
70908
70821
|
})
|
|
70909
70822
|
};
|
|
70910
70823
|
};
|
|
70911
|
-
var mutationToCreateMultipleObjects = async (_,
|
|
70912
|
-
const
|
|
70913
|
-
const inputFields =
|
|
70824
|
+
var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first, order } }, context, info, className) => {
|
|
70825
|
+
const outputFields = getFieldsFromInfo(info, className);
|
|
70826
|
+
const inputFields = fields;
|
|
70914
70827
|
const updatedFieldsToCreate = await Promise.all(inputFields.map((inputField) => executeRelationOnFields({
|
|
70915
70828
|
className,
|
|
70916
70829
|
fields: inputField,
|
|
@@ -70919,10 +70832,11 @@ var mutationToCreateMultipleObjects = async (_, args, context, info, className)
|
|
|
70919
70832
|
const objects = await context.wabe.controllers.database.createObjects({
|
|
70920
70833
|
className,
|
|
70921
70834
|
data: updatedFieldsToCreate,
|
|
70922
|
-
fields,
|
|
70923
|
-
offset
|
|
70924
|
-
first
|
|
70925
|
-
context
|
|
70835
|
+
fields: outputFields,
|
|
70836
|
+
offset,
|
|
70837
|
+
first,
|
|
70838
|
+
context,
|
|
70839
|
+
order: transformOrder(order)
|
|
70926
70840
|
});
|
|
70927
70841
|
return {
|
|
70928
70842
|
edges: objects.map((object) => ({ node: object }))
|
|
@@ -70947,23 +70861,24 @@ var mutationToUpdateObject = async (_, args, context, info, className) => {
|
|
|
70947
70861
|
})
|
|
70948
70862
|
};
|
|
70949
70863
|
};
|
|
70950
|
-
var mutationToUpdateMultipleObjects = async (_,
|
|
70951
|
-
const
|
|
70864
|
+
var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset, first, order } }, context, info, className) => {
|
|
70865
|
+
const outputFields = getFieldsFromInfo(info, className);
|
|
70952
70866
|
const updatedFields = await executeRelationOnFields({
|
|
70953
70867
|
className,
|
|
70954
|
-
fields
|
|
70868
|
+
fields,
|
|
70955
70869
|
context,
|
|
70956
70870
|
typeOfExecution: "updateMany",
|
|
70957
|
-
where
|
|
70871
|
+
where
|
|
70958
70872
|
});
|
|
70959
70873
|
const objects = await context.wabe.controllers.database.updateObjects({
|
|
70960
70874
|
className,
|
|
70961
|
-
where
|
|
70875
|
+
where,
|
|
70962
70876
|
data: updatedFields,
|
|
70963
|
-
fields,
|
|
70964
|
-
offset
|
|
70965
|
-
first
|
|
70966
|
-
context
|
|
70877
|
+
fields: outputFields,
|
|
70878
|
+
offset,
|
|
70879
|
+
first,
|
|
70880
|
+
context,
|
|
70881
|
+
order
|
|
70967
70882
|
});
|
|
70968
70883
|
return {
|
|
70969
70884
|
edges: objects.map((object) => ({ node: object }))
|
|
@@ -70980,15 +70895,16 @@ var mutationToDeleteObject = async (_, args, context, info, className) => {
|
|
|
70980
70895
|
})
|
|
70981
70896
|
};
|
|
70982
70897
|
};
|
|
70983
|
-
var mutationToDeleteMultipleObjects = async (_,
|
|
70984
|
-
const
|
|
70898
|
+
var mutationToDeleteMultipleObjects = async (_, { input: { where, offset, first, order } }, context, info, className) => {
|
|
70899
|
+
const outputFields = getFieldsFromInfo(info, className);
|
|
70985
70900
|
const objects = await context.wabe.controllers.database.deleteObjects({
|
|
70986
70901
|
className,
|
|
70987
|
-
where
|
|
70988
|
-
fields,
|
|
70989
|
-
offset
|
|
70990
|
-
first
|
|
70991
|
-
context
|
|
70902
|
+
where,
|
|
70903
|
+
fields: outputFields,
|
|
70904
|
+
offset,
|
|
70905
|
+
first,
|
|
70906
|
+
context,
|
|
70907
|
+
order
|
|
70992
70908
|
});
|
|
70993
70909
|
return {
|
|
70994
70910
|
edges: objects.map((object) => ({ node: object }))
|
|
@@ -71024,29 +70940,32 @@ class GraphQLSchema {
|
|
|
71024
70940
|
createInputObject,
|
|
71025
70941
|
updateInputObject,
|
|
71026
70942
|
whereInputObject,
|
|
71027
|
-
connectionObject
|
|
70943
|
+
connectionObject,
|
|
70944
|
+
orderEnumType
|
|
71028
70945
|
} = currentObject;
|
|
71029
|
-
const
|
|
70946
|
+
const defaultQueries2 = this.createDefaultQueries({
|
|
71030
70947
|
className,
|
|
71031
70948
|
whereInputType: whereInputObject,
|
|
71032
70949
|
object,
|
|
71033
|
-
connectionObject
|
|
70950
|
+
connectionObject,
|
|
70951
|
+
orderEnumType
|
|
71034
70952
|
});
|
|
71035
|
-
const
|
|
70953
|
+
const defaultMutations2 = this.createDefaultMutations({
|
|
71036
70954
|
className,
|
|
71037
70955
|
whereInputType: whereInputObject,
|
|
71038
70956
|
object,
|
|
71039
70957
|
connectionObject,
|
|
71040
70958
|
defaultUpdateInputType: updateInputObject,
|
|
71041
|
-
defaultCreateInputType: createInputObject
|
|
70959
|
+
defaultCreateInputType: createInputObject,
|
|
70960
|
+
orderEnumType
|
|
71042
70961
|
});
|
|
71043
|
-
const defaultQueriesKeys = Object.keys(
|
|
71044
|
-
const defaultMutationsKeys = Object.keys(
|
|
70962
|
+
const defaultQueriesKeys = Object.keys(defaultQueries2);
|
|
70963
|
+
const defaultMutationsKeys = Object.keys(defaultMutations2);
|
|
71045
70964
|
for (const key in defaultQueriesKeys) {
|
|
71046
|
-
acc.queries[defaultQueriesKeys[key]] =
|
|
70965
|
+
acc.queries[defaultQueriesKeys[key]] = defaultQueries2[defaultQueriesKeys[key]];
|
|
71047
70966
|
}
|
|
71048
70967
|
for (const key in defaultMutationsKeys) {
|
|
71049
|
-
acc.mutations[defaultMutationsKeys[key]] =
|
|
70968
|
+
acc.mutations[defaultMutationsKeys[key]] = defaultMutations2[defaultMutationsKeys[key]];
|
|
71050
70969
|
}
|
|
71051
70970
|
acc.objects.push(object);
|
|
71052
70971
|
acc.objects.push(inputObject);
|
|
@@ -71083,6 +71002,18 @@ class GraphQLSchema {
|
|
|
71083
71002
|
...scalar
|
|
71084
71003
|
})) || [];
|
|
71085
71004
|
}
|
|
71005
|
+
createOrderEnumType(wabeClass) {
|
|
71006
|
+
const fields = wabeClass.fields;
|
|
71007
|
+
const classEnums = Object.keys(fields).reduce((acc, fieldName) => {
|
|
71008
|
+
acc[`${fieldName}_ASC`] = { value: { [fieldName]: "ASC" } };
|
|
71009
|
+
acc[`${fieldName}_DESC`] = { value: { [fieldName]: "DESC" } };
|
|
71010
|
+
return acc;
|
|
71011
|
+
}, {});
|
|
71012
|
+
return new import_graphql4.GraphQLEnumType({
|
|
71013
|
+
name: `${wabeClass.name}Order`,
|
|
71014
|
+
values: classEnums
|
|
71015
|
+
});
|
|
71016
|
+
}
|
|
71086
71017
|
createEnums() {
|
|
71087
71018
|
return this.schemas.schema.enums?.map((wabeEnum) => {
|
|
71088
71019
|
const enumValues = wabeEnum.values;
|
|
@@ -71288,6 +71219,7 @@ class GraphQLSchema {
|
|
|
71288
71219
|
graphqlParser,
|
|
71289
71220
|
wabeClass
|
|
71290
71221
|
});
|
|
71222
|
+
const orderEnumType = this.createOrderEnumType(wabeClass);
|
|
71291
71223
|
this.allObjects[wabeClass.name] = {
|
|
71292
71224
|
connectionObject,
|
|
71293
71225
|
createInputObject,
|
|
@@ -71296,9 +71228,41 @@ class GraphQLSchema {
|
|
|
71296
71228
|
pointerInputObject,
|
|
71297
71229
|
relationInputObject,
|
|
71298
71230
|
inputObject,
|
|
71299
|
-
object
|
|
71231
|
+
object,
|
|
71232
|
+
orderEnumType
|
|
71300
71233
|
};
|
|
71301
71234
|
}
|
|
71235
|
+
_getGraphQLOutputType(currentQueryOrMutation, graphqlParser, currentArgs) {
|
|
71236
|
+
if (currentQueryOrMutation.type === "Object") {
|
|
71237
|
+
const objectGraphqlParser = graphqlParser({
|
|
71238
|
+
schemaFields: currentQueryOrMutation.outputObject.fields,
|
|
71239
|
+
graphqlObjectType: "Object",
|
|
71240
|
+
allObjects: this.allObjects
|
|
71241
|
+
});
|
|
71242
|
+
return new import_graphql4.GraphQLObjectType({
|
|
71243
|
+
name: currentQueryOrMutation.outputObject.name,
|
|
71244
|
+
fields: () => objectGraphqlParser.getGraphqlFields(currentQueryOrMutation.outputObject.name)
|
|
71245
|
+
});
|
|
71246
|
+
}
|
|
71247
|
+
if (currentQueryOrMutation.type === "Array" && currentQueryOrMutation.typeValue === "Object") {
|
|
71248
|
+
const outputObject = graphqlParser({
|
|
71249
|
+
schemaFields: currentQueryOrMutation.outputObject.fields,
|
|
71250
|
+
graphqlObjectType: "Object",
|
|
71251
|
+
allObjects: this.allObjects
|
|
71252
|
+
});
|
|
71253
|
+
const graphqlObject = new import_graphql4.GraphQLObjectType({
|
|
71254
|
+
name: currentQueryOrMutation.outputObject.name,
|
|
71255
|
+
fields: () => outputObject.getGraphqlFields(currentQueryOrMutation.outputObject.name)
|
|
71256
|
+
});
|
|
71257
|
+
return new import_graphql4.GraphQLList(currentQueryOrMutation.typeValueRequired ? new import_graphql4.GraphQLNonNull(graphqlObject) : graphqlObject);
|
|
71258
|
+
}
|
|
71259
|
+
const graphqlParserWithInput = graphqlParser({
|
|
71260
|
+
schemaFields: currentArgs,
|
|
71261
|
+
graphqlObjectType: "Object",
|
|
71262
|
+
allObjects: this.allObjects
|
|
71263
|
+
});
|
|
71264
|
+
return graphqlParserWithInput.getGraphqlType(currentQueryOrMutation);
|
|
71265
|
+
}
|
|
71302
71266
|
createCustomMutations({
|
|
71303
71267
|
resolvers: resolvers3,
|
|
71304
71268
|
graphqlParser
|
|
@@ -71314,24 +71278,7 @@ class GraphQLSchema {
|
|
|
71314
71278
|
graphqlObjectType: "InputObject",
|
|
71315
71279
|
allObjects: this.allObjects
|
|
71316
71280
|
});
|
|
71317
|
-
const
|
|
71318
|
-
if (currentMutation.type !== "Object")
|
|
71319
|
-
return graphqlParserWithInput.getGraphqlType({
|
|
71320
|
-
...currentMutation
|
|
71321
|
-
});
|
|
71322
|
-
const objectGraphqlParser = graphqlParser({
|
|
71323
|
-
schemaFields: currentMutation.outputObject.fields,
|
|
71324
|
-
graphqlObjectType: "Object",
|
|
71325
|
-
allObjects: this.allObjects
|
|
71326
|
-
});
|
|
71327
|
-
return new import_graphql4.GraphQLObjectType({
|
|
71328
|
-
name: currentMutation.outputObject.name,
|
|
71329
|
-
fields: () => ({
|
|
71330
|
-
...objectGraphqlParser.getGraphqlFields(currentMutation.outputObject.name)
|
|
71331
|
-
})
|
|
71332
|
-
});
|
|
71333
|
-
};
|
|
71334
|
-
const outputType = getGraphqlOutputType();
|
|
71281
|
+
const outputType = this._getGraphQLOutputType(currentMutation, graphqlParser, input);
|
|
71335
71282
|
if (!outputType)
|
|
71336
71283
|
throw new Error("Invalid mutation output type");
|
|
71337
71284
|
const graphqlInput = new import_graphql4.GraphQLInputObjectType({
|
|
@@ -71360,26 +71307,7 @@ class GraphQLSchema {
|
|
|
71360
71307
|
graphqlObjectType: "Object",
|
|
71361
71308
|
allObjects: this.allObjects
|
|
71362
71309
|
});
|
|
71363
|
-
const
|
|
71364
|
-
if (currentQuery.type !== "Object")
|
|
71365
|
-
return graphqlParserWithInput.getGraphqlType({
|
|
71366
|
-
...currentQuery
|
|
71367
|
-
});
|
|
71368
|
-
if (currentQuery.type === "Object") {
|
|
71369
|
-
const objectGraphqlParser = graphqlParser({
|
|
71370
|
-
schemaFields: currentQuery.outputObject.fields,
|
|
71371
|
-
graphqlObjectType: "Object",
|
|
71372
|
-
allObjects: this.allObjects
|
|
71373
|
-
});
|
|
71374
|
-
return new import_graphql4.GraphQLObjectType({
|
|
71375
|
-
name: currentQuery.outputObject.name,
|
|
71376
|
-
fields: () => ({
|
|
71377
|
-
...objectGraphqlParser.getGraphqlFields(currentQuery.outputObject.name)
|
|
71378
|
-
})
|
|
71379
|
-
});
|
|
71380
|
-
}
|
|
71381
|
-
};
|
|
71382
|
-
const outputType = getGraphqlOutputType();
|
|
71310
|
+
const outputType = this._getGraphQLOutputType(currentQuery, graphqlParser, currentArgs);
|
|
71383
71311
|
if (!outputType)
|
|
71384
71312
|
throw new Error("Invalid mutation output type");
|
|
71385
71313
|
acc[currentKey] = {
|
|
@@ -71395,7 +71323,8 @@ class GraphQLSchema {
|
|
|
71395
71323
|
className,
|
|
71396
71324
|
whereInputType,
|
|
71397
71325
|
object,
|
|
71398
|
-
connectionObject
|
|
71326
|
+
connectionObject,
|
|
71327
|
+
orderEnumType
|
|
71399
71328
|
}) {
|
|
71400
71329
|
const classNameWithFirstLetterLowerCase = firstLetterInLowerCase(className);
|
|
71401
71330
|
return {
|
|
@@ -71411,7 +71340,8 @@ class GraphQLSchema {
|
|
|
71411
71340
|
args: {
|
|
71412
71341
|
where: { type: whereInputType },
|
|
71413
71342
|
offset: { type: import_graphql4.GraphQLInt },
|
|
71414
|
-
first: { type: import_graphql4.GraphQLInt }
|
|
71343
|
+
first: { type: import_graphql4.GraphQLInt },
|
|
71344
|
+
order: { type: new import_graphql4.GraphQLList(new import_graphql4.GraphQLNonNull(orderEnumType)) }
|
|
71415
71345
|
},
|
|
71416
71346
|
resolve: (root, args, ctx, info) => queryForMultipleObject(root, args, ctx, info, className)
|
|
71417
71347
|
}
|
|
@@ -71423,7 +71353,8 @@ class GraphQLSchema {
|
|
|
71423
71353
|
defaultUpdateInputType,
|
|
71424
71354
|
defaultCreateInputType,
|
|
71425
71355
|
whereInputType,
|
|
71426
|
-
connectionObject
|
|
71356
|
+
connectionObject,
|
|
71357
|
+
orderEnumType
|
|
71427
71358
|
}) {
|
|
71428
71359
|
const classNameWithFirstLetterLowerCase = firstLetterInLowerCase(className);
|
|
71429
71360
|
const pluralClassName = pluralize(className);
|
|
@@ -71447,7 +71378,8 @@ class GraphQLSchema {
|
|
|
71447
71378
|
type: new import_graphql4.GraphQLNonNull(new import_graphql4.GraphQLList(defaultCreateInputType))
|
|
71448
71379
|
},
|
|
71449
71380
|
offset: { type: import_graphql4.GraphQLInt },
|
|
71450
|
-
first: { type: import_graphql4.GraphQLInt }
|
|
71381
|
+
first: { type: import_graphql4.GraphQLInt },
|
|
71382
|
+
order: { type: new import_graphql4.GraphQLList(orderEnumType) }
|
|
71451
71383
|
})
|
|
71452
71384
|
});
|
|
71453
71385
|
const updatePayloadType = new import_graphql4.GraphQLObjectType({
|
|
@@ -71470,7 +71402,8 @@ class GraphQLSchema {
|
|
|
71470
71402
|
fields: { type: defaultUpdateInputType },
|
|
71471
71403
|
where: { type: whereInputType },
|
|
71472
71404
|
offset: { type: import_graphql4.GraphQLInt },
|
|
71473
|
-
first: { type: import_graphql4.GraphQLInt }
|
|
71405
|
+
first: { type: import_graphql4.GraphQLInt },
|
|
71406
|
+
order: { type: new import_graphql4.GraphQLList(orderEnumType) }
|
|
71474
71407
|
})
|
|
71475
71408
|
});
|
|
71476
71409
|
const deletePayloadType = new import_graphql4.GraphQLObjectType({
|
|
@@ -71489,7 +71422,8 @@ class GraphQLSchema {
|
|
|
71489
71422
|
const deletesInputType = new import_graphql4.GraphQLInputObjectType({
|
|
71490
71423
|
name: `Delete${pluralClassName}Input`,
|
|
71491
71424
|
fields: () => ({
|
|
71492
|
-
where: { type: whereInputType }
|
|
71425
|
+
where: { type: whereInputType },
|
|
71426
|
+
order: { type: new import_graphql4.GraphQLList(orderEnumType) }
|
|
71493
71427
|
})
|
|
71494
71428
|
});
|
|
71495
71429
|
return {
|
|
@@ -71610,6 +71544,44 @@ var authHandler = async (context, wabeContext, provider) => {
|
|
|
71610
71544
|
}
|
|
71611
71545
|
};
|
|
71612
71546
|
|
|
71547
|
+
// src/payment/linkPayment.ts
|
|
71548
|
+
var linkPayment = async (context, email, amount, currency) => {
|
|
71549
|
+
try {
|
|
71550
|
+
const user = await context.wabe.controllers.database.getObjects({
|
|
71551
|
+
className: "User",
|
|
71552
|
+
context: {
|
|
71553
|
+
...context,
|
|
71554
|
+
isRoot: true
|
|
71555
|
+
},
|
|
71556
|
+
fields: ["id"],
|
|
71557
|
+
where: {
|
|
71558
|
+
email: {
|
|
71559
|
+
equalTo: email
|
|
71560
|
+
}
|
|
71561
|
+
},
|
|
71562
|
+
first: 1
|
|
71563
|
+
});
|
|
71564
|
+
if (user.length === 0)
|
|
71565
|
+
return;
|
|
71566
|
+
const userId = user[0].id;
|
|
71567
|
+
await context.wabe.controllers.database.createObject({
|
|
71568
|
+
className: "Payment",
|
|
71569
|
+
context: {
|
|
71570
|
+
...context,
|
|
71571
|
+
isRoot: true
|
|
71572
|
+
},
|
|
71573
|
+
data: {
|
|
71574
|
+
user: userId,
|
|
71575
|
+
amount,
|
|
71576
|
+
currency
|
|
71577
|
+
},
|
|
71578
|
+
fields: []
|
|
71579
|
+
});
|
|
71580
|
+
} catch (err) {
|
|
71581
|
+
console.error(err);
|
|
71582
|
+
}
|
|
71583
|
+
};
|
|
71584
|
+
|
|
71613
71585
|
// src/server/routes/index.ts
|
|
71614
71586
|
var defaultRoutes = () => [
|
|
71615
71587
|
{
|
|
@@ -71628,6 +71600,46 @@ var defaultRoutes = () => [
|
|
|
71628
71600
|
handler: async (context) => {
|
|
71629
71601
|
return oauthHandlerCallback(context, context.wabe);
|
|
71630
71602
|
}
|
|
71603
|
+
},
|
|
71604
|
+
{
|
|
71605
|
+
method: "POST",
|
|
71606
|
+
path: "/webhooks/payment",
|
|
71607
|
+
handler: async (context) => {
|
|
71608
|
+
const body = await context.request.json();
|
|
71609
|
+
switch (body.type) {
|
|
71610
|
+
case "payment_intent.succeeded": {
|
|
71611
|
+
const res = await context.wabe.wabe.controllers.payment?.getCustomerById({
|
|
71612
|
+
id: body.data.object.customer?.id || ""
|
|
71613
|
+
});
|
|
71614
|
+
const customerEmail = res?.email || "";
|
|
71615
|
+
const extractedBody = {
|
|
71616
|
+
created: body.created,
|
|
71617
|
+
currency: body.data.object.currency,
|
|
71618
|
+
amount: body.data.object.amount / 100,
|
|
71619
|
+
billingDetails: body.data.object.shipping,
|
|
71620
|
+
paymentMethodTypes: body.data.object.payment_method_types,
|
|
71621
|
+
customerEmail
|
|
71622
|
+
};
|
|
71623
|
+
if (extractedBody.customerEmail)
|
|
71624
|
+
await linkPayment(context.wabe, extractedBody.customerEmail, extractedBody.amount, extractedBody.currency);
|
|
71625
|
+
await context.wabe.wabe.config.payment?.onPaymentSucceed?.(extractedBody);
|
|
71626
|
+
break;
|
|
71627
|
+
}
|
|
71628
|
+
case "payment_intent.payment_failed": {
|
|
71629
|
+
const extractedBody = {
|
|
71630
|
+
created: body.created,
|
|
71631
|
+
amount: body.data.object.amount / 100,
|
|
71632
|
+
messageError: body.data.object.last_payment_error?.message,
|
|
71633
|
+
paymentMethodTypes: body.data.object.payment_method_types
|
|
71634
|
+
};
|
|
71635
|
+
await context.wabe.wabe.config.payment?.onPaymentFailed?.(extractedBody);
|
|
71636
|
+
break;
|
|
71637
|
+
}
|
|
71638
|
+
default:
|
|
71639
|
+
break;
|
|
71640
|
+
}
|
|
71641
|
+
return context.res.sendJson({ received: true });
|
|
71642
|
+
}
|
|
71631
71643
|
}
|
|
71632
71644
|
];
|
|
71633
71645
|
// ../../node_modules/@graphql-tools/utils/esm/helpers.js
|
|
@@ -80894,40 +80906,9 @@ var generateCodegen = async ({
|
|
|
80894
80906
|
}));
|
|
80895
80907
|
};
|
|
80896
80908
|
|
|
80897
|
-
// ../../node_modules/argon2/argon2.cjs
|
|
80898
|
-
var __dirname = "/home/runner/work/wabe/wabe/node_modules/argon2";
|
|
80899
|
-
var assert = __require("node:assert");
|
|
80900
|
-
var { randomBytes, timingSafeEqual } = __require("node:crypto");
|
|
80901
|
-
var { promisify } = __require("node:util");
|
|
80902
|
-
var { deserialize, serialize } = require_format();
|
|
80903
|
-
var gypBuild = require_node_gyp_build2();
|
|
80904
|
-
var { hash: bindingsHash } = gypBuild(__dirname);
|
|
80905
|
-
var generateSalt = promisify(randomBytes);
|
|
80906
|
-
var argon2d = 0;
|
|
80907
|
-
var argon2i = 1;
|
|
80908
|
-
var argon2id = 2;
|
|
80909
|
-
var types11 = Object.freeze({ argon2d, argon2i, argon2id });
|
|
80910
|
-
var names = Object.freeze({
|
|
80911
|
-
[types11.argon2d]: "argon2d",
|
|
80912
|
-
[types11.argon2i]: "argon2i",
|
|
80913
|
-
[types11.argon2id]: "argon2id"
|
|
80914
|
-
});
|
|
80915
|
-
var defaults = Object.freeze({
|
|
80916
|
-
hashLength: 32,
|
|
80917
|
-
timeCost: 3,
|
|
80918
|
-
memoryCost: 1 << 16,
|
|
80919
|
-
parallelism: 4,
|
|
80920
|
-
type: argon2id,
|
|
80921
|
-
version: 19
|
|
80922
|
-
});
|
|
80923
|
-
var limits = Object.freeze({
|
|
80924
|
-
hashLength: { min: 4, max: 2 ** 32 - 1 },
|
|
80925
|
-
memoryCost: { min: 1 << 10, max: 2 ** 32 - 1 },
|
|
80926
|
-
timeCost: { min: 2, max: 2 ** 32 - 1 },
|
|
80927
|
-
parallelism: { min: 1, max: 2 ** 24 - 1 }
|
|
80928
|
-
});
|
|
80929
|
-
|
|
80930
80909
|
// src/authentication/providers/EmailPassword.ts
|
|
80910
|
+
import"argon2";
|
|
80911
|
+
|
|
80931
80912
|
class EmailPassword {
|
|
80932
80913
|
async onSignIn({
|
|
80933
80914
|
input,
|
|
@@ -87037,9 +87018,23 @@ var initializeRoles = async (wabe) => {
|
|
|
87037
87018
|
const roles = wabe.config?.authentication?.roles || [];
|
|
87038
87019
|
if (roles.length === 0)
|
|
87039
87020
|
return;
|
|
87040
|
-
const
|
|
87041
|
-
|
|
87042
|
-
|
|
87021
|
+
const res = await wabe.controllers.database.getObjects({
|
|
87022
|
+
className: "Role",
|
|
87023
|
+
context: {
|
|
87024
|
+
isRoot: true,
|
|
87025
|
+
wabe
|
|
87026
|
+
},
|
|
87027
|
+
fields: ["name"],
|
|
87028
|
+
where: {
|
|
87029
|
+
name: {
|
|
87030
|
+
in: roles
|
|
87031
|
+
}
|
|
87032
|
+
}
|
|
87033
|
+
});
|
|
87034
|
+
const alreadyCreatedRoles = res.map((role) => role.name);
|
|
87035
|
+
const objectsToCreate = roles.filter((role) => !alreadyCreatedRoles.includes(role)).map((role) => ({ name: role }));
|
|
87036
|
+
if (objectsToCreate.length === 0)
|
|
87037
|
+
return;
|
|
87043
87038
|
await wabe.controllers.database.createObjects({
|
|
87044
87039
|
className: "Role",
|
|
87045
87040
|
context: {
|
|
@@ -87065,6 +87060,49 @@ class EmailController {
|
|
|
87065
87060
|
}
|
|
87066
87061
|
}
|
|
87067
87062
|
|
|
87063
|
+
// src/payment/PaymentController.ts
|
|
87064
|
+
class PaymentController {
|
|
87065
|
+
adapter;
|
|
87066
|
+
config;
|
|
87067
|
+
constructor(paymentConfig) {
|
|
87068
|
+
this.adapter = paymentConfig.adapter;
|
|
87069
|
+
this.config = paymentConfig;
|
|
87070
|
+
}
|
|
87071
|
+
async getCustomerById(options) {
|
|
87072
|
+
return this.adapter.getCustomerById(options);
|
|
87073
|
+
}
|
|
87074
|
+
async initWebhook({ webhookUrl }) {
|
|
87075
|
+
return this.adapter.initWebhook({
|
|
87076
|
+
webhookUrl
|
|
87077
|
+
});
|
|
87078
|
+
}
|
|
87079
|
+
async createCustomer(options) {
|
|
87080
|
+
return this.adapter.createCustomer(options);
|
|
87081
|
+
}
|
|
87082
|
+
async createPayment(options) {
|
|
87083
|
+
return this.adapter.createPayment({
|
|
87084
|
+
...options,
|
|
87085
|
+
currency: this.config.currency,
|
|
87086
|
+
paymentMethod: this.config.supportedPaymentMethods
|
|
87087
|
+
});
|
|
87088
|
+
}
|
|
87089
|
+
async cancelSubscription(options) {
|
|
87090
|
+
return this.adapter.cancelSubscription(options);
|
|
87091
|
+
}
|
|
87092
|
+
async getInvoices(options) {
|
|
87093
|
+
return this.adapter.getInvoices(options);
|
|
87094
|
+
}
|
|
87095
|
+
async getTotalRevenue(options) {
|
|
87096
|
+
return this.adapter.getTotalRevenue(options);
|
|
87097
|
+
}
|
|
87098
|
+
async getAllTransactions(options) {
|
|
87099
|
+
return this.adapter.getAllTransactions(options);
|
|
87100
|
+
}
|
|
87101
|
+
async getHypotheticalSubscriptionRevenue() {
|
|
87102
|
+
return this.adapter.getHypotheticalSubscriptionRevenue();
|
|
87103
|
+
}
|
|
87104
|
+
}
|
|
87105
|
+
|
|
87068
87106
|
// src/server/index.ts
|
|
87069
87107
|
class Wabe {
|
|
87070
87108
|
server;
|
|
@@ -87080,7 +87118,9 @@ class Wabe {
|
|
|
87080
87118
|
hooks: hooks3,
|
|
87081
87119
|
file,
|
|
87082
87120
|
email,
|
|
87083
|
-
|
|
87121
|
+
payment: payment2,
|
|
87122
|
+
routes: routes2,
|
|
87123
|
+
publicUrl
|
|
87084
87124
|
}) {
|
|
87085
87125
|
this.config = {
|
|
87086
87126
|
port,
|
|
@@ -87090,10 +87130,12 @@ class Wabe {
|
|
|
87090
87130
|
authentication: authentication3,
|
|
87091
87131
|
rootKey,
|
|
87092
87132
|
hooks: hooks3,
|
|
87133
|
+
publicUrl,
|
|
87093
87134
|
file: {
|
|
87094
87135
|
adapter: file?.adapter || fileDevAdapter
|
|
87095
87136
|
},
|
|
87096
87137
|
email,
|
|
87138
|
+
payment: payment2,
|
|
87097
87139
|
routes: routes2
|
|
87098
87140
|
};
|
|
87099
87141
|
this.server = new O().get("/health", (context) => {
|
|
@@ -87106,12 +87148,37 @@ class Wabe {
|
|
|
87106
87148
|
});
|
|
87107
87149
|
this.controllers = {
|
|
87108
87150
|
database: new DatabaseController2(databaseAdapter),
|
|
87109
|
-
email: email?.adapter ? new EmailController(email.adapter) : undefined
|
|
87110
|
-
|
|
87151
|
+
email: email?.adapter ? new EmailController(email.adapter) : undefined,
|
|
87152
|
+
payment: payment2?.adapter ? new PaymentController(payment2) : undefined
|
|
87153
|
+
};
|
|
87154
|
+
if (this.controllers.payment) {
|
|
87155
|
+
if (!this.config.publicUrl)
|
|
87156
|
+
throw new Error("publicUrl config is not defined");
|
|
87157
|
+
this.controllers.payment.initWebhook({
|
|
87158
|
+
webhookUrl: `http://${this.config.publicUrl}:${this.config.port}/webhooks/payment`
|
|
87159
|
+
});
|
|
87160
|
+
}
|
|
87161
|
+
this.loadRoleEnum();
|
|
87111
87162
|
this.loadDefaultRoutes();
|
|
87112
87163
|
this.loadHooks();
|
|
87113
87164
|
this.loadAuthenticationMethods();
|
|
87114
87165
|
}
|
|
87166
|
+
loadRoleEnum() {
|
|
87167
|
+
const roles2 = this.config.authentication?.roles || [];
|
|
87168
|
+
if (roles2.length === 0)
|
|
87169
|
+
return;
|
|
87170
|
+
const roleEnum = {
|
|
87171
|
+
name: "RoleEnum",
|
|
87172
|
+
values: roles2.reduce((acc, currentRole) => {
|
|
87173
|
+
acc[currentRole] = { value: currentRole };
|
|
87174
|
+
return acc;
|
|
87175
|
+
}, {})
|
|
87176
|
+
};
|
|
87177
|
+
this.config.schema = {
|
|
87178
|
+
...this.config.schema,
|
|
87179
|
+
enums: [...this.config.schema?.enums || [], roleEnum]
|
|
87180
|
+
};
|
|
87181
|
+
}
|
|
87115
87182
|
loadAuthenticationMethods() {
|
|
87116
87183
|
this.config.authentication = {
|
|
87117
87184
|
...this.config.authentication,
|
|
@@ -87153,17 +87220,17 @@ class Wabe {
|
|
|
87153
87220
|
const wabeSchema = new Schema(this.config);
|
|
87154
87221
|
this.config.schema = wabeSchema.schema;
|
|
87155
87222
|
const graphqlSchema = new GraphQLSchema(wabeSchema);
|
|
87156
|
-
const
|
|
87223
|
+
const types11 = graphqlSchema.createSchema();
|
|
87157
87224
|
const schema3 = new import_graphql86.GraphQLSchema({
|
|
87158
87225
|
query: new import_graphql86.GraphQLObjectType({
|
|
87159
87226
|
name: "Query",
|
|
87160
|
-
fields:
|
|
87227
|
+
fields: types11.queries
|
|
87161
87228
|
}),
|
|
87162
87229
|
mutation: new import_graphql86.GraphQLObjectType({
|
|
87163
87230
|
name: "Mutation",
|
|
87164
|
-
fields:
|
|
87231
|
+
fields: types11.mutations
|
|
87165
87232
|
}),
|
|
87166
|
-
types: [...
|
|
87233
|
+
types: [...types11.scalars, ...types11.enums, ...types11.objects]
|
|
87167
87234
|
});
|
|
87168
87235
|
if (this.config.codegen && this.config.codegen.enabled && this.config.codegen.path) {
|
|
87169
87236
|
await generateCodegen({
|
|
@@ -87274,15 +87341,19 @@ export {
|
|
|
87274
87341
|
getDefaultHooks,
|
|
87275
87342
|
generateCodegen,
|
|
87276
87343
|
buildMongoWhereQuery,
|
|
87344
|
+
buildMongoOrderQuery,
|
|
87277
87345
|
_findHooksByPriority,
|
|
87278
87346
|
Wabe,
|
|
87279
87347
|
Schema,
|
|
87280
87348
|
ProviderEnum,
|
|
87349
|
+
PaymentReccuringInterval,
|
|
87350
|
+
PaymentMode,
|
|
87281
87351
|
OperationType,
|
|
87282
87352
|
OAuth2Client,
|
|
87283
87353
|
MongoAdapter,
|
|
87284
87354
|
Google,
|
|
87285
87355
|
DatabaseEnum,
|
|
87286
87356
|
DatabaseController2 as DatabaseController,
|
|
87357
|
+
Currency,
|
|
87287
87358
|
AuthenticationProvider
|
|
87288
87359
|
};
|