@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,89 +1,17 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_product_compatibility_query, delete_product_compatibility_query, get_auto_assign_accessory_product_number_query, get_product_compatibilities_query, update_product_compatibility_query, } from "./product_compatibilities.queries";
|
|
4
3
|
export async function server_get_product_compatibilities(primary_product_number, role) {
|
|
5
|
-
|
|
6
|
-
const { data: primary, error: primaryError } = await supabase
|
|
7
|
-
.from("product_numbers")
|
|
8
|
-
.select("product_id, products!inner(manufacturers!inner(id))")
|
|
9
|
-
.eq("product_number", primary_product_number)
|
|
10
|
-
.eq("lifecycle", "active")
|
|
11
|
-
.eq("products.lifecycle", "active")
|
|
12
|
-
.eq("products.manufacturers.lifecycle", "active")
|
|
13
|
-
.maybeSingle();
|
|
14
|
-
if (primaryError) {
|
|
15
|
-
return IWebResponse.error(primaryError.message).to_compatible();
|
|
16
|
-
}
|
|
17
|
-
if (!primary) {
|
|
18
|
-
return IWebResponse.success([]).to_compatible();
|
|
19
|
-
}
|
|
20
|
-
const { data, error } = await supabase
|
|
21
|
-
.from("product_compatibilities")
|
|
22
|
-
.select("*, product_numbers!product_compatibilities_accessory_product_number_fkey!inner(products!inner(manufacturers!inner(id)))")
|
|
23
|
-
.eq("primary_product_id", primary.product_id)
|
|
24
|
-
.eq("role", role)
|
|
25
|
-
.eq("product_numbers.lifecycle", "active")
|
|
26
|
-
.eq("product_numbers.products.lifecycle", "active")
|
|
27
|
-
.eq("product_numbers.products.manufacturers.lifecycle", "active")
|
|
28
|
-
.order("accessory_product_number");
|
|
29
|
-
if (error) {
|
|
30
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
31
|
-
}
|
|
32
|
-
const compatibilities = (data ?? []).map(({ primary_product_id, role, accessory_product_number, auto_assign, inserted_at, }) => ({
|
|
33
|
-
primary_product_id,
|
|
34
|
-
role,
|
|
35
|
-
accessory_product_number,
|
|
36
|
-
auto_assign,
|
|
37
|
-
inserted_at,
|
|
38
|
-
}));
|
|
39
|
-
return IWebResponse.success(compatibilities).to_compatible();
|
|
4
|
+
return get_product_compatibilities_query(await newServerClient(), primary_product_number, role);
|
|
40
5
|
}
|
|
41
6
|
export async function server_get_auto_assign_accessory_product_number(primary_product_number, role) {
|
|
42
|
-
|
|
43
|
-
if (response.status !== EnumWebResponse.SUCCESS) {
|
|
44
|
-
return IWebResponse.error(response.msg ?? "Unable to load product compatibilities").to_compatible();
|
|
45
|
-
}
|
|
46
|
-
const productNumber = response.data?.find((compatibility) => compatibility.auto_assign)
|
|
47
|
-
?.accessory_product_number ?? null;
|
|
48
|
-
return IWebResponse.success(productNumber).to_compatible();
|
|
7
|
+
return get_auto_assign_accessory_product_number_query(await newServerClient(), primary_product_number, role);
|
|
49
8
|
}
|
|
50
9
|
export async function server_create_product_compatibility(compatibility) {
|
|
51
|
-
|
|
52
|
-
const { data, error } = await supabase
|
|
53
|
-
.from("product_compatibilities")
|
|
54
|
-
.insert(compatibility)
|
|
55
|
-
.select("*")
|
|
56
|
-
.single();
|
|
57
|
-
if (error) {
|
|
58
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
59
|
-
}
|
|
60
|
-
return IWebResponse.success(data).to_compatible();
|
|
10
|
+
return create_product_compatibility_query(await newServerClient(), compatibility);
|
|
61
11
|
}
|
|
62
12
|
export async function server_update_product_compatibility(primary_product_id, role, accessory_product_number, updates) {
|
|
63
|
-
|
|
64
|
-
const { data, error } = await supabase
|
|
65
|
-
.from("product_compatibilities")
|
|
66
|
-
.update(updates)
|
|
67
|
-
.eq("primary_product_id", primary_product_id)
|
|
68
|
-
.eq("role", role)
|
|
69
|
-
.eq("accessory_product_number", accessory_product_number)
|
|
70
|
-
.select("*")
|
|
71
|
-
.single();
|
|
72
|
-
if (error) {
|
|
73
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
74
|
-
}
|
|
75
|
-
return IWebResponse.success(data).to_compatible();
|
|
13
|
+
return update_product_compatibility_query(await newServerClient(), primary_product_id, role, accessory_product_number, updates);
|
|
76
14
|
}
|
|
77
15
|
export async function server_delete_product_compatibility(primary_product_id, role, accessory_product_number) {
|
|
78
|
-
|
|
79
|
-
const { error } = await supabase
|
|
80
|
-
.from("product_compatibilities")
|
|
81
|
-
.delete()
|
|
82
|
-
.eq("primary_product_id", primary_product_id)
|
|
83
|
-
.eq("role", role)
|
|
84
|
-
.eq("accessory_product_number", accessory_product_number);
|
|
85
|
-
if (error) {
|
|
86
|
-
return IWebResponse.error(error.message).to_compatible();
|
|
87
|
-
}
|
|
88
|
-
return IWebResponse.success(true).to_compatible();
|
|
16
|
+
return delete_product_compatibility_query(await newServerClient(), primary_product_id, role, accessory_product_number);
|
|
89
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IProductCompatibility, ProductCompatibilityInsert, ProductCompatibilityUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_product_compatibilities_query(client: SupabaseClient<Database>, primary_product_number: string, role: string): Promise<IWebResponseCompatible<IProductCompatibility[]>>;
|
|
6
|
+
export declare function get_auto_assign_accessory_product_number_query(client: SupabaseClient<Database>, primary_product_number: string, role: string): Promise<IWebResponseCompatible<string | null>>;
|
|
7
|
+
export declare function create_product_compatibility_query(client: SupabaseClient<Database>, compatibility: ProductCompatibilityInsert): Promise<IWebResponseCompatible<IProductCompatibility | null>>;
|
|
8
|
+
export declare function update_product_compatibility_query(client: SupabaseClient<Database>, primary_product_id: number, role: string, accessory_product_number: string, updates: ProductCompatibilityUpdate): Promise<IWebResponseCompatible<IProductCompatibility | null>>;
|
|
9
|
+
export declare function delete_product_compatibility_query(client: SupabaseClient<Database>, primary_product_id: number, role: string, accessory_product_number: string): Promise<IWebResponseCompatible<boolean>>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_product_compatibilities_query(client, primary_product_number, role) {
|
|
3
|
+
const { data: primary, error: primaryError } = await client
|
|
4
|
+
.from("product_numbers")
|
|
5
|
+
.select("product_id, products!product_numbers_product_id_fkey!inner(manufacturers!inner(id))")
|
|
6
|
+
.eq("product_number", primary_product_number)
|
|
7
|
+
.eq("lifecycle", "active")
|
|
8
|
+
.eq("products.lifecycle", "active")
|
|
9
|
+
.eq("products.manufacturers.lifecycle", "active")
|
|
10
|
+
.maybeSingle();
|
|
11
|
+
if (primaryError) {
|
|
12
|
+
return IWebResponse.error(primaryError.message).to_compatible();
|
|
13
|
+
}
|
|
14
|
+
if (!primary) {
|
|
15
|
+
return IWebResponse.success([]).to_compatible();
|
|
16
|
+
}
|
|
17
|
+
const { data, error } = await client
|
|
18
|
+
.from("product_compatibilities")
|
|
19
|
+
.select("*, product_numbers!product_compatibilities_accessory_product_number_fkey!inner(products!product_numbers_product_id_fkey!inner(manufacturers!inner(id)))")
|
|
20
|
+
.eq("primary_product_id", primary.product_id)
|
|
21
|
+
.eq("role", role)
|
|
22
|
+
.eq("product_numbers.lifecycle", "active")
|
|
23
|
+
.eq("product_numbers.products.lifecycle", "active")
|
|
24
|
+
.eq("product_numbers.products.manufacturers.lifecycle", "active")
|
|
25
|
+
.order("accessory_product_number");
|
|
26
|
+
if (error) {
|
|
27
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
28
|
+
}
|
|
29
|
+
const compatibilities = (data ?? []).map(({ primary_product_id, role, accessory_product_number, auto_assign, inserted_at, }) => ({
|
|
30
|
+
primary_product_id,
|
|
31
|
+
role,
|
|
32
|
+
accessory_product_number,
|
|
33
|
+
auto_assign,
|
|
34
|
+
inserted_at,
|
|
35
|
+
}));
|
|
36
|
+
return IWebResponse.success(compatibilities).to_compatible();
|
|
37
|
+
}
|
|
38
|
+
export async function get_auto_assign_accessory_product_number_query(client, primary_product_number, role) {
|
|
39
|
+
const response = await get_product_compatibilities_query(client, primary_product_number, role);
|
|
40
|
+
if (response.status !== EnumWebResponse.SUCCESS) {
|
|
41
|
+
return IWebResponse.error(response.msg ?? "Unable to load product compatibilities").to_compatible();
|
|
42
|
+
}
|
|
43
|
+
const productNumber = response.data?.find((compatibility) => compatibility.auto_assign)
|
|
44
|
+
?.accessory_product_number ?? null;
|
|
45
|
+
return IWebResponse.success(productNumber).to_compatible();
|
|
46
|
+
}
|
|
47
|
+
export async function create_product_compatibility_query(client, compatibility) {
|
|
48
|
+
const { data, error } = await client
|
|
49
|
+
.from("product_compatibilities")
|
|
50
|
+
.insert(compatibility)
|
|
51
|
+
.select("*")
|
|
52
|
+
.single();
|
|
53
|
+
if (error) {
|
|
54
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
55
|
+
}
|
|
56
|
+
return IWebResponse.success(data).to_compatible();
|
|
57
|
+
}
|
|
58
|
+
export async function update_product_compatibility_query(client, primary_product_id, role, accessory_product_number, updates) {
|
|
59
|
+
const { data, error } = await client
|
|
60
|
+
.from("product_compatibilities")
|
|
61
|
+
.update(updates)
|
|
62
|
+
.eq("primary_product_id", primary_product_id)
|
|
63
|
+
.eq("role", role)
|
|
64
|
+
.eq("accessory_product_number", accessory_product_number)
|
|
65
|
+
.select("*")
|
|
66
|
+
.single();
|
|
67
|
+
if (error) {
|
|
68
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
69
|
+
}
|
|
70
|
+
return IWebResponse.success(data).to_compatible();
|
|
71
|
+
}
|
|
72
|
+
export async function delete_product_compatibility_query(client, primary_product_id, role, accessory_product_number) {
|
|
73
|
+
const { error } = await client
|
|
74
|
+
.from("product_compatibilities")
|
|
75
|
+
.delete()
|
|
76
|
+
.eq("primary_product_id", primary_product_id)
|
|
77
|
+
.eq("role", role)
|
|
78
|
+
.eq("accessory_product_number", accessory_product_number);
|
|
79
|
+
if (error) {
|
|
80
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
81
|
+
}
|
|
82
|
+
return IWebResponse.success(true).to_compatible();
|
|
83
|
+
}
|
|
@@ -1,66 +1,17 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_product_number_query, get_product_for_product_number_query, get_product_number_query, get_product_numbers_by_product_query, update_product_number_query, } from "./product_numbers.queries";
|
|
4
3
|
export async function server_get_product_numbers_by_product(product_id) {
|
|
5
|
-
|
|
6
|
-
const { data, error } = await supabase
|
|
7
|
-
.from("product_numbers")
|
|
8
|
-
.select("*")
|
|
9
|
-
.eq("product_id", product_id)
|
|
10
|
-
.order("product_number");
|
|
11
|
-
if (error) {
|
|
12
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
13
|
-
}
|
|
14
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
4
|
+
return get_product_numbers_by_product_query(await newServerClient(), product_id);
|
|
15
5
|
}
|
|
16
6
|
export async function server_get_product_number(product_number) {
|
|
17
|
-
|
|
18
|
-
const { data, error } = await supabase
|
|
19
|
-
.from("product_numbers")
|
|
20
|
-
.select("*")
|
|
21
|
-
.eq("product_number", product_number)
|
|
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_product_number_query(await newServerClient(), product_number);
|
|
27
8
|
}
|
|
28
|
-
// Resolves the product line for a given product_number via the FK chain.
|
|
29
9
|
export async function server_get_product_for_product_number(product_number) {
|
|
30
|
-
|
|
31
|
-
const { data, error } = await supabase
|
|
32
|
-
.from("product_numbers")
|
|
33
|
-
.select("products(*)")
|
|
34
|
-
.eq("product_number", product_number)
|
|
35
|
-
.maybeSingle();
|
|
36
|
-
if (error) {
|
|
37
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
38
|
-
}
|
|
39
|
-
const product = data?.products ?? null;
|
|
40
|
-
return IWebResponse.success(product).to_compatible();
|
|
10
|
+
return get_product_for_product_number_query(await newServerClient(), product_number);
|
|
41
11
|
}
|
|
42
12
|
export async function server_create_product_number(row) {
|
|
43
|
-
|
|
44
|
-
const { data, error } = await supabase
|
|
45
|
-
.from("product_numbers")
|
|
46
|
-
.insert(row)
|
|
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();
|
|
13
|
+
return create_product_number_query(await newServerClient(), row);
|
|
53
14
|
}
|
|
54
15
|
export async function server_update_product_number(product_number, updates) {
|
|
55
|
-
|
|
56
|
-
const { data, error } = await supabase
|
|
57
|
-
.from("product_numbers")
|
|
58
|
-
.update(updates)
|
|
59
|
-
.eq("product_number", product_number)
|
|
60
|
-
.select("*")
|
|
61
|
-
.single();
|
|
62
|
-
if (error) {
|
|
63
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
64
|
-
}
|
|
65
|
-
return IWebResponse.success(data).to_compatible();
|
|
16
|
+
return update_product_number_query(await newServerClient(), product_number, updates);
|
|
66
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IProduct, IProductNumber, ProductNumberInsert, ProductNumberUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_product_numbers_by_product_query(client: SupabaseClient<Database>, product_id: number): Promise<IWebResponseCompatible<IProductNumber[]>>;
|
|
6
|
+
export declare function get_product_number_query(client: SupabaseClient<Database>, product_number: string): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
7
|
+
export declare function get_product_for_product_number_query(client: SupabaseClient<Database>, product_number: string): Promise<IWebResponseCompatible<IProduct | null>>;
|
|
8
|
+
export declare function create_product_number_query(client: SupabaseClient<Database>, row: ProductNumberInsert): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
9
|
+
export declare function update_product_number_query(client: SupabaseClient<Database>, product_number: string, updates: ProductNumberUpdate): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_product_numbers_by_product_query(client, product_id) {
|
|
3
|
+
const { data, error } = await client
|
|
4
|
+
.from("product_numbers")
|
|
5
|
+
.select("*")
|
|
6
|
+
.eq("product_id", product_id)
|
|
7
|
+
.order("product_number");
|
|
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_product_number_query(client, product_number) {
|
|
14
|
+
const { data, error } = await client
|
|
15
|
+
.from("product_numbers")
|
|
16
|
+
.select("*")
|
|
17
|
+
.eq("product_number", product_number)
|
|
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 get_product_for_product_number_query(client, product_number) {
|
|
25
|
+
const { data, error } = await client
|
|
26
|
+
.from("product_numbers")
|
|
27
|
+
.select("products!product_numbers_product_id_fkey(*)")
|
|
28
|
+
.eq("product_number", product_number)
|
|
29
|
+
.maybeSingle();
|
|
30
|
+
if (error) {
|
|
31
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
32
|
+
}
|
|
33
|
+
const product = data?.products ?? null;
|
|
34
|
+
return IWebResponse.success(product).to_compatible();
|
|
35
|
+
}
|
|
36
|
+
export async function create_product_number_query(client, row) {
|
|
37
|
+
const { data, error } = await client
|
|
38
|
+
.from("product_numbers")
|
|
39
|
+
.insert(row)
|
|
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
|
+
}
|
|
47
|
+
export async function update_product_number_query(client, product_number, updates) {
|
|
48
|
+
const { data, error } = await client
|
|
49
|
+
.from("product_numbers")
|
|
50
|
+
.update(updates)
|
|
51
|
+
.eq("product_number", product_number)
|
|
52
|
+
.select("*")
|
|
53
|
+
.single();
|
|
54
|
+
if (error) {
|
|
55
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
56
|
+
}
|
|
57
|
+
return IWebResponse.success(data).to_compatible();
|
|
58
|
+
}
|
package/dist/helpers/products.js
CHANGED
|
@@ -1,65 +1,17 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
2
|
+
import { create_product_query, get_product_by_id_query, get_products_by_manufacturer_query, get_products_query, update_product_query, } from "./products.queries";
|
|
4
3
|
export async function server_get_products(options) {
|
|
5
|
-
|
|
6
|
-
let query = supabase.from("products").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_products_query(await newServerClient(), options);
|
|
15
5
|
}
|
|
16
6
|
export async function server_get_product_by_id(product_id) {
|
|
17
|
-
|
|
18
|
-
const { data, error } = await supabase
|
|
19
|
-
.from("products")
|
|
20
|
-
.select("*")
|
|
21
|
-
.eq("id", product_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_product_by_id_query(await newServerClient(), product_id);
|
|
27
8
|
}
|
|
28
9
|
export async function server_get_products_by_manufacturer(manufacturer_id) {
|
|
29
|
-
|
|
30
|
-
const { data, error } = await supabase
|
|
31
|
-
.from("products")
|
|
32
|
-
.select("*")
|
|
33
|
-
.eq("manufacturer_id", manufacturer_id)
|
|
34
|
-
.eq("lifecycle", "active")
|
|
35
|
-
.order("name");
|
|
36
|
-
if (error) {
|
|
37
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
38
|
-
}
|
|
39
|
-
return IWebResponse.success(data ?? []).to_compatible();
|
|
10
|
+
return get_products_by_manufacturer_query(await newServerClient(), manufacturer_id);
|
|
40
11
|
}
|
|
41
12
|
export async function server_create_product(row) {
|
|
42
|
-
|
|
43
|
-
const { data, error } = await supabase
|
|
44
|
-
.from("products")
|
|
45
|
-
.insert(row)
|
|
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 create_product_query(await newServerClient(), row);
|
|
52
14
|
}
|
|
53
15
|
export async function server_update_product(product_id, updates) {
|
|
54
|
-
|
|
55
|
-
const { data, error } = await supabase
|
|
56
|
-
.from("products")
|
|
57
|
-
.update(updates)
|
|
58
|
-
.eq("id", product_id)
|
|
59
|
-
.select("*")
|
|
60
|
-
.single();
|
|
61
|
-
if (error) {
|
|
62
|
-
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
63
|
-
}
|
|
64
|
-
return IWebResponse.success(data).to_compatible();
|
|
16
|
+
return update_product_query(await newServerClient(), product_id, updates);
|
|
65
17
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import { IProduct, ProductInsert, ProductUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { Database } from "../types/supabase";
|
|
5
|
+
export declare function get_products_query(client: SupabaseClient<Database>, options?: {
|
|
6
|
+
include_inactive?: boolean;
|
|
7
|
+
}): Promise<IWebResponseCompatible<IProduct[]>>;
|
|
8
|
+
export declare function get_product_by_id_query(client: SupabaseClient<Database>, product_id: number): Promise<IWebResponseCompatible<IProduct | null>>;
|
|
9
|
+
export declare function get_products_by_manufacturer_query(client: SupabaseClient<Database>, manufacturer_id: number): Promise<IWebResponseCompatible<IProduct[]>>;
|
|
10
|
+
export declare function create_product_query(client: SupabaseClient<Database>, row: ProductInsert): Promise<IWebResponseCompatible<IProduct | null>>;
|
|
11
|
+
export declare function update_product_query(client: SupabaseClient<Database>, product_id: number, updates: ProductUpdate): Promise<IWebResponseCompatible<IProduct | null>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
export async function get_products_query(client, options) {
|
|
3
|
+
let query = client.from("products").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_product_by_id_query(client, product_id) {
|
|
14
|
+
const { data, error } = await client
|
|
15
|
+
.from("products")
|
|
16
|
+
.select("*")
|
|
17
|
+
.eq("id", product_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 get_products_by_manufacturer_query(client, manufacturer_id) {
|
|
25
|
+
const { data, error } = await client
|
|
26
|
+
.from("products")
|
|
27
|
+
.select("*")
|
|
28
|
+
.eq("manufacturer_id", manufacturer_id)
|
|
29
|
+
.eq("lifecycle", "active")
|
|
30
|
+
.order("name");
|
|
31
|
+
if (error) {
|
|
32
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: [] };
|
|
33
|
+
}
|
|
34
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
35
|
+
}
|
|
36
|
+
export async function create_product_query(client, row) {
|
|
37
|
+
const { data, error } = await client
|
|
38
|
+
.from("products")
|
|
39
|
+
.insert(row)
|
|
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
|
+
}
|
|
47
|
+
export async function update_product_query(client, product_id, updates) {
|
|
48
|
+
const { data, error } = await client
|
|
49
|
+
.from("products")
|
|
50
|
+
.update(updates)
|
|
51
|
+
.eq("id", product_id)
|
|
52
|
+
.select("*")
|
|
53
|
+
.single();
|
|
54
|
+
if (error) {
|
|
55
|
+
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
56
|
+
}
|
|
57
|
+
return IWebResponse.success(data).to_compatible();
|
|
58
|
+
}
|
|
@@ -1,83 +1,17 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
4
|
-
import { get_providers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
5
|
-
// function that fetches the providers from our db given a herd id
|
|
2
|
+
import { create_provider_query, delete_providers_by_ids_query, get_providers_by_herd_ids_query, get_providers_by_herd_query, update_provider_query, } from "./providers.queries";
|
|
6
3
|
export async function server_get_providers_by_herd(herd_id) {
|
|
7
|
-
|
|
8
|
-
const { data, error } = await supabase
|
|
9
|
-
.from("providers")
|
|
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_providers_by_herd_query(await newServerClient(), herd_id);
|
|
22
5
|
}
|
|
23
|
-
// Fetches providers for many herds in one query, grouped by herd_id.
|
|
24
6
|
export async function server_get_providers_by_herd_ids(herd_ids) {
|
|
25
7
|
return get_providers_by_herd_ids_query(await newServerClient(), herd_ids);
|
|
26
8
|
}
|
|
27
|
-
// function that creates a new provider in our db
|
|
28
9
|
export async function server_create_provider(provider) {
|
|
29
|
-
|
|
30
|
-
const { data, error } = await supabase
|
|
31
|
-
.from("providers")
|
|
32
|
-
.insert(provider)
|
|
33
|
-
.select("*")
|
|
34
|
-
.single();
|
|
35
|
-
if (error) {
|
|
36
|
-
return {
|
|
37
|
-
status: EnumWebResponse.ERROR,
|
|
38
|
-
msg: error.message,
|
|
39
|
-
data: null,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return IWebResponse.success(data).to_compatible();
|
|
44
|
-
}
|
|
10
|
+
return create_provider_query(await newServerClient(), provider);
|
|
45
11
|
}
|
|
46
|
-
// function that updates a provider in our db
|
|
47
12
|
export async function server_update_provider(provider_id, updates) {
|
|
48
|
-
|
|
49
|
-
const { data, error } = await supabase
|
|
50
|
-
.from("providers")
|
|
51
|
-
.update(updates)
|
|
52
|
-
.eq("id", provider_id)
|
|
53
|
-
.select("*")
|
|
54
|
-
.single();
|
|
55
|
-
if (error) {
|
|
56
|
-
return {
|
|
57
|
-
status: EnumWebResponse.ERROR,
|
|
58
|
-
msg: error.message,
|
|
59
|
-
data: null,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return IWebResponse.success(data).to_compatible();
|
|
64
|
-
}
|
|
13
|
+
return update_provider_query(await newServerClient(), provider_id, updates);
|
|
65
14
|
}
|
|
66
|
-
// function that deletes providers by ids
|
|
67
15
|
export async function server_delete_providers_by_ids(provider_ids) {
|
|
68
|
-
|
|
69
|
-
const { error } = await supabase
|
|
70
|
-
.from("providers")
|
|
71
|
-
.delete()
|
|
72
|
-
.in("id", provider_ids);
|
|
73
|
-
if (error) {
|
|
74
|
-
return {
|
|
75
|
-
status: EnumWebResponse.ERROR,
|
|
76
|
-
msg: error.message,
|
|
77
|
-
data: false,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
return IWebResponse.success(true).to_compatible();
|
|
82
|
-
}
|
|
16
|
+
return delete_providers_by_ids_query(await newServerClient(), provider_ids);
|
|
83
17
|
}
|
|
@@ -2,4 +2,8 @@ import { SupabaseClient } from "@supabase/supabase-js";
|
|
|
2
2
|
import { IProvider } from "../types/db";
|
|
3
3
|
import { Database } from "../types/supabase";
|
|
4
4
|
import { IWebResponseCompatible } from "../types/requests";
|
|
5
|
-
export
|
|
5
|
+
export { get_providers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
6
|
+
export declare function get_providers_by_herd_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IProvider[]>>;
|
|
7
|
+
export declare function create_provider_query(client: SupabaseClient<Database>, provider: Omit<IProvider, "id" | "created_at">): Promise<IWebResponseCompatible<IProvider>>;
|
|
8
|
+
export declare function update_provider_query(client: SupabaseClient<Database>, provider_id: number, updates: Partial<Omit<IProvider, "id" | "created_at">>): Promise<IWebResponseCompatible<IProvider>>;
|
|
9
|
+
export declare function delete_providers_by_ids_query(client: SupabaseClient<Database>, provider_ids: number[]): Promise<IWebResponseCompatible<boolean>>;
|
|
@@ -1,20 +1,61 @@
|
|
|
1
1
|
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export { get_providers_by_herd_ids_query } from "./herd_scoped.queries";
|
|
3
|
+
export async function get_providers_by_herd_query(client, herd_id) {
|
|
4
|
+
const { data, error } = await client
|
|
5
|
+
.from("providers")
|
|
6
|
+
.select("*")
|
|
7
|
+
.eq("herd_id", herd_id);
|
|
8
|
+
if (error) {
|
|
9
|
+
return {
|
|
10
|
+
status: EnumWebResponse.ERROR,
|
|
11
|
+
msg: error.message,
|
|
12
|
+
data: null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return IWebResponse.success(data).to_compatible();
|
|
16
|
+
}
|
|
17
|
+
export async function create_provider_query(client, provider) {
|
|
18
|
+
const { data, error } = await client
|
|
19
|
+
.from("providers")
|
|
20
|
+
.insert(provider)
|
|
21
|
+
.select("*")
|
|
22
|
+
.single();
|
|
23
|
+
if (error) {
|
|
24
|
+
return {
|
|
25
|
+
status: EnumWebResponse.ERROR,
|
|
26
|
+
msg: error.message,
|
|
27
|
+
data: null,
|
|
28
|
+
};
|
|
6
29
|
}
|
|
30
|
+
return IWebResponse.success(data).to_compatible();
|
|
31
|
+
}
|
|
32
|
+
export async function update_provider_query(client, provider_id, updates) {
|
|
7
33
|
const { data, error } = await client
|
|
8
34
|
.from("providers")
|
|
35
|
+
.update(updates)
|
|
36
|
+
.eq("id", provider_id)
|
|
9
37
|
.select("*")
|
|
10
|
-
.
|
|
11
|
-
.order("id", { ascending: true });
|
|
38
|
+
.single();
|
|
12
39
|
if (error) {
|
|
13
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
status: EnumWebResponse.ERROR,
|
|
42
|
+
msg: error.message,
|
|
43
|
+
data: null,
|
|
44
|
+
};
|
|
14
45
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
46
|
+
return IWebResponse.success(data).to_compatible();
|
|
47
|
+
}
|
|
48
|
+
export async function delete_providers_by_ids_query(client, provider_ids) {
|
|
49
|
+
const { error } = await client
|
|
50
|
+
.from("providers")
|
|
51
|
+
.delete()
|
|
52
|
+
.in("id", provider_ids);
|
|
53
|
+
if (error) {
|
|
54
|
+
return {
|
|
55
|
+
status: EnumWebResponse.ERROR,
|
|
56
|
+
msg: error.message,
|
|
57
|
+
data: false,
|
|
58
|
+
};
|
|
18
59
|
}
|
|
19
|
-
return IWebResponse.success(
|
|
60
|
+
return IWebResponse.success(true).to_compatible();
|
|
20
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IPubsubTokenMint } from "../types/pubsub_token";
|
|
2
2
|
import { IWebResponseCompatible } from "../types/requests";
|
|
3
3
|
export declare function server_mint_pubsub_token(): Promise<IWebResponseCompatible<IPubsubTokenMint>>;
|
|
4
|
+
export declare function server_get_pubsub_jwt_public_keys(): Promise<IWebResponseCompatible<import("../types").IPubsubJwtPublicKeyEntry[]>>;
|