neo-cmp-cli 1.13.17 → 1.13.18

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 (71) hide show
  1. package/dist/index2.js +1 -1
  2. package/dist/neo/env.js +1 -1
  3. package/dist/neo/pushCmp.js +1 -1
  4. package/dist/package.json.js +1 -1
  5. package/package.json +3 -2
  6. package/template/asset-manage-template/docs/README.md +1 -232
  7. package/template/echarts-custom-cmp-template/package.json +1 -1
  8. package/template/neo-bi-cmps/package.json +1 -1
  9. package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +1 -1
  10. package/template/neo-custom-cmp-template/docs/README.md +0 -231
  11. package/template/neo-custom-cmp-template/package.json +1 -1
  12. package/template/neo-h5-cmps/src/components/entityList__c/index.tsx +1 -2
  13. package/template/neo-h5-cmps/src/components/entityTabs__c/index.tsx +1 -1
  14. package/template/neo-h5-cmps/src/components/globalSearchInput__c/index.tsx +1 -1
  15. package/template/neo-h5-cmps/src/components/openChatPageBtn__c/index.tsx +1 -2
  16. package/template/neo-pipeline-cmps/neo.config.js +11 -0
  17. package/template/neo-pipeline-cmps/src/assets/css/common.scss +16 -16
  18. package/template/neo-pipeline-cmps/src/assets/css/mixin.scss +5 -5
  19. package/template/neo-pipeline-cmps/src/components/filterBar__c/README.md +9 -9
  20. package/template/neo-pipeline-cmps/src/components/filterBar__c/common.scss +5 -5
  21. package/template/neo-pipeline-cmps/src/components/filterBar__c/index.tsx +47 -46
  22. package/template/neo-pipeline-cmps/src/components/filterBar__c/model.ts +13 -11
  23. package/template/neo-pipeline-cmps/src/components/filterBar__c/style.scss +1 -1
  24. package/template/neo-pipeline-cmps/src/components/pipelineFunnel__c/README.md +17 -17
  25. package/template/neo-pipeline-cmps/src/components/pipelineFunnel__c/index.tsx +23 -22
  26. package/template/neo-pipeline-cmps/src/components/pipelineFunnel__c/model.ts +18 -17
  27. package/template/neo-pipeline-cmps/src/components/showHealthResult__c/index.tsx +33 -26
  28. package/template/neo-pipeline-cmps/src/components/showHealthResult__c/model.ts +9 -9
  29. package/template/neo-pipeline-cmps/src/components/simpleTable__c/README.md +53 -54
  30. package/template/neo-pipeline-cmps/src/components/simpleTable__c/common.scss +5 -5
  31. package/template/neo-pipeline-cmps/src/components/simpleTable__c/index.tsx +70 -68
  32. package/template/neo-pipeline-cmps/src/components/simpleTable__c/model.ts +41 -41
  33. package/template/neo-pipeline-cmps/src/components/simpleTable__c/style.scss +2 -3
  34. package/template/neo-pipeline-cmps/src/components/stageSwitch__c/README.md +15 -15
  35. package/template/neo-pipeline-cmps/src/components/stageSwitch__c/index.tsx +35 -33
  36. package/template/neo-pipeline-cmps/src/components/stageSwitch__c/model.ts +16 -15
  37. package/template/neo-pipeline-cmps/src/components/stageTimeChart__c/README.md +18 -18
  38. package/template/neo-pipeline-cmps/src/components/stageTimeChart__c/index.tsx +20 -20
  39. package/template/neo-pipeline-cmps/src/components/stageTimeChart__c/model.ts +21 -18
  40. package/template/neo-pipeline-cmps/src/utils/common.ts +14 -14
  41. package/template/neo-pipeline-cmps/src/utils/filter2chartFilter.ts +21 -23
  42. package/template/neo-pipeline-cmps/src/utils/filterBar.ts +14 -14
  43. package/template/neo-pipeline-cmps/src/utils/pipelineFunnel.ts +5 -5
  44. package/template/neo-pipeline-cmps/src/utils/queryByCustomSQL.ts +26 -22
  45. package/template/neo-pipeline-cmps/src/utils/requestDebounce.ts +3 -3
  46. package/template/neo-pipeline-cmps/src/utils/simpleTable.tsx +31 -26
  47. package/template/neo-pipeline-cmps/src/utils/stageSwitch.ts +1 -1
  48. package/template/neo-pipeline-cmps/src/utils/stageTimeChart.ts +5 -5
  49. package/template/neo-pipeline-cmps/src/utils/targetNumber.ts +2 -2
  50. package/template/neo-web-form/package.json +1 -1
  51. package/template/neo-web-form/src/components/batchAddTable__c/index.tsx +161 -41
  52. package/template/neo-web-form/src/components/batchAddTable__c/model.ts +4 -2
  53. package/template/react-custom-cmp-template/package.json +1 -1
  54. package/template/asset-manage-template/src/utils/axiosFetcher.ts +0 -37
  55. package/template/asset-manage-template/src/utils/queryObjectData.ts +0 -112
  56. package/template/asset-manage-template/src/utils/xobjects.ts +0 -162
  57. package/template/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -37
  58. package/template/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -112
  59. package/template/neo-custom-cmp-template/src/utils/xobjects.ts +0 -162
  60. package/template/neo-h5-cmps/src/utils/axiosFetcher.ts +0 -37
  61. package/template/neo-h5-cmps/src/utils/queryObjectData.ts +0 -112
  62. package/template/neo-h5-cmps/src/utils/xobjects.ts +0 -167
  63. package/template/neo-order-cmps/src/utils/axiosFetcher.ts +0 -37
  64. package/template/neo-order-cmps/src/utils/queryObjectData.ts +0 -112
  65. package/template/neo-order-cmps/src/utils/xobjects.ts +0 -162
  66. package/template/neo-web-entity-grid/src/utils/axiosFetcher.ts +0 -37
  67. package/template/neo-web-entity-grid/src/utils/queryObjectData.ts +0 -112
  68. package/template/neo-web-entity-grid/src/utils/xobjects.ts +0 -167
  69. package/template/neo-web-form/src/utils/axiosFetcher.ts +0 -37
  70. package/template/neo-web-form/src/utils/queryObjectData.ts +0 -112
  71. package/template/neo-web-form/src/utils/xobjects.ts +0 -167
