@adventurelabs/scout-core 1.4.13 → 1.4.15

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,4 +1,4 @@
1
- import { IArtifactWithMediaUrl } from "../types/db";
1
+ import { IArtifact, IArtifactWithMediaUrl, ArtifactInsert, ArtifactUpdate } from "../types/db";
2
2
  import { IWebResponseCompatible } from "../types/requests";
3
3
  import { SupabaseClient } from "@supabase/supabase-js";
4
4
  export declare function server_get_artifacts_by_herd(herd_id: number, limit?: number, offset?: number, client?: SupabaseClient): Promise<IWebResponseCompatible<IArtifactWithMediaUrl[]>>;
@@ -7,3 +7,15 @@ export declare function server_get_total_artifacts_by_herd(herd_id: number): Pro
7
7
  export declare function server_get_artifacts_by_device_ids_batch(device_ids: number[], limit_per_device?: number, client?: SupabaseClient): Promise<{
8
8
  [device_id: number]: IArtifactWithMediaUrl[];
9
9
  }>;
10
+ export declare function server_insert_artifact(artifact: ArtifactInsert | ArtifactInsert[], client?: SupabaseClient): Promise<IWebResponseCompatible<IArtifact[]>>;
11
+ export declare function server_update_artifact(artifact: (ArtifactUpdate & {
12
+ id: number;
13
+ }) | (ArtifactUpdate & {
14
+ id: number;
15
+ })[], client?: SupabaseClient): Promise<IWebResponseCompatible<IArtifact[]>>;
16
+ export declare function server_delete_artifact(id: number | number[], client?: SupabaseClient): Promise<IWebResponseCompatible<boolean>>;
17
+ /** Semantic search over artifacts using Vertex multimodal embedding (embedding_vertex_mm_01). */
18
+ export declare function server_match_artifacts_by_vertex_embedding(query_embedding: number[], match_threshold: number, match_count: number, options?: {
19
+ herd_id?: number | null;
20
+ client?: SupabaseClient;
21
+ }): Promise<IWebResponseCompatible<IArtifact[]>>;
@@ -119,3 +119,59 @@ export async function server_get_artifacts_by_device_ids_batch(device_ids, limit
119
119
  });
120
120
  return artifactsByDevice;
121
121
  }
122
+ export async function server_insert_artifact(artifact, client) {
123
+ const supabase = client || (await newServerClient());
124
+ const arr = Array.isArray(artifact) ? artifact : [artifact];
125
+ const { data, error } = await supabase
126
+ .from("artifacts")
127
+ .insert(arr)
128
+ .select("*");
129
+ if (error) {
130
+ return IWebResponse.error(error.message).to_compatible();
131
+ }
132
+ return IWebResponse.success(data || []).to_compatible();
133
+ }
134
+ export async function server_update_artifact(artifact, client) {
135
+ const supabase = client || (await newServerClient());
136
+ const arr = Array.isArray(artifact) ? artifact : [artifact];
137
+ const results = [];
138
+ for (const record of arr) {
139
+ const { id, ...updateData } = record;
140
+ delete updateData.created_at;
141
+ const { data, error } = await supabase
142
+ .from("artifacts")
143
+ .update(updateData)
144
+ .eq("id", id)
145
+ .select("*")
146
+ .single();
147
+ if (error) {
148
+ return IWebResponse.error(error.message).to_compatible();
149
+ }
150
+ if (data)
151
+ results.push(data);
152
+ }
153
+ return IWebResponse.success(results).to_compatible();
154
+ }
155
+ export async function server_delete_artifact(id, client) {
156
+ const supabase = client || (await newServerClient());
157
+ const ids = Array.isArray(id) ? id : [id];
158
+ const { error } = await supabase.from("artifacts").delete().in("id", ids);
159
+ if (error) {
160
+ return IWebResponse.error(error.message).to_compatible();
161
+ }
162
+ return IWebResponse.success(true).to_compatible();
163
+ }
164
+ /** Semantic search over artifacts using Vertex multimodal embedding (embedding_vertex_mm_01). */
165
+ export async function server_match_artifacts_by_vertex_embedding(query_embedding, match_threshold, match_count, options) {
166
+ const supabase = options?.client ?? (await newServerClient());
167
+ const { data, error } = await supabase.rpc("match_artifacts_by_vertex_embedding", {
168
+ query_embedding: query_embedding,
169
+ match_threshold,
170
+ match_count,
171
+ herd_id_caller: options?.herd_id ?? null,
172
+ });
173
+ if (error) {
174
+ return IWebResponse.error(error.message).to_compatible();
175
+ }
176
+ return IWebResponse.success((data ?? [])).to_compatible();
177
+ }
@@ -9,3 +9,8 @@ export declare function server_update_event(events: (EventUpdate & {
9
9
  }) | (EventUpdate & {
10
10
  id: number;
11
11
  })[], client?: SupabaseClient): Promise<IWebResponseCompatible<IEvent[]>>;
