1
1
import { lazy , Suspense } from "react"
2
-
3
2
import { stringify } from "yaml"
4
- import { match , P } from "ts-pattern"
5
3
6
4
import { tryJsonPrettyPrint } from "../../helpers"
7
5
import { type PdlBlock } from "../../pdl_ast"
@@ -52,23 +50,20 @@ export default function Code({
52
50
}
53
51
54
52
function block_code_cleanup ( data : string | PdlBlock ) : string | PdlBlock {
55
- if (
56
- data === null ||
57
- typeof data === "boolean" ||
58
- typeof data === "number" ||
59
- typeof data === "string"
60
- ) {
53
+ if ( data === null || typeof data !== "object" ) {
61
54
return data
62
55
}
63
56
// remove pdl__result
64
- const new_data = { ...data , pdl__result : undefined , pdl__is_leaf : undefined }
65
- // remove trace
66
- match ( new_data ) . with ( { pdl__trace : P . _ } , ( data ) => {
67
- delete data . pdl__trace
68
- } )
69
- // remove other trace artifacts
70
- delete new_data . pdl__id
71
- delete new_data . pdl__timing
57
+ const new_data = {
58
+ ...data ,
59
+ pdl__result : undefined ,
60
+ pdl__is_leaf : undefined ,
61
+ pdl__usage : undefined ,
62
+ pdl__trace : undefined ,
63
+ pdl__id : undefined ,
64
+ pdl__timing : undefined ,
65
+ pdl__location : undefined ,
66
+ }
72
67
// remove contribute: ["result", context]
73
68
if (
74
69
new_data ?. contribute ?. includes ( "result" ) &&
@@ -80,8 +75,6 @@ function block_code_cleanup(data: string | PdlBlock): string | PdlBlock {
80
75
if ( Object . keys ( data ?. defs ?? { } ) . length === 0 ) {
81
76
delete new_data . defs
82
77
}
83
- // remove location info
84
- delete new_data . pdl__location
85
78
// recursive cleanup
86
79
return map_block_children ( block_code_cleanup , new_data )
87
80
}
0 commit comments