@rocketmakers/ioc 0.3.3 → 0.3.6
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/CHANGELOG.md +5 -0
- package/lib/binder.d.ts +6 -6
- package/lib/curry.generated.d.ts +60 -60
- package/lib/index.d.ts +14 -11
- package/lib/index.js +11 -9
- package/lib/inversify.d.ts +2 -6
- package/lib/naming/camel.d.ts +6 -0
- package/lib/naming/camel.js +13 -0
- package/lib/naming/none.d.ts +6 -0
- package/lib/naming/none.js +7 -0
- package/lib/tail.generated.d.ts +3 -3
- package/lib/types.d.ts +4 -4
- package/package.json +19 -15
- package/lib/prefix.d.ts +0 -17
- package/lib/prefix.js +0 -23
package/CHANGELOG.md
ADDED
package/lib/binder.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Curried1, Param1 } from './curry.generated';
|
|
2
2
|
import { Func, IFunctionResolver } from './tail.generated';
|
|
3
3
|
import { NewableOf, TupleToKeysOfMapped } from './types';
|
|
4
|
-
|
|
4
|
+
type CollectCurriedParams<TOriginal extends Func, TCurried, TCollect extends any[] = []> = TOriginal extends TCurried ? TCollect : CollectCurriedParams<Curried1<TOriginal>, TCurried, [...TCollect, Param1<Parameters<TOriginal>>]>;
|
|
5
5
|
export declare class Binder<T, TItem, TDep> {
|
|
6
6
|
protected key: string;
|
|
7
7
|
protected keyTransformer: (keyName: string) => string;
|
|
8
8
|
constructor(key: string, keyTransformer: (keyName: string) => string);
|
|
9
9
|
/** Gets the underlying container binding to the specified key */
|
|
10
|
-
get binding(): import("inversify/
|
|
10
|
+
get binding(): import("inversify/lib/cjs/interfaces/interfaces").interfaces.BindingToSyntax<TItem>;
|
|
11
11
|
/** Register a function */
|
|
12
|
-
function(item: TItem): import("inversify/
|
|
12
|
+
function(item: TItem): import("inversify/lib/cjs/interfaces/interfaces").interfaces.BindingWhenOnSyntax<TItem>;
|
|
13
13
|
/** Register a function resolver */
|
|
14
|
-
functionResolver(item: IFunctionResolver<TItem>): import("inversify/
|
|
14
|
+
functionResolver(item: IFunctionResolver<TItem>): import("inversify/lib/cjs/interfaces/interfaces").interfaces.BindingWhenOnSyntax<TItem>;
|
|
15
15
|
/** Register a constant */
|
|
16
|
-
constant(item: TItem): import("inversify/
|
|
16
|
+
constant(item: TItem): import("inversify/lib/cjs/interfaces/interfaces").interfaces.BindingWhenOnSyntax<TItem>;
|
|
17
17
|
/** Register a curried function */
|
|
18
|
-
functionCurry<TFn extends Func>(item: TFn, params: TupleToKeysOfMapped<CollectCurriedParams<TFn, TItem>, T & TDep>): import("inversify/
|
|
18
|
+
functionCurry<TFn extends Func>(item: TFn, params: TupleToKeysOfMapped<CollectCurriedParams<TFn, TItem>, T & TDep>): import("inversify/lib/cjs/interfaces/interfaces").interfaces.BindingWhenOnSyntax<TItem>;
|
|
19
19
|
/** Register a class */
|
|
20
20
|
class<C extends NewableOf<TItem>>(cls: C, params: TupleToKeysOfMapped<ConstructorParameters<C>, T & TDep>): import("./inversify").BindingInWhenOnSyntax<InstanceType<C>>;
|
|
21
21
|
}
|
package/lib/curry.generated.d.ts
CHANGED
|
@@ -1,143 +1,143 @@
|
|
|
1
1
|
/** Returns a mapped type that removes the first element from the type array */
|
|
2
|
-
export
|
|
2
|
+
export type Tail1<T extends any[]> = ((...t: T) => any) extends (_1: any, ...tail: infer TTail) => any ? TTail : [
|
|
3
3
|
];
|
|
4
4
|
/** Returns a mapped type that removes the first 2 elements from the type array */
|
|
5
|
-
export
|
|
5
|
+
export type Tail2<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, ...tail: infer TTail) => any ? TTail : [
|
|
6
6
|
];
|
|
7
7
|
/** Returns a mapped type that removes the first 3 elements from the type array */
|
|
8
|
-
export
|
|
8
|
+
export type Tail3<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, ...tail: infer TTail) => any ? TTail : [
|
|
9
9
|
];
|
|
10
10
|
/** Returns a mapped type that removes the first 4 elements from the type array */
|
|
11
|
-
export
|
|
11
|
+
export type Tail4<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, ...tail: infer TTail) => any ? TTail : [
|
|
12
12
|
];
|
|
13
13
|
/** Returns a mapped type that removes the first 5 elements from the type array */
|
|
14
|
-
export
|
|
14
|
+
export type Tail5<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, ...tail: infer TTail) => any ? TTail : [
|
|
15
15
|
];
|
|
16
16
|
/** Returns a mapped type that removes the first 6 elements from the type array */
|
|
17
|
-
export
|
|
17
|
+
export type Tail6<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, ...tail: infer TTail) => any ? TTail : [
|
|
18
18
|
];
|
|
19
19
|
/** Returns a mapped type that removes the first 7 elements from the type array */
|
|
20
|
-
export
|
|
20
|
+
export type Tail7<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, ...tail: infer TTail) => any ? TTail : [
|
|
21
21
|
];
|
|
22
22
|
/** Returns a mapped type that removes the first 8 elements from the type array */
|
|
23
|
-
export
|
|
23
|
+
export type Tail8<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, ...tail: infer TTail) => any ? TTail : [
|
|
24
24
|
];
|
|
25
25
|
/** Returns a mapped type that removes the first 9 elements from the type array */
|
|
26
|
-
export
|
|
26
|
+
export type Tail9<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, ...tail: infer TTail) => any ? TTail : [
|
|
27
27
|
];
|
|
28
28
|
/** Returns a mapped type that removes the first 10 elements from the type array */
|
|
29
|
-
export
|
|
29
|
+
export type Tail10<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, ...tail: infer TTail) => any ? TTail : [
|
|
30
30
|
];
|
|
31
31
|
/** Returns a mapped type that removes the first 11 elements from the type array */
|
|
32
|
-
export
|
|
32
|
+
export type Tail11<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, ...tail: infer TTail) => any ? TTail : [
|
|
33
33
|
];
|
|
34
34
|
/** Returns a mapped type that removes the first 12 elements from the type array */
|
|
35
|
-
export
|
|
35
|
+
export type Tail12<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, ...tail: infer TTail) => any ? TTail : [
|
|
36
36
|
];
|
|
37
37
|
/** Returns a mapped type that removes the first 13 elements from the type array */
|
|
38
|
-
export
|
|
38
|
+
export type Tail13<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, ...tail: infer TTail) => any ? TTail : [
|
|
39
39
|
];
|
|
40
40
|
/** Returns a mapped type that removes the first 14 elements from the type array */
|
|
41
|
-
export
|
|
41
|
+
export type Tail14<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, ...tail: infer TTail) => any ? TTail : [
|
|
42
42
|
];
|
|
43
43
|
/** Returns a mapped type that removes the first 15 elements from the type array */
|
|
44
|
-
export
|
|
44
|
+
export type Tail15<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, ...tail: infer TTail) => any ? TTail : [
|
|
45
45
|
];
|
|
46
46
|
/** Returns a mapped type that removes the first 16 elements from the type array */
|
|
47
|
-
export
|
|
47
|
+
export type Tail16<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, _16: any, ...tail: infer TTail) => any ? TTail : [
|
|
48
48
|
];
|
|
49
49
|
/** Returns a mapped type that removes the first 17 elements from the type array */
|
|
50
|
-
export
|
|
50
|
+
export type Tail17<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, _16: any, _17: any, ...tail: infer TTail) => any ? TTail : [
|
|
51
51
|
];
|
|
52
52
|
/** Returns a mapped type that removes the first 18 elements from the type array */
|
|
53
|
-
export
|
|
53
|
+
export type Tail18<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, _16: any, _17: any, _18: any, ...tail: infer TTail) => any ? TTail : [
|
|
54
54
|
];
|
|
55
55
|
/** Returns a mapped type that removes the first 19 elements from the type array */
|
|
56
|
-
export
|
|
56
|
+
export type Tail19<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, _16: any, _17: any, _18: any, _19: any, ...tail: infer TTail) => any ? TTail : [
|
|
57
57
|
];
|
|
58
58
|
/** Returns a mapped type that removes the first 20 elements from the type array */
|
|
59
|
-
export
|
|
59
|
+
export type Tail20<T extends any[]> = ((...t: T) => any) extends (_1: any, _2: any, _3: any, _4: any, _5: any, _6: any, _7: any, _8: any, _9: any, _10: any, _11: any, _12: any, _13: any, _14: any, _15: any, _16: any, _17: any, _18: any, _19: any, _20: any, ...tail: infer TTail) => any ? TTail : [
|
|
60
60
|
];
|
|
61
61
|
/** Returns a mapped type of the function that removes the first parameter from the method */
|
|
62
|
-
export
|
|
62
|
+
export type Curried1<T extends (...args: any[]) => any> = (...tail: Tail1<Parameters<T>>) => ReturnType<T>;
|
|
63
63
|
/** Returns a mapped type of the function that removes the first 2 parameters from the method */
|
|
64
|
-
export
|
|
64
|
+
export type Curried2<T extends (...args: any[]) => any> = (...tail: Tail2<Parameters<T>>) => ReturnType<T>;
|
|
65
65
|
/** Returns a mapped type of the function that removes the first 3 parameters from the method */
|
|
66
|
-
export
|
|
66
|
+
export type Curried3<T extends (...args: any[]) => any> = (...tail: Tail3<Parameters<T>>) => ReturnType<T>;
|
|
67
67
|
/** Returns a mapped type of the function that removes the first 4 parameters from the method */
|
|
68
|
-
export
|
|
68
|
+
export type Curried4<T extends (...args: any[]) => any> = (...tail: Tail4<Parameters<T>>) => ReturnType<T>;
|
|
69
69
|
/** Returns a mapped type of the function that removes the first 5 parameters from the method */
|
|
70
|
-
export
|
|
70
|
+
export type Curried5<T extends (...args: any[]) => any> = (...tail: Tail5<Parameters<T>>) => ReturnType<T>;
|
|
71
71
|
/** Returns a mapped type of the function that removes the first 6 parameters from the method */
|
|
72
|
-
export
|
|
72
|
+
export type Curried6<T extends (...args: any[]) => any> = (...tail: Tail6<Parameters<T>>) => ReturnType<T>;
|
|
73
73
|
/** Returns a mapped type of the function that removes the first 7 parameters from the method */
|
|
74
|
-
export
|
|
74
|
+
export type Curried7<T extends (...args: any[]) => any> = (...tail: Tail7<Parameters<T>>) => ReturnType<T>;
|
|
75
75
|
/** Returns a mapped type of the function that removes the first 8 parameters from the method */
|
|
76
|
-
export
|
|
76
|
+
export type Curried8<T extends (...args: any[]) => any> = (...tail: Tail8<Parameters<T>>) => ReturnType<T>;
|
|
77
77
|
/** Returns a mapped type of the function that removes the first 9 parameters from the method */
|
|
78
|
-
export
|
|
78
|
+
export type Curried9<T extends (...args: any[]) => any> = (...tail: Tail9<Parameters<T>>) => ReturnType<T>;
|
|
79
79
|
/** Returns a mapped type of the function that removes the first 10 parameters from the method */
|
|
80
|
-
export
|
|
80
|
+
export type Curried10<T extends (...args: any[]) => any> = (...tail: Tail10<Parameters<T>>) => ReturnType<T>;
|
|
81
81
|
/** Returns a mapped type of the function that removes the first 11 parameters from the method */
|
|
82
|
-
export
|
|
82
|
+
export type Curried11<T extends (...args: any[]) => any> = (...tail: Tail11<Parameters<T>>) => ReturnType<T>;
|
|
83
83
|
/** Returns a mapped type of the function that removes the first 12 parameters from the method */
|
|
84
|
-
export
|
|
84
|
+
export type Curried12<T extends (...args: any[]) => any> = (...tail: Tail12<Parameters<T>>) => ReturnType<T>;
|
|
85
85
|
/** Returns a mapped type of the function that removes the first 13 parameters from the method */
|
|
86
|
-
export
|
|
86
|
+
export type Curried13<T extends (...args: any[]) => any> = (...tail: Tail13<Parameters<T>>) => ReturnType<T>;
|
|
87
87
|
/** Returns a mapped type of the function that removes the first 14 parameters from the method */
|
|
88
|
-
export
|
|
88
|
+
export type Curried14<T extends (...args: any[]) => any> = (...tail: Tail14<Parameters<T>>) => ReturnType<T>;
|
|
89
89
|
/** Returns a mapped type of the function that removes the first 15 parameters from the method */
|
|
90
|
-
export
|
|
90
|
+
export type Curried15<T extends (...args: any[]) => any> = (...tail: Tail15<Parameters<T>>) => ReturnType<T>;
|
|
91
91
|
/** Returns a mapped type of the function that removes the first 16 parameters from the method */
|
|
92
|
-
export
|
|
92
|
+
export type Curried16<T extends (...args: any[]) => any> = (...tail: Tail16<Parameters<T>>) => ReturnType<T>;
|
|
93
93
|
/** Returns a mapped type of the function that removes the first 17 parameters from the method */
|
|
94
|
-
export
|
|
94
|
+
export type Curried17<T extends (...args: any[]) => any> = (...tail: Tail17<Parameters<T>>) => ReturnType<T>;
|
|
95
95
|
/** Returns a mapped type of the function that removes the first 18 parameters from the method */
|
|
96
|
-
export
|
|
96
|
+
export type Curried18<T extends (...args: any[]) => any> = (...tail: Tail18<Parameters<T>>) => ReturnType<T>;
|
|
97
97
|
/** Returns a mapped type of the function that removes the first 19 parameters from the method */
|
|
98
|
-
export
|
|
98
|
+
export type Curried19<T extends (...args: any[]) => any> = (...tail: Tail19<Parameters<T>>) => ReturnType<T>;
|
|
99
99
|
/** Returns a mapped type of the function that removes the first 20 parameters from the method */
|
|
100
|
-
export
|
|
100
|
+
export type Curried20<T extends (...args: any[]) => any> = (...tail: Tail20<Parameters<T>>) => ReturnType<T>;
|
|
101
101
|
/** Returns the type in position 1 of the type array */
|
|
102
|
-
export
|
|
102
|
+
export type Param1<T extends any[]> = T extends [
|
|
103
103
|
any,
|
|
104
104
|
...any[]
|
|
105
105
|
] ? T[0] : never;
|
|
106
106
|
/** Returns the type in position 2 of the type array */
|
|
107
|
-
export
|
|
107
|
+
export type Param2<T extends any[]> = Param1<Tail1<T>>;
|
|
108
108
|
/** Returns the type in position 3 of the type array */
|
|
109
|
-
export
|
|
109
|
+
export type Param3<T extends any[]> = Param1<Tail2<T>>;
|
|
110
110
|
/** Returns the type in position 4 of the type array */
|
|
111
|
-
export
|
|
111
|
+
export type Param4<T extends any[]> = Param1<Tail3<T>>;
|
|
112
112
|
/** Returns the type in position 5 of the type array */
|
|
113
|
-
export
|
|
113
|
+
export type Param5<T extends any[]> = Param1<Tail4<T>>;
|
|
114
114
|
/** Returns the type in position 6 of the type array */
|
|
115
|
-
export
|
|
115
|
+
export type Param6<T extends any[]> = Param1<Tail5<T>>;
|
|
116
116
|
/** Returns the type in position 7 of the type array */
|
|
117
|
-
export
|
|
117
|
+
export type Param7<T extends any[]> = Param1<Tail6<T>>;
|
|
118
118
|
/** Returns the type in position 8 of the type array */
|
|
119
|
-
export
|
|
119
|
+
export type Param8<T extends any[]> = Param1<Tail7<T>>;
|
|
120
120
|
/** Returns the type in position 9 of the type array */
|
|
121
|
-
export
|
|
121
|
+
export type Param9<T extends any[]> = Param1<Tail8<T>>;
|
|
122
122
|
/** Returns the type in position 10 of the type array */
|
|
123
|
-
export
|
|
123
|
+
export type Param10<T extends any[]> = Param1<Tail9<T>>;
|
|
124
124
|
/** Returns the type in position 11 of the type array */
|
|
125
|
-
export
|
|
125
|
+
export type Param11<T extends any[]> = Param1<Tail10<T>>;
|
|
126
126
|
/** Returns the type in position 12 of the type array */
|
|
127
|
-
export
|
|
127
|
+
export type Param12<T extends any[]> = Param1<Tail11<T>>;
|
|
128
128
|
/** Returns the type in position 13 of the type array */
|
|
129
|
-
export
|
|
129
|
+
export type Param13<T extends any[]> = Param1<Tail12<T>>;
|
|
130
130
|
/** Returns the type in position 14 of the type array */
|
|
131
|
-
export
|
|
131
|
+
export type Param14<T extends any[]> = Param1<Tail13<T>>;
|
|
132
132
|
/** Returns the type in position 15 of the type array */
|
|
133
|
-
export
|
|
133
|
+
export type Param15<T extends any[]> = Param1<Tail14<T>>;
|
|
134
134
|
/** Returns the type in position 16 of the type array */
|
|
135
|
-
export
|
|
135
|
+
export type Param16<T extends any[]> = Param1<Tail15<T>>;
|
|
136
136
|
/** Returns the type in position 17 of the type array */
|
|
137
|
-
export
|
|
137
|
+
export type Param17<T extends any[]> = Param1<Tail16<T>>;
|
|
138
138
|
/** Returns the type in position 18 of the type array */
|
|
139
|
-
export
|
|
139
|
+
export type Param18<T extends any[]> = Param1<Tail17<T>>;
|
|
140
140
|
/** Returns the type in position 19 of the type array */
|
|
141
|
-
export
|
|
141
|
+
export type Param19<T extends any[]> = Param1<Tail18<T>>;
|
|
142
142
|
/** Returns the type in position 20 of the type array */
|
|
143
|
-
export
|
|
143
|
+
export type Param20<T extends any[]> = Param1<Tail19<T>>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { interfaces } from 'inversify';
|
|
3
3
|
import { Binder } from './binder';
|
|
4
|
-
import {
|
|
4
|
+
import { CamelPrefixed } from './naming/camel';
|
|
5
|
+
import { Prefixed } from './naming/none';
|
|
5
6
|
import { IFunctionResolver, KeysOfType, StringKeyof } from './tail.generated';
|
|
6
7
|
import { KeysNotOfType, NewableOf } from './types';
|
|
7
8
|
export * from './curry.generated';
|
|
8
9
|
export * from './inversify';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
10
|
+
export { CamelPrefixed } from './naming/camel';
|
|
11
|
+
export { Prefixed } from './naming/none';
|
|
12
|
+
export type BindingInWhenOnSyntax<T> = interfaces.BindingInWhenOnSyntax<T>;
|
|
13
|
+
export declare const internalContainer: import("inversify/lib/cjs/container/container").Container;
|
|
11
14
|
/** @deprecated LEGACY: Use this helper function to provide container curry functions */
|
|
12
15
|
export declare function containerRegisterFunctionResolver<T>(): {
|
|
13
16
|
curry1<TFn extends import("./tail.generated").Func, K1 extends KeysOfType<T, import("./curry.generated").Param1<Parameters<TFn>>>>(fn: TFn, key1: K1): IFunctionResolver<import("./curry.generated").Curried1<TFn>>;
|
|
@@ -42,8 +45,8 @@ export declare function containerRegister<TContainer>(): {
|
|
|
42
45
|
construct(keys: import("./types").TupleToKeysOfMapped<ConstructorParameters<C>, TContainer>): import("./inversify").BindingInWhenOnSyntax<InstanceType<C>>;
|
|
43
46
|
};
|
|
44
47
|
};
|
|
45
|
-
export
|
|
46
|
-
export
|
|
48
|
+
export type ContainerBinder<T, TItem, TDep> = (item: Binder<T, TItem, TDep>) => interfaces.BindingOnSyntax<TItem>;
|
|
49
|
+
export type ContainerBinding<T, TDep> = {
|
|
47
50
|
[P in keyof T]-?: ContainerBinder<T, T[P], TDep>;
|
|
48
51
|
};
|
|
49
52
|
/** The definition of an IoC Container */
|
|
@@ -58,11 +61,11 @@ export declare function containerFactory<T>(): IContainer<T>;
|
|
|
58
61
|
/** Register the bindings required for your container */
|
|
59
62
|
export declare function register<TContainer>(binding: ContainerBinding<TContainer, {}>): IContainer<TContainer>;
|
|
60
63
|
export declare function register<TContainer, TDep>(binding: ContainerBinding<TContainer, TDep>, dependent: IContainer<TDep>): IContainer<TContainer & TDep>;
|
|
61
|
-
export
|
|
64
|
+
export type NamingConvention = 'none' | 'camel';
|
|
62
65
|
/** Register the bindings required for your container */
|
|
63
|
-
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer>(convention: 'camel', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, {}>): IContainer<
|
|
64
|
-
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer, TDep>(convention: 'camel', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, TDep>, dependent: IContainer<TDep>): IContainer<
|
|
65
|
-
export declare function registerWithPrefix<TKeyPrefix extends string, T>(convention: 'none', prefix: TKeyPrefix, binding: ContainerBinding<T, {}>): IContainer<
|
|
66
|
-
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer, TDep>(convention: 'none', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, TDep>, dependent: IContainer<TDep>): IContainer<
|
|
66
|
+
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer>(convention: 'camel', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, {}>): IContainer<CamelPrefixed<TContainer, TKeyPrefix>>;
|
|
67
|
+
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer, TDep>(convention: 'camel', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, TDep>, dependent: IContainer<TDep>): IContainer<CamelPrefixed<TContainer, typeof prefix> & TDep>;
|
|
68
|
+
export declare function registerWithPrefix<TKeyPrefix extends string, T>(convention: 'none', prefix: TKeyPrefix, binding: ContainerBinding<T, {}>): IContainer<Prefixed<T, TKeyPrefix>>;
|
|
69
|
+
export declare function registerWithPrefix<TKeyPrefix extends string, TContainer, TDep>(convention: 'none', prefix: TKeyPrefix, binding: ContainerBinding<TContainer, TDep>, dependent: IContainer<TDep>): IContainer<Prefixed<TContainer, typeof prefix> & TDep>;
|
|
67
70
|
/** Safely merge two containers */
|
|
68
|
-
export declare function mergeContainers<T1, T2>(container1: IContainer<T1>, container2: IContainer<T2
|
|
71
|
+
export declare function mergeContainers<T1, T2>(container1: IContainer<T1>, container2: IContainer<T2>, sharedKeys?: string[]): IContainer<T1 & T2>;
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,8 @@ var binder_legacy_1 = require("./binder-legacy");
|
|
|
8
8
|
var curry_1 = require("./curry");
|
|
9
9
|
var error_1 = require("./error");
|
|
10
10
|
var inversify_1 = require("./inversify");
|
|
11
|
-
var
|
|
11
|
+
var camel_1 = require("./naming/camel");
|
|
12
|
+
var none_1 = require("./naming/none");
|
|
12
13
|
var tail_generated_1 = require("./tail.generated");
|
|
13
14
|
tslib_1.__exportStar(require("./curry.generated"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./inversify"), exports);
|
|
@@ -62,8 +63,8 @@ function containerFactory() {
|
|
|
62
63
|
return createContainerOf([]);
|
|
63
64
|
}
|
|
64
65
|
exports.containerFactory = containerFactory;
|
|
65
|
-
function getCombinedKeys(keys, dependent) {
|
|
66
|
-
var duplicates = keys.filter(function (k) { return dependent.indexOf(k) > -1; });
|
|
66
|
+
function getCombinedKeys(keys, dependent, sharedKeys) {
|
|
67
|
+
var duplicates = keys.filter(function (k) { return (!sharedKeys || sharedKeys.indexOf(k) > -1) && dependent.indexOf(k) > -1; });
|
|
67
68
|
if (duplicates.length) {
|
|
68
69
|
throw new error_1.IocDuplicateKeyError(duplicates);
|
|
69
70
|
}
|
|
@@ -75,6 +76,7 @@ function registerInternal(binding, transform, dependent) {
|
|
|
75
76
|
var mappedKeys = keys.reduce(function (record, key) {
|
|
76
77
|
var newKey = transform(key);
|
|
77
78
|
newKeys.push(newKey);
|
|
79
|
+
// eslint-disable-next-line no-param-reassign
|
|
78
80
|
record[key] = newKey;
|
|
79
81
|
return record;
|
|
80
82
|
}, {});
|
|
@@ -96,9 +98,9 @@ exports.register = register;
|
|
|
96
98
|
function keyTransformFactory(convention, prefix) {
|
|
97
99
|
switch (convention) {
|
|
98
100
|
case 'none':
|
|
99
|
-
return
|
|
101
|
+
return (0, none_1.keyTransform)(prefix);
|
|
100
102
|
case 'camel':
|
|
101
|
-
return
|
|
103
|
+
return (0, camel_1.camelKeyTransform)(prefix);
|
|
102
104
|
default: {
|
|
103
105
|
var n = convention;
|
|
104
106
|
throw new Error("Invalid IoC container prefix kind: ".concat(n));
|
|
@@ -106,13 +108,13 @@ function keyTransformFactory(convention, prefix) {
|
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
function registerWithPrefix(convention, prefix, binding, dependent) {
|
|
109
|
-
var
|
|
110
|
-
return registerInternal(binding,
|
|
111
|
+
var transform = keyTransformFactory(convention, prefix);
|
|
112
|
+
return registerInternal(binding, transform, dependent);
|
|
111
113
|
}
|
|
112
114
|
exports.registerWithPrefix = registerWithPrefix;
|
|
113
115
|
/** Safely merge two containers */
|
|
114
|
-
function mergeContainers(container1, container2) {
|
|
115
|
-
var combinedKeys = getCombinedKeys(container1.keys, container2.keys);
|
|
116
|
+
function mergeContainers(container1, container2, sharedKeys) {
|
|
117
|
+
var combinedKeys = getCombinedKeys(container1.keys, container2.keys, sharedKeys);
|
|
116
118
|
return createContainerOf(combinedKeys);
|
|
117
119
|
}
|
|
118
120
|
exports.mergeContainers = mergeContainers;
|
package/lib/inversify.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { Container, interfaces } from 'inversify';
|
|
2
2
|
import { Newable } from './types';
|
|
3
3
|
declare global {
|
|
4
|
-
|
|
5
|
-
interface Global {
|
|
6
|
-
_rocketmakers_ioc: Container;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
4
|
+
var _rocketmakers_ioc: Container;
|
|
9
5
|
}
|
|
10
6
|
export declare const reflectMetadataKeys: {
|
|
11
7
|
injectable: string;
|
|
@@ -26,5 +22,5 @@ export declare function makeInjected(classType: any, index: number, serviceIdent
|
|
|
26
22
|
export declare function makeParamUnmanaged(classType: any, parameterIndex: number): void;
|
|
27
23
|
/** @deprecated Renamed to makeParamUnmanaged */
|
|
28
24
|
export declare function makeUnmanaged(classType: any, parameterIndex: number): void;
|
|
29
|
-
export
|
|
25
|
+
export type BindingInWhenOnSyntax<T> = interfaces.BindingInWhenOnSyntax<T>;
|
|
30
26
|
export declare function registerClass<T extends Newable>(key: string, classType: T, ctorParams: string[]): BindingInWhenOnSyntax<InstanceType<T>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StringKeyof } from '../tail.generated';
|
|
2
|
+
export type CamelConvention<TPrefix extends string, TKey extends string> = `${TPrefix}${Capitalize<TKey>}`;
|
|
3
|
+
export type CamelPrefixed<T, TPrefix extends string> = {
|
|
4
|
+
[K in StringKeyof<T> as CamelConvention<TPrefix, K>]: T[K];
|
|
5
|
+
};
|
|
6
|
+
export declare function camelKeyTransform<TPrefix extends string>(prefix: TPrefix): <TKey extends string>(key: TKey) => CamelConvention<TPrefix, TKey>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.camelKeyTransform = void 0;
|
|
4
|
+
function capitalize(value) {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return (value[0].toUpperCase() + value.substring(1));
|
|
9
|
+
}
|
|
10
|
+
function camelKeyTransform(prefix) {
|
|
11
|
+
return function (key) { return "".concat(prefix).concat(capitalize(key)); };
|
|
12
|
+
}
|
|
13
|
+
exports.camelKeyTransform = camelKeyTransform;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StringKeyof } from '../tail.generated';
|
|
2
|
+
export type Convention<TPrefix extends string, TKey extends string> = `${TPrefix}${TKey}`;
|
|
3
|
+
export type Prefixed<T, TPrefix extends string> = {
|
|
4
|
+
[K in StringKeyof<T> as Convention<TPrefix, K>]: T[K];
|
|
5
|
+
};
|
|
6
|
+
export declare function keyTransform<TPrefix extends string>(prefix: TPrefix): <TKey extends string>(key: TKey) => Convention<TPrefix, TKey>;
|
package/lib/tail.generated.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { Param1, Curried1, Curried2, Curried3, Curried4, Curried5, Curried6, Cur
|
|
|
2
2
|
export interface IFunctionResolver<T> {
|
|
3
3
|
resolved: () => T;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type StringKeyof<T> = Extract<keyof T, string>;
|
|
6
|
+
export type KeysOfType<TMap, TKey> = {
|
|
7
7
|
[P in StringKeyof<TMap>]: TMap[P] extends TKey ? P : never;
|
|
8
8
|
}[StringKeyof<TMap>];
|
|
9
|
-
export
|
|
9
|
+
export type Func = (...args: any) => any;
|
|
10
10
|
export declare function containerRegisterFunctionResolverInternal<T>(curryInner: <TFn extends Func>(fn: TFn, ...keys: PropertyKey[]) => IFunctionResolver<any>): {
|
|
11
11
|
/** Curry out the first parameter from the method */
|
|
12
12
|
curry1<TFn extends Func, K1 extends KeysOfType<T, Param1<Parameters<TFn>>>>(fn: TFn, key1: K1): IFunctionResolver<Curried1<TFn>>;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { KeysOfType, StringKeyof } from './tail.generated';
|
|
2
|
-
export
|
|
2
|
+
export type KeysNotOfType<TMap, TKey> = {
|
|
3
3
|
[P in StringKeyof<TMap>]: TMap[P] extends TKey ? never : P;
|
|
4
4
|
}[StringKeyof<TMap>];
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
5
|
+
export type NewableOf<T> = new (...args: any) => T;
|
|
6
|
+
export type Newable = new (...args: any) => any;
|
|
7
|
+
export type TupleToKeysOfMapped<TTuple extends Array<any>, TMapped> = {
|
|
8
8
|
[K in keyof TTuple]: TTuple[K] extends TTuple[number] ? KeysOfType<TMapped, TTuple[K]> : never;
|
|
9
9
|
};
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocketmakers/ioc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start-test": "npm run build && node lib/test.js",
|
|
8
|
-
"start": "npm run build && node lib/index.js",
|
|
9
|
-
"build": "tsc -p source",
|
|
10
|
-
"test": "npm run build && ava --verbose"
|
|
11
|
-
},
|
|
12
6
|
"keywords": [],
|
|
13
7
|
"author": "",
|
|
14
8
|
"license": "ISC",
|
|
15
9
|
"dependencies": {
|
|
16
|
-
"inversify": "
|
|
17
|
-
"reflect-metadata": "
|
|
18
|
-
"tslib": "
|
|
10
|
+
"inversify": "6.1.6",
|
|
11
|
+
"reflect-metadata": "0.2.2",
|
|
12
|
+
"tslib": "2.8.1"
|
|
19
13
|
},
|
|
20
14
|
"devDependencies": {
|
|
21
|
-
"@types/node": "
|
|
22
|
-
"ava": "
|
|
23
|
-
"
|
|
24
|
-
"typescript
|
|
15
|
+
"@types/node": "20.17.9",
|
|
16
|
+
"ava": "3.15.0",
|
|
17
|
+
"eslint": "8.57.1",
|
|
18
|
+
"typescript": "4.9.5",
|
|
19
|
+
"typescript-json-schema": "0.65.1",
|
|
20
|
+
"eslint-config-ioc": "0.5.1",
|
|
21
|
+
"ioc-code-gen": "1.0.0",
|
|
22
|
+
"tsconfig-ioc": "0.5.1"
|
|
25
23
|
},
|
|
26
24
|
"publishConfig": {
|
|
27
25
|
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"lint": "eslint . --ext .ts",
|
|
29
|
+
"lint-fix": "pnpm lint --fix",
|
|
30
|
+
"start": "npm run build && node lib/index.js",
|
|
31
|
+
"build": "tsc -p ."
|
|
28
32
|
}
|
|
29
|
-
}
|
|
33
|
+
}
|
package/lib/prefix.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { StringKeyof } from './tail.generated';
|
|
2
|
-
export declare namespace Prefix {
|
|
3
|
-
type Convention<TPrefix extends string, TKey extends string> = `${TPrefix}${TKey}`;
|
|
4
|
-
export type Prefixed<T, TPrefix extends string> = {
|
|
5
|
-
[K in StringKeyof<T> as Convention<TPrefix, K>]: T[K];
|
|
6
|
-
};
|
|
7
|
-
export function keyTransform<TPrefix extends string>(prefix: TPrefix): <TKey extends string>(key: TKey) => Convention<TPrefix, TKey>;
|
|
8
|
-
export {};
|
|
9
|
-
}
|
|
10
|
-
export declare namespace CamelPrefix {
|
|
11
|
-
type Convention<TPrefix extends string, TKey extends string> = `${TPrefix}${Capitalize<TKey>}`;
|
|
12
|
-
export type Prefixed<T, TPrefix extends string> = {
|
|
13
|
-
[K in StringKeyof<T> as Convention<TPrefix, K>]: T[K];
|
|
14
|
-
};
|
|
15
|
-
export function keyTransform<TPrefix extends string>(prefix: TPrefix): <TKey extends string>(key: TKey) => Convention<TPrefix, TKey>;
|
|
16
|
-
export {};
|
|
17
|
-
}
|
package/lib/prefix.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamelPrefix = exports.Prefix = void 0;
|
|
4
|
-
var Prefix;
|
|
5
|
-
(function (Prefix) {
|
|
6
|
-
function keyTransform(prefix) {
|
|
7
|
-
return function (key) { return "".concat(prefix).concat(key); };
|
|
8
|
-
}
|
|
9
|
-
Prefix.keyTransform = keyTransform;
|
|
10
|
-
})(Prefix = exports.Prefix || (exports.Prefix = {}));
|
|
11
|
-
function capitalize(value) {
|
|
12
|
-
if (!value) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
return (value[0].toUpperCase() + value.substring(1));
|
|
16
|
-
}
|
|
17
|
-
var CamelPrefix;
|
|
18
|
-
(function (CamelPrefix) {
|
|
19
|
-
function keyTransform(prefix) {
|
|
20
|
-
return function (key) { return "".concat(prefix).concat(capitalize(key)); };
|
|
21
|
-
}
|
|
22
|
-
CamelPrefix.keyTransform = keyTransform;
|
|
23
|
-
})(CamelPrefix = exports.CamelPrefix || (exports.CamelPrefix = {}));
|