@asenajs/ioc 0.0.0-stage → 0.1.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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -2
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/CircularDependencyDetector.d.ts +49 -0
  7. package/dist/lib/CircularDependencyDetector.js +69 -0
  8. package/dist/lib/CircularDependencyDetector.js.map +1 -0
  9. package/dist/lib/Container.d.ts +247 -0
  10. package/dist/lib/Container.js +563 -0
  11. package/dist/lib/Container.js.map +1 -0
  12. package/dist/lib/IocApplication.d.ts +88 -0
  13. package/dist/lib/IocApplication.js +110 -0
  14. package/dist/lib/IocApplication.js.map +1 -0
  15. package/dist/lib/IocEngine.d.ts +173 -0
  16. package/dist/lib/IocEngine.js +725 -0
  17. package/dist/lib/IocEngine.js.map +1 -0
  18. package/dist/lib/component/Scope.d.ts +4 -0
  19. package/dist/lib/component/Scope.js +6 -0
  20. package/dist/lib/component/Scope.js.map +1 -0
  21. package/dist/lib/component/componentRegistry.d.ts +34 -0
  22. package/dist/lib/component/componentRegistry.js +134 -0
  23. package/dist/lib/component/componentRegistry.js.map +1 -0
  24. package/dist/lib/component/componentUtils.d.ts +16 -0
  25. package/dist/lib/component/componentUtils.js +44 -0
  26. package/dist/lib/component/componentUtils.js.map +1 -0
  27. package/dist/lib/component/decorators/Component.d.ts +8 -0
  28. package/dist/lib/component/decorators/Component.js +12 -0
  29. package/dist/lib/component/decorators/Component.js.map +1 -0
  30. package/dist/lib/component/decorators/Implements.d.ts +7 -0
  31. package/dist/lib/component/decorators/Implements.js +14 -0
  32. package/dist/lib/component/decorators/Implements.js.map +1 -0
  33. package/dist/lib/component/decorators/Inject.d.ts +29 -0
  34. package/dist/lib/component/decorators/Inject.js +82 -0
  35. package/dist/lib/component/decorators/Inject.js.map +1 -0
  36. package/dist/lib/component/decorators/OnStart.d.ts +20 -0
  37. package/dist/lib/component/decorators/OnStart.js +33 -0
  38. package/dist/lib/component/decorators/OnStart.js.map +1 -0
  39. package/dist/lib/component/decorators/OnStop.d.ts +15 -0
  40. package/dist/lib/component/decorators/OnStop.js +28 -0
  41. package/dist/lib/component/decorators/OnStop.js.map +1 -0
  42. package/dist/lib/component/decorators/PostConstruct.d.ts +14 -0
  43. package/dist/lib/component/decorators/PostConstruct.js +16 -0
  44. package/dist/lib/component/decorators/PostConstruct.js.map +1 -0
  45. package/dist/lib/component/decorators/PostProcessor.d.ts +25 -0
  46. package/dist/lib/component/decorators/PostProcessor.js +29 -0
  47. package/dist/lib/component/decorators/PostProcessor.js.map +1 -0
  48. package/dist/lib/component/decorators/Service.d.ts +8 -0
  49. package/dist/lib/component/decorators/Service.js +12 -0
  50. package/dist/lib/component/decorators/Service.js.map +1 -0
  51. package/dist/lib/component/decorators/Strategy.d.ts +9 -0
  52. package/dist/lib/component/decorators/Strategy.js +29 -0
  53. package/dist/lib/component/decorators/Strategy.js.map +1 -0
  54. package/dist/lib/component/decorators/Value.d.ts +29 -0
  55. package/dist/lib/component/decorators/Value.js +41 -0
  56. package/dist/lib/component/decorators/Value.js.map +1 -0
  57. package/dist/lib/component/decorators/index.d.ts +11 -0
  58. package/dist/lib/component/decorators/index.js +12 -0
  59. package/dist/lib/component/decorators/index.js.map +1 -0
  60. package/dist/lib/component/decorators/legacyDecorator.d.ts +15 -0
  61. package/dist/lib/component/decorators/legacyDecorator.js +24 -0
  62. package/dist/lib/component/decorators/legacyDecorator.js.map +1 -0
  63. package/dist/lib/component/index.d.ts +3 -0
  64. package/dist/lib/component/index.js +4 -0
  65. package/dist/lib/component/index.js.map +1 -0
  66. package/dist/lib/constants/ComponentConstants.d.ts +21 -0
  67. package/dist/lib/constants/ComponentConstants.js +25 -0
  68. package/dist/lib/constants/ComponentConstants.js.map +1 -0
  69. package/dist/lib/constants/index.d.ts +1 -0
  70. package/dist/lib/constants/index.js +2 -0
  71. package/dist/lib/constants/index.js.map +1 -0
  72. package/dist/lib/decorators/CoreService.d.ts +11 -0
  73. package/dist/lib/decorators/CoreService.js +30 -0
  74. package/dist/lib/decorators/CoreService.js.map +1 -0
  75. package/dist/lib/decorators/index.d.ts +1 -0
  76. package/dist/lib/decorators/index.js +2 -0
  77. package/dist/lib/decorators/index.js.map +1 -0
  78. package/dist/lib/helper/fileHelper.d.ts +1 -0
  79. package/dist/lib/helper/fileHelper.js +29 -0
  80. package/dist/lib/helper/fileHelper.js.map +1 -0
  81. package/dist/lib/helper/iocHelper.d.ts +2 -0
  82. package/dist/lib/helper/iocHelper.js +12 -0
  83. package/dist/lib/helper/iocHelper.js.map +1 -0
  84. package/dist/lib/helper/valueResolver.d.ts +24 -0
  85. package/dist/lib/helper/valueResolver.js +37 -0
  86. package/dist/lib/helper/valueResolver.js.map +1 -0
  87. package/dist/lib/index.d.ts +12 -0
  88. package/dist/lib/index.js +13 -0
  89. package/dist/lib/index.js.map +1 -0
  90. package/dist/lib/lifecycle/LifecycleService.d.ts +78 -0
  91. package/dist/lib/lifecycle/LifecycleService.js +181 -0
  92. package/dist/lib/lifecycle/LifecycleService.js.map +1 -0
  93. package/dist/lib/lifecycle/LifecycleState.d.ts +20 -0
  94. package/dist/lib/lifecycle/LifecycleState.js +22 -0
  95. package/dist/lib/lifecycle/LifecycleState.js.map +1 -0
  96. package/dist/lib/lifecycle/index.d.ts +2 -0
  97. package/dist/lib/lifecycle/index.js +3 -0
  98. package/dist/lib/lifecycle/index.js.map +1 -0
  99. package/dist/lib/logger/IocLogger.d.ts +35 -0
  100. package/dist/lib/logger/IocLogger.js +2 -0
  101. package/dist/lib/logger/IocLogger.js.map +1 -0
  102. package/dist/lib/logger/index.d.ts +1 -0
  103. package/dist/lib/logger/index.js +2 -0
  104. package/dist/lib/logger/index.js.map +1 -0
  105. package/dist/lib/types/Class.d.ts +1 -0
  106. package/dist/lib/types/Class.js +2 -0
  107. package/dist/lib/types/Class.js.map +1 -0
  108. package/dist/lib/types/ComponentPostProcessor.d.ts +30 -0
  109. package/dist/lib/types/ComponentPostProcessor.js +2 -0
  110. package/dist/lib/types/ComponentPostProcessor.js.map +1 -0
  111. package/dist/lib/types/ContainerService.d.ts +6 -0
  112. package/dist/lib/types/ContainerService.js +2 -0
  113. package/dist/lib/types/ContainerService.js.map +1 -0
  114. package/dist/lib/types/ICoreService.d.ts +9 -0
  115. package/dist/lib/types/ICoreService.js +2 -0
  116. package/dist/lib/types/ICoreService.js.map +1 -0
  117. package/dist/lib/types/ICoreServiceNames.d.ts +10 -0
  118. package/dist/lib/types/ICoreServiceNames.js +12 -0
  119. package/dist/lib/types/ICoreServiceNames.js.map +1 -0
  120. package/dist/lib/types/InjectableComponent.d.ts +42 -0
  121. package/dist/lib/types/InjectableComponent.js +2 -0
  122. package/dist/lib/types/InjectableComponent.js.map +1 -0
  123. package/dist/lib/types/IocConfig.d.ts +11 -0
  124. package/dist/lib/types/IocConfig.js +2 -0
  125. package/dist/lib/types/IocConfig.js.map +1 -0
  126. package/dist/lib/types/LifecycleComponent.d.ts +29 -0
  127. package/dist/lib/types/LifecycleComponent.js +2 -0
  128. package/dist/lib/types/LifecycleComponent.js.map +1 -0
  129. package/dist/lib/types/decorators/ComponentParams.d.ts +5 -0
  130. package/dist/lib/types/decorators/ComponentParams.js +2 -0
  131. package/dist/lib/types/decorators/ComponentParams.js.map +1 -0
  132. package/dist/lib/types/decorators/ComponentType.d.ts +14 -0
  133. package/dist/lib/types/decorators/ComponentType.js +10 -0
  134. package/dist/lib/types/decorators/ComponentType.js.map +1 -0
  135. package/dist/lib/types/decorators/ServiceParams.d.ts +2 -0
  136. package/dist/lib/types/decorators/ServiceParams.js +2 -0
  137. package/dist/lib/types/decorators/ServiceParams.js.map +1 -0
  138. package/dist/lib/types/index.d.ts +11 -0
  139. package/dist/lib/types/index.js +12 -0
  140. package/dist/lib/types/index.js.map +1 -0
  141. package/dist/lib/utils/errorChain.d.ts +4 -0
  142. package/dist/lib/utils/errorChain.js +29 -0
  143. package/dist/lib/utils/errorChain.js.map +1 -0
  144. package/dist/lib/utils/typedMetadata.d.ts +54 -0
  145. package/dist/lib/utils/typedMetadata.js +97 -0
  146. package/dist/lib/utils/typedMetadata.js.map +1 -0
  147. package/package.json +73 -4
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The component kinds this package defines itself.
3
+ */
4
+ export var ComponentType;
5
+ (function (ComponentType) {
6
+ ComponentType["COMPONENT"] = "COMPONENT";
7
+ ComponentType["SERVICE"] = "SERVICE";
8
+ ComponentType["POST_PROCESSOR"] = "POST_PROCESSOR";
9
+ })(ComponentType || (ComponentType = {}));
10
+ //# sourceMappingURL=ComponentType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentType.js","sourceRoot":"","sources":["../../../../lib/types/decorators/ComponentType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;IACnB,kDAAiC,CAAA;AACnC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
@@ -0,0 +1,2 @@
1
+ import type { ComponentParams } from './ComponentParams';
2
+ export type ServiceParams = ComponentParams;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ServiceParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceParams.js","sourceRoot":"","sources":["../../../../lib/types/decorators/ServiceParams.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export * from './Class';
2
+ export * from './decorators/ComponentParams';
3
+ export * from './decorators/ComponentType';
4
+ export * from './decorators/ServiceParams';
5
+ export * from './IocConfig';
6
+ export * from './InjectableComponent';
7
+ export * from './ContainerService';
8
+ export * from './LifecycleComponent';
9
+ export * from './ICoreService';
10
+ export * from './ComponentPostProcessor';
11
+ export * from './ICoreServiceNames';
@@ -0,0 +1,12 @@
1
+ export * from './Class';
2
+ export * from './decorators/ComponentParams';
3
+ export * from './decorators/ComponentType';
4
+ export * from './decorators/ServiceParams';
5
+ export * from './IocConfig';
6
+ export * from './InjectableComponent';
7
+ export * from './ContainerService';
8
+ export * from './LifecycleComponent';
9
+ export * from './ICoreService';
10
+ export * from './ComponentPostProcessor';
11
+ export * from './ICoreServiceNames';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** `"@OnStart hook 'Db.open()' failed: connection refused"` - the message, then every cause's. */
2
+ export declare const describeErrorChain: (error: unknown) => string;
3
+ /** A stack trace never includes the cause; this is what to append to one. */
4
+ export declare const describeCauses: (error: unknown) => string;
@@ -0,0 +1,29 @@
1
+ const MAX_CAUSE_DEPTH = 10;
2
+ const describeValue = (value) => {
3
+ if (value instanceof Error)
4
+ return value.message;
5
+ if (typeof value === 'string')
6
+ return value;
7
+ return Bun.inspect(value, { compact: true });
8
+ };
9
+ /** `"@OnStart hook 'Db.open()' failed: connection refused"` - the message, then every cause's. */
10
+ export const describeErrorChain = (error) => {
11
+ const parts = [];
12
+ const seen = new Set();
13
+ let current = error;
14
+ while (parts.length < MAX_CAUSE_DEPTH && !seen.has(current)) {
15
+ seen.add(current);
16
+ parts.push(describeValue(current));
17
+ if (!(current instanceof Error) || current.cause === undefined)
18
+ break;
19
+ current = current.cause;
20
+ }
21
+ return parts.join(': ');
22
+ };
23
+ /** A stack trace never includes the cause; this is what to append to one. */
24
+ export const describeCauses = (error) => {
25
+ if (!(error instanceof Error) || error.cause === undefined || error.cause === error)
26
+ return '';
27
+ return `\nCaused by: ${describeErrorChain(error.cause)}`;
28
+ };
29
+ //# sourceMappingURL=errorChain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorChain.js","sourceRoot":"","sources":["../../../lib/utils/errorChain.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,aAAa,GAAG,CAAC,KAAc,EAAU,EAAE;IAC/C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAEjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAW,CAAC;IAChC,IAAI,OAAO,GAAY,KAAK,CAAC;IAE7B,OAAO,KAAK,CAAC,MAAM,GAAG,eAAe,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM;QAEtE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE;IACvD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAE/F,OAAO,gBAAgB,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAC3D,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ export declare const getTypedMetadata: <T>(key: string | symbol, target: any) => T | undefined;
2
+ export declare const getOwnTypedMetadata: <T>(key: string | symbol, target: any) => T | undefined;
3
+ /**
4
+ * Collects the prototype chain of `target`, most distant ancestor first.
5
+ *
6
+ * Accepts both shapes decorators store metadata on:
7
+ * - a **class constructor** (`class B extends A` -> `[A, B]`), which is where class decorators
8
+ * and every decorator in this package write (`target.constructor`);
9
+ * - a **prototype object** (`B.prototype` -> `[A.prototype, B.prototype]`), which is what a
10
+ * property or method decorator receives and may write to directly.
11
+ *
12
+ * Ancestors-first is the order every caller wants: merging in that order lets the nearest
13
+ * class override an inherited entry while keeping the rest.
14
+ *
15
+ * @param target - A class constructor, a prototype object, or anything else (yields `[]`)
16
+ * @returns The chain, ancestors first, excluding `Function.prototype` / `Object.prototype`
17
+ */
18
+ export declare const getPrototypeChainOf: (target: any) => any[];
19
+ /**
20
+ * Reads an array-shaped metadata key across the prototype chain and unions it.
21
+ *
22
+ * The list counterpart of {@link getChainedTypedMetadata}. Order is preserved
23
+ * ancestors-first and duplicates are removed by identity, so a subclass can only ever *add*
24
+ * to what it inherits. That direction matters when the list holds guards or suppressions:
25
+ * silently dropping an inherited one is never the safe answer.
26
+ *
27
+ * @param key - Metadata key holding an array
28
+ * @param target - A class constructor or a prototype object
29
+ * @returns The unioned array, `[]` when the chain carries none
30
+ */
31
+ export declare const getChainedTypedMetadataList: <T>(key: string | symbol, target: any) => T[];
32
+ /**
33
+ * Reads a record-shaped metadata key across the whole prototype chain and merges it.
34
+ *
35
+ * Method-level decorators write their metadata to the class where the *method is declared*
36
+ * (`target.constructor`), so a handler inherited from a base class lives on that base class.
37
+ * Neither of the other two readers gives the right answer for those:
38
+ * - `getOwnTypedMetadata` never sees the base class at all, so the handler is silently lost.
39
+ * - `getTypedMetadata` returns the *nearest* ancestor's record whole, so a single entry on
40
+ * the subclass shadows every inherited one.
41
+ *
42
+ * This walks from the most distant ancestor down to the class itself and merges per key, so
43
+ * a subclass overrides an inherited entry by method name and keeps the rest. That matches
44
+ * Spring (`MethodIntrospector.selectMethods` scans the hierarchy) and JAX-RS §3.6.
45
+ *
46
+ * The result is always a fresh object: merging in place would write the subclass's entries
47
+ * into the base class's stored record, leaking them into every sibling subclass.
48
+ *
49
+ * @param key - Metadata key holding a `{ [methodName]: value }` record
50
+ * @param target - A class constructor
51
+ * @returns The merged record, `{}` when the chain carries none
52
+ */
53
+ export declare const getChainedTypedMetadata: <T extends Record<string, any>>(key: string | symbol, target: any) => T;
54
+ export declare const defineTypedMetadata: <T>(key: string | symbol, value: T, target: any, sym?: string | symbol) => void;
@@ -0,0 +1,97 @@
1
+ import { defineMetadata, getMetadata, getOwnMetadata } from 'reflect-metadata/no-conflict';
2
+ export const getTypedMetadata = (key, target) => {
3
+ return getMetadata(key, target);
4
+ };
5
+ export const getOwnTypedMetadata = (key, target) => {
6
+ return getOwnMetadata(key, target);
7
+ };
8
+ /**
9
+ * Collects the prototype chain of `target`, most distant ancestor first.
10
+ *
11
+ * Accepts both shapes decorators store metadata on:
12
+ * - a **class constructor** (`class B extends A` -> `[A, B]`), which is where class decorators
13
+ * and every decorator in this package write (`target.constructor`);
14
+ * - a **prototype object** (`B.prototype` -> `[A.prototype, B.prototype]`), which is what a
15
+ * property or method decorator receives and may write to directly.
16
+ *
17
+ * Ancestors-first is the order every caller wants: merging in that order lets the nearest
18
+ * class override an inherited entry while keeping the rest.
19
+ *
20
+ * @param target - A class constructor, a prototype object, or anything else (yields `[]`)
21
+ * @returns The chain, ancestors first, excluding `Function.prototype` / `Object.prototype`
22
+ */
23
+ export const getPrototypeChainOf = (target) => {
24
+ if (target === null || target === undefined) {
25
+ return [];
26
+ }
27
+ const chain = [];
28
+ // A constructor chain terminates at Function.prototype, an object chain at Object.prototype
29
+ // or at null (`Object.create(null)`). Guarding on all three keeps one walker for both shapes.
30
+ for (let current = target; current !== null && current !== undefined && current !== Function.prototype && current !== Object.prototype;) {
31
+ chain.unshift(current);
32
+ current = Object.getPrototypeOf(current);
33
+ }
34
+ return chain;
35
+ };
36
+ /**
37
+ * Reads an array-shaped metadata key across the prototype chain and unions it.
38
+ *
39
+ * The list counterpart of {@link getChainedTypedMetadata}. Order is preserved
40
+ * ancestors-first and duplicates are removed by identity, so a subclass can only ever *add*
41
+ * to what it inherits. That direction matters when the list holds guards or suppressions:
42
+ * silently dropping an inherited one is never the safe answer.
43
+ *
44
+ * @param key - Metadata key holding an array
45
+ * @param target - A class constructor or a prototype object
46
+ * @returns The unioned array, `[]` when the chain carries none
47
+ */
48
+ export const getChainedTypedMetadataList = (key, target) => {
49
+ const merged = [];
50
+ for (const link of getPrototypeChainOf(target)) {
51
+ const own = getOwnMetadata(key, link);
52
+ if (!own)
53
+ continue;
54
+ for (const entry of own) {
55
+ if (!merged.includes(entry)) {
56
+ merged.push(entry);
57
+ }
58
+ }
59
+ }
60
+ return merged;
61
+ };
62
+ /**
63
+ * Reads a record-shaped metadata key across the whole prototype chain and merges it.
64
+ *
65
+ * Method-level decorators write their metadata to the class where the *method is declared*
66
+ * (`target.constructor`), so a handler inherited from a base class lives on that base class.
67
+ * Neither of the other two readers gives the right answer for those:
68
+ * - `getOwnTypedMetadata` never sees the base class at all, so the handler is silently lost.
69
+ * - `getTypedMetadata` returns the *nearest* ancestor's record whole, so a single entry on
70
+ * the subclass shadows every inherited one.
71
+ *
72
+ * This walks from the most distant ancestor down to the class itself and merges per key, so
73
+ * a subclass overrides an inherited entry by method name and keeps the rest. That matches
74
+ * Spring (`MethodIntrospector.selectMethods` scans the hierarchy) and JAX-RS §3.6.
75
+ *
76
+ * The result is always a fresh object: merging in place would write the subclass's entries
77
+ * into the base class's stored record, leaking them into every sibling subclass.
78
+ *
79
+ * @param key - Metadata key holding a `{ [methodName]: value }` record
80
+ * @param target - A class constructor
81
+ * @returns The merged record, `{}` when the chain carries none
82
+ */
83
+ export const getChainedTypedMetadata = (key, target) => {
84
+ const merged = {};
85
+ for (const link of getPrototypeChainOf(target)) {
86
+ Object.assign(merged, getOwnMetadata(key, link) || {});
87
+ }
88
+ return merged;
89
+ };
90
+ export const defineTypedMetadata = (key, value, target, sym) => {
91
+ if (sym === undefined) {
92
+ defineMetadata(key, value, target);
93
+ return;
94
+ }
95
+ defineMetadata(key, value, target, sym);
96
+ };
97
+ //# sourceMappingURL=typedMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedMetadata.js","sourceRoot":"","sources":["../../../lib/utils/typedMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAI,GAAoB,EAAE,MAAW,EAAiB,EAAE;IACtF,OAAO,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAI,GAAoB,EAAE,MAAW,EAAiB,EAAE;IACzF,OAAO,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAW,EAAS,EAAE;IACxD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAU,EAAE,CAAC;IAExB,4FAA4F;IAC5F,8FAA8F;IAC9F,KACE,IAAI,OAAO,GAAG,MAAM,EACpB,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS,GAC3G,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAI,GAAoB,EAAE,MAAW,EAAO,EAAE;IACvF,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,KAAK,MAAM,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,CAAoB,CAAC;QAEzD,IAAI,CAAC,GAAG;YAAE,SAAS;QAEnB,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAgC,GAAoB,EAAE,MAAW,EAAK,EAAE;IAC7G,MAAM,MAAM,GAAG,EAAyB,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAI,GAAoB,EAAE,KAAQ,EAAE,MAAW,EAAE,GAAqB,EAAQ,EAAE;IACjH,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@asenajs/ioc",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "author": "LibirSoft",
5
+ "description": "IoC container for Bun: decorator-declared components, field-based dependency injection and a start/stop lifecycle",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/AsenaJs/ioc.git"
9
+ },
10
+ "homepage": "https://github.com/AsenaJs/ioc#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/AsenaJs/ioc/issues"
13
+ },
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.js",
19
+ "types": "./dist/index.d.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "reflect-metadata": "^0.2.2"
32
+ },
33
+ "devDependencies": {
34
+ "@changesets/cli": "^2.31.1",
35
+ "@types/bun": "latest",
36
+ "@typescript-eslint/eslint-plugin": "^8.68.0",
37
+ "@typescript-eslint/parser": "^8.68.0",
38
+ "eslint": "^9.39.5",
39
+ "eslint-config-prettier": "^9.1.2",
40
+ "prettier": "^3.9.6",
41
+ "typescript": "^5.9.3",
42
+ "typescript-eslint": "^8.68.0"
43
+ },
44
+ "keywords": [
45
+ "ioc",
46
+ "dependency injection",
47
+ "decorators",
48
+ "bun",
49
+ "typescript",
50
+ "asena",
51
+ "asenajs"
52
+ ],
53
+ "license": "MIT",
54
+ "engines": {
55
+ "bun": ">=1.4.0"
56
+ },
57
+ "scripts": {
58
+ "test": "bun test",
59
+ "test:watch": "bun test --watch",
60
+ "test:coverage": "bun test --coverage",
61
+ "build": "bun run clean && tsc",
62
+ "typecheck": "tsc -p tsconfig.typecheck.json",
63
+ "clean": "rm -rf dist",
64
+ "prepublishOnly": "bun run build",
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix",
67
+ "format": "prettier --write .",
68
+ "format:check": "prettier --check .",
69
+ "check": "bun run lint && bun run format:check",
70
+ "check:fix": "bun run lint:fix && bun run format",
71
+ "changeset": "changeset",
72
+ "version": "changeset version",
73
+ "release": "bun run build && changeset publish"
74
+ }
75
+ }