@venizia/ignis-inversion 0.4.3 → 0.4.4

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 (153) hide show
  1. package/LICENSE.md +2 -5
  2. package/README.md +18 -6
  3. package/dist/esm/modules/container/base.d.ts.map +1 -1
  4. package/dist/esm/modules/container/base.js +3 -1
  5. package/dist/esm/modules/container/base.js.map +1 -1
  6. package/dist/esm/modules/container/container.d.ts.map +1 -1
  7. package/dist/esm/modules/container/container.js +1 -0
  8. package/dist/esm/modules/container/container.js.map +1 -1
  9. package/dist/esm/modules/container/index.d.ts +1 -0
  10. package/dist/esm/modules/container/index.d.ts.map +1 -1
  11. package/dist/esm/modules/container/index.js +1 -0
  12. package/dist/esm/modules/container/index.js.map +1 -1
  13. package/dist/esm/modules/container/verifier.d.ts +47 -0
  14. package/dist/esm/modules/container/verifier.d.ts.map +1 -0
  15. package/dist/esm/modules/container/verifier.js +115 -0
  16. package/dist/esm/modules/container/verifier.js.map +1 -0
  17. package/package.json +7 -15
  18. package/dist/cjs/common/base-helper.d.ts +0 -9
  19. package/dist/cjs/common/base-helper.d.ts.map +0 -1
  20. package/dist/cjs/common/base-helper.js +0 -11
  21. package/dist/cjs/common/base-helper.js.map +0 -1
  22. package/dist/cjs/common/index.d.ts +0 -5
  23. package/dist/cjs/common/index.d.ts.map +0 -1
  24. package/dist/cjs/common/index.js +0 -21
  25. package/dist/cjs/common/index.js.map +0 -1
  26. package/dist/cjs/common/logger.d.ts +0 -11
  27. package/dist/cjs/common/logger.d.ts.map +0 -1
  28. package/dist/cjs/common/logger.js +0 -26
  29. package/dist/cjs/common/logger.js.map +0 -1
  30. package/dist/cjs/common/types.d.ts +0 -22
  31. package/dist/cjs/common/types.d.ts.map +0 -1
  32. package/dist/cjs/common/types.js +0 -3
  33. package/dist/cjs/common/types.js.map +0 -1
  34. package/dist/cjs/common/utilities.d.ts +0 -38
  35. package/dist/cjs/common/utilities.d.ts.map +0 -1
  36. package/dist/cjs/common/utilities.js +0 -83
  37. package/dist/cjs/common/utilities.js.map +0 -1
  38. package/dist/cjs/index.d.ts +0 -4
  39. package/dist/cjs/index.d.ts.map +0 -1
  40. package/dist/cjs/index.js +0 -26
  41. package/dist/cjs/index.js.map +0 -1
  42. package/dist/cjs/modules/binding/binding.d.ts +0 -37
  43. package/dist/cjs/modules/binding/binding.d.ts.map +0 -1
  44. package/dist/cjs/modules/binding/binding.js +0 -120
  45. package/dist/cjs/modules/binding/binding.js.map +0 -1
  46. package/dist/cjs/modules/binding/common/constants.d.ts +0 -19
  47. package/dist/cjs/modules/binding/common/constants.d.ts.map +0 -1
  48. package/dist/cjs/modules/binding/common/constants.js +0 -33
  49. package/dist/cjs/modules/binding/common/constants.js.map +0 -1
  50. package/dist/cjs/modules/binding/common/index.d.ts +0 -3
  51. package/dist/cjs/modules/binding/common/index.d.ts.map +0 -1
  52. package/dist/cjs/modules/binding/common/index.js +0 -19
  53. package/dist/cjs/modules/binding/common/index.js.map +0 -1
  54. package/dist/cjs/modules/binding/common/types.d.ts +0 -28
  55. package/dist/cjs/modules/binding/common/types.d.ts.map +0 -1
  56. package/dist/cjs/modules/binding/common/types.js +0 -8
  57. package/dist/cjs/modules/binding/common/types.js.map +0 -1
  58. package/dist/cjs/modules/binding/index.d.ts +0 -3
  59. package/dist/cjs/modules/binding/index.d.ts.map +0 -1
  60. package/dist/cjs/modules/binding/index.js +0 -19
  61. package/dist/cjs/modules/binding/index.js.map +0 -1
  62. package/dist/cjs/modules/container/abstract.d.ts +0 -69
  63. package/dist/cjs/modules/container/abstract.d.ts.map +0 -1
  64. package/dist/cjs/modules/container/abstract.js +0 -12
  65. package/dist/cjs/modules/container/abstract.js.map +0 -1
  66. package/dist/cjs/modules/container/base.d.ts +0 -101
  67. package/dist/cjs/modules/container/base.d.ts.map +0 -1
  68. package/dist/cjs/modules/container/base.js +0 -193
  69. package/dist/cjs/modules/container/base.js.map +0 -1
  70. package/dist/cjs/modules/container/common/index.d.ts +0 -2
  71. package/dist/cjs/modules/container/common/index.d.ts.map +0 -1
  72. package/dist/cjs/modules/container/common/index.js +0 -18
  73. package/dist/cjs/modules/container/common/index.js.map +0 -1
  74. package/dist/cjs/modules/container/common/types.d.ts +0 -60
  75. package/dist/cjs/modules/container/common/types.d.ts.map +0 -1
  76. package/dist/cjs/modules/container/common/types.js +0 -3
  77. package/dist/cjs/modules/container/common/types.js.map +0 -1
  78. package/dist/cjs/modules/container/container.d.ts +0 -24
  79. package/dist/cjs/modules/container/container.d.ts.map +0 -1
  80. package/dist/cjs/modules/container/container.js +0 -100
  81. package/dist/cjs/modules/container/container.js.map +0 -1
  82. package/dist/cjs/modules/container/index.d.ts +0 -5
  83. package/dist/cjs/modules/container/index.d.ts.map +0 -1
  84. package/dist/cjs/modules/container/index.js +0 -21
  85. package/dist/cjs/modules/container/index.js.map +0 -1
  86. package/dist/cjs/modules/error/app-error.d.ts +0 -32
  87. package/dist/cjs/modules/error/app-error.d.ts.map +0 -1
  88. package/dist/cjs/modules/error/app-error.js +0 -102
  89. package/dist/cjs/modules/error/app-error.js.map +0 -1
  90. package/dist/cjs/modules/error/common/constants.d.ts +0 -14
  91. package/dist/cjs/modules/error/common/constants.d.ts.map +0 -1
  92. package/dist/cjs/modules/error/common/constants.js +0 -23
  93. package/dist/cjs/modules/error/common/constants.js.map +0 -1
  94. package/dist/cjs/modules/error/common/index.d.ts +0 -3
  95. package/dist/cjs/modules/error/common/index.d.ts.map +0 -1
  96. package/dist/cjs/modules/error/common/index.js +0 -19
  97. package/dist/cjs/modules/error/common/index.js.map +0 -1
  98. package/dist/cjs/modules/error/common/types.d.ts +0 -75
  99. package/dist/cjs/modules/error/common/types.d.ts.map +0 -1
  100. package/dist/cjs/modules/error/common/types.js +0 -3
  101. package/dist/cjs/modules/error/common/types.js.map +0 -1
  102. package/dist/cjs/modules/error/definition.d.ts +0 -10
  103. package/dist/cjs/modules/error/definition.d.ts.map +0 -1
  104. package/dist/cjs/modules/error/definition.js +0 -12
  105. package/dist/cjs/modules/error/definition.js.map +0 -1
  106. package/dist/cjs/modules/error/index.d.ts +0 -6
  107. package/dist/cjs/modules/error/index.d.ts.map +0 -1
  108. package/dist/cjs/modules/error/index.js +0 -22
  109. package/dist/cjs/modules/error/index.js.map +0 -1
  110. package/dist/cjs/modules/error/message-code.d.ts +0 -28
  111. package/dist/cjs/modules/error/message-code.d.ts.map +0 -1
  112. package/dist/cjs/modules/error/message-code.js +0 -57
  113. package/dist/cjs/modules/error/message-code.js.map +0 -1
  114. package/dist/cjs/modules/error/message-template.d.ts +0 -19
  115. package/dist/cjs/modules/error/message-template.d.ts.map +0 -1
  116. package/dist/cjs/modules/error/message-template.js +0 -38
  117. package/dist/cjs/modules/error/message-template.js.map +0 -1
  118. package/dist/cjs/modules/index.d.ts +0 -6
  119. package/dist/cjs/modules/index.d.ts.map +0 -1
  120. package/dist/cjs/modules/index.js +0 -22
  121. package/dist/cjs/modules/index.js.map +0 -1
  122. package/dist/cjs/modules/metadata/common/constants.d.ts +0 -6
  123. package/dist/cjs/modules/metadata/common/constants.d.ts.map +0 -1
  124. package/dist/cjs/modules/metadata/common/constants.js +0 -9
  125. package/dist/cjs/modules/metadata/common/constants.js.map +0 -1
  126. package/dist/cjs/modules/metadata/common/index.d.ts +0 -2
  127. package/dist/cjs/modules/metadata/common/index.d.ts.map +0 -1
  128. package/dist/cjs/modules/metadata/common/index.js +0 -18
  129. package/dist/cjs/modules/metadata/common/index.js.map +0 -1
  130. package/dist/cjs/modules/metadata/index.d.ts +0 -3
  131. package/dist/cjs/modules/metadata/index.d.ts.map +0 -1
  132. package/dist/cjs/modules/metadata/index.js +0 -19
  133. package/dist/cjs/modules/metadata/index.js.map +0 -1
  134. package/dist/cjs/modules/metadata/injectors.d.ts +0 -16
  135. package/dist/cjs/modules/metadata/injectors.d.ts.map +0 -1
  136. package/dist/cjs/modules/metadata/injectors.js +0 -47
  137. package/dist/cjs/modules/metadata/injectors.js.map +0 -1
  138. package/dist/cjs/modules/registry/common/index.d.ts +0 -2
  139. package/dist/cjs/modules/registry/common/index.d.ts.map +0 -1
  140. package/dist/cjs/modules/registry/common/index.js +0 -18
  141. package/dist/cjs/modules/registry/common/index.js.map +0 -1
  142. package/dist/cjs/modules/registry/common/types.d.ts +0 -20
  143. package/dist/cjs/modules/registry/common/types.d.ts.map +0 -1
  144. package/dist/cjs/modules/registry/common/types.js +0 -3
  145. package/dist/cjs/modules/registry/common/types.js.map +0 -1
  146. package/dist/cjs/modules/registry/index.d.ts +0 -3
  147. package/dist/cjs/modules/registry/index.d.ts.map +0 -1
  148. package/dist/cjs/modules/registry/index.js +0 -19
  149. package/dist/cjs/modules/registry/index.js.map +0 -1
  150. package/dist/cjs/modules/registry/registry.d.ts +0 -66
  151. package/dist/cjs/modules/registry/registry.d.ts.map +0 -1
  152. package/dist/cjs/modules/registry/registry.js +0 -98
  153. package/dist/cjs/modules/registry/registry.js.map +0 -1
