@cheetah.js/orm 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bun/index.js CHANGED
@@ -219060,7 +219060,7 @@ var Reflect2;
219060
219060
  });
219061
219061
  })(Reflect2 || (Reflect2 = {}));
219062
219062
 
219063
- // /export/htdocs/p/framework/packages/core/dist/domain/provider-type.js
219063
+ // ../../node_modules/balanced-match/index.jsodules/minimatch
219064
219064
  var ProviderType;
219065
219065
  (function(ProviderType2) {
219066
219066
  ProviderType2["ROUTES"] = "routes";
@@ -219069,7 +219069,7 @@ var ProviderType;
219069
219069
  ProviderType2["CONTROLLER"] = "controller";
219070
219070
  })(ProviderType || (ProviderType = {}));
219071
219071
 
219072
- // /export/htdocs/p/framework/packages/core/dist/domain/provider-scope.js
219072
+ // ../../node_modules/balanced-match/index.jsodules/minimatch/
219073
219073
  var ProviderScope;
219074
219074
  (function(ProviderScope2) {
219075
219075
  ProviderScope2["REQUEST"] = "request";
@@ -219077,13 +219077,36 @@ var ProviderScope;
219077
219077
  ProviderScope2["SINGLETON"] = "singleton";
219078
219078
  })(ProviderScope || (ProviderScope = {}));
219079
219079
 
219080
+ // /export/htdocs/p/framework/packages/core/dist/domain/provider-type.js
219081
+ var ProviderType2;
219082
+ (function(ProviderType3) {
219083
+ ProviderType3["ROUTES"] = "routes";
219084
+ ProviderType3["SERVICE"] = "service";
219085
+ ProviderType3["PROVIDER"] = "provider";
219086
+ ProviderType3["CONTROLLER"] = "controller";
219087
+ })(ProviderType2 || (ProviderType2 = {}));
219088
+
219089
+ // /export/htdocs/p/framework/packages/core/dist/domain/provider-scope.js
219090
+ var ProviderScope2;
219091
+ (function(ProviderScope3) {
219092
+ ProviderScope3["REQUEST"] = "request";
219093
+ ProviderScope3["INSTANCE"] = "instance";
219094
+ ProviderScope3["SINGLETON"] = "singleton";
219095
+ })(ProviderScope2 || (ProviderScope2 = {}));
219096
+
219080
219097
  // /export/htdocs/p/framework/packages/core/dist/domain/provider.js
