wabe 0.5.20 → 0.5.22

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.js CHANGED
@@ -43364,6 +43364,223 @@ var require_lib5 = __commonJS((exports) => {
43364
43364
  } });
43365
43365
  });
43366
43366
 
43367
+ // ../../node_modules/retry/lib/retry_operation.js
43368
+ var require_retry_operation = __commonJS((exports, module) => {
43369
+ function RetryOperation(timeouts, options) {
43370
+ if (typeof options === "boolean") {
43371
+ options = { forever: options };
43372
+ }
43373
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
43374
+ this._timeouts = timeouts;
43375
+ this._options = options || {};
43376
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
43377
+ this._fn = null;
43378
+ this._errors = [];
43379
+ this._attempts = 1;
43380
+ this._operationTimeout = null;
43381
+ this._operationTimeoutCb = null;
43382
+ this._timeout = null;
43383
+ this._operationStart = null;
43384
+ this._timer = null;
43385
+ if (this._options.forever) {
43386
+ this._cachedTimeouts = this._timeouts.slice(0);
43387
+ }
43388
+ }
43389
+ module.exports = RetryOperation;
43390
+ RetryOperation.prototype.reset = function() {
43391
+ this._attempts = 1;
43392
+ this._timeouts = this._originalTimeouts.slice(0);
43393
+ };
43394
+ RetryOperation.prototype.stop = function() {
43395
+ if (this._timeout) {
43396
+ clearTimeout(this._timeout);
43397
+ }
43398
+ if (this._timer) {
43399
+ clearTimeout(this._timer);
43400
+ }
43401
+ this._timeouts = [];
43402
+ this._cachedTimeouts = null;
43403
+ };
43404
+ RetryOperation.prototype.retry = function(err) {
43405
+ if (this._timeout) {
43406
+ clearTimeout(this._timeout);
43407
+ }
43408
+ if (!err) {
43409
+ return false;
43410
+ }
43411
+ var currentTime = new Date().getTime();
43412
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
43413
+ this._errors.push(err);
43414
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
43415
+ return false;
43416
+ }
43417
+ this._errors.push(err);
43418
+ var timeout = this._timeouts.shift();
43419
+ if (timeout === undefined) {
43420
+ if (this._cachedTimeouts) {
43421
+ this._errors.splice(0, this._errors.length - 1);
43422
+ timeout = this._cachedTimeouts.slice(-1);
43423
+ } else {
43424
+ return false;
43425
+ }
43426
+ }
43427
+ var self2 = this;
43428
+ this._timer = setTimeout(function() {
43429
+ self2._attempts++;
43430
+ if (self2._operationTimeoutCb) {
43431
+ self2._timeout = setTimeout(function() {
43432
+ self2._operationTimeoutCb(self2._attempts);
43433
+ }, self2._operationTimeout);
43434
+ if (self2._options.unref) {
43435
+ self2._timeout.unref();
43436
+ }
43437
+ }
43438
+ self2._fn(self2._attempts);
43439
+ }, timeout);
43440
+ if (this._options.unref) {
43441
+ this._timer.unref();
43442
+ }
43443
+ return true;
43444
+ };
43445
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
43446
+ this._fn = fn;
43447
+ if (timeoutOps) {
43448
+ if (timeoutOps.timeout) {
43449
+ this._operationTimeout = timeoutOps.timeout;
43450
+ }
43451
+ if (timeoutOps.cb) {
43452
+ this._operationTimeoutCb = timeoutOps.cb;
43453
+ }
43454
+ }
43455
+ var self2 = this;
43456
+ if (this._operationTimeoutCb) {
43457
+ this._timeout = setTimeout(function() {
43458
+ self2._operationTimeoutCb();
43459
+ }, self2._operationTimeout);
43460
+ }
43461
+ this._operationStart = new Date().getTime();
43462
+ this._fn(this._attempts);
43463
+ };
43464
+ RetryOperation.prototype.try = function(fn) {
43465
+ console.log("Using RetryOperation.try() is deprecated");
43466
+ this.attempt(fn);
43467
+ };
43468
+ RetryOperation.prototype.start = function(fn) {
43469
+ console.log("Using RetryOperation.start() is deprecated");
43470
+ this.attempt(fn);
43471
+ };
43472
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
43473
+ RetryOperation.prototype.errors = function() {
43474
+ return this._errors;
43475
+ };
43476
+ RetryOperation.prototype.attempts = function() {
43477
+ return this._attempts;
43478
+ };
43479
+ RetryOperation.prototype.mainError = function() {
43480
+ if (this._errors.length === 0) {
43481
+ return null;
43482
+ }
43483
+ var counts = {};
43484
+ var mainError = null;
43485
+ var mainErrorCount = 0;
43486
+ for (var i = 0;i < this._errors.length; i++) {
43487
+ var error = this._errors[i];
43488
+ var message = error.message;
43489
+ var count = (counts[message] || 0) + 1;
43490
+ counts[message] = count;
43491
+ if (count >= mainErrorCount) {
43492
+ mainError = error;
43493
+ mainErrorCount = count;
43494
+ }
43495
+ }
43496
+ return mainError;
43497
+ };
43498
+ });
43499
+
43500
+ // ../../node_modules/retry/lib/retry.js
43501
+ var require_retry = __commonJS((exports) => {
43502
+ var RetryOperation = require_retry_operation();
43503
+ exports.operation = function(options) {
43504
+ var timeouts = exports.timeouts(options);
43505
+ return new RetryOperation(timeouts, {
43506
+ forever: options && (options.forever || options.retries === Infinity),
43507
+ unref: options && options.unref,
43508
+ maxRetryTime: options && options.maxRetryTime
43509
+ });
43510
+ };
43511
+ exports.timeouts = function(options) {
43512
+ if (options instanceof Array) {
43513
+ return [].concat(options);
43514
+ }
43515
+ var opts = {
43516
+ retries: 10,
43517
+ factor: 2,
43518
+ minTimeout: 1 * 1000,
43519
+ maxTimeout: Infinity,
43520
+ randomize: false
43521
+ };
43522
+ for (var key in options) {
43523
+ opts[key] = options[key];
43524
+ }
43525
+ if (opts.minTimeout > opts.maxTimeout) {
43526
+ throw new Error("minTimeout is greater than maxTimeout");
43527
+ }
43528
+ var timeouts = [];
43529
+ for (var i = 0;i < opts.retries; i++) {
43530
+ timeouts.push(this.createTimeout(i, opts));
43531
+ }
43532
+ if (options && options.forever && !timeouts.length) {
43533
+ timeouts.push(this.createTimeout(i, opts));
43534
+ }
43535
+ timeouts.sort(function(a, b) {
43536
+ return a - b;
43537
+ });
43538
+ return timeouts;
43539
+ };
43540
+ exports.createTimeout = function(attempt, opts) {
43541
+ var random = opts.randomize ? Math.random() + 1 : 1;
43542
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
43543
+ timeout = Math.min(timeout, opts.maxTimeout);
43544
+ return timeout;
43545
+ };
43546
+ exports.wrap = function(obj, options, methods) {
43547
+ if (options instanceof Array) {
43548
+ methods = options;
43549
+ options = null;
43550
+ }
43551
+ if (!methods) {
43552
+ methods = [];
43553
+ for (var key in obj) {
43554
+ if (typeof obj[key] === "function") {
43555
+ methods.push(key);
43556
+ }
43557
+ }
43558
+ }
43559
+ for (var i = 0;i < methods.length; i++) {
43560
+ var method = methods[i];
43561
+ var original = obj[method];
43562
+ obj[method] = function retryWrapper(original2) {
43563
+ var op = exports.operation(options);
43564
+ var args = Array.prototype.slice.call(arguments, 1);
43565
+ var callback = args.pop();
43566
+ args.push(function(err) {
43567
+ if (op.retry(err)) {
43568
+ return;
43569
+ }
43570
+ if (err) {
43571
+ arguments[0] = op.mainError();
43572
+ }
43573
+ callback.apply(this, arguments);
43574
+ });
43575
+ op.attempt(function() {
43576
+ original2.apply(obj, args);
43577
+ });
43578
+ }.bind(obj, original);
43579
+ obj[method].options = options;
43580
+ }
43581
+ };
43582
+ });
43583
+
43367
43584
  // ../../node_modules/safe-buffer/index.js
