@loopback/context 1.25.0 → 2.1.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 +80 -0
- package/dist/binding-filter.d.ts +20 -2
- package/dist/binding-filter.js +58 -9
- package/dist/binding-filter.js.map +1 -1
- package/dist/binding.d.ts +50 -2
- package/dist/binding.js +33 -1
- package/dist/binding.js.map +1 -1
- package/dist/context-event.d.ts +23 -0
- package/dist/context-event.js +7 -0
- package/dist/context-event.js.map +1 -0
- package/dist/context-observer.d.ts +1 -36
- package/dist/context-subscription.d.ts +147 -0
- package/dist/context-subscription.js +336 -0
- package/dist/context-subscription.js.map +1 -0
- package/dist/context-tag-indexer.d.ts +42 -0
- package/dist/context-tag-indexer.js +134 -0
- package/dist/context-tag-indexer.js.map +1 -0
- package/dist/context-view.d.ts +2 -1
- package/dist/context-view.js.map +1 -1
- package/dist/context.d.ts +44 -68
- package/dist/context.js +69 -249
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/inject.d.ts +9 -2
- package/dist/inject.js +60 -0
- package/dist/inject.js.map +1 -1
- package/dist/interceptor.js +4 -4
- package/dist/interceptor.js.map +1 -1
- package/dist/invocation.d.ts +0 -1
- package/dist/invocation.js +1 -5
- package/dist/invocation.js.map +1 -1
- package/dist/json-types.d.ts +28 -0
- package/dist/json-types.js +7 -0
- package/dist/json-types.js.map +1 -0
- package/dist/resolution-session.d.ts +2 -6
- package/dist/resolution-session.js +0 -4
- package/dist/resolution-session.js.map +1 -1
- package/dist/value-promise.d.ts +1 -3
- package/package.json +9 -9
- package/src/binding-filter.ts +83 -11
- package/src/binding.ts +79 -3
- package/src/context-event.ts +30 -0
- package/src/context-observer.ts +1 -38
- package/src/context-subscription.ts +403 -0
- package/src/context-tag-indexer.ts +149 -0
- package/src/context-view.ts +2 -5
- package/src/context.ts +104 -290
- package/src/index.ts +3 -0
- package/src/inject.ts +65 -0
- package/src/interceptor.ts +7 -6
- package/src/invocation.ts +1 -3
- package/src/json-types.ts +35 -0
- package/src/resolution-session.ts +4 -7
- package/src/value-promise.ts +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
2
|
+
// Node module: @loopback/context
|
|
3
|
+
// This file is licensed under the MIT License.
|
|
4
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type definition for JSON types
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* JSON primitive types:
|
|
12
|
+
* - string
|
|
13
|
+
* - number
|
|
14
|
+
* - boolean
|
|
15
|
+
* - null
|
|
16
|
+
*/
|
|
17
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JSON values
|
|
21
|
+
* - primitive
|
|
22
|
+
* - object
|
|
23
|
+
* - array
|
|
24
|
+
*/
|
|
25
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* JSON object
|
|
29
|
+
*/
|
|
30
|
+
export interface JSONObject extends Record<string, JSONValue> {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* JSON array
|
|
34
|
+
*/
|
|
35
|
+
export interface JSONArray extends Array<JSONValue> {}
|
|
@@ -155,9 +155,7 @@ export class ResolutionSession {
|
|
|
155
155
|
* Describe the injection for debugging purpose
|
|
156
156
|
* @param injection - Injection object
|
|
157
157
|
*/
|
|
158
|
-
static describeInjection(injection
|
|
159
|
-
/* istanbul ignore if */
|
|
160
|
-
if (injection == null) return {};
|
|
158
|
+
static describeInjection(injection: Readonly<Injection>) {
|
|
161
159
|
const name = getTargetName(
|
|
162
160
|
injection.target,
|
|
163
161
|
injection.member,
|
|
@@ -166,8 +164,7 @@ export class ResolutionSession {
|
|
|
166
164
|
return {
|
|
167
165
|
targetName: name,
|
|
168
166
|
bindingSelector: injection.bindingSelector,
|
|
169
|
-
|
|
170
|
-
metadata: injection.metadata as object,
|
|
167
|
+
metadata: injection.metadata,
|
|
171
168
|
};
|
|
172
169
|
}
|
|
173
170
|
|
|
@@ -300,14 +297,14 @@ export class ResolutionSession {
|
|
|
300
297
|
*/
|
|
301
298
|
getInjectionPath() {
|
|
302
299
|
return this.injectionStack
|
|
303
|
-
.map(i => ResolutionSession.describeInjection(i)
|
|
300
|
+
.map(i => ResolutionSession.describeInjection(i).targetName)
|
|
304
301
|
.join(' --> ');
|
|
305
302
|
}
|
|
306
303
|
|
|
307
304
|
private static describe(e: ResolutionElement) {
|
|
308
305
|
switch (e.type) {
|
|
309
306
|
case 'injection':
|
|
310
|
-
return '@' + ResolutionSession.describeInjection(e.value)
|
|
307
|
+
return '@' + ResolutionSession.describeInjection(e.value).targetName;
|
|
311
308
|
case 'binding':
|
|
312
309
|
return e.value.key;
|
|
313
310
|
}
|
package/src/value-promise.ts
CHANGED