@kronos-integration/service 11.2.1 → 11.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "11.2.1",
3
+ "version": "11.2.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -54,15 +54,17 @@ export function EndpointsMixin(superclass) {
54
54
  const receive = definition.receive;
55
55
 
56
56
  if (typeof receive === "string") {
57
- if (typeof this[receive] === "function") {
58
- definition.receive = (...args) => this[receive](...args);
59
- } else {
60
- if (this[receive] === undefined) {
61
- throw new Error(
62
- `No sucht method or property ${this.name}.${receive}`
63
- );
64
- }
65
- definition.receive = () => this[receive];
57
+ switch(typeof this[receive]) {
58
+ case "function":
59
+ definition.receive = (...args) => this[receive](...args);
60
+ break;
61
+ default:
62
+ definition.receive = () => this[receive];
63
+ break;
64
+ case "undefined":
65
+ throw new Error(
66
+ `No sucht method or property ${this.name}.${receive}`
67
+ );
66
68
  }
67
69
  }
68
70
  }
@@ -193,9 +195,7 @@ export function EndpointsMixin(superclass) {
193
195
  const serviceProvider = this.owner;
194
196
  const service = serviceName.length === 0 ? serviceProvider : serviceProvider.getService(serviceName);
195
197
 
196
- return service
197
- ? service.endpointForExpression(suffixExpression)
198
- : undefined;
198
+ return service?.endpointForExpression(suffixExpression);
199
199
  }
200
200
 
201
201
  if (from !== undefined) {
package/src/service.mjs CHANGED
@@ -79,7 +79,7 @@ const ssfDefault = {
79
79
  * @param {string} config.description human readable description
80
80
  * @param {Object} config.endpoints will be merged with the build in ones
81
81
  * @param {InitializationContext} ic
82
- *
82
+ *
83
83
  * @property {Object} endpoints
84
84
  */
85
85
  export class Service extends EndpointsMixin(
@@ -368,16 +368,13 @@ export class Service extends EndpointsMixin(
368
368
  Object.assign(json, atts);
369
369
  }
370
370
 
371
- for (const endpointName in this.endpoints) {
372
- const ep = this.endpoints[endpointName];
373
-
374
- function add(ep) {
371
+ for (const [endpointName, ep] of Object.entries(this.endpoints)) {
372
+ const add = ep => {
375
373
  if (json.endpoints === undefined) {
376
374
  json.endpoints = {};
377
375
  }
378
376
  json.endpoints[endpointName] = ep.toJSONWithOptions(options);
379
- }
380
-
377
+ };
381
378
  if (ep.isDefault) {
382
379
  if (options.includeDefaults) {
383
380
  add(ep);