@adventurelabs/scout-core 1.4.69 → 1.4.71

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.
@@ -0,0 +1,5 @@
1
+ import { Database } from "../types/supabase";
2
+ import { IHerdAllowedDomain } from "../types/db";
3
+ import { IWebResponseCompatible } from "../types/requests";
4
+ import { SupabaseClient } from "@supabase/supabase-js";
5
+ export declare function server_get_herd_allowed_domains(herd_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdAllowedDomain[]>>;
@@ -0,0 +1,15 @@
1
+ "use server";
2
+ import { newServerClient } from "../supabase/server";
3
+ import { IWebResponse } from "../types/requests";
4
+ export async function server_get_herd_allowed_domains(herd_id, supabaseClient) {
5
+ const supabase = supabaseClient ?? (await newServerClient());
6
+ const { data, error } = await supabase
7
+ .from("herd_allowed_domains")
8
+ .select("*")
9
+ .eq("herd_id", herd_id)
10
+ .order("domain", { ascending: true });
11
+ if (error) {
12
+ return IWebResponse.error(error.message).to_compatible();
13
+ }
14
+ return IWebResponse.success(data ?? []).to_compatible();
15
+ }
@@ -7,5 +7,8 @@ export declare function get_herds(client: SupabaseClient<Database>): Promise<IWe
7
7
  export declare function get_herds_with_location(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdPrettyLocation[]>>;
8
8
  export declare function get_herd_by_slug(slug: string): Promise<IWebResponseCompatible<IHerd>>;
9
9
  export declare function deleteHerd(herd_id: number): Promise<IWebResponseCompatible<boolean>>;
10
- export declare function createHerd(newHerd: any): Promise<IWebResponseCompatible<boolean>>;
10
+ export declare function createHerd(newHerd: Omit<IHerd, "id" | "inserted_at"> & {
11
+ id?: number;
12
+ inserted_at?: string;
13
+ }): Promise<IWebResponseCompatible<boolean>>;
11
14
  export declare function server_load_herd_modules(): Promise<IHerdModulesResponseWithStatus>;
@@ -66,11 +66,7 @@ export async function deleteHerd(herd_id) {
66
66
  }
67
67
  export async function createHerd(newHerd) {
68
68
  const supabase = await newServerClient();
69
- const user = await supabase.auth.getUser();
70
- const userId = user?.data?.user?.id;
71
- newHerd.created_by = userId;
72
- // strip id field from herd object
73
- const { data, error } = await supabase.from("herds").insert([newHerd]);
69
+ const { error } = await supabase.from("herds").insert([newHerd]);
74
70
  if (error) {
75
71
  return {
76
72
  status: EnumWebResponse.ERROR,
@@ -0,0 +1,8 @@
1
+ import { Database } from "../types/supabase";
2
+ import { IHerdInvitation, Role } from "../types/db";
3
+ import { IWebResponseCompatible } from "../types/requests";
4
+ import { SupabaseClient } from "@supabase/supabase-js";
5
+ export declare function server_create_herd_invitation(herd_id: number, email: string, role: Role, expires_at?: string | null): Promise<IWebResponseCompatible<IHerdInvitation | null>>;
6
+ export declare function accept_herd_invitations_for_current_user(invitation_ids: number[], supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
7
+ export declare function server_get_herd_invitations_for_current_user(): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
8
+ export declare function server_get_herd_invitations_by_herd(herd_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
@@ -0,0 +1,47 @@
1
+ "use server";
2
+ import { newServerClient } from "../supabase/server";
3
+ import { IWebResponse } from "../types/requests";
4
+ export async function server_create_herd_invitation(herd_id, email, role, expires_at) {
5
+ const supabase = await newServerClient();
6
+ const { data, error } = await supabase.rpc("create_herd_invitation", {
7
+ p_herd_id: herd_id,
8
+ p_email: email,
9
+ p_role: role,
10
+ p_expires_at: expires_at ?? undefined,
11
+ });
12
+ if (error) {
13
+ return IWebResponse.error(error.message).to_compatible();
14
+ }
15
+ return IWebResponse.success(data).to_compatible();
16
+ }
17
+ export async function accept_herd_invitations_for_current_user(invitation_ids, supabaseClient) {
18
+ if (invitation_ids.length === 0) {
19
+ return IWebResponse.error("At least one invitation id is required").to_compatible();
20
+ }
21
+ const supabase = supabaseClient ?? (await newServerClient());
22
+ const { data, error } = await supabase.rpc("accept_herd_invitations_for_current_user", { p_invitation_ids: invitation_ids });
23
+ if (error) {
24
+ return IWebResponse.error(error.message).to_compatible();
25
+ }
26
+ return IWebResponse.success(data ?? []).to_compatible();
27
+ }
28
+ export async function server_get_herd_invitations_for_current_user() {
29
+ const supabase = await newServerClient();
30
+ const { data, error } = await supabase.rpc("get_herd_invitations_for_current_user");
31
+ if (error) {
32
+ return IWebResponse.error(error.message).to_compatible();
33
+ }
34
+ return IWebResponse.success(data ?? []).to_compatible();
35
+ }
36
+ export async function server_get_herd_invitations_by_herd(herd_id, supabaseClient) {
37
+ const supabase = supabaseClient ?? (await newServerClient());
38
+ const { data, error } = await supabase
39
+ .from("herd_invitations")
40
+ .select("*")
41
+ .eq("herd_id", herd_id)
42
+ .order("created_at", { ascending: false });
43
+ if (error) {
44
+ return IWebResponse.error(error.message).to_compatible();
45
+ }
46
+ return IWebResponse.success(data ?? []).to_compatible();
47
+ }
@@ -1,14 +1,18 @@
1
1
  import { SupabaseClient } from "@supabase/supabase-js";
2
2
  import { Database } from "../types/supabase";
3
- import { EntityLifecycle, IArtifact, IDeviceRow, IEvent, IPart, ISession, IUserProfileRow } from "../types/db";
3
+ import { EntityLifecycle, IArtifact, IDeviceRow, IEvent, IHerdAllowedDomain, IPart, ISession, IUserProfileRow, IUserRolePerHerd } from "../types/db";
4
4
  import { IWebResponseCompatible } from "../types/requests";
5
5
  export interface LifecycleUpdateOptions {
6
6
  lifecycle_reason?: string | null;
7
7
  lifecycle_changed_by?: string | null;
8
8
  }
9
+ /** Matches DB auto-generated reason when an allowed domain is paused. */
10
+ export declare const AUTO_GENERATED_ALLOWED_DOMAIN_INACTIVE_REASON: "auto_generated_allowed_domain_inactive";
9
11
  export declare function update_user_lifecycle(client: SupabaseClient<Database>, user_id: string, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IUserProfileRow | null>>;
10
12
  export declare function update_device_lifecycle(client: SupabaseClient<Database>, device_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IDeviceRow | null>>;
11
13
  export declare function update_session_lifecycle(client: SupabaseClient<Database>, session_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<ISession | null>>;
12
14
  export declare function update_part_lifecycle(client: SupabaseClient<Database>, part_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IPart | null>>;
13
15
  export declare function update_event_lifecycle(client: SupabaseClient<Database>, event_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IEvent | null>>;
14
16
  export declare function update_artifact_lifecycle(client: SupabaseClient<Database>, artifact_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IArtifact | null>>;
17
+ export declare function update_user_role_per_herd_lifecycle(client: SupabaseClient<Database>, membership_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IUserRolePerHerd | null>>;
18
+ export declare function update_herd_allowed_domain_lifecycle(client: SupabaseClient<Database>, domain_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<IWebResponseCompatible<IHerdAllowedDomain | null>>;
@@ -1,4 +1,6 @@
1
1
  import { IWebResponse } from "../types/requests";
2
+ /** Matches DB auto-generated reason when an allowed domain is paused. */
3
+ export const AUTO_GENERATED_ALLOWED_DOMAIN_INACTIVE_REASON = "auto_generated_allowed_domain_inactive";
2
4
  function build_lifecycle_patch(lifecycle, options) {
3
5
  const patch = { lifecycle };
4
6
  if (options && "lifecycle_reason" in options) {
@@ -72,3 +74,21 @@ export async function update_artifact_lifecycle(client, artifact_id, lifecycle,
72
74
  .single();
73
75
  return lifecycle_result(data, error, "Artifact not found or lifecycle update failed");
74
76
  }
77
+ export async function update_user_role_per_herd_lifecycle(client, membership_id, lifecycle, options) {
78
+ const { data, error } = await client
79
+ .from("users_roles_per_herd")
80
+ .update(build_lifecycle_patch(lifecycle, options))
81
+ .eq("id", membership_id)
82
+ .select("*")
83
+ .single();
84
+ return lifecycle_result(data, error, "Herd membership not found or lifecycle update failed");
85
+ }
86
+ export async function update_herd_allowed_domain_lifecycle(client, domain_id, lifecycle, options) {
87
+ const { data, error } = await client
88
+ .from("herd_allowed_domains")
89
+ .update(build_lifecycle_patch(lifecycle, options))
90
+ .eq("id", domain_id)
91
+ .select("*")
92
+ .single();
93
+ return lifecycle_result(data, error, "Allowed domain not found or lifecycle update failed");
94
+ }
@@ -1,7 +1,10 @@
1
- import { IUser, IUserAndRole, IUserRolePerHerd, Role } from "../types/db";
1
+ import { IUser, IUserAndRole, IUserProfileRow, IUserRolePerHerd, Role } from "../types/db";
2
2
  import { IWebResponseCompatible } from "../types/requests";
3
3
  import { SupabaseClient } from "@supabase/supabase-js";
4
+ import { Database } from "../types/supabase";
4
5
  export declare function server_get_user_roles(herd_id: number): Promise<IWebResponseCompatible<IUserRolePerHerd[]>>;
5
6
  export declare function server_get_user(): Promise<IWebResponseCompatible<IUser | null>>;
6
7
  export declare function server_get_users_with_herd_access(herd_id: number, supabaseClient?: SupabaseClient): Promise<IWebResponseCompatible<IUserAndRole[]>>;
7
8
  export declare function server_upsert_user_with_role(herd_id: number, username: string, role: Role): Promise<IWebResponseCompatible<IUserAndRole | null>>;
9
+ export type UserProfileUpdate = Database["public"]["Tables"]["users"]["Update"];
10
+ export declare function update_user_profile(client: SupabaseClient<Database>, user_id: string, patch: UserProfileUpdate): Promise<IWebResponseCompatible<IUserProfileRow | null>>;
@@ -31,7 +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 (*)
34
+ users!users_roles_per_herd_user_id_fkey (*)
35
35
  `)
36
36
  .eq("herd_id", herd_id);
37
37
  if (error) {
@@ -74,3 +74,18 @@ export async function server_upsert_user_with_role(herd_id, username, role) {
74
74
  }
75
75
  return IWebResponse.success({ user, role }).to_compatible();
76
76
  }
77
+ export async function update_user_profile(client, user_id, patch) {
78
+ const { data, error } = await client
79
+ .from("users")
80
+ .update(patch)
81
+ .eq("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("User not found or profile update failed").to_compatible();
89
+ }
90
+ return IWebResponse.success(data).to_compatible();
91
+ }
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ export * from "./helpers/tags";
36
36
  export * from "./helpers/time";
37
37
  export * from "./helpers/ui";
38
38
  export * from "./helpers/users";
39
+ export * from "./helpers/invitations";
40
+ export * from "./helpers/herd_allowed_domains";
39
41
  export * from "./helpers/web";
40
42
  export * from "./helpers/zones";
41
43
  export * from "./helpers/storage";
@@ -51,6 +53,7 @@ export * from "./helpers/operators";
51
53
  export * from "./helpers/versions_software";
52
54
  export * from "./helpers/versions_software_server";
53
55
  export * from "./helpers/parts";
56
+ export * from "./helpers/lifecycle";
54
57
  export * from "./helpers/storagePath";
55
58
  export * from "./hooks/useScoutRealtimeConnectivity";
56
59
  export * from "./hooks/useScoutRealtimeDevices";
@@ -73,5 +76,5 @@ export * from "./supabase/middleware";
73
76
  export * from "./supabase/server";
74
77
  export * from "./api_keys/actions";
75
78
  export type { HerdModule, IHerdModule } from "./types/herd_module";
76
- 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";
79
+ export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, ICredential, CredentialInsert, CredentialUpdate, ICertificate, CertificateInsert, CertificateUpdate, IUserAndRole, IUserProfileRow, IHerdInvitation, IHerdAllowedDomain, IUserRolePerHerd, HerdInvitationStatus, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, IAnalysisJob, IAnalysisTask, AnalysisWorkStatus, } from "./types/db";
77
80
  export { EnumSessionsVisibility } from "./types/events";
package/dist/index.js CHANGED
@@ -39,6 +39,8 @@ export * from "./helpers/tags";
39
39
  export * from "./helpers/time";
40
40
  export * from "./helpers/ui";
41
41
  export * from "./helpers/users";
42
+ export * from "./helpers/invitations";
43
+ export * from "./helpers/herd_allowed_domains";
42
44
  export * from "./helpers/web";
43
45
  export * from "./helpers/zones";
44
46
  export * from "./helpers/storage";
@@ -54,6 +56,7 @@ export * from "./helpers/operators";
54
56
  export * from "./helpers/versions_software";
55
57
  export * from "./helpers/versions_software_server";
56
58
  export * from "./helpers/parts";
59
+ export * from "./helpers/lifecycle";
57
60
  export * from "./helpers/storagePath";
58
61
  // Hooks
59
62
  export * from "./hooks/useScoutRealtimeConnectivity";
@@ -749,11 +749,103 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
749
749
  referencedColumns: ["id"];
750
750
  }];
751
751
  };
752
+ herd_allowed_domains: {
753
+ Row: {
754
+ created_at: string;
755
+ domain: string;
756
+ herd_id: number;
757
+ id: number;
758
+ lifecycle: Database["public"]["Enums"]["entity_lifecycle"];
759
+ lifecycle_changed_at: string;
760
+ lifecycle_changed_by: string | null;
761
+ lifecycle_reason: string | null;
762
+ };
763
+ Insert: {
764
+ created_at?: string;
765
+ domain: string;
766
+ herd_id: number;
767
+ id?: number;
768
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
769
+ lifecycle_changed_at?: string;
770
+ lifecycle_changed_by?: string | null;
771
+ lifecycle_reason?: string | null;
772
+ };
773
+ Update: {
774
+ created_at?: string;
775
+ domain?: string;
776
+ herd_id?: number;
777
+ id?: number;
778
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
779
+ lifecycle_changed_at?: string;
780
+ lifecycle_changed_by?: string | null;
781
+ lifecycle_reason?: string | null;
782
+ };
783
+ Relationships: [{
784
+ foreignKeyName: "herd_allowed_domains_herd_id_fkey";
785
+ columns: ["herd_id"];
786
+ isOneToOne: false;
787
+ referencedRelation: "herds";
788
+ referencedColumns: ["id"];
789
+ }, {
790
+ foreignKeyName: "herd_allowed_domains_lifecycle_changed_by_fkey";
791
+ columns: ["lifecycle_changed_by"];
792
+ isOneToOne: false;
793
+ referencedRelation: "users";
794
+ referencedColumns: ["id"];
795
+ }];
796
+ };
797
+ herd_invitations: {
798
+ Row: {
799
+ accepted_at: string | null;
800
+ created_at: string;
801
+ email: string;
802
+ expires_at: string | null;
803
+ herd_id: number;
804
+ id: number;
805
+ invited_by: string;
806
+ role: Database["public"]["Enums"]["role"];
807
+ status: Database["public"]["Enums"]["herd_invitation_status"];
808
+ };
809
+ Insert: {
810
+ accepted_at?: string | null;
811
+ created_at?: string;
812
+ email: string;
813
+ expires_at?: string | null;
814
+ herd_id: number;
815
+ id?: number;
816
+ invited_by: string;
817
+ role: Database["public"]["Enums"]["role"];
818
+ status?: Database["public"]["Enums"]["herd_invitation_status"];
819
+ };
820
+ Update: {
821
+ accepted_at?: string | null;
822
+ created_at?: string;
823
+ email?: string;
824
+ expires_at?: string | null;
825
+ herd_id?: number;
826
+ id?: number;
827
+ invited_by?: string;
828
+ role?: Database["public"]["Enums"]["role"];
829
+ status?: Database["public"]["Enums"]["herd_invitation_status"];
830
+ };
831
+ Relationships: [{
832
+ foreignKeyName: "herd_invitations_herd_id_fkey";
833
+ columns: ["herd_id"];
834
+ isOneToOne: false;
835
+ referencedRelation: "herds";
836
+ referencedColumns: ["id"];
837
+ }, {
838
+ foreignKeyName: "herd_invitations_invited_by_fkey";
839
+ columns: ["invited_by"];
840
+ isOneToOne: false;
841
+ referencedRelation: "users";
842
+ referencedColumns: ["id"];
843
+ }];
844
+ };
752
845
  herds: {
753
846
  Row: {
754
847
  auto_delete_media_with_humans: boolean | null;
755
848
  auto_delete_media_with_no_tracks: boolean | null;
756
- created_by: string;
757
849
  description: string;
758
850
  earthranger_domain: string | null;
759
851
  earthranger_token: string | null;
@@ -769,7 +861,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
769
861
  Insert: {
770
862
  auto_delete_media_with_humans?: boolean | null;
771
863
  auto_delete_media_with_no_tracks?: boolean | null;
772
- created_by: string;
773
864
  description: string;
774
865
  earthranger_domain?: string | null;
775
866
  earthranger_token?: string | null;
@@ -785,7 +876,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
785
876
  Update: {
786
877
  auto_delete_media_with_humans?: boolean | null;
787
878
  auto_delete_media_with_no_tracks?: boolean | null;
788
- created_by?: string;
789
879
  description?: string;
790
880
  earthranger_domain?: string | null;
791
881
  earthranger_token?: string | null;
@@ -798,13 +888,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
798
888
  video_server_url?: string | null;
799
889
  video_subscriber_token?: string | null;
800
890
  };
801
- Relationships: [{
802
- foreignKeyName: "herds_created_by_fkey";
803
- columns: ["created_by"];
804
- isOneToOne: false;
805
- referencedRelation: "users";
806
- referencedColumns: ["id"];
807
- }];
891
+ Relationships: [];
808
892
  };
809
893
  layers: {
810
894
  Row: {
@@ -1522,6 +1606,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1522
1606
  herd_id: number;
1523
1607
  id: number;
1524
1608
  inserted_at: string;
1609
+ lifecycle: Database["public"]["Enums"]["entity_lifecycle"];
1610
+ lifecycle_changed_at: string;
1611
+ lifecycle_changed_by: string | null;
1612
+ lifecycle_reason: string | null;
1525
1613
  role: Database["public"]["Enums"]["role"];
1526
1614
  user_id: string;
1527
1615
  };
@@ -1529,6 +1617,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1529
1617
  herd_id: number;
1530
1618
  id?: number;
1531
1619
  inserted_at?: string;
1620
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
1621
+ lifecycle_changed_at?: string;
1622
+ lifecycle_changed_by?: string | null;
1623
+ lifecycle_reason?: string | null;
1532
1624
  role: Database["public"]["Enums"]["role"];
1533
1625
  user_id: string;
1534
1626
  };
@@ -1536,6 +1628,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1536
1628
  herd_id?: number;
1537
1629
  id?: number;
1538
1630
  inserted_at?: string;
1631
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
1632
+ lifecycle_changed_at?: string;
1633
+ lifecycle_changed_by?: string | null;
1634
+ lifecycle_reason?: string | null;
1539
1635
  role?: Database["public"]["Enums"]["role"];
1540
1636
  user_id?: string;
1541
1637
  };
@@ -1545,6 +1641,12 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1545
1641
  isOneToOne: false;
1546
1642
  referencedRelation: "herds";
1547
1643
  referencedColumns: ["id"];
1644
+ }, {
1645
+ foreignKeyName: "users_roles_per_herd_lifecycle_changed_by_fkey";
1646
+ columns: ["lifecycle_changed_by"];
1647
+ isOneToOne: false;
1648
+ referencedRelation: "users";
1649
+ referencedColumns: ["id"];
1548
1650
  }, {
1549
1651
  foreignKeyName: "users_roles_per_herd_user_id_fkey";
1550
1652
  columns: ["user_id"];
@@ -1732,6 +1834,28 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1732
1834
  };
1733
1835
  };
1734
1836
  Functions: {
1837
+ accept_herd_invitations_for_current_user: {
1838
+ Args: {
1839
+ p_invitation_ids: number[];
1840
+ };
1841
+ Returns: {
1842
+ accepted_at: string | null;
1843
+ created_at: string;
1844
+ email: string;
1845
+ expires_at: string | null;
1846
+ herd_id: number;
1847
+ id: number;
1848
+ invited_by: string;
1849
+ role: Database["public"]["Enums"]["role"];
1850
+ status: Database["public"]["Enums"]["herd_invitation_status"];
1851
+ }[];
1852
+ SetofOptions: {
1853
+ from: "*";
1854
+ to: "herd_invitations";
1855
+ isOneToOne: false;
1856
+ isSetofReturn: true;
1857
+ };
1858
+ };
1735
1859
  ack_queue_message: {
1736
1860
  Args: {
1737
1861
  message_id: number;
@@ -1782,6 +1906,31 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1782
1906
  table_name: string;
1783
1907
  }[];
1784
1908
  };
1909
+ create_herd_invitation: {
1910
+ Args: {
1911
+ p_email: string;
1912
+ p_expires_at?: string;
1913
+ p_herd_id: number;
1914
+ p_role: Database["public"]["Enums"]["role"];
1915
+ };
1916
+ Returns: {
1917
+ accepted_at: string | null;
1918
+ created_at: string;
1919
+ email: string;
1920
+ expires_at: string | null;
1921
+ herd_id: number;
1922
+ id: number;
1923
+ invited_by: string;
1924
+ role: Database["public"]["Enums"]["role"];
1925
+ status: Database["public"]["Enums"]["herd_invitation_status"];
1926
+ };
1927
+ SetofOptions: {
1928
+ from: "*";
1929
+ to: "herd_invitations";
1930
+ isOneToOne: true;
1931
+ isSetofReturn: false;
1932
+ };
1933
+ };
1785
1934
  delete_all_orphaned_sessions: {
1786
1935
  Args: {
1787
1936
  min_age_seconds?: number;
@@ -1808,6 +1957,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1808
1957
  timestamp_start: string;
1809
1958
  }[];
1810
1959
  };
1960
+ expire_herd_invitations: {
1961
+ Args: never;
1962
+ Returns: number;
1963
+ };
1811
1964
  fix_all_sessions_missing_distance: {
1812
1965
  Args: never;
1813
1966
  Returns: {
@@ -2510,6 +2663,26 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
2510
2663
  min_value: number;
2511
2664
  }[];
2512
2665
  };
2666
+ get_herd_invitations_for_current_user: {
2667
+ Args: never;
2668
+ Returns: {
2669
+ accepted_at: string | null;
2670
+ created_at: string;
2671
+ email: string;
2672
+ expires_at: string | null;
2673
+ herd_id: number;
2674
+ id: number;
2675
+ invited_by: string;
2676
+ role: Database["public"]["Enums"]["role"];
2677
+ status: Database["public"]["Enums"]["herd_invitation_status"];
2678
+ }[];
2679
+ SetofOptions: {
2680
+ from: "*";
2681
+ to: "herd_invitations";
2682
+ isOneToOne: false;
2683
+ isSetofReturn: true;
2684
+ };
2685
+ };
2513
2686
  get_herd_uptime_summary: {
2514
2687
  Args: {
2515
2688
  p_device_types?: Database["public"]["Enums"]["device_type"][];
@@ -3001,6 +3174,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
3001
3174
  app_permission: "herds.delete" | "events.delete";
3002
3175
  device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown" | "gps_tracker_vehicle" | "gps_tracker_person" | "radio_mesh_base_station_gateway";
3003
3176
  entity_lifecycle: "active" | "retired" | "deleted";
3177
+ herd_invitation_status: "pending" | "accepted" | "revoked" | "expired";
3004
3178
  media_type: "image" | "video" | "audio" | "text";
3005
3179
  plan_type: "mission" | "fence" | "rally" | "markov";
3006
3180
  role: "admin" | "editor" | "viewer";
@@ -3150,7 +3324,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
3150
3324
  inserted_at: string | null;
3151
3325
  slug: string | null;
3152
3326
  description: string | null;
3153
- created_by: string | null;
3154
3327
  is_public: boolean | null;
3155
3328
  earthranger_domain: string | null;
3156
3329
  earthranger_token: string | null;
@@ -27,6 +27,9 @@ export type ILayer = Database["public"]["Tables"]["layers"]["Row"];
27
27
  export type IAction = Database["public"]["Tables"]["actions"]["Row"];
28
28
  export type IZone = Database["public"]["Tables"]["zones"]["Row"];
29
29
  export type IUserRolePerHerd = Database["public"]["Tables"]["users_roles_per_herd"]["Row"];
30
+ export type IHerdInvitation = Database["public"]["Tables"]["herd_invitations"]["Row"];
31
+ export type IHerdAllowedDomain = Database["public"]["Tables"]["herd_allowed_domains"]["Row"];
32
+ export type HerdInvitationStatus = Database["public"]["Enums"]["herd_invitation_status"];
30
33
  export type IHerd = Database["public"]["Tables"]["herds"]["Row"];
31
34
  export type ISession = Database["public"]["Tables"]["sessions"]["Row"];
32
35
  export type IConnectivity = Database["public"]["Tables"]["connectivity"]["Row"];
@@ -785,11 +785,109 @@ export type Database = {
785
785
  }
786
786
  ];
787
787
  };
788
+ herd_allowed_domains: {
789
+ Row: {
790
+ created_at: string;
791
+ domain: string;
792
+ herd_id: number;
793
+ id: number;
794
+ lifecycle: Database["public"]["Enums"]["entity_lifecycle"];
795
+ lifecycle_changed_at: string;
796
+ lifecycle_changed_by: string | null;
797
+ lifecycle_reason: string | null;
798
+ };
799
+ Insert: {
800
+ created_at?: string;
801
+ domain: string;
802
+ herd_id: number;
803
+ id?: number;
804
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
805
+ lifecycle_changed_at?: string;
806
+ lifecycle_changed_by?: string | null;
807
+ lifecycle_reason?: string | null;
808
+ };
809
+ Update: {
810
+ created_at?: string;
811
+ domain?: string;
812
+ herd_id?: number;
813
+ id?: number;
814
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
815
+ lifecycle_changed_at?: string;
816
+ lifecycle_changed_by?: string | null;
817
+ lifecycle_reason?: string | null;
818
+ };
819
+ Relationships: [
820
+ {
821
+ foreignKeyName: "herd_allowed_domains_herd_id_fkey";
822
+ columns: ["herd_id"];
823
+ isOneToOne: false;
824
+ referencedRelation: "herds";
825
+ referencedColumns: ["id"];
826
+ },
827
+ {
828
+ foreignKeyName: "herd_allowed_domains_lifecycle_changed_by_fkey";
829
+ columns: ["lifecycle_changed_by"];
830
+ isOneToOne: false;
831
+ referencedRelation: "users";
832
+ referencedColumns: ["id"];
833
+ }
834
+ ];
835
+ };
836
+ herd_invitations: {
837
+ Row: {
838
+ accepted_at: string | null;
839
+ created_at: string;
840
+ email: string;
841
+ expires_at: string | null;
842
+ herd_id: number;
843
+ id: number;
844
+ invited_by: string;
845
+ role: Database["public"]["Enums"]["role"];
846
+ status: Database["public"]["Enums"]["herd_invitation_status"];
847
+ };
848
+ Insert: {
849
+ accepted_at?: string | null;
850
+ created_at?: string;
851
+ email: string;
852
+ expires_at?: string | null;
853
+ herd_id: number;
854
+ id?: number;
855
+ invited_by: string;
856
+ role: Database["public"]["Enums"]["role"];
857
+ status?: Database["public"]["Enums"]["herd_invitation_status"];
858
+ };
859
+ Update: {
860
+ accepted_at?: string | null;
861
+ created_at?: string;
862
+ email?: string;
863
+ expires_at?: string | null;
864
+ herd_id?: number;
865
+ id?: number;
866
+ invited_by?: string;
867
+ role?: Database["public"]["Enums"]["role"];
868
+ status?: Database["public"]["Enums"]["herd_invitation_status"];
869
+ };
870
+ Relationships: [
871
+ {
872
+ foreignKeyName: "herd_invitations_herd_id_fkey";
873
+ columns: ["herd_id"];
874
+ isOneToOne: false;
875
+ referencedRelation: "herds";
876
+ referencedColumns: ["id"];
877
+ },
878
+ {
879
+ foreignKeyName: "herd_invitations_invited_by_fkey";
880
+ columns: ["invited_by"];
881
+ isOneToOne: false;
882
+ referencedRelation: "users";
883
+ referencedColumns: ["id"];
884
+ }
885
+ ];
886
+ };
788
887
  herds: {
789
888
  Row: {
790
889
  auto_delete_media_with_humans: boolean | null;
791
890
  auto_delete_media_with_no_tracks: boolean | null;
792
- created_by: string;
793
891
  description: string;
794
892
  earthranger_domain: string | null;
795
893
  earthranger_token: string | null;
@@ -805,7 +903,6 @@ export type Database = {
805
903
  Insert: {
806
904
  auto_delete_media_with_humans?: boolean | null;
807
905
  auto_delete_media_with_no_tracks?: boolean | null;
808
- created_by: string;
809
906
  description: string;
810
907
  earthranger_domain?: string | null;
811
908
  earthranger_token?: string | null;
@@ -821,7 +918,6 @@ export type Database = {
821
918
  Update: {
822
919
  auto_delete_media_with_humans?: boolean | null;
823
920
  auto_delete_media_with_no_tracks?: boolean | null;
824
- created_by?: string;
825
921
  description?: string;
826
922
  earthranger_domain?: string | null;
827
923
  earthranger_token?: string | null;
@@ -834,15 +930,7 @@ export type Database = {
834
930
  video_server_url?: string | null;
835
931
  video_subscriber_token?: string | null;
836
932
  };
837
- Relationships: [
838
- {
839
- foreignKeyName: "herds_created_by_fkey";
840
- columns: ["created_by"];
841
- isOneToOne: false;
842
- referencedRelation: "users";
843
- referencedColumns: ["id"];
844
- }
845
- ];
933
+ Relationships: [];
846
934
  };
847
935
  layers: {
848
936
  Row: {
@@ -1599,6 +1687,10 @@ export type Database = {
1599
1687
  herd_id: number;
1600
1688
  id: number;
1601
1689
  inserted_at: string;
1690
+ lifecycle: Database["public"]["Enums"]["entity_lifecycle"];
1691
+ lifecycle_changed_at: string;
1692
+ lifecycle_changed_by: string | null;
1693
+ lifecycle_reason: string | null;
1602
1694
  role: Database["public"]["Enums"]["role"];
1603
1695
  user_id: string;
1604
1696
  };
@@ -1606,6 +1698,10 @@ export type Database = {
1606
1698
  herd_id: number;
1607
1699
  id?: number;
1608
1700
  inserted_at?: string;
1701
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
1702
+ lifecycle_changed_at?: string;
1703
+ lifecycle_changed_by?: string | null;
1704
+ lifecycle_reason?: string | null;
1609
1705
  role: Database["public"]["Enums"]["role"];
1610
1706
  user_id: string;
1611
1707
  };
@@ -1613,6 +1709,10 @@ export type Database = {
1613
1709
  herd_id?: number;
1614
1710
  id?: number;
1615
1711
  inserted_at?: string;
1712
+ lifecycle?: Database["public"]["Enums"]["entity_lifecycle"];
1713
+ lifecycle_changed_at?: string;
1714
+ lifecycle_changed_by?: string | null;
1715
+ lifecycle_reason?: string | null;
1616
1716
  role?: Database["public"]["Enums"]["role"];
1617
1717
  user_id?: string;
1618
1718
  };
@@ -1624,6 +1724,13 @@ export type Database = {
1624
1724
  referencedRelation: "herds";
1625
1725
  referencedColumns: ["id"];
1626
1726
  },
1727
+ {
1728
+ foreignKeyName: "users_roles_per_herd_lifecycle_changed_by_fkey";
1729
+ columns: ["lifecycle_changed_by"];
1730
+ isOneToOne: false;
1731
+ referencedRelation: "users";
1732
+ referencedColumns: ["id"];
1733
+ },
1627
1734
  {
1628
1735
  foreignKeyName: "users_roles_per_herd_user_id_fkey";
1629
1736
  columns: ["user_id"];
@@ -1824,6 +1931,28 @@ export type Database = {
1824
1931
  };
1825
1932
  };
1826
1933
  Functions: {
1934
+ accept_herd_invitations_for_current_user: {
1935
+ Args: {
1936
+ p_invitation_ids: number[];
1937
+ };
1938
+ Returns: {
1939
+ accepted_at: string | null;
1940
+ created_at: string;
1941
+ email: string;
1942
+ expires_at: string | null;
1943
+ herd_id: number;
1944
+ id: number;
1945
+ invited_by: string;
1946
+ role: Database["public"]["Enums"]["role"];
1947
+ status: Database["public"]["Enums"]["herd_invitation_status"];
1948
+ }[];
1949
+ SetofOptions: {
1950
+ from: "*";
1951
+ to: "herd_invitations";
1952
+ isOneToOne: false;
1953
+ isSetofReturn: true;
1954
+ };
1955
+ };
1827
1956
  ack_queue_message: {
1828
1957
  Args: {
1829
1958
  message_id: number;
@@ -1874,6 +2003,31 @@ export type Database = {
1874
2003
  table_name: string;
1875
2004
  }[];
1876
2005
  };
2006
+ create_herd_invitation: {
2007
+ Args: {
2008
+ p_email: string;
2009
+ p_expires_at?: string;
2010
+ p_herd_id: number;
2011
+ p_role: Database["public"]["Enums"]["role"];
2012
+ };
2013
+ Returns: {
2014
+ accepted_at: string | null;
2015
+ created_at: string;
2016
+ email: string;
2017
+ expires_at: string | null;
2018
+ herd_id: number;
2019
+ id: number;
2020
+ invited_by: string;
2021
+ role: Database["public"]["Enums"]["role"];
2022
+ status: Database["public"]["Enums"]["herd_invitation_status"];
2023
+ };
2024
+ SetofOptions: {
2025
+ from: "*";
2026
+ to: "herd_invitations";
2027
+ isOneToOne: true;
2028
+ isSetofReturn: false;
2029
+ };
2030
+ };
1877
2031
  delete_all_orphaned_sessions: {
1878
2032
  Args: {
1879
2033
  min_age_seconds?: number;
@@ -1900,6 +2054,10 @@ export type Database = {
1900
2054
  timestamp_start: string;
1901
2055
  }[];
1902
2056
  };
2057
+ expire_herd_invitations: {
2058
+ Args: never;
2059
+ Returns: number;
2060
+ };
1903
2061
  fix_all_sessions_missing_distance: {
1904
2062
  Args: never;
1905
2063
  Returns: {
@@ -2602,6 +2760,26 @@ export type Database = {
2602
2760
  min_value: number;
2603
2761
  }[];
2604
2762
  };
2763
+ get_herd_invitations_for_current_user: {
2764
+ Args: never;
2765
+ Returns: {
2766
+ accepted_at: string | null;
2767
+ created_at: string;
2768
+ email: string;
2769
+ expires_at: string | null;
2770
+ herd_id: number;
2771
+ id: number;
2772
+ invited_by: string;
2773
+ role: Database["public"]["Enums"]["role"];
2774
+ status: Database["public"]["Enums"]["herd_invitation_status"];
2775
+ }[];
2776
+ SetofOptions: {
2777
+ from: "*";
2778
+ to: "herd_invitations";
2779
+ isOneToOne: false;
2780
+ isSetofReturn: true;
2781
+ };
2782
+ };
2605
2783
  get_herd_uptime_summary: {
2606
2784
  Args: {
2607
2785
  p_device_types?: Database["public"]["Enums"]["device_type"][];
@@ -3093,6 +3271,7 @@ export type Database = {
3093
3271
  app_permission: "herds.delete" | "events.delete";
3094
3272
  device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown" | "gps_tracker_vehicle" | "gps_tracker_person" | "radio_mesh_base_station_gateway";
3095
3273
  entity_lifecycle: "active" | "retired" | "deleted";
3274
+ herd_invitation_status: "pending" | "accepted" | "revoked" | "expired";
3096
3275
  media_type: "image" | "video" | "audio" | "text";
3097
3276
  plan_type: "mission" | "fence" | "rally" | "markov";
3098
3277
  role: "admin" | "editor" | "viewer";
@@ -3242,7 +3421,6 @@ export type Database = {
3242
3421
  inserted_at: string | null;
3243
3422
  slug: string | null;
3244
3423
  description: string | null;
3245
- created_by: string | null;
3246
3424
  is_public: boolean | null;
3247
3425
  earthranger_domain: string | null;
3248
3426
  earthranger_token: string | null;
@@ -3408,6 +3586,7 @@ export declare const Constants: {
3408
3586
  readonly app_permission: readonly ["herds.delete", "events.delete"];
3409
3587
  readonly device_type: readonly ["trail_camera", "drone_fixed_wing", "drone_quad", "gps_tracker", "sentry_tower", "smart_buoy", "radio_mesh_base_station", "radio_mesh_repeater", "unknown", "gps_tracker_vehicle", "gps_tracker_person", "radio_mesh_base_station_gateway"];
3410
3588
  readonly entity_lifecycle: readonly ["active", "retired", "deleted"];
3589
+ readonly herd_invitation_status: readonly ["pending", "accepted", "revoked", "expired"];
3411
3590
  readonly media_type: readonly ["image", "video", "audio", "text"];
3412
3591
  readonly plan_type: readonly ["mission", "fence", "rally", "markov"];
3413
3592
  readonly role: readonly ["admin", "editor", "viewer"];
@@ -24,6 +24,7 @@ export const Constants = {
24
24
  "radio_mesh_base_station_gateway",
25
25
  ],
26
26
  entity_lifecycle: ["active", "retired", "deleted"],
27
+ herd_invitation_status: ["pending", "accepted", "revoked", "expired"],
27
28
  media_type: ["image", "video", "audio", "text"],
28
29
  plan_type: ["mission", "fence", "rally", "markov"],
29
30
  role: ["admin", "editor", "viewer"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.4.69",
3
+ "version": "1.4.71",
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",