-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for outputVariables
and inputVariables
in RequestBatchRequest
type.
#313
Comments
I just started putting together a PR that adds a properly typed |
One issue I am seeing is that of enforcing type safety. About the best option I can come up with is this: export declare type RequestBatchRequest<T = keyof OBSRequestTypes> = T extends keyof OBSRequestTypes ? OBSRequestTypes[T] extends never ? {
requestType: T;
requestId?: string;
outputVariables?: Record<string, keyof OBSResponseTypes[T]>;
} : {
requestType: T;
requestId?: string;
requestData: Partial<OBSRequestTypes[T]>;
inputVariables?: Partial<OBSRequestTypes[T]>;
outputVariables?: Record<string, keyof OBSResponseTypes[T]>;
} : never;
export declare type RequestBatchRequest<T = keyof OBSRequestTypes, S = Record<string, string>> = T extends keyof OBSRequestTypes ? OBSRequestTypes[T] extends never ? {
requestType: T;
requestId?: string;
outputVariables?: Record<string, keyof OBSResponseTypes[T]>;
} : {
requestType: T;
requestId?: string;
requestData: Omit<OBSRequestTypes[T], keyof S>;
inputVariables?: S;
outputVariables?: Record<string, keyof OBSResponseTypes[T]>;
} : never; However, unless the template for const req: RequestBatchRequest<'someRequest', {fieldName: string}> = {
requestType: 'someRequest',
requestData: { aField: 'value' },
inputVariables: {fieldName: 'outputVariableName'},
} If anyone has other ideas, I am all ears. |
Description:
One of the many significant changes to the OBS websocket v5 protocol is that source visibility requires the source's ID within the scene where it is being enabled/disabled. For something as simple (and common) as toggling on/off a source, this is cumbersome and can add considerable complexity to client code. The "recommended" way of doing this is to use a batched request that get's a source's id within a scene (given the scene name and source name), store its value in the
outputVariables
field of that request, then send a source enable request that specifies aninputVariable
from the prior request'soutputVariables
as thesourceId
. (An example is given in the issue here: obsproject/obs-websocket#1014 (comment) ). Unfortunately, the typescript typedef forRequestBatchRequest
does not allow for theinputVariables
oroutputVariables
fields.Modifying the
type.d.ts
file to allow for an optionalinputVariables: any
andoutputVariables: any
allows this to work via obs-websocket-js. However it appears that this file is automatically generated from OBS Websocket's types?Versions Used (if applicable):
The text was updated successfully, but these errors were encountered: