@adventurelabs/scout-core 1.0.133 → 1.2.1
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/cache.d.ts +0 -5
- package/dist/helpers/cache.js +5 -166
- package/dist/helpers/versions_software.d.ts +0 -2
- package/dist/helpers/versions_software.js +0 -85
- package/dist/hooks/useScoutRealtimeConnectivity.js +1 -1
- package/dist/hooks/useScoutRealtimeDevices.js +1 -2
- package/dist/hooks/useScoutRealtimeVersionsSoftware.js +5 -20
- package/dist/hooks/useScoutRefresh.js +9 -79
- package/dist/providers/ScoutRefreshProvider.d.ts +1 -0
- package/dist/store/scout.d.ts +2 -15
- package/dist/store/scout.js +1 -21
- package/dist/types/supabase.d.ts +1 -0
- package/package.json +1 -1
package/dist/helpers/cache.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IHerdModule } from "../types/herd_module";
|
|
2
|
-
import { IVersionsSoftware } from "../types/db";
|
|
3
2
|
export interface CacheMetadata {
|
|
4
3
|
key: string;
|
|
5
4
|
timestamp: number;
|
|
@@ -46,7 +45,6 @@ export declare class ScoutCache {
|
|
|
46
45
|
getHerdModules(): Promise<CacheResult<IHerdModule[]>>;
|
|
47
46
|
clearHerdModules(): Promise<void>;
|
|
48
47
|
invalidateHerdModules(): Promise<void>;
|
|
49
|
-
invalidateVersionsSoftware(): Promise<void>;
|
|
50
48
|
getCacheStats(): Promise<CacheStats>;
|
|
51
49
|
isCacheValid(ttlMs?: number): Promise<boolean>;
|
|
52
50
|
getCacheAge(): Promise<number>;
|
|
@@ -60,8 +58,5 @@ export declare class ScoutCache {
|
|
|
60
58
|
isCacheVersionCompatible(): Promise<boolean>;
|
|
61
59
|
resetDatabase(): Promise<void>;
|
|
62
60
|
checkDatabaseHealth(): Promise<DatabaseHealth>;
|
|
63
|
-
setVersionsSoftware(versionsSoftware: IVersionsSoftware[], ttlMs?: number, etag?: string): Promise<void>;
|
|
64
|
-
getVersionsSoftware(): Promise<CacheResult<IVersionsSoftware[]>>;
|
|
65
|
-
clearVersionsSoftware(): Promise<void>;
|
|
66
61
|
}
|
|
67
62
|
export declare const scoutCache: ScoutCache;
|
package/dist/helpers/cache.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const DB_NAME = "ScoutCache";
|
|
2
|
-
const DB_VERSION =
|
|
3
|
-
const CACHE_VERSION = "3.0.0"; // Cache metadata version string
|
|
2
|
+
const DB_VERSION = 4; // Increment to invalidate old cache versions
|
|
4
3
|
const HERD_MODULES_STORE = "herd_modules";
|
|
5
4
|
const CACHE_METADATA_STORE = "cache_metadata";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const DEFAULT_TTL_MS = 2 * 24 * 60 * 60 * 1000;
|
|
5
|
+
// Default TTL: 24 hours (1 day)
|
|
6
|
+
const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
9
7
|
export class ScoutCache {
|
|
10
8
|
constructor() {
|
|
11
9
|
this.db = null;
|
|
@@ -63,17 +61,6 @@ export class ScoutCache {
|
|
|
63
61
|
keyPath: "key",
|
|
64
62
|
});
|
|
65
63
|
console.log("[ScoutCache] Created cache_metadata object store");
|
|
66
|
-
// Create versions_software store
|
|
67
|
-
const versionsSoftwareStore = db.createObjectStore(VERSIONS_SOFTWARE_STORE, {
|
|
68
|
-
keyPath: "id",
|
|
69
|
-
});
|
|
70
|
-
versionsSoftwareStore.createIndex("system", "system", {
|
|
71
|
-
unique: false,
|
|
72
|
-
});
|
|
73
|
-
versionsSoftwareStore.createIndex("timestamp", "timestamp", {
|
|
74
|
-
unique: false,
|
|
75
|
-
});
|
|
76
|
-
console.log("[ScoutCache] Created versions_software object store");
|
|
77
64
|
console.log(`[ScoutCache] Database schema upgrade to version ${DB_VERSION} completed`);
|
|
78
65
|
}
|
|
79
66
|
catch (error) {
|
|
@@ -92,17 +79,13 @@ export class ScoutCache {
|
|
|
92
79
|
return false;
|
|
93
80
|
const hasHerdModulesStore = this.db.objectStoreNames.contains(HERD_MODULES_STORE);
|
|
94
81
|
const hasMetadataStore = this.db.objectStoreNames.contains(CACHE_METADATA_STORE);
|
|
95
|
-
const hasVersionsSoftwareStore = this.db.objectStoreNames.contains(VERSIONS_SOFTWARE_STORE);
|
|
96
82
|
if (!hasHerdModulesStore) {
|
|
97
83
|
console.error("[ScoutCache] Missing herd_modules object store");
|
|
98
84
|
}
|
|
99
85
|
if (!hasMetadataStore) {
|
|
100
86
|
console.error("[ScoutCache] Missing cache_metadata object store");
|
|
101
87
|
}
|
|
102
|
-
|
|
103
|
-
console.error("[ScoutCache] Missing versions_software object store");
|
|
104
|
-
}
|
|
105
|
-
return hasHerdModulesStore && hasMetadataStore && hasVersionsSoftwareStore;
|
|
88
|
+
return hasHerdModulesStore && hasMetadataStore;
|
|
106
89
|
}
|
|
107
90
|
async setHerdModules(herdModules, ttlMs = DEFAULT_TTL_MS, etag) {
|
|
108
91
|
await this.init();
|
|
@@ -118,7 +101,7 @@ export class ScoutCache {
|
|
|
118
101
|
const herdModulesStore = transaction.objectStore(HERD_MODULES_STORE);
|
|
119
102
|
const metadataStore = transaction.objectStore(CACHE_METADATA_STORE);
|
|
120
103
|
const timestamp = Date.now();
|
|
121
|
-
const version =
|
|
104
|
+
const version = "2.0.0";
|
|
122
105
|
// Store each herd module (contains all nested data - devices, events, zones, etc.)
|
|
123
106
|
herdModules.forEach((herdModule) => {
|
|
124
107
|
const cacheEntry = {
|
|
@@ -238,21 +221,6 @@ export class ScoutCache {
|
|
|
238
221
|
metadataStore.delete("providers");
|
|
239
222
|
});
|
|
240
223
|
}
|
|
241
|
-
async invalidateVersionsSoftware() {
|
|
242
|
-
await this.init();
|
|
243
|
-
if (!this.db)
|
|
244
|
-
throw new Error("Database not initialized");
|
|
245
|
-
if (!this.validateDatabaseSchema()) {
|
|
246
|
-
throw new Error("Database schema validation failed - required object stores not found");
|
|
247
|
-
}
|
|
248
|
-
const transaction = this.db.transaction([CACHE_METADATA_STORE], "readwrite");
|
|
249
|
-
return new Promise((resolve, reject) => {
|
|
250
|
-
transaction.onerror = () => reject(transaction.error);
|
|
251
|
-
transaction.oncomplete = () => resolve();
|
|
252
|
-
const metadataStore = transaction.objectStore(CACHE_METADATA_STORE);
|
|
253
|
-
metadataStore.delete("versions_software");
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
224
|
async getCacheStats() {
|
|
257
225
|
const result = await this.getHerdModules();
|
|
258
226
|
const totalRequests = this.stats.hits + this.stats.misses;
|
|
@@ -397,135 +365,6 @@ export class ScoutCache {
|
|
|
397
365
|
issues,
|
|
398
366
|
};
|
|
399
367
|
}
|
|
400
|
-
async setVersionsSoftware(versionsSoftware, ttlMs = DEFAULT_TTL_MS, etag) {
|
|
401
|
-
await this.init();
|
|
402
|
-
if (!this.db)
|
|
403
|
-
throw new Error("Database not initialized");
|
|
404
|
-
if (!this.validateDatabaseSchema()) {
|
|
405
|
-
throw new Error("Database schema validation failed - required object stores not found");
|
|
406
|
-
}
|
|
407
|
-
const transaction = this.db.transaction([VERSIONS_SOFTWARE_STORE, CACHE_METADATA_STORE], "readwrite");
|
|
408
|
-
return new Promise((resolve, reject) => {
|
|
409
|
-
transaction.onerror = () => reject(transaction.error);
|
|
410
|
-
transaction.oncomplete = () => resolve();
|
|
411
|
-
const versionsSoftwareStore = transaction.objectStore(VERSIONS_SOFTWARE_STORE);
|
|
412
|
-
const metadataStore = transaction.objectStore(CACHE_METADATA_STORE);
|
|
413
|
-
const timestamp = Date.now();
|
|
414
|
-
const version = CACHE_VERSION;
|
|
415
|
-
// Clear existing versions_software data first
|
|
416
|
-
versionsSoftwareStore.clear();
|
|
417
|
-
// Store each software version with timestamp
|
|
418
|
-
versionsSoftware.forEach((version) => {
|
|
419
|
-
const cacheEntry = {
|
|
420
|
-
...version,
|
|
421
|
-
timestamp,
|
|
422
|
-
dbVersion: DB_VERSION,
|
|
423
|
-
};
|
|
424
|
-
versionsSoftwareStore.put(cacheEntry);
|
|
425
|
-
});
|
|
426
|
-
// Store cache metadata
|
|
427
|
-
const metadata = {
|
|
428
|
-
key: "versions_software",
|
|
429
|
-
timestamp,
|
|
430
|
-
ttl: ttlMs,
|
|
431
|
-
version,
|
|
432
|
-
dbVersion: DB_VERSION,
|
|
433
|
-
etag,
|
|
434
|
-
lastModified: timestamp,
|
|
435
|
-
};
|
|
436
|
-
metadataStore.put(metadata);
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
async getVersionsSoftware() {
|
|
440
|
-
await this.init();
|
|
441
|
-
if (!this.db)
|
|
442
|
-
throw new Error("Database not initialized");
|
|
443
|
-
if (!this.validateDatabaseSchema()) {
|
|
444
|
-
throw new Error("Database schema validation failed - required object stores not found");
|
|
445
|
-
}
|
|
446
|
-
const transaction = this.db.transaction([VERSIONS_SOFTWARE_STORE, CACHE_METADATA_STORE], "readonly");
|
|
447
|
-
return new Promise((resolve, reject) => {
|
|
448
|
-
transaction.onerror = () => reject(transaction.error);
|
|
449
|
-
const versionsSoftwareStore = transaction.objectStore(VERSIONS_SOFTWARE_STORE);
|
|
450
|
-
const metadataStore = transaction.objectStore(CACHE_METADATA_STORE);
|
|
451
|
-
// Get metadata first
|
|
452
|
-
const metadataRequest = metadataStore.get("versions_software");
|
|
453
|
-
metadataRequest.onsuccess = () => {
|
|
454
|
-
const metadata = metadataRequest.result;
|
|
455
|
-
const now = Date.now();
|
|
456
|
-
if (!metadata) {
|
|
457
|
-
this.stats.misses++;
|
|
458
|
-
resolve({ data: null, isStale: true, age: 0, metadata: null });
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
// Check if cache is from an incompatible DB version
|
|
462
|
-
if (!metadata.dbVersion || metadata.dbVersion !== DB_VERSION) {
|
|
463
|
-
console.log(`[ScoutCache] Versions software cache from incompatible DB version (${metadata.dbVersion || "unknown"} !== ${DB_VERSION}), invalidating`);
|
|
464
|
-
this.stats.misses++;
|
|
465
|
-
resolve({ data: null, isStale: true, age: 0, metadata });
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
const age = now - metadata.timestamp;
|
|
469
|
-
const isStale = age > metadata.ttl;
|
|
470
|
-
if (isStale) {
|
|
471
|
-
this.stats.misses++;
|
|
472
|
-
console.log(`[ScoutCache] Versions software cache is stale (${Math.round(age / 1000)}s old, TTL: ${Math.round(metadata.ttl / 1000)}s)`);
|
|
473
|
-
resolve({ data: null, isStale: true, age, metadata });
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
// Get all versions_software
|
|
477
|
-
const getAllRequest = versionsSoftwareStore.getAll();
|
|
478
|
-
getAllRequest.onsuccess = () => {
|
|
479
|
-
const cacheEntries = getAllRequest.result;
|
|
480
|
-
if (!cacheEntries || cacheEntries.length === 0) {
|
|
481
|
-
this.stats.misses++;
|
|
482
|
-
resolve({ data: null, isStale: false, age, metadata });
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
// Extract versions_software data and remove cache metadata
|
|
486
|
-
const versionsSoftware = cacheEntries.map((entry) => {
|
|
487
|
-
const { timestamp, dbVersion, ...versionData } = entry;
|
|
488
|
-
return versionData;
|
|
489
|
-
});
|
|
490
|
-
this.stats.hits++;
|
|
491
|
-
console.log(`[ScoutCache] Found ${versionsSoftware.length} cached software versions (${Math.round(age / 1000)}s old)`);
|
|
492
|
-
resolve({
|
|
493
|
-
data: versionsSoftware,
|
|
494
|
-
isStale: false,
|
|
495
|
-
age,
|
|
496
|
-
metadata,
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
getAllRequest.onerror = () => {
|
|
500
|
-
this.stats.misses++;
|
|
501
|
-
console.error("[ScoutCache] Failed to get versions software:", getAllRequest.error);
|
|
502
|
-
resolve({ data: null, isStale: true, age, metadata });
|
|
503
|
-
};
|
|
504
|
-
};
|
|
505
|
-
metadataRequest.onerror = () => {
|
|
506
|
-
this.stats.misses++;
|
|
507
|
-
console.error("[ScoutCache] Failed to get versions software metadata:", metadataRequest.error);
|
|
508
|
-
resolve({ data: null, isStale: true, age: 0, metadata: null });
|
|
509
|
-
};
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
async clearVersionsSoftware() {
|
|
513
|
-
await this.init();
|
|
514
|
-
if (!this.db)
|
|
515
|
-
throw new Error("Database not initialized");
|
|
516
|
-
if (!this.validateDatabaseSchema()) {
|
|
517
|
-
throw new Error("Database schema validation failed - required object stores not found");
|
|
518
|
-
}
|
|
519
|
-
const transaction = this.db.transaction([VERSIONS_SOFTWARE_STORE, CACHE_METADATA_STORE], "readwrite");
|
|
520
|
-
return new Promise((resolve, reject) => {
|
|
521
|
-
transaction.onerror = () => reject(transaction.error);
|
|
522
|
-
transaction.oncomplete = () => resolve();
|
|
523
|
-
const versionsSoftwareStore = transaction.objectStore(VERSIONS_SOFTWARE_STORE);
|
|
524
|
-
const metadataStore = transaction.objectStore(CACHE_METADATA_STORE);
|
|
525
|
-
versionsSoftwareStore.clear();
|
|
526
|
-
metadataStore.delete("versions_software");
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
368
|
}
|
|
530
369
|
// Singleton instance
|
|
531
370
|
export const scoutCache = new ScoutCache();
|
|
@@ -3,10 +3,8 @@ import { IVersionsSoftware, VersionsSoftwareInsert } from "../types/db";
|
|
|
3
3
|
import { IWebResponseCompatible } from "../types/requests";
|
|
4
4
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
5
5
|
export declare function get_versions_software(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IVersionsSoftware[]>>;
|
|
6
|
-
export declare function get_versions_software_with_cache(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IVersionsSoftware[]>>;
|
|
7
6
|
export declare function get_versions_software_by_system(client: SupabaseClient<Database>, system: string): Promise<IWebResponseCompatible<IVersionsSoftware[]>>;
|
|
8
7
|
export declare function create_version_software(client: SupabaseClient<Database>, newVersionSoftware: VersionsSoftwareInsert): Promise<IWebResponseCompatible<IVersionsSoftware | null>>;
|
|
9
8
|
export declare function update_version_software(client: SupabaseClient<Database>, version_id: number, updatedVersionSoftware: Partial<VersionsSoftwareInsert>): Promise<IWebResponseCompatible<IVersionsSoftware | null>>;
|
|
10
|
-
export declare function server_get_versions_software(): Promise<IWebResponseCompatible<IVersionsSoftware[]>>;
|
|
11
9
|
export declare function delete_version_software(client: SupabaseClient<Database>, version_id: number): Promise<IWebResponseCompatible<IVersionsSoftware | null>>;
|
|
12
10
|
export declare function get_versions_software_by_created_by(client: SupabaseClient<Database>, user_id: string): Promise<IWebResponseCompatible<IVersionsSoftware[]>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IWebResponse } from "../types/requests";
|
|
2
|
-
import { scoutCache } from "./cache";
|
|
3
2
|
export async function get_versions_software(client) {
|
|
4
3
|
const { data, error } = await client
|
|
5
4
|
.from("versions_software")
|
|
@@ -13,35 +12,6 @@ export async function get_versions_software(client) {
|
|
|
13
12
|
}
|
|
14
13
|
return IWebResponse.success(data).to_compatible();
|
|
15
14
|
}
|
|
16
|
-
export async function get_versions_software_with_cache(client) {
|
|
17
|
-
try {
|
|
18
|
-
// Try to get from cache first
|
|
19
|
-
const cacheResult = await scoutCache.getVersionsSoftware();
|
|
20
|
-
if (cacheResult.data && !cacheResult.isStale) {
|
|
21
|
-
console.log(`[VersionsSoftware] Using cached data (${Math.round(cacheResult.age / 1000)}s old)`);
|
|
22
|
-
return IWebResponse.success(cacheResult.data).to_compatible();
|
|
23
|
-
}
|
|
24
|
-
// Cache miss or stale data - fetch from API
|
|
25
|
-
console.log("[VersionsSoftware] Cache miss or stale, fetching from API");
|
|
26
|
-
const apiResponse = await get_versions_software(client);
|
|
27
|
-
// If API request was successful, cache the result
|
|
28
|
-
if (apiResponse.status === "success" && apiResponse.data) {
|
|
29
|
-
try {
|
|
30
|
-
await scoutCache.setVersionsSoftware(apiResponse.data);
|
|
31
|
-
console.log(`[VersionsSoftware] Cached ${apiResponse.data.length} software versions`);
|
|
32
|
-
}
|
|
33
|
-
catch (cacheError) {
|
|
34
|
-
console.warn("[VersionsSoftware] Failed to cache data:", cacheError);
|
|
35
|
-
// Continue anyway, we still have the API data
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return apiResponse;
|
|
39
|
-
}
|
|
40
|
-
catch (cacheError) {
|
|
41
|
-
console.warn("[VersionsSoftware] Cache error, falling back to API:", cacheError);
|
|
42
|
-
return get_versions_software(client);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
15
|
export async function get_versions_software_by_system(client, system) {
|
|
46
16
|
const { data, error } = await client
|
|
47
17
|
.from("versions_software")
|
|
@@ -68,14 +38,6 @@ export async function create_version_software(client, newVersionSoftware) {
|
|
|
68
38
|
if (!data) {
|
|
69
39
|
return IWebResponse.error("Failed to create software version").to_compatible();
|
|
70
40
|
}
|
|
71
|
-
// Invalidate cache after successful creation
|
|
72
|
-
try {
|
|
73
|
-
await scoutCache.invalidateVersionsSoftware();
|
|
74
|
-
console.log("[VersionsSoftware] Cache invalidated after creation");
|
|
75
|
-
}
|
|
76
|
-
catch (cacheError) {
|
|
77
|
-
console.warn("[VersionsSoftware] Failed to invalidate cache:", cacheError);
|
|
78
|
-
}
|
|
79
41
|
return IWebResponse.success(data).to_compatible();
|
|
80
42
|
}
|
|
81
43
|
export async function update_version_software(client, version_id, updatedVersionSoftware) {
|
|
@@ -96,47 +58,8 @@ export async function update_version_software(client, version_id, updatedVersion
|
|
|
96
58
|
if (!data) {
|
|
97
59
|
return IWebResponse.error("Software version not found or update failed").to_compatible();
|
|
98
60
|
}
|
|
99
|
-
// Invalidate cache after successful update
|
|
100
|
-
try {
|
|
101
|
-
await scoutCache.invalidateVersionsSoftware();
|
|
102
|
-
console.log("[VersionsSoftware] Cache invalidated after update");
|
|
103
|
-
}
|
|
104
|
-
catch (cacheError) {
|
|
105
|
-
console.warn("[VersionsSoftware] Failed to invalidate cache:", cacheError);
|
|
106
|
-
}
|
|
107
61
|
return IWebResponse.success(data).to_compatible();
|
|
108
62
|
}
|
|
109
|
-
export async function server_get_versions_software() {
|
|
110
|
-
const { newServerClient } = await import("../supabase/server");
|
|
111
|
-
const client = await newServerClient();
|
|
112
|
-
try {
|
|
113
|
-
// Try to get from cache first
|
|
114
|
-
const cacheResult = await scoutCache.getVersionsSoftware();
|
|
115
|
-
if (cacheResult.data && !cacheResult.isStale) {
|
|
116
|
-
console.log(`[VersionsSoftware] Server using cached data (${Math.round(cacheResult.age / 1000)}s old)`);
|
|
117
|
-
return IWebResponse.success(cacheResult.data).to_compatible();
|
|
118
|
-
}
|
|
119
|
-
// Cache miss or stale data - fetch from API
|
|
120
|
-
console.log("[VersionsSoftware] Server cache miss or stale, fetching from API");
|
|
121
|
-
const apiResponse = await get_versions_software(client);
|
|
122
|
-
// If API request was successful, cache the result
|
|
123
|
-
if (apiResponse.status === "success" && apiResponse.data) {
|
|
124
|
-
try {
|
|
125
|
-
await scoutCache.setVersionsSoftware(apiResponse.data);
|
|
126
|
-
console.log(`[VersionsSoftware] Server cached ${apiResponse.data.length} software versions`);
|
|
127
|
-
}
|
|
128
|
-
catch (cacheError) {
|
|
129
|
-
console.warn("[VersionsSoftware] Server failed to cache data:", cacheError);
|
|
130
|
-
// Continue anyway, we still have the API data
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return apiResponse;
|
|
134
|
-
}
|
|
135
|
-
catch (cacheError) {
|
|
136
|
-
console.warn("[VersionsSoftware] Server cache error, falling back to API:", cacheError);
|
|
137
|
-
return get_versions_software(client);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
63
|
export async function delete_version_software(client, version_id) {
|
|
141
64
|
const { data, error } = await client
|
|
142
65
|
.from("versions_software")
|
|
@@ -150,14 +73,6 @@ export async function delete_version_software(client, version_id) {
|
|
|
150
73
|
if (!data) {
|
|
151
74
|
return IWebResponse.error("Software version not found or deletion failed").to_compatible();
|
|
152
75
|
}
|
|
153
|
-
// Invalidate cache after successful deletion
|
|
154
|
-
try {
|
|
155
|
-
await scoutCache.invalidateVersionsSoftware();
|
|
156
|
-
console.log("[VersionsSoftware] Cache invalidated after deletion");
|
|
157
|
-
}
|
|
158
|
-
catch (cacheError) {
|
|
159
|
-
console.warn("[VersionsSoftware] Failed to invalidate cache:", cacheError);
|
|
160
|
-
}
|
|
161
76
|
return IWebResponse.success(data).to_compatible();
|
|
162
77
|
}
|
|
163
78
|
export async function get_versions_software_by_created_by(client, user_id) {
|
|
@@ -44,7 +44,7 @@ export function useScoutRealtimeConnectivity(scoutSupabase) {
|
|
|
44
44
|
default:
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
console.log(`[
|
|
47
|
+
console.log(`[scout-core realtime] CONNECTIVITY ${data.operation} received for device ${connectivityData.device_id}:`, JSON.stringify(connectivityData));
|
|
48
48
|
const realtimeData = {
|
|
49
49
|
data: connectivityData,
|
|
50
50
|
operation,
|
|
@@ -28,14 +28,12 @@ export function useScoutRealtimeDevices(scoutSupabase) {
|
|
|
28
28
|
case "UPDATE":
|
|
29
29
|
operation = EnumRealtimeOperation.UPDATE;
|
|
30
30
|
if (data.record) {
|
|
31
|
-
console.log("[Devices] Device updated:", data.record);
|
|
32
31
|
dispatch(updateDevice(data.record));
|
|
33
32
|
}
|
|
34
33
|
break;
|
|
35
34
|
case "DELETE":
|
|
36
35
|
operation = EnumRealtimeOperation.DELETE;
|
|
37
36
|
if (data.old_record) {
|
|
38
|
-
console.log("[Devices] Device deleted:", data.old_record);
|
|
39
37
|
dispatch(deleteDevice(data.old_record));
|
|
40
38
|
}
|
|
41
39
|
break;
|
|
@@ -46,6 +44,7 @@ export function useScoutRealtimeDevices(scoutSupabase) {
|
|
|
46
44
|
data: deviceData,
|
|
47
45
|
operation,
|
|
48
46
|
};
|
|
47
|
+
console.log(`[scout-core realtime] DEVICE ${data.operation} received:`, JSON.stringify(realtimeData));
|
|
49
48
|
setNewDeviceItems((prev) => [realtimeData, ...prev]);
|
|
50
49
|
}, [dispatch]);
|
|
51
50
|
// Clear new items when herd changes
|
|
@@ -1,52 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useAppDispatch } from "../store/hooks";
|
|
3
2
|
import { useEffect, useRef, useCallback, useState } from "react";
|
|
4
|
-
import { upsertVersionSoftware, deleteVersionSoftwareById, } from "../store/scout";
|
|
5
3
|
import { EnumRealtimeOperation } from "../types/realtime";
|
|
6
4
|
export function useScoutRealtimeVersionsSoftware(scoutSupabase) {
|
|
7
5
|
const channels = useRef([]);
|
|
8
|
-
const dispatch = useAppDispatch();
|
|
9
6
|
const [newVersionsItems, setNewVersionsItems] = useState([]);
|
|
10
7
|
// Handle versions software broadcasts
|
|
11
8
|
const handleVersionsSoftwareBroadcast = useCallback((payload) => {
|
|
12
|
-
|
|
13
|
-
const data = payload.payload;
|
|
9
|
+
const { event, payload: data } = payload;
|
|
14
10
|
const versionData = data.record || data.old_record;
|
|
15
|
-
if (!versionData)
|
|
11
|
+
if (!versionData) {
|
|
16
12
|
return;
|
|
13
|
+
}
|
|
17
14
|
let operation;
|
|
18
15
|
switch (data.operation) {
|
|
19
16
|
case "INSERT":
|
|
20
17
|
operation = EnumRealtimeOperation.INSERT;
|
|
21
|
-
if (data.record) {
|
|
22
|
-
console.log("[VersionsSoftware] New version received:", data.record);
|
|
23
|
-
dispatch(upsertVersionSoftware(data.record));
|
|
24
|
-
}
|
|
25
18
|
break;
|
|
26
19
|
case "UPDATE":
|
|
27
20
|
operation = EnumRealtimeOperation.UPDATE;
|
|
28
|
-
if (data.record) {
|
|
29
|
-
console.log("[VersionsSoftware] Version updated:", data.record);
|
|
30
|
-
dispatch(upsertVersionSoftware(data.record));
|
|
31
|
-
}
|
|
32
21
|
break;
|
|
33
22
|
case "DELETE":
|
|
34
23
|
operation = EnumRealtimeOperation.DELETE;
|
|
35
|
-
if (data.old_record) {
|
|
36
|
-
console.log("[VersionsSoftware] Version deleted:", data.old_record);
|
|
37
|
-
dispatch(deleteVersionSoftwareById(data.old_record.id));
|
|
38
|
-
}
|
|
39
24
|
break;
|
|
40
25
|
default:
|
|
41
26
|
return;
|
|
42
27
|
}
|
|
43
|
-
console.log(`[
|
|
28
|
+
console.log(`[scout-core realtime] VERSIONS_SOFTWARE ${data.operation} received for version ${versionData.system}@${versionData.version}:`, JSON.stringify(versionData));
|
|
44
29
|
const realtimeData = {
|
|
45
30
|
data: versionData,
|
|
46
31
|
operation,
|
|
47
32
|
};
|
|
48
33
|
setNewVersionsItems((prev) => [realtimeData, ...prev]);
|
|
49
|
-
}, [
|
|
34
|
+
}, []);
|
|
50
35
|
// Clear new items
|
|
51
36
|
const clearNewItems = useCallback(() => {
|
|
52
37
|
setNewVersionsItems([]);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useEffect, useCallback, useRef, useMemo } from "react";
|
|
2
2
|
import { useAppDispatch } from "../store/hooks";
|
|
3
3
|
import { useStore } from "react-redux";
|
|
4
|
-
import { EnumScoutStateStatus, setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setUser, setDataSource, setDataSourceInfo,
|
|
4
|
+
import { EnumScoutStateStatus, setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setUser, setDataSource, setDataSourceInfo, } from "../store/scout";
|
|
5
5
|
import { EnumHerdModulesLoadingState } from "../types/herd_module";
|
|
6
6
|
import { server_load_herd_modules } from "../helpers/herds";
|
|
7
|
-
import { server_get_versions_software } from "../helpers/versions_software";
|
|
8
7
|
import { scoutCache } from "../helpers/cache";
|
|
9
8
|
import { EnumDataSource } from "../types/data_source";
|
|
10
9
|
import { createBrowserClient } from "@supabase/ssr";
|
|
@@ -88,10 +87,7 @@ export function useScoutRefresh(options = {}) {
|
|
|
88
87
|
if (cacheFirst) {
|
|
89
88
|
const cacheStartTime = Date.now();
|
|
90
89
|
try {
|
|
91
|
-
const
|
|
92
|
-
scoutCache.getHerdModules(),
|
|
93
|
-
scoutCache.getVersionsSoftware(),
|
|
94
|
-
]);
|
|
90
|
+
const cacheResult = await scoutCache.getHerdModules();
|
|
95
91
|
cacheLoadDuration = Date.now() - cacheStartTime;
|
|
96
92
|
timingRefs.current.cacheLoadDuration = cacheLoadDuration;
|
|
97
93
|
dispatch(setCacheLoadDuration(cacheLoadDuration));
|
|
@@ -110,18 +106,13 @@ export function useScoutRefresh(options = {}) {
|
|
|
110
106
|
console.log(`[useScoutRefresh] Updating store with cached herd modules`);
|
|
111
107
|
dispatch(setHerdModules(cachedHerdModules));
|
|
112
108
|
dispatch(setHerdModulesLoadingState(EnumHerdModulesLoadingState.SUCCESSFULLY_LOADED));
|
|
113
|
-
// Load cached software versions if available
|
|
114
|
-
if (versionsCacheResult.data && !versionsCacheResult.isStale) {
|
|
115
|
-
console.log(`[useScoutRefresh] Loaded ${versionsCacheResult.data.length} software versions from cache`);
|
|
116
|
-
dispatch(setVersionsSoftware(versionsCacheResult.data));
|
|
117
|
-
}
|
|
118
109
|
// If cache is fresh, we still background fetch but don't wait
|
|
119
110
|
if (!cacheResult.isStale) {
|
|
120
111
|
// Background fetch fresh data without blocking
|
|
121
112
|
(async () => {
|
|
122
113
|
try {
|
|
123
114
|
const backgroundStartTime = Date.now();
|
|
124
|
-
const [backgroundHerdModulesResult, backgroundUserResult
|
|
115
|
+
const [backgroundHerdModulesResult, backgroundUserResult] = await Promise.all([
|
|
125
116
|
(async () => {
|
|
126
117
|
const start = Date.now();
|
|
127
118
|
const result = await server_load_herd_modules();
|
|
@@ -145,45 +136,22 @@ export function useScoutRefresh(options = {}) {
|
|
|
145
136
|
dispatch(setUserApiDuration(duration));
|
|
146
137
|
return { data: data.user, status: "success" };
|
|
147
138
|
})(),
|
|
148
|
-
(async () => {
|
|
149
|
-
const start = Date.now();
|
|
150
|
-
const result = await server_get_versions_software();
|
|
151
|
-
const duration = Date.now() - start;
|
|
152
|
-
return { ...result, duration };
|
|
153
|
-
})(),
|
|
154
139
|
]);
|
|
155
140
|
const backgroundDuration = Date.now() - backgroundStartTime;
|
|
156
141
|
// Validate background responses
|
|
157
|
-
if (backgroundHerdModulesResult.
|
|
158
|
-
backgroundHerdModulesResult.data &&
|
|
142
|
+
if (backgroundHerdModulesResult.data &&
|
|
159
143
|
Array.isArray(backgroundHerdModulesResult.data) &&
|
|
160
144
|
backgroundUserResult &&
|
|
161
145
|
backgroundUserResult.data) {
|
|
162
146
|
// Update cache with fresh data
|
|
163
147
|
try {
|
|
164
|
-
await
|
|
165
|
-
scoutCache.setHerdModules(backgroundHerdModulesResult.data, cacheTtlMs),
|
|
166
|
-
backgroundVersionsResult &&
|
|
167
|
-
backgroundVersionsResult.status === "success" &&
|
|
168
|
-
backgroundVersionsResult.data
|
|
169
|
-
? scoutCache.setVersionsSoftware(backgroundVersionsResult.data, cacheTtlMs)
|
|
170
|
-
: Promise.resolve(),
|
|
171
|
-
]);
|
|
148
|
+
await scoutCache.setHerdModules(backgroundHerdModulesResult.data, cacheTtlMs);
|
|
172
149
|
}
|
|
173
150
|
catch (cacheError) {
|
|
174
151
|
console.warn("[useScoutRefresh] Background cache save failed:", cacheError);
|
|
175
152
|
await handleIndexedDbError(cacheError, "background cache save", async () => {
|
|
176
|
-
const promises = [];
|
|
177
153
|
if (backgroundHerdModulesResult.data) {
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
if (backgroundVersionsResult &&
|
|
181
|
-
backgroundVersionsResult.status === "success" &&
|
|
182
|
-
backgroundVersionsResult.data) {
|
|
183
|
-
promises.push(scoutCache.setVersionsSoftware(backgroundVersionsResult.data, cacheTtlMs));
|
|
184
|
-
}
|
|
185
|
-
if (promises.length > 0) {
|
|
186
|
-
await Promise.all(promises);
|
|
154
|
+
await scoutCache.setHerdModules(backgroundHerdModulesResult.data, cacheTtlMs);
|
|
187
155
|
}
|
|
188
156
|
});
|
|
189
157
|
}
|
|
@@ -194,13 +162,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
194
162
|
console.log(`[useScoutRefresh] Updating store with background user data`);
|
|
195
163
|
dispatch(setUser(backgroundUserResult.data));
|
|
196
164
|
}
|
|
197
|
-
// Update software versions if successful
|
|
198
|
-
if (backgroundVersionsResult &&
|
|
199
|
-
backgroundVersionsResult.status === "success" &&
|
|
200
|
-
backgroundVersionsResult.data) {
|
|
201
|
-
console.log(`[useScoutRefresh] Updating store with background software versions`);
|
|
202
|
-
dispatch(setVersionsSoftware(backgroundVersionsResult.data));
|
|
203
|
-
}
|
|
204
165
|
// Update data source to DATABASE
|
|
205
166
|
dispatch(setDataSource(EnumDataSource.DATABASE));
|
|
206
167
|
dispatch(setDataSourceInfo({
|
|
@@ -234,7 +195,7 @@ export function useScoutRefresh(options = {}) {
|
|
|
234
195
|
}
|
|
235
196
|
// Step 2: Load fresh data from API
|
|
236
197
|
const parallelStartTime = Date.now();
|
|
237
|
-
const [herdModulesResult, userResult
|
|
198
|
+
const [herdModulesResult, userResult] = await Promise.all([
|
|
238
199
|
(async () => {
|
|
239
200
|
const start = Date.now();
|
|
240
201
|
const result = await server_load_herd_modules();
|
|
@@ -252,16 +213,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
252
213
|
start,
|
|
253
214
|
};
|
|
254
215
|
})(),
|
|
255
|
-
(async () => {
|
|
256
|
-
const start = Date.now();
|
|
257
|
-
const result = await server_get_versions_software();
|
|
258
|
-
const duration = Date.now() - start;
|
|
259
|
-
return {
|
|
260
|
-
result,
|
|
261
|
-
duration,
|
|
262
|
-
start,
|
|
263
|
-
};
|
|
264
|
-
})(),
|
|
265
216
|
]);
|
|
266
217
|
const parallelDuration = Date.now() - parallelStartTime;
|
|
267
218
|
console.log(`[useScoutRefresh] Parallel API requests completed in ${parallelDuration}ms`);
|
|
@@ -305,15 +256,7 @@ export function useScoutRefresh(options = {}) {
|
|
|
305
256
|
// Step 3: Update cache with fresh data
|
|
306
257
|
const cacheSaveStartTime = Date.now();
|
|
307
258
|
try {
|
|
308
|
-
|
|
309
|
-
scoutCache.setHerdModules(compatible_new_herd_modules, cacheTtlMs),
|
|
310
|
-
];
|
|
311
|
-
// Cache software versions if available
|
|
312
|
-
if (versionsResult.result.status === "success" &&
|
|
313
|
-
versionsResult.result.data) {
|
|
314
|
-
cachePromises.push(scoutCache.setVersionsSoftware(versionsResult.result.data, cacheTtlMs));
|
|
315
|
-
}
|
|
316
|
-
await Promise.all(cachePromises);
|
|
259
|
+
await scoutCache.setHerdModules(compatible_new_herd_modules, cacheTtlMs);
|
|
317
260
|
const cacheSaveDuration = Date.now() - cacheSaveStartTime;
|
|
318
261
|
timingRefs.current.cacheSaveDuration = cacheSaveDuration;
|
|
319
262
|
console.log(`[useScoutRefresh] Cache updated in ${cacheSaveDuration}ms with TTL: ${Math.round(cacheTtlMs / 1000)}s`);
|
|
@@ -321,14 +264,7 @@ export function useScoutRefresh(options = {}) {
|
|
|
321
264
|
catch (cacheError) {
|
|
322
265
|
console.warn("[useScoutRefresh] Cache save failed:", cacheError);
|
|
323
266
|
await handleIndexedDbError(cacheError, "cache save", async () => {
|
|
324
|
-
|
|
325
|
-
scoutCache.setHerdModules(compatible_new_herd_modules, cacheTtlMs),
|
|
326
|
-
];
|
|
327
|
-
if (versionsResult.result.status === "success" &&
|
|
328
|
-
versionsResult.result.data) {
|
|
329
|
-
retryPromises.push(scoutCache.setVersionsSoftware(versionsResult.result.data, cacheTtlMs));
|
|
330
|
-
}
|
|
331
|
-
await Promise.all(retryPromises);
|
|
267
|
+
await scoutCache.setHerdModules(compatible_new_herd_modules, cacheTtlMs);
|
|
332
268
|
});
|
|
333
269
|
}
|
|
334
270
|
// Step 4: Conditionally update store with fresh data, skip timestamp-only changes
|
|
@@ -338,12 +274,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
338
274
|
dispatch(setHerdModules(compatible_new_herd_modules));
|
|
339
275
|
console.log(`[useScoutRefresh] Updating store with fresh user data`);
|
|
340
276
|
dispatch(setUser(res_new_user.data));
|
|
341
|
-
// Update software versions
|
|
342
|
-
if (versionsResult.result.status === "success" &&
|
|
343
|
-
versionsResult.result.data) {
|
|
344
|
-
console.log(`[useScoutRefresh] Updating store with fresh software versions`);
|
|
345
|
-
dispatch(setVersionsSoftware(versionsResult.result.data));
|
|
346
|
-
}
|
|
347
277
|
dispatch(setHerdModulesLoadingState(EnumHerdModulesLoadingState.SUCCESSFULLY_LOADED));
|
|
348
278
|
const dataProcessingDuration = Date.now() - dataProcessingStartTime;
|
|
349
279
|
timingRefs.current.dataProcessingDuration = dataProcessingDuration;
|
|
@@ -1389,6 +1389,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1389
1389
|
frequency_hz: number | null;
|
|
1390
1390
|
bandwidth_hz: number | null;
|
|
1391
1391
|
associated_station: string | null;
|
|
1392
|
+
mode: string | null;
|
|
1392
1393
|
};
|
|
1393
1394
|
device_heartbeat_analysis: {
|
|
1394
1395
|
device_id: number | null;
|
package/dist/store/scout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUser
|
|
1
|
+
import { IUser } from "../types/db";
|
|
2
2
|
import { IHerdModule, EnumHerdModulesLoadingState } from "../types/herd_module";
|
|
3
3
|
import { EnumDataSource, IDataSourceInfo } from "../types/data_source";
|
|
4
4
|
import { MapDeviceIdToConnectivity } from "../types/connectivity";
|
|
@@ -23,7 +23,6 @@ export interface ScoutState {
|
|
|
23
23
|
data_source: EnumDataSource;
|
|
24
24
|
data_source_info: IDataSourceInfo | null;
|
|
25
25
|
active_herd_gps_trackers_connectivity: MapDeviceIdToConnectivity;
|
|
26
|
-
versions_software: IVersionsSoftware[];
|
|
27
26
|
}
|
|
28
27
|
export interface RootState {
|
|
29
28
|
scout: ScoutState;
|
|
@@ -173,19 +172,7 @@ export declare const scoutSlice: import("@reduxjs/toolkit").Slice<ScoutState, {
|
|
|
173
172
|
payload: any;
|
|
174
173
|
type: string;
|
|
175
174
|
}) => void;
|
|
176
|
-
setVersionsSoftware: (state: import("immer").WritableDraft<ScoutState>, action: {
|
|
177
|
-
payload: any;
|
|
178
|
-
type: string;
|
|
179
|
-
}) => void;
|
|
180
|
-
upsertVersionSoftware: (state: import("immer").WritableDraft<ScoutState>, action: {
|
|
181
|
-
payload: any;
|
|
182
|
-
type: string;
|
|
183
|
-
}) => void;
|
|
184
|
-
deleteVersionSoftwareById: (state: import("immer").WritableDraft<ScoutState>, action: {
|
|
185
|
-
payload: any;
|
|
186
|
-
type: string;
|
|
187
|
-
}) => void;
|
|
188
175
|
}, "scout", "scout", import("@reduxjs/toolkit").SliceSelectors<ScoutState>>;
|
|
189
|
-
export declare const setHerdModules: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModules">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setStatus">, setHerdModulesLoadingState: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesLoadingState">, setHerdModulesLoadedInMs: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesLoadedInMs">, setHerdModulesApiServerProcessingDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesApiServerProcessingDuration">, setHerdModulesApiTotalRequestDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesApiTotalRequestDuration">, setUserApiDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setUserApiDuration">, setDataProcessingDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataProcessingDuration">, setCacheLoadDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setCacheLoadDuration">, setActiveHerdId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveHerdId">, setActiveDeviceId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveDeviceId">, setDataSource: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataSource">, setDataSourceInfo: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataSourceInfo">, appendEventsToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendEventsToHerdModule">, replaceEventsForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/replaceEventsForHerdModule">, appendArtifactsToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendArtifactsToHerdModule">, replaceArtifactsForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/replaceArtifactsForHerdModule">, updateEventValuesForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateEventValuesForHerdModule">, updatePageIndexForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updatePageIndexForHerdModule">, appendPlansToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendPlansToHerdModule">, setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setUser">, addTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addTag">, deleteTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteTag">, updateTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateTag">, addNewDeviceToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addNewDeviceToHerdModule">, updateDeviceForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateDeviceForHerdModule">, addDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addDevice">, deleteDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteDevice">, updateDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateDevice">, addPlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addPlan">, deletePlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deletePlan">, updatePlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updatePlan">, addSessionToStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addSessionToStore">, deleteSessionFromStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteSessionFromStore">, updateSessionInStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateSessionInStore">, setActiveHerdGpsTrackersConnectivity: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveHerdGpsTrackersConnectivity"
|
|
176
|
+
export declare const setHerdModules: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModules">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setStatus">, setHerdModulesLoadingState: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesLoadingState">, setHerdModulesLoadedInMs: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesLoadedInMs">, setHerdModulesApiServerProcessingDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesApiServerProcessingDuration">, setHerdModulesApiTotalRequestDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setHerdModulesApiTotalRequestDuration">, setUserApiDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setUserApiDuration">, setDataProcessingDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataProcessingDuration">, setCacheLoadDuration: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setCacheLoadDuration">, setActiveHerdId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveHerdId">, setActiveDeviceId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveDeviceId">, setDataSource: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataSource">, setDataSourceInfo: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setDataSourceInfo">, appendEventsToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendEventsToHerdModule">, replaceEventsForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/replaceEventsForHerdModule">, appendArtifactsToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendArtifactsToHerdModule">, replaceArtifactsForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/replaceArtifactsForHerdModule">, updateEventValuesForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateEventValuesForHerdModule">, updatePageIndexForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updatePageIndexForHerdModule">, appendPlansToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/appendPlansToHerdModule">, setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setUser">, addTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addTag">, deleteTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteTag">, updateTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateTag">, addNewDeviceToHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addNewDeviceToHerdModule">, updateDeviceForHerdModule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateDeviceForHerdModule">, addDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addDevice">, deleteDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteDevice">, updateDevice: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateDevice">, addPlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addPlan">, deletePlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deletePlan">, updatePlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updatePlan">, addSessionToStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/addSessionToStore">, deleteSessionFromStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/deleteSessionFromStore">, updateSessionInStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/updateSessionInStore">, setActiveHerdGpsTrackersConnectivity: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "scout/setActiveHerdGpsTrackersConnectivity">;
|
|
190
177
|
declare const _default: import("redux").Reducer<ScoutState>;
|
|
191
178
|
export default _default;
|
package/dist/store/scout.js
CHANGED
|
@@ -25,7 +25,6 @@ const initialState = {
|
|
|
25
25
|
data_source: EnumDataSource.UNKNOWN,
|
|
26
26
|
data_source_info: null,
|
|
27
27
|
active_herd_gps_trackers_connectivity: {},
|
|
28
|
-
versions_software: [],
|
|
29
28
|
};
|
|
30
29
|
export const scoutSlice = createSlice({
|
|
31
30
|
name: "scout",
|
|
@@ -285,27 +284,8 @@ export const scoutSlice = createSlice({
|
|
|
285
284
|
setActiveHerdGpsTrackersConnectivity: (state, action) => {
|
|
286
285
|
state.active_herd_gps_trackers_connectivity = action.payload;
|
|
287
286
|
},
|
|
288
|
-
setVersionsSoftware: (state, action) => {
|
|
289
|
-
state.versions_software = action.payload;
|
|
290
|
-
},
|
|
291
|
-
upsertVersionSoftware: (state, action) => {
|
|
292
|
-
const version = action.payload;
|
|
293
|
-
const existingIndex = state.versions_software.findIndex((v) => v.id === version.id);
|
|
294
|
-
if (existingIndex !== -1) {
|
|
295
|
-
// Update existing version
|
|
296
|
-
state.versions_software[existingIndex] = version;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
// Add new version
|
|
300
|
-
state.versions_software = [version, ...state.versions_software];
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
deleteVersionSoftwareById: (state, action) => {
|
|
304
|
-
const versionId = action.payload;
|
|
305
|
-
state.versions_software = state.versions_software.filter((version) => version.id !== versionId);
|
|
306
|
-
},
|
|
307
287
|
},
|
|
308
288
|
});
|
|
309
289
|
// Action creators are generated for each case reducer function
|
|
310
|
-
export const { setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, appendEventsToHerdModule, replaceEventsForHerdModule, appendArtifactsToHerdModule, replaceArtifactsForHerdModule, updateEventValuesForHerdModule, updatePageIndexForHerdModule, appendPlansToHerdModule, setUser, addTag, deleteTag, updateTag, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, addSessionToStore, deleteSessionFromStore, updateSessionInStore, setActiveHerdGpsTrackersConnectivity,
|
|
290
|
+
export const { setHerdModules, setStatus, setHerdModulesLoadingState, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, appendEventsToHerdModule, replaceEventsForHerdModule, appendArtifactsToHerdModule, replaceArtifactsForHerdModule, updateEventValuesForHerdModule, updatePageIndexForHerdModule, appendPlansToHerdModule, setUser, addTag, deleteTag, updateTag, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, addSessionToStore, deleteSessionFromStore, updateSessionInStore, setActiveHerdGpsTrackersConnectivity, } = scoutSlice.actions;
|
|
311
291
|
export default scoutSlice.reducer;
|
package/dist/types/supabase.d.ts
CHANGED