@loopback/context 4.0.0-alpha.9 → 4.0.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/LICENSE +25 -0
- package/README.md +116 -0
- package/dist/binding-config.d.ts +40 -0
- package/dist/binding-config.js +33 -0
- package/dist/binding-config.js.map +1 -0
- package/dist/binding-decorator.d.ts +45 -0
- package/dist/binding-decorator.js +118 -0
- package/dist/binding-decorator.js.map +1 -0
- package/dist/binding-filter.d.ts +108 -0
- package/dist/binding-filter.js +162 -0
- package/dist/binding-filter.js.map +1 -0
- package/dist/binding-inspector.d.ts +150 -0
- package/dist/binding-inspector.js +249 -0
- package/dist/binding-inspector.js.map +1 -0
- package/dist/binding-key.d.ts +66 -0
- package/dist/binding-key.js +121 -0
- package/dist/binding-key.js.map +1 -0
- package/dist/binding-sorter.d.ts +71 -0
- package/dist/binding-sorter.js +89 -0
- package/dist/binding-sorter.js.map +1 -0
- package/dist/binding.d.ts +577 -0
- package/dist/binding.js +788 -0
- package/dist/binding.js.map +1 -0
- 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 +36 -0
- package/dist/context-observer.js +7 -0
- package/dist/context-observer.js.map +1 -0
- package/dist/context-subscription.d.ts +147 -0
- package/dist/context-subscription.js +317 -0
- package/dist/context-subscription.js.map +1 -0
- package/dist/context-tag-indexer.d.ts +42 -0
- package/dist/context-tag-indexer.js +135 -0
- package/dist/context-tag-indexer.js.map +1 -0
- package/dist/context-view.d.ts +209 -0
- package/dist/context-view.js +240 -0
- package/dist/context-view.js.map +1 -0
- package/dist/context.d.ts +513 -0
- package/dist/context.js +717 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/inject-config.d.ts +67 -0
- package/dist/inject-config.js +181 -0
- package/dist/inject-config.js.map +1 -0
- package/dist/inject.d.ts +250 -0
- package/dist/inject.js +535 -0
- package/dist/inject.js.map +1 -0
- package/dist/interception-proxy.d.ts +76 -0
- package/dist/interception-proxy.js +67 -0
- package/dist/interception-proxy.js.map +1 -0
- package/dist/interceptor-chain.d.ts +121 -0
- package/dist/interceptor-chain.js +148 -0
- package/dist/interceptor-chain.js.map +1 -0
- package/dist/interceptor.d.ts +138 -0
- package/dist/interceptor.js +299 -0
- package/dist/interceptor.js.map +1 -0
- package/dist/invocation.d.ts +101 -0
- package/dist/invocation.js +163 -0
- package/dist/invocation.js.map +1 -0
- package/dist/json-types.d.ts +28 -0
- package/{lib/src/provider.js → dist/json-types.js} +3 -3
- package/dist/json-types.js.map +1 -0
- package/dist/keys.d.ts +65 -0
- package/dist/keys.js +74 -0
- package/dist/keys.js.map +1 -0
- package/dist/provider.d.ts +31 -0
- package/{lib6/src → dist}/provider.js +2 -2
- package/dist/provider.js.map +1 -0
- package/dist/resolution-session.d.ts +180 -0
- package/dist/resolution-session.js +274 -0
- package/dist/resolution-session.js.map +1 -0
- package/dist/resolver.d.ts +46 -0
- package/dist/resolver.js +203 -0
- package/dist/resolver.js.map +1 -0
- package/dist/unique-id.d.ts +14 -0
- package/dist/unique-id.js +26 -0
- package/dist/unique-id.js.map +1 -0
- package/dist/value-promise.d.ts +134 -0
- package/dist/value-promise.js +277 -0
- package/dist/value-promise.js.map +1 -0
- package/package.json +49 -34
- package/src/binding-config.ts +73 -0
- package/src/binding-decorator.ts +136 -0
- package/src/binding-filter.ts +250 -0
- package/src/binding-inspector.ts +371 -0
- package/src/binding-key.ts +136 -0
- package/src/binding-sorter.ts +124 -0
- package/src/binding.ts +1107 -0
- package/src/context-event.ts +30 -0
- package/src/context-observer.ts +50 -0
- package/src/context-subscription.ts +402 -0
- package/src/context-tag-indexer.ts +147 -0
- package/src/context-view.ts +440 -0
- package/src/context.ts +1079 -0
- package/src/index.ts +58 -0
- package/src/inject-config.ts +239 -0
- package/src/inject.ts +796 -0
- package/src/interception-proxy.ts +127 -0
- package/src/interceptor-chain.ts +268 -0
- package/src/interceptor.ts +430 -0
- package/src/invocation.ts +269 -0
- package/src/json-types.ts +35 -0
- package/src/keys.ts +85 -0
- package/src/provider.ts +37 -0
- package/src/resolution-session.ts +414 -0
- package/src/resolver.ts +282 -0
- package/src/unique-id.ts +24 -0
- package/src/value-promise.ts +318 -0
- package/index.d.ts +0 -6
- package/index.js +0 -9
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -12
- package/lib/index.js.map +0 -1
- package/lib/src/binding.d.ts +0 -98
- package/lib/src/binding.js +0 -169
- package/lib/src/binding.js.map +0 -1
- package/lib/src/context.d.ts +0 -14
- package/lib/src/context.js +0 -122
- package/lib/src/context.js.map +0 -1
- package/lib/src/index.d.ts +0 -10
- package/lib/src/index.js +0 -25
- package/lib/src/index.js.map +0 -1
- package/lib/src/inject.d.ts +0 -60
- package/lib/src/inject.js +0 -112
- package/lib/src/inject.js.map +0 -1
- package/lib/src/is-promise.d.ts +0 -1
- package/lib/src/is-promise.js +0 -15
- package/lib/src/is-promise.js.map +0 -1
- package/lib/src/provider.d.ts +0 -31
- package/lib/src/provider.js.map +0 -1
- package/lib/src/reflect.d.ts +0 -38
- package/lib/src/reflect.js +0 -143
- package/lib/src/reflect.js.map +0 -1
- package/lib/src/resolver.d.ts +0 -30
- package/lib/src/resolver.js +0 -141
- package/lib/src/resolver.js.map +0 -1
- package/lib6/index.d.ts +0 -1
- package/lib6/index.js +0 -12
- package/lib6/index.js.map +0 -1
- package/lib6/src/binding.d.ts +0 -98
- package/lib6/src/binding.js +0 -169
- package/lib6/src/binding.js.map +0 -1
- package/lib6/src/context.d.ts +0 -14
- package/lib6/src/context.js +0 -122
- package/lib6/src/context.js.map +0 -1
- package/lib6/src/index.d.ts +0 -10
- package/lib6/src/index.js +0 -25
- package/lib6/src/index.js.map +0 -1
- package/lib6/src/inject.d.ts +0 -60
- package/lib6/src/inject.js +0 -112
- package/lib6/src/inject.js.map +0 -1
- package/lib6/src/is-promise.d.ts +0 -1
- package/lib6/src/is-promise.js +0 -15
- package/lib6/src/is-promise.js.map +0 -1
- package/lib6/src/provider.d.ts +0 -31
- package/lib6/src/provider.js.map +0 -1
- package/lib6/src/reflect.d.ts +0 -38
- package/lib6/src/reflect.js +0 -143
- package/lib6/src/reflect.js.map +0 -1
- package/lib6/src/resolver.d.ts +0 -30
- package/lib6/src/resolver.js +0 -141
- package/lib6/src/resolver.js.map +0 -1
package/lib/src/provider.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ValueOrPromise } from './binding';
|
|
2
|
-
/**
|
|
3
|
-
* @exports Provider<T> : interface definition for a provider of a value
|
|
4
|
-
* of type T
|
|
5
|
-
* @summary Providers allow binding of a value provider class instead of the
|
|
6
|
-
* value itself
|
|
7
|
-
* @example:
|
|
8
|
-
* ```ts
|
|
9
|
-
* export class DateProvider implements Provider<Date> {
|
|
10
|
-
* constructor(@inject('stringDate') private param: String){}
|
|
11
|
-
* value(): Date {
|
|
12
|
-
* return new Date(param);
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
* @example: Binding a context
|
|
17
|
-
* ```ts
|
|
18
|
-
* ctx.bind('provider_key').toProvider(MyProvider);
|
|
19
|
-
* ```
|
|
20
|
-
* @example: getting a value dynamically
|
|
21
|
-
* ```ts
|
|
22
|
-
* ctx.get('provider_key');
|
|
23
|
-
* ctx.getBinding('provider_key').getValue();
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export interface Provider<T> {
|
|
27
|
-
/**
|
|
28
|
-
* @returns a value or a promise
|
|
29
|
-
*/
|
|
30
|
-
value(): ValueOrPromise<T>;
|
|
31
|
-
}
|
package/lib/src/provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE"}
|
package/lib/src/reflect.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export declare class NamespacedReflect {
|
|
3
|
-
private namespace;
|
|
4
|
-
/**
|
|
5
|
-
* @param namespace : namespace to bind this reflect context
|
|
6
|
-
*/
|
|
7
|
-
constructor(namespace?: string);
|
|
8
|
-
private getMetadataKey(metadataKey);
|
|
9
|
-
/**
|
|
10
|
-
* define metadata for a target class or it's property/method
|
|
11
|
-
*/
|
|
12
|
-
defineMetadata(metadataKey: string, metadataValue: any, target: Object, propertyKey?: string | symbol): void;
|
|
13
|
-
/**
|
|
14
|
-
* lookup metadata from a target object and its prototype chain
|
|
15
|
-
*/
|
|
16
|
-
getMetadata(metadataKey: string, target: Object, propertyKey?: string | symbol): any;
|
|
17
|
-
/**
|
|
18
|
-
* get own metadata for a target object or it's property/method
|
|
19
|
-
*/
|
|
20
|
-
getOwnMetadata(metadataKey: string, target: Object, propertyKey?: string | symbol): any;
|
|
21
|
-
/**
|
|
22
|
-
* Check if the target has corresponding metadata
|
|
23
|
-
* @param metadataKey Key
|
|
24
|
-
* @param target Target
|
|
25
|
-
* @param propertyKey Optional property key
|
|
26
|
-
*/
|
|
27
|
-
hasMetadata(metadataKey: string, target: Object, propertyKey?: string | symbol): boolean;
|
|
28
|
-
hasOwnMetadata(metadataKey: string, target: Object, propertyKey?: string | symbol): boolean;
|
|
29
|
-
deleteMetadata(metadataKey: string, target: Object, propertyKey?: string | symbol): boolean;
|
|
30
|
-
getMetadataKeys(target: Object, propertyKey?: string | symbol): string[];
|
|
31
|
-
getOwnMetadataKeys(target: Object, propertyKey?: string | symbol): string[];
|
|
32
|
-
decorate(decorators: (PropertyDecorator | MethodDecorator)[] | ClassDecorator[], target: Object, targetKey?: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor;
|
|
33
|
-
metadata(metadataKey: string, metadataValue: any): {
|
|
34
|
-
(target: Function): void;
|
|
35
|
-
(target: Object, targetKey: string | symbol): void;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export declare const Reflector: NamespacedReflect;
|
package/lib/src/reflect.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/context
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
require("reflect-metadata");
|
|
8
|
-
/* tslint:disable:no-any */
|
|
9
|
-
/*
|
|
10
|
-
* namespaced wrapper to handle reflect api
|
|
11
|
-
*/
|
|
12
|
-
class NamespacedReflect {
|
|
13
|
-
/**
|
|
14
|
-
* @param namespace : namespace to bind this reflect context
|
|
15
|
-
*/
|
|
16
|
-
constructor(namespace) {
|
|
17
|
-
this.namespace = namespace;
|
|
18
|
-
}
|
|
19
|
-
getMetadataKey(metadataKey) {
|
|
20
|
-
// prefix namespace, if provided, to the metadata key
|
|
21
|
-
return this.namespace ? this.namespace + ':' + metadataKey : metadataKey;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* define metadata for a target class or it's property/method
|
|
25
|
-
*/
|
|
26
|
-
defineMetadata(metadataKey, metadataValue, target, propertyKey) {
|
|
27
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
28
|
-
if (propertyKey) {
|
|
29
|
-
Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
Reflect.defineMetadata(metadataKey, metadataValue, target);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* lookup metadata from a target object and its prototype chain
|
|
37
|
-
*/
|
|
38
|
-
getMetadata(metadataKey, target, propertyKey) {
|
|
39
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
40
|
-
if (propertyKey) {
|
|
41
|
-
return Reflect.getMetadata(metadataKey, target, propertyKey);
|
|
42
|
-
}
|
|
43
|
-
return Reflect.getMetadata(metadataKey, target);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* get own metadata for a target object or it's property/method
|
|
47
|
-
*/
|
|
48
|
-
getOwnMetadata(metadataKey, target, propertyKey) {
|
|
49
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
50
|
-
if (propertyKey) {
|
|
51
|
-
return Reflect.getOwnMetadata(metadataKey, target, propertyKey);
|
|
52
|
-
}
|
|
53
|
-
return Reflect.getOwnMetadata(metadataKey, target);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Check if the target has corresponding metadata
|
|
57
|
-
* @param metadataKey Key
|
|
58
|
-
* @param target Target
|
|
59
|
-
* @param propertyKey Optional property key
|
|
60
|
-
*/
|
|
61
|
-
hasMetadata(metadataKey, target, propertyKey) {
|
|
62
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
63
|
-
if (propertyKey) {
|
|
64
|
-
return Reflect.hasMetadata(metadataKey, target, propertyKey);
|
|
65
|
-
}
|
|
66
|
-
return Reflect.hasMetadata(metadataKey, target);
|
|
67
|
-
}
|
|
68
|
-
hasOwnMetadata(metadataKey, target, propertyKey) {
|
|
69
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
70
|
-
if (propertyKey) {
|
|
71
|
-
return Reflect.hasOwnMetadata(metadataKey, target, propertyKey);
|
|
72
|
-
}
|
|
73
|
-
return Reflect.hasOwnMetadata(metadataKey, target);
|
|
74
|
-
}
|
|
75
|
-
deleteMetadata(metadataKey, target, propertyKey) {
|
|
76
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
77
|
-
if (propertyKey) {
|
|
78
|
-
return Reflect.deleteMetadata(metadataKey, target, propertyKey);
|
|
79
|
-
}
|
|
80
|
-
return Reflect.deleteMetadata(metadataKey, target);
|
|
81
|
-
}
|
|
82
|
-
getMetadataKeys(target, propertyKey) {
|
|
83
|
-
let keys;
|
|
84
|
-
if (propertyKey) {
|
|
85
|
-
keys = Reflect.getMetadataKeys(target, propertyKey);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
keys = Reflect.getMetadataKeys(target);
|
|
89
|
-
}
|
|
90
|
-
const metaKeys = [];
|
|
91
|
-
if (keys) {
|
|
92
|
-
if (!this.namespace)
|
|
93
|
-
return keys; // No normalization is needed
|
|
94
|
-
const prefix = this.namespace + ':';
|
|
95
|
-
for (const key of keys) {
|
|
96
|
-
if (key.indexOf(prefix) === 0) {
|
|
97
|
-
// Only add keys with the namespace prefix
|
|
98
|
-
metaKeys.push(key.substr(prefix.length));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return metaKeys;
|
|
103
|
-
}
|
|
104
|
-
getOwnMetadataKeys(target, propertyKey) {
|
|
105
|
-
let keys;
|
|
106
|
-
if (propertyKey) {
|
|
107
|
-
keys = Reflect.getOwnMetadataKeys(target, propertyKey);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
keys = Reflect.getOwnMetadataKeys(target);
|
|
111
|
-
}
|
|
112
|
-
const metaKeys = [];
|
|
113
|
-
if (keys) {
|
|
114
|
-
if (!this.namespace)
|
|
115
|
-
return keys; // No normalization is needed
|
|
116
|
-
const prefix = this.namespace + ':';
|
|
117
|
-
for (const key of keys) {
|
|
118
|
-
if (key.indexOf(prefix) === 0) {
|
|
119
|
-
// Only add keys with the namespace prefix
|
|
120
|
-
metaKeys.push(key.substr(prefix.length));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return metaKeys;
|
|
125
|
-
}
|
|
126
|
-
decorate(decorators, target, targetKey, descriptor) {
|
|
127
|
-
if (targetKey) {
|
|
128
|
-
return Reflect.decorate(decorators, target, targetKey, descriptor);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return Reflect.decorate(decorators, target);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/* tslint:disable-next-line:no-any */
|
|
135
|
-
metadata(metadataKey, metadataValue) {
|
|
136
|
-
metadataKey = this.getMetadataKey(metadataKey);
|
|
137
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.NamespacedReflect = NamespacedReflect;
|
|
141
|
-
/* tslint:disable-next-line:variable-name */
|
|
142
|
-
exports.Reflector = new NamespacedReflect('loopback');
|
|
143
|
-
//# sourceMappingURL=reflect.js.map
|
package/lib/src/reflect.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.js","sourceRoot":"","sources":["../../src/reflect.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;AAGhE,4BAA0B;AAE1B,2BAA2B;AAE3B;;GAEG;AACH;IACE;;OAEG;IACH,YAAoB,SAAkB;QAAlB,cAAS,GAAT,SAAS,CAAS;IAAG,CAAC;IAElC,cAAc,CAAC,WAAmB;QACxC,qDAAqD;QACrD,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,WAAW,GAAG,WAAW,CAAC;IAC3E,CAAC;IAED;;OAEG;IACH,cAAc,CACZ,WAAmB,EACnB,aAAkB,EAClB,MAAc,EACd,WAA6B;QAE7B,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC/C,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QAC1E,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW,CACT,WAAmB,E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AC,CAAC;YACN,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAoB,UAAU,EAAa,MAAM,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAED,qCAAqC;IACrC,QAAQ,CACN,WAAmB,EACnB,aAAkB;QAKlB,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC;CACF;AAtKD,8CAsKC;AAED,4CAA4C;AAC/B,QAAA,SAAS,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC"}
|
package/lib/src/resolver.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Context } from './context';
|
|
2
|
-
import { BoundValue } from './binding';
|
|
3
|
-
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
4
|
-
/**
|
|
5
|
-
* Create an instance of a class which constructor has arguments
|
|
6
|
-
* decorated with `@inject`.
|
|
7
|
-
*
|
|
8
|
-
* The function returns a class when all dependencies were
|
|
9
|
-
* resolved synchronously, or a Promise otherwise.
|
|
10
|
-
*
|
|
11
|
-
* @param ctor The class constructor to call.
|
|
12
|
-
* @param ctx The context containing values for `@inject` resolution
|
|
13
|
-
*/
|
|
14
|
-
export declare function instantiateClass<T>(ctor: Constructor<T>, ctx: Context): T | Promise<T>;
|
|
15
|
-
/**
|
|
16
|
-
* Given a function with arguments decorated with `@inject`,
|
|
17
|
-
* return the list of arguments resolved using the values
|
|
18
|
-
* bound in `ctx`.
|
|
19
|
-
|
|
20
|
-
* The function returns an argument array when all dependencies were
|
|
21
|
-
* resolved synchronously, or a Promise otherwise.
|
|
22
|
-
*
|
|
23
|
-
* @param fn The function for which the arguments should be resolved.
|
|
24
|
-
* @param ctx The context containing values for `@inject` resolution
|
|
25
|
-
*/
|
|
26
|
-
export declare function resolveInjectedArguments(fn: Function, ctx: Context): BoundValue[] | Promise<BoundValue[]>;
|
|
27
|
-
export declare type KV = {
|
|
28
|
-
[p: string]: BoundValue;
|
|
29
|
-
};
|
|
30
|
-
export declare function resolveInjectedProperties(fn: Function, ctx: Context): KV | Promise<KV>;
|
package/lib/src/resolver.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2013,2017. All Rights Reserved.
|
|
3
|
-
// Node module: loopback
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const is_promise_1 = require("./is-promise");
|
|
8
|
-
const inject_1 = require("./inject");
|
|
9
|
-
/**
|
|
10
|
-
* Create an instance of a class which constructor has arguments
|
|
11
|
-
* decorated with `@inject`.
|
|
12
|
-
*
|
|
13
|
-
* The function returns a class when all dependencies were
|
|
14
|
-
* resolved synchronously, or a Promise otherwise.
|
|
15
|
-
*
|
|
16
|
-
* @param ctor The class constructor to call.
|
|
17
|
-
* @param ctx The context containing values for `@inject` resolution
|
|
18
|
-
*/
|
|
19
|
-
function instantiateClass(ctor, ctx) {
|
|
20
|
-
const argsOrPromise = resolveInjectedArguments(ctor, ctx);
|
|
21
|
-
const propertiesOrPromise = resolveInjectedProperties(ctor, ctx);
|
|
22
|
-
let inst;
|
|
23
|
-
if (is_promise_1.isPromise(argsOrPromise)) {
|
|
24
|
-
// Instantiate the class asynchronously
|
|
25
|
-
inst = argsOrPromise.then(args => new ctor(...args));
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// Instantiate the class synchronously
|
|
29
|
-
inst = new ctor(...argsOrPromise);
|
|
30
|
-
}
|
|
31
|
-
if (is_promise_1.isPromise(propertiesOrPromise)) {
|
|
32
|
-
return propertiesOrPromise.then(props => {
|
|
33
|
-
if (is_promise_1.isPromise(inst)) {
|
|
34
|
-
// Inject the properties asynchrounously
|
|
35
|
-
return inst.then(obj => Object.assign(obj, props));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
// Inject the properties synchrounously
|
|
39
|
-
return Object.assign(inst, props);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (is_promise_1.isPromise(inst)) {
|
|
45
|
-
// Inject the properties asynchrounously
|
|
46
|
-
return inst.then(obj => Object.assign(obj, propertiesOrPromise));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// Inject the properties synchrounously
|
|
50
|
-
return Object.assign(inst, propertiesOrPromise);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.instantiateClass = instantiateClass;
|
|
55
|
-
/**
|
|
56
|
-
* Resolve the value or promise for a given injection
|
|
57
|
-
* @param ctx Context
|
|
58
|
-
* @param injection Descriptor of the injection
|
|
59
|
-
*/
|
|
60
|
-
function resolve(ctx, injection) {
|
|
61
|
-
if (injection.resolve) {
|
|
62
|
-
// A custom resolve function is provided
|
|
63
|
-
return injection.resolve(ctx, injection);
|
|
64
|
-
}
|
|
65
|
-
// Default to resolve the value from the context by binding key
|
|
66
|
-
const binding = ctx.getBinding(injection.bindingKey);
|
|
67
|
-
return binding.getValue(ctx);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Given a function with arguments decorated with `@inject`,
|
|
71
|
-
* return the list of arguments resolved using the values
|
|
72
|
-
* bound in `ctx`.
|
|
73
|
-
|
|
74
|
-
* The function returns an argument array when all dependencies were
|
|
75
|
-
* resolved synchronously, or a Promise otherwise.
|
|
76
|
-
*
|
|
77
|
-
* @param fn The function for which the arguments should be resolved.
|
|
78
|
-
* @param ctx The context containing values for `@inject` resolution
|
|
79
|
-
*/
|
|
80
|
-
function resolveInjectedArguments(fn, ctx) {
|
|
81
|
-
// NOTE: the array may be sparse, i.e.
|
|
82
|
-
// Object.keys(injectedArgs).length !== injectedArgs.length
|
|
83
|
-
// Example value:
|
|
84
|
-
// [ , 'key1', , 'key2']
|
|
85
|
-
const injectedArgs = inject_1.describeInjectedArguments(fn);
|
|
86
|
-
const args = new Array(fn.length);
|
|
87
|
-
let asyncResolvers = undefined;
|
|
88
|
-
for (let ix = 0; ix < fn.length; ix++) {
|
|
89
|
-
const injection = injectedArgs[ix];
|
|
90
|
-
if (!injection.bindingKey && !injection.resolve) {
|
|
91
|
-
throw new Error(`Cannot resolve injected arguments for function ${fn.name}: ` +
|
|
92
|
-
`The argument ${ix + 1} was not decorated for dependency injection.`);
|
|
93
|
-
}
|
|
94
|
-
const valueOrPromise = resolve(ctx, injection);
|
|
95
|
-
if (is_promise_1.isPromise(valueOrPromise)) {
|
|
96
|
-
if (!asyncResolvers)
|
|
97
|
-
asyncResolvers = [];
|
|
98
|
-
asyncResolvers.push(valueOrPromise.then((v) => (args[ix] = v)));
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
args[ix] = valueOrPromise;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (asyncResolvers) {
|
|
105
|
-
return Promise.all(asyncResolvers).then(() => args);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return args;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.resolveInjectedArguments = resolveInjectedArguments;
|
|
112
|
-
function resolveInjectedProperties(fn, ctx) {
|
|
113
|
-
const injectedProperties = inject_1.describeInjectedProperties(fn.prototype);
|
|
114
|
-
const properties = {};
|
|
115
|
-
let asyncResolvers = undefined;
|
|
116
|
-
const propertyResolver = (p) => (v) => (properties[p] = v);
|
|
117
|
-
for (const p in injectedProperties) {
|
|
118
|
-
const injection = injectedProperties[p];
|
|
119
|
-
if (!injection.bindingKey && !injection.resolve) {
|
|
120
|
-
throw new Error(`Cannot resolve injected property for class ${fn.name}: ` +
|
|
121
|
-
`The property ${p} was not decorated for dependency injection.`);
|
|
122
|
-
}
|
|
123
|
-
const valueOrPromise = resolve(ctx, injection);
|
|
124
|
-
if (is_promise_1.isPromise(valueOrPromise)) {
|
|
125
|
-
if (!asyncResolvers)
|
|
126
|
-
asyncResolvers = [];
|
|
127
|
-
asyncResolvers.push(valueOrPromise.then(propertyResolver(p)));
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
properties[p] = valueOrPromise;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (asyncResolvers) {
|
|
134
|
-
return Promise.all(asyncResolvers).then(() => properties);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return properties;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.resolveInjectedProperties = resolveInjectedProperties;
|
|
141
|
-
//# sourceMappingURL=resolver.js.map
|
package/lib/src/resolver.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/resolver.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAIhE,6CAAuC;AACvC,qCAIkB;AAKlB;;;;;;;;;GASG;AACH,0BACE,IAAoB,EACpB,GAAY;IAEZ,MAAM,aAAa,GAAG,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1D,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjE,IAAI,IAAoB,CAAC;IACzB,EAAE,CAAC,CAAC,sBAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC7B,uCAAuC;QACvC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,sCAAsC;QACtC,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;IACpC,CAAC;IACD,EAAE,CAAC,CAAC,sBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC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AAC,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,CAAC;IAC5D,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,MAAM,CAAC,UAAU,CAAC;IACpB,CAAC;AACH,CAAC;AAlCD,8DAkCC"}
|
package/lib6/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src';
|
package/lib6/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2013,2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/context
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
function __export(m) {
|
|
7
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
// NOTE(bajtos) This file is used by VSCode/TypeScriptServer at dev time only
|
|
11
|
-
__export(require("./src"));
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/lib6/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,6EAA6E;AAC7E,2BAAsB"}
|
package/lib6/src/binding.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Context } from './context';
|
|
2
|
-
import { Constructor } from './resolver';
|
|
3
|
-
import { Provider } from './provider';
|
|
4
|
-
export declare type BoundValue = any;
|
|
5
|
-
export declare type ValueOrPromise<T> = T | Promise<T>;
|
|
6
|
-
export declare class Binding {
|
|
7
|
-
isLocked: boolean;
|
|
8
|
-
static PROPERTY_SEPARATOR: string;
|
|
9
|
-
/**
|
|
10
|
-
* Validate the binding key format. Please note that `#` is reserved.
|
|
11
|
-
* @param key Binding key, such as `a, a.b, a:b, a/b
|
|
12
|
-
*/
|
|
13
|
-
static validateKey(key: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Remove the segament that denotes a property path
|
|
16
|
-
* @param key Binding key, such as `a, a.b, a:b, a/b, a.b#x, a:b#x.y, a/b#x.y`
|
|
17
|
-
*/
|
|
18
|
-
static normalizeKey(key: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Get the property path separated by `#`
|
|
21
|
-
* @param key Binding key
|
|
22
|
-
*/
|
|
23
|
-
static getKeyPath(key: string): string | undefined;
|
|
24
|
-
private readonly _key;
|
|
25
|
-
private _tags;
|
|
26
|
-
valueConstructor: Constructor<BoundValue>;
|
|
27
|
-
constructor(_key: string, isLocked?: boolean);
|
|
28
|
-
readonly key: string;
|
|
29
|
-
readonly tags: Set<string>;
|
|
30
|
-
/**
|
|
31
|
-
* This is an internal function optimized for performance.
|
|
32
|
-
* Users should use `@inject(key)` or `ctx.get(key)` instead.
|
|
33
|
-
*
|
|
34
|
-
* Get the value bound to this key. Depending on `isSync`, this
|
|
35
|
-
* function returns either:
|
|
36
|
-
* - the bound value
|
|
37
|
-
* - a promise of the bound value
|
|
38
|
-
*
|
|
39
|
-
* Consumers wishing to consume sync values directly should use `isPromise`
|
|
40
|
-
* to check the type of the returned value to decide how to handle it.
|
|
41
|
-
*
|
|
42
|
-
* ```
|
|
43
|
-
* const result = binding.getValue(ctx);
|
|
44
|
-
* if (isPromise(result)) {
|
|
45
|
-
* result.then(doSomething)
|
|
46
|
-
* } else {
|
|
47
|
-
* doSomething(result);
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
getValue(ctx: Context): BoundValue | Promise<BoundValue>;
|
|
52
|
-
lock(): this;
|
|
53
|
-
tag(tagName: string | string[]): this;
|
|
54
|
-
/**
|
|
55
|
-
* Bind the key to a constant value.
|
|
56
|
-
*
|
|
57
|
-
* @param value The bound value.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
*
|
|
61
|
-
* ```ts
|
|
62
|
-
* ctx.bind('appName').to('CodeHub');
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
to(value: BoundValue): this;
|
|
66
|
-
/**
|
|
67
|
-
* Bind the key to a computed (dynamic) value.
|
|
68
|
-
*
|
|
69
|
-
* @param factoryFn The factory function creating the value.
|
|
70
|
-
* Both sync and async functions are supported.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
*
|
|
74
|
-
* ```ts
|
|
75
|
-
* // synchronous
|
|
76
|
-
* ctx.bind('now').toDynamicValue(() => Date.now());
|
|
77
|
-
*
|
|
78
|
-
* // asynchronous
|
|
79
|
-
* ctx.bind('something').toDynamicValue(
|
|
80
|
-
* async () => Promise.delay(10).then(doSomething)
|
|
81
|
-
* );
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
toDynamicValue(factoryFn: () => BoundValue | Promise<BoundValue>): this;
|
|
85
|
-
/**
|
|
86
|
-
* Bind the key to a BindingProvider
|
|
87
|
-
*/
|
|
88
|
-
toProvider<T>(providerClass: Constructor<Provider<T>>): this;
|
|
89
|
-
/**
|
|
90
|
-
* Bind the key to an instance of the given class.
|
|
91
|
-
*
|
|
92
|
-
* @param ctor The class constructor to call. Any constructor
|
|
93
|
-
* arguments must be annotated with `@inject` so that
|
|
94
|
-
* we can resolve them from the context.
|
|
95
|
-
*/
|
|
96
|
-
toClass<T>(ctor: Constructor<T>): this;
|
|
97
|
-
unlock(): this;
|
|
98
|
-
}
|