@adventurelabs/scout-core 1.4.9 → 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/types/db.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";
|
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;
|