@kronos-integration/endpoint 9.5.2 → 9.5.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/README.md CHANGED
@@ -53,47 +53,58 @@ 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
+ * [removeConnection](#removeconnection)
59
59
  * [Parameters](#parameters-7)
60
+ * [getConnectionState](#getconnectionstate)
61
+ * [Parameters](#parameters-8)
62
+ * [setConnectionState](#setconnectionstate)
63
+ * [Parameters](#parameters-9)
64
+ * [didConnect](#didconnect)
65
+ * [Parameters](#parameters-10)
60
66
  * [isEndpoint](#isendpoint)
61
- * [Parameters](#parameters-8)
67
+ * [Parameters](#parameters-11)
62
68
  * [instanciateInterceptors](#instanciateinterceptors)
63
- * [Parameters](#parameters-9)
69
+ * [Parameters](#parameters-12)
64
70
  * [MultiConnectionEndpoint](#multiconnectionendpoint)
65
- * [Parameters](#parameters-10)
71
+ * [Parameters](#parameters-13)
66
72
  * [getConnectionState](#getconnectionstate-1)
67
- * [Parameters](#parameters-11)
73
+ * [Parameters](#parameters-14)
68
74
  * [setConnectionState](#setconnectionstate-1)
69
- * [Parameters](#parameters-12)
75
+ * [Parameters](#parameters-15)
76
+ * [removeConnection](#removeconnection-1)
77
+ * [Parameters](#parameters-16)
70
78
  * [isConnected](#isconnected-1)
71
- * [Parameters](#parameters-13)
79
+ * [Parameters](#parameters-17)
72
80
  * [connections](#connections-1)
73
81
  * [connections](#connections-2)
74
82
  * [MultiSendEndpoint](#multisendendpoint)
75
- * [Parameters](#parameters-14)
83
+ * [Parameters](#parameters-18)
76
84
  * [isOut](#isout-1)
77
85
  * [ReceivableEndpoint](#receivableendpoint)
78
- * [Parameters](#parameters-15)
86
+ * [Parameters](#parameters-19)
79
87
  * [isIn](#isin-2)
80
88
  * [receive](#receive-1)
81
89
  * [receive](#receive-2)
82
- * [Parameters](#parameters-16)
90
+ * [Parameters](#parameters-20)
83
91
  * [ReceiveEndpointDefault](#receiveendpointdefault)
84
92
  * [isDefault](#isdefault-1)
85
93
  * [ReceiveEndpointSelfConnectedDefault](#receiveendpointselfconnecteddefault)
86
- * [removeConnection](#removeconnection)
87
- * [Parameters](#parameters-17)
94
+ * [removeConnection](#removeconnection-2)
95
+ * [Parameters](#parameters-21)
88
96
  * [ReceiveEndpoint](#receiveendpoint)
89
- * [Parameters](#parameters-18)
97
+ * [Parameters](#parameters-22)
90
98
  * [isIn](#isin-3)
91
99
  * [SendEndpointDefault](#sendendpointdefault)
92
100
  * [isDefault](#isdefault-2)
93
101
  * [SendEndpoint](#sendendpoint)
94
- * [Parameters](#parameters-19)
102
+ * [Parameters](#parameters-23)
95
103
  * [isOut](#isout-2)
96
- * [isIn](#isin-4)
104
+ * [removeConnection](#removeconnection-3)
105
+ * [Parameters](#parameters-24)
106
+ * [SendReceiveEndpoint](#sendreceiveendpoint)
107
+ * [isIn](#isin-4)
97
108
 
98
109
  ## DummyReceiveEndpoint
99
110
 
@@ -134,9 +145,6 @@ Connection endpoint.
134
145
  * `owner` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** of the endpoint (service)
135
146
  * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
136
147
 
137
- * `options.didConnect` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** called after receiver is present
138
- * `options.interceptors` **(Interceptor | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)?** interceptors
139
-
140
148
  ### displayName
141
149
 
142
150
  Name as presented for humans.
@@ -244,7 +252,22 @@ Closes all connections.
244
252
 
245
253
  ### connections
246
254
 
247
- Returns **Iterable\<any>**&#x20;
255
+ Returns **Iterable<[Endpoint](#endpoint)>**&#x20;
256
+
257
+ ### addConnection
258
+
259
+ #### Parameters
260
+
261
+ * `connection` **[Endpoint](#endpoint)**&#x20;
262
+
263
+ ### removeConnection
264
+
265
+ Actually stop the communication.
266
+
267
+ #### Parameters
268
+
269
+ * `other` **[Endpoint](#endpoint)**&#x20;
270
+ * `backpointer` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** true if this is the call form back call from the other side
248
271
 
249
272
  ### getConnectionState
250
273
 
@@ -265,6 +288,13 @@ Set state for a given connection.
265
288
  * `other` **[Endpoint](#endpoint)**&#x20;
266
289
  * `state` **[ConnectionState](#connectionstate)**&#x20;
267
290
 
291
+ ### didConnect
292
+
293
+ #### Parameters
294
+
295
+ * `endpoint` **[Endpoint](#endpoint)**&#x20;
296
+ * `other` **[Endpoint](#endpoint)**&#x20;
297
+
268
298
  ## isEndpoint
269
299
 
270
300
  Check for Endpoint.
@@ -281,7 +311,7 @@ Instanciate interceptors from its definitions.
281
311
 
282
312
  ### Parameters
283
313
 
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;
314
+ * `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)> | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
285
315
  * `owner` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
286
316
 
287
317
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Interceptor>**&#x20;
@@ -318,6 +348,15 @@ Set connection state.
318
348
  * `other` **[Endpoint](#endpoint)**&#x20;
319
349
  * `state` **any** for the connection to other
320
350
 
351
+ ### removeConnection
352
+
353
+ Actually stop the communication.
354
+
355
+ #### Parameters
356
+
357
+ * `other` **[Endpoint](#endpoint)**&#x20;
358
+ * `backpointer` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** true if this is the call form back call from the other side
359
+
321
360
  ### isConnected
322
361
 
323
362
  Check connectivity.
@@ -475,7 +514,22 @@ We are always *out*
475
514
 
476
515
  Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** always true
477
516
 
478
- ## isIn
517
+ ### removeConnection
518
+
519
+ Actually stop the communication.
520
+
521
+ #### Parameters
522
+
523
+ * `other` **[Endpoint](#endpoint)**&#x20;
524
+ * `backpointer` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** true if this is the call form back call from the other side
525
+
526
+ ## SendReceiveEndpoint
527
+
528
+ **Extends SendEndpoint**
529
+
530
+ bi directional endpint
531
+
532
+ ### isIn
479
533
 
480
534
  Always receiving.
481
535
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/endpoint",
3
- "version": "9.5.2",
3
+ "version": "9.5.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -28,14 +28,15 @@
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 --rootDir src ./src**/*.mjs",
31
+ "prepare": "npm run prepare:typescript",
32
+ "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
32
33
  "test": "npm run test:ava",
33
34
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
34
35
  "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",
35
36
  "docs": "documentation readme --section=API ./src/**/*.mjs",
36
- "lint": "npm run lint:docs && npm run lint:tsc",
37
+ "lint": "npm run lint:docs && npm run lint:typescript",
37
38
  "lint:docs": "documentation lint ./src/**/*.mjs",
38
- "lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
39
+ "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
39
40
  },
40
41
  "dependencies": {
41
42
  "@kronos-integration/interceptor": "^10.3.0"
@@ -44,11 +45,11 @@
44
45
  "ava": "^6.1.2",
45
46
  "c8": "^9.1.0",
46
47
  "documentation": "^14.0.3",
47
- "semantic-release": "^23.0.2",
48
- "typescript": "^5.3.3"
48
+ "semantic-release": "^23.0.8",
49
+ "typescript": "^5.4.5"
49
50
  },
50
51
  "engines": {
51
- "node": ">=20.11.1"
52
+ "node": ">=20.12.2"
52
53
  },
53
54
  "repository": {
54
55
  "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 }) {
@@ -251,7 +254,7 @@ export class Endpoint {
251
254
  /**
252
255
  * Actually start with the communication.
253
256
  * @param {Endpoint} other
254
- * @param {boolean?} backpointer true if this is the call from back call from the other side
257
+ * @param {boolean} [backpointer] true if this is the call from back call from the other side
255
258
  */
256
259
  openConnection(other, backpointer) {
257
260
  if (other !== undefined) {
@@ -311,22 +314,28 @@ 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
321
  /**
319
- *
320
- * @param {any} connection
322
+ *
323
+ * @param {Endpoint} connection
324
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
321
325
  */
322
- addConnection(connection) {}
326
+ addConnection(connection, backpointer) {}
323
327
 
324
- removeConnection() {}
328
+ /**
329
+ * Actually stop the communication.
330
+ * @param {Endpoint} other
331
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
332
+ */
333
+ removeConnection(other, backpointer) {}
325
334
 
326
335
  /**
327
336
  * Deliver state for a given connection.
328
337
  * @param {Endpoint} other
329
- * @return {ConnectionState}
338
+ * @return {ConnectionState}
330
339
  */
331
340
  getConnectionState(other) {}
332
341
 
@@ -337,7 +346,12 @@ export class Endpoint {
337
346
  */
338
347
  setConnectionState(other, state) {}
339
348
 
340
- didConnect(a,b) {}
349
+ /**
350
+ *
351
+ * @param {Endpoint} endpoint
352
+ * @param {Endpoint} other
353
+ */
354
+ didConnect(endpoint, other) {}
341
355
 
342
356
  get receivingInterceptors() {
343
357
  return [];
@@ -355,7 +369,7 @@ export function isEndpoint(object) {
355
369
 
356
370
  /**
357
371
  * Instanciate interceptors from its definitions.
358
- * @param {Interceptor[]|string[]} interceptors
372
+ * @param {Interceptor[]|string[]|undefined} interceptors
359
373
  * @param {Object} owner
360
374
  * @return {Interceptor[]}
361
375
  */
@@ -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);
@@ -1,4 +1,4 @@
1
- import { isEndpoint, Endpoint} from "./endpoint.mjs";
1
+ import { isEndpoint, Endpoint } from "./endpoint.mjs";
2
2
  import { ReceivableEndpoint } from "./receivable-endpoint.mjs";
3
3
 
4
4
  /**
@@ -12,10 +12,9 @@ import { ReceivableEndpoint } from "./receivable-endpoint.mjs";
12
12
  * @param {Function} [options.didConnect] called after receiver is present
13
13
  */
14
14
  export class SendEndpoint extends ReceivableEndpoint {
15
-
16
15
  #connection;
17
16
  #state;
18
-
17
+
19
18
  constructor(name, owner, options) {
20
19
  super(name, owner, options);
21
20
  if (isEndpoint(options?.connected)) {
@@ -45,6 +44,11 @@ export class SendEndpoint extends ReceivableEndpoint {
45
44
  }
46
45
  }
47
46
 
47
+ /**
48
+ * Add a connection.
49
+ * @param {Endpoint} other
50
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
51
+ */
48
52
  addConnection(other, backpointer) {
49
53
  if (this.#connection === other) {
50
54
  return;
@@ -74,6 +78,11 @@ export class SendEndpoint extends ReceivableEndpoint {
74
78
  }
75
79
  }
76
80
 
81
+ /**
82
+ * Actually stop the communication.
83
+ * @param {Endpoint} other
84
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
85
+ */
77
86
  removeConnection(other, backpointer) {
78
87
  this.closeConnection(other);
79
88
 
@@ -6,27 +6,37 @@
6
6
  export function isEndpoint(object: any): boolean;
7
7
  /**
8
8
  * Instanciate interceptors from its definitions.
9
- * @param {Interceptor[]|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[] | 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
  /**
@@ -115,9 +125,9 @@ export class Endpoint {
115
125
  /**
116
126
  * Actually start with the communication.
117
127
  * @param {Endpoint} other
118
- * @param {boolean?} backpointer true if this is the call from back call from the other side
128
+ * @param {boolean} [backpointer] true if this is the call from back call from the other side
119
129
  */
120
- openConnection(other: Endpoint, backpointer: boolean | null): void;
130
+ openConnection(other: Endpoint, backpointer?: boolean): void;
121
131
  /**
122
132
  * Actually stop the communication.
123
133
  * @param {Endpoint} other
@@ -133,15 +143,21 @@ export class Endpoint {
133
143
  */
134
144
  closeConnections(): void;
135
145
  /**
136
- * @return {Iterable<any>}
146
+ * @return {Iterable<Endpoint>}
137
147
  */
138
- connections(): Iterable<any>;
148
+ connections(): Iterable<Endpoint>;
139
149
  /**
140
150
  *
141
- * @param {any} connection
151
+ * @param {Endpoint} connection
152
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
153
+ */
154
+ addConnection(connection: Endpoint, backpointer?: boolean): void;
155
+ /**
156
+ * Actually stop the communication.
157
+ * @param {Endpoint} other
158
+ * @param {boolean} [backpointer] true if this is the call form back call from the other side
142
159
  */
143
- addConnection(connection: any): void;
144
- removeConnection(): void;
160
+ removeConnection(other: Endpoint, backpointer?: boolean): void;
145
161
  /**
146
162
  * Deliver state for a given connection.
147
163
  * @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
@@ -11,8 +11,6 @@
11
11
  export class SendEndpoint extends ReceivableEndpoint {
12
12
  getConnectionState(other: any): any;
13
13
  setConnectionState(other: any, state: any): void;
14
- addConnection(other: any, backpointer: any): void;
15
- removeConnection(other: any, backpointer: any): void;
16
14
  connections(): Generator<any, void, unknown>;
17
15
  send(...args: any[]): Promise<any>;
18
16
  #private;