[{"data":1,"prerenderedAt":1099},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fresolvers":3},{"id":4,"title":5,"body":6,"description":1083,"extension":1084,"frontmatter":1085,"heading":5,"meta":1090,"navigation":1092,"order":1079,"path":1093,"seo":1094,"sitemap":1095,"source":1096,"stem":1097,"__hash__":1098},"docs\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fresolvers.md","Resolvers",{"type":7,"value":8,"toc":1071},"minimark",[9,17,23,38,403,408,556,562,575,591,635,641,734,740,767,770,782,869,873,884,1034,1050],[10,11,13],"h2",{"id":12},"createresolver",[14,15,16],"code",{},"createResolver",[18,19,20,22],"p",{},[14,21,16],{}," builds a plugin resolver for names, paths, and imports.",[18,24,25,26,29,30,33,34,37],{},"Provide ",[14,27,28],{},"pluginName",". Methods use ",[14,31,32],{},"this"," to reach the merged resolver, so namespaced methods call ",[14,35,36],{},"this.name(...)"," for active casing.",[39,40,45],"pre",{"language":41,"filename":42,"code":43,"class":44},"typescript","resolver.ts","import { createResolver } from 'kubb\u002Fkit'\nimport type { PluginType, Resolver } from 'kubb\u002Fkit'\n\n\u002F\u002F Extend the base Resolver with plugin-specific naming namespaces.\ntype MyResolver = Resolver & {\n  schema: {\n    name(node: { name: string }): string\n  }\n}\n\ntype MyPlugin = PluginType\u003C'plugin-example', object, object, MyResolver>\n\nexport const resolver = createResolver\u003CMyPlugin>({\n  pluginName: 'plugin-example',\n  name(name) {\n    return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n  },\n  schema: {\n    name(node) {\n      return this.name(node.name)\n    },\n  },\n})","highlights",[14,46,48,75,76,75,101,75,103,75,109,75,127,75,140,75,173,75,180,75,184,75,186,75,220,75,222,75,247,75,260,75,273,75,331,75,339,75,349,75,361,75,384,75,391,75,399],{"class":47},"language-typescript",[49,50,53,57,61,65,68,71],"span",{"class":51,"style":52},"line","display: inline",[49,54,56],{"style":55},"color:#d73a49;--hls-dark:#f97583","import ",[49,58,60],{"style":59},"color:#005cc5;--hls-dark:#79b8ff","{ ",[49,62,64],{"style":63},"color:#24292e;--hls-dark:#e1e4e8","createResolver ",[49,66,67],{"style":59},"} ",[49,69,70],{"style":55},"from ",[49,72,74],{"style":73},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fkit'","\n",[49,77,78,80,83,85,89,92,95,97,99],{"class":51,"style":52},[49,79,56],{"style":55},[49,81,82],{"style":63},"type ",[49,84,60],{"style":59},[49,86,88],{"style":87},"color:#6f42c1;--hls-dark:#b392f0","PluginType",[49,90,91],{"style":55},", ",[49,93,94],{"style":87},"Resolver ",[49,96,67],{"style":59},[49,98,70],{"style":55},[49,100,74],{"style":73},[49,102],{"class":51,"style":52},[49,104,105],{"class":51,"style":52},[49,106,108],{"style":107},"color:#6a737d;--hls-dark:#6a737d","\u002F\u002F Extend the base Resolver with plugin-specific naming namespaces.",[49,110,111,113,116,119,121,124],{"class":51,"style":52},[49,112,82],{"style":55},[49,114,115],{"style":87},"MyResolver ",[49,117,118],{"style":55},"= ",[49,120,94],{"style":87},[49,122,123],{"style":55},"& ",[49,125,126],{"style":59},"{",[49,128,129,132,135,138],{"class":51,"style":52},[49,130,131],{"style":59},"  ",[49,133,134],{"style":59},"schema",[49,136,137],{"style":55},": ",[49,139,126],{"style":59},[49,141,142,145,148,151,154,156,158,160,162,165,168,170],{"class":51,"style":52},[49,143,144],{"style":59},"    ",[49,146,147],{"style":87},"name",[49,149,150],{"style":59},"(",[49,152,153],{"style":63},"node",[49,155,137],{"style":55},[49,157,60],{"style":59},[49,159,147],{"style":59},[49,161,137],{"style":63},[49,163,164],{"style":87},"string ",[49,166,167],{"style":59},"})",[49,169,137],{"style":63},[49,171,172],{"style":87},"string",[49,174,175,177],{"class":51,"style":52},[49,176,131],{"style":87},[49,178,179],{"style":59},"}",[49,181,182],{"class":51,"style":52},[49,183,179],{"style":59},[49,185],{"class":51,"style":52},[49,187,188,190,193,195,197,200,203,205,208,210,212,214,217],{"class":51,"style":52},[49,189,82],{"style":55},[49,191,192],{"style":87},"MyPlugin ",[49,194,118],{"style":55},[49,196,88],{"style":87},[49,198,199],{"style":55},"\u003C",[49,201,202],{"style":73},"'plugin-example'",[49,204,91],{"style":55},[49,206,207],{"style":63},"object",[49,209,91],{"style":55},[49,211,207],{"style":63},[49,213,91],{"style":55},[49,215,216],{"style":87},"MyResolver",[49,218,219],{"style":55},">",[49,221],{"class":51,"style":52},[49,223,224,227,230,233,235,237,239,242,244],{"class":51,"style":52},[49,225,226],{"style":55},"export ",[49,228,229],{"style":55},"const ",[49,231,232],{"style":63},"resolver ",[49,234,118],{"style":55},[49,236,16],{"style":63},[49,238,199],{"style":55},[49,240,241],{"style":87},"MyPlugin",[49,243,219],{"style":55},[49,245,246],{"style":59},"({",[49,248,249,251,253,255,257],{"class":51,"style":52},[49,250,131],{"style":59},[49,252,28],{"style":59},[49,254,137],{"style":55},[49,256,202],{"style":73},[49,258,259],{"style":55},",",[49,261,262,264,266,268,270],{"class":51,"style":52},[49,263,131],{"style":55},[49,265,147],{"style":87},[49,267,150],{"style":59},[49,269,147],{"style":63},[49,271,272],{"style":59},") {",[49,274,275,277,280,283,286,288,291,294,296,299,302,304,307,310,313,315,317,320,322,325,327,329],{"class":51,"style":52},[49,276,144],{"style":59},[49,278,279],{"style":55},"return ",[49,281,282],{"style":73},"`",[49,284,285],{"style":63},"${",[49,287,147],{"style":63},[49,289,290],{"style":55},".",[49,292,293],{"style":87},"charAt",[49,295,150],{"style":59},[49,297,298],{"style":59},"0",[49,300,301],{"style":59},")",[49,303,290],{"style":55},[49,305,306],{"style":87},"toUpperCase",[49,308,309],{"style":59},"()",[49,311,312],{"style":63},"}${",[49,314,147],{"style":63},[49,316,290],{"style":55},[49,318,319],{"style":87},"slice",[49,321,150],{"style":59},[49,323,324],{"style":59},"1",[49,326,301],{"style":59},[49,328,179],{"style":63},[49,330,282],{"style":73},[49,332,333,335,337],{"class":51,"style":52},[49,334,131],{"style":73},[49,336,179],{"style":59},[49,338,259],{"style":55},[49,340,341,343,345,347],{"class":51,"style":52},[49,342,131],{"style":55},[49,344,134],{"style":59},[49,346,137],{"style":55},[49,348,126],{"style":59},[49,350,351,353,355,357,359],{"class":51,"style":52},[49,352,144],{"style":59},[49,354,147],{"style":87},[49,356,150],{"style":59},[49,358,153],{"style":63},[49,360,272],{"style":59},[49,362,363,366,368,370,372,374,376,378,380,382],{"class":51,"style":52},[49,364,365],{"style":59},"      ",[49,367,279],{"style":55},[49,369,32],{"style":63},[49,371,290],{"style":55},[49,373,147],{"style":87},[49,375,150],{"style":59},[49,377,153],{"style":63},[49,379,290],{"style":55},[49,381,147],{"style":59},[49,383,301],{"style":59},[49,385,386,389],{"class":51,"style":52},[49,387,388],{"style":59},"    }",[49,390,259],{"style":55},[49,392,393,395,397],{"class":51,"style":52},[49,394,131],{"style":55},[49,396,179],{"style":59},[49,398,259],{"style":55},[49,400,401],{"class":51,"style":52},[49,402,167],{"style":59},[404,405,407],"h3",{"id":406},"auto-injected-resolver-defaults","Auto-injected resolver defaults",[409,410,411,424],"table",{},[412,413,414],"thead",{},[415,416,417,421],"tr",{},[418,419,420],"th",{},"Method",[418,422,423],{},"Default behavior",[425,426,427,441,458,471,492,506,529,543],"tbody",{},[415,428,429,434],{},[430,431,432],"td",{},[14,433,147],{},[430,435,436,437,440],{},"Active top-level identifier casing. Delegates to ",[14,438,439],{},"default.name"," when omitted",[415,442,443,448],{},[430,444,445],{},[14,446,447],{},"file",[430,449,450,451,454,455],{},"Top-level ",[14,452,453],{},"FileNode"," builder, delegates to ",[14,456,457],{},"default.file",[415,459,460,464],{},[430,461,462],{},[14,463,439],{},[430,465,466,467,470],{},"The core ",[14,468,469],{},"camelCase"," generated-identifier casing",[415,472,473,478],{},[430,474,475],{},[14,476,477],{},"default.options",[430,479,480,481,91,484,487,488,491],{},"Applies ",[14,482,483],{},"exclude",[14,485,486],{},"include",", and ",[14,489,490],{},"override"," filters",[415,493,494,499],{},[430,495,496],{},[14,497,498],{},"default.path",[430,500,501,502,505],{},"Resolves to ",[14,503,504],{},"output.path",", with optional tag\u002Fpath-based subdirectories",[415,507,508,512],{},[430,509,510],{},[14,511,457],{},[430,513,514,515,517,518,521,522,525,526,301],{},"Constructs a full ",[14,516,453],{}," using the resolver's ",[14,519,520],{},"file.baseName"," casing (camelCase by default, with ",[14,523,524],{},"pet.petId"," becoming ",[14,527,528],{},"pet\u002FpetId",[415,530,531,536],{},[430,532,533],{},[14,534,535],{},"default.banner",[430,537,538,539,542],{},"Returns ",[14,540,541],{},"output.banner"," or the standard \"Generated by Kubb\" header",[415,544,545,550],{},[430,546,547],{},[14,548,549],{},"default.footer",[430,551,538,552,555],{},[14,553,554],{},"output.footer"," when set",[404,557,559],{"id":558},"imports",[14,560,561],{},"resolver.imports",[18,563,564,566,567,570,571,574],{},[14,565,561],{}," builds one import entry per ",[14,568,569],{},"$ref"," in a schema tree, so a generator emits the imports for every schema the current node references. Each import uses the ref's ",[14,572,573],{},"targetName"," when set, and otherwise the last segment of its pointer.",[18,576,577,578,580,581,583,584,587,588,290],{},"The resulting names and paths go through the resolver's own ",[14,579,147],{}," and ",[14,582,447],{}," conventions. ",[14,585,586],{},"extname"," defaults to ",[14,589,590],{},".ts",[39,592,595],{"language":41,"filename":593,"code":594,"class":44},"imports.ts","const imports = resolver.imports({ node, root, output })\n\u002F\u002F → [{ kind: 'Import', name: ['pet'], path: '\u002Fsrc\u002Ftypes\u002Fpet.ts' }]",[14,596,597,75,630],{"class":47},[49,598,599,601,604,606,609,611,613,616,618,620,623,625,628],{"class":51,"style":52},[49,600,229],{"style":55},[49,602,603],{"style":63},"imports ",[49,605,118],{"style":55},[49,607,608],{"style":63},"resolver",[49,610,290],{"style":55},[49,612,558],{"style":87},[49,614,615],{"style":59},"({ ",[49,617,153],{"style":63},[49,619,91],{"style":55},[49,621,622],{"style":63},"root",[49,624,91],{"style":55},[49,626,627],{"style":63},"output ",[49,629,167],{"style":59},[49,631,632],{"class":51,"style":52},[49,633,634],{"style":107},"\u002F\u002F → [{ kind: 'Import', name: ['pet'], path: '\u002Fsrc\u002Ftypes\u002Fpet.ts' }]",[18,636,637,638,640],{},"Pass ",[14,639,147],{}," to override how a referenced schema name becomes the imported identifier, for example to point enum refs at a suffixed type name:",[39,642,645],{"language":41,"filename":643,"code":644,"class":44},"importsName.ts","const imports = resolver.imports({\n  node,\n  root,\n  output,\n  name: (schemaName) => `${resolver.name(schemaName)}Type`,\n})",[14,646,647,75,663,75,671,75,679,75,688,75,730],{"class":47},[49,648,649,651,653,655,657,659,661],{"class":51,"style":52},[49,650,229],{"style":55},[49,652,603],{"style":63},[49,654,118],{"style":55},[49,656,608],{"style":63},[49,658,290],{"style":55},[49,660,558],{"style":87},[49,662,246],{"style":59},[49,664,665,667,669],{"class":51,"style":52},[49,666,131],{"style":59},[49,668,153],{"style":63},[49,670,259],{"style":55},[49,672,673,675,677],{"class":51,"style":52},[49,674,131],{"style":55},[49,676,622],{"style":63},[49,678,259],{"style":55},[49,680,681,683,686],{"class":51,"style":52},[49,682,131],{"style":55},[49,684,685],{"style":63},"output",[49,687,259],{"style":55},[49,689,690,692,694,696,698,701,704,707,709,711,713,715,717,719,721,723,725,728],{"class":51,"style":52},[49,691,131],{"style":55},[49,693,147],{"style":59},[49,695,137],{"style":55},[49,697,150],{"style":59},[49,699,700],{"style":63},"schemaName",[49,702,703],{"style":59},") ",[49,705,706],{"style":55},"=> ",[49,708,282],{"style":73},[49,710,285],{"style":63},[49,712,608],{"style":63},[49,714,290],{"style":55},[49,716,147],{"style":87},[49,718,150],{"style":59},[49,720,700],{"style":63},[49,722,301],{"style":59},[49,724,179],{"style":63},[49,726,727],{"style":73},"Type`",[49,729,259],{"style":55},[49,731,732],{"class":51,"style":52},[49,733,167],{"style":59},[404,735,737],{"id":736},"resolvermerge",[14,738,739],{},"Resolver.merge",[18,741,742,745,746,749,750,753,754,756,757,759,760,763,764,290],{},[14,743,744],{},"Resolver.merge(base, patch)"," returns a new resolver with ",[14,747,748],{},"patch","'s fields layered over ",[14,751,752],{},"base","'s and every helper re-bound. A top-level ",[14,755,147],{}," replaces, while ",[14,758,447],{}," and each namespace merge per member, so overriding ",[14,761,762],{},"query.name"," keeps the base ",[14,765,766],{},"query.keyName",[18,768,769],{},"Use it to compose resolvers or apply partial overrides.",[771,772,774,775,778,779,781],"blockquote",{"as":773},"tip","Type a patch with ",[14,776,777],{},"ResolverPatch\u003CT>"," to keep ",[14,780,32],{}," and namespace shapes checked against the target resolver.",[39,783,786],{"language":41,"filename":784,"code":785,"class":44},"merge.ts","const patched = Resolver.merge(resolver, {\n  name(name) {\n    return `Custom${this.default.name(name)}`\n  },\n})",[14,787,788,75,813,75,825,75,857,75,865],{"class":47},[49,789,790,792,795,797,800,802,805,807,809,811],{"class":51,"style":52},[49,791,229],{"style":55},[49,793,794],{"style":63},"patched ",[49,796,118],{"style":55},[49,798,799],{"style":87},"Resolver",[49,801,290],{"style":55},[49,803,804],{"style":87},"merge",[49,806,150],{"style":59},[49,808,608],{"style":63},[49,810,91],{"style":55},[49,812,126],{"style":59},[49,814,815,817,819,821,823],{"class":51,"style":52},[49,816,131],{"style":59},[49,818,147],{"style":87},[49,820,150],{"style":59},[49,822,147],{"style":63},[49,824,272],{"style":59},[49,826,827,829,831,834,836,838,840,843,845,847,849,851,853,855],{"class":51,"style":52},[49,828,144],{"style":59},[49,830,279],{"style":55},[49,832,833],{"style":73},"`Custom",[49,835,285],{"style":63},[49,837,32],{"style":63},[49,839,290],{"style":55},[49,841,842],{"style":59},"default",[49,844,290],{"style":55},[49,846,147],{"style":87},[49,848,150],{"style":59},[49,850,147],{"style":63},[49,852,301],{"style":59},[49,854,179],{"style":63},[49,856,282],{"style":73},[49,858,859,861,863],{"class":51,"style":52},[49,860,131],{"style":73},[49,862,179],{"style":59},[49,864,259],{"style":55},[49,866,867],{"class":51,"style":52},[49,868,167],{"style":59},[10,870,872],{"id":871},"resolver-overrides","Resolver overrides",[18,874,875,877,878,580,880,883],{},[14,876,147],{}," changes identifier casing. ",[14,879,520],{},[14,881,882],{},"file.path"," control files. Plugin namespaces control specific symbols.",[39,885,888],{"language":41,"filename":886,"code":887,"class":44},"Type definition","type ResolverPatch = {\n  name?: (name: string) => string\n  file?: {\n    baseName?: (params: { name: string; extname: string }) => string\n    path?: (params: { baseName: string; output: Output }) => string\n  }\n  \u002F\u002F plugin-specific namespaces, such as query.keyName or schema.typeName\n}",[14,889,890,75,901,75,926,75,937,75,979,75,1017,75,1023,75,1030],{"class":47},[49,891,892,894,897,899],{"class":51,"style":52},[49,893,82],{"style":55},[49,895,896],{"style":87},"ResolverPatch ",[49,898,118],{"style":55},[49,900,126],{"style":59},[49,902,903,905,907,910,912,914,916,918,920,922,924],{"class":51,"style":52},[49,904,131],{"style":59},[49,906,147],{"style":59},[49,908,909],{"style":63},"?",[49,911,137],{"style":55},[49,913,150],{"style":59},[49,915,147],{"style":63},[49,917,137],{"style":63},[49,919,172],{"style":87},[49,921,703],{"style":59},[49,923,706],{"style":55},[49,925,172],{"style":63},[49,927,928,931,933,935],{"class":51,"style":52},[49,929,930],{"style":63},"  file",[49,932,909],{"style":63},[49,934,137],{"style":55},[49,936,126],{"style":59},[49,938,939,941,944,946,948,950,953,955,957,959,961,963,966,968,970,972,975,977],{"class":51,"style":52},[49,940,144],{"style":59},[49,942,943],{"style":59},"baseName",[49,945,909],{"style":63},[49,947,137],{"style":55},[49,949,150],{"style":59},[49,951,952],{"style":63},"params",[49,954,137],{"style":55},[49,956,60],{"style":59},[49,958,147],{"style":59},[49,960,137],{"style":63},[49,962,172],{"style":87},[49,964,965],{"style":55},"; ",[49,967,586],{"style":59},[49,969,137],{"style":63},[49,971,164],{"style":87},[49,973,974],{"style":59},"}) ",[49,976,706],{"style":55},[49,978,172],{"style":63},[49,980,981,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1011,1013,1015],{"class":51,"style":52},[49,982,983],{"style":63},"    path",[49,985,909],{"style":63},[49,987,137],{"style":55},[49,989,150],{"style":59},[49,991,952],{"style":63},[49,993,137],{"style":55},[49,995,60],{"style":59},[49,997,943],{"style":59},[49,999,137],{"style":63},[49,1001,172],{"style":87},[49,1003,965],{"style":55},[49,1005,685],{"style":59},[49,1007,137],{"style":63},[49,1009,1010],{"style":87},"Output ",[49,1012,974],{"style":59},[49,1014,706],{"style":55},[49,1016,172],{"style":63},[49,1018,1019,1021],{"class":51,"style":52},[49,1020,131],{"style":63},[49,1022,179],{"style":59},[49,1024,1025,1027],{"class":51,"style":52},[49,1026,131],{"style":59},[49,1028,1029],{"style":107},"\u002F\u002F plugin-specific namespaces, such as query.keyName or schema.typeName",[49,1031,1032],{"class":51,"style":52},[49,1033,179],{"style":59},[18,1035,1036,1037,1039,1040,1043,1044,1046,1047,1049],{},"Methods run with a ",[14,1038,32],{}," context bound to the full, merged resolver, so write them as regular functions rather than arrow functions. ",[14,1041,1042],{},"this.default.name(name)"," always applies Kubb's core ",[14,1045,469],{}," default. The plugin preset's ",[14,1048,147],{}," method remains separate.",[18,1051,1052,1053,1056,1057,1059,1060,1063,1064,1066,1067,1070],{},"From a namespaced method, ",[14,1054,1055],{},"this.name(name)"," calls the active top-level ",[14,1058,147],{}," method and follows any user override. Calling ",[14,1061,1062],{},"this.name"," from the top-level ",[14,1065,147],{}," method itself recurses, so call an exported preset resolver such as ",[14,1068,1069],{},"resolverTs.name"," when you want to wrap its casing.",{"title":1072,"searchDepth":1073,"depth":1073,"links":1074},"",5,[1075,1082],{"id":12,"depth":1076,"text":16,"children":1077},2,[1078,1080,1081],{"id":406,"depth":1079,"text":407},3,{"id":558,"depth":1079,"text":561},{"id":736,"depth":1079,"text":739},{"id":871,"depth":1076,"text":872},"createResolver builds a Resolver that controls file naming and path resolution for a plugin, with auto-injected defaults under resolver.default and Resolver.merge for layering overrides.","md",{"layout":1086,"title":5,"description":1083,"outline":1087,"order":1079,"navigation":1088},"doc",[1076,1079],{"title":5,"icon":1089},"i-iconoir-label",{"layout":1086,"outline":1091},[1076,1079],{"title":5,"icon":1089},"\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fresolvers",{"title":5,"description":1083},{"loc":1093},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fresolvers.md","docs\u002F5.x\u002Freference\u002Fkit\u002Fresolvers","dxUyOBUV7TM2XLmmdHWw1-hFdNqF8VZsLOZKzyeefQI",1792931645286]