@formant/data-sdk 0.0.144 → 0.0.146

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.
@@ -6,6 +6,10 @@ export interface IDevice {
6
6
  tags: ITags;
7
7
  }
8
8
  export type AppMessage = {
9
+ type: "request_date";
10
+ minTime?: Date;
11
+ maxTime?: Date;
12
+ } | {
9
13
  type: "go_to_time";
10
14
  time: number;
11
15
  } | {
@@ -51,6 +55,9 @@ export type ModuleConfigurationMessage = {
51
55
  configuration: string;
52
56
  };
53
57
  export type EmbeddedAppMessage = {
58
+ type: "date_response";
59
+ data: Date;
60
+ } | {
54
61
  type: "overview_devices";
55
62
  data: IDevice[];
56
63
  } | {
@@ -136,4 +143,5 @@ export declare class App {
136
143
  okText?: string;
137
144
  cancelText?: string;
138
145
  }): Promise<any>;
146
+ static getDate(minTime?: Date, maxTime?: Date): Promise<unknown>;
139
147
  }
@@ -1,52 +1,2 @@
1
- export interface User {
2
- firstName: string;
3
- lastName: string;
4
- email: string;
5
- organizationId: string;
6
- id: string;
7
- }
8
- export interface IAuthentication {
9
- accessToken: string;
10
- organizationId: string;
11
- refreshToken: string;
12
- userId: string;
13
- }
14
- export interface IConfirmForgotPasswordRequest {
15
- email: string;
16
- confirmationCode: string;
17
- newPassword: string;
18
- }
19
- export interface IRespondToNewPasswordRequiredChallengeRequest {
20
- userId: string;
21
- session: string;
22
- newPassword: string;
23
- }
24
- export declare class Authentication {
25
- static token: string | undefined;
26
- static refreshToken: string | undefined;
27
- static currentUser: User | undefined;
28
- static currentOrganization: string | undefined;
29
- static isShareToken: boolean;
30
- static defaultDeviceId: string | undefined;
31
- static waitingForAuth: ((result: boolean) => void)[];
32
- static login(email: string, password: string): Promise<IAuthentication | Error>;
33
- static loginWithToken(token: string, refreshToken?: string): Promise<void>;
34
- static isAuthenticated(): boolean;
35
- static getCurrentUser(): User | undefined;
36
- static waitTilAuthenticated(): Promise<boolean>;
37
- static listenForRefresh(): Promise<void>;
38
- static forgotPassword(email: string): Promise<void>;
39
- /**
40
- * @example
41
- * // Body
42
- * await Authentication.confirmForgotPassword({
43
- * email: "joe@gmail.com"
44
- * confirmationCode: "1",
45
- * newPassword: "NewPassword"
46
- * });
47
- */
48
- static confirmForgotPassword(request: IConfirmForgotPasswordRequest): Promise<boolean>;
49
- static respondToNewPasswordRequiredChallenge(request: IRespondToNewPasswordRequiredChallengeRequest): Promise<any>;
50
- static loginWithGoogle(token: string): Promise<any>;
51
- static refresh(token: string): Promise<void>;
52
- }
1
+ import { IAuthenticationStore } from "./stores/IAuthenticationStore";
2
+ export declare const Authentication: IAuthenticationStore;
@@ -12,7 +12,7 @@ import { IEventQuery } from "./main";
12
12
  import { AggregateLevel } from "./main";
13
13
  import { EventType } from "./main";
14
14
  import { IShare } from "./model/IShare";
15
- import { EventEmitter } from 'events';
15
+ import { EventEmitter } from "events";
16
16
  export interface ConfigurationDocument {
17
17
  urdfFiles: string[];
18
18
  telemetry?: {
@@ -155,5 +155,5 @@ export declare class Device extends EventEmitter implements IRealtimeDevice {
155
155
  date: string;
156
156
  events: import("./main").IEvent[];
157
157
  }[]>;
158
- createShareLink(share: IShare, view: string): Promise<string>;
158
+ createShareLink(share: IShare, view: string): Promise<string | null>;
159
159
  }
@@ -200,5 +200,5 @@ export declare class Fleet {
200
200
  * userName: "User",
201
201
  * });
202
202
  */
203
- static createShareLink(share: IShare, view: string): Promise<string>;
203
+ static createShareLink(share: IShare, view: string): Promise<string | null>;
204
204
  }
@@ -129,3 +129,4 @@ export * from "./model/ISqlResult";
129
129
  export * from "./model/IAnalyticsModuleConfiguration";
130
130
  export * from "./model/IAggregateRow";
131
131
  export * from "./model/ISqlRow";
132
+ export * from "./stores/IAuthenticationStore";
@@ -1,5 +1,5 @@
1
1
  import { accessLevels } from "./accessLevels";
2
- export type AccessLevel = typeof accessLevels[number];
2
+ export type AccessLevel = (typeof accessLevels)[number];
3
3
  export declare const viewer: "viewer" | "operator" | "administrator";
4
4
  export declare const operator: "viewer" | "operator" | "administrator";
5
5
  export declare const administrator: "viewer" | "operator" | "administrator";
@@ -1,2 +1,2 @@
1
1
  import { analyticsAggregateTypes } from "./analyticsAggregteTypes";
2
- export type AnalyticsAggregateType = typeof analyticsAggregateTypes[number];
2
+ export type AnalyticsAggregateType = (typeof analyticsAggregateTypes)[number];
@@ -1,2 +1,2 @@
1
1
  import { analyicsChartTypes } from "./analyticsChartTypes";
2
- export type AnalyticsChartType = typeof analyicsChartTypes[number];
2
+ export type AnalyticsChartType = (typeof analyicsChartTypes)[number];
@@ -1,2 +1,2 @@
1
1
  import { deviceType } from "./deviceTypes";
2
- export type DeviceType = typeof deviceType[number];
2
+ export type DeviceType = (typeof deviceType)[number];
@@ -1,2 +1,2 @@
1
1
  import { eventTypes } from "./eventTypes";
2
- export type EventType = typeof eventTypes[number];
2
+ export type EventType = (typeof eventTypes)[number];
@@ -1,2 +1,2 @@
1
1
  import { healthStatuses } from "./healthStatuses";
2
- export type HealthStatus = typeof healthStatuses[number];
2
+ export type HealthStatus = (typeof healthStatuses)[number];
@@ -1,2 +1,2 @@
1
1
  import { severities } from "./severities";
2
- export type Severity = typeof severities[number];
2
+ export type Severity = (typeof severities)[number];
@@ -1,2 +1,2 @@
1
1
  import { videoMimeTypes } from "./videoMimeTypes";
2
- export type VideoMimeType = typeof videoMimeTypes[number];
2
+ export type VideoMimeType = (typeof videoMimeTypes)[number];
@@ -0,0 +1,56 @@
1
+ import { User, IAuthentication, IAuthenticationStore, IConfirmForgotPasswordRequest, IRespondToNewPasswordRequiredChallengeRequest } from "./IAuthenticationStore";
2
+ interface IAuthenticationStoreOptions {
3
+ apiUrl: string;
4
+ refreshAuthToken: () => void;
5
+ addAccessTokenRefreshListener: (callback: (token: string) => void) => void;
6
+ }
7
+ export declare class AuthenticationStore implements IAuthenticationStore {
8
+ private _refreshToken;
9
+ private _isShareToken;
10
+ private _currentOrganization;
11
+ private _currentUser;
12
+ private _defaultDeviceId;
13
+ private _token;
14
+ private _waitingForAuth;
15
+ private _refreshTimer;
16
+ private readonly _apiUrl;
17
+ private readonly _refreshAuthToken;
18
+ private readonly _addAccessTokenRefreshListener;
19
+ constructor({ apiUrl, refreshAuthToken, addAccessTokenRefreshListener, }: IAuthenticationStoreOptions);
20
+ get token(): string | undefined;
21
+ get currentUser(): User | undefined;
22
+ get currentOrganization(): string | undefined;
23
+ get defaultDeviceId(): string | undefined;
24
+ /**
25
+ * @deprecated Do not use directly. This will be removed in future versions of the API
26
+ */
27
+ get refreshToken(): string | undefined;
28
+ /**
29
+ * @deprecated Do not use directly. This will be removed in future versions of the API
30
+ */
31
+ get isShareToken(): boolean;
32
+ login(email: string, password: string): Promise<IAuthentication | Error>;
33
+ loginWithToken(token: string, refreshToken?: string): Promise<void>;
34
+ isAuthenticated(): boolean;
35
+ /**
36
+ * @deprecated use currentUser property instead.
37
+ */
38
+ getCurrentUser(): User | undefined;
39
+ waitTilAuthenticated(): Promise<boolean>;
40
+ listenForRefresh(): Promise<void>;
41
+ forgotPassword(email: string): Promise<void>;
42
+ /**
43
+ * @example
44
+ * // Body
45
+ * await this.confirmForgotPassword({
46
+ * email: "joe@gmail.com"
47
+ * confirmationCode: "1",
48
+ * newPassword: "NewPassword"
49
+ * });
50
+ */
51
+ confirmForgotPassword(request: IConfirmForgotPasswordRequest): Promise<boolean>;
52
+ respondToNewPasswordRequiredChallenge(request: IRespondToNewPasswordRequiredChallengeRequest): Promise<any>;
53
+ loginWithGoogle(token: string): Promise<any>;
54
+ refresh(token: string): Promise<void>;
55
+ }
56
+ export {};
@@ -0,0 +1,58 @@
1
+ export interface User {
2
+ firstName: string;
3
+ lastName: string;
4
+ email: string;
5
+ organizationId: string;
6
+ roleId: string;
7
+ id: string;
8
+ }
9
+ export interface IAuthentication {
10
+ accessToken: string;
11
+ organizationId: string;
12
+ refreshToken: string;
13
+ userId: string;
14
+ }
15
+ export interface IConfirmForgotPasswordRequest {
16
+ email: string;
17
+ confirmationCode: string;
18
+ newPassword: string;
19
+ }
20
+ export interface IRespondToNewPasswordRequiredChallengeRequest {
21
+ userId: string;
22
+ session: string;
23
+ newPassword: string;
24
+ }
25
+ export interface IAuthenticationStore {
26
+ readonly token: string | undefined;
27
+ readonly currentUser: User | undefined;
28
+ readonly currentOrganization: string | undefined;
29
+ readonly defaultDeviceId: string | undefined;
30
+ /**
31
+ * @deprecated Do not use directly. This will be removed in future versions of the API
32
+ */
33
+ readonly refreshToken: string | undefined;
34
+ /**
35
+ * @deprecated Do not use directly. This will be removed in future versions of the API
36
+ */
37
+ readonly isShareToken: boolean;
38
+ login(email: string, password: string): Promise<IAuthentication | Error>;
39
+ loginWithToken(token: string, refreshToken?: string): Promise<void>;
40
+ isAuthenticated(): boolean;
41
+ getCurrentUser(): User | undefined;
42
+ waitTilAuthenticated(): Promise<boolean>;
43
+ listenForRefresh(): Promise<void>;
44
+ forgotPassword(email: string): Promise<void>;
45
+ /**
46
+ * @example
47
+ * // Body
48
+ * await this.confirmForgotPassword({
49
+ * email: "joe@gmail.com"
50
+ * confirmationCode: "1",
51
+ * newPassword: "NewPassword"
52
+ * });
53
+ */
54
+ confirmForgotPassword(request: IConfirmForgotPasswordRequest): Promise<boolean>;
55
+ respondToNewPasswordRequiredChallenge(request: IRespondToNewPasswordRequiredChallengeRequest): Promise<any>;
56
+ loginWithGoogle(token: string): Promise<any>;
57
+ refresh(token: string): Promise<void>;
58
+ }
@@ -1,11 +1,11 @@
1
1
  import { INumericAggregate } from "../model/INumericAggregate";
