@frontmcp/testing 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/perf/index.js CHANGED
@@ -1108,6 +1108,7 @@ function sleep3(ms) {
1108
1108
 
1109
1109
  // libs/testing/src/transport/streamable-http.transport.ts
1110
1110
  var DEFAULT_TIMEOUT = 3e4;
1111
+ var NOTIFICATION_STREAM_REOPEN_DELAY_MS = 250;
1111
1112
  var StreamableHttpTransport = class {
1112
1113
  config;
1113
1114
  state = "disconnected";
@@ -1119,6 +1120,10 @@ var StreamableHttpTransport = class {
1119
1120
  interceptors;
1120
1121
  publicMode;
1121
1122
  elicitationHandler;
1123
+ notificationHandler;
1124
+ notificationStream;
1125
+ notificationProtocolVersion = "";
1126
+ notificationStreamReopenTimer;
1122
1127
  constructor(config) {
1123
1128
  this.config = {
1124
1129
  baseUrl: config.baseUrl.replace(/\/$/, ""),
@@ -1135,6 +1140,7 @@ var StreamableHttpTransport = class {
1135
1140
  this.interceptors = config.interceptors;
1136
1141
  this.publicMode = config.publicMode ?? false;
1137
1142
  this.elicitationHandler = config.elicitationHandler;
1143
+ this.notificationHandler = config.notificationHandler;
1138
1144
  }
1139
1145
  async connect() {
1140
1146
  this.state = "connecting";
@@ -1354,7 +1360,12 @@ var StreamableHttpTransport = class {
1354
1360
  };
1355
1361
  }
1356
1362
  }
1363
+ async openNotificationStream(protocolVersion) {
1364
+ this.notificationProtocolVersion = protocolVersion;
1365
+ await this.connectNotificationStream();
1366
+ }
1357
1367
  async close() {
1368
+ this.closeNotificationStream();
1358
1369
  this.state = "disconnected";
1359
1370
  this.sessionId = void 0;
1360
1371
  this.log("StreamableHTTP transport closed");
@@ -1393,6 +1404,7 @@ var StreamableHttpTransport = class {
1393
1404
  return { ...this.lastRequestHeaders };
1394
1405
  }
1395
1406
  async simulateDisconnect() {
1407
+ this.closeNotificationStream();
1396
1408
  this.state = "disconnected";
1397
1409
  this.sessionId = void 0;
1398
1410
  }
@@ -1411,6 +1423,72 @@ var StreamableHttpTransport = class {
1411
1423
  // ═══════════════════════════════════════════════════════════════════
1412
1424
  // PRIVATE HELPERS
1413
1425
  // ═══════════════════════════════════════════════════════════════════
1426
+ closeNotificationStream() {
1427
+ clearTimeout(this.notificationStreamReopenTimer);
1428
+ this.notificationStream?.abort();
1429
+ this.notificationStream = void 0;
1430
+ }
1431
+ /** Opens the stream without holding up the caller past the request timeout; close() aborts it at any point. */
1432
+ async connectNotificationStream() {
1433
+ if (!this.sessionId || this.notificationStream) return;
1434
+ const controller = new AbortController();
1435
+ this.notificationStream = controller;
1436
+ const { "Content-Type": _contentType, ...headers } = this.buildHeaders();
1437
+ const established = fetch(this.mcpUrl(), {
1438
+ method: "GET",
1439
+ headers: { ...headers, Accept: "text/event-stream", "MCP-Protocol-Version": this.notificationProtocolVersion },
1440
+ signal: controller.signal
1441
+ }).then(
1442
+ async (response) => {
1443
+ const isEventStream = response.headers.get("content-type")?.includes("text/event-stream") ?? false;
1444
+ if (!response.ok || !response.body || !isEventStream) {
1445
+ await response.body?.cancel();
1446
+ this.log(`Server offers no notification stream (HTTP ${response.status})`);
1447
+ this.releaseNotificationStream(controller);
1448
+ return;
1449
+ }
1450
+ void this.readNotificationStream(controller, response.body.getReader());
1451
+ },
1452
+ (error) => {
1453
+ this.log("Failed to open the notification stream:", error);
1454
+ this.releaseNotificationStream(controller);
1455
+ }
1456
+ );
1457
+ let establishTimer;
1458
+ const establishDeadline = new Promise((resolve) => {
1459
+ establishTimer = setTimeout(resolve, this.config.timeout);
1460
+ });
1461
+ await Promise.race([established, establishDeadline]);
1462
+ clearTimeout(establishTimer);
1463
+ }
1464
+ releaseNotificationStream(controller) {
1465
+ if (this.notificationStream === controller) this.notificationStream = void 0;
1466
+ }
1467
+ async readNotificationStream(controller, reader) {
1468
+ const decoder = new TextDecoder();
1469
+ let buffer = "";
1470
+ try {
1471
+ for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) {
1472
+ const { completeEvents, remainder } = splitSSEEvents(buffer + decoder.decode(chunk.value, { stream: true }));
1473
+ buffer = remainder;
1474
+ for (const eventText of completeEvents) {
1475
+ for (const event of this.parseSSEEvents(eventText, void 0).events) {
1476
+ await this.handleSSEEvent(event);
1477
+ }
1478
+ }
1479
+ }
1480
+ } catch (error) {
1481
+ this.log("Notification stream ended:", error);
1482
+ } finally {
1483
+ reader.releaseLock();
1484
+ }
1485
+ if (controller.signal.aborted || this.notificationStream !== controller) return;
1486
+ this.releaseNotificationStream(controller);
1487
+ this.notificationStreamReopenTimer = setTimeout(
1488
+ () => void this.connectNotificationStream(),
1489
+ NOTIFICATION_STREAM_REOPEN_DELAY_MS
1490
+ );
1491
+ }
1414
1492
  /**
1415
1493
  * Handle SSE response with elicitation support.
1416
1494
  *
@@ -1548,6 +1626,13 @@ var StreamableHttpTransport = class {
1548
1626
  response: { jsonrpc: "2.0", id: null, result: void 0 }
1549
1627
  };
1550
1628
  }
1629
+ if ("method" in parsed && parsed.id === void 0) {
1630
+ this.notificationHandler?.(parsed);
1631
+ return {
1632
+ isFinal: false,
1633
+ response: { jsonrpc: "2.0", id: null, result: void 0 }
1634
+ };
1635
+ }
1551
1636
  if ("result" in parsed || "error" in parsed) {
1552
1637
  return { isFinal: true, response: parsed };
1553
1638
  }
@@ -1718,6 +1803,13 @@ var StreamableHttpTransport = class {
1718
1803
  };
1719
1804
  }
1720
1805
  };
1806
+ function splitSSEEvents(buffer) {
1807
+ const endsWithCarriageReturn = buffer.endsWith("\r");
1808
+ const normalized = (endsWithCarriageReturn ? buffer.slice(0, -1) : buffer).replace(/\r\n?/g, "\n");
1809
+ const completeEvents = normalized.split("\n\n");
1810
+ const remainder = completeEvents.pop() ?? "";
1811
+ return { completeEvents, remainder: endsWithCarriageReturn ? `${remainder}\r` : remainder };
1812
+ }
1721
1813
 
1722
1814
  // libs/testing/src/platform/platform-client-info.ts
1723
1815
  var MCP_APPS_EXTENSION_KEY = "io.modelcontextprotocol/ui";
@@ -1854,7 +1946,8 @@ var McpTestClientBuilder = class {
1854
1946
  return this;
1855
1947
  }
1856
1948
  /**
1857
- * Set the MCP protocol version to request
1949
+ * Set the MCP protocol version to request (default '2025-06-18').
1950
+ * '2026-07-28' has no initialize handshake, so `build()` throws for it.
1858
1951
  */
1859
1952
  withProtocolVersion(version) {
1860
1953
  this.config.protocolVersion = version;
@@ -1950,6 +2043,7 @@ var McpTestClientBuilder = class {
1950
2043
  // libs/testing/src/client/mcp-test-client.ts
1951
2044
  var DEFAULT_TIMEOUT2 = 3e4;
1952
2045
  var DEFAULT_PROTOCOL_VERSION = "2025-06-18";
2046
+ var UNSUPPORTED_PROTOCOL_VERSIONS = ["2026-07-28"];
1953
2047
  var DEFAULT_CLIENT_INFO = {
1954
2048
  name: "@frontmcp/testing",
1955
2049
  version: "0.4.0"
@@ -1986,6 +2080,8 @@ var McpTestClient = class {
1986
2080
  _traces = [];
1987
2081
  _notifications = [];
1988
2082
  _progressUpdates = [];
2083
+ collectingProgress = false;
2084
+ progressTokenCounter = 0;
1989
2085
  // Interceptor chain
1990
2086
  _interceptors;
1991
2087
  // Elicitation handler for server→client elicit requests
@@ -1994,6 +2090,11 @@ var McpTestClient = class {
1994
2090
  // CONSTRUCTOR & FACTORY
1995
2091
  // ═══════════════════════════════════════════════════════════════════
1996
2092
  constructor(config) {
2093
+ if (config.protocolVersion && UNSUPPORTED_PROTOCOL_VERSIONS.includes(config.protocolVersion)) {
2094
+ throw new Error(
2095
+ `McpTestClient does not support protocol version ${config.protocolVersion}: it has no initialize handshake. Use ${DEFAULT_PROTOCOL_VERSION} or earlier.`
2096
+ );
2097
+ }
1997
2098
  this.config = {
1998
2099
  baseUrl: config.baseUrl,
1999
2100
  entryPath: config.entryPath,
@@ -2079,6 +2180,7 @@ var McpTestClient = class {
2079
2180
  jsonrpc: "2.0",
2080
2181
  method: "notifications/initialized"
2081
2182
  });
2183
+ await this.transport.openNotificationStream?.(this.initResult.protocolVersion);
2082
2184
  this.log("info", `Connected to ${this.initResult.serverInfo?.name ?? "MCP Server"}`);
2083
2185
  return this.initResult;
2084
2186
  }
@@ -2189,8 +2291,8 @@ var McpTestClient = class {
2189
2291
  /**
2190
2292
  * Call a tool by name with arguments
2191
2293
  */
2192
- call: async (name, args) => {
2193
- const response = await this.callTool(name, args);
2294
+ call: async (name, args, options = {}) => {
2295
+ const response = await this.callTool(name, args, this.progressTokenFor(options));
2194
2296
  return this.wrapToolResult(response);
2195
2297
  }
2196
2298
  };
@@ -2332,6 +2434,7 @@ var McpTestClient = class {
2332
2434
  * Collect progress notifications specifically
2333
2435
  */
2334
2436
  collectProgress: () => {
2437
+ this.collectingProgress = true;
2335
2438
  return new ProgressCollector(this._progressUpdates);
2336
2439
  },
2337
2440
  /**
@@ -2637,12 +2740,29 @@ var McpTestClient = class {
2637
2740
  async listTools() {
2638
2741
  return this.request("tools/list", {});
2639
2742
  }
2640
- async callTool(name, args) {
2743
+ async callTool(name, args, progressToken) {
2641
2744
  return this.request("tools/call", {
2642
2745
  name,
2643
- arguments: args ?? {}
2746
+ arguments: args ?? {},
2747
+ ...progressToken !== void 0 && { _meta: { progressToken } }
2644
2748
  });
2645
2749
  }
2750
+ progressTokenFor(options) {
2751
+ if (options.progressToken !== void 0) return options.progressToken;
2752
+ return this.collectingProgress ? `progress-${++this.progressTokenCounter}` : void 0;
2753
+ }
2754
+ recordNotification = (notification) => {
2755
+ const timestamp = /* @__PURE__ */ new Date();
2756
+ this._notifications.push({ method: notification.method, params: notification.params, timestamp });
2757
+ if (notification.method !== "notifications/progress") return;
2758
+ const { progress, total, progressToken } = notification.params ?? {};
2759
+ this._progressUpdates.push({
2760
+ progress: Number(progress),
2761
+ total: typeof total === "number" ? total : void 0,
2762
+ progressToken: typeof progressToken === "string" || typeof progressToken === "number" ? progressToken : void 0,
2763
+ timestamp
2764
+ });
2765
+ };
2646
2766
  async listResources() {
2647
2767
  return this.request("resources/list", {});
2648
2768
  }
@@ -2689,7 +2809,8 @@ var McpTestClient = class {
2689
2809
  debug: this.config.debug,
2690
2810
  interceptors: this._interceptors,
2691
2811
  clientInfo: this.config.clientInfo,
2692
- elicitationHandler: this._elicitationHandler
2812
+ elicitationHandler: this._elicitationHandler,
2813
+ notificationHandler: this.recordNotification
2693
2814
  });
2694
2815
  case "sse":
2695
2816
  throw new Error("SSE transport not yet implemented");
package/setup.js CHANGED
@@ -368,18 +368,17 @@ var toBeError = function(received, expectedCode) {
368
368
  message: () => `Expected a result wrapper object with isError property`
369
369
  };
370
370
  }
371
- let pass = result.isError;
372
- if (pass && expectedCode !== void 0) {
373
- pass = result.error?.code === expectedCode;
374
- }
371
+ const receivedCode = typeof expectedCode === "string" ? result.raw?._meta?.["code"] : result.error?.code;
372
+ const codeMatches = expectedCode === void 0 || receivedCode === expectedCode;
373
+ const pass = result.isError && codeMatches;
375
374
  return {
376
375
  pass,
377
376
  message: () => {
378
377
  if (!result.isError) {
379
378
  return "Expected result to be an error, but it was successful";
380
379
  }
381
- if (expectedCode !== void 0 && result.error?.code !== expectedCode) {
382
- return `Expected error code ${expectedCode}, but got ${result.error?.code}`;
380
+ if (!codeMatches) {
381
+ return `Expected error code ${expectedCode}, but got ${String(receivedCode)}`;
383
382
  }
384
383
  return "Expected result not to be an error";
385
384
  }
@@ -2,6 +2,6 @@
2
2
  * @file transport/index.ts
3
3
  * @description Transport layer exports
4
4
  */
5
- export type { McpTransport, TransportConfig, TransportState, JsonRpcRequest, JsonRpcResponse, } from './transport.interface';
5
+ export type { McpTransport, TransportConfig, TransportState, JsonRpcRequest, JsonRpcResponse, NotificationHandler, } from './transport.interface';
6
6
  export { StreamableHttpTransport } from './streamable-http.transport';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -22,6 +22,10 @@ export declare class StreamableHttpTransport implements McpTransport {
22
22
  private interceptors?;
23
23
  private readonly publicMode;
24
24
  private elicitationHandler?;
25
+ private readonly notificationHandler?;
26
+ private notificationStream?;
27
+ private notificationProtocolVersion;
28
+ private notificationStreamReopenTimer?;
25
29
  constructor(config: TransportConfig);
26
30
  connect(): Promise<void>;
27
31
  /**
@@ -34,6 +38,7 @@ export declare class StreamableHttpTransport implements McpTransport {
34
38
  }>;
35
39
  notify(message: JsonRpcRequest): Promise<void>;
36
40
  sendRaw(data: string): Promise<JsonRpcResponse>;
41
+ openNotificationStream(protocolVersion: string): Promise<void>;
37
42
  close(): Promise<void>;
38
43
  isConnected(): boolean;
39
44
  getState(): TransportState;
@@ -48,6 +53,11 @@ export declare class StreamableHttpTransport implements McpTransport {
48
53
  getLastRequestHeaders(): Record<string, string>;
49
54
  simulateDisconnect(): Promise<void>;
50
55
  waitForReconnect(timeoutMs: number): Promise<void>;
56
+ private closeNotificationStream;
57
+ /** Opens the stream without holding up the caller past the request timeout; close() aborts it at any point. */
58
+ private connectNotificationStream;
59
+ private releaseNotificationStream;
60
+ private readNotificationStream;
51
61
  /**
52
62
  * Handle SSE response with elicitation support.
53
63
  *
@@ -1 +1 @@
1
- {"version":3,"file":"streamable-http.transport.d.ts","sourceRoot":"","sources":["../../src/transport/streamable-http.transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAwC,kBAAkB,EAA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AgB,GAAG,IAAI;IAIrD,eAAe,IAAI,gBAAgB,GAAG,SAAS;IAI/C,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI;IAIpE,kBAAkB,IAAI,MAAM;IAI5B,iBAAiB,IAAI,MAAM;IAI3B,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxD;;;;;OAKG;YACW,gCAAgC;IA+F9C;;OAEG;IACH,OAAO,CAAC,cAAc;IAiDtB;;OAEG;YACW,cAAc;IAuC5B;;OAEG;YACW,wBAAwB;IAqCtC;;OAEG;YACW,uBAAuB;IA8BrC;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,GAAG;IAMX;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,2BAA2B;CAsDpC"}
1
+ {"version":3,"file":"streamable-http.transport.d.ts","sourceRoot":"","sources":["../../src/transport/streamable-http.transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAwC,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,YAAY,EAEZ,eAAe,EACf,cAAc,EACf,MAAM,uBAAuB,CAAC;AAK/B;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAMrB;IACF,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,eAAe,CAAK;IAC5B,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,MAAM;IAI3B,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxD,OAAO,CAAC,uBAAuB;IAM/B,+GAA+G;YACjG,yBAAyB;IAiCvC,OAAO,CAAC,yBAAyB;YAInB,sBAAsB;IA6BpC;;;;;OAKG;YACW,gCAAgC;IA+F9C;;OAEG;IACH,OAAO,CAAC,cAAc;IAiDtB;;OAEG;YACW,cAAc;IA+C5B;;OAEG;YACW,wBAAwB;IAqCtC;;OAEG;YACW,uBAAuB;IA8BrC;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,GAAG;IAMX;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,2BAA2B;CAsDpC"}
@@ -20,6 +20,7 @@ export interface JsonRpcResponse {
20
20
  };
21
21
  }
22
22
  export type TransportState = 'disconnected' | 'connecting' | 'connected' | 'error';
23
+ export type NotificationHandler = (notification: JsonRpcRequest) => void;
23
24
  /**
24
25
  * Interface that all MCP transports must implement
25
26
  */
@@ -104,6 +105,12 @@ export interface McpTransport {
104
105
  * this handler is called to provide the user's response.
105
106
  */
106
107
  setElicitationHandler?(handler: ElicitationHandler | undefined): void;
108
+ /**
109
+ * Open the session's standalone GET stream, where the server sends
110
+ * notifications that are not tied to a request's own response.
111
+ * @param protocolVersion - The version negotiated at initialize, sent as `MCP-Protocol-Version`
112
+ */
113
+ openNotificationStream?(protocolVersion: string): Promise<void>;
107
114
  }
108
115
  /**
109
116
  * Configuration for transport implementations
@@ -139,5 +146,7 @@ export interface TransportConfig {
139
146
  clientInfo?: ClientInfo;
140
147
  /** Handler for server→client elicitation requests during tool execution */
141
148
  elicitationHandler?: ElicitationHandler;
149
+ /** Handler for server notifications streamed during a request */
150
+ notificationHandler?: NotificationHandler;
142
151
  }
143
152
  //# sourceMappingURL=transport.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.interface.d.ts","sourceRoot":"","sources":["../../src/transport/transport.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGtF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,GAAG;QAAE,MAAM,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAEzF;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CA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mC;IACnC,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,OAAO,gBAAgB,EAAE,gBAAgB,CAAC;IACzD,+EAA+E;IAC/E,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC"}
1
+ {"version":3,"file":"transport.interface.d.ts","sourceRoot":"","sources":["../../src/transport/transport.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGtF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnF,MAAM,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,cAAc,KAAK,IAAI,CAAC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