package/LICENSE.md CHANGED
@@ -4,7 +4,7 @@ Ignis is a TypeScript Server Infrastructure framework built on [Hono](https://ho
4
4
 
5
5
  ## MIT License
6
6
 
7
- Copyright (c) 2025 VENIZIA Ltd. Co.
7
+ Copyright (c) 2025 Venizia Co., Ltd.
8
8
 
9
9
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
10
  of this software and associated documentation files (the "Software"), to deal
@@ -86,12 +86,9 @@ Ignis uses the following open-source libraries. We are grateful to the authors a
86
86
 
87
87
  ## Acknowledgments
88
88
 
89
- Ignis Framework is inspired by and built upon the work of many open-source projects:
89
+ Ignis Framework is built on the work of open-source projects:
90
90
 
91
91
  - **[Hono](https://hono.dev/)** by Yusuke Wada - The ultrafast web framework that powers Ignis
92
- - **[LoopBack 4](https://loopback.io/)** by IBM/StrongLoop - Inspiration for the enterprise architecture patterns
93
- - **[NestJS](https://nestjs.com/)** by Kamil Mysliwiec - Inspiration for decorator-based controllers
94
- - **[InversifyJS](https://inversify.io/)** - Inspiration for the IoC container design
95
92
 
96
93
  We thank all the maintainers and contributors of these projects for their excellent work.
97
94
 
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @venizia/ignis-inversion
2
2
 
3
3
  The dependency injection container under IGNIS, and the error type every IGNIS package throws. It
4
- depends on no other IGNIS package, so you can install it alone to get LoopBack 4-style bindings
5
- without the framework.
4
+ depends on no other IGNIS package, so you can install it alone to get bindings by key, tags and
5
+ scopes without the framework.
6
6
 
7
7
  ## Install
8
8
 
@@ -122,8 +122,8 @@ try {
122
122
  becomes `text`. A missing code becomes `MessageCode.DEFAULT` (`core.system_error`). Unknown
123
123
  top-level keys go into `extra`.
124
124
 
125
- Test with `isApplicationError(error)`, not `instanceof ApplicationError`. A CommonJS copy and an
126
- ES module copy of the package can both be loaded, and `instanceof` fails across them.
125
+ Test with `isApplicationError(error)`, not `instanceof ApplicationError`. Two installed copies of the
126
+ package (two versions nested by a package manager) each hold their own class, and `instanceof` fails across them.
127
127
 
128
128
  ## Entry points
129
129
 
@@ -131,8 +131,7 @@ ES module copy of the package can both be loaded, and `instanceof` fails across
131
131
  | :--- | :--- | :--- |
132
132
  | `@venizia/ignis-inversion` | Everything: container, bindings, `@inject`, `MetadataRegistry`, errors | none |
133
133
 
134
- The package ships both CommonJS (`dist/cjs`) and ES modules (`dist/esm`). `import` resolves the ES
135
- build, `require` the CommonJS one. The ES build is what a browser bundle takes.
134
+ The package ships ES modules only (`dist/esm`). That build is what a browser bundle takes.
136
135
 
137
136
  ## Where it sits
138
137
 
@@ -148,3 +147,16 @@ Depends on nothing in IGNIS. Used by filter, helpers and kernel: dev-configs ->
148
147
  - [Source](https://github.com/VENIZIA-AI/ignis/blob/main/packages/inversion)
149
148
 
150
149
  MIT licensed - see [LICENSE.md](./LICENSE.md).
150
+
151
+ ---
152
+
153
+ <p align="center">
154
+ <a href="https://venizia.ai">
155
+ <picture>
156
+ <source media="(prefers-color-scheme: dark)" srcset="https://venizia.ai/assets/logo-white.svg">
157
+ <img src="https://venizia.ai/assets/logo.svg" alt="VENIZIA" height="28">
158
+ </picture>
159
+ </a>
160
+ <br>
161
+ <sub>@venizia/ignis-inversion is part of IGNIS, built and maintained by <a href="https://venizia.ai">VENIZIA</a>.</sub>
162
+ </p>
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAK/C,kKAAkK;AAClK,8BAAsB,aAAc,SAAQ,iBAAiB;IAC3D,SAAS,CAAC,QAAQ,4BAA8B;IAEhD,2EAA2E;IAC3E,SAAS,CAAC,gBAAgB,sBAA6B;IAEvD,mJAAmJ;IACnJ,SAAS,CAAC,qBAAqB,UAAS;IAExC,2JAA2J;IAC3J,SAAS,CAAC,4BAA4B,UAAS;IAE/C,oHAAoH;IACpH,SAAS,CAAC,UAAU,sBAA6B;IAEjD,kGAAkG;IAClG,SAAS,CAAC,uBAAuB,sBAA6B;IAE9D;;;;OAIG;IACH,SAAS,CAAC,eAAe,SAAK;IAC9B,SAAS,CAAC,aAAa,cAAqB;gBAEhC,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAI3B,mBAAmB;IAI5B;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE;QAC1B,GAAG,EAAE,WAAW,GAAG;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;KACvD,GAAG,MAAM,GAAG,SAAS;IAqBtB,2GAA2G;IAC3G,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAiB7C,IAAI,CAAC,CA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,CAAC,EAAE,IAAI,EAAE;QACpB,GAAG,EAAE,WAAW,GAAG;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QACtD,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,GAAG,CAAC,GAAG,SAAS;IAwDR,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE;QACvC,QAAQ,EAAE;aACP,CAAC,IAAI,MAAM,CAAC,GAAG;gBACd,GAAG,EAAE,WAAW,GAAG;oBAAE,SAAS,EAAE,MAAM,CAAC;oBAAC,GAAG,EAAE,MAAM,CAAA;iBAAE,CAAC;gBACtD,UAAU,CAAC,EAAE,OAAO,CAAC;aACtB;SACF,CAAC;KACH,GAAG;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;KAAE;IAMxC,gMAAgM;IACvL,uBAAuB,IAAI,IAAI;IAMxC,yFAAyF;IAChF,sBAAsB,IAAI,IAAI;IAIvC,4IAA4I;IACnI,mBAAmB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAIlD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;IAI7B,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAChC,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;KACvC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE;IAyBP,KAAK,IAAI,IAAI;IAOb,KAAK,IAAI,IAAI;CAKvB"}
@@ -130,8 +130,10 @@ export class BaseContainer extends AbstractContainer {
130
130
  }
131
131
  }
132
132
  if (!isOptional) {
133
+ const printed = typeof key === 'object' ? BindingKeys.build(key) : String(key);
133
134
  throw getError({
134
- message: `Binding key: ${typeof key === 'object' ? BindingKeys.build(key) : String(key)} is not bounded in context!`,
135
+ message: `Binding key: ${printed} is not bounded in context!`,
136
+ extra: { unboundKey: printed },
135
137
  });
136
138
  }
137
139
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/modules/container/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,wGAAwG;AACxG,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,kKAAkK;AAClK,MAAM,OAAgB,aAAc,SAAQ,iBAAiB;IA0B3D,YAAY,IAAwB;QAClC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;QA1B5C,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QAEhD,2EAA2E;QACjE,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEvD,mJAAmJ;QACzI,0BAAqB,GAAG,KAAK,CAAC;QAExC,2JAA2J;QACjJ,iCAA4B,GAAG,KAAK,CAAC;QAE/C,oHAAoH;QAC1G,eAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEjD,kGAAkG;QACxF,4BAAuB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE9D;;;;WAIG;QACO,oBAAe,GAAG,CAAC,CAAC;QACpB,kBAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAI5C,CAAC;IAEQ,mBAAmB;QAC1B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACO,WAAW,CAAC,IAErB;QACC,MAAM,EAAE,GAAG,EAA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,CAAC;CACF","sourcesContent":["import { type TBindingKey, type TClass, type TNullable } from '@/common/types';\nimport { Binding } from '../binding/binding';\nimport { BindingKeys } from '../binding/common/constants';\nimport { getError } from '../error';\nimport { metadataRegistry } from '../registry/registry';\nimport { AbstractContainer } from './abstract';\n\n/** A dependency graph nests far less than this; deeper is all but certainly a cycle, and is checked. */\nconst CYCLE_CHECK_DEPTH = 64;\n\n/** Storage half of the container, keyed by normalized binding-key strings - resolution (`instantiate`) stays abstract, it is the part an implementation swaps. */\nexport abstract class BaseContainer extends AbstractContainer {\n protected bindings = new Map<string, Binding>();\n\n /** How often each bound key has been handed out since counting started. */\n protected resolutionCounts = new Map<string, number>();\n\n /** Off by default: the counter sits on the hottest path in the container, and an application that never reads the report should not pay for it. */\n protected isCountingResolutions = false;\n\n /** Whether `startResolutionCounting` has ever run. A report read without it would name every binding, which is a wrong answer rather than an empty one. */\n protected hasStartedResolutionCounting = false;\n\n /** The string each BOUND symbol is stored under: `Symbol('x')` twice is two keys, and both print as \"Symbol(x)\". */\n protected symbolKeys = new Map<symbol, string>();\n\n /** How many symbols have been bound per description, so a new one gets its suffix in one step. */\n protected symbolDescriptionCounts = new Map<string, number>();\n\n /**\n * Nesting depth of the reads in progress. Past {@link CYCLE_CHECK_DEPTH} the keys are tracked, and\n * a key met again is a cycle: a real graph is far shallower, so the common read pays one counter.\n * Only the synchronous part is checked - a cycle through an `await` is not seen.\n */\n protected resolutionDepth = 0;\n protected resolvingKeys = new Set<string>();\n\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? BaseContainer.name });\n }\n\n override getMetadataRegistry() {\n return metadataRegistry;\n }\n\n /**\n * The string a key is stored under, or `undefined` for a symbol that was never bound - a lookup\n * never records one, so reading with throwaway symbols leaves nothing behind.\n */\n protected toKeyString(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): string | undefined {\n const { key } = opts;\n\n switch (typeof key) {\n case 'string': {\n return key;\n }\n case 'symbol': {\n return this.symbolKeys.get(key);\n }\n case 'object': {\n return BindingKeys.build(key);\n }\n default: {\n throw getError({\n message: `[getBinding] Invalid binding key type | opts: ${String(key)} | allowed: [string, symbol, { namespace: string, key: string }]`,\n });\n }\n }\n }\n\n /** A bound symbol's own string: its description, suffixed (`Symbol(x)#2`) when another symbol holds it. */\n protected bindSymbolKey(opts: { key: symbol }): string {\n const { key } = opts;\n\n const known = this.symbolKeys.get(key);\n if (known !== undefined) {\n return known;\n }\n\n const description = key.toString();\n const count = (this.symbolDescriptionCounts.get(description) ?? 0) + 1;\n this.symbolDescriptionCounts.set(description, count);\n\n const keyStr = count === 1 ? description : `${description}#${count}`;\n this.symbolKeys.set(key, keyStr);\n return keyStr;\n }\n\n override bind<T>(opts: { key: TBindingKey }): Binding<T> {\n const { key } = opts;\n const keyStr = typeof key === 'symbol' ? this.bindSymbolKey({ key }) : key;\n const binding = new Binding<T>({ key: keyStr });\n this.bindings.set(keyStr, binding as Binding);\n return binding;\n }\n\n override isBound(opts: { key: TBindingKey }): boolean {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr !== undefined && this.bindings.has(keyStr);\n }\n\n override getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<Binding<T>> {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr === undefined ? undefined : this.bindings.get(keyStr);\n }\n\n override unbind(opts: { key: TBindingKey }): boolean {\n const { key } = opts;\n const keyStr = this.toKeyString({ key });\n\n if (typeof key === 'symbol') {\n this.symbolKeys.delete(key);\n }\n\n return keyStr !== undefined && this.bindings.delete(keyStr);\n }\n\n override set<T>(opts: { binding: Binding<T> }): void {\n const { binding } = opts;\n this.bindings.set(binding.key, binding);\n }\n\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: false;\n }): T;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined {\n const { key, isOptional = false } = opts;\n\n const binding = this.getBinding<T>({ key });\n if (binding) {\n // Counted here and nowhere else: constructor injection, property injection, `application.get`\n // and `verifyBindings` all arrive through this one method. A miss below is not a resolution.\n if (this.isCountingResolutions) {\n this.resolutionCounts.set(binding.key, (this.resolutionCounts.get(binding.key) ?? 0) + 1);\n }\n\n // The hot path: a cached singleton or a value builds nothing, so it cannot be part of a cycle.\n if (binding.isSettled()) {\n return binding.getValue(this);\n }\n\n this.resolutionDepth++;\n const isTracked = this.resolutionDepth > CYCLE_CHECK_DEPTH;\n\n if (isTracked && this.resolvingKeys.has(binding.key)) {\n this.resolutionDepth--;\n throw getError({\n message: `Circular dependency | ${[...this.resolvingKeys, binding.key].join(' -> ')}`,\n });\n }\n\n if (isTracked) {\n this.resolvingKeys.add(binding.key);\n }\n\n try {\n return binding.getValue(this);\n } finally {\n this.resolutionDepth--;\n if (isTracked) {\n this.resolvingKeys.delete(binding.key);\n }\n }\n }\n\n if (!isOptional) {\n throw getError({\n message: `Binding key: ${typeof key === 'object' ? BindingKeys.build(key) : String(key)} is not bounded in context!`,\n });\n }\n\n return undefined;\n }\n\n override gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined } {\n return opts.bindings.map((opt) => this.get({ ...opt, isOptional: true })) as {\n [K in keyof T]: T[K] | undefined;\n };\n }\n\n /** Clears the counts and starts counting. Call it AFTER `initialize()`: boot resolves plenty no request ever asks for, and `bootChecks.binding.doVerify` reads every service and repository. */\n override startResolutionCounting(): void {\n this.resolutionCounts.clear();\n this.isCountingResolutions = true;\n this.hasStartedResolutionCounting = true;\n }\n\n /** Stops counting and keeps what was counted, so `get` returns to its uncounted cost. */\n override stopResolutionCounting(): void {\n this.isCountingResolutions = false;\n }\n\n /** How many times each bound key has been read since counting started. A key that was bound and never read is absent. The map is a copy. */\n override getResolutionCounts(): ReadonlyMap<string, number> {\n return new Map(this.resolutionCounts);\n }\n\n override resolve<T>(cls: TClass<T>): T {\n return this.instantiate(cls);\n }\n\n override findByTag<T = any>(opts: {\n tag: string;\n exclude?: Array<string> | Set<string>;\n }): Binding<T>[] {\n const { tag, exclude } = opts;\n\n const rs: Binding<T>[] = [];\n\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n if (!binding.hasTag(tag)) {\n continue;\n }\n\n if (exclude instanceof Array && exclude.length > 0 && exclude.includes(binding.key)) {\n continue;\n }\n\n if (exclude instanceof Set && exclude.size > 0 && exclude.has(binding.key)) {\n continue;\n }\n\n rs.push(binding);\n }\n\n return rs;\n }\n\n override clear(): void {\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n binding.clearCache();\n }\n }\n\n override reset(): void {\n this.bindings.clear();\n this.symbolKeys.clear();\n this.symbolDescriptionCounts.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/modules/container/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,wGAAwG;AACxG,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,kKAAkK;AAClK,MAAM,OAAgB,aAAc,SAAQ,iBAAiB;IA0B3D,YAAY,IAAwB;QAClC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;QA1B5C,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QAEhD,2EAA2E;QACjE,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEvD,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AAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3E,SAAS;YACX,CAAC;YAED,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEQ,KAAK;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IAEQ,KAAK;QACZ,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { type TBindingKey, type TClass, type TNullable } from '@/common/types';\nimport { Binding } from '../binding/binding';\nimport { BindingKeys } from '../binding/common/constants';\nimport { getError } from '../error';\nimport { metadataRegistry } from '../registry/registry';\nimport { AbstractContainer } from './abstract';\n\n/** A dependency graph nests far less than this; deeper is all but certainly a cycle, and is checked. */\nconst CYCLE_CHECK_DEPTH = 64;\n\n/** Storage half of the container, keyed by normalized binding-key strings - resolution (`instantiate`) stays abstract, it is the part an implementation swaps. */\nexport abstract class BaseContainer extends AbstractContainer {\n protected bindings = new Map<string, Binding>();\n\n /** How often each bound key has been handed out since counting started. */\n protected resolutionCounts = new Map<string, number>();\n\n /** Off by default: the counter sits on the hottest path in the container, and an application that never reads the report should not pay for it. */\n protected isCountingResolutions = false;\n\n /** Whether `startResolutionCounting` has ever run. A report read without it would name every binding, which is a wrong answer rather than an empty one. */\n protected hasStartedResolutionCounting = false;\n\n /** The string each BOUND symbol is stored under: `Symbol('x')` twice is two keys, and both print as \"Symbol(x)\". */\n protected symbolKeys = new Map<symbol, string>();\n\n /** How many symbols have been bound per description, so a new one gets its suffix in one step. */\n protected symbolDescriptionCounts = new Map<string, number>();\n\n /**\n * Nesting depth of the reads in progress. Past {@link CYCLE_CHECK_DEPTH} the keys are tracked, and\n * a key met again is a cycle: a real graph is far shallower, so the common read pays one counter.\n * Only the synchronous part is checked - a cycle through an `await` is not seen.\n */\n protected resolutionDepth = 0;\n protected resolvingKeys = new Set<string>();\n\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? BaseContainer.name });\n }\n\n override getMetadataRegistry() {\n return metadataRegistry;\n }\n\n /**\n * The string a key is stored under, or `undefined` for a symbol that was never bound - a lookup\n * never records one, so reading with throwaway symbols leaves nothing behind.\n */\n protected toKeyString(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): string | undefined {\n const { key } = opts;\n\n switch (typeof key) {\n case 'string': {\n return key;\n }\n case 'symbol': {\n return this.symbolKeys.get(key);\n }\n case 'object': {\n return BindingKeys.build(key);\n }\n default: {\n throw getError({\n message: `[getBinding] Invalid binding key type | opts: ${String(key)} | allowed: [string, symbol, { namespace: string, key: string }]`,\n });\n }\n }\n }\n\n /** A bound symbol's own string: its description, suffixed (`Symbol(x)#2`) when another symbol holds it. */\n protected bindSymbolKey(opts: { key: symbol }): string {\n const { key } = opts;\n\n const known = this.symbolKeys.get(key);\n if (known !== undefined) {\n return known;\n }\n\n const description = key.toString();\n const count = (this.symbolDescriptionCounts.get(description) ?? 0) + 1;\n this.symbolDescriptionCounts.set(description, count);\n\n const keyStr = count === 1 ? description : `${description}#${count}`;\n this.symbolKeys.set(key, keyStr);\n return keyStr;\n }\n\n override bind<T>(opts: { key: TBindingKey }): Binding<T> {\n const { key } = opts;\n const keyStr = typeof key === 'symbol' ? this.bindSymbolKey({ key }) : key;\n const binding = new Binding<T>({ key: keyStr });\n this.bindings.set(keyStr, binding as Binding);\n return binding;\n }\n\n override isBound(opts: { key: TBindingKey }): boolean {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr !== undefined && this.bindings.has(keyStr);\n }\n\n override getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<Binding<T>> {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr === undefined ? undefined : this.bindings.get(keyStr);\n }\n\n override unbind(opts: { key: TBindingKey }): boolean {\n const { key } = opts;\n const keyStr = this.toKeyString({ key });\n\n if (typeof key === 'symbol') {\n this.symbolKeys.delete(key);\n }\n\n return keyStr !== undefined && this.bindings.delete(keyStr);\n }\n\n override set<T>(opts: { binding: Binding<T> }): void {\n const { binding } = opts;\n this.bindings.set(binding.key, binding);\n }\n\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: false;\n }): T;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined {\n const { key, isOptional = false } = opts;\n\n const binding = this.getBinding<T>({ key });\n if (binding) {\n // Counted here and nowhere else: constructor injection, property injection, `application.get`\n // and `verifyBindings` all arrive through this one method. A miss below is not a resolution.\n if (this.isCountingResolutions) {\n this.resolutionCounts.set(binding.key, (this.resolutionCounts.get(binding.key) ?? 0) + 1);\n }\n\n // The hot path: a cached singleton or a value builds nothing, so it cannot be part of a cycle.\n if (binding.isSettled()) {\n return binding.getValue(this);\n }\n\n this.resolutionDepth++;\n const isTracked = this.resolutionDepth > CYCLE_CHECK_DEPTH;\n\n if (isTracked && this.resolvingKeys.has(binding.key)) {\n this.resolutionDepth--;\n throw getError({\n message: `Circular dependency | ${[...this.resolvingKeys, binding.key].join(' -> ')}`,\n });\n }\n\n if (isTracked) {\n this.resolvingKeys.add(binding.key);\n }\n\n try {\n return binding.getValue(this);\n } finally {\n this.resolutionDepth--;\n if (isTracked) {\n this.resolvingKeys.delete(binding.key);\n }\n }\n }\n\n if (!isOptional) {\n const printed = typeof key === 'object' ? BindingKeys.build(key) : String(key);\n\n throw getError({\n message: `Binding key: ${printed} is not bounded in context!`,\n extra: { unboundKey: printed },\n });\n }\n\n return undefined;\n }\n\n override gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined } {\n return opts.bindings.map((opt) => this.get({ ...opt, isOptional: true })) as {\n [K in keyof T]: T[K] | undefined;\n };\n }\n\n /** Clears the counts and starts counting. Call it AFTER `initialize()`: boot resolves plenty no request ever asks for, and `bootChecks.binding.doVerify` reads every service and repository. */\n override startResolutionCounting(): void {\n this.resolutionCounts.clear();\n this.isCountingResolutions = true;\n this.hasStartedResolutionCounting = true;\n }\n\n /** Stops counting and keeps what was counted, so `get` returns to its uncounted cost. */\n override stopResolutionCounting(): void {\n this.isCountingResolutions = false;\n }\n\n /** How many times each bound key has been read since counting started. A key that was bound and never read is absent. The map is a copy. */\n override getResolutionCounts(): ReadonlyMap<string, number> {\n return new Map(this.resolutionCounts);\n }\n\n override resolve<T>(cls: TClass<T>): T {\n return this.instantiate(cls);\n }\n\n override findByTag<T = any>(opts: {\n tag: string;\n exclude?: Array<string> | Set<string>;\n }): Binding<T>[] {\n const { tag, exclude } = opts;\n\n const rs: Binding<T>[] = [];\n\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n if (!binding.hasTag(tag)) {\n continue;\n }\n\n if (exclude instanceof Array && exclude.length > 0 && exclude.includes(binding.key)) {\n continue;\n }\n\n if (exclude instanceof Set && exclude.size > 0 && exclude.has(binding.key)) {\n continue;\n }\n\n rs.push(binding);\n }\n\n return rs;\n }\n\n override clear(): void {\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n binding.clearCache();\n }\n }\n\n override reset(): void {\n this.bindings.clear();\n this.symbolKeys.clear();\n this.symbolDescriptionCounts.clear();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,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AAS;IA2ClB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;CAyD3C"}
@@ -36,6 +36,7 @@ export class Container extends BaseContainer {
36
36
  if (recorded === undefined) {
37
37
  throw getError({
38
38
  message: `[${cls.name}] ${at} names '${target.name}', which is not registered as an artifact | Decorate it (@service, @repository, ...) or register it on the application before it is injected`,
39
+ extra: { unregisteredClass: target.name },
39
40
  });
40
41
  }
41
42
  // A same-name class records the same derived key (a library's own copy of a class the application registers): resolving it would hand back the OTHER class without a word.
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../../../../src/modules/container/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,qGAAqG;AACrG,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,YAAY,IAAwB;QAClC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACO,iBAAiB,CAAC,IAM3B;QACC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAEpE,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAChD,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,yCAAyC;aACtE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAG,mBAAmB,CA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,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,KAAK,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC;gBACjC,GAAG,EAAE,QAAQ,CAAC,UAAU;gBACxB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU;gBACV,GAAG;gBACH,EAAE,EAAE,aAAa,MAAM,CAAC,WAAW,CAAC,GAAG;aACxC,CAAC,CAAC;YAEF,QAAgB,CAAC,WAAW,CAAC;gBAC5B,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { getError } from '../error';\nimport { type AnyType, type TBindingKey, type TClass, type TInjectTarget } from '@/common/types';\nimport { resolveInjectTarget } from '@/common/utilities';\nimport { BaseContainer } from './base';\n\n/** Default container: constructor + property injection driven by the decorator metadata registry. */\nexport class Container extends BaseContainer {\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? Container.name });\n }\n\n /**\n * The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative\n * `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework\n * writes may carry both, and then the class wins and the key is the fallback for a class nothing\n * recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither\n * resolves to `undefined`, as an optional key would.\n */\n protected resolveBindingKey(opts: {\n key?: TBindingKey;\n target?: TInjectTarget;\n isOptional?: boolean;\n cls: TClass<AnyType>;\n at: string;\n }): TBindingKey | undefined {\n const { key, target: declared, isOptional = false, cls, at } = opts;\n\n if (declared === undefined && key !== undefined) {\n return key;\n }\n\n if (declared === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} has neither an @inject key nor a class`,\n });\n }\n\n const target = resolveInjectTarget({ target: declared });\n if (target === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names a function that did not return a class`,\n });\n }\n\n const recorded = this.getMetadataRegistry().getBindingKey({ target }) ?? key;\n if (recorded === undefined && isOptional) {\n return undefined;\n }\n\n if (recorded === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', which is not registered as an artifact | Decorate it (@service, @repository, ...) or register it on the application before it is injected`,\n });\n }\n\n // A same-name class records the same derived key (a library's own copy of a class the application registers): resolving it would hand back the OTHER class without a word.\n const bound = this.getBinding({ key: recorded })?.boundClass();\n if (bound && bound !== target && !(bound.prototype instanceof target)) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', but '${String(recorded)}' is bound to a different class named '${bound.name}' | Two classes share one name and so one key - rename one, re-export the registered one, or inject by key`,\n });\n }\n\n return recorded;\n }\n\n override instantiate<T>(cls: TClass<T>): T {\n const registry = this.getMetadataRegistry();\n\n const injectMetadata = registry.getInjectMetadata({\n target: cls,\n });\n\n const args: any[] = [];\n\n for (let index = 0; index < (injectMetadata?.length ?? 0); index++) {\n const meta = injectMetadata?.[index];\n\n if (!meta) {\n throw getError({\n message: `[${cls.name}] Constructor parameter ${index} has no @inject | Every parameter of a container-instantiated class must be decorated - the container cannot supply an undecorated one`,\n });\n }\n\n const isOptional = meta.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: meta.key,\n target: meta.target,\n isOptional,\n cls,\n at: `Constructor parameter ${index}`,\n });\n\n args[meta.index] = key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n const instance = new cls(...args);\n\n const propertyMetadata = registry.getPropertiesMetadata({\n target: instance as object,\n });\n\n if (!propertyMetadata?.size) {\n return instance;\n }\n\n const properties = propertyMetadata.entries();\n for (const [propertyKey, metadata] of properties) {\n const isOptional = metadata.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: metadata.bindingKey,\n target: metadata.target,\n isOptional,\n cls,\n at: `Property '${String(propertyKey)}'`,\n });\n\n (instance as any)[propertyKey] =\n key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n return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AEF,QAAgB,CAAC,WAAW,CAAC;gBAC5B,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { getError } from '../error';\nimport { type AnyType, type TBindingKey, type TClass, type TInjectTarget } from '@/common/types';\nimport { resolveInjectTarget } from '@/common/utilities';\nimport { BaseContainer } from './base';\n\n/** Default container: constructor + property injection driven by the decorator metadata registry. */\nexport class Container extends BaseContainer {\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? Container.name });\n }\n\n /**\n * The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative\n * `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework\n * writes may carry both, and then the class wins and the key is the fallback for a class nothing\n * recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither\n * resolves to `undefined`, as an optional key would.\n */\n protected resolveBindingKey(opts: {\n key?: TBindingKey;\n target?: TInjectTarget;\n isOptional?: boolean;\n cls: TClass<AnyType>;\n at: string;\n }): TBindingKey | undefined {\n const { key, target: declared, isOptional = false, cls, at } = opts;\n\n if (declared === undefined && key !== undefined) {\n return key;\n }\n\n if (declared === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} has neither an @inject key nor a class`,\n });\n }\n\n const target = resolveInjectTarget({ target: declared });\n if (target === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names a function that did not return a class`,\n });\n }\n\n const recorded = this.getMetadataRegistry().getBindingKey({ target }) ?? key;\n if (recorded === undefined && isOptional) {\n return undefined;\n }\n\n if (recorded === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', which is not registered as an artifact | Decorate it (@service, @repository, ...) or register it on the application before it is injected`,\n extra: { unregisteredClass: target.name },\n });\n }\n\n // A same-name class records the same derived key (a library's own copy of a class the application registers): resolving it would hand back the OTHER class without a word.\n const bound = this.getBinding({ key: recorded })?.boundClass();\n if (bound && bound !== target && !(bound.prototype instanceof target)) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', but '${String(recorded)}' is bound to a different class named '${bound.name}' | Two classes share one name and so one key - rename one, re-export the registered one, or inject by key`,\n });\n }\n\n return recorded;\n }\n\n override instantiate<T>(cls: TClass<T>): T {\n const registry = this.getMetadataRegistry();\n\n const injectMetadata = registry.getInjectMetadata({\n target: cls,\n });\n\n const args: any[] = [];\n\n for (let index = 0; index < (injectMetadata?.length ?? 0); index++) {\n const meta = injectMetadata?.[index];\n\n if (!meta) {\n throw getError({\n message: `[${cls.name}] Constructor parameter ${index} has no @inject | Every parameter of a container-instantiated class must be decorated - the container cannot supply an undecorated one`,\n });\n }\n\n const isOptional = meta.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: meta.key,\n target: meta.target,\n isOptional,\n cls,\n at: `Constructor parameter ${index}`,\n });\n\n args[meta.index] = key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n const instance = new cls(...args);\n\n const propertyMetadata = registry.getPropertiesMetadata({\n target: instance as object,\n });\n\n if (!propertyMetadata?.size) {\n return instance;\n }\n\n const properties = propertyMetadata.entries();\n for (const [propertyKey, metadata] of properties) {\n const isOptional = metadata.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: metadata.bindingKey,\n target: metadata.target,\n isOptional,\n cls,\n at: `Property '${String(propertyKey)}'`,\n });\n\n (instance as any)[propertyKey] =\n key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n return instance;\n }\n}\n"]}
@@ -2,4 +2,5 @@ export * from './abstract.js';
2
2
  export * from './base.js';
