-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): encode workflow and step ids on response
- Loading branch information
1 parent
541510d
commit ff8388f
Showing
18 changed files
with
234 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
40 changes: 40 additions & 0 deletions
40
apps/api/src/app/workflows-v2/pipes/parse-request-workflow.pipe.ts
This file contains 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,40 @@ | ||
import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; | ||
|
||
import { isStepCreateBody, isStepUpdateBody, UpsertStepBody, UpsertWorkflowBody, UpdateStepBody } from '@novu/shared'; | ||
|
||
import { parseSlugId } from './parse-slug-Id.pipe'; | ||
|
||
@Injectable() | ||
export class ParseRequestWorkflowPipe implements PipeTransform<UpsertWorkflowBody> { | ||
transform(value: UpsertWorkflowBody, metadata: ArgumentMetadata) { | ||
if (!value) { | ||
return value; | ||
} | ||
|
||
return decodeSteps(value); | ||
} | ||
} | ||
|
||
function decodeSteps(value: UpsertWorkflowBody) { | ||
const steps = value.steps.map((step: UpsertStepBody) => { | ||
if (isStepCreateBody(step)) { | ||
return step; | ||
} | ||
|
||
if (isStepUpdateBody(step)) { | ||
const { id, ...rest } = step as UpdateStepBody; | ||
|
||
return { | ||
...rest, | ||
_id: parseSlugId(id), | ||
}; | ||
} | ||
|
||
return step; | ||
}); | ||
|
||
return { | ||
...value, | ||
steps, | ||
}; | ||
} |
This file contains 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
6 changes: 3 additions & 3 deletions
6
apps/api/src/app/workflows-v2/usecases/upsert-workflow/upsert-workflow.command.ts
This file contains 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { EnvironmentWithUserObjectCommand } from '@novu/application-generic'; | ||
import { CreateWorkflowDto, UpdateWorkflowDto } from '@novu/shared'; | ||
import { CreateWorkflowDto, IdentifierOrInternalId, UpsertWorkflowDto } from '@novu/shared'; | ||
|
||
export class UpsertWorkflowCommand extends EnvironmentWithUserObjectCommand { | ||
identifierOrInternalId?: string; | ||
identifierOrInternalId?: IdentifierOrInternalId; | ||
|
||
workflowDto: CreateWorkflowDto | UpdateWorkflowDto; | ||
workflowDto: CreateWorkflowDto | UpsertWorkflowDto; | ||
} |
This file contains 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
Oops, something went wrong.