@riktajs/core 0.9.0 → 0.10.1

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 (93) hide show
  1. package/README.md +132 -132
  2. package/dist/core/application.d.ts +1 -1
  3. package/dist/core/application.js +36 -43
  4. package/dist/core/config/abstract-config-provider.js +8 -13
  5. package/dist/core/config/env-loader.js +12 -17
  6. package/dist/core/config/index.d.ts +2 -2
  7. package/dist/core/config/index.js +2 -18
  8. package/dist/core/constants.js +18 -21
  9. package/dist/core/container/abstract-class.utils.d.ts +1 -1
  10. package/dist/core/container/abstract-class.utils.js +14 -24
  11. package/dist/core/container/container.d.ts +2 -2
  12. package/dist/core/container/container.js +16 -20
  13. package/dist/core/container/implements.decorator.d.ts +1 -1
  14. package/dist/core/container/implements.decorator.js +17 -23
  15. package/dist/core/container/index.d.ts +5 -5
  16. package/dist/core/container/index.js +5 -21
  17. package/dist/core/container/injection-token.js +1 -5
  18. package/dist/core/container/request-scope.d.ts +1 -1
  19. package/dist/core/container/request-scope.js +4 -8
  20. package/dist/core/decorators/apply-decorators.js +3 -7
  21. package/dist/core/decorators/autowired.decorator.d.ts +1 -1
  22. package/dist/core/decorators/autowired.decorator.js +12 -16
  23. package/dist/core/decorators/config-property.decorator.js +9 -15
  24. package/dist/core/decorators/controller.decorator.js +9 -12
  25. package/dist/core/decorators/create-param-decorator.d.ts +1 -1
  26. package/dist/core/decorators/create-param-decorator.js +7 -12
  27. package/dist/core/decorators/index.d.ts +9 -9
  28. package/dist/core/decorators/index.js +9 -25
  29. package/dist/core/decorators/injectable.decorator.d.ts +1 -1
  30. package/dist/core/decorators/injectable.decorator.js +8 -11
  31. package/dist/core/decorators/param.decorator.d.ts +1 -1
  32. package/dist/core/decorators/param.decorator.js +14 -17
  33. package/dist/core/decorators/provider.decorator.d.ts +2 -2
  34. package/dist/core/decorators/provider.decorator.js +12 -17
  35. package/dist/core/decorators/route.decorator.js +13 -17
  36. package/dist/core/discovery.d.ts +1 -1
  37. package/dist/core/discovery.js +25 -57
  38. package/dist/core/exceptions/catch.decorator.d.ts +1 -1
  39. package/dist/core/exceptions/catch.decorator.js +6 -11
  40. package/dist/core/exceptions/config.exceptions.js +3 -9
  41. package/dist/core/exceptions/discovery.exception.js +1 -5
  42. package/dist/core/exceptions/exception-filter.js +5 -10
  43. package/dist/core/exceptions/exceptions.d.ts +1 -1
  44. package/dist/core/exceptions/exceptions.js +19 -40
  45. package/dist/core/exceptions/http-exception.js +1 -5
  46. package/dist/core/exceptions/index.d.ts +7 -7
  47. package/dist/core/exceptions/index.js +7 -39
  48. package/dist/core/exceptions/validation.exception.d.ts +1 -1
  49. package/dist/core/exceptions/validation.exception.js +2 -6
  50. package/dist/core/guards/can-activate.interface.d.ts +1 -1
  51. package/dist/core/guards/can-activate.interface.js +1 -2
  52. package/dist/core/guards/execution-context.d.ts +1 -1
  53. package/dist/core/guards/execution-context.js +1 -5
  54. package/dist/core/guards/index.d.ts +3 -3
  55. package/dist/core/guards/index.js +2 -8
  56. package/dist/core/guards/use-guards.decorator.d.ts +2 -2
  57. package/dist/core/guards/use-guards.decorator.js +10 -14
  58. package/dist/core/index.d.ts +17 -17
  59. package/dist/core/index.js +17 -35
  60. package/dist/core/interceptors/index.d.ts +2 -2
  61. package/dist/core/interceptors/index.js +1 -6
  62. package/dist/core/interceptors/interceptor.interface.d.ts +1 -1
  63. package/dist/core/interceptors/interceptor.interface.js +1 -2
  64. package/dist/core/interceptors/use-interceptors.decorator.d.ts +2 -2
  65. package/dist/core/interceptors/use-interceptors.decorator.js +10 -14
  66. package/dist/core/lifecycle/event-bus.d.ts +1 -1
  67. package/dist/core/lifecycle/event-bus.js +4 -7
  68. package/dist/core/lifecycle/index.d.ts +3 -3
  69. package/dist/core/lifecycle/index.js +3 -19
  70. package/dist/core/lifecycle/interfaces.js +1 -2
  71. package/dist/core/lifecycle/on.decorator.d.ts +1 -1
  72. package/dist/core/lifecycle/on.decorator.js +5 -9
  73. package/dist/core/metadata.d.ts +2 -2
  74. package/dist/core/metadata.js +26 -43
  75. package/dist/core/middleware/index.d.ts +3 -3
  76. package/dist/core/middleware/index.js +2 -9
  77. package/dist/core/middleware/middleware.decorator.js +2 -5
  78. package/dist/core/middleware/rikta-middleware.interface.js +1 -2
  79. package/dist/core/middleware/use-middleware.decorator.d.ts +2 -2
  80. package/dist/core/middleware/use-middleware.decorator.js +10 -14
  81. package/dist/core/profiler/index.d.ts +2 -2
  82. package/dist/core/profiler/index.js +1 -8
  83. package/dist/core/profiler/performance-profiler.d.ts +1 -1
  84. package/dist/core/profiler/performance-profiler.js +6 -12
  85. package/dist/core/registry.d.ts +1 -1
  86. package/dist/core/registry.js +4 -7
  87. package/dist/core/router/router.d.ts +2 -2
  88. package/dist/core/router/router.js +31 -35
  89. package/dist/core/types.d.ts +3 -3
  90. package/dist/core/types.js +1 -2
  91. package/dist/index.d.ts +2 -2
  92. package/dist/index.js +2 -20
  93. package/package.json +8 -1
