@adventurelabs/scout-core 2.1.2 → 2.2.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/dist/helpers/connectivity.queries.js +40 -42
- package/dist/helpers/db.d.ts +3 -3
- 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/api.d.ts +48 -48
- package/dist/store/hooks.d.ts +3 -3
- package/dist/supabase/client.d.ts +3 -3
- package/dist/supabase/server.d.ts +3 -3
- package/dist/supabase/server.js +2 -1
- package/dist/types/db.d.ts +12 -3
- package/dist/types/extend.d.ts +126 -0
- package/dist/types/extend.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,35 +1,51 @@
|
|
|
1
1
|
import { EnumWebResponse, IWebResponse, } from "../types/requests";
|
|
2
|
+
function connectivityError(msg, data) {
|
|
3
|
+
return {
|
|
4
|
+
status: EnumWebResponse.ERROR,
|
|
5
|
+
msg,
|
|
6
|
+
data,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function herdRangeError(msg, offset) {
|
|
10
|
+
return {
|
|
11
|
+
...connectivityError(msg, []),
|
|
12
|
+
hasMore: false,
|
|
13
|
+
nextOffset: offset,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function connectivityTimestampMs(timestamp) {
|
|
17
|
+
if (!timestamp)
|
|
18
|
+
return null;
|
|
19
|
+
const time = new Date(timestamp).getTime();
|
|
20
|
+
return Number.isNaN(time) ? null : time;
|
|
21
|
+
}
|
|
2
22
|
function sortConnectivityByTimestamp(data) {
|
|
3
|
-
|
|
4
|
-
|
|
23
|
+
const withTimes = data.map((row) => ({
|
|
24
|
+
row,
|
|
25
|
+
time: connectivityTimestampMs(row.timestamp_start),
|
|
26
|
+
}));
|
|
27
|
+
withTimes.sort((a, b) => {
|
|
28
|
+
if (a.time == null || b.time == null)
|
|
5
29
|
return 0;
|
|
6
|
-
return
|
|
7
|
-
new Date(b.timestamp_start).getTime());
|
|
30
|
+
return a.time - b.time;
|
|
8
31
|
});
|
|
32
|
+
return withTimes.map(({ row }) => row);
|
|
9
33
|
}
|
|
10
34
|
export async function get_connectivity_by_session_id_query(client, sessionId) {
|
|
11
35
|
const { data, error } = await client.rpc("get_connectivity_with_coordinates", { session_id_caller: sessionId });
|
|
12
36
|
if (error) {
|
|
13
37
|
console.warn("Error fetching connectivity by session id:", error.message);
|
|
14
|
-
return
|
|
15
|
-
status: EnumWebResponse.ERROR,
|
|
16
|
-
msg: error.message,
|
|
17
|
-
data: [],
|
|
18
|
-
};
|
|
38
|
+
return connectivityError(error.message, []);
|
|
19
39
|
}
|
|
20
|
-
return IWebResponse.success(sortConnectivityByTimestamp(data
|
|
40
|
+
return IWebResponse.success(sortConnectivityByTimestamp(data ?? [])).to_compatible();
|
|
21
41
|
}
|
|
22
42
|
export async function get_connectivity_by_device_id_query(client, deviceId, timestamp) {
|
|
23
43
|
const { data, error } = await client.rpc("get_connectivity_with_coordinates_by_device_and_timestamp", { device_id_caller: deviceId, timestamp_filter: timestamp });
|
|
24
44
|
if (error) {
|
|
25
|
-
console.warn("Error fetching connectivity by
|
|
26
|
-
return
|
|
27
|
-
status: EnumWebResponse.ERROR,
|
|
28
|
-
msg: error.message,
|
|
29
|
-
data: [],
|
|
30
|
-
};
|
|
45
|
+
console.warn("Error fetching connectivity by device id:", error.message);
|
|
46
|
+
return connectivityError(error.message, []);
|
|
31
47
|
}
|
|
32
|
-
return IWebResponse.success(sortConnectivityByTimestamp(data
|
|
48
|
+
return IWebResponse.success(sortConnectivityByTimestamp(data ?? [])).to_compatible();
|
|
33
49
|
}
|
|
34
50
|
export async function insert_connectivity_query(client, connectivity) {
|
|
35
51
|
const connectivityArray = Array.isArray(connectivity)
|
|
@@ -41,13 +57,9 @@ export async function insert_connectivity_query(client, connectivity) {
|
|
|
41
57
|
.select("*");
|
|
42
58
|
if (error) {
|
|
43
59
|
console.warn("Error inserting connectivity:", error.message);
|
|
44
|
-
return
|
|
45
|
-
status: EnumWebResponse.ERROR,
|
|
46
|
-
msg: error.message,
|
|
47
|
-
data: [],
|
|
48
|
-
};
|
|
60
|
+
return connectivityError(error.message, []);
|
|
49
61
|
}
|
|
50
|
-
return IWebResponse.success(data
|
|
62
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
51
63
|
}
|
|
52
64
|
export async function update_connectivity_query(client, connectivity) {
|
|
53
65
|
const connectivityArray = Array.isArray(connectivity)
|
|
@@ -65,11 +77,7 @@ export async function update_connectivity_query(client, connectivity) {
|
|
|
65
77
|
.single();
|
|
66
78
|
if (error) {
|
|
67
79
|
console.warn("Error updating connectivity:", error.message);
|
|
68
|
-
return
|
|
69
|
-
status: EnumWebResponse.ERROR,
|
|
70
|
-
msg: error.message,
|
|
71
|
-
data: [],
|
|
72
|
-
};
|
|
80
|
+
return connectivityError(error.message, []);
|
|
73
81
|
}
|
|
74
82
|
if (data) {
|
|
75
83
|
updatedConnectivity.push(data);
|
|
@@ -87,15 +95,9 @@ export async function get_connectivity_for_herd_time_range_query(client, herdId,
|
|
|
87
95
|
});
|
|
88
96
|
if (error) {
|
|
89
97
|
console.warn("Error fetching connectivity for herd time range:", error.message);
|
|
90
|
-
return
|
|
91
|
-
status: EnumWebResponse.ERROR,
|
|
92
|
-
msg: error.message,
|
|
93
|
-
data: [],
|
|
94
|
-
hasMore: false,
|
|
95
|
-
nextOffset: offset,
|
|
96
|
-
};
|
|
98
|
+
return herdRangeError(error.message, offset);
|
|
97
99
|
}
|
|
98
|
-
const sorted = sortConnectivityByTimestamp(data
|
|
100
|
+
const sorted = sortConnectivityByTimestamp(data ?? []);
|
|
99
101
|
const hasMore = sorted.length > maxCount;
|
|
100
102
|
const items = hasMore ? sorted.slice(0, maxCount) : sorted;
|
|
101
103
|
return {
|
|
@@ -111,11 +113,7 @@ export async function get_connectivity_for_artifact_query(client, artifactId, ma
|
|
|
111
113
|
});
|
|
112
114
|
if (error) {
|
|
113
115
|
console.warn("Error fetching connectivity for artifact:", error.message);
|
|
114
|
-
return
|
|
115
|
-
status: EnumWebResponse.ERROR,
|
|
116
|
-
msg: error.message,
|
|
117
|
-
data: [],
|
|
118
|
-
};
|
|
116
|
+
return connectivityError(error.message, []);
|
|
119
117
|
}
|
|
120
|
-
return IWebResponse.success(sortConnectivityByTimestamp(data
|
|
118
|
+
return IWebResponse.success(sortConnectivityByTimestamp(data ?? [])).to_compatible();
|
|
121
119
|
}
|
package/dist/helpers/db.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare function createClientWithApiKey(user_api_key: string):
|
|
1
|
+
import type { AnyScoutDatabase, ScoutDatabase } from "../types/extend";
|
|
2
|
+
import type { ScoutDatabaseClient } from "../types/db";
|
|
3
|
+
export declare function createClientWithApiKey<DB extends AnyScoutDatabase = ScoutDatabase>(user_api_key: string): ScoutDatabaseClient<DB> | null;
|
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/api.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
175
175
|
isFetching: false;
|
|
176
176
|
isSuccess: false;
|
|
177
177
|
isError: false;
|
|
178
|
-
}, "
|
|
178
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
179
179
|
isSuccess: true;
|
|
180
180
|
isFetching: true;
|
|
181
181
|
error: undefined;
|
|
@@ -199,7 +199,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
199
199
|
isFetching: false;
|
|
200
200
|
isSuccess: false;
|
|
201
201
|
isError: false;
|
|
202
|
-
}, "
|
|
202
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
203
203
|
isSuccess: true;
|
|
204
204
|
isFetching: false;
|
|
205
205
|
error: undefined;
|
|
@@ -284,7 +284,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
284
284
|
isFetching: false;
|
|
285
285
|
isSuccess: false;
|
|
286
286
|
isError: false;
|
|
287
|
-
}, "
|
|
287
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
288
288
|
isSuccess: true;
|
|
289
289
|
isFetching: true;
|
|
290
290
|
error: undefined;
|
|
@@ -308,7 +308,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
308
308
|
isFetching: false;
|
|
309
309
|
isSuccess: false;
|
|
310
310
|
isError: false;
|
|
311
|
-
}, "
|
|
311
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
312
312
|
isSuccess: true;
|
|
313
313
|
isFetching: false;
|
|
314
314
|
error: undefined;
|
|
@@ -391,7 +391,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
391
391
|
isFetching: false;
|
|
392
392
|
isSuccess: false;
|
|
393
393
|
isError: false;
|
|
394
|
-
}, "
|
|
394
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
395
395
|
isSuccess: true;
|
|
396
396
|
isFetching: true;
|
|
397
397
|
error: undefined;
|
|
@@ -415,7 +415,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
415
415
|
isFetching: false;
|
|
416
416
|
isSuccess: false;
|
|
417
417
|
isError: false;
|
|
418
|
-
}, "
|
|
418
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
419
419
|
isSuccess: true;
|
|
420
420
|
isFetching: false;
|
|
421
421
|
error: undefined;
|
|
@@ -500,7 +500,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
500
500
|
isFetching: false;
|
|
501
501
|
isSuccess: false;
|
|
502
502
|
isError: false;
|
|
503
|
-
}, "
|
|
503
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
504
504
|
isSuccess: true;
|
|
505
505
|
isFetching: true;
|
|
506
506
|
error: undefined;
|
|
@@ -524,7 +524,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
524
524
|
isFetching: false;
|
|
525
525
|
isSuccess: false;
|
|
526
526
|
isError: false;
|
|
527
|
-
}, "
|
|
527
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
528
528
|
isSuccess: true;
|
|
529
529
|
isFetching: false;
|
|
530
530
|
error: undefined;
|
|
@@ -607,7 +607,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
607
607
|
isFetching: false;
|
|
608
608
|
isSuccess: false;
|
|
609
609
|
isError: false;
|
|
610
|
-
}, "
|
|
610
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
611
611
|
isSuccess: true;
|
|
612
612
|
isFetching: true;
|
|
613
613
|
error: undefined;
|
|
@@ -631,7 +631,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
631
631
|
isFetching: false;
|
|
632
632
|
isSuccess: false;
|
|
633
633
|
isError: false;
|
|
634
|
-
}, "
|
|
634
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
635
635
|
isSuccess: true;
|
|
636
636
|
isFetching: false;
|
|
637
637
|
error: undefined;
|
|
@@ -716,7 +716,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
716
716
|
isFetching: false;
|
|
717
717
|
isSuccess: false;
|
|
718
718
|
isError: false;
|
|
719
|
-
}, "
|
|
719
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
720
720
|
isSuccess: true;
|
|
721
721
|
isFetching: true;
|
|
722
722
|
error: undefined;
|
|
@@ -740,7 +740,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
740
740
|
isFetching: false;
|
|
741
741
|
isSuccess: false;
|
|
742
742
|
isError: false;
|
|
743
|
-
}, "
|
|
743
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
744
744
|
isSuccess: true;
|
|
745
745
|
isFetching: false;
|
|
746
746
|
error: undefined;
|
|
@@ -823,7 +823,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
823
823
|
isFetching: false;
|
|
824
824
|
isSuccess: false;
|
|
825
825
|
isError: false;
|
|
826
|
-
}, "
|
|
826
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
827
827
|
isSuccess: true;
|
|
828
828
|
isFetching: true;
|
|
829
829
|
error: undefined;
|
|
@@ -847,7 +847,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
847
847
|
isFetching: false;
|
|
848
848
|
isSuccess: false;
|
|
849
849
|
isError: false;
|
|
850
|
-
}, "
|
|
850
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
851
851
|
isSuccess: true;
|
|
852
852
|
isFetching: false;
|
|
853
853
|
error: undefined;
|
|
@@ -932,7 +932,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
932
932
|
isFetching: false;
|
|
933
933
|
isSuccess: false;
|
|
934
934
|
isError: false;
|
|
935
|
-
}, "
|
|
935
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
936
936
|
isSuccess: true;
|
|
937
937
|
isFetching: true;
|
|
938
938
|
error: undefined;
|
|
@@ -956,7 +956,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
956
956
|
isFetching: false;
|
|
957
957
|
isSuccess: false;
|
|
958
958
|
isError: false;
|
|
959
|
-
}, "
|
|
959
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
960
960
|
isSuccess: true;
|
|
961
961
|
isFetching: false;
|
|
962
962
|
error: undefined;
|
|
@@ -1039,7 +1039,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1039
1039
|
isFetching: false;
|
|
1040
1040
|
isSuccess: false;
|
|
1041
1041
|
isError: false;
|
|
1042
|
-
}, "
|
|
1042
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1043
1043
|
isSuccess: true;
|
|
1044
1044
|
isFetching: true;
|
|
1045
1045
|
error: undefined;
|
|
@@ -1063,7 +1063,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1063
1063
|
isFetching: false;
|
|
1064
1064
|
isSuccess: false;
|
|
1065
1065
|
isError: false;
|
|
1066
|
-
}, "
|
|
1066
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1067
1067
|
isSuccess: true;
|
|
1068
1068
|
isFetching: false;
|
|
1069
1069
|
error: undefined;
|
|
@@ -1148,7 +1148,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1148
1148
|
isFetching: false;
|
|
1149
1149
|
isSuccess: false;
|
|
1150
1150
|
isError: false;
|
|
1151
|
-
}, "
|
|
1151
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1152
1152
|
isSuccess: true;
|
|
1153
1153
|
isFetching: true;
|
|
1154
1154
|
error: undefined;
|
|
@@ -1172,7 +1172,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1172
1172
|
isFetching: false;
|
|
1173
1173
|
isSuccess: false;
|
|
1174
1174
|
isError: false;
|
|
1175
|
-
}, "
|
|
1175
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1176
1176
|
isSuccess: true;
|
|
1177
1177
|
isFetching: false;
|
|
1178
1178
|
error: undefined;
|
|
@@ -1255,7 +1255,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1255
1255
|
isFetching: false;
|
|
1256
1256
|
isSuccess: false;
|
|
1257
1257
|
isError: false;
|
|
1258
|
-
}, "
|
|
1258
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1259
1259
|
isSuccess: true;
|
|
1260
1260
|
isFetching: true;
|
|
1261
1261
|
error: undefined;
|
|
@@ -1279,7 +1279,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1279
1279
|
isFetching: false;
|
|
1280
1280
|
isSuccess: false;
|
|
1281
1281
|
isError: false;
|
|
1282
|
-
}, "
|
|
1282
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1283
1283
|
isSuccess: true;
|
|
1284
1284
|
isFetching: false;
|
|
1285
1285
|
error: undefined;
|
|
@@ -1364,7 +1364,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1364
1364
|
isFetching: false;
|
|
1365
1365
|
isSuccess: false;
|
|
1366
1366
|
isError: false;
|
|
1367
|
-
}, "
|
|
1367
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1368
1368
|
isSuccess: true;
|
|
1369
1369
|
isFetching: true;
|
|
1370
1370
|
error: undefined;
|
|
@@ -1388,7 +1388,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1388
1388
|
isFetching: false;
|
|
1389
1389
|
isSuccess: false;
|
|
1390
1390
|
isError: false;
|
|
1391
|
-
}, "
|
|
1391
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1392
1392
|
isSuccess: true;
|
|
1393
1393
|
isFetching: false;
|
|
1394
1394
|
error: undefined;
|
|
@@ -1467,7 +1467,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1467
1467
|
isFetching: false;
|
|
1468
1468
|
isSuccess: false;
|
|
1469
1469
|
isError: false;
|
|
1470
|
-
}, "
|
|
1470
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1471
1471
|
isSuccess: true;
|
|
1472
1472
|
isFetching: true;
|
|
1473
1473
|
error: undefined;
|
|
@@ -1487,7 +1487,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1487
1487
|
isFetching: false;
|
|
1488
1488
|
isSuccess: false;
|
|
1489
1489
|
isError: false;
|
|
1490
|
-
}, "
|
|
1490
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1491
1491
|
isSuccess: true;
|
|
1492
1492
|
isFetching: false;
|
|
1493
1493
|
error: undefined;
|
|
@@ -1560,7 +1560,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1560
1560
|
isFetching: false;
|
|
1561
1561
|
isSuccess: false;
|
|
1562
1562
|
isError: false;
|
|
1563
|
-
}, "
|
|
1563
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1564
1564
|
isSuccess: true;
|
|
1565
1565
|
isFetching: true;
|
|
1566
1566
|
error: undefined;
|
|
@@ -1580,7 +1580,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1580
1580
|
isFetching: false;
|
|
1581
1581
|
isSuccess: false;
|
|
1582
1582
|
isError: false;
|
|
1583
|
-
}, "
|
|
1583
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1584
1584
|
isSuccess: true;
|
|
1585
1585
|
isFetching: false;
|
|
1586
1586
|
error: undefined;
|
|
@@ -1651,7 +1651,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1651
1651
|
isFetching: false;
|
|
1652
1652
|
isSuccess: false;
|
|
1653
1653
|
isError: false;
|
|
1654
|
-
}, "
|
|
1654
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1655
1655
|
isSuccess: true;
|
|
1656
1656
|
isFetching: true;
|
|
1657
1657
|
error: undefined;
|
|
@@ -1671,7 +1671,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1671
1671
|
isFetching: false;
|
|
1672
1672
|
isSuccess: false;
|
|
1673
1673
|
isError: false;
|
|
1674
|
-
}, "
|
|
1674
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1675
1675
|
isSuccess: true;
|
|
1676
1676
|
isFetching: false;
|
|
1677
1677
|
error: undefined;
|
|
@@ -1744,7 +1744,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1744
1744
|
isFetching: false;
|
|
1745
1745
|
isSuccess: false;
|
|
1746
1746
|
isError: false;
|
|
1747
|
-
}, "
|
|
1747
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1748
1748
|
isSuccess: true;
|
|
1749
1749
|
isFetching: true;
|
|
1750
1750
|
error: undefined;
|
|
@@ -1764,7 +1764,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1764
1764
|
isFetching: false;
|
|
1765
1765
|
isSuccess: false;
|
|
1766
1766
|
isError: false;
|
|
1767
|
-
}, "
|
|
1767
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1768
1768
|
isSuccess: true;
|
|
1769
1769
|
isFetching: false;
|
|
1770
1770
|
error: undefined;
|
|
@@ -1835,7 +1835,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1835
1835
|
isFetching: false;
|
|
1836
1836
|
isSuccess: false;
|
|
1837
1837
|
isError: false;
|
|
1838
|
-
}, "
|
|
1838
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1839
1839
|
isSuccess: true;
|
|
1840
1840
|
isFetching: true;
|
|
1841
1841
|
error: undefined;
|
|
@@ -1855,7 +1855,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1855
1855
|
isFetching: false;
|
|
1856
1856
|
isSuccess: false;
|
|
1857
1857
|
isError: false;
|
|
1858
|
-
}, "
|
|
1858
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1859
1859
|
isSuccess: true;
|
|
1860
1860
|
isFetching: false;
|
|
1861
1861
|
error: undefined;
|
|
@@ -1928,7 +1928,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1928
1928
|
isFetching: false;
|
|
1929
1929
|
isSuccess: false;
|
|
1930
1930
|
isError: false;
|
|
1931
|
-
}, "
|
|
1931
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
1932
1932
|
isSuccess: true;
|
|
1933
1933
|
isFetching: true;
|
|
1934
1934
|
error: undefined;
|
|
@@ -1948,7 +1948,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
1948
1948
|
isFetching: false;
|
|
1949
1949
|
isSuccess: false;
|
|
1950
1950
|
isError: false;
|
|
1951
|
-
}, "
|
|
1951
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
1952
1952
|
isSuccess: true;
|
|
1953
1953
|
isFetching: false;
|
|
1954
1954
|
error: undefined;
|
|
@@ -2019,7 +2019,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2019
2019
|
isFetching: false;
|
|
2020
2020
|
isSuccess: false;
|
|
2021
2021
|
isError: false;
|
|
2022
|
-
}, "
|
|
2022
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2023
2023
|
isSuccess: true;
|
|
2024
2024
|
isFetching: true;
|
|
2025
2025
|
error: undefined;
|
|
@@ -2039,7 +2039,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2039
2039
|
isFetching: false;
|
|
2040
2040
|
isSuccess: false;
|
|
2041
2041
|
isError: false;
|
|
2042
|
-
}, "
|
|
2042
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2043
2043
|
isSuccess: true;
|
|
2044
2044
|
isFetching: false;
|
|
2045
2045
|
error: undefined;
|
|
@@ -2112,7 +2112,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2112
2112
|
isFetching: false;
|
|
2113
2113
|
isSuccess: false;
|
|
2114
2114
|
isError: false;
|
|
2115
|
-
}, "
|
|
2115
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2116
2116
|
isSuccess: true;
|
|
2117
2117
|
isFetching: true;
|
|
2118
2118
|
error: undefined;
|
|
@@ -2132,7 +2132,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2132
2132
|
isFetching: false;
|
|
2133
2133
|
isSuccess: false;
|
|
2134
2134
|
isError: false;
|
|
2135
|
-
}, "
|
|
2135
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2136
2136
|
isSuccess: true;
|
|
2137
2137
|
isFetching: false;
|
|
2138
2138
|
error: undefined;
|
|
@@ -2203,7 +2203,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2203
2203
|
isFetching: false;
|
|
2204
2204
|
isSuccess: false;
|
|
2205
2205
|
isError: false;
|
|
2206
|
-
}, "
|
|
2206
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2207
2207
|
isSuccess: true;
|
|
2208
2208
|
isFetching: true;
|
|
2209
2209
|
error: undefined;
|
|
@@ -2223,7 +2223,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2223
2223
|
isFetching: false;
|
|
2224
2224
|
isSuccess: false;
|
|
2225
2225
|
isError: false;
|
|
2226
|
-
}, "
|
|
2226
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2227
2227
|
isSuccess: true;
|
|
2228
2228
|
isFetching: false;
|
|
2229
2229
|
error: undefined;
|
|
@@ -2296,7 +2296,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2296
2296
|
isFetching: false;
|
|
2297
2297
|
isSuccess: false;
|
|
2298
2298
|
isError: false;
|
|
2299
|
-
}, "
|
|
2299
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2300
2300
|
isSuccess: true;
|
|
2301
2301
|
isFetching: true;
|
|
2302
2302
|
error: undefined;
|
|
@@ -2316,7 +2316,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2316
2316
|
isFetching: false;
|
|
2317
2317
|
isSuccess: false;
|
|
2318
2318
|
isError: false;
|
|
2319
|
-
}, "
|
|
2319
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2320
2320
|
isSuccess: true;
|
|
2321
2321
|
isFetching: false;
|
|
2322
2322
|
error: undefined;
|
|
@@ -2387,7 +2387,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2387
2387
|
isFetching: false;
|
|
2388
2388
|
isSuccess: false;
|
|
2389
2389
|
isError: false;
|
|
2390
|
-
}, "
|
|
2390
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2391
2391
|
isSuccess: true;
|
|
2392
2392
|
isFetching: true;
|
|
2393
2393
|
error: undefined;
|
|
@@ -2407,7 +2407,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2407
2407
|
isFetching: false;
|
|
2408
2408
|
isSuccess: false;
|
|
2409
2409
|
isError: false;
|
|
2410
|
-
}, "
|
|
2410
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2411
2411
|
isSuccess: true;
|
|
2412
2412
|
isFetching: false;
|
|
2413
2413
|
error: undefined;
|
|
@@ -2480,7 +2480,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2480
2480
|
isFetching: false;
|
|
2481
2481
|
isSuccess: false;
|
|
2482
2482
|
isError: false;
|
|
2483
|
-
}, "
|
|
2483
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "isFetching" | "isSuccess"> & {
|
|
2484
2484
|
isSuccess: true;
|
|
2485
2485
|
isFetching: true;
|
|
2486
2486
|
error: undefined;
|
|
@@ -2500,7 +2500,7 @@ export declare const useGetSessionsInfiniteByHerdQuery: <R extends Record<string
|
|
|
2500
2500
|
isFetching: false;
|
|
2501
2501
|
isSuccess: false;
|
|
2502
2502
|
isError: false;
|
|
2503
|
-
}, "
|
|
2503
|
+
}, "error" | "data" | "fulfilledTimeStamp" | "currentData" | "isFetching" | "isSuccess"> & {
|
|
2504
2504
|
isSuccess: true;
|
|
2505
2505
|
isFetching: false;
|
|
2506
2506
|
error: undefined;
|
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;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createScoutBrowserClient():
|
|
1
|
+
import type { AnyScoutDatabase, ScoutDatabase } from "../types/extend";
|
|
2
|
+
import type { ScoutDatabaseClient } from "../types/db";
|
|
3
|
+
export declare function createScoutBrowserClient<DB extends AnyScoutDatabase = ScoutDatabase>(): ScoutDatabaseClient<DB>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { AnyScoutDatabase, ScoutDatabase } from "../types/extend";
|
|
3
|
+
import type { ScoutDatabaseClient } from "../types/db";
|
|
4
4
|
export interface IServerClientOptions {
|
|
5
5
|
persistSession?: boolean;
|
|
6
6
|
}
|
|
@@ -8,4 +8,4 @@ export interface IServerClientOptions {
|
|
|
8
8
|
* Reuses one read client per RSC request. Cookie writes are opt-in for
|
|
9
9
|
* auth-mutating actions; middleware persists normal session refreshes.
|
|
10
10
|
*/
|
|
11
|
-
export declare function newServerClient(options?: IServerClientOptions): Promise<
|
|
11
|
+
export declare function newServerClient<DB extends AnyScoutDatabase = ScoutDatabase>(options?: IServerClientOptions): Promise<ScoutDatabaseClient<DB>>;
|
package/dist/supabase/server.js
CHANGED
|
@@ -31,5 +31,6 @@ const cachedRequestClient = cache(() => createRequestClient({}));
|
|
|
31
31
|
export function newServerClient(options = {}) {
|
|
32
32
|
return options.persistSession
|
|
33
33
|
? createRequestClient(options)
|
|
34
|
-
:
|
|
34
|
+
: // The schema only exists at compile time, so the cached client serves any extension of it.
|
|
35
|
+
cachedRequestClient();
|
|
35
36
|
}
|
package/dist/types/db.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { SupabaseClient, User } from "@supabase/supabase-js";
|
|
2
2
|
import type { Database } from "./supabase";
|
|
3
|
-
|
|
3
|
+
import type { AnyScoutDatabase, ScoutDatabase } from "./extend";
|
|
4
|
+
/**
|
|
5
|
+
* A Supabase client over Scout's schema, or over any deployment schema that extends it (see
|
|
6
|
+
* `ExtendDatabase`). Scout helpers accept both.
|
|
7
|
+
*/
|
|
8
|
+
export type ScoutDatabaseClient<DB extends AnyScoutDatabase = ScoutDatabase> = SupabaseClient<DB>;
|
|
4
9
|
export type DeviceType = Database["public"]["Enums"]["device_type"];
|
|
5
10
|
export type MediaType = Database["public"]["Enums"]["media_type"];
|
|
6
11
|
export type TagObservationType = Database["public"]["Enums"]["tag_observation_type"];
|
|
@@ -63,6 +68,10 @@ export type IProvider = Database["public"]["Tables"]["providers"]["Row"];
|
|
|
63
68
|
export type IPart = Database["public"]["Tables"]["parts"]["Row"];
|
|
64
69
|
export type IManufacturer = Database["public"]["Tables"]["manufacturers"]["Row"];
|
|
65
70
|
export type IProduct = Database["public"]["Tables"]["products"]["Row"];
|
|
71
|
+
/** Product in `IProductCatalog`, with manufacturer name from the products join. */
|
|
72
|
+
export type ICatalogProduct = IProduct & {
|
|
73
|
+
manufacturers?: Pick<IManufacturer, "name"> | null;
|
|
74
|
+
};
|
|
66
75
|
export type IProductNumber = Database["public"]["Tables"]["product_numbers"]["Row"];
|
|
67
76
|
export type IProductCompatibility = Database["public"]["Tables"]["product_compatibilities"]["Row"];
|
|
68
77
|
export type ISensorPose = Database["public"]["Tables"]["sensor_poses"]["Row"];
|
|
@@ -200,10 +209,10 @@ export type HerdOperatingPermissionCreateInput = Pick<HerdOperatingPermissionIns
|
|
|
200
209
|
export type HerdOperatingPermissionUpdateInput = Partial<Pick<HerdOperatingPermissionCreateInput, "operating_permission_id">> & LifecyclePatch;
|
|
201
210
|
/**
|
|
202
211
|
* Products stored once and shared by every part that references them
|
|
203
|
-
* (parts.product_number -> product_numbers -> products).
|
|
212
|
+
* (parts.product_number -> product_numbers -> products -> manufacturers).
|
|
204
213
|
*/
|
|
205
214
|
export interface IProductCatalog {
|
|
206
|
-
products: Record<number,
|
|
215
|
+
products: Record<number, ICatalogProduct>;
|
|
207
216
|
product_id_by_number: Record<string, number>;
|
|
208
217
|
}
|
|
209
218
|
export type IUserCredential = Database["public"]["Tables"]["user_credentials"]["Row"];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { DatabaseWithoutInternals } from "@supabase/supabase-js";
|
|
2
|
+
import type { Database } from "./supabase";
|
|
3
|
+
/**
|
|
4
|
+
* Scout's generated schema. Deployments that add their own tables, views, functions, enums or
|
|
5
|
+
* composite types describe the additions with `ExtendDatabase` instead of replacing this, so
|
|
6
|
+
* Scout's own helpers keep working against the same client.
|
|
7
|
+
*/
|
|
8
|
+
export type ScoutDatabase = Database;
|
|
9
|
+
/**
|
|
10
|
+
* What Scout requires of a deployment's schema: that it covers Scout's own. Generator metadata
|
|
11
|
+
* is excluded because `__InternalSupabase` pins the PostgREST version the types were generated
|
|
12
|
+
* against, and a deployment that runs its own `supabase gen types` will not report Scout's.
|
|
13
|
+
*/
|
|
14
|
+
export type AnyScoutDatabase = DatabaseWithoutInternals<ScoutDatabase>;
|
|
15
|
+
type ScoutSchema = ScoutDatabase["public"];
|
|
16
|
+
/**
|
|
17
|
+
* A foreign key reachable from a table, as the Supabase generator emits it. Mirrors PostgREST's
|
|
18
|
+
* own `GenericRelationship`, which the package declares but does not export.
|
|
19
|
+
*/
|
|
20
|
+
export interface TableRelationship {
|
|
21
|
+
foreignKeyName: string;
|
|
22
|
+
columns: string[];
|
|
23
|
+
isOneToOne?: boolean;
|
|
24
|
+
referencedRelation: string;
|
|
25
|
+
referencedColumns: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A table (or updatable view) a deployment adds. Only `Row` is required.
|
|
29
|
+
*
|
|
30
|
+
* Declare row shapes as type aliases, not interfaces: PostgREST needs an index signature to
|
|
31
|
+
* resolve a schema, and TypeScript only infers one for aliases. Loosening this constraint does
|
|
32
|
+
* not help, it just trades this error for a silently untyped client.
|
|
33
|
+
*/
|
|
34
|
+
export interface TableExtension {
|
|
35
|
+
Row: Record<string, unknown>;
|
|
36
|
+
Insert?: Record<string, unknown>;
|
|
37
|
+
Update?: Record<string, unknown>;
|
|
38
|
+
Relationships?: TableRelationship[];
|
|
39
|
+
}
|
|
40
|
+
/** A PostgREST function a deployment adds, as reached through `client.rpc(...)`. */
|
|
41
|
+
export interface FunctionExtension {
|
|
42
|
+
Args: Record<string, unknown>;
|
|
43
|
+
Returns: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** Everything a deployment adds to the `public` schema on top of Scout's. */
|
|
46
|
+
export interface SchemaExtension {
|
|
47
|
+
Tables?: Record<string, TableExtension>;
|
|
48
|
+
Views?: Record<string, TableExtension>;
|
|
49
|
+
Functions?: Record<string, FunctionExtension>;
|
|
50
|
+
Enums?: Record<string, string>;
|
|
51
|
+
CompositeTypes?: Record<string, Record<string, unknown>>;
|
|
52
|
+
}
|
|
53
|
+
type Added<Ext extends SchemaExtension, K extends keyof SchemaExtension> = K extends keyof Ext ? Exclude<Ext[K], undefined> : {};
|
|
54
|
+
/** Supplies the `Insert`/`Update`/`Relationships` members the Supabase generator would emit. */
|
|
55
|
+
type NormalizeTables<T> = {
|
|
56
|
+
[K in keyof T]: {
|
|
57
|
+
Row: T[K] extends {
|
|
58
|
+
Row: infer R;
|
|
59
|
+
} ? R : never;
|
|
60
|
+
Insert: T[K] extends {
|
|
61
|
+
Insert: infer I;
|
|
62
|
+
} ? I : T[K] extends {
|
|
63
|
+
Row: infer R;
|
|
64
|
+
} ? R : never;
|
|
65
|
+
Update: T[K] extends {
|
|
66
|
+
Update: infer U;
|
|
67
|
+
} ? U : T[K] extends {
|
|
68
|
+
Row: infer R;
|
|
69
|
+
} ? Partial<R> : never;
|
|
70
|
+
Relationships: T[K] extends {
|
|
71
|
+
Relationships: infer L;
|
|
72
|
+
} ? L : [];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
type NormalizeViews<T> = {
|
|
76
|
+
[K in keyof T]: Omit<T[K], "Relationships"> & {
|
|
77
|
+
Relationships: T[K] extends {
|
|
78
|
+
Relationships: infer L;
|
|
79
|
+
} ? L : [];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Merges a deployment's additions into Scout's schema. The result stays assignable to
|
|
84
|
+
* `ScoutDatabase`, so a client built from it satisfies every Scout helper while also typing the
|
|
85
|
+
* deployment's own tables and RPCs.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* type AppDatabase = ExtendDatabase<{
|
|
89
|
+
* Tables: { field_notes: { Row: { id: number; body: string } } };
|
|
90
|
+
* Functions: { notes_for_herd: { Args: { herd_id: number }; Returns: { id: number }[] } };
|
|
91
|
+
* }>;
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* Each member intersects rather than being merged with a mapped type. Intersecting leaves
|
|
95
|
+
* Scout's schema as one constituent that resolves lazily, so the constraint check short-circuits
|
|
96
|
+
* on its identity; a mapped merge has to walk all of it eagerly and measured ~49% more type
|
|
97
|
+
* instantiations. The cost is that hover text shows the intersection unreduced.
|
|
98
|
+
*/
|
|
99
|
+
export type ExtendDatabase<Ext extends SchemaExtension> = Omit<ScoutDatabase, "public"> & {
|
|
100
|
+
public: {
|
|
101
|
+
Tables: ScoutSchema["Tables"] & NormalizeTables<Added<Ext, "Tables">>;
|
|
102
|
+
Views: ScoutSchema["Views"] & NormalizeViews<Added<Ext, "Views">>;
|
|
103
|
+
Functions: ScoutSchema["Functions"] & Added<Ext, "Functions">;
|
|
104
|
+
Enums: ScoutSchema["Enums"] & Added<Ext, "Enums">;
|
|
105
|
+
CompositeTypes: ScoutSchema["CompositeTypes"] & Added<Ext, "CompositeTypes">;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Adopts a schema a deployment generated from its own project, for deployments whose own
|
|
110
|
+
* `supabase gen types` run already covers Scout's tables alongside theirs.
|
|
111
|
+
*
|
|
112
|
+
* Only the generator metadata is rewritten. `supabase gen types` records the PostgREST version
|
|
113
|
+
* of the project it ran against, and `SupabaseClient` carries that version in its own type, so a
|
|
114
|
+
* deployment on a different version would otherwise produce a client no Scout helper accepts
|
|
115
|
+
* even though the schemas agree. Scout's helpers are written against Scout's PostgREST
|
|
116
|
+
* regardless. The `AnyScoutDatabase` constraint still rejects a schema that does not cover
|
|
117
|
+
* Scout's.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* import type { Database as Generated } from "@/types/supabase";
|
|
121
|
+
*
|
|
122
|
+
* export type AppDatabase = AdoptDatabase<Generated>;
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export type AdoptDatabase<DB extends AnyScoutDatabase> = Omit<DB, "__InternalSupabase"> & Pick<ScoutDatabase, "__InternalSupabase">;
|
|
126
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED