@adventurelabs/scout-core 1.4.38 → 1.4.40

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) {
@@ -61,6 +61,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
61
61
  tagged_at: string | null;
62
62
  timestamp_observation: string | null;
63
63
  timestamp_observation_end: string;
64
+ tracked_at: string | null;
64
65
  updated_at: string | null;
65
66
  };
66
67
  Insert: {
@@ -76,6 +77,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
76
77
  tagged_at?: string | null;
77
78
  timestamp_observation?: string | null;
78
79
  timestamp_observation_end?: string;
80
+ tracked_at?: string | null;
79
81
  updated_at?: string | null;
80
82
  };
81
83
  Update: {
@@ -91,6 +93,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
91
93
  tagged_at?: string | null;
92
94
  timestamp_observation?: string | null;
93
95
  timestamp_observation_end?: string;
96
+ tracked_at?: string | null;
94
97
  updated_at?: string | null;
95
98
  };
96
99
  Relationships: [{
@@ -456,6 +459,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
456
459
  session_id: number | null;
457
460
  tagged_at: string | null;
458
461
  timestamp_observation: string;
462
+ tracked_at: string | null;
459
463
  };
460
464
  Insert: {
461
465
  altitude?: number;
@@ -475,6 +479,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
475
479
  session_id?: number | null;
476
480
  tagged_at?: string | null;
477
481
  timestamp_observation?: string;
482
+ tracked_at?: string | null;
478
483
  };
479
484
  Update: {
480
485
  altitude?: number;
@@ -494,6 +499,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
494
499
  session_id?: number | null;
495
500
  tagged_at?: string | null;
496
501
  timestamp_observation?: string;
502
+ tracked_at?: string | null;
497
503
  };
498
504
  Relationships: [{
499
505
  foreignKeyName: "events_device_id_fkey";
@@ -1423,6 +1429,13 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1423
1429
  };
1424
1430
  };
1425
1431
  Functions: {
1432
+ ack_queue_message: {
1433
+ Args: {
1434
+ message_id: number;
1435
+ queue_name: string;
1436
+ };
1437
+ Returns: boolean;
1438
+ };
1426
1439
  analyze_device_heartbeats: {
1427
1440
  Args: {
1428
1441
  p_device_id: number;
@@ -1488,6 +1501,18 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1488
1501
  timestamp_start: string;
1489
1502
  }[];
1490
1503
  };
1504
+ fix_all_sessions_missing_distance: {
1505
+ Args: never;
1506
+ Returns: {
1507
+ device_id: number;
1508
+ new_distance_max_from_start: number;
1509
+ new_distance_total: number;
1510
+ old_distance_max_from_start: number;
1511
+ old_distance_total: number;
1512
+ session_id: number;
1513
+ status: string;
1514
+ }[];
1515
+ };
1491
1516
  fix_all_sessions_missing_end_timestamps: {
1492
1517
  Args: never;
1493
1518
  Returns: {
@@ -1498,6 +1523,19 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1498
1523
  status: string;
1499
1524
  }[];
1500
1525
  };
1526
+ fix_session_distance_from_connectivity: {
1527
+ Args: {
1528
+ session_id_param: number;
1529
+ };
1530
+ Returns: {
1531
+ new_distance_max_from_start: number;
1532
+ new_distance_total: number;
1533
+ old_distance_max_from_start: number;
1534
+ old_distance_total: number;
1535
+ session_id: number;
1536
+ status: string;
1537
+ }[];
1538
+ };
1501
1539
  fix_session_end_timestamp: {
1502
1540
  Args: {
1503
1541
  session_id_param: number;
@@ -1534,6 +1572,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1534
1572
  tagged_at: string | null;
1535
1573
  timestamp_observation: string | null;
1536
1574
  timestamp_observation_end: string;
1575
+ tracked_at: string | null;
1537
1576
  updated_at: string | null;
1538
1577
  }[];
1539
1578
  SetofOptions: {
@@ -1561,6 +1600,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1561
1600
  tagged_at: string | null;
1562
1601
  timestamp_observation: string | null;
1563
1602
  timestamp_observation_end: string;
1603
+ tracked_at: string | null;
1564
1604
  updated_at: string | null;
1565
1605
  }[];
1566
1606
  SetofOptions: {
@@ -1589,6 +1629,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1589
1629
  tagged_at: string | null;
1590
1630
  timestamp_observation: string | null;
1591
1631
  timestamp_observation_end: string;
1632
+ tracked_at: string | null;
1592
1633
  updated_at: string | null;
1593
1634
  }[];
1594
1635
  SetofOptions: {
@@ -1617,6 +1658,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1617
1658
  tagged_at: string | null;
1618
1659
  timestamp_observation: string | null;
1619
1660
  timestamp_observation_end: string;
1661
+ tracked_at: string | null;
1620
1662
  updated_at: string | null;
1621
1663
  }[];
1622
1664
  SetofOptions: {
@@ -1646,6 +1688,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1646
1688
  tagged_at: string | null;
1647
1689
  timestamp_observation: string | null;
1648
1690
  timestamp_observation_end: string;
1691
+ tracked_at: string | null;
1649
1692
  updated_at: string | null;
1650
1693
  }[];
1651
1694
  SetofOptions: {
@@ -1675,6 +1718,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1675
1718
  tagged_at: string | null;
1676
1719
  timestamp_observation: string | null;
1677
1720
  timestamp_observation_end: string;
1721
+ tracked_at: string | null;
1678
1722
  updated_at: string | null;
1679
1723
  }[];
1680
1724
  SetofOptions: {
@@ -1704,6 +1748,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1704
1748
  tagged_at: string | null;
1705
1749
  timestamp_observation: string | null;
1706
1750
  timestamp_observation_end: string;
1751
+ tracked_at: string | null;
1707
1752
  updated_at: string | null;
1708
1753
  }[];
1709
1754
  SetofOptions: {
@@ -1753,6 +1798,36 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1753
1798
  isOneToOne: false;
1754
1799
  isSetofReturn: true;
1755
1800
  };
1801
+ } | {
1802
+ Args: {
1803
+ end_timestamp_caller: string;
1804
+ herd_id_caller: number;
1805
+ max_elements_caller?: number;
1806
+ offset_caller?: number;
1807
+ start_timestamp_caller: string;
1808
+ };
1809
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1810
+ SetofOptions: {
1811
+ from: "*";
1812
+ to: "connectivity_with_coordinates";
1813
+ isOneToOne: false;
1814
+ isSetofReturn: true;
1815
+ };
1816
+ } | {
1817
+ Args: {
1818
+ end_timestamp_caller: string;
1819
+ herd_id_caller: number;
1820
+ max_elements_caller?: number;
1821
+ sample_caller?: boolean;
1822
+ start_timestamp_caller: string;
1823
+ };
1824
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1825
+ SetofOptions: {
1826
+ from: "*";
1827
+ to: "connectivity_with_coordinates";
1828
+ isOneToOne: false;
1829
+ isSetofReturn: true;
1830
+ };
1756
1831
  };
1757
1832
  get_connectivity_with_coordinates: {
1758
1833
  Args: {
@@ -2195,6 +2270,31 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
2195
2270
  isSetofReturn: true;
2196
2271
  };
2197
2272
  };
2273
+ preview_fix_all_sessions_missing_distance: {
2274
+ Args: never;
2275
+ Returns: {
2276
+ device_id: number;
2277
+ new_distance_max_from_start: number;
2278
+ new_distance_total: number;
2279
+ old_distance_max_from_start: number;
2280
+ old_distance_total: number;
2281
+ session_id: number;
2282
+ status: string;
2283
+ }[];
2284
+ };
2285
+ preview_fix_session_distance_from_connectivity: {
2286
+ Args: {
2287
+ session_id_param: number;
2288
+ };
2289
+ Returns: {
2290
+ new_distance_max_from_start: number;
2291
+ new_distance_total: number;
2292
+ old_distance_max_from_start: number;
2293
+ old_distance_total: number;
2294
+ session_id: number;
2295
+ status: string;
2296
+ }[];
2297
+ };
2198
2298
  remove_rls_broadcast_triggers: {
2199
2299
  Args: never;
2200
2300
  Returns: undefined;
@@ -2222,6 +2322,20 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
2222
2322
  };
2223
2323
  Returns: undefined;
2224
2324
  };
2325
+ sync_orphan_session_links: {
2326
+ Args: {
2327
+ preview?: boolean;
2328
+ };
2329
+ Returns: {
2330
+ assigned_session_id: number;
2331
+ candidate_session_count: number;
2332
+ device_id: number;
2333
+ entity_id: number;
2334
+ entity_type: string;
2335
+ old_session_id: number;
2336
+ status: string;
2337
+ }[];
2338
+ };
2225
2339
  };
2226
2340
  Enums: {
2227
2341
  app_permission: "herds.delete" | "events.delete";
@@ -60,6 +60,7 @@ export type Database = {
60
60
  tagged_at: string | null;
61
61
  timestamp_observation: string | null;
62
62
  timestamp_observation_end: string;
63
+ tracked_at: string | null;
63
64
  updated_at: string | null;
64
65
  };
65
66
  Insert: {
@@ -75,6 +76,7 @@ export type Database = {
75
76
  tagged_at?: string | null;
76
77
  timestamp_observation?: string | null;
77
78
  timestamp_observation_end?: string;
79
+ tracked_at?: string | null;
78
80
  updated_at?: string | null;
79
81
  };
80
82
  Update: {
@@ -90,6 +92,7 @@ export type Database = {
90
92
  tagged_at?: string | null;
91
93
  timestamp_observation?: string | null;
92
94
  timestamp_observation_end?: string;
95
+ tracked_at?: string | null;
93
96
  updated_at?: string | null;
94
97
  };
95
98
  Relationships: [
@@ -476,6 +479,7 @@ export type Database = {
476
479
  session_id: number | null;
477
480
  tagged_at: string | null;
478
481
  timestamp_observation: string;
482
+ tracked_at: string | null;
479
483
  };
480
484
  Insert: {
481
485
  altitude?: number;
@@ -495,6 +499,7 @@ export type Database = {
495
499
  session_id?: number | null;
496
500
  tagged_at?: string | null;
497
501
  timestamp_observation?: string;
502
+ tracked_at?: string | null;
498
503
  };
499
504
  Update: {
500
505
  altitude?: number;
@@ -514,6 +519,7 @@ export type Database = {
514
519
  session_id?: number | null;
515
520
  tagged_at?: string | null;
516
521
  timestamp_observation?: string;
522
+ tracked_at?: string | null;
517
523
  };
518
524
  Relationships: [
519
525
  {
@@ -1500,6 +1506,13 @@ export type Database = {
1500
1506
  };
1501
1507
  };
1502
1508
  Functions: {
1509
+ ack_queue_message: {
1510
+ Args: {
1511
+ message_id: number;
1512
+ queue_name: string;
1513
+ };
1514
+ Returns: boolean;
1515
+ };
1503
1516
  analyze_device_heartbeats: {
1504
1517
  Args: {
1505
1518
  p_device_id: number;
@@ -1565,6 +1578,18 @@ export type Database = {
1565
1578
  timestamp_start: string;
1566
1579
  }[];
1567
1580
  };
1581
+ fix_all_sessions_missing_distance: {
1582
+ Args: never;
1583
+ Returns: {
1584
+ device_id: number;
1585
+ new_distance_max_from_start: number;
1586
+ new_distance_total: number;
1587
+ old_distance_max_from_start: number;
1588
+ old_distance_total: number;
1589
+ session_id: number;
1590
+ status: string;
1591
+ }[];
1592
+ };
1568
1593
  fix_all_sessions_missing_end_timestamps: {
1569
1594
  Args: never;
1570
1595
  Returns: {
@@ -1575,6 +1600,19 @@ export type Database = {
1575
1600
  status: string;
1576
1601
  }[];
1577
1602
  };
1603
+ fix_session_distance_from_connectivity: {
1604
+ Args: {
1605
+ session_id_param: number;
1606
+ };
1607
+ Returns: {
1608
+ new_distance_max_from_start: number;
1609
+ new_distance_total: number;
1610
+ old_distance_max_from_start: number;
1611
+ old_distance_total: number;
1612
+ session_id: number;
1613
+ status: string;
1614
+ }[];
1615
+ };
1578
1616
  fix_session_end_timestamp: {
1579
1617
  Args: {
1580
1618
  session_id_param: number;
@@ -1611,6 +1649,7 @@ export type Database = {
1611
1649
  tagged_at: string | null;
1612
1650
  timestamp_observation: string | null;
1613
1651
  timestamp_observation_end: string;
1652
+ tracked_at: string | null;
1614
1653
  updated_at: string | null;
1615
1654
  }[];
1616
1655
  SetofOptions: {
@@ -1638,6 +1677,7 @@ export type Database = {
1638
1677
  tagged_at: string | null;
1639
1678
  timestamp_observation: string | null;
1640
1679
  timestamp_observation_end: string;
1680
+ tracked_at: string | null;
1641
1681
  updated_at: string | null;
1642
1682
  }[];
1643
1683
  SetofOptions: {
@@ -1666,6 +1706,7 @@ export type Database = {
1666
1706
  tagged_at: string | null;
1667
1707
  timestamp_observation: string | null;
1668
1708
  timestamp_observation_end: string;
1709
+ tracked_at: string | null;
1669
1710
  updated_at: string | null;
1670
1711
  }[];
1671
1712
  SetofOptions: {
@@ -1694,6 +1735,7 @@ export type Database = {
1694
1735
  tagged_at: string | null;
1695
1736
  timestamp_observation: string | null;
1696
1737
  timestamp_observation_end: string;
1738
+ tracked_at: string | null;
1697
1739
  updated_at: string | null;
1698
1740
  }[];
1699
1741
  SetofOptions: {
@@ -1723,6 +1765,7 @@ export type Database = {
1723
1765
  tagged_at: string | null;
1724
1766
  timestamp_observation: string | null;
1725
1767
  timestamp_observation_end: string;
1768
+ tracked_at: string | null;
1726
1769
  updated_at: string | null;
1727
1770
  }[];
1728
1771
  SetofOptions: {
@@ -1752,6 +1795,7 @@ export type Database = {
1752
1795
  tagged_at: string | null;
1753
1796
  timestamp_observation: string | null;
1754
1797
  timestamp_observation_end: string;
1798
+ tracked_at: string | null;
1755
1799
  updated_at: string | null;
1756
1800
  }[];
1757
1801
  SetofOptions: {
@@ -1781,6 +1825,7 @@ export type Database = {
1781
1825
  tagged_at: string | null;
1782
1826
  timestamp_observation: string | null;
1783
1827
  timestamp_observation_end: string;
1828
+ tracked_at: string | null;
1784
1829
  updated_at: string | null;
1785
1830
  }[];
1786
1831
  SetofOptions: {
@@ -1830,6 +1875,36 @@ export type Database = {
1830
1875
  isOneToOne: false;
1831
1876
  isSetofReturn: true;
1832
1877
  };
1878
+ } | {
1879
+ Args: {
1880
+ end_timestamp_caller: string;
1881
+ herd_id_caller: number;
1882
+ max_elements_caller?: number;
1883
+ offset_caller?: number;
1884
+ start_timestamp_caller: string;
1885
+ };
1886
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1887
+ SetofOptions: {
1888
+ from: "*";
1889
+ to: "connectivity_with_coordinates";
1890
+ isOneToOne: false;
1891
+ isSetofReturn: true;
1892
+ };
1893
+ } | {
1894
+ Args: {
1895
+ end_timestamp_caller: string;
1896
+ herd_id_caller: number;
1897
+ max_elements_caller?: number;
1898
+ sample_caller?: boolean;
1899
+ start_timestamp_caller: string;
1900
+ };
1901
+ Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
1902
+ SetofOptions: {
1903
+ from: "*";
1904
+ to: "connectivity_with_coordinates";
1905
+ isOneToOne: false;
1906
+ isSetofReturn: true;
1907
+ };
1833
1908
  };
1834
1909
  get_connectivity_with_coordinates: {
1835
1910
  Args: {
@@ -2272,6 +2347,31 @@ export type Database = {
2272
2347
  isSetofReturn: true;
2273
2348
  };
2274
2349
  };
2350
+ preview_fix_all_sessions_missing_distance: {
2351
+ Args: never;
2352
+ Returns: {
2353
+ device_id: number;
2354
+ new_distance_max_from_start: number;
2355
+ new_distance_total: number;
2356
+ old_distance_max_from_start: number;
2357
+ old_distance_total: number;
2358
+ session_id: number;
2359
+ status: string;
2360
+ }[];
2361
+ };
2362
+ preview_fix_session_distance_from_connectivity: {
2363
+ Args: {
2364
+ session_id_param: number;
2365
+ };
2366
+ Returns: {
2367
+ new_distance_max_from_start: number;
2368
+ new_distance_total: number;
2369
+ old_distance_max_from_start: number;
2370
+ old_distance_total: number;
2371
+ session_id: number;
2372
+ status: string;
2373
+ }[];
2374
+ };
2275
2375
  remove_rls_broadcast_triggers: {
2276
2376
  Args: never;
2277
2377
  Returns: undefined;
@@ -2299,6 +2399,20 @@ export type Database = {
2299
2399
  };
2300
2400
  Returns: undefined;
2301
2401
  };
2402
+ sync_orphan_session_links: {
2403
+ Args: {
2404
+ preview?: boolean;
2405
+ };
2406
+ Returns: {
2407
+ assigned_session_id: number;
2408
+ candidate_session_count: number;
2409
+ device_id: number;
2410
+ entity_id: number;
2411
+ entity_type: string;
2412
+ old_session_id: number;
2413
+ status: string;
2414
+ }[];
2415
+ };
2302
2416
  };
2303
2417
  Enums: {
2304
2418
  app_permission: "herds.delete" | "events.delete";
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.40",
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",