@@ -1,27 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRIMARY_METADATA = exports.IMPLEMENTS_METADATA = void 0;
4
- exports.isAbstractClass = isAbstractClass;
5
- exports.extendsFrom = extendsFrom;
6
- exports.getImplementedAbstract = getImplementedAbstract;
7
- exports.isPrimaryImplementation = isPrimaryImplementation;
8
- exports.setImplementsMetadata = setImplementsMetadata;
9
- exports.setPrimaryMetadata = setPrimaryMetadata;
10
- exports.markAsAbstract = markAsAbstract;
11
- exports.IMPLEMENTS_METADATA = Symbol('rikta:implements');
12
- exports.PRIMARY_METADATA = Symbol('rikta:primary');
13
- function isAbstractClass(target) {
1
+ export const IMPLEMENTS_METADATA = Symbol('rikta:implements');
2
+ export const PRIMARY_METADATA = Symbol('rikta:primary');
3
+ export function isAbstractClass(target) {
14
4
  if (typeof target !== 'function') {
15
5
  return false;
16
6
  }
17
- const isMarkedAbstract = Reflect.getMetadata(exports.IMPLEMENTS_METADATA, target) === undefined
7
+ const isMarkedAbstract = Reflect.getMetadata(IMPLEMENTS_METADATA, target) === undefined
18
8
  && Reflect.hasMetadata('abstract:class', target);
19
9
  if (isMarkedAbstract) {
20
10
  return true;
21
11
  }
22
12
  return Reflect.getMetadata('abstract:class', target) === true;
23
13
  }
24
- function extendsFrom(derived, base) {
14
+ export function extendsFrom(derived, base) {
25
15
  if (!derived || !base) {
26
16
  return false;
27
17
  }
@@ -37,18 +27,18 @@ function extendsFrom(derived, base) {
37
27
  }
38
28
  return false;
39
29
  }
40
- function getImplementedAbstract(target) {
41
- return Reflect.getMetadata(exports.IMPLEMENTS_METADATA, target);
30
+ export function getImplementedAbstract(target) {
31
+ return Reflect.getMetadata(IMPLEMENTS_METADATA, target);
42
32
  }
43
- function isPrimaryImplementation(target) {
44
- return Reflect.getMetadata(exports.PRIMARY_METADATA, target) === true;
33
+ export function isPrimaryImplementation(target) {
34
+ return Reflect.getMetadata(PRIMARY_METADATA, target) === true;
45
35
  }
46
- function setImplementsMetadata(target, abstractClass) {
47
- Reflect.defineMetadata(exports.IMPLEMENTS_METADATA, abstractClass, target);
36
+ export function setImplementsMetadata(target, abstractClass) {
37
+ Reflect.defineMetadata(IMPLEMENTS_METADATA, abstractClass, target);
48
38
  }
49
- function setPrimaryMetadata(target) {
50
- Reflect.defineMetadata(exports.PRIMARY_METADATA, true, target);
39
+ export function setPrimaryMetadata(target) {
40
+ Reflect.defineMetadata(PRIMARY_METADATA, true, target);
51
41
  }
52
- function markAsAbstract(target) {
42
+ export function markAsAbstract(target) {
53
43
  Reflect.defineMetadata('abstract:class', true, target);
54
44
  }
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
- import { Constructor, InjectableOptions } from '../types';
3
- import { Token, ProviderDefinition } from './injection-token';
2
+ import { Constructor, InjectableOptions } from '../types.js';
3
+ import { Token, ProviderDefinition } from './injection-token.js';
4
4
  export declare class Container {
5
5
  private static instance;
6
6
  private singletons;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.container = exports.Container = void 0;
4
- require("reflect-metadata");
5
- const constants_1 = require("../constants");
6
- const injection_token_1 = require("./injection-token");
7
- const registry_1 = require("../registry");
8
- const abstract_class_utils_1 = require("./abstract-class.utils");
9
- const request_scope_1 = require("./request-scope");
10
- class Container {
1
+ import 'reflect-metadata';
2
+ import { INJECT_METADATA, AUTOWIRED_METADATA } from '../constants.js';
3
+ import { InjectionToken } from './injection-token.js';
4
+ import { registry } from '../registry.js';
5
+ import { isAbstractClass } from './abstract-class.utils.js';
6
+ import { requestScopeStorage } from './request-scope.js';
7
+ export class Container {
11
8
  static instance;
12
9
  singletons = new Map();
13
10
  providers = new Map();
@@ -80,7 +77,7 @@ class Container {
80
77
  this.singletons.set(token, instance);
81
78
  return instance;
82
79
  }
83
- if (!(0, abstract_class_utils_1.isAbstractClass)(token)) {
80
+ if (!isAbstractClass(token)) {
84
81
  return this.resolveClass(token);
85
82
  }
86
83
  }
@@ -102,7 +99,7 @@ class Container {
102
99
  if (config?.provider && 'useClass' in config.provider) {
103
100
  return config.provider.useClass;
104
101
  }
105
- const implementations = registry_1.registry.getImplementations(abstractClass);
102
+ const implementations = registry.getImplementations(abstractClass);
106
103
  if (!implementations || implementations.length === 0) {
107
104
  return undefined;
108
105
  }
@@ -168,18 +165,18 @@ class Container {
168
165
  return this.singletons.get(target);
169
166
  }
170
167
  if (scope === 'request') {
171
- if (!request_scope_1.requestScopeStorage.isInRequestScope()) {
168
+ if (!requestScopeStorage.isInRequestScope()) {
172
169
  throw new Error(`Cannot resolve request-scoped provider '${target.name}' outside of a request context. ` +
173
170
  `Request-scoped providers can only be resolved during HTTP request handling.`);
174
171
  }
175
- const existingInstance = request_scope_1.requestScopeStorage.get(target);
172
+ const existingInstance = requestScopeStorage.get(target);
176
173
  if (existingInstance !== undefined) {
177
174
  return existingInstance;
178
175
  }
179
176
  }
180
177
  this.resolutionStack.add(target);
181
178
  try {
182
- const injectMeta = Reflect.getMetadata(constants_1.INJECT_METADATA, target) ?? [];
179
+ const injectMeta = Reflect.getMetadata(INJECT_METADATA, target) ?? [];
183
180
  const paramTypes = Reflect.getMetadata('design:paramtypes', target) ?? [];
184
181
  const maxIndex = injectMeta.length > 0
185
182
  ? Math.max(...injectMeta.map(m => m.index ?? -1))
@@ -218,7 +215,7 @@ class Container {
218
215
  this.singletons.set(target, instance);
219
216
  }
220
217
  else if (scope === 'request') {
221
- request_scope_1.requestScopeStorage.set(target, instance);
218
+ requestScopeStorage.set(target, instance);
222
219
  }
223
220
  return instance;
224
221
  }
@@ -227,7 +224,7 @@ class Container {
227
224
  }
228
225
  }
229
226
  injectProperties(target, instance) {
230
- const autowireMeta = Reflect.getMetadata(constants_1.AUTOWIRED_METADATA, target) ?? [];
227
+ const autowireMeta = Reflect.getMetadata(AUTOWIRED_METADATA, target) ?? [];
231
228
  for (const meta of autowireMeta) {
232
229
  if (!meta.propertyKey)
233
230
  continue;
@@ -283,7 +280,7 @@ class Container {
283
280
  if (typeof token === 'function') {
284
281
  return token.name;
285
282
  }
286
- if (token instanceof injection_token_1.InjectionToken) {
283
+ if (token instanceof InjectionToken) {
287
284
  return token.toString();
288
285
  }
289
286
  if (typeof token === 'symbol') {
@@ -292,5 +289,4 @@ class Container {
292
289
  return String(token);
293
290
  }
294
291
  }
295
- exports.Container = Container;
296
- exports.container = Container.getInstance();
292
+ export const container = Container.getInstance();
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { AnyConstructor } from '../types';
2
+ import { AnyConstructor } from '../types.js';
3
3
  export declare function Implements<T extends AnyConstructor>(abstractClass: T): ClassDecorator;
4
4
  export declare function Primary(): ClassDecorator;
5
5
  export declare function Named(name: string): ClassDecorator;
@@ -1,45 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Implements = Implements;
4
- exports.Primary = Primary;
5
- exports.Named = Named;
6
- exports.AbstractClass = AbstractClass;
7
- require("reflect-metadata");
8
- const abstract_class_utils_1 = require("./abstract-class.utils");
9
- const registry_1 = require("../registry");
10
- function Implements(abstractClass) {
1
+ import 'reflect-metadata';
2
+ import { setImplementsMetadata, setPrimaryMetadata, markAsAbstract, IMPLEMENTS_METADATA } from './abstract-class.utils.js';
3
+ import { registry } from '../registry.js';
4
+ export function Implements(abstractClass) {
11
5
  return (target) => {
12
- (0, abstract_class_utils_1.setImplementsMetadata)(target, abstractClass);
13
- (0, abstract_class_utils_1.markAsAbstract)(abstractClass);
6
+ setImplementsMetadata(target, abstractClass);
7
+ markAsAbstract(abstractClass);
14
8
  const name = Reflect.getMetadata('rikta:named', target);
15
- registry_1.registry.registerAbstractImplementation(abstractClass, target, name);
9
+ registry.registerAbstractImplementation(abstractClass, target, name);
16
10
  const isPrimary = Reflect.getMetadata('rikta:is-primary', target) === true;
17
11
  if (isPrimary) {
18
- registry_1.registry.setPrimaryImplementation(abstractClass, target);
12
+ registry.setPrimaryImplementation(abstractClass, target);
19
13
  }
20
14
  };
21
15
  }
22
- function Primary() {
16
+ export function Primary() {
23
17
  return (target) => {
24
- (0, abstract_class_utils_1.setPrimaryMetadata)(target);
25
- const abstractClass = Reflect.getMetadata(abstract_class_utils_1.IMPLEMENTS_METADATA, target);
18
+ setPrimaryMetadata(target);
19
+ const abstractClass = Reflect.getMetadata(IMPLEMENTS_METADATA, target);
26
20
  if (abstractClass) {
27
- registry_1.registry.setPrimaryImplementation(abstractClass, target);
21
+ registry.setPrimaryImplementation(abstractClass, target);
28
22
  }
29
23
  Reflect.defineMetadata('rikta:is-primary', true, target);
30
24
  };
31
25
  }
32
- function Named(name) {
26
+ export function Named(name) {
33
27
  return (target) => {
34
28
  Reflect.defineMetadata('rikta:named', name, target);
35
- const abstractClass = Reflect.getMetadata(abstract_class_utils_1.IMPLEMENTS_METADATA, target);
29
+ const abstractClass = Reflect.getMetadata(IMPLEMENTS_METADATA, target);
36
30
  if (abstractClass) {
37
- registry_1.registry.setImplementationName(abstractClass, target, name);
31
+ registry.setImplementationName(abstractClass, target, name);
38
32
  }
39
33
  };
40
34
  }
41
- function AbstractClass() {
35
+ export function AbstractClass() {
42
36
  return (target) => {
43
- (0, abstract_class_utils_1.markAsAbstract)(target);
37
+ markAsAbstract(target);
44
38
  };
45
39
  }
@@ -1,5 +1,5 @@
1
- export * from './container';
2
- export * from './injection-token';
3
- export * from './abstract-class.utils';
4
- export * from './implements.decorator';
5
- export * from './request-scope';
1
+ export * from './container.js';
2
+ export * from './injection-token.js';
3
+ export * from './abstract-class.utils.js';
4
+ export * from './implements.decorator.js';
5
+ export * from './request-scope.js';
@@ -1,21 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./container"), exports);
18
- __exportStar(require("./injection-token"), exports);
19
- __exportStar(require("./abstract-class.utils"), exports);
20
- __exportStar(require("./implements.decorator"), exports);
21
- __exportStar(require("./request-scope"), exports);
1
+ export * from './container.js';
2
+ export * from './injection-token.js';
3
+ export * from './abstract-class.utils.js';
4
+ export * from './implements.decorator.js';
5
+ export * from './request-scope.js';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectionToken = void 0;
4
- class InjectionToken {
1
+ export class InjectionToken {
5
2
  description;
6
3
  options;
7
4
  constructor(description, options) {
@@ -12,4 +9,3 @@ class InjectionToken {
12
9
  return `InjectionToken(${this.description})`;
13
10
  }
14
11
  }
15
- exports.InjectionToken = InjectionToken;
@@ -1,4 +1,4 @@
1
- import { Token } from './injection-token';
1
+ import { Token } from './injection-token.js';
2
2
  export declare class RequestScopeStorage {
3
3
  private static instance;
4
4
  private readonly asyncLocalStorage;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestScopeStorage = exports.RequestScopeStorage = void 0;
4
- const node_async_hooks_1 = require("node:async_hooks");
5
- class RequestScopeStorage {
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ export class RequestScopeStorage {
6
3
  static instance;
7
- asyncLocalStorage = new node_async_hooks_1.AsyncLocalStorage();
4
+ asyncLocalStorage = new AsyncLocalStorage();
8
5
  constructor() { }
9
6
  static getInstance() {
10
7
  if (!RequestScopeStorage.instance) {
@@ -49,5 +46,4 @@ class RequestScopeStorage {
49
46
  return this.asyncLocalStorage.getStore();
50
47
  }
51
48
  }
52
- exports.RequestScopeStorage = RequestScopeStorage;
53
- exports.requestScopeStorage = RequestScopeStorage.getInstance();
49
+ export const requestScopeStorage = RequestScopeStorage.getInstance();
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyDecorators = applyDecorators;
4
- exports.SetMetadata = SetMetadata;
5
- require("reflect-metadata");
6
- function applyDecorators(...decorators) {
1
+ import 'reflect-metadata';
2
+ export function applyDecorators(...decorators) {
7
3
  return ((target, propertyKey, descriptor) => {
8
4
  for (const decorator of decorators.reverse()) {
9
5
  if (descriptor) {
@@ -27,7 +23,7 @@ function applyDecorators(...decorators) {
27
23
  }
28
24
  });
29
25
  }
30
- function SetMetadata(key, value) {
26
+ export function SetMetadata(key, value) {
31
27
  const decoratorFactory = (target, propertyKey, descriptor) => {
32
28
  if (descriptor) {
33
29
  Reflect.defineMetadata(key, value, target.constructor, propertyKey);
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Token } from '../container/injection-token';
2
+ import { Token } from '../container/injection-token.js';
3
3
  export interface AutowiredMetadata {
4
4
  token: Token;
5
5
  index?: number;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Autowired = Autowired;
4
- exports.Optional = Optional;
5
- require("reflect-metadata");
6
- const constants_1 = require("../constants");
7
- function Autowired(token, name) {
1
+ import 'reflect-metadata';
2
+ import { INJECT_METADATA, AUTOWIRED_METADATA } from '../constants.js';
3
+ export function Autowired(token, name) {
8
4
  return (target, propertyKey, parameterIndex) => {
9
5
  if (typeof parameterIndex === 'number') {
10
6
  const paramTypes = Reflect.getMetadata('design:paramtypes', target) ?? [];
@@ -14,13 +10,13 @@ function Autowired(token, name) {
14
10
  throw new Error(`@Autowired() on constructor parameter ${parameterIndex} of ${target.name} ` +
15
11
  `could not infer type. Please provide a token explicitly.`);
16
12
  }
17
- const existingInjects = Reflect.getMetadata(constants_1.INJECT_METADATA, target) ?? [];
13
+ const existingInjects = Reflect.getMetadata(INJECT_METADATA, target) ?? [];
18
14
  existingInjects.push({
19
15
  token: resolvedToken,
20
16
  index: parameterIndex,
21
17
  name,
22
18
  });
23
- Reflect.defineMetadata(constants_1.INJECT_METADATA, existingInjects, target);
19
+ Reflect.defineMetadata(INJECT_METADATA, existingInjects, target);
24
20
  }
25
21
  else if (propertyKey !== undefined) {
26
22
  const inferredType = Reflect.getMetadata('design:type', target, propertyKey);
@@ -29,20 +25,20 @@ function Autowired(token, name) {
29
25
  throw new Error(`@Autowired() on ${target.constructor.name}.${String(propertyKey)} ` +
30
26
  `could not infer type. Please provide a token explicitly.`);
31
27
  }
32
- const existingAutowires = Reflect.getMetadata(constants_1.AUTOWIRED_METADATA, target.constructor) ?? [];
28
+ const existingAutowires = Reflect.getMetadata(AUTOWIRED_METADATA, target.constructor) ?? [];
33
29
  existingAutowires.push({
34
30
  token: resolvedToken,
35
31
  propertyKey: String(propertyKey),
36
32
  name,
37
33
  });
38
- Reflect.defineMetadata(constants_1.AUTOWIRED_METADATA, existingAutowires, target.constructor);
34
+ Reflect.defineMetadata(AUTOWIRED_METADATA, existingAutowires, target.constructor);
39
35
  }
40
36
  };
41
37
  }
42
- function Optional() {
38
+ export function Optional() {
43
39
  return (target, propertyKey, parameterIndex) => {
44
40
  if (typeof parameterIndex === 'number') {
45
- const existingInjects = Reflect.getMetadata(constants_1.INJECT_METADATA, target) ?? [];
41
+ const existingInjects = Reflect.getMetadata(INJECT_METADATA, target) ?? [];
46
42
  let meta = existingInjects.find(m => m.index === parameterIndex);
47
43
  if (meta) {
48
44
  meta.optional = true;
@@ -58,10 +54,10 @@ function Optional() {
58
54
  });
59
55
  }
60
56
  }
61
- Reflect.defineMetadata(constants_1.INJECT_METADATA, existingInjects, target);
57
+ Reflect.defineMetadata(INJECT_METADATA, existingInjects, target);
62
58
  }
63
59
  else if (propertyKey !== undefined) {
64
- const existingAutowires = Reflect.getMetadata(constants_1.AUTOWIRED_METADATA, target.constructor) ?? [];
60
+ const existingAutowires = Reflect.getMetadata(AUTOWIRED_METADATA, target.constructor) ?? [];
65
61
  let meta = existingAutowires.find(m => m.propertyKey === String(propertyKey));
66
62
  if (meta) {
67
63
  meta.optional = true;
@@ -76,7 +72,7 @@ function Optional() {
76
72
  });
77
73
  }
78
74
  }
79
- Reflect.defineMetadata(constants_1.AUTOWIRED_METADATA, existingAutowires, target.constructor);
75
+ Reflect.defineMetadata(AUTOWIRED_METADATA, existingAutowires, target.constructor);
80
76
  }
81
77
  };
82
78
  }
@@ -1,11 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigProperty = ConfigProperty;
4
- exports.getConfigPropertyMappings = getConfigPropertyMappings;
5
- exports.hasConfigProperties = hasConfigProperties;
6
- exports.clearPropertyNameCache = clearPropertyNameCache;
7
- require("reflect-metadata");
8
- const constants_1 = require("../constants");
1
+ import 'reflect-metadata';
2
+ import { CONFIG_PROPERTY_METADATA } from '../constants.js';
9
3
  const propertyNameCache = new Map();
10
4
  function toUpperSnakeCase(propertyName) {
11
5
  if (propertyNameCache.has(propertyName)) {
@@ -18,7 +12,7 @@ function toUpperSnakeCase(propertyName) {
18
12
  propertyNameCache.set(propertyName, envKey);
19
13
  return envKey;
20
14
  }
21
- function ConfigProperty(envKey) {
15
+ export function ConfigProperty(envKey) {
22
16
  return (target, propertyKey) => {
23
17
  if (typeof propertyKey === 'symbol') {
24
18
  throw new Error(`@ConfigProperty: Symbol properties are not supported. ` +
@@ -34,7 +28,7 @@ function ConfigProperty(envKey) {
34
28
  `Use "${finalEnvKey.toUpperCase()}" instead.`);
35
29
  }
36
30
  const constructor = target.constructor;
37
- const existingMappings = Reflect.getMetadata(constants_1.CONFIG_PROPERTY_METADATA, constructor) || [];
31
+ const existingMappings = Reflect.getMetadata(CONFIG_PROPERTY_METADATA, constructor) || [];
38
32
  const duplicate = existingMappings.find(m => m.propertyKey === propertyKey);
39
33
  if (duplicate) {
40
34
  throw new Error(`@ConfigProperty: Property "${propertyKey}" on class "${constructor.name}" ` +
@@ -50,16 +44,16 @@ function ConfigProperty(envKey) {
50
44
  envKey: finalEnvKey,
51
45
  };
52
46
  const updatedMappings = [...existingMappings, newMapping];
53
- Reflect.defineMetadata(constants_1.CONFIG_PROPERTY_METADATA, updatedMappings, constructor);
47
+ Reflect.defineMetadata(CONFIG_PROPERTY_METADATA, updatedMappings, constructor);
54
48
  };
55
49
  }
56
- function getConfigPropertyMappings(target) {
57
- return Reflect.getMetadata(constants_1.CONFIG_PROPERTY_METADATA, target) || [];
50
+ export function getConfigPropertyMappings(target) {
51
+ return Reflect.getMetadata(CONFIG_PROPERTY_METADATA, target) || [];
58
52
  }
59
- function hasConfigProperties(target) {
53
+ export function hasConfigProperties(target) {
60
54
  const mappings = getConfigPropertyMappings(target);
61
55
  return mappings.length > 0;
62
56
  }
63
- function clearPropertyNameCache() {
57
+ export function clearPropertyNameCache() {
64
58
  propertyNameCache.clear();
65
59
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Controller = Controller;
4
- require("reflect-metadata");
5
- const constants_1 = require("../constants");
6
- const container_1 = require("../container/container");
7
- const registry_1 = require("../registry");
8
- function Controller(prefixOrOptions) {
1
+ import 'reflect-metadata';
2
+ import { CONTROLLER_METADATA, INJECTABLE_METADATA } from '../constants.js';
3
+ import { container } from '../container/container.js';
4
+ import { registry } from '../registry.js';
5
+ export function Controller(prefixOrOptions) {
9
6
  return (target) => {
10
7
  const prefix = typeof prefixOrOptions === 'string'
11
8
  ? prefixOrOptions
@@ -13,9 +10,9 @@ function Controller(prefixOrOptions) {
13
10
  const normalizedPrefix = prefix
14
11
  ? (prefix.startsWith('/') ? prefix : `/${prefix}`)
15
12
  : '';
16
- Reflect.defineMetadata(constants_1.CONTROLLER_METADATA, { prefix: normalizedPrefix }, target);
17
- Reflect.defineMetadata(constants_1.INJECTABLE_METADATA, { scope: 'singleton' }, target);
18
- container_1.container.register(target, { scope: 'singleton' });
19
- registry_1.registry.registerController(target);
13
+ Reflect.defineMetadata(CONTROLLER_METADATA, { prefix: normalizedPrefix }, target);
14
+ Reflect.defineMetadata(INJECTABLE_METADATA, { scope: 'singleton' }, target);
15
+ container.register(target, { scope: 'singleton' });
16
+ registry.registerController(target);
20
17
  };
21
18
  }
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { ExecutionContext } from '../guards/execution-context';
2
+ import { ExecutionContext } from '../guards/execution-context.js';
3
3
  export declare const CUSTOM_PARAM_METADATA: unique symbol;
4
4
  export interface CustomParamMetadata<T = unknown> {
5
5
  index: number;
@@ -1,26 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CUSTOM_PARAM_METADATA = void 0;
4
- exports.createParamDecorator = createParamDecorator;
5
- exports.getCustomParamMetadata = getCustomParamMetadata;
6
- require("reflect-metadata");
7
- exports.CUSTOM_PARAM_METADATA = Symbol.for('rikta:custom:param:metadata');
8
- function createParamDecorator(factory) {
1
+ import 'reflect-metadata';
2
+ export const CUSTOM_PARAM_METADATA = Symbol.for('rikta:custom:param:metadata');
3
+ export function createParamDecorator(factory) {
9
4
  return (data) => {
10
5
  return (target, propertyKey, parameterIndex) => {
11
6
  if (propertyKey === undefined)
12
7
  return;
13
- const existingParams = Reflect.getMetadata(exports.CUSTOM_PARAM_METADATA, target.constructor, propertyKey) ?? [];
8
+ const existingParams = Reflect.getMetadata(CUSTOM_PARAM_METADATA, target.constructor, propertyKey) ?? [];
14
9
  const metadata = {
15
10
  index: parameterIndex,
16
11
  factory: factory,
17
12
  data,
18
13
  };
19
14
  existingParams.push(metadata);
20
- Reflect.defineMetadata(exports.CUSTOM_PARAM_METADATA, existingParams, target.constructor, propertyKey);
15
+ Reflect.defineMetadata(CUSTOM_PARAM_METADATA, existingParams, target.constructor, propertyKey);
21
16
  };
22
17
  };
23
18
  }
24
- function getCustomParamMetadata(target, propertyKey) {
25
- return Reflect.getMetadata(exports.CUSTOM_PARAM_METADATA, target, propertyKey) ?? [];
19
+ export function getCustomParamMetadata(target, propertyKey) {
20
+ return Reflect.getMetadata(CUSTOM_PARAM_METADATA, target, propertyKey) ?? [];
26
21
  }
@@ -1,9 +1,9 @@
1
- export * from './injectable.decorator';
2
- export * from './controller.decorator';
3
- export * from './route.decorator';
4
- export * from './param.decorator';
5
- export * from './autowired.decorator';
6
- export * from './provider.decorator';
7
- export * from './config-property.decorator';
8
- export * from './create-param-decorator';
9
- export * from './apply-decorators';
1
+ export * from './injectable.decorator.js';
2
+ export * from './controller.decorator.js';
3
+ export * from './route.decorator.js';
4
+ export * from './param.decorator.js';
5
+ export * from './autowired.decorator.js';
6
+ export * from './provider.decorator.js';
7
+ export * from './config-property.decorator.js';
8
+ export * from './create-param-decorator.js';
9
+ export * from './apply-decorators.js';
@@ -1,25 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./injectable.decorator"), exports);
18
- __exportStar(require("./controller.decorator"), exports);
19
- __exportStar(require("./route.decorator"), exports);
20
- __exportStar(require("./param.decorator"), exports);
21
- __exportStar(require("./autowired.decorator"), exports);
22
- __exportStar(require("./provider.decorator"), exports);
23
- __exportStar(require("./config-property.decorator"), exports);
24
- __exportStar(require("./create-param-decorator"), exports);
25
- __exportStar(require("./apply-decorators"), exports);
1
+ export * from './injectable.decorator.js';
2
+ export * from './controller.decorator.js';
3
+ export * from './route.decorator.js';
4
+ export * from './param.decorator.js';
5
+ export * from './autowired.decorator.js';
6
+ export * from './provider.decorator.js';
7
+ export * from './config-property.decorator.js';
8
+ export * from './create-param-decorator.js';
9
+ export * from './apply-decorators.js';
@@ -1,3 +1,3 @@
1
1
  import 'reflect-metadata';
2
- import { InjectableOptions } from '../types';
2
+ import { InjectableOptions } from '../types.js';
3
3
  export declare function Injectable(options?: InjectableOptions): ClassDecorator;
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Injectable = Injectable;
4
- require("reflect-metadata");
5
- const constants_1 = require("../constants");
6
- const container_1 = require("../container/container");
7
- const registry_1 = require("../registry");
8
- function Injectable(options = {}) {
1
+ import 'reflect-metadata';
2
+ import { INJECTABLE_METADATA } from '../constants.js';
3
+ import { container } from '../container/container.js';
4
+ import { registry } from '../registry.js';
5
+ export function Injectable(options = {}) {
9
6
  return (target) => {
10
- Reflect.defineMetadata(constants_1.INJECTABLE_METADATA, options, target);
11
- container_1.container.register(target, options);
12
- registry_1.registry.registerProvider(target);
7
+ Reflect.defineMetadata(INJECTABLE_METADATA, options, target);
8
+ container.register(target, options);
9
+ registry.registerProvider(target);
13
10
  };
14
11
  }