@loopback/service-proxy 2.3.0 → 2.3.4
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 +35 -0
- package/dist/decorators/service.decorator.d.ts +1 -1
- package/dist/decorators/service.decorator.js +3 -3
- package/dist/decorators/service.decorator.js.map +1 -1
- package/dist/mixins/service.mixin.d.ts +50 -40
- package/dist/mixins/service.mixin.js +7 -2
- package/dist/mixins/service.mixin.js.map +1 -1
- package/package.json +12 -13
- package/src/decorators/service.decorator.ts +1 -1
- package/src/mixins/service.mixin.ts +21 -36
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
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.4](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.3.3...@loopback/service-proxy@2.3.4) (2020-06-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/service-proxy
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.3.3](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.3.2...@loopback/service-proxy@2.3.3) (2020-06-23)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* set node version to >=10.16 to support events.once ([e39da1c](https://github.com/strongloop/loopback-next/commit/e39da1ca47728eafaf83c10ce35b09b03b6a4edc))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [2.3.2](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.3.1...@loopback/service-proxy@2.3.2) (2020-06-11)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @loopback/service-proxy
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [2.3.1](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@2.3.0...@loopback/service-proxy@2.3.1) (2020-05-28)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @loopback/service-proxy
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
# [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
42
|
|
|
8
43
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.serviceProxy = exports.ServiceProxyMetadata = exports.SERVICE_PROXY_KEY = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
9
|
const __1 = require("..");
|
|
10
|
-
exports.SERVICE_PROXY_KEY =
|
|
10
|
+
exports.SERVICE_PROXY_KEY = core_1.MetadataAccessor.create('service.proxy');
|
|
11
11
|
/**
|
|
12
12
|
* Metadata for a service proxy
|
|
13
13
|
*/
|
|
@@ -27,7 +27,7 @@ function serviceProxy(dataSource) {
|
|
|
27
27
|
return function (target, key, parameterIndex) {
|
|
28
28
|
if (key || typeof parameterIndex === 'number') {
|
|
29
29
|
const meta = new ServiceProxyMetadata(dataSource);
|
|
30
|
-
|
|
30
|
+
core_1.inject('', meta, resolve)(target, key, parameterIndex);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
throw new Error('@serviceProxy can only be applied to properties or method parameters');
|
|
@@ -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;;;AAEhE
|
|
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,yCAMwB;AACxB,0BAAuC;AAO1B,QAAA,iBAAiB,GAAG,uBAAgB,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,aAAM,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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Binding, BindingFromClassOptions, Provider, Constructor } from '@loopback/
|
|
1
|
+
import { Binding, BindingAddress, BindingFromClassOptions, Provider, Constructor } from '@loopback/core';
|
|
2
2
|
import { Application, MixinTarget, ServiceOptions, Component } from '@loopback/core';
|
|
3
|
-
import
|
|
4
|
-
import { Server, ApplicationConfig, ApplicationMetadata, LifeCycleObserver } from '@loopback/core';
|
|
3
|
+
import * as loopbackContext from '@loopback/core';
|
|
5
4
|
/**
|
|
6
5
|
* Interface for classes with `new` operator.
|
|
7
6
|
*/
|
|
@@ -21,6 +20,11 @@ export interface Class<T> {
|
|
|
21
20
|
* Please note: the members in the mixin function are documented in a dummy class
|
|
22
21
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
23
22
|
*
|
|
23
|
+
* @param superClass - Application class
|
|
24
|
+
* @returns A new class that extends the super class with service proxy related
|
|
25
|
+
* methods
|
|
26
|
+
*
|
|
27
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
24
28
|
*/
|
|
25
29
|
export declare function ServiceMixin<T extends MixinTarget<Application>>(superClass: T): {
|
|
26
30
|
new (...args: any[]): {
|
|
@@ -81,48 +85,48 @@ export declare function ServiceMixin<T extends MixinTarget<Application>>(superCl
|
|
|
81
85
|
*
|
|
82
86
|
* @param component - The component to mount services of
|
|
83
87
|
*/
|
|
84
|
-
mountComponentServices<T_2 extends Component = Component>(component: Constructor<T_2>, componentBindingKey?: string | BindingKey<T_2> | undefined): void;
|
|
85
|
-
readonly options: ApplicationConfig;
|
|
88
|
+
mountComponentServices<T_2 extends Component = Component>(component: Constructor<T_2>, componentBindingKey?: string | loopbackContext.BindingKey<T_2> | undefined): void;
|
|
89
|
+
readonly options: loopbackContext.ApplicationConfig;
|
|
86
90
|
readonly state: string;
|
|
87
91
|
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>;
|
|
92
|
+
server: <T_4 extends loopbackContext.Server>(ctor: Constructor<T_4>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_4>;
|
|
93
|
+
servers: <T_5 extends loopbackContext.Server>(ctors: Constructor<T_5>[]) => Binding<any>[];
|
|
94
|
+
getServer: <T_6 extends loopbackContext.Server>(target: string | Constructor<T_6>) => Promise<T_6>;
|
|
91
95
|
start: () => Promise<void>;
|
|
92
96
|
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>;
|
|
97
|
+
setMetadata: (metadata: loopbackContext.ApplicationMetadata) => void;
|
|
98
|
+
lifeCycleObserver: <T_7 extends loopbackContext.LifeCycleObserver>(ctor: Constructor<T_7>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_7>;
|
|
95
99
|
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>;
|
|
100
|
+
interceptor: (interceptor: loopbackContext.Interceptor | Constructor<Provider<loopbackContext.Interceptor>>, nameOrOptions?: string | loopbackContext.InterceptorBindingOptions | undefined) => Binding<loopbackContext.Interceptor>;
|
|
97
101
|
readonly name: string;
|
|
98
|
-
readonly subscriptionManager: ContextSubscriptionManager;
|
|
99
|
-
readonly parent: Context | undefined;
|
|
100
|
-
emitEvent: <T_8 extends ContextEvent>(type: string, event: T_8) => void;
|
|
102
|
+
readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
|
|
103
|
+
readonly parent: loopbackContext.Context | undefined;
|
|
104
|
+
emitEvent: <T_8 extends loopbackContext.ContextEvent>(type: string, event: T_8) => void;
|
|
101
105
|
emitError: (err: unknown) => void;
|
|
102
106
|
bind: <ValueType = any>(key: BindingAddress<ValueType>) => Binding<ValueType>;
|
|
103
107
|
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
|
+
configure: <ConfigValueType = any>(key?: string | loopbackContext.BindingKey<unknown> | undefined) => Binding<ConfigValueType>;
|
|
109
|
+
getConfigAsValueOrPromise: <ConfigValueType_1>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => loopbackContext.ValueOrPromise<ConfigValueType_1 | undefined>;
|
|
110
|
+
getConfig: <ConfigValueType_2>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
|
|
111
|
+
getConfigSync: <ConfigValueType_3>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
|
|
108
112
|
unbind: (key: BindingAddress<unknown>) => boolean;
|
|
109
|
-
subscribe: (observer: ContextEventObserver) => Subscription;
|
|
110
|
-
unsubscribe: (observer: ContextEventObserver) => boolean;
|
|
113
|
+
subscribe: (observer: loopbackContext.ContextEventObserver) => loopbackContext.Subscription;
|
|
114
|
+
unsubscribe: (observer: loopbackContext.ContextEventObserver) => boolean;
|
|
111
115
|
close: () => void;
|
|
112
|
-
isSubscribed: (observer: ContextObserver) => boolean;
|
|
113
|
-
createView: <T_9 = unknown>(filter: BindingFilter, comparator?: BindingComparator | undefined) => ContextView<T_9>;
|
|
116
|
+
isSubscribed: (observer: loopbackContext.ContextObserver) => boolean;
|
|
117
|
+
createView: <T_9 = unknown>(filter: loopbackContext.BindingFilter, comparator?: loopbackContext.BindingComparator | undefined) => loopbackContext.ContextView<T_9>;
|
|
114
118
|
contains: (key: BindingAddress<unknown>) => boolean;
|
|
115
119
|
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>>[];
|
|
120
|
+
getOwnerContext: (key: BindingAddress<unknown>) => loopbackContext.Context | undefined;
|
|
121
|
+
find: <ValueType_1 = any>(pattern?: string | RegExp | loopbackContext.BindingFilter | undefined) => Readonly<Binding<ValueType_1>>[];
|
|
118
122
|
findByTag: <ValueType_2 = any>(tagFilter: string | RegExp | Record<string, any>) => Readonly<Binding<ValueType_2>>[];
|
|
119
123
|
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>;
|
|
124
|
+
<ValueType_3>(keyWithPath: BindingAddress<ValueType_3>, session?: loopbackContext.ResolutionSession | undefined): Promise<ValueType_3>;
|
|
125
|
+
<ValueType_4>(keyWithPath: BindingAddress<ValueType_4>, options: loopbackContext.ResolutionOptions): Promise<ValueType_4 | undefined>;
|
|
122
126
|
};
|
|
123
127
|
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;
|
|
128
|
+
<ValueType_5>(keyWithPath: BindingAddress<ValueType_5>, session?: loopbackContext.ResolutionSession | undefined): ValueType_5;
|
|
129
|
+
<ValueType_6>(keyWithPath: BindingAddress<ValueType_6>, options?: loopbackContext.ResolutionOptions | undefined): ValueType_6 | undefined;
|
|
126
130
|
};
|
|
127
131
|
getBinding: {
|
|
128
132
|
<ValueType_7 = any>(key: BindingAddress<ValueType_7>): Binding<ValueType_7>;
|
|
@@ -130,13 +134,19 @@ export declare function ServiceMixin<T extends MixinTarget<Application>>(superCl
|
|
|
130
134
|
optional?: boolean | undefined;
|
|
131
135
|
} | undefined): Binding<ValueType_8> | undefined;
|
|
132
136
|
};
|
|
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
|
+
findOrCreateBinding: <T_10>(key: BindingAddress<T_10>, policy?: loopbackContext.BindingCreationPolicy | undefined) => Binding<T_10>;
|
|
138
|
+
getValueOrPromise: <ValueType_9>(keyWithPath: BindingAddress<ValueType_9>, optionsOrSession?: loopbackContext.ResolutionOptions | loopbackContext.ResolutionSession | undefined) => loopbackContext.ValueOrPromise<ValueType_9 | undefined>;
|
|
139
|
+
toJSON: () => loopbackContext.JSONObject;
|
|
140
|
+
inspect: (options?: loopbackContext.ContextInspectOptions | undefined) => loopbackContext.JSONObject;
|
|
141
|
+
on: {
|
|
142
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
143
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
144
|
+
};
|
|
145
|
+
once: {
|
|
146
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
147
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
148
|
+
};
|
|
137
149
|
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
150
|
prependListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
141
151
|
prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
142
152
|
removeListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
@@ -155,9 +165,9 @@ export declare function ServiceMixin<T extends MixinTarget<Application>>(superCl
|
|
|
155
165
|
* Interface for an Application mixed in with ServiceMixin
|
|
156
166
|
*/
|
|
157
167
|
export interface ApplicationWithServices extends Application {
|
|
158
|
-
serviceProvider<S>(provider:
|
|
159
|
-
component(component:
|
|
160
|
-
mountComponentServices(component:
|
|
168
|
+
serviceProvider<S>(provider: Constructor<Provider<S>>, name?: string): Binding<S>;
|
|
169
|
+
component(component: Constructor<{}>, name?: string): Binding;
|
|
170
|
+
mountComponentServices(component: Constructor<{}>): void;
|
|
161
171
|
}
|
|
162
172
|
/**
|
|
163
173
|
* A dummy class created to generate the tsdoc for the members in service
|
|
@@ -193,7 +203,7 @@ export declare class ServiceMixinDoc {
|
|
|
193
203
|
* app.serviceProvider(GeocoderServiceProvider);
|
|
194
204
|
* ```
|
|
195
205
|
*/
|
|
196
|
-
serviceProvider<S>(provider:
|
|
206
|
+
serviceProvider<S>(provider: Constructor<Provider<S>>): Binding<S>;
|
|
197
207
|
/**
|
|
198
208
|
* Add a component to this application. Also mounts
|
|
199
209
|
* all the components services.
|
|
@@ -215,7 +225,7 @@ export declare class ServiceMixinDoc {
|
|
|
215
225
|
* app.component(ProductComponent);
|
|
216
226
|
* ```
|
|
217
227
|
*/
|
|
218
|
-
component(component:
|
|
228
|
+
component(component: Constructor<unknown>): Binding;
|
|
219
229
|
/**
|
|
220
230
|
* Get an instance of a component and mount all it's
|
|
221
231
|
* services. This function is intended to be used internally
|
|
@@ -223,5 +233,5 @@ export declare class ServiceMixinDoc {
|
|
|
223
233
|
*
|
|
224
234
|
* @param component - The component to mount services of
|
|
225
235
|
*/
|
|
226
|
-
mountComponentServices(component:
|
|
236
|
+
mountComponentServices(component: Constructor<unknown>): void;
|
|
227
237
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2018,
|
|
2
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
3
3
|
// Node module: @loopback/service-proxy
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -18,6 +18,11 @@ exports.ServiceMixinDoc = exports.ServiceMixin = void 0;
|
|
|
18
18
|
* Please note: the members in the mixin function are documented in a dummy class
|
|
19
19
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
20
20
|
*
|
|
21
|
+
* @param superClass - Application class
|
|
22
|
+
* @returns A new class that extends the super class with service proxy related
|
|
23
|
+
* methods
|
|
24
|
+
*
|
|
25
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
21
26
|
*/
|
|
22
27
|
function ServiceMixin(superClass) {
|
|
23
28
|
return class extends superClass {
|
|
@@ -74,7 +79,7 @@ function ServiceMixin(superClass) {
|
|
|
74
79
|
*/
|
|
75
80
|
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
76
81
|
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
83
|
// @ts-ignore
|
|
79
84
|
component(componentCtor, nameOrOptions) {
|
|
80
85
|
const binding = super.component(componentCtor, nameOrOptions);
|
|
@@ -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;;;AA+BhE;;;;;;;;;;;;;;;;;;GAkBG;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,6DAA6D;QAC7D,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;AAcD;;;;;;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,QAAkC;QACnD,MAAM,IAAI,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,SAAS,CAAC,SAA+B;QAC9C,MAAM,IAAI,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,SAA+B,IAAG,CAAC;CAC3D;AAtED,0CAsEC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/service-proxy",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.4",
|
|
4
|
+
"description": "A common set of interfaces for interacting with service oriented backends such as REST APIs, SOAP Web Services, and gRPC microservices",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=10"
|
|
8
|
+
"node": ">=10.16"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
|
|
@@ -17,21 +17,20 @@
|
|
|
17
17
|
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
|
|
18
18
|
"verify": "npm pack && tar xf loopback-service-proxy*.tgz && tree package && npm run clean"
|
|
19
19
|
},
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
20
|
"author": "IBM Corp.",
|
|
24
21
|
"copyright.owner": "IBM Corp.",
|
|
25
22
|
"license": "MIT",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@loopback/build": "^
|
|
28
|
-
"@loopback/eslint-config": "^
|
|
29
|
-
"@loopback/testlab": "^3.
|
|
30
|
-
"@types/node": "^10.17.
|
|
27
|
+
"@loopback/build": "^6.1.0",
|
|
28
|
+
"@loopback/eslint-config": "^8.0.3",
|
|
29
|
+
"@loopback/testlab": "^3.2.0",
|
|
30
|
+
"@types/node": "^10.17.26"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@loopback/
|
|
34
|
-
"@loopback/core": "^2.7.0",
|
|
33
|
+
"@loopback/core": "^2.9.1",
|
|
35
34
|
"loopback-datasource-juggler": "^4.21.2",
|
|
36
35
|
"tslib": "^2.0.0"
|
|
37
36
|
},
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
47
46
|
"directory": "packages/service-proxy"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b89db3d3b8be6a36e63e91c2331d217fda7538de"
|
|
50
49
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,
|
|
1
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/service-proxy
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
Binding,
|
|
8
|
+
BindingAddress,
|
|
8
9
|
BindingFromClassOptions,
|
|
9
10
|
Provider,
|
|
10
11
|
Constructor,
|
|
11
|
-
} from '@loopback/
|
|
12
|
+
} from '@loopback/core';
|
|
12
13
|
import {
|
|
13
14
|
Application,
|
|
14
15
|
MixinTarget,
|
|
@@ -18,33 +19,9 @@ import {
|
|
|
18
19
|
|
|
19
20
|
// FIXME(rfeng): Workaround for https://github.com/microsoft/rushstack/pull/1867
|
|
20
21
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
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';
|
|
22
|
+
import * as loopbackContext from '@loopback/core';
|
|
23
|
+
import * as loopbackCore from '@loopback/core';
|
|
24
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
48
25
|
|
|
49
26
|
/**
|
|
50
27
|
* Interface for classes with `new` operator.
|
|
@@ -68,6 +45,11 @@ export interface Class<T> {
|
|
|
68
45
|
* Please note: the members in the mixin function are documented in a dummy class
|
|
69
46
|
* called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>
|
|
70
47
|
*
|
|
48
|
+
* @param superClass - Application class
|
|
49
|
+
* @returns A new class that extends the super class with service proxy related
|
|
50
|
+
* methods
|
|
51
|
+
*
|
|
52
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
71
53
|
*/
|
|
72
54
|
export function ServiceMixin<T extends MixinTarget<Application>>(
|
|
73
55
|
superClass: T,
|
|
@@ -130,7 +112,7 @@ export function ServiceMixin<T extends MixinTarget<Application>>(
|
|
|
130
112
|
*/
|
|
131
113
|
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
132
114
|
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
134
116
|
// @ts-ignore
|
|
135
117
|
component<T extends Component = Component>(
|
|
136
118
|
componentCtor: Constructor<T>,
|
|
@@ -169,9 +151,12 @@ export function ServiceMixin<T extends MixinTarget<Application>>(
|
|
|
169
151
|
* Interface for an Application mixed in with ServiceMixin
|
|
170
152
|
*/
|
|
171
153
|
export interface ApplicationWithServices extends Application {
|
|
172
|
-
serviceProvider<S>(
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
serviceProvider<S>(
|
|
155
|
+
provider: Constructor<Provider<S>>,
|
|
156
|
+
name?: string,
|
|
157
|
+
): Binding<S>;
|
|
158
|
+
component(component: Constructor<{}>, name?: string): Binding;
|
|
159
|
+
mountComponentServices(component: Constructor<{}>): void;
|
|
175
160
|
}
|
|
176
161
|
|
|
177
162
|
/**
|
|
@@ -214,7 +199,7 @@ export class ServiceMixinDoc {
|
|
|
214
199
|
* app.serviceProvider(GeocoderServiceProvider);
|
|
215
200
|
* ```
|
|
216
201
|
*/
|
|
217
|
-
serviceProvider<S>(provider:
|
|
202
|
+
serviceProvider<S>(provider: Constructor<Provider<S>>): Binding<S> {
|
|
218
203
|
throw new Error();
|
|
219
204
|
}
|
|
220
205
|
|
|
@@ -239,7 +224,7 @@ export class ServiceMixinDoc {
|
|
|
239
224
|
* app.component(ProductComponent);
|
|
240
225
|
* ```
|
|
241
226
|
*/
|
|
242
|
-
public component(component:
|
|
227
|
+
public component(component: Constructor<unknown>): Binding {
|
|
243
228
|
throw new Error();
|
|
244
229
|
}
|
|
245
230
|
|
|
@@ -250,5 +235,5 @@ export class ServiceMixinDoc {
|
|
|
250
235
|
*
|
|
251
236
|
* @param component - The component to mount services of
|
|
252
237
|
*/
|
|
253
|
-
mountComponentServices(component:
|
|
238
|
+
mountComponentServices(component: Constructor<unknown>) {}
|
|
254
239
|
}
|