@rbleattler/omp-ts-typegen 0.2025.1 → 0.2025.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -9
- package/package.json +52 -43
- package/readme.md +130 -130
- package/schema-explained.md +192 -192
- package/scripts/generate-types.ts +184 -184
- package/scripts/test-types.ts +416 -416
- package/scripts/validator.ts +88 -88
- package/src/index.ts +1 -1
- package/src/types/omp.ts +776 -0
- package/theme-validation-details.md +16 -0
- package/theme-validation.md +2 -2
- package/tsconfig.json +44 -44
- package/.github/copilot-instructions.md +0 -74
- package/.github/workflows/nightly-types.yml +0 -42
- package/.vscode/settings.json +0 -5
- package/default.omp.json +0 -60
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/omp.d.ts +0 -368
- package/dist/types/omp.d.ts.map +0 -1
- package/dist/types/omp.js +0 -398
- package/dist/types/omp.js.map +0 -1
- package/tsconfig.scripts.json +0 -9
package/src/types/omp.ts
ADDED
|
@@ -0,0 +1,776 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oh My Posh TypeScript definitions
|
|
3
|
+
*
|
|
4
|
+
* Generated from schema: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/refs/heads/main/themes/schema.json
|
|
5
|
+
* Generated on: 2025-03-11T00:03:42.512Z
|
|
6
|
+
*
|
|
7
|
+
* @see https://ohmyposh.dev/docs/
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* eslint-disable */
|
|
11
|
+
/* tslint:disable */
|
|
12
|
+
|
|
13
|
+
// To parse this data:
|
|
14
|
+
//
|
|
15
|
+
// import { Convert, OhMyPosh } from "./file";
|
|
16
|
+
//
|
|
17
|
+
// const ohMyPosh = Convert.toOhMyPosh(json);
|
|
18
|
+
//
|
|
19
|
+
// These functions will throw an error if the JSON doesn't
|
|
20
|
+
// match the expected interface, even if the JSON is valid.
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* https://ohmyposh.dev/docs/configuration/general
|
|
24
|
+
*/
|
|
25
|
+
export type OhMyPosh = {
|
|
26
|
+
accent_color?: string;
|
|
27
|
+
/**
|
|
28
|
+
* https://ohmyposh.dev/docs/configuration/general#blocks
|
|
29
|
+
*/
|
|
30
|
+
blocks: Block[];
|
|
31
|
+
/**
|
|
32
|
+
* https://ohmyposh.dev/docs/configuration/title#console-title-template
|
|
33
|
+
*/
|
|
34
|
+
console_title_template?: string;
|
|
35
|
+
/**
|
|
36
|
+
* https://ohmyposh.dev/docs/configuration/cycle
|
|
37
|
+
*/
|
|
38
|
+
cycle?: CycleElement[];
|
|
39
|
+
/**
|
|
40
|
+
* https://ohmyposh.dev/docs/configuration/debug-prompt
|
|
41
|
+
*/
|
|
42
|
+
debug_prompt?: ExtraPrompt;
|
|
43
|
+
/**
|
|
44
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
45
|
+
*/
|
|
46
|
+
enable_cursor_positioning?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* https://ohmyposh.dev/docs/configuration/line-error
|
|
49
|
+
*/
|
|
50
|
+
error_line?: ExtraPrompt;
|
|
51
|
+
/**
|
|
52
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
53
|
+
*/
|
|
54
|
+
final_space?: boolean;
|
|
55
|
+
iterm_features?: TheITerm2FeaturesToEnable[];
|
|
56
|
+
/**
|
|
57
|
+
* https://ohmyposh.dev/docs/configuration/colors#palette
|
|
58
|
+
*/
|
|
59
|
+
palette?: { [key: string]: string };
|
|
60
|
+
/**
|
|
61
|
+
* https://ohmyposh.dev/docs/configuration/colors#palettes
|
|
62
|
+
*/
|
|
63
|
+
palettes?: Palettes;
|
|
64
|
+
/**
|
|
65
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
66
|
+
*/
|
|
67
|
+
patch_pwsh_bleed?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
70
|
+
*/
|
|
71
|
+
pwd?: string;
|
|
72
|
+
/**
|
|
73
|
+
* https://ohmyposh.dev/docs/configuration/secondary-prompt
|
|
74
|
+
*/
|
|
75
|
+
secondary_prompt?: ExtraPrompt;
|
|
76
|
+
shell_integration?: boolean;
|
|
77
|
+
terminal_background?: string;
|
|
78
|
+
/**
|
|
79
|
+
* https://ohmyposh.dev/docs/configuration/tooltips
|
|
80
|
+
*/
|
|
81
|
+
tooltips?: TooltipListPromptElementsToDisplayBasedOnContext[];
|
|
82
|
+
/**
|
|
83
|
+
* https://ohmyposh.dev/docs/configuration/transient
|
|
84
|
+
*/
|
|
85
|
+
transient_prompt?: TransientPromptSetting;
|
|
86
|
+
/**
|
|
87
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
88
|
+
*/
|
|
89
|
+
upgrade?: EnableUpgradeNotice;
|
|
90
|
+
/**
|
|
91
|
+
* https://ohmyposh.dev/docs/configuration/line-error
|
|
92
|
+
*/
|
|
93
|
+
valid_line?: ExtraPrompt;
|
|
94
|
+
/**
|
|
95
|
+
* https://ohmyposh.dev/docs/configuration/templates#config-variables
|
|
96
|
+
*/
|
|
97
|
+
var?: { [key: string]: any };
|
|
98
|
+
[property: string]: any;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* https://ohmyposh.dev/docs/configuration/block
|
|
103
|
+
*/
|
|
104
|
+
export type Block = {
|
|
105
|
+
/**
|
|
106
|
+
* https://ohmyposh.dev/docs/configuration/block#alignment
|
|
107
|
+
*/
|
|
108
|
+
alignment?: BlockAlignment;
|
|
109
|
+
/**
|
|
110
|
+
* https://ohmyposh.dev/docs/configuration/block#leading-diamond
|
|
111
|
+
*/
|
|
112
|
+
leading_diamond?: string;
|
|
113
|
+
/**
|
|
114
|
+
* https://ohmyposh.dev/docs/configuration/block#newline
|
|
115
|
+
*/
|
|
116
|
+
newline?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* https://ohmyposh.dev/docs/configuration/block#segments
|
|
119
|
+
*/
|
|
120
|
+
segments?: Segment[];
|
|
121
|
+
/**
|
|
122
|
+
* https://ohmyposh.dev/docs/configuration/block#trailing-diamond
|
|
123
|
+
*/
|
|
124
|
+
trailing_diamond?: string;
|
|
125
|
+
/**
|
|
126
|
+
* https://ohmyposh.dev/docs/configuration/block#type
|
|
127
|
+
*/
|
|
128
|
+
type?: BlockType;
|
|
129
|
+
[property: string]: any;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* https://ohmyposh.dev/docs/configuration/block#alignment
|
|
134
|
+
*/
|
|
135
|
+
export type BlockAlignment = "left" | "right";
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
139
|
+
*/
|
|
140
|
+
export type Segment = {
|
|
141
|
+
/**
|
|
142
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
143
|
+
*/
|
|
144
|
+
alias?: string;
|
|
145
|
+
background?: string;
|
|
146
|
+
/**
|
|
147
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
148
|
+
*/
|
|
149
|
+
background_templates?: string[];
|
|
150
|
+
/**
|
|
151
|
+
* https://ohmyposh.dev/docs/configuration/segment#cache
|
|
152
|
+
*/
|
|
153
|
+
cache?: CacheSettings;
|
|
154
|
+
/**
|
|
155
|
+
* https://ohmyposh.dev/docs/configuration/segment#include--exclude-folders
|
|
156
|
+
*/
|
|
157
|
+
exclude_folders?: string[];
|
|
158
|
+
foreground?: string;
|
|
159
|
+
/**
|
|
160
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
161
|
+
*/
|
|
162
|
+
foreground_templates?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* https://ohmyposh.dev/docs/configuration/segment#include--exclude-folders
|
|
165
|
+
*/
|
|
166
|
+
include_folders?: string[];
|
|
167
|
+
/**
|
|
168
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
169
|
+
*/
|
|
170
|
+
interactive?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
173
|
+
*/
|
|
174
|
+
max_width?: number;
|
|
175
|
+
/**
|
|
176
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
177
|
+
*/
|
|
178
|
+
min_width?: number;
|
|
179
|
+
/**
|
|
180
|
+
* https://ohmyposh.dev/docs/configuration/segment#properties
|
|
181
|
+
*/
|
|
182
|
+
properties?: { [key: string]: any };
|
|
183
|
+
/**
|
|
184
|
+
* https://ohmyposh.dev/docs/configuration/segment#style
|
|
185
|
+
*/
|
|
186
|
+
style: string;
|
|
187
|
+
/**
|
|
188
|
+
* https://ohmyposh.dev/docs/configuration/templates
|
|
189
|
+
*/
|
|
190
|
+
template?: string;
|
|
191
|
+
/**
|
|
192
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
193
|
+
*/
|
|
194
|
+
templates_logic?: TemplatesLogic;
|
|
195
|
+
/**
|
|
196
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
197
|
+
*/
|
|
198
|
+
type: SegmentType;
|
|
199
|
+
[property: string]: any;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* https://ohmyposh.dev/docs/configuration/segment#cache
|
|
204
|
+
*/
|
|
205
|
+
export type CacheSettings = {
|
|
206
|
+
duration?: string;
|
|
207
|
+
/**
|
|
208
|
+
* https://ohmyposh.dev/docs/configuration/segment#strategy
|
|
209
|
+
*/
|
|
210
|
+
strategy?: CacheStrategy;
|
|
211
|
+
[property: string]: any;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* https://ohmyposh.dev/docs/configuration/segment#strategy
|
|
216
|
+
*/
|
|
217
|
+
export type CacheStrategy = "folder" | "session";
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
221
|
+
*/
|
|
222
|
+
export type TemplatesLogic = "first_match" | "join";
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
226
|
+
*/
|
|
227
|
+
export type SegmentType = "angular" | "argocd" | "aurelia" | "aws" | "az" | "azd" | "azfunc" | "battery" | "bazel" | "brewfather" | "buf" | "bun" | "carbonintensity" | "cds" | "cf" | "cftarget" | "cmake" | "command" | "connection" | "crystal" | "dart" | "deno" | "docker" | "dotnet" | "elixir" | "executiontime" | "firebase" | "flutter" | "fortran" | "fossil" | "gcp" | "git" | "gitversion" | "go" | "haskell" | "helm" | "ipify" | "java" | "julia" | "kotlin" | "kubectl" | "lastfm" | "lua" | "mercurial" | "mojo" | "mvn" | "nbgv" | "nightscout" | "nim" | "nix-shell" | "node" | "npm" | "nx" | "ocaml" | "os" | "owm" | "path" | "perl" | "php" | "plastic" | "pnpm" | "project" | "pulumi" | "python" | "quasar" | "r" | "react" | "root" | "ruby" | "rust" | "sapling" | "session" | "shell" | "sitecore" | "spotify" | "status" | "strava" | "svelte" | "svn" | "swift" | "sysinfo" | "talosctl" | "tauri" | "terraform" | "text" | "time" | "ui5tooling" | "umbraco" | "unity" | "upgrade" | "v" | "vala" | "wakatime" | "winreg" | "withings" | "xmake" | "yarn" | "ytm" | "zig";
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* https://ohmyposh.dev/docs/configuration/block#type
|
|
231
|
+
*/
|
|
232
|
+
export type BlockType = "prompt" | "rprompt";
|
|
233
|
+
|
|
234
|
+
export type CycleElement = any[] | boolean | number | number | null | CycleObject | string;
|
|
235
|
+
|
|
236
|
+
export type CycleObject = {
|
|
237
|
+
background?: string;
|
|
238
|
+
foreground?: string;
|
|
239
|
+
[property: string]: any;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* https://ohmyposh.dev/docs/configuration/debug-prompt
|
|
244
|
+
*
|
|
245
|
+
* https://ohmyposh.dev/docs/configuration/line-error
|
|
246
|
+
*
|
|
247
|
+
* https://ohmyposh.dev/docs/configuration/secondary-prompt
|
|
248
|
+
*/
|
|
249
|
+
export type ExtraPrompt = {
|
|
250
|
+
background?: string;
|
|
251
|
+
/**
|
|
252
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
253
|
+
*/
|
|
254
|
+
background_templates?: string[];
|
|
255
|
+
foreground?: string;
|
|
256
|
+
/**
|
|
257
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
258
|
+
*/
|
|
259
|
+
foreground_templates?: string[];
|
|
260
|
+
template?: string;
|
|
261
|
+
[property: string]: any;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type TheITerm2FeaturesToEnable = "prompt_mark" | "current_dir" | "remote_host";
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* https://ohmyposh.dev/docs/configuration/colors#palettes
|
|
268
|
+
*/
|
|
269
|
+
export type Palettes = {
|
|
270
|
+
list?: { [key: string]: { [key: string]: string } };
|
|
271
|
+
template?: string;
|
|
272
|
+
[property: string]: any;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
277
|
+
*/
|
|
278
|
+
export type TooltipListPromptElementsToDisplayBasedOnContext = {
|
|
279
|
+
/**
|
|
280
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
281
|
+
*/
|
|
282
|
+
alias?: string;
|
|
283
|
+
background?: string;
|
|
284
|
+
/**
|
|
285
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
286
|
+
*/
|
|
287
|
+
background_templates?: string[];
|
|
288
|
+
/**
|
|
289
|
+
* https://ohmyposh.dev/docs/configuration/segment#cache
|
|
290
|
+
*/
|
|
291
|
+
cache?: CacheSettings;
|
|
292
|
+
/**
|
|
293
|
+
* https://ohmyposh.dev/docs/configuration/segment#include--exclude-folders
|
|
294
|
+
*/
|
|
295
|
+
exclude_folders?: string[];
|
|
296
|
+
foreground?: string;
|
|
297
|
+
/**
|
|
298
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
299
|
+
*/
|
|
300
|
+
foreground_templates?: string[];
|
|
301
|
+
/**
|
|
302
|
+
* https://ohmyposh.dev/docs/configuration/segment#include--exclude-folders
|
|
303
|
+
*/
|
|
304
|
+
include_folders?: string[];
|
|
305
|
+
/**
|
|
306
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
307
|
+
*/
|
|
308
|
+
interactive?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
311
|
+
*/
|
|
312
|
+
max_width?: number;
|
|
313
|
+
/**
|
|
314
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
315
|
+
*/
|
|
316
|
+
min_width?: number;
|
|
317
|
+
/**
|
|
318
|
+
* https://ohmyposh.dev/docs/configuration/segment#properties
|
|
319
|
+
*/
|
|
320
|
+
properties?: { [key: string]: any };
|
|
321
|
+
/**
|
|
322
|
+
* https://ohmyposh.dev/docs/configuration/segment#style
|
|
323
|
+
*/
|
|
324
|
+
style: string;
|
|
325
|
+
/**
|
|
326
|
+
* https://ohmyposh.dev/docs/configuration/templates
|
|
327
|
+
*/
|
|
328
|
+
template?: string;
|
|
329
|
+
/**
|
|
330
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
331
|
+
*/
|
|
332
|
+
templates_logic?: TemplatesLogic;
|
|
333
|
+
tips: string[];
|
|
334
|
+
/**
|
|
335
|
+
* https://ohmyposh.dev/docs/configuration/segment
|
|
336
|
+
*/
|
|
337
|
+
type: SegmentType;
|
|
338
|
+
[property: string]: any;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* https://ohmyposh.dev/docs/configuration/transient
|
|
343
|
+
*
|
|
344
|
+
* https://ohmyposh.dev/docs/configuration/debug-prompt
|
|
345
|
+
*
|
|
346
|
+
* https://ohmyposh.dev/docs/configuration/line-error
|
|
347
|
+
*
|
|
348
|
+
* https://ohmyposh.dev/docs/configuration/secondary-prompt
|
|
349
|
+
*/
|
|
350
|
+
export type TransientPromptSetting = {
|
|
351
|
+
background?: string;
|
|
352
|
+
/**
|
|
353
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
354
|
+
*/
|
|
355
|
+
background_templates?: string[];
|
|
356
|
+
filler?: string;
|
|
357
|
+
foreground?: string;
|
|
358
|
+
/**
|
|
359
|
+
* https://ohmyposh.dev/docs/configuration/colors#color-templates
|
|
360
|
+
*/
|
|
361
|
+
foreground_templates?: string[];
|
|
362
|
+
/**
|
|
363
|
+
* Add a newline before the prompt
|
|
364
|
+
*/
|
|
365
|
+
newline?: boolean;
|
|
366
|
+
template?: string;
|
|
367
|
+
[property: string]: any;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* https://ohmyposh.dev/docs/configuration/general#general-settings
|
|
372
|
+
*/
|
|
373
|
+
export type EnableUpgradeNotice = {
|
|
374
|
+
auto?: boolean;
|
|
375
|
+
interval?: string;
|
|
376
|
+
notice?: boolean;
|
|
377
|
+
source?: Source;
|
|
378
|
+
[property: string]: any;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export type Source = "cdn" | "github";
|
|
382
|
+
|
|
383
|
+
// Converts JSON strings to/from your types
|
|
384
|
+
// and asserts the results of JSON.parse at runtime
|
|
385
|
+
export class Convert {
|
|
386
|
+
public static toOhMyPosh(json: string): OhMyPosh {
|
|
387
|
+
return cast(JSON.parse(json), r("OhMyPosh"));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public static ohMyPoshToJson(value: OhMyPosh): string {
|
|
391
|
+
return JSON.stringify(uncast(value, r("OhMyPosh")), null, 2);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
|
|
396
|
+
const prettyTyp = prettyTypeName(typ);
|
|
397
|
+
const parentText = parent ? ` on ${parent}` : '';
|
|
398
|
+
const keyText = key ? ` for key "${key}"` : '';
|
|
399
|
+
throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function prettyTypeName(typ: any): string {
|
|
403
|
+
if (Array.isArray(typ)) {
|
|
404
|
+
if (typ.length === 2 && typ[0] === undefined) {
|
|
405
|
+
return `an optional ${prettyTypeName(typ[1])}`;
|
|
406
|
+
} else {
|
|
407
|
+
return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
|
|
408
|
+
}
|
|
409
|
+
} else if (typeof typ === "object" && typ.literal !== undefined) {
|
|
410
|
+
return typ.literal;
|
|
411
|
+
} else {
|
|
412
|
+
return typeof typ;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function jsonToJSProps(typ: any): any {
|
|
417
|
+
if (typ.jsonToJS === undefined) {
|
|
418
|
+
const map: any = {};
|
|
419
|
+
typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
|
|
420
|
+
typ.jsonToJS = map;
|
|
421
|
+
}
|
|
422
|
+
return typ.jsonToJS;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function jsToJSONProps(typ: any): any {
|
|
426
|
+
if (typ.jsToJSON === undefined) {
|
|
427
|
+
const map: any = {};
|
|
428
|
+
typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
|
|
429
|
+
typ.jsToJSON = map;
|
|
430
|
+
}
|
|
431
|
+
return typ.jsToJSON;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
|
|
435
|
+
function transformPrimitive(typ: string, val: any): any {
|
|
436
|
+
if (typeof typ === typeof val) return val;
|
|
437
|
+
return invalidValue(typ, val, key, parent);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function transformUnion(typs: any[], val: any): any {
|
|
441
|
+
// val must validate against one typ in typs
|
|
442
|
+
const l = typs.length;
|
|
443
|
+
for (let i = 0; i < l; i++) {
|
|
444
|
+
const typ = typs[i];
|
|
445
|
+
try {
|
|
446
|
+
return transform(val, typ, getProps);
|
|
447
|
+
} catch (_) {}
|
|
448
|
+
}
|
|
449
|
+
return invalidValue(typs, val, key, parent);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function transformEnum(cases: string[], val: any): any {
|
|
453
|
+
if (cases.indexOf(val) !== -1) return val;
|
|
454
|
+
return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function transformArray(typ: any, val: any): any {
|
|
458
|
+
// val must be an array with no invalid elements
|
|
459
|
+
if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
|
|
460
|
+
return val.map(el => transform(el, typ, getProps));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function transformDate(val: any): any {
|
|
464
|
+
if (val === null) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
const d = new Date(val);
|
|
468
|
+
if (isNaN(d.valueOf())) {
|
|
469
|
+
return invalidValue(l("Date"), val, key, parent);
|
|
470
|
+
}
|
|
471
|
+
return d;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
|
|
475
|
+
if (val === null || typeof val !== "object" || Array.isArray(val)) {
|
|
476
|
+
return invalidValue(l(ref || "object"), val, key, parent);
|
|
477
|
+
}
|
|
478
|
+
const result: any = {};
|
|
479
|
+
Object.getOwnPropertyNames(props).forEach(key => {
|
|
480
|
+
const prop = props[key];
|
|
481
|
+
const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
|
|
482
|
+
result[prop.key] = transform(v, prop.typ, getProps, key, ref);
|
|
483
|
+
});
|
|
484
|
+
Object.getOwnPropertyNames(val).forEach(key => {
|
|
485
|
+
if (!Object.prototype.hasOwnProperty.call(props, key)) {
|
|
486
|
+
result[key] = transform(val[key], additional, getProps, key, ref);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (typ === "any") return val;
|
|
493
|
+
if (typ === null) {
|
|
494
|
+
if (val === null) return val;
|
|
495
|
+
return invalidValue(typ, val, key, parent);
|
|
496
|
+
}
|
|
497
|
+
if (typ === false) return invalidValue(typ, val, key, parent);
|
|
498
|
+
let ref: any = undefined;
|
|
499
|
+
while (typeof typ === "object" && typ.ref !== undefined) {
|
|
500
|
+
ref = typ.ref;
|
|
501
|
+
typ = typeMap[typ.ref];
|
|
502
|
+
}
|
|
503
|
+
if (Array.isArray(typ)) return transformEnum(typ, val);
|
|
504
|
+
if (typeof typ === "object") {
|
|
505
|
+
return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
|
|
506
|
+
: typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
|
|
507
|
+
: typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
|
|
508
|
+
: invalidValue(typ, val, key, parent);
|
|
509
|
+
}
|
|
510
|
+
// Numbers can be parsed by Date but shouldn't be.
|
|
511
|
+
if (typ === Date && typeof val !== "number") return transformDate(val);
|
|
512
|
+
return transformPrimitive(typ, val);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function cast<T>(val: any, typ: any): T {
|
|
516
|
+
return transform(val, typ, jsonToJSProps);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function uncast<T>(val: T, typ: any): any {
|
|
520
|
+
return transform(val, typ, jsToJSONProps);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function l(typ: any) {
|
|
524
|
+
return { literal: typ };
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function a(typ: any) {
|
|
528
|
+
return { arrayItems: typ };
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function u(...typs: any[]) {
|
|
532
|
+
return { unionMembers: typs };
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function o(props: any[], additional: any) {
|
|
536
|
+
return { props, additional };
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function m(additional: any) {
|
|
540
|
+
return { props: [], additional };
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function r(name: string) {
|
|
544
|
+
return { ref: name };
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const typeMap: any = {
|
|
548
|
+
"OhMyPosh": o([
|
|
549
|
+
{ json: "accent_color", js: "accent_color", typ: u(undefined, "") },
|
|
550
|
+
{ json: "blocks", js: "blocks", typ: a(r("Block")) },
|
|
551
|
+
{ json: "console_title_template", js: "console_title_template", typ: u(undefined, "") },
|
|
552
|
+
{ json: "cycle", js: "cycle", typ: u(undefined, a(u(a("any"), true, 3.14, 0, null, r("CycleObject"), ""))) },
|
|
553
|
+
{ json: "debug_prompt", js: "debug_prompt", typ: u(undefined, r("ExtraPrompt")) },
|
|
554
|
+
{ json: "enable_cursor_positioning", js: "enable_cursor_positioning", typ: u(undefined, true) },
|
|
555
|
+
{ json: "error_line", js: "error_line", typ: u(undefined, r("ExtraPrompt")) },
|
|
556
|
+
{ json: "final_space", js: "final_space", typ: u(undefined, true) },
|
|
557
|
+
{ json: "iterm_features", js: "iterm_features", typ: u(undefined, a(r("TheITerm2FeaturesToEnable"))) },
|
|
558
|
+
{ json: "palette", js: "palette", typ: u(undefined, m("")) },
|
|
559
|
+
{ json: "palettes", js: "palettes", typ: u(undefined, r("Palettes")) },
|
|
560
|
+
{ json: "patch_pwsh_bleed", js: "patch_pwsh_bleed", typ: u(undefined, true) },
|
|
561
|
+
{ json: "pwd", js: "pwd", typ: u(undefined, "") },
|
|
562
|
+
{ json: "secondary_prompt", js: "secondary_prompt", typ: u(undefined, r("ExtraPrompt")) },
|
|
563
|
+
{ json: "shell_integration", js: "shell_integration", typ: u(undefined, true) },
|
|
564
|
+
{ json: "terminal_background", js: "terminal_background", typ: u(undefined, "") },
|
|
565
|
+
{ json: "tooltips", js: "tooltips", typ: u(undefined, a(r("TooltipListPromptElementsToDisplayBasedOnContext"))) },
|
|
566
|
+
{ json: "transient_prompt", js: "transient_prompt", typ: u(undefined, r("TransientPromptSetting")) },
|
|
567
|
+
{ json: "upgrade", js: "upgrade", typ: u(undefined, r("EnableUpgradeNotice")) },
|
|
568
|
+
{ json: "valid_line", js: "valid_line", typ: u(undefined, r("ExtraPrompt")) },
|
|
569
|
+
{ json: "var", js: "var", typ: u(undefined, m("any")) },
|
|
570
|
+
], "any"),
|
|
571
|
+
"Block": o([
|
|
572
|
+
{ json: "alignment", js: "alignment", typ: u(undefined, r("BlockAlignment")) },
|
|
573
|
+
{ json: "leading_diamond", js: "leading_diamond", typ: u(undefined, "") },
|
|
574
|
+
{ json: "newline", js: "newline", typ: u(undefined, true) },
|
|
575
|
+
{ json: "segments", js: "segments", typ: u(undefined, a(r("Segment"))) },
|
|
576
|
+
{ json: "trailing_diamond", js: "trailing_diamond", typ: u(undefined, "") },
|
|
577
|
+
{ json: "type", js: "type", typ: u(undefined, r("BlockType")) },
|
|
578
|
+
], "any"),
|
|
579
|
+
"Segment": o([
|
|
580
|
+
{ json: "alias", js: "alias", typ: u(undefined, "") },
|
|
581
|
+
{ json: "background", js: "background", typ: u(undefined, "") },
|
|
582
|
+
{ json: "background_templates", js: "background_templates", typ: u(undefined, a("")) },
|
|
583
|
+
{ json: "cache", js: "cache", typ: u(undefined, r("CacheSettings")) },
|
|
584
|
+
{ json: "exclude_folders", js: "exclude_folders", typ: u(undefined, a("")) },
|
|
585
|
+
{ json: "foreground", js: "foreground", typ: u(undefined, "") },
|
|
586
|
+
{ json: "foreground_templates", js: "foreground_templates", typ: u(undefined, a("")) },
|
|
587
|
+
{ json: "include_folders", js: "include_folders", typ: u(undefined, a("")) },
|
|
588
|
+
{ json: "interactive", js: "interactive", typ: u(undefined, true) },
|
|
589
|
+
{ json: "max_width", js: "max_width", typ: u(undefined, 0) },
|
|
590
|
+
{ json: "min_width", js: "min_width", typ: u(undefined, 0) },
|
|
591
|
+
{ json: "properties", js: "properties", typ: u(undefined, m("any")) },
|
|
592
|
+
{ json: "style", js: "style", typ: "" },
|
|
593
|
+
{ json: "template", js: "template", typ: u(undefined, "") },
|
|
594
|
+
{ json: "templates_logic", js: "templates_logic", typ: u(undefined, r("TemplatesLogic")) },
|
|
595
|
+
{ json: "type", js: "type", typ: r("SegmentType") },
|
|
596
|
+
], "any"),
|
|
597
|
+
"CacheSettings": o([
|
|
598
|
+
{ json: "duration", js: "duration", typ: u(undefined, "") },
|
|
599
|
+
{ json: "strategy", js: "strategy", typ: u(undefined, r("CacheStrategy")) },
|
|
600
|
+
], "any"),
|
|
601
|
+
"CycleObject": o([
|
|
602
|
+
{ json: "background", js: "background", typ: u(undefined, "") },
|
|
603
|
+
{ json: "foreground", js: "foreground", typ: u(undefined, "") },
|
|
604
|
+
], "any"),
|
|
605
|
+
"ExtraPrompt": o([
|
|
606
|
+
{ json: "background", js: "background", typ: u(undefined, "") },
|
|
607
|
+
{ json: "background_templates", js: "background_templates", typ: u(undefined, a("")) },
|
|
608
|
+
{ json: "foreground", js: "foreground", typ: u(undefined, "") },
|
|
609
|
+
{ json: "foreground_templates", js: "foreground_templates", typ: u(undefined, a("")) },
|
|
610
|
+
{ json: "template", js: "template", typ: u(undefined, "") },
|
|
611
|
+
], "any"),
|
|
612
|
+
"Palettes": o([
|
|
613
|
+
{ json: "list", js: "list", typ: u(undefined, m(m(""))) },
|
|
614
|
+
{ json: "template", js: "template", typ: u(undefined, "") },
|
|
615
|
+
], "any"),
|
|
616
|
+
"TooltipListPromptElementsToDisplayBasedOnContext": o([
|
|
617
|
+
{ json: "alias", js: "alias", typ: u(undefined, "") },
|
|
618
|
+
{ json: "background", js: "background", typ: u(undefined, "") },
|
|
619
|
+
{ json: "background_templates", js: "background_templates", typ: u(undefined, a("")) },
|
|
620
|
+
{ json: "cache", js: "cache", typ: u(undefined, r("CacheSettings")) },
|
|
621
|
+
{ json: "exclude_folders", js: "exclude_folders", typ: u(undefined, a("")) },
|
|
622
|
+
{ json: "foreground", js: "foreground", typ: u(undefined, "") },
|
|
623
|
+
{ json: "foreground_templates", js: "foreground_templates", typ: u(undefined, a("")) },
|
|
624
|
+
{ json: "include_folders", js: "include_folders", typ: u(undefined, a("")) },
|
|
625
|
+
{ json: "interactive", js: "interactive", typ: u(undefined, true) },
|
|
626
|
+
{ json: "max_width", js: "max_width", typ: u(undefined, 0) },
|
|
627
|
+
{ json: "min_width", js: "min_width", typ: u(undefined, 0) },
|
|
628
|
+
{ json: "properties", js: "properties", typ: u(undefined, m("any")) },
|
|
629
|
+
{ json: "style", js: "style", typ: "" },
|
|
630
|
+
{ json: "template", js: "template", typ: u(undefined, "") },
|
|
631
|
+
{ json: "templates_logic", js: "templates_logic", typ: u(undefined, r("TemplatesLogic")) },
|
|
632
|
+
{ json: "tips", js: "tips", typ: a("") },
|
|
633
|
+
{ json: "type", js: "type", typ: r("SegmentType") },
|
|
634
|
+
], "any"),
|
|
635
|
+
"TransientPromptSetting": o([
|
|
636
|
+
{ json: "background", js: "background", typ: u(undefined, "") },
|
|
637
|
+
{ json: "background_templates", js: "background_templates", typ: u(undefined, a("")) },
|
|
638
|
+
{ json: "filler", js: "filler", typ: u(undefined, "") },
|
|
639
|
+
{ json: "foreground", js: "foreground", typ: u(undefined, "") },
|
|
640
|
+
{ json: "foreground_templates", js: "foreground_templates", typ: u(undefined, a("")) },
|
|
641
|
+
{ json: "newline", js: "newline", typ: u(undefined, true) },
|
|
642
|
+
{ json: "template", js: "template", typ: u(undefined, "") },
|
|
643
|
+
], "any"),
|
|
644
|
+
"EnableUpgradeNotice": o([
|
|
645
|
+
{ json: "auto", js: "auto", typ: u(undefined, true) },
|
|
646
|
+
{ json: "interval", js: "interval", typ: u(undefined, "") },
|
|
647
|
+
{ json: "notice", js: "notice", typ: u(undefined, true) },
|
|
648
|
+
{ json: "source", js: "source", typ: u(undefined, r("Source")) },
|
|
649
|
+
], "any"),
|
|
650
|
+
"BlockAlignment": [
|
|
651
|
+
"left",
|
|
652
|
+
"right",
|
|
653
|
+
],
|
|
654
|
+
"CacheStrategy": [
|
|
655
|
+
"folder",
|
|
656
|
+
"session",
|
|
657
|
+
],
|
|
658
|
+
"TemplatesLogic": [
|
|
659
|
+
"first_match",
|
|
660
|
+
"join",
|
|
661
|
+
],
|
|
662
|
+
"SegmentType": [
|
|
663
|
+
"angular",
|
|
664
|
+
"argocd",
|
|
665
|
+
"aurelia",
|
|
666
|
+
"aws",
|
|
667
|
+
"az",
|
|
668
|
+
"azd",
|
|
669
|
+
"azfunc",
|
|
670
|
+
"battery",
|
|
671
|
+
"bazel",
|
|
672
|
+
"brewfather",
|
|
673
|
+
"buf",
|
|
674
|
+
"bun",
|
|
675
|
+
"carbonintensity",
|
|
676
|
+
"cds",
|
|
677
|
+
"cf",
|
|
678
|
+
"cftarget",
|
|
679
|
+
"cmake",
|
|
680
|
+
"command",
|
|
681
|
+
"connection",
|
|
682
|
+
"crystal",
|
|
683
|
+
"dart",
|
|
684
|
+
"deno",
|
|
685
|
+
"docker",
|
|
686
|
+
"dotnet",
|
|
687
|
+
"elixir",
|
|
688
|
+
"executiontime",
|
|
689
|
+
"firebase",
|
|
690
|
+
"flutter",
|
|
691
|
+
"fortran",
|
|
692
|
+
"fossil",
|
|
693
|
+
"gcp",
|
|
694
|
+
"git",
|
|
695
|
+
"gitversion",
|
|
696
|
+
"go",
|
|
697
|
+
"haskell",
|
|
698
|
+
"helm",
|
|
699
|
+
"ipify",
|
|
700
|
+
"java",
|
|
701
|
+
"julia",
|
|
702
|
+
"kotlin",
|
|
703
|
+
"kubectl",
|
|
704
|
+
"lastfm",
|
|
705
|
+
"lua",
|
|
706
|
+
"mercurial",
|
|
707
|
+
"mojo",
|
|
708
|
+
"mvn",
|
|
709
|
+
"nbgv",
|
|
710
|
+
"nightscout",
|
|
711
|
+
"nim",
|
|
712
|
+
"nix-shell",
|
|
713
|
+
"node",
|
|
714
|
+
"npm",
|
|
715
|
+
"nx",
|
|
716
|
+
"ocaml",
|
|
717
|
+
"os",
|
|
718
|
+
"owm",
|
|
719
|
+
"path",
|
|
720
|
+
"perl",
|
|
721
|
+
"php",
|
|
722
|
+
"plastic",
|
|
723
|
+
"pnpm",
|
|
724
|
+
"project",
|
|
725
|
+
"pulumi",
|
|
726
|
+
"python",
|
|
727
|
+
"quasar",
|
|
728
|
+
"r",
|
|
729
|
+
"react",
|
|
730
|
+
"root",
|
|
731
|
+
"ruby",
|
|
732
|
+
"rust",
|
|
733
|
+
"sapling",
|
|
734
|
+
"session",
|
|
735
|
+
"shell",
|
|
736
|
+
"sitecore",
|
|
737
|
+
"spotify",
|
|
738
|
+
"status",
|
|
739
|
+
"strava",
|
|
740
|
+
"svelte",
|
|
741
|
+
"svn",
|
|
742
|
+
"swift",
|
|
743
|
+
"sysinfo",
|
|
744
|
+
"talosctl",
|
|
745
|
+
"tauri",
|
|
746
|
+
"terraform",
|
|
747
|
+
"text",
|
|
748
|
+
"time",
|
|
749
|
+
"ui5tooling",
|
|
750
|
+
"umbraco",
|
|
751
|
+
"unity",
|
|
752
|
+
"upgrade",
|
|
753
|
+
"v",
|
|
754
|
+
"vala",
|
|
755
|
+
"wakatime",
|
|
756
|
+
"winreg",
|
|
757
|
+
"withings",
|
|
758
|
+
"xmake",
|
|
759
|
+
"yarn",
|
|
760
|
+
"ytm",
|
|
761
|
+
"zig",
|
|
762
|
+
],
|
|
763
|
+
"BlockType": [
|
|
764
|
+
"prompt",
|
|
765
|
+
"rprompt",
|
|
766
|
+
],
|
|
767
|
+
"TheITerm2FeaturesToEnable": [
|
|
768
|
+
"current_dir",
|
|
769
|
+
"prompt_mark",
|
|
770
|
+
"remote_host",
|
|
771
|
+
],
|
|
772
|
+
"Source": [
|
|
773
|
+
"cdn",
|
|
774
|
+
"github",
|
|
775
|
+
],
|
|
776
|
+
};
|