@eyepop.ai/eyepop 0.16.3 → 0.17.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.
@@ -8898,10 +8898,11 @@ function readableStreamAsyncIterable(stream) {
8898
8898
 
8899
8899
  // jobs.ts
8900
8900
  var AbstractJob = class {
8901
- constructor(getSession, client, requestLogger) {
8901
+ constructor(params, getSession, client, requestLogger) {
8902
8902
  this._responseStream = null;
8903
8903
  this._controller = new AbortController();
8904
8904
  this._getSession = getSession;
8905
+ this._params = params ?? null;
8905
8906
  this._client = client;
8906
8907
  this._requestLogger = requestLogger;
8907
8908
  }
@@ -8975,36 +8976,60 @@ var UploadJob = class extends AbstractJob {
8975
8976
  get [Symbol.toStringTag]() {
8976
8977
  return "uploadJob";
8977
8978
  }
8978
- constructor(stream, mimeType, getSession, client, requestLogger) {
8979
- super(getSession, client, requestLogger);
8979
+ constructor(stream, mimeType, params, getSession, client, requestLogger) {
8980
+ super(params, getSession, client, requestLogger);
8980
8981
  this._uploadStream = stream;
8981
8982
  this._mimeType = mimeType;
8982
8983
  }
8983
8984
  async startJob() {
8984
8985
  const session = await this._getSession();
8985
- const headers = {
8986
- "Authorization": `Bearer ${session.accessToken}`,
8987
- "Accept": "application/jsonl",
8988
- "Content-Type": this._mimeType
8989
- };
8990
8986
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync`;
8991
- this._requestLogger.debug("before POST %s with stream as body");
8992
- const response = await this._client.fetch(postUrl, {
8993
- headers,
8994
- method: "POST",
8995
- body: this._uploadStream,
8996
- signal: this._controller.signal,
8997
- // @ts-ignore
8998
- "duplex": "half",
8999
- dispatcher: this._dispatcher
9000
- });
9001
- this._requestLogger.debug("after POST %s with stream as body");
8987
+ let response;
8988
+ if (this._params) {
8989
+ this._requestLogger.debug("before POST %s with multipart body because of params");
8990
+ const params = JSON.stringify(this._params);
8991
+ const paramBlob = new Blob([params], { type: "application/json" });
8992
+ const formData = new FormData();
8993
+ formData.append("params", paramBlob);
8994
+ formData.append("file", this._uploadStream);
8995
+ const headers = {
8996
+ "Authorization": `Bearer ${session.accessToken}`,
8997
+ "Accept": "application/jsonl"
8998
+ };
8999
+ response = await this._client.fetch(postUrl, {
9000
+ headers,
9001
+ method: "POST",
9002
+ body: formData,
9003
+ signal: this._controller.signal,
9004
+ // @ts-ignore
9005
+ "duplex": "half",
9006
+ dispatcher: this._dispatcher
9007
+ });
9008
+ this._requestLogger.debug("after POST %s with multipart body because of params");
9009
+ } else {
9010
+ this._requestLogger.debug("before POST %s with stream as body");
9011
+ const headers = {
9012
+ "Authorization": `Bearer ${session.accessToken}`,
9013
+ "Accept": "application/jsonl",
9014
+ "Content-Type": this._mimeType
9015
+ };
9016
+ response = await this._client.fetch(postUrl, {
9017
+ headers,
9018
+ method: "POST",
9019
+ body: this._uploadStream,
9020
+ signal: this._controller.signal,
9021
+ // @ts-ignore
9022
+ "duplex": "half",
9023
+ dispatcher: this._dispatcher
9024
+ });
9025
+ this._requestLogger.debug("after POST %s with stream as body");
9026
+ }
9002
9027
  return response;
9003
9028
  }
9004
9029
  };
9005
9030
  var LoadFromJob = class extends AbstractJob {
9006
- constructor(location, getSession, client, requestLogger) {
9007
- super(getSession, client, requestLogger);
9031
+ constructor(location, params, getSession, client, requestLogger) {
9032
+ super(params, getSession, client, requestLogger);
9008
9033
  this._location = location;
9009
9034
  }
9010
9035
  get [Symbol.toStringTag]() {
@@ -9013,7 +9038,8 @@ var LoadFromJob = class extends AbstractJob {
9013
9038
  async startJob() {
9014
9039
  const body = {
9015
9040
  "sourceType": "URL",
9016
- "url": this._location
9041
+ "url": this._location,
9042
+ "params": this._params
9017
9043
  };
9018
9044
  const session = await this._getSession();
9019
9045
  const headers = {
@@ -9036,8 +9062,8 @@ var LoadFromJob = class extends AbstractJob {
9036
9062
  }
9037
9063
  };
9038
9064
  var LoadLiveIngressJob = class extends AbstractJob {
9039
- constructor(ingressId, getSession, client, requestLogger) {
9040
- super(getSession, client, requestLogger);
9065
+ constructor(ingressId, params, getSession, client, requestLogger) {
9066
+ super(params, getSession, client, requestLogger);
9041
9067
  this._ingressId = ingressId;
9042
9068
  }
9043
9069
  get [Symbol.toStringTag]() {
@@ -9046,7 +9072,8 @@ var LoadLiveIngressJob = class extends AbstractJob {
9046
9072
  async startJob() {
9047
9073
  const body = {
9048
9074
  "sourceType": "LIVE_INGRESS",
9049
- "liveIngressId": this._ingressId
9075
+ "liveIngressId": this._ingressId,
9076
+ "params": this._params
9050
9077
  };
9051
9078
  const session = await this._getSession();
9052
9079
  const headers = {
@@ -9909,17 +9936,17 @@ var Endpoint = class {
9909
9936
  }, this._client, this._requestLogger);
9910
9937
  return whep.start();
9911
9938
  }
9912
- async process(source) {
9939
+ async process(source, params = void 0) {
9913
9940
  if (source.file !== void 0) {
9914
- return this.uploadFile(source);
9941
+ return this.uploadFile(source, params);
9915
9942
  } else if (source.stream !== void 0) {
9916
- return this.uploadStream(source);
9943
+ return this.uploadStream(source, params);
9917
9944
  } else if (source.path !== void 0) {
9918
- return this.uploadPath(source);
9945
+ return this.uploadPath(source, params);
9919
9946
  } else if (source.url !== void 0) {
9920
- return this.loadFrom(source);
9947
+ return this.loadFrom(source, params);
9921
9948
  } else if (source.ingressId !== void 0) {
9922
- return this.loadLiveIngress(source);
9949
+ return this.loadLiveIngress(source, params);
9923
9950
  } else {
9924
9951
  return Promise.reject("unknown source type");
9925
9952
  }
@@ -9961,14 +9988,14 @@ var Endpoint = class {
9961
9988
  this.updateState();
9962
9989
  }
9963
9990
  }
9964
- async uploadFile(source) {
9991
+ async uploadFile(source, params) {
9965
9992
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
9966
9993
  return Promise.reject("endpoint not connected, use connect() before upload()");
9967
9994
  }
9968
9995
  await this._limit.acquire();
9969
9996
  try {
9970
9997
  this.updateState();
9971
- const job = new UploadJob(source.file, source.file.type, async () => {
9998
+ const job = new UploadJob(source.file, source.file.type, params, async () => {
9972
9999
  return this.session();
9973
10000
  }, this._client, this._requestLogger);
9974
10001
  return job.start(() => {
@@ -9981,14 +10008,14 @@ var Endpoint = class {
9981
10008
  throw e;
9982
10009
  }
9983
10010
  }
9984
- async uploadStream(source) {
10011
+ async uploadStream(source, params) {
9985
10012
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
9986
10013
  return Promise.reject("endpoint not connected, use connect() before upload()");
9987
10014
  }
9988
10015
  await this._limit.acquire();
9989
10016
  try {
9990
10017
  this.updateState();
9991
- const job = new UploadJob(source.stream, source.mimeType, async () => {
10018
+ const job = new UploadJob(source.stream, source.mimeType, params, async () => {
9992
10019
  return this.session();
9993
10020
  }, this._client, this._requestLogger);
9994
10021
  return job.start(() => {
@@ -10001,7 +10028,7 @@ var Endpoint = class {
10001
10028
  throw e;
10002
10029
  }
10003
10030
  }
10004
- async uploadPath(source) {
10031
+ async uploadPath(source, params) {
10005
10032
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10006
10033
  throw new Error("endpoint not connected, use connect() before process()");
10007
10034
  }
@@ -10009,7 +10036,7 @@ var Endpoint = class {
10009
10036
  try {
10010
10037
  this.updateState();
10011
10038
  const streamSource = await resolvePath(source);
10012
- const job = new UploadJob(streamSource.stream, streamSource.mimeType, async () => {
10039
+ const job = new UploadJob(streamSource.stream, streamSource.mimeType, params, async () => {
10013
10040
  return this.session();
10014
10041
  }, this._client, this._requestLogger);
10015
10042
  return job.start(() => {
@@ -10022,14 +10049,14 @@ var Endpoint = class {
10022
10049
  throw e;
10023
10050
  }
10024
10051
  }
10025
- async loadFrom(source) {
10052
+ async loadFrom(source, params) {
10026
10053
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10027
10054
  throw new Error("endpoint not connected, use connect() before loadFrom()");
10028
10055
  }
10029
10056
  await this._limit.acquire();
10030
10057
  try {
10031
10058
  this.updateState();
10032
- const job = new LoadFromJob(source.url, async () => {
10059
+ const job = new LoadFromJob(source.url, params, async () => {
10033
10060
  return this.session();
10034
10061
  }, this._client, this._requestLogger);
10035
10062
  return job.start(() => {
@@ -10042,14 +10069,14 @@ var Endpoint = class {
10042
10069
  throw e;
10043
10070
  }
10044
10071
  }
10045
- async loadLiveIngress(source) {
10072
+ async loadLiveIngress(source, params) {
10046
10073
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10047
10074
  throw new Error("endpoint not connected, use connect() before loadLiveIngress()");
10048
10075
  }
10049
10076
  await this._limit.acquire();
10050
10077
  try {
10051
10078
  this.updateState();
10052
- const job = new LoadLiveIngressJob(source.ingressId, async () => {
10079
+ const job = new LoadLiveIngressJob(source.ingressId, params, async () => {
10053
10080
  return this.session();
10054
10081
  }, this._client, this._requestLogger);
10055
10082
  return job.start(() => {