[{"data":1,"prerenderedAt":3045},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fast":3},{"id":4,"title":5,"body":6,"description":3026,"extension":3027,"frontmatter":3028,"heading":5,"meta":3035,"navigation":3037,"order":3031,"path":3038,"seo":3039,"sitemap":3040,"source":3041,"stem":3042,"__hash__":3043,"hasPopups":3044},"docs\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fast.md","AST and node builders",{"type":7,"value":8,"toc":2997},"minimark",[9,16,42,222,250,257,261,271,276,389,393,547,551,689,693,704,825,829,868,874,1226,1232,1238,1254,1670,1678,1682,1689,2205,2209,2239,2313,2367,2371,2384,2430,2434,2460,2463,2472,2514,2530,2589,2593,2612,2762,2771,2775,2778,2803,2841,2854,2858,2880,2959],[10,11,13],"h2",{"id":12},"ast",[14,15,12],"code",{},[17,18,19,21,22,25,26,29,30,33,34,37,38,41],"p",{},[14,20,12],{}," is ",[14,23,24],{},"kubb\u002Fkit","'s namespace for the entire AST surface, the same way TypeScript groups its node constructors under ",[14,27,28],{},"ts.factory",". It carries the ",[14,31,32],{},"factory"," node builders, the ",[14,35,36],{},"transform"," and ",[14,39,40],{},"collect"," visitors, the guards, the ref and string helpers, and the macro engine.",[43,44,50],"pre",{"language":45,"meta":46,"code":47,"filename":48,"class":49},"typescript","twoslash","import { ast } from 'kubb\u002Fkit'\n\nconst root = ast.factory.createInput({\n  schemas: [ast.factory.createSchema({ name: 'Pet', type: 'object', properties: [] })],\n  operations: [],\n})","ast-namespace.ts","shiki shiki-themes github-light github-dark twoslash lsp dark:github-dark",[14,51,53,82,83,82,85,82,130,82,204,82,217],{"class":52},"language-typescript",[54,55,58,62,66,72,75,78],"span",{"class":56,"style":57},"line","display: inline",[54,59,61],{"style":60},"color:#D73A49;--shiki-dark:#F97583","import",[54,63,65],{"style":64},"color:#24292E;--shiki-dark:#E1E4E8"," { ",[54,67,68],{"style":64},[54,69,12],{"class":70,"data-popup":71},"twoslash-hover","0",[54,73,74],{"style":64}," } ",[54,76,77],{"style":60},"from",[54,79,81],{"style":80},"color:#032F62;--shiki-dark:#9ECBFF"," 'kubb\u002Fkit'","\n",[54,84],{"class":56,"style":57},[54,86,87,90,94,100,103,105,110,113,118,120,127],{"class":56,"style":57},[54,88,89],{"style":60},"const",[54,91,93],{"style":92},"color:#005CC5;--shiki-dark:#79B8FF"," ",[54,95,96],{"style":92},[54,97,99],{"class":70,"data-popup":98},"1","root",[54,101,102],{"style":60}," =",[54,104,93],{"style":64},[54,106,107],{"style":64},[54,108,12],{"class":70,"data-popup":109},"2",[54,111,112],{"style":64},".",[54,114,115],{"style":64},[54,116,32],{"class":70,"data-popup":117},"3",[54,119,112],{"style":64},[54,121,123],{"style":122},"color:#6F42C1;--shiki-dark:#B392F0",[54,124,126],{"class":70,"data-popup":125},"4","createInput",[54,128,129],{"style":64},"({",[54,131,132,135,141,144,149,151,156,158,164,167,173,176,179,182,188,190,193,195,201],{"class":56,"style":57},[54,133,134],{"style":64},"  ",[54,136,137],{"style":64},[54,138,140],{"class":70,"data-popup":139},"5","schemas",[54,142,143],{"style":64},": [",[54,145,146],{"style":64},[54,147,12],{"class":70,"data-popup":148},"6",[54,150,112],{"style":64},[54,152,153],{"style":64},[54,154,32],{"class":70,"data-popup":155},"7",[54,157,112],{"style":64},[54,159,160],{"style":122},[54,161,163],{"class":70,"data-popup":162},"8","createSchema",[54,165,166],{"style":64},"({ ",[54,168,169],{"style":64},[54,170,172],{"class":70,"data-popup":171},"9","name",[54,174,175],{"style":64},": ",[54,177,178],{"style":80},"'Pet'",[54,180,181],{"style":64},", ",[54,183,184],{"style":64},[54,185,187],{"class":70,"data-popup":186},"10","type",[54,189,175],{"style":64},[54,191,192],{"style":80},"'object'",[54,194,181],{"style":64},[54,196,197],{"style":64},[54,198,200],{"class":70,"data-popup":199},"11","properties",[54,202,203],{"style":64},": [] })],",[54,205,206,208,214],{"class":56,"style":57},[54,207,134],{"style":64},[54,209,210],{"style":64},[54,211,213],{"class":70,"data-popup":212},"12","operations",[54,215,216],{"style":64},": [],",[54,218,219],{"class":56,"style":57},[54,220,221],{"style":64},"})",[17,223,224,225,228,229,181,232,235,236,239,240,243,244,249],{},"Node building goes through ",[14,226,227],{},"ast.factory",". ",[14,230,231],{},"ast.factory.createFile",[14,233,234],{},"ast.factory.createSource",", and ",[14,237,238],{},"ast.factory.createText"," build the ",[14,241,242],{},"FileNode"," tree a generator returns. See the ",[245,246,248],"a",{"href":247},"#factory-functions","factory table"," below.",[17,251,252,253,112],{},"For why the AST exists and how it fits the pipeline, see ",[245,254,256],{"href":255},"\u002Fdocs\u002F5.x\u002Fexplanation\u002Farchitecture#ast","AST concepts",[10,258,260],{"id":259},"schema-node-types","Schema node types",[17,262,263,264,267,268,270],{},"A ",[14,265,266],{},"SchemaNode"," is discriminated by its ",[14,269,187],{},". The values fall into three families.",[272,273,275],"h3",{"id":274},"structural-types","Structural types",[277,278,279,295],"table",{},[280,281,282],"thead",{},[283,284,285,289,292],"tr",{},[286,287,288],"th",{},"Type",[286,290,291],{},"Description",[286,293,294],{},"TypeScript",[296,297,298,314,329,344,359,374],"tbody",{},[283,299,300,306,309],{},[301,302,303],"td",{},[14,304,305],{},"object",[301,307,308],{},"Object with named properties",[301,310,311],{},[14,312,313],{},"{ name: string; age: number }",[283,315,316,321,324],{},[301,317,318],{},[14,319,320],{},"array",[301,322,323],{},"Sequence of items",[301,325,326],{},[14,327,328],{},"string[]",[283,330,331,336,339],{},[301,332,333],{},[14,334,335],{},"tuple",[301,337,338],{},"Fixed-length array with typed positions",[301,340,341],{},[14,342,343],{},"[string, number, boolean]",[283,345,346,351,354],{},[301,347,348],{},[14,349,350],{},"union",[301,352,353],{},"One of multiple types",[301,355,356],{},[14,357,358],{},"string | number",[283,360,361,366,369],{},[301,362,363],{},[14,364,365],{},"intersection",[301,367,368],{},"Combination of multiple types",[301,370,371],{},[14,372,373],{},"A & B",[283,375,376,381,384],{},[301,377,378],{},[14,379,380],{},"enum",[301,382,383],{},"Fixed set of literal values",[301,385,386],{},[14,387,388],{},"'active' | 'inactive'",[272,390,392],{"id":391},"scalar-types","Scalar types",[277,394,395,405],{},[280,396,397],{},[283,398,399,401,403],{},[286,400,288],{},[286,402,291],{},[286,404,294],{},[296,406,407,421,435,449,463,477,491,505,519,533],{},[283,408,409,414,417],{},[301,410,411],{},[14,412,413],{},"string",[301,415,416],{},"Text value",[301,418,419],{},[14,420,413],{},[283,422,423,428,431],{},[301,424,425],{},[14,426,427],{},"number",[301,429,430],{},"Numeric value",[301,432,433],{},[14,434,427],{},[283,436,437,442,445],{},[301,438,439],{},[14,440,441],{},"integer",[301,443,444],{},"Whole number",[301,446,447],{},[14,448,427],{},[283,450,451,456,459],{},[301,452,453],{},[14,454,455],{},"bigint",[301,457,458],{},"Large integer",[301,460,461],{},[14,462,455],{},[283,464,465,470,473],{},[301,466,467],{},[14,468,469],{},"boolean",[301,471,472],{},"True\u002Ffalse",[301,474,475],{},[14,476,469],{},[283,478,479,484,487],{},[301,480,481],{},[14,482,483],{},"null",[301,485,486],{},"Null value",[301,488,489],{},[14,490,483],{},[283,492,493,498,501],{},[301,494,495],{},[14,496,497],{},"any",[301,499,500],{},"Any value",[301,502,503],{},[14,504,497],{},[283,506,507,512,515],{},[301,508,509],{},[14,510,511],{},"unknown",[301,513,514],{},"Unknown value",[301,516,517],{},[14,518,511],{},[283,520,521,526,529],{},[301,522,523],{},[14,524,525],{},"void",[301,527,528],{},"No value",[301,530,531],{},[14,532,525],{},[283,534,535,540,543],{},[301,536,537],{},[14,538,539],{},"never",[301,541,542],{},"Never produced",[301,544,545],{},[14,546,539],{},[272,548,550],{"id":549},"special-types","Special types",[277,552,553,564],{},[280,554,555],{},[283,556,557,559,561],{},[286,558,288],{},[286,560,291],{},[286,562,563],{},"Example",[296,565,566,586,601,616,631,646,661,676],{},[283,567,568,573,576],{},[301,569,570],{},[14,571,572],{},"ref",[301,574,575],{},"Reference to another schema",[301,577,578,581,582,585],{},[14,579,580],{},"Pet"," (from ",[14,583,584],{},"$ref",")",[283,587,588,593,596],{},[301,589,590],{},[14,591,592],{},"date",[301,594,595],{},"ISO date",[301,597,598],{},[14,599,600],{},"2024-01-15",[283,602,603,608,611],{},[301,604,605],{},[14,606,607],{},"datetime",[301,609,610],{},"ISO datetime",[301,612,613],{},[14,614,615],{},"2024-01-15T10:30:00Z",[283,617,618,623,626],{},[301,619,620],{},[14,621,622],{},"time",[301,624,625],{},"ISO time",[301,627,628],{},[14,629,630],{},"10:30:00",[283,632,633,638,641],{},[301,634,635],{},[14,636,637],{},"uuid",[301,639,640],{},"UUID string",[301,642,643],{},[14,644,645],{},"550e8400-e29b-41d4-a716-446655440000",[283,647,648,653,656],{},[301,649,650],{},[14,651,652],{},"email",[301,654,655],{},"Email address",[301,657,658],{},[14,659,660],{},"user@example.com",[283,662,663,668,671],{},[301,664,665],{},[14,666,667],{},"url",[301,669,670],{},"URL string",[301,672,673],{},[14,674,675],{},"https:\u002F\u002Fexample.com",[283,677,678,683,686],{},[301,679,680],{},[14,681,682],{},"blob",[301,684,685],{},"Binary data",[301,687,688],{},"Raw bytes",[10,690,692],{"id":691},"factory-functions","Factory functions",[17,694,695,696,181,698,235,700,703],{},"Factories return defaulted, fully typed nodes for adapters and generator handlers. Never build AST literals by hand. Besides ",[14,697,126],{},[14,699,163],{},[14,701,702],{},"createOperation",", the namespace provides constructors for source files and the TypeScript-level artifacts generators emit:",[277,705,706,716],{},[280,707,708],{},[283,709,710,713],{},[286,711,712],{},"Factory",[286,714,715],{},"Purpose",[296,717,718,737,757,776,786,799,815],{},[283,719,720,731],{},[301,721,722,181,725,181,728],{},[14,723,724],{},"createFile",[14,726,727],{},"createSource",[14,729,730],{},"createText",[301,732,733,734,736],{},"Build ",[14,735,242],{},"s emitted by generators.",[283,738,739,747],{},[301,740,741,181,744],{},[14,742,743],{},"createImport",[14,745,746],{},"createExport",[301,748,749,750,752,753,756],{},"Emit ",[14,751,61],{}," \u002F ",[14,754,755],{},"export"," statements.",[283,758,759,773],{},[301,760,761,181,764,181,767,181,770],{},[14,762,763],{},"createConst",[14,765,766],{},"createFunction",[14,768,769],{},"createArrowFunction",[14,771,772],{},"createJsx",[301,774,775],{},"Emit TypeScript declarations and JSX.",[283,777,778,783],{},[301,779,780],{},[14,781,782],{},"createParameter",[301,784,785],{},"Describe operation parameters.",[283,787,788,796],{},[301,789,790,181,793],{},[14,791,792],{},"createProperty",[14,794,795],{},"createType",[301,797,798],{},"Compose object properties and TypeScript types.",[283,800,801,812],{},[301,802,803,181,806,181,809],{},[14,804,805],{},"createResponse",[14,807,808],{},"createRequestBody",[14,810,811],{},"createContent",[301,813,814],{},"Model responses, request bodies, and content entries.",[283,816,817,822],{},[301,818,819],{},[14,820,821],{},"createBreak",[301,823,824],{},"Emit line breaks between nodes.",[10,826,828],{"id":827},"visitors","Visitors",[17,830,831,832,834,835,837,838,181,841,181,844,181,847,181,850,181,853,856,857,861,862,864,865,867],{},"Two visitor functions cover the common traversal patterns: ",[14,833,36],{}," rewrites the tree and ",[14,836,40],{}," gathers nodes. Visitor objects use lowercase, kind-style keys (",[14,839,840],{},"input",[14,842,843],{},"operation",[14,845,846],{},"schema",[14,848,849],{},"property",[14,851,852],{},"parameter",[14,854,855],{},"response","). To rewrite nodes inside a plugin, reach for ",[245,858,860],{"href":859},"\u002Fdocs\u002F5.x\u002Fhow-to\u002Fmacros","macros",", which add names, ordering, and composition on top of ",[14,863,36],{},". For logging, validation, or statistics, ",[14,866,40],{}," the nodes you care about.",[272,869,871,873],{"id":870},"transform-synchronous-returns-a-new-tree",[14,872,36],{},": synchronous, returns a new tree",[43,875,878],{"language":45,"meta":46,"code":876,"filename":877,"class":49},"import { ast } from 'kubb\u002Fkit'\n\nconst root = ast.factory.createInput({ schemas: [], operations: [] })\n\nconst enhanced = ast.transform(root, {\n  schema(node) {\n    if (node.type === 'object' && node.additionalProperties === undefined) {\n      return { ...node, additionalProperties: false }\n    }\n    return node\n  },\n  operation(node) {\n    return { ...node, tags: node.tags?.length ? node.tags : ['untagged'] }\n  },\n})","transform.ts",[14,879,880,82,897,82,899,82,951,82,953,82,992,82,1013,82,1073,82,1103,82,1108,82,1120,82,1125,82,1143,82,1218,82,1222],{"class":52},[54,881,882,884,886,891,893,895],{"class":56,"style":57},[54,883,61],{"style":60},[54,885,65],{"style":64},[54,887,888],{"style":64},[54,889,12],{"class":70,"data-popup":890},"13",[54,892,74],{"style":64},[54,894,77],{"style":60},[54,896,81],{"style":80},[54,898],{"class":56,"style":57},[54,900,901,903,905,910,912,914,919,921,926,928,933,935,940,943,948],{"class":56,"style":57},[54,902,89],{"style":60},[54,904,93],{"style":92},[54,906,907],{"style":92},[54,908,99],{"class":70,"data-popup":909},"14",[54,911,102],{"style":60},[54,913,93],{"style":64},[54,915,916],{"style":64},[54,917,12],{"class":70,"data-popup":918},"15",[54,920,112],{"style":64},[54,922,923],{"style":64},[54,924,32],{"class":70,"data-popup":925},"16",[54,927,112],{"style":64},[54,929,930],{"style":122},[54,931,126],{"class":70,"data-popup":932},"17",[54,934,166],{"style":64},[54,936,937],{"style":64},[54,938,140],{"class":70,"data-popup":939},"18",[54,941,942],{"style":64},": [], ",[54,944,945],{"style":64},[54,946,213],{"class":70,"data-popup":947},"19",[54,949,950],{"style":64},": [] })",[54,952],{"class":56,"style":57},[54,954,955,957,959,965,967,969,974,976,981,984,989],{"class":56,"style":57},[54,956,89],{"style":60},[54,958,93],{"style":92},[54,960,961],{"style":92},[54,962,964],{"class":70,"data-popup":963},"20","enhanced",[54,966,102],{"style":60},[54,968,93],{"style":64},[54,970,971],{"style":64},[54,972,12],{"class":70,"data-popup":973},"21",[54,975,112],{"style":64},[54,977,978],{"style":122},[54,979,36],{"class":70,"data-popup":980},"22",[54,982,983],{"style":64},"(",[54,985,986],{"style":64},[54,987,99],{"class":70,"data-popup":988},"23",[54,990,991],{"style":64},", {",[54,993,994,996,1001,1003,1010],{"class":56,"style":57},[54,995,134],{"style":122},[54,997,998],{"style":122},[54,999,846],{"class":70,"data-popup":1000},"24",[54,1002,983],{"style":64},[54,1004,1006],{"style":1005},"color:#E36209;--shiki-dark:#FFAB70",[54,1007,1009],{"class":70,"data-popup":1008},"25","node",[54,1011,1012],{"style":64},") {",[54,1014,1015,1018,1021,1026,1028,1033,1035,1038,1041,1044,1046,1051,1053,1059,1061,1063,1065,1071],{"class":56,"style":57},[54,1016,1017],{"style":60},"    if",[54,1019,1020],{"style":64}," (",[54,1022,1023],{"style":64},[54,1024,1009],{"class":70,"data-popup":1025},"26",[54,1027,112],{"style":64},[54,1029,1030],{"style":64},[54,1031,187],{"class":70,"data-popup":1032},"27",[54,1034,93],{"style":64},[54,1036,1037],{"style":60},"===",[54,1039,1040],{"style":80}," 'object'",[54,1042,1043],{"style":60}," &&",[54,1045,93],{"style":64},[54,1047,1048],{"style":64},[54,1049,1009],{"class":70,"data-popup":1050},"28",[54,1052,112],{"style":64},[54,1054,1055],{"style":64},[54,1056,1058],{"class":70,"data-popup":1057},"29","additionalProperties",[54,1060,93],{"style":64},[54,1062,1037],{"style":60},[54,1064,93],{"style":92},[54,1066,1067],{"style":92},[54,1068,1070],{"class":70,"data-popup":1069},"30","undefined",[54,1072,1012],{"style":64},[54,1074,1075,1078,1080,1083,1088,1090,1095,1097,1100],{"class":56,"style":57},[54,1076,1077],{"style":60},"      return",[54,1079,65],{"style":64},[54,1081,1082],{"style":60},"...",[54,1084,1085],{"style":64},[54,1086,1009],{"class":70,"data-popup":1087},"31",[54,1089,181],{"style":64},[54,1091,1092],{"style":64},[54,1093,1058],{"class":70,"data-popup":1094},"32",[54,1096,175],{"style":64},[54,1098,1099],{"style":92},"false",[54,1101,1102],{"style":64}," }",[54,1104,1105],{"class":56,"style":57},[54,1106,1107],{"style":64},"    }",[54,1109,1110,1113,1115],{"class":56,"style":57},[54,1111,1112],{"style":60},"    return",[54,1114,93],{"style":64},[54,1116,1117],{"style":64},[54,1118,1009],{"class":70,"data-popup":1119},"33",[54,1121,1122],{"class":56,"style":57},[54,1123,1124],{"style":64},"  },",[54,1126,1127,1129,1134,1136,1141],{"class":56,"style":57},[54,1128,134],{"style":122},[54,1130,1131],{"style":122},[54,1132,843],{"class":70,"data-popup":1133},"34",[54,1135,983],{"style":64},[54,1137,1138],{"style":1005},[54,1139,1009],{"class":70,"data-popup":1140},"35",[54,1142,1012],{"style":64},[54,1144,1145,1147,1149,1151,1156,1158,1164,1166,1171,1173,1178,1181,1187,1190,1192,1197,1199,1204,1206,1209,1212,1215],{"class":56,"style":57},[54,1146,1112],{"style":60},[54,1148,65],{"style":64},[54,1150,1082],{"style":60},[54,1152,1153],{"style":64},[54,1154,1009],{"class":70,"data-popup":1155},"36",[54,1157,181],{"style":64},[54,1159,1160],{"style":64},[54,1161,1163],{"class":70,"data-popup":1162},"37","tags",[54,1165,175],{"style":64},[54,1167,1168],{"style":64},[54,1169,1009],{"class":70,"data-popup":1170},"38",[54,1172,112],{"style":64},[54,1174,1175],{"style":64},[54,1176,1163],{"class":70,"data-popup":1177},"39",[54,1179,1180],{"style":64},"?.",[54,1182,1183],{"style":92},[54,1184,1186],{"class":70,"data-popup":1185},"40","length",[54,1188,1189],{"style":60}," ?",[54,1191,93],{"style":64},[54,1193,1194],{"style":64},[54,1195,1009],{"class":70,"data-popup":1196},"41",[54,1198,112],{"style":64},[54,1200,1201],{"style":64},[54,1202,1163],{"class":70,"data-popup":1203},"42",[54,1205,93],{"style":64},[54,1207,1208],{"style":60},":",[54,1210,1211],{"style":64}," [",[54,1213,1214],{"style":80},"'untagged'",[54,1216,1217],{"style":64},"] }",[54,1219,1220],{"class":56,"style":57},[54,1221,1124],{"style":64},[54,1223,1224],{"class":56,"style":57},[54,1225,221],{"style":64},[17,1227,1228,1229,1231],{},"Use ",[14,1230,36],{}," to change AST structure, normalize inconsistencies, or annotate nodes.",[272,1233,1235,1237],{"id":1234},"collect-gather-matching-nodes",[14,1236,40],{},": gather matching nodes",[17,1239,1240,1242,1243,1246,1247,1250,1251,112],{},[14,1241,40],{}," is a generator function, so it yields matches lazily and you consume it with ",[14,1244,1245],{},"for...of"," or spread it into an array. When you want the array up front, call ",[14,1248,1249],{},"collectSync",", which is the eager counterpart and returns ",[14,1252,1253],{},"Array\u003CT>",[43,1255,1258],{"language":45,"meta":46,"code":1256,"filename":1257,"class":49},"import { ast } from 'kubb\u002Fkit'\n\nconst root = ast.factory.createInput({ schemas: [], operations: [] })\n\nconst mutations = ast.collectSync\u003Cast.OperationNode>(root, {\n  operation(node) {\n    return node.method === 'POST' ? node : undefined\n  },\n})\n\nconst deprecated = ast.collectSync\u003Cast.SchemaNode>(root, {\n  schema(node) {\n    return 'deprecated' in node && node.deprecated ? node : undefined\n  },\n})\n\nconsole.log(`POST operations: ${mutations.length}`)\nconsole.log(`Deprecated schemas: ${deprecated.length}`)","collect.ts",[14,1259,1260,82,1277,82,1279,82,1329,82,1331,82,1385,82,1403,82,1449,82,1453,82,1457,82,1459,82,1510,82,1528,82,1587,82,1591,82,1595,82,1597,82,1635],{"class":52},[54,1261,1262,1264,1266,1271,1273,1275],{"class":56,"style":57},[54,1263,61],{"style":60},[54,1265,65],{"style":64},[54,1267,1268],{"style":64},[54,1269,12],{"class":70,"data-popup":1270},"43",[54,1272,74],{"style":64},[54,1274,77],{"style":60},[54,1276,81],{"style":80},[54,1278],{"class":56,"style":57},[54,1280,1281,1283,1285,1290,1292,1294,1299,1301,1306,1308,1313,1315,1320,1322,1327],{"class":56,"style":57},[54,1282,89],{"style":60},[54,1284,93],{"style":92},[54,1286,1287],{"style":92},[54,1288,99],{"class":70,"data-popup":1289},"44",[54,1291,102],{"style":60},[54,1293,93],{"style":64},[54,1295,1296],{"style":64},[54,1297,12],{"class":70,"data-popup":1298},"45",[54,1300,112],{"style":64},[54,1302,1303],{"style":64},[54,1304,32],{"class":70,"data-popup":1305},"46",[54,1307,112],{"style":64},[54,1309,1310],{"style":122},[54,1311,126],{"class":70,"data-popup":1312},"47",[54,1314,166],{"style":64},[54,1316,1317],{"style":64},[54,1318,140],{"class":70,"data-popup":1319},"48",[54,1321,942],{"style":64},[54,1323,1324],{"style":64},[54,1325,213],{"class":70,"data-popup":1326},"49",[54,1328,950],{"style":64},[54,1330],{"class":56,"style":57},[54,1332,1333,1335,1337,1343,1345,1347,1352,1354,1359,1362,1367,1369,1375,1378,1383],{"class":56,"style":57},[54,1334,89],{"style":60},[54,1336,93],{"style":92},[54,1338,1339],{"style":92},[54,1340,1342],{"class":70,"data-popup":1341},"50","mutations",[54,1344,102],{"style":60},[54,1346,93],{"style":64},[54,1348,1349],{"style":64},[54,1350,12],{"class":70,"data-popup":1351},"51",[54,1353,112],{"style":64},[54,1355,1356],{"style":122},[54,1357,1249],{"class":70,"data-popup":1358},"52",[54,1360,1361],{"style":64},"\u003C",[54,1363,1364],{"style":122},[54,1365,12],{"class":70,"data-popup":1366},"53",[54,1368,112],{"style":64},[54,1370,1371],{"style":122},[54,1372,1374],{"class":70,"data-popup":1373},"54","OperationNode",[54,1376,1377],{"style":64},">(",[54,1379,1380],{"style":64},[54,1381,99],{"class":70,"data-popup":1382},"55",[54,1384,991],{"style":64},[54,1386,1387,1389,1394,1396,1401],{"class":56,"style":57},[54,1388,134],{"style":122},[54,1390,1391],{"style":122},[54,1392,843],{"class":70,"data-popup":1393},"56",[54,1395,983],{"style":64},[54,1397,1398],{"style":1005},[54,1399,1009],{"class":70,"data-popup":1400},"57",[54,1402,1012],{"style":64},[54,1404,1405,1407,1409,1414,1416,1422,1424,1426,1429,1431,1433,1438,1440,1442,1444],{"class":56,"style":57},[54,1406,1112],{"style":60},[54,1408,93],{"style":64},[54,1410,1411],{"style":64},[54,1412,1009],{"class":70,"data-popup":1413},"58",[54,1415,112],{"style":64},[54,1417,1418],{"style":64},[54,1419,1421],{"class":70,"data-popup":1420},"59","method",[54,1423,93],{"style":64},[54,1425,1037],{"style":60},[54,1427,1428],{"style":80}," 'POST'",[54,1430,1189],{"style":60},[54,1432,93],{"style":64},[54,1434,1435],{"style":64},[54,1436,1009],{"class":70,"data-popup":1437},"60",[54,1439,93],{"style":64},[54,1441,1208],{"style":60},[54,1443,93],{"style":92},[54,1445,1446],{"style":92},[54,1447,1070],{"class":70,"data-popup":1448},"61",[54,1450,1451],{"class":56,"style":57},[54,1452,1124],{"style":64},[54,1454,1455],{"class":56,"style":57},[54,1456,221],{"style":64},[54,1458],{"class":56,"style":57},[54,1460,1461,1463,1465,1471,1473,1475,1480,1482,1487,1489,1494,1496,1501,1503,1508],{"class":56,"style":57},[54,1462,89],{"style":60},[54,1464,93],{"style":92},[54,1466,1467],{"style":92},[54,1468,1470],{"class":70,"data-popup":1469},"62","deprecated",[54,1472,102],{"style":60},[54,1474,93],{"style":64},[54,1476,1477],{"style":64},[54,1478,12],{"class":70,"data-popup":1479},"63",[54,1481,112],{"style":64},[54,1483,1484],{"style":122},[54,1485,1249],{"class":70,"data-popup":1486},"64",[54,1488,1361],{"style":64},[54,1490,1491],{"style":122},[54,1492,12],{"class":70,"data-popup":1493},"65",[54,1495,112],{"style":64},[54,1497,1498],{"style":122},[54,1499,266],{"class":70,"data-popup":1500},"66",[54,1502,1377],{"style":64},[54,1504,1505],{"style":64},[54,1506,99],{"class":70,"data-popup":1507},"67",[54,1509,991],{"style":64},[54,1511,1512,1514,1519,1521,1526],{"class":56,"style":57},[54,1513,134],{"style":122},[54,1515,1516],{"style":122},[54,1517,846],{"class":70,"data-popup":1518},"68",[54,1520,983],{"style":64},[54,1522,1523],{"style":1005},[54,1524,1009],{"class":70,"data-popup":1525},"69",[54,1527,1012],{"style":64},[54,1529,1530,1532,1535,1538,1540,1545,1547,1550,1552,1557,1559,1564,1566,1569,1571,1576,1578,1580,1582],{"class":56,"style":57},[54,1531,1112],{"style":60},[54,1533,1534],{"style":80}," 'deprecated'",[54,1536,1537],{"style":60}," in",[54,1539,93],{"style":64},[54,1541,1542],{"style":64},[54,1543,1009],{"class":70,"data-popup":1544},"70",[54,1546,93],{"style":64},[54,1548,1549],{"style":60},"&&",[54,1551,93],{"style":64},[54,1553,1554],{"style":64},[54,1555,1009],{"class":70,"data-popup":1556},"71",[54,1558,112],{"style":64},[54,1560,1561],{"style":64},[54,1562,1470],{"class":70,"data-popup":1563},"72",[54,1565,93],{"style":64},[54,1567,1568],{"style":60},"?",[54,1570,93],{"style":64},[54,1572,1573],{"style":64},[54,1574,1009],{"class":70,"data-popup":1575},"73",[54,1577,93],{"style":64},[54,1579,1208],{"style":60},[54,1581,93],{"style":92},[54,1583,1584],{"style":92},[54,1585,1070],{"class":70,"data-popup":1586},"74",[54,1588,1589],{"class":56,"style":57},[54,1590,1124],{"style":64},[54,1592,1593],{"class":56,"style":57},[54,1594,221],{"style":64},[54,1596],{"class":56,"style":57},[54,1598,1599,1605,1607,1613,1615,1618,1623,1625,1630,1633],{"class":56,"style":57},[54,1600,1601],{"style":64},[54,1602,1604],{"class":70,"data-popup":1603},"75","console",[54,1606,112],{"style":64},[54,1608,1609],{"style":122},[54,1610,1612],{"class":70,"data-popup":1611},"76","log",[54,1614,983],{"style":64},[54,1616,1617],{"style":80},"`POST operations: ${",[54,1619,1620],{"style":64},[54,1621,1342],{"class":70,"data-popup":1622},"77",[54,1624,112],{"style":80},[54,1626,1627],{"style":92},[54,1628,1186],{"class":70,"data-popup":1629},"78",[54,1631,1632],{"style":80},"}`",[54,1634,585],{"style":64},[54,1636,1637,1642,1644,1649,1651,1654,1659,1661,1666,1668],{"class":56,"style":57},[54,1638,1639],{"style":64},[54,1640,1604],{"class":70,"data-popup":1641},"79",[54,1643,112],{"style":64},[54,1645,1646],{"style":122},[54,1647,1612],{"class":70,"data-popup":1648},"80",[54,1650,983],{"style":64},[54,1652,1653],{"style":80},"`Deprecated schemas: ${",[54,1655,1656],{"style":64},[54,1657,1470],{"class":70,"data-popup":1658},"81",[54,1660,112],{"style":80},[54,1662,1663],{"style":92},[54,1664,1186],{"class":70,"data-popup":1665},"82",[54,1667,1632],{"style":80},[54,1669,585],{"style":64},[17,1671,1228,1672,1674,1675,1677],{},[14,1673,40],{}," to stream matches as you find them, and ",[14,1676,1249],{}," to find specific nodes, filter by a criterion, or build a list for later processing.",[10,1679,1681],{"id":1680},"guards-and-narrowing","Guards and narrowing",[17,1683,1684,1685,1688],{},"Kubb exports type guards and a ",[14,1686,1687],{},"narrowSchema"," helper for safe discrimination:",[43,1690,1693],{"language":45,"meta":46,"code":1691,"filename":1692,"class":49},"import { ast } from 'kubb\u002Fkit'\n\nconst root = ast.factory.createInput({ schemas: [], operations: [] })\n\nfor (const node of ast.collect\u003Cast.SchemaNode>(root, { schema: (node) => node })) {\n  const obj = ast.narrowSchema(node, 'object')\n  if (obj) {\n    console.log(`object with ${obj.properties.length} properties`)\n  }\n\n  if (node.type === 'ref') {\n    console.log(`reference to: ${node.ref}`)\n  }\n}\n\nfor (const node of ast.collect\u003Cast.OperationNode>(root, { operation: (node) => node })) {\n  if (ast.isHttpOperationNode(node)) {\n    console.log(`${node.method} ${node.path}`)\n  }\n}","guards.ts",[14,1694,1695,82,1712,82,1714,82,1764,82,1766,82,1852,82,1894,82,1908,82,1954,82,1959,82,1961,82,1988,82,2025,82,2029,82,2034,82,2036,82,2115,82,2144,82,2197,82,2201],{"class":52},[54,1696,1697,1699,1701,1706,1708,1710],{"class":56,"style":57},[54,1698,61],{"style":60},[54,1700,65],{"style":64},[54,1702,1703],{"style":64},[54,1704,12],{"class":70,"data-popup":1705},"83",[54,1707,74],{"style":64},[54,1709,77],{"style":60},[54,1711,81],{"style":80},[54,1713],{"class":56,"style":57},[54,1715,1716,1718,1720,1725,1727,1729,1734,1736,1741,1743,1748,1750,1755,1757,1762],{"class":56,"style":57},[54,1717,89],{"style":60},[54,1719,93],{"style":92},[54,1721,1722],{"style":92},[54,1723,99],{"class":70,"data-popup":1724},"84",[54,1726,102],{"style":60},[54,1728,93],{"style":64},[54,1730,1731],{"style":64},[54,1732,12],{"class":70,"data-popup":1733},"85",[54,1735,112],{"style":64},[54,1737,1738],{"style":64},[54,1739,32],{"class":70,"data-popup":1740},"86",[54,1742,112],{"style":64},[54,1744,1745],{"style":122},[54,1746,126],{"class":70,"data-popup":1747},"87",[54,1749,166],{"style":64},[54,1751,1752],{"style":64},[54,1753,140],{"class":70,"data-popup":1754},"88",[54,1756,942],{"style":64},[54,1758,1759],{"style":64},[54,1760,213],{"class":70,"data-popup":1761},"89",[54,1763,950],{"style":64},[54,1765],{"class":56,"style":57},[54,1767,1768,1771,1773,1775,1777,1782,1785,1787,1792,1794,1799,1801,1806,1808,1813,1815,1820,1823,1828,1831,1836,1839,1842,1844,1849],{"class":56,"style":57},[54,1769,1770],{"style":60},"for",[54,1772,1020],{"style":64},[54,1774,89],{"style":60},[54,1776,93],{"style":92},[54,1778,1779],{"style":92},[54,1780,1009],{"class":70,"data-popup":1781},"90",[54,1783,1784],{"style":60}," of",[54,1786,93],{"style":64},[54,1788,1789],{"style":64},[54,1790,12],{"class":70,"data-popup":1791},"91",[54,1793,112],{"style":64},[54,1795,1796],{"style":122},[54,1797,40],{"class":70,"data-popup":1798},"92",[54,1800,1361],{"style":64},[54,1802,1803],{"style":122},[54,1804,12],{"class":70,"data-popup":1805},"93",[54,1807,112],{"style":64},[54,1809,1810],{"style":122},[54,1811,266],{"class":70,"data-popup":1812},"94",[54,1814,1377],{"style":64},[54,1816,1817],{"style":64},[54,1818,99],{"class":70,"data-popup":1819},"95",[54,1821,1822],{"style":64},", { ",[54,1824,1825],{"style":122},[54,1826,846],{"class":70,"data-popup":1827},"96",[54,1829,1830],{"style":64},": (",[54,1832,1833],{"style":1005},[54,1834,1009],{"class":70,"data-popup":1835},"97",[54,1837,1838],{"style":64},") ",[54,1840,1841],{"style":60},"=>",[54,1843,93],{"style":64},[54,1845,1846],{"style":64},[54,1847,1009],{"class":70,"data-popup":1848},"98",[54,1850,1851],{"style":64}," })) {",[54,1853,1854,1857,1859,1865,1867,1869,1874,1876,1881,1883,1888,1890,1892],{"class":56,"style":57},[54,1855,1856],{"style":60},"  const",[54,1858,93],{"style":92},[54,1860,1861],{"style":92},[54,1862,1864],{"class":70,"data-popup":1863},"99","obj",[54,1866,102],{"style":60},[54,1868,93],{"style":64},[54,1870,1871],{"style":64},[54,1872,12],{"class":70,"data-popup":1873},"100",[54,1875,112],{"style":64},[54,1877,1878],{"style":122},[54,1879,1687],{"class":70,"data-popup":1880},"101",[54,1882,983],{"style":64},[54,1884,1885],{"style":64},[54,1886,1009],{"class":70,"data-popup":1887},"102",[54,1889,181],{"style":64},[54,1891,192],{"style":80},[54,1893,585],{"style":64},[54,1895,1896,1899,1901,1906],{"class":56,"style":57},[54,1897,1898],{"style":60},"  if",[54,1900,1020],{"style":64},[54,1902,1903],{"style":64},[54,1904,1864],{"class":70,"data-popup":1905},"103",[54,1907,1012],{"style":64},[54,1909,1910,1913,1918,1920,1925,1927,1930,1935,1937,1942,1944,1949,1952],{"class":56,"style":57},[54,1911,1912],{"style":64},"    ",[54,1914,1915],{"style":64},[54,1916,1604],{"class":70,"data-popup":1917},"104",[54,1919,112],{"style":64},[54,1921,1922],{"style":122},[54,1923,1612],{"class":70,"data-popup":1924},"105",[54,1926,983],{"style":64},[54,1928,1929],{"style":80},"`object with ${",[54,1931,1932],{"style":64},[54,1933,1864],{"class":70,"data-popup":1934},"106",[54,1936,112],{"style":80},[54,1938,1939],{"style":64},[54,1940,200],{"class":70,"data-popup":1941},"107",[54,1943,112],{"style":80},[54,1945,1946],{"style":92},[54,1947,1186],{"class":70,"data-popup":1948},"108",[54,1950,1951],{"style":80},"} properties`",[54,1953,585],{"style":64},[54,1955,1956],{"class":56,"style":57},[54,1957,1958],{"style":64},"  }",[54,1960],{"class":56,"style":57},[54,1962,1963,1965,1967,1972,1974,1979,1981,1983,1986],{"class":56,"style":57},[54,1964,1898],{"style":60},[54,1966,1020],{"style":64},[54,1968,1969],{"style":64},[54,1970,1009],{"class":70,"data-popup":1971},"109",[54,1973,112],{"style":64},[54,1975,1976],{"style":64},[54,1977,187],{"class":70,"data-popup":1978},"110",[54,1980,93],{"style":64},[54,1982,1037],{"style":60},[54,1984,1985],{"style":80}," 'ref'",[54,1987,1012],{"style":64},[54,1989,1990,1992,1997,1999,2004,2006,2009,2014,2016,2021,2023],{"class":56,"style":57},[54,1991,1912],{"style":64},[54,1993,1994],{"style":64},[54,1995,1604],{"class":70,"data-popup":1996},"111",[54,1998,112],{"style":64},[54,2000,2001],{"style":122},[54,2002,1612],{"class":70,"data-popup":2003},"112",[54,2005,983],{"style":64},[54,2007,2008],{"style":80},"`reference to: ${",[54,2010,2011],{"style":64},[54,2012,1009],{"class":70,"data-popup":2013},"113",[54,2015,112],{"style":80},[54,2017,2018],{"style":64},[54,2019,572],{"class":70,"data-popup":2020},"114",[54,2022,1632],{"style":80},[54,2024,585],{"style":64},[54,2026,2027],{"class":56,"style":57},[54,2028,1958],{"style":64},[54,2030,2031],{"class":56,"style":57},[54,2032,2033],{"style":64},"}",[54,2035],{"class":56,"style":57},[54,2037,2038,2040,2042,2044,2046,2051,2053,2055,2060,2062,2067,2069,2074,2076,2081,2083,2088,2090,2095,2097,2102,2104,2106,2108,2113],{"class":56,"style":57},[54,2039,1770],{"style":60},[54,2041,1020],{"style":64},[54,2043,89],{"style":60},[54,2045,93],{"style":92},[54,2047,2048],{"style":92},[54,2049,1009],{"class":70,"data-popup":2050},"115",[54,2052,1784],{"style":60},[54,2054,93],{"style":64},[54,2056,2057],{"style":64},[54,2058,12],{"class":70,"data-popup":2059},"116",[54,2061,112],{"style":64},[54,2063,2064],{"style":122},[54,2065,40],{"class":70,"data-popup":2066},"117",[54,2068,1361],{"style":64},[54,2070,2071],{"style":122},[54,2072,12],{"class":70,"data-popup":2073},"118",[54,2075,112],{"style":64},[54,2077,2078],{"style":122},[54,2079,1374],{"class":70,"data-popup":2080},"119",[54,2082,1377],{"style":64},[54,2084,2085],{"style":64},[54,2086,99],{"class":70,"data-popup":2087},"120",[54,2089,1822],{"style":64},[54,2091,2092],{"style":122},[54,2093,843],{"class":70,"data-popup":2094},"121",[54,2096,1830],{"style":64},[54,2098,2099],{"style":1005},[54,2100,1009],{"class":70,"data-popup":2101},"122",[54,2103,1838],{"style":64},[54,2105,1841],{"style":60},[54,2107,93],{"style":64},[54,2109,2110],{"style":64},[54,2111,1009],{"class":70,"data-popup":2112},"123",[54,2114,1851],{"style":64},[54,2116,2117,2119,2121,2126,2128,2134,2136,2141],{"class":56,"style":57},[54,2118,1898],{"style":60},[54,2120,1020],{"style":64},[54,2122,2123],{"style":64},[54,2124,12],{"class":70,"data-popup":2125},"124",[54,2127,112],{"style":64},[54,2129,2130],{"style":122},[54,2131,2133],{"class":70,"data-popup":2132},"125","isHttpOperationNode",[54,2135,983],{"style":64},[54,2137,2138],{"style":64},[54,2139,1009],{"class":70,"data-popup":2140},"126",[54,2142,2143],{"style":64},")) {",[54,2145,2146,2148,2153,2155,2160,2162,2165,2170,2172,2177,2180,2185,2187,2193,2195],{"class":56,"style":57},[54,2147,1912],{"style":64},[54,2149,2150],{"style":64},[54,2151,1604],{"class":70,"data-popup":2152},"127",[54,2154,112],{"style":64},[54,2156,2157],{"style":122},[54,2158,1612],{"class":70,"data-popup":2159},"128",[54,2161,983],{"style":64},[54,2163,2164],{"style":80},"`${",[54,2166,2167],{"style":64},[54,2168,1009],{"class":70,"data-popup":2169},"129",[54,2171,112],{"style":80},[54,2173,2174],{"style":64},[54,2175,1421],{"class":70,"data-popup":2176},"130",[54,2178,2179],{"style":80},"} ${",[54,2181,2182],{"style":64},[54,2183,1009],{"class":70,"data-popup":2184},"131",[54,2186,112],{"style":80},[54,2188,2189],{"style":64},[54,2190,2192],{"class":70,"data-popup":2191},"132","path",[54,2194,1632],{"style":80},[54,2196,585],{"style":64},[54,2198,2199],{"class":56,"style":57},[54,2200,1958],{"style":64},[54,2202,2203],{"class":56,"style":57},[54,2204,2033],{"style":64},[10,2206,2208],{"id":2207},"refs-and-naming-helpers","Refs and naming helpers",[17,2210,2211,2212,2215,2216,2218,2219,181,2222,181,2225,235,2228,2231,2232,2234,2235,2238],{},"The helpers split across two surfaces. ",[14,2213,2214],{},"resolveRefName"," ships on the ",[14,2217,12],{}," namespace, like the guards and node types. ",[14,2220,2221],{},"extractRefName",[14,2223,2224],{},"childName",[14,2226,2227],{},"enumPropName",[14,2229,2230],{},"syncSchemaRef"," are named exports of ",[14,2233,24],{}," itself. The same split applies to ",[14,2236,2237],{},"containsCircularRef"," and the built-in macros below.",[277,2240,2241,2250],{},[280,2242,2243],{},[283,2244,2245,2248],{},[286,2246,2247],{},"Helper",[286,2249,715],{},[296,2251,2252,2267,2279,2288,2297],{},[283,2253,2254,2258],{},[301,2255,2256],{},[14,2257,2221],{},[301,2259,2260,2261,2264,2265,112],{},"Turn ",[14,2262,2263],{},"'#\u002Fcomponents\u002Fschemas\u002FPet'"," into ",[14,2266,178],{},[283,2268,2269,2273],{},[301,2270,2271],{},[14,2272,2214],{},[301,2274,2275,2276,112],{},"Resolve the name a ref node emits, preferring its ",[14,2277,2278],{},"targetName",[283,2280,2281,2285],{},[301,2282,2283],{},[14,2284,2224],{},[301,2286,2287],{},"Derive a child property name from context.",[283,2289,2290,2294],{},[301,2291,2292],{},[14,2293,2227],{},[301,2295,2296],{},"Convert an enum value into a valid property name.",[283,2298,2299,2303],{},[301,2300,2301],{},[14,2302,2230],{},[301,2304,2305,2306,181,2309,2312],{},"Merge a ref node with its resolved schema, letting usage-site fields (",[14,2307,2308],{},"description",[14,2310,2311],{},"nullable",") override.",[43,2314,2317],{"language":45,"meta":46,"code":2315,"filename":2316,"class":49},"import { extractRefName } from 'kubb\u002Fkit'\n\nconst name = extractRefName('#\u002Fcomponents\u002Fschemas\u002FPet')\n\u002F\u002F    ^?","refs.ts",[14,2318,2319,82,2336,82,2338,82,2365],{"class":52},[54,2320,2321,2323,2325,2330,2332,2334],{"class":56,"style":57},[54,2322,61],{"style":60},[54,2324,65],{"style":64},[54,2326,2327],{"style":64},[54,2328,2221],{"class":70,"data-popup":2329},"133",[54,2331,74],{"style":64},[54,2333,77],{"style":60},[54,2335,81],{"style":80},[54,2337],{"class":56,"style":57},[54,2339,2340,2342,2344,2350,2352,2354,2359,2361,2363],{"class":56,"style":57},[54,2341,89],{"style":60},[54,2343,93],{"style":92},[54,2345,2346],{"style":92},[54,2347,172],{"class":2348,"data-popup":2349},"twoslash-hover twoslash-query-persisted","134",[54,2351,102],{"style":60},[54,2353,93],{"style":122},[54,2355,2356],{"style":122},[54,2357,2221],{"class":70,"data-popup":2358},"135",[54,2360,983],{"style":64},[54,2362,2263],{"style":80},[54,2364,585],{"style":64},[54,2366],{"class":56,"style":57},[10,2368,2370],{"id":2369},"schema-graph","Schema graph",[17,2372,2373,2374,37,2377,2380,2381,2383],{},"Analyze how schemas reference each other, to prune unused schemas or wrap circular ones in a lazy construct. ",[14,2375,2376],{},"collectUsedSchemaNames",[14,2378,2379],{},"findCircularSchemas"," ship on the ",[14,2382,12],{}," namespace.",[277,2385,2386,2394],{},[280,2387,2388],{},[283,2389,2390,2392],{},[286,2391,2247],{},[286,2393,715],{},[296,2395,2396,2409,2421],{},[283,2397,2398,2402],{},[301,2399,2400],{},[14,2401,2376],{},[301,2403,2404,2405,2408],{},"Collect the names of every top-level schema transitively used by a set of operations. Pair it with ",[14,2406,2407],{},"include"," filters to leave unreferenced schemas ungenerated.",[283,2410,2411,2415],{},[301,2412,2413],{},[14,2414,2379],{},[301,2416,2417,2418,112],{},"Find every schema that takes part in a circular dependency chain, so those positions can be wrapped in a lazy getter or ",[14,2419,2420],{},"z.lazy(() => …)",[283,2422,2423,2427],{},[301,2424,2425],{},[14,2426,2237],{},[301,2428,2429],{},"Report whether a schema, or anything nested inside it, references a circular schema.",[10,2431,2433],{"id":2432},"constants","Constants",[277,2435,2436,2445],{},[280,2437,2438],{},[283,2439,2440,2443],{},[286,2441,2442],{},"Export",[286,2444,715],{},[296,2446,2447],{},[283,2448,2449,2454],{},[301,2450,2451],{},[14,2452,2453],{},"schemaTypes",[301,2455,2456,2457,2459],{},"Map of every schema ",[14,2458,187],{}," discriminant.",[10,2461,2462],{"id":860},"Macros",[17,2464,2465,2466,2468,2469,112],{},"A macro is a named, composable transform built on ",[14,2467,36],{}," that rewrites nodes before printing, adding ordering, gating, and reuse a bare visitor doesn't give you. See ",[245,2470,2471],{"href":859},"Macros concepts",[277,2473,2474,2482],{},[280,2475,2476],{},[283,2477,2478,2480],{},[286,2479,2442],{},[286,2481,715],{},[296,2483,2484,2494,2504],{},[283,2485,2486,2491],{},[301,2487,2488],{},[14,2489,2490],{},"defineMacro",[301,2492,2493],{},"Type a macro and read it as one definition.",[283,2495,2496,2501],{},[301,2497,2498],{},[14,2499,2500],{},"composeMacros",[301,2502,2503],{},"Fold an ordered list of macros into one visitor.",[283,2505,2506,2511],{},[301,2507,2508],{},[14,2509,2510],{},"applyMacros",[301,2512,2513],{},"Run a list of macros over a node tree.",[17,2515,2516,2517,181,2520,235,2523,2526,2527,2529],{},"Kubb also ships built-in macros for common schema normalizations that any adapter can compose with its own. ",[14,2518,2519],{},"macroDiscriminatorEnum",[14,2521,2522],{},"macroEnumName",[14,2524,2525],{},"macroRenameSchema"," read options, so call them to build the macro. Plugins that import another plugin's output compute names from the nodes they see, so register a rename on every plugin that touches the schema, for example by passing one shared ",[14,2528,860],{}," array to each plugin.",[277,2531,2532,2541],{},[280,2533,2534],{},[283,2535,2536,2539],{},[286,2537,2538],{},"Macro",[286,2540,715],{},[296,2542,2543,2555,2564,2573],{},[283,2544,2545,2550],{},[301,2546,2547],{},[14,2548,2549],{},"macroSimplifyUnion",[301,2551,2552,2553,112],{},"Drop union members a broader scalar primitive already covers, such as a multi-value string enum next to ",[14,2554,413],{},[283,2556,2557,2561],{},[301,2558,2559],{},[14,2560,2519],{},[301,2562,2563],{},"Replace a discriminator property's schema with a string enum of its allowed values.",[283,2565,2566,2570],{},[301,2567,2568],{},[14,2569,2522],{},[301,2571,2572],{},"Name an inline enum schema from its parent and property name.",[283,2574,2575,2579],{},[301,2576,2577],{},[14,2578,2525],{},[301,2580,2581,2582,2584,2585,2588],{},"Rename a schema's declaration and stamp ",[14,2583,2278],{}," on every ref pointing at it, so ",[14,2586,2587],{},"resolver.imports"," emits the new name everywhere.",[272,2590,2592],{"id":2591},"macro-options-and-callbacks","Macro options and callbacks",[17,2594,2595,2596,2600,2601,2603,2604,2607,2608,2611],{},"A macro carries the per-kind callbacks of a ",[245,2597,2599],{"href":2598},"\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fast#visitors","visitor",", plus a ",[14,2602,172],{},", an optional ",[14,2605,2606],{},"enforce"," order, and an optional ",[14,2609,2610],{},"match"," predicate.",[43,2613,2617],{"language":45,"filename":2614,"code":2615,"class":2616},"Type definition","type Macro = {\n  name: string\n  enforce?: 'pre' | 'post'\n  match?: (node: Node) => boolean\n  schema?(node: SchemaNode, context): SchemaNode | null | undefined\n  operation?(node: OperationNode, context): OperationNode | null | undefined\n  \u002F\u002F input, output, property, parameter, response\n}","shiki shiki-themes github-light github-dark dark:github-dark",[14,2618,2619,82,2631,82,2641,82,2658,82,2681,82,2718,82,2752,82,2758],{"class":52},[54,2620,2621,2623,2626,2628],{"class":56,"style":57},[54,2622,187],{"style":60},[54,2624,2625],{"style":122}," Macro",[54,2627,102],{"style":60},[54,2629,2630],{"style":64}," {",[54,2632,2633,2636,2638],{"class":56,"style":57},[54,2634,2635],{"style":1005},"  name",[54,2637,1208],{"style":60},[54,2639,2640],{"style":92}," string",[54,2642,2643,2646,2649,2652,2655],{"class":56,"style":57},[54,2644,2645],{"style":1005},"  enforce",[54,2647,2648],{"style":60},"?:",[54,2650,2651],{"style":80}," 'pre'",[54,2653,2654],{"style":60}," |",[54,2656,2657],{"style":80}," 'post'",[54,2659,2660,2663,2665,2667,2669,2671,2674,2676,2678],{"class":56,"style":57},[54,2661,2662],{"style":122},"  match",[54,2664,2648],{"style":60},[54,2666,1020],{"style":64},[54,2668,1009],{"style":1005},[54,2670,1208],{"style":60},[54,2672,2673],{"style":122}," Node",[54,2675,1838],{"style":64},[54,2677,1841],{"style":60},[54,2679,2680],{"style":92}," boolean",[54,2682,2683,2686,2688,2690,2692,2694,2697,2699,2702,2704,2706,2708,2710,2713,2715],{"class":56,"style":57},[54,2684,2685],{"style":122},"  schema",[54,2687,1568],{"style":60},[54,2689,983],{"style":64},[54,2691,1009],{"style":1005},[54,2693,1208],{"style":60},[54,2695,2696],{"style":122}," SchemaNode",[54,2698,181],{"style":64},[54,2700,2701],{"style":1005},"context",[54,2703,585],{"style":64},[54,2705,1208],{"style":60},[54,2707,2696],{"style":122},[54,2709,2654],{"style":60},[54,2711,2712],{"style":92}," null",[54,2714,2654],{"style":60},[54,2716,2717],{"style":92}," undefined",[54,2719,2720,2723,2725,2727,2729,2731,2734,2736,2738,2740,2742,2744,2746,2748,2750],{"class":56,"style":57},[54,2721,2722],{"style":122},"  operation",[54,2724,1568],{"style":60},[54,2726,983],{"style":64},[54,2728,1009],{"style":1005},[54,2730,1208],{"style":60},[54,2732,2733],{"style":122}," OperationNode",[54,2735,181],{"style":64},[54,2737,2701],{"style":1005},[54,2739,585],{"style":64},[54,2741,1208],{"style":60},[54,2743,2733],{"style":122},[54,2745,2654],{"style":60},[54,2747,2712],{"style":92},[54,2749,2654],{"style":60},[54,2751,2717],{"style":92},[54,2753,2754],{"class":56,"style":57},[54,2755,2757],{"style":2756},"color:#6A737D;--shiki-dark:#6A737D","  \u002F\u002F input, output, property, parameter, response",[54,2759,2760],{"class":56,"style":57},[54,2761,2033],{"style":64},[17,2763,2764,2765,2767,2768,2770],{},"Each callback returns a replacement node, or ",[14,2766,1070],{}," or ",[14,2769,483],{}," to leave the node untouched.",[10,2772,2774],{"id":2773},"printers","Printers",[17,2776,2777],{},"Lower-level helpers for parsers that turn the AST into source code:",[277,2779,2780,2788],{},[280,2781,2782],{},[283,2783,2784,2786],{},[286,2785,2442],{},[286,2787,715],{},[296,2789,2790],{},[283,2791,2792,2797],{},[301,2793,2794],{},[14,2795,2796],{},"createPrinter",[301,2798,2799,2800,112],{},"Typed helper for creating a ",[14,2801,2802],{},"Printer",[17,2804,2805,2807,2808,2811,2812,2814,2815,2818,2819,2822,2823,2826,2827,181,2830,235,2833,2836,2837,112],{},[14,2806,2796],{}," takes an ",[14,2809,2810],{},"overrides"," map to replace the handler for individual schema node types. Pass overrides through the ",[14,2813,2810],{}," field rather than spreading them into ",[14,2816,2817],{},"nodes",", otherwise ",[14,2820,2821],{},"this.base"," cannot find the original handler. The ",[14,2824,2825],{},"printer.nodes"," option on ",[14,2828,2829],{},"@kubb\u002Fplugin-ts",[14,2831,2832],{},"@kubb\u002Fplugin-zod",[14,2834,2835],{},"@kubb\u002Fplugin-faker"," feeds this map. See ",[245,2838,2840],{"href":2839},"\u002Fdocs\u002F5.x\u002Fhow-to\u002Fprinters","Customize printers",[17,2842,2843,2844,2848,2849,2853],{},"See ",[245,2845,2847],{"href":2846},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-zod\u002Fguides\u002Fcustomization#import-a-custom-codec","Import a custom codec"," for a complete example and ",[245,2850,2852],{"href":2851},"\u002Fdocs\u002F5.x\u002Fexplanation\u002Farchitecture#parsers","Parsers concepts"," for how parsers consume printers.",[272,2855,2857],{"id":2856},"printer-handlers-and-context","Printer handlers and context",[17,2859,2860,2861,2863,2864,181,2867,181,2870,181,2873,2876,2877,2879],{},"The map is keyed by the schema ",[14,2862,187],{}," discriminant, such as ",[14,2865,2866],{},"'string'",[14,2868,2869],{},"'integer'",[14,2871,2872],{},"'date'",[14,2874,2875],{},"'enum'",", or ",[14,2878,192],{},". Supply only the handlers you want to replace and the built-in ones fill in the rest.",[43,2881,2883],{"language":45,"filename":2614,"code":2882,"class":2616},"type PrinterNodes = Partial\u003C{\n  [K in SchemaType]: (this: Context, node: SchemaNodeByType[K]) => Output | null\n}>",[14,2884,2885,82,2900,82,2954],{"class":52},[54,2886,2887,2889,2892,2894,2897],{"class":56,"style":57},[54,2888,187],{"style":60},[54,2890,2891],{"style":122}," PrinterNodes",[54,2893,102],{"style":60},[54,2895,2896],{"style":122}," Partial",[54,2898,2899],{"style":64},"\u003C{",[54,2901,2902,2905,2908,2910,2913,2916,2918,2920,2923,2925,2928,2930,2932,2934,2937,2940,2942,2945,2947,2950,2952],{"class":56,"style":57},[54,2903,2904],{"style":64},"  [",[54,2906,2907],{"style":122},"K",[54,2909,1537],{"style":60},[54,2911,2912],{"style":122}," SchemaType",[54,2914,2915],{"style":64},"]",[54,2917,1208],{"style":60},[54,2919,1020],{"style":64},[54,2921,2922],{"style":92},"this",[54,2924,1208],{"style":60},[54,2926,2927],{"style":122}," Context",[54,2929,181],{"style":64},[54,2931,1009],{"style":1005},[54,2933,1208],{"style":60},[54,2935,2936],{"style":122}," SchemaNodeByType",[54,2938,2939],{"style":64},"[",[54,2941,2907],{"style":122},[54,2943,2944],{"style":64},"]) ",[54,2946,1841],{"style":60},[54,2948,2949],{"style":122}," Output",[54,2951,2654],{"style":60},[54,2953,2712],{"style":92},[54,2955,2956],{"class":56,"style":57},[54,2957,2958],{"style":64},"}>",[17,2960,2961,2962,2964,2965,2968,2969,2972,2973,2976,2977,2980,2981,2767,2983,2980,2986,2988,2989,2992,2993,2996],{},"Handlers run with a ",[14,2963,2922],{}," context, so write them as regular functions rather than arrow functions. ",[14,2966,2967],{},"this.transform(node)"," recurses into a nested schema node through the full handler map, overrides included. ",[14,2970,2971],{},"this.base(node)"," runs the built-in handler your override replaced, so you can wrap its output instead of rebuilding it. ",[14,2974,2975],{},"this.options"," reads the resolved printer options, such as ",[14,2978,2979],{},"arrayType"," on ",[14,2982,2829],{},[14,2984,2985],{},"direction",[14,2987,2832],{},". Inside a handler, ",[14,2990,2991],{},"this.import(ast.factory.createImport(...))"," declares an import the printed code needs. The built-in generators collect these imports. In your own generator, call ",[14,2994,2995],{},"printer.drainImports()"," after printing to collect them.",{"title":2998,"searchDepth":2999,"depth":2999,"links":3000},"",5,[3001,3003,3009,3010,3016,3017,3018,3019,3020,3023],{"id":12,"depth":3002,"text":12},2,{"id":259,"depth":3002,"text":260,"children":3004},[3005,3007,3008],{"id":274,"depth":3006,"text":275},3,{"id":391,"depth":3006,"text":392},{"id":549,"depth":3006,"text":550},{"id":691,"depth":3002,"text":692},{"id":827,"depth":3002,"text":828,"children":3011},[3012,3014],{"id":870,"depth":3006,"text":3013},"transform: synchronous, returns a new tree",{"id":1234,"depth":3006,"text":3015},"collect: gather matching nodes",{"id":1680,"depth":3002,"text":1681},{"id":2207,"depth":3002,"text":2208},{"id":2369,"depth":3002,"text":2370},{"id":2432,"depth":3002,"text":2433},{"id":860,"depth":3002,"text":2462,"children":3021},[3022],{"id":2591,"depth":3006,"text":2592},{"id":2773,"depth":3002,"text":2774,"children":3024},[3025],{"id":2856,"depth":3006,"text":2857},"The ast namespace groups the factory node builders, the transform and collect visitors, the guards, the ref and naming helpers, the macro engine, and the printer helper behind one import.","md",{"layout":3029,"title":5,"description":3026,"outline":3030,"order":3031,"navigation":3032},"doc",[3002,3006],8,{"title":3033,"icon":3034},"AST & node builders","i-iconoir-code-brackets",{"layout":3029,"outline":3036},[3002,3006],{"title":3033,"icon":3034},"\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fast",{"title":5,"description":3026},{"loc":3038},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fast.md","docs\u002F5.x\u002Freference\u002Fkit\u002Fast","fTwnVi7MYLNPRyeGJ70Kw-IUXSRUPcjUOraxHDK8L24",true,1792333816611]