@adventurelabs/scout-core 1.4.64 → 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/users.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/providers/ScoutRefreshProvider.d.ts +9 -0
- package/dist/types/db.d.ts +4 -1
- package/dist/types/supabase.d.ts +9 -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/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";
|
|
@@ -1367,17 +1367,26 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1367
1367
|
users: {
|
|
1368
1368
|
Row: {
|
|
1369
1369
|
earthranger_id: string | null;
|
|
1370
|
+
first: string | null;
|
|
1370
1371
|
id: string;
|
|
1372
|
+
last: string | null;
|
|
1373
|
+
title: string | null;
|
|
1371
1374
|
username: string | null;
|
|
1372
1375
|
};
|
|
1373
1376
|
Insert: {
|
|
1374
1377
|
earthranger_id?: string | null;
|
|
1378
|
+
first?: string | null;
|
|
1375
1379
|
id: string;
|
|
1380
|
+
last?: string | null;
|
|
1381
|
+
title?: string | null;
|
|
1376
1382
|
username?: string | null;
|
|
1377
1383
|
};
|
|
1378
1384
|
Update: {
|
|
1379
1385
|
earthranger_id?: string | null;
|
|
1386
|
+
first?: string | null;
|
|
1380
1387
|
id?: string;
|
|
1388
|
+
last?: string | null;
|
|
1389
|
+
title?: string | null;
|
|
1381
1390
|
username?: string | null;
|
|
1382
1391
|
};
|
|
1383
1392
|
Relationships: [];
|
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,7 +128,7 @@ export interface IEventWithSession extends IEvent {
|
|
|
125
128
|
session: ISession | null;
|
|
126
129
|
}
|
|
127
130
|
export type IUserAndRole = {
|
|
128
|
-
user: Pick<Database["public"]["Tables"]["users"]["Row"], "id" | "username" | "earthranger_id"> | null;
|
|
131
|
+
user: Pick<Database["public"]["Tables"]["users"]["Row"], "id" | "username" | "earthranger_id" | "first" | "last" | "title"> | null;
|
|
129
132
|
role: Role;
|
|
130
133
|
};
|
|
131
134
|
export interface IApiKeyScout {
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -1437,17 +1437,26 @@ export type Database = {
|
|
|
1437
1437
|
users: {
|
|
1438
1438
|
Row: {
|
|
1439
1439
|
earthranger_id: string | null;
|
|
1440
|
+
first: string | null;
|
|
1440
1441
|
id: string;
|
|
1442
|
+
last: string | null;
|
|
1443
|
+
title: string | null;
|
|
1441
1444
|
username: string | null;
|
|
1442
1445
|
};
|
|
1443
1446
|
Insert: {
|
|
1444
1447
|
earthranger_id?: string | null;
|
|
1448
|
+
first?: string | null;
|
|
1445
1449
|
id: string;
|
|
1450
|
+
last?: string | null;
|
|
1451
|
+
title?: string | null;
|
|
1446
1452
|
username?: string | null;
|
|
1447
1453
|
};
|
|
1448
1454
|
Update: {
|
|
1449
1455
|
earthranger_id?: string | null;
|
|
1456
|
+
first?: string | null;
|
|
1450
1457
|
id?: string;
|
|
1458
|
+
last?: string | null;
|
|
1459
|
+
title?: string | null;
|
|
1451
1460
|
username?: string | null;
|
|
1452
1461
|
};
|
|
1453
1462
|
Relationships: [];
|