@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { newServerClient } from "../supabase/server";
|
|
2
|
+
import { create_part, delete_part, get_deleted_parts_by_device_id, get_part_by_id, get_parts_by_certificate_id, get_parts_by_device_id, get_parts_by_herd_id, get_parts_by_herd_ids, get_parts_by_lifecycle, get_parts_by_product_and_serial, get_parts_by_product_number, get_parts_by_serial_number, get_parts_by_status, hard_delete_part, restore_part, update_part, update_part_status, } from "./parts";
|
|
3
|
+
export async function server_get_parts_by_device_id(device_id) {
|
|
4
|
+
const client = await newServerClient();
|
|
5
|
+
return get_parts_by_device_id(client, device_id);
|
|
6
|
+
}
|
|
7
|
+
export async function server_get_part_by_id(part_id) {
|
|
8
|
+
const client = await newServerClient();
|
|
9
|
+
return get_part_by_id(client, part_id);
|
|
10
|
+
}
|
|
11
|
+
export async function server_get_parts_by_serial_number(serial_number) {
|
|
12
|
+
const client = await newServerClient();
|
|
13
|
+
return get_parts_by_serial_number(client, serial_number);
|
|
14
|
+
}
|
|
15
|
+
export async function server_get_parts_by_product_number(product_number) {
|
|
16
|
+
const client = await newServerClient();
|
|
17
|
+
return get_parts_by_product_number(client, product_number);
|
|
18
|
+
}
|
|
19
|
+
export async function server_get_parts_by_lifecycle(lifecycle) {
|
|
20
|
+
const client = await newServerClient();
|
|
21
|
+
return get_parts_by_lifecycle(client, lifecycle);
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated Use server_get_parts_by_lifecycle */
|
|
24
|
+
export async function server_get_parts_by_status(lifecycle) {
|
|
25
|
+
const client = await newServerClient();
|
|
26
|
+
return get_parts_by_status(client, lifecycle);
|
|
27
|
+
}
|
|
28
|
+
export async function server_create_part(newPart) {
|
|
29
|
+
const client = await newServerClient();
|
|
30
|
+
return create_part(client, newPart);
|
|
31
|
+
}
|
|
32
|
+
export async function server_update_part(part_id, updatedPart) {
|
|
33
|
+
const client = await newServerClient();
|
|
34
|
+
return update_part(client, part_id, updatedPart);
|
|
35
|
+
}
|
|
36
|
+
export async function server_delete_part(part_id, options) {
|
|
37
|
+
const client = await newServerClient();
|
|
38
|
+
return delete_part(client, part_id, options);
|
|
39
|
+
}
|
|
40
|
+
export async function server_update_part_status(part_id, lifecycle, options) {
|
|
41
|
+
const client = await newServerClient();
|
|
42
|
+
return update_part_status(client, part_id, lifecycle, options);
|
|
43
|
+
}
|
|
44
|
+
export async function server_get_parts_by_certificate_id(certificate_id) {
|
|
45
|
+
const client = await newServerClient();
|
|
46
|
+
return get_parts_by_certificate_id(client, certificate_id);
|
|
47
|
+
}
|
|
48
|
+
export async function server_get_parts_by_herd_id(herd_id) {
|
|
49
|
+
const client = await newServerClient();
|
|
50
|
+
return get_parts_by_herd_id(client, herd_id);
|
|
51
|
+
}
|
|
52
|
+
export async function server_get_parts_by_herd_ids(herd_ids) {
|
|
53
|
+
const client = await newServerClient();
|
|
54
|
+
return get_parts_by_herd_ids(client, herd_ids);
|
|
55
|
+
}
|
|
56
|
+
export async function server_restore_part(part_id, options) {
|
|
57
|
+
const client = await newServerClient();
|
|
58
|
+
return restore_part(client, part_id, options);
|
|
59
|
+
}
|
|
60
|
+
export async function server_hard_delete_part(part_id) {
|
|
61
|
+
const client = await newServerClient();
|
|
62
|
+
return hard_delete_part(client, part_id);
|
|
63
|
+
}
|
|
64
|
+
export async function server_get_deleted_parts_by_device_id(device_id) {
|
|
65
|
+
const client = await newServerClient();
|
|
66
|
+
return get_deleted_parts_by_device_id(client, device_id);
|
|
67
|
+
}
|
|
68
|
+
export async function server_get_parts_by_product_and_serial(product_number, serial_number) {
|
|
69
|
+
const client = await newServerClient();
|
|
70
|
+
return get_parts_by_product_and_serial(client, product_number, serial_number);
|
|
71
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { PinInsert } from "../types/db";
|
|
2
|
+
export declare function server_get_pins_for_herd(herd_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
3
|
+
id: number | null;
|
|
4
|
+
created_at: string | null;
|
|
5
|
+
location: unknown;
|
|
6
|
+
altitude_relative_to_ground: number | null;
|
|
7
|
+
color: string | null;
|
|
8
|
+
name: string | null;
|
|
9
|
+
description: string | null;
|
|
10
|
+
herd_id: number | null;
|
|
11
|
+
created_by: string | null;
|
|
12
|
+
latitude: number | null;
|
|
13
|
+
longitude: number | null;
|
|
14
|
+
}[]>>;
|
|
15
|
+
export declare function server_get_pin_by_id(pin_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
16
|
+
id: number | null;
|
|
17
|
+
created_at: string | null;
|
|
18
|
+
location: unknown;
|
|
19
|
+
altitude_relative_to_ground: number | null;
|
|
20
|
+
color: string | null;
|
|
21
|
+
name: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
herd_id: number | null;
|
|
24
|
+
created_by: string | null;
|
|
25
|
+
latitude: number | null;
|
|
26
|
+
longitude: number | null;
|
|
27
|
+
} | null>>;
|
|
28
|
+
export declare function server_create_pin(newPin: PinInsert): Promise<import("../types").IWebResponseCompatible<{
|
|
29
|
+
id: number | null;
|
|
30
|
+
created_at: string | null;
|
|
31
|
+
location: unknown;
|
|
32
|
+
altitude_relative_to_ground: number | null;
|
|
33
|
+
color: string | null;
|
|
34
|
+
name: string | null;
|
|
35
|
+
description: string | null;
|
|
36
|
+
herd_id: number | null;
|
|
37
|
+
created_by: string | null;
|
|
38
|
+
latitude: number | null;
|
|
39
|
+
longitude: number | null;
|
|
40
|
+
} | null>>;
|
|
41
|
+
export declare function server_create_pin_with_coordinates(latitude: number, longitude: number, pinData: Omit<PinInsert, "location">): Promise<import("../types").IWebResponseCompatible<{
|
|
42
|
+
id: number | null;
|
|
43
|
+
created_at: string | null;
|
|
44
|
+
location: unknown;
|
|
45
|
+
altitude_relative_to_ground: number | null;
|
|
46
|
+
color: string | null;
|
|
47
|
+
name: string | null;
|
|
48
|
+
description: string | null;
|
|
49
|
+
herd_id: number | null;
|
|
50
|
+
created_by: string | null;
|
|
51
|
+
latitude: number | null;
|
|
52
|
+
longitude: number | null;
|
|
53
|
+
} | null>>;
|
|
54
|
+
export declare function server_update_pin(pin_id: number, updatedPin: Partial<PinInsert>): Promise<import("../types").IWebResponseCompatible<{
|
|
55
|
+
id: number | null;
|
|
56
|
+
created_at: string | null;
|
|
57
|
+
location: unknown;
|
|
58
|
+
altitude_relative_to_ground: number | null;
|
|
59
|
+
color: string | null;
|
|
60
|
+
name: string | null;
|
|
61
|
+
description: string | null;
|
|
62
|
+
herd_id: number | null;
|
|
63
|
+
created_by: string | null;
|
|
64
|
+
latitude: number | null;
|
|
65
|
+
longitude: number | null;
|
|
66
|
+
} | null>>;
|
|
67
|
+
export declare function server_update_pin_location(pin_id: number, latitude: number, longitude: number, updatedPin?: Partial<Omit<PinInsert, "location">>): Promise<import("../types").IWebResponseCompatible<{
|
|
68
|
+
id: number | null;
|
|
69
|
+
created_at: string | null;
|
|
70
|
+
location: unknown;
|
|
71
|
+
altitude_relative_to_ground: number | null;
|
|
72
|
+
color: string | null;
|
|
73
|
+
name: string | null;
|
|
74
|
+
description: string | null;
|
|
75
|
+
herd_id: number | null;
|
|
76
|
+
created_by: string | null;
|
|
77
|
+
latitude: number | null;
|
|
78
|
+
longitude: number | null;
|
|
79
|
+
} | null>>;
|
|
80
|
+
export declare function server_delete_pin(pin_id: number): Promise<import("../types").IWebResponseCompatible<{
|
|
81
|
+
id: number | null;
|
|
82
|
+
created_at: string | null;
|
|
83
|
+
location: unknown;
|
|
84
|
+
altitude_relative_to_ground: number | null;
|
|
85
|
+
color: string | null;
|
|
86
|
+
name: string | null;
|
|
87
|
+
description: string | null;
|
|
88
|
+
herd_id: number | null;
|
|
89
|
+
created_by: string | null;
|
|
90
|
+
latitude: number | null;
|
|
91
|
+
longitude: number | null;
|
|
92
|
+
} | null>>;
|
|
93
|
+
export declare function server_get_pins_by_created_by(user_id: string): Promise<import("../types").IWebResponseCompatible<{
|
|
94
|
+
id: number | null;
|
|
95
|
+
created_at: string | null;
|
|
96
|
+
location: unknown;
|
|
97
|
+
altitude_relative_to_ground: number | null;
|
|
98
|
+
color: string | null;
|
|
99
|
+
name: string | null;
|
|
100
|
+
description: string | null;
|
|
101
|
+
herd_id: number | null;
|
|
102
|
+
created_by: string | null;
|
|
103
|
+
latitude: number | null;
|
|
104
|
+
longitude: number | null;
|
|
105
|
+
}[]>>;
|
|
106
|
+
export declare function server_get_pins_by_color(herd_id: number, color: string): Promise<import("../types").IWebResponseCompatible<{
|
|
107
|
+
id: number | null;
|
|
108
|
+
created_at: string | null;
|
|
109
|
+
location: unknown;
|
|
110
|
+
altitude_relative_to_ground: number | null;
|
|
111
|
+
color: string | null;
|
|
112
|
+
name: string | null;
|
|
113
|
+
description: string | null;
|
|
114
|
+
herd_id: number | null;
|
|
115
|
+
created_by: string | null;
|
|
116
|
+
latitude: number | null;
|
|
117
|
+
longitude: number | null;
|
|
118
|
+
}[]>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { newServerClient } from "../supabase/server";
|
|
2
|
+
import { create_pin, create_pin_with_coordinates, delete_pin, get_pin_by_id, get_pins_by_color, get_pins_by_created_by, get_pins_for_herd, update_pin, update_pin_location, } from "./pins";
|
|
3
|
+
export async function server_get_pins_for_herd(herd_id) {
|
|
4
|
+
const client = await newServerClient();
|
|
5
|
+
return get_pins_for_herd(client, herd_id);
|
|
6
|
+
}
|
|
7
|
+
export async function server_get_pin_by_id(pin_id) {
|
|
8
|
+
const client = await newServerClient();
|
|
9
|
+
return get_pin_by_id(client, pin_id);
|
|
10
|
+
}
|
|
11
|
+
export async function server_create_pin(newPin) {
|
|
12
|
+
const client = await newServerClient();
|
|
13
|
+
return create_pin(client, newPin);
|
|
14
|
+
}
|
|
15
|
+
export async function server_create_pin_with_coordinates(latitude, longitude, pinData) {
|
|
16
|
+
const client = await newServerClient();
|
|
17
|
+
return create_pin_with_coordinates(client, latitude, longitude, pinData);
|
|
18
|
+
}
|
|
19
|
+
export async function server_update_pin(pin_id, updatedPin) {
|
|
20
|
+
const client = await newServerClient();
|
|
21
|
+
return update_pin(client, pin_id, updatedPin);
|
|
22
|
+
}
|
|
23
|
+
export async function server_update_pin_location(pin_id, latitude, longitude, updatedPin) {
|
|
24
|
+
const client = await newServerClient();
|
|
25
|
+
return update_pin_location(client, pin_id, latitude, longitude, updatedPin);
|
|
26
|
+
}
|
|
27
|
+
export async function server_delete_pin(pin_id) {
|
|
28
|
+
const client = await newServerClient();
|
|
29
|
+
return delete_pin(client, pin_id);
|
|
30
|
+
}
|
|
31
|
+
export async function server_get_pins_by_created_by(user_id) {
|
|
32
|
+
const client = await newServerClient();
|
|
33
|
+
return get_pins_by_created_by(client, user_id);
|
|
34
|
+
}
|
|
35
|
+
export async function server_get_pins_by_color(herd_id, color) {
|
|
36
|
+
const client = await newServerClient();
|
|
37
|
+
return get_pins_by_color(client, herd_id, color);
|
|
38
|
+
}
|
package/dist/helpers/plans.js
CHANGED
|
@@ -1,66 +1,14 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
|
-
import {
|
|
4
|
-
import { get_plans_by_herd_ids_query } from "./herd_scoped.queries";
|
|
5
|
-
// function that fetches the plans our db given a herd id
|
|
2
|
+
import { create_plans_query, delete_plans_by_ids_query, get_plans_by_herd_ids_query, get_plans_by_herd_query, } from "./plans.queries";
|
|
6
3
|
export async function server_get_plans_by_herd(herd_id) {
|
|
7
|
-
|
|
8
|
-
const { data, error } = await supabase
|
|
9
|
-
.from("plans")
|
|
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_plans_by_herd_query(await newServerClient(), herd_id);
|
|
22
5
|
}
|
|
23
|
-
// Fetches plans for many herds in one query, grouped by herd_id.
|
|
24
6
|
export async function server_get_plans_by_herd_ids(herd_ids) {
|
|
25
7
|
return get_plans_by_herd_ids_query(await newServerClient(), herd_ids);
|
|
26
8
|
}
|
|
27
|
-
// function that uploads plan to our db
|
|
28
9
|
export async function server_create_plans(plans) {
|
|
29
|
-
|
|
30
|
-
let formatted_plans = plans.map((plan) => {
|
|
31
|
-
let formatted_plan = { ...plan };
|
|
32
|
-
delete formatted_plan.id;
|
|
33
|
-
delete formatted_plan.inserted_at;
|
|
34
|
-
return formatted_plan;
|
|
35
|
-
});
|
|
36
|
-
const supabase = await newServerClient();
|
|
37
|
-
// insert data and return the response
|
|
38
|
-
const { data, error } = await supabase
|
|
39
|
-
.from("plans")
|
|
40
|
-
.insert(formatted_plans)
|
|
41
|
-
.select("*");
|
|
42
|
-
if (error) {
|
|
43
|
-
return {
|
|
44
|
-
status: EnumWebResponse.ERROR,
|
|
45
|
-
msg: error.message,
|
|
46
|
-
data: null,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return IWebResponse.success(data).to_compatible();
|
|
51
|
-
}
|
|
10
|
+
return create_plans_query(await newServerClient(), plans);
|
|
52
11
|
}
|
|
53
12
|
export async function server_delete_plans_by_ids(plan_ids) {
|
|
54
|
-
|
|
55
|
-
const { error } = await supabase.from("plans").delete().in("id", plan_ids);
|
|
56
|
-
if (error) {
|
|
57
|
-
return {
|
|
58
|
-
status: EnumWebResponse.ERROR,
|
|
59
|
-
msg: error.message,
|
|
60
|
-
data: false,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return IWebResponse.success(true).to_compatible();
|
|
65
|
-
}
|
|
13
|
+
return delete_plans_by_ids_query(await newServerClient(), plan_ids);
|
|
66
14
|
}
|
|
@@ -2,4 +2,7 @@ import { SupabaseClient } from "@supabase/supabase-js";
|
|
|
2
2
|
import { IPlan } from "../types/db";
|
|
3
3
|
import { Database } from "../types/supabase";
|
|
4
4
|
import { IWebResponseCompatible } from "../types/requests";
|
|
5
|
-
export
|
|
5
|
+
export { get_plans_by_herd_ids_query } from "./herd_scoped.queries";
|
|
6
|
+
export declare function get_plans_by_herd_query(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IPlan[]>>;
|
|
7
|
+
export declare function create_plans_query(client: SupabaseClient<Database>, plans: IPlan[]): Promise<IWebResponseCompatible<IPlan[]>>;
|
|
8
|
+
export declare function delete_plans_by_ids_query(client: SupabaseClient<Database>, plan_ids: number[]): Promise<IWebResponseCompatible<boolean>>;
|
|
@@ -1,20 +1,47 @@
|
|
|
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_plans_by_herd_ids_query } from "./herd_scoped.queries";
|
|
3
|
+
export async function get_plans_by_herd_query(client, herd_id) {
|
|
7
4
|
const { data, error } = await client
|
|
8
5
|
.from("plans")
|
|
9
6
|
.select("*")
|
|
10
|
-
.
|
|
11
|
-
|
|
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_plans_query(client, plans) {
|
|
18
|
+
const formatted_plans = plans.map(({ herd_id, instructions, name, plan_type }) => ({
|
|
19
|
+
herd_id,
|
|
20
|
+
instructions,
|
|
21
|
+
name,
|
|
22
|
+
plan_type,
|
|
23
|
+
}));
|
|
24
|
+
const { data, error } = await client
|
|
25
|
+
.from("plans")
|
|
26
|
+
.insert(formatted_plans)
|
|
27
|
+
.select("*");
|
|
12
28
|
if (error) {
|
|
13
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
status: EnumWebResponse.ERROR,
|
|
31
|
+
msg: error.message,
|
|
32
|
+
data: null,
|
|
33
|
+
};
|
|
14
34
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
return IWebResponse.success(data).to_compatible();
|
|
36
|
+
}
|
|
37
|
+
export async function delete_plans_by_ids_query(client, plan_ids) {
|
|
38
|
+
const { error } = await client.from("plans").delete().in("id", plan_ids);
|
|
39
|
+
if (error) {
|
|
40
|
+
return {
|
|
41
|
+
status: EnumWebResponse.ERROR,
|
|
42
|
+
msg: error.message,
|
|
43
|
+
data: false,
|
|
44
|
+
};
|
|
18
45
|
}
|
|
19
|
-
return IWebResponse.success(
|
|
46
|
+
return IWebResponse.success(true).to_compatible();
|
|
20
47
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function server_get_points_for_user_by_user_id(user_id: string): Promise<import("../types").IWebResponseCompatible<{
|
|
2
|
+
id: number;
|
|
3
|
+
inserted_at: string;
|
|
4
|
+
points: number;
|
|
5
|
+
update_reason: string;
|
|
6
|
+
user_id: string;
|
|
7
|
+
}[]>>;
|
|
8
|
+
export declare function server_get_points_balance_for_user_id(user_id: string): Promise<import("../types").IWebResponseCompatible<number>>;
|
|
9
|
+
export declare function server_update_points_balance_for_user(user_id: string, balance: number, update_reason: string): Promise<import("../types").IWebResponseCompatible<import("./points_for_user").PointsBalanceUpdateResult | null>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { newServerClient } from "../supabase/server";
|
|
2
|
+
import { get_points_balance_for_user_id, get_points_for_user_by_user_id, update_points_balance_for_user, } from "./points_for_user";
|
|
3
|
+
export async function server_get_points_for_user_by_user_id(user_id) {
|
|
4
|
+
const client = await newServerClient();
|
|
5
|
+
return get_points_for_user_by_user_id(client, user_id);
|
|
6
|
+
}
|
|
7
|
+
export async function server_get_points_balance_for_user_id(user_id) {
|
|
8
|
+
const client = await newServerClient();
|
|
9
|
+
return get_points_balance_for_user_id(client, user_id);
|
|
10
|
+
}
|
|
11
|
+
export async function server_update_points_balance_for_user(user_id, balance, update_reason) {
|
|
12
|
+
const client = await newServerClient();
|
|
13
|
+
return update_points_balance_for_user(client, user_id, balance, update_reason);
|
|
14
|
+
}
|
|
@@ -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!product_numbers_product_id_fkey!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!product_numbers_product_id_fkey!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!product_numbers_product_id_fkey(*)")
|
|
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
|
}
|