@equinor/fusion-framework-module-signalr 13.0.0 → 13.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.
- package/CHANGELOG.md +8 -0
- package/dist/esm/{SignalRModuleConfigurator.js → SignalRConfigurator.js} +3 -23
- package/dist/esm/SignalRConfigurator.js.map +1 -0
- package/dist/esm/SignalRModule.js +3 -1
- package/dist/esm/SignalRModule.js.map +1 -1
- package/dist/esm/SignalRModuleConfigBuilder.js +23 -0
- package/dist/esm/SignalRModuleConfigBuilder.js.map +1 -0
- package/dist/esm/SignalRModuleProvider.js +6 -1
- package/dist/esm/SignalRModuleProvider.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/Topic.js +2 -2
- package/dist/esm/lib/Topic.js.map +1 -1
- package/dist/esm/lib/utils/configure-from-framework.js +2 -0
- package/dist/esm/lib/utils/configure-from-framework.js.map +1 -1
- package/dist/esm/lib/utils/enable-signalr.js +2 -1
- package/dist/esm/lib/utils/enable-signalr.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/SignalRConfigurator.d.ts +37 -0
- package/dist/types/SignalRModule.d.ts +1 -1
- package/dist/types/{SignalRModuleConfigurator.d.ts → SignalRModuleConfigBuilder.d.ts} +1 -35
- package/dist/types/SignalRModuleProvider.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/lib/Topic.d.ts +2 -2
- package/dist/types/lib/utils/enable-signalr.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -8
- package/src/SignalRConfigurator.ts +66 -0
- package/src/SignalRModule.ts +4 -1
- package/src/{SignalRModuleConfigurator.ts → SignalRModuleConfigBuilder.ts} +2 -61
- package/src/SignalRModuleProvider.ts +14 -9
- package/src/index.ts +3 -2
- package/src/lib/Topic.ts +4 -4
- package/src/lib/utils/configure-from-framework.ts +3 -1
- package/src/lib/utils/enable-signalr.ts +5 -4
- package/src/version.ts +1 -1
- package/dist/esm/SignalRModuleConfigurator.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
+
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
3
|
+
import { type ISignalRConfigurator, type SignalRConfig, type SignalRHubConfig, type SignalRModuleConfigBuilderCallback } from './SignalRModuleConfigBuilder';
|
|
4
|
+
/**
|
|
5
|
+
* Default {@link ISignalRConfigurator} implementation.
|
|
6
|
+
*
|
|
7
|
+
* Collects hub registrations and builder callbacks, then produces a
|
|
8
|
+
* {@link SignalRConfig} during the module initialization phase.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SignalRConfigurator implements ISignalRConfigurator {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* Register a named SignalR hub connection.
|
|
14
|
+
*
|
|
15
|
+
* @param name - Unique identifier for the hub
|
|
16
|
+
* @param config - Hub connection configuration
|
|
17
|
+
*/
|
|
18
|
+
addHub(name: string, config: SignalRHubConfig): void;
|
|
19
|
+
/**
|
|
20
|
+
* Register a configuration builder callback that will run during
|
|
21
|
+
* {@link SignalRConfigurator.createConfig}.
|
|
22
|
+
*
|
|
23
|
+
* @param cb - Callback receiving a {@link SignalRModuleConfigBuilder}
|
|
24
|
+
* @template T - Type of module dependencies made available to the builder callback
|
|
25
|
+
*/
|
|
26
|
+
onCreateConfig<T>(cb: SignalRModuleConfigBuilderCallback<T>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Build the final {@link SignalRConfig} by executing all registered
|
|
29
|
+
* builder callbacks and collecting hub configurations.
|
|
30
|
+
*
|
|
31
|
+
* Normally called during the module `initialize` phase.
|
|
32
|
+
*
|
|
33
|
+
* @param init - Module initializer arguments providing access to resolved dependencies
|
|
34
|
+
* @returns Resolved configuration containing all registered hubs
|
|
35
|
+
*/
|
|
36
|
+
createConfig(init: ModuleInitializerArgs<ISignalRConfigurator, [ServiceDiscoveryModule]>): Promise<SignalRConfig>;
|
|
37
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Module } from '@equinor/fusion-framework-module';
|
|
2
|
-
import {
|
|
2
|
+
import type { ISignalRConfigurator } from './SignalRModuleConfigBuilder';
|
|
3
3
|
import { type ISignalRProvider } from './SignalRModuleProvider';
|
|
4
4
|
/** String literal key used to register the SignalR module in the Fusion Framework module system. */
|
|
5
5
|
export type SignalRModuleKey = 'signalR';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type AnyModule, ModuleConfigBuilder
|
|
2
|
-
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
1
|
+
import { type AnyModule, ModuleConfigBuilder } from '@equinor/fusion-framework-module';
|
|
3
2
|
import type { IHttpConnectionOptions, LogLevel } from '@microsoft/signalr';
|
|
4
3
|
/**
|
|
5
4
|
* Public configuration interface for the SignalR module.
|
|
@@ -94,36 +93,3 @@ export declare class SignalRModuleConfigBuilder<TDeps extends AnyModule[] | unkn
|
|
|
94
93
|
*/
|
|
95
94
|
addHub(name: string, config: SignalRHubConfig): Promise<void>;
|
|
96
95
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Default {@link ISignalRConfigurator} implementation.
|
|
99
|
-
*
|
|
100
|
-
* Collects hub registrations and builder callbacks, then produces a
|
|
101
|
-
* {@link SignalRConfig} during the module initialization phase.
|
|
102
|
-
*/
|
|
103
|
-
export declare class SignalRConfigurator implements ISignalRConfigurator {
|
|
104
|
-
#private;
|
|
105
|
-
/**
|
|
106
|
-
* Register a named SignalR hub connection.
|
|
107
|
-
*
|
|
108
|
-
* @param name - Unique identifier for the hub
|
|
109
|
-
* @param config - Hub connection configuration
|
|
110
|
-
*/
|
|
111
|
-
addHub(name: string, config: SignalRHubConfig): void;
|
|
112
|
-
/**
|
|
113
|
-
* Register a configuration builder callback that will run during
|
|
114
|
-
* {@link SignalRConfigurator.createConfig}.
|
|
115
|
-
*
|
|
116
|
-
* @param cb - Callback receiving a {@link SignalRModuleConfigBuilder}
|
|
117
|
-
*/
|
|
118
|
-
onCreateConfig<T>(cb: SignalRModuleConfigBuilderCallback<T>): void;
|
|
119
|
-
/**
|
|
120
|
-
* Build the final {@link SignalRConfig} by executing all registered
|
|
121
|
-
* builder callbacks and collecting hub configurations.
|
|
122
|
-
*
|
|
123
|
-
* Normally called during the module `initialize` phase.
|
|
124
|
-
*
|
|
125
|
-
* @param init - Module initializer arguments providing access to resolved dependencies
|
|
126
|
-
* @returns Resolved configuration containing all registered hubs
|
|
127
|
-
*/
|
|
128
|
-
createConfig(init: ModuleInitializerArgs<ISignalRConfigurator, [ServiceDiscoveryModule]>): Promise<SignalRConfig>;
|
|
129
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HubConnection } from '@microsoft/signalr';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import type { SignalRConfig } from './
|
|
3
|
+
import type { SignalRConfig } from './SignalRModuleConfigBuilder';
|
|
4
4
|
import { Topic } from './lib/Topic';
|
|
5
5
|
/**
|
|
6
6
|
* Public interface for the SignalR module provider.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* @see {@link enableSignalR} for the quickest way to register the module.
|
|
12
12
|
* @see {@link ISignalRProvider.connect} for subscribing to hub methods at runtime.
|
|
13
13
|
*/
|
|
14
|
-
export { ISignalRConfigurator,
|
|
14
|
+
export { ISignalRConfigurator, SignalRConfig, SignalRHubConfig, SignalRModuleConfigBuilder, SignalRModuleConfigBuilderCallback, } from './SignalRModuleConfigBuilder';
|
|
15
|
+
export { SignalRConfigurator } from './SignalRConfigurator';
|
|
15
16
|
export { ISignalRProvider, SignalRModuleProvider } from './SignalRModuleProvider';
|
|
16
17
|
export { Topic } from './lib/Topic';
|
|
17
18
|
export { enableSignalR } from './lib/utils/enable-signalr';
|
|
@@ -37,7 +37,7 @@ export declare class Topic<T> extends Observable<T> {
|
|
|
37
37
|
* @param args - Arguments forwarded to `HubConnection.send()`
|
|
38
38
|
* @throws {Error} When the hub connection has not been established yet
|
|
39
39
|
*/
|
|
40
|
-
send(...args:
|
|
40
|
+
send(...args: unknown[]): void;
|
|
41
41
|
/**
|
|
42
42
|
* Invoke a server method on this topic and wait for a response.
|
|
43
43
|
*
|
|
@@ -46,5 +46,5 @@ export declare class Topic<T> extends Observable<T> {
|
|
|
46
46
|
* @returns Promise resolving with the server's response
|
|
47
47
|
* @throws {Error} When the hub connection has not been established yet
|
|
48
48
|
*/
|
|
49
|
-
invoke<T>(...args:
|
|
49
|
+
invoke<T>(...args: unknown[]): Promise<T>;
|
|
50
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
2
|
-
import type { SignalRModuleConfigBuilderCallback } from '../../
|
|
2
|
+
import type { SignalRModuleConfigBuilderCallback } from '../../SignalRModuleConfigBuilder';
|
|
3
3
|
/**
|
|
4
4
|
* Call-signature overloads for {@link enableSignalR}.
|
|
5
5
|
*/
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "13.0.
|
|
1
|
+
export declare const version = "13.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-signalr",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"rxjs": "^7.8.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"typescript": "^
|
|
31
|
-
"@equinor/fusion-framework-module": "^6.1.
|
|
32
|
-
"@equinor/fusion-framework-module-
|
|
33
|
-
"@equinor/fusion-framework-module-
|
|
30
|
+
"typescript": "^7.0.2",
|
|
31
|
+
"@equinor/fusion-framework-module": "^6.1.1",
|
|
32
|
+
"@equinor/fusion-framework-module-msal": "^10.0.2",
|
|
33
|
+
"@equinor/fusion-framework-module-service-discovery": "^10.0.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@equinor/fusion-framework-module-
|
|
37
|
-
"@equinor/fusion-framework-module": "^
|
|
38
|
-
"@equinor/fusion-framework-module
|
|
36
|
+
"@equinor/fusion-framework-module-msal": "^10.0.2",
|
|
37
|
+
"@equinor/fusion-framework-module-service-discovery": "^10.0.2",
|
|
38
|
+
"@equinor/fusion-framework-module": "^6.1.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@equinor/fusion-framework-module-service-discovery": {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
+
|
|
3
|
+
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type ISignalRConfigurator,
|
|
7
|
+
SignalRModuleConfigBuilder,
|
|
8
|
+
type SignalRConfig,
|
|
9
|
+
type SignalRHubConfig,
|
|
10
|
+
type SignalRModuleConfigBuilderCallback,
|
|
11
|
+
} from './SignalRModuleConfigBuilder';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default {@link ISignalRConfigurator} implementation.
|
|
15
|
+
*
|
|
16
|
+
* Collects hub registrations and builder callbacks, then produces a
|
|
17
|
+
* {@link SignalRConfig} during the module initialization phase.
|
|
18
|
+
*/
|
|
19
|
+
export class SignalRConfigurator implements ISignalRConfigurator {
|
|
20
|
+
#builderCallbacks: Array<SignalRModuleConfigBuilderCallback> = [];
|
|
21
|
+
|
|
22
|
+
#hubs: Record<string, SignalRHubConfig> = {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Register a named SignalR hub connection.
|
|
26
|
+
*
|
|
27
|
+
* @param name - Unique identifier for the hub
|
|
28
|
+
* @param config - Hub connection configuration
|
|
29
|
+
*/
|
|
30
|
+
public addHub(name: string, config: SignalRHubConfig) {
|
|
31
|
+
this.#hubs[name] = config;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Register a configuration builder callback that will run during
|
|
36
|
+
* {@link SignalRConfigurator.createConfig}.
|
|
37
|
+
*
|
|
38
|
+
* @param cb - Callback receiving a {@link SignalRModuleConfigBuilder}
|
|
39
|
+
* @template T - Type of module dependencies made available to the builder callback
|
|
40
|
+
*/
|
|
41
|
+
public onCreateConfig<T>(cb: SignalRModuleConfigBuilderCallback<T>): void {
|
|
42
|
+
this.#builderCallbacks.push(cb);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build the final {@link SignalRConfig} by executing all registered
|
|
47
|
+
* builder callbacks and collecting hub configurations.
|
|
48
|
+
*
|
|
49
|
+
* Normally called during the module `initialize` phase.
|
|
50
|
+
*
|
|
51
|
+
* @param init - Module initializer arguments providing access to resolved dependencies
|
|
52
|
+
* @returns Resolved configuration containing all registered hubs
|
|
53
|
+
*/
|
|
54
|
+
public async createConfig(
|
|
55
|
+
init: ModuleInitializerArgs<ISignalRConfigurator, [ServiceDiscoveryModule]>,
|
|
56
|
+
): Promise<SignalRConfig> {
|
|
57
|
+
/** trigger all builder callbacks */
|
|
58
|
+
for (const cb of this.#builderCallbacks) {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
const builder = new SignalRModuleConfigBuilder<[ServiceDiscoveryModule]>(init, this);
|
|
61
|
+
await Promise.resolve(cb(builder));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { hubs: this.#hubs };
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/SignalRModule.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Module } from '@equinor/fusion-framework-module';
|
|
2
|
-
import {
|
|
2
|
+
import type { ISignalRConfigurator } from './SignalRModuleConfigBuilder';
|
|
3
|
+
import { SignalRConfigurator } from './SignalRConfigurator';
|
|
3
4
|
|
|
4
5
|
import { type ISignalRProvider, SignalRModuleProvider } from './SignalRModuleProvider';
|
|
5
6
|
|
|
@@ -33,6 +34,8 @@ export type SignalRModule = Module<SignalRModuleKey, ISignalRProvider, ISignalRC
|
|
|
33
34
|
* configurator.addConfig({ module: signalR });
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
37
|
+
// Deliberately co-located with the `moduleKey` constant it references
|
|
38
|
+
// fusion-lint-disable-next-line single-export-per-file
|
|
36
39
|
export const module: SignalRModule = {
|
|
37
40
|
name: moduleKey,
|
|
38
41
|
configure: () => new SignalRConfigurator(),
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AnyModule,
|
|
3
|
-
ModuleConfigBuilder,
|
|
4
|
-
type ModuleInitializerArgs,
|
|
5
|
-
} from '@equinor/fusion-framework-module';
|
|
1
|
+
import { type AnyModule, ModuleConfigBuilder } from '@equinor/fusion-framework-module';
|
|
6
2
|
|
|
7
|
-
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
8
3
|
import type { IHttpConnectionOptions, LogLevel } from '@microsoft/signalr';
|
|
9
4
|
|
|
10
5
|
/**
|
|
@@ -103,7 +98,7 @@ export type SignalRConfig = {
|
|
|
103
98
|
*/
|
|
104
99
|
export class SignalRModuleConfigBuilder<
|
|
105
100
|
TDeps extends AnyModule[] | unknown = unknown,
|
|
106
|
-
// TODO
|
|
101
|
+
// TODO(#5096): use BaseConfigBuilder
|
|
107
102
|
> extends ModuleConfigBuilder<TDeps, ISignalRConfigurator> {
|
|
108
103
|
/**
|
|
109
104
|
* Register a named hub connection through the underlying configurator.
|
|
@@ -115,57 +110,3 @@ export class SignalRModuleConfigBuilder<
|
|
|
115
110
|
this._config.addHub(name, config);
|
|
116
111
|
}
|
|
117
112
|
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Default {@link ISignalRConfigurator} implementation.
|
|
121
|
-
*
|
|
122
|
-
* Collects hub registrations and builder callbacks, then produces a
|
|
123
|
-
* {@link SignalRConfig} during the module initialization phase.
|
|
124
|
-
*/
|
|
125
|
-
export class SignalRConfigurator implements ISignalRConfigurator {
|
|
126
|
-
#builderCallbacks: Array<SignalRModuleConfigBuilderCallback> = [];
|
|
127
|
-
|
|
128
|
-
#hubs: Record<string, SignalRHubConfig> = {};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Register a named SignalR hub connection.
|
|
132
|
-
*
|
|
133
|
-
* @param name - Unique identifier for the hub
|
|
134
|
-
* @param config - Hub connection configuration
|
|
135
|
-
*/
|
|
136
|
-
public addHub(name: string, config: SignalRHubConfig) {
|
|
137
|
-
this.#hubs[name] = config;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Register a configuration builder callback that will run during
|
|
142
|
-
* {@link SignalRConfigurator.createConfig}.
|
|
143
|
-
*
|
|
144
|
-
* @param cb - Callback receiving a {@link SignalRModuleConfigBuilder}
|
|
145
|
-
*/
|
|
146
|
-
public onCreateConfig<T>(cb: SignalRModuleConfigBuilderCallback<T>): void {
|
|
147
|
-
this.#builderCallbacks.push(cb);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Build the final {@link SignalRConfig} by executing all registered
|
|
152
|
-
* builder callbacks and collecting hub configurations.
|
|
153
|
-
*
|
|
154
|
-
* Normally called during the module `initialize` phase.
|
|
155
|
-
*
|
|
156
|
-
* @param init - Module initializer arguments providing access to resolved dependencies
|
|
157
|
-
* @returns Resolved configuration containing all registered hubs
|
|
158
|
-
*/
|
|
159
|
-
public async createConfig(
|
|
160
|
-
init: ModuleInitializerArgs<ISignalRConfigurator, [ServiceDiscoveryModule]>,
|
|
161
|
-
): Promise<SignalRConfig> {
|
|
162
|
-
/** trigger all builder callbacks */
|
|
163
|
-
for (const cb of this.#builderCallbacks) {
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
const builder = new SignalRModuleConfigBuilder<[ServiceDiscoveryModule]>(init, this);
|
|
166
|
-
await Promise.resolve(cb(builder));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return { hubs: this.#hubs };
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HubConnectionBuilder, type HubConnection, AbortError } from '@microsoft/signalr';
|
|
2
2
|
import { Observable, shareReplay } from 'rxjs';
|
|
3
3
|
|
|
4
|
-
import type { SignalRConfig } from './
|
|
4
|
+
import type { SignalRConfig } from './SignalRModuleConfigBuilder';
|
|
5
5
|
|
|
6
6
|
import { Topic } from './lib/Topic';
|
|
7
7
|
|
|
@@ -81,10 +81,12 @@ export class SignalRModuleProvider implements ISignalRProvider {
|
|
|
81
81
|
protected _createHubConnection(hubId: string): Observable<HubConnection> {
|
|
82
82
|
const LOG_LEVEL_CRITICAL = 5;
|
|
83
83
|
|
|
84
|
+
// Reuse an already-established connection observable for this hub
|
|
84
85
|
if (hubId in this.#hubConnections) {
|
|
85
86
|
return this.#hubConnections[hubId];
|
|
86
87
|
}
|
|
87
88
|
const config = this.#config.hubs[hubId];
|
|
89
|
+
// Fail loudly when the hub was never registered with the configurator
|
|
88
90
|
if (!config) {
|
|
89
91
|
throw Error(`could not find any configuration for hub [${hubId}]`);
|
|
90
92
|
}
|
|
@@ -106,6 +108,7 @@ export class SignalRModuleProvider implements ISignalRProvider {
|
|
|
106
108
|
observer.next(connection);
|
|
107
109
|
})
|
|
108
110
|
.catch((error: unknown) => {
|
|
111
|
+
// Swallow expected teardown aborts; re-throw anything else
|
|
109
112
|
if (error instanceof AbortError) {
|
|
110
113
|
// AbortError is expected during teardown — safe to ignore
|
|
111
114
|
} else {
|
|
@@ -121,14 +124,16 @@ export class SignalRModuleProvider implements ISignalRProvider {
|
|
|
121
124
|
};
|
|
122
125
|
|
|
123
126
|
return teardown;
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
})
|
|
128
|
+
// Share a single connection across subscribers and tear it down when unused
|
|
129
|
+
.pipe(
|
|
130
|
+
shareReplay({
|
|
131
|
+
/** only emit last connection when new subscriber connects */
|
|
132
|
+
bufferSize: 1,
|
|
133
|
+
/** when no subscribers, teardown observable */
|
|
134
|
+
refCount: true,
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
132
137
|
|
|
133
138
|
return this.#hubConnections[hubId];
|
|
134
139
|
}
|
package/src/index.ts
CHANGED
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
ISignalRConfigurator,
|
|
17
|
-
SignalRConfigurator,
|
|
18
17
|
SignalRConfig,
|
|
19
18
|
SignalRHubConfig,
|
|
20
19
|
SignalRModuleConfigBuilder,
|
|
21
20
|
SignalRModuleConfigBuilderCallback,
|
|
22
|
-
} from './
|
|
21
|
+
} from './SignalRModuleConfigBuilder';
|
|
22
|
+
|
|
23
|
+
export { SignalRConfigurator } from './SignalRConfigurator';
|
|
23
24
|
|
|
24
25
|
export { ISignalRProvider, SignalRModuleProvider } from './SignalRModuleProvider';
|
|
25
26
|
|
package/src/lib/Topic.ts
CHANGED
|
@@ -53,8 +53,8 @@ export class Topic<T> extends Observable<T> {
|
|
|
53
53
|
* @param args - Arguments forwarded to `HubConnection.send()`
|
|
54
54
|
* @throws {Error} When the hub connection has not been established yet
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
public send(...args: unknown[]): void {
|
|
57
|
+
// A connection must have been established before sending is possible
|
|
58
58
|
if (!this.connection) {
|
|
59
59
|
throw new Error('No hub connection awaitable');
|
|
60
60
|
}
|
|
@@ -69,8 +69,8 @@ export class Topic<T> extends Observable<T> {
|
|
|
69
69
|
* @returns Promise resolving with the server's response
|
|
70
70
|
* @throws {Error} When the hub connection has not been established yet
|
|
71
71
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
public invoke<T>(...args: unknown[]): Promise<T> {
|
|
73
|
+
// A connection must have been established before invoking is possible
|
|
74
74
|
if (!this.connection) {
|
|
75
75
|
throw new Error('No hub connection awaitable');
|
|
76
76
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
2
2
|
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
3
3
|
|
|
4
|
-
import type { SignalRModuleConfigBuilder } from '../../
|
|
4
|
+
import type { SignalRModuleConfigBuilder } from '../../SignalRModuleConfigBuilder';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Configure a SignalR hub connection using Fusion Framework service-discovery
|
|
@@ -26,6 +26,7 @@ export const configureFromFramework = async (
|
|
|
26
26
|
url: new URL(args.path, service.uri).toString(),
|
|
27
27
|
options: {
|
|
28
28
|
accessTokenFactory: async () => {
|
|
29
|
+
// Scopes are required to acquire a token for this service
|
|
29
30
|
if (!service.scopes) {
|
|
30
31
|
throw Error(
|
|
31
32
|
`service [${service.name}] does not have authentication scopes, please configure an endpoint with scopes`,
|
|
@@ -34,6 +35,7 @@ export const configureFromFramework = async (
|
|
|
34
35
|
const token = await authProvider.acquireAccessToken({
|
|
35
36
|
request: { scopes: service.scopes ?? service.defaultScopes },
|
|
36
37
|
});
|
|
38
|
+
// Fail loudly rather than connecting the hub without a valid token
|
|
37
39
|
if (!token) {
|
|
38
40
|
throw Error('failed to acquire access token');
|
|
39
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
2
|
-
import type { SignalRModuleConfigBuilderCallback } from '../../
|
|
2
|
+
import type { SignalRModuleConfigBuilderCallback } from '../../SignalRModuleConfigBuilder';
|
|
3
3
|
import { module } from '../../SignalRModule';
|
|
4
4
|
import { configureFromFramework } from './configure-from-framework';
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ export interface enableSignalR {
|
|
|
15
15
|
* @param cb - Builder callback for manual hub configuration
|
|
16
16
|
*/
|
|
17
17
|
(
|
|
18
|
-
//
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: IModulesConfigurator<any, any> widens to accept a configurator for any concrete module set
|
|
19
19
|
configurator: IModulesConfigurator<any, any>,
|
|
20
20
|
name: string,
|
|
21
21
|
cb: SignalRModuleConfigBuilderCallback,
|
|
@@ -29,7 +29,7 @@ export interface enableSignalR {
|
|
|
29
29
|
* @param options - Service name and path used to resolve the hub endpoint
|
|
30
30
|
*/
|
|
31
31
|
(
|
|
32
|
-
//
|
|
32
|
+
// biome-ignore lint/suspicious/noExplicitAny: IModulesConfigurator<any, any> widens to accept a configurator for any concrete module set
|
|
33
33
|
configurator: IModulesConfigurator<any, any>,
|
|
34
34
|
name: string,
|
|
35
35
|
options: { service: string; path: string },
|
|
@@ -69,11 +69,12 @@ export interface enableSignalR {
|
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
export function enableSignalR(
|
|
72
|
-
//
|
|
72
|
+
// biome-ignore lint/suspicious/noExplicitAny: IModulesConfigurator<any, any> widens to accept a configurator for any concrete module set
|
|
73
73
|
configurator: IModulesConfigurator<any, any>,
|
|
74
74
|
name: string,
|
|
75
75
|
optionsOrCallback: SignalRModuleConfigBuilderCallback | { service: string; path: string },
|
|
76
76
|
) {
|
|
77
|
+
// Callback form configures the hub directly against the resolved builder
|
|
77
78
|
if (typeof optionsOrCallback === 'function') {
|
|
78
79
|
configurator.addConfig({
|
|
79
80
|
module,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '13.0.
|
|
2
|
+
export const version = '13.0.1';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SignalRModuleConfigurator.js","sourceRoot":"","sources":["../../src/SignalRModuleConfigurator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,GAEpB,MAAM,kCAAkC,CAAC;AAyF1C;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAGX,SAAQ,mBAAgD;IACxD;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,MAAwB;QACjD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAC9B,iBAAiB,GAA8C,EAAE,CAAC;IAElE,KAAK,GAAqC,EAAE,CAAC;IAE7C;;;;;OAKG;IACI,MAAM,CAAC,IAAY,EAAE,MAAwB;QAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAI,EAAyC;QAChE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,YAAY,CACvB,IAA2E;QAE3E,oCAAoC;QACpC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACxC,8DAA8D;YAC9D,MAAM,OAAO,GAAG,IAAI,0BAA0B,CAA2B,IAAI,EAAE,IAAI,CAAC,CAAC;YACrF,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF"}
|