@deepkit/injector
Advanced tools
Comparing version 1.0.1-alpha.40 to 1.0.1-alpha.41
@@ -155,2 +155,3 @@ import { ClassSchema, ExtractClassDefinition, PlainSchemaProps, PropertySchema } from '@deepkit/type'; | ||
args: any[]; | ||
order: number; | ||
} | { | ||
@@ -160,4 +161,6 @@ type: 'property'; | ||
value: any; | ||
order: number; | ||
} | { | ||
type: 'stop'; | ||
order: number; | ||
}; | ||
@@ -177,3 +180,3 @@ export declare class ConfiguredProviderRegistry { | ||
*/ | ||
export declare function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
export declare function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry, order: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
export declare class InjectorContext implements BasicInjector { | ||
@@ -202,3 +205,3 @@ readonly contextManager: ContextRegistry; | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order?: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
getModuleNames(): string[]; | ||
@@ -205,0 +208,0 @@ static forProviders(providers: ProviderWithScope[]): InjectorContext; |
@@ -367,2 +367,5 @@ "use strict"; | ||
if (configuredProviderCalls) { | ||
configuredProviderCalls.sort((a, b) => { | ||
return a.order - b.order; | ||
}); | ||
for (const call of configuredProviderCalls) { | ||
@@ -578,7 +581,7 @@ if (call.type === 'stop') | ||
*/ | ||
function setupProvider(classTypeOrToken, registry) { | ||
function setupProvider(classTypeOrToken, registry, order) { | ||
const proxy = new Proxy({}, { | ||
get(target, prop) { | ||
return (...args) => { | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args }); | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args, order }); | ||
return proxy; | ||
@@ -588,3 +591,3 @@ }; | ||
set(target, prop, value) { | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value }); | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value, order }); | ||
return true; | ||
@@ -628,4 +631,4 @@ } | ||
*/ | ||
setupProvider(classTypeOrToken) { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry); | ||
setupProvider(classTypeOrToken, order = 0) { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry, order); | ||
} | ||
@@ -632,0 +635,0 @@ getModuleNames() { |
@@ -18,3 +18,3 @@ import { ClassType } from '@deepkit/core'; | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order?: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
} |
@@ -27,4 +27,4 @@ "use strict"; | ||
*/ | ||
setupProvider(classTypeOrToken) { | ||
return injector_1.setupProvider(classTypeOrToken, this.setupProviderRegistry); | ||
setupProvider(classTypeOrToken, order = 0) { | ||
return injector_1.setupProvider(classTypeOrToken, this.setupProviderRegistry, order); | ||
} | ||
@@ -31,0 +31,0 @@ } |
@@ -69,4 +69,4 @@ "use strict"; | ||
const context = injector_1.InjectorContext.forProviders([MyService, { provide: MySubService, scope: 'rpc' }]); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
{ | ||
@@ -73,0 +73,0 @@ const s = context.getInjector(0).get(MyService); |
@@ -155,2 +155,3 @@ import { ClassSchema, ExtractClassDefinition, PlainSchemaProps, PropertySchema } from '@deepkit/type'; | ||
args: any[]; | ||
order: number; | ||
} | { | ||
@@ -160,4 +161,6 @@ type: 'property'; | ||
value: any; | ||
order: number; | ||
} | { | ||
type: 'stop'; | ||
order: number; | ||
}; | ||
@@ -177,3 +180,3 @@ export declare class ConfiguredProviderRegistry { | ||
*/ | ||
export declare function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
export declare function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry, order: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
export declare class InjectorContext implements BasicInjector { | ||
@@ -202,3 +205,3 @@ readonly contextManager: ContextRegistry; | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order?: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
getModuleNames(): string[]; | ||
@@ -205,0 +208,0 @@ static forProviders(providers: ProviderWithScope[]): InjectorContext; |
@@ -351,2 +351,5 @@ /* | ||
if (configuredProviderCalls) { | ||
configuredProviderCalls.sort((a, b) => { | ||
return a.order - b.order; | ||
}); | ||
for (const call of configuredProviderCalls) { | ||
@@ -555,7 +558,7 @@ if (call.type === 'stop') | ||
*/ | ||
export function setupProvider(classTypeOrToken, registry) { | ||
export function setupProvider(classTypeOrToken, registry, order) { | ||
const proxy = new Proxy({}, { | ||
get(target, prop) { | ||
return (...args) => { | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args }); | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args, order }); | ||
return proxy; | ||
@@ -565,3 +568,3 @@ }; | ||
set(target, prop, value) { | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value }); | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value, order }); | ||
return true; | ||
@@ -604,4 +607,4 @@ } | ||
*/ | ||
setupProvider(classTypeOrToken) { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry); | ||
setupProvider(classTypeOrToken, order = 0) { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry, order); | ||
} | ||
@@ -608,0 +611,0 @@ getModuleNames() { |
@@ -18,3 +18,3 @@ import { ClassType } from '@deepkit/core'; | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order?: number): ConfigureProvider<T extends ClassType<infer C> ? C : T>; | ||
} |
@@ -24,6 +24,6 @@ import { ConfiguredProviderRegistry, setupProvider } from './injector'; | ||
*/ | ||
setupProvider(classTypeOrToken) { | ||
return setupProvider(classTypeOrToken, this.setupProviderRegistry); | ||
setupProvider(classTypeOrToken, order = 0) { | ||
return setupProvider(classTypeOrToken, this.setupProviderRegistry, order); | ||
} | ||
} | ||
//# sourceMappingURL=module.js.map |
@@ -67,4 +67,4 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
const context = InjectorContext.forProviders([MyService, { provide: MySubService, scope: 'rpc' }]); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
{ | ||
@@ -71,0 +71,0 @@ const s = context.getInjector(0).get(MyService); |
{ | ||
"name": "@deepkit/injector", | ||
"version": "1.0.1-alpha.40", | ||
"version": "1.0.1-alpha.41", | ||
"description": "Deepkit Dependency Injection", | ||
@@ -42,3 +42,3 @@ "type": "commonjs", | ||
}, | ||
"gitHead": "ec8b31395e0dbd76a550872dd3f510f0c75bfbf6" | ||
"gitHead": "4766c5a7229111f59f19e47e4f20332e282679a6" | ||
} |
@@ -412,2 +412,6 @@ /* | ||
if (configuredProviderCalls) { | ||
configuredProviderCalls.sort((a, b) => { | ||
return a.order - b.order; | ||
}); | ||
for (const call of configuredProviderCalls) { | ||
@@ -613,6 +617,6 @@ if (call.type === 'stop') break; | ||
export type ConfiguredProviderCalls = { | ||
type: 'call', methodName: string | symbol | number, args: any[] | ||
type: 'call', methodName: string | symbol | number, args: any[], order: number | ||
} | ||
| { type: 'property', property: string | symbol | number, value: any } | ||
| { type: 'stop' } | ||
| { type: 'property', property: string | symbol | number, value: any, order: number } | ||
| { type: 'stop', order: number } | ||
; | ||
@@ -651,7 +655,7 @@ | ||
*/ | ||
export function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
export function setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, registry: ConfiguredProviderRegistry, order: number): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
const proxy = new Proxy({}, { | ||
get(target, prop) { | ||
return (...args: any[]) => { | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args }); | ||
registry.add(classTypeOrToken, { type: 'call', methodName: prop, args: args, order }); | ||
return proxy; | ||
@@ -661,3 +665,3 @@ }; | ||
set(target, prop, value) { | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value }); | ||
registry.add(classTypeOrToken, { type: 'property', property: prop, value: value, order }); | ||
return true; | ||
@@ -711,4 +715,4 @@ } | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry); | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order: number = 0): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
return setupProvider(classTypeOrToken, this.configuredProviderRegistry, order); | ||
} | ||
@@ -715,0 +719,0 @@ |
@@ -33,5 +33,5 @@ import { ClassType } from '@deepkit/core'; | ||
*/ | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
return setupProvider(classTypeOrToken, this.setupProviderRegistry); | ||
setupProvider<T extends ClassType<T> | any>(classTypeOrToken: T, order: number = 0): ConfigureProvider<T extends ClassType<infer C> ? C : T> { | ||
return setupProvider(classTypeOrToken, this.setupProviderRegistry, order); | ||
} | ||
} |
@@ -71,4 +71,4 @@ import { expect, test } from '@jest/globals'; | ||
const context = InjectorContext.forProviders([MyService, { provide: MySubService, scope: 'rpc' }]); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'] }); | ||
context.configuredProviderRegistry.add(MyService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
context.configuredProviderRegistry.add(MySubService, { type: 'call', methodName: 'set', args: ['foo'], order: 0 }); | ||
@@ -75,0 +75,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
316217
4336