package/dist/index2.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./_virtual/index.js"),o=require("figlet"),s=require("yargs"),a=require("chalk"),n=require("inquirer"),t=require("ora"),i=require("./main2.js"),p=require("./utils/common.js"),c=require("./neo/env.js"),m=require("./package.json.js");var l;exports.__require=function(){if(l)return e.__exports;l=1;const r=o,u=s,g=a,d=n,h=t,{neoInit:y,neoInitByCopy:v,inspect:b,neoConfigInit:f,validateProjectName:C,getCmpTypeByDir:$,NeoService:x,NeoLoginService:T,hasNeoProject:w,consoleTag:j}=i.__require(),{errorLog:U,successLog:D,warningLog:L}=p.__require(),_=i.__require(),{getNeoCrmAPI:q}=c.__require(),M=m.default,N=r.textSync("neo",{font:"Lean"}),A=_.projectConfig,S=function(e){return g.green(g.bold(e))},R={"config init":"初始化配置文件",config:"初始化配置文件",dev:"开启本地调试模式",build:"构建生产环境代码",build2lib:"构建 UMD 模块",build2esm:"构建 ESM 模块",publish2oss:"发布到 OSS",inspect:"输出配置文件",open:"打开项目"},P={...R,init:"初始化自定义组件项目",login:"登录 NeoCRM 平台",logout:"登出 NeoCRM 平台","create project":"创建自定义组件项目","create cmp":"创建自定义组件",linkDebug:"开启外链调试模式",preview:"预览自定义组件","pull cmp":"拉取线上自定义组件","push cmp":"发布自定义组件到平台","delete cmp":"删除线上自定义组件",pull:"拉取线上自定义组件",push:"发布自定义组件到平台",delete:"删除线上自定义组件"},k=[{name:"线上生产环境(crm.xiaoshouyi.com)",value:"production"},{name:"灰度环境(crm-gray.xiaoshouyi.com)",value:"gray"},{name:"沙盒环境(crm-sandbox.xiaoshouyi.com)",value:"sandbox"},{name:"开发环境(crm-cd.xiaoshouyi.com)",value:"cd"},{name:"tencentuat环境(crm-tencentuat.xiaoshouyi.com)",value:"tencentuat"},{name:"自定义环境(在neo.config.js / neoConfig 中自行配置)",value:"custom"}],B=k.map(e=>e.value);return u.middleware(function(e){if(e.help||e.version)return;const o=function(e){if(!e._||0===e._.length)return"";const o=e._.join(" ");if(P[o])return o;const s=e._[0];return P[s]?s:o||s}(e);if(!o)return;const s=P[o]||o;R[o]&&(console.log(g.green(N)),console.log(g.green(`当前版本:v${M.version}.\n`))),console.log(""),console.log(g.cyan(`执行命令: ${s}`)),console.log("")}).command("init [options]","根据模板创建一个自定义组件",e=>{e.usage(S("Usage")+": $0 init [options]").option("type",{alias:"t",describe:"自定义组件类型(react ts 技术栈/ vue2.0 技术栈/ react 技术栈)"}).option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.type&&e.name)w()&&(U(`${j}创建自定义组件失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`),process.exit(1)),"github"===e.mode?y(e.type,e.name):v(e.type,e.name);else{const o=[],s=[{name:"模板1.Web端列表组件: 含基础大列表、Picker 列表等示例组件",value:"neo-web-entity-grid",short:"neo-web-entity-grid"},{name:"模板2.H5端业务组件: 含全局搜索、数据列表、数据Tabs、打开AI对话页等示例组件",value:"neo-h5-cmps",short:"neo-h5-cmps"},{name:"模板3.自定义业务组件: 含实体表单、实体数据详情、实体数据表格等示例组件",value:"neo",short:"neo"},{name:"模板4.数值指标组件: 可配置展示实体数据源中关键数值指标",value:"neo-bi-cmps",short:"neo-bi-cmps"},{name:"模板5.antd 组件: 含基于 Antd 实现的数据仪表板、搜索组件等示例组件",value:"antd",short:"antd"},{name:"模板6.echarts 组件: 含基于 ECharts 实现的图表示例组件",value:"echarts",short:"echarts"},{name:"模板7.地图组件: 含基于 高德地图API 实现的示例组件",value:"amap",short:"amap"},{name:"模板8.vue2 组件: 含基于 Vue2 实现的示例组件",value:"vue2",short:"vue2"}];e.type||o.push({name:"type",type:"list",message:"请选择您要创建的自定义组件类型: ",default:"react-ts",choices:s}),e.name||o.push({name:"name",type:"input",message:"请设置自定义组件项目名称(默认 neoCustomCmp):",default:"neoCustomCmp"}),d.prompt(o).then(o=>{const{isValid:s,errors:a}=C(o.name);s||(U(a.join("\n")),process.exit(1)),"github"===e.mode?y(o.type,o.name):v(o.type,o.name)})}}).command("config init","创建 neo.config.js 配置文件",e=>{e.usage(S("Usage")+": $0 config init").alias("h","help")},()=>{f("neo.config.js")}).command("login","登录 NeoCRM 平台(OAuth2 授权)",e=>{e.usage(S("Usage")+": $0 login [options]").option("env",{alias:"e",describe:"登录环境(可选,不指定则交互选择)。",type:"string",choices:B}).alias("h","help")},async e=>{const o=async e=>{const o=q(e,A.neoConfig);try{const e=new T(o);await e.login(),process.exit(0)}catch(e){U(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}};if(e.env)return void await o(e.env);const s=[{name:"env",type:"list",message:"请选择您要登录的环境:",default:"cd",choices:k}],a=await d.prompt(s);await o(a.env)}).command("logout","登出 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 logout").alias("h","help")},async()=>{try{const e=new T;await e.logout(),process.exit(0)}catch(e){U(`\n登出失败: ${e.message||e.msg}`),process.exit(1)}}).command("create","创建项目或者组件",e=>e.command("project [options]","创建自定义组件项目(含工程代码)",e=>{e.usage(S("Usage")+": $0 project [options]").option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.name)_.createCmpProjectByTemplate(e.name);else{const e=[{name:"name",type:"input",message:"请设置自定义组件项目名称:"}];d.prompt(e).then(e=>{const{isValid:o,errors:s}=C(e.name);o||(U(s.join("\n")),process.exit(1)),e.name?_.createCmpProjectByTemplate(e.name):(U("自定义组件项目名称不能为空。"),process.exit(1))})}}).command("cmp [options]","创建自定义组件",e=>{e.usage(S("Usage")+": $0 cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).option("targetDevice",{alias:"d",describe:"终端类型(all: 所有端, web: 网页端, mobile: 移动端),不指定则交互选择",choices:["all","web","mobile"]}).alias("h","help")},e=>{const o=[{name:"所有端(all)",value:"all"},{name:"网页端(web)",value:"web"},{name:"移动端(mobile)",value:"mobile"}];if(e.name&&void 0!==e.targetDevice)_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice});else if(e.name){const s=[{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(s).then(o=>{_.createCmpByTemplate(e.name,{targetDevice:o.targetDevice})})}else{const e=[{name:"name",type:"input",message:"请设置自定义组件名称:"},{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(e).then(e=>{e.name?_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice}):(U("自定义组件名称不能为空。"),process.exit(1))})}})).command("pull cmp [options]","拉取线上自定义组件",e=>{e.usage(S("Usage")+": $0 pull cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo pull cmp] 即将拉取自定义组件:${e.name},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);try{await _.pullCmp(e.name)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}else{const e=new x,o=h("正在拉取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表拉取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要拉取的自定义组件:",choices:[{name:"拉取所有组件(ALL)",value:"ALL"},...s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))]}];try{const o=await d.prompt(a);if(o.cmpType)if("ALL"===o.cmpType){L(`[neo pull cmp] 即将拉取当前租户下的所有自定义组件(共 ${s.length} 个),如本地存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);for(let o=0,a=s.length;o<a;o++){const n=s[o];console.log(g.gray(`[neo pull cmp] 正在拉取第 ${o+1}/${a} 个组件: ${n.cmpType}`)),await _.pullCmp(n.cmpType,e)}D("[neo pull cmp]拉取所有组件命令已执行完成。")}else L(`[neo pull cmp] 即将拉取自定义组件:${o.cmpType},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`),await _.pullCmp(o.cmpType,e);else U("请选择要拉取的自定义组件。"),process.exit(1)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}}).command("delete cmp [options]","删除线上自定义组件",e=>{e.usage(S("Usage")+": $0 delete cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name)_.deleteCmp(e.name);else{const e=new x,o=h("正在获取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表获取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要删除的自定义组件:",choices:s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))}];d.prompt(a).then(o=>{o.cmpType?_.deleteCmp(o.cmpType,e):(U("自定义组件名称不能为空。"),process.exit(1))})}}).command("preview [options]","预览指定自定义组件(仅预览组件本身内容)",e=>{e.usage(S("Usage")+": $0 preview [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.previewCmp(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要预览的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要预览的自定义组件。"),process.exit(1)),_.previewCmp(e.cmpType)})}}).command("dev","开启本地调试模式",e=>{e.usage(S("Usage")+": $0 dev").alias("h","help")},()=>{_.dev()}).command("linkDebug","开启外链调试模式(在线上页面设计器端调试)",e=>{e.usage(S("Usage")+": $0 linkDebug [options]").option("platform",{alias:"p",describe:"调试设备类型:pc(网页端)、h5(移动端),默认 pc",type:"string",choices:["pc","h5"]}).alias("h","help")},e=>{const o=e=>{_.linkDebug({platform:e})};e.platform?o(e.platform):d.prompt([{name:"platform",type:"list",message:"请选择调试设备类型:",default:"pc",choices:[{name:"网页端(PC)",value:"pc",short:"pc"},{name:"移动端(H5)",value:"h5",short:"h5"}]}]).then(e=>{e.platform||(U("未选择调试设备类型。"),process.exit(1)),o(e.platform)})}).command("build","构建生产环境代码",e=>{e.usage(S("Usage")+": $0 build").alias("h","help")},e=>{_.build()}).command("build2lib","构建 UMD 模块",e=>{e.usage(S("Usage")+": $0 build2lib").alias("h","help")},e=>{_.build2lib()}).command("publish2oss [options]","发布到oss",e=>{e.usage(S("Usage")+": $0 publish2oss [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.publish2oss(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要发布的自定义组件。"),process.exit(1)),_.publish2oss(e.cmpType)})}}).command("push cmp [options]","构建并发布自定义组件到 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 push cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo push cmp] 即将构建并发布自定义组件:${e.name} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);try{await _.pushCmp(e.name)}catch(e){U(e.message||e.msg||"发布自定义组件失败"),process.exit(1)}}else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:[{name:"发布所有组件(ALL)",value:"ALL"},...e.map(e=>({name:e,value:e}))]}];d.prompt(o).then(async o=>{o.cmpType||(U("请选择要发布的自定义组件。"),process.exit(1));try{if("ALL"===o.cmpType){L(`[neo push cmp] 即将构建并发布当前目录下的所有自定义组件(共 ${e.length} 个)到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);for(let o=0,s=e.length;o<s;o++){const a=e[o];console.log(g.gray(`[neo push cmp] 正在发布第 ${o+1}/${s} 个组件: ${a}`)),await _.pushCmp(a,!0)}D("[neo push cmp]发布所有组件命令已执行完成。")}else L(`[neo push cmp] 即将构建并发布自定义组件:${o.cmpType} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`),await _.pushCmp(o.cmpType)}catch(e){U(e.message||e.msg||"发布失败"),process.exit(1)}})}}).command("build2esm","构建 ESM 模块",e=>{e.usage(S("Usage")+": $0 build2esm").alias("h","help")},()=>{_.build2esm()}).command("inspect","输出当前配置文件",e=>{e.usage(S("Usage")+": $0 inspect").option("type",{alias:"t",describe:"环境类型(本地调试环境/生产环境/library构建环境)",default:"build"}).alias("h","help")},e=>{b(e.type)}).command("open [options]","使用 Cursor 或 VSCode 打开项目",e=>{e.usage(S("Usage")+": $0 open [options]").option("editor",{alias:"e",describe:"编辑器类型(cursor/vscode/auto),默认为 auto(自动检测)",default:"auto",choices:["cursor","vscode","code","auto"]}).option("name",{alias:"n",describe:"要打开的项目名称,默认为当前目录"}).alias("h","help")},e=>{_.openEditor(e.editor,e.name)}).alias("h","help").alias("v","version").strict().fail((e,o,s)=>{U(`\n运行命令时发生错误: ${e}。\n`),console.log(S("当前可用命令列表:")),console.log("");[{cmd:"init [options]",desc:"根据模板创建一个自定义组件"},{cmd:"create project [options]",desc:"创建自定义组件项目(含工程代码)"},{cmd:"create cmp [options]",desc:"创建自定义组件"},{cmd:"preview [options]",desc:"预览指定自定义组件(仅预览组件本身内容)"},{cmd:"linkDebug [options]",desc:"开启外链调试模式(在线上页面设计器端调试),支持 --platform pc|h5,默认网页端"},{cmd:"login [options]",desc:"登录 NeoCRM 平台(OAuth2 授权),支持 --env cd|uat|cd"},{cmd:"logout",desc:"登出 NeoCRM 平台"},{cmd:"pull cmp [options]",desc:"拉取线上自定义组件"},{cmd:"delete cmp [options]",desc:"删除线上自定义组件"},{cmd:"push cmp [options]",desc:"构建并发布自定义组件到 NeoCRM 平台"},{cmd:"open [options]",desc:"使用 Cursor 或 VSCode 打开项目"}].forEach(({cmd:e,desc:o})=>{console.log(` ${g.cyan(e.padEnd(25))} ${o}`)}),console.log(""),console.log(`使用 ${g.cyan("neo <command> --help")} 查看具体命令的帮助信息。`),console.log(""),process.exit(1)}).help().updateStrings({"Usage:":S("Usage:"),"Commands:":S("Commands:"),"Options:":S("Options:")}).parseAsync().catch(e=>{e&&(U(`\n运行命令时发生错误: ${e.message||e}。\n`),process.exit(1))}),e.__exports};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./_virtual/index.js"),o=require("figlet"),s=require("yargs"),a=require("chalk"),n=require("inquirer"),t=require("ora"),i=require("./main2.js"),p=require("./utils/common.js"),c=require("./neo/env.js"),m=require("./package.json.js");var l;exports.__require=function(){if(l)return e.__exports;l=1;const r=o,u=s,g=a,d=n,h=t,{neoInit:y,neoInitByCopy:v,inspect:b,neoConfigInit:f,validateProjectName:C,getCmpTypeByDir:$,NeoService:x,NeoLoginService:T,hasNeoProject:w,consoleTag:j}=i.__require(),{errorLog:U,successLog:D,warningLog:L}=p.__require(),_=i.__require(),{getNeoCrmAPI:q}=c.__require(),M=m.default,N=r.textSync("neo",{font:"Lean"}),A=_.projectConfig,S=function(e){return g.green(g.bold(e))},R={"config init":"初始化配置文件",config:"初始化配置文件",dev:"开启本地调试模式",build:"构建生产环境代码",build2lib:"构建 UMD 模块",build2esm:"构建 ESM 模块",publish2oss:"发布到 OSS",inspect:"输出配置文件",open:"打开项目"},P={...R,init:"初始化自定义组件项目",login:"登录 NeoCRM 平台",logout:"登出 NeoCRM 平台","create project":"创建自定义组件项目","create cmp":"创建自定义组件",linkDebug:"开启外链调试模式",preview:"预览自定义组件","pull cmp":"拉取线上自定义组件","push cmp":"发布自定义组件到平台","delete cmp":"删除线上自定义组件",pull:"拉取线上自定义组件",push:"发布自定义组件到平台",delete:"删除线上自定义组件"},k=[{name:"线上生产环境(crm.xiaoshouyi.com)",value:"production"},{name:"P20环境(crm-p20.xiaoshouyi.com)",value:"p20"},{name:"沙盒环境(crm-sandbox.xiaoshouyi.com)",value:"sandbox"},{name:"开发环境(crm-cd.xiaoshouyi.com)",value:"cd"},{name:"tencentuat环境(crm-tencentuat.xiaoshouyi.com)",value:"tencentuat"},{name:"自定义环境(在neo.config.js / neoConfig 中自行配置)",value:"custom"}],B=k.map(e=>e.value);return u.middleware(function(e){if(e.help||e.version)return;const o=function(e){if(!e._||0===e._.length)return"";const o=e._.join(" ");if(P[o])return o;const s=e._[0];return P[s]?s:o||s}(e);if(!o)return;const s=P[o]||o;R[o]&&(console.log(g.green(N)),console.log(g.green(`当前版本:v${M.version}.\n`))),console.log(""),console.log(g.cyan(`执行命令: ${s}`)),console.log("")}).command("init [options]","根据模板创建一个自定义组件",e=>{e.usage(S("Usage")+": $0 init [options]").option("type",{alias:"t",describe:"自定义组件类型(react ts 技术栈/ vue2.0 技术栈/ react 技术栈)"}).option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.type&&e.name)w()&&(U(`${j}创建自定义组件失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`),process.exit(1)),"github"===e.mode?y(e.type,e.name):v(e.type,e.name);else{const o=[],s=[{name:"模板1.Web端列表组件: 含基础大列表、Picker 列表等示例组件",value:"neo-web-entity-grid",short:"neo-web-entity-grid"},{name:"模板2.H5端业务组件: 含全局搜索、数据列表、数据Tabs、打开AI对话页等示例组件",value:"neo-h5-cmps",short:"neo-h5-cmps"},{name:"模板3.自定义业务组件: 含实体表单、实体数据详情、实体数据表格等示例组件",value:"neo",short:"neo"},{name:"模板4.数值指标组件: 可配置展示实体数据源中关键数值指标",value:"neo-bi-cmps",short:"neo-bi-cmps"},{name:"模板5.antd 组件: 含基于 Antd 实现的数据仪表板、搜索组件等示例组件",value:"antd",short:"antd"},{name:"模板6.echarts 组件: 含基于 ECharts 实现的图表示例组件",value:"echarts",short:"echarts"},{name:"模板7.地图组件: 含基于 高德地图API 实现的示例组件",value:"amap",short:"amap"},{name:"模板8.vue2 组件: 含基于 Vue2 实现的示例组件",value:"vue2",short:"vue2"}];e.type||o.push({name:"type",type:"list",message:"请选择您要创建的自定义组件类型: ",default:"react-ts",choices:s}),e.name||o.push({name:"name",type:"input",message:"请设置自定义组件项目名称(默认 neoCustomCmp):",default:"neoCustomCmp"}),d.prompt(o).then(o=>{const{isValid:s,errors:a}=C(o.name);s||(U(a.join("\n")),process.exit(1)),"github"===e.mode?y(o.type,o.name):v(o.type,o.name)})}}).command("config init","创建 neo.config.js 配置文件",e=>{e.usage(S("Usage")+": $0 config init").alias("h","help")},()=>{f("neo.config.js")}).command("login","登录 NeoCRM 平台(OAuth2 授权)",e=>{e.usage(S("Usage")+": $0 login [options]").option("env",{alias:"e",describe:"登录环境(可选,不指定则交互选择)。",type:"string",choices:B}).alias("h","help")},async e=>{const o=async e=>{const o=q(e,A.neoConfig);try{const e=new T(o);await e.login(),process.exit(0)}catch(e){U(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}};if(e.env)return void await o(e.env);const s=[{name:"env",type:"list",message:"请选择您要登录的环境:",default:"cd",choices:k}],a=await d.prompt(s);await o(a.env)}).command("logout","登出 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 logout").alias("h","help")},async()=>{try{const e=new T;await e.logout(),process.exit(0)}catch(e){U(`\n登出失败: ${e.message||e.msg}`),process.exit(1)}}).command("create","创建项目或者组件",e=>e.command("project [options]","创建自定义组件项目(含工程代码)",e=>{e.usage(S("Usage")+": $0 project [options]").option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.name)_.createCmpProjectByTemplate(e.name);else{const e=[{name:"name",type:"input",message:"请设置自定义组件项目名称:"}];d.prompt(e).then(e=>{const{isValid:o,errors:s}=C(e.name);o||(U(s.join("\n")),process.exit(1)),e.name?_.createCmpProjectByTemplate(e.name):(U("自定义组件项目名称不能为空。"),process.exit(1))})}}).command("cmp [options]","创建自定义组件",e=>{e.usage(S("Usage")+": $0 cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).option("targetDevice",{alias:"d",describe:"终端类型(all: 所有端, web: 网页端, mobile: 移动端),不指定则交互选择",choices:["all","web","mobile"]}).alias("h","help")},e=>{const o=[{name:"所有端(all)",value:"all"},{name:"网页端(web)",value:"web"},{name:"移动端(mobile)",value:"mobile"}];if(e.name&&void 0!==e.targetDevice)_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice});else if(e.name){const s=[{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(s).then(o=>{_.createCmpByTemplate(e.name,{targetDevice:o.targetDevice})})}else{const e=[{name:"name",type:"input",message:"请设置自定义组件名称:"},{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(e).then(e=>{e.name?_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice}):(U("自定义组件名称不能为空。"),process.exit(1))})}})).command("pull cmp [options]","拉取线上自定义组件",e=>{e.usage(S("Usage")+": $0 pull cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo pull cmp] 即将拉取自定义组件:${e.name},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);try{await _.pullCmp(e.name)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}else{const e=new x,o=h("正在拉取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表拉取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要拉取的自定义组件:",choices:[{name:"拉取所有组件(ALL)",value:"ALL"},...s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))]}];try{const o=await d.prompt(a);if(o.cmpType)if("ALL"===o.cmpType){L(`[neo pull cmp] 即将拉取当前租户下的所有自定义组件(共 ${s.length} 个),如本地存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);for(let o=0,a=s.length;o<a;o++){const n=s[o];console.log(g.gray(`[neo pull cmp] 正在拉取第 ${o+1}/${a} 个组件: ${n.cmpType}`)),await _.pullCmp(n.cmpType,e)}D("[neo pull cmp]拉取所有组件命令已执行完成。")}else L(`[neo pull cmp] 即将拉取自定义组件:${o.cmpType},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`),await _.pullCmp(o.cmpType,e);else U("请选择要拉取的自定义组件。"),process.exit(1)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}}).command("delete cmp [options]","删除线上自定义组件",e=>{e.usage(S("Usage")+": $0 delete cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name)_.deleteCmp(e.name);else{const e=new x,o=h("正在获取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表获取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要删除的自定义组件:",choices:s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))}];d.prompt(a).then(o=>{o.cmpType?_.deleteCmp(o.cmpType,e):(U("自定义组件名称不能为空。"),process.exit(1))})}}).command("preview [options]","预览指定自定义组件(仅预览组件本身内容)",e=>{e.usage(S("Usage")+": $0 preview [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.previewCmp(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要预览的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要预览的自定义组件。"),process.exit(1)),_.previewCmp(e.cmpType)})}}).command("dev","开启本地调试模式",e=>{e.usage(S("Usage")+": $0 dev").alias("h","help")},()=>{_.dev()}).command("linkDebug","开启外链调试模式(在线上页面设计器端调试)",e=>{e.usage(S("Usage")+": $0 linkDebug [options]").option("platform",{alias:"p",describe:"调试设备类型:pc(网页端)、h5(移动端),默认 pc",type:"string",choices:["pc","h5"]}).alias("h","help")},e=>{const o=e=>{_.linkDebug({platform:e})};e.platform?o(e.platform):d.prompt([{name:"platform",type:"list",message:"请选择调试设备类型:",default:"pc",choices:[{name:"网页端(PC)",value:"pc",short:"pc"},{name:"移动端(H5)",value:"h5",short:"h5"}]}]).then(e=>{e.platform||(U("未选择调试设备类型。"),process.exit(1)),o(e.platform)})}).command("build","构建生产环境代码",e=>{e.usage(S("Usage")+": $0 build").alias("h","help")},e=>{_.build()}).command("build2lib","构建 UMD 模块",e=>{e.usage(S("Usage")+": $0 build2lib").alias("h","help")},e=>{_.build2lib()}).command("publish2oss [options]","发布到oss",e=>{e.usage(S("Usage")+": $0 publish2oss [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.publish2oss(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要发布的自定义组件。"),process.exit(1)),_.publish2oss(e.cmpType)})}}).command("push cmp [options]","构建并发布自定义组件到 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 push cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo push cmp] 即将构建并发布自定义组件:${e.name} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);try{await _.pushCmp(e.name)}catch(e){U(e.message||e.msg||"发布自定义组件失败"),process.exit(1)}}else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:[{name:"发布所有组件(ALL)",value:"ALL"},...e.map(e=>({name:e,value:e}))]}];d.prompt(o).then(async o=>{o.cmpType||(U("请选择要发布的自定义组件。"),process.exit(1));try{if("ALL"===o.cmpType){L(`[neo push cmp] 即将构建并发布当前目录下的所有自定义组件(共 ${e.length} 个)到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);for(let o=0,s=e.length;o<s;o++){const a=e[o];console.log(g.gray(`[neo push cmp] 正在发布第 ${o+1}/${s} 个组件: ${a}`)),await _.pushCmp(a,!0)}D("[neo push cmp]发布所有组件命令已执行完成。")}else L(`[neo push cmp] 即将构建并发布自定义组件:${o.cmpType} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`),await _.pushCmp(o.cmpType)}catch(e){U(e.message||e.msg||"发布失败"),process.exit(1)}})}}).command("build2esm","构建 ESM 模块",e=>{e.usage(S("Usage")+": $0 build2esm").alias("h","help")},()=>{_.build2esm()}).command("inspect","输出当前配置文件",e=>{e.usage(S("Usage")+": $0 inspect").option("type",{alias:"t",describe:"环境类型(本地调试环境/生产环境/library构建环境)",default:"build"}).alias("h","help")},e=>{b(e.type)}).command("open [options]","使用 Cursor 或 VSCode 打开项目",e=>{e.usage(S("Usage")+": $0 open [options]").option("editor",{alias:"e",describe:"编辑器类型(cursor/vscode/auto),默认为 auto(自动检测)",default:"auto",choices:["cursor","vscode","code","auto"]}).option("name",{alias:"n",describe:"要打开的项目名称,默认为当前目录"}).alias("h","help")},e=>{_.openEditor(e.editor,e.name)}).alias("h","help").alias("v","version").strict().fail((e,o,s)=>{U(`\n运行命令时发生错误: ${e}。\n`),console.log(S("当前可用命令列表:")),console.log("");[{cmd:"init [options]",desc:"根据模板创建一个自定义组件"},{cmd:"create project [options]",desc:"创建自定义组件项目(含工程代码)"},{cmd:"create cmp [options]",desc:"创建自定义组件"},{cmd:"preview [options]",desc:"预览指定自定义组件(仅预览组件本身内容)"},{cmd:"linkDebug [options]",desc:"开启外链调试模式(在线上页面设计器端调试),支持 --platform pc|h5,默认网页端"},{cmd:"login [options]",desc:"登录 NeoCRM 平台(OAuth2 授权),支持 --env cd|uat|cd"},{cmd:"logout",desc:"登出 NeoCRM 平台"},{cmd:"pull cmp [options]",desc:"拉取线上自定义组件"},{cmd:"delete cmp [options]",desc:"删除线上自定义组件"},{cmd:"push cmp [options]",desc:"构建并发布自定义组件到 NeoCRM 平台"},{cmd:"open [options]",desc:"使用 Cursor 或 VSCode 打开项目"}].forEach(({cmd:e,desc:o})=>{console.log(` ${g.cyan(e.padEnd(25))} ${o}`)}),console.log(""),console.log(`使用 ${g.cyan("neo <command> --help")} 查看具体命令的帮助信息。`),console.log(""),process.exit(1)}).help().updateStrings({"Usage:":S("Usage:"),"Commands:":S("Commands:"),"Options:":S("Options:")}).parseAsync().catch(e=>{e&&(U(`\n运行命令时发生错误: ${e.message||e}。\n`),process.exit(1))}),e.__exports};
package/dist/neo/env.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var t,e;exports.__require=function(){if(e)return t;e=1;const a=o,u={production:{neoBaseURL:"https://crm.xiaoshouyi.com",loginURL:"https://login.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login.xiaoshouyi.com/auc/oauth2/token"},gray:{neoBaseURL:"https://crm-gray.xiaoshouyi.com",loginURL:"https://login.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login.xiaoshouyi.com/auc/oauth2/token"},sandbox:{neoBaseURL:"https://crm-sandbox.xiaoshouyi.com",loginURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/token"},cd:{neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token"},tencentuat:{neoBaseURL:"https://crm-tencentuat.xiaoshouyi.com",loginURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/token"}},n={neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token",delete:"/rest/metadata/v3.0/ui/customComponents",saveAPI:"/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent",queryAll_v1:"/rest/metadata/v3.0/ui/components/filter?custom=true",queryAll:"/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents",getCodeLibAPI:o=>`/rest/metadata/v3.0/ui/customComponents/${o}/codeLib`,uploadAPI:"/rest/metadata/v3.0/ui/customComponents/actions/upload",getUserInfoAPI:"/rest/auc/v2.0/userInfo",pcLinkDebugUrl:"/bff/spa/neo.ui.designer.web/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true",h5LinkDebugUrl:"/bff/spa/neo.ui.designer.h5/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true"};return t={DefaultNeoCrmAPI:n,getNeoCrmAPI:(o="cd",t={})=>{let e,s=a.cloneDeep(n);return e="custom"===o?{...t,neoBaseURL:t.neoBaseURL,loginURL:t.loginURL||t.loginAPI,tokenURL:t.tokenURL||t.tokenAPI}:u[o]||u.cd,{...s,...e}}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var t,e;exports.__require=function(){if(e)return t;e=1;const a=o,u={production:{neoBaseURL:"https://crm.xiaoshouyi.com",loginURL:"https://login.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login.xiaoshouyi.com/auc/oauth2/token"},p20:{neoBaseURL:"https://crm-p20.xiaoshouyi.com",loginURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/token"},sandbox:{neoBaseURL:"https://crm-sandbox.xiaoshouyi.com",loginURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/token"},cd:{neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token"},tencentuat:{neoBaseURL:"https://crm-tencentuat.xiaoshouyi.com",loginURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/token"}},n={neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token",delete:"/rest/metadata/v3.0/ui/customComponents",saveAPI:"/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent",queryAll_v1:"/rest/metadata/v3.0/ui/components/filter?custom=true",queryAll:"/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents",getCodeLibAPI:o=>`/rest/metadata/v3.0/ui/customComponents/${o}/codeLib`,uploadAPI:"/rest/metadata/v3.0/ui/customComponents/actions/upload",getUserInfoAPI:"/rest/auc/v2.0/userInfo",pcLinkDebugUrl:"/bff/spa/neo.ui.designer.web/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true",h5LinkDebugUrl:"/bff/spa/neo.ui.designer.h5/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true"};return t={DefaultNeoCrmAPI:n,getNeoCrmAPI:(o="cd",t={})=>{let e,s=a.cloneDeep(n);return e="custom"===o?{...t,neoBaseURL:t.neoBaseURL,loginURL:t.loginURL||t.loginAPI,tokenURL:t.tokenURL||t.tokenAPI}:u[o]||u.cd,{...s,...e}}}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),o=require("lodash"),r=require("akfun"),s=require("ora"),i=require("jsdom"),a=require("./neoService.js"),n=require("../utils/common.js"),l=require("../utils/pathUtils.js"),c=require("../utils/projectUtils/createCmpProjectZip.js"),p=require("../utils/projectUtils/updatePublishLog.js"),u=require("../utils/cmpTypeValidator.js");var g,m;exports.__require=function(){if(m)return g;m=1;const d=e,w=t,h=o,{getConfigObj:f}=r,b=s,{JSDOM:T}=i,y=a.__require(),{getFramework:C,errorLog:$,successLog:v}=n.__require(),{catchCurPackageJson:q}=l.__require(),j=c.__require(),P=p.__require(),{validateApiName:_}=u.__require(),D=f(q()),S=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),O=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,eventCategory:e.eventCategory||2,pageType:e.pageType||1,targetDevice:e.targetDevice||1,eventParams:e.eventParams||[]})):[],E=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,funcScope:e.funcScope||1,pageType:e.pageType||1,targetDevice:e.targetDevice||1,custom:!0,funcInParams:e.funcInParams||[],funcOutParams:e.funcOutParams||[]})):[];return g=async(e,t)=>{const o=b("正在发布组件...").start(),{isValid:r,errors:s}=_(t);if(!r)throw $(s.join("\n")),new Error(s.join("\n"));try{let r,s=new y;await s.ensureValidToken(),o.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{r=j(t,process.cwd(),e.assetsRoot),r?v(`[1/4] 源码文件打包完成: ${w.basename(r)}。`,o):$("[1/4] 源码文件打包失败,未返回 zip 文件路径。",o)}catch(e){$("[1/4] 源码文件打包失败。",o)}o.start("[2/4] 获取自定义组件构建产物...");const i=await s.getCmpAssets(t);let a;o.start("[3/4] 构建组件数据...");try{a=await(async(e,t)=>{if(!t||!t.cmpType)return $("自定义组件信息或组件名称不能为空"),null;const{cmpType:o}=t;if(!e||!d.existsSync(e))return $(`未找到自定义组件目录: ${e}`),null;const r=h.camelCase(o),s=w.join(e,`${r}Model.js`);if(!d.existsSync(s))throw $(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`);const i=globalThis.window;if(!globalThis.window){const e=new T("<!DOCTYPE html><p>Hello world</p>",{url:"http://localhost",contentType:"text/html",includeNodeLocations:!0,storageQuota:1e5});globalThis.window={...e.window,console:console,neoRequire:()=>{},postMessage:()=>{}},globalThis.document=e.window.document,globalThis.this={}}const a=globalThis.self;globalThis.self||(globalThis.self=globalThis);try{if(!d.existsSync(s))throw $(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`);if(require(s),!globalThis.window||!globalThis.window.NEOEditorCustomModels)throw $(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${s} `),new Error(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${s} `);const e=globalThis.window.NEOEditorCustomModels[o];if(!e)throw $(`未找到自定义组件模型类(${o}),模型文件地址: ${s} `),new Error(`未找到自定义组件模型类(${o}),模型文件地址: ${s} `);const r=new e;if(!r)throw $(`未找到自定义组件模型信息(${o}),模型文件地址: ${s} `),new Error(`未找到自定义组件模型信息(${o}),模型文件地址: ${s} `);return{...t,version:D.version||"1.0.0",framework:D.framework?C(D.framework):0,label:r.label||o,description:r.description||"",componentCategory:(r.tags||["自定义组件"]).join(","),targetPage:r.targetPage||["all"],targetObject:r.targetObject||["all"],targetApplication:r.targetApplication||["all"],targetDevice:r.targetDevice||"web",iconUrl:r.iconUrl||r.iconUrl,defaultProps:JSON.stringify(r.defaultComProps||{}),previewProps:JSON.stringify(r.previewComProps||{}),props:S(r.propsSchema||[]),events:O(r.events||[],o),functions:E(r.functions||r.actions||[],o),exposedToDesigner:void 0===r.exposedToDesigner||r.exposedToDesigner,namespace:r.namespace||"neo-cmp-cli",enableDuplicate:void 0===r.enableDuplicate||r.enableDuplicate}}catch(e){return $(`自定义组件模型文件解析失败 (${s||"未知路径"}): ${e.message||e.msg}`),$(e.stack),null}finally{void 0===i?delete globalThis.window:globalThis.window=i,void 0===a?delete globalThis.self:globalThis.self=a}})(e.assetsRoot,i),a?v("[3/4] 组件数据构建完成。",o):$(`[3/4] 未获取到自定义组件模型信息(${t})。`,o)}catch(e){$(`[3/4] 组件数据构建失败: ${e.message||e.msg}`,o)}o.start("[4/4] 保存组件信息到 NeoCRM 平台...");const n=["assetFile","modelAssetFile","cssAssetFile","codeLibFile"],l={...a};n.forEach(e=>{l[e]&&l[e].fileContent&&(l[e]=h.omit(l[e],["fileContent"]))}),P(l);try{await s.updateCustomComponent(a),v("[4/4] 组件信息保存成功",o)}catch(e){$("[4/4] 组件信息保存失败",o)}const{tenant_id:c,instance_uri:p}=s.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${c||"未返回"},所在租户的 API 域名: ${p||"未返回"}。)`)}catch(e){try{o&&o.isSpinning&&$(`❌ 自定义组件发布失败: ${e.message||e.msg}`,o)}catch{$(`\n❌ 自定义组件发布失败: ${e.message||e.msg}`)}throw e}},g};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),r=require("lodash"),o=require("akfun"),s=require("ora"),i=require("jsdom"),a=require("./neoService.js"),n=require("../utils/common.js"),l=require("../utils/pathUtils.js"),c=require("../utils/projectUtils/createCmpProjectZip.js"),p=require("../utils/projectUtils/updatePublishLog.js"),u=require("../utils/cmpTypeValidator.js");var g,m;exports.__require=function(){if(m)return g;m=1;const d=e,w=t,h=r,{getConfigObj:f}=o,y=s,{JSDOM:b}=i,T=a.__require(),{getFramework:C,errorLog:$,successLog:v}=n.__require(),{catchCurPackageJson:q}=l.__require(),j=c.__require(),P=p.__require(),{validateApiName:S}=u.__require(),O=f(q()),_=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),D=(e=[],t)=>e&&0!==e.length?e.map(e=>{let r=e.eventParams||"[]";return h.isArray(r)&&(r=JSON.stringify(r)),{...e,componentType:t,eventCategory:e.eventCategory||2,pageType:e.pageType||1,targetDevice:e.targetDevice||1,eventParams:r}}):[],E=(e=[],t)=>e&&0!==e.length?e.map(e=>{let r=e.funcInParams||"[]",o=e.funcOutParams||"[]";return h.isArray(r)&&(r=JSON.stringify(r)),h.isArray(o)&&(o=JSON.stringify(o)),{...e,componentType:t,funcScope:e.funcScope||1,pageType:e.pageType||1,targetDevice:e.targetDevice||1,custom:!0,funcInParams:r,funcOutParams:o}}):[];return g=async(e,t)=>{const r=y("正在发布组件...").start(),{isValid:o,errors:s}=S(t);if(!o)throw $(s.join("\n")),new Error(s.join("\n"));try{let o,s=new T;await s.ensureValidToken(),r.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{o=j(t,process.cwd(),e.assetsRoot),o?v(`[1/4] 源码文件打包完成: ${w.basename(o)}。`,r):$("[1/4] 源码文件打包失败,未返回 zip 文件路径。",r)}catch(e){$("[1/4] 源码文件打包失败。",r)}r.start("[2/4] 获取自定义组件构建产物...");const i=await s.getCmpAssets(t);let a;r.start("[3/4] 构建组件数据...");try{a=await(async(e,t)=>{if(!t||!t.cmpType)return $("自定义组件信息或组件名称不能为空"),null;const{cmpType:r}=t;if(!e||!d.existsSync(e))return $(`未找到自定义组件目录: ${e}`),null;const o=h.camelCase(r),s=w.join(e,`${o}Model.js`);if(!d.existsSync(s))throw $(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`);const i=globalThis.window;if(!globalThis.window){const e=new b("<!DOCTYPE html><p>Hello world</p>",{url:"http://localhost",contentType:"text/html",includeNodeLocations:!0,storageQuota:1e5});globalThis.window={...e.window,console:console,neoRequire:()=>{},postMessage:()=>{}},globalThis.document=e.window.document,globalThis.this={}}const a=globalThis.self;globalThis.self||(globalThis.self=globalThis);try{if(!d.existsSync(s))throw $(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${s}`);if(require(s),!globalThis.window||!globalThis.window.NEOEditorCustomModels)throw $(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${s} `),new Error(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${s} `);const e=globalThis.window.NEOEditorCustomModels[r];if(!e)throw $(`未找到自定义组件模型类(${r}),模型文件地址: ${s} `),new Error(`未找到自定义组件模型类(${r}),模型文件地址: ${s} `);const o=new e;if(!o)throw $(`未找到自定义组件模型信息(${r}),模型文件地址: ${s} `),new Error(`未找到自定义组件模型信息(${r}),模型文件地址: ${s} `);return{...t,version:O.version||"1.0.0",framework:O.framework?C(O.framework):0,label:o.label||r,description:o.description||"",componentCategory:(o.tags||["自定义组件"]).join(","),targetPage:o.targetPage||["all"],targetObject:o.targetObject||["all"],targetApplication:o.targetApplication||["all"],targetDevice:o.targetDevice||"web",iconUrl:o.iconUrl||o.iconUrl,defaultProps:JSON.stringify(o.defaultComProps||{}),previewProps:JSON.stringify(o.previewComProps||{}),props:_(o.propsSchema||[]),events:D(o.events||[],r),functions:E(o.functions||o.actions||[],r),exposedToDesigner:void 0===o.exposedToDesigner||o.exposedToDesigner,namespace:o.namespace||"neo-cmp-cli",enableDuplicate:void 0===o.enableDuplicate||o.enableDuplicate}}catch(e){return $(`自定义组件模型文件解析失败 (${s||"未知路径"}): ${e.message||e.msg}`),$(e.stack),null}finally{void 0===i?delete globalThis.window:globalThis.window=i,void 0===a?delete globalThis.self:globalThis.self=a}})(e.assetsRoot,i),a?v("[3/4] 组件数据构建完成。",r):$(`[3/4] 未获取到自定义组件模型信息(${t})。`,r)}catch(e){$(`[3/4] 组件数据构建失败: ${e.message||e.msg}`,r)}r.start("[4/4] 保存组件信息到 NeoCRM 平台...");const n=["assetFile","modelAssetFile","cssAssetFile","codeLibFile"],l={...a};n.forEach(e=>{l[e]&&l[e].fileContent&&(l[e]=h.omit(l[e],["fileContent"]))}),P(l);try{await s.updateCustomComponent(a),v("[4/4] 组件信息保存成功",r)}catch(e){$("[4/4] 组件信息保存失败",r)}const{tenant_id:c,instance_uri:p}=s.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${c||"未返回"},所在租户的 API 域名: ${p||"未返回"}。)`)}catch(e){try{r&&r.isSpinning&&$(`❌ 自定义组件发布失败: ${e.message||e.msg}`,r)}catch{$(`\n❌ 自定义组件发布失败: ${e.message||e.msg}`)}throw e}},g};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.13.16";const o={version:e};exports.default=o,exports.version=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.13.18";const o={version:e};exports.default=o,exports.version=e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.13.17",
3
+ "version": "1.13.18",
4
4
  "description": "Neo 自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -58,7 +58,8 @@
58
58
  "portfinder": "^1.0.38",
59
59
  "webpack-sources": "^3.2.3",
60
60
  "yargs": "^17.7.2",
61
- "jsdom": "^28.0.0"
61
+ "jsdom": "^28.0.0",
62
+ "@cloudbase/js-sdk": "^1.7.1"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@commitlint/cli": "^18.0.0",
@@ -10,235 +10,4 @@
10
10
  - [获取业务数据信息(单个数据)](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_paas_customObject_getBusinessDataInformation.html&id=1405&dir=output_1757929564205&time=1758781533725): /rest/data/v2.0/xobjects/{xObjectApiKey}/{id};
11
11
  - [查询接口(通用查询接口)](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_queryInterfaceDescription.html&id=1405&dir=output_1757929564205&time=1758784491846): /rest/data/v2/query;
12
12
  - [获取业务类型描述](https://doc.xiaoshouyi.com/?sso-domain=login-cd.xiaoshouyi.com#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_paas_customObject_getBusinessTypeDescription.html&id=1405&dir=output_1757929564205&time=1758798530511): /rest/data/v2.0/xobjects/{xObjectApiKey}/busiType;
13
- - 更多可用接口见[文档](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_apiIntroduction.html&id=1405&dir=output_1757929564205)。
14
-
15
- ## Open API 请求方法
16
-
17
- ### 基础请求工具
18
-
19
- #### axiosFetcher
20
- 基于 axios 封装的通用请求工具,支持 GET、POST、PATCH、DELETE 等请求方法。
21
-
22
- ```typescript
23
- import axiosFetcher from '@/utils/axiosFetcher';
24
-
25
- // 基本用法
26
- const result = await axiosFetcher({
27
- url: '/api/endpoint',
28
- method: 'GET',
29
- data: { key: 'value' },
30
- headers: { 'Custom-Header': 'value' },
31
- timeout: 30000
32
- });
33
- ```
34
-
35
- **参数说明:**
36
- - `url`: 请求地址
37
- - `method`: 请求方法,默认为 'GET'
38
- - `data`: 请求数据,GET 请求会转为 params
39
- - `headers`: 请求头,默认包含 'Content-Type': 'application/json'
40
- - `timeout`: 超时时间,默认 30000ms
41
-
42
- ### 业务对象相关接口
43
-
44
- #### 1. 查询业务对象数据列表 (queryXObjectData)
45
- 使用通用查询接口获取业务对象数据,支持分页和排序。
46
-
47
- ```typescript
48
- import { queryXObjectData } from '@/utils/queryObjectData';
49
-
50
- // 基本查询
51
- const result = await queryXObjectData({
52
- xObjectApiKey: 'Contact', // 业务对象 API Key
53
- fields: ['name', 'phone', 'email'], // 查询字段
54
- page: 1, // 页码
55
- pageSize: 10, // 每页数量
56
- orderBy: 'name asc' // 排序条件(可选)
57
- });
58
- ```
59
-
60
- **参数说明:**
61
- - `xObjectApiKey`: 业务对象的 API Key
62
- - `fields`: 需要查询的字段数组,会自动添加 'id' 字段
63
- - `page`: 页码,默认为 1
64
- - `pageSize`: 每页数量,默认为 10
65
- - `orderBy`: 排序条件,如 'name asc' 或 'createdTime desc'
66
-
67
- **返回结果:**
68
- ```typescript
69
- {
70
- code: 200,
71
- result: {
72
- // 查询结果数据
73
- records: any[],
74
- // 分页信息
75
- totalSize: number, // 总个数
76
- }
77
- }
78
- ```
79
-
80
- #### 2. 获取业务类型列表 (getEntityTypeList)
81
- 获取指定业务对象的业务类型列表。
82
-
83
- ```typescript
84
- import { getEntityTypeList } from '@/utils/xobjects';
85
-
86
- const result = await getEntityTypeList('Contact', {
87
- // 其他请求选项
88
- });
89
- ```
90
-
91
- **参数说明:**
92
- - `xObjectApiKey`: 业务对象的 API Key
93
- - `options`: 可选的请求配置
94
-
95
- #### 3. 获取对象列表 (getEntityList)
96
- 获取系统中的对象列表,支持标准对象和自定义对象。
97
-
98
- ```typescript
99
- import { getEntityList } from '@/utils/xobjects';
100
-
101
- // 获取标准对象列表
102
- const standardObjects = await getEntityList({
103
- custom: false, // 获取标准对象
104
- active: true // 仅获取有权限的对象
105
- });
106
-
107
- // 获取自定义对象列表
108
- const customObjects = await getEntityList({
109
- custom: true, // 获取自定义对象
110
- active: true // 仅获取有权限的对象
111
- });
112
- ```
113
-
114
- **参数说明:**
115
- - `custom`: 是否获取自定义对象,false 为标准对象,true 为自定义对象
116
- - `active`: 是否仅获取有权限的对象,默认为 true
117
-
118
- #### 4. 创建业务数据 (createXObject)
119
- 创建新的业务数据记录。
120
-
121
- ```typescript
122
- import { createXObject } from '@/utils/xobjects';
123
-
124
- const result = await createXObject('Contact', {
125
- method: 'POST',
126
- data: {
127
- name: '张三',
128
- phone: '13800138000',
129
- email: 'zhangsan@example.com'
130
- }
131
- });
132
- ```
133
-
134
- **参数说明:**
135
- - `xObjectApiKey`: 业务对象的 API Key
136
- - `options.data`: 要创建的数据对象
137
- - `options.method`: 请求方法,默认为 'GET'(建议使用 'POST')
138
-
139
- #### 5. 更新业务数据 (updateXObject)
140
- 更新指定的业务数据记录。
141
-
142
- ```typescript
143
- import { updateXObject } from '@/utils/xobjects';
144
-
145
- const result = await updateXObject('Contact', '12345', {
146
- method: 'PATCH',
147
- data: {
148
- name: '李四',
149
- phone: '13900139000'
150
- }
151
- });
152
- ```
153
-
154
- **参数说明:**
155
- - `xObjectApiKey`: 业务对象的 API Key
156
- - `objectId`: 要更新的记录 ID
157
- - `options.data`: 要更新的数据对象
158
- - `options.method`: 请求方法,默认为 'PATCH'
159
-
160
- #### 6. 获取业务数据信息 (getXObject)
161
- 获取指定业务数据记录的详细信息。
162
-
163
- ```typescript
164
- import { getXObject } from '@/utils/xobjects';
165
-
166
- const result = await getXObject('Contact', '12345', {
167
- // 其他请求选项
168
- });
169
- ```
170
-
171
- **参数说明:**
172
- - `xObjectApiKey`: 业务对象的 API Key
173
- - `objectId`: 要获取的记录 ID
174
- - `options`: 可选的请求配置
175
-
176
- #### 7. 删除业务数据 (deleteXObject)
177
- 删除指定的业务数据记录。
178
-
179
- ```typescript
180
- import { deleteXObject } from '@/utils/xobjects';
181
-
182
- const result = await deleteXObject('Contact', '12345');
183
- ```
184
-
185
- **参数说明:**
186
- - `xObjectApiKey`: 业务对象的 API Key
187
- - `objectId`: 要删除的记录 ID
188
-
189
- #### 8. 获取业务对象描述 (getXObjectDesc)
190
- 获取业务对象的描述信息。
191
-
192
- ```typescript
193
- import { getXObjectDesc } from '@/utils/xobjects';
194
-
195
- const result = await getXObjectDesc('Contact');
196
- ```
197
-
198
- **参数说明:**
199
- - `xObjectApiKey`: 业务对象的 API Key
200
-
201
- ### 使用示例
202
-
203
- ```typescript
204
- import {
205
- queryXObjectData,
206
- createXObject,
207
- updateXObject,
208
- getXObject,
209
- deleteXObject
210
- } from '@/utils/xobjects';
211
-
212
- // 查询联系人列表
213
- const contacts = await queryXObjectData({
214
- xObjectApiKey: 'Contact',
215
- fields: ['name', 'phone', 'email'],
216
- page: 1,
217
- pageSize: 20,
218
- orderBy: 'createdTime desc'
219
- });
220
-
221
- // 创建新联系人
222
- const newContact = await createXObject('Contact', {
223
- method: 'POST',
224
- data: {
225
- name: '王五',
226
- phone: '13700137000',
227
- email: 'wangwu@example.com'
228
- }
229
- });
230
-
231
- // 更新联系人
232
- const updatedContact = await updateXObject('Contact', newContact.id, {
233
- data: {
234
- name: '王五(更新)'
235
- }
236
- });
237
-
238
- // 获取联系人详情
239
- const contactDetail = await getXObject('Contact', newContact.id);
240
-
241
- // 删除联系人
242
- await deleteXObject('Contact', newContact.id);
243
- ```
244
-
13
+ - 更多可用接口见[文档](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_apiIntroduction.html&id=1405&dir=output_1757929564205)。
@@ -48,7 +48,7 @@
48
48
  "@commitlint/config-conventional": "^18.0.0",
49
49
  "@types/react": "^16.9.11",
50
50
  "@types/react-dom": "^16.9.15",
51
- "neo-cmp-cli": "^1.13.17",
51
+ "neo-cmp-cli": "^1.13.18",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5",
@@ -53,7 +53,7 @@
53
53
  "@types/react-dom": "^16.9.15",
54
54
  "husky": "^4.2.5",
55
55
  "lint-staged": "^10.2.9",
56
- "neo-cmp-cli": "^1.13.17",
56
+ "neo-cmp-cli": "^1.13.18",
57
57
  "prettier": "^2.0.5"
58
58
  },
59
59
  "overrides": {
@@ -100,7 +100,7 @@ export class TargetNumberModel {
100
100
  {
101
101
  type: 'xObjectDetailApi',
102
102
  name: 'entityApiKey',
103
- label: '绑定实体业务数据',
103
+ label: '绑定实体业务数据', // 绑定实体业务数据
104
104
  placeholder: '绑定实体业务数据源',
105
105
  disabledFieldSelect: true,
106
106
  disabledAutoFetchData: true,
@@ -11,234 +11,3 @@
11
11
  - [查询接口(通用查询接口)](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_queryInterfaceDescription.html&id=1405&dir=output_1757929564205&time=1758784491846): /rest/data/v2/query;
12
12
  - [获取业务类型描述](https://doc.xiaoshouyi.com/?sso-domain=login-cd.xiaoshouyi.com#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_paas_customObject_getBusinessTypeDescription.html&id=1405&dir=output_1757929564205&time=1758798530511): /rest/data/v2.0/xobjects/{xObjectApiKey}/busiType;
13
13
  - 更多可用接口见[文档](https://doc.xiaoshouyi.com/#/proMan/workplaceDetailApi?url=%2F%2Fconcepts%2Fapi_apiIntroduction.html&id=1405&dir=output_1757929564205)。
14
-
15
- ## Open API 请求方法
16
-
17
- ### 基础请求工具
18
-
19
- #### axiosFetcher
20
- 基于 axios 封装的通用请求工具,支持 GET、POST、PATCH、DELETE 等请求方法。
21
-
22
- ```typescript
23
- import axiosFetcher from '@/utils/axiosFetcher';
24
-
25
- // 基本用法
26
- const result = await axiosFetcher({
27
- url: '/api/endpoint',
28
- method: 'GET',
29
- data: { key: 'value' },
30
- headers: { 'Custom-Header': 'value' },
31
- timeout: 30000
32
- });
33
- ```
34
-
35
- **参数说明:**
36
- - `url`: 请求地址
37
- - `method`: 请求方法,默认为 'GET'
38
- - `data`: 请求数据,GET 请求会转为 params
39
- - `headers`: 请求头,默认包含 'Content-Type': 'application/json'
40
- - `timeout`: 超时时间,默认 30000ms
41
-
42
- ### 业务对象相关接口
43
-
44
- #### 1. 查询业务对象数据列表 (queryXObjectData)
45
- 使用通用查询接口获取业务对象数据,支持分页和排序。
46
-
47
- ```typescript
48
- import { queryXObjectData } from '@/utils/queryObjectData';
49
-
50
- // 基本查询
51
- const result = await queryXObjectData({
52
- xObjectApiKey: 'Contact', // 业务对象 API Key
53
- fields: ['name', 'phone', 'email'], // 查询字段
54
- page: 1, // 页码
55
- pageSize: 10, // 每页数量
56
- orderBy: 'name asc' // 排序条件(可选)
57
- });
58
- ```
59
-
60
- **参数说明:**
61
- - `xObjectApiKey`: 业务对象的 API Key
62
- - `fields`: 需要查询的字段数组,会自动添加 'id' 字段
63
- - `page`: 页码,默认为 1
64
- - `pageSize`: 每页数量,默认为 10
65
- - `orderBy`: 排序条件,如 'name asc' 或 'createdTime desc'
66
-
67
- **返回结果:**
68
- ```typescript
69
- {
70
- code: 200,
71
- result: {
72
- // 查询结果数据
73
- records: any[],
74
- // 分页信息
75
- totalSize: number, // 总个数
76
- }
77
- }
78
- ```
79
-
80
- #### 2. 获取业务类型列表 (getEntityTypeList)
81
- 获取指定业务对象的业务类型列表。
82
-
83
- ```typescript
84
- import { getEntityTypeList } from '@/utils/xobjects';
85
-
86
- const result = await getEntityTypeList('Contact', {
87
- // 其他请求选项
88
- });
89
- ```
90
-
91
- **参数说明:**
92
- - `xObjectApiKey`: 业务对象的 API Key
93
- - `options`: 可选的请求配置
94
-
95
- #### 3. 获取对象列表 (getEntityList)
96
- 获取系统中的对象列表,支持标准对象和自定义对象。
97
-
98
- ```typescript
99
- import { getEntityList } from '@/utils/xobjects';
100
-
101
- // 获取标准对象列表
102
- const standardObjects = await getEntityList({
103
- custom: false, // 获取标准对象
104
- active: true // 仅获取有权限的对象
105
- });
106
-
107
- // 获取自定义对象列表
108
- const customObjects = await getEntityList({
109
- custom: true, // 获取自定义对象
110
- active: true // 仅获取有权限的对象
111
- });
112
- ```
113
-
114
- **参数说明:**
115
- - `custom`: 是否获取自定义对象,false 为标准对象,true 为自定义对象
116
- - `active`: 是否仅获取有权限的对象,默认为 true
117
-
118
- #### 4. 创建业务数据 (createXObject)
119
- 创建新的业务数据记录。
120
-
121
- ```typescript
122
- import { createXObject } from '@/utils/xobjects';
123
-
124
- const result = await createXObject('Contact', {
125
- method: 'POST',
126
- data: {
127
- name: '张三',
128
- phone: '13800138000',
129
- email: 'zhangsan@example.com'
130
- }
131
- });
132
- ```
133
-
134
- **参数说明:**
135
- - `xObjectApiKey`: 业务对象的 API Key
136
- - `options.data`: 要创建的数据对象
137
- - `options.method`: 请求方法,默认为 'GET'(建议使用 'POST')
138
-
139
- #### 5. 更新业务数据 (updateXObject)
140
- 更新指定的业务数据记录。
141
-
142
- ```typescript
143
- import { updateXObject } from '@/utils/xobjects';
144
-
145
- const result = await updateXObject('Contact', '12345', {
146
- method: 'PATCH',
147
- data: {
148
- name: '李四',
149
- phone: '13900139000'
150
- }
151
- });
152
- ```
153
-
154
- **参数说明:**
155
- - `xObjectApiKey`: 业务对象的 API Key
156
- - `objectId`: 要更新的记录 ID
157
- - `options.data`: 要更新的数据对象
158
- - `options.method`: 请求方法,默认为 'PATCH'
159
-
160
- #### 6. 获取业务数据信息 (getXObject)
161
- 获取指定业务数据记录的详细信息。
162
-
163
- ```typescript
164
- import { getXObject } from '@/utils/xobjects';
165
-
166
- const result = await getXObject('Contact', '12345', {
167
- // 其他请求选项
168
- });
169
- ```
170
-
171
- **参数说明:**
172
- - `xObjectApiKey`: 业务对象的 API Key
173
- - `objectId`: 要获取的记录 ID
174
- - `options`: 可选的请求配置
175
-
176
- #### 7. 删除业务数据 (deleteXObject)
177
- 删除指定的业务数据记录。
178
-
179
- ```typescript
180
- import { deleteXObject } from '@/utils/xobjects';
181
-
182
- const result = await deleteXObject('Contact', '12345');
183
- ```
184
-
185
- **参数说明:**
186
- - `xObjectApiKey`: 业务对象的 API Key
187
- - `objectId`: 要删除的记录 ID
188
-
189
- #### 8. 获取业务对象描述 (getXObjectDesc)
190
- 获取业务对象的描述信息。
191
-
192
- ```typescript
193
- import { getXObjectDesc } from '@/utils/xobjects';
194
-
195
- const result = await getXObjectDesc('Contact');
196
- ```
197
-
198
- **参数说明:**
199
- - `xObjectApiKey`: 业务对象的 API Key
200
-
201
- ### 使用示例
202
-
203
- ```typescript
204
- import {
205
- queryXObjectData,
206
- createXObject,
207
- updateXObject,
208
- getXObject,
209
- deleteXObject
210
- } from '@/utils/xobjects';
211
-
212
- // 查询联系人列表
213
- const contacts = await queryXObjectData({
214
- xObjectApiKey: 'Contact',
215
- fields: ['name', 'phone', 'email'],
216
- page: 1,
217
- pageSize: 20,
218
- orderBy: 'createdTime desc'
219
- });
220
-
221
- // 创建新联系人
222
- const newContact = await createXObject('Contact', {
223
- method: 'POST',
224
- data: {
225
- name: '王五',
226
- phone: '13700137000',
227
- email: 'wangwu@example.com'
228
- }
229
- });
230
-
231
- // 更新联系人
232
- const updatedContact = await updateXObject('Contact', newContact.id, {
233
- data: {
234
- name: '王五(更新)'
235
- }
236
- });
237
-
238
- // 获取联系人详情
239
- const contactDetail = await getXObject('Contact', newContact.id);
240
-
241
- // 删除联系人
242
- await deleteXObject('Contact', newContact.id);
243
- ```
244
-