autosync_backend2 1.2.52 → 1.2.56

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1558 -1421
  2. package/dist/index.js +649 -247
  3. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -24919,17 +24919,7 @@ var require_tools = __commonJS((exports, module) => {
24919
24919
  } = require_symbols();
24920
24920
  var { isMainThread } = __require("worker_threads");
24921
24921
  var transport = require_transport();
24922
- var asJsonChan;
24923
- if (typeof diagChan.tracingChannel === "function") {
24924
- asJsonChan = diagChan.tracingChannel("pino_asJson");
24925
- } else {
24926
- asJsonChan = {
24927
- hasSubscribers: false,
24928
- traceSync(fn, store5, thisArg, ...args) {
24929
- return fn.call(thisArg, ...args);
24930
- }
24931
- };
24932
- }
24922
+ var asJsonChan = diagChan.tracingChannel("pino_asJson");
24933
24923
  function noop2() {}
24934
24924
  function genLog(level, hook) {
24935
24925
  if (!hook)
@@ -25420,7 +25410,7 @@ var require_levels = __commonJS((exports, module) => {
25420
25410
 
25421
25411
  // node_modules/pino/lib/meta.js
25422
25412
  var require_meta = __commonJS((exports, module) => {
25423
- module.exports = { version: "9.14.0" };
25413
+ module.exports = { version: "10.1.0" };
25424
25414
  });
25425
25415
 
25426
25416
  // node_modules/pino/lib/proto.js
@@ -25432,7 +25422,6 @@ var require_proto = __commonJS((exports, module) => {
25432
25422
  setLevelSym,
25433
25423
  getLevelSym,
25434
25424
  chindingsSym,
25435
- parsedChindingsSym,
25436
25425
  mixinSym,
25437
25426
  asJsonSym,
25438
25427
  writeSym,
@@ -25524,7 +25513,6 @@ var require_proto = __commonJS((exports, module) => {
25524
25513
  instance[formattersSym] = buildFormatters(formatters.level, resetChildingsFormatter, formatters.log);
25525
25514
  }
25526
25515
  instance[chindingsSym] = asChindings(instance, bindings2);
25527
- instance[setLevelSym](this.level);
25528
25516
  if (this.onChild !== noop2) {
25529
25517
  this.onChild(instance);
25530
25518
  }
@@ -25573,8 +25561,10 @@ var require_proto = __commonJS((exports, module) => {
25573
25561
  instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
25574
25562
  }
25575
25563
  instance[chindingsSym] = asChindings(instance, bindings2);
25576
- const childLevel = options.level || this.level;
25577
- instance[setLevelSym](childLevel);
25564
+ if (options.level !== undefined && options.level !== this.level || options.hasOwnProperty("customLevels")) {
25565
+ const childLevel = options.level || this.level;
25566
+ instance[setLevelSym](childLevel);
25567
+ }
25578
25568
  this.onChild(instance);
25579
25569
  return instance;
25580
25570
  }
@@ -25589,7 +25579,6 @@ var require_proto = __commonJS((exports, module) => {
25589
25579
  function setBindings(newBindings) {
25590
25580
  const chindings = asChindings(this, newBindings);
25591
25581
  this[chindingsSym] = chindings;
25592
- delete this[parsedChindingsSym];
25593
25582
  }
25594
25583
  function defaultMixinMergeStrategy(mergeObject, mixinObject) {
25595
25584
  return Object.assign(mixinObject, mergeObject);
@@ -100204,89 +100193,90 @@ var require_fast_decode_uri_component = __commonJS2((exports, module) => {
100204
100193
  });
100205
100194
  var require_dist = __commonJS2((exports) => {
100206
100195
  Object.defineProperty(exports, "__esModule", { value: true });
100207
- exports.parse = parse2;
100208
- exports.serialize = serialize;
100209
- var cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/, domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/, __toString = Object.prototype.toString, NullObject = (() => {
100196
+ exports.parseCookie = parseCookie;
100197
+ exports.parse = parseCookie;
100198
+ exports.stringifyCookie = stringifyCookie;
100199
+ exports.stringifySetCookie = stringifySetCookie;
100200
+ exports.serialize = stringifySetCookie;
100201
+ exports.parseSetCookie = parseSetCookie;
100202
+ exports.stringifySetCookie = stringifySetCookie;
100203
+ exports.serialize = stringifySetCookie;
100204
+ var cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/, domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/, maxAgeRegExp = /^-?\d+$/, __toString = Object.prototype.toString, NullObject = (() => {
100210
100205
  let C = function() {};
100211
100206
  return C.prototype = Object.create(null), C;
100212
100207
  })();
100213
- function parse2(str, options) {
100208
+ function parseCookie(str, options) {
100214
100209
  let obj2 = new NullObject, len = str.length;
100215
100210
  if (len < 2)
100216
100211
  return obj2;
100217
100212
  let dec = options?.decode || decode2, index = 0;
100218
100213
  do {
100219
- let eqIdx = str.indexOf("=", index);
100214
+ let eqIdx = eqIndex(str, index, len);
100220
100215
  if (eqIdx === -1)
100221
100216
  break;
100222
- let colonIdx = str.indexOf(";", index), endIdx = colonIdx === -1 ? len : colonIdx;
100217
+ let endIdx = endIndex(str, index, len);
100223
100218
  if (eqIdx > endIdx) {
100224
100219
  index = str.lastIndexOf(";", eqIdx - 1) + 1;
100225
100220
  continue;
100226
100221
  }
100227
- let keyStartIdx = startIndex(str, index, eqIdx), keyEndIdx = endIndex(str, eqIdx, keyStartIdx), key = str.slice(keyStartIdx, keyEndIdx);
100228
- if (obj2[key] === undefined) {
100229
- let valStartIdx = startIndex(str, eqIdx + 1, endIdx), valEndIdx = endIndex(str, endIdx, valStartIdx), value = dec(str.slice(valStartIdx, valEndIdx));
100230
- obj2[key] = value;
100231
- }
100222
+ let key = valueSlice(str, index, eqIdx);
100223
+ if (obj2[key] === undefined)
100224
+ obj2[key] = dec(valueSlice(str, eqIdx + 1, endIdx));
100232
100225
  index = endIdx + 1;
100233
100226
  } while (index < len);
100234
100227
  return obj2;
100235
100228
  }
100236
- function startIndex(str, index, max2) {
100237
- do {
100238
- let code = str.charCodeAt(index);
100239
- if (code !== 32 && code !== 9)
100240
- return index;
100241
- } while (++index < max2);
100242
- return max2;
100243
- }
100244
- function endIndex(str, index, min) {
100245
- while (index > min) {
100246
- let code = str.charCodeAt(--index);
100247
- if (code !== 32 && code !== 9)
100248
- return index + 1;
100249
- }
100250
- return min;
100251
- }
100252
- function serialize(name, val, options) {
100253
- let enc = options?.encode || encodeURIComponent;
100254
- if (!cookieNameRegExp.test(name))
100255
- throw TypeError(`argument name is invalid: ${name}`);
100256
- let value = enc(val);
100229
+ function stringifyCookie(cookie, options) {
100230
+ let enc = options?.encode || encodeURIComponent, cookieStrings = [];
100231
+ for (let name of Object.keys(cookie)) {
100232
+ let val = cookie[name];
100233
+ if (val === undefined)
100234
+ continue;
100235
+ if (!cookieNameRegExp.test(name))
100236
+ throw TypeError(`cookie name is invalid: ${name}`);
100237
+ let value = enc(val);
100238
+ if (!cookieValueRegExp.test(value))
100239
+ throw TypeError(`cookie val is invalid: ${val}`);
100240
+ cookieStrings.push(`${name}=${value}`);
100241
+ }
100242
+ return cookieStrings.join("; ");
100243
+ }
100244
+ function stringifySetCookie(_name, _val, _opts) {
100245
+ let cookie = typeof _name === "object" ? _name : { ..._opts, name: _name, value: String(_val) }, enc = (typeof _val === "object" ? _val : _opts)?.encode || encodeURIComponent;
100246
+ if (!cookieNameRegExp.test(cookie.name))
100247
+ throw TypeError(`argument name is invalid: ${cookie.name}`);
100248
+ let value = cookie.value ? enc(cookie.value) : "";
100257
100249
  if (!cookieValueRegExp.test(value))
100258
- throw TypeError(`argument val is invalid: ${val}`);
100259
- let str = name + "=" + value;
100260
- if (!options)
100261
- return str;
100262
- if (options.maxAge !== undefined) {
100263
- if (!Number.isInteger(options.maxAge))
100264
- throw TypeError(`option maxAge is invalid: ${options.maxAge}`);
100265
- str += "; Max-Age=" + options.maxAge;
100266
- }
100267
- if (options.domain) {
100268
- if (!domainValueRegExp.test(options.domain))
100269
- throw TypeError(`option domain is invalid: ${options.domain}`);
100270
- str += "; Domain=" + options.domain;
100271
- }
100272
- if (options.path) {
100273
- if (!pathValueRegExp.test(options.path))
100274
- throw TypeError(`option path is invalid: ${options.path}`);
100275
- str += "; Path=" + options.path;
100276
- }
100277
- if (options.expires) {
100278
- if (!isDate(options.expires) || !Number.isFinite(options.expires.valueOf()))
100279
- throw TypeError(`option expires is invalid: ${options.expires}`);
100280
- str += "; Expires=" + options.expires.toUTCString();
100281
- }
100282
- if (options.httpOnly)
100250
+ throw TypeError(`argument val is invalid: ${cookie.value}`);
100251
+ let str = cookie.name + "=" + value;
100252
+ if (cookie.maxAge !== undefined) {
100253
+ if (!Number.isInteger(cookie.maxAge))
100254
+ throw TypeError(`option maxAge is invalid: ${cookie.maxAge}`);
100255
+ str += "; Max-Age=" + cookie.maxAge;
100256
+ }
100257
+ if (cookie.domain) {
100258
+ if (!domainValueRegExp.test(cookie.domain))
100259
+ throw TypeError(`option domain is invalid: ${cookie.domain}`);
100260
+ str += "; Domain=" + cookie.domain;
100261
+ }
100262
+ if (cookie.path) {
100263
+ if (!pathValueRegExp.test(cookie.path))
100264
+ throw TypeError(`option path is invalid: ${cookie.path}`);
100265
+ str += "; Path=" + cookie.path;
100266
+ }
100267
+ if (cookie.expires) {
100268
+ if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf()))
100269
+ throw TypeError(`option expires is invalid: ${cookie.expires}`);
100270
+ str += "; Expires=" + cookie.expires.toUTCString();
100271
+ }
100272
+ if (cookie.httpOnly)
100283
100273
  str += "; HttpOnly";
100284
- if (options.secure)
100274
+ if (cookie.secure)
100285
100275
  str += "; Secure";
100286
- if (options.partitioned)
100276
+ if (cookie.partitioned)
100287
100277
  str += "; Partitioned";
100288
- if (options.priority)
100289
- switch (typeof options.priority === "string" ? options.priority.toLowerCase() : undefined) {
100278
+ if (cookie.priority)
100279
+ switch (typeof cookie.priority === "string" ? cookie.priority.toLowerCase() : undefined) {
100290
100280
  case "low":
100291
100281
  str += "; Priority=Low";
100292
100282
  break;
@@ -100297,10 +100287,10 @@ var require_dist = __commonJS2((exports) => {
100297
100287
  str += "; Priority=High";
100298
100288
  break;
100299
100289
  default:
100300
- throw TypeError(`option priority is invalid: ${options.priority}`);
100290
+ throw TypeError(`option priority is invalid: ${cookie.priority}`);
100301
100291
  }
100302
- if (options.sameSite)
100303
- switch (typeof options.sameSite === "string" ? options.sameSite.toLowerCase() : options.sameSite) {
100292
+ if (cookie.sameSite)
100293
+ switch (typeof cookie.sameSite === "string" ? cookie.sameSite.toLowerCase() : cookie.sameSite) {
100304
100294
  case true:
100305
100295
  case "strict":
100306
100296
  str += "; SameSite=Strict";
@@ -100312,10 +100302,83 @@ var require_dist = __commonJS2((exports) => {
100312
100302
  str += "; SameSite=None";
100313
100303
  break;
100314
100304
  default:
100315
- throw TypeError(`option sameSite is invalid: ${options.sameSite}`);
100305
+ throw TypeError(`option sameSite is invalid: ${cookie.sameSite}`);
100316
100306
  }
100317
100307
  return str;
100318
100308
  }
100309
+ function parseSetCookie(str, options) {
100310
+ let dec = options?.decode || decode2, len = str.length, endIdx = endIndex(str, 0, len), eqIdx = eqIndex(str, 0, endIdx), setCookie = eqIdx === -1 ? { name: "", value: dec(valueSlice(str, 0, endIdx)) } : { name: valueSlice(str, 0, eqIdx), value: dec(valueSlice(str, eqIdx + 1, endIdx)) }, index = endIdx + 1;
100311
+ while (index < len) {
100312
+ let endIdx2 = endIndex(str, index, len), eqIdx2 = eqIndex(str, index, endIdx2), attr = eqIdx2 === -1 ? valueSlice(str, index, endIdx2) : valueSlice(str, index, eqIdx2), val = eqIdx2 === -1 ? undefined : valueSlice(str, eqIdx2 + 1, endIdx2);
100313
+ switch (attr.toLowerCase()) {
100314
+ case "httponly":
100315
+ setCookie.httpOnly = true;
100316
+ break;
100317
+ case "secure":
100318
+ setCookie.secure = true;
100319
+ break;
100320
+ case "partitioned":
100321
+ setCookie.partitioned = true;
100322
+ break;
100323
+ case "domain":
100324
+ setCookie.domain = val;
100325
+ break;
100326
+ case "path":
100327
+ setCookie.path = val;
100328
+ break;
100329
+ case "max-age":
100330
+ if (val && maxAgeRegExp.test(val))
100331
+ setCookie.maxAge = Number(val);
100332
+ break;
100333
+ case "expires":
100334
+ if (!val)
100335
+ break;
100336
+ let date2 = new Date(val);
100337
+ if (Number.isFinite(date2.valueOf()))
100338
+ setCookie.expires = date2;
100339
+ break;
100340
+ case "priority":
100341
+ if (!val)
100342
+ break;
100343
+ let priority = val.toLowerCase();
100344
+ if (priority === "low" || priority === "medium" || priority === "high")
100345
+ setCookie.priority = priority;
100346
+ break;
100347
+ case "samesite":
100348
+ if (!val)
100349
+ break;
100350
+ let sameSite = val.toLowerCase();
100351
+ if (sameSite === "lax" || sameSite === "strict" || sameSite === "none")
100352
+ setCookie.sameSite = sameSite;
100353
+ break;
100354
+ }
100355
+ index = endIdx2 + 1;
100356
+ }
100357
+ return setCookie;
100358
+ }
100359
+ function endIndex(str, min, len) {
100360
+ let index = str.indexOf(";", min);
100361
+ return index === -1 ? len : index;
100362
+ }
100363
+ function eqIndex(str, min, max2) {
100364
+ let index = str.indexOf("=", min);
100365
+ return index < max2 ? index : -1;
100366
+ }
100367
+ function valueSlice(str, min, max2) {
100368
+ let start = min, end = max2;
100369
+ do {
100370
+ let code = str.charCodeAt(start);
100371
+ if (code !== 32 && code !== 9)
100372
+ break;
100373
+ } while (++start < end);
100374
+ while (end > start) {
100375
+ let code = str.charCodeAt(end - 1);
100376
+ if (code !== 32 && code !== 9)
100377
+ break;
100378
+ end--;
100379
+ }
100380
+ return str.slice(start, end);
100381
+ }
100319
100382
  function decode2(str) {
100320
100383
  if (str.indexOf("%") === -1)
100321
100384
  return str;
@@ -100608,7 +100671,7 @@ var mergeDeep = (target, source, options) => {
100608
100671
  if (!isObject(target) || !isObject(source))
100609
100672
  return target;
100610
100673
  for (let [key, value] of Object.entries(source)) {
100611
- if (skipKeys?.includes(key))
100674
+ if (skipKeys?.includes(key) || ["__proto__", "constructor", "prototype"].includes(key))
100612
100675
  continue;
100613
100676
  if (mergeArray && Array.isArray(value)) {
100614
100677
  target[key] = Array.isArray(target[key]) ? [...target[key], ...value] : target[key] = value;
@@ -101093,7 +101156,10 @@ class InvalidCookieSignature extends Error {
101093
101156
  var mapValueError = (error) => {
101094
101157
  if (!error)
101095
101158
  return { summary: undefined };
101096
- let { message, path, value, type } = error, property = path.slice(1).replaceAll("/", "."), isRoot = path === "";
101159
+ let { message, path, value, type } = error;
101160
+ if (Array.isArray(path))
101161
+ path = path[0];
101162
+ let property = typeof path === "string" ? path.slice(1).replaceAll("/", ".") : "unknown", isRoot = path === "";
101097
101163
  switch (type) {
101098
101164
  case 42:
101099
101165
  return { ...error, summary: isRoot ? "Value should not be provided" : `Property '${property}' should not be provided` };
@@ -101140,6 +101206,9 @@ class ValidationError extends Error {
101140
101206
  code = "VALIDATION";
101141
101207
  status = 422;
101142
101208
  valueError;
101209
+ get messageValue() {
101210
+ return this.valueError;
101211
+ }
101143
101212
  expected;
101144
101213
  customError;
101145
101214
  constructor(type, validator, value, allowUnsafeValidationDetails = false, errors) {
@@ -101197,11 +101266,11 @@ class ValidationError extends Error {
101197
101266
  toResponse(headers) {
101198
101267
  return new Response(this.message, { status: 400, headers: { ...headers, "content-type": "application/json" } });
101199
101268
  }
101200
- detail(message) {
101269
+ detail(message, allowUnsafeValidatorDetails = this.allowUnsafeValidationDetails) {
101201
101270
  if (!this.customError)
101202
101271
  return this.message;
101203
- let validator = this.validator, value = this.value, expected = this.expected, errors = this.all;
101204
- return isProduction && !this.allowUnsafeValidationDetails ? { type: "validation", on: this.type, found: value, message } : { type: "validation", on: this.type, property: this.valueError?.path || "root", message, summary: mapValueError(this.valueError).summary, found: value, expected, errors };
101272
+ let value = this.value, expected = this.expected, errors = this.all;
101273
+ return isProduction && !allowUnsafeValidatorDetails ? { type: "validation", on: this.type, found: value, message } : { type: "validation", on: this.type, property: this.valueError?.path || "root", message, summary: mapValueError(this.valueError).summary, found: value, expected, errors };
101205
101274
  }
101206
101275
  }
101207
101276
  var tryParse = (v, schema) => {
@@ -101678,11 +101747,18 @@ t.ArrayBuffer = ElysiaType.ArrayBuffer;
101678
101747
  t.Uint8Array = ElysiaType.Uint8Array;
101679
101748
  var import_cookie = __toESM2(require_dist(), 1);
101680
101749
  var import_fast_decode_uri_component = __toESM2(require_fast_decode_uri_component(), 1);
101750
+ var hashString = (str) => {
101751
+ let hash2 = 2166136261, len = str.length;
101752
+ for (let i2 = 0;i2 < len; i2++)
101753
+ hash2 ^= str.charCodeAt(i2), hash2 = Math.imul(hash2, 16777619);
101754
+ return hash2 >>> 0;
101755
+ };
101681
101756
 
101682
101757
  class Cookie {
101683
101758
  name;
101684
101759
  jar;
101685
101760
  initial;
101761
+ valueHash;
101686
101762
  constructor(name, jar, initial = {}) {
101687
101763
  this.name = name;
101688
101764
  this.jar = jar;
@@ -101694,7 +101770,7 @@ class Cookie {
101694
101770
  set cookie(jar) {
101695
101771
  if (!(this.name in this.jar))
101696
101772
  this.jar[this.name] = this.initial;
101697
- this.jar[this.name] = jar;
101773
+ this.jar[this.name] = jar, this.valueHash = undefined;
101698
101774
  }
101699
101775
  get setCookie() {
101700
101776
  if (!(this.name in this.jar))
@@ -101708,7 +101784,25 @@ class Cookie {
101708
101784
  return this.cookie.value;
101709
101785
  }
101710
101786
  set value(value) {
101711
- this.setCookie.value = value;
101787
+ let current = this.cookie.value;
101788
+ if (current === value)
101789
+ return;
101790
+ if (typeof current === "object" && current !== null && typeof value === "object" && value !== null)
101791
+ try {
101792
+ let valueStr = JSON.stringify(value), newHash = hashString(valueStr);
101793
+ if (this.valueHash !== undefined && this.valueHash !== newHash)
101794
+ this.valueHash = newHash;
101795
+ else {
101796
+ if (JSON.stringify(current) === valueStr) {
101797
+ this.valueHash = newHash;
101798
+ return;
101799
+ }
101800
+ this.valueHash = newHash;
101801
+ }
101802
+ } catch {}
101803
+ if (!(this.name in this.jar))
101804
+ this.jar[this.name] = { ...this.initial };
101805
+ this.jar[this.name].value = value;
101712
101806
  }
101713
101807
  get expires() {
101714
101808
  return this.cookie.expires;
@@ -102336,7 +102430,17 @@ var mapCompactResponse = (response, request) => {
102336
102430
  return new Response(response);
102337
102431
  }
102338
102432
  };
102339
- var errorToResponse = (error, set2) => new Response(JSON.stringify({ name: error?.name, message: error?.message, cause: error?.cause }), { status: set2?.status !== 200 ? set2?.status ?? 500 : 500, headers: set2?.headers });
102433
+ var errorToResponse = (error, set2) => {
102434
+ if (typeof error?.toResponse === "function") {
102435
+ let raw = error.toResponse(), targetSet = set2 ?? { headers: {}, status: 200, redirect: "" }, apply = (resolved) => {
102436
+ if (resolved instanceof Response)
102437
+ targetSet.status = resolved.status;
102438
+ return mapResponse(resolved, targetSet);
102439
+ };
102440
+ return typeof raw?.then === "function" ? raw.then(apply) : apply(raw);
102441
+ }
102442
+ return new Response(JSON.stringify({ name: error?.name, message: error?.message, cause: error?.cause }), { status: set2?.status !== 200 ? set2?.status ?? 500 : 500, headers: set2?.headers });
102443
+ };
102340
102444
  var createStaticHandler = (handle, hooks, setHeaders = {}) => {
102341
102445
  if (typeof handle === "function")
102342
102446
  return;
@@ -102389,10 +102493,7 @@ else c.body[key]=value}`;
102389
102493
  for (let key of Object.keys(app.decorator))
102390
102494
  decoratorsLiteral += `,'${key}':decorator['${key}']`;
102391
102495
  let standardHostname = app.config.handler?.standardHostname ?? true, hasTrace = !!app.event.trace?.length;
102392
- if (fnLiteral += `const u=r.url,s=u.indexOf('/',${standardHostname ? 11 : 7}),qi=u.indexOf('?',s+1)
102393
- let p
102394
- if(qi===-1)p=u.substring(s)
102395
- else p=u.substring(s, qi)
102496
+ if (fnLiteral += `const u=r.url,s=u.indexOf('/',${standardHostname ? 11 : 7}),qi=u.indexOf('?',s+1),p=u.substring(s,qi===-1?undefined:qi)
102396
102497
  `, hasTrace)
102397
102498
  fnLiteral += `const id=randomId()
102398
102499
  `;
@@ -102412,7 +102513,7 @@ return `;
102412
102513
  return findDynamicRoute += "}", { declare: hasErrorHook ? "" : `const error404Message=notFound.message.toString()
102413
102514
  const error404=new Response(error404Message,{status:404})
102414
102515
  `, code: findDynamicRoute };
102415
- } }, composeError: { mapResponseContext: "", validationError: "return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})", unknownError: "return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})" }, listen() {
102516
+ } }, composeError: { mapResponseContext: "", validationError: "set.headers['content-type']='application/json';return mapResponse(error.message,set)", unknownError: "set.status=error.status??set.status??500;return mapResponse(error.message,set)" }, listen() {
102416
102517
  return () => {
102417
102518
  throw Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead");
102418
102519
  };
@@ -103027,7 +103128,17 @@ var mapCompactResponse2 = (response, request) => {
103027
103128
  return new Response(response);
103028
103129
  }
103029
103130
  };
103030
- var errorToResponse2 = (error, set2) => new Response(JSON.stringify({ name: error?.name, message: error?.message, cause: error?.cause }), { status: set2?.status !== 200 ? set2?.status ?? 500 : 500, headers: set2?.headers });
103131
+ var errorToResponse2 = (error, set2) => {
103132
+ if (typeof error?.toResponse === "function") {
103133
+ let raw = error.toResponse(), targetSet = set2 ?? { headers: {}, status: 200, redirect: "" }, apply = (resolved) => {
103134
+ if (resolved instanceof Response)
103135
+ targetSet.status = resolved.status;
103136
+ return mapResponse2(resolved, targetSet);
103137
+ };
103138
+ return typeof raw?.then === "function" ? raw.then(apply) : apply(raw);
103139
+ }
103140
+ return new Response(JSON.stringify({ name: error?.name, message: error?.message, cause: error?.cause }), { status: set2?.status !== 200 ? set2?.status ?? 500 : 500, headers: set2?.headers });
103141
+ };
103031
103142
  var createStaticHandler2 = (handle, hooks, setHeaders = {}) => {
103032
103143
  if (typeof handle === "function")
103033
103144
  return;
@@ -103091,9 +103202,9 @@ function parseQueryFromURL(input, startIndex = 0, array, object) {
103091
103202
  finalValue = valueSlice;
103092
103203
  }
103093
103204
  let currentValue = result[finalKey];
103094
- if (array?.[finalKey])
103205
+ if (array && array?.[finalKey])
103095
103206
  if (finalValue.charCodeAt(0) === 91) {
103096
- if (object?.[finalKey])
103207
+ if (object && object?.[finalKey])
103097
103208
  finalValue = JSON.parse(finalValue);
103098
103209
  else
103099
103210
  finalValue = finalValue.slice(1, -1).split(",");
@@ -103318,7 +103429,7 @@ var createTracer = (traceListener) => {
103318
103429
  };
103319
103430
  var Kind3 = Symbol.for("TypeBox.Kind");
103320
103431
  var Hint2 = Symbol.for("TypeBox.Hint");
103321
- var isSpecialProperty = (name) => /(\ |-|\t|\n|\.)/.test(name) || !isNaN(+name[0]);
103432
+ var isSpecialProperty = (name) => /(\ |-|\t|\n|\.|\[|\]|\{|\})/.test(name) || !isNaN(+name[0]);
103322
103433
  var joinProperty = (v1, v2, isOptional = false) => {
103323
103434
  if (typeof v2 === "number")
103324
103435
  return `${v1}[${v2}]`;
@@ -103362,7 +103473,7 @@ var handleRecord = (schema, property, instruction) => {
103362
103473
  let v = `(()=>{const ar${i2}s=Object.keys(${property}),ar${i2}v={};for(let i=0;i<ar${i2}s.length;i++){const ar${i2}p=${property}[ar${i2}s[i]];ar${i2}v[ar${i2}s[i]]=${mirror(child, `ar${i2}p`, instruction)}`, optionals = instruction.optionalsInArray[i2 + 1];
103363
103474
  if (optionals)
103364
103475
  for (let oi = 0;oi < optionals.length; oi++) {
103365
- let target = `ar${i2}v[ar${i2}s[i]].${optionals[oi]}`;
103476
+ let target = `ar${i2}v[ar${i2}s[i]]${optionals[oi]}`;
103366
103477
  v += `;if(${target}===undefined)delete ${target}`;
103367
103478
  }
103368
103479
  return v += `}return ar${i2}v})()`, v;
@@ -103422,7 +103533,7 @@ var handleUnion = (schemas, property, instruction) => {
103422
103533
  else
103423
103534
  return instruction.modules.Import(type.$ref);
103424
103535
  return type;
103425
- };
103536
+ }, cleanThenCheck = "";
103426
103537
  for (let i2 = 0;i2 < schemas.length; i2++) {
103427
103538
  let type = unwrapRef(schemas[i2]);
103428
103539
  if (Array.isArray(type.anyOf))
@@ -103435,9 +103546,13 @@ var handleUnion = (schemas, property, instruction) => {
103435
103546
  else
103436
103547
  type.items = unwrapRef(type.items);
103437
103548
  typeChecks.push(TypeCompiler.Compile(type)), v += `if(d.unions[${ui}][${i2}].Check(${property})){return ${mirror(type, property, { ...instruction, recursion: instruction.recursion + 1, parentIsOptional: true })}}
103549
+ `, cleanThenCheck += (i2 ? "" : "let ") + "tmp=" + mirror(type, property, { ...instruction, recursion: instruction.recursion + 1, parentIsOptional: true }) + `
103550
+ if(d.unions[${ui}][${i2}].Check(tmp))return tmp
103438
103551
  `;
103439
103552
  }
103440
- return v += `return ${instruction.removeUnknownUnionType ? "undefined" : property}})()`, v;
103553
+ if (cleanThenCheck)
103554
+ v += cleanThenCheck;
103555
+ return v += `return ${instruction.removeUnknownUnionType ? "undefined" : property}`, v + "})()";
103441
103556
  };
103442
103557
  var mirror = (schema, property, instruction) => {
103443
103558
  if (!schema)
@@ -103466,7 +103581,17 @@ var mirror = (schema, property, instruction) => {
103466
103581
  if (isOptional) {
103467
103582
  let index = instruction.array;
103468
103583
  if (property.startsWith("ar")) {
103469
- let refName = name.slice(name.indexOf(".") + 1), array = instruction.optionalsInArray;
103584
+ let dotIndex = name.indexOf("."), refName;
103585
+ if (dotIndex >= 0)
103586
+ refName = name.slice(dotIndex);
103587
+ else
103588
+ refName = name.slice(property.length);
103589
+ if (refName.startsWith("?."))
103590
+ if (refName.charAt(2) === "[")
103591
+ refName = refName.slice(2);
103592
+ else
103593
+ refName = refName.slice(1);
103594
+ let array = instruction.optionalsInArray;
103470
103595
  if (array[index])
103471
103596
  array[index].push(refName);
103472
103597
  else
@@ -103482,18 +103607,19 @@ var mirror = (schema, property, instruction) => {
103482
103607
  v += "}";
103483
103608
  break;
103484
103609
  case "array":
103485
- if (schema.items.type !== "object" && schema.items.type !== "array")
103610
+ if (schema.items.type !== "object" && schema.items.type !== "array") {
103486
103611
  if (Array.isArray(schema.items)) {
103487
103612
  v = handleTuple(schema.items, property, instruction);
103488
103613
  break;
103489
- } else if (isRoot)
103614
+ } else if (isRoot && !Array.isArray(schema.items.anyOf))
103490
103615
  return "return v";
103491
103616
  else if (Kind3 in schema.items && schema.items.$ref && (schema.items[Kind3] === "Ref" || schema.items[Kind3] === "This"))
103492
103617
  v = mirror(deepClone(instruction.definitions[schema.items.$ref]), property, { ...instruction, parentIsOptional: true, recursion: instruction.recursion + 1 });
103493
- else {
103618
+ else if (!Array.isArray(schema.items.anyOf)) {
103494
103619
  v = property;
103495
103620
  break;
103496
103621
  }
103622
+ }
103497
103623
  let i2 = instruction.array;
103498
103624
  instruction.array++;
103499
103625
  let reference = property;
@@ -103505,7 +103631,7 @@ var mirror = (schema, property, instruction) => {
103505
103631
  let optionals = instruction.optionalsInArray[i2 + 1];
103506
103632
  if (optionals)
103507
103633
  for (let oi = 0;oi < optionals.length; oi++) {
103508
- let target = `ar${i2}v[i].${optionals[oi]}`;
103634
+ let target = `ar${i2}v[i]${optionals[oi]}`;
103509
103635
  v += `;if(${target}===undefined)delete ${target}`;
103510
103636
  }
103511
103637
  if (v += "}", !isRoot)
@@ -104339,7 +104465,7 @@ var composeValidationFactory = ({ injectResponse = "", normalize = false, valida
104339
104465
  let code = injectResponse + `
104340
104466
  `;
104341
104467
  code += `if(${name} instanceof ElysiaCustomStatusResponse){c.set.status=${name}.code
104342
- ${name}=${name}.response}if(${name} instanceof Response === false)switch(c.set.status){`;
104468
+ ${name}=${name}.response}if(${name} instanceof Response === false && typeof ${name}?.next !== 'function' && !(${name} instanceof ReadableStream))switch(c.set.status){`;
104343
104469
  for (let [status2, value] of Object.entries(validator.response)) {
104344
104470
  if (code += `
104345
104471
  case ${status2}:
@@ -104463,11 +104589,14 @@ return function(){return a}`)(handler);
104463
104589
  let secret = !cookieMeta.secrets ? undefined : typeof cookieMeta.secrets === "string" ? cookieMeta.secrets : cookieMeta.secrets[0];
104464
104590
  if (_encodeCookie += `const _setCookie = c.set.cookie
104465
104591
  if(_setCookie){`, cookieMeta.sign === true)
104466
- _encodeCookie += `for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${secret}')}`;
104467
- else
104592
+ _encodeCookie += `for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,${!secret ? "undefined" : JSON.stringify(secret)})}`;
104593
+ else {
104594
+ if (typeof cookieMeta.sign === "string")
104595
+ cookieMeta.sign = [cookieMeta.sign];
104468
104596
  for (let name of cookieMeta.sign)
104469
- _encodeCookie += `if(_setCookie['${name}']?.value)c.set.cookie['${name}'].value=await signCookie(_setCookie['${name}'].value,'${secret}')
104597
+ _encodeCookie += `if(_setCookie[${JSON.stringify(name)}]?.value)c.set.cookie[${JSON.stringify(name)}].value=await signCookie(_setCookie[${JSON.stringify(name)}].value,${!secret ? "undefined" : JSON.stringify(secret)})
104470
104598
  `;
104599
+ }
104471
104600
  _encodeCookie += `}
104472
104601
  `;
104473
104602
  }
@@ -104484,14 +104613,16 @@ if(_setCookie){`, cookieMeta.sign === true)
104484
104613
  if (fnLiteral += "try{", hasCookie) {
104485
104614
  let get = (name, defaultValue) => {
104486
104615
  let value = cookieMeta?.[name] ?? defaultValue;
104616
+ if (value === undefined)
104617
+ return "";
104487
104618
  if (!value)
104488
104619
  return typeof defaultValue === "string" ? `${name}:"${defaultValue}",` : `${name}:${defaultValue},`;
104489
104620
  if (typeof value === "string")
104490
- return `${name}:'${value}',`;
104621
+ return `${name}:${JSON.stringify(value)},`;
104491
104622
  if (value instanceof Date)
104492
104623
  return `${name}: new Date(${value.getTime()}),`;
104493
104624
  return `${name}:${value},`;
104494
- }, options = cookieMeta ? `{secrets:${cookieMeta.secrets !== undefined ? typeof cookieMeta.secrets === "string" ? `'${cookieMeta.secrets}'` : "[" + cookieMeta.secrets.reduce((a, b) => a + `'${b}',`, "") + "]" : "undefined"},sign:${cookieMeta.sign === true ? true : cookieMeta.sign !== undefined ? "[" + cookieMeta.sign.reduce((a, b) => a + `'${b}',`, "") + "]" : "undefined"},` + get("domain") + get("expires") + get("httpOnly") + get("maxAge") + get("path", "/") + get("priority") + get("sameSite") + get("secure") + "}" : "undefined";
104625
+ }, options = cookieMeta ? `{secrets:${cookieMeta.secrets !== undefined ? typeof cookieMeta.secrets === "string" ? JSON.stringify(cookieMeta.secrets) : "[" + cookieMeta.secrets.map((x2) => JSON.stringify(x2)).join(",") + "]" : "undefined"},sign:${cookieMeta.sign === true ? true : cookieMeta.sign !== undefined ? typeof cookieMeta.sign === "string" ? JSON.stringify(cookieMeta.sign) : "[" + cookieMeta.sign.map((x2) => JSON.stringify(x2)).join(",") + "]" : "undefined"},` + get("domain") + get("expires") + get("httpOnly") + get("maxAge") + get("path", "/") + get("priority") + get("sameSite") + get("secure") + "}" : "undefined";
104495
104626
  if (hasHeaders)
104496
104627
  fnLiteral += `
104497
104628
  c.cookie=await parseCookie(c.set,c.headers.cookie,${options})
@@ -104508,12 +104639,12 @@ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${options})
104508
104639
  if (Kind in schema && schema.properties)
104509
104640
  for (let [key, value] of Object.entries(schema.properties)) {
104510
104641
  if (hasElysiaMeta("ArrayQuery", value))
104511
- arrayProperties[key] = 1, hasArrayProperty = true;
104642
+ arrayProperties[key] = true, hasArrayProperty = true;
104512
104643
  if (hasElysiaMeta("ObjectString", value))
104513
- objectProperties[key] = 1, hasObjectProperty = true;
104644
+ objectProperties[key] = true, hasObjectProperty = true;
104514
104645
  }
104515
104646
  }
104516
- fnLiteral += `if(c.qi===-1){c.query=Object.create(null)}else{c.query=parseQueryFromURL(c.url,c.qi+1,${hasArrayProperty ? JSON.stringify(arrayProperties) : undefined},${hasObjectProperty ? JSON.stringify(objectProperties) : undefined})}`;
104647
+ fnLiteral += `if(c.qi===-1){c.query=Object.create(null)}else{c.query=parseQueryFromURL(c.url,c.qi+1${hasArrayProperty ? "," + JSON.stringify(arrayProperties) : hasObjectProperty ? ",undefined" : ""}${hasObjectProperty ? "," + JSON.stringify(objectProperties) : ""})}`;
104517
104648
  }
104518
104649
  let isAsyncHandler = typeof handler === "function" && isAsync(handler), saveResponse = hasTrace || hooks.afterResponse?.length ? "c.response=c.responseValue= " : "", responseKeys = Object.keys(validator.response ?? {}), hasMultipleResponses = responseKeys.length > 1, hasSingle200 = responseKeys.length === 0 || responseKeys.length === 1 && responseKeys[0] === "200", maybeAsync = hasCookie || hasBody || isAsyncHandler || !!hooks.parse?.length || !!hooks.afterHandle?.some(isAsync) || !!hooks.beforeHandle?.some(isAsync) || !!hooks.transform?.some(isAsync) || !!hooks.mapResponse?.some(isAsync) || validator.body?.provider === "standard" || validator.headers?.provider === "standard" || validator.query?.provider === "standard" || validator.params?.provider === "standard" || validator.cookie?.provider === "standard" || Object.values(validator.response ?? {}).find((x2) => x2.provider === "standard"), maybeStream = (typeof handler === "function" ? isGenerator(handler) : false) || !!hooks.beforeHandle?.some(isGenerator) || !!hooks.afterHandle?.some(isGenerator) || !!hooks.transform?.some(isGenerator), hasSet = inference.cookie || inference.set || hasHeaders || hasTrace || hasMultipleResponses || !hasSingle200 || isHandleFn && hasDefaultHeaders || maybeStream, _afterResponse, afterResponse = (hasStream = true) => {
104519
104650
  if (_afterResponse !== undefined)
@@ -104544,7 +104675,7 @@ ${prefix}e.afterResponse[${i2}](c)
104544
104675
  if (!after)
104545
104676
  return `return ${response}`;
104546
104677
  return `const _res=${response}` + after + "return _res";
104547
- }, mapResponseContext = maybeStream || adapter.mapResponseContext ? `,${adapter.mapResponseContext}` : "";
104678
+ }, mapResponseContext = maybeStream && adapter.mapResponseContext ? `,${adapter.mapResponseContext}` : "";
104548
104679
  if (hasTrace || inference.route)
104549
104680
  fnLiteral += `c.route=\`${path}\`
104550
104681
  `;
@@ -104913,7 +105044,7 @@ if(vac.issues){` + validation.validate("cookie", undefined, "vac.issues") + `}el
104913
105044
  `;
104914
105045
  else if (validator.body?.schema?.noValidate !== true) {
104915
105046
  if (fnLiteral += "if(validator.cookie.Check(cookieValue)===false){" + validation.validate("cookie", "cookieValue") + "}", validator.cookie.hasTransform)
104916
- fnLiteral += coerceTransformDecodeError("for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue))){c.cookie[key].value=value}", "cookie", allowUnsafeValidationDetails);
105047
+ fnLiteral += coerceTransformDecodeError("for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue))){c.cookie[key].cookie.value = value}", "cookie", allowUnsafeValidationDetails);
104917
105048
  }
104918
105049
  if (validator.cookie.isOptional)
104919
105050
  fnLiteral += "}";
@@ -105174,7 +105305,7 @@ c.defs=definitions
105174
105305
  fnLiteral = init + fnLiteral + "}", init = "";
105175
105306
  try {
105176
105307
  return Function("hooks", `"use strict";
105177
- ` + fnLiteral)({ handler, hooks: lifeCycleToFn(hooks), validator: hasValidation ? validator : undefined, handleError: app.handleError, mapResponse: adapterHandler.mapResponse, mapCompactResponse: adapterHandler.mapCompactResponse, mapEarlyResponse: adapterHandler.mapEarlyResponse, isNotEmpty, utils: { parseQuery: hasBody ? parseQuery : undefined, parseQueryFromURL: hasQuery ? validator.query?.provider === "standard" ? parseQueryStandardSchema : parseQueryFromURL : undefined }, error: { ValidationError: hasValidation ? ValidationError : undefined, ParseError: hasBody ? ParseError2 : undefined }, fileType, schema: app.router.history, definitions: app.definitions.type, tee, ERROR_CODE, parseCookie: hasCookie ? parseCookie : undefined, signCookie: hasCookie ? signCookie : undefined, decodeURIComponent: hasQuery ? import_fast_decode_uri_component3.default : undefined, ElysiaCustomStatusResponse, ELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined, ELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined, getServer: inference.server ? () => app.getServer() : undefined, fileUnions: fileUnions.length ? fileUnions : undefined, TypeBoxError: hasValidation ? TypeBoxError : undefined, parser: app["~parser"], ...adapter.inject });
105308
+ ` + fnLiteral)({ handler, hooks: lifeCycleToFn(hooks), validator: hasValidation ? validator : undefined, handleError: app.handleError, mapResponse: adapterHandler.mapResponse, mapCompactResponse: adapterHandler.mapCompactResponse, mapEarlyResponse: adapterHandler.mapEarlyResponse, isNotEmpty, utils: { parseQuery: hasBody ? parseQuery : undefined, parseQueryFromURL: hasQuery ? validator.query?.provider === "standard" ? parseQueryStandardSchema : parseQueryFromURL : undefined }, error: { ValidationError: hasValidation ? ValidationError : undefined, ParseError: hasBody ? ParseError2 : undefined }, fileType, schema: app.router.history, definitions: app.definitions.type, tee, ERROR_CODE, parseCookie: hasCookie ? parseCookie : undefined, signCookie: hasCookie ? signCookie : undefined, Cookie: hasCookie ? Cookie : undefined, decodeURIComponent: hasQuery ? import_fast_decode_uri_component3.default : undefined, ElysiaCustomStatusResponse, ELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined, ELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined, getServer: inference.server ? () => app.getServer() : undefined, fileUnions: fileUnions.length ? fileUnions : undefined, TypeBoxError: hasValidation ? TypeBoxError : undefined, parser: app["~parser"], ...adapter.inject });
105178
105309
  } catch (error) {
105179
105310
  let debugHooks = lifeCycleToFn(hooks);
105180
105311
  console.log("[Composer] failed to generate optimized handler"), console.log("---"), console.log({ handler: typeof handler === "function" ? handler.toString() : handler, instruction: fnLiteral, hooks: { ...debugHooks, transform: debugHooks?.transform?.map?.((x2) => x2.toString()), resolve: debugHooks?.resolve?.map?.((x2) => x2.toString()), beforeHandle: debugHooks?.beforeHandle?.map?.((x2) => x2.toString()), afterHandle: debugHooks?.afterHandle?.map?.((x2) => x2.toString()), mapResponse: debugHooks?.mapResponse?.map?.((x2) => x2.toString()), parse: debugHooks?.parse?.map?.((x2) => x2.toString()), error: debugHooks?.error?.map?.((x2) => x2.toString()), afterResponse: debugHooks?.afterResponse?.map?.((x2) => x2.toString()), stop: debugHooks?.stop?.map?.((x2) => x2.toString()) }, validator, definitions: app.definitions.type, error }), console.log("---"), process.exit(1);
@@ -105216,12 +105347,7 @@ var composeGeneralHandler = (app) => {
105216
105347
  if (findDynamicRoute += router.http.root.ALL ? `??router.find('ALL',p)
105217
105348
  ` : `
105218
105349
  `, isWebstandard)
105219
- findDynamicRoute += `if(r.method==='HEAD'){const route=router.find('GET',p)
105220
- if(route){c.params=route.params
105221
- const _res=route.store.handler?route.store.handler(c):route.store.compile()(c)
105222
- if(_res)return getResponseLength(_res).then((length)=>{_res.headers.set('content-length', length)
105223
- return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers})
105224
- })}}`;
105350
+ findDynamicRoute += 'if(r.method==="HEAD"){const route=router.find("GET",p);if(route){c.params=route.params;const _res=route.store.handler?route.store.handler(c):route.store.compile()(c);if(_res)return Promise.resolve(_res).then((_res)=>{if(!_res.headers)_res.headers=new Headers();return getResponseLength(_res).then((length)=>{_res.headers.set("content-length", length);return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers});})});}}';
105225
105351
  let afterResponse = `c.error=notFound
105226
105352
  `;
105227
105353
  if (app.event.afterResponse?.length && !app.event.error) {
@@ -105273,13 +105399,9 @@ return route.store.compile()(c)
105273
105399
  `;
105274
105400
  }
105275
105401
  if (isWebstandard && (("GET" in methods) || ("ALL" in methods)) && "HEAD" in methods === false)
105276
- switchMap += `case 'HEAD':const _ht=ht[${methods.GET ?? methods.ALL}].composed(c)
105277
- if(typeof _ht === 'function') {return _ht.then(_res=>getResponseLength(_res).then((length)=>{_res.headers.set('content-length', length)
105278
- return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers})
105279
- }))
105280
- }else{return getResponseLength(_ht).then((length)=>{_ht.headers.set('content-length', length)
105402
+ switchMap += `case 'HEAD':return Promise.resolve(ht[${methods.GET ?? methods.ALL}].composed(c)).then(_ht=>getResponseLength(_ht).then((length)=>{_ht.headers.set('content-length', length)
105281
105403
  return new Response(null,{status:_ht.status,statusText:_ht.statusText,headers:_ht.headers})
105282
- })}
105404
+ }))
105283
105405
  `;
105284
105406
  for (let [method, index] of Object.entries(methods)) {
105285
105407
  if (method === "ALL" || method === "GET" || method === "WS")
@@ -105337,8 +105459,8 @@ map: switch(p){
105337
105459
  };
105338
105460
  var composeErrorHandler = (app) => {
105339
105461
  let hooks = app.event, fnLiteral = "", adapter = app["~adapter"].composeError, adapterVariables = adapter.inject ? Object.keys(adapter.inject).join(",") + "," : "", hasTrace = !!app.event.trace?.length;
105340
- if (fnLiteral += "const {mapResponse,ERROR_CODE,ElysiaCustomStatusResponse," + allocateIf("onError,", app.event.error) + allocateIf("afterResponse,", app.event.afterResponse) + allocateIf("trace,", app.event.trace) + allocateIf("onMapResponse,", app.event.mapResponse) + allocateIf("ELYSIA_TRACE,", hasTrace) + allocateIf("ELYSIA_REQUEST_ID,", hasTrace) + adapterVariables + `}=inject
105341
- `, fnLiteral += `return ${app.event.error?.find(isAsync) || app.event.mapResponse?.find(isAsync) ? "async " : ""}function(context,error,skipGlobal){`, fnLiteral += "", hasTrace)
105462
+ if (fnLiteral += "const {mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ValidationError,TransformDecodeError," + allocateIf("onError,", app.event.error) + allocateIf("afterResponse,", app.event.afterResponse) + allocateIf("trace,", app.event.trace) + allocateIf("onMapResponse,", app.event.mapResponse) + allocateIf("ELYSIA_TRACE,", hasTrace) + allocateIf("ELYSIA_REQUEST_ID,", hasTrace) + adapterVariables + `}=inject
105463
+ `, fnLiteral += "return async function(context,error,skipGlobal){", fnLiteral += "", hasTrace)
105342
105464
  fnLiteral += `const id=context[ELYSIA_REQUEST_ID]
105343
105465
  `;
105344
105466
  let report = createReport({ context: "context", trace: hooks.trace, addFn: (word) => {
@@ -105370,11 +105492,18 @@ if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.co
105370
105492
  error.message=error.response}`, adapter.declare)
105371
105493
  fnLiteral += adapter.declare;
105372
105494
  let saveResponse = hasTrace || !!hooks.afterResponse?.length ? "context.response = " : "";
105373
- if (app.event.error)
105495
+ if (fnLiteral += `if(typeof error?.toResponse==='function'&&!(error instanceof ValidationError)&&!(error instanceof TransformDecodeError)){try{let raw=error.toResponse()
105496
+ if(typeof raw?.then==='function')raw=await raw
105497
+ if(raw instanceof Response)set.status=raw.status
105498
+ context.response=context.responseValue=raw
105499
+ }catch(toResponseError){
105500
+ }
105501
+ }
105502
+ `, app.event.error)
105374
105503
  for (let i2 = 0;i2 < app.event.error.length; i2++) {
105375
105504
  let handler = app.event.error[i2], response = `${isAsync(handler) ? "await " : ""}onError[${i2}](context)
105376
105505
  `;
105377
- if (fnLiteral += "if(skipGlobal!==true){", hasReturn(handler)) {
105506
+ if (fnLiteral += "if(skipGlobal!==true&&!context.response){", hasReturn(handler)) {
105378
105507
  fnLiteral += `_r=${response}
105379
105508
  if(_r!==undefined){if(_r instanceof Response){` + afterResponse() + `return mapResponse(_r,set${adapter.mapResponseContext})}if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
105380
105509
  error.message = error.response}if(set.status===200||!set.status)set.status=error.status
@@ -105391,14 +105520,12 @@ error.message = error.response}if(set.status===200||!set.status)set.status=error
105391
105520
  fnLiteral += response;
105392
105521
  fnLiteral += "}";
105393
105522
  }
105394
- fnLiteral += `if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){
105523
+ fnLiteral += `if(error instanceof ValidationError||error instanceof TransformDecodeError){
105395
105524
  if(error.error)error=error.error
105396
105525
  set.status=error.status??422
105397
105526
  ` + afterResponse() + adapter.validationError + `
105398
105527
  }
105399
- `, fnLiteral += "if(error instanceof Error){" + afterResponse() + `
105400
- if(typeof error.toResponse==='function')return context.response=context.responseValue=error.toResponse()
105401
- ` + adapter.unknownError + `
105528
+ `, fnLiteral += "if(!context.response&&error instanceof Error){" + afterResponse() + adapter.unknownError + `
105402
105529
  }`;
105403
105530
  let mapResponseReporter = report("mapResponse", { total: hooks.mapResponse?.length, name: "context" });
105404
105531
  if (fnLiteral += `
@@ -105416,7 +105543,7 @@ if(mr!==undefined)error=context.response=context.responseValue=mr}`, endUnit();
105416
105543
  return mapResponse(${saveResponse}error,set${adapter.mapResponseContext})}`;
105417
105544
  let mapFn = (x2) => typeof x2 === "function" ? x2 : x2.fn;
105418
105545
  return Function("inject", `"use strict";
105419
- ` + fnLiteral)({ mapResponse: app["~adapter"].handler.mapResponse, ERROR_CODE, ElysiaCustomStatusResponse, onError: app.event.error?.map(mapFn), afterResponse: app.event.afterResponse?.map(mapFn), trace: app.event.trace?.map(mapFn), onMapResponse: app.event.mapResponse?.map(mapFn), ELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined, ELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined, ...adapter.inject });
105546
+ ` + fnLiteral)({ mapResponse: app["~adapter"].handler.mapResponse, ERROR_CODE, ElysiaCustomStatusResponse, ValidationError, TransformDecodeError, onError: app.event.error?.map(mapFn), afterResponse: app.event.afterResponse?.map(mapFn), trace: app.event.trace?.map(mapFn), onMapResponse: app.event.mapResponse?.map(mapFn), ELYSIA_TRACE: hasTrace ? ELYSIA_TRACE : undefined, ELYSIA_REQUEST_ID: hasTrace ? ELYSIA_REQUEST_ID : undefined, ...adapter.inject });
105420
105547
  };
105421
105548
  var allocateIf2 = (value, condition) => condition ? value : "";
105422
105549
  var createContext = (app, route, inference, isInline = false) => {
@@ -105488,6 +105615,10 @@ var websocket = { open(ws) {
105488
105615
  ws.data.drain?.(ws);
105489
105616
  }, close(ws, code, reason) {
105490
105617
  ws.data.close?.(ws, code, reason);
105618
+ }, ping(ws) {
105619
+ ws.data.ping?.(ws);
105620
+ }, pong(ws) {
105621
+ ws.data.pong?.(ws);
105491
105622
  } };
105492
105623
 
105493
105624
  class ElysiaWS {
@@ -105586,7 +105717,7 @@ var createWSMessageParser = (parse2) => {
105586
105717
  return message;
105587
105718
  };
105588
105719
  };
105589
- var createHandleWSResponse = (validateResponse) => {
105720
+ var createHandleWSResponse = (responseValidator) => {
105590
105721
  let handleWSResponse = (ws, data) => {
105591
105722
  if (data instanceof Promise)
105592
105723
  return data.then((data2) => handleWSResponse(ws, data2));
@@ -105594,9 +105725,9 @@ var createHandleWSResponse = (validateResponse) => {
105594
105725
  return ws.send(data.toString());
105595
105726
  if (data === undefined)
105596
105727
  return;
105597
- let send = (datum) => {
105598
- if (validateResponse?.Check(datum) === false)
105599
- return ws.send(new ValidationError("message", validateResponse, datum).message);
105728
+ let validateResponse = responseValidator ? responseValidator.provider === "standard" ? (data2) => responseValidator.schema["~standard"].validate(data2).issues : (data2) => responseValidator.Check(data2) === false : undefined, send = (datum) => {
105729
+ if (validateResponse && validateResponse(datum) === false)
105730
+ return ws.send(new ValidationError("message", responseValidator, datum).message);
105600
105731
  if (typeof datum === "object")
105601
105732
  return ws.send(JSON.stringify(datum));
105602
105733
  ws.send(datum);
@@ -105607,8 +105738,8 @@ var createHandleWSResponse = (validateResponse) => {
105607
105738
  if (init instanceof Promise)
105608
105739
  return (async () => {
105609
105740
  let first = await init;
105610
- if (validateResponse?.Check(first) === false)
105611
- return ws.send(new ValidationError("message", validateResponse, first).message);
105741
+ if (validateResponse && validateResponse(first))
105742
+ return ws.send(new ValidationError("message", responseValidator, first).message);
105612
105743
  if (send(first.value), !first.done)
105613
105744
  for await (let datum of data)
105614
105745
  send(datum);
@@ -105776,10 +105907,10 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
105776
105907
  } else
105777
105908
  console.log("Elysia isn't running. Call `app.listen` to start the server.", Error().stack);
105778
105909
  }, ws(app, path, options) {
105779
- let { parse: parse2, body, response, ...rest } = options, validateMessage = getSchemaValidator(body, { modules: app.definitions.typebox, models: app.definitions.type, normalize: app.config.normalize }), validateResponse = getSchemaValidator(response, { modules: app.definitions.typebox, models: app.definitions.type, normalize: app.config.normalize });
105910
+ let { parse: parse2, body, response, ...rest } = options, messageValidator = getSchemaValidator(body, { modules: app.definitions.typebox, models: app.definitions.type, normalize: app.config.normalize }), validateMessage = messageValidator ? messageValidator.provider === "standard" ? (data) => messageValidator.schema["~standard"].validate(data).issues : (data) => messageValidator.Check(data) === false : undefined, responseValidator = getSchemaValidator(response, { modules: app.definitions.typebox, models: app.definitions.type, normalize: app.config.normalize });
105780
105911
  app.route("WS", path, async (context) => {
105781
105912
  let server = context.server ?? app.server, { set: set2, path: path2, qi, headers, query, params } = context;
105782
- if (context.validator = validateResponse, options.upgrade) {
105913
+ if (context.validator = responseValidator, options.upgrade) {
105783
105914
  if (typeof options.upgrade === "function") {
105784
105915
  let temp = options.upgrade(context);
105785
105916
  if (temp instanceof Promise)
@@ -105794,7 +105925,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
105794
105925
  }
105795
105926
  if (set2.headers["set-cookie"] && Array.isArray(set2.headers["set-cookie"]))
105796
105927
  set2.headers = parseSetCookies(new Headers(set2.headers), set2.headers["set-cookie"]);
105797
- let handleResponse3 = createHandleWSResponse(validateResponse), parseMessage = createWSMessageParser(parse2), _id;
105928
+ let handleResponse3 = createHandleWSResponse(responseValidator), parseMessage = createWSMessageParser(parse2), _id;
105798
105929
  if (typeof options.beforeHandle === "function") {
105799
105930
  let result = options.beforeHandle(context);
105800
105931
  if (result instanceof Promise)
@@ -105813,7 +105944,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
105813
105944
  if (_id)
105814
105945
  return _id;
105815
105946
  return _id = randomId();
105816
- }, validator: validateResponse, ping(ws, data) {
105947
+ }, validator: responseValidator, ping(ws, data) {
105817
105948
  options.ping?.(ws, data);
105818
105949
  }, pong(ws, data) {
105819
105950
  options.pong?.(ws, data);
@@ -105825,8 +105956,8 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
105825
105956
  }
105826
105957
  }, message: async (ws, _message) => {
105827
105958
  let message = await parseMessage(ws, _message);
105828
- if (validateMessage?.Check(message) === false) {
105829
- let validationError = new ValidationError("message", validateMessage, message);
105959
+ if (validateMessage && validateMessage(message)) {
105960
+ let validationError = new ValidationError("message", messageValidator, message);
105830
105961
  if (!hasCustomErrorHandlers)
105831
105962
  return void ws.send(validationError.message);
105832
105963
  return handleErrors(ws, validationError);
@@ -105850,7 +105981,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
105850
105981
  }
105851
105982
  } } }))
105852
105983
  return;
105853
- return set2.status = 400, "Expected a websocket connection";
105984
+ return status(400, "Expected a websocket connection");
105854
105985
  }, { ...rest, websocket: options });
105855
105986
  } };
105856
105987
  var injectDefaultValues = (typeChecker, obj2) => {
@@ -105896,7 +106027,7 @@ var createDynamicHandler = (app) => {
105896
106027
  case "application/octet-stream":
105897
106028
  body = await request.arrayBuffer();
105898
106029
  break;
105899
- case "multipart/form-data":
106030
+ case "multipart/form-data": {
105900
106031
  body = {};
105901
106032
  let form2 = await request.formData();
105902
106033
  for (let key of form2.keys()) {
@@ -105909,6 +106040,7 @@ var createDynamicHandler = (app) => {
105909
106040
  body[key] = value;
105910
106041
  }
105911
106042
  break;
106043
+ }
105912
106044
  }
105913
106045
  else {
105914
106046
  let contentType;
@@ -105940,7 +106072,7 @@ var createDynamicHandler = (app) => {
105940
106072
  body = await request.arrayBuffer();
105941
106073
  break;
105942
106074
  case "formdata":
105943
- case "multipart/form-data":
106075
+ case "multipart/form-data": {
105944
106076
  body = {};
105945
106077
  let form2 = await request.formData();
105946
106078
  for (let key of form2.keys()) {
@@ -105953,7 +106085,8 @@ var createDynamicHandler = (app) => {
105953
106085
  body[key] = value;
105954
106086
  }
105955
106087
  break;
105956
- default:
106088
+ }
106089
+ default: {
105957
106090
  let parser = app["~parser"][hook];
105958
106091
  if (parser) {
105959
106092
  let temp = parser(context, contentType);
@@ -105965,6 +106098,7 @@ var createDynamicHandler = (app) => {
105965
106098
  }
105966
106099
  }
105967
106100
  break;
106101
+ }
105968
106102
  }
105969
106103
  else {
105970
106104
  let temp = hook(context, contentType);
@@ -105990,7 +106124,7 @@ var createDynamicHandler = (app) => {
105990
106124
  case "application/octet-stream":
105991
106125
  body = await request.arrayBuffer();
105992
106126
  break;
105993
- case "multipart/form-data":
106127
+ case "multipart/form-data": {
105994
106128
  body = {};
105995
106129
  let form2 = await request.formData();
105996
106130
  for (let key of form2.keys()) {
@@ -106003,6 +106137,7 @@ var createDynamicHandler = (app) => {
106003
106137
  body[key] = value;
106004
106138
  }
106005
106139
  break;
106140
+ }
106006
106141
  }
106007
106142
  }
106008
106143
  }
@@ -106184,7 +106319,16 @@ var createDynamicErrorHandler = (app) => {
106184
106319
  let { mapResponse: mapResponse3 } = app["~adapter"].handler;
106185
106320
  return async (context, error) => {
106186
106321
  let errorContext = Object.assign(context, { error, code: error.code });
106187
- if (errorContext.set = context.set, app.event.error)
106322
+ if (errorContext.set = context.set, typeof error?.toResponse === "function" && !(error instanceof ValidationError) && !(error instanceof TransformDecodeError))
106323
+ try {
106324
+ let raw = error.toResponse();
106325
+ if (typeof raw?.then === "function")
106326
+ raw = await raw;
106327
+ if (raw instanceof Response)
106328
+ context.set.status = raw.status;
106329
+ context.response = raw;
106330
+ } catch (toResponseError) {}
106331
+ if (!context.response && app.event.error)
106188
106332
  for (let i2 = 0;i2 < app.event.error.length; i2++) {
106189
106333
  let response = app.event.error[i2].fn(errorContext);
106190
106334
  if (response instanceof Promise)
@@ -106192,7 +106336,18 @@ var createDynamicErrorHandler = (app) => {
106192
106336
  if (response !== undefined && response !== null)
106193
106337
  return context.response = mapResponse3(response, context.set);
106194
106338
  }
106195
- return new Response(typeof error.cause === "string" ? error.cause : error.message, { headers: context.set.headers, status: error.status ?? 500 });
106339
+ if (context.response) {
106340
+ if (app.event.mapResponse)
106341
+ for (let i2 = 0;i2 < app.event.mapResponse.length; i2++) {
106342
+ let response = app.event.mapResponse[i2].fn(errorContext);
106343
+ if (response instanceof Promise)
106344
+ response = await response;
106345
+ if (response !== undefined && response !== null)
106346
+ context.response = response;
106347
+ }
106348
+ return mapResponse3(context.response, context.set);
106349
+ }
106350
+ return context.set.status = error.status ?? 500, mapResponse3(typeof error.cause === "string" ? error.cause : error.message, context.set);
106196
106351
  };
106197
106352
  };
106198
106353
 
@@ -106415,27 +106570,28 @@ class Elysia {
106415
106570
  this.router.response[path2] = nativeStaticHandler();
106416
106571
  };
106417
106572
  addResponsePath(path);
106418
- let _compiled, compile2 = () => {
106419
- if (_compiled)
106420
- return _compiled;
106421
- return _compiled = composeHandler({ app: this, path, method, hooks, validator: createValidator(), handler: typeof handle !== "function" && typeof adapter.createStaticHandler !== "function" ? () => handle : handle, allowMeta, inference: this.inference });
106573
+ let compile2 = () => {
106574
+ let compiled = composeHandler({ app: this, path, method, hooks, validator: createValidator(), handler: typeof handle !== "function" && typeof adapter.createStaticHandler !== "function" ? () => handle : handle, allowMeta, inference: this.inference });
106575
+ if (this.router.history[index])
106576
+ this.router.history[index].composed = compiled;
106577
+ return compiled;
106422
106578
  }, oldIndex;
106423
106579
  if (`${method}_${path}` in this.routeTree)
106424
106580
  for (let i2 = 0;i2 < this.router.history.length; i2++) {
106425
- let route = this.router.history[i2];
106426
- if (route.path === path && route.method === method) {
106581
+ let route2 = this.router.history[i2];
106582
+ if (route2.path === path && route2.method === method) {
106427
106583
  oldIndex = i2;
106428
106584
  break;
106429
106585
  }
106430
106586
  }
106431
106587
  else
106432
106588
  this.routeTree[`${method}_${path}`] = this.router.history.length;
106433
- let index = oldIndex ?? this.router.history.length, mainHandler = shouldPrecompile ? compile2() : (ctx) => (this.router.history[index].composed = compile2())(ctx);
106589
+ let index = oldIndex ?? this.router.history.length, route = this.router.history, mainHandler = shouldPrecompile ? compile2() : (ctx) => (route[index].composed = compile2())(ctx);
106434
106590
  if (oldIndex !== undefined)
106435
106591
  this.router.history[oldIndex] = Object.assign({ method, path, composed: mainHandler, compile: compile2, handler: handle, hooks }, standaloneValidators.length ? { standaloneValidators } : undefined, localHook.webSocket ? { websocket: localHook.websocket } : undefined);
106436
106592
  else
106437
106593
  this.router.history.push(Object.assign({ method, path, composed: mainHandler, compile: compile2, handler: handle, hooks }, localHook.webSocket ? { websocket: localHook.websocket } : undefined));
106438
- let handler = { handler: shouldPrecompile ? mainHandler : undefined, compile() {
106594
+ let handler = { handler: shouldPrecompile ? route[index].composed : undefined, compile() {
106439
106595
  return this.handler = compile2();
106440
106596
  } }, staticRouter = this.router.static, isStaticPath = path.indexOf(":") === -1 && path.indexOf("*") === -1;
106441
106597
  if (method === "WS") {
@@ -106892,6 +107048,10 @@ class Elysia {
106892
107048
  insertStandaloneValidator(localHook, k2, value2), delete localHook[key];
106893
107049
  continue;
106894
107050
  }
107051
+ if (k2 === "introspect") {
107052
+ value2?.(localHook), delete localHook[key];
107053
+ continue;
107054
+ }
106895
107055
  if (k2 === "detail") {
106896
107056
  if (!localHook.detail)
106897
107057
  localHook.detail = {};
@@ -136264,7 +136424,7 @@ class WithSubquery extends Subquery {
136264
136424
  }
136265
136425
 
136266
136426
  // node_modules/drizzle-orm/version.js
136267
- var version4 = "0.44.7";
136427
+ var version4 = "0.45.0";
136268
136428
 
136269
136429
  // node_modules/drizzle-orm/tracing.js
136270
136430
  var otel;
@@ -136897,6 +137057,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
136897
137057
  decoder2 = field;
136898
137058
  } else if (is(field, SQL)) {
136899
137059
  decoder2 = field.decoder;
137060
+ } else if (is(field, Subquery)) {
137061
+ decoder2 = field._.sql.decoder;
136900
137062
  } else {
136901
137063
  decoder2 = field.sql.decoder;
136902
137064
  }
@@ -136937,7 +137099,7 @@ function orderSelectedFields(fields, pathPrefix) {
136937
137099
  return result;
136938
137100
  }
136939
137101
  const newPath = pathPrefix ? [...pathPrefix, name] : [name];
136940
- if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased)) {
137102
+ if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) {
136941
137103
  result.push({ path: newPath, field });
136942
137104
  } else if (is(field, Table)) {
136943
137105
  result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
@@ -137321,7 +137483,9 @@ class PgDate extends PgColumn {
137321
137483
  return "date";
137322
137484
  }
137323
137485
  mapFromDriverValue(value) {
137324
- return new Date(value);
137486
+ if (typeof value === "string")
137487
+ return new Date(value);
137488
+ return value;
137325
137489
  }
137326
137490
  mapToDriverValue(value) {
137327
137491
  return value.toISOString();
@@ -137343,6 +137507,11 @@ class PgDateString extends PgColumn {
137343
137507
  getSQLType() {
137344
137508
  return "date";
137345
137509
  }
137510
+ mapFromDriverValue(value) {
137511
+ if (typeof value === "string")
137512
+ return value;
137513
+ return value.toISOString().slice(0, -14);
137514
+ }
137346
137515
  }
137347
137516
  function date7(a, b) {
137348
137517
  const { name, config: config5 } = getColumnNameAndConfig(a, b);
@@ -138085,9 +138254,11 @@ class PgTimestamp extends PgColumn {
138085
138254
  const precision = this.precision === undefined ? "" : ` (${this.precision})`;
138086
138255
  return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
138087
138256
  }
138088
- mapFromDriverValue = (value) => {
138089
- return new Date(this.withTimezone ? value : value + "+0000");
138090
- };
138257
+ mapFromDriverValue(value) {
138258
+ if (typeof value === "string")
138259
+ return new Date(this.withTimezone ? value : value + "+0000");
138260
+ return value;
138261
+ }
138091
138262
  mapToDriverValue = (value) => {
138092
138263
  return value.toISOString();
138093
138264
  };
@@ -138118,6 +138289,17 @@ class PgTimestampString extends PgColumn {
138118
138289
  const precision = this.precision === undefined ? "" : `(${this.precision})`;
138119
138290
  return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
138120
138291
  }
138292
+ mapFromDriverValue(value) {
138293
+ if (typeof value === "string")
138294
+ return value;
138295
+ const shortened = value.toISOString().slice(0, -1).replace("T", " ");
138296
+ if (this.withTimezone) {
138297
+ const offset = value.getTimezoneOffset();
138298
+ const sign = offset <= 0 ? "+" : "-";
138299
+ return `${shortened}${sign}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
138300
+ }
138301
+ return shortened;
138302
+ }
138121
138303
  }
138122
138304
  function timestamp(a, b = {}) {
138123
138305
  const { name, config: config5 } = getColumnNameAndConfig(a, b);
@@ -140160,7 +140342,8 @@ class PgDialect {
140160
140342
  const setSize = columnNames.length;
140161
140343
  return sql3.join(columnNames.flatMap((colName, i2) => {
140162
140344
  const col = tableColumns[colName];
140163
- const value = set2[colName] ?? sql3.param(col.onUpdateFn(), col);
140345
+ const onUpdateFnResult = col.onUpdateFn?.();
140346
+ const value = set2[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql3.param(onUpdateFnResult, col));
140164
140347
  const res = sql3`${sql3.identifier(this.casing.getColumnCasing(col))} = ${value}`;
140165
140348
  if (i2 < setSize - 1) {
140166
140349
  return [res, sql3.raw(", ")];
@@ -140209,6 +140392,16 @@ class PgDialect {
140209
140392
  } else {
140210
140393
  chunk.push(field);
140211
140394
  }
140395
+ } else if (is(field, Subquery)) {
140396
+ const entries = Object.entries(field._.selectedFields);
140397
+ if (entries.length === 1) {
140398
+ const entry = entries[0][1];
140399
+ const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v) => entry.mapFromDriverValue(v) } : entry.sql.decoder;
140400
+ if (fieldDecoder) {
140401
+ field._.sql.decoder = fieldDecoder;
140402
+ }
140403
+ }
140404
+ chunk.push(field);
140212
140405
  }
140213
140406
  if (i2 < columnsLen - 1) {
140214
140407
  chunk.push(sql3`, `);
@@ -142174,6 +142367,7 @@ class PgTransaction extends PgDatabase {
142174
142367
 
142175
142368
  // node_modules/drizzle-orm/node-postgres/session.js
142176
142369
  var { Pool: Pool2, types: types2 } = esm_default;
142370
+ var NativePool = esm_default.native ? esm_default.native.Pool : undefined;
142177
142371
 
142178
142372
  class NodePgPreparedQuery extends PgPreparedQuery {
142179
142373
  constructor(client, queryString, params, logger2, cache2, queryMetadata, cacheConfig, fields, name, _isResponseInArrayMode, customResultMapper) {
@@ -142331,7 +142525,7 @@ class NodePgSession extends PgSession {
142331
142525
  return new NodePgPreparedQuery(this.client, query.sql, query.params, this.logger, this.cache, queryMetadata, cacheConfig, fields, name, isResponseInArrayMode, customResultMapper);
142332
142526
  }
142333
142527
  async transaction(transaction, config5) {
142334
- const session = this.client instanceof Pool2 ? new NodePgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
142528
+ const session = this.client instanceof Pool2 || NativePool && this.client instanceof NativePool ? new NodePgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
142335
142529
  const tx = new NodePgTransaction(this.dialect, session, this.schema);
142336
142530
  await tx.execute(sql3`begin${config5 ? sql3` ${tx.getTransactionConfigSQL(config5)}` : undefined}`);
142337
142531
  try {
@@ -142342,7 +142536,7 @@ class NodePgSession extends PgSession {
142342
142536
  await tx.execute(sql3`rollback`);
142343
142537
  throw error3;
142344
142538
  } finally {
142345
- if (this.client instanceof Pool2) {
142539
+ if (this.client instanceof Pool2 || NativePool && this.client instanceof NativePool) {
142346
142540
  session.client.release();
142347
142541
  }
142348
142542
  }
@@ -142855,7 +143049,7 @@ var companyBillingPlanTable = companySchema.table("billing_plan", {
142855
143049
  companyId: uuid5().notNull(),
142856
143050
  billingPeriod: companyBillingPeriodEnum().notNull().default("MONTHLY"),
142857
143051
  basePrice: numeric({ mode: "number" }).notNull(),
142858
- pricePerCar: numeric({ mode: "number" }),
143052
+ maxCarCount: integer2(),
142859
143053
  active: boolean4().notNull().default(true),
142860
143054
  note: text()
142861
143055
  });
@@ -142867,8 +143061,6 @@ var companyInvoiceTable = companySchema.table("invoice", {
142867
143061
  periodEnd: date7().notNull(),
142868
143062
  carCount: integer2().notNull(),
142869
143063
  basePrice: numeric({ mode: "number" }).notNull(),
142870
- carPrice: numeric({ mode: "number" }).notNull(),
142871
- totalPrice: numeric({ mode: "number" }).notNull(),
142872
143064
  status: companyInvoiceStatusEnum().notNull().default("PENDING"),
142873
143065
  issuedAt: timestamp({ withTimezone: true, mode: "string" }).notNull(),
142874
143066
  paidAt: timestamp({ withTimezone: true, mode: "string" }),
@@ -143431,7 +143623,7 @@ var db_default = db;
143431
143623
  var webCrypto = globalThis.crypto;
143432
143624
  var subtle = webCrypto.subtle;
143433
143625
 
143434
- // node_modules/@upstash/redis/chunk-TAJI6TAE.mjs
143626
+ // node_modules/@upstash/redis/chunk-TBGBPMGD.mjs
143435
143627
  var __defProp6 = Object.defineProperty;
143436
143628
  var __export4 = (target, all) => {
143437
143629
  for (var name in all)
@@ -146238,7 +146430,7 @@ var Redis = class {
146238
146430
  zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
146239
146431
  zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
146240
146432
  };
146241
- var VERSION = "v1.35.6";
146433
+ var VERSION = "v1.35.7";
146242
146434
 
146243
146435
  // node_modules/@upstash/redis/nodejs.mjs
146244
146436
  if (typeof atob === "undefined") {
@@ -146273,7 +146465,7 @@ var Redis2 = class _Redis extends Redis {
146273
146465
  });
146274
146466
  super(client, {
146275
146467
  automaticDeserialization: configOrRequester.automaticDeserialization,
146276
- enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
146468
+ enableTelemetry: configOrRequester.enableTelemetry ?? !process.env.UPSTASH_DISABLE_TELEMETRY,
146277
146469
  latencyLogging: configOrRequester.latencyLogging,
146278
146470
  enableAutoPipelining: configOrRequester.enableAutoPipelining
146279
146471
  });
@@ -147381,10 +147573,6 @@ var CompanyInvoiceLogic;
147381
147573
  if (!carCount || carCount === 0) {
147382
147574
  carCount = await CompanyInvoiceLogic.getCarCount(body.companyId);
147383
147575
  }
147384
- const basePrice = Number(billingPlan.basePrice);
147385
- const pricePerCar = billingPlan.pricePerCar ? Number(billingPlan.pricePerCar) : 0;
147386
- const carPrice = pricePerCar * Math.max(0, carCount - 1);
147387
- const totalPrice = basePrice + carPrice;
147388
147576
  const issuedAt = new Date;
147389
147577
  const dueAt = new Date(issuedAt);
147390
147578
  dueAt.setDate(dueAt.getDate() + 30);
@@ -147395,8 +147583,6 @@ var CompanyInvoiceLogic;
147395
147583
  periodStart: body.periodStart,
147396
147584
  periodEnd: periodEnd.toISOString().split("T")[0],
147397
147585
  carCount,
147398
- carPrice,
147399
- totalPrice,
147400
147586
  status: "PENDING",
147401
147587
  issuedAt: issuedAt.toISOString(),
147402
147588
  dueAt: dueAt.toISOString()
@@ -147481,13 +147667,12 @@ var CompanyInvoicePaymentLogic;
147481
147667
  }).from(companyInvoicePaymentTable).where(eq(companyInvoicePaymentTable.invoiceId, body.invoiceId));
147482
147668
  const totalPaid = paidAmountResult[0]?.totalPaid ?? 0;
147483
147669
  const newPaymentAmount = Number(body.amount);
147484
- const invoiceTotal = Number(invoice.totalPrice);
147485
147670
  const newTotalPaid = totalPaid + newPaymentAmount;
147486
147671
  const [payment] = await db_default.insert(companyInvoicePaymentTable).values({
147487
147672
  ...body,
147488
147673
  paidAt: body.paidAt || new Date().toISOString()
147489
147674
  }).returning();
147490
- if (newTotalPaid >= invoiceTotal) {
147675
+ if (newTotalPaid >= invoice.basePrice) {
147491
147676
  await db_default.update(companyInvoiceTable).set({
147492
147677
  status: "PAID",
147493
147678
  paidAt: new Date().toISOString()
@@ -147956,7 +148141,7 @@ var WarehouseItemLogic;
147956
148141
  }
147957
148142
  const BATCH_SIZE = 1000;
147958
148143
  const currentItems = await db_default.select().from(warehouseItemTable).where(inArray(warehouseItemTable.productId, body.map((item) => item.productId)));
147959
- const newItems = body.filter((item) => !currentItems.map((i2) => i2.productId).includes(item.productId));
148144
+ const newItems = body.filter((item) => currentItems.filter((i2) => i2.productId === item.productId && i2.warehouseId === item.warehouseId).length === 0);
147960
148145
  for (let i2 = 0;i2 < newItems.length; i2 += BATCH_SIZE) {
147961
148146
  const batch = newItems.slice(i2, i2 + BATCH_SIZE);
147962
148147
  const inserted = await db_default.insert(warehouseItemTable).values(batch).returning();
@@ -150277,9 +150462,10 @@ var normalizeRetryOptions = (retry2 = {}) => {
150277
150462
  if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
150278
150463
  throw new Error("retry.statusCodes must be an array");
150279
150464
  }
150465
+ const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== undefined));
150280
150466
  return {
150281
150467
  ...defaultRetryOptions,
150282
- ...retry2
150468
+ ...normalizedRetry
150283
150469
  };
150284
150470
  };
150285
150471
 
@@ -150534,7 +150720,8 @@ class Ky {
150534
150720
  jitteredDelay = retryDelay;
150535
150721
  }
150536
150722
  }
150537
- return Math.min(this.#options.retry.backoffLimit, jitteredDelay);
150723
+ const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
150724
+ return Math.min(backoffLimit, jitteredDelay);
150538
150725
  }
150539
150726
  async#calculateRetryDelay(error3) {
150540
150727
  this.#retryCount++;
@@ -155479,6 +155666,225 @@ var msRoutes = new Elysia({
155479
155666
  }).use(record_default);
155480
155667
  var ms_default = msRoutes;
155481
155668
 
155669
+ // src/routes/fleet/pm/plan/logic.ts
155670
+ var PmPlanLogic;
155671
+ ((PmPlanLogic) => {
155672
+ PmPlanLogic.select = async (query, user2) => {
155673
+ const filter = and(eq(pmPlanTable.companyId, user2.companyId), softDeletedFilter(pmPlanTable));
155674
+ const columns = getTableColumns(pmPlanTable);
155675
+ const baseQuery = db_default.select({
155676
+ ...columns,
155677
+ totalCount: totalCountSql
155678
+ }).from(pmPlanTable).where(filter).$dynamic();
155679
+ const result = await pagination_helper_default(baseQuery, query.pagination);
155680
+ return getPaginationContent(result, query.pagination.size);
155681
+ };
155682
+ PmPlanLogic.create = async (body, user2) => {
155683
+ const [result] = await db_default.insert(pmPlanTable).values({
155684
+ ...body,
155685
+ companyId: user2.companyId
155686
+ }).returning({
155687
+ id: pmPlanTable.id
155688
+ });
155689
+ return result;
155690
+ };
155691
+ PmPlanLogic.update = async (id, body, user2) => {
155692
+ await db_default.update(pmPlanTable).set({
155693
+ ...body
155694
+ }).where(and(eq(pmPlanTable.id, id), eq(pmPlanTable.companyId, user2.companyId)));
155695
+ };
155696
+ PmPlanLogic.remove = async (id, user2) => {
155697
+ await db_default.update(pmPlanTable).set({
155698
+ deletedAt: nowSql_helper_default
155699
+ }).where(and(eq(pmPlanTable.id, id), eq(pmPlanTable.companyId, user2.companyId)));
155700
+ };
155701
+ })(PmPlanLogic ||= {});
155702
+ var logic_default40 = PmPlanLogic;
155703
+
155704
+ // src/routes/fleet/pm/plan/machine/logic.ts
155705
+ var PmPlanLogic2;
155706
+ ((PmPlanLogic) => {
155707
+ PmPlanLogic.select = async (query) => {
155708
+ const filter = and(eq(pmPlanMachineTable.pmPlanId, query.pmPlanId), softDeletedFilter(pmPlanMachineTable));
155709
+ const columns = getTableColumns(pmPlanMachineTable);
155710
+ const baseQuery = db_default.select({
155711
+ ...columns,
155712
+ totalCount: totalCountSql
155713
+ }).from(pmPlanMachineTable).where(filter).$dynamic();
155714
+ const result = await pagination_helper_default(baseQuery, query.pagination);
155715
+ return getPaginationContent(result, query.pagination.size);
155716
+ };
155717
+ PmPlanLogic.create = async (body, user2) => {
155718
+ if (!user2.employeeId) {
155719
+ return status("Bad Request", "\u0410\u0436\u0438\u043B\u0442\u043D\u044B \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439.");
155720
+ }
155721
+ await db_default.insert(pmPlanMachineTable).values({
155722
+ ...body,
155723
+ userCreatedId: user2.id,
155724
+ employeeCreatedId: user2.employeeId
155725
+ });
155726
+ };
155727
+ PmPlanLogic.createMany = async (body) => {
155728
+ if (body.length === 0) {
155729
+ return status("Bad Request", "\u041C\u0430\u0448\u0438\u043D\u044B \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u043E\u0440\u0443\u0443\u043B\u0430\u0445 \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u0431\u0430\u0439\u0445\u0433\u04AF\u0439 \u0431\u0430\u0439\u043D\u0430.");
155730
+ }
155731
+ const result = await db_default.insert(pmPlanMachineTable).values(body).returning();
155732
+ return result;
155733
+ };
155734
+ PmPlanLogic.update = async (id, body) => {
155735
+ await db_default.update(pmPlanMachineTable).set({
155736
+ ...body
155737
+ }).where(and(eq(pmPlanMachineTable.id, id)));
155738
+ };
155739
+ PmPlanLogic.remove = async (id) => {
155740
+ await db_default.update(pmPlanMachineTable).set({
155741
+ deletedAt: nowSql_helper_default
155742
+ }).where(and(eq(pmPlanMachineTable.id, id)));
155743
+ };
155744
+ })(PmPlanLogic2 ||= {});
155745
+ var logic_default41 = PmPlanLogic2;
155746
+
155747
+ // src/routes/fleet/pm/plan/machine/model.ts
155748
+ var PmPlanMachineModel;
155749
+ ((PmPlanMachineModel) => {
155750
+ const createSchema = createInsertSchema2(pmPlanMachineTable);
155751
+ const updateSchema = createUpdateSchema(pmPlanMachineTable);
155752
+ PmPlanMachineModel.create = t.Omit(OmitBaseSchema(createSchema), [
155753
+ "employeeCreatedId",
155754
+ "userCreatedId"
155755
+ ]);
155756
+ PmPlanMachineModel.update = OmitBaseSchema(updateSchema);
155757
+ PmPlanMachineModel.select = t.Composite([
155758
+ PaginationSchema,
155759
+ t.Object({
155760
+ pmPlanId: t.String({ format: "uuid" })
155761
+ })
155762
+ ]);
155763
+ PmPlanMachineModel.createMany = t.Array(OmitBaseSchema(createSchema));
155764
+ })(PmPlanMachineModel ||= {});
155765
+ var model_default40 = PmPlanMachineModel;
155766
+
155767
+ // src/routes/fleet/pm/plan/machine/index.ts
155768
+ var machineRoutes2 = new Elysia({
155769
+ prefix: "/machine",
155770
+ tags: ["PmPlanMachine"]
155771
+ }).use(better_auth_default).guard({
155772
+ auth: true
155773
+ }).get("/", async ({ query }) => logic_default41.select(query), {
155774
+ query: model_default40.select
155775
+ }).post("/", async ({ body, user: user2 }) => logic_default41.create(body, user2), {
155776
+ body: model_default40.create
155777
+ }).post("/many", async ({ body }) => logic_default41.createMany(body), {
155778
+ body: model_default40.createMany
155779
+ }).guard({
155780
+ params: IdSchema
155781
+ }).put("/:id", async ({ body, params: { id } }) => logic_default41.update(id, body), {
155782
+ body: model_default40.update
155783
+ }).delete("/:id", async ({ params: { id } }) => logic_default41.remove(id));
155784
+ var machine_default2 = machineRoutes2;
155785
+
155786
+ // src/routes/fleet/pm/plan/product/logic.ts
155787
+ var PmPlanProductLogic;
155788
+ ((PmPlanProductLogic) => {
155789
+ PmPlanProductLogic.select = async (query) => {
155790
+ const filter = and(eq(pmPlanProductTable.pmPlanId, query.pmPlanId), softDeletedFilter(pmPlanProductTable));
155791
+ const columns = getTableColumns(pmPlanProductTable);
155792
+ const baseQuery = db_default.select({
155793
+ ...columns,
155794
+ totalCount: totalCountSql
155795
+ }).from(pmPlanProductTable).where(filter).$dynamic();
155796
+ const result = await pagination_helper_default(baseQuery, query.pagination);
155797
+ return getPaginationContent(result, query.pagination.size);
155798
+ };
155799
+ PmPlanProductLogic.create = async (body) => {
155800
+ await db_default.insert(pmPlanProductTable).values({
155801
+ ...body
155802
+ });
155803
+ };
155804
+ PmPlanProductLogic.createMany = async (body) => {
155805
+ if (body.length === 0) {
155806
+ return status("Bad Request", "\u0411\u04AF\u0442\u044D\u044D\u0433\u0434\u044D\u0445\u04AF\u04AF\u043D\u0438\u0439 \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u043E\u0440\u0443\u0443\u043B\u0430\u0445 \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u0431\u0430\u0439\u0445\u0433\u04AF\u0439 \u0431\u0430\u0439\u043D\u0430.");
155807
+ }
155808
+ const result = await db_default.insert(pmPlanProductTable).values(body).returning();
155809
+ return result;
155810
+ };
155811
+ PmPlanProductLogic.update = async (id, body) => {
155812
+ await db_default.update(pmPlanProductTable).set({
155813
+ ...body
155814
+ }).where(and(eq(pmPlanProductTable.id, id)));
155815
+ };
155816
+ PmPlanProductLogic.remove = async (id) => {
155817
+ await db_default.update(pmPlanProductTable).set({
155818
+ deletedAt: nowSql_helper_default
155819
+ }).where(and(eq(pmPlanProductTable.id, id)));
155820
+ };
155821
+ })(PmPlanProductLogic ||= {});
155822
+ var logic_default42 = PmPlanProductLogic;
155823
+
155824
+ // src/routes/fleet/pm/plan/product/model.ts
155825
+ var PmPlanProductModel;
155826
+ ((PmPlanProductModel) => {
155827
+ const createSchema = createInsertSchema2(pmPlanProductTable);
155828
+ const updateSchema = createUpdateSchema(pmPlanProductTable);
155829
+ PmPlanProductModel.create = OmitBaseSchema(createSchema);
155830
+ PmPlanProductModel.update = OmitBaseSchema(updateSchema);
155831
+ PmPlanProductModel.select = t.Composite([
155832
+ PaginationSchema,
155833
+ t.Object({
155834
+ pmPlanId: t.String({ format: "uuid" })
155835
+ })
155836
+ ]);
155837
+ PmPlanProductModel.createMany = t.Array(OmitBaseSchema(createSchema));
155838
+ })(PmPlanProductModel ||= {});
155839
+ var model_default41 = PmPlanProductModel;
155840
+
155841
+ // src/routes/fleet/pm/plan/product/index.ts
155842
+ var productRoutes5 = new Elysia({
155843
+ prefix: "/product",
155844
+ tags: ["PmPlanProduct"]
155845
+ }).use(better_auth_default).guard({
155846
+ auth: true
155847
+ }).get("/", async ({ query }) => logic_default42.select(query), {
155848
+ query: model_default41.select
155849
+ }).post("/", async ({ body }) => logic_default42.create(body), {
155850
+ body: model_default41.create
155851
+ }).post("/many", async ({ body }) => logic_default42.createMany(body), {
155852
+ body: model_default41.createMany
155853
+ }).guard({
155854
+ params: IdSchema
155855
+ }).put("/:id", async ({ body, params: { id } }) => logic_default42.update(id, body), {
155856
+ body: model_default41.update
155857
+ }).delete("/:id", async ({ params: { id } }) => logic_default42.remove(id));
155858
+ var product_default5 = productRoutes5;
155859
+
155860
+ // src/routes/fleet/pm/plan/model.ts
155861
+ var PmPlanModel;
155862
+ ((PmPlanModel) => {
155863
+ const createSchema = createInsertSchema2(pmPlanTable);
155864
+ const updateSchema = createUpdateSchema(pmPlanTable);
155865
+ PmPlanModel.create = OmitBaseSchema(createSchema);
155866
+ PmPlanModel.update = OmitBaseSchema(updateSchema);
155867
+ PmPlanModel.select = t.Composite([PaginationSchema]);
155868
+ })(PmPlanModel ||= {});
155869
+ var model_default42 = PmPlanModel;
155870
+
155871
+ // src/routes/fleet/pm/plan/index.ts
155872
+ var planRoutes = new Elysia({
155873
+ prefix: "/plan",
155874
+ tags: ["PmPlan"]
155875
+ }).use(better_auth_default).use(machine_default2).use(product_default5).guard({
155876
+ userKind: "COMPANY_ADMIN"
155877
+ }).get("/", async ({ query, user: user2 }) => logic_default40.select(query, user2), {
155878
+ query: model_default42.select
155879
+ }).post("/", async ({ body, user: user2 }) => logic_default40.create(body, user2), {
155880
+ body: model_default42.create
155881
+ }).guard({
155882
+ params: IdSchema
155883
+ }).put("/:id", async ({ body, params: { id }, user: user2 }) => logic_default40.update(id, body, user2), {
155884
+ body: model_default42.update
155885
+ }).delete("/:id", async ({ params: { id }, user: user2 }) => logic_default40.remove(id, user2));
155886
+ var plan_default = planRoutes;
155887
+
155482
155888
  // src/routes/fleet/pm/template/logic.ts
155483
155889
  var PmTemplateLogic;
155484
155890
  ((PmTemplateLogic) => {
@@ -155511,7 +155917,7 @@ var PmTemplateLogic;
155511
155917
  }).where(and(eq(pmTemplateTable.id, id), eq(pmTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")));
155512
155918
  };
155513
155919
  })(PmTemplateLogic ||= {});
155514
- var logic_default40 = PmTemplateLogic;
155920
+ var logic_default43 = PmTemplateLogic;
155515
155921
 
155516
155922
  // src/routes/fleet/pm/template/model.ts
155517
155923
  var PmTemplateModel;
@@ -155522,7 +155928,7 @@ var PmTemplateModel;
155522
155928
  PmTemplateModel.update = OmitBaseSchema(updateSchema);
155523
155929
  PmTemplateModel.select = t.Composite([PaginationSchema]);
155524
155930
  })(PmTemplateModel ||= {});
155525
- var model_default40 = PmTemplateModel;
155931
+ var model_default43 = PmTemplateModel;
155526
155932
 
155527
155933
  // src/routes/fleet/pm/template/product/logic.ts
155528
155934
  var PmTemplateProductLogic;
@@ -155554,7 +155960,7 @@ var PmTemplateProductLogic;
155554
155960
  }).where(and(eq(pmTemplateProductTable.id, id)));
155555
155961
  };
155556
155962
  })(PmTemplateProductLogic ||= {});
155557
- var logic_default41 = PmTemplateProductLogic;
155963
+ var logic_default44 = PmTemplateProductLogic;
155558
155964
 
155559
155965
  // src/routes/fleet/pm/template/product/model.ts
155560
155966
  var PmTemplateProductModel;
@@ -155570,46 +155976,46 @@ var PmTemplateProductModel;
155570
155976
  })
155571
155977
  ]);
155572
155978
  })(PmTemplateProductModel ||= {});
155573
- var model_default41 = PmTemplateProductModel;
155979
+ var model_default44 = PmTemplateProductModel;
155574
155980
 
155575
155981
  // src/routes/fleet/pm/template/product/index.ts
155576
- var productRoutes5 = new Elysia({
155982
+ var productRoutes6 = new Elysia({
155577
155983
  prefix: "/product",
155578
155984
  tags: ["PmTemplateProduct"]
155579
155985
  }).use(better_auth_default).guard({
155580
155986
  userKind: "COMPANY_ADMIN"
155581
- }).get("/", async ({ query }) => logic_default41.select(query), {
155582
- query: model_default41.select
155583
- }).post("/", async ({ body }) => logic_default41.create(body), {
155584
- body: model_default41.create
155987
+ }).get("/", async ({ query }) => logic_default44.select(query), {
155988
+ query: model_default44.select
155989
+ }).post("/", async ({ body }) => logic_default44.create(body), {
155990
+ body: model_default44.create
155585
155991
  }).guard({
155586
155992
  params: IdSchema
155587
- }).put("/:id", async ({ body, params: { id } }) => logic_default41.update(id, body), {
155588
- body: model_default41.update
155589
- }).delete("/:id", async ({ params: { id } }) => logic_default41.remove(id));
155590
- var product_default5 = productRoutes5;
155993
+ }).put("/:id", async ({ body, params: { id } }) => logic_default44.update(id, body), {
155994
+ body: model_default44.update
155995
+ }).delete("/:id", async ({ params: { id } }) => logic_default44.remove(id));
155996
+ var product_default6 = productRoutes6;
155591
155997
 
155592
155998
  // src/routes/fleet/pm/template/index.ts
155593
155999
  var templateRoutes2 = new Elysia({
155594
156000
  prefix: "/template",
155595
156001
  tags: ["PmTemplate"]
155596
- }).use(better_auth_default).use(product_default5).guard({
156002
+ }).use(better_auth_default).use(product_default6).guard({
155597
156003
  userKind: "COMPANY_ADMIN"
155598
- }).get("/", async ({ query, user: user2 }) => logic_default40.select(query, user2), {
155599
- query: model_default40.select
155600
- }).post("/", async ({ body, user: user2 }) => logic_default40.create(body, user2), {
155601
- body: model_default40.create
156004
+ }).get("/", async ({ query, user: user2 }) => logic_default43.select(query, user2), {
156005
+ query: model_default43.select
156006
+ }).post("/", async ({ body, user: user2 }) => logic_default43.create(body, user2), {
156007
+ body: model_default43.create
155602
156008
  }).guard({
155603
156009
  params: IdSchema
155604
- }).put("/:id", async ({ body, params: { id }, user: user2 }) => logic_default40.update(id, body, user2), {
155605
- body: model_default40.update
155606
- }).delete("/:id", async ({ params: { id }, user: user2 }) => logic_default40.remove(id, user2));
156010
+ }).put("/:id", async ({ body, params: { id }, user: user2 }) => logic_default43.update(id, body, user2), {
156011
+ body: model_default43.update
156012
+ }).delete("/:id", async ({ params: { id }, user: user2 }) => logic_default43.remove(id, user2));
155607
156013
  var template_default2 = templateRoutes2;
155608
156014
 
155609
156015
  // src/routes/fleet/pm/index.ts
155610
156016
  var pmRoutes = new Elysia({
155611
156017
  prefix: "/pm"
155612
- }).use(template_default2);
156018
+ }).use(template_default2).use(plan_default);
155613
156019
  var pm_default = pmRoutes;
155614
156020
 
155615
156021
  // src/routes/fleet/index.ts
@@ -155647,7 +156053,7 @@ var UomCategoryLogic;
155647
156053
  }).where(and(eq(uomCategoryTable.id, id)));
155648
156054
  };
155649
156055
  })(UomCategoryLogic ||= {});
155650
- var logic_default42 = UomCategoryLogic;
156056
+ var logic_default45 = UomCategoryLogic;
155651
156057
 
155652
156058
  // src/routes/uom/category/model.ts
155653
156059
  var UomCategoryModel;
@@ -155658,7 +156064,7 @@ var UomCategoryModel;
155658
156064
  UomCategoryModel.update = OmitBaseSchema(updateSchema);
155659
156065
  UomCategoryModel.select = t.Composite([PaginationSchema]);
155660
156066
  })(UomCategoryModel ||= {});
155661
- var model_default42 = UomCategoryModel;
156067
+ var model_default45 = UomCategoryModel;
155662
156068
 
155663
156069
  // src/routes/uom/category/index.ts
155664
156070
  var categoryRoutes = new Elysia({
@@ -155666,15 +156072,15 @@ var categoryRoutes = new Elysia({
155666
156072
  tags: ["UomCategory"]
155667
156073
  }).use(better_auth_default).guard({
155668
156074
  auth: true
155669
- }).get("/", async ({ query }) => logic_default42.select(query), {
155670
- query: model_default42.select
155671
- }).post("/", async ({ body }) => logic_default42.create(body), {
155672
- body: model_default42.create
156075
+ }).get("/", async ({ query }) => logic_default45.select(query), {
156076
+ query: model_default45.select
156077
+ }).post("/", async ({ body }) => logic_default45.create(body), {
156078
+ body: model_default45.create
155673
156079
  }).guard({
155674
156080
  params: IdSchema
155675
- }).put("/:id", async ({ body, params: { id } }) => logic_default42.update(id, body), {
155676
- body: model_default42.update
155677
- }).delete("/:id", async ({ params: { id } }) => logic_default42.remove(id));
156081
+ }).put("/:id", async ({ body, params: { id } }) => logic_default45.update(id, body), {
156082
+ body: model_default45.update
156083
+ }).delete("/:id", async ({ params: { id } }) => logic_default45.remove(id));
155678
156084
  var category_default = categoryRoutes;
155679
156085
 
155680
156086
  // src/routes/uom/conversion/logic.ts
@@ -155708,7 +156114,7 @@ var UomConversionLogic;
155708
156114
  }).where(and(eq(uomConversionTable.id, id)));
155709
156115
  };
155710
156116
  })(UomConversionLogic ||= {});
155711
- var logic_default43 = UomConversionLogic;
156117
+ var logic_default46 = UomConversionLogic;
155712
156118
 
155713
156119
  // src/routes/uom/conversion/model.ts
155714
156120
  var UomConversionModel;
@@ -155725,7 +156131,7 @@ var UomConversionModel;
155725
156131
  })
155726
156132
  ]);
155727
156133
  })(UomConversionModel ||= {});
155728
- var model_default43 = UomConversionModel;
156134
+ var model_default46 = UomConversionModel;
155729
156135
 
155730
156136
  // src/routes/uom/conversion/index.ts
155731
156137
  var conversionRoutes = new Elysia({
@@ -155733,15 +156139,15 @@ var conversionRoutes = new Elysia({
155733
156139
  tags: ["UomConversion"]
155734
156140
  }).use(better_auth_default).guard({
155735
156141
  auth: true
155736
- }).get("/", async ({ query }) => logic_default43.select(query), {
155737
- query: model_default43.select
155738
- }).post("/", async ({ body }) => logic_default43.create(body), {
155739
- body: model_default43.create
156142
+ }).get("/", async ({ query }) => logic_default46.select(query), {
156143
+ query: model_default46.select
156144
+ }).post("/", async ({ body }) => logic_default46.create(body), {
156145
+ body: model_default46.create
155740
156146
  }).guard({
155741
156147
  params: IdSchema
155742
- }).put("/:id", async ({ body, params: { id } }) => logic_default43.update(id, body), {
155743
- body: model_default43.update
155744
- }).delete("/:id", async ({ params: { id } }) => logic_default43.remove(id));
156148
+ }).put("/:id", async ({ body, params: { id } }) => logic_default46.update(id, body), {
156149
+ body: model_default46.update
156150
+ }).delete("/:id", async ({ params: { id } }) => logic_default46.remove(id));
155745
156151
  var conversion_default = conversionRoutes;
155746
156152
 
155747
156153
  // src/routes/uom/logic.ts
@@ -155775,7 +156181,7 @@ var UomLogic;
155775
156181
  }).where(and(eq(uomTable.id, id)));
155776
156182
  };
155777
156183
  })(UomLogic ||= {});
155778
- var logic_default44 = UomLogic;
156184
+ var logic_default47 = UomLogic;
155779
156185
 
155780
156186
  // src/routes/uom/model.ts
155781
156187
  var UomModel;
@@ -155791,27 +156197,23 @@ var UomModel;
155791
156197
  })
155792
156198
  ]);
