@adventurelabs/scout-core 1.4.8 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/versions_software_server.d.ts +6 -0
- package/dist/helpers/versions_software_server.js +71 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providers/ScoutRefreshProvider.d.ts +3 -0
- package/dist/types/db.d.ts +3 -0
- package/dist/types/supabase.d.ts +3 -0
- package/package.json +1 -1
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IVersionsSoftwareWithBuildUrl } from "../types/db";
|
|
2
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
3
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
4
|
+
export declare function server_get_versions_software(client?: SupabaseClient): Promise<IWebResponseCompatible<IVersionsSoftwareWithBuildUrl[]>>;
|
|
5
|
+
export declare function server_get_versions_software_by_system(system: string, client?: SupabaseClient): Promise<IWebResponseCompatible<IVersionsSoftwareWithBuildUrl[]>>;
|
|
6
|
+
export declare function server_get_versions_software_by_created_by(user_id: string, client?: SupabaseClient): Promise<IWebResponseCompatible<IVersionsSoftwareWithBuildUrl[]>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { newServerClient } from "../supabase/server";
|
|
3
|
+
import { IWebResponse } from "../types/requests";
|
|
4
|
+
import { generateSignedUrlsBatch } from "./storage";
|
|
5
|
+
/** Resolves path_build_artifact to signed URLs. Paths must be full storage paths (e.g. software_build_artifacts/...). */
|
|
6
|
+
async function attachBuildArtifactUrls(data, client) {
|
|
7
|
+
const uniquePaths = Array.from(new Set(data
|
|
8
|
+
.map((v) => v.path_build_artifact)
|
|
9
|
+
.filter((path) => !!path)));
|
|
10
|
+
if (uniquePaths.length === 0) {
|
|
11
|
+
return data.map((v) => ({ ...v, build_artifact_url: null }));
|
|
12
|
+
}
|
|
13
|
+
const signedUrls = await generateSignedUrlsBatch(uniquePaths, undefined, client);
|
|
14
|
+
const urlMap = new Map();
|
|
15
|
+
uniquePaths.forEach((path, index) => {
|
|
16
|
+
urlMap.set(path, signedUrls[index]);
|
|
17
|
+
});
|
|
18
|
+
return data.map((v) => ({
|
|
19
|
+
...v,
|
|
20
|
+
build_artifact_url: v.path_build_artifact
|
|
21
|
+
? urlMap.get(v.path_build_artifact) ?? null
|
|
22
|
+
: null,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export async function server_get_versions_software(client) {
|
|
26
|
+
const supabase = client || (await newServerClient());
|
|
27
|
+
const { data, error } = await supabase
|
|
28
|
+
.from("versions_software")
|
|
29
|
+
.select("*")
|
|
30
|
+
.order("created_at", { ascending: false });
|
|
31
|
+
if (error) {
|
|
32
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
33
|
+
}
|
|
34
|
+
if (!data) {
|
|
35
|
+
return IWebResponse.error("No software versions found").to_compatible();
|
|
36
|
+
}
|
|
37
|
+
const withUrls = await attachBuildArtifactUrls(data, client);
|
|
38
|
+
return IWebResponse.success(withUrls).to_compatible();
|
|
39
|
+
}
|
|
40
|
+
export async function server_get_versions_software_by_system(system, client) {
|
|
41
|
+
const supabase = client || (await newServerClient());
|
|
42
|
+
const { data, error } = await supabase
|
|
43
|
+
.from("versions_software")
|
|
44
|
+
.select("*")
|
|
45
|
+
.eq("system", system)
|
|
46
|
+
.order("created_at", { ascending: false });
|
|
47
|
+
if (error) {
|
|
48
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
49
|
+
}
|
|
50
|
+
if (!data) {
|
|
51
|
+
return IWebResponse.error(`No software versions found for system: ${system}`).to_compatible();
|
|
52
|
+
}
|
|
53
|
+
const withUrls = await attachBuildArtifactUrls(data, client);
|
|
54
|
+
return IWebResponse.success(withUrls).to_compatible();
|
|
55
|
+
}
|
|
56
|
+
export async function server_get_versions_software_by_created_by(user_id, client) {
|
|
57
|
+
const supabase = client || (await newServerClient());
|
|
58
|
+
const { data, error } = await supabase
|
|
59
|
+
.from("versions_software")
|
|
60
|
+
.select("*")
|
|
61
|
+
.eq("created_by", user_id)
|
|
62
|
+
.order("created_at", { ascending: false });
|
|
63
|
+
if (error) {
|
|
64
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
65
|
+
}
|
|
66
|
+
if (!data) {
|
|
67
|
+
return IWebResponse.error("No software versions found for user").to_compatible();
|
|
68
|
+
}
|
|
69
|
+
const withUrls = await attachBuildArtifactUrls(data, client);
|
|
70
|
+
return IWebResponse.success(withUrls).to_compatible();
|
|
71
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * from "./helpers/heartbeats";
|
|
|
39
39
|
export * from "./helpers/providers";
|
|
40
40
|
export * from "./helpers/operators";
|
|
41
41
|
export * from "./helpers/versions_software";
|
|
42
|
+
export * from "./helpers/versions_software_server";
|
|
42
43
|
export * from "./helpers/parts";
|
|
43
44
|
export * from "./hooks/useScoutRealtimeConnectivity";
|
|
44
45
|
export * from "./hooks/useScoutRealtimeDevices";
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./helpers/heartbeats";
|
|
|
42
42
|
export * from "./helpers/providers";
|
|
43
43
|
export * from "./helpers/operators";
|
|
44
44
|
export * from "./helpers/versions_software";
|
|
45
|
+
export * from "./helpers/versions_software_server";
|
|
45
46
|
export * from "./helpers/parts";
|
|
46
47
|
// Hooks
|
|
47
48
|
export * from "./hooks/useScoutRealtimeConnectivity";
|
|
@@ -886,6 +886,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
886
886
|
hyperlink: string | null;
|
|
887
887
|
id: number;
|
|
888
888
|
min: boolean;
|
|
889
|
+
path_build_artifact: string | null;
|
|
889
890
|
pre: boolean;
|
|
890
891
|
stable: boolean;
|
|
891
892
|
system: string;
|
|
@@ -901,6 +902,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
901
902
|
hyperlink?: string | null;
|
|
902
903
|
id?: number;
|
|
903
904
|
min?: boolean;
|
|
905
|
+
path_build_artifact?: string | null;
|
|
904
906
|
pre?: boolean;
|
|
905
907
|
stable?: boolean;
|
|
906
908
|
system: string;
|
|
@@ -916,6 +918,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
916
918
|
hyperlink?: string | null;
|
|
917
919
|
id?: number;
|
|
918
920
|
min?: boolean;
|
|
921
|
+
path_build_artifact?: string | null;
|
|
919
922
|
pre?: boolean;
|
|
920
923
|
stable?: boolean;
|
|
921
924
|
system?: string;
|
package/dist/types/db.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export type IHealthMetricSummaryRow = Database["public"]["Functions"]["get_healt
|
|
|
33
33
|
export type IArtifactWithMediaUrl = IArtifact & {
|
|
34
34
|
media_url?: string | null;
|
|
35
35
|
};
|
|
36
|
+
export type IVersionsSoftwareWithBuildUrl = IVersionsSoftware & {
|
|
37
|
+
build_artifact_url?: string | null;
|
|
38
|
+
};
|
|
36
39
|
export interface ISessionSummary {
|
|
37
40
|
total_session_time_minutes: number;
|
|
38
41
|
total_session_time_night_minutes: number;
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -931,6 +931,7 @@ export type Database = {
|
|
|
931
931
|
hyperlink: string | null;
|
|
932
932
|
id: number;
|
|
933
933
|
min: boolean;
|
|
934
|
+
path_build_artifact: string | null;
|
|
934
935
|
pre: boolean;
|
|
935
936
|
stable: boolean;
|
|
936
937
|
system: string;
|
|
@@ -946,6 +947,7 @@ export type Database = {
|
|
|
946
947
|
hyperlink?: string | null;
|
|
947
948
|
id?: number;
|
|
948
949
|
min?: boolean;
|
|
950
|
+
path_build_artifact?: string | null;
|
|
949
951
|
pre?: boolean;
|
|
950
952
|
stable?: boolean;
|
|
951
953
|
system: string;
|
|
@@ -961,6 +963,7 @@ export type Database = {
|
|
|
961
963
|
hyperlink?: string | null;
|
|
962
964
|
id?: number;
|
|
963
965
|
min?: boolean;
|
|
966
|
+
path_build_artifact?: string | null;
|
|
964
967
|
pre?: boolean;
|
|
965
968
|
stable?: boolean;
|
|
966
969
|
system?: string;
|