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