@adventurelabs/scout-core 1.4.66 → 1.4.67

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.
@@ -31,14 +31,7 @@ export async function server_get_users_with_herd_access(herd_id, supabaseClient)
31
31
  .from("users_roles_per_herd")
32
32
  .select(`
33
33
  role,
34
- users (
35
- id,
36
- username,
37
- earthranger_id,
38
- first,
39
- last,
40
- title
41
- )
34
+ users (*)
42
35
  `)
43
36
  .eq("herd_id", herd_id);
44
37
  if (error) {
@@ -49,7 +42,6 @@ export async function server_get_users_with_herd_access(herd_id, supabaseClient)
49
42
  };
50
43
  }
51
44
  else {
52
- // Transform the data to match IUserAndRole interface
53
45
  const transformedData = data.map((item) => ({
54
46
  user: item.users,
55
47
  role: item.role,
@@ -76,12 +68,9 @@ export async function server_upsert_user_with_role(herd_id, username, role) {
76
68
  herd_id: herd_id,
77
69
  role: role,
78
70
  };
79
- // upddate or insert user role
80
- const { data, error } = await supabase
81
- .from("users_roles_per_herd")
82
- .upsert(newRoleForDb);
71
+ const { error } = await supabase.from("users_roles_per_herd").upsert(newRoleForDb);
83
72
  if (error) {
84
73
  return IWebResponse.error("Unable to update or add user with provided username. Ensure you have sufficient permissions.").to_compatible();
85
74
  }
86
- return IWebResponse.success(data).to_compatible();
75
+ return IWebResponse.success({ user, role }).to_compatible();
87
76
  }
package/dist/index.d.ts CHANGED
@@ -70,5 +70,5 @@ export * from "./supabase/middleware";
70
70
  export * from "./supabase/server";
71
71
  export * from "./api_keys/actions";
72
72
  export type { HerdModule, IHerdModule } from "./types/herd_module";
73
- export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, ICredential, CredentialInsert, CredentialUpdate, ICertificate, CertificateInsert, CertificateUpdate, IUserAndRole, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, IAnalysisJob, IAnalysisTask, AnalysisWorkStatus, } from "./types/db";
73
+ export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, ICredential, CredentialInsert, CredentialUpdate, ICertificate, CertificateInsert, CertificateUpdate, IUserAndRole, IUserProfileRow, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, IAnalysisJob, IAnalysisTask, AnalysisWorkStatus, } from "./types/db";
74
74
  export { EnumSessionsVisibility } from "./types/events";
@@ -1366,26 +1366,32 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1366
1366
  };
1367
1367
  users: {
1368
1368
  Row: {
1369
+ auto_approve_sessions: boolean;
1369
1370
  earthranger_id: string | null;
1370
1371
  first: string | null;
1371
1372
  id: string;
1372
1373
  last: string | null;
1374
+ signature_base64: string | null;
1373
1375
  title: string | null;
1374
1376
  username: string | null;
1375
1377
  };
1376
1378
  Insert: {
1379
+ auto_approve_sessions?: boolean;
1377
1380
  earthranger_id?: string | null;
1378
1381
  first?: string | null;
1379
1382
  id: string;
1380
1383
  last?: string | null;
1384
+ signature_base64?: string | null;
1381
1385
  title?: string | null;
1382
1386
  username?: string | null;
1383
1387
  };
1384
1388
  Update: {
1389
+ auto_approve_sessions?: boolean;
1385
1390
  earthranger_id?: string | null;
1386
1391
  first?: string | null;
1387
1392
  id?: string;
1388
1393
  last?: string | null;
1394
+ signature_base64?: string | null;
1389
1395
  title?: string | null;
1390
1396
  username?: string | null;
1391
1397
  };
@@ -6,7 +6,10 @@ export type DeviceType = Database["public"]["Enums"]["device_type"];
6
6
  export type MediaType = Database["public"]["Enums"]["media_type"];
7
7
  export type TagObservationType = Database["public"]["Enums"]["tag_observation_type"];
8
8
  export type AnalysisWorkStatus = Database["public"]["Enums"]["analysis_work_status"];
9
+ /** Supabase Auth user (`auth.getUser()`); not `public.users`. */
9
10
  export type IUser = User;
11
+ /** Full `public.users` profile row (generated from DB). */
12
+ export type IUserProfileRow = Database["public"]["Tables"]["users"]["Row"];
10
13
  export type IDevice = Database["public"]["CompositeTypes"]["device_pretty_location"] & {
11
14
  api_keys_scout?: IApiKeyScout[];
12
15
  parts?: IPart[];
@@ -131,7 +134,7 @@ export interface IEventWithSession extends IEvent {
131
134
  session: ISession | null;
132
135
  }
133
136
  export type IUserAndRole = {
134
- user: Pick<Database["public"]["Tables"]["users"]["Row"], "id" | "username" | "earthranger_id" | "first" | "last" | "title"> | null;
137
+ user: IUserProfileRow | null;
135
138
  role: Role;
136
139
  };
137
140
  export interface IApiKeyScout {
@@ -1436,26 +1436,32 @@ export type Database = {
1436
1436
  };
1437
1437
  users: {
1438
1438
  Row: {
1439
+ auto_approve_sessions: boolean;
1439
1440
  earthranger_id: string | null;
1440
1441
  first: string | null;
1441
1442
  id: string;
1442
1443
  last: string | null;
1444
+ signature_base64: string | null;
1443
1445
  title: string | null;
1444
1446
  username: string | null;
1445
1447
  };
1446
1448
  Insert: {
1449
+ auto_approve_sessions?: boolean;
1447
1450
  earthranger_id?: string | null;
1448
1451
  first?: string | null;
1449
1452
  id: string;
1450
1453
  last?: string | null;
1454
+ signature_base64?: string | null;
1451
1455
  title?: string | null;
1452
1456
  username?: string | null;
1453
1457
  };
1454
1458
  Update: {
1459
+ auto_approve_sessions?: boolean;
1455
1460
  earthranger_id?: string | null;
1456
1461
  first?: string | null;
1457
1462
  id?: string;
1458
1463
  last?: string | null;
1464
+ signature_base64?: string | null;
1459
1465
  title?: string | null;
1460
1466
  username?: string | null;
1461
1467
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.4.66",
3
+ "version": "1.4.67",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",