Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dev-playground/client/src/routes/analytics.route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function AnalyticsRoute() {
data: untaggedAppsData,
loading: untaggedAppsLoading,
error: untaggedAppsError,
} = useAnalyticsQuery("untagged_apps", untaggedAppsParams);
} = useAnalyticsQuery("untagged_apps", untaggedAppsParams, { asUser: true });

const metrics = useMemo(() => {
if (!summaryDataRaw || summaryDataRaw.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ function ArrowAnalyticsRoute() {

<main className="max-w-7xl mx-auto px-6 py-12">
<div className="flex flex-col gap-6">
{/* ============================================================ */}
{/* UNIFIED CHARTS - FORMAT COMPARISON */}
{/* ============================================================ */}
<div>
<h2 className="text-2xl font-bold mb-4">Unified Charts API</h2>
<p className="text-muted-foreground mb-6">
Expand Down
46 changes: 45 additions & 1 deletion apps/dev-playground/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,49 @@ import { reconnect } from "./reconnect-plugin";
import { telemetryExamples } from "./telemetry-example-plugin";

createApp({
plugins: [server(), reconnect(), telemetryExamples(), analytics({})],
plugins: [
server({ autoStart: false }),
reconnect(),
telemetryExamples(),
analytics({}),
],
}).then((appkit) => {
appkit.server
.extend((app) => {
app.get("/sp", (_req, res) => {
appkit.analytics
.query("SELECT * FROM samples.nyctaxi.trips;")
.then((result) => {
console.log(result[0]);
res.json(result);
})
.catch((error) => {
console.error("Error:", error);
res.status(500).json({
error: error.message,
errorCode: error.errorCode,
statusCode: error.statusCode,
});
});
});

app.get("/obo", (req, res) => {
appkit.analytics
.asUser(req)
.query("SELECT * FROM samples.nyctaxi.trips;")
.then((result) => {
console.log(result[0]);
res.json(result);
})
.catch((error) => {
console.error("OBO Error:", error);
res.status(500).json({
error: error.message,
errorCode: error.errorCode,
statusCode: error.statusCode,
});
});
});
})
.start();
});
113 changes: 76 additions & 37 deletions docs/docs/api/appkit/Class.Plugin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Abstract Class: Plugin\<TConfig\>

Defined in: [appkit/src/plugin/plugin.ts:33](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L33)
Defined in: [appkit/src/plugin/plugin.ts:58](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L58)

## Type Parameters

Expand All @@ -20,7 +20,7 @@ Defined in: [appkit/src/plugin/plugin.ts:33](https://github.com/databricks/appki
new Plugin<TConfig>(config: TConfig): Plugin<TConfig>;
```

Defined in: [appkit/src/plugin/plugin.ts:54](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L54)
Defined in: [appkit/src/plugin/plugin.ts:76](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L76)

#### Parameters

Expand All @@ -40,7 +40,7 @@ Defined in: [appkit/src/plugin/plugin.ts:54](https://github.com/databricks/appki
protected app: AppManager;
```

Defined in: [appkit/src/plugin/plugin.ts:39](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L39)
Defined in: [appkit/src/plugin/plugin.ts:64](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L64)

***

Expand All @@ -50,7 +50,7 @@ Defined in: [appkit/src/plugin/plugin.ts:39](https://github.com/databricks/appki
protected cache: CacheManager;
```

Defined in: [appkit/src/plugin/plugin.ts:38](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L38)
Defined in: [appkit/src/plugin/plugin.ts:63](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L63)

***

Expand All @@ -60,7 +60,7 @@ Defined in: [appkit/src/plugin/plugin.ts:38](https://github.com/databricks/appki
protected config: TConfig;
```

Defined in: [appkit/src/plugin/plugin.ts:54](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L54)
Defined in: [appkit/src/plugin/plugin.ts:76](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L76)

***

Expand All @@ -70,7 +70,7 @@ Defined in: [appkit/src/plugin/plugin.ts:54](https://github.com/databricks/appki
protected devFileReader: DevFileReader;
```

Defined in: [appkit/src/plugin/plugin.ts:40](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L40)
Defined in: [appkit/src/plugin/plugin.ts:65](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L65)

***

Expand All @@ -80,7 +80,7 @@ Defined in: [appkit/src/plugin/plugin.ts:40](https://github.com/databricks/appki
abstract protected envVars: string[];
```

Defined in: [appkit/src/plugin/plugin.ts:43](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L43)
Defined in: [appkit/src/plugin/plugin.ts:68](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L68)

***

Expand All @@ -90,7 +90,7 @@ Defined in: [appkit/src/plugin/plugin.ts:43](https://github.com/databricks/appki
protected isReady: boolean = false;
```

Defined in: [appkit/src/plugin/plugin.ts:37](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L37)
Defined in: [appkit/src/plugin/plugin.ts:62](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L62)

***

Expand All @@ -100,7 +100,7 @@ Defined in: [appkit/src/plugin/plugin.ts:37](https://github.com/databricks/appki
name: string;
```

Defined in: [appkit/src/plugin/plugin.ts:52](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L52)
Defined in: [appkit/src/plugin/plugin.ts:74](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L74)

#### Implementation of

Expand All @@ -110,25 +110,13 @@ BasePlugin.name

***

### requiresDatabricksClient

```ts
requiresDatabricksClient: boolean = false;
```

Defined in: [appkit/src/plugin/plugin.ts:46](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L46)

If the plugin requires the Databricks client to be set in the request context

***

### streamManager

```ts
protected streamManager: StreamManager;
```

Defined in: [appkit/src/plugin/plugin.ts:41](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L41)
Defined in: [appkit/src/plugin/plugin.ts:66](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L66)

***

Expand All @@ -138,7 +126,7 @@ Defined in: [appkit/src/plugin/plugin.ts:41](https://github.com/databricks/appki
protected telemetry: ITelemetry;
```

Defined in: [appkit/src/plugin/plugin.ts:42](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L42)
Defined in: [appkit/src/plugin/plugin.ts:67](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L67)

***

Expand All @@ -148,7 +136,7 @@ Defined in: [appkit/src/plugin/plugin.ts:42](https://github.com/databricks/appki
static phase: PluginPhase = "normal";
```

Defined in: [appkit/src/plugin/plugin.ts:51](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L51)
Defined in: [appkit/src/plugin/plugin.ts:73](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L73)

## Methods

Expand All @@ -158,7 +146,7 @@ Defined in: [appkit/src/plugin/plugin.ts:51](https://github.com/databricks/appki
abortActiveOperations(): void;
```

Defined in: [appkit/src/plugin/plugin.ts:79](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L79)
Defined in: [appkit/src/plugin/plugin.ts:101](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L101)

#### Returns

Expand All @@ -172,16 +160,67 @@ BasePlugin.abortActiveOperations

***

### asUser()

```ts
asUser(req: Request): this;
```

Defined in: [appkit/src/plugin/plugin.ts:134](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L134)

Execute operations using the user's identity from the request.

Returns a scoped instance of this plugin where all method calls
will execute with the user's Databricks credentials instead of
the service principal.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `req` | `Request` | The Express request containing the user token in headers |

#### Returns

`this`

A scoped plugin instance that executes as the user

#### Throws

Error if user token is not available in request headers

#### Example

```typescript
// In route handler - execute query as the requesting user
router.post('/users/me/query/:key', async (req, res) => {
const result = await this.asUser(req).query(req.params.key)
res.json(result)
})

// Mixed execution in same handler
router.post('/dashboard', async (req, res) => {
const [systemData, userData] = await Promise.all([
this.getSystemStats(), // Service principal
this.asUser(req).getUserPreferences(), // User context
])
res.json({ systemData, userData })
})
```

***

### execute()

```ts
protected execute<T>(
fn: (signal?: AbortSignal) => Promise<T>,
options: PluginExecutionSettings,
userKey: string): Promise<T | undefined>;
userKey?: string): Promise<T | undefined>;
```

Defined in: [appkit/src/plugin/plugin.ts:143](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L143)
Defined in: [appkit/src/plugin/plugin.ts:263](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L263)

#### Type Parameters

Expand All @@ -195,7 +234,7 @@ Defined in: [appkit/src/plugin/plugin.ts:143](https://github.com/databricks/appk
| ------ | ------ |
| `fn` | (`signal?`: `AbortSignal`) => `Promise`\<`T`\> |
| `options` | `PluginExecutionSettings` |
| `userKey` | `string` |
| `userKey?` | `string` |

#### Returns

Expand All @@ -210,10 +249,10 @@ protected executeStream<T>(
res: IAppResponse,
fn: StreamExecuteHandler<T>,
options: StreamExecutionSettings,
userKey: string): Promise<void>;
userKey?: string): Promise<void>;
```

Defined in: [appkit/src/plugin/plugin.ts:84](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L84)
Defined in: [appkit/src/plugin/plugin.ts:201](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L201)

#### Type Parameters

Expand All @@ -228,7 +267,7 @@ Defined in: [appkit/src/plugin/plugin.ts:84](https://github.com/databricks/appki
| `res` | `IAppResponse` |
| `fn` | `StreamExecuteHandler`\<`T`\> |
| `options` | [`StreamExecutionSettings`](Interface.StreamExecutionSettings.md) |
| `userKey` | `string` |
| `userKey?` | `string` |

#### Returns

Expand All @@ -242,7 +281,7 @@ Defined in: [appkit/src/plugin/plugin.ts:84](https://github.com/databricks/appki
getEndpoints(): PluginEndpointMap;
```

Defined in: [appkit/src/plugin/plugin.ts:75](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L75)
Defined in: [appkit/src/plugin/plugin.ts:97](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L97)

#### Returns

Expand All @@ -262,7 +301,7 @@ BasePlugin.getEndpoints
injectRoutes(_: Router): void;
```

Defined in: [appkit/src/plugin/plugin.ts:69](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L69)
Defined in: [appkit/src/plugin/plugin.ts:91](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L91)

#### Parameters

Expand All @@ -288,7 +327,7 @@ BasePlugin.injectRoutes
protected registerEndpoint(name: string, path: string): void;
```

Defined in: [appkit/src/plugin/plugin.ts:165](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L165)
Defined in: [appkit/src/plugin/plugin.ts:288](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L288)

#### Parameters

Expand All @@ -309,7 +348,7 @@ Defined in: [appkit/src/plugin/plugin.ts:165](https://github.com/databricks/appk
protected route<_TResponse>(router: Router, config: RouteConfig): void;
```

Defined in: [appkit/src/plugin/plugin.ts:169](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L169)
Defined in: [appkit/src/plugin/plugin.ts:292](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L292)

#### Type Parameters

Expand All @@ -336,7 +375,7 @@ Defined in: [appkit/src/plugin/plugin.ts:169](https://github.com/databricks/appk
setup(): Promise<void>;
```

Defined in: [appkit/src/plugin/plugin.ts:73](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L73)
Defined in: [appkit/src/plugin/plugin.ts:95](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L95)

#### Returns

Expand All @@ -356,7 +395,7 @@ BasePlugin.setup
validateEnv(): void;
```

Defined in: [appkit/src/plugin/plugin.ts:65](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L65)
Defined in: [appkit/src/plugin/plugin.ts:87](https://github.com/databricks/appkit/blob/main/packages/appkit/src/plugin/plugin.ts#L87)

#### Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/appkit/Function.createApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function createApp<T>(config: {
}): Promise<PluginMap<T>>;
```

Defined in: [appkit/src/core/appkit.ts:127](https://github.com/databricks/appkit/blob/main/packages/appkit/src/core/appkit.ts#L127)
Defined in: [appkit/src/core/appkit.ts:133](https://github.com/databricks/appkit/blob/main/packages/appkit/src/core/appkit.ts#L133)

Bootstraps AppKit with the provided configuration.

Expand Down
14 changes: 0 additions & 14 deletions docs/docs/api/appkit/Function.getRequestContext.md

This file was deleted.

Loading