@nice-code/action 0.4.3 → 0.4.5

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.
Files changed (26) hide show
  1. package/README.md +20 -28
  2. package/build/devtools/browser/index.js +173 -57
  3. package/build/devtools/server/index.js +2 -0
  4. package/build/index.js +303 -165
  5. package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +2 -1
  6. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +4 -3
  7. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +3 -3
  8. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +2 -2
  9. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/{TransportCustom.d.ts → CustomConnection.d.ts} +2 -2
  10. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.d.ts +33 -0
  11. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/{TransportHttp.d.ts → HttpConnection.d.ts} +2 -2
  12. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.d.ts +28 -0
  13. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +1 -2
  14. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +25 -12
  15. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +15 -2
  16. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.d.ts +21 -0
  17. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/{TransportWebSocket.d.ts → WebSocketConnection.d.ts} +2 -2
  18. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +32 -0
  19. package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +2 -2
  20. package/build/types/devtools/browser/components/HandlerChips.d.ts +11 -0
  21. package/build/types/devtools/browser/components/Tooltip.d.ts +11 -1
  22. package/build/types/devtools/browser/devtools_dock.d.ts +7 -0
  23. package/build/types/devtools/core/ActionDevtools.types.d.ts +5 -0
  24. package/build/types/index.d.ts +4 -4
  25. package/package.json +4 -4
  26. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.combined.types.d.ts +0 -4
package/build/index.js CHANGED
@@ -1870,6 +1870,143 @@ class ConnectionTransportManager {
1870
1870
  }
1871
1871
  }
1872
1872
 
