[{"data":1,"prerenderedAt":2249},["ShallowReactive",2],{"navigation_docs":3,"-rpc-middlewares-fetch-metadata":399},[4,162,346],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":24},"RPC","icon-park-outline:lightning","\u002Frpc","01.rpc",[10,25,63,77,102,136],{"title":11,"icon":12,"redirect":7,"path":13,"stem":14,"children":15,"page":24},"Introduction","icon-park-outline:home","\u002Frpc\u002Fintroduction","01.rpc\u002F01.introduction",[16,20],{"title":17,"path":18,"stem":19},"Quick Start","\u002Frpc\u002Fintroduction\u002Fquick-start","01.rpc\u002F01.introduction\u002F02.quick-start",{"title":21,"path":22,"stem":23},"Manual Install","\u002Frpc\u002Fintroduction\u002Fmanual-install","01.rpc\u002F01.introduction\u002F03.manual-install",false,{"title":26,"icon":27,"path":28,"stem":29,"children":30,"page":24},"Server","icon-park-outline:server","\u002Frpc\u002Fserver","01.rpc\u002F02.server",[31,35,39,43,47,51,55,59],{"title":32,"path":33,"stem":34},"Routes","\u002Frpc\u002Fserver\u002Froutes","01.rpc\u002F02.server\u002F01.routes",{"title":36,"path":37,"stem":38},"Middleware","\u002Frpc\u002Fserver\u002Fmiddleware","01.rpc\u002F02.server\u002F02.middleware",{"title":40,"path":41,"stem":42},"Call Context","\u002Frpc\u002Fserver\u002Fcall-context","01.rpc\u002F02.server\u002F03.call-context",{"title":44,"path":45,"stem":46},"Headers","\u002Frpc\u002Fserver\u002Fheaders","01.rpc\u002F02.server\u002F04.headers",{"title":48,"path":49,"stem":50},"Error Handling","\u002Frpc\u002Fserver\u002Ferror-handling","01.rpc\u002F02.server\u002F05.error-handling",{"title":52,"path":53,"stem":54},"Validation","\u002Frpc\u002Fserver\u002Fvalidation","01.rpc\u002F02.server\u002F06.validation",{"title":56,"path":57,"stem":58},"JSON Round Trip","\u002Frpc\u002Fserver\u002Fjson-round-trip","01.rpc\u002F02.server\u002F07.json-round-trip",{"title":60,"path":61,"stem":62},"Drizzle Tables","\u002Frpc\u002Fserver\u002Fdrizzle-tables","01.rpc\u002F02.server\u002F08.drizzle-tables",{"title":64,"icon":65,"path":66,"stem":67,"children":68,"page":24},"Middlewares","icon-park-outline:link-one","\u002Frpc\u002Fmiddlewares","01.rpc\u002F03.middlewares",[69,73],{"title":70,"path":71,"stem":72},"fetchMetadata","\u002Frpc\u002Fmiddlewares\u002Ffetch-metadata","01.rpc\u002F03.middlewares\u002F01.fetch-metadata",{"title":74,"path":75,"stem":76},"syncRoutes","\u002Frpc\u002Fmiddlewares\u002Fsync-routes","01.rpc\u002F03.middlewares\u002F02.sync-routes",{"title":78,"icon":79,"path":80,"stem":81,"children":82,"page":24},"Client","icon-park-outline:computer","\u002Frpc\u002Fclient","01.rpc\u002F04.client",[83,87,91,94,98],{"title":84,"path":85,"stem":86},"Client Overview","\u002Frpc\u002Fclient\u002Fclient-overview","01.rpc\u002F04.client\u002F00.client-overview",{"title":88,"path":89,"stem":90},"Client Middleware","\u002Frpc\u002Fclient\u002Fclient-middleware","01.rpc\u002F04.client\u002F01.client-middleware",{"title":48,"path":92,"stem":93},"\u002Frpc\u002Fclient\u002Ferror-handling","01.rpc\u002F04.client\u002F02.error-handling",{"title":95,"path":96,"stem":97},"Batch Requests","\u002Frpc\u002Fclient\u002Fbatch","01.rpc\u002F04.client\u002F03.batch",{"title":99,"path":100,"stem":101},"Cancellation & Timeouts","\u002Frpc\u002Fclient\u002Fcancellation-timeouts","01.rpc\u002F04.client\u002F04.cancellation-timeouts",{"title":103,"redirect":104,"icon":105,"path":106,"stem":107,"children":108,"page":24},"Platforms","\u002Frpc\u002Fplatforms\u002Fnode-js","icon-park-outline:play","\u002Frpc\u002Fplatforms","01.rpc\u002F06.platforms",[109,112,116,120,124,128,132],{"title":110,"path":104,"stem":111},"Node.js","01.rpc\u002F06.platforms\u002F01.node-js",{"title":113,"path":114,"stem":115},"Bun","\u002Frpc\u002Fplatforms\u002Fbun","01.rpc\u002F06.platforms\u002F02.bun",{"title":117,"path":118,"stem":119},"AWS Lambda","\u002Frpc\u002Fplatforms\u002Faws-lambda","01.rpc\u002F06.platforms\u002F03.aws-lambda",{"title":121,"path":122,"stem":123},"Google Cloud Functions","\u002Frpc\u002Fplatforms\u002Fgoogle-cloud-functions","01.rpc\u002F06.platforms\u002F04.google-cloud-functions",{"title":125,"path":126,"stem":127},"Cloudflare Workers","\u002Frpc\u002Fplatforms\u002Fcloudflare","01.rpc\u002F06.platforms\u002F05.cloudflare",{"title":129,"path":130,"stem":131},"Vercel","\u002Frpc\u002Fplatforms\u002Fvercel","01.rpc\u002F06.platforms\u002F06.vercel",{"title":133,"path":134,"stem":135},"uWebSockets.js","\u002Frpc\u002Fplatforms\u002Fuwebsockets","01.rpc\u002F06.platforms\u002F07.uwebsockets",{"title":137,"icon":138,"path":139,"stem":140,"children":141,"page":24},"Devtools","icon-park-outline:tool","\u002Frpc\u002Fdevtools","01.rpc\u002F07.devtools",[142,146,150,154,158],{"title":143,"path":144,"stem":145},"Linter","\u002Frpc\u002Fdevtools\u002Flinter","01.rpc\u002F07.devtools\u002F01.linter",{"title":147,"path":148,"stem":149},"Vite","\u002Frpc\u002Fdevtools\u002Fvite","01.rpc\u002F07.devtools\u002F02.vite",{"title":151,"path":152,"stem":153},"Next.js","\u002Frpc\u002Fdevtools\u002Fnextjs","01.rpc\u002F07.devtools\u002F03.nextjs",{"title":155,"path":156,"stem":157},"CLI","\u002Frpc\u002Fdevtools\u002Fcli","01.rpc\u002F07.devtools\u002F04.cli",{"title":159,"path":160,"stem":161},"API Types","\u002Frpc\u002Fdevtools\u002Fapi-types","01.rpc\u002F07.devtools\u002F05.api-types",{"title":163,"icon":164,"path":165,"stem":166,"children":167,"page":24},"RunTypes","i-lucide-braces","\u002Fruntypes","02.runtypes",[168,184,224,254,268,290,332],{"title":11,"icon":169,"redirect":165,"path":170,"stem":171,"children":172,"page":24},"i-lucide-rocket","\u002Fruntypes\u002Fintroduction","02.runtypes\u002F01.introduction",[173,177,180],{"title":174,"path":175,"stem":176},"Built on typescript-go","\u002Fruntypes\u002Fintroduction\u002Fbuilt-on-typescript-go","02.runtypes\u002F01.introduction\u002F02.built-on-typescript-go",{"title":17,"path":178,"stem":179},"\u002Fruntypes\u002Fintroduction\u002Fquick-start","02.runtypes\u002F01.introduction\u002F03.quick-start",{"title":181,"path":182,"stem":183},"Configuration","\u002Fruntypes\u002Fintroduction\u002Fconfiguration","02.runtypes\u002F01.introduction\u002F04.configuration",{"title":185,"icon":186,"redirect":187,"path":188,"stem":189,"children":190,"page":24},"Guide","i-lucide-book-open","\u002Fruntypes\u002Fguide\u002Ftype-builders","\u002Fruntypes\u002Fguide","02.runtypes\u002F02.guide",[191,194,198,201,204,208,212,216,220],{"title":192,"path":187,"stem":193},"Types vs Type Builders","02.runtypes\u002F02.guide\u002F01.type-builders",{"title":195,"path":196,"stem":197},"Reflection","\u002Fruntypes\u002Fguide\u002Freflection","02.runtypes\u002F02.guide\u002F02.reflection",{"title":52,"path":199,"stem":200},"\u002Fruntypes\u002Fguide\u002Fvalidation","02.runtypes\u002F02.guide\u002F03.validation",{"title":56,"path":202,"stem":203},"\u002Fruntypes\u002Fguide\u002Fjson-round-trip","02.runtypes\u002F02.guide\u002F04.json-round-trip",{"title":205,"path":206,"stem":207},"Data Mocking","\u002Fruntypes\u002Fguide\u002Fmocking","02.runtypes\u002F02.guide\u002F07.mocking",{"title":209,"path":210,"stem":211},"JSON Schemas","\u002Fruntypes\u002Fguide\u002Fjson-schemas","02.runtypes\u002F02.guide\u002F08.json-schemas",{"title":213,"path":214,"stem":215},"Pure Functions","\u002Fruntypes\u002Fguide\u002Fpure-functions","02.runtypes\u002F02.guide\u002F09.pure-functions",{"title":217,"path":218,"stem":219},"Compiler Markers","\u002Fruntypes\u002Fguide\u002Fcompiler-markers","02.runtypes\u002F02.guide\u002F10.compiler-markers",{"title":221,"path":222,"stem":223},"All Compiled Functions","\u002Fruntypes\u002Fguide\u002Fall-compiled-functions","02.runtypes\u002F02.guide\u002F11.all-compiled-functions",{"title":225,"icon":226,"redirect":227,"path":228,"stem":229,"children":230,"page":24},"Type Formats","i-lucide-shapes","\u002Fruntypes\u002Ftype-formats\u002Foverview","\u002Fruntypes\u002Ftype-formats","02.runtypes\u002F03.type-formats",[231,234,238,242,246,250],{"title":232,"path":227,"stem":233},"Overview","02.runtypes\u002F03.type-formats\u002F01.overview",{"title":235,"path":236,"stem":237},"String Formats","\u002Fruntypes\u002Ftype-formats\u002Fstring","02.runtypes\u002F03.type-formats\u002F02.string",{"title":239,"path":240,"stem":241},"Number Formats","\u002Fruntypes\u002Ftype-formats\u002Fnumber","02.runtypes\u002F03.type-formats\u002F03.number",{"title":243,"path":244,"stem":245},"BigInt Formats","\u002Fruntypes\u002Ftype-formats\u002Fbigint","02.runtypes\u002F03.type-formats\u002F04.bigint",{"title":247,"path":248,"stem":249},"Date and Time Formats","\u002Fruntypes\u002Ftype-formats\u002Fdate-time","02.runtypes\u002F03.type-formats\u002F05.date-time",{"title":251,"path":252,"stem":253},"Collection Formats","\u002Fruntypes\u002Ftype-formats\u002Fcollections","02.runtypes\u002F03.type-formats\u002F06.collections",{"title":255,"icon":256,"redirect":257,"path":258,"stem":259,"children":260,"page":24},"Tooling","i-lucide-wrench","\u002Fruntypes\u002Ftooling\u002Flinting","\u002Fruntypes\u002Ftooling","02.runtypes\u002F04.tooling",[261,264],{"title":262,"path":257,"stem":263},"Linting","02.runtypes\u002F04.tooling\u002F01.linting",{"title":265,"path":266,"stem":267},"Source Conversion","\u002Fruntypes\u002Ftooling\u002Fsource-conversion","02.runtypes\u002F04.tooling\u002F02.source-conversion",{"title":269,"icon":270,"redirect":271,"path":272,"stem":273,"children":274,"page":24},"AI Integration","i-lucide-sparkles","\u002Fruntypes\u002Fai-integration\u002Fworkflow-and-commands","\u002Fruntypes\u002Fai-integration","02.runtypes\u002F05.ai-integration",[275,278,282,286],{"title":276,"path":271,"stem":277},"AI Workflow","02.runtypes\u002F05.ai-integration\u002F01.workflow-and-commands",{"title":279,"path":280,"stem":281},"FriendlyText","\u002Fruntypes\u002Fai-integration\u002Ffriendly-text","02.runtypes\u002F05.ai-integration\u002F02.friendly-text",{"title":283,"path":284,"stem":285},"MockData","\u002Fruntypes\u002Fai-integration\u002Fmock-data","02.runtypes\u002F05.ai-integration\u002F03.mock-data",{"title":287,"path":288,"stem":289},"Translations (i18n)","\u002Fruntypes\u002Fai-integration\u002Fi18n","02.runtypes\u002F05.ai-integration\u002F04.i18n",{"title":291,"icon":292,"redirect":293,"path":294,"stem":295,"children":296,"page":24},"Drizzle ORM","i-lineicons-drizzle","\u002Fruntypes\u002Fdrizzle-orm\u002Fdrizzle-overview","\u002Fruntypes\u002Fdrizzle-orm","02.runtypes\u002F06.drizzle-orm",[297,300,304,308,312,316,320,324,328],{"title":298,"path":293,"stem":299},"Drizzle Overview","02.runtypes\u002F06.drizzle-orm\u002F00.drizzle-overview",{"title":301,"path":302,"stem":303},"Column Formats","\u002Fruntypes\u002Fdrizzle-orm\u002Fcolumn-formats","02.runtypes\u002F06.drizzle-orm\u002F01.column-formats",{"title":305,"path":306,"stem":307},"Views","\u002Fruntypes\u002Fdrizzle-orm\u002Fviews","02.runtypes\u002F06.drizzle-orm\u002F02.views",{"title":309,"path":310,"stem":311},"Indexes and Constraints","\u002Fruntypes\u002Fdrizzle-orm\u002Fconstraints","02.runtypes\u002F06.drizzle-orm\u002F03.constraints",{"title":313,"path":314,"stem":315},"Row Level Security","\u002Fruntypes\u002Fdrizzle-orm\u002Frow-level-security","02.runtypes\u002F06.drizzle-orm\u002F04.row-level-security",{"title":317,"path":318,"stem":319},"Relations","\u002Fruntypes\u002Fdrizzle-orm\u002Frelations","02.runtypes\u002F06.drizzle-orm\u002F05.relations",{"title":321,"path":322,"stem":323},"The Schema File","\u002Fruntypes\u002Fdrizzle-orm\u002Fschema-file","02.runtypes\u002F06.drizzle-orm\u002F06.schema-file",{"title":325,"path":326,"stem":327},"Migrate an Existing Schema","\u002Fruntypes\u002Fdrizzle-orm\u002Fmigrate-an-existing-schema","02.runtypes\u002F06.drizzle-orm\u002F07.migrate-an-existing-schema",{"title":329,"path":330,"stem":331},"Cloudflare D1 and Durable Objects","\u002Fruntypes\u002Fdrizzle-orm\u002Fcloudflare-storage","02.runtypes\u002F06.drizzle-orm\u002F08.cloudflare-storage",{"title":333,"icon":334,"redirect":335,"path":336,"stem":337,"children":338,"page":24},"Diagnostics","i-lucide-triangle-alert","\u002Fruntypes\u002Fdiagnostics\u002Ferror-levels","\u002Fruntypes\u002Fdiagnostics","02.runtypes\u002F08.diagnostics",[339,342],{"title":340,"path":335,"stem":341},"Error Levels","02.runtypes\u002F08.diagnostics\u002F01.error-levels",{"title":343,"path":344,"stem":345},"All Diagnostics","\u002Fruntypes\u002Fdiagnostics\u002Fall-diagnostics","02.runtypes\u002F08.diagnostics\u002F02.all-diagnostics",{"title":347,"icon":348,"path":349,"stem":350,"children":351,"page":24},"Benchmarks","i-lucide-gauge","\u002Fbenchmarks","03.benchmarks",[352,372],{"title":5,"icon":6,"redirect":353,"path":354,"stem":355,"children":356,"page":24},"\u002Fbenchmarks\u002Frpc\u002Fhello-world","\u002Fbenchmarks\u002Frpc","03.benchmarks\u002F02.rpc",[357,360,364,368],{"title":358,"path":353,"stem":359},"Hello World","03.benchmarks\u002F02.rpc\u002F01.hello-world",{"title":361,"path":362,"stem":363},"Light Validation","\u002Fbenchmarks\u002Frpc\u002Flight-validation","03.benchmarks\u002F02.rpc\u002F02.light-validation",{"title":365,"path":366,"stem":367},"Heavy Validation","\u002Fbenchmarks\u002Frpc\u002Fheavy-validation","03.benchmarks\u002F02.rpc\u002F03.heavy-validation",{"title":369,"path":370,"stem":371},"Payload Sizes","\u002Fbenchmarks\u002Frpc\u002Fpayload-sizes","03.benchmarks\u002F02.rpc\u002F04.payload-sizes",{"title":163,"icon":164,"redirect":373,"path":374,"stem":375,"children":376,"page":24},"\u002Fbenchmarks\u002Fruntypes\u002Fis-valid","\u002Fbenchmarks\u002Fruntypes","03.benchmarks\u002F03.runtypes",[377,380,384,388,392,395],{"title":378,"path":373,"stem":379},"Is Valid","03.benchmarks\u002F03.runtypes\u002F01.is-valid",{"title":381,"path":382,"stem":383},"Is Valid Formats","\u002Fbenchmarks\u002Fruntypes\u002Fis-valid-formats","03.benchmarks\u002F03.runtypes\u002F02.is-valid-formats",{"title":385,"path":386,"stem":387},"Get Errors","\u002Fbenchmarks\u002Fruntypes\u002Fget-errors","03.benchmarks\u002F03.runtypes\u002F03.get-errors",{"title":389,"path":390,"stem":391},"Get Errors Formats","\u002Fbenchmarks\u002Fruntypes\u002Fget-errors-formats","03.benchmarks\u002F03.runtypes\u002F04.get-errors-formats",{"title":56,"path":393,"stem":394},"\u002Fbenchmarks\u002Fruntypes\u002Fjson-round-trip","03.benchmarks\u002F03.runtypes\u002F05.json-round-trip",{"title":396,"path":397,"stem":398},"Type Checking","\u002Fbenchmarks\u002Fruntypes\u002Ftype-checking","03.benchmarks\u002F03.runtypes\u002F07.type-checking",{"id":400,"title":70,"body":401,"description":407,"extension":2244,"links":2245,"meta":2246,"navigation":602,"path":71,"seo":2247,"stem":72,"__hash__":2248},"docs\u002F01.rpc\u002F03.middlewares\u002F01.fetch-metadata.md",{"type":402,"value":403,"toc":2242},"minimark",[404,408,411,414,424,427,431,2238],[405,406,407],"p",{},"Fetch route metadata from the server instead of bundling it in the client.",[405,409,410],{},"Route metadata is what the client needs to call a route: its param and return types, its options, and its validation and JSON round trip functions. By default, the mion build plugin bundles it into your client code.",[405,412,413],{},"Use this middleware when:",[415,416,417,421],"ul",{},[418,419,420],"li",{},"You don't want the routes metadata in the client bundle, for example to keep the bundle small for a large API.",[418,422,423],{},"Your client is built in a separate project from your server, or without the mion build plugin.",[405,425,426],{},"When you deploy a server that changes a route, the client fetches it again, with no client rebuild.",[428,429,430],"warning",{},"A client that fetches metadata builds the validation and JSON round trip functions at runtime, so a strict Content Security Policy blocks it. A client built without the mion build plugin cannot send batches.",[432,433,434,982],"tabs",{},[435,436,437],"tabs-item",{"label":26},[438,439,442,447,450,510,514,524,793,797,801,804,846,850,853,857,861,868,903,907,917],"div",{"className":440},[441],"tab-body",[443,444,446],"h2",{"id":445},"getting-route-metadata","Getting Route Metadata",[405,448,449],{},"A fetched client gets the server's own compiled functions, so they always match it.",[451,452,453,469],"table",{},[454,455,456],"thead",{},[457,458,459,463,466],"tr",{},[460,461,462],"th",{},"Mode",[460,464,465],{},"How the client gets it",[460,467,468],{},"What you set up",[470,471,472,484],"tbody",{},[457,473,474,478,481],{},[475,476,477],"td",{},"Bundled (default)",[475,479,480],{},"The build ships it with the client, for every route the client calls.",[475,482,483],{},"Nothing.",[457,485,486,489,497],{},[475,487,488],{},"Fetched",[475,490,491,492,496],{},"The ",[493,494,495],"code",{},"mionFetchMetadata"," middleware sends it on a route's first call, and the client saves it.",[475,498,499,504,505,509],{},[500,501,503],"a",{"href":502},"#adding-the-middleware","The middleware"," and ",[500,506,508],{"href":507},"#disabling-routes-metadata-bundling","the client setup",".",[443,511,513],{"id":512},"adding-the-middleware","Adding the Middleware",[405,515,516,517,519,520,523],{},"Import ",[493,518,495],{}," from ",[493,521,522],{},"@mionjs\u002Frouter\u002Fmiddlewares"," and add it to your routes. Only an API whose clients fetch metadata needs it.",[525,526,532],"pre",{"className":527,"code":528,"filename":529,"language":530,"meta":531,"style":531},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import {createMionRouter, Routes} from '@mionjs\u002Frouter';\nimport {mionFetchMetadata} from '@mionjs\u002Frouter\u002Fmiddlewares';\n\nconst mion = createMionRouter();\n\nconst routes = {\n  \u002F\u002F at the root, before any route or group, or the router refuses it\n  mionFetchMetadata,\n  sayHello: mion.route((ctx, name: string): string => `Hello ${name}`),\n} satisfies Routes;\n\nconst myApi = mion.initRoutes(routes);\n\nexport type MyApi = typeof myApi;\n","server.routes.ts","ts","",[493,533,534,576,597,604,626,631,644,651,660,726,738,743,765,770],{"__ignoreMap":531},[535,536,539,543,547,551,554,557,560,563,566,570,573],"span",{"class":537,"line":538},"line",1,[535,540,542],{"class":541},"s7zQu","import",[535,544,546],{"class":545},"sMK4o"," {",[535,548,550],{"class":549},"sTEyZ","createMionRouter",[535,552,553],{"class":545},",",[535,555,556],{"class":549}," Routes",[535,558,559],{"class":545},"}",[535,561,562],{"class":541}," from",[535,564,565],{"class":545}," '",[535,567,569],{"class":568},"sfazB","@mionjs\u002Frouter",[535,571,572],{"class":545},"'",[535,574,575],{"class":545},";\n",[535,577,579,581,583,585,587,589,591,593,595],{"class":537,"line":578},2,[535,580,542],{"class":541},[535,582,546],{"class":545},[535,584,495],{"class":549},[535,586,559],{"class":545},[535,588,562],{"class":541},[535,590,565],{"class":545},[535,592,522],{"class":568},[535,594,572],{"class":545},[535,596,575],{"class":545},[535,598,600],{"class":537,"line":599},3,[535,601,603],{"emptyLinePlaceholder":602},true,"\n",[535,605,607,611,614,617,621,624],{"class":537,"line":606},4,[535,608,610],{"class":609},"spNyl","const",[535,612,613],{"class":549}," mion ",[535,615,616],{"class":545},"=",[535,618,620],{"class":619},"s2Zo4"," createMionRouter",[535,622,623],{"class":549},"()",[535,625,575],{"class":545},[535,627,629],{"class":537,"line":628},5,[535,630,603],{"emptyLinePlaceholder":602},[535,632,634,636,639,641],{"class":537,"line":633},6,[535,635,610],{"class":609},[535,637,638],{"class":549}," routes ",[535,640,616],{"class":545},[535,642,643],{"class":545}," {\n",[535,645,647],{"class":537,"line":646},7,[535,648,650],{"class":649},"sHwdD","  \u002F\u002F at the root, before any route or group, or the router refuses it\n",[535,652,654,657],{"class":537,"line":653},8,[535,655,656],{"class":549},"  mionFetchMetadata",[535,658,659],{"class":545},",\n",[535,661,663,667,670,673,675,678,681,683,687,689,692,694,698,701,703,706,709,712,715,718,721,724],{"class":537,"line":662},9,[535,664,666],{"class":665},"swJcz","  sayHello",[535,668,669],{"class":545},":",[535,671,672],{"class":549}," mion",[535,674,509],{"class":545},[535,676,677],{"class":619},"route",[535,679,680],{"class":549},"(",[535,682,680],{"class":545},[535,684,686],{"class":685},"sHdIc","ctx",[535,688,553],{"class":545},[535,690,691],{"class":685}," name",[535,693,669],{"class":545},[535,695,697],{"class":696},"sBMFI"," string",[535,699,700],{"class":545},"):",[535,702,697],{"class":696},[535,704,705],{"class":609}," =>",[535,707,708],{"class":545}," `",[535,710,711],{"class":568},"Hello ",[535,713,714],{"class":545},"${",[535,716,717],{"class":549},"name",[535,719,720],{"class":545},"}`",[535,722,723],{"class":549},")",[535,725,659],{"class":545},[535,727,729,731,734,736],{"class":537,"line":728},10,[535,730,559],{"class":545},[535,732,733],{"class":541}," satisfies",[535,735,556],{"class":696},[535,737,575],{"class":545},[535,739,741],{"class":537,"line":740},11,[535,742,603],{"emptyLinePlaceholder":602},[535,744,746,748,751,753,755,757,760,763],{"class":537,"line":745},12,[535,747,610],{"class":609},[535,749,750],{"class":549}," myApi ",[535,752,616],{"class":545},[535,754,672],{"class":549},[535,756,509],{"class":545},[535,758,759],{"class":619},"initRoutes",[535,761,762],{"class":549},"(routes)",[535,764,575],{"class":545},[535,766,768],{"class":537,"line":767},13,[535,769,603],{"emptyLinePlaceholder":602},[535,771,773,776,779,782,785,788,791],{"class":537,"line":772},14,[535,774,775],{"class":541},"export",[535,777,778],{"class":609}," type",[535,780,781],{"class":696}," MyApi",[535,783,784],{"class":545}," =",[535,786,787],{"class":545}," typeof",[535,789,790],{"class":549}," myApi",[535,792,575],{"class":545},[794,795,796],"tip",{},"It runs only when a request asks for metadata, so other calls cost nothing.",[443,798,800],{"id":799},"what-the-middleware-answers","What the Middleware Answers",[405,802,803],{},"Given a list of route ids, it returns the metadata of each route and of every middleware that runs with it.",[451,805,806,816],{},[454,807,808],{},[457,809,810,813],{},[460,811,812],{},"It describes",[460,814,815],{},"It never describes",[470,817,818,826,838],{},[457,819,820,823],{},[475,821,822],{},"Every route",[475,824,825],{},"Your handler code",[457,827,828,831],{},[475,829,830],{},"Middleware that takes params or headers, or returns data",[475,832,833,837],{},[500,834,836],{"href":835},"\u002Frpc\u002Fserver\u002Fmiddleware#raw-middleware","Raw middleware",", and middleware with no params and no return data",[457,839,840,843],{},[475,841,842],{},"The compiled validation and JSON round trip functions of those",[475,844,845],{},"mion's internal routes",[443,847,849],{"id":848},"why-metadata-is-public","Why Metadata Is Public",[405,851,852],{},"Any client can ask for any route's metadata, without logging in. A client with bundled metadata has the same metadata in its JavaScript. Treat it like a public API schema: it shows your types, never your data.",[854,855,856],"note",{},"Route metadata is not access control. Protect your routes with your own middleware.",[443,858,860],{"id":859},"listing-every-method","Listing Every Method",[405,862,863,864,867],{},"A client written without mion can POST this body to any route path to list every public route and middleware, and the ids of your ",[500,865,866],{"href":96},"batches",", so it can call a batch by id. The route at that path does not run.",[525,869,873],{"className":870,"code":871,"language":872,"meta":531,"style":531},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\"mionFetchMetadata\": [[], \"all\"]}\n","json",[493,874,875],{"__ignoreMap":531},[535,876,877,880,883,885,887,889,892,895,898,900],{"class":537,"line":538},[535,878,879],{"class":545},"{",[535,881,882],{"class":545},"\"",[535,884,495],{"class":609},[535,886,882],{"class":545},[535,888,669],{"class":545},[535,890,891],{"class":545}," [[],",[535,893,894],{"class":545}," \"",[535,896,897],{"class":568},"all",[535,899,882],{"class":545},[535,901,902],{"class":545},"]}\n",[443,904,906],{"id":905},"method-list-limit","Method List Limit",[405,908,909,910,913,914,509],{},"When the API has more routes and middleware than the ",[493,911,912],{},"getAllRemoteMethodsMaxNumber"," router option, you get no full list: the answer has only the ids you sent, no batch ids, and ",[493,915,916],{},"truncated: true",[525,918,920],{"className":527,"code":919,"language":530,"meta":531,"style":531},"import {createMionRouter} from '@mionjs\u002Frouter';\n\n\u002F\u002F list up to 200 methods when a client asks for all of them (100 by default)\nexport const mion = createMionRouter({getAllRemoteMethodsMaxNumber: 200});\n",[493,921,922,942,946,951],{"__ignoreMap":531},[535,923,924,926,928,930,932,934,936,938,940],{"class":537,"line":538},[535,925,542],{"class":541},[535,927,546],{"class":545},[535,929,550],{"class":549},[535,931,559],{"class":545},[535,933,562],{"class":541},[535,935,565],{"class":545},[535,937,569],{"class":568},[535,939,572],{"class":545},[535,941,575],{"class":545},[535,943,944],{"class":537,"line":578},[535,945,603],{"emptyLinePlaceholder":602},[535,947,948],{"class":537,"line":599},[535,949,950],{"class":649},"\u002F\u002F list up to 200 methods when a client asks for all of them (100 by default)\n",[535,952,953,955,958,960,962,964,966,968,970,972,976,978,980],{"class":537,"line":606},[535,954,775],{"class":541},[535,956,957],{"class":609}," const",[535,959,613],{"class":549},[535,961,616],{"class":545},[535,963,620],{"class":619},[535,965,680],{"class":549},[535,967,879],{"class":545},[535,969,912],{"class":665},[535,971,669],{"class":545},[535,973,975],{"class":974},"sbssI"," 200",[535,977,559],{"class":545},[535,979,723],{"class":549},[535,981,575],{"class":545},[435,983,984],{"label":78},[438,985,987,991,1013,1373,1437,1451,1455,1465,1510,1514,1517,1574,1577,1581,1588,1804,1851,1860,1867,1871,1899,2063,2074,2078,2096,2137,2149,2153,2158],{"className":986},[441],[443,988,990],{"id":989},"disabling-routes-metadata-bundling","Disabling Routes Metadata Bundling",[405,992,993,994,997,998,1001,1002,1005,1006,1009,1010,509],{},"Set ",[493,995,996],{},"client: {routes: 'fetch'}"," in your client build, then call ",[493,999,1000],{},"useFetchMetadata"," once, next to ",[493,1003,1004],{},"initClient",", with the client's ",[493,1007,1008],{},"middlewares.mionFetchMetadata",". The server must also ",[500,1011,1012],{"href":502},"add the middleware",[1014,1015,1016,1157],"code-split",{},[525,1017,1020],{"className":527,"code":1018,"filename":1019,"language":530,"meta":531,"style":531},"import {defineConfig} from 'vite';\nimport {mionVitePlugin} from '@mionjs\u002Fdevtools\u002Fvite';\n\nexport default defineConfig({\n  plugins: [\n    mionVitePlugin({\n      \u002F\u002F fetch each route's metadata from the server on first use\n      client: {routes: 'fetch'},\n    }),\n  ],\n});\n","vite.config.ts",[493,1021,1022,1044,1066,1070,1085,1095,1104,1109,1133,1142,1149],{"__ignoreMap":531},[535,1023,1024,1026,1028,1031,1033,1035,1037,1040,1042],{"class":537,"line":538},[535,1025,542],{"class":541},[535,1027,546],{"class":545},[535,1029,1030],{"class":549},"defineConfig",[535,1032,559],{"class":545},[535,1034,562],{"class":541},[535,1036,565],{"class":545},[535,1038,1039],{"class":568},"vite",[535,1041,572],{"class":545},[535,1043,575],{"class":545},[535,1045,1046,1048,1050,1053,1055,1057,1059,1062,1064],{"class":537,"line":578},[535,1047,542],{"class":541},[535,1049,546],{"class":545},[535,1051,1052],{"class":549},"mionVitePlugin",[535,1054,559],{"class":545},[535,1056,562],{"class":541},[535,1058,565],{"class":545},[535,1060,1061],{"class":568},"@mionjs\u002Fdevtools\u002Fvite",[535,1063,572],{"class":545},[535,1065,575],{"class":545},[535,1067,1068],{"class":537,"line":599},[535,1069,603],{"emptyLinePlaceholder":602},[535,1071,1072,1074,1077,1080,1082],{"class":537,"line":606},[535,1073,775],{"class":541},[535,1075,1076],{"class":541}," default",[535,1078,1079],{"class":619}," defineConfig",[535,1081,680],{"class":549},[535,1083,1084],{"class":545},"{\n",[535,1086,1087,1090,1092],{"class":537,"line":628},[535,1088,1089],{"class":665},"  plugins",[535,1091,669],{"class":545},[535,1093,1094],{"class":549}," [\n",[535,1096,1097,1100,1102],{"class":537,"line":633},[535,1098,1099],{"class":619},"    mionVitePlugin",[535,1101,680],{"class":549},[535,1103,1084],{"class":545},[535,1105,1106],{"class":537,"line":646},[535,1107,1108],{"class":649},"      \u002F\u002F fetch each route's metadata from the server on first use\n",[535,1110,1111,1114,1116,1118,1121,1123,1125,1128,1130],{"class":537,"line":653},[535,1112,1113],{"class":665},"      client",[535,1115,669],{"class":545},[535,1117,546],{"class":545},[535,1119,1120],{"class":665},"routes",[535,1122,669],{"class":545},[535,1124,565],{"class":545},[535,1126,1127],{"class":568},"fetch",[535,1129,572],{"class":545},[535,1131,1132],{"class":545},"},\n",[535,1134,1135,1138,1140],{"class":537,"line":662},[535,1136,1137],{"class":545},"    }",[535,1139,723],{"class":549},[535,1141,659],{"class":545},[535,1143,1144,1147],{"class":537,"line":728},[535,1145,1146],{"class":549},"  ]",[535,1148,659],{"class":545},[535,1150,1151,1153,1155],{"class":537,"line":740},[535,1152,559],{"class":545},[535,1154,723],{"class":549},[535,1156,575],{"class":545},[525,1158,1161],{"className":527,"code":1159,"filename":1160,"language":530,"meta":531,"style":531},"import {initClient} from '@mionjs\u002Fclient';\nimport {useFetchMetadata} from '@mionjs\u002Fclient\u002Fmiddlewares';\nimport type {MyApi} from '.\u002Fmetadata-fetch.routes.ts';\n\nconst {routes, middlewares} = initClient\u003CMyApi>({\n  baseURL: 'http:\u002F\u002Flocalhost:3000',\n});\nuseFetchMetadata(middlewares.mionFetchMetadata);\n\n\u002F\u002F the first call also fetches the metadata of sayHello\nconst [greeting] = await routes.sayHello('Ana').call();\nconsole.log(greeting);\n","client.ts",[493,1162,1163,1184,1205,1229,1233,1265,1281,1289,1303,1307,1312,1358],{"__ignoreMap":531},[535,1164,1165,1167,1169,1171,1173,1175,1177,1180,1182],{"class":537,"line":538},[535,1166,542],{"class":541},[535,1168,546],{"class":545},[535,1170,1004],{"class":549},[535,1172,559],{"class":545},[535,1174,562],{"class":541},[535,1176,565],{"class":545},[535,1178,1179],{"class":568},"@mionjs\u002Fclient",[535,1181,572],{"class":545},[535,1183,575],{"class":545},[535,1185,1186,1188,1190,1192,1194,1196,1198,1201,1203],{"class":537,"line":578},[535,1187,542],{"class":541},[535,1189,546],{"class":545},[535,1191,1000],{"class":549},[535,1193,559],{"class":545},[535,1195,562],{"class":541},[535,1197,565],{"class":545},[535,1199,1200],{"class":568},"@mionjs\u002Fclient\u002Fmiddlewares",[535,1202,572],{"class":545},[535,1204,575],{"class":545},[535,1206,1207,1209,1211,1213,1216,1218,1220,1222,1225,1227],{"class":537,"line":599},[535,1208,542],{"class":541},[535,1210,778],{"class":541},[535,1212,546],{"class":545},[535,1214,1215],{"class":549},"MyApi",[535,1217,559],{"class":545},[535,1219,562],{"class":541},[535,1221,565],{"class":545},[535,1223,1224],{"class":568},".\u002Fmetadata-fetch.routes.ts",[535,1226,572],{"class":545},[535,1228,575],{"class":545},[535,1230,1231],{"class":537,"line":606},[535,1232,603],{"emptyLinePlaceholder":602},[535,1234,1235,1237,1239,1241,1243,1246,1248,1250,1253,1256,1258,1261,1263],{"class":537,"line":628},[535,1236,610],{"class":609},[535,1238,546],{"class":545},[535,1240,1120],{"class":549},[535,1242,553],{"class":545},[535,1244,1245],{"class":549}," middlewares",[535,1247,559],{"class":545},[535,1249,784],{"class":545},[535,1251,1252],{"class":619}," initClient",[535,1254,1255],{"class":545},"\u003C",[535,1257,1215],{"class":696},[535,1259,1260],{"class":545},">",[535,1262,680],{"class":549},[535,1264,1084],{"class":545},[535,1266,1267,1270,1272,1274,1277,1279],{"class":537,"line":633},[535,1268,1269],{"class":665},"  baseURL",[535,1271,669],{"class":545},[535,1273,565],{"class":545},[535,1275,1276],{"class":568},"http:\u002F\u002Flocalhost:3000",[535,1278,572],{"class":545},[535,1280,659],{"class":545},[535,1282,1283,1285,1287],{"class":537,"line":646},[535,1284,559],{"class":545},[535,1286,723],{"class":549},[535,1288,575],{"class":545},[535,1290,1291,1293,1296,1298,1301],{"class":537,"line":653},[535,1292,1000],{"class":619},[535,1294,1295],{"class":549},"(middlewares",[535,1297,509],{"class":545},[535,1299,1300],{"class":549},"mionFetchMetadata)",[535,1302,575],{"class":545},[535,1304,1305],{"class":537,"line":662},[535,1306,603],{"emptyLinePlaceholder":602},[535,1308,1309],{"class":537,"line":728},[535,1310,1311],{"class":649},"\u002F\u002F the first call also fetches the metadata of sayHello\n",[535,1313,1314,1316,1319,1322,1325,1327,1330,1333,1335,1338,1340,1342,1345,1347,1349,1351,1354,1356],{"class":537,"line":740},[535,1315,610],{"class":609},[535,1317,1318],{"class":545}," [",[535,1320,1321],{"class":549},"greeting",[535,1323,1324],{"class":545},"]",[535,1326,784],{"class":545},[535,1328,1329],{"class":541}," await",[535,1331,1332],{"class":549}," routes",[535,1334,509],{"class":545},[535,1336,1337],{"class":619},"sayHello",[535,1339,680],{"class":549},[535,1341,572],{"class":545},[535,1343,1344],{"class":568},"Ana",[535,1346,572],{"class":545},[535,1348,723],{"class":549},[535,1350,509],{"class":545},[535,1352,1353],{"class":619},"call",[535,1355,623],{"class":549},[535,1357,575],{"class":545},[535,1359,1360,1363,1365,1368,1371],{"class":537,"line":745},[535,1361,1362],{"class":549},"console",[535,1364,509],{"class":545},[535,1366,1367],{"class":619},"log",[535,1369,1370],{"class":549},"(greeting)",[535,1372,575],{"class":545},[451,1374,1375,1385],{},[454,1376,1377],{},[457,1378,1379,1382],{},[460,1380,1381],{},"Tool",[460,1383,1384],{},"Disable routes metadata bundling",[470,1386,1387,1399,1414,1427],{},[457,1388,1389,1395],{},[475,1390,1391],{},[500,1392,1394],{"href":1393},"\u002Frpc\u002Fdevtools\u002Fvite#all-plugin-options","Vite plugin",[475,1396,1397],{},[493,1398,996],{},[457,1400,1401,1410],{},[475,1402,1403,1406,1407],{},[500,1404,151],{"href":1405},"\u002Frpc\u002Fdevtools\u002Fnextjs#options"," ",[493,1408,1409],{},"withMion",[475,1411,1412],{},[493,1413,996],{},[457,1415,1416,1422],{},[475,1417,1418],{},[500,1419,1421],{"href":1420},"\u002Frpc\u002Fdevtools\u002Fcli#compiling-a-fetching-client","mion CLI",[475,1423,1424],{},[493,1425,1426],{},"--client-routes fetch",[457,1428,1429,1432],{},[475,1430,1431],{},"tsconfig plugin entry",[475,1433,1434],{},[493,1435,1436],{},"clientRoutes: 'fetch'",[854,1438,1439,1440,1443,1444,1450],{},"The code that fetches metadata is a separate file, downloaded only when a call first needs metadata. If it fails to load, the call gets ",[493,1441,1442],{},"metadata-load-error"," in its ",[500,1445,1447],{"href":1446},"\u002Frpc\u002Fclient\u002Ferror-handling#the-result-pattern",[493,1448,1449],{},"@thrownErrors",", and the next call tries again.",[443,1452,1454],{"id":1453},"fetching-only-what-the-build-misses","Fetching Only What the Build Misses",[405,1456,1457,1458,1460,1461,509],{},"If you keep bundling on and also call ",[493,1459,1000],{},", the client fetches metadata only for calls the build could not bundle: calls whose route a generic helper hides. Fetched metadata never replaces a bundled route. To keep every call bundled, see ",[500,1462,1464],{"href":1463},"\u002Frpc\u002Fdevtools\u002Fvite#generic-call-helpers","Generic Call Helpers",[451,1466,1467,1476],{},[454,1468,1469],{},[457,1470,1471,1473],{},[460,1472,78],{},[460,1474,1475],{},"A call whose route the build cannot see",[470,1477,1478,1494],{},[457,1479,1480,1485],{},[475,1481,1482,1483],{},"Without ",[493,1484,1000],{},[475,1486,1487,1488,1443,1491,1493],{},"Stops the build with rpc-client-route-id-widened. If it runs anyway, it gets ",[493,1489,1490],{},"route-metadata-not-found",[493,1492,1449],{},", naming the fix.",[457,1495,1496,1501],{},[475,1497,1498,1499],{},"With ",[493,1500,1000],{},[475,1502,1503,1504,509],{},"Fetches its metadata instead, so a strict Content Security Policy blocks it. The build reports rpc-client-route-id-widened-fetched, an Info message shown only with ",[500,1505,1507],{"href":1506},"\u002Fruntypes\u002Fdiagnostics\u002Ferror-levels#showing-info-messages",[493,1508,1509],{},"levels: 'all'",[443,1511,1513],{"id":1512},"the-first-call","The First Call",[405,1515,1516],{},"A route's first call goes out right away and asks for the metadata in the same request. The server validates the params and answers with the result and the metadata. The client saves the metadata, so later calls also validate in the browser before sending.",[451,1518,1519,1529],{},[454,1520,1521],{},[457,1522,1523,1526],{},[460,1524,1525],{},"Case",[460,1527,1528],{},"What the client does",[470,1530,1531,1543,1555,1566],{},[457,1532,1533,1540],{},[475,1534,1535,1536,1539],{},"Params that ",[493,1537,1538],{},"JSON.stringify"," cannot write",[475,1541,1542],{},"Fetches the metadata first, then sends the call.",[457,1544,1545,1552],{},[475,1546,1547,1548,1551],{},"A param that needs its type to be encoded, like a ",[493,1549,1550],{},"string | Date"," union",[475,1553,1554],{},"Sends the call once more with the right encoding. The route did not run.",[457,1556,1557,1563],{},[475,1558,1559,1562],{},[493,1560,1561],{},"typeErrors()"," on a route it has not seen",[475,1564,1565],{},"Fetches the metadata alone. The route does not run.",[457,1567,1568,1571],{},[475,1569,1570],{},"A saved copy that no longer matches the server",[475,1572,1573],{},"Drops the saved copy and sends the call once more.",[854,1575,1576],{},"The client sends a call again at most once, only when the server could not read or validate the params, and never after a mutation in that call succeeded. After the route's own error, a network error, a timeout or an abort, it never sends again.",[443,1578,1580],{"id":1579},"saving-fetched-metadata","Saving Fetched Metadata",[405,1582,1583,1584,1587],{},"The client saves what it fetched, per server, so a later visit does not ask again. Pick where with the ",[493,1585,1586],{},"storageEngine"," client option. Where the store cannot open, like on the server or in a browser that blocks IndexedDB, the client keeps it in memory.",[525,1589,1591],{"className":527,"code":1590,"filename":1160,"language":530,"meta":531,"style":531},"import {initClient, requestPersistentStorage} from '@mionjs\u002Fclient';\nimport {useFetchMetadata} from '@mionjs\u002Fclient\u002Fmiddlewares';\nimport type {MyApi} from '.\u002Fmetadata-fetch.routes.ts';\n\nconst {middlewares} = initClient\u003CMyApi>({\n  baseURL: 'http:\u002F\u002Flocalhost:3000',\n  storageEngine: 'indexeddb',\n});\nuseFetchMetadata(middlewares.mionFetchMetadata);\n\n\u002F\u002F ask the browser to keep the cache when it clears storage, best after a user action\ndocument\n  .querySelector('#settings')\n  ?.addEventListener('click', () => requestPersistentStorage());\n",[493,1592,1593,1618,1638,1660,1664,1689,1703,1719,1727,1739,1743,1748,1753,1773],{"__ignoreMap":531},[535,1594,1595,1597,1599,1601,1603,1606,1608,1610,1612,1614,1616],{"class":537,"line":538},[535,1596,542],{"class":541},[535,1598,546],{"class":545},[535,1600,1004],{"class":549},[535,1602,553],{"class":545},[535,1604,1605],{"class":549}," requestPersistentStorage",[535,1607,559],{"class":545},[535,1609,562],{"class":541},[535,1611,565],{"class":545},[535,1613,1179],{"class":568},[535,1615,572],{"class":545},[535,1617,575],{"class":545},[535,1619,1620,1622,1624,1626,1628,1630,1632,1634,1636],{"class":537,"line":578},[535,1621,542],{"class":541},[535,1623,546],{"class":545},[535,1625,1000],{"class":549},[535,1627,559],{"class":545},[535,1629,562],{"class":541},[535,1631,565],{"class":545},[535,1633,1200],{"class":568},[535,1635,572],{"class":545},[535,1637,575],{"class":545},[535,1639,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658],{"class":537,"line":599},[535,1641,542],{"class":541},[535,1643,778],{"class":541},[535,1645,546],{"class":545},[535,1647,1215],{"class":549},[535,1649,559],{"class":545},[535,1651,562],{"class":541},[535,1653,565],{"class":545},[535,1655,1224],{"class":568},[535,1657,572],{"class":545},[535,1659,575],{"class":545},[535,1661,1662],{"class":537,"line":606},[535,1663,603],{"emptyLinePlaceholder":602},[535,1665,1666,1668,1670,1673,1675,1677,1679,1681,1683,1685,1687],{"class":537,"line":628},[535,1667,610],{"class":609},[535,1669,546],{"class":545},[535,1671,1672],{"class":549},"middlewares",[535,1674,559],{"class":545},[535,1676,784],{"class":545},[535,1678,1252],{"class":619},[535,1680,1255],{"class":545},[535,1682,1215],{"class":696},[535,1684,1260],{"class":545},[535,1686,680],{"class":549},[535,1688,1084],{"class":545},[535,1690,1691,1693,1695,1697,1699,1701],{"class":537,"line":633},[535,1692,1269],{"class":665},[535,1694,669],{"class":545},[535,1696,565],{"class":545},[535,1698,1276],{"class":568},[535,1700,572],{"class":545},[535,1702,659],{"class":545},[535,1704,1705,1708,1710,1712,1715,1717],{"class":537,"line":646},[535,1706,1707],{"class":665},"  storageEngine",[535,1709,669],{"class":545},[535,1711,565],{"class":545},[535,1713,1714],{"class":568},"indexeddb",[535,1716,572],{"class":545},[535,1718,659],{"class":545},[535,1720,1721,1723,1725],{"class":537,"line":653},[535,1722,559],{"class":545},[535,1724,723],{"class":549},[535,1726,575],{"class":545},[535,1728,1729,1731,1733,1735,1737],{"class":537,"line":662},[535,1730,1000],{"class":619},[535,1732,1295],{"class":549},[535,1734,509],{"class":545},[535,1736,1300],{"class":549},[535,1738,575],{"class":545},[535,1740,1741],{"class":537,"line":728},[535,1742,603],{"emptyLinePlaceholder":602},[535,1744,1745],{"class":537,"line":740},[535,1746,1747],{"class":649},"\u002F\u002F ask the browser to keep the cache when it clears storage, best after a user action\n",[535,1749,1750],{"class":537,"line":745},[535,1751,1752],{"class":549},"document\n",[535,1754,1755,1758,1761,1763,1765,1768,1770],{"class":537,"line":767},[535,1756,1757],{"class":545},"  .",[535,1759,1760],{"class":619},"querySelector",[535,1762,680],{"class":549},[535,1764,572],{"class":545},[535,1766,1767],{"class":568},"#settings",[535,1769,572],{"class":545},[535,1771,1772],{"class":549},")\n",[535,1774,1775,1778,1781,1783,1785,1788,1790,1792,1795,1797,1799,1802],{"class":537,"line":772},[535,1776,1777],{"class":545},"  ?.",[535,1779,1780],{"class":619},"addEventListener",[535,1782,680],{"class":549},[535,1784,572],{"class":545},[535,1786,1787],{"class":568},"click",[535,1789,572],{"class":545},[535,1791,553],{"class":545},[535,1793,1794],{"class":545}," ()",[535,1796,705],{"class":609},[535,1798,1605],{"class":619},[535,1800,1801],{"class":549},"())",[535,1803,575],{"class":545},[451,1805,1806,1817],{},[454,1807,1808],{},[457,1809,1810,1814],{},[460,1811,1812],{},[493,1813,1586],{},[460,1815,1816],{},"Where it saves",[470,1818,1819,1830,1840],{},[457,1820,1821,1827],{},[475,1822,1823,1826],{},[493,1824,1825],{},"'indexeddb'"," (default)",[475,1828,1829],{},"The browser's IndexedDB, kept between visits.",[457,1831,1832,1837],{},[475,1833,1834],{},[493,1835,1836],{},"'memory'",[475,1838,1839],{},"Memory, for this page load or process only.",[457,1841,1842,1845],{},[475,1843,1844],{},"A function",[475,1846,1847,509],{},[500,1848,1850],{"href":1849},"#using-your-own-store","Your own store",[854,1852,1853,1854,1443,1857,1859],{},"Each server's cache holds up to 8 MB and drops its oldest entries first. If the browser still refuses a write, a later call gets a ",[493,1855,1856],{},"metadata-cache-error",[493,1858,1449],{},", once.",[794,1861,1862,1863,1866],{},"The browser can clear the cache (low disk space, or Safari after 7 days without a visit), and the client then fetches again. mion never shows a permission popup itself: call ",[493,1864,1865],{},"requestPersistentStorage()"," yourself, as in the example.",[443,1868,1870],{"id":1869},"using-your-own-store","Using Your Own Store",[405,1872,993,1873,1875,1876,519,1879,1881,1882,1885,1886,1885,1889,504,1892,1895,1896,509],{},[493,1874,1586],{}," to a function that opens your own store. The client calls it once. Your store implements ",[493,1877,1878],{},"MetadataStore",[493,1880,1179],{},": ",[493,1883,1884],{},"readAll",", ",[493,1887,1888],{},"write",[493,1890,1891],{},"remove",[493,1893,1894],{},"clear",", each for one server's ",[493,1897,1898],{},"baseURL",[525,1900,1902],{"className":527,"code":1901,"filename":1160,"language":530,"meta":531,"style":531},"import {initClient, type MetadataStore} from '@mionjs\u002Fclient';\nimport type {MyApi} from '.\u002Fmetadata-fetch.routes.ts';\n\n\u002F\u002F your app's own storage, like a native app's database\ndeclare function openAppStore(): Promise\u003CMetadataStore | undefined>;\n\nexport const {routes, middlewares} = initClient\u003CMyApi>({\n  baseURL: 'http:\u002F\u002Flocalhost:3000',\n  \u002F\u002F returning undefined keeps the cache in memory\n  storageEngine: openAppStore,\n});\n",[493,1903,1904,1931,1953,1957,1962,1992,1996,2026,2040,2045,2055],{"__ignoreMap":531},[535,1905,1906,1908,1910,1912,1914,1916,1919,1921,1923,1925,1927,1929],{"class":537,"line":538},[535,1907,542],{"class":541},[535,1909,546],{"class":545},[535,1911,1004],{"class":549},[535,1913,553],{"class":545},[535,1915,778],{"class":541},[535,1917,1918],{"class":549}," MetadataStore",[535,1920,559],{"class":545},[535,1922,562],{"class":541},[535,1924,565],{"class":545},[535,1926,1179],{"class":568},[535,1928,572],{"class":545},[535,1930,575],{"class":545},[535,1932,1933,1935,1937,1939,1941,1943,1945,1947,1949,1951],{"class":537,"line":578},[535,1934,542],{"class":541},[535,1936,778],{"class":541},[535,1938,546],{"class":545},[535,1940,1215],{"class":549},[535,1942,559],{"class":545},[535,1944,562],{"class":541},[535,1946,565],{"class":545},[535,1948,1224],{"class":568},[535,1950,572],{"class":545},[535,1952,575],{"class":545},[535,1954,1955],{"class":537,"line":599},[535,1956,603],{"emptyLinePlaceholder":602},[535,1958,1959],{"class":537,"line":606},[535,1960,1961],{"class":649},"\u002F\u002F your app's own storage, like a native app's database\n",[535,1963,1964,1967,1970,1973,1976,1979,1981,1983,1986,1989],{"class":537,"line":628},[535,1965,1966],{"class":609},"declare",[535,1968,1969],{"class":609}," function",[535,1971,1972],{"class":619}," openAppStore",[535,1974,1975],{"class":545},"():",[535,1977,1978],{"class":696}," Promise",[535,1980,1255],{"class":545},[535,1982,1878],{"class":696},[535,1984,1985],{"class":545}," |",[535,1987,1988],{"class":696}," undefined",[535,1990,1991],{"class":545},">;\n",[535,1993,1994],{"class":537,"line":633},[535,1995,603],{"emptyLinePlaceholder":602},[535,1997,1998,2000,2002,2004,2006,2008,2010,2012,2014,2016,2018,2020,2022,2024],{"class":537,"line":646},[535,1999,775],{"class":541},[535,2001,957],{"class":609},[535,2003,546],{"class":545},[535,2005,1120],{"class":549},[535,2007,553],{"class":545},[535,2009,1245],{"class":549},[535,2011,559],{"class":545},[535,2013,784],{"class":545},[535,2015,1252],{"class":619},[535,2017,1255],{"class":545},[535,2019,1215],{"class":696},[535,2021,1260],{"class":545},[535,2023,680],{"class":549},[535,2025,1084],{"class":545},[535,2027,2028,2030,2032,2034,2036,2038],{"class":537,"line":653},[535,2029,1269],{"class":665},[535,2031,669],{"class":545},[535,2033,565],{"class":545},[535,2035,1276],{"class":568},[535,2037,572],{"class":545},[535,2039,659],{"class":545},[535,2041,2042],{"class":537,"line":662},[535,2043,2044],{"class":649},"  \u002F\u002F returning undefined keeps the cache in memory\n",[535,2046,2047,2049,2051,2053],{"class":537,"line":728},[535,2048,1707],{"class":665},[535,2050,669],{"class":545},[535,2052,1972],{"class":549},[535,2054,659],{"class":545},[535,2056,2057,2059,2061],{"class":537,"line":740},[535,2058,559],{"class":545},[535,2060,723],{"class":549},[535,2062,575],{"class":545},[794,2064,2065,2067,2068,2070,2071,2073],{},[493,2066,1888],{}," must save the whole batch of records or reject. ",[493,2069,1884],{}," returns the records of that exact ",[493,2072,1898],{},", never a prefix match.",[443,2075,2077],{"id":2076},"api-version-check","API Version Check",[405,2079,2080,2082,2083,2086,2087,2090,2091,2095],{},[493,2081,495],{}," sends the server's API version in the ",[493,2084,2085],{},"x-build-version"," header of every response, and the client compares it with the version it was built with. A mismatch does not stop the call: reload the app or rebuild the client to fix it. Use ",[500,2088,2089],{"href":75},"mionSyncRoutes"," to stop such calls, or run ",[500,2092,2094],{"href":2093},"\u002Frpc\u002Fdevtools\u002Fcli#checking-a-client-against-its-server","mion api-check"," to catch a mismatch before you deploy.",[451,2097,2098,2107],{},[454,2099,2100],{},[457,2101,2102,2104],{},[460,2103,78],{},[460,2105,2106],{},"On a mismatch",[470,2108,2109,2125],{},[457,2110,2111,2115],{},[475,2112,1482,2113],{},[493,2114,1000],{},[475,2116,2117,2118,2121,2122,2124],{},"The call that sees it gets an ",[493,2119,2120],{},"api-version-mismatch"," error in its ",[493,2123,1449],{},", once per server.",[457,2126,2127,2131],{},[475,2128,1498,2129],{},[493,2130,1000],{},[475,2132,2133,2134,2136],{},"Each route is checked once, on its first call after the mismatch. A changed route whose metadata was fetched is fetched again. A changed bundled route gets ",[493,2135,2120],{},", naming the route.",[794,2138,1482,2139,2141,2142,2145,2146,2148],{},[493,2140,495],{},", or with ",[493,2143,2144],{},"apiVersionCheck: false"," in ",[493,2147,550],{},", the server sends no version and the client checks nothing.",[443,2150,2152],{"id":2151},"build-checks","Build Checks",[405,2154,2155,2156,509],{},"The build fails on a setup that would fail at runtime. Look up any name in ",[500,2157,343],{"href":344},[451,2159,2160,2170],{},[454,2161,2162],{},[457,2163,2164,2167],{},[460,2165,2166],{},"Name",[460,2168,2169],{},"When",[470,2171,2172,2183,2191,2199,2207,2215,2225],{},[457,2173,2174,2177],{},[475,2175,2176],{},"rpc-client-api-unreadable",[475,2178,2179,2180,509],{},"The client is not typed with ",[493,2181,2182],{},"PublicApi\u003Ctypeof routes>",[457,2184,2185,2188],{},[475,2186,2187],{},"rpc-client-route-not-declared",[475,2189,2190],{},"A call names a route the API type does not declare.",[457,2192,2193,2196],{},[475,2194,2195],{},"rpc-client-route-id-widened",[475,2197,2198],{},"A generic helper hides a call's route, and the client does not fetch metadata.",[457,2200,2201,2204],{},[475,2202,2203],{},"rpc-client-version-mismatch",[475,2205,2206],{},"A client and an API in one program are typed with different APIs.",[457,2208,2209,2212],{},[475,2210,2211],{},"rpc-client-middleware-not-set-up, rpc-client-optional-middleware-not-set-up",[475,2213,2214],{},"A called route runs a middleware the client never sets up.",[457,2216,2217,2220],{},[475,2218,2219],{},"rpc-client-no-metadata-route",[475,2221,2222,2223,509],{},"The client fetches metadata, but the API does not add ",[493,2224,495],{},[457,2226,2227,2230],{},[475,2228,2229],{},"rpc-client-fetch-not-set-up",[475,2231,2232,2233,2235,2236,509],{},"The client builds with ",[493,2234,996],{},", but never calls ",[493,2237,1000],{},[2239,2240,2241],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}",{"title":531,"searchDepth":578,"depth":578,"links":2243},[],"md",null,{},{"title":70,"description":407},"gtIQyDWw1iygFVlgcFvGhNSWpHLrTLyBY7J6JH7IX0U",1793324369975]