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
8 changes: 8 additions & 0 deletions .changeset/slimy-hairs-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@workflow/world-postgres": patch
"@workflow/world-vercel": patch
"@workflow/world-local": patch
"@workflow/world": patch
---

Remove `AuthProvider` interface from `World` and associated implementations
20 changes: 0 additions & 20 deletions packages/world-local/src/auth.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/world-local/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { World } from '@workflow/world';
import { auth } from './auth.js';
import { config } from './config.js';
import { createQueue } from './queue.js';
import { createStorage } from './storage.js';
import { createStreamer } from './streamer.js';

/**
* Creates an embedded world instance that combines queue, storage, streamer, and authentication functionalities.
* Creates an embedded world instance that combines queue, storage, and streamer functionalities.
*
* @param dataDir - The directory to use for storage. If not provided, the default data dir will be used.
* @param port - The port to use for the queue. If not provided, the default port will be used.
Expand All @@ -24,6 +23,5 @@ export function createEmbeddedWorld({
...createQueue(queuePort),
...createStorage(dir),
...createStreamer(dir),
...auth,
};
}
43 changes: 1 addition & 42 deletions packages/world-postgres/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AuthProvider, Storage, World } from '@workflow/world';
import type { Storage, World } from '@workflow/world';
import PgBoss from 'pg-boss';
import createPostgres from 'postgres';
import type { PostgresWorldConfig } from './config.js';
Expand All @@ -21,45 +21,6 @@ function createStorage(drizzle: Drizzle): Storage {
};
}

function createAuthProvider(
_config: PostgresWorldConfig,
boss: PgBoss
): AuthProvider {
return {
async getAuthInfo() {
return {
environment: 'postgres',
ownerId: 'postgres',
projectId: 'postgres',
};
},
async checkHealth() {
try {
if (!(await boss.isInstalled())) {
throw new Error('Postgres Boss is not installed properly');
}
} catch (err) {
return {
success: false,
data: { healthy: false },
message:
err &&
typeof err === 'object' &&
'message' in err &&
typeof err.message === 'string'
? err.message
: String(err),
};
}
return {
success: true,
message: 'Postgres connection is healthy',
data: { healthy: true },
};
},
};
}

export function createWorld(
config: PostgresWorldConfig = {
connectionString:
Expand All @@ -79,12 +40,10 @@ export function createWorld(
const queue = createQueue(boss, config);
const storage = createStorage(drizzle);
const streamer = createStreamer(postgres, drizzle);
const auth = createAuthProvider(config, boss);

return {
...storage,
...streamer,
...auth,
...queue,
async start() {
await queue.start();
Expand Down
37 changes: 0 additions & 37 deletions packages/world-vercel/src/auth.ts

This file was deleted.

10 changes: 2 additions & 8 deletions packages/world-vercel/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { AuthProvider, Storage, Streamer } from '@workflow/world';
import type { Storage, Streamer } from '@workflow/world';
import { createStorage } from './storage.js';
import { createStreamer } from './streamer.js';
import type { APIConfig } from './utils.js';

export function createVercel(
config?: APIConfig
): Streamer & Storage & AuthProvider {
export function createVercel(config?: APIConfig): Streamer & Storage {
const storage = createStorage(config);
const streamer = createStreamer(config);

Expand All @@ -15,10 +13,6 @@ export function createVercel(
closeStream: streamer.closeStream,
readFromStream: streamer.readFromStream,

// AuthProvider interface
getAuthInfo: storage.getAuthInfo,
checkHealth: storage.checkHealth,

// Storage interface with namespaced methods
runs: storage.runs,
steps: storage.steps,
Expand Down
2 changes: 0 additions & 2 deletions packages/world-vercel/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { World } from '@workflow/world';
import { createAuth } from './auth.js';
import { createQueue } from './queue.js';
import { createStorage } from './storage.js';
import { createStreamer } from './streamer.js';
Expand All @@ -14,7 +13,6 @@ export function createVercelWorld(config?: APIConfig): World {
return {
...createQueue(),
...createStorage(config),
...createAuth(config),
...createStreamer(config),
};
}
9 changes: 2 additions & 7 deletions packages/world-vercel/src/storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AuthProvider, Storage } from '@workflow/world';
import { checkHealth, getAuthInfo } from './auth.js';
import type { Storage } from '@workflow/world';
import { createWorkflowRunEvent, getWorkflowRunEvents } from './events.js';
import {
createHook,
Expand All @@ -25,12 +24,8 @@ import {
} from './steps.js';
import type { APIConfig } from './utils.js';

export function createStorage(config?: APIConfig): Storage & AuthProvider {
export function createStorage(config?: APIConfig): Storage {
return {
// AuthProvider interface
getAuthInfo: () => getAuthInfo(config),
checkHealth: () => checkHealth(config),

// Storage interface with namespaced methods
runs: {
create: (data) => createWorkflowRun(data, config),
Expand Down
23 changes: 0 additions & 23 deletions packages/world/src/auth.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/world/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type * from './auth.js';
export { AuthInfoSchema, HealthCheckResponseSchema } from './auth.js';
export type * from './events.js';
export {
BaseEventSchema,
Expand Down
9 changes: 1 addition & 8 deletions packages/world/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { AuthInfo, HealthCheckResponse } from './auth.js';
import type {
CreateEventParams,
CreateEventRequest,
Expand Down Expand Up @@ -44,11 +43,6 @@ export interface Streamer {
): Promise<ReadableStream<Uint8Array>>;
}

export interface AuthProvider {
getAuthInfo(): Promise<AuthInfo>;
checkHealth(): Promise<HealthCheckResponse>;
}

export interface Storage {
runs: {
create(data: CreateWorkflowRunRequest): Promise<WorkflowRun>;
Expand Down Expand Up @@ -104,9 +98,8 @@ export interface Storage {

/**
* The "World" interface represents how Workflows are able to communicate with the outside world.
* This means persistence, queuing and serialization.
*/
export interface World extends Queue, Storage, AuthProvider, Streamer {
export interface World extends Queue, Storage, Streamer {
/**
* A function that will be called to start any background tasks needed by the World implementation.
* For example, in the case of a queue backed World, this would start the queue processing.
Expand Down