@eyepop.ai/eyepop 3.20.1 → 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.
- package/dist/eyepop.index.d.mts +50 -9
- package/dist/eyepop.index.d.ts +50 -9
- package/dist/eyepop.index.js +82 -12
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +80 -12
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
8931
|
+
throw new ComputeApiError(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`, response.status);
|
|
8895
8932
|
} else if (response.status != 200) {
|
|
8896
|
-
|
|
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) {
|
|
@@ -9995,7 +10034,10 @@ var LoadFromJob = class extends AbstractJob {
|
|
|
9995
10034
|
roi: this._params.roi,
|
|
9996
10035
|
fps: this._params.fps,
|
|
9997
10036
|
camera: this._params.camera,
|
|
9998
|
-
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
|
|
9999
10041
|
};
|
|
10000
10042
|
if (this._params.motionDetect) {
|
|
10001
10043
|
Object.assign(body, this._params.motionDetect);
|
|
@@ -10749,6 +10791,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10749
10791
|
this._popName = null;
|
|
10750
10792
|
this._sessionAccessToken = null;
|
|
10751
10793
|
this._sessionAccessTokenValidUntil = null;
|
|
10794
|
+
this._accountId = void 0;
|
|
10752
10795
|
this._pipeline = null;
|
|
10753
10796
|
this._pipelineCreatePromise = null;
|
|
10754
10797
|
}
|
|
@@ -10798,6 +10841,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10798
10841
|
accessToken: session.accessToken,
|
|
10799
10842
|
validUntil: session.validUntil,
|
|
10800
10843
|
popId: this.options().popId,
|
|
10844
|
+
accountId: this._accountId ?? this.options().accountId,
|
|
10801
10845
|
baseUrl: this._baseUrl,
|
|
10802
10846
|
pipelineId: this._pipelineId || void 0,
|
|
10803
10847
|
authenticationHeaders: () => this._authenticationHeaders(session)
|
|
@@ -11353,6 +11397,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
11353
11397
|
authorizationHeader: () => this.computeAuthorizationHeader(),
|
|
11354
11398
|
sessionUuid: this.options().sessionUuid,
|
|
11355
11399
|
sessionName: this.options().sessionName,
|
|
11400
|
+
accountId: this.options().accountId,
|
|
11356
11401
|
pipelineImage: this.options().pipelineImage,
|
|
11357
11402
|
pipelineVersion: this.options().pipelineVersion,
|
|
11358
11403
|
pop: this.options().pop,
|
|
@@ -11367,6 +11412,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
11367
11412
|
this._sessionAccessToken = resolved.accessToken;
|
|
11368
11413
|
this._sessionAccessTokenValidUntil = resolved.accessTokenValidUntil;
|
|
11369
11414
|
this._baseUrl = resolved.session.session_endpoint;
|
|
11415
|
+
this._accountId = resolved.session.account_uuid || void 0;
|
|
11370
11416
|
this._pipeline = null;
|
|
11371
11417
|
this._pipelineId = resolved.pipelineId;
|
|
11372
11418
|
if (this.options().pop) {
|
|
@@ -12990,7 +13036,7 @@ var PointCloud = class {
|
|
|
12990
13036
|
return placed;
|
|
12991
13037
|
}
|
|
12992
13038
|
/**
|
|
12993
|
-
* Per axis (min, max) in
|
|
13039
|
+
* Per axis (min, max) in meters over the placed points, or undefined if none were.
|
|
12994
13040
|
*
|
|
12995
13041
|
* The counterpart to DepthMap's finiteMin/finiteMax, which are one axis
|
|
12996
13042
|
* because a depth map has one value per pixel.
|
|
@@ -13169,6 +13215,19 @@ var readEnv = (env) => {
|
|
|
13169
13215
|
}
|
|
13170
13216
|
return void 0;
|
|
13171
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
|
+
};
|
|
13172
13231
|
var stringToBooleanSafe = (str) => {
|
|
13173
13232
|
if (typeof str == "undefined") {
|
|
13174
13233
|
return false;
|
|
@@ -13183,7 +13242,8 @@ var EyePop;
|
|
|
13183
13242
|
apiKey: envApiKey
|
|
13184
13243
|
} : void 0;
|
|
13185
13244
|
EyePop2.endpoint = workerEndpoint;
|
|
13186
|
-
function workerEndpoint(
|
|
13245
|
+
function workerEndpoint(options = {}) {
|
|
13246
|
+
const opts = { ...options };
|
|
13187
13247
|
if (opts.pop !== void 0) {
|
|
13188
13248
|
validatePop(opts.pop);
|
|
13189
13249
|
}
|
|
@@ -13207,6 +13267,9 @@ var EyePop;
|
|
|
13207
13267
|
if (opts.sessionName === void 0) {
|
|
13208
13268
|
opts.sessionName = readEnv("EYEPOP_SESSION_NAME");
|
|
13209
13269
|
}
|
|
13270
|
+
if (opts.accountId === void 0) {
|
|
13271
|
+
opts.accountId = readAccountUuidEnv();
|
|
13272
|
+
}
|
|
13210
13273
|
if (opts.pipelineImage === void 0) {
|
|
13211
13274
|
opts.pipelineImage = readEnv("EYEPOP_PIPELINE_IMAGE");
|
|
13212
13275
|
}
|
|
@@ -13229,6 +13292,9 @@ var EyePop;
|
|
|
13229
13292
|
if (auth.session.popId) {
|
|
13230
13293
|
opts.popId = auth.session.popId;
|
|
13231
13294
|
}
|
|
13295
|
+
if (auth.session.accountId) {
|
|
13296
|
+
opts.accountId = auth.session.accountId;
|
|
13297
|
+
}
|
|
13232
13298
|
}
|
|
13233
13299
|
}
|
|
13234
13300
|
}
|
|
@@ -13242,7 +13308,7 @@ var EyePop;
|
|
|
13242
13308
|
throw new Error("apiKey/accessToken/session/oAuth2 option or EYEPOP_API_KEY environment variable is required");
|
|
13243
13309
|
}
|
|
13244
13310
|
if (opts.accountId === void 0) {
|
|
13245
|
-
opts.accountId =
|
|
13311
|
+
opts.accountId = readAccountUuidEnv();
|
|
13246
13312
|
}
|
|
13247
13313
|
if (auth.session !== void 0) {
|
|
13248
13314
|
if (auth.session !== void 0) {
|
|
@@ -13312,6 +13378,8 @@ export {
|
|
|
13312
13378
|
AutoAnnotateStatus,
|
|
13313
13379
|
AutoAnnotateTask,
|
|
13314
13380
|
ChangeType,
|
|
13381
|
+
ComputeAccountMismatchError,
|
|
13382
|
+
ComputeApiError,
|
|
13315
13383
|
ContourType,
|
|
13316
13384
|
DEFAULT_PREDICTION_VERSION,
|
|
13317
13385
|
DataApiType,
|