@eyepop.ai/eyepop 0.17.0 → 0.18.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 +8 -1
- package/dist/eyepop.index.d.ts +8 -1
- package/dist/eyepop.index.js +119 -3
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +119 -3
- 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
|
@@ -152,12 +152,15 @@ interface OAuth2Auth {
|
|
|
152
152
|
oAuth2: true | Auth0Options;
|
|
153
153
|
}
|
|
154
154
|
type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
|
|
155
|
+
declare enum TransientPopId {
|
|
156
|
+
Transient = "transient"
|
|
157
|
+
}
|
|
155
158
|
interface Options {
|
|
156
159
|
auth?: Authentication | undefined;
|
|
157
160
|
/**
|
|
158
161
|
* Defaults to process.env['EYEPOP_POP_ID'].
|
|
159
162
|
*/
|
|
160
|
-
popId?: string | undefined;
|
|
163
|
+
popId?: string | TransientPopId | undefined;
|
|
161
164
|
/**
|
|
162
165
|
* Override the default base URL for the API, e.g., "https://api.eyepop.ai/"
|
|
163
166
|
*
|
|
@@ -177,6 +180,7 @@ declare class Endpoint {
|
|
|
177
180
|
private _baseUrl;
|
|
178
181
|
private _pipelineId;
|
|
179
182
|
private _popName;
|
|
183
|
+
private _pipeline;
|
|
180
184
|
private _client;
|
|
181
185
|
private _limit;
|
|
182
186
|
private _state;
|
|
@@ -190,6 +194,8 @@ declare class Endpoint {
|
|
|
190
194
|
state(): EndpointState;
|
|
191
195
|
pendingJobs(): number;
|
|
192
196
|
popName(): string | null;
|
|
197
|
+
popComp(): string | null;
|
|
198
|
+
changePopComp(popComp: string): Promise<void>;
|
|
193
199
|
popId(): string | null;
|
|
194
200
|
onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
|
|
195
201
|
onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
|
|
@@ -211,6 +217,7 @@ declare class Endpoint {
|
|
|
211
217
|
private reconnect;
|
|
212
218
|
private authorizationHeader;
|
|
213
219
|
private currentAccessToken;
|
|
220
|
+
private startPopLessPipeline;
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
declare namespace EyePop {
|
package/dist/eyepop.index.d.ts
CHANGED
|
@@ -152,12 +152,15 @@ interface OAuth2Auth {
|
|
|
152
152
|
oAuth2: true | Auth0Options;
|
|
153
153
|
}
|
|
154
154
|
type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
|
|
155
|
+
declare enum TransientPopId {
|
|
156
|
+
Transient = "transient"
|
|
157
|
+
}
|
|
155
158
|
interface Options {
|
|
156
159
|
auth?: Authentication | undefined;
|
|
157
160
|
/**
|
|
158
161
|
* Defaults to process.env['EYEPOP_POP_ID'].
|
|
159
162
|
*/
|
|
160
|
-
popId?: string | undefined;
|
|
163
|
+
popId?: string | TransientPopId | undefined;
|
|
161
164
|
/**
|
|
162
165
|
* Override the default base URL for the API, e.g., "https://api.eyepop.ai/"
|
|
163
166
|
*
|
|
@@ -177,6 +180,7 @@ declare class Endpoint {
|
|
|
177
180
|
private _baseUrl;
|
|
178
181
|
private _pipelineId;
|
|
179
182
|
private _popName;
|
|
183
|
+
private _pipeline;
|
|
180
184
|
private _client;
|
|
181
185
|
private _limit;
|
|
182
186
|
private _state;
|
|
@@ -190,6 +194,8 @@ declare class Endpoint {
|
|
|
190
194
|
state(): EndpointState;
|
|
191
195
|
pendingJobs(): number;
|
|
192
196
|
popName(): string | null;
|
|
197
|
+
popComp(): string | null;
|
|
198
|
+
changePopComp(popComp: string): Promise<void>;
|
|
193
199
|
popId(): string | null;
|
|
194
200
|
onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
|
|
195
201
|
onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
|
|
@@ -211,6 +217,7 @@ declare class Endpoint {
|
|
|
211
217
|
private reconnect;
|
|
212
218
|
private authorizationHeader;
|
|
213
219
|
private currentAccessToken;
|
|
220
|
+
private startPopLessPipeline;
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
declare namespace EyePop {
|
package/dist/eyepop.index.js
CHANGED
|
@@ -9821,6 +9821,7 @@ var Endpoint = class {
|
|
|
9821
9821
|
this._expire_token_time = null;
|
|
9822
9822
|
this._client = null;
|
|
9823
9823
|
this._state = "Idle" /* Idle */;
|
|
9824
|
+
this._pipeline = null;
|
|
9824
9825
|
this._stateChangeHandler = null;
|
|
9825
9826
|
this._ingressEventHandler = null;
|
|
9826
9827
|
this._ingressEventWs = null;
|
|
@@ -9850,6 +9851,40 @@ var Endpoint = class {
|
|
|
9850
9851
|
popName() {
|
|
9851
9852
|
return this._popName;
|
|
9852
9853
|
}
|
|
9854
|
+
popComp() {
|
|
9855
|
+
if (this._pipeline) {
|
|
9856
|
+
return this._pipeline.inferPipeline;
|
|
9857
|
+
} else {
|
|
9858
|
+
return null;
|
|
9859
|
+
}
|
|
9860
|
+
}
|
|
9861
|
+
async changePopComp(popComp) {
|
|
9862
|
+
if (!this._baseUrl || !this._client) {
|
|
9863
|
+
return Promise.reject("endpoint not connected, use connect() before changePopComp()");
|
|
9864
|
+
}
|
|
9865
|
+
const patch_url = `${this._baseUrl}/pipelines/${this._pipelineId}/inferencePipeline`;
|
|
9866
|
+
const headers = {
|
|
9867
|
+
"Authorization": await this.authorizationHeader(),
|
|
9868
|
+
"Content-Type": "application/json"
|
|
9869
|
+
};
|
|
9870
|
+
const body = {
|
|
9871
|
+
"pipeline": popComp
|
|
9872
|
+
};
|
|
9873
|
+
this._requestLogger.debug("before PATCH %s", patch_url);
|
|
9874
|
+
let response = await this._client.fetch(patch_url, {
|
|
9875
|
+
method: "PATCH",
|
|
9876
|
+
body: JSON.stringify(body),
|
|
9877
|
+
headers
|
|
9878
|
+
});
|
|
9879
|
+
if (response.status != 204) {
|
|
9880
|
+
const message = await response.text();
|
|
9881
|
+
return Promise.reject(`Unexpected status ${response.status}: ${message}`);
|
|
9882
|
+
}
|
|
9883
|
+
this._requestLogger.debug("after PATCH %s", patch_url);
|
|
9884
|
+
if (this._pipeline) {
|
|
9885
|
+
this._pipeline.inferPipeline = popComp;
|
|
9886
|
+
}
|
|
9887
|
+
}
|
|
9853
9888
|
popId() {
|
|
9854
9889
|
return this._options.popId || null;
|
|
9855
9890
|
}
|
|
@@ -10149,7 +10184,12 @@ var Endpoint = class {
|
|
|
10149
10184
|
if (!this._client) {
|
|
10150
10185
|
return Promise.reject("endpoint not initialized");
|
|
10151
10186
|
}
|
|
10152
|
-
|
|
10187
|
+
let config_url;
|
|
10188
|
+
if (this._options.popId == "transient" /* Transient */) {
|
|
10189
|
+
config_url = `${this.eyepopUrl()}/workers/config`;
|
|
10190
|
+
} else {
|
|
10191
|
+
config_url = `${this.eyepopUrl()}/pops/${this._options.popId}/config?auto_start=false`;
|
|
10192
|
+
}
|
|
10153
10193
|
const headers = {
|
|
10154
10194
|
"Authorization": await this.authorizationHeader()
|
|
10155
10195
|
};
|
|
@@ -10194,13 +10234,35 @@ var Endpoint = class {
|
|
|
10194
10234
|
}
|
|
10195
10235
|
const baseUrl = new URL(config.base_url, this.eyepopUrl());
|
|
10196
10236
|
this._baseUrl = baseUrl.toString();
|
|
10197
|
-
this.
|
|
10198
|
-
|
|
10237
|
+
if (this._options.popId == "transient" /* Transient */) {
|
|
10238
|
+
this._pipelineId = await this.startPopLessPipeline();
|
|
10239
|
+
this._popName = this._options.popId;
|
|
10240
|
+
} else {
|
|
10241
|
+
this._pipelineId = config.pipeline_id;
|
|
10242
|
+
this._popName = config.name;
|
|
10243
|
+
}
|
|
10199
10244
|
this._requestLogger.debug("after GET %s: %s / %s", config_url, this._baseUrl, this._pipelineId);
|
|
10200
10245
|
if (!this._pipelineId || !this._baseUrl) {
|
|
10201
10246
|
return Promise.reject(`Pop not started`);
|
|
10202
10247
|
}
|
|
10203
10248
|
this._baseUrl = this._baseUrl.replace(/\/+$/, "");
|
|
10249
|
+
if (this._baseUrl) {
|
|
10250
|
+
const get_url = `${this._baseUrl}/pipelines/${this._pipelineId}`;
|
|
10251
|
+
const headers2 = {
|
|
10252
|
+
"Authorization": await this.authorizationHeader()
|
|
10253
|
+
};
|
|
10254
|
+
this._requestLogger.debug("before GET %s", get_url);
|
|
10255
|
+
let response2 = await this._client.fetch(get_url, {
|
|
10256
|
+
method: "GET",
|
|
10257
|
+
headers: headers2
|
|
10258
|
+
});
|
|
10259
|
+
if (response2.status > 200) {
|
|
10260
|
+
const message = await response2.text();
|
|
10261
|
+
return Promise.reject(`Unexpected status ${response2.status}: ${message}`);
|
|
10262
|
+
}
|
|
10263
|
+
this._requestLogger.debug("after GET %s", get_url);
|
|
10264
|
+
this._pipeline = await response2.json();
|
|
10265
|
+
}
|
|
10204
10266
|
this.updateState();
|
|
10205
10267
|
return Promise.resolve(this);
|
|
10206
10268
|
}
|
|
@@ -10255,6 +10317,60 @@ var Endpoint = class {
|
|
|
10255
10317
|
this._logger.debug("using access token, valid for at least %d seconds", this._expire_token_time - now);
|
|
10256
10318
|
return this._token;
|
|
10257
10319
|
}
|
|
10320
|
+
async startPopLessPipeline() {
|
|
10321
|
+
if (this._client == null || this._baseUrl == null) {
|
|
10322
|
+
return Promise.reject("endpoint not initialized");
|
|
10323
|
+
}
|
|
10324
|
+
this.updateState("StartingPop" /* StartingPop */);
|
|
10325
|
+
let pipeline;
|
|
10326
|
+
if (this._pipeline) {
|
|
10327
|
+
pipeline = this._pipeline.inferPipeline;
|
|
10328
|
+
} else {
|
|
10329
|
+
pipeline = "identity";
|
|
10330
|
+
}
|
|
10331
|
+
const body = {
|
|
10332
|
+
"inferPipelineDef": {
|
|
10333
|
+
"pipeline": pipeline
|
|
10334
|
+
},
|
|
10335
|
+
"source": {
|
|
10336
|
+
"sourceType": "NONE"
|
|
10337
|
+
},
|
|
10338
|
+
"idleTimeoutSeconds": 30,
|
|
10339
|
+
"logging": ["out_meta"],
|
|
10340
|
+
"videoOutput": "no_output"
|
|
10341
|
+
};
|
|
10342
|
+
const post_url = `${this._baseUrl.replace(/\/+$/, "")}/pipelines`;
|
|
10343
|
+
let headers = {
|
|
10344
|
+
"Content-Type": "application/json",
|
|
10345
|
+
"Authorization": await this.authorizationHeader()
|
|
10346
|
+
};
|
|
10347
|
+
this._requestLogger.debug("before POST %s", post_url);
|
|
10348
|
+
let response = await this._client.fetch(post_url, {
|
|
10349
|
+
method: "POST",
|
|
10350
|
+
headers,
|
|
10351
|
+
body: JSON.stringify(body)
|
|
10352
|
+
});
|
|
10353
|
+
if (response.status == 401) {
|
|
10354
|
+
this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", post_url);
|
|
10355
|
+
this._token = null;
|
|
10356
|
+
headers = {
|
|
10357
|
+
"Content-Type": "application/json",
|
|
10358
|
+
"Authorization": await this.authorizationHeader()
|
|
10359
|
+
};
|
|
10360
|
+
response = await this._client.fetch(post_url, {
|
|
10361
|
+
method: "POST",
|
|
10362
|
+
headers,
|
|
10363
|
+
body: JSON.stringify(body)
|
|
10364
|
+
});
|
|
10365
|
+
}
|
|
10366
|
+
if (response.status != 200) {
|
|
10367
|
+
const message = await response.text();
|
|
10368
|
+
return Promise.reject(`Unexpected status ${response.status}: ${message}`);
|
|
10369
|
+
}
|
|
10370
|
+
this._requestLogger.debug("after POST %s", post_url);
|
|
10371
|
+
const pipelineId = (await response.json())["id"];
|
|
10372
|
+
return pipelineId;
|
|
10373
|
+
}
|
|
10258
10374
|
};
|
|
10259
10375
|
|
|
10260
10376
|
// index.ts
|