@oxy-hq/sdk 0.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.
@@ -0,0 +1,367 @@
1
+
2
+ //#region src/config.d.ts
3
+ /**
4
+ * Configuration for the Oxy SDK
5
+ */
6
+ interface OxyConfig {
7
+ /**
8
+ * Base URL of the Oxy API (e.g., 'https://api.oxy.tech' or 'http://localhost:3000')
9
+ */
10
+ baseUrl: string;
11
+ /**
12
+ * API key for authentication (optional for local development)
13
+ */
14
+ apiKey?: string;
15
+ /**
16
+ * Project ID (UUID)
17
+ */
18
+ projectId: string;
19
+ /**
20
+ * Optional branch name (defaults to current branch if not specified)
21
+ */
22
+ branch?: string;
23
+ /**
24
+ * Request timeout in milliseconds (default: 30000)
25
+ */
26
+ timeout?: number;
27
+ }
28
+ /**
29
+ * Creates an Oxy configuration from environment variables
30
+ *
31
+ * Environment variables:
32
+ * - OXY_URL: Base URL of the Oxy API
33
+ * - OXY_API_KEY: API key for authentication
34
+ * - OXY_PROJECT_ID: Project ID (UUID)
35
+ * - OXY_BRANCH: (Optional) Branch name
36
+ *
37
+ * @param overrides - Optional configuration overrides
38
+ * @returns OxyConfig object
39
+ * @throws Error if required environment variables are missing
40
+ */
41
+ declare function createConfig(overrides?: Partial<OxyConfig>): OxyConfig;
42
+ //#endregion
43
+ //#region src/types.d.ts
44
+ /**
45
+ * Represents an app item in the project
46
+ */
47
+ interface AppItem {
48
+ name: string;
49
+ path: string;
50
+ }
51
+ /**
52
+ * Reference to a data file (usually parquet)
53
+ */
54
+ interface FileReference {
55
+ file_path: string;
56
+ }
57
+ /**
58
+ * Table data structure for in-memory tables
59
+ * (used when data is fetched and parsed)
60
+ */
61
+ interface TableData {
62
+ columns: string[];
63
+ rows: any[][];
64
+ total_rows?: number;
65
+ }
66
+ type DataContainer = Record<string, FileReference>;
67
+ /**
68
+ * Response from app data endpoints
69
+ */
70
+ interface AppDataResponse {
71
+ data: DataContainer | null;
72
+ error: string | null;
73
+ }
74
+ /**
75
+ * Display with potential error
76
+ */
77
+ interface DisplayWithError {
78
+ display?: DisplayData;
79
+ error?: string;
80
+ }
81
+ /**
82
+ * Display data structure
83
+ */
84
+ interface DisplayData {
85
+ type: string;
86
+ content: any;
87
+ }
88
+ /**
89
+ * Response from get displays endpoint
90
+ */
91
+ interface GetDisplaysResponse {
92
+ displays: DisplayWithError[];
93
+ }
94
+ /**
95
+ * Query result from ParquetReader
96
+ */
97
+ interface QueryResult$1 {
98
+ columns: string[];
99
+ rows: any[][];
100
+ rowCount: number;
101
+ }
102
+ //#endregion
103
+ //#region src/client.d.ts
104
+ /**
105
+ * Oxy API Client for interacting with Oxy data
106
+ */
107
+ declare class OxyClient {
108
+ private config;
109
+ constructor(config: OxyConfig);
110
+ /**
111
+ * Encodes a file path to base64 for use in API URLs
112
+ */
113
+ private encodePathBase64;
114
+ /**
115
+ * Makes an authenticated HTTP request to the Oxy API
116
+ */
117
+ private request;
118
+ /**
119
+ * Builds query parameters including optional branch
120
+ */
121
+ private buildQueryParams;
122
+ /**
123
+ * Lists all apps in the project
124
+ *
125
+ * @returns Array of app items
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const apps = await client.listApps();
130
+ * console.log('Available apps:', apps);
131
+ * ```
132
+ */
133
+ listApps(): Promise<AppItem[]>;
134
+ /**
135
+ * Gets data for a specific app
136
+ *
137
+ * @param appPath - Relative path to the app file (e.g., 'my-app.app.yml')
138
+ * @returns App data response
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const data = await client.getAppData('dashboard.app.yml');
143
+ * if (data.error) {
144
+ * console.error('Error:', data.error);
145
+ * } else {
146
+ * console.log('App data:', data.data);
147
+ * }
148
+ * ```
149
+ */
150
+ getAppData(appPath: string): Promise<AppDataResponse>;
151
+ /**
152
+ * Runs an app and returns fresh data (bypasses cache)
153
+ *
154
+ * @param appPath - Relative path to the app file
155
+ * @returns App data response
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const data = await client.runApp('dashboard.app.yml');
160
+ * console.log('Fresh app data:', data.data);
161
+ * ```
162
+ */
163
+ runApp(appPath: string): Promise<AppDataResponse>;
164
+ /**
165
+ * Gets display configurations for an app
166
+ *
167
+ * @param appPath - Relative path to the app file
168
+ * @returns Display configurations with potential errors
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const displays = await client.getDisplays('dashboard.app.yml');
173
+ * displays.displays.forEach(d => {
174
+ * if (d.error) {
175
+ * console.error('Display error:', d.error);
176
+ * } else {
177
+ * console.log('Display:', d.display);
178
+ * }
179
+ * });
180
+ * ```
181
+ */
182
+ getDisplays(appPath: string): Promise<GetDisplaysResponse>;
183
+ /**
184
+ * Gets a file from the app state directory (e.g., generated charts, images)
185
+ *
186
+ * This is useful for retrieving generated assets like charts, images, or other
187
+ * files produced by app workflows and stored in the state directory.
188
+ *
189
+ * @param filePath - Relative path to the file in state directory
190
+ * @returns Blob containing the file data
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Get a generated chart image
195
+ * const blob = await client.getFile('charts/sales-chart.png');
196
+ * const imageUrl = URL.createObjectURL(blob);
197
+ *
198
+ * // Use in an img tag
199
+ * document.querySelector('img').src = imageUrl;
200
+ * ```
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * // Download a file
205
+ * const blob = await client.getFile('exports/data.csv');
206
+ * const a = document.createElement('a');
207
+ * a.href = URL.createObjectURL(blob);
208
+ * a.download = 'data.csv';
209
+ * a.click();
210
+ * ```
211
+ */
212
+ getFile(filePath: string): Promise<Blob>;
213
+ /**
214
+ * Gets a file URL for direct browser access
215
+ *
216
+ * This returns a URL that can be used directly in img tags, fetch calls, etc.
217
+ * The URL includes authentication via query parameters.
218
+ *
219
+ * @param filePath - Relative path to the file in state directory
220
+ * @returns Full URL to the file
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * const imageUrl = client.getFileUrl('charts/sales-chart.png');
225
+ *
226
+ * // Use directly in img tag (in environments where query-based auth is supported)
227
+ * document.querySelector('img').src = imageUrl;
228
+ * ```
229
+ */
230
+ getFileUrl(filePath: string): string;
231
+ /**
232
+ * Fetches a parquet file and parses it into table data
233
+ *
234
+ * @param filePath - Relative path to the parquet file
235
+ * @param limit - Maximum number of rows to return (default: 100)
236
+ * @returns TableData with columns and rows
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const tableData = await client.getTableData('data/sales.parquet', 50);
241
+ * console.log(tableData.columns);
242
+ * console.log(tableData.rows);
243
+ * console.log(`Total rows: ${tableData.total_rows}`);
244
+ * ```
245
+ */
246
+ getTableData(filePath: string, limit?: number): Promise<TableData>;
247
+ }
248
+ //#endregion
249
+ //#region src/parquet.d.ts
250
+ /**
251
+ * Query result interface
252
+ */
253
+ interface QueryResult {
254
+ columns: string[];
255
+ rows: any[][];
256
+ rowCount: number;
257
+ }
258
+ /**
259
+ * ParquetReader provides methods to read and query Parquet files
260
+ */
261
+ declare class ParquetReader {
262
+ private tableName;
263
+ private registered;
264
+ constructor(tableName?: string);
265
+ /**
266
+ * Register a Parquet file from a Blob
267
+ *
268
+ * @param blob - Parquet file as Blob
269
+ *
270
+ * @example
271
+ * ```typescript
272
+ * const blob = await client.getFile('data/sales.parquet');
273
+ * const reader = new ParquetReader('sales');
274
+ * await reader.registerParquet(blob);
275
+ * ```
276
+ */
277
+ registerParquet(blob: Blob): Promise<void>;
278
+ /**
279
+ * Execute a SQL query against the registered Parquet data
280
+ *
281
+ * @param sql - SQL query string
282
+ * @returns Query result with columns and rows
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const result = await reader.query('SELECT * FROM sales LIMIT 10');
287
+ * console.log(result.columns);
288
+ * console.log(result.rows);
289
+ * ```
290
+ */
291
+ query(sql: string): Promise<QueryResult>;
292
+ /**
293
+ * Get all data from the registered table
294
+ *
295
+ * @param limit - Maximum number of rows to return (default: all)
296
+ * @returns Query result
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const allData = await reader.getAll();
301
+ * const first100 = await reader.getAll(100);
302
+ * ```
303
+ */
304
+ getAll(limit?: number): Promise<QueryResult>;
305
+ /**
306
+ * Get table schema information
307
+ *
308
+ * @returns Schema information
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * const schema = await reader.getSchema();
313
+ * console.log(schema.columns); // ['id', 'name', 'sales']
314
+ * console.log(schema.rows); // [['id', 'INTEGER'], ['name', 'VARCHAR'], ...]
315
+ * ```
316
+ */
317
+ getSchema(): Promise<QueryResult>;
318
+ /**
319
+ * Get row count
320
+ *
321
+ * @returns Number of rows in the table
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * const count = await reader.count();
326
+ * console.log(`Total rows: ${count}`);
327
+ * ```
328
+ */
329
+ count(): Promise<number>;
330
+ /**
331
+ * Close and cleanup resources
332
+ */
333
+ close(): Promise<void>;
334
+ }
335
+ /**
336
+ * Helper function to quickly read a Parquet blob and execute a query
337
+ *
338
+ * @param blob - Parquet file as Blob
339
+ * @param sql - SQL query to execute (optional, defaults to SELECT *)
340
+ * @returns Query result
341
+ *
342
+ * @example
343
+ * ```typescript
344
+ * const blob = await client.getFile('data/sales.parquet');
345
+ * const result = await queryParquet(blob, 'SELECT product, SUM(amount) as total FROM data GROUP BY product');
346
+ * console.log(result);
347
+ * ```
348
+ */
349
+ declare function queryParquet(blob: Blob, sql?: string): Promise<QueryResult>;
350
+ /**
351
+ * Helper function to read Parquet file and get all data
352
+ *
353
+ * @param blob - Parquet file as Blob
354
+ * @param limit - Maximum number of rows (optional)
355
+ * @returns Query result
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * const blob = await client.getFile('data/sales.parquet');
360
+ * const data = await readParquet(blob, 1000);
361
+ * console.log(`Loaded ${data.rowCount} rows`);
362
+ * ```
363
+ */
364
+ declare function readParquet(blob: Blob, limit?: number): Promise<QueryResult>;
365
+ //#endregion
366
+ export { type AppDataResponse, type AppItem, type DataContainer, type DisplayData, type DisplayWithError, type FileReference, OxyClient, type OxyConfig, type QueryResult as ParquetQueryResult, ParquetReader, type QueryResult$1 as QueryResult, type TableData, createConfig, queryParquet, readParquet };
367
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/types.ts","../src/client.ts","../src/parquet.ts"],"sourcesContent":[],"mappings":";;;AAGA;AAwCA;AAAiD,UAxChC,SAAA,CAwCgC;EAAR;;;;;;ACxCzC;EAQiB,MAAA,CAAA,EAAA,MAAA;EAQA;AAMjB;AAKA;EAQiB,SAAA,EAAA,MAAA;EAQA;AAQjB;AAgBA;;;;ACzDA;EAGsB,OAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;iBF2BN,YAAA,aAAyB,QAAQ,aAAa;;;;AAxC9D;AAwCA;AAAiD,UCxChC,OAAA,CDwCgC;EAAR,IAAA,EAAA,MAAA;EAAqB,IAAA,EAAA,MAAA;;;;;ACxC7C,UAQA,aAAA,CARO;EAQP,SAAA,EAAA,MAAa;AAQ9B;AAMA;AAKA;AAQA;AAQA;AAQiB,UAnCA,SAAA,CAmCmB;EAgBnB,OAAA,EAAA,MAAA,EAAW;;;;ACzDf,KDYD,aAAA,GAAgB,MCZN,CAAA,MAAA,EDYqB,aCZrB,CAAA;;;;AAiIuB,UDhH5B,eAAA,CCgH4B;EAAR,IAAA,ED/G7B,aC+G6B,GAAA,IAAA;EAoBI,KAAA,EAAA,MAAA,GAAA,IAAA;;;;;AAgEN,UD5LlB,gBAAA,CC4LkB;EAmDkC,OAAA,CAAA,ED9OzD,WC8OyD;EAAR,KAAA,CAAA,EAAA,MAAA;;;;;ACnO5C,UFJA,WAAA,CEIW;EASf,IAAA,EAAA,MAAA;EAoBiB,OAAA,EAAA,GAAA;;;;;AAkFE,UF3Gf,mBAAA,CE2Ge;EAiBH,QAAA,EF3HjB,gBE2HiB,EAAA;;AA4F7B;;;AAGG,UF3Mc,aAAA,CE2Md;EAAO,OAAA,EAAA,MAAA,EAAA;;;;;;AHtOV;;;AAA8D,cE9BjD,SAAA,CF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