@rudderjs/core 0.0.8

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.
@@ -0,0 +1,418 @@
1
+ import { container } from './di.js';
2
+ import { Env, ConfigRepository, setConfigRepository } from '@rudderjs/support';
3
+ import { rudder } from '@rudderjs/rudder';
4
+ import { ValidationError } from './validation.js';
5
+ import { HttpException, renderHttpException, renderServerError, report, setExceptionReporter, } from './exceptions.js';
6
+ export class Application {
7
+ static instance;
8
+ container;
9
+ providers = [];
10
+ booted = false;
11
+ _booting = false;
12
+ _bootedProviders = new WeakSet();
13
+ /** Tracks registered provider classes to prevent duplicates. */
14
+ _registeredClasses = new Set();
15
+ /** Tracks registered provider names to prevent duplicates from factory functions. */
16
+ _registeredNames = new Set();
17
+ /** Deferred providers — token → ProviderClass (lazily booted on first resolve). */
18
+ _deferredProviders = new Map();
19
+ name;
20
+ env;
21
+ debug;
22
+ constructor(config = {}) {
23
+ this.container = container;
24
+ this.name = config.name ?? Env.get('APP_NAME', 'RudderJS');
25
+ this.env = config.env ?? Env.get('APP_ENV', 'production');
26
+ this.debug = config.debug ?? Env.getBool('APP_DEBUG', false);
27
+ this.container.instance('app', this);
28
+ this.container.instance('Application', this);
29
+ if (config.config) {
30
+ const repo = new ConfigRepository(config.config);
31
+ setConfigRepository(repo);
32
+ this.container.instance('config', repo);
33
+ }
34
+ for (const Provider of config.providers ?? []) {
35
+ this._trackProvider(Provider);
36
+ this.providers.push(new Provider(this));
37
+ }
38
+ }
39
+ /** Track a provider class for duplicate detection. */
40
+ _trackProvider(Provider) {
41
+ this._registeredClasses.add(Provider);
42
+ if (Provider.name)
43
+ this._registeredNames.add(Provider.name);
44
+ }
45
+ /** Check whether a provider class (or its name) has already been registered. */
46
+ _isDuplicate(Provider) {
47
+ if (this._registeredClasses.has(Provider))
48
+ return true;
49
+ if (Provider.name && this._registeredNames.has(Provider.name))
50
+ return true;
51
+ return false;
52
+ }
53
+ static create(config) {
54
+ const g = globalThis;
55
+ if (!g['__rudderjs_app__']) {
56
+ g['__rudderjs_app__'] = new Application(config);
57
+ }
58
+ Application.instance = g['__rudderjs_app__'];
59
+ return Application.instance;
60
+ }
61
+ static getInstance() {
62
+ const g = globalThis;
63
+ const inst = (g['__rudderjs_app__'] ?? Application.instance);
64
+ if (!inst) {
65
+ throw new Error('[RudderJS] Application has not been created yet. Call Application.create() first.');
66
+ }
67
+ return inst;
68
+ }
69
+ // ── Container proxy methods ───────────────────────────────
70
+ bind(token, factory) {
71
+ this.container.bind(token, factory);
72
+ return this;
73
+ }
74
+ singleton(token, factory) {
75
+ this.container.singleton(token, factory);
76
+ return this;
77
+ }
78
+ instance(token, value) {
79
+ this.container.instance(token, value);
80
+ return this;
81
+ }
82
+ make(token) {
83
+ return this.container.make(token);
84
+ }
85
+ scoped(token, factory) {
86
+ this.container.scoped(token, factory);
87
+ return this;
88
+ }
89
+ runScoped(fn) {
90
+ return this.container.runScoped(fn);
91
+ }
92
+ when(concrete) {
93
+ return this.container.when(concrete);
94
+ }
95
+ // ── Lifecycle ─────────────────────────────────────────────
96
+ /**
97
+ * Dynamically register a service provider at runtime.
98
+ *
99
+ * - Calls `register()` immediately so bindings are available.
100
+ * - If the application is already booted, calls `boot()` too.
101
+ * - Duplicate providers (by class reference or class name) are silently skipped.
102
+ *
103
+ * Works with both provider classes and factory return values:
104
+ * ```ts
105
+ * await this.app.register(MyServiceProvider)
106
+ * await this.app.register(cache(cacheConfig))
107
+ * ```
108
+ */
109
+ async register(Provider) {
110
+ if (Array.isArray(Provider)) {
111
+ for (const P of Provider)
112
+ await this.register(P);
113
+ return this;
114
+ }
115
+ if (this._isDuplicate(Provider))
116
+ return this;
117
+ this._trackProvider(Provider);
118
+ const instance = new Provider(this);
119
+ this.providers.push(instance);
120
+ instance.register();
121
+ if (this.booted || this._booting) {
122
+ try {
123
+ await instance.boot?.();
124
+ this._bootedProviders.add(instance);
125
+ }
126
+ catch (err) {
127
+ const name = instance.constructor.name || Provider.name || 'AnonymousProvider';
128
+ const cause = err instanceof Error ? err.message : String(err);
129
+ throw new Error(`[RudderJS] Provider "${name}" failed to boot.\n Cause: ${cause}\n Check your provider configuration in bootstrap/providers.ts`, { cause: err });
130
+ }
131
+ }
132
+ return this;
133
+ }
134
+ _registerAll() {
135
+ for (let i = 0; i < this.providers.length; i++) {
136
+ const provider = this.providers[i];
137
+ const tokens = provider.provides?.();
138
+ if (tokens && tokens.length > 0) {
139
+ // Deferred — map each token to the provider's constructor for lazy boot
140
+ const Ctor = provider.constructor;
141
+ for (const token of tokens) {
142
+ this._deferredProviders.set(token, Ctor);
143
+ }
144
+ continue;
145
+ }
146
+ provider.register();
147
+ }
148
+ // Wire the missing handler so deferred providers boot on first resolve
149
+ if (this._deferredProviders.size > 0) {
150
+ this.container.setMissingHandler((token) => {
151
+ const key = typeof token === 'symbol' ? undefined : token;
152
+ if (!key)
153
+ return;
154
+ const Provider = this._deferredProviders.get(key);
155
+ if (!Provider)
156
+ return;
157
+ // Remove all tokens for this provider to prevent re-entry
158
+ for (const [t, P] of this._deferredProviders) {
159
+ if (P === Provider)
160
+ this._deferredProviders.delete(t);
161
+ }
162
+ const instance = new Provider(this);
163
+ this.providers.push(instance);
164
+ instance.register();
165
+ // Deferred providers must have sync boot (or none)
166
+ instance.boot?.();
167
+ this._bootedProviders.add(instance);
168
+ });
169
+ }
170
+ }
171
+ async _bootAll() {
172
+ this._booting = true;
173
+ for (const provider of this.providers) {
174
+ if (this._bootedProviders.has(provider))
175
+ continue;
176
+ try {
177
+ await provider.boot?.();
178
+ this._bootedProviders.add(provider);
179
+ }
180
+ catch (err) {
181
+ const name = provider.constructor.name;
182
+ const cause = err instanceof Error ? err.message : String(err);
183
+ throw new Error(`[RudderJS] Provider "${name}" failed to boot.\n Cause: ${cause}\n Check your provider configuration in bootstrap/providers.ts`, { cause: err });
184
+ }
185
+ }
186
+ this._booting = false;
187
+ this.booted = true;
188
+ }
189
+ async bootstrap() {
190
+ if (this.booted)
191
+ return this;
192
+ this._registerAll();
193
+ await this._bootAll();
194
+ return this;
195
+ }
196
+ isBooted() { return this.booted; }
197
+ isProduction() { return this.env === 'production'; }
198
+ isDevelopment() { return this.env === 'development' || this.env === 'local'; }
199
+ static configure(options) {
200
+ return new AppBuilder(options);
201
+ }
202
+ /** @internal — testing only */
203
+ static resetForTesting() {
204
+ ;
205
+ Application['instance'] = undefined;
206
+ globalThis['__rudderjs_app__'] = undefined;
207
+ }
208
+ }
209
+ // ─── Middleware Configurator ───────────────────────────────
210
+ export class MiddlewareConfigurator {
211
+ _handlers = [];
212
+ use(handler) {
213
+ this._handlers.push(handler);
214
+ return this;
215
+ }
216
+ getHandlers() { return this._handlers; }
217
+ }
218
+ export class ExceptionConfigurator {
219
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
+ _renders = [];
221
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
+ _ignored = new Set();
223
+ /**
224
+ * Register a custom renderer for a specific error type.
225
+ *
226
+ * @example
227
+ * e.render(PaymentError, (err, req) =>
228
+ * new Response(JSON.stringify({ code: err.code }), { status: 402, headers: { 'Content-Type': 'application/json' } })
229
+ * )
230
+ */
231
+ render(
232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
233
+ type, fn) {
234
+ this._renders.push({ type, fn: fn });
235
+ return this;
236
+ }
237
+ /**
238
+ * Ignore an error type — re-throws it so the server's native handler sees it.
239
+ */
240
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
241
+ ignore(type) {
242
+ this._ignored.add(type);
243
+ return this;
244
+ }
245
+ /**
246
+ * Override the global exception reporter for unhandled errors.
247
+ * By default, `@rudderjs/log` wires this automatically when installed.
248
+ *
249
+ * @example
250
+ * e.reportUsing((err) => Sentry.captureException(err))
251
+ */
252
+ reportUsing(fn) {
253
+ setExceptionReporter(fn);
254
+ return this;
255
+ }
256
+ /** @internal — called by RudderJS to produce the combined error handler */
257
+ buildHandler() {
258
+ const renders = this._renders.slice();
259
+ const ignored = new Set(this._ignored);
260
+ return async (err, req) => {
261
+ // 1. Explicitly ignored — re-throw
262
+ for (const type of ignored) {
263
+ if (err instanceof type)
264
+ throw err;
265
+ }
266
+ // 2. User-registered renderers (take priority)
267
+ for (const { type, fn } of renders) {
268
+ if (err instanceof type)
269
+ return fn(err, req);
270
+ }
271
+ // 3. ValidationError — 422 JSON
272
+ if (err instanceof ValidationError) {
273
+ return new Response(JSON.stringify(err.toJSON()), {
274
+ status: 422,
275
+ headers: { 'Content-Type': 'application/json' },
276
+ });
277
+ }
278
+ // 4. HttpException — render with its status code (JSON or HTML)
279
+ if (err instanceof HttpException) {
280
+ return renderHttpException(err, req);
281
+ }
282
+ // 5. Unhandled — report + render 500
283
+ report(err);
284
+ let debug = false;
285
+ try {
286
+ debug = Application.getInstance().debug;
287
+ }
288
+ catch { /* app not ready */ }
289
+ return renderServerError(req, debug, err);
290
+ };
291
+ }
292
+ }
293
+ // ─── App Builder ───────────────────────────────────────────
294
+ export class AppBuilder {
295
+ _options;
296
+ _loaders = [];
297
+ _mwFn;
298
+ _excFn;
299
+ constructor(_options) {
300
+ this._options = _options;
301
+ }
302
+ withRouting(routes) {
303
+ if (routes.web)
304
+ this._loaders.push(routes.web);
305
+ if (routes.api)
306
+ this._loaders.push(routes.api);
307
+ if (routes.commands)
308
+ this._loaders.push(routes.commands);
309
+ if (routes.channels)
310
+ this._loaders.push(routes.channels);
311
+ return this;
312
+ }
313
+ withMiddleware(fn) {
314
+ this._mwFn = fn;
315
+ return this;
316
+ }
317
+ withExceptions(fn) {
318
+ this._excFn = fn;
319
+ return this;
320
+ }
321
+ create() {
322
+ const g = globalThis;
323
+ if (g['__rudderjs_instance__'])
324
+ return g['__rudderjs_instance__'];
325
+ const app = Application.create({
326
+ ...(this._options.config && { config: this._options.config }),
327
+ ...(this._options.providers && { providers: this._options.providers }),
328
+ });
329
+ const instance = new RudderJS(app, this._options.server, this._loaders, this._mwFn, this._excFn);
330
+ g['__rudderjs_instance__'] = instance;
331
+ return instance;
332
+ }
333
+ }
334
+ // ─── RudderJS (Configured Application) ─────────────────────
335
+ export class RudderJS {
336
+ _app;
337
+ _server;
338
+ _loaders;
339
+ _mwFn;
340
+ _excFn;
341
+ /** Phase 1: providers only — safe to await in CLI (no Vike virtual imports) */
342
+ _providerBoot;
343
+ /** Phase 2: provider boot + HTTP handler — created lazily on first handleRequest call */
344
+ _boot = null;
345
+ _handler = null;
346
+ constructor(_app, _server, _loaders, _mwFn, _excFn) {
347
+ this._app = _app;
348
+ this._server = _server;
349
+ this._loaders = _loaders;
350
+ this._mwFn = _mwFn;
351
+ this._excFn = _excFn;
352
+ this._providerBoot = this._bootstrapProviders();
353
+ }
354
+ _suppressVikeNoise() {
355
+ const isNoise = (args) => {
356
+ const msg = args.map(a => String(a ?? '')).join(' ');
357
+ if (msg.includes('[vike]'))
358
+ return true;
359
+ if (msg.includes('Server running at '))
360
+ return true;
361
+ return false;
362
+ };
363
+ const _log = console.log;
364
+ const _warn = console.warn;
365
+ const _info = console.info;
366
+ console.log = (...a) => { if (!isNoise(a))
367
+ _log(...a); };
368
+ console.warn = (...a) => { if (!isNoise(a))
369
+ _warn(...a); };
370
+ console.info = (...a) => { if (!isNoise(a))
371
+ _info(...a); };
372
+ }
373
+ /** Phase 1 — boot providers + routes. Safe in CLI (no Vike virtual URLs). */
374
+ async _bootstrapProviders() {
375
+ this._suppressVikeNoise();
376
+ if (this._app.isDevelopment()) {
377
+ rudder.reset();
378
+ const { router } = await import('@rudderjs/router');
379
+ router.reset();
380
+ }
381
+ await this._app.bootstrap();
382
+ await Promise.all(this._loaders.map(l => l()));
383
+ console.log('[RudderJS] ready');
384
+ }
385
+ /** Phase 2 — create the HTTP fetch handler. Requires Vite context (virtual: URLs). */
386
+ async _createHandler() {
387
+ const mw = new MiddlewareConfigurator();
388
+ this._mwFn?.(mw);
389
+ const exc = new ExceptionConfigurator();
390
+ this._excFn?.(exc);
391
+ const errorHandler = exc.buildHandler();
392
+ const { router } = await import('@rudderjs/router');
393
+ this._handler = await this._server.createFetchHandler((adapter) => {
394
+ for (const h of mw.getHandlers())
395
+ adapter.applyMiddleware(h);
396
+ router.mount(adapter);
397
+ adapter.setErrorHandler?.(errorHandler);
398
+ });
399
+ }
400
+ /** Boot providers without starting an HTTP server — used by the CLI */
401
+ async boot() {
402
+ await this._providerBoot;
403
+ }
404
+ async handleRequest(request, env, ctx) {
405
+ if (!this._boot)
406
+ this._boot = this._providerBoot.then(() => this._createHandler());
407
+ await this._boot;
408
+ if (!this._handler)
409
+ throw new Error('[RudderJS] Request handler not initialized.');
410
+ return this._handler(request, env, ctx);
411
+ }
412
+ fetch = (request, env, ctx) => this.handleRequest(request, env, ctx);
413
+ }
414
+ // ─── Global helpers ────────────────────────────────────────
415
+ export const app = () => Application.getInstance();
416
+ export const resolve = (token) => Application.getInstance().make(token);
417
+ export function defineConfig(config) { return config; }
418
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAE,MAAM,SAAS,CAAA;AAExE,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,EACN,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AAiBxB,MAAM,OAAO,WAAW;IACd,MAAM,CAAC,QAAQ,CAAa;IAC3B,SAAS,CAAW;IACrB,SAAS,GAAsB,EAAE,CAAA;IACjC,MAAM,GAAG,KAAK,CAAA;IACd,QAAQ,GAAG,KAAK,CAAA;IAChB,gBAAgB,GAAG,IAAI,OAAO,EAAmB,CAAA;IAEzD,gEAAgE;IACxD,kBAAkB,G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AAE,CAAC,WAAW,CAAC,WAAW,EAAE,CAAA;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAAuC,EAAK,EAAE,CACvE,WAAW,CAAC,WAAW,EAAE,CAAC,IAAI,CAAI,KAAK,CAAC,CAAA;AAE1C,MAAM,UAAU,YAAY,CAAI,MAAS,IAAO,OAAO,MAAM,CAAA,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Augment this interface in your project to get fully typed config() calls.
3
+ *
4
+ * @example
5
+ * // config/index.ts
6
+ * import type configs from './index.js'
7
+ * declare module '@rudderjs/core' {
8
+ * interface AppConfig extends typeof configs {}
9
+ * }
10
+ */
11
+ export interface AppConfig {
12
+ }
13
+ type IsEmpty<T> = keyof T extends never ? true : false;
14
+ type Paths<T> = T extends Record<string, unknown> ? {
15
+ [K in keyof T & string]: T[K] extends Record<string, unknown> ? K | `${K}.${Paths<T[K]>}` : K;
16
+ }[keyof T & string] : never;
17
+ type Get<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Get<T[K], Rest> : unknown : P extends keyof T ? T[P] : unknown;
18
+ type ConfigKey = IsEmpty<AppConfig> extends true ? string : Paths<AppConfig>;
19
+ type ConfigValue<K extends string> = IsEmpty<AppConfig> extends true ? unknown : Get<AppConfig, K>;
20
+ export declare function config<K extends ConfigKey>(key: K, fallback?: ConfigValue<K>): ConfigValue<K>;
21
+ export declare function config<T = unknown>(key: string, fallback?: T): T;
22
+ export {};
23
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,MAAM,WAAW,SAAS;CAAG;AAI7B,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;AAEtD,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7C;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GACpB,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GACzB,CAAC;CACR,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GACnB,KAAK,CAAA;AAET,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAC1B,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GAChC,CAAC,SAAS,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,GAC7C,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;AAIxC,KAAK,SAAS,GAAK,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,GAAG,MAAM,GAAK,KAAK,CAAC,SAAS,CAAC,CAAA;AAChF,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,GAAG,OAAO,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AAIlG,wBAAgB,MAAM,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AAC9F,wBAAgB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,5 @@
1
+ import { config as _config } from '@rudderjs/support';
2
+ export function config(key, fallback) {
3
+ return _config(key, fallback);
4
+ }
5
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAA;AA4CrD,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,QAAkB;IACpD,OAAO,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC/B,CAAC"}
package/dist/di.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import 'reflect-metadata';
2
+ type Constructor<T = unknown> = new (...args: never) => T;
3
+ type Factory<T = unknown> = (container: Container) => T;
4
+ /** Mark a class as injectable (auto-resolved by the container) */
5
+ export declare function Injectable(): ClassDecorator;
6
+ /** Inject a specific token into a constructor parameter */
7
+ export declare function Inject(token: string | symbol): ParameterDecorator;
8
+ export declare class Container {
9
+ private bindings;
10
+ private instances;
11
+ private aliases;
12
+ private _scopeAlsInstance;
13
+ private get _scopeAls();
14
+ private _contextual;
15
+ private _missingHandler;
16
+ reset(): this;
17
+ bind<T>(token: string | symbol | Constructor<T>, factory: Factory<T>): this;
18
+ singleton<T>(token: string | symbol | Constructor<T>, factory: Factory<T>): this;
19
+ /**
20
+ * Register a scoped binding — like singleton but per-request.
21
+ * The factory runs once per `runScoped()` call and is cached for that scope.
22
+ */
23
+ scoped<T>(token: string | symbol | Constructor<T>, factory: Factory<T>): this;
24
+ /**
25
+ * Execute `fn` inside a fresh scope. Scoped bindings resolved within
26
+ * this call are cached and automatically discarded when `fn` completes.
27
+ */
28
+ runScoped<T>(fn: () => T): T;
29
+ instance<T>(token: string | symbol | Constructor<T>, value: T): this;
30
+ alias(from: string, to: string | symbol): this;
31
+ make<T>(token: string | symbol | Constructor<T>): T;
32
+ has(token: string | symbol | Constructor): boolean;
33
+ forget(token: string | symbol | Constructor): this;
34
+ /**
35
+ * Set a handler called when `make()` cannot find a binding.
36
+ * Used by Application to lazily boot deferred providers.
37
+ */
38
+ setMissingHandler(fn: ((token: string | symbol) => void) | null): this;
39
+ /**
40
+ * Contextual binding — when resolving `concrete`, override a dependency.
41
+ *
42
+ * @example
43
+ * container.when(PhotoController).needs('storage').give(() => new S3Storage())
44
+ */
45
+ when(concrete: Constructor): ContextualBindingBuilder;
46
+ /** @internal — called by ContextualBindingBuilder */
47
+ _addContextualBinding(concrete: Constructor, need: string | symbol, factory: Factory): void;
48
+ private autoResolve;
49
+ private toToken;
50
+ private resolveAlias;
51
+ }
52
+ export declare class ContextualBindingBuilder {
53
+ private readonly _container;
54
+ private readonly _concrete;
55
+ constructor(_container: Container, _concrete: Constructor);
56
+ needs(token: string | symbol | Constructor): {
57
+ give: (factoryOrValue: Factory | unknown) => void;
58
+ };
59
+ }
60
+ export declare const container: Container;
61
+ export {};
62
+ //# sourceMappingURL=di.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"di.d.ts","sourceRoot":"","sources":["../src/di.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAkBzB,KAAK,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC,CAAA;AACzD,KAAK,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAA;AAQvD,kEAAkE;AAClE,wBAAgB,UAAU,IAAI,cAAc,CAI3C;AAED,2DAA2D;AAC3D,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAMjE;AAID,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,OAAO,CAAuC;IAKtD,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,KAAK,SAAS,GAQpB;IAGD,OAAO,CAAC,WAAW,CAAmD;IAGtE,OAAO,CAAC,eAAe,CAAkD;IAEzE,KAAK,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