12
+ /** Semantic search over events using Vertex multimodal embedding (embedding_vertex_mm_01). */
13
+ export declare function server_match_events_by_vertex_embedding(query_embedding: number[], match_threshold: number, match_count: number, options?: {
14
+ herd_id?: number | null;
15
+ client?: SupabaseClient;
16
+ }): Promise<IWebResponseCompatible<IEvent[]>>;
@@ -70,3 +70,18 @@ export async function server_update_event(events, client) {
70
70
  }
71
71
  return IWebResponse.success(updatedEvents).to_compatible();
72
72
  }
73
+ /** Semantic search over events using Vertex multimodal embedding (embedding_vertex_mm_01). */
74
+ export async function server_match_events_by_vertex_embedding(query_embedding, match_threshold, match_count, options) {
75
+ const supabase = options?.client ?? (await newServerClient());
76
+ const rpcName = "match_events_by_vertex_embedding";
77
+ const { data, error } = await supabase.rpc(rpcName, {
78
+ query_embedding: JSON.stringify(query_embedding),
79
+ match_threshold,
80
+ match_count,
81
+ herd_id_caller: options?.herd_id ?? undefined,
82
+ });
83
+ if (error) {
84
+ return IWebResponse.error(error.message).to_compatible();
85
+ }
86
+ return IWebResponse.success((data ?? [])).to_compatible();
87
+ }
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from "./types/supabase";
10
10
  export * from "./types/bounding_boxes";
11
11
  export * from "./types/events";
12
12
  export * from "./types/connectivity";
13
+ export * from "./helpers/artifacts";
13
14
  export * from "./helpers/auth";
14
15
  export * from "./helpers/bounding_boxes";
15
16
  export * from "./helpers/chat";
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ export * from "./types/bounding_boxes";
13
13
  export * from "./types/events";
14
14
  export * from "./types/connectivity";
15
15
  // Helpers
16
+ export * from "./helpers/artifacts";
16
17
  export * from "./helpers/auth";
17
18
  export * from "./helpers/bounding_boxes";
18
19
  export * from "./helpers/chat";
@@ -1637,6 +1637,65 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1637
1637
  };
1638
1638
  Returns: string[];
1639
1639
  };
