@iotready/nextjs-components-library 1.0.0-preview3 → 1.0.0-preview31

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.
@@ -1,55 +1,180 @@
1
1
  "use server";
2
+ import { parse } from "csv-parse";
2
3
  import moment from "moment";
3
- /* export async function getInfluxDataV2(influxConfig: InfluxConfig, field: string, timeStart: string, timeEnd: string, deviceID: string, timeGroup: string, raw: boolean): Promise<Point[]> {
4
- const query = `
5
- from(bucket: "${influxConfig.bucket}")
6
- |> range(start: ${timeStart}, stop: ${timeEnd})
7
- |> filter(fn: (r) => r._measurement == "${influxConfig.measurement}")
8
- |> filter(fn: (r) => r["_field"] == "${field}")
9
- |> filter(fn: (r) => r["deviceid"] == "${deviceID}")
10
- |> aggregateWindow(every: ${timeGroup}m, fn: last, createEmpty: false)
11
- |> yield(name: "last")
4
+ import { FilterTagMode } from "./types";
5
+ export async function getInfluxAlerts(influxConfig, fields, limit, offset, sort, filter, timeStart, timeEnd, aggregate = false) {
6
+ const conditions = fields
7
+ .map((field) => `r["valueName"] == "${field}"`)
8
+ .join(" or ");
9
+ let query = `
10
+ import "contrib/tomhollingworth/events"
11
+ from(bucket: "${influxConfig.bucket}")`;
12
+ if (timeStart && timeEnd) {
13
+ query += ` |> range(start: ${timeStart}, stop: ${timeEnd})`;
14
+ }
15
+ query += `
16
+ |> filter(fn: (r) => r["_measurement"] == "${influxConfig.measurement}" and r["${filter.field}"] == "${filter.value}" and (${conditions}))
17
+ |> filter(fn: (r) => r["d"] == "3" or r["d"] !~ /./) // Include only events with tag d == 3 or no tag d
18
+ |> sort(columns: ["_time"]) // Ordina gli eventi cronologicamente
19
+ |> group(columns: ["valueName"]) // Raggruppa per il tag
20
+ `;
21
+ if (aggregate) {
22
+ // Aggregate same consecutive values
23
+ query += `
24
+ |> duplicate(column: "_value", as: "prev_value")
25
+ |> difference(columns: ["prev_value"], keepFirst: true)
26
+ |> filter(fn: (r) => r.prev_value != 0 or not exists r.prev_value)
27
+ `;
28
+ }
29
+ const queryCount = `${query} |> group() |> count()`;
30
+ query += `
31
+ |> events.duration(unit: 1s, stop: 2020-01-02T00:00:00Z)
32
+ |> keep(columns: ["_time", "valueName", "_value", "duration"])
33
+ |> group() // Raggruppa tutti i dati in un unico gruppo
34
+ `;
35
+ if (sort && sort.field === "time" && sort.sort === "desc") {
36
+ query += ` |> sort(columns: ["_time"], desc: true)`;
37
+ }
38
+ else {
39
+ query += ` |> sort(columns: ["_time"])`;
40
+ }
41
+ query += ` |> limit(n:${limit}, offset:${offset})`;
42
+ const responses = await Promise.all([
43
+ fetch(encodeURI(`${influxConfig.url}/api/v2/query?org=${influxConfig.orgId}`), {
44
+ method: "POST",
45
+ headers: {
46
+ Authorization: `Token ${influxConfig.accessToken}`,
47
+ "Content-Type": "application/json"
48
+ },
49
+ body: JSON.stringify({
50
+ query: query,
51
+ type: "flux"
52
+ })
53
+ }),
54
+ fetch(encodeURI(`${influxConfig.url}/api/v2/query?org=${influxConfig.orgId}`), {
55
+ method: "POST",
56
+ headers: {
57
+ Authorization: `Token ${influxConfig.accessToken}`,
58
+ "Content-Type": "application/json"
59
+ },
60
+ body: JSON.stringify({
61
+ query: queryCount,
62
+ type: "flux"
63
+ })
64
+ })
65
+ ]);
66
+ if (!responses[0].ok) {
67
+ throw new Error(`Failed to fetch data from InfluxDB: ${responses[0].statusText}`);
68
+ }
69
+ const data = await responses[0].text();
70
+ const count = await responses[1].text();
71
+ const rows = [];
72
+ const parsedData = parse(data.trim(), { columns: true });
73
+ parsedData.forEach((row) => {
74
+ rows.push({
75
+ time: row["_time"],
76
+ duration: parseInt(row["duration"], 10),
77
+ value: parseInt(row["_value"], 10),
78
+ valueName: row["valueName"]
79
+ });
80
+ });
81
+ const parsedCount = count.split("\n")[1].split(",");
82
+ let countData = parsedCount[3];
83
+ return {
84
+ data: rows,
85
+ count: countData
86
+ };
87
+ }
88
+ export async function getDwSlots(influxConfig, timeStart, timeEnd, filter) {
89
+ const field = "dw";
90
+ const query = `
91
+ SELECT ("value") FROM "${influxConfig.measurement}"
92
+ WHERE "${filter.field}" = '${filter.value}'
93
+ AND "valueName" = '${field}'
94
+ AND time >= '${moment.unix(timeStart).toISOString()}'
95
+ AND time <= '${moment.unix(timeEnd).toISOString()}'
12
96
  `;
13
-
14
- const response = await fetch(`${influxConfig.url}/api/v2/query?org=${influxConfig.orgId}`, {
15
- method: 'POST',
16
- headers: {
17
- 'Content-Type': 'application/json',
18
- 'Authorization': `Token ${influxConfig.accessToken}`,
19
- 'Accept': 'application/csv'
20
- },
21
- body: JSON.stringify({
22
- query: query
23
- })
24
- });
25
- if (!response.ok) {
26
- throw new Error(`Failed to fetch data from InfluxDB: ${response.statusText}`);
27
- }
28
- const data = await response.text();
29
- return data.split('\n').map(line => {
30
- const row = line.split(',');
31
- const timestamp = row[5];
32
- const value = parseFloat(row[6]);
33
- console.log(timestamp, value);
34
- if (isNaN(value)) {
35
- return null;
36
- }
37
- return { x: new Date(timestamp).getTime(), y: value };
38
- }).filter(point => point !== null);
39
- }*/ // NOT WORKING, NEED TO FIX
40
- export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, deviceID, timeGroup, raw) {
97
+ const response = await fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${query}`), {
98
+ headers: {
99
+ Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
100
+ }
101
+ });
102
+ if (!response.ok) {
103
+ throw new Error(`Failed to fetch DW data: ${response.statusText}`);
104
+ }
105
+ const data = await response.json();
106
+ const series = data?.results?.[0]?.series?.[0];
107
+ if (!series?.values || !Array.isArray(series.values)) {
108
+ return data; // niente da fare, ritorna i dati grezzi
109
+ }
110
+ const values = series.values;
111
+ // Modifiche ai valori
112
+ if (values.length > 0) {
113
+ // Aggiungi punto all'inizio se il primo valore è 0
114
+ if (values[0][1] === 0) {
115
+ values.unshift([moment.unix(timeStart).unix(), 1]);
116
+ }
117
+ // Aggiungi punto alla fine se l'ultimo valore è 1
118
+ if (values[values.length - 1][1] === 1) {
119
+ values.push([moment.unix(timeEnd).unix(), 0]);
120
+ }
121
+ }
122
+ return data; // stessa struttura di Influx, con values modificati
123
+ }
124
+ export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, filter, timeGroup, raw, fill, filterTag, tagInclude = FilterTagMode.Include) {
41
125
  let query;
126
+ let preStartValue = null;
127
+ // Costruzione filtro tag
128
+ let filterTagCondition = "";
129
+ if (filterTag !== undefined && filterTag !== null) {
130
+ switch (tagInclude) {
131
+ case FilterTagMode.Include:
132
+ filterTagCondition = ` AND ("d" = '${filterTag}' OR "d" !~ /./)`;
133
+ break;
134
+ case FilterTagMode.Exclude:
135
+ filterTagCondition = ` AND ("d" != '${filterTag}' OR "d" !~ /./)`;
136
+ break;
137
+ case FilterTagMode.DW:
138
+ filterTagCondition = ` AND "d" = '${filterTag}'`;
139
+ break;
140
+ }
141
+ }
42
142
  if (raw) {
43
- query = `SELECT ("value") FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' AND "valueName" = '${field}' AND time >= '${moment
143
+ query = `SELECT ("value") FROM "${influxConfig.measurement}" WHERE "${filter.field}" = '${filter.value}' AND "valueName" = '${field}'${filterTagCondition} AND time >= '${moment
44
144
  .unix(timeStart)
45
145
  .toISOString()}' AND time <= '${moment.unix(timeEnd).toISOString()}'`;
46
146
  }
47
147
  else {
48
- query = `SELECT last("value") FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' AND "valueName" = '${field}' AND time >= '${moment
148
+ query = `SELECT last("value") FROM "${influxConfig.measurement}" WHERE "${filter.field}" = '${filter.value}' AND "valueName" = '${field}'${filterTagCondition} AND time >= '${moment
49
149
  .unix(timeStart)
50
150
  .toISOString()}' AND time <= '${moment
51
151
  .unix(timeEnd)
52
- .toISOString()}' GROUP BY time(${timeGroup}) fill(null)`;
152
+ .toISOString()}' GROUP BY time(${timeGroup})`;
153
+ if (fill === "none") {
154
+ query += ` fill(none)`;
155
+ }
156
+ else if (fill === "previous") {
157
+ query += ` fill(previous)`;
158
+ }
159
+ else {
160
+ query += ` fill(null)`;
161
+ }
162
+ }
163
+ if (fill !== "null") {
164
+ // Query to get the last data point before timeStart
165
+ const preStartQuery = `SELECT last("value") FROM "${influxConfig.measurement}" WHERE "${filter.field}" = '${filter.value}' AND "valueName" = '${field}'${filterTagCondition} AND time < '${moment
166
+ .unix(timeStart)
167
+ .toISOString()}'`;
168
+ const preStartResponse = await fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${preStartQuery}`), {
169
+ headers: {
170
+ Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
171
+ }
172
+ });
173
+ if (!preStartResponse.ok) {
174
+ throw new Error(`Failed to fetch pre-start data from InfluxDB: ${preStartResponse.statusText}`);
175
+ }
176
+ const preStartData = await preStartResponse.json();
177
+ preStartValue = preStartData.results[0].series?.[0]?.values?.[0]?.[1];
53
178
  }
54
179
  const response = await fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${query}`), {
55
180
  headers: {
@@ -57,7 +182,6 @@ export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, d
57
182
  }
58
183
  });
