@eyepop.ai/eyepop 0.9.2 → 0.10.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
@@ -2,8 +2,22 @@ import { Logger } from 'pino';
2
2
  import { CanvasRenderingContext2D } from 'canvas';
3
3
 
4
4
  interface Session {
5
+ readonly eyepopUrl: string;
6
+ readonly popId: string;
5
7
  readonly accessToken: string;
6
- readonly validUntil: Date;
8
+ readonly validUntil: number;
9
+ }
10
+ interface SessionPlus extends Session {
11
+ readonly baseUrl: string;
12
+ readonly pipelineId: string;
13
+ }
14
+ declare enum EndpointState {
15
+ Idle = "Idle",
16
+ Busy = "Busy",
17
+ Authenticating = "Authenticating",
18
+ FetchConfig = "FetchConfig",
19
+ StartingPop = "StartingPop",
20
+ Error = "Error"
7
21
  }
8
22
  interface UploadParams {
9
23
  readonly filePath?: string | undefined;
@@ -61,7 +75,7 @@ interface PredictedKeyPoints {
61
75
  interface PredictedKeyPoint extends Point3d, PredictedClass {
62
76
  }
63
77
 
64
- interface Options {
78
+ interface Authentication {
65
79
  /**
66
80
  * Authentication secret for server side execution.
67
81
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
@@ -71,6 +85,14 @@ interface Options {
71
85
  * Temporary authentication token for client side execution.
72
86
  */
73
87
  session?: Session | undefined;
88
+ /**
89
+ * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
90
+ * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
91
+ */
92
+ oAuth?: true | string | undefined;
93
+ }
94
+ interface Options {
95
+ auth?: Authentication | undefined;
74
96
  /**
75
97
  * Defaults to process.env['EYEPOP_POP_ID'].
76
98
  */
@@ -100,18 +122,28 @@ declare class Endpoint {
100
122
  private _popName;
101
123
  private _client;
102
124
  private _limit;
125
+ private _state;
126
+ private _stateChangeHandler;
103
127
  private _logger;
104
128
  private readonly _requestLogger;
105
129
  constructor(options: Options);
130
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
131
+ state(): EndpointState;
132
+ pendingJobs(): number;
106
133
  popName(): string | null;
107
- session(): Promise<Session>;
134
+ popId(): string | null;
135
+ session(): Promise<SessionPlus>;
108
136
  upload(params: UploadParams): Promise<ResultStream>;
109
137
  loadFrom(location: string): Promise<ResultStream>;
110
138
  connect(): Promise<Endpoint>;
139
+ private jobDone;
140
+ private updateState;
141
+ private jobStatus;
142
+ private reconnect;
111
143
  disconnect(wait?: boolean): Promise<void>;
112
144
  protected authorizationHeader(): Promise<string>;
113
145
  private currentAccessToken;
114
- private eyepopUrl;
146
+ eyepopUrl(): string;
115
147
  }
116
148
 
117
149
  declare class EyePopPlot {
@@ -129,13 +161,16 @@ declare class EyePopPlot {
129
161
  blank_color: string;
130
162
  };
131
163
  prediction(p: Prediction): void;
132
- object(obj: PredictedObject): void;
164
+ object(obj: PredictedObject, x_scale: number, y_scale: number): void;
133
165
  static toTitleCase(str: string): string;
134
166
  }
135
167
 
136
168
  declare class EyePopSdk {
137
- static endpoint({ secretKey, session, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
169
+ static defaultAuth: {
170
+ secretKey: string | undefined;
171
+ };
172
+ static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
138
173
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
139
174
  }
140
175
 
141
- export { EyePopSdk };
176
+ export { EndpointState, EyePopSdk, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type Session, type UploadParams, EyePopSdk as default };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,22 @@ import { Logger } from 'pino';
2
2
  import { CanvasRenderingContext2D } from 'canvas';
3
3
 
4
4
  interface Session {
5
+ readonly eyepopUrl: string;
6
+ readonly popId: string;
5
7
  readonly accessToken: string;
6
- readonly validUntil: Date;
8
+ readonly validUntil: number;
9
+ }
10
+ interface SessionPlus extends Session {
11
+ readonly baseUrl: string;
12
+ readonly pipelineId: string;
13
+ }
14
+ declare enum EndpointState {
15
+ Idle = "Idle",
16
+ Busy = "Busy",
17
+ Authenticating = "Authenticating",
18
+ FetchConfig = "FetchConfig",
19
+ StartingPop = "StartingPop",
20
+ Error = "Error"
7
21
  }
8
22
  interface UploadParams {
9
23
  readonly filePath?: string | undefined;
@@ -61,7 +75,7 @@ interface PredictedKeyPoints {
61
75
  interface PredictedKeyPoint extends Point3d, PredictedClass {
62
76
  }
63
77
 
64
- interface Options {
78
+ interface Authentication {
65
79
  /**
66
80
  * Authentication secret for server side execution.
67
81
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
@@ -71,6 +85,14 @@ interface Options {
71
85
  * Temporary authentication token for client side execution.
72
86
  */
73
87
  session?: Session | undefined;
88
+ /**
89
+ * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
90
+ * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
91
+ */
92
+ oAuth?: true | string | undefined;
93
+ }
94
+ interface Options {
95
+ auth?: Authentication | undefined;
74
96
  /**
75
97
  * Defaults to process.env['EYEPOP_POP_ID'].
76
98
  */
@@ -100,18 +122,28 @@ declare class Endpoint {
100
122
  private _popName;
101
123
  private _client;
102
124
  private _limit;
125
+ private _state;
126
+ private _stateChangeHandler;
103
127
  private _logger;
104
128
  private readonly _requestLogger;
105
129
  constructor(options: Options);
130
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
131
+ state(): EndpointState;
132
+ pendingJobs(): number;
106
133
  popName(): string | null;
107
- session(): Promise<Session>;
134
+ popId(): string | null;
135
+ session(): Promise<SessionPlus>;
108
136
  upload(params: UploadParams): Promise<ResultStream>;
109
137
  loadFrom(location: string): Promise<ResultStream>;
110
138
  connect(): Promise<Endpoint>;
139
+ private jobDone;
140
+ private updateState;
141
+ private jobStatus;
142
+ private reconnect;
111
143
  disconnect(wait?: boolean): Promise<void>;
112
144
  protected authorizationHeader(): Promise<string>;
113
145
  private currentAccessToken;
114
- private eyepopUrl;
146
+ eyepopUrl(): string;
115
147
  }
116
148
 
117
149
  declare class EyePopPlot {
@@ -129,13 +161,16 @@ declare class EyePopPlot {
129
161
  blank_color: string;
130
162
  };
131
163
  prediction(p: Prediction): void;
132
- object(obj: PredictedObject): void;
164
+ object(obj: PredictedObject, x_scale: number, y_scale: number): void;
133
165
  static toTitleCase(str: string): string;
134
166
  }
135
167
 
136
168
  declare class EyePopSdk {
137
- static endpoint({ secretKey, session, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
169
+ static defaultAuth: {
170
+ secretKey: string | undefined;
171
+ };
172
+ static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
138
173
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
139
174
  }
140
175
 
141
- export { EyePopSdk };
176
+ export { EndpointState, EyePopSdk, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type Session, type UploadParams, EyePopSdk as default };