@adventurelabs/scout-core 1.4.70 → 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.
|
@@ -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
|
+
}
|
package/dist/helpers/users.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export * from "./helpers/operators";
|
|
|
53
53
|
export * from "./helpers/versions_software";
|
|
54
54
|
export * from "./helpers/versions_software_server";
|
|
55
55
|
export * from "./helpers/parts";
|
|
56
|
+
export * from "./helpers/lifecycle";
|
|
56
57
|
export * from "./helpers/storagePath";
|
|
57
58
|
export * from "./hooks/useScoutRealtimeConnectivity";
|
|
58
59
|
export * from "./hooks/useScoutRealtimeDevices";
|
|
@@ -75,5 +76,5 @@ export * from "./supabase/middleware";
|
|
|
75
76
|
export * from "./supabase/server";
|
|
76
77
|
export * from "./api_keys/actions";
|
|
77
78
|
export type { HerdModule, IHerdModule } from "./types/herd_module";
|
|
78
|
-
export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, ICredential, CredentialInsert, CredentialUpdate, ICertificate, CertificateInsert, CertificateUpdate, IUserAndRole, IUserProfileRow, IHerdInvitation, IHerdAllowedDomain, HerdInvitationStatus, 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";
|
|
79
80
|
export { EnumSessionsVisibility } from "./types/events";
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,7 @@ export * from "./helpers/operators";
|
|
|
56
56
|
export * from "./helpers/versions_software";
|
|
57
57
|
export * from "./helpers/versions_software_server";
|
|
58
58
|
export * from "./helpers/parts";
|
|
59
|
+
export * from "./helpers/lifecycle";
|
|
59
60
|
export * from "./helpers/storagePath";
|
|
60
61
|
// Hooks
|
|
61
62
|
export * from "./hooks/useScoutRealtimeConnectivity";
|
|
@@ -755,18 +755,30 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
755
755
|
domain: string;
|
|
756
756
|
herd_id: number;
|
|
757
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;
|
|
758
762
|
};
|
|
759
763
|
Insert: {
|
|
760
764
|
created_at?: string;
|
|
761
765
|
domain: string;
|
|
762
766
|
herd_id: number;
|
|
763
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;
|
|
764
772
|
};
|
|
765
773
|
Update: {
|
|
766
774
|
created_at?: string;
|
|
767
775
|
domain?: string;
|
|
768
776
|
herd_id?: number;
|
|
769
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;
|
|
770
782
|
};
|
|
771
783
|
Relationships: [{
|
|
772
784
|
foreignKeyName: "herd_allowed_domains_herd_id_fkey";
|
|
@@ -774,6 +786,12 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
774
786
|
isOneToOne: false;
|
|
775
787
|
referencedRelation: "herds";
|
|
776
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"];
|
|
777
795
|
}];
|
|
778
796
|
};
|
|
779
797
|
herd_invitations: {
|
|
@@ -1588,6 +1606,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1588
1606
|
herd_id: number;
|
|
1589
1607
|
id: number;
|
|
1590
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;
|
|
1591
1613
|
role: Database["public"]["Enums"]["role"];
|
|
1592
1614
|
user_id: string;
|
|
1593
1615
|
};
|
|
@@ -1595,6 +1617,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1595
1617
|
herd_id: number;
|
|
1596
1618
|
id?: number;
|
|
1597
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;
|
|
1598
1624
|
role: Database["public"]["Enums"]["role"];
|
|
1599
1625
|
user_id: string;
|
|
1600
1626
|
};
|
|
@@ -1602,6 +1628,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1602
1628
|
herd_id?: number;
|
|
1603
1629
|
id?: number;
|
|
1604
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;
|
|
1605
1635
|
role?: Database["public"]["Enums"]["role"];
|
|
1606
1636
|
user_id?: string;
|
|
1607
1637
|
};
|
|
@@ -1611,6 +1641,12 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1611
1641
|
isOneToOne: false;
|
|
1612
1642
|
referencedRelation: "herds";
|
|
1613
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"];
|
|
1614
1650
|
}, {
|
|
1615
1651
|
foreignKeyName: "users_roles_per_herd_user_id_fkey";
|
|
1616
1652
|
columns: ["user_id"];
|
|
@@ -1921,6 +1957,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1921
1957
|
timestamp_start: string;
|
|
1922
1958
|
}[];
|
|
1923
1959
|
};
|
|
1960
|
+
expire_herd_invitations: {
|
|
1961
|
+
Args: never;
|
|
1962
|
+
Returns: number;
|
|
1963
|
+
};
|
|
1924
1964
|
fix_all_sessions_missing_distance: {
|
|
1925
1965
|
Args: never;
|
|
1926
1966
|
Returns: {
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -791,18 +791,30 @@ export type Database = {
|
|
|
791
791
|
domain: string;
|
|
792
792
|
herd_id: number;
|
|
793
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;
|
|
794
798
|
};
|
|
795
799
|
Insert: {
|
|
796
800
|
created_at?: string;
|
|
797
801
|
domain: string;
|
|
798
802
|
herd_id: number;
|
|
799
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;
|
|
800
808
|
};
|
|
801
809
|
Update: {
|
|
802
810
|
created_at?: string;
|
|
803
811
|
domain?: string;
|
|
804
812
|
herd_id?: number;
|
|
805
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;
|
|
806
818
|
};
|
|
807
819
|
Relationships: [
|
|
808
820
|
{
|
|
@@ -811,6 +823,13 @@ export type Database = {
|
|
|
811
823
|
isOneToOne: false;
|
|
812
824
|
referencedRelation: "herds";
|
|
813
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"];
|
|
814
833
|
}
|
|
815
834
|
];
|
|
816
835
|
};
|
|
@@ -1668,6 +1687,10 @@ export type Database = {
|
|
|
1668
1687
|
herd_id: number;
|
|
1669
1688
|
id: number;
|
|
1670
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;
|
|
1671
1694
|
role: Database["public"]["Enums"]["role"];
|
|
1672
1695
|
user_id: string;
|
|
1673
1696
|
};
|
|
@@ -1675,6 +1698,10 @@ export type Database = {
|
|
|
1675
1698
|
herd_id: number;
|
|
1676
1699
|
id?: number;
|
|
1677
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;
|
|
1678
1705
|
role: Database["public"]["Enums"]["role"];
|
|
1679
1706
|
user_id: string;
|
|
1680
1707
|
};
|
|
@@ -1682,6 +1709,10 @@ export type Database = {
|
|
|
1682
1709
|
herd_id?: number;
|
|
1683
1710
|
id?: number;
|
|
1684
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;
|
|
1685
1716
|
role?: Database["public"]["Enums"]["role"];
|
|
1686
1717
|
user_id?: string;
|
|
1687
1718
|
};
|
|
@@ -1693,6 +1724,13 @@ export type Database = {
|
|
|
1693
1724
|
referencedRelation: "herds";
|
|
1694
1725
|
referencedColumns: ["id"];
|
|
1695
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
|
+
},
|
|
1696
1734
|
{
|
|
1697
1735
|
foreignKeyName: "users_roles_per_herd_user_id_fkey";
|
|
1698
1736
|
columns: ["user_id"];
|
|
@@ -2016,6 +2054,10 @@ export type Database = {
|
|
|
2016
2054
|
timestamp_start: string;
|
|
2017
2055
|
}[];
|
|
2018
2056
|
};
|
|
2057
|
+
expire_herd_invitations: {
|
|
2058
|
+
Args: never;
|
|
2059
|
+
Returns: number;
|
|
2060
|
+
};
|
|
2019
2061
|
fix_all_sessions_missing_distance: {
|
|
2020
2062
|
Args: never;
|
|
2021
2063
|
Returns: {
|