2 lines
2.9 KiB
JavaScript
2 lines
2.9 KiB
JavaScript
import{aQ as a}from"./index-C6ULY2Si.js";const r="/sl/projection/reflection";function l(){return{fields:[],status:[],methods:[]}}function f(){return{car:l(),site:l(),track:l()}}const $=f;async function s(e){const{data:t}=await a.get(`${r}${e}`);if(!t?.success)throw new Error(t?.message??`reflection ${e} failed`);return t.data}async function n(e,t){const{data:o}=await a.post(`${r}${e}`,null,{params:t});if(!o?.success)throw new Error(o?.message??`reflection ${e} failed`);return o.data}async function d(e){const{data:t}=await a.delete(`${r}${e}`);if(!t?.success)throw new Error(t?.message??`reflection ${e} failed`);return t.data}const g={listKinds:()=>s("/kinds"),listAssemblies:()=>s("/assemblies"),listObjects:e=>s(`/objects/${e}`),listCreatableTypes:e=>s(`/types/${e}`),createObject:(e,t,o)=>{const i={};if(t&&(i.typeName=t),o)for(const[p,c]of Object.entries(o))c==null||c===""||(i[p]=c);return n(`/objects/${e}`,i)},deleteObject:(e,t)=>d(`/objects/${e}/${t}`),reloadPlugins:()=>n("/plugins/reload"),listPlugins:()=>s("/plugins"),unloadPlugin:e=>n(`/plugins/${encodeURIComponent(e)}/unload`),listMethods:(e,t)=>s(`/methods/${e}/${t}`),listMethodsByType:e=>s(`/methods-by-type/${e}`),getStatus:(e,t)=>s(`/status/${e}/${t}`),getFields:(e,t)=>s(`/fields/${e}/${t}`),setField:(e,t,o,i)=>n(`/fields/${e}/${t}/${encodeURIComponent(o)}`,{value:i}),deleteField:(e,t,o)=>d(`/fields/${e}/${t}/${encodeURIComponent(o)}`),getBundle:(e,t)=>s(`/bundle/${e}/${t}`),execute:(e,t,o,i)=>n(`/execute/${e}/${t}/${encodeURIComponent(o)}`,i),gotoCarSite:(e,t)=>n(`/car/${e}/goto-site`,{siteId:t}),getScriptSource:e=>s(`/scripts/${e}/source`),getScriptExceptionStatus:e=>s(`/scripts/${e}/exception-status`),getMonitorConfig:()=>s("/monitor-config"),saveMonitorConfig:async e=>{const{data:t}=await a.post(`${r}/monitor-config`,e);if(!t?.success)throw new Error(t?.message??"saveMonitorConfig failed");return t.data},getSelection:()=>s("/selection"),setSelection:(e,t)=>n("/selection",{kind:e,id:t}),clearSelection:()=>n("/selection/clear"),getProjectFields:()=>s("/project/fields"),setProjectField:(e,t)=>n(`/project/fields/${encodeURIComponent(e)}`,{value:t}),saveProject:e=>n("/project/save",e?{path:e}:void 0),getAppConfigFields:()=>s("/app-config/fields"),setAppConfigField:(e,t)=>n(`/app-config/fields/${encodeURIComponent(e)}`,{value:t}),saveAppConfig:()=>n("/app-config/save"),getCarStyleTypes:()=>s("/car-style/types"),getCarStyle:e=>s(`/car-style/${encodeURIComponent(e)}`),putCarStyle:async(e,t)=>{const{data:o}=await a.post(`${r}/car-style/${encodeURIComponent(e)}`,t);if(!o?.success)throw new Error(o?.message??"putCarStyle failed");return o.data},deleteCarStyle:e=>d(`/car-style/${encodeURIComponent(e)}`),getAlarmColors:()=>s("/car-style/alarm-colors"),putAlarmColors:async e=>{const{data:t}=await a.post(`${r}/car-style/alarm-colors`,e);if(!t?.success)throw new Error(t?.message??"putAlarmColors failed");return t.data},saveCarStyle:()=>n("/car-style/save")};export{f as a,$ as e,g as r};
|