@adventurelabs/scout-core 1.5.5 → 2.0.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/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 +76 -0
- package/dist/client/index.js +83 -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/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/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 +75 -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 +178 -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 +1 -89
- 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 +78 -0
- package/dist/server/index.js +80 -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 +47 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/supabase.d.ts +512 -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,6 +1,6 @@
|
|
|
1
1
|
import { IWebResponse } from "../types/requests";
|
|
2
|
-
export async function
|
|
3
|
-
const { data, error } = await
|
|
2
|
+
export async function create_herd_invitation_query(client, herd_id, email, herd_role_id, expires_at) {
|
|
3
|
+
const { data, error } = await client.rpc("create_herd_invitation", {
|
|
4
4
|
p_herd_id: herd_id,
|
|
5
5
|
p_email: email,
|
|
6
6
|
p_herd_role_id: herd_role_id,
|
|
@@ -11,25 +11,25 @@ export async function createHerdInvitationWithClient(supabase, herd_id, email, h
|
|
|
11
11
|
}
|
|
12
12
|
return IWebResponse.success(data).to_compatible();
|
|
13
13
|
}
|
|
14
|
-
export async function
|
|
14
|
+
export async function accept_herd_invitations_for_current_user_query(client, invitation_ids) {
|
|
15
15
|
if (invitation_ids.length === 0) {
|
|
16
16
|
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
17
17
|
}
|
|
18
|
-
const { data, error } = await
|
|
18
|
+
const { data, error } = await client.rpc("accept_herd_invitations_for_current_user", { p_invitation_ids: invitation_ids });
|
|
19
19
|
if (error) {
|
|
20
20
|
return IWebResponse.error(error.message).to_compatible();
|
|
21
21
|
}
|
|
22
22
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
23
23
|
}
|
|
24
|
-
export async function
|
|
25
|
-
const { data, error } = await
|
|
24
|
+
export async function get_herd_invitations_for_current_user_query(client) {
|
|
25
|
+
const { data, error } = await client.rpc("get_herd_invitations_for_current_user");
|
|
26
26
|
if (error) {
|
|
27
27
|
return IWebResponse.error(error.message).to_compatible();
|
|
28
28
|
}
|
|
29
29
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
30
30
|
}
|
|
31
|
-
export async function
|
|
32
|
-
const { data, error } = await
|
|
31
|
+
export async function get_herd_invitations_by_herd_query(client, herd_id) {
|
|
32
|
+
const { data, error } = await client
|
|
33
33
|
.from("herd_invitations")
|
|
34
34
|
.select("*")
|
|
35
35
|
.eq("herd_id", herd_id)
|
|
@@ -39,21 +39,21 @@ export async function getHerdInvitationsByHerdWithClient(supabase, herd_id) {
|
|
|
39
39
|
}
|
|
40
40
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
41
41
|
}
|
|
42
|
-
export async function
|
|
42
|
+
export async function reject_herd_invitations_for_current_user_query(client, invitation_ids) {
|
|
43
43
|
if (invitation_ids.length === 0) {
|
|
44
44
|
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
45
45
|
}
|
|
46
|
-
const { data, error } = await
|
|
46
|
+
const { data, error } = await client.rpc("reject_herd_invitations_for_current_user", { p_invitation_ids: invitation_ids });
|
|
47
47
|
if (error) {
|
|
48
48
|
return IWebResponse.error(error.message).to_compatible();
|
|
49
49
|
}
|
|
50
50
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
51
51
|
}
|
|
52
|
-
export async function
|
|
52
|
+
export async function revoke_herd_invitations_query(client, invitation_ids) {
|
|
53
53
|
if (invitation_ids.length === 0) {
|
|
54
54
|
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
55
55
|
}
|
|
56
|
-
const { data, error } = await
|
|
56
|
+
const { data, error } = await client.rpc("revoke_herd_invitations", {
|
|
57
57
|
p_invitation_ids: invitation_ids,
|
|
58
58
|
});
|
|
59
59
|
if (error) {
|
package/dist/helpers/issuers.js
CHANGED
|
@@ -1,63 +1,17 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_issuer_query, get_issuer_by_id_query, get_issuers_by_localization_query, get_issuers_query, update_issuer_query, } from "./issuers.queries";
|
|
4
3
|
export async function server_get_issuers() {
|
|
5
|
-
|
|
6
|
-
const { data, error } = await supabase
|
|
7
|
-
.from("issuers")
|
|
8
|
-
.select("*")
|
|
9
|
-
.order("name");
|
|
10
|
-
if (error) {
|
|
11
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
12
|
-
}
|
|
13
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
4
|
+
return get_issuers_query(await newServerClient());
|
|
14
5
|
}
|
|
15
6
|
export async function server_get_issuer_by_id(issuer_id) {
|
|
16
|
-
|
|
17
|
-
const { data, error } = await supabase
|
|
18
|
-
.from("issuers")
|
|
19
|
-
.select("*")
|
|
20
|
-
.eq("id", issuer_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_issuer_by_id_query(await newServerClient(), issuer_id);
|
|
26
8
|
}
|
|
27
9
|
export async function server_get_issuers_by_localization(localization_id) {
|
|
28
|
-
|
|
29
|
-
const { data, error } = await supabase
|
|
30
|
-
.from("issuers")
|
|
31
|
-
.select("*")
|
|
32
|
-
.eq("localization_id", localization_id)
|
|
33
|
-
.order("name");
|
|
34
|
-
if (error) {
|
|
35
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
36
|
-
}
|
|
37
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
10
|
+
return get_issuers_by_localization_query(await newServerClient(), localization_id);
|
|
38
11
|
}
|
|
39
12
|
export async function server_create_issuer(row) {
|
|
40
|
-
|
|
41
|
-
const { data, error } = await supabase
|
|
42
|
-
.from("issuers")
|
|
43
|
-
.insert(row)
|
|
44
|
-
.select("*")
|
|
45
|
-
.single();
|
|
46
|
-
if (error) {
|
|
47
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
48
|
-
}
|
|
49
|
-
return IWebResponse.success(data).to_compatible();
|
|
13
|
+
return create_issuer_query(await newServerClient(), row);
|
|
50
14
|
}
|
|
51
15
|
export async function server_update_issuer(issuer_id, updates) {
|
|
52
|
-
|
|
53
|
-
const { data, error } = await supabase
|
|
54
|
-
.from("issuers")
|
|
55
|
-
.update(updates)
|
|
56
|
-
.eq("id", issuer_id)
|
|
57
|
-
.select("*")
|
|
58
|
-
.single();
|
|
59
|
-
if (error) {
|
|
60
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
61
|
-
}
|
|
62
|
-
return IWebResponse.success(data).to_compatible();
|
|
16
|
+
return update_issuer_query(await newServerClient(), issuer_id, updates);
|
|
63
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IIssuer, IssuerInsert, IssuerUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_issuers_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IIssuer[]>>;
|
|
6
|
+
export declare function get_issuer_by_id_query(client: SupabaseClient<Database>, issuer_id: number): Promise<IWebResponseCompatible<IIssuer | null>>;
|
|
7
|
+
export declare function get_issuers_by_localization_query(client: SupabaseClient<Database>, localization_id: number): Promise<IWebResponseCompatible<IIssuer[]>>;
|
|
8
|
+
export declare function create_issuer_query(client: SupabaseClient<Database>, row: IssuerInsert): Promise<IWebResponseCompatible<IIssuer | null>>;
|
|
9
|
+
export declare function update_issuer_query(client: SupabaseClient<Database>, issuer_id: number, updates: IssuerUpdate): Promise<IWebResponseCompatible<IIssuer | null>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_issuers_query(client) {
|
|
3
|
+
const { data, error } = await client.from("issuers").select("*").order("name");
|
|
4
|
+
if (error) {
|
|
5
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
6
|
+
}
|
|
7
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
8
|
+
}
|
|
9
|
+
export async function get_issuer_by_id_query(client, issuer_id) {
|
|
10
|
+
const { data, error } = await client
|
|
11
|
+
.from("issuers")
|
|
12
|
+
.select("*")
|
|
13
|
+
.eq("id", issuer_id)
|
|
14
|
+
.maybeSingle();
|
|
15
|
+
if (error) {
|
|
16
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
17
|
+
}
|
|
18
|
+
return IWebResponse.success(data).to_compatible();
|
|
19
|
+
}
|
|
20
|
+
export async function get_issuers_by_localization_query(client, localization_id) {
|
|
21
|
+
const { data, error } = await client
|
|
22
|
+
.from("issuers")
|
|
23
|
+
.select("*")
|
|
24
|
+
.eq("localization_id", localization_id)
|
|
25
|
+
.order("name");
|
|
26
|
+
if (error) {
|
|
27
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
28
|
+
}
|
|
29
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
30
|
+
}
|
|
31
|
+
export async function create_issuer_query(client, row) {
|
|
32
|
+
const { data, error } = await client
|
|
33
|
+
.from("issuers")
|
|
34
|
+
.insert(row)
|
|
35
|
+
.select("*")
|
|
36
|
+
.single();
|
|
37
|
+
if (error) {
|
|
38
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
39
|
+
}
|
|
40
|
+
return IWebResponse.success(data).to_compatible();
|
|
41
|
+
}
|
|
42
|
+
export async function update_issuer_query(client, issuer_id, updates) {
|
|
43
|
+
const { data, error } = await client
|
|
44
|
+
.from("issuers")
|
|
45
|
+
.update(updates)
|
|
46
|
+
.eq("id", issuer_id)
|
|
47
|
+
.select("*")
|
|
48
|
+
.single();
|
|
49
|
+
if (error) {
|
|
50
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
51
|
+
}
|
|
52
|
+
return IWebResponse.success(data).to_compatible();
|
|
53
|
+
}
|
package/dist/helpers/layers.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
4
|
-
import { get_layers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
5
|
-
// function that fetches the layers from our db given a herd id
|
|
2
|
+
import { get_layers_by_herd_ids_query, get_layers_by_herd_query, } from "./layers.queries";
|
|
6
3
|
export async function server_get_layers_by_herd(herd_id) {
|
|
7
|
-
|
|
8
|
-
const { data, error } = await supabase
|
|
9
|
-
.from("layers")
|
|
10
|
-
.select("*")
|
|
11
|
-
.eq("herd_id", herd_id);
|
|
12
|
-
if (error) {
|
|
13
|
-
return {
|
|
14
|
-
status: EnumWebResponse.ERROR,
|
|
15
|
-
msg: error.message,
|
|
16
|
-
data: null,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return IWebResponse.success(data).to_compatible();
|
|
21
|
-
}
|
|
4
|
+
return get_layers_by_herd_query(await newServerClient(), herd_id);
|
|
22
5
|
}
|
|
23
|
-
// Fetches layers for many herds in one query, grouped by herd_id.
|
|
24
6
|
export async function server_get_layers_by_herd_ids(herd_ids) {
|
|
25
7
|
return get_layers_by_herd_ids_query(await newServerClient(), herd_ids);
|
|
26
8
|
}
|
|
@@ -2,4 +2,5 @@ import { SupabaseClient } from "@supabase/supabase-js";
|
|
|
2
2
|
import { ILayer } from "../types/db";
|
|
3
3
|
import { Database } from "../types/supabase";
|
|
4
4
|
import { IWebResponseCompatible } from "../types/requests";
|
|
5
|
-
export
|
|
5
|
+
export { get_layers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
6
|
+
export declare function get_layers_by_herd_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<ILayer[]>>;
|
|
@@ -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,178 @@
|
|
|
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
|
+
contact_type_id: number | null;
|
|
153
|
+
created_at: string;
|
|
154
|
+
created_by: string | null;
|
|
155
|
+
email: string | null;
|
|
156
|
+
herd_id: number;
|
|
157
|
+
id: number;
|
|
158
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
159
|
+
lifecycle_changed_at: string;
|
|
160
|
+
lifecycle_changed_by: string | null;
|
|
161
|
+
lifecycle_reason: string | null;
|
|
162
|
+
name: string;
|
|
163
|
+
notes: string | null;
|
|
164
|
+
phone: string | null;
|
|
165
|
+
radio_frequency: string | null;
|
|
166
|
+
updated_at: string;
|
|
167
|
+
updated_by: string | null;
|
|
168
|
+
} | null>>;
|
|
169
|
+
export declare function server_update_herd_allowed_domain_lifecycle(domain_id: number, lifecycle: EntityLifecycle, options?: LifecycleUpdateOptions): Promise<import("../types").IWebResponseCompatible<{
|
|
170
|
+
created_at: string;
|
|
171
|
+
domain: string;
|
|
172
|
+
herd_id: number;
|
|
173
|
+
id: number;
|
|
174
|
+
lifecycle: import("../types").Database["public"]["Enums"]["entity_lifecycle"];
|
|
175
|
+
lifecycle_changed_at: string;
|
|
176
|
+
lifecycle_changed_by: string | null;
|
|
177
|
+
lifecycle_reason: string | null;
|
|
178
|
+
} | 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
|
+
}
|