@sinch/cli 0.1.0-dev.2096736014 → 0.1.0-dev.2106538252

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ ${e}`))}list(e,n={}){let{indent:i=" ",bullet:r="\u2022"}=n;e.forEach(s=>{consol
42
42
  `,e+=`*Documentation generated on ${new Date(o.generatedAt).toLocaleString()} using Sinch AI*
43
43
  `),e}async function st(o,e){let n=se.resolve(e);await Ee.writeFile(n,o,"utf8")}function Kt(o){switch(se.extname(o).toLowerCase()){case".js":return"node";case".py":return"python";case".cs":return"csharp";default:return"node"}}var Ee,se,at=de(()=>{"use strict";Ee=m(require("fs-extra")),se=m(require("path"));_();A()});var Qt=N((Vi,zt)=>{"use strict";var X=m(require("fs-extra")),me=m(require("path")),v=m(require("chalk")),Jt=require("commander");_();A();B();F();Nt();var Mt=m(require("adm-zip")),Wt=m(require("os")),Ht=m(require("inquirer")),Gt=require("child_process"),Yt=new Jt.Command("deploy");Yt.description("Deploy function to production").option("-n, --name <name>","Function name (default: current directory)").option("--no-wait","Don't wait for deployment to complete").option("--non-interactive","Use default values without prompting (auto-generates docs)").option("--no-docs","no doc generation").action(async o=>{try{if(await p.load(),!p.isInProject())throw new Error('Not in a Sinch Functions project directory. Run "sinch functions init" first.');let e=p.getProjectConfig(),n=o.name||e.name,i=e.runtime;await po(e,o),d.start("\u{1F4E6} Packaging function...");let r=await co(n);d.succeed("\u{1F4E6} Function packaged"),d.start("\u{1F527} Preparing configuration...");let s=await lo(i);d.succeed("\u{1F527} Configuration prepared"),d.start("\u{1F680} Submitting deployment...");let a=new E(p.getApiConfig()),c=await X.default.readFile(r),l=await a.deployFunction(n,i,c,s);if(await X.default.remove(r),d.succeed("\u{1F680} Deployment submitted"),p.set("functionId",l.id,!0),await p.saveProjectConfig(),t.newline(),t.info(`Function ID: ${v.default.cyan(l.id)}`),t.info(`Status: ${ct(l.status)}`),o.wait===!1){t.newline(),t.info("\u{1F4A1} Check deployment progress with:"),t.info(` ${v.default.cyan(`sinch functions status ${l.id}`)}`);return}await uo(a,l.id)}catch(e){d.stop(),t.error(`Failed to deploy function: ${e.message}`),process.exit(1)}});async function co(o){let e=new Mt.default,n=process.cwd(),i=me.default.join(Wt.default.tmpdir(),`${o}-${Date.now()}.zip`),r=["node_modules","bin","obj",".git",".DS_Store","*.zip",".env",".env.local","npm-debug.log*",".sinch-tmp","examples","claude.md","readme.md"];async function s(a,c=""){let l=await X.default.readdir(a);for(let u of l){let g=me.default.join(a,u),h=me.default.join(c,u).replace(/\\/g,"/");if(r.some(w=>u.match(new RegExp(w.replace("*",".*")))))continue;if((await X.default.stat(g)).isDirectory())await s(g,h);else{let w=await X.default.readFile(g);e.addFile(h,w)}}}return await s(n),e.writeZip(i),i}async function lo(o){let e={},n=null;try{n=await p.getCredentials()}catch(i){t.debug("Could not load credentials from secure storage: "+i.message)}if(o==="csharp"){let i=me.default.join(process.cwd(),"appsettings.json");if(await X.default.pathExists(i))try{let r=await X.default.readJson(i);for(let s of Object.keys(r)){if(s==="Logging"||s==="AllowedHosts")continue;let a=r[s];if(a===""||a===null||a===void 0){let c="",l=!1;try{let u=(0,Gt.execSync)(`dotnet user-secrets get "${s}"`,{cwd:process.cwd(),encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();u&&!u.includes("No secrets configured")&&!u.includes("was not found")&&(c=u,l=!0,t.debug(`Found ${s} in dotnet user-secrets`))}catch{}!c&&n&&(s==="PROJECT_ID"&&n.projectId?c=n.projectId:s==="PROJECT_ID_API_KEY"&&n.keyId?c=n.keyId:s==="PROJECT_ID_API_SECRET"&&n.keySecret?(c=n.keySecret,l=!0):s==="VOICE_APPLICATION_KEY"&&n.applicationKey?c=n.applicationKey:s==="VOICE_APPLICATION_SECRET"&&n.applicationSecret&&(c=n.applicationSecret,l=!0)),c&&(e[s]={Value:c,Secret:l})}else e[s]={Value:String(a),Secret:!1}}}catch(r){t.debug("Could not read appsettings.json: "+r.message)}}else{let i=me.default.join(process.cwd(),".env");if(await X.default.pathExists(i))try{let r=await X.default.readFile(i,"utf8"),s={};r.split(`
44
44
  `).forEach(a=>{if(a.trim()&&!a.trim().startsWith("#")){let[c,...l]=a.split("=");c&&(s[c.trim()]=l.join("=").trim())}});for(let[a,c]of Object.entries(s))if(c===""||c===null||c===void 0){let l="",u=!1;n&&(a==="PROJECT_ID"&&n.projectId?l=n.projectId:a==="PROJECT_ID_API_KEY"&&n.keyId?l=n.keyId:a==="PROJECT_ID_API_SECRET"&&n.keySecret?(l=n.keySecret,u=!0):a==="VOICE_APPLICATION_KEY"&&n.applicationKey?l=n.applicationKey:a==="VOICE_APPLICATION_SECRET"&&n.applicationSecret&&(l=n.applicationSecret,u=!0)),l&&(e[a]={Value:l,Secret:u})}else e[a]={Value:c,Secret:!1}}catch(r){t.debug("Could not read .env file: "+r.message)}}return e}async function uo(o,e){let i=Date.now(),r=!1,s;return t.newline(),d.start("\u23F3 Connecting to deployment stream..."),new Promise((a,c)=>{let l,u;t.debug(`Attempting to connect to SSE stream for function ${e}`),o.streamDeployment(e,g=>{t.debug(`SSE event received: ${g.type}`);let h=Math.floor((Date.now()-i)/1e3);switch(g.type){case"connected":d.text="\u23F3 Deployment stream connected, waiting for updates...";break;case"status":let S=g.data.data.message;d.text=`\u23F3 ${S} (${h}s)`;break;case"progress":let w=g.data.data.message,T=g.data.data.percentComplete;T?d.text=`\u23F3 ${w} (${T}%, ${h}s)`:d.text=`\u23F3 ${w} (${h}s)`;break;case"completed":r=!0,s=g.data.data.url,d.succeed("\u2705 Function deployed successfully"),o.getFunction(e).then(async $=>{if(t.newline(),t.info("\u{1F389} Deployment Complete!"),t.info(` Function: ${v.default.cyan($.name)}`),t.info(` Status: ${ct("Running")}`),t.info(` URL: ${v.default.blue(s)}`),s){t.newline(),t.info("\u{1F4DE} Voice Integration:");try{d.start("Updating Sinch Voice callback URL..."),await it(s),d.succeed("Voice callback URL updated automatically"),t.info(` Callback URL set to: ${v.default.cyan(s)}`)}catch(b){d.fail("Failed to update callback URL automatically"),t.warn(` Error: ${b.message}`),t.info(` Manual setup: ${v.default.cyan(`sinch voice callback-url ${s}`)}`)}t.info(` Test function: ${v.default.cyan(`curl ${s}`)}`)}t.newline(),t.info("\u{1F4A1} Next steps:"),t.info(` \u2022 View logs: ${v.default.cyan(`sinch functions logs ${e} --follow`)}`),t.info(` \u2022 Check status: ${v.default.cyan(`sinch functions status ${e}`)}`),l&&l(),u&&clearTimeout(u),a()}).catch($=>{t.error(`Failed to get function details: ${$.message}`),l&&l(),u&&clearTimeout(u),a()});break;case"failed":r=!0;let V=g.data.data.errorMessage;d.fail("\u274C Deployment failed"),t.newline(),t.error("Deployment failed:"),V&&t.error(` ${V}`),t.newline(),t.info("\u{1F4A1} Troubleshooting:"),t.info(` \u2022 Check logs: ${v.default.cyan(`sinch functions logs ${e}`)}`),t.info(` \u2022 Check status: ${v.default.cyan(`sinch functions status ${e}`)}`),l&&l(),u&&clearTimeout(u),process.exit(1);break}},g=>{t.debug("SSE stream error, falling back to polling:",g),console.error("SSE Error details:",g),d.text="\u23F3 Deployment stream unavailable, checking status...",l&&l(),Vt(o,e,i,3e5).then(a).catch(c)}).then(g=>{t.debug("SSE stream setup successful, cleanup function received"),l=g,u=setTimeout(()=>{r||(d.fail("\u23F0 Deployment timeout"),t.newline(),t.warn("Deployment is taking longer than expected"),t.info("\u{1F4A1} Check deployment progress with:"),t.info(` ${v.default.cyan(`sinch functions status ${e}`)}`),l&&l(),a())},3e5)}).catch(g=>{t.debug(`Failed to set up SSE stream, falling back to polling: ${g.message}`),Vt(o,e,i,3e5).then(a).catch(c)})})}async function Vt(o,e,n,i){for(;Date.now()-n<i;){try{let a=(await o.getFunctionStatus(e)).function;if(a.status==="Running"){if(d.succeed("\u2705 Function deployed successfully"),t.newline(),t.info("\u{1F389} Deployment Complete!"),t.info(` Function: ${v.default.cyan(a.name)}`),t.info(` Status: ${ct(a.status)}`),t.info(` URL: ${v.default.blue(a.containerAppUrl)}`),a.containerAppUrl){t.newline(),t.info("\u{1F4DE} Voice Integration:");try{d.start("Updating Sinch Voice callback URL..."),await it(a.containerAppUrl),d.succeed("Voice callback URL updated automatically"),t.info(` Callback URL set to: ${v.default.cyan(a.containerAppUrl)}`)}catch(l){d.fail("Failed to update callback URL automatically"),t.warn(` Error: ${l.message}`),t.info(` Manual setup: ${v.default.cyan(`sinch voice callback-url ${a.containerAppUrl}`)}`)}t.info(` Test function: ${v.default.cyan(`curl ${a.containerAppUrl}`)}`)}t.newline(),t.info("\u{1F4A1} Next steps:"),t.info(` \u2022 View logs: ${v.default.cyan(`sinch functions logs ${e} --follow`)}`),t.info(` \u2022 Check status: ${v.default.cyan(`sinch functions status ${e}`)}`);return}a.status==="Failed"&&(d.fail("\u274C Deployment failed"),t.newline(),t.error("Deployment failed:"),a.errorMessage&&t.error(` ${a.errorMessage}`),t.newline(),t.info("\u{1F4A1} Troubleshooting:"),t.info(` \u2022 Check logs: ${v.default.cyan(`sinch functions logs ${e}`)}`),t.info(` \u2022 Check status: ${v.default.cyan(`sinch functions status ${e}`)}`),process.exit(1));let c=Math.floor((Date.now()-n)/1e3);d.text=`\u23F3 Deploying function... (${a.status}, ${c}s)`}catch(s){t.debug(`Status check failed: ${s.message}`)}await new Promise(s=>setTimeout(s,3e3))}d.fail("\u23F0 Deployment timeout"),t.newline(),t.warn("Deployment is taking longer than expected"),t.info("\u{1F4A1} Check deployment progress with:"),t.info(` ${v.default.cyan(`sinch functions status ${e}`)}`)}function ct(o){return{Running:v.default.green("\u2705 Running"),Failed:v.default.red("\u274C Failed"),Pending:v.default.yellow("\u23F3 Pending"),Building:v.default.blue("\u{1F528} Building")}[o]||v.default.gray(o)}async function po(o,e){let n=!1;if(e.docs===!1){t.info("Skipping documentation generation (--no-docs flag)");return}if(e.nonInteractive)t.info("Generating documentation (non-interactive mode)"),n=!0;else{if(o.docsPreference==="never")return;if(fo(o))n=!0;else{let i=await Ht.default.prompt([{type:"list",name:"docsChoice",message:"Generate/update documentation before deployment?",choices:[{name:"Yes - Generate documentation this time",value:"yes"},{name:"No - Skip documentation this time",value:"no"},{name:"Always - Generate documentation and remember preference",value:"always"},{name:"Never - Don't generate documentation and remember preference",value:"never"}],default:"yes"}]);i.docsChoice==="yes"?n=!0:i.docsChoice==="no"?n=!1:i.docsChoice==="always"?(n=!0,p.set("docsPreference","always",!0),await p.saveProjectConfig()):i.docsChoice==="never"&&(n=!1,p.set("docsPreference","never",!0),await p.saveProjectConfig())}}if(n)try{d.start("\u{1F4DD} Generating documentation...");let{generateDocsFromLocal:i,saveDocumentationToFile:r}=(at(),D(qt)),s=await i(),a=me.default.basename(process.cwd());await r(s,"README.md",a),d.succeed("\u{1F4DD} Documentation updated in README.md")}catch(i){d.warn(`\u26A0\uFE0F Failed to generate documentation: ${i.message}`),t.warn("Continuing with deployment...")}}function fo(o){return o.docsPreference==="always"}zt.exports=Yt});var nn=N((Gi,tn)=>{"use strict";var L=m(require("fs-extra")),ne=m(require("path")),he=m(require("chalk")),lt=require("child_process"),Zt=m(require("chokidar")),Xt=require("commander"),Me=m(require("inquirer"));A();B();F();var en=new Xt.Command("dev");en.description("Start local development server").option("-p, --port <port>","Port to run on","3000").option("--no-watch","Disable file watching").option("-d, --debug","Enable debugging with --inspect").option("--tunnel","Force ngrok tunnel creation").option("--no-tunnel",'Disable ngrok tunnel and reset "always" preference').action(async o=>{try{if(await p.load(),!p.isInProject())throw new Error('Not in a Sinch Functions project directory. Run "sinch functions init" first.');let e=p.getProjectConfig();if(!e)throw new Error("No project configuration found");if((e.runtime||"node")==="csharp"){if((await L.default.readdir(process.cwd()).then(r=>r.filter(s=>s.endsWith(".csproj")))).length===0)throw new Error("No .csproj file found. Make sure you're in a valid C# function directory.")}else{let i=ne.default.join(process.cwd(),"host.js");if(!await L.default.pathExists(i))throw new Error("host.js not found. Make sure you're in a valid Node.js function directory.")}t.title(`Starting ${e.name} (${e.runtime})`),t.info(`Port: ${o.port}`),t.info(`Watch: ${o.watch?"enabled":"disabled"}`),o.debug&&t.info("Debug: enabled on port 9229"),t.newline(),await go(o,e)}catch(e){d.stop(),t.error(`Failed to start development server: ${e.message}`),process.exit(1)}});async function go(o,e){let n=e.runtime||"node",i=null,r=!1;if(o.tunnel===!0)r=!0;else if(o.tunnel===!1)r=!1,e.tunnel?.preference==="always"&&(p.set("tunnel",{...e.tunnel,preference:"no"},!0),await p.saveProjectConfig());else if(e.tunnel?.preference==="never")r=!1;else if(Co(e))r=!0;else{let{tunnelChoice:u}=await Me.default.prompt([{type:"list",name:"tunnelChoice",message:"Create sinch tunnel for external access?",choices:[{name:"Yes - Create tunnel this time",value:"yes"},{name:"No - Local only this time",value:"no"},{name:"Always - Create tunnel and remember preference",value:"always"},{name:"Never - Don't create tunnel and remember preference",value:"never"}],default:"no"}]);u==="yes"?r=!0:u==="no"?r=!1:u==="always"?(r=!0,p.set("tunnel",{...e.tunnel,preference:"always"},!0),await p.saveProjectConfig()):u==="never"&&(r=!1,p.set("tunnel",{...e.tunnel,preference:"never"},!0),await p.saveProjectConfig())}r&&(i=await bo(o.port,e));let s={...process.env,PORT:o.port,NODE_ENV:"development",SINCH_FUNCTIONS_LOCAL:"true",SINCH_TUNNEL:r?"true":"false"};e.variables&&Object.entries(e.variables).forEach(([u,g])=>{s[u]=g});try{let u=await p.getApplicationCredentials(e.voiceAppKey);u?(s.SINCH_APPLICATION_KEY=u.applicationKey,s.SINCH_APPLICATION_SECRET=u.applicationSecret,t.debug("\u2705 Injected application credentials for voice operations")):t.debug("\u26A0\uFE0F No application credentials found - voice features may not work")}catch(u){t.debug(`\u26A0\uFE0F Could not load application credentials: ${u.message}`)}t.info("\u{1F680} Starting local server...");let a=null,c=!1;function l(){if(a&&a.kill(),n==="csharp"){let u=["run"];o.port&&u.push("--urls",`http://localhost:${o.port}`),o.debug&&(s.ASPNETCORE_ENVIRONMENT="Development",s.ASPNETCORE_URLS=`http://localhost:${o.port}`),a=(0,lt.spawn)("dotnet",u,{env:s,stdio:"inherit",cwd:process.cwd()})}else{let u=ne.default.join(process.cwd(),"host.js"),g=[];o.debug&&g.push("--inspect=9229"),g.push(u),a=(0,lt.spawn)("node",g,{env:s,stdio:"inherit",cwd:process.cwd()})}a.on("spawn",async()=>{c||(c=!0,t.newline(),t.success(`\u2705 Server running on http://localhost:${o.port}`),o.debug&&(t.newline(),n==="csharp"?vo():ho()),t.newline(),t.info("\u{1F4A1} Development commands:"),t.info(` \u2022 Test function: ${he.default.cyan(`curl http://localhost:${o.port}`)}`),t.info(` \u2022 View in browser: ${he.default.cyan(`http://localhost:${o.port}`)}`),i&&t.info(` \u2022 Tunnel URL: ${he.default.cyan(i)}`),t.info(` \u2022 Stop server: ${he.default.gray("Ctrl+C")}`),o.watch&&t.info(` \u2022 File watching: ${he.default.green("enabled")}`))}),a.on("error",u=>{t.error(`Server error: ${u.message}`)}),a.on("exit",(u,g)=>{g!=="SIGTERM"&&g!=="SIGKILL"&&t.error(`Server exited with code ${u}`)})}l(),o.watch&&mo(()=>{t.info("\u{1F4DD} Files changed, restarting server..."),l()},n),process.on("SIGINT",()=>{t.newline(),t.info("\u{1F534} Stopping development server..."),a&&a.kill("SIGTERM"),process.exit(0)}),await new Promise(()=>{})}function mo(o,e="node"){let n=[".git/**",".DS_Store","*.tmp",".sinch-tmp/**"];e==="csharp"?n.push("bin/**","obj/**","*.user",".vs/**"):n.push("node_modules/**");let i=Zt.default.watch(".",{ignored:n,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:10}});i.on("change",r=>{t.debug(`File changed: ${r}`),o()}),i.on("add",r=>{t.debug(`File added: ${r}`),o()}),i.on("unlink",r=>{t.debug(`File removed: ${r}`),o()})}async function ho(){try{let o=await Ie("code",".vscode"),e=await Ie("cursor",".cursor"),n=await Ie("webstorm",".idea");if(o||e){let i=o?"VS Code":"Cursor",r=".vscode";if(t.info(`\u{1F41B} ${i} detected! Debug setup:`),await wo(r))t.info(" 1. \u2705 Created .vscode/launch.json for you");else{let a=ne.default.join(process.cwd(),r,"launch.json");await L.default.pathExists(a)?t.info(" 1. \u2705 Found existing .vscode/launch.json"):t.info(" 1. \u26A0\uFE0F Could not create .vscode/launch.json")}t.info(" 2. \u{1F50D} Press F5 to attach debugger"),t.info(" 3. \u{1F534} Set breakpoints in your function.js"),t.info(" 4. \u{1F4DE} Test your function to hit breakpoints")}else n?(t.info("\u{1F41B} WebStorm detected! Debug setup:"),t.info(" 1. \u{1F50D} Run \u2192 Attach to Node.js/Chrome \u2192 localhost:9229"),t.info(" 2. \u{1F534} Set breakpoints in your function.js")):(t.info("\u{1F41B} Manual debug setup:"),t.info(' \u2022 VS Code/Cursor: Open "Run and Debug" \u2192 "Attach to Node.js Process"'),t.info(' \u2022 Chrome DevTools: Visit chrome://inspect \u2192 Click "inspect"'),t.info(" \u2022 Manual: Connect debugger to ws://localhost:9229"))}catch{t.info("\u{1F41B} Debug instructions:"),t.info(" \u2022 Connect your debugger to ws://localhost:9229"),t.info(" \u2022 Set breakpoints and test your function")}}async function Ie(o,e){try{if(o==="code"&&yo())return!0;let{spawn:n}=require("child_process"),i=await new Promise(s=>{let a=n(o,["--version"],{stdio:"pipe"});a.on("close",c=>s(c===0)),a.on("error",()=>s(!1))}),r=e?await L.default.pathExists(e):!1;return i||r}catch{return!1}}function yo(){return process.env.TERM_PROGRAM==="vscode"||!!process.env.VSCODE_IPC_HOOK||!!process.env.VSCODE_PID}async function wo(o=".vscode"){try{let e=ne.default.join(process.cwd(),o),n=ne.default.join(e,"launch.json");if(await L.default.pathExists(n))return!1;await L.default.ensureDir(e);let i={version:"0.2.0",configurations:[{name:"Attach to Sinch Function",type:"node",request:"attach",port:9229,localRoot:"${workspaceFolder}",remoteRoot:"${workspaceFolder}",skipFiles:["<node_internals>/**","node_modules/**"]}]};return await L.default.writeJson(n,i,{spaces:2}),!!await L.default.pathExists(n)}catch{return!1}}function Co(o){return o.tunnel?o.tunnel.preference==="always":!1}async function bo(o,e){try{let n=require("ngrok");await So(),t.info("\u{1F310} Starting ngrok tunnel...");let i={port:o};e.tunnel&&e.tunnel.subdomain&&(i.subdomain=e.tunnel.subdomain);let r=await n.connect(i);t.success(`\u{1F310} Tunnel created: ${he.default.blue(r)}`);let s=e.tunnel?.preference||"no";return p.set("tunnel",{preference:s,lastUpdated:new Date().toISOString(),subdomain:i.subdomain||r.split("//")[1]?.split(".")[0],lastUrl:r},!0),await p.saveProjectConfig(),r}catch(n){return t.warn(`Failed to create tunnel: ${n.message}`),t.info("\u{1F4A1} You can still test locally on http://localhost:"+o),null}}async function So(){if(p.get("ngrokAuthToken"))return;let e=p.getProjectConfig();if(e&&e.ngrokAuthPrompted)return;t.newline(),t.info("\u{1F510} Ngrok authentication enables:"),t.info(" \u2022 Persistent subdomain URLs"),t.info(" \u2022 Longer tunnel sessions"),t.info(" \u2022 Custom subdomains (with paid plan)"),t.newline();let{setupAuth:n}=await Me.default.prompt([{type:"confirm",name:"setupAuth",message:"Would you like to add your ngrok auth token for persistent URLs?",default:!0}]);if(n){t.info("Get your free auth token at: https://dashboard.ngrok.com/get-started/your-authtoken"),t.newline();let{authToken:i}=await Me.default.prompt([{type:"input",name:"authToken",message:"Enter your ngrok auth token:",validate:r=>!r||r.trim().length<10?"Please enter a valid ngrok auth token":!0}]);try{await require("ngrok").authtoken(i.trim()),p.set("ngrokAuthToken",i.trim()),await p.save(),t.success("\u2705 Ngrok authentication configured")}catch(r){t.error(`Failed to configure ngrok auth: ${r.message}`)}}else p.set("ngrokAuthPrompted",!0,!0),await p.saveProjectConfig(),t.info("\u{1F4A1} You can configure ngrok auth later with: sinch tunnel setup")}async function vo(){try{let o=await Ie("code",".vscode"),e=await Ie("devenv"),n=await Ie("rider",".idea");o?(t.info("\u{1F41B} VS Code detected! Debug setup:"),await $o(".vscode")?t.info(" 1. \u2705 Created .vscode/launch.json for C#"):t.info(" 1. \u2705 Found existing .vscode/launch.json"),t.info(" 2. \u{1F50D} Press F5 to attach debugger"),t.info(" 3. \u{1F534} Set breakpoints in your Function.cs"),t.info(" 4. \u{1F4DE} Test your function to hit breakpoints")):e?(t.info("\u{1F41B} Visual Studio detected! Debug setup:"),t.info(" 1. \u{1F50D} Debug \u2192 Attach to Process \u2192 dotnet.exe"),t.info(" 2. \u{1F534} Set breakpoints in your Function.cs"),t.info(" 3. \u{1F4DE} Test your function to hit breakpoints")):n?(t.info("\u{1F41B} JetBrains Rider detected! Debug setup:"),t.info(" 1. \u{1F50D} Run \u2192 Attach to Process \u2192 dotnet"),t.info(" 2. \u{1F534} Set breakpoints in your Function.cs")):(t.info("\u{1F41B} C# Debug setup:"),t.info(" \u2022 Visual Studio: Debug \u2192 Attach to Process \u2192 dotnet.exe"),t.info(" \u2022 VS Code: Install C# extension, then F5 to debug"),t.info(" \u2022 Rider: Run \u2192 Attach to Process"))}catch{t.info("\u{1F41B} C# Debug instructions:"),t.info(" \u2022 Attach your debugger to the dotnet process"),t.info(" \u2022 Set breakpoints in Function.cs")}}async function $o(o=".vscode"){try{let e=ne.default.join(process.cwd(),o),n=ne.default.join(e,"launch.json");if(await L.default.pathExists(n))return!1;await L.default.ensureDir(e);let i={version:"0.2.0",configurations:[{name:".NET Core Launch (web)",type:"coreclr",request:"launch",preLaunchTask:"build",program:"${workspaceFolder}/bin/Debug/net8.0/Function.dll",args:[],cwd:"${workspaceFolder}",stopAtEntry:!1,serverReadyAction:{action:"openExternally",pattern:"\\bNow listening on:\\s+(https?://\\S+)"},env:{ASPNETCORE_ENVIRONMENT:"Development"},sourceFileMap:{"/Views":"${workspaceFolder}/Views"}},{name:".NET Core Attach",type:"coreclr",request:"attach"}]};await L.default.writeJson(n,i,{spaces:2});let r=ne.default.join(e,"tasks.json");if(!await L.default.pathExists(r)){let s={version:"2.0.0",tasks:[{label:"build",command:"dotnet",type:"process",args:["build","${workspaceFolder}/Function.csproj","/property:GenerateFullPaths=true","/consoleloggerparameters:NoSummary"],problemMatcher:"$msCompile"}]};await L.default.writeJson(r,s,{spaces:2})}return await L.default.pathExists(n)}catch{return!1}}tn.exports=en});var cn=N((Xi,an)=>{"use strict";var q=m(require("chalk")),on=require("commander");_();A();B();F();var rn=new on.Command("status");rn.description("Show function status and details").argument("[function-id]","Function ID to check (optional if sinch.json exists)").option("-f, --follow","Watch status changes in real-time").option("--json","Output raw JSON").action(async(o,e)=>{try{await p.load();let n=new E(p.getApiConfig()),i=o;if(!i){if(!p.isInProject())throw new Error("Function ID required. Provide as argument or run from function directory with sinch.json");if(i=p.getProjectConfig()?.functionId,!i)throw new Error("No function ID found in sinch.json. Deploy the function first or provide function ID as argument.")}e.follow?await Po(n,i):await ko(n,i,e)}catch(n){d.stop(),t.error(`Failed to get function status: ${n.message}`),process.exit(1)}});async function ko(o,e,n){d.start("\u{1F4E1} Loading function status...");try{let i=await o.getFunction(e),r=await o.getFunctionStatus(e);if(d.stop(),n.json){console.log(JSON.stringify({function:i,deployment:r},null,2));return}let s=i,a=r.status,c=r.error;t.newline(),t.title(`Function Status: ${s.name}`),t.newline(),t.info("\u{1F4CB} Function Details:"),t.info(` ID: ${q.default.gray(s.id)}`),t.info(` Name: ${q.default.cyan(s.name)}`),t.info(` Runtime: ${q.default.yellow(s.runtime)}`),t.info(` Deployment Status: ${sn(a)}`),s.created&&t.info(` Created: ${new Date(s.created).toLocaleString()}`),s.updated&&t.info(` Updated: ${new Date(s.updated).toLocaleString()}`),s.url&&t.info(` URL: ${q.default.blue(s.url)}`),a==="Failed"&&c&&(t.newline(),t.error("Deployment Error:"),t.error(` ${c}`)),t.newline(),t.info("\u{1F4A1} Commands:"),t.info(` \u2022 View logs: ${q.default.cyan(`sinch functions logs ${e}`)}`),t.info(` \u2022 Redeploy: ${q.default.cyan("sinch functions deploy")}`),t.info(` \u2022 Delete: ${q.default.cyan(`sinch functions delete ${e}`)}`)}catch(i){throw d.stop(),i}}async function Po(o,e){t.info("\u{1F440} Watching deployment status (press Ctrl+C to stop)..."),t.newline();let n=null,i=setInterval(async()=>{try{let r=await o.getFunctionStatus(e),s=r.status;if(s!==n){let a=new Date().toLocaleTimeString();if(t.info(`[${a}] Status: ${sn(s)}`),n=s,s==="Running"){t.success("Function deployment is now running!");try{let c=await o.getFunction(e);c.url&&t.info(`URL: ${q.default.blue(c.url)}`)}catch{}}else s==="Failed"&&(t.error("Function deployment failed!"),r.error&&t.error(`Error: ${r.error}`),clearInterval(i))}}catch(r){t.error(`Error checking status: ${r.message}`)}},3e3);process.on("SIGINT",()=>{clearInterval(i),t.newline(),t.info("Stopped watching function status"),process.exit(0)})}function sn(o){return{Running:q.default.green("\u2705 Running"),Failed:q.default.red("\u274C Failed"),Pending:q.default.yellow("\u23F3 Pending"),Building:q.default.blue("\u{1F528} Building")}[o]||q.default.gray(o)}an.exports=rn});var yn=N((ir,hn)=>{"use strict";var ye=m(require("chalk")),dn=require("commander");_();A();B();F();var ut=require("child_process"),Fe=m(require("fs")),Oe=m(require("os")),_e=m(require("path")),dt=new dn.Command("logs");dt.description("View function logs").argument("[function-id]","Function ID to get logs for (optional if sinch.json exists)").option("-f, --follow","Follow log output in real-time").option("-n, --lines <number>","Number of historical lines to show","50").option("--level <level>","Filter by log level (debug, info, warning, error)").option("--search <text>","Search for text in log messages").option("--since <duration>","Show logs since duration (e.g., 1h, 30m, 5s)").action(async(o,e)=>{try{await p.load();let n=new E(p.getApiConfig()),i=o;if(!i){if(!p.isInProject())throw new Error("Function ID required. Provide as argument or run from function directory with sinch.json");let s=p.getProjectConfig();if(!s)throw new Error("No project configuration found");if(i=s.functionId,!i)throw new Error("No function ID found in sinch.json. Deploy the function first or provide function ID as argument.")}d.start("Loading function details...");let r=await n.getFunction(i);d.stop(),t.info(`\u{1F4CB} Logs for function: ${ye.default.cyan(r.name)} (${Io(r.status)})`),t.newline(),e.follow?await pn(n,i,r.name,e):await Lo(n,i,e)}catch(n){d.stop(),t.error(`Failed to get logs: ${n.message}`),process.exit(1)}});dt.command("stream").description("Stream function logs in real-time").argument("[function-id]","Function ID to stream logs for (optional if sinch.json exists)").option("--level <level>","Filter by log level (debug, info, warning, error)").option("--search <text>","Search for text in log messages").action(async(o,e)=>{try{await p.load();let n=new E(p.getApiConfig()),i=o;if(!i){if(!p.isInProject())throw new Error("Function ID required. Provide as argument or run from function directory with sinch.json");let s=p.getProjectConfig();if(!s)throw new Error("No project configuration found");if(i=s.functionId,!i)throw new Error("No function ID found in sinch.json. Deploy the function first or provide function ID as argument.")}d.start("Connecting to log stream...");let r=await Eo(n,i);d.stop(),await pn(n,i,r.name,{...e,follow:!0})}catch(n){d.stop(),t.error(`Failed to stream logs: ${n.message}`),process.exit(1)}});async function Eo(o,e){return await o.getFunction(e)}async function pn(o,e,n,i){let r=o.baseUrl.replace(/\/+$/,""),s=o.projectId,a=`${r}/v1/projects/${s}/functions/${e}/logs/stream`,c=o.credentials,l=[],u=gn(l,"STREAMING",n),g={Accept:"text/event-stream","Cache-Control":"no-cache"};if(c)try{let S=await c.retrieve();if(S&&S.keyId&&S.keySecret){let w=Buffer.from(`${S.keyId}:${S.keySecret}`).toString("base64");g.Authorization=`Basic ${w}`}}catch(S){t.debug("Failed to add authentication:",S)}let h=new AbortController;try{let S=await fetch(a,{method:"GET",headers:g,signal:h.signal});if(!S.ok)throw new Error(`SSE connection failed: ${S.status} ${S.statusText}`);if(!S.body)throw new Error("Response body is null");ln(u.statusBar,"CONNECTED",n),u.screen.render();let w=S.body.getReader(),T=new TextDecoder,V="";(async()=>{try{for(;;){let{done:b,value:C}=await w.read();if(b)break;V+=T.decode(C,{stream:!0});let y=V.split(`
45
- `);V=y.pop()||"";for(let P of y)if(!P.startsWith("event:")&&P.startsWith("data:")){let Q=P.substring(5).trim();if(Q)try{let I=JSON.parse(Q);l.push(I),fn(u.table,I,l),u.table.focus(),u.screen.render()}catch{}}}}catch(b){b.name!=="AbortError"&&(ln(u.statusBar,"RECONNECTING",n),u.screen.render())}})(),u.screen.key(["q","C-c"],()=>{h.abort(),process.exit(0)}),await new Promise(()=>{})}catch(S){h.abort(),t.error(`\u274C Streaming failed: ${S.message}`),process.exit(1)}}function Io(o){return{Running:ye.default.green("\u2705 Running"),Failed:ye.default.red("\u274C Failed"),Pending:ye.default.yellow("\u23F3 Pending"),Building:ye.default.blue("\u{1F528} Building")}[o]||ye.default.gray(o)}var we=[];function fn(o,e,n){let i=new Date(e.startTime),r=i.getFullYear()+"-"+String(i.getMonth()+1).padStart(2,"0")+"-"+String(i.getDate()).padStart(2,"0")+" "+String(i.getHours()).padStart(2,"0")+":"+String(i.getMinutes()).padStart(2,"0")+":"+String(i.getSeconds()).padStart(2,"0"),s=xo(e),a=`${e.executionTimeMs}ms`,c=e.statusCode.toString(),l=process.stdout.columns||120,g=Math.max(30,l-35),h=e.url.length>g?e.url.substring(0,g-2)+"..":e.url;we.push([r,s,a,c,h]),we.length>100&&(we=we.slice(-100),n&&n.length>100&&n.splice(0,n.length-100));let S=[["Time","Callback","Duration","Status","Path"],...we];o.setData(S)}function Ao(o,e,n,i,r){try{let s=require("blessed");t.debug(`Showing request details for ${o.httpMethod} ${o.url}`);let a=s.box({parent:e,top:0,left:0,width:"100%",height:"100%",border:{type:"line"},style:{border:{fg:"cyan"},bg:"black",fg:"white"},scrollable:!0,alwaysScroll:!0,keys:!0,vi:!0,tags:!0,label:" Request Details "}),c=s.box({parent:a,top:1,left:2,width:"100%-4",height:1,content:"{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J/1] JSON [C/2] cURL{/}",tags:!0,style:{bg:"blue",fg:"white"}});s.box({parent:a,top:2,left:2,width:"100%-4",height:1,content:`{bold}{cyan-fg}${o.httpMethod}{/} {blue-fg}${o.url}{/} - {${Oo(o.statusCode)}}${o.statusCode}{/} - {yellow-fg}${o.executionTimeMs}ms{/} - {magenta-fg}${o.memoryUsedMB||0}MB{/}`,tags:!0,style:{bg:"black"}});let l=s.box({parent:a,top:4,left:2,width:"100%-4",height:"100%-5",scrollable:!0,alwaysScroll:!0,keys:!0,vi:!0,tags:!0,content:Ro(o)});l.focus(),e.render();let u=!0,g=()=>{u&&(u=!1,a.destroy(),n.focus(),e.render())};e.key(["escape","q"],()=>{u&&g()}),e.key(["up","k"],()=>{u&&(l.scroll(-1),e.render())}),e.key(["down","j"],()=>{u&&(l.scroll(1),e.render())}),e.on("keypress",(h,S)=>{u&&t.debug(`Key pressed: ch="${h}" key=${JSON.stringify(S)}`)}),e.key(["J","j"],()=>{u&&(t.debug("J/j key pressed - attempting JSON copy"),c.setContent("{black-bg}{yellow-fg} J KEY PRESSED - COPYING JSON... {/}"),e.render(),setTimeout(()=>{try{let h=JSON.stringify(o,null,2);t.debug(`JSON content length: ${h.length}`),t.debug("Attempting native clipboard copy"),We(h).then(()=>{c.setContent("{green-fg}\u2713 Request JSON copied to clipboard!{/}"),t.debug("Native clipboard copy succeeded"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{t.debug(`Native clipboard failed: ${S.message}`);let w=_e.default.join(Oe.default.tmpdir(),`sinch-request-${Date.now()}.json`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 JSON saved to: ${w}{/}`),t.debug(`Saved to temp file: ${w}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){t.debug(`JSON copy error: ${h.message}`),c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["C","c"],()=>{u&&(t.debug("C/c key pressed - attempting cURL copy"),c.setContent("{black-bg}{yellow-fg} C KEY PRESSED - COPYING CURL... {/}"),e.render(),setTimeout(()=>{try{let h=un(o);t.debug("Attempting native clipboard copy for cURL"),We(h).then(()=>{c.setContent("{green-fg}\u2713 cURL command copied to clipboard!{/}"),t.debug("Native clipboard copy succeeded for cURL"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{t.debug(`Native clipboard failed for cURL: ${S.message}`);let w=_e.default.join(Oe.default.tmpdir(),`sinch-curl-${Date.now()}.sh`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 cURL saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){t.debug(`cURL copy error: ${h.message}`),c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["1"],()=>{u&&(t.debug("1 key pressed - copying JSON (alternative binding)"),c.setContent("{black-bg}{yellow-fg} 1 KEY - COPYING JSON... {/}"),e.render(),setTimeout(()=>{try{let h=JSON.stringify(o,null,2);We(h).then(()=>{c.setContent("{green-fg}\u2713 Request JSON copied to clipboard!{/}"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{let w=_e.default.join(Oe.default.tmpdir(),`sinch-request-${Date.now()}.json`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 JSON saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["2"],()=>{u&&(t.debug("2 key pressed - copying cURL (alternative binding)"),c.setContent("{black-bg}{yellow-fg} 2 KEY - COPYING CURL... {/}"),e.render(),setTimeout(()=>{try{let h=un(o);We(h).then(()=>{c.setContent("{green-fg}\u2713 cURL command copied to clipboard!{/}"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{let w=_e.default.join(Oe.default.tmpdir(),`sinch-curl-${Date.now()}.sh`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 cURL saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))})}catch(s){t.debug(`Error in showBlessedZoomedRequest: ${s.message}`)}}function Ro(o){let e="";return e+=`
45
+ `);V=y.pop()||"";for(let P of y)if(!P.startsWith("event:")&&P.startsWith("data:")){let Q=P.substring(5).trim();if(Q)try{let I=JSON.parse(Q);I.type==="request"&&I.request&&(l.push(I.request),fn(u.table,I.request,l),u.table.focus(),u.screen.render())}catch{}}}}catch(b){b.name!=="AbortError"&&(ln(u.statusBar,"RECONNECTING",n),u.screen.render())}})(),u.screen.key(["q","C-c"],()=>{h.abort(),process.exit(0)}),await new Promise(()=>{})}catch(S){h.abort(),t.error(`\u274C Streaming failed: ${S.message}`),process.exit(1)}}function Io(o){return{Running:ye.default.green("\u2705 Running"),Failed:ye.default.red("\u274C Failed"),Pending:ye.default.yellow("\u23F3 Pending"),Building:ye.default.blue("\u{1F528} Building")}[o]||ye.default.gray(o)}var we=[];function fn(o,e,n){let i=new Date(e.startTime),r=i.getFullYear()+"-"+String(i.getMonth()+1).padStart(2,"0")+"-"+String(i.getDate()).padStart(2,"0")+" "+String(i.getHours()).padStart(2,"0")+":"+String(i.getMinutes()).padStart(2,"0")+":"+String(i.getSeconds()).padStart(2,"0"),s=xo(e),a=`${e.executionTimeMs}ms`,c=e.statusCode.toString(),l=process.stdout.columns||120,g=Math.max(30,l-35),h=e.url.length>g?e.url.substring(0,g-2)+"..":e.url;we.push([r,s,a,c,h]),we.length>100&&(we=we.slice(-100),n&&n.length>100&&n.splice(0,n.length-100));let S=[["Time","Callback","Duration","Status","Path"],...we];o.setData(S)}function Ao(o,e,n,i,r){try{let s=require("blessed");t.debug(`Showing request details for ${o.httpMethod} ${o.url}`);let a=s.box({parent:e,top:0,left:0,width:"100%",height:"100%",border:{type:"line"},style:{border:{fg:"cyan"},bg:"black",fg:"white"},scrollable:!0,alwaysScroll:!0,keys:!0,vi:!0,tags:!0,label:" Request Details "}),c=s.box({parent:a,top:1,left:2,width:"100%-4",height:1,content:"{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J/1] JSON [C/2] cURL{/}",tags:!0,style:{bg:"blue",fg:"white"}});s.box({parent:a,top:2,left:2,width:"100%-4",height:1,content:`{bold}{cyan-fg}${o.httpMethod}{/} {blue-fg}${o.url}{/} - {${Oo(o.statusCode)}}${o.statusCode}{/} - {yellow-fg}${o.executionTimeMs}ms{/} - {magenta-fg}${o.memoryUsedMB||0}MB{/}`,tags:!0,style:{bg:"black"}});let l=s.box({parent:a,top:4,left:2,width:"100%-4",height:"100%-5",scrollable:!0,alwaysScroll:!0,keys:!0,vi:!0,tags:!0,content:Ro(o)});l.focus(),e.render();let u=!0,g=()=>{u&&(u=!1,a.destroy(),n.focus(),e.render())};e.key(["escape","q"],()=>{u&&g()}),e.key(["up","k"],()=>{u&&(l.scroll(-1),e.render())}),e.key(["down","j"],()=>{u&&(l.scroll(1),e.render())}),e.on("keypress",(h,S)=>{u&&t.debug(`Key pressed: ch="${h}" key=${JSON.stringify(S)}`)}),e.key(["J","j"],()=>{u&&(t.debug("J/j key pressed - attempting JSON copy"),c.setContent("{black-bg}{yellow-fg} J KEY PRESSED - COPYING JSON... {/}"),e.render(),setTimeout(()=>{try{let h=JSON.stringify(o,null,2);t.debug(`JSON content length: ${h.length}`),t.debug("Attempting native clipboard copy"),We(h).then(()=>{c.setContent("{green-fg}\u2713 Request JSON copied to clipboard!{/}"),t.debug("Native clipboard copy succeeded"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{t.debug(`Native clipboard failed: ${S.message}`);let w=_e.default.join(Oe.default.tmpdir(),`sinch-request-${Date.now()}.json`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 JSON saved to: ${w}{/}`),t.debug(`Saved to temp file: ${w}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){t.debug(`JSON copy error: ${h.message}`),c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["C","c"],()=>{u&&(t.debug("C/c key pressed - attempting cURL copy"),c.setContent("{black-bg}{yellow-fg} C KEY PRESSED - COPYING CURL... {/}"),e.render(),setTimeout(()=>{try{let h=un(o);t.debug("Attempting native clipboard copy for cURL"),We(h).then(()=>{c.setContent("{green-fg}\u2713 cURL command copied to clipboard!{/}"),t.debug("Native clipboard copy succeeded for cURL"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{t.debug(`Native clipboard failed for cURL: ${S.message}`);let w=_e.default.join(Oe.default.tmpdir(),`sinch-curl-${Date.now()}.sh`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 cURL saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){t.debug(`cURL copy error: ${h.message}`),c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["1"],()=>{u&&(t.debug("1 key pressed - copying JSON (alternative binding)"),c.setContent("{black-bg}{yellow-fg} 1 KEY - COPYING JSON... {/}"),e.render(),setTimeout(()=>{try{let h=JSON.stringify(o,null,2);We(h).then(()=>{c.setContent("{green-fg}\u2713 Request JSON copied to clipboard!{/}"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{let w=_e.default.join(Oe.default.tmpdir(),`sinch-request-${Date.now()}.json`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 JSON saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))}),e.key(["2"],()=>{u&&(t.debug("2 key pressed - copying cURL (alternative binding)"),c.setContent("{black-bg}{yellow-fg} 2 KEY - COPYING CURL... {/}"),e.render(),setTimeout(()=>{try{let h=un(o);We(h).then(()=>{c.setContent("{green-fg}\u2713 cURL command copied to clipboard!{/}"),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}).catch(S=>{let w=_e.default.join(Oe.default.tmpdir(),`sinch-curl-${Date.now()}.sh`);Fe.default.writeFileSync(w,h),c.setContent(`{yellow-fg}\u2713 cURL saved to: ${w}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)})}catch(h){c.setContent(`{red-fg}\u2717 Copy failed: ${h.message}{/}`),e.render(),setTimeout(()=>{u&&(c.setContent("{gray-fg}[Esc/Q] Close [\u2191\u2193] Scroll [J] JSON [C] cURL{/}"),e.render())},3e3)}},100))})}catch(s){t.debug(`Error in showBlessedZoomedRequest: ${s.message}`)}}function Ro(o){let e="";return e+=`
46
46
  `,e+=To(o),e+=`
47
47
  `,e+=jo(o),e+=`
48
48
  `,e+=Do(o),e}function To(o){let e="",n=process.stdout.columns-6;e+="{bold}{green-fg}\u250C\u2500 REQUEST "+"\u2500".repeat(Math.max(0,n-10))+`\u2510{/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinch/cli",
3
- "version": "0.1.0-dev.2096736014",
3
+ "version": "0.1.0-dev.2106538252",
4
4
  "description": "Official Sinch CLI - Manage all Sinch products from your terminal",
5
5
  "main": "dist/index.js",
6
6
  "bin": {