@loopback/context 3.5.1 → 3.8.1
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 +60 -0
- package/dist/binding-config.js +1 -0
- package/dist/binding-config.js.map +1 -1
- package/dist/binding-decorator.d.ts +1 -2
- package/dist/binding-decorator.js +1 -0
- package/dist/binding-decorator.js.map +1 -1
- package/dist/binding-filter.d.ts +2 -2
- package/dist/binding-filter.js +4 -3
- package/dist/binding-filter.js.map +1 -1
- package/dist/binding-inspector.d.ts +14 -7
- package/dist/binding-inspector.js +14 -6
- package/dist/binding-inspector.js.map +1 -1
- package/dist/binding-key.d.ts +5 -0
- package/dist/binding-key.js +104 -90
- package/dist/binding-key.js.map +1 -1
- package/dist/binding-sorter.js +1 -0
- package/dist/binding-sorter.js.map +1 -1
- package/dist/binding.d.ts +84 -7
- package/dist/binding.js +120 -35
- package/dist/binding.js.map +1 -1
- package/dist/context-subscription.js +1 -0
- package/dist/context-subscription.js.map +1 -1
- package/dist/context-tag-indexer.js +1 -0
- package/dist/context-tag-indexer.js.map +1 -1
- package/dist/context-view.js +1 -0
- package/dist/context-view.js.map +1 -1
- package/dist/context.js +2 -2
- package/dist/context.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/inject-config.js +1 -0
- package/dist/inject-config.js.map +1 -1
- package/dist/inject.d.ts +13 -6
- package/dist/inject.js +6 -8
- package/dist/inject.js.map +1 -1
- package/dist/interception-proxy.js +1 -0
- package/dist/interception-proxy.js.map +1 -1
- package/dist/interceptor-chain.d.ts +39 -4
- package/dist/interceptor-chain.js +26 -4
- package/dist/interceptor-chain.js.map +1 -1
- package/dist/interceptor.d.ts +28 -3
- package/dist/interceptor.js +54 -0
- package/dist/interceptor.js.map +1 -1
- package/dist/invocation.js +1 -0
- package/dist/invocation.js.map +1 -1
- package/dist/keys.d.ts +5 -0
- package/dist/keys.js +6 -0
- package/dist/keys.js.map +1 -1
- package/dist/resolution-session.d.ts +26 -6
- package/dist/resolution-session.js +1 -0
- package/dist/resolution-session.js.map +1 -1
- package/dist/resolver.js +1 -0
- package/dist/resolver.js.map +1 -1
- package/dist/value-promise.d.ts +8 -4
- package/dist/value-promise.js +17 -0
- package/dist/value-promise.js.map +1 -1
- package/package.json +13 -13
- package/src/binding-decorator.ts +2 -3
- package/src/binding-filter.ts +8 -7
- package/src/binding-inspector.ts +32 -9
- package/src/binding-key.ts +12 -0
- package/src/binding.ts +210 -44
- package/src/context.ts +2 -2
- package/src/inject.ts +22 -16
- package/src/interceptor-chain.ts +66 -7
- package/src/interceptor.ts +85 -2
- package/src/keys.ts +6 -0
- package/src/resolution-session.ts +30 -2
- package/src/value-promise.ts +13 -0
- package/index.d.ts +0 -6
- package/index.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,66 @@
|
|
|
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.8.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.8.0...@loopback/context@3.8.1) (2020-05-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/context
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.8.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.7.0...@loopback/context@3.8.0) (2020-05-19)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **context:** check parameter design type for method injections ([7e81e10](https://github.com/strongloop/loopback-next/commit/7e81e10f8d5c5c5cd9be0e091fde9bf8c4b1e3b3))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **context:** allow bindings to be created from dynamic value provider classes ([9e15154](https://github.com/strongloop/loopback-next/commit/9e15154dae3a3b51b5e090ecfe4052f416051332))
|
|
25
|
+
* **context:** pass resolution context to the factory function for toDynamicValue() ([6513d3f](https://github.com/strongloop/loopback-next/commit/6513d3f5e36b90f58501cfbf311b2b26210d44dd))
|
|
26
|
+
* **context:** use a `_source` to keep the original value provider for bindings ([90679f3](https://github.com/strongloop/loopback-next/commit/90679f3826a8cf18f06123503a9b96c763b5dc20))
|
|
27
|
+
* **core:** allow extensionFilter to take a list of extension point names ([8f315eb](https://github.com/strongloop/loopback-next/commit/8f315eb46bee7365da5325a23b948df9d477bfdb))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [3.7.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.6.0...@loopback/context@3.7.0) (2020-05-07)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **context:** allow binding keys to be used with composeInterceptors() ([0663c04](https://github.com/strongloop/loopback-next/commit/0663c0425b77cbbfa6391e0c4bd92f56b590a548))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* **context:** add registerInterceptor helper function and app.interceptor ([c760966](https://github.com/strongloop/loopback-next/commit/c76096684771ffaf535b75b025892ccfb057bff0))
|
|
44
|
+
* **context:** allow composition of intercetors ([261e9eb](https://github.com/strongloop/loopback-next/commit/261e9eb7d197fc480ab241bdd3b70b8a6e272908))
|
|
45
|
+
* **context:** allows bindings with singleton/context scopes to be refreshed ([8155147](https://github.com/strongloop/loopback-next/commit/8155147ceae756b60a0c9289f94ea8be6199c6d7))
|
|
46
|
+
* **context:** allows default namespace for bindings from classes ([ec2da01](https://github.com/strongloop/loopback-next/commit/ec2da01d766881da1c90dd47c50f8af319e04614))
|
|
47
|
+
* **context:** consolidate uuid generation and testing ([5abe25e](https://github.com/strongloop/loopback-next/commit/5abe25ecc2632b0d25140b5e863dfee446c29a01))
|
|
48
|
+
* **context:** force interceptor functions to return a value ([5663a76](https://github.com/strongloop/loopback-next/commit/5663a7642cbbb43fab08020d398393d0aabeed86))
|
|
49
|
+
* **context:** relax parameter type for isProviderClass() ([aafe7d0](https://github.com/strongloop/loopback-next/commit/aafe7d002a3bc0d2a1db5aceb054f25cb4f4f11f))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# [3.6.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.5.1...@loopback/context@3.6.0) (2020-04-29)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* **context:** add `BindingKey.generate` to generate unique binding keys ([9478d31](https://github.com/strongloop/loopback-next/commit/9478d319a472e1dca4122a29dbb414ce1525bdb0))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
6
66
|
## [3.5.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.5.0...@loopback/context@3.5.1) (2020-04-23)
|
|
7
67
|
|
|
8
68
|
**Note:** Version bump only for package @loopback/context
|
package/dist/binding-config.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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.configBindingKeyFor = exports.DefaultConfigurationResolver = void 0;
|
|
7
8
|
const binding_key_1 = require("./binding-key");
|
|
8
9
|
/**
|
|
9
10
|
* Resolver for configurations of bindings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-config.js","sourceRoot":"","sources":["../src/binding-config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"binding-config.js","sourceRoot":"","sources":["../src/binding-config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,+CAAyD;AAgCzD;;GAEG;AACH,MAAa,4BAA4B;IACvC,YAA4B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEhD,yBAAyB,CACvB,GAA4B,EAC5B,YAAqB,EACrB,iBAAqC;QAErC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,mBAAmB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAsB,MAAM,CAAC,MAAM,CAC9C,EAAC,QAAQ,EAAE,IAAI,EAAC,EAChB,iBAAiB,CAClB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAkB,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF;AAjBD,oEAiBC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,GAAmB,EACnB,YAAqB;IAErB,OAAO,wBAAU,CAAC,MAAM,CACtB,wBAAU,CAAC,iBAAiB,CAAkB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAC7D,YAAY,CACb,CAAC;AACJ,CAAC;AARD,kDAQC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BindingSpec } from './binding-inspector';
|
|
2
|
-
import { Provider } from './provider';
|
|
3
2
|
import { Constructor } from './value-promise';
|
|
4
3
|
/**
|
|
5
4
|
* Decorate a class with binding configuration
|
|
@@ -22,5 +21,5 @@ export declare namespace bind {
|
|
|
22
21
|
*
|
|
23
22
|
* A list of binding scope/tags or template functions to configure the binding
|
|
24
23
|
*/
|
|
25
|
-
function provider(...specs: BindingSpec[]): (target: Constructor<
|
|
24
|
+
function provider(...specs: BindingSpec[]): (target: Constructor<unknown>) => void;
|
|
26
25
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
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
8
|
const metadata_1 = require("@loopback/metadata");
|
|
8
9
|
const binding_inspector_1 = require("./binding-inspector");
|
|
9
10
|
/**
|
|
@@ -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
|
|
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,oBAAqB,SAAQ,gCAAsC;IACvE,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,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 -93,9 +93,9 @@ export declare const ANY_TAG_VALUE: TagValueMatcher;
|
|
|
93
93
|
/**
|
|
94
94
|
* Create a tag value matcher function that returns `true` if the target tag
|
|
95
95
|
* value equals to the item value or is an array that includes the item value.
|
|
96
|
-
* @param
|
|
96
|
+
* @param itemValues - A list of tag item value
|
|
97
97
|
*/
|
|
98
|
-
export declare function includesTagValue(
|
|
98
|
+
export declare function includesTagValue(...itemValues: unknown[]): TagValueMatcher;
|
|
99
99
|
/**
|
|
100
100
|
* Create a binding filter for the tag pattern
|
|
101
101
|
* @param tagPattern - Binding tag name, regexp, or object
|
package/dist/binding-filter.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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.filterByKey = exports.filterByTag = exports.includesTagValue = exports.ANY_TAG_VALUE = exports.isBindingTagFilter = exports.isBindingAddress = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* Check if an object is a `BindingKey` by duck typing
|
|
9
10
|
* @param selector Binding selector
|
|
@@ -60,11 +61,11 @@ exports.ANY_TAG_VALUE = (tagValue, tagName, tagMap) => tagName in tagMap;
|
|
|
60
61
|
/**
|
|
61
62
|
* Create a tag value matcher function that returns `true` if the target tag
|
|
62
63
|
* value equals to the item value or is an array that includes the item value.
|
|
63
|
-
* @param
|
|
64
|
+
* @param itemValues - A list of tag item value
|
|
64
65
|
*/
|
|
65
|
-
function includesTagValue(
|
|
66
|
+
function includesTagValue(...itemValues) {
|
|
66
67
|
return tagValue => {
|
|
67
|
-
return (
|
|
68
|
+
return itemValues.some(itemValue =>
|
|
68
69
|
// The tag value equals the item value
|
|
69
70
|
tagValue === itemValue ||
|
|
70
71
|
// The tag value contains the item value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-filter.js","sourceRoot":"","sources":["../src/binding-filter.ts"],"names":[],"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;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,oCAAoC;IACpC,gCAAgC;IAChC,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC1E,qCAAqC;IACrC,yDAAyD;IACzD,+CAA+C;IAC/C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MetadataAccessor } from '@loopback/metadata';
|
|
2
|
-
import { Binding, BindingScope, BindingTag, BindingTemplate } from './binding';
|
|
2
|
+
import { Binding, BindingScope, BindingTag, BindingTemplate, DynamicValueProviderClass } from './binding';
|
|
3
3
|
import { BindingAddress } from './binding-key';
|
|
4
4
|
import { Provider } from './provider';
|
|
5
5
|
import { Constructor } from './value-promise';
|
|
@@ -39,7 +39,7 @@ export declare type BindingSpec<T = unknown> = BindingTemplate<T> | BindingScope
|
|
|
39
39
|
*
|
|
40
40
|
* @typeParam T - Value type
|
|
41
41
|
*/
|
|
42
|
-
export declare function isProviderClass<T>(cls:
|
|
42
|
+
export declare function isProviderClass<T>(cls: unknown): cls is Constructor<Provider<T>>;
|
|
43
43
|
/**
|
|
44
44
|
* A factory function to create a template function to bind the target class
|
|
45
45
|
* as a `Provider`.
|
|
@@ -52,10 +52,11 @@ export declare function asProvider<T>(target: Constructor<Provider<T>>): Binding
|
|
|
52
52
|
* A factory function to create a template function to bind the target class
|
|
53
53
|
* as a class or `Provider`.
|
|
54
54
|
* @param target - Target class, which can be an implementation of `Provider`
|
|
55
|
+
* or `DynamicValueProviderClass`
|
|
55
56
|
*
|
|
56
57
|
* @typeParam T - Value type
|
|
57
58
|
*/
|
|
58
|
-
export declare function asClassOrProvider<T>(target: Constructor<T | Provider<T>>): BindingTemplate<T>;
|
|
59
|
+
export declare function asClassOrProvider<T>(target: Constructor<T | Provider<T>> | DynamicValueProviderClass<T>): BindingTemplate<T>;
|
|
59
60
|
/**
|
|
60
61
|
* Convert binding scope and tags as a template function
|
|
61
62
|
* @param scopeAndTags - Binding scope and tags
|
|
@@ -81,7 +82,7 @@ export declare function removeNameAndKeyTags(binding: Binding<unknown>): void;
|
|
|
81
82
|
*
|
|
82
83
|
* @typeParam T - Value type
|
|
83
84
|
*/
|
|
84
|
-
export declare function bindingTemplateFor<T>(cls: Constructor<T | Provider<T>>): BindingTemplate<T>;
|
|
85
|
+
export declare function bindingTemplateFor<T>(cls: Constructor<T | Provider<T>> | DynamicValueProviderClass<T>): BindingTemplate<T>;
|
|
85
86
|
/**
|
|
86
87
|
* Mapping artifact types to binding key namespaces (prefixes).
|
|
87
88
|
*
|
|
@@ -109,17 +110,23 @@ export declare type BindingFromClassOptions = {
|
|
|
109
110
|
*/
|
|
110
111
|
type?: string;
|
|
111
112
|
/**
|
|
112
|
-
* Artifact name, such as `my-rest-server` and `my-controller
|
|
113
|
+
* Artifact name, such as `my-rest-server` and `my-controller`. It
|
|
114
|
+
* overrides the name tag
|
|
113
115
|
*/
|
|
114
116
|
name?: string;
|
|
115
117
|
/**
|
|
116
|
-
* Namespace for the binding key, such as `servers` and `controllers
|
|
118
|
+
* Namespace for the binding key, such as `servers` and `controllers`. It
|
|
119
|
+
* overrides the default namespace or namespace tag
|
|
117
120
|
*/
|
|
118
121
|
namespace?: string;
|
|
119
122
|
/**
|
|
120
123
|
* Mapping artifact type to binding key namespaces
|
|
121
124
|
*/
|
|
122
125
|
typeNamespaceMapping?: TypeNamespaceMapping;
|
|
126
|
+
/**
|
|
127
|
+
* Default namespace if the binding does not have an explicit namespace
|
|
128
|
+
*/
|
|
129
|
+
defaultNamespace?: string;
|
|
123
130
|
/**
|
|
124
131
|
* Default scope if the binding does not have an explicit scope
|
|
125
132
|
*/
|
|
@@ -137,4 +144,4 @@ export declare type BindingFromClassOptions = {
|
|
|
137
144
|
*
|
|
138
145
|
* @typeParam T - Value type
|
|
139
146
|
*/
|
|
140
|
-
export declare function createBindingFromClass<T>(cls: Constructor<T | Provider<T
|
|
147
|
+
export declare function createBindingFromClass<T>(cls: Constructor<T | Provider<T>> | DynamicValueProviderClass<T>, options?: BindingFromClassOptions): Binding<T>;
|
|
@@ -4,6 +4,7 @@
|
|
|
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.createBindingFromClass = exports.DEFAULT_TYPE_NAMESPACES = exports.bindingTemplateFor = exports.removeNameAndKeyTags = exports.getBindingMetadata = exports.asBindingTemplate = exports.asClassOrProvider = exports.asProvider = exports.isProviderClass = exports.BINDING_METADATA_KEY = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const metadata_1 = require("@loopback/metadata");
|
|
9
10
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -22,7 +23,7 @@ exports.BINDING_METADATA_KEY = metadata_1.MetadataAccessor.create('binding.metad
|
|
|
22
23
|
*/
|
|
23
24
|
function isProviderClass(cls) {
|
|
24
25
|
var _a;
|
|
25
|
-
return typeof
|
|
26
|
+
return (typeof cls === 'function' && typeof ((_a = cls.prototype) === null || _a === void 0 ? void 0 : _a.value) === 'function');
|
|
26
27
|
}
|
|
27
28
|
exports.isProviderClass = isProviderClass;
|
|
28
29
|
/**
|
|
@@ -44,6 +45,7 @@ exports.asProvider = asProvider;
|
|
|
44
45
|
* A factory function to create a template function to bind the target class
|
|
45
46
|
* as a class or `Provider`.
|
|
46
47
|
* @param target - Target class, which can be an implementation of `Provider`
|
|
48
|
+
* or `DynamicValueProviderClass`
|
|
47
49
|
*
|
|
48
50
|
* @typeParam T - Value type
|
|
49
51
|
*/
|
|
@@ -53,6 +55,11 @@ function asClassOrProvider(target) {
|
|
|
53
55
|
if (isProviderClass(target)) {
|
|
54
56
|
asProvider(target)(binding);
|
|
55
57
|
}
|
|
58
|
+
else if (binding_1.isDynamicValueProviderClass(target)) {
|
|
59
|
+
binding.toDynamicValue(target).tag(keys_1.ContextTags.DYNAMIC_VALUE_PROVIDER, {
|
|
60
|
+
[keys_1.ContextTags.TYPE]: keys_1.ContextTags.DYNAMIC_VALUE_PROVIDER,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
56
63
|
else {
|
|
57
64
|
binding.toClass(target);
|
|
58
65
|
}
|
|
@@ -127,6 +134,7 @@ exports.bindingTemplateFor = bindingTemplateFor;
|
|
|
127
134
|
exports.DEFAULT_TYPE_NAMESPACES = {
|
|
128
135
|
class: 'classes',
|
|
129
136
|
provider: 'providers',
|
|
137
|
+
dynamicValueProvider: 'dynamicValueProviders',
|
|
130
138
|
};
|
|
131
139
|
/**
|
|
132
140
|
* Create a binding from a class with decorated metadata. The class is attached
|
|
@@ -204,7 +212,7 @@ function getNamespace(type, typeNamespaces = exports.DEFAULT_TYPE_NAMESPACES) {
|
|
|
204
212
|
* @typeParam T - Value type
|
|
205
213
|
*/
|
|
206
214
|
function buildBindingKey(cls, options = {}) {
|
|
207
|
-
var _a, _b, _c, _d;
|
|
215
|
+
var _a, _b, _c, _d, _e;
|
|
208
216
|
if (options.key)
|
|
209
217
|
return options.key;
|
|
210
218
|
const templateFn = bindingTemplateFor(cls);
|
|
@@ -214,17 +222,17 @@ function buildBindingKey(cls, options = {}) {
|
|
|
214
222
|
let key = bindingTemplate.tagMap[keys_1.ContextTags.KEY];
|
|
215
223
|
if (key)
|
|
216
224
|
return key;
|
|
217
|
-
let namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : bindingTemplate.tagMap[keys_1.ContextTags.NAMESPACE];
|
|
225
|
+
let namespace = (_b = (_a = options.namespace) !== null && _a !== void 0 ? _a : bindingTemplate.tagMap[keys_1.ContextTags.NAMESPACE]) !== null && _b !== void 0 ? _b : options.defaultNamespace;
|
|
218
226
|
if (!namespace) {
|
|
219
227
|
const namespaces = Object.assign({}, exports.DEFAULT_TYPE_NAMESPACES, options.typeNamespaceMapping);
|
|
220
228
|
// Derive the key from type + name
|
|
221
|
-
let type = (
|
|
229
|
+
let type = (_c = options.type) !== null && _c !== void 0 ? _c : bindingTemplate.tagMap[keys_1.ContextTags.TYPE];
|
|
222
230
|
if (!type) {
|
|
223
|
-
type = (
|
|
231
|
+
type = (_d = bindingTemplate.tagNames.find(t => namespaces[t] != null)) !== null && _d !== void 0 ? _d : keys_1.ContextTags.CLASS;
|
|
224
232
|
}
|
|
225
233
|
namespace = getNamespace(type, namespaces);
|
|
226
234
|
}
|
|
227
|
-
const name = (
|
|
235
|
+
const name = (_e = options.name) !== null && _e !== void 0 ? _e : (bindingTemplate.tagMap[keys_1.ContextTags.NAME] || cls.name);
|
|
228
236
|
key = `${namespace}.${name}`;
|
|
229
237
|
return key;
|
|
230
238
|
}
|
|
@@ -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,gEAAgE
|
|
1
|
+
{"version":3,"file":"binding-inspector.js","sourceRoot":"","sources":["../src/binding-inspector.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,iDAAuE;AACvE,0DAAiC;AACjC,uCAOmB;AAEnB,iCAAmC;AAInC,MAAM,KAAK,GAAG,eAAY,CAAC,oCAAoC,CAAC,CAAC;AAkBjE;;GAEG;AACU,QAAA,oBAAoB,GAAG,2BAAgB,CAAC,MAAM,CAGzD,kBAAkB,CAAC,CAAC;AAetB;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,GAAY;;IAEZ,OAAO,CACL,OAAO,GAAG,KAAK,UAAU,IAAI,cAAO,GAAG,CAAC,SAAS,0CAAE,KAA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,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
|
@@ -54,4 +54,9 @@ export declare class BindingKey<ValueType> {
|
|
|
54
54
|
* @param key - Key of the target binding to be configured
|
|
55
55
|
*/
|
|
56
56
|
static buildKeyForConfig<T>(key?: BindingAddress): BindingAddress<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Generate a unique binding key with `uuid`
|
|
59
|
+
* @param namespace - Namespace for the binding
|
|
60
|
+
*/
|
|
61
|
+
static generate<T>(namespace?: string): BindingKey<T>;
|
|
57
62
|
}
|
package/dist/binding-key.js
CHANGED
|
@@ -4,102 +4,116 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* BindingKey.create<string>('application.name');
|
|
19
|
-
* BindingKey.create<number>('config', 'rest.port);
|
|
20
|
-
* BindingKey.create<number>('config#rest.port');
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param key - The binding key. When propertyPath is not provided, the key
|
|
24
|
-
* is allowed to contain propertyPath as encoded via `BindingKey#toString()`
|
|
25
|
-
* @param propertyPath - Optional path to a deep property of the bound value.
|
|
26
|
-
*/
|
|
27
|
-
static create(key, propertyPath) {
|
|
28
|
-
// TODO(bajtos) allow chaining of propertyPaths, e.g.
|
|
29
|
-
// BindingKey.create('config#rest', 'port')
|
|
30
|
-
// should create {key: 'config', path: 'rest.port'}
|
|
31
|
-
if (propertyPath) {
|
|
32
|
-
BindingKey.validate(key);
|
|
33
|
-
return new BindingKey(key, propertyPath);
|
|
7
|
+
exports.BindingKey = void 0;
|
|
8
|
+
const value_promise_1 = require("./value-promise");
|
|
9
|
+
let BindingKey = /** @class */ (() => {
|
|
10
|
+
class BindingKey {
|
|
11
|
+
constructor(key, propertyPath) {
|
|
12
|
+
this.key = key;
|
|
13
|
+
this.propertyPath = propertyPath;
|
|
34
14
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
static validate(key) {
|
|
61
|
-
if (!key)
|
|
62
|
-
throw new Error('Binding key must be provided.');
|
|
63
|
-
key = key.toString();
|
|
64
|
-
if (key.includes(BindingKey.PROPERTY_SEPARATOR)) {
|
|
65
|
-
throw new Error(`Binding key ${key} cannot contain` +
|
|
66
|
-
` '${BindingKey.PROPERTY_SEPARATOR}'.`);
|
|
15
|
+
/**
|
|
16
|
+
* Create a new key for a binding bound to a value of type `ValueType`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* BindingKey.create<string>('application.name');
|
|
22
|
+
* BindingKey.create<number>('config', 'rest.port);
|
|
23
|
+
* BindingKey.create<number>('config#rest.port');
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param key - The binding key. When propertyPath is not provided, the key
|
|
27
|
+
* is allowed to contain propertyPath as encoded via `BindingKey#toString()`
|
|
28
|
+
* @param propertyPath - Optional path to a deep property of the bound value.
|
|
29
|
+
*/
|
|
30
|
+
static create(key, propertyPath) {
|
|
31
|
+
// TODO(bajtos) allow chaining of propertyPaths, e.g.
|
|
32
|
+
// BindingKey.create('config#rest', 'port')
|
|
33
|
+
// should create {key: 'config', path: 'rest.port'}
|
|
34
|
+
if (propertyPath) {
|
|
35
|
+
BindingKey.validate(key);
|
|
36
|
+
return new BindingKey(key, propertyPath);
|
|
37
|
+
}
|
|
38
|
+
return BindingKey.parseKeyWithPath(key);
|
|
67
39
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
40
|
+
toString() {
|
|
41
|
+
return this.propertyPath
|
|
42
|
+
? `${this.key}${BindingKey.PROPERTY_SEPARATOR}${this.propertyPath}`
|
|
43
|
+
: this.key;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a binding address for retrieving a deep property of the object
|
|
47
|
+
* bound to the current binding key.
|
|
48
|
+
*
|
|
49
|
+
* @param propertyPath - A dot-separated path to a (deep) property, e.g. "server.port".
|
|
50
|
+
*/
|
|
51
|
+
deepProperty(propertyPath) {
|
|
52
|
+
// TODO(bajtos) allow chaining of propertyPaths, e.g.
|
|
53
|
+
// BindingKey.create('config', 'rest').deepProperty('port')
|
|
54
|
+
// should create {key: 'config', path: 'rest.port'}
|
|
55
|
+
return BindingKey.create(this.key, propertyPath);
|
|
80
56
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Validate the binding key format. Please note that `#` is reserved.
|
|
59
|
+
* Returns a string representation of the binding key.
|
|
60
|
+
*
|
|
61
|
+
* @param key - Binding key, such as `a`, `a.b`, `a:b`, or `a/b`
|
|
62
|
+
*/
|
|
63
|
+
static validate(key) {
|
|
64
|
+
if (!key)
|
|
65
|
+
throw new Error('Binding key must be provided.');
|
|
66
|
+
key = key.toString();
|
|
67
|
+
if (key.includes(BindingKey.PROPERTY_SEPARATOR)) {
|
|
68
|
+
throw new Error(`Binding key ${key} cannot contain` +
|
|
69
|
+
` '${BindingKey.PROPERTY_SEPARATOR}'.`);
|
|
70
|
+
}
|
|
71
|
+
return key;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parse a string containing both the binding key and the path to the deeply
|
|
75
|
+
* nested property to retrieve.
|
|
76
|
+
*
|
|
77
|
+
* @param keyWithPath - The key with an optional path,
|
|
78
|
+
* e.g. "application.instance" or "config#rest.port".
|
|
79
|
+
*/
|
|
80
|
+
static parseKeyWithPath(keyWithPath) {
|
|
81
|
+
if (typeof keyWithPath !== 'string') {
|
|
82
|
+
return BindingKey.create(keyWithPath.key, keyWithPath.propertyPath);
|
|
83
|
+
}
|
|
84
|
+
const index = keyWithPath.indexOf(BindingKey.PROPERTY_SEPARATOR);
|
|
85
|
+
if (index === -1) {
|
|
86
|
+
return new BindingKey(keyWithPath);
|
|
87
|
+
}
|
|
88
|
+
return BindingKey.create(keyWithPath.substr(0, index).trim(), keyWithPath.substr(index + 1));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Build a binding key for the configuration of the given binding.
|
|
92
|
+
* The format is `<key>:$config`
|
|
93
|
+
*
|
|
94
|
+
* @param key - Key of the target binding to be configured
|
|
95
|
+
*/
|
|
96
|
+
static buildKeyForConfig(key = '') {
|
|
97
|
+
const suffix = BindingKey.CONFIG_NAMESPACE;
|
|
98
|
+
const bindingKey = key ? `${key}:${suffix}` : suffix;
|
|
99
|
+
return bindingKey;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generate a unique binding key with `uuid`
|
|
103
|
+
* @param namespace - Namespace for the binding
|
|
104
|
+
*/
|
|
105
|
+
static generate(namespace = '') {
|
|
106
|
+
const prefix = namespace ? `${namespace}.` : '';
|
|
107
|
+
const name = value_promise_1.uuid();
|
|
108
|
+
return BindingKey.create(`${prefix}${name}`);
|
|
84
109
|
}
|
|
85
|
-
return BindingKey.create(keyWithPath.substr(0, index).trim(), keyWithPath.substr(index + 1));
|
|
86
110
|
}
|
|
111
|
+
BindingKey.PROPERTY_SEPARATOR = '#';
|
|
87
112
|
/**
|
|
88
|
-
*
|
|
89
|
-
* The format is `<key>:$config`
|
|
90
|
-
*
|
|
91
|
-
* @param key - Key of the target binding to be configured
|
|
113
|
+
* Name space for configuration binding keys
|
|
92
114
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return bindingKey;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
115
|
+
BindingKey.CONFIG_NAMESPACE = '$config';
|
|
116
|
+
return BindingKey;
|
|
117
|
+
})();
|
|
99
118
|
exports.BindingKey = BindingKey;
|
|
100
|
-
BindingKey.PROPERTY_SEPARATOR = '#';
|
|
101
|
-
/**
|
|
102
|
-
* Name space for configuration binding keys
|
|
103
|
-
*/
|
|
104
|
-
BindingKey.CONFIG_NAMESPACE = '$config';
|
|
105
119
|
//# sourceMappingURL=binding-key.js.map
|
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
|
|
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,mDAAqC;AAIrC;IAAA,MAAa,UAAU;QAiCrB,YACkB,GAAW,EACX,YAAqB;YADrB,QAAG,GAAH,GAAG,CAAQ;YACX,iBAAY,GAAZ,YAAY,CAAS;QACpC,CAAC;QAjCJ;;;;;;;;;;;;;;WAcG;QACI,MAAM,CAAC,MAAM,CAClB,GAAW,EACX,YAAqB;YAErB,qDAAqD;YACrD,6CAA6C;YAC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AU,CAAC,kBAAkB,CAAC,CAAC;YACjE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBAChB,OAAO,IAAI,UAAU,CAAI,WAAW,CAAC,CAAC;aACvC;YAED,OAAO,UAAU,CAAC,MAAM,CACtB,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,EACnC,WAAW,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAC9B,CAAC;QACJ,CAAC;QAOD;;;;;WAKG;QACH,MAAM,CAAC,iBAAiB,CAAI,MAAsB,EAAE;YAClD,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC;YAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YACrD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED;;;WAGG;QACH,MAAM,CAAC,QAAQ,CAAI,SAAS,GAAG,EAAE;YAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,oBAAI,EAAE,CAAC;YACpB,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;;IA1He,6BAAkB,GAAG,GAAG,CAAC;IAiGzC;;OAEG;IACI,2BAAgB,GAAG,SAAS,CAAC;IAuBtC,iBAAC;KAAA;AA5HY,gCAAU"}
|
package/dist/binding-sorter.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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.sortBindingsByPhase = exports.compareByOrder = exports.compareBindingsByTag = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* Creates a binding compare function to sort bindings by tagged phase name.
|
|
9
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-sorter.js","sourceRoot":"","sources":["../src/binding-sorter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"binding-sorter.js","sourceRoot":"","sources":["../src/binding-sorter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AA6BhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,oBAAoB,CAClC,YAAY,GAAG,OAAO,EACtB,gBAAqC,EAAE;IAEvC,OAAO,CAAC,CAA6B,EAAE,CAA6B,EAAE,EAAE;QACtE,OAAO,cAAc,CACnB,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EACtB,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EACtB,aAAa,CACd,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,oDAWC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,cAAc,CAC5B,CAAqC,EACrC,CAAqC,EACrC,QAA6B,EAAE;IAE/B,CAAC,GAAG,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAC;IACZ,CAAC,GAAG,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAC;IACZ,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE;QAC1B,kBAAkB;QAClB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB;SAAM;QACL,4CAA4C;QAE5C,6BAA6B;QAC7B,IAAI,OAAO,CAAC,KAAK,QAAQ,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