From f1a7262a1cb4107b542d6a0a52e07dc99fe1ebf0 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 25 Oct 2025 00:02:47 -0700 Subject: [PATCH 1/3] Remove `AuthProvider` interface from `World` and associated implementations The `getAuthInfo()` and `checkHealth()` were never being used. Let's from from the World interface to simplify things for implementors. --- .changeset/slimy-hairs-thank.md | 8 ++++++ packages/world-local/src/auth.ts | 20 ------------- packages/world-local/src/index.ts | 2 -- packages/world-postgres/src/index.ts | 43 +--------------------------- packages/world-vercel/src/auth.ts | 37 ------------------------ packages/world-vercel/src/backend.ts | 10 ++----- packages/world-vercel/src/index.ts | 2 -- packages/world-vercel/src/storage.ts | 9 ++---- packages/world/src/auth.ts | 23 --------------- packages/world/src/index.ts | 2 -- packages/world/src/interfaces.ts | 8 +----- 11 files changed, 14 insertions(+), 150 deletions(-) create mode 100644 .changeset/slimy-hairs-thank.md delete mode 100644 packages/world-local/src/auth.ts delete mode 100644 packages/world-vercel/src/auth.ts delete mode 100644 packages/world/src/auth.ts diff --git a/.changeset/slimy-hairs-thank.md b/.changeset/slimy-hairs-thank.md new file mode 100644 index 000000000..d87993c32 --- /dev/null +++ b/.changeset/slimy-hairs-thank.md @@ -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 diff --git a/packages/world-local/src/auth.ts b/packages/world-local/src/auth.ts deleted file mode 100644 index 64fd900df..000000000 --- a/packages/world-local/src/auth.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { AuthProvider } from '@workflow/world'; - -export const auth: AuthProvider = { - async getAuthInfo() { - return { - ownerId: 'embedded-owner', - projectId: 'embedded-project', - environment: 'embedded', - userId: 'embedded-user', - }; - }, - - async checkHealth() { - return { - success: true, - data: { healthy: true }, - message: 'Embedded backend is healthy', - }; - }, -}; diff --git a/packages/world-local/src/index.ts b/packages/world-local/src/index.ts index 529c82e70..4d71ebfca 100644 --- a/packages/world-local/src/index.ts +++ b/packages/world-local/src/index.ts @@ -1,5 +1,4 @@ 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'; @@ -24,6 +23,5 @@ export function createEmbeddedWorld({ ...createQueue(queuePort), ...createStorage(dir), ...createStreamer(dir), - ...auth, }; } diff --git a/packages/world-postgres/src/index.ts b/packages/world-postgres/src/index.ts index 82f1d9e87..edd9e86ec 100644 --- a/packages/world-postgres/src/index.ts +++ b/packages/world-postgres/src/index.ts @@ -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'; @@ -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: @@ -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(); diff --git a/packages/world-vercel/src/auth.ts b/packages/world-vercel/src/auth.ts deleted file mode 100644 index 146a3dbf8..000000000 --- a/packages/world-vercel/src/auth.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { - type AuthInfo, - AuthInfoSchema, - type AuthProvider, - type HealthCheckResponse, - HealthCheckResponseSchema, -} from '@workflow/world'; -import type { APIConfig } from './utils.js'; -import { makeRequest } from './utils.js'; - -// Functions -export async function getAuthInfo(config?: APIConfig): Promise { - return makeRequest({ - endpoint: '/v1', - options: { method: 'GET' }, - config, - schema: AuthInfoSchema, - }); -} - -export async function checkHealth( - config?: APIConfig -): Promise { - return makeRequest({ - endpoint: '/v1/health', - options: { method: 'GET' }, - config, - schema: HealthCheckResponseSchema, - }); -} - -export function createAuth(config?: APIConfig): AuthProvider { - return { - checkHealth: () => checkHealth(config), - getAuthInfo: () => getAuthInfo(config), - }; -} diff --git a/packages/world-vercel/src/backend.ts b/packages/world-vercel/src/backend.ts index f2f744780..ee0045037 100644 --- a/packages/world-vercel/src/backend.ts +++ b/packages/world-vercel/src/backend.ts @@ -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); @@ -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, diff --git a/packages/world-vercel/src/index.ts b/packages/world-vercel/src/index.ts index cdae3acd6..6c42bf200 100644 --- a/packages/world-vercel/src/index.ts +++ b/packages/world-vercel/src/index.ts @@ -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'; @@ -14,7 +13,6 @@ export function createVercelWorld(config?: APIConfig): World { return { ...createQueue(), ...createStorage(config), - ...createAuth(config), ...createStreamer(config), }; } diff --git a/packages/world-vercel/src/storage.ts b/packages/world-vercel/src/storage.ts index 6501aa571..51c5a8eaf 100644 --- a/packages/world-vercel/src/storage.ts +++ b/packages/world-vercel/src/storage.ts @@ -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, @@ -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), diff --git a/packages/world/src/auth.ts b/packages/world/src/auth.ts deleted file mode 100644 index 5e172eacb..000000000 --- a/packages/world/src/auth.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { z } from 'zod'; - -// Auth schemas -export const AuthInfoSchema = z.object({ - ownerId: z.string(), - projectId: z.string(), - environment: z.string(), - userId: z.string().optional(), -}); - -export const HealthCheckResponseSchema = z.object({ - success: z.boolean(), - data: z - .object({ - healthy: z.boolean(), - }) - .and(z.record(z.string(), z.any())), - message: z.string(), -}); - -// Inferred types -export type AuthInfo = z.infer; -export type HealthCheckResponse = z.infer; diff --git a/packages/world/src/index.ts b/packages/world/src/index.ts index 81e7f4b76..6074ab048 100644 --- a/packages/world/src/index.ts +++ b/packages/world/src/index.ts @@ -1,5 +1,3 @@ -export type * from './auth.js'; -export { AuthInfoSchema, HealthCheckResponseSchema } from './auth.js'; export type * from './events.js'; export { BaseEventSchema, diff --git a/packages/world/src/interfaces.ts b/packages/world/src/interfaces.ts index b0e0c991b..1d4ccfb34 100644 --- a/packages/world/src/interfaces.ts +++ b/packages/world/src/interfaces.ts @@ -1,4 +1,3 @@ -import type { AuthInfo, HealthCheckResponse } from './auth.js'; import type { CreateEventParams, CreateEventRequest, @@ -44,11 +43,6 @@ export interface Streamer { ): Promise>; } -export interface AuthProvider { - getAuthInfo(): Promise; - checkHealth(): Promise; -} - export interface Storage { runs: { create(data: CreateWorkflowRunRequest): Promise; @@ -106,7 +100,7 @@ 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. From 2e6a91af22e899a9bd59f20e8c0356f0a9656b39 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 25 Oct 2025 00:06:37 -0700 Subject: [PATCH 2/3] . --- packages/world/src/interfaces.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/world/src/interfaces.ts b/packages/world/src/interfaces.ts index 1d4ccfb34..fbc0a76ac 100644 --- a/packages/world/src/interfaces.ts +++ b/packages/world/src/interfaces.ts @@ -98,7 +98,6 @@ 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, Streamer { /** From d4995c6cfe2a70d32bc94b5f0750aa24403c58c2 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 25 Oct 2025 00:15:26 -0700 Subject: [PATCH 3/3] . --- packages/world-local/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/world-local/src/index.ts b/packages/world-local/src/index.ts index 4d71ebfca..239dd6968 100644 --- a/packages/world-local/src/index.ts +++ b/packages/world-local/src/index.ts @@ -5,7 +5,7 @@ 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.