-
Notifications
You must be signed in to change notification settings - Fork 0
feat(workspace): workspace domain — schema, store, routes, daemon linking #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "name": "@paws/domain-workspace", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "description": "Workspace domain — Workspace, WorkspaceStore, routes", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./src/index.ts", | ||
| "import": "./src/index.ts" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "test": "vitest run --passWithNoTests", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@hono/zod-openapi": "catalog:", | ||
| "@paws/domain-common": "workspace:*", | ||
| "zod": "catalog:" | ||
| }, | ||
| "devDependencies": { | ||
| "vitest": "catalog:" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| export { | ||
| CreateWorkspaceRequestSchema, | ||
| UpdateWorkspaceRequestSchema, | ||
| WorkspaceListResponseSchema, | ||
| WorkspaceRepoSchema, | ||
| WorkspaceSchema, | ||
| WorkspaceSettingsSchema, | ||
| } from './types.js'; | ||
| export type { | ||
| CreateWorkspaceRequest, | ||
| UpdateWorkspaceRequest, | ||
| Workspace, | ||
| WorkspaceListResponse, | ||
| WorkspaceRepo, | ||
| WorkspaceSettings, | ||
| } from './types.js'; | ||
|
|
||
| export { createWorkspaceStore } from './store.js'; | ||
| export type { WorkspaceStore } from './store.js'; | ||
|
|
||
| export { | ||
| createWorkspaceRoute, | ||
| deleteWorkspaceRoute, | ||
| getWorkspaceRoute, | ||
| listWorkspacesRoute, | ||
| updateWorkspaceRoute, | ||
| } from './routes.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import { createRoute, z } from '@hono/zod-openapi'; | ||
| import { ErrorResponseSchema } from '@paws/domain-common'; | ||
| import { | ||
| CreateWorkspaceRequestSchema, | ||
| UpdateWorkspaceRequestSchema, | ||
| WorkspaceListResponseSchema, | ||
| WorkspaceSchema, | ||
| } from './types.js'; | ||
|
|
||
| export const createWorkspaceRoute = createRoute({ | ||
| method: 'post', | ||
| path: '/v1/workspaces', | ||
| tags: ['Workspaces'], | ||
| request: { | ||
| body: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: CreateWorkspaceRequestSchema, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| responses: { | ||
| 201: { | ||
| description: 'Workspace created', | ||
| content: { 'application/json': { schema: WorkspaceSchema } }, | ||
| }, | ||
| 400: { | ||
| description: 'Validation error', | ||
| content: { 'application/json': { schema: ErrorResponseSchema } }, | ||
| }, | ||
| 409: { | ||
| description: 'Workspace name already exists', | ||
| content: { 'application/json': { schema: ErrorResponseSchema } }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const listWorkspacesRoute = createRoute({ | ||
| method: 'get', | ||
| path: '/v1/workspaces', | ||
| tags: ['Workspaces'], | ||
| responses: { | ||
| 200: { | ||
| description: 'List of workspaces', | ||
| content: { 'application/json': { schema: WorkspaceListResponseSchema } }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const getWorkspaceRoute = createRoute({ | ||
| method: 'get', | ||
| path: '/v1/workspaces/{id}', | ||
| tags: ['Workspaces'], | ||
| request: { | ||
| params: z.object({ id: z.string().min(1) }), | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: 'Workspace detail', | ||
| content: { 'application/json': { schema: WorkspaceSchema } }, | ||
| }, | ||
| 404: { | ||
| description: 'Workspace not found', | ||
| content: { 'application/json': { schema: ErrorResponseSchema } }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const updateWorkspaceRoute = createRoute({ | ||
| method: 'put', | ||
| path: '/v1/workspaces/{id}', | ||
| tags: ['Workspaces'], | ||
| request: { | ||
| params: z.object({ id: z.string().min(1) }), | ||
| body: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: UpdateWorkspaceRequestSchema, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: 'Workspace updated', | ||
| content: { 'application/json': { schema: WorkspaceSchema } }, | ||
| }, | ||
| 404: { | ||
| description: 'Workspace not found', | ||
| content: { 'application/json': { schema: ErrorResponseSchema } }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const deleteWorkspaceRoute = createRoute({ | ||
| method: 'delete', | ||
| path: '/v1/workspaces/{id}', | ||
| tags: ['Workspaces'], | ||
| request: { | ||
| params: z.object({ id: z.string().min(1) }), | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: 'Workspace deleted', | ||
| content: { | ||
| 'application/json': { | ||
| schema: z.object({ | ||
| id: z.string(), | ||
| deleted: z.literal(true), | ||
| }), | ||
| }, | ||
| }, | ||
| }, | ||
| 404: { | ||
| description: 'Workspace not found', | ||
| content: { 'application/json': { schema: ErrorResponseSchema } }, | ||
| }, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import type { CreateWorkspaceRequest, Workspace } from './types.js'; | ||
|
|
||
| export interface WorkspaceStore { | ||
| create(workspace: Workspace): Workspace; | ||
| get(id: string): Workspace | undefined; | ||
| getByName(name: string): Workspace | undefined; | ||
| list(): Workspace[]; | ||
| update(id: string, partial: Partial<CreateWorkspaceRequest>): Workspace | undefined; | ||
| delete(id: string): boolean; | ||
| } | ||
|
|
||
| /** In-memory workspace store */ | ||
| export function createWorkspaceStore(): WorkspaceStore { | ||
| const workspaces = new Map<string, Workspace>(); | ||
|
|
||
| return { | ||
| create(workspace) { | ||
| workspaces.set(workspace.id, workspace); | ||
| return workspace; | ||
| }, | ||
|
|
||
| get(id) { | ||
| return workspaces.get(id); | ||
| }, | ||
|
|
||
| getByName(name) { | ||
| for (const workspace of workspaces.values()) { | ||
| if (workspace.name === name) return workspace; | ||
| } | ||
| return undefined; | ||
| }, | ||
|
|
||
| list() { | ||
| return [...workspaces.values()]; | ||
| }, | ||
|
|
||
| update(id, partial) { | ||
| const workspace = workspaces.get(id); | ||
| if (!workspace) return undefined; | ||
| const updated: Workspace = { | ||
| ...workspace, | ||
| ...(partial.name !== undefined && { name: partial.name }), | ||
| ...(partial.description !== undefined && { description: partial.description }), | ||
| ...(partial.type !== undefined && { type: partial.type }), | ||
| ...(partial.repos !== undefined && { repos: partial.repos }), | ||
| ...(partial.settings !== undefined && { settings: partial.settings }), | ||
| updatedAt: new Date().toISOString(), | ||
| }; | ||
| workspaces.set(id, updated); | ||
| return updated; | ||
| }, | ||
|
|
||
| delete(id) { | ||
| return workspaces.delete(id); | ||
| }, | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: arek-e/paws
Length of output: 2553
Control-plane store implementations are missing the
workspacefield.The
workspacefield is correctly added toStoredDaemonand thecreate()method here (line 50), but the control-plane has a separateStoredDaemoninterface and store implementations inapps/control-plane/src/store/daemons.tsthat don't include this field.Update required:
workspace?: string | undefinedto the StoredDaemon interface (line 12)workspace: request.workspaceto the in-memory store'screate()method (line 48)workspaceto the SQLite store's insert statement (line 150-163)Without these changes, the
workspacevalue will be silently dropped when daemons are created through the control-plane.🤖 Prompt for AI Agents