@navios/core 1.1.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 (241) hide show
  1. package/CHANGELOG.md +53 -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 -4424
  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-3LcTrbxz.d.mts +0 -3804
  88. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  89. package/lib/index-B14SekVb.d.cts +0 -3804
  90. package/lib/index-B14SekVb.d.cts.map +0 -1
  91. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  92. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  93. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  94. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  95. package/lib/tokens-BEuBMGGX.cjs +0 -193
  96. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  97. package/lib/tokens-COyNGV1I.mjs +0 -97
  98. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  99. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  100. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  101. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  102. package/lib/use-guards.decorator-DhumFTk3.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 -14
  159. package/src/interfaces/navios-module.mts +0 -28
  160. package/src/interfaces/plugin-context.mts +0 -104
  161. package/src/interfaces/plugin-stage.mts +0 -62
  162. package/src/interfaces/plugin.interface.mts +0 -119
  163. package/src/interfaces/staged-plugin.interface.mts +0 -209
  164. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  165. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  166. package/src/legacy-compat/attribute.factory.mts +0 -351
  167. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  168. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  169. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  170. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  171. package/src/legacy-compat/decorators/index.mts +0 -11
  172. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  173. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  174. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  175. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  176. package/src/legacy-compat/index.mts +0 -57
  177. package/src/logger/README.md +0 -3
  178. package/src/logger/console-logger.service.mts +0 -714
  179. package/src/logger/index.mts +0 -6
  180. package/src/logger/log-levels.mts +0 -21
  181. package/src/logger/logger-service.interface.mts +0 -42
  182. package/src/logger/logger.service.mts +0 -113
  183. package/src/logger/logger.tokens.mts +0 -44
  184. package/src/logger/utils/cli-colors.util.mts +0 -17
  185. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  186. package/src/logger/utils/index.mts +0 -5
  187. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  188. package/src/logger/utils/is-log-level.util.mts +0 -10
  189. package/src/logger/utils/shared.utils.mts +0 -51
  190. package/src/metadata/controller.metadata.mts +0 -79
  191. package/src/metadata/handler.metadata.mts +0 -80
  192. package/src/metadata/index.mts +0 -4
  193. package/src/metadata/module.metadata.mts +0 -116
  194. package/src/metadata/navios-managed.metadata.mts +0 -42
  195. package/src/navios.application.mts +0 -678
  196. package/src/navios.environment.mts +0 -42
  197. package/src/navios.factory.mts +0 -158
  198. package/src/responders/enums/framework-error.enum.mts +0 -38
  199. package/src/responders/enums/index.mts +0 -1
  200. package/src/responders/index.mts +0 -4
  201. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  202. package/src/responders/interfaces/error-response.interface.mts +0 -22
  203. package/src/responders/interfaces/index.mts +0 -3
  204. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  205. package/src/responders/services/error-response-producer.service.mts +0 -143
  206. package/src/responders/services/forbidden-responder.service.mts +0 -77
  207. package/src/responders/services/index.mts +0 -5
  208. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  209. package/src/responders/services/not-found-responder.service.mts +0 -76
  210. package/src/responders/services/validation-error-responder.service.mts +0 -78
  211. package/src/responders/tokens/index.mts +0 -1
  212. package/src/responders/tokens/responder.tokens.mts +0 -84
  213. package/src/services/abstract-handler-adapter.service.mts +0 -366
  214. package/src/services/guard-runner.service.mts +0 -152
  215. package/src/services/index.mts +0 -4
  216. package/src/services/instance-resolver.service.mts +0 -177
  217. package/src/services/module-loader.service.mts +0 -255
  218. package/src/stores/index.mts +0 -1
  219. package/src/stores/request-id.store.mts +0 -85
  220. package/src/testing/index.mts +0 -3
  221. package/src/testing/testing-module.mts +0 -393
  222. package/src/testing/unit-testing-module.mts +0 -298
  223. package/src/tokens/adapter.token.mts +0 -6
  224. package/src/tokens/endpoint-adapter.token.mts +0 -8
  225. package/src/tokens/execution-context.token.mts +0 -9
  226. package/src/tokens/http-adapter.token.mts +0 -8
  227. package/src/tokens/index.mts +0 -10
  228. package/src/tokens/multipart-adapter.token.mts +0 -8
  229. package/src/tokens/navios-options.token.mts +0 -6
  230. package/src/tokens/reply.token.mts +0 -3
  231. package/src/tokens/request.token.mts +0 -3
  232. package/src/tokens/stream-adapter.token.mts +0 -8
  233. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  234. package/src/utils/adapter-supports.util.mts +0 -47
  235. package/src/utils/define-plugin.mts +0 -251
  236. package/src/utils/index.mts +0 -2
  237. package/tsconfig.json +0 -21
  238. package/tsconfig.lib.json +0 -8
  239. package/tsconfig.spec.json +0 -15
  240. package/tsdown.config.mts +0 -35
  241. package/vitest.config.mts +0 -15