59
184
  if (!response.ok) {
60
- console.log(response);
61
185
  throw new Error(`Failed to fetch data from InfluxDB: ${response.statusText}`);
62
186
  }
63
187
  const data = await response.json();
@@ -72,61 +196,34 @@ export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, d
72
196
  }
73
197
  ];
74
198
  }
75
- else {
76
- // Always override the name to be the field
77
- data.results[0].series.forEach((series) => {
78
- series.name = field; // Force the series name to be the field name
79
- });
80
- }
81
- return data;
82
- }
83
- export async function getManyMeasuresV1(influxConfig, fields, limit, offset, sort, deviceID, timeStart, timeEnd) {
84
- if (fields.length > 0) {
85
- const conditions = fields
86
- .map((field) => `"valueName" = '${field}'`)
87
- .join(" OR ");
88
- let queryCount = `SELECT count(*) FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' AND (${conditions})`;
89
- let queryPagination = `SELECT "valueName", "value" FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' AND (${conditions})`;
90
- if (timeStart) {
91
- queryCount += ` AND time >= '${moment.unix(timeStart).toISOString()}'`;
92
- queryPagination += ` AND time >= '${moment
93
- .unix(timeStart)
94
- .toISOString()}'`;
95
- }
96
- if (timeEnd) {
97
- queryCount += ` AND time <= '${moment.unix(timeEnd).toISOString()}'`;
98
- queryPagination += ` AND time <= '${moment.unix(timeEnd).toISOString()}'`;
99
- }
100
- if (sort && sort.field === "time") {
101
- queryPagination = `${queryPagination} ORDER BY "${sort.field}" ${sort.sort}`;
102
- }
103
- queryPagination = `${queryPagination} LIMIT ${limit} OFFSET ${offset}`;
104
- const responses = await Promise.all([
105
- fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${queryPagination}`), {
106
- headers: {
107
- Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
108
- }
109
- }),
110
- fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${queryCount}`), {
111
- headers: {
112
- Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
113
- }
114
- })
115
- ]);
116
- if (!responses[0].ok) {
117
- throw new Error(`Failed to fetch data from InfluxDB: ${responses[0].statusText}`);
199
+ // Always override the name to be the field
200
+ data.results[0].series.forEach((series) => {
201
+ series.name = field; // Force the series name to be the field name
202
+ });
203
+ // 1000000 REMOVED AND ADDED TO MOVE THE POINT AWAY IN THE CHART
204
+ if (fill !== "null") {
205
+ if (preStartValue !== null && preStartValue !== undefined) {
206
+ // Insert the pre-start value at the beginning of the dataset
207
+ data.results[0].series[0].values.unshift([
208
+ timeStart - 1000000,
209
+ preStartValue
210
+ ]);
118
211
  }
119
- const data = await responses[0].json();
120
- const count = await responses[1].json();
121
- return { data, count };
122
- }
123
- else {
124
- return null;
212
+ // Set the last point as the timeEnd and last value of the dataset
213
+ const lastSeries = data.results[0].series[0];
214
+ const lastValue = lastSeries?.values &&
215
+ lastSeries.values.length > 0 &&
216
+ lastSeries.values.slice(-1)[0].length > 1
217
+ ? lastSeries.values.slice(-1)[0][1]
218
+ : null;
219
+ data.results[0].series[0].values.push([timeEnd + 1000000, lastValue]);
125
220
  }
221
+ return data;
126
222
  }
