@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
@@ -1,133 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const resolver_1 = require("./resolver");
16
- // FIXME(bajtos) The binding class should be parameterized by the value type stored
17
- class Binding {
18
- constructor(_key, isLocked = false) {
19
- this._key = _key;
20
- this.isLocked = isLocked;
21
- }
22
- get key() { return this._key; }
23
- get tagName() { return this._tagName; }
24
- /**
25
- * This is an internal function optimized for performance.
26
- * Users should use `@inject(key)` or `ctx.get(key)` instead.
27
- *
28
- * Get the value bound to this key. Depending on `isSync`, this function returns either:
29
- * - the bound value
30
- * - a promise of the bound value
31
- *
32
- * Consumers wishing to consume sync values directly should use `isPromise`
33
- * to check the type of the returned value to decide how to handle it.
34
- *
35
- * ```
36
- * const result = binding.getValue(ctx);
37
- * if (isPromise(result)) {
38
- * result.then(doSomething)
39
- * } else {
40
- * doSomething(result);
41
- * }
42
- * ```
43
- */
44
- getValue(ctx) {
45
- return Promise.reject(new Error(`No value was configured for binding ${this._key}.`));
46
- }
47
- lock() {
48
- this.isLocked = true;
49
- return this;
50
- }
51
- tag(tagName) {
52
- this._tagName = tagName;
53
- return this;
54
- }
55
- /**
56
- * Bind the key to a constant value.
57
- *
58
- * @param value The bound value.
59
- *
60
- * @example
61
- *
62
- * ```ts
63
- * ctx.bind('appName').to('CodeHub');
64
- * ```
65
- */
66
- to(value) {
67
- this.getValue = () => value;
68
- return this;
69
- }
70
- /**
71
- * Bind the key to a computed (dynamic) value.
72
- *
73
- * @param factoryFn The factory function creating the value.
74
- * Both sync and async functions are supported.
75
- *
76
- * @example
77
- *
78
- * ```ts
79
- * // synchronous
80
- * ctx.bind('now').toDynamicValue(() => Date.now());
81
- *
82
- * // asynchronous
83
- * ctx.bind('something').toDynamicValue(
84
- * async () => Promise.delay(10).then(doSomething)
85
- * );
86
- * ```
87
- */
88
- toDynamicValue(factoryFn) {
89
- // TODO(bajtos) allow factoryFn with @inject arguments
90
- this.getValue = (ctx) => factoryFn();
91
- return this;
92
- }
93
- /**
94
- * Bind the key to a BindingProvider
95
- */
96
- toProvider(providerClass) {
97
- this.getProviderInstance = (ctx) => __awaiter(this, void 0, void 0, function* () {
98
- const providerOrPromise = resolver_1.instantiateClass(providerClass, ctx);
99
- return resolver_1.resolveValueOrPromise(providerOrPromise);
100
- });
101
- this.getValue = (ctx) => __awaiter(this, void 0, void 0, function* () {
102
- const providerInstance = yield this.getProviderInstance(ctx);
103
- return providerInstance.value();
104
- });
105
- return this;
106
- }
107
- /**
108
- * get an instance of the provider
109
- */
110
- getProviderInstance(ctx) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- return Promise.reject(new Error(`No provider is attached to binding ${this._key}.`));
113
- });
114
- }
115
- /**
116
- * Bind the key to an instance of the given class.
117
- *
118
- * @param ctor The class constructor to call. Any constructor
119
- * arguments must be annotated with `@inject` so that
120
- * we can resolve them from the context.
121
- */
122
- toClass(ctor) {
123
- this.getValue = context => resolver_1.instantiateClass(ctor, context);
124
- this.valueConstructor = ctor;
125
- return this;
126
- }
127
- unlock() {
128
- this.isLocked = false;
129
- return this;
130
- }
131
- }
132
- exports.Binding = Binding;
133
- //# 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,yCAAgF;AAShF,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;;OAEG;IACI,UAAU,CAAI,aAAuC;QAC1D,IAAI,CAAC,mBAAmB,GAAG,CAAO,GAAY;YAC5C,MAAM,iBAAiB,GAAgC,2BAAgB,CAAc,aAAa,EAAE,GAAG,CAAC,CAAC;YACzG,MAAM,CAAC,gCAAqB,CAAc,iBAAiB,CAAC,CAAC;QAC/D,CAAC,CAAA,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,CAAO,GAAG;YACxB,MAAM,gBAAgB,GAAgB,MAAM,IAAI,CAAC,mBAAmB,CAAI,GAAG,CAAC,CAAC;YAC7E,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAA,CAAC;QACF,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACU,mBAAmB,CAAI,GAAY;;YAC9C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;QACvF,CAAC;KAAA;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;AA3HD,0BA2HC"}
@@ -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
- }
@@ -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,M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AAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC;QAAC,KAAK,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"}
@@ -1,10 +0,0 @@
1
- export { Binding, BoundValue } from './binding';
2
- export { Context } from './context';
3
- export { Constructor, resolveValueOrPromise } from './resolver';
4
- export { inject } from './inject';
5
- export { NamespacedReflect } from './reflect';
6
- export { Provider } from './provider';
7
- export { isPromise } from './isPromise';
8
- export { instantiateClass } from './resolver';
9
- export { describeInjectedArguments, describeInjectedProperties } from './inject';
10
- export { Reflector } from './reflect';
package/lib6/src/index.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- // Copyright IBM Corp. 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
- var binding_1 = require("./binding");
8
- exports.Binding = binding_1.Binding;
9
- var context_1 = require("./context");
10
- exports.Context = context_1.Context;
11
- var resolver_1 = require("./resolver");
12
- exports.resolveValueOrPromise = resolver_1.resolveValueOrPromise;
13
- var inject_1 = require("./inject");
14
- exports.inject = inject_1.inject;
15
- var reflect_1 = require("./reflect");
16
- exports.NamespacedReflect = reflect_1.NamespacedReflect;
17
- var isPromise_1 = require("./isPromise");
18
- exports.isPromise = isPromise_1.isPromise;
19
- // internals for testing
20
- var resolver_2 = require("./resolver");
21
- exports.instantiateClass = resolver_2.instantiateClass;
22
- var inject_2 = require("./inject");
23
- exports.describeInjectedArguments = inject_2.describeInjectedArguments;
24
- exports.describeInjectedProperties = inject_2.describeInjectedProperties;
25
- var reflect_2 = require("./reflect");
26
- exports.Reflector = reflect_2.Reflector;
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,wBAAwB;AACxB,+CAA+C;AAC/C,gEAAgE;;AAEhE,qCAA8C;AAAtC,4BAAA,OAAO,CAAA;AACf,qCAAkC;AAA1B,4BAAA,OAAO,CAAA;AACf,uCAA8D;AAAzC,2CAAA,qBAAqB,CAAA;AAC1C,mCAAgC;AAAxB,0BAAA,MAAM,CAAA;AACd,qCAA4C;AAApC,sCAAA,iBAAiB,CAAA;AAEzB,yCAAsC;AAA9B,gCAAA,SAAS,CAAA;AAEjB,wBAAwB;AACxB,uCAA4C;AAApC,sCAAA,gBAAgB,CAAA;AACxB,mCAA+E;AAAvE,6CAAA,yBAAyB,CAAA;AAAE,8CAAA,0BAA0B,CAAA;AAC7D,qCAAoC;AAA5B,8BAAA,SAAS,CAAA"}
@@ -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
- };
@@ -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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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>;
@@ -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"}
@@ -1,29 +0,0 @@
1
- import { ValueOrPromise } from './binding';
2
- /**
3
- * @exports Provider<T> : interface definition for a provider of a value of type T
4
- * @summary Providers allow binding of a value provider class instead of the value itself
5
- * @example:
6
- * ```ts
7
- * export class DateProvider implements Provider<Date> {
8
- * constructor(@inject('stringDate') private param: String){}
9
- * value(): Date {
10
- * return new Date(param);
11
- * }
12
- * }
13
- * ```
14
- * @example: Binding a context
15
- * ```ts
16
- * ctx.bind('provider_key').toProvider(MyProvider);
17
- * ```
18
- * @example: getting a value dynamically
19
- * ```ts
20
- * ctx.get('provider_key');
21
- * ctx.getBinding('provider_key').getValue();
22
- * ```
23
- */
24
- export interface Provider<T> {
25
- /**
26
- * @returns a value or a promise
27
- */
28
- value(): ValueOrPromise<T>;
29
- }
@@ -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"}
@@ -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;
@@ -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