@@ -0,0 +1,237 @@
1
+ import { n as ExecutionContext } from "./execution-context-BTJdHhbf.cjs";
2
+ import { AnyInjectableType, ClassType, Container, InjectionToken, Provider } from "@navios/di";
3
+ /**
4
+ * Available log levels in order of severity (lowest to highest).
5
+ */
6
+ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
7
+ /**
8
+ * Log level type.
9
+ *
10
+ * Represents the severity level of a log message.
11
+ * Levels are: 'verbose', 'debug', 'log', 'warn', 'error', 'fatal'
12
+ *
13
+ * @publicApi
14
+ */
15
+ type LogLevel = (typeof LOG_LEVELS)[number];
16
+ /**
17
+ * @publicApi
18
+ */
19
+ declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
20
+ /**
21
+ * Reads log levels out of a setting: `'error'`, `'warn,error'`, `'>=warn'` or
22
+ * `'>warn'`. An empty string stands for every level.
23
+ * @publicApi
24
+ */
25
+ declare function filterLogLevels(parseableString?: string): LogLevel[];
26
+ /**
27
+ * @publicApi
28
+ */
29
+ interface LoggerService {
30
+ /**
31
+ * Write a 'log' level log.
32
+ */
33
+ log(message: any, ...optionalParams: any[]): any;
34
+ /**
35
+ * Write an 'error' level log.
36
+ */
37
+ error(message: any, ...optionalParams: any[]): any;
38
+ /**
39
+ * Write a 'warn' level log.
40
+ */
41
+ warn(message: any, ...optionalParams: any[]): any;
42
+ /**
43
+ * Write a 'debug' level log.
44
+ */
45
+ debug?(message: any, ...optionalParams: any[]): any;
46
+ /**
47
+ * Write a 'verbose' level log.
48
+ */
49
+ verbose?(message: any, ...optionalParams: any[]): any;
50
+ /**
51
+ * Write a 'fatal' level log.
52
+ */
53
+ fatal?(message: any, ...optionalParams: any[]): any;
54
+ /**
55
+ * Set log levels.
56
+ * @param levels log levels
57
+ */
58
+ setLogLevels?(levels: LogLevel[]): any;
59
+ }
60
+ /**
61
+ * Injection token for the logger output service.
62
+ *
63
+ * This token is used to provide a custom logger implementation.
64
+ * By default, it's bound to ConsoleLogger.
65
+ */
66
+ declare const LoggerOutput: InjectionToken<LoggerService, undefined, false>;
67
+ /**
68
+ * The parameters of a function that takes options: they may be left out when
69
+ * none of them is required.
70
+ */
71
+ type OptionsArgument<Options, Rest extends unknown[] = []> = {} extends Options ? [options?: Options, ...rest: Rest] : [options: Options, ...rest: Rest];
72
+ /**
73
+ * Dependencies shared by every execution context of an application.
74
+ */
75
+ interface ContextHost {
76
+ readonly container: Container;
77
+ /**
78
+ * Called when a token is used through a context; may throw. Does nothing for
79
+ * a token that `needsScope` is false for.
80
+ */
81
+ onScopedUse: ((token: AnyInjectableType) => void) | null;
82
+ /** Receives what an `onFinish` callback throws; without it that is dropped. */
83
+ readonly logger?: Pick<LoggerService, 'error'>;
84
+ }
85
+ /**
86
+ * Whether a context resolves `token` from a DI scope of its execution. A
87
+ * singleton is the same in all of them.
88
+ */
89
+ declare function needsScope(container: Container, token: AnyInjectableType): boolean;
90
+ /**
91
+ * Builds the host for an application's contexts, applying its policy for
92
+ * request-scoped services.
93
+ */
94
+ declare function createContextHost(container: Container, mode: 'allow' | 'warn' | 'forbid', logger: LoggerService): ContextHost;
95
+ /**
96
+ * A module as it applies to one application: its guards, interceptors and
97
+ * attributes together with those it inherits, and the modules that import it.
98
+ */
99
+ interface ModuleNode {
100
+ module: ClassType;
101
+ providers: Provider[];
102
+ /** The module's transport-specific options, by option name. */
103
+ entries: ReadonlyMap<string, unknown>;
104
+ guards: ClassType[];
105
+ interceptors: ClassType[];
106
+ attributes: Map<symbol, unknown>;
107
+ /**
108
+ * The attributes that the importers of the module do not agree about, and what
109
+ * each of two import paths gives it. They are not among `attributes`;
110
+ * `handlerChain` refuses a handler that would inherit one.
111
+ */
112
+ disputed: ReadonlyMap<symbol, string>;
113
+ /** The modules that import this one, in the order they were reached. */
114
+ importers: ModuleNode[];
115
+ /** Whether the module was given to the application directly. */
116
+ isRoot: boolean;
117
+ }
118
+ /**
119
+ * Walks the import graph from the given roots and computes, for this
120
+ * application only, what applies to each module.
121
+ *
122
+ * - Guards and interceptors are the union over every path that reaches a
123
+ * module, outermost first: what the importers contribute, importers in
124
+ * import order, then the module's own. Nothing is written back to the
125
+ * classes, so two applications importing one module under different parents
126
+ * do not affect each other.
127
+ * - An attribute comes from the module itself or else from what imports it.
128
+ * One that the importers do not agree about is in `disputed` instead.
129
+ *
130
+ * Neither depends on the order in which a module happens to be reached.
131
+ * Modules are returned in dependency order: a module comes after everything
132
+ * it imports. That cannot be done for modules that import each other, which is
133
+ * an error as well.
134
+ */
135
+ declare function buildModuleGraph(roots: ClassType[]): ModuleNode[];
136
+ /**
137
+ * What the application gives a transport when it creates it.
138
+ */
139
+ interface TransportHost {
140
+ readonly container: Container;
141
+ readonly logger: LoggerService;
142
+ /** For the transport's execution contexts. */
143
+ readonly contextHost: ContextHost;
144
+ /** Whether the application keeps the current context in an async store. */
145
+ readonly asyncContext: boolean;
146
+ /**
147
+ * Interceptors around every handler of the application, outermost first.
148
+ * Complete once `setup()` is called.
149
+ */
150
+ readonly interceptors: readonly ClassType[];
151
+ }
152
+ /**
153
+ * One way work reaches the application: an HTTP server, a queue consumer, a
154
+ * command line. The application creates it, hands it the module graph, and
155
+ * starts and stops it together with the others.
156
+ */
157
+ interface Transport {
158
+ /**
159
+ * Reads the module graph and prepares the transport's handlers. Must not
160
+ * start accepting work.
161
+ */
162
+ setup(graph: readonly ModuleNode[]): void | Promise<void>;
163
+ /** Starts accepting work. Called at most once. */
164
+ start?(): void | Promise<void>;
165
+ /**
166
+ * Stops accepting work and waits, up to `timeoutMs`, for what is in flight.
167
+ * One that takes much longer is left behind. When the application fails to
168
+ * initialise or to start it is called for every transport that was created,
169
+ * with no time to wait and possibly before `setup` or `start` ran; it must
170
+ * release what `create` acquired. Called once, and again when `start` settles
171
+ * only after that.
172
+ */
173
+ stop(timeoutMs: number): void | Promise<void>;
174
+ }
175
+ interface TransportDefinition<Options, T extends Transport> {
176
+ /** The kind of transport, and the default name of an instance. */
177
+ name: string;
178
+ create(host: TransportHost, options: Options): T | Promise<T>;
179
+ }
180
+ /**
181
+ * A transport as it is listed in an application's options.
182
+ */
183
+ interface TransportInstance<T extends Transport = Transport> {
184
+ readonly definition: TransportDefinition<any, T>;
185
+ /** `{}` when the transport was given none. */
186
+ readonly options: unknown;
187
+ /** Unique within the application. Defaults to the definition's name. */
188
+ readonly instanceName: string;
189
+ }
190
+ /**
191
+ * What `defineTransport` returns: called with options it gives the instance
192
+ * to list in an application, and it is the key to look the transport up with.
193
+ */
194
+ interface TransportFactory<Options, T extends Transport> {
195
+ (...args: OptionsArgument<Options, [instanceName?: string]>): TransportInstance<T>;
196
+ readonly definition: TransportDefinition<Options, T>;
197
+ }
198
+ /**
199
+ * Defines a transport.
200
+ *
201
+ * ```ts
202
+ * export const queueTransport = defineTransport({
203
+ * name: 'queue',
204
+ * create(host, options: { url: string }) {
205
+ * return new QueueTransport(host, options)
206
+ * },
207
+ * })
208
+ *
209
+ * const app = createApplication(AppModule, {
210
+ * transports: [queueTransport({ url })],
211
+ * })
212
+ * await app.start()
213
+ * app.transport(queueTransport) // the QueueTransport
214
+ * ```
215
+ *
216
+ * An application can hold several transports of one definition when each has
217
+ * its own name: `queueTransport({ url }, 'orders')`.
218
+ */
219
+ declare function defineTransport<Options = void, T extends Transport = Transport>(definition: TransportDefinition<Options, T>): TransportFactory<Options, T>;
220
+ /**
221
+ * Turns on the async context: one `AsyncLocalStorage` holding the current
222
+ * `ExecutionContext`. The `asyncContext: true` option of an application does it.
223
+ */
224
+ declare function enableAsyncContext(): Promise<void>;
225
+ /**
226
+ * Runs `fn` with `ctx` as the current context. A transport does this when its
227
+ * host says that the application has an async context.
228
+ */
229
+ declare function runInContext<R>(ctx: ExecutionContext, fn: () => R): R;
230
+ /**
231
+ * The context of the handler being run, for code that cannot receive it as an
232
+ * argument. Returns `undefined` outside a handler, and always when the
233
+ * application was not created with `asyncContext: true`.
234
+ */
235
+ declare function currentContext(): ExecutionContext | undefined;
236
+ export { LoggerService as _, TransportDefinition as a, filterLogLevels as b, TransportInstance as c, buildModuleGraph as d, ContextHost as f, LoggerOutput as g, OptionsArgument as h, Transport as i, defineTransport as l, needsScope as m, enableAsyncContext as n, TransportFactory as o, createContextHost as p, runInContext as r, TransportHost as s, currentContext as t, ModuleNode as u, LOG_LEVELS as v, isLogLevel as x, LogLevel as y };
237
+ //# sourceMappingURL=async-context-Dqk7pE-D.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-context-Dqk7pE-D.d.cts","names":[],"sources":["../src/logger/log-levels.mts","../src/logger/logger-output.mts","../src/internal/options-argument.mts","../src/execution/context-host.mts","../src/modules/module-graph.mts","../src/transports/transport.mts","../src/execution/async-context.mts"],"mappings":";;;;;cAGa;;;;;;;;;KAiBD,mBAAmB;;;;iBAKf,WAAW,qBAAqB,iBAAiB;;;;;;iBAgDjD,gBAAgB,2BAAuB;;;;UClEtC;;;;EAIf,IAAI,iBAAiB;;;;EAKrB,MAAM,iBAAiB;;;;EAKvB,KAAK,iBAAiB;;;;EAKtB,OAAO,iBAAiB;;;;EAKxB,SAAS,iBAAiB;;;;EAK1B,OAAO,iBAAiB;;;;;EAMxB,cAAc,QAAQ;;;;;;;;cASX,cAAY,eAAA;;;;;KC/Cb,gBAAgB,SAAS,0CAA0C,WAC1E,UAAU,YAAY,MAAM,SAC5B,SAAS,YAAY,MAAM;;;;UCGf;WACN,WAAW;;;;;EAKpB,eAAe,OAAO;;WAEb,SAAS,KAAK;;;;;;iBAsBT,WAAW,WAAW,WAAW,OAAO;;;;;iBAQxC,kBACd,WAAW,WACX,mCACA,QAAQ,gBACP;;;;;UCvCc;EACf,QAAQ;EACR,WAAW;;EAEX,SAAS;EACT,QAAQ;EACR,cAAc;EACd,YAAY;;;;;;EAMZ,UAAU;;EAEV,WAAW;;EAEX;;;;;;;;;;;;;;;;;;;iBAgHc,iBAAiB,OAAO,cAAc;;;;UCjIrC;WACN,WAAW;WACX,QAAQ;;WAER,aAAa;;WAEb;;;;;WAKA,uBAAuB;;;;;;;UAQjB;;;;;EAKf,MAAM,gBAAgB,sBAAsB;;EAE5C,iBAAiB;;;;;;;;;EASjB,KAAK,2BAA2B;;UAGjB,oBAAoB,SAAS,UAAU;;EAEtD;EACA,OAAO,MAAM,eAAe,SAAS,UAAU,IAAI,QAAQ;;;;;UAM5C,kBAAkB,UAAU,YAAY;WAC9C,YAAY,yBAAyB;;WAErC;;WAEA;;;;;;UAOM,iBAAiB,SAAS,UAAU;MAC/C,MAAM,gBAAgB,UAAU,0BAA0B,kBAAkB;WACvE,YAAY,oBAAoB,SAAS;;;;;;;;;;;;;;;;;;;;;;;iBAwBpC,gBAAgB,gBAAgB,UAAU,YAAY,WACpE,YAAY,oBAAoB,SAAS,KACxC,iBAAiB,SAAS;;;;;iBCtFP,sBAAsB;;;;;iBAW5B,aAAa,GAAG,KAAK,kBAAkB,UAAU,IAAI;;;;;;iBASrD,kBAAkB"}
@@ -0,0 +1,70 @@
1
+ import { InferInput, InferOutput, StandardSchemaV1 } from "@navios/di";
2
+ import { r as HandlerInfo } from "./execution-context-BTJdHhbf.cjs";
3
+ type AttributeContext = ClassDecoratorContext | ClassMethodDecoratorContext | ClassFieldDecoratorContext;
4
+ /**
5
+ * The result of calling an attribute. It is a decorator for a module, a
6
+ * controller, a handler method or a handler field, and it can also be passed
7
+ * in `handler(endpoint, { attributes: [...] }, fn)`.
8
+ */
9
+ interface AttributeApplication {
10
+ (target: any, context: AttributeContext): any;
11
+ readonly token: symbol;
12
+ readonly value: unknown;
13
+ }
14
+ interface ClassAttribute {
15
+ (): AttributeApplication;
16
+ readonly token: symbol;
17
+ }
18
+ interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {
19
+ (value: InferInput<Schema>): AttributeApplication;
20
+ readonly token: symbol;
21
+ readonly schema: Schema;
22
+ }
23
+ /**
24
+ * What reading an attribute needs of it. An attribute of either factory, the
25
+ * standard one or the one from `@navios/core/legacy-compat`, has this shape;
26
+ * what calling it returns differs between the two and does not matter here.
27
+ */
28
+ interface ReadableAttribute {
29
+ readonly token: symbol;
30
+ readonly schema?: undefined;
31
+ }
32
+ interface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {
33
+ readonly token: symbol;
34
+ readonly schema: Schema;
35
+ }
36
+ type AttributeSource = HandlerInfo | {
37
+ attributes: ReadonlyMap<symbol, unknown>;
38
+ };
39
+ /**
40
+ * Creates and reads attributes: typed metadata attached to modules,
41
+ * controllers and handlers.
42
+ *
43
+ * ```ts
44
+ * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
45
+ * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))
46
+ *
47
+ * if (AttributeFactory.has(Public, ctx.handler)) return true
48
+ * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null
49
+ * ```
50
+ */
51
+ declare class AttributeFactory {
52
+ static createAttribute(token: symbol): ClassAttribute;
53
+ static createAttribute<Schema extends StandardSchemaV1>(token: symbol, schema: Schema): ClassSchemaAttribute<Schema>;
54
+ /**
55
+ * The attribute's value for a handler: the handler's own, else the controller's,
56
+ * else the module's. `null` when none has it.
57
+ */
58
+ static get(attribute: ReadableAttribute, source: AttributeSource): true | null;
59
+ static get<Schema extends StandardSchemaV1>(attribute: ReadableSchemaAttribute<Schema>, source: AttributeSource): InferOutput<Schema> | null;
60
+ /**
61
+ * Every value of the attribute for a handler, most specific first.
62
+ */
63
+ static getAll(attribute: ReadableAttribute, source: AttributeSource): true[];
64
+ static getAll<Schema extends StandardSchemaV1>(attribute: ReadableSchemaAttribute<Schema>, source: AttributeSource): InferOutput<Schema>[];
65
+ static has(attribute: {
66
+ token: symbol;
67
+ }, source: AttributeSource): boolean;
68
+ }
69
+ export { ClassSchemaAttribute as i, AttributeFactory as n, ClassAttribute as r, AttributeApplication as t };
70
+ //# sourceMappingURL=attribute-factory-B3VuYnp7.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-factory-B3VuYnp7.d.cts","names":[],"sources":["../src/attributes/attribute-factory.mts"],"mappings":";;KASK,mBACD,wBACA,8BACA;;;;;;UAOa;GACd,aAAa,SAAS;WACd;WACA;;UAGM;MACX;WACK;;UAGM,qBAAqB,eAAe;GAClD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;;;;;;UAyBT;WACC;WACA;;UAGD,wBAAwB,eAAe;WACtC;WACA,QAAQ;;KAGd,kBAAkB;EAAgB,YAAY;;;;;;;;;;;;;;cAwBtC;SACJ,gBAAgB,gBAAgB;SAChC,gBAAgB,eAAe,kBACpC,eACA,QAAQ,SACP,qBAAqB;;;;;SA6BjB,IAAI,WAAW,mBAAmB,QAAQ;SAC1C,IAAI,eAAe,kBACxB,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;;;;SAaR,OAAO,WAAW,mBAAmB,QAAQ;SAC7C,OAAO,eAAe,kBAC3B,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;SAWR,IAAI;IAAa;KAAiB,QAAQ"}
@@ -0,0 +1,70 @@
1
+ import { InferInput, InferOutput, StandardSchemaV1 } from "@navios/di";
2
+ import { r as HandlerInfo } from "./execution-context-BPD3FeFb.mjs";
3
+ type AttributeContext = ClassDecoratorContext | ClassMethodDecoratorContext | ClassFieldDecoratorContext;
4
+ /**
5
+ * The result of calling an attribute. It is a decorator for a module, a
6
+ * controller, a handler method or a handler field, and it can also be passed
7
+ * in `handler(endpoint, { attributes: [...] }, fn)`.
8
+ */
9
+ interface AttributeApplication {
10
+ (target: any, context: AttributeContext): any;
11
+ readonly token: symbol;
12
+ readonly value: unknown;
13
+ }
14
+ interface ClassAttribute {
15
+ (): AttributeApplication;
16
+ readonly token: symbol;
17
+ }
18
+ interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {
19
+ (value: InferInput<Schema>): AttributeApplication;
20
+ readonly token: symbol;
21
+ readonly schema: Schema;
22
+ }
23
+ /**
24
+ * What reading an attribute needs of it. An attribute of either factory, the
25
+ * standard one or the one from `@navios/core/legacy-compat`, has this shape;
26
+ * what calling it returns differs between the two and does not matter here.
27
+ */
28
+ interface ReadableAttribute {
29
+ readonly token: symbol;
30
+ readonly schema?: undefined;
31
+ }
32
+ interface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {
33
+ readonly token: symbol;
34
+ readonly schema: Schema;
35
+ }
36
+ type AttributeSource = HandlerInfo | {
37
+ attributes: ReadonlyMap<symbol, unknown>;
38
+ };
39
+ /**
40
+ * Creates and reads attributes: typed metadata attached to modules,
41
+ * controllers and handlers.
42
+ *
43
+ * ```ts
44
+ * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
45
+ * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))
46
+ *
47
+ * if (AttributeFactory.has(Public, ctx.handler)) return true
48
+ * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null
49
+ * ```
50
+ */
51
+ declare class AttributeFactory {
52
+ static createAttribute(token: symbol): ClassAttribute;
53
+ static createAttribute<Schema extends StandardSchemaV1>(token: symbol, schema: Schema): ClassSchemaAttribute<Schema>;
54
+ /**
55
+ * The attribute's value for a handler: the handler's own, else the controller's,
56
+ * else the module's. `null` when none has it.
57
+ */
58
+ static get(attribute: ReadableAttribute, source: AttributeSource): true | null;
59
+ static get<Schema extends StandardSchemaV1>(attribute: ReadableSchemaAttribute<Schema>, source: AttributeSource): InferOutput<Schema> | null;
60
+ /**
61
+ * Every value of the attribute for a handler, most specific first.
62
+ */
63
+ static getAll(attribute: ReadableAttribute, source: AttributeSource): true[];
64
+ static getAll<Schema extends StandardSchemaV1>(attribute: ReadableSchemaAttribute<Schema>, source: AttributeSource): InferOutput<Schema>[];
65
+ static has(attribute: {
66
+ token: symbol;
67
+ }, source: AttributeSource): boolean;
68
+ }
69
+ export { ClassSchemaAttribute as i, AttributeFactory as n, ClassAttribute as r, AttributeApplication as t };
70
+ //# sourceMappingURL=attribute-factory-mKOXoVnV.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-factory-mKOXoVnV.d.mts","names":[],"sources":["../src/attributes/attribute-factory.mts"],"mappings":";;KASK,mBACD,wBACA,8BACA;;;;;;UAOa;GACd,aAAa,SAAS;WACd;WACA;;UAGM;MACX;WACK;;UAGM,qBAAqB,eAAe;GAClD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;;;;;;UAyBT;WACC;WACA;;UAGD,wBAAwB,eAAe;WACtC;WACA,QAAQ;;KAGd,kBAAkB;EAAgB,YAAY;;;;;;;;;;;;;;cAwBtC;SACJ,gBAAgB,gBAAgB;SAChC,gBAAgB,eAAe,kBACpC,eACA,QAAQ,SACP,qBAAqB;;;;;SA6BjB,IAAI,WAAW,mBAAmB,QAAQ;SAC1C,IAAI,eAAe,kBACxB,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;;;;SAaR,OAAO,WAAW,mBAAmB,QAAQ;SAC7C,OAAO,eAAe,kBAC3B,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;SAWR,IAAI;IAAa;KAAiB,QAAQ"}
@@ -0,0 +1,172 @@
1
+ // src/internal/single-copy.mts
2
+ /**
3
+ * Warns when a second copy of this package is loaded into the process.
4
+ *
5
+ * Several things only work with one copy: `@Module` options that other
6
+ * packages add by declaration merging, the async store behind
7
+ * `currentContext()`, and `instanceof` checks on context keys. Two copies
8
+ * usually mean two versions were installed, or one package bundled its own.
9
+ */
10
+ const registryKey = Symbol.for("navios.core.copies");
11
+ function registerCopy(url, warn) {
12
+ if (typeof url !== "string") return;
13
+ const location = url.replace(/[?#].*$/, "");
14
+ const holder = globalThis;
15
+ const registry = holder[registryKey] ??= {
16
+ locations: /* @__PURE__ */ new Set(),
17
+ warned: false
18
+ };
19
+ if (registry.locations.has(location)) return;
20
+ registry.locations.add(location);
21
+ if (registry.locations.size > 1 && !registry.warned) {
22
+ registry.warned = true;
23
+ warn(`[Navios] @navios/core is loaded more than once:\n` + [...registry.locations].map((entry) => ` - ${entry}`).join("\n") + "\nModule options, currentContext() and context keys are not shared between copies. Make sure every package resolves the same @navios/core: one version, not bundled into another package, and not loaded with both import and require.");
24
+ }
25
+ }
26
+ // src/internal/this-copy.mts
27
+ /**
28
+ * Registers this copy of the package. Every entry point imports this module,
29
+ * so a copy is noticed whichever entry is loaded, and counted once: the
30
+ * entries of one build share this module.
31
+ */
32
+ registerCopy(require("url").pathToFileURL(__filename).href, (message) => console.warn(message));
33
+ // src/metadata/decorator-metadata.mts
34
+ /**
35
+ * Returns a value stored in decorator metadata under `key`, creating it for
36
+ * this class if it only exists on a parent. Decorator metadata objects
37
+ * inherit from the parent class's, so writing through an inherited value
38
+ * would change the parent.
39
+ * @internal
40
+ */
41
+ function own(metadata, key, create) {
42
+ if (!Object.hasOwn(metadata, key)) metadata[key] = create(metadata[key]);
43
+ return metadata[key];
44
+ }
45
+ /** The metadata of a decorator context, which has to have one. */
46
+ function requireMetadata(context) {
47
+ if (!context.metadata) throw new Error("[Navios] Decorator metadata is not available. Use standard decorators, or the @navios/core/legacy-compat entry point with experimentalDecorators.");
48
+ return context.metadata;
49
+ }
50
+ // src/metadata/class-metadata.mts
51
+ const ClassAttributesKey = Symbol.for("navios.core.classAttributes");
52
+ const ClassGuardsKey = Symbol.for("navios.core.classGuards");
53
+ const ClassInterceptorsKey = Symbol.for("navios.core.classInterceptors");
54
+ /** The attributes of a class, inherited ones included, to read and to add to. */
55
+ function classAttributes(context) {
56
+ return own(requireMetadata(context), ClassAttributesKey, (inherited) => new Map(inherited));
57
+ }
58
+ /** The guards of a class, as `classAttributes`. */
59
+ function classGuards(context) {
60
+ return own(requireMetadata(context), ClassGuardsKey, (inherited) => [...inherited ?? []]);
61
+ }
62
+ /** The interceptors of a class, as `classAttributes`. */
63
+ function classInterceptors(context) {
64
+ return own(requireMetadata(context), ClassInterceptorsKey, (inherited) => [...inherited ?? []]);
65
+ }
66
+ /** @internal */
67
+ function unique(list) {
68
+ return Array.from(new Set(list));
69
+ }
70
+ /**
71
+ * Puts `first` in front of `list`, in place, skipping duplicates.
72
+ */
73
+ function prepend(list, first) {
74
+ if (first) {
75
+ const added = unique([...first]).filter((item) => !list.includes(item));
76
+ list.unshift(...added);
77
+ }
78
+ return list;
79
+ }
80
+ // src/metadata/member-metadata.mts
81
+ /** Where the members of a class are kept in its metadata. */
82
+ const MembersKey = Symbol.for("navios.core.members");
83
+ /**
84
+ * What decorators attached to a member, inherited ones included, to read and to
85
+ * add to.
86
+ */
87
+ function memberMetadata(context, name) {
88
+ const members = own(requireMetadata(context), MembersKey, (inherited) => {
89
+ const copy = /* @__PURE__ */ new Map();
90
+ if (inherited) for (const [key, value] of inherited) copy.set(key, {
91
+ ...value,
92
+ guards: [...value.guards],
93
+ interceptors: [...value.interceptors],
94
+ attributes: new Map(value.attributes),
95
+ entries: new Map(value.entries)
96
+ });
97
+ return copy;
98
+ });
99
+ let member = members.get(name);
100
+ if (!member) {
101
+ member = {
102
+ name,
103
+ guards: [],
104
+ interceptors: [],
105
+ attributes: /* @__PURE__ */ new Map(),
106
+ entries: /* @__PURE__ */ new Map()
107
+ };
108
+ members.set(name, member);
109
+ }
110
+ return member;
111
+ }
112
+ // src/attributes/attribute-value.mts
113
+ /** Sets the values of attributes on a map of them. */
114
+ function applyAttributes(target, attributes) {
115
+ for (const attribute of attributes ?? []) target.set(attribute.token, attribute.value);
116
+ }
117
+ Object.defineProperty(exports, "MembersKey", {
118
+ enumerable: true,
119
+ get: function() {
120
+ return MembersKey;
121
+ }
122
+ });
123
+ Object.defineProperty(exports, "applyAttributes", {
124
+ enumerable: true,
125
+ get: function() {
126
+ return applyAttributes;
127
+ }
128
+ });
129
+ Object.defineProperty(exports, "classAttributes", {
130
+ enumerable: true,
131
+ get: function() {
132
+ return classAttributes;
133
+ }
134
+ });
135
+ Object.defineProperty(exports, "classGuards", {
136
+ enumerable: true,
137
+ get: function() {
138
+ return classGuards;
139
+ }
140
+ });
141
+ Object.defineProperty(exports, "classInterceptors", {
142
+ enumerable: true,
143
+ get: function() {
144
+ return classInterceptors;
145
+ }
146
+ });
147
+ Object.defineProperty(exports, "memberMetadata", {
148
+ enumerable: true,
149
+ get: function() {
150
+ return memberMetadata;
151
+ }
152
+ });
153
+ Object.defineProperty(exports, "prepend", {
154
+ enumerable: true,
155
+ get: function() {
156
+ return prepend;
157
+ }
158
+ });
159
+ Object.defineProperty(exports, "requireMetadata", {
160
+ enumerable: true,
161
+ get: function() {
162
+ return requireMetadata;
163
+ }
164
+ });
165
+ Object.defineProperty(exports, "unique", {
166
+ enumerable: true,
167
+ get: function() {
168
+ return unique;
169
+ }
170
+ });
171
+
172
+ //# sourceMappingURL=attribute-value-CjX9ZkLq.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-value-CjX9ZkLq.cjs","names":[],"sources":["../src/internal/single-copy.mts","../src/internal/this-copy.mts","../src/metadata/decorator-metadata.mts","../src/metadata/class-metadata.mts","../src/metadata/member-metadata.mts","../src/attributes/attribute-value.mts"],"sourcesContent":["/**\n * Warns when a second copy of this package is loaded into the process.\n *\n * Several things only work with one copy: `@Module` options that other\n * packages add by declaration merging, the async store behind\n * `currentContext()`, and `instanceof` checks on context keys. Two copies\n * usually mean two versions were installed, or one package bundled its own.\n */\nconst registryKey = Symbol.for('navios.core.copies')\n\ninterface Registry {\n locations: Set<string>\n warned: boolean\n}\n\nexport function registerCopy(url: string | undefined, warn: (message: string) => void): void {\n if (typeof url !== 'string') {\n // `import.meta` is empty in a bundle that is not a module.\n return\n }\n // A development server adds a query when it loads a file again.\n const location = url.replace(/[?#].*$/, '')\n const holder = globalThis as { [registryKey]?: Registry }\n const registry = (holder[registryKey] ??= { locations: new Set(), warned: false })\n if (registry.locations.has(location)) {\n // The same file evaluated again: a module reload, not a second copy.\n return\n }\n registry.locations.add(location)\n if (registry.locations.size > 1 && !registry.warned) {\n registry.warned = true\n warn(\n `[Navios] @navios/core is loaded more than once:\\n` +\n [...registry.locations].map((entry) => ` - ${entry}`).join('\\n') +\n `\\nModule options, currentContext() and context keys are not shared between copies. ` +\n `Make sure every package resolves the same @navios/core: one version, not bundled into ` +\n `another package, and not loaded with both import and require.`,\n )\n }\n}\n","/**\n * Registers this copy of the package. Every entry point imports this module,\n * so a copy is noticed whichever entry is loaded, and counted once: the\n * entries of one build share this module.\n */\nimport { registerCopy } from './single-copy.mjs'\n\nregisterCopy(import.meta.url, (message) => console.warn(message))\n","/** The `metadata` of a decorator context. */\nexport type DecoratorMetadata = Record<PropertyKey, unknown>\n\n/**\n * Returns a value stored in decorator metadata under `key`, creating it for\n * this class if it only exists on a parent. Decorator metadata objects\n * inherit from the parent class's, so writing through an inherited value\n * would change the parent.\n * @internal\n */\nexport function own<T>(metadata: DecoratorMetadata, key: symbol, create: (inherited?: T) => T): T {\n if (!Object.hasOwn(metadata, key)) {\n metadata[key] = create(metadata[key] as T | undefined)\n }\n return metadata[key] as T\n}\n\n/** The metadata of a decorator context, which has to have one. */\nexport function requireMetadata(context: { metadata?: DecoratorMetadata }): DecoratorMetadata {\n if (!context.metadata) {\n throw new Error(\n '[Navios] Decorator metadata is not available. Use standard decorators, or the ' +\n '@navios/core/legacy-compat entry point with experimentalDecorators.',\n )\n }\n return context.metadata\n}\n","import type { ClassType } from '@navios/di'\n\nimport { own, requireMetadata } from './decorator-metadata.mjs'\n\nimport type { DecoratorMetadata } from './decorator-metadata.mjs'\n\nconst ClassAttributesKey = Symbol.for('navios.core.classAttributes')\nconst ClassGuardsKey = Symbol.for('navios.core.classGuards')\nconst ClassInterceptorsKey = Symbol.for('navios.core.classInterceptors')\n\n/** The attributes of a class, inherited ones included, to read and to add to. */\nexport function classAttributes(context: { metadata?: DecoratorMetadata }): Map<symbol, unknown> {\n return own(requireMetadata(context), ClassAttributesKey, (inherited) => new Map(inherited))\n}\n\n/** The guards of a class, as `classAttributes`. */\nexport function classGuards(context: { metadata?: DecoratorMetadata }): ClassType[] {\n return own<ClassType[]>(requireMetadata(context), ClassGuardsKey, (inherited) => [\n ...(inherited ?? []),\n ])\n}\n\n/** The interceptors of a class, as `classAttributes`. */\nexport function classInterceptors(context: { metadata?: DecoratorMetadata }): ClassType[] {\n return own<ClassType[]>(requireMetadata(context), ClassInterceptorsKey, (inherited) => [\n ...(inherited ?? []),\n ])\n}\n\n/** @internal */\nexport function unique(list: ClassType[]): ClassType[] {\n return Array.from(new Set(list))\n}\n\n/**\n * Puts `first` in front of `list`, in place, skipping duplicates.\n */\nexport function prepend(list: ClassType[], first: Iterable<ClassType> | undefined): ClassType[] {\n if (first) {\n const added = unique([...first]).filter((item) => !list.includes(item))\n list.unshift(...added)\n }\n return list\n}\n","import type { ClassType } from '@navios/di'\n\nimport { own, requireMetadata } from './decorator-metadata.mjs'\n\nimport type { DecoratorMetadata } from './decorator-metadata.mjs'\n\n/**\n * What decorators and `handler()` options can attach to a handler.\n */\nexport interface HandlerExtras {\n guards: ClassType[]\n interceptors: ClassType[]\n attributes: Map<symbol, unknown>\n}\n\n/**\n * A class member that is, or may become, a handler: what decorators attached\n * to it.\n */\nexport interface MethodHandlerMetadata extends HandlerExtras {\n name: string\n /**\n * What makes the member a handler of a transport, under that transport's\n * own symbol.\n */\n entries: Map<symbol, unknown>\n}\n\n/** Where the members of a class are kept in its metadata. */\nexport const MembersKey = Symbol.for('navios.core.members')\n\n/**\n * What decorators attached to a member, inherited ones included, to read and to\n * add to.\n */\nexport function memberMetadata(\n context: { metadata?: DecoratorMetadata },\n name: string,\n): MethodHandlerMetadata {\n const members = own<Map<string, MethodHandlerMetadata>>(\n requireMetadata(context),\n MembersKey,\n (inherited) => {\n const copy = new Map<string, MethodHandlerMetadata>()\n if (inherited) {\n for (const [key, value] of inherited) {\n copy.set(key, {\n ...value,\n guards: [...value.guards],\n interceptors: [...value.interceptors],\n attributes: new Map(value.attributes),\n entries: new Map(value.entries),\n })\n }\n }\n return copy\n },\n )\n let member = members.get(name)\n if (!member) {\n member = { name, guards: [], interceptors: [], attributes: new Map(), entries: new Map() }\n members.set(name, member)\n }\n return member\n}\n","/** An attribute value as returned by calling an attribute. */\nexport type AttributeValue = { readonly token: symbol; readonly value: unknown }\n\n/** Sets the values of attributes on a map of them. */\nexport function applyAttributes(\n target: Map<symbol, unknown>,\n attributes: AttributeValue[] | undefined,\n): void {\n for (const attribute of attributes ?? []) {\n target.set(attribute.token, attribute.value)\n }\n}\n"],"mappings":"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"}