1873
+ // src/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.ts
1874
+ class ActionExternalClientHandler extends ActionHandler {
1875
+ externalClient;
1876
+ handlerType = "external" /* external */;
1877
+ cuid;
1878
+ _defaultTimeout;
1879
+ _transportCache = new Map;
1880
+ transportManager = new ConnectionTransportManager(this._transportCache);
1881
+ _incomingActionDataListeners = [];
1882
+ actionRouter = new ActionRouter({
1883
+ contextType: "handler_route" /* handler_route */,
1884
+ handler: this
1885
+ });
1886
+ constructor({
1887
+ runtimeCoordinate: externalClientSpecifier,
1888
+ transports,
1889
+ defaultTimeout
1890
+ }) {
1891
+ super();
1892
+ this.externalClient = externalClientSpecifier;
1893
+ this.cuid = nanoid4();
1894
+ this._defaultTimeout = defaultTimeout ?? DEFAULT_TRANSPORT_TIMEOUT;
1895
+ for (const transport of transports) {
1896
+ const connection = transport._createConnection({
1897
+ resolvers: {
1898
+ onIncomingActionDataJson: (json) => {
1899
+ for (const l of this._incomingActionDataListeners)
1900
+ l(json);
1901
+ }
1902
+ }
1903
+ });
1904
+ connection.definition = transport;
1905
+ this.transportManager.addTransport(connection);
1906
+ }
1907
+ }
1908
+ forDomain(domain) {
1909
+ this.actionRouter.forDomain(domain, true);
1910
+ return this;
1911
+ }
1912
+ forAction(action) {
1913
+ this.actionRouter.forAction(action, true);
1914
+ return this;
1915
+ }
1916
+ forActionIds(domain, ids) {
1917
+ this.actionRouter.forActionIds(domain, ids, true);
1918
+ return this;
1919
+ }
1920
+ _setIncomingActionDataListener(listener) {
1921
+ this._incomingActionDataListeners.push(listener);
1922
+ }
1923
+ async handleActionRequest(action, config) {
1924
+ const localRuntime = config?.targetLocalRuntime ?? ActionRuntime.getDefault();
1925
+ const localClient = localRuntime.coordinate;
1926
+ const incomingTimeout = config?.timeout ?? this._defaultTimeout;
1927
+ const parentCuid = peekHandlerCuid();
1928
+ const callSite = action._callSite ?? new Error().stack;
1929
+ const { methods, transport } = await this.transportManager.getReadyTransport({
1930
+ action,
1931
+ localClient,
1932
+ externalClient: this.externalClient
1933
+ });
1934
+ action.context.addRouteItem({
1935
+ runtime: localClient,
1936
+ handler: this.toHandlerRouteItem(transport, {
1937
+ action,
1938
+ localClient,
1939
+ externalClient: this.externalClient
1940
+ }),
1941
+ time: Date.now()
1942
+ });
1943
+ const runningAction = new RunningAction({
1944
+ context: action.context,
1945
+ request: action,
1946
+ parentCuid,
1947
+ callSite
1948
+ });
1949
+ localRuntime.registerRunningAction(runningAction);
1950
+ const routeActionParams = {
1951
+ action,
1952
+ runningAction,
1953
+ localClient,
1954
+ externalClient: this.externalClient,
1955
+ timeout: incomingTimeout
1956
+ };
1957
+ if (action.type === "request" /* request */ && methods.updateRunConfig != null) {
1958
+ const runConfig = methods.updateRunConfig(routeActionParams);
1959
+ routeActionParams.timeout = runConfig?.timeout ?? incomingTimeout;
1960
+ }
1961
+ try {
1962
+ methods.sendActionData(routeActionParams);
1963
+ } catch (err3) {
1964
+ runningAction._abort(err3);
1965
+ }
1966
+ return runningAction;
1967
+ }
1968
+ async sendReturnPayload(payload, config) {
1969
+ const localClient = config.targetLocalRuntime.coordinate;
1970
+ try {
1971
+ const { methods } = await this.transportManager.getReadyTransport({
1972
+ action: payload,
1973
+ localClient,
1974
+ externalClient: this.externalClient
1975
+ });
1976
+ if (methods.sendReturnData == null)
1977
+ return false;
1978
+ methods.sendReturnData(payload);
1979
+ return true;
1980
+ } catch {
1981
+ return false;
1982
+ }
1983
+ }
1984
+ toJsonObject() {
1985
+ return {
1986
+ type: this.handlerType,
1987
+ client: this.externalClient
1988
+ };
1989
+ }
1990
+ toHandlerRouteItem(transport, input) {
1991
+ return {
1992
+ type: this.handlerType,
1993
+ client: this.externalClient,
1994
+ transOrd: transport.transOrd,
1995
+ transType: transport.type,
1996
+ transInfo: transport.definition?.getRouteInfo(input)
1997
+ };
1998
+ }
1999
+ clearTransportCache() {
2000
+ this._transportCache.clear();
2001
+ }
2002
+ }
2003
+ var createExternalClientHandler = (config) => {
2004
+ return new ActionExternalClientHandler(config);
2005
+ };
2006
+ // src/ActionRuntime/Handler/ExternalClient/Transport/Transport.ts
2007
+ class Transport {
2008
+ }
2009
+
1873
2010
  // src/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.ts
1874
2011
  function addTransportStatusMetadata(transportStatus) {
1875
2012
  if (transportStatus.status === "ready" /* ready */) {
@@ -1902,14 +2039,15 @@ function addTransportStatusMetadata(transportStatus) {
1902
2039
  };
1903
2040
  }
1904
2041
 
1905
- // src/ActionRuntime/Handler/ExternalClient/Transport/Transport.ts
2042
+ // src/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.ts
1906
2043
  var transportOrd = 0;
1907
2044
 
1908
- class Transport {
2045
+ class TransportConnection {
1909
2046
  def;
1910
2047
  transOrd = transportOrd++;
1911
2048
  type;
1912
2049
  initialized;
2050
+ definition;
1913
2051
  constructor(def) {
1914
2052
  this.def = def;
1915
2053
  this.type = def.type;
@@ -1958,8 +2096,8 @@ class Transport {
1958
2096
  }
1959
2097
  }
1960
2098
 
1961
- // src/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.ts
1962
- class TransportCustom extends Transport {
2099
+ // src/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomConnection.ts
2100
+ class CustomConnection extends TransportConnection {
1963
2101
  constructor(def) {
1964
2102
  super({
1965
2103
  ...def,
@@ -1975,9 +2113,65 @@ class TransportCustom extends Transport {
1975
2113
  }
1976
2114
  }
1977
2115
 
1978
- // src/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.ts
2116
+ // src/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.ts
2117
+ class CustomTransport extends Transport {
2118
+ options;
2119
+ type = "custom" /* custom */;
2120
+ constructor(options) {
2121
+ super();
2122
+ this.options = options;
2123
+ }
2124
+ _createConnection(_ctx) {
2125
+ const options = this.options;
2126
+ return new CustomConnection({
2127
+ initialize: () => ({
2128
+ getTransportCacheKey: options.getTransportCacheKey,
2129
+ getTransport: options.getTransport ?? (() => ({
2130
+ status: "ready" /* ready */,
2131
+ readyData: {
2132
+ sendActionData: options.sendActionData,
2133
+ sendReturnData: options.sendReturnData,
2134
+ updateRunConfig: options.updateRunConfig,
2135
+ closeTransport: options.closeTransport ?? (() => {})
2136
+ }
2137
+ }))
2138
+ })
2139
+ });
2140
+ }
2141
+ getRouteInfo(input) {
2142
+ if (this.options.getRouteInfo != null)
2143
+ return this.options.getRouteInfo(input);
2144
+ return {
2145
+ type: "custom" /* custom */,
2146
+ summary: this.options.label ?? "custom"
2147
+ };
2148
+ }
2149
+ }
2150
+ // src/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.ts
2151
+ import { err as err3 } from "@nice-code/error";
2152
+ var EErrId_NiceTransport_WebSocket;
2153
+ ((EErrId_NiceTransport_WebSocket2) => {
2154
+ EErrId_NiceTransport_WebSocket2["ws_disconnected"] = "ws_disconnected";
2155
+ EErrId_NiceTransport_WebSocket2["ws_create_failed"] = "ws_create_failed";
2156
+ EErrId_NiceTransport_WebSocket2["ws_error"] = "ws_error";
2157
+ })(EErrId_NiceTransport_WebSocket ||= {});
2158
+ var err_nice_transport_ws = err_nice_transport.createChildDomain({
2159
+ domain: "ws_transport",
2160
+ schema: {
2161
+ ["ws_disconnected" /* ws_disconnected */]: err3({
2162
+ message: () => `WebSocket transport disconnected.`
2163
+ }),
2164
+ ["ws_create_failed" /* ws_create_failed */]: err3({
2165
+ message: ({ originalError }) => `Failed to create WebSocket transport.${originalError ? ` Original error: ${originalError.message}` : ""}`
2166
+ }),
2167
+ ["ws_error" /* ws_error */]: err3({
2168
+ message: ({ originalError }) => `WebSocket transport error.${originalError ? ` Original error: ${originalError.message}` : ""}`
2169
+ })
2170
+ }
2171
+ });
2172
+ // src/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpConnection.ts
1979
2173
  import { castNiceError as castNiceError3, isNiceErrorObject as isNiceErrorObject2, NiceError as NiceError2 } from "@nice-code/error";
1980
- class TransportHttp extends Transport {
2174
+ class HttpConnection extends TransportConnection {
1981
2175
  constructor(def) {
1982
2176
  super({
1983
2177
  ...def,
@@ -1988,7 +2182,7 @@ class TransportHttp extends Transport {
1988
2182
  return {
1989
2183
  sendActionData: (input) => {
1990
2184
  const request = methods.createRequest(input);
1991
- this.send({ ...input, params: { request }, runningAction: input.runningAction }).catch((err3) => input.runningAction._abort(err3));
2185
+ this.send({ ...input, params: { request }, runningAction: input.runningAction }).catch((err4) => input.runningAction._abort(err4));
1992
2186
  },
1993
2187
  updateRunConfig: methods.updateRunConfig
1994
2188
  };
@@ -2048,7 +2242,7 @@ class TransportHttp extends Transport {
2048
2242
  try {
2049
2243
  text = await res.text();
2050
2244
  } catch (e) {
2051
- console.warn(`Failed to read error response body for failed HTTP request in TransportHttp:`, e);
2245
+ console.warn(`Failed to read error response body for failed HTTP request in HttpConnection:`, e);
2052
2246
  }
2053
2247
  throw err_nice_transport.fromId("send_failed" /* send_failed */, {
2054
2248
  actionState: action.type,
@@ -2068,18 +2262,18 @@ class TransportHttp extends Transport {
2068
2262
  }
2069
2263
  runningAction._completeWithResult(action._domain.hydrateResultPayload(json));
2070
2264
  }
2071
- } catch (err3) {
2265
+ } catch (err4) {
2072
2266
  if (timedOut) {
2073
2267
  throw err_nice_transport.fromId("timeout" /* timeout */, { timeout });
2074
2268
  }
2075
- if (err3 instanceof NiceError2) {
2076
- throw err3;
2269
+ if (err4 instanceof NiceError2) {
2270
+ throw err4;
2077
2271
  }
2078
2272
  throw err_nice_transport.fromId("send_failed" /* send_failed */, {
2079
2273
  actionState: action.type,
2080
2274
  actionId: action.id,
2081
- message: err3 instanceof Error ? err3.message : String(err3)
2082
- }).withOriginError(err3 instanceof Error ? err3 : undefined);
2275
+ message: err4 instanceof Error ? err4.message : String(err4)
2276
+ }).withOriginError(err4 instanceof Error ? err4 : undefined);
2083
2277
  } finally {
2084
2278
  clearTimeout(timeoutId);
2085
2279
  unsubscribe();
@@ -2087,29 +2281,57 @@ class TransportHttp extends Transport {
2087
2281
  }
2088
2282
  }
2089
2283
 
2090
- // src/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.ts
2091
- import { err as err3 } from "@nice-code/error";
2092
- var EErrId_NiceTransport_WebSocket;
2093
- ((EErrId_NiceTransport_WebSocket2) => {
2094
- EErrId_NiceTransport_WebSocket2["ws_disconnected"] = "ws_disconnected";
2095
- EErrId_NiceTransport_WebSocket2["ws_create_failed"] = "ws_create_failed";
2096
- EErrId_NiceTransport_WebSocket2["ws_error"] = "ws_error";
2097
- })(EErrId_NiceTransport_WebSocket ||= {});
2098
- var err_nice_transport_ws = err_nice_transport.createChildDomain({
2099
- domain: "ws_transport",
2100
- schema: {
2101
- ["ws_disconnected" /* ws_disconnected */]: err3({
2102
- message: () => `WebSocket transport disconnected.`
2103
- }),
2104
- ["ws_create_failed" /* ws_create_failed */]: err3({
2105
- message: ({ originalError }) => `Failed to create WebSocket transport.${originalError ? ` Original error: ${originalError.message}` : ""}`
2106
- }),
2107
- ["ws_error" /* ws_error */]: err3({
2108
- message: ({ originalError }) => `WebSocket transport error.${originalError ? ` Original error: ${originalError.message}` : ""}`
2109
- })
2284
+ // src/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.ts
2285
+ function resolveMaybe(value, input) {
2286
+ return typeof value === "function" ? value(input) : value;
2287
+ }
2288
+ function shortPath(url) {
2289
+ try {
2290
+ return new URL(url).pathname || url;
2291
+ } catch {
2292
+ return url;
2110
2293
  }
2111
- });
2294
+ }
2112
2295
 
2296
+ class HttpTransport extends Transport {
2297
+ options;
2298
+ type = "http" /* http */;
2299
+ constructor(options) {
2300
+ super();
2301
+ this.options = options;
2302
+ }
2303
+ _resolveRequest(input) {
2304
+ if (this.options.createRequest != null)
2305
+ return this.options.createRequest(input);
2306
+ return {
2307
+ url: resolveMaybe(this.options.url, input),
2308
+ headers: this.options.headers != null ? resolveMaybe(this.options.headers, input) : undefined
2309
+ };
2310
+ }
2311
+ _createConnection(_ctx) {
2312
+ return new HttpConnection({
2313
+ initialize: () => ({
2314
+ getTransportCacheKey: this.options.getTransportCacheKey,
2315
+ getTransport: () => ({
2316
+ status: "ready" /* ready */,
2317
+ readyData: {
2318
+ createRequest: (input) => this._resolveRequest(input),
2319
+ updateRunConfig: this.options.updateRunConfig
2320
+ }
2321
+ })
2322
+ })
2323
+ });
2324
+ }
2325
+ getRouteInfo(input) {
2326
+ const { url } = this._resolveRequest(input);
2327
+ return {
2328
+ type: "http" /* http */,
2329
+ method: "POST",
2330
+ url,
2331
+ summary: `POST ${shortPath(url)}`
2332
+ };
2333
+ }
2334
+ }
2113
2335
  // src/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.ts
2114
2336
  var createUnsetTransportResolvers = (type) => ({
2115
2337
  onIncomingActionDataJson: (json) => {
@@ -2117,8 +2339,8 @@ var createUnsetTransportResolvers = (type) => ({
2117
2339
  }
2118
2340
  });
2119
2341
 
2120
- // src/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.ts
2121
- class TransportWebSocket extends Transport {
2342
+ // src/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.ts
2343
+ class WebSocketConnection extends TransportConnection {
2122
2344
  resolvers;
2123
2345
  _abortSet = new Set;
2124
2346
  constructor(def, resolvers) {
@@ -2252,140 +2474,55 @@ class TransportWebSocket extends Transport {
2252
2474
  }
2253
2475
  }
2254
2476
 
2255
- // src/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.ts
2256
- class ActionExternalClientHandler extends ActionHandler {
2257
- externalClient;
2258
- handlerType = "external" /* external */;
2259
- cuid;
2260
- _defaultTimeout;
2261
- _transportCache = new Map;
2262
- transportManager = new ConnectionTransportManager(this._transportCache);
2263
- _incomingActionDataListeners = [];
2264
- actionRouter = new ActionRouter({
2265
- contextType: "handler_route" /* handler_route */,
2266
- handler: this
2267
- });
2268
- constructor({
2269
- externalClientSpecifier,
2270
- transports,
2271
- defaultTimeout
2272
- }) {
2477
+ // src/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.ts
2478
+ function resolveMaybe2(value, input) {
2479
+ return typeof value === "function" ? value(input) : value;
2480
+ }
2481
+ function shortWs(url) {
2482
+ try {
2483
+ const u = new URL(url);
2484
+ return `${u.host}${u.pathname}`;
2485
+ } catch {
2486
+ return url;
2487
+ }
2488
+ }
2489
+
2490
+ class WebSocketTransport extends Transport {
2491
+ options;
2492
+ type = "ws" /* ws */;
2493
+ constructor(options) {
2273
2494
  super();
2274
- this.externalClient = externalClientSpecifier;
2275
- this.cuid = nanoid4();
2276
- this._defaultTimeout = defaultTimeout ?? DEFAULT_TRANSPORT_TIMEOUT;
2277
- for (const def of transports) {
2278
- if (def.type === "ws" /* ws */) {
2279
- this.transportManager.addTransport(new TransportWebSocket(def, {
2280
- onIncomingActionDataJson: (json) => {
2281
- for (const l of this._incomingActionDataListeners)
2282
- l(json);
2495
+ this.options = options;
2496
+ }
2497
+ _createSocket(input) {
2498
+ if (this.options.createWebSocket != null)
2499
+ return this.options.createWebSocket(input);
2500
+ return new WebSocket(resolveMaybe2(this.options.url, input));
2501
+ }
2502
+ _createConnection(ctx) {
2503
+ return new WebSocketConnection({
2504
+ initialize: () => ({
2505
+ getTransportCacheKey: this.options.getTransportCacheKey ?? ((input) => [resolveMaybe2(this.options.url, input)]),
2506
+ getTransport: (input) => ({
2507
+ status: "ready" /* ready */,
2508
+ readyData: {
2509
+ ws: this._createSocket(input),
2510
+ formatMessage: this.options.formatMessage,
2511
+ updateRunConfig: this.options.updateRunConfig
2283
2512
  }
2284
- }));
2285
- } else if (def.type === "http" /* http */) {
2286
- this.transportManager.addTransport(new TransportHttp(def));
2287
- } else if (def.type === "custom" /* custom */) {
2288
- this.transportManager.addTransport(new TransportCustom(def));
2289
- } else {
2290
- throw err_nice_action.fromId("not_implemented" /* not_implemented */, {
2291
- label: `transport type "${def.type}"`
2292
- });
2293
- }
2294
- }
2295
- }
2296
- forDomain(domain) {
2297
- this.actionRouter.forDomain(domain, true);
2298
- return this;
2299
- }
2300
- forAction(action) {
2301
- this.actionRouter.forAction(action, true);
2302
- return this;
2513
+ })
2514
+ })
2515
+ }, ctx.resolvers);
2303
2516
  }
2304
- forActionIds(domain, ids) {
2305
- this.actionRouter.forActionIds(domain, ids, true);
2306
- return this;
2307
- }
2308
- _setIncomingActionDataListener(listener) {
2309
- this._incomingActionDataListeners.push(listener);
2310
- }
2311
- async handleActionRequest(action, config) {
2312
- const localRuntime = config?.targetLocalRuntime ?? ActionRuntime.getDefault();
2313
- const localClient = localRuntime.coordinate;
2314
- const incomingTimeout = config?.timeout ?? this._defaultTimeout;
2315
- const parentCuid = peekHandlerCuid();
2316
- const callSite = action._callSite ?? new Error().stack;
2317
- const { methods, transport } = await this.transportManager.getReadyTransport({
2318
- action,
2319
- localClient,
2320
- externalClient: this.externalClient
2321
- });
2322
- action.context.addRouteItem({
2323
- runtime: localClient,
2324
- handler: this.toHandlerRouteItem(transport),
2325
- time: Date.now()
2326
- });
2327
- const runningAction = new RunningAction({
2328
- context: action.context,
2329
- request: action,
2330
- parentCuid,
2331
- callSite
2332
- });
2333
- localRuntime.registerRunningAction(runningAction);
2334
- const routeActionParams = {
2335
- action,
2336
- runningAction,
2337
- localClient,
2338
- externalClient: this.externalClient,
2339
- timeout: incomingTimeout
2340
- };
2341
- if (action.type === "request" /* request */ && methods.updateRunConfig != null) {
2342
- const runConfig = methods.updateRunConfig(routeActionParams);
2343
- routeActionParams.timeout = runConfig?.timeout ?? incomingTimeout;
2344
- }
2345
- try {
2346
- methods.sendActionData(routeActionParams);
2347
- } catch (err4) {
2348
- runningAction._abort(err4);
2349
- }
2350
- return runningAction;
2351
- }
2352
- async sendReturnPayload(payload, config) {
2353
- const localClient = config.targetLocalRuntime.coordinate;
2354
- try {
2355
- const { methods } = await this.transportManager.getReadyTransport({
2356
- action: payload,
2357
- localClient,
2358
- externalClient: this.externalClient
2359
- });
2360
- if (methods.sendReturnData == null)
2361
- return false;
2362
- methods.sendReturnData(payload);
2363
- return true;
2364
- } catch {
2365
- return false;
2366
- }
2367
- }
2368
- toJsonObject() {
2517
+ getRouteInfo(input) {
2518
+ const url = resolveMaybe2(this.options.url, input);
2369
2519
  return {
2370
- type: this.handlerType,
2371
- client: this.externalClient
2520
+ type: "ws" /* ws */,
2521
+ url,
2522
+ summary: `ws ${shortWs(url)}`
2372
2523
  };
2373
2524
  }
2374
- toHandlerRouteItem(transport) {
2375
- return {
2376
- type: this.handlerType,
2377
- client: this.externalClient,
2378
- transOrd: transport.transOrd,
2379
- transType: transport.type
2380
- };
2381
- }
2382
- clearTransportCache() {
2383
- this._transportCache.clear();
2384
- }
2385
2525
  }
2386
- var createExternalClientHandler = (config) => {
2387
- return new ActionExternalClientHandler(config);
2388
- };
2389
2526
  export {
2390
2527
  isActionPayload_Result_JsonObject,
2391
2528
  isActionPayload_Request_JsonObject,
@@ -2398,11 +2535,11 @@ export {
2398
2535
  createExternalClientHandler,
2399
2536
  createActionRootDomain,
2400
2537
  actionSchema,
2401
- TransportWebSocket,
2402
- TransportHttp,
2538
+ WebSocketTransport,
2403
2539
  Transport,
2404
2540
  RuntimeCoordinate,
2405
2541
  RunningAction,
2542
+ HttpTransport,
2406
2543
  ETransportType,
2407
2544
  ETransportStatus,
2408
2545
  ERunningActionUpdateType,
@@ -2413,6 +2550,7 @@ export {
2413
2550
  EErrId_NiceAction,
2414
2551
  EActionProgressType,
2415
2552
  EActionPayloadType,
2553
+ CustomTransport,
2416
2554
  ActionSchema,
2417
2555
  ActionRuntime,
2418
2556
  ActionRootDomain,
@@ -1,6 +1,6 @@
1
1
  import type { TInferActionError } from "../../..";
2
2
  import type { IActionHandler_ExternalClient_Json, IActionHandler_Local_Json } from "../../../ActionRuntime/Handler/ActionHandler.types";
3
- import type { ETransportType } from "../../../ActionRuntime/Handler/ExternalClient/Transport/Transport.types";
3
+ import type { ETransportType, ITransportRouteInfo } from "../../../ActionRuntime/Handler/ExternalClient/Transport/Transport.types";
4
4
  import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
5
5
  import type { EActionForm, IActionBase, IActionBase_JsonObject } from "../ActionBase.types";
6
6
  import type { ActionContext } from "../Context/ActionContext";
@@ -25,6 +25,7 @@ export interface IActionPayload_Base<DT extends EActionPayloadType, DOM extends
25
25
  export type IActionRouteItemHandler = IActionHandler_Local_Json | (IActionHandler_ExternalClient_Json & {
26
26
  transType: ETransportType;
27
27
  transOrd: number;
28
+ transInfo?: ITransportRouteInfo;
28
29
  });
29
30
  /**
30
31
  * [ ]
@@ -10,7 +10,8 @@ import { RuntimeCoordinate } from "../../RuntimeCoordinate";
10
10
  import { ActionHandler } from "../ActionHandler";
11
11
  import { EActionHandlerType, type IActionHandler_ExternalClient, type IActionHandler_ExternalClient_Json, type IHandleActionOptions } from "../ActionHandler.types";
12
12
  import type { IActionExternalClientRequestHandlerConfig } from "./ActionExternalClientHandler.types";
13
- import type { Transport } from "./Transport/Transport";
13
+ import { type ITransportRouteActionParams } from "./Transport/Transport.types";
14
+ import type { TransportConnection } from "./Transport/TransportConnection";
14
15
  export declare class ActionExternalClientHandler extends ActionHandler<EActionHandlerType.external> implements IActionHandler_ExternalClient {
15
16
  readonly externalClient: RuntimeCoordinate;
16
17
  readonly handlerType = EActionHandlerType.external;
@@ -20,7 +21,7 @@ export declare class ActionExternalClientHandler extends ActionHandler<EActionHa
20
21
  private transportManager;
21
22
  private _incomingActionDataListeners;
22
23
  readonly actionRouter: ActionRouter<true>;
23
- constructor({ externalClientSpecifier, transports, defaultTimeout, }: IActionExternalClientRequestHandlerConfig);
24
+ constructor({ runtimeCoordinate: externalClientSpecifier, transports, defaultTimeout, }: IActionExternalClientRequestHandlerConfig);
24
25
  forDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>): this;
25
26
  forAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actionSchema"] & string>(action: ActionCore<ACT_DOM, ID>): this;
26
27
  forActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actionSchema"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS): this;
@@ -37,7 +38,7 @@ export declare class ActionExternalClientHandler extends ActionHandler<EActionHa
37
38
  targetLocalRuntime: ActionRuntime;
38
39
  }): Promise<boolean>;
39
40
  toJsonObject(): IActionHandler_ExternalClient_Json;
40
- toHandlerRouteItem(transport: Transport): IActionRouteItemHandler;
41
+ toHandlerRouteItem(transport: TransportConnection, input: ITransportRouteActionParams): IActionRouteItemHandler;
41
42
  clearTransportCache(): void;
42
43
  }
43
44
  export declare const createExternalClientHandler: (config: IActionExternalClientRequestHandlerConfig) => ActionExternalClientHandler;
@@ -1,7 +1,7 @@
1
1
  import type { RuntimeCoordinate } from "../../RuntimeCoordinate";
2
- import type { TActionTransportDef } from "./Transport/Transport.combined.types";
2
+ import type { Transport } from "./Transport/Transport";
3
3
  export interface IActionExternalClientRequestHandlerConfig {
4
4
  defaultTimeout?: number;
5
- externalClientSpecifier: RuntimeCoordinate;
6
- transports: TActionTransportDef[];
5
+ runtimeCoordinate: RuntimeCoordinate;
6
+ transports: Transport[];
7
7
  }
@@ -1,9 +1,9 @@
1
- import type { Transport } from "./Transport";
2
1
  import { type IActionTransportReady, type ITransportRouteActionParams, type TTransportCache } from "./Transport.types";
2
+ import type { TransportConnection } from "./TransportConnection";
3
3
  export declare class ConnectionTransportManager {
4
4
  private _cache;
5
5
  private _transports;
6
6
  constructor(_cache: TTransportCache);
7
- addTransport(transport: Transport): void;
7
+ addTransport(transport: TransportConnection): void;
8
8
  getReadyTransport(routeActionParams: ITransportRouteActionParams): Promise<IActionTransportReady>;
9
9
  }
@@ -1,7 +1,7 @@
1
- import { Transport } from "../Transport";
1
+ import { TransportConnection } from "../TransportConnection";
2
2
  import { ETransportType, type IActionTransportReadyData_Methods, type ITransportRouteActionParams } from "../Transport.types";
3
3
  import type { IActionTransportDef_Custom, IActionTransportInitialized_Custom, IActionTransportReadyData_Custom, TActionTransportDef_Custom_NoType } from "./TransportCustom.types";
4
- export declare class TransportCustom extends Transport<ETransportType.custom, ITransportRouteActionParams, IActionTransportReadyData_Custom, IActionTransportInitialized_Custom, IActionTransportDef_Custom> {
4
+ export declare class CustomConnection extends TransportConnection<ETransportType.custom, ITransportRouteActionParams, IActionTransportReadyData_Custom, IActionTransportInitialized_Custom, IActionTransportDef_Custom> {
5
5
  constructor(def: TActionTransportDef_Custom_NoType);
6
6
  protected _finalizeTransportMethods(inputs: IActionTransportReadyData_Custom): IActionTransportReadyData_Methods;
7
7
  }