@brownandroot/api 0.7.0 → 0.9.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @brownandroot/api
2
2
 
3
- Read-only TypeScript client for the Brown & Root APIHub data service. All methods are GET-only no create, update, or delete operations are supported.
3
+ TypeScript client for the Brown & Root APIHub data service. Provides read-only access to company data and an LLM chat endpoint powered by Azure AI Foundry.
4
4
 
5
5
  ## Installation
6
6
 
@@ -61,10 +61,21 @@ const orders = await client.getWorkorders()
61
61
  const order = await client.getWorkorder('WO001')
62
62
  ```
63
63
 
64
- ### LLM Logs
64
+ ### LLM
65
65
 
66
66
  ```typescript
67
+ // List logs
67
68
  const logs = await client.getLlmLogs()
69
+
70
+ // Chat completion
71
+ const result = await client.chat({
72
+ messages: [{ role: 'user', content: 'Summarize this document...' }],
73
+ source: 'my-app',
74
+ user: 'jane.doe',
75
+ function: 'summarize',
76
+ })
77
+ console.log(result.message.content)
78
+ console.log(result.usage) // { tokensIn, tokensOut, totalTokens }
68
79
  ```
69
80
 
70
81
  ## Types
@@ -77,9 +88,11 @@ import type {
77
88
  BusinessUnit,
78
89
  Costcode,
79
90
  Paytype,
80
- Shift,
81
91
  Workorder,
82
92
  LlmLog,
93
+ ChatMessage,
94
+ ChatRequest,
95
+ ChatResponse,
83
96
  ApiHubClientOptions,
84
97
  } from '@brownandroot/api'
85
98
  ```
package/dist/index.d.ts CHANGED
@@ -58,6 +58,26 @@ export interface LlmLog {
58
58
  totalTokens: number | null;
59
59
  createdAt: string | null;
60
60
  }
61
+ export interface ChatMessage {
62
+ role: 'system' | 'user' | 'assistant';
63
+ content: string;
64
+ }
65
+ export interface ChatRequest {
66
+ messages: ChatMessage[];
67
+ source: string;
68
+ user: string;
69
+ function?: string;
70
+ temperature?: number;
71
+ maxTokens?: number;
72
+ }
73
+ export interface ChatResponse {
74
+ message: ChatMessage;
75
+ usage: {
76
+ tokensIn: number | null;
77
+ tokensOut: number | null;
78
+ totalTokens: number | null;
79
+ };
80
+ }
61
81
  export interface BusinessUnit {
62
82
  id: string;
63
83
  companyId: string;
@@ -119,6 +139,19 @@ export interface Workorder {
119
139
  parentWorkOrder: string | null;
120
140
  workOrder2: string | null;
121
141
  }
142
+ export interface Jobtypejobstep {
143
+ id: string;
144
+ grp: string | null;
145
+ jobType: string | null;
146
+ jobStep: string | null;
147
+ description: string | null;
148
+ payclass: string | null;
149
+ isActive: boolean;
150
+ createdBy: string;
151
+ createdAt: string;
152
+ updatedBy: string | null;
153
+ updatedAt: string | null;
154
+ }
122
155
  export declare class ApiHubClient {
123
156
  private baseUrl;
124
157
  private apiKey;
@@ -145,6 +178,8 @@ export declare class ApiHubClient {
145
178
  }>;
146
179
  /** List all LLM log entries (newest first) */
147
180
  getLlmLogs(): Promise<LlmLog[]>;
181
+ /** Send a chat completion request to the LLM */
182
+ chat(request: ChatRequest): Promise<ChatResponse>;
148
183
  getBusinessUnits(): Promise<BusinessUnit[]>;
149
184
  getBusinessUnitsDropdown(): Promise<DropdownOption[]>;
150
185
  getBusinessUnit(id: string): Promise<BusinessUnit>;
@@ -157,4 +192,7 @@ export declare class ApiHubClient {
157
192
  getWorkorders(): Promise<Workorder[]>;
158
193
  getWorkordersDropdown(): Promise<DropdownOption[]>;
159
194
  getWorkorder(id: string): Promise<Workorder>;
195
+ getJobtypejobsteps(): Promise<Jobtypejobstep[]>;
196
+ getJobtypejobstepsDropdown(): Promise<DropdownOption[]>;
197
+ getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
160
198
  }
package/dist/index.js CHANGED
@@ -54,6 +54,22 @@ export class ApiHubClient {
54
54
  async getLlmLogs() {
55
55
  return this.request('/llm-logs');
56
56
  }
57
+ /** Send a chat completion request to the LLM */
58
+ async chat(request) {
59
+ const res = await fetch(`${this.baseUrl}/llm/chat`, {
60
+ method: 'POST',
61
+ headers: {
62
+ 'x-api-key': this.apiKey,
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ body: JSON.stringify(request),
66
+ });
67
+ if (!res.ok) {
68
+ const body = await res.json().catch(() => ({}));
69
+ throw new Error(body.error ?? `Request failed: ${res.status}`);
70
+ }
71
+ return res.json();
72
+ }
57
73
  // -----------------------------------------------------------------------
58
74
  // Business Units
59
75
  // -----------------------------------------------------------------------
@@ -102,4 +118,16 @@ export class ApiHubClient {
102
118
  async getWorkorder(id) {
103
119
  return this.request(`/workorders/${encodeURIComponent(id)}`);
104
120
  }
121
+ // -----------------------------------------------------------------------
122
+ // Job Type / Job Steps
123
+ // -----------------------------------------------------------------------
124
+ async getJobtypejobsteps() {
125
+ return this.request('/jobtypejobsteps');
126
+ }
127
+ async getJobtypejobstepsDropdown() {
128
+ return this.request('/jobtypejobsteps/dropdown');
129
+ }
130
+ async getJobtypejobstep(id) {
131
+ return this.request(`/jobtypejobsteps/${encodeURIComponent(id)}`);
132
+ }
105
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brownandroot/api",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",