@eyepop.ai/eyepop 0.18.0 → 0.18.1
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 +1 -0
- package/dist/eyepop.index.d.ts +1 -0
- package/dist/eyepop.index.js +63 -31
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +63 -31
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.d.mts
CHANGED
package/dist/eyepop.index.d.ts
CHANGED
package/dist/eyepop.index.js
CHANGED
|
@@ -9859,22 +9859,26 @@ var Endpoint = class {
|
|
|
9859
9859
|
}
|
|
9860
9860
|
}
|
|
9861
9861
|
async changePopComp(popComp) {
|
|
9862
|
-
|
|
9862
|
+
const client = this._client;
|
|
9863
|
+
const baseUrl = this._baseUrl;
|
|
9864
|
+
if (!baseUrl || !client) {
|
|
9863
9865
|
return Promise.reject("endpoint not connected, use connect() before changePopComp()");
|
|
9864
9866
|
}
|
|
9865
9867
|
const patch_url = `${this._baseUrl}/pipelines/${this._pipelineId}/inferencePipeline`;
|
|
9866
|
-
const headers = {
|
|
9867
|
-
"Authorization": await this.authorizationHeader(),
|
|
9868
|
-
"Content-Type": "application/json"
|
|
9869
|
-
};
|
|
9870
9868
|
const body = {
|
|
9871
9869
|
"pipeline": popComp
|
|
9872
9870
|
};
|
|
9873
9871
|
this._requestLogger.debug("before PATCH %s", patch_url);
|
|
9874
|
-
let response = await this.
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9872
|
+
let response = await this.fetchWithRetry(async () => {
|
|
9873
|
+
let headers = {
|
|
9874
|
+
"Authorization": await this.authorizationHeader(),
|
|
9875
|
+
"Content-Type": "application/json"
|
|
9876
|
+
};
|
|
9877
|
+
return client.fetch(patch_url, {
|
|
9878
|
+
method: "PATCH",
|
|
9879
|
+
body: JSON.stringify(body),
|
|
9880
|
+
headers
|
|
9881
|
+
});
|
|
9878
9882
|
});
|
|
9879
9883
|
if (response.status != 204) {
|
|
9880
9884
|
const message = await response.text();
|
|
@@ -9923,19 +9927,22 @@ var Endpoint = class {
|
|
|
9923
9927
|
return Promise.reject("option secretKey or environment variable EYEPOP_SECRET_KEY is required");
|
|
9924
9928
|
}
|
|
9925
9929
|
this._client = await createHttpClient();
|
|
9930
|
+
const client = this._client;
|
|
9926
9931
|
let result = await this.reconnect();
|
|
9927
9932
|
if (this._baseUrl && this._options.stopJobs) {
|
|
9928
9933
|
const stop_url = `${this._baseUrl}/pipelines/${this._pipelineId}/source?mode=preempt&processing=sync`;
|
|
9929
9934
|
const body = { "sourceType": "NONE" };
|
|
9930
|
-
const headers = {
|
|
9931
|
-
"Authorization": await this.authorizationHeader(),
|
|
9932
|
-
"Content-Type": "application/json"
|
|
9933
|
-
};
|
|
9934
9935
|
this._requestLogger.debug("before PATCH %s", stop_url);
|
|
9935
|
-
let response = await this.
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9936
|
+
let response = await this.fetchWithRetry(async () => {
|
|
9937
|
+
const headers = {
|
|
9938
|
+
"Authorization": await this.authorizationHeader(),
|
|
9939
|
+
"Content-Type": "application/json"
|
|
9940
|
+
};
|
|
9941
|
+
return client.fetch(stop_url, {
|
|
9942
|
+
method: "PATCH",
|
|
9943
|
+
headers,
|
|
9944
|
+
body: JSON.stringify(body)
|
|
9945
|
+
});
|
|
9939
9946
|
});
|
|
9940
9947
|
if (response.status >= 300) {
|
|
9941
9948
|
const message = await response.text();
|
|
@@ -10016,25 +10023,19 @@ var Endpoint = class {
|
|
|
10016
10023
|
}
|
|
10017
10024
|
}
|
|
10018
10025
|
async startIngressWs() {
|
|
10019
|
-
|
|
10026
|
+
const client = this._client;
|
|
10027
|
+
if (this._ingressEventWs || !this._baseUrl || !client) {
|
|
10020
10028
|
return;
|
|
10021
10029
|
}
|
|
10022
10030
|
try {
|
|
10023
10031
|
const getTokenUrl = `${this._baseUrl}/liveIngress/events/token`;
|
|
10024
|
-
const headers = {
|
|
10025
|
-
"Authorization": await this.authorizationHeader()
|
|
10026
|
-
};
|
|
10027
10032
|
this._requestLogger.debug("before GET %s", getTokenUrl);
|
|
10028
|
-
let response = await this.
|
|
10029
|
-
|
|
10030
|
-
this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", getTokenUrl);
|
|
10031
|
-
this._token = null;
|
|
10032
|
-
const headers2 = {
|
|
10033
|
+
let response = await this.fetchWithRetry(async () => {
|
|
10034
|
+
const headers = {
|
|
10033
10035
|
"Authorization": await this.authorizationHeader()
|
|
10034
10036
|
};
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
}
|
|
10037
|
+
return client.fetch(getTokenUrl, { headers });
|
|
10038
|
+
});
|
|
10038
10039
|
if (response.status != 200) {
|
|
10039
10040
|
const message = await response.text();
|
|
10040
10041
|
return Promise.reject(`Unexpected status ${response.status}: ${message}`);
|
|
@@ -10180,6 +10181,39 @@ var Endpoint = class {
|
|
|
10180
10181
|
this._expire_token_time = null;
|
|
10181
10182
|
}
|
|
10182
10183
|
}
|
|
10184
|
+
async fetchWithRetry(fetcher, retries = 1) {
|
|
10185
|
+
while (true) {
|
|
10186
|
+
try {
|
|
10187
|
+
const response = await fetcher();
|
|
10188
|
+
if (response.status == 401) {
|
|
10189
|
+
this._token = null;
|
|
10190
|
+
this._expire_token_time = null;
|
|
10191
|
+
if (retries--) {
|
|
10192
|
+
this._requestLogger.info("received 401 response, attempt to reauthorize and retry");
|
|
10193
|
+
} else {
|
|
10194
|
+
return Promise.reject(`response ${response.status}: ${response.statusText}`);
|
|
10195
|
+
}
|
|
10196
|
+
} else if (response.status == 404) {
|
|
10197
|
+
this._pipelineId = null;
|
|
10198
|
+
this._baseUrl = null;
|
|
10199
|
+
if (retries--) {
|
|
10200
|
+
this._requestLogger.info("received 404 response, attempt to restart pop and retry");
|
|
10201
|
+
} else {
|
|
10202
|
+
return Promise.reject(`response ${response.status}: ${response.statusText}`);
|
|
10203
|
+
}
|
|
10204
|
+
} else {
|
|
10205
|
+
return response;
|
|
10206
|
+
}
|
|
10207
|
+
} catch (error) {
|
|
10208
|
+
this._pipelineId = null;
|
|
10209
|
+
this._baseUrl = null;
|
|
10210
|
+
if (retries--) {
|
|
10211
|
+
this._requestLogger.info("unknown, attempt to restart pop (as if we received 404)", error);
|
|
10212
|
+
return Promise.reject(error);
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
}
|
|
10216
|
+
}
|
|
10183
10217
|
async reconnect() {
|
|
10184
10218
|
if (!this._client) {
|
|
10185
10219
|
return Promise.reject("endpoint not initialized");
|
|
@@ -10205,7 +10239,6 @@ var Endpoint = class {
|
|
|
10205
10239
|
this.updateState("FetchConfig" /* FetchConfig */);
|
|
10206
10240
|
response = await this._client.fetch(config_url, {
|
|
10207
10241
|
headers: headers2
|
|
10208
|
-
// @ts-ignore
|
|
10209
10242
|
});
|
|
10210
10243
|
}
|
|
10211
10244
|
if (response.status != 200) {
|
|
@@ -10223,7 +10256,6 @@ var Endpoint = class {
|
|
|
10223
10256
|
this.updateState("StartingPop" /* StartingPop */);
|
|
10224
10257
|
response = await this._client.fetch(auto_start_config_url, {
|
|
10225
10258
|
headers: headers2
|
|
10226
|
-
// @ts-ignore
|
|
10227
10259
|
});
|
|
10228
10260
|
if (response.status != 200) {
|
|
10229
10261
|
this.updateState("Error" /* Error */);
|