ts-ioc-container 33.4.0 → 33.5.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.
- package/cjm/by.js +7 -5
- package/cjm/index.js +2 -1
- package/cjm/registration/IRegistration.js +5 -1
- package/esm/by.js +7 -5
- package/esm/index.js +1 -1
- package/esm/registration/IRegistration.js +3 -0
- package/package.json +2 -2
- package/typings/by.d.ts +2 -0
- package/typings/index.d.ts +1 -1
- package/typings/registration/IRegistration.d.ts +1 -0
package/cjm/by.js
CHANGED
|
@@ -52,17 +52,18 @@ const depKey = (key = (0, utils_1.generateUUID)()) => {
|
|
|
52
52
|
let isValidWhen;
|
|
53
53
|
const mappers = [];
|
|
54
54
|
return {
|
|
55
|
+
key,
|
|
55
56
|
assignTo: (registration) => {
|
|
56
|
-
registration.pipe(...mappers).to(key);
|
|
57
|
+
let reg = registration.pipe(...mappers).to(key);
|
|
57
58
|
if (isValidWhen) {
|
|
58
|
-
registration.when(isValidWhen);
|
|
59
|
+
reg = registration.when(isValidWhen);
|
|
59
60
|
}
|
|
60
|
-
return
|
|
61
|
+
return reg;
|
|
61
62
|
},
|
|
62
63
|
register: (fn) => {
|
|
63
|
-
|
|
64
|
+
let registration = new Registration_1.Registration(() => new Provider_1.Provider(fn), key).pipe(...mappers);
|
|
64
65
|
if (isValidWhen) {
|
|
65
|
-
registration.when(isValidWhen);
|
|
66
|
+
registration = registration.when(isValidWhen);
|
|
66
67
|
}
|
|
67
68
|
return registration;
|
|
68
69
|
},
|
|
@@ -79,6 +80,7 @@ const depKey = (key = (0, utils_1.generateUUID)()) => {
|
|
|
79
80
|
isValidWhen = value;
|
|
80
81
|
return this;
|
|
81
82
|
},
|
|
83
|
+
redirectFrom: (registration) => registration.redirectFrom(key),
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
86
|
exports.depKey = depKey;
|
package/cjm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getParameterMetadata = exports.getMethodMetadata = exports.setMethodMetadata = exports.setParameterMetadata = exports.getMetadata = exports.setMetadata = exports.depKey = exports.byAliases = exports.byAlias = exports.IMemoKey = exports.by = exports.HookContext = exports.injectProp = exports.runHooksAsync = exports.runHooks = exports.hasHooks = exports.hook = exports.getHooks = exports.ContainerDisposedError = exports.MethodNotImplementedError = exports.DependencyNotFoundError = exports.Registration = exports.register = exports.scope = exports.key = exports.decorate = exports.multiCache = exports.MultiCache = exports.SingletonProvider = exports.singleton = exports.Provider = exports.ProviderDecorator = exports.args = exports.argsFn = exports.alias = exports.visible = exports.provider = exports.ProxyInjector = exports.SimpleInjector = exports.MetadataInjector = exports.resolveArgs = exports.inject = exports.AutoMockedContainer = exports.EmptyContainer = exports.Container = exports.isDependencyKey = void 0;
|
|
3
|
+
exports.getParameterMetadata = exports.getMethodMetadata = exports.setMethodMetadata = exports.setParameterMetadata = exports.getMetadata = exports.setMetadata = exports.depKey = exports.byAliases = exports.byAlias = exports.IMemoKey = exports.by = exports.HookContext = exports.injectProp = exports.runHooksAsync = exports.runHooks = exports.hasHooks = exports.hook = exports.getHooks = exports.ContainerDisposedError = exports.MethodNotImplementedError = exports.DependencyNotFoundError = exports.Registration = exports.redirectFrom = exports.register = exports.scope = exports.key = exports.decorate = exports.multiCache = exports.MultiCache = exports.SingletonProvider = exports.singleton = exports.Provider = exports.ProviderDecorator = exports.args = exports.argsFn = exports.alias = exports.visible = exports.provider = exports.ProxyInjector = exports.SimpleInjector = exports.MetadataInjector = exports.resolveArgs = exports.inject = exports.AutoMockedContainer = exports.EmptyContainer = exports.Container = exports.isDependencyKey = void 0;
|
|
4
4
|
// Containers
|
|
5
5
|
var IContainer_1 = require("./container/IContainer");
|
|
6
6
|
Object.defineProperty(exports, "isDependencyKey", { enumerable: true, get: function () { return IContainer_1.isDependencyKey; } });
|
|
@@ -43,6 +43,7 @@ var IRegistration_1 = require("./registration/IRegistration");
|
|
|
43
43
|
Object.defineProperty(exports, "key", { enumerable: true, get: function () { return IRegistration_1.key; } });
|
|
44
44
|
Object.defineProperty(exports, "scope", { enumerable: true, get: function () { return IRegistration_1.scope; } });
|
|
45
45
|
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return IRegistration_1.register; } });
|
|
46
|
+
Object.defineProperty(exports, "redirectFrom", { enumerable: true, get: function () { return IRegistration_1.redirectFrom; } });
|
|
46
47
|
var Registration_1 = require("./registration/Registration");
|
|
47
48
|
Object.defineProperty(exports, "Registration", { enumerable: true, get: function () { return Registration_1.Registration; } });
|
|
48
49
|
// Errors
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = exports.getTransformers = exports.scope = exports.key = void 0;
|
|
3
|
+
exports.register = exports.getTransformers = exports.scope = exports.redirectFrom = exports.key = void 0;
|
|
4
4
|
const metadata_1 = require("../metadata");
|
|
5
5
|
const key = (...keys) => (r) => {
|
|
6
6
|
const [originalKey, ...redirectKeys] = keys;
|
|
@@ -11,6 +11,10 @@ const key = (...keys) => (r) => {
|
|
|
11
11
|
return registration;
|
|
12
12
|
};
|
|
13
13
|
exports.key = key;
|
|
14
|
+
const redirectFrom = (redirectKey) => (r) => {
|
|
15
|
+
return r.redirectFrom(redirectKey);
|
|
16
|
+
};
|
|
17
|
+
exports.redirectFrom = redirectFrom;
|
|
14
18
|
const scope = (predicate) => (r) => r.when(predicate);
|
|
15
19
|
exports.scope = scope;
|
|
16
20
|
const METADATA_KEY = 'registration';
|
package/esm/by.js
CHANGED
|
@@ -46,17 +46,18 @@ export const depKey = (key = generateUUID()) => {
|
|
|
46
46
|
let isValidWhen;
|
|
47
47
|
const mappers = [];
|
|
48
48
|
return {
|
|
49
|
+
key,
|
|
49
50
|
assignTo: (registration) => {
|
|
50
|
-
registration.pipe(...mappers).to(key);
|
|
51
|
+
let reg = registration.pipe(...mappers).to(key);
|
|
51
52
|
if (isValidWhen) {
|
|
52
|
-
registration.when(isValidWhen);
|
|
53
|
+
reg = registration.when(isValidWhen);
|
|
53
54
|
}
|
|
54
|
-
return
|
|
55
|
+
return reg;
|
|
55
56
|
},
|
|
56
57
|
register: (fn) => {
|
|
57
|
-
|
|
58
|
+
let registration = new Registration(() => new Provider(fn), key).pipe(...mappers);
|
|
58
59
|
if (isValidWhen) {
|
|
59
|
-
registration.when(isValidWhen);
|
|
60
|
+
registration = registration.when(isValidWhen);
|
|
60
61
|
}
|
|
61
62
|
return registration;
|
|
62
63
|
},
|
|
@@ -73,5 +74,6 @@ export const depKey = (key = generateUUID()) => {
|
|
|
73
74
|
isValidWhen = value;
|
|
74
75
|
return this;
|
|
75
76
|
},
|
|
77
|
+
redirectFrom: (registration) => registration.redirectFrom(key),
|
|
76
78
|
};
|
|
77
79
|
};
|
package/esm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { singleton, SingletonProvider } from './provider/singleton/SingletonProv
|
|
|
15
15
|
export { MultiCache, multiCache } from './provider/singleton/MultiCache';
|
|
16
16
|
export { decorate } from './provider/DecoratorProvider';
|
|
17
17
|
// Registrations
|
|
18
|
-
export { key, scope, register } from './registration/IRegistration';
|
|
18
|
+
export { key, scope, register, redirectFrom, } from './registration/IRegistration';
|
|
19
19
|
export { Registration } from './registration/Registration';
|
|
20
20
|
// Errors
|
|
21
21
|
export { DependencyNotFoundError } from './errors/DependencyNotFoundError';
|
|
@@ -7,6 +7,9 @@ export const key = (...keys) => (r) => {
|
|
|
7
7
|
}
|
|
8
8
|
return registration;
|
|
9
9
|
};
|
|
10
|
+
export const redirectFrom = (redirectKey) => (r) => {
|
|
11
|
+
return r.redirectFrom(redirectKey);
|
|
12
|
+
};
|
|
10
13
|
export const scope = (predicate) => (r) => r.when(predicate);
|
|
11
14
|
const METADATA_KEY = 'registration';
|
|
12
15
|
export const getTransformers = (Target) => getMetadata(Target, METADATA_KEY) ?? [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "33.
|
|
3
|
+
"version": "33.5.0",
|
|
4
4
|
"description": "Typescript IoC container",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
60
|
"typescript": "5.4.3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "554d11b827eeaea495cc7024ade9b1e7fd6c8649"
|
|
63
63
|
}
|
package/typings/by.d.ts
CHANGED
|
@@ -27,12 +27,14 @@ export declare const by: {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
export type DepKey<T> = {
|
|
30
|
+
key: DependencyKey;
|
|
30
31
|
assignTo: (registration: IRegistration<T>) => IRegistration<T>;
|
|
31
32
|
register: (fn: (s: IContainer, ...args: unknown[]) => T) => IRegistration<T>;
|
|
32
33
|
resolve: (s: IContainer, ...args: unknown[]) => T;
|
|
33
34
|
pipe(...values: MapFn<IProvider<T>>[]): DepKey<T>;
|
|
34
35
|
to(target: DependencyKey): DepKey<T>;
|
|
35
36
|
when(value: ScopePredicate): DepKey<T>;
|
|
37
|
+
redirectFrom: (registration: IRegistration<T>) => IRegistration<T>;
|
|
36
38
|
};
|
|
37
39
|
export declare const depKey: <T>(key?: DependencyKey) => DepKey<T>;
|
|
38
40
|
export {};
|
package/typings/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { singleton, SingletonProvider } from './provider/singleton/SingletonProv
|
|
|
13
13
|
export { MultiCache, multiCache } from './provider/singleton/MultiCache';
|
|
14
14
|
export { Cache } from './provider/singleton/Cache';
|
|
15
15
|
export { decorate, DecorateFn } from './provider/DecoratorProvider';
|
|
16
|
-
export { key, IRegistration, ReturnTypeOfRegistration, scope, register } from './registration/IRegistration';
|
|
16
|
+
export { key, IRegistration, ReturnTypeOfRegistration, scope, register, redirectFrom, } from './registration/IRegistration';
|
|
17
17
|
export { Registration } from './registration/Registration';
|
|
18
18
|
export { DependencyNotFoundError } from './errors/DependencyNotFoundError';
|
|
19
19
|
export { MethodNotImplementedError } from './errors/MethodNotImplementedError';
|
|
@@ -10,6 +10,7 @@ export interface IRegistration<T = any> extends IContainerModule {
|
|
|
10
10
|
}
|
|
11
11
|
export type ReturnTypeOfRegistration<T> = T extends IRegistration<infer R> ? R : never;
|
|
12
12
|
export declare const key: (...keys: DependencyKey[]) => MapFn<IRegistration>;
|
|
13
|
+
export declare const redirectFrom: (redirectKey: DependencyKey) => MapFn<IRegistration>;
|
|
13
14
|
export declare const scope: (predicate: ScopePredicate) => MapFn<IRegistration>;
|
|
14
15
|
export declare const getTransformers: (Target: constructor<unknown>) => MapFn<IRegistration<any>>[];
|
|
15
16
|
export declare const register: (...mappers: MapFn<IRegistration>[]) => ClassDecorator;
|