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
12 changes: 7 additions & 5 deletions apps/dev-playground/server/lakebase-examples-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, toPlugin } from "@databricks/appkit";
import { getUsernameWithApiLookup, Plugin, toPlugin } from "@databricks/appkit";
import type { IAppRouter } from "shared";
import * as drizzleExample from "./lakebase-examples/drizzle-example";
import * as rawExample from "./lakebase-examples/raw-driver-example";
Expand Down Expand Up @@ -42,12 +42,14 @@ export class LakebaseExamplesPlugin extends Plugin {
}

try {
const user = await getUsernameWithApiLookup();

// Initialize all four examples in parallel
await Promise.all([
rawExample.setup(),
drizzleExample.setup(),
typeormExample.setup(),
sequelizeExample.setup(),
rawExample.setup(user),
drizzleExample.setup(user),
typeormExample.setup(user),
sequelizeExample.setup(user),
]);
} catch (error) {
console.error("Failed to initialize Lakebase examples:", error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type NewActivityLog = typeof activityLogs.$inferInsert;
let db: ReturnType<typeof drizzle>;
let pool: Pool;

export async function setup() {
pool = createLakebasePool();
export async function setup(user?: string) {
pool = createLakebasePool({ user });
db = drizzle(pool);

// For production apps, use: npx drizzle-kit push or drizzle-kit generate + migrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ interface Product {
created_at: Date;
}

export async function setup() {
export async function setup(user?: string) {
// Create pool with automatic OAuth token refresh
pool = createLakebasePool();
pool = createLakebasePool({ user });

// Create schema and table (idempotent)
await pool.query(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Order

let sequelize: Sequelize;

export async function setup() {
export async function setup(user?: string) {
// @ts-expect-error password property supports a function for Lakehouse OAuth tokens
sequelize = new Sequelize({
dialect: "postgres",
...getLakebaseOrmConfig(),
...getLakebaseOrmConfig({ user }),
logging: false,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ class Task {

let dataSource: DataSource;

export async function setup() {
export async function setup(user?: string) {
// Create schema if not exists (TypeORM's synchronize doesn't create schemas)
// See https://github.com/typeorm/typeorm/issues/3192
const pool = createLakebasePool();
const pool = createLakebasePool({ user });
await pool.query("CREATE SCHEMA IF NOT EXISTS typeorm_example");
await pool.end();

dataSource = new DataSource({
type: "postgres",
...getLakebaseOrmConfig(),
...getLakebaseOrmConfig({ user }),
entities: [Task],
synchronize: true,
logging: false,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The backend SDK that provides the plugin architecture and core functionality. It
- Cache management and streaming capabilities
- Type generation for SQL queries

See the [Plugins](./plugins.md) and [API reference](./api/appkit/) documentation for detailed information.
See the [Plugins](./plugins/index.md) and [API reference](./api/appkit/) documentation for detailed information.

### @databricks/appkit-ui

Expand Down Expand Up @@ -87,7 +87,7 @@ Integration with Databricks services:

## See also

- [Plugins](./plugins.md): Deep dive into the plugin system
- [Plugins](./plugins/index.md): Deep dive into the plugin system
- [API reference](./api/): Complete API documentation
- [Development](./development/): Explore development workflows
- [Core Principles](./core-principles.md): Learn about AppKit's design philosophy
2 changes: 1 addition & 1 deletion docs/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ For advanced Databricks Apps configuration (authorization, networking, resource
## See also

- [App management](./app-management.mdx) - Deploying and managing apps
- [Plugins](./plugins.md) - Plugin configuration options
- [Plugins](./plugins/index.md) - Plugin configuration options
2 changes: 1 addition & 1 deletion docs/docs/development/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ Then create `config/queries/` and add your `.sql` files.

- [Local development](./local-development.mdx) - Running the dev server
- [Configuration](../configuration.mdx) - Environment variables
- [Plugins](../plugins.md) - Plugin configuration
- [Plugins](../plugins/index.md) - Plugin configuration
2 changes: 1 addition & 1 deletion docs/docs/development/type-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ data?.forEach(row => {

## See also

- [Plugins](../plugins.md) - Analytics plugin configuration
- [Plugins](../plugins/index.md) - Analytics plugin configuration
- [API Reference](/docs/api/appkit-ui) - Complete UI components API documentation
Loading