@navios/core 1.0.0 → 2.0.0-alpha.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 (237) hide show
  1. package/CHANGELOG.md +97 -11
  2. package/README.md +67 -220
  3. package/lib/async-context-6pdlnNLA.d.mts +237 -0
  4. package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
  5. package/lib/async-context-Dqk7pE-D.d.cts +237 -0
  6. package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
  7. package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
  8. package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
  9. package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
  10. package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
  11. package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
  12. package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
  13. package/lib/attribute-value-DMEA255r.mjs +119 -0
  14. package/lib/attribute-value-DMEA255r.mjs.map +1 -0
  15. package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
  16. package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
  17. package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
  18. package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
  19. package/lib/execution-context-BPD3FeFb.d.mts +71 -0
  20. package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
  21. package/lib/execution-context-BTJdHhbf.d.cts +71 -0
  22. package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
  23. package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
  24. package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
  25. package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
  26. package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
  27. package/lib/index.cjs +1687 -4409
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +838 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +838 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1573 -4219
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bha7GER_.mjs +135 -0
  44. package/lib/module-Bha7GER_.mjs.map +1 -0
  45. package/lib/module-DZewk_2r.cjs +164 -0
  46. package/lib/module-DZewk_2r.cjs.map +1 -0
  47. package/lib/module-graph-DCP9MHG0.cjs +147 -0
  48. package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
  49. package/lib/module-graph-xvVEykFM.mjs +142 -0
  50. package/lib/module-graph-xvVEykFM.mjs.map +1 -0
  51. package/lib/module-metadata-C8S92seK.cjs +95 -0
  52. package/lib/module-metadata-C8S92seK.cjs.map +1 -0
  53. package/lib/module-metadata-k3RTt20x.mjs +66 -0
  54. package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
  55. package/lib/module-options-Dmse0gii.d.mts +51 -0
  56. package/lib/module-options-Dmse0gii.d.mts.map +1 -0
  57. package/lib/module-options-IuDO-p8u.d.cts +51 -0
  58. package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
  59. package/lib/testing/index.cjs +96 -414
  60. package/lib/testing/index.cjs.map +1 -1
  61. package/lib/testing/index.d.cts +25 -385
  62. package/lib/testing/index.d.cts.map +1 -1
  63. package/lib/testing/index.d.mts +24 -385
  64. package/lib/testing/index.d.mts.map +1 -1
  65. package/lib/testing/index.mjs +94 -408
  66. package/lib/testing/index.mjs.map +1 -1
  67. package/lib/transport.cjs +25 -0
  68. package/lib/transport.d.cts +190 -0
  69. package/lib/transport.d.cts.map +1 -0
  70. package/lib/transport.d.mts +190 -0
  71. package/lib/transport.d.mts.map +1 -0
  72. package/lib/transport.mjs +7 -0
  73. package/package.json +37 -17
  74. package/docs/README.md +0 -316
  75. package/docs/adapters.md +0 -308
  76. package/docs/application-setup.md +0 -524
  77. package/docs/attributes.md +0 -689
  78. package/docs/controllers.md +0 -373
  79. package/docs/endpoints.md +0 -444
  80. package/docs/exceptions.md +0 -352
  81. package/docs/guards.md +0 -550
  82. package/docs/legacy-compat.md +0 -356
  83. package/docs/modules.md +0 -377
  84. package/docs/quick-start.md +0 -290
  85. package/docs/services.md +0 -427
  86. package/docs/testing.md +0 -827
  87. package/lib/index-C0Sg16Eb.d.cts +0 -3365
  88. package/lib/index-C0Sg16Eb.d.cts.map +0 -1
  89. package/lib/index-DySQ6Dpd.d.mts +0 -3365
  90. package/lib/index-DySQ6Dpd.d.mts.map +0 -1
  91. package/lib/navios.factory-CO5MB_OK.cjs +0 -4125
  92. package/lib/navios.factory-CO5MB_OK.cjs.map +0 -1
  93. package/lib/navios.factory-D6Y94P9B.mjs +0 -3828
  94. package/lib/navios.factory-D6Y94P9B.mjs.map +0 -1
  95. package/lib/tokens-4J9sredA.mjs +0 -100
  96. package/lib/tokens-4J9sredA.mjs.map +0 -1
  97. package/lib/tokens-CWw9kyeD.cjs +0 -196
  98. package/lib/tokens-CWw9kyeD.cjs.map +0 -1
  99. package/lib/use-guards.decorator-BecoQSmE.mjs +0 -339
  100. package/lib/use-guards.decorator-BecoQSmE.mjs.map +0 -1
  101. package/lib/use-guards.decorator-C4ml9XaT.cjs +0 -447
  102. package/lib/use-guards.decorator-C4ml9XaT.cjs.map +0 -1
  103. package/project.json +0 -66
  104. package/src/__tests__/attribute.factory.spec.mts +0 -300
  105. package/src/__tests__/config.service.spec.mts +0 -43
  106. package/src/__tests__/console-logger.service.spec.mts +0 -312
  107. package/src/__tests__/controller-resolver.spec.mts +0 -229
  108. package/src/__tests__/controller.spec.mts +0 -58
  109. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  110. package/src/__tests__/logger.service.spec.mts +0 -147
  111. package/src/__tests__/responders.spec.mts +0 -340
  112. package/src/__tests__/testing-module.spec.mts +0 -459
  113. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  114. package/src/attribute.factory.mts +0 -325
  115. package/src/config/config-service.interface.mts +0 -47
  116. package/src/config/config.provider.mts +0 -69
  117. package/src/config/config.service.mts +0 -176
  118. package/src/config/index.mts +0 -5
  119. package/src/config/types.mts +0 -58
  120. package/src/config/utils/helpers.mts +0 -23
  121. package/src/config/utils/index.mts +0 -1
  122. package/src/decorators/controller.decorator.mts +0 -81
  123. package/src/decorators/endpoint.decorator.mts +0 -181
  124. package/src/decorators/header.decorator.mts +0 -38
  125. package/src/decorators/http-code.decorator.mts +0 -38
  126. package/src/decorators/index.mts +0 -8
  127. package/src/decorators/module.decorator.mts +0 -106
  128. package/src/decorators/multipart.decorator.mts +0 -169
  129. package/src/decorators/stream.decorator.mts +0 -155
  130. package/src/decorators/use-guards.decorator.mts +0 -73
  131. package/src/exceptions/bad-request.exception.mts +0 -28
  132. package/src/exceptions/conflict.exception.mts +0 -31
  133. package/src/exceptions/forbidden.exception.mts +0 -30
  134. package/src/exceptions/http.exception.mts +0 -33
  135. package/src/exceptions/index.mts +0 -7
  136. package/src/exceptions/internal-server-error.exception.mts +0 -33
  137. package/src/exceptions/not-found.exception.mts +0 -33
  138. package/src/exceptions/unauthorized.exception.mts +0 -30
  139. package/src/factories/adapter.factory.mts +0 -20
  140. package/src/factories/endpoint-adapter.factory.mts +0 -21
  141. package/src/factories/http-adapter.factory.mts +0 -20
  142. package/src/factories/index.mts +0 -8
  143. package/src/factories/multipart-adapter.factory.mts +0 -21
  144. package/src/factories/reply.factory.mts +0 -21
  145. package/src/factories/request.factory.mts +0 -21
  146. package/src/factories/stream-adapter.factory.mts +0 -20
  147. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  148. package/src/index.mts +0 -16
  149. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  150. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  151. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  152. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  153. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  154. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  155. package/src/interfaces/adapter-environment.interface.mts +0 -74
  156. package/src/interfaces/can-activate.mts +0 -38
  157. package/src/interfaces/http-header.mts +0 -18
  158. package/src/interfaces/index.mts +0 -11
  159. package/src/interfaces/navios-module.mts +0 -28
  160. package/src/interfaces/plugin.interface.mts +0 -139
  161. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  162. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  163. package/src/legacy-compat/attribute.factory.mts +0 -351
  164. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  165. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  166. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  167. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  168. package/src/legacy-compat/decorators/index.mts +0 -11
  169. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  170. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  171. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  172. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  173. package/src/legacy-compat/index.mts +0 -57
  174. package/src/logger/README.md +0 -3
  175. package/src/logger/console-logger.service.mts +0 -714
  176. package/src/logger/index.mts +0 -6
  177. package/src/logger/log-levels.mts +0 -21
  178. package/src/logger/logger-service.interface.mts +0 -42
  179. package/src/logger/logger.service.mts +0 -113
  180. package/src/logger/logger.tokens.mts +0 -44
  181. package/src/logger/utils/cli-colors.util.mts +0 -17
  182. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  183. package/src/logger/utils/index.mts +0 -5
  184. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  185. package/src/logger/utils/is-log-level.util.mts +0 -10
  186. package/src/logger/utils/shared.utils.mts +0 -51
  187. package/src/metadata/controller.metadata.mts +0 -72
  188. package/src/metadata/handler.metadata.mts +0 -80
  189. package/src/metadata/index.mts +0 -4
  190. package/src/metadata/module.metadata.mts +0 -108
  191. package/src/metadata/navios-managed.metadata.mts +0 -42
  192. package/src/navios.application.mts +0 -484
  193. package/src/navios.environment.mts +0 -42
  194. package/src/navios.factory.mts +0 -158
  195. package/src/responders/enums/framework-error.enum.mts +0 -38
  196. package/src/responders/enums/index.mts +0 -1
  197. package/src/responders/index.mts +0 -4
  198. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  199. package/src/responders/interfaces/error-response.interface.mts +0 -22
  200. package/src/responders/interfaces/index.mts +0 -3
  201. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  202. package/src/responders/services/error-response-producer.service.mts +0 -143
  203. package/src/responders/services/forbidden-responder.service.mts +0 -77
  204. package/src/responders/services/index.mts +0 -5
  205. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  206. package/src/responders/services/not-found-responder.service.mts +0 -76
  207. package/src/responders/services/validation-error-responder.service.mts +0 -78
  208. package/src/responders/tokens/index.mts +0 -1
  209. package/src/responders/tokens/responder.tokens.mts +0 -84
  210. package/src/services/abstract-handler-adapter.service.mts +0 -366
  211. package/src/services/guard-runner.service.mts +0 -152
  212. package/src/services/index.mts +0 -4
  213. package/src/services/instance-resolver.service.mts +0 -177
  214. package/src/services/module-loader.service.mts +0 -252
  215. package/src/stores/index.mts +0 -1
  216. package/src/stores/request-id.store.mts +0 -85
  217. package/src/testing/index.mts +0 -3
  218. package/src/testing/testing-module.mts +0 -393
  219. package/src/testing/unit-testing-module.mts +0 -298
  220. package/src/tokens/adapter.token.mts +0 -6
  221. package/src/tokens/endpoint-adapter.token.mts +0 -8
  222. package/src/tokens/execution-context.token.mts +0 -9
  223. package/src/tokens/http-adapter.token.mts +0 -8
  224. package/src/tokens/index.mts +0 -10
  225. package/src/tokens/multipart-adapter.token.mts +0 -8
  226. package/src/tokens/navios-options.token.mts +0 -6
  227. package/src/tokens/reply.token.mts +0 -3
  228. package/src/tokens/request.token.mts +0 -3
  229. package/src/tokens/stream-adapter.token.mts +0 -8
  230. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  231. package/src/utils/adapter-supports.util.mts +0 -47
  232. package/src/utils/index.mts +0 -1
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. package/vitest.config.mts +0 -15
@@ -0,0 +1,190 @@
1
+ /**
2
+ * What the author of a transport needs and application code does not: the
3
+ * transport contract, the module graph, handler metadata, and the pieces of
4
+ * an execution context.
5
+ *
6
+ * Application code imports from `@navios/core`.
7
+ */
8
+ import { a as ContextValue, i as ContextKey, n as ExecutionContext, r as HandlerInfo, t as AttributeMap } from "./execution-context-BTJdHhbf.cjs";
9
+ import { _ as LoggerService, a as TransportDefinition, c as TransportInstance, d as buildModuleGraph, f as ContextHost, i as Transport, l as defineTransport, m as needsScope, o as TransportFactory, r as runInContext, s as TransportHost, u as ModuleNode } from "./async-context-Dqk7pE-D.cjs";
10
+ import { ClassType, ClassType as ClassType$1, Container, Provider, ScopedContainer } from "@navios/di";
11
+ import { constructedInstances } from "@navios/di/internal";
12
+ import { a as Interceptor, i as AttributeValue, n as Guard, o as InterceptorClass, r as GuardClass } from "./module-options-IuDO-p8u.cjs";
13
+ /** The `metadata` of a decorator context. */
14
+ type DecoratorMetadata = Record<PropertyKey, unknown>;
15
+ interface ModuleMetadata {
16
+ imports: ClassType$1[];
17
+ guards: ClassType$1[];
18
+ interceptors: ClassType$1[];
19
+ providers: Provider[];
20
+ attributes: Map<symbol, unknown>;
21
+ /**
22
+ * Every option the module system itself does not use, by option name, as
23
+ * written. A transport reads its own from here.
24
+ */
25
+ entries: Map<string, unknown>;
26
+ }
27
+ export declare function getModuleMetadata(target: ClassType$1): ModuleMetadata;
28
+ export declare function hasModuleMetadata(target: ClassType$1): boolean;
29
+ /**
30
+ * What decorators and `handler()` options can attach to a handler.
31
+ */
32
+ interface HandlerExtras {
33
+ guards: ClassType$1[];
34
+ interceptors: ClassType$1[];
35
+ attributes: Map<symbol, unknown>;
36
+ }
37
+ /**
38
+ * A class member that is, or may become, a handler: what decorators attached
39
+ * to it.
40
+ */
41
+ interface MethodHandlerMetadata extends HandlerExtras {
42
+ name: string;
43
+ /**
44
+ * What makes the member a handler of a transport, under that transport's
45
+ * own symbol.
46
+ */
47
+ entries: Map<symbol, unknown>;
48
+ }
49
+ /**
50
+ * What decorators attached to a member, inherited ones included, to read and to
51
+ * add to.
52
+ */
53
+ export declare function memberMetadata(context: {
54
+ metadata?: DecoratorMetadata;
55
+ }, name: string): MethodHandlerMetadata;
56
+ /** What a transport's decorator for handler classes may take. */
57
+ interface HandlerClassOptions {
58
+ guards?: Iterable<ClassType$1>;
59
+ interceptors?: Iterable<ClassType$1>;
60
+ attributes?: AttributeValue[];
61
+ }
62
+ /** A class that owns handlers: what applies to all of them, and its members. */
63
+ interface HandlerClassMetadata extends HandlerExtras {
64
+ /** The members decorators were applied to, by name. */
65
+ members: Map<string, MethodHandlerMetadata>;
66
+ }
67
+ /**
68
+ * What decorators attached to a class of handlers and to its members, together
69
+ * with the options of the class decorator that asks. The lists are live:
70
+ * `@UseGuards` and the like placed above that decorator run after it and are
71
+ * still seen.
72
+ */
73
+ export declare function describeHandlerClass(context: {
74
+ metadata?: DecoratorMetadata;
75
+ }, options?: HandlerClassOptions): HandlerClassMetadata;
76
+ interface Extras {
77
+ readonly guards: readonly ClassType$1[];
78
+ readonly interceptors: readonly ClassType$1[];
79
+ }
80
+ interface OwnExtras extends Extras {
81
+ readonly attributes: ReadonlyMap<symbol, unknown>;
82
+ }
83
+ interface HandlerChainInput {
84
+ /**
85
+ * Interceptors around every handler of the application or of the transport,
86
+ * outermost first.
87
+ */
88
+ application: readonly ClassType$1[];
89
+ /** The module the handler belongs to, with what it inherits. */
90
+ node: Extras & Pick<ModuleNode, 'module' | 'disputed'>;
91
+ /** The class that owns the handler. */
92
+ owner: OwnExtras;
93
+ /** The handler itself. */
94
+ member: OwnExtras;
95
+ }
96
+ interface HandlerChain {
97
+ guards: ClassType$1[];
98
+ /** `outer` and `inner`, one after the other. */
99
+ interceptors: ClassType$1[];
100
+ /** Interceptors around the guards: those of the application. */
101
+ outer: ClassType$1[];
102
+ /** Interceptors inside the guards: those of the module, the class and the handler. */
103
+ inner: ClassType$1[];
104
+ }
105
+ /**
106
+ * The guards and interceptors that apply to one handler, in the order they
107
+ * run: the interceptors of the application, then the guards from the module
108
+ * chain, the owning class and the handler, then the interceptors of the same
109
+ * three. A class that appears twice is kept where it first appears.
110
+ *
111
+ * An interceptor of the application sees every execution, denied ones
112
+ * included, as tracing and logging need. One that is attached to handlers runs
113
+ * only for what their guards let through.
114
+ *
115
+ * Throws when the handler would inherit an attribute that the importers of its
116
+ * module do not agree about.
117
+ *
118
+ * Every transport uses this, so the rule is the same everywhere. `runChain`
119
+ * runs the chain.
120
+ */
121
+ export declare function handlerChain(input: HandlerChainInput): HandlerChain;
122
+ /** A handler's chain with its instances, ready to run. */
123
+ interface ResolvedChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown> {
124
+ readonly outer: ReadonlyArray<Interceptor<Ctx, Result>>;
125
+ readonly guards: ReadonlyArray<{
126
+ readonly type: ClassType$1;
127
+ readonly guard: Guard<Ctx>;
128
+ }>;
129
+ readonly inner: ReadonlyArray<Interceptor<Ctx, Result>>;
130
+ }
131
+ /**
132
+ * Resolves the classes of a chain. A transport does this once per handler,
133
+ * while it is set up.
134
+ */
135
+ export declare function resolveChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown>(container: Pick<Container, 'get'>, chain: Pick<HandlerChain, 'outer' | 'guards' | 'inner'>): Promise<ResolvedChain<Ctx, Result>>;
136
+ /**
137
+ * Runs a handler with what applies to it: the outer interceptors, the guards
138
+ * one after another, the inner interceptors, the handler. When a guard refuses,
139
+ * nothing further runs and `onDenied` says what becomes of the execution: what
140
+ * it returns is the result, and what it throws is the failure.
141
+ */
142
+ export declare function runChain<Ctx extends ExecutionContext, Result>(ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType$1) => Result | Promise<Result>): Promise<Result>;
143
+ interface BasicExecutionContextInit {
144
+ /** The transport kind, for example `'cli'`. */
145
+ kind: string;
146
+ id: string;
147
+ handler: HandlerInfo;
148
+ host: ContextHost;
149
+ /** Defaults to a signal of the context's own that never aborts. */
150
+ signal?: AbortSignal;
151
+ }
152
+ /**
153
+ * An `ExecutionContext` for transports that need nothing beyond the neutral
154
+ * contract. The transport creates one per execution and calls `finish()` when
155
+ * the handler is done.
156
+ */
157
+ export declare class BasicExecutionContext implements ExecutionContext {
158
+ readonly kind: string;
159
+ readonly id: string;
160
+ readonly handler: HandlerInfo;
161
+ private readonly host;
162
+ private readonly givenSignal;
163
+ private ownSignal;
164
+ private slots;
165
+ private scope;
166
+ private finishers;
167
+ private finished;
168
+ private finishing;
169
+ constructor(init: BasicExecutionContextInit);
170
+ /** Not shared between contexts: listeners would outlive their execution. */
171
+ get signal(): AbortSignal;
172
+ get<K extends ContextKey>(key: K): ContextValue<K>;
173
+ find<K extends ContextKey>(key: K): ContextValue<K> | undefined;
174
+ set<K extends ContextKey>(key: K, value: ContextValue<K>): void;
175
+ has(key: ContextKey): boolean;
176
+ use: ScopedContainer['getSync'];
177
+ resolve: ScopedContainer['get'];
178
+ onFinish(callback: () => void | Promise<void>): void;
179
+ /**
180
+ * Runs the `onFinish` callbacks in reverse order, those they register
181
+ * included, then disposes the DI scope. Runs once, however often it is
182
+ * called; every caller waits for that run.
183
+ */
184
+ finish(): Promise<void>;
185
+ private runFinishers;
186
+ /** Runs a callback whose failure must not stop what follows. */
187
+ private runFinisher;
188
+ }
189
+ export { type AttributeMap, type BasicExecutionContextInit, type ClassType, type ContextHost, type DecoratorMetadata, type ExecutionContext, type Guard, type GuardClass, type HandlerChain, type HandlerChainInput, type HandlerClassMetadata, type HandlerClassOptions, type HandlerExtras, type HandlerInfo, type Interceptor, type InterceptorClass, type LoggerService, type MethodHandlerMetadata, type ModuleMetadata, type ModuleNode, type ResolvedChain, type Transport, type TransportDefinition, type TransportFactory, type TransportHost, type TransportInstance, buildModuleGraph, constructedInstances, defineTransport, needsScope, runInContext };
190
+ //# sourceMappingURL=transport.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.cts","names":["ClassType","ClassType","ClassType","ClassType","ClassType"],"sources":["../src/metadata/decorator-metadata.mts","../src/modules/module-metadata.mts","../src/metadata/member-metadata.mts","../src/metadata/handler-class.mts","../src/metadata/handler-chain.mts","../src/metadata/run-chain.mts","../src/execution/basic-execution-context.mts"],"mappings":";;;;;;;;;;;;;KACY,oBAAoB,OAAO;UCetB;EACf,SAASA;EACT,QAAQA;EACR,cAAcA;EACd,WAAW;EACX,YAAY;;;;;EAKZ,SAAS;;wBA4FK,kBAAkB,QAAQA,cAAY;wBAYtC,kBAAkB,QAAQA;;;;UCzHzB;EACf,QAAQC;EACR,cAAcA;EACd,YAAY;;;;;;UAOG,8BAA8B;EAC7C;;;;;EAKA,SAAS;;;;;;wBAUK,eACd;EAAW,WAAW;GACtB,eACC;;UCxBc;EACf,SAAS,SAASC;EAClB,eAAe,SAASA;EACxB,aAAa;;;UAIE,6BAA6B;;EAE5C,SAAS,YAAY;;;;;;;;wBASP,qBACd;EAAW,WAAW;GACtB,UAAS,sBACR;UC/BO;WACC,iBAAiBC;WACjB,uBAAuBA;;UAGxB,kBAAkB;WACjB,YAAY;;UAGN;;;;;EAKf,sBAAsBA;;EAEtB,MAAM,SAAS,KAAK;;EAEpB,OAAO;;EAEP,QAAQ;;UAGO;EACf,QAAQA;;EAER,cAAcA;;EAEd,OAAOA;;EAEP,OAAOA;;;;;;;;;;;;;;;;;;wBAmCO,aAAa,OAAO,oBAAoB;;UC1DvC,cAAc,YAAY,mBAAmB,kBAAkB;WACrE,OAAO,cAAc,YAAY,KAAK;WACtC,QAAQ;aAAyB,MAAMC;aAAoB,OAAO,MAAM;;WACxE,OAAO,cAAc,YAAY,KAAK;;;;;;wBAoB3B,aACpB,YAAY,mBAAmB,kBAC/B,kBAEA,WAAW,KAAK,mBAChB,OAAO,KAAK,8CACX,QAAQ,cAAc,KAAK;;;;;;;wBAoCd,SAAS,YAAY,kBAAkB,QACrD,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAOA,gBAAc,SAAS,QAAQ,UAChD,QAAQ;UCtEM;;EAEf;EACA;EACA,SAAS;EACT,MAAM;;EAEN,SAAS;;;;;;;qBAQE,iCAAiC;WACnC;WACA;WACA,SAAS;mBACD;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,MAAM;;MASd,UAAU;EAId,IAAI,UAAU,YAAY,KAAK,IAAI,aAAa;EAWhD,KAAK,UAAU,YAAY,KAAK,IAAI,aAAa;EAIjD,IAAI,UAAU,YAAY,KAAK,GAAG,OAAO,aAAa;EAItD,IAAI,KAAK;EA4BD,KAAK;EAEL,SAAS;EAEjB,SAAS,uBAAuB;;;;;;EAahC,UAAU;UAII;;UAeA"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * What the author of a transport needs and application code does not: the
3
+ * transport contract, the module graph, handler metadata, and the pieces of
4
+ * an execution context.
5
+ *
6
+ * Application code imports from `@navios/core`.
7
+ */
8
+ import { _ as LoggerService, a as TransportDefinition, c as TransportInstance, d as buildModuleGraph, f as ContextHost, i as Transport, l as defineTransport, m as needsScope, o as TransportFactory, r as runInContext, s as TransportHost, u as ModuleNode } from "./async-context-6pdlnNLA.mjs";
9
+ import { ClassType, ClassType as ClassType$1, Container, Provider, ScopedContainer } from "@navios/di";
10
+ import { constructedInstances } from "@navios/di/internal";
11
+ import { a as Interceptor, i as AttributeValue, n as Guard, o as InterceptorClass, r as GuardClass } from "./module-options-Dmse0gii.mjs";
12
+ import { a as ContextValue, i as ContextKey, n as ExecutionContext, r as HandlerInfo, t as AttributeMap } from "./execution-context-BPD3FeFb.mjs";
13
+ /** The `metadata` of a decorator context. */
14
+ type DecoratorMetadata = Record<PropertyKey, unknown>;
15
+ interface ModuleMetadata {
16
+ imports: ClassType$1[];
17
+ guards: ClassType$1[];
18
+ interceptors: ClassType$1[];
19
+ providers: Provider[];
20
+ attributes: Map<symbol, unknown>;
21
+ /**
22
+ * Every option the module system itself does not use, by option name, as
23
+ * written. A transport reads its own from here.
24
+ */
25
+ entries: Map<string, unknown>;
26
+ }
27
+ export declare function getModuleMetadata(target: ClassType$1): ModuleMetadata;
28
+ export declare function hasModuleMetadata(target: ClassType$1): boolean;
29
+ /**
30
+ * What decorators and `handler()` options can attach to a handler.
31
+ */
32
+ interface HandlerExtras {
33
+ guards: ClassType$1[];
34
+ interceptors: ClassType$1[];
35
+ attributes: Map<symbol, unknown>;
36
+ }
37
+ /**
38
+ * A class member that is, or may become, a handler: what decorators attached
39
+ * to it.
40
+ */
41
+ interface MethodHandlerMetadata extends HandlerExtras {
42
+ name: string;
43
+ /**
44
+ * What makes the member a handler of a transport, under that transport's
45
+ * own symbol.
46
+ */
47
+ entries: Map<symbol, unknown>;
48
+ }
49
+ /**
50
+ * What decorators attached to a member, inherited ones included, to read and to
51
+ * add to.
52
+ */
53
+ export declare function memberMetadata(context: {
54
+ metadata?: DecoratorMetadata;
55
+ }, name: string): MethodHandlerMetadata;
56
+ /** What a transport's decorator for handler classes may take. */
57
+ interface HandlerClassOptions {
58
+ guards?: Iterable<ClassType$1>;
59
+ interceptors?: Iterable<ClassType$1>;
60
+ attributes?: AttributeValue[];
61
+ }
62
+ /** A class that owns handlers: what applies to all of them, and its members. */
63
+ interface HandlerClassMetadata extends HandlerExtras {
64
+ /** The members decorators were applied to, by name. */
65
+ members: Map<string, MethodHandlerMetadata>;
66
+ }
67
+ /**
68
+ * What decorators attached to a class of handlers and to its members, together
69
+ * with the options of the class decorator that asks. The lists are live:
70
+ * `@UseGuards` and the like placed above that decorator run after it and are
71
+ * still seen.
72
+ */
73
+ export declare function describeHandlerClass(context: {
74
+ metadata?: DecoratorMetadata;
75
+ }, options?: HandlerClassOptions): HandlerClassMetadata;
76
+ interface Extras {
77
+ readonly guards: readonly ClassType$1[];
78
+ readonly interceptors: readonly ClassType$1[];
79
+ }
80
+ interface OwnExtras extends Extras {
81
+ readonly attributes: ReadonlyMap<symbol, unknown>;
82
+ }
83
+ interface HandlerChainInput {
84
+ /**
85
+ * Interceptors around every handler of the application or of the transport,
86
+ * outermost first.
87
+ */
88
+ application: readonly ClassType$1[];
89
+ /** The module the handler belongs to, with what it inherits. */
90
+ node: Extras & Pick<ModuleNode, 'module' | 'disputed'>;
91
+ /** The class that owns the handler. */
92
+ owner: OwnExtras;
93
+ /** The handler itself. */
94
+ member: OwnExtras;
95
+ }
96
+ interface HandlerChain {
97
+ guards: ClassType$1[];
98
+ /** `outer` and `inner`, one after the other. */
99
+ interceptors: ClassType$1[];
100
+ /** Interceptors around the guards: those of the application. */
101
+ outer: ClassType$1[];
102
+ /** Interceptors inside the guards: those of the module, the class and the handler. */
103
+ inner: ClassType$1[];
104
+ }
105
+ /**
106
+ * The guards and interceptors that apply to one handler, in the order they
107
+ * run: the interceptors of the application, then the guards from the module
108
+ * chain, the owning class and the handler, then the interceptors of the same
109
+ * three. A class that appears twice is kept where it first appears.
110
+ *
111
+ * An interceptor of the application sees every execution, denied ones
112
+ * included, as tracing and logging need. One that is attached to handlers runs
113
+ * only for what their guards let through.
114
+ *
115
+ * Throws when the handler would inherit an attribute that the importers of its
116
+ * module do not agree about.
117
+ *
118
+ * Every transport uses this, so the rule is the same everywhere. `runChain`
119
+ * runs the chain.
120
+ */
121
+ export declare function handlerChain(input: HandlerChainInput): HandlerChain;
122
+ /** A handler's chain with its instances, ready to run. */
123
+ interface ResolvedChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown> {
124
+ readonly outer: ReadonlyArray<Interceptor<Ctx, Result>>;
125
+ readonly guards: ReadonlyArray<{
126
+ readonly type: ClassType$1;
127
+ readonly guard: Guard<Ctx>;
128
+ }>;
129
+ readonly inner: ReadonlyArray<Interceptor<Ctx, Result>>;
130
+ }
131
+ /**
132
+ * Resolves the classes of a chain. A transport does this once per handler,
133
+ * while it is set up.
134
+ */
135
+ export declare function resolveChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown>(container: Pick<Container, 'get'>, chain: Pick<HandlerChain, 'outer' | 'guards' | 'inner'>): Promise<ResolvedChain<Ctx, Result>>;
136
+ /**
137
+ * Runs a handler with what applies to it: the outer interceptors, the guards
138
+ * one after another, the inner interceptors, the handler. When a guard refuses,
139
+ * nothing further runs and `onDenied` says what becomes of the execution: what
140
+ * it returns is the result, and what it throws is the failure.
141
+ */
142
+ export declare function runChain<Ctx extends ExecutionContext, Result>(ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType$1) => Result | Promise<Result>): Promise<Result>;
143
+ interface BasicExecutionContextInit {
144
+ /** The transport kind, for example `'cli'`. */
145
+ kind: string;
146
+ id: string;
147
+ handler: HandlerInfo;
148
+ host: ContextHost;
149
+ /** Defaults to a signal of the context's own that never aborts. */
150
+ signal?: AbortSignal;
151
+ }
152
+ /**
153
+ * An `ExecutionContext` for transports that need nothing beyond the neutral
154
+ * contract. The transport creates one per execution and calls `finish()` when
155
+ * the handler is done.
156
+ */
157
+ export declare class BasicExecutionContext implements ExecutionContext {
158
+ readonly kind: string;
159
+ readonly id: string;
160
+ readonly handler: HandlerInfo;
161
+ private readonly host;
162
+ private readonly givenSignal;
163
+ private ownSignal;
164
+ private slots;
165
+ private scope;
166
+ private finishers;
167
+ private finished;
168
+ private finishing;
169
+ constructor(init: BasicExecutionContextInit);
170
+ /** Not shared between contexts: listeners would outlive their execution. */
171
+ get signal(): AbortSignal;
172
+ get<K extends ContextKey>(key: K): ContextValue<K>;
173
+ find<K extends ContextKey>(key: K): ContextValue<K> | undefined;
174
+ set<K extends ContextKey>(key: K, value: ContextValue<K>): void;
175
+ has(key: ContextKey): boolean;
176
+ use: ScopedContainer['getSync'];
177
+ resolve: ScopedContainer['get'];
178
+ onFinish(callback: () => void | Promise<void>): void;
179
+ /**
180
+ * Runs the `onFinish` callbacks in reverse order, those they register
181
+ * included, then disposes the DI scope. Runs once, however often it is
182
+ * called; every caller waits for that run.
183
+ */
184
+ finish(): Promise<void>;
185
+ private runFinishers;
186
+ /** Runs a callback whose failure must not stop what follows. */
187
+ private runFinisher;
188
+ }
189
+ export { type AttributeMap, type BasicExecutionContextInit, type ClassType, type ContextHost, type DecoratorMetadata, type ExecutionContext, type Guard, type GuardClass, type HandlerChain, type HandlerChainInput, type HandlerClassMetadata, type HandlerClassOptions, type HandlerExtras, type HandlerInfo, type Interceptor, type InterceptorClass, type LoggerService, type MethodHandlerMetadata, type ModuleMetadata, type ModuleNode, type ResolvedChain, type Transport, type TransportDefinition, type TransportFactory, type TransportHost, type TransportInstance, buildModuleGraph, constructedInstances, defineTransport, needsScope, runInContext };
190
+ //# sourceMappingURL=transport.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.mts","names":["ClassType","ClassType","ClassType","ClassType","ClassType"],"sources":["../src/metadata/decorator-metadata.mts","../src/modules/module-metadata.mts","../src/metadata/member-metadata.mts","../src/metadata/handler-class.mts","../src/metadata/handler-chain.mts","../src/metadata/run-chain.mts","../src/execution/basic-execution-context.mts"],"mappings":";;;;;;;;;;;;;KACY,oBAAoB,OAAO;UCetB;EACf,SAASA;EACT,QAAQA;EACR,cAAcA;EACd,WAAW;EACX,YAAY;;;;;EAKZ,SAAS;;wBA4FK,kBAAkB,QAAQA,cAAY;wBAYtC,kBAAkB,QAAQA;;;;UCzHzB;EACf,QAAQC;EACR,cAAcA;EACd,YAAY;;;;;;UAOG,8BAA8B;EAC7C;;;;;EAKA,SAAS;;;;;;wBAUK,eACd;EAAW,WAAW;GACtB,eACC;;UCxBc;EACf,SAAS,SAASC;EAClB,eAAe,SAASA;EACxB,aAAa;;;UAIE,6BAA6B;;EAE5C,SAAS,YAAY;;;;;;;;wBASP,qBACd;EAAW,WAAW;GACtB,UAAS,sBACR;UC/BO;WACC,iBAAiBC;WACjB,uBAAuBA;;UAGxB,kBAAkB;WACjB,YAAY;;UAGN;;;;;EAKf,sBAAsBA;;EAEtB,MAAM,SAAS,KAAK;;EAEpB,OAAO;;EAEP,QAAQ;;UAGO;EACf,QAAQA;;EAER,cAAcA;;EAEd,OAAOA;;EAEP,OAAOA;;;;;;;;;;;;;;;;;;wBAmCO,aAAa,OAAO,oBAAoB;;UC1DvC,cAAc,YAAY,mBAAmB,kBAAkB;WACrE,OAAO,cAAc,YAAY,KAAK;WACtC,QAAQ;aAAyB,MAAMC;aAAoB,OAAO,MAAM;;WACxE,OAAO,cAAc,YAAY,KAAK;;;;;;wBAoB3B,aACpB,YAAY,mBAAmB,kBAC/B,kBAEA,WAAW,KAAK,mBAChB,OAAO,KAAK,8CACX,QAAQ,cAAc,KAAK;;;;;;;wBAoCd,SAAS,YAAY,kBAAkB,QACrD,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAOA,gBAAc,SAAS,QAAQ,UAChD,QAAQ;UCtEM;;EAEf;EACA;EACA,SAAS;EACT,MAAM;;EAEN,SAAS;;;;;;;qBAQE,iCAAiC;WACnC;WACA;WACA,SAAS;mBACD;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,MAAM;;MASd,UAAU;EAId,IAAI,UAAU,YAAY,KAAK,IAAI,aAAa;EAWhD,KAAK,UAAU,YAAY,KAAK,IAAI,aAAa;EAIjD,IAAI,UAAU,YAAY,KAAK,GAAG,OAAO,aAAa;EAItD,IAAI,KAAK;EA4BD,KAAK;EAEL,SAAS;EAEjB,SAAS,uBAAuB;;;;;;EAahC,UAAU;UAII;;UAeA"}
@@ -0,0 +1,7 @@
1
+ import { r as memberMetadata } from "./attribute-value-DMEA255r.mjs";
2
+ import { a as describeHandlerClass, i as handlerChain, n as resolveChain, o as defineTransport, r as runChain, t as BasicExecutionContext } from "./basic-execution-context-CeGuhMOz.mjs";
3
+ import { constructedInstances } from "@navios/di/internal";
4
+ import { t as buildModuleGraph } from "./module-graph-xvVEykFM.mjs";
5
+ import { a as hasModuleMetadata, i as getModuleMetadata } from "./module-metadata-k3RTt20x.mjs";
6
+ import { o as runInContext, r as needsScope } from "./execution-context-token-CrXmTvk2.mjs";
7
+ export { BasicExecutionContext, buildModuleGraph, constructedInstances, defineTransport, describeHandlerClass, getModuleMetadata, handlerChain, hasModuleMetadata, memberMetadata, needsScope, resolveChain, runChain, runInContext };
package/package.json CHANGED
@@ -1,23 +1,25 @@
1
1
  {
2
2
  "name": "@navios/core",
3
- "version": "1.0.0",
3
+ "version": "2.0.0-alpha.0",
4
+ "license": "MIT",
4
5
  "author": {
5
6
  "name": "Oleksandr Hanzha",
6
7
  "email": "alex@granted.name"
7
8
  },
8
9
  "repository": {
9
- "directory": "packages/core",
10
10
  "type": "git",
11
- "url": "https://github.com/Arilas/navios.git"
12
- },
13
- "license": "MIT",
14
- "peerDependencies": {
15
- "@navios/builder": "^1.0.0",
16
- "zod": "^3.25.0 || ^4.0.0"
11
+ "url": "https://github.com/navios-org/navios.git",
12
+ "directory": "packages/core"
17
13
  },
18
- "typings": "./lib/index.d.mts",
14
+ "files": [
15
+ "lib",
16
+ "README.md",
17
+ "CHANGELOG.md",
18
+ "LICENSE"
19
+ ],
19
20
  "main": "./lib/index.cjs",
20
21
  "module": "./lib/index.mjs",
22
+ "typings": "./lib/index.d.mts",
21
23
  "exports": {
22
24
  ".": {
23
25
  "import": {
@@ -29,6 +31,16 @@
29
31
  "default": "./lib/index.cjs"
30
32
  }
31
33
  },
34
+ "./transport": {
35
+ "import": {
36
+ "types": "./lib/transport.d.mts",
37
+ "default": "./lib/transport.mjs"
38
+ },
39
+ "require": {
40
+ "types": "./lib/transport.d.cts",
41
+ "default": "./lib/transport.cjs"
42
+ }
43
+ },
32
44
  "./testing": {
33
45
  "import": {
34
46
  "types": "./lib/testing/index.d.mts",
@@ -50,15 +62,23 @@
50
62
  }
51
63
  }
52
64
  },
53
- "devDependencies": {
54
- "@navios/builder": "^1.0.0",
55
- "@types/supertest": "^6.0.3",
56
- "supertest": "^7.1.4",
57
- "tsx": "^4.21.0",
58
- "typescript": "^5.9.3",
59
- "zod": "^4.2.1"
65
+ "scripts": {
66
+ "check": "tsc -b",
67
+ "lint": "yarn run -T oxlint --fix && yarn run -T oxfmt",
68
+ "test:ci": "vitest run",
69
+ "build": "tsdown",
70
+ "publish": "node ../../scripts/assert-stable-version.mjs && yarn npm publish --access public",
71
+ "publish:next": "yarn npm publish --access public --tag next"
60
72
  },
61
73
  "dependencies": {
62
- "@navios/di": "^1.0.0"
74
+ "@navios/di": "2.0.0-alpha.0"
75
+ },
76
+ "devDependencies": {
77
+ "tsx": "^4.23.15",
78
+ "typescript": "^7.0.2",
79
+ "zod": "^4.6.7"
80
+ },
81
+ "engines": {
82
+ "node": ">=24"
63
83
  }
64
84
  }