@loadstrike/loadstrike-sdk 1.0.21101 → 1.0.21301

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/cjs/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimescaleDbReportingSink = exports.SplunkReportingSinkOptions = exports.SplunkReportingSink = exports.OtelCollectorReportingSinkOptions = exports.OtelCollectorReportingSink = exports.InfluxDbReportingSinkOptions = exports.InfluxDbReportingSink = exports.GrafanaLokiReportingSinkOptions = exports.GrafanaLokiReportingSink = exports.DatadogReportingSinkOptions = exports.DatadogReportingSink = exports.HttpAuthOptions = exports.HttpOAuth2ClientCredentialsOptions = exports.PushDiffusionEndpointDefinition = exports.DelegateStreamEndpointDefinition = exports.AzureEventHubsEndpointDefinition = exports.RedisStreamsEndpointDefinition = exports.NatsEndpointDefinition = exports.RabbitMqEndpointDefinition = exports.KafkaSaslOptions = exports.KafkaEndpointDefinition = exports.HttpEndpointDefinition = exports.TrafficEndpointDefinition = exports.EndpointAdapterFactory = exports.TrackingFieldSelector = exports.TrackingPayloadBuilder = exports.RedisCorrelationStore = exports.RedisCorrelationStoreOptions = exports.InMemoryCorrelationStore = exports.CrossPlatformTrackingRuntime = exports.CorrelationStoreConfiguration = exports.LoadStrikeThreshold = exports.LoadStrikeStep = exports.LoadStrikeGauge = exports.LoadStrikeCounter = exports.LoadStrikeMetric = exports.LoadStrikeSimulation = exports.LoadStrikeScenario = exports.LoadStrikeRunner = exports.LoadStrikeOperationType = exports.LoadStrikeScenarioOperation = exports.LoadStrikeLogLevel = exports.LoadStrikeResponse = exports.LoadStrikeReportFormat = exports.LoadStrikeNodeType = exports.LoadStrikePluginDataTable = exports.LoadStrikePluginData = exports.LoadStrikeContext = exports.ScenarioTrackingExtensions = exports.CrossPlatformScenarioConfigurator = void 0;
4
- exports.TimescaleDbReportingSinkOptions = void 0;
3
+ exports.OtelCollectorReportingSinkOptions = exports.OtelCollectorReportingSink = exports.InfluxDbReportingSinkOptions = exports.InfluxDbReportingSink = exports.GrafanaLokiReportingSinkOptions = exports.GrafanaLokiReportingSink = exports.DatadogReportingSinkOptions = exports.DatadogReportingSink = exports.HttpAuthOptions = exports.HttpOAuth2ClientCredentialsOptions = exports.PushDiffusionEndpointDefinition = exports.DelegateStreamEndpointDefinition = exports.AzureEventHubsEndpointDefinition = exports.RedisStreamsEndpointDefinition = exports.NatsEndpointDefinition = exports.RabbitMqEndpointDefinition = exports.KafkaSaslOptions = exports.KafkaEndpointDefinition = exports.HttpEndpointDefinition = exports.TrafficEndpointDefinition = exports.EndpointAdapterFactory = exports.TrackingFieldSelector = exports.TrackingPayloadBuilder = exports.RedisCorrelationStore = exports.RedisCorrelationStoreOptions = exports.InMemoryCorrelationStore = exports.CrossPlatformTrackingRuntime = exports.CorrelationStoreConfiguration = exports.LoadStrikeThreshold = exports.LoadStrikeStep = exports.LoadStrikeGauge = exports.LoadStrikeCounter = exports.LoadStrikeMetric = exports.LoadStrikeSimulation = exports.LoadStrikeScenario = exports.LoadStrikeRunner = exports.LoadStrikeOperationType = exports.LoadStrikeScenarioOperation = exports.LoadStrikeLogLevel = exports.LoadStrikeResponse = exports.LoadStrikeReportFormat = exports.LoadStrikeNodeType = exports.LoadStrikePluginDataTable = exports.LoadStrikePluginData = exports.LoadStrikeContext = exports.ScenarioTrackingExtensions = exports.CrossPlatformScenarioConfigurator = exports.LoadStrikeAutopilotReadiness = exports.LoadStrikeAutopilotResult = exports.LoadStrikeAutopilot = void 0;
4
+ exports.TimescaleDbReportingSinkOptions = exports.TimescaleDbReportingSink = exports.SplunkReportingSinkOptions = exports.SplunkReportingSink = void 0;
5
+ var autopilot_js_1 = require("./autopilot.js");
6
+ Object.defineProperty(exports, "LoadStrikeAutopilot", { enumerable: true, get: function () { return autopilot_js_1.LoadStrikeAutopilot; } });
7
+ Object.defineProperty(exports, "LoadStrikeAutopilotResult", { enumerable: true, get: function () { return autopilot_js_1.LoadStrikeAutopilotResult; } });
8
+ var autopilot_contracts_js_1 = require("./autopilot-contracts.js");
9
+ Object.defineProperty(exports, "LoadStrikeAutopilotReadiness", { enumerable: true, get: function () { return autopilot_contracts_js_1.LoadStrikeAutopilotReadiness; } });
5
10
  var runtime_js_1 = require("./runtime.js");
6
11
  Object.defineProperty(exports, "CrossPlatformScenarioConfigurator", { enumerable: true, get: function () { return runtime_js_1.CrossPlatformScenarioConfigurator; } });
7
12
  Object.defineProperty(exports, "ScenarioTrackingExtensions", { enumerable: true, get: function () { return runtime_js_1.ScenarioTrackingExtensions; } });
package/dist/cjs/local.js CHANGED
@@ -589,6 +589,9 @@ function collectRequestedFeatures(request) {
589
589
  }
590
590
  for (const scenarioValue of scenarios) {
591
591
  const scenario = asRecord(scenarioValue);
592
+ for (const feature of normalizeStringArray(pickValue(scenario, "InternalLicenseFeatures", "internalLicenseFeatures"))) {
593
+ features.add(feature);
594
+ }
592
595
  if (asList(scenario.Thresholds).length > 0) {
593
596
  features.add("policy.report_finalizer_and_threshold_controls");
594
597
  }
@@ -1584,7 +1584,7 @@ class LoadStrikeContext {
1584
1584
  }
1585
1585
  exports.LoadStrikeContext = LoadStrikeContext;
1586
1586
  class LoadStrikeScenario {
1587
- constructor(name, runHandler, initHandler, cleanHandler, loadSimulations, thresholds, trackingConfiguration, maxFailCount, withoutWarmUpValue, warmUpDurationSeconds, weight, restartIterationOnFail) {
1587
+ constructor(name, runHandler, initHandler, cleanHandler, loadSimulations, thresholds, trackingConfiguration, maxFailCount, withoutWarmUpValue, warmUpDurationSeconds, weight, restartIterationOnFail, internalLicenseFeatures = []) {
1588
1588
  this.name = name;
1589
1589
  this.runHandler = runHandler;
1590
1590
  this.initHandler = initHandler;
@@ -1597,6 +1597,7 @@ class LoadStrikeScenario {
1597
1597
  this.warmUpDurationSeconds = warmUpDurationSeconds;
1598
1598
  this.weight = weight;
1599
1599
  this.restartIterationOnFail = restartIterationOnFail;
1600
+ this.internalLicenseFeatures = normalizeStringArray(internalLicenseFeatures);
1600
1601
  }
1601
1602
  static create(name, runHandler) {
1602
1603
  const scenarioName = requireNonEmpty(name, "Scenario name must be provided.");
@@ -1639,7 +1640,7 @@ class LoadStrikeScenario {
1639
1640
  if (typeof handler !== "function") {
1640
1641
  throw new TypeError("Init handler must be provided.");
1641
1642
  }
1642
- return new LoadStrikeScenario(this.name, this.runHandler, handler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1643
+ return new LoadStrikeScenario(this.name, this.runHandler, handler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1643
1644
  }
1644
1645
  /**
1645
1646
  * Configures init async for this SDK object.
@@ -1656,7 +1657,7 @@ class LoadStrikeScenario {
1656
1657
  if (typeof handler !== "function") {
1657
1658
  throw new TypeError("Clean handler must be provided.");
1658
1659
  }
1659
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, handler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1660
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, handler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1660
1661
  }
1661
1662
  /**
1662
1663
  * Configures clean async for this SDK object.
@@ -1673,14 +1674,14 @@ class LoadStrikeScenario {
1673
1674
  if (!Number.isFinite(maxFailCount)) {
1674
1675
  throw new RangeError("maxFailCount should be a finite number.");
1675
1676
  }
1676
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, Math.trunc(maxFailCount), this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1677
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, Math.trunc(maxFailCount), this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1677
1678
  }
1678
1679
  /**
1679
1680
  * Configures out warm up for this SDK object.
1680
1681
  * Use this when out warm up should be set explicitly before the run starts.
1681
1682
  */
1682
1683
  withoutWarmUp() {
1683
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, true, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1684
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, true, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1684
1685
  }
1685
1686
  /**
1686
1687
  * Configures warm up duration for this SDK object.
@@ -1690,7 +1691,7 @@ class LoadStrikeScenario {
1690
1691
  if (!Number.isFinite(durationSeconds)) {
1691
1692
  throw new RangeError("Warmup duration should be a finite number.");
1692
1693
  }
1693
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, durationSeconds, this.weight, this.restartIterationOnFail);
1694
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, durationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1694
1695
  }
1695
1696
  /**
1696
1697
  * Configures weight for this SDK object.
@@ -1700,14 +1701,14 @@ class LoadStrikeScenario {
1700
1701
  if (!Number.isFinite(weight)) {
1701
1702
  throw new RangeError("Weight should be a finite number.");
1702
1703
  }
1703
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, Math.trunc(weight), this.restartIterationOnFail);
1704
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, Math.trunc(weight), this.restartIterationOnFail, this.internalLicenseFeatures);
1704
1705
  }
1705
1706
  /**
1706
1707
  * Configures restart iteration on fail for this SDK object.
1707
1708
  * Use this when restart iteration on fail should be set explicitly before the run starts.
1708
1709
  */
1709
1710
  withRestartIterationOnFail(shouldRestart) {
1710
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, Boolean(shouldRestart));
1711
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, Boolean(shouldRestart), this.internalLicenseFeatures);
1711
1712
  }
1712
1713
  /**
1713
1714
  * Configures cross platform tracking for this SDK object.
@@ -1728,7 +1729,7 @@ class LoadStrikeScenario {
1728
1729
  ? mapRuntimeTrackingEndpointSpec(destinationSpec)
1729
1730
  : null;
1730
1731
  validateRuntimeTrackingConfiguration(copied, sourceEndpoint, destinationEndpoint);
1731
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, copied, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1732
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, copied, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1732
1733
  }
1733
1734
  /**
1734
1735
  * Configures load simulations for this SDK object.
@@ -1738,7 +1739,7 @@ class LoadStrikeScenario {
1738
1739
  if (!simulations.length) {
1739
1740
  throw new Error("At least one load simulation should be provided.");
1740
1741
  }
1741
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, simulations.map((simulation) => attachLoadSimulationProjection({ ...simulation })), this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1742
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, simulations.map((simulation) => attachLoadSimulationProjection({ ...simulation })), this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1742
1743
  }
1743
1744
  /**
1744
1745
  * Configures thresholds for this SDK object.
@@ -1748,7 +1749,7 @@ class LoadStrikeScenario {
1748
1749
  if (!thresholds.length) {
1749
1750
  throw new Error("At least one threshold should be provided.");
1750
1751
  }
1751
- return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, thresholds.map((threshold) => ({ ...threshold })), this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
1752
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, thresholds.map((threshold) => ({ ...threshold })), this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, this.internalLicenseFeatures);
1752
1753
  }
1753
1754
  /**
1754
1755
  * Returns simulations.
@@ -1806,6 +1807,13 @@ class LoadStrikeScenario {
1806
1807
  shouldRestartIterationOnFail() {
1807
1808
  return this.restartIterationOnFail;
1808
1809
  }
1810
+ __loadStrikeInternalLicenseFeatures() {
1811
+ return [...this.internalLicenseFeatures];
1812
+ }
1813
+ __loadStrikeWithInternalLicenseFeatures(...features) {
1814
+ const merged = Array.from(new Set([...this.internalLicenseFeatures, ...normalizeStringArray(features)]));
1815
+ return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail, merged);
1816
+ }
1809
1817
  async invokeInit(context) {
1810
1818
  if (this.initHandler) {
1811
1819
  await this.initHandler(context);
@@ -7475,17 +7483,24 @@ function buildLicenseValidationPayload(options, scenarios) {
7475
7483
  const context = {
7476
7484
  ...toRunContext(options)
7477
7485
  };
7478
- const scenarioSpecs = scenarios.map((scenario) => ({
7479
- Name: scenario.name,
7480
- MaxFailCount: scenario.getMaxFailCount(),
7481
- RestartIterationOnFail: scenario.shouldRestartIterationOnFail(),
7482
- WithoutWarmUp: scenario.isWithoutWarmUp(),
7483
- WarmUpDurationSeconds: scenario.getWarmUpDurationSeconds(),
7484
- Weight: scenario.getWeight(),
7485
- LoadSimulations: [...scenario.getSimulations()],
7486
- Thresholds: [...scenario.getThresholds()],
7487
- Tracking: scenario.getTrackingConfiguration() ?? {}
7488
- }));
7486
+ const scenarioSpecs = scenarios.map((scenario) => {
7487
+ const row = {
7488
+ Name: scenario.name,
7489
+ MaxFailCount: scenario.getMaxFailCount(),
7490
+ RestartIterationOnFail: scenario.shouldRestartIterationOnFail(),
7491
+ WithoutWarmUp: scenario.isWithoutWarmUp(),
7492
+ WarmUpDurationSeconds: scenario.getWarmUpDurationSeconds(),
7493
+ Weight: scenario.getWeight(),
7494
+ LoadSimulations: [...scenario.getSimulations()],
7495
+ Thresholds: [...scenario.getThresholds()],
7496
+ Tracking: scenario.getTrackingConfiguration() ?? {}
7497
+ };
7498
+ const internalLicenseFeatures = scenario.__loadStrikeInternalLicenseFeatures();
7499
+ if (internalLicenseFeatures.length > 0) {
7500
+ row.InternalLicenseFeatures = internalLicenseFeatures;
7501
+ }
7502
+ return row;
7503
+ });
7489
7504
  return {
7490
7505
  Context: context,
7491
7506
  Scenarios: scenarioSpecs,
@@ -0,0 +1,8 @@
1
+ export const LoadStrikeAutopilotReadiness = {
2
+ Ready: "Ready",
3
+ RequiresSecrets: "RequiresSecrets",
4
+ RequiresEndpointBinding: "RequiresEndpointBinding",
5
+ RequiresTargetBinding: "RequiresTargetBinding",
6
+ RequiresTrackingSelector: "RequiresTrackingSelector",
7
+ RequiresReview: "RequiresReview"
8
+ };