@lpdjs/firestore-repo-service 2.6.8 → 2.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/servers/hono/cli.cjs +52 -44
- package/dist/servers/hono/cli.cjs.map +1 -1
- package/dist/servers/hono/cli.js +52 -44
- package/dist/servers/hono/cli.js.map +1 -1
- package/dist/servers/hono/index.cjs +7 -7
- package/dist/servers/hono/index.cjs.map +1 -1
- package/dist/servers/hono/index.d.cts +553 -11
- package/dist/servers/hono/index.d.ts +553 -11
- package/dist/servers/hono/index.js +7 -7
- package/dist/servers/hono/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Hono}from'hono';import {getRequestListener}from'@hono/node-server';import {extendZodWithOpenApi,OpenAPIRegistry,OpenApiGeneratorV31}from'@asteasolutions/zod-to-openapi';import {z as z$1}from'zod';import {AsyncLocalStorage}from'async_hooks';import {readdirSync,statSync,mkdirSync,writeFileSync}from'fs';import {join,relative,sep,dirname}from'path';function
|
|
1
|
+
import {Hono}from'hono';import {getRequestListener}from'@hono/node-server';import {extendZodWithOpenApi,OpenAPIRegistry,OpenApiGeneratorV31}from'@asteasolutions/zod-to-openapi';import {z as z$1}from'zod';import {AsyncLocalStorage}from'async_hooks';import {readdirSync,statSync,mkdirSync,writeFileSync}from'fs';import {join,relative,sep,dirname}from'path';function Q(t){return t}var v=class extends Error{constructor(n,o){super("Request validation failed");this.zodError=n;this.source=o;this.statusCode=400;this.name="ValidationError";}};var T=class extends Error{constructor(n){super(n);this.statusCode=400;this.name="BadRequestError";}},S=class extends Error{constructor(n){super("Output validation failed");this.zodError=n;this.statusCode=500;this.name="OutputValidationError";}};function _(t){return t.issues.map(e=>({path:e.path.join("."),code:e.code,message:e.message}))}function E(t,e){return e instanceof v?t.json({success:false,error:"Validation failed",issues:_(e.zodError)},400):e instanceof T?t.json({success:false,error:"Bad Request",message:e.message},400):e instanceof S?t.json({success:false,error:"Output validation failed",issues:_(e.zodError)},500):null}extendZodWithOpenApi(z$1);var U="Successful response",Z="Error response";function re(t){return t==="get"?"query":"json"}function oe(t,e){let n=e?.output;return n?typeof n=="function"?n(t):n:t}function se(t){if(typeof t.safeParse=="function")return {description:Z,schema:t};let e=t;return {description:e.description??Z,schema:e.schema}}function C(t,e,n,o){let s=new OpenAPIRegistry;if(n.securitySchemes)for(let[i,c]of Object.entries(n.securitySchemes))s.registerComponent("securitySchemes",i,c);for(let i of t){let c=i.method,p=i.source??re(c),u=ce(e,i.path??"/"),d=i.status??200,m=ie(c,p,i.input),g=$(p,i.input,"query"),h=$(p,i.input,"param"),f=pe(c,u),l=oe(i.output,o),y={[d]:l?{description:U,content:{"application/json":{schema:l}}}:{description:U}};if(o?.errors)for(let[x,A]of Object.entries(o.errors)){let{description:q,schema:L}=se(A);y[x]=L?{description:q,content:{"application/json":{schema:L}}}:{description:q};}s.registerPath({method:c,path:ae(u),operationId:f,summary:i.summary,description:i.description,tags:i.tags,deprecated:i.deprecated,security:i.security,request:{...g?{query:g}:{},...h?{params:h}:{},...m?{body:m}:{}},responses:y});}return new OpenApiGeneratorV31(s.definitions).generateDocument({openapi:"3.1.0",info:n.info,servers:n.servers,security:n.security})}function ie(t,e,n){return !n||t==="get"?null:e==="json"?{content:{"application/json":{schema:n}}}:e==="form"?{content:{"application/x-www-form-urlencoded":{schema:n}}}:null}function $(t,e,n){if(e&&(n==="query"&&t==="query"||n==="param"&&t==="param"))return e}function ae(t){return t.replace(/:([A-Za-z0-9_]+)/g,"{$1}")}function ce(t,e){let n=t.endsWith("/")?t.slice(0,-1):t,o=e.startsWith("/")?e:`/${e}`,s=`${n}${o}`;return s===""?"/":s}function pe(t,e){let n=e.replace(/[{}]/g,"").replace(/\/+/g,"_").replace(/[^A-Za-z0-9_]/g,"").replace(/^_+|_+$/g,"");return `${t}_${n||"root"}`}function P(t,e){let n=t.replace(/"/g,""");return `<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -9,22 +9,22 @@ import {Hono}from'hono';import {getRequestListener}from'@hono/node-server';impor
|
|
|
9
9
|
<script id="api-reference" data-url="${n}"></script>
|
|
10
10
|
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
11
11
|
</body>
|
|
12
|
-
</html>`}var h=new AsyncLocalStorage,Y=Object.freeze({get c(){let t=h.getStore();if(!t)throw new Error("[services] requestContext.c was accessed outside of a request. Wrap non-HTTP code paths (cron, triggers, scripts, tests) in `withRequestContext({ c }, () => ...)` to supply a Hono Context.");return t.c},get maybeC(){return h.getStore()?.c}});function O(){return async(t,e)=>{await h.run({c:t},async()=>{await e();});}}function Q(t,e){return h.run({c:t.c},async()=>e())}var v="ctx";function X(t){let e=new Map,n=[],o=new Proxy({},{get(r,s){if(typeof s!="string")return;if(s===v)return Y;if(e.has(s))return e.get(s);let i=t[s];if(typeof i!="function")throw new Error(`[services] unknown service "${s}". Registered: ${[v,...Object.keys(t)].join(", ")}`);if(n.includes(s))throw new Error(`[services] circular dependency detected: ${[...n,s].join(" \u2192 ")}`);n.push(s);try{let a=ee(i)?new i(o):i(o);return e.set(s,a),a}finally{n.pop();}},has(r,s){return typeof s!="string"?false:s===v||s in t},ownKeys(){return [v,...Object.keys(t)]},getOwnPropertyDescriptor(r,s){if(typeof s=="string"&&(s===v||s in t))return {enumerable:true,configurable:true}}});return o}function ee(t){return /^class[\s{]/.test(Function.prototype.toString.call(t))}var re=Object.freeze({}),g=class{constructor(e){this.cachedSpec=null;this.options=e,this.app=new Hono,this.mountedRoutes=oe(e.routes,e.api),e.services&&this.app.use("*",O());let n=[...e.middlewares??[],...e.globalMiddlewares??[]];for(let o of n)this.app.use("*",o);this.mountRoutes(),this.mountOpenApi(),e.notFound&&this.app.notFound(e.notFound),e.onError&&this.app.onError(e.onError);}get hono(){return this.app}get nodeHandler(){return getRequestListener(this.app.fetch,{overrideGlobalObjects:false})}toFunction(e,n){let o=this.nodeHandler;return n?e(n,o):e(o)}buildOpenApiSpec(){if(this.cachedSpec)return this.cachedSpec;if(!this.options.openapi)throw new Error("[HonoServer] openapi config not set");return this.cachedSpec=A(this.mountedRoutes,this.options.basePath??"",this.options.openapi),this.cachedSpec}mountRoutes(){let e=this.options.basePath??"",n=this.options.validateOutput??false,o=this.options.verbose??false;for(let r of this.mountedRoutes){if(!r.path)throw new Error(`[HonoServer] route "${r.method.toUpperCase()} (no path)" \u2014 missing \`path\`. Run the codegen so the path is derived from the file location, or set it explicitly.`);let s=P(e,r.path),i=r.middlewares??[],a=r.source??(r.method==="get"?"query":"json"),p=ie(r,a,n,this.options.interceptor,this.options.services),u=r.method.toUpperCase();this.app.on(u,[s],...i,p),o&&console.log(`[HonoServer] ${r.method.toUpperCase().padEnd(6)} ${s}`);}}mountOpenApi(){let e=this.options.openapi;if(!e)return;let n=e.path??"/openapi.json",o=e.docsPath===void 0?"/docs":e.docsPath,r=P(this.options.basePath??"",n),s=o===false?null:P(this.options.basePath??"",o);if(this.app.get(r,i=>i.json(this.buildOpenApiSpec())),s){let i=se(s,r);this.app.get(s,a=>a.html(w(i,e.info.title)));}}};function oe(t,e){return e?t.filter(n=>Array.isArray(n.api)?n.api.includes(e):n.api===e):t.slice()}function P(t,e){let n=t.endsWith("/")?t.slice(0,-1):t,o=e.startsWith("/")?e:`/${e}`,r=`${n}${o}`;return r===""?"/":r}function se(t,e){let n=t.split("/").filter(Boolean),o=e.split("/").filter(Boolean);n.pop();let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r++;let s=n.length-r;return [...Array(s).fill(".."),...o.slice(r)].join("/")||"./"}function ie(t,e,n,o,r){let s=t.input,i=t.output,a=t.status??200,p=r??re;return async u=>{let f=async()=>{let y;if(s){let l;try{l=await ue(u,e,t.method);}catch(x){throw new T(x instanceof Error?x.message:String(x))}let S=s.safeParse(l);if(!S.success)throw new m(S.error,e);y=S.data;}let d=await t.handler({input:y,c:u,services:p});if(n&&i&&!(d instanceof Response)){let l=i.safeParse(d);if(!l.success)throw new R(l.error);return l.data}return d},c;if(o)c=await o({next:f,route:t,c:u,services:p});else try{c=await f();}catch(y){let d=ae(u,y);if(d)return d;throw y}return c instanceof Response?c:u.json(c,a)}}var T=class extends Error{constructor(n){super(n);this.statusCode=400;this.name="BadRequestError";}},R=class extends Error{constructor(n){super("Output validation failed");this.zodError=n;this.statusCode=500;this.name="OutputValidationError";}};function ae(t,e){return e instanceof m?t.json({success:false,error:"Validation failed",issues:k(e.zodError)},400):e instanceof T?t.json({success:false,error:"Bad Request",message:e.message},400):e instanceof R?t.json({success:false,error:"Output validation failed",issues:k(e.zodError)},500):null}async function ue(t,e,n){switch(e){case "json":{if(n==="get")return t.req.query();let o=await t.req.text();if(!o)return {};try{return JSON.parse(o)}catch(r){throw new Error(`Invalid JSON body: ${r instanceof Error?r.message:String(r)}`)}}case "query":return t.req.query();case "form":return await t.req.parseBody();case "param":return t.req.param();default:return {}}}function k(t){return t.issues.map(e=>({path:e.path.join("."),code:e.code,message:e.message}))}var C=class{constructor(e){this.services=e;}};function E(t,e){return {...e,input:t.input,output:t.output,handler:({input:n,services:o})=>new t(o).execute(n)}}function pe(t,e){let n=e?.services;return {configs:t,defineRoute(o){return o},useCaseRoute(o,r){return E(o,r)},serverFor(o,r){let s=t[o];if(!s)throw new Error(`[ApiRegistry] unknown api "${o}". Registered: ${Object.keys(t).join(", ")}`);return new g({...s,api:o,routes:r,services:n})},toFunctions(o,r,s){let i={};for(let a of Object.keys(t)){let p={...s?.defaults??{},...s?.per?.[a]??{}},u=new g({...t[a],api:a,routes:o,services:n});i[a]=Object.keys(p).length?u.toFunction(r,p):u.toFunction(r);}return i}}}var H={skipSegments:["useCases","useCase","use-cases","use-case"],casing:"preserve"};function M(t,e=H){let n=new Set(e.skipSegments.map(r=>r.toLowerCase()));return "/"+t.split("/").filter(Boolean).filter(r=>!n.has(r.toLowerCase())).map(r=>e.casing==="kebab"?ce(r):r).join("/")}function ce(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function D(t,e,n){let o=z(t),r=z(e),s=0;for(;s<o.length&&s<r.length&&o[s]===r[s];)s++;let i=o.length-s,a=r.slice(s),u=(a[a.length-1]??"").replace(/\.[mc]?[tj]sx?$/i,""),f=n===""?u:`${u}${n}`;return a[a.length-1]=f,(i===0?"./":"../".repeat(i))+a.join("/")}function z(t){return t.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter((n,o)=>!(o===0&&n===""))}var q={routesFile:"routes.ts",excludeSegments:["node_modules","__generated__","tests","__tests__",".turbo","dist","build",".next"]};function ge(t,e=q){let n=[];return F(t,t,e,n),n.sort((o,r)=>o.relPath.localeCompare(r.relPath)),n}function F(t,e,n,o){let r;try{r=readdirSync(e);}catch{return}for(let s of r){if(n.excludeSegments.includes(s))continue;let i=join(e,s),a;try{a=statSync(i);}catch{continue}if(a.isDirectory())F(t,i,n,o);else if(a.isFile()&&s===n.routesFile){let p=relative(t,i).split(sep).join("/"),u=p.replace(/\/?[^/]+$/,"");o.push({absPath:i,relPath:p,relDir:u});}}}var _="/**\n * AUTO-GENERATED by `@lpdjs/firestore-repo-service` Hono codegen.\n * Do not edit by hand \u2014 re-run `hono:gen` after adding / removing route files.\n */\n";function j(t,e){let n=dirname(e.outFile);mkdirSync(n,{recursive:true});let o=e.banner??_,r=(e.now??new Date).toISOString(),s=e.importExtension,i=[],a=[],p=[];t.forEach((f,c)=>{let y=D(n,f.absPath,s),d=M(f.relDir,e.derive);i.push(`import mod${c} from ${JSON.stringify(y)};`),a.push(` { __derivedPath: ${JSON.stringify(d)}, mod: mod${c} },`),p.push({source:f.relPath,url:d});});let u=`${o}// Generated at ${r} \u2014 ${t.length} route file${t.length===1?"":"s"}.
|
|
12
|
+
</html>`}var w=new AsyncLocalStorage,de=Object.freeze({get c(){let t=w.getStore();if(!t)throw new Error("[services] requestContext.c was accessed outside of a request. Wrap non-HTTP code paths (cron, triggers, scripts, tests) in `withRequestContext({ c }, () => ...)` to supply a Hono Context.");return t.c},get maybeC(){return w.getStore()?.c}});function I(){return async(t,e)=>{await w.run({c:t},async()=>{await e();});}}function le(t,e){return w.run({c:t.c},async()=>e())}var O="ctx";function fe(t){let e=new Map,n=[],o=new Proxy({},{get(s,r){if(typeof r!="string")return;if(r===O)return de;if(e.has(r))return e.get(r);let a=t[r];if(typeof a!="function")throw new Error(`[services] unknown service "${r}". Registered: ${[O,...Object.keys(t)].join(", ")}`);if(n.includes(r))throw new Error(`[services] circular dependency detected: ${[...n,r].join(" \u2192 ")}`);n.push(r);try{let i=ye(a)?new a(o):a(o);return e.set(r,i),i}finally{n.pop();}},has(s,r){return typeof r!="string"?false:r===O||r in t},ownKeys(){return [O,...Object.keys(t)]},getOwnPropertyDescriptor(s,r){if(typeof r=="string"&&(r===O||r in t))return {enumerable:true,configurable:true}}});return o}function ye(t){return /^class[\s{]/.test(Function.prototype.toString.call(t))}var me=Object.freeze({}),R=class{constructor(e){this.cachedSpec=null;this.options=e,this.app=new Hono,this.mountedRoutes=Se(e.routes,e.api),e.services&&this.app.use("*",I());let n=[...e.middlewares??[],...e.globalMiddlewares??[]];for(let o of n)this.app.use("*",o);this.mountRoutes(),this.mountOpenApi(),e.notFound&&this.app.notFound(e.notFound),e.onError&&this.app.onError(e.onError);}get hono(){return this.app}get nodeHandler(){return getRequestListener(this.app.fetch,{overrideGlobalObjects:false})}toFunction(e,n){let o=this.nodeHandler;return n?e(n,o):e(o)}buildOpenApiSpec(){if(this.cachedSpec)return this.cachedSpec;if(!this.options.openapi)throw new Error("[HonoServer] openapi config not set");return this.cachedSpec=C(this.mountedRoutes,this.options.basePath??"",this.options.openapi,Te(this.options.interceptor)),this.cachedSpec}mountRoutes(){let e=this.options.basePath??"",n=this.options.validateOutput??false,o=this.options.verbose??false;for(let s of this.mountedRoutes){if(!s.path)throw new Error(`[HonoServer] route "${s.method.toUpperCase()} (no path)" \u2014 missing \`path\`. Run the codegen so the path is derived from the file location, or set it explicitly.`);let r=k(e,s.path),a=s.middlewares??[],i=s.source??(s.method==="get"?"query":"json"),c=xe(s,i,n,ve(this.options.interceptor),this.options.services,this.options.errorHandler,this.options.logger),p=s.method.toUpperCase();this.app.on(p,[r],...a,c),o&&console.log(`[HonoServer] ${s.method.toUpperCase().padEnd(6)} ${r}`);}}mountOpenApi(){let e=this.options.openapi;if(!e)return;let n=e.path??"/openapi.json",o=e.docsPath===void 0?"/docs":e.docsPath,s=k(this.options.basePath??"",n),r=o===false?null:k(this.options.basePath??"",o),a=e.docsAuth?Array.isArray(e.docsAuth)?e.docsAuth:[e.docsAuth]:[];if(this.app.on("GET",[s],...a,i=>i.json(this.buildOpenApiSpec())),r){let i=Re(r,s);this.app.on("GET",[r],...a,c=>c.html(P(i,e.info.title)));}}};function B(t){return typeof t=="object"&&t!==null&&typeof t.handler=="function"}function ve(t){if(t)return B(t)?t.handler:t}function Te(t){return B(t)?t:void 0}function Se(t,e){return e?t.filter(n=>Array.isArray(n.api)?n.api.includes(e):n.api===e):t.slice()}function k(t,e){let n=t.endsWith("/")?t.slice(0,-1):t,o=e.startsWith("/")?e:`/${e}`,s=`${n}${o}`;return s===""?"/":s}function Re(t,e){let n=t.split("/").filter(Boolean),o=e.split("/").filter(Boolean);n.pop();let s=0;for(;s<n.length&&s<o.length&&n[s]===o[s];)s++;let r=n.length-s;return [...Array(r).fill(".."),...o.slice(s)].join("/")||"./"}function xe(t,e,n,o,s,r,a){let i=t.input,c=t.output,p=t.status??200,u=s??me;return async d=>{let m=async f=>{if(r){let l=await r.handle({error:f,c:d,route:t,services:u,logger:a});if(l)return l}return E(d,f)},g=async()=>{let f;if(i){let y;try{y=await Ae(d,e,t.method);}catch(A){throw new T(A instanceof Error?A.message:String(A))}let x=i.safeParse(y);if(!x.success)throw new v(x.error,e);f=x.data;}let l=await t.handler({input:f,c:d,services:u,errorHandler:r,logger:a});if(n&&c&&!(l instanceof Response)){let y=c.safeParse(l);if(!y.success)throw new S(y.error);return y.data}return l},h;if(o)try{h=await o({next:g,route:t,c:d,services:u,errorHandler:r,logger:a});}catch(f){let l=await m(f);if(l)return l;throw f}else try{h=await g();}catch(f){let l=await m(f);if(l)return l;throw f}return h instanceof Response?h:d.json(h,p)}}async function Ae(t,e,n){switch(e){case "json":{if(n==="get")return t.req.query();let o=await t.req.text();if(!o)return {};try{return JSON.parse(o)}catch(s){throw new Error(`Invalid JSON body: ${s instanceof Error?s.message:String(s)}`)}}case "query":return t.req.query();case "form":return await t.req.parseBody();case "param":return t.req.param();default:return {}}}var b=class{constructor(e){this.services=e;}};function H(t,e){return {...e,input:t.input,output:t.output,handler:({input:n,services:o})=>new t(o).execute(n)}}function Ee(t,e){let n=e?.services,o=e?.errorHandler,s=e?.logger;return {configs:t,defineRoute(r){return r},useCaseRoute(r,a){return H(r,a)},serverFor(r,a){let i=t[r];if(!i)throw new Error(`[ApiRegistry] unknown api "${r}". Registered: ${Object.keys(t).join(", ")}`);return new R({...i,api:r,routes:a,services:n,errorHandler:i.errorHandler??o,logger:i.logger??s})},toFunctions(r,a,i){let c={};for(let p of Object.keys(t)){let u={...i?.defaults??{},...i?.per?.[p]??{}},d=new R({...t[p],api:p,routes:r,services:n,errorHandler:t[p].errorHandler??o,logger:t[p].logger??s});c[p]=Object.keys(u).length?d.toFunction(a,u):d.toFunction(a);}return c}}}function G(t){return t||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT||process.env.GCP_PROJECT||void 0}function M(t,e={}){if(!e.enabled||!t)return;let n=G(e.projectId);if(!n)return;let s=`jsonPayload.${e.field??"errorId"}="${t}"`,r=[`query=${encodeURIComponent(s)}`];return e.duration&&r.push(`duration=${encodeURIComponent(e.duration)}`),`https://console.cloud.google.com/logs/query;${r.join(";")}?project=${encodeURIComponent(n)}`}var D=class{constructor(e={}){this.options=e;}gcpLogsUrl(e){return M(e,this.options.gcpLogs)}async handle(e){let n=await this.mapError(e);return n?(this.logError(e,n),n):this.handleBuiltin(e)}mapError(e){return null}logError(e,n){}handleBuiltin(e){return E(e.c,e.error)}};var z=class t{info(e,n){this.write("INFO",this.payload(e,n));}warn(e,n){this.write("WARNING",this.payload(e,n));}debug(e,n){this.write("DEBUG",this.payload(e,n));}error(e,n){let o=t.errorId(e);return this.write("ERROR",{errorId:o,message:e instanceof Error?e.message:String(e),...e instanceof Error&&e.stack?{stack:e.stack}:{},...n!==void 0?{meta:n}:{}}),o}payload(e,n){return n!==void 0?{message:e,meta:n}:{message:e}}write(e,n){let o={severity:e,...n};e==="ERROR"?console.error(o):e==="WARNING"?console.warn(o):console.log(o);}static errorId(e){return e&&typeof e=="object"&&"errorId"in e&&typeof e.errorId=="string"?e.errorId:Math.random().toString(36).slice(2,12)}};function Oe(t){let{getAuth:e,allow:n,checkRevoked:o=false,contextKey:s="docsUser"}=t;return async(r,a)=>{let c=(r.req.header("authorization")??r.req.header("Authorization"))?.match(/^Bearer\s+(.+)$/i);if(!c)return r.json({error:"Unauthorized"},401,{"WWW-Authenticate":"Bearer"});let p;try{p=await e().verifyIdToken(c[1],o);}catch{return r.json({error:"Unauthorized"},401,{"WWW-Authenticate":"Bearer"})}if(n){let u=false;try{u=await n(p);}catch{u=false;}if(!u)return r.json({error:"Forbidden"},403)}return r.set(s,p),a()}}function we(t){let{username:e,password:n,realm:o="Docs"}=t,s=`Basic ${btoa(`${e}:${n}`)}`;return async(r,a)=>{let i=r.req.header("authorization")??r.req.header("Authorization")??"";return Ce(i,s)?a():r.text("Unauthorized",401,{"WWW-Authenticate":`Basic realm="${o}"`})}}function Ce(t,e){if(t.length!==e.length)return false;let n=0;for(let o=0;o<t.length;o++)n|=t.charCodeAt(o)^e.charCodeAt(o);return n===0}var K={skipSegments:["useCases","useCase","use-cases","use-case"],casing:"preserve"};function F(t,e=K){let n=new Set(e.skipSegments.map(s=>s.toLowerCase()));return "/"+t.split("/").filter(Boolean).filter(s=>!n.has(s.toLowerCase())).map(s=>e.casing==="kebab"?Pe(s):s).join("/")}function Pe(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function j(t,e,n){let o=N(t),s=N(e),r=0;for(;r<o.length&&r<s.length&&o[r]===s[r];)r++;let a=o.length-r,i=s.slice(r),p=(i[i.length-1]??"").replace(/\.[mc]?[tj]sx?$/i,""),u=n===""?p:`${p}${n}`;return i[i.length-1]=u,(a===0?"./":"../".repeat(a))+i.join("/")}function N(t){return t.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter((n,o)=>!(o===0&&n===""))}var W={routesFile:"routes.ts",excludeSegments:["node_modules","__generated__","tests","__tests__",".turbo","dist","build",".next"]};function De(t,e=W){let n=[];return V(t,t,e,n),n.sort((o,s)=>o.relPath.localeCompare(s.relPath)),n}function V(t,e,n,o){let s;try{s=readdirSync(e);}catch{return}for(let r of s){if(n.excludeSegments.includes(r))continue;let a=join(e,r),i;try{i=statSync(a);}catch{continue}if(i.isDirectory())V(t,a,n,o);else if(i.isFile()&&r===n.routesFile){let c=relative(t,a).split(sep).join("/"),p=c.replace(/\/?[^/]+$/,"");o.push({absPath:a,relPath:c,relDir:p});}}}var J="/**\n * AUTO-GENERATED by `@lpdjs/firestore-repo-service` Hono codegen.\n * Do not edit by hand \u2014 re-run `hono:gen` after adding / removing route files.\n */\n";function Y(t,e){let n=dirname(e.outFile);mkdirSync(n,{recursive:true});let o=e.banner??J,s=(e.now??new Date).toISOString(),r=e.importExtension,a=[],i=[],c=[];t.forEach((u,d)=>{let m=j(n,u.absPath,r),g=F(u.relDir,e.derive);a.push(`import mod${d} from ${JSON.stringify(m)};`),i.push(` { __derivedPath: ${JSON.stringify(g)}, mod: mod${d} },`),c.push({source:u.relPath,url:g});});let p=`${o}// Generated at ${s} \u2014 ${t.length} route file${t.length===1?"":"s"}.
|
|
13
13
|
|
|
14
14
|
import type { AnyRouteDef, RouteModuleDefault } from "@lpdjs/firestore-repo-service/servers/hono";
|
|
15
15
|
|
|
16
|
-
`+
|
|
17
|
-
`)+(
|
|
16
|
+
`+a.join(`
|
|
17
|
+
`)+(a.length?`
|
|
18
18
|
|
|
19
19
|
`:`
|
|
20
20
|
`)+`const __defs: { __derivedPath: string; mod: RouteModuleDefault }[] = [
|
|
21
|
-
`+
|
|
22
|
-
`)+(
|
|
21
|
+
`+i.join(`
|
|
22
|
+
`)+(i.length?`
|
|
23
23
|
`:"")+`];
|
|
24
24
|
|
|
25
25
|
export const routes: AnyRouteDef[] = __defs.flatMap(({ __derivedPath, mod }) => {
|
|
26
26
|
const list = Array.isArray(mod) ? mod : [mod];
|
|
27
27
|
return list.map((route) => ({ ...route, path: route.path ?? __derivedPath }));
|
|
28
28
|
});
|
|
29
|
-
`;return writeFileSync(e.outFile,
|
|
29
|
+
`;return writeFileSync(e.outFile,p,"utf8"),{outFile:e.outFile,routeCount:t.length,derivedPaths:c}}function Le(t,e,n,o,s){let r=s(t),a=join(t,e);return Y(r,{outFile:a,derive:n,importExtension:o})}export{T as BadRequestError,D as BaseErrorHandler,z as BaseLogger,K as DEFAULT_DERIVE,J as DEFAULT_GENERATOR_BANNER,W as DEFAULT_SCANNER,R as HonoServer,S as OutputValidationError,b as UseCase,v as ValidationError,we as basicAuth,C as buildOpenApiDocument,Ee as createApiRegistry,I as createRequestContextMiddleware,fe as createServices,E as defaultErrorResponse,Q as defineRoutes,F as derivePath,Oe as firebaseBearerAuth,M as gcpLogsUrl,Le as generateFromRoot,Y as generateRoutesManifest,P as renderDocsHtml,G as resolveGcpProjectId,De as scanRoutes,j as toImportSpecifier,H as useCaseRoute,le as withRequestContext};//# sourceMappingURL=index.js.map
|
|
30
30
|
//# sourceMappingURL=index.js.map
|