@loopback/context 4.0.0-alpha.7 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) 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/dist/json-types.js +7 -0
  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/dist/provider.js +7 -0
  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 -35
  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 -102
  116. package/lib/context.d.ts +0 -14
  117. package/lib/context.js +0 -96
  118. package/lib/index.d.ts +0 -5
  119. package/lib/index.js +0 -13
  120. package/lib/inject.d.ts +0 -47
  121. package/lib/inject.js +0 -73
  122. package/lib/isPromise.d.ts +0 -1
  123. package/lib/isPromise.js +0 -14
  124. package/lib/resolver.d.ts +0 -30
  125. package/lib/resolver.js +0 -128
  126. package/lib6/binding.d.ts +0 -75
  127. package/lib6/binding.js +0 -102
  128. package/lib6/context.d.ts +0 -14
  129. package/lib6/context.js +0 -96
  130. package/lib6/index.d.ts +0 -5
  131. package/lib6/index.js +0 -13
  132. package/lib6/inject.d.ts +0 -47
  133. package/lib6/inject.js +0 -73
  134. package/lib6/isPromise.d.ts +0 -1
  135. package/lib6/isPromise.js +0 -14
  136. package/lib6/resolver.d.ts +0 -30
  137. package/lib6/resolver.js +0 -128
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE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;AAED;;GAEG;AACH,MAAM,YAAY;IAAlB;QACmB,YAAO,GAAG,IAAI,GAAG,EAAgC,CAAC;QAClD,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAoBzD,CAAC;IAlBC,KAAK,CAAC,IAA0B;QAC9B,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,IAAI,IAAI,IAAI,EAAE;YAChB,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACjB,oDAAoD;YACpD,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,yDAAyD;gBACzD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;gBAClC,IAAI,GAAG,GAAG,IAAI,KAAK,KAAK,EAAE,CAAC;aAC5B;iBAAM;gBACL,oCAAoC;gBACpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;aAC7B;YACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAYD;;GAEG;AACH,IAAY,qBAeX;AAfD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,iDAAwB,CAAA;IACxB;;;OAGG;IACH,+CAAsB,CAAA;IACtB;;;OAGG;IACH,2DAAkC,CAAA;AACpC,CAAC,EAfW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAehC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Facilities to manage artifacts and their dependencies using {@link Context}
3
+ * in your Node.js applications. It can be used independent of the LoopBack
4
+ * framework.
5
+ *
6
+ * @remarks
7
+ * This package exposes TypeScript/JavaScript APIs and decorators to register
8
+ * artifacts, declare dependencies, and resolve artifacts by keys. The
9
+ * {@link Context} also serves as an IoC container to support dependency
10
+ * injection.
11
+ * Context and Binding are the two core concepts. A context is a registry of
12
+ * bindings and each binding represents a resolvable artifact by the key.
13
+ *
14
+ * - Bindings can be fulfilled by a constant, a factory function, a class, or a
15
+ * provider.
16
+ * - Bindings can be grouped by tags and searched by tags.
17
+ * - Binding scopes can be used to control how a resolved binding value is
18
+ * shared.
19
+ * - Bindings can be resolved synchronously or asynchronously.
20
+ * - Provide {@link inject | @inject} and other variants of decorators to
21
+ * express dependencies.
22
+ * - Support Constructor, property, and method injections.
23
+ * - Allow contexts to form a hierarchy to share or override bindings.
24
+ *
25
+ * @pakageDocumentation
26
+ */
27
+ export * from '@loopback/metadata';
28
+ export * from './binding';
29
+ export * from './binding-config';
30
+ export * from './binding-decorator';
31
+ export * from './binding-filter';
32
+ export * from './binding-inspector';
33
+ export * from './binding-key';
34
+ export * from './binding-sorter';
35
+ export * from './context';
36
+ export * from './context-event';
37
+ export * from './context-observer';
38
+ export * from './context-subscription';
39
+ export * from './context-view';
40
+ export * from './inject';
41
+ export * from './inject-config';
42
+ export * from './interception-proxy';
43
+ export * from './interceptor';
44
+ export * from './interceptor-chain';
45
+ export * from './invocation';
46
+ export * from './json-types';
47
+ export * from './keys';
48
+ export * from './provider';
49
+ export * from './resolution-session';
50
+ export * from './resolver';
51
+ export * from './unique-id';
52
+ export * from './value-promise';
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2017,2020. 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
+ const tslib_1 = require("tslib");
8
+ /**
9
+ * Facilities to manage artifacts and their dependencies using {@link Context}
10
+ * in your Node.js applications. It can be used independent of the LoopBack
11
+ * framework.
12
+ *
13
+ * @remarks
14
+ * This package exposes TypeScript/JavaScript APIs and decorators to register
15
+ * artifacts, declare dependencies, and resolve artifacts by keys. The
16
+ * {@link Context} also serves as an IoC container to support dependency
17
+ * injection.
18
+ * Context and Binding are the two core concepts. A context is a registry of
19
+ * bindings and each binding represents a resolvable artifact by the key.
20
+ *
21
+ * - Bindings can be fulfilled by a constant, a factory function, a class, or a
22
+ * provider.
23
+ * - Bindings can be grouped by tags and searched by tags.
24
+ * - Binding scopes can be used to control how a resolved binding value is
25
+ * shared.
26
+ * - Bindings can be resolved synchronously or asynchronously.
27
+ * - Provide {@link inject | @inject} and other variants of decorators to
28
+ * express dependencies.
29
+ * - Support Constructor, property, and method injections.
30
+ * - Allow contexts to form a hierarchy to share or override bindings.
31
+ *
32
+ * @pakageDocumentation
33
+ */
34
+ (0, tslib_1.__exportStar)(require("@loopback/metadata"), exports);
35
+ (0, tslib_1.__exportStar)(require("./binding"), exports);
36
+ (0, tslib_1.__exportStar)(require("./binding-config"), exports);
37
+ (0, tslib_1.__exportStar)(require("./binding-decorator"), exports);
38
+ (0, tslib_1.__exportStar)(require("./binding-filter"), exports);
39
+ (0, tslib_1.__exportStar)(require("./binding-inspector"), exports);
40
+ (0, tslib_1.__exportStar)(require("./binding-key"), exports);
41
+ (0, tslib_1.__exportStar)(require("./binding-sorter"), exports);
42
+ (0, tslib_1.__exportStar)(require("./context"), exports);
43
+ (0, tslib_1.__exportStar)(require("./context-event"), exports);
44
+ (0, tslib_1.__exportStar)(require("./context-observer"), exports);
45
+ (0, tslib_1.__exportStar)(require("./context-subscription"), exports);
46
+ (0, tslib_1.__exportStar)(require("./context-view"), exports);
47
+ (0, tslib_1.__exportStar)(require("./inject"), exports);
48
+ (0, tslib_1.__exportStar)(require("./inject-config"), exports);
49
+ (0, tslib_1.__exportStar)(require("./interception-proxy"), exports);
50
+ (0, tslib_1.__exportStar)(require("./interceptor"), exports);
51
+ (0, tslib_1.__exportStar)(require("./interceptor-chain"), exports);
52
+ (0, tslib_1.__exportStar)(require("./invocation"), exports);
53
+ (0, tslib_1.__exportStar)(require("./json-types"), exports);
54
+ (0, tslib_1.__exportStar)(require("./keys"), exports);
55
+ (0, tslib_1.__exportStar)(require("./provider"), exports);
56
+ (0, tslib_1.__exportStar)(require("./resolution-session"), exports);
57
+ (0, tslib_1.__exportStar)(require("./resolver"), exports);
58
+ (0, tslib_1.__exportStar)(require("./unique-id"), exports);
59
+ (0, tslib_1.__exportStar)(require("./value-promise"), exports);
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,kEAAmC;AACnC,yDAA0B;AAC1B,gEAAiC;AACjC,mEAAoC;AACpC,gEAAiC;AACjC,mEAAoC;AACpC,6DAA8B;AAC9B,gEAAiC;AACjC,yDAA0B;AAC1B,+DAAgC;AAChC,kEAAmC;AACnC,sEAAuC;AACvC,8DAA+B;AAC/B,wDAAyB;AACzB,+DAAgC;AAChC,oEAAqC;AACrC,6DAA8B;AAC9B,mEAAoC;AACpC,4DAA6B;AAC7B,4DAA6B;AAC7B,sDAAuB;AACvB,0DAA2B;AAC3B,oEAAqC;AACrC,0DAA2B;AAC3B,2DAA4B;AAC5B,+DAAgC"}
@@ -0,0 +1,67 @@
1
+ import { BindingAddress } from './binding-key';
2
+ import { InjectionMetadata } from './inject';
3
+ /**
4
+ * Injection metadata for `@config.*`
5
+ */
6
+ export interface ConfigInjectionMetadata extends InjectionMetadata {
7
+ /**
8
+ * Property path to retrieve the configuration of the target binding, for
9
+ * example, `rest.host`.
10
+ */
11
+ propertyPath?: string;
12
+ /**
13
+ * Customize the target binding key from which the configuration is fetched.
14
+ * If not specified, the configuration of the current binding that contains
15
+ * the injection is used.
16
+ */
17
+ fromBinding?: BindingAddress;
18
+ }
19
+ /**
20
+ * Inject a property from `config` of the current binding. If no corresponding
21
+ * config value is present, `undefined` will be injected as the configuration
22
+ * binding is resolved with `optional: true` by default.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * class Store {
27
+ * constructor(
28
+ * @config('x') public optionX: number,
29
+ * @config('y') public optionY: string,
30
+ * ) { }
31
+ * }
32
+ *
33
+ * ctx.configure('store1', { x: 1, y: 'a' });
34
+ * ctx.configure('store2', { x: 2, y: 'b' });
35
+ *
36
+ * ctx.bind('store1').toClass(Store);
37
+ * ctx.bind('store2').toClass(Store);
38
+ *
39
+ * const store1 = ctx.getSync('store1');
40
+ * expect(store1.optionX).to.eql(1);
41
+ * expect(store1.optionY).to.eql('a');
42
+ *
43
+ * const store2 = ctx.getSync('store2');
44
+ * expect(store2.optionX).to.eql(2);
45
+ * expect(store2.optionY).to.eql('b');
46
+ * ```
47
+ *
48
+ * @param propertyPath - Optional property path of the config. If is `''` or not
49
+ * present, the `config` object will be returned.
50
+ * @param metadata - Optional metadata to help the injection
51
+ */
52
+ export declare function config(propertyPath?: string | ConfigInjectionMetadata, metadata?: ConfigInjectionMetadata): (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
53
+ export declare namespace config {
54
+ /**
55
+ * `@inject.getter` decorator to inject a config getter function
56
+ * @param propertyPath - Optional property path of the config object
57
+ * @param metadata - Injection metadata
58
+ */
59
+ const getter: (propertyPath?: string | ConfigInjectionMetadata | undefined, metadata?: ConfigInjectionMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
60
+ /**
61
+ * `@inject.view` decorator to inject a config context view to allow dynamic
62
+ * changes in configuration
63
+ * @param propertyPath - Optional property path of the config object
64
+ * @param metadata - Injection metadata
65
+ */
66
+ const view: (propertyPath?: string | ConfigInjectionMetadata | undefined, metadata?: ConfigInjectionMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
67
+ }
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019. 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
+ exports.config = void 0;
8
+ const binding_key_1 = require("./binding-key");
9
+ const context_view_1 = require("./context-view");
10
+ const inject_1 = require("./inject");
11
+ const resolution_session_1 = require("./resolution-session");
12
+ const value_promise_1 = require("./value-promise");
13
+ /**
14
+ * Inject a property from `config` of the current binding. If no corresponding
15
+ * config value is present, `undefined` will be injected as the configuration
16
+ * binding is resolved with `optional: true` by default.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * class Store {
21
+ * constructor(
22
+ * @config('x') public optionX: number,
23
+ * @config('y') public optionY: string,
24
+ * ) { }
25
+ * }
26
+ *
27
+ * ctx.configure('store1', { x: 1, y: 'a' });
28
+ * ctx.configure('store2', { x: 2, y: 'b' });
29
+ *
30
+ * ctx.bind('store1').toClass(Store);
31
+ * ctx.bind('store2').toClass(Store);
32
+ *
33
+ * const store1 = ctx.getSync('store1');
34
+ * expect(store1.optionX).to.eql(1);
35
+ * expect(store1.optionY).to.eql('a');
36
+ *
37
+ * const store2 = ctx.getSync('store2');
38
+ * expect(store2.optionX).to.eql(2);
39
+ * expect(store2.optionY).to.eql('b');
40
+ * ```
41
+ *
42
+ * @param propertyPath - Optional property path of the config. If is `''` or not
43
+ * present, the `config` object will be returned.
44
+ * @param metadata - Optional metadata to help the injection
45
+ */
46
+ function config(propertyPath, metadata) {
47
+ propertyPath = propertyPath !== null && propertyPath !== void 0 ? propertyPath : '';
48
+ if (typeof propertyPath === 'object') {
49
+ metadata = propertyPath;
50
+ propertyPath = '';
51
+ }
52
+ metadata = Object.assign({ propertyPath, decorator: '@config', optional: true }, metadata);
53
+ return (0, inject_1.inject)('', metadata, resolveFromConfig);
54
+ }
55
+ exports.config = config;
56
+ (function (config) {
57
+ /**
58
+ * `@inject.getter` decorator to inject a config getter function
59
+ * @param propertyPath - Optional property path of the config object
60
+ * @param metadata - Injection metadata
61
+ */
62
+ config.getter = function injectConfigGetter(propertyPath, metadata) {
63
+ propertyPath = propertyPath !== null && propertyPath !== void 0 ? propertyPath : '';
64
+ if (typeof propertyPath === 'object') {
65
+ metadata = propertyPath;
66
+ propertyPath = '';
67
+ }
68
+ metadata = Object.assign({ propertyPath, decorator: '@config.getter', optional: true }, metadata);
69
+ return (0, inject_1.inject)('', metadata, resolveAsGetterFromConfig);
70
+ };
71
+ /**
72
+ * `@inject.view` decorator to inject a config context view to allow dynamic
73
+ * changes in configuration
74
+ * @param propertyPath - Optional property path of the config object
75
+ * @param metadata - Injection metadata
76
+ */
77
+ config.view = function injectConfigView(propertyPath, metadata) {
78
+ propertyPath = propertyPath !== null && propertyPath !== void 0 ? propertyPath : '';
79
+ if (typeof propertyPath === 'object') {
80
+ metadata = propertyPath;
81
+ propertyPath = '';
82
+ }
83
+ metadata = Object.assign({ propertyPath, decorator: '@config.view', optional: true }, metadata);
84
+ return (0, inject_1.inject)('', metadata, resolveAsViewFromConfig);
85
+ };
86
+ })(config = exports.config || (exports.config = {}));
87
+ /**
88
+ * Get the key for the current binding on which dependency injection is
89
+ * performed
90
+ * @param session - Resolution session
91
+ */
92
+ function getCurrentBindingKey(session) {
93
+ var _a;
94
+ // The current binding is not set if `instantiateClass` is invoked directly
95
+ return (_a = session.currentBinding) === null || _a === void 0 ? void 0 : _a.key;
96
+ }
97
+ /**
98
+ * Get the target binding key from which the configuration should be resolved
99
+ * @param injection - Injection
100
+ * @param session - Resolution session
101
+ */
102
+ function getTargetBindingKey(injection, session) {
103
+ return injection.metadata.fromBinding || getCurrentBindingKey(session);
104
+ }
105
+ /**
106
+ * Resolver for `@config`
107
+ * @param ctx - Context object
108
+ * @param injection - Injection metadata
109
+ * @param session - Resolution session
110
+ */
111
+ function resolveFromConfig(ctx, injection, session) {
112
+ const bindingKey = getTargetBindingKey(injection, session);
113
+ // Return `undefined` if no current binding is present
114
+ if (!bindingKey)
115
+ return undefined;
116
+ const meta = injection.metadata;
117
+ return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, {
118
+ session,
119
+ optional: meta.optional,
120
+ });
121
+ }
122
+ /**
123
+ * Resolver from `@config.getter`
124
+ * @param ctx - Context object
125
+ * @param injection - Injection metadata
126
+ * @param session - Resolution session
127
+ */
128
+ function resolveAsGetterFromConfig(ctx, injection, session) {
129
+ (0, inject_1.assertTargetType)(injection, Function, 'Getter function');
130
+ const bindingKey = getTargetBindingKey(injection, session);
131
+ // We need to clone the session for the getter as it will be resolved later
132
+ const forkedSession = resolution_session_1.ResolutionSession.fork(session);
133
+ const meta = injection.metadata;
134
+ return async function getter() {
135
+ // Return `undefined` if no current binding is present
136
+ if (!bindingKey)
137
+ return undefined;
138
+ return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, {
139
+ session: forkedSession,
140
+ optional: meta.optional,
141
+ });
142
+ };
143
+ }
144
+ /**
145
+ * Resolver for `@config.view`
146
+ * @param ctx - Context object
147
+ * @param injection - Injection metadata
148
+ * @param session - Resolution session
149
+ */
150
+ function resolveAsViewFromConfig(ctx, injection, session) {
151
+ (0, inject_1.assertTargetType)(injection, context_view_1.ContextView);
152
+ const bindingKey = getTargetBindingKey(injection, session);
153
+ // Return `undefined` if no current binding is present
154
+ if (!bindingKey)
155
+ return undefined;
156
+ const view = new ConfigView(ctx, binding => binding.key === binding_key_1.BindingKey.buildKeyForConfig(bindingKey).toString(), injection.metadata.propertyPath);
157
+ view.open();
158
+ return view;
159
+ }
160
+ /**
161
+ * A subclass of `ContextView` to handle dynamic configuration as its
162
+ * `values()` honors the `propertyPath`.
163
+ */
164
+ class ConfigView extends context_view_1.ContextView {
165
+ constructor(ctx, filter, propertyPath) {
166
+ super(ctx, filter);
167
+ this.propertyPath = propertyPath;
168
+ }
169
+ /**
170
+ * Get values for the configuration with a property path
171
+ * @param session - Resolution session
172
+ */
173
+ async values(session) {
174
+ const configValues = await super.values(session);
175
+ const propertyPath = this.propertyPath;
176
+ if (!propertyPath)
177
+ return configValues;
178
+ return configValues.map(v => (0, value_promise_1.getDeepProperty)(v, propertyPath));
179
+ }
180
+ }
181
+ //# sourceMappingURL=inject-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-config.js","sourceRoot":"","sources":["../src/inject-config.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;;AAGhE,+CAAyD;AAEzD,iDAA2C;AAC3C,qCAAgF;AAChF,6DAAuD;AACvD,mDAAgE;AAmBhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,MAAM,CACpB,YAA+C,EAC/C,QAAkC;IAElC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC;IAClC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,QAAQ,GAAG,YAAY,CAAC;QACxB,YAAY,GAAG,EAAE,CAAC;KACnB;IACD,QAAQ,GAAG,MAAM,CAAC,MAAM,CACtB,EAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAC,EACpD,QAAQ,CACT,CAAC;IACF,OAAO,IAAA,eAAM,EAAC,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACjD,CAAC;AAdD,wBAcC;AAED,WAAiB,MAAM;IACrB;;;;OAIG;IACU,aAAM,GAAG,SAAS,kBAAkB,CAC/C,YAA+C,EAC/C,QAAkC;QAElC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC;QAClC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;YACpC,QAAQ,GAAG,YAAY,CAAC;YACxB,YAAY,GAAG,EAAE,CAAC;SACnB;QACD,QAAQ,GAAG,MAAM,CAAC,MAAM,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CAAC,QAAQ,EAAE,EACrE,SAAS,CAAC,QAAQ,CAAC,YAAY,CAChC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,CAAC;IACZ,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAW,SAAQ,0BAAW;IAClC,YACE,GAAY,EACZ,MAAqB,EACb,YAAqB;QAE7B,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAFX,iBAAY,GAAZ,YAAY,CAAS;IAG/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,OAA2B;QACtC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,IAAI,CAAC,YAAY;YAAE,OAAO,YAAY,CAAC;QACvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,+BAAe,EAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;IACjE,CAAC;CACF"}
@@ -0,0 +1,250 @@
1
+ import { MetadataMap } from '@loopback/metadata';
2
+ import { Binding, BindingTag } from './binding';
3
+ import { BindingFilter, BindingSelector } from './binding-filter';
4
+ import { BindingAddress, BindingKey } from './binding-key';
5
+ import { BindingComparator } from './binding-sorter';
6
+ import { BindingCreationPolicy, Context } from './context';
7
+ import { JSONObject } from './json-types';
8
+ import { ResolutionOptions, ResolutionSession } from './resolution-session';
9
+ import { BoundValue, Constructor, ValueOrPromise } from './value-promise';
10
+ /**
11
+ * A function to provide resolution of injected values.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const resolver: ResolverFunction = (ctx, injection, session) {
16
+ * return session.currentBinding?.key;
17
+ * }
18
+ * ```
19
+ */
20
+ export interface ResolverFunction {
21
+ (ctx: Context, injection: Readonly<Injection>, session: ResolutionSession): ValueOrPromise<BoundValue>;
22
+ }
23
+ /**
24
+ * An object to provide metadata for `@inject`
25
+ */
26
+ export interface InjectionMetadata extends Omit<ResolutionOptions, 'session'> {
27
+ /**
28
+ * Name of the decorator function, such as `@inject` or `@inject.setter`.
29
+ * It's usually set by the decorator implementation.
30
+ */
31
+ decorator?: string;
32
+ /**
33
+ * Optional comparator for matched bindings
34
+ */
35
+ bindingComparator?: BindingComparator;
36
+ /**
37
+ * Other attributes
38
+ */
39
+ [attribute: string]: BoundValue;
40
+ }
41
+ /**
42
+ * Descriptor for an injection point
43
+ */
44
+ export interface Injection<ValueType = BoundValue> {
45
+ target: Object;
46
+ member?: string;
47
+ methodDescriptorOrParameterIndex?: TypedPropertyDescriptor<ValueType> | number;
48
+ bindingSelector: BindingSelector<ValueType>;
49
+ metadata: InjectionMetadata;
50
+ resolve?: ResolverFunction;
51
+ }
52
+ /**
53
+ * A decorator to annotate method arguments for automatic injection
54
+ * by LoopBack IoC container.
55
+ *
56
+ * @example
57
+ * Usage - Typescript:
58
+ *
59
+ * ```ts
60
+ * class InfoController {
61
+ * @inject('authentication.user') public userName: string;
62
+ *
63
+ * constructor(@inject('application.name') public appName: string) {
64
+ * }
65
+ * // ...
66
+ * }
67
+ * ```
68
+ *
69
+ * Usage - JavaScript:
70
+ *
71
+ * - TODO(bajtos)
72
+ *
73
+ * @param bindingSelector - What binding to use in order to resolve the value of the
74
+ * decorated constructor parameter or property.
75
+ * @param metadata - Optional metadata to help the injection
76
+ * @param resolve - Optional function to resolve the injection
77
+ *
78
+ */
79
+ export declare function inject(bindingSelector: BindingSelector, metadata?: InjectionMetadata, resolve?: ResolverFunction): (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
80
+ /**
81
+ * The function injected by `@inject.getter(bindingSelector)`. It can be used
82
+ * to fetch bound value(s) from the underlying binding(s). The return value will
83
+ * be an array if the `bindingSelector` is a `BindingFilter` function.
84
+ */
85
+ export declare type Getter<T> = () => Promise<T>;
86
+ export declare namespace Getter {
87
+ /**
88
+ * Convert a value into a Getter returning that value.
89
+ * @param value
90
+ */
91
+ function fromValue<T>(value: T): Getter<T>;
92
+ }
93
+ /**
94
+ * The function injected by `@inject.setter(bindingKey)`. It sets the underlying
95
+ * binding to a constant value using `binding.to(value)`.
96
+ *
97
+ * @example
98
+ *
99
+ * ```ts
100
+ * setterFn('my-value');
101
+ * ```
102
+ * @param value - The value for the underlying binding
103
+ */
104
+ export declare type Setter<T> = (value: T) => void;
105
+ /**
106
+ * Metadata for `@inject.binding`
107
+ */
108
+ export interface InjectBindingMetadata extends InjectionMetadata {
109
+ /**
110
+ * Controls how the underlying binding is resolved/created
111
+ */
112
+ bindingCreation?: BindingCreationPolicy;
113
+ }
114
+ export declare namespace inject {
115
+ /**
116
+ * Inject a function for getting the actual bound value.
117
+ *
118
+ * This is useful when implementing Actions, where
119
+ * the action is instantiated for Sequence constructor, but some
120
+ * of action's dependencies become bound only after other actions
121
+ * have been executed by the sequence.
122
+ *
123
+ * See also `Getter<T>`.
124
+ *
125
+ * @param bindingSelector - The binding key or filter we want to eventually get
126
+ * value(s) from.
127
+ * @param metadata - Optional metadata to help the injection
128
+ */
129
+ const getter: (bindingSelector: BindingSelector<unknown>, metadata?: InjectionMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
130
+ /**
131
+ * Inject a function for setting (binding) the given key to a given
132
+ * value. (Only static/constant values are supported, it's not possible
133
+ * to bind a key to a class or a provider.)
134
+ *
135
+ * This is useful e.g. when implementing Actions that are contributing
136
+ * new Elements.
137
+ *
138
+ * See also `Setter<T>`.
139
+ *
140
+ * @param bindingKey - The key of the value we want to set.
141
+ * @param metadata - Optional metadata to help the injection
142
+ */
143
+ const setter: (bindingKey: BindingAddress, metadata?: InjectBindingMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
144
+ /**
145
+ * Inject the binding object for the given key. This is useful if a binding
146
+ * needs to be set up beyond just a constant value allowed by
147
+ * `@inject.setter`. The injected binding is found or created based on the
148
+ * `metadata.bindingCreation` option. See `BindingCreationPolicy` for more
149
+ * details.
150
+ *
151
+ * @example
152
+ *
153
+ * ```ts
154
+ * class MyAuthAction {
155
+ * @inject.binding('current-user', {
156
+ * bindingCreation: BindingCreationPolicy.ALWAYS_CREATE,
157
+ * })
158
+ * private userBinding: Binding<UserProfile>;
159
+ *
160
+ * async authenticate() {
161
+ * this.userBinding.toDynamicValue(() => {...});
162
+ * }
163
+ * }
164
+ * ```
165
+ *
166
+ * @param bindingKey - Binding key
167
+ * @param metadata - Metadata for the injection
168
+ */
169
+ const binding: (bindingKey?: string | BindingKey<unknown> | undefined, metadata?: InjectBindingMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
170
+ /**
171
+ * Inject an array of values by a tag pattern string or regexp
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * class AuthenticationManager {
176
+ * constructor(
177
+ * @inject.tag('authentication.strategy') public strategies: Strategy[],
178
+ * ) {}
179
+ * }
180
+ * ```
181
+ * @param bindingTag - Tag name, regex or object
182
+ * @param metadata - Optional metadata to help the injection
183
+ */
184
+ const tag: (bindingTag: BindingTag | RegExp, metadata?: InjectionMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
185
+ /**
186
+ * Inject matching bound values by the filter function
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * class MyControllerWithView {
191
+ * @inject.view(filterByTag('foo'))
192
+ * view: ContextView<string[]>;
193
+ * }
194
+ * ```
195
+ * @param bindingFilter - A binding filter function
196
+ * @param metadata
197
+ */
198
+ const view: (bindingFilter: BindingFilter, metadata?: InjectionMetadata | undefined) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
199
+ /**
200
+ * Inject the context object.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * class MyProvider {
205
+ * constructor(@inject.context() private ctx: Context) {}
206
+ * }
207
+ * ```
208
+ */
209
+ const context: () => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
210
+ }
211
+ /**
212
+ * Assert the target type inspected from TypeScript for injection to be the
213
+ * expected type. If the types don't match, an error is thrown.
214
+ * @param injection - Injection information
215
+ * @param expectedType - Expected type
216
+ * @param expectedTypeName - Name of the expected type to be used in the error
217
+ * @returns The name of the target
218
+ */
219
+ export declare function assertTargetType(injection: Readonly<Injection>, expectedType: Function, expectedTypeName?: string): string;
220
+ /**
221
+ * Return an array of injection objects for parameters
222
+ * @param target - The target class for constructor or static methods,
223
+ * or the prototype for instance methods
224
+ * @param method - Method name, undefined for constructor
225
+ */
226
+ export declare function describeInjectedArguments(target: Object, method?: string): Readonly<Injection>[];
227
+ /**
228
+ * Inspect the target type for the injection to find out the corresponding
229
+ * JavaScript type
230
+ * @param injection - Injection information
231
+ */
232
+ export declare function inspectTargetType(injection: Readonly<Injection>): Function | undefined;
233
+ /**
234
+ * Return a map of injection objects for properties
235
+ * @param target - The target class for static properties or
236
+ * prototype for instance properties.
237
+ */
238
+ export declare function describeInjectedProperties(target: Object): MetadataMap<Readonly<Injection>>;
239
+ /**
240
+ * Inspect injections for a binding created with `toClass` or `toProvider`
241
+ * @param binding - Binding object
242
+ */
243
+ export declare function inspectInjections(binding: Readonly<Binding<unknown>>): JSONObject;
244
+ /**
245
+ * Check if the given class has `@inject` or other decorations that map to
246
+ * `@inject`.
247
+ *
248
+ * @param cls - Class with possible `@inject` decorations
249
+ */
250
+ export declare function hasInjections(cls: Constructor<unknown>): boolean;