-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTsClientOptions.cs
More file actions
193 lines (159 loc) · 8.07 KB
/
Copy pathTsClientOptions.cs
File metadata and controls
193 lines (159 loc) · 8.07 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
namespace NpgsqlRest.TsClient;
public class TsClientOptions
{
/// <summary>
/// File path for the generated code. Set to null to skip the code generation. Use {0} to set schema name when BySchema is true
/// </summary>
public string? FilePath { get; set; } = null!;
/// <summary>
/// Force file overwrite.
/// </summary>
public bool FileOverwrite { get; set; } = false;
/// <summary>
/// Include current host information in the URL prefix.
/// </summary>
public bool IncludeHost { get; set; } = false;
/// <summary>
/// Set the custom host prefix information.
/// </summary>
public string? CustomHost { get; set; } = null;
/// <summary>
/// Adds comment header to above request based on PostgreSQL routine
/// Set None to skip.
/// Set Simple (default) to add name, parameters and return values to comment header.
/// Set Full to add the entire routine code as comment header.
/// </summary>
public CommentHeader CommentHeader { get; set; } = CommentHeader.Simple;
/// <summary>
/// When CommentHeader is set to Simple or Full, set to true to include routine comments in comment header.
/// </summary>
public bool CommentHeaderIncludeComments { get; set; } = true;
/// <summary>
/// Set to true to include status code in response: {status: response.status, response: model}
/// </summary>
public bool IncludeStatusCode { get; set; } = false;
/// <summary>
/// Create files by PostgreSQL schema. File name will use formatted FilePath where {0} is is the schema name in the pascal case.
/// </summary>
public bool BySchema { get; set; } = false;
/// <summary>
/// Create separate file with global types {name}Types.d.ts
/// </summary>
public bool CreateSeparateTypeFile { get; set; } = true;
/// <summary>
/// Emit request/response (and composite) interfaces with the `export` keyword so they can be imported by other modules.
/// When false (default), interfaces are emitted as plain `interface` declarations (module-private when inline, ambient/global in the separate `.d.ts` file).
/// When true and CreateSeparateTypeFile is true, the separate type file becomes an importable module (`{name}Types.ts` with `export interface`) instead of an ambient `{name}Types.d.ts`, and the generated client file imports the named types from it.
/// Has no effect when SkipTypes is true.
/// </summary>
public bool ExportTypes { get; set; } = false;
/// <summary>
/// Lines to add to each header. {0} format placeholder is current timestamp
/// </summary>
public List<string> HeaderLines { get; set; } = ["// autogenerated at {0}", "", ""];
/// <summary>
/// Module name to import "baseUrl" constant, instead of defining it in a module.
/// </summary>
public string? ImportBaseUrlFrom { get; set; } = null;
/// <summary>
/// Module name to import "pasreQuery" function, instead of defining it in a module.
/// </summary>
public string? ImportParseQueryFrom { get; set; } = null;
/// <summary>
/// Include optional parameter `parseUrl: (url: string) => string = url=>url` that will parse constructed url.
/// </summary>
public bool IncludeParseUrlParam { get; set; } = false;
/// <summary>
/// Include optional parameter `parseRequest: (request: RequestInit) => RequestInit = request=>request` that will parse constructed request.
/// </summary>
public bool IncludeParseRequestParam { get; set; } = false;
/// <summary>
/// Array of routine names to skip (without schema)
/// </summary>
public string[] SkipRoutineNames { get; set; } = [];
/// <summary>
/// Array of generated function names to skip (without schema)
/// </summary>
public string[] SkipFunctionNames { get; set; } = [];
/// <summary>
/// Array of url paths to skip
/// </summary>
public string[] SkipPaths { get; set; } = [];
/// <summary>
/// Array of schema names to skip
/// </summary>
public string[] SkipSchemas { get; set; } = [];
/// <summary>
/// Default TypeScript type for JSON types.
/// </summary>
public string DefaultJsonType { get; set; } = "any";
/// <summary>
/// Use routine name instead of endpoint name when generating a function name.
/// </summary>
public bool UseRoutineNameInsteadOfEndpoint { get; set; } = false;
/// <summary>
/// Export URLs as constants.
/// </summary>
public bool ExportUrls { get; set; } = false;
/// <summary>
/// Skip generating types and produce pure JavaScript code. Setting this to true will also change .ts extension to .js where applicable.
/// </summary>
public bool SkipTypes { get; set; } = false;
/// <summary>
/// Keep TypeScript models unique, meaning, models will same fields and types will be merged into one model with name of the last model. Significantly reduces number of generated models.
/// </summary>
public bool UniqueModels { get; set; } = false;
/// <summary>
/// Name of the header to use for XSRF token. Set to null to skip.
/// </summary>
public string? XsrfTokenHeaderName { get; set; } = null;
/// <summary>
/// Export event sources create functions for streaming events.
/// </summary>
public bool ExportEventSources { get; set; } = true;
/// <summary>
/// List if custom imports to add to the generated code. It adds line to a file. Use full expression like `import { MyType } from './my-type';`
/// </summary>
public string[] CustomImports { get; set; } = [];
/// <summary>
/// List if custom headers to add to the each request in generated code. Header key is automatically quoted if it doesn't contain quotes.
/// </summary>
public Dictionary<string, string> CustomHeaders { get; set; } = [];
/// <summary>
/// When true, include PostgreSQL schema name in the generated type names to avoid name collisions. Set to false to simplify type names when no name collisions are expected.
/// </summary>
public bool IncludeSchemaInNames { get; set; } = false;
/// <summary>
/// Expression to parse error response. Default is "await response.json()".
/// Only used when IncludeStatusCode is true.
/// </summary>
public string ErrorExpression { get; set; } = "await response.json()";
/// <summary>
/// TypeScript type for error response. Default is "{status: number; title: string; detail?: string | null} | undefined".
/// Only used when IncludeStatusCode is true.
/// </summary>
public string ErrorType { get; set; } = "{status: number; title: string; detail?: string | null} | undefined";
/// <summary>
/// Name for the error type alias emitted at the top of the generated file.
/// The alias body is derived from ErrorType (with " | undefined" stripped).
/// Only used when IncludeStatusCode is true and SkipTypes is false.
/// Default is "ApiError".
/// </summary>
public string ErrorTypeName { get; set; } = "ApiError";
/// <summary>
/// Name for the generic result type alias emitted at the top of the generated file.
/// Defined as: type {ResultTypeName}<T> = {status: number, response: T, error: {ErrorTypeName} | undefined}.
/// Only used when IncludeStatusCode is true and SkipTypes is false.
/// Default is "ApiResult".
/// </summary>
public string ResultTypeName { get; set; } = "ApiResult";
/// <summary>
/// When true, parameters that are filled by the server and cannot be set by the client are omitted
/// from the generated request interface, query string, and body. This covers automatic parameters
/// that are also optional: HTTP Custom Type fields, resolved-parameter expressions, upload metadata,
/// and — on endpoints that use user parameters — IP-address and user-claim parameters. A client value
/// for these would be overridden server-side, so emitting them is misleading. Default is false
/// (all parameters are emitted, preserving existing generated output).
/// </summary>
public bool OmitAutomaticParameters { get; set; } = false;
}