forked from jappel/leistungsbilanz-ts
Add atomic circuit update commands
This commit is contained in:
parent
b79faed320
commit
296cb0f1c4
17 changed files with 940 additions and 167 deletions
|
|
@ -6,18 +6,22 @@ export type ProjectCommandJsonValue =
|
|||
| ProjectCommandJsonValue[]
|
||||
| { [key: string]: ProjectCommandJsonValue };
|
||||
|
||||
export interface SerializedProjectCommand {
|
||||
export interface SerializedProjectCommand<TPayload = ProjectCommandJsonValue> {
|
||||
schemaVersion: number;
|
||||
type: string;
|
||||
payload: ProjectCommandJsonValue;
|
||||
payload: TPayload;
|
||||
}
|
||||
|
||||
export function serializeProjectCommand(command: SerializedProjectCommand): string {
|
||||
export function serializeProjectCommand(
|
||||
command: SerializedProjectCommand<unknown>
|
||||
): string {
|
||||
assertSerializedProjectCommand(command);
|
||||
return JSON.stringify(command);
|
||||
}
|
||||
|
||||
export function deserializeProjectCommand(serialized: string): SerializedProjectCommand {
|
||||
export function deserializeProjectCommand(
|
||||
serialized: string
|
||||
): SerializedProjectCommand<ProjectCommandJsonValue> {
|
||||
const parsed: unknown = JSON.parse(serialized);
|
||||
assertSerializedProjectCommand(parsed);
|
||||
return parsed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue