@formant/data-sdk 0.0.135 → 0.0.136

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.
Files changed (25) hide show
  1. package/dist/data-sdk.es.js +142 -24
  2. package/dist/data-sdk.umd.js +18 -18
  3. package/dist/types/data-sdk/src/Device.d.ts +2 -0
  4. package/dist/types/data-sdk/src/Fleet.d.ts +118 -0
  5. package/dist/types/data-sdk/src/main.d.ts +13 -0
  6. package/dist/types/data-sdk/src/model/AggregateLevel.d.ts +1 -1
  7. package/dist/types/data-sdk/src/model/AnalyticsAggregateType.d.ts +2 -0
  8. package/dist/types/data-sdk/src/model/AnalyticsChartType.d.ts +2 -0
  9. package/dist/types/data-sdk/src/model/IAggregateRow.d.ts +8 -0
  10. package/dist/types/data-sdk/src/model/IAnalyticsModule.d.ts +15 -0
  11. package/dist/types/data-sdk/src/model/IAnalyticsModuleConfiguration.d.ts +6 -0
  12. package/dist/types/data-sdk/src/model/IScopeFilter.d.ts +6 -0
  13. package/dist/types/data-sdk/src/model/IShare.d.ts +16 -0
  14. package/dist/types/data-sdk/src/model/ISqlColumn.d.ts +6 -0
  15. package/dist/types/data-sdk/src/model/ISqlQuery.d.ts +21 -0
  16. package/dist/types/data-sdk/src/model/ISqlResult.d.ts +12 -0
  17. package/dist/types/data-sdk/src/model/ISqlRow.d.ts +5 -0
  18. package/dist/types/data-sdk/src/model/IStreamColumn.d.ts +7 -0
  19. package/dist/types/data-sdk/src/model/ITaskReportColumn.d.ts +7 -0
  20. package/dist/types/data-sdk/src/model/analyticsAggregteTypes.d.ts +1 -0
  21. package/dist/types/data-sdk/src/model/analyticsChartTypes.d.ts +1 -0
  22. package/dist/types/data-sdk/src/utils/aggregateFunctionUtils.d.ts +4 -3
  23. package/dist/types/data-sdk/src/utils/index.d.ts +1 -0
  24. package/dist/types/data-sdk/src/utils/timeout.d.ts +1 -0
  25. package/package.json +2 -1
@@ -10,6 +10,7 @@ import { RtcStreamType } from "@formant/realtime-sdk/dist/model/RtcStreamType";
10
10
  import { IEventQuery } from "./main";
11
11
  import { AggregateLevel } from "./main";
12
12
  import { EventType } from "./main";
