appflare 0.2.34 → 0.2.36

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/cli/generate.ts CHANGED
@@ -181,7 +181,7 @@ export async function generateArtifacts(
181
181
  return {
182
182
  compilerOptions: {
183
183
  lib: ["es2024"],
184
- types: ["@types/node", "bun", "@cloudflare/workers-types/2023-07-01"],
184
+ types: ["@types/node", "@cloudflare/workers-types/2023-07-01"],
185
185
  module: "es2022",
186
186
  target: "es2024",
187
187
  moduleResolution: "bundler",
@@ -217,7 +217,6 @@ export async function generateArtifacts(
217
217
  stdout: "inherit",
218
218
  stderr: "inherit",
219
219
  });
220
- console.log(process.execPath, tscBin, "-p", configPath, { cwd: outDirAbs });
221
220
  const code = await p.exited;
222
221
  if (code !== 0) throw new Error(`tsc ${label} failed with exit code ${code}`);
223
222
  }
@@ -111,6 +111,13 @@ function normalizeOperation(
111
111
  .filter(Boolean)
112
112
  .slice(1);
113
113
 
114
+ if (
115
+ segments.length >= 2 &&
116
+ segments[segments.length - 1] === segments[segments.length - 2]
117
+ ) {
118
+ segments.pop();
119
+ }
120
+
114
121
  if (segments.length === 0) {
115
122
  return null;
116
123
  }
package/dist/cli/index.js CHANGED
@@ -167,7 +167,7 @@ export function createAppflare<Options extends BetterAuthClientOptions = Inferre
167
167
  return new Appflare(options);
168
168
  }
169
169
  `}function Jn(e){let t=e.replace(/[^A-Za-z0-9_]/g,"_");return /^[0-9]/.test(t)?`_${t}`:t||"_route"}function ge(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function Zn(e){return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function fe(e){let t={children:new Map};for(let n of e){let r=t;for(let a of n.segments){let o=r.children.get(a);o||(o={children:new Map},r.children.set(a,o)),r=o;}r.operation=n;}return t}function L(e,t=1){let n=" ".repeat(t),r=" ".repeat(t+1),a=Array.from(e.children.entries()).sort(([s],[i])=>s.localeCompare(i));if(a.length===0)return e.operation?`${e.operation.alias}Route(runtime)`:"{}";let o=["{"];for(let[s,i]of a)o.push(`${r}${Zn(s)}: ${L(i,t+1)},`);return e.operation&&(o.push(`${r}run: ${e.operation.alias}Route(runtime).run,`),o.push(`${r}schema: ${e.operation.alias}Route(runtime).schema,`),e.operation.kind==="query"&&o.push(`${r}subscribe: ${e.operation.alias}Route(runtime).subscribe,`)),o.push(`${n}}`),o.join(`
