* Convert a raw hook input received over the wire into its public-facing shape. * This deserializes the numeric Unix-ms `timestamp` field on BaseHookInput * into a Date and maps the wire `cwd` field to `workingDirectory`.
(raw: unknown)
| 66 | * into a Date and maps the wire `cwd` field to `workingDirectory`. |
| 67 | */ |
| 68 | function deserializeHookInput(raw: unknown): unknown { |
| 69 | if ( |
| 70 | !raw || |
| 71 | typeof raw !== "object" || |
| 72 | typeof (raw as { timestamp?: unknown }).timestamp !== "number" |
| 73 | ) { |
| 74 | return raw; |
| 75 | } |
| 76 | const obj = raw as Record<string, unknown> & { timestamp: number; cwd?: string }; |
| 77 | const { cwd, ...rest } = obj; |
| 78 | return { ...rest, timestamp: new Date(obj.timestamp), workingDirectory: cwd }; |
| 79 | } |
| 80 | |
| 81 | function isOpenCanvasInstance(value: unknown): value is OpenCanvasInstance { |
| 82 | if (!value || typeof value !== "object") { |
no outgoing calls
no test coverage detected
searching dependent graphs…