Add atomic circuit update commands
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user