@eyepop.ai/eyepop 0.16.3 → 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.
@@ -44,6 +44,17 @@ interface UrlSource {
44
44
  readonly url: string;
45
45
  }
46
46
  type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
47
+ interface Box {
48
+ readonly topLeft: Point2d;
49
+ readonly bottomRight: Point2d;
50
+ }
51
+ interface Roi {
52
+ readonly points: Point2d[] | undefined;
53
+ readonly boxes: Box[] | undefined;
54
+ }
55
+ interface SourceParams {
56
+ readonly roi: Roi | undefined;
57
+ }
47
58
  interface StreamTime {
48
59
  timestamp: number;
49
60
  seconds: number;
@@ -65,6 +76,16 @@ interface PredictedClass {
65
76
  classLabel: string;
66
77
  category: string;
67
78
  }
79
+ interface Contour {
80
+ points: Array<Point2d>;
81
+ cutouts: Array<Array<Point2d>>;
82
+ }
83
+ interface Mask {
84
+ bitmap: string;
85
+ width: number;
86
+ height: number;
87
+ stride: number;
88
+ }
68
89
  interface PredictedObject extends PredictedClass {
69
90
  traceId: number | undefined;
70
91
  x: number;
@@ -72,12 +93,14 @@ interface PredictedObject extends PredictedClass {
72
93
  width: number;
73
94
  height: number;
74
95
  orientation: number;
75
- outline: Array<Point2d>;
76
- objects: Array<PredictedObject>;
77
- classes: Array<PredictedClass>;
78
- labels: Array<string>;
79
- meshs: Array<PredictedMesh>;
80
- keyPoints: Array<PredictedKeyPoints>;
96
+ outline: Array<Point2d> | undefined;
97
+ contours: Array<Contour> | undefined;
98
+ mask: Mask | undefined;
99
+ objects: Array<PredictedObject> | undefined;
100
+ classes: Array<PredictedClass> | undefined;
101
+ labels: Array<string> | undefined;
102
+ meshs: Array<PredictedMesh> | undefined;
103
+ keyPoints: Array<PredictedKeyPoints> | undefined;
81
104
  }
82
105
  interface Point2d {
83
106
  x: number;
@@ -129,12 +152,15 @@ interface OAuth2Auth {
129
152
  oAuth2: true | Auth0Options;
130
153
  }
131
154
  type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
155
+ declare enum TransientPopId {
156
+ Transient = "transient"
157
+ }
132
158
  interface Options {
133
159
  auth?: Authentication | undefined;
134
160
  /**
135
161
  * Defaults to process.env['EYEPOP_POP_ID'].
136
162
  */
137
- popId?: string | undefined;
163
+ popId?: string | TransientPopId | undefined;
138
164
  /**
139
165
  * Override the default base URL for the API, e.g., "https://api.eyepop.ai/"
140
166
  *
@@ -154,6 +180,7 @@ declare class Endpoint {
154
180
  private _baseUrl;
155
181
  private _pipelineId;
156
182
  private _popName;
183
+ private _pipeline;
157
184
  private _client;
158
185
  private _limit;
159
186
  private _state;
@@ -167,6 +194,8 @@ declare class Endpoint {
167
194
  state(): EndpointState;
168
195
  pendingJobs(): number;
169
196
  popName(): string | null;
197
+ popComp(): string | null;
198
+ changePopComp(popComp: string): Promise<void>;
170
199
  popId(): string | null;
171
200
  onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
172
201
  onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
@@ -175,7 +204,7 @@ declare class Endpoint {
175
204
  session(): Promise<SessionPlus>;
176
205
  liveIngress(stream: MediaStream): Promise<LiveMedia>;
177
206
  liveEgress(ingressId: string): Promise<LiveMedia>;
178
- process(source: Source): Promise<ResultStream>;
207
+ process(source: Source, params?: SourceParams | undefined): Promise<ResultStream>;
179
208
  private startIngressWs;
180
209
  private uploadFile;
181
210
  private uploadStream;
@@ -188,10 +217,11 @@ declare class Endpoint {
188
217
  private reconnect;
189
218
  private authorizationHeader;
190
219
  private currentAccessToken;
220
+ private startPopLessPipeline;
191
221
  }
192
222
 
193
223
  declare namespace EyePop {
194
224
  function endpoint(opts?: Options): Endpoint;
195
225
  }
196
226
 
197
- export { EndpointState, EyePop, type FileSource, type IngressEvent, type LiveMedia, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type StreamTime, type UrlSource, EyePop as default };
227
+ export { type Contour, EndpointState, EyePop, type FileSource, type IngressEvent, type LiveMedia, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type StreamTime, type UrlSource, EyePop as default };
@@ -44,6 +44,17 @@ interface UrlSource {
44
44
  readonly url: string;
45
45
  }
46
46
  type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
47
+ interface Box {
48
+ readonly topLeft: Point2d;
49
+ readonly bottomRight: Point2d;
50
+ }
51
+ interface Roi {
52
+ readonly points: Point2d[] | undefined;
53
+ readonly boxes: Box[] | undefined;
54
+ }
55
+ interface SourceParams {
56
+ readonly roi: Roi | undefined;
57
+ }
47
58
  interface StreamTime {
48
59
  timestamp: number;
49
60
  seconds: number;
@@ -65,6 +76,16 @@ interface PredictedClass {
65
76
  classLabel: string;
66
77
  category: string;
67
78
  }
79
+ interface Contour {
80
+ points: Array<Point2d>;
81
+ cutouts: Array<Array<Point2d>>;
82
+ }
83
+ interface Mask {
84
+ bitmap: string;
85
+ width: number;
86
+ height: number;
87
+ stride: number;
88
+ }
68
89
  interface PredictedObject extends PredictedClass {
69
90
  traceId: number | undefined;
70
91
  x: number;
@@ -72,12 +93,14 @@ interface PredictedObject extends PredictedClass {
72
93
  width: number;
73
94
  height: number;
74
95
  orientation: number;
75
- outline: Array<Point2d>;
76
- objects: Array<PredictedObject>;
77
- classes: Array<PredictedClass>;
78
- labels: Array<string>;
79
- meshs: Array<PredictedMesh>;
80
- keyPoints: Array<PredictedKeyPoints>;
96
+ outline: Array<Point2d> | undefined;
97
+ contours: Array<Contour> | undefined;
98
+ mask: Mask | undefined;
99
+ objects: Array<PredictedObject> | undefined;
100
+ classes: Array<PredictedClass> | undefined;
101
+ labels: Array<string> | undefined;
102
+ meshs: Array<PredictedMesh> | undefined;
103
+ keyPoints: Array<PredictedKeyPoints> | undefined;
81
104
  }
82
105
  interface Point2d {
83
106
  x: number;
@@ -129,12 +152,15 @@ interface OAuth2Auth {
129
152
  oAuth2: true | Auth0Options;
130
153
  }
131
154
  type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
155
+ declare enum TransientPopId {
156
+ Transient = "transient"
157
+ }
132
158
  interface Options {
133
159
  auth?: Authentication | undefined;
134
160
  /**
135
161
  * Defaults to process.env['EYEPOP_POP_ID'].
136
162
  */
137
- popId?: string | undefined;
163
+ popId?: string | TransientPopId | undefined;
138
164
  /**
139
165
  * Override the default base URL for the API, e.g., "https://api.eyepop.ai/"
140
166
  *
@@ -154,6 +180,7 @@ declare class Endpoint {
154
180
  private _baseUrl;
155
181
  private _pipelineId;
156
182
  private _popName;
183
+ private _pipeline;
157
184
  private _client;
158
185
  private _limit;
159
186
  private _state;
@@ -167,6 +194,8 @@ declare class Endpoint {
167
194
  state(): EndpointState;
168
195
  pendingJobs(): number;
169
196
  popName(): string | null;
197
+ popComp(): string | null;
198
+ changePopComp(popComp: string): Promise<void>;
170
199
  popId(): string | null;
171
200
  onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
172
201
  onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
@@ -175,7 +204,7 @@ declare class Endpoint {
175
204
  session(): Promise<SessionPlus>;
176
205
  liveIngress(stream: MediaStream): Promise<LiveMedia>;
177
206
  liveEgress(ingressId: string): Promise<LiveMedia>;
178
- process(source: Source): Promise<ResultStream>;
207
+ process(source: Source, params?: SourceParams | undefined): Promise<ResultStream>;
179
208
  private startIngressWs;
180
209
  private uploadFile;
181
210
  private uploadStream;
@@ -188,10 +217,11 @@ declare class Endpoint {
188
217
  private reconnect;
189
218
  private authorizationHeader;
190
219
  private currentAccessToken;
220
+ private startPopLessPipeline;
191
221
  }
192
222
 
193
223
  declare namespace EyePop {
194
224
  function endpoint(opts?: Options): Endpoint;
195
225
  }
196
226
 
197
- export { EndpointState, EyePop, type FileSource, type IngressEvent, type LiveMedia, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type StreamTime, type UrlSource, EyePop as default };
227
+ export { type Contour, EndpointState, EyePop, type FileSource, type IngressEvent, type LiveMedia, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type StreamTime, type UrlSource, EyePop as default };
@@ -8927,10 +8927,11 @@ function readableStreamAsyncIterable(stream) {
8927
8927
 
8928
8928
  // jobs.ts
8929
8929
  var AbstractJob = class {
8930
- constructor(getSession, client, requestLogger) {
8930
+ constructor(params, getSession, client, requestLogger) {
8931
8931
  this._responseStream = null;
8932
8932
  this._controller = new AbortController();
8933
8933
  this._getSession = getSession;
8934
+ this._params = params ?? null;
8934
8935
  this._client = client;
8935
8936
  this._requestLogger = requestLogger;
8936
8937
  }
@@ -9004,36 +9005,60 @@ var UploadJob = class extends AbstractJob {
9004
9005
  get [Symbol.toStringTag]() {
9005
9006
  return "uploadJob";
9006
9007
  }
9007
- constructor(stream, mimeType, getSession, client, requestLogger) {
9008
- super(getSession, client, requestLogger);
9008
+ constructor(stream, mimeType, params, getSession, client, requestLogger) {
9009
+ super(params, getSession, client, requestLogger);
9009
9010
  this._uploadStream = stream;
9010
9011
  this._mimeType = mimeType;
9011
9012
  }
9012
9013
  async startJob() {
9013
9014
  const session = await this._getSession();
9014
- const headers = {
9015
- "Authorization": `Bearer ${session.accessToken}`,
9016
- "Accept": "application/jsonl",
9017
- "Content-Type": this._mimeType
9018
- };
9019
9015
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync`;
9020
- this._requestLogger.debug("before POST %s with stream as body");
9021
- const response = await this._client.fetch(postUrl, {
9022
- headers,
9023
- method: "POST",
9024
- body: this._uploadStream,
9025
- signal: this._controller.signal,
9026
- // @ts-ignore
9027
- "duplex": "half",
9028
- dispatcher: this._dispatcher
9029
- });
9030
- this._requestLogger.debug("after POST %s with stream as body");
9016
+ let response;
9017
+ if (this._params) {
9018
+ this._requestLogger.debug("before POST %s with multipart body because of params");
9019
+ const params = JSON.stringify(this._params);
9020
+ const paramBlob = new Blob([params], { type: "application/json" });
9021
+ const formData = new FormData();
9022
+ formData.append("params", paramBlob);
9023
+ formData.append("file", this._uploadStream);
9024
+ const headers = {
9025
+ "Authorization": `Bearer ${session.accessToken}`,
9026
+ "Accept": "application/jsonl"
9027
+ };
9028
+ response = await this._client.fetch(postUrl, {
9029
+ headers,
9030
+ method: "POST",
9031
+ body: formData,
9032
+ signal: this._controller.signal,
9033
+ // @ts-ignore
9034
+ "duplex": "half",
9035
+ dispatcher: this._dispatcher
9036
+ });
9037
+ this._requestLogger.debug("after POST %s with multipart body because of params");
9038
+ } else {
9039
+ this._requestLogger.debug("before POST %s with stream as body");
9040
+ const headers = {
9041
+ "Authorization": `Bearer ${session.accessToken}`,
9042
+ "Accept": "application/jsonl",
9043
+ "Content-Type": this._mimeType
9044
+ };
9045
+ response = await this._client.fetch(postUrl, {
9046
+ headers,
9047
+ method: "POST",
9048
+ body: this._uploadStream,
9049
+ signal: this._controller.signal,
9050
+ // @ts-ignore
9051
+ "duplex": "half",
9052
+ dispatcher: this._dispatcher
9053
+ });
9054
+ this._requestLogger.debug("after POST %s with stream as body");
9055
+ }
9031
9056
  return response;
9032
9057
  }
9033
9058
  };
9034
9059
  var LoadFromJob = class extends AbstractJob {
9035
- constructor(location, getSession, client, requestLogger) {
9036
- super(getSession, client, requestLogger);
9060
+ constructor(location, params, getSession, client, requestLogger) {
9061
+ super(params, getSession, client, requestLogger);
9037
9062
  this._location = location;
9038
9063
  }
9039
9064
  get [Symbol.toStringTag]() {
@@ -9042,7 +9067,8 @@ var LoadFromJob = class extends AbstractJob {
9042
9067
  async startJob() {
9043
9068
  const body = {
9044
9069
  "sourceType": "URL",
9045
- "url": this._location
9070
+ "url": this._location,
9071
+ "params": this._params
9046
9072
  };
9047
9073
  const session = await this._getSession();
9048
9074
  const headers = {
@@ -9065,8 +9091,8 @@ var LoadFromJob = class extends AbstractJob {
9065
9091
  }
9066
9092
  };
9067
9093
  var LoadLiveIngressJob = class extends AbstractJob {
9068
- constructor(ingressId, getSession, client, requestLogger) {
9069
- super(getSession, client, requestLogger);
9094
+ constructor(ingressId, params, getSession, client, requestLogger) {
9095
+ super(params, getSession, client, requestLogger);
9070
9096
  this._ingressId = ingressId;
9071
9097
  }
9072
9098
  get [Symbol.toStringTag]() {
@@ -9075,7 +9101,8 @@ var LoadLiveIngressJob = class extends AbstractJob {
9075
9101
  async startJob() {
9076
9102
  const body = {
9077
9103
  "sourceType": "LIVE_INGRESS",
9078
- "liveIngressId": this._ingressId
9104
+ "liveIngressId": this._ingressId,
9105
+ "params": this._params
9079
9106
  };
9080
9107
  const session = await this._getSession();
9081
9108
  const headers = {
@@ -9794,6 +9821,7 @@ var Endpoint = class {
9794
9821
  this._expire_token_time = null;
9795
9822
  this._client = null;
9796
9823
  this._state = "Idle" /* Idle */;
9824
+ this._pipeline = null;
9797
9825
  this._stateChangeHandler = null;
9798
9826
  this._ingressEventHandler = null;
9799
9827
  this._ingressEventWs = null;
@@ -9823,6 +9851,40 @@ var Endpoint = class {
9823
9851
  popName() {
9824
9852
  return this._popName;
9825
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
+ }
9826
9888
  popId() {
9827
9889
  return this._options.popId || null;
9828
9890
  }
@@ -9938,17 +10000,17 @@ var Endpoint = class {
9938
10000
  }, this._client, this._requestLogger);
9939
10001
  return whep.start();
9940
10002
  }
9941
- async process(source) {
10003
+ async process(source, params = void 0) {
9942
10004
  if (source.file !== void 0) {
9943
- return this.uploadFile(source);
10005
+ return this.uploadFile(source, params);
9944
10006
  } else if (source.stream !== void 0) {
9945
- return this.uploadStream(source);
10007
+ return this.uploadStream(source, params);
9946
10008
  } else if (source.path !== void 0) {
9947
- return this.uploadPath(source);
10009
+ return this.uploadPath(source, params);
9948
10010
  } else if (source.url !== void 0) {
9949
- return this.loadFrom(source);
10011
+ return this.loadFrom(source, params);
9950
10012
  } else if (source.ingressId !== void 0) {
9951
- return this.loadLiveIngress(source);
10013
+ return this.loadLiveIngress(source, params);
9952
10014
  } else {
9953
10015
  return Promise.reject("unknown source type");
9954
10016
  }
@@ -9990,14 +10052,14 @@ var Endpoint = class {
9990
10052
  this.updateState();
9991
10053
  }
9992
10054
  }
9993
- async uploadFile(source) {
10055
+ async uploadFile(source, params) {
9994
10056
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
9995
10057
  return Promise.reject("endpoint not connected, use connect() before upload()");
9996
10058
  }
9997
10059
  await this._limit.acquire();
9998
10060
  try {
9999
10061
  this.updateState();
10000
- const job = new UploadJob(source.file, source.file.type, async () => {
10062
+ const job = new UploadJob(source.file, source.file.type, params, async () => {
10001
10063
  return this.session();
10002
10064
  }, this._client, this._requestLogger);
10003
10065
  return job.start(() => {
@@ -10010,14 +10072,14 @@ var Endpoint = class {
10010
10072
  throw e;
10011
10073
  }
10012
10074
  }
10013
- async uploadStream(source) {
10075
+ async uploadStream(source, params) {
10014
10076
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10015
10077
  return Promise.reject("endpoint not connected, use connect() before upload()");
10016
10078
  }
10017
10079
  await this._limit.acquire();
10018
10080
  try {
10019
10081
  this.updateState();
10020
- const job = new UploadJob(source.stream, source.mimeType, async () => {
10082
+ const job = new UploadJob(source.stream, source.mimeType, params, async () => {
10021
10083
  return this.session();
10022
10084
  }, this._client, this._requestLogger);
10023
10085
  return job.start(() => {
@@ -10030,7 +10092,7 @@ var Endpoint = class {
10030
10092
  throw e;
10031
10093
  }
10032
10094
  }
10033
- async uploadPath(source) {
10095
+ async uploadPath(source, params) {
10034
10096
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10035
10097
  throw new Error("endpoint not connected, use connect() before process()");
10036
10098
  }
@@ -10038,7 +10100,7 @@ var Endpoint = class {
10038
10100
  try {
10039
10101
  this.updateState();
10040
10102
  const streamSource = await resolvePath(source);
10041
- const job = new UploadJob(streamSource.stream, streamSource.mimeType, async () => {
10103
+ const job = new UploadJob(streamSource.stream, streamSource.mimeType, params, async () => {
10042
10104
  return this.session();
10043
10105
  }, this._client, this._requestLogger);
10044
10106
  return job.start(() => {
@@ -10051,14 +10113,14 @@ var Endpoint = class {
10051
10113
  throw e;
10052
10114
  }
10053
10115
  }
10054
- async loadFrom(source) {
10116
+ async loadFrom(source, params) {
10055
10117
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10056
10118
  throw new Error("endpoint not connected, use connect() before loadFrom()");
10057
10119
  }
10058
10120
  await this._limit.acquire();
10059
10121
  try {
10060
10122
  this.updateState();
10061
- const job = new LoadFromJob(source.url, async () => {
10123
+ const job = new LoadFromJob(source.url, params, async () => {
10062
10124
  return this.session();
10063
10125
  }, this._client, this._requestLogger);
10064
10126
  return job.start(() => {
@@ -10071,14 +10133,14 @@ var Endpoint = class {
10071
10133
  throw e;
10072
10134
  }
10073
10135
  }
10074
- async loadLiveIngress(source) {
10136
+ async loadLiveIngress(source, params) {
10075
10137
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10076
10138
  throw new Error("endpoint not connected, use connect() before loadLiveIngress()");
10077
10139
  }
10078
10140
  await this._limit.acquire();
10079
10141
  try {
10080
10142
  this.updateState();
10081
- const job = new LoadLiveIngressJob(source.ingressId, async () => {
10143
+ const job = new LoadLiveIngressJob(source.ingressId, params, async () => {
10082
10144
  return this.session();
10083
10145
  }, this._client, this._requestLogger);
10084
10146
  return job.start(() => {
@@ -10122,7 +10184,12 @@ var Endpoint = class {
10122
10184
  if (!this._client) {
10123
10185
  return Promise.reject("endpoint not initialized");
10124
10186
  }
10125
- const config_url = `${this.eyepopUrl()}/pops/${this._options.popId}/config?auto_start=false`;
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
+ }
10126
10193
  const headers = {
10127
10194
  "Authorization": await this.authorizationHeader()
10128
10195
  };
@@ -10167,13 +10234,35 @@ var Endpoint = class {
10167
10234
  }
10168
10235
  const baseUrl = new URL(config.base_url, this.eyepopUrl());
10169
10236
  this._baseUrl = baseUrl.toString();
10170
- this._pipelineId = config.pipeline_id;
10171
- this._popName = config.name;
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
+ }
10172
10244
  this._requestLogger.debug("after GET %s: %s / %s", config_url, this._baseUrl, this._pipelineId);
10173
10245
  if (!this._pipelineId || !this._baseUrl) {
10174
10246
  return Promise.reject(`Pop not started`);
10175
10247
  }
10176
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
+ }
10177
10266
  this.updateState();
10178
10267
  return Promise.resolve(this);
10179
10268
  }
@@ -10228,6 +10317,60 @@ var Endpoint = class {
10228
10317
  this._logger.debug("using access token, valid for at least %d seconds", this._expire_token_time - now);
10229
10318
  return this._token;
10230
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
+ }
10231
10374
  };
10232
10375
 
10233
10376
  // index.ts