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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
use serde::{Deserialize, Serialize};
use serde_json::Value;
use super::{NodeHandle, ProjectHandle, SignatureHandle, SymbolHandle, TypeHandle};
/// Response returned by the `initialize` endpoint.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InitializeResponse {
/// Whether the server treats file names as case sensitive.
pub use_case_sensitive_file_names: bool,
/// Current working directory used by the worker.
pub current_directory: String,
}
/// Parsed `tsconfig` metadata returned by `parseConfigFile`.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfigResponse {
/// Compiler options after Corsa normalization and inheritance resolution.
pub options: Value,
/// Files that belong to the parsed config according to Corsa.
pub file_names: Vec<String>,
}
/// Project descriptor returned by endpoints that resolve a project handle.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ProjectResponse {
/// Opaque handle used by follow-up project-scoped requests.
pub id: ProjectHandle,
/// Absolute or workspace-relative `tsconfig` path that defines the project.
pub config_file_name: String,
/// Raw compiler options associated with this project.
pub compiler_options: Value,
/// Root files that seed the project graph.
pub root_files: Vec<String>,
}
/// Symbol metadata returned by Corsa.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SymbolResponse {
/// Opaque handle used to re-query the symbol later.
pub id: SymbolHandle,
/// Symbol display name.
pub name: String,
/// TypeScript `SymbolFlags` bitset.
pub flags: u32,
/// TypeScript `CheckFlags` bitset for checker-specific symbol state.
pub check_flags: u32,
/// Declaration nodes associated with the symbol.
#[serde(default)]
pub declarations: Vec<NodeHandle>,
/// Preferred declaration node when Corsa exposes one.
#[serde(skip_serializing_if = "Option::is_none")]
pub value_declaration: Option<NodeHandle>,
}
/// Type metadata returned by checker-oriented endpoints.
///
/// This structure intentionally mirrors upstream TypeScript concepts closely so
/// advanced consumers can recover rich relationships without re-querying every
/// detail immediately.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TypeResponse {
/// Opaque handle used to reference this type in later requests.
pub id: TypeHandle,
/// TypeScript `TypeFlags` bitset.
pub flags: u32,
/// TypeScript `ObjectFlags` bitset when the type is an object type.
#[serde(skip_serializing_if = "Option::is_none")]
pub object_flags: Option<u32>,
/// Serialized literal-like value payload when available.
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Value>,
/// Target type for instantiated or mapped types.
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<TypeHandle>,
/// Generic type parameters declared directly on the type.
#[serde(default)]
pub type_parameters: Vec<TypeHandle>,
/// Generic type parameters captured from outer declarations.
#[serde(default)]
pub outer_type_parameters: Vec<TypeHandle>,
/// Type parameters introduced locally while resolving the type.
#[serde(default)]
pub local_type_parameters: Vec<TypeHandle>,
/// Tuple/element flags for tuple-like types.
#[serde(default)]
pub element_flags: Vec<u32>,
/// Fixed tuple length when known.
#[serde(skip_serializing_if = "Option::is_none")]
pub fixed_length: Option<i32>,
/// Whether the type is marked readonly in a tuple/object-like context.
#[serde(skip_serializing_if = "Option::is_none")]
pub readonly: Option<bool>,
/// Object type referenced by wrapper types such as indexed accesses.
#[serde(skip_serializing_if = "Option::is_none")]
pub object_type: Option<TypeHandle>,
/// Index type referenced by wrapper types such as indexed accesses.
#[serde(skip_serializing_if = "Option::is_none")]
pub index_type: Option<TypeHandle>,
/// Checker "check" type associated with conditional or indexed forms.
#[serde(skip_serializing_if = "Option::is_none")]
pub check_type: Option<TypeHandle>,
/// Type used on the `extends` side of conditional relationships.
#[serde(skip_serializing_if = "Option::is_none")]
pub extends_type: Option<TypeHandle>,
/// Base type for inheritance-like relationships.
#[serde(skip_serializing_if = "Option::is_none")]
pub base_type: Option<TypeHandle>,
/// Substitution constraint for substituted type variables.
#[serde(skip_serializing_if = "Option::is_none")]
pub subst_constraint: Option<TypeHandle>,
/// Human-readable type renderings produced by Corsa.
///
/// Many higher-level integrations can use this directly instead of
/// round-tripping through another text-rendering endpoint.
#[serde(default)]
pub texts: Vec<String>,
/// Symbol associated with the type when present.
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol: Option<SymbolHandle>,
}
/// Call signature metadata returned by checker-oriented endpoints.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SignatureResponse {
/// Opaque handle used to reference the signature later.
pub id: SignatureHandle,
/// TypeScript `SignatureFlags` bitset.
pub flags: u32,
/// Declaration node that produced the signature, if exposed.
#[serde(skip_serializing_if = "Option::is_none")]
pub declaration: Option<NodeHandle>,
/// Generic type parameters declared on the signature.
#[serde(default)]
pub type_parameters: Vec<TypeHandle>,
/// Parameter symbols in declaration order.
#[serde(default)]
pub parameters: Vec<SymbolHandle>,
/// `this` parameter symbol when explicitly modeled.
#[serde(skip_serializing_if = "Option::is_none")]
pub this_parameter: Option<SymbolHandle>,
/// Target signature for instantiated or wrapped signatures.
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<SignatureHandle>,
}
/// Type predicate metadata such as `value is Foo`.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TypePredicateResponse {
/// TypeScript internal predicate kind tag.
pub kind: i32,
/// Parameter index targeted by the predicate.
pub parameter_index: i32,
/// Parameter name, when the predicate refers to a named parameter.
#[serde(skip_serializing_if = "Option::is_none")]
pub parameter_name: Option<String>,
/// Narrowed type described by the predicate.
#[serde(skip_serializing_if = "Option::is_none")]
pub r#type: Option<TypeResponse>,
}
/// Index signature information returned by checker queries.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexInfo {
/// Type of the index key.
pub key_type: TypeResponse,
/// Value type produced by indexing with [`Self::key_type`].
pub value_type: TypeResponse,
/// Whether the index signature is readonly.
#[serde(default)]
pub is_readonly: bool,
}