@hahnpro/flow-sdk 6.0.2 → 7.0.1
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/dist/FlowApplication.d.ts +7 -1
- package/dist/FlowApplication.js +25 -4
- package/dist/FlowElement.d.ts +1 -0
- package/dist/FlowElement.js +6 -3
- package/dist/FlowModule.js +1 -2
- package/dist/amqp.js +1 -2
- package/dist/extra-validators.js +1 -2
- package/dist/nats.d.ts +2 -0
- package/dist/nats.js +30 -0
- package/dist/unit-decorators.js +38 -39
- package/dist/unit-utils.js +3 -4
- package/dist/utils.js +8 -9
- package/package.json +9 -8
|
@@ -8,10 +8,13 @@ import { ClassType, Flow, FlowElementContext } from './flow.interface';
|
|
|
8
8
|
import { FlowEvent } from './FlowEvent';
|
|
9
9
|
import { Logger } from './FlowLogger';
|
|
10
10
|
import { RpcClient } from './RpcClient';
|
|
11
|
+
import { NatsConnection, ConnectionOptions as NatsConnectionOptions } from 'nats';
|
|
11
12
|
interface FlowAppConfig {
|
|
12
13
|
logger?: Logger;
|
|
13
14
|
amqpConfig?: AmqpConnectionConfig;
|
|
14
15
|
amqpConnection?: AmqpConnectionManager;
|
|
16
|
+
natsConfig?: NatsConnectionOptions;
|
|
17
|
+
natsConnection?: NatsConnection;
|
|
15
18
|
apiClient?: HttpClient;
|
|
16
19
|
skipApi?: boolean;
|
|
17
20
|
explicitInit?: boolean;
|
|
@@ -24,6 +27,8 @@ export declare class FlowApplication {
|
|
|
24
27
|
private _rpcClient;
|
|
25
28
|
private amqpChannel;
|
|
26
29
|
private readonly amqpConnection;
|
|
30
|
+
private readonly natsConnectionConfig?;
|
|
31
|
+
private _natsConnection?;
|
|
27
32
|
private readonly baseLogger;
|
|
28
33
|
private context;
|
|
29
34
|
private declarations;
|
|
@@ -37,9 +42,10 @@ export declare class FlowApplication {
|
|
|
37
42
|
private readonly skipApi;
|
|
38
43
|
private readonly apiClient?;
|
|
39
44
|
constructor(modules: ClassType<any>[], flow: Flow, config?: FlowAppConfig);
|
|
40
|
-
constructor(modules: ClassType<any>[], flow: Flow, baseLogger?: Logger, amqpConnection?: AmqpConnection, skipApi?: boolean, explicitInit?: boolean);
|
|
45
|
+
constructor(modules: ClassType<any>[], flow: Flow, baseLogger?: Logger, amqpConnection?: AmqpConnection, natsConnection?: NatsConnection, skipApi?: boolean, explicitInit?: boolean);
|
|
41
46
|
get rpcClient(): RpcClient;
|
|
42
47
|
get api(): API;
|
|
48
|
+
get natsConnection(): NatsConnection;
|
|
43
49
|
init(): Promise<void>;
|
|
44
50
|
private publishLifecycleEvent;
|
|
45
51
|
private setQueueMetrics;
|
package/dist/FlowApplication.js
CHANGED
|
@@ -15,11 +15,12 @@ const flow_interface_1 = require("./flow.interface");
|
|
|
15
15
|
const FlowLogger_1 = require("./FlowLogger");
|
|
16
16
|
const RpcClient_1 = require("./RpcClient");
|
|
17
17
|
const utils_1 = require("./utils");
|
|
18
|
+
const nats_1 = require("./nats");
|
|
18
19
|
const MAX_EVENT_SIZE_BYTES = +process.env.MAX_EVENT_SIZE_BYTES || 512 * 1024;
|
|
19
20
|
const WARN_EVENT_PROCESSING_SEC = +process.env.WARN_EVENT_PROCESSING_SEC || 60;
|
|
20
21
|
const WARN_EVENT_QUEUE_SIZE = +process.env.WARN_EVENT_QUEUE_SIZE || 100;
|
|
21
22
|
class FlowApplication {
|
|
22
|
-
constructor(modules, flow, baseLoggerOrConfig, amqpConnection, skipApi, explicitInit, mockApi) {
|
|
23
|
+
constructor(modules, flow, baseLoggerOrConfig, amqpConnection, natsConnection, skipApi, explicitInit, mockApi) {
|
|
23
24
|
this.modules = modules;
|
|
24
25
|
this.flow = flow;
|
|
25
26
|
this.declarations = {};
|
|
@@ -207,6 +208,8 @@ class FlowApplication {
|
|
|
207
208
|
const config = baseLoggerOrConfig;
|
|
208
209
|
this.baseLogger = config.logger;
|
|
209
210
|
this.amqpConnection = config.amqpConnection || (0, amqp_1.createAmqpConnection)(config.amqpConfig);
|
|
211
|
+
this.natsConnectionConfig = config.natsConfig;
|
|
212
|
+
this._natsConnection = config.natsConnection;
|
|
210
213
|
this.skipApi = config.skipApi || false;
|
|
211
214
|
explicitInit = config.explicitInit || false;
|
|
212
215
|
this._api = config.mockApi || null;
|
|
@@ -215,6 +218,7 @@ class FlowApplication {
|
|
|
215
218
|
else {
|
|
216
219
|
this.baseLogger = baseLoggerOrConfig;
|
|
217
220
|
this.amqpConnection = amqpConnection?.managedConnection;
|
|
221
|
+
this._natsConnection = natsConnection;
|
|
218
222
|
this.skipApi = skipApi || false;
|
|
219
223
|
explicitInit = explicitInit || false;
|
|
220
224
|
this._api = mockApi || null;
|
|
@@ -246,6 +250,9 @@ class FlowApplication {
|
|
|
246
250
|
get api() {
|
|
247
251
|
return this._api;
|
|
248
252
|
}
|
|
253
|
+
get natsConnection() {
|
|
254
|
+
return this._natsConnection;
|
|
255
|
+
}
|
|
249
256
|
async init() {
|
|
250
257
|
if (this.initialized)
|
|
251
258
|
return;
|
|
@@ -263,6 +270,14 @@ class FlowApplication {
|
|
|
263
270
|
this.logger.error(new Error(err));
|
|
264
271
|
await this.destroy(1);
|
|
265
272
|
};
|
|
273
|
+
if (!this._natsConnection && this.natsConnectionConfig) {
|
|
274
|
+
try {
|
|
275
|
+
this._natsConnection = await (0, nats_1.createNatsConnection)(this.natsConnectionConfig);
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
await logErrorAndExit(`Could not connect to the NATS-Servers: ${err}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
266
281
|
this.amqpChannel = this.amqpConnection?.createChannel({
|
|
267
282
|
json: true,
|
|
268
283
|
setup: async (channel) => {
|
|
@@ -284,7 +299,9 @@ class FlowApplication {
|
|
|
284
299
|
}
|
|
285
300
|
},
|
|
286
301
|
});
|
|
287
|
-
|
|
302
|
+
if (this.amqpChannel) {
|
|
303
|
+
await this.amqpChannel.waitForConnect();
|
|
304
|
+
}
|
|
288
305
|
for (const module of this.modules) {
|
|
289
306
|
const moduleName = Reflect.getMetadata('module:name', module);
|
|
290
307
|
const moduleDeclarations = Reflect.getMetadata('module:declarations', module);
|
|
@@ -379,13 +396,17 @@ class FlowApplication {
|
|
|
379
396
|
for (const element of Object.values(this.elements)) {
|
|
380
397
|
element?.onDestroy?.();
|
|
381
398
|
}
|
|
382
|
-
|
|
399
|
+
if (this._rpcClient) {
|
|
400
|
+
await this._rpcClient.close();
|
|
401
|
+
}
|
|
383
402
|
}
|
|
384
403
|
catch (err) {
|
|
385
404
|
this.logger.error(err);
|
|
386
405
|
}
|
|
387
406
|
await (0, utils_1.delay)(250);
|
|
388
|
-
|
|
407
|
+
if (this.amqpConnection) {
|
|
408
|
+
await this.amqpConnection.close();
|
|
409
|
+
}
|
|
389
410
|
}
|
|
390
411
|
catch (err) {
|
|
391
412
|
console.error(err);
|
package/dist/FlowElement.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare abstract class FlowElement<T = any> {
|
|
|
17
17
|
private stopPropagateStream;
|
|
18
18
|
constructor({ app, logger, ...metadata }: Context, properties?: unknown, propertiesClassType?: ClassType<T>, whitelist?: boolean);
|
|
19
19
|
get flowProperties(): Record<string, any>;
|
|
20
|
+
get natsConnection(): import("nats").NatsConnection;
|
|
20
21
|
onDestroy?: () => void;
|
|
21
22
|
onMessage?: (message: DeploymentMessage) => void;
|
|
22
23
|
onFlowPropertiesChanged?: (properties: Record<string, any>) => void;
|
package/dist/FlowElement.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowDashboard = exports.FlowTrigger = exports.FlowTask = exports.FlowResource = exports.
|
|
3
|
+
exports.FlowDashboard = exports.FlowTrigger = exports.FlowTask = exports.FlowResource = exports.FlowElement = void 0;
|
|
4
|
+
exports.InputStream = InputStream;
|
|
5
|
+
exports.FlowFunction = FlowFunction;
|
|
4
6
|
const class_transformer_1 = require("class-transformer");
|
|
5
7
|
const class_validator_1 = require("class-validator");
|
|
6
8
|
const python_shell_1 = require("python-shell");
|
|
@@ -41,6 +43,9 @@ class FlowElement {
|
|
|
41
43
|
get flowProperties() {
|
|
42
44
|
return this.app?.getProperties?.() || {};
|
|
43
45
|
}
|
|
46
|
+
get natsConnection() {
|
|
47
|
+
return this.app?.natsConnection;
|
|
48
|
+
}
|
|
44
49
|
emitOutput(data = {}, outputId = 'default', time = new Date()) {
|
|
45
50
|
return this.emitEvent(data, null, outputId, time);
|
|
46
51
|
}
|
|
@@ -122,7 +127,6 @@ function InputStream(id = 'default', options) {
|
|
|
122
127
|
};
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
|
-
exports.InputStream = InputStream;
|
|
126
130
|
function FlowFunction(fqn) {
|
|
127
131
|
const fqnRegExp = /^([a-zA-Z][a-zA-Z\d]*[.-])*[a-zA-Z][a-zA-Z\d]*$/;
|
|
128
132
|
if (!fqnRegExp.test(fqn)) {
|
|
@@ -133,7 +137,6 @@ function FlowFunction(fqn) {
|
|
|
133
137
|
target.prototype.functionFqn = fqn;
|
|
134
138
|
};
|
|
135
139
|
}
|
|
136
|
-
exports.FlowFunction = FlowFunction;
|
|
137
140
|
class FlowResource extends FlowElement {
|
|
138
141
|
}
|
|
139
142
|
exports.FlowResource = FlowResource;
|
package/dist/FlowModule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowModule =
|
|
3
|
+
exports.FlowModule = FlowModule;
|
|
4
4
|
function FlowModule(metadata) {
|
|
5
5
|
const validateNameRegExp = new RegExp(/^(@[a-z][a-z0-9-]*\/)?[a-z][a-z0-9-]*$/);
|
|
6
6
|
if (!validateNameRegExp.test(metadata.name)) {
|
|
@@ -11,4 +11,3 @@ function FlowModule(metadata) {
|
|
|
11
11
|
Reflect.defineMetadata('module:declarations', metadata.declarations, target);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
exports.FlowModule = FlowModule;
|
package/dist/amqp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAmqpConnection =
|
|
3
|
+
exports.createAmqpConnection = createAmqpConnection;
|
|
4
4
|
const amqp_connection_manager_1 = require("amqp-connection-manager");
|
|
5
5
|
function createAmqpConnection(config) {
|
|
6
6
|
if (!config) {
|
|
@@ -10,4 +10,3 @@ function createAmqpConnection(config) {
|
|
|
10
10
|
const uri = `${protocol}://${user}:${password}@${hostname}:${port}${vhost ? '/' + vhost : ''}`;
|
|
11
11
|
return (0, amqp_connection_manager_1.connect)(uri);
|
|
12
12
|
}
|
|
13
|
-
exports.createAmqpConnection = createAmqpConnection;
|
package/dist/extra-validators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IncompatableWith =
|
|
3
|
+
exports.IncompatableWith = IncompatableWith;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const class_validator_1 = require("class-validator");
|
|
6
6
|
let IsNotSiblingOfConstraint = class IsNotSiblingOfConstraint {
|
|
@@ -49,4 +49,3 @@ function IncompatableWith(incompatibleSiblings) {
|
|
|
49
49
|
validateIf(target, key);
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
exports.IncompatableWith = IncompatableWith;
|
package/dist/nats.d.ts
ADDED
package/dist/nats.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNatsConnection = createNatsConnection;
|
|
4
|
+
const nats_1 = require("nats");
|
|
5
|
+
async function createNatsConnection(config) {
|
|
6
|
+
const servers = config?.servers ?? process.env.NATS_SERVERS?.split(',') ?? [];
|
|
7
|
+
const reconnect = config?.reconnect ?? (process.env.NATS_RECONNECT ?? 'true') === 'true';
|
|
8
|
+
let maxReconnectAttempts = config?.maxReconnectAttempts ?? parseInt(process.env.NATS_MAX_RECONNECT_ATTEMPTS ?? '10', 10);
|
|
9
|
+
if (isNaN(maxReconnectAttempts)) {
|
|
10
|
+
maxReconnectAttempts = 10;
|
|
11
|
+
}
|
|
12
|
+
let reconnectTimeWait = config?.reconnectTimeWait ?? parseInt(process.env.NATS_RECONNECT_TIME_WAIT ?? '2000', 10);
|
|
13
|
+
if (isNaN(reconnectTimeWait)) {
|
|
14
|
+
reconnectTimeWait = 2000;
|
|
15
|
+
}
|
|
16
|
+
let timeout = config?.timeout ?? parseInt(process.env.NATS_TIMEOUT ?? '2000', 10);
|
|
17
|
+
if (isNaN(timeout)) {
|
|
18
|
+
timeout = 2000;
|
|
19
|
+
}
|
|
20
|
+
const options = {
|
|
21
|
+
servers,
|
|
22
|
+
reconnect,
|
|
23
|
+
maxReconnectAttempts,
|
|
24
|
+
reconnectTimeWait,
|
|
25
|
+
timeout,
|
|
26
|
+
user: config?.user ?? process.env.NATS_USER,
|
|
27
|
+
pass: config.pass ?? process.env.NATS_PASSWORD,
|
|
28
|
+
};
|
|
29
|
+
return (0, nats_1.connect)(options);
|
|
30
|
+
}
|
package/dist/unit-decorators.js
CHANGED
|
@@ -1,157 +1,156 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IsTime = IsTime;
|
|
4
|
+
exports.IsLength = IsLength;
|
|
5
|
+
exports.IsMass = IsMass;
|
|
6
|
+
exports.IsElectricCurrent = IsElectricCurrent;
|
|
7
|
+
exports.IsThermodynamicTemperature = IsThermodynamicTemperature;
|
|
8
|
+
exports.IsAmountOfSubstance = IsAmountOfSubstance;
|
|
9
|
+
exports.IsLuminousIntensity = IsLuminousIntensity;
|
|
10
|
+
exports.IsVoltage = IsVoltage;
|
|
11
|
+
exports.IsForce = IsForce;
|
|
12
|
+
exports.IsEnergy = IsEnergy;
|
|
13
|
+
exports.IsPower = IsPower;
|
|
14
|
+
exports.IsPressure = IsPressure;
|
|
15
|
+
exports.IsFrequency = IsFrequency;
|
|
16
|
+
exports.IsArea = IsArea;
|
|
17
|
+
exports.IsVolume = IsVolume;
|
|
18
|
+
exports.IsAngle = IsAngle;
|
|
19
|
+
exports.IsTranslationalAcceleration = IsTranslationalAcceleration;
|
|
20
|
+
exports.IsTranslationalVelocity = IsTranslationalVelocity;
|
|
21
|
+
exports.IsTranslationalDisplacement = IsTranslationalDisplacement;
|
|
22
|
+
exports.IsSpringConstant = IsSpringConstant;
|
|
23
|
+
exports.IsRotationalAcceleration = IsRotationalAcceleration;
|
|
24
|
+
exports.IsRotationalVelocity = IsRotationalVelocity;
|
|
25
|
+
exports.IsRotationalDisplacement = IsRotationalDisplacement;
|
|
26
|
+
exports.IsTorque = IsTorque;
|
|
27
|
+
exports.IsMomentOfInertia = IsMomentOfInertia;
|
|
28
|
+
exports.IsRotatingUnbalance = IsRotatingUnbalance;
|
|
29
|
+
exports.IsMechanicalPower = IsMechanicalPower;
|
|
30
|
+
exports.IsMechanicalEnergy = IsMechanicalEnergy;
|
|
31
|
+
exports.IsDynamicViscosity = IsDynamicViscosity;
|
|
32
|
+
exports.IsVolumeFlow = IsVolumeFlow;
|
|
33
|
+
exports.IsMassFlow = IsMassFlow;
|
|
34
|
+
exports.IsHeatFlux = IsHeatFlux;
|
|
35
|
+
exports.IsThermalEnergy = IsThermalEnergy;
|
|
36
|
+
exports.IsSpecificHeatCapacity = IsSpecificHeatCapacity;
|
|
37
|
+
exports.IsThermalTransmittance = IsThermalTransmittance;
|
|
38
|
+
exports.IsElectricalPower = IsElectricalPower;
|
|
39
|
+
exports.IsElectricalEnergy = IsElectricalEnergy;
|
|
40
|
+
exports.IsElectricalFrequency = IsElectricalFrequency;
|
|
4
41
|
const unit_utils_1 = require("./unit-utils");
|
|
5
42
|
const units_1 = require("./units");
|
|
6
43
|
function IsTime(unit = units_1.units.time.baseUnit, validationOptions) {
|
|
7
44
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'time', validationOptions);
|
|
8
45
|
}
|
|
9
|
-
exports.IsTime = IsTime;
|
|
10
46
|
function IsLength(unit = units_1.units.length.baseUnit, validationOptions) {
|
|
11
47
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'length', validationOptions);
|
|
12
48
|
}
|
|
13
|
-
exports.IsLength = IsLength;
|
|
14
49
|
function IsMass(unit = units_1.units.mass.baseUnit, validationOptions) {
|
|
15
50
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'mass', validationOptions);
|
|
16
51
|
}
|
|
17
|
-
exports.IsMass = IsMass;
|
|
18
52
|
function IsElectricCurrent(unit = units_1.units.electricCurrent.baseUnit, validationOptions) {
|
|
19
53
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'electricCurrent', validationOptions);
|
|
20
54
|
}
|
|
21
|
-
exports.IsElectricCurrent = IsElectricCurrent;
|
|
22
55
|
function IsThermodynamicTemperature(unit = units_1.units.thermodynamicTemperature.baseUnit, validationOptions) {
|
|
23
56
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'thermodynamicTemperature', validationOptions);
|
|
24
57
|
}
|
|
25
|
-
exports.IsThermodynamicTemperature = IsThermodynamicTemperature;
|
|
26
58
|
function IsAmountOfSubstance(unit = units_1.units.amountOfSubstance.baseUnit, validationOptions) {
|
|
27
59
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'amountOfSubstance', validationOptions);
|
|
28
60
|
}
|
|
29
|
-
exports.IsAmountOfSubstance = IsAmountOfSubstance;
|
|
30
61
|
function IsLuminousIntensity(unit = units_1.units.luminousIntensity.baseUnit, validationOptions) {
|
|
31
62
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'luminousIntensity', validationOptions);
|
|
32
63
|
}
|
|
33
|
-
exports.IsLuminousIntensity = IsLuminousIntensity;
|
|
34
64
|
function IsVoltage(unit = units_1.units.voltage.baseUnit, validationOptions) {
|
|
35
65
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'voltage', validationOptions);
|
|
36
66
|
}
|
|
37
|
-
exports.IsVoltage = IsVoltage;
|
|
38
67
|
function IsForce(unit = units_1.units.force.baseUnit, validationOptions) {
|
|
39
68
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'force', validationOptions);
|
|
40
69
|
}
|
|
41
|
-
exports.IsForce = IsForce;
|
|
42
70
|
function IsEnergy(unit = units_1.units.energy.baseUnit, validationOptions) {
|
|
43
71
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'energy', validationOptions);
|
|
44
72
|
}
|
|
45
|
-
exports.IsEnergy = IsEnergy;
|
|
46
73
|
function IsPower(unit = units_1.units.power.baseUnit, validationOptions) {
|
|
47
74
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'power', validationOptions);
|
|
48
75
|
}
|
|
49
|
-
exports.IsPower = IsPower;
|
|
50
76
|
function IsPressure(unit = units_1.units.pressure.baseUnit, validationOptions) {
|
|
51
77
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'pressure', validationOptions);
|
|
52
78
|
}
|
|
53
|
-
exports.IsPressure = IsPressure;
|
|
54
79
|
function IsFrequency(unit = units_1.units.frequency.baseUnit, validationOptions) {
|
|
55
80
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'frequency', validationOptions);
|
|
56
81
|
}
|
|
57
|
-
exports.IsFrequency = IsFrequency;
|
|
58
82
|
function IsArea(unit = units_1.units.area.baseUnit, validationOptions) {
|
|
59
83
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'area', validationOptions);
|
|
60
84
|
}
|
|
61
|
-
exports.IsArea = IsArea;
|
|
62
85
|
function IsVolume(unit = units_1.units.volume.baseUnit, validationOptions) {
|
|
63
86
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'volume', validationOptions);
|
|
64
87
|
}
|
|
65
|
-
exports.IsVolume = IsVolume;
|
|
66
88
|
function IsAngle(unit = units_1.units.angle.baseUnit, validationOptions) {
|
|
67
89
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'angle', validationOptions);
|
|
68
90
|
}
|
|
69
|
-
exports.IsAngle = IsAngle;
|
|
70
91
|
function IsTranslationalAcceleration(unit = units_1.units.translationalAcceleration.baseUnit, validationOptions) {
|
|
71
92
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'translationalAcceleration', validationOptions);
|
|
72
93
|
}
|
|
73
|
-
exports.IsTranslationalAcceleration = IsTranslationalAcceleration;
|
|
74
94
|
function IsTranslationalVelocity(unit = units_1.units.translationalVelocity.baseUnit, validationOptions) {
|
|
75
95
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'translationalVelocity', validationOptions);
|
|
76
96
|
}
|
|
77
|
-
exports.IsTranslationalVelocity = IsTranslationalVelocity;
|
|
78
97
|
function IsTranslationalDisplacement(unit = units_1.units.translationalDisplacement.baseUnit, validationOptions) {
|
|
79
98
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'translationalDisplacement', validationOptions);
|
|
80
99
|
}
|
|
81
|
-
exports.IsTranslationalDisplacement = IsTranslationalDisplacement;
|
|
82
100
|
function IsSpringConstant(unit = units_1.units.springConstant.baseUnit, validationOptions) {
|
|
83
101
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'springConstant', validationOptions);
|
|
84
102
|
}
|
|
85
|
-
exports.IsSpringConstant = IsSpringConstant;
|
|
86
103
|
function IsRotationalAcceleration(unit = units_1.units.rotationalAcceleration.baseUnit, validationOptions) {
|
|
87
104
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'rotationalAcceleration', validationOptions);
|
|
88
105
|
}
|
|
89
|
-
exports.IsRotationalAcceleration = IsRotationalAcceleration;
|
|
90
106
|
function IsRotationalVelocity(unit = units_1.units.rotationalVelocity.baseUnit, validationOptions) {
|
|
91
107
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'rotationalVelocity', validationOptions);
|
|
92
108
|
}
|
|
93
|
-
exports.IsRotationalVelocity = IsRotationalVelocity;
|
|
94
109
|
function IsRotationalDisplacement(unit = units_1.units.rotationalDisplacement.baseUnit, validationOptions) {
|
|
95
110
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'rotationalDisplacement', validationOptions);
|
|
96
111
|
}
|
|
97
|
-
exports.IsRotationalDisplacement = IsRotationalDisplacement;
|
|
98
112
|
function IsTorque(unit = units_1.units.torque.baseUnit, validationOptions) {
|
|
99
113
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'torque', validationOptions);
|
|
100
114
|
}
|
|
101
|
-
exports.IsTorque = IsTorque;
|
|
102
115
|
function IsMomentOfInertia(unit = units_1.units.momentOfInertia.baseUnit, validationOptions) {
|
|
103
116
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'momentOfInertia', validationOptions);
|
|
104
117
|
}
|
|
105
|
-
exports.IsMomentOfInertia = IsMomentOfInertia;
|
|
106
118
|
function IsRotatingUnbalance(unit = units_1.units.rotatingUnbalance.baseUnit, validationOptions) {
|
|
107
119
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'rotatingUnbalance', validationOptions);
|
|
108
120
|
}
|
|
109
|
-
exports.IsRotatingUnbalance = IsRotatingUnbalance;
|
|
110
121
|
function IsMechanicalPower(unit = units_1.units.mechanicalPower.baseUnit, validationOptions) {
|
|
111
122
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'mechanicalPower', validationOptions);
|
|
112
123
|
}
|
|
113
|
-
exports.IsMechanicalPower = IsMechanicalPower;
|
|
114
124
|
function IsMechanicalEnergy(unit = units_1.units.mechanicalEnergy.baseUnit, validationOptions) {
|
|
115
125
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'mechanicalEnergy', validationOptions);
|
|
116
126
|
}
|
|
117
|
-
exports.IsMechanicalEnergy = IsMechanicalEnergy;
|
|
118
127
|
function IsDynamicViscosity(unit = units_1.units.dynamicViscosity.baseUnit, validationOptions) {
|
|
119
128
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'dynamicViscosity', validationOptions);
|
|
120
129
|
}
|
|
121
|
-
exports.IsDynamicViscosity = IsDynamicViscosity;
|
|
122
130
|
function IsVolumeFlow(unit = units_1.units.volumeFlow.baseUnit, validationOptions) {
|
|
123
131
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'volumeFlow', validationOptions);
|
|
124
132
|
}
|
|
125
|
-
exports.IsVolumeFlow = IsVolumeFlow;
|
|
126
133
|
function IsMassFlow(unit = units_1.units.massFlow.baseUnit, validationOptions) {
|
|
127
134
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'massFlow', validationOptions);
|
|
128
135
|
}
|
|
129
|
-
exports.IsMassFlow = IsMassFlow;
|
|
130
136
|
function IsHeatFlux(unit = units_1.units.heatFlux.baseUnit, validationOptions) {
|
|
131
137
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'heatFlux', validationOptions);
|
|
132
138
|
}
|
|
133
|
-
exports.IsHeatFlux = IsHeatFlux;
|
|
134
139
|
function IsThermalEnergy(unit = units_1.units.thermalEnergy.baseUnit, validationOptions) {
|
|
135
140
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'thermalEnergy', validationOptions);
|
|
136
141
|
}
|
|
137
|
-
exports.IsThermalEnergy = IsThermalEnergy;
|
|
138
142
|
function IsSpecificHeatCapacity(unit = units_1.units.specificHeatCapacity.baseUnit, validationOptions) {
|
|
139
143
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'specificHeatCapacity', validationOptions);
|
|
140
144
|
}
|
|
141
|
-
exports.IsSpecificHeatCapacity = IsSpecificHeatCapacity;
|
|
142
145
|
function IsThermalTransmittance(unit = units_1.units.thermalTransmittance.baseUnit, validationOptions) {
|
|
143
146
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'thermalTransmittance', validationOptions);
|
|
144
147
|
}
|
|
145
|
-
exports.IsThermalTransmittance = IsThermalTransmittance;
|
|
146
148
|
function IsElectricalPower(unit = units_1.units.electricalPower.baseUnit, validationOptions) {
|
|
147
149
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'electricalPower', validationOptions);
|
|
148
150
|
}
|
|
149
|
-
exports.IsElectricalPower = IsElectricalPower;
|
|
150
151
|
function IsElectricalEnergy(unit = units_1.units.electricalEnergy.baseUnit, validationOptions) {
|
|
151
152
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'electricalEnergy', validationOptions);
|
|
152
153
|
}
|
|
153
|
-
exports.IsElectricalEnergy = IsElectricalEnergy;
|
|
154
154
|
function IsElectricalFrequency(unit = units_1.units.electricalFrequency.baseUnit, validationOptions) {
|
|
155
155
|
return (0, unit_utils_1.makeUnitDecorator)(unit, 'electricalFrequency', validationOptions);
|
|
156
156
|
}
|
|
157
|
-
exports.IsElectricalFrequency = IsElectricalFrequency;
|
package/dist/unit-utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.makeUnitDecorator = makeUnitDecorator;
|
|
4
|
+
exports.verifyUnit = verifyUnit;
|
|
5
|
+
exports.computeUnitOptions = computeUnitOptions;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const class_validator_1 = require("class-validator");
|
|
6
8
|
const units_1 = require("./units");
|
|
@@ -20,7 +22,6 @@ function makeUnitDecorator(unit, metric, validationOptions) {
|
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
|
-
exports.makeUnitDecorator = makeUnitDecorator;
|
|
24
25
|
let UnitArgsValidator = class UnitArgsValidator {
|
|
25
26
|
validate(value, validationArguments) {
|
|
26
27
|
return (0, class_validator_1.isNumber)(value);
|
|
@@ -72,7 +73,6 @@ function verifyUnit(unit, metric) {
|
|
|
72
73
|
}
|
|
73
74
|
return -1;
|
|
74
75
|
}
|
|
75
|
-
exports.verifyUnit = verifyUnit;
|
|
76
76
|
function verifyIndices(indices, unit) {
|
|
77
77
|
if (indices.length === 0 || !unit)
|
|
78
78
|
return 1;
|
|
@@ -141,4 +141,3 @@ function computeUnitOptions(dimension) {
|
|
|
141
141
|
}))
|
|
142
142
|
: allUnits;
|
|
143
143
|
}
|
|
144
|
-
exports.computeUnitOptions = computeUnitOptions;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fillTemplate = fillTemplate;
|
|
4
|
+
exports.getCircularReplacer = getCircularReplacer;
|
|
5
|
+
exports.toArray = toArray;
|
|
6
|
+
exports.delay = delay;
|
|
7
|
+
exports.deleteFiles = deleteFiles;
|
|
8
|
+
exports.handleApiError = handleApiError;
|
|
9
|
+
exports.runPyScript = runPyScript;
|
|
10
|
+
exports.truncate = truncate;
|
|
4
11
|
const tslib_1 = require("tslib");
|
|
5
12
|
const fs_1 = require("fs");
|
|
6
13
|
const isPlainObject_1 = tslib_1.__importDefault(require("lodash/isPlainObject"));
|
|
@@ -37,7 +44,6 @@ function fillTemplate(value, ...templateVariables) {
|
|
|
37
44
|
return value;
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
|
-
exports.fillTemplate = fillTemplate;
|
|
41
47
|
function getCircularReplacer() {
|
|
42
48
|
const seen = new WeakSet();
|
|
43
49
|
return (key, value) => {
|
|
@@ -50,22 +56,18 @@ function getCircularReplacer() {
|
|
|
50
56
|
return value;
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
|
-
exports.getCircularReplacer = getCircularReplacer;
|
|
54
59
|
function toArray(value = []) {
|
|
55
60
|
return Array.isArray(value) ? value : value.split(',').map((v) => v.trim());
|
|
56
61
|
}
|
|
57
|
-
exports.toArray = toArray;
|
|
58
62
|
function delay(ms) {
|
|
59
63
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
60
64
|
}
|
|
61
|
-
exports.delay = delay;
|
|
62
65
|
async function deleteFiles(dir, ...filenames) {
|
|
63
66
|
for (const filename of filenames) {
|
|
64
67
|
await fs_1.promises.unlink((0, path_1.join)(dir, filename)).catch((err) => {
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
|
-
exports.deleteFiles = deleteFiles;
|
|
69
71
|
function handleApiError(error, logger) {
|
|
70
72
|
if (error.isAxiosError) {
|
|
71
73
|
if (error.response && error.response.data) {
|
|
@@ -83,7 +85,6 @@ function handleApiError(error, logger) {
|
|
|
83
85
|
logger.error(error);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
exports.handleApiError = handleApiError;
|
|
87
88
|
function runPyScript(scriptPath, data) {
|
|
88
89
|
return new Promise((resolve, reject) => {
|
|
89
90
|
let pyData;
|
|
@@ -105,7 +106,6 @@ function runPyScript(scriptPath, data) {
|
|
|
105
106
|
});
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
|
-
exports.runPyScript = runPyScript;
|
|
109
109
|
function truncate(msg, depth = 4, maxStringLength = 1000) {
|
|
110
110
|
let truncated = (0, util_1.inspect)(msg, { depth, maxStringLength });
|
|
111
111
|
if (truncated.startsWith("'") && truncated.endsWith("'")) {
|
|
@@ -113,4 +113,3 @@ function truncate(msg, depth = 4, maxStringLength = 1000) {
|
|
|
113
113
|
}
|
|
114
114
|
return truncated;
|
|
115
115
|
}
|
|
116
|
-
exports.truncate = truncate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/flow-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "SDK for building Flow Modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -28,26 +28,27 @@
|
|
|
28
28
|
"amqplib": "0.10.4",
|
|
29
29
|
"class-transformer": "0.5.1",
|
|
30
30
|
"class-validator": "~0.14.1",
|
|
31
|
-
"cloudevents": "8.0.
|
|
31
|
+
"cloudevents": "8.0.2",
|
|
32
32
|
"lodash": "4.17.21",
|
|
33
|
-
"
|
|
33
|
+
"nats": "2.28.2",
|
|
34
|
+
"object-sizeof": "~2.6.5",
|
|
34
35
|
"python-shell": "5.0.0",
|
|
35
36
|
"reflect-metadata": "0.2.2",
|
|
36
37
|
"rxjs": "7.8.1",
|
|
37
38
|
"string-interp": "0.3.6",
|
|
38
|
-
"@hahnpro/hpc-api": "5.2.
|
|
39
|
+
"@hahnpro/hpc-api": "5.2.7"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/amqplib": "0.10.5",
|
|
42
43
|
"@types/jest": "29.5.12",
|
|
43
|
-
"@types/lodash": "4.17.
|
|
44
|
-
"@types/node": "20.14.
|
|
44
|
+
"@types/lodash": "4.17.7",
|
|
45
|
+
"@types/node": "20.14.14",
|
|
45
46
|
"class-validator-jsonschema": "5.0.1",
|
|
46
47
|
"jest": "29.7.0",
|
|
47
|
-
"typescript": "5.4
|
|
48
|
+
"typescript": "5.5.4"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"axios": "1.7.
|
|
51
|
+
"axios": "1.7.3",
|
|
51
52
|
"class-transformer": "0.5.1",
|
|
52
53
|
"class-validator": "0.14.1",
|
|
53
54
|
"lodash": "4.17.21",
|