coze-coding-dev-sdk 0.7.18-beta.33 → 0.7.18-beta.34
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/cjs/cli/index.js
CHANGED
|
@@ -104,7 +104,4 @@ Image URL: ${o.data[0].url}`)),e.output)){t.start("Downloading image...");let n=
|
|
|
104
104
|
✓ Result saved to: ${e.output}`)))}catch(e){t.fail(J.red("✗ Video generation failed")),console.error(J.red(`Error: ${e.message}`)),process.exit(1)}}),eG=new h("search").description("Search the web using AI").requiredOption("-q, --query <text>","Search query").option("--type <type>","Search type (web or image)","web").option("--count <number>","Number of results","10").option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{let t=eO("Searching...").start();try{let n,i=new m.Config,r=eH(e.header),a=new m.SearchClient(i,r,e.verbose);n="image"===e.type?await a.imageSearch(e.query,parseInt(e.count)):await a.webSearch(e.query,parseInt(e.count)),t.succeed(J.green("Search completed!")),"image"===e.type&&n.image_items?n.image_items.forEach((e,t)=>{console.log(J.cyan(`
|
|
105
105
|
[${t+1}] ${e.title||"Image"}`)),console.log(J.gray(e.url||"")),console.log(J.yellow(`Image URL: ${e.image.url}`))}):n.web_items&&n.web_items.forEach((e,t)=>{console.log(J.cyan(`
|
|
106
106
|
[${t+1}] ${e.title}`)),console.log(J.gray(e.url||"")),e.snippet&&console.log(e.snippet)})}catch(e){t.fail(J.red("Search failed")),console.error(J.red(e.message)),process.exit(1)}}),e$=new h("tts").description("Text-to-speech conversion").requiredOption("-t, --text <text>","Text to convert to speech").option("--speaker <speaker>","Speaker voice to use","zh_female_xiaohe_uranus_bigtts").option("--mock","Use mock mode (test run)").option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).action(async e=>{let t=eO("Converting text to speech...").start();try{let n=new m.Config,i={},r=eH(e.header);r&&Object.assign(i,r),e.mock&&(i[eF]=eZ,console.log(J.yellow("\uD83E\uDDEA Mock mode enabled (test run)")));let a=new m.TTSClient(n,Object.keys(i).length>0?i:void 0),o=await a.synthesize({uid:"cli-user",text:e.text,speaker:e.speaker});t.succeed(J.green("Text-to-speech conversion completed!")),console.log(J.cyan(`Audio URL: ${o.audioUri}`)),console.log(J.cyan(`Audio Size: ${o.audioSize} bytes`))}catch(e){t.fail(J.red("Text-to-speech conversion failed")),console.error(J.red(e.message)),process.exit(1)}}),eU=new h("asr").description("Automatic speech recognition").option("-u, --url <url>","Audio file URL").option("-f, --file <path>","Local audio file path (will be base64 encoded)").option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{let t=eO("Recognizing speech...").start();try{e.url||e.file||(t.fail(J.red("Please provide either --url or --file")),process.exit(1));let n=new m.Config,i=eH(e.header),r=new m.ASRClient(n,i,e.verbose),a=e.url?{url:e.url}:{base64Data:eN.readFileSync(eY.resolve(e.file)).toString("base64")},o=await r.recognize(a);t.succeed(J.green("Speech recognition completed!")),console.log(J.cyan("\nRecognized text:")),console.log(o.text)}catch(e){t.fail(J.red("Speech recognition failed")),console.error(J.red(e.message)),process.exit(1)}}),ez=new h("chat").description("Chat with AI using LLM").requiredOption("-p, --prompt <text>","User prompt").option("-s, --system <text>","System prompt").option("--model <model>","Model to use","doubao-seed-1-6-251015").option("--temperature <number>","Temperature (0-2)","0.7").option("--stream","Enable streaming output",!1).option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{try{let t=new m.Config,n=new m.LLMClient(t),i=eH(e.header),r=[];e.system&&r.push({role:"system",content:e.system}),r.push({role:"user",content:e.prompt});let a={model:e.model,temperature:parseFloat(e.temperature)};if(e.stream){for await(let e of(console.log(J.cyan("\nAI Response:")),n.stream(r,a,void 0,i)))e.content&&process.stdout.write(e.content.toString());console.log("\n")}else{let e=eO("Generating response...").start(),t=await n.invoke(r,a,void 0,i);e.succeed(J.green("Response generated!")),console.log(J.cyan("\nAI Response:")),console.log(t.content)}}catch(e){console.error(J.red("Chat failed")),console.error(J.red(e.message)),process.exit(1)}}),eQ=process.env.COZE_PROJECT_TYPE,eK="wechat_mini_program"===eQ,eq="app"===eQ,eV=(n=process.cwd(),i="server"===eY.basename(n),eK||eq?i?"src/storage/database/shared/schema.ts":"server/src/storage/database/shared/schema.ts":"src/storage/database/shared/schema.ts"),e0=new h("db").description("Database operations");e0.command("generate-models").description("Generate ORM models from database schema").option("-o, --output <path>","Output file path",eV).option("-v, --verbose","Enable verbose output").action(async e=>{let t=eO("Generating models from database...").start();try{let{generateModels:n}=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"./src/database/index.ts")),i=eY.resolve(e.output);await n({outputPath:i,verbose:e.verbose}),t.succeed(J.green(`Models generated at ${i}`))}catch(e){t.fail(J.red("Failed to generate models")),console.error(J.red(e.message)),process.exit(1)}}),e0.command("upgrade").description("Push schema changes to database").option("-s, --schema <path>","Schema file path",eV).option("-p, --project <path>","Project root path",process.cwd()).option("-v, --verbose","Enable verbose output").action(async e=>{let t=eO("Pushing schema to database...").start();try{let{upgrade:n}=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"./src/database/index.ts"));await n({schemaPath:e.schema,projectPath:e.project,verbose:e.verbose}),t.succeed(J.green("Database schema updated successfully"))}catch(e){t.fail(J.red("Failed to upgrade database")),console.error(J.red(e.message)),process.exit(1)}}),e0.command("diagnose").description("获取数据库运行状态诊断报告").option("-e, --env <env>","目标环境: dev 或 prod,不传则使用 token 中的环境").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/database/diagnose")),e.env&&console.log(J.cyan("\uD83D\uDCE4 Payload:"),{env:e.env}),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({report:{},mock:!0},null,2));return}let n=eO("Diagnosing database...").start();try{let{Config:i,SupabaseClient:r}=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"./src/index.ts")),a=new i,o=new r(a,t),s=await o.diagnoseDatabase(e.env);if(e.verbose&&(n.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code){let t=s.msg||"";if(t.toLowerCase().includes("record not found")){let t=e.env||"dev/prod";n.fail(J.red(`${t} 数据库还未创建,请先创建数据库后再进行诊断`))}else n.fail(J.red(`Error: ${t}`));process.exit(1)}n.succeed(J.green("Database diagnosis completed!")),console.log(JSON.stringify(s.report,null,2))}catch(e){n.fail(J.red("Failed to diagnose database")),console.error(J.red(e.message)),process.exit(1)}});let e1=new h("embedding").description("Generate embeddings for text, images, or videos using AI").option("-t, --text <text>","Text to embed (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("--image-url <url>","Image URL to embed (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("--video-url <url>","Video URL to embed (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("-d, --dimensions <number>","Output embedding dimensions",parseInt).option("--instructions <text>","Instructions for embedding generation").option("--multi-embedding","Enable multi-embedding mode").option("--sparse-embedding","Enable sparse embedding mode").option("-o, --output <path>","Output file path for embedding JSON").option("--mock","Use mock mode (test run)").option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{let t=e.text&&e.text.length>0,n=e.imageUrl&&e.imageUrl.length>0,i=e.videoUrl&&e.videoUrl.length>0;t||n||i||(console.error(J.red("Error: At least one of --text, --image-url, or --video-url is required")),process.exit(1));let r=eO("Generating embeddings...").start();try{let a=new m.Config,o={},s=eH(e.header);s&&Object.assign(o,s),e.mock&&(o[eF]=eZ,console.log(J.yellow("\uD83E\uDDEA Mock mode enabled (test run)")));let l=new m.EmbeddingClient(a,Object.keys(o).length>0?o:void 0,e.verbose),u=await l.embed(t?e.text:void 0,n?e.imageUrl:void 0,i?e.videoUrl:void 0,{dimensions:e.dimensions,instructions:e.instructions,multiEmbedding:e.multiEmbedding,sparseEmbedding:e.sparseEmbedding});if(r.succeed(J.green("Embeddings generated successfully!")),console.log(J.cyan(`Model: ${u.model}`)),u.data?.embedding&&(console.log(J.cyan(`Embedding dimensions: ${u.data.embedding.length}`)),console.log(J.gray(`First 5 values: [${u.data.embedding.slice(0,5).join(", ")}...]`))),u.data?.multi_embedding&&console.log(J.cyan(`Multi-embedding vectors: ${u.data.multi_embedding.length}`)),u.data?.sparse_embedding&&console.log(J.cyan(`Sparse embedding items: ${u.data.sparse_embedding.length}`)),u.usage&&console.log(J.gray(`Tokens used: ${u.usage.total_tokens}`)),e.output){let t=eY.resolve(e.output);eN.writeFileSync(t,JSON.stringify(u,null,2)),console.log(J.green(`Embedding saved to ${t}`))}}catch(e){r.fail(J.red("Failed to generate embeddings")),console.error(J.red(e.message)),process.exit(1)}}),e2=new h("knowledge").description("Knowledge Base tools");e2.command("search").description("Search for knowledge chunks").requiredOption("-q, --query <text>","Search query").option("-d, --dataset <name>","Dataset names (tables) to search in (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("-k, --top-k <number>","Number of results to return","5").option("-m, --min-score <number>","Minimum similarity score","0.0").option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{let t=eO("Searching...").start();try{let n=new m.Config,i=eH(e.header),r=new m.KnowledgeClient(n,i,e.verbose),a=await r.search(e.query,e.dataset.length>0?e.dataset:void 0,parseInt(e.topK),parseFloat(e.minScore));if(0!==a.code)return void t.fail(J.red(`Error ${a.code}: ${a.msg}`));t.succeed(J.green("Search completed!")),console.log(J.bold("\nSearch Results:")),console.log("────────────────────────────────────────────────────────────────────────────────"),0===a.chunks.length&&console.log(J.yellow("No matching chunks found.")),a.chunks.forEach((e,t)=>{console.log(J.cyan(`[${t+1}] Score: ${e.score.toFixed(4)}`)),e.doc_id&&console.log(J.dim(`Doc ID: ${e.doc_id}`)),e.chunk_id&&console.log(J.dim(`Chunk ID: ${e.chunk_id}`)),console.log(J.green("Content:")),console.log(e.content),console.log("────────────────────────────────────────────────────────────────────────────────")})}catch(e){t.fail(J.red("Search failed")),console.error(J.red(e.message)),process.exit(1)}}),e2.command("add").description("Add documents to knowledge base").requiredOption("-d, --dataset <name>","Dataset name (table) to add to").option("-c, --content <text>","Raw text content to add (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("-u, --url <url>","Web URL to add (can be used multiple times)",(e,t)=>t.concat([e]),[]).option("--chunk-separator <char>","Chunk separator","\\n").option("--max-tokens <number>","Max tokens per chunk","500").option("--remove-extra-spaces","Normalize extra spaces",!1).option("--remove-urls-emails","Strip URLs and emails",!1).option("-H, --header <header>",'Custom HTTP header (format: "Key: Value" or "Key=Value", can be used multiple times)',(e,t)=>t.concat([e]),[]).option("--verbose","Enable verbose logging to print HTTP request details",!1).action(async e=>{let t=eO("Adding documents...").start();try{let n=new m.Config,i=eH(e.header),r=new m.KnowledgeClient(n,i,e.verbose),a=[];if(e.content&&e.content.forEach(e=>{a.push({source:m.DataSourceType.TEXT,raw_data:e})}),e.url&&e.url.forEach(e=>{a.push({source:m.DataSourceType.URL,url:e})}),0===a.length)return void t.fail(J.red("No content or URL provided to add."));let o={separator:e.chunkSeparator.replace(/\\n/g,"\n"),max_tokens:parseInt(e.maxTokens),remove_extra_spaces:e.removeExtraSpaces,remove_urls_emails:e.removeUrlsEmails},s=await r.addDocuments(a,e.dataset,o);if(0!==s.code)return void t.fail(J.red(`Error ${s.code}: ${s.msg}`));t.succeed(J.green("Documents added successfully!")),s.doc_ids&&s.doc_ids.length>0&&(console.log(J.cyan(`
|
|
107
|
-
Added ${s.doc_ids.length} documents.`)),console.log(J.dim(`Doc IDs: ${s.doc_ids.join(", ")}`)))}catch(e){t.fail(J.red("Add documents failed")),console.error(J.red(e.message)),process.exit(1)}});var e3=__webpack_require__("os"),e4=__webpack_require__("./node_modules/@aws-sdk/client-s3/dist-es/commands/PutObjectCommand.js"),e8=__webpack_require__("./node_modules/@aws-sdk/lib-storage/dist-es/index.js"),e6=__webpack_require__("crypto"),e5=__webpack_require__("./node_modules/archiver/index.js"),e9=__webpack_require__.n(e5);let e7={".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".xml":"application/xml",".txt":"text/plain",".csv":"text/csv",".md":"text/markdown",".yaml":"text/yaml",".yml":"text/yaml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".ico":"image/x-icon",".bmp":"image/bmp",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".flac":"audio/flac",".mp4":"video/mp4",".webm":"video/webm",".avi":"video/x-msvideo",".mov":"video/quicktime",".pdf":"application/pdf",".zip":"application/zip",".gz":"application/gzip",".tar":"application/x-tar",".rar":"application/vnd.rar",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"application/vnd.ms-fontobject"};function te(e,t,n,i){let r=i(t);if(n){let e=eY.extname(r),t=r.slice(0,r.length-e.length),n=eY.posix.dirname(t),i=eY.posix.basename(t),a=(0,e6.randomUUID)().replace(/-/g,"").slice(0,8);r="."!==n?`${n}/${i}_${a}${e}`:`${i}_${a}${e}`}return e+r}async function tt(e){let t=eY.basename(e),n=`${t}.zip`,i=eN.mkdtempSync(eY.join(e3.tmpdir(),"storage-upload-")),r=eY.join(i,n);return new Promise((n,i)=>{let a=eN.createWriteStream(r),o=e9()("zip",{zlib:{level:9}});a.on("close",()=>n(r)),o.on("error",e=>i(e)),o.pipe(a),o.directory(e,t),o.finalize()})}async function tn(e,t,n,i,r){var a;let o=(a=n,e7[eY.extname(a).toLowerCase()]||"application/octet-stream");if(eN.statSync(n).size<=r){let r=eN.readFileSync(n);await e.send(new e4.w({Bucket:t,Key:i,Body:r,ContentType:o}))}else{let r=eN.createReadStream(n),a=new e8._({client:e,params:{Bucket:t,Key:i,Body:r,ContentType:o}});await a.done()}}let ti=new h("storage").description("Object storage commands");ti.command("upload").description("Upload files and directories to object storage.\n\nFiles are uploaded directly. Directories are uploaded recursively\nAND also zipped as a single archive.\nReturns JSON with file-to-URL mappings.\n\nExamples:\n coze-coding-ai storage upload ./data --prefix my-project/\n coze-coding-ai storage upload file1.txt dir1/ dir2/ --prefix uploads/\n coze-coding-ai storage upload report.csv --prefix reports/ --expire 3600").argument("<paths...>","File or directory paths to upload").option("-p, --prefix <prefix>","Target S3 key prefix (virtual directory)","").option("--uuid","Append UUID suffix to filenames to avoid collisions").option("-e, --expire <seconds>","Presigned URL expiration in seconds (default: 86400 = 24h)","86400").option("-t, --threshold <bytes>","Size threshold for streaming upload (default: 5MB)","5242880").option("-c, --max-concurrency <n>","Number of parallel uploads (default: 4)","4").option("--dry-run","List items without uploading").option("-v, --verbose","Show detailed output").action(async(e,t)=>{var n;let i,r,a,{S3Storage:o}=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"./src/s3/index.ts")),s=[],l=[];for(let t of e){let e=eY.resolve(t);if(!eN.existsSync(e)){console.log(J.yellow(`Warning: ${t} does not exist, skipping`));continue}let n=eN.statSync(e);n.isFile()?s.push(e):n.isDirectory()?l.push(e):console.log(J.yellow(`Warning: ${t} is not a file or directory, skipping`))}0===s.length&&0===l.length&&(console.log(J.red("No files or directories found to upload.")),process.exit(1));let u=(n=t.prefix)&&(n=n.replace(/^\/+|\/+$/g,""))?n+"/":"",d=parseInt(t.expire,10),h=parseInt(t.threshold,10),c=parseInt(t.maxConcurrency,10);try{r=(i=new o).resolveBucket(void 0)}catch(e){console.log(J.red(`S3 configuration error: ${e.message}`)),process.exit(1)}let f=e=>i.sanitizeFileName(e),p=[];for(let e of s){let n=eY.basename(e),i=te(u,n,!!t.uuid,f);p.push({localPath:e,objectKey:i,displayName:n})}let m=[];for(let e of l)for(let{absolutePath:n,relativeKey:i}of function(e){let t=[],n=eY.dirname(e);return!function e(i){for(let r of eN.readdirSync(i,{withFileTypes:!0})){let a=eY.join(i,r.name);if(r.isDirectory())e(a);else if(r.isFile()){let e=eY.relative(n,a).split(eY.sep).join("/");t.push({absolutePath:a,relativeKey:e})}}}(e),t}(e)){let e=te(u,i,!!t.uuid,f);m.push({localPath:n,objectKey:e,displayName:i})}let g=[...p,...m],b=[];for(let e of l){let n=eY.basename(e),i=te(u,`${n}.zip`,!!t.uuid,f);b.push({dirPath:e,objectKey:i,displayName:`${n}/`})}let y=g.length+b.length;if(t.dryRun){for(let e of(console.log(J.cyan(`Dry run: ${y} items would be uploaded to s3://${r}/${u}
|
|
108
|
-
`)),g))console.log(` ${J.dim("file")} ${e.displayName} -> ${e.objectKey}`);for(let e of b)console.log(` ${J.dim("zip ")} ${e.displayName} -> ${e.objectKey}`);return}try{a=i.getClient()}catch(e){console.log(J.red(`Failed to initialize S3 client: ${e.message}`)),process.exit(1)}console.log(`Uploading ${y} items to s3://${r}/${u} ...
|
|
109
|
-
`);let w={},S=[],v=0,x=new Set(p.map(e=>e.displayName)),E=[...g],T=[];async function C(e){try{if(await tn(a,r,e.localPath,e.objectKey,h),x.has(e.displayName)){let t=await i.generatePresignedUrl({key:e.objectKey,expireTime:d});w[e.displayName]=t}t.verbose&&console.log(J.green(" OK")+` ${e.displayName} -> ${e.objectKey}`)}catch(n){S.push({name:e.displayName,error:n.message}),t.verbose&&console.log(J.red(" FAIL")+` ${e.displayName}: ${n.message}`)}finally{v++,process.stdout.write(`\r [${v}/${y}] items processed`)}}for(;E.length>0||T.length>0;){for(;T.length<c&&E.length>0;){let e=C(E.shift()).then(()=>{T.splice(T.indexOf(e),1)});T.push(e)}T.length>0&&await Promise.race(T)}for(let e of b){let n=null;try{t.verbose&&console.log(`
|
|
110
|
-
Zipping ${e.displayName} ...`),n=await tt(e.dirPath),await tn(a,r,n,e.objectKey,h);let o=await i.generatePresignedUrl({key:e.objectKey,expireTime:d});w[e.displayName]=o,t.verbose&&console.log(J.green(" OK")+` ${e.displayName} -> ${e.objectKey}`)}catch(n){S.push({name:e.displayName,error:n.message}),t.verbose&&console.log(J.red(" FAIL")+` ${e.displayName}: ${n.message}`)}finally{if(n)try{eN.unlinkSync(n),eN.rmdirSync(eY.dirname(n))}catch{}v++,process.stdout.write(`\r [${v}/${y}] items processed`)}}process.stdout.write("\n");let L={...w};S.length>0&&(L._failures=S),console.log(),console.log(JSON.stringify(L,null,2)),console.log();let j=Object.keys(w).length;console.log(J.green(` OK ${j}/${y} items uploaded`)),S.length>0&&(console.log(J.red(` FAIL ${S.length} items`)),process.exit(1))});let tr=new h("supabase").description("Supabase 管理命令,包括 Edge Functions、Storage Buckets 和 Auth 配置管理"),ta=tr.command("func").description("Edge Functions(边缘函数)管理命令");ta.command("list").description("列出所有 Edge Functions").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/list")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({functions:[],mock:!0},null,2));return}let n=eO("Fetching functions...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.listFunctions();e.verbose&&(n.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code)),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Functions fetched successfully!")),console.log(JSON.stringify(a.functions,null,2))}catch(e){n.fail(J.red("Failed to fetch functions")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("get").description("获取 Edge Function 详情和源码").argument("<slug>",'函数标识符,即函数的唯一名称(如 "hello-world"),可通过 "func list" 命令查看').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/get")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({function:{slug:e},files:[],mock:!0},null,2));return}let i=eO("Fetching function...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.getFunction(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Function fetched successfully!")),console.log(JSON.stringify({function:o.function,files:o.files},null,2))}catch(e){i.fail(J.red("Failed to fetch function")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("deploy").description("部署或更新 Edge Function。如果函数已存在则更新,不存在则创建新函数").argument("<slug>",'函数标识符,只能包含小写字母、数字和连字符(如 "hello-world")').option("-c, --code <code>","函数代码字符串(用于单文件函数),与 --file 二选一").option("-f, --file <items...>","文件名和内容对,格式:--file <文件名> <内容>,可多次使用,例如:--file index.ts 'Deno.serve(...)' --file handler.ts 'export ...'").option("-n, --name <name>","函数显示名称,用于在控制台中展示").option("-e, --entrypoint <path>",'入口文件名称,多文件部署时必需,指定主入口文件(如 "index.ts")').option("--verify-jwt","启用 JWT 验证,调用函数需要携带有效的 JWT token").option("--no-verify-jwt","禁用 JWT 验证").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=t.code;if(t.file&&t.file.length>0){t.file.length%2!=0&&(console.error(J.red("Error: --file requires pairs of <name> <content>")),process.exit(1)),n=[];for(let e=0;e<t.file.length;e+=2)n.push({name:t.file[e],content:t.file[e+1]})}i||n||(console.error(J.red("Error: Either --code or --file is required")),process.exit(1));let r=eH(t.header),a={code:i,files:n,name:t.name,entrypoint:t.entrypoint,verify_jwt:t.verifyJwt};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/deploy")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e,...a,code:i?`${i.substring(0,50)}...`:void 0}),r&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(r))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,slug:e,version:1,mock:!0},null,2));return}let o=eO("Deploying function...").start();try{let n=new m.Config,i=new m.SupabaseClient(n,r),s=await i.deployFunction(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Function deployed successfully!")),console.log(JSON.stringify({success:s.success,slug:s.slug,version:s.version},null,2))}catch(e){o.fail(J.red("Failed to deploy function")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("delete").description("删除 Edge Function。⚠️ 警告:此操作不可逆,删除后函数将无法恢复").argument("<slug>",'函数标识符,可通过 "func list" 命令查看所有函数的 slug').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/delete")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Deleting function...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.deleteFunction(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Function deleted successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to delete function")),console.error(J.red(e.message)),process.exit(1)}});let to=tr.command("bucket").description("Storage Buckets(存储桶)管理命令");to.command("list").description("列出所有 Storage Buckets").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/list")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({buckets:[],mock:!0},null,2));return}let n=eO("Fetching buckets...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.listBuckets();e.verbose&&(n.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code)),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Buckets fetched successfully!")),console.log(JSON.stringify(a.buckets,null,2))}catch(e){n.fail(J.red("Failed to fetch buckets")),console.error(J.red(e.message)),process.exit(1)}}),to.command("get").description("获取 Storage Bucket 详情").argument("<bucket_id>",'存储桶 ID,即存储桶的唯一标识符(如 "avatars"),可通过 "bucket list" 命令查看').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/get")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({bucket:{id:e},mock:!0},null,2));return}let i=eO("Fetching bucket...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.getBucket(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Bucket fetched successfully!")),console.log(JSON.stringify(o.bucket,null,2))}catch(e){i.fail(J.red("Failed to fetch bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("create").description("创建新的 Storage Bucket").argument("<bucket_id>",'存储桶 ID,只能包含小写字母、数字和连字符(如 "user-avatars")').option("-n, --name <name>","存储桶显示名称,用于在控制台中展示").option("--public","设置为公开存储桶,允许匿名访问").option("--private","设置为私有存储桶,需要认证才能访问").option("--file-size-limit <bytes>","单个文件大小限制(字节),例如 10485760 表示 10MB",parseInt).option("--allowed-mime-types <types>",'允许上传的文件 MIME 类型(逗号分隔),例如 "image/png,image/jpeg"').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=eH(t.header);t.public?n=!0:t.private&&(n=!1);let r=t.allowedMimeTypes?t.allowedMimeTypes.split(",").map(e=>e.trim()):void 0,a={name:t.name,public:n,file_size_limit:t.fileSizeLimit,allowed_mime_types:r};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/create")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e,...a}),i&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(i))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,bucket_id:e,mock:!0},null,2));return}let o=eO("Creating bucket...").start();try{let n=new m.Config,r=new m.SupabaseClient(n,i),s=await r.createBucket(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Bucket created successfully!")),console.log(JSON.stringify({success:s.success,bucket_id:s.bucket_id},null,2))}catch(e){o.fail(J.red("Failed to create bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("update").description("更新 Storage Bucket 配置").argument("<bucket_id>",'存储桶 ID,可通过 "bucket list" 命令查看所有存储桶的 ID').option("--public","设置为公开存储桶,允许匿名访问").option("--private","设置为私有存储桶,需要认证才能访问").option("--file-size-limit <bytes>","单个文件大小限制(字节),例如 10485760 表示 10MB",parseInt).option("--allowed-mime-types <types>",'允许上传的文件 MIME 类型(逗号分隔),例如 "image/png,image/jpeg"').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=eH(t.header);t.public?n=!0:t.private&&(n=!1);let r=t.allowedMimeTypes?t.allowedMimeTypes.split(",").map(e=>e.trim()):void 0,a={public:n,file_size_limit:t.fileSizeLimit,allowed_mime_types:r};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/update")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e,...a}),i&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(i))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let o=eO("Updating bucket...").start();try{let n=new m.Config,r=new m.SupabaseClient(n,i),s=await r.updateBucket(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Bucket updated successfully!")),console.log(JSON.stringify({success:s.success},null,2))}catch(e){o.fail(J.red("Failed to update bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("delete").description("删除 Storage Bucket。⚠️ 警告:此操作不可逆,删除后存储桶及其中的所有文件将无法恢复").argument("<bucket_id>",'存储桶 ID,可通过 "bucket list" 命令查看所有存储桶的 ID').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/delete")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Deleting bucket...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.deleteBucket(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Bucket deleted successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to delete bucket")),console.error(J.red(e.message)),process.exit(1)}});let ts=tr.command("auth").description("Auth(认证配置)管理命令");ts.command("get-config").description("获取 Auth 认证配置,包括邮箱认证、SMTP 等设置").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/auth/config/get")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({config:{},mock:!0},null,2));return}let n=eO("Fetching auth config...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.getAuthConfig();e.verbose&&console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Auth config fetched successfully!")),console.log(JSON.stringify(a.config,null,2))}catch(e){n.fail(J.red("Failed to fetch auth config")),console.error(J.red(e.message)),process.exit(1)}}),ts.command("update-config").description("更新 Auth 认证配置。至少需要提供一个配置项,更新 SMTP 配置后建议测试邮件发送功能").option("--site-url <url>",'站点 URL,用于邮件中的链接跳转地址(如 "https://myapp.com")').option("--disable-signup","禁用用户自助注册功能").option("--enable-signup","启用用户自助注册功能").option("--external-email-enabled","启用邮箱认证方式").option("--external-email-disabled","禁用邮箱认证方式").option("--mailer-autoconfirm","启用邮箱自动确认(跳过邮件验证)").option("--no-mailer-autoconfirm","禁用邮箱自动确认").option("--double-confirm-changes","启用敏感操作的双重确认").option("--no-double-confirm-changes","禁用敏感操作的双重确认").option("--mailer-secure-email-change-enabled","启用安全邮箱更改流程").option("--mailer-secure-email-change-disabled","禁用安全邮箱更改流程").option("--mailer-otp-exp <seconds>","OTP 验证码过期时间(秒),例如 3600 表示 1 小时",parseInt).option("--password-min-length <length>","用户密码最小长度要求,例如 8",parseInt).option("--password-required-characters <chars>",'密码必需包含的字符类型,例如 "abcABC123"').option("--smtp-host <host>",'SMTP 邮件服务器地址,例如 "smtp.sendgrid.net"').option("--smtp-port <port>","SMTP 邮件服务器端口,例如 587",parseInt).option("--smtp-user <user>","SMTP 认证用户名").option("--smtp-pass <pass>","SMTP 认证密码或 API Key").option("--smtp-admin-email <email>",'发件人邮箱地址,例如 "noreply@myapp.com"').option("--smtp-sender-name <name>",'发件人显示名称,例如 "My App"').option("--smtp-max-frequency <seconds>","同一邮箱的最小发送间隔(秒),用于防止滥用",parseInt).option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t={};void 0!==e.siteUrl&&(t.site_url=e.siteUrl),e.disableSignup&&(t.disable_signup=!0),e.enableSignup&&(t.disable_signup=!1),e.externalEmailEnabled&&(t.external_email_enabled=!0),e.externalEmailDisabled&&(t.external_email_enabled=!1),void 0!==e.mailerAutoconfirm&&(t.mailer_autoconfirm=e.mailerAutoconfirm),void 0!==e.doubleConfirmChanges&&(t.double_confirm_changes=e.doubleConfirmChanges),e.mailerSecureEmailChangeEnabled&&(t.mailer_secure_email_change_enabled=!0),e.mailerSecureEmailChangeDisabled&&(t.mailer_secure_email_change_enabled=!1),void 0!==e.mailerOtpExp&&(t.mailer_otp_exp=e.mailerOtpExp),void 0!==e.passwordMinLength&&(t.password_min_length=e.passwordMinLength),void 0!==e.passwordRequiredCharacters&&(t.password_required_characters=e.passwordRequiredCharacters),void 0!==e.smtpHost&&(t.smtp_host=e.smtpHost),void 0!==e.smtpPort&&(t.smtp_port=e.smtpPort),void 0!==e.smtpUser&&(t.smtp_user=e.smtpUser),void 0!==e.smtpPass&&(t.smtp_pass=e.smtpPass),void 0!==e.smtpAdminEmail&&(t.smtp_admin_email=e.smtpAdminEmail),void 0!==e.smtpSenderName&&(t.smtp_sender_name=e.smtpSenderName),void 0!==e.smtpMaxFrequency&&(t.smtp_max_frequency=e.smtpMaxFrequency),0===Object.keys(t).length&&(console.error(J.red("Error: At least one config option is required")),process.exit(1));let n=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/auth/config/update")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{config:t}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Updating auth config...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.updateAuthConfig(t);e.verbose&&console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Auth config updated successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to update auth config")),console.error(J.red(e.message)),process.exit(1)}});let tl=new h;tl.name("coze-coding-ai").description("Coze Coding CLI - AI-powered tools for image generation, video generation, search, voice, chat, embedding, knowledge, and supabase management").version("0.3.0"),tl.addCommand(eW),tl.addCommand(eX),tl.addCommand(eG),tl.addCommand(e$),tl.addCommand(eU),tl.addCommand(ez),tl.addCommand(e0),tl.addCommand(e1),tl.addCommand(e2),tl.addCommand(tr),tl.addCommand(ti),tl.parse(process.argv)})(),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
107
|
+
Added ${s.doc_ids.length} documents.`)),console.log(J.dim(`Doc IDs: ${s.doc_ids.join(", ")}`)))}catch(e){t.fail(J.red("Add documents failed")),console.error(J.red(e.message)),process.exit(1)}});var e3=__webpack_require__("os"),e4=__webpack_require__("./node_modules/@aws-sdk/client-s3/dist-es/commands/PutObjectCommand.js"),e8=__webpack_require__("./node_modules/@aws-sdk/lib-storage/dist-es/index.js"),e6=__webpack_require__("crypto"),e5=__webpack_require__("./node_modules/archiver/index.js"),e9=__webpack_require__.n(e5);let e7={".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".xml":"application/xml",".txt":"text/plain",".csv":"text/csv",".md":"text/markdown",".yaml":"text/yaml",".yml":"text/yaml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".ico":"image/x-icon",".bmp":"image/bmp",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".flac":"audio/flac",".mp4":"video/mp4",".webm":"video/webm",".avi":"video/x-msvideo",".mov":"video/quicktime",".pdf":"application/pdf",".zip":"application/zip",".gz":"application/gzip",".tar":"application/x-tar",".rar":"application/vnd.rar",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"application/vnd.ms-fontobject"};function te(e,t,n,i){let r=i(t);if(n){let e=eY.extname(r),t=r.slice(0,r.length-e.length),n=eY.posix.dirname(t),i=eY.posix.basename(t),a=(0,e6.randomUUID)().replace(/-/g,"").slice(0,8);r="."!==n?`${n}/${i}_${a}${e}`:`${i}_${a}${e}`}return e+r}async function tt(e){let t=eY.basename(e),n=`${t}.zip`,i=eN.mkdtempSync(eY.join(e3.tmpdir(),"storage-upload-")),r=eY.join(i,n);return new Promise((n,i)=>{let a=eN.createWriteStream(r),o=e9()("zip",{zlib:{level:9}});a.on("close",()=>n(r)),o.on("error",e=>i(e)),o.pipe(a),o.directory(e,t),o.finalize()})}async function tn(e,t,n,i,r){var a;let o=(a=n,e7[eY.extname(a).toLowerCase()]||"application/octet-stream");if(eN.statSync(n).size<=r){let r=eN.readFileSync(n);await e.send(new e4.w({Bucket:t,Key:i,Body:r,ContentType:o}))}else{let r=eN.createReadStream(n),a=new e8._({client:e,params:{Bucket:t,Key:i,Body:r,ContentType:o}});await a.done()}}let ti=new h("storage").description("Object storage commands");ti.command("upload").description("Upload files and directories to object storage.\nOutputs JSON with name-to-URL mappings to stdout.\n\nExamples:\n coze-coding-ai storage upload ./data --prefix my-project/\n coze-coding-ai storage upload file1.txt dir1/ dir2/ --prefix uploads/\n coze-coding-ai storage upload report.csv --prefix reports/ --expire 3600").argument("<paths...>","File or directory paths to upload").option("-p, --prefix <prefix>","Target S3 key prefix (virtual directory)","").option("--uuid","Append UUID suffix to filenames to avoid collisions").option("-e, --expire <seconds>","Presigned URL expiration in seconds (default: 86400 = 24h)","86400").option("-t, --threshold <bytes>","Size threshold for streaming upload (default: 5MB)","5242880").option("-c, --max-concurrency <n>","Number of parallel uploads (default: 4)","4").action(async(e,t)=>{var n;let i,r,a,{S3Storage:o}=await Promise.resolve().then(__webpack_require__.bind(__webpack_require__,"./src/s3/index.ts")),s=[],l=[];for(let t of e){let e=eY.resolve(t);if(!eN.existsSync(e)){console.error(`Warning: ${t} does not exist, skipping`);continue}let n=eN.statSync(e);n.isFile()?s.push(e):n.isDirectory()?l.push(e):console.error(`Warning: ${t} is not a file or directory, skipping`)}0===s.length&&0===l.length&&(console.log(JSON.stringify({_error:"No files or directories found to upload."})),process.exit(1));let u=(n=t.prefix)&&(n=n.replace(/^\/+|\/+$/g,""))?n+"/":"",d=parseInt(t.expire,10),h=parseInt(t.threshold,10),c=parseInt(t.maxConcurrency,10);try{r=(i=new o).resolveBucket(void 0)}catch(e){console.log(JSON.stringify({_error:`S3 configuration error: ${e.message}`})),process.exit(1)}let f=e=>i.sanitizeFileName(e),p=[];for(let e of s){let n=eY.basename(e),i=te(u,n,!!t.uuid,f);p.push({localPath:e,objectKey:i,displayName:n})}let m=[];for(let e of l)for(let{absolutePath:n,relativeKey:i}of function(e){let t=[],n=eY.dirname(e);return!function e(i){for(let r of eN.readdirSync(i,{withFileTypes:!0})){let a=eY.join(i,r.name);if(r.isDirectory())e(a);else if(r.isFile()){let e=eY.relative(n,a).split(eY.sep).join("/");t.push({absolutePath:a,relativeKey:e})}}}(e),t}(e)){let e=te(u,i,!!t.uuid,f);m.push({localPath:n,objectKey:e,displayName:i})}let g=[...p,...m],b=[];for(let e of l){let n=eY.basename(e),i=te(u,`${n}.zip`,!!t.uuid,f);b.push({dirPath:e,objectKey:i,displayName:`${n}/`})}try{a=i.getClient()}catch(e){console.log(JSON.stringify({_error:`Failed to initialize S3 client: ${e.message}`})),process.exit(1)}let y={},w=[],S=new Set(p.map(e=>e.displayName)),v=[...g],x=[];async function E(e){try{if(await tn(a,r,e.localPath,e.objectKey,h),S.has(e.displayName)){let t=await i.generatePresignedUrl({key:e.objectKey,expireTime:d});y[e.displayName]=t}}catch(t){w.push({name:e.displayName,error:t.message})}}for(;v.length>0||x.length>0;){for(;x.length<c&&v.length>0;){let e=E(v.shift()).then(()=>{x.splice(x.indexOf(e),1)});x.push(e)}x.length>0&&await Promise.race(x)}for(let e of b){let t=null;try{t=await tt(e.dirPath),await tn(a,r,t,e.objectKey,h);let n=await i.generatePresignedUrl({key:e.objectKey,expireTime:d});y[e.displayName]=n}catch(t){w.push({name:e.displayName,error:t.message})}finally{if(t)try{eN.unlinkSync(t),eN.rmdirSync(eY.dirname(t))}catch{}}}let T={...y};w.length>0&&(T._failures=w),console.log(JSON.stringify(T,null,2)),w.length>0&&process.exit(1)});let tr=new h("supabase").description("Supabase 管理命令,包括 Edge Functions、Storage Buckets 和 Auth 配置管理"),ta=tr.command("func").description("Edge Functions(边缘函数)管理命令");ta.command("list").description("列出所有 Edge Functions").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/list")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({functions:[],mock:!0},null,2));return}let n=eO("Fetching functions...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.listFunctions();e.verbose&&(n.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code)),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Functions fetched successfully!")),console.log(JSON.stringify(a.functions,null,2))}catch(e){n.fail(J.red("Failed to fetch functions")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("get").description("获取 Edge Function 详情和源码").argument("<slug>",'函数标识符,即函数的唯一名称(如 "hello-world"),可通过 "func list" 命令查看').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/get")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({function:{slug:e},files:[],mock:!0},null,2));return}let i=eO("Fetching function...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.getFunction(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Function fetched successfully!")),console.log(JSON.stringify({function:o.function,files:o.files},null,2))}catch(e){i.fail(J.red("Failed to fetch function")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("deploy").description("部署或更新 Edge Function。如果函数已存在则更新,不存在则创建新函数").argument("<slug>",'函数标识符,只能包含小写字母、数字和连字符(如 "hello-world")').option("-c, --code <code>","函数代码字符串(用于单文件函数),与 --file 二选一").option("-f, --file <items...>","文件名和内容对,格式:--file <文件名> <内容>,可多次使用,例如:--file index.ts 'Deno.serve(...)' --file handler.ts 'export ...'").option("-n, --name <name>","函数显示名称,用于在控制台中展示").option("-e, --entrypoint <path>",'入口文件名称,多文件部署时必需,指定主入口文件(如 "index.ts")').option("--verify-jwt","启用 JWT 验证,调用函数需要携带有效的 JWT token").option("--no-verify-jwt","禁用 JWT 验证").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=t.code;if(t.file&&t.file.length>0){t.file.length%2!=0&&(console.error(J.red("Error: --file requires pairs of <name> <content>")),process.exit(1)),n=[];for(let e=0;e<t.file.length;e+=2)n.push({name:t.file[e],content:t.file[e+1]})}i||n||(console.error(J.red("Error: Either --code or --file is required")),process.exit(1));let r=eH(t.header),a={code:i,files:n,name:t.name,entrypoint:t.entrypoint,verify_jwt:t.verifyJwt};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/deploy")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e,...a,code:i?`${i.substring(0,50)}...`:void 0}),r&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(r))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,slug:e,version:1,mock:!0},null,2));return}let o=eO("Deploying function...").start();try{let n=new m.Config,i=new m.SupabaseClient(n,r),s=await i.deployFunction(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Function deployed successfully!")),console.log(JSON.stringify({success:s.success,slug:s.slug,version:s.version},null,2))}catch(e){o.fail(J.red("Failed to deploy function")),console.error(J.red(e.message)),process.exit(1)}}),ta.command("delete").description("删除 Edge Function。⚠️ 警告:此操作不可逆,删除后函数将无法恢复").argument("<slug>",'函数标识符,可通过 "func list" 命令查看所有函数的 slug').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/functions/delete")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{slug:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Deleting function...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.deleteFunction(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Function deleted successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to delete function")),console.error(J.red(e.message)),process.exit(1)}});let to=tr.command("bucket").description("Storage Buckets(存储桶)管理命令");to.command("list").description("列出所有 Storage Buckets").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/list")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({buckets:[],mock:!0},null,2));return}let n=eO("Fetching buckets...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.listBuckets();e.verbose&&(n.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code)),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Buckets fetched successfully!")),console.log(JSON.stringify(a.buckets,null,2))}catch(e){n.fail(J.red("Failed to fetch buckets")),console.error(J.red(e.message)),process.exit(1)}}),to.command("get").description("获取 Storage Bucket 详情").argument("<bucket_id>",'存储桶 ID,即存储桶的唯一标识符(如 "avatars"),可通过 "bucket list" 命令查看').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/get")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({bucket:{id:e},mock:!0},null,2));return}let i=eO("Fetching bucket...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.getBucket(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Bucket fetched successfully!")),console.log(JSON.stringify(o.bucket,null,2))}catch(e){i.fail(J.red("Failed to fetch bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("create").description("创建新的 Storage Bucket").argument("<bucket_id>",'存储桶 ID,只能包含小写字母、数字和连字符(如 "user-avatars")').option("-n, --name <name>","存储桶显示名称,用于在控制台中展示").option("--public","设置为公开存储桶,允许匿名访问").option("--private","设置为私有存储桶,需要认证才能访问").option("--file-size-limit <bytes>","单个文件大小限制(字节),例如 10485760 表示 10MB",parseInt).option("--allowed-mime-types <types>",'允许上传的文件 MIME 类型(逗号分隔),例如 "image/png,image/jpeg"').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=eH(t.header);t.public?n=!0:t.private&&(n=!1);let r=t.allowedMimeTypes?t.allowedMimeTypes.split(",").map(e=>e.trim()):void 0,a={name:t.name,public:n,file_size_limit:t.fileSizeLimit,allowed_mime_types:r};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/create")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e,...a}),i&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(i))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,bucket_id:e,mock:!0},null,2));return}let o=eO("Creating bucket...").start();try{let n=new m.Config,r=new m.SupabaseClient(n,i),s=await r.createBucket(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Bucket created successfully!")),console.log(JSON.stringify({success:s.success,bucket_id:s.bucket_id},null,2))}catch(e){o.fail(J.red("Failed to create bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("update").description("更新 Storage Bucket 配置").argument("<bucket_id>",'存储桶 ID,可通过 "bucket list" 命令查看所有存储桶的 ID').option("--public","设置为公开存储桶,允许匿名访问").option("--private","设置为私有存储桶,需要认证才能访问").option("--file-size-limit <bytes>","单个文件大小限制(字节),例如 10485760 表示 10MB",parseInt).option("--allowed-mime-types <types>",'允许上传的文件 MIME 类型(逗号分隔),例如 "image/png,image/jpeg"').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n,i=eH(t.header);t.public?n=!0:t.private&&(n=!1);let r=t.allowedMimeTypes?t.allowedMimeTypes.split(",").map(e=>e.trim()):void 0,a={public:n,file_size_limit:t.fileSizeLimit,allowed_mime_types:r};if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/update")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e,...a}),i&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(i))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let o=eO("Updating bucket...").start();try{let n=new m.Config,r=new m.SupabaseClient(n,i),s=await r.updateBucket(e,a);t.verbose&&(o.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),s.code)),0!==s.code&&(o.fail(J.red(`Error: ${s.msg}`)),process.exit(1)),o.succeed(J.green("Bucket updated successfully!")),console.log(JSON.stringify({success:s.success},null,2))}catch(e){o.fail(J.red("Failed to update bucket")),console.error(J.red(e.message)),process.exit(1)}}),to.command("delete").description("删除 Storage Bucket。⚠️ 警告:此操作不可逆,删除后存储桶及其中的所有文件将无法恢复").argument("<bucket_id>",'存储桶 ID,可通过 "bucket list" 命令查看所有存储桶的 ID').option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async(e,t)=>{let n=eH(t.header);if(t.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/buckets/delete")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{bucket_id:e}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),t.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Deleting bucket...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.deleteBucket(e);t.verbose&&(i.stop(),console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code)),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Bucket deleted successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to delete bucket")),console.error(J.red(e.message)),process.exit(1)}});let ts=tr.command("auth").description("Auth(认证配置)管理命令");ts.command("get-config").description("获取 Auth 认证配置,包括邮箱认证、SMTP 等设置").option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/auth/config/get")),t&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(t))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({config:{},mock:!0},null,2));return}let n=eO("Fetching auth config...").start();try{let i=new m.Config,r=new m.SupabaseClient(i,t),a=await r.getAuthConfig();e.verbose&&console.log(J.cyan("\uD83D\uDCE5 Response code:"),a.code),0!==a.code&&(n.fail(J.red(`Error: ${a.msg}`)),process.exit(1)),n.succeed(J.green("Auth config fetched successfully!")),console.log(JSON.stringify(a.config,null,2))}catch(e){n.fail(J.red("Failed to fetch auth config")),console.error(J.red(e.message)),process.exit(1)}}),ts.command("update-config").description("更新 Auth 认证配置。至少需要提供一个配置项,更新 SMTP 配置后建议测试邮件发送功能").option("--site-url <url>",'站点 URL,用于邮件中的链接跳转地址(如 "https://myapp.com")').option("--disable-signup","禁用用户自助注册功能").option("--enable-signup","启用用户自助注册功能").option("--external-email-enabled","启用邮箱认证方式").option("--external-email-disabled","禁用邮箱认证方式").option("--mailer-autoconfirm","启用邮箱自动确认(跳过邮件验证)").option("--no-mailer-autoconfirm","禁用邮箱自动确认").option("--double-confirm-changes","启用敏感操作的双重确认").option("--no-double-confirm-changes","禁用敏感操作的双重确认").option("--mailer-secure-email-change-enabled","启用安全邮箱更改流程").option("--mailer-secure-email-change-disabled","禁用安全邮箱更改流程").option("--mailer-otp-exp <seconds>","OTP 验证码过期时间(秒),例如 3600 表示 1 小时",parseInt).option("--password-min-length <length>","用户密码最小长度要求,例如 8",parseInt).option("--password-required-characters <chars>",'密码必需包含的字符类型,例如 "abcABC123"').option("--smtp-host <host>",'SMTP 邮件服务器地址,例如 "smtp.sendgrid.net"').option("--smtp-port <port>","SMTP 邮件服务器端口,例如 587",parseInt).option("--smtp-user <user>","SMTP 认证用户名").option("--smtp-pass <pass>","SMTP 认证密码或 API Key").option("--smtp-admin-email <email>",'发件人邮箱地址,例如 "noreply@myapp.com"').option("--smtp-sender-name <name>",'发件人显示名称,例如 "My App"').option("--smtp-max-frequency <seconds>","同一邮箱的最小发送间隔(秒),用于防止滥用",parseInt).option("--mock","使用 mock 模式(测试运行,不会真正执行操作)").option("-H, --header <header>",'自定义 HTTP 请求头,格式: "Key: Value" 或 "Key=Value",可多次使用',(e,t)=>t.concat([e]),[]).option("--verbose","显示详细的 HTTP 请求和响应日志",!1).action(async e=>{let t={};void 0!==e.siteUrl&&(t.site_url=e.siteUrl),e.disableSignup&&(t.disable_signup=!0),e.enableSignup&&(t.disable_signup=!1),e.externalEmailEnabled&&(t.external_email_enabled=!0),e.externalEmailDisabled&&(t.external_email_enabled=!1),void 0!==e.mailerAutoconfirm&&(t.mailer_autoconfirm=e.mailerAutoconfirm),void 0!==e.doubleConfirmChanges&&(t.double_confirm_changes=e.doubleConfirmChanges),e.mailerSecureEmailChangeEnabled&&(t.mailer_secure_email_change_enabled=!0),e.mailerSecureEmailChangeDisabled&&(t.mailer_secure_email_change_enabled=!1),void 0!==e.mailerOtpExp&&(t.mailer_otp_exp=e.mailerOtpExp),void 0!==e.passwordMinLength&&(t.password_min_length=e.passwordMinLength),void 0!==e.passwordRequiredCharacters&&(t.password_required_characters=e.passwordRequiredCharacters),void 0!==e.smtpHost&&(t.smtp_host=e.smtpHost),void 0!==e.smtpPort&&(t.smtp_port=e.smtpPort),void 0!==e.smtpUser&&(t.smtp_user=e.smtpUser),void 0!==e.smtpPass&&(t.smtp_pass=e.smtpPass),void 0!==e.smtpAdminEmail&&(t.smtp_admin_email=e.smtpAdminEmail),void 0!==e.smtpSenderName&&(t.smtp_sender_name=e.smtpSenderName),void 0!==e.smtpMaxFrequency&&(t.smtp_max_frequency=e.smtpMaxFrequency),0===Object.keys(t).length&&(console.error(J.red("Error: At least one config option is required")),process.exit(1));let n=eH(e.header);if(e.verbose&&(console.log(J.cyan("\uD83D\uDCE4 Request: POST /v1/supabase/auth/config/update")),console.log(J.cyan("\uD83D\uDCE4 Payload:"),{config:t}),n&&console.log(J.cyan("\uD83D\uDCE4 Headers:"),eJ(n))),e.mock){console.log(J.yellow("\uD83E\uDDEA Mock mode enabled - skipping actual request")),console.log(JSON.stringify({success:!0,mock:!0},null,2));return}let i=eO("Updating auth config...").start();try{let r=new m.Config,a=new m.SupabaseClient(r,n),o=await a.updateAuthConfig(t);e.verbose&&console.log(J.cyan("\uD83D\uDCE5 Response code:"),o.code),0!==o.code&&(i.fail(J.red(`Error: ${o.msg}`)),process.exit(1)),i.succeed(J.green("Auth config updated successfully!")),console.log(JSON.stringify({success:o.success},null,2))}catch(e){i.fail(J.red("Failed to update auth config")),console.error(J.red(e.message)),process.exit(1)}});let tl=new h;tl.name("coze-coding-ai").description("Coze Coding CLI - AI-powered tools for image generation, video generation, search, voice, chat, embedding, knowledge, and supabase management").version("0.3.0"),tl.addCommand(eW),tl.addCommand(eX),tl.addCommand(eG),tl.addCommand(e$),tl.addCommand(eU),tl.addCommand(ez),tl.addCommand(e0),tl.addCommand(e1),tl.addCommand(e2),tl.addCommand(tr),tl.addCommand(ti),tl.parse(process.argv)})(),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|