@loopback/context 4.0.0-alpha.8 → 4.1.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.
Files changed (201) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +116 -0
  3. package/dist/binding-config.d.ts +40 -0
  4. package/dist/binding-config.js +33 -0
  5. package/dist/binding-config.js.map +1 -0
  6. package/dist/binding-decorator.d.ts +45 -0
  7. package/dist/binding-decorator.js +118 -0
  8. package/dist/binding-decorator.js.map +1 -0
  9. package/dist/binding-filter.d.ts +108 -0
  10. package/dist/binding-filter.js +162 -0
  11. package/dist/binding-filter.js.map +1 -0
  12. package/dist/binding-inspector.d.ts +150 -0
  13. package/dist/binding-inspector.js +249 -0
  14. package/dist/binding-inspector.js.map +1 -0
  15. package/dist/binding-key.d.ts +66 -0
  16. package/dist/binding-key.js +121 -0
  17. package/dist/binding-key.js.map +1 -0
  18. package/dist/binding-sorter.d.ts +71 -0
  19. package/dist/binding-sorter.js +89 -0
  20. package/dist/binding-sorter.js.map +1 -0
  21. package/dist/binding.d.ts +577 -0
  22. package/dist/binding.js +788 -0
  23. package/dist/binding.js.map +1 -0
  24. package/dist/context-event.d.ts +23 -0
  25. package/dist/context-event.js +7 -0
  26. package/dist/context-event.js.map +1 -0
  27. package/dist/context-observer.d.ts +36 -0
  28. package/dist/context-observer.js +7 -0
  29. package/dist/context-observer.js.map +1 -0
  30. package/dist/context-subscription.d.ts +147 -0
  31. package/dist/context-subscription.js +317 -0
  32. package/dist/context-subscription.js.map +1 -0
  33. package/dist/context-tag-indexer.d.ts +42 -0
  34. package/dist/context-tag-indexer.js +135 -0
  35. package/dist/context-tag-indexer.js.map +1 -0
  36. package/dist/context-view.d.ts +209 -0
  37. package/dist/context-view.js +240 -0
  38. package/dist/context-view.js.map +1 -0
  39. package/dist/context.d.ts +513 -0
  40. package/dist/context.js +717 -0
  41. package/dist/context.js.map +1 -0
  42. package/dist/index.d.ts +52 -0
  43. package/dist/index.js +60 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/inject-config.d.ts +67 -0
  46. package/dist/inject-config.js +181 -0
  47. package/dist/inject-config.js.map +1 -0
  48. package/dist/inject.d.ts +250 -0
  49. package/dist/inject.js +535 -0
  50. package/dist/inject.js.map +1 -0
  51. package/dist/interception-proxy.d.ts +76 -0
  52. package/dist/interception-proxy.js +67 -0
  53. package/dist/interception-proxy.js.map +1 -0
  54. package/dist/interceptor-chain.d.ts +121 -0
  55. package/dist/interceptor-chain.js +148 -0
  56. package/dist/interceptor-chain.js.map +1 -0
  57. package/dist/interceptor.d.ts +138 -0
  58. package/dist/interceptor.js +299 -0
  59. package/dist/interceptor.js.map +1 -0
  60. package/dist/invocation.d.ts +101 -0
  61. package/dist/invocation.js +163 -0
  62. package/dist/invocation.js.map +1 -0
  63. package/dist/json-types.d.ts +28 -0
  64. package/{lib/src/provider.js → dist/json-types.js} +3 -3
  65. package/dist/json-types.js.map +1 -0
  66. package/dist/keys.d.ts +65 -0
  67. package/dist/keys.js +74 -0
  68. package/dist/keys.js.map +1 -0
  69. package/dist/provider.d.ts +31 -0
  70. package/{lib6/src → dist}/provider.js +2 -2
  71. package/dist/provider.js.map +1 -0
  72. package/dist/resolution-session.d.ts +180 -0
  73. package/dist/resolution-session.js +274 -0
  74. package/dist/resolution-session.js.map +1 -0
  75. package/dist/resolver.d.ts +46 -0
  76. package/dist/resolver.js +203 -0
  77. package/dist/resolver.js.map +1 -0
  78. package/dist/unique-id.d.ts +14 -0
  79. package/dist/unique-id.js +26 -0
  80. package/dist/unique-id.js.map +1 -0
  81. package/dist/value-promise.d.ts +134 -0
  82. package/dist/value-promise.js +277 -0
  83. package/dist/value-promise.js.map +1 -0
  84. package/package.json +49 -34
  85. package/src/binding-config.ts +73 -0
  86. package/src/binding-decorator.ts +136 -0
  87. package/src/binding-filter.ts +250 -0
  88. package/src/binding-inspector.ts +371 -0
  89. package/src/binding-key.ts +136 -0
  90. package/src/binding-sorter.ts +124 -0
  91. package/src/binding.ts +1107 -0
  92. package/src/context-event.ts +30 -0
  93. package/src/context-observer.ts +50 -0
  94. package/src/context-subscription.ts +402 -0
  95. package/src/context-tag-indexer.ts +147 -0
  96. package/src/context-view.ts +440 -0
  97. package/src/context.ts +1079 -0
  98. package/src/index.ts +58 -0
  99. package/src/inject-config.ts +239 -0
  100. package/src/inject.ts +796 -0
  101. package/src/interception-proxy.ts +127 -0
  102. package/src/interceptor-chain.ts +268 -0
  103. package/src/interceptor.ts +430 -0
  104. package/src/invocation.ts +269 -0
  105. package/src/json-types.ts +35 -0
  106. package/src/keys.ts +85 -0
  107. package/src/provider.ts +37 -0
  108. package/src/resolution-session.ts +414 -0
  109. package/src/resolver.ts +282 -0
  110. package/src/unique-id.ts +24 -0
  111. package/src/value-promise.ts +318 -0
  112. package/index.d.ts +0 -6
  113. package/index.js +0 -9
  114. package/lib/binding.d.ts +0 -75
  115. package/lib/binding.js +0 -103
  116. package/lib/binding.js.map +0 -1
  117. package/lib/context.d.ts +0 -14
  118. package/lib/context.js +0 -97
  119. package/lib/context.js.map +0 -1
  120. package/lib/index.d.ts +0 -1
  121. package/lib/index.js +0 -12
  122. package/lib/index.js.map +0 -1
  123. package/lib/inject.d.ts +0 -46
  124. package/lib/inject.js +0 -74
  125. package/lib/inject.js.map +0 -1
  126. package/lib/isPromise.d.ts +0 -1
  127. package/lib/isPromise.js +0 -15
  128. package/lib/isPromise.js.map +0 -1
  129. package/lib/reflect.d.ts +0 -39
  130. package/lib/reflect.js +0 -20
  131. package/lib/reflect.js.map +0 -1
  132. package/lib/resolver.d.ts +0 -30
  133. package/lib/resolver.js +0 -129
  134. package/lib/resolver.js.map +0 -1
  135. package/lib/src/binding.d.ts +0 -85
  136. package/lib/src/binding.js +0 -123
  137. package/lib/src/binding.js.map +0 -1
  138. package/lib/src/context.d.ts +0 -14
  139. package/lib/src/context.js +0 -97
  140. package/lib/src/context.js.map +0 -1
  141. package/lib/src/index.d.ts +0 -10
  142. package/lib/src/index.js +0 -27
  143. package/lib/src/index.js.map +0 -1
  144. package/lib/src/inject.d.ts +0 -46
  145. package/lib/src/inject.js +0 -74
  146. package/lib/src/inject.js.map +0 -1
  147. package/lib/src/isPromise.d.ts +0 -1
  148. package/lib/src/isPromise.js +0 -15
  149. package/lib/src/isPromise.js.map +0 -1
  150. package/lib/src/provider.d.ts +0 -29
  151. package/lib/src/provider.js.map +0 -1
  152. package/lib/src/reflect.d.ts +0 -38
  153. package/lib/src/reflect.js +0 -143
  154. package/lib/src/reflect.js.map +0 -1
  155. package/lib/src/resolver.d.ts +0 -34
  156. package/lib/src/resolver.js +0 -144
  157. package/lib/src/resolver.js.map +0 -1
  158. package/lib6/binding.d.ts +0 -75
  159. package/lib6/binding.js +0 -103
  160. package/lib6/binding.js.map +0 -1
  161. package/lib6/context.d.ts +0 -14
  162. package/lib6/context.js +0 -97
  163. package/lib6/context.js.map +0 -1
  164. package/lib6/index.d.ts +0 -1
  165. package/lib6/index.js +0 -12
  166. package/lib6/index.js.map +0 -1
  167. package/lib6/inject.d.ts +0 -46
  168. package/lib6/inject.js +0 -74
  169. package/lib6/inject.js.map +0 -1
  170. package/lib6/isPromise.d.ts +0 -1
  171. package/lib6/isPromise.js +0 -15
  172. package/lib6/isPromise.js.map +0 -1
  173. package/lib6/reflect.d.ts +0 -39
  174. package/lib6/reflect.js +0 -20
  175. package/lib6/reflect.js.map +0 -1
  176. package/lib6/resolver.d.ts +0 -30
  177. package/lib6/resolver.js +0 -129
  178. package/lib6/resolver.js.map +0 -1
  179. package/lib6/src/binding.d.ts +0 -85
  180. package/lib6/src/binding.js +0 -133
  181. package/lib6/src/binding.js.map +0 -1
  182. package/lib6/src/context.d.ts +0 -14
  183. package/lib6/src/context.js +0 -97
  184. package/lib6/src/context.js.map +0 -1
  185. package/lib6/src/index.d.ts +0 -10
  186. package/lib6/src/index.js +0 -27
  187. package/lib6/src/index.js.map +0 -1
  188. package/lib6/src/inject.d.ts +0 -46
  189. package/lib6/src/inject.js +0 -74
  190. package/lib6/src/inject.js.map +0 -1
  191. package/lib6/src/isPromise.d.ts +0 -1
  192. package/lib6/src/isPromise.js +0 -15
  193. package/lib6/src/isPromise.js.map +0 -1
  194. package/lib6/src/provider.d.ts +0 -29
  195. package/lib6/src/provider.js.map +0 -1
  196. package/lib6/src/reflect.d.ts +0 -38
  197. package/lib6/src/reflect.js +0 -143
  198. package/lib6/src/reflect.js.map +0 -1
  199. package/lib6/src/resolver.d.ts +0 -34
  200. package/lib6/src/resolver.js +0 -154
  201. package/lib6/src/resolver.js.map +0 -1
