-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Update assemblers to allow transforming create/update dtos
- Loading branch information
1 parent
7fc7fe3
commit 5085d11
Showing
17 changed files
with
192 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ export class TodoItemInputDTO { | |
|
||
@IsBoolean() | ||
@Field() | ||
completed!: boolean; | ||
isCompleted!: boolean; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import { Class } from '../common'; | ||
import { Class, DeepPartial } from '../common'; | ||
import { Assembler, getAssembler } from './assembler'; | ||
import { DefaultAssembler } from './default.assembler'; | ||
|
||
/** | ||
* Assembler Service used by query services to look up Assemblers. | ||
*/ | ||
export class AssemblerFactory { | ||
static getAssembler<From, To>(FromClass: Class<From>, ToClass: Class<To>): Assembler<From, To> { | ||
const AssemblerClass = getAssembler(FromClass, ToClass); | ||
static getAssembler<From, To, C = DeepPartial<From>, CE = DeepPartial<To>, U = C, UE = CE>( | ||
FromClass: Class<From>, | ||
ToClass: Class<To>, | ||
): Assembler<From, To, C, CE, U, UE> { | ||
const AssemblerClass = getAssembler<From, To, C, CE, U, UE>(FromClass, ToClass); | ||
if (AssemblerClass) { | ||
return new AssemblerClass(); | ||
} | ||
return new DefaultAssembler(FromClass, ToClass); | ||
const defaultAssember = new DefaultAssembler(FromClass, ToClass); | ||
// if its a default just assume the types can be converted for all types | ||
return (defaultAssember as unknown) as Assembler<From, To, C, CE, U, UE>; | ||
} | ||
} |
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.