@nsshunt/stsobservability 1.0.69 → 1.0.71

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.
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
17
17
  return __privateGet(obj, member, getter);
18
18
  }
19
19
  });
20
- var _a, _label, _options, _data, _val, _interval, _timeoutComputeVelocity, _lastVelocity, _delta, _maxVelocity, _timerInterval, _copy, _velocity, _velocityVal, _valStack, _averageValStack, _maxAverageValStack, _maxAverageIterations, _valStackMaxLength, _valStackAverage, _timeStamp, _maxTimeDiff, _vaTimeDiff, _velocityTimeDiff, _autoComputeVelocity, _autoComputeVelocityTimeout, _countDiff, _timeDiff, _deltaCountDiff, _deltaTimeDif, _minTimeForReporting, _averageVelocity, _InstrumentVelocity_instances, ComputeVelocityByTimeDiff_fn, ComputeVelocity_fn, SetupAutoComputeVelocity_fn, GetVelocityStackAverage_fn, GetVal_fn, SetVal_fn, GetVelocity_fn, GetMaxVelocity_fn, GetDelta_fn, GetTimeStamp_fn, GetCountDiff_fn, GetTimeDiff_fn, GetDeltaCountDiff_fn, GetDeltaTimeDif_fn, GetAverageVelocity_fn, _histogramData, _val2, _copy2, _InstrumentHistogram_instances, GetVal_fn2, SetVal_fn2, GetHistogramData_fn, SetHistogramData_fn, _messages, _readPos, _maxSize, _copy3, _useLatestMessages, _consoleLogging, _instrumentLogging, _winstonLogging, _stsLogger, _InstrumentLog_instances, DumpToConsole_fn, GetVal_fn3, SetVal_fn3, _start, _copy4, _pauseVal, _InstrumentTimerGauge_instances, GetVal_fn4, SetVal_fn4, _val3, _maxval, _lastObservedValue, _timeSeriesList, _maxSampleSize, _timerInterval2, _observer, _min, _max, _observations, _total, _copy5, _InstrumentGauge_instances, GetVal_fn5, SetVal_fn5, GetMin_fn, GetMax_fn, GetAverage_fn, GetAndResetMaxVal_fn, NumberCompare_fn, GetPercentileData_fn, _val4, _copy6, _InstrumentObject_instances, GetVal_fn6, SetVal_fn6, _tinyEmitter, _RequestCompleted, _httpsAgent, _inPublish, _observer2, _publishState, _publisherTransport, _PublishInstruments_instances, PublishTimeoutLoop_fn, UpdateState_fn, _instruments, _publisher, _PublishInstrumentController_instances, GetInstrument_fn, ProcessTelemetryCommand_fn, CreateInstrument_fn, CreateInstruments_fn, _kafkaLog, _maxLogLength, _socketSubscribeKeepAlive, _options2, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options3, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options4, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options5, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options6, _sockets, _httpsAgent2, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn;
20
+ var _a, _label, _options, _data, _val, _interval, _timeoutComputeVelocity, _lastVelocity, _delta, _maxVelocity, _timerInterval, _copy, _velocity, _velocityVal, _valStack, _averageValStack, _maxAverageValStack, _maxAverageIterations, _valStackMaxLength, _valStackAverage, _timeStamp, _maxTimeDiff, _vaTimeDiff, _velocityTimeDiff, _autoComputeVelocity, _autoComputeVelocityTimeout, _countDiff, _timeDiff, _deltaCountDiff, _deltaTimeDif, _minTimeForReporting, _averageVelocity, _InstrumentVelocity_instances, ComputeVelocityByTimeDiff_fn, ComputeVelocity_fn, SetupAutoComputeVelocity_fn, GetVelocityStackAverage_fn, GetVal_fn, SetVal_fn, GetVelocity_fn, GetMaxVelocity_fn, GetDelta_fn, GetTimeStamp_fn, GetCountDiff_fn, GetTimeDiff_fn, GetDeltaCountDiff_fn, GetDeltaTimeDif_fn, GetAverageVelocity_fn, _histogramData, _val2, _copy2, _InstrumentHistogram_instances, GetVal_fn2, SetVal_fn2, GetHistogramData_fn, SetHistogramData_fn, _messages, _readPos, _maxSize, _copy3, _useLatestMessages, _consoleLogging, _instrumentLogging, _winstonLogging, _stsLogger, _InstrumentLog_instances, DumpToConsole_fn, GetVal_fn3, SetVal_fn3, _start, _copy4, _pauseVal, _InstrumentTimerGauge_instances, GetVal_fn4, SetVal_fn4, _val3, _maxval, _lastObservedValue, _timeSeriesList, _maxSampleSize, _timerInterval2, _observer, _min, _max, _observations, _total, _copy5, _InstrumentGauge_instances, GetVal_fn5, SetVal_fn5, GetMin_fn, GetMax_fn, GetAverage_fn, GetAndResetMaxVal_fn, NumberCompare_fn, GetPercentileData_fn, _val4, _copy6, _InstrumentObject_instances, GetVal_fn6, SetVal_fn6, _tinyEmitter, _RequestCompleted, _httpsAgent, _inPublish, _observer2, _publishState, _publisherTransport, _PublishInstruments_instances, PublishTimeoutLoop_fn, UpdateState_fn, _instruments, _publisher, _PublishInstrumentController_instances, GetInstrument_fn, ProcessTelemetryCommand_fn, CreateInstrument_fn, CreateInstruments_fn, _kafkaLog, _maxLogLength, _socketSubscribeKeepAlive, _options2, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options3, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options4, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options5, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options6, _sockets, _httpsAgent2, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
21
21
  import _cloneDeep from "lodash.clonedeep";
22
22
  import isNode from "detect-node";
23
23
  import { STSOptionsBase } from "@nsshunt/stsutils";
@@ -6630,6 +6630,149 @@ EstablishSocketConnect_fn = function(name, onConnectCallBack, socketEventsCallBa
6630
6630
  }
6631
6631
  });
6632
6632
  };
6633
+ var STSNamespace = /* @__PURE__ */ ((STSNamespace2) => {
6634
+ STSNamespace2["STSMonitor"] = "stsinstrumentmanager/stsmonitor";
6635
+ STSNamespace2["STSControl"] = "stsinstrumentmanager/stscontrol";
6636
+ return STSNamespace2;
6637
+ })(STSNamespace || {});
6638
+ var STSRoom = /* @__PURE__ */ ((STSRoom2) => {
6639
+ STSRoom2["STSInstrumentDataRoom"] = "stsinstrumentdataroom";
6640
+ STSRoom2["STSInstrumentDataSubscriptionRoom"] = "stsinstrumentdatasubscriptionroom";
6641
+ STSRoom2["STSRunnerRoom"] = "stsrunnerroom";
6642
+ STSRoom2["STSNodeRunnerRoom"] = "stsnoderunnerroom";
6643
+ return STSRoom2;
6644
+ })(STSRoom || {});
6645
+ var STSEvent = /* @__PURE__ */ ((STSEvent2) => {
6646
+ STSEvent2["STSInstrumentData"] = "stsinstrumentdata";
6647
+ STSEvent2["STSSubInstrumentData"] = "stssubinstrumentdata";
6648
+ STSEvent2["STSResetInstrumentData"] = "stsresetinstrumentdata";
6649
+ STSEvent2["STSStartLoggingInstrumentData"] = "stsStartLoggingInstrumentData";
6650
+ STSEvent2["STSStopLoggingInstrumentData"] = "stsStopLoggingInstrumentData";
6651
+ STSEvent2["STSStart"] = "stsstart";
6652
+ STSEvent2["STSStop"] = "stsstop";
6653
+ STSEvent2["STSPause"] = "stspause";
6654
+ STSEvent2["STSResume"] = "stsresume";
6655
+ STSEvent2["STSTerminate"] = "ststerminate";
6656
+ STSEvent2["STSUpdateStaticConfig"] = "stsupdatestaticconfig";
6657
+ STSEvent2["STSUpdateDynamicConfig"] = "stsupdatedynamicconfig";
6658
+ STSEvent2["STSSendToRoom"] = "sendToRoom";
6659
+ STSEvent2["connect"] = "connect";
6660
+ return STSEvent2;
6661
+ })(STSEvent || {});
6662
+ class SocketIoServerHelper {
6663
+ constructor(options) {
6664
+ __privateAdd(this, _socketIoServerHelperOptions);
6665
+ __privateAdd(this, _namespace, {});
6666
+ __publicField(this, "LeaveRoom", (namespace, socket, room) => {
6667
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: Leaving room [${room}]`);
6668
+ socket.leave(room);
6669
+ });
6670
+ __publicField(this, "JoinRoom", (namespace, socket, room) => {
6671
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: Socket joining room [${room}], ID: [${socket.id}]`);
6672
+ socket.join(room);
6673
+ });
6674
+ __privateAdd(this, _SetupStandardEvents, (namespace, socket) => {
6675
+ socket.on("disconnect", (reason) => {
6676
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnect, ID: [${socket.id}] [${reason}]`);
6677
+ });
6678
+ socket.on("disconnecting", (reason) => {
6679
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnecting, ID: [${socket.id}] [${reason}]`);
6680
+ });
6681
+ socket.on("error", (error) => {
6682
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket error, ID: [${socket.id}] [${error}]`);
6683
+ });
6684
+ socket.on("__STSdisconnect", (reason) => {
6685
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnect: socket disconnect, ID: [${socket.id}] [${reason}]`);
6686
+ });
6687
+ socket.on("__STSdisconnecting", (reason, callBackResult) => {
6688
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnecting: socket disconnecting, ID: [${socket.id}] [${reason}]`);
6689
+ callBackResult("__STSdisconnecting accepted by server.");
6690
+ });
6691
+ socket.on("__STSjoinRoom", (rooms) => {
6692
+ rooms.forEach((room) => {
6693
+ this.JoinRoom(namespace, socket, room);
6694
+ });
6695
+ });
6696
+ socket.on("__STSleaveRoom", (rooms) => {
6697
+ rooms.forEach((room) => {
6698
+ this.LeaveRoom(namespace, socket, room);
6699
+ });
6700
+ });
6701
+ socket.on("__STSsendToRoom", (rooms, payload) => {
6702
+ rooms.forEach((room) => {
6703
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}:socket.on:sendToRoom: __STSsendToRoom: Sending to room [${room}], ID: [${socket.id}]`);
6704
+ namespace.socketionamespace.to(room).emit(payload.command, payload);
6705
+ });
6706
+ });
6707
+ });
6708
+ // Use this middleward to check every incomming connection
6709
+ __privateAdd(this, _SetupConnectionMiddleware, (nameSpace) => {
6710
+ nameSpace.socketionamespace.use((socket, next) => {
6711
+ {
6712
+ next();
6713
+ }
6714
+ });
6715
+ });
6716
+ // Use this middleware to check very packet being received
6717
+ __privateAdd(this, _SetupMessageMiddleware, (socket) => {
6718
+ socket.use(([event, ...args], next) => {
6719
+ next();
6720
+ });
6721
+ });
6722
+ __publicField(this, "SetupNamespace", (io2, namespace, rooms, autoJoinRooms, socketConnectCallBack, socketEventsCallBack) => {
6723
+ __privateGet(this, _namespace)[namespace] = {
6724
+ namespace,
6725
+ pid: process.pid,
6726
+ socketionamespace: io2.of(`/${namespace}/`)
6727
+ };
6728
+ __privateGet(this, _SetupConnectionMiddleware).call(this, __privateGet(this, _namespace)[namespace]);
6729
+ __privateGet(this, _namespace)[namespace].socketionamespace.on("connection", (socket) => {
6730
+ this.LogMessage(__privateGet(this, _namespace)[namespace], `${namespace}: Socket connected, ID: [${socket.id}]`);
6731
+ this.LogMessage(__privateGet(this, _namespace)[namespace], `${namespace}: Authentication Handshake: [${JSON.stringify(socket.handshake.auth)}]`);
6732
+ __privateGet(this, _SetupMessageMiddleware).call(this, socket);
6733
+ if (autoJoinRooms) {
6734
+ rooms.map((room) => {
6735
+ this.JoinRoom(__privateGet(this, _namespace)[namespace], socket, room);
6736
+ });
6737
+ }
6738
+ __privateGet(this, _SetupStandardEvents).call(this, __privateGet(this, _namespace)[namespace], socket);
6739
+ if (socketConnectCallBack) {
6740
+ setTimeout(() => {
6741
+ socketConnectCallBack(socket);
6742
+ }, 0);
6743
+ }
6744
+ if (socketEventsCallBack) {
6745
+ socketEventsCallBack(socket);
6746
+ }
6747
+ });
6748
+ return __privateGet(this, _namespace)[namespace].socketionamespace;
6749
+ });
6750
+ __publicField(this, "GetSTSSocketIONamespace", (namespace) => {
6751
+ return __privateGet(this, _namespace)[namespace];
6752
+ });
6753
+ __publicField(this, "GetSTSSocketIONamespaces", () => {
6754
+ return __privateGet(this, _namespace);
6755
+ });
6756
+ __publicField(this, "DisconnectSockets", () => {
6757
+ for (const [, namespace] of Object.entries(__privateGet(this, _namespace))) {
6758
+ namespace.socketionamespace.disconnectSockets();
6759
+ }
6760
+ __privateSet(this, _namespace, {});
6761
+ });
6762
+ __privateSet(this, _socketIoServerHelperOptions, options);
6763
+ }
6764
+ LogMessage(namespace, message) {
6765
+ __privateGet(this, _socketIoServerHelperOptions).logger.debug(`${namespace.namespace}: ${message}`);
6766
+ }
6767
+ SetupEvent(event, eventCb) {
6768
+ return this;
6769
+ }
6770
+ }
6771
+ _socketIoServerHelperOptions = new WeakMap();
6772
+ _namespace = new WeakMap();
6773
+ _SetupStandardEvents = new WeakMap();
6774
+ _SetupConnectionMiddleware = new WeakMap();
6775
+ _SetupMessageMiddleware = new WeakMap();
6633
6776
  export {
6634
6777
  CompareSTSInstrumentControllerPluginKey,
6635
6778
  CreateInstrument,
@@ -6674,10 +6817,14 @@ export {
6674
6817
  PublishTransportRESTServer,
6675
6818
  RequestLoggerMiddleware,
6676
6819
  RequestLoggerMiddlewareEventName,
6820
+ STSEvent,
6677
6821
  STSInstrumentControllerPlugin,
6678
6822
  STSInstrumentControllerPluginKey,
6823
+ STSNamespace,
6824
+ STSRoom,
6679
6825
  SocketIoClientHelper,
6680
6826
  SocketIoMessageSender,
6827
+ SocketIoServerHelper,
6681
6828
  StopInstruments,
6682
6829
  SubscriptionTopic,
6683
6830
  TransportType,