package/lib/binding.d.ts DELETED
@@ -1,75 +0,0 @@
1
- import { Context } from './context';
2
- import { Constructor } from './resolver';
3
- export declare type BoundValue = any;
4
- export declare class Binding {
5
- private readonly _key;
6
- isLocked: boolean;
7
- private _tagName;
8
- valueConstructor: Constructor<BoundValue>;
9
- constructor(_key: string, isLocked?: boolean);
10
- readonly key: string;
11
- readonly tagName: string;
12
- /**
13
- * This is an internal function optimized for performance.
14
- * Users should use `@inject(key)` or `ctx.get(key)` instead.
15
- *
16
- * Get the value bound to this key. Depending on `isSync`, this function returns either:
17
- * - the bound value
18
- * - a promise of the bound value
19
- *
20
- * Consumers wishing to consume sync values directly should use `isPromise`
21
- * to check the type of the returned value to decide how to handle it.
22
- *
23
- * ```
24
- * const result = binding.getValue(ctx);
25
- * if (isPromise(result)) {
26
- * result.then(doSomething)
27
- * } else {
28
- * doSomething(result);
29
- * }
30
- * ```
31
- */
32
- getValue(ctx: Context): BoundValue | Promise<BoundValue>;
33
- lock(): this;
34
- tag(tagName: string): this;
35
- /**
36
- * Bind the key to a constant value.
37
- *
38
- * @param value The bound value.
39
- *
40
- * @example
41
- *
42
- * ```ts
43
- * ctx.bind('appName').to('CodeHub');
44
- * ```
45
- */
46
- to(value: BoundValue): this;
47
- /**
48
- * Bind the key to a computed (dynamic) value.
49
- *
50
- * @param factoryFn The factory function creating the value.
51
- * Both sync and async functions are supported.
52
- *
53
- * @example
54
- *
55
- * ```ts
56
- * // synchronous
57
- * ctx.bind('now').toDynamicValue(() => Date.now());
58
- *
59
- * // asynchronous
60
- * ctx.bind('something').toDynamicValue(
61
- * async () => Promise.delay(10).then(doSomething)
62
- * );
63
- * ```
64
- */
65
- toDynamicValue(factoryFn: () => BoundValue | Promise<BoundValue>): this;
66
- /**
67
- * Bind the key to an instance of the given class.
68
- *
69
- * @param ctor The class constructor to call. Any constructor
70
- * arguments must be annotated with `@inject` so that
71
- * we can resolve them from the context.
72
- */
73
- toClass<T>(ctor: Constructor<T>): this;
74
- unlock(): this;
75
- }
package/lib/binding.js DELETED
@@ -1,103 +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 resolver_1 = require("./resolver");
8
- // FIXME(bajtos) The binding class should be parameterized by the value type stored
9
- class Binding {
10
- constructor(_key, isLocked = false) {
11
- this._key = _key;
12
- this.isLocked = isLocked;
13
- }
14
- get key() { return this._key; }
15
- get tagName() { return this._tagName; }
16
- /**
17
- * This is an internal function optimized for performance.
18
- * Users should use `@inject(key)` or `ctx.get(key)` instead.
19
- *
20
- * Get the value bound to this key. Depending on `isSync`, this function returns either:
21
- * - the bound value
22
- * - a promise of the bound value
23
- *
24
- * Consumers wishing to consume sync values directly should use `isPromise`
25
- * to check the type of the returned value to decide how to handle it.
26
- *
27
- * ```
28
- * const result = binding.getValue(ctx);
29
- * if (isPromise(result)) {
30
- * result.then(doSomething)
31
- * } else {
32
- * doSomething(result);
33
- * }
34
- * ```
35
- */
36
- getValue(ctx) {
37
- return Promise.reject(new Error(`No value was configured for binding ${this._key}.`));
38
- }
39
- lock() {
40
- this.isLocked = true;
41
- return this;
42
- }
43
- tag(tagName) {
44
- this._tagName = tagName;
45
- return this;
46
- }
47
- /**
48
- * Bind the key to a constant value.
49
- *
50
- * @param value The bound value.
51
- *
52
- * @example
53
- *
54
- * ```ts
55
- * ctx.bind('appName').to('CodeHub');
56
- * ```
57
- */
58
- to(value) {
59
- this.getValue = () => value;
60
- return this;
61
- }
62
- /**
63
- * Bind the key to a computed (dynamic) value.
64
- *
65
- * @param factoryFn The factory function creating the value.
66
- * Both sync and async functions are supported.
67
- *
68
- * @example
69
- *
70
- * ```ts
71
- * // synchronous
72
- * ctx.bind('now').toDynamicValue(() => Date.now());
73
- *
74
- * // asynchronous
75
- * ctx.bind('something').toDynamicValue(
76
- * async () => Promise.delay(10).then(doSomething)
77
- * );
78
- * ```
79
- */
80
- toDynamicValue(factoryFn) {
81
- // TODO(bajtos) allow factoryFn with @inject arguments
82
- this.getValue = (ctx) => factoryFn();
83
- return this;
84
- }
85
- /**
86
- * Bind the key to an instance of the given class.
87
- *
88
- * @param ctor The class constructor to call. Any constructor
89
- * arguments must be annotated with `@inject` so that
90
- * we can resolve them from the context.
91
- */
92
- toClass(ctor) {
93
- this.getValue = context => resolver_1.instantiateClass(ctor, context);
94
- this.valueConstructor = ctor;
95
- return this;
96
- }
97
- unlock() {
98
- this.isLocked = false;
99
- return this;
100
- }
101
- }
102
- exports.Binding = Binding;
103
- //# sourceMappingURL=binding.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAGhE,yCAAyD;AAKzD,mFAAmF;AACnF;IAME,YAA6B,IAAY,EAAS,WAAoB,KAAK;QAA9C,SAAI,GAAJ,IAAI,CAAQ;QAAS,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;IAC/E,IAAI,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/B,IAAI,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,GAAY;QACnB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,IAAI;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,OAAe;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACH,EAAE,CAAC,KAAiB;QAClB,IAAI,CAAC,QAAQ,GAAG,MAAM,KAAK,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,SAAiD;QAC9D,sDAAsD;QACtD,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAI,IAAoB;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,2BAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;CACF;AArGD,0BAqGC"}
package/lib/context.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { Binding, BoundValue } from './binding';
2
- export declare class Context {
3
- private _parent;
4
- private registry;
5
- constructor(_parent?: Context);
6
- bind(key: string): Binding;
7
- contains(key: string): boolean;
8
- find(pattern?: string): Binding[];
9
- findByTag(pattern: string): Binding[];
10
- protected _mergeWithParent(childList: Binding[], parentList?: Binding[]): Binding[];
11
- get(key: string): Promise<BoundValue>;
12
- getSync(key: string): BoundValue;
13
- getBinding(key: string): Binding;
14
- }
package/lib/context.js DELETED
@@ -1,97 +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 binding_1 = require("./binding");
8
- const isPromise_1 = require("./isPromise");
9
- class Context {
10
- constructor(_parent) {
11
- this._parent = _parent;
12
- this.registry = new Map();
13
- }
14
- bind(key) {
15
- const keyExists = this.registry.has(key);
16
- if (keyExists) {
17
- const existingBinding = this.registry.get(key);
18
- const bindingIsLocked = existingBinding && existingBinding.isLocked;
19
- if (bindingIsLocked)
20
- throw new Error(`Cannot rebind key "${key}", associated binding is locked`);
21
- }
22
- const binding = new binding_1.Binding(key);
23
- this.registry.set(key, binding);
24
- return binding;
25
- }
26
- contains(key) {
27
- return this.registry.has(key);
28
- }
29
- find(pattern) {
30
- let bindings = [];
31
- if (pattern) {
32
- // TODO(@superkhau): swap with production grade glob to regex lib
33
- const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
34
- this.registry.forEach(binding => {
35
- const isMatch = glob.test(binding.key);
36
- if (isMatch)
37
- bindings.push(binding);
38
- });
39
- }
40
- else {
41
- bindings = Array.from(this.registry.values());
42
- }
43
- const parentBindings = this._parent && this._parent.find(pattern);
44
- return this._mergeWithParent(bindings, parentBindings);
45
- }
46
- findByTag(pattern) {
47
- const bindings = [];
48
- // TODO(@superkhau): swap with production grade glob to regex lib
49
- const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
50
- this.registry.forEach(binding => {
51
- const isMatch = glob.test(binding.tagName);
52
- if (isMatch)
53
- bindings.push(binding);
54
- });
55
- const parentBindings = this._parent && this._parent.findByTag(pattern);
56
- return this._mergeWithParent(bindings, parentBindings);
57
- }
58
- _mergeWithParent(childList, parentList) {
59
- if (!parentList)
60
- return childList;
61
- const additions = parentList.filter(parentBinding => {
62
- // children bindings take precedence
63
- return !childList.some(childBinding => childBinding.key === parentBinding.key);
64
- });
65
- return childList.concat(additions);
66
- }
67
- get(key) {
68
- try {
69
- const binding = this.getBinding(key);
70
- return Promise.resolve(binding.getValue(this));
71
- }
72
- catch (err) {
73
- return Promise.reject(err);
74
- }
75
- }
76
- getSync(key) {
77
- const binding = this.getBinding(key);
78
- const valueOrPromise = binding.getValue(this);
79
- if (isPromise_1.isPromise(valueOrPromise)) {
80
- throw new Error(`Cannot get ${key} synchronously: ` +
81
- `the value requires async computation`);
82
- }
83
- return valueOrPromise;
84
- }
85
- getBinding(key) {
86
- const binding = this.registry.get(key);
87
- if (binding) {
88
- return binding;
89
- }
90
- if (this._parent) {
91
- return this._parent.getBinding(key);
92
- }
93
- throw new Error(`The key ${key} was not bound to any value.`);
94
- }
95
- }
96
- exports.Context = Context;
97
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAEhE,uCAA8C;AAE9C,2CAAsC;AAEtC;IAGE,YAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC,GAAW;QACd,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/C,MAAM,eAAe,GAAG,eAAe,IAAI,eAAe,CAAC,QAAQ,CAAC;YACpE,EAAE,CAAC,CAAC,eAAe,C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AAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAW;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE9C,EAAE,CAAC,CAAC,qBAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,cAAc,GAAG,kBAAkB;gBACnC,sCAAsC,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,cAAc,CAAC;IACxB,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,OAAO,CAAC;QACjB,CAAC;QAED,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,8BAA8B,CAAC,CAAC;IAChE,CAAC;CACF;AApGD,0BAoGC"}
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src';
package/lib/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/lib/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/lib/inject.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import { BoundValue } from './binding';
2
- export interface Injection {
3
- bindingKey: string;
4
- metadata?: {
5
- [attribute: string]: BoundValue;
6
- };
7
- }
8
- /**
9
- * A decorator to annotate method arguments for automatic injection
10
- * by LoopBack IoC container.
11
- *
12
- * Usage - Typescript:
13
- *
14
- * ```ts
15
- * class InfoController {
16
- * @inject('authentication.user') public userName: string;
17
- *
18
- * constructor(@inject('application.name') public appName: string) {
19
- * }
20
- * // ...
21
- * }
22
- * ```
23
- *
24
- * Usage - JavaScript:
25
- *
26
- * - TODO(bajtos)
27
- *
28
- * @param bindingKey What binding to use in order to resolve the value of the
29
- * decorated constructor parameter or property.
30
- * @param metadata Optional metadata to help the injection
31
- *
32
- */
33
- export declare function inject(bindingKey: string, metadata?: Object): (target: any, propertyKey?: string | symbol | undefined, propertyDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
34
- /**
35
- * Return an array of injection objects for constructor parameters
36
- * @param target The target class
37
- */
38
- export declare function describeInjectedArguments(target: Function): Injection[];
39
- /**
40
- * Return a map of injection objects for properties
41
- * @param target The target class. Please note a property decorator function receives
42
- * the target.prototype
43
- */
44
- export declare function describeInjectedProperties(target: Function): {
45
- [p: string]: Injection;
46
- };
package/lib/inject.js DELETED
@@ -1,74 +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 reflect_1 = require("./reflect");
8
- const REFLECTION_CDI_KEY = 'loopback:inject:constructor';
9
- const REFLECTION_PDI_KEY = 'loopback:inject:properties';
10
- /**
11
- * A decorator to annotate method arguments for automatic injection
12
- * by LoopBack IoC container.
13
- *
14
- * Usage - Typescript:
15
- *
16
- * ```ts
17
- * class InfoController {
18
- * @inject('authentication.user') public userName: string;
19
- *
20
- * constructor(@inject('application.name') public appName: string) {
21
- * }
22
- * // ...
23
- * }
24
- * ```
25
- *
26
- * Usage - JavaScript:
27
- *
28
- * - TODO(bajtos)
29
- *
30
- * @param bindingKey What binding to use in order to resolve the value of the
31
- * decorated constructor parameter or property.
32
- * @param metadata Optional metadata to help the injection
33
- *
34
- */
35
- function inject(bindingKey, metadata) {
36
- // tslint:disable-next-line:no-any
37
- return function markArgumentAsInjected(target, propertyKey, propertyDescriptorOrParameterIndex) {
38
- if (typeof propertyDescriptorOrParameterIndex === 'number') {
39
- // The decorator is applied to a method parameter
40
- // Please note propertyKey is `undefined` for constructor
41
- const injectedArgs = reflect_1.Reflector.getOwnMetadata(REFLECTION_CDI_KEY, target, propertyKey) || [];
42
- injectedArgs[propertyDescriptorOrParameterIndex] = { bindingKey, metadata };
43
- reflect_1.Reflector.defineMetadata(REFLECTION_CDI_KEY, injectedArgs, target, propertyKey);
44
- }
45
- else if (propertyKey) {
46
- // The decorator is applied to a property
47
- const injections = reflect_1.Reflector.getOwnMetadata(REFLECTION_PDI_KEY, target) || {};
48
- injections[propertyKey] = { bindingKey, metadata };
49
- reflect_1.Reflector.defineMetadata(REFLECTION_PDI_KEY, injections, target);
50
- }
51
- else {
52
- throw new Error('@inject can be used on properties or method parameters.');
53
- }
54
- };
55
- }
56
- exports.inject = inject;
57
- /**
58
- * Return an array of injection objects for constructor parameters
59
- * @param target The target class
60
- */
61
- function describeInjectedArguments(target) {
62
- return reflect_1.Reflector.getOwnMetadata(REFLECTION_CDI_KEY, target) || [];
63
- }
64
- exports.describeInjectedArguments = describeInjectedArguments;
65
- /**
66
- * Return a map of injection objects for properties
67
- * @param target The target class. Please note a property decorator function receives
68
- * the target.prototype
69
- */
70
- function describeInjectedProperties(target) {
71
- return reflect_1.Reflector.getOwnMetadata(REFLECTION_PDI_KEY, target.prototype) || {};
72
- }
73
- exports.describeInjectedProperties = describeInjectedProperties;
74
- //# sourceMappingURL=inject.js.map
package/lib/inject.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAGhE,uCAAsC;AAGtC,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAOxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,gBAAuB,UAAkB,EAAE,QAAiB;IAC1D,kCAAkC;IAClC,MAAM,CAAC,gCAAgC,MAAW,EAAE,WAA6B,EAC/E,kCAAiF;QAEjF,EAAE,CAAC,CAAC,OAAO,kCAAkC,KAAK,QAAQ,CAAC,CAAC,CAAC;YAC3D,iDAAiD;YACjD,yDAAyD;YACzD,MAAM,YAAY,GAChB,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;YAC3E,YAAY,CAAC,kCAAkC,CAAC,GAAG,EAAC,UAAU,EAAE,QAAQ,EAAC,CAAC;YAC1E,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,YAAY,EAAE,MAAM,EAAE,WAAY,CAAC,CAAC;QACnF,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YACvB,yCAAyC;YACzC,MAAM,UAAU,GACd,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YAC7D,UAAU,CAAC,WAAW,CAAC,GAAG,EAAC,UAAU,EAAE,QAAQ,EAAC,CAAC;YACjD,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAtBD,wBAsBC;AAED;;;GAGG;AACH,mCAA0C,MAAgB;IACxD,MAAM,CAAC,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACpE,CAAC;AAFD,8DAEC;AAED;;;;GAIG;AACH,oCAA2C,MAAgB;IACzD,MAAM,CAAC,mBAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AAC9E,CAAC;AAFD,gEAEC"}
@@ -1 +0,0 @@
1
- export declare function isPromise<T>(value: T | Promise<T>): value is Promise<T>;
package/lib/isPromise.js DELETED
@@ -1,15 +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
- function isPromise(value) {
8
- if (!value)
9
- return false;
10
- if (typeof value !== 'object' && typeof value !== 'function')
11
- return false;
12
- return typeof value.then === 'function';
13
- }
14
- exports.isPromise = isPromise;
15
- //# sourceMappingURL=isPromise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isPromise.js","sourceRoot":"","sources":["../src/isPromise.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAEhE,mBAA6B,KAAqB;IAChD,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACT,MAAM,CAAC,KAAK,CAAC;IACf,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;QAC3D,MAAM,CAAC,KAAK,CAAC;IACf,MAAM,CAAC,OAAQ,KAAoB,CAAC,IAAI,KAAK,UAAU,CAAC;AAC1D,CAAC;AAND,8BAMC"}
package/lib/reflect.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import 'reflect-metadata';
2
- export declare const Reflector: {
3
- defineMetadata: {
4
- (metadataKey: any, metadataValue: any, target: Object): void;
5
- (metadataKey: any, metadataValue: any, target: Object, propertyKey: string | symbol): void;
6
- };
7
- getMetadata: {
8
- (metadataKey: any, target: Object): any;
9
- (metadataKey: any, target: Object, propertyKey: string | symbol): any;
10
- };
11
- getOwnMetadata: {
12
- (metadataKey: any, target: Object): any;
13
- (metadataKey: any, target: Object, propertyKey: string | symbol): any;
14
- };
15
- hasMetadata: {
16
- (metadataKey: any, target: Object): boolean;
17
- (metadataKey: any, target: Object, propertyKey: string | symbol): boolean;
18
- };
19
- hasOwnMetadata: {
20
- (metadataKey: any, target: Object): boolean;
21
- (metadataKey: any, target: Object, propertyKey: string | symbol): boolean;
22
- };
23
- getMetadataKeys: {
24
- (target: Object): any[];
25
- (target: Object, propertyKey: string | symbol): any[];
26
- };
27
- getOwnMetadataKeys: {
28
- (target: Object): any[];
29
- (target: Object, propertyKey: string | symbol): any[];
30
- };
31
- decorate: {
32
- (decorators: ClassDecorator[], target: Function): Function;
33
- (decorators: (PropertyDecorator | MethodDecorator)[], target: Object, propertyKey: string | symbol, attributes?: PropertyDescriptor | undefined): PropertyDescriptor;
34
- };
35
- metadata: (metadataKey: any, metadataValue: any) => {
36
- (target: Function): void;
37
- (target: Object, propertyKey: string | symbol): void;
38
- };
39
- };
package/lib/reflect.js DELETED
@@ -1,20 +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-next-line:variable-name */
9
- exports.Reflector = {
10
- defineMetadata: Reflect.defineMetadata,
11
- getMetadata: Reflect.getMetadata,
12
- getOwnMetadata: Reflect.getOwnMetadata,
13
- hasMetadata: Reflect.hasMetadata,
14
- hasOwnMetadata: Reflect.hasOwnMetadata,
15
- getMetadataKeys: Reflect.getMetadataKeys,
16
- getOwnMetadataKeys: Reflect.getOwnMetadataKeys,
17
- decorate: Reflect.decorate,
18
- metadata: Reflect.metadata,
19
- };
20
- //# sourceMappingURL=reflect.js.map
@@ -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;;AAEhE,4BAA0B;AAE1B,4CAA4C;AAC/B,QAAA,SAAS,GAAG;IACvB,cAAc,EAAE,OAAO,CAAC,cAAc;IACtC,WAAW,EAAE,OAAO,CAAC,WAAW;IAChC,cAAc,EAAE,OAAO,CAAC,cAAc;IACtC,WAAW,EAAE,OAAO,CAAC,WAAW;IAChC,cAAc,EAAE,OAAO,CAAC,cAAc;IACtC,eAAe,EAAE,OAAO,CAAC,eAAe;IACxC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;IAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;CAC3B,CAAC"}
package/lib/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>;