@typeslayer/validate 0.0.0 → 0.1.10

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.
@@ -0,0 +1,1126 @@
1
+ import { z } from "zod/v4";
2
+ import { absolutePath, typeId } from "./utils";
3
+
4
+ export const TRACE_JSON_FILENAME = "trace.json";
5
+
6
+ export const eventPhase = {
7
+ begin: "B",
8
+ end: "E",
9
+ complete: "X",
10
+ metadata: "M",
11
+ instantGlobal: "I",
12
+ // 'i' is instantThread
13
+ } as const;
14
+
15
+ export const instantScope = {
16
+ thread: "t",
17
+ global: "g",
18
+ process: "p",
19
+ };
20
+
21
+ const durationEvent = {
22
+ ph: z.union([z.literal(eventPhase.begin), z.literal(eventPhase.end)]),
23
+ };
24
+
25
+ const completeEvent = {
26
+ ph: z.literal(eventPhase.complete),
27
+ dur: z.number().positive(),
28
+ };
29
+
30
+ const instantEvent = {
31
+ ph: z.literal(eventPhase.instantGlobal),
32
+ };
33
+
34
+ const category = {
35
+ parse: {
36
+ cat: z.literal("parse"),
37
+ },
38
+ program: {
39
+ cat: z.literal("program"),
40
+ },
41
+ bind: {
42
+ cat: z.literal("bind"),
43
+ },
44
+ check: {
45
+ cat: z.literal("check"),
46
+ },
47
+ checkTypes: {
48
+ cat: z.literal("checkTypes"),
49
+ },
50
+ emit: {
51
+ cat: z.literal("emit"),
52
+ },
53
+ session: {
54
+ cat: z.literal("session"),
55
+ },
56
+ };
57
+
58
+ const eventCommon = {
59
+ pid: z.number().int().positive(),
60
+ tid: z.number().int().positive(),
61
+ ts: z.number().positive(),
62
+ };
63
+
64
+ /*
65
+ * METADATA EVENTS
66
+ */
67
+
68
+ const event_metadata__TracingStartedInBrowser = z
69
+ .object({
70
+ ...eventCommon,
71
+ cat: z.literal("disabled-by-default-devtools.timeline"),
72
+ name: z.literal("TracingStartedInBrowser"),
73
+ ph: z.literal(eventPhase.metadata),
74
+ })
75
+ .strict();
76
+
77
+ const event_metadata__process_name = z
78
+ .object({
79
+ ...eventCommon,
80
+ ph: z.literal(eventPhase.metadata),
81
+ args: z.object({
82
+ name: z.literal("tsc"),
83
+ }),
84
+ cat: z.literal("__metadata"),
85
+ name: z.literal("process_name"),
86
+ })
87
+ .strict();
88
+
89
+ const event_metadata__thread_name = z
90
+ .object({
91
+ ...eventCommon,
92
+ name: z.literal("thread_name"),
93
+ cat: z.literal("__metadata"),
94
+ ph: z.literal(eventPhase.metadata),
95
+ args: z.object({
96
+ name: z.literal("Main"),
97
+ }),
98
+ })
99
+ .strict();
100
+
101
+ /*
102
+ * PARSE PHASE EVENTS
103
+ */
104
+
105
+ const event_parse__createSourceFile = z
106
+ .object({
107
+ ...eventCommon,
108
+ ...category.parse,
109
+ ...durationEvent,
110
+ name: z.literal("createSourceFile"),
111
+ args: z.object({
112
+ path: absolutePath,
113
+ }),
114
+ })
115
+ .strict();
116
+
117
+ const event_parse__parseJsonSourceFileConfigFileContent = z
118
+ .object({
119
+ ...eventCommon,
120
+ ...category.parse,
121
+ ...completeEvent,
122
+ name: z.literal("parseJsonSourceFileConfigFileContent"),
123
+ args: z.object({
124
+ path: absolutePath,
125
+ }),
126
+ })
127
+ .strict();
128
+
129
+ /*
130
+ * PROGRAM PHASE EVENTS
131
+ */
132
+
133
+ const event_program__createProgram = z
134
+ .object({
135
+ ...eventCommon,
136
+ ...category.program,
137
+ ...durationEvent,
138
+ name: z.literal("createProgram"),
139
+ args: z.object({
140
+ configFilePath: absolutePath, // path to the tsconfig.json file
141
+ }),
142
+ })
143
+ .strict();
144
+
145
+ const event_program__findSourceFile = z
146
+ .object({
147
+ ...eventCommon,
148
+ ...category.program,
149
+ ...completeEvent,
150
+ name: z.literal("findSourceFile"),
151
+ dur: z.number(),
152
+ args: z.object({
153
+ fileName: absolutePath,
154
+ fileIncludeKind: z.union([
155
+ z.literal("RootFile"),
156
+ z.literal("Import"),
157
+ z.literal("TypeReferenceDirective"),
158
+ z.literal("LibFile"),
159
+ z.literal("LibReferenceDirective"),
160
+ z.literal("AutomaticTypeDirectiveFile"),
161
+ z.literal("ReferenceFile"),
162
+ ]),
163
+ }),
164
+ })
165
+ .strict();
166
+
167
+ const event_program__processRootFiles = z
168
+ .object({
169
+ ...eventCommon,
170
+ ...category.program,
171
+ ...completeEvent,
172
+ name: z.literal("processRootFiles"),
173
+ dur: z.number(),
174
+ args: z.object({ count: z.number().int().positive() }),
175
+ })
176
+ .strict();
177
+
178
+ const event_program__processTypeReferenceDirective = z
179
+ .object({
180
+ ...eventCommon,
181
+ ...category.program,
182
+ ...completeEvent,
183
+ name: z.literal("processTypeReferenceDirective"),
184
+ dur: z.number(),
185
+ args: z.object({
186
+ directive: z.string(),
187
+ hasResolved: z.literal(true),
188
+ refKind: z.number().int().positive(),
189
+ refPath: absolutePath.optional(),
190
+ }),
191
+ })
192
+ .strict();
193
+
194
+ const event_program__processTypeReferences = z
195
+ .object({
196
+ ...eventCommon,
197
+ ...category.program,
198
+ ...completeEvent,
199
+ name: z.literal("processTypeReferences"),
200
+ dur: z.number(),
201
+ args: z.object({
202
+ count: z.number().int().positive(),
203
+ }),
204
+ })
205
+ .strict();
206
+
207
+ const event_program__resolveLibrary = z
208
+ .object({
209
+ ...eventCommon,
210
+ ...category.program,
211
+ ...completeEvent,
212
+ name: z.literal("resolveLibrary"),
213
+ args: z.object({
214
+ resolveFrom: absolutePath,
215
+ }),
216
+ })
217
+ .strict();
218
+
219
+ const event_program__resolveModuleNamesWorker = z
220
+ .object({
221
+ ...eventCommon,
222
+ ...category.program,
223
+ ...completeEvent,
224
+ name: z.literal("resolveModuleNamesWorker"),
225
+ args: z.object({
226
+ containingFileName: absolutePath,
227
+ }),
228
+ })
229
+ .strict();
230
+
231
+ const event_program__resolveTypeReferenceDirectiveNamesWorker = z
232
+ .object({
233
+ ...eventCommon,
234
+ ...category.program,
235
+ ...completeEvent,
236
+ name: z.literal("resolveTypeReferenceDirectiveNamesWorker"),
237
+ args: z.object({
238
+ containingFileName: absolutePath,
239
+ }),
240
+ })
241
+ .strict();
242
+
243
+ const event_program__shouldProgramCreateNewSourceFiles = z
244
+ .object({
245
+ ...eventCommon,
246
+ ...category.program,
247
+ ...instantEvent,
248
+ name: z.literal("shouldProgramCreateNewSourceFiles"),
249
+ s: z.union([
250
+ z.literal(instantScope.global),
251
+ z.literal(instantScope.thread),
252
+ z.literal(instantScope.process),
253
+ ]),
254
+ args: z.object({
255
+ hasOldProgram: z.boolean(),
256
+ }),
257
+ })
258
+ .strict();
259
+
260
+ const event_program__tryReuseStructureFromOldProgram = z
261
+ .object({
262
+ ...eventCommon,
263
+ ...category.program,
264
+ ...completeEvent,
265
+ name: z.literal("tryReuseStructureFromOldProgram"),
266
+ dur: z.number(),
267
+ args: z.object({}),
268
+ })
269
+ .strict();
270
+
271
+ /*
272
+ * BIND PHASE EVENTS
273
+ */
274
+
275
+ const event_bind__bindSourceFile = z
276
+ .object({
277
+ ...eventCommon,
278
+ ...category.bind,
279
+ ...durationEvent,
280
+ name: z.literal("bindSourceFile"),
281
+ args: z.object({
282
+ path: absolutePath,
283
+ }),
284
+ })
285
+ .strict();
286
+
287
+ /*
288
+ * CHECK PHASE EVENTS
289
+ */
290
+
291
+ const event_check__checkExpression = z
292
+ .object({
293
+ ...eventCommon,
294
+ ...category.check,
295
+ ...completeEvent,
296
+ name: z.literal("checkExpression"),
297
+ dur: z.number(),
298
+ args: z.object({
299
+ kind: z.number(),
300
+ pos: z.number(),
301
+ end: z.number(),
302
+ path: absolutePath.optional(),
303
+ }),
304
+ })
305
+ .strict();
306
+
307
+ const event_check__checkSourceFile = z
308
+ .object({
309
+ ...eventCommon,
310
+ ...category.check,
311
+ ...durationEvent,
312
+ name: z.literal("checkSourceFile"),
313
+ args: z.object({
314
+ path: absolutePath,
315
+ }),
316
+ })
317
+ .strict();
318
+
319
+ const event_check__checkVariableDeclaration = z
320
+ .object({
321
+ ...eventCommon,
322
+ ...category.check,
323
+ ...completeEvent,
324
+ name: z.literal("checkVariableDeclaration"),
325
+ dur: z.number(),
326
+ args: z.object({
327
+ kind: z.number(),
328
+ pos: z.number(),
329
+ end: z.number(),
330
+ path: absolutePath,
331
+ }),
332
+ })
333
+ .strict();
334
+
335
+ const event_check__checkDeferredNode = z
336
+ .object({
337
+ ...eventCommon,
338
+ ...category.check,
339
+ ...completeEvent,
340
+ name: z.literal("checkDeferredNode"),
341
+ dur: z.number(),
342
+ args: z.object({
343
+ kind: z.number(),
344
+ pos: z.number(),
345
+ end: z.number(),
346
+ path: absolutePath,
347
+ }),
348
+ })
349
+ .strict();
350
+
351
+ const event_check__checkSourceFileNodes = z
352
+ .object({
353
+ ...eventCommon,
354
+ ...category.check,
355
+ ...completeEvent,
356
+ name: z.literal("checkSourceFileNodes"),
357
+ dur: z.number(),
358
+ args: z.object({
359
+ path: absolutePath,
360
+ }),
361
+ })
362
+ .strict();
363
+
364
+ /*
365
+ * CHECKTYPES PHASE EVENTS
366
+ */
367
+ const event_checktypes__checkTypeParameterDeferred = z
368
+ .object({
369
+ ...eventCommon,
370
+ ...category.checkTypes,
371
+ ...completeEvent,
372
+ name: z.literal("checkTypeParameterDeferred"),
373
+ dur: z.number(),
374
+ args: z.object({
375
+ parent: typeId,
376
+ id: typeId,
377
+ }),
378
+ })
379
+ .strict();
380
+
381
+ const event_checktypes__getVariancesWorker = z
382
+ .object({
383
+ ...eventCommon,
384
+ ...category.checkTypes,
385
+ ...completeEvent,
386
+ name: z.literal("getVariancesWorker"),
387
+ dur: z.number(),
388
+ args: z.object({
389
+ arity: z.number().int().nonnegative(),
390
+ id: z.number().int().positive(),
391
+ results: z.object({
392
+ variances: z.array(
393
+ z.union([
394
+ z.literal("[independent]"),
395
+ z.literal("[independent] (unreliable)"),
396
+ z.literal("[independent] (unmeasurable)"),
397
+ z.literal("[bivariant]"),
398
+ z.literal("[bivariant] (unreliable)"),
399
+ z.literal("[bivariant] (unmeasurable)"),
400
+ z.literal("in"),
401
+ z.literal("in (unreliable)"),
402
+ z.literal("in (unmeasurable)"),
403
+ z.literal("out"),
404
+ z.literal("out (unreliable)"),
405
+ z.literal("out (unmeasurable)"),
406
+ z.literal("in out" /*burger*/),
407
+ z.literal("in out (unreliable)"),
408
+ z.literal("in out (unmeasurable)"),
409
+ ]),
410
+ ),
411
+ }),
412
+ }),
413
+ })
414
+ .strict();
415
+
416
+ const event_checktypes__structuredTypeRelatedTo = z
417
+ .object({
418
+ ...eventCommon,
419
+ ...category.checkTypes,
420
+ ...completeEvent,
421
+ name: z.literal("structuredTypeRelatedTo"),
422
+ args: z.object({
423
+ sourceId: typeId,
424
+ targetId: typeId,
425
+ }),
426
+ })
427
+ .strict();
428
+
429
+ /*
430
+ * CHECKTYPES PHASE DEPTH LIMIT EVENTS
431
+ */
432
+
433
+ /**
434
+ * The `checkCrossProductUnion_DepthLimit` limit is hit when the cross-product of two types exceeds 100_000 combinations while expanding intersections into a union.
435
+ *
436
+ * This triggers the error `TS(2590) Expression produces a union type that is too complex to represent.`
437
+ */
438
+ export const event_checktypes__checkCrossProductUnion_DepthLimit = z
439
+ .object({
440
+ ...eventCommon,
441
+ ...category.checkTypes,
442
+ ...instantEvent,
443
+ name: z.literal("checkCrossProductUnion_DepthLimit"),
444
+ s: z.union([
445
+ z.literal(instantScope.global),
446
+ z.literal(instantScope.thread),
447
+ z.literal(instantScope.process),
448
+ ]),
449
+ args: z.object({
450
+ types: z.array(typeId),
451
+ size: z.number().int().positive(),
452
+ }),
453
+ })
454
+ .strict();
455
+ export type EventChecktypes__CheckCrossProductUnion_DepthLimit = z.infer<
456
+ typeof event_checktypes__checkCrossProductUnion_DepthLimit
457
+ >;
458
+
459
+ /**
460
+ * The `checkTypeRelatedTo_DepthLimit` limit is hit when a type relationship check overflows: either the checker reaches its recursion stack limit while comparing deeply nested (or expanding) types or it exhausts the relation-complexity budget.
461
+ * in Node.js the maximum number of elements in a map is 2^24.
462
+ * TypeScript therefore limits the number of entries an invocation of `checkTypeRelatedTo` can add to a relation to 1/8th of its remaining capacity.
463
+ * This limit being hit means the relation will be recorded as failing.
464
+ *
465
+ * This triggers one of the following errors:
466
+ * - `TS(2859) Excessive complexity comparing types '{0}' and '{1}'.`
467
+ * - `TS(2321) Excessive stack depth comparing types '{0}' and '{1}'.`
468
+ */
469
+ export const event_checktypes__checkTypeRelatedTo_DepthLimit = z
470
+ .object({
471
+ ...eventCommon,
472
+ ...category.checkTypes,
473
+ ...instantEvent,
474
+ name: z.literal("checkTypeRelatedTo_DepthLimit"),
475
+ s: z.union([
476
+ z.literal(instantScope.global),
477
+ z.literal(instantScope.thread),
478
+ z.literal(instantScope.process),
479
+ ]),
480
+ args: z.object({
481
+ sourceId: typeId,
482
+ targetId: typeId,
483
+ depth: z.number().int().positive(),
484
+ targetDepth: z.number().int().positive(),
485
+ }),
486
+ })
487
+ .strict();
488
+ export type EventChecktypes__CheckTypeRelatedTo_DepthLimit = z.infer<
489
+ typeof event_checktypes__checkTypeRelatedTo_DepthLimit
490
+ >;
491
+
492
+ /**
493
+ * The `getTypeAtFlowNode_DepthLimit` limit is hit when resolving the control flow type for a reference causes more than 2_000 recursions.
494
+ * To avoid overflowing the call stack we report an error and disable further control flow analysis in the containing function or module body.
495
+ *
496
+ * This triggers the error `TS(2563) The containing function or module body is too large for control flow analysis.`
497
+ */
498
+ export const event_checktypes__getTypeAtFlowNode_DepthLimit = z
499
+ .object({
500
+ ...eventCommon,
501
+ ...category.checkTypes,
502
+ ...instantEvent,
503
+ name: z.literal("getTypeAtFlowNode_DepthLimit"),
504
+ s: z.union([
505
+ z.literal(instantScope.global),
506
+ z.literal(instantScope.thread),
507
+ z.literal(instantScope.process),
508
+ ]),
509
+ args: z.object({
510
+ flowId: z.number().int().positive(),
511
+ }),
512
+ })
513
+ .strict();
514
+ export type EventChecktypes__GetTypeAtFlowNode_DepthLimit = z.infer<
515
+ typeof event_checktypes__getTypeAtFlowNode_DepthLimit
516
+ >;
517
+
518
+ /**
519
+ * The `instantiateType_DepthLimit` is hit when more than 100 recursive type instantiations or 5_000_000 instantiations are caused by the same statement or expression.
520
+ * There is a very high likelihood we're dealing with a combination of infinite generic types that perpetually generate new type identities, so TypeScript stops and throws this error.
521
+ *
522
+ * This triggers the error `TS(2589) Type instantiation is excessively deep and possibly infinite.`
523
+ */
524
+
525
+ export const event_checktypes__instantiateType_DepthLimit = z
526
+ .object({
527
+ ...eventCommon,
528
+ ...category.checkTypes,
529
+ ...instantEvent,
530
+ name: z.literal("instantiateType_DepthLimit"),
531
+ s: z.union([
532
+ z.literal(instantScope.global),
533
+ z.literal(instantScope.thread),
534
+ z.literal(instantScope.process),
535
+ ]),
536
+ args: z.object({
537
+ typeId,
538
+ instantiationDepth: z.number().int(),
539
+ instantiationCount: z.number().int().positive(),
540
+ }),
541
+ })
542
+ .strict();
543
+ export type EventChecktypes__InstantiateType_DepthLimit = z.infer<
544
+ typeof event_checktypes__instantiateType_DepthLimit
545
+ >;
546
+
547
+ /**
548
+ * The `recursiveTypeRelatedTo_DepthLimit` limit is hit when the sourceDepth or targetDepth of a type check exceeds 100 during recursive type comparison, indicating a runaway recursion from deeply nested generics or type instantiations.
549
+ *
550
+ * This is not currently considered a hard error by the compiler and therefore
551
+ does not report to the user (unless you're a TypeSlayer user 😉).
552
+ */
553
+ export const event_checktypes__recursiveTypeRelatedTo_DepthLimit = z
554
+ .object({
555
+ ...eventCommon,
556
+ ...category.checkTypes,
557
+ ...instantEvent,
558
+ name: z.literal("recursiveTypeRelatedTo_DepthLimit"),
559
+ s: z.union([
560
+ z.literal(instantScope.global),
561
+ z.literal(instantScope.thread),
562
+ z.literal(instantScope.process),
563
+ ]),
564
+ args: z.object({
565
+ sourceId: typeId,
566
+ sourceIdStack: z.array(typeId),
567
+ targetId: typeId,
568
+ targetIdStack: z.array(typeId),
569
+ depth: z.number().int().positive(),
570
+ targetDepth: z.number().int().positive(),
571
+ }),
572
+ })
573
+ .strict();
574
+ export type EventChecktypes__RecursiveTypeRelatedTo_DepthLimit = z.infer<
575
+ typeof event_checktypes__recursiveTypeRelatedTo_DepthLimit
576
+ >;
577
+
578
+ /**
579
+ * The `removeSubtypes_DepthLimit` limit is hit when subtype-reduction work becomes too large.
580
+ * Specifically, when more than 100,000 pairwise constituent checks occur, the type checker will pause and estimate remaining work.
581
+ * If that estimate exceeds 1_000_000 pairwise checks, the checker will halt and report this error.
582
+ *
583
+ * This triggers the error `TS(2590) Expression produces a union type that is too complex to represent.`
584
+ *
585
+ */
586
+ export const event_checktypes__removeSubtypes_DepthLimit = z
587
+ .object({
588
+ ...eventCommon,
589
+ ...category.checkTypes,
590
+ ...instantEvent,
591
+ name: z.literal("removeSubtypes_DepthLimit"),
592
+ s: z.union([
593
+ z.literal(instantScope.global),
594
+ z.literal(instantScope.thread),
595
+ z.literal(instantScope.process),
596
+ ]),
597
+ args: z.object({
598
+ typeIds: z.array(typeId),
599
+ }),
600
+ })
601
+ .strict();
602
+ export type EventChecktypes__RemoveSubtypes_DepthLimit = z.infer<
603
+ typeof event_checktypes__removeSubtypes_DepthLimit
604
+ >;
605
+
606
+ /**
607
+ * The `traceUnionsOrIntersectionsTooLarge_DepthLimit` limit is hit when the product of a source and target type that will be part of a union will exceed 1_000_000 members when multiplied out.
608
+ *
609
+ * This is not currently considered a hard error by the compiler and therefore
610
+ does not report to the user (unless you're a TypeSlayer user 😉).
611
+ */
612
+ export const event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit = z
613
+ .object({
614
+ ...eventCommon,
615
+ ...category.checkTypes,
616
+ ...instantEvent,
617
+ name: z.literal("traceUnionsOrIntersectionsTooLarge_DepthLimit"),
618
+ s: z.union([
619
+ z.literal(instantScope.global),
620
+ z.literal(instantScope.thread),
621
+ z.literal(instantScope.process),
622
+ ]),
623
+ args: z.object({
624
+ sourceId: typeId,
625
+ sourceSize: z.number().int().positive(),
626
+ targetId: typeId,
627
+ targetSize: z.number().int().positive(),
628
+ pos: z.number().int().nonnegative().optional(),
629
+ end: z.number().int().positive().optional(),
630
+ }),
631
+ })
632
+ .strict();
633
+ export type EventChecktypes__TraceUnionsOrIntersectionsTooLarge_DepthLimit =
634
+ z.infer<
635
+ typeof event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit
636
+ >;
637
+
638
+ /**
639
+ * The `typeRelatedToDiscriminatedType_DepthLimit` limit is hit when comparing a source object to a discriminated-union target type with more than 25 constituent types.
640
+ * When this occurs, the type checker will just return `false` for the type comparison to avoid excessive computation.
641
+ *
642
+ * This is not currently considered a hard error by the compiler and therefore
643
+ does not report to the user (unless you're a TypeSlayer user 😉).
644
+ */
645
+ export const event_checktypes__typeRelatedToDiscriminatedType_DepthLimit = z
646
+ .object({
647
+ ...eventCommon,
648
+ ...category.checkTypes,
649
+ ...instantEvent,
650
+ name: z.literal("typeRelatedToDiscriminatedType_DepthLimit"),
651
+ s: z.union([
652
+ z.literal(instantScope.global),
653
+ z.literal(instantScope.thread),
654
+ z.literal(instantScope.process),
655
+ ]),
656
+ args: z.object({
657
+ sourceId: typeId,
658
+ targetId: typeId,
659
+ numCombinations: z.number().int().positive(),
660
+ }),
661
+ })
662
+ .strict();
663
+
664
+ export type EventChecktypes__TypeRelatedToDiscriminatedType_DepthLimit =
665
+ z.infer<typeof event_checktypes__typeRelatedToDiscriminatedType_DepthLimit>;
666
+
667
+ export const depthLimits = [
668
+ event_checktypes__checkCrossProductUnion_DepthLimit,
669
+ event_checktypes__checkTypeRelatedTo_DepthLimit,
670
+ event_checktypes__getTypeAtFlowNode_DepthLimit,
671
+ event_checktypes__instantiateType_DepthLimit,
672
+ event_checktypes__recursiveTypeRelatedTo_DepthLimit,
673
+ event_checktypes__removeSubtypes_DepthLimit,
674
+ event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit,
675
+ event_checktypes__typeRelatedToDiscriminatedType_DepthLimit,
676
+ ];
677
+
678
+ export type DepthLimitNames =
679
+ | EventChecktypes__CheckCrossProductUnion_DepthLimit["name"]
680
+ | EventChecktypes__CheckTypeRelatedTo_DepthLimit["name"]
681
+ | EventChecktypes__GetTypeAtFlowNode_DepthLimit["name"]
682
+ | EventChecktypes__InstantiateType_DepthLimit["name"]
683
+ | EventChecktypes__RecursiveTypeRelatedTo_DepthLimit["name"]
684
+ | EventChecktypes__RemoveSubtypes_DepthLimit["name"]
685
+ | EventChecktypes__TraceUnionsOrIntersectionsTooLarge_DepthLimit["name"]
686
+ | EventChecktypes__TypeRelatedToDiscriminatedType_DepthLimit["name"];
687
+
688
+ /*
689
+ * EMIT PHASE EVENTS
690
+ */
691
+
692
+ const event_emit__emit = z
693
+ .object({
694
+ ...eventCommon,
695
+ ...category.emit,
696
+ ...durationEvent,
697
+ name: z.literal("emit"),
698
+ args: z.object({}), // for some reason, this is empty
699
+ })
700
+ .strict();
701
+
702
+ const event_emit__emitBuildInfo = z
703
+ .object({
704
+ ...eventCommon,
705
+ ...category.emit,
706
+ ph: z.union([
707
+ z.literal(eventPhase.begin),
708
+ z.literal(eventPhase.end),
709
+ z.literal(eventPhase.complete),
710
+ ]),
711
+ dur: z.number().positive().optional(),
712
+ name: z.literal("emitBuildInfo"),
713
+ args: z.union([
714
+ z.object({}),
715
+ z.object({
716
+ buildInfoPath: absolutePath,
717
+ }),
718
+ ]),
719
+ })
720
+ .strict();
721
+
722
+ const event_emit__emitDeclarationFileOrBundle = z
723
+ .object({
724
+ ...eventCommon,
725
+ ...category.emit,
726
+ ...completeEvent,
727
+ name: z.literal("emitDeclarationFileOrBundle"),
728
+ dur: z.number(),
729
+ args: z.object({
730
+ declarationFilePath: absolutePath,
731
+ }),
732
+ })
733
+ .strict();
734
+
735
+ const event_emit__emitJsFileOrBundle = z
736
+ .object({
737
+ ...eventCommon,
738
+ ...category.emit,
739
+ ...completeEvent,
740
+ name: z.literal("emitJsFileOrBundle"),
741
+ dur: z.number(),
742
+ args: z.object({
743
+ jsFilePath: absolutePath,
744
+ }),
745
+ })
746
+ .strict();
747
+
748
+ const event_emit__transformNodes = z
749
+ .object({
750
+ ...eventCommon,
751
+ ...category.emit,
752
+ ...completeEvent,
753
+ name: z.literal("transformNodes"),
754
+ args: z.object({
755
+ path: absolutePath,
756
+ }),
757
+ })
758
+ .strict();
759
+
760
+ /*
761
+ * SESSION PHASE EVENTS
762
+ */
763
+
764
+ const event_session__cancellationThrown = z
765
+ .object({
766
+ ...eventCommon,
767
+ ...category.session,
768
+ ...instantEvent,
769
+ name: z.literal("cancellationThrown"),
770
+ args: z.object({
771
+ kind: z.union([
772
+ z.literal("CancellationTokenObject"),
773
+ z.literal("ThrotledCancellationToken"),
774
+ ]),
775
+ }),
776
+ })
777
+ .strict();
778
+
779
+ const event_session__commandCanceled = z
780
+ .object({
781
+ ...eventCommon,
782
+ ...category.session,
783
+ ...instantEvent,
784
+ name: z.literal("commandCanceled"),
785
+ args: z.object({
786
+ seq: z.number().int().nonnegative(),
787
+ command: z.string(),
788
+ }),
789
+ })
790
+ .strict();
791
+
792
+ const event_session__commandError = z
793
+ .object({
794
+ ...eventCommon,
795
+ ...category.session,
796
+ ...instantEvent,
797
+ name: z.literal("commandError"),
798
+ args: z.object({
799
+ seq: z.number().int().nonnegative(),
800
+ command: z.string(),
801
+ message: z.string(),
802
+ }),
803
+ })
804
+ .strict();
805
+
806
+ const event_session__createConfiguredProject = z
807
+ .object({
808
+ ...eventCommon,
809
+ ...category.session,
810
+ ...instantEvent,
811
+ name: z.literal("createConfiguredProject"),
812
+ args: z.object({
813
+ configFilePath: absolutePath,
814
+ }),
815
+ })
816
+ .strict();
817
+
818
+ const event_session__createdDocumentRegistryBucket = z
819
+ .object({
820
+ ...eventCommon,
821
+ ...category.session,
822
+ ...instantEvent,
823
+ name: z.literal("createdDocumentRegistryBucket"),
824
+ args: z.object({
825
+ configFilePath: absolutePath,
826
+ key: z.string(),
827
+ }),
828
+ })
829
+ .strict();
830
+
831
+ const event_session__documentRegistryBucketOverlap = z
832
+ .object({
833
+ ...eventCommon,
834
+ ...category.session,
835
+ ...instantEvent,
836
+ name: z.literal("documentRegistryBucketOverlap"),
837
+ args: z.object({
838
+ path: absolutePath,
839
+ key1: z.string(),
840
+ key2: z.string(),
841
+ }),
842
+ })
843
+ .strict();
844
+
845
+ const event_session__executeCommand = z
846
+ .object({
847
+ ...eventCommon,
848
+ ...category.session,
849
+ ...durationEvent,
850
+ name: z.literal("executeCommand"),
851
+ args: z.object({
852
+ seq: z.number().int().nonnegative(),
853
+ command: z.string(),
854
+ }),
855
+ })
856
+ .strict();
857
+
858
+ const event_session__finishCachingPerDirectoryResolution = z
859
+ .object({
860
+ ...eventCommon,
861
+ ...category.session,
862
+ ...instantEvent,
863
+ name: z.literal("finishCachingPerDirectoryResolution"),
864
+ s: z.union([
865
+ z.literal(instantScope.global),
866
+ z.literal(instantScope.thread),
867
+ z.literal(instantScope.process),
868
+ ]),
869
+ })
870
+ .strict();
871
+
872
+ const event_session__getPackageJsonAutoImportProvider = z
873
+ .object({
874
+ ...eventCommon,
875
+ ...category.session,
876
+ ...completeEvent,
877
+ name: z.literal("getPackageJsonAutoImportProvider"),
878
+ })
879
+ .strict();
880
+
881
+ const event_session__getUnresolvedImports = z
882
+ .object({
883
+ ...eventCommon,
884
+ ...category.session,
885
+ ...completeEvent,
886
+ name: z.literal("getUnresolvedImports"),
887
+ args: z.object({
888
+ count: z.number().int().nonnegative(),
889
+ }),
890
+ })
891
+ .strict();
892
+
893
+ const event_session__loadConfiguredProject = z
894
+ .object({
895
+ ...eventCommon,
896
+ ...category.session,
897
+ ...durationEvent,
898
+ name: z.literal("loadConfiguredProject"),
899
+ args: z.object({
900
+ configFilePath: absolutePath,
901
+ }),
902
+ })
903
+ .strict();
904
+
905
+ const event_session__regionSemanticCheck = z
906
+ .object({
907
+ ...eventCommon,
908
+ ...category.session,
909
+ ...durationEvent,
910
+ name: z.literal("regionSemanticCheck"),
911
+ args: z.object({
912
+ file: absolutePath,
913
+ configFilePath: absolutePath,
914
+ }),
915
+ })
916
+ .strict();
917
+
918
+ const event_session__request = z
919
+ .object({
920
+ ...eventCommon,
921
+ ...category.session,
922
+ ...instantEvent,
923
+ name: z.literal("request"),
924
+ args: z.object({
925
+ seq: z.number().int().nonnegative(),
926
+ command: z.string(),
927
+ }),
928
+ })
929
+ .strict();
930
+
931
+ const event_session__response = z
932
+ .object({
933
+ ...eventCommon,
934
+ ...category.session,
935
+ ...instantEvent,
936
+ name: z.literal("response"),
937
+ args: z.object({
938
+ seq: z.number().int().nonnegative(),
939
+ command: z.string(),
940
+ success: z.boolean(),
941
+ }),
942
+ })
943
+ .strict();
944
+
945
+ const event_session__semanticCheck = z
946
+ .object({
947
+ ...eventCommon,
948
+ ...category.session,
949
+ ...durationEvent,
950
+ name: z.literal("semanticCheck"),
951
+ args: z.object({
952
+ file: absolutePath,
953
+ configFilePath: absolutePath,
954
+ }),
955
+ })
956
+ .strict();
957
+
958
+ const event_session__stepAction = z
959
+ .object({
960
+ ...eventCommon,
961
+ ...category.session,
962
+ ...instantEvent,
963
+ name: z.literal("stepAction"),
964
+ s: z.union([
965
+ z.literal(instantScope.global),
966
+ z.literal(instantScope.thread),
967
+ z.literal(instantScope.process),
968
+ ]),
969
+ args: z.object({
970
+ seq: z.number().int().nonnegative(),
971
+ }),
972
+ })
973
+ .strict();
974
+
975
+ const event_session__stepCanceled = z
976
+ .object({
977
+ ...eventCommon,
978
+ ...category.session,
979
+ ...instantEvent,
980
+ name: z.literal("stepCanceled"),
981
+ args: z.object({
982
+ seq: z.number().int().nonnegative(),
983
+ early: z.literal(true).optional(),
984
+ }),
985
+ })
986
+ .strict();
987
+
988
+ const event_session__stepError = z
989
+ .object({
990
+ ...eventCommon,
991
+ ...category.session,
992
+ ...instantEvent,
993
+ name: z.literal("stepError"),
994
+ args: z.object({
995
+ seq: z.number().int().nonnegative(),
996
+ message: z.string(),
997
+ }),
998
+ })
999
+ .strict();
1000
+
1001
+ const event_session__suggestionCheck = z
1002
+ .object({
1003
+ ...eventCommon,
1004
+ ...category.session,
1005
+ ...durationEvent,
1006
+ name: z.literal("suggestionCheck"),
1007
+ args: z.object({
1008
+ file: absolutePath,
1009
+ configFilePath: absolutePath,
1010
+ }),
1011
+ })
1012
+ .strict();
1013
+
1014
+ const event_session__syntacticCheck = z
1015
+ .object({
1016
+ ...eventCommon,
1017
+ ...category.session,
1018
+ ...durationEvent,
1019
+ name: z.literal("syntacticCheck"),
1020
+ args: z.object({
1021
+ file: absolutePath,
1022
+ configFilePath: absolutePath,
1023
+ }),
1024
+ })
1025
+ .strict();
1026
+
1027
+ const event_session__updateGraph = z
1028
+ .object({
1029
+ ...eventCommon,
1030
+ ...category.session,
1031
+ ...durationEvent,
1032
+ name: z.literal("updateGraph"),
1033
+ args: z.object({
1034
+ name: z.string(),
1035
+ kind: z.union([
1036
+ z.literal(0), //"Inferred
1037
+ z.literal(1), // Configured"
1038
+ z.literal(2), // "Inferred"
1039
+ z.literal(3), // "External"
1040
+ z.literal(4), // "AutoImportProvider"
1041
+ z.literal(5), // "Auxiliary"
1042
+ ]),
1043
+ }),
1044
+ })
1045
+ .strict();
1046
+
1047
+ /*
1048
+ * TRACE EVENT UNION
1049
+ */
1050
+
1051
+ export const traceEvent = z.discriminatedUnion(
1052
+ "name",
1053
+ [
1054
+ event_metadata__TracingStartedInBrowser,
1055
+ event_metadata__process_name,
1056
+ event_metadata__thread_name,
1057
+
1058
+ event_parse__createSourceFile,
1059
+ event_parse__parseJsonSourceFileConfigFileContent,
1060
+
1061
+ event_program__createProgram,
1062
+ event_program__findSourceFile,
1063
+ event_program__processRootFiles,
1064
+ event_program__processTypeReferenceDirective,
1065
+ event_program__processTypeReferences,
1066
+ event_program__resolveLibrary,
1067
+ event_program__resolveModuleNamesWorker,
1068
+ event_program__resolveTypeReferenceDirectiveNamesWorker,
1069
+ event_program__shouldProgramCreateNewSourceFiles,
1070
+ event_program__tryReuseStructureFromOldProgram,
1071
+
1072
+ event_bind__bindSourceFile,
1073
+
1074
+ event_check__checkExpression,
1075
+ event_check__checkSourceFile,
1076
+ event_check__checkVariableDeclaration,
1077
+ event_check__checkDeferredNode,
1078
+ event_check__checkSourceFileNodes,
1079
+
1080
+ event_checktypes__checkTypeParameterDeferred,
1081
+ event_checktypes__getVariancesWorker,
1082
+ event_checktypes__structuredTypeRelatedTo,
1083
+
1084
+ ...depthLimits,
1085
+
1086
+ event_emit__emit,
1087
+ event_emit__emitBuildInfo,
1088
+ event_emit__emitDeclarationFileOrBundle,
1089
+ event_emit__emitJsFileOrBundle,
1090
+ event_emit__transformNodes,
1091
+
1092
+ event_session__cancellationThrown,
1093
+ event_session__commandCanceled,
1094
+ event_session__commandError,
1095
+ event_session__createConfiguredProject,
1096
+ event_session__createdDocumentRegistryBucket,
1097
+ event_session__documentRegistryBucketOverlap,
1098
+ event_session__executeCommand,
1099
+ event_session__finishCachingPerDirectoryResolution,
1100
+ event_session__getPackageJsonAutoImportProvider,
1101
+ event_session__getUnresolvedImports,
1102
+ event_session__loadConfiguredProject,
1103
+ event_session__regionSemanticCheck,
1104
+ event_session__request,
1105
+ event_session__response,
1106
+ event_session__semanticCheck,
1107
+ event_session__stepAction,
1108
+ event_session__stepCanceled,
1109
+ event_session__stepError,
1110
+ event_session__suggestionCheck,
1111
+ event_session__syntacticCheck,
1112
+ event_session__updateGraph,
1113
+ ],
1114
+ {
1115
+ // errorMap: (issue, ctx) => ({
1116
+ // // prettier-ignore
1117
+ // message: issue.code === "invalid_union_discriminator" ?
1118
+ // `Invalid discriminator value. Expected ${issue.options.map(opt => `'${String(opt)}'`).join(' | ')}, got '${ctx.data.type}'.`
1119
+ // : ctx.defaultError,
1120
+ // }),
1121
+ },
1122
+ );
1123
+
1124
+ export type TraceEvent = z.infer<typeof traceEvent>;
1125
+ export const traceJsonSchema = z.array(traceEvent);
1126
+ export type TraceJsonSchema = z.infer<typeof traceJsonSchema>;