155793
156199
  })(UomModel ||= {});
155794
- var model_default44 = UomModel;
156200
+ var model_default47 = UomModel;
155795
156201
 
155796
156202
  // src/routes/uom/index.ts
155797
156203
  var uomSchemaRoutes = new Elysia({
155798
156204
  prefix: "/uom"
155799
156205
  }).use(better_auth_default).use(category_default).use(conversion_default).guard({
155800
- userKind: "ADMIN"
155801
- }).get("/", async ({ query }) => logic_default44.select(query), {
155802
- query: model_default44.select,
155803
- tags: ["Uom"]
155804
- }).post("/", async ({ body }) => logic_default44.create(body), {
155805
- body: model_default44.create,
156206
+ userKind: "ADMIN",
155806
156207
  tags: ["Uom"]
156208
+ }).get("/", async ({ query }) => logic_default47.select(query), {
156209
+ query: model_default47.select
156210
+ }).post("/", async ({ body }) => logic_default47.create(body), {
156211
+ body: model_default47.create
155807
156212
  }).guard({
155808
156213
  params: IdSchema
155809
- }).put("/:id", async ({ body, params: { id } }) => logic_default44.update(id, body), {
155810
- body: model_default44.update,
155811
- tags: ["Uom"]
155812
- }).delete("/:id", async ({ params: { id } }) => logic_default44.remove(id), {
155813
- tags: ["Uom"]
155814
- });
156214
+ }).put("/:id", async ({ body, params: { id } }) => logic_default47.update(id, body), {
156215
+ body: model_default47.update
156216
+ }).delete("/:id", async ({ params: { id } }) => logic_default47.remove(id));
155815
156217
  var uom_default = uomSchemaRoutes;
155816
156218
 
155817
156219
  // src/routes/index.ts