@adventurelabs/scout-core 1.5.5 → 2.0.1
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/README.md +47 -0
- package/dist/api_keys/actions.d.ts +0 -1
- package/dist/api_keys/actions.js +0 -14
- package/dist/client/index.d.ts +76 -0
- package/dist/client/index.js +83 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/helpers/analysis_usage/jobs_server.d.ts +25 -0
- package/dist/helpers/analysis_usage/jobs_server.js +10 -0
- package/dist/helpers/analysis_usage/tasks_server.d.ts +63 -0
- package/dist/helpers/analysis_usage/tasks_server.js +14 -0
- package/dist/helpers/artifacts.d.ts +0 -1
- package/dist/helpers/artifacts.js +10 -147
- package/dist/helpers/artifacts.queries.d.ts +26 -0
- package/dist/helpers/{artifacts.internal.js → artifacts.queries.js} +24 -41
- package/dist/helpers/auth.d.ts +1 -1
- package/dist/helpers/auth.js +2 -3
- package/dist/helpers/auth_server.d.ts +2 -0
- package/dist/helpers/auth_server.js +10 -0
- package/dist/helpers/certificates_server.d.ts +101 -0
- package/dist/helpers/certificates_server.js +42 -0
- package/dist/helpers/chat.d.ts +1 -2
- package/dist/helpers/chat.js +3 -38
- package/dist/helpers/chat.queries.d.ts +13 -0
- package/dist/helpers/chat.queries.js +39 -0
- package/dist/helpers/client_abilities_jwt_keys.js +0 -1
- package/dist/helpers/client_abilities_token_server.d.ts +1 -0
- package/dist/helpers/client_abilities_token_server.js +5 -2
- package/dist/helpers/compliance.d.ts +26 -0
- package/dist/helpers/compliance.js +74 -0
- package/dist/helpers/compliance.queries.d.ts +28 -0
- package/dist/helpers/compliance.queries.js +167 -0
- package/dist/helpers/connectivity.d.ts +1 -5
- package/dist/helpers/connectivity.js +7 -140
- package/dist/helpers/connectivity.queries.d.ts +18 -0
- package/dist/helpers/connectivity.queries.js +121 -0
- package/dist/helpers/contacts_server.d.ts +75 -0
- package/dist/helpers/contacts_server.js +18 -0
- package/dist/helpers/deviceTransfer.js +2 -11
- package/dist/helpers/deviceTransfer.queries.d.ts +4 -0
- package/dist/helpers/deviceTransfer.queries.js +11 -0
- package/dist/helpers/devices.js +4 -61
- package/dist/helpers/devices.queries.d.ts +4 -1
- package/dist/helpers/devices.queries.js +52 -0
- package/dist/helpers/document_templates.js +6 -52
- package/dist/helpers/document_templates.queries.d.ts +9 -0
- package/dist/helpers/document_templates.queries.js +56 -0
- package/dist/helpers/documents_server.d.ts +226 -0
- package/dist/helpers/documents_server.js +38 -0
- package/dist/helpers/email.d.ts +0 -6
- package/dist/helpers/email.js +1 -19
- package/dist/helpers/embeddings.d.ts +0 -5
- package/dist/helpers/embeddings.js +2 -19
- package/dist/helpers/embeddings.queries.d.ts +7 -0
- package/dist/helpers/{embeddings.internal.js → embeddings.queries.js} +2 -2
- package/dist/helpers/eventUtils.d.ts +3 -12
- package/dist/helpers/eventUtils.js +0 -10
- package/dist/helpers/events.d.ts +0 -1
- package/dist/helpers/events.js +7 -107
- package/dist/helpers/events.queries.d.ts +17 -0
- package/dist/helpers/{events.internal.js → events.queries.js} +24 -15
- package/dist/helpers/health_metrics.js +3 -38
- package/dist/helpers/health_metrics.queries.d.ts +12 -0
- package/dist/helpers/health_metrics.queries.js +39 -0
- package/dist/helpers/heartbeats.js +4 -83
- package/dist/helpers/heartbeats.queries.d.ts +11 -0
- package/dist/helpers/heartbeats.queries.js +76 -0
- package/dist/helpers/herd_allowed_domains.js +2 -12
- package/dist/helpers/{herd_allowed_domains_internal.d.ts → herd_allowed_domains.queries.d.ts} +1 -1
- package/dist/helpers/{herd_allowed_domains_internal.js → herd_allowed_domains.queries.js} +2 -2
- package/dist/helpers/herd_credentials_server.d.ts +76 -0
- package/dist/helpers/herd_credentials_server.js +22 -0
- package/dist/helpers/herd_modules.queries.js +10 -7
- package/dist/helpers/herd_roles.js +13 -148
- package/dist/helpers/herd_roles.queries.d.ts +18 -0
- package/dist/helpers/{herd_roles_internal.js → herd_roles.queries.js} +28 -28
- package/dist/helpers/herds.js +5 -47
- package/dist/helpers/herds.queries.d.ts +8 -1
- package/dist/helpers/herds.queries.js +48 -0
- package/dist/helpers/invitations.js +7 -58
- package/dist/helpers/invitations.queries.d.ts +10 -0
- package/dist/helpers/{invitations_internal.js → invitations.queries.js} +12 -12
- package/dist/helpers/issuers.js +6 -52
- package/dist/helpers/issuers.queries.d.ts +9 -0
- package/dist/helpers/issuers.queries.js +53 -0
- package/dist/helpers/layers.js +2 -20
- package/dist/helpers/layers.queries.d.ts +2 -1
- package/dist/helpers/layers.queries.js +9 -13
- package/dist/helpers/lifecycle_server.d.ts +178 -0
- package/dist/helpers/lifecycle_server.js +38 -0
- package/dist/helpers/localizations.js +5 -42
- package/dist/helpers/localizations.queries.d.ts +8 -0
- package/dist/helpers/localizations.queries.js +45 -0
- package/dist/helpers/maintenance_requests_server.d.ts +124 -0
- package/dist/helpers/maintenance_requests_server.js +34 -0
- package/dist/helpers/manufacturers.js +5 -43
- package/dist/helpers/manufacturers.queries.d.ts +10 -0
- package/dist/helpers/manufacturers.queries.js +46 -0
- package/dist/helpers/media_urls.d.ts +13 -0
- package/dist/helpers/media_urls.js +21 -0
- package/dist/helpers/models.js +8 -80
- package/dist/helpers/models.queries.d.ts +13 -0
- package/dist/helpers/models.queries.js +79 -0
- package/dist/helpers/observations_server.d.ts +51 -0
- package/dist/helpers/observations_server.js +22 -0
- package/dist/helpers/operating_contexts.js +39 -154
- package/dist/helpers/operating_contexts.queries.d.ts +48 -0
- package/dist/helpers/operating_contexts.queries.js +223 -0
- package/dist/helpers/operators.js +4 -57
- package/dist/helpers/operators.queries.d.ts +7 -0
- package/dist/helpers/operators.queries.js +55 -0
- package/dist/helpers/parts.d.ts +0 -87
- package/dist/helpers/parts.js +1 -89
- package/dist/helpers/parts_server.d.ts +260 -0
- package/dist/helpers/parts_server.js +71 -0
- package/dist/helpers/pins_server.d.ts +118 -0
- package/dist/helpers/pins_server.js +38 -0
- package/dist/helpers/plans.js +4 -56
- package/dist/helpers/plans.queries.d.ts +4 -1
- package/dist/helpers/plans.queries.js +39 -12
- package/dist/helpers/points_for_user_server.d.ts +9 -0
- package/dist/helpers/points_for_user_server.js +14 -0
- package/dist/helpers/product_compatibilities.js +6 -78
- package/dist/helpers/product_compatibilities.queries.d.ts +9 -0
- package/dist/helpers/product_compatibilities.queries.js +83 -0
- package/dist/helpers/product_numbers.js +6 -55
- package/dist/helpers/product_numbers.queries.d.ts +9 -0
- package/dist/helpers/product_numbers.queries.js +58 -0
- package/dist/helpers/products.js +6 -54
- package/dist/helpers/products.queries.d.ts +11 -0
- package/dist/helpers/products.queries.js +58 -0
- package/dist/helpers/providers.js +5 -71
- package/dist/helpers/providers.queries.d.ts +5 -1
- package/dist/helpers/providers.queries.js +52 -11
- package/dist/helpers/pubsub_token_server.d.ts +1 -0
- package/dist/helpers/pubsub_token_server.js +5 -2
- package/dist/helpers/segmentations_sam3.js +5 -78
- package/dist/helpers/segmentations_sam3.queries.d.ts +16 -0
- package/dist/helpers/segmentations_sam3.queries.js +81 -0
- package/dist/helpers/sensor_poses_server.d.ts +98 -0
- package/dist/helpers/sensor_poses_server.js +26 -0
- package/dist/helpers/session_incidents_server.d.ts +106 -0
- package/dist/helpers/session_incidents_server.js +22 -0
- package/dist/helpers/session_summaries.d.ts +2 -0
- package/dist/helpers/session_summaries.js +7 -23
- package/dist/helpers/session_summaries.queries.d.ts +6 -3
- package/dist/helpers/session_summaries.queries.js +27 -0
- package/dist/helpers/sessions.js +8 -122
- package/dist/helpers/sessions.queries.d.ts +14 -2
- package/dist/helpers/sessions.queries.js +88 -1
- package/dist/helpers/storage.js +0 -1
- package/dist/helpers/supabase_auth.d.ts +6 -0
- package/dist/helpers/supabase_auth.js +37 -0
- package/dist/helpers/tags.d.ts +0 -1
- package/dist/helpers/tags.js +13 -559
- package/dist/helpers/tags.queries.d.ts +33 -0
- package/dist/helpers/tags.queries.js +454 -0
- package/dist/helpers/user_credentials_server.d.ts +76 -0
- package/dist/helpers/user_credentials_server.js +22 -0
- package/dist/helpers/users.d.ts +2 -2
- package/dist/helpers/users.js +8 -107
- package/dist/helpers/users.queries.d.ts +9 -1
- package/dist/helpers/users.queries.js +107 -0
- package/dist/helpers/versions_software.d.ts +3 -1
- package/dist/helpers/versions_software.js +24 -0
- package/dist/helpers/versions_software_server.d.ts +83 -4
- package/dist/helpers/versions_software_server.js +23 -50
- package/dist/helpers/zones.d.ts +1 -16
- package/dist/helpers/zones.js +4 -104
- package/dist/helpers/zones.queries.d.ts +6 -0
- package/dist/helpers/zones.queries.js +78 -0
- package/dist/hooks/useAuthorizedRealtimeTopics.js +8 -2
- package/dist/hooks/useInfiniteQuery.js +18 -14
- package/dist/hooks/useScoutRealtimeBroadcast.js +8 -6
- package/dist/hooks/useScoutRealtimeDocuments.js +3 -2
- package/dist/hooks/useScoutRefresh.d.ts +9 -25
- package/dist/hooks/useScoutRefresh.js +33 -213
- package/dist/providers/ScoutRefreshProvider.d.ts +1 -1
- package/dist/providers/ScoutRefreshProvider.js +56 -13
- package/dist/server/index.d.ts +78 -0
- package/dist/server/index.js +80 -0
- package/dist/server/middleware.d.ts +2 -0
- package/dist/server/middleware.js +2 -0
- package/dist/server/supabase.d.ts +2 -0
- package/dist/server/supabase.js +2 -0
- package/dist/store/api.d.ts +40 -40
- package/dist/store/api.js +38 -109
- package/dist/store/configureStore.d.ts +0 -55
- package/dist/store/configureStore.js +1 -8
- package/dist/store/hooks.js +1 -0
- package/dist/supabase/client.d.ts +3 -0
- package/dist/supabase/client.js +10 -0
- package/dist/supabase/middleware.d.ts +1 -0
- package/dist/supabase/middleware.js +6 -20
- package/dist/supabase/server.d.ts +7 -2
- package/dist/supabase/server.js +13 -1
- package/dist/types/db.d.ts +47 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/supabase.d.ts +512 -0
- package/package.json +53 -4
- package/dist/api_keys/index.d.ts +0 -1
- package/dist/api_keys/index.js +0 -1
- package/dist/helpers/artifacts.internal.d.ts +0 -22
- package/dist/helpers/client_abilities_jwt_keys_internal.d.ts +0 -9
- package/dist/helpers/client_abilities_jwt_keys_internal.js +0 -20
- package/dist/helpers/connectivity.internal.d.ts +0 -10
- package/dist/helpers/connectivity.internal.js +0 -47
- package/dist/helpers/credentials.d.ts +0 -9
- package/dist/helpers/credentials.js +0 -92
- package/dist/helpers/embeddings.internal.d.ts +0 -5
- package/dist/helpers/events.internal.d.ts +0 -13
- package/dist/helpers/herd_roles_internal.d.ts +0 -18
- package/dist/helpers/index.d.ts +0 -56
- package/dist/helpers/index.js +0 -56
- package/dist/helpers/invitations_internal.d.ts +0 -10
- package/dist/helpers/versions_software_internal.d.ts +0 -6
- package/dist/helpers/versions_software_internal.js +0 -53
- package/dist/hooks/useDeviceDisplayName.d.ts +0 -8
- package/dist/hooks/useDeviceDisplayName.js +0 -49
- package/dist/index.d.ts +0 -108
- package/dist/index.js +0 -114
- package/dist/supabase/index.d.ts +0 -2
- package/dist/supabase/index.js +0 -2
package/package.json
CHANGED
|
@@ -1,9 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adventurelabs/scout-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Core utilities and helpers for Adventure Labs Scout applications",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"exports": {
|
|
6
|
+
"./client": {
|
|
7
|
+
"types": "./dist/client/index.d.ts",
|
|
8
|
+
"import": "./dist/client/index.js",
|
|
9
|
+
"default": "./dist/client/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./server": {
|
|
12
|
+
"types": "./dist/server/index.d.ts",
|
|
13
|
+
"react-server": "./dist/server/index.js",
|
|
14
|
+
"import": "./dist/server/index.js",
|
|
15
|
+
"default": "./dist/server/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./server/middleware": {
|
|
18
|
+
"types": "./dist/server/middleware.d.ts",
|
|
19
|
+
"react-server": "./dist/server/middleware.js",
|
|
20
|
+
"import": "./dist/server/middleware.js",
|
|
21
|
+
"default": "./dist/server/middleware.js"
|
|
22
|
+
},
|
|
23
|
+
"./server/supabase": {
|
|
24
|
+
"types": "./dist/server/supabase.d.ts",
|
|
25
|
+
"react-server": "./dist/server/supabase.js",
|
|
26
|
+
"import": "./dist/server/supabase.js",
|
|
27
|
+
"default": "./dist/server/supabase.js"
|
|
28
|
+
},
|
|
29
|
+
"./types": {
|
|
30
|
+
"types": "./dist/types/index.d.ts",
|
|
31
|
+
"import": "./dist/types/index.js",
|
|
32
|
+
"default": "./dist/types/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
"client": [
|
|
39
|
+
"dist/client/index.d.ts"
|
|
40
|
+
],
|
|
41
|
+
"server": [
|
|
42
|
+
"dist/server/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"server/middleware": [
|
|
45
|
+
"dist/server/middleware.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"server/supabase": [
|
|
48
|
+
"dist/server/supabase.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"types": [
|
|
51
|
+
"dist/types/index.d.ts"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
7
55
|
"files": [
|
|
8
56
|
"dist",
|
|
9
57
|
"README.md"
|
|
@@ -57,6 +105,7 @@
|
|
|
57
105
|
},
|
|
58
106
|
"dependencies": {
|
|
59
107
|
"dequal": "^2.0.3",
|
|
60
|
-
"jose": "5"
|
|
108
|
+
"jose": "5",
|
|
109
|
+
"server-only": "^0.0.1"
|
|
61
110
|
}
|
|
62
111
|
}
|
package/dist/api_keys/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./actions";
|
package/dist/api_keys/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./actions";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IArtifact, IArtifactWithMediaUrl, ArtifactInsert, ArtifactUpdate } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import type { Database } from "../types/supabase";
|
|
5
|
-
export interface ArtifactTimeRangeOptions {
|
|
6
|
-
start_timestamp?: string;
|
|
7
|
-
end_timestamp?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function getArtifactByIdWithClient(client: SupabaseClient<Database>, id: number): Promise<IWebResponseCompatible<IArtifactWithMediaUrl | null>>;
|
|
10
|
-
export declare function getArtifactsByHerdWithClient(client: SupabaseClient<Database>, herd_id: number, limit: number, offset: number, options: ArtifactTimeRangeOptions | undefined): Promise<IWebResponseCompatible<IArtifactWithMediaUrl[]>>;
|
|
11
|
-
export declare function getArtifactsByDeviceIdWithClient(client: SupabaseClient<Database>, device_id: number, limit: number, offset: number): Promise<IWebResponseCompatible<IArtifactWithMediaUrl[]>>;
|
|
12
|
-
export declare function getArtifactsByDeviceIdsBatchWithClient(client: SupabaseClient<Database>, device_ids: number[], limit_per_device: number, options: ArtifactTimeRangeOptions | undefined): Promise<{
|
|
13
|
-
[device_id: number]: IArtifactWithMediaUrl[];
|
|
14
|
-
}>;
|
|
15
|
-
export declare function insertArtifactWithClient(client: SupabaseClient<Database>, artifact: ArtifactInsert | ArtifactInsert[]): Promise<IWebResponseCompatible<IArtifact[]>>;
|
|
16
|
-
export declare function updateArtifactWithClient(client: SupabaseClient<Database>, artifact: (ArtifactUpdate & {
|
|
17
|
-
id: number;
|
|
18
|
-
}) | (ArtifactUpdate & {
|
|
19
|
-
id: number;
|
|
20
|
-
})[]): Promise<IWebResponseCompatible<IArtifact[]>>;
|
|
21
|
-
export declare function deleteArtifactWithClient(client: SupabaseClient<Database>, id: number | number[]): Promise<IWebResponseCompatible<boolean>>;
|
|
22
|
-
export declare function matchArtifactsByVertexEmbeddingWithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IArtifact[]>>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
3
|
-
import { Database, Json } from "../types/supabase";
|
|
4
|
-
export type ClientAbilitiesPublicJwk = Record<string, Json | undefined> & {
|
|
5
|
-
kty: string;
|
|
6
|
-
kid?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function upsert_client_abilities_jwt_public_key(client: SupabaseClient<Database>, kid: string, publicJwk: ClientAbilitiesPublicJwk): Promise<IWebResponseCompatible<null>>;
|
|
9
|
-
export declare function revoke_client_abilities_jwt_public_key(client: SupabaseClient<Database>, kid: string): Promise<IWebResponseCompatible<null>>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IWebResponse } from "../types/requests";
|
|
2
|
-
export async function upsert_client_abilities_jwt_public_key(client, kid, publicJwk) {
|
|
3
|
-
const { error } = await client.rpc("upsert_client_abilities_jwt_public_key", {
|
|
4
|
-
p_kid: kid,
|
|
5
|
-
p_public_jwk: publicJwk,
|
|
6
|
-
});
|
|
7
|
-
if (error) {
|
|
8
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
9
|
-
}
|
|
10
|
-
return IWebResponse.success(null).to_compatible();
|
|
11
|
-
}
|
|
12
|
-
export async function revoke_client_abilities_jwt_public_key(client, kid) {
|
|
13
|
-
const { error } = await client.rpc("revoke_client_abilities_jwt_public_key", {
|
|
14
|
-
p_kid: kid,
|
|
15
|
-
});
|
|
16
|
-
if (error) {
|
|
17
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
18
|
-
}
|
|
19
|
-
return IWebResponse.success(null).to_compatible();
|
|
20
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IConnectivity, ConnectivityInsert, ConnectivityUpdate } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import type { Database } from "../types/supabase";
|
|
5
|
-
export declare function insertConnectivityWithClient(client: SupabaseClient<Database>, connectivity: ConnectivityInsert | ConnectivityInsert[]): Promise<IWebResponseCompatible<IConnectivity[]>>;
|
|
6
|
-
export declare function updateConnectivityWithClient(client: SupabaseClient<Database>, connectivity: (ConnectivityUpdate & {
|
|
7
|
-
id: number;
|
|
8
|
-
}) | (ConnectivityUpdate & {
|
|
9
|
-
id: number;
|
|
10
|
-
})[]): Promise<IWebResponseCompatible<IConnectivity[]>>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
-
export async function insertConnectivityWithClient(client, connectivity) {
|
|
3
|
-
const connectivityArray = Array.isArray(connectivity)
|
|
4
|
-
? connectivity
|
|
5
|
-
: [connectivity];
|
|
6
|
-
const { data, error } = await client
|
|
7
|
-
.from("connectivity")
|
|
8
|
-
.insert(connectivityArray)
|
|
9
|
-
.select("*");
|
|
10
|
-
if (error) {
|
|
11
|
-
console.warn("Error inserting connectivity:", error.message);
|
|
12
|
-
return {
|
|
13
|
-
status: EnumWebResponse.ERROR,
|
|
14
|
-
msg: error.message,
|
|
15
|
-
data: [],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return IWebResponse.success(data || []).to_compatible();
|
|
19
|
-
}
|
|
20
|
-
export async function updateConnectivityWithClient(client, connectivity) {
|
|
21
|
-
const connectivityArray = Array.isArray(connectivity)
|
|
22
|
-
? connectivity
|
|
23
|
-
: [connectivity];
|
|
24
|
-
const updatedConnectivity = [];
|
|
25
|
-
for (const record of connectivityArray) {
|
|
26
|
-
const { id, ...updateData } = record;
|
|
27
|
-
delete updateData.inserted_at;
|
|
28
|
-
const { data, error } = await client
|
|
29
|
-
.from("connectivity")
|
|
30
|
-
.update(updateData)
|
|
31
|
-
.eq("id", id)
|
|
32
|
-
.select("*")
|
|
33
|
-
.single();
|
|
34
|
-
if (error) {
|
|
35
|
-
console.warn("Error updating connectivity:", error.message);
|
|
36
|
-
return {
|
|
37
|
-
status: EnumWebResponse.ERROR,
|
|
38
|
-
msg: error.message,
|
|
39
|
-
data: [],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (data) {
|
|
43
|
-
updatedConnectivity.push(data);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return IWebResponse.success(updatedConnectivity).to_compatible();
|
|
47
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { IEmbeddingSearchResult } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import type { Database } from "../types/supabase";
|
|
5
|
-
export declare function searchEmbeddingsVertexMultimodal001WithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IEmbeddingSearchResult[]>>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IEvent, IEventWithMediaUrl, EventInsert, EventUpdate } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import type { Database } from "../types/supabase";
|
|
5
|
-
export declare function getEventByIdWithClient(client: SupabaseClient<Database>, id: number): Promise<IWebResponseCompatible<IEventWithMediaUrl | null>>;
|
|
6
|
-
export declare function insertEventWithClient(client: SupabaseClient<Database>, events: EventInsert | EventInsert[]): Promise<IWebResponseCompatible<IEvent[]>>;
|
|
7
|
-
export declare function updateEventWithClient(client: SupabaseClient<Database>, events: (EventUpdate & {
|
|
8
|
-
id: number;
|
|
9
|
-
}) | (EventUpdate & {
|
|
10
|
-
id: number;
|
|
11
|
-
})[]): Promise<IWebResponseCompatible<IEvent[]>>;
|
|
12
|
-
export declare function deleteEventWithClient(client: SupabaseClient<Database>, id: number | number[]): Promise<IWebResponseCompatible<boolean>>;
|
|
13
|
-
export declare function matchEventsByVertexEmbeddingWithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IEvent[]>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IAbility, IHerdRole, IHerdRoleAbilityRow, IHerdRoleWithAbilities, IPlatformDefaultRoleAbilitiesGroup } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import { Database } from "../types/supabase";
|
|
5
|
-
export declare function listAbilitiesWithClient(supabase: SupabaseClient<Database>): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
6
|
-
export declare function getAbilitiesByIdsWithClient(supabase: SupabaseClient<Database>, ids: number[]): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
7
|
-
export declare function getHerdRolesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRole[]>>;
|
|
8
|
-
export declare function getHerdRolesWithAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRoleWithAbilities[]>>;
|
|
9
|
-
export declare function getHerdRoleBySystemNameWithClient(supabase: SupabaseClient<Database>, herd_id: number, system_name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
10
|
-
export declare function createHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_id: number, system_name: string, name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
11
|
-
export declare function updateHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_role_id: number, patch: {
|
|
12
|
-
name?: string;
|
|
13
|
-
}): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
14
|
-
export declare function deleteHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_role_id: number): Promise<IWebResponseCompatible<null>>;
|
|
15
|
-
export declare function setHerdRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_role_id: number, ability_ids: number[]): Promise<IWebResponseCompatible<IHerdRoleAbilityRow[]>>;
|
|
16
|
-
export declare function getPlatformDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>): Promise<IWebResponseCompatible<IPlatformDefaultRoleAbilitiesGroup[]>>;
|
|
17
|
-
export declare function setPlatformDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, system_name: string, ability_keys: string[]): Promise<IWebResponseCompatible<null>>;
|
|
18
|
-
export declare function resetHerdDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<null>>;
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export * from "./analysis_usage";
|
|
2
|
-
export * from "./auth";
|
|
3
|
-
export * from "./bounding_boxes";
|
|
4
|
-
export * from "./chat";
|
|
5
|
-
export * from "./certificates";
|
|
6
|
-
export * from "./user_credentials";
|
|
7
|
-
export * from "./herd_credentials";
|
|
8
|
-
export * from "./db";
|
|
9
|
-
export * from "./devices";
|
|
10
|
-
export * from "./email";
|
|
11
|
-
export * from "./events";
|
|
12
|
-
export * from "./gps";
|
|
13
|
-
export * from "./health_metrics";
|
|
14
|
-
export * from "./heartbeats";
|
|
15
|
-
export * from "./herds";
|
|
16
|
-
export * from "./location";
|
|
17
|
-
export * from "./lifecycle";
|
|
18
|
-
export * from "./models";
|
|
19
|
-
export * from "./manufacturers";
|
|
20
|
-
export * from "./products";
|
|
21
|
-
export * from "./product_numbers";
|
|
22
|
-
export * from "./product_compatibilities";
|
|
23
|
-
export * from "./localizations";
|
|
24
|
-
export * from "./issuers";
|
|
25
|
-
export * from "./document_templates";
|
|
26
|
-
export * from "./documents";
|
|
27
|
-
export * from "./maintenance_requests";
|
|
28
|
-
export * from "./session_incidents";
|
|
29
|
-
export * from "./contacts";
|
|
30
|
-
export * from "./operating_contexts";
|
|
31
|
-
export * from "./plans";
|
|
32
|
-
export * from "./sessions";
|
|
33
|
-
export * from "./segmentations_sam3";
|
|
34
|
-
export * from "./tags";
|
|
35
|
-
export * from "./time";
|
|
36
|
-
export * from "./ui";
|
|
37
|
-
export * from "./users";
|
|
38
|
-
export * from "./web";
|
|
39
|
-
export * from "./zones";
|
|
40
|
-
export * from "./cache";
|
|
41
|
-
export * from "./observations";
|
|
42
|
-
export * from "./operators";
|
|
43
|
-
export * from "./parts";
|
|
44
|
-
export * from "./sensor_poses";
|
|
45
|
-
export * from "./versions_software";
|
|
46
|
-
export * from "./versions_software_server";
|
|
47
|
-
export * from "./artifacts";
|
|
48
|
-
export * from "./pins";
|
|
49
|
-
export * from "./points_for_user";
|
|
50
|
-
export * from "./pubsub_token";
|
|
51
|
-
export * from "./pubsub_token_server";
|
|
52
|
-
export * from "./client_abilities_token";
|
|
53
|
-
export * from "./client_abilities_token_server";
|
|
54
|
-
export * from "./client_abilities_jwt_keys";
|
|
55
|
-
export * from "./herd_roles";
|
|
56
|
-
export * from "./storagePath";
|
package/dist/helpers/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export * from "./analysis_usage";
|
|
2
|
-
export * from "./auth";
|
|
3
|
-
export * from "./bounding_boxes";
|
|
4
|
-
export * from "./chat";
|
|
5
|
-
export * from "./certificates";
|
|
6
|
-
export * from "./user_credentials";
|
|
7
|
-
export * from "./herd_credentials";
|
|
8
|
-
export * from "./db";
|
|
9
|
-
export * from "./devices";
|
|
10
|
-
export * from "./email";
|
|
11
|
-
export * from "./events";
|
|
12
|
-
export * from "./gps";
|
|
13
|
-
export * from "./health_metrics";
|
|
14
|
-
export * from "./heartbeats";
|
|
15
|
-
export * from "./herds";
|
|
16
|
-
export * from "./location";
|
|
17
|
-
export * from "./lifecycle";
|
|
18
|
-
export * from "./models";
|
|
19
|
-
export * from "./manufacturers";
|
|
20
|
-
export * from "./products";
|
|
21
|
-
export * from "./product_numbers";
|
|
22
|
-
export * from "./product_compatibilities";
|
|
23
|
-
export * from "./localizations";
|
|
24
|
-
export * from "./issuers";
|
|
25
|
-
export * from "./document_templates";
|
|
26
|
-
export * from "./documents";
|
|
27
|
-
export * from "./maintenance_requests";
|
|
28
|
-
export * from "./session_incidents";
|
|
29
|
-
export * from "./contacts";
|
|
30
|
-
export * from "./operating_contexts";
|
|
31
|
-
export * from "./plans";
|
|
32
|
-
export * from "./sessions";
|
|
33
|
-
export * from "./segmentations_sam3";
|
|
34
|
-
export * from "./tags";
|
|
35
|
-
export * from "./time";
|
|
36
|
-
export * from "./ui";
|
|
37
|
-
export * from "./users";
|
|
38
|
-
export * from "./web";
|
|
39
|
-
export * from "./zones";
|
|
40
|
-
export * from "./cache";
|
|
41
|
-
export * from "./observations";
|
|
42
|
-
export * from "./operators";
|
|
43
|
-
export * from "./parts";
|
|
44
|
-
export * from "./sensor_poses";
|
|
45
|
-
export * from "./versions_software";
|
|
46
|
-
export * from "./versions_software_server";
|
|
47
|
-
export * from "./artifacts";
|
|
48
|
-
export * from "./pins";
|
|
49
|
-
export * from "./points_for_user";
|
|
50
|
-
export * from "./pubsub_token";
|
|
51
|
-
export * from "./pubsub_token_server";
|
|
52
|
-
export * from "./client_abilities_token";
|
|
53
|
-
export * from "./client_abilities_token_server";
|
|
54
|
-
export * from "./client_abilities_jwt_keys";
|
|
55
|
-
export * from "./herd_roles";
|
|
56
|
-
export * from "./storagePath";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IHerdInvitation, IHerdInvitationWithHerdSlug } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import { Database } from "../types/supabase";
|
|
5
|
-
export declare function createHerdInvitationWithClient(supabase: SupabaseClient<Database>, herd_id: number, email: string, herd_role_id: number, expires_at?: string | null): Promise<IWebResponseCompatible<IHerdInvitation | null>>;
|
|
6
|
-
export declare function acceptHerdInvitationsWithClient(supabase: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
7
|
-
export declare function getHerdInvitationsForCurrentUserWithClient(supabase: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdInvitationWithHerdSlug[]>>;
|
|
8
|
-
export declare function getHerdInvitationsByHerdWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
9
|
-
export declare function rejectHerdInvitationsWithClient(supabase: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
10
|
-
export declare function revokeHerdInvitationsWithClient(supabase: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IVersionsSoftwareWithBuildUrl } from "../types/db";
|
|
3
|
-
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
-
import { Database } from "../types/supabase";
|
|
5
|
-
export declare function get_versions_software(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IVersionsSoftwareWithBuildUrl[]>>;
|
|
6
|
-
export declare function get_versions_software_by_system(client: SupabaseClient<Database>, system: string): Promise<IWebResponseCompatible<IVersionsSoftwareWithBuildUrl[]>>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { IWebResponse } from "../types/requests";
|
|
2
|
-
import { generateSignedUrlsBatchWithClient } from "./storage_internal";
|
|
3
|
-
async function attachBuildArtifactUrls(client, data) {
|
|
4
|
-
const uniquePaths = Array.from(new Set(data
|
|
5
|
-
.map((version) => version.path_build_artifact)
|
|
6
|
-
.filter((path) => !!path)));
|
|
7
|
-
if (uniquePaths.length === 0) {
|
|
8
|
-
return data.map((version) => ({
|
|
9
|
-
...version,
|
|
10
|
-
build_artifact_url: null,
|
|
11
|
-
}));
|
|
12
|
-
}
|
|
13
|
-
const signedUrls = await generateSignedUrlsBatchWithClient(client, uniquePaths);
|
|
14
|
-
const urlMap = new Map();
|
|
15
|
-
uniquePaths.forEach((path, index) => {
|
|
16
|
-
urlMap.set(path, signedUrls[index]);
|
|
17
|
-
});
|
|
18
|
-
return data.map((version) => ({
|
|
19
|
-
...version,
|
|
20
|
-
build_artifact_url: version.path_build_artifact
|
|
21
|
-
? urlMap.get(version.path_build_artifact) ?? null
|
|
22
|
-
: null,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
export async function get_versions_software(client) {
|
|
26
|
-
const { data, error } = await client
|
|
27
|
-
.from("versions_software")
|
|
28
|
-
.select("*")
|
|
29
|
-
.order("created_at", { ascending: false });
|
|
30
|
-
if (error) {
|
|
31
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
32
|
-
}
|
|
33
|
-
if (!data) {
|
|
34
|
-
return IWebResponse.error("No software versions found").to_compatible();
|
|
35
|
-
}
|
|
36
|
-
const withUrls = await attachBuildArtifactUrls(client, data);
|
|
37
|
-
return IWebResponse.success(withUrls).to_compatible();
|
|
38
|
-
}
|
|
39
|
-
export async function get_versions_software_by_system(client, system) {
|
|
40
|
-
const { data, error } = await client
|
|
41
|
-
.from("versions_software")
|
|
42
|
-
.select("*")
|
|
43
|
-
.eq("system", system)
|
|
44
|
-
.order("created_at", { ascending: false });
|
|
45
|
-
if (error) {
|
|
46
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
47
|
-
}
|
|
48
|
-
if (!data) {
|
|
49
|
-
return IWebResponse.error(`No software versions found for system: ${system}`).to_compatible();
|
|
50
|
-
}
|
|
51
|
-
const withUrls = await attachBuildArtifactUrls(client, data);
|
|
52
|
-
return IWebResponse.success(withUrls).to_compatible();
|
|
53
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { IDevice } from "../types/db";
|
|
3
|
-
import type { IHerdModule } from "../types/herd_module";
|
|
4
|
-
export declare function primeDeviceDisplayNameCache(devices: Iterable<IDevice>): void;
|
|
5
|
-
export declare function useDeviceDisplayName(deviceId: number | null | undefined, options?: {
|
|
6
|
-
herdModules?: IHerdModule[];
|
|
7
|
-
supabase?: SupabaseClient;
|
|
8
|
-
}): string | null;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { formatDeviceDisplayName } from "../helpers/ui";
|
|
4
|
-
const labelByDeviceId = new Map();
|
|
5
|
-
function rememberDevice(device) {
|
|
6
|
-
if (device.id == null)
|
|
7
|
-
return;
|
|
8
|
-
labelByDeviceId.set(device.id, formatDeviceDisplayName(device));
|
|
9
|
-
}
|
|
10
|
-
export function primeDeviceDisplayNameCache(devices) {
|
|
11
|
-
for (const device of devices)
|
|
12
|
-
rememberDevice(device);
|
|
13
|
-
}
|
|
14
|
-
export function useDeviceDisplayName(deviceId, options = {}) {
|
|
15
|
-
const [, setTick] = useState(0);
|
|
16
|
-
const bump = () => setTick(t => t + 1);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!options.herdModules?.length)
|
|
19
|
-
return;
|
|
20
|
-
for (const hm of options.herdModules) {
|
|
21
|
-
for (const device of hm.devices ?? [])
|
|
22
|
-
rememberDevice(device);
|
|
23
|
-
}
|
|
24
|
-
bump();
|
|
25
|
-
}, [options.herdModules]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (deviceId == null || labelByDeviceId.has(deviceId) || !options.supabase) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
let cancelled = false;
|
|
31
|
-
options.supabase
|
|
32
|
-
.from("devices")
|
|
33
|
-
.select("id, name, domain_name, description")
|
|
34
|
-
.eq("id", deviceId)
|
|
35
|
-
.maybeSingle()
|
|
36
|
-
.then(({ data }) => {
|
|
37
|
-
if (cancelled || !data)
|
|
38
|
-
return;
|
|
39
|
-
rememberDevice(data);
|
|
40
|
-
bump();
|
|
41
|
-
});
|
|
42
|
-
return () => {
|
|
43
|
-
cancelled = true;
|
|
44
|
-
};
|
|
45
|
-
}, [deviceId, options.supabase]);
|
|
46
|
-
if (deviceId == null)
|
|
47
|
-
return null;
|
|
48
|
-
return labelByDeviceId.get(deviceId) ?? `Device ${deviceId}`;
|
|
49
|
-
}
|