43368
43585
  var require_safe_buffer = __commonJS((exports, module) => {
43369
43586
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -46389,7 +46606,7 @@ var require_lodash = __commonJS((exports, module) => {
46389
46606
  }
46390
46607
  var objectProto = Object.prototype;
46391
46608
  var hasOwnProperty = objectProto.hasOwnProperty;
46392
- var objectToString = objectProto.toString;
46609
+ var objectToString2 = objectProto.toString;
46393
46610
  var propertyIsEnumerable = objectProto.propertyIsEnumerable;
46394
46611
  var nativeKeys = overArg(Object.keys, Object);
46395
46612
  var nativeMax = Math.max;
@@ -46433,7 +46650,7 @@ var require_lodash = __commonJS((exports, module) => {
46433
46650
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
46434
46651
  }
46435
46652
  function isArguments(value) {
46436
- return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag);
46653
+ return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString2.call(value) == argsTag);
46437
46654
  }
46438
46655
  var isArray = Array.isArray;
46439
46656
  function isArrayLike(value) {
@@ -46443,7 +46660,7 @@ var require_lodash = __commonJS((exports, module) => {
46443
46660
  return isObjectLike(value) && isArrayLike(value);
46444
46661
  }
46445
46662
  function isFunction(value) {
46446
- var tag = isObject(value) ? objectToString.call(value) : "";
46663
+ var tag = isObject(value) ? objectToString2.call(value) : "";
46447
46664
  return tag == funcTag || tag == genTag;
46448
46665
  }
46449
46666
  function isLength(value) {
@@ -46457,10 +46674,10 @@ var require_lodash = __commonJS((exports, module) => {
46457
46674
  return !!value && typeof value == "object";
46458
46675
  }
46459
46676
  function isString(value) {
46460
- return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
46677
+ return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString2.call(value) == stringTag;
46461
46678
  }
46462
46679
  function isSymbol(value) {
46463
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
46680
+ return typeof value == "symbol" || isObjectLike(value) && objectToString2.call(value) == symbolTag;
46464
46681
  }
46465
46682
  function toFinite(value) {
46466
46683
  if (!value) {
@@ -46508,9 +46725,9 @@ var require_lodash = __commonJS((exports, module) => {
46508
46725
  var require_lodash2 = __commonJS((exports, module) => {
46509
46726
  var boolTag = "[object Boolean]";
46510
46727
  var objectProto = Object.prototype;
46511
- var objectToString = objectProto.toString;
46728
+ var objectToString2 = objectProto.toString;
46512
46729
  function isBoolean(value) {
46513
- return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag;
46730
+ return value === true || value === false || isObjectLike(value) && objectToString2.call(value) == boolTag;
46514
46731
  }
46515
46732
  function isObjectLike(value) {
46516
46733
  return !!value && typeof value == "object";
@@ -46530,7 +46747,7 @@ var require_lodash3 = __commonJS((exports, module) => {
46530
46747
  var reIsOctal = /^0o[0-7]+$/i;
46531
46748
  var freeParseInt = parseInt;
46532
46749
  var objectProto = Object.prototype;
46533
- var objectToString = objectProto.toString;
46750
+ var objectToString2 = objectProto.toString;
46534
46751
  function isInteger(value) {
46535
46752
  return typeof value == "number" && value == toInteger(value);
46536
46753
  }
@@ -46542,7 +46759,7 @@ var require_lodash3 = __commonJS((exports, module) => {
46542
46759
  return !!value && typeof value == "object";
46543
46760
  }
46544
46761
  function isSymbol(value) {
46545
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
46762
+ return typeof value == "symbol" || isObjectLike(value) && objectToString2.call(value) == symbolTag;
46546
46763
  }
46547
46764
  function toFinite(value) {
46548
46765
  if (!value) {
@@ -46584,12 +46801,12 @@ var require_lodash3 = __commonJS((exports, module) => {
46584
46801
  var require_lodash4 = __commonJS((exports, module) => {
46585
46802
  var numberTag = "[object Number]";
46586
46803
  var objectProto = Object.prototype;
46587
- var objectToString = objectProto.toString;
46804
+ var objectToString2 = objectProto.toString;
46588
46805
  function isObjectLike(value) {
46589
46806
  return !!value && typeof value == "object";
46590
46807
  }
46591
46808
  function isNumber(value) {
46592
- return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag;
46809
+ return typeof value == "number" || isObjectLike(value) && objectToString2.call(value) == numberTag;
46593
46810
  }
46594
46811
  module.exports = isNumber;
46595
46812
  });
@@ -46617,13 +46834,13 @@ var require_lodash5 = __commonJS((exports, module) => {
46617
46834
  var funcToString = funcProto.toString;
46618
46835
  var hasOwnProperty = objectProto.hasOwnProperty;
46619
46836
  var objectCtorString = funcToString.call(Object);
46620
- var objectToString = objectProto.toString;
46837
+ var objectToString2 = objectProto.toString;
46621
46838
  var getPrototype = overArg(Object.getPrototypeOf, Object);
46622
46839
  function isObjectLike(value) {
46623
46840
  return !!value && typeof value == "object";
46624
46841
  }
46625
46842
  function isPlainObject(value) {
46626
- if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
46843
+ if (!isObjectLike(value) || objectToString2.call(value) != objectTag || isHostObject(value)) {
46627
46844
  return false;
46628
46845
  }
46629
46846
  var proto = getPrototype(value);
@@ -46640,13 +46857,13 @@ var require_lodash5 = __commonJS((exports, module) => {
46640
46857
  var require_lodash6 = __commonJS((exports, module) => {
46641
46858
  var stringTag = "[object String]";
46642
46859
  var objectProto = Object.prototype;
46643
- var objectToString = objectProto.toString;
46860
+ var objectToString2 = objectProto.toString;
46644
46861
  var isArray = Array.isArray;
46645
46862
  function isObjectLike(value) {
46646
46863
  return !!value && typeof value == "object";
46647
46864
  }
46648
46865
  function isString(value) {
46649
- return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
46866
+ return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString2.call(value) == stringTag;
46650
46867
  }
46651
46868
  module.exports = isString;
46652
46869
  });
@@ -46664,7 +46881,7 @@ var require_lodash7 = __commonJS((exports, module) => {
46664
46881
  var reIsOctal = /^0o[0-7]+$/i;
46665
46882
  var freeParseInt = parseInt;
46666
46883
  var objectProto = Object.prototype;
46667
- var objectToString = objectProto.toString;
46884
+ var objectToString2 = objectProto.toString;
46668
46885
  function before(n, func) {
46669
46886
  var result;
46670
46887
  if (typeof func != "function") {
@@ -46692,7 +46909,7 @@ var require_lodash7 = __commonJS((exports, module) => {
46692
46909
  return !!value && typeof value == "object";
46693
46910
  }
46694
46911
  function isSymbol(value) {
46695
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
46912
+ return typeof value == "symbol" || isObjectLike(value) && objectToString2.call(value) == symbolTag;
46696
46913
  }
46697
46914
  function toFinite(value) {
46698
46915
  if (!value) {
@@ -60350,6 +60567,12 @@ var handleFile = async (hookObject) => {
60350
60567
  var defaultBeforeCreateUpload = (hookObject) => handleFile(hookObject);
60351
60568
  var defaultBeforeUpdateUpload = (hookObject) => handleFile(hookObject);
60352
60569
 
60570
+ // src/utils/export.ts
60571
+ var contextWithRoot = (context) => ({
60572
+ ...context,
60573
+ isRoot: true
60574
+ });
60575
+
60353
60576
  // src/hooks/HookObject.ts
60354
60577
  class HookObject {
60355
60578
  className;
@@ -61192,6 +61415,110 @@ var gql = (chunks, ...variables) => {
61192
61415
 
61193
61416
  // src/database/adapters/MongoAdapter.ts
61194
61417
  var import_mongodb = __toESM(require_lib5(), 1);
61418
+
61419
+ // ../../node_modules/p-retry/index.js
61420
+ var import_retry = __toESM(require_retry(), 1);
61421
+
61422
+ // ../../node_modules/is-network-error/index.js
61423
+ var objectToString = Object.prototype.toString;
61424
+ var isError = (value) => objectToString.call(value) === "[object Error]";
61425
+ var errorMessages = new Set([
61426
+ "network error",
61427
+ "Failed to fetch",
61428
+ "NetworkError when attempting to fetch resource.",
61429
+ "The Internet connection appears to be offline.",
61430
+ "Load failed",
61431
+ "Network request failed",
61432
+ "fetch failed",
61433
+ "terminated"
61434
+ ]);
61435
+ function isNetworkError(error) {
61436
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
61437
+ if (!isValid) {
61438
+ return false;
61439
+ }
61440
+ if (error.message === "Load failed") {
61441
+ return error.stack === undefined;
61442
+ }
61443
+ return errorMessages.has(error.message);
61444
+ }
61445
+
61446
+ // ../../node_modules/p-retry/index.js
61447
+ class AbortError extends Error {
61448
+ constructor(message) {
61449
+ super();
61450
+ if (message instanceof Error) {
61451
+ this.originalError = message;
61452
+ ({ message } = message);
61453
+ } else {
61454
+ this.originalError = new Error(message);
61455
+ this.originalError.stack = this.stack;
61456
+ }
61457
+ this.name = "AbortError";
61458
+ this.message = message;
61459
+ }
61460
+ }
61461
+ var decorateErrorWithCounts = (error, attemptNumber, options) => {
61462
+ const retriesLeft = options.retries - (attemptNumber - 1);
61463
+ error.attemptNumber = attemptNumber;
61464
+ error.retriesLeft = retriesLeft;
61465
+ return error;
61466
+ };
61467
+ async function pRetry(input, options) {
61468
+ return new Promise((resolve, reject) => {
61469
+ options = { ...options };
61470
+ options.onFailedAttempt ??= () => {
61471
+ };
61472
+ options.shouldRetry ??= () => true;
61473
+ options.retries ??= 10;
61474
+ const operation = import_retry.default.operation(options);
61475
+ const abortHandler = () => {
61476
+ operation.stop();
61477
+ reject(options.signal?.reason);
61478
+ };
61479
+ if (options.signal && !options.signal.aborted) {
61480
+ options.signal.addEventListener("abort", abortHandler, { once: true });
61481
+ }
61482
+ const cleanUp = () => {
61483
+ options.signal?.removeEventListener("abort", abortHandler);
61484
+ operation.stop();
61485
+ };
61486
+ operation.attempt(async (attemptNumber) => {
61487
+ try {
61488
+ const result = await input(attemptNumber);
61489
+ cleanUp();
61490
+ resolve(result);
61491
+ } catch (error) {
61492
+ try {
61493
+ if (!(error instanceof Error)) {
61494
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
61495
+ }
61496
+ if (error instanceof AbortError) {
61497
+ throw error.originalError;
61498
+ }
61499
+ if (error instanceof TypeError && !isNetworkError(error)) {
61500
+ throw error;
61501
+ }
61502
+ decorateErrorWithCounts(error, attemptNumber, options);
61503
+ if (!await options.shouldRetry(error)) {
61504
+ operation.stop();
61505
+ reject(error);
61506
+ }
61507
+ await options.onFailedAttempt(error);
61508
+ if (!operation.retry(error)) {
61509
+ throw operation.mainError();
61510
+ }
61511
+ } catch (finalError) {
61512
+ decorateErrorWithCounts(finalError, attemptNumber, options);
61513
+ cleanUp();
61514
+ reject(finalError);
61515
+ }
61516
+ }
61517
+ });
61518
+ });
61519
+ }
61520
+
61521
+ // src/database/adapters/MongoAdapter.ts
61195
61522
  var buildMongoOrderQuery = (order) => {
61196
61523
  if (!order)
61197
61524
  return {};
@@ -61267,7 +61594,11 @@ class MongoAdapter {
61267
61594
  this.client = new import_mongodb.MongoClient(options.databaseUrl);
61268
61595
  }
61269
61596
  async connect() {
61270
- const client = await this.client.connect();
61597
+ const client = await pRetry(() => this.client.connect(), {
61598
+ retries: 5,
61599
+ minTimeout: 100,
61600
+ factor: 2
61601
+ });
61271
61602
  this.database = client.db(this.options.databaseName);
61272
61603
  return client;
61273
61604
  }
@@ -61390,10 +61721,7 @@ class MongoAdapter {
61390
61721
  fields: ["id"],
61391
61722
  offset,
61392
61723
  first,
61393
- context: {
61394
- ...context,
61395
- isRoot: true
61396
- },
61724
+ context: contextWithRoot(context),
61397
61725
  order
61398
61726
  });
61399
61727
  if (objectsBeforeUpdate.length === 0)
@@ -61636,10 +61964,7 @@ var initializeHook = ({
61636
61964
  return {};
61637
61965
  return context.wabe.controllers.database.getObject({
61638
61966
  className,
61639
- context: {
61640
- ...context,
61641
- isRoot: true
61642
- },
61967
+ context: contextWithRoot(context),
61643
61968
  id,
61644
61969
  skipHooks: true,
61645
61970
  fields: ["*"]
@@ -61653,10 +61978,7 @@ var initializeHook = ({
61653
61978
  return [{}];
61654
61979
  const res = await context.wabe.controllers.database.getObjects({
61655
61980
  className,
61656
- context: {
61657
- ...context,
61658
- isRoot: true
61659
- },
61981
+ context: contextWithRoot(context),
61660
61982
  where: where ? where : { id: { in: ids } },
61661
61983
  fields: ["*"],
61662
61984
  skipHooks: true
@@ -62139,10 +62461,7 @@ class DatabaseController2 {
62139
62461
  return null;
62140
62462
  return this.getObject({
62141
62463
  className,
62142
- context: {
62143
- ...context,
62144
- isRoot: true
62145
- },
62464
+ context: contextWithRoot(context),
62146
62465
  fields,
62147
62466
  id,
62148
62467
  skipHooks: true
@@ -62380,7 +62699,6 @@ var AuthenticationProvider;
62380
62699
  })(AuthenticationProvider ||= {});
62381
62700
  // src/authentication/Session.ts
62382
62701
  var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
62383
-
62384
62702
  class Session {
62385
62703
  accessToken = undefined;
62386
62704
  refreshToken = undefined;
@@ -62429,10 +62747,7 @@ class Session {
62429
62747
  }, import.meta.env.JWT_SECRET || "dev");
62430
62748
  const res = await context.wabe.controllers.database.createObject({
62431
62749
  className: "_Session",
62432
- context: {
62433
- ...context,
62434
- isRoot: true
62435
- },
62750
+ context: contextWithRoot(context),
62436
62751
  data: {
62437
62752
  accessToken: this.accessToken,
62438
62753
  accessTokenExpiresAt: this.getAccessTokenExpireAt(context.wabe.config),
@@ -62455,10 +62770,7 @@ class Session {
62455
62770
  return;
62456
62771
  await context.wabe.controllers.database.deleteObject({
62457
62772
  className: "_Session",
62458
- context: {
62459
- ...context,
62460
- isRoot: true
62461
- },
62773
+ context: contextWithRoot(context),
62462
62774
  id: context.sessionId,
62463
62775
  fields: []
62464
62776
  });
@@ -62475,10 +62787,7 @@ class Session {
62475
62787
  accessToken: { equalTo: accessToken }
62476
62788
  },
62477
62789
  fields: ["id", "user", "refreshToken", "refreshTokenExpiresAt"],
62478
- context: {
62479
- ...context,
62480
- isRoot: true
62481
- }
62790
+ context: contextWithRoot(context)
62482
62791
  });
62483
62792
  if (!session.length)
62484
62793
  return {
@@ -62521,10 +62830,7 @@ class Session {
62521
62830
  }, import.meta.env.JWT_SECRET || "dev");
62522
62831
  await context.wabe.controllers.database.updateObject({
62523
62832
  className: "_Session",
62524
- context: {
62525
- ...context,
62526
- isRoot: true
62527
- },
62833
+ context: contextWithRoot(context),
62528
62834
  id,
62529
62835
  data: {
62530
62836
  accessToken: newAccessToken,
@@ -62597,10 +62903,7 @@ var signUpWithResolver = async (_, {
62597
62903
  const session = new Session;
62598
62904
  if (!createdUserId)
62599
62905
  throw new Error("User not created");
62600
- const { accessToken, refreshToken } = await session.create(createdUserId, {
62601
- ...context,
62602
- isRoot: true
62603
- });
62906
+ const { accessToken, refreshToken } = await session.create(createdUserId, contextWithRoot(context));
62604
62907
  if (context.wabe.config.authentication?.session?.cookieSession) {
62605
62908
  context.response?.setCookie("refreshToken", refreshToken, {
62606
62909
  httpOnly: true,
@@ -62862,10 +63165,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
62862
63165
  },
62863
63166
  fields: ["id"],
62864
63167
  first: 1,
62865
- context: {
62866
- ...context,
62867
- isRoot: true
62868
- }
63168
+ context: contextWithRoot(context)
62869
63169
  });
62870
63170
  if (user.length === 0)
62871
63171
  return true;
@@ -62890,10 +63190,7 @@ var resetPasswordResolver = async (_, { input: { email, password, otp, provider
62890
63190
  }
62891
63191
  },
62892
63192
  fields: [],
62893
- context: {
62894
- ...context,
62895
- isRoot: true
62896
- }
63193
+ context: contextWithRoot(context)
62897
63194
  });
62898
63195
  return true;
62899
63196
  };
@@ -63034,10 +63331,7 @@ var sendOtpCodeResolver = async (_, { input }, context) => {
63034
63331
  },
63035
63332
  fields: ["id"],
63036
63333
  first: 1,
63037
- context: {
63038
- ...context,
63039
- isRoot: true
63040
- }
63334
+ context: contextWithRoot(context)
63041
63335
  });
63042
63336
  if (user.length === 0)
63043
63337
  return true;
@@ -63167,18 +63461,6 @@ class Schema {
63167
63461
  values: {
63168
63462
  EmailOTP: "emailOTP"
63169
63463
  }
63170
- },
63171
- {
63172
- name: "PaymentMode",
63173
- values: Object.fromEntries(Object.values(PaymentMode).map((key) => [key, key]))
63174
- },
63175
- {
63176
- name: "PaymentReccuringInterval",
63177
- values: Object.fromEntries(Object.values(PaymentReccuringInterval).map((key) => [key, key]))
63178
- },
63179
- {
63180
- name: "Currency",
63181
- values: Object.fromEntries(Object.values(Currency).map((key) => [key, key]))
63182
63464
  }
63183
63465
  ];
63184
63466
  }
@@ -63371,41 +63653,6 @@ class Schema {
63371
63653
  }
63372
63654
  };
63373
63655
  }
63374
- paymentClass() {
63375
- return {
63376
- name: "Payment",
63377
- fields: {
63378
- user: {
63379
- type: "Pointer",
63380
- class: "User",
63381
- required: true
63382
- },
63383
- amount: {
63384
- type: "Int",
63385
- required: true,
63386
- description: "Amount in cents"
63387
- },
63388
- currency: {
63389
- type: "Currency",
63390
- required: true
63391
- }
63392
- },
63393
- permissions: {
63394
- read: {
63395
- authorizedRoles: ["Admin" /* Admin */],
63396
- requireAuthentication: true
63397
- },
63398
- delete: {
63399
- authorizedRoles: ["Admin" /* Admin */],
63400
- requireAuthentication: true
63401
- },
63402
- update: {
63403
- authorizedRoles: ["Admin" /* Admin */],
63404
- requireAuthentication: true
63405
- }
63406
- }
63407
- };
63408
- }
63409
63656
  roleClass() {
63410
63657
  return {
63411
63658
  name: "Role",
@@ -63633,7 +63880,6 @@ class Schema {
63633
63880
  this.userClass(),
63634
63881
  this.sessionClass(),
63635
63882
  this.roleClass(),
63636
- this.paymentClass(),
63637
63883
  this.internalConfigClass()
63638
63884
  ]);
63639
63885
  }
@@ -65434,10 +65680,7 @@ class EmailPassword {
65434
65680
  }
65435
65681
  }
65436
65682
  },
65437
- context: {
65438
- ...context,
65439
- isRoot: true
65440
- },
65683
+ context: contextWithRoot(context),
65441
65684
  fields: ["id", "authentication"],
65442
65685
  first: 1
65443
65686
  });
@@ -65515,15 +65758,7 @@ class Google3 {
65515
65758
  }) {
65516
65759
  const { authorizationCode, codeVerifier } = input;
65517
65760
  const googleOauth = new Google(context.wabe.config);
65518
- const {
65519
- accessToken,
65520
- refreshToken,
65521
- idToken,
65522
- accessTokenExpiresAt,
65523
- refreshTokenExpiresAt
65524
- } = await googleOauth.validateAuthorizationCode(authorizationCode, codeVerifier);
65525
- if (!refreshToken)
65526
- throw new Error("Access_type must be offline");
65761
+ const { accessToken, idToken } = await googleOauth.validateAuthorizationCode(authorizationCode, codeVerifier);
65527
65762
  if (!idToken)
65528
65763
  throw new Error("Authentication failed");
65529
65764
  const { email, verifiedEmail } = await googleOauth.getUserInfo(accessToken, idToken);
@@ -65536,10 +65771,7 @@ class Google3 {
65536
65771
  }
65537
65772
  }
65538
65773
  },
65539
- context: {
65540
- ...context,
65541
- isRoot: true
65542
- },
65774
+ context: contextWithRoot(context),
65543
65775
  first: 1,
65544
65776
  fields: ["id"]
65545
65777
  });
@@ -65558,34 +65790,19 @@ class Google3 {
65558
65790
  google: authenticationDataToSave
65559
65791
  }
65560
65792
  },
65561
- context: {
65562
- ...context,
65563
- isRoot: true
65564
- },
65793
+ context: contextWithRoot(context),
65565
65794
  fields: ["*", "id"]
65566
65795
  });
65567
65796
  if (!createdUser)
65568
65797
  throw new Error("User not found");
65569
65798
  return {
65570
- user: createdUser,
65571
- oauth: {
65572
- refreshToken,
65573
- accessToken,
65574
- accessTokenExpiresAt: accessTokenExpiresAt || new Date,
65575
- refreshTokenExpiresAt: refreshTokenExpiresAt || new Date
65576
- }
65799
+ user: createdUser
65577
65800
  };
65578
65801
  }
65579
65802
  if (!user[0])
65580
65803
  throw new Error("User not found");
65581
65804
  return {
65582
- user: user[0],
65583
- oauth: {
65584
- refreshToken,
65585
- accessToken,
65586
- accessTokenExpiresAt: accessTokenExpiresAt || new Date,
65587
- refreshTokenExpiresAt: refreshTokenExpiresAt || new Date
65588
- }
65805
+ user: user[0]
65589
65806
  };
65590
65807
  }
65591
65808
  onSignIn(options) {
@@ -75971,6 +76188,7 @@ export {
75971
76188
  initializeHook,
75972
76189
  getDefaultHooks,
75973
76190
  generateCodegen,
76191
+ contextWithRoot,
75974
76192
  buildMongoWhereQuery,
75975
76193
  buildMongoOrderQuery,
75976
76194
  _findHooksByPriority,