170
- `)}function Yn(e,t){if(e.kind!=="query"&&e.kind!=="mutation")return null;let n=e.clientSegments&&e.clientSegments.length>0?e.clientSegments:e.routePath.replace(/^\//,"").split("/").filter(Boolean).slice(1);if(n.length===0)return null;let r=Jn(`op_${t}_${e.kind}_${n.join("_")}`);return {kind:e.kind,routePath:e.routePath,queryName:e.handlerName??n.join("/"),segments:n,importPath:e.clientImportPath,exportName:e.exportName,alias:r,schemaConst:`${r}Schema`,typeBase:`${ge(e.kind)}${ge(n.join("_"))}`}}function Xn(e){let t=`${e.typeBase}Input`,n=`${e.typeBase}Output`,r=`${e.typeBase}Schema`,a=e.kind==="query"?"GET":"POST";return e.kind==="query"?`const ${e.alias}Route = (
170
+ `)}function Yn(e,t){if(e.kind!=="query"&&e.kind!=="mutation")return null;let n=e.clientSegments&&e.clientSegments.length>0?e.clientSegments:e.routePath.replace(/^\//,"").split("/").filter(Boolean).slice(1);if(n.length>=2&&n[n.length-1]===n[n.length-2]&&n.pop(),n.length===0)return null;let r=Jn(`op_${t}_${e.kind}_${n.join("_")}`);return {kind:e.kind,routePath:e.routePath,queryName:e.handlerName??n.join("/"),segments:n,importPath:e.clientImportPath,exportName:e.exportName,alias:r,schemaConst:`${r}Schema`,typeBase:`${ge(e.kind)}${ge(n.join("_"))}`}}function Xn(e){let t=`${e.typeBase}Input`,n=`${e.typeBase}Output`,r=`${e.typeBase}Schema`,a=e.kind==="query"?"GET":"POST";return e.kind==="query"?`const ${e.alias}Route = (
171
171
  runtime: RequestRuntime,
172
172
  ): AppflareQueryRouteClient<typeof ${e.schemaConst}, ${n}> => {
173
173
  const run: AppflareQueryRouteClient<typeof ${e.schemaConst}, ${n}>["run"] = async (
@@ -8972,10 +8972,10 @@ ${s.join(`
8972
8972
  `),...zn,...Hn,Bun.write(y,En),Bun.write(m,""),Bun.write(v,jn),Bun.write(N,`${JSON.stringify(Bn,null,2)}
8973
8973
  `),Bun.write(Wn,Vn)]),process.stdout.write(`\u{1F4DD} Source artifacts (${(performance.now()-c).toFixed(0)}ms)
8974
8974
  `);let H=path.relative(o,y).replace(/\\/g,"/"),Ln=H.startsWith(".")?H:`./${H}`,z=path.relative(o,m).replace(/\\/g,"/"),Un=z.startsWith(".")?z:`./${z}`,le=await Bun.spawn([process.execPath,d,"generate","--config",Ln,"--output",Un,"--yes"],{cwd:o,stdout:"inherit",stderr:"inherit"}).exited;if(le!==0)throw new Error(`better-auth generation failed with exit code ${le}`);process.stdout.write(`\u{1F510} Auth schema (${(performance.now()-c).toFixed(0)}ms)
8975
- `);function Qn(w={}){return {compilerOptions:{lib:["es2024"],types:["@types/node","bun","@cloudflare/workers-types/2023-07-01"],module:"es2022",target:"es2024",moduleResolution:"bundler",strictNullChecks:true,skipLibCheck:true,declaration:true,emitDeclarationOnly:true,noCheck:true,jsx:"react-jsx",paths:{"_generated/*":["./*"]},...w},include:["./*.ts","./client/*.ts"]}}let ce=path.resolve(t,"tsconfig.js.json");await Promise.all([Bun.write(ce,`${JSON.stringify(Qn({declaration:true,emitDeclarationOnly:false}),null,2)}
8975
+ `);function Qn(w={}){return {compilerOptions:{lib:["es2024"],types:["@types/node","@cloudflare/workers-types/2023-07-01"],module:"es2022",target:"es2024",moduleResolution:"bundler",strictNullChecks:true,skipLibCheck:true,declaration:true,emitDeclarationOnly:true,noCheck:true,jsx:"react-jsx",paths:{"_generated/*":["./*"]},...w},include:["./*.ts","./client/*.ts"]}}let ce=path.resolve(t,"tsconfig.js.json");await Promise.all([Bun.write(ce,`${JSON.stringify(Qn({declaration:true,emitDeclarationOnly:false}),null,2)}
8976
8976
  `)]),process.stdout.write(`\u{1F4C4} TS configs (${(performance.now()-c).toFixed(0)}ms)
8977
8977
  `);async function _n(w,A){process.stdout.write(`\u2699\uFE0F ${A}... (${(performance.now()-c).toFixed(0)}ms)
8978
- `);let T=Bun.spawn([process.execPath,f,"-p",w],{cwd:t,stdout:"inherit",stderr:"inherit"});console.log(process.execPath,f,"-p",w,{cwd:t});let S=await T.exited;if(S!==0)throw new Error(`tsc ${A} failed with exit code ${S}`)}await _n(ce,"JS files"),process.stdout.write(`\u2705 JS + declarations (${(performance.now()-c).toFixed(0)}ms)
8978
+ `);let S=await Bun.spawn([process.execPath,f,"-p",w],{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(S!==0)throw new Error(`tsc ${A} failed with exit code ${S}`)}await _n(ce,"JS files"),process.stdout.write(`\u2705 JS + declarations (${(performance.now()-c).toFixed(0)}ms)
8979
8979
  `);async function ue(w){let A=await promises.readdir(w,{withFileTypes:true});for(let T of A){let S=path.join(w,T.name);if(T.isDirectory()){if(T.name==="node_modules"||T.name.startsWith("."))continue;await ue(S);}else T.name.endsWith(".ts")&&!T.name.endsWith(".d.ts")&&await promises.rm(S);}}await ue(t),process.stdout.write(`\u{1F4E6} Cleaned .ts files (${(performance.now()-c).toFixed(0)}ms)
8980
8980
  `);let Kn=t+"/";async function de(w){let A=await promises.readdir(w,{withFileTypes:true});for(let T of A){let S=path.join(w,T.name);if(T.isDirectory()){if(T.name==="node_modules"||T.name.startsWith(".")||S===t)continue;await de(S);}else !S.startsWith(Kn)&&(T.name.endsWith(".d.ts")||T.name.endsWith(".js"))&&await promises.rm(S);}}await de(o),process.stdout.write(`\u{1F9F9} Cleanup (${(performance.now()-c).toFixed(0)}ms)
8981
8981
  `);let Gn=path.resolve(o,"tsconfig.json");if(e.config.build&&fs.existsSync(Gn)){process.stdout.write(`\u2699\uFE0F Building project... (${(performance.now()-c).toFixed(0)}ms)
@@ -167,7 +167,7 @@ export function createAppflare<Options extends BetterAuthClientOptions = Inferre
167
167
  return new Appflare(options);
168
168
  }
169
169
  `}function Jn(e){let t=e.replace(/[^A-Za-z0-9_]/g,"_");return /^[0-9]/.test(t)?`_${t}`:t||"_route"}function ge(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function Zn(e){return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function fe(e){let t={children:new Map};for(let n of e){let r=t;for(let a of n.segments){let o=r.children.get(a);o||(o={children:new Map},r.children.set(a,o)),r=o;}r.operation=n;}return t}function L(e,t=1){let n=" ".repeat(t),r=" ".repeat(t+1),a=Array.from(e.children.entries()).sort(([s],[i])=>s.localeCompare(i));if(a.length===0)return e.operation?`${e.operation.alias}Route(runtime)`:"{}";let o=["{"];for(let[s,i]of a)o.push(`${r}${Zn(s)}: ${L(i,t+1)},`);return e.operation&&(o.push(`${r}run: ${e.operation.alias}Route(runtime).run,`),o.push(`${r}schema: ${e.operation.alias}Route(runtime).schema,`),e.operation.kind==="query"&&o.push(`${r}subscribe: ${e.operation.alias}Route(runtime).subscribe,`)),o.push(`${n}}`),o.join(`
170
- `)}function Yn(e,t){if(e.kind!=="query"&&e.kind!=="mutation")return null;let n=e.clientSegments&&e.clientSegments.length>0?e.clientSegments:e.routePath.replace(/^\//,"").split("/").filter(Boolean).slice(1);if(n.length===0)return null;let r=Jn(`op_${t}_${e.kind}_${n.join("_")}`);return {kind:e.kind,routePath:e.routePath,queryName:e.handlerName??n.join("/"),segments:n,importPath:e.clientImportPath,exportName:e.exportName,alias:r,schemaConst:`${r}Schema`,typeBase:`${ge(e.kind)}${ge(n.join("_"))}`}}function Xn(e){let t=`${e.typeBase}Input`,n=`${e.typeBase}Output`,r=`${e.typeBase}Schema`,a=e.kind==="query"?"GET":"POST";return e.kind==="query"?`const ${e.alias}Route = (
170
+ `)}function Yn(e,t){if(e.kind!=="query"&&e.kind!=="mutation")return null;let n=e.clientSegments&&e.clientSegments.length>0?e.clientSegments:e.routePath.replace(/^\//,"").split("/").filter(Boolean).slice(1);if(n.length>=2&&n[n.length-1]===n[n.length-2]&&n.pop(),n.length===0)return null;let r=Jn(`op_${t}_${e.kind}_${n.join("_")}`);return {kind:e.kind,routePath:e.routePath,queryName:e.handlerName??n.join("/"),segments:n,importPath:e.clientImportPath,exportName:e.exportName,alias:r,schemaConst:`${r}Schema`,typeBase:`${ge(e.kind)}${ge(n.join("_"))}`}}function Xn(e){let t=`${e.typeBase}Input`,n=`${e.typeBase}Output`,r=`${e.typeBase}Schema`,a=e.kind==="query"?"GET":"POST";return e.kind==="query"?`const ${e.alias}Route = (
171
171
  runtime: RequestRuntime,
172
172
  ): AppflareQueryRouteClient<typeof ${e.schemaConst}, ${n}> => {
173
173
  const run: AppflareQueryRouteClient<typeof ${e.schemaConst}, ${n}>["run"] = async (
@@ -8972,10 +8972,10 @@ ${s.join(`
8972
8972
  `),...zn,...Hn,Bun.write(y,En),Bun.write(m,""),Bun.write(v,jn),Bun.write(N,`${JSON.stringify(Bn,null,2)}
8973
8973
  `),Bun.write(Wn,Vn)]),process.stdout.write(`\u{1F4DD} Source artifacts (${(performance.now()-c).toFixed(0)}ms)
8974
8974
  `);let H=relative(o,y).replace(/\\/g,"/"),Ln=H.startsWith(".")?H:`./${H}`,z=relative(o,m).replace(/\\/g,"/"),Un=z.startsWith(".")?z:`./${z}`,le=await Bun.spawn([process.execPath,d,"generate","--config",Ln,"--output",Un,"--yes"],{cwd:o,stdout:"inherit",stderr:"inherit"}).exited;if(le!==0)throw new Error(`better-auth generation failed with exit code ${le}`);process.stdout.write(`\u{1F510} Auth schema (${(performance.now()-c).toFixed(0)}ms)
8975
- `);function Qn(w={}){return {compilerOptions:{lib:["es2024"],types:["@types/node","bun","@cloudflare/workers-types/2023-07-01"],module:"es2022",target:"es2024",moduleResolution:"bundler",strictNullChecks:true,skipLibCheck:true,declaration:true,emitDeclarationOnly:true,noCheck:true,jsx:"react-jsx",paths:{"_generated/*":["./*"]},...w},include:["./*.ts","./client/*.ts"]}}let ce=resolve(t,"tsconfig.js.json");await Promise.all([Bun.write(ce,`${JSON.stringify(Qn({declaration:true,emitDeclarationOnly:false}),null,2)}
8975
+ `);function Qn(w={}){return {compilerOptions:{lib:["es2024"],types:["@types/node","@cloudflare/workers-types/2023-07-01"],module:"es2022",target:"es2024",moduleResolution:"bundler",strictNullChecks:true,skipLibCheck:true,declaration:true,emitDeclarationOnly:true,noCheck:true,jsx:"react-jsx",paths:{"_generated/*":["./*"]},...w},include:["./*.ts","./client/*.ts"]}}let ce=resolve(t,"tsconfig.js.json");await Promise.all([Bun.write(ce,`${JSON.stringify(Qn({declaration:true,emitDeclarationOnly:false}),null,2)}
8976
8976
  `)]),process.stdout.write(`\u{1F4C4} TS configs (${(performance.now()-c).toFixed(0)}ms)
8977
8977
  `);async function _n(w,A){process.stdout.write(`\u2699\uFE0F ${A}... (${(performance.now()-c).toFixed(0)}ms)
8978
- `);let T=Bun.spawn([process.execPath,f,"-p",w],{cwd:t,stdout:"inherit",stderr:"inherit"});console.log(process.execPath,f,"-p",w,{cwd:t});let S=await T.exited;if(S!==0)throw new Error(`tsc ${A} failed with exit code ${S}`)}await _n(ce,"JS files"),process.stdout.write(`\u2705 JS + declarations (${(performance.now()-c).toFixed(0)}ms)
8978
+ `);let S=await Bun.spawn([process.execPath,f,"-p",w],{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(S!==0)throw new Error(`tsc ${A} failed with exit code ${S}`)}await _n(ce,"JS files"),process.stdout.write(`\u2705 JS + declarations (${(performance.now()-c).toFixed(0)}ms)
8979
8979
  `);async function ue(w){let A=await readdir(w,{withFileTypes:true});for(let T of A){let S=join(w,T.name);if(T.isDirectory()){if(T.name==="node_modules"||T.name.startsWith("."))continue;await ue(S);}else T.name.endsWith(".ts")&&!T.name.endsWith(".d.ts")&&await rm(S);}}await ue(t),process.stdout.write(`\u{1F4E6} Cleaned .ts files (${(performance.now()-c).toFixed(0)}ms)
8980
8980
  `);let Kn=t+"/";async function de(w){let A=await readdir(w,{withFileTypes:true});for(let T of A){let S=join(w,T.name);if(T.isDirectory()){if(T.name==="node_modules"||T.name.startsWith(".")||S===t)continue;await de(S);}else !S.startsWith(Kn)&&(T.name.endsWith(".d.ts")||T.name.endsWith(".js"))&&await rm(S);}}await de(o),process.stdout.write(`\u{1F9F9} Cleanup (${(performance.now()-c).toFixed(0)}ms)
8981
8981
  `);let Gn=resolve(o,"tsconfig.json");if(e.config.build&&existsSync(Gn)){process.stdout.write(`\u2699\uFE0F Building project... (${(performance.now()-c).toFixed(0)}ms)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appflare",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",