Skip to content

Commit

Permalink
feat: add discard
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Dec 5, 2023
1 parent 29a7268 commit d531a7d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/CasparCG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import {
PingParameters,
BeginParameters,
CommitParameters,
DiscardParameters,
} from './parameters'

export class CasparCG extends BasicCasparCGAPI {
Expand Down Expand Up @@ -575,5 +576,11 @@ export class CasparCG extends BasicCasparCGAPI {
params,
})
}
async discard(params: DiscardParameters = {}): Promise<APIRequest<Commands.Discard>> {
return this.executeCommand({
command: Commands.Discard,
params,
})
}
}
export type APIRequest<C extends Commands> = SendResult<CReturnType<C>>
5 changes: 5 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import {
BeginParameters,
CommitParameters,
PingParameters,
DiscardParameters,
} from './parameters'

export enum Commands {
Expand Down Expand Up @@ -182,6 +183,7 @@ export enum Commands {
Ping = 'PING',
Begin = 'BEGIN',
Commit = 'COMMIT',
Discard = 'DISCARD',
}

export interface Command<Cmd extends Commands, Params> {
Expand Down Expand Up @@ -298,6 +300,7 @@ export interface AllTypedCommands {
[Commands.Ping]: TypedResponseCommand<Commands.Ping, PingParameters, unknown>
[Commands.Begin]: TypedResponseCommand<Commands.Begin, BeginParameters, unknown>
[Commands.Commit]: TypedResponseCommand<Commands.Commit, CommitParameters, unknown>
[Commands.Discard]: TypedResponseCommand<Commands.Discard, DiscardParameters, unknown>
}

export type LoadbgCommand = AllTypedCommands[Commands.Loadbg]['command']
Expand Down Expand Up @@ -387,6 +390,7 @@ export type RestartCommand = AllTypedCommands[Commands.Restart]['command']
export type PingCommand = AllTypedCommands[Commands.Ping]['command']
export type BeginCommand = AllTypedCommands[Commands.Begin]['command']
export type CommitCommand = AllTypedCommands[Commands.Commit]['command']
export type DiscardCommand = AllTypedCommands[Commands.Discard]['command']

export type AMCPCommand =
| LoadbgCommand
Expand Down Expand Up @@ -476,3 +480,4 @@ export type AMCPCommand =
| PingCommand
| BeginCommand
| CommitCommand
| DiscardCommand
1 change: 1 addition & 0 deletions src/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,4 @@ export type RestartParameters = Empty
export type PingParameters = Empty
export type BeginParameters = Empty
export type CommitParameters = Empty
export type DiscardParameters = Empty
4 changes: 4 additions & 0 deletions src/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ export const serializers: Readonly<Serializers<AMCPCommand>> = {
[Commands.Bye]: [commandNameSerializer],
[Commands.Kill]: [commandNameSerializer],
[Commands.Restart]: [commandNameSerializer],
[Commands.Ping]: [commandNameSerializer],
[Commands.Begin]: [commandNameSerializer],
[Commands.Commit]: [commandNameSerializer],
[Commands.Discard]: [commandNameSerializer],
}

export const serializersV21: Readonly<Serializers<AMCPCommand>> = {
Expand Down

0 comments on commit d531a7d

Please sign in to comment.