@brownandroot/api 0.15.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -4
- package/dist/businessUnits.remote.d.ts +4 -0
- package/dist/businessUnits.remote.js +7 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +21 -0
- package/dist/costcodes.remote.d.ts +9 -0
- package/dist/costcodes.remote.js +13 -0
- package/dist/employees.remote.d.ts +18 -0
- package/dist/employees.remote.js +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +12 -0
- package/dist/jobtypejobsteps.remote.d.ts +3 -0
- package/dist/jobtypejobsteps.remote.js +6 -0
- package/dist/llm.remote.d.ts +12 -0
- package/dist/llm.remote.js +17 -0
- package/dist/paytypes.remote.d.ts +4 -0
- package/dist/paytypes.remote.js +7 -0
- package/dist/rag.remote.d.ts +11 -0
- package/dist/rag.remote.js +16 -0
- package/dist/workorders.remote.d.ts +5 -0
- package/dist/workorders.remote.js +8 -0
- package/package.json +58 -6
package/README.md
CHANGED
|
@@ -8,7 +8,65 @@ TypeScript client for the Brown & Root APIHub data service. Provides access to e
|
|
|
8
8
|
npm install @brownandroot/api
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## SvelteKit Remote Functions
|
|
14
|
+
|
|
15
|
+
For SvelteKit apps, the package ships ready-to-use remote functions that run on the server and read credentials from environment variables automatically — no manual client instantiation needed.
|
|
16
|
+
|
|
17
|
+
### Setup
|
|
18
|
+
|
|
19
|
+
Add to your app's `.env`:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
APIHUB_URL=https://your-apihub-url.com
|
|
23
|
+
APIHUB_API_KEY=your-api-key
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Enable remote functions in `svelte.config.js` (if not already):
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
kit: {
|
|
30
|
+
experimental: { remoteFunctions: true }
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Usage
|
|
35
|
+
|
|
36
|
+
Import directly from the domain sub-path and call in components:
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
import { getEmployeesDropdown } from '@brownandroot/api/employees'
|
|
41
|
+
import { getBusinessUnitsDropdown } from '@brownandroot/api/businessUnits'
|
|
42
|
+
|
|
43
|
+
const employees = $derived(await getEmployeesDropdown())
|
|
44
|
+
const businessUnits = $derived(await getBusinessUnitsDropdown())
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or compose with your own remote functions:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { query } from '$app/server'
|
|
52
|
+
import { getSupervisorChain } from '@brownandroot/api/employees'
|
|
53
|
+
|
|
54
|
+
export const getMyManagers = query(async () => {
|
|
55
|
+
return (await getSupervisorChain('12345')).slice(0, 2)
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Available sub-paths:** `employees`, `businessUnits`, `costcodes`, `paytypes`, `workorders`, `jobtypejobsteps`, `llm`, `rag`
|
|
60
|
+
|
|
61
|
+
> `chatStream` is not available as a remote function — use `ApiHubClient` directly to proxy the SSE response.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## ApiHubClient (direct usage)
|
|
66
|
+
|
|
67
|
+
For non-SvelteKit environments or when you need full control (caching, streaming):
|
|
68
|
+
|
|
69
|
+
### Setup
|
|
12
70
|
|
|
13
71
|
```typescript
|
|
14
72
|
import { ApiHubClient } from '@brownandroot/api'
|
|
@@ -171,6 +229,9 @@ interface Employee {
|
|
|
171
229
|
const units = await client.getBusinessUnits()
|
|
172
230
|
const dropdown = await client.getBusinessUnitsDropdown() // { value, label }[]
|
|
173
231
|
const unit = await client.getBusinessUnit('BU001')
|
|
232
|
+
|
|
233
|
+
// Search by description (case-insensitive partial match)
|
|
234
|
+
const results = await client.searchBusinessUnits('west')
|
|
174
235
|
```
|
|
175
236
|
|
|
176
237
|
---
|
|
@@ -183,10 +244,13 @@ const dropdown = await client.getCostcodesDropdown() // { value, label }[]
|
|
|
183
244
|
const code = await client.getCostcode('CC001')
|
|
184
245
|
|
|
185
246
|
// Filtered by business unit
|
|
186
|
-
const
|
|
247
|
+
const buDropdown = await client.getCostcodesDropdownByBu('BU001')
|
|
187
248
|
|
|
188
249
|
// Filtered by business unit and pay type
|
|
189
|
-
const
|
|
250
|
+
const buPtDropdown = await client.getCostcodesDropdownByBuAndPayType('BU001', 'PT01')
|
|
251
|
+
|
|
252
|
+
// Search by description or JDE cost code (case-insensitive partial match)
|
|
253
|
+
const results = await client.searchCostcodes('labor')
|
|
190
254
|
```
|
|
191
255
|
|
|
192
256
|
---
|
|
@@ -197,6 +261,9 @@ const dropdown = await client.getCostcodesDropdownByBuAndPayType('BU001', 'PT01'
|
|
|
197
261
|
const types = await client.getPaytypes()
|
|
198
262
|
const dropdown = await client.getPaytypesDropdown() // { value, label, payClass }[]
|
|
199
263
|
const type = await client.getPaytype('PT001')
|
|
264
|
+
|
|
265
|
+
// Search by description (case-insensitive partial match)
|
|
266
|
+
const results = await client.searchPaytypes('regular')
|
|
200
267
|
```
|
|
201
268
|
|
|
202
269
|
---
|
|
@@ -209,7 +276,10 @@ const dropdown = await client.getWorkordersDropdown() // { value, label }[]
|
|
|
209
276
|
const order = await client.getWorkorder('WO001')
|
|
210
277
|
|
|
211
278
|
// Filtered by business unit
|
|
212
|
-
const
|
|
279
|
+
const buDropdown = await client.getWorkordersDropdownByBu('BU001')
|
|
280
|
+
|
|
281
|
+
// Search by description or client work order ID (case-insensitive partial match)
|
|
282
|
+
const results = await client.searchWorkorders('pipe')
|
|
213
283
|
```
|
|
214
284
|
|
|
215
285
|
---
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getBusinessUnits: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").BusinessUnit[]>;
|
|
2
|
+
export declare const getBusinessUnitsDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getBusinessUnit: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit>;
|
|
4
|
+
export declare const searchBusinessUnits: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getBusinessUnits = query(async () => getClient().getBusinessUnits());
|
|
5
|
+
export const getBusinessUnitsDropdown = query(async () => getClient().getBusinessUnitsDropdown());
|
|
6
|
+
export const getBusinessUnit = query(z.string(), async (id) => getClient().getBusinessUnit(id));
|
|
7
|
+
export const searchBusinessUnits = query(z.string(), async (q) => getClient().searchBusinessUnits(q));
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApiHubClient } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a singleton ApiHubClient configured from the consuming app's
|
|
4
|
+
* APIHUB_URL and APIHUB_API_KEY environment variables.
|
|
5
|
+
*
|
|
6
|
+
* Must only be called inside remote function bodies (server-side only).
|
|
7
|
+
*/
|
|
8
|
+
export declare function getClient(): ApiHubClient;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { env } from '$env/dynamic/private';
|
|
2
|
+
import { ApiHubClient } from './index.js';
|
|
3
|
+
let _client = null;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a singleton ApiHubClient configured from the consuming app's
|
|
6
|
+
* APIHUB_URL and APIHUB_API_KEY environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Must only be called inside remote function bodies (server-side only).
|
|
9
|
+
*/
|
|
10
|
+
export function getClient() {
|
|
11
|
+
if (!_client) {
|
|
12
|
+
const baseUrl = env.APIHUB_URL;
|
|
13
|
+
const apiKey = env.APIHUB_API_KEY;
|
|
14
|
+
if (!baseUrl)
|
|
15
|
+
throw new Error('APIHUB_URL environment variable is not set');
|
|
16
|
+
if (!apiKey)
|
|
17
|
+
throw new Error('APIHUB_API_KEY environment variable is not set');
|
|
18
|
+
_client = new ApiHubClient({ baseUrl, apiKey });
|
|
19
|
+
}
|
|
20
|
+
return _client;
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getCostcodes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Costcode[]>;
|
|
2
|
+
export declare const getCostcodesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getCostcode: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode>;
|
|
4
|
+
export declare const getCostcodesDropdownByBu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").DropdownOption[]>;
|
|
5
|
+
export declare const getCostcodesDropdownByBuAndPayType: import("@sveltejs/kit").RemoteQueryFunction<{
|
|
6
|
+
businessUnitId: string;
|
|
7
|
+
payTypeCode: string;
|
|
8
|
+
}, import("./index.js").DropdownOption[]>;
|
|
9
|
+
export declare const searchCostcodes: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const buPayTypeSchema = z.object({
|
|
5
|
+
businessUnitId: z.string(),
|
|
6
|
+
payTypeCode: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export const getCostcodes = query(async () => getClient().getCostcodes());
|
|
9
|
+
export const getCostcodesDropdown = query(async () => getClient().getCostcodesDropdown());
|
|
10
|
+
export const getCostcode = query(z.string(), async (id) => getClient().getCostcode(id));
|
|
11
|
+
export const getCostcodesDropdownByBu = query(z.string(), async (businessUnitId) => getClient().getCostcodesDropdownByBu(businessUnitId));
|
|
12
|
+
export const getCostcodesDropdownByBuAndPayType = query(buPayTypeSchema, async ({ businessUnitId, payTypeCode }) => getClient().getCostcodesDropdownByBuAndPayType(businessUnitId, payTypeCode));
|
|
13
|
+
export const searchCostcodes = query(z.string(), async (q) => getClient().searchCostcodes(q));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const getEmployees: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Employee[]>;
|
|
2
|
+
export declare const getEmployeesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getEmployee: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee>;
|
|
4
|
+
export declare const searchByName: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
5
|
+
export declare const getBySupervisor: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
6
|
+
export declare const searchByEmail: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
7
|
+
export declare const getSupervisorChain: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
8
|
+
export declare const getJdeFromEmail: import("@sveltejs/kit").RemoteQueryFunction<string, {
|
|
9
|
+
jde: string | null;
|
|
10
|
+
employee: import("./index.js").Employee | null;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const searchByHbu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
13
|
+
export declare const verifyIdentity: import("@sveltejs/kit").RemoteCommand<{
|
|
14
|
+
first3FirstName: string;
|
|
15
|
+
first3LastName: string;
|
|
16
|
+
dob: string;
|
|
17
|
+
ssn4: string;
|
|
18
|
+
}, Promise<import("./index.js").Employee | null>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const employeeIdSchema = z.string().min(1);
|
|
5
|
+
const verifyIdentitySchema = z.object({
|
|
6
|
+
first3FirstName: z.string(),
|
|
7
|
+
first3LastName: z.string(),
|
|
8
|
+
dob: z.string(),
|
|
9
|
+
ssn4: z.string(),
|
|
10
|
+
});
|
|
11
|
+
export const getEmployees = query(async () => getClient().getEmployees());
|
|
12
|
+
export const getEmployeesDropdown = query(async () => getClient().getEmployeesDropdown());
|
|
13
|
+
export const getEmployee = query(employeeIdSchema, async (employeeId) => getClient().getEmployee(employeeId));
|
|
14
|
+
export const searchByName = query(z.string(), async (name) => getClient().searchByName(name));
|
|
15
|
+
export const getBySupervisor = query(employeeIdSchema, async (supervisorId) => getClient().getBySupervisor(supervisorId));
|
|
16
|
+
export const searchByEmail = query(z.string(), async (email) => getClient().searchByEmail(email));
|
|
17
|
+
export const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
18
|
+
export const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
|
19
|
+
export const searchByHbu = query(z.string(), async (hbu) => getClient().searchByHbu(hbu));
|
|
20
|
+
export const verifyIdentity = command(verifyIdentitySchema, async (inputs) => getClient().verifyIdentity(inputs));
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export interface Employee {
|
|
|
5
5
|
employeeId: string;
|
|
6
6
|
name: string | null;
|
|
7
7
|
email: string | null;
|
|
8
|
+
personalEmail: string | null;
|
|
9
|
+
clientEmail: string | null;
|
|
10
|
+
workEmail: string | null;
|
|
8
11
|
badgeNumber: string | null;
|
|
9
12
|
employementStatus: string | null;
|
|
10
13
|
residentTaxArea: string | null;
|
|
@@ -258,6 +261,7 @@ export declare class ApiHubClient {
|
|
|
258
261
|
getBusinessUnits(): Promise<BusinessUnit[]>;
|
|
259
262
|
getBusinessUnitsDropdown(): Promise<DropdownOption[]>;
|
|
260
263
|
getBusinessUnit(id: string): Promise<BusinessUnit>;
|
|
264
|
+
searchBusinessUnits(q: string): Promise<BusinessUnit[]>;
|
|
261
265
|
getCostcodes(): Promise<Costcode[]>;
|
|
262
266
|
getCostcodesDropdown(): Promise<DropdownOption[]>;
|
|
263
267
|
getCostcode(id: string): Promise<Costcode>;
|
|
@@ -265,14 +269,17 @@ export declare class ApiHubClient {
|
|
|
265
269
|
getCostcodesDropdownByBu(businessUnitId: string): Promise<DropdownOption[]>;
|
|
266
270
|
/** Get cost codes for a specific business unit and pay type, formatted for dropdown controls */
|
|
267
271
|
getCostcodesDropdownByBuAndPayType(businessUnitId: string, payTypeCode: string): Promise<DropdownOption[]>;
|
|
272
|
+
searchCostcodes(q: string): Promise<Costcode[]>;
|
|
268
273
|
getPaytypes(): Promise<Paytype[]>;
|
|
269
274
|
getPaytypesDropdown(): Promise<PaytypeDropdownOption[]>;
|
|
270
275
|
getPaytype(id: string): Promise<Paytype>;
|
|
276
|
+
searchPaytypes(q: string): Promise<Paytype[]>;
|
|
271
277
|
getWorkorders(): Promise<Workorder[]>;
|
|
272
278
|
getWorkordersDropdown(): Promise<DropdownOption[]>;
|
|
273
279
|
/** Get work orders for a specific business unit, formatted for dropdown controls */
|
|
274
280
|
getWorkordersDropdownByBu(businessUnitId: string): Promise<DropdownOption[]>;
|
|
275
281
|
getWorkorder(id: string): Promise<Workorder>;
|
|
282
|
+
searchWorkorders(q: string): Promise<Workorder[]>;
|
|
276
283
|
getJobtypejobsteps(): Promise<Jobtypejobstep[]>;
|
|
277
284
|
getJobtypejobstepsDropdown(): Promise<DropdownOption[]>;
|
|
278
285
|
getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,9 @@ export class ApiHubClient {
|
|
|
256
256
|
async getBusinessUnit(id) {
|
|
257
257
|
return this.request(`/business-units/${encodeURIComponent(id)}`);
|
|
258
258
|
}
|
|
259
|
+
async searchBusinessUnits(q) {
|
|
260
|
+
return this.request(`/business-units/search?q=${encodeURIComponent(q)}`);
|
|
261
|
+
}
|
|
259
262
|
// -----------------------------------------------------------------------
|
|
260
263
|
// Cost Codes
|
|
261
264
|
// -----------------------------------------------------------------------
|
|
@@ -276,6 +279,9 @@ export class ApiHubClient {
|
|
|
276
279
|
async getCostcodesDropdownByBuAndPayType(businessUnitId, payTypeCode) {
|
|
277
280
|
return this.cachedRequest(`/costcodes/by-bu/${encodeURIComponent(businessUnitId)}/by-paytype/${encodeURIComponent(payTypeCode)}/dropdown`);
|
|
278
281
|
}
|
|
282
|
+
async searchCostcodes(q) {
|
|
283
|
+
return this.request(`/costcodes/search?q=${encodeURIComponent(q)}`);
|
|
284
|
+
}
|
|
279
285
|
// -----------------------------------------------------------------------
|
|
280
286
|
// Pay Types
|
|
281
287
|
// -----------------------------------------------------------------------
|
|
@@ -288,6 +294,9 @@ export class ApiHubClient {
|
|
|
288
294
|
async getPaytype(id) {
|
|
289
295
|
return this.request(`/paytypes/${encodeURIComponent(id)}`);
|
|
290
296
|
}
|
|
297
|
+
async searchPaytypes(q) {
|
|
298
|
+
return this.request(`/paytypes/search?q=${encodeURIComponent(q)}`);
|
|
299
|
+
}
|
|
291
300
|
// -----------------------------------------------------------------------
|
|
292
301
|
// Work Orders
|
|
293
302
|
// -----------------------------------------------------------------------
|
|
@@ -304,6 +313,9 @@ export class ApiHubClient {
|
|
|
304
313
|
async getWorkorder(id) {
|
|
305
314
|
return this.request(`/workorders/${encodeURIComponent(id)}`);
|
|
306
315
|
}
|
|
316
|
+
async searchWorkorders(q) {
|
|
317
|
+
return this.request(`/workorders/search?q=${encodeURIComponent(q)}`);
|
|
318
|
+
}
|
|
307
319
|
// -----------------------------------------------------------------------
|
|
308
320
|
// Job Type / Job Steps
|
|
309
321
|
// -----------------------------------------------------------------------
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const getJobtypejobsteps: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Jobtypejobstep[]>;
|
|
2
|
+
export declare const getJobtypejobstepsDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getJobtypejobstep: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Jobtypejobstep>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getJobtypejobsteps = query(async () => getClient().getJobtypejobsteps());
|
|
5
|
+
export const getJobtypejobstepsDropdown = query(async () => getClient().getJobtypejobstepsDropdown());
|
|
6
|
+
export const getJobtypejobstep = query(z.string(), async (id) => getClient().getJobtypejobstep(id));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const getLlmLogs: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").LlmLog[]>;
|
|
2
|
+
export declare const chat: import("@sveltejs/kit").RemoteCommand<{
|
|
3
|
+
user: string;
|
|
4
|
+
messages: {
|
|
5
|
+
role: "system" | "user" | "assistant";
|
|
6
|
+
content: string;
|
|
7
|
+
}[];
|
|
8
|
+
source: string;
|
|
9
|
+
function?: string | undefined;
|
|
10
|
+
temperature?: number | undefined;
|
|
11
|
+
maxTokens?: number | undefined;
|
|
12
|
+
}, Promise<import("./index.js").ChatResponse>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const chatMessageSchema = z.object({
|
|
5
|
+
role: z.enum(['system', 'user', 'assistant']),
|
|
6
|
+
content: z.string(),
|
|
7
|
+
});
|
|
8
|
+
const chatRequestSchema = z.object({
|
|
9
|
+
messages: z.array(chatMessageSchema),
|
|
10
|
+
source: z.string(),
|
|
11
|
+
user: z.string(),
|
|
12
|
+
function: z.string().optional(),
|
|
13
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
14
|
+
maxTokens: z.number().int().positive().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const getLlmLogs = query(async () => getClient().getLlmLogs());
|
|
17
|
+
export const chat = command(chatRequestSchema, async (request) => getClient().chat(request));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getPaytypes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Paytype[]>;
|
|
2
|
+
export declare const getPaytypesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").PaytypeDropdownOption[]>;
|
|
3
|
+
export declare const getPaytype: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype>;
|
|
4
|
+
export declare const searchPaytypes: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getPaytypes = query(async () => getClient().getPaytypes());
|
|
5
|
+
export const getPaytypesDropdown = query(async () => getClient().getPaytypesDropdown());
|
|
6
|
+
export const getPaytype = query(z.string(), async (id) => getClient().getPaytype(id));
|
|
7
|
+
export const searchPaytypes = query(z.string(), async (q) => getClient().searchPaytypes(q));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const listDocuments: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DocumentRecord[]>;
|
|
2
|
+
export declare const uploadDocument: import("@sveltejs/kit").RemoteCommand<{
|
|
3
|
+
fileName: string;
|
|
4
|
+
base64Content: string;
|
|
5
|
+
uploadedBy: string;
|
|
6
|
+
}, Promise<import("./index.js").DocumentRecord>>;
|
|
7
|
+
export declare const deleteDocument: import("@sveltejs/kit").RemoteCommand<number, Promise<void>>;
|
|
8
|
+
export declare const searchDocuments: import("@sveltejs/kit").RemoteCommand<{
|
|
9
|
+
query: string;
|
|
10
|
+
topK?: number | undefined;
|
|
11
|
+
}, Promise<import("./index.js").SearchResult[]>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const uploadDocumentSchema = z.object({
|
|
5
|
+
fileName: z.string().min(1),
|
|
6
|
+
base64Content: z.string().min(1),
|
|
7
|
+
uploadedBy: z.string().min(1),
|
|
8
|
+
});
|
|
9
|
+
const searchDocumentsSchema = z.object({
|
|
10
|
+
query: z.string().min(1),
|
|
11
|
+
topK: z.number().int().positive().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const listDocuments = query(async () => getClient().listDocuments());
|
|
14
|
+
export const uploadDocument = command(uploadDocumentSchema, async ({ fileName, base64Content, uploadedBy }) => getClient().uploadDocument(fileName, base64Content, uploadedBy));
|
|
15
|
+
export const deleteDocument = command(z.number().int().positive(), async (id) => getClient().deleteDocument(id));
|
|
16
|
+
export const searchDocuments = command(searchDocumentsSchema, async ({ query: q, topK }) => getClient().searchDocuments(q, topK));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getWorkorders: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Workorder[]>;
|
|
2
|
+
export declare const getWorkordersDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getWorkordersDropdownByBu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").DropdownOption[]>;
|
|
4
|
+
export declare const getWorkorder: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder>;
|
|
5
|
+
export declare const searchWorkorders: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getWorkorders = query(async () => getClient().getWorkorders());
|
|
5
|
+
export const getWorkordersDropdown = query(async () => getClient().getWorkordersDropdown());
|
|
6
|
+
export const getWorkordersDropdownByBu = query(z.string(), async (businessUnitId) => getClient().getWorkordersDropdownByBu(businessUnitId));
|
|
7
|
+
export const getWorkorder = query(z.string(), async (id) => getClient().getWorkorder(id));
|
|
8
|
+
export const searchWorkorders = query(z.string(), async (q) => getClient().searchWorkorders(q));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brownandroot/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,19 +11,71 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./employees": {
|
|
18
|
+
"types": "./dist/employees.remote.d.ts",
|
|
19
|
+
"default": "./dist/employees.remote.js"
|
|
20
|
+
},
|
|
21
|
+
"./businessUnits": {
|
|
22
|
+
"types": "./dist/businessUnits.remote.d.ts",
|
|
23
|
+
"default": "./dist/businessUnits.remote.js"
|
|
24
|
+
},
|
|
25
|
+
"./costcodes": {
|
|
26
|
+
"types": "./dist/costcodes.remote.d.ts",
|
|
27
|
+
"default": "./dist/costcodes.remote.js"
|
|
28
|
+
},
|
|
29
|
+
"./paytypes": {
|
|
30
|
+
"types": "./dist/paytypes.remote.d.ts",
|
|
31
|
+
"default": "./dist/paytypes.remote.js"
|
|
32
|
+
},
|
|
33
|
+
"./workorders": {
|
|
34
|
+
"types": "./dist/workorders.remote.d.ts",
|
|
35
|
+
"default": "./dist/workorders.remote.js"
|
|
36
|
+
},
|
|
37
|
+
"./jobtypejobsteps": {
|
|
38
|
+
"types": "./dist/jobtypejobsteps.remote.d.ts",
|
|
39
|
+
"default": "./dist/jobtypejobsteps.remote.js"
|
|
40
|
+
},
|
|
41
|
+
"./llm": {
|
|
42
|
+
"types": "./dist/llm.remote.d.ts",
|
|
43
|
+
"default": "./dist/llm.remote.js"
|
|
44
|
+
},
|
|
45
|
+
"./rag": {
|
|
46
|
+
"types": "./dist/rag.remote.d.ts",
|
|
47
|
+
"default": "./dist/rag.remote.js"
|
|
16
48
|
}
|
|
17
49
|
},
|
|
18
50
|
"files": [
|
|
19
51
|
"dist"
|
|
20
52
|
],
|
|
21
53
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
54
|
+
"prepare": "bun svelte-kit sync || echo ''",
|
|
55
|
+
"build": "bun svelte-kit sync && bun svelte-package",
|
|
56
|
+
"prepublishOnly": "bun run build",
|
|
24
57
|
"publish:manual": "npm publish --access public"
|
|
25
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@sveltejs/kit": "^2.0.0",
|
|
61
|
+
"svelte": "^5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@sveltejs/kit": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"svelte": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
26
71
|
"devDependencies": {
|
|
27
|
-
"
|
|
72
|
+
"@sveltejs/adapter-node": "^5.0.0",
|
|
73
|
+
"@sveltejs/kit": "^2.0.0",
|
|
74
|
+
"@sveltejs/package": "^2.0.0",
|
|
75
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
76
|
+
"svelte": "^5.0.0",
|
|
77
|
+
"typescript": "^5.0.0",
|
|
78
|
+
"vite": "^6.0.0",
|
|
79
|
+
"zod": "^3.0.0"
|
|
28
80
|
}
|
|
29
81
|
}
|