@adventurelabs/scout-core 2.0.0 → 2.0.2
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/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/helpers/cache.d.ts +25 -17
- package/dist/helpers/cache.js +225 -221
- package/dist/helpers/compliance.d.ts +26 -0
- package/dist/helpers/compliance.js +74 -0
- package/dist/helpers/compliance.queries.d.ts +28 -0
- package/dist/helpers/compliance.queries.js +167 -0
- package/dist/helpers/contacts_server.d.ts +12 -0
- package/dist/helpers/lifecycle_server.d.ts +3 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useScoutRealtimeOperatingContexts.d.ts +5 -3
- package/dist/hooks/useScoutRealtimeOperatingContexts.js +8 -0
- package/dist/hooks/useScoutRefresh.d.ts +3 -2
- package/dist/hooks/useScoutRefresh.js +160 -123
- package/dist/providers/ScoutRefreshProvider.js +39 -17
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/store/scout.d.ts +1 -3
- package/dist/store/scout.js +9 -14
- package/dist/types/db.d.ts +45 -1
- package/dist/types/supabase.d.ts +512 -0
- package/package.json +1 -1
package/dist/store/scout.js
CHANGED
|
@@ -24,17 +24,16 @@ const initialState = {
|
|
|
24
24
|
active_herd_id: null,
|
|
25
25
|
active_device_id: null,
|
|
26
26
|
user: null,
|
|
27
|
-
// Initialize data source tracking
|
|
28
27
|
data_source: EnumDataSource.UNKNOWN,
|
|
29
28
|
data_source_info: null,
|
|
30
29
|
active_herd_gps_trackers_connectivity: {},
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
const scoutSlice = createSlice({
|
|
33
32
|
name: "scout",
|
|
34
33
|
initialState,
|
|
35
34
|
reducers: {
|
|
35
|
+
resetScoutState: () => initialState,
|
|
36
36
|
setHerdModules: (state, action) => {
|
|
37
|
-
// Payload is the modules array (legacy) or { modules, contentHash }.
|
|
38
37
|
const payload = action.payload;
|
|
39
38
|
const modules = Array.isArray(payload)
|
|
40
39
|
? payload
|
|
@@ -42,7 +41,12 @@ export const scoutSlice = createSlice({
|
|
|
42
41
|
const contentHash = Array.isArray(payload)
|
|
43
42
|
? null
|
|
44
43
|
: payload.contentHash ?? null;
|
|
45
|
-
|
|
44
|
+
if (state.active_herd_id &&
|
|
45
|
+
!modules.some((module) => module.herd.id?.toString() === state.active_herd_id)) {
|
|
46
|
+
state.active_herd_id = null;
|
|
47
|
+
state.active_device_id = null;
|
|
48
|
+
state.active_herd_gps_trackers_connectivity = {};
|
|
49
|
+
}
|
|
46
50
|
if (contentHash != null) {
|
|
47
51
|
if (state.herd_modules_content_hash === contentHash) {
|
|
48
52
|
return;
|
|
@@ -138,7 +142,6 @@ export const scoutSlice = createSlice({
|
|
|
138
142
|
herd_module.devices.push(device);
|
|
139
143
|
}
|
|
140
144
|
},
|
|
141
|
-
// append device to herd module
|
|
142
145
|
addNewDeviceToHerdModule: (state, action) => {
|
|
143
146
|
const { herd_id, device } = action.payload;
|
|
144
147
|
const herd_module = state.herd_modules.find((hm) => hm.herd.id?.toString() === herd_id);
|
|
@@ -146,11 +149,6 @@ export const scoutSlice = createSlice({
|
|
|
146
149
|
herd_module.devices = [...herd_module.devices, device];
|
|
147
150
|
}
|
|
148
151
|
},
|
|
149
|
-
// NOTE: Tag management will need to be updated to work with RTK Query
|
|
150
|
-
// These actions are commented out until we implement tag management with RTK Query
|
|
151
|
-
// addTag(state, action) { ... },
|
|
152
|
-
// deleteTag(state, action) { ... },
|
|
153
|
-
// updateTag(state, action) { ... },
|
|
154
152
|
addDevice(state, action) {
|
|
155
153
|
for (const herd_module of state.herd_modules) {
|
|
156
154
|
if (herd_module.herd.id === action.payload.herd_id) {
|
|
@@ -205,8 +203,6 @@ export const scoutSlice = createSlice({
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
},
|
|
208
|
-
// NOTE: Events, sessions, and artifacts are now handled by RTK Query
|
|
209
|
-
// These actions have been removed as they're no longer needed
|
|
210
206
|
setUser: (state, action) => {
|
|
211
207
|
state.user = action.payload;
|
|
212
208
|
},
|
|
@@ -215,6 +211,5 @@ export const scoutSlice = createSlice({
|
|
|
215
211
|
},
|
|
216
212
|
},
|
|
217
213
|
});
|
|
218
|
-
|
|
219
|
-
export const { setHerdModules, setStatus, setHerdModulesLoadingState, setLoadingPerformance, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, updateSessionSummariesForHerdModule, appendPlansToHerdModule, setUser, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, setActiveHerdGpsTrackersConnectivity, } = scoutSlice.actions;
|
|
214
|
+
export const { resetScoutState, setHerdModules, setStatus, setHerdModulesLoadingState, setLoadingPerformance, setHerdModulesLoadedInMs, setHerdModulesApiServerProcessingDuration, setHerdModulesApiTotalRequestDuration, setUserApiDuration, setDataProcessingDuration, setCacheLoadDuration, setActiveHerdId, setActiveDeviceId, setDataSource, setDataSourceInfo, updateSessionSummariesForHerdModule, appendPlansToHerdModule, setUser, addNewDeviceToHerdModule, updateDeviceForHerdModule, addDevice, deleteDevice, updateDevice, addPlan, deletePlan, updatePlan, setActiveHerdGpsTrackersConnectivity, } = scoutSlice.actions;
|
|
220
215
|
export default scoutSlice.reducer;
|
package/dist/types/db.d.ts
CHANGED
|
@@ -73,6 +73,10 @@ export type IMaintenanceRequest = Database["public"]["Tables"]["maintenance_requ
|
|
|
73
73
|
export type ISessionIncident = Database["public"]["Tables"]["session_incidents"]["Row"];
|
|
74
74
|
export type SessionIncidentType = Database["public"]["Enums"]["session_incident_type"];
|
|
75
75
|
export type IContact = Database["public"]["Tables"]["contacts"]["Row"];
|
|
76
|
+
export type IContactType = Database["public"]["Tables"]["contact_types"]["Row"];
|
|
77
|
+
export type IComplianceResourceType = Database["public"]["Tables"]["compliance_resource_types"]["Row"];
|
|
78
|
+
export type IComplianceResource = Database["public"]["Tables"]["compliance_resources"]["Row"];
|
|
79
|
+
export type IHerdOperatingPermission = Database["public"]["Tables"]["herd_operating_permissions"]["Row"];
|
|
76
80
|
export type IDocumentCondition = Database["public"]["Tables"]["document_conditions"]["Row"];
|
|
77
81
|
export type IOperatingContextType = Database["public"]["Tables"]["operating_context_types"]["Row"];
|
|
78
82
|
export type IOperatingContextRole = Database["public"]["Tables"]["operating_context_roles"]["Row"];
|
|
@@ -86,6 +90,10 @@ export type IOperatingContextEquipmentRequirement = Database["public"]["Tables"]
|
|
|
86
90
|
export type IOperatingContextRegion = Database["public"]["Tables"]["operating_context_regions"]["Row"];
|
|
87
91
|
export type IOperatingContextRisk = Database["public"]["Tables"]["operating_context_risks"]["Row"];
|
|
88
92
|
export type IOperatingContextWeatherSnapshot = Database["public"]["Tables"]["operating_context_weather_snapshots"]["Row"];
|
|
93
|
+
export type IOperatingContextPointOfInterestType = Database["public"]["Tables"]["operating_context_point_of_interest_types"]["Row"];
|
|
94
|
+
export type IOperatingContextPointOfInterest = Database["public"]["Tables"]["operating_context_points_of_interest"]["Row"];
|
|
95
|
+
export type IOperatingPermission = Database["public"]["Tables"]["operating_permissions"]["Row"];
|
|
96
|
+
export type IOperatingContextContact = Database["public"]["Tables"]["operating_context_contacts"]["Row"];
|
|
89
97
|
export type OperatingContextPayloadType = Database["public"]["Enums"]["operating_context_payload_type"];
|
|
90
98
|
export type OperatingContextRiskProbability = Database["public"]["Enums"]["operating_context_risk_probability"];
|
|
91
99
|
export type OperatingContextRiskSeverity = Database["public"]["Enums"]["operating_context_risk_severity"];
|
|
@@ -116,7 +124,7 @@ export type OperatingContextEquipmentCategoryCreateInput = Pick<OperatingContext
|
|
|
116
124
|
export type OperatingContextEquipmentCategoryUpdateInput = Partial<OperatingContextEquipmentCategoryCreateInput> & LifecyclePatch;
|
|
117
125
|
export type OperatingContextEquipmentItemCreateInput = Pick<OperatingContextEquipmentItemInsert, "equipment_category_id" | "name">;
|
|
118
126
|
export type OperatingContextEquipmentItemUpdateInput = Partial<OperatingContextEquipmentItemCreateInput> & LifecyclePatch;
|
|
119
|
-
export type OperatingContextCreateInput = Pick<OperatingContextInsert, "herd_id" | "operating_context_type_id" | "name" | "description" | "valid_from" | "valid_to" | "distance_max_from_home" | "altitude_agl_max" | "involves_third_party_land">;
|
|
127
|
+
export type OperatingContextCreateInput = Pick<OperatingContextInsert, "herd_id" | "operating_context_type_id" | "name" | "description" | "local_notes" | "valid_from" | "valid_to" | "distance_max_from_home" | "altitude_agl_max" | "involves_third_party_land">;
|
|
120
128
|
export type OperatingContextUpdateInput = Partial<Omit<OperatingContextCreateInput, "herd_id">> & LifecyclePatch;
|
|
121
129
|
export type OperatingContextPayloadCreateInput = Pick<OperatingContextPayloadInsert, "operating_context_id" | "payload_type" | "weight_kg" | "description">;
|
|
122
130
|
export type OperatingContextPayloadUpdateInput = Partial<Omit<OperatingContextPayloadCreateInput, "operating_context_id">> & LifecyclePatch;
|
|
@@ -136,6 +144,26 @@ export interface OperatingContextRegionCreateInput {
|
|
|
136
144
|
export type OperatingContextRegionUpdateInput = Partial<Omit<OperatingContextRegionCreateInput, "operating_context_id">> & LifecyclePatch;
|
|
137
145
|
export type OperatingContextRiskCreateInput = Pick<OperatingContextRiskInsert, "operating_context_id" | "severity_before" | "probability_before" | "hazard" | "mitigation" | "severity_after" | "probability_after">;
|
|
138
146
|
export type OperatingContextRiskUpdateInput = Partial<Omit<OperatingContextRiskCreateInput, "operating_context_id">> & LifecyclePatch;
|
|
147
|
+
export type ContactTypeCreateInput = Pick<ContactTypeInsert, "localization_id" | "name" | "description" | "num_required">;
|
|
148
|
+
export type ContactTypeUpdateInput = Partial<ContactTypeCreateInput> & LifecyclePatch;
|
|
149
|
+
export type OperatingContextPointOfInterestTypeCreateInput = Pick<OperatingContextPointOfInterestTypeInsert, "localization_id" | "system_name" | "name" | "num_required">;
|
|
150
|
+
export type OperatingContextPointOfInterestTypeUpdateInput = Partial<OperatingContextPointOfInterestTypeCreateInput> & LifecyclePatch;
|
|
151
|
+
export type OperatingPermissionCreateInput = Pick<OperatingPermissionInsert, "localization_id" | "name" | "description">;
|
|
152
|
+
export type OperatingPermissionUpdateInput = Partial<OperatingPermissionCreateInput> & LifecyclePatch;
|
|
153
|
+
export type ComplianceResourceTypeCreateInput = Pick<ComplianceResourceTypeInsert, "system_name" | "name" | "description">;
|
|
154
|
+
export type ComplianceResourceTypeUpdateInput = Partial<ComplianceResourceTypeCreateInput> & LifecyclePatch;
|
|
155
|
+
export type ComplianceResourceCreateInput = Pick<ComplianceResourceInsert, "localization_id" | "compliance_resource_type_id" | "name" | "description" | "url" | "file_uri" | "published_at">;
|
|
156
|
+
export type ComplianceResourceUpdateInput = Partial<ComplianceResourceCreateInput> & LifecyclePatch;
|
|
157
|
+
export interface OperatingContextPointOfInterestCreateInput {
|
|
158
|
+
operating_context_id: number;
|
|
159
|
+
point_of_interest_type_id: number;
|
|
160
|
+
location: GeographyPoint | string;
|
|
161
|
+
}
|
|
162
|
+
export type OperatingContextPointOfInterestUpdateInput = Partial<Omit<OperatingContextPointOfInterestCreateInput, "operating_context_id">> & LifecyclePatch;
|
|
163
|
+
export type OperatingContextContactCreateInput = Pick<OperatingContextContactInsert, "operating_context_id" | "contact_id" | "herd_id">;
|
|
164
|
+
export type OperatingContextContactUpdateInput = Partial<Pick<OperatingContextContactCreateInput, "contact_id">> & LifecyclePatch;
|
|
165
|
+
export type HerdOperatingPermissionCreateInput = Pick<HerdOperatingPermissionInsert, "herd_id" | "operating_permission_id">;
|
|
166
|
+
export type HerdOperatingPermissionUpdateInput = Partial<Pick<HerdOperatingPermissionCreateInput, "operating_permission_id">> & LifecyclePatch;
|
|
139
167
|
/** A part with its resolved product (parts.product_number -> product_numbers -> products). */
|
|
140
168
|
export type IPartWithProduct = IPart & {
|
|
141
169
|
product?: IProduct | null;
|
|
@@ -215,6 +243,14 @@ export type SessionIncidentInsert = Database["public"]["Tables"]["session_incide
|
|
|
215
243
|
export type SessionIncidentUpdate = Database["public"]["Tables"]["session_incidents"]["Update"];
|
|
216
244
|
export type ContactInsert = Database["public"]["Tables"]["contacts"]["Insert"];
|
|
217
245
|
export type ContactUpdate = Database["public"]["Tables"]["contacts"]["Update"];
|
|
246
|
+
export type ContactTypeInsert = Database["public"]["Tables"]["contact_types"]["Insert"];
|
|
247
|
+
export type ContactTypeUpdate = Database["public"]["Tables"]["contact_types"]["Update"];
|
|
248
|
+
export type ComplianceResourceTypeInsert = Database["public"]["Tables"]["compliance_resource_types"]["Insert"];
|
|
249
|
+
export type ComplianceResourceTypeUpdate = Database["public"]["Tables"]["compliance_resource_types"]["Update"];
|
|
250
|
+
export type ComplianceResourceInsert = Database["public"]["Tables"]["compliance_resources"]["Insert"];
|
|
251
|
+
export type ComplianceResourceUpdate = Database["public"]["Tables"]["compliance_resources"]["Update"];
|
|
252
|
+
export type HerdOperatingPermissionInsert = Database["public"]["Tables"]["herd_operating_permissions"]["Insert"];
|
|
253
|
+
export type HerdOperatingPermissionUpdate = Database["public"]["Tables"]["herd_operating_permissions"]["Update"];
|
|
218
254
|
export type DocumentConditionInsert = Database["public"]["Tables"]["document_conditions"]["Insert"];
|
|
219
255
|
export type DocumentConditionUpdate = Database["public"]["Tables"]["document_conditions"]["Update"];
|
|
220
256
|
export type OperatingContextTypeInsert = Database["public"]["Tables"]["operating_context_types"]["Insert"];
|
|
@@ -239,6 +275,14 @@ export type OperatingContextRegionInsert = Database["public"]["Tables"]["operati
|
|
|
239
275
|
export type OperatingContextRegionUpdate = Database["public"]["Tables"]["operating_context_regions"]["Update"];
|
|
240
276
|
export type OperatingContextRiskInsert = Database["public"]["Tables"]["operating_context_risks"]["Insert"];
|
|
241
277
|
export type OperatingContextRiskUpdate = Database["public"]["Tables"]["operating_context_risks"]["Update"];
|
|
278
|
+
export type OperatingContextPointOfInterestTypeInsert = Database["public"]["Tables"]["operating_context_point_of_interest_types"]["Insert"];
|
|
279
|
+
export type OperatingContextPointOfInterestTypeUpdate = Database["public"]["Tables"]["operating_context_point_of_interest_types"]["Update"];
|
|
280
|
+
export type OperatingContextPointOfInterestInsert = Database["public"]["Tables"]["operating_context_points_of_interest"]["Insert"];
|
|
281
|
+
export type OperatingContextPointOfInterestUpdate = Database["public"]["Tables"]["operating_context_points_of_interest"]["Update"];
|
|
282
|
+
export type OperatingPermissionInsert = Database["public"]["Tables"]["operating_permissions"]["Insert"];
|
|
283
|
+
export type OperatingPermissionUpdate = Database["public"]["Tables"]["operating_permissions"]["Update"];
|
|
284
|
+
export type OperatingContextContactInsert = Database["public"]["Tables"]["operating_context_contacts"]["Insert"];
|
|
285
|
+
export type OperatingContextContactUpdate = Database["public"]["Tables"]["operating_context_contacts"]["Update"];
|
|
242
286
|
export interface CredentialQueryArgs {
|
|
243
287
|
type?: string;
|
|
244
288
|
}
|