@kronos-integration/endpoint 9.5.1 → 9.5.3

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 CHANGED
@@ -53,47 +53,50 @@ Named communication (end)-points inside of kronos
53
53
  * [openConnections](#openconnections)
54
54
  * [closeConnections](#closeconnections)
55
55
  * [connections](#connections)
56
- * [getConnectionState](#getconnectionstate)
56
+ * [addConnection](#addconnection)
57
57
  * [Parameters](#parameters-6)
58
- * [setConnectionState](#setconnectionstate)
58
+ * [getConnectionState](#getconnectionstate)
59
59
  * [Parameters](#parameters-7)
60
+ * [setConnectionState](#setconnectionstate)
61
+ * [Parameters](#parameters-8)
60
62
  * [isEndpoint](#isendpoint)
61
- * [Parameters](#parameters-8)
62
- * [instanciateInterceptors](#instanciateinterceptors)
63
63
  * [Parameters](#parameters-9)
64
- * [MultiConnectionEndpoint](#multiconnectionendpoint)
64
+ * [instanciateInterceptors](#instanciateinterceptors)
65
65
  * [Parameters](#parameters-10)
66
+ * [MultiConnectionEndpoint](#multiconnectionendpoint)
67
+ * [Parameters](#parameters-11)
66
68
  * [getConnectionState](#getconnectionstate-1)
67
- * [Parameters](#parameters-11)
68
- * [setConnectionState](#setconnectionstate-1)
69
69
  * [Parameters](#parameters-12)
70
- * [isConnected](#isconnected-1)
70
+ * [setConnectionState](#setconnectionstate-1)
71
71
  * [Parameters](#parameters-13)
72
+ * [isConnected](#isconnected-1)
73
+ * [Parameters](#parameters-14)
72
74
  * [connections](#connections-1)
73
75
  * [connections](#connections-2)
74
76
  * [MultiSendEndpoint](#multisendendpoint)
75
- * [Parameters](#parameters-14)
77
+ * [Parameters](#parameters-15)
76
78
  * [isOut](#isout-1)
77
79
  * [ReceivableEndpoint](#receivableendpoint)
78
- * [Parameters](#parameters-15)
80
+ * [Parameters](#parameters-16)
79
81
  * [isIn](#isin-2)
80
82
  * [receive](#receive-1)
81
83
  * [receive](#receive-2)
82
- * [Parameters](#parameters-16)
84
+ * [Parameters](#parameters-17)
83
85
  * [ReceiveEndpointDefault](#receiveendpointdefault)
84
86
  * [isDefault](#isdefault-1)
85
87
  * [ReceiveEndpointSelfConnectedDefault](#receiveendpointselfconnecteddefault)
86
88
  * [removeConnection](#removeconnection)
87
- * [Parameters](#parameters-17)
89
+ * [Parameters](#parameters-18)
88
90
  * [ReceiveEndpoint](#receiveendpoint)
89
- * [Parameters](#parameters-18)
91
+ * [Parameters](#parameters-19)
90
92
  * [isIn](#isin-3)
91
93
  * [SendEndpointDefault](#sendendpointdefault)
92
94
  * [isDefault](#isdefault-2)
93
95
  * [SendEndpoint](#sendendpoint)
94
- * [Parameters](#parameters-19)
96
+ * [Parameters](#parameters-20)
95
97
  * [isOut](#isout-2)
96
- * [isIn](#isin-4)
98
+ * [SendReceiveEndpoint](#sendreceiveendpoint)
99
+ * [isIn](#isin-4)
97
100
 
98
101
  ## DummyReceiveEndpoint
99
102
 
@@ -246,6 +249,12 @@ Closes all connections.
246
249
 
247
250
  Returns **Iterable\<any>**&#x20;
248
251
 
252
+ ### addConnection
253
+
254
+ #### Parameters
255
+
256
+ * `connection` **any**&#x20;
257
+
249
258
  ### getConnectionState
250
259
 
251
260
  Deliver state for a given connection.
@@ -281,7 +290,7 @@ Instanciate interceptors from its definitions.
281
290
 
282
291
  ### Parameters
283
292
 
284
- * `interceptors` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Interceptor> | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Class> | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)**&#x20;
293
+ * `interceptors` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Interceptor> | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)**&#x20;
285
294
  * `owner` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
286
295
 
287
296
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Interceptor>**&#x20;
@@ -475,7 +484,13 @@ We are always *out*
475
484
 
476
485
  Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** always true
477
486
 
478
- ## isIn
487
+ ## SendReceiveEndpoint
488
+
489
+ **Extends SendEndpoint**
490
+
491
+ bi directional endpint
492
+
493
+ ### isIn
479
494
 
480
495
  Always receiving.
481
496
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/endpoint",
3
- "version": "9.5.1",
3
+ "version": "9.5.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -8,8 +8,8 @@
8
8
  "types": "./types/module.d.mts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./types/module.d.mts",
12
- "default": "./src/module.mjs"
11
+ "default": "./src/module.mjs",
12
+ "types": "./types/module.d.mts"
13
13
  }
14
14
  },
15
15
  "description": "named communication (end)-points inside of kronos",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "license": "BSD-2-Clause",
30
30
  "scripts": {
31
- "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
31
+ "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
32
32
  "test": "npm run test:ava",
33
33
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
34
34
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
@@ -41,14 +41,14 @@
41
41
  "@kronos-integration/interceptor": "^10.3.0"
42
42
  },
43
43
  "devDependencies": {
44
- "ava": "^6.1.1",
44
+ "ava": "^6.1.2",
45
45
  "c8": "^9.1.0",
46
46
  "documentation": "^14.0.3",
47
47
  "semantic-release": "^23.0.2",
48
48
  "typescript": "^5.3.3"
49
49
  },
50
50
  "engines": {
51
- "node": ">=20.11.0"
51
+ "node": ">=20.11.1"
52
52
  },
53
53
  "repository": {
54
54
  "type": "git",
package/src/endpoint.mjs CHANGED
@@ -6,13 +6,16 @@ import { Interceptor } from "@kronos-integration/interceptor";
6
6
 
7
7
  /**
8
8
  * Connection endpoint.
9
- * @param {string} name endpoint name
10
- * @param {Object} owner of the endpoint (service)
11
- * @param {Object} options
12
- * @param {Function} [options.didConnect] called after receiver is present
13
- * @param {Interceptor|Object[]} [options.interceptors] interceptors
14
9
  */
10
+
15
11
  export class Endpoint {
12
+ /**
13
+ * @param {string} name endpoint name
14
+ * @param {Object} owner of the endpoint (service)
15
+ * @param {Object} options
16
+ * @param {function(Endpoint,Endpoint):void} [options.didConnect] called after receiver is present
17
+ * @param {Interceptor[]|string[]} [options.interceptors] interceptors
18
+ */
16
19
  constructor(name, owner, options) {
17
20
  this.name = name;
18
21
  this.owner = owner;
@@ -62,7 +65,7 @@ export class Endpoint {
62
65
  }
63
66
 
64
67
  /**
65
- *
68
+ *
66
69
  * @param {Object} options
67
70
  */
68
71
  connectionNamesWithStates(options = { includeRuntimeInfo: true }) {
@@ -276,7 +279,7 @@ export class Endpoint {
276
279
  /**
277
280
  * Actually stop the communication.
278
281
  * @param {Endpoint} other
279
- * @param {boolean?} backpointer true if this is the call from back call from the other side
282
+ * @param {boolean} [backpointer] true if this is the call from back call from the other side
280
283
  */
281
284
  closeConnection(other, backpointer) {
282
285
  if (other !== undefined) {
@@ -311,18 +314,27 @@ export class Endpoint {
311
314
  }
312
315
 
313
316
  /**
314
- * @return {Iterable<any>}
317
+ * @return {Iterable<Endpoint>}
315
318
  */
316
319
  *connections() {}
317
320
 
318
- addConnection() {}
321
+ /**
322
+ *
323
+ * @param {Endpoint} connection
324
+ */
325
+ addConnection(connection) {}
319
326
 
320
- removeConnection() {}
327
+ /**
328
+ * Actually stop the communication.
329
+ * @param {Endpoint} other
330
+ * @param {boolean?} backpointer true if this is the call form back call from the other side
331
+ */
332
+ removeConnection(other, backpointer) {}
321
333
 
322
334
  /**
323
335
  * Deliver state for a given connection.
324
336
  * @param {Endpoint} other
325
- * @return {ConnectionState}
337
+ * @return {ConnectionState}
326
338
  */
327
339
  getConnectionState(other) {}
328
340
 
@@ -333,7 +345,12 @@ export class Endpoint {
333
345
  */
334
346
  setConnectionState(other, state) {}
335
347
 
336
- didConnect(a,b) {}
348
+ /**
349
+ *
350
+ * @param {Endpoint} endpoint
351
+ * @param {Endpoint} other
352
+ */
353
+ didConnect(endpoint, other) {}
337
354
 
338
355
  get receivingInterceptors() {
339
356
  return [];
@@ -351,7 +368,7 @@ export function isEndpoint(object) {
351
368
 
352
369
  /**
353
370
  * Instanciate interceptors from its definitions.
354
- * @param {Interceptor[]|Class[]|String[]} interceptors
371
+ * @param {Interceptor[]|string[]|undefined} interceptors
355
372
  * @param {Object} owner
356
373
  * @return {Interceptor[]}
357
374
  */
@@ -51,6 +51,11 @@ export class MultiConnectionEndpoint extends ReceivableEndpoint {
51
51
  }
52
52
  }
53
53
 
54
+ /**
55
+ * Actually stop the communication.
56
+ * @param {Endpoint} other
57
+ * @param {boolean?} backpointer true if this is the call form back call from the other side
58
+ */
54
59
  removeConnection(other, backpointer) {
55
60
  this.closeConnection(other);
56
61
  this.#connections.delete(other);
@@ -12,7 +12,6 @@ import { Endpoint } from "./endpoint.mjs";
12
12
  * @param {Function} [options.didConnect] called after receiver is present
13
13
  */
14
14
  export class MultiSendEndpoint extends MultiConnectionEndpoint {
15
-
16
15
  /**
17
16
  * We are always _out_
18
17
  * @return {boolean} always true
@@ -30,7 +29,8 @@ export class MultiSendEndpoint extends MultiConnectionEndpoint {
30
29
 
31
30
  const next = async (...args) =>
32
31
  c >= interceptors.length
33
- ? connection.receive(...args)
32
+ ? // @ts-ignore
33
+ connection.receive(...args)
34
34
  : interceptors[c++].receive(this, next, ...args);
35
35
 
36
36
  next(...args);
@@ -38,7 +38,7 @@ export class MultiSendEndpoint extends MultiConnectionEndpoint {
38
38
  }
39
39
  }
40
40
 
41
- async * sendAndReceive(...args) {
41
+ async *sendAndReceive(...args) {
42
42
  const interceptors = this.interceptors;
43
43
 
44
44
  for (const connection of this.connections()) {
@@ -47,7 +47,8 @@ export class MultiSendEndpoint extends MultiConnectionEndpoint {
47
47
 
48
48
  const next = async (...args) =>
49
49
  c >= interceptors.length
50
- ? connection.receive(...args)
50
+ ? // @ts-ignore
51
+ connection.receive(...args)
51
52
  : interceptors[c++].receive(this, next, ...args);
52
53
 
53
54
  yield next(...args);
@@ -27,6 +27,7 @@ export class ReceiveEndpointSelfConnectedDefault extends ReceiveEndpointDefault
27
27
  * @param {boolean?} backpointer true if this is the call form back call from the other side
28
28
  */
29
29
  removeConnection(other, backpointer) {
30
+ // @ts-ignore
30
31
  if (other === this) {
31
32
  return;
32
33
  }
@@ -74,6 +74,11 @@ export class SendEndpoint extends ReceivableEndpoint {
74
74
  }
75
75
  }
76
76
 
77
+ /**
78
+ * Actually stop the communication.
79
+ * @param {Endpoint} other
80
+ * @param {boolean?} backpointer true if this is the call form back call from the other side
81
+ */
77
82
  removeConnection(other, backpointer) {
78
83
  this.closeConnection(other);
79
84
 
@@ -1,5 +1,8 @@
1
1
  import { SendEndpoint } from "./send-endpoint.mjs";
2
2
 
3
+ /**
4
+ * bi directional endpint
5
+ */
3
6
  export class SendReceiveEndpoint extends SendEndpoint {
4
7
 
5
8
  /**
@@ -6,27 +6,37 @@
6
6
  export function isEndpoint(object: any): boolean;
7
7
  /**
8
8
  * Instanciate interceptors from its definitions.
9
- * @param {Interceptor[]|Class[]|String[]} interceptors
9
+ * @param {Interceptor[]|string[]|undefined} interceptors
10
10
  * @param {Object} owner
11
11
  * @return {Interceptor[]}
12
12
  */
13
- export function instanciateInterceptors(interceptors: Interceptor[] | Class[] | string[], owner: any): Interceptor[];
13
+ export function instanciateInterceptors(interceptors: Interceptor[] | string[] | undefined, owner: any): Interceptor[];
14
14
  /**
15
15
  * @typedef {Object} ConnectionState
16
16
  */
17
17
  /**
18
18
  * Connection endpoint.
19
- * @param {string} name endpoint name
20
- * @param {Object} owner of the endpoint (service)
21
- * @param {Object} options
22
- * @param {Function} [options.didConnect] called after receiver is present
23
- * @param {Interceptor|Object[]} [options.interceptors] interceptors
24
19
  */
25
20
  export class Endpoint {
26
- constructor(name: any, owner: any, options: any);
27
- name: any;
21
+ /**
22
+ * @param {string} name endpoint name
23
+ * @param {Object} owner of the endpoint (service)
24
+ * @param {Object} options
25
+ * @param {function(Endpoint,Endpoint):void} [options.didConnect] called after receiver is present
26
+ * @param {Interceptor[]|string[]} [options.interceptors] interceptors
27
+ */
28
+ constructor(name: string, owner: any, options: {
29
+ didConnect?: (arg0: Endpoint, arg1: Endpoint) => void;
30
+ interceptors?: Interceptor[] | string[];
31
+ });
32
+ name: string;
28
33
  owner: any;
29
- didConnect(a: any, b: any): void;
34
+ /**
35
+ *
36
+ * @param {Endpoint} endpoint
37
+ * @param {Endpoint} other
38
+ */
39
+ didConnect(endpoint: Endpoint, other: Endpoint): void;
30
40
  interceptors: Interceptor[];
31
41
  /**
32
42
  * Name as presented for humans.
@@ -54,9 +64,9 @@ export class Endpoint {
54
64
  *
55
65
  * @param {Object} options
56
66
  */
57
- connectionNamesWithStates(options?: any): any[];
58
- toString(): any;
59
- get identifier(): any;
67
+ connectionNamesWithStates(options?: any): string[];
68
+ toString(): string;
69
+ get identifier(): string;
60
70
  /**
61
71
  * @return {boolean} false
62
72
  */
@@ -75,7 +85,7 @@ export class Endpoint {
75
85
  out: boolean;
76
86
  open: boolean;
77
87
  dummy: boolean;
78
- connected: any;
88
+ connected: string | string[];
79
89
  interceptors: any[];
80
90
  };
81
91
  /**
@@ -87,7 +97,7 @@ export class Endpoint {
87
97
  out: boolean;
88
98
  open: boolean;
89
99
  dummy: boolean;
90
- connected: any;
100
+ connected: string | string[];
91
101
  interceptors: any[];
92
102
  };
93
103
  /**
@@ -121,9 +131,9 @@ export class Endpoint {
121
131
  /**
122
132
  * Actually stop the communication.
123
133
  * @param {Endpoint} other
124
- * @param {boolean?} backpointer true if this is the call from back call from the other side
134
+ * @param {boolean} [backpointer] true if this is the call from back call from the other side
125
135
  */
126
- closeConnection(other: Endpoint, backpointer: boolean | null): void;
136
+ closeConnection(other: Endpoint, backpointer?: boolean): void;
127
137
  /**
128
138
  * Opens all connections.
129
139
  */
@@ -133,11 +143,20 @@ export class Endpoint {
133
143
  */
134
144
  closeConnections(): void;
135
145
  /**
136
- * @return {Iterable<any>}
146
+ * @return {Iterable<Endpoint>}
147
+ */
148
+ connections(): Iterable<Endpoint>;
149
+ /**
150
+ *
151
+ * @param {Endpoint} connection
152
+ */
153
+ addConnection(connection: Endpoint): void;
154
+ /**
155
+ * Actually stop the communication.
156
+ * @param {Endpoint} other
157
+ * @param {boolean?} backpointer true if this is the call form back call from the other side
137
158
  */
138
- connections(): Iterable<any>;
139
- addConnection(): void;
140
- removeConnection(): void;
159
+ removeConnection(other: Endpoint, backpointer: boolean | null): void;
141
160
  /**
142
161
  * Deliver state for a given connection.
143
162
  * @param {Endpoint} other
@@ -4,7 +4,6 @@
4
4
  */
5
5
  export class MultiConnectionEndpoint extends ReceivableEndpoint {
6
6
  addConnection(other: any, backpointer: any): void;
7
- removeConnection(other: any, backpointer: any): void;
8
7
  /**
9
8
  * All connections
10
9
  */
@@ -6,6 +6,7 @@
6
6
  * @param {Function} [options.receivingInterceptors]
7
7
  */
8
8
  export class ReceivableEndpoint extends Endpoint {
9
+ constructor(name: any, owner: any, options: any);
9
10
  /**
10
11
  * Set the receive function.
11
12
  * @param {Function} receive
@@ -3,14 +3,7 @@
3
3
  */
4
4
  export class ReceiveEndpointSelfConnectedDefault extends ReceiveEndpointDefault {
5
5
  connections(): any;
6
- /**
7
- * Actually stop the communication.
8
- * @param {Endpoint} other
9
- * @param {boolean?} backpointer true if this is the call form back call from the other side
10
- */
11
- removeConnection(other: Endpoint, backpointer: boolean | null): void;
12
6
  isConnected(other: any): boolean;
13
7
  send(...args: any[]): Promise<any>;
14
8
  }
15
9
  import { ReceiveEndpointDefault } from "./receive-endpoint-default.mjs";
16
- import { Endpoint } from "./endpoint.mjs";
@@ -12,7 +12,6 @@ export class SendEndpoint extends ReceivableEndpoint {
12
12
  getConnectionState(other: any): any;
13
13
  setConnectionState(other: any, state: any): void;
14
14
  addConnection(other: any, backpointer: any): void;
15
- removeConnection(other: any, backpointer: any): void;
16
15
  connections(): Generator<any, void, unknown>;
17
16
  send(...args: any[]): Promise<any>;
18
17
  #private;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * bi directional endpint
3
+ */
1
4
  export class SendReceiveEndpoint extends SendEndpoint {
2
5
  }
3
6
  import { SendEndpoint } from "./send-endpoint.mjs";