13
+ import { IShare } from "./model/IShare";
13
14
  export interface ConfigurationDocument {
14
15
  urdfFiles: string[];
15
16
  telemetry?: {
@@ -147,4 +148,5 @@ export declare class Device implements IRealtimeDevice {
147
148
  date: string;
148
149
  events: import("./main").IEvent[];
149
150
  }[]>;
151
+ createShareLink(params: IShare): Promise<any>;
150
152
  }
@@ -11,6 +11,11 @@ import { IStream } from "./model/IStream";
11
11
  import { IView } from "./model/IView";
12
12
  import { AggregateLevel } from "./main";
13
13
  import { EventType } from "./main";
14
+ import { IAnalyticsModule } from "./model/IAnalyticsModule";
15
+ import { IStreamColumn } from "./model/IStreamColumn";
16
+ import { ITaskReportColumn } from "./model/ITaskReportColumn";
17
+ import { ISqlQuery } from "./model/ISqlQuery";
18
+ import { ISqlResult } from "./model/ISqlResult";
14
19
  export interface TelemetryResult {
15
20
  deviceId: string;
16
21
  name: string;
@@ -63,4 +68,117 @@ export declare class Fleet {
63
68
  date: string;
64
69
  events: IEvent[];
65
70
  }[]>;
71
+ static getAnalyticsModules(): Promise<IAnalyticsModule>;
72
+ /**
73
+ * retrieves a list of all available data streams that can be used for running analytics.
74
+ * This function takes no arguments and returns a list of stream names that can be used for analyzing data.
75
+ * @example
76
+ * // Returns
77
+ * [
78
+ * {
79
+ * streamName: "$.agent.health",
80
+ streamType : "health"
81
+ },
82
+ {
83
+ * streamName: "up.hours",
84
+ streamType : "numeric"
85
+ }
86
+ ]
87
+ */
88
+ static getAnalyticStreams(): Promise<IStreamColumn[]>;
89
+ /**
90
+ * retrieves a list of all available tables that can be used to create task reports.
91
+ * This function takes no arguments and returns a list of table names that can be used for creating task reports.
92
+ * @returns List all available tables
93
+ * @example
94
+ * // Returns
95
+ *[
96
+ * {
97
+ * name: "",
98
+ * tableName: "TASK_REPORTS_CLEANING_MODE",
99
+ * columns: [
100
+ * {
101
+ * name: "TYPE",
102
+ * isNullable: true,
103
+ * dataType: "string",
104
+ * tableName: "custom"
105
+ * }
106
+ * ]
107
+ * }
108
+ *]
109
+ */
110
+ static getTaskReportTables(): Promise<ITaskReportColumn[]>;
111
+ /**
112
+ *Retrieves all stream rows
113
+ * @example
114
+ * // Body
115
+ * const analytics = await Fleet.queryAnalytics({
116
+ * aggregateLevel: "day",
117
+ * orderByColumn: "TIMESTAMP",
118
+ * streamColumns: [
119
+ * {
120
+ * streamName: "consumables_residual_percentage",
121
+ * streamType: "numeric set",
122
+ * },
123
+ * ],
124
+ * });
125
+ * //Returns
126
+ * {
127
+ * aggregates: [],
128
+ * columns: [
129
+ * {
130
+ * name: 'TIMESTAMP',
131
+ * isNullable: true,
132
+ * dataType: 'string',
133
+ * tableName: 'NUMERIC_SET_MAIN'
134
+ * }
135
+ * ],
136
+ * items: [
137
+ * {
138
+ * axisLabel: "suction_blade",
139
+ * name: "consumables_residual_percentage",
140
+ * tableName: "NUMERIC_SET_TEST",
141
+ * time: "2020-04-20T08:00:00.000Z",
142
+ * type: "numeric set",
143
+ * unitLabel: "percent"
144
+ * }
145
+ * ],
146
+ * rowCount: 14,
147
+ * rows: []
148
+ * sqlText: "SELECT dateadd(day, dayofweek(TIMESTAMP), to_timestamp_tz('4/20/2020')) AS TIMESTAMP, SUM(VALUE)"
149
+ * }
150
+ */
151
+ static queryAnalytics(query: ISqlQuery): Promise<ISqlResult>;
152
+ /**
153
+ * Retrieves all rows
154
+ * sqlQuery is required
155
+ * @param query
156
+ * @returns
157
+ */
158
+ static getAnalyticsRows(query: ISqlQuery): Promise<any>;
159
+ /**
160
+ * @param taskColumns is required
161
+ * @returns
162
+ * All task reports
163
+ * @example
164
+ * // Body
165
+ * const tasks = await Fleet.getTaskReports({
166
+ * taskColumns: [
167
+ * {
168
+ * columns: [
169
+ * {
170
+ * dataType: "string",
171
+ * isNullable: true,
172
+ * name: "TYPE",
173
+ * tableName: "custom",
174
+ * },
175
+ * ],
176
+ * name: "DURATION_SECONDS",
177
+ * tableName: "TASK_REPORTS_CLEANING_MODE",
178
+ * yAxis: "DURATION_SECONDS",
179
+ * },
180
+ * ],
181
+ * });
182
+ */
183
+ static getTaskReportRows(query: ISqlQuery): Promise<any>;
66
184
  }
@@ -116,3 +116,16 @@ export * from "./model/IAnnotationQuery";
116
116
  export * from "./model/IStream";
117
117
  export { IRtcSendConfiguration, IRtcStreamMessage, IRtcStreamPayload, } from "@formant/realtime-sdk";
118
118
  export * from "./model/JsonSchema";
119
+ export * from "./utils/aggregateFunctionUtils";
120
+ export * from "./model/IStreamColumn";
121
+ export * from "./model/IAnalyticsModule";
122
+ export * from "./model/ITaskReportColumn";
123
+ export * from "./model/IView";
124
+ export * from "./model/IShare";
125
+ export * from "./model/ISqlQuery";
126
+ export * from "./model/IScopeFilter";
127
+ export * from "./model/ISqlColumn";
128
+ export * from "./model/ISqlResult";
129
+ export * from "./model/IAnalyticsModuleConfiguration";
130
+ export * from "./model/IAggregateRow";
131
+ export * from "./model/ISqlRow";
@@ -1 +1 @@
1
- export type AggregateLevel = "year" | "month" | "week" | "day" | "hour" | "minute" | "quarter";
1
+ export type AggregateLevel = "year" | "month" | "week" | "day" | "12 hours" | "4 hours" | "hour" | "30 minutes" | "5 minutes" | "minute" | "30 seconds" | "5 seconds" | "second" | "quarter";
@@ -0,0 +1,2 @@
1
+ import { analyticsAggregateTypes } from "./analyticsAggregteTypes";
2
+ export type AnalyticsAggregateType = typeof analyticsAggregateTypes[number];
@@ -0,0 +1,2 @@
1
+ import { analyicsChartTypes } from "./analyticsChartTypes";
2
+ export type AnalyticsChartType = typeof analyicsChartTypes[number];
@@ -0,0 +1,8 @@
1
+ import { AnalyticsAggregateType } from "./AnalyticsAggregateType";
2
+ export interface IAggregateRow {
3
+ unit?: string;
4
+ label?: string;
5
+ name: string;
6
+ value: number;
7
+ type: AnalyticsAggregateType;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { IBaseEntity } from "./IBaseEntity";
2
+ import { Uuid } from "./Uuid";
3
+ import { ISqlQuery } from "./ISqlQuery";
4
+ import { IAnalyticsModuleConfiguration } from "./IAnalyticsModuleConfiguration";
5
+ export interface IAnalyticsModule extends IBaseEntity {
6
+ id?: Uuid;
7
+ organizationId?: Uuid;
8
+ name: string;
9
+ query: ISqlQuery | null;
10
+ configuration: IAnalyticsModuleConfiguration | null;
11
+ layout: any | null;
12
+ data: any[] | null;
13
+ streamIds: Uuid[];
14
+ fullscreen?: boolean;
15
+ }
@@ -0,0 +1,6 @@
1
+ import { AnalyticsAggregateType } from "./AnalyticsAggregateType";
2
+ import { AnalyticsChartType } from "./AnalyticsChartType";
3
+ export interface IAnalyticsModuleConfiguration {
4
+ chartType?: AnalyticsChartType;
5
+ aggregateType?: AnalyticsAggregateType;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { IFilter } from "./IFilter";
2
+ import { IsoDate } from "./IsoDate";
3
+ export interface IScopeFilter extends IFilter {
4
+ start?: IsoDate;
5
+ end?: IsoDate;
6
+ }
@@ -0,0 +1,16 @@
1
+ import { IBaseEntity } from "./IBaseEntity";
2
+ import { Uuid } from "./Uuid";
3
+ import { IScopeFilter } from "./IScopeFilter";
4
+ import { IsoDate } from "./IsoDate";
5
+ export interface IShare extends IBaseEntity {
6
+ organizationId?: Uuid;
7
+ userId?: Uuid;
8
+ code?: string;
9
+ scope: IScopeFilter;
10
+ time: IsoDate;
11
+ expiration?: IsoDate | null;
12
+ channelId?: Uuid;
13
+ message?: string;
14
+ userName?: string;
15
+ delegateTeleop?: boolean;
16
+ }
@@ -0,0 +1,6 @@
1
+ export interface ISqlColumn {
2
+ name: string;
3
+ tableName: string;
4
+ isNullable?: boolean;
5
+ dataType: "string" | "timestamp" | "boolean" | "number" | "null";
6
+ }
@@ -0,0 +1,21 @@
1
+ import { IsoDate } from "./IsoDate";
2
+ import { IFilter } from "./IFilter";
3
+ import { AggregateLevel } from "./AggregateLevel";
4
+ import { IStreamColumn } from "./IStreamColumn";
5
+ import { ITaskReportColumn } from "./ITaskReportColumn";
6
+ export interface ISqlQuery extends IFilter {
7
+ sqlQuery?: string;
8
+ parameters?: string[];
9
+ start?: IsoDate;
10
+ end?: IsoDate;
11
+ streamColumns?: IStreamColumn[];
12
+ taskColumns?: ITaskReportColumn[];
13
+ aggregateLevel?: AggregateLevel;
14
+ limit?: number;
15
+ orderByColumn?: string;
16
+ orderByDescending?: boolean;
17
+ visibleColumns?: string[];
18
+ filters?: string[];
19
+ type?: "stream" | "task" | "advanced";
20
+ unit?: string;
21
+ }
@@ -0,0 +1,12 @@
1
+ import { IAggregateRow } from "./IAggregateRow";
2
+ import { ISqlColumn } from "./ISqlColumn";
3
+ import { ISqlRow } from "./ISqlRow";
4
+ export interface ISqlResult {
5
+ rows: ISqlRow[];
6
+ columns: ISqlColumn[];
7
+ aggregates?: IAggregateRow[];
8
+ sqlText: string;
9
+ aggregateSqlText?: string;
10
+ rowCount: number;
11
+ unit?: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ import { IsoDate } from "./IsoDate";
2
+ export interface ISqlRow {
3
+ [key: string]: string | IsoDate | number | boolean | null;
4
+ tableName: string;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { StreamType } from "./StreamType";
2
+ import { AnalyticsAggregateType } from "./AnalyticsAggregateType";
3
+ export interface IStreamColumn {
4
+ streamName: string;
5
+ streamType: StreamType;
6
+ aggregateType?: AnalyticsAggregateType;
7
+ }
@@ -0,0 +1,7 @@
1
+ import { ISqlColumn } from "./ISqlColumn";
2
+ export interface ITaskReportColumn {
3
+ tableName: string;
4
+ columns?: ISqlColumn[];
5
+ name: string;
6
+ yAxis?: string;
7
+ }
@@ -0,0 +1 @@
1
+ export declare const analyticsAggregateTypes: readonly ["avg", "sum", "count", "min", "max"];
@@ -0,0 +1 @@
1
+ export declare const analyicsChartTypes: readonly ["line", "bar", "table", "pie", "summary"];
@@ -1,7 +1,8 @@
1
1
  import { INumericAggregate } from "../model/INumericAggregate";
2
- import { AggregateLevel } from "../main";
2
+ export declare const vailableAggregationIntervals: readonly ["day", "week", "month", "year", "hour", "minute", "quarter"];
3
+ export type ValidAggregationInterval = typeof vailableAggregationIntervals[number];
3
4
  export type IAggregateByDateFunctions = {
4
- [key in AggregateLevel]: AggregateFunction;
5
+ [key in ValidAggregationInterval]: AggregateFunction;
5
6
  };
6
7
  export declare const aggregateFunctions: readonly ["interval", "start", "end", "sub", "get"];
7
8
  export type AggregateFunctions = typeof aggregateFunctions[number];
@@ -23,5 +24,5 @@ export declare const aggregateFunctionMap: {
23
24
  sum: typeof getSum;
24
25
  count: typeof getCount;
25
26
  };
26
- export declare const aggregateByDateFunctions: IAggregateByDateFunctions;
27
+ export declare const aggregateByDateFunctions: any;
27
28
  export declare const formatTimeFrameText: (start: string, end: string) => string;
@@ -1,2 +1,3 @@
1
1
  export * from "./aggregateFunctionUtils";
2
2
  export * from "./numericAggregateUtils";
3
+ export * from "./timeout";
@@ -0,0 +1 @@
1
+ export declare const timeout: (s: number) => Promise<unknown>;
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "require": "./dist/data-sdk.umd.js"
19
19
  }
20
20
  },
21
- "version": "0.0.135",
21
+ "version": "0.0.136",
22
22
  "scripts": {
23
23
  "dev": "vite --port 9146",
24
24
  "build": "tsc && vite build",
@@ -27,6 +27,7 @@
27
27
  "docs": "typedoc src/main.ts --theme default --out ../../docs/data-sdk/"
28
28
  },
29
29
  "devDependencies": {
30
+ "@types/node": "^18.15.11",
30
31
  "typedoc": "^0.22.13",
31
32
  "typescript": "^4.3.2",
32
33
  "vite": "^2.5.4"