Skip to content

Commit

Permalink
fix(httpSend): Use the same types for the sendCommand action as a tim…
Browse files Browse the repository at this point in the history
…eline object (nrkno#269)
  • Loading branch information
PeterC89 authored Jul 5, 2023
1 parent 35d4e5d commit 3385217
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
11 changes: 1 addition & 10 deletions packages/timeline-state-resolver-types/src/generated/httpSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ export enum TimelineContentTypeHTTPParamType {

export type SomeMappingHttpSend = Record<string, never>

export interface SendCommandPayload {
type: string
url: string
params: {
[k: string]: unknown
}
paramsType?: string
temporalPriority?: number
queueId?: string
}
export type SendCommandPayload = HTTPSendCommandContent

export enum HttpSendActions {
Resync = 'resync',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,54 @@
"destructive": false,
"payload": {
"type": "object",
"tsType": "HTTPSendCommandContent",
"properties": {
"type": {
"type": "string"
"type": "string",
"title": "TimelineContentTypeHTTP",
"ui:title": "Type",
"ui:summaryTitle": "Type",
"default": "",
"enum": ["get", "post", "put", "delete"],
"tsEnumNames": ["GET", "POST", "PUT", "DELETE"]
},
"url": { "type": "string" },
"params": { "type": "object" },
"paramsType": { "type": "string" },
"temporalPriority": { "type": "number" },
"queueId": { "type": "string" }
"url": {
"type": "string",
"ui:title": "Url",
"ui:summaryTitle": "URL",
"default": ""
},
"params": {
"type": "object",
"ui:title": "Params",
"ui:displayType": "json",
"additionalProperties": true
},
"paramsType": {
"type": "string",
"title": "TimelineContentTypeHTTPParamType",
"ui:title": "Params type",
"default": "json",
"enum": ["json", "form"],
"tsEnumNames": ["JSON", "FORM"]
},
"headers": {
"type": "object",
"additionalProperties": { "type": "string" }
},
"temporalPriority": {
"type": "integer",
"ui:title": "Temporal Priority",
"default": 0
},
"queueId": {
"type": "string",
"description": "Commands in the same queue will be sent in order (will wait for the previous to finish before sending next",
"ui:title": "Send Queue Id"
}
},
"additionalProperties": false,
"required": ["type", "url", "params"]
"required": ["type", "url", "params"],
"additionalProperties": false
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class HTTPSendDevice extends DeviceWithState<HTTPSendState, DeviceOptions
response: t('Failed to send command: Missing url'),
}
}
if (Object.values<TimelineContentTypeHTTP>(TimelineContentTypeHTTP).includes(cmd.type as TimelineContentTypeHTTP)) {
if (Object.values<TimelineContentTypeHTTP>(TimelineContentTypeHTTP).includes(cmd.type)) {
return {
result: ActionExecutionResultCode.Error,
response: t('Failed to send command: type is invalid'),
Expand All @@ -174,7 +174,7 @@ export class HTTPSendDevice extends DeviceWithState<HTTPSendState, DeviceOptions
}
}

await this._commandReceiver(time, cmd as HTTPSendCommandContent, 'makeReady', '')
await this._commandReceiver(time, cmd, 'makeReady', '')

return {
result: ActionExecutionResultCode.Ok,
Expand Down

0 comments on commit 3385217

Please sign in to comment.