@adventurelabs/scout-core 1.4.49 → 1.4.51
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.
|
@@ -117,38 +117,42 @@ export function useScoutRefresh(options = {}) {
|
|
|
117
117
|
// Background fetch fresh data without blocking
|
|
118
118
|
(async () => {
|
|
119
119
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
120
|
+
const userPromise = (async () => {
|
|
121
|
+
const start = Date.now();
|
|
122
|
+
const { data } = await supabase.auth.getUser();
|
|
123
|
+
const duration = Date.now() - start;
|
|
124
|
+
timingRefs.current.userApiDuration = duration;
|
|
125
|
+
dispatch(setUserApiDuration(duration));
|
|
126
|
+
if (data.user) {
|
|
127
|
+
dispatch(setUser(data.user));
|
|
128
|
+
}
|
|
129
|
+
return data.user ?? null;
|
|
130
|
+
})();
|
|
131
|
+
let backgroundHerdModulesResult;
|
|
132
|
+
try {
|
|
133
|
+
const start = Date.now();
|
|
134
|
+
const result = await server_load_herd_modules();
|
|
135
|
+
const totalDuration = Date.now() - start;
|
|
136
|
+
const serverDuration = result.server_processing_time_ms || totalDuration;
|
|
137
|
+
const clientOverhead = totalDuration - serverDuration;
|
|
138
|
+
console.log(`[useScoutRefresh] Background API timing breakdown:`);
|
|
139
|
+
console.log(` - Server processing: ${serverDuration}ms`);
|
|
140
|
+
console.log(` - Client overhead: ${clientOverhead}ms`);
|
|
141
|
+
console.log(` - Total request: ${totalDuration}ms`);
|
|
142
|
+
timingRefs.current.herdModulesDuration = serverDuration;
|
|
143
|
+
dispatch(setHerdModulesApiServerProcessingDuration(serverDuration));
|
|
144
|
+
dispatch(setHerdModulesApiTotalRequestDuration(totalDuration));
|
|
145
|
+
backgroundHerdModulesResult = result;
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
await userPromise.catch(() => { });
|
|
149
|
+
throw e;
|
|
150
|
+
}
|
|
151
|
+
const backgroundUserResult = await userPromise;
|
|
147
152
|
// Validate background responses
|
|
148
153
|
if (backgroundHerdModulesResult.data &&
|
|
149
154
|
Array.isArray(backgroundHerdModulesResult.data) &&
|
|
150
|
-
backgroundUserResult
|
|
151
|
-
backgroundUserResult.data) {
|
|
155
|
+
backgroundUserResult) {
|
|
152
156
|
// Update cache with fresh data
|
|
153
157
|
try {
|
|
154
158
|
await scoutCache.setHerdModules(backgroundHerdModulesResult.data, cacheTtlMs);
|
|
@@ -164,10 +168,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
164
168
|
// Update store with fresh data from background request
|
|
165
169
|
console.log(`[useScoutRefresh] Updating store with background herd modules`);
|
|
166
170
|
dispatch(setHerdModules(backgroundHerdModulesResult.data));
|
|
167
|
-
if (backgroundUserResult && backgroundUserResult.data) {
|
|
168
|
-
console.log(`[useScoutRefresh] Updating store with background user data`);
|
|
169
|
-
dispatch(setUser(backgroundUserResult.data));
|
|
170
|
-
}
|
|
171
171
|
// Update data source to DATABASE
|
|
172
172
|
dispatch(setDataSource(EnumDataSource.DATABASE));
|
|
173
173
|
dispatch(setDataSourceInfo({
|
|
@@ -226,35 +226,41 @@ export function useScoutRefresh(options = {}) {
|
|
|
226
226
|
lastQueryAtRef.current = Date.now();
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
// Step 2: Load fresh data from API
|
|
229
|
+
// Step 2: Load fresh data from API (user resolves independently; Redux gets user as soon as getUser returns)
|
|
230
230
|
const parallelStartTime = Date.now();
|
|
231
|
-
const
|
|
232
|
-
|
|
231
|
+
const userPromise = (async () => {
|
|
232
|
+
const start = Date.now();
|
|
233
|
+
const { data } = await supabase.auth.getUser();
|
|
234
|
+
const duration = Date.now() - start;
|
|
235
|
+
timingRefs.current.userApiDuration = duration;
|
|
236
|
+
dispatch(setUserApiDuration(duration));
|
|
237
|
+
if (!data.user) {
|
|
238
|
+
throw new Error("Invalid user response");
|
|
239
|
+
}
|
|
240
|
+
dispatch(setUser(data.user));
|
|
241
|
+
return data.user;
|
|
242
|
+
})();
|
|
243
|
+
let herdModulesResult;
|
|
244
|
+
try {
|
|
245
|
+
herdModulesResult = await (async () => {
|
|
233
246
|
const start = Date.now();
|
|
234
247
|
const result = await server_load_herd_modules();
|
|
235
248
|
const totalDuration = Date.now() - start;
|
|
236
249
|
const serverDuration = result.server_processing_time_ms || totalDuration;
|
|
237
250
|
return { result, totalDuration, serverDuration, start };
|
|
238
|
-
})()
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
duration,
|
|
246
|
-
start,
|
|
247
|
-
};
|
|
248
|
-
})(),
|
|
249
|
-
]);
|
|
251
|
+
})();
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
await userPromise.catch(() => { });
|
|
255
|
+
throw e;
|
|
256
|
+
}
|
|
257
|
+
await userPromise;
|
|
250
258
|
const parallelDuration = Date.now() - parallelStartTime;
|
|
251
|
-
console.log(`[useScoutRefresh]
|
|
259
|
+
console.log(`[useScoutRefresh] API requests completed in ${parallelDuration}ms`);
|
|
252
260
|
// Extract results and timing
|
|
253
261
|
const herdModulesResponse = herdModulesResult.result;
|
|
254
|
-
const res_new_user = userResult.result;
|
|
255
262
|
const herdModulesServerDuration = herdModulesResult.serverDuration;
|
|
256
263
|
const herdModulesTotalDuration = herdModulesResult.totalDuration;
|
|
257
|
-
const userApiDuration = userResult.duration;
|
|
258
264
|
const clientOverhead = herdModulesTotalDuration - herdModulesServerDuration;
|
|
259
265
|
console.log(`[useScoutRefresh] Fresh API timing breakdown:`);
|
|
260
266
|
console.log(` - Server processing: ${herdModulesServerDuration}ms`);
|
|
@@ -262,20 +268,15 @@ export function useScoutRefresh(options = {}) {
|
|
|
262
268
|
console.log(` - Total request: ${herdModulesTotalDuration}ms`);
|
|
263
269
|
// Store timing values
|
|
264
270
|
timingRefs.current.herdModulesDuration = herdModulesServerDuration;
|
|
265
|
-
timingRefs.current.userApiDuration = userApiDuration;
|
|
266
271
|
// Dispatch timing actions
|
|
267
272
|
dispatch(setHerdModulesApiServerProcessingDuration(herdModulesServerDuration));
|
|
268
273
|
dispatch(setHerdModulesApiTotalRequestDuration(herdModulesTotalDuration));
|
|
269
|
-
dispatch(setUserApiDuration(userApiDuration));
|
|
270
274
|
// Validate API responses
|
|
271
275
|
const validationStartTime = Date.now();
|
|
272
276
|
if (!herdModulesResponse.data ||
|
|
273
277
|
!Array.isArray(herdModulesResponse.data)) {
|
|
274
278
|
throw new Error("Invalid herd modules response");
|
|
275
279
|
}
|
|
276
|
-
if (!res_new_user || !res_new_user.data) {
|
|
277
|
-
throw new Error("Invalid user response");
|
|
278
|
-
}
|
|
279
280
|
const validationDuration = Date.now() - validationStartTime;
|
|
280
281
|
console.log(`[useScoutRefresh] Data validation took: ${validationDuration}ms`);
|
|
281
282
|
// Use the validated data
|
|
@@ -305,8 +306,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
305
306
|
// Update store with new data
|
|
306
307
|
console.log(`[useScoutRefresh] Updating store with fresh herd modules`);
|
|
307
308
|
dispatch(setHerdModules(compatible_new_herd_modules));
|
|
308
|
-
console.log(`[useScoutRefresh] Updating store with fresh user data`);
|
|
309
|
-
dispatch(setUser(res_new_user.data));
|
|
310
309
|
dispatch(setHerdModulesLoadingState(EnumHerdModulesLoadingState.SUCCESSFULLY_LOADED));
|
|
311
310
|
const dataProcessingDuration = Date.now() - dataProcessingStartTime;
|
|
312
311
|
timingRefs.current.dataProcessingDuration = dataProcessingDuration;
|
|
@@ -51,6 +51,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
51
51
|
Row: {
|
|
52
52
|
id: number;
|
|
53
53
|
inserted_at: string;
|
|
54
|
+
job_type: string;
|
|
54
55
|
status: Database["public"]["Enums"]["analysis_work_status"];
|
|
55
56
|
timestamp_finished: string | null;
|
|
56
57
|
timestamp_requested: string;
|
|
@@ -59,6 +60,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
59
60
|
Insert: {
|
|
60
61
|
id?: number;
|
|
61
62
|
inserted_at?: string;
|
|
63
|
+
job_type?: string;
|
|
62
64
|
status?: Database["public"]["Enums"]["analysis_work_status"];
|
|
63
65
|
timestamp_finished?: string | null;
|
|
64
66
|
timestamp_requested?: string;
|
|
@@ -67,6 +69,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
67
69
|
Update: {
|
|
68
70
|
id?: number;
|
|
69
71
|
inserted_at?: string;
|
|
72
|
+
job_type?: string;
|
|
70
73
|
status?: Database["public"]["Enums"]["analysis_work_status"];
|
|
71
74
|
timestamp_finished?: string | null;
|
|
72
75
|
timestamp_requested?: string;
|
|
@@ -700,6 +703,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
700
703
|
};
|
|
701
704
|
herds: {
|
|
702
705
|
Row: {
|
|
706
|
+
auto_delete_media_with_humans: boolean | null;
|
|
707
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
703
708
|
created_by: string;
|
|
704
709
|
description: string;
|
|
705
710
|
earthranger_domain: string | null;
|
|
@@ -714,6 +719,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
714
719
|
video_subscriber_token: string | null;
|
|
715
720
|
};
|
|
716
721
|
Insert: {
|
|
722
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
723
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
717
724
|
created_by: string;
|
|
718
725
|
description: string;
|
|
719
726
|
earthranger_domain?: string | null;
|
|
@@ -728,6 +735,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
728
735
|
video_subscriber_token?: string | null;
|
|
729
736
|
};
|
|
730
737
|
Update: {
|
|
738
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
739
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
731
740
|
created_by?: string;
|
|
732
741
|
description?: string;
|
|
733
742
|
earthranger_domain?: string | null;
|
|
@@ -1615,6 +1624,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1615
1624
|
isSetofReturn: true;
|
|
1616
1625
|
};
|
|
1617
1626
|
};
|
|
1627
|
+
auto_assign_session_post_approver: {
|
|
1628
|
+
Args: never;
|
|
1629
|
+
Returns: number;
|
|
1630
|
+
};
|
|
1618
1631
|
check_realtime_schema_status: {
|
|
1619
1632
|
Args: never;
|
|
1620
1633
|
Returns: {
|
|
@@ -2915,6 +2928,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
2915
2928
|
location: string | null;
|
|
2916
2929
|
latitude: number | null;
|
|
2917
2930
|
longitude: number | null;
|
|
2931
|
+
auto_delete_media_with_humans: boolean | null;
|
|
2932
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
2918
2933
|
};
|
|
2919
2934
|
pins_pretty_location: {
|
|
2920
2935
|
id: number | null;
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export type Database = {
|
|
|
50
50
|
Row: {
|
|
51
51
|
id: number;
|
|
52
52
|
inserted_at: string;
|
|
53
|
+
job_type: string;
|
|
53
54
|
status: Database["public"]["Enums"]["analysis_work_status"];
|
|
54
55
|
timestamp_finished: string | null;
|
|
55
56
|
timestamp_requested: string;
|
|
@@ -58,6 +59,7 @@ export type Database = {
|
|
|
58
59
|
Insert: {
|
|
59
60
|
id?: number;
|
|
60
61
|
inserted_at?: string;
|
|
62
|
+
job_type?: string;
|
|
61
63
|
status?: Database["public"]["Enums"]["analysis_work_status"];
|
|
62
64
|
timestamp_finished?: string | null;
|
|
63
65
|
timestamp_requested?: string;
|
|
@@ -66,6 +68,7 @@ export type Database = {
|
|
|
66
68
|
Update: {
|
|
67
69
|
id?: number;
|
|
68
70
|
inserted_at?: string;
|
|
71
|
+
job_type?: string;
|
|
69
72
|
status?: Database["public"]["Enums"]["analysis_work_status"];
|
|
70
73
|
timestamp_finished?: string | null;
|
|
71
74
|
timestamp_requested?: string;
|
|
@@ -733,6 +736,8 @@ export type Database = {
|
|
|
733
736
|
};
|
|
734
737
|
herds: {
|
|
735
738
|
Row: {
|
|
739
|
+
auto_delete_media_with_humans: boolean | null;
|
|
740
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
736
741
|
created_by: string;
|
|
737
742
|
description: string;
|
|
738
743
|
earthranger_domain: string | null;
|
|
@@ -747,6 +752,8 @@ export type Database = {
|
|
|
747
752
|
video_subscriber_token: string | null;
|
|
748
753
|
};
|
|
749
754
|
Insert: {
|
|
755
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
756
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
750
757
|
created_by: string;
|
|
751
758
|
description: string;
|
|
752
759
|
earthranger_domain?: string | null;
|
|
@@ -761,6 +768,8 @@ export type Database = {
|
|
|
761
768
|
video_subscriber_token?: string | null;
|
|
762
769
|
};
|
|
763
770
|
Update: {
|
|
771
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
772
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
764
773
|
created_by?: string;
|
|
765
774
|
description?: string;
|
|
766
775
|
earthranger_domain?: string | null;
|
|
@@ -1700,6 +1709,10 @@ export type Database = {
|
|
|
1700
1709
|
isSetofReturn: true;
|
|
1701
1710
|
};
|
|
1702
1711
|
};
|
|
1712
|
+
auto_assign_session_post_approver: {
|
|
1713
|
+
Args: never;
|
|
1714
|
+
Returns: number;
|
|
1715
|
+
};
|
|
1703
1716
|
check_realtime_schema_status: {
|
|
1704
1717
|
Args: never;
|
|
1705
1718
|
Returns: {
|
|
@@ -3000,6 +3013,8 @@ export type Database = {
|
|
|
3000
3013
|
location: string | null;
|
|
3001
3014
|
latitude: number | null;
|
|
3002
3015
|
longitude: number | null;
|
|
3016
|
+
auto_delete_media_with_humans: boolean | null;
|
|
3017
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
3003
3018
|
};
|
|
3004
3019
|
pins_pretty_location: {
|
|
3005
3020
|
id: number | null;
|