fmode-ng 0.0.232 → 0.0.233
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/esm2022/lib/core/agent/chat/fmode-chat.mjs +1 -1
- package/esm2022/lib/core/agent/chat/message/index.mjs +10 -0
- package/esm2022/lib/core/agent/chat/message/message-manager.mjs +10 -0
- package/esm2022/lib/core/agent/chat/message/message.mjs +10 -0
- package/esm2022/lib/core/ecom/index.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/index.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/client.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/index.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/merchant.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/public.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/shop.mjs +10 -0
- package/esm2022/lib/core/ecom/shopee/src/types.mjs +10 -0
- package/esm2022/lib/core/index.mjs +1 -1
- package/fesm2022/fmode-ng.mjs +1 -1
- package/fesm2022/fmode-ng.mjs.map +1 -1
- package/lib/core/agent/chat/fmode-chat.d.ts +35 -1
- package/lib/core/agent/chat/interface.d.ts +2 -0
- package/lib/core/agent/chat/message/index.d.ts +2 -0
- package/lib/core/agent/chat/message/message-manager.d.ts +86 -0
- package/lib/core/agent/chat/message/message.d.ts +175 -0
- package/lib/core/ecom/index.d.ts +1 -0
- package/lib/core/ecom/shopee/index.d.ts +1 -0
- package/lib/core/ecom/shopee/src/client.d.ts +51 -0
- package/lib/core/ecom/shopee/src/index.d.ts +37 -0
- package/lib/core/ecom/shopee/src/merchant.d.ts +214 -0
- package/lib/core/ecom/shopee/src/public.d.ts +204 -0
- package/lib/core/ecom/shopee/src/shop.d.ts +177 -0
- package/lib/core/ecom/shopee/src/types.d.ts +102 -0
- package/lib/core/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* 保留所有权利 All Rights Reserved.
|
|
6
6
|
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/fmode-chat.mjs
|
|
7
7
|
*/
|
|
8
|
-
import{finalize}from"rxjs";import{FmodeParse}from"../../../core/parse";const Parse=FmodeParse.with("nova");import{FmodeTTS,FmodeTTSProviderDoubao}from"../../voice/tts";import{PromptTemplate}from"@langchain/core/prompts";import{getFormatTpl}from"../prompt/prompt-util";import{FmodeChatCompletion}from"./completion";const PromptTplTalkSSMLOutputCode="talk-ssml-output-tpl",PromptTplTalkTextSSMLCode="talk-text-ssml-tpl";export function getMessageContentText(t){let e="";return"string"==typeof t&&(e=t),"object"==typeof t&&(e=t?.find((t=>t?.text))?.text||""),e}export function getMessageImageUrl(t){return"object"==typeof t?t?.find((t=>t?.image_url))?.image_url?.url||"":null}export class FmodeChat{async loadModelList(t){if(this.modelList?.length)return;let e=new Parse.Query("ChatModel");e.notEqualTo("isDeleted",!0),e.equalTo("isEnabled",!0),e.addAscending("index"),this.modelList=await e.find(),this.currentModel=t||this.modelList?.find((t=>"fmode-1.6-cn"==t.get("code")))}showAvatar(){this.avatarConfig=this.role?.get("avatarConfig"),this.avatarConfig&&(this.isAvatarShow=!0,this.avatarConfig?.image&&(this.avatarConfig.image.waiting=this.avatarConfig.image.waiting||this.role?.get("thumb")||this.role?.get("avatar"),this.avatarMode="image"),this.avatarConfig?.video&&(this.avatarConfig.video.waiting=this.avatarConfig.video.waiting,this.avatarMode="video"))}scrollToBottom(t){t=t||this.scrollComp,t?.nativeElement?.scrollHeight&&(t.nativeElement.scrollTop=t.nativeElement.scrollHeight)}constructor(t,e,i,s,o,a,n){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.latestAIResponse="",this.userInput="",this.userImage="",this.isDirect=!1,this.mode="page",this.hideShare=!1,this.hideModalSelect=!1,this.hideInputPreview=!1,this.isAvatarShow=!1,this.avatarMode="",this.isPromptModalOpen=!1,this.isPromptMessageAreaShow=!0,this.promptList=[],this.focusUserInput=()=>{},this.leftButtons=[{title:"灵感",icon:"color-wand-outline",onClick:()=>{this.isPromptModalOpen=!0},show:()=>this?.promptList?.length},{title:"角色",icon:"people-outline",onClick:()=>{this.navCtrl?.navigateRoot("/chat/pro/mask")},show:()=>!0},{title:"呼叫",icon:"call-outline",onClick:()=>{this.chatServ?.callRole(this.role)},show:()=>this?.role?.get("voiceConfig")}],this.isVoiceInputMode=!1,this.isTexting=!1,this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=t=>{console.log(t)},this.welcome=async()=>{let t=this.messageList?.filter((t=>"assistant"==t?.role));if(t?.length)return;let e=Parse.User.current(),i=await this.loadSelf("Person","userVerify"),s=await this.loadSelf("Profile","user"),o=i?.get("name")||i?.get("userVefiry")?.get("realname")||i?.get("userVefiry")?.get("nickname"),a=e?.get("nickname")||s?.get("name")||e?.get("realname")||e?.get("name");i?.get("userVerify")?.id==e?.id&&(o="您"),a||(a=o);let n=this.role.get("voiceConfig")?.welcome?.prompt;if(this.role.get("voiceConfig")?.welcome?.promptList?.length){let t=this.role.get("voiceConfig")?.welcome?.promptList;n=t[Math.floor(Math.random()*t.length)]}if(!n)return;let r=await PromptTemplate.fromTemplate(n,{templateFormat:"mustache"}).format({name:a,userName:a,personName:o,timeOfDay:this.getTimeOfDay()}),l=await this.getVoiceByContentText(r),h={role:"assistant",voice:l,content:r,complete:!0};this.voiceMap[l?.id],this.playChatVoice(this.voiceMap[l?.id]),this.messageList.push(h)},this.self={},this.voiceMap={},this.VoiceTTSMap={},this.chatServ=s,this.role=e,this.sessionId=t,this.navCtrl=o,this.ncloud=a,this.uploadServ=n,i?.id&&(this.chatSession=i,this.messageList=this.chatSession.get("messageList"),this.sessionId=i?.id),this.role?.id&&(this.voiceConfig=this.role?.get("voiceConfig"),this.voiceConfig?.autoTalk&&(this.isTalkMode=this.isTalkMode||this.voiceConfig?.autoTalk,this.isDirect=!0))}getTimeOfDay(){const t=(new Date).getHours();return t>=5&&t<12?"早上":t>=12&&t<14?"中午":t>=14&&t<18?"下午":"晚上"}async loadSelf(t,e){if(this.self[t])return this.self[t];let i=Parse.User.current(),s=new Parse.Query(t);return s.include(e),s.equalTo(e,i?.id),this.self[t]=await s.first(),this.self[t]}async loadTalkSystemPrompt(t){if(!this.isTalkMode)return;if(!t)return;let e=t?.get("voiceConfig");"男"==t?.get("gender")?(this.SSMLRoleVoice="zh-CN-YunyeNeural","doubao"==e.provider&&(this.SSMLRoleVoice="zh_male_yangguangqingnian_emo_v2_mars_bigtts")):(this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural","doubao"==e.provider&&(this.SSMLRoleVoice="zh_female_shuangkuaisisi_emo_v2_mars_bigtts")),this.SSMLRoleVoice=t?.get("voiceConfig")?.voice||this.SSMLRoleVoice;let i=await getFormatTpl("talk-ssml-output-tpl",{SSMLRoleVoice:this.SSMLRoleVoice}),s=t.get("prompt")||"请你扮演飞码AI的人工智能专家。";s+=i;let o={role:"user",content:s,hidden:!0},a=this.messageList?.map((t=>t?.content)).join();if(a.indexOf(s)>-1)return;let n=this.messageList?.findIndex((t=>"system"==t?.role)),r=n+1;this.messageList.splice(r,0,o)}loadRolePrompt(){let t=this.role?.get("prompt"),e={role:"user",content:t,hidden:!0};if(!t)return;let i=this.messageList?.map((t=>t?.content)).join();if(i.indexOf(t)>-1)return;let s=this.messageList?.findIndex((t=>"system"==t?.role)),o=s+1;this.messageList.splice(o,0,e)}async sendMessage(t="FmodeAiTest测试问题",e,i,s,o){if(this.scrollToBottom&&this.scrollToBottom(),this.isPromptMessageAreaShow=!1,this.loadRolePrompt(),e){let i={role:"user",content:[{type:"image_url",image_url:{url:e}},{type:"text",text:t}],complete:!0,createdAt:new Date};o&&(i.voice={id:o?.id}),this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:e}},{type:"text",text:t}],complete:!0,createdAt:new Date})}else{let e={role:"user",content:t,complete:!0,createdAt:new Date};o&&(e.voice={id:o?.id,duration:o?.duration}),this.messageList.push(e)}let a=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"});if(this.onUserSend){if(!await this.onUserSend(this,this.messageList[this.messageList?.length-1]))return}this.userInput="",this.userImage="";let n=this.isDirect||!1;this.isTalkMode&&(n=!0);let r=a.sendCompletion({isDirect:n,onComplete:i||null}).pipe(finalize((async()=>{if(this.isTalkMode){let t=this.messageList[a.indexOfList]?.content,e=await this.getVoiceByContentText(t,s);s?.onSSMLComplete&&s?.onSSMLComplete(e),this.messageList[a.indexOfList].voice=e,this.playChatVoice(this.voiceMap[e?.id],{onResult:t=>{t?.duration&&(this.messageList[a.indexOfList].voice.duration=t?.duration)}})}this.messageList[a.indexOfList].complete=!0}))).subscribe((t=>{this.messageList[a.indexOfList]||s?.onMessageStart?.(t),this.messageList[a.indexOfList]=t,this.latestAIResponse=this.getContentText(t?.content);let e=this.chatSession?.get("messageList")?.length;this.messageList?.length>e&&this.saveChatSession(),t?.complete&&(this.onMessage&&this.onMessage(this,this.messageList[this.messageList?.length-1]),this.saveChatSession(),r.unsubscribe()),this.scrollToBottom&&this.scrollToBottom()}))}getVoiceByContentText(t,e,i=!1){let s=this.getContentText(t),o=new(Parse.Object.extend("ChatVoice")),a="",n=this.voiceConfig||this.role?.get("voiceConfig");return this.SSMLRoleVoice=n?.voice||this.SSMLRoleVoice,new Promise((async(t,e)=>{let resolveChatVoice=async()=>{o.set("content",s),o.set("ssml",a),o.set("role","assistant");let e=localStorage.getItem("company");e&&o.set("company",{__type:"Pointer",className:"Company",objectId:e}),Parse.User.current()?.id&&o.set("user",Parse.User.current().toPointer()),this.chatSession?.id&&o.set("session",this.chatSession?.toPointer()),o=await o.save(),this.voiceMap[o?.id]=o,t({id:o?.id})};if(0==i){let t=n?.provider||"microsoft",e=n?.rate,i=e?"</prosody>":"";a=`<speak provider="${t}">${e?`<prosody rate="${e}">`:""}<voice name="${this.SSMLRoleVoice}">${s}</voice>${i}</speak>`,"doubao"==t&&(a=s),resolveChatVoice()}if(1==i){let t=await getFormatTpl("talk-text-ssml-tpl",{content:s,SSMLRoleVoice:this.SSMLRoleVoice});new FmodeChatCompletion(this.fixMessageList([{role:"user",content:t}]),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"}).sendCompletion({isDirect:!0}).subscribe((async t=>{t?.complete&&(a=this.getContentText(t?.content),resolveChatVoice())}))}}))}getContentText(t){return"string"==typeof t?t:t?.[0]?.text||""}async initTTS(){this.voiceConfig=this.voiceConfig||this.role?.get("voiceConfig");let t=await this.ncloud.apig("voice/tts/token",{company:localStorage.getItem("company"),provider:this.voiceConfig?.provider||"microsoft"});if(t.provider=this.voiceConfig?.provider,!t?.provider||t?.provider,"doubao"==t?.provider&&(t.provider=new FmodeTTSProviderDoubao),t.voiceConfig=this.voiceConfig,console.log("initTTS",t),t?.token||t?.stsToken){return new FmodeTTS(t,this.uploadServ)}return null}stopPlayingVoice(){Object.values(this.VoiceTTSMap).forEach((t=>{t?.isPlaying&&t?.stop()}))}async playChatVoice(t,e){let i=await this.initTTS();if(console.log("playChatVoice",i),i){try{i.voiceConfig=this.voiceConfig,this.playAnimation("talking"),i.speakAsync(t?.get("ssml"),t,{onStart:t=>{e?.onStart&&e?.onStart(t)},onLoaded:t=>{e?.onLoaded&&e?.onLoaded(t)},onResult:t=>{e?.onResult&&e?.onResult(t)},onStop:()=>{e?.onStop&&e?.onStop(),this.playAnimation("waiting")}})}catch(t){}return this.VoiceTTSMap[t.id]=i,i}return null}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession=await this.chatSession.save(),this.onChatSaved&&this.onChatSaved(this),this.sessionId=this.chatSession?.id,this.sessionId){let t=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;window.location?.pathname?.indexOf("chat/session")>-1&&(t=`${window.location.origin}/chat/session/chat/${this.sessionId}`),"modal"==this.mode&&(t=window.location.href),t=this.getInviteUrl(t),window.history.replaceState(null,null,t+window.location.search);let e={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:this.chatSession?.get("messageList")?.[this.chatSession?.get("messageList")?.length-1]?.content?.slice(0,20),latest:this.chatSession?.createdAt};this.chatServ&&!this.chatServ?.chatList?.length&&(this.chatServ.chatList=[]);let i=this.chatServ?.chatList?.find((t=>t?.sid==e?.sid));i>-1?this.chatServ.chatList[i]=e:this.chatServ?.chatList.unshift(e)}}getInviteUrl(t){let e=new URL(t),i=Parse.User?.current()?.id;return e.searchParams.set("invite",i),e.href}genTitle(){if(this.title)return this.title;let t=this.messageList.find((t=>"user"==t.role))?.content;return"string"==typeof t&&(this.title=t?.slice(0,15)||""),"object"==typeof t&&(this.title=t?.find((t=>t?.text))?.text||""),this.title}fixMessageList(t){return t.map((t=>({role:t.role,content:t.content})))}nowStr(){let t=new Date;return`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()} ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}}
|
|
8
|
+
import{finalize}from"rxjs";import{FmodeParse}from"../../../core/parse";const Parse=FmodeParse.with("nova");import{FmodeTTS,FmodeTTSProviderDoubao}from"../../voice/tts";import{PromptTemplate}from"@langchain/core/prompts";import{getFormatTpl}from"../prompt/prompt-util";import{FmodeChatCompletion}from"./completion";import{MessageScene,MessageManager}from"./message";const PromptTplTalkSSMLOutputCode="talk-ssml-output-tpl",PromptTplTalkTextSSMLCode="talk-text-ssml-tpl";export function getMessageContentText(e){let t="";return"string"==typeof e&&(t=e),"object"==typeof e&&(t=e?.find((e=>e?.text))?.text||""),t}export function getMessageImageUrl(e){return"object"==typeof e?e?.find((e=>e?.image_url))?.image_url?.url||"":null}export class FmodeChat{async loadModelList(e){if(this.modelList?.length)return;let t=new Parse.Query("ChatModel");t.notEqualTo("isDeleted",!0),t.equalTo("isEnabled",!0),t.addAscending("index"),this.modelList=await t.find(),this.currentModel=e||this.modelList?.find((e=>"fmode-1.6-cn"==e.get("code")))}showAvatar(){this.avatarConfig=this.role?.get("avatarConfig"),this.avatarConfig&&(this.isAvatarShow=!0,this.avatarConfig?.image&&(this.avatarConfig.image.waiting=this.avatarConfig.image.waiting||this.role?.get("thumb")||this.role?.get("avatar"),this.avatarMode="image"),this.avatarConfig?.video&&(this.avatarConfig.video.waiting=this.avatarConfig.video.waiting,this.avatarMode="video"))}scrollToBottom(e){e=e||this.scrollComp,e?.nativeElement?.scrollHeight&&(e.nativeElement.scrollTop=e.nativeElement.scrollHeight)}constructor(e,t,s,i,o,a,n){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageManager=null,this.latestAIResponse="",this.userInput="",this.userImage="",this.isDirect=!1,this.mode="page",this.hideShare=!1,this.hideModalSelect=!1,this.hideInputPreview=!1,this.isAvatarShow=!1,this.avatarMode="",this.isPromptModalOpen=!1,this.isPromptMessageAreaShow=!0,this.promptList=[],this.focusUserInput=()=>{},this.leftButtons=[{title:"灵感",icon:"color-wand-outline",onClick:()=>{this.isPromptModalOpen=!0},show:()=>this?.promptList?.length},{title:"角色",icon:"people-outline",onClick:()=>{this.navCtrl?.navigateRoot("/chat/pro/mask")},show:()=>!0},{title:"呼叫",icon:"call-outline",onClick:()=>{this.chatServ?.callRole(this.role)},show:()=>this?.role?.get("voiceConfig")}],this.isVoiceInputMode=!1,this.isTexting=!1,this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=e=>{console.log(e)},this.welcome=async()=>{const e=await this.getMessageList();let t=e?.filter((e=>"assistant"==e?.role));if(t?.length)return;let s=Parse.User.current(),i=await this.loadSelf("Person","userVerify"),o=await this.loadSelf("Profile","user"),a=i?.get("name")||i?.get("userVefiry")?.get("realname")||i?.get("userVefiry")?.get("nickname"),n=s?.get("nickname")||o?.get("name")||s?.get("realname")||s?.get("name");i?.get("userVerify")?.id==s?.id&&(a="您"),n||(n=a);let r=this.role.get("voiceConfig")?.welcome?.prompt;if(this.role.get("voiceConfig")?.welcome?.promptList?.length){let e=this.role.get("voiceConfig")?.welcome?.promptList;r=e[Math.floor(Math.random()*e.length)]}if(!r)return;let l=await PromptTemplate.fromTemplate(r,{templateFormat:"mustache"}).format({name:n,userName:n,personName:a,timeOfDay:this.getTimeOfDay()}),h=await this.getVoiceByContentText(l),c={role:"assistant",voice:h,content:l,complete:!0,createdAt:new Date};await this.addMessage(c,MessageScene.ROLE),this.voiceMap[h?.id],this.playChatVoice(this.voiceMap[h?.id])},this.self={},this.voiceMap={},this.VoiceTTSMap={},this.chatServ=i,this.role=t,this.sessionId=e,this.navCtrl=o,this.ncloud=a,this.uploadServ=n,this.initCompany(),s?.id&&(this.chatSession=s,this.sessionId=s?.id,this.initMessageManager()),this.role?.id&&(this.voiceConfig=this.role?.get("voiceConfig"),this.voiceConfig?.autoTalk&&(this.isTalkMode=this.isTalkMode||this.voiceConfig?.autoTalk,this.isDirect=!0))}async getMessageList(){return this.messageManager?await this.messageManager.getMessages():[{role:"system",content:"系统提示:AI仅供参考"}]}get messageList(){return this.messageManager?[]:[{role:"system",content:"系统提示:AI仅供参考"}]}set messageList(e){this.messageManager&&this.messageManager.clearCache()}initMessageManager(){this.chatSession&&this.role&&this.company&&(this.messageManager=MessageManager.createForRole(this.chatSession,this.role,this.company))}async initCompany(){const e=localStorage.getItem("company");e&&(this.company={__type:"Pointer",className:"Company",objectId:e})}async addMessage(e,t=MessageScene.ROLE){this.messageManager&&await this.messageManager.addMessage(e,t)}async updateMessage(e,t){this.messageManager&&await this.messageManager.updateMessage(e,t)}async reloadMessages(){this.messageManager&&await this.messageManager.reloadMessages()}getTimeOfDay(){const e=(new Date).getHours();return e>=5&&e<12?"早上":e>=12&&e<14?"中午":e>=14&&e<18?"下午":"晚上"}async loadSelf(e,t){if(this.self[e])return this.self[e];let s=Parse.User.current(),i=new Parse.Query(e);return i.include(t),i.equalTo(t,s?.id),this.self[e]=await i.first(),this.self[e]}async loadTalkSystemPrompt(e){if(!this.isTalkMode)return;if(!e)return;let t=e?.get("voiceConfig");"男"==e?.get("gender")?(this.SSMLRoleVoice="zh-CN-YunyeNeural","doubao"==t.provider&&(this.SSMLRoleVoice="zh_male_yangguangqingnian_emo_v2_mars_bigtts")):(this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural","doubao"==t.provider&&(this.SSMLRoleVoice="zh_female_shuangkuaisisi_emo_v2_mars_bigtts")),this.SSMLRoleVoice=e?.get("voiceConfig")?.voice||this.SSMLRoleVoice;let s=await getFormatTpl("talk-ssml-output-tpl",{SSMLRoleVoice:this.SSMLRoleVoice}),i=e.get("prompt")||"请你扮演飞码AI的人工智能专家。";i+=s;let o={role:"user",content:i,hidden:!0},a=this.messageList?.map((e=>e?.content)).join();if(a.indexOf(i)>-1)return;let n=this.messageList?.findIndex((e=>"system"==e?.role)),r=n+1;this.messageList.splice(r,0,o)}loadRolePrompt(){let e=this.role?.get("prompt"),t={role:"user",content:e,hidden:!0};if(!e)return;let s=this.messageList?.map((e=>e?.content)).join();if(s.indexOf(e)>-1)return;let i=this.messageList?.findIndex((e=>"system"==e?.role)),o=i+1;this.messageList.splice(o,0,t)}async sendMessage(e="FmodeAiTest测试问题",t,s,i,o){let a;this.scrollToBottom&&this.scrollToBottom(),this.isPromptMessageAreaShow=!1,this.loadRolePrompt(),t?(a={role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date},o&&(a.voice={id:o?.id})):(a={role:"user",content:e,complete:!0,createdAt:new Date},o&&(a.voice={id:o?.id,duration:o?.duration})),await this.addMessage(a,MessageScene.ROLE);const n=await this.getMessageList();let r=new FmodeChatCompletion(this.fixMessageList(n),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"});if(this.onUserSend){if(!await this.onUserSend(this,a))return}this.userInput="",this.userImage="";let l=this.isDirect||!1;this.isTalkMode&&(l=!0);const h={role:"assistant",content:"",complete:!1,createdAt:new Date};await this.addMessage(h,MessageScene.ROLE);const c=await this.getMessageList(),g=c.length-1;let m=r.sendCompletion({isDirect:l,onComplete:s||null}).pipe(finalize((async()=>{let e=c[g];if(this.isTalkMode){let t=e?.content,s=await this.getVoiceByContentText(t,i);i?.onSSMLComplete&&i?.onSSMLComplete(s),e.voice=s,this.playChatVoice(this.voiceMap[s?.id],{onResult:t=>{t?.duration&&(e.voice.duration=t?.duration)}})}e.complete=!0,await this.updateMessage(g,e)}))).subscribe((async e=>{await this.updateMessage(g,e),this.latestAIResponse=this.getContentText(e?.content);let t=this.chatSession?.get("messageList")?.length;const s=await this.getMessageList();if(s?.length>t&&this.saveChatSession(),e?.complete){const e=await this.getMessageList();this.onMessage&&this.onMessage(this,e[e?.length-1]),this.saveChatSession(),m.unsubscribe()}this.scrollToBottom&&this.scrollToBottom()}))}getVoiceByContentText(e,t,s=!1){let i=this.getContentText(e),o=new(Parse.Object.extend("ChatVoice")),a="",n=this.voiceConfig||this.role?.get("voiceConfig");return this.SSMLRoleVoice=n?.voice||this.SSMLRoleVoice,new Promise((async(e,t)=>{let resolveChatVoice=async()=>{o.set("content",i),o.set("ssml",a),o.set("role","assistant");let t=localStorage.getItem("company");t&&o.set("company",{__type:"Pointer",className:"Company",objectId:t}),Parse.User.current()?.id&&o.set("user",Parse.User.current().toPointer()),this.chatSession?.id&&o.set("session",this.chatSession?.toPointer()),o=await o.save(),this.voiceMap[o?.id]=o,e({id:o?.id})};if(0==s){let e=n?.provider||"microsoft",t=n?.rate,s=t?"</prosody>":"";a=`<speak provider="${e}">${t?`<prosody rate="${t}">`:""}<voice name="${this.SSMLRoleVoice}">${i}</voice>${s}</speak>`,"doubao"==e&&(a=i),resolveChatVoice()}if(1==s){let e=await getFormatTpl("talk-text-ssml-tpl",{content:i,SSMLRoleVoice:this.SSMLRoleVoice});new FmodeChatCompletion(this.fixMessageList([{role:"user",content:e}]),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"}).sendCompletion({isDirect:!0}).subscribe((async e=>{e?.complete&&(a=this.getContentText(e?.content),resolveChatVoice())}))}}))}getContentText(e){return"string"==typeof e?e:e?.[0]?.text||""}async initTTS(){this.voiceConfig=this.voiceConfig||this.role?.get("voiceConfig");let e=await this.ncloud.apig("voice/tts/token",{company:localStorage.getItem("company"),provider:this.voiceConfig?.provider||"microsoft"});if(e.provider=this.voiceConfig?.provider,!e?.provider||e?.provider,"doubao"==e?.provider&&(e.provider=new FmodeTTSProviderDoubao),e.voiceConfig=this.voiceConfig,console.log("initTTS",e),e?.token||e?.stsToken){return new FmodeTTS(e,this.uploadServ)}return null}stopPlayingVoice(){Object.values(this.VoiceTTSMap).forEach((e=>{e?.isPlaying&&e?.stop()}))}async playChatVoice(e,t){let s=await this.initTTS();if(console.log("playChatVoice",s),s){try{s.voiceConfig=this.voiceConfig,this.playAnimation("talking"),s.speakAsync(e?.get("ssml"),e,{onStart:e=>{t?.onStart&&t?.onStart(e)},onLoaded:e=>{t?.onLoaded&&t?.onLoaded(e)},onResult:e=>{t?.onResult&&t?.onResult(e)},onStop:()=>{t?.onStop&&t?.onStop(),this.playAnimation("waiting")}})}catch(e){}return this.VoiceTTSMap[e.id]=s,s}return null}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession.get("messageList")||this.chatSession.set("messageList",[]),this.chatSession=await this.chatSession.save(),this.onChatSaved&&this.onChatSaved(this),this.sessionId=this.chatSession?.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;window.location?.pathname?.indexOf("chat/session")>-1&&(e=`${window.location.origin}/chat/session/chat/${this.sessionId}`),"modal"==this.mode&&(e=window.location.href),e=this.getInviteUrl(e),window.history.replaceState(null,null,e+window.location.search);const t=await this.getMessageList(),s=t[t?.length-1];let i="";if("string"==typeof s?.content)i=s.content.slice(0,20);else if(Array.isArray(s?.content)){const e=s.content.find((e=>e?.text));i=e?.text?.slice(0,20)||""}let o={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:i,latest:this.chatSession?.createdAt};this.chatServ&&!this.chatServ?.chatList?.length&&(this.chatServ.chatList=[]);let a=this.chatServ?.chatList?.find((e=>e?.sid==o?.sid));a>-1?this.chatServ.chatList[a]=o:this.chatServ?.chatList.unshift(o)}}getInviteUrl(e){let t=new URL(e),s=Parse.User?.current()?.id;return t.searchParams.set("invite",s),t.href}genTitle(){if(this.title)return this.title;let e=this.messageList.find((e=>"user"==e.role))?.content;return"string"==typeof e&&(this.title=e?.slice(0,15)||""),"object"==typeof e&&(this.title=e?.find((e=>e?.text))?.text||""),this.title}fixMessageList(e){return e.map((e=>({role:e.role,content:e.content})))}nowStr(){let e=new Date;return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`}}
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvZm1vZGUtY2hhdC5tanM=`
|
|
10
10
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/index.mjs
|
|
7
|
+
*/
|
|
8
|
+
export*from"./message";export*from"./message-manager";
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9pbmRleC5tanM=`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/message-manager.mjs
|
|
7
|
+
*/
|
|
8
|
+
import{FmodeParse}from"../../../../core/parse";import{Message,MessageScene,MessageRole}from"./message";const Parse=FmodeParse.with("nova");export class MessageManager{constructor(e){this._newMessages=[],this._legacyMessages=[],this._mergedMessages=[],this._isDirty=!0,this.options=e}async getMessages(){return this._isDirty&&(await this.loadAndMergeMessages(),this._isDirty=!1),[...this._mergedMessages]}async addMessage(e,s){const t=s||this.options.scene||MessageScene.ROLE;try{const s={content:{type:Message.getMessageType(e),role:e.role||MessageRole.USER,content:e.content,json:e.json,hidden:e.hidden,complete:e.complete,voice:e.voice,cid:e.cid,createdAt:e.createdAt||new Date},scene:t,company:this.options.company,session:t===MessageScene.ROLE?this.options.chatSession:void 0,role:t===MessageScene.ROLE?this.options.role:void 0,group:t===MessageScene.GROUP?this.options.group:void 0,userFrom:t===MessageScene.USER?this.options.userFrom:void 0,userTo:t===MessageScene.USER?this.options.userTo:void 0,contact:t===MessageScene.SERVICE?this.options.contact:void 0},a=Message.create(s);await a.save(),this._newMessages.push(a),this._isDirty=!0}catch(s){console.error("保存新消息失败:",s),this._legacyMessages.push({...e,source:"legacy"}),this._isDirty=!0}}async updateMessage(e,s){const t=await this.getMessages();if(e<0||e>=t.length)return;const a=t[e];if("new"===a.source&&a.id){const e=this._newMessages.findIndex((e=>e.id===a.id));if(e>=0){const t={type:Message.getMessageType(s),role:s.role||MessageRole.USER,content:s.content,json:s.json,hidden:s.hidden,complete:s.complete,voice:s.voice,cid:s.cid,createdAt:s.createdAt||new Date};this._newMessages[e].updateContent(t),await this._newMessages[e].save()}}this._isDirty=!0}async reloadMessages(){this._newMessages=[],this._legacyMessages=[],this._isDirty=!0,await this.getMessages()}async loadAndMergeMessages(){this._legacyMessages=this.options.chatSession?.get("messageList")||[];try{switch(this.options.scene){case MessageScene.ROLE:this.options.chatSession&&(this._newMessages=await Message.findRoleMessages(this.options.chatSession,{ascending:!0}));break;case MessageScene.GROUP:this.options.group&&(this._newMessages=await Message.findGroupMessages(this.options.group,{ascending:!0}));break;case MessageScene.USER:this.options.userFrom&&this.options.userTo&&(this._newMessages=await Message.findUserMessages(this.options.userFrom,this.options.userTo,{ascending:!0}));break;case MessageScene.SERVICE:this.options.contact&&(this._newMessages=await Message.findServiceMessages(this.options.contact,{ascending:!0}));break;default:this._newMessages=[]}}catch(e){console.error("加载新版消息失败:",e),this._newMessages=[]}if(this._mergedMessages=[],this._legacyMessages.length>0&&this._mergedMessages.push(...this._legacyMessages.map((e=>({...e,source:"legacy"})))),this._newMessages.length>0){const e=this._newMessages.map((e=>({...e.toFmodeChatMessage(),source:"new",id:e.id})));this._mergedMessages.push(...e)}}getStats(){const e={total:this._mergedMessages.length,legacy:this._legacyMessages.length,new:this._newMessages.length,user:0,assistant:0};return this._mergedMessages.forEach((s=>{"user"===s.role&&e.user++,"assistant"===s.role&&e.assistant++})),e}async searchMessages(e){if(!e.trim())return await this.getMessages();const s=await this.getMessages(),t=e.toLowerCase();return s.filter((e=>{let s="";return"string"==typeof e.content?s=e.content:Array.isArray(e.content)&&(s=e.content.filter((e=>e?.text)).map((e=>e.text)).join(" ")),s.toLowerCase().includes(t)}))}clearCache(){this._newMessages=[],this._legacyMessages=[],this._mergedMessages=[],this._isDirty=!0}static createForRole(e,s,t){return new MessageManager({chatSession:e,role:s,company:t,scene:MessageScene.ROLE})}static createForGroup(e,s){return new MessageManager({group:e,company:s,scene:MessageScene.GROUP})}static createForUser(e,s,t){return new MessageManager({userFrom:e,userTo:s,company:t,scene:MessageScene.USER})}static createForService(e,s){return new MessageManager({contact:e,company:s,scene:MessageScene.SERVICE})}static create(e){return new MessageManager(e)}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9tZXNzYWdlLW1hbmFnZXIubWpz`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/message.mjs
|
|
7
|
+
*/
|
|
8
|
+
import{FmodeQuery,FmodeParse}from"../../../../core/parse";const Parse=FmodeParse.with("nova");export var MessageScene;!function(e){e.ROLE="role",e.USER="user",e.GROUP="group",e.SERVICE="service"}(MessageScene||(MessageScene={}));export var MessageType;!function(e){e.TEXT="text",e.IMAGE="image",e.VOICE="voice",e.AGENT_TASK="agent_task",e.SYSTEM="system",e.EXTERNAL="external"}(MessageType||(MessageType={}));export var MessageRole;!function(e){e.USER="user",e.ASSISTANT="assistant",e.SYSTEM="system",e.AGENT="agent",e.EXTERNAL="external"}(MessageRole||(MessageRole={}));export var MessageStatus;!function(e){e.SENDING="sending",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed"}(MessageStatus||(MessageStatus={}));export class Message{constructor(e){this.parseObject=e||new Parse.Object("Message")}static create(e){const s=new Message;return s.parseObject.set("company",e.company),s.parseObject.set("content",e.content),s.parseObject.set("scene",e.scene),s.parseObject.set("session",e.session),s.parseObject.set("group",e.group),s.parseObject.set("userFrom",e.userFrom),s.parseObject.set("userTo",e.userTo),s.parseObject.set("role",e.role),s.parseObject.set("external",e.external),s.parseObject.set("contact",e.contact),s.parseObject.set("attachments",e.attachments||[]),s.parseObject.set("metadata",e.metadata||{}),s.parseObject.set("status",MessageStatus.SENT),s.parseObject.set("hidden",e.content.hidden||!1),s.parseObject.set("sentAt",new Date),s}async save(e){return await this.parseObject.save(e),this}updateContent(e){return this.parseObject.set("content",e),this}updateStatus(e){return this.parseObject.set("status",e),e===MessageStatus.READ&&this.parseObject.set("readAt",new Date),this}get id(){return this.parseObject.id}get(e){return this.parseObject.get(e)}set(e,s){return this.parseObject.set(e,s),this}toFmodeChatMessage(){const e=this.parseObject.get("content");return{role:e?.role||MessageRole.USER,content:e?.content||"",json:e?.json,hidden:e?.hidden,complete:!1!==e?.complete,createdAt:this.parseObject.get("sentAt")||this.parseObject.createdAt,voice:e?.voice,cid:e?.cid}}getParseObject(){return this.parseObject}static fromParseObject(e){return new Message(e)}static query(){return new FmodeQuery("Message")}static queryByScene(e){const s=Message.query();return s.equalTo("scene",e),s}static async findRoleMessages(e,s={}){const t=Message.queryByScene(MessageScene.ROLE);t.equalTo("session",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findGroupMessages(e,s={}){const t=Message.queryByScene(MessageScene.GROUP);t.equalTo("group",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findUserMessages(e,s,t={}){const a=Message.queryByScene(MessageScene.USER);a.containedIn("userFrom",[e,s]),a.containedIn("userTo",[e,s]),t.limit&&a.limit(t.limit),t.skip&&a.skip(t.skip),!1!==t.ascending?a.ascending("sentAt"):a.descending("sentAt");return(await a.find()).map((e=>Message.fromParseObject(e)))}static async findServiceMessages(e,s={}){const t=Message.queryByScene(MessageScene.SERVICE);t.equalTo("contact",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findByExternalId(e,s){const t=Message.query();t.equalTo("external.source",e),t.equalTo("external.id",s);const a=await t.first();return a?Message.fromParseObject(a):null}static getMessageType(e){if(e.voice)return MessageType.VOICE;if(e.json)return MessageType.AGENT_TASK;if(e.hidden)return MessageType.SYSTEM;if(Array.isArray(e.content)){return e.content.some((e=>e?.image_url))?MessageType.IMAGE:MessageType.TEXT}return MessageType.TEXT}static fromFmodeChatMessage(e,s){const t={type:Message.getMessageType(e),role:e.role||MessageRole.USER,content:e.content,json:e.json,hidden:e.hidden,complete:e.complete,voice:e.voice,cid:e.cid,createdAt:e.createdAt};return Message.create({...s,content:t})}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9tZXNzYWdlLm1qcw==`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/index.mjs
|
|
7
|
+
*/
|
|
8
|
+
export*from"./shopee/index";
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vaW5kZXgubWpz`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/index.mjs
|
|
7
|
+
*/
|
|
8
|
+
export*from"./src/index";
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL2luZGV4Lm1qcw==`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/client.mjs
|
|
7
|
+
*/
|
|
8
|
+
export class ShopeeClient{constructor(e){if(this.environment="sandbox",!e.serverUrl)throw new Error("serverUrl is required in SDK configuration");this.serverUrl=e.serverUrl.replace(/\/$/,""),this.timeout=e.timeout||3e4,this.headers={"Content-Type":"application/json","User-Agent":"ShopeeSDK/1.0",...e.headers}}async request(e,r){const t=`${this.serverUrl}/api/ecom/shopee/forward`;console.log(e,t,this.serverUrl);const s={shop_id:e.toString(),method:r.method,path:r.path,query:r.query||{},...r.body&&{body:r.body},environment:this.environment},o=new AbortController,i=setTimeout((()=>o.abort()),this.timeout);try{const r=await fetch(t,{method:"POST",headers:this.headers,body:JSON.stringify(s),signal:o.signal});if(clearTimeout(i),!r.ok){const e=await r.text();throw new Error(`HTTP ${r.status}: ${e}`)}const n=await r.json();if(!n.success&&"AUTH_REQUIRED"===n.error){throw new Error(`Authorization required for shop ${e}. Please visit: ${n.data.auth_url}`)}if(!n.success&&"AUTH_EXPIRED"===n.error){throw new Error(`Authorization expired for shop ${e}. Please visit: ${n.data.auth_url}`)}if(!n.success){const e=n;throw new Error(`API request failed: ${e.message} (Status: ${e.data.status_code})`)}return n}catch(e){if(clearTimeout(i),e instanceof Error){if("AbortError"===e.name)throw new Error(`Request timeout after ${this.timeout}ms`);throw e}throw new Error("Unknown error occurred during API request")}}async get(e,r,t){return this.request(e,{method:"GET",path:r,query:t})}async post(e,r,t,s){return this.request(e,{method:"POST",path:r,body:t,query:s})}async put(e,r,t,s){return this.request(e,{method:"PUT",path:r,body:t,query:s})}async delete(e,r,t){return this.request(e,{method:"DELETE",path:r,query:t})}getServerUrl(){return this.serverUrl}getTimeout(){return this.timeout}setHeaders(e){this.headers={...this.headers,...e}}getHeaders(){return{...this.headers}}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9jbGllbnQubWpz`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/index.mjs
|
|
7
|
+
*/
|
|
8
|
+
import{ShopeeClient}from"./client";import{ShopeeShop}from"./shop";import{ShopeeMerchant}from"./merchant";import{ShopeePublic}from"./public";export{ShopeeClient};export{ShopeeShop};export{ShopeeMerchant};export{ShopeePublic};export class ShopeeSDK{constructor(e){this.client=new ShopeeClient(e),this.public=new ShopeePublic(this.client)}shop(e,t="sandbox"){return this.client.environment=t,new ShopeeShop(this.client,e)}merchant(e){return new ShopeeMerchant(this.client,e)}getClient(){return this.client}updateConfig(e){e.serverUrl?(this.client=new ShopeeClient({...e,serverUrl:e.serverUrl}),this.public=new ShopeePublic(this.client)):(e.headers&&this.client.setHeaders(e.headers),e.timeout&&console.log("Timeout update would require client reinitialization"))}}export default ShopeeSDK;
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9pbmRleC5tanM=`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/merchant.mjs
|
|
7
|
+
*/
|
|
8
|
+
export class ShopeeMerchant{constructor(t,i){if(!i||i<=0)throw new Error("Valid main_account_id is required");this.client=t,this.mainAccountId=i}async getMerchantInfo(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_merchant_info")}async getShopList(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_shop_list")}async getProfile(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_profile")}async updateProfile(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/update_profile",t)}async getFinancialInfo(){return this.client.get(this.mainAccountId,"/api/v2/financial/get_financial_info")}async getWalletBalance(){return this.client.get(this.mainAccountId,"/api/v2/financial/get_wallet_balance")}async getTransactionHistory(t={}){return this.client.get(this.mainAccountId,"/api/v2/financial/get_transaction_history",t)}async createWithdrawal(t){return this.client.post(this.mainAccountId,"/api/v2/financial/create_withdrawal",t)}async getWithdrawalHistory(t={}){return this.client.get(this.mainAccountId,"/api/v2/financial/get_withdrawal_history",t)}async getStatistics(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_statistics",t)}async getNotifications(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_notifications",t)}async markNotificationAsRead(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/mark_notification_read",{notification_id:t})}async getSettings(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_settings")}async updateSettings(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/update_settings",t)}async getPermissions(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_permissions")}async getAuditLogs(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_audit_logs",t)}getMainAccountId(){return this.mainAccountId}getClient(){return this.client}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9tZXJjaGFudC5tanM=`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/public.mjs
|
|
7
|
+
*/
|
|
8
|
+
export class ShopeePublic{constructor(e){this.client=e}async generateAuthUrl(e){let t=new Headers;t.append("Content-Type","application/json");let i=await fetch(this.client.getServerUrl()+"/api/ecom/shopee/auth-url",{headers:t,method:"POST",body:JSON.stringify({redirect_uri:e})});return await i.json()}async generateCancelAuthUrl(e){return this.client.post(0,"/api/ecom/shopee/cancel-auth-url",{redirect_uri:e})}async getConfig(){return this.client.get(0,"/api/ecom/shopee/config")}async healthCheck(){return this.client.get(0,"/api/ecom/shopee/health")}async verifySignature(e,t,i){return this.client.post(0,"/api/ecom/shopee/verify-signature",{path:e,params:t,timestamp:i})}async getPublicCategories(e){return this.client.get(0,"/api/v2/public/category/get_category",{region:e})}async getPublicItemDetail(e,t,i){return this.client.get(0,"/api/v2/public/item/get_item_detail",{item_id:e,shop_id:t,region:i})}async searchPublicItems(e){return this.client.get(0,"/api/v2/public/item/search",e)}async getPublicShopInfo(e,t){return this.client.get(0,"/api/v2/public/shop/get_shop_info",{shop_id:e,region:t})}async getPublicShopItems(e,t,i={}){return this.client.get(0,"/api/v2/public/shop/get_items",{shop_id:e,region:t,...i})}async getPublicLogistics(e){return this.client.get(0,"/api/v2/public/logistics/get_channels",{region:e})}async getExchangeRates(e,t){const i={};return e&&(i.from_currency=e),t&&(i.to_currency=t),this.client.get(0,"/api/v2/public/currency/get_exchange_rate",i)}async getMarketplaceStats(e){return this.client.get(0,"/api/v2/public/marketplace/get_statistics",{region:e})}async getTrendingItems(e,t){const i={region:e};return t&&(i.category_id=t),this.client.get(0,"/api/v2/public/trending/get_items",i)}async validateWebhook(e,t){return this.client.post(0,"/api/v2/public/webhook/validate",{payload:e,signature:t})}getClient(){return this.client}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9wdWJsaWMubWpz`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/shop.mjs
|
|
7
|
+
*/
|
|
8
|
+
export class ShopeeShop{constructor(t,i){if(!i||i<=0)throw new Error("Valid shop_id is required");this.client=t,this.shopId=i}async getShopInfo(){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}async getCategories(){return this.client.get(this.shopId,"/api/v2/product/get_category",{shop_id:this.shopId})}async getComments(t){return this.client.get(this.shopId,"/api/v2/product/get_comment",{shop_id:this.shopId,...t})}async getProductList(t={}){return t.offset=t?.offset||0,t.page_size=t?.page_size||10,t.item_status=t?.item_status||"NORMAL",this.client.get(this.shopId,"/api/v2/product/get_item_list",{shop_id:this.shopId,...t})}async getProductDetail(t){return this.client.get(this.shopId,"/api/v2/product/get_item_detail",{item_id:t})}async addProduct(t){return this.client.post(this.shopId,"/api/v2/product/add_item",t)}async updateProduct(t,i){return this.client.post(this.shopId,"/api/v2/product/update_item",{item_id:t,...i})}async deleteProduct(t){return this.client.post(this.shopId,"/api/v2/product/delete_item",{item_id:t})}async unlistProduct(t){return this.client.post(this.shopId,"/api/v2/product/unlist_item",{item_id:t})}async getOrderList(t={}){const i=Date.now(),s=i-2592e6,e={shop_id:this.shopId,time_from:Math.floor(s/1e3),time_to:Math.floor(i/1e3),time_range_field:"create_time",...t};return this.client.get(this.shopId,"/api/v2/order/get_order_list",e)}async getOrderDetail(t){return this.client.get(this.shopId,"/api/v2/order/get_order_detail",{order_sn:t})}async getPerformanceMetrics(){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}async getLogistics(){return this.client.get(this.shopId,"/api/v2/logistics/get_channel_list",{shop_id:this.shopId})}async getDiscounts(){return this.client.get(this.shopId,"/api/v2/discount/get_discount_list",{shop_id:this.shopId})}async getAnalytics(t={}){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}getShopId(){return this.shopId}getClient(){return this.client}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9zaG9wLm1qcw==`
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @copyright © 未来飞马 © 未来全栈 www.fmode.cn
|
|
4
|
+
* 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
|
|
5
|
+
* 保留所有权利 All Rights Reserved.
|
|
6
|
+
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/types.mjs
|
|
7
|
+
*/
|
|
8
|
+
export{};
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy90eXBlcy5tanM=`
|
|
10
|
+
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* 保留所有权利 All Rights Reserved.
|
|
6
6
|
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/index.mjs
|
|
7
7
|
*/
|
|
8
|
-
export*from"./agent";export*from"./voice";export*from"./parse";export*from"./social";export*from"./storage";export*from"./storage/util-file-md5";export*from"./storage/util-file-metadata";
|
|
8
|
+
export*from"./agent";export*from"./voice";export*from"./parse";export*from"./social";export*from"./storage";export*from"./storage/util-file-md5";export*from"./storage/util-file-metadata";export*from"./ecom";
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2luZGV4Lm1qcw==`
|
|
10
10
|
|