@adventurelabs/scout-core 2.1.1 → 2.1.3
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/dist/helpers/parts.js +6 -3
- package/dist/helpers/product_catalog.d.ts +7 -4
- package/dist/helpers/product_catalog.js +13 -3
- package/dist/helpers/product_numbers.d.ts +2 -2
- package/dist/helpers/product_numbers.queries.d.ts +2 -2
- package/dist/helpers/product_numbers.queries.js +3 -3
- package/dist/store/hooks.d.ts +3 -3
- package/dist/types/db.d.ts +7 -3
- package/dist/types/supabase.d.ts +0 -1
- package/package.json +1 -1
package/dist/helpers/parts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IWebResponse } from "../types/requests";
|
|
2
2
|
import { update_part_lifecycle } from "./lifecycle";
|
|
3
|
-
import { build_product_catalog, EMPTY_PRODUCT_CATALOG, } from "./product_catalog";
|
|
3
|
+
import { build_product_catalog, catalog_product_from_join, EMPTY_PRODUCT_CATALOG, } from "./product_catalog";
|
|
4
4
|
export async function get_parts_by_device_id(client, device_id) {
|
|
5
5
|
const { data, error } = await client
|
|
6
6
|
.from("parts")
|
|
@@ -185,7 +185,10 @@ export async function get_parts_by_herd_ids(client, herd_ids) {
|
|
|
185
185
|
*,
|
|
186
186
|
devices!parts_device_id_fkey(herd_id),
|
|
187
187
|
product_numbers!parts_product_number_fkey(
|
|
188
|
-
products!product_numbers_product_id_fkey(
|
|
188
|
+
products!product_numbers_product_id_fkey(
|
|
189
|
+
*,
|
|
190
|
+
manufacturers!products_manufacturer_id_fkey(name)
|
|
191
|
+
)
|
|
189
192
|
)
|
|
190
193
|
`)
|
|
191
194
|
.in("devices.herd_id", herd_ids)
|
|
@@ -204,7 +207,7 @@ export async function get_parts_by_herd_ids(client, herd_ids) {
|
|
|
204
207
|
const part = partRow;
|
|
205
208
|
product_entries.push({
|
|
206
209
|
product_number: part.product_number,
|
|
207
|
-
product: product_numbers?.products
|
|
210
|
+
product: catalog_product_from_join(product_numbers?.products),
|
|
208
211
|
});
|
|
209
212
|
(parts_by_device[_a = row.device_id] ?? (parts_by_device[_a] = [])).push(part);
|
|
210
213
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { IDevice, IPart, IProduct, IProductCatalog } from "../types/db";
|
|
1
|
+
import { ICatalogProduct, IDevice, IManufacturer, IPart, IProduct, IProductCatalog } from "../types/db";
|
|
2
2
|
export declare const EMPTY_PRODUCT_CATALOG: IProductCatalog;
|
|
3
|
+
export declare function catalog_product_from_join(product: (IProduct & {
|
|
4
|
+
manufacturers?: Pick<IManufacturer, "name"> | null;
|
|
5
|
+
}) | null | undefined): ICatalogProduct | null;
|
|
3
6
|
export declare function build_product_catalog(entries: Iterable<{
|
|
4
7
|
product_number: string;
|
|
5
|
-
product: IProduct | null | undefined;
|
|
8
|
+
product: ICatalogProduct | IProduct | null | undefined;
|
|
6
9
|
}>): IProductCatalog;
|
|
7
|
-
export declare function get_product_for_part(catalog: IProductCatalog | null | undefined, part: Pick<IPart, "product_number"> | null | undefined):
|
|
10
|
+
export declare function get_product_for_part(catalog: IProductCatalog | null | undefined, part: Pick<IPart, "product_number"> | null | undefined): ICatalogProduct | null;
|
|
8
11
|
/** Distinct products across a device's parts, in part order. */
|
|
9
|
-
export declare function get_products_for_device(catalog: IProductCatalog | null | undefined, device: Pick<IDevice, "parts"> | null | undefined):
|
|
12
|
+
export declare function get_products_for_device(catalog: IProductCatalog | null | undefined, device: Pick<IDevice, "parts"> | null | undefined): ICatalogProduct[];
|
|
@@ -2,6 +2,15 @@ export const EMPTY_PRODUCT_CATALOG = {
|
|
|
2
2
|
products: {},
|
|
3
3
|
product_id_by_number: {},
|
|
4
4
|
};
|
|
5
|
+
export function catalog_product_from_join(product) {
|
|
6
|
+
if (!product)
|
|
7
|
+
return null;
|
|
8
|
+
const { manufacturers, ...row } = product;
|
|
9
|
+
return {
|
|
10
|
+
...row,
|
|
11
|
+
manufacturers: manufacturers ?? null,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
5
14
|
export function build_product_catalog(entries) {
|
|
6
15
|
var _a, _b;
|
|
7
16
|
const catalog = {
|
|
@@ -9,10 +18,11 @@ export function build_product_catalog(entries) {
|
|
|
9
18
|
product_id_by_number: {},
|
|
10
19
|
};
|
|
11
20
|
for (const { product_number, product } of entries) {
|
|
12
|
-
|
|
21
|
+
const catalog_product = catalog_product_from_join(product);
|
|
22
|
+
if (!catalog_product)
|
|
13
23
|
continue;
|
|
14
|
-
catalog.product_id_by_number[product_number] =
|
|
15
|
-
(_a = catalog.products)[_b =
|
|
24
|
+
catalog.product_id_by_number[product_number] = catalog_product.id;
|
|
25
|
+
(_a = catalog.products)[_b = catalog_product.id] ?? (_a[_b] = catalog_product);
|
|
16
26
|
}
|
|
17
27
|
return catalog;
|
|
18
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICatalogProduct, IProductNumber, ProductNumberInsert, ProductNumberUpdate } from "../types/db";
|
|
2
2
|
import { IWebResponseCompatible } from "../types/requests";
|
|
3
3
|
export declare function server_get_product_numbers_by_product(product_id: number): Promise<IWebResponseCompatible<IProductNumber[]>>;
|
|
4
4
|
export declare function server_get_product_number(product_number: string): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
5
|
-
export declare function server_get_product_for_product_number(product_number: string): Promise<IWebResponseCompatible<
|
|
5
|
+
export declare function server_get_product_for_product_number(product_number: string): Promise<IWebResponseCompatible<ICatalogProduct | null>>;
|
|
6
6
|
export declare function server_create_product_number(row: ProductNumberInsert): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
7
7
|
export declare function server_update_product_number(product_number: string, updates: ProductNumberUpdate): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import {
|
|
2
|
+
import { ICatalogProduct, IProductNumber, ProductNumberInsert, ProductNumberUpdate } from "../types/db";
|
|
3
3
|
import { IWebResponseCompatible } from "../types/requests";
|
|
4
4
|
import { Database } from "../types/supabase";
|
|
5
5
|
export declare function get_product_numbers_by_product_query(client: SupabaseClient<Database>, product_id: number): Promise<IWebResponseCompatible<IProductNumber[]>>;
|
|
6
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<
|
|
7
|
+
export declare function get_product_for_product_number_query(client: SupabaseClient<Database>, product_number: string): Promise<IWebResponseCompatible<ICatalogProduct | null>>;
|
|
8
8
|
export declare function create_product_number_query(client: SupabaseClient<Database>, row: ProductNumberInsert): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
9
9
|
export declare function update_product_number_query(client: SupabaseClient<Database>, product_number: string, updates: ProductNumberUpdate): Promise<IWebResponseCompatible<IProductNumber | null>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
import { catalog_product_from_join } from "./product_catalog";
|
|
2
3
|
export async function get_product_numbers_by_product_query(client, product_id) {
|
|
3
4
|
const { data, error } = await client
|
|
4
5
|
.from("product_numbers")
|
|
@@ -24,14 +25,13 @@ export async function get_product_number_query(client, product_number) {
|
|
|
24
25
|
export async function get_product_for_product_number_query(client, product_number) {
|
|
25
26
|
const { data, error } = await client
|
|
26
27
|
.from("product_numbers")
|
|
27
|
-
.select("products!product_numbers_product_id_fkey(
|
|
28
|
+
.select("products!product_numbers_product_id_fkey(*, manufacturers!products_manufacturer_id_fkey(name))")
|
|
28
29
|
.eq("product_number", product_number)
|
|
29
30
|
.maybeSingle();
|
|
30
31
|
if (error) {
|
|
31
32
|
return { status: EnumWebResponse.ERROR, msg: error.message, data: null };
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
return IWebResponse.success(product).to_compatible();
|
|
34
|
+
return IWebResponse.success(catalog_product_from_join(data?.products)).to_compatible();
|
|
35
35
|
}
|
|
36
36
|
export async function create_product_number_query(client, row) {
|
|
37
37
|
const { data, error } = await client
|
package/dist/store/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoadingPerformance } from "./scout";
|
|
2
|
-
import { IDevice, IPart,
|
|
2
|
+
import { ICatalogProduct, IDevice, IPart, IProductCatalog, ISessionSummary } from "../types/db";
|
|
3
3
|
export declare const useAppDispatch: import("react-redux").UseDispatch<import("redux").Dispatch<import("redux").UnknownAction>>;
|
|
4
4
|
export declare const useHerdModulesLoadingState: () => any;
|
|
5
5
|
export declare const useIsHerdModulesLoading: () => boolean;
|
|
@@ -11,6 +11,6 @@ export declare const useLoadingPerformance: () => LoadingPerformance;
|
|
|
11
11
|
export declare const useSessionSummariesByHerd: (herdId: number) => ISessionSummary | null;
|
|
12
12
|
export declare const useHasSessionSummaries: (herdId: number) => boolean;
|
|
13
13
|
export declare const useProductCatalog: () => IProductCatalog;
|
|
14
|
-
export declare const useProductForPart: (part: Pick<IPart, "product_number"> | null | undefined) =>
|
|
15
|
-
export declare const useProductsForDevice: (device: Pick<IDevice, "parts"> | null | undefined) =>
|
|
14
|
+
export declare const useProductForPart: (part: Pick<IPart, "product_number"> | null | undefined) => ICatalogProduct | null;
|
|
15
|
+
export declare const useProductsForDevice: (device: Pick<IDevice, "parts"> | null | undefined) => ICatalogProduct[];
|
|
16
16
|
export declare const useHerdModulesLoadingTimeAgo: () => string | null;
|
package/dist/types/db.d.ts
CHANGED
|
@@ -63,6 +63,10 @@ export type IProvider = Database["public"]["Tables"]["providers"]["Row"];
|
|
|
63
63
|
export type IPart = Database["public"]["Tables"]["parts"]["Row"];
|
|
64
64
|
export type IManufacturer = Database["public"]["Tables"]["manufacturers"]["Row"];
|
|
65
65
|
export type IProduct = Database["public"]["Tables"]["products"]["Row"];
|
|
66
|
+
/** Product in `IProductCatalog`, with manufacturer name from the products join. */
|
|
67
|
+
export type ICatalogProduct = IProduct & {
|
|
68
|
+
manufacturers?: Pick<IManufacturer, "name"> | null;
|
|
69
|
+
};
|
|
66
70
|
export type IProductNumber = Database["public"]["Tables"]["product_numbers"]["Row"];
|
|
67
71
|
export type IProductCompatibility = Database["public"]["Tables"]["product_compatibilities"]["Row"];
|
|
68
72
|
export type ISensorPose = Database["public"]["Tables"]["sensor_poses"]["Row"];
|
|
@@ -200,10 +204,10 @@ export type HerdOperatingPermissionCreateInput = Pick<HerdOperatingPermissionIns
|
|
|
200
204
|
export type HerdOperatingPermissionUpdateInput = Partial<Pick<HerdOperatingPermissionCreateInput, "operating_permission_id">> & LifecyclePatch;
|
|
201
205
|
/**
|
|
202
206
|
* Products stored once and shared by every part that references them
|
|
203
|
-
* (parts.product_number -> product_numbers -> products).
|
|
207
|
+
* (parts.product_number -> product_numbers -> products -> manufacturers).
|
|
204
208
|
*/
|
|
205
209
|
export interface IProductCatalog {
|
|
206
|
-
products: Record<number,
|
|
210
|
+
products: Record<number, ICatalogProduct>;
|
|
207
211
|
product_id_by_number: Record<string, number>;
|
|
208
212
|
}
|
|
209
213
|
export type IUserCredential = Database["public"]["Tables"]["user_credentials"]["Row"];
|
|
@@ -378,7 +382,7 @@ export type IFeedItem = {
|
|
|
378
382
|
event_data: (IEventAndTagsPrettyLocation & ISignedMediaUrls) | null;
|
|
379
383
|
artifact_data: IArtifactWithMediaUrl | null;
|
|
380
384
|
};
|
|
381
|
-
/** Lean merged events/artifacts row: media paths and
|
|
385
|
+
/** Lean merged events/artifacts row: media paths and duration, not `feed_item`'s arrays. */
|
|
382
386
|
export type IGalleryItemRow = Database["public"]["CompositeTypes"]["gallery_item"];
|
|
383
387
|
export type IGalleryItem = IGalleryItemRow & ISignedMediaUrls & {
|
|
384
388
|
media_kind: MediaKind;
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -7148,7 +7148,6 @@ export type Database = {
|
|
|
7148
7148
|
processing_blocked_reason: string | null;
|
|
7149
7149
|
latitude: number | null;
|
|
7150
7150
|
longitude: number | null;
|
|
7151
|
-
tag_count: number | null;
|
|
7152
7151
|
duration_seconds: number | null;
|
|
7153
7152
|
};
|
|
7154
7153
|
herd_invitation_with_herd_slug: {
|