@adventurelabs/scout-core 1.4.38 → 1.4.39

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.
@@ -9,7 +9,12 @@ export declare function server_update_connectivity(connectivity: (ConnectivityUp
9
9
  }) | (ConnectivityUpdate & {
10
10
  id: number;
11
11
  })[], client?: SupabaseClient): Promise<IWebResponseCompatible<IConnectivity[]>>;
12
- /** Connectivity records for a herd within a time range */
13
- export declare function server_get_connectivity_for_herd_time_range(herdId: number, startTimestamp: string, endTimestamp: string, maxCount?: number): Promise<IWebResponseCompatible<IConnectivityWithCoordinates[]>>;
12
+ /** Pagination info returned with herd time range connectivity. */
13
+ export type HerdConnectivityTimeRangeResponse = IWebResponseCompatible<IConnectivityWithCoordinates[]> & {
14
+ hasMore: boolean;
15
+ nextOffset: number;
16
+ };
17
+ /** Connectivity records for a herd within a time range. Returns most recent rows with hasMore and nextOffset for pagination. */
18
+ export declare function server_get_connectivity_for_herd_time_range(herdId: number, startTimestamp: string, endTimestamp: string, maxCount?: number, offset?: number): Promise<HerdConnectivityTimeRangeResponse>;
14
19
  /** Connectivity records for an artifact (uses session when set, else device + time window). */
15
20
  export declare function server_get_connectivity_for_artifact(artifactId: number, maxElements?: number): Promise<IWebResponseCompatible<IConnectivityWithCoordinates[]>>;
@@ -96,14 +96,15 @@ export async function server_update_connectivity(connectivity, client) {
96
96
  }
97
97
  return IWebResponse.success(updatedConnectivity).to_compatible();
98
98
  }
99
- /** Connectivity records for a herd within a time range */
100
- export async function server_get_connectivity_for_herd_time_range(herdId, startTimestamp, endTimestamp, maxCount = 1000) {
99
+ /** Connectivity records for a herd within a time range. Returns most recent rows with hasMore and nextOffset for pagination. */
100
+ export async function server_get_connectivity_for_herd_time_range(herdId, startTimestamp, endTimestamp, maxCount = 1000, offset = 0) {
101
101
  const supabase = await newServerClient();
102
102
  const { data, error } = await supabase.rpc("get_connectivity_for_herd_time_range", {
103
103
  herd_id_caller: herdId,
104
104
  start_timestamp_caller: startTimestamp,
105
105
  end_timestamp_caller: endTimestamp,
106
- max_elements_caller: maxCount,
106
+ max_elements_caller: maxCount + 1,
107
+ offset_caller: offset,
107
108
  });
108
109
  if (error) {
109
110
  console.warn("Error fetching connectivity for herd time range:", error.message);
@@ -111,15 +112,24 @@ export async function server_get_connectivity_for_herd_time_range(herdId, startT
111
112
  status: EnumWebResponse.ERROR,
112
113
  msg: error.message,
113
114
  data: [],
115
+ hasMore: false,
116
+ nextOffset: offset,
114
117
  };
115
118
  }
116
- const sortedConnectivity = (data || []).sort((a, b) => {
119
+ const sorted = (data || []).sort((a, b) => {
117
120
  if (!a.timestamp_start || !b.timestamp_start)
118
121
  return 0;
119
122
  return (new Date(a.timestamp_start).getTime() -
120
123
  new Date(b.timestamp_start).getTime());
121
124
  });
122
- return IWebResponse.success(sortedConnectivity).to_compatible();
125
+ const hasMore = sorted.length > maxCount;
126
+ const items = hasMore ? sorted.slice(0, maxCount) : sorted;
127
+ const nextOffset = offset + items.length;
128
+ return {
129
+ ...IWebResponse.success(items).to_compatible(),
130
+ hasMore,
131
+ nextOffset,
132
+ };
123
133
  }
124
134
  /** Connectivity records for an artifact (uses session when set, else device + time window). */
125
135
  export async function server_get_connectivity_for_artifact(artifactId, maxElements = 1000) {
@@ -1488,6 +1488,18 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1488
1488
  timestamp_start: string;
1489
1489
  }[];
1490
1490
  };
1491
+ fix_all_sessions_missing_distance: {
1492
+ Args: never;
1493
+ Returns: {
1494
+ device_id: number;
1495
+ new_distance_max_from_start: number;
1496
+ new_distance_total: number;
1497
+ old_distance_max_from_start: number;
1498
+ old_distance_total: number;
1499
+ session_id: number;
1500
+ status: string;
1501
+ }[];
1502
+ };
1491
1503
  fix_all_sessions_missing_end_timestamps: {
1492
1504
  Args: never;
1493
1505
  Returns: {
@@ -1498,6 +1510,19 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1498
1510
  status: string;
1499
1511
  }[];
1500
1512
  };
1513
+ fix_session_distance_from_connectivity: {
1514
+ Args: {
1515
+ session_id_param: number;
1516
+ };
1517
+ Returns: {
1518
+ new_distance_max_from_start: number;
1519
+ new_distance_total: number;
1520
+ old_distance_max_from_start: number;
1521
+ old_distance_total: number;
1522
+ session_id: number;
1523
+ status: string;
1524
+ }[];
1525
+ };
1501
1526
  fix_session_end_timestamp: {
1502
1527
  Args: {
1503
1528
  session_id_param: number;
@@ -1753,6 +1778,36 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1753
1778
  isOneToOne: false;
1754
1779
  isSetofReturn: true;
1755
1780
  };
1781
+ } | {
1782
+ Args: {
1783
+ end_timestamp_caller: string;
1784
+ herd_id_caller: number;
1785
+ max_elements_caller?: number;
1786
+ offset_caller?: number;
1787
+ start_timestamp_caller: string;
1788
+ };
1789
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1790
+ SetofOptions: {
1791
+ from: "*";
1792
+ to: "connectivity_with_coordinates";
1793
+ isOneToOne: false;
1794
+ isSetofReturn: true;
1795
+ };
1796
+ } | {
1797
+ Args: {
1798
+ end_timestamp_caller: string;
1799
+ herd_id_caller: number;
1800
+ max_elements_caller?: number;
1801
+ sample_caller?: boolean;
1802
+ start_timestamp_caller: string;
1803
+ };
1804
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1805
+ SetofOptions: {
1806
+ from: "*";
1807
+ to: "connectivity_with_coordinates";
1808
+ isOneToOne: false;
1809
+ isSetofReturn: true;
1810
+ };
1756
1811
  };
1757
1812
  get_connectivity_with_coordinates: {
1758
1813
  Args: {
@@ -2195,6 +2250,31 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
2195
2250
  isSetofReturn: true;
2196
2251
  };
2197
2252
  };
2253
+ preview_fix_all_sessions_missing_distance: {
2254
+ Args: never;
2255
+ Returns: {
2256
+ device_id: number;
2257
+ new_distance_max_from_start: number;
2258
+ new_distance_total: number;
2259
+ old_distance_max_from_start: number;
2260
+ old_distance_total: number;
2261
+ session_id: number;
2262
+ status: string;
2263
+ }[];
2264
+ };
2265
+ preview_fix_session_distance_from_connectivity: {
2266
+ Args: {
2267
+ session_id_param: number;
2268
+ };
2269
+ Returns: {
2270
+ new_distance_max_from_start: number;
2271
+ new_distance_total: number;
2272
+ old_distance_max_from_start: number;
2273
+ old_distance_total: number;
2274
+ session_id: number;
2275
+ status: string;
2276
+ }[];
2277
+ };
2198
2278
  remove_rls_broadcast_triggers: {
2199
2279
  Args: never;
2200
2280
  Returns: undefined;
@@ -1565,6 +1565,18 @@ export type Database = {
1565
1565
  timestamp_start: string;
1566
1566
  }[];
1567
1567
  };
1568
+ fix_all_sessions_missing_distance: {
1569
+ Args: never;
1570
+ Returns: {
1571
+ device_id: number;
1572
+ new_distance_max_from_start: number;
1573
+ new_distance_total: number;
1574
+ old_distance_max_from_start: number;
1575
+ old_distance_total: number;
1576
+ session_id: number;
1577
+ status: string;
1578
+ }[];
1579
+ };
1568
1580
  fix_all_sessions_missing_end_timestamps: {
1569
1581
  Args: never;
1570
1582
  Returns: {
@@ -1575,6 +1587,19 @@ export type Database = {
1575
1587
  status: string;
1576
1588
  }[];
1577
1589
  };
1590
+ fix_session_distance_from_connectivity: {
1591
+ Args: {
1592
+ session_id_param: number;
1593
+ };
1594
+ Returns: {
1595
+ new_distance_max_from_start: number;
1596
+ new_distance_total: number;
1597
+ old_distance_max_from_start: number;
1598
+ old_distance_total: number;
1599
+ session_id: number;
1600
+ status: string;
1601
+ }[];
1602
+ };
1578
1603
  fix_session_end_timestamp: {
1579
1604
  Args: {
1580
1605
  session_id_param: number;
@@ -1830,6 +1855,36 @@ export type Database = {
1830
1855
  isOneToOne: false;
1831
1856
  isSetofReturn: true;
1832
1857
  };
1858
+ } | {
1859
+ Args: {
1860
+ end_timestamp_caller: string;
1861
+ herd_id_caller: number;
1862
+ max_elements_caller?: number;
1863
+ offset_caller?: number;
1864
+ start_timestamp_caller: string;
1865
+ };
1866
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1867
+ SetofOptions: {
1868
+ from: "*";
1869
+ to: "connectivity_with_coordinates";
1870
+ isOneToOne: false;
1871
+ isSetofReturn: true;
1872
+ };
1873
+ } | {
1874
+ Args: {
1875
+ end_timestamp_caller: string;
1876
+ herd_id_caller: number;
1877
+ max_elements_caller?: number;
1878
+ sample_caller?: boolean;
1879
+ start_timestamp_caller: string;
1880
+ };
1881
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1882
+ SetofOptions: {
1883
+ from: "*";
1884
+ to: "connectivity_with_coordinates";
1885
+ isOneToOne: false;
1886
+ isSetofReturn: true;
1887
+ };
1833
1888
  };
1834
1889
  get_connectivity_with_coordinates: {
1835
1890
  Args: {
@@ -2272,6 +2327,31 @@ export type Database = {
2272
2327
  isSetofReturn: true;
2273
2328
  };
2274
2329
  };
2330
+ preview_fix_all_sessions_missing_distance: {
2331
+ Args: never;
2332
+ Returns: {
2333
+ device_id: number;
2334
+ new_distance_max_from_start: number;
2335
+ new_distance_total: number;
2336
+ old_distance_max_from_start: number;
2337
+ old_distance_total: number;
2338
+ session_id: number;
2339
+ status: string;
2340
+ }[];
2341
+ };
2342
+ preview_fix_session_distance_from_connectivity: {
2343
+ Args: {
2344
+ session_id_param: number;
2345
+ };
2346
+ Returns: {
2347
+ new_distance_max_from_start: number;
2348
+ new_distance_total: number;
2349
+ old_distance_max_from_start: number;
2350
+ old_distance_total: number;
2351
+ session_id: number;
2352
+ status: string;
2353
+ }[];
2354
+ };
2275
2355
  remove_rls_broadcast_triggers: {
2276
2356
  Args: never;
2277
2357
  Returns: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.4.38",
3
+ "version": "1.4.39",
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",