@mindignited/continuum-client 2.14.6
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/README.md +10 -0
- package/dist/continuum.cjs +3 -0
- package/dist/continuum.cjs.map +1 -0
- package/dist/continuum.js +1156 -0
- package/dist/continuum.js.map +1 -0
- package/dist/src/api/ConnectionInfo.d.ts +35 -0
- package/dist/src/api/Continuum.d.ts +81 -0
- package/dist/src/api/ContinuumDecorators.d.ts +5 -0
- package/dist/src/api/ILogManager.d.ts +49 -0
- package/dist/src/api/Identifiable.d.ts +7 -0
- package/dist/src/api/LogManager.d.ts +9 -0
- package/dist/src/api/errors/AuthenticationError.d.ts +4 -0
- package/dist/src/api/errors/AuthorizationError.d.ts +4 -0
- package/dist/src/api/errors/ContinuumError.d.ts +6 -0
- package/dist/src/api/security/ConnectedInfo.d.ts +9 -0
- package/dist/src/api/security/IParticipant.d.ts +30 -0
- package/dist/src/api/security/Participant.d.ts +11 -0
- package/dist/src/api/security/ParticipantConstants.d.ts +12 -0
- package/dist/src/core/api/CRI.d.ts +122 -0
- package/dist/src/core/api/ContextInterceptor.d.ts +19 -0
- package/dist/src/core/api/DefaultCRI.d.ts +32 -0
- package/dist/src/core/api/EventBus.d.ts +55 -0
- package/dist/src/core/api/IEventBus.d.ts +204 -0
- package/dist/src/core/api/IServiceRegistry.d.ts +74 -0
- package/dist/src/core/api/ServiceIdentifier.d.ts +20 -0
- package/dist/src/core/api/ServiceRegistry.d.ts +29 -0
- package/dist/src/core/api/StompConnectionManager.d.ts +38 -0
- package/dist/src/core/api/StreamData.d.ts +18 -0
- package/dist/src/core/api/crud/AbstractIterablePage.d.ts +23 -0
- package/dist/src/core/api/crud/CrudServiceProxy.d.ts +19 -0
- package/dist/src/core/api/crud/CrudServiceProxyFactory.d.ts +12 -0
- package/dist/src/core/api/crud/FunctionalIterablePage.d.ts +8 -0
- package/dist/src/core/api/crud/ICrudServiceProxy.d.ts +69 -0
- package/dist/src/core/api/crud/ICrudServiceProxyFactory.d.ts +12 -0
- package/dist/src/core/api/crud/IDataSource.d.ts +67 -0
- package/dist/src/core/api/crud/IterablePage.d.ts +15 -0
- package/dist/src/core/api/crud/Page.d.ts +19 -0
- package/dist/src/core/api/crud/Pageable.d.ts +65 -0
- package/dist/src/core/api/crud/Sort.d.ts +63 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/internal/core/api/ArgumentResolver.d.ts +14 -0
- package/dist/src/internal/core/api/EventUtil.d.ts +10 -0
- package/dist/src/internal/core/api/Logger.d.ts +21 -0
- package/dist/src/internal/core/api/ReturnValueConverter.d.ts +13 -0
- package/dist/src/internal/core/api/ServiceInvocationSupervisor.d.ts +39 -0
- package/dist/src/internal/core/api/crud/FindAllIterablePage.d.ts +13 -0
- package/dist/src/internal/core/api/crud/SearchIterablePage.d.ts +14 -0
- package/package.json +66 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Identifiable } from '../Identifiable';
|
|
2
|
+
/**
|
|
3
|
+
* Created by Navíd Mitchell 🤪on 6/16/23.
|
|
4
|
+
*/
|
|
5
|
+
export interface IParticipant extends Identifiable<string> {
|
|
6
|
+
/**
|
|
7
|
+
* The identity of the participant
|
|
8
|
+
*
|
|
9
|
+
* @return the identity of the participant
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* The tenant that the participant belongs to
|
|
14
|
+
*
|
|
15
|
+
* @return the tenant or null if not using multi-tenancy
|
|
16
|
+
*/
|
|
17
|
+
tenantId?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Metadata is a map of key value pairs that can be used to store additional information about a participant
|
|
20
|
+
*
|
|
21
|
+
* @return a map of key value pairs
|
|
22
|
+
*/
|
|
23
|
+
metadata: Map<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Roles are a list of strings that can be used to authorize a participant to perform certain actions
|
|
26
|
+
*
|
|
27
|
+
* @return a list of roles
|
|
28
|
+
*/
|
|
29
|
+
roles: string[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IParticipant } from './IParticipant';
|
|
2
|
+
/**
|
|
3
|
+
* Created by Navid Mitchell on 6/2/20
|
|
4
|
+
*/
|
|
5
|
+
export declare class Participant implements IParticipant {
|
|
6
|
+
id: string;
|
|
7
|
+
tenantId?: string | null;
|
|
8
|
+
metadata: Map<string, string>;
|
|
9
|
+
roles: string[];
|
|
10
|
+
constructor(id: string, tenantId?: string, metadata?: Map<string, string>, roles?: string[]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some common constants used for the {@link Participant} and {@link Participant#getMetadata()}
|
|
3
|
+
* Created by navid on 2/3/20
|
|
4
|
+
*/
|
|
5
|
+
export declare class ParticipantConstants {
|
|
6
|
+
static readonly PARTICIPANT_TYPE_METADATA_KEY: string;
|
|
7
|
+
static readonly PARTICIPANT_TYPE_DEVICE: string;
|
|
8
|
+
static readonly PARTICIPANT_TYPE_CLI: string;
|
|
9
|
+
static readonly PARTICIPANT_TYPE_USER: string;
|
|
10
|
+
static readonly PARTICIPANT_TYPE_NODE: string;
|
|
11
|
+
static readonly CLI_PARTICIPANT_ID: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CRI` is a Continuum Resource Identifier used by Continuum to route requests appropriately.
|
|
3
|
+
*
|
|
4
|
+
* The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Continuum.
|
|
5
|
+
*
|
|
6
|
+
* Will be in a format as follows where anything surrounded with `[]` is optional:
|
|
7
|
+
*
|
|
8
|
+
* scheme://[scope@]resourceName[/path][#version]
|
|
9
|
+
*
|
|
10
|
+
* NOTE: If scope needs to be used to identify a sub-scope, it will follow the form `scope = scope:sub-scope`.
|
|
11
|
+
*
|
|
12
|
+
* This format can have varied meanings based upon the scheme used.
|
|
13
|
+
*
|
|
14
|
+
* @author Navid Mitchell
|
|
15
|
+
* @since 3/25/25
|
|
16
|
+
*/
|
|
17
|
+
export interface CRI {
|
|
18
|
+
/**
|
|
19
|
+
* The scheme for this `CRI`.
|
|
20
|
+
*
|
|
21
|
+
* @returns a string containing the scheme
|
|
22
|
+
*/
|
|
23
|
+
scheme(): string;
|
|
24
|
+
/**
|
|
25
|
+
* The scope for this `CRI` or `null` if not provided.
|
|
26
|
+
*
|
|
27
|
+
* This is useful to narrow down the `CRI`. This could be something like a user id, device id, or a node id.
|
|
28
|
+
*
|
|
29
|
+
* @returns a string containing the scope if provided or `null` if not set
|
|
30
|
+
*/
|
|
31
|
+
scope(): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* @returns `true` if the `scope` is set
|
|
34
|
+
*/
|
|
35
|
+
hasScope(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The name of the resource represented by this `CRI`.
|
|
38
|
+
*
|
|
39
|
+
* In the case of a `srv` `CRI`, this will be the service name.
|
|
40
|
+
* In the case of a `stream` `CRI`, this will be the name of the event type that the stream expects.
|
|
41
|
+
*
|
|
42
|
+
* For the following CRI, `resourceName` would be the portion specified by `resourceName`:
|
|
43
|
+
*
|
|
44
|
+
* `scheme://[scope@]resourceName/path`
|
|
45
|
+
*
|
|
46
|
+
* @returns the string containing the name of this resource
|
|
47
|
+
*/
|
|
48
|
+
resourceName(): string;
|
|
49
|
+
/**
|
|
50
|
+
* This is a version for the resource or `null` if not provided.
|
|
51
|
+
*
|
|
52
|
+
* @returns a string containing the version if provided or `null` if not set
|
|
53
|
+
*/
|
|
54
|
+
version(): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* @returns `true` if the `version` is set
|
|
57
|
+
*/
|
|
58
|
+
hasVersion(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The path for this `CRI`, without a leading `/`.
|
|
61
|
+
*
|
|
62
|
+
* For the following CRI, `path` would be the portion specified by `path`:
|
|
63
|
+
*
|
|
64
|
+
* `scheme://[scope@]resourceName/path`
|
|
65
|
+
*
|
|
66
|
+
* @returns the path string if provided or `null` if not set
|
|
67
|
+
*/
|
|
68
|
+
path(): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* @returns `true` if the `path` is set
|
|
71
|
+
*/
|
|
72
|
+
hasPath(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Base Resource is a portion of the fully qualified `CRI` containing the following:
|
|
75
|
+
*
|
|
76
|
+
* `scheme://[scope@]resourceName`
|
|
77
|
+
*
|
|
78
|
+
* @returns string containing the baseResource
|
|
79
|
+
*/
|
|
80
|
+
baseResource(): string;
|
|
81
|
+
/**
|
|
82
|
+
* The fully qualified value for this `CRI`.
|
|
83
|
+
*
|
|
84
|
+
* @returns the fully qualified `CRI` as a string
|
|
85
|
+
*/
|
|
86
|
+
raw(): string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new `CRI` from a raw string.
|
|
90
|
+
*
|
|
91
|
+
* @param rawUrc the raw string
|
|
92
|
+
* @returns the newly created `CRI`
|
|
93
|
+
*/
|
|
94
|
+
export declare function createCRI(rawUrc: string): CRI;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new `CRI` from scheme and resourceName.
|
|
97
|
+
*
|
|
98
|
+
* @param scheme the scheme
|
|
99
|
+
* @param resourceName the resource name
|
|
100
|
+
* @returns the newly created `CRI`
|
|
101
|
+
*/
|
|
102
|
+
export declare function createCRI(scheme: string, resourceName: string): CRI;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new `CRI` from scheme, scope, and resourceName.
|
|
105
|
+
*
|
|
106
|
+
* @param scheme the scheme
|
|
107
|
+
* @param scope the scope
|
|
108
|
+
* @param resourceName the resource name
|
|
109
|
+
* @returns the newly created `CRI`
|
|
110
|
+
*/
|
|
111
|
+
export declare function createCRI(scheme: string, scope: string | null, resourceName: string): CRI;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new `CRI` from all provided values.
|
|
114
|
+
*
|
|
115
|
+
* @param scheme the scheme
|
|
116
|
+
* @param scope the scope
|
|
117
|
+
* @param resourceName the resource name
|
|
118
|
+
* @param path the path
|
|
119
|
+
* @param version the version
|
|
120
|
+
* @returns the newly created `CRI`
|
|
121
|
+
*/
|
|
122
|
+
export declare function createCRI(scheme: string, scope: string | null, resourceName: string, path: string | null, version: string | null): CRI;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IEvent } from './IEventBus.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for the service context, extendable by users for type-safe context data.
|
|
4
|
+
*
|
|
5
|
+
* @author Navid Mitchell 🤝Grok
|
|
6
|
+
* @since 3/25/2025
|
|
7
|
+
*/
|
|
8
|
+
export interface ServiceContext {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Interface for interceptors that create or modify the ServiceContext before service method invocation.
|
|
13
|
+
*
|
|
14
|
+
* @author Navid Mitchell 🤝Grok
|
|
15
|
+
* @since 3/25/2025
|
|
16
|
+
*/
|
|
17
|
+
export interface ContextInterceptor<T extends ServiceContext> {
|
|
18
|
+
intercept(event: IEvent, context: T): Promise<T> | T;
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CRI } from './CRI';
|
|
2
|
+
/**
|
|
3
|
+
* Default implementation of the `CRI` interface.
|
|
4
|
+
*
|
|
5
|
+
* @author Navid Mitchell
|
|
6
|
+
* @since 3/25/25
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultCRI implements CRI {
|
|
9
|
+
private readonly _scheme;
|
|
10
|
+
private readonly _scope;
|
|
11
|
+
private readonly _resourceName;
|
|
12
|
+
private readonly _path;
|
|
13
|
+
private readonly _version;
|
|
14
|
+
private readonly _raw;
|
|
15
|
+
constructor(rawCRI: string);
|
|
16
|
+
constructor(scheme: string, scope: string | null, resourceName: string, path: string | null, version: string | null);
|
|
17
|
+
scheme(): string;
|
|
18
|
+
scope(): string | null;
|
|
19
|
+
hasScope(): boolean;
|
|
20
|
+
resourceName(): string;
|
|
21
|
+
version(): string | null;
|
|
22
|
+
hasVersion(): boolean;
|
|
23
|
+
path(): string | null;
|
|
24
|
+
hasPath(): boolean;
|
|
25
|
+
baseResource(): string;
|
|
26
|
+
raw(): string;
|
|
27
|
+
equals(other: any): boolean;
|
|
28
|
+
hashCode(): number;
|
|
29
|
+
toString(): string;
|
|
30
|
+
private static parseRaw;
|
|
31
|
+
private static buildRaw;
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ConnectionInfo, ServerInfo } from '../../api/ConnectionInfo';
|
|
2
|
+
import { ConnectedInfo } from '../../api/security/ConnectedInfo';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { Optional } from 'typescript-optional';
|
|
5
|
+
import { IEvent, IEventBus } from './IEventBus';
|
|
6
|
+
/**
|
|
7
|
+
* Default IEvent implementation
|
|
8
|
+
*/
|
|
9
|
+
export declare class Event implements IEvent {
|
|
10
|
+
cri: string;
|
|
11
|
+
headers: Map<string, string>;
|
|
12
|
+
data: Optional<Uint8Array>;
|
|
13
|
+
constructor(cri: string, headers?: Map<string, string>, data?: Uint8Array);
|
|
14
|
+
getHeader(key: string): string | undefined;
|
|
15
|
+
hasHeader(key: string): boolean;
|
|
16
|
+
setHeader(key: string, value: string): void;
|
|
17
|
+
removeHeader(key: string): boolean;
|
|
18
|
+
setDataString(data: string): void;
|
|
19
|
+
getDataString(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default implementation of {@link IEventBus}
|
|
23
|
+
*/
|
|
24
|
+
export declare class EventBus implements IEventBus {
|
|
25
|
+
fatalErrors: Observable<Error>;
|
|
26
|
+
serverInfo: ServerInfo | null;
|
|
27
|
+
private stompConnectionManager;
|
|
28
|
+
private replyToCri;
|
|
29
|
+
private requestRepliesObservable;
|
|
30
|
+
private requestRepliesSubject;
|
|
31
|
+
private requestRepliesSubscription;
|
|
32
|
+
private errorSubject;
|
|
33
|
+
private errorSubjectSubscription;
|
|
34
|
+
constructor();
|
|
35
|
+
isConnectionActive(): boolean;
|
|
36
|
+
isConnected(): boolean;
|
|
37
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
38
|
+
disconnect(force?: boolean): Promise<void>;
|
|
39
|
+
send(event: IEvent): void;
|
|
40
|
+
request(event: IEvent): Promise<IEvent>;
|
|
41
|
+
requestStream(event: IEvent, sendControlEvents?: boolean): Observable<IEvent>;
|
|
42
|
+
observe(cri: string): Observable<IEvent>;
|
|
43
|
+
private cleanup;
|
|
44
|
+
/**
|
|
45
|
+
* Creates the proper error to return if this.stompConnectionManager?.rxStomp is not available on a send request
|
|
46
|
+
*/
|
|
47
|
+
private createSendUnavailableError;
|
|
48
|
+
/**
|
|
49
|
+
* This is internal impl of observe that creates a cold observable.
|
|
50
|
+
* The public variants transform this to some type of hot observable depending on the need
|
|
51
|
+
* @param cri to observe
|
|
52
|
+
* @return the cold {@link Observable<IEvent>} for the given destination
|
|
53
|
+
*/
|
|
54
|
+
private _observe;
|
|
55
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Optional } from 'typescript-optional';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ConnectedInfo } from '../../api/security/ConnectedInfo';
|
|
4
|
+
import { ContinuumError } from '../../api/errors/ContinuumError';
|
|
5
|
+
import { ConnectionInfo, ServerInfo } from '../../api/ConnectionInfo';
|
|
6
|
+
/**
|
|
7
|
+
* Part of the low level portion of continuum representing data to be processed
|
|
8
|
+
*
|
|
9
|
+
* This is similar to a Stomp Frame but with more required information and no control plane semantics.
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* Created by Navid Mitchell on 2019-01-04.
|
|
13
|
+
*/
|
|
14
|
+
export interface IEvent {
|
|
15
|
+
/**
|
|
16
|
+
* The cri that specifies where the event should be routed
|
|
17
|
+
*/
|
|
18
|
+
cri: string;
|
|
19
|
+
/**
|
|
20
|
+
* Any headers defined for this event.
|
|
21
|
+
* This will usually contain all the fields above as well since they are typically wrappers around expected header values.
|
|
22
|
+
*/
|
|
23
|
+
headers: Map<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* The event payload. The payload depends on the type the payload is encoded into a media format which is specified by the contentType attribute (e.g. application/json).
|
|
26
|
+
*/
|
|
27
|
+
data: Optional<Uint8Array>;
|
|
28
|
+
/**
|
|
29
|
+
* @return the data property as a UTF-8 encoded string
|
|
30
|
+
*/
|
|
31
|
+
getDataString(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the value for the header with the given key
|
|
34
|
+
* @param key to get the header value for
|
|
35
|
+
* @return the header value or undefined if there is no header for the key
|
|
36
|
+
*/
|
|
37
|
+
getHeader(key: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Tests if a header for the given key exists
|
|
40
|
+
* @param key to check if exists as a header
|
|
41
|
+
* @return true if the header for the key exists false if not
|
|
42
|
+
*/
|
|
43
|
+
hasHeader(key: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Removes the header from the headers map
|
|
46
|
+
* @param key to remove
|
|
47
|
+
* @return true if an element in the headers map object existed and has been removed, or false if the element does not exist
|
|
48
|
+
*/
|
|
49
|
+
removeHeader(key: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the data property from the given string value
|
|
52
|
+
* @param data
|
|
53
|
+
*/
|
|
54
|
+
setDataString(data: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the header into the headers map
|
|
57
|
+
* @param key the key to use
|
|
58
|
+
* @param value the value to use
|
|
59
|
+
*/
|
|
60
|
+
setHeader(key: string, value: string): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Part of the low level portion of continuum representing a connection to a continuum server
|
|
64
|
+
* This is similar to a Stomp Client but with more required information and no control plane semantics.
|
|
65
|
+
*
|
|
66
|
+
* Created by Navid Mitchell on 2019-01-04.
|
|
67
|
+
*/
|
|
68
|
+
export interface IEventBus {
|
|
69
|
+
/**
|
|
70
|
+
* Any errors emitted by this observable will be fatal and the connection will be closed.
|
|
71
|
+
* You will need to resolve the problem and reconnect.
|
|
72
|
+
*/
|
|
73
|
+
fatalErrors: Observable<ContinuumError>;
|
|
74
|
+
/**
|
|
75
|
+
* The {@link ServerInfo} used when connecting, if connected or null
|
|
76
|
+
*/
|
|
77
|
+
serverInfo: ServerInfo | null;
|
|
78
|
+
/**
|
|
79
|
+
* Requests a connection to the given Stomp url
|
|
80
|
+
* @param connectionInfo provides the information needed to connect to the continuum server
|
|
81
|
+
* @return Promise containing the result of the initial connection attempt
|
|
82
|
+
*/
|
|
83
|
+
connect(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
84
|
+
/**
|
|
85
|
+
* Disconnects the client from the server
|
|
86
|
+
* This will clear any subscriptions and close the connection
|
|
87
|
+
* @param force if true then the connection will be closed immediately without sending a disconnect frame
|
|
88
|
+
* When this mode is used, the actual Websocket may linger for a while
|
|
89
|
+
* and the broker may not realize that the connection is no longer in use.
|
|
90
|
+
*
|
|
91
|
+
* @return Promise containing the result of the disconnect attempt
|
|
92
|
+
*/
|
|
93
|
+
disconnect(force?: boolean): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Determines if the connection is connected.
|
|
96
|
+
* This means that there is an open connection to the Continuum server
|
|
97
|
+
* @return true if the connection is active false if not
|
|
98
|
+
*/
|
|
99
|
+
isConnected(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Determines if the connection is active.
|
|
102
|
+
* This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
|
|
103
|
+
* If this is true and {@link IEventBus#isConnected} is false messages sent will be queued
|
|
104
|
+
* @return true if the connection is active false if not
|
|
105
|
+
*/
|
|
106
|
+
isConnectionActive(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a subscription for all {@link IEvent}'s for the given destination
|
|
109
|
+
* @param cri to subscribe to
|
|
110
|
+
*/
|
|
111
|
+
observe(cri: string): Observable<IEvent>;
|
|
112
|
+
/**
|
|
113
|
+
* Sends an {@link IEvent} expecting a response
|
|
114
|
+
* All response correlation will be handled internally
|
|
115
|
+
* @param event to send as the request
|
|
116
|
+
* @return a Promise that will resolve when the response is received
|
|
117
|
+
*/
|
|
118
|
+
request(event: IEvent): Promise<IEvent>;
|
|
119
|
+
/**
|
|
120
|
+
* Sends an {@link IEvent} expecting multiple responses
|
|
121
|
+
* All response correlation will be handled internally
|
|
122
|
+
* @param event to send as the request
|
|
123
|
+
* @param sendControlEvents if true then control events will be sent to the server when changes to the returned to Observable are requested
|
|
124
|
+
* @return an {@link Observable<IEvent} that will provide the response stream
|
|
125
|
+
* NOTE: the naming here is similar to RSocket https://www.baeldung.com/rsocket#3-requeststream
|
|
126
|
+
*/
|
|
127
|
+
requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
|
|
128
|
+
/**
|
|
129
|
+
* Send a single {@link IEvent} to the connected server
|
|
130
|
+
* @param event to send
|
|
131
|
+
*/
|
|
132
|
+
send(event: IEvent): void;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Constants used within {@link IEvent}'s to control the flow of events
|
|
136
|
+
* Header that start with __ will always be persisted between messages
|
|
137
|
+
*/
|
|
138
|
+
export declare enum EventConstants {
|
|
139
|
+
CONTENT_TYPE_HEADER = "content-type",
|
|
140
|
+
CONTENT_LENGTH_HEADER = "content-length",
|
|
141
|
+
REPLY_TO_HEADER = "reply-to",
|
|
142
|
+
/**
|
|
143
|
+
* This is the replyToId that will be supplied by the client, which will be used when sending replies to the client.
|
|
144
|
+
*/
|
|
145
|
+
REPLY_TO_ID_HEADER = "reply-to-id",
|
|
146
|
+
/**
|
|
147
|
+
* Header provided by the sever on connection to represent the user's session id
|
|
148
|
+
*/
|
|
149
|
+
SESSION_HEADER = "session",
|
|
150
|
+
/**
|
|
151
|
+
* Header provided by the server on connection to provide the {@link ConnectionInfo} as a JSON string
|
|
152
|
+
*/
|
|
153
|
+
CONNECTED_INFO_HEADER = "connected-info",
|
|
154
|
+
/**
|
|
155
|
+
* Header provided by the client on connection request to represent that the server
|
|
156
|
+
* should not keep the session alive after any network disconnection.
|
|
157
|
+
*/
|
|
158
|
+
DISABLE_STICKY_SESSION_HEADER = "disable-sticky-session",
|
|
159
|
+
/**
|
|
160
|
+
* Correlates a response with a given request
|
|
161
|
+
* Headers that start with __ will always be persisted between messages
|
|
162
|
+
*/
|
|
163
|
+
CORRELATION_ID_HEADER = "__correlation-id",
|
|
164
|
+
/**
|
|
165
|
+
* Denotes that something caused an error. Will contain a brief message about the error
|
|
166
|
+
*/
|
|
167
|
+
ERROR_HEADER = "error",
|
|
168
|
+
/**
|
|
169
|
+
* Denotes the completion of an event stream. The value typically will contain the reason for completion.
|
|
170
|
+
*/
|
|
171
|
+
COMPLETE_HEADER = "complete",
|
|
172
|
+
/**
|
|
173
|
+
* Denotes the event is a control plane event. These are used for internal coordination.
|
|
174
|
+
*/
|
|
175
|
+
CONTROL_HEADER = "control",
|
|
176
|
+
/**
|
|
177
|
+
* Stream is complete, no further values will be sent.
|
|
178
|
+
*/
|
|
179
|
+
CONTROL_VALUE_COMPLETE = "complete",
|
|
180
|
+
CONTROL_VALUE_CANCEL = "cancel",
|
|
181
|
+
CONTROL_VALUE_SUSPEND = "suspend",
|
|
182
|
+
CONTROL_VALUE_RESUME = "resume",
|
|
183
|
+
SERVICE_DESTINATION_PREFIX = "srv://",
|
|
184
|
+
SERVICE_DESTINATION_SCHEME = "srv",
|
|
185
|
+
STREAM_DESTINATION_PREFIX = "stream://",
|
|
186
|
+
STREAM_DESTINATION_SCHEME = "stream",
|
|
187
|
+
CONTENT_JSON = "application/json",
|
|
188
|
+
CONTENT_TEXT = "text/plain",
|
|
189
|
+
/**
|
|
190
|
+
* The traceparent HTTP header field identifies the incoming request in a tracing system. It has four fields:
|
|
191
|
+
*
|
|
192
|
+
* version
|
|
193
|
+
* trace-id
|
|
194
|
+
* parent-id
|
|
195
|
+
* trace-flags
|
|
196
|
+
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
197
|
+
*/
|
|
198
|
+
TRACEPARENT_HEADER = "traceparent",
|
|
199
|
+
/**
|
|
200
|
+
* The main purpose of the tracestate header is to provide additional vendor-specific trace identification information across different distributed tracing systems and is a companion header for the traceparent field. It also conveys information about the request’s position in multiple distributed tracing graphs.
|
|
201
|
+
* @see https://www.w3.org/TR/trace-context/#tracestate-header
|
|
202
|
+
*/
|
|
203
|
+
TRACESTATE_HEADER = "tracestate"
|
|
204
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ContextInterceptor, ServiceContext } from './ContextInterceptor.js';
|
|
2
|
+
import { ServiceIdentifier } from './ServiceIdentifier.js';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { IEvent } from './IEventBus';
|
|
5
|
+
/**
|
|
6
|
+
* Provides an interface to allow the {@link IServiceProxy} creator the ability to have fine grain control of the outgoing {@link IEvent}
|
|
7
|
+
*/
|
|
8
|
+
export interface IEventFactory {
|
|
9
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* {@link IServiceProxy} provides the ability to access a remote service
|
|
13
|
+
*
|
|
14
|
+
* Created by navid on 2019-04-18.
|
|
15
|
+
*/
|
|
16
|
+
export interface IServiceProxy {
|
|
17
|
+
/**
|
|
18
|
+
* The remote id of the service that this proxy is for
|
|
19
|
+
*/
|
|
20
|
+
serviceIdentifier: string;
|
|
21
|
+
/**
|
|
22
|
+
* Provides functionality to invoke the remote service that returns a single result
|
|
23
|
+
* @param methodIdentifier of the service method to invoke
|
|
24
|
+
* @param args to pass to the service invocation
|
|
25
|
+
* @param scope string or undefined or null, if not undefined or null this is used to determine which service instance rpc requests should be routed to.
|
|
26
|
+
* @param eventFactory IEventFactory or undefined or null, if not undefined or null this is the {@link IEventFactory} to use when creating {@link IEvent}'s to send
|
|
27
|
+
* @return a {@link Promise} that will resolve to the result from the invocation
|
|
28
|
+
*/
|
|
29
|
+
invoke(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Provides functionality to invoke the remote service that returns a stream of results
|
|
32
|
+
* @param methodIdentifier of the service method to invoke
|
|
33
|
+
* @param args to pass to the service invocation
|
|
34
|
+
* @param scope string or undefined or null, if not undefined or null this is used to determine which service instance rpc requests should be routed to.
|
|
35
|
+
* @param eventFactory IEventFactory or undefined or null, if not undefined or null this is the {@link IEventFactory} to use when creating {@link IEvent}'s to send
|
|
36
|
+
* @return a {@link Observable} that will resolve to the result from the invocation
|
|
37
|
+
*/
|
|
38
|
+
invokeStream(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Observable<any>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Provides the functionality to register services as well as create proxies for those services
|
|
42
|
+
*
|
|
43
|
+
* Created by Navid Mitchell on 2019-02-08.
|
|
44
|
+
*/
|
|
45
|
+
export interface IServiceRegistry {
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new service proxy that can be used to access the desired service.
|
|
48
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
49
|
+
* @return the {@link IServiceProxy} that can be used to access the service
|
|
50
|
+
*/
|
|
51
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
52
|
+
/**
|
|
53
|
+
* Registers a new service with the service registry.
|
|
54
|
+
* This will allow the service to be accessed remotely.
|
|
55
|
+
*
|
|
56
|
+
* @param serviceIdentifier identifies the service to be registered
|
|
57
|
+
* @param service to use invoke when the service is called
|
|
58
|
+
*/
|
|
59
|
+
register(serviceIdentifier: ServiceIdentifier, service: any): void;
|
|
60
|
+
/**
|
|
61
|
+
* Unregisters a service with the service registry.
|
|
62
|
+
* This will remove the service from the registry, and it will no longer be accessible remotely.
|
|
63
|
+
*
|
|
64
|
+
* @param serviceIdentifier identifies the service to be unregistered
|
|
65
|
+
*/
|
|
66
|
+
unRegister(serviceIdentifier: ServiceIdentifier): void;
|
|
67
|
+
/**
|
|
68
|
+
* Registers a {@link ContextInterceptor} that will be used to modify the {@link ServiceContext} before the service method is invoked.
|
|
69
|
+
* This allows for custom context data to be added or modified before the service method is called.
|
|
70
|
+
*
|
|
71
|
+
* @param interceptor the {@link ContextInterceptor} to register
|
|
72
|
+
*/
|
|
73
|
+
registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
|
|
74
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CRI } from './CRI.js';
|
|
2
|
+
export declare class ServiceIdentifier {
|
|
3
|
+
namespace: string;
|
|
4
|
+
name: string;
|
|
5
|
+
scope?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
private _cri;
|
|
8
|
+
constructor(namespace: string, name: string);
|
|
9
|
+
/**
|
|
10
|
+
* Returns the qualified name for this {@link ServiceIdentifier}
|
|
11
|
+
* This is the namespace.name
|
|
12
|
+
* @return string containing the qualified name
|
|
13
|
+
*/
|
|
14
|
+
qualifiedName(): string;
|
|
15
|
+
/**
|
|
16
|
+
* The {@link CRI} that represents this {@link ServiceIdentifier}
|
|
17
|
+
* @return the cri for this {@link ServiceIdentifier}
|
|
18
|
+
*/
|
|
19
|
+
cri(): CRI;
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ServiceIdentifier } from './ServiceIdentifier.js';
|
|
2
|
+
import { IEvent, IEventBus } from './IEventBus';
|
|
3
|
+
import { IEventFactory, IServiceProxy, IServiceRegistry } from './IServiceRegistry';
|
|
4
|
+
import { ContextInterceptor, ServiceContext } from './ContextInterceptor';
|
|
5
|
+
/**
|
|
6
|
+
* An implementation of a {@link IEventFactory} which uses JSON content
|
|
7
|
+
*/
|
|
8
|
+
export declare class JsonEventFactory implements IEventFactory {
|
|
9
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An implementation of a {@link IEventFactory} which uses text content
|
|
13
|
+
*/
|
|
14
|
+
export declare class TextEventFactory implements IEventFactory {
|
|
15
|
+
create(cri: string, args: any[] | null | undefined): IEvent;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The default implementation of {@link IServiceRegistry}
|
|
19
|
+
*/
|
|
20
|
+
export declare class ServiceRegistry implements IServiceRegistry {
|
|
21
|
+
private readonly eventBus;
|
|
22
|
+
private readonly supervisors;
|
|
23
|
+
private contextInterceptor;
|
|
24
|
+
constructor(eventBus: IEventBus);
|
|
25
|
+
serviceProxy(serviceIdentifier: string): IServiceProxy;
|
|
26
|
+
register(serviceIdentifier: ServiceIdentifier, service: any): void;
|
|
27
|
+
unRegister(serviceIdentifier: ServiceIdentifier): void;
|
|
28
|
+
registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ConnectionInfo } from '../../api/ConnectionInfo';
|
|
2
|
+
import { ConnectedInfo } from '../../api/security/ConnectedInfo';
|
|
3
|
+
import { RxStomp } from '@stomp/rx-stomp';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new RxStomp client and manages it
|
|
6
|
+
* This is here to simplify the logic needed for connection management and the usage of the client.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StompConnectionManager {
|
|
9
|
+
lastWebsocketError: Event | null;
|
|
10
|
+
/**
|
|
11
|
+
* This will return true if a {@link ConnectionInfo#maxConnectionAttempts} threshold was set and was reached
|
|
12
|
+
*/
|
|
13
|
+
maxConnectionAttemptsReached: boolean;
|
|
14
|
+
rxStomp: RxStomp | null;
|
|
15
|
+
private readonly INITIAL_RECONNECT_DELAY;
|
|
16
|
+
private readonly MAX_RECONNECT_DELAY;
|
|
17
|
+
private readonly JITTER_MAX;
|
|
18
|
+
private connectionAttempts;
|
|
19
|
+
private initialConnectionSuccessful;
|
|
20
|
+
private debugLogger;
|
|
21
|
+
private replyToId;
|
|
22
|
+
readonly replyToCri: string;
|
|
23
|
+
deactivationHandler: (() => void) | null;
|
|
24
|
+
/**
|
|
25
|
+
* @return true if this {@link StompConnectionManager} is actively trying to maintain a connection to the Stomp server, false if not.
|
|
26
|
+
*/
|
|
27
|
+
get active(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* return true if this {@link StompConnectionManager} is active and has a connection to the stomp server
|
|
30
|
+
*/
|
|
31
|
+
get connected(): boolean;
|
|
32
|
+
activate(connectionInfo: ConnectionInfo): Promise<ConnectedInfo>;
|
|
33
|
+
deactivate(force?: boolean): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Make sure clients don't all try to reconnect at the same time.
|
|
36
|
+
*/
|
|
37
|
+
private connectionJitterDelay;
|
|
38
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Identifiable } from '../../index';
|
|
2
|
+
export declare enum StreamOperation {
|
|
3
|
+
EXISTING = "EXISTING",
|
|
4
|
+
UPDATE = "UPDATE",
|
|
5
|
+
REMOVE = "REMOVE"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Holder for domain objects that will be returned as a stream of changes to a data set
|
|
9
|
+
*
|
|
10
|
+
* Created by Navid Mitchell on 6/3/20
|
|
11
|
+
*/
|
|
12
|
+
export declare class StreamData<I, T> implements Identifiable<I> {
|
|
13
|
+
streamOperation: StreamOperation;
|
|
14
|
+
id: I;
|
|
15
|
+
value: T;
|
|
16
|
+
constructor(streamOperation: StreamOperation, id: I, value: T);
|
|
17
|
+
isSet(): boolean;
|
|
18
|
+
}
|