@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.
@@ -8679,6 +8679,9 @@ function pipelineIdFromSession(session) {
8679
8679
  }
8680
8680
  function sessionCreateBody(options) {
8681
8681
  const body = {};
8682
+ if (options.accountId) {
8683
+ body.account_uuid = options.accountId;
8684
+ }
8682
8685
  if (options.sessionName) {
8683
8686
  body.session_name = options.sessionName;
8684
8687
  }
@@ -8728,6 +8731,42 @@ function pipelineErrorMessage(session) {
8728
8731
  }
8729
8732
  return null;
8730
8733
  }
8734
+ var ComputeApiError = class extends Error {
8735
+ constructor(message, status, code) {
8736
+ super(message);
8737
+ this.name = "ComputeApiError";
8738
+ this.status = status;
8739
+ this.code = code;
8740
+ }
8741
+ };
8742
+ var ComputeAccountMismatchError = class extends Error {
8743
+ constructor(sessionUuid, sessionAccountId, accountId) {
8744
+ super(`Compute session ${sessionUuid} runs under account ${sessionAccountId || "(none)"}, not the configured account ${accountId}`);
8745
+ this.name = "ComputeAccountMismatchError";
8746
+ this.sessionUuid = sessionUuid;
8747
+ this.sessionAccountId = sessionAccountId;
8748
+ this.accountId = accountId;
8749
+ }
8750
+ };
8751
+ async function computeApiError(response, action) {
8752
+ const code = await responseErrorCode(response);
8753
+ const message = await responseErrorMessage(response);
8754
+ return new ComputeApiError(`Unexpected status ${response.status} ${action}: ${message}`, response.status, code);
8755
+ }
8756
+ async function responseErrorCode(response) {
8757
+ try {
8758
+ const parsed = normalizedJsonValue(await response.clone().json());
8759
+ if (!parsed || typeof parsed != "object") {
8760
+ return void 0;
8761
+ }
8762
+ const record = parsed;
8763
+ const nested = normalizedJsonValue(record["error"]);
8764
+ const code = nested && typeof nested == "object" ? nested["code"] : record["code"];
8765
+ return typeof code == "string" && code.length > 0 ? code : void 0;
8766
+ } catch (_) {
8767
+ return void 0;
8768
+ }
8769
+ }
8731
8770
  async function responseErrorMessage(response) {
8732
8771
  const contentType = response.headers.get("content-type") || "";
8733
8772
  if (contentType.includes("application/json")) {
@@ -8831,8 +8870,7 @@ var ComputeSessionClient = class {
8831
8870
  if (response.status == 404) {
8832
8871
  sessions = [];
8833
8872
  } else if (response.status != 200) {
8834
- const message = await responseErrorMessage(response);
8835
- throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
8873
+ throw await computeApiError(response, "fetching compute sessions");
8836
8874
  } else {
8837
8875
  const response_content = await responseJson(response);
8838
8876
  sessions = response_content;
@@ -8840,7 +8878,7 @@ var ComputeSessionClient = class {
8840
8878
  if (sessions.length > 0) {
8841
8879
  this.options.logger?.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
8842
8880
  for (let s of sessions) {
8843
- if (!SESSION_DEAD.has(s.session_status) && !s.persistent && (!this.options.sessionName || s.session_name === this.options.sessionName)) {
8881
+ 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)) {
8844
8882
  session = s;
8845
8883
  this.options.logger?.debug(`Use active session ${s.session_uuid} with pipeline ${pipelineIdFromSession(s)}`);
8846
8884
  break;
@@ -8865,8 +8903,7 @@ var ComputeSessionClient = class {
8865
8903
  const query = "wait=true";
8866
8904
  const response = await this.options.httpClient.fetch(`${sessionsUrl}?${query}`, request);
8867
8905
  if (response.status != 200) {
8868
- const message = await responseErrorMessage(response);
8869
- throw new Error(`Unexpected status ${response.status} creating a compute session: ${message}`);
8906
+ throw await computeApiError(response, "creating a compute session");
8870
8907
  } else {
8871
8908
  sessions = await responseJson(response);
8872
8909
  }
@@ -8891,14 +8928,16 @@ var ComputeSessionClient = class {
8891
8928
  headers
8892
8929
  });
8893
8930
  if (response.status == 404) {
8894
- throw new Error(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`);
8931
+ throw new ComputeApiError(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`, response.status);
8895
8932
  } else if (response.status != 200) {
8896
- const message = await responseErrorMessage(response);
8897
- throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
8933
+ throw await computeApiError(response, "fetching compute sessions");
8898
8934
  } else {
8899
8935
  const response_content = await responseJson(response);
8900
8936
  session = response_content;
8901
8937
  }
8938
+ if (this.options.accountId && session.account_uuid !== this.options.accountId) {
8939
+ throw new ComputeAccountMismatchError(sessionUuid, session.account_uuid, this.options.accountId);
8940
+ }
8902
8941
  return session;
8903
8942
  }
8904
8943
  async sessionAuthorizationHeader(session) {
@@ -9283,7 +9322,6 @@ var VideoMode = /* @__PURE__ */ ((VideoMode2) => {
9283
9322
  var PopComponentType = /* @__PURE__ */ ((PopComponentType2) => {
9284
9323
  PopComponentType2["FORWARD"] = "forward";
9285
9324
  PopComponentType2["INFERENCE"] = "inference";
9286
- PopComponentType2["TRACING"] = "tracing";
9287
9325
  PopComponentType2["TRACKING"] = "tracking";
9288
9326
  PopComponentType2["CONTOUR_FINDER"] = "contour_finder";
9289
9327
  PopComponentType2["COMPONENT_FINDER"] = "component_finder";
@@ -9996,7 +10034,10 @@ var LoadFromJob = class extends AbstractJob {
9996
10034
  roi: this._params.roi,
9997
10035
  fps: this._params.fps,
9998
10036
  camera: this._params.camera,
9999
- version: this._version
10037
+ version: this._version,
10038
+ // undefined is dropped by JSON.stringify, so an unset option leaves
10039
+ // the worker's own default to decide rather than pinning it here.
10040
+ rtspForceNonCompliantUrl: this._params.rtspForceNonCompliantUrl
10000
10041
  };
10001
10042
  if (this._params.motionDetect) {
10002
10043
  Object.assign(body, this._params.motionDetect);
@@ -10750,6 +10791,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10750
10791
  this._popName = null;
10751
10792
  this._sessionAccessToken = null;
10752
10793
  this._sessionAccessTokenValidUntil = null;
10794
+ this._accountId = void 0;
10753
10795
  this._pipeline = null;
10754
10796
  this._pipelineCreatePromise = null;
10755
10797
  }
@@ -10799,6 +10841,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10799
10841
  accessToken: session.accessToken,
10800
10842
  validUntil: session.validUntil,
10801
10843
  popId: this.options().popId,
10844
+ accountId: this._accountId ?? this.options().accountId,
10802
10845
  baseUrl: this._baseUrl,
10803
10846
  pipelineId: this._pipelineId || void 0,
10804
10847
  authenticationHeaders: () => this._authenticationHeaders(session)
@@ -11354,6 +11397,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
11354
11397
  authorizationHeader: () => this.computeAuthorizationHeader(),
11355
11398
  sessionUuid: this.options().sessionUuid,
11356
11399
  sessionName: this.options().sessionName,
11400
+ accountId: this.options().accountId,
11357
11401
  pipelineImage: this.options().pipelineImage,
11358
11402
  pipelineVersion: this.options().pipelineVersion,
11359
11403
  pop: this.options().pop,
@@ -11368,6 +11412,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
11368
11412
  this._sessionAccessToken = resolved.accessToken;
11369
11413
  this._sessionAccessTokenValidUntil = resolved.accessTokenValidUntil;
11370
11414
  this._baseUrl = resolved.session.session_endpoint;
11415
+ this._accountId = resolved.session.account_uuid || void 0;
11371
11416
  this._pipeline = null;
11372
11417
  this._pipelineId = resolved.pipelineId;
11373
11418
  if (this.options().pop) {
@@ -12991,7 +13036,7 @@ var PointCloud = class {
12991
13036
  return placed;
12992
13037
  }
12993
13038
  /**
12994
- * Per axis (min, max) in metres over the placed points, or undefined if none were.
13039
+ * Per axis (min, max) in meters over the placed points, or undefined if none were.
12995
13040
  *
12996
13041
  * The counterpart to DepthMap's finiteMin/finiteMax, which are one axis
12997
13042
  * because a depth map has one value per pixel.
@@ -13170,6 +13215,19 @@ var readEnv = (env) => {
13170
13215
  }
13171
13216
  return void 0;
13172
13217
  };
13218
+ var warnedAccountIdEnv = false;
13219
+ var readAccountUuidEnv = () => {
13220
+ const accountUuid = readEnv("EYEPOP_ACCOUNT_UUID");
13221
+ if (accountUuid !== void 0) {
13222
+ return accountUuid;
13223
+ }
13224
+ const accountId = readEnv("EYEPOP_ACCOUNT_ID");
13225
+ if (accountId !== void 0 && !warnedAccountIdEnv) {
13226
+ warnedAccountIdEnv = true;
13227
+ console.warn("EYEPOP_ACCOUNT_ID is deprecated, use EYEPOP_ACCOUNT_UUID instead");
13228
+ }
13229
+ return accountId;
13230
+ };
13173
13231
  var stringToBooleanSafe = (str) => {
13174
13232
  if (typeof str == "undefined") {
13175
13233
  return false;
@@ -13184,7 +13242,8 @@ var EyePop;
13184
13242
  apiKey: envApiKey
13185
13243
  } : void 0;
13186
13244
  EyePop2.endpoint = workerEndpoint;
13187
- function workerEndpoint(opts = {}) {
13245
+ function workerEndpoint(options = {}) {
13246
+ const opts = { ...options };
13188
13247
  if (opts.pop !== void 0) {
13189
13248
  validatePop(opts.pop);
13190
13249
  }
@@ -13208,6 +13267,9 @@ var EyePop;
13208
13267
  if (opts.sessionName === void 0) {
13209
13268
  opts.sessionName = readEnv("EYEPOP_SESSION_NAME");
13210
13269
  }
13270
+ if (opts.accountId === void 0) {
13271
+ opts.accountId = readAccountUuidEnv();
13272
+ }
13211
13273
  if (opts.pipelineImage === void 0) {
13212
13274
  opts.pipelineImage = readEnv("EYEPOP_PIPELINE_IMAGE");
13213
13275
  }
@@ -13230,6 +13292,9 @@ var EyePop;
13230
13292
  if (auth.session.popId) {
13231
13293
  opts.popId = auth.session.popId;
13232
13294
  }
13295
+ if (auth.session.accountId) {
13296
+ opts.accountId = auth.session.accountId;
13297
+ }
13233
13298
  }
13234
13299
  }
13235
13300
  }
@@ -13243,7 +13308,7 @@ var EyePop;
13243
13308
  throw new Error("apiKey/accessToken/session/oAuth2 option or EYEPOP_API_KEY environment variable is required");
13244
13309
  }
13245
13310
  if (opts.accountId === void 0) {
13246
- opts.accountId = readEnv("EYEPOP_ACCOUNT_ID");
13311
+ opts.accountId = readAccountUuidEnv();
13247
13312
  }
13248
13313
  if (auth.session !== void 0) {
13249
13314
  if (auth.session !== void 0) {
@@ -13313,6 +13378,8 @@ export {
13313
13378
  AutoAnnotateStatus,
13314
13379
  AutoAnnotateTask,
13315
13380
  ChangeType,
13381
+ ComputeAccountMismatchError,
13382
+ ComputeApiError,
13316
13383
  ContourType,
13317
13384
  DEFAULT_PREDICTION_VERSION,
13318
13385
  DataApiType,