127
- export async function getFirstTimestamp(influxConfig, deviceID) {
128
- // Query per ottenere il primo timestamp e il valore ordinato per "time" in modo crescente
129
- const query = `SELECT "time", "value" FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' ORDER BY time ASC LIMIT 1`;
223
+ export async function exportDataV1(influxConfig, field, timeStart, timeEnd, filter) {
224
+ const query = `SELECT ("value") FROM "${influxConfig.measurement}" WHERE "${filter.field}" = '${filter.value}' AND "valueName" = '${field}' AND time >= '${moment
225
+ .unix(timeStart)
226
+ .toISOString()}' AND time <= '${moment.unix(timeEnd).toISOString()}'`;
130
227
  const response = await fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${query}`), {
131
228
  headers: {
132
229
  Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
@@ -136,10 +233,22 @@ export async function getFirstTimestamp(influxConfig, deviceID) {
136
233
  throw new Error(`Failed to fetch data from InfluxDB: ${response.statusText}`);
137
234
  }
138
235
  const data = await response.json();
139
- // Verifica che ci siano risultati nella risposta
140
- if (data?.results[0]?.series && data?.results[0]?.series[0]?.values[0]?.[0]) {
141
- // Ritorna il primo timestamp
142
- return data.results[0].series[0].values[0][0];
236
+ // Ensure the name is manually set to the field
237
+ if (!data.results[0].series) {
238
+ // Set default value with null time and null value
239
+ data.results[0].series = [
240
+ {
241
+ name: field, // Manually set the series name as the field
242
+ columns: ["time", "value"],
243
+ values: [] // Set null point for time and value
244
+ }
245
+ ];
246
+ }
247
+ else {
248
+ // Always override the name to be the field
249
+ data.results[0].series.forEach((series) => {
250
+ series.name = field; // Force the series name to be the field name
251
+ });
143
252
  }
144
- return null; // Se non ci sono record, ritorna null
253
+ return data;
145
254
  }
@@ -1,19 +1,25 @@
1
+ import { TrackleDeviceType } from "../types";
1
2
  export type TrackleConfig = {
3
+ orgName: string;
2
4
  apiUrl: string;
3
- createCustomerUrl: string;
4
5
  clientId: string;
5
6
  clientSecret: string;
6
7
  tokenUrl: string;
7
8
  cookieName: string;
8
9
  cookieSecure: boolean;
9
10
  apiTimeout: number;
11
+ productID: number;
10
12
  };
11
13
  export declare function logOut(trackleConfig: TrackleConfig): Promise<void>;
12
14
  export declare function createCustomer(trackleConfig: TrackleConfig, uid: string): Promise<{
13
15
  organization: string;
14
16
  uid: string;
15
17
  }>;
16
- export declare function getDevices(trackleConfig: TrackleConfig, productId?: number, uid?: string, group?: string, selected?: string): Promise<{
18
+ export declare function removeCustomer(trackleConfig: TrackleConfig, uid: string): Promise<{
19
+ organization: string;
20
+ uid: string;
21
+ }>;
22
+ export declare function getDevices(trackleConfig: TrackleConfig, productId?: number, uid?: string, query?: string): Promise<{
17
23
  devices: any[];
18
24
  }>;
19
25
  export declare function getDevice(trackleConfig: TrackleConfig, id: string, productId?: number, uid?: string): Promise<{
@@ -31,5 +37,5 @@ export declare function post(trackleConfig: TrackleConfig, id: string, endpoint:
31
37
  export declare function put(trackleConfig: TrackleConfig, id: string, endpoint: string, value: any, productId?: number, uid?: string): Promise<{
32
38
  return_value: number;
33
39
  }>;
34
- export declare function addDevicesToGroup(trackleConfig: TrackleConfig, productId: number, uid: string, group: string, devicesToPatch: any[]): Promise<string[]>;
35
- export declare function removeDevicesFromGroup(trackleConfig: TrackleConfig, productId: number, uid: string, group: string, devicesToPatch: any[]): Promise<string[]>;
40
+ export declare function addDevicesToGroup(trackleConfig: TrackleConfig, productId: number, uid: string, group: string, devicesToPatch: TrackleDeviceType[]): Promise<TrackleDeviceType[]>;
41
+ export declare function removeDevicesFromGroup(trackleConfig: TrackleConfig, productId: number, uid: string, group: string, devicesToPatch: TrackleDeviceType[]): Promise<TrackleDeviceType[]>;
@@ -48,34 +48,35 @@ export async function logOut(trackleConfig) {
48
48
  cookies().delete(trackleConfig.cookieName);
49
49
  }
50
50
  export async function createCustomer(trackleConfig, uid) {
51
- return await wretch(trackleConfig.createCustomerUrl)
51
+ return await wretch(`${trackleConfig.apiUrl}/orgs/${trackleConfig.orgName}/customers`)
52
52
  .headers({
53
53
  Authorization: `Basic ${btoa(`${trackleConfig.clientId}:${trackleConfig.clientSecret}`)}`
54
54
  })
55
55
  .post({ uid })
56
56
  .json();
57
57
  }
58
- export async function getDevices(trackleConfig, productId, uid, group, selected) {
59
- let queryParams = "last_handshake_at!=null";
60
- if (group !== "all") {
61
- queryParams = `last_handshake_at!=null&state.groups=/${group}/`;
62
- if (!uid) {
63
- queryParams += "&quarantined=false";
64
- }
58
+ export async function removeCustomer(trackleConfig, uid) {
59
+ return await wretch(`${trackleConfig.apiUrl}/orgs/${trackleConfig.orgName}/customers/${uid}`)
60
+ .headers({
61
+ Authorization: `Basic ${btoa(`${trackleConfig.clientId}:${trackleConfig.clientSecret}`)}`
62
+ })
63
+ .delete().json();
64
+ }
65
+ export async function getDevices(trackleConfig, productId, uid, query) {
66
+ const api = uid ? wretchApi(trackleConfig, uid) : wretchApi(trackleConfig);
67
+ let response;
68
+ try {
69
+ response = await api
70
+ .get(uid
71
+ ? `/devices${query ? "?" + query : ""}`
72
+ : `/products/${productId}/devices${query ? "?" + query : ""}`)
73
+ .setTimeout(trackleConfig.apiTimeout)
74
+ .json();
65
75
  }
66
- else if (selected !== "all") {
67
- queryParams = `last_handshake_at!=null&state.groups!=/${selected}/`;
68
- if (!uid) {
69
- queryParams += "&quarantined=false";
70
- }
76
+ catch (error) {
77
+ console.error("Error fetching devices:", error);
78
+ throw error;
71
79
  }
72
- const api = uid ? wretchApi(trackleConfig, uid) : wretchApi(trackleConfig);
73
- const response = await api
74
- .get(uid
75
- ? `/devices?${queryParams}`
76
- : `/products/${productId}/devices?${queryParams}`)
77
- .setTimeout(trackleConfig.apiTimeout)
78
- .json();
79
80
  return (uid ? { devices: response } : response);
80
81
  }
81
82
  export async function getDevice(trackleConfig, id, productId, uid) {
@@ -123,7 +124,9 @@ export async function put(trackleConfig, id, endpoint, value, productId, uid) {
123
124
  export async function addDevicesToGroup(trackleConfig, productId, uid, group, devicesToPatch) {
124
125
  const devicesPatched = [];
125
126
  for (const device of devicesToPatch) {
126
- const newGroups = device?.groups && device?.groups instanceof Array ? device?.groups : [];
127
+ const newGroups = device.state?.groups && device.state?.groups instanceof Array
128
+ ? device.state?.groups
129
+ : [];
127
130
  if (!newGroups.includes(group)) {
128
131
  newGroups.push(group);
129
132
  await wretchApi(trackleConfig, uid)
@@ -133,7 +136,7 @@ export async function addDevicesToGroup(trackleConfig, productId, uid, group, de
133
136
  })
134
137
  .setTimeout(trackleConfig.apiTimeout)
135
138
  .res();
136
- devicesPatched.push(device.id);
139
+ devicesPatched.push(device);
137
140
  }
138
141
  }
139
142
  return devicesPatched;
@@ -141,7 +144,9 @@ export async function addDevicesToGroup(trackleConfig, productId, uid, group, de
141
144
  export async function removeDevicesFromGroup(trackleConfig, productId, uid, group, devicesToPatch) {
142
145
  const devicesPatched = [];
143
146
  for (const device of devicesToPatch) {
144
- let newGroups = device?.groups && device?.groups instanceof Array ? device?.groups : [];
147
+ let newGroups = device.state?.groups && device.state?.groups instanceof Array
148
+ ? device.state?.groups
149
+ : [];
145
150
  if (newGroups.includes(group)) {
146
151
  newGroups = newGroups.filter((newGroup) => newGroup !== group);
147
152
  await wretchApi(trackleConfig, uid)
@@ -151,7 +156,7 @@ export async function removeDevicesFromGroup(trackleConfig, productId, uid, grou
151
156
  })
152
157
  .setTimeout(trackleConfig.apiTimeout)
153
158
  .res();
154
- devicesPatched.push(device.id);
159
+ devicesPatched.push(device);
155
160
  }
156
161
  }
157
162
  return devicesPatched;
@@ -0,0 +1,16 @@
1
+ export type InfluxConfig = {
2
+ url: string;
3
+ accessToken: string;
4
+ bucket: string;
5
+ orgId: string;
6
+ measurement: string;
7
+ dbName: string;
8
+ username: string;
9
+ password: string;
10
+ };
11
+ export declare enum FilterTagMode {
12
+ Include = "include",// include tag + quelli senza tag
13
+ Exclude = "exclude",// esclude il tag
14
+ DW = "dw"
15
+ }
16
+ export type InfluxFillType = "null" | "none" | "previous";
@@ -0,0 +1,6 @@
1
+ export var FilterTagMode;
2
+ (function (FilterTagMode) {
3
+ FilterTagMode["Include"] = "include";
4
+ FilterTagMode["Exclude"] = "exclude";
5
+ FilterTagMode["DW"] = "dw"; // solo esattamente quel tag
6
+ })(FilterTagMode || (FilterTagMode = {}));
@@ -0,0 +1,19 @@
1
+ export type AssetType = {
2
+ id: string;
3
+ device?: TrackleDeviceType;
4
+ [key: string]: any;
5
+ };
6
+ export type TrackleDeviceType = {
7
+ id: string;
8
+ state: {
9
+ groups: string[] | null;
10
+ };
11
+ managers: string[] | null;
12
+ [key: string]: any;
13
+ };
14
+ export type DevicePositionType = {
15
+ deviceID: string;
16
+ name: string;
17
+ lat: number;
18
+ lng: number;
19
+ };
@@ -0,0 +1 @@
1
+ export {};
package/types/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./user";
2
+ export * from "./device";
package/types/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./user";
2
+ export * from "./device";
package/types/user.d.ts CHANGED
@@ -4,6 +4,7 @@ export type UserType = {
4
4
  name: string;
5
5
  picture?: string;
6
6
  role: string;
7
+ demo?: any;
7
8
  lastSignInAt?: number;
8
9
  firstname?: string;
9
10
  lastname?: string;