219081
219098
  class Provider {
219099
+ type = ProviderType2.PROVIDER;
219100
+ deps = [];
219101
+ instance;
219102
+ _provide;
219103
+ _useClass;
219104
+ hooks;
219105
+ path;
219106
+ scope = ProviderScope2.SINGLETON;
219107
+ children = [];
219108
+ parent;
219082
219109
  constructor(token, options = {}) {
219083
- this.type = ProviderType.PROVIDER;
219084
- this.deps = [];
219085
- this.scope = ProviderScope.SINGLETON;
219086
- this.children = [];
219087
219110
  this.provide = token;
219088
219111
  this.useClass = token;
219089
219112
  Object.assign(this, options);
@@ -219127,10 +219150,7 @@ class Provider {
219127
219150
 
219128
219151
  // /export/htdocs/p/framework/packages/core/dist/commons/registries/ProviderControl.js
219129
219152
  class ProviderControl extends Map {
219130
- constructor() {
219131
- super(...arguments);
219132
- this.settings = new Map;
219133
- }
219153
+ settings = new Map;
219134
219154
  get(key) {
219135
219155
  return super.get(getClassOrSymbol(key));
219136
219156
  }
@@ -219195,7 +219215,7 @@ class ProviderControl extends Map {
219195
219215
  }
219196
219216
  }
219197
219217
  createIfNotExists(key, options) {
219198
- const type = options.type || ProviderType.PROVIDER;
219218
+ const type = options.type || ProviderType2.PROVIDER;
219199
219219
  if (!this.has(key)) {
219200
219220
  const { model = Provider } = this.settings.get(type) || {};
219201
219221
  const item = new model(key, options);
@@ -219212,9 +219232,9 @@ function registerProvider(provider3) {
219212
219232
  }
219213
219233
  return GlobalProvider.merge(provider3.provide, provider3);
219214
219234
  }
219215
- GlobalProvider.createRegistry(ProviderType.CONTROLLER, Provider);
219216
- GlobalProvider.createRegistry(ProviderType.ROUTES, Provider);
219217
- var registerController = GlobalProvider.createRegisterFn(ProviderType.CONTROLLER);
219235
+ GlobalProvider.createRegistry(ProviderType2.CONTROLLER, Provider);
219236
+ GlobalProvider.createRegistry(ProviderType2.ROUTES, Provider);
219237
+ var registerController = GlobalProvider.createRegisterFn(ProviderType2.CONTROLLER);
219218
219238
  // /export/htdocs/p/framework/node_modules/globby/index.js
219219
219239
  var import_merge2 = __toESM(require_merge2(), 1);
219220
219240
  var import_fast_glob2 = __toESM(require_out4(), 1);
@@ -219567,9 +219587,9 @@ class Container extends Map {
219567
219587
  }
219568
219588
  // /export/htdocs/p/framework/packages/core/dist/container/ContainerConfiguration.js
219569
219589
  class ContainerConfiguration {
219590
+ default = new Map;
219591
+ map = new Map;
219570
219592
  constructor(initialProps = {}) {
219571
- this.default = new Map;
219572
- this.map = new Map;
219573
219593
  Object.entries({
219574
219594
  scopes: {},
219575
219595
  resolvers: [],
@@ -221235,10 +221255,12 @@ var createParamNode = (paramName) => ({
221235
221255
  });
221236
221256
 
221237
221257
  class Memoirist {
221238
- constructor() {
221239
- this.root = {};
221240
- this.history = [];
221241
- }
221258
+ root = {};
221259
+ history = [];
221260
+ static regex = {
221261
+ static: /:.+?(?=\/|$)/,
221262
+ params: /:.+?(?=\/|$)/g
221263
+ };
221242
221264
  add(method, path2, store) {
221243
221265
  if (typeof path2 !== "string")
221244
221266
  throw new TypeError("Route path must be a string");
@@ -221338,10 +221360,6 @@ class Memoirist {
221338
221360
  return matchRoute(url, url.length, root, 0);
221339
221361
  }
221340
221362
  }
221341
- Memoirist.regex = {
221342
- static: /:.+?(?=\/|$)/,
221343
- params: /:.+?(?=\/|$)/g
221344
- };
221345
221363
  var matchRoute = (url, urlLength, node, startIndex) => {
221346
221364
  const part = node?.part;
221347
221365
  const endIndex = startIndex + part.length;
@@ -221422,13 +221440,11 @@ var __decorate = function(decorators4, target, key, desc) {
221422
221440
  };
221423
221441
  var InjectorService_1;
221424
221442
  var InjectorService = InjectorService_1 = class InjectorService2 {
221425
- constructor() {
221426
- this.settings = new ContainerConfiguration;
221427
- this.container = new Container;
221428
- this.applicationConfig = {};
221429
- this.router = new memoirist_default;
221430
- this.historyMethods = new Map;
221431
- }
221443
+ settings = new ContainerConfiguration;
221444
+ container = new Container;
221445
+ applicationConfig = {};
221446
+ router = new memoirist_default;
221447
+ historyMethods = new Map;
221432
221448
  loadModule(container5, applicationConfig, router) {
221433
221449
  this.container = container5;
221434
221450
  this.router = router;
@@ -221441,7 +221457,7 @@ var InjectorService = InjectorService_1 = class InjectorService2 {
221441
221457
  resolveControllers() {
221442
221458
  if (!this.settings)
221443
221459
  return {};
221444
- const controllers = GlobalProvider.getByType(ProviderType.CONTROLLER).filter((controller2) => !controller2.isChild());
221460
+ const controllers = GlobalProvider.getByType(ProviderType2.CONTROLLER).filter((controller2) => !controller2.isChild());
221445
221461
  let hydrateRoute = new Map;
221446
221462
  for (const controller2 of controllers) {
221447
221463
  let routes = Metadata.get(CONTROLLER_ROUTES, controller2.token);
@@ -221565,16 +221581,16 @@ var InjectorService = InjectorService_1 = class InjectorService2 {
221565
221581
  const construct = (deps2) => new provider3.useClass(...deps2);
221566
221582
  let instance;
221567
221583
  if (isRequestScope(provider3, deps, this)) {
221568
- scope = ProviderScope.REQUEST;
221584
+ scope = ProviderScope2.REQUEST;
221569
221585
  }
221570
221586
  const services = deps.filter((t) => !isPrimitiveType(t)).map((token) => this.invoke(getClassOrSymbol(token), locals));
221571
221587
  instance = construct(services);
221572
221588
  switch (scope) {
221573
- case ProviderScope.SINGLETON:
221589
+ case ProviderScope2.SINGLETON:
221574
221590
  provider3.instance = instance;
221575
221591
  this.container.addProvider(provider3.token, provider3);
221576
221592
  break;
221577
- case ProviderScope.REQUEST:
221593
+ case ProviderScope2.REQUEST:
221578
221594
  const clone = provider3.clone();
221579
221595
  clone.instance = instance;
221580
221596
  locals.set(clone.token, clone);
@@ -221626,7 +221642,7 @@ var InjectorService = InjectorService_1 = class InjectorService2 {
221626
221642
  return methodInfo;
221627
221643
  }
221628
221644
  scopeOf(provider3) {
221629
- return provider3.scope || ProviderScope.SINGLETON;
221645
+ return provider3.scope || ProviderScope2.SINGLETON;
221630
221646
  }
221631
221647
  getConstructorDependencies(target, propertyKey) {
221632
221648
  return Metadata.getOwn("override:ctor:design:paramtypes", target, propertyKey) || [...Metadata.getParamTypes(target, propertyKey)];
@@ -221717,13 +221733,13 @@ var __metadata = function(k, v) {
221717
221733
  };
221718
221734
  var Context_1;
221719
221735
  var Context = Context_1 = class Context2 {
221736
+ query = {};
221737
+ body = {};
221738
+ param = {};
221739
+ req = {};
221740
+ headers = {};
221741
+ locals = {};
221720
221742
  constructor() {
221721
- this.query = {};
221722
- this.body = {};
221723
- this.param = {};
221724
- this.req = {};
221725
- this.headers = {};
221726
- this.locals = {};
221727
221743
  }
221728
221744
  static async createFromRequest(url, request, server) {
221729
221745
  const context = new Context_1;
@@ -221757,7 +221773,7 @@ var Context = Context_1 = class Context2 {
221757
221773
  }
221758
221774
  };
221759
221775
  Context = Context_1 = __decorate2([
221760
- Injectable({ scope: ProviderScope.REQUEST }),
221776
+ Injectable({ scope: ProviderScope2.REQUEST }),
221761
221777
  __metadata("design:paramtypes", [])
221762
221778
  ], Context);
221763
221779
  // /export/htdocs/p/framework/packages/core/dist/domain/LocalsContainer.js
@@ -221806,6 +221822,7 @@ class Metadata {
221806
221822
  static setParamTypes(target, propertyKey, value) {
221807
221823
  return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
221808
221824
  }
221825
+ static getTargetsFromPropertyKey = (metadataKey) => PROPERTIES2.has(metadataKey) ? PROPERTIES2.get(metadataKey) || [] : [];
221809
221826
  static set(key, value, target, propertyKey) {
221810
221827
  const targets = PROPERTIES2.has(key) ? PROPERTIES2.get(key) || [] : [];
221811
221828
  const classConstructor = classOf(target);
@@ -221825,7 +221842,6 @@ class Metadata {
221825
221842
  return Reflect.getMetadata(ROUTE_PARAM, target.constructor, propertyKey);
221826
221843
  }
221827
221844
  }
221828
- Metadata.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES2.has(metadataKey) ? PROPERTIES2.get(metadataKey) || [] : [];
221829
221845
  // /export/htdocs/p/framework/packages/core/dist/domain/http-method.js
221830
221846
  var HttpMethod;
221831
221847
  (function(HttpMethod2) {
@@ -221910,6 +221926,9 @@ class Router {
221910
221926
  var RouteExecutor = new Router;
221911
221927
  // /export/htdocs/p/framework/packages/core/dist/exceptions/HttpException.js
221912
221928
  class HttpException {
221929
+ response;
221930
+ statusCode;
221931
+ message;
221913
221932
  constructor(response, statusCode) {
221914
221933
  this.response = response;
221915
221934
  this.statusCode = statusCode;
@@ -221934,23 +221953,13 @@ import process3 from "process";
221934
221953
  var parseUrl2 = require_parseurl_fast();
221935
221954
 
221936
221955
  class Cheetah {
221956
+ config;
221957
+ router = new memoirist_default;
221958
+ injector = createInjector();
221959
+ fetch = (request, server) => this.fetcher(request, server);
221960
+ server;
221937
221961
  constructor(config = {}) {
221938
221962
  this.config = config;
221939
- this.router = new memoirist_default;
221940
- this.injector = createInjector();
221941
- this.fetch = (request, server) => this.fetcher(request, server);
221942
- this.catcher = (error) => {
221943
- if (error instanceof HttpException) {
221944
- return new Response(JSON.stringify({
221945
- message: error.getResponse(),
221946
- statusCode: error.getStatus()
221947
- }), {
221948
- status: error.statusCode,
221949
- headers: { "Content-Type": "application/json" }
221950
- });
221951
- }
221952
- return new Response(error.message, { status: 500 });
221953
- };
221954
221963
  this.injector.callHook(EventType.OnApplicationBoot, {});
221955
221964
  }
221956
221965
  use(plugin) {
@@ -221991,6 +222000,18 @@ class Cheetah {
221991
222000
  local.set(Context, context);
221992
222001
  return RouteExecutor.executeRoute(route.store, this.injector, context, local);
221993
222002
  }
222003
+ catcher = (error) => {
222004
+ if (error instanceof HttpException) {
222005
+ return new Response(JSON.stringify({
222006
+ message: error.getResponse(),
222007
+ statusCode: error.getStatus()
222008
+ }), {
222009
+ status: error.statusCode,
222010
+ headers: { "Content-Type": "application/json" }
222011
+ });
222012
+ }
222013
+ return new Response(error.message, { status: 500 });
222014
+ };
221994
222015
  close(closeActiveConnections = false) {
221995
222016
  this.server.stop(closeActiveConnections);
221996
222017
  }
@@ -222133,7 +222154,7 @@ function isRequestScope(provider4, deps, injector) {
222133
222154
  const depProvider = injector.get(dep);
222134
222155
  if (!depProvider)
222135
222156
  return false;
222136
- return depProvider.scope === ProviderScope.REQUEST;
222157
+ return depProvider.scope === ProviderScope2.REQUEST;
222137
222158
  });
222138
222159
  }
222139
222160
  // /export/htdocs/p/framework/packages/core/dist/utils/nameOf.js
@@ -222272,6 +222293,8 @@ var __metadata3 = function(k, v) {
222272
222293
  return Reflect.metadata(k, v);
222273
222294
  };
222274
222295
  var LoggerService = class LoggerService2 {
222296
+ injector;
222297
+ logger;
222275
222298
  constructor(injector) {
222276
222299
  this.injector = injector;
222277
222300
  const pinoConfig = this.injector.applicationConfig.logger || {};
@@ -222300,81 +222323,19 @@ LoggerService = __decorate4([
222300
222323
  Service(),
222301
222324
  __metadata3("design:paramtypes", [InjectorService])
222302
222325
  ], LoggerService);
222303
- // ../../node_modules/balanced-match/
222304
- function Entity(options) {
222305
- return (target) => {
222306
- const entities = Metadata.get(ENTITIES, Reflect) || [];
222307
- entities.push({ target, options });
222308
- Metadata.set(ENTITIES, entities, Reflect);
222309
- };
222310
- }
222311
- // ../../node_m
222312
- function getDefaultLength(type) {
222313
- if (type === "String") {
222314
- return 255;
222315
- }
222316
- if (type === "Number") {
222317
- return 11;
222318
- }
222319
- if (type === "Boolean") {
222320
- return 1;
222321
- }
222322
- if (type === "Date") {
222323
- return 6;
222324
- }
222325
- return 255;
222326
- }
222327
-
222328
- // ../../node_modules/balanced-match/in
222329
- function Property(options) {
222330
- return (target, propertyKey) => {
222331
- const properties = Metadata.get(PROPERTIES, target.constructor) || [];
222332
- const type = Metadata.getType(target, propertyKey);
222333
- const length = options && options.length || getDefaultLength(type.name);
222334
- options = { length, ...options };
222335
- properties.push({ propertyKey, options });
222336
- Metadata.set(PROPERTIES, properties, target.constructor);
222337
- if (options.isPrimary) {
222338
- const indexes = Metadata.get("indexes", target.constructor) || [];
222339
- indexes.push({ name: `[TABLE]_pkey`, properties: [propertyKey] });
222340
- Metadata.set("indexes", indexes, target.constructor);
222341
- }
222342
- properties.forEach((property) => {
222343
- const types = Metadata.get(PROPERTIES_METADATA, target.constructor) || {};
222344
- const type2 = Metadata.getType(target, property.propertyKey);
222345
- types[property.propertyKey] = { type: type2, options: property.options };
222346
- Metadata.set(PROPERTIES_METADATA, types, target.constructor);
222347
- });
222348
- };
222349
- }
222350
- // ../../node_modules/balanced-match/index
222351
- function PrimaryKey(options) {
222352
- const isPrimary = true;
222353
- return Property({ ...options, isPrimary, unique: true });
222354
- }
222355
- // ../../node_modules/balanced-match/index.jsodules/minimatch
222356
- var ProviderType2;
222357
- (function(ProviderType3) {
222358
- ProviderType3["ROUTES"] = "routes";
222359
- ProviderType3["SERVICE"] = "service";
222360
- ProviderType3["PROVIDER"] = "provider";
222361
- ProviderType3["CONTROLLER"] = "controller";
222362
- })(ProviderType2 || (ProviderType2 = {}));
222363
-
222364
- // ../../node_modules/balanced-match/index.jsodules/minimatch/
222365
- var ProviderScope2;
222366
- (function(ProviderScope3) {
222367
- ProviderScope3["REQUEST"] = "request";
222368
- ProviderScope3["INSTANCE"] = "instance";
222369
- ProviderScope3["SINGLETON"] = "singleton";
222370
- })(ProviderScope2 || (ProviderScope2 = {}));
222371
-
222372
222326
  // ../../node_modules/balanced-match/index.jsodules/mini
222373
222327
  class Provider2 {
222328
+ type = ProviderType.PROVIDER;
222329
+ deps = [];
222330
+ instance;
222331
+ _provide;
222332
+ _useClass;
222333
+ hooks;
222334
+ path;
222335
+ scope = ProviderScope.SINGLETON;
222336
+ children = [];
222337
+ parent;
222374
222338
  constructor(token, options = {}) {
222375
- this.type = ProviderType2.PROVIDER;
222376
- this.deps = [];
222377
- this.scope = ProviderScope2.SINGLETON;
222378
222339
  this.provide = token;
222379
222340
  this.useClass = token;
222380
222341
  Object.assign(this, options);
@@ -222411,14 +222372,14 @@ class Provider2 {
222411
222372
  clone() {
222412
222373
  return new (classOf(this))(this._provide, this);
222413
222374
  }
222375
+ isChild() {
222376
+ return !!this.parent;
222377
+ }
222414
222378
  }
222415
222379
 
222416
222380
  // ../../node_modules/balanced-match/index.jsodules/minimatch/dist/cjs/unes
222417
222381
  class ProviderControl5 extends Map {
222418
- constructor() {
222419
- super(...arguments);
222420
- this.settings = new Map;
222421
- }
222382
+ settings = new Map;
222422
222383
  get(key) {
222423
222384
  return super.get(getClassOrSymbol(key));
222424
222385
  }
@@ -222483,7 +222444,7 @@ class ProviderControl5 extends Map {
222483
222444
  }
222484
222445
  }
222485
222446
  createIfNotExists(key, options) {
222486
- const type = options.type || ProviderType2.PROVIDER;
222447
+ const type = options.type || ProviderType.PROVIDER;
222487
222448
  if (!this.has(key)) {
222488
222449
  const { model = Provider2 } = this.settings.get(type) || {};
222489
222450
  const item = new model(key, options);
@@ -222494,9 +222455,9 @@ class ProviderControl5 extends Map {
222494
222455
  }
222495
222456
  var GlobalProvider2 = new ProviderControl5;
222496
222457
  // ../../node_modules/balanced-match/index.jsodules/minimatch/dist/cjs/unesc
222497
- GlobalProvider2.createRegistry(ProviderType2.CONTROLLER, Provider2);
222498
- GlobalProvider2.createRegistry(ProviderType2.ROUTES, Provider2);
222499
- var registerController2 = GlobalProvider2.createRegisterFn(ProviderType2.CONTROLLER);
222458
+ GlobalProvider2.createRegistry(ProviderType.CONTROLLER, Provider2);
222459
+ GlobalProvider2.createRegistry(ProviderType.ROUTES, Provider2);
222460
+ var registerController2 = GlobalProvider2.createRegisterFn(ProviderType.CONTROLLER);
222500
222461
  // ../../node_modules/balanced-match/index.jsodules/minimatch/dist/cjs/unes
222501
222462
  function createParamDecorator2(func) {
222502
222463
  return (data) => (target, propertyKey, parameterIndex) => {
@@ -222524,7 +222485,7 @@ var Body2 = createParamDecorator2((context, data) => data ? context.body[data] :
222524
222485
  var Query2 = createParamDecorator2((context, data) => data ? context.query[data] : context.query || {});
222525
222486
  var Param2 = createParamDecorator2((context, data) => data ? context.param[data] : null);
222526
222487
  var Req2 = createParamDecorator2((context) => context.req);
222527
- var Headers2 = createParamDecorator2((context, data) => data ? context.headers.get(data) : context.headers || {});
222488
+ var Headers2 = createParamDecorator2((context, data) => data ? context.headers[data] : context.headers || {});
222528
222489
  var Locals2 = createParamDecorator2((context) => context.locals || {});
222529
222490
  var Get2 = createMethodDecorator2("GET");
222530
222491
  var Post2 = createMethodDecorator2("POST");
@@ -222567,9 +222528,9 @@ class Container2 extends Map {
222567
222528
  }
222568
222529
  // ../../node_modules/balanced-match/index.jsodules/minimatch/dist/cjs/un
222569
222530
  class ContainerConfiguration4 {
222531
+ default = new Map;
222532
+ map = new Map;
222570
222533
  constructor(initialProps = {}) {
222571
- this.default = new Map;
222572
- this.map = new Map;
222573
222534
  Object.entries({
222574
222535
  scopes: {},
222575
222536
  resolvers: [],
@@ -222664,10 +222625,12 @@ var createParamNode2 = (paramName) => ({
222664
222625
  });
222665
222626
 
222666
222627
  class Memoirist2 {
222667
- constructor() {
222668
- this.root = {};
222669
- this.history = [];
222670
- }
222628
+ root = {};
222629
+ history = [];
222630
+ static regex = {
222631
+ static: /:.+?(?=\/|$)/,
222632
+ params: /:.+?(?=\/|$)/g
222633
+ };
222671
222634
  add(method, path2, store) {
222672
222635
  if (typeof path2 !== "string")
222673
222636
  throw new TypeError("Route path must be a string");
@@ -222767,10 +222730,6 @@ class Memoirist2 {
222767
222730
  return matchRoute2(url, url.length, root, 0);
222768
222731
  }
222769
222732
  }
222770
- Memoirist2.regex = {
222771
- static: /:.+?(?=\/|$)/,
222772
- params: /:.+?(?=\/|$)/g
222773
- };
222774
222733
  var matchRoute2 = (url, urlLength, node, startIndex) => {
222775
222734
  const part = node?.part;
222776
222735
  const endIndex = startIndex + part.length;
@@ -222851,26 +222810,24 @@ var __decorate5 = function(decorators5, target, key, desc) {
222851
222810
  };
222852
222811
  var InjectorService_12;
222853
222812
  var InjectorService5 = InjectorService_12 = class InjectorService6 {
222854
- constructor() {
222855
- this.settings = new ContainerConfiguration4;
222856
- this.container = new Container2;
222857
- this.applicationConfig = {};
222858
- this.router = new memoirist_default2;
222859
- this.historyMethods = new Map;
222860
- }
222813
+ settings = new ContainerConfiguration4;
222814
+ container = new Container2;
222815
+ applicationConfig = {};
222816
+ router = new memoirist_default2;
222817
+ historyMethods = new Map;
222861
222818
  loadModule(container9, applicationConfig, router) {
222862
222819
  this.container = container9;
222863
222820
  this.router = router;
222864
222821
  this.applicationConfig = applicationConfig;
222865
222822
  this.removeUnknownProviders();
222866
- this.callHook(EventType.OnApplicationInit);
222867
222823
  this.saveInjector();
222868
222824
  this.resolveControllers();
222825
+ this.callHook(EventType.OnApplicationInit);
222869
222826
  }
222870
222827
  resolveControllers() {
222871
222828
  if (!this.settings)
222872
222829
  return {};
222873
- const controllers = GlobalProvider.getByType(ProviderType.CONTROLLER);
222830
+ const controllers = GlobalProvider.getByType(ProviderType2.CONTROLLER).filter((controller3) => !controller3.isChild());
222874
222831
  let hydrateRoute = new Map;
222875
222832
  for (const controller3 of controllers) {
222876
222833
  let routes = Metadata.get(CONTROLLER_ROUTES, controller3.token);
@@ -222902,11 +222859,68 @@ var InjectorService5 = InjectorService_12 = class InjectorService6 {
222902
222859
  }))
222903
222860
  ]);
222904
222861
  }
222862
+ if (controller3.children) {
222863
+ const childrenRoutes = this.resolveChildrenRoutes(controller3.path ?? "", controller3.children, controllerMiddleware);
222864
+ childrenRoutes.forEach((route) => {
222865
+ hydrateRoute.set(route.method.toLowerCase(), [
222866
+ ...hydrateRoute.get(route.method.toLowerCase()) || [],
222867
+ route
222868
+ ]);
222869
+ });
222870
+ }
222905
222871
  }
222906
222872
  hydrateRoute.forEach((method) => {
222907
222873
  method.forEach((route) => this.router.add(route.method.toLowerCase(), route.path, route));
222908
222874
  });
222909
222875
  }
222876
+ resolveChildrenRoutes(parentPath, children, parentMiddlewares) {
222877
+ let childrenRoutes = [];
222878
+ for (const childController of children) {
222879
+ let controller3 = GlobalProvider.get(childController);
222880
+ if (!controller3)
222881
+ throw new Error(`Child ${childController} not is an controller. Please, check the providers configuration.`);
222882
+ let childRoutes = Metadata.get(CONTROLLER_ROUTES, controller3.token);
222883
+ const childMiddlewares = Metadata.get(CONTROLLER_MIDDLEWARES, controller3.token) || [];
222884
+ if (childRoutes.length === 0)
222885
+ continue;
222886
+ if (parentPath) {
222887
+ childRoutes = childRoutes.map((route) => {
222888
+ let controllerPath = controller3?.path ?? "";
222889
+ if (controllerPath.endsWith("/")) {
222890
+ controllerPath = controller3.path.slice(0, -1);
222891
+ }
222892
+ if (!controllerPath.startsWith("/")) {
222893
+ controllerPath = `/${controller3.path}`;
222894
+ }
222895
+ route.path = `${parentPath}${controllerPath ?? ""}${route.path}`;
222896
+ if (route.path.endsWith("/")) {
222897
+ route.path = route.path.slice(0, -1);
222898
+ }
222899
+ if (!route.path.startsWith("/")) {
222900
+ route.path = `/${route.path}`;
222901
+ }
222902
+ return route;
222903
+ });
222904
+ }
222905
+ for (const method of Object.keys(HttpMethod).map((key) => HttpMethod[key])) {
222906
+ if (!childRoutes.some((route) => route.method.toLowerCase() === method))
222907
+ continue;
222908
+ childrenRoutes = [
222909
+ ...childrenRoutes,
222910
+ ...childRoutes.filter((route) => route.method.toLowerCase() === method).map((route) => ({
222911
+ ...route,
222912
+ provider: controller3.token,
222913
+ route,
222914
+ middlewares: [...parentMiddlewares, ...childMiddlewares, ...Metadata.get(ROUTE_MIDDLEWARES, controller3.token, route.methodName) || []]
222915
+ }))
222916
+ ];
222917
+ }
222918
+ if (controller3.children) {
222919
+ childrenRoutes = [...childrenRoutes, ...this.resolveChildrenRoutes(controller3.path, controller3.children, childMiddlewares)];
222920
+ }
222921
+ }
222922
+ return childrenRoutes;
222923
+ }
222910
222924
  ensureProvider(token) {
222911
222925
  if (!this.container.has(token) && GlobalProvider.has(token)) {
222912
222926
  this.container.addProvider(token);
@@ -222937,16 +222951,16 @@ var InjectorService5 = InjectorService_12 = class InjectorService6 {
222937
222951
  const construct = (deps2) => new provider6.useClass(...deps2);
222938
222952
  let instance;
222939
222953
  if (isRequestScope(provider6, deps, this)) {
222940
- scope = ProviderScope.REQUEST;
222954
+ scope = ProviderScope2.REQUEST;
222941
222955
  }
222942
222956
  const services = deps.filter((t) => !isPrimitiveType(t)).map((token) => this.invoke(getClassOrSymbol(token), locals));
222943
222957
  instance = construct(services);
222944
222958
  switch (scope) {
222945
- case ProviderScope.SINGLETON:
222959
+ case ProviderScope2.SINGLETON:
222946
222960
  provider6.instance = instance;
222947
222961
  this.container.addProvider(provider6.token, provider6);
222948
222962
  break;
222949
- case ProviderScope.REQUEST:
222963
+ case ProviderScope2.REQUEST:
222950
222964
  const clone = provider6.clone();
222951
222965
  clone.instance = instance;
222952
222966
  locals.set(clone.token, clone);
@@ -222998,7 +223012,7 @@ var InjectorService5 = InjectorService_12 = class InjectorService6 {
222998
223012
  return methodInfo;
222999
223013
  }
223000
223014
  scopeOf(provider6) {
223001
- return provider6.scope || ProviderScope.SINGLETON;
223015
+ return provider6.scope || ProviderScope2.SINGLETON;
223002
223016
  }
223003
223017
  getConstructorDependencies(target, propertyKey) {
223004
223018
  return Metadata.getOwn("override:ctor:design:paramtypes", target, propertyKey) || [...Metadata.getParamTypes(target, propertyKey)];
@@ -223084,13 +223098,13 @@ var __metadata4 = function(k, v) {
223084
223098
  };
223085
223099
  var Context_12;
223086
223100
  var Context4 = Context_12 = class Context5 {
223101
+ query = {};
223102
+ body = {};
223103
+ param = {};
223104
+ req = {};
223105
+ headers = {};
223106
+ locals = {};
223087
223107
  constructor() {
223088
- this.query = {};
223089
- this.body = {};
223090
- this.param = {};
223091
- this.req = {};
223092
- this.headers = {};
223093
- this.locals = {};
223094
223108
  }
223095
223109
  static async createFromRequest(url, request, server) {
223096
223110
  const context = new Context_12;
@@ -223124,7 +223138,7 @@ var Context4 = Context_12 = class Context5 {
223124
223138
  }
223125
223139
  };
223126
223140
  Context4 = Context_12 = __decorate6([
223127
- Injectable({ scope: ProviderScope.REQUEST }),
223141
+ Injectable({ scope: ProviderScope2.REQUEST }),
223128
223142
  __metadata4("design:paramtypes", [])
223129
223143
  ], Context4);
223130
223144
  // ../../node_modules/balanced-match/index.jsodules/mini
@@ -223168,6 +223182,7 @@ class Metadata3 {
223168
223182
  static setParamTypes(target, propertyKey, value) {
223169
223183
  return this.set(DESIGN_PARAM_TYPES2, value, target.prototype, propertyKey);
223170
223184
  }
223185
+ static getTargetsFromPropertyKey = (metadataKey) => PROPERTIES3.has(metadataKey) ? PROPERTIES3.get(metadataKey) || [] : [];
223171
223186
  static set(key, value, target, propertyKey) {
223172
223187
  const targets = PROPERTIES3.has(key) ? PROPERTIES3.get(key) || [] : [];
223173
223188
  const classConstructor = classOf(target);
@@ -223187,7 +223202,6 @@ class Metadata3 {
223187
223202
  return Reflect.getMetadata(ROUTE_PARAM, target.constructor, propertyKey);
223188
223203
  }
223189
223204
  }
223190
- Metadata3.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES3.has(metadataKey) ? PROPERTIES3.get(metadataKey) || [] : [];
223191
223205
  // ../../node_modules/balanced-match/index.jsodules/minimat
223192
223206
  var HttpMethod2;
223193
223207
  (function(HttpMethod3) {
@@ -223273,9 +223287,75 @@ var RouteExecutor4 = new Router2;
223273
223287
  // ../../node_modules/balanced-match/index.jsodu
223274
223288
  import process4 from "process";
223275
223289
  var parseUrl4 = require_parseurl_fast();
223290
+
223291
+ class Cheetah3 {
223292
+ config;
223293
+ router = new memoirist_default2;
223294
+ injector = createInjector();
223295
+ fetch = (request, server) => this.fetcher(request, server);
223296
+ server;
223297
+ constructor(config = {}) {
223298
+ this.config = config;
223299
+ this.injector.callHook(EventType.OnApplicationBoot, {});
223300
+ }
223301
+ use(plugin) {
223302
+ if (!this.config.providers) {
223303
+ this.config.providers = [];
223304
+ }
223305
+ for (const provider7 of plugin.config.exports || []) {
223306
+ this.config.providers.push(provider7);
223307
+ }
223308
+ return this;
223309
+ }
223310
+ useLogger(provider7) {
223311
+ registerProvider({ provide: LoggerService, useClass: provider7 });
223312
+ return this;
223313
+ }
223314
+ async listen(port = 3000) {
223315
+ process4.on("SIGTERM", () => this.injector.callHook(EventType.OnApplicationShutdown));
223316
+ this.injector.loadModule(createContainer(), this.config, this.router);
223317
+ this.createHttpServer(port);
223318
+ }
223319
+ getInjector() {
223320
+ return this.injector;
223321
+ }
223322
+ createHttpServer(port) {
223323
+ this.server = Bun.serve({ port, fetch: this.fetch, error: this.catcher });
223324
+ console.log(`Server running on port ${port}`);
223325
+ }
223326
+ async fetcher(request, server) {
223327
+ const urlParsed = parseUrl4(request);
223328
+ const context = await Context.createFromRequest(urlParsed, request, server);
223329
+ this.injector.callHook(EventType.OnRequest, { context });
223330
+ const local = new LocalsContainer;
223331
+ const route = this.router.find(request.method.toLowerCase(), urlParsed.path);
223332
+ if (!route) {
223333
+ throw new HttpException("Method not allowed", 404);
223334
+ }
223335
+ context.param = route.params;
223336
+ local.set(Context, context);
223337
+ return RouteExecutor4.executeRoute(route.store, this.injector, context, local);
223338
+ }
223339
+ catcher = (error) => {
223340
+ if (error instanceof HttpException) {
223341
+ return new Response(JSON.stringify({
223342
+ message: error.getResponse(),
223343
+ statusCode: error.getStatus()
223344
+ }), {
223345
+ status: error.statusCode,
223346
+ headers: { "Content-Type": "application/json" }
223347
+ });
223348
+ }
223349
+ return new Response(error.message, { status: 500 });
223350
+ };
223351
+ close(closeActiveConnections = false) {
223352
+ this.server.stop(closeActiveConnections);
223353
+ }
223354
+ }
223276
223355
  // ../../node_modules/balanced-match/index.jsodules/mini
223277
223356
  var EventType2;
223278
223357
  (function(EventType3) {
223358
+ EventType3["OnApplicationBoot"] = "OnApplicationBoot";
223279
223359
  EventType3["OnApplicationInit"] = "OnApplicationInit";
223280
223360
  EventType3["OnApplicationShutdown"] = "OnApplicationShutdown";
223281
223361
  EventType3["OnRequest"] = "OnRequest";
@@ -223327,6 +223407,8 @@ var __metadata6 = function(k, v) {
223327
223407
  return Reflect.metadata(k, v);
223328
223408
  };
223329
223409
  var LoggerService3 = class LoggerService4 {
223410
+ injector;
223411
+ logger;
223330
223412
  constructor(injector) {
223331
223413
  this.injector = injector;
223332
223414
  const pinoConfig = this.injector.applicationConfig.logger || {};
@@ -223355,19 +223437,71 @@ LoggerService3 = __decorate8([
223355
223437
  Service(),
223356
223438
  __metadata6("design:paramtypes", [InjectorService])
223357
223439
  ], LoggerService3);
223440
+ // ../../node_modules/balanced-match/
223441
+ function Entity(options) {
223442
+ return (target) => {
223443
+ const entities = Metadata3.get(ENTITIES, Reflect) || [];
223444
+ entities.push({ target, options });
223445
+ Metadata3.set(ENTITIES, entities, Reflect);
223446
+ };
223447
+ }
223448
+ // ../../node_m
223449
+ function getDefaultLength(type) {
223450
+ if (type === "String") {
223451
+ return 255;
223452
+ }
223453
+ if (type === "Number") {
223454
+ return 11;
223455
+ }
223456
+ if (type === "Boolean") {
223457
+ return 1;
223458
+ }
223459
+ if (type === "Date") {
223460
+ return 6;
223461
+ }
223462
+ return 255;
223463
+ }
223464
+
223465
+ // ../../node_modules/balanced-match/in
223466
+ function Property(options) {
223467
+ return (target, propertyKey) => {
223468
+ const properties = Metadata.get(PROPERTIES, target.constructor) || [];
223469
+ const type = Metadata.getType(target, propertyKey);
223470
+ const length = options && options.length || getDefaultLength(type.name);
223471
+ options = { length, ...options };
223472
+ properties.push({ propertyKey, options });
223473
+ Metadata.set(PROPERTIES, properties, target.constructor);
223474
+ if (options.isPrimary) {
223475
+ const indexes = Metadata.get("indexes", target.constructor) || [];
223476
+ indexes.push({ name: `[TABLE]_pkey`, properties: [propertyKey] });
223477
+ Metadata.set("indexes", indexes, target.constructor);
223478
+ }
223479
+ properties.forEach((property) => {
223480
+ const types = Metadata.get(PROPERTIES_METADATA, target.constructor) || {};
223481
+ const type2 = Metadata.getType(target, property.propertyKey);
223482
+ types[property.propertyKey] = { type: type2, options: property.options };
223483
+ Metadata.set(PROPERTIES_METADATA, types, target.constructor);
223484
+ });
223485
+ };
223486
+ }
223487
+ // ../../node_modules/balanced-match/index
223488
+ function PrimaryKey(options) {
223489
+ const isPrimary = true;
223490
+ return Property({ ...options, isPrimary, unique: true });
223491
+ }
223358
223492
  // ../../node_modules/balanced-match/in
223359
223493
  function OneToMany(entity, fkKey) {
223360
223494
  return (target, propertyKey) => {
223361
- const existing = Metadata3.get(PROPERTIES_RELATIONS, target.constructor) || [];
223362
- existing.push({ relation: "one-to-many", propertyKey, isRelation: true, entity, fkKey, type: Metadata3.getType(target, propertyKey) });
223363
- Metadata3.set(PROPERTIES_RELATIONS, existing, target.constructor);
223495
+ const existing = Metadata.get(PROPERTIES_RELATIONS, target.constructor) || [];
223496
+ existing.push({ relation: "one-to-many", propertyKey, isRelation: true, entity, fkKey, type: Metadata.getType(target, propertyKey) });
223497
+ Metadata.set(PROPERTIES_RELATIONS, existing, target.constructor);
223364
223498
  };
223365
223499
  }
223366
223500
  function ManyToOne(entity) {
223367
223501
  return (target, propertyKey) => {
223368
- const existing = Metadata3.get(PROPERTIES_RELATIONS, target.constructor) || [];
223369
- existing.push({ relation: "many-to-one", propertyKey, isRelation: true, entity, type: Metadata3.getType(target, propertyKey) });
223370
- Metadata3.set(PROPERTIES_RELATIONS, existing, target.constructor);
223502
+ const existing = Metadata.get(PROPERTIES_RELATIONS, target.constructor) || [];
223503
+ existing.push({ relation: "many-to-one", propertyKey, isRelation: true, entity, type: Metadata.getType(target, propertyKey) });
223504
+ Metadata.set(PROPERTIES_RELATIONS, existing, target.constructor);
223371
223505
  };
223372
223506
  }
223373
223507
  // ../../node_modules/balanced-match
@@ -223849,7 +223983,9 @@ class SqlBuilder {
223849
223983
  if (!entity) {
223850
223984
  return;
223851
223985
  }
223852
- if (entitiesOptions.get(alias).showProperties.hasOwnProperty(prop)) {
223986
+ const entityProperty = entitiesOptions.get(alias).showProperties[prop];
223987
+ if (entityProperty) {
223988
+ console.log(typeof value, entityProperty.type);
223853
223989
  entity[prop] = value;
223854
223990
  }
223855
223991
  });
@@ -223921,6 +224057,7 @@ class Orm {
223921
224057
  connection;
223922
224058
  constructor(logger3) {
223923
224059
  this.logger = logger3;
224060
+ Orm.instance = this;
223924
224061
  }
223925
224062
  static getInstance() {
223926
224063
  return Orm.instance;
@@ -224395,4 +224532,4 @@ export {
224395
224532
  BaseEntity
224396
224533
  };
224397
224534
 
224398
- //# debugId=5BDA3B9753B71C6664756e2164756e21
224535
+ //# debugId=B31B68854150104864756e2164756e21