-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core)!: update class transformer library (#547)
BREAKING CHANGE: class-transformer released a breaking change in a patch version, causing AFJ to break. I updated to the newer version and pinned the version exactly as this is the second time this has happened now. Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
5545a2a
commit dee03e3
Showing
11 changed files
with
60 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
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,25 +1,23 @@ | ||
import { classToPlain, deserialize, plainToClass, serialize } from 'class-transformer' | ||
import { instanceToPlain, plainToInstance } from 'class-transformer' | ||
|
||
export class JsonTransformer { | ||
public static toJSON<T>(classInstance: T) { | ||
return classToPlain(classInstance, { | ||
return instanceToPlain(classInstance, { | ||
exposeDefaultValues: true, | ||
}) | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
public static fromJSON<T>(json: any, Class: { new (...args: any[]): T }): T { | ||
return plainToClass(Class, json, { exposeDefaultValues: true }) | ||
return plainToInstance(Class, json, { exposeDefaultValues: true }) | ||
} | ||
|
||
public static serialize<T>(classInstance: T): string { | ||
return serialize(classInstance, { | ||
exposeDefaultValues: true, | ||
}) | ||
return JSON.stringify(this.toJSON(classInstance)) | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
public static deserialize<T>(jsonString: string, Class: { new (...args: any[]): T }): T { | ||
return deserialize(Class, jsonString, { exposeDefaultValues: true }) | ||
return this.fromJSON(JSON.parse(jsonString), Class) | ||
} | ||
} |
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.