@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IAbility, IHerdRole, IHerdRoleAbilityRow, IHerdRoleWithAbilities, IPlatformDefaultRoleAbilitiesGroup } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function list_abilities_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
6
|
+
export declare function get_abilities_by_ids_query(client: SupabaseClient<Database>, ids: number[]): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
7
|
+
export declare function get_herd_roles_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRole[]>>;
|
|
8
|
+
export declare function get_herd_roles_with_abilities_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRoleWithAbilities[]>>;
|
|
9
|
+
export declare function get_herd_role_by_system_name_query(client: SupabaseClient<Database>, herd_id: number, system_name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
10
|
+
export declare function create_herd_role_query(client: SupabaseClient<Database>, herd_id: number, system_name: string, name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
11
|
+
export declare function update_herd_role_query(client: SupabaseClient<Database>, herd_role_id: number, patch: {
|
|
12
|
+
name?: string;
|
|
13
|
+
}): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
14
|
+
export declare function delete_herd_role_query(client: SupabaseClient<Database>, herd_role_id: number): Promise<IWebResponseCompatible<null>>;
|
|
15
|
+
export declare function set_herd_role_abilities_query(client: SupabaseClient<Database>, herd_role_id: number, ability_ids: number[]): Promise<IWebResponseCompatible<IHerdRoleAbilityRow[]>>;
|
|
16
|
+
export declare function get_platform_default_role_abilities_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IPlatformDefaultRoleAbilitiesGroup[]>>;
|
|
17
|
+
export declare function set_platform_default_role_abilities_query(client: SupabaseClient<Database>, system_name: string, ability_keys: string[]): Promise<IWebResponseCompatible<null>>;
|
|
18
|
+
export declare function reset_herd_default_role_abilities_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<null>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IWebResponse } from "../types/requests";
|
|
2
|
-
export async function
|
|
3
|
-
const { data, error } = await
|
|
2
|
+
export async function list_abilities_query(client) {
|
|
3
|
+
const { data, error } = await client
|
|
4
4
|
.from("abilities")
|
|
5
5
|
.select("*")
|
|
6
6
|
.order("key", { ascending: true });
|
|
@@ -9,11 +9,11 @@ export async function listAbilitiesWithClient(supabase) {
|
|
|
9
9
|
}
|
|
10
10
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
11
11
|
}
|
|
12
|
-
export async function
|
|
12
|
+
export async function get_abilities_by_ids_query(client, ids) {
|
|
13
13
|
if (ids.length === 0) {
|
|
14
14
|
return IWebResponse.success([]).to_compatible();
|
|
15
15
|
}
|
|
16
|
-
const { data, error } = await
|
|
16
|
+
const { data, error } = await client
|
|
17
17
|
.from("abilities")
|
|
18
18
|
.select("*")
|
|
19
19
|
.in("id", ids)
|
|
@@ -23,8 +23,8 @@ export async function getAbilitiesByIdsWithClient(supabase, ids) {
|
|
|
23
23
|
}
|
|
24
24
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
25
25
|
}
|
|
26
|
-
export async function
|
|
27
|
-
const { data, error } = await
|
|
26
|
+
export async function get_herd_roles_query(client, herd_id) {
|
|
27
|
+
const { data, error } = await client
|
|
28
28
|
.from("herd_roles")
|
|
29
29
|
.select("*")
|
|
30
30
|
.eq("herd_id", herd_id)
|
|
@@ -34,8 +34,8 @@ export async function getHerdRolesWithClient(supabase, herd_id) {
|
|
|
34
34
|
}
|
|
35
35
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
36
36
|
}
|
|
37
|
-
export async function
|
|
38
|
-
const { data, error } = await
|
|
37
|
+
export async function get_herd_roles_with_abilities_query(client, herd_id) {
|
|
38
|
+
const { data, error } = await client
|
|
39
39
|
.from("herd_roles")
|
|
40
40
|
.select(`
|
|
41
41
|
*,
|
|
@@ -56,15 +56,15 @@ export async function getHerdRolesWithAbilitiesWithClient(supabase, herd_id) {
|
|
|
56
56
|
return {
|
|
57
57
|
...role,
|
|
58
58
|
abilities: links
|
|
59
|
-
.map((
|
|
60
|
-
.filter((
|
|
61
|
-
ability_ids: links.map((
|
|
59
|
+
.map((link) => link.abilities)
|
|
60
|
+
.filter((ability) => ability != null),
|
|
61
|
+
ability_ids: links.map((link) => link.ability_id),
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
64
|
return IWebResponse.success(rows).to_compatible();
|
|
65
65
|
}
|
|
66
|
-
export async function
|
|
67
|
-
const { data, error } = await
|
|
66
|
+
export async function get_herd_role_by_system_name_query(client, herd_id, system_name) {
|
|
67
|
+
const { data, error } = await client
|
|
68
68
|
.from("herd_roles")
|
|
69
69
|
.select("*")
|
|
70
70
|
.eq("herd_id", herd_id)
|
|
@@ -75,8 +75,8 @@ export async function getHerdRoleBySystemNameWithClient(supabase, herd_id, syste
|
|
|
75
75
|
}
|
|
76
76
|
return IWebResponse.success(data).to_compatible();
|
|
77
77
|
}
|
|
78
|
-
export async function
|
|
79
|
-
const { data, error } = await
|
|
78
|
+
export async function create_herd_role_query(client, herd_id, system_name, name) {
|
|
79
|
+
const { data, error } = await client
|
|
80
80
|
.from("herd_roles")
|
|
81
81
|
.insert({ herd_id, system_name, name, is_system: false })
|
|
82
82
|
.select("*")
|
|
@@ -86,8 +86,8 @@ export async function createHerdRoleWithClient(supabase, herd_id, system_name, n
|
|
|
86
86
|
}
|
|
87
87
|
return IWebResponse.success(data).to_compatible();
|
|
88
88
|
}
|
|
89
|
-
export async function
|
|
90
|
-
const { data, error } = await
|
|
89
|
+
export async function update_herd_role_query(client, herd_role_id, patch) {
|
|
90
|
+
const { data, error } = await client
|
|
91
91
|
.from("herd_roles")
|
|
92
92
|
.update(patch)
|
|
93
93
|
.eq("id", herd_role_id)
|
|
@@ -98,8 +98,8 @@ export async function updateHerdRoleWithClient(supabase, herd_role_id, patch) {
|
|
|
98
98
|
}
|
|
99
99
|
return IWebResponse.success(data).to_compatible();
|
|
100
100
|
}
|
|
101
|
-
export async function
|
|
102
|
-
const { error } = await
|
|
101
|
+
export async function delete_herd_role_query(client, herd_role_id) {
|
|
102
|
+
const { error } = await client
|
|
103
103
|
.from("herd_roles")
|
|
104
104
|
.delete()
|
|
105
105
|
.eq("id", herd_role_id);
|
|
@@ -108,8 +108,8 @@ export async function deleteHerdRoleWithClient(supabase, herd_role_id) {
|
|
|
108
108
|
}
|
|
109
109
|
return IWebResponse.success(null).to_compatible();
|
|
110
110
|
}
|
|
111
|
-
export async function
|
|
112
|
-
const { error: deleteError } = await
|
|
111
|
+
export async function set_herd_role_abilities_query(client, herd_role_id, ability_ids) {
|
|
112
|
+
const { error: deleteError } = await client
|
|
113
113
|
.from("herd_role_abilities")
|
|
114
114
|
.delete()
|
|
115
115
|
.eq("herd_role_id", herd_role_id);
|
|
@@ -119,7 +119,7 @@ export async function setHerdRoleAbilitiesWithClient(supabase, herd_role_id, abi
|
|
|
119
119
|
if (ability_ids.length === 0) {
|
|
120
120
|
return IWebResponse.success([]).to_compatible();
|
|
121
121
|
}
|
|
122
|
-
const { data, error } = await
|
|
122
|
+
const { data, error } = await client
|
|
123
123
|
.from("herd_role_abilities")
|
|
124
124
|
.insert(ability_ids.map((ability_id) => ({ herd_role_id, ability_id })))
|
|
125
125
|
.select("*");
|
|
@@ -128,8 +128,8 @@ export async function setHerdRoleAbilitiesWithClient(supabase, herd_role_id, abi
|
|
|
128
128
|
}
|
|
129
129
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
130
130
|
}
|
|
131
|
-
export async function
|
|
132
|
-
const { data, error } = await
|
|
131
|
+
export async function get_platform_default_role_abilities_query(client) {
|
|
132
|
+
const { data, error } = await client.rpc("get_platform_default_role_abilities");
|
|
133
133
|
if (error) {
|
|
134
134
|
return IWebResponse.error(error.message).to_compatible();
|
|
135
135
|
}
|
|
@@ -138,8 +138,8 @@ export async function getPlatformDefaultRoleAbilitiesWithClient(supabase) {
|
|
|
138
138
|
: [];
|
|
139
139
|
return IWebResponse.success(groups).to_compatible();
|
|
140
140
|
}
|
|
141
|
-
export async function
|
|
142
|
-
const { error } = await
|
|
141
|
+
export async function set_platform_default_role_abilities_query(client, system_name, ability_keys) {
|
|
142
|
+
const { error } = await client.rpc("set_platform_default_role_abilities", {
|
|
143
143
|
p_system_name: system_name,
|
|
144
144
|
p_ability_keys: ability_keys,
|
|
145
145
|
});
|
|
@@ -148,8 +148,8 @@ export async function setPlatformDefaultRoleAbilitiesWithClient(supabase, system
|
|
|
148
148
|
}
|
|
149
149
|
return IWebResponse.success(null).to_compatible();
|
|
150
150
|
}
|
|
151
|
-
export async function
|
|
152
|
-
const { error } = await
|
|
151
|
+
export async function reset_herd_default_role_abilities_query(client, herd_id) {
|
|
152
|
+
const { error } = await client.rpc("reset_herd_default_role_abilities", {
|
|
153
153
|
p_herd_id: herd_id,
|
|
154
154
|
});
|
|
155
155
|
if (error) {
|
package/dist/helpers/herds.js
CHANGED
|
@@ -1,62 +1,20 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
4
|
-
import { get_herds_with_location_query } from "./herds.queries";
|
|
2
|
+
import { create_herd_query, delete_herd_query, get_herd_by_slug_query, get_herds_query, get_herds_with_location_query, } from "./herds.queries";
|
|
5
3
|
import { load_herd_modules_query } from "./herd_modules.queries";
|
|
6
4
|
export async function get_herds() {
|
|
7
|
-
|
|
8
|
-
const { data: herds } = await supabase.from("herds").select();
|
|
9
|
-
if (!herds) {
|
|
10
|
-
return {
|
|
11
|
-
status: EnumWebResponse.ERROR,
|
|
12
|
-
msg: "No herds found",
|
|
13
|
-
data: null,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return IWebResponse.success(herds).to_compatible();
|
|
5
|
+
return get_herds_query(await newServerClient());
|
|
17
6
|
}
|
|
18
7
|
export async function get_herds_with_location() {
|
|
19
8
|
return get_herds_with_location_query(await newServerClient());
|
|
20
9
|
}
|
|
21
10
|
export async function get_herd_by_slug(slug) {
|
|
22
|
-
|
|
23
|
-
const { data: herds } = await supabase
|
|
24
|
-
.from("herds")
|
|
25
|
-
.select()
|
|
26
|
-
.eq("slug", slug)
|
|
27
|
-
.limit(1);
|
|
28
|
-
if (!herds) {
|
|
29
|
-
return {
|
|
30
|
-
status: EnumWebResponse.ERROR,
|
|
31
|
-
msg: "No herds found",
|
|
32
|
-
data: null,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return IWebResponse.success(herds[0]);
|
|
11
|
+
return get_herd_by_slug_query(await newServerClient(), slug);
|
|
36
12
|
}
|
|
37
13
|
export async function deleteHerd(herd_id) {
|
|
38
|
-
|
|
39
|
-
const { error } = await supabase.from("herds").delete().match({ id: herd_id });
|
|
40
|
-
if (error) {
|
|
41
|
-
return {
|
|
42
|
-
status: EnumWebResponse.ERROR,
|
|
43
|
-
msg: error.message,
|
|
44
|
-
data: null,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return IWebResponse.success(true).to_compatible();
|
|
14
|
+
return delete_herd_query(await newServerClient(), herd_id);
|
|
48
15
|
}
|
|
49
16
|
export async function createHerd(newHerd) {
|
|
50
|
-
|
|
51
|
-
const { error } = await supabase.from("herds").insert([newHerd]);
|
|
52
|
-
if (error) {
|
|
53
|
-
return {
|
|
54
|
-
status: EnumWebResponse.ERROR,
|
|
55
|
-
msg: error.message,
|
|
56
|
-
data: null,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return IWebResponse.success(true).to_compatible();
|
|
17
|
+
return create_herd_query(await newServerClient(), newHerd);
|
|
60
18
|
}
|
|
61
19
|
export async function server_load_herd_modules() {
|
|
62
20
|
return load_herd_modules_query(await newServerClient());
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IHerdPrettyLocation } from "../types/db";
|
|
2
|
+
import { IHerd, IHerdPrettyLocation } from "../types/db";
|
|
3
3
|
import { Database } from "../types/supabase";
|
|
4
4
|
import { IWebResponseCompatible } from "../types/requests";
|
|
5
|
+
export declare function get_herds_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerd[]>>;
|
|
5
6
|
export declare function get_herds_with_location_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdPrettyLocation[]>>;
|
|
7
|
+
export declare function get_herd_by_slug_query(client: SupabaseClient<Database>, slug: string): Promise<IWebResponseCompatible<IHerd>>;
|
|
8
|
+
export declare function delete_herd_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<boolean>>;
|
|
9
|
+
export declare function create_herd_query(client: SupabaseClient<Database>, newHerd: Omit<IHerd, "id" | "inserted_at"> & {
|
|
10
|
+
id?: number;
|
|
11
|
+
inserted_at?: string;
|
|
12
|
+
}): Promise<IWebResponseCompatible<boolean>>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_herds_query(client) {
|
|
3
|
+
const { data: herds } = await client.from("herds").select();
|
|
4
|
+
if (!herds) {
|
|
5
|
+
return {
|
|
6
|
+
status: EnumWebResponse.ERROR,
|
|
7
|
+
msg: "No herds found",
|
|
8
|
+
data: null,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return IWebResponse.success(herds).to_compatible();
|
|
12
|
+
}
|
|
2
13
|
export async function get_herds_with_location_query(client) {
|
|
3
14
|
const { data, error } = await client.rpc("get_herds_with_location");
|
|
4
15
|
if (error) {
|
|
@@ -10,3 +21,40 @@ export async function get_herds_with_location_query(client) {
|
|
|
10
21
|
}
|
|
11
22
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
12
23
|
}
|
|
24
|
+
export async function get_herd_by_slug_query(client, slug) {
|
|
25
|
+
const { data: herds } = await client
|
|
26
|
+
.from("herds")
|
|
27
|
+
.select()
|
|
28
|
+
.eq("slug", slug)
|
|
29
|
+
.limit(1);
|
|
30
|
+
if (!herds) {
|
|
31
|
+
return {
|
|
32
|
+
status: EnumWebResponse.ERROR,
|
|
33
|
+
msg: "No herds found",
|
|
34
|
+
data: null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return IWebResponse.success(herds[0]);
|
|
38
|
+
}
|
|
39
|
+
export async function delete_herd_query(client, herd_id) {
|
|
40
|
+
const { error } = await client.from("herds").delete().match({ id: herd_id });
|
|
41
|
+
if (error) {
|
|
42
|
+
return {
|
|
43
|
+
status: EnumWebResponse.ERROR,
|
|
44
|
+
msg: error.message,
|
|
45
|
+
data: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return IWebResponse.success(true).to_compatible();
|
|
49
|
+
}
|
|
50
|
+
export async function create_herd_query(client, newHerd) {
|
|
51
|
+
const { error } = await client.from("herds").insert([newHerd]);
|
|
52
|
+
if (error) {
|
|
53
|
+
return {
|
|
54
|
+
status: EnumWebResponse.ERROR,
|
|
55
|
+
msg: error.message,
|
|
56
|
+
data: null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return IWebResponse.success(true).to_compatible();
|
|
60
|
+
}
|
|
@@ -1,71 +1,20 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { accept_herd_invitations_for_current_user_query, create_herd_invitation_query, get_herd_invitations_by_herd_query, get_herd_invitations_for_current_user_query, reject_herd_invitations_for_current_user_query, revoke_herd_invitations_query, } from "./invitations.queries";
|
|
4
3
|
export async function server_create_herd_invitation(herd_id, email, herd_role_id, expires_at) {
|
|
5
|
-
|
|
6
|
-
const { data, error } = await supabase.rpc("create_herd_invitation", {
|
|
7
|
-
p_herd_id: herd_id,
|
|
8
|
-
p_email: email,
|
|
9
|
-
p_herd_role_id: herd_role_id,
|
|
10
|
-
p_expires_at: expires_at ?? undefined,
|
|
11
|
-
});
|
|
12
|
-
if (error) {
|
|
13
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
14
|
-
}
|
|
15
|
-
return IWebResponse.success(data).to_compatible();
|
|
4
|
+
return create_herd_invitation_query(await newServerClient(), herd_id, email, herd_role_id, expires_at);
|
|
16
5
|
}
|
|
17
6
|
export async function accept_herd_invitations_for_current_user(invitation_ids) {
|
|
18
|
-
|
|
19
|
-
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
20
|
-
}
|
|
21
|
-
const supabase = await newServerClient();
|
|
22
|
-
const { data, error } = await supabase.rpc("accept_herd_invitations_for_current_user", { p_invitation_ids: invitation_ids });
|
|
23
|
-
if (error) {
|
|
24
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
25
|
-
}
|
|
26
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
7
|
+
return accept_herd_invitations_for_current_user_query(await newServerClient(), invitation_ids);
|
|
27
8
|
}
|
|
28
9
|
export async function server_get_herd_invitations_for_current_user() {
|
|
29
|
-
|
|
30
|
-
const { data, error } = await supabase.rpc("get_herd_invitations_for_current_user");
|
|
31
|
-
if (error) {
|
|
32
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
33
|
-
}
|
|
34
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
10
|
+
return get_herd_invitations_for_current_user_query(await newServerClient());
|
|
35
11
|
}
|
|
36
12
|
export async function server_get_herd_invitations_by_herd(herd_id) {
|
|
37
|
-
|
|
38
|
-
const { data, error } = await supabase
|
|
39
|
-
.from("herd_invitations")
|
|
40
|
-
.select("*")
|
|
41
|
-
.eq("herd_id", herd_id)
|
|
42
|
-
.order("created_at", { ascending: false });
|
|
43
|
-
if (error) {
|
|
44
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
45
|
-
}
|
|
46
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
13
|
+
return get_herd_invitations_by_herd_query(await newServerClient(), herd_id);
|
|
47
14
|
}
|
|
48
15
|
export async function reject_herd_invitations_for_current_user(invitation_ids) {
|
|
49
|
-
|
|
50
|
-
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
51
|
-
}
|
|
52
|
-
const supabase = await newServerClient();
|
|
53
|
-
const { data, error } = await supabase.rpc("reject_herd_invitations_for_current_user", { p_invitation_ids: invitation_ids });
|
|
54
|
-
if (error) {
|
|
55
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
56
|
-
}
|
|
57
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
16
|
+
return reject_herd_invitations_for_current_user_query(await newServerClient(), invitation_ids);
|
|
58
17
|
}
|
|
59
18
|
export async function server_revoke_herd_invitations(invitation_ids) {
|
|
60
|
-
|
|
61
|
-
return IWebResponse.error("At least one invitation id is required").to_compatible();
|
|
62
|
-
}
|
|
63
|
-
const supabase = await newServerClient();
|
|
64
|
-
const { data, error } = await supabase.rpc("revoke_herd_invitations", {
|
|
65
|
-
p_invitation_ids: invitation_ids,
|
|
66
|
-
});
|
|
67
|
-
if (error) {
|
|
68
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
69
|
-
}
|
|
70
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
19
|
+
return revoke_herd_invitations_query(await newServerClient(), invitation_ids);
|
|
71
20
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IHerdInvitation, IHerdInvitationWithHerdSlug } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function create_herd_invitation_query(client: SupabaseClient<Database>, herd_id: number, email: string, herd_role_id: number, expires_at?: string | null): Promise<IWebResponseCompatible<IHerdInvitation | null>>;
|
|
6
|
+
export declare function accept_herd_invitations_for_current_user_query(client: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
7
|
+
export declare function get_herd_invitations_for_current_user_query(client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdInvitationWithHerdSlug[]>>;
|
|
8
|
+
export declare function get_herd_invitations_by_herd_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
9
|
+
export declare function reject_herd_invitations_for_current_user_query(client: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
10
|
+
export declare function revoke_herd_invitations_query(client: SupabaseClient<Database>, invitation_ids: number[]): Promise<IWebResponseCompatible<IHerdInvitation[]>>;
|
|
@@ -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[]>>;
|