-
-
Notifications
You must be signed in to change notification settings - Fork 551
/
types.ts
94 lines (85 loc) · 2.02 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { JSONObject, MediaBundle } from "@nteract/commutable";
import { Subject } from "rxjs";
export type MessageType =
| "execute_request"
| "inspect_request"
| "inspect_reply"
| "kernel_info_request"
| "kernel_info_reply"
| "complete_request"
| "history_request"
| "history_reply"
| "is_complete_request"
| "comm_info_request"
| "comm_info_reply"
| "shutdown_request"
| "shutdown_reply"
| "shell"
| "display_data"
| "stream"
| "update_display_data"
| "execute_input"
| "execute_result"
| "error"
| "status"
| "clear_output"
| "iopub"
| "input_request"
| "input_reply"
| "stdin"
| "comm_open"
| "comm_msg"
| "comm_close"
| "complete_reply"
| "is_complete_reply"
| "execute_reply"
| "interrupt_request"
| "interrupt_reply";
export interface JupyterMessageHeader<MT extends MessageType = MessageType> {
msg_id: string;
username: string;
date: string; // ISO 8601 timestamp
msg_type: MT;
version: string; // this could be an enum
session: string;
}
export interface JupyterMessage<MT extends MessageType = MessageType, C = any> {
header: JupyterMessageHeader<MT>;
parent_header:
| JupyterMessageHeader<any>
| {
msg_id?: string;
};
metadata: object;
content: C;
channel: string;
buffers?: Uint8Array | null;
}
export interface ExecuteMessageContent {
code: string;
silent: boolean;
store_history: boolean;
user_expressions: object;
allow_stdin: boolean;
stop_on_error: boolean;
}
export type ExecuteRequest = JupyterMessage<
"execute_request",
ExecuteMessageContent
>;
export interface BasicOutputMessageContent {
data?: object;
metadata?: object;
transient?: object;
}
export interface UpdateDisplayDataContent extends BasicOutputMessageContent {
output_type: "update_display_data";
data: MediaBundle;
metadata: JSONObject;
transient?: { display_id?: string };
}
export type UpdateDisplayData = JupyterMessage<
"update_display_data",
UpdateDisplayDataContent
>;
export type Channels = Subject<JupyterMessage>;