2
2
  export declare const vailableAggregationIntervals: readonly ["day", "week", "month", "year", "hour", "minute", "quarter"];
3
- export type ValidAggregationInterval = typeof vailableAggregationIntervals[number];
3
+ export type ValidAggregationInterval = (typeof vailableAggregationIntervals)[number];
4
4
  export type IAggregateByDateFunctions = {
5
5
  [key in ValidAggregationInterval]: AggregateFunction;
6
6
  };
7
7
  export declare const aggregateFunctions: readonly ["interval", "start", "end", "sub", "get"];
8
- export type AggregateFunctions = typeof aggregateFunctions[number];
8
+ export type AggregateFunctions = (typeof aggregateFunctions)[number];
9
9
  export type AggregateFunction = {
10
10
  [key in AggregateFunctions]: any;
11
11
  };
package/package.json CHANGED
@@ -18,27 +18,39 @@
18
18
  "require": "./dist/data-sdk.umd.js"
19
19
  }
20
20
  },
21
- "version": "0.0.144",
21
+ "version": "0.0.146",
22
22
  "scripts": {
23
23
  "dev": "vite --port 9146",
24
24
  "build": "tsc && vite build",
25
25
  "serve": "vite preview",
26
- "types": "tsc src/*.ts --lib ESNext,DOM --declaration --emitDeclarationOnly --downlevelIteration --outDir dist/types",
26
+ "test": "concurrently --kill-others-on-fail npm:test:*",
27
+ "test:unit": "vitest run",
28
+ "coverage": "vitest run --coverage",
29
+ "prettier:check": "prettier --check src/",
30
+ "prettier:write": "prettier --write src/",
31
+ "types": "tsc --project ./tsconfig.types.json",
27
32
  "docs": "typedoc src/main.ts --theme default --out ../../docs/data-sdk/"
28
33
  },
29
34
  "devDependencies": {
30
35
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
31
36
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
32
37
  "@rollup/plugin-node-resolve": "^15.0.2",
33
- "@types/node": "^18.15.11",
34
- "typedoc": "^0.22.13",
35
- "typescript": "^4.9.3",
36
- "vite": "^4.1.0",
37
- "grpc-web": "1.2.1"
38
+ "@types/node": "^18.16.3",
39
+ "@vitest/coverage-c8": "^0.30.1",
40
+ "concurrently": "^8.0.1",
41
+ "grpc-web": "1.2.1",
42
+ "prettier": "2.8.8",
43
+ "typedoc": "^0.24.6",
44
+ "typescript": "^5.0.4",
45
+ "vite": "^4.3.3",
46
+ "vitest": "^0.30.1"
38
47
  },
39
48
  "types": "./dist/types/data-sdk/src/main.d.ts",
40
49
  "dependencies": {
41
50
  "@formant/realtime-sdk": "0.0.20",
42
- "date-fns": "^2.29.3"
51
+ "date-fns": "^2.30.0"
52
+ },
53
+ "engines": {
54
+ "node": "^18.12.0 || ^16.13.0"
43
55
  }
44
56
  }