@loadstrike/loadstrike-sdk 1.0.26901 → 1.0.27101
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 +6 -2
- package/dist/cjs/local.js +3 -1
- package/dist/cjs/runtime.js +109 -1
- package/dist/cjs/transports.js +346 -12
- package/dist/esm/index.js +2 -2
- package/dist/esm/local.js +3 -1
- package/dist/esm/runtime.js +106 -0
- package/dist/esm/transports.js +345 -11
- package/dist/types/contracts.d.ts +18 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/runtime.d.ts +53 -0
- package/dist/types/transports.d.ts +80 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.TimescaleDbReportingSinkOptions = exports.TimescaleDbReportingSink = exports.SplunkReportingSinkOptions = exports.SplunkReportingSink = exports.PortalReportingSink = exports.OtelCollectorReportingSinkOptions = exports.OtelCollectorReportingSink = exports.InfluxDbReportingSinkOptions = exports.InfluxDbReportingSink = exports.GrafanaLokiReportingSinkOptions = void 0;
|
|
3
|
+
exports.HttpOAuth2ClientCredentialsOptions = exports.WebSocketEndpointDefinition = exports.GrpcEndpointDefinition = exports.PushDiffusionEndpointDefinition = exports.DelegateStreamEndpointDefinition = exports.SqsEndpointDefinition = exports.AzureEventHubsEndpointDefinition = exports.RedisStreamsEndpointDefinition = exports.NatsEndpointDefinition = exports.RabbitMqEndpointDefinition = exports.KafkaSaslOptions = exports.KafkaEndpointDefinition = exports.HttpEndpointDefinition = exports.TrafficEndpointDefinition = exports.LOADSTRIKE_TRACE_ID_TRACKING_FIELD = exports.LOADSTRIKE_TRACE_ID_HEADER = 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.CrossPlatformTrackingConfiguration = exports.LoadStrikeTrafficMix = exports.LoadStrikeSimulation = exports.LoadStrikeScenarioShare = exports.LoadStrikeScenario = exports.LoadStrikeRunner = exports.LoadStrikeOperationType = exports.LoadStrikeScenarioOperation = exports.LoadStrikeLogLevel = exports.LoadStrikeResponse = exports.LoadStrikeReportFormat = exports.LoadStrikeNodeType = exports.LoadStrikePluginDataTable = exports.LoadStrikePluginData = exports.LoadStrikeBrowserWebVitals = exports.LoadStrikeAccessibility = exports.LoadStrikeContext = exports.ScenarioTrackingExtensions = exports.CrossPlatformScenarioConfigurator = exports.LoadStrikeAutopilotReadiness = exports.LoadStrikeAutopilotResult = exports.LoadStrikeAutopilot = void 0;
|
|
4
|
+
exports.TimescaleDbReportingSinkOptions = exports.TimescaleDbReportingSink = exports.SplunkReportingSinkOptions = exports.SplunkReportingSink = exports.PortalReportingSink = exports.OtelCollectorReportingSinkOptions = exports.OtelCollectorReportingSink = exports.InfluxDbReportingSinkOptions = exports.InfluxDbReportingSink = exports.GrafanaLokiReportingSinkOptions = exports.GrafanaLokiReportingSink = exports.DatadogReportingSinkOptions = exports.DatadogReportingSink = exports.HttpAuthOptions = void 0;
|
|
5
5
|
var autopilot_js_1 = require("./autopilot.js");
|
|
6
6
|
Object.defineProperty(exports, "LoadStrikeAutopilot", { enumerable: true, get: function () { return autopilot_js_1.LoadStrikeAutopilot; } });
|
|
7
7
|
Object.defineProperty(exports, "LoadStrikeAutopilotResult", { enumerable: true, get: function () { return autopilot_js_1.LoadStrikeAutopilotResult; } });
|
|
@@ -11,6 +11,8 @@ var runtime_js_1 = require("./runtime.js");
|
|
|
11
11
|
Object.defineProperty(exports, "CrossPlatformScenarioConfigurator", { enumerable: true, get: function () { return runtime_js_1.CrossPlatformScenarioConfigurator; } });
|
|
12
12
|
Object.defineProperty(exports, "ScenarioTrackingExtensions", { enumerable: true, get: function () { return runtime_js_1.ScenarioTrackingExtensions; } });
|
|
13
13
|
Object.defineProperty(exports, "LoadStrikeContext", { enumerable: true, get: function () { return runtime_js_1.LoadStrikeContext; } });
|
|
14
|
+
Object.defineProperty(exports, "LoadStrikeAccessibility", { enumerable: true, get: function () { return runtime_js_1.LoadStrikeAccessibility; } });
|
|
15
|
+
Object.defineProperty(exports, "LoadStrikeBrowserWebVitals", { enumerable: true, get: function () { return runtime_js_1.LoadStrikeBrowserWebVitals; } });
|
|
14
16
|
Object.defineProperty(exports, "LoadStrikePluginData", { enumerable: true, get: function () { return runtime_js_1.LoadStrikePluginData; } });
|
|
15
17
|
Object.defineProperty(exports, "LoadStrikePluginDataTable", { enumerable: true, get: function () { return runtime_js_1.LoadStrikePluginDataTable; } });
|
|
16
18
|
Object.defineProperty(exports, "LoadStrikeNodeType", { enumerable: true, get: function () { return runtime_js_1.LoadStrikeNodeType; } });
|
|
@@ -52,6 +54,8 @@ Object.defineProperty(exports, "AzureEventHubsEndpointDefinition", { enumerable:
|
|
|
52
54
|
Object.defineProperty(exports, "SqsEndpointDefinition", { enumerable: true, get: function () { return transports_js_1.SqsEndpointDefinition; } });
|
|
53
55
|
Object.defineProperty(exports, "DelegateStreamEndpointDefinition", { enumerable: true, get: function () { return transports_js_1.DelegateStreamEndpointDefinition; } });
|
|
54
56
|
Object.defineProperty(exports, "PushDiffusionEndpointDefinition", { enumerable: true, get: function () { return transports_js_1.PushDiffusionEndpointDefinition; } });
|
|
57
|
+
Object.defineProperty(exports, "GrpcEndpointDefinition", { enumerable: true, get: function () { return transports_js_1.GrpcEndpointDefinition; } });
|
|
58
|
+
Object.defineProperty(exports, "WebSocketEndpointDefinition", { enumerable: true, get: function () { return transports_js_1.WebSocketEndpointDefinition; } });
|
|
55
59
|
Object.defineProperty(exports, "HttpOAuth2ClientCredentialsOptions", { enumerable: true, get: function () { return transports_js_1.HttpOAuth2ClientCredentialsOptions; } });
|
|
56
60
|
Object.defineProperty(exports, "HttpAuthOptions", { enumerable: true, get: function () { return transports_js_1.HttpAuthOptions; } });
|
|
57
61
|
var sinks_js_1 = require("./sinks.js");
|
package/dist/cjs/local.js
CHANGED
|
@@ -79,7 +79,9 @@ const TRACKING_FEATURE_BY_KIND = {
|
|
|
79
79
|
delegatestream: "endpoint.delegate_stream",
|
|
80
80
|
nats: "endpoint.nats",
|
|
81
81
|
redisstreams: "endpoint.redis_streams",
|
|
82
|
-
sqs: "endpoint.sqs"
|
|
82
|
+
sqs: "endpoint.sqs",
|
|
83
|
+
grpc: "endpoint.grpc",
|
|
84
|
+
websocket: "endpoint.websocket"
|
|
83
85
|
};
|
|
84
86
|
const CI_ENVIRONMENT_VARIABLES = [
|
|
85
87
|
"GITHUB_ACTIONS",
|
package/dist/cjs/runtime.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.__loadstrikeTestExports = exports.LoadStrikeRunner = exports.LoadStrikeTrafficMix = exports.LoadStrikeScenarioShare = exports.LoadStrikeScenario = exports.LoadStrikeContext = exports.ScenarioTrackingExtensions = exports.CrossPlatformScenarioConfigurator = exports.LoadStrikeThreshold = exports.LoadStrikeMetric = exports.LoadStrikeGauge = exports.LoadStrikeCounter = exports.LoadStrikeSimulation = exports.LoadStrikeStep = exports.LoadStrikeResponse = exports.LoadStrikePluginData = exports.LoadStrikePluginDataTable = exports.CrossPlatformTrackingConfiguration = exports.LoadStrikeOperationType = exports.LoadStrikeScenarioOperation = exports.LoadStrikeLogLevel = exports.LoadStrikeReportFormat = exports.LoadStrikeNodeType = void 0;
|
|
6
|
+
exports.__loadstrikeTestExports = exports.LoadStrikeRunner = exports.LoadStrikeTrafficMix = exports.LoadStrikeScenarioShare = exports.LoadStrikeScenario = exports.LoadStrikeBrowserWebVitals = exports.LoadStrikeAccessibility = exports.LoadStrikeContext = exports.ScenarioTrackingExtensions = exports.CrossPlatformScenarioConfigurator = exports.LoadStrikeThreshold = exports.LoadStrikeMetric = exports.LoadStrikeGauge = exports.LoadStrikeCounter = exports.LoadStrikeSimulation = exports.LoadStrikeStep = exports.LoadStrikeResponse = exports.LoadStrikePluginData = exports.LoadStrikePluginDataTable = exports.CrossPlatformTrackingConfiguration = exports.LoadStrikeOperationType = exports.LoadStrikeScenarioOperation = exports.LoadStrikeLogLevel = exports.LoadStrikeReportFormat = exports.LoadStrikeNodeType = void 0;
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const node_crypto_1 = require("node:crypto");
|
|
9
9
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -1622,6 +1622,114 @@ class LoadStrikeContext {
|
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
1624
|
exports.LoadStrikeContext = LoadStrikeContext;
|
|
1625
|
+
const ACCESSIBILITY_TESTING_FEATURE = "testing.accessibility";
|
|
1626
|
+
const BROWSER_WEB_VITALS_FEATURE = "testing.browser_web_vitals";
|
|
1627
|
+
class LoadStrikeAccessibility {
|
|
1628
|
+
static createScenario(name, options, check) {
|
|
1629
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
1630
|
+
throw new Error("Scenario name must be provided.");
|
|
1631
|
+
}
|
|
1632
|
+
validateAbsoluteUrl(options?.url, "Accessibility check URL");
|
|
1633
|
+
if (typeof check !== "function") {
|
|
1634
|
+
throw new TypeError("Accessibility check callback must be provided.");
|
|
1635
|
+
}
|
|
1636
|
+
return LoadStrikeScenario
|
|
1637
|
+
.create(name, async (scenarioContext) => {
|
|
1638
|
+
const result = await check({ options, scenarioContext });
|
|
1639
|
+
const failure = evaluateAccessibilityResult(options, result);
|
|
1640
|
+
return failure
|
|
1641
|
+
? LoadStrikeResponse.fail("accessibility", failure)
|
|
1642
|
+
: LoadStrikeResponse.ok("200", 0, `Accessibility check passed with ${(result.violations ?? []).length} violation(s).`);
|
|
1643
|
+
})
|
|
1644
|
+
.withoutWarmUp()
|
|
1645
|
+
.__loadStrikeWithInternalLicenseFeatures(ACCESSIBILITY_TESTING_FEATURE);
|
|
1646
|
+
}
|
|
1647
|
+
static CreateScenario(name, options, check) {
|
|
1648
|
+
return LoadStrikeAccessibility.createScenario(name, options, check);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
exports.LoadStrikeAccessibility = LoadStrikeAccessibility;
|
|
1652
|
+
class LoadStrikeBrowserWebVitals {
|
|
1653
|
+
static createScenario(name, options, measure) {
|
|
1654
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
1655
|
+
throw new Error("Scenario name must be provided.");
|
|
1656
|
+
}
|
|
1657
|
+
validateAbsoluteUrl(options?.url, "Browser Web Vitals URL");
|
|
1658
|
+
if (typeof measure !== "function") {
|
|
1659
|
+
throw new TypeError("Browser Web Vitals measurement callback must be provided.");
|
|
1660
|
+
}
|
|
1661
|
+
return LoadStrikeScenario
|
|
1662
|
+
.create(name, async (scenarioContext) => {
|
|
1663
|
+
const result = await measure({ options, scenarioContext });
|
|
1664
|
+
const failure = evaluateWebVitalsResult(options, result);
|
|
1665
|
+
return failure
|
|
1666
|
+
? LoadStrikeResponse.fail("web_vitals", failure)
|
|
1667
|
+
: LoadStrikeResponse.ok("200", 0, "Browser Web Vitals check passed.");
|
|
1668
|
+
})
|
|
1669
|
+
.withoutWarmUp()
|
|
1670
|
+
.__loadStrikeWithInternalLicenseFeatures(BROWSER_WEB_VITALS_FEATURE);
|
|
1671
|
+
}
|
|
1672
|
+
static CreateScenario(name, options, measure) {
|
|
1673
|
+
return LoadStrikeBrowserWebVitals.createScenario(name, options, measure);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
exports.LoadStrikeBrowserWebVitals = LoadStrikeBrowserWebVitals;
|
|
1677
|
+
function validateAbsoluteUrl(value, label) {
|
|
1678
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1679
|
+
throw new Error(`${label} must be provided.`);
|
|
1680
|
+
}
|
|
1681
|
+
try {
|
|
1682
|
+
const parsed = new URL(value);
|
|
1683
|
+
if (!parsed.protocol || !parsed.host) {
|
|
1684
|
+
throw new Error("invalid");
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
catch {
|
|
1688
|
+
throw new Error(`${label} must be an absolute URL.`);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
function evaluateAccessibilityResult(options, result) {
|
|
1692
|
+
if (!result) {
|
|
1693
|
+
return "Accessibility check did not return a result.";
|
|
1694
|
+
}
|
|
1695
|
+
const violations = Array.isArray(result.violations) ? result.violations : [];
|
|
1696
|
+
const maxViolations = Math.max(0, Number(options.maxViolations ?? 0));
|
|
1697
|
+
const critical = countAccessibilityImpact(violations, "critical");
|
|
1698
|
+
const serious = countAccessibilityImpact(violations, "serious");
|
|
1699
|
+
const maxCritical = Math.max(0, Number(options.maxCriticalViolations ?? 0));
|
|
1700
|
+
const maxSerious = Math.max(0, Number(options.maxSeriousViolations ?? 0));
|
|
1701
|
+
if (violations.length > maxViolations) {
|
|
1702
|
+
return `Accessibility violations ${violations.length} exceeded limit ${maxViolations}.`;
|
|
1703
|
+
}
|
|
1704
|
+
if (critical > maxCritical) {
|
|
1705
|
+
return `Critical accessibility violations ${critical} exceeded limit ${maxCritical}.`;
|
|
1706
|
+
}
|
|
1707
|
+
if (serious > maxSerious) {
|
|
1708
|
+
return `Serious accessibility violations ${serious} exceeded limit ${maxSerious}.`;
|
|
1709
|
+
}
|
|
1710
|
+
return "";
|
|
1711
|
+
}
|
|
1712
|
+
function countAccessibilityImpact(violations, impact) {
|
|
1713
|
+
return violations.filter((violation) => String(violation.impact ?? "").toLowerCase() === impact).length;
|
|
1714
|
+
}
|
|
1715
|
+
function evaluateWebVitalsResult(options, result) {
|
|
1716
|
+
if (!result) {
|
|
1717
|
+
return "Browser Web Vitals check did not return a result.";
|
|
1718
|
+
}
|
|
1719
|
+
return firstWebVitalViolation(["LCP", result.largestContentfulPaintMs, options.maxLargestContentfulPaintMs, "ms"], ["INP", result.interactionToNextPaintMs, options.maxInteractionToNextPaintMs, "ms"], ["CLS", result.cumulativeLayoutShift, options.maxCumulativeLayoutShift, ""], ["FCP", result.firstContentfulPaintMs, options.maxFirstContentfulPaintMs, "ms"], ["TTFB", result.timeToFirstByteMs, options.maxTimeToFirstByteMs, "ms"]);
|
|
1720
|
+
}
|
|
1721
|
+
function firstWebVitalViolation(...values) {
|
|
1722
|
+
for (const [name, actualRaw, limitRaw, unit] of values) {
|
|
1723
|
+
const actual = Number(actualRaw);
|
|
1724
|
+
const limit = Number(limitRaw);
|
|
1725
|
+
if (!Number.isFinite(actual) || !Number.isFinite(limit) || actual <= limit) {
|
|
1726
|
+
continue;
|
|
1727
|
+
}
|
|
1728
|
+
const suffix = unit ? ` ${unit}` : "";
|
|
1729
|
+
return `${name} ${actual}${suffix} exceeded limit ${limit}${suffix}.`;
|
|
1730
|
+
}
|
|
1731
|
+
return "";
|
|
1732
|
+
}
|
|
1625
1733
|
class LoadStrikeScenario {
|
|
1626
1734
|
constructor(name, runHandler, initHandler, cleanHandler, loadSimulations, thresholds, trackingConfiguration, maxFailCount, withoutWarmUpValue, warmUpDurationSeconds, weight, restartIterationOnFail, internalLicenseFeatures = []) {
|
|
1627
1735
|
this.name = name;
|
package/dist/cjs/transports.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.__loadstrikeTestExports = exports.EndpointAdapterFactory = exports.KafkaSaslOptions = exports.HttpAuthOptions = exports.HttpOAuth2ClientCredentialsOptions = exports.PushDiffusionEndpointDefinition = exports.DelegateStreamEndpointDefinition = exports.SqsEndpointDefinition = exports.AzureEventHubsEndpointDefinition = exports.RedisStreamsEndpointDefinition = exports.NatsEndpointDefinition = exports.RabbitMqEndpointDefinition = exports.KafkaEndpointDefinition = exports.HttpEndpointDefinition = exports.TrafficEndpointDefinition = exports.LOADSTRIKE_TRACE_ID_TRACKING_FIELD = exports.LOADSTRIKE_TRACE_ID_HEADER = void 0;
|
|
36
|
+
exports.__loadstrikeTestExports = exports.EndpointAdapterFactory = exports.KafkaSaslOptions = exports.HttpAuthOptions = exports.HttpOAuth2ClientCredentialsOptions = exports.WebSocketEndpointDefinition = exports.GrpcEndpointDefinition = exports.PushDiffusionEndpointDefinition = exports.DelegateStreamEndpointDefinition = exports.SqsEndpointDefinition = exports.AzureEventHubsEndpointDefinition = exports.RedisStreamsEndpointDefinition = exports.NatsEndpointDefinition = exports.RabbitMqEndpointDefinition = exports.KafkaEndpointDefinition = exports.HttpEndpointDefinition = exports.TrafficEndpointDefinition = exports.LOADSTRIKE_TRACE_ID_TRACKING_FIELD = exports.LOADSTRIKE_TRACE_ID_HEADER = void 0;
|
|
37
37
|
const node_crypto_1 = require("node:crypto");
|
|
38
38
|
const correlation_js_1 = require("./correlation.js");
|
|
39
39
|
exports.LOADSTRIKE_TRACE_ID_HEADER = "loadstrike-trace-id";
|
|
@@ -321,6 +321,74 @@ class PushDiffusionEndpointDefinitionModel extends TrafficEndpointDefinitionMode
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
+
class GrpcEndpointDefinitionModel extends TrafficEndpointDefinitionModel {
|
|
325
|
+
constructor(initial) {
|
|
326
|
+
super(initial);
|
|
327
|
+
this.Kind = "Grpc";
|
|
328
|
+
this.Target = "";
|
|
329
|
+
this.ServiceName = "";
|
|
330
|
+
this.MethodName = "";
|
|
331
|
+
this.MethodType = "Unary";
|
|
332
|
+
this.DeadlineSeconds = 30;
|
|
333
|
+
this.ConnectionMetadata = {};
|
|
334
|
+
this.Metadata = {};
|
|
335
|
+
initializeGrpcEndpointDefinitionModel(this, initial);
|
|
336
|
+
}
|
|
337
|
+
Validate() {
|
|
338
|
+
super.Validate();
|
|
339
|
+
requireNonEmptyString(this.Target, "Target must be provided for gRPC endpoint definitions.");
|
|
340
|
+
requireNonEmptyString(this.ServiceName, "ServiceName must be provided for gRPC endpoint definitions.");
|
|
341
|
+
requireNonEmptyString(this.MethodName, "MethodName must be provided for gRPC endpoint definitions.");
|
|
342
|
+
requireNonEmptyString(this.MethodType, "MethodType must be provided for gRPC endpoint definitions.");
|
|
343
|
+
if (this.DeadlineSeconds <= 0) {
|
|
344
|
+
throw new RangeError("Deadline must be greater than zero.");
|
|
345
|
+
}
|
|
346
|
+
if (this.Mode === "Produce" && typeof this.ProduceAsync !== "function") {
|
|
347
|
+
throw new Error("ProduceAsync delegate must be provided when endpoint mode is Produce.");
|
|
348
|
+
}
|
|
349
|
+
if (this.Mode === "Consume" && typeof this.ConsumeAsync !== "function") {
|
|
350
|
+
throw new Error("ConsumeAsync delegate must be provided when endpoint mode is Consume.");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
class WebSocketEndpointDefinitionModel extends TrafficEndpointDefinitionModel {
|
|
355
|
+
constructor(initial) {
|
|
356
|
+
super(initial);
|
|
357
|
+
this.Kind = "WebSocket";
|
|
358
|
+
this.Url = "";
|
|
359
|
+
this.Subprotocols = [];
|
|
360
|
+
this.ConnectTimeoutSeconds = 30;
|
|
361
|
+
this.CloseTimeoutSeconds = 5;
|
|
362
|
+
this.ConnectionMetadata = {};
|
|
363
|
+
initializeWebSocketEndpointDefinitionModel(this, initial);
|
|
364
|
+
}
|
|
365
|
+
Validate() {
|
|
366
|
+
super.Validate();
|
|
367
|
+
const url = requireNonEmptyString(this.Url, "Url must be provided for WebSocket endpoint definitions.");
|
|
368
|
+
let parsed;
|
|
369
|
+
try {
|
|
370
|
+
parsed = new URL(url);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
throw new Error("Url must be an absolute ws:// or wss:// URI.");
|
|
374
|
+
}
|
|
375
|
+
if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
|
|
376
|
+
throw new Error("Url must be an absolute ws:// or wss:// URI.");
|
|
377
|
+
}
|
|
378
|
+
if (this.ConnectTimeoutSeconds <= 0) {
|
|
379
|
+
throw new RangeError("ConnectTimeout must be greater than zero.");
|
|
380
|
+
}
|
|
381
|
+
if (this.CloseTimeoutSeconds <= 0) {
|
|
382
|
+
throw new RangeError("CloseTimeout must be greater than zero.");
|
|
383
|
+
}
|
|
384
|
+
if (this.Mode === "Produce" && typeof this.ProduceAsync !== "function") {
|
|
385
|
+
throw new Error("ProduceAsync delegate must be provided when endpoint mode is Produce.");
|
|
386
|
+
}
|
|
387
|
+
if (this.Mode === "Consume" && typeof this.ConsumeAsync !== "function") {
|
|
388
|
+
throw new Error("ConsumeAsync delegate must be provided when endpoint mode is Consume.");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
324
392
|
exports.TrafficEndpointDefinition = TrafficEndpointDefinitionModel;
|
|
325
393
|
exports.HttpEndpointDefinition = HttpEndpointDefinitionModel;
|
|
326
394
|
exports.KafkaEndpointDefinition = KafkaEndpointDefinitionModel;
|
|
@@ -331,6 +399,8 @@ exports.AzureEventHubsEndpointDefinition = AzureEventHubsEndpointDefinitionModel
|
|
|
331
399
|
exports.SqsEndpointDefinition = SqsEndpointDefinitionModel;
|
|
332
400
|
exports.DelegateStreamEndpointDefinition = DelegateStreamEndpointDefinitionModel;
|
|
333
401
|
exports.PushDiffusionEndpointDefinition = PushDiffusionEndpointDefinitionModel;
|
|
402
|
+
exports.GrpcEndpointDefinition = GrpcEndpointDefinitionModel;
|
|
403
|
+
exports.WebSocketEndpointDefinition = WebSocketEndpointDefinitionModel;
|
|
334
404
|
exports.HttpOAuth2ClientCredentialsOptions = HttpOAuth2ClientCredentialsOptionsModel;
|
|
335
405
|
exports.HttpAuthOptions = HttpAuthOptionsModel;
|
|
336
406
|
exports.KafkaSaslOptions = KafkaSaslOptionsModel;
|
|
@@ -780,6 +850,101 @@ function initializePushDiffusionEndpointDefinitionModel(target, initial) {
|
|
|
780
850
|
target.SubscribeAsync = subscribeAsync;
|
|
781
851
|
}
|
|
782
852
|
}
|
|
853
|
+
function initializeGrpcEndpointDefinitionModel(target, initial) {
|
|
854
|
+
const raw = asRecordOrEmpty(initial);
|
|
855
|
+
const targetUrl = pickOptionalEndpointString(raw, "Target", "target");
|
|
856
|
+
if (targetUrl) {
|
|
857
|
+
target.Target = targetUrl;
|
|
858
|
+
}
|
|
859
|
+
const serviceName = pickOptionalEndpointString(raw, "ServiceName", "serviceName");
|
|
860
|
+
if (serviceName) {
|
|
861
|
+
target.ServiceName = serviceName;
|
|
862
|
+
}
|
|
863
|
+
const methodName = pickOptionalEndpointString(raw, "MethodName", "methodName");
|
|
864
|
+
if (methodName) {
|
|
865
|
+
target.MethodName = methodName;
|
|
866
|
+
}
|
|
867
|
+
const methodType = pickOptionalEndpointString(raw, "MethodType", "methodType");
|
|
868
|
+
if (methodType) {
|
|
869
|
+
target.MethodType = methodType;
|
|
870
|
+
}
|
|
871
|
+
const deadlineMs = pickOptionalEndpointNumber(raw, "DeadlineMs", "deadlineMs");
|
|
872
|
+
const deadlineSeconds = pickOptionalEndpointNumber(raw, "DeadlineSeconds", "deadlineSeconds", "Deadline", "deadline");
|
|
873
|
+
if (deadlineMs != null) {
|
|
874
|
+
target.DeadlineSeconds = deadlineMs / 1000;
|
|
875
|
+
}
|
|
876
|
+
else if (deadlineSeconds != null) {
|
|
877
|
+
target.DeadlineSeconds = deadlineSeconds;
|
|
878
|
+
}
|
|
879
|
+
const produce = pickEndpointFunction(raw, "Produce", "produce");
|
|
880
|
+
if (produce) {
|
|
881
|
+
target.Produce = produce;
|
|
882
|
+
}
|
|
883
|
+
const consume = pickEndpointFunction(raw, "Consume", "consume");
|
|
884
|
+
if (consume) {
|
|
885
|
+
target.Consume = consume;
|
|
886
|
+
}
|
|
887
|
+
const produceAsync = pickEndpointFunction(raw, "ProduceAsync", "produceAsync");
|
|
888
|
+
if (produceAsync) {
|
|
889
|
+
target.ProduceAsync = produceAsync;
|
|
890
|
+
}
|
|
891
|
+
const consumeAsync = pickEndpointFunction(raw, "ConsumeAsync", "consumeAsync");
|
|
892
|
+
if (consumeAsync) {
|
|
893
|
+
target.ConsumeAsync = consumeAsync;
|
|
894
|
+
}
|
|
895
|
+
if (hasAnyEndpointField(raw, ["ConnectionMetadata", "connectionMetadata"])) {
|
|
896
|
+
target.ConnectionMetadata = pickEndpointStringRecord(raw, "ConnectionMetadata", "connectionMetadata");
|
|
897
|
+
}
|
|
898
|
+
if (hasAnyEndpointField(raw, ["Metadata", "metadata"])) {
|
|
899
|
+
target.Metadata = pickEndpointStringRecord(raw, "Metadata", "metadata");
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
function initializeWebSocketEndpointDefinitionModel(target, initial) {
|
|
903
|
+
const raw = asRecordOrEmpty(initial);
|
|
904
|
+
const url = pickOptionalEndpointString(raw, "Url", "url");
|
|
905
|
+
if (url) {
|
|
906
|
+
target.Url = url;
|
|
907
|
+
}
|
|
908
|
+
const subprotocols = pickEndpointStringArray(raw, "Subprotocols", "subprotocols");
|
|
909
|
+
if (subprotocols) {
|
|
910
|
+
target.Subprotocols = subprotocols;
|
|
911
|
+
}
|
|
912
|
+
const connectMs = pickOptionalEndpointNumber(raw, "ConnectTimeoutMs", "connectTimeoutMs");
|
|
913
|
+
const connectSeconds = pickOptionalEndpointNumber(raw, "ConnectTimeoutSeconds", "connectTimeoutSeconds", "ConnectTimeout", "connectTimeout");
|
|
914
|
+
if (connectMs != null) {
|
|
915
|
+
target.ConnectTimeoutSeconds = connectMs / 1000;
|
|
916
|
+
}
|
|
917
|
+
else if (connectSeconds != null) {
|
|
918
|
+
target.ConnectTimeoutSeconds = connectSeconds;
|
|
919
|
+
}
|
|
920
|
+
const closeMs = pickOptionalEndpointNumber(raw, "CloseTimeoutMs", "closeTimeoutMs");
|
|
921
|
+
const closeSeconds = pickOptionalEndpointNumber(raw, "CloseTimeoutSeconds", "closeTimeoutSeconds", "CloseTimeout", "closeTimeout");
|
|
922
|
+
if (closeMs != null) {
|
|
923
|
+
target.CloseTimeoutSeconds = closeMs / 1000;
|
|
924
|
+
}
|
|
925
|
+
else if (closeSeconds != null) {
|
|
926
|
+
target.CloseTimeoutSeconds = closeSeconds;
|
|
927
|
+
}
|
|
928
|
+
const produce = pickEndpointFunction(raw, "Produce", "produce");
|
|
929
|
+
if (produce) {
|
|
930
|
+
target.Produce = produce;
|
|
931
|
+
}
|
|
932
|
+
const consume = pickEndpointFunction(raw, "Consume", "consume");
|
|
933
|
+
if (consume) {
|
|
934
|
+
target.Consume = consume;
|
|
935
|
+
}
|
|
936
|
+
const produceAsync = pickEndpointFunction(raw, "ProduceAsync", "produceAsync");
|
|
937
|
+
if (produceAsync) {
|
|
938
|
+
target.ProduceAsync = produceAsync;
|
|
939
|
+
}
|
|
940
|
+
const consumeAsync = pickEndpointFunction(raw, "ConsumeAsync", "consumeAsync");
|
|
941
|
+
if (consumeAsync) {
|
|
942
|
+
target.ConsumeAsync = consumeAsync;
|
|
943
|
+
}
|
|
944
|
+
if (hasAnyEndpointField(raw, ["ConnectionMetadata", "connectionMetadata"])) {
|
|
945
|
+
target.ConnectionMetadata = pickEndpointStringRecord(raw, "ConnectionMetadata", "connectionMetadata");
|
|
946
|
+
}
|
|
947
|
+
}
|
|
783
948
|
function validateTrafficEndpointDefinitionModel(target) {
|
|
784
949
|
requireNonEmptyString(target.Name, "Endpoint name must be provided.");
|
|
785
950
|
if (target.Mode !== "Produce" && target.Mode !== "Consume") {
|
|
@@ -1914,6 +2079,10 @@ class PushDiffusionEndpointAdapter extends CallbackAdapter {
|
|
|
1914
2079
|
}
|
|
1915
2080
|
class DelegateStreamEndpointAdapter extends CallbackAdapter {
|
|
1916
2081
|
}
|
|
2082
|
+
class GrpcEndpointAdapter extends CallbackAdapter {
|
|
2083
|
+
}
|
|
2084
|
+
class WebSocketEndpointAdapter extends CallbackAdapter {
|
|
2085
|
+
}
|
|
1917
2086
|
class EndpointAdapterFactory {
|
|
1918
2087
|
static create(endpoint) {
|
|
1919
2088
|
if (endpoint instanceof TrafficEndpointDefinitionModel) {
|
|
@@ -1940,6 +2109,10 @@ class EndpointAdapterFactory {
|
|
|
1940
2109
|
return new PushDiffusionEndpointAdapter(normalized);
|
|
1941
2110
|
case "DelegateStream":
|
|
1942
2111
|
return new DelegateStreamEndpointAdapter(normalized);
|
|
2112
|
+
case "Grpc":
|
|
2113
|
+
return new GrpcEndpointAdapter(normalized);
|
|
2114
|
+
case "WebSocket":
|
|
2115
|
+
return new WebSocketEndpointAdapter(normalized);
|
|
1943
2116
|
default:
|
|
1944
2117
|
throw new Error(`Unsupported endpoint kind: ${String(normalized?.kind ?? "")}.`);
|
|
1945
2118
|
}
|
|
@@ -2114,6 +2287,62 @@ const DELEGATE_STREAM_ENDPOINT_FLAT_KEYS = [
|
|
|
2114
2287
|
"ConnectionMetadata",
|
|
2115
2288
|
"connectionMetadata"
|
|
2116
2289
|
];
|
|
2290
|
+
const GRPC_ENDPOINT_FLAT_KEYS = [
|
|
2291
|
+
"Target",
|
|
2292
|
+
"target",
|
|
2293
|
+
"ServiceName",
|
|
2294
|
+
"serviceName",
|
|
2295
|
+
"MethodName",
|
|
2296
|
+
"methodName",
|
|
2297
|
+
"MethodType",
|
|
2298
|
+
"methodType",
|
|
2299
|
+
"Deadline",
|
|
2300
|
+
"deadline",
|
|
2301
|
+
"DeadlineSeconds",
|
|
2302
|
+
"deadlineSeconds",
|
|
2303
|
+
"DeadlineMs",
|
|
2304
|
+
"deadlineMs",
|
|
2305
|
+
"Metadata",
|
|
2306
|
+
"metadata",
|
|
2307
|
+
"Produce",
|
|
2308
|
+
"produce",
|
|
2309
|
+
"Consume",
|
|
2310
|
+
"consume",
|
|
2311
|
+
"ProduceAsync",
|
|
2312
|
+
"produceAsync",
|
|
2313
|
+
"ConsumeAsync",
|
|
2314
|
+
"consumeAsync",
|
|
2315
|
+
"ConnectionMetadata",
|
|
2316
|
+
"connectionMetadata"
|
|
2317
|
+
];
|
|
2318
|
+
const WEB_SOCKET_ENDPOINT_FLAT_KEYS = [
|
|
2319
|
+
"Url",
|
|
2320
|
+
"url",
|
|
2321
|
+
"Subprotocols",
|
|
2322
|
+
"subprotocols",
|
|
2323
|
+
"ConnectTimeout",
|
|
2324
|
+
"connectTimeout",
|
|
2325
|
+
"ConnectTimeoutSeconds",
|
|
2326
|
+
"connectTimeoutSeconds",
|
|
2327
|
+
"ConnectTimeoutMs",
|
|
2328
|
+
"connectTimeoutMs",
|
|
2329
|
+
"CloseTimeout",
|
|
2330
|
+
"closeTimeout",
|
|
2331
|
+
"CloseTimeoutSeconds",
|
|
2332
|
+
"closeTimeoutSeconds",
|
|
2333
|
+
"CloseTimeoutMs",
|
|
2334
|
+
"closeTimeoutMs",
|
|
2335
|
+
"Produce",
|
|
2336
|
+
"produce",
|
|
2337
|
+
"Consume",
|
|
2338
|
+
"consume",
|
|
2339
|
+
"ProduceAsync",
|
|
2340
|
+
"produceAsync",
|
|
2341
|
+
"ConsumeAsync",
|
|
2342
|
+
"consumeAsync",
|
|
2343
|
+
"ConnectionMetadata",
|
|
2344
|
+
"connectionMetadata"
|
|
2345
|
+
];
|
|
2117
2346
|
function normalizeEndpointDefinition(endpoint) {
|
|
2118
2347
|
if (!endpoint || typeof endpoint !== "object") {
|
|
2119
2348
|
return endpoint;
|
|
@@ -2148,7 +2377,9 @@ function normalizeEndpointDefinition(endpoint) {
|
|
|
2148
2377
|
azureEventHubs: normalizeProtocolOptions(pickEndpointTransportRecord(raw, kind, "AzureEventHubs", ["azureEventHubs", "AzureEventHubs"], AZURE_EVENT_HUBS_ENDPOINT_FLAT_KEYS)),
|
|
2149
2378
|
sqs: normalizeProtocolOptions(pickEndpointTransportRecord(raw, kind, "Sqs", ["sqs", "Sqs"], SQS_ENDPOINT_FLAT_KEYS)),
|
|
2150
2379
|
pushDiffusion: normalizeProtocolOptions(pickEndpointTransportRecord(raw, kind, "PushDiffusion", ["pushDiffusion", "PushDiffusion"], PUSH_DIFFUSION_ENDPOINT_FLAT_KEYS)),
|
|
2151
|
-
delegate: normalizeDelegateEndpointOptions(pickEndpointTransportRecord(raw, kind, "DelegateStream", ["delegate", "Delegate", "DelegateStream"], DELEGATE_STREAM_ENDPOINT_FLAT_KEYS))
|
|
2380
|
+
delegate: normalizeDelegateEndpointOptions(pickEndpointTransportRecord(raw, kind, "DelegateStream", ["delegate", "Delegate", "DelegateStream"], DELEGATE_STREAM_ENDPOINT_FLAT_KEYS)),
|
|
2381
|
+
grpc: normalizeProtocolOptions(pickEndpointTransportRecord(raw, kind, "Grpc", ["grpc", "Grpc"], GRPC_ENDPOINT_FLAT_KEYS)),
|
|
2382
|
+
webSocket: normalizeProtocolOptions(pickEndpointTransportRecord(raw, kind, "WebSocket", ["webSocket", "WebSocket"], WEB_SOCKET_ENDPOINT_FLAT_KEYS))
|
|
2152
2383
|
};
|
|
2153
2384
|
}
|
|
2154
2385
|
function resolveEndpointKind(raw) {
|
|
@@ -2234,6 +2465,28 @@ function resolveEndpointKind(raw) {
|
|
|
2234
2465
|
])) {
|
|
2235
2466
|
return "PushDiffusion";
|
|
2236
2467
|
}
|
|
2468
|
+
if (Object.keys(pickEndpointRecord(raw, "grpc", "Grpc")).length || hasAnyEndpointField(raw, [
|
|
2469
|
+
"Target",
|
|
2470
|
+
"target",
|
|
2471
|
+
"ServiceName",
|
|
2472
|
+
"serviceName",
|
|
2473
|
+
"MethodName",
|
|
2474
|
+
"methodName",
|
|
2475
|
+
"MethodType",
|
|
2476
|
+
"methodType"
|
|
2477
|
+
])) {
|
|
2478
|
+
return "Grpc";
|
|
2479
|
+
}
|
|
2480
|
+
if (Object.keys(pickEndpointRecord(raw, "webSocket", "WebSocket")).length || hasAnyEndpointField(raw, [
|
|
2481
|
+
"Subprotocols",
|
|
2482
|
+
"subprotocols",
|
|
2483
|
+
"ConnectTimeoutSeconds",
|
|
2484
|
+
"connectTimeoutSeconds",
|
|
2485
|
+
"CloseTimeoutSeconds",
|
|
2486
|
+
"closeTimeoutSeconds"
|
|
2487
|
+
])) {
|
|
2488
|
+
return "WebSocket";
|
|
2489
|
+
}
|
|
2237
2490
|
if (Object.keys(pickEndpointRecord(raw, "delegate", "Delegate", "DelegateStream")).length || hasAnyEndpointField(raw, [
|
|
2238
2491
|
"Produce",
|
|
2239
2492
|
"produce",
|
|
@@ -2477,10 +2730,8 @@ function validateEndpointDefinition(endpoint) {
|
|
|
2477
2730
|
if (mode !== "Produce" && mode !== "Consume") {
|
|
2478
2731
|
throw new Error(`Unsupported endpoint mode: ${mode}.`);
|
|
2479
2732
|
}
|
|
2480
|
-
const hasProduceDelegate =
|
|
2481
|
-
|
|
2482
|
-
const hasConsumeDelegate = typeof endpoint.delegate?.consume === "function"
|
|
2483
|
-
|| typeof endpoint.delegate?.consumeAsync === "function";
|
|
2733
|
+
const hasProduceDelegate = Boolean(resolveProduceDelegate(endpoint) || resolveStructuredProduceDelegate(endpoint));
|
|
2734
|
+
const hasConsumeDelegate = Boolean(resolveConsumeDelegate(endpoint) || resolveStructuredConsumeDelegate(endpoint) || resolveStructuredConsumeStreamDelegate(endpoint));
|
|
2484
2735
|
const hasModeDelegate = mode === "Produce" ? hasProduceDelegate : hasConsumeDelegate;
|
|
2485
2736
|
switch (kind) {
|
|
2486
2737
|
case "Http":
|
|
@@ -2510,6 +2761,12 @@ function validateEndpointDefinition(endpoint) {
|
|
|
2510
2761
|
case "DelegateStream":
|
|
2511
2762
|
validateDelegateStreamEndpoint(endpoint, mode);
|
|
2512
2763
|
return;
|
|
2764
|
+
case "Grpc":
|
|
2765
|
+
validateGrpcEndpoint(endpoint, mode);
|
|
2766
|
+
return;
|
|
2767
|
+
case "WebSocket":
|
|
2768
|
+
validateWebSocketEndpoint(endpoint, mode);
|
|
2769
|
+
return;
|
|
2513
2770
|
default:
|
|
2514
2771
|
throw new Error(`Unsupported endpoint kind: ${kind}.`);
|
|
2515
2772
|
}
|
|
@@ -2585,6 +2842,57 @@ function validateDelegateStreamEndpoint(endpoint, mode) {
|
|
|
2585
2842
|
throw new Error("ConsumeAsync delegate must be provided when endpoint mode is Consume.");
|
|
2586
2843
|
}
|
|
2587
2844
|
}
|
|
2845
|
+
function validateGrpcEndpoint(endpoint, mode) {
|
|
2846
|
+
const options = asRecordOrEmpty(endpoint.grpc);
|
|
2847
|
+
requireNonEmptyString(optionString(options, "Target", "target"), "Target must be provided for gRPC endpoint definitions.");
|
|
2848
|
+
requireNonEmptyString(optionString(options, "ServiceName", "serviceName"), "ServiceName must be provided for gRPC endpoint definitions.");
|
|
2849
|
+
requireNonEmptyString(optionString(options, "MethodName", "methodName"), "MethodName must be provided for gRPC endpoint definitions.");
|
|
2850
|
+
requireNonEmptyString(optionString(options, "MethodType", "methodType") || "Unary", "MethodType must be provided for gRPC endpoint definitions.");
|
|
2851
|
+
const deadlineMs = optionNumber(options, "DeadlineMs", "deadlineMs");
|
|
2852
|
+
const deadlineSeconds = optionNumber(options, "DeadlineSeconds", "deadlineSeconds", "Deadline", "deadline");
|
|
2853
|
+
if ((hasOptionValue(options, "DeadlineMs", "deadlineMs") && deadlineMs <= 0)
|
|
2854
|
+
|| (hasOptionValue(options, "DeadlineSeconds", "deadlineSeconds", "Deadline", "deadline") && deadlineSeconds <= 0)) {
|
|
2855
|
+
throw new RangeError("Deadline must be greater than zero.");
|
|
2856
|
+
}
|
|
2857
|
+
if (mode === "Produce" && !resolveStructuredProduceDelegate(endpoint) && !resolveProduceDelegate(endpoint)) {
|
|
2858
|
+
throw new Error("ProduceAsync delegate must be provided when endpoint mode is Produce.");
|
|
2859
|
+
}
|
|
2860
|
+
if (mode === "Consume" && !resolveStructuredConsumeDelegate(endpoint) && !resolveStructuredConsumeStreamDelegate(endpoint) && !resolveConsumeDelegate(endpoint)) {
|
|
2861
|
+
throw new Error("ConsumeAsync delegate must be provided when endpoint mode is Consume.");
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
function validateWebSocketEndpoint(endpoint, mode) {
|
|
2865
|
+
const options = asRecordOrEmpty(endpoint.webSocket);
|
|
2866
|
+
const url = requireNonEmptyString(optionString(options, "Url", "url"), "Url must be provided for WebSocket endpoint definitions.");
|
|
2867
|
+
let parsed;
|
|
2868
|
+
try {
|
|
2869
|
+
parsed = new URL(url);
|
|
2870
|
+
}
|
|
2871
|
+
catch {
|
|
2872
|
+
throw new Error("Url must be an absolute ws:// or wss:// URI.");
|
|
2873
|
+
}
|
|
2874
|
+
if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
|
|
2875
|
+
throw new Error("Url must be an absolute ws:// or wss:// URI.");
|
|
2876
|
+
}
|
|
2877
|
+
const connectMs = optionNumber(options, "ConnectTimeoutMs", "connectTimeoutMs");
|
|
2878
|
+
const connectSeconds = optionNumber(options, "ConnectTimeoutSeconds", "connectTimeoutSeconds", "ConnectTimeout", "connectTimeout");
|
|
2879
|
+
const closeMs = optionNumber(options, "CloseTimeoutMs", "closeTimeoutMs");
|
|
2880
|
+
const closeSeconds = optionNumber(options, "CloseTimeoutSeconds", "closeTimeoutSeconds", "CloseTimeout", "closeTimeout");
|
|
2881
|
+
if ((hasOptionValue(options, "ConnectTimeoutMs", "connectTimeoutMs") && connectMs <= 0)
|
|
2882
|
+
|| (hasOptionValue(options, "ConnectTimeoutSeconds", "connectTimeoutSeconds", "ConnectTimeout", "connectTimeout") && connectSeconds <= 0)) {
|
|
2883
|
+
throw new RangeError("ConnectTimeout must be greater than zero.");
|
|
2884
|
+
}
|
|
2885
|
+
if ((hasOptionValue(options, "CloseTimeoutMs", "closeTimeoutMs") && closeMs <= 0)
|
|
2886
|
+
|| (hasOptionValue(options, "CloseTimeoutSeconds", "closeTimeoutSeconds", "CloseTimeout", "closeTimeout") && closeSeconds <= 0)) {
|
|
2887
|
+
throw new RangeError("CloseTimeout must be greater than zero.");
|
|
2888
|
+
}
|
|
2889
|
+
if (mode === "Produce" && !resolveStructuredProduceDelegate(endpoint) && !resolveProduceDelegate(endpoint)) {
|
|
2890
|
+
throw new Error("ProduceAsync delegate must be provided when endpoint mode is Produce.");
|
|
2891
|
+
}
|
|
2892
|
+
if (mode === "Consume" && !resolveStructuredConsumeDelegate(endpoint) && !resolveStructuredConsumeStreamDelegate(endpoint) && !resolveConsumeDelegate(endpoint)) {
|
|
2893
|
+
throw new Error("ConsumeAsync delegate must be provided when endpoint mode is Consume.");
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2588
2896
|
function validateHttpAuthOptions(options) {
|
|
2589
2897
|
const auth = options.auth;
|
|
2590
2898
|
if (!auth) {
|
|
@@ -3227,6 +3535,10 @@ function createDelegateRequestEndpointView(endpoint) {
|
|
|
3227
3535
|
return new exports.AzureEventHubsEndpointDefinition(endpoint);
|
|
3228
3536
|
case "PushDiffusion":
|
|
3229
3537
|
return new exports.PushDiffusionEndpointDefinition(endpoint);
|
|
3538
|
+
case "Grpc":
|
|
3539
|
+
return new exports.GrpcEndpointDefinition(endpoint);
|
|
3540
|
+
case "WebSocket":
|
|
3541
|
+
return new exports.WebSocketEndpointDefinition(endpoint);
|
|
3230
3542
|
default:
|
|
3231
3543
|
return new exports.DelegateStreamEndpointDefinition(endpoint);
|
|
3232
3544
|
}
|
|
@@ -3445,12 +3757,20 @@ function parseBodyObject(body) {
|
|
|
3445
3757
|
function resolveStructuredProduceDelegate(endpoint) {
|
|
3446
3758
|
return endpoint.delegate?.produceAsync
|
|
3447
3759
|
?? endpoint.pushDiffusion?.PublishAsync
|
|
3448
|
-
?? endpoint.pushDiffusion?.publishAsync
|
|
3760
|
+
?? endpoint.pushDiffusion?.publishAsync
|
|
3761
|
+
?? endpoint.grpc?.ProduceAsync
|
|
3762
|
+
?? endpoint.grpc?.produceAsync
|
|
3763
|
+
?? endpoint.webSocket?.ProduceAsync
|
|
3764
|
+
?? endpoint.webSocket?.produceAsync;
|
|
3449
3765
|
}
|
|
3450
3766
|
function resolveStructuredConsumeDelegate(endpoint) {
|
|
3451
3767
|
const delegate = endpoint.delegate?.consumeAsync
|
|
3452
3768
|
?? endpoint.pushDiffusion?.SubscribeAsync
|
|
3453
|
-
?? endpoint.pushDiffusion?.subscribeAsync
|
|
3769
|
+
?? endpoint.pushDiffusion?.subscribeAsync
|
|
3770
|
+
?? endpoint.grpc?.ConsumeAsync
|
|
3771
|
+
?? endpoint.grpc?.consumeAsync
|
|
3772
|
+
?? endpoint.webSocket?.ConsumeAsync
|
|
3773
|
+
?? endpoint.webSocket?.consumeAsync;
|
|
3454
3774
|
return typeof delegate === "function" && delegate.length === 0
|
|
3455
3775
|
? delegate
|
|
3456
3776
|
: undefined;
|
|
@@ -3458,22 +3778,36 @@ function resolveStructuredConsumeDelegate(endpoint) {
|
|
|
3458
3778
|
function resolveStructuredConsumeStreamDelegate(endpoint) {
|
|
3459
3779
|
const delegate = endpoint.delegate?.consumeAsync
|
|
3460
3780
|
?? endpoint.pushDiffusion?.SubscribeAsync
|
|
3461
|
-
?? endpoint.pushDiffusion?.subscribeAsync
|
|
3781
|
+
?? endpoint.pushDiffusion?.subscribeAsync
|
|
3782
|
+
?? endpoint.grpc?.ConsumeAsync
|
|
3783
|
+
?? endpoint.grpc?.consumeAsync
|
|
3784
|
+
?? endpoint.webSocket?.ConsumeAsync
|
|
3785
|
+
?? endpoint.webSocket?.consumeAsync;
|
|
3462
3786
|
return typeof delegate === "function" && delegate.length > 0
|
|
3463
3787
|
? delegate
|
|
3464
3788
|
: undefined;
|
|
3465
3789
|
}
|
|
3466
3790
|
function resolveProduceDelegate(endpoint) {
|
|
3467
|
-
return endpoint.delegate?.produce
|
|
3791
|
+
return endpoint.delegate?.produce
|
|
3792
|
+
?? endpoint.grpc?.Produce
|
|
3793
|
+
?? endpoint.grpc?.produce
|
|
3794
|
+
?? endpoint.webSocket?.Produce
|
|
3795
|
+
?? endpoint.webSocket?.produce;
|
|
3468
3796
|
}
|
|
3469
3797
|
function resolveConsumeDelegate(endpoint) {
|
|
3470
|
-
return endpoint.delegate?.consume
|
|
3798
|
+
return endpoint.delegate?.consume
|
|
3799
|
+
?? endpoint.grpc?.Consume
|
|
3800
|
+
?? endpoint.grpc?.consume
|
|
3801
|
+
?? endpoint.webSocket?.Consume
|
|
3802
|
+
?? endpoint.webSocket?.consume;
|
|
3471
3803
|
}
|
|
3472
3804
|
function resolveConnectionMetadata(endpoint) {
|
|
3473
3805
|
return {
|
|
3474
3806
|
...(endpoint.connectionMetadata ?? {}),
|
|
3475
3807
|
...(endpoint.delegate?.connectionMetadata ?? {}),
|
|
3476
|
-
...toStringRecord(endpoint.pushDiffusion?.ConnectionProperties ?? endpoint.pushDiffusion?.connectionProperties)
|
|
3808
|
+
...toStringRecord(endpoint.pushDiffusion?.ConnectionProperties ?? endpoint.pushDiffusion?.connectionProperties),
|
|
3809
|
+
...toStringRecord(endpoint.grpc?.ConnectionMetadata ?? endpoint.grpc?.connectionMetadata),
|
|
3810
|
+
...toStringRecord(endpoint.webSocket?.ConnectionMetadata ?? endpoint.webSocket?.connectionMetadata)
|
|
3477
3811
|
};
|
|
3478
3812
|
}
|
|
3479
3813
|
function isStructuredProduceResult(value) {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { LoadStrikeAutopilot, LoadStrikeAutopilotResult } from "./autopilot.js";
|
|
2
2
|
export { LoadStrikeAutopilotReadiness } from "./autopilot-contracts.js";
|
|
3
|
-
export { CrossPlatformScenarioConfigurator, ScenarioTrackingExtensions, LoadStrikeContext, LoadStrikePluginData, LoadStrikePluginDataTable, LoadStrikeNodeType, LoadStrikeReportFormat, LoadStrikeResponse, LoadStrikeLogLevel, LoadStrikeScenarioOperation, LoadStrikeOperationType, LoadStrikeRunner, LoadStrikeScenario, LoadStrikeScenarioShare, LoadStrikeSimulation, LoadStrikeTrafficMix, CrossPlatformTrackingConfiguration, LoadStrikeMetric, LoadStrikeCounter, LoadStrikeGauge, LoadStrikeStep, LoadStrikeThreshold } from "./runtime.js";
|
|
3
|
+
export { CrossPlatformScenarioConfigurator, ScenarioTrackingExtensions, LoadStrikeContext, LoadStrikeAccessibility, LoadStrikeBrowserWebVitals, LoadStrikePluginData, LoadStrikePluginDataTable, LoadStrikeNodeType, LoadStrikeReportFormat, LoadStrikeResponse, LoadStrikeLogLevel, LoadStrikeScenarioOperation, LoadStrikeOperationType, LoadStrikeRunner, LoadStrikeScenario, LoadStrikeScenarioShare, LoadStrikeSimulation, LoadStrikeTrafficMix, CrossPlatformTrackingConfiguration, LoadStrikeMetric, LoadStrikeCounter, LoadStrikeGauge, LoadStrikeStep, LoadStrikeThreshold } from "./runtime.js";
|
|
4
4
|
export { CorrelationStoreConfiguration, CrossPlatformTrackingRuntime, InMemoryCorrelationStore, RedisCorrelationStoreOptions, RedisCorrelationStore, TrackingPayloadBuilder, TrackingFieldSelector } from "./correlation.js";
|
|
5
|
-
export { LOADSTRIKE_TRACE_ID_HEADER, LOADSTRIKE_TRACE_ID_TRACKING_FIELD, TrafficEndpointDefinition, HttpEndpointDefinition, KafkaEndpointDefinition, KafkaSaslOptions, RabbitMqEndpointDefinition, NatsEndpointDefinition, RedisStreamsEndpointDefinition, AzureEventHubsEndpointDefinition, SqsEndpointDefinition, DelegateStreamEndpointDefinition, PushDiffusionEndpointDefinition, HttpOAuth2ClientCredentialsOptions, HttpAuthOptions } from "./transports.js";
|
|
5
|
+
export { LOADSTRIKE_TRACE_ID_HEADER, LOADSTRIKE_TRACE_ID_TRACKING_FIELD, TrafficEndpointDefinition, HttpEndpointDefinition, KafkaEndpointDefinition, KafkaSaslOptions, RabbitMqEndpointDefinition, NatsEndpointDefinition, RedisStreamsEndpointDefinition, AzureEventHubsEndpointDefinition, SqsEndpointDefinition, DelegateStreamEndpointDefinition, PushDiffusionEndpointDefinition, GrpcEndpointDefinition, WebSocketEndpointDefinition, HttpOAuth2ClientCredentialsOptions, HttpAuthOptions } from "./transports.js";
|
|
6
6
|
export { DatadogReportingSink, DatadogReportingSinkOptions, GrafanaLokiReportingSink, GrafanaLokiReportingSinkOptions, InfluxDbReportingSink, InfluxDbReportingSinkOptions, OtelCollectorReportingSink, OtelCollectorReportingSinkOptions, PortalReportingSink, SplunkReportingSink, SplunkReportingSinkOptions, TimescaleDbReportingSink, TimescaleDbReportingSinkOptions } from "./sinks.js";
|