@eyepop.ai/eyepop 3.20.0 → 3.21.0

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.
@@ -8667,6 +8667,8 @@ __export(index_exports, {
8667
8667
  AutoAnnotateStatus: () => AutoAnnotateStatus,
8668
8668
  AutoAnnotateTask: () => AutoAnnotateTask,
8669
8669
  ChangeType: () => ChangeType,
8670
+ ComputeAccountMismatchError: () => ComputeAccountMismatchError,
8671
+ ComputeApiError: () => ComputeApiError,
8670
8672
  ContourType: () => ContourType,
8671
8673
  DEFAULT_PREDICTION_VERSION: () => DEFAULT_PREDICTION_VERSION,
8672
8674
  DataApiType: () => DataApiType,
@@ -8778,6 +8780,9 @@ function pipelineIdFromSession(session) {
8778
8780
  }
8779
8781
  function sessionCreateBody(options) {
8780
8782
  const body = {};
8783
+ if (options.accountId) {
8784
+ body.account_uuid = options.accountId;
8785
+ }
8781
8786
  if (options.sessionName) {
8782
8787
  body.session_name = options.sessionName;
8783
8788
  }
@@ -8827,6 +8832,42 @@ function pipelineErrorMessage(session) {
8827
8832
  }
8828
8833
  return null;
8829
8834
  }
8835
+ var ComputeApiError = class extends Error {
8836
+ constructor(message, status, code) {
8837
+ super(message);
8838
+ this.name = "ComputeApiError";
8839
+ this.status = status;
8840
+ this.code = code;
8841
+ }
8842
+ };
8843
+ var ComputeAccountMismatchError = class extends Error {
8844
+ constructor(sessionUuid, sessionAccountId, accountId) {
8845
+ super(`Compute session ${sessionUuid} runs under account ${sessionAccountId || "(none)"}, not the configured account ${accountId}`);
8846
+ this.name = "ComputeAccountMismatchError";
8847
+ this.sessionUuid = sessionUuid;
8848
+ this.sessionAccountId = sessionAccountId;
8849
+ this.accountId = accountId;
8850
+ }
8851
+ };
8852
+ async function computeApiError(response, action) {
8853
+ const code = await responseErrorCode(response);
8854
+ const message = await responseErrorMessage(response);
8855
+ return new ComputeApiError(`Unexpected status ${response.status} ${action}: ${message}`, response.status, code);
8856
+ }
8857
+ async function responseErrorCode(response) {
8858
+ try {
8859
+ const parsed = normalizedJsonValue(await response.clone().json());
8860
+ if (!parsed || typeof parsed != "object") {
8861
+ return void 0;
8862
+ }
8863
+ const record = parsed;
8864
+ const nested = normalizedJsonValue(record["error"]);
8865
+ const code = nested && typeof nested == "object" ? nested["code"] : record["code"];
8866
+ return typeof code == "string" && code.length > 0 ? code : void 0;
8867
+ } catch (_) {
8868
+ return void 0;
8869
+ }
8870
+ }
8830
8871
  async function responseErrorMessage(response) {
8831
8872
  const contentType = response.headers.get("content-type") || "";
8832
8873
  if (contentType.includes("application/json")) {
@@ -8930,8 +8971,7 @@ var ComputeSessionClient = class {
8930
8971
  if (response.status == 404) {
8931
8972
  sessions = [];
8932
8973
  } else if (response.status != 200) {
8933
- const message = await responseErrorMessage(response);
8934
- throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
8974
+ throw await computeApiError(response, "fetching compute sessions");
8935
8975
  } else {
8936
8976
  const response_content = await responseJson(response);
8937
8977
  sessions = response_content;
@@ -8939,7 +8979,7 @@ var ComputeSessionClient = class {
8939
8979
  if (sessions.length > 0) {
8940
8980
  this.options.logger?.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
8941
8981
  for (let s of sessions) {
8942
- if (!SESSION_DEAD.has(s.session_status) && !s.persistent && (!this.options.sessionName || s.session_name === this.options.sessionName)) {
8982
+ if (!SESSION_DEAD.has(s.session_status) && !s.persistent && (!this.options.sessionName || s.session_name === this.options.sessionName) && (!this.options.accountId || s.account_uuid === this.options.accountId)) {
8943
8983
  session = s;
8944
8984
  this.options.logger?.debug(`Use active session ${s.session_uuid} with pipeline ${pipelineIdFromSession(s)}`);
8945
8985
  break;
@@ -8964,8 +9004,7 @@ var ComputeSessionClient = class {
8964
9004
  const query = "wait=true";
8965
9005
  const response = await this.options.httpClient.fetch(`${sessionsUrl}?${query}`, request);
8966
9006
  if (response.status != 200) {
8967
- const message = await responseErrorMessage(response);
8968
- throw new Error(`Unexpected status ${response.status} creating a compute session: ${message}`);
9007
+ throw await computeApiError(response, "creating a compute session");
8969
9008
  } else {
8970
9009
  sessions = await responseJson(response);
8971
9010
  }
@@ -8990,14 +9029,16 @@ var ComputeSessionClient = class {
8990
9029
  headers
8991
9030
  });
8992
9031
  if (response.status == 404) {
8993
- throw new Error(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`);
9032
+ throw new ComputeApiError(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`, response.status);
8994
9033
  } else if (response.status != 200) {
8995
- const message = await responseErrorMessage(response);
8996
- throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
9034
+ throw await computeApiError(response, "fetching compute sessions");
8997
9035
  } else {
8998
9036
  const response_content = await responseJson(response);
8999
9037
  session = response_content;
9000
9038
  }
9039
+ if (this.options.accountId && session.account_uuid !== this.options.accountId) {
9040
+ throw new ComputeAccountMismatchError(sessionUuid, session.account_uuid, this.options.accountId);
9041
+ }
9001
9042
  return session;
9002
9043
  }
9003
9044
  async sessionAuthorizationHeader(session) {
@@ -9382,7 +9423,6 @@ var VideoMode = /* @__PURE__ */ ((VideoMode2) => {
9382
9423
  var PopComponentType = /* @__PURE__ */ ((PopComponentType2) => {
9383
9424
  PopComponentType2["FORWARD"] = "forward";
9384
9425
  PopComponentType2["INFERENCE"] = "inference";
9385
- PopComponentType2["TRACING"] = "tracing";
9386
9426
  PopComponentType2["TRACKING"] = "tracking";
9387
9427
  PopComponentType2["CONTOUR_FINDER"] = "contour_finder";
9388
9428
  PopComponentType2["COMPONENT_FINDER"] = "component_finder";
@@ -10095,7 +10135,10 @@ var LoadFromJob = class extends AbstractJob {
10095
10135
  roi: this._params.roi,
10096
10136
  fps: this._params.fps,
10097
10137
  camera: this._params.camera,
10098
- version: this._version
10138
+ version: this._version,
10139
+ // undefined is dropped by JSON.stringify, so an unset option leaves
10140
+ // the worker's own default to decide rather than pinning it here.
10141
+ rtspForceNonCompliantUrl: this._params.rtspForceNonCompliantUrl
10099
10142
  };
10100
10143
  if (this._params.motionDetect) {
10101
10144
  Object.assign(body, this._params.motionDetect);
@@ -10849,6 +10892,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10849
10892
  this._popName = null;
10850
10893
  this._sessionAccessToken = null;
10851
10894
  this._sessionAccessTokenValidUntil = null;
10895
+ this._accountId = void 0;
10852
10896
  this._pipeline = null;
10853
10897
  this._pipelineCreatePromise = null;
10854
10898
  }
@@ -10898,6 +10942,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10898
10942
  accessToken: session.accessToken,
10899
10943
  validUntil: session.validUntil,
10900
10944
  popId: this.options().popId,
10945
+ accountId: this._accountId ?? this.options().accountId,
10901
10946
  baseUrl: this._baseUrl,
10902
10947
  pipelineId: this._pipelineId || void 0,
10903
10948
  authenticationHeaders: () => this._authenticationHeaders(session)
@@ -11453,6 +11498,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
11453
11498
  authorizationHeader: () => this.computeAuthorizationHeader(),
11454
11499
  sessionUuid: this.options().sessionUuid,
11455
11500
  sessionName: this.options().sessionName,
11501
+ accountId: this.options().accountId,
11456
11502
  pipelineImage: this.options().pipelineImage,
11457
11503
  pipelineVersion: this.options().pipelineVersion,
11458
11504
  pop: this.options().pop,
@@ -11467,6 +11513,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
11467
11513
  this._sessionAccessToken = resolved.accessToken;
11468
11514
  this._sessionAccessTokenValidUntil = resolved.accessTokenValidUntil;
11469
11515
  this._baseUrl = resolved.session.session_endpoint;
11516
+ this._accountId = resolved.session.account_uuid || void 0;
11470
11517
  this._pipeline = null;
11471
11518
  this._pipelineId = resolved.pipelineId;
11472
11519
  if (this.options().pop) {
@@ -13090,7 +13137,7 @@ var PointCloud = class {
13090
13137
  return placed;
13091
13138
  }
13092
13139
  /**
13093
- * Per axis (min, max) in metres over the placed points, or undefined if none were.
13140
+ * Per axis (min, max) in meters over the placed points, or undefined if none were.
13094
13141
  *
13095
13142
  * The counterpart to DepthMap's finiteMin/finiteMax, which are one axis
13096
13143
  * because a depth map has one value per pixel.
@@ -13269,6 +13316,19 @@ var readEnv = (env) => {
13269
13316
  }
13270
13317
  return void 0;
13271
13318
  };
13319
+ var warnedAccountIdEnv = false;
13320
+ var readAccountUuidEnv = () => {
13321
+ const accountUuid = readEnv("EYEPOP_ACCOUNT_UUID");
13322
+ if (accountUuid !== void 0) {
13323
+ return accountUuid;
13324
+ }
13325
+ const accountId = readEnv("EYEPOP_ACCOUNT_ID");
13326
+ if (accountId !== void 0 && !warnedAccountIdEnv) {
13327
+ warnedAccountIdEnv = true;
13328
+ console.warn("EYEPOP_ACCOUNT_ID is deprecated, use EYEPOP_ACCOUNT_UUID instead");
13329
+ }
13330
+ return accountId;
13331
+ };
13272
13332
  var stringToBooleanSafe = (str) => {
13273
13333
  if (typeof str == "undefined") {
13274
13334
  return false;
@@ -13283,7 +13343,8 @@ var EyePop;
13283
13343
  apiKey: envApiKey
13284
13344
  } : void 0;
13285
13345
  EyePop2.endpoint = workerEndpoint;
13286
- function workerEndpoint(opts = {}) {
13346
+ function workerEndpoint(options = {}) {
13347
+ const opts = { ...options };
13287
13348
  if (opts.pop !== void 0) {
13288
13349
  validatePop(opts.pop);
13289
13350
  }
@@ -13307,6 +13368,9 @@ var EyePop;
13307
13368
  if (opts.sessionName === void 0) {
13308
13369
  opts.sessionName = readEnv("EYEPOP_SESSION_NAME");
13309
13370
  }
13371
+ if (opts.accountId === void 0) {
13372
+ opts.accountId = readAccountUuidEnv();
13373
+ }
13310
13374
  if (opts.pipelineImage === void 0) {
13311
13375
  opts.pipelineImage = readEnv("EYEPOP_PIPELINE_IMAGE");
13312
13376
  }
@@ -13329,6 +13393,9 @@ var EyePop;
13329
13393
  if (auth.session.popId) {
13330
13394
  opts.popId = auth.session.popId;
13331
13395
  }
13396
+ if (auth.session.accountId) {
13397
+ opts.accountId = auth.session.accountId;
13398
+ }
13332
13399
  }
13333
13400
  }
13334
13401
  }
@@ -13342,7 +13409,7 @@ var EyePop;
13342
13409
  throw new Error("apiKey/accessToken/session/oAuth2 option or EYEPOP_API_KEY environment variable is required");
13343
13410
  }
13344
13411
  if (opts.accountId === void 0) {
13345
- opts.accountId = readEnv("EYEPOP_ACCOUNT_ID");
13412
+ opts.accountId = readAccountUuidEnv();
13346
13413
  }
13347
13414
  if (auth.session !== void 0) {
13348
13415
  if (auth.session !== void 0) {
@@ -13413,6 +13480,8 @@ var index_default = EyePop;
13413
13480
  AutoAnnotateStatus,
13414
13481
  AutoAnnotateTask,
13415
13482
  ChangeType,
13483
+ ComputeAccountMismatchError,
13484
+ ComputeApiError,
13416
13485
  ContourType,
13417
13486
  DEFAULT_PREDICTION_VERSION,
13418
13487
  DataApiType,