3
3
  export * from './common/index.js';
4
4
  export * from './container.js';
5
+ export * from './verifier.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -2,4 +2,5 @@ export * from './abstract.js';
2
2
  export * from './base.js';
3
3
  export * from './common/index.js';
4
4
  export * from './container.js';
5
+ export * from './verifier.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC","sourcesContent":["export * from './abstract';\nexport * from './base';\nexport * from './common';\nexport * from './container';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["export * from './abstract';\nexport * from './base';\nexport * from './common';\nexport * from './container';\nexport * from './verifier';\n"]}
@@ -0,0 +1,47 @@
1
+ import type { TClass } from '../../common/types.js';
2
+ import type { IContainer } from './common/types.js';
3
+ /** A class (matched exactly, never by subclass), a class name, or a binding key. */
4
+ export type TBindingSkip = TClass<unknown> | string;
5
+ export interface IVerifyBindingsOptions {
6
+ container: IContainer;
7
+ /**
8
+ * A binding is in a namespace when it carries the tag `Binding` sets from the first segment of its
9
+ * key: `services.Orders` is in `services`. Required: inversion does not know which namespaces an
10
+ * application uses. A namespace that itself holds a dot is not supported.
11
+ */
12
+ namespaces: string[];
13
+ /** Bindings to leave unresolved. A skip that matches no enumerated binding is reported in `unmatchedSkips`. */
14
+ skip?: TBindingSkip[];
15
+ }
16
+ export interface IBindingFailure {
17
+ /** The binding that could not resolve, that is, who needs the missing thing. */
18
+ key: string;
19
+ message: string;
20
+ /** An injected key nobody bound (`extra.unboundKey` of the container's error). */
21
+ missingKey?: string;
22
+ /** An injected class nobody registered (`extra.unregisteredClass` of the container's error). */
23
+ unregisteredClass?: string;
24
+ /** The thrown object, unchanged. */
25
+ error: unknown;
26
+ }
27
+ export interface IBindingVerification {
28
+ /** Keys resolved, in container order, namespaces in the order given. */
29
+ verified: string[];
30
+ failures: IBindingFailure[];
31
+ unmatchedSkips: TBindingSkip[];
32
+ }
33
+ /**
34
+ * Resolves every binding of the given namespaces once and reports every failure, instead of stopping
35
+ * at the first. It changes nothing in the container. A failed binding is a result, never a throw:
36
+ * `assertBindingsResolve` is the throwing form.
37
+ */
38
+ export declare const verifyBindings: (opts: IVerifyBindingsOptions) => IBindingVerification;
39
+ /**
40
+ * `verifyBindings`, and one `ApplicationError` when a binding failed or a skip matched nothing: the
41
+ * message lists `<key>: <message>` per failure, `extra.missing` maps each missing key or class name to
42
+ * the bindings that needed it.
43
+ */
44
+ export declare const assertBindingsResolve: (opts: IVerifyBindingsOptions & {
45
+ scope: string;
46
+ }) => IBindingVerification;
47
+ //# sourceMappingURL=verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,UAAU,CAAC;IAEtB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IAErB,+GAA+G;IAC/G,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAEhB,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,oCAAoC;IACpC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC;AAgDD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,sBAAsB,KAAG,oBA4C7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,KAC/C,oBAuCF,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { getError } from '../error/index.js';
2
+ const hasBoundClass = (binding) => 'boundClass' in binding && typeof binding.boundClass === 'function';
3
+ const classOf = (binding) => hasBoundClass(binding) ? binding.boundClass() : undefined;
4
+ const skipName = (skip) => (typeof skip === 'string' ? skip : skip.name);
5
+ const matchesSkip = (opts) => {
6
+ const { skip, binding } = opts;
7
+ const bound = classOf(binding);
8
+ if (typeof skip === 'string') {
9
+ return skip === binding.key || (bound !== undefined && skip === bound.name);
10
+ }
11
+ return bound === skip;
12
+ };
13
+ const readString = (opts) => {
14
+ const { source, name } = opts;
15
+ if (typeof source !== 'object' || source === null || !(name in source)) {
16
+ return undefined;
17
+ }
18
+ const value = Reflect.get(source, name);
19
+ return typeof value === 'string' ? value : undefined;
20
+ };
21
+ /** What a thrown value says about the thing it could not find; a constructor's own error says nothing. */
22
+ const readMissing = (error) => {
23
+ const extra = typeof error === 'object' && error !== null ? Reflect.get(error, 'extra') : undefined;
24
+ const missingKey = readString({ source: extra, name: 'unboundKey' });
25
+ const unregisteredClass = readString({ source: extra, name: 'unregisteredClass' });
26
+ return {
27
+ ...(missingKey === undefined ? {} : { missingKey }),
28
+ ...(unregisteredClass === undefined ? {} : { unregisteredClass }),
29
+ };
30
+ };
31
+ /**
32
+ * Resolves every binding of the given namespaces once and reports every failure, instead of stopping
33
+ * at the first. It changes nothing in the container. A failed binding is a result, never a throw:
34
+ * `assertBindingsResolve` is the throwing form.
35
+ */
36
+ export const verifyBindings = (opts) => {
37
+ const { container, namespaces, skip = [] } = opts;
38
+ const enumerated = new Map();
39
+ for (const namespace of namespaces) {
40
+ for (const binding of container.findByTag({ tag: namespace })) {
41
+ if (!enumerated.has(binding.key)) {
42
+ enumerated.set(binding.key, binding);
43
+ }
44
+ }
45
+ }
46
+ const matched = new Set();
47
+ const verified = [];
48
+ const failures = [];
49
+ for (const binding of enumerated.values()) {
50
+ const skipped = skip.filter((candidate) => matchesSkip({ skip: candidate, binding }));
51
+ for (const candidate of skipped) {
52
+ matched.add(candidate);
53
+ }
54
+ if (skipped.length > 0) {
55
+ continue;
56
+ }
57
+ try {
58
+ container.get({ key: binding.key });
59
+ verified.push(binding.key);
60
+ }
61
+ catch (error) {
62
+ failures.push({
63
+ key: binding.key,
64
+ message: error instanceof Error ? error.message : String(error),
65
+ ...readMissing(error),
66
+ error,
67
+ });
68
+ }
69
+ }
70
+ return {
71
+ verified,
72
+ failures,
73
+ unmatchedSkips: skip.filter((candidate) => !matched.has(candidate)),
74
+ };
75
+ };
76
+ /**
77
+ * `verifyBindings`, and one `ApplicationError` when a binding failed or a skip matched nothing: the
78
+ * message lists `<key>: <message>` per failure, `extra.missing` maps each missing key or class name to
79
+ * the bindings that needed it.
80
+ */
81
+ export const assertBindingsResolve = (opts) => {
82
+ const { scope, ...rest } = opts;
83
+ const result = verifyBindings(rest);
84
+ if (result.failures.length === 0 && result.unmatchedSkips.length === 0) {
85
+ return result;
86
+ }
87
+ const parts = [
88
+ ...result.failures.map((failure) => `${failure.key}: ${failure.message}`),
89
+ ...result.unmatchedSkips.map((skip) => `skip matched no binding: ${skipName(skip)}`),
90
+ ];
91
+ const missing = {};
92
+ for (const failure of result.failures) {
93
+ const what = failure.missingKey ?? failure.unregisteredClass;
94
+ if (what !== undefined) {
95
+ missing[what] = [...(missing[what] ?? []), failure.key];
96
+ }
97
+ }
98
+ const header = result.failures.length > 0
99
+ ? `[${scope}] ${result.failures.length} binding(s) cannot be resolved | `
100
+ : `[${scope}] `;
101
+ throw getError({
102
+ message: `${header}${parts.join(' | ')}`,
103
+ extra: {
104
+ failures: result.failures.map(({ key, message, missingKey, unregisteredClass }) => ({
105
+ key,
106
+ message,
107
+ ...(missingKey === undefined ? {} : { missingKey }),
108
+ ...(unregisteredClass === undefined ? {} : { unregisteredClass }),
109
+ })),
110
+ missing,
111
+ unmatchedSkips: result.unmatchedSkips.map(skipName),
112
+ },
113
+ });
114
+ };
115
+ //# sourceMappingURL=verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../../../src/modules/container/verifier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA8CpC,MAAM,aAAa,GAAG,CAAC,OAAiB,EAAuC,EAAE,CAC/E,YAAY,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC;AAEtE,MAAM,OAAO,GAAG,CAAC,OAAiB,EAA+B,EAAE,CACjE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAC,IAAkB,EAAU,EAAE,CAAC,CAAC,OAAO,IAAI,KAA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CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;gBACnD,GAAG,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC;aAClE,CAAC,CAAC;YACH,OAAO;YACP,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;SACpD;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { TClass } from '@/common/types';\nimport type { IBinding } from '../binding/common/types';\nimport { getError } from '../error';\nimport type { IContainer } from './common/types';\n\n/** A class (matched exactly, never by subclass), a class name, or a binding key. */\nexport type TBindingSkip = TClass<unknown> | string;\n\nexport interface IVerifyBindingsOptions {\n container: IContainer;\n\n /**\n * A binding is in a namespace when it carries the tag `Binding` sets from the first segment of its\n * key: `services.Orders` is in `services`. Required: inversion does not know which namespaces an\n * application uses. A namespace that itself holds a dot is not supported.\n */\n namespaces: string[];\n\n /** Bindings to leave unresolved. A skip that matches no enumerated binding is reported in `unmatchedSkips`. */\n skip?: TBindingSkip[];\n}\n\nexport interface IBindingFailure {\n /** The binding that could not resolve, that is, who needs the missing thing. */\n key: string;\n message: string;\n\n /** An injected key nobody bound (`extra.unboundKey` of the container's error). */\n missingKey?: string;\n\n /** An injected class nobody registered (`extra.unregisteredClass` of the container's error). */\n unregisteredClass?: string;\n\n /** The thrown object, unchanged. */\n error: unknown;\n}\n\nexport interface IBindingVerification {\n /** Keys resolved, in container order, namespaces in the order given. */\n verified: string[];\n failures: IBindingFailure[];\n unmatchedSkips: TBindingSkip[];\n}\n\ninterface IClassBinding {\n boundClass: () => TClass<unknown> | undefined;\n}\n\nconst hasBoundClass = (binding: IBinding): binding is IBinding & IClassBinding =>\n 'boundClass' in binding && typeof binding.boundClass === 'function';\n\nconst classOf = (binding: IBinding): TClass<unknown> | undefined =>\n hasBoundClass(binding) ? binding.boundClass() : undefined;\n\nconst skipName = (skip: TBindingSkip): string => (typeof skip === 'string' ? skip : skip.name);\n\nconst matchesSkip = (opts: { skip: TBindingSkip; binding: IBinding }): boolean => {\n const { skip, binding } = opts;\n const bound = classOf(binding);\n\n if (typeof skip === 'string') {\n return skip === binding.key || (bound !== undefined && skip === bound.name);\n }\n\n return bound === skip;\n};\n\nconst readString = (opts: { source: unknown; name: string }): string | undefined => {\n const { source, name } = opts;\n if (typeof source !== 'object' || source === null || !(name in source)) {\n return undefined;\n }\n\n const value = Reflect.get(source, name);\n return typeof value === 'string' ? value : undefined;\n};\n\n/** What a thrown value says about the thing it could not find; a constructor's own error says nothing. */\nconst readMissing = (error: unknown): { missingKey?: string; unregisteredClass?: string } => {\n const extra =\n typeof error === 'object' && error !== null ? Reflect.get(error, 'extra') : undefined;\n const missingKey = readString({ source: extra, name: 'unboundKey' });\n const unregisteredClass = readString({ source: extra, name: 'unregisteredClass' });\n\n return {\n ...(missingKey === undefined ? {} : { missingKey }),\n ...(unregisteredClass === undefined ? {} : { unregisteredClass }),\n };\n};\n\n/**\n * Resolves every binding of the given namespaces once and reports every failure, instead of stopping\n * at the first. It changes nothing in the container. A failed binding is a result, never a throw:\n * `assertBindingsResolve` is the throwing form.\n */\nexport const verifyBindings = (opts: IVerifyBindingsOptions): IBindingVerification => {\n const { container, namespaces, skip = [] } = opts;\n\n const enumerated = new Map<string, IBinding>();\n for (const namespace of namespaces) {\n for (const binding of container.findByTag({ tag: namespace })) {\n if (!enumerated.has(binding.key)) {\n enumerated.set(binding.key, binding);\n }\n }\n }\n\n const matched = new Set<TBindingSkip>();\n const verified: string[] = [];\n const failures: IBindingFailure[] = [];\n\n for (const binding of enumerated.values()) {\n const skipped = skip.filter((candidate) => matchesSkip({ skip: candidate, binding }));\n for (const candidate of skipped) {\n matched.add(candidate);\n }\n\n if (skipped.length > 0) {\n continue;\n }\n\n try {\n container.get({ key: binding.key });\n verified.push(binding.key);\n } catch (error) {\n failures.push({\n key: binding.key,\n message: error instanceof Error ? error.message : String(error),\n ...readMissing(error),\n error,\n });\n }\n }\n\n return {\n verified,\n failures,\n unmatchedSkips: skip.filter((candidate) => !matched.has(candidate)),\n };\n};\n\n/**\n * `verifyBindings`, and one `ApplicationError` when a binding failed or a skip matched nothing: the\n * message lists `<key>: <message>` per failure, `extra.missing` maps each missing key or class name to\n * the bindings that needed it.\n */\nexport const assertBindingsResolve = (\n opts: IVerifyBindingsOptions & { scope: string },\n): IBindingVerification => {\n const { scope, ...rest } = opts;\n const result = verifyBindings(rest);\n\n if (result.failures.length === 0 && result.unmatchedSkips.length === 0) {\n return result;\n }\n\n const parts = [\n ...result.failures.map((failure) => `${failure.key}: ${failure.message}`),\n ...result.unmatchedSkips.map((skip) => `skip matched no binding: ${skipName(skip)}`),\n ];\n\n const missing: Record<string, string[]> = {};\n for (const failure of result.failures) {\n const what = failure.missingKey ?? failure.unregisteredClass;\n if (what !== undefined) {\n missing[what] = [...(missing[what] ?? []), failure.key];\n }\n }\n\n const header =\n result.failures.length > 0\n ? `[${scope}] ${result.failures.length} binding(s) cannot be resolved | `\n : `[${scope}] `;\n\n throw getError({\n message: `${header}${parts.join(' | ')}`,\n extra: {\n failures: result.failures.map(({ key, message, missingKey, unregisteredClass }) => ({\n key,\n message,\n ...(missingKey === undefined ? {} : { missingKey }),\n ...(unregisteredClass === undefined ? {} : { unregisteredClass }),\n })),\n missing,\n unmatchedSkips: result.unmatchedSkips.map(skipName),\n },\n });\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@venizia/ignis-inversion",
3
- "version": "0.4.3",
4
- "description": "Lightweight, high-performance Dependency Injection and Inversion of Control container for TypeScript (~350 lines). Features decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, tag-based discovery, and reflect-metadata integration. Inspired by LoopBack 4 and InversifyJS but simpler. Zero framework lock-in — works standalone or with Ignis.",
3
+ "version": "0.4.4",
4
+ "description": "A small, standalone Dependency Injection and Inversion of Control container for TypeScript. Features decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, tag-based discovery, and reflect-metadata integration. Zero framework lock-in — works standalone or with Ignis.",
5
5
  "keywords": [
6
6
  "architecture",
7
7
  "binding",
@@ -21,13 +21,10 @@
21
21
  "injectable",
22
22
  "injection",
23
23
  "injector",
24
- "inversify",
25
- "inversify-alternative",
26
24
  "inversion-of-control",
27
25
  "ioc",
28
26
  "ioc-container",
29
27
  "lightweight",
30
- "loopback",
31
28
  "loose-coupling",
32
29
  "metadata",
33
30
  "nodejs",
@@ -43,7 +40,6 @@
43
40
  "tag-discovery",
44
41
  "testability",
45
42
  "transient",
46
- "tsyringe-alternative",
47
43
  "typescript",
48
44
  "venizia"
49
45
  ],
@@ -70,18 +66,14 @@
70
66
  "!**/*.tsbuildinfo"
71
67
  ],
72
68
  "sideEffects": [
73
- "./dist/cjs/index.js",
74
69
  "./dist/esm/index.js"
75
70
  ],
76
- "main": "./dist/cjs/index.js",
77
- "module": "./dist/esm/index.js",
78
- "types": "./dist/cjs/index.d.ts",
71
+ "main": "./dist/esm/index.js",
72
+ "types": "./dist/esm/index.d.ts",
79
73
  "exports": {
80
74
  ".": {
81
- "types": "./dist/cjs/index.d.ts",
82
- "import": "./dist/esm/index.js",
83
- "require": "./dist/cjs/index.js",
84
- "default": "./dist/cjs/index.js"
75
+ "types": "./dist/esm/index.d.ts",
76
+ "default": "./dist/esm/index.js"
85
77
  },
86
78
  "./package.json": "./package.json"
87
79
  },
@@ -97,7 +89,7 @@
97
89
  },
98
90
  "devDependencies": {
99
91
  "@types/bun": "^1.4.3",
100
- "@venizia/dev-configs": "0.4.3",
92
+ "@venizia/dev-configs": "0.4.4",
101
93
  "eslint": "^10.13.0",
102
94
  "oxlint": "1.89.0",
103
95
  "oxlint-tsgolint": "7.0.2004",
@@ -1,9 +0,0 @@
1
- export declare class BaseHelper {
2
- scope: string;
3
- identifier: string;
4
- constructor(opts: {
5
- scope: string;
6
- identifier?: string;
7
- });
8
- }
9
- //# sourceMappingURL=base-helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-helper.d.ts","sourceRoot":"","sources":["../../../src/common/base-helper.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CAIzD"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseHelper = void 0;
4
- class BaseHelper {
5
- constructor(opts) {
6
- this.scope = opts.scope ?? '';
7
- this.identifier = opts.identifier ?? '';
8
- }
9
- }
10
- exports.BaseHelper = BaseHelper;
11
- //# sourceMappingURL=base-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-helper.js","sourceRoot":"","sources":["../../../src/common/base-helper.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAIrB,YAAY,IAA4C;QACtD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;IAC1C,CAAC;CACF;AARD,gCAQC","sourcesContent":["export class BaseHelper {\n scope: string;\n identifier: string;\n\n constructor(opts: { scope: string; identifier?: string }) {\n this.scope = opts.scope ?? '';\n this.identifier = opts.identifier ?? '';\n }\n}\n"]}
@@ -1,5 +0,0 @@
1
- export * from './base-helper';
2
- export * from './logger';
3
- export * from './types';
4
- export * from './utilities';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -1,21 +0,0 @@
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("./base-helper"), exports);
18
- __exportStar(require("./logger"), exports);
19
- __exportStar(require("./types"), exports);
20
- __exportStar(require("./utilities"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B","sourcesContent":["export * from './base-helper';\nexport * from './logger';\nexport * from './types';\nexport * from './utilities';\n"]}
@@ -1,11 +0,0 @@
1
- export declare class Logger {
2
- private static debugEnabled;
3
- static enableDebug(opts: {
4
- enabled: boolean;
5
- }): void;
6
- static info(message: string, ...args: unknown[]): void;
7
- static warn(message: string, ...args: unknown[]): void;
8
- static error(message: string, ...args: unknown[]): void;
9
- static debug(message: string, ...args: unknown[]): void;
10
- }
11
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAA2C;IAEtE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAI7C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAI/C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAI/C,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIhD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;CAOjD"}