@adventurelabs/scout-core 1.5.4 → 2.0.0
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/README.md +47 -0
- package/dist/api_keys/actions.d.ts +0 -1
- package/dist/api_keys/actions.js +0 -14
- package/dist/client/index.d.ts +75 -0
- package/dist/client/index.js +82 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/helpers/analysis_usage/jobs_server.d.ts +25 -0
- package/dist/helpers/analysis_usage/jobs_server.js +10 -0
- package/dist/helpers/analysis_usage/tasks_server.d.ts +63 -0
- package/dist/helpers/analysis_usage/tasks_server.js +14 -0
- package/dist/helpers/artifacts.d.ts +0 -1
- package/dist/helpers/artifacts.js +10 -147
- package/dist/helpers/artifacts.queries.d.ts +26 -0
- package/dist/helpers/{artifacts.internal.js → artifacts.queries.js} +24 -41
- package/dist/helpers/auth.d.ts +1 -1
- package/dist/helpers/auth.js +2 -3
- package/dist/helpers/auth_server.d.ts +2 -0
- package/dist/helpers/auth_server.js +10 -0
- package/dist/helpers/certificates_server.d.ts +101 -0
- package/dist/helpers/certificates_server.js +42 -0
- package/dist/helpers/chat.d.ts +1 -2
- package/dist/helpers/chat.js +3 -38
- package/dist/helpers/chat.queries.d.ts +13 -0
- package/dist/helpers/chat.queries.js +39 -0
- package/dist/helpers/client_abilities_jwt_keys.js +0 -1
- package/dist/helpers/client_abilities_token_server.d.ts +1 -0
- package/dist/helpers/client_abilities_token_server.js +5 -2
- package/dist/helpers/connectivity.d.ts +1 -5
- package/dist/helpers/connectivity.js +7 -140
- package/dist/helpers/connectivity.queries.d.ts +18 -0
- package/dist/helpers/connectivity.queries.js +121 -0
- package/dist/helpers/contacts_server.d.ts +63 -0
- package/dist/helpers/contacts_server.js +18 -0
- package/dist/helpers/deviceTransfer.js +2 -11
- package/dist/helpers/deviceTransfer.queries.d.ts +4 -0
- package/dist/helpers/deviceTransfer.queries.js +11 -0
- package/dist/helpers/devices.js +4 -61
- package/dist/helpers/devices.queries.d.ts +4 -1
- package/dist/helpers/devices.queries.js +52 -0
- package/dist/helpers/document_templates.js +6 -52
- package/dist/helpers/document_templates.queries.d.ts +9 -0
- package/dist/helpers/document_templates.queries.js +56 -0
- package/dist/helpers/documents_server.d.ts +226 -0
- package/dist/helpers/documents_server.js +38 -0
- package/dist/helpers/email.d.ts +0 -6
- package/dist/helpers/email.js +1 -19
- package/dist/helpers/embeddings.d.ts +0 -5
- package/dist/helpers/embeddings.js +2 -19
- package/dist/helpers/embeddings.queries.d.ts +7 -0
- package/dist/helpers/{embeddings.internal.js → embeddings.queries.js} +2 -2
- package/dist/helpers/eventUtils.d.ts +3 -12
- package/dist/helpers/eventUtils.js +0 -10
- package/dist/helpers/events.d.ts +0 -1
- package/dist/helpers/events.js +7 -107
- package/dist/helpers/events.queries.d.ts +17 -0
- package/dist/helpers/{events.internal.js → events.queries.js} +24 -15
- package/dist/helpers/health_metrics.js +3 -38
- package/dist/helpers/health_metrics.queries.d.ts +12 -0
- package/dist/helpers/health_metrics.queries.js +39 -0
- package/dist/helpers/heartbeats.js +4 -83
- package/dist/helpers/heartbeats.queries.d.ts +11 -0
- package/dist/helpers/heartbeats.queries.js +76 -0
- package/dist/helpers/herd_allowed_domains.js +2 -12
- package/dist/helpers/{herd_allowed_domains_internal.d.ts → herd_allowed_domains.queries.d.ts} +1 -1
- package/dist/helpers/{herd_allowed_domains_internal.js → herd_allowed_domains.queries.js} +2 -2
- package/dist/helpers/herd_credentials_server.d.ts +76 -0
- package/dist/helpers/herd_credentials_server.js +22 -0
- package/dist/helpers/herd_modules.queries.js +10 -7
- package/dist/helpers/herd_roles.js +13 -148
- package/dist/helpers/herd_roles.queries.d.ts +18 -0
- package/dist/helpers/{herd_roles_internal.js → herd_roles.queries.js} +28 -28
- package/dist/helpers/herds.js +5 -47
- package/dist/helpers/herds.queries.d.ts +8 -1
- package/dist/helpers/herds.queries.js +48 -0
- package/dist/helpers/invitations.js +7 -58
- package/dist/helpers/invitations.queries.d.ts +10 -0
- package/dist/helpers/{invitations_internal.js → invitations.queries.js} +12 -12
- package/dist/helpers/issuers.js +6 -52
- package/dist/helpers/issuers.queries.d.ts +9 -0
- package/dist/helpers/issuers.queries.js +53 -0
- package/dist/helpers/layers.js +2 -20
- package/dist/helpers/layers.queries.d.ts +2 -1
- package/dist/helpers/layers.queries.js +9 -13
- package/dist/helpers/lifecycle_server.d.ts +175 -0
- package/dist/helpers/lifecycle_server.js +38 -0
- package/dist/helpers/localizations.js +5 -42
- package/dist/helpers/localizations.queries.d.ts +8 -0
- package/dist/helpers/localizations.queries.js +45 -0
- package/dist/helpers/maintenance_requests_server.d.ts +124 -0
- package/dist/helpers/maintenance_requests_server.js +34 -0
- package/dist/helpers/manufacturers.js +5 -43
- package/dist/helpers/manufacturers.queries.d.ts +10 -0
- package/dist/helpers/manufacturers.queries.js +46 -0
- package/dist/helpers/media_urls.d.ts +13 -0
- package/dist/helpers/media_urls.js +21 -0
- package/dist/helpers/models.js +8 -80
- package/dist/helpers/models.queries.d.ts +13 -0
- package/dist/helpers/models.queries.js +79 -0
- package/dist/helpers/observations_server.d.ts +51 -0
- package/dist/helpers/observations_server.js +22 -0
- package/dist/helpers/operating_contexts.js +39 -154
- package/dist/helpers/operating_contexts.queries.d.ts +48 -0
- package/dist/helpers/operating_contexts.queries.js +223 -0
- package/dist/helpers/operators.js +4 -57
- package/dist/helpers/operators.queries.d.ts +7 -0
- package/dist/helpers/operators.queries.js +55 -0
- package/dist/helpers/parts.d.ts +0 -87
- package/dist/helpers/parts.js +4 -90
- package/dist/helpers/parts_server.d.ts +260 -0
- package/dist/helpers/parts_server.js +71 -0
- package/dist/helpers/pins_server.d.ts +118 -0
- package/dist/helpers/pins_server.js +38 -0
- package/dist/helpers/plans.js +4 -56
- package/dist/helpers/plans.queries.d.ts +4 -1
- package/dist/helpers/plans.queries.js +39 -12
- package/dist/helpers/points_for_user_server.d.ts +9 -0
- package/dist/helpers/points_for_user_server.js +14 -0
- package/dist/helpers/product_compatibilities.js +6 -78
- package/dist/helpers/product_compatibilities.queries.d.ts +9 -0
- package/dist/helpers/product_compatibilities.queries.js +83 -0
- package/dist/helpers/product_numbers.js +6 -55
- package/dist/helpers/product_numbers.queries.d.ts +9 -0
- package/dist/helpers/product_numbers.queries.js +58 -0
- package/dist/helpers/products.js +6 -54
- package/dist/helpers/products.queries.d.ts +11 -0
- package/dist/helpers/products.queries.js +58 -0
- package/dist/helpers/providers.js +5 -71
- package/dist/helpers/providers.queries.d.ts +5 -1
- package/dist/helpers/providers.queries.js +52 -11
- package/dist/helpers/pubsub_token_server.d.ts +1 -0
- package/dist/helpers/pubsub_token_server.js +5 -2
- package/dist/helpers/segmentations_sam3.js +5 -78
- package/dist/helpers/segmentations_sam3.queries.d.ts +16 -0
- package/dist/helpers/segmentations_sam3.queries.js +81 -0
- package/dist/helpers/sensor_poses_server.d.ts +98 -0
- package/dist/helpers/sensor_poses_server.js +26 -0
- package/dist/helpers/session_incidents_server.d.ts +106 -0
- package/dist/helpers/session_incidents_server.js +22 -0
- package/dist/helpers/session_summaries.d.ts +2 -0
- package/dist/helpers/session_summaries.js +7 -23
- package/dist/helpers/session_summaries.queries.d.ts +6 -3
- package/dist/helpers/session_summaries.queries.js +27 -0
- package/dist/helpers/sessions.js +8 -122
- package/dist/helpers/sessions.queries.d.ts +14 -2
- package/dist/helpers/sessions.queries.js +88 -1
- package/dist/helpers/storage.js +0 -1
- package/dist/helpers/supabase_auth.d.ts +6 -0
- package/dist/helpers/supabase_auth.js +37 -0
- package/dist/helpers/tags.d.ts +0 -1
- package/dist/helpers/tags.js +13 -559
- package/dist/helpers/tags.queries.d.ts +33 -0
- package/dist/helpers/tags.queries.js +454 -0
- package/dist/helpers/user_credentials_server.d.ts +76 -0
- package/dist/helpers/user_credentials_server.js +22 -0
- package/dist/helpers/users.d.ts +2 -2
- package/dist/helpers/users.js +8 -107
- package/dist/helpers/users.queries.d.ts +9 -1
- package/dist/helpers/users.queries.js +107 -0
- package/dist/helpers/versions_software.d.ts +3 -1
- package/dist/helpers/versions_software.js +24 -0
- package/dist/helpers/versions_software_server.d.ts +83 -4
- package/dist/helpers/versions_software_server.js +23 -50
- package/dist/helpers/zones.d.ts +1 -16
- package/dist/helpers/zones.js +4 -104
- package/dist/helpers/zones.queries.d.ts +6 -0
- package/dist/helpers/zones.queries.js +78 -0
- package/dist/hooks/useAuthorizedRealtimeTopics.js +8 -2
- package/dist/hooks/useInfiniteQuery.js +18 -14
- package/dist/hooks/useScoutRealtimeBroadcast.js +8 -6
- package/dist/hooks/useScoutRealtimeDocuments.js +3 -2
- package/dist/hooks/useScoutRefresh.d.ts +9 -25
- package/dist/hooks/useScoutRefresh.js +33 -213
- package/dist/providers/ScoutRefreshProvider.d.ts +1 -1
- package/dist/providers/ScoutRefreshProvider.js +56 -13
- package/dist/server/index.d.ts +77 -0
- package/dist/server/index.js +79 -0
- package/dist/server/middleware.d.ts +2 -0
- package/dist/server/middleware.js +2 -0
- package/dist/server/supabase.d.ts +2 -0
- package/dist/server/supabase.js +2 -0
- package/dist/store/api.d.ts +40 -40
- package/dist/store/api.js +38 -109
- package/dist/store/configureStore.d.ts +0 -55
- package/dist/store/configureStore.js +1 -8
- package/dist/store/hooks.js +1 -0
- package/dist/supabase/client.d.ts +3 -0
- package/dist/supabase/client.js +10 -0
- package/dist/supabase/middleware.d.ts +1 -0
- package/dist/supabase/middleware.js +6 -20
- package/dist/supabase/server.d.ts +7 -2
- package/dist/supabase/server.js +13 -1
- package/dist/types/db.d.ts +2 -2
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/package.json +53 -4
- package/dist/api_keys/index.d.ts +0 -1
- package/dist/api_keys/index.js +0 -1
- package/dist/helpers/artifacts.internal.d.ts +0 -22
- package/dist/helpers/client_abilities_jwt_keys_internal.d.ts +0 -9
- package/dist/helpers/client_abilities_jwt_keys_internal.js +0 -20
- package/dist/helpers/connectivity.internal.d.ts +0 -10
- package/dist/helpers/connectivity.internal.js +0 -47
- package/dist/helpers/credentials.d.ts +0 -9
- package/dist/helpers/credentials.js +0 -92
- package/dist/helpers/embeddings.internal.d.ts +0 -5
- package/dist/helpers/events.internal.d.ts +0 -13
- package/dist/helpers/herd_roles_internal.d.ts +0 -18
- package/dist/helpers/index.d.ts +0 -56
- package/dist/helpers/index.js +0 -56
- package/dist/helpers/invitations_internal.d.ts +0 -10
- package/dist/helpers/versions_software_internal.d.ts +0 -6
- package/dist/helpers/versions_software_internal.js +0 -53
- package/dist/hooks/useDeviceDisplayName.d.ts +0 -8
- package/dist/hooks/useDeviceDisplayName.js +0 -49
- package/dist/index.d.ts +0 -108
- package/dist/index.js +0 -114
- package/dist/supabase/index.d.ts +0 -2
- package/dist/supabase/index.js +0 -2
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
if (herd_ids.length === 0) {
|
|
5
|
-
return IWebResponse.success({}).to_compatible();
|
|
6
|
-
}
|
|
2
|
+
export { get_layers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
3
|
+
export async function get_layers_by_herd_query(client, herd_id) {
|
|
7
4
|
const { data, error } = await client
|
|
8
5
|
.from("layers")
|
|
9
6
|
.select("*")
|
|
10
|
-
.
|
|
11
|
-
.order("id", { ascending: true });
|
|
7
|
+
.eq("herd_id", herd_id);
|
|
12
8
|
if (error) {
|
|
13
|
-
return {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
return {
|
|
10
|
+
status: EnumWebResponse.ERROR,
|
|
11
|
+
msg: error.message,
|
|
12
|
+
data: null,
|
|
13
|
+
};
|
|
18
14
|
}
|
|
19
|
-
return IWebResponse.success(
|
|
15
|
+
return IWebResponse.success(data).to_compatible();
|
|
20
16
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { EntityLifecycle } from "../types/db";
|
|
2
|
+
import { LifecycleUpdateOptions } from "./lifecycle";
|
|
3
|
+
export declare function server_update_user_lifecycle(user_id: string, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
4
|
+
auto_approve_sessions: boolean;
|
|
5
|
+
earthranger_id: string | null;
|
|
6
|
+
first: string | null;
|
|
7
|
+
id: string;
|
|
8
|
+
is_registered: boolean;
|
|
9
|
+
last: string | null;
|
|
10
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
11
|
+
lifecycle_changed_at: string;
|
|
12
|
+
lifecycle_changed_by: string | null;
|
|
13
|
+
lifecycle_reason: string | null;
|
|
14
|
+
photo_uri: string | null;
|
|
15
|
+
signature_base64: string | null;
|
|
16
|
+
title: string | null;
|
|
17
|
+
username: string | null;
|
|
18
|
+
} | null>>;
|
|
19
|
+
export declare function server_update_device_lifecycle(device_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
20
|
+
altitude: number | null;
|
|
21
|
+
color: string | null;
|
|
22
|
+
created_by: string;
|
|
23
|
+
description: string;
|
|
24
|
+
device_type: import("../types").Database["public"]["Enums"]["device_type"];
|
|
25
|
+
domain_name: string | null;
|
|
26
|
+
heading: number | null;
|
|
27
|
+
herd_id: number;
|
|
28
|
+
id: number;
|
|
29
|
+
inserted_at: string;
|
|
30
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
31
|
+
lifecycle_changed_at: string;
|
|
32
|
+
lifecycle_changed_by: string | null;
|
|
33
|
+
lifecycle_reason: string | null;
|
|
34
|
+
location: unknown;
|
|
35
|
+
name: string;
|
|
36
|
+
} | null>>;
|
|
37
|
+
export declare function server_update_session_lifecycle(session_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
38
|
+
altitude_average: number;
|
|
39
|
+
altitude_max: number;
|
|
40
|
+
altitude_min: number;
|
|
41
|
+
battery_id: number | null;
|
|
42
|
+
device_id: number;
|
|
43
|
+
distance_max_from_start: number;
|
|
44
|
+
distance_total: number;
|
|
45
|
+
end_approver: string | null;
|
|
46
|
+
end_reason: import("../types").Database["public"]["Enums"]["session_end_reason"] | null;
|
|
47
|
+
id: number;
|
|
48
|
+
inserted_at: string;
|
|
49
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
50
|
+
lifecycle_changed_at: string;
|
|
51
|
+
lifecycle_changed_by: string | null;
|
|
52
|
+
lifecycle_reason: string | null;
|
|
53
|
+
locations: unknown;
|
|
54
|
+
post_approver: string | null;
|
|
55
|
+
software_version: string;
|
|
56
|
+
start_approver: string | null;
|
|
57
|
+
status: import("../types").Database["public"]["Enums"]["session_status"];
|
|
58
|
+
timestamp_end: string | null;
|
|
59
|
+
timestamp_start: string;
|
|
60
|
+
velocity_average: number;
|
|
61
|
+
velocity_max: number;
|
|
62
|
+
velocity_min: number;
|
|
63
|
+
} | null>>;
|
|
64
|
+
export declare function server_update_part_lifecycle(part_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
65
|
+
certificate_id: number | null;
|
|
66
|
+
created_at: string;
|
|
67
|
+
device_id: number | null;
|
|
68
|
+
health: import("../types").Database["public"]["Enums"]["health_item"];
|
|
69
|
+
herd_id: number | null;
|
|
70
|
+
id: number;
|
|
71
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
72
|
+
lifecycle_changed_at: string;
|
|
73
|
+
lifecycle_changed_by: string | null;
|
|
74
|
+
lifecycle_reason: string | null;
|
|
75
|
+
primary_calibration_id: number | null;
|
|
76
|
+
product_number: string;
|
|
77
|
+
serial_number: string;
|
|
78
|
+
updated_at: string | null;
|
|
79
|
+
} | null>>;
|
|
80
|
+
export declare function server_update_event_lifecycle(event_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
81
|
+
altitude: number;
|
|
82
|
+
device_id: number;
|
|
83
|
+
earthranger_url: string | null;
|
|
84
|
+
embedded_at: string | null;
|
|
85
|
+
file_path: string | null;
|
|
86
|
+
heading: number;
|
|
87
|
+
id: number;
|
|
88
|
+
inserted_at: string;
|
|
89
|
+
is_public: boolean;
|
|
90
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
91
|
+
lifecycle_changed_at: string;
|
|
92
|
+
lifecycle_changed_by: string | null;
|
|
93
|
+
lifecycle_reason: string | null;
|
|
94
|
+
location: unknown;
|
|
95
|
+
media_type: import("../types").Database["public"]["Enums"]["media_type"];
|
|
96
|
+
media_url: string | null;
|
|
97
|
+
message: string | null;
|
|
98
|
+
origin_heading: number | null;
|
|
99
|
+
origin_height: number | null;
|
|
100
|
+
origin_location: unknown;
|
|
101
|
+
origin_pitch: number | null;
|
|
102
|
+
origin_roll: number | null;
|
|
103
|
+
processing_blocked_at: string | null;
|
|
104
|
+
processing_blocked_reason: string | null;
|
|
105
|
+
segmented_at: string | null;
|
|
106
|
+
sensor_pitch: number | null;
|
|
107
|
+
sensor_roll: number | null;
|
|
108
|
+
sensor_yaw: number | null;
|
|
109
|
+
session_id: number | null;
|
|
110
|
+
tagged_at: string | null;
|
|
111
|
+
timestamp_observation: string;
|
|
112
|
+
tracked_at: string | null;
|
|
113
|
+
} | null>>;
|
|
114
|
+
export declare function server_update_artifact_lifecycle(artifact_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
115
|
+
created_at: string;
|
|
116
|
+
device_id: number;
|
|
117
|
+
embedded_at: string | null;
|
|
118
|
+
file_path: string;
|
|
119
|
+
file_size_bytes: number | null;
|
|
120
|
+
id: number;
|
|
121
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
122
|
+
lifecycle_changed_at: string;
|
|
123
|
+
lifecycle_changed_by: string | null;
|
|
124
|
+
lifecycle_reason: string | null;
|
|
125
|
+
modality: string | null;
|
|
126
|
+
processing_blocked_at: string | null;
|
|
127
|
+
processing_blocked_reason: string | null;
|
|
128
|
+
proxy_file_path: string | null;
|
|
129
|
+
proxy_generated_at: string | null;
|
|
130
|
+
segmented_at: string | null;
|
|
131
|
+
session_id: number | null;
|
|
132
|
+
tagged_at: string | null;
|
|
133
|
+
thumbnail_file_path: string | null;
|
|
134
|
+
thumbnail_generated_at: string | null;
|
|
135
|
+
timestamp_observation: string | null;
|
|
136
|
+
timestamp_observation_end: string;
|
|
137
|
+
tracked_at: string | null;
|
|
138
|
+
updated_at: string | null;
|
|
139
|
+
} | null>>;
|
|
140
|
+
export declare function server_update_user_role_per_herd_lifecycle(membership_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
141
|
+
herd_id: number;
|
|
142
|
+
herd_role_id: number;
|
|
143
|
+
id: number;
|
|
144
|
+
inserted_at: string;
|
|
145
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
146
|
+
lifecycle_changed_at: string;
|
|
147
|
+
lifecycle_changed_by: string | null;
|
|
148
|
+
lifecycle_reason: string | null;
|
|
149
|
+
user_id: string;
|
|
150
|
+
} | null>>;
|
|
151
|
+
export declare function server_update_contact_lifecycle(contact_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
152
|
+
created_at: string;
|
|
153
|
+
created_by: string | null;
|
|
154
|
+
email: string | null;
|
|
155
|
+
herd_id: number;
|
|
156
|
+
id: number;
|
|
157
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
158
|
+
lifecycle_changed_at: string;
|
|
159
|
+
lifecycle_changed_by: string | null;
|
|
160
|
+
lifecycle_reason: string | null;
|
|
161
|
+
name: string;
|
|
162
|
+
phone: string | null;
|
|
163
|
+
updated_at: string;
|
|
164
|
+
updated_by: string | null;
|
|
165
|
+
} | null>>;
|
|
166
|
+
export declare function server_update_herd_allowed_domain_lifecycle(domain_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
167
|
+
created_at: string;
|
|
168
|
+
domain: string;
|
|
169
|
+
herd_id: number;
|
|
170
|
+
id: number;
|
|
171
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
172
|
+
lifecycle_changed_at: string;
|
|
173
|
+
lifecycle_changed_by: string | null;
|
|
174
|
+
lifecycle_reason: string | null;
|
|
175
|
+
} | null>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { newServerClient } from "../supabase/server";
|
|
2
|
+
import { update_artifact_lifecycle, update_contact_lifecycle, update_device_lifecycle, update_event_lifecycle, update_herd_allowed_domain_lifecycle, update_part_lifecycle, update_session_lifecycle, update_user_lifecycle, update_user_role_per_herd_lifecycle, } from "./lifecycle";
|
|
3
|
+
export async function server_update_user_lifecycle(user_id, lifecycle, options) {
|
|
4
|
+
const client = await newServerClient();
|
|
5
|
+
return update_user_lifecycle(client, user_id, lifecycle, options);
|
|
6
|
+
}
|
|
7
|
+
export async function server_update_device_lifecycle(device_id, lifecycle, options) {
|
|
8
|
+
const client = await newServerClient();
|
|
9
|
+
return update_device_lifecycle(client, device_id, lifecycle, options);
|
|
10
|
+
}
|
|
11
|
+
export async function server_update_session_lifecycle(session_id, lifecycle, options) {
|
|
12
|
+
const client = await newServerClient();
|
|
13
|
+
return update_session_lifecycle(client, session_id, lifecycle, options);
|
|
14
|
+
}
|
|
15
|
+
export async function server_update_part_lifecycle(part_id, lifecycle, options) {
|
|
16
|
+
const client = await newServerClient();
|
|
17
|
+
return update_part_lifecycle(client, part_id, lifecycle, options);
|
|
18
|
+
}
|
|
19
|
+
export async function server_update_event_lifecycle(event_id, lifecycle, options) {
|
|
20
|
+
const client = await newServerClient();
|
|
21
|
+
return update_event_lifecycle(client, event_id, lifecycle, options);
|
|
22
|
+
}
|
|
23
|
+
export async function server_update_artifact_lifecycle(artifact_id, lifecycle, options) {
|
|
24
|
+
const client = await newServerClient();
|
|
25
|
+
return update_artifact_lifecycle(client, artifact_id, lifecycle, options);
|
|
26
|
+
}
|
|
27
|
+
export async function server_update_user_role_per_herd_lifecycle(membership_id, lifecycle, options) {
|
|
28
|
+
const client = await newServerClient();
|
|
29
|
+
return update_user_role_per_herd_lifecycle(client, membership_id, lifecycle, options);
|
|
30
|
+
}
|
|
31
|
+
export async function server_update_contact_lifecycle(contact_id, lifecycle, options) {
|
|
32
|
+
const client = await newServerClient();
|
|
33
|
+
return update_contact_lifecycle(client, contact_id, lifecycle, options);
|
|
34
|
+
}
|
|
35
|
+
export async function server_update_herd_allowed_domain_lifecycle(domain_id, lifecycle, options) {
|
|
36
|
+
const client = await newServerClient();
|
|
37
|
+
return update_herd_allowed_domain_lifecycle(client, domain_id, lifecycle, options);
|
|
38
|
+
}
|
|
@@ -1,51 +1,14 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_localization_query, get_localization_by_id_query, get_localizations_query, update_localization_query, } from "./localizations.queries";
|
|
4
3
|
export async function server_get_localizations() {
|
|
5
|
-
|
|
6
|
-
const { data, error } = await supabase
|
|
7
|
-
.from("localizations")
|
|
8
|
-
.select("*")
|
|
9
|
-
.order("region");
|
|
10
|
-
if (error) {
|
|
11
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
12
|
-
}
|
|
13
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
4
|
+
return get_localizations_query(await newServerClient());
|
|
14
5
|
}
|
|
15
6
|
export async function server_get_localization_by_id(localization_id) {
|
|
16
|
-
|
|
17
|
-
const { data, error } = await supabase
|
|
18
|
-
.from("localizations")
|
|
19
|
-
.select("*")
|
|
20
|
-
.eq("id", localization_id)
|
|
21
|
-
.maybeSingle();
|
|
22
|
-
if (error) {
|
|
23
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
24
|
-
}
|
|
25
|
-
return IWebResponse.success(data).to_compatible();
|
|
7
|
+
return get_localization_by_id_query(await newServerClient(), localization_id);
|
|
26
8
|
}
|
|
27
9
|
export async function server_create_localization(row) {
|
|
28
|
-
|
|
29
|
-
const { data, error } = await supabase
|
|
30
|
-
.from("localizations")
|
|
31
|
-
.insert(row)
|
|
32
|
-
.select("*")
|
|
33
|
-
.single();
|
|
34
|
-
if (error) {
|
|
35
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
36
|
-
}
|
|
37
|
-
return IWebResponse.success(data).to_compatible();
|
|
10
|
+
return create_localization_query(await newServerClient(), row);
|
|
38
11
|
}
|
|
39
12
|
export async function server_update_localization(localization_id, updates) {
|
|
40
|
-
|
|
41
|
-
const { data, error } = await supabase
|
|
42
|
-
.from("localizations")
|
|
43
|
-
.update(updates)
|
|
44
|
-
.eq("id", localization_id)
|
|
45
|
-
.select("*")
|
|
46
|
-
.single();
|
|
47
|
-
if (error) {
|
|
48
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
49
|
-
}
|
|
50
|
-
return IWebResponse.success(data).to_compatible();
|
|
13
|
+
return update_localization_query(await newServerClient(), localization_id, updates);
|
|
51
14
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { ILocalization, LocalizationInsert, LocalizationUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_localizations_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<ILocalization[]>>;
|
|
6
|
+
export declare function get_localization_by_id_query(client: SupabaseClient<Database>, localization_id: number): Promise<IWebResponseCompatible<ILocalization | null>>;
|
|
7
|
+
export declare function create_localization_query(client: SupabaseClient<Database>, row: LocalizationInsert): Promise<IWebResponseCompatible<ILocalization | null>>;
|
|
8
|
+
export declare function update_localization_query(client: SupabaseClient<Database>, localization_id: number, updates: LocalizationUpdate): Promise<IWebResponseCompatible<ILocalization | null>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_localizations_query(client) {
|
|
3
|
+
const { data, error } = await client
|
|
4
|
+
.from("localizations")
|
|
5
|
+
.select("*")
|
|
6
|
+
.order("region");
|
|
7
|
+
if (error) {
|
|
8
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
9
|
+
}
|
|
10
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
11
|
+
}
|
|
12
|
+
export async function get_localization_by_id_query(client, localization_id) {
|
|
13
|
+
const { data, error } = await client
|
|
14
|
+
.from("localizations")
|
|
15
|
+
.select("*")
|
|
16
|
+
.eq("id", localization_id)
|
|
17
|
+
.maybeSingle();
|
|
18
|
+
if (error) {
|
|
19
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
20
|
+
}
|
|
21
|
+
return IWebResponse.success(data).to_compatible();
|
|
22
|
+
}
|
|
23
|
+
export async function create_localization_query(client, row) {
|
|
24
|
+
const { data, error } = await client
|
|
25
|
+
.from("localizations")
|
|
26
|
+
.insert(row)
|
|
27
|
+
.select("*")
|
|
28
|
+
.single();
|
|
29
|
+
if (error) {
|
|
30
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
31
|
+
}
|
|
32
|
+
return IWebResponse.success(data).to_compatible();
|
|
33
|
+
}
|
|
34
|
+
export async function update_localization_query(client, localization_id, updates) {
|
|
35
|
+
const { data, error } = await client
|
|
36
|
+
.from("localizations")
|
|
37
|
+
.update(updates)
|
|
38
|
+
.eq("id", localization_id)
|
|
39
|
+
.select("*")
|
|
40
|
+
.single();
|
|
41
|
+
if (error) {
|
|
42
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
43
|
+
}
|
|
44
|
+
return IWebResponse.success(data).to_compatible();
|
|
45
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { MaintenanceRequestInsert, MaintenanceRequestUpdate } from "../types/db";
|
|
2
|
+
export declare function server_get_maintenance_requests_by_device_id(device_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
3
|
+
created_at: string;
|
|
4
|
+
creator_user_id: string | null;
|
|
5
|
+
defect_timestamp: string;
|
|
6
|
+
description: string;
|
|
7
|
+
device_id: number | null;
|
|
8
|
+
id: number;
|
|
9
|
+
image: string | null;
|
|
10
|
+
is_serviceable: boolean;
|
|
11
|
+
part_id: number | null;
|
|
12
|
+
remediation_completed_at: string | null;
|
|
13
|
+
remediation_completed_user_id: string | null;
|
|
14
|
+
remediation_notes: string | null;
|
|
15
|
+
session_incident_id: number | null;
|
|
16
|
+
updated_at: string | null;
|
|
17
|
+
updated_by_user_id: string | null;
|
|
18
|
+
}[]>>;
|
|
19
|
+
export declare function server_get_maintenance_requests_by_part_id(part_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
20
|
+
created_at: string;
|
|
21
|
+
creator_user_id: string | null;
|
|
22
|
+
defect_timestamp: string;
|
|
23
|
+
description: string;
|
|
24
|
+
device_id: number | null;
|
|
25
|
+
id: number;
|
|
26
|
+
image: string | null;
|
|
27
|
+
is_serviceable: boolean;
|
|
28
|
+
part_id: number | null;
|
|
29
|
+
remediation_completed_at: string | null;
|
|
30
|
+
remediation_completed_user_id: string | null;
|
|
31
|
+
remediation_notes: string | null;
|
|
32
|
+
session_incident_id: number | null;
|
|
33
|
+
updated_at: string | null;
|
|
34
|
+
updated_by_user_id: string | null;
|
|
35
|
+
}[]>>;
|
|
36
|
+
export declare function server_get_maintenance_requests_by_herd_id(herd_id: number, options?: {
|
|
37
|
+
limit?: number;
|
|
38
|
+
offset?: number;
|
|
39
|
+
}): Promise<import("../types").IWebResponseCompatible<{
|
|
40
|
+
created_at: string;
|
|
41
|
+
creator_user_id: string | null;
|
|
42
|
+
defect_timestamp: string;
|
|
43
|
+
description: string;
|
|
44
|
+
device_id: number | null;
|
|
45
|
+
id: number;
|
|
46
|
+
image: string | null;
|
|
47
|
+
is_serviceable: boolean;
|
|
48
|
+
part_id: number | null;
|
|
49
|
+
remediation_completed_at: string | null;
|
|
50
|
+
remediation_completed_user_id: string | null;
|
|
51
|
+
remediation_notes: string | null;
|
|
52
|
+
session_incident_id: number | null;
|
|
53
|
+
updated_at: string | null;
|
|
54
|
+
updated_by_user_id: string | null;
|
|
55
|
+
}[]>>;
|
|
56
|
+
export declare function server_get_maintenance_requests_count_by_herd_id(herd_id: number): Promise<import("../types").IWebResponseCompatible<number>>;
|
|
57
|
+
export declare function server_get_maintenance_request_by_id(request_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
58
|
+
created_at: string;
|
|
59
|
+
creator_user_id: string | null;
|
|
60
|
+
defect_timestamp: string;
|
|
61
|
+
description: string;
|
|
62
|
+
device_id: number | null;
|
|
63
|
+
id: number;
|
|
64
|
+
image: string | null;
|
|
65
|
+
is_serviceable: boolean;
|
|
66
|
+
part_id: number | null;
|
|
67
|
+
remediation_completed_at: string | null;
|
|
68
|
+
remediation_completed_user_id: string | null;
|
|
69
|
+
remediation_notes: string | null;
|
|
70
|
+
session_incident_id: number | null;
|
|
71
|
+
updated_at: string | null;
|
|
72
|
+
updated_by_user_id: string | null;
|
|
73
|
+
} | null>>;
|
|
74
|
+
export declare function server_create_maintenance_request(row: MaintenanceRequestInsert): Promise<import("../types").IWebResponseCompatible<{
|
|
75
|
+
created_at: string;
|
|
76
|
+
creator_user_id: string | null;
|
|
77
|
+
defect_timestamp: string;
|
|
78
|
+
description: string;
|
|
79
|
+
device_id: number | null;
|
|
80
|
+
id: number;
|
|
81
|
+
image: string | null;
|
|
82
|
+
is_serviceable: boolean;
|
|
83
|
+
part_id: number | null;
|
|
84
|
+
remediation_completed_at: string | null;
|
|
85
|
+
remediation_completed_user_id: string | null;
|
|
86
|
+
remediation_notes: string | null;
|
|
87
|
+
session_incident_id: number | null;
|
|
88
|
+
updated_at: string | null;
|
|
89
|
+
updated_by_user_id: string | null;
|
|
90
|
+
} | null>>;
|
|
91
|
+
export declare function server_update_maintenance_request(request_id: number, patch: MaintenanceRequestUpdate): Promise<import("../types").IWebResponseCompatible<{
|
|
92
|
+
created_at: string;
|
|
93
|
+
creator_user_id: string | null;
|
|
94
|
+
defect_timestamp: string;
|
|
95
|
+
description: string;
|
|
96
|
+
device_id: number | null;
|
|
97
|
+
id: number;
|
|
98
|
+
image: string | null;
|
|
99
|
+
is_serviceable: boolean;
|
|
100
|
+
part_id: number | null;
|
|
101
|
+
remediation_completed_at: string | null;
|
|
102
|
+
remediation_completed_user_id: string | null;
|
|
103
|
+
remediation_notes: string | null;
|
|
104
|
+
session_incident_id: number | null;
|
|
105
|
+
updated_at: string | null;
|
|
106
|
+
updated_by_user_id: string | null;
|
|
107
|
+
} | null>>;
|
|
108
|
+
export declare function server_delete_maintenance_request(request_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
109
|
+
created_at: string;
|
|
110
|
+
creator_user_id: string | null;
|
|
111
|
+
defect_timestamp: string;
|
|
112
|
+
description: string;
|
|
113
|
+
device_id: number | null;
|
|
114
|
+
id: number;
|
|
115
|
+
image: string | null;
|
|
116
|
+
is_serviceable: boolean;
|
|
117
|
+
part_id: number | null;
|
|
118
|
+
remediation_completed_at: string | null;
|
|
119
|
+
remediation_completed_user_id: string | null;
|
|
120
|
+
remediation_notes: string | null;
|
|
121
|
+
session_incident_id: number | null;
|
|
122
|
+
updated_at: string | null;
|
|
123
|
+
updated_by_user_id: string | null;
|
|
124
|
+
} | null>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { newServerClient } from "../supabase/server";
|
|
2
|
+
import { create_maintenance_request, delete_maintenance_request, get_maintenance_request_by_id, get_maintenance_requests_by_device_id, get_maintenance_requests_by_herd_id, get_maintenance_requests_by_part_id, get_maintenance_requests_count_by_herd_id, update_maintenance_request, } from "./maintenance_requests";
|
|
3
|
+
export async function server_get_maintenance_requests_by_device_id(device_id) {
|
|
4
|
+
const client = await newServerClient();
|
|
5
|
+
return get_maintenance_requests_by_device_id(client, device_id);
|
|
6
|
+
}
|
|
7
|
+
export async function server_get_maintenance_requests_by_part_id(part_id) {
|
|
8
|
+
const client = await newServerClient();
|
|
9
|
+
return get_maintenance_requests_by_part_id(client, part_id);
|
|
10
|
+
}
|
|
11
|
+
export async function server_get_maintenance_requests_by_herd_id(herd_id, options) {
|
|
12
|
+
const client = await newServerClient();
|
|
13
|
+
return get_maintenance_requests_by_herd_id(client, herd_id, options);
|
|
14
|
+
}
|
|
15
|
+
export async function server_get_maintenance_requests_count_by_herd_id(herd_id) {
|
|
16
|
+
const client = await newServerClient();
|
|
17
|
+
return get_maintenance_requests_count_by_herd_id(client, herd_id);
|
|
18
|
+
}
|
|
19
|
+
export async function server_get_maintenance_request_by_id(request_id) {
|
|
20
|
+
const client = await newServerClient();
|
|
21
|
+
return get_maintenance_request_by_id(client, request_id);
|
|
22
|
+
}
|
|
23
|
+
export async function server_create_maintenance_request(row) {
|
|
24
|
+
const client = await newServerClient();
|
|
25
|
+
return create_maintenance_request(client, row);
|
|
26
|
+
}
|
|
27
|
+
export async function server_update_maintenance_request(request_id, patch) {
|
|
28
|
+
const client = await newServerClient();
|
|
29
|
+
return update_maintenance_request(client, request_id, patch);
|
|
30
|
+
}
|
|
31
|
+
export async function server_delete_maintenance_request(request_id) {
|
|
32
|
+
const client = await newServerClient();
|
|
33
|
+
return delete_maintenance_request(client, request_id);
|
|
34
|
+
}
|
|
@@ -1,52 +1,14 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_manufacturer_query, get_manufacturer_by_id_query, get_manufacturers_query, update_manufacturer_query, } from "./manufacturers.queries";
|
|
4
3
|
export async function server_get_manufacturers(options) {
|
|
5
|
-
|
|
6
|
-
let query = supabase.from("manufacturers").select("*").order("name");
|
|
7
|
-
if (!options?.include_inactive) {
|
|
8
|
-
query = query.eq("lifecycle", "active");
|
|
9
|
-
}
|
|
10
|
-
const { data, error } = await query;
|
|
11
|
-
if (error) {
|
|
12
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
13
|
-
}
|
|
14
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
4
|
+
return get_manufacturers_query(await newServerClient(), options);
|
|
15
5
|
}
|
|
16
6
|
export async function server_get_manufacturer_by_id(manufacturer_id) {
|
|
17
|
-
|
|
18
|
-
const { data, error } = await supabase
|
|
19
|
-
.from("manufacturers")
|
|
20
|
-
.select("*")
|
|
21
|
-
.eq("id", manufacturer_id)
|
|
22
|
-
.maybeSingle();
|
|
23
|
-
if (error) {
|
|
24
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
25
|
-
}
|
|
26
|
-
return IWebResponse.success(data).to_compatible();
|
|
7
|
+
return get_manufacturer_by_id_query(await newServerClient(), manufacturer_id);
|
|
27
8
|
}
|
|
28
9
|
export async function server_create_manufacturer(row) {
|
|
29
|
-
|
|
30
|
-
const { data, error } = await supabase
|
|
31
|
-
.from("manufacturers")
|
|
32
|
-
.insert(row)
|
|
33
|
-
.select("*")
|
|
34
|
-
.single();
|
|
35
|
-
if (error) {
|
|
36
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
37
|
-
}
|
|
38
|
-
return IWebResponse.success(data).to_compatible();
|
|
10
|
+
return create_manufacturer_query(await newServerClient(), row);
|
|
39
11
|
}
|
|
40
12
|
export async function server_update_manufacturer(manufacturer_id, updates) {
|
|
41
|
-
|
|
42
|
-
const { data, error } = await supabase
|
|
43
|
-
.from("manufacturers")
|
|
44
|
-
.update(updates)
|
|
45
|
-
.eq("id", manufacturer_id)
|
|
46
|
-
.select("*")
|
|
47
|
-
.single();
|
|
48
|
-
if (error) {
|
|
49
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
50
|
-
}
|
|
51
|
-
return IWebResponse.success(data).to_compatible();
|
|
13
|
+
return update_manufacturer_query(await newServerClient(), manufacturer_id, updates);
|
|
52
14
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IManufacturer, ManufacturerInsert, ManufacturerUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_manufacturers_query(client: SupabaseClient<Database>, options?: {
|
|
6
|
+
include_inactive?: boolean;
|
|
7
|
+
}): Promise<IWebResponseCompatible<IManufacturer[]>>;
|
|
8
|
+
export declare function get_manufacturer_by_id_query(client: SupabaseClient<Database>, manufacturer_id: number): Promise<IWebResponseCompatible<IManufacturer | null>>;
|
|
9
|
+
export declare function create_manufacturer_query(client: SupabaseClient<Database>, row: ManufacturerInsert): Promise<IWebResponseCompatible<IManufacturer | null>>;
|
|
10
|
+
export declare function update_manufacturer_query(client: SupabaseClient<Database>, manufacturer_id: number, updates: ManufacturerUpdate): Promise<IWebResponseCompatible<IManufacturer | null>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_manufacturers_query(client, options) {
|
|
3
|
+
let query = client.from("manufacturers").select("*").order("name");
|
|
4
|
+
if (!options?.include_inactive) {
|
|
5
|
+
query = query.eq("lifecycle", "active");
|
|
6
|
+
}
|
|
7
|
+
const { data, error } = await query;
|
|
8
|
+
if (error) {
|
|
9
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
10
|
+
}
|
|
11
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
12
|
+
}
|
|
13
|
+
export async function get_manufacturer_by_id_query(client, manufacturer_id) {
|
|
14
|
+
const { data, error } = await client
|
|
15
|
+
.from("manufacturers")
|
|
16
|
+
.select("*")
|
|
17
|
+
.eq("id", manufacturer_id)
|
|
18
|
+
.maybeSingle();
|
|
19
|
+
if (error) {
|
|
20
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
21
|
+
}
|
|
22
|
+
return IWebResponse.success(data).to_compatible();
|
|
23
|
+
}
|
|
24
|
+
export async function create_manufacturer_query(client, row) {
|
|
25
|
+
const { data, error } = await client
|
|
26
|
+
.from("manufacturers")
|
|
27
|
+
.insert(row)
|
|
28
|
+
.select("*")
|
|
29
|
+
.single();
|
|
30
|
+
if (error) {
|
|
31
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
32
|
+
}
|
|
33
|
+
return IWebResponse.success(data).to_compatible();
|
|
34
|
+
}
|
|
35
|
+
export async function update_manufacturer_query(client, manufacturer_id, updates) {
|
|
36
|
+
const { data, error } = await client
|
|
37
|
+
.from("manufacturers")
|
|
38
|
+
.update(updates)
|
|
39
|
+
.eq("id", manufacturer_id)
|
|
40
|
+
.select("*")
|
|
41
|
+
.single();
|
|
42
|
+
if (error) {
|
|
43
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
44
|
+
}
|
|
45
|
+
return IWebResponse.success(data).to_compatible();
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import type { IArtifact, IArtifactWithMediaUrl } from "../types/db";
|
|
3
|
+
import type { Database } from "../types/supabase";
|
|
4
|
+
type EventWithStoragePath = {
|
|
5
|
+
file_path?: string | null;
|
|
6
|
+
media_url?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function createSignedUrlMap(client: SupabaseClient<Database>, paths: Iterable<string | null | undefined>): Promise<Map<string, string | null>>;
|
|
9
|
+
export declare function addEventMediaUrls<T extends EventWithStoragePath>(client: SupabaseClient<Database>, events: T[]): Promise<Array<T & {
|
|
10
|
+
media_url: string | null;
|
|
11
|
+
}>>;
|
|
12
|
+
export declare function addArtifactMediaUrls(client: SupabaseClient<Database>, artifacts: IArtifact[]): Promise<IArtifactWithMediaUrl[]>;
|
|
13
|
+
export {};
|