Skip to content

Commit ae16b79

Browse files
authored
Merge pull request #100 from import-ai/task
fix(task): fix task field camel
2 parents e2aacdf + e9878b4 commit ae16b79

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/resources/wizard-task/reader.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Reader {
1515
resource_id: resource.id,
1616
},
1717
payload: {
18-
resourceId: resource.id,
18+
resource_id: resource.id,
1919
},
2020
namespaceId: resource.namespaceId,
2121
userId: user.id,

src/wizard/internal.wizard.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Body, Controller, Get, Post, Res } from '@nestjs/common';
21
import { Response } from 'express';
2+
import { WizardService } from 'src/wizard/wizard.service';
33
import { Public } from 'src/auth/decorators/public.decorator';
4+
import { transformKeysToSnakeCase } from 'src/interceptor/utils';
45
import { TaskCallbackDto } from 'src/wizard/dto/task-callback.dto';
5-
import { WizardService } from 'src/wizard/wizard.service';
6+
import { Body, Controller, Get, Post, Res } from '@nestjs/common';
67

78
@Controller('internal/api/v1/wizard')
89
export class InternalWizardController {
@@ -12,8 +13,7 @@ export class InternalWizardController {
1213
@Get('/task')
1314
async fetchTask(@Res() res: Response): Promise<void> {
1415
const task = await this.wizardService.fetchTask();
15-
res.status(task ? 200 : 204).json(task);
16-
return;
16+
res.status(task ? 200 : 204).json(transformKeysToSnakeCase(task));
1717
}
1818

1919
@Public()

src/wizard/processors/collect.processor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export class CollectProcessor extends Processor {
1313
}
1414

1515
async process(task: Task): Promise<Record<string, any>> {
16-
if (!task.payload?.resourceId) {
16+
const resourceId = task.payload?.resource_id || task.payload?.resourceId;
17+
if (!resourceId) {
1718
throw new BadRequestException('Invalid task payload');
1819
}
19-
const resourceId = task.payload.resourceId;
2020
if (task.exception) {
2121
const user = await this.userService.find(task.userId);
2222
if (user) {

src/wizard/wizard.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class WizardService {
7272
const resource = await this.resourcesService.create(user, resourceDto);
7373
console.debug({ resource });
7474

75-
const payload = { resourceId: resource.id };
75+
const payload = { resource_id: resource.id };
7676

7777
const task = await this.create({
7878
function: 'collect',

0 commit comments

Comments
 (0)