@loopback/service-proxy 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/decorators/service.decorator.js +1 -0
- package/dist/decorators/service.decorator.js.map +1 -1
- package/dist/legacy-juggler-bridge.js +1 -0
- package/dist/legacy-juggler-bridge.js.map +1 -1
- package/dist/mixins/service.mixin.d.ts +75 -7
- package/dist/mixins/service.mixin.js +13 -8
- package/dist/mixins/service.mixin.js.map +1 -1
- package/package.json +12 -13
- package/src/mixins/service.mixin.ts +66 -13
- package/index.d.ts +0 -6
- package/index.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.2.1...@loopback/service-proxy@2.3.0) (2020-05-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **service-proxy:** refine service mixin ([a6d0e2a](https://github.com/strongloop/loopback-next/commit/a6d0e2a457751568faffc1e733dc15f2e7232d2c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.2.1](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.2.0...@loopback/service-proxy@2.2.1) (2020-05-19)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @loopback/service-proxy
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [2.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.1.2...@loopback/service-proxy@2.2.0) (2020-05-07)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **core:** allow options for artifact registration on an application ([f3fdc3b](https://github.com/strongloop/loopback-next/commit/f3fdc3b94e34610dd1bebb600a497c77a2794019))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [2.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.1.1...@loopback/service-proxy@2.1.2) (2020-04-29)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @loopback/service-proxy
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [2.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.1.0...@loopback/service-proxy@2.1.1) (2020-04-23)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package @loopback/service-proxy
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.serviceProxy = exports.ServiceProxyMetadata = exports.SERVICE_PROXY_KEY = void 0;
|
|
7
8
|
const context_1 = require("@loopback/context");
|
|
8
9
|
const __1 = require("..");
|
|
9
10
|
exports.SERVICE_PROXY_KEY = context_1.MetadataAccessor.create('service.proxy');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../src/decorators/service.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../src/decorators/service.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,+CAM2B;AAC3B,0BAAuC;AAO1B,QAAA,iBAAiB,GAAG,0BAAgB,CAAC,MAAM,CAGtD,eAAe,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAa,oBAAoB;IAK/B,YAAY,UAAuC;QAJnD,cAAS,GAAG,eAAe,CAAC;QAK1B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC;SAClC;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;SAC9B;IACH,CAAC;CACF;AAZD,oDAYC;AAED,SAAgB,YAAY,CAAC,UAAuC;IAClE,OAAO,UAAU,MAAc,EAAE,GAAW,EAAE,cAAuB;QACnE,IAAI,GAAG,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YAC7C,MAAM,IAAI,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;YAClD,gBAAM,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;SACxD;aAAM;YACL,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC;AAXD,oCAWC;AAED;;;;GAIG;AACH,KAAK,UAAU,OAAO,CAAC,GAAY,EAAE,SAAoB;IACvD,MAAM,IAAI,GAAG,SAAS,CAAC,QAAgC,CAAC;IACxD,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,cAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,IAAI,CAAC,cAAc,EAAE;QACvB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CACtB,cAAc,GAAG,IAAI,CAAC,cAAc,CACrC,CAAC;QACF,OAAO,cAAU,CAAC,EAAE,CAAC,CAAC;KACvB;IACD,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getService = exports.juggler = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const loopback_datasource_juggler_1 = tslib_1.__importDefault(require("loopback-datasource-juggler"));
|
|
9
10
|
var juggler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-juggler-bridge.js","sourceRoot":"","sources":["../src/legacy-juggler-bridge.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"legacy-juggler-bridge.js","sourceRoot":"","sources":["../src/legacy-juggler-bridge.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,sGAAiD;AAEjD,IAAiB,OAAO,CAGvB;AAHD,WAAiB,OAAO;IACtB,6DAA6D;IAC/C,kBAAU,GAAG,qCAAM,CAAC,UAAU,CAAC;AAC/C,CAAC,EAHgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAGvB;AAUD;;;;;;GAMG;AACI,KAAK,UAAU,UAAU,CAC9B,EAAqB;IAErB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACnB,8DAA8D;IAC9D,OAAO,EAAE,CAAC,gBAAuB,CAAC;AACpC,CAAC;AAND,gCAMC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Binding, Provider } from '@loopback/context';
|
|
2
|
-
import { Application } from '@loopback/core';
|
|
1
|
+
import { Binding, BindingFromClassOptions, Provider, Constructor } from '@loopback/context';
|
|
2
|
+
import { Application, MixinTarget, ServiceOptions, Component } from '@loopback/core';
|
|
3
|
+
import { BindingAddress, BindingFilter, JSONObject, Context, ContextSubscriptionManager, ContextEvent, Interceptor, InterceptorBindingOptions, ResolutionOptions, BindingKey, ValueOrPromise, ContextEventObserver, ContextObserver, Subscription, BindingComparator, ContextView, ResolutionSession, BindingCreationPolicy, ContextInspectOptions } from '@loopback/context';
|
|
4
|
+
import { Server, ApplicationConfig, ApplicationMetadata, LifeCycleObserver } from '@loopback/core';
|
|
3
5
|
/**
|
|
4
6
|
* Interface for classes with `new` operator.
|
|
5
7
|
*/
|
|
@@ -20,9 +22,8 @@ export interface Class<T> {
|
|
|
20
22
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
21
23
|
*
|
|
22
24
|
*/
|
|
23
|
-
export declare function ServiceMixin<T extends
|
|
25
|
+
export declare function ServiceMixin<T extends MixinTarget<Application>>(superClass: T): {
|
|
24
26
|
new (...args: any[]): {
|
|
25
|
-
[x: string]: any;
|
|
26
27
|
/**
|
|
27
28
|
* Add a service to this application.
|
|
28
29
|
*
|
|
@@ -50,7 +51,7 @@ export declare function ServiceMixin<T extends Class<any>>(superClass: T): {
|
|
|
50
51
|
* app.serviceProvider(GeocoderServiceProvider);
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
|
-
serviceProvider<S>(provider:
|
|
54
|
+
serviceProvider<S>(provider: Constructor<Provider<S>>, nameOrOptions?: string | ServiceOptions | undefined): Binding<S>;
|
|
54
55
|
/**
|
|
55
56
|
* Add a component to this application. Also mounts
|
|
56
57
|
* all the components services.
|
|
@@ -72,7 +73,7 @@ export declare function ServiceMixin<T extends Class<any>>(superClass: T): {
|
|
|
72
73
|
* app.component(ProductComponent);
|
|
73
74
|
* ```
|
|
74
75
|
*/
|
|
75
|
-
component(
|
|
76
|
+
component<T_1 extends Component = Component>(componentCtor: Constructor<T_1>, nameOrOptions?: string | BindingFromClassOptions | undefined): Binding<T_1>;
|
|
76
77
|
/**
|
|
77
78
|
* Get an instance of a component and mount all it's
|
|
78
79
|
* services. This function is intended to be used internally
|
|
@@ -80,7 +81,74 @@ export declare function ServiceMixin<T extends Class<any>>(superClass: T): {
|
|
|
80
81
|
*
|
|
81
82
|
* @param component - The component to mount services of
|
|
82
83
|
*/
|
|
83
|
-
mountComponentServices(component:
|
|
84
|
+
mountComponentServices<T_2 extends Component = Component>(component: Constructor<T_2>, componentBindingKey?: string | BindingKey<T_2> | undefined): void;
|
|
85
|
+
readonly options: ApplicationConfig;
|
|
86
|
+
readonly state: string;
|
|
87
|
+
controller: <T_3>(controllerCtor: Constructor<T_3>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_3>;
|
|
88
|
+
server: <T_4 extends Server>(ctor: Constructor<T_4>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_4>;
|
|
89
|
+
servers: <T_5 extends Server>(ctors: Constructor<T_5>[]) => Binding<any>[];
|
|
90
|
+
getServer: <T_6 extends Server>(target: string | Constructor<T_6>) => Promise<T_6>;
|
|
91
|
+
start: () => Promise<void>;
|
|
92
|
+
stop: () => Promise<void>;
|
|
93
|
+
setMetadata: (metadata: ApplicationMetadata) => void;
|
|
94
|
+
lifeCycleObserver: <T_7 extends LifeCycleObserver>(ctor: Constructor<T_7>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_7>;
|
|
95
|
+
service: <S_2>(cls: Constructor<S_2 | Provider<S_2>>, nameOrOptions?: string | ServiceOptions | undefined) => Binding<S_2>;
|
|
96
|
+
interceptor: (interceptor: Interceptor | Constructor<Provider<Interceptor>>, nameOrOptions?: string | InterceptorBindingOptions | undefined) => Binding<Interceptor>;
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly subscriptionManager: ContextSubscriptionManager;
|
|
99
|
+
readonly parent: Context | undefined;
|
|
100
|
+
emitEvent: <T_8 extends ContextEvent>(type: string, event: T_8) => void;
|
|
101
|
+
emitError: (err: unknown) => void;
|
|
102
|
+
bind: <ValueType = any>(key: BindingAddress<ValueType>) => Binding<ValueType>;
|
|
103
|
+
add: (binding: Binding<unknown>) => Application;
|
|
104
|
+
configure: <ConfigValueType = any>(key?: string | BindingKey<unknown> | undefined) => Binding<ConfigValueType>;
|
|
105
|
+
getConfigAsValueOrPromise: <ConfigValueType_1>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => ValueOrPromise<ConfigValueType_1 | undefined>;
|
|
106
|
+
getConfig: <ConfigValueType_2>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
|
|
107
|
+
getConfigSync: <ConfigValueType_3>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
|
|
108
|
+
unbind: (key: BindingAddress<unknown>) => boolean;
|
|
109
|
+
subscribe: (observer: ContextEventObserver) => Subscription;
|
|
110
|
+
unsubscribe: (observer: ContextEventObserver) => boolean;
|
|
111
|
+
close: () => void;
|
|
112
|
+
isSubscribed: (observer: ContextObserver) => boolean;
|
|
113
|
+
createView: <T_9 = unknown>(filter: BindingFilter, comparator?: BindingComparator | undefined) => ContextView<T_9>;
|
|
114
|
+
contains: (key: BindingAddress<unknown>) => boolean;
|
|
115
|
+
isBound: (key: BindingAddress<unknown>) => boolean;
|
|
116
|
+
getOwnerContext: (key: BindingAddress<unknown>) => Context | undefined;
|
|
117
|
+
find: <ValueType_1 = any>(pattern?: string | RegExp | BindingFilter | undefined) => Readonly<Binding<ValueType_1>>[];
|
|
118
|
+
findByTag: <ValueType_2 = any>(tagFilter: string | RegExp | Record<string, any>) => Readonly<Binding<ValueType_2>>[];
|
|
119
|
+
get: {
|
|
120
|
+
<ValueType_3>(keyWithPath: BindingAddress<ValueType_3>, session?: ResolutionSession | undefined): Promise<ValueType_3>;
|
|
121
|
+
<ValueType_4>(keyWithPath: BindingAddress<ValueType_4>, options: ResolutionOptions): Promise<ValueType_4 | undefined>;
|
|
122
|
+
};
|
|
123
|
+
getSync: {
|
|
124
|
+
<ValueType_5>(keyWithPath: BindingAddress<ValueType_5>, session?: ResolutionSession | undefined): ValueType_5;
|
|
125
|
+
<ValueType_6>(keyWithPath: BindingAddress<ValueType_6>, options?: ResolutionOptions | undefined): ValueType_6 | undefined;
|
|
126
|
+
};
|
|
127
|
+
getBinding: {
|
|
128
|
+
<ValueType_7 = any>(key: BindingAddress<ValueType_7>): Binding<ValueType_7>;
|
|
129
|
+
<ValueType_8>(key: BindingAddress<ValueType_8>, options?: {
|
|
130
|
+
optional?: boolean | undefined;
|
|
131
|
+
} | undefined): Binding<ValueType_8> | undefined;
|
|
132
|
+
};
|
|
133
|
+
findOrCreateBinding: <T_10>(key: BindingAddress<T_10>, policy?: BindingCreationPolicy | undefined) => Binding<T_10>;
|
|
134
|
+
getValueOrPromise: <ValueType_9>(keyWithPath: BindingAddress<ValueType_9>, optionsOrSession?: ResolutionOptions | ResolutionSession | undefined) => ValueOrPromise<ValueType_9 | undefined>;
|
|
135
|
+
toJSON: () => JSONObject;
|
|
136
|
+
inspect: (options?: ContextInspectOptions | undefined) => JSONObject;
|
|
137
|
+
addListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
138
|
+
on: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
139
|
+
once: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
140
|
+
prependListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
141
|
+
prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
142
|
+
removeListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
143
|
+
off: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
144
|
+
removeAllListeners: (event?: string | symbol | undefined) => Application;
|
|
145
|
+
setMaxListeners: (n: number) => Application;
|
|
146
|
+
getMaxListeners: () => number;
|
|
147
|
+
listeners: (event: string | symbol) => Function[];
|
|
148
|
+
rawListeners: (event: string | symbol) => Function[];
|
|
149
|
+
emit: (event: string | symbol, ...args: any[]) => boolean;
|
|
150
|
+
eventNames: () => (string | symbol)[];
|
|
151
|
+
listenerCount: (type: string | symbol) => number;
|
|
84
152
|
};
|
|
85
153
|
} & T;
|
|
86
154
|
/**
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ServiceMixinDoc = exports.ServiceMixin = void 0;
|
|
7
8
|
/**
|
|
8
9
|
* A mixin class for Application that creates a .serviceProvider()
|
|
9
10
|
* function to register a service automatically. Also overrides
|
|
@@ -18,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
19
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
19
20
|
*
|
|
20
21
|
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
function ServiceMixin(superClass) {
|
|
23
23
|
return class extends superClass {
|
|
24
24
|
/**
|
|
@@ -48,8 +48,8 @@ function ServiceMixin(superClass) {
|
|
|
48
48
|
* app.serviceProvider(GeocoderServiceProvider);
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
serviceProvider(provider,
|
|
52
|
-
return this.service(provider,
|
|
51
|
+
serviceProvider(provider, nameOrOptions) {
|
|
52
|
+
return this.service(provider, nameOrOptions);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Add a component to this application. Also mounts
|
|
@@ -72,9 +72,14 @@ function ServiceMixin(superClass) {
|
|
|
72
72
|
* app.component(ProductComponent);
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
76
|
+
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
component(componentCtor, nameOrOptions) {
|
|
80
|
+
const binding = super.component(componentCtor, nameOrOptions);
|
|
81
|
+
this.mountComponentServices(componentCtor, binding.key);
|
|
82
|
+
return binding;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* Get an instance of a component and mount all it's
|
|
@@ -83,8 +88,8 @@ function ServiceMixin(superClass) {
|
|
|
83
88
|
*
|
|
84
89
|
* @param component - The component to mount services of
|
|
85
90
|
*/
|
|
86
|
-
mountComponentServices(component) {
|
|
87
|
-
const componentKey = `components.${component.name}`;
|
|
91
|
+
mountComponentServices(component, componentBindingKey) {
|
|
92
|
+
const componentKey = componentBindingKey !== null && componentBindingKey !== void 0 ? componentBindingKey : `components.${component.name}`;
|
|
88
93
|
const compInstance = this.getSync(componentKey);
|
|
89
94
|
if (compInstance.serviceProviders) {
|
|
90
95
|
for (const provider of compInstance.serviceProviders) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.mixin.js","sourceRoot":"","sources":["../../src/mixins/service.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"service.mixin.js","sourceRoot":"","sources":["../../src/mixins/service.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAsDhE;;;;;;;;;;;;;GAaG;AACH,SAAgB,YAAY,CAC1B,UAAa;IAEb,OAAO,KAAM,SAAQ,UAAU;QAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,eAAe,CACb,QAAkC,EAClC,aAAuC;YAEvC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC/C,CAAC;QAED;;;;;;;;;;;;;;;;;;;;WAoBG;QACH,wEAAwE;QACxE,0EAA0E;QAC1E,4DAA4D;QAC5D,aAAa;QACb,SAAS,CACP,aAA6B,EAC7B,aAAgD;YAEhD,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAC9D,IAAI,CAAC,sBAAsB,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC;QACjB,CAAC;QAED;;;;;;WAMG;QACH,sBAAsB,CACpB,SAAyB,EACzB,mBAAuC;YAEvC,MAAM,YAAY,GAChB,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,cAAc,SAAS,CAAC,IAAI,EAAE,CAAC;YACxD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAY,YAAY,CAAC,CAAC;YAE3D,IAAI,YAAY,CAAC,gBAAgB,EAAE;gBACjC,KAAK,MAAM,QAAQ,IAAI,YAAY,CAAC,gBAAgB,EAAE;oBACpD,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;iBAChC;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA9FD,oCA8FC;AAWD;;;;;;GAMG;AACH,MAAa,eAAe;IAC1B,8DAA8D;IAC9D,YAAY,GAAG,IAAW;QACxB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CAAI,QAA4B;QAC7C,MAAM,IAAI,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,SAAS,CAAC,SAAyB;QACxC,MAAM,IAAI,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,SAAyB,IAAG,CAAC;CACrD;AAtED,0CAsEC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/service-proxy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Service integration for LoopBack 4",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
5
7
|
"engines": {
|
|
6
8
|
"node": ">=10"
|
|
7
9
|
},
|
|
8
|
-
"main": "index",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
|
|
11
12
|
"build": "lb-tsc",
|
|
@@ -23,21 +24,19 @@
|
|
|
23
24
|
"copyright.owner": "IBM Corp.",
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@loopback/build": "^5.
|
|
27
|
-
"@loopback/eslint-config": "^
|
|
28
|
-
"@loopback/testlab": "^3.1.
|
|
29
|
-
"@types/node": "^10.17.
|
|
27
|
+
"@loopback/build": "^5.4.1",
|
|
28
|
+
"@loopback/eslint-config": "^7.0.1",
|
|
29
|
+
"@loopback/testlab": "^3.1.5",
|
|
30
|
+
"@types/node": "^10.17.24"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@loopback/context": "^3.
|
|
33
|
-
"@loopback/core": "^2.
|
|
34
|
-
"loopback-datasource-juggler": "^4.
|
|
35
|
-
"tslib": "^
|
|
33
|
+
"@loopback/context": "^3.8.1",
|
|
34
|
+
"@loopback/core": "^2.7.0",
|
|
35
|
+
"loopback-datasource-juggler": "^4.21.2",
|
|
36
|
+
"tslib": "^2.0.0"
|
|
36
37
|
},
|
|
37
38
|
"files": [
|
|
38
39
|
"README.md",
|
|
39
|
-
"index.js",
|
|
40
|
-
"index.d.ts",
|
|
41
40
|
"dist",
|
|
42
41
|
"src",
|
|
43
42
|
"!*/__tests__"
|
|
@@ -47,5 +46,5 @@
|
|
|
47
46
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
48
47
|
"directory": "packages/service-proxy"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "62aea854bf85c5a5995b59e6908fe5409f7eea96"
|
|
51
50
|
}
|
|
@@ -3,8 +3,48 @@
|
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
Binding,
|
|
8
|
+
BindingFromClassOptions,
|
|
9
|
+
Provider,
|
|
10
|
+
Constructor,
|
|
11
|
+
} from '@loopback/context';
|
|
12
|
+
import {
|
|
13
|
+
Application,
|
|
14
|
+
MixinTarget,
|
|
15
|
+
ServiceOptions,
|
|
16
|
+
Component,
|
|
17
|
+
} from '@loopback/core';
|
|
18
|
+
|
|
19
|
+
// FIXME(rfeng): Workaround for https://github.com/microsoft/rushstack/pull/1867
|
|
20
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
21
|
+
import {
|
|
22
|
+
BindingAddress,
|
|
23
|
+
BindingFilter,
|
|
24
|
+
JSONObject,
|
|
25
|
+
Context,
|
|
26
|
+
ContextSubscriptionManager,
|
|
27
|
+
ContextEvent,
|
|
28
|
+
Interceptor,
|
|
29
|
+
InterceptorBindingOptions,
|
|
30
|
+
ResolutionOptions,
|
|
31
|
+
BindingKey,
|
|
32
|
+
ValueOrPromise,
|
|
33
|
+
ContextEventObserver,
|
|
34
|
+
ContextObserver,
|
|
35
|
+
Subscription,
|
|
36
|
+
BindingComparator,
|
|
37
|
+
ContextView,
|
|
38
|
+
ResolutionSession,
|
|
39
|
+
BindingCreationPolicy,
|
|
40
|
+
ContextInspectOptions,
|
|
41
|
+
} from '@loopback/context';
|
|
42
|
+
import {
|
|
43
|
+
Server,
|
|
44
|
+
ApplicationConfig,
|
|
45
|
+
ApplicationMetadata,
|
|
46
|
+
LifeCycleObserver,
|
|
47
|
+
} from '@loopback/core';
|
|
8
48
|
|
|
9
49
|
/**
|
|
10
50
|
* Interface for classes with `new` operator.
|
|
@@ -29,8 +69,9 @@ export interface Class<T> {
|
|
|
29
69
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
30
70
|
*
|
|
31
71
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
72
|
+
export function ServiceMixin<T extends MixinTarget<Application>>(
|
|
73
|
+
superClass: T,
|
|
74
|
+
) {
|
|
34
75
|
return class extends superClass {
|
|
35
76
|
/**
|
|
36
77
|
* Add a service to this application.
|
|
@@ -60,10 +101,10 @@ export function ServiceMixin<T extends Class<any>>(superClass: T) {
|
|
|
60
101
|
* ```
|
|
61
102
|
*/
|
|
62
103
|
serviceProvider<S>(
|
|
63
|
-
provider:
|
|
64
|
-
|
|
104
|
+
provider: Constructor<Provider<S>>,
|
|
105
|
+
nameOrOptions?: string | ServiceOptions,
|
|
65
106
|
): Binding<S> {
|
|
66
|
-
return this.service(provider,
|
|
107
|
+
return this.service(provider, nameOrOptions);
|
|
67
108
|
}
|
|
68
109
|
|
|
69
110
|
/**
|
|
@@ -87,9 +128,17 @@ export function ServiceMixin<T extends Class<any>>(superClass: T) {
|
|
|
87
128
|
* app.component(ProductComponent);
|
|
88
129
|
* ```
|
|
89
130
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
131
|
+
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
132
|
+
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
component<T extends Component = Component>(
|
|
136
|
+
componentCtor: Constructor<T>,
|
|
137
|
+
nameOrOptions?: string | BindingFromClassOptions,
|
|
138
|
+
) {
|
|
139
|
+
const binding = super.component(componentCtor, nameOrOptions);
|
|
140
|
+
this.mountComponentServices(componentCtor, binding.key);
|
|
141
|
+
return binding;
|
|
93
142
|
}
|
|
94
143
|
|
|
95
144
|
/**
|
|
@@ -99,9 +148,13 @@ export function ServiceMixin<T extends Class<any>>(superClass: T) {
|
|
|
99
148
|
*
|
|
100
149
|
* @param component - The component to mount services of
|
|
101
150
|
*/
|
|
102
|
-
mountComponentServices
|
|
103
|
-
|
|
104
|
-
|
|
151
|
+
mountComponentServices<T extends Component = Component>(
|
|
152
|
+
component: Constructor<T>,
|
|
153
|
+
componentBindingKey?: BindingAddress<T>,
|
|
154
|
+
) {
|
|
155
|
+
const componentKey =
|
|
156
|
+
componentBindingKey ?? `components.${component.name}`;
|
|
157
|
+
const compInstance = this.getSync<Component>(componentKey);
|
|
105
158
|
|
|
106
159
|
if (compInstance.serviceProviders) {
|
|
107
160
|
for (const provider of compInstance.serviceProviders) {
|
package/index.d.ts
DELETED
package/index.js
DELETED