@hahnpro/flow-sdk 4.19.1 → 4.20.0

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,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Hahn PRO
3
+ Copyright (c) 2021 Hahn PRO
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # `@hahnpro/flow-sdk`
2
2
 
3
- https://gitlab.com/hahnpro/flow
3
+ https://github.com/hahnprojects/flow
@@ -62,7 +62,7 @@ class FlowElement {
62
62
  }
63
63
  }
64
64
  validateProperties(classType, properties = {}, whitelist = false) {
65
- const props = (0, class_transformer_1.plainToClass)(classType, properties);
65
+ const props = (0, class_transformer_1.plainToInstance)(classType, properties);
66
66
  const errors = (0, class_validator_1.validateSync)(props, { whitelist });
67
67
  if (Array.isArray(errors) && errors.length > 0) {
68
68
  for (const e of errors) {
@@ -8,16 +8,19 @@ export interface Logger {
8
8
  verbose(message: any, metadata?: any): void;
9
9
  }
10
10
  export declare const defaultLogger: Logger;
11
+ export interface LoggerOptions {
12
+ truncate: boolean;
13
+ }
11
14
  export declare class FlowLogger implements Logger {
12
15
  private readonly metadata;
13
16
  private readonly logger;
14
17
  private readonly publishEvent?;
15
18
  private static getStackTrace;
16
19
  constructor(metadata: FlowElementContext, logger?: Logger, publishEvent?: (event: FlowEvent) => Promise<void>);
17
- debug: (message: any) => void;
18
- error: (message: any) => void;
19
- log: (message: any) => void;
20
- warn: (message: any) => void;
21
- verbose: (message: any) => void;
20
+ debug: (message: any, options?: LoggerOptions) => void;
21
+ error: (message: any, options?: LoggerOptions) => void;
22
+ log: (message: any, options?: LoggerOptions) => void;
23
+ warn: (message: any, options?: LoggerOptions) => void;
24
+ verbose: (message: any, options?: LoggerOptions) => void;
22
25
  private publish;
23
26
  }
@@ -14,11 +14,11 @@ class FlowLogger {
14
14
  this.metadata = metadata;
15
15
  this.logger = logger;
16
16
  this.publishEvent = publishEvent;
17
- this.debug = (message) => this.publish(message, 'debug');
18
- this.error = (message) => this.publish(message, 'error');
19
- this.log = (message) => this.publish(message, 'info');
20
- this.warn = (message) => this.publish(message, 'warn');
21
- this.verbose = (message) => this.publish(message, 'verbose');
17
+ this.debug = (message, options) => this.publish(message, 'debug', options);
18
+ this.error = (message, options) => this.publish(message, 'error', options);
19
+ this.log = (message, options) => this.publish(message, 'info', options);
20
+ this.warn = (message, options) => this.publish(message, 'warn', options);
21
+ this.verbose = (message, options) => this.publish(message, 'verbose', options);
22
22
  }
23
23
  static getStackTrace() {
24
24
  let stack;
@@ -34,7 +34,7 @@ class FlowLogger {
34
34
  .filter((value) => !value.includes('Logger'));
35
35
  return stack.splice(1).join('\n');
36
36
  }
37
- publish(message, level) {
37
+ publish(message, level, options) {
38
38
  var _a;
39
39
  if (this.publishEvent) {
40
40
  const event = new FlowEvent_1.FlowEvent(this.metadata, message, `flow.log.${level}`);
@@ -42,15 +42,15 @@ class FlowLogger {
42
42
  }
43
43
  switch (level) {
44
44
  case 'debug':
45
- return this.logger.debug(message, this.metadata);
45
+ return this.logger.debug(message, Object.assign(Object.assign({}, this.metadata), options));
46
46
  case 'error':
47
- return this.logger.error(message, this.metadata);
47
+ return this.logger.error(message, Object.assign(Object.assign({}, this.metadata), options));
48
48
  case 'warn':
49
- return this.logger.warn(message, this.metadata);
49
+ return this.logger.warn(message, Object.assign(Object.assign({}, this.metadata), options));
50
50
  case 'verbose':
51
- return this.logger.verbose(message, this.metadata);
51
+ return this.logger.verbose(message, Object.assign(Object.assign({}, this.metadata), options));
52
52
  default:
53
- this.logger.log(message, this.metadata);
53
+ this.logger.log(message, Object.assign(Object.assign({}, this.metadata), options));
54
54
  }
55
55
  }
56
56
  }
@@ -6,8 +6,9 @@ const class_validator_1 = require("class-validator");
6
6
  const units_1 = require("./units");
7
7
  function makeUnitDecorator(unit, metric, validationOptions) {
8
8
  const conversionFactor = verifyUnit(unit, metric);
9
- if (conversionFactor < 0)
10
- throw `${unit} is not a valid ${metric}.`;
9
+ if (conversionFactor < 0) {
10
+ throw new Error(`${unit} is not a valid ${metric}.`);
11
+ }
11
12
  return (object, propertyName) => {
12
13
  Reflect.defineMetadata(`conversionFactor:${propertyName}`, conversionFactor, object.constructor);
13
14
  (0, class_validator_1.registerDecorator)({
@@ -118,7 +119,7 @@ function computeIndices(unit, dimensions) {
118
119
  }
119
120
  function computeUnitOptions(dimension) {
120
121
  const definition = units_1.units[units_1.dimensionToUnitMap[dimension.substring(0, 1)]];
121
- const exponent = dimension.length === 1 ? 1 : Number.parseInt(dimension.substring(dimension.length - 1));
122
+ const exponent = dimension.length === 1 ? 1 : Number.parseInt(dimension.substring(dimension.length - 1), 10);
122
123
  const withPrefixes = definition.units
123
124
  .filter((unit) => unit.SIPrefixes)
124
125
  .map((unit) => prefixes.map((prefix) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/flow-sdk",
3
- "version": "4.19.1",
3
+ "version": "4.20.0",
4
4
  "description": "SDK for building Flow Modules",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git@gitlab.com:hahnpro/flow.git"
12
+ "url": "git@github.com:hahnprojects/flow.git"
13
13
  },
14
14
  "directories": {
15
15
  "lib": "lib",
@@ -24,13 +24,13 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@hahnpro/hpc-api": "1.0.1",
27
+ "@hahnpro/hpc-api": "1.1.0",
28
28
  "amqp-connection-manager": "^3.7.0",
29
29
  "amqplib": "^0.8.0",
30
- "class-transformer": "0.4.0",
31
- "class-validator": "~0.13.1",
30
+ "class-transformer": "0.5.1",
31
+ "class-validator": "~0.13.2",
32
32
  "class-validator-jsonschema": "^3.1.0",
33
- "cloudevents": "^5.0.0",
33
+ "cloudevents": "^5.2.0",
34
34
  "lodash": "^4.17.21",
35
35
  "object-sizeof": "^1.6.1",
36
36
  "python-shell": "^3.0.1",
@@ -40,17 +40,17 @@
40
40
  "uuid": "^8.3.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@golevelup/nestjs-rabbitmq": "^1.18.0",
43
+ "@golevelup/nestjs-rabbitmq": "^1.18.1",
44
44
  "@types/amqp-connection-manager": "^2.0.12",
45
45
  "@types/amqplib": "^0.8.2",
46
- "@types/jest": "^27.0.2",
47
- "@types/lodash": "^4.14.175",
48
- "@types/node": "^14.17.22",
49
- "jest": "^27.2.5",
50
- "typescript": "^4.4.4"
46
+ "@types/jest": "^27.0.3",
47
+ "@types/lodash": "^4.14.178",
48
+ "@types/node": "^16.11.12",
49
+ "jest": "^27.4.4",
50
+ "typescript": "^4.5.3"
51
51
  },
52
52
  "engines": {
53
- "node": ">=v14.13"
53
+ "node": "^14.13.1 || >=16.0.0"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "../../node_modules/.bin/tsc -p tsconfig.lib.json",