@gbozee/ultimate 0.0.2-71 → 0.0.2-73

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
@@ -3957,7 +3957,7 @@ var require_util = __commonJS((exports) => {
3957
3957
  }
3958
3958
  return value;
3959
3959
  };
3960
- })(util4 = exports.util || (exports.util = {}));
3960
+ })(util4 || (exports.util = util4 = {}));
3961
3961
  var objectUtil2;
3962
3962
  (function(objectUtil3) {
3963
3963
  objectUtil3.mergeShapes = (first, second) => {
@@ -3966,7 +3966,7 @@ var require_util = __commonJS((exports) => {
3966
3966
  ...second
3967
3967
  };
3968
3968
  };
3969
- })(objectUtil2 = exports.objectUtil || (exports.objectUtil = {}));
3969
+ })(objectUtil2 || (exports.objectUtil = objectUtil2 = {}));
3970
3970
  exports.ZodParsedType = util4.arrayToEnum([
3971
3971
  "string",
3972
3972
  "nan",
@@ -4063,6 +4063,9 @@ var require_ZodError = __commonJS((exports) => {
4063
4063
  exports.quotelessJson = quotelessJson2;
4064
4064
 
4065
4065
  class ZodError2 extends Error {
4066
+ get errors() {
4067
+ return this.issues;
4068
+ }
4066
4069
  constructor(issues) {
4067
4070
  super();
4068
4071
  this.issues = [];
@@ -4081,9 +4084,6 @@ var require_ZodError = __commonJS((exports) => {
4081
4084
  this.name = "ZodError";
4082
4085
  this.issues = issues;
4083
4086
  }
4084
- get errors() {
4085
- return this.issues;
4086
- }
4087
4087
  format(_mapper) {
4088
4088
  const mapper = _mapper || function(issue) {
4089
4089
  return issue.message;
@@ -4422,7 +4422,7 @@ var require_errorUtil = __commonJS((exports) => {
4422
4422
  (function(errorUtil3) {
4423
4423
  errorUtil3.errToObj = (message2) => typeof message2 === "string" ? { message: message2 } : message2 || {};
4424
4424
  errorUtil3.toString = (message2) => typeof message2 === "string" ? message2 : message2 === null || message2 === undefined ? undefined : message2.message;
4425
- })(errorUtil2 = exports.errorUtil || (exports.errorUtil = {}));
4425
+ })(errorUtil2 || (exports.errorUtil = errorUtil2 = {}));
4426
4426
  });
4427
4427
 
4428
4428
  // node_modules/zod/lib/types.js
@@ -4518,34 +4518,6 @@ var require_types = __commonJS((exports) => {
4518
4518
  }
4519
4519
 
4520
4520
  class ZodType2 {
4521
- constructor(def) {
4522
- this.spa = this.safeParseAsync;
4523
- this._def = def;
4524
- this.parse = this.parse.bind(this);
4525
- this.safeParse = this.safeParse.bind(this);
4526
- this.parseAsync = this.parseAsync.bind(this);
4527
- this.safeParseAsync = this.safeParseAsync.bind(this);
4528
- this.spa = this.spa.bind(this);
4529
- this.refine = this.refine.bind(this);
4530
- this.refinement = this.refinement.bind(this);
4531
- this.superRefine = this.superRefine.bind(this);
4532
- this.optional = this.optional.bind(this);
4533
- this.nullable = this.nullable.bind(this);
4534
- this.nullish = this.nullish.bind(this);
4535
- this.array = this.array.bind(this);
4536
- this.promise = this.promise.bind(this);
4537
- this.or = this.or.bind(this);
4538
- this.and = this.and.bind(this);
4539
- this.transform = this.transform.bind(this);
4540
- this.brand = this.brand.bind(this);
4541
- this.default = this.default.bind(this);
4542
- this.catch = this.catch.bind(this);
4543
- this.describe = this.describe.bind(this);
4544
- this.pipe = this.pipe.bind(this);
4545
- this.readonly = this.readonly.bind(this);
4546
- this.isNullable = this.isNullable.bind(this);
4547
- this.isOptional = this.isOptional.bind(this);
4548
- }
4549
4521
  get description() {
4550
4522
  return this._def.description;
4551
4523
  }
@@ -4609,6 +4581,43 @@ var require_types = __commonJS((exports) => {
4609
4581
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
4610
4582
  return handleResult2(ctx, result);
4611
4583
  }
4584
+ "~validate"(data) {
4585
+ var _a, _b;
4586
+ const ctx = {
4587
+ common: {
4588
+ issues: [],
4589
+ async: !!this["~standard"].async
4590
+ },
4591
+ path: [],
4592
+ schemaErrorMap: this._def.errorMap,
4593
+ parent: null,
4594
+ data,
4595
+ parsedType: (0, util_1.getParsedType)(data)
4596
+ };
4597
+ if (!this["~standard"].async) {
4598
+ try {
4599
+ const result = this._parseSync({ data, path: [], parent: ctx });
4600
+ return (0, parseUtil_1.isValid)(result) ? {
4601
+ value: result.value
4602
+ } : {
4603
+ issues: ctx.common.issues
4604
+ };
4605
+ } catch (err) {
4606
+ if ((_b = (_a = err === null || err === undefined ? undefined : err.message) === null || _a === undefined ? undefined : _a.toLowerCase()) === null || _b === undefined ? undefined : _b.includes("encountered")) {
4607
+ this["~standard"].async = true;
4608
+ }
4609
+ ctx.common = {
4610
+ issues: [],
4611
+ async: true
4612
+ };
4613
+ }
4614
+ }
4615
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_1.isValid)(result) ? {
4616
+ value: result.value
4617
+ } : {
4618
+ issues: ctx.common.issues
4619
+ });
4620
+ }
4612
4621
  async parseAsync(data, params) {
4613
4622
  const result = await this.safeParseAsync(data, params);
4614
4623
  if (result.success)
@@ -4686,6 +4695,39 @@ var require_types = __commonJS((exports) => {
4686
4695
  superRefine(refinement) {
4687
4696
  return this._refinement(refinement);
4688
4697
  }
4698
+ constructor(def) {
4699
+ this.spa = this.safeParseAsync;
4700
+ this._def = def;
4701
+ this.parse = this.parse.bind(this);
4702
+ this.safeParse = this.safeParse.bind(this);
4703
+ this.parseAsync = this.parseAsync.bind(this);
4704
+ this.safeParseAsync = this.safeParseAsync.bind(this);
4705
+ this.spa = this.spa.bind(this);
4706
+ this.refine = this.refine.bind(this);
4707
+ this.refinement = this.refinement.bind(this);
4708
+ this.superRefine = this.superRefine.bind(this);
4709
+ this.optional = this.optional.bind(this);
4710
+ this.nullable = this.nullable.bind(this);
4711
+ this.nullish = this.nullish.bind(this);
4712
+ this.array = this.array.bind(this);
4713
+ this.promise = this.promise.bind(this);
4714
+ this.or = this.or.bind(this);
4715
+ this.and = this.and.bind(this);
4716
+ this.transform = this.transform.bind(this);
4717
+ this.brand = this.brand.bind(this);
4718
+ this.default = this.default.bind(this);
4719
+ this.catch = this.catch.bind(this);
4720
+ this.describe = this.describe.bind(this);
4721
+ this.pipe = this.pipe.bind(this);
4722
+ this.readonly = this.readonly.bind(this);
4723
+ this.isNullable = this.isNullable.bind(this);
4724
+ this.isOptional = this.isOptional.bind(this);
4725
+ this["~standard"] = {
4726
+ version: 1,
4727
+ vendor: "zod",
4728
+ validate: (data) => this["~validate"](data)
4729
+ };
4730
+ }
4689
4731
  optional() {
4690
4732
  return ZodOptional2.create(this, this._def);
4691
4733
  }
@@ -4696,7 +4738,7 @@ var require_types = __commonJS((exports) => {
4696
4738
  return this.nullable().optional();
4697
4739
  }
4698
4740
  array() {
4699
- return ZodArray2.create(this, this._def);
4741
+ return ZodArray2.create(this);
4700
4742
  }
4701
4743
  promise() {
4702
4744
  return ZodPromise2.create(this, this._def);
@@ -4765,26 +4807,31 @@ var require_types = __commonJS((exports) => {
4765
4807
  exports.ZodSchema = ZodType2;
4766
4808
  var cuidRegex2 = /^c[^\s-]{8,}$/i;
4767
4809
  var cuid2Regex2 = /^[0-9a-z]+$/;
4768
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/;
4810
+ var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
4769
4811
  var uuidRegex2 = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
4770
4812
  var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
4813
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
4771
4814
  var durationRegex2 = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
4772
4815
  var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
4773
4816
  var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4774
4817
  var emojiRegex2;
4775
4818
  var ipv4Regex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
4776
- var ipv6Regex2 = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
4819
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
4820
+ var ipv6Regex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
4821
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4777
4822
  var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
4823
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
4778
4824
  var dateRegexSource2 = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
4779
4825
  var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
4780
4826
  function timeRegexSource2(args) {
4781
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
4827
+ let secondsRegexSource = `[0-5]\\d`;
4782
4828
  if (args.precision) {
4783
- regex = `${regex}\\.\\d{${args.precision}}`;
4829
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
4784
4830
  } else if (args.precision == null) {
4785
- regex = `${regex}(\\.\\d+)?`;
4831
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
4786
4832
  }
4787
- return regex;
4833
+ const secondsQuantifier = args.precision ? "+" : "?";
4834
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
4788
4835
  }
4789
4836
  function timeRegex2(args) {
4790
4837
  return new RegExp(`^${timeRegexSource2(args)}$`);
@@ -4808,6 +4855,33 @@ var require_types = __commonJS((exports) => {
4808
4855
  }
4809
4856
  return false;
4810
4857
  }
4858
+ function isValidJWT(jwt, alg) {
4859
+ if (!jwtRegex.test(jwt))
4860
+ return false;
4861
+ try {
4862
+ const [header] = jwt.split(".");
4863
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
4864
+ const decoded = JSON.parse(atob(base64));
4865
+ if (typeof decoded !== "object" || decoded === null)
4866
+ return false;
4867
+ if (!decoded.typ || !decoded.alg)
4868
+ return false;
4869
+ if (alg && decoded.alg !== alg)
4870
+ return false;
4871
+ return true;
4872
+ } catch (_a) {
4873
+ return false;
4874
+ }
4875
+ }
4876
+ function isValidCidr(ip, version) {
4877
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
4878
+ return true;
4879
+ }
4880
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
4881
+ return true;
4882
+ }
4883
+ return false;
4884
+ }
4811
4885
 
4812
4886
  class ZodString2 extends ZodType2 {
4813
4887
  _parse(input) {
@@ -5065,6 +5139,26 @@ var require_types = __commonJS((exports) => {
5065
5139
  });
5066
5140
  status.dirty();
5067
5141
  }
5142
+ } else if (check2.kind === "jwt") {
5143
+ if (!isValidJWT(input.data, check2.alg)) {
5144
+ ctx = this._getOrReturnCtx(input, ctx);
5145
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5146
+ validation: "jwt",
5147
+ code: ZodError_1.ZodIssueCode.invalid_string,
5148
+ message: check2.message
5149
+ });
5150
+ status.dirty();
5151
+ }
5152
+ } else if (check2.kind === "cidr") {
5153
+ if (!isValidCidr(input.data, check2.version)) {
5154
+ ctx = this._getOrReturnCtx(input, ctx);
5155
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5156
+ validation: "cidr",
5157
+ code: ZodError_1.ZodIssueCode.invalid_string,
5158
+ message: check2.message
5159
+ });
5160
+ status.dirty();
5161
+ }
5068
5162
  } else if (check2.kind === "base64") {
5069
5163
  if (!base64Regex2.test(input.data)) {
5070
5164
  ctx = this._getOrReturnCtx(input, ctx);
@@ -5075,6 +5169,16 @@ var require_types = __commonJS((exports) => {
5075
5169
  });
5076
5170
  status.dirty();
5077
5171
  }
5172
+ } else if (check2.kind === "base64url") {
5173
+ if (!base64urlRegex.test(input.data)) {
5174
+ ctx = this._getOrReturnCtx(input, ctx);
5175
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5176
+ validation: "base64url",
5177
+ code: ZodError_1.ZodIssueCode.invalid_string,
5178
+ message: check2.message
5179
+ });
5180
+ status.dirty();
5181
+ }
5078
5182
  } else {
5079
5183
  util_1.util.assertNever(check2);
5080
5184
  }
@@ -5121,9 +5225,21 @@ var require_types = __commonJS((exports) => {
5121
5225
  base64(message2) {
5122
5226
  return this._addCheck({ kind: "base64", ...errorUtil_1.errorUtil.errToObj(message2) });
5123
5227
  }
5228
+ base64url(message2) {
5229
+ return this._addCheck({
5230
+ kind: "base64url",
5231
+ ...errorUtil_1.errorUtil.errToObj(message2)
5232
+ });
5233
+ }
5234
+ jwt(options) {
5235
+ return this._addCheck({ kind: "jwt", ...errorUtil_1.errorUtil.errToObj(options) });
5236
+ }
5124
5237
  ip(options) {
5125
5238
  return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) });
5126
5239
  }
5240
+ cidr(options) {
5241
+ return this._addCheck({ kind: "cidr", ...errorUtil_1.errorUtil.errToObj(options) });
5242
+ }
5127
5243
  datetime(options) {
5128
5244
  var _a, _b;
5129
5245
  if (typeof options === "string") {
@@ -5273,9 +5389,15 @@ var require_types = __commonJS((exports) => {
5273
5389
  get isIP() {
5274
5390
  return !!this._def.checks.find((ch) => ch.kind === "ip");
5275
5391
  }
5392
+ get isCIDR() {
5393
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
5394
+ }
5276
5395
  get isBase64() {
5277
5396
  return !!this._def.checks.find((ch) => ch.kind === "base64");
5278
5397
  }
5398
+ get isBase64url() {
5399
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
5400
+ }
5279
5401
  get minLength() {
5280
5402
  let min = null;
5281
5403
  for (const ch of this._def.checks) {
@@ -5557,17 +5679,15 @@ var require_types = __commonJS((exports) => {
5557
5679
  }
5558
5680
  _parse(input) {
5559
5681
  if (this._def.coerce) {
5560
- input.data = BigInt(input.data);
5682
+ try {
5683
+ input.data = BigInt(input.data);
5684
+ } catch (_a) {
5685
+ return this._getInvalidInput(input);
5686
+ }
5561
5687
  }
5562
5688
  const parsedType = this._getType(input);
5563
5689
  if (parsedType !== util_1.ZodParsedType.bigint) {
5564
- const ctx2 = this._getOrReturnCtx(input);
5565
- (0, parseUtil_1.addIssueToContext)(ctx2, {
5566
- code: ZodError_1.ZodIssueCode.invalid_type,
5567
- expected: util_1.ZodParsedType.bigint,
5568
- received: ctx2.parsedType
5569
- });
5570
- return parseUtil_1.INVALID;
5690
+ return this._getInvalidInput(input);
5571
5691
  }
5572
5692
  let ctx = undefined;
5573
5693
  const status = new parseUtil_1.ParseStatus;
@@ -5614,6 +5734,15 @@ var require_types = __commonJS((exports) => {
5614
5734
  }
5615
5735
  return { status: status.value, value: input.data };
5616
5736
  }
5737
+ _getInvalidInput(input) {
5738
+ const ctx = this._getOrReturnCtx(input);
5739
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5740
+ code: ZodError_1.ZodIssueCode.invalid_type,
5741
+ expected: util_1.ZodParsedType.bigint,
5742
+ received: ctx.parsedType
5743
+ });
5744
+ return parseUtil_1.INVALID;
5745
+ }
5617
5746
  gte(value, message2) {
5618
5747
  return this.setLimit("min", value, true, errorUtil_1.errorUtil.toString(message2));
5619
5748
  }
@@ -7652,16 +7781,32 @@ var require_types = __commonJS((exports) => {
7652
7781
  ...processCreateParams2(params)
7653
7782
  });
7654
7783
  };
7655
- function custom2(check2, params = {}, fatal) {
7784
+ function cleanParams(params, data) {
7785
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
7786
+ const p2 = typeof p === "string" ? { message: p } : p;
7787
+ return p2;
7788
+ }
7789
+ function custom2(check2, _params = {}, fatal) {
7656
7790
  if (check2)
7657
7791
  return ZodAny2.create().superRefine((data, ctx) => {
7658
7792
  var _a, _b;
7659
- if (!check2(data)) {
7660
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
7661
- const _fatal = (_b = (_a = p.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
7662
- const p2 = typeof p === "string" ? { message: p } : p;
7663
- ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
7793
+ const r = check2(data);
7794
+ if (r instanceof Promise) {
7795
+ return r.then((r2) => {
7796
+ var _a2, _b2;
7797
+ if (!r2) {
7798
+ const params = cleanParams(_params, data);
7799
+ const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== undefined ? _a2 : fatal) !== null && _b2 !== undefined ? _b2 : true;
7800
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
7801
+ }
7802
+ });
7664
7803
  }
7804
+ if (!r) {
7805
+ const params = cleanParams(_params, data);
7806
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
7807
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
7808
+ }
7809
+ return;
7665
7810
  });
7666
7811
  return ZodAny2.create();
7667
7812
  }
@@ -7707,7 +7852,7 @@ var require_types = __commonJS((exports) => {
7707
7852
  ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
7708
7853
  ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
7709
7854
  ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
7710
- })(ZodFirstPartyTypeKind2 = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
7855
+ })(ZodFirstPartyTypeKind2 || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind2 = {}));
7711
7856
  var instanceOfType2 = (cls, params = {
7712
7857
  message: `Input not instance of ${cls.name}`
7713
7858
  }) => custom2((data) => data instanceof cls, params);
@@ -7805,9 +7950,13 @@ var require_external = __commonJS((exports) => {
7805
7950
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
7806
7951
  if (k2 === undefined)
7807
7952
  k2 = k;
7808
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
7809
- return m[k];
7810
- } });
7953
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7954
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7955
+ desc = { enumerable: true, get: function() {
7956
+ return m[k];
7957
+ } };
7958
+ }
7959
+ Object.defineProperty(o, k2, desc);
7811
7960
  } : function(o, m, k, k2) {
7812
7961
  if (k2 === undefined)
7813
7962
  k2 = k;
@@ -7832,9 +7981,13 @@ var require_lib = __commonJS((exports) => {
7832
7981
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
7833
7982
  if (k2 === undefined)
7834
7983
  k2 = k;
7835
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
7836
- return m[k];
7837
- } });
7984
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7985
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7986
+ desc = { enumerable: true, get: function() {
7987
+ return m[k];
7988
+ } };
7989
+ }
7990
+ Object.defineProperty(o, k2, desc);
7838
7991
  } : function(o, m, k, k2) {
7839
7992
  if (k2 === undefined)
7840
7993
  k2 = k;
@@ -16497,7 +16650,7 @@ var require_combined_stream = __commonJS((exports, module) => {
16497
16650
  };
16498
16651
  });
16499
16652
 
16500
- // node_modules/mime-db/db.json
16653
+ // node_modules/form-data/node_modules/mime-types/node_modules/mime-db/db.json
16501
16654
  var require_db = __commonJS((exports, module) => {
16502
16655
  module.exports = {
16503
16656
  "application/1d-interleaved-parityfec": {
@@ -25020,7 +25173,7 @@ var require_db = __commonJS((exports, module) => {
25020
25173
  };
25021
25174
  });
25022
25175
 
25023
- // node_modules/mime-db/index.js
25176
+ // node_modules/form-data/node_modules/mime-types/node_modules/mime-db/index.js
25024
25177
  var require_mime_db = __commonJS((exports, module) => {
25025
25178
  /*!
25026
25179
  * mime-db
@@ -25031,7 +25184,7 @@ var require_mime_db = __commonJS((exports, module) => {
25031
25184
  module.exports = require_db();
25032
25185
  });
25033
25186
 
25034
- // node_modules/mime-types/index.js
25187
+ // node_modules/form-data/node_modules/mime-types/index.js
25035
25188
  var require_mime_types = __commonJS((exports) => {
25036
25189
  /*!
25037
25190
  * mime-types
@@ -41720,7 +41873,7 @@ __export(exports_app, {
41720
41873
  App: () => App
41721
41874
  });
41722
41875
 
41723
- // node_modules/zod/lib/index.mjs
41876
+ // node_modules/@trigger.dev/core/node_modules/zod/lib/index.mjs
41724
41877
  var util;
41725
41878
  (function(util2) {
41726
41879
  util2.assertEqual = (val) => val;
@@ -53902,8 +54055,8 @@ class Strategy {
53902
54055
  return result;
53903
54056
  }
53904
54057
  generateOppositeTrades(payload) {
53905
- const { kind, risk_factor = 0.5 } = payload;
53906
- const entry = this.position[kind].entry;
54058
+ const { kind, risk_factor = 0.5, avg_entry } = payload;
54059
+ const entry = avg_entry || this.position[kind].entry;
53907
54060
  const stop = this.tp(kind);
53908
54061
  const risk = this.pnl(kind) * risk_factor;
53909
54062
  const risk_reward = getRiskReward({