@adventurelabs/scout-core 1.4.63 → 1.4.65
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/helpers/credentials.d.ts +9 -0
- package/dist/helpers/credentials.js +92 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/tags.js +7 -7
- package/dist/helpers/users.js +5 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/providers/ScoutRefreshProvider.d.ts +20 -0
- package/dist/types/db.d.ts +4 -4
- package/dist/types/supabase.d.ts +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Database } from "../types/supabase";
|
|
2
|
+
import { CredentialInsert, CredentialUpdate, ICredential } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
5
|
+
export declare function get_credentials_by_user_id(client: SupabaseClient<Database>, user_id: string): Promise<IWebResponseCompatible<ICredential[]>>;
|
|
6
|
+
export declare function get_credential_by_id(client: SupabaseClient<Database>, credential_id: number, user_id: string): Promise<IWebResponseCompatible<ICredential | null>>;
|
|
7
|
+
export declare function create_credential(client: SupabaseClient<Database>, row: CredentialInsert): Promise<IWebResponseCompatible<ICredential | null>>;
|
|
8
|
+
export declare function update_credential(client: SupabaseClient<Database>, credential_id: number, user_id: string, patch: CredentialUpdate): Promise<IWebResponseCompatible<ICredential | null>>;
|
|
9
|
+
export declare function delete_credential(client: SupabaseClient<Database>, credential_id: number, user_id: string): Promise<IWebResponseCompatible<ICredential | null>>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IWebResponse } from "../types/requests";
|
|
2
|
+
export async function get_credentials_by_user_id(client, user_id) {
|
|
3
|
+
const { data, error } = await client
|
|
4
|
+
.from("credentials")
|
|
5
|
+
.select("*")
|
|
6
|
+
.eq("user_id", user_id)
|
|
7
|
+
.order("created_at", { ascending: false });
|
|
8
|
+
if (error) {
|
|
9
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
10
|
+
}
|
|
11
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
12
|
+
}
|
|
13
|
+
export async function get_credential_by_id(client, credential_id, user_id) {
|
|
14
|
+
const { data, error } = await client
|
|
15
|
+
.from("credentials")
|
|
16
|
+
.select("*")
|
|
17
|
+
.eq("id", credential_id)
|
|
18
|
+
.eq("user_id", user_id)
|
|
19
|
+
.single();
|
|
20
|
+
if (error) {
|
|
21
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
22
|
+
}
|
|
23
|
+
if (!data) {
|
|
24
|
+
return IWebResponse.error("Credential not found")
|
|
25
|
+
.to_compatible();
|
|
26
|
+
}
|
|
27
|
+
return IWebResponse.success(data).to_compatible();
|
|
28
|
+
}
|
|
29
|
+
export async function create_credential(client, row) {
|
|
30
|
+
if (!row.user_id) {
|
|
31
|
+
return IWebResponse.error("user_id is required")
|
|
32
|
+
.to_compatible();
|
|
33
|
+
}
|
|
34
|
+
if (!row.issuer?.trim()) {
|
|
35
|
+
return IWebResponse.error("issuer is required")
|
|
36
|
+
.to_compatible();
|
|
37
|
+
}
|
|
38
|
+
if (!row.type?.trim()) {
|
|
39
|
+
return IWebResponse.error("type is required")
|
|
40
|
+
.to_compatible();
|
|
41
|
+
}
|
|
42
|
+
const { data, error } = await client
|
|
43
|
+
.from("credentials")
|
|
44
|
+
.insert([row])
|
|
45
|
+
.select("*")
|
|
46
|
+
.single();
|
|
47
|
+
if (error) {
|
|
48
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
49
|
+
}
|
|
50
|
+
if (!data) {
|
|
51
|
+
return IWebResponse.error("Failed to create credential").to_compatible();
|
|
52
|
+
}
|
|
53
|
+
return IWebResponse.success(data).to_compatible();
|
|
54
|
+
}
|
|
55
|
+
export async function update_credential(client, credential_id, user_id, patch) {
|
|
56
|
+
const { id: _id, user_id: _uid, created_at: _ca, ...updateData } = patch;
|
|
57
|
+
if (Object.keys(updateData).length === 0) {
|
|
58
|
+
return IWebResponse.error("No valid fields to update").to_compatible();
|
|
59
|
+
}
|
|
60
|
+
const { data, error } = await client
|
|
61
|
+
.from("credentials")
|
|
62
|
+
.update(updateData)
|
|
63
|
+
.eq("id", credential_id)
|
|
64
|
+
.eq("user_id", user_id)
|
|
65
|
+
.select("*")
|
|
66
|
+
.single();
|
|
67
|
+
if (error) {
|
|
68
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
69
|
+
}
|
|
70
|
+
if (!data) {
|
|
71
|
+
return IWebResponse.error("Credential not found")
|
|
72
|
+
.to_compatible();
|
|
73
|
+
}
|
|
74
|
+
return IWebResponse.success(data).to_compatible();
|
|
75
|
+
}
|
|
76
|
+
export async function delete_credential(client, credential_id, user_id) {
|
|
77
|
+
const { data, error } = await client
|
|
78
|
+
.from("credentials")
|
|
79
|
+
.delete()
|
|
80
|
+
.eq("id", credential_id)
|
|
81
|
+
.eq("user_id", user_id)
|
|
82
|
+
.select("*")
|
|
83
|
+
.single();
|
|
84
|
+
if (error) {
|
|
85
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
86
|
+
}
|
|
87
|
+
if (!data) {
|
|
88
|
+
return IWebResponse.error("Credential not found")
|
|
89
|
+
.to_compatible();
|
|
90
|
+
}
|
|
91
|
+
return IWebResponse.success(data).to_compatible();
|
|
92
|
+
}
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
package/dist/helpers/tags.js
CHANGED
|
@@ -124,16 +124,11 @@ export async function server_update_tags(tags) {
|
|
|
124
124
|
// Update each tag individually since we need to preserve the id
|
|
125
125
|
const updatedTags = [];
|
|
126
126
|
for (const tag of tags) {
|
|
127
|
-
const { id, ...updateData } = tag;
|
|
127
|
+
const { id, inserted_at: _ignoredInsertedAt, ...updateData } = tag;
|
|
128
128
|
const { data, error } = await supabase
|
|
129
129
|
.from("tags")
|
|
130
130
|
.update({
|
|
131
|
-
|
|
132
|
-
y: updateData.y,
|
|
133
|
-
width: updateData.width,
|
|
134
|
-
height: updateData.height,
|
|
135
|
-
class: updateData.class,
|
|
136
|
-
conf: updateData.conf,
|
|
131
|
+
...updateData,
|
|
137
132
|
observation_type: updateData.observation_type,
|
|
138
133
|
})
|
|
139
134
|
.eq("id", id)
|
|
@@ -291,6 +286,9 @@ export async function server_get_events_and_tags_for_devices_batch(device_ids, l
|
|
|
291
286
|
earthranger_url: row.earthranger_url,
|
|
292
287
|
herd_id: row.herd_id,
|
|
293
288
|
tags: Array.isArray(row.tags) ? row.tags : [],
|
|
289
|
+
embedded_at: row.embedded_at ?? null,
|
|
290
|
+
segmented_at: row.segmented_at ?? null,
|
|
291
|
+
tagged_at: row.tagged_at ?? null,
|
|
294
292
|
};
|
|
295
293
|
eventsByDevice[device_id].push(event);
|
|
296
294
|
});
|
|
@@ -452,6 +450,8 @@ export async function get_event_and_tags_by_event_id(event_id) {
|
|
|
452
450
|
subject_latitude: subjectLat,
|
|
453
451
|
subject_longitude: subjectLon,
|
|
454
452
|
subject_id: tag.subject_id ?? null,
|
|
453
|
+
score: tag.score ?? null,
|
|
454
|
+
score_source: tag.score_source ?? null,
|
|
455
455
|
};
|
|
456
456
|
}),
|
|
457
457
|
earthranger_url: data[0].earthranger_url,
|
package/dist/helpers/users.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./helpers/auth";
|
|
|
16
16
|
export * from "./helpers/bounding_boxes";
|
|
17
17
|
export * from "./helpers/chat";
|
|
18
18
|
export * from "./helpers/connectivity";
|
|
19
|
+
export * from "./helpers/credentials";
|
|
19
20
|
export * from "./helpers/db";
|
|
20
21
|
export * from "./helpers/devices";
|
|
21
22
|
export * from "./helpers/email";
|
|
@@ -68,5 +69,5 @@ export * from "./supabase/middleware";
|
|
|
68
69
|
export * from "./supabase/server";
|
|
69
70
|
export * from "./api_keys/actions";
|
|
70
71
|
export type { HerdModule, IHerdModule } from "./types/herd_module";
|
|
71
|
-
export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, IUserAndRole, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, IAnalysisJob, IAnalysisTask, AnalysisWorkStatus, } from "./types/db";
|
|
72
|
+
export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, ICredential, CredentialInsert, CredentialUpdate, IUserAndRole, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, IAnalysisJob, IAnalysisTask, AnalysisWorkStatus, } from "./types/db";
|
|
72
73
|
export { EnumSessionsVisibility } from "./types/events";
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./helpers/auth";
|
|
|
19
19
|
export * from "./helpers/bounding_boxes";
|
|
20
20
|
export * from "./helpers/chat";
|
|
21
21
|
export * from "./helpers/connectivity";
|
|
22
|
+
export * from "./helpers/credentials";
|
|
22
23
|
export * from "./helpers/db";
|
|
23
24
|
export * from "./helpers/devices";
|
|
24
25
|
export * from "./helpers/email";
|
|
@@ -1267,6 +1267,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1267
1267
|
origin_location: unknown;
|
|
1268
1268
|
origin_pitch: number | null;
|
|
1269
1269
|
origin_roll: number | null;
|
|
1270
|
+
score: number | null;
|
|
1271
|
+
score_source: string | null;
|
|
1270
1272
|
sensor_pitch: number | null;
|
|
1271
1273
|
sensor_roll: number | null;
|
|
1272
1274
|
sensor_yaw: number | null;
|
|
@@ -1294,6 +1296,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1294
1296
|
origin_location?: unknown;
|
|
1295
1297
|
origin_pitch?: number | null;
|
|
1296
1298
|
origin_roll?: number | null;
|
|
1299
|
+
score?: number | null;
|
|
1300
|
+
score_source?: string | null;
|
|
1297
1301
|
sensor_pitch?: number | null;
|
|
1298
1302
|
sensor_roll?: number | null;
|
|
1299
1303
|
sensor_yaw?: number | null;
|
|
@@ -1321,6 +1325,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1321
1325
|
origin_location?: unknown;
|
|
1322
1326
|
origin_pitch?: number | null;
|
|
1323
1327
|
origin_roll?: number | null;
|
|
1328
|
+
score?: number | null;
|
|
1329
|
+
score_source?: string | null;
|
|
1324
1330
|
sensor_pitch?: number | null;
|
|
1325
1331
|
sensor_roll?: number | null;
|
|
1326
1332
|
sensor_yaw?: number | null;
|
|
@@ -1360,15 +1366,27 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1360
1366
|
};
|
|
1361
1367
|
users: {
|
|
1362
1368
|
Row: {
|
|
1369
|
+
earthranger_id: string | null;
|
|
1370
|
+
first: string | null;
|
|
1363
1371
|
id: string;
|
|
1372
|
+
last: string | null;
|
|
1373
|
+
title: string | null;
|
|
1364
1374
|
username: string | null;
|
|
1365
1375
|
};
|
|
1366
1376
|
Insert: {
|
|
1377
|
+
earthranger_id?: string | null;
|
|
1378
|
+
first?: string | null;
|
|
1367
1379
|
id: string;
|
|
1380
|
+
last?: string | null;
|
|
1381
|
+
title?: string | null;
|
|
1368
1382
|
username?: string | null;
|
|
1369
1383
|
};
|
|
1370
1384
|
Update: {
|
|
1385
|
+
earthranger_id?: string | null;
|
|
1386
|
+
first?: string | null;
|
|
1371
1387
|
id?: string;
|
|
1388
|
+
last?: string | null;
|
|
1389
|
+
title?: string | null;
|
|
1372
1390
|
username?: string | null;
|
|
1373
1391
|
};
|
|
1374
1392
|
Relationships: [];
|
|
@@ -3030,6 +3048,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
3030
3048
|
subject_latitude: number | null;
|
|
3031
3049
|
subject_longitude: number | null;
|
|
3032
3050
|
subject_id: number | null;
|
|
3051
|
+
score: number | null;
|
|
3052
|
+
score_source: string | null;
|
|
3033
3053
|
};
|
|
3034
3054
|
zones_and_actions_pretty_location: {
|
|
3035
3055
|
id: number | null;
|
package/dist/types/db.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type IOperator = Database["public"]["Tables"]["operators"]["Row"];
|
|
|
30
30
|
export type IObservation = Database["public"]["Tables"]["observations"]["Row"];
|
|
31
31
|
export type IProvider = Database["public"]["Tables"]["providers"]["Row"];
|
|
32
32
|
export type IPart = Database["public"]["Tables"]["parts"]["Row"];
|
|
33
|
+
export type ICredential = Database["public"]["Tables"]["credentials"]["Row"];
|
|
33
34
|
export type IVersionsSoftware = Database["public"]["Tables"]["versions_software"]["Row"];
|
|
34
35
|
export type IArtifact = Database["public"]["Tables"]["artifacts"]["Row"];
|
|
35
36
|
export type IHealthMetric = Database["public"]["Tables"]["health_metrics"]["Row"];
|
|
@@ -69,6 +70,8 @@ export interface ISessionSummary {
|
|
|
69
70
|
}
|
|
70
71
|
export type ISessionUsageOverTime = Database["public"]["Functions"]["get_session_usage_over_time"]["Returns"];
|
|
71
72
|
export type PartInsert = Database["public"]["Tables"]["parts"]["Insert"];
|
|
73
|
+
export type CredentialInsert = Database["public"]["Tables"]["credentials"]["Insert"];
|
|
74
|
+
export type CredentialUpdate = Database["public"]["Tables"]["credentials"]["Update"];
|
|
72
75
|
export type VersionsSoftwareInsert = Database["public"]["Tables"]["versions_software"]["Insert"];
|
|
73
76
|
export type ArtifactInsert = Database["public"]["Tables"]["artifacts"]["Insert"];
|
|
74
77
|
export type ArtifactUpdate = Database["public"]["Tables"]["artifacts"]["Update"];
|
|
@@ -125,10 +128,7 @@ export interface IEventWithSession extends IEvent {
|
|
|
125
128
|
session: ISession | null;
|
|
126
129
|
}
|
|
127
130
|
export type IUserAndRole = {
|
|
128
|
-
user:
|
|
129
|
-
id: string;
|
|
130
|
-
username: string | null;
|
|
131
|
-
} | null;
|
|
131
|
+
user: Pick<Database["public"]["Tables"]["users"]["Row"], "id" | "username" | "earthranger_id" | "first" | "last" | "title"> | null;
|
|
132
132
|
role: Role;
|
|
133
133
|
};
|
|
134
134
|
export interface IApiKeyScout {
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -1332,6 +1332,8 @@ export type Database = {
|
|
|
1332
1332
|
origin_location: unknown;
|
|
1333
1333
|
origin_pitch: number | null;
|
|
1334
1334
|
origin_roll: number | null;
|
|
1335
|
+
score: number | null;
|
|
1336
|
+
score_source: string | null;
|
|
1335
1337
|
sensor_pitch: number | null;
|
|
1336
1338
|
sensor_roll: number | null;
|
|
1337
1339
|
sensor_yaw: number | null;
|
|
@@ -1359,6 +1361,8 @@ export type Database = {
|
|
|
1359
1361
|
origin_location?: unknown;
|
|
1360
1362
|
origin_pitch?: number | null;
|
|
1361
1363
|
origin_roll?: number | null;
|
|
1364
|
+
score?: number | null;
|
|
1365
|
+
score_source?: string | null;
|
|
1362
1366
|
sensor_pitch?: number | null;
|
|
1363
1367
|
sensor_roll?: number | null;
|
|
1364
1368
|
sensor_yaw?: number | null;
|
|
@@ -1386,6 +1390,8 @@ export type Database = {
|
|
|
1386
1390
|
origin_location?: unknown;
|
|
1387
1391
|
origin_pitch?: number | null;
|
|
1388
1392
|
origin_roll?: number | null;
|
|
1393
|
+
score?: number | null;
|
|
1394
|
+
score_source?: string | null;
|
|
1389
1395
|
sensor_pitch?: number | null;
|
|
1390
1396
|
sensor_roll?: number | null;
|
|
1391
1397
|
sensor_yaw?: number | null;
|
|
@@ -1430,15 +1436,27 @@ export type Database = {
|
|
|
1430
1436
|
};
|
|
1431
1437
|
users: {
|
|
1432
1438
|
Row: {
|
|
1439
|
+
earthranger_id: string | null;
|
|
1440
|
+
first: string | null;
|
|
1433
1441
|
id: string;
|
|
1442
|
+
last: string | null;
|
|
1443
|
+
title: string | null;
|
|
1434
1444
|
username: string | null;
|
|
1435
1445
|
};
|
|
1436
1446
|
Insert: {
|
|
1447
|
+
earthranger_id?: string | null;
|
|
1448
|
+
first?: string | null;
|
|
1437
1449
|
id: string;
|
|
1450
|
+
last?: string | null;
|
|
1451
|
+
title?: string | null;
|
|
1438
1452
|
username?: string | null;
|
|
1439
1453
|
};
|
|
1440
1454
|
Update: {
|
|
1455
|
+
earthranger_id?: string | null;
|
|
1456
|
+
first?: string | null;
|
|
1441
1457
|
id?: string;
|
|
1458
|
+
last?: string | null;
|
|
1459
|
+
title?: string | null;
|
|
1442
1460
|
username?: string | null;
|
|
1443
1461
|
};
|
|
1444
1462
|
Relationships: [];
|
|
@@ -3115,6 +3133,8 @@ export type Database = {
|
|
|
3115
3133
|
subject_latitude: number | null;
|
|
3116
3134
|
subject_longitude: number | null;
|
|
3117
3135
|
subject_id: number | null;
|
|
3136
|
+
score: number | null;
|
|
3137
|
+
score_source: string | null;
|
|
3118
3138
|
};
|
|
3119
3139
|
zones_and_actions_pretty_location: {
|
|
3120
3140
|
id: number | null;
|