Skip to content

Commit a93ac00

Browse files
committed
refactor(wizard): update collect endpoint
1 parent d2b4240 commit a93ac00

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/wizard/wizard.controller.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Req,
77
Sse,
88
UseInterceptors,
9+
ValidationPipe,
910
} from '@nestjs/common';
1011
import { WizardService } from 'omniboxd/wizard/wizard.service';
1112
import { CollectRequestDto } from 'omniboxd/wizard/dto/collect-request.dto';
@@ -21,6 +22,20 @@ import {
2122
} from 'omniboxd/decorators/validate-share.decorator';
2223
import { Share } from 'omniboxd/shares/entities/share.entity';
2324

25+
@Controller('api/v1/wizard')
26+
export class CollectController {
27+
constructor(private readonly wizardService: WizardService) {}
28+
29+
@Post('collect')
30+
async collect(
31+
@UserId() userId: string,
32+
@Body() data: CollectRequestDto,
33+
@Body('namespaceId', new ValidationPipe()) namespaceId: string,
34+
): Promise<CollectResponseDto> {
35+
return await this.wizardService.collect(namespaceId, userId, data);
36+
}
37+
}
38+
2439
@Controller('api/v1/namespaces/:namespaceId/wizard')
2540
export class WizardController {
2641
constructor(private readonly wizardService: WizardService) {}
@@ -95,4 +110,21 @@ export class SharedWizardController {
95110
'ask',
96111
);
97112
}
113+
114+
@Post('write')
115+
@Sse()
116+
@CookieAuth({ onAuthFail: 'continue' })
117+
@ValidateShare()
118+
async write(
119+
@ValidatedShare() share: Share,
120+
@RequestId() requestId: string,
121+
@Body() body: AgentRequestDto,
122+
) {
123+
return await this.wizardService.streamService.createShareAgentStream(
124+
share,
125+
body,
126+
requestId,
127+
'write',
128+
);
129+
}
98130
}

src/wizard/wizard.e2e-spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ describe('WizardController (e2e)', () => {
181181

182182
// Note: The RequestId decorator returns undefined if header is missing,
183183
// but the service might handle this gracefully
184-
const response = await client.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`).send(askData);
184+
const response = await client
185+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
186+
.send(askData);
185187

186188
// The endpoint might still work without X-Request-Id
187189
expect([
@@ -337,7 +339,9 @@ describe('WizardController (e2e)', () => {
337339
// or if the proxy path doesn't exist. In a real test environment,
338340
// you might want to mock the wizard service.
339341
const response = await client
340-
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/test-proxy-path`)
342+
.post(
343+
`/api/v1/namespaces/${client.namespace.id}/wizard/test-proxy-path`,
344+
)
341345
.send({ test: 'data' });
342346

343347
// The response status depends on the wizard service implementation

0 commit comments

Comments
 (0)