@eyepop.ai/eyepop 0.11.0 → 0.13.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/index.d.mts CHANGED
@@ -19,19 +19,32 @@ declare enum EndpointState {
19
19
  StartingPop = "StartingPop",
20
20
  Error = "Error"
21
21
  }
22
- interface LiveIngress {
22
+ interface LiveMedia {
23
23
  ingressId(): string;
24
+ stream(): Promise<MediaStream>;
24
25
  close(): Promise<void>;
25
26
  }
26
27
  interface IngressEvent {
27
- readonly ingressId?: string;
28
- readonly event?: "stream-ready" | "stream-ready";
28
+ readonly ingressId: string;
29
+ readonly event: "stream-ready" | "stream-ready";
29
30
  }
30
- interface UploadParams {
31
- readonly filePath?: string | undefined;
32
- readonly file?: File | undefined;
33
- readonly mimeType?: string | undefined;
31
+ interface FileSource {
32
+ readonly file: File;
34
33
  }
34
+ interface StreamSource {
35
+ readonly stream: ReadableStream<Uint8Array>;
36
+ readonly mimeType: string;
37
+ }
38
+ interface PathSource {
39
+ readonly path: string;
40
+ }
41
+ interface LiveSource {
42
+ readonly ingressId: string;
43
+ }
44
+ interface UrlSource {
45
+ readonly url: string;
46
+ }
47
+ type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
35
48
  interface Prediction {
36
49
  timestamp: number;
37
50
  seconds: number;
@@ -86,22 +99,32 @@ interface ResultStream extends AsyncIterable<Prediction> {
86
99
  cancel(): void;
87
100
  }
88
101
 
89
- interface Authentication {
102
+ interface Auth0Options {
103
+ domain: string;
104
+ clientId: string;
105
+ audience: string;
106
+ scope: string;
107
+ }
108
+ interface SecretKeyAuth {
90
109
  /**
91
110
  * Authentication secret for server side execution.
92
111
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
93
112
  */
94
- secretKey?: string | undefined;
113
+ secretKey: string;
114
+ }
115
+ interface SessionAuth {
95
116
  /**
96
117
  * Temporary authentication token for client side execution.
97
118
  */
98
- session?: Session | undefined;
119
+ session: Session;
120
+ }
121
+ interface OAuth2Auth {
99
122
  /**
100
- * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
101
- * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
123
+ * For development mode, authenticate with your dashboard.eyepop.ai account
102
124
  */
103
- oAuth?: true | string | undefined;
125
+ oAuth2: true | Auth0Options;
104
126
  }
127
+ type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
105
128
  interface Options {
106
129
  auth?: Authentication | undefined;
107
130
  /**
@@ -136,27 +159,31 @@ declare class Endpoint {
136
159
  private _logger;
137
160
  private readonly _requestLogger;
138
161
  constructor(options: Options);
139
- onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
140
- private startIngressWs;
141
- onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
162
+ eyepopUrl(): string;
142
163
  state(): EndpointState;
143
164
  pendingJobs(): number;
144
165
  popName(): string | null;
145
166
  popId(): string | null;
146
- session(): Promise<SessionPlus>;
147
- liveIngress(stream: MediaStream): Promise<LiveIngress>;
148
- upload(params: UploadParams): Promise<ResultStream>;
149
- loadFrom(location: string): Promise<ResultStream>;
150
- loadLiveIngress(ingressId: string): Promise<ResultStream>;
167
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
168
+ onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
151
169
  connect(): Promise<Endpoint>;
170
+ disconnect(wait?: boolean): Promise<void>;
171
+ session(): Promise<SessionPlus>;
172
+ liveIngress(stream: MediaStream): Promise<LiveMedia>;
173
+ liveEgress(ingressId: string): Promise<LiveMedia>;
174
+ process(source: Source): Promise<ResultStream>;
175
+ private startIngressWs;
176
+ private uploadFile;
177
+ private uploadStream;
178
+ private uploadPath;
179
+ private loadFrom;
180
+ private loadLiveIngress;
152
181
  private jobDone;
153
182
  private updateState;
154
183
  private jobStatus;
155
184
  private reconnect;
156
- disconnect(wait?: boolean): Promise<void>;
157
- protected authorizationHeader(): Promise<string>;
185
+ private authorizationHeader;
158
186
  private currentAccessToken;
159
- eyepopUrl(): string;
160
187
  }
161
188
 
162
189
  declare class EyePopPlot {
@@ -179,11 +206,10 @@ declare class EyePopPlot {
179
206
  }
180
207
 
181
208
  declare class EyePopSdk {
182
- static defaultAuth: {
183
- secretKey: string | undefined;
184
- };
209
+ private static readonly envSecretKey;
210
+ static defaultAuth: SecretKeyAuth | undefined;
185
211
  static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
186
212
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
187
213
  }
188
214
 
189
- export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type UploadParams, EyePopSdk as default };
215
+ export { EndpointState, EyePopSdk, 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 UrlSource, EyePopSdk as default };
package/dist/index.d.ts CHANGED
@@ -19,19 +19,32 @@ declare enum EndpointState {
19
19
  StartingPop = "StartingPop",
20
20
  Error = "Error"
21
21
  }
22
- interface LiveIngress {
22
+ interface LiveMedia {
23
23
  ingressId(): string;
24
+ stream(): Promise<MediaStream>;
24
25
  close(): Promise<void>;
25
26
  }
26
27
  interface IngressEvent {
27
- readonly ingressId?: string;
28
- readonly event?: "stream-ready" | "stream-ready";
28
+ readonly ingressId: string;
29
+ readonly event: "stream-ready" | "stream-ready";
29
30
  }
30
- interface UploadParams {
31
- readonly filePath?: string | undefined;
32
- readonly file?: File | undefined;
33
- readonly mimeType?: string | undefined;
31
+ interface FileSource {
32
+ readonly file: File;
34
33
  }
34
+ interface StreamSource {
35
+ readonly stream: ReadableStream<Uint8Array>;
36
+ readonly mimeType: string;
37
+ }
38
+ interface PathSource {
39
+ readonly path: string;
40
+ }
41
+ interface LiveSource {
42
+ readonly ingressId: string;
43
+ }
44
+ interface UrlSource {
45
+ readonly url: string;
46
+ }
47
+ type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
35
48
  interface Prediction {
36
49
  timestamp: number;
37
50
  seconds: number;
@@ -86,22 +99,32 @@ interface ResultStream extends AsyncIterable<Prediction> {
86
99
  cancel(): void;
87
100
  }
88
101
 
89
- interface Authentication {
102
+ interface Auth0Options {
103
+ domain: string;
104
+ clientId: string;
105
+ audience: string;
106
+ scope: string;
107
+ }
108
+ interface SecretKeyAuth {
90
109
  /**
91
110
  * Authentication secret for server side execution.
92
111
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
93
112
  */
94
- secretKey?: string | undefined;
113
+ secretKey: string;
114
+ }
115
+ interface SessionAuth {
95
116
  /**
96
117
  * Temporary authentication token for client side execution.
97
118
  */
98
- session?: Session | undefined;
119
+ session: Session;
120
+ }
121
+ interface OAuth2Auth {
99
122
  /**
100
- * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
101
- * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
123
+ * For development mode, authenticate with your dashboard.eyepop.ai account
102
124
  */
103
- oAuth?: true | string | undefined;
125
+ oAuth2: true | Auth0Options;
104
126
  }
127
+ type Authentication = undefined | SecretKeyAuth | SessionAuth | OAuth2Auth;
105
128
  interface Options {
106
129
  auth?: Authentication | undefined;
107
130
  /**
@@ -136,27 +159,31 @@ declare class Endpoint {
136
159
  private _logger;
137
160
  private readonly _requestLogger;
138
161
  constructor(options: Options);
139
- onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
140
- private startIngressWs;
141
- onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
162
+ eyepopUrl(): string;
142
163
  state(): EndpointState;
143
164
  pendingJobs(): number;
144
165
  popName(): string | null;
145
166
  popId(): string | null;
146
- session(): Promise<SessionPlus>;
147
- liveIngress(stream: MediaStream): Promise<LiveIngress>;
148
- upload(params: UploadParams): Promise<ResultStream>;
149
- loadFrom(location: string): Promise<ResultStream>;
150
- loadLiveIngress(ingressId: string): Promise<ResultStream>;
167
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
168
+ onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
151
169
  connect(): Promise<Endpoint>;
170
+ disconnect(wait?: boolean): Promise<void>;
171
+ session(): Promise<SessionPlus>;
172
+ liveIngress(stream: MediaStream): Promise<LiveMedia>;
173
+ liveEgress(ingressId: string): Promise<LiveMedia>;
174
+ process(source: Source): Promise<ResultStream>;
175
+ private startIngressWs;
176
+ private uploadFile;
177
+ private uploadStream;
178
+ private uploadPath;
179
+ private loadFrom;
180
+ private loadLiveIngress;
152
181
  private jobDone;
153
182
  private updateState;
154
183
  private jobStatus;
155
184
  private reconnect;
156
- disconnect(wait?: boolean): Promise<void>;
157
- protected authorizationHeader(): Promise<string>;
185
+ private authorizationHeader;
158
186
  private currentAccessToken;
159
- eyepopUrl(): string;
160
187
  }
161
188
 
162
189
  declare class EyePopPlot {
@@ -179,11 +206,10 @@ declare class EyePopPlot {
179
206
  }
180
207
 
181
208
  declare class EyePopSdk {
182
- static defaultAuth: {
183
- secretKey: string | undefined;
184
- };
209
+ private static readonly envSecretKey;
210
+ static defaultAuth: SecretKeyAuth | undefined;
185
211
  static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
186
212
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
187
213
  }
188
214
 
189
- export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type UploadParams, EyePopSdk as default };
215
+ export { EndpointState, EyePopSdk, 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 UrlSource, EyePopSdk as default };