Skip to content

Commit 7868434

Browse files
authored
Remove AuthProvider interface from World and associated implementations (vercel#49)
* 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. * . * .
1 parent d3a4ed3 commit 7868434

11 files changed

Lines changed: 15 additions & 152 deletions

File tree

.changeset/slimy-hairs-thank.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@workflow/world-postgres": patch
3+
"@workflow/world-vercel": patch
4+
"@workflow/world-local": patch
5+
"@workflow/world": patch
6+
---
7+
8+
Remove `AuthProvider` interface from `World` and associated implementations

packages/world-local/src/auth.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/world-local/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { World } from '@workflow/world';
2-
import { auth } from './auth.js';
32
import { config } from './config.js';
43
import { createQueue } from './queue.js';
54
import { createStorage } from './storage.js';
65
import { createStreamer } from './streamer.js';
76

87
/**
9-
* Creates an embedded world instance that combines queue, storage, streamer, and authentication functionalities.
8+
* Creates an embedded world instance that combines queue, storage, and streamer functionalities.
109
*
1110
* @param dataDir - The directory to use for storage. If not provided, the default data dir will be used.
1211
* @param port - The port to use for the queue. If not provided, the default port will be used.
@@ -24,6 +23,5 @@ export function createEmbeddedWorld({
2423
...createQueue(queuePort),
2524
...createStorage(dir),
2625
...createStreamer(dir),
27-
...auth,
2826
};
2927
}

packages/world-postgres/src/index.ts

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AuthProvider, Storage, World } from '@workflow/world';
1+
import type { Storage, World } from '@workflow/world';
22
import PgBoss from 'pg-boss';
33
import createPostgres from 'postgres';
44
import type { PostgresWorldConfig } from './config.js';
@@ -21,45 +21,6 @@ function createStorage(drizzle: Drizzle): Storage {
2121
};
2222
}
2323

24-
function createAuthProvider(
25-
_config: PostgresWorldConfig,
26-
boss: PgBoss
27-
): AuthProvider {
28-
return {
29-
async getAuthInfo() {
30-
return {
31-
environment: 'postgres',
32-
ownerId: 'postgres',
33-
projectId: 'postgres',
34-
};
35-
},
36-
async checkHealth() {
37-
try {
38-
if (!(await boss.isInstalled())) {
39-
throw new Error('Postgres Boss is not installed properly');
40-
}
41-
} catch (err) {
42-
return {
43-
success: false,
44-
data: { healthy: false },
45-
message:
46-
err &&
47-
typeof err === 'object' &&
48-
'message' in err &&
49-
typeof err.message === 'string'
50-
? err.message
51-
: String(err),
52-
};
53-
}
54-
return {
55-
success: true,
56-
message: 'Postgres connection is healthy',
57-
data: { healthy: true },
58-
};
59-
},
60-
};
61-
}
62-
6324
export function createWorld(
6425
config: PostgresWorldConfig = {
6526
connectionString:
@@ -79,12 +40,10 @@ export function createWorld(
7940
const queue = createQueue(boss, config);
8041
const storage = createStorage(drizzle);
8142
const streamer = createStreamer(postgres, drizzle);
82-
const auth = createAuthProvider(config, boss);
8343

8444
return {
8545
...storage,
8646
...streamer,
87-
...auth,
8847
...queue,
8948
async start() {
9049
await queue.start();

packages/world-vercel/src/auth.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

packages/world-vercel/src/backend.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { AuthProvider, Storage, Streamer } from '@workflow/world';
1+
import type { Storage, Streamer } from '@workflow/world';
22
import { createStorage } from './storage.js';
33
import { createStreamer } from './streamer.js';
44
import type { APIConfig } from './utils.js';
55

6-
export function createVercel(
7-
config?: APIConfig
8-
): Streamer & Storage & AuthProvider {
6+
export function createVercel(config?: APIConfig): Streamer & Storage {
97
const storage = createStorage(config);
108
const streamer = createStreamer(config);
119

@@ -15,10 +13,6 @@ export function createVercel(
1513
closeStream: streamer.closeStream,
1614
readFromStream: streamer.readFromStream,
1715

18-
// AuthProvider interface
19-
getAuthInfo: storage.getAuthInfo,
20-
checkHealth: storage.checkHealth,
21-
2216
// Storage interface with namespaced methods
2317
runs: storage.runs,
2418
steps: storage.steps,

packages/world-vercel/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { World } from '@workflow/world';
2-
import { createAuth } from './auth.js';
32
import { createQueue } from './queue.js';
43
import { createStorage } from './storage.js';
54
import { createStreamer } from './streamer.js';
@@ -14,7 +13,6 @@ export function createVercelWorld(config?: APIConfig): World {
1413
return {
1514
...createQueue(),
1615
...createStorage(config),
17-
...createAuth(config),
1816
...createStreamer(config),
1917
};
2018
}

packages/world-vercel/src/storage.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { AuthProvider, Storage } from '@workflow/world';
2-
import { checkHealth, getAuthInfo } from './auth.js';
1+
import type { Storage } from '@workflow/world';
32
import { createWorkflowRunEvent, getWorkflowRunEvents } from './events.js';
43
import {
54
createHook,
@@ -25,12 +24,8 @@ import {
2524
} from './steps.js';
2625
import type { APIConfig } from './utils.js';
2726

28-
export function createStorage(config?: APIConfig): Storage & AuthProvider {
27+
export function createStorage(config?: APIConfig): Storage {
2928
return {
30-
// AuthProvider interface
31-
getAuthInfo: () => getAuthInfo(config),
32-
checkHealth: () => checkHealth(config),
33-
3429
// Storage interface with namespaced methods
3530
runs: {
3631
create: (data) => createWorkflowRun(data, config),

packages/world/src/auth.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/world/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export type * from './auth.js';
2-
export { AuthInfoSchema, HealthCheckResponseSchema } from './auth.js';
31
export type * from './events.js';
42
export {
53
BaseEventSchema,

0 commit comments

Comments
 (0)