@nsshunt/stsobservability 1.0.75 → 1.0.77

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.
@@ -21,7 +21,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
21
21
  }
22
22
  });
23
23
 
24
- var _a, _label, _options2, _data2, _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, _agentManager2, _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, _options3, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options4, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options5, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options6, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options7, _sockets, _agentManager3, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
24
+ var _a, _label, _options2, _data2, _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, _agentManager2, _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, _options3, _agentManager3, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options4, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options5, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options6, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options7, _sockets, _agentManager4, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
25
25
  var Gauge = /* @__PURE__ */ ((Gauge2) => {
26
26
  Gauge2["ACTIVE_REQUEST_GAUGE"] = "a";
27
27
  Gauge2["AUTHENTICATION_COUNT_GAUGE"] = "b";
@@ -4919,7 +4919,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
4919
4919
  return __privateGet2(obj, member, getter);
4920
4920
  }
4921
4921
  });
4922
- var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout;
4922
+ var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
4923
4923
  var ansiStyles$1 = { exports: {} };
4924
4924
  var colorName;
4925
4925
  var hasRequiredColorName;
@@ -6560,10 +6560,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6560
6560
  __privateAdd2(this, _agentResetInterval, null);
6561
6561
  __privateAdd2(this, _requestCount, 0);
6562
6562
  __privateAdd2(this, _SetupResetInterval, () => {
6563
- __privateSet2(this, _agentResetInterval, setTimeout(() => {
6564
- this.ResetAgent();
6565
- __privateGet2(this, _SetupResetInterval).call(this);
6566
- }, __privateGet2(this, _options).agentResetInterval).unref());
6563
+ if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
6564
+ __privateSet2(this, _agentResetInterval, setTimeout(() => {
6565
+ this.ResetAgent();
6566
+ __privateGet2(this, _SetupResetInterval).call(this);
6567
+ }, __privateGet2(this, _options).agentResetInterval).unref());
6568
+ }
6567
6569
  });
6568
6570
  __privateAdd2(this, _GetAgentOptions, (https2) => {
6569
6571
  let options;
@@ -6599,6 +6601,22 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6599
6601
  __privateGet2(this, _SetupResetInterval).call(this);
6600
6602
  }
6601
6603
  }
6604
+ get agentResetInterval() {
6605
+ return __privateGet2(this, _options).agentResetInterval;
6606
+ }
6607
+ set agentResetInterval(val) {
6608
+ if (__privateGet2(this, _agentResetInterval)) {
6609
+ clearTimeout(__privateGet2(this, _agentResetInterval));
6610
+ }
6611
+ __privateGet2(this, _options).agentResetInterval = val;
6612
+ __privateGet2(this, _SetupResetInterval).call(this);
6613
+ }
6614
+ get agentResetCount() {
6615
+ return __privateGet2(this, _options).agentResetCount;
6616
+ }
6617
+ set agentResetCount(val) {
6618
+ __privateGet2(this, _options).agentResetCount = val;
6619
+ }
6602
6620
  IncRequestCount() {
6603
6621
  __privateWrapper2(this, _requestCount)._++;
6604
6622
  if (__privateGet2(this, _options).agentResetCount) {
@@ -6679,18 +6697,55 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6679
6697
  __privateAdd2(this, _data);
6680
6698
  __privateAdd2(this, _agentManager);
6681
6699
  __privateAdd2(this, _timeout);
6700
+ __privateAdd2(this, _withCredentials);
6682
6701
  __privateSet2(this, _url, url);
6683
6702
  __privateSet2(this, _method, method);
6684
- __privateSet2(this, _headers, headers);
6703
+ if (headers !== void 0) {
6704
+ __privateSet2(this, _headers, headers);
6705
+ }
6685
6706
  if (timeout !== void 0) {
6686
6707
  __privateSet2(this, _timeout, timeout);
6687
6708
  }
6688
6709
  }
6710
+ withCookies(cookies) {
6711
+ if (!__privateGet2(this, _headers)) {
6712
+ __privateSet2(this, _headers, {});
6713
+ }
6714
+ __privateGet2(this, _headers)["Cookie"] = cookies.join("; ");
6715
+ return this;
6716
+ }
6689
6717
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6690
6718
  withData(data) {
6691
6719
  __privateSet2(this, _data, data);
6692
6720
  return this;
6693
6721
  }
6722
+ // 'Content-Type': 'application/json'
6723
+ withAuthHeaders(accesssToken, stsUserId) {
6724
+ if (!__privateGet2(this, _headers)) {
6725
+ __privateSet2(this, _headers, {});
6726
+ }
6727
+ __privateGet2(this, _headers)["Content-Type"] = "application/json";
6728
+ __privateGet2(this, _headers)["Authorization"] = "Bearer " + accesssToken;
6729
+ if (stsUserId) {
6730
+ __privateGet2(this, _headers)["x-sts_user_id"] = stsUserId;
6731
+ }
6732
+ return this;
6733
+ }
6734
+ withHeaders(headers) {
6735
+ __privateSet2(this, _headers, headers);
6736
+ return this;
6737
+ }
6738
+ withDefaultHeaders() {
6739
+ if (!__privateGet2(this, _headers)) {
6740
+ __privateSet2(this, _headers, {});
6741
+ }
6742
+ __privateGet2(this, _headers)["Content-Type"] = "application/json";
6743
+ return this;
6744
+ }
6745
+ withCredentials() {
6746
+ __privateSet2(this, _withCredentials, true);
6747
+ return this;
6748
+ }
6694
6749
  withTimeout(timeout) {
6695
6750
  __privateSet2(this, _timeout, timeout);
6696
6751
  return this;
@@ -6702,9 +6757,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6702
6757
  get config() {
6703
6758
  const retVal = {
6704
6759
  url: __privateGet2(this, _url),
6705
- method: __privateGet2(this, _method),
6706
- headers: __privateGet2(this, _headers)
6760
+ method: __privateGet2(this, _method)
6707
6761
  };
6762
+ if (__privateGet2(this, _headers)) {
6763
+ retVal.headers = __privateGet2(this, _headers);
6764
+ }
6708
6765
  if (__privateGet2(this, _agentManager) !== void 0) {
6709
6766
  if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
6710
6767
  retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
@@ -6718,6 +6775,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6718
6775
  if (__privateGet2(this, _timeout) !== void 0) {
6719
6776
  retVal.timeout = __privateGet2(this, _timeout);
6720
6777
  }
6778
+ if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
6779
+ retVal.withCredentials = true;
6780
+ }
6721
6781
  return retVal;
6722
6782
  }
6723
6783
  }
@@ -6727,6 +6787,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6727
6787
  _data = /* @__PURE__ */ new WeakMap();
6728
6788
  _agentManager = /* @__PURE__ */ new WeakMap();
6729
6789
  _timeout = /* @__PURE__ */ new WeakMap();
6790
+ _withCredentials = /* @__PURE__ */ new WeakMap();
6730
6791
  class PublishTransportRESTServer extends stsutils.STSOptionsBase {
6731
6792
  constructor(options) {
6732
6793
  super(options);
@@ -6744,15 +6805,17 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6744
6805
  if (this.options.socketPath) {
6745
6806
  retVal = await axios({
6746
6807
  method: "post",
6747
- //data: payload,
6748
6808
  data: Buffer.from(encodedData),
6749
6809
  headers,
6750
- //httpsAgent: this.#httpsAgent,
6751
6810
  socketPath: this.options.socketPath
6752
6811
  });
6753
6812
  } else {
6754
- if (isNode && __privateGet(this, _agentManager2)) {
6755
- retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).withAgentManager(__privateGet(this, _agentManager2)).config);
6813
+ if (isNode) {
6814
+ if (__privateGet(this, _agentManager2)) {
6815
+ retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).withAgentManager(__privateGet(this, _agentManager2)).config);
6816
+ } else {
6817
+ retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).config);
6818
+ }
6756
6819
  } else {
6757
6820
  const blob = new Blob([encodedData], { type: "application/octet-stream" });
6758
6821
  retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(blob).config);
@@ -7662,6 +7725,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
7662
7725
  __privateAdd(this, _options3);
7663
7726
  // This is required becuase each call to .bind create a new replica bound function - so we need the same instance for on/off event bindings.
7664
7727
  __publicField(this, "KeepAliveAckBoundFunction");
7728
+ __privateAdd(this, _agentManager3, null);
7665
7729
  __privateAdd(this, _GetData, async (subscription) => {
7666
7730
  try {
7667
7731
  const retVal = await __privateMethod(this, _ObservabilityRESTAPISubscriber_instances, InvokeRESTAPI_fn).call(this, subscription);
@@ -7678,6 +7742,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
7678
7742
  }
7679
7743
  });
7680
7744
  __privateSet(this, _options3, options);
7745
+ if (isNode && options.useAgentManager && options.useAgentManager === true) {
7746
+ __privateSet(this, _agentManager3, new AgentManager({}));
7747
+ }
7681
7748
  }
7682
7749
  SubscribeOne(subscription) {
7683
7750
  this.Subscribe([subscription]);
@@ -7706,6 +7773,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
7706
7773
  }
7707
7774
  _socketSubscribeKeepAlive = new WeakMap();
7708
7775
  _options3 = new WeakMap();
7776
+ _agentManager3 = new WeakMap();
7709
7777
  _ObservabilityRESTAPISubscriber_instances = new WeakSet();
7710
7778
  LogDebugMessage_fn = function(message) {
7711
7779
  __privateGet(this, _options3).logger.debug(message);
@@ -7782,25 +7850,13 @@ var __privateWrapper = (obj, member, setter, getter) => ({
7782
7850
  }
7783
7851
  if (url.localeCompare("") !== 0) {
7784
7852
  const endPointUrl = `${__privateGet(this, _options3).urlBase}${url}`;
7785
- const headers = {
7786
- "Content-Type": "application/json"
7787
- };
7788
7853
  let retVal;
7789
7854
  const start = performance.now();
7790
7855
  try {
7791
- if (isNode && __privateGet(this, _options3).agent) {
7792
- retVal = await axios({
7793
- url: endPointUrl,
7794
- method: "get",
7795
- headers,
7796
- httpsAgent: __privateGet(this, _options3).agent
7797
- });
7856
+ if (isNode && __privateGet(this, _agentManager3)) {
7857
+ retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().withAgentManager(__privateGet(this, _agentManager3)).config);
7798
7858
  } else {
7799
- retVal = await axios({
7800
- url: endPointUrl,
7801
- method: "get",
7802
- headers
7803
- });
7859
+ retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().config);
7804
7860
  }
7805
7861
  const end = performance.now();
7806
7862
  const diff = end - start;
@@ -8666,10 +8722,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
8666
8722
  __privateAdd(this, _SocketIoClientHelper_instances);
8667
8723
  __privateAdd(this, _options7);
8668
8724
  __privateAdd(this, _sockets, {});
8669
- __privateAdd(this, _agentManager3, null);
8725
+ __privateAdd(this, _agentManager4, null);
8670
8726
  __privateSet(this, _options7, options);
8671
8727
  if (isNode) {
8672
- __privateSet(this, _agentManager3, new AgentManager({
8728
+ __privateSet(this, _agentManager4, new AgentManager({
8673
8729
  agentOptions: __privateGet(this, _options7).agentOptions
8674
8730
  }));
8675
8731
  }
@@ -8696,7 +8752,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
8696
8752
  }
8697
8753
  _options7 = new WeakMap();
8698
8754
  _sockets = new WeakMap();
8699
- _agentManager3 = new WeakMap();
8755
+ _agentManager4 = new WeakMap();
8700
8756
  _SocketIoClientHelper_instances = new WeakSet();
8701
8757
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8702
8758
  LogDebugMessage_fn5 = function(message) {
@@ -8726,7 +8782,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
8726
8782
  socketOptions = {
8727
8783
  transports: ["websocket"],
8728
8784
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8729
- agent: (_a2 = __privateGet(this, _agentManager3)) == null ? void 0 : _a2.GetAgent(socketDetail.address)
8785
+ agent: (_a2 = __privateGet(this, _agentManager4)) == null ? void 0 : _a2.GetAgent(socketDetail.address)
8730
8786
  };
8731
8787
  } else {
8732
8788
  socketOptions = {