@adventurelabs/scout-core 1.4.82 → 1.4.83
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/models.d.ts +11 -0
- package/dist/helpers/models.js +95 -0
- package/dist/types/db.d.ts +2 -0
- package/package.json +1 -1
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IModel, IModelsPerJobsPerHerd } from "../types/db";
|
|
2
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
3
|
+
export declare function server_get_model_by_id(model_id: number): Promise<IWebResponseCompatible<IModel | null>>;
|
|
4
|
+
export declare function server_get_models_by_ids(model_ids: number[]): Promise<IWebResponseCompatible<IModel[]>>;
|
|
5
|
+
export declare function server_get_models(options?: {
|
|
6
|
+
include_inactive?: boolean;
|
|
7
|
+
}): Promise<IWebResponseCompatible<IModel[]>>;
|
|
8
|
+
export declare function server_get_models_per_jobs_per_herd_by_herd(herd_id: number): Promise<IWebResponseCompatible<IModelsPerJobsPerHerd[]>>;
|
|
9
|
+
export declare function server_create_models_per_jobs_per_herd(activation: Omit<IModelsPerJobsPerHerd, "id" | "inserted_at">): Promise<IWebResponseCompatible<IModelsPerJobsPerHerd>>;
|
|
10
|
+
export declare function server_update_models_per_jobs_per_herd(id: number, updates: Partial<Omit<IModelsPerJobsPerHerd, "id" | "inserted_at">>): Promise<IWebResponseCompatible<IModelsPerJobsPerHerd>>;
|
|
11
|
+
export declare function server_delete_models_per_jobs_per_herd_by_ids(ids: number[]): Promise<IWebResponseCompatible<boolean>>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { newServerClient } from "../supabase/server";
|
|
3
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
4
|
+
// function that fetches a single model by id; null if not found
|
|
5
|
+
export async function server_get_model_by_id(model_id) {
|
|
6
|
+
const supabase = await newServerClient();
|
|
7
|
+
const { data, error } = await supabase
|
|
8
|
+
.from("models")
|
|
9
|
+
.select("*")
|
|
10
|
+
.eq("id", model_id)
|
|
11
|
+
.maybeSingle();
|
|
12
|
+
if (error) {
|
|
13
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
14
|
+
}
|
|
15
|
+
return IWebResponse.success(data).to_compatible();
|
|
16
|
+
}
|
|
17
|
+
// function that fetches multiple models by id
|
|
18
|
+
export async function server_get_models_by_ids(model_ids) {
|
|
19
|
+
if (model_ids.length === 0) {
|
|
20
|
+
return IWebResponse.success([]).to_compatible();
|
|
21
|
+
}
|
|
22
|
+
const supabase = await newServerClient();
|
|
23
|
+
const { data, error } = await supabase
|
|
24
|
+
.from("models")
|
|
25
|
+
.select("*")
|
|
26
|
+
.in("id", model_ids);
|
|
27
|
+
if (error) {
|
|
28
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
29
|
+
}
|
|
30
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
31
|
+
}
|
|
32
|
+
// function that lists models, active only by default
|
|
33
|
+
export async function server_get_models(options) {
|
|
34
|
+
const supabase = await newServerClient();
|
|
35
|
+
let query = supabase.from("models").select("*").order("name");
|
|
36
|
+
if (!options?.include_inactive) {
|
|
37
|
+
query = query.eq("is_active", true);
|
|
38
|
+
}
|
|
39
|
+
const { data, error } = await query;
|
|
40
|
+
if (error) {
|
|
41
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
42
|
+
}
|
|
43
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
44
|
+
}
|
|
45
|
+
// function that fetches the model activations for a herd
|
|
46
|
+
export async function server_get_models_per_jobs_per_herd_by_herd(herd_id) {
|
|
47
|
+
const supabase = await newServerClient();
|
|
48
|
+
const { data, error } = await supabase
|
|
49
|
+
.from("models_per_jobs_per_herd")
|
|
50
|
+
.select("*")
|
|
51
|
+
.eq("herd_id", herd_id);
|
|
52
|
+
if (error) {
|
|
53
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
54
|
+
}
|
|
55
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
56
|
+
}
|
|
57
|
+
// function that creates a model activation
|
|
58
|
+
export async function server_create_models_per_jobs_per_herd(activation) {
|
|
59
|
+
const supabase = await newServerClient();
|
|
60
|
+
const { data, error } = await supabase
|
|
61
|
+
.from("models_per_jobs_per_herd")
|
|
62
|
+
.insert(activation)
|
|
63
|
+
.select("*")
|
|
64
|
+
.single();
|
|
65
|
+
if (error) {
|
|
66
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
67
|
+
}
|
|
68
|
+
return IWebResponse.success(data).to_compatible();
|
|
69
|
+
}
|
|
70
|
+
// function that updates a model activation
|
|
71
|
+
export async function server_update_models_per_jobs_per_herd(id, updates) {
|
|
72
|
+
const supabase = await newServerClient();
|
|
73
|
+
const { data, error } = await supabase
|
|
74
|
+
.from("models_per_jobs_per_herd")
|
|
75
|
+
.update(updates)
|
|
76
|
+
.eq("id", id)
|
|
77
|
+
.select("*")
|
|
78
|
+
.single();
|
|
79
|
+
if (error) {
|
|
80
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
81
|
+
}
|
|
82
|
+
return IWebResponse.success(data).to_compatible();
|
|
83
|
+
}
|
|
84
|
+
// function that deletes model activations by ids
|
|
85
|
+
export async function server_delete_models_per_jobs_per_herd_by_ids(ids) {
|
|
86
|
+
const supabase = await newServerClient();
|
|
87
|
+
const { error } = await supabase
|
|
88
|
+
.from("models_per_jobs_per_herd")
|
|
89
|
+
.delete()
|
|
90
|
+
.in("id", ids);
|
|
91
|
+
if (error) {
|
|
92
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: false };
|
|
93
|
+
}
|
|
94
|
+
return IWebResponse.success(true).to_compatible();
|
|
95
|
+
}
|
package/dist/types/db.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export type IPin = Database["public"]["CompositeTypes"]["pins_pretty_location"];
|
|
|
19
19
|
export type IEvent = Database["public"]["Tables"]["events"]["Row"];
|
|
20
20
|
export type ITag = Database["public"]["Tables"]["tags"]["Row"];
|
|
21
21
|
export type ITagPrettyLocation = Database["public"]["CompositeTypes"]["tags_pretty_location"];
|
|
22
|
+
export type IModel = Database["public"]["Tables"]["models"]["Row"];
|
|
23
|
+
export type IModelsPerJobsPerHerd = Database["public"]["Tables"]["models_per_jobs_per_herd"]["Row"];
|
|
22
24
|
export type ISegmentationSam3 = Database["public"]["Tables"]["segmentations_sam3"]["Row"];
|
|
23
25
|
export type ISegmentationSam3Pretty = Database["public"]["CompositeTypes"]["segmentations_sam3_pretty"];
|
|
24
26
|
export type IPlan = Database["public"]["Tables"]["plans"]["Row"];
|