1640
+ match_artifacts_by_vertex_embedding: {
1641
+ Args: {
1642
+ herd_id_caller?: number;
1643
+ match_count: number;
1644
+ match_threshold: number;
1645
+ query_embedding: string;
1646
+ };
1647
+ Returns: {
1648
+ created_at: string;
1649
+ device_id: number;
1650
+ embedding_qwen_vl_2b: string | null;
1651
+ embedding_vertex_mm_01: string | null;
1652
+ file_path: string;
1653
+ id: number;
1654
+ modality: string | null;
1655
+ session_id: number | null;
1656
+ timestamp_observation: string | null;
1657
+ timestamp_observation_end: string;
1658
+ updated_at: string | null;
1659
+ }[];
1660
+ SetofOptions: {
1661
+ from: "*";
1662
+ to: "artifacts";
1663
+ isOneToOne: false;
1664
+ isSetofReturn: true;
1665
+ };
1666
+ };
1667
+ match_events_by_vertex_embedding: {
1668
+ Args: {
1669
+ herd_id_caller?: number;
1670
+ match_count: number;
1671
+ match_threshold: number;
1672
+ query_embedding: string;
1673
+ };
1674
+ Returns: {
1675
+ altitude: number;
1676
+ device_id: number;
1677
+ earthranger_url: string | null;
1678
+ embedding_qwen_vl_2b: string | null;
1679
+ embedding_vertex_mm_01: string | null;
1680
+ file_path: string | null;
1681
+ heading: number;
1682
+ id: number;
1683
+ inserted_at: string;
1684
+ is_public: boolean;
1685
+ location: unknown;
1686
+ media_type: Database["public"]["Enums"]["media_type"];
1687
+ media_url: string | null;
1688
+ message: string | null;
1689
+ session_id: number | null;
1690
+ timestamp_observation: string;
1691
+ }[];
1692
+ SetofOptions: {
1693
+ from: "*";
1694
+ to: "events";
1695
+ isOneToOne: false;
1696
+ isSetofReturn: true;
1697
+ };
1698
+ };
1640
1699
  remove_rls_broadcast_triggers: {
1641
1700
  Args: never;
1642
1701
  Returns: undefined;
@@ -58,6 +58,7 @@ export type ISessionUsageOverTime = Database["public"]["Functions"]["get_session
58
58
  export type PartInsert = Database["public"]["Tables"]["parts"]["Insert"];
59
59
  export type VersionsSoftwareInsert = Database["public"]["Tables"]["versions_software"]["Insert"];
60
60
  export type ArtifactInsert = Database["public"]["Tables"]["artifacts"]["Insert"];
61
+ export type ArtifactUpdate = Database["public"]["Tables"]["artifacts"]["Update"];
61
62
  export type PinInsert = Database["public"]["Tables"]["pins"]["Insert"];
62
63
  export type SessionInsert = Database["public"]["Tables"]["sessions"]["Insert"];
63
64
  export type SessionUpdate = Database["public"]["Tables"]["sessions"]["Update"];
@@ -1693,6 +1693,65 @@ export type Database = {
1693
1693
  };
1694
1694
  Returns: string[];
1695
1695
  };
1696
+ match_artifacts_by_vertex_embedding: {
1697
+ Args: {
1698
+ herd_id_caller?: number;
1699
+ match_count: number;
1700
+ match_threshold: number;
1701
+ query_embedding: string;
1702
+ };
1703
+ Returns: {
1704
+ created_at: string;
1705
+ device_id: number;
1706
+ embedding_qwen_vl_2b: string | null;
1707
+ embedding_vertex_mm_01: string | null;
1708
+ file_path: string;
1709
+ id: number;
1710
+ modality: string | null;
1711
+ session_id: number | null;
1712
+ timestamp_observation: string | null;
1713
+ timestamp_observation_end: string;
1714
+ updated_at: string | null;
1715
+ }[];
1716
+ SetofOptions: {
1717
+ from: "*";
1718
+ to: "artifacts";
1719
+ isOneToOne: false;
1720
+ isSetofReturn: true;
1721
+ };
1722
+ };
1723
+ match_events_by_vertex_embedding: {
1724
+ Args: {
1725
+ herd_id_caller?: number;
1726
+ match_count: number;
1727
+ match_threshold: number;
1728
+ query_embedding: string;
1729
+ };
1730
+ Returns: {
1731
+ altitude: number;
1732
+ device_id: number;
1733
+ earthranger_url: string | null;
1734
+ embedding_qwen_vl_2b: string | null;
1735
+ embedding_vertex_mm_01: string | null;
1736
+ file_path: string | null;
1737
+ heading: number;
1738
+ id: number;
1739
+ inserted_at: string;
1740
+ is_public: boolean;
1741
+ location: unknown;
1742
+ media_type: Database["public"]["Enums"]["media_type"];
1743
+ media_url: string | null;
1744
+ message: string | null;
1745
+ session_id: number | null;
1746
+ timestamp_observation: string;
1747
+ }[];
1748
+ SetofOptions: {
1749
+ from: "*";
1750
+ to: "events";
1751
+ isOneToOne: false;
1752
+ isSetofReturn: true;
1753
+ };
1754
+ };
1696
1755
  remove_rls_broadcast_triggers: {
1697
1756
  Args: never;
1698
1757
  Returns: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.4.13",
3
+ "version": "1.4.15",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",