@kronos-integration/service 10.4.54 → 10.4.56

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023 darlenya & arlac77
1
+ Copyright (c) 2015-2024 darlenya & arlac77
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/@kronos-integration/service.svg)](https://www.npmjs.com/package/@kronos-integration/service)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
+ [![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
3
4
  [![bundlejs](https://deno.bundlejs.com/?q=@kronos-integration/service\&badge=detailed)](https://bundlejs.com/?q=@kronos-integration/service)
4
5
  [![downloads](http://img.shields.io/npm/dm/@kronos-integration/service.svg?style=flat-square)](https://npmjs.org/package/@kronos-integration/service)
5
6
  [![GitHub Issues](https://img.shields.io/github/issues/Kronos-Integration/service.svg?style=flat-square)](https://github.com/Kronos-Integration/service/issues)
@@ -82,9 +83,7 @@ Manages endpoints in a container.
82
83
 
83
84
  ### Parameters
84
85
 
85
- * `superclass` **Class** class to be extended
86
-
87
- Returns **Class** extended class
86
+ * `superclass`  
88
87
 
89
88
  ## endpoints
90
89
 
@@ -97,8 +96,8 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
97
96
  **Extends Service**
98
97
 
99
98
  Config providing service.
100
- Dispatches config requests to services;
101
- or preserves them until a maching service becomes avaliable.
99
+ Dispatches config requests to services.
100
+ Also preserves them until a maching service becomes avaliable.
102
101
 
103
102
  ### Properties
104
103
 
@@ -111,7 +110,7 @@ Deliver configuration for a given service.
111
110
  #### Parameters
112
111
 
113
112
  * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** service name
114
- * `config` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
113
+ * `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
115
114
 
116
115
  ### clearPreserved
117
116
 
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "10.4.54",
3
+ "version": "10.4.56",
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "provenance": true
6
7
  },
7
8
  "exports": {
8
9
  ".": "./src/module.mjs"
@@ -24,29 +25,31 @@
24
25
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
25
26
  "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",
26
27
  "docs": "documentation readme --section=API ./src/**/*.mjs",
27
- "lint": "npm run lint:docs",
28
- "lint:docs": "documentation lint ./src/**/*.mjs"
28
+ "lint": "npm run lint:docs && npm run lint:tsc",
29
+ "lint:docs": "documentation lint ./src/**/*.mjs",
30
+ "lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
29
31
  },
30
32
  "dependencies": {
31
- "@kronos-integration/endpoint": "^9.4.44",
32
- "@kronos-integration/interceptor": "^10.2.37",
33
- "loglevel-mixin": "^7.1.0",
33
+ "@kronos-integration/endpoint": "^9.5.0",
34
+ "@kronos-integration/interceptor": "^10.2.38",
35
+ "loglevel-mixin": "^7.2.1",
34
36
  "model-attributes": "^4.2.2",
35
- "remove-sensible-values": "^1.2.3",
36
- "statetransition-mixin": "^8.0.5"
37
+ "remove-sensible-values": "^1.3.1",
38
+ "statetransition-mixin": "^8.1.0"
37
39
  },
38
40
  "devDependencies": {
39
- "ava": "^6.0.1",
40
- "c8": "^8.0.1",
41
- "documentation": "^14.0.2",
42
- "semantic-release": "^22.0.10"
41
+ "ava": "^6.1.1",
42
+ "c8": "^9.1.0",
43
+ "documentation": "^14.0.3",
44
+ "semantic-release": "^23.0.2",
45
+ "typescript": "^5.3.3"
43
46
  },
44
47
  "engines": {
45
- "node": ">=20.10.0"
48
+ "node": ">=20.11.0"
46
49
  },
47
50
  "repository": {
48
51
  "type": "git",
49
- "url": "https://github.com/Kronos-Integration/service"
52
+ "url": "git+https://github.com/Kronos-Integration/service.git"
50
53
  },
51
54
  "bugs": {
52
55
  "url": "https://github.com/Kronos-Integration/service/issues"
@@ -55,7 +58,8 @@
55
58
  "template": {
56
59
  "inheritFrom": [
57
60
  "arlac77/template-arlac77-github",
58
- "arlac77/template-kronos-component"
61
+ "arlac77/template-kronos-component",
62
+ "arlac77/template-typescript"
59
63
  ]
60
64
  }
61
65
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Endpoint,
2
3
  SendEndpoint,
3
4
  SendEndpointDefault,
4
5
  SendReceiveEndpoint,
@@ -7,12 +8,13 @@ import {
7
8
  ReceiveEndpointDefault,
8
9
  ReceiveEndpointSelfConnectedDefault
9
10
  } from "@kronos-integration/endpoint";
11
+ import { InitializationContext } from "./initialization-context.mjs";
10
12
 
11
13
  /**
12
14
  * Endpoint accessor mixin.
13
15
  * Manages endpoints in a container.
14
- * @param {Class} superclass class to be extended
15
- * @return {Class} extended class
16
+ * @param {new() => superclass} superclass class to be extended
17
+ * @return {new() => superclass} extended class
16
18
  */
17
19
  export function EndpointsMixin(superclass) {
18
20
  return class EndpointsMixin extends superclass {
@@ -41,6 +43,7 @@ export function EndpointsMixin(superclass) {
41
43
  * @param {string} name of the endpoint
42
44
  * @param {Object} definition endpoints definition
43
45
  * @param {string|Function} definition.receive name of method or property
46
+ * @param {Endpoint} definition.connected
44
47
  * @param {InitializationContext} ic
45
48
  * @return {Object} suitable to pass as options to the endpoint factory
46
49
  */
@@ -75,6 +78,8 @@ export function EndpointsMixin(superclass) {
75
78
  * @param {any} definition.receive defined will result in a ReceiveEndpoint
76
79
  * @param {boolean} definition.out true will result in a SendEndpoint
77
80
  * @param {boolean} definition.default true will result in a (Send|Receive)DefaultEndpoint
81
+ * @param {boolean} definition.multi true will result in a MultiSendEndpoint
82
+ * @param {Endpoint[]|string} definition.connected true will result in a MultiSendEndpoint
78
83
  * @param {InitializationContext} ic
79
84
  * @return {Object} endpoint factory
80
85
  */
@@ -21,9 +21,9 @@ export const InitializationContext = LogLevelMixin(
21
21
  */
22
22
  class InitializationContext {
23
23
 
24
- outstandingServices = new Map();
25
- outstandingFactories = new Map();
26
- outstandingEndpointConnections = new Map();
24
+ /** @type {Map<string,Promise<Service>>} */ outstandingServices = new Map();
25
+ /** @type {Map<string,Promise<Function>>} */ outstandingFactories = new Map();
26
+ /** @type {Map<string,Promise<Endpoint>>} */ outstandingEndpointConnections = new Map();
27
27
 
28
28
  constructor(serviceProvider, options) {
29
29
  this.serviceProvider = serviceProvider;
@@ -32,7 +32,7 @@ export const InitializationContext = LogLevelMixin(
32
32
  /**
33
33
  * Forward to the serviceProvider.
34
34
  * @param {string} level the log level
35
- * @param {Object} arg log content
35
+ * @param {Object} args log content
36
36
  */
37
37
  log(level, ...args) {
38
38
  if (this.serviceProvider) {
@@ -162,7 +162,7 @@ export const InitializationContext = LogLevelMixin(
162
162
 
163
163
  /**
164
164
  *
165
- * @param {string|class} type name if type
165
+ * @param {string|(new() => type)} type name if type
166
166
  */
167
167
  async getServiceFactory(type) {
168
168
  const sp = this.serviceProvider;
@@ -230,7 +230,7 @@ export const InitializationContext = LogLevelMixin(
230
230
  * - otherwise declare this action as a new outstanding service declaration
231
231
  * @param {Object} config
232
232
  * @param {string} name service name
233
- * @return {Service}
233
+ * @return {Promise<Service|undefined>}
234
234
  */
235
235
  async declareService(config, name) {
236
236
  const sp = this.serviceProvider;
@@ -4,8 +4,8 @@ import { keyValue2Object } from "./util.mjs";
4
4
 
5
5
  /**
6
6
  * Config providing service.
7
- * Dispatches config requests to services;
8
- * or preserves them until a maching service becomes avaliable.
7
+ * Dispatches config requests to services.
8
+ * Also preserves them until a maching service becomes avaliable.
9
9
  * @property {Map<string,Object>} preservedConfigs values for services not already established
10
10
  */
11
11
  export class ServiceConfig extends Service {
@@ -25,7 +25,7 @@ export class ServiceConfig extends Service {
25
25
  /**
26
26
  * Deliver configuration for a given service.
27
27
  * @param {string} name service name
28
- * @param {object} config
28
+ * @param {Object} config
29
29
  */
30
30
  async configFor(name, config) {
31
31
  this.trace(`configFor ${name}`);
@@ -9,8 +9,8 @@ import { InitializationContext } from "./initialization-context.mjs";
9
9
  * By default a service provider has two build in services
10
10
  * 'logger' and 'config'.
11
11
  *
12
- * @param {Class} serviceLoggerClass where the logging houtd go
13
- * @param {Class} serviceConfigClass where the config comes from
12
+ * @param {new(Object,InitializationContext) => serviceLoggerClass} serviceLoggerClass where the logging houtd go
13
+ * @param {new(Object,InitializationContext) => serviceConfigClass} serviceConfigClass where the config comes from
14
14
  */
15
15
  export function ServiceProviderMixin(
16
16
  superclass,
@@ -106,8 +106,8 @@ export function ServiceProviderMixin(
106
106
  * Registers a interceptor factory for later use by
107
107
  * @see {instantiateInterceptor}.
108
108
  *
109
- * @param {Class} factory
110
- * @returns {Class} factory
109
+ * @param {new() => factory} factory
110
+ * @returns {new() => factory} factory
111
111
  */
112
112
  registerInterceptorFactory(factory) {
113
113
  this.interceptorFactories[factory.name] = factory;
@@ -181,7 +181,7 @@ export function ServiceProviderMixin(
181
181
  * If a service for the name is already present and it has a matching type
182
182
  * then its configure() is called and returned.
183
183
  * Otherwise a new service will be created eventually replacing an already existing service with the same name.
184
- * @param {object} config with
184
+ * @param {object} configs with
185
185
  * name - the service name
186
186
  * type - the service factory name - defaults to config.name
187
187
  * @return {Promise<Object>} resolving to the declared services
package/src/service.mjs CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  setAttributes
7
7
  } from "model-attributes";
8
8
  import { EndpointsMixin } from "./endpoints-mixin.mjs";
9
+ import { InitializationContext } from "./initialization-context.mjs";
9
10
 
10
11
  const _ca = createAttributes({
11
12
  description: {
@@ -78,6 +79,8 @@ const ssfDefault = {
78
79
  * @param {string} config.description human readable description
79
80
  * @param {Object} config.endpoints will be merged with the build in ones
80
81
  * @param {InitializationContext} ic
82
+ *
83
+ * @property {Object} endpoints
81
84
  */
82
85
  export class Service extends EndpointsMixin(
83
86
  StateTransitionMixin(