@hailer/app-sdk 1.0.0 → 1.0.1-beta2

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/lib/app-sdk.js ADDED
@@ -0,0 +1,2 @@
1
+ var z=Object.create;var M=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var H=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var Z=(a,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Q(t))!Y.call(a,i)&&i!==e&&M(a,i,{get:()=>t[i],enumerable:!(s=G(t,i))||s.enumerable});return a};var $=(a,t,e)=>(e=a!=null?z(X(a)):{},Z(t||!a||!a.__esModule?M(e,"default",{value:a,enumerable:!0}):e,a));var o=(a,t,e)=>new Promise((s,i)=>{var r=u=>{try{l(e.next(u))}catch(h){i(h)}},n=u=>{try{l(e.throw(u))}catch(h){i(h)}},l=u=>u.done?s(u.value):Promise.resolve(u.value).then(r,n);l((e=e.apply(a,t)).next())});var B=H(f=>{"use strict";var tt=f&&f.__awaiter||function(a,t,e,s){function i(r){return r instanceof e?r:new e(function(n){n(r)})}return new(e||(e=Promise))(function(r,n){function l(p){try{h(s.next(p))}catch(E){n(E)}}function u(p){try{h(s.throw(p))}catch(E){n(E)}}function h(p){p.done?r(p.value):i(p.value).then(l,u)}h((s=s.apply(a,t||[])).next())})};Object.defineProperty(f,"__esModule",{value:!0});f.Client=void 0;var D=class{constructor(t,e){this.write=t,this.requests={},this.id=0,this.mtu=65535,e&&e.mtu&&(this.mtu=e.mtu)}destroy(){this.requests=null,this.write=null}messageReceived(t){let e=!!(t.err||t.ack||t.fin),s=t.ack||t.err||t.sig||t.fin,i=this.requests[s],r;if(i&&typeof i.cb=="function"){let n;t.fin?i.cb.call(i.context,null,null,!0):i.canceled?console.log("This request is canceled. Not calling the callback."):(n=t.err?t.data:null,r=i.cb.call(i.context,n,t.data,e))}return e&&delete this.requests[s],r}requestAsync(t,e){return tt(this,void 0,void 0,function*(){return new Promise((s,i)=>{this.request(t,e,(r,n)=>{if(r)return i(n);s(n)})})})}request(t,e,s){this.id++;let i={op:t};return Array.isArray(e)&&(i.args=e),s&&(i.id=this.id,this.requests[i.id]={cb:s,context:{id:i.id,cancel:()=>{setTimeout((r=>()=>{this.requests[r]&&console.log("rpc-client.js: timeout, the request has not been removed while it was canceled",r,this.requests[r])})(i.id),1500),this.requests[i.id].canceled=!0,this.write({end:i.id})},emit:r=>this.write({sig:i.id,data:r})}}),this.write(i),i.id||null}send(t,e){this.write({push:t,data:e})}end(t){this.write({end:t})}};f.Client=D});var N=H(m=>{"use strict";Object.defineProperty(m,"__esModule",{value:!0});m.Server=void 0;var g=console.log,F=class{constructor(t){this.modules={},this.methods={},this.requests={},this.clientIdCounter=0,this.requestId=0,this.invokeId=0,t&&this.insertMethods(t)}destroy(){for(let t in this.requests){for(let e in this.requests[t])typeof this.requests[t][e].end=="function"&&this.requests[t][e].end();delete this.requests[t]}}insertMethods(t){let e="";this.addMethods(e,t)}addMethods(t,e){let s=t?t+".":"";for(let i in e)if(i!=="_"){if(i.substring(0,1)!=="_"&&e["_"+i])if(typeof e[i]=="function"){let r=e["_"+i].name||i;e["_"+i].fullname=s+r;try{this.modules[s+r]=e["_"+i],this.methods[s+r]=e[i]}catch(n){console.log("Kaboom! ",n)}}else typeof e[i]=="object"&&this.addMethods(s+i,e[i])}}listMethods(t,e,s){let i={};function r(l,u){let h={};for(let p in l)u[p]||(h[p]=l[p]);return h}let n={fullname:!0};for(let l in this.modules)i[l]=r(this.modules[l],n);s(null,i)}clientOffline(t){for(let e in this.requests[t])typeof this.requests[t][e].end=="function"&&this.requests[t][e].end(),delete this.requests[t][e]}closeAll(){for(let t in this.requests)for(let e in this.requests[t])typeof this.requests[t][e].end=="function"&&this.requests[t][e].end(),delete this.requests[t][e]}parse(t,e,s,i){if(typeof i=="number")try{if(t.push){this.requests[i]&&this.requests[i][t.push]&&this.invokeRaw(t,e,this.requests[i][t.push].context,i);return}if(t.sig){this.requests[i]&&this.requests[i][t.sig]&&this.invokeRaw(t,e,this.requests[i][t.sig].context,i);return}if(t.end){let r=t.end;if(this.requests[i]&&this.requests[i][r]){typeof this.requests[i][r].end=="function"&&this.requests[i][r].end(),e({fin:r}),delete this.requests[i][r];return}if(!this.requests[i][r])return;typeof this.requests[i][r].end=="function"&&this.requests[r].end();return}if(t.op==="methods"){this.listMethods(t.args,s,function(r,n){e({ack:t.id,data:n})});return}if(typeof this.methods[t.op]>"u"){e({err:t.id,data:{code:300,msg:"No method found: "+t.op}});return}this.invokeRaw(t,e,s,i)}catch(r){g("Dynamic RPC failed to execute ",t.op,r,r.stack);try{console.log("RPC caught error",r.stack),e({ack:t.id,err:t.id,data:"caught error in "+t.op+": "+r.toString(),debug:r.stack})}catch(n){e({err:t.id,data:"rpc",errmsg:n.toString()})}}}emit(t,e){for(let s in this.requests)if(this.requests[s]){for(let i in this.requests[s])if(this.requests[s][i].op===t){let{send:r}=this.requests[s][i];r({sig:i,data:e})}}}invokeRaw(t,e,s,i){if(++this.requestId,!this.requests[i])return console.log("Session not opened for client. Use Server.open() first");if(t.push){let r=this.requests[i][t.push];if(t.data===null){console.log("msg.data is null:",t);return}r.data(t.data);return}if(t.sig){let r=this.requests[i][t.sig];try{this.methods[r.op].call(this.requests[i][t.sig],t.data,{send:n=>{typeof r.end=="function"&&r.end(),this.requests[i][t.sig]&&delete this.requests[i][t.sig],e({ack:t.sig,data:n})},emit:n=>(this.requests[i][t.sig]||typeof r.end=="function"&&r.end(),e({sig:t.sig,data:n})),error:n=>{typeof r.end=="function"&&r.end(),delete this.requests[i][t.sig],e({err:t.sig,data:n})},close:n=>{typeof r.end=="function"&&r.end(),delete this.requests[i][t.sig],e({fin:t.sig})}},s)}catch(n){console.log("Calling the method in RPC failed:",t.op,t.args,n.stack),delete this.requests[i][t.sig],e({err:t.sig,data:{msg:"rpc failed during execution of "+t.op,code:578}})}return}if(typeof t.id>"u"){let r={};this.methods[t.op].call(r,{args:t.args},{send:()=>{g("Trying to send response to event ("+t.op+"). Dropping.")},emit:()=>{g("Trying to emit response to event ("+t.op+"). Dropping.")},error:()=>{g("Trying to respond with error to event ("+t.op+"). Dropping.")},close:()=>{g("Trying to close event ("+t.op+"). Dropping.")}},s)}else{let r={id:t.id,op:t.op,args:t.args,context:s,end:null,send:e};this.requests[i]||(this.requests[i]={}),this.requests[i][t.id]&&(console.log("Serious warning. There is already a request by that id, we'll kill it off! This session is likely not clean. clientId:",i,"msg",t,"stack trace:",new Error().stack),typeof this.requests[i][t.id].end=="function"&&this.requests[i][t.id].end(),delete this.requests[i][t.id],console.log("Removed old request by same id from same client...")),this.requests[i][t.id]=r;try{this.methods[t.op].call(r,{args:t.args},{send:n=>{typeof r.end=="function"&&r.end(),this.requests[i][t.id]&&delete this.requests[i][t.id],e({ack:t.id,data:n})},emit:n=>(this.requests[i][t.id]||typeof r.end=="function"&&r.end(),e({sig:t.id,data:n})),error:n=>{typeof r.end=="function"&&r.end(),delete this.requests[i][t.id],e({err:t.id,data:n})},close:n=>{typeof r.end=="function"&&r.end(),delete this.requests[i][t.id],e({fin:t.id})}},s)}catch(n){console.log("Calling the method in RPC failed:",t.op,t.args,n.stack),delete this.requests[i][t.id],e({err:t.id,data:{msg:"rpc failed during execution of "+t.op,code:578}})}}}close(t){for(let e in this.requests[t])typeof this.requests[t][e].end=="function"&&this.requests[t][e].end(),delete this.requests[t][e];delete this.requests[t]}open(){let t=++this.clientIdCounter;return this.requests[t]={},t}};m.Server=F});var I=H(d=>{"use strict";var et=d&&d.__createBinding||(Object.create?function(a,t,e,s){s===void 0&&(s=e),Object.defineProperty(a,s,{enumerable:!0,get:function(){return t[e]}})}:function(a,t,e,s){s===void 0&&(s=e),a[s]=t[e]}),W=d&&d.__exportStar||function(a,t){for(var e in a)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&et(t,a,e)};Object.defineProperty(d,"__esModule",{value:!0});W(B(),d);W(N(),d)});var V=$(I(),1);var c=class extends Error{constructor(e){super();this.code=e.code,this.msg=e.msg,this.debug=e.debug,Object.setPrototypeOf(this,c.prototype)}};var b=class{constructor(t){this.client=t}get(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.user.get",[t])}catch(e){throw new c(e)}})}current(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.user.current",[])}catch(t){throw new c(t)}})}list(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.user.list",[])}catch(t){throw new c(t)}})}};var w=class{constructor(t){this.client=t}list(t,e){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.kanban.list",[t,...e?[e]:[]])}catch(s){throw new c(s)}})}load(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.kanban.load",[t])}catch(e){throw new c(e)}})}updatePriority(t,e){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.kanban.updatePriority",[{activityId:t,priority:e}])}catch(s){throw new c(s)}})}};var v=class{constructor(t){this.client=t;this.kanban=new w(t)}list(t,e,s){return o(this,null,function*(){try{return(yield this.client.requestAsync("v1.activity.list",[t,e,s])).activities}catch(i){throw new c(i)}})}get(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.get",[t])}catch(e){throw new c(e)}})}create(t,e,s){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.create",[t,e,...s?[s]:[]])}catch(i){throw new c(i)}})}update(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.update",t)}catch(e){throw new c(e)}})}remove(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.activity.remove",t)}catch(e){throw new c(e)}})}};var q=class{constructor(t){this.client=t}current(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.network.current",[])}catch(t){throw new c(t)}})}};var A=class{constructor(t){this.client=t}open(t,e){return o(this,null,function*(){yield this.client.requestAsync("v1.ui.activity.open",[t,...e?[e]:[]])})}create(t,e){return o(this,null,function*(){return yield this.client.requestAsync("v1.ui.activity.create",[t,...e?[e]:[]])})}};var k=class{constructor(t){this.client=t}open(t,e,s){return o(this,null,function*(){yield this.client.requestAsync("v1.ui.snackbar.open",[t,e,s])})}};var x=class{constructor(t){this.client=t}uploadFile(t,e,s){return o(this,null,function*(){return yield this.client.requestAsync("v1.ui.file.upload",[yield this.toBase64(t),e,!!(s!=null&&s.isPublic)])})}toBase64(t){return new Promise((e,s)=>{let i=new FileReader;i.readAsDataURL(t),i.onload=()=>{var r;return e((r=i.result)!=null?r:"")},i.onerror=s})}};var P=class{constructor(t){this.client=t;this.activity=new A(t),this.snackbar=new k(t),this.files=new x(t)}};var C=class{constructor(t){this.client=t}list(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.process.list",[])}catch(t){throw new c(t)}})}get(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.process.get",[t])}catch(e){throw new c(e)}})}getFieldIdByName(t,e){return o(this,null,function*(){var s,i;try{return(i=Object.values(((s=yield this.get(t))==null?void 0:s.fields)||{}).find(r=>r.label.toLowerCase()===e))==null?void 0:i._id}catch(r){throw new c(r)}})}};var K=["https://app.hailer.com","https://next.hailer.com","https://testapp.hailer.biz","https://app.hailer.biz","https://localhost:9443"],y="https://api.hailer.com",J={"https://app.hailer.com":y,"https://next.hailer.com":y,"https://app.hailer.biz":"https://api.hailer.biz","https://testapp.hailer.biz":"https://testapi.hailer.biz","https://localhost:9443":"http://localhost:1337"};var O=class{constructor(t){this.options=t}config(){return o(this,null,function*(){let t="manifest.json",e=window.location.origin+window.location.pathname,s=e+t;e.endsWith("/index.html")&&(s=e.slice(0,-10)+t);let i=yield(yield fetch(s)).text(),n=JSON.parse(i).appId;return yield(yield fetch(this.options.publicBackendUrl+"/api/v3/app/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([n])})).json()})}};var R=class{constructor(t){this.options=t}data(t){return o(this,null,function*(){let e=yield fetch(this.options.publicBackendUrl+"/api/v2/forms/process/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([t])});if(!e.ok)throw new c(yield e.json());return yield e.json()})}submit(t,e){return o(this,null,function*(){let s=yield fetch(this.options.publicBackendUrl+"/api/v2/forms/activity/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([t,e])});if(!s.ok)throw new c(yield s.json());return yield s.json()})}};var _=class{constructor(t){this.options=t}data(t){return o(this,null,function*(){let e=yield fetch(this.options.publicBackendUrl+"/api/v3/insight/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([t])});if(!e.ok)throw new c(yield e.json());return yield e.json()})}dataAsObject(t){return o(this,null,function*(){let s=(yield this.data(t)).data,i=[];return s.rows.forEach(r=>{let n={};s.headers.forEach((l,u)=>{n[l]=r[u]}),i.push(n)}),i})}};var U=class{constructor(t){this.insight=new _(t),this.form=new R(t),this.app=new O(t)}};var S=class{constructor(t){this.client=t}list(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.workflow.list",[])}catch(t){throw new c(t)}})}get(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.workflow.get",[t])}catch(e){throw new c(e)}})}};var j=class{constructor(t){this.client=t;this.config={update:(t,e)=>o(this,null,function*(){try{return yield this.client.requestAsync("v1.app.config.update",[t,e])}catch(s){throw console.log("Errorasd ",s),new c(s)}})}}};var T=class{constructor(t){this.client=t}data(t){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.insight.data",[t])}catch(e){throw new c(e)}})}list(){return o(this,null,function*(){try{return yield this.client.requestAsync("v1.insight.list",[])}catch(t){throw new c(t)}})}};var L=class{constructor(t={}){this.options=t;this.outside=null;var i,r;let e=(i=t.allowedUrls)!=null?i:K;this.apiVersion=(r=t.apiVersion)!=null?r:1,this.subscribedSignals=t.subscribedSignals,this.client=new V.Client(n=>{this.hostUrl&&parent.postMessage(JSON.stringify(n),this.hostUrl)}),this.user=new b(this.client),this.app=new j(this.client),this.activity=new v(this.client),this.insight=new T(this.client),this.network=new q(this.client),this.process=new C(this.client),this.workflow=new S(this.client),this.public=new U(this.options),this.ui=new P(this.client);let s=JSON.stringify({op:"register",args:[]});window.location===window.parent.location?(this.options.publicBackendUrl||(this.options.publicBackendUrl=y),this.public.app.config().then(n=>{var l,u;this.outside=!0,(u=(l=this.options).outside)==null||u.call(l,n)}).catch(n=>{var l,u;(u=(l=this.options).error)==null||u.call(l,n),console.error("Failed to get app configuration in Public App.",n)})):(e.forEach(n=>parent.postMessage(s,n)),this.timer=setTimeout(()=>{var n,l;this.outside=!0,(l=(n=this.options).outside)==null||l.call(n)},100)),this.createEventListener()}createEventListener(){window.addEventListener("message",t=>o(this,null,function*(){var s,i;let e=t.data;try{let r=JSON.parse(e);if(r.op==="register"){if(this.appId){console.error("App Id is already set...! Are you using hot-reload?");return}clearTimeout(this.timer),this.appId=r.data.appId,this.hostUrl=t.origin,this.options.publicBackendUrl||(this.options.publicBackendUrl=J[this.hostUrl]||y),this.client.request("v1.ui.settings",[],(n,l,u)=>{var h,p;if(n){console.log("ui.settings error:",n,l);return}(p=(h=this.options).settings)==null||p.call(h,l)}),this.client.request("v1.config",[],(n,l,u)=>{var h,p;if(n){console.log("config error:",n,l);return}(p=(h=this.options).config)==null||p.call(h,l)}),this.subscribedSignals&&this.client.request("v1.signals",[this.subscribedSignals],(n,l,u)=>{var h,p;if(n){console.log("signals error:",n,l);return}l&&((p=(h=this.options).signals)==null||p.call(h,l))}),this.outside=!1,(i=(s=this.options).connected)==null||i.call(s);return}if(!this.appId)return;this.client.messageReceived(r)}catch(r){console.error("Error handling message:",r)}}))}info(){return{hostUrl:this.hostUrl,config:this.config,outside:this.outside}}request(t,e){return o(this,null,function*(){return yield this.client.requestAsync(t,e)})}};export{L as HailerApi,c as HailerError};
2
+ //# sourceMappingURL=app-sdk.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/@wishcore/wish-rpc/src/rpc-client.ts", "../node_modules/@wishcore/wish-rpc/src/rpc-server.ts", "../node_modules/@wishcore/wish-rpc/src/index.ts", "../src/hailer-api.ts", "../src/types.ts", "../src/modules/user.ts", "../src/modules/activity/kanban.ts", "../src/modules/activity.ts", "../src/modules/network.ts", "../src/modules/ui/activity.ts", "../src/modules/ui/snackbar.ts", "../src/modules/ui/files.ts", "../src/modules/ui.ts", "../src/modules/process.ts", "../src/constants.ts", "../src/modules/public/app.ts", "../src/modules/public/form.ts", "../src/modules/public/insight.ts", "../src/modules/public.ts", "../src/modules/workflow.ts", "../src/modules/app.ts", "../src/modules/insight.ts"],
4
+ "sourcesContent": [null, null, null, "import { Client } from '@wishcore/wish-rpc';\nimport { UserApi } from './modules/user';\nimport { ActivityApi } from './modules/activity';\nimport { WorkspaceApi } from './modules/network';\nimport { HailerApiInfo, HailerAppConfig, HailerSettings, HailerSignal } from './types';\nimport { Ui } from './modules/ui';\nimport { Process } from './modules/process';\nimport { DEFAULT_ALLOWED_URLS, DEFAULT_API_VERSION, DEFAULT_BACKEND_URL, publicBackendMap } from './constants';\nimport { HailerPublicApi } from './modules/public';\nimport { WorkflowApi } from './modules/workflow';\nimport { AppApi } from './modules/app';\nimport { InsightApi } from './modules/insight';\n\nexport interface Options {\n /** When connected is called the host is ready to receive calls */\n connected?: () => void;\n /** Callback when app is determined to be outside of Hailer, as a standalone app */\n outside?: (config?: any) => void;\n /** Callback on errors, defaults to printing errors in console */\n error?: (error: Error) => void;\n /** Callback called on app init and when permissions have changed */\n permissions?: () => void;\n /** Callback called on app init and when settings have changed */\n settings?: (data: HailerSettings) => void;\n /** Callback called on app init and when config has changed */\n config?: (config: any) => void;\n /** Will be called each time a subscribed signal is emitted from Hailer frontend. To subscribe to signals, add them to options.subscribedSignals[] */\n signals?: (signal: HailerSignal) => void;\n /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/\n allowedUrls?: string[];\n /** The signals we want the Hailer frontend to pass to the app. If an empty array is provided, all signals will be passed. */\n subscribedSignals?: string[];\n /** Api version to be used in the app by default */\n apiVersion?: 1;\n /** Public backend Api url. Defaults to https://api.hailer.com */\n publicBackendUrl?: string;\n}\n\nexport class HailerApi {\n public user: UserApi;\n public app: AppApi;\n public activity: ActivityApi;\n public insight: InsightApi;\n public network: WorkspaceApi;\n public process: Process;\n public workflow: WorkflowApi;\n /** All public endpoints, which can be accessed while not logged in to Hailer. */\n public public: HailerPublicApi;\n /** User interface commands */\n public ui: Ui;\n /** Url of the Hailer instance hosting the API */\n private hostUrl?: string;\n\n private appId?: string;\n private client: Client;\n private apiVersion: 1;\n private settings?: HailerSettings;\n private config?: HailerAppConfig;\n private subscribedSignals?: string[];\n private timer?: NodeJS.Timeout;\n /**\n * Hailer API state\n * \n * ```\n * true // outside hailer\n * false // logged into hailer\n * null // state not yet detected\n * ``` \n */\n private outside: boolean | null = null;\n\n /**\n * Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.\n *\n * This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React\n */\n constructor(\n public options: Options = {}\n ) {\n const allowedUrls = options.allowedUrls ?? DEFAULT_ALLOWED_URLS;\n this.apiVersion = options.apiVersion ?? DEFAULT_API_VERSION;\n this.subscribedSignals = options.subscribedSignals;\n \n this.client = new Client(msg => {\n if (this.hostUrl){\n parent.postMessage(JSON.stringify(msg), this.hostUrl)\n }\n })\n\n this.user = new UserApi(this.client);\n this.app = new AppApi(this.client);\n this.activity = new ActivityApi(this.client);\n this.insight = new InsightApi(this.client);\n this.network = new WorkspaceApi(this.client);\n this.process = new Process(this.client);\n this.workflow = new WorkflowApi(this.client);\n this.public = new HailerPublicApi(this.options);\n this.ui = new Ui(this.client);\n\n const registerMessage = JSON.stringify({ op: 'register', args: [] });\n\n // If we are not in Iframe set location to outside, else wait 100ms for response to register to check if we are in Hailer\n if (window.location === window.parent.location) {\n // Pick a backend to use for public requests, unless it is set\n if (!this.options.publicBackendUrl) {\n this.options.publicBackendUrl = DEFAULT_BACKEND_URL;\n }\n\n this.public.app.config().then(config => {\n // CSM app assumes we are inside hailer when config is called... breaks the thing...\n // this.options.config?.(config);\n\n this.outside = true;\n this.options.outside?.(config);\n }).catch(error => {\n this.options.error?.(error);\n console.error('Failed to get app configuration in Public App.', error);\n });\n } else {\n // if in a frame, try register to Hailer by sending register to all allowed urls\n allowedUrls.forEach(url => parent.postMessage(registerMessage, url));\n this.timer = setTimeout(() => {\n this.outside = true;\n this.options.outside?.()\n }, 100);\n }\n\n this.createEventListener();\n }\n\n private createEventListener() {\n window.addEventListener('message', async event => {\n const data = event.data;\n\n try {\n const msg = JSON.parse(data);\n if (msg.op === 'register') {\n if (this.appId) {\n console.error('App Id is already set...! Are you using hot-reload?');\n return;\n }\n\n clearTimeout(this.timer)\n this.appId = msg.data.appId\n\n // Set host url now that we have a response\n this.hostUrl = event.origin\n\n // Pick a backend to use for public requests, unless it is set\n if (!this.options.publicBackendUrl) {\n this.options.publicBackendUrl = publicBackendMap[this.hostUrl] || DEFAULT_BACKEND_URL;\n }\n\n // Register listeners for config and settings\n this.client.request('v1.ui.settings', [], (error: any, data: HailerSettings, end: boolean) => {\n if (error) {\n console.log('ui.settings error:', error, data);\n return;\n }\n\n this.options.settings?.(data);\n });\n\n this.client.request('v1.config', [], (error: any, data: any, end: boolean) => {\n if (error) {\n console.log('config error:', error, data);\n return;\n }\n this.options.config?.(data)\n })\n\n // Register subscribed signals\n if (this.subscribedSignals) {\n this.client.request('v1.signals', [this.subscribedSignals], (error: any, data: any, end: boolean) => {\n if (error) {\n console.log('signals error:', error, data);\n return;\n }\n\n if (data) {\n this.options.signals?.(data);\n }\n });\n }\n\n this.outside = false;\n // Call connected callback\n this.options.connected?.();\n return;\n }\n\n // bail out unless appId is set, as the app is not properly registered\n if (!this.appId) {\n return;\n }\n\n this.client.messageReceived(msg);\n } catch (error) {\n console.error('Error handling message:', error);\n }\n });\n }\n\n info(): HailerApiInfo {\n return {\n hostUrl: this.hostUrl,\n config: this.config,\n outside: this.outside,\n }\n }\n\n // TODO: This is here for development and debugging, might be removed later\n async request(op: string, args: any[]) {\n return await this.client.requestAsync(op, args);\n }\n}\n", "export interface User {\n firstname: string;\n lastname: string;\n email: string;\n lastSeen: number;\n status?: string;\n managedUser?: boolean;\n removed?: number;\n}\n\nexport interface Workspace {\n _id: string;\n name: string;\n members: string[];\n settings: {\n isolatedTeams?: boolean;\n defaultView: string;\n functionFieldVersion?: 1 | 2;\n color?: string;\n allowPublicCopy?: boolean;\n };\n license: object;\n invoicing?: any;\n propertyFields?: {\n [section: string]: {\n [field: string]: any;\n };\n };\n}\n\nexport interface Activity {\n _id: string;\n process: string;\n teamAccount: TeamAccount // TODO: Convert in frontend\n created: number;\n uid: string;\n cid: string;\n discussion: string;\n currentPhase: string;\n active?: boolean;\n history?: any[];\n name?: string;\n followers?: string[];\n completePhases?: string[];\n location?: {\n type: 'point' | 'area' | 'polyline',\n label: string | null\n data: {\n lat: number\n lng: number\n }[]\n };\n fields?: any;\n files?: any[];\n updated?: number;\n updatedBy?: string;\n priority?: number;\n sequence?: number\n}\n\nexport interface TeamAccount {\n account: string;\n team: string;\n}\n\nexport interface FormsData {\n files: string[];\n history: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 0: {\n [fieldId: string]: {\n value: any;\n };\n };\n };\n name: string;\n location?: boolean;\n uid?: string;\n}\nexport interface FormsResponse {\n name: string;\n description?: string;\n enableUnlinkedMode: boolean;\n enableAttachments: boolean;\n enableMapLocation: boolean;\n locationRequired: 1;\n phases: {\n _id: string;\n followers: [];\n name: string;\n description: string;\n uid: string;\n created: number;\n fields: string[];\n announcementFields: [];\n announcementRecipients: [];\n announcementFieldsOrder: [];\n isEndpoint: boolean;\n }[];\n phasesOrder: string[];\n fields: {\n [id: string]: {\n data: [];\n label: string;\n required: boolean;\n type: string;\n inviteToDiscussionOnChange: boolean;\n _id: string;\n created: number;\n updated: number;\n uid: string;\n functionEnabled: boolean;\n };\n };\n enableMessenger: boolean;\n publicForm: {\n enableMessaging: boolean;\n };\n fieldsOrder: [];\n}\n\nexport interface FormCreateResponse {\n key: string,\n creator: string,\n followers: string,\n active: boolean,\n enableMessaging: boolean,\n allowRead: boolean\n}\n\nexport interface InsightResponse {\n insight: {\n name: string\n },\n data: InsightResponseData\n}\n\nexport interface InsightResponseData {\n headers: string[],\n rows: [],\n time: number\n}\n\nexport interface HailerAppConfig {\n fields?: {\n [fieldName: string]: {\n type: string;\n value?: string | number | boolean;\n };\n };\n}\n\nexport type HailerProcess = Workflow;\n\nexport interface Workflow {\n _id: string;\n cid: string;\n name: string;\n description?: string;\n fields: { [fieldId: string]: any };\n phases: { [phase_id: string]: WorkflowPhase };\n phasesOrder: string[];\n\n /*\n defaultView: 'table' | 'kanban' | 'map' | 'calendar';\n fields: { [fieldId: string]: any };\n fieldsOrder: string[];\n phasesRemoved: string[];\n members: any;\n updated: number;\n coverImage?: string;\n createNewLabel?: string;\n enableAddedField: boolean;\n enableLinkedAnnouncements?: boolean;\n enableMapLocation?: boolean;\n enableUnlinkedMode?: boolean;\n enableMessenger?: boolean;\n allowGuests?: boolean;\n enableGuestEditing?: boolean;\n enableModifiedField?: boolean;\n enableOwnerField?: boolean;\n enableOwnerTeamField?: boolean;\n ownerTeamFieldTitle?: string;\n enableUniqueName?: boolean;\n enablePredefinedName?: boolean;\n enablePreselectedTeam?: boolean;\n initPhaseDescription?: string;\n locationRequired?: boolean;\n nameColumnText?: string;\n nameFunction?: string;\n nameFunctionEnabled?: boolean;\n nameFunctionVariables?: any;\n nameEditable?: boolean;\n personInCharge?: string;\n personInChargeLabel?: string;\n publicForm?: {\n key: string;\n active: boolean;\n creator: string;\n team_account: TeamAccount;\n followers: string;\n allowRead: boolean;\n enableMessaging?: boolean;\n }\n predefinedNamePrefix?: string;\n preselectedTeam?: TeamAccount;\n enableAttachments: boolean;\n nameFieldPlaceHolderText: string;\n order?: number;\n allowMultipleTags?: boolean;\n allowCustomTags?: boolean;\n requireFileTag?: boolean;\n documentTemplates?: any;\n color?: string;\n starred?: string[];\n isStarred?: boolean;\n createdActivities?: number;\n */\n}\n\nexport interface WorkflowPhase {\n _id: string;\n name: string;\n description?: string;\n /*\n followers: string[];\n created: number;\n uid?: string;\n members?: any[]\n fields?: string[]\n enableAnnouncement?: boolean,\n announcementFields?: string[];\n announcementRecipients?: string[];\n announcementFieldsOrder?: string[];\n announcementToOwner?: boolean;\n announcementToOwnerTeam?: boolean;\n isEndPoint?: boolean;\n possibleNextPhase?: string[];\n possibleNextPhaseSettings?: any;\n fieldOptions?: any;\n primaryNumericField?: string;\n webhooksEnabled?: boolean;\n webhookAdded?: boolean;\n webhookUpdated?: boolean;\n primaryDateField?: string | null | any;\n removed?: number;\n removedBy?: string;\n color?: string | null;\n */\n}\n\nexport type PermissionType = 'admin' | 'own' | 'ownteam' | 'any' | 'edit';\n\nexport interface Member {\n id: string;\n info: { [key: string]: string | number | boolean | null };\n permissions: PermissionType[];\n}\n\nexport interface InsightWorkflowSource {\n name: string;\n workflowId: string;\n fields: {\n name: string;\n fieldId?: string;\n /** Used for phaseLastMove meta */\n phaseId?: string;\n /** Activity information, like _id, created, phaseId etc. */\n meta?: string;\n }[];\n}\nexport interface InsightDoc {\n name: string;\n sources: InsightWorkflowSource[];\n cid: string;\n /** User id of creator */\n uid: string;\n members: Member[];\n updated: number;\n public: boolean;\n /** Key for accessing Insight when set to public */\n publicKey?: string;\n /** sandboxed javascript with access to all activities in given workflows */\n function?: string;\n /** To be used with SQLite if we want to.... */\n query?: string;\n}\n\n// These are separate so we can do different configs if necessary without it being a breaking change\nexport interface InsightData {\n headers: string[];\n rows: (string | number | null)[][];\n time: number;\n}\n\nexport interface InsightResponseAsObjectItem {\n [key: string]: any\n}\nexport type InsightResponseAsObjects = InsightResponseAsObjectItem[]\n\nexport interface KanbanListResponse {\n map: {\n [phaseId: string]: {\n activities: {\n _id: string,\n followers: string[],\n name: string,\n fields: { [key: string]: any }\n files: string[],\n primaryDateField: number,\n priority: number,\n }[]\n meta: {\n count: number,\n totalPrimaryNumericValue: number,\n primaryNumericFieldUnit: string | null\n }\n }\n }\n}\n\nexport interface KanbanLoadResponse {\n activity: {\n _id: string,\n followers: string[],\n name: string,\n fields: { [key: string]: any },\n files: string[],\n primaryDateField: number | null,\n priority: number,\n linkedFromCount: number\n },\n process: string,\n phase: string\n}\nexport interface ActivityListOptions {\n sortBy?: 'name' | 'created' | 'updated' | 'following' | 'owner' | 'team' | 'completedOn' | 'priority',\n sortOrder?: 'asc' | 'desc',\n limit?: number,\n skip?: number,\n includeUsers?: boolean,\n includeTeams?: boolean,\n includeHistory?: boolean\n filters?: any\n}\nexport interface ActivityCreateOptions {\n teamId?: string;\n fileIds?: string[];\n followerIds?: string[];\n location?: {\n label?: string;\n type: 'area' | 'point' | 'polyline';\n data: [{ lat: number, lng: number }];\n };\n discussionId?: string;\n phaseId?: string;\n returnDocument?: boolean;\n}\nexport interface ActivityKanbanListOptions {\n filter: {\n user?: {\n uid: string;\n field: string;\n },\n account?: string;\n team?: string;\n dates?: {\n field: string;\n start: number;\n end: number;\n };\n },\n search?: string;\n limit?: number;\n skip?: number;\n phase?: string;\n includeUsers?: boolean;\n includeTeams?: boolean;\n}\n\nexport interface HailerSettings {\n theme: 'light' | 'dark'\n preferredLanguages: string[];\n}\n\nexport interface HailerError {\n code: number,\n msg: string, \n debug: object\n}\n\nexport interface HailerApiInfo {\n /** Url of the Hailer instance hosting the API */\n hostUrl?: string;\n config?: HailerAppConfig;\n outside: boolean | null;\n}\n\nexport class HailerError extends Error {\n public code: number\n public msg: string\n public debug: object\n constructor(error: {code: number, msg: string, debug: object}) {\n super()\n\n this.code = error.code\n this.msg = error.msg\n this.debug = error.debug\n \n Object.setPrototypeOf(this, HailerError.prototype);\n }\n}\n\nexport interface HailerSignal {\n sig: string;\n meta: any;\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, User } from '../types';\n\nexport class UserApi {\n constructor(private client: Client) {}\n\n /** \n * Returns the specified user\n * \n * @param userId id of the Hailer user\n *\n * @returns Hailer user information\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(userId: string): Promise<User> {\n try {\n const res = await this.client.requestAsync('v1.user.get', [userId]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Returns the current user\n *\n * \n * @returns the current Hailer user information\n *\n * @throws {HailerError} if request is incorrect\n */\n async current(): Promise<User> {\n try {\n const res = await this.client.requestAsync('v1.user.current', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Lists all Hailer users from a workspace\n * \n * \n * @returns list of Hailer users in the workspace the app user is currently in\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<{ [key: string]: User }> {\n try {\n const users = await this.client.requestAsync('v1.user.list', []);\n return users;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { ActivityKanbanListOptions, HailerError, KanbanListResponse, KanbanLoadResponse } from '../../types';\n\nexport class Kanban {\n constructor(private client: Client) { }\n \n /** \n * Lists all activities in a kanban grouped by phases\n * \n * @param processId the id of the process the kanban relates to\n * @param options ActivityKanbanListOptions\n *\n * @returns activities in kanban list format\n *\n * @throws {HailerError} if request fails\n */\n async list(processId: string, options?: ActivityKanbanListOptions): Promise<KanbanListResponse> {\n try {\n const res = await this.client.requestAsync('v1.activity.kanban.list', [processId, ...options ? [options] : []]);\n return res;\n } catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Loads a single activity in kanban format\n * \n * @param activityId activityId of the wanted activity\n *\n * @returns activity in kanban format\n * \n * @throws {HailerError} if request is incorrect\n */\n async load(activityId: string): Promise<KanbanLoadResponse> {\n try {\n const res = await this.client.requestAsync('v1.activity.kanban.load', [activityId]);\n return res;\n } catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates priority of activities in kanban\n * \n * @param activityId activityId of the wanted activity\n * @param priority new priority for the activity\n *\n * @throws {HailerError} if request is incorrect\n */\n async updatePriority(activityId: string, priority: number): Promise<void> {\n try {\n const res = await this.client.requestAsync('v1.activity.kanban.updatePriority', [{activityId, priority}]);\n return res;\n } catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { ActivityCreateOptions, ActivityListOptions, Activity, HailerError } from '../types';\nimport { Kanban } from './activity/kanban';\n\nexport class ActivityApi {\n public kanban: Kanban\n constructor(private client: Client) {\n this.kanban = new Kanban(client)\n }\n\n /** \n * Lists all activities from the specified process and phase\n *\n * @param processId process from current network\n * @param phaseId phase in the process specified in processId\n * @param options ActivityListOptions\n *\n * @returns List of Hailer activities from process and phase filtered with supplied options\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(processId: string, phaseId: string, options?: ActivityListOptions): Promise<Activity[]> {\n try {\n const res = await this.client.requestAsync('v1.activity.list', [processId, phaseId, options]);\n return res.activities;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets single activity\n *\n * @param activityId activity Id of the process specified in processId\n * @param processId Process where the activityId is\n * @param phaseId Phase where the activityId is in process specified by processId\n * @param options options containing apiVersion\n *\n * @returns Hailer activity information or undefined if no activity is found\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(activityId: string): Promise<Activity | undefined> {\n try {\n // Uses the same endpoint as getAll but only returns the activity in question\n return await this.client.requestAsync('v1.activity.get', [activityId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates activities\n * \n * @param processId The process where the activity is created\n * @param activities new activities as objects\n * @param activities.name name of the activity\n * @param activities.fields fields of the activity\n * @param options ActivityCreateOptions\n *\n * @throws {HailerError} if request is incorrect\n */\n async create(processId: string, activities: { name: string; fields: { [id: string]: string | number } }[], options?: ActivityCreateOptions ): Promise<Activity[]> {\n try {\n const res = await this.client.requestAsync('v1.activity.create', [processId, activities, ...options ? [options] : []]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates activites\n *\n * Each activity has the following parameters \n * @param activities updated activity objects of an activity to edit\n * @param activities.name New name of the activity\n * @param activities.fields change values of fields, null removes current value\n * @param activities.phaseId New phase of the activity\n * @param options \n *\n * @returns The number of updated activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async update(activities: { _id: string, name?: string, fields?: { [id: string]: string | number | null }, phaseId?: string }[]): Promise<number> {\n try {\n const res = await this.client.requestAsync('v1.activity.update', activities);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Removes activities\n *\n * @param activities Ids of activities to be removed\n * @param options options containing apiVersion\n *\n * @returns The number of removed activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async remove(activities: string[]): Promise<number> {\n try {\n const res = await this.client.requestAsync('v1.activity.remove', activities);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, Workspace } from '../types';\n\nexport class WorkspaceApi {\n constructor(private client: Client) {}\n\n /** \n * Returns the current network\n *\n * @returns the Hailer Workspace information the user is currently in\n *\n * @throws {HailerError} if request is incorrect\n */\n async current(): Promise<Workspace> {\n try {\n const res = await this.client.requestAsync('v1.network.current', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\n\nexport type ActivityTabTypes =\n 'detail' |\n 'discussion' |\n 'files' |\n 'location' |\n 'linkedFrom' |\n 'options';\n\nexport class Activity {\n constructor(private client: Client) {}\n\n /** Opens an activity in Hailer sidebar */\n async open(\n /** Hailer Activity Id */\n activityId: string,\n options?: {\n /** Which tab to open in activity aside */\n tab?: ActivityTabTypes\n },\n ): Promise<void> {\n await this.client.requestAsync('v1.ui.activity.open', [activityId, ...options ? [options] : []]);\n }\n\n /** Opens activity creation view in Hailer sidebar */\n async create(\n processId: string,\n options?: {\n /** Activity name/title */\n name?: string,\n /** Prepopulate fields */\n fields?: {\n [fieldId: string]: number | string | { start: number, end: number },\n }\n }\n ): Promise<{ _id: string, name: string } | null> {\n return await this.client.requestAsync('v1.ui.activity.create', [processId, ...options ? [options] : []]);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\n\nexport class Snackbar {\n constructor(private client: Client) {}\n\n /** \n * Opens a snackbar in Hailer\n * @param text the text displayed on the snackbar\n * @param buttonLabel the label for the button on the snackbar, for example 'OK'\n * @param duration the time the snackbar is visible in ms\n */\n async open(\n /** The text displayed on the snackbar */\n text: string,\n /** The label for the button on the snackbar, for example 'OK' */\n buttonLabel: string,\n /** The time the snackbar is visible in ms */\n duration?: number,\n ): Promise<void> {\n await this.client.requestAsync('v1.ui.snackbar.open', [text, buttonLabel, duration]);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\n\nexport class Files {\n constructor(private client: Client) {}\n\n /**\n * Uploads a file to Hailer\n *\n * @param file file to be uploaded\n * @param publicFile is the file accessible outside of Hailer\n * @param options if file is public\n *\n * @returns File ID in Hailer as string\n */\n public async uploadFile(file: File, filename: string, options: { isPublic?: boolean }): Promise<string> {\n return await this.client.requestAsync('v1.ui.file.upload', [await this.toBase64(file), filename, !!options?.isPublic]);\n }\n\n private toBase64(file: File): Promise<string | ArrayBuffer> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result ?? '');\n reader.onerror = reject;\n });\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { Activity } from './ui/activity';\nimport { Snackbar } from './ui/snackbar';\nimport { Files } from './ui/files';\n\n\nexport class Ui {\n public activity;\n public snackbar;\n public files;\n\n constructor(private client: Client) {\n this.activity = new Activity(client);\n this.snackbar = new Snackbar(client);\n this.files = new Files(client);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, HailerProcess } from '../types';\n\n/** @deprecated Use Workflow instead */\nexport class Process {\n constructor(private client: Client) {}\n \n /** \n * Lists all processes from a workspace\n *\n * @returns all Hailer processes in the workspace the app user is currently in \n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<{ [key: string]: HailerProcess }> {\n try {\n const processes = await this.client.requestAsync('v1.process.list', []);\n return processes;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets a single process from a workspace\n * \n * @param processId the id of the process in question\n * \n * @returns the specified Hailer process\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(processId: string): Promise<HailerProcess> {\n try {\n const process = await this.client.requestAsync('v1.process.get', [processId]);\n return process;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /**\n * Gets an id of a field in a process by its name\n *\n * @param processId the id of the process in question\n * @param fieldName name of the field\n *\n * @returns the field id as string\n *\n * @throws {HailerError} if request is incorrect\n */\n async getFieldIdByName(processId: string, fieldName: string): Promise<string> {\n try {\n return Object.values((await this.get(processId))?.fields || {}).find(\n (field) => field.label.toLowerCase() === fieldName\n )?._id;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}\n", "// Changing this will be a breaking change\nexport const DEFAULT_API_VERSION = 1;\n\nexport const DEFAULT_ALLOWED_URLS = ['https://app.hailer.com', 'https://next.hailer.com', 'https://testapp.hailer.biz', 'https://app.hailer.biz', 'https://localhost:9443'];\n\nexport const DEFAULT_BACKEND_URL = 'https://api.hailer.com';\n\n/** Map of which backend to use depending on which frontend is hosting the app frame, be sure to fall back to production backend if no match */\nexport const publicBackendMap: { [host: string]: string } = {\n 'https://app.hailer.com': DEFAULT_BACKEND_URL,\n 'https://next.hailer.com': DEFAULT_BACKEND_URL,\n 'https://app.hailer.biz': 'https://api.hailer.biz',\n 'https://testapp.hailer.biz': 'https://testapi.hailer.biz',\n 'https://localhost:9443': 'http://localhost:1337',\n}\n", "import { Options } from '../../hailer-api';\nimport { HailerAppConfig } from '../../types';\n\nexport class App {\n constructor(private options: Options) {}\n\n /** \n * Read data from app API\n *\n * @param appId key of a specific insight\n *\n * @returns App manifest\n *\n * @throws {HailerError} if there is something wrong with the request or insight cannot be found\n * @throws {TypeError} if Hailer cannot be reached\n */\n async config(): Promise<HailerAppConfig> {\n const manifestFile = 'manifest.json';\n const location = window.location.origin + window.location.pathname;\n let manifestUrl = location + manifestFile;\n\n if (location.endsWith('/index.html')) {\n manifestUrl = location.slice(0, -10) + manifestFile;\n }\n\n const manifestContent = await (await fetch(manifestUrl)).text();\n\n const manifest = JSON.parse(manifestContent);\n\n const appId = manifest.appId;\n\n const res = await fetch(this.options.publicBackendUrl + '/api/v3/app/public', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([appId])\n });\n\n return await res.json();\n }\n\n}\n", "import { Options } from '../../hailer-api';\nimport { FormCreateResponse, FormsData, FormsResponse, HailerError } from '../../types';\n\nexport class Form {\n constructor(private options: Options) {}\n\n /** \n * Read data from forms\n *\n * @param formsKey key of a form\n * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms\n *\n * @returns forms data as object or null if form could not be found\n *\n * @throws {HailerError} if there is something wrong with the request or form cannot be found\n * @throws {TypeError} if Hailer cannot be reached\n */\n async data(formsKey: string): Promise<FormsResponse> {\n const res = await fetch(this.options.publicBackendUrl + '/api/v2/forms/process/get', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([formsKey])\n });\n if (!res.ok) {\n throw new HailerError(await res.json())\n }\n return await res.json();\n }\n\n /** \n * Submits form to specified process\n *\n * @param formsKey key of a form\n * @param formsData Data to be sent to form endpoint\n * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms\n *\n * @returns form creation data or null if form could not be created\n *\n * @throws {HailerError} if there is something wrong with the request or form cannot be found\n * @throws {TypeError} if Hailer cannot be reached\n */\n async submit(formsKey: string, formsData: FormsData): Promise<FormCreateResponse> {\n const res = await fetch(this.options.publicBackendUrl + '/api/v2/forms/activity/create', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([formsKey, formsData])\n });\n if (!res.ok) {\n throw new HailerError(await res.json())\n }\n return await res.json();\n }\n}\n", "import { Options } from '../../hailer-api';\nimport { HailerError, InsightResponse, InsightResponseAsObjects, InsightResponseData } from '../../types';\n\nexport class InsightPublicApi {\n constructor(private options: Options) {}\n\n /** \n * Read data from insight API\n *\n * @param insightKey key of a specific insight\n * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public\n *\n * @returns Insight data as object\n *\n * @throws {HailerError} if there is something wrong with the request or insight cannot be found\n * @throws {TypeError} if Hailer cannot be reached\n */\n async data(insightKey: string): Promise<InsightResponse> {\n const res = await fetch(this.options.publicBackendUrl + '/api/v3/insight/public', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([insightKey])\n }\n );\n if (!res.ok) {\n throw new HailerError(await res.json())\n }\n return await res.json();\n }\n\n /** \n * Read data from insight API and return in an array of JavaScript objects\n *\n * @param insightKey key of a specific insight\n * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public\n *\n * @returns Insight data as array of JavaScript objects\n *\n * @throws {HailerError} if there is something wrong with the request or insight cannot be found\n * @throws {TypeError} if Hailer cannot be reached\n */\n async dataAsObject(insightKey: string): Promise<InsightResponseAsObjects> {\n const res = await this.data(insightKey);\n\n const input: InsightResponseData = res.data;\n const data: InsightResponseAsObjects = [];\n \n input.rows.forEach((row) => {\n // The object keys are constructed dynamically, so any is necessary\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const object: any = {};\n input.headers.forEach((header, headerIndex) => {\n object[header] = row[headerIndex];\n });\n data.push(object);\n });\n return data;\n }\n}\n", "import { Options } from '../hailer-api';\nimport { App } from './public/app';\nimport { Form } from './public/form';\nimport { InsightPublicApi } from './public/insight';\n\n/**\n * This class is used to access Hailer public API even when the app is outside of Hailer\n */\nexport class HailerPublicApi {\n /** Allows accessing public insight methods. Used for reading data from Hailer even when app is outside of Hailer */\n public insight: InsightPublicApi;\n /** Allows accessing public forms methods. Used for sending data to Hailer even when app is outside of Hailer */\n public form: Form;\n /** Access public App information */\n public app: App;\n\n constructor(options: Options) {\n this.insight = new InsightPublicApi(options);\n this.form = new Form(options);\n this.app = new App(options);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, Workflow } from '../types';\n\nexport class WorkflowApi {\n constructor(private client: Client) {}\n \n /** \n * Lists all processes from a workspace\n *\n * @returns all Hailer processes in the workspace the app user is currently in \n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<Workflow[]> {\n try {\n const processes = await this.client.requestAsync('v1.workflow.list', []);\n return processes;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets a single process from a workspace\n * \n * @param processId the id of the process in question\n * \n * @returns the specified Hailer process\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(processId: string): Promise<Workflow> {\n try {\n const process = await this.client.requestAsync('v1.workflow.get', [processId]);\n return process;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerAppConfig, HailerError } from '../types';\n\n/**\n * This class is used to access Hailer public API even when the app is outside of Hailer\n */\nexport class AppApi {\n\n constructor(private client: Client) {\n }\n\n config = {\n update: async (appId: string, config: HailerAppConfig): Promise<void> => {\n try {\n return await this.client.requestAsync('v1.app.config.update', [appId, config]);\n } catch (error: any) {\n console.log('Errorasd ', error);\n throw new HailerError(error);\n }\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, InsightData, InsightDoc } from '../types';\n\nexport class InsightApi {\n constructor(private client: Client) {}\n\n /** \n * Get Insight data \n * \n * @param insightId the id of the Insight the data is fetched from\n * \n * @returns data from the Insight\n *\n * @throws {HailerError} if request is incorrect\n */\n async data(insightId: string): Promise<InsightData> {\n try {\n return await this.client.requestAsync('v1.insight.data', [insightId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get Insight data \n * \n * \n * @returns data from the Insight\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<InsightDoc[]> {\n try {\n return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I,CAAG,CACnC,OAASa,EAAP,CACE,QAAQ,MAAM,0BAA2BA,CAAK,CAClD,CACJ,EAAC,CACL,CAEA,MAAsB,CAClB,MAAO,CACH,QAAS,KAAK,QACd,OAAQ,KAAK,OACb,QAAS,KAAK,OAClB,CACJ,CAGM,QAAQO,EAAYC,EAAa,QAAAL,EAAA,sBACnC,OAAO,MAAM,KAAK,OAAO,aAAaI,EAAIC,CAAI,CAClD,GACJ",
6
+ "names": ["Client", "write", "opts", "msg", "end", "id", "request", "retval", "err", "op", "args", "resolve", "reject", "data", "cb", "exports", "debug", "Server", "methods", "i", "j", "o", "path", "prefix", "ip", "e", "args", "context", "cb", "result", "copy", "s", "filter", "d", "clientId", "msg", "respond", "id", "err", "data", "op", "client", "send", "ctx", "reqCtx", "exports", "__exportStar", "exports", "import_wish_rpc", "HailerError", "error", "UserApi", "client", "userId", "__async", "error", "HailerError", "Kanban", "client", "processId", "options", "__async", "error", "HailerError", "activityId", "priority", "ActivityApi", "client", "Kanban", "processId", "phaseId", "options", "__async", "error", "HailerError", "activityId", "activities", "WorkspaceApi", "client", "__async", "error", "HailerError", "Activity", "client", "activityId", "options", "__async", "processId", "Snackbar", "client", "text", "buttonLabel", "duration", "__async", "Files", "client", "file", "filename", "options", "__async", "resolve", "reject", "reader", "_a", "Ui", "client", "Activity", "Snackbar", "Files", "Process", "client", "__async", "error", "HailerError", "processId", "fieldName", "_a", "_b", "field", "DEFAULT_ALLOWED_URLS", "DEFAULT_BACKEND_URL", "publicBackendMap", "App", "options", "__async", "manifestFile", "location", "manifestUrl", "manifestContent", "appId", "Form", "options", "formsKey", "__async", "res", "HailerError", "formsData", "InsightPublicApi", "options", "insightKey", "__async", "res", "HailerError", "input", "data", "row", "object", "header", "headerIndex", "HailerPublicApi", "options", "InsightPublicApi", "Form", "App", "WorkflowApi", "client", "__async", "error", "HailerError", "processId", "AppApi", "client", "appId", "config", "__async", "error", "HailerError", "InsightApi", "client", "insightId", "__async", "error", "HailerError", "HailerApi", "options", "_a", "_b", "allowedUrls", "DEFAULT_ALLOWED_URLS", "msg", "UserApi", "AppApi", "ActivityApi", "InsightApi", "WorkspaceApi", "Process", "WorkflowApi", "HailerPublicApi", "Ui", "registerMessage", "DEFAULT_BACKEND_URL", "config", "error", "url", "event", "__async", "data", "publicBackendMap", "end", "op", "args"]
7
+ }
@@ -1,12 +1,13 @@
1
- import { User } from './modules/user';
2
- import { Activity } from './modules/activity';
3
- import { Network } from './modules/network';
4
- import { ApiVersion, HailerApiInfo, HailerSettings, HailerSignal } from './types';
1
+ import { UserApi } from './modules/user';
2
+ import { ActivityApi } from './modules/activity';
3
+ import { WorkspaceApi } from './modules/network';
4
+ import { HailerApiInfo, HailerSettings, HailerSignal } from './types';
5
5
  import { Ui } from './modules/ui';
6
- import { Insight } from './modules/insight';
7
6
  import { Process } from './modules/process';
8
- import { HailerApiPublic } from './modules/public';
9
- import { Workflow } from './modules/workflow';
7
+ import { HailerPublicApi } from './modules/public';
8
+ import { WorkflowApi } from './modules/workflow';
9
+ import { AppApi } from './modules/app';
10
+ import { InsightApi } from './modules/insight';
10
11
  export interface Options {
11
12
  /** When connected is called the host is ready to receive calls */
12
13
  connected?: () => void;
@@ -27,20 +28,21 @@ export interface Options {
27
28
  /** The signals we want the Hailer frontend to pass to the app. If an empty array is provided, all signals will be passed. */
28
29
  subscribedSignals?: string[];
29
30
  /** Api version to be used in the app by default */
30
- apiVersion?: ApiVersion;
31
+ apiVersion?: 1;
31
32
  /** Public backend Api url. Defaults to https://api.hailer.com */
32
33
  publicBackendUrl?: string;
33
34
  }
34
35
  export declare class HailerApi {
35
36
  options: Options;
36
- user: User;
37
- activity: Activity;
38
- insight: Insight;
39
- network: Network;
37
+ user: UserApi;
38
+ app: AppApi;
39
+ activity: ActivityApi;
40
+ insight: InsightApi;
41
+ network: WorkspaceApi;
40
42
  process: Process;
41
- workflow: Workflow;
43
+ workflow: WorkflowApi;
42
44
  /** All public endpoints, which can be accessed while not logged in to Hailer. */
43
- public: HailerApiPublic;
45
+ public: HailerPublicApi;
44
46
  /** User interface commands */
45
47
  ui: Ui;
46
48
  /** Url of the Hailer instance hosting the API */
@@ -7,7 +7,7 @@ export declare class Kanban {
7
7
  * Lists all activities in a kanban grouped by phases
8
8
  *
9
9
  * @param processId the id of the process the kanban relates to
10
- * @param options object containing apiVersion option and requestOptions to be passed to the backend endpoint
10
+ * @param options ActivityKanbanListOptions
11
11
  *
12
12
  * @returns activities in kanban list format
13
13
  *
@@ -18,7 +18,6 @@ export declare class Kanban {
18
18
  * Loads a single activity in kanban format
19
19
  *
20
20
  * @param activityId activityId of the wanted activity
21
- * @param options object containing apiVersion option
22
21
  *
23
22
  * @returns activity in kanban format
24
23
  *
@@ -30,7 +29,6 @@ export declare class Kanban {
30
29
  *
31
30
  * @param activityId activityId of the wanted activity
32
31
  * @param priority new priority for the activity
33
- * @param options object containing apiVersion option
34
32
  *
35
33
  * @throws {HailerError} if request is incorrect
36
34
  */
@@ -1,7 +1,7 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { ActivityCreateOptions, ActivityListOptions, HailerActivity } from '../types';
2
+ import { ActivityCreateOptions, ActivityListOptions, Activity } from '../types';
3
3
  import { Kanban } from './activity/kanban';
4
- export declare class Activity {
4
+ export declare class ActivityApi {
5
5
  private client;
6
6
  kanban: Kanban;
7
7
  constructor(client: Client);
@@ -10,13 +10,13 @@ export declare class Activity {
10
10
  *
11
11
  * @param processId process from current network
12
12
  * @param phaseId phase in the process specified in processId
13
- * @param options options with apiVersion and requestOptions, default values can be found in api.hailer.com/docs v3.activity.list
13
+ * @param options ActivityListOptions
14
14
  *
15
15
  * @returns List of Hailer activities from process and phase filtered with supplied options
16
16
  *
17
17
  * @throws {HailerError} if request is incorrect
18
18
  */
19
- list(processId: string, phaseId: string, options?: ActivityListOptions): Promise<HailerActivity[]>;
19
+ list(processId: string, phaseId: string, options?: ActivityListOptions): Promise<Activity[]>;
20
20
  /**
21
21
  * Gets single activity
22
22
  *
@@ -29,7 +29,7 @@ export declare class Activity {
29
29
  *
30
30
  * @throws {HailerError} if request is incorrect
31
31
  */
32
- get(activityId: string): Promise<HailerActivity | undefined>;
32
+ get(activityId: string): Promise<Activity | undefined>;
33
33
  /**
34
34
  * Creates activities
35
35
  *
@@ -37,7 +37,7 @@ export declare class Activity {
37
37
  * @param activities new activities as objects
38
38
  * @param activities.name name of the activity
39
39
  * @param activities.fields fields of the activity
40
- * @param options optional options with apiVersion and requestOptions to be passed to the backend endpoint
40
+ * @param options ActivityCreateOptions
41
41
  *
42
42
  * @throws {HailerError} if request is incorrect
43
43
  */
@@ -46,7 +46,7 @@ export declare class Activity {
46
46
  fields: {
47
47
  [id: string]: string | number;
48
48
  };
49
- }[], options?: ActivityCreateOptions): Promise<HailerActivity[]>;
49
+ }[], options?: ActivityCreateOptions): Promise<Activity[]>;
50
50
  /**
51
51
  * Updates activites
52
52
  *
@@ -55,7 +55,7 @@ export declare class Activity {
55
55
  * @param activities.name New name of the activity
56
56
  * @param activities.fields change values of fields, null removes current value
57
57
  * @param activities.phaseId New phase of the activity
58
- * @param options options containing apiVersion
58
+ * @param options
59
59
  *
60
60
  * @returns The number of updated activities
61
61
  *
@@ -0,0 +1,12 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { HailerAppConfig } from '../types';
3
+ /**
4
+ * This class is used to access Hailer public API even when the app is outside of Hailer
5
+ */
6
+ export declare class AppApi {
7
+ private client;
8
+ constructor(client: Client);
9
+ config: {
10
+ update: (appId: string, config: HailerAppConfig) => Promise<void>;
11
+ };
12
+ }
@@ -1,13 +1,12 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
2
  import { InsightData, InsightDoc } from '../types';
3
- export declare class Insight {
3
+ export declare class InsightApi {
4
4
  private client;
5
5
  constructor(client: Client);
6
6
  /**
7
7
  * Get Insight data
8
8
  *
9
9
  * @param insightId the id of the Insight the data is fetched from
10
- * @param options object containing apiVersion option
11
10
  *
12
11
  * @returns data from the Insight
13
12
  *
@@ -17,7 +16,6 @@ export declare class Insight {
17
16
  /**
18
17
  * Get Insight data
19
18
  *
20
- * @param options object containing apiVersion option
21
19
  *
22
20
  * @returns data from the Insight
23
21
  *
@@ -1,6 +1,6 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { HailerWorkspace } from '../types';
3
- export declare class Network {
2
+ import { Workspace } from '../types';
3
+ export declare class WorkspaceApi {
4
4
  private client;
5
5
  constructor(client: Client);
6
6
  /**
@@ -10,5 +10,5 @@ export declare class Network {
10
10
  *
11
11
  * @throws {HailerError} if request is incorrect
12
12
  */
13
- current(): Promise<HailerWorkspace>;
13
+ current(): Promise<Workspace>;
14
14
  }
@@ -18,7 +18,6 @@ export declare class Process {
18
18
  * Gets a single process from a workspace
19
19
  *
20
20
  * @param processId the id of the process in question
21
- * @param options object containing apiVersion option
22
21
  *
23
22
  * @returns the specified Hailer process
24
23
  *
@@ -30,7 +29,6 @@ export declare class Process {
30
29
  *
31
30
  * @param processId the id of the process in question
32
31
  * @param fieldName name of the field
33
- * @param options object containing apiVersion option
34
32
  *
35
33
  * @returns the field id as string
36
34
  *
@@ -1,6 +1,6 @@
1
1
  import { Options } from '../../hailer-api';
2
2
  import { InsightResponse, InsightResponseAsObjects } from '../../types';
3
- export declare class Insight {
3
+ export declare class InsightPublicApi {
4
4
  private options;
5
5
  constructor(options: Options);
6
6
  /**
@@ -1,13 +1,13 @@
1
1
  import { Options } from '../hailer-api';
2
2
  import { App } from './public/app';
3
3
  import { Form } from './public/form';
4
- import { Insight } from './public/insight';
4
+ import { InsightPublicApi } from './public/insight';
5
5
  /**
6
6
  * This class is used to access Hailer public API even when the app is outside of Hailer
7
7
  */
8
- export declare class HailerApiPublic {
8
+ export declare class HailerPublicApi {
9
9
  /** Allows accessing public insight methods. Used for reading data from Hailer even when app is outside of Hailer */
10
- insight: Insight;
10
+ insight: InsightPublicApi;
11
11
  /** Allows accessing public forms methods. Used for sending data to Hailer even when app is outside of Hailer */
12
12
  form: Form;
13
13
  /** Access public App information */
@@ -21,5 +21,8 @@ export declare class Activity {
21
21
  end: number;
22
22
  };
23
23
  };
24
- }): Promise<void>;
24
+ }): Promise<{
25
+ _id: string;
26
+ name: string;
27
+ } | null>;
25
28
  }
@@ -7,7 +7,6 @@ export declare class Snackbar {
7
7
  * @param text the text displayed on the snackbar
8
8
  * @param buttonLabel the label for the button on the snackbar, for example 'OK'
9
9
  * @param duration the time the snackbar is visible in ms
10
- * @param options object containing apiVersion option
11
10
  */
12
11
  open(
13
12
  /** The text displayed on the snackbar */
@@ -1,39 +1,36 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { HailerUser } from '../types';
3
- export declare class User {
2
+ import { User } from '../types';
3
+ export declare class UserApi {
4
4
  private client;
5
5
  constructor(client: Client);
6
6
  /**
7
7
  * Returns the specified user
8
8
  *
9
9
  * @param userId id of the Hailer user
10
- * @param options object containing apiVersion option
11
10
  *
12
11
  * @returns Hailer user information
13
12
  *
14
13
  * @throws {HailerError} if request is incorrect
15
14
  */
16
- get(userId: string): Promise<HailerUser>;
15
+ get(userId: string): Promise<User>;
17
16
  /**
18
17
  * Returns the current user
19
18
  *
20
- * @param options object containing apiVersion option
21
19
  *
22
20
  * @returns the current Hailer user information
23
21
  *
24
22
  * @throws {HailerError} if request is incorrect
25
23
  */
26
- current(): Promise<HailerUser>;
24
+ current(): Promise<User>;
27
25
  /**
28
26
  * Lists all Hailer users from a workspace
29
27
  *
30
- * @param options object containing apiVersion option
31
28
  *
32
29
  * @returns list of Hailer users in the workspace the app user is currently in
33
30
  *
34
31
  * @throws {HailerError} if request is incorrect
35
32
  */
36
33
  list(): Promise<{
37
- [key: string]: HailerUser;
34
+ [key: string]: User;
38
35
  }>;
39
36
  }
@@ -1,6 +1,6 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { HailerProcess } from '../types';
3
- export declare class Workflow {
2
+ import { Workflow } from '../types';
3
+ export declare class WorkflowApi {
4
4
  private client;
5
5
  constructor(client: Client);
6
6
  /**
@@ -10,16 +10,15 @@ export declare class Workflow {
10
10
  *
11
11
  * @throws {HailerError} if request is incorrect
12
12
  */
13
- list(): Promise<HailerProcess[]>;
13
+ list(): Promise<Workflow[]>;
14
14
  /**
15
15
  * Gets a single process from a workspace
16
16
  *
17
17
  * @param processId the id of the process in question
18
- * @param options object containing apiVersion option
19
18
  *
20
19
  * @returns the specified Hailer process
21
20
  *
22
21
  * @throws {HailerError} if request is incorrect
23
22
  */
24
- get(processId: string): Promise<HailerProcess>;
23
+ get(processId: string): Promise<Workflow>;
25
24
  }
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export interface HailerUser {
1
+ export interface User {
2
2
  firstname: string;
3
3
  lastname: string;
4
4
  email: string;
@@ -7,7 +7,7 @@ export interface HailerUser {
7
7
  managedUser?: boolean;
8
8
  removed?: number;
9
9
  }
10
- export interface HailerWorkspace {
10
+ export interface Workspace {
11
11
  _id: string;
12
12
  name: string;
13
13
  members: string[];
@@ -26,7 +26,7 @@ export interface HailerWorkspace {
26
26
  };
27
27
  };
28
28
  }
29
- export interface HailerActivity {
29
+ export interface Activity {
30
30
  _id: string;
31
31
  process: string;
32
32
  teamAccount: TeamAccount;
@@ -59,13 +59,6 @@ export interface TeamAccount {
59
59
  account: string;
60
60
  team: string;
61
61
  }
62
- export interface Link {
63
- id: string;
64
- linkId: string;
65
- type: LinkType;
66
- created: string;
67
- }
68
- export type LinkType = 'user-mention' | 'reaction' | 'tag' | 'apple-id' | 'feed.lastseen' | 'google-folder-id';
69
62
  export interface FormsData {
70
63
  files: string[];
71
64
  history: {
@@ -147,7 +140,8 @@ export interface HailerAppConfig {
147
140
  };
148
141
  };
149
142
  }
150
- export interface HailerProcess {
143
+ export type HailerProcess = Workflow;
144
+ export interface Workflow {
151
145
  _id: string;
152
146
  cid: string;
153
147
  name: string;
@@ -156,16 +150,17 @@ export interface HailerProcess {
156
150
  [fieldId: string]: any;
157
151
  };
158
152
  phases: {
159
- [phase_id: string]: HailerPhase;
153
+ [phase_id: string]: WorkflowPhase;
160
154
  };
155
+ phasesOrder: string[];
161
156
  }
162
- export interface HailerPhase {
157
+ export interface WorkflowPhase {
163
158
  _id: string;
164
159
  name: string;
165
160
  description?: string;
166
161
  }
167
162
  export type PermissionType = 'admin' | 'own' | 'ownteam' | 'any' | 'edit';
168
- export interface MemberDoc {
163
+ export interface Member {
169
164
  id: string;
170
165
  info: {
171
166
  [key: string]: string | number | boolean | null;
@@ -190,7 +185,7 @@ export interface InsightDoc {
190
185
  cid: string;
191
186
  /** User id of creator */
192
187
  uid: string;
193
- members: MemberDoc[];
188
+ members: Member[];
194
189
  updated: number;
195
190
  public: boolean;
196
191
  /** Key for accessing Insight when set to public */
@@ -294,7 +289,6 @@ export interface ActivityKanbanListOptions {
294
289
  includeUsers?: boolean;
295
290
  includeTeams?: boolean;
296
291
  }
297
- export type ApiVersion = 1;
298
292
  export interface HailerSettings {
299
293
  theme: 'light' | 'dark';
300
294
  preferredLanguages: string[];