raiton 3.1.0 → 4.0.0

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 (87) hide show
  1. package/README.md +1 -1
  2. package/build/bin/index.mjs +138 -133
  3. package/package.json +3 -3
  4. package/scripts/update-version.ts +42 -5
  5. package/source/bin/bootstrapper.ts +1 -1
  6. package/source/commands/develop.command.ts +1 -1
  7. package/source/core/application.ts +2 -2
  8. package/source/core/builder.ts +3 -3
  9. package/source/core/config/define.ts +1 -1
  10. package/source/core/controller/builder.ts +1 -1
  11. package/source/core/controller/metadata.ts +1 -1
  12. package/source/core/index.ts +1 -0
  13. package/source/core/injection/injection.ts +2 -2
  14. package/source/core/middleware/compose.ts +1 -1
  15. package/source/core/router/handler.ts +5 -5
  16. package/source/core/router/router.ts +1 -1
  17. package/source/core/socket/index.ts +1 -0
  18. package/source/core/socket/metadata.ts +13 -0
  19. package/source/core/thread.ts +4 -4
  20. package/source/{sdk → framework}/artifacts.ts +1 -0
  21. package/source/{sdk → framework}/constants/decorators.constant.ts +2 -0
  22. package/source/{sdk → framework}/decorators/index.ts +1 -0
  23. package/source/framework/decorators/socket.decorator.ts +41 -0
  24. package/source/{sdk → framework}/utilities/artifact.util.ts +3 -0
  25. package/source/types/application.ts +1 -1
  26. package/source/types/controller.ts +1 -1
  27. package/source/types/index.ts +1 -0
  28. package/source/types/responses.ts +1 -1
  29. package/source/types/router.ts +1 -1
  30. package/source/types/runtime.ts +1 -1
  31. package/source/types/socket.ts +15 -0
  32. package/source/types/thread.ts +1 -1
  33. package/source/{sdk → framework}/constants/index.ts +0 -0
  34. package/source/{sdk → framework}/constants/microservices.constant.ts +0 -0
  35. package/source/{sdk → framework}/controllers.ts +0 -0
  36. package/source/{sdk → framework}/data-transfer-object.ts +0 -0
  37. package/source/{sdk → framework}/decorators/access-guard.decorator.ts +0 -0
  38. package/source/{sdk → framework}/decorators/controllable.decorator.ts +0 -0
  39. package/source/{sdk → framework}/decorators/guard.decorator.ts +0 -0
  40. package/source/{sdk → framework}/decorators/injection.decorator.ts +0 -0
  41. package/source/{sdk → framework}/decorators/middleware.decorator.ts +0 -0
  42. package/source/{sdk → framework}/decorators/parametrable.ts +0 -0
  43. package/source/{sdk → framework}/decorators/routable.decorator.ts +0 -0
  44. package/source/{sdk → framework}/encryption.ts +0 -0
  45. package/source/{sdk → framework}/enums/encrypted.enum.ts +0 -0
  46. package/source/{sdk → framework}/enums/event.message.enum.ts +0 -0
  47. package/source/{sdk → framework}/enums/http-method.enum.ts +0 -0
  48. package/source/{sdk → framework}/enums/http-parameters.enum.ts +0 -0
  49. package/source/{sdk → framework}/enums/http-status.enum.ts +0 -0
  50. package/source/{sdk → framework}/enums/index.ts +0 -0
  51. package/source/{sdk → framework}/enums/runtime.enum.ts +0 -0
  52. package/source/{sdk → framework}/enums/timestamp.enum.ts +0 -0
  53. package/source/{sdk → framework}/env.ts +0 -0
  54. package/source/{sdk → framework}/exceptions/http-exception.ts +0 -0
  55. package/source/{sdk → framework}/exceptions/index.ts +0 -0
  56. package/source/{sdk → framework}/exceptions/throwable.ts +0 -0
  57. package/source/{sdk → framework}/index.ts +2 -2
  58. /package/source/{sdk → framework}/parameter-bag.ts +0 -0
  59. /package/source/{sdk → framework}/plugins/body-parser.plugin.ts +0 -0
  60. /package/source/{sdk → framework}/plugins/index.ts +0 -0
  61. /package/source/{sdk → framework}/plugins/security/body-limit.ts +0 -0
  62. /package/source/{sdk → framework}/plugins/security/cors.ts +0 -0
  63. /package/source/{sdk → framework}/plugins/security/headers.ts +0 -0
  64. /package/source/{sdk → framework}/plugins/security/index.ts +0 -0
  65. /package/source/{sdk → framework}/plugins/security/method-guard.ts +0 -0
  66. /package/source/{sdk → framework}/plugins/security/rate-limit.ts +0 -0
  67. /package/source/{sdk → framework}/repositories.ts +0 -0
  68. /package/source/{sdk → framework}/responses/error.ts +0 -0
  69. /package/source/{sdk → framework}/responses/helpers.ts +0 -0
  70. /package/source/{sdk → framework}/responses/http-throwable.ts +0 -0
  71. /package/source/{sdk → framework}/responses/http.ts +0 -0
  72. /package/source/{sdk → framework}/responses/index.ts +0 -0
  73. /package/source/{sdk → framework}/runtime/bun/server.ts +0 -0
  74. /package/source/{sdk → framework}/runtime/deno/server.ts +0 -0
  75. /package/source/{sdk → framework}/runtime/index.ts +0 -0
  76. /package/source/{sdk → framework}/runtime/node/reply.ts +0 -0
  77. /package/source/{sdk → framework}/runtime/node/request.ts +0 -0
  78. /package/source/{sdk → framework}/runtime/node/server.ts +0 -0
  79. /package/source/{sdk → framework}/runtime/web/server.ts +0 -0
  80. /package/source/{sdk → framework}/services.ts +0 -0
  81. /package/source/{sdk → framework}/utilities/alias-path.util.ts +0 -0
  82. /package/source/{sdk → framework}/utilities/callable.util.ts +0 -0
  83. /package/source/{sdk → framework}/utilities/index.ts +0 -0
  84. /package/source/{sdk → framework}/utilities/json.util.ts +0 -0
  85. /package/source/{sdk → framework}/utilities/path.util.ts +0 -0
  86. /package/source/{sdk → framework}/utilities/url.ts +0 -0
  87. /package/source/{sdk → framework}/utilities/utilities.util.ts +0 -0
package/README.md CHANGED
@@ -30,7 +30,7 @@ npm install raiton reflect-metadata
30
30
  ### 1. Créez un contrôleur (`source/controllers/hello.controller.ts`)
31
31
 
32
32
  ```typescript
33
- import { Controllable, Get, Param } from "raiton/sdk";
33
+ import { Controllable, Get, Param } from "raiton/framework";
34
34
 
35
35
  @Controllable('/hello')
36
36
  export class HelloController {
@@ -3873,13 +3873,13 @@ var require_Reflect2 = __commonJS(() => {
3873
3873
  }
3874
3874
  return { value: undefined, done: true };
3875
3875
  };
3876
- MapIterator2.prototype.throw = function(error) {
3876
+ MapIterator2.prototype.throw = function(error2) {
3877
3877
  if (this._index >= 0) {
3878
3878
  this._index = -1;
3879
3879
  this._keys = arraySentinel;
3880
3880
  this._values = arraySentinel;
3881
3881
  }
3882
- throw error;
3882
+ throw error2;
3883
3883
  };
3884
3884
  MapIterator2.prototype.return = function(value) {
3885
3885
  if (this._index >= 0) {
@@ -4799,7 +4799,7 @@ var require_bcrypt = __commonJS((exports, module) => {
4799
4799
  });
4800
4800
 
4801
4801
  // source/bin/index.ts
4802
- var import_reflect_metadata5 = __toESM(require_Reflect(), 1);
4802
+ var import_reflect_metadata6 = __toESM(require_Reflect(), 1);
4803
4803
 
4804
4804
  // node_modules/commander/esm.mjs
4805
4805
  var import__ = __toESM(require_commander(), 1);
@@ -4817,7 +4817,7 @@ var {
4817
4817
  Help
4818
4818
  } = import__.default;
4819
4819
  // package.json
4820
- var version = "3.1.0";
4820
+ var version = "4.0.0";
4821
4821
 
4822
4822
  // source/bin/cli.ts
4823
4823
  var CLI = new Command;
@@ -6211,7 +6211,7 @@ class RaitonConfig {
6211
6211
  }
6212
6212
  }
6213
6213
  }
6214
- // source/sdk/utilities/artifact.util.ts
6214
+ // source/framework/utilities/artifact.util.ts
6215
6215
  function isControllerArtifact(filename) {
6216
6216
  return isArtifact(filename, "controller");
6217
6217
  }
@@ -6223,7 +6223,7 @@ function isArtifact(filename, artifact) {
6223
6223
  filename.endsWith(`.${artifact}.cjs`)
6224
6224
  ].some(Boolean);
6225
6225
  }
6226
- // source/sdk/utilities/path.util.ts
6226
+ // source/framework/utilities/path.util.ts
6227
6227
  import path2 from "node:path";
6228
6228
  import { fileURLToPath } from "node:url";
6229
6229
  function getDirname(importMetaUrl) {
@@ -6257,16 +6257,121 @@ class RaitonDirectories {
6257
6257
  return path4.join(Raiton.thread?.builder.workdir || "", RaitonConfig.get("rootDir") || "./");
6258
6258
  }
6259
6259
  }
6260
- // source/sdk/constants/decorators.constant.ts
6260
+ // source/framework/constants/decorators.constant.ts
6261
6261
  var METADATA_KEYS = {
6262
6262
  CONTROLLERS: Symbol("controller:meta"),
6263
+ SOCKETS: Symbol("socket:meta"),
6264
+ SOCKET_EVENTS: Symbol("socket:event:meta"),
6263
6265
  ROUTE_PARAMETERS: Symbol("route:meta"),
6264
6266
  GRAFTS: Symbol("graft:meta"),
6265
6267
  CONTAINER: Symbol("container:meta"),
6266
6268
  INJECT_PARAMETERS: Symbol("inject:parameters"),
6267
6269
  INJECT_PROPERTIES: Symbol("inject:properties")
6268
6270
  };
6269
- // source/sdk/decorators/routable.decorator.ts
6271
+ // source/framework/responses/http.ts
6272
+ class HttpResponse {
6273
+ response;
6274
+ static push(response) {
6275
+ throw new ThrowableResponse({
6276
+ statusCode: response.statusCode || 400 /* BAD_REQUEST */,
6277
+ message: response.message || "No response message provided",
6278
+ data: response.data,
6279
+ error: response.error,
6280
+ errorStack: response.errorStack
6281
+ });
6282
+ }
6283
+ constructor(response) {
6284
+ this.response = response;
6285
+ }
6286
+ status(statusCode) {
6287
+ this.response.statusCode = statusCode;
6288
+ return this;
6289
+ }
6290
+ message(message) {
6291
+ this.response.message = message;
6292
+ return this;
6293
+ }
6294
+ data(data) {
6295
+ this.response.data = data;
6296
+ return this;
6297
+ }
6298
+ error(error) {
6299
+ this.response.error = error;
6300
+ return this;
6301
+ }
6302
+ stack(stack) {
6303
+ this.response.errorStack = stack;
6304
+ return this;
6305
+ }
6306
+ render() {
6307
+ return new ThrowableResponse({ ...this.response }).render();
6308
+ }
6309
+ }
6310
+
6311
+ // source/framework/responses/error.ts
6312
+ class HttpErrorResponse {
6313
+ stack = new Map;
6314
+ get entries() {
6315
+ return [...this.stack.values()];
6316
+ }
6317
+ add(input) {
6318
+ this.stack.set(input.id, input);
6319
+ return this;
6320
+ }
6321
+ remove(id) {
6322
+ this.stack.delete(id);
6323
+ return this;
6324
+ }
6325
+ get(id) {
6326
+ return this.stack.get(id);
6327
+ }
6328
+ has(id) {
6329
+ return this.stack.has(id);
6330
+ }
6331
+ clear() {
6332
+ this.stack.clear();
6333
+ return this;
6334
+ }
6335
+ get empty() {
6336
+ return this.stack.size === 0;
6337
+ }
6338
+ get existence() {
6339
+ return this.stack.size;
6340
+ }
6341
+ push() {
6342
+ const first = this.stack.values().next().value;
6343
+ HttpResponse.push({
6344
+ statusCode: 500,
6345
+ message: first?.message || "Internal server error",
6346
+ error: true,
6347
+ errorStack: this.entries
6348
+ });
6349
+ }
6350
+ }
6351
+ // source/framework/responses/http-throwable.ts
6352
+ class ThrowableResponse extends Error {
6353
+ input;
6354
+ statusCode;
6355
+ constructor(input, statusCode = 500 /* INTERNAL_SERVER_ERROR */) {
6356
+ super(typeof input === "string" ? input : input.message);
6357
+ this.input = input;
6358
+ this.statusCode = statusCode;
6359
+ }
6360
+ render() {
6361
+ const stack = typeof this.input === "object" ? this.input.errorStack : undefined;
6362
+ return {
6363
+ message: this.message,
6364
+ statusCode: this.statusCode,
6365
+ data: typeof this.input === "object" ? this.input.data : undefined,
6366
+ error: typeof this.input === "object" ? this.input.error : false,
6367
+ stack: stack instanceof Error ? Raiton.thread?.builder?.options?.development ? this.stack?.split(`
6368
+ `).map((e) => e.trim()) : undefined : stack
6369
+ };
6370
+ }
6371
+ }
6372
+ // source/core/socket/metadata.ts
6373
+ var import_reflect_metadata = __toESM(require_Reflect2(), 1);
6374
+ // source/framework/decorators/routable.decorator.ts
6270
6375
  function stabilizeRoute(meta, { path: path5, method, propertyKey }) {
6271
6376
  return {
6272
6377
  ...meta.routes.filter((route) => route.path === path5 && route.method === method || route.propertyKey === propertyKey)[0] || {},
@@ -6294,8 +6399,8 @@ var Options = createRoutableDecorator("OPTIONS" /* OPTIONS */);
6294
6399
  var Trace = createRoutableDecorator("TRACE" /* TRACE */);
6295
6400
  var Delete = createRoutableDecorator("DELETE" /* DELETE */);
6296
6401
  var Head = createRoutableDecorator("HEAD" /* HEAD */);
6297
- // source/sdk/decorators/parametrable.ts
6298
- var import_reflect_metadata = __toESM(require_Reflect2(), 1);
6402
+ // source/framework/decorators/parametrable.ts
6403
+ var import_reflect_metadata2 = __toESM(require_Reflect2(), 1);
6299
6404
  function createRouteParametrableDecorator(type, callable2) {
6300
6405
  return (key) => {
6301
6406
  return (target, propertyKey, index) => {
@@ -6317,12 +6422,12 @@ var UploadedFile = createRouteParametrableDecorator("upload" /* UPLOAD_FILE */);
6317
6422
  var Headers2 = createRouteParametrableDecorator("header" /* HEADER */);
6318
6423
  var Req = createRouteParametrableDecorator("req" /* REQ */);
6319
6424
  var Reply = createRouteParametrableDecorator("reply" /* REPLY */);
6320
- // source/sdk/decorators/injection.decorator.ts
6321
- var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
6425
+ // source/framework/decorators/injection.decorator.ts
6426
+ var import_reflect_metadata4 = __toESM(require_Reflect2(), 1);
6322
6427
 
6323
6428
  // source/core/injection/injection.ts
6324
- var import_reflect_metadata2 = __toESM(require_Reflect2(), 1);
6325
- // source/sdk/exceptions/throwable.ts
6429
+ var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
6430
+ // source/framework/exceptions/throwable.ts
6326
6431
  class Throwable extends Error {
6327
6432
  statusCode;
6328
6433
  constructor(message, statusCode = 500, label) {
@@ -6418,16 +6523,16 @@ class Injection {
6418
6523
  continue;
6419
6524
  }
6420
6525
  if (typeof param === "function") {
6421
- const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, param);
6422
- const token2 = metadata?.name || param.name;
6526
+ const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, param);
6527
+ const token2 = metadata2?.name || param.name;
6423
6528
  this.addDependent(token2, definition.name);
6424
6529
  args.push(this.get(token2, effectiveScope));
6425
6530
  continue;
6426
6531
  }
6427
6532
  }
6428
6533
  if (designParam && typeof designParam === "function" && designParam.name) {
6429
- const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, designParam);
6430
- const token = metadata?.name || designParam.name;
6534
+ const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, designParam);
6535
+ const token = metadata2?.name || designParam.name;
6431
6536
  this.addDependent(token, definition.name);
6432
6537
  args.push(this.get(token, effectiveScope));
6433
6538
  continue;
@@ -6492,8 +6597,8 @@ class Injection {
6492
6597
  this.addDependent(token, definition.name);
6493
6598
  instance[propertyKey] = this.get(token, scope);
6494
6599
  } else if (typeof type === "function") {
6495
- const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, type);
6496
- const token_ = metadata?.name || type.name;
6600
+ const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, type);
6601
+ const token_ = metadata2?.name || type.name;
6497
6602
  this.addDependent(token_, definition.name);
6498
6603
  instance[propertyKey] = this.get(token_, scope);
6499
6604
  }
@@ -6519,10 +6624,10 @@ class Injection {
6519
6624
  this.clear();
6520
6625
  }
6521
6626
  static resolve(construct) {
6522
- const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, construct);
6523
- if (!metadata)
6627
+ const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, construct);
6628
+ if (!metadata2)
6524
6629
  throw new Throwable(`Cannot resolve ${construct.name} as dependency`);
6525
- return this.get(metadata.name);
6630
+ return this.get(metadata2.name);
6526
6631
  }
6527
6632
  }
6528
6633
  // source/core/guards.ts
@@ -6561,107 +6666,6 @@ class RaitonGuards {
6561
6666
  return this;
6562
6667
  }
6563
6668
  }
6564
- // source/sdk/responses/http.ts
6565
- class HttpResponse {
6566
- response;
6567
- static push(response) {
6568
- throw new ThrowableResponse({
6569
- statusCode: response.statusCode || 400 /* BAD_REQUEST */,
6570
- message: response.message || "No response message provided",
6571
- data: response.data,
6572
- error: response.error,
6573
- errorStack: response.errorStack
6574
- });
6575
- }
6576
- constructor(response) {
6577
- this.response = response;
6578
- }
6579
- status(statusCode) {
6580
- this.response.statusCode = statusCode;
6581
- return this;
6582
- }
6583
- message(message) {
6584
- this.response.message = message;
6585
- return this;
6586
- }
6587
- data(data) {
6588
- this.response.data = data;
6589
- return this;
6590
- }
6591
- error(error) {
6592
- this.response.error = error;
6593
- return this;
6594
- }
6595
- stack(stack) {
6596
- this.response.errorStack = stack;
6597
- return this;
6598
- }
6599
- render() {
6600
- return new ThrowableResponse({ ...this.response }).render();
6601
- }
6602
- }
6603
-
6604
- // source/sdk/responses/error.ts
6605
- class HttpErrorResponse {
6606
- stack = new Map;
6607
- get entries() {
6608
- return [...this.stack.values()];
6609
- }
6610
- add(input) {
6611
- this.stack.set(input.id, input);
6612
- return this;
6613
- }
6614
- remove(id) {
6615
- this.stack.delete(id);
6616
- return this;
6617
- }
6618
- get(id) {
6619
- return this.stack.get(id);
6620
- }
6621
- has(id) {
6622
- return this.stack.has(id);
6623
- }
6624
- clear() {
6625
- this.stack.clear();
6626
- return this;
6627
- }
6628
- get empty() {
6629
- return this.stack.size === 0;
6630
- }
6631
- get existence() {
6632
- return this.stack.size;
6633
- }
6634
- push() {
6635
- const first = this.stack.values().next().value;
6636
- HttpResponse.push({
6637
- statusCode: 500,
6638
- message: first?.message || "Internal server error",
6639
- error: true,
6640
- errorStack: this.entries
6641
- });
6642
- }
6643
- }
6644
- // source/sdk/responses/http-throwable.ts
6645
- class ThrowableResponse extends Error {
6646
- input;
6647
- statusCode;
6648
- constructor(input, statusCode = 500 /* INTERNAL_SERVER_ERROR */) {
6649
- super(typeof input === "string" ? input : input.message);
6650
- this.input = input;
6651
- this.statusCode = statusCode;
6652
- }
6653
- render() {
6654
- const stack = typeof this.input === "object" ? this.input.errorStack : undefined;
6655
- return {
6656
- message: this.message,
6657
- statusCode: this.statusCode,
6658
- data: typeof this.input === "object" ? this.input.data : undefined,
6659
- error: typeof this.input === "object" ? this.input.error : false,
6660
- stack: stack instanceof Error ? Raiton.thread?.builder?.options?.development ? this.stack?.split(`
6661
- `).map((e) => e.trim()) : undefined : stack
6662
- };
6663
- }
6664
- }
6665
6669
  // source/core/hooks.ts
6666
6670
  class HookStore {
6667
6671
  hooks = new Map;
@@ -6889,7 +6893,7 @@ class PluginScope {
6889
6893
  function definePlugin(setup, name) {
6890
6894
  return { setup, name };
6891
6895
  }
6892
- // source/sdk/plugins/security/headers.ts
6896
+ // source/framework/plugins/security/headers.ts
6893
6897
  var secureHeaders = definePlugin((scope2) => {
6894
6898
  scope2.use(async ({ context, next }) => {
6895
6899
  context.reply.header("X-Content-Type-Options", "nosniff");
@@ -6899,20 +6903,20 @@ var secureHeaders = definePlugin((scope2) => {
6899
6903
  await next();
6900
6904
  });
6901
6905
  }, "security-headers");
6902
- // source/sdk/encryption.ts
6906
+ // source/framework/encryption.ts
6903
6907
  var import_argon2 = __toESM(require_argon2(), 1);
6904
6908
  var import_bcrypt = __toESM(require_bcrypt(), 1);
6905
6909
  // source/core/controller/metadata.ts
6906
- var import_reflect_metadata4 = __toESM(require_Reflect2(), 1);
6910
+ var import_reflect_metadata5 = __toESM(require_Reflect2(), 1);
6907
6911
  function getControllerMetadata(target) {
6908
- let metadata = Reflect.getMetadata(METADATA_KEYS.CONTROLLERS, target);
6909
- if (!metadata) {
6910
- metadata = { routes: [], middlewares: {} };
6911
- Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS, metadata, target);
6912
+ let metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTROLLERS, target);
6913
+ if (!metadata2) {
6914
+ metadata2 = { routes: [], middlewares: {} };
6915
+ Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS, metadata2, target);
6912
6916
  }
6913
- return metadata;
6917
+ return metadata2;
6914
6918
  }
6915
- // source/sdk/artifacts.ts
6919
+ // source/framework/artifacts.ts
6916
6920
  class Artifacts {
6917
6921
  static types = new Set;
6918
6922
  static defaultTypes = [
@@ -6926,6 +6930,7 @@ class Artifacts {
6926
6930
  "utility",
6927
6931
  "source",
6928
6932
  "controller",
6933
+ "socket",
6929
6934
  "middleware",
6930
6935
  "hook",
6931
6936
  "event",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiton",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading.",
@@ -30,8 +30,8 @@
30
30
  ".": "./source/core/index.ts",
31
31
  "./core/*": "./source/core/*.ts",
32
32
  "./commands/*": "./source/commands/*.ts",
33
- "./sdk": "./source/sdk/index.ts",
34
- "./sdk/*": "./source/sdk/*.ts",
33
+ "./framework": "./source/framework/index.ts",
34
+ "./framework/*": "./source/framework/*.ts",
35
35
  "./types": "./source/types/index.ts",
36
36
  "./types/*": "./source/types/*.ts"
37
37
  },
@@ -10,6 +10,14 @@ function getLatestTag() {
10
10
  }
11
11
  }
12
12
 
13
+ function getCurrentBranch() {
14
+ try {
15
+ return execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
16
+ } catch {
17
+ return "main";
18
+ }
19
+ }
20
+
13
21
  function getCommitsSince(tag: string | null) {
14
22
  const range = tag ? `${tag}..HEAD` : "HEAD";
15
23
  try {
@@ -35,13 +43,13 @@ function determineIncrement(commits: string[]) {
35
43
  }
36
44
  if (
37
45
  commit.startsWith("feat") ||
46
+ commit.startsWith("update") ||
38
47
  commit.startsWith("add")
39
48
  ) {
40
49
  increment = "minor";
41
50
  } else if (
42
51
  !increment &&
43
52
  commit.startsWith("fix") ||
44
- commit.startsWith("update") ||
45
53
  commit.startsWith("remove")
46
54
  ) {
47
55
  increment = "patch";
@@ -51,11 +59,21 @@ function determineIncrement(commits: string[]) {
51
59
  return increment;
52
60
  }
53
61
 
54
- function updateVersion(increment: "major" | "minor" | "patch") {
62
+ function updateVersion(increment: "major" | "minor" | "patch", branch: string) {
55
63
  const packageJsonPath = path.resolve(process.cwd(), "package.json");
56
64
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
57
65
  const currentVersion = packageJson.version;
58
- const [major, minor, patch] = currentVersion.split(".").map(Number);
66
+
67
+ // Identification du suffixe de branche (alpha, beta, rc)
68
+ let preReleaseType: string | null = null;
69
+ if (branch.startsWith("alpha")) preReleaseType = "alpha";
70
+ else if (branch.startsWith("beta")) preReleaseType = "beta";
71
+ else if (branch.startsWith("rc")) preReleaseType = "rc";
72
+
73
+ // Extraction de la version de base et de la pre-release
74
+ // Format: major.minor.patch-type.num
75
+ const [versionPart, preReleasePart] = currentVersion.split("-");
76
+ const [major, minor, patch] = versionPart.split(".").map(Number);
59
77
 
60
78
  let nextVersion = "";
61
79
  if (increment === "major") {
@@ -66,9 +84,27 @@ function updateVersion(increment: "major" | "minor" | "patch") {
66
84
  nextVersion = `${major}.${minor}.${patch + 1}`;
67
85
  }
68
86
 
87
+ // Si nous sommes sur une branche de pre-release
88
+ if (preReleaseType) {
89
+ let preReleaseCount = 0;
90
+ if (preReleasePart && preReleasePart.startsWith(preReleaseType)) {
91
+ // Si on était déjà sur le même type de pre-release, on incrémente le compteur
92
+ // Si la version de base a changé suite à l'incrément, on repart à 0 ?
93
+ // Généralement si on fait un "feat" sur une branche alpha, on incrémente le patch ou le minor
94
+ // MAIS on garde le suffixe alpha.
95
+ const match = preReleasePart.match(/\d+$/);
96
+ preReleaseCount = match ? parseInt(match[0], 10) + 1 : 0;
97
+
98
+ // Si la version de base a été incrémentée, on pourrait vouloir repartir de 0,
99
+ // mais ici on suit la logique demandée : ajouter le nom de la branche.
100
+ }
101
+
102
+ nextVersion = `${nextVersion}-${preReleaseType}.${preReleaseCount}`;
103
+ }
104
+
69
105
  packageJson.version = nextVersion;
70
106
  writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
71
- console.log(`Version updated from ${currentVersion} to ${nextVersion}`);
107
+ console.log(`Version updated from ${currentVersion} to ${nextVersion} (branch: ${branch})`);
72
108
  return nextVersion;
73
109
  }
74
110
 
@@ -91,7 +127,8 @@ function main() {
91
127
  }
92
128
 
93
129
  console.log(`Determined increment: ${increment}`);
94
- updateVersion(increment);
130
+ const branch = getCurrentBranch();
131
+ updateVersion(increment, branch);
95
132
  }
96
133
 
97
134
  main();
@@ -1,6 +1,6 @@
1
1
  import {Command} from 'commander';
2
2
  import {RaitonCommands, RaitonConfig} from "../core";
3
- import {getPackageRoot} from "../sdk";
3
+ import {getPackageRoot} from "../framework";
4
4
  import {CliTools} from "./cli-tools";
5
5
 
6
6
 
@@ -1,7 +1,7 @@
1
1
  import {Raiton, RaitonCommand} from "../core";
2
2
  import {ChildProcess, ChildProcessWithoutNullStreams} from 'node:child_process';
3
3
  import {Logger} from "@protorians/logger";
4
- import {EventMessageEnum} from "../sdk";
4
+ import {EventMessageEnum} from "../framework";
5
5
  import {CliTools} from "../bin/cli-tools";
6
6
  import path from "node:path";
7
7
 
@@ -1,11 +1,11 @@
1
1
  import {PluginScope} from './plugins/scope'
2
2
  import {RequestContext} from './context'
3
3
  import {ApplicationConfigInterface, ApplicationInterface} from "../types/application";
4
- import {HttpMethod} from "../sdk";
4
+ import {HttpMethod} from "../framework";
5
5
  import {RouteHandlerCallable} from "../types";
6
6
  import {Logger} from "@protorians/logger";
7
7
  import {RaitonConfig} from "./config";
8
- import {Artifacts} from "../sdk/artifacts";
8
+ import {Artifacts} from "../framework/artifacts";
9
9
  import {Injection} from "./injection";
10
10
 
11
11
  export class Application implements ApplicationInterface {
@@ -5,13 +5,13 @@ import fs, {WatchEventType} from "node:fs";
5
5
  import type {BuilderConfigInterface, BuilderInterface,} from "../types";
6
6
  import {RaitonThread} from "./thread";
7
7
  import {Raiton} from "./raiton";
8
- import {isControllerArtifact, isServiceArtifact} from "../sdk";
8
+ import {isControllerArtifact, isServiceArtifact} from "../framework";
9
9
  import {ControllerBuilder} from "./controller";
10
10
  import {watch} from "fs";
11
11
  import {LBadge, Logger} from "@protorians/logger";
12
- import {Throwable} from "../sdk/exceptions";
12
+ import {Throwable} from "../framework/exceptions";
13
13
  import {Injection} from "./injection";
14
- import {Artifacts} from "../sdk/artifacts";
14
+ import {Artifacts} from "../framework/artifacts";
15
15
 
16
16
  export class RaitonBuilder implements BuilderInterface {
17
17
  protected _source: string | null = null;
@@ -1,5 +1,5 @@
1
1
  import {ConfigurableInterface} from "../../types/config";
2
- import {JsonUtil} from "../../sdk/utilities";
2
+ import {JsonUtil} from "../../framework/utilities";
3
3
 
4
4
  export async function defineConfig(config?: ConfigurableInterface) {
5
5
  const workdir = process.cwd();
@@ -4,7 +4,7 @@ import {LBadge, Logger} from "@protorians/logger";
4
4
  import {compileController} from "./compiler";
5
5
  import {RaitonThread} from "../thread";
6
6
  import {Injection} from "../injection";
7
- import {isControllerArtifact} from "../../sdk";
7
+ import {isControllerArtifact} from "../../framework";
8
8
  import path from "node:path";
9
9
 
10
10
  export class ControllerBuilder {
@@ -1,5 +1,5 @@
1
1
  import {ControllerMetaInterface} from "../../types";
2
- import {METADATA_KEYS} from "../../sdk";
2
+ import {METADATA_KEYS} from "../../framework";
3
3
  import "reflect-metadata";
4
4
 
5
5
  export function getControllerMetadata(target: any): ControllerMetaInterface {
@@ -9,6 +9,7 @@ export * from "./raiton"
9
9
  export * from "./thread"
10
10
  export * from "./application"
11
11
  export * from "./controller"
12
+ export * from "./socket"
12
13
  export * from "./plugins"
13
14
  export * from "./middleware"
14
15
  export * from "./router"
@@ -2,8 +2,8 @@ import "reflect-metadata";
2
2
  import type {ConstructorType, ContainerDefinitionInterface} from "../../types";
3
3
  import {LifetimeEnum, TextUtility} from "@protorians/core";
4
4
  import {Logger} from "@protorians/logger";
5
- import {METADATA_KEYS} from "../../sdk/constants";
6
- import {Throwable} from "../../sdk/exceptions";
5
+ import {METADATA_KEYS} from "../../framework/constants";
6
+ import {Throwable} from "../../framework/exceptions";
7
7
 
8
8
  const camelCase = TextUtility.camelCase;
9
9
 
@@ -1,5 +1,5 @@
1
1
  import {MiddlewareType} from '../../types'
2
- import {Throwable} from "../../sdk/exceptions";
2
+ import {Throwable} from "../../framework/exceptions";
3
3
 
4
4
  export function middlewareCompose(middlewares: MiddlewareType[]) {
5
5
  return function (request: any) {
@@ -1,11 +1,11 @@
1
1
  import {ControllerMetaInterface, MiddlewareCallable, ParamMetaInterface, RouteMetaInterface} from "../../types";
2
- import {METADATA_KEYS, Parametrable} from "../../sdk";
2
+ import {METADATA_KEYS, Parametrable} from "../../framework";
3
3
  import {Logger} from "@protorians/logger";
4
4
  import {middlewareCompose, Raiton} from "..";
5
- import {DataTransferObject} from "../../sdk/data-transfer-object";
6
- import {Throwable} from "../../sdk/exceptions/throwable";
7
- import {HttpException} from "../../sdk/exceptions";
8
- import {ThrowableResponse} from "../../sdk/responses/http-throwable";
5
+ import {DataTransferObject} from "../../framework/data-transfer-object";
6
+ import {Throwable} from "../../framework/exceptions/throwable";
7
+ import {HttpException} from "../../framework/exceptions";
8
+ import {ThrowableResponse} from "../../framework/responses/http-throwable";
9
9
 
10
10
  export function createHandler(
11
11
  instance: any,
@@ -1,5 +1,5 @@
1
1
  import {RouteHandlerCallable} from '../../types'
2
- import {HttpMethod} from "../../sdk/enums";
2
+ import {HttpMethod} from "../../framework/enums";
3
3
  import {Route} from './route'
4
4
  import {RouteMatcher} from './matcher'
5
5
 
@@ -0,0 +1 @@
1
+ export * from "./metadata"
@@ -0,0 +1,13 @@
1
+ import {SocketMetaInterface} from "../../types";
2
+ import {METADATA_KEYS} from "../../framework";
3
+ import "reflect-metadata";
4
+
5
+ export function getSocketMetadata(target: any): SocketMetaInterface {
6
+ let metadata = Reflect.getMetadata(METADATA_KEYS.SOCKETS, target);
7
+ if (!metadata) {
8
+ metadata = { namespace: '/', events: [] };
9
+ Reflect.defineMetadata(METADATA_KEYS.SOCKETS, metadata, target);
10
+ }
11
+
12
+ return metadata;
13
+ }
@@ -7,16 +7,16 @@ import type {
7
7
  ThreadSetupOptionsInterface,
8
8
  ThreadWaitCallable,
9
9
  } from "../types";
10
- import {EventMessageEnum, RuntimeType} from "../sdk/enums";
10
+ import {EventMessageEnum, RuntimeType} from "../framework/enums";
11
11
  import {ProcessUtility} from "@protorians/core";
12
12
  import {until} from "./process.util";
13
13
  import {ApplicationInterface} from "../types/application";
14
- import {Runtime} from "../sdk/runtime";
14
+ import {Runtime} from "../framework/runtime";
15
15
  import {LBadge, Logger} from "@protorians/logger";
16
16
  import {ControllerBuilder} from "./controller";
17
- import {bodyParserPlugin} from "../sdk/plugins/body-parser.plugin";
17
+ import {bodyParserPlugin} from "../framework/plugins/body-parser.plugin";
18
18
  import {Injection} from "./injection/injection";
19
- import {Throwable} from "../sdk/exceptions";
19
+ import {Throwable} from "../framework/exceptions";
20
20
  import os from "os";
21
21
 
22
22
 
@@ -19,6 +19,7 @@ export class Artifacts {
19
19
  'utility',
20
20
  'source',
21
21
  'controller',
22
+ 'socket',
22
23
  'middleware',
23
24
  'hook',
24
25
  'event',
@@ -1,5 +1,7 @@
1
1
  export const METADATA_KEYS = {
2
2
  CONTROLLERS: Symbol('controller:meta'),
3
+ SOCKETS: Symbol('socket:meta'),
4
+ SOCKET_EVENTS: Symbol('socket:event:meta'),
3
5
  ROUTE_PARAMETERS: Symbol('route:meta'),
4
6
  GRAFTS: Symbol('graft:meta'),
5
7
  CONTAINER: Symbol('container:meta'),
@@ -1,4 +1,5 @@
1
1
  export * from "./controllable.decorator"
2
+ export * from "./socket.decorator"
2
3
  export * from "./middleware.decorator"
3
4
  export * from "./routable.decorator"
4
5
  export * from "./parametrable"
@@ -0,0 +1,41 @@
1
+ import {getSocketMetadata} from "../../core/socket";
2
+ import {Injectable} from "..";
3
+ import {LifetimeEnum} from "@protorians/core";
4
+ import {SocketEventType} from "../../types";
5
+
6
+ export function Socket(namespace = '/') {
7
+ return (target: any) => {
8
+ const name = target.name;
9
+ Injectable(LifetimeEnum.TRANSIENT, name)(target)
10
+
11
+ const meta = getSocketMetadata(target.prototype || target)
12
+ meta.namespace = namespace;
13
+ }
14
+ }
15
+
16
+ function createSocketEventDecorator(type: SocketEventType, name?: string) {
17
+ return (target: any, propertyKey: string) => {
18
+ const meta = getSocketMetadata(target)
19
+ meta.events.push({
20
+ type,
21
+ name: name || propertyKey,
22
+ propertyKey
23
+ })
24
+ }
25
+ }
26
+
27
+ export function OnConnect() {
28
+ return createSocketEventDecorator('connect')
29
+ }
30
+
31
+ export function OnDisconnect() {
32
+ return createSocketEventDecorator('disconnect')
33
+ }
34
+
35
+ export function OnMessage(name?: string) {
36
+ return createSocketEventDecorator('message', name)
37
+ }
38
+
39
+ export function OnEvent(name: string) {
40
+ return createSocketEventDecorator('event', name)
41
+ }
@@ -2,6 +2,9 @@ export function isControllerArtifact(filename: string) {
2
2
  return isArtifact(filename, 'controller')
3
3
  }
4
4
 
5
+ export function isSocketArtifact(filename: string) {
6
+ return isArtifact(filename, 'socket')
7
+ }
5
8
 
6
9
  export function isServiceArtifact(filename: string) {
7
10
  return isArtifact(filename, 'service')
@@ -1,4 +1,4 @@
1
- import {HttpMethod} from "../sdk";
1
+ import {HttpMethod} from "../framework";
2
2
 
3
3
  export interface ApplicationConfigInterface {
4
4
  workdir?: string;
@@ -1,4 +1,4 @@
1
- import {HttpMethod, Parametrable} from "../sdk/enums";
1
+ import {HttpMethod, Parametrable} from "../framework/enums";
2
2
  import {ContextInterface} from "./core";
3
3
  import {MiddlewareCallable, MiddlewareType} from "./middleware";
4
4
 
@@ -16,6 +16,7 @@ export type * from "./plugin"
16
16
  export type * from "./runtime"
17
17
  export type * from "./router"
18
18
  export type * from "./controller"
19
+ export type * from "./socket"
19
20
  export type * from "./injection"
20
21
  export type * from "./responses"
21
22
  export type * from "./server"
@@ -1,4 +1,4 @@
1
- import {HttpStatus} from "../sdk/enums/http-status.enum";
1
+ import {HttpStatus} from "../framework/enums/http-status.enum";
2
2
  import {ParseableEntriesType, ParseableType} from "./parseable";
3
3
 
4
4
  export interface HttpResponseBaseInterface {
@@ -1,5 +1,5 @@
1
1
  import {RequestContext} from "../core/context";
2
- import {HttpMethod} from "../sdk";
2
+ import {HttpMethod} from "../framework";
3
3
 
4
4
  export type RouteHandlerCallable = (ctx: RequestContext) => Promise<any> | any
5
5
 
@@ -1,4 +1,4 @@
1
- import {RuntimeType} from "../sdk/enums/runtime.enum";
1
+ import {RuntimeType} from "../framework/enums/runtime.enum";
2
2
 
3
3
  export interface RuntimeServerInterface {
4
4
  listen(port: number, hostname?: string): Promise<void>
@@ -0,0 +1,15 @@
1
+
2
+ export interface SocketMetaInterface {
3
+ namespace: string;
4
+ events: SocketEventMetaInterface[];
5
+ }
6
+
7
+ export interface SocketEventMetaInterface {
8
+ name: string;
9
+ propertyKey: string;
10
+ type: SocketEventType;
11
+ }
12
+
13
+ export type SocketEventType = 'message' | 'connect' | 'disconnect' | 'event';
14
+
15
+ export type SocketDecoratorCallable = (metadata: SocketMetaInterface) => void;
@@ -1,7 +1,7 @@
1
1
  import {BuilderInterface} from "./builder";
2
2
  import {RuntimeAdapterInterface} from "./runtime";
3
3
  import {ApplicationInterface} from "./application";
4
- import {RuntimeType} from "../sdk/enums/runtime.enum";
4
+ import {RuntimeType} from "../framework/enums/runtime.enum";
5
5
 
6
6
  export interface ThreadSetupOptionsInterface {
7
7
  application: ApplicationInterface;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,9 +1,9 @@
1
1
  export * from "./enums/index"
2
2
  export * from "./constants/index"
3
- export * from "./decorators/index"
3
+ export * from "./utilities/index"
4
4
  export * from "./responses/index"
5
+ export * from "./decorators/index"
5
6
  export * from "./plugins/index"
6
- export * from "./utilities/index"
7
7
  export * from "./runtime/index"
8
8
  export * from "./exceptions/index"
9
9
  export * from "./controllers"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes