@loopback/context 3.10.0 → 3.12.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/CHANGELOG.md +44 -0
- package/dist/binding-decorator.d.ts +24 -4
- package/dist/binding-decorator.js +34 -11
- package/dist/binding-decorator.js.map +1 -1
- package/dist/binding-inspector.d.ts +8 -5
- package/dist/binding-inspector.js +6 -3
- package/dist/binding-inspector.js.map +1 -1
- package/dist/binding-key.d.ts +1 -1
- package/dist/binding-key.js +1 -0
- package/dist/binding-key.js.map +1 -1
- package/dist/binding.d.ts +63 -6
- package/dist/binding.js +112 -36
- package/dist/binding.js.map +1 -1
- package/dist/context-view.d.ts +8 -8
- package/dist/context-view.js.map +1 -1
- package/dist/context.d.ts +25 -4
- package/dist/context.js +80 -4
- package/dist/context.js.map +1 -1
- package/dist/inject.d.ts +9 -2
- package/dist/inject.js +25 -11
- package/dist/inject.js.map +1 -1
- package/dist/interceptor-chain.d.ts +1 -0
- package/dist/interceptor-chain.js.map +1 -1
- package/dist/interceptor.js +1 -1
- package/dist/interceptor.js.map +1 -1
- package/dist/resolver.js +5 -7
- package/dist/resolver.js.map +1 -1
- package/dist/value-promise.d.ts +4 -4
- package/dist/value-promise.js +2 -2
- package/dist/value-promise.js.map +1 -1
- package/package.json +11 -11
- package/src/binding-decorator.ts +35 -9
- package/src/binding-inspector.ts +8 -5
- package/src/binding-key.ts +3 -5
- package/src/binding.ts +123 -36
- package/src/context-view.ts +8 -7
- package/src/context.ts +100 -5
- package/src/inject.ts +37 -15
- package/src/interceptor-chain.ts +1 -0
- package/src/interceptor.ts +2 -2
- package/src/resolver.ts +5 -9
- package/src/value-promise.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.12.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.11.1...@loopback/context@3.12.0) (2020-10-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **context:** introduce new binding scopes ([9916cfd](https://github.com/strongloop/loopback-next/commit/9916cfd4449a870f7a3378e2e674957aed7c1626))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [3.11.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.11.0...@loopback/context@3.11.1) (2020-09-17)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @loopback/context
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [3.11.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.10.1...@loopback/context@3.11.0) (2020-09-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* improve handling of missing design-time type metadata ([95b6a2b](https://github.com/strongloop/loopback-next/commit/95b6a2b7ce64e614720df43b905f77a53a54e438))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **context:** add `[@injectable](https://github.com/injectable)` as a preferred decorator for `[@bind](https://github.com/bind)` ([1f75c35](https://github.com/strongloop/loopback-next/commit/1f75c35937a4190564bdade48b0782c4364f6101))
|
|
36
|
+
* allow dynamic value provider classes and classes with [@inject](https://github.com/inject) to be booted ([7b85cdf](https://github.com/strongloop/loopback-next/commit/7b85cdf63730ef659a4ee799f05f02eea8a1e3e8))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [3.10.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.10.0...@loopback/context@3.10.1) (2020-08-27)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @loopback/context
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
6
50
|
# [3.10.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.9.4...@loopback/context@3.10.0) (2020-08-19)
|
|
7
51
|
|
|
8
52
|
|
|
@@ -5,8 +5,9 @@ import { Constructor } from './value-promise';
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* @
|
|
8
|
+
* @injectable((binding) => {binding.inScope(BindingScope.SINGLETON).tag('controller')}
|
|
9
9
|
* )
|
|
10
|
+
* @injectable({scope: BindingScope.SINGLETON})
|
|
10
11
|
* export class MyController {
|
|
11
12
|
* }
|
|
12
13
|
* ```
|
|
@@ -14,12 +15,31 @@ import { Constructor } from './value-promise';
|
|
|
14
15
|
* @param specs - A list of binding scope/tags or template functions to
|
|
15
16
|
* configure the binding
|
|
16
17
|
*/
|
|
17
|
-
export declare function
|
|
18
|
-
|
|
18
|
+
export declare function injectable(...specs: BindingSpec[]): ClassDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* A namespace to host shortcuts for `@injectable`
|
|
21
|
+
*/
|
|
22
|
+
export declare namespace injectable {
|
|
19
23
|
/**
|
|
20
|
-
* `@
|
|
24
|
+
* `@injectable.provider` to denote a provider class
|
|
21
25
|
*
|
|
22
26
|
* A list of binding scope/tags or template functions to configure the binding
|
|
23
27
|
*/
|
|
24
28
|
function provider(...specs: BindingSpec[]): (target: Constructor<unknown>) => void;
|
|
25
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* `@bind` is now an alias to {@link injectable} for backward compatibility
|
|
32
|
+
* {@inheritDoc injectable}
|
|
33
|
+
*/
|
|
34
|
+
export declare function bind(...specs: BindingSpec[]): ClassDecorator;
|
|
35
|
+
/**
|
|
36
|
+
* Alias namespace `bind` to `injectable` for backward compatibility
|
|
37
|
+
*
|
|
38
|
+
* It should have the same members as `bind`.
|
|
39
|
+
*/
|
|
40
|
+
export declare namespace bind {
|
|
41
|
+
/**
|
|
42
|
+
* {@inheritDoc injectable.provider}
|
|
43
|
+
*/
|
|
44
|
+
const provider: typeof injectable.provider;
|
|
45
|
+
}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.bind = void 0;
|
|
7
|
+
exports.bind = exports.injectable = void 0;
|
|
8
8
|
const metadata_1 = require("@loopback/metadata");
|
|
9
9
|
const binding_inspector_1 = require("./binding-inspector");
|
|
10
10
|
/**
|
|
11
|
-
* Decorator factory for `@
|
|
11
|
+
* Decorator factory for `@injectable`
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class InjectableDecoratorFactory extends metadata_1.ClassDecoratorFactory {
|
|
14
14
|
mergeWithInherited(inherited, target) {
|
|
15
15
|
if (inherited) {
|
|
16
16
|
return {
|
|
@@ -43,8 +43,9 @@ class BindDecoratorFactory extends metadata_1.ClassDecoratorFactory {
|
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
-
* @
|
|
46
|
+
* @injectable((binding) => {binding.inScope(BindingScope.SINGLETON).tag('controller')}
|
|
47
47
|
* )
|
|
48
|
+
* @injectable({scope: BindingScope.SINGLETON})
|
|
48
49
|
* export class MyController {
|
|
49
50
|
* }
|
|
50
51
|
* ```
|
|
@@ -52,7 +53,7 @@ class BindDecoratorFactory extends metadata_1.ClassDecoratorFactory {
|
|
|
52
53
|
* @param specs - A list of binding scope/tags or template functions to
|
|
53
54
|
* configure the binding
|
|
54
55
|
*/
|
|
55
|
-
function
|
|
56
|
+
function injectable(...specs) {
|
|
56
57
|
const templateFunctions = specs.map(t => {
|
|
57
58
|
if (typeof t === 'function') {
|
|
58
59
|
return t;
|
|
@@ -67,14 +68,17 @@ function bind(...specs) {
|
|
|
67
68
|
templates: [binding_inspector_1.asClassOrProvider(cls), ...templateFunctions],
|
|
68
69
|
target: cls,
|
|
69
70
|
};
|
|
70
|
-
const decorator =
|
|
71
|
+
const decorator = InjectableDecoratorFactory.createDecorator(binding_inspector_1.BINDING_METADATA_KEY, spec, { decoratorName: '@injectable' });
|
|
71
72
|
decorator(target);
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
|
-
exports.
|
|
75
|
-
|
|
75
|
+
exports.injectable = injectable;
|
|
76
|
+
/**
|
|
77
|
+
* A namespace to host shortcuts for `@injectable`
|
|
78
|
+
*/
|
|
79
|
+
(function (injectable) {
|
|
76
80
|
/**
|
|
77
|
-
* `@
|
|
81
|
+
* `@injectable.provider` to denote a provider class
|
|
78
82
|
*
|
|
79
83
|
* A list of binding scope/tags or template functions to configure the binding
|
|
80
84
|
*/
|
|
@@ -83,13 +87,32 @@ exports.bind = bind;
|
|
|
83
87
|
if (!binding_inspector_1.isProviderClass(target)) {
|
|
84
88
|
throw new Error(`Target ${target} is not a Provider`);
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
injectable(
|
|
87
91
|
// Set up the default for providers
|
|
88
92
|
binding_inspector_1.asProvider(target),
|
|
89
93
|
// Call other template functions
|
|
90
94
|
...specs)(target);
|
|
91
95
|
};
|
|
92
96
|
}
|
|
93
|
-
|
|
97
|
+
injectable.provider = provider;
|
|
98
|
+
})(injectable = exports.injectable || (exports.injectable = {}));
|
|
99
|
+
/**
|
|
100
|
+
* `@bind` is now an alias to {@link injectable} for backward compatibility
|
|
101
|
+
* {@inheritDoc injectable}
|
|
102
|
+
*/
|
|
103
|
+
function bind(...specs) {
|
|
104
|
+
return injectable(...specs);
|
|
105
|
+
}
|
|
106
|
+
exports.bind = bind;
|
|
107
|
+
/**
|
|
108
|
+
* Alias namespace `bind` to `injectable` for backward compatibility
|
|
109
|
+
*
|
|
110
|
+
* It should have the same members as `bind`.
|
|
111
|
+
*/
|
|
112
|
+
(function (bind) {
|
|
113
|
+
/**
|
|
114
|
+
* {@inheritDoc injectable.provider}
|
|
115
|
+
*/
|
|
116
|
+
bind.provider = injectable.provider;
|
|
94
117
|
})(bind = exports.bind || (exports.bind = {}));
|
|
95
118
|
//# sourceMappingURL=binding-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../src/binding-decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,iDAAyD;AACzD,2DAS6B;AAG7B;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../src/binding-decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,iDAAyD;AACzD,2DAS6B;AAG7B;;GAEG;AACH,MAAM,0BAA2B,SAAQ,gCAExC;IACC,kBAAkB,CAAC,SAA0B,EAAE,MAAgB;QAC7D,IAAI,SAAS,EAAE;YACb,OAAO;gBACL,SAAS,EAAE;oBACT,GAAG,SAAS,CAAC,SAAS;oBACtB,wCAAoB;oBACpB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS;iBACvB;gBACD,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;aACzB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACnC,OAAO,IAAI,CAAC,IAAI,CAAC;SAClB;IACH,CAAC;IAED,YAAY,CAAC,WAA4B;QACvC,OAAO;YACL,SAAS,EAAE,CAAC,GAAG,WAAW,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YAC7D,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;SACzB,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,IAAqB,EAAE,MAAgB;QAChD,IAAI,CAAC,MAAM,GAAG,MAA8B,CAAC;QAC7C,OAAO,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AAI,CAAC,GAAG,KAAoB;IAC1C,OAAO,UAAU,CAAC,GAAG,KAAK,CAAC,CAAC;AAC9B,CAAC;AAFD,oBAEC;AAED;;;;GAIG;AACH,WAAiB,IAAI;IACnB;;OAEG;IACU,aAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AAC9C,CAAC,EALgB,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAKpB"}
|
|
@@ -4,7 +4,7 @@ import { BindingAddress } from './binding-key';
|
|
|
4
4
|
import { Provider } from './provider';
|
|
5
5
|
import { Constructor } from './value-promise';
|
|
6
6
|
/**
|
|
7
|
-
* Binding metadata from `@
|
|
7
|
+
* Binding metadata from `@injectable`
|
|
8
8
|
*
|
|
9
9
|
* @typeParam T - Value type
|
|
10
10
|
*/
|
|
@@ -30,7 +30,7 @@ export declare type BindingScopeAndTags = {
|
|
|
30
30
|
tags?: BindingTag | BindingTag[];
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* Specification of parameters for `@
|
|
33
|
+
* Specification of parameters for `@injectable()`
|
|
34
34
|
*/
|
|
35
35
|
export declare type BindingSpec<T = unknown> = BindingTemplate<T> | BindingScopeAndTags;
|
|
36
36
|
/**
|
|
@@ -78,7 +78,7 @@ export declare function removeNameAndKeyTags(binding: Binding<unknown>): void;
|
|
|
78
78
|
/**
|
|
79
79
|
* Get the binding template for a class with binding metadata
|
|
80
80
|
*
|
|
81
|
-
* @param cls - A class with optional `@
|
|
81
|
+
* @param cls - A class with optional `@injectable`
|
|
82
82
|
*
|
|
83
83
|
* @typeParam T - Value type
|
|
84
84
|
*/
|
|
@@ -136,10 +136,13 @@ export declare type BindingFromClassOptions = {
|
|
|
136
136
|
* Create a binding from a class with decorated metadata. The class is attached
|
|
137
137
|
* to the binding as follows:
|
|
138
138
|
* - `binding.toClass(cls)`: if `cls` is a plain class such as `MyController`
|
|
139
|
-
* - `binding.toProvider(cls)`:
|
|
139
|
+
* - `binding.toProvider(cls)`: if `cls` is a value provider class with a
|
|
140
140
|
* prototype method `value()`
|
|
141
|
+
* - `binding.toDynamicValue(cls)`: if `cls` is a dynamic value provider class
|
|
142
|
+
* with a static method `value()`
|
|
141
143
|
*
|
|
142
|
-
* @param cls - A class. It can be either a plain class
|
|
144
|
+
* @param cls - A class. It can be either a plain class, a value provider class,
|
|
145
|
+
* or a dynamic value provider class
|
|
143
146
|
* @param options - Options to customize the binding key
|
|
144
147
|
*
|
|
145
148
|
* @typeParam T - Value type
|
|
@@ -111,7 +111,7 @@ exports.removeNameAndKeyTags = removeNameAndKeyTags;
|
|
|
111
111
|
/**
|
|
112
112
|
* Get the binding template for a class with binding metadata
|
|
113
113
|
*
|
|
114
|
-
* @param cls - A class with optional `@
|
|
114
|
+
* @param cls - A class with optional `@injectable`
|
|
115
115
|
*
|
|
116
116
|
* @typeParam T - Value type
|
|
117
117
|
*/
|
|
@@ -140,10 +140,13 @@ exports.DEFAULT_TYPE_NAMESPACES = {
|
|
|
140
140
|
* Create a binding from a class with decorated metadata. The class is attached
|
|
141
141
|
* to the binding as follows:
|
|
142
142
|
* - `binding.toClass(cls)`: if `cls` is a plain class such as `MyController`
|
|
143
|
-
* - `binding.toProvider(cls)`:
|
|
143
|
+
* - `binding.toProvider(cls)`: if `cls` is a value provider class with a
|
|
144
144
|
* prototype method `value()`
|
|
145
|
+
* - `binding.toDynamicValue(cls)`: if `cls` is a dynamic value provider class
|
|
146
|
+
* with a static method `value()`
|
|
145
147
|
*
|
|
146
|
-
* @param cls - A class. It can be either a plain class
|
|
148
|
+
* @param cls - A class. It can be either a plain class, a value provider class,
|
|
149
|
+
* or a dynamic value provider class
|
|
147
150
|
* @param options - Options to customize the binding key
|
|
148
151
|
*
|
|
149
152
|
* @typeParam T - Value type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-inspector.js","sourceRoot":"","sources":["../src/binding-inspector.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAA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AC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClE,wBAAwB;IACxB,IAAI,GAAG,GAAW,eAAe,CAAC,MAAM,CAAC,kBAAW,CAAC,GAAG,CAAC,CAAC;IAC1D,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IAEpB,IAAI,SAAS,eACX,OAAO,CAAC,SAAS,mCACjB,eAAe,CAAC,MAAM,CAAC,kBAAW,CAAC,SAAS,CAAC,mCAC7C,OAAO,CAAC,gBAAgB,CAAC;IAC3B,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAC9B,EAAE,EACF,+BAAuB,EACvB,OAAO,CAAC,oBAAoB,CAC7B,CAAC;QACF,kCAAkC;QAClC,IAAI,IAAI,SAAG,OAAO,CAAC,IAAI,mCAAI,eAAe,CAAC,MAAM,CAAC,kBAAW,CAAC,IAAI,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,SACF,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,mCACzD,kBAAW,CAAC,KAAK,CAAC;SACrB;QACD,SAAS,GAAG,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;KAC5C;IAED,MAAM,IAAI,SACR,OAAO,CAAC,IAAI,mCAAI,CAAC,eAAe,CAAC,MAAM,CAAC,kBAAW,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IACzE,GAAG,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;IAE7B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/binding-key.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class BindingKey<ValueType> {
|
|
|
18
18
|
* is allowed to contain propertyPath as encoded via `BindingKey#toString()`
|
|
19
19
|
* @param propertyPath - Optional path to a deep property of the bound value.
|
|
20
20
|
*/
|
|
21
|
-
static create<
|
|
21
|
+
static create<V>(key: string, propertyPath?: string): BindingKey<V>;
|
|
22
22
|
private constructor();
|
|
23
23
|
toString(): string;
|
|
24
24
|
/**
|
package/dist/binding-key.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.BindingKey = void 0;
|
|
8
8
|
const unique_id_1 = require("./unique-id");
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
10
|
class BindingKey {
|
|
10
11
|
constructor(key, propertyPath) {
|
|
11
12
|
this.key = key;
|
package/dist/binding-key.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-key.js","sourceRoot":"","sources":["../src/binding-key.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,2CAA6C;AAI7C,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"binding-key.js","sourceRoot":"","sources":["../src/binding-key.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,2CAA6C;AAI7C,6DAA6D;AAC7D,MAAa,UAAU;IA8BrB,YACkB,GAAW,EACX,YAAqB;QADrB,QAAG,GAAH,GAAG,CAAQ;QACX,iBAAY,GAAZ,YAAY,CAAS;IACpC,CAAC;IA9BJ;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAC,MAAM,CAAI,GAAW,EAAE,YAAqB;QACxD,qDAAqD;QACrD,6CAA6C;QAC7C,mDAAmD;QACnD,IAAI,YAAY,EAAE;YAChB,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,IAAI,UAAU,CAAI,GAAG,EAAE,YAAY,CAAC,CAAC;SAC7C;QAED,OAAO,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;I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nC,WAAW,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAC9B,CAAC;IACJ,CAAC;IAOD;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAI,MAAsB,EAAE;QAClD,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC;QAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACrD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAI,SAAS,GAAG,EAAE;QAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,4BAAgB,EAAE,CAAC;QAChC,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;;AA5HH,gCA6HC;AA5HiB,6BAAkB,GAAG,GAAG,CAAC;AA8FzC;;GAEG;AACI,2BAAgB,GAAG,SAAS,CAAC"}
|
package/dist/binding.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export declare enum BindingScope {
|
|
|
30
30
|
*/
|
|
31
31
|
TRANSIENT = "Transient",
|
|
32
32
|
/**
|
|
33
|
+
* @deprecated Finer-grained scopes such as `APPLICATION`, `SERVER`, or
|
|
34
|
+
* `REQUEST` should be used instead to ensure the scope of sharing of resolved
|
|
35
|
+
* binding values.
|
|
36
|
+
*
|
|
33
37
|
* The binding provides a value as a singleton within each local context. The
|
|
34
38
|
* value is calculated only once per context and cached for subsequential
|
|
35
39
|
* uses. Child contexts have their own value and do not share with their
|
|
@@ -51,6 +55,7 @@ export declare enum BindingScope {
|
|
|
51
55
|
* 3. `'b1'` is resolved in `app` but not in `req2`, a new value `2` is
|
|
52
56
|
* calculated and used for `req2` afterward
|
|
53
57
|
* - req2.get('b1') ==> 2 (always)
|
|
58
|
+
*
|
|
54
59
|
*/
|
|
55
60
|
CONTEXT = "Context",
|
|
56
61
|
/**
|
|
@@ -74,7 +79,53 @@ export declare enum BindingScope {
|
|
|
74
79
|
* 3. `'b1'` is resolved in `app`, reuse it for `req2`
|
|
75
80
|
* - req2.get('b1') ==> 0 (always)
|
|
76
81
|
*/
|
|
77
|
-
SINGLETON = "Singleton"
|
|
82
|
+
SINGLETON = "Singleton",
|
|
83
|
+
/**
|
|
84
|
+
* Application scope
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* The binding provides an application-scoped value within the context
|
|
88
|
+
* hierarchy. Resolved value for this binding will be cached and shared for
|
|
89
|
+
* the same application context (denoted by its scope property set to
|
|
90
|
+
* `BindingScope.APPLICATION`).
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
APPLICATION = "Application",
|
|
94
|
+
/**
|
|
95
|
+
* Server scope
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* The binding provides an server-scoped value within the context hierarchy.
|
|
99
|
+
* Resolved value for this binding will be cached and shared for the same
|
|
100
|
+
* server context (denoted by its scope property set to
|
|
101
|
+
* `BindingScope.SERVER`).
|
|
102
|
+
*
|
|
103
|
+
* It's possible that an application has more than one servers configured,
|
|
104
|
+
* such as a `RestServer` and a `GrpcServer`. Both server contexts are created
|
|
105
|
+
* with `scope` set to `BindingScope.SERVER`. Depending on where a binding
|
|
106
|
+
* is resolved:
|
|
107
|
+
* - If the binding is resolved from the RestServer or below, it will be
|
|
108
|
+
* cached using the RestServer context as the key.
|
|
109
|
+
* - If the binding is resolved from the GrpcServer or below, it will be
|
|
110
|
+
* cached using the GrpcServer context as the key.
|
|
111
|
+
*
|
|
112
|
+
* The same binding can resolved/shared/cached for all servers, each of which
|
|
113
|
+
* has its own value for the binding.
|
|
114
|
+
*/
|
|
115
|
+
SERVER = "Server",
|
|
116
|
+
/**
|
|
117
|
+
* Request scope
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* The binding provides an request-scoped value within the context hierarchy.
|
|
121
|
+
* Resolved value for this binding will be cached and shared for the same
|
|
122
|
+
* request context (denoted by its scope property set to
|
|
123
|
+
* `BindingScope.REQUEST`).
|
|
124
|
+
*
|
|
125
|
+
* The `REQUEST` scope is very useful for controllers, services and artifacts
|
|
126
|
+
* that want to have a single instance/value for a given request.
|
|
127
|
+
*/
|
|
128
|
+
REQUEST = "Request"
|
|
78
129
|
}
|
|
79
130
|
/**
|
|
80
131
|
* Type of the binding source
|
|
@@ -245,7 +296,7 @@ export declare class Binding<T = BoundValue> extends EventEmitter {
|
|
|
245
296
|
constructor(key: BindingAddress<T>, isLocked?: boolean);
|
|
246
297
|
/**
|
|
247
298
|
* Cache the resolved value by the binding scope
|
|
248
|
-
* @param
|
|
299
|
+
* @param resolutionCtx - The resolution context
|
|
249
300
|
* @param result - The calculated value for the binding
|
|
250
301
|
*/
|
|
251
302
|
private _cacheValue;
|
|
@@ -255,7 +306,7 @@ export declare class Binding<T = BoundValue> extends EventEmitter {
|
|
|
255
306
|
private _clearCache;
|
|
256
307
|
/**
|
|
257
308
|
* Invalidate the binding cache so that its value will be reloaded next time.
|
|
258
|
-
* This is useful to force reloading a
|
|
309
|
+
* This is useful to force reloading a cached value when its configuration or
|
|
259
310
|
* dependencies are changed.
|
|
260
311
|
* **WARNING**: The state held in the cached value will be gone.
|
|
261
312
|
*
|
|
@@ -296,6 +347,12 @@ export declare class Binding<T = BoundValue> extends EventEmitter {
|
|
|
296
347
|
* @param options - Optional options for binding and dependency resolution
|
|
297
348
|
*/
|
|
298
349
|
getValue(ctx: Context, options?: ResolutionOptions): ValueOrPromise<T | undefined>;
|
|
350
|
+
/**
|
|
351
|
+
* Locate and validate the resolution context
|
|
352
|
+
* @param ctx - Current context
|
|
353
|
+
* @param options - Resolution options
|
|
354
|
+
*/
|
|
355
|
+
private getResolutionContext;
|
|
299
356
|
/**
|
|
300
357
|
* Lock the binding so that it cannot be rebound
|
|
301
358
|
*/
|
|
@@ -448,7 +505,7 @@ export declare class Binding<T = BoundValue> extends EventEmitter {
|
|
|
448
505
|
* easy to read.
|
|
449
506
|
* @param key - Binding key
|
|
450
507
|
*/
|
|
451
|
-
static bind<
|
|
508
|
+
static bind<V = unknown>(key: BindingAddress<V>): Binding<V>;
|
|
452
509
|
/**
|
|
453
510
|
* Create a configuration binding for the given key
|
|
454
511
|
*
|
|
@@ -458,12 +515,12 @@ export declare class Binding<T = BoundValue> extends EventEmitter {
|
|
|
458
515
|
* .to({port: 3000});
|
|
459
516
|
* ```
|
|
460
517
|
*
|
|
461
|
-
* @typeParam
|
|
518
|
+
* @typeParam V Generic type for the configuration value (not the binding to
|
|
462
519
|
* be configured)
|
|
463
520
|
*
|
|
464
521
|
* @param key - Key for the binding to be configured
|
|
465
522
|
*/
|
|
466
|
-
static configure<
|
|
523
|
+
static configure<V = unknown>(key: BindingAddress): Binding<V>;
|
|
467
524
|
/**
|
|
468
525
|
* The "changed" event is emitted by methods such as `tag`, `inScope`, `to`,
|
|
469
526
|
* and `toClass`.
|