@truenas/api-client 9.0.2 → 9.0.3

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.
@@ -4306,6 +4306,11 @@ async function createTrueNasClient(opts) {
4306
4306
  `Cannot create client for system ${uuid}: hostnames array is empty`
4307
4307
  );
4308
4308
  }
4309
+ if (opts.websocketPath !== void 0 && !opts.websocketPath.startsWith("/")) {
4310
+ throw new Error(
4311
+ `Cannot create client for system ${uuid}: websocketPath must be an absolute path, got '${opts.websocketPath}'.`
4312
+ );
4313
+ }
4309
4314
  logger.info("Creating versioned API client", {
4310
4315
  uuid: uuid.slice(0, 8),
4311
4316
  hostnames: hostnames.join(", "),
@@ -4335,7 +4340,7 @@ async function createTrueNasClient(opts) {
4335
4340
  logger.info("API version supplied by the caller, skipping discovery", {
4336
4341
  uuid: uuid.slice(0, 8),
4337
4342
  version: known.version,
4338
- websocketPath: known.websocketPath
4343
+ websocketPath: opts.websocketPath ?? known.websocketPath
4339
4344
  });
4340
4345
  return instantiateClientForVersion(known, opts, logger);
4341
4346
  }
@@ -4354,7 +4359,7 @@ async function createTrueNasClient(opts) {
4354
4359
  // of them anyway.
4355
4360
  hostname: winner.hostname,
4356
4361
  version: version.version,
4357
- websocketPath: version.websocketPath
4362
+ websocketPath: opts.websocketPath ?? version.websocketPath
4358
4363
  });
4359
4364
  } catch (error) {
4360
4365
  const errorMessage = errorMessageOrDefault(error, "Unknown error");
@@ -4480,6 +4485,7 @@ function clientClassFor(version) {
4480
4485
  function instantiateClientForVersion(version, opts, logger) {
4481
4486
  const { uuid, hostnames, enabled, systemName } = opts;
4482
4487
  const versionKey = clientVersionKey(version);
4488
+ const endpoint = opts.websocketPath === void 0 ? version : { ...version, websocketPath: opts.websocketPath };
4483
4489
  const Client = CLIENT_BY_VERSION_KEY[versionKey];
4484
4490
  if (!Client) {
4485
4491
  logger.error("No client implementation for version", {
@@ -4494,12 +4500,13 @@ function instantiateClientForVersion(version, opts, logger) {
4494
4500
  logger.info(`Instantiating ${Client.name}`, {
4495
4501
  uuid: uuid.slice(0, 8),
4496
4502
  version: version.version,
4497
- versionKey
4503
+ versionKey,
4504
+ websocketPath: endpoint.websocketPath
4498
4505
  });
4499
4506
  return new Client(
4500
4507
  uuid,
4501
4508
  hostnames,
4502
- version,
4509
+ endpoint,
4503
4510
  enabled,
4504
4511
  systemName,
4505
4512
  logger,
@@ -4524,5 +4531,5 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
4524
4531
  })(UserRole || {});
4525
4532
 
4526
4533
  export { AppState, AuthError, AuthErrorCode, AuthResponseType, InvalidVersionResponseError, JobState, NoCompatibleVersionsError, SUPPORTED_API_VERSIONS, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV27, TrueNasApiClientV28, TrueNasApiError, TrueNasAuthMechanism, TrueNasAuthenticator, TrueNasConnection, UserRole, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, clientClassFor, consoleLogger, createTrueNasClient, getApiErrorMessage, getCloseMessage, isJobFinished, noopLogger, parseApiVersion, policyViolationCloseCode, subscriptionName, v25_10_0_exports, v25_10_1_exports, v25_10_2_exports, v25_10_3_exports, v25_10_4_exports, v25_10_5_exports, v27_0_0_exports, v28_0_0_exports };
4527
- //# sourceMappingURL=chunk-PJVDHM2S.js.map
4528
- //# sourceMappingURL=chunk-PJVDHM2S.js.map
4534
+ //# sourceMappingURL=chunk-K5ICTA2D.js.map
4535
+ //# sourceMappingURL=chunk-K5ICTA2D.js.map