@oxy-hq/sdk 0.2.5 → 1.0.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 +61 -45
- package/dist/index.cjs +58 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +30 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +42 -20
- package/dist/index.mjs.map +1 -1
- package/dist/{postMessage-B1J0jDRN.cjs → postMessage-Cb5PCtcE.cjs} +12 -11
- package/dist/{postMessage-B1J0jDRN.cjs.map → postMessage-Cb5PCtcE.cjs.map} +1 -1
- package/dist/{postMessage-BxdgtX8j.mjs → postMessage-Gnhr_wnw.mjs} +25 -2
- package/dist/{postMessage-BxdgtX8j.mjs.map → postMessage-Gnhr_wnw.mjs.map} +1 -1
- package/package.json +78 -79
- package/dist/postMessage-BSNS3ccd.cjs +0 -5
- package/dist/postMessage-D5wWgwcO.mjs +0 -4
package/README.md
CHANGED
|
@@ -37,12 +37,12 @@ import { OxySDK } from "@oxy/sdk";
|
|
|
37
37
|
const sdk = new OxySDK({
|
|
38
38
|
apiKey: "your-api-key",
|
|
39
39
|
projectId: "your-project-id",
|
|
40
|
-
baseUrl: "https://api.oxy.tech"
|
|
40
|
+
baseUrl: "https://api.oxy.tech",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// Load parquet files and query them
|
|
44
|
-
await sdk.loadFile(
|
|
45
|
-
await sdk.loadFile(
|
|
44
|
+
await sdk.loadFile("data/sales.parquet", "sales");
|
|
45
|
+
await sdk.loadFile("data/customers.parquet", "customers");
|
|
46
46
|
|
|
47
47
|
// Query with SQL - supports joins across multiple tables
|
|
48
48
|
const result = await sdk.query(`
|
|
@@ -65,10 +65,10 @@ import { OxySDK, createConfig } from "@oxy/sdk";
|
|
|
65
65
|
const sdk = new OxySDK(createConfig());
|
|
66
66
|
|
|
67
67
|
// Loads all data from the app and registers tables
|
|
68
|
-
await sdk.loadAppData(
|
|
68
|
+
await sdk.loadAppData("dashboard.app.yml");
|
|
69
69
|
|
|
70
70
|
// Query the loaded tables
|
|
71
|
-
const result = await sdk.query(
|
|
71
|
+
const result = await sdk.query("SELECT * FROM my_table LIMIT 10");
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
### Iframe Usage (PostMessage Authentication)
|
|
@@ -81,11 +81,11 @@ import { OxySDK } from "@oxy/sdk";
|
|
|
81
81
|
// SDK automatically requests API key from parent window
|
|
82
82
|
const sdk = await OxySDK.create({
|
|
83
83
|
parentOrigin: "https://app.example.com",
|
|
84
|
-
projectId: "your-project-uuid"
|
|
84
|
+
projectId: "your-project-uuid",
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
await sdk.loadAppData(
|
|
88
|
-
const result = await sdk.query(
|
|
87
|
+
await sdk.loadAppData("dashboard.app.yml");
|
|
88
|
+
const result = await sdk.query("SELECT * FROM my_table LIMIT 10");
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
**Parent window setup:**
|
|
@@ -95,14 +95,17 @@ window.addEventListener("message", (event) => {
|
|
|
95
95
|
if (event.data.type !== "OXY_AUTH_REQUEST") return;
|
|
96
96
|
if (event.origin !== "https://your-iframe-app.com") return;
|
|
97
97
|
|
|
98
|
-
event.source.postMessage(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
event.source.postMessage(
|
|
99
|
+
{
|
|
100
|
+
type: "OXY_AUTH_RESPONSE",
|
|
101
|
+
version: "1.0",
|
|
102
|
+
requestId: event.data.requestId,
|
|
103
|
+
apiKey: getUserApiKey(),
|
|
104
|
+
projectId: "your-project-uuid",
|
|
105
|
+
baseUrl: "https://api.oxy.tech",
|
|
106
|
+
},
|
|
107
|
+
event.origin,
|
|
108
|
+
);
|
|
106
109
|
});
|
|
107
110
|
```
|
|
108
111
|
|
|
@@ -130,8 +133,8 @@ const sdk = new OxySDK(createConfig());
|
|
|
130
133
|
The SDK provides `OxyProvider` and `useOxy` hooks for easy integration:
|
|
131
134
|
|
|
132
135
|
```tsx
|
|
133
|
-
import { OxyProvider, useOxy, createConfig } from
|
|
134
|
-
import { useEffect, useState } from
|
|
136
|
+
import { OxyProvider, useOxy, createConfig } from "@oxy/sdk";
|
|
137
|
+
import { useEffect, useState } from "react";
|
|
135
138
|
|
|
136
139
|
// Wrap your app with OxyProvider
|
|
137
140
|
function App() {
|
|
@@ -149,8 +152,9 @@ function Dashboard() {
|
|
|
149
152
|
|
|
150
153
|
useEffect(() => {
|
|
151
154
|
if (sdk) {
|
|
152
|
-
sdk
|
|
153
|
-
.
|
|
155
|
+
sdk
|
|
156
|
+
.loadAppData("dashboard.app.yml")
|
|
157
|
+
.then(() => sdk.query("SELECT * FROM my_table LIMIT 100"))
|
|
154
158
|
.then(setData);
|
|
155
159
|
}
|
|
156
160
|
}, [sdk]);
|
|
@@ -165,13 +169,17 @@ function Dashboard() {
|
|
|
165
169
|
<table>
|
|
166
170
|
<thead>
|
|
167
171
|
<tr>
|
|
168
|
-
{data.columns.map(col =>
|
|
172
|
+
{data.columns.map((col) => (
|
|
173
|
+
<th key={col}>{col}</th>
|
|
174
|
+
))}
|
|
169
175
|
</tr>
|
|
170
176
|
</thead>
|
|
171
177
|
<tbody>
|
|
172
178
|
{data.rows.map((row, i) => (
|
|
173
179
|
<tr key={i}>
|
|
174
|
-
{row.map((cell, j) =>
|
|
180
|
+
{row.map((cell, j) => (
|
|
181
|
+
<td key={j}>{String(cell)}</td>
|
|
182
|
+
))}
|
|
175
183
|
</tr>
|
|
176
184
|
))}
|
|
177
185
|
</tbody>
|
|
@@ -184,14 +192,11 @@ function Dashboard() {
|
|
|
184
192
|
### Iframe with PostMessage Auth
|
|
185
193
|
|
|
186
194
|
```tsx
|
|
187
|
-
import { OxyProvider, useOxySDK } from
|
|
195
|
+
import { OxyProvider, useOxySDK } from "@oxy/sdk";
|
|
188
196
|
|
|
189
197
|
function App() {
|
|
190
198
|
return (
|
|
191
|
-
<OxyProvider
|
|
192
|
-
useAsync
|
|
193
|
-
config={{ parentOrigin: 'https://app.example.com' }}
|
|
194
|
-
>
|
|
199
|
+
<OxyProvider useAsync config={{ parentOrigin: "https://app.example.com" }}>
|
|
195
200
|
<Dashboard />
|
|
196
201
|
</OxyProvider>
|
|
197
202
|
);
|
|
@@ -202,8 +207,9 @@ function Dashboard() {
|
|
|
202
207
|
const [data, setData] = useState(null);
|
|
203
208
|
|
|
204
209
|
useEffect(() => {
|
|
205
|
-
sdk
|
|
206
|
-
.
|
|
210
|
+
sdk
|
|
211
|
+
.loadFile("data/sales.parquet", "sales")
|
|
212
|
+
.then(() => sdk.query("SELECT * FROM sales LIMIT 100"))
|
|
207
213
|
.then(setData);
|
|
208
214
|
}, [sdk]);
|
|
209
215
|
|
|
@@ -274,8 +280,8 @@ Creates an SDK instance with async configuration (supports postMessage auth).
|
|
|
274
280
|
|
|
275
281
|
```typescript
|
|
276
282
|
const sdk = await OxySDK.create({
|
|
277
|
-
parentOrigin:
|
|
278
|
-
projectId:
|
|
283
|
+
parentOrigin: "https://app.example.com",
|
|
284
|
+
projectId: "your-project-id",
|
|
279
285
|
});
|
|
280
286
|
```
|
|
281
287
|
|
|
@@ -284,7 +290,7 @@ const sdk = await OxySDK.create({
|
|
|
284
290
|
Loads a Parquet file from Oxy and registers it for SQL queries.
|
|
285
291
|
|
|
286
292
|
```typescript
|
|
287
|
-
await sdk.loadFile(
|
|
293
|
+
await sdk.loadFile("data/sales.parquet", "sales");
|
|
288
294
|
```
|
|
289
295
|
|
|
290
296
|
#### `async loadFiles(files: Array<{filePath: string, tableName: string}>): Promise<void>`
|
|
@@ -293,8 +299,8 @@ Loads multiple Parquet files at once.
|
|
|
293
299
|
|
|
294
300
|
```typescript
|
|
295
301
|
await sdk.loadFiles([
|
|
296
|
-
{ filePath:
|
|
297
|
-
{ filePath:
|
|
302
|
+
{ filePath: "data/sales.parquet", tableName: "sales" },
|
|
303
|
+
{ filePath: "data/customers.parquet", tableName: "customers" },
|
|
298
304
|
]);
|
|
299
305
|
```
|
|
300
306
|
|
|
@@ -303,9 +309,9 @@ await sdk.loadFiles([
|
|
|
303
309
|
Loads all data from an app's data container. Uses container keys as table names.
|
|
304
310
|
|
|
305
311
|
```typescript
|
|
306
|
-
const data = await sdk.loadAppData(
|
|
312
|
+
const data = await sdk.loadAppData("dashboard.app.yml");
|
|
307
313
|
// Now query the tables using their container keys
|
|
308
|
-
const result = await sdk.query(
|
|
314
|
+
const result = await sdk.query("SELECT * FROM my_table");
|
|
309
315
|
```
|
|
310
316
|
|
|
311
317
|
#### `async query(sql: string): Promise<QueryResult>`
|
|
@@ -313,7 +319,7 @@ const result = await sdk.query('SELECT * FROM my_table');
|
|
|
313
319
|
Executes a SQL query against loaded data.
|
|
314
320
|
|
|
315
321
|
```typescript
|
|
316
|
-
const result = await sdk.query(
|
|
322
|
+
const result = await sdk.query("SELECT * FROM sales WHERE amount > 1000");
|
|
317
323
|
```
|
|
318
324
|
|
|
319
325
|
#### `async getAll(tableName: string, limit?: number): Promise<QueryResult>`
|
|
@@ -321,7 +327,7 @@ const result = await sdk.query('SELECT * FROM sales WHERE amount > 1000');
|
|
|
321
327
|
Gets all data from a loaded table.
|
|
322
328
|
|
|
323
329
|
```typescript
|
|
324
|
-
const data = await sdk.getAll(
|
|
330
|
+
const data = await sdk.getAll("sales", 100);
|
|
325
331
|
```
|
|
326
332
|
|
|
327
333
|
#### `async getSchema(tableName: string): Promise<QueryResult>`
|
|
@@ -355,13 +361,22 @@ Closes and cleans up all resources.
|
|
|
355
361
|
Provider component that initializes and provides OxySDK to child components.
|
|
356
362
|
|
|
357
363
|
**Props:**
|
|
364
|
+
|
|
358
365
|
- `config?: Partial<OxyConfig>` - SDK configuration
|
|
359
366
|
- `useAsync?: boolean` - If true, uses async initialization (supports postMessage auth)
|
|
367
|
+
- `appPath?: string` - Optional app path to load initial app data upon initialization
|
|
368
|
+
- `files?: Record<string, string>` - Optional initial files to preload as a mapping of table name to file path
|
|
360
369
|
- `onReady?: (sdk: OxySDK) => void` - Called when SDK is initialized
|
|
361
370
|
- `onError?: (error: Error) => void` - Called on initialization error
|
|
371
|
+
- `loadingFallback?: ReactNode` - Rendered while the SDK is initializing (replaces `children` during load)
|
|
372
|
+
- `errorFallback?: ReactNode | ((error: Error) => ReactNode)` - Rendered when initialization fails; can be a node or a render function that receives the error
|
|
362
373
|
|
|
363
374
|
```tsx
|
|
364
|
-
<OxyProvider
|
|
375
|
+
<OxyProvider
|
|
376
|
+
config={createConfig()}
|
|
377
|
+
loadingFallback={<div>Loading SDK...</div>}
|
|
378
|
+
errorFallback={(error) => <div>Failed to initialize: {error.message}</div>}
|
|
379
|
+
>
|
|
365
380
|
<YourApp />
|
|
366
381
|
</OxyProvider>
|
|
367
382
|
```
|
|
@@ -375,6 +390,7 @@ const { sdk, isLoading, error } = useOxy();
|
|
|
375
390
|
```
|
|
376
391
|
|
|
377
392
|
Returns:
|
|
393
|
+
|
|
378
394
|
- `sdk: OxySDK | null` - The SDK instance (null if not ready)
|
|
379
395
|
- `isLoading: boolean` - True while initializing
|
|
380
396
|
- `error: Error | null` - Initialization error if any
|
|
@@ -394,8 +410,8 @@ For advanced use cases, access the underlying client via `sdk.getClient()`:
|
|
|
394
410
|
```typescript
|
|
395
411
|
const client = sdk.getClient();
|
|
396
412
|
await client.listApps();
|
|
397
|
-
await client.getDisplays(
|
|
398
|
-
const blob = await client.getFile(
|
|
413
|
+
await client.getDisplays("my-app.app.yml");
|
|
414
|
+
const blob = await client.getFile("path/to/file.parquet");
|
|
399
415
|
```
|
|
400
416
|
|
|
401
417
|
### Advanced: ParquetReader
|
|
@@ -404,7 +420,7 @@ For advanced use cases, access the underlying reader via `sdk.getReader()`:
|
|
|
404
420
|
|
|
405
421
|
```typescript
|
|
406
422
|
const reader = sdk.getReader();
|
|
407
|
-
await reader.registerParquet(customBlob,
|
|
423
|
+
await reader.registerParquet(customBlob, "custom_table");
|
|
408
424
|
```
|
|
409
425
|
|
|
410
426
|
Or use standalone:
|
|
@@ -413,10 +429,10 @@ Or use standalone:
|
|
|
413
429
|
import { ParquetReader } from "@oxy/sdk";
|
|
414
430
|
|
|
415
431
|
const reader = new ParquetReader();
|
|
416
|
-
await reader.registerParquet(blob1,
|
|
417
|
-
await reader.registerParquet(blob2,
|
|
432
|
+
await reader.registerParquet(blob1, "table1");
|
|
433
|
+
await reader.registerParquet(blob2, "table2");
|
|
418
434
|
|
|
419
|
-
const result = await reader.query(
|
|
435
|
+
const result = await reader.query("SELECT * FROM table1 JOIN table2 ON ...");
|
|
420
436
|
await reader.close();
|
|
421
437
|
```
|
|
422
438
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
// @oxy/sdk - TypeScript SDK for Oxy data platform
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __exportAll = (all, no_symbols) => {
|
|
11
|
+
let target = {};
|
|
12
|
+
for (var name in all) {
|
|
13
|
+
__defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (!no_symbols) {
|
|
19
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
20
|
+
}
|
|
21
|
+
return target;
|
|
22
|
+
};
|
|
9
23
|
var __copyProps = (to, from, except, desc) => {
|
|
10
24
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
25
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -26,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
40
|
}) : target, mod));
|
|
27
41
|
|
|
28
42
|
//#endregion
|
|
29
|
-
const require_postMessage = require('./postMessage-
|
|
43
|
+
const require_postMessage = require('./postMessage-Cb5PCtcE.cjs');
|
|
30
44
|
let _duckdb_duckdb_wasm = require("@duckdb/duckdb-wasm");
|
|
31
45
|
_duckdb_duckdb_wasm = __toESM(_duckdb_duckdb_wasm);
|
|
32
46
|
let react = require("react");
|
|
@@ -107,13 +121,13 @@ function createConfig(overrides) {
|
|
|
107
121
|
* ```
|
|
108
122
|
*/
|
|
109
123
|
async function createConfigAsync(overrides) {
|
|
110
|
-
const { isInIframe
|
|
124
|
+
const { isInIframe } = await Promise.resolve().then(() => require("./postMessage-Cb5PCtcE.cjs")).then((n) => n.postMessage_exports);
|
|
111
125
|
let baseUrl = overrides?.baseUrl || getEnvVar("OXY_URL");
|
|
112
126
|
let apiKey = overrides?.apiKey || getEnvVar("OXY_API_KEY");
|
|
113
127
|
let projectId = overrides?.projectId || getEnvVar("OXY_PROJECT_ID");
|
|
114
128
|
const disableAutoAuth = overrides?.disableAutoAuth ?? false;
|
|
115
129
|
const parentOrigin = overrides?.parentOrigin || (window?.location.ancestorOrigins?.[0] ? window.location.ancestorOrigins[0] : "https://app.oxy.tech");
|
|
116
|
-
if (!disableAutoAuth && isInIframe
|
|
130
|
+
if (!disableAutoAuth && isInIframe() && !apiKey) if (!parentOrigin) logWarningAboutMissingParentOrigin();
|
|
117
131
|
else apiKey = await attemptPostMessageAuth(parentOrigin, overrides?.timeout || 5e3, apiKey, projectId, baseUrl).then((result) => {
|
|
118
132
|
if (result.projectId) projectId = result.projectId;
|
|
119
133
|
if (result.baseUrl) baseUrl = result.baseUrl;
|
|
@@ -128,8 +142,8 @@ function logWarningAboutMissingParentOrigin() {
|
|
|
128
142
|
console.warn("[Oxy SDK] Running in iframe without API key and no parentOrigin specified. PostMessage authentication will be skipped. Provide parentOrigin config to enable automatic authentication.");
|
|
129
143
|
}
|
|
130
144
|
async function attemptPostMessageAuth(parentOrigin, timeout, currentApiKey, currentProjectId, currentBaseUrl) {
|
|
131
|
-
const { requestAuthFromParent
|
|
132
|
-
const authResult = await requestAuthFromParent
|
|
145
|
+
const { requestAuthFromParent } = await Promise.resolve().then(() => require("./postMessage-Cb5PCtcE.cjs")).then((n) => n.postMessage_exports);
|
|
146
|
+
const authResult = await requestAuthFromParent({
|
|
133
147
|
parentOrigin,
|
|
134
148
|
timeout
|
|
135
149
|
});
|
|
@@ -459,11 +473,12 @@ var OxyClient = class OxyClient {
|
|
|
459
473
|
return new OxyClient(await createConfigAsync(config));
|
|
460
474
|
}
|
|
461
475
|
/**
|
|
462
|
-
* Encodes a file path to base64 for use in API URLs
|
|
476
|
+
* Encodes a file path to base64 for use in API URLs.
|
|
477
|
+
* Handles Unicode characters (e.g., emojis) properly in both Node.js and browser.
|
|
463
478
|
*/
|
|
464
479
|
encodePathBase64(path) {
|
|
465
480
|
if (typeof Buffer !== "undefined") return Buffer.from(path).toString("base64");
|
|
466
|
-
else return btoa(path);
|
|
481
|
+
else return btoa(encodeURIComponent(path).replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(parseInt(p1, 16))));
|
|
467
482
|
}
|
|
468
483
|
/**
|
|
469
484
|
* Makes an authenticated HTTP request to the Oxy API
|
|
@@ -474,7 +489,7 @@ var OxyClient = class OxyClient {
|
|
|
474
489
|
"Content-Type": "application/json",
|
|
475
490
|
...options.headers || {}
|
|
476
491
|
};
|
|
477
|
-
if (this.config.apiKey) headers
|
|
492
|
+
if (this.config.apiKey) headers.Authorization = `Bearer ${this.config.apiKey}`;
|
|
478
493
|
const controller = new AbortController();
|
|
479
494
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout || 3e4);
|
|
480
495
|
try {
|
|
@@ -492,7 +507,7 @@ var OxyClient = class OxyClient {
|
|
|
492
507
|
details: errorText
|
|
493
508
|
};
|
|
494
509
|
}
|
|
495
|
-
if ((typeof options.headers === "object" && options.headers !== null ? options.headers
|
|
510
|
+
if ((typeof options.headers === "object" && options.headers !== null ? options.headers.Accept : void 0) === "application/octet-stream") return response.blob();
|
|
496
511
|
return response.json();
|
|
497
512
|
} catch (error) {
|
|
498
513
|
clearTimeout(timeoutId);
|
|
@@ -522,7 +537,7 @@ var OxyClient = class OxyClient {
|
|
|
522
537
|
*/
|
|
523
538
|
async listApps() {
|
|
524
539
|
const query = this.buildQueryParams();
|
|
525
|
-
return this.request(`/${this.config.projectId}/
|
|
540
|
+
return this.request(`/${this.config.projectId}/apps${query}`);
|
|
526
541
|
}
|
|
527
542
|
/**
|
|
528
543
|
* Gets data for a specific app
|
|
@@ -543,7 +558,7 @@ var OxyClient = class OxyClient {
|
|
|
543
558
|
async getAppData(appPath) {
|
|
544
559
|
const pathb64 = this.encodePathBase64(appPath);
|
|
545
560
|
const query = this.buildQueryParams();
|
|
546
|
-
return this.request(`/${this.config.projectId}/
|
|
561
|
+
return this.request(`/${this.config.projectId}/apps/${pathb64}${query}`);
|
|
547
562
|
}
|
|
548
563
|
/**
|
|
549
564
|
* Runs an app and returns fresh data (bypasses cache)
|
|
@@ -560,7 +575,7 @@ var OxyClient = class OxyClient {
|
|
|
560
575
|
async runApp(appPath) {
|
|
561
576
|
const pathb64 = this.encodePathBase64(appPath);
|
|
562
577
|
const query = this.buildQueryParams();
|
|
563
|
-
return this.request(`/${this.config.projectId}/
|
|
578
|
+
return this.request(`/${this.config.projectId}/apps/${pathb64}/run${query}`, { method: "POST" });
|
|
564
579
|
}
|
|
565
580
|
/**
|
|
566
581
|
* Gets display configurations for an app
|
|
@@ -583,7 +598,7 @@ var OxyClient = class OxyClient {
|
|
|
583
598
|
async getDisplays(appPath) {
|
|
584
599
|
const pathb64 = this.encodePathBase64(appPath);
|
|
585
600
|
const query = this.buildQueryParams();
|
|
586
|
-
return this.request(`/${this.config.projectId}/
|
|
601
|
+
return this.request(`/${this.config.projectId}/apps/${pathb64}/displays${query}`);
|
|
587
602
|
}
|
|
588
603
|
/**
|
|
589
604
|
* Gets a file from the app state directory (e.g., generated charts, images)
|
|
@@ -617,7 +632,7 @@ var OxyClient = class OxyClient {
|
|
|
617
632
|
async getFile(filePath) {
|
|
618
633
|
const pathb64 = this.encodePathBase64(filePath);
|
|
619
634
|
const query = this.buildQueryParams();
|
|
620
|
-
return this.request(`/${this.config.projectId}/
|
|
635
|
+
return this.request(`/${this.config.projectId}/apps/file/${pathb64}${query}`, { headers: { Accept: "application/octet-stream" } });
|
|
621
636
|
}
|
|
622
637
|
/**
|
|
623
638
|
* Gets a file URL for direct browser access
|
|
@@ -639,7 +654,7 @@ var OxyClient = class OxyClient {
|
|
|
639
654
|
getFileUrl(filePath) {
|
|
640
655
|
const pathb64 = this.encodePathBase64(filePath);
|
|
641
656
|
const query = this.buildQueryParams();
|
|
642
|
-
return `${this.config.baseUrl}/${this.config.projectId}/
|
|
657
|
+
return `${this.config.baseUrl}/${this.config.projectId}/apps/file/${pathb64}${query}`;
|
|
643
658
|
}
|
|
644
659
|
/**
|
|
645
660
|
* Fetches a parquet file and parses it into table data
|
|
@@ -949,8 +964,24 @@ const OxyContext = (0, react.createContext)(void 0);
|
|
|
949
964
|
* );
|
|
950
965
|
* }
|
|
951
966
|
* ```
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```tsx
|
|
970
|
+
* // With loading and error slots
|
|
971
|
+
* function App() {
|
|
972
|
+
* return (
|
|
973
|
+
* <OxyProvider
|
|
974
|
+
* config={createConfig()}
|
|
975
|
+
* loadingFallback={<div>Loading SDK...</div>}
|
|
976
|
+
* errorFallback={(error) => <div>Error: {error.message}</div>}
|
|
977
|
+
* >
|
|
978
|
+
* <Dashboard />
|
|
979
|
+
* </OxyProvider>
|
|
980
|
+
* );
|
|
981
|
+
* }
|
|
982
|
+
* ```
|
|
952
983
|
*/
|
|
953
|
-
function OxyProvider({ children, config, useAsync = false, appPath, files, onReady, onError }) {
|
|
984
|
+
function OxyProvider({ children, config, useAsync = false, appPath, files, onReady, onError, loadingFallback, errorFallback }) {
|
|
954
985
|
const [sdk, setSdk] = (0, react.useState)(null);
|
|
955
986
|
const [isLoading, setIsLoading] = (0, react.useState)(true);
|
|
956
987
|
const [error, setError] = (0, react.useState)(null);
|
|
@@ -981,11 +1012,11 @@ function OxyProvider({ children, config, useAsync = false, appPath, files, onRea
|
|
|
981
1012
|
onReady?.(sdkInstance);
|
|
982
1013
|
}
|
|
983
1014
|
} catch (err) {
|
|
984
|
-
const error
|
|
1015
|
+
const error = err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to initialize SDK");
|
|
985
1016
|
if (mounted) {
|
|
986
|
-
setError(error
|
|
1017
|
+
setError(error);
|
|
987
1018
|
setIsLoading(false);
|
|
988
|
-
onError?.(error
|
|
1019
|
+
onError?.(error);
|
|
989
1020
|
}
|
|
990
1021
|
}
|
|
991
1022
|
}
|
|
@@ -1000,11 +1031,16 @@ function OxyProvider({ children, config, useAsync = false, appPath, files, onRea
|
|
|
1000
1031
|
onReady,
|
|
1001
1032
|
onError
|
|
1002
1033
|
]);
|
|
1034
|
+
const content = (() => {
|
|
1035
|
+
if (isLoading && loadingFallback !== void 0) return loadingFallback;
|
|
1036
|
+
if (error && errorFallback !== void 0) return typeof errorFallback === "function" ? errorFallback(error) : errorFallback;
|
|
1037
|
+
return children;
|
|
1038
|
+
})();
|
|
1003
1039
|
return /* @__PURE__ */ react.default.createElement(OxyContext.Provider, { value: {
|
|
1004
1040
|
sdk,
|
|
1005
1041
|
isLoading,
|
|
1006
1042
|
error
|
|
1007
|
-
} },
|
|
1043
|
+
} }, content);
|
|
1008
1044
|
}
|
|
1009
1045
|
/**
|
|
1010
1046
|
* Hook to access OxySDK from child components
|
|
@@ -1079,6 +1115,7 @@ exports.PostMessageAuthInvalidOriginError = require_postMessage.PostMessageAuthI
|
|
|
1079
1115
|
exports.PostMessageAuthInvalidResponseError = require_postMessage.PostMessageAuthInvalidResponseError;
|
|
1080
1116
|
exports.PostMessageAuthNotInIframeError = require_postMessage.PostMessageAuthNotInIframeError;
|
|
1081
1117
|
exports.PostMessageAuthTimeoutError = require_postMessage.PostMessageAuthTimeoutError;
|
|
1118
|
+
exports.__exportAll = __exportAll;
|
|
1082
1119
|
exports.createConfig = createConfig;
|
|
1083
1120
|
exports.createConfigAsync = createConfigAsync;
|
|
1084
1121
|
exports.initializeDuckDB = initializeDuckDB;
|