@hailer/app-sdk 2.2.0 → 2.3.0
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 +2 -2
- package/lib/app-sdk.js.map +4 -4
- package/lib/modules/activity/ball.d.ts +34 -0
- package/lib/modules/activity.d.ts +2 -0
- package/lib/modules/ui/sidestack.d.ts +39 -0
- package/lib/tools/publish.cjs +2 -4
- package/lib/tools/publish.cjs.map +1 -1
- package/lib/types.d.ts +10 -0
- package/package.json +1 -1
package/lib/app-sdk.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
Field: ${this.details}, ${this.debug}`}};var f=class{constructor(e){this.client=e}async get(e){try{return await this.client.requestAsync("user.get",[e])}catch(t){throw new n(t)}}async current(){try{return await this.client.requestAsync("user.current",[])}catch(e){throw new n(e)}}async list(){try{return await this.client.requestAsync("user.list",[])}catch(e){throw new n(e)}}};var b=class{constructor(e){this.client=e}async list(e,t){try{return await this.client.requestAsync("activity.kanban.list",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async load(e){try{return await this.client.requestAsync("activity.kanban.load",[e])}catch(t){throw new n(t)}}async updatePriority(e,t){try{return await this.client.requestAsync("activity.kanban.updatePriority",[{activityId:e,priority:t}])}catch(i){throw new n(i)}}};var w=class{constructor(e){this.client=e;this.kanban=new b(e)}async list(e,t,i){try{return await this.client.requestAsync("activity.list",[e,t,i])}catch(r){throw new n(r)}}async get(e){try{return await this.client.requestAsync("activity.get",[e])}catch(t){throw new n(t)}}async create(e,t,i){try{return await this.client.requestAsync("activity.create",[e,t,...i?[i]:[]])}catch(r){throw new n(r)}}async update(e,t){try{return await this.client.requestAsync("activity.update",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async remove(e){try{return await this.client.requestAsync("activity.remove",[e])}catch(t){throw new n(t)}}async print(e){try{return await this.client.requestAsync("activity.print",[e])}catch(t){throw new n(t)}}};var A=class{constructor(e){this.client=e;this.product={publishTemplate:this.publishTemplate.bind(this),isProductInstalled:this.isProductInstalled.bind(this),get:this.get.bind(this),install:this.install.bind(this),getManifest:this.getManifest.bind(this)}}async current(){try{return await this.client.requestAsync("workspace.current",[])}catch(e){throw new n(e)}}async list(){try{return await this.client.requestAsync("workspace.list",[])}catch(e){throw new n(e)}}async publishTemplate(e){try{return await this.client.requestAsync("workspace.product.publishTemplate",[e])}catch(t){throw new n(t)}}async isProductInstalled(e,t){try{return await this.client.requestAsync("workspace.product.isProductInstalled",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("workspace.product.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("workspace.product.install",[e,t])}catch(i){throw new n(i)}}async getManifest(e){try{return await this.client.requestAsync("workspace.product.getManifest",[e])}catch(t){throw new n(t)}}};var P=class{constructor(e){this.client=e}async list(){try{return await this.client.requestAsync("team.list",[])}catch(e){throw new n(e)}}};var v=class{constructor(e){this.client=e}async get(e){try{return await this.client.requestAsync("file.get",[e])}catch(t){throw new n(t)}}async upload(e,t,i){try{let r=await this.toBase64(e);return await this.client.requestAsync("file.upload",[r,t,!!i?.isPublic])}catch(r){throw new n(r)}}toBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result??""),r.onerror=i})}};var k=class{constructor(e){this.client=e}async open(e,t){await this.client.requestAsync("ui.activity.open",[e,...t?[t]:[]])}async create(e,t){return await this.client.requestAsync("ui.activity.create",[e,...t?[t]:[]])}async editMultiple(e){return await this.client.requestAsync("ui.activity.editMultiple",[e])}};var q=class{constructor(e){this.client=e}async open(e,t){await this.client.requestAsync("ui.discussion.open",[e,...t?[t]:[]])}};var R=class{constructor(e){this.client=e}async open(e,t,i){await this.client.requestAsync("ui.snackbar.open",[e,t,i])}};var x=class{constructor(e){this.client=e}async uploadFile(e,t,i){return await this.client.requestAsync("ui.file.upload",[await this.toBase64(e),t,!!i?.isPublic])}toBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result??""),r.onerror=i})}};var I=class{constructor(e){this.client=e;this.function={edit:async(e,t)=>{await this.client.requestAsync("ui.workflow.function.edit",[e,t])}}}};var T=class{constructor(e){this.client=e;this.activity=new k(e),this.discussion=new q(e),this.snackbar=new R(e),this.workflow=new I(e),this.insight={create:async t=>{await e.requestAsync("ui.insight.create",[t])},edit:async t=>{await e.requestAsync("ui.insight.edit",[t])},delete:async t=>{await e.requestAsync("ui.insight.delete",[t])},permission:async t=>{await e.requestAsync("ui.insight.permission",[t])}},this.files=new x(e)}};var te=["https://app.hailer.com","https://next.hailer.com","https://testapp.hailer.biz","https://app.hailer.biz","https://app.hailer.local.gd","https://app.k8s.hailer.com","https://next.k8s.hailer.com","https://localhost:9443"],g="https://api.hailer.com",re={"https://app.hailer.com":g,"https://next.hailer.com":g,"https://app.hailer.biz":"https://api.hailer.biz","https://testapp.hailer.biz":"https://testapi.hailer.biz","https://app.hailer.local.gd":"https://api.hailer.local.gd","https://app.k8s.hailer.com":"https://api.k8s.hailer.com","https://next.k8s.hailer.com":"https://api.k8s.hailer.com","https://localhost:9443":"http://localhost:1337"};var C=class{constructor(e){this.options=e}async config(){let e="manifest.json",t=window.location.origin+window.location.pathname,i=t+e;t.endsWith("/index.html")&&(i=t.slice(0,-10)+e);let r=await(await fetch(i)).text(),a=JSON.parse(r).appId;return await(await fetch(this.options.publicBackendUrl+"/api/v3/app/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([a])})).json()}};var S=class{constructor(e){this.options=e}async data(e){let t=await fetch(this.options.publicBackendUrl+"/api/v2/forms/process/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}async submit(e,t){let i=await fetch(this.options.publicBackendUrl+"/api/v2/forms/activity/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e,t])});if(!i.ok)throw new n(await i.json());return await i.json()}};var U=class{constructor(e){this.options=e}async data(e){let t=await fetch(this.options.publicBackendUrl+"/api/v3/insight/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}async dataAsObject(e){let i=(await this.data(e)).data,r=[];return i.rows.forEach(s=>{let a={};i.headers.forEach((u,m)=>{a[u]=s[m]}),r.push(a)}),r}};var O=class{constructor(e){this.options=e}async list(e,t){let i=await fetch(this.options.publicBackendUrl+"/api/v3/product/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e,t])});if(!i.ok)throw new n(await i.json());return await i.json()}async get(e){let t=await fetch(this.options.publicBackendUrl+"/api/v3/product/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}};var L=class{constructor(e){this.insight=new U(e),this.form=new S(e),this.app=new C(e),this.product=new O(e)}};var W=class{constructor(e){this.client=e}async list(){try{return await this.client.requestAsync("workflow.list",[])}catch(e){throw console.error(e.msg,e),new n(e)}}async get(e){try{return await this.client.requestAsync("workflow.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("workflow.install",[e,t])}catch(i){throw new n(i)}}};var _=class{constructor(e){this.client=e;this.config={update:async(e,t)=>{try{return await this.client.requestAsync("app.config.update",[e,...t?[t]:[]])}catch(i){throw console.log("Errorasd ",i),new n(i)}}};this.product={isProductInstalled:this.isProductInstalled.bind(this),get:this.get.bind(this),install:this.install.bind(this),getInstalledVersion:this.getInstalledVersion.bind(this),getManifest:this.getManifest.bind(this)}}async isProductInstalled(e,t){try{return await this.client.requestAsync("app.product.isProductInstalled",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("app.product.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("app.product.install",[e,t])}catch(i){throw new n(i)}}async getInstalledVersion(e){try{return await this.client.requestAsync("app.product.getInstalledVersion",[e])}catch(t){throw new n(t)}}async getManifest(e){try{return await this.client.requestAsync("app.product.getManifest",[e])}catch(t){throw new n(t)}}};var D=class{constructor(e){this.client=e}async data(e,t){try{return await this.client.requestAsync("insight.data",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async list(){try{return await this.client.requestAsync("insight.list",[])}catch(e){throw new n(e)}}async update(e,t){try{return await this.client.requestAsync("insight.update",[e,t])}catch(i){throw new n(i)}}};var E=class{constructor(e){this.client=e;this.map=async()=>{try{return await this.client.requestAsync("permission.map",[])}catch(e){throw console.log("Failed to read permissions from Hailer, error:",e),new n(e)}}}};var M=class{constructor(e){this.client=e}async list(e,t){try{return await this.client.requestAsync("product.list",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("product.get",[e])}catch(t){throw new n(t)}}async create(e){try{return await this.client.requestAsync("product.create",[e])}catch(t){throw new n(t)}}async update(e,t){try{return await this.client.requestAsync("product.update",[e,t])}catch(i){throw new n(i)}}async remove(e){try{return await this.client.requestAsync("product.remove",[e])}catch(t){throw new n(t)}}async setPublic(e,t){try{return await this.client.requestAsync("product.setPublic",[e,t])}catch(i){throw new n(i)}}};var F=class{constructor(e){this.client=e}async createPricing(e){try{return await this.client.requestAsync("payment.createPricing",[e])}catch(t){throw new n(t)}}async updatePricing(e){try{return await this.client.requestAsync("payment.updatePricing",[e])}catch(t){throw new n(t)}}async getPricing(e){try{return await this.client.requestAsync("payment.getPricing",[{productId:e}])}catch(t){throw new n(t)}}async createPurchase(e){try{return await this.client.requestAsync("payment.createPurchase",[e])}catch(t){throw new n(t)}}async getPurchases(e){try{return await this.client.requestAsync("payment.getPurchases",[{workspaceId:e}])||[]}catch(t){throw new n(t)}}async calculateStripeTax(e){try{return await this.client.requestAsync("payment.calculateStripeTax",[e])}catch(t){throw new n(t)}}};var N=class{constructor(e){this.client=e;this.referral={listCodes:async e=>{try{return await this.client.requestAsync("admin.referral.listCodes",[e?.filter||null,e?.options||null])}catch(t){throw new n(t)}},listEvents:async e=>{try{return await this.client.requestAsync("admin.referral.listEvents",[e?.filter||null,e?.options||null])}catch(t){throw new n(t)}},updateCode:async(e,t)=>{try{return await this.client.requestAsync("admin.referral.updateCode",[{codeId:e,...t}])}catch(i){throw new n(i)}}}}async listWorkspaces(e){try{return await this.client.requestAsync("admin.workspace.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async getWorkspace(e){try{return await this.client.requestAsync("admin.workspace.get",[e])}catch(t){throw new n(t)}}async createStripeSession(e){try{return await this.client.requestAsync("admin.workspace.createStripeSession",[e])}catch(t){throw new n(t)}}async createInvoiceIntegration(e){try{return await this.client.requestAsync("admin.workspace.createInvoiceIntegration",[e])}catch(t){throw new n(t)}}async updateWorkspaceSubscription(e){try{return await this.client.requestAsync("admin.workspace.updateSubscription",[e])}catch(t){throw new n(t)}}async updatePurchasePrice(e){try{return await this.client.requestAsync("admin.purchase.updatePrice",[e])}catch(t){throw new n(t)}}async listWorkspaceUsers(e){try{return await this.client.requestAsync("admin.workspace.listUsers",[e.workspaceId,e.filter,e.options])}catch(t){throw new n(t)}}async updateUser(e){try{return await this.client.requestAsync("admin.user.update",[e.userId,e.updates])}catch(t){throw new n(t)}}async updateTokenBalance(e){try{return await this.client.requestAsync("admin.workspace.updateTokenBalance",[e])}catch(t){throw new n(t)}}async updateWorkspaceOverrides(e){try{return await this.client.requestAsync("admin.workspace.updateOverrides",[e])}catch(t){throw new n(t)}}async updateWorkspaceMarketplaceSettings(e){try{return await this.client.requestAsync("admin.workspace.updateMarketplaceSettings",[e])}catch(t){throw new n(t)}}async listTokenTransactions(e){try{return await this.client.requestAsync("admin.tokenTransaction.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async listInvoices(e){try{return await this.client.requestAsync("admin.invoice.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async updateInvoiceHandled(e){try{return await this.client.requestAsync("admin.invoice.updateHandled",[e.purchaseIds,e.handled])}catch(t){throw new n(t)}}async listMonthlyRevenue(e){try{return await this.client.requestAsync("admin.revenue.list",[e.month,e.year,e.filter,e.options])}catch(t){throw new n(t)}}async getDashboardStatistics(e){try{return await this.client.requestAsync("admin.dashboard.statistics",[e])}catch(t){throw new n(t)}}async getDashboardTrends(e,t){try{return await this.client.requestAsync("admin.dashboard.trends",[e,t])}catch(i){throw new n(i)}}};var B=class{constructor(e){this.client=e;this.admin={workspacesList:async e=>{try{return await this.client.requestAsync("metrics.workspaceSearch",[e])}catch(t){throw new n(t)}},usersList:async e=>{try{return await this.client.requestAsync("metrics.user.list",[e])}catch(t){throw new n(t)}}}}async list(e){try{return await this.client.requestAsync("metrics.list",e?[e]:[])}catch(t){throw new n(t)}}async get(e,t){try{let i=Array.isArray(e)?e:[e];return await this.client.requestAsync("metrics.get",[i,t])}catch(i){throw new n(i)}}};var z=class{constructor(e,t){this.client=e;this.onopen=null;this.onmessage=null;this.onclose=null;this.onerror=null;this.readyState=WebSocket.CONNECTING;this.connectionId=null;this.client.request("http.ws.open",[t],(i,r)=>{if(i){this.readyState=WebSocket.CLOSED,this.onerror?.({error:i});return}if(r)switch(r.connectionId&&!this.connectionId&&(this.connectionId=r.connectionId),r.event){case"open":this.readyState=WebSocket.OPEN,this.onopen?.({});break;case"message":this.onmessage?.({data:r.data??""});break;case"close":this.readyState=WebSocket.CLOSED,this.onclose?.({code:r.code,reason:r.reason});break;case"error":this.onerror?.({error:r.data});break}})}send(e){if(this.readyState!==WebSocket.OPEN||!this.connectionId)throw new Error("WebSocket is not open");this.client.requestAsync("http.ws.send",[this.connectionId,e]).catch(t=>{this.onerror?.({error:t})})}close(e,t){this.connectionId&&this.client.requestAsync("http.ws.close",[this.connectionId,e,t]).catch(i=>{this.onerror?.({error:i})}),this.readyState=WebSocket.CLOSING}},j=class{constructor(e){this.client=e}async fetch(e,t){return await this.client.requestAsync("http.fetch",[e,t]).catch(i=>{throw i})}async upload(e,t){return await this.client.requestAsync("http.upload",[e,t]).catch(i=>{throw i})}openWebSocket(e){return new z(this.client,e)}};var Y=class{constructor(e={}){this.options=e;this.outside=null;let t=e.allowedUrls??te;this.client=new ie.Client(r=>{this.hostUrl&&parent.postMessage(JSON.stringify(r),this.hostUrl)}),this.user=new f(this.client),this.app=new _(this.client),this.activity=new w(this.client),this.insight=new D(this.client),this.workspace=new A(this.client),this.team=new P(this.client),this.file=new v(this.client),this.workflow=new W(this.client),this.permission=new E(this.client),this.public=new L(this.options),this.ui=new T(this.client),this.product=new M(this.client),this.payment=new F(this.client),this.admin=new N(this.client),this.metrics=new B(this.client),this.http=new j(this.client);let i=JSON.stringify({op:"register",args:[{appApiVersion:"2"}]});window.location===window.parent.location?(this.options.publicBackendUrl||(this.options.publicBackendUrl=g),this.public.app.config().then(r=>{this.outside=!0,this.options.outside?.(r)}).catch(r=>{this.options.error?.(r),console.error("Failed to get app configuration in Public App.",r)})):(t.forEach(r=>parent.postMessage(i,r)),this.timer=setTimeout(()=>{this.outside=!0,this.options.outside?.()},100)),this.createEventListener()}createEventListener(){window.addEventListener("message",async e=>{let t=e.data;try{let i=JSON.parse(t);if(i.op==="register"){if(this.appId){console.error("App Id is already set...! Are you using hot-reload?");return}clearTimeout(this.timer),this.appId=i.data.appId,this.workspaceId=i.data.workspaceId,this.hostUrl=e.origin,this.options.publicBackendUrl||(this.options.publicBackendUrl=re[this.hostUrl]||g),this.client.request("ui.settings",[],(r,s,a)=>{if(r){console.log("ui.settings error:",r,s);return}this.options.settings?.(s)}),this.client.request("config",[],(r,s,a)=>{if(r){console.log("config error:",r,s);return}this.options.config?.(s)}),this.client.request("signal",[],(r,s,a)=>{if(r){console.log("signal error:",r,s);return}s&&this.options.signals?.(s)}),this.outside=!1,this.options.connected?.();return}if(!this.appId)return;this.client.messageReceived(i)}catch{console.log("Dropped invalid JSON message")}})}info(){return{hostUrl:this.hostUrl,config:this.config,outside:this.outside,workspaceId:this.workspaceId}}};export{Y as HailerApi,n as HailerError,B as MetricsApi};
|
|
1
|
+
var se=Object.create;var Q=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var K=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var pe=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ae(e))!ue.call(o,r)&&r!==t&&Q(o,r,{get:()=>e[r],enumerable:!(i=oe(e,r))||i.enumerable});return o};var le=(o,e,t)=>(t=o!=null?se(ce(o)):{},pe(e||!o||!o.__esModule?Q(t,"default",{value:o,enumerable:!0}):t,o));var X=K(d=>{"use strict";var de=d&&d.__awaiter||function(o,e,t,i){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function u(c){try{l(i.next(c))}catch(V){a(V)}}function m(c){try{l(i.throw(c))}catch(V){a(V)}}function l(c){c.done?s(c.value):r(c.value).then(u,m)}l((i=i.apply(o,e||[])).next())})};Object.defineProperty(d,"__esModule",{value:!0});d.Client=void 0;var J=class{constructor(e,t){this.write=e,this.requests={},this.id=0,this.mtu=65535,t&&t.mtu&&(this.mtu=t.mtu)}destroy(){this.requests=null,this.write=null}messageReceived(e){let t=!!(e.err||e.ack||e.fin),i=e.ack||e.err||e.sig||e.fin,r=this.requests[i],s;if(r&&typeof r.cb=="function"){let a;e.fin?r.cb.call(r.context,null,null,!0):r.canceled?console.log("This request is canceled. Not calling the callback."):(a=e.err?e.data:null,s=r.cb.call(r.context,a,e.data,t))}return t&&delete this.requests[i],s}requestAsync(e,t){return de(this,void 0,void 0,function*(){return new Promise((i,r)=>{this.request(e,t,(s,a)=>{if(s)return r(a);i(a)})})})}request(e,t,i){this.id++;let r={op:e};return Array.isArray(t)&&(r.args=t),i&&(r.id=this.id,this.requests[r.id]={cb:i,context:{id:r.id,cancel:()=>{setTimeout((s=>()=>{this.requests[s]&&console.log("rpc-client.js: timeout, the request has not been removed while it was canceled",s,this.requests[s])})(r.id),1500),this.requests[r.id].canceled=!0,this.write({end:r.id})},emit:s=>this.write({sig:r.id,data:s})}}),this.write(r),r.id||null}send(e,t){this.write({push:e,data:t})}end(e){this.write({end:e})}};d.Client=J});var Z=K(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.Server=void 0;var h=console.log,G=class{constructor(e){this.modules={},this.methods={},this.requests={},this.clientIdCounter=0,this.requestId=0,this.invokeId=0,e&&this.insertMethods(e)}destroy(){for(let e in this.requests){for(let t in this.requests[e])typeof this.requests[e][t].end=="function"&&this.requests[e][t].end();delete this.requests[e]}}insertMethods(e){this.addMethods("",e)}addMethods(e,t){let i=e?e+".":"";for(let r in t)if(r!=="_"){if(r.substring(0,1)!=="_"&&t["_"+r])if(typeof t[r]=="function"){let s=t["_"+r].name||r;t["_"+r].fullname=i+s;try{this.modules[i+s]=t["_"+r],this.methods[i+s]=t[r]}catch(a){console.log("Kaboom! ",a)}}else typeof t[r]=="object"&&this.addMethods(i+r,t[r])}}listMethods(e,t,i){let r={};function s(u,m){let l={};for(let c in u)m[c]||(l[c]=u[c]);return l}let a={fullname:!0};for(let u in this.modules)r[u]=s(this.modules[u],a);i(null,r)}clientOffline(e){for(let t in this.requests[e])typeof this.requests[e][t].end=="function"&&this.requests[e][t].end(),delete this.requests[e][t]}closeAll(){for(let e in this.requests)for(let t in this.requests[e])typeof this.requests[e][t].end=="function"&&this.requests[e][t].end(),delete this.requests[e][t]}parse(e,t,i,r){if(typeof r=="number")try{if(e.push){this.requests[r]&&this.requests[r][e.push]&&this.invokeRaw(e,t,this.requests[r][e.push].context,r);return}if(e.sig){this.requests[r]&&this.requests[r][e.sig]&&this.invokeRaw(e,t,this.requests[r][e.sig].context,r);return}if(e.end){let s=e.end;if(this.requests[r]&&this.requests[r][s]){typeof this.requests[r][s].end=="function"&&this.requests[r][s].end(),t({fin:s}),delete this.requests[r][s];return}if(!this.requests[r][s])return;typeof this.requests[r][s].end=="function"&&this.requests[s].end();return}if(e.op==="methods"){this.listMethods(e.args,i,function(s,a){t({ack:e.id,data:a})});return}if(typeof this.methods[e.op]>"u"){t({err:e.id,data:{code:300,msg:"No method found: "+e.op}});return}this.invokeRaw(e,t,i,r)}catch(s){h("Dynamic RPC failed to execute ",e.op,s,s.stack);try{console.log("RPC caught error",s.stack),t({ack:e.id,err:e.id,data:"caught error in "+e.op+": "+s.toString(),debug:s.stack})}catch(a){t({err:e.id,data:"rpc",errmsg:a.toString()})}}}emit(e,t){for(let i in this.requests)if(this.requests[i]){for(let r in this.requests[i])if(this.requests[i][r].op===e){let{send:s}=this.requests[i][r];s({sig:r,data:t})}}}invokeRaw(e,t,i,r){if(++this.requestId,!this.requests[r])return console.log("Session not opened for client. Use Server.open() first");if(e.push){let s=this.requests[r][e.push];if(e.data===null){console.log("msg.data is null:",e);return}s.data(e.data);return}if(e.sig){let s=this.requests[r][e.sig];try{this.methods[s.op].call(this.requests[r][e.sig],e.data,{send:a=>{typeof s.end=="function"&&s.end(),this.requests[r][e.sig]&&delete this.requests[r][e.sig],t({ack:e.sig,data:a})},emit:a=>(this.requests[r][e.sig]||typeof s.end=="function"&&s.end(),t({sig:e.sig,data:a})),error:a=>{typeof s.end=="function"&&s.end(),delete this.requests[r][e.sig],t({err:e.sig,data:a})},close:a=>{typeof s.end=="function"&&s.end(),delete this.requests[r][e.sig],t({fin:e.sig})}},i)}catch(a){console.log("Calling the method in RPC failed:",e.op,e.args,a.stack),delete this.requests[r][e.sig],t({err:e.sig,data:{msg:"rpc failed during execution of "+e.op,code:578}})}return}if(typeof e.id>"u"){let s={};this.methods[e.op].call(s,{args:e.args},{send:()=>{h("Trying to send response to event ("+e.op+"). Dropping.")},emit:()=>{h("Trying to emit response to event ("+e.op+"). Dropping.")},error:()=>{h("Trying to respond with error to event ("+e.op+"). Dropping.")},close:()=>{h("Trying to close event ("+e.op+"). Dropping.")}},i)}else{let s={id:e.id,op:e.op,args:e.args,context:i,end:null,send:t};this.requests[r]||(this.requests[r]={}),this.requests[r][e.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:",r,"msg",e,"stack trace:",new Error().stack),typeof this.requests[r][e.id].end=="function"&&this.requests[r][e.id].end(),delete this.requests[r][e.id],console.log("Removed old request by same id from same client...")),this.requests[r][e.id]=s;try{this.methods[e.op].call(s,{args:e.args},{send:a=>{typeof s.end=="function"&&s.end(),this.requests[r][e.id]&&delete this.requests[r][e.id],t({ack:e.id,data:a})},emit:a=>(this.requests[r][e.id]||typeof s.end=="function"&&s.end(),t({sig:e.id,data:a})),error:a=>{typeof s.end=="function"&&s.end(),delete this.requests[r][e.id],t({err:e.id,data:a})},close:a=>{typeof s.end=="function"&&s.end(),delete this.requests[r][e.id],t({fin:e.id})}},i)}catch(a){console.log("Calling the method in RPC failed:",e.op,e.args,a.stack),delete this.requests[r][e.id],t({err:e.id,data:{msg:"rpc failed during execution of "+e.op,code:578}})}}}close(e){for(let t in this.requests[e])typeof this.requests[e][t].end=="function"&&this.requests[e][t].end(),delete this.requests[e][t];delete this.requests[e]}open(){let e=++this.clientIdCounter;return this.requests[e]={},e}};y.Server=G});var te=K(p=>{"use strict";var me=p&&p.__createBinding||(Object.create?function(o,e,t,i){i===void 0&&(i=t),Object.defineProperty(o,i,{enumerable:!0,get:function(){return e[t]}})}:function(o,e,t,i){i===void 0&&(i=t),o[i]=e[t]}),ee=p&&p.__exportStar||function(o,e){for(var t in o)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&me(e,o,t)};Object.defineProperty(p,"__esModule",{value:!0});ee(X(),p);ee(Z(),p)});var ne=le(te(),1);var z=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.msg=e,this.code=t,Error.captureStackTrace?.(this,this.constructor)}},n=class extends z{constructor(e){super(e.msg,e.code),this.details=e.details,this.debug=e.debug}toString(){return console.log("Going to log an error... ;-D"),`${super.toString()}
|
|
2
|
+
Field: ${this.details}, ${this.debug}`}};var f=class{constructor(e){this.client=e}async get(e){try{return await this.client.requestAsync("user.get",[e])}catch(t){throw new n(t)}}async current(){try{return await this.client.requestAsync("user.current",[])}catch(e){throw new n(e)}}async list(){try{return await this.client.requestAsync("user.list",[])}catch(e){throw new n(e)}}};var b=class{constructor(e){this.client=e}async list(e,t){try{return await this.client.requestAsync("activity.kanban.list",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async load(e){try{return await this.client.requestAsync("activity.kanban.load",[e])}catch(t){throw new n(t)}}async updatePriority(e,t){try{return await this.client.requestAsync("activity.kanban.updatePriority",[{activityId:e,priority:t}])}catch(i){throw new n(i)}}};var w=class{constructor(e){this.client=e}async pass(e,t){try{return await this.client.requestAsync("activity.ball.pass",[e,t])}catch(i){throw new n(i)}}async take(e){try{return await this.client.requestAsync("activity.ball.take",[e])}catch(t){throw new n(t)}}async list(e){if(Array.isArray(e)&&e.length===0)return[];try{return await this.client.requestAsync("activity.ball.list",[e])}catch(t){throw new n(t)}}};var A=class{constructor(e){this.client=e;this.kanban=new b(e),this.ball=new w(e)}async list(e,t,i){try{return await this.client.requestAsync("activity.list",[e,t,i])}catch(r){throw new n(r)}}async get(e){try{return await this.client.requestAsync("activity.get",[e])}catch(t){throw new n(t)}}async create(e,t,i){try{return await this.client.requestAsync("activity.create",[e,t,...i?[i]:[]])}catch(r){throw new n(r)}}async update(e,t){try{return await this.client.requestAsync("activity.update",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async remove(e){try{return await this.client.requestAsync("activity.remove",[e])}catch(t){throw new n(t)}}async print(e){try{return await this.client.requestAsync("activity.print",[e])}catch(t){throw new n(t)}}};var P=class{constructor(e){this.client=e;this.product={publishTemplate:this.publishTemplate.bind(this),isProductInstalled:this.isProductInstalled.bind(this),get:this.get.bind(this),install:this.install.bind(this),getManifest:this.getManifest.bind(this)}}async current(){try{return await this.client.requestAsync("workspace.current",[])}catch(e){throw new n(e)}}async list(){try{return await this.client.requestAsync("workspace.list",[])}catch(e){throw new n(e)}}async publishTemplate(e){try{return await this.client.requestAsync("workspace.product.publishTemplate",[e])}catch(t){throw new n(t)}}async isProductInstalled(e,t){try{return await this.client.requestAsync("workspace.product.isProductInstalled",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("workspace.product.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("workspace.product.install",[e,t])}catch(i){throw new n(i)}}async getManifest(e){try{return await this.client.requestAsync("workspace.product.getManifest",[e])}catch(t){throw new n(t)}}};var v=class{constructor(e){this.client=e}async list(){try{return await this.client.requestAsync("team.list",[])}catch(e){throw new n(e)}}};var k=class{constructor(e){this.client=e}async get(e){try{return await this.client.requestAsync("file.get",[e])}catch(t){throw new n(t)}}async upload(e,t,i){try{let r=await this.toBase64(e);return await this.client.requestAsync("file.upload",[r,t,!!i?.isPublic])}catch(r){throw new n(r)}}toBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result??""),r.onerror=i})}};var q=class{constructor(e){this.client=e}async open(e,t){await this.client.requestAsync("ui.activity.open",[e,...t?[t]:[]])}async create(e,t){return await this.client.requestAsync("ui.activity.create",[e,...t?[t]:[]])}async editMultiple(e){return await this.client.requestAsync("ui.activity.editMultiple",[e])}};var R=class{constructor(e){this.client=e}async open(e,t){await this.client.requestAsync("ui.discussion.open",[e,...t?[t]:[]])}};var x=class{constructor(e){this.client=e}async open(e,t,i){await this.client.requestAsync("ui.snackbar.open",[e,t,i])}};var I=class{constructor(e){this.client=e}async uploadFile(e,t,i){return await this.client.requestAsync("ui.file.upload",[await this.toBase64(e),t,!!i?.isPublic])}toBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result??""),r.onerror=i})}};var T=class{constructor(e){this.client=e;this.function={edit:async(e,t)=>{await this.client.requestAsync("ui.workflow.function.edit",[e,t])}}}};var C=class{constructor(e){this.client=e;this.activity=new q(e),this.discussion=new R(e),this.snackbar=new x(e),this.workflow=new T(e),this.insight={create:async t=>{await e.requestAsync("ui.insight.create",[t])},edit:async t=>{await e.requestAsync("ui.insight.edit",[t])},delete:async t=>{await e.requestAsync("ui.insight.delete",[t])},permission:async t=>{await e.requestAsync("ui.insight.permission",[t])}},this.files=new I(e)}};var re=["https://app.hailer.com","https://next.hailer.com","https://testapp.hailer.biz","https://app.hailer.biz","https://app.hailer.local.gd","https://app.k8s.hailer.com","https://next.k8s.hailer.com","https://localhost:9443"],g="https://api.hailer.com",ie={"https://app.hailer.com":g,"https://next.hailer.com":g,"https://app.hailer.biz":"https://api.hailer.biz","https://testapp.hailer.biz":"https://testapi.hailer.biz","https://app.hailer.local.gd":"https://api.hailer.local.gd","https://app.k8s.hailer.com":"https://api.k8s.hailer.com","https://next.k8s.hailer.com":"https://api.k8s.hailer.com","https://localhost:9443":"http://localhost:1337"};var S=class{constructor(e){this.options=e}async config(){let e="manifest.json",t=window.location.origin+window.location.pathname,i=t+e;t.endsWith("/index.html")&&(i=t.slice(0,-10)+e);let r=await(await fetch(i)).text(),a=JSON.parse(r).appId;return await(await fetch(this.options.publicBackendUrl+"/api/v3/app/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([a])})).json()}};var U=class{constructor(e){this.options=e}async data(e){let t=await fetch(this.options.publicBackendUrl+"/api/v2/forms/process/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}async submit(e,t){let i=await fetch(this.options.publicBackendUrl+"/api/v2/forms/activity/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e,t])});if(!i.ok)throw new n(await i.json());return await i.json()}};var O=class{constructor(e){this.options=e}async data(e){let t=await fetch(this.options.publicBackendUrl+"/api/v3/insight/public",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}async dataAsObject(e){let i=(await this.data(e)).data,r=[];return i.rows.forEach(s=>{let a={};i.headers.forEach((u,m)=>{a[u]=s[m]}),r.push(a)}),r}};var L=class{constructor(e){this.options=e}async list(e,t){let i=await fetch(this.options.publicBackendUrl+"/api/v3/product/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e,t])});if(!i.ok)throw new n(await i.json());return await i.json()}async get(e){let t=await fetch(this.options.publicBackendUrl+"/api/v3/product/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])});if(!t.ok)throw new n(await t.json());return await t.json()}};var W=class{constructor(e){this.insight=new O(e),this.form=new U(e),this.app=new S(e),this.product=new L(e)}};var _=class{constructor(e){this.client=e}async list(){try{return await this.client.requestAsync("workflow.list",[])}catch(e){throw console.error(e.msg,e),new n(e)}}async get(e){try{return await this.client.requestAsync("workflow.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("workflow.install",[e,t])}catch(i){throw new n(i)}}};var E=class{constructor(e){this.client=e;this.config={update:async(e,t)=>{try{return await this.client.requestAsync("app.config.update",[e,...t?[t]:[]])}catch(i){throw console.log("Errorasd ",i),new n(i)}}};this.product={isProductInstalled:this.isProductInstalled.bind(this),get:this.get.bind(this),install:this.install.bind(this),getInstalledVersion:this.getInstalledVersion.bind(this),getManifest:this.getManifest.bind(this)}}async isProductInstalled(e,t){try{return await this.client.requestAsync("app.product.isProductInstalled",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("app.product.get",[e])}catch(t){throw new n(t)}}async install(e,t){try{return await this.client.requestAsync("app.product.install",[e,t])}catch(i){throw new n(i)}}async getInstalledVersion(e){try{return await this.client.requestAsync("app.product.getInstalledVersion",[e])}catch(t){throw new n(t)}}async getManifest(e){try{return await this.client.requestAsync("app.product.getManifest",[e])}catch(t){throw new n(t)}}};var D=class{constructor(e){this.client=e}async data(e,t){try{return await this.client.requestAsync("insight.data",[e,...t?[t]:[]])}catch(i){throw new n(i)}}async list(){try{return await this.client.requestAsync("insight.list",[])}catch(e){throw new n(e)}}async update(e,t){try{return await this.client.requestAsync("insight.update",[e,t])}catch(i){throw new n(i)}}};var M=class{constructor(e){this.client=e;this.map=async()=>{try{return await this.client.requestAsync("permission.map",[])}catch(e){throw console.log("Failed to read permissions from Hailer, error:",e),new n(e)}}}};var F=class{constructor(e){this.client=e}async list(e,t){try{return await this.client.requestAsync("product.list",[e,t])}catch(i){throw new n(i)}}async get(e){try{return await this.client.requestAsync("product.get",[e])}catch(t){throw new n(t)}}async create(e){try{return await this.client.requestAsync("product.create",[e])}catch(t){throw new n(t)}}async update(e,t){try{return await this.client.requestAsync("product.update",[e,t])}catch(i){throw new n(i)}}async remove(e){try{return await this.client.requestAsync("product.remove",[e])}catch(t){throw new n(t)}}async setPublic(e,t){try{return await this.client.requestAsync("product.setPublic",[e,t])}catch(i){throw new n(i)}}};var B=class{constructor(e){this.client=e}async createPricing(e){try{return await this.client.requestAsync("payment.createPricing",[e])}catch(t){throw new n(t)}}async updatePricing(e){try{return await this.client.requestAsync("payment.updatePricing",[e])}catch(t){throw new n(t)}}async getPricing(e){try{return await this.client.requestAsync("payment.getPricing",[{productId:e}])}catch(t){throw new n(t)}}async createPurchase(e){try{return await this.client.requestAsync("payment.createPurchase",[e])}catch(t){throw new n(t)}}async getPurchases(e){try{return await this.client.requestAsync("payment.getPurchases",[{workspaceId:e}])||[]}catch(t){throw new n(t)}}async calculateStripeTax(e){try{return await this.client.requestAsync("payment.calculateStripeTax",[e])}catch(t){throw new n(t)}}};var N=class{constructor(e){this.client=e;this.referral={listCodes:async e=>{try{return await this.client.requestAsync("admin.referral.listCodes",[e?.filter||null,e?.options||null])}catch(t){throw new n(t)}},listEvents:async e=>{try{return await this.client.requestAsync("admin.referral.listEvents",[e?.filter||null,e?.options||null])}catch(t){throw new n(t)}},updateCode:async(e,t)=>{try{return await this.client.requestAsync("admin.referral.updateCode",[{codeId:e,...t}])}catch(i){throw new n(i)}}}}async listWorkspaces(e){try{return await this.client.requestAsync("admin.workspace.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async getWorkspace(e){try{return await this.client.requestAsync("admin.workspace.get",[e])}catch(t){throw new n(t)}}async createStripeSession(e){try{return await this.client.requestAsync("admin.workspace.createStripeSession",[e])}catch(t){throw new n(t)}}async createInvoiceIntegration(e){try{return await this.client.requestAsync("admin.workspace.createInvoiceIntegration",[e])}catch(t){throw new n(t)}}async updateWorkspaceSubscription(e){try{return await this.client.requestAsync("admin.workspace.updateSubscription",[e])}catch(t){throw new n(t)}}async updatePurchasePrice(e){try{return await this.client.requestAsync("admin.purchase.updatePrice",[e])}catch(t){throw new n(t)}}async listWorkspaceUsers(e){try{return await this.client.requestAsync("admin.workspace.listUsers",[e.workspaceId,e.filter,e.options])}catch(t){throw new n(t)}}async updateUser(e){try{return await this.client.requestAsync("admin.user.update",[e.userId,e.updates])}catch(t){throw new n(t)}}async updateTokenBalance(e){try{return await this.client.requestAsync("admin.workspace.updateTokenBalance",[e])}catch(t){throw new n(t)}}async updateWorkspaceOverrides(e){try{return await this.client.requestAsync("admin.workspace.updateOverrides",[e])}catch(t){throw new n(t)}}async updateWorkspaceMarketplaceSettings(e){try{return await this.client.requestAsync("admin.workspace.updateMarketplaceSettings",[e])}catch(t){throw new n(t)}}async listTokenTransactions(e){try{return await this.client.requestAsync("admin.tokenTransaction.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async listInvoices(e){try{return await this.client.requestAsync("admin.invoice.list",[e?.filter,e?.options])}catch(t){throw new n(t)}}async updateInvoiceHandled(e){try{return await this.client.requestAsync("admin.invoice.updateHandled",[e.purchaseIds,e.handled])}catch(t){throw new n(t)}}async listMonthlyRevenue(e){try{return await this.client.requestAsync("admin.revenue.list",[e.month,e.year,e.filter,e.options])}catch(t){throw new n(t)}}async getDashboardStatistics(e){try{return await this.client.requestAsync("admin.dashboard.statistics",[e])}catch(t){throw new n(t)}}async getDashboardTrends(e,t){try{return await this.client.requestAsync("admin.dashboard.trends",[e,t])}catch(i){throw new n(i)}}};var H=class{constructor(e){this.client=e;this.admin={workspacesList:async e=>{try{return await this.client.requestAsync("metrics.workspaceSearch",[e])}catch(t){throw new n(t)}},usersList:async e=>{try{return await this.client.requestAsync("metrics.user.list",[e])}catch(t){throw new n(t)}}}}async list(e){try{return await this.client.requestAsync("metrics.list",e?[e]:[])}catch(t){throw new n(t)}}async get(e,t){try{let i=Array.isArray(e)?e:[e];return await this.client.requestAsync("metrics.get",[i,t])}catch(i){throw new n(i)}}};var Y=class{constructor(e,t){this.client=e;this.onopen=null;this.onmessage=null;this.onclose=null;this.onerror=null;this.readyState=WebSocket.CONNECTING;this.connectionId=null;this.client.request("http.ws.open",[t],(i,r)=>{if(i){this.readyState=WebSocket.CLOSED,this.onerror?.({error:i});return}if(r)switch(r.connectionId&&!this.connectionId&&(this.connectionId=r.connectionId),r.event){case"open":this.readyState=WebSocket.OPEN,this.onopen?.({});break;case"message":this.onmessage?.({data:r.data??""});break;case"close":this.readyState=WebSocket.CLOSED,this.onclose?.({code:r.code,reason:r.reason});break;case"error":this.onerror?.({error:r.data});break}})}send(e){if(this.readyState!==WebSocket.OPEN||!this.connectionId)throw new Error("WebSocket is not open");this.client.requestAsync("http.ws.send",[this.connectionId,e]).catch(t=>{this.onerror?.({error:t})})}close(e,t){this.connectionId&&this.client.requestAsync("http.ws.close",[this.connectionId,e,t]).catch(i=>{this.onerror?.({error:i})}),this.readyState=WebSocket.CLOSING}},j=class{constructor(e){this.client=e}async fetch(e,t){return await this.client.requestAsync("http.fetch",[e,t]).catch(i=>{throw i})}async upload(e,t){return await this.client.requestAsync("http.upload",[e,t]).catch(i=>{throw i})}openWebSocket(e){return new Y(this.client,e)}};var $=class{constructor(e={}){this.options=e;this.outside=null;let t=e.allowedUrls??re;this.client=new ne.Client(r=>{this.hostUrl&&parent.postMessage(JSON.stringify(r),this.hostUrl)}),this.user=new f(this.client),this.app=new E(this.client),this.activity=new A(this.client),this.insight=new D(this.client),this.workspace=new P(this.client),this.team=new v(this.client),this.file=new k(this.client),this.workflow=new _(this.client),this.permission=new M(this.client),this.public=new W(this.options),this.ui=new C(this.client),this.product=new F(this.client),this.payment=new B(this.client),this.admin=new N(this.client),this.metrics=new H(this.client),this.http=new j(this.client);let i=JSON.stringify({op:"register",args:[{appApiVersion:"2"}]});window.location===window.parent.location?(this.options.publicBackendUrl||(this.options.publicBackendUrl=g),this.public.app.config().then(r=>{this.outside=!0,this.options.outside?.(r)}).catch(r=>{this.options.error?.(r),console.error("Failed to get app configuration in Public App.",r)})):(t.forEach(r=>parent.postMessage(i,r)),this.timer=setTimeout(()=>{this.outside=!0,this.options.outside?.()},100)),this.createEventListener()}createEventListener(){window.addEventListener("message",async e=>{let t=e.data;try{let i=JSON.parse(t);if(i.op==="register"){if(this.appId){console.error("App Id is already set...! Are you using hot-reload?");return}clearTimeout(this.timer),this.appId=i.data.appId,this.workspaceId=i.data.workspaceId,this.hostUrl=e.origin,this.options.publicBackendUrl||(this.options.publicBackendUrl=ie[this.hostUrl]||g),this.client.request("ui.settings",[],(r,s,a)=>{if(r){console.log("ui.settings error:",r,s);return}this.options.settings?.(s)}),this.client.request("config",[],(r,s,a)=>{if(r){console.log("config error:",r,s);return}this.options.config?.(s)}),this.client.request("signal",[],(r,s,a)=>{if(r){console.log("signal error:",r,s);return}s&&this.options.signals?.(s)}),this.outside=!1,this.options.connected?.();return}if(!this.appId)return;this.client.messageReceived(i)}catch{console.log("Dropped invalid JSON message")}})}info(){return{hostUrl:this.hostUrl,config:this.config,outside:this.outside,workspaceId:this.workspaceId}}};export{$ as HailerApi,n as HailerError,H as MetricsApi};
|
|
3
3
|
//# sourceMappingURL=app-sdk.js.map
|
package/lib/app-sdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
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/workspace.ts", "../src/modules/team.ts", "../src/modules/file.ts", "../src/modules/ui/activity.ts", "../src/modules/ui/discussion.ts", "../src/modules/ui/snackbar.ts", "../src/modules/ui/files.ts", "../src/modules/ui/workflow.ts", "../src/modules/ui.ts", "../src/constants.ts", "../src/modules/public/app.ts", "../src/modules/public/form.ts", "../src/modules/public/insight.ts", "../src/modules/public/product.ts", "../src/modules/public.ts", "../src/modules/workflow.ts", "../src/modules/app.ts", "../src/modules/insight.ts", "../src/modules/permission.ts", "../src/modules/product.ts", "../src/modules/payment.ts", "../src/modules/admin.ts", "../src/modules/metrics.ts", "../src/modules/http.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/workspace';\nimport { TeamApi } from './modules/team';\nimport { FileApi } from './modules/file';\nimport { ApiInfo, Config, Settings, Signal } from './types';\nimport { Ui } from './modules/ui';\nimport { DEFAULT_ALLOWED_URLS, 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';\nimport { PermissionApi } from './modules/permission';\nimport { ProductApi } from './modules/product';\nimport { Payment } from './modules/payment';\nimport { Admin } from './modules/admin';\nimport { MetricsApi } from './modules/metrics';\nimport { HttpApi } from './modules/http';\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: Settings) => 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: Signal) => void;\n /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/\n allowedUrls?: string[];\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 workspace: WorkspaceApi;\n public team: TeamApi;\n public file: FileApi;\n public workflow: WorkflowApi;\n public permission: PermissionApi;\n public product: ProductApi;\n public payment: Payment;\n public admin: Admin;\n public metrics: MetricsApi;\n /** HTTP proxy for making authenticated HTTP/WebSocket requests through the parent frame */\n public http: HttpApi;\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 /** If set it indicates that app is locked to a specific workspaceId */\n private workspaceId?: string;\n private client: Client;\n private config?: Config;\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 \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.workspace = new WorkspaceApi(this.client);\n this.team = new TeamApi(this.client);\n this.file = new FileApi(this.client);\n this.workflow = new WorkflowApi(this.client);\n this.permission = new PermissionApi(this.client);\n this.public = new HailerPublicApi(this.options);\n this.ui = new Ui(this.client);\n this.product = new ProductApi(this.client);\n this.payment = new Payment(this.client);\n this.admin = new Admin(this.client);\n this.metrics = new MetricsApi(this.client);\n this.http = new HttpApi(this.client);\n\n const registerMessage = JSON.stringify({ op: 'register', args: [{ appApiVersion: '2' }] });\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\n this.appId = msg.data.appId;\n this.workspaceId = msg.data.workspaceId;\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('ui.settings', [], (error: any, data: Settings, 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('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 this.client.request('signal', [], (error: any, data: any, end: boolean) => {\n if (error) {\n console.log('signal error:', error, data);\n return;\n }\n\n if (data) {\n this.options.signals?.(data);\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.log('Dropped invalid JSON message');\n }\n });\n }\n\n info(): ApiInfo {\n return {\n hostUrl: this.hostUrl,\n config: this.config,\n outside: this.outside,\n workspaceId: this.workspaceId,\n }\n }\n}\n", "export interface User {\n _id: string;\n firstname: string;\n lastname: string;\n // email: string;\n // lastSeen: number;\n // status?: string;\n // managedUser?: boolean;\n // removed?: number;\n // defaultProfilepic: string;\n}\n\n/* export 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} */\nexport interface Workspace {\n _id: string;\n name: string;\n}\n\nexport interface Team {\n _id: string;\n name: string;\n}\n\nexport interface TeamsByWorkspace {\n [workspaceId: string]: Team[];\n}\n\nexport interface ActivityFieldRange {\n start: number;\n end: number;\n }\n\n export interface ActivityFieldLink {\n _id: string;\n name: string;\n }\n \nexport interface ActivityFieldError {\n error?: string\n}\n\nexport type ActivityFieldValue = boolean | number | string | (ActivityFieldCountry & ActivityFieldError & ActivityFieldRange & ActivityFieldLink);\n\nexport type ActivityFieldUpdateValue = ActivityFieldValue | null;\n/*\nexport interface UserMap {\n [userId: string]: User;\n}\n\n*/\n\nexport interface ActivityFieldCountry {\n /** ISO 3166-1 alpha-2 (cca2) */\n code: string;\n}\nexport interface Activity {\n _id: string;\n process: string;\n teamAccount: TeamAccount // TODO: Convert in frontend\n created: number;\n uid: string;\n workspaceId: 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?: {\n [fieldId: string]: ActivityFieldValue\n };\n // fields?: { [fieldId: string]: string | number };\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 Config {\n [fieldName: string]: string;\n}\n\nexport type WorkflowFieldType = (\n 'activitylink' |\n 'country' |\n 'date' |\n 'daterange' |\n 'datetime' |\n 'numeric' |\n 'numericunit' |\n 'teams' |\n 'text' |\n 'textarea' |\n 'textunit' |\n 'textpredefinedoptions' |\n 'time' |\n 'timerange' |\n 'datetimerange' |\n 'users' |\n 'linkedfrom' |\n 'subheader'\n);\n\nexport interface WorkflowField {\n _id: string;\n type: WorkflowFieldType;\n label: string;\n required: boolean;\n unit: string;\n placeholder: string;\n description: string;\n data: string[];\n functionEnabled: boolean;\n editable: boolean;\n functionVariables?: { [key: string]: any };\n}\n\nexport interface DocumentTemplate {\n templateId?: string; // Valid ObjectId for regular templates, or non-ObjectId string for multi-pdf templates\n name: string;\n order?: number;\n}\n\nexport interface Workflow {\n _id: string;\n name: string;\n description?: string;\n fields: { [fieldId: string]: any };\n fieldsOrder: string[];\n phases: { [phase_id: string]: WorkflowPhase };\n phasesOrder: string[];\n enablePredefinedName?: boolean;\n nameFunctionEnabled?: boolean;\n nameEditable?: boolean;\n productInstalledId: string;\n workspaceId: string;\n documentTemplates?: DocumentTemplate[];\n /*\n defaultView: 'table' | 'kanban' | 'map' | 'calendar';\n fields: { [fieldId: string]: any };\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 enablePreselectedTeam?: boolean;\n initPhaseDescription?: string;\n locationRequired?: boolean;\n nameColumnText?: string;\n nameFunction?: string;\n nameFunctionVariables?: any;\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 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 fields?: string[];\n primaryDateField?: string;\n primaryNumericField?: string\n /*\n followers: string[];\n created: number;\n uid?: string;\n members?: any[]\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/**\n * ```ts\n * { [templateId: string]: string }\n * ```\n */\nexport interface IdsMap {\n [templateId: string]: string;\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 type WorkflowPermission = 'admin' | 'any' | 'ownteam' | 'own' | 'guest' | 'none';\nexport type WorkflowPhasePermission = 'edit' | 'view' | 'none';\n\nexport interface PermissionPath {\n type: 'network' | 'user' | 'team' | 'group';\n id: string;\n permission: WorkflowPermission | WorkflowPhasePermission;\n};\n\nexport interface WorkflowPermissionMap {\n [workflowId: string]: {\n // hasAccess: boolean;\n isAdmin: boolean;\n permission: WorkflowPermission;\n permissions: PermissionPath;\n phases: {\n [phaseId: string]: {\n // name: string;\n // hasAccess: boolean;\n permission: WorkflowPhasePermission,\n permissions: PermissionPath[];\n restricted: boolean;\n }\n };\n teams: string[];\n\n }\n};\n\nexport interface WorkspaceRolesPermission {\n isAdmin: boolean;\n isOwner: boolean;\n isGuest: boolean;\n isInviter: boolean;\n isUser: boolean;\n // custom: roleSchema,\n};\n\nexport interface PermissionMap {\n [userId: string]: {\n workflow: WorkflowPermissionMap,\n workspace: WorkspaceRolesPermission,\n // calendar: calendarPermissionMapSchema,\n // insight: insightPermissionMapSchema,\n // app: appPermissionMapSchema,\n // teams: Joi.array().items(validTeamId),\n // permits: Joi.array().items(Joi.string()),\n },\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 _id: string;\n name: string;\n /** Key for accessing Insight when set to public */\n publicKey?: string;\n presets: {\n version: 1;\n name: string | 'default';\n options: any;\n }[];\n /** To be used with SQLite if we want to.... */\n query?: string;\n sources: InsightWorkflowSource[];\n public: boolean;\n \n // members: Member[];\n // updated: number;\n /** User id of creator */\n // uid: string;\n // workspaceId: string;\n /** sandboxed javascript with access to all activities in given workflows */\n // function?: string;\n\n \n}\n\nexport type InsightPublic = Omit<InsightDoc, '_id'>;\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}\n\n\n/** Simplistic syntax for add/remove/replace */\nexport interface IdSetUpdate {\n /** Clear all existing */\n '*'?: null,\n /** Add: true, Remove: null */\n [id: string]: true | null | undefined\n}\nexport interface ActivityLocation {\n data: {\n lat: number;\n lng: number;\n }[],\n label?: string;\n type: 'area' | 'point' | 'polyline';\n};\nexport interface ActivityUpdateOptions {\n fields?: ActivityFieldUpdateValue,\n teamId?: string,\n location?: ActivityLocation\n phaseId?: string,\n files?: IdSetUpdate,\n followers?: IdSetUpdate,\n};\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 PrintRequest {\n activityId: string;\n /** Template ID for regular templates */\n templateId?: string;\n /** Template name for multi-pdf templates (when templateId is empty) */\n templateName?: string;\n /** Whether to save the PDF to the file system */\n savePdf?: boolean;\n}\n\nexport interface PrintResponse {\n filename: string;\n /** Base64-encoded document data */\n data: string;\n mimeType: string;\n}\n\nexport interface Settings {\n theme: 'light' | 'dark'\n preferredLanguages: string[];\n}\n\nexport interface ApiInfo {\n /** Url of the Hailer instance hosting the API */\n hostUrl?: string;\n config?: Config;\n outside: boolean | null;\n workspaceId?: string;\n}\n\nexport interface ApiError {\n code: number,\n msg: string, \n debug: object\n}\n\nclass CustomError extends Error {\n public msg: string;\n public code: number;\n \n constructor(message: string, code: number) {\n super(message);\n this.name = this.constructor.name;\n this.msg = message;\n this.code = code;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\nexport class HailerError extends CustomError {\n public debug: object\n public details?: any\n\n constructor(error: {code: number, msg: string, details?: any, debug: any}) {\n super(error.msg, error.code)\n\n this.details = error.details;\n this.debug = error.debug;\n }\n\n toString() {\n console.log('Going to log an error... ;-D');\n return `${super.toString()} \\nField: ${this.details}, ${this.debug}`;\n }\n}\n\nexport interface Signal {\n name: string;\n data: any;\n}\n\nexport interface Product extends ProductType {\n _id: string;\n targetId?: string;\n name: string;\n description?: string;\n icon?: string;\n images?: string[];\n externalUrl?: string;\n publisher?: string;\n ctaLabel: string;\n ctaLink: string;\n /** Available or not in app store */\n public?: boolean;\n cid?: string;\n uid: string;\n}\n\nexport interface ProductListResponse {\n products: Product[];\n totalCount: number;\n}\n\nexport interface ProductSearchOption {\n limit?: number,\n skip?: number,\n search?: string,\n reverse?: boolean,\n sortBy?: 'name' | 'created' | 'updated' | 'type',\n sortOrder?: 'asc' | 'desc'\n}\n\nexport interface ProductSearchFilter extends ProductType {\n public?: boolean,\n cid?: string,\n uid?: string,\n}\n\nexport interface ProductType {\n type?: 'app' | 'template' | 'integration' | 'expert' | 'ai-agent',\n}\n\nexport interface ProductVersion {\n _id: string;\n name: string;\n versions?: Version[];\n cid?: string;\n}\n\nexport interface Version {\n version: string;\n description: string;\n packageHash: string;\n created: number;\n}\n\n// Payment and Pricing Types\nexport interface PricingPlan {\n planId: 'monthly' | 'yearly' | 'one_time';\n label: string;\n price: number;\n currency: string;\n interval: 'month' | 'year' | null;\n}\n\nexport interface PaymentProvider {\n priceId?: {\n monthly?: string;\n yearly?: string;\n one_time?: string;\n };\n trial_days?: number;\n}\n\nexport interface PricingProviders {\n stripe?: PaymentProvider;\n paddle?: PaymentProvider;\n // fuze?: PaymentProvider; // Hidden for now\n}\n\nexport interface PricingData {\n _id?: string;\n productId?: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n created?: number;\n updated?: number;\n}\n\nexport interface CreatePricingRequest {\n productId: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n}\n\nexport interface UpdatePricingRequest {\n productId: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n}\n\nexport interface CreatePurchaseRequest {\n productId: string;\n workspaceId: string;\n planType: 'monthly' | 'yearly' | 'one_time';\n successUrl?: string; // Optional for backward compatibility\n cancelUrl?: string; // Optional for backward compatibility\n useTokens?: boolean; // Optional - use workspace tokens for one-time purchases\n}\n\nexport interface CreatePurchaseResponse {\n status: 'installed_free' | 'subscription_created' | 'checkout_required' | 'payment_processed' | 'payment_failed';\n message?: string;\n productId?: string;\n planType?: string;\n purchaseId?: string;\n subscriptionId?: string;\n provider?: string;\n trialDays?: number;\n checkoutUrl?: string;\n error?: string; // For payment failure details\n}\n\nexport interface Purchase {\n _id: string;\n uid: string;\n cid: string;\n productId?: string;\n productName?: string;\n provider?: 'stripe' | 'paddle' | 'fuze';\n type: 'monthly' | 'yearly' | 'one_time';\n purchaseType: 'workspace' | 'product';\n startedAt: number;\n created: number;\n updated?: number;\n customStatus?: string;\n expiresAt?: number;\n trialDays?: number;\n trialStart?: number;\n trialEnd?: number;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n pricing?: {\n amount: number;\n currency: string;\n interval: string;\n source: string;\n };\n stripe?: {\n customerId?: string;\n checkoutSessionId?: string;\n subscriptionId?: string;\n paymentIntentId?: string;\n status?: string;\n };\n paddle?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n fuze?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n}\n\n// Admin interfaces\nexport interface AdminWorkspaceListItem {\n _id: string;\n name: string;\n memberCount: number;\n created: number;\n updated?: number;\n creatorEmail?: string;\n paymentPlan?: string;\n monthlyPrice?: number;\n paymentMethod?: 'subscription' | 'invoice';\n subscriptionActive?: boolean;\n provider?: string;\n stripeStatus?: string;\n hasPendingSubscription?: boolean;\n tokenBalance?: number;\n autoReloadEnabled?: boolean;\n}\n\nexport interface AdminWorkspaceListRequest {\n filter?: {\n name?: string;\n };\n options?: {\n search?: string;\n sortBy?: string;\n sortOrder?: string;\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminWorkspaceListResponse {\n workspaces: AdminWorkspaceListItem[];\n totalCount: number;\n}\n\n// Purchase data for admin interfaces\nexport interface AdminPurchaseData {\n _id: string;\n uid: string;\n cid: string;\n productId?: string | null;\n productName?: string | null;\n provider?: string;\n type: string;\n purchaseType: 'workspace' | 'product';\n billingType?: 'subscription' | 'invoice';\n planName?: 'flexible' | 'pro' | 'business' | 'enterprise';\n startedAt?: number;\n expiresAt?: number;\n created: number;\n updated?: number;\n customStatus?: string;\n trialStart?: number;\n trialEnd?: number;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n pricing?: {\n amount: number;\n currency: string;\n interval?: string;\n source: 'purchase_record' | 'pricing_collection';\n };\n availablePricing?: Array<{\n planId: 'monthly' | 'yearly' | 'one_time';\n label: string;\n price: number;\n currency: string;\n interval: string | null;\n }>;\n trialDays?: number;\n stripe?: {\n customerId?: string;\n checkoutSessionId?: string;\n subscriptionId?: string;\n paymentIntentId?: string;\n status?: string;\n };\n paddle?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n fuze?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n}\n\n// Single workspace for admin get method (extends list item with purchase data)\nexport interface AdminWorkspaceOverrides {\n // Boolean overrides\n functionFields?: boolean;\n kanban?: boolean;\n customRoles?: boolean;\n restricted?: boolean;\n insight?: boolean;\n dataExport?: boolean;\n documentGenerator?: boolean;\n groups?: boolean;\n print?: boolean;\n isolatedTeams?: boolean;\n managedUsers?: boolean;\n translations?: boolean;\n indexedData?: boolean;\n fastFunctions?: boolean;\n activityRecovery?: boolean;\n videoCall?: boolean;\n // Number overrides\n users?: number | null;\n // String overrides\n tourIdentifier?: string;\n}\n\nexport interface AdminWorkspaceMarketplaceSettings {\n creatorPercent: number;\n}\n\nexport interface AdminWorkspace extends AdminWorkspaceListItem {\n purchaseId?: string;\n purchases?: AdminPurchaseData[];\n overrides?: AdminWorkspaceOverrides;\n marketplace?: AdminWorkspaceMarketplaceSettings;\n}\n\nexport interface AdminUpdateOverridesRequest {\n workspaceId: string;\n overrides: AdminWorkspaceOverrides;\n}\n\nexport interface AdminUpdateMarketplaceSettingsRequest {\n workspaceId: string;\n creatorPercent: number;\n}\n\nexport interface AdminCreateStripeSessionRequest {\n workspaceId: string;\n planName: 'flexible' | 'pro' | 'business' | 'enterprise';\n customPrice: number;\n paymentMethod: 'stripe';\n baseUrl: string;\n}\n\nexport interface AdminCreateStripeSessionResponse {\n success: boolean;\n message: string;\n sessionUrl?: string;\n}\n\nexport interface AdminCreateInvoiceIntegrationRequest {\n workspaceId: string;\n planName: 'enterprise'; // Only enterprise for invoice\n customPrice: number;\n paymentMethod: 'hailer';\n}\n\nexport interface AdminCreateInvoiceIntegrationResponse {\n success: boolean;\n message: string;\n}\n\nexport interface AdminUpdateWorkspaceSubscriptionRequest {\n purchaseId: string;\n billingType: 'subscription' | 'invoice';\n customPrice: number;\n planName: 'flexible' | 'pro' | 'business' | 'enterprise';\n tokenAmount?: number;\n}\n\nexport interface AdminUpdatePurchasePriceRequest {\n purchaseId: string;\n workspaceId: string;\n newPrice: number;\n}\n\nexport interface AdminWorkspaceUser {\n _id: string;\n name: string;\n email: string;\n role: 'owner' | 'admin' | 'user' | 'guest' | 'inviter';\n joined?: number;\n lastActive?: number;\n emailVerified?: boolean;\n managedUser?: boolean | null;\n}\n\nexport interface AdminWorkspaceUsersListRequest {\n workspaceId?: string;\n filter?: {\n email?: string;\n role?: string;\n };\n options?: {\n search?: string;\n sortBy?: string;\n sortOrder?: string;\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminWorkspaceUsersListResponse {\n users: AdminWorkspaceUser[];\n totalCount: number;\n}\n\nexport interface AdminUpdateUserRequest {\n userId: string;\n updates: {\n emailVerified?: boolean;\n };\n}\n\nexport interface AdminUpdateUserResponse {\n success: boolean;\n}\n\nexport interface AdminUpdateTokenBalanceRequest {\n workspaceId: string;\n tokenAmount: number;\n payoutType?: 'admin_bonus' | 'creator_payout';\n payoutMonth?: number;\n payoutYear?: number;\n creatorPercent?: number;\n}\n\nexport interface AdminTokenTransaction {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n type: 'purchase' | 'deduction' | 'bonus' | 'admin_adjustment' | 'creator_payout';\n amount: number;\n reason: string;\n meta?: {\n payoutMonth?: number;\n payoutYear?: number;\n creatorProfit?: number;\n creatorPercent?: number;\n [key: string]: any\n };\n createdAt: number;\n}\n\nexport interface AdminTokenTransactionFilter {\n workspaceId?: string;\n type?: 'purchase' | 'deduction' | 'bonus' | 'admin_adjustment' | 'creator_payout';\n operation?: string;\n dateFrom?: number;\n dateTo?: number;\n search?: string;\n}\n\nexport interface AdminTokenTransactionStatistics {\n netChange: number;\n totalPurchases: number;\n totalPurchasesEuro: number;\n purchasesBySource: {\n stripe: {\n count: number;\n tokens: number;\n revenue: number;\n };\n adminPortal: {\n count: number;\n tokens: number;\n revenue: number;\n };\n };\n totalDeductions: number;\n totalDeductionsEuro: number;\n consumptionByOperation: {\n [operation: string]: {\n count: number;\n tokens: number;\n };\n };\n totalBonuses: number;\n totalBonusesEuro: number;\n totalCreatorPayouts: number;\n totalCreatorPayoutsEuro: number;\n totalRefunds: number;\n totalRefundsEuro: number;\n}\n\nexport interface AdminTokenTransactionsListRequest {\n filter?: AdminTokenTransactionFilter;\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminTokenTransactionsListResponse {\n transactions: AdminTokenTransaction[];\n totalCount: number;\n statistics: AdminTokenTransactionStatistics;\n}\n\nexport interface AdminInvoicePurchase {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n purchaseType: 'workspace' | 'product';\n type: 'monthly' | 'yearly' | 'one_time';\n provider: 'hailer';\n billingType: 'invoice';\n planName?: string;\n productId?: string;\n productName?: string;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n customStatus?: string;\n invoiceHandled?: boolean;\n startedAt: number;\n expiresAt?: number;\n trialStart?: number;\n trialEnd?: number;\n}\n\nexport interface AdminInvoiceListRequest {\n filter?: {\n workspaceId?: string;\n purchaseType?: 'workspace' | 'product';\n status?: 'handled' | 'unhandled' | 'all';\n search?: string;\n };\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminInvoiceWorkspaceGroup {\n cid: string;\n workspaceName: string;\n allHandled: boolean;\n purchases: AdminInvoicePurchase[];\n}\n\nexport interface AdminInvoiceListResponse {\n invoices: AdminInvoicePurchase[];\n totalCount: number;\n workspaceGroups: AdminInvoiceWorkspaceGroup[];\n}\n\nexport interface AdminInvoiceUpdateHandledRequest {\n purchaseIds: string | string[];\n handled: boolean;\n}\n\nexport interface AdminInvoiceUpdateHandledResponse {\n updatedCount: number;\n}\n\n// Monthly Revenue Tracking Types\nexport interface AdminRevenuePurchase {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n purchaseType: 'workspace' | 'product';\n type: 'monthly' | 'yearly' | 'one_time';\n provider: string;\n productId?: string;\n productName?: string;\n productOwnerCid?: string;\n productOwnerName?: string;\n pricePaid?: { amount: number; currency: string };\n startedAt: number;\n expiresAt?: number;\n // Calculated fields\n normalizedMonthlyRevenue: number; // Yearly \u00F7 12, others as-is\n isMarketplace: boolean;\n profitToHailer: number;\n profitToCreator?: number;\n statusInMonth: 'active' | 'started' | 'ended';\n}\n\nexport interface AdminRevenueWorkspaceGroup {\n cid: string;\n workspaceName: string;\n totalRevenue: number;\n totalMRR: number;\n totalOneTime: number;\n totalCreatorProfit: number;\n totalHailerProfit: number;\n creatorPercent: number;\n productCount: number;\n paidOut?: boolean;\n productBreakdown: Array<{\n productId: string;\n productName: string;\n installationCount: number;\n totalRevenue: number;\n subscriptionTypes: {\n monthly: number;\n yearly: number;\n one_time: number;\n };\n installedBy: Array<{\n cid: string;\n workspaceName: string;\n type: string;\n }>;\n }>;\n purchases: AdminRevenuePurchase[];\n}\n\nexport interface AdminRevenueWorkspaceSubscriptions {\n totalWorkspaces: number;\n totalRevenue: number;\n byPlan: Array<{\n planName: string;\n count: number;\n revenue: number;\n }>;\n}\n\nexport interface AdminRevenueStatistics {\n selectedMonth: { month: number; year: number };\n totalMRR: number;\n totalOneTime: number;\n totalRevenue: number;\n activeCount: number;\n hailerProfit: number;\n creatorProfit: number;\n}\n\nexport interface AdminRevenueListRequest {\n month: number;\n year: number;\n filter?: {\n workspaceId?: string;\n purchaseType?: 'workspace' | 'product';\n subscriptionType?: 'monthly' | 'yearly' | 'one_time';\n search?: string;\n };\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminRevenueListResponse {\n purchases: AdminRevenuePurchase[];\n totalCount: number;\n workspaceGroups: AdminRevenueWorkspaceGroup[];\n statistics: AdminRevenueStatistics;\n}\n\n// Dashboard Statistics Types\nexport interface AdminDashboardEntityStatistics {\n today: number;\n total: number;\n lastWeek: number;\n growth: number;\n}\n\nexport interface AdminDashboardStatisticsResponse {\n users: AdminDashboardEntityStatistics;\n workspaces: AdminDashboardEntityStatistics;\n activities: AdminDashboardEntityStatistics;\n messages: AdminDashboardEntityStatistics;\n userMessages: AdminDashboardEntityStatistics;\n}\n\n// Dashboard Trends Types\nexport interface AdminDashboardTrendDataPoint {\n date: string;\n count: number;\n}\n\nexport interface AdminDashboardTrendsResponse {\n users?: AdminDashboardTrendDataPoint[];\n workspaces?: AdminDashboardTrendDataPoint[];\n}\n\n// Stripe Tax Calculation Types\nexport interface StripeTaxLineItem {\n amount: number;\n reference: string;\n tax_code?: string;\n quantity?: number;\n}\n\nexport interface StripeTaxCalculationRequest {\n workspaceId: string;\n lineItems: StripeTaxLineItem[];\n}\n\nexport interface StripeTaxLineItemResult {\n reference: string;\n amount: number;\n taxAmount: number;\n totalAmount: number;\n}\n\nexport interface StripeTaxCalculationResponse {\n amountSubtotal: number;\n amountTax: number;\n amountTotal: number;\n taxRate?: number;\n country?: string;\n countryName?: string;\n currency: string;\n lineItems: StripeTaxLineItemResult[];\n}\n\n// Admin Referral Types\nexport interface AdminReferralCode {\n _id: string;\n code: string;\n uid: string;\n cid: string;\n ownerEmail?: string;\n workspaceName?: string;\n bonusTokens: number;\n isActive: boolean;\n totalReferrals: number;\n totalTokensAwarded: number;\n created: number;\n}\n\nexport interface AdminReferralCodeListRequest {\n filter?: {\n isActive?: boolean;\n cid?: string;\n };\n options?: {\n search?: string;\n limit?: number;\n skip?: number;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n };\n}\n\nexport interface AdminReferralCodeListResponse {\n codes: AdminReferralCode[];\n totalCount: number;\n stats: {\n activeCount: number;\n totalReferrals: number;\n totalTokensAwarded: number;\n };\n}\n\nexport interface AdminReferralEvent {\n _id: string;\n referralCodeId: string;\n referralCode: string;\n referrerUid: string;\n referrerCid: string;\n refereeUid: string;\n refereeCid: string;\n refereeEmail?: string;\n refereeWorkspaceName?: string;\n status: 'pending' | 'completed' | 'failed';\n bonusTokensAwarded: number;\n failureReason?: string;\n created: number;\n completedAt?: number;\n}\n\nexport interface AdminReferralEventListRequest {\n filter?: {\n referralCodeId?: string;\n referrerCid?: string;\n status?: 'pending' | 'completed' | 'failed';\n };\n options?: {\n limit?: number;\n skip?: number;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n };\n}\n\nexport interface AdminReferralEventListResponse {\n events: AdminReferralEvent[];\n totalCount: number;\n stats: {\n completedCount: number;\n pendingCount: number;\n totalTokensAwarded: number;\n };\n}\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 return await this.client.requestAsync('user.get', [userId]);\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 return await this.client.requestAsync('user.current', []);\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<User[]> {\n try {\n return await this.client.requestAsync('user.list', []);\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('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('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('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, ActivityFieldUpdateValue, ActivityUpdateOptions, ActivityFieldValue, PrintRequest, PrintResponse } 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 return await this.client.requestAsync('activity.list', [processId, phaseId, options]);\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('activity.get', [activityId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async create(workflowId: string | undefined, activities: { name?: string; fields?: { [id: string]: ActivityFieldValue }, phaseId?: string, teamId?: string }[], options?: ActivityCreateOptions ): Promise<Activity[]> {\n try {\n return await this.client.requestAsync('activity.create', [workflowId, activities, ...options ? [options] : []]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates activites\n *\n * @returns The number of updated activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async update(\n activities: { _id: string, name?: string, fields?: { [id: string]: ActivityFieldUpdateValue }, phaseId?: string, teamId?: string }[],\n options?: ActivityUpdateOptions\n ): Promise<number> {\n try {\n return await this.client.requestAsync('activity.update', [activities, ...options ? [options] : []]);\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 return await this.client.requestAsync('activity.remove', [activities]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Prints activities using document templates\n *\n * @param requests Array of print requests\n * @param requests[].activityId The ID of the activity to print\n * @param requests[].templateId Template ID for regular templates\n * @param requests[].templateName Template name for multi-pdf templates (when templateId is empty)\n * @param requests[].savePdf Whether to save the generated PDF\n *\n * @returns PDF data with filename, base64 data, and mimeType\n *\n * @throws {HailerError} if request is incorrect\n */\n async print(requests: PrintRequest[]): Promise<PrintResponse> {\n try {\n return await this.client.requestAsync('activity.print', [requests]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, ProductVersion, Workspace } from '../types';\n\nexport class WorkspaceApi {\n product: {\n /** Publish template in Hailer market */\n publishTemplate: (template: {\n workspaceId?: string,\n versionId?: string,\n version: string,\n versionDescription: string,\n title: string,\n description: string\n }) => Promise<ProductVersion>\n\n /** Check if product is installed */\n isProductInstalled(\n id: string,\n workspaceId: string\n ): Promise<boolean>\n\n /** Get version */\n get(\n id: string\n ): Promise<ProductVersion | undefined>\n\n /** Install template from Hailer market */\n install(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get manifest content from Hailer market */\n getManifest(id: string): Promise<any>\n };\n\n constructor(private client: Client) {\n this.product = {\n publishTemplate: this.publishTemplate.bind(this),\n isProductInstalled: this.isProductInstalled.bind(this),\n get: this.get.bind(this),\n install: this.install.bind(this),\n getManifest: this.getManifest.bind(this),\n };\n }\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('workspace.current', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /**\n * Returns all workspaces for user if personal app\n * If not personal app it returns only the current workspace\n * @returns the Hailer Workspaces information for the user\n * \n * * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<Workspace[]> {\n try {\n const res = await this.client.requestAsync('workspace.list', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n\n /** \n * Publish template in Hailer market\n * \n * @param workspaceId Id of workspace\n * @param versionId link to version (empty if first publish)\n * @param version Version number\n * @param versionDescription Version description\n * @param title\n * @param description\n * \n * @returns Created version in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n private async publishTemplate(\n template: {\n workspaceId?: string,\n versionId?: string,\n version: string,\n versionDescription: string,\n title: string,\n description: string\n }\n ): Promise<ProductVersion> {\n try {\n const result = await this.client.requestAsync('workspace.product.publishTemplate', [template]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Check if product is installed\n *\n * @param id Id of product in Hailer market\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async isProductInstalled(\n id: string,\n workspaceId: string\n ): Promise<boolean> {\n try {\n return await this.client.requestAsync('workspace.product.isProductInstalled', [id, workspaceId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get version\n *\n * @param id targetId\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async get(\n id: string\n ): Promise<ProductVersion | undefined> {\n try {\n return await this.client.requestAsync('workspace.product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Install template from Hailer market\n *\n * @param productId Id of product in Hailer market\n * \n * @param workspaceId Id of workspace where the product will be installed\n *\n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async install(productId: string, workspaceId: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('workspace.product.install', [productId, workspaceId]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get manifest content from Hailer market\n *\n * @param id target Id\n *\n * @returns Manifest content\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getManifest(id: string): Promise<any> {\n try {\n return await this.client.requestAsync('workspace.product.getManifest', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, TeamsByWorkspace } from '../types';\n\nexport class TeamApi {\n constructor(private client: Client) {}\n\n /**\n * Lists all teams grouped by workspace ID\n *\n * @returns Teams grouped by workspace ID\n *\n * @example\n * const teams = await hailer.team.list();\n * // { \"workspaceId1\": [{ _id: \"...\", name: \"Team A\" }], ... }\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<TeamsByWorkspace> {\n try {\n return await this.client.requestAsync('team.list', []);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError } from '../types';\n\nexport interface FileResponse {\n filename: string;\n /** Base64-encoded file data */\n data: string;\n mimeType: string;\n}\n\nexport interface UploadOptions {\n /** Whether the file should be publicly accessible */\n isPublic?: boolean;\n}\n\nexport class FileApi {\n constructor(private client: Client) {}\n\n /**\n * Gets a file by ID and returns it as base64 data\n *\n * @param fileId The ID of the file to fetch\n *\n * @returns File data with filename, base64 data, and mimeType\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(fileId: string): Promise<FileResponse> {\n try {\n return await this.client.requestAsync('file.get', [fileId]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Uploads a file to Hailer\n *\n * @param file File to be uploaded\n * @param filename Name of the file\n * @param options Upload options\n *\n * @returns File ID in Hailer\n *\n * @throws {HailerError} if upload fails\n */\n async upload(file: File, filename: string, options?: UploadOptions): Promise<string> {\n try {\n const base64Data = await this.toBase64(file);\n return await this.client.requestAsync('file.upload', [base64Data, filename, !!options?.isPublic]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n private toBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve((reader.result as string) ?? '');\n reader.onerror = reject;\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('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 /** Phase ID to pre-select */\n phaseId?: string,\n /** Team ID to pre-select */\n teamId?: string,\n /** Prepopulate fields */\n fields?: {\n [fieldId: string]: number | string | { start: number, end: number },\n },\n location?: {\n type: 'area' | 'point' | 'polyline',\n data: { lng: number, lat: number }[],\n },\n }\n ): Promise<{ _id: string, name: string } | null> {\n return await this.client.requestAsync('ui.activity.create', [processId, ...options ? [options] : []]);\n }\n\n /** Opens multiple activity edit view in Hailer sidebar */\n async editMultiple(\n activityIds: string[]\n ) {\n return await this.client.requestAsync('ui.activity.editMultiple', [activityIds]);\n }\n}\n", "import { Client } from \"@wishcore/wish-rpc\";\n\n/**\n * Valid tab types for opening discussions.\n * - Private discussions: \"discussions\" | \"files\" | \"info\" | \"location\"\n * - Group discussions: \"discussion\" | \"overview\" | \"files\"\n */\nexport type DiscussionTabTypes =\n | \"discussions\"\n | \"files\"\n | \"location\"\n | \"info\"\n | \"discussion\"\n | \"overview\"\n | \"detail\"\n | \"participants\"\n | \"linkedFrom\"\n | \"options\";\n\nexport class Discussion {\n constructor(private client: Client) {}\n\n /** Opens a discussion/chat in Hailer sidebar */\n async open(\n /** Hailer Discussion Id */\n discussionId: string,\n options?: {\n /** Which tab to open in discussion aside (only applies to group discussions) */\n tab?: DiscussionTabTypes;\n /** Whether to expand the sidebar if collapsed (default: true) */\n expandIfCollapsed?: boolean;\n },\n ): Promise<void> {\n await this.client.requestAsync(\"ui.discussion.open\", [\n discussionId,\n ...(options ? [options] : []),\n ]);\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('ui.snackbar.open', [text, buttonLabel, duration]);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\n\n/**\n * @deprecated Use FileApi from '@hailer/app-sdk' instead.\n * This class is kept for backwards compatibility.\n *\n * @example\n * // New way (recommended):\n * import { FileApi } from '@hailer/app-sdk';\n * const fileApi = new FileApi(client);\n * const fileId = await fileApi.upload(base64Data, filename, { isPublic: false });\n */\nexport class Files {\n constructor(private client: Client) {}\n\n /**\n * Uploads a file to Hailer\n *\n * @deprecated Use FileApi.upload() instead\n *\n * @param file file to be uploaded\n * @param filename name of the file\n * @param options upload options\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('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';\n\nexport class Workflow {\n constructor(private client: Client) {}\n\n function = {\n /**\n * Opens the function editor dialog for a specific field\n * @param fieldId The ID of the field to edit\n * @param options Additional options including workflowId and activityId\n */\n edit: async (\n workflowId: string,\n fieldId: string,\n ): Promise<void> => {\n await this.client.requestAsync('ui.workflow.function.edit', [workflowId, fieldId]);\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport { Activity } from './ui/activity';\nimport { Discussion } from './ui/discussion';\nimport { Snackbar } from './ui/snackbar';\nimport { Files } from './ui/files';\nimport { Workflow } from './ui/workflow';\n\n\nexport class Ui {\n public activity;\n public discussion;\n public snackbar;\n public files;\n public insight;\n public workflow;\n\n constructor(private client: Client) {\n this.activity = new Activity(client);\n this.discussion = new Discussion(client);\n this.snackbar = new Snackbar(client);\n this.workflow = new Workflow(client);\n\n this.insight = {\n create: async (\n /** Defaults to App workspace */\n workspaceId?: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.create', [workspaceId]);\n },\n edit: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.edit', [insightId]);\n },\n delete: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.delete', [insightId]);\n },\n permission: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.permission', [insightId]);\n }\n };\n\n this.files = new Files(client);\n }\n}\n", "export const DEFAULT_ALLOWED_URLS = [\n 'https://app.hailer.com',\n 'https://next.hailer.com',\n 'https://testapp.hailer.biz',\n 'https://app.hailer.biz',\n 'https://app.hailer.local.gd',\n 'https://app.k8s.hailer.com',\n 'https://next.k8s.hailer.com',\n 'https://localhost:9443'\n];\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://app.hailer.local.gd': 'https://api.hailer.local.gd',\n 'https://app.k8s.hailer.com': 'https://api.k8s.hailer.com',\n 'https://next.k8s.hailer.com': 'https://api.k8s.hailer.com',\n 'https://localhost:9443': 'http://localhost:1337',\n}\n", "import { Options } from '../../hailer-api';\nimport { Config } 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<Config> {\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 { HailerError, Product, ProductListResponse, ProductSearchFilter, ProductSearchOption, ProductType } from '../../types';\n\nexport class ProductPublicApi {\n constructor(private options: Options) {}\n\n /** \n * Lists products from Hailer market\n *\n * @param filter ProductSearchFilter\n * @param options ProductSearchOption\n *\n * @returns List of products in Hailer market filtered with supplied options\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(\n filter?: ProductSearchFilter, \n options?: ProductSearchOption\n ): Promise<ProductListResponse> {\n \n const res = await fetch(this.options.publicBackendUrl + '/api/v3/product/list', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([filter, options])\n });\n\n if (!res.ok) {\n throw new HailerError(await res.json())\n }\n return await res.json();\n }\n\n /** \n * Gets single product from Hailer market\n *\n * @param id Product Id\n *\n * @returns Single product from Hailer market or undefined if no product found\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(id: string): Promise<Product | undefined> {\n const res = await fetch(this.options.publicBackendUrl + '/api/v3/product/get', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([id])\n });\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 { Product } from '../types';\nimport { App } from './public/app';\nimport { Form } from './public/form';\nimport { InsightPublicApi } from './public/insight';\nimport { ProductPublicApi } from './public/product';\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 /** Access public Product information */\n public product: ProductPublicApi;\n\n constructor(options: Options) {\n this.insight = new InsightPublicApi(options);\n this.form = new Form(options);\n this.app = new App(options);\n this.product = new ProductPublicApi(options);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, IdsMap, 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 return await this.client.requestAsync('workflow.list', []);\n } catch (error: any) {\n console.error(error.msg, error);\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets a single process from a workspace\n * \n * @param workflowId 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(workflowId: string): Promise<Workflow> {\n try {\n return await this.client.requestAsync('workflow.get', [workflowId]);\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 install(workflowSpec: any, option?: { workspaceId?: string }): Promise<IdsMap> {\n try {\n return await this.client.requestAsync('workflow.install', [workflowSpec, option]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { Config, HailerError, ProductVersion, Version } 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 product: {\n /** Check if product is installed */\n isProductInstalled(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get version */\n get(\n id: string\n ): Promise<ProductVersion | undefined>\n\n /** Install app from Hailer market */\n install(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get installed version */\n getInstalledVersion(id: string): Promise<Version>\n\n /** Get manifest content from Hailer market */\n getManifest(id: string): Promise<any>\n };\n\n constructor(private client: Client) {\n this.product = {\n isProductInstalled: this.isProductInstalled.bind(this),\n get: this.get.bind(this),\n install: this.install.bind(this),\n getInstalledVersion: this.getInstalledVersion.bind(this),\n getManifest: this.getManifest.bind(this),\n };\n }\n\n config = {\n update: async (config: Config, option?: { appId?: string }): Promise<void> => {\n try {\n return await this.client.requestAsync('app.config.update', [config, ...option ? [option] : []]);\n } catch (error: any) {\n console.log('Errorasd ', error);\n throw new HailerError(error);\n }\n }\n }\n\n /** \n * Check if product is installed\n *\n * @param productId Id of product in Hailer market\n * \n * @param workspaceId Id of workspace\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async isProductInstalled(productId: string, workspaceId: string): Promise<boolean> {\n try {\n return await this.client.requestAsync('app.product.isProductInstalled', [productId, workspaceId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get version\n *\n * @param id targetId\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async get(\n id: string\n ): Promise<ProductVersion | undefined> {\n try {\n return await this.client.requestAsync('app.product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Install app from Hailer market\n *\n * @param productId Id of product in Hailer market\n *\n * @param workspaceId Id of workspace where the product will be installed\n * \n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async install(productId: string, workspaceId: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('app.product.install', [productId, workspaceId]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get installed version from Hailer market\n *\n * @param id Id of product in Hailer market\n *\n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getInstalledVersion(id: string): Promise<Version> {\n try {\n const result = await this.client.requestAsync('app.product.getInstalledVersion', [id]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get manifest content from Hailer market\n *\n * @param id target Id\n *\n * @returns Manifest content\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getManifest(id: string): Promise<any> {\n try {\n return await this.client.requestAsync('app.product.getManifest', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \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, options: { update?: true }): Promise<InsightData> {\n\n try {\n /*data = [{ insightId, { headers, rows, time } }] */\n return await this.client.requestAsync('insight.data', [insightId, ...options ? [options] : []]);\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 await this.client.requestAsync('insight.list', []);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get Insight data \n * \n * @returns data from the Insight\n *\n * @throws {HailerError} if request is incorrect\n */\n /* @private */ async update(insightId: string, update: Partial<InsightDoc>): Promise<InsightDoc[]> {\n try {\n return await this.client.requestAsync('insight.update', [insightId, update]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n } \n}\n\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, PermissionMap } 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 PermissionApi {\n\n constructor(private client: Client) {}\n\n map = async (): Promise<PermissionMap> => {\n try {\n return await this.client.requestAsync('permission.map', []);\n } catch (error: any) {\n console.log('Failed to read permissions from Hailer, error:', error);\n throw new HailerError(error);\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, Product, ProductSearchOption, ProductSearchFilter, ProductListResponse } from '../types';\n\nexport class ProductApi {\n constructor(private client: Client) {}\n\n /** \n * Lists products from Hailer market\n *\n * @param filter ProductSearchFilter\n * @param options ProductSearchOption\n *\n * @returns List of products in Hailer market filtered with supplied options\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(\n filter?: ProductSearchFilter, \n options?: ProductSearchOption): Promise<ProductListResponse> {\n try {\n const res = await this.client.requestAsync('product.list', [filter, options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets single product from Hailer market\n *\n * @param id Product Id\n *\n * @returns Single product from Hailer market or undefined if no product found\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(id: string): Promise<Product | undefined> {\n try {\n return await this.client.requestAsync('product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates product in Hailer market\n * \n * @param targetId link to targetId (version)\n * @param name Name of the product\n * @param description Description what this product is doing\n * @param icon Icon id for the product\n * @param images List of fileIds for showing pictures of the product\n * @param externalUrl Public URL for creator to show more information about the product\n * @param publisher Publisher (author)\n * @param type App, template, music etc.\n * \n * @returns Created product in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n async create(\n product: {\n targetId?: string,\n name: string,\n description?: string,\n icon?: string,\n images?: string[],\n externalUrl?: string,\n publisher?: string,\n type?: string\n }\n ): Promise<Product> {\n try {\n const result = await this.client.requestAsync('product.create', [product]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates product in Hailer market\n *\n * @param id Id of product in Hailer market\n * @param name Name of the product\n * @param description Description what this product is doing\n * @param icon Icon id for the product\n * @param images List of fileIds for showing pictures of the product\n * @param externalUrl Public URL for creator to show more information about the product\n * @param publisher Publisher (Author)\n * @param public: Visible or not in Hailer market\n * @param type App, template, music etc.\n *\n * @returns Updated product in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n async update(\n id: string,\n product: {\n name?: string,\n description?: string,\n icon?: string,\n images?: string[],\n externalUrl?: string,\n publisher?: string,\n public?: boolean,\n type?: string\n }\n ): Promise<Product> {\n try {\n const result = await this.client.requestAsync('product.update', [id, product]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Remove product from Hailer market\n *\n * @param id Id of product in Hailer market\n *\n * @returns true, if removed\n *\n * @throws {HailerError} if request is incorrect\n */\n async remove(id: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('product.remove', [id]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Set product as public or not (visible) in Hailer market\n *\n * @param id Id of product in Hailer market\n * @param isPublic Visible or not in Hailer market\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n async setPublic(\n id: string,\n isPublic: boolean\n ): Promise<boolean> {\n try {\n return await this.client.requestAsync('product.setPublic', [id, isPublic]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport {\n HailerError,\n PricingData,\n CreatePricingRequest,\n UpdatePricingRequest,\n CreatePurchaseRequest,\n CreatePurchaseResponse,\n Purchase,\n StripeTaxCalculationRequest,\n StripeTaxCalculationResponse\n} from '../types';\n\nexport class Payment {\n constructor(private client: Client) {}\n\n /** \n * Creates pricing configuration for a product\n *\n * @param request CreatePricingRequest containing productId, types, and providers\n *\n * @returns Created pricing configuration\n *\n * @throws {HailerError} if request is incorrect or product not found\n */\n async createPricing(request: CreatePricingRequest): Promise<PricingData> {\n try {\n const res = await this.client.requestAsync('payment.createPricing', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates pricing configuration for a product\n *\n * @param request UpdatePricingRequest containing productId, types, and providers\n *\n * @returns Updated pricing configuration\n *\n * @throws {HailerError} if request is incorrect, product not found, or pricing doesn't exist\n */\n async updatePricing(request: UpdatePricingRequest): Promise<PricingData> {\n try {\n const res = await this.client.requestAsync('payment.updatePricing', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets pricing configuration for a product\n *\n * @param productId Product ID to get pricing for\n *\n * @returns Pricing configuration or null if not found\n *\n * @throws {HailerError} if request is incorrect or product not found\n */\n async getPricing(productId: string): Promise<PricingData | null> {\n try {\n const res = await this.client.requestAsync('payment.getPricing', [{ productId }]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates a product purchase/subscription\n *\n * @param request CreatePurchaseRequest containing productId, workspaceId, and planType\n *\n * @returns Purchase creation result with status and details\n *\n * @throws {HailerError} if request is incorrect, product not found, or payment fails\n */\n async createPurchase(request: CreatePurchaseRequest): Promise<CreatePurchaseResponse> {\n try {\n const res = await this.client.requestAsync('payment.createPurchase', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /**\n * Gets purchases for a workspace\n *\n * @param workspaceId Workspace ID to get purchases for\n *\n * @returns Array of purchases for the workspace\n *\n * @throws {HailerError} if request is incorrect or workspace not found\n */\n async getPurchases(workspaceId: string): Promise<Purchase[]> {\n try {\n const res = await this.client.requestAsync('payment.getPurchases', [{ workspaceId }]);\n return res || [];\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Calculates Stripe tax for line items\n *\n * @param request StripeTaxCalculationRequest containing workspaceId and lineItems\n *\n * @returns Tax calculation result with amounts, rates, and country information\n *\n * @throws {HailerError} if request is incorrect, workspace not found, or Stripe customer not found\n */\n async calculateStripeTax(request: StripeTaxCalculationRequest): Promise<StripeTaxCalculationResponse> {\n try {\n const res = await this.client.requestAsync('payment.calculateStripeTax', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport {\n HailerError,\n AdminWorkspaceListRequest,\n AdminWorkspaceListResponse,\n AdminWorkspace,\n AdminCreateStripeSessionRequest,\n AdminCreateStripeSessionResponse,\n AdminCreateInvoiceIntegrationRequest,\n AdminCreateInvoiceIntegrationResponse,\n AdminUpdateWorkspaceSubscriptionRequest,\n AdminUpdatePurchasePriceRequest,\n AdminWorkspaceUsersListRequest,\n AdminWorkspaceUsersListResponse,\n AdminUpdateUserRequest,\n AdminUpdateUserResponse,\n AdminTokenTransactionsListRequest,\n AdminTokenTransactionsListResponse,\n AdminUpdateOverridesRequest,\n AdminUpdateMarketplaceSettingsRequest,\n AdminInvoiceListRequest,\n AdminInvoiceListResponse,\n AdminInvoiceUpdateHandledRequest,\n AdminInvoiceUpdateHandledResponse,\n AdminRevenueListRequest,\n AdminRevenueListResponse,\n AdminDashboardStatisticsResponse,\n AdminDashboardTrendsResponse,\n AdminReferralCodeListRequest,\n AdminReferralCodeListResponse,\n AdminReferralEventListRequest,\n AdminReferralEventListResponse\n} from '../types';\n\nexport class Admin {\n constructor(private client: Client) {}\n\n /**\n * Referral management endpoints\n */\n public referral = {\n /**\n * Lists all referral codes with optional filters\n */\n listCodes: async (request?: AdminReferralCodeListRequest): Promise<AdminReferralCodeListResponse> => {\n try {\n const res = await this.client.requestAsync('admin.referral.listCodes', [request?.filter || null, request?.options || null]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Lists referral events with optional filters\n */\n listEvents: async (request?: AdminReferralEventListRequest): Promise<AdminReferralEventListResponse> => {\n try {\n const res = await this.client.requestAsync('admin.referral.listEvents', [request?.filter || null, request?.options || null]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Updates a referral code's bonus amount or active status\n */\n updateCode: async (codeId: string, updates: { bonusTokens?: number; isActive?: boolean }): Promise<boolean> => {\n try {\n const res = await this.client.requestAsync('admin.referral.updateCode', [{ codeId, ...updates }]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n };\n\n /**\n * Lists workspaces with search, pagination, and sorting\n *\n * @param request AdminWorkspaceListRequest containing filter and options\n *\n * @returns List of workspaces with total count\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listWorkspaces(request?: AdminWorkspaceListRequest): Promise<AdminWorkspaceListResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets detailed information about a specific workspace\n *\n * @param workspaceId The ID of the workspace to retrieve\n *\n * @returns Workspace details including payment information\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async getWorkspace(workspaceId: string): Promise<AdminWorkspace> {\n try {\n const res = await this.client.requestAsync('admin.workspace.get', [workspaceId]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Creates a Stripe checkout session for workspace subscription\n *\n * @param request AdminCreateStripeSessionRequest containing workspace details and payment info\n *\n * @returns AdminCreateStripeSessionResponse with success status and session URL\n *\n * @throws {HailerError} if request fails, user not authorized, or workspace already has subscription\n */\n async createStripeSession(request: AdminCreateStripeSessionRequest): Promise<AdminCreateStripeSessionResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.createStripeSession', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Creates an invoice integration for workspace subscription\n *\n * @param request AdminCreateInvoiceIntegrationRequest containing workspace details and payment info\n *\n * @returns AdminCreateInvoiceIntegrationResponse with success status\n *\n * @throws {HailerError} if request fails, user not authorized, or workspace already has subscription\n */\n async createInvoiceIntegration(request: AdminCreateInvoiceIntegrationRequest): Promise<AdminCreateInvoiceIntegrationResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.createInvoiceIntegration', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace subscription billing information\n *\n * @param request AdminUpdateWorkspaceSubscriptionRequest containing purchase ID and new billing details\n *\n * @returns boolean indicating whether the update was successful\n *\n * @throws {HailerError} if request fails, user not authorized, or purchase not found\n */\n async updateWorkspaceSubscription(request: AdminUpdateWorkspaceSubscriptionRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateSubscription', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates purchase price for active invoice products\n *\n * @param request AdminUpdatePurchasePriceRequest containing purchase ID, workspace ID, and new price\n *\n * @returns boolean indicating whether the update was successful\n *\n * @throws {HailerError} if request fails, user not authorized, purchase not found, or not an invoice product\n */\n async updatePurchasePrice(request: AdminUpdatePurchasePriceRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.purchase.updatePrice', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists users in a workspace with search, filtering, pagination, and sorting\n * If no workspaceId provided, lists all users across all workspaces\n *\n * @param request AdminWorkspaceUsersListRequest containing optional workspace ID, filter and options\n *\n * @returns List of workspace users with total count and role information\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async listWorkspaceUsers(request: AdminWorkspaceUsersListRequest): Promise<AdminWorkspaceUsersListResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.listUsers', [request.workspaceId, request.filter, request.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates a user's information (currently supports email verification only)\n *\n * @param request AdminUpdateUserRequest containing user ID and updates\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, user not found, or user not authorized\n */\n async updateUser(request: AdminUpdateUserRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.user.update', [request.userId, request.updates]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace token balance\n *\n * @param request Object containing workspaceId, tokenAmount, and optional payout parameters\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async updateTokenBalance(request: {\n workspaceId: string;\n tokenAmount: number;\n payoutMonth?: number;\n payoutYear?: number;\n payoutType?: 'admin_bonus' | 'creator_payout';\n creatorPercent?: number;\n }): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateTokenBalance', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace license overrides\n *\n * @param request AdminUpdateOverridesRequest containing workspaceId and overrides object\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async updateWorkspaceOverrides(request: AdminUpdateOverridesRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateOverrides', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n async updateWorkspaceMarketplaceSettings(request: AdminUpdateMarketplaceSettingsRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateMarketplaceSettings', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists token transactions with filtering, pagination, and statistics\n *\n * @param request AdminTokenTransactionsListRequest containing optional filter and pagination options\n *\n * @returns AdminTokenTransactionsListResponse with transactions, total count, and statistics\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listTokenTransactions(request?: AdminTokenTransactionsListRequest): Promise<AdminTokenTransactionsListResponse> {\n try {\n const res = await this.client.requestAsync('admin.tokenTransaction.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists Hailer invoice purchases with filtering, pagination, and workspace grouping\n *\n * @param request AdminInvoiceListRequest containing optional filter and pagination options\n *\n * @returns AdminInvoiceListResponse with invoices, total count, and workspace groups\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listInvoices(request?: AdminInvoiceListRequest): Promise<AdminInvoiceListResponse> {\n try {\n const res = await this.client.requestAsync('admin.invoice.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates the handled status for one or more Hailer invoice purchases\n *\n * @param request AdminInvoiceUpdateHandledRequest containing purchase ID(s) and handled status\n *\n * @returns AdminInvoiceUpdateHandledResponse with count of updated records\n *\n * @throws {HailerError} if request fails, purchase not found, or not a Hailer invoice purchase\n */\n async updateInvoiceHandled(request: AdminInvoiceUpdateHandledRequest): Promise<AdminInvoiceUpdateHandledResponse> {\n try {\n const res = await this.client.requestAsync('admin.invoice.updateHandled', [request.purchaseIds, request.handled]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n async listMonthlyRevenue(request: AdminRevenueListRequest): Promise<AdminRevenueListResponse> {\n try {\n const res = await this.client.requestAsync('admin.revenue.list', [\n request.month,\n request.year,\n request.filter,\n request.options\n ]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets dashboard statistics including counts for users, workspaces, activities, and messages\n * Includes today's count, total count, last week count, and week-over-week growth percentage\n *\n * @param entities Optional array of entity types to fetch. Defaults to all entities.\n * Valid values: 'users', 'workspaces', 'activities', 'messages', 'userMessages'\n *\n * @returns AdminDashboardStatisticsResponse with statistics for requested entity types\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async getDashboardStatistics(entities?: string[]): Promise<AdminDashboardStatisticsResponse> {\n try {\n const res = await this.client.requestAsync('admin.dashboard.statistics', [entities]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets dashboard trends showing daily creation counts over time\n *\n * @param days Number of days to fetch (30, 90, 180, or 365). Defaults to 30.\n * @param entities Optional array of entity types to fetch. Defaults to ['users', 'workspaces'].\n * Valid values: 'users', 'workspaces'\n *\n * @returns AdminDashboardTrendsResponse with daily counts for requested entity types\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async getDashboardTrends(days?: 30 | 90 | 180 | 365, entities?: string[]): Promise<AdminDashboardTrendsResponse> {\n try {\n const res = await this.client.requestAsync('admin.dashboard.trends', [days, entities]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError } from '../types';\n\nexport interface MetricDefinition {\n id: string;\n name: string;\n description: string;\n category: string;\n supportsTimeRange: boolean;\n supportsBreakdown: boolean;\n}\n\nexport interface MetricData {\n metricType: string;\n timestamp: number;\n current: {\n value: number;\n labels?: any;\n };\n timeSeries?: Array<{\n timestamp: number;\n value: number;\n }>;\n breakdown?: {\n byWorkspace?: Record<string, number>;\n byUser?: Record<string, number>;\n };\n metadata: {\n scope?: any;\n permissions?: any;\n source: string;\n executionTime?: number;\n };\n}\nexport interface MetricOptions {\n workspaceId?: string;\n userId?: string;\n timeRange?: {\n start: number;\n end: number;\n };\n interval?: '1m' | '5m' | '15m' | '30m' | '1h' | '5h';\n\n // Query Builder options (optional)\n /** Aggregation function to apply */\n aggregation?: 'sum' | 'avg' | 'max' | 'min' | 'count' | 'rate' | 'increase';\n\n /** Group results by specified labels (max 3). Allowed: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */\n groupBy?: string[];\n\n /** Limit results to top N values (1-100) */\n topk?: number;\n\n /** Additional label filters. Allowed keys: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */\n labelFilters?: Record<string, string>;\n}\n\nexport interface MetricListOptions {\n category?: string;\n includeDetails?: boolean;\n}\n\nexport interface WorkspaceMetricsListOptions {\n /** Array of workspace IDs to look up */\n workspaceIds?: string[];\n /** Search by workspace name (minimum 3 characters) */\n name?: string;\n}\n\nexport type WorkspaceMetricsListResult = Array<{\n _id: string;\n name: string;\n}>;\n\nexport interface UserMetricsListOptions {\n /** Array of user IDs to look up */\n userIds: string[];\n}\n\nexport type UserMetricsListResult = Array<{\n _id: string;\n name?: string;\n email: string;\n}>;\n\nexport class MetricsApi {\n constructor(private client: Client) {}\n\n /**\n * Get list of available metrics for current user based on permissions\n * @param options Optional filtering options\n * @returns Array of metric IDs or detailed metric definitions\n */\n async list(options?: MetricListOptions): Promise<string[] | MetricDefinition[]> {\n try {\n return await this.client.requestAsync('metrics.list', options ? [options] : []);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * Get metrics data with optional Query Builder\n * @param metricTypes Single metric or array of metrics to fetch\n * @param options Optional filtering, time range, and Query Builder options\n * @returns Metric data with values and optional time series\n *\n * @example\n * // Simple query\n * await api.metrics.get('hailer.activity.create', { workspaceId: 'abc123' });\n *\n * @example\n * // Query Builder: Top 10 users by activity\n * await api.metrics.get('hailer.activity.create', {\n * workspaceId: 'abc123',\n * timeRange: { start: Date.now() - 86400000, end: Date.now() },\n * aggregation: 'sum',\n * groupBy: ['user'],\n * topk: 10\n * });\n */\n async get(metricTypes: string | string[], options?: MetricOptions): Promise<MetricData> {\n try {\n // Backend expects array, convert string to array if needed\n const metricsArray = Array.isArray(metricTypes) ? metricTypes : [metricTypes];\n return await this.client.requestAsync('metrics.get', [metricsArray, options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * Admin endpoints for metrics management\n */\n admin = {\n /**\n * Get list of workspaces for admin metrics filtering\n * @param options Lookup by workspaceIds array or name search (min 3 chars)\n * @returns List of workspaces\n *\n * @example\n * // Look up by workspace IDs\n * await api.metrics.admin.workspacesList({ workspaceIds: ['id1', 'id2'] });\n *\n * @example\n * // Search by workspace name\n * await api.metrics.admin.workspacesList({ name: 'Sales' });\n */\n workspacesList: async (options: WorkspaceMetricsListOptions): Promise<WorkspaceMetricsListResult> => {\n try {\n return await this.client.requestAsync('metrics.workspaceSearch', [options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Get list of users for admin metrics filtering\n * @param options Lookup by userIds array\n * @returns List of users with _id, name, email\n *\n * @example\n * // Look up by user IDs\n * await api.metrics.admin.usersList({ userIds: ['id1', 'id2'] });\n */\n usersList: async (options: UserMetricsListOptions): Promise<UserMetricsListResult> => {\n try {\n return await this.client.requestAsync('metrics.user.list', [options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n };\n}", "import { Client } from \"@wishcore/wish-rpc\";\n\nexport interface HTTPFetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n}\n\nexport interface HTTPUploadEntry {\n /** Form field name */\n name: string;\n /** Value: plain string for fields, base64 string for files */\n value: string;\n /** When present, entry is a file with this filename (value is base64) */\n filename?: string;\n}\n\nexport interface HTTPFetchResponse {\n status: number;\n statusText: string;\n headers: Record<string, string>;\n body: string;\n}\n\n/**\n * Events emitted by the parent frame for a HTTP WebSocket connection.\n */\ninterface HTTPWsEvent {\n connectionId: string;\n event: \"open\" | \"message\" | \"close\" | \"error\";\n data?: string;\n code?: number;\n reason?: string;\n}\n\n/**\n * A WebSocket-like object that proxies through the parent Hailer frame.\n */\nexport class HTTPWebSocket {\n public onopen: ((event: any) => void) | null = null;\n public onmessage: ((event: { data: string }) => void) | null = null;\n public onclose: ((event: { code?: number; reason?: string }) => void) | null =\n null;\n public onerror: ((event: any) => void) | null = null;\n public readyState: number = WebSocket.CONNECTING;\n\n public connectionId: string | null = null;\n\n constructor(\n private client: Client,\n url: string,\n ) {\n // Open a streaming RPC request \u2014 callback fires for each WS event from parent\n this.client.request(\n \"http.ws.open\",\n [url],\n (error: any, data: HTTPWsEvent) => {\n if (error) {\n this.readyState = WebSocket.CLOSED;\n this.onerror?.({ error });\n return;\n }\n\n if (!data) return;\n\n // Store connectionId from first event\n if (data.connectionId && !this.connectionId) {\n this.connectionId = data.connectionId;\n }\n\n switch (data.event) {\n case \"open\":\n this.readyState = WebSocket.OPEN;\n this.onopen?.({});\n break;\n case \"message\":\n this.onmessage?.({ data: data.data ?? \"\" });\n break;\n case \"close\":\n this.readyState = WebSocket.CLOSED;\n this.onclose?.({ code: data.code, reason: data.reason });\n break;\n case \"error\":\n this.onerror?.({ error: data.data });\n break;\n }\n },\n );\n }\n\n send(data: string): void {\n if (this.readyState !== WebSocket.OPEN || !this.connectionId) {\n throw new Error(\"WebSocket is not open\");\n }\n this.client\n .requestAsync(\"http.ws.send\", [this.connectionId, data])\n .catch((error) => {\n this.onerror?.({ error });\n });\n }\n\n close(code?: number, reason?: string): void {\n if (this.connectionId) {\n this.client\n .requestAsync(\"http.ws.close\", [this.connectionId, code, reason])\n .catch((error) => {\n this.onerror?.({ error });\n });\n }\n this.readyState = WebSocket.CLOSING;\n }\n}\n\n/**\n * Proxy module for making authenticated HTTP and WebSocket requests\n * through the parent Hailer frame.\n */\nexport class HttpApi {\n constructor(private client: Client) {}\n\n /**\n * Make an HTTP request through the parent frame.\n * The parent's browser context sends the hlrkey cookie automatically.\n */\n async fetch(\n url: string,\n options?: HTTPFetchOptions,\n ): Promise<HTTPFetchResponse> {\n return await this.client\n .requestAsync(\"http.fetch\", [url, options])\n .catch((error) => {\n throw error;\n });\n }\n\n /**\n * Upload files through the parent frame as multipart/form-data.\n * Files are sent as base64 strings and reconstructed into FormData by the parent.\n * The parent's browser context sends the hlrkey cookie automatically.\n */\n async upload(\n url: string,\n entries: HTTPUploadEntry[],\n ): Promise<HTTPFetchResponse> {\n return await this.client\n .requestAsync(\"http.upload\", [url, entries])\n .catch((error) => {\n throw error;\n });\n }\n\n /**\n * Open a WebSocket connection through the parent frame.\n * Returns a HTTPWebSocket that mimics the native WebSocket API.\n */\n openWebSocket(url: string): HTTPWebSocket {\n return new HTTPWebSocket(this.client, url);\n }\n}\n"],
|
|
5
|
-
"mappings": "q7BAMA,IAAaA,EAAb,KAAmB,CAKf,YAAoBC,EAAuCC,EAAsB,CAA7D,KAAA,MAAAD,EAJZ,KAAA,SAAuB,CAAA,EACvB,KAAA,GAAK,EACL,KAAA,IAAM,MAGPC,GAAQA,EAAK,MACZ,KAAK,IAAMA,EAAK,IAExB,CAEA,SAAO,CACH,KAAK,SAAW,KAChB,KAAK,MAAQ,IACjB,CAEA,gBAAgBC,EAAG,CAEf,IAAMC,EAAM,CAAC,EAAED,EAAI,KAAOA,EAAI,KAAOA,EAAI,KAEnCE,EAAKF,EAAI,KAAOA,EAAI,KAAOA,EAAI,KAAOA,EAAI,IAE1CG,EAAU,KAAK,SAASD,CAAE,EAC5BE,EAEJ,GAAGD,GAAW,OAAOA,EAAQ,IAAO,WAAY,CAC5C,IAAIE,EACDL,EAAI,IAEHG,EAAQ,GAAG,KAAKA,EAAQ,QAAS,KAAM,KAAM,EAAI,EAE9CA,EAAQ,SACP,QAAQ,IAAI,qDAAqD,GAGjEE,EAAML,EAAI,IAAMA,EAAI,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J,CACA,KAAK,QAAQ,SAASA,CAAI,CAC9B,CAAC,EAGD,KAAK,OAAO,QAAQ,SAAU,CAAC,EAAG,CAACH,EAAYG,EAAWE,IAAiB,CACvE,GAAIL,EAAO,CACP,QAAQ,IAAI,gBAAiBA,EAAOG,CAAI,EACxC,MACJ,CAEIA,GACA,KAAK,QAAQ,UAAUA,CAAI,CAEnC,CAAC,EAED,KAAK,QAAU,GAEf,KAAK,QAAQ,YAAY,EACzB,MACJ,CAGA,GAAI,CAAC,KAAK,MACN,OAGJ,KAAK,OAAO,gBAAgBvB,CAAG,CACnC,MAAgB,CACZ,QAAQ,IAAI,8BAA8B,CAC9C,CACJ,CAAC,CACL,CAEA,MAAgB,CACZ,MAAO,CACH,QAAS,KAAK,QACd,OAAQ,KAAK,OACb,QAAS,KAAK,QACd,YAAa,KAAK,WACtB,CACJ,CACJ",
|
|
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", "CustomError", "message", "code", "HailerError", "error", "UserApi", "client", "userId", "error", "HailerError", "Kanban", "client", "processId", "options", "error", "HailerError", "activityId", "priority", "ActivityApi", "client", "Kanban", "processId", "phaseId", "options", "error", "HailerError", "activityId", "workflowId", "activities", "requests", "WorkspaceApi", "client", "error", "HailerError", "template", "id", "workspaceId", "productId", "TeamApi", "client", "error", "HailerError", "FileApi", "client", "fileId", "error", "HailerError", "file", "filename", "options", "base64Data", "resolve", "reject", "reader", "Activity", "client", "activityId", "options", "processId", "activityIds", "Discussion", "client", "discussionId", "options", "Snackbar", "client", "text", "buttonLabel", "duration", "Files", "client", "file", "filename", "options", "resolve", "reject", "reader", "Workflow", "client", "workflowId", "fieldId", "Ui", "client", "Activity", "Discussion", "Snackbar", "Workflow", "workspaceId", "insightId", "Files", "DEFAULT_ALLOWED_URLS", "DEFAULT_BACKEND_URL", "publicBackendMap", "App", "options", "manifestFile", "location", "manifestUrl", "manifestContent", "appId", "Form", "options", "formsKey", "res", "HailerError", "formsData", "InsightPublicApi", "options", "insightKey", "res", "HailerError", "input", "data", "row", "object", "header", "headerIndex", "ProductPublicApi", "options", "filter", "res", "HailerError", "id", "HailerPublicApi", "options", "InsightPublicApi", "Form", "App", "ProductPublicApi", "WorkflowApi", "client", "error", "HailerError", "workflowId", "workflowSpec", "option", "AppApi", "client", "config", "option", "error", "HailerError", "productId", "workspaceId", "id", "InsightApi", "client", "insightId", "options", "error", "HailerError", "update", "PermissionApi", "client", "error", "HailerError", "ProductApi", "client", "filter", "options", "error", "HailerError", "id", "product", "isPublic", "Payment", "client", "request", "error", "HailerError", "productId", "workspaceId", "Admin", "client", "request", "error", "HailerError", "codeId", "updates", "workspaceId", "entities", "days", "MetricsApi", "client", "options", "error", "HailerError", "metricTypes", "metricsArray", "HTTPWebSocket", "client", "url", "error", "data", "code", "reason", "HttpApi", "options", "entries", "HailerApi", "options", "allowedUrls", "DEFAULT_ALLOWED_URLS", "msg", "UserApi", "AppApi", "ActivityApi", "InsightApi", "WorkspaceApi", "TeamApi", "FileApi", "WorkflowApi", "PermissionApi", "HailerPublicApi", "Ui", "ProductApi", "Payment", "Admin", "MetricsApi", "HttpApi", "registerMessage", "DEFAULT_BACKEND_URL", "config", "error", "url", "event", "data", "publicBackendMap", "end"]
|
|
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/ball.ts", "../src/modules/activity.ts", "../src/modules/workspace.ts", "../src/modules/team.ts", "../src/modules/file.ts", "../src/modules/ui/activity.ts", "../src/modules/ui/discussion.ts", "../src/modules/ui/snackbar.ts", "../src/modules/ui/files.ts", "../src/modules/ui/workflow.ts", "../src/modules/ui.ts", "../src/constants.ts", "../src/modules/public/app.ts", "../src/modules/public/form.ts", "../src/modules/public/insight.ts", "../src/modules/public/product.ts", "../src/modules/public.ts", "../src/modules/workflow.ts", "../src/modules/app.ts", "../src/modules/insight.ts", "../src/modules/permission.ts", "../src/modules/product.ts", "../src/modules/payment.ts", "../src/modules/admin.ts", "../src/modules/metrics.ts", "../src/modules/http.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/workspace';\nimport { TeamApi } from './modules/team';\nimport { FileApi } from './modules/file';\nimport { ApiInfo, Config, Settings, Signal } from './types';\nimport { Ui } from './modules/ui';\nimport { DEFAULT_ALLOWED_URLS, 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';\nimport { PermissionApi } from './modules/permission';\nimport { ProductApi } from './modules/product';\nimport { Payment } from './modules/payment';\nimport { Admin } from './modules/admin';\nimport { MetricsApi } from './modules/metrics';\nimport { HttpApi } from './modules/http';\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: Settings) => 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: Signal) => void;\n /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/\n allowedUrls?: string[];\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 workspace: WorkspaceApi;\n public team: TeamApi;\n public file: FileApi;\n public workflow: WorkflowApi;\n public permission: PermissionApi;\n public product: ProductApi;\n public payment: Payment;\n public admin: Admin;\n public metrics: MetricsApi;\n /** HTTP proxy for making authenticated HTTP/WebSocket requests through the parent frame */\n public http: HttpApi;\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 /** If set it indicates that app is locked to a specific workspaceId */\n private workspaceId?: string;\n private client: Client;\n private config?: Config;\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 \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.workspace = new WorkspaceApi(this.client);\n this.team = new TeamApi(this.client);\n this.file = new FileApi(this.client);\n this.workflow = new WorkflowApi(this.client);\n this.permission = new PermissionApi(this.client);\n this.public = new HailerPublicApi(this.options);\n this.ui = new Ui(this.client);\n this.product = new ProductApi(this.client);\n this.payment = new Payment(this.client);\n this.admin = new Admin(this.client);\n this.metrics = new MetricsApi(this.client);\n this.http = new HttpApi(this.client);\n\n const registerMessage = JSON.stringify({ op: 'register', args: [{ appApiVersion: '2' }] });\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\n this.appId = msg.data.appId;\n this.workspaceId = msg.data.workspaceId;\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('ui.settings', [], (error: any, data: Settings, 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('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 this.client.request('signal', [], (error: any, data: any, end: boolean) => {\n if (error) {\n console.log('signal error:', error, data);\n return;\n }\n\n if (data) {\n this.options.signals?.(data);\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.log('Dropped invalid JSON message');\n }\n });\n }\n\n info(): ApiInfo {\n return {\n hostUrl: this.hostUrl,\n config: this.config,\n outside: this.outside,\n workspaceId: this.workspaceId,\n }\n }\n}\n", "export interface User {\n _id: string;\n firstname: string;\n lastname: string;\n // email: string;\n // lastSeen: number;\n // status?: string;\n // managedUser?: boolean;\n // removed?: number;\n // defaultProfilepic: string;\n}\n\n/* export 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} */\nexport interface Workspace {\n _id: string;\n name: string;\n}\n\nexport interface Team {\n _id: string;\n name: string;\n}\n\nexport interface TeamsByWorkspace {\n [workspaceId: string]: Team[];\n}\n\nexport interface ActivityFieldRange {\n start: number;\n end: number;\n }\n\n export interface ActivityFieldLink {\n _id: string;\n name: string;\n }\n \nexport interface ActivityFieldError {\n error?: string\n}\n\nexport type ActivityFieldValue = boolean | number | string | (ActivityFieldCountry & ActivityFieldError & ActivityFieldRange & ActivityFieldLink);\n\nexport type ActivityFieldUpdateValue = ActivityFieldValue | null;\n/*\nexport interface UserMap {\n [userId: string]: User;\n}\n\n*/\n\nexport interface ActivityFieldCountry {\n /** ISO 3166-1 alpha-2 (cca2) */\n code: string;\n}\nexport interface Activity {\n _id: string;\n process: string;\n teamAccount: TeamAccount // TODO: Convert in frontend\n created: number;\n uid: string;\n workspaceId: 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?: {\n [fieldId: string]: ActivityFieldValue\n };\n // fields?: { [fieldId: string]: string | number };\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 Config {\n [fieldName: string]: string;\n}\n\nexport type WorkflowFieldType = (\n 'activitylink' |\n 'country' |\n 'date' |\n 'daterange' |\n 'datetime' |\n 'numeric' |\n 'numericunit' |\n 'teams' |\n 'text' |\n 'textarea' |\n 'textunit' |\n 'textpredefinedoptions' |\n 'time' |\n 'timerange' |\n 'datetimerange' |\n 'users' |\n 'linkedfrom' |\n 'subheader'\n);\n\nexport interface WorkflowField {\n _id: string;\n type: WorkflowFieldType;\n label: string;\n required: boolean;\n unit: string;\n placeholder: string;\n description: string;\n data: string[];\n functionEnabled: boolean;\n editable: boolean;\n functionVariables?: { [key: string]: any };\n}\n\nexport interface DocumentTemplate {\n templateId?: string; // Valid ObjectId for regular templates, or non-ObjectId string for multi-pdf templates\n name: string;\n order?: number;\n}\n\nexport interface Workflow {\n _id: string;\n name: string;\n description?: string;\n fields: { [fieldId: string]: any };\n fieldsOrder: string[];\n phases: { [phase_id: string]: WorkflowPhase };\n phasesOrder: string[];\n enablePredefinedName?: boolean;\n nameFunctionEnabled?: boolean;\n nameEditable?: boolean;\n productInstalledId: string;\n workspaceId: string;\n documentTemplates?: DocumentTemplate[];\n /*\n defaultView: 'table' | 'kanban' | 'map' | 'calendar';\n fields: { [fieldId: string]: any };\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 enablePreselectedTeam?: boolean;\n initPhaseDescription?: string;\n locationRequired?: boolean;\n nameColumnText?: string;\n nameFunction?: string;\n nameFunctionVariables?: any;\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 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 fields?: string[];\n primaryDateField?: string;\n primaryNumericField?: string\n /*\n followers: string[];\n created: number;\n uid?: string;\n members?: any[]\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/**\n * ```ts\n * { [templateId: string]: string }\n * ```\n */\nexport interface IdsMap {\n [templateId: string]: string;\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 type WorkflowPermission = 'admin' | 'any' | 'ownteam' | 'own' | 'guest' | 'none';\nexport type WorkflowPhasePermission = 'edit' | 'view' | 'none';\n\nexport interface PermissionPath {\n type: 'network' | 'user' | 'team' | 'group';\n id: string;\n permission: WorkflowPermission | WorkflowPhasePermission;\n};\n\nexport interface WorkflowPermissionMap {\n [workflowId: string]: {\n // hasAccess: boolean;\n isAdmin: boolean;\n permission: WorkflowPermission;\n permissions: PermissionPath;\n phases: {\n [phaseId: string]: {\n // name: string;\n // hasAccess: boolean;\n permission: WorkflowPhasePermission,\n permissions: PermissionPath[];\n restricted: boolean;\n }\n };\n teams: string[];\n\n }\n};\n\nexport interface WorkspaceRolesPermission {\n isAdmin: boolean;\n isOwner: boolean;\n isGuest: boolean;\n isInviter: boolean;\n isUser: boolean;\n // custom: roleSchema,\n};\n\nexport interface PermissionMap {\n [userId: string]: {\n workflow: WorkflowPermissionMap,\n workspace: WorkspaceRolesPermission,\n // calendar: calendarPermissionMapSchema,\n // insight: insightPermissionMapSchema,\n // app: appPermissionMapSchema,\n // teams: Joi.array().items(validTeamId),\n // permits: Joi.array().items(Joi.string()),\n },\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 _id: string;\n name: string;\n /** Key for accessing Insight when set to public */\n publicKey?: string;\n presets: {\n version: 1;\n name: string | 'default';\n options: any;\n }[];\n /** To be used with SQLite if we want to.... */\n query?: string;\n sources: InsightWorkflowSource[];\n public: boolean;\n \n // members: Member[];\n // updated: number;\n /** User id of creator */\n // uid: string;\n // workspaceId: string;\n /** sandboxed javascript with access to all activities in given workflows */\n // function?: string;\n\n \n}\n\nexport type InsightPublic = Omit<InsightDoc, '_id'>;\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}\n\n\n/** Simplistic syntax for add/remove/replace */\nexport interface IdSetUpdate {\n /** Clear all existing */\n '*'?: null,\n /** Add: true, Remove: null */\n [id: string]: true | null | undefined\n}\nexport interface ActivityLocation {\n data: {\n lat: number;\n lng: number;\n }[],\n label?: string;\n type: 'area' | 'point' | 'polyline';\n};\nexport interface ActivityUpdateOptions {\n fields?: ActivityFieldUpdateValue,\n teamId?: string,\n location?: ActivityLocation\n phaseId?: string,\n files?: IdSetUpdate,\n followers?: IdSetUpdate,\n};\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 PrintRequest {\n activityId: string;\n /** Template ID for regular templates */\n templateId?: string;\n /** Template name for multi-pdf templates (when templateId is empty) */\n templateName?: string;\n /** Whether to save the PDF to the file system */\n savePdf?: boolean;\n}\n\nexport interface PrintResponse {\n filename: string;\n /** Base64-encoded document data */\n data: string;\n mimeType: string;\n}\n\nexport interface Settings {\n theme: 'light' | 'dark'\n preferredLanguages: string[];\n}\n\nexport interface ApiInfo {\n /** Url of the Hailer instance hosting the API */\n hostUrl?: string;\n config?: Config;\n outside: boolean | null;\n workspaceId?: string;\n}\n\nexport interface ApiError {\n code: number,\n msg: string, \n debug: object\n}\n\nclass CustomError extends Error {\n public msg: string;\n public code: number;\n \n constructor(message: string, code: number) {\n super(message);\n this.name = this.constructor.name;\n this.msg = message;\n this.code = code;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\nexport class HailerError extends CustomError {\n public debug: object\n public details?: any\n\n constructor(error: {code: number, msg: string, details?: any, debug: any}) {\n super(error.msg, error.code)\n\n this.details = error.details;\n this.debug = error.debug;\n }\n\n toString() {\n console.log('Going to log an error... ;-D');\n return `${super.toString()} \\nField: ${this.details}, ${this.debug}`;\n }\n}\n\nexport interface Signal {\n name: string;\n data: any;\n}\n\nexport interface Product extends ProductType {\n _id: string;\n targetId?: string;\n name: string;\n description?: string;\n icon?: string;\n images?: string[];\n externalUrl?: string;\n publisher?: string;\n ctaLabel: string;\n ctaLink: string;\n /** Available or not in app store */\n public?: boolean;\n cid?: string;\n uid: string;\n}\n\nexport interface ProductListResponse {\n products: Product[];\n totalCount: number;\n}\n\nexport interface ProductSearchOption {\n limit?: number,\n skip?: number,\n search?: string,\n reverse?: boolean,\n sortBy?: 'name' | 'created' | 'updated' | 'type',\n sortOrder?: 'asc' | 'desc'\n}\n\nexport interface ProductSearchFilter extends ProductType {\n public?: boolean,\n cid?: string,\n uid?: string,\n}\n\nexport interface ProductType {\n type?: 'app' | 'template' | 'integration' | 'expert' | 'ai-agent',\n}\n\nexport interface ProductVersion {\n _id: string;\n name: string;\n versions?: Version[];\n cid?: string;\n}\n\nexport interface Version {\n version: string;\n description: string;\n packageHash: string;\n created: number;\n}\n\n// Payment and Pricing Types\nexport interface PricingPlan {\n planId: 'monthly' | 'yearly' | 'one_time';\n label: string;\n price: number;\n currency: string;\n interval: 'month' | 'year' | null;\n}\n\nexport interface PaymentProvider {\n priceId?: {\n monthly?: string;\n yearly?: string;\n one_time?: string;\n };\n trial_days?: number;\n}\n\nexport interface PricingProviders {\n stripe?: PaymentProvider;\n paddle?: PaymentProvider;\n // fuze?: PaymentProvider; // Hidden for now\n}\n\nexport interface PricingData {\n _id?: string;\n productId?: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n created?: number;\n updated?: number;\n}\n\nexport interface CreatePricingRequest {\n productId: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n}\n\nexport interface UpdatePricingRequest {\n productId: string;\n types: PricingPlan[];\n providers: PricingProviders;\n paymentEnabled?: boolean;\n}\n\nexport interface CreatePurchaseRequest {\n productId: string;\n workspaceId: string;\n planType: 'monthly' | 'yearly' | 'one_time';\n successUrl?: string; // Optional for backward compatibility\n cancelUrl?: string; // Optional for backward compatibility\n useTokens?: boolean; // Optional - use workspace tokens for one-time purchases\n}\n\nexport interface CreatePurchaseResponse {\n status: 'installed_free' | 'subscription_created' | 'checkout_required' | 'payment_processed' | 'payment_failed';\n message?: string;\n productId?: string;\n planType?: string;\n purchaseId?: string;\n subscriptionId?: string;\n provider?: string;\n trialDays?: number;\n checkoutUrl?: string;\n error?: string; // For payment failure details\n}\n\nexport interface Purchase {\n _id: string;\n uid: string;\n cid: string;\n productId?: string;\n productName?: string;\n provider?: 'stripe' | 'paddle' | 'fuze';\n type: 'monthly' | 'yearly' | 'one_time';\n purchaseType: 'workspace' | 'product';\n startedAt: number;\n created: number;\n updated?: number;\n customStatus?: string;\n expiresAt?: number;\n trialDays?: number;\n trialStart?: number;\n trialEnd?: number;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n pricing?: {\n amount: number;\n currency: string;\n interval: string;\n source: string;\n };\n stripe?: {\n customerId?: string;\n checkoutSessionId?: string;\n subscriptionId?: string;\n paymentIntentId?: string;\n status?: string;\n };\n paddle?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n fuze?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n}\n\n// Admin interfaces\nexport interface AdminWorkspaceListItem {\n _id: string;\n name: string;\n memberCount: number;\n created: number;\n updated?: number;\n creatorEmail?: string;\n paymentPlan?: string;\n monthlyPrice?: number;\n paymentMethod?: 'subscription' | 'invoice';\n subscriptionActive?: boolean;\n provider?: string;\n stripeStatus?: string;\n hasPendingSubscription?: boolean;\n tokenBalance?: number;\n autoReloadEnabled?: boolean;\n}\n\nexport interface AdminWorkspaceListRequest {\n filter?: {\n name?: string;\n };\n options?: {\n search?: string;\n sortBy?: string;\n sortOrder?: string;\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminWorkspaceListResponse {\n workspaces: AdminWorkspaceListItem[];\n totalCount: number;\n}\n\n// Purchase data for admin interfaces\nexport interface AdminPurchaseData {\n _id: string;\n uid: string;\n cid: string;\n productId?: string | null;\n productName?: string | null;\n provider?: string;\n type: string;\n purchaseType: 'workspace' | 'product';\n billingType?: 'subscription' | 'invoice';\n planName?: 'flexible' | 'pro' | 'business' | 'enterprise';\n startedAt?: number;\n expiresAt?: number;\n created: number;\n updated?: number;\n customStatus?: string;\n trialStart?: number;\n trialEnd?: number;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n pricing?: {\n amount: number;\n currency: string;\n interval?: string;\n source: 'purchase_record' | 'pricing_collection';\n };\n availablePricing?: Array<{\n planId: 'monthly' | 'yearly' | 'one_time';\n label: string;\n price: number;\n currency: string;\n interval: string | null;\n }>;\n trialDays?: number;\n stripe?: {\n customerId?: string;\n checkoutSessionId?: string;\n subscriptionId?: string;\n paymentIntentId?: string;\n status?: string;\n };\n paddle?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n fuze?: {\n customerId?: string;\n subscriptionId?: string;\n status?: string;\n };\n}\n\n// Single workspace for admin get method (extends list item with purchase data)\nexport interface AdminWorkspaceOverrides {\n // Boolean overrides\n functionFields?: boolean;\n kanban?: boolean;\n customRoles?: boolean;\n restricted?: boolean;\n insight?: boolean;\n dataExport?: boolean;\n documentGenerator?: boolean;\n groups?: boolean;\n print?: boolean;\n isolatedTeams?: boolean;\n managedUsers?: boolean;\n translations?: boolean;\n indexedData?: boolean;\n fastFunctions?: boolean;\n activityRecovery?: boolean;\n videoCall?: boolean;\n // Number overrides\n users?: number | null;\n // String overrides\n tourIdentifier?: string;\n}\n\nexport interface AdminWorkspaceMarketplaceSettings {\n creatorPercent: number;\n}\n\nexport interface AdminWorkspace extends AdminWorkspaceListItem {\n purchaseId?: string;\n purchases?: AdminPurchaseData[];\n overrides?: AdminWorkspaceOverrides;\n marketplace?: AdminWorkspaceMarketplaceSettings;\n}\n\nexport interface AdminUpdateOverridesRequest {\n workspaceId: string;\n overrides: AdminWorkspaceOverrides;\n}\n\nexport interface AdminUpdateMarketplaceSettingsRequest {\n workspaceId: string;\n creatorPercent: number;\n}\n\nexport interface AdminCreateStripeSessionRequest {\n workspaceId: string;\n planName: 'flexible' | 'pro' | 'business' | 'enterprise';\n customPrice: number;\n paymentMethod: 'stripe';\n baseUrl: string;\n}\n\nexport interface AdminCreateStripeSessionResponse {\n success: boolean;\n message: string;\n sessionUrl?: string;\n}\n\nexport interface AdminCreateInvoiceIntegrationRequest {\n workspaceId: string;\n planName: 'enterprise'; // Only enterprise for invoice\n customPrice: number;\n paymentMethod: 'hailer';\n}\n\nexport interface AdminCreateInvoiceIntegrationResponse {\n success: boolean;\n message: string;\n}\n\nexport interface AdminUpdateWorkspaceSubscriptionRequest {\n purchaseId: string;\n billingType: 'subscription' | 'invoice';\n customPrice: number;\n planName: 'flexible' | 'pro' | 'business' | 'enterprise';\n tokenAmount?: number;\n}\n\nexport interface AdminUpdatePurchasePriceRequest {\n purchaseId: string;\n workspaceId: string;\n newPrice: number;\n}\n\nexport interface AdminWorkspaceUser {\n _id: string;\n name: string;\n email: string;\n role: 'owner' | 'admin' | 'user' | 'guest' | 'inviter';\n joined?: number;\n lastActive?: number;\n emailVerified?: boolean;\n managedUser?: boolean | null;\n}\n\nexport interface AdminWorkspaceUsersListRequest {\n workspaceId?: string;\n filter?: {\n email?: string;\n role?: string;\n };\n options?: {\n search?: string;\n sortBy?: string;\n sortOrder?: string;\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminWorkspaceUsersListResponse {\n users: AdminWorkspaceUser[];\n totalCount: number;\n}\n\nexport interface AdminUpdateUserRequest {\n userId: string;\n updates: {\n emailVerified?: boolean;\n };\n}\n\nexport interface AdminUpdateUserResponse {\n success: boolean;\n}\n\nexport interface AdminUpdateTokenBalanceRequest {\n workspaceId: string;\n tokenAmount: number;\n payoutType?: 'admin_bonus' | 'creator_payout';\n payoutMonth?: number;\n payoutYear?: number;\n creatorPercent?: number;\n}\n\nexport interface AdminTokenTransaction {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n type: 'purchase' | 'deduction' | 'bonus' | 'admin_adjustment' | 'creator_payout';\n amount: number;\n reason: string;\n meta?: {\n payoutMonth?: number;\n payoutYear?: number;\n creatorProfit?: number;\n creatorPercent?: number;\n [key: string]: any\n };\n createdAt: number;\n}\n\nexport interface AdminTokenTransactionFilter {\n workspaceId?: string;\n type?: 'purchase' | 'deduction' | 'bonus' | 'admin_adjustment' | 'creator_payout';\n operation?: string;\n dateFrom?: number;\n dateTo?: number;\n search?: string;\n}\n\nexport interface AdminTokenTransactionStatistics {\n netChange: number;\n totalPurchases: number;\n totalPurchasesEuro: number;\n purchasesBySource: {\n stripe: {\n count: number;\n tokens: number;\n revenue: number;\n };\n adminPortal: {\n count: number;\n tokens: number;\n revenue: number;\n };\n };\n totalDeductions: number;\n totalDeductionsEuro: number;\n consumptionByOperation: {\n [operation: string]: {\n count: number;\n tokens: number;\n };\n };\n totalBonuses: number;\n totalBonusesEuro: number;\n totalCreatorPayouts: number;\n totalCreatorPayoutsEuro: number;\n totalRefunds: number;\n totalRefundsEuro: number;\n}\n\nexport interface AdminTokenTransactionsListRequest {\n filter?: AdminTokenTransactionFilter;\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminTokenTransactionsListResponse {\n transactions: AdminTokenTransaction[];\n totalCount: number;\n statistics: AdminTokenTransactionStatistics;\n}\n\nexport interface AdminInvoicePurchase {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n purchaseType: 'workspace' | 'product';\n type: 'monthly' | 'yearly' | 'one_time';\n provider: 'hailer';\n billingType: 'invoice';\n planName?: string;\n productId?: string;\n productName?: string;\n pricePaid?: {\n amount: number;\n currency: string;\n };\n customStatus?: string;\n invoiceHandled?: boolean;\n startedAt: number;\n expiresAt?: number;\n trialStart?: number;\n trialEnd?: number;\n}\n\nexport interface AdminInvoiceListRequest {\n filter?: {\n workspaceId?: string;\n purchaseType?: 'workspace' | 'product';\n status?: 'handled' | 'unhandled' | 'all';\n search?: string;\n };\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminInvoiceWorkspaceGroup {\n cid: string;\n workspaceName: string;\n allHandled: boolean;\n purchases: AdminInvoicePurchase[];\n}\n\nexport interface AdminInvoiceListResponse {\n invoices: AdminInvoicePurchase[];\n totalCount: number;\n workspaceGroups: AdminInvoiceWorkspaceGroup[];\n}\n\nexport interface AdminInvoiceUpdateHandledRequest {\n purchaseIds: string | string[];\n handled: boolean;\n}\n\nexport interface AdminInvoiceUpdateHandledResponse {\n updatedCount: number;\n}\n\n// Monthly Revenue Tracking Types\nexport interface AdminRevenuePurchase {\n _id: string;\n uid: string;\n cid: string;\n workspaceName: string;\n created: number;\n purchaseType: 'workspace' | 'product';\n type: 'monthly' | 'yearly' | 'one_time';\n provider: string;\n productId?: string;\n productName?: string;\n productOwnerCid?: string;\n productOwnerName?: string;\n pricePaid?: { amount: number; currency: string };\n startedAt: number;\n expiresAt?: number;\n // Calculated fields\n normalizedMonthlyRevenue: number; // Yearly \u00F7 12, others as-is\n isMarketplace: boolean;\n profitToHailer: number;\n profitToCreator?: number;\n statusInMonth: 'active' | 'started' | 'ended';\n}\n\nexport interface AdminRevenueWorkspaceGroup {\n cid: string;\n workspaceName: string;\n totalRevenue: number;\n totalMRR: number;\n totalOneTime: number;\n totalCreatorProfit: number;\n totalHailerProfit: number;\n creatorPercent: number;\n productCount: number;\n paidOut?: boolean;\n productBreakdown: Array<{\n productId: string;\n productName: string;\n installationCount: number;\n totalRevenue: number;\n subscriptionTypes: {\n monthly: number;\n yearly: number;\n one_time: number;\n };\n installedBy: Array<{\n cid: string;\n workspaceName: string;\n type: string;\n }>;\n }>;\n purchases: AdminRevenuePurchase[];\n}\n\nexport interface AdminRevenueWorkspaceSubscriptions {\n totalWorkspaces: number;\n totalRevenue: number;\n byPlan: Array<{\n planName: string;\n count: number;\n revenue: number;\n }>;\n}\n\nexport interface AdminRevenueStatistics {\n selectedMonth: { month: number; year: number };\n totalMRR: number;\n totalOneTime: number;\n totalRevenue: number;\n activeCount: number;\n hailerProfit: number;\n creatorProfit: number;\n}\n\nexport interface AdminRevenueListRequest {\n month: number;\n year: number;\n filter?: {\n workspaceId?: string;\n purchaseType?: 'workspace' | 'product';\n subscriptionType?: 'monthly' | 'yearly' | 'one_time';\n search?: string;\n };\n options?: {\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n skip?: number;\n };\n}\n\nexport interface AdminRevenueListResponse {\n purchases: AdminRevenuePurchase[];\n totalCount: number;\n workspaceGroups: AdminRevenueWorkspaceGroup[];\n statistics: AdminRevenueStatistics;\n}\n\n// Dashboard Statistics Types\nexport interface AdminDashboardEntityStatistics {\n today: number;\n total: number;\n lastWeek: number;\n growth: number;\n}\n\nexport interface AdminDashboardStatisticsResponse {\n users: AdminDashboardEntityStatistics;\n workspaces: AdminDashboardEntityStatistics;\n activities: AdminDashboardEntityStatistics;\n messages: AdminDashboardEntityStatistics;\n userMessages: AdminDashboardEntityStatistics;\n}\n\n// Dashboard Trends Types\nexport interface AdminDashboardTrendDataPoint {\n date: string;\n count: number;\n}\n\nexport interface AdminDashboardTrendsResponse {\n users?: AdminDashboardTrendDataPoint[];\n workspaces?: AdminDashboardTrendDataPoint[];\n}\n\n// Stripe Tax Calculation Types\nexport interface StripeTaxLineItem {\n amount: number;\n reference: string;\n tax_code?: string;\n quantity?: number;\n}\n\nexport interface StripeTaxCalculationRequest {\n workspaceId: string;\n lineItems: StripeTaxLineItem[];\n}\n\nexport interface StripeTaxLineItemResult {\n reference: string;\n amount: number;\n taxAmount: number;\n totalAmount: number;\n}\n\nexport interface StripeTaxCalculationResponse {\n amountSubtotal: number;\n amountTax: number;\n amountTotal: number;\n taxRate?: number;\n country?: string;\n countryName?: string;\n currency: string;\n lineItems: StripeTaxLineItemResult[];\n}\n\n// Admin Referral Types\nexport interface AdminReferralCode {\n _id: string;\n code: string;\n uid: string;\n cid: string;\n ownerEmail?: string;\n workspaceName?: string;\n bonusTokens: number;\n isActive: boolean;\n totalReferrals: number;\n totalTokensAwarded: number;\n created: number;\n}\n\nexport interface AdminReferralCodeListRequest {\n filter?: {\n isActive?: boolean;\n cid?: string;\n };\n options?: {\n search?: string;\n limit?: number;\n skip?: number;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n };\n}\n\nexport interface AdminReferralCodeListResponse {\n codes: AdminReferralCode[];\n totalCount: number;\n stats: {\n activeCount: number;\n totalReferrals: number;\n totalTokensAwarded: number;\n };\n}\n\nexport interface AdminReferralEvent {\n _id: string;\n referralCodeId: string;\n referralCode: string;\n referrerUid: string;\n referrerCid: string;\n refereeUid: string;\n refereeCid: string;\n refereeEmail?: string;\n refereeWorkspaceName?: string;\n status: 'pending' | 'completed' | 'failed';\n bonusTokensAwarded: number;\n failureReason?: string;\n created: number;\n completedAt?: number;\n}\n\nexport interface AdminReferralEventListRequest {\n filter?: {\n referralCodeId?: string;\n referrerCid?: string;\n status?: 'pending' | 'completed' | 'failed';\n };\n options?: {\n limit?: number;\n skip?: number;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n };\n}\n\nexport interface AdminReferralEventListResponse {\n events: AdminReferralEvent[];\n totalCount: number;\n stats: {\n completedCount: number;\n pendingCount: number;\n totalTokensAwarded: number;\n };\n}\n\nexport interface BallHolder {\n userId: string;\n assignedAt: string;\n}\n\nexport interface BallHolderEntry {\n activityId: string;\n discussionId: string;\n activityName: string;\n ballHolder: BallHolder;\n}\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 return await this.client.requestAsync('user.get', [userId]);\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 return await this.client.requestAsync('user.current', []);\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<User[]> {\n try {\n return await this.client.requestAsync('user.list', []);\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('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('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('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 { BallHolderEntry, HailerError } from '../../types';\n\nexport class Ball {\n constructor(private client: Client) { }\n\n /**\n * Pass the ball (activity responsibility) to another user.\n *\n * @param activityId activity to update\n * @param toUserId recipient user id; must be a participant of the activity's discussion\n *\n * @throws {HailerError} if the activity has no ball tracking, the caller is a guest, or the target is not a participant\n */\n async pass(activityId: string, toUserId: string): Promise<void> {\n try {\n return await this.client.requestAsync('activity.ball.pass', [activityId, toUserId]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * Take the ball (activity responsibility) for the current user.\n *\n * @param activityId activity to take\n *\n * @throws {HailerError} if ball tracking is disabled, the caller is a guest, or the caller lacks phase access\n */\n async take(activityId: string): Promise<void> {\n try {\n return await this.client.requestAsync('activity.ball.take', [activityId]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * List ball holders for activity discussions.\n *\n * @param discussionIds `'*'` to load every ball holder the user can see, or an array of discussionIds to restrict the result.\n * Unknown or non-participant discussionIds are silently dropped. An empty array returns `[]` without hitting the backend.\n *\n * @returns array of ball holder entries for activities where the caller can access both the discussion and the workflow\n *\n * @throws {HailerError} if the request is invalid\n */\n async list(discussionIds: string[] | '*'): Promise<BallHolderEntry[]> {\n if (Array.isArray(discussionIds) && discussionIds.length === 0) {\n return [];\n }\n try {\n return await this.client.requestAsync('activity.ball.list', [discussionIds]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { ActivityCreateOptions, ActivityListOptions, Activity, HailerError, ActivityFieldUpdateValue, ActivityUpdateOptions, ActivityFieldValue, PrintRequest, PrintResponse } from '../types';\nimport { Kanban } from './activity/kanban';\nimport { Ball } from './activity/ball';\n\nexport class ActivityApi {\n public kanban: Kanban\n public ball: Ball\n constructor(private client: Client) {\n this.kanban = new Kanban(client)\n this.ball = new Ball(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 return await this.client.requestAsync('activity.list', [processId, phaseId, options]);\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('activity.get', [activityId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async create(workflowId: string | undefined, activities: { name?: string; fields?: { [id: string]: ActivityFieldValue }, phaseId?: string, teamId?: string }[], options?: ActivityCreateOptions ): Promise<Activity[]> {\n try {\n return await this.client.requestAsync('activity.create', [workflowId, activities, ...options ? [options] : []]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates activites\n *\n * @returns The number of updated activities\n *\n * @throws {HailerError} if request is incorrect\n */\n async update(\n activities: { _id: string, name?: string, fields?: { [id: string]: ActivityFieldUpdateValue }, phaseId?: string, teamId?: string }[],\n options?: ActivityUpdateOptions\n ): Promise<number> {\n try {\n return await this.client.requestAsync('activity.update', [activities, ...options ? [options] : []]);\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 return await this.client.requestAsync('activity.remove', [activities]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Prints activities using document templates\n *\n * @param requests Array of print requests\n * @param requests[].activityId The ID of the activity to print\n * @param requests[].templateId Template ID for regular templates\n * @param requests[].templateName Template name for multi-pdf templates (when templateId is empty)\n * @param requests[].savePdf Whether to save the generated PDF\n *\n * @returns PDF data with filename, base64 data, and mimeType\n *\n * @throws {HailerError} if request is incorrect\n */\n async print(requests: PrintRequest[]): Promise<PrintResponse> {\n try {\n return await this.client.requestAsync('activity.print', [requests]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, ProductVersion, Workspace } from '../types';\n\nexport class WorkspaceApi {\n product: {\n /** Publish template in Hailer market */\n publishTemplate: (template: {\n workspaceId?: string,\n versionId?: string,\n version: string,\n versionDescription: string,\n title: string,\n description: string\n }) => Promise<ProductVersion>\n\n /** Check if product is installed */\n isProductInstalled(\n id: string,\n workspaceId: string\n ): Promise<boolean>\n\n /** Get version */\n get(\n id: string\n ): Promise<ProductVersion | undefined>\n\n /** Install template from Hailer market */\n install(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get manifest content from Hailer market */\n getManifest(id: string): Promise<any>\n };\n\n constructor(private client: Client) {\n this.product = {\n publishTemplate: this.publishTemplate.bind(this),\n isProductInstalled: this.isProductInstalled.bind(this),\n get: this.get.bind(this),\n install: this.install.bind(this),\n getManifest: this.getManifest.bind(this),\n };\n }\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('workspace.current', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /**\n * Returns all workspaces for user if personal app\n * If not personal app it returns only the current workspace\n * @returns the Hailer Workspaces information for the user\n * \n * * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<Workspace[]> {\n try {\n const res = await this.client.requestAsync('workspace.list', []);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n\n /** \n * Publish template in Hailer market\n * \n * @param workspaceId Id of workspace\n * @param versionId link to version (empty if first publish)\n * @param version Version number\n * @param versionDescription Version description\n * @param title\n * @param description\n * \n * @returns Created version in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n private async publishTemplate(\n template: {\n workspaceId?: string,\n versionId?: string,\n version: string,\n versionDescription: string,\n title: string,\n description: string\n }\n ): Promise<ProductVersion> {\n try {\n const result = await this.client.requestAsync('workspace.product.publishTemplate', [template]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Check if product is installed\n *\n * @param id Id of product in Hailer market\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async isProductInstalled(\n id: string,\n workspaceId: string\n ): Promise<boolean> {\n try {\n return await this.client.requestAsync('workspace.product.isProductInstalled', [id, workspaceId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get version\n *\n * @param id targetId\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async get(\n id: string\n ): Promise<ProductVersion | undefined> {\n try {\n return await this.client.requestAsync('workspace.product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Install template from Hailer market\n *\n * @param productId Id of product in Hailer market\n * \n * @param workspaceId Id of workspace where the product will be installed\n *\n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async install(productId: string, workspaceId: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('workspace.product.install', [productId, workspaceId]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get manifest content from Hailer market\n *\n * @param id target Id\n *\n * @returns Manifest content\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getManifest(id: string): Promise<any> {\n try {\n return await this.client.requestAsync('workspace.product.getManifest', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, TeamsByWorkspace } from '../types';\n\nexport class TeamApi {\n constructor(private client: Client) {}\n\n /**\n * Lists all teams grouped by workspace ID\n *\n * @returns Teams grouped by workspace ID\n *\n * @example\n * const teams = await hailer.team.list();\n * // { \"workspaceId1\": [{ _id: \"...\", name: \"Team A\" }], ... }\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(): Promise<TeamsByWorkspace> {\n try {\n return await this.client.requestAsync('team.list', []);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError } from '../types';\n\nexport interface FileResponse {\n filename: string;\n /** Base64-encoded file data */\n data: string;\n mimeType: string;\n}\n\nexport interface UploadOptions {\n /** Whether the file should be publicly accessible */\n isPublic?: boolean;\n}\n\nexport class FileApi {\n constructor(private client: Client) {}\n\n /**\n * Gets a file by ID and returns it as base64 data\n *\n * @param fileId The ID of the file to fetch\n *\n * @returns File data with filename, base64 data, and mimeType\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(fileId: string): Promise<FileResponse> {\n try {\n return await this.client.requestAsync('file.get', [fileId]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Uploads a file to Hailer\n *\n * @param file File to be uploaded\n * @param filename Name of the file\n * @param options Upload options\n *\n * @returns File ID in Hailer\n *\n * @throws {HailerError} if upload fails\n */\n async upload(file: File, filename: string, options?: UploadOptions): Promise<string> {\n try {\n const base64Data = await this.toBase64(file);\n return await this.client.requestAsync('file.upload', [base64Data, filename, !!options?.isPublic]);\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n private toBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve((reader.result as string) ?? '');\n reader.onerror = reject;\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('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 /** Phase ID to pre-select */\n phaseId?: string,\n /** Team ID to pre-select */\n teamId?: string,\n /** Prepopulate fields */\n fields?: {\n [fieldId: string]: number | string | { start: number, end: number },\n },\n location?: {\n type: 'area' | 'point' | 'polyline',\n data: { lng: number, lat: number }[],\n },\n }\n ): Promise<{ _id: string, name: string } | null> {\n return await this.client.requestAsync('ui.activity.create', [processId, ...options ? [options] : []]);\n }\n\n /** Opens multiple activity edit view in Hailer sidebar */\n async editMultiple(\n activityIds: string[]\n ) {\n return await this.client.requestAsync('ui.activity.editMultiple', [activityIds]);\n }\n}\n", "import { Client } from \"@wishcore/wish-rpc\";\n\n/**\n * Valid tab types for opening discussions.\n * - Private discussions: \"discussions\" | \"files\" | \"info\" | \"location\"\n * - Group discussions: \"discussion\" | \"overview\" | \"files\"\n */\nexport type DiscussionTabTypes =\n | \"discussions\"\n | \"files\"\n | \"location\"\n | \"info\"\n | \"discussion\"\n | \"overview\"\n | \"detail\"\n | \"participants\"\n | \"linkedFrom\"\n | \"options\";\n\nexport class Discussion {\n constructor(private client: Client) {}\n\n /** Opens a discussion/chat in Hailer sidebar */\n async open(\n /** Hailer Discussion Id */\n discussionId: string,\n options?: {\n /** Which tab to open in discussion aside (only applies to group discussions) */\n tab?: DiscussionTabTypes;\n /** Whether to expand the sidebar if collapsed (default: true) */\n expandIfCollapsed?: boolean;\n },\n ): Promise<void> {\n await this.client.requestAsync(\"ui.discussion.open\", [\n discussionId,\n ...(options ? [options] : []),\n ]);\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('ui.snackbar.open', [text, buttonLabel, duration]);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\n\n/**\n * @deprecated Use FileApi from '@hailer/app-sdk' instead.\n * This class is kept for backwards compatibility.\n *\n * @example\n * // New way (recommended):\n * import { FileApi } from '@hailer/app-sdk';\n * const fileApi = new FileApi(client);\n * const fileId = await fileApi.upload(base64Data, filename, { isPublic: false });\n */\nexport class Files {\n constructor(private client: Client) {}\n\n /**\n * Uploads a file to Hailer\n *\n * @deprecated Use FileApi.upload() instead\n *\n * @param file file to be uploaded\n * @param filename name of the file\n * @param options upload options\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('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';\n\nexport class Workflow {\n constructor(private client: Client) {}\n\n function = {\n /**\n * Opens the function editor dialog for a specific field\n * @param fieldId The ID of the field to edit\n * @param options Additional options including workflowId and activityId\n */\n edit: async (\n workflowId: string,\n fieldId: string,\n ): Promise<void> => {\n await this.client.requestAsync('ui.workflow.function.edit', [workflowId, fieldId]);\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport { Activity } from './ui/activity';\nimport { Discussion } from './ui/discussion';\nimport { Snackbar } from './ui/snackbar';\nimport { Files } from './ui/files';\nimport { Workflow } from './ui/workflow';\n\n\nexport class Ui {\n public activity;\n public discussion;\n public snackbar;\n public files;\n public insight;\n public workflow;\n\n constructor(private client: Client) {\n this.activity = new Activity(client);\n this.discussion = new Discussion(client);\n this.snackbar = new Snackbar(client);\n this.workflow = new Workflow(client);\n\n this.insight = {\n create: async (\n /** Defaults to App workspace */\n workspaceId?: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.create', [workspaceId]);\n },\n edit: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.edit', [insightId]);\n },\n delete: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.delete', [insightId]);\n },\n permission: async (\n insightId: string\n ): Promise<void> => {\n await client.requestAsync('ui.insight.permission', [insightId]);\n }\n };\n\n this.files = new Files(client);\n }\n}\n", "export const DEFAULT_ALLOWED_URLS = [\n 'https://app.hailer.com',\n 'https://next.hailer.com',\n 'https://testapp.hailer.biz',\n 'https://app.hailer.biz',\n 'https://app.hailer.local.gd',\n 'https://app.k8s.hailer.com',\n 'https://next.k8s.hailer.com',\n 'https://localhost:9443'\n];\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://app.hailer.local.gd': 'https://api.hailer.local.gd',\n 'https://app.k8s.hailer.com': 'https://api.k8s.hailer.com',\n 'https://next.k8s.hailer.com': 'https://api.k8s.hailer.com',\n 'https://localhost:9443': 'http://localhost:1337',\n}\n", "import { Options } from '../../hailer-api';\nimport { Config } 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<Config> {\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 { HailerError, Product, ProductListResponse, ProductSearchFilter, ProductSearchOption, ProductType } from '../../types';\n\nexport class ProductPublicApi {\n constructor(private options: Options) {}\n\n /** \n * Lists products from Hailer market\n *\n * @param filter ProductSearchFilter\n * @param options ProductSearchOption\n *\n * @returns List of products in Hailer market filtered with supplied options\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(\n filter?: ProductSearchFilter, \n options?: ProductSearchOption\n ): Promise<ProductListResponse> {\n \n const res = await fetch(this.options.publicBackendUrl + '/api/v3/product/list', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([filter, options])\n });\n\n if (!res.ok) {\n throw new HailerError(await res.json())\n }\n return await res.json();\n }\n\n /** \n * Gets single product from Hailer market\n *\n * @param id Product Id\n *\n * @returns Single product from Hailer market or undefined if no product found\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(id: string): Promise<Product | undefined> {\n const res = await fetch(this.options.publicBackendUrl + '/api/v3/product/get', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify([id])\n });\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 { Product } from '../types';\nimport { App } from './public/app';\nimport { Form } from './public/form';\nimport { InsightPublicApi } from './public/insight';\nimport { ProductPublicApi } from './public/product';\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 /** Access public Product information */\n public product: ProductPublicApi;\n\n constructor(options: Options) {\n this.insight = new InsightPublicApi(options);\n this.form = new Form(options);\n this.app = new App(options);\n this.product = new ProductPublicApi(options);\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, IdsMap, 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 return await this.client.requestAsync('workflow.list', []);\n } catch (error: any) {\n console.error(error.msg, error);\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets a single process from a workspace\n * \n * @param workflowId 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(workflowId: string): Promise<Workflow> {\n try {\n return await this.client.requestAsync('workflow.get', [workflowId]);\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 install(workflowSpec: any, option?: { workspaceId?: string }): Promise<IdsMap> {\n try {\n return await this.client.requestAsync('workflow.install', [workflowSpec, option]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { Config, HailerError, ProductVersion, Version } 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 product: {\n /** Check if product is installed */\n isProductInstalled(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get version */\n get(\n id: string\n ): Promise<ProductVersion | undefined>\n\n /** Install app from Hailer market */\n install(productId: string, workspaceId: string): Promise<boolean>\n\n /** Get installed version */\n getInstalledVersion(id: string): Promise<Version>\n\n /** Get manifest content from Hailer market */\n getManifest(id: string): Promise<any>\n };\n\n constructor(private client: Client) {\n this.product = {\n isProductInstalled: this.isProductInstalled.bind(this),\n get: this.get.bind(this),\n install: this.install.bind(this),\n getInstalledVersion: this.getInstalledVersion.bind(this),\n getManifest: this.getManifest.bind(this),\n };\n }\n\n config = {\n update: async (config: Config, option?: { appId?: string }): Promise<void> => {\n try {\n return await this.client.requestAsync('app.config.update', [config, ...option ? [option] : []]);\n } catch (error: any) {\n console.log('Errorasd ', error);\n throw new HailerError(error);\n }\n }\n }\n\n /** \n * Check if product is installed\n *\n * @param productId Id of product in Hailer market\n * \n * @param workspaceId Id of workspace\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async isProductInstalled(productId: string, workspaceId: string): Promise<boolean> {\n try {\n return await this.client.requestAsync('app.product.isProductInstalled', [productId, workspaceId]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get version\n *\n * @param id targetId\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n private async get(\n id: string\n ): Promise<ProductVersion | undefined> {\n try {\n return await this.client.requestAsync('app.product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Install app from Hailer market\n *\n * @param productId Id of product in Hailer market\n *\n * @param workspaceId Id of workspace where the product will be installed\n * \n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async install(productId: string, workspaceId: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('app.product.install', [productId, workspaceId]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get installed version from Hailer market\n *\n * @param id Id of product in Hailer market\n *\n * @returns true, if installed else error\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getInstalledVersion(id: string): Promise<Version> {\n try {\n const result = await this.client.requestAsync('app.product.getInstalledVersion', [id]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get manifest content from Hailer market\n *\n * @param id target Id\n *\n * @returns Manifest content\n *\n * @throws {HailerError} if request is incorrect\n */\n private async getManifest(id: string): Promise<any> {\n try {\n return await this.client.requestAsync('app.product.getManifest', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \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, options: { update?: true }): Promise<InsightData> {\n\n try {\n /*data = [{ insightId, { headers, rows, time } }] */\n return await this.client.requestAsync('insight.data', [insightId, ...options ? [options] : []]);\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 await this.client.requestAsync('insight.list', []);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Get Insight data \n * \n * @returns data from the Insight\n *\n * @throws {HailerError} if request is incorrect\n */\n /* @private */ async update(insightId: string, update: Partial<InsightDoc>): Promise<InsightDoc[]> {\n try {\n return await this.client.requestAsync('insight.update', [insightId, update]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n } \n}\n\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, PermissionMap } 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 PermissionApi {\n\n constructor(private client: Client) {}\n\n map = async (): Promise<PermissionMap> => {\n try {\n return await this.client.requestAsync('permission.map', []);\n } catch (error: any) {\n console.log('Failed to read permissions from Hailer, error:', error);\n throw new HailerError(error);\n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError, Product, ProductSearchOption, ProductSearchFilter, ProductListResponse } from '../types';\n\nexport class ProductApi {\n constructor(private client: Client) {}\n\n /** \n * Lists products from Hailer market\n *\n * @param filter ProductSearchFilter\n * @param options ProductSearchOption\n *\n * @returns List of products in Hailer market filtered with supplied options\n *\n * @throws {HailerError} if request is incorrect\n */\n async list(\n filter?: ProductSearchFilter, \n options?: ProductSearchOption): Promise<ProductListResponse> {\n try {\n const res = await this.client.requestAsync('product.list', [filter, options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets single product from Hailer market\n *\n * @param id Product Id\n *\n * @returns Single product from Hailer market or undefined if no product found\n *\n * @throws {HailerError} if request is incorrect\n */\n async get(id: string): Promise<Product | undefined> {\n try {\n return await this.client.requestAsync('product.get', [id]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates product in Hailer market\n * \n * @param targetId link to targetId (version)\n * @param name Name of the product\n * @param description Description what this product is doing\n * @param icon Icon id for the product\n * @param images List of fileIds for showing pictures of the product\n * @param externalUrl Public URL for creator to show more information about the product\n * @param publisher Publisher (author)\n * @param type App, template, music etc.\n * \n * @returns Created product in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n async create(\n product: {\n targetId?: string,\n name: string,\n description?: string,\n icon?: string,\n images?: string[],\n externalUrl?: string,\n publisher?: string,\n type?: string\n }\n ): Promise<Product> {\n try {\n const result = await this.client.requestAsync('product.create', [product]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates product in Hailer market\n *\n * @param id Id of product in Hailer market\n * @param name Name of the product\n * @param description Description what this product is doing\n * @param icon Icon id for the product\n * @param images List of fileIds for showing pictures of the product\n * @param externalUrl Public URL for creator to show more information about the product\n * @param publisher Publisher (Author)\n * @param public: Visible or not in Hailer market\n * @param type App, template, music etc.\n *\n * @returns Updated product in Hailer market\n *\n * @throws {HailerError} if request is incorrect\n */\n async update(\n id: string,\n product: {\n name?: string,\n description?: string,\n icon?: string,\n images?: string[],\n externalUrl?: string,\n publisher?: string,\n public?: boolean,\n type?: string\n }\n ): Promise<Product> {\n try {\n const result = await this.client.requestAsync('product.update', [id, product]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Remove product from Hailer market\n *\n * @param id Id of product in Hailer market\n *\n * @returns true, if removed\n *\n * @throws {HailerError} if request is incorrect\n */\n async remove(id: string): Promise<boolean> {\n try {\n const result = await this.client.requestAsync('product.remove', [id]);\n return result;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Set product as public or not (visible) in Hailer market\n *\n * @param id Id of product in Hailer market\n * @param isPublic Visible or not in Hailer market\n *\n * @returns true if ok else false\n *\n * @throws {HailerError} if request is incorrect\n */\n async setPublic(\n id: string,\n isPublic: boolean\n ): Promise<boolean> {\n try {\n return await this.client.requestAsync('product.setPublic', [id, isPublic]);\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n}\n", "import { Client } from '@wishcore/wish-rpc';\nimport {\n HailerError,\n PricingData,\n CreatePricingRequest,\n UpdatePricingRequest,\n CreatePurchaseRequest,\n CreatePurchaseResponse,\n Purchase,\n StripeTaxCalculationRequest,\n StripeTaxCalculationResponse\n} from '../types';\n\nexport class Payment {\n constructor(private client: Client) {}\n\n /** \n * Creates pricing configuration for a product\n *\n * @param request CreatePricingRequest containing productId, types, and providers\n *\n * @returns Created pricing configuration\n *\n * @throws {HailerError} if request is incorrect or product not found\n */\n async createPricing(request: CreatePricingRequest): Promise<PricingData> {\n try {\n const res = await this.client.requestAsync('payment.createPricing', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Updates pricing configuration for a product\n *\n * @param request UpdatePricingRequest containing productId, types, and providers\n *\n * @returns Updated pricing configuration\n *\n * @throws {HailerError} if request is incorrect, product not found, or pricing doesn't exist\n */\n async updatePricing(request: UpdatePricingRequest): Promise<PricingData> {\n try {\n const res = await this.client.requestAsync('payment.updatePricing', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Gets pricing configuration for a product\n *\n * @param productId Product ID to get pricing for\n *\n * @returns Pricing configuration or null if not found\n *\n * @throws {HailerError} if request is incorrect or product not found\n */\n async getPricing(productId: string): Promise<PricingData | null> {\n try {\n const res = await this.client.requestAsync('payment.getPricing', [{ productId }]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /** \n * Creates a product purchase/subscription\n *\n * @param request CreatePurchaseRequest containing productId, workspaceId, and planType\n *\n * @returns Purchase creation result with status and details\n *\n * @throws {HailerError} if request is incorrect, product not found, or payment fails\n */\n async createPurchase(request: CreatePurchaseRequest): Promise<CreatePurchaseResponse> {\n try {\n const res = await this.client.requestAsync('payment.createPurchase', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error) \n }\n }\n\n /**\n * Gets purchases for a workspace\n *\n * @param workspaceId Workspace ID to get purchases for\n *\n * @returns Array of purchases for the workspace\n *\n * @throws {HailerError} if request is incorrect or workspace not found\n */\n async getPurchases(workspaceId: string): Promise<Purchase[]> {\n try {\n const res = await this.client.requestAsync('payment.getPurchases', [{ workspaceId }]);\n return res || [];\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Calculates Stripe tax for line items\n *\n * @param request StripeTaxCalculationRequest containing workspaceId and lineItems\n *\n * @returns Tax calculation result with amounts, rates, and country information\n *\n * @throws {HailerError} if request is incorrect, workspace not found, or Stripe customer not found\n */\n async calculateStripeTax(request: StripeTaxCalculationRequest): Promise<StripeTaxCalculationResponse> {\n try {\n const res = await this.client.requestAsync('payment.calculateStripeTax', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport {\n HailerError,\n AdminWorkspaceListRequest,\n AdminWorkspaceListResponse,\n AdminWorkspace,\n AdminCreateStripeSessionRequest,\n AdminCreateStripeSessionResponse,\n AdminCreateInvoiceIntegrationRequest,\n AdminCreateInvoiceIntegrationResponse,\n AdminUpdateWorkspaceSubscriptionRequest,\n AdminUpdatePurchasePriceRequest,\n AdminWorkspaceUsersListRequest,\n AdminWorkspaceUsersListResponse,\n AdminUpdateUserRequest,\n AdminUpdateUserResponse,\n AdminTokenTransactionsListRequest,\n AdminTokenTransactionsListResponse,\n AdminUpdateOverridesRequest,\n AdminUpdateMarketplaceSettingsRequest,\n AdminInvoiceListRequest,\n AdminInvoiceListResponse,\n AdminInvoiceUpdateHandledRequest,\n AdminInvoiceUpdateHandledResponse,\n AdminRevenueListRequest,\n AdminRevenueListResponse,\n AdminDashboardStatisticsResponse,\n AdminDashboardTrendsResponse,\n AdminReferralCodeListRequest,\n AdminReferralCodeListResponse,\n AdminReferralEventListRequest,\n AdminReferralEventListResponse\n} from '../types';\n\nexport class Admin {\n constructor(private client: Client) {}\n\n /**\n * Referral management endpoints\n */\n public referral = {\n /**\n * Lists all referral codes with optional filters\n */\n listCodes: async (request?: AdminReferralCodeListRequest): Promise<AdminReferralCodeListResponse> => {\n try {\n const res = await this.client.requestAsync('admin.referral.listCodes', [request?.filter || null, request?.options || null]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Lists referral events with optional filters\n */\n listEvents: async (request?: AdminReferralEventListRequest): Promise<AdminReferralEventListResponse> => {\n try {\n const res = await this.client.requestAsync('admin.referral.listEvents', [request?.filter || null, request?.options || null]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Updates a referral code's bonus amount or active status\n */\n updateCode: async (codeId: string, updates: { bonusTokens?: number; isActive?: boolean }): Promise<boolean> => {\n try {\n const res = await this.client.requestAsync('admin.referral.updateCode', [{ codeId, ...updates }]);\n return res;\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n };\n\n /**\n * Lists workspaces with search, pagination, and sorting\n *\n * @param request AdminWorkspaceListRequest containing filter and options\n *\n * @returns List of workspaces with total count\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listWorkspaces(request?: AdminWorkspaceListRequest): Promise<AdminWorkspaceListResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets detailed information about a specific workspace\n *\n * @param workspaceId The ID of the workspace to retrieve\n *\n * @returns Workspace details including payment information\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async getWorkspace(workspaceId: string): Promise<AdminWorkspace> {\n try {\n const res = await this.client.requestAsync('admin.workspace.get', [workspaceId]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Creates a Stripe checkout session for workspace subscription\n *\n * @param request AdminCreateStripeSessionRequest containing workspace details and payment info\n *\n * @returns AdminCreateStripeSessionResponse with success status and session URL\n *\n * @throws {HailerError} if request fails, user not authorized, or workspace already has subscription\n */\n async createStripeSession(request: AdminCreateStripeSessionRequest): Promise<AdminCreateStripeSessionResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.createStripeSession', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Creates an invoice integration for workspace subscription\n *\n * @param request AdminCreateInvoiceIntegrationRequest containing workspace details and payment info\n *\n * @returns AdminCreateInvoiceIntegrationResponse with success status\n *\n * @throws {HailerError} if request fails, user not authorized, or workspace already has subscription\n */\n async createInvoiceIntegration(request: AdminCreateInvoiceIntegrationRequest): Promise<AdminCreateInvoiceIntegrationResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.createInvoiceIntegration', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace subscription billing information\n *\n * @param request AdminUpdateWorkspaceSubscriptionRequest containing purchase ID and new billing details\n *\n * @returns boolean indicating whether the update was successful\n *\n * @throws {HailerError} if request fails, user not authorized, or purchase not found\n */\n async updateWorkspaceSubscription(request: AdminUpdateWorkspaceSubscriptionRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateSubscription', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates purchase price for active invoice products\n *\n * @param request AdminUpdatePurchasePriceRequest containing purchase ID, workspace ID, and new price\n *\n * @returns boolean indicating whether the update was successful\n *\n * @throws {HailerError} if request fails, user not authorized, purchase not found, or not an invoice product\n */\n async updatePurchasePrice(request: AdminUpdatePurchasePriceRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.purchase.updatePrice', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists users in a workspace with search, filtering, pagination, and sorting\n * If no workspaceId provided, lists all users across all workspaces\n *\n * @param request AdminWorkspaceUsersListRequest containing optional workspace ID, filter and options\n *\n * @returns List of workspace users with total count and role information\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async listWorkspaceUsers(request: AdminWorkspaceUsersListRequest): Promise<AdminWorkspaceUsersListResponse> {\n try {\n const res = await this.client.requestAsync('admin.workspace.listUsers', [request.workspaceId, request.filter, request.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates a user's information (currently supports email verification only)\n *\n * @param request AdminUpdateUserRequest containing user ID and updates\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, user not found, or user not authorized\n */\n async updateUser(request: AdminUpdateUserRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.user.update', [request.userId, request.updates]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace token balance\n *\n * @param request Object containing workspaceId, tokenAmount, and optional payout parameters\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async updateTokenBalance(request: {\n workspaceId: string;\n tokenAmount: number;\n payoutMonth?: number;\n payoutYear?: number;\n payoutType?: 'admin_bonus' | 'creator_payout';\n creatorPercent?: number;\n }): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateTokenBalance', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates workspace license overrides\n *\n * @param request AdminUpdateOverridesRequest containing workspaceId and overrides object\n *\n * @returns boolean indicating success\n *\n * @throws {HailerError} if request fails, workspace not found, or user not authorized\n */\n async updateWorkspaceOverrides(request: AdminUpdateOverridesRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateOverrides', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n async updateWorkspaceMarketplaceSettings(request: AdminUpdateMarketplaceSettingsRequest): Promise<boolean> {\n try {\n const res = await this.client.requestAsync('admin.workspace.updateMarketplaceSettings', [request]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists token transactions with filtering, pagination, and statistics\n *\n * @param request AdminTokenTransactionsListRequest containing optional filter and pagination options\n *\n * @returns AdminTokenTransactionsListResponse with transactions, total count, and statistics\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listTokenTransactions(request?: AdminTokenTransactionsListRequest): Promise<AdminTokenTransactionsListResponse> {\n try {\n const res = await this.client.requestAsync('admin.tokenTransaction.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Lists Hailer invoice purchases with filtering, pagination, and workspace grouping\n *\n * @param request AdminInvoiceListRequest containing optional filter and pagination options\n *\n * @returns AdminInvoiceListResponse with invoices, total count, and workspace groups\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async listInvoices(request?: AdminInvoiceListRequest): Promise<AdminInvoiceListResponse> {\n try {\n const res = await this.client.requestAsync('admin.invoice.list', [request?.filter, request?.options]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Updates the handled status for one or more Hailer invoice purchases\n *\n * @param request AdminInvoiceUpdateHandledRequest containing purchase ID(s) and handled status\n *\n * @returns AdminInvoiceUpdateHandledResponse with count of updated records\n *\n * @throws {HailerError} if request fails, purchase not found, or not a Hailer invoice purchase\n */\n async updateInvoiceHandled(request: AdminInvoiceUpdateHandledRequest): Promise<AdminInvoiceUpdateHandledResponse> {\n try {\n const res = await this.client.requestAsync('admin.invoice.updateHandled', [request.purchaseIds, request.handled]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n async listMonthlyRevenue(request: AdminRevenueListRequest): Promise<AdminRevenueListResponse> {\n try {\n const res = await this.client.requestAsync('admin.revenue.list', [\n request.month,\n request.year,\n request.filter,\n request.options\n ]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets dashboard statistics including counts for users, workspaces, activities, and messages\n * Includes today's count, total count, last week count, and week-over-week growth percentage\n *\n * @param entities Optional array of entity types to fetch. Defaults to all entities.\n * Valid values: 'users', 'workspaces', 'activities', 'messages', 'userMessages'\n *\n * @returns AdminDashboardStatisticsResponse with statistics for requested entity types\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async getDashboardStatistics(entities?: string[]): Promise<AdminDashboardStatisticsResponse> {\n try {\n const res = await this.client.requestAsync('admin.dashboard.statistics', [entities]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n\n /**\n * Gets dashboard trends showing daily creation counts over time\n *\n * @param days Number of days to fetch (30, 90, 180, or 365). Defaults to 30.\n * @param entities Optional array of entity types to fetch. Defaults to ['users', 'workspaces'].\n * Valid values: 'users', 'workspaces'\n *\n * @returns AdminDashboardTrendsResponse with daily counts for requested entity types\n *\n * @throws {HailerError} if request fails or user not authorized\n */\n async getDashboardTrends(days?: 30 | 90 | 180 | 365, entities?: string[]): Promise<AdminDashboardTrendsResponse> {\n try {\n const res = await this.client.requestAsync('admin.dashboard.trends', [days, entities]);\n return res;\n }\n catch (error: any) {\n throw new HailerError(error)\n }\n }\n}", "import { Client } from '@wishcore/wish-rpc';\nimport { HailerError } from '../types';\n\nexport interface MetricDefinition {\n id: string;\n name: string;\n description: string;\n category: string;\n supportsTimeRange: boolean;\n supportsBreakdown: boolean;\n}\n\nexport interface MetricData {\n metricType: string;\n timestamp: number;\n current: {\n value: number;\n labels?: any;\n };\n timeSeries?: Array<{\n timestamp: number;\n value: number;\n }>;\n breakdown?: {\n byWorkspace?: Record<string, number>;\n byUser?: Record<string, number>;\n };\n metadata: {\n scope?: any;\n permissions?: any;\n source: string;\n executionTime?: number;\n };\n}\nexport interface MetricOptions {\n workspaceId?: string;\n userId?: string;\n timeRange?: {\n start: number;\n end: number;\n };\n interval?: '1m' | '5m' | '15m' | '30m' | '1h' | '5h';\n\n // Query Builder options (optional)\n /** Aggregation function to apply */\n aggregation?: 'sum' | 'avg' | 'max' | 'min' | 'count' | 'rate' | 'increase';\n\n /** Group results by specified labels (max 3). Allowed: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */\n groupBy?: string[];\n\n /** Limit results to top N values (1-100) */\n topk?: number;\n\n /** Additional label filters. Allowed keys: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */\n labelFilters?: Record<string, string>;\n}\n\nexport interface MetricListOptions {\n category?: string;\n includeDetails?: boolean;\n}\n\nexport interface WorkspaceMetricsListOptions {\n /** Array of workspace IDs to look up */\n workspaceIds?: string[];\n /** Search by workspace name (minimum 3 characters) */\n name?: string;\n}\n\nexport type WorkspaceMetricsListResult = Array<{\n _id: string;\n name: string;\n}>;\n\nexport interface UserMetricsListOptions {\n /** Array of user IDs to look up */\n userIds: string[];\n}\n\nexport type UserMetricsListResult = Array<{\n _id: string;\n name?: string;\n email: string;\n}>;\n\nexport class MetricsApi {\n constructor(private client: Client) {}\n\n /**\n * Get list of available metrics for current user based on permissions\n * @param options Optional filtering options\n * @returns Array of metric IDs or detailed metric definitions\n */\n async list(options?: MetricListOptions): Promise<string[] | MetricDefinition[]> {\n try {\n return await this.client.requestAsync('metrics.list', options ? [options] : []);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * Get metrics data with optional Query Builder\n * @param metricTypes Single metric or array of metrics to fetch\n * @param options Optional filtering, time range, and Query Builder options\n * @returns Metric data with values and optional time series\n *\n * @example\n * // Simple query\n * await api.metrics.get('hailer.activity.create', { workspaceId: 'abc123' });\n *\n * @example\n * // Query Builder: Top 10 users by activity\n * await api.metrics.get('hailer.activity.create', {\n * workspaceId: 'abc123',\n * timeRange: { start: Date.now() - 86400000, end: Date.now() },\n * aggregation: 'sum',\n * groupBy: ['user'],\n * topk: 10\n * });\n */\n async get(metricTypes: string | string[], options?: MetricOptions): Promise<MetricData> {\n try {\n // Backend expects array, convert string to array if needed\n const metricsArray = Array.isArray(metricTypes) ? metricTypes : [metricTypes];\n return await this.client.requestAsync('metrics.get', [metricsArray, options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n\n /**\n * Admin endpoints for metrics management\n */\n admin = {\n /**\n * Get list of workspaces for admin metrics filtering\n * @param options Lookup by workspaceIds array or name search (min 3 chars)\n * @returns List of workspaces\n *\n * @example\n * // Look up by workspace IDs\n * await api.metrics.admin.workspacesList({ workspaceIds: ['id1', 'id2'] });\n *\n * @example\n * // Search by workspace name\n * await api.metrics.admin.workspacesList({ name: 'Sales' });\n */\n workspacesList: async (options: WorkspaceMetricsListOptions): Promise<WorkspaceMetricsListResult> => {\n try {\n return await this.client.requestAsync('metrics.workspaceSearch', [options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n },\n\n /**\n * Get list of users for admin metrics filtering\n * @param options Lookup by userIds array\n * @returns List of users with _id, name, email\n *\n * @example\n * // Look up by user IDs\n * await api.metrics.admin.usersList({ userIds: ['id1', 'id2'] });\n */\n usersList: async (options: UserMetricsListOptions): Promise<UserMetricsListResult> => {\n try {\n return await this.client.requestAsync('metrics.user.list', [options]);\n } catch (error: any) {\n throw new HailerError(error);\n }\n }\n };\n}", "import { Client } from \"@wishcore/wish-rpc\";\n\nexport interface HTTPFetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n}\n\nexport interface HTTPUploadEntry {\n /** Form field name */\n name: string;\n /** Value: plain string for fields, base64 string for files */\n value: string;\n /** When present, entry is a file with this filename (value is base64) */\n filename?: string;\n}\n\nexport interface HTTPFetchResponse {\n status: number;\n statusText: string;\n headers: Record<string, string>;\n body: string;\n}\n\n/**\n * Events emitted by the parent frame for a HTTP WebSocket connection.\n */\ninterface HTTPWsEvent {\n connectionId: string;\n event: \"open\" | \"message\" | \"close\" | \"error\";\n data?: string;\n code?: number;\n reason?: string;\n}\n\n/**\n * A WebSocket-like object that proxies through the parent Hailer frame.\n */\nexport class HTTPWebSocket {\n public onopen: ((event: any) => void) | null = null;\n public onmessage: ((event: { data: string }) => void) | null = null;\n public onclose: ((event: { code?: number; reason?: string }) => void) | null =\n null;\n public onerror: ((event: any) => void) | null = null;\n public readyState: number = WebSocket.CONNECTING;\n\n public connectionId: string | null = null;\n\n constructor(\n private client: Client,\n url: string,\n ) {\n // Open a streaming RPC request \u2014 callback fires for each WS event from parent\n this.client.request(\n \"http.ws.open\",\n [url],\n (error: any, data: HTTPWsEvent) => {\n if (error) {\n this.readyState = WebSocket.CLOSED;\n this.onerror?.({ error });\n return;\n }\n\n if (!data) return;\n\n // Store connectionId from first event\n if (data.connectionId && !this.connectionId) {\n this.connectionId = data.connectionId;\n }\n\n switch (data.event) {\n case \"open\":\n this.readyState = WebSocket.OPEN;\n this.onopen?.({});\n break;\n case \"message\":\n this.onmessage?.({ data: data.data ?? \"\" });\n break;\n case \"close\":\n this.readyState = WebSocket.CLOSED;\n this.onclose?.({ code: data.code, reason: data.reason });\n break;\n case \"error\":\n this.onerror?.({ error: data.data });\n break;\n }\n },\n );\n }\n\n send(data: string): void {\n if (this.readyState !== WebSocket.OPEN || !this.connectionId) {\n throw new Error(\"WebSocket is not open\");\n }\n this.client\n .requestAsync(\"http.ws.send\", [this.connectionId, data])\n .catch((error) => {\n this.onerror?.({ error });\n });\n }\n\n close(code?: number, reason?: string): void {\n if (this.connectionId) {\n this.client\n .requestAsync(\"http.ws.close\", [this.connectionId, code, reason])\n .catch((error) => {\n this.onerror?.({ error });\n });\n }\n this.readyState = WebSocket.CLOSING;\n }\n}\n\n/**\n * Proxy module for making authenticated HTTP and WebSocket requests\n * through the parent Hailer frame.\n */\nexport class HttpApi {\n constructor(private client: Client) {}\n\n /**\n * Make an HTTP request through the parent frame.\n * The parent's browser context sends the hlrkey cookie automatically.\n */\n async fetch(\n url: string,\n options?: HTTPFetchOptions,\n ): Promise<HTTPFetchResponse> {\n return await this.client\n .requestAsync(\"http.fetch\", [url, options])\n .catch((error) => {\n throw error;\n });\n }\n\n /**\n * Upload files through the parent frame as multipart/form-data.\n * Files are sent as base64 strings and reconstructed into FormData by the parent.\n * The parent's browser context sends the hlrkey cookie automatically.\n */\n async upload(\n url: string,\n entries: HTTPUploadEntry[],\n ): Promise<HTTPFetchResponse> {\n return await this.client\n .requestAsync(\"http.upload\", [url, entries])\n .catch((error) => {\n throw error;\n });\n }\n\n /**\n * Open a WebSocket connection through the parent frame.\n * Returns a HTTPWebSocket that mimics the native WebSocket API.\n */\n openWebSocket(url: string): HTTPWebSocket {\n return new HTTPWebSocket(this.client, url);\n }\n}\n"],
|
|
5
|
+
"mappings": "q7BAMA,IAAaA,EAAb,KAAmB,CAKf,YAAoBC,EAAuCC,EAAsB,CAA7D,KAAA,MAAAD,EAJZ,KAAA,SAAuB,CAAA,EACvB,KAAA,GAAK,EACL,KAAA,IAAM,MAGPC,GAAQA,EAAK,MACZ,KAAK,IAAMA,EAAK,IAExB,CAEA,SAAO,CACH,KAAK,SAAW,KAChB,KAAK,MAAQ,IACjB,CAEA,gBAAgBC,EAAG,CAEf,IAAMC,EAAM,CAAC,EAAED,EAAI,KAAOA,EAAI,KAAOA,EAAI,KAEnCE,EAAKF,EAAI,KAAOA,EAAI,KAAOA,EAAI,KAAOA,EAAI,IAE1CG,EAAU,KAAK,SAASD,CAAE,EAC5BE,EAEJ,GAAGD,GAAW,OAAOA,EAAQ,IAAO,WAAY,CAC5C,IAAIE,EACDL,EAAI,IAEHG,EAAQ,GAAG,KAAKA,EAAQ,QAAS,KAAM,KAAM,EAAI,EAE9CA,EAAQ,SACP,QAAQ,IAAI,qDAAqD,GAGjEE,EAAML,EAAI,IAAMA,EAAI,KAAO,KAC3BI,EAASD,EAAQ,GAAG,KAAKA,EAAQ,QAASE,EAAKL,EAAI,KAAMC,CAAG,GAKxE,OAAGA,GAEC,OAAO,KAAK,SAASC,CAAE,EAGpBE,CACX,CAEM,aAAaE,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MAAM,qDAAqD,EACnE,MACJ,CAEA,aAAa,KAAK,KAAK,EAEvB,KAAK,MAAQA,EAAI,KAAK,MACtB,KAAK,YAAcA,EAAI,KAAK,YAG5B,KAAK,QAAUsB,EAAM,OAGhB,KAAK,QAAQ,mBACd,KAAK,QAAQ,iBAAmBE,GAAiB,KAAK,OAAO,GAAKN,GAItE,KAAK,OAAO,QAAQ,cAAe,CAAC,EAAG,CAACE,EAAYG,EAAgBE,IAAiB,CACjF,GAAIL,EAAO,CACP,QAAQ,IAAI,qBAAsBA,EAAOG,CAAI,EAC7C,MACJ,CAEA,KAAK,QAAQ,WAAWA,CAAI,CAChC,CAAC,EAED,KAAK,OAAO,QAAQ,SAAU,CAAC,EAAG,CAACH,EAAYG,EAAWE,IAAiB,CACvE,GAAIL,EAAO,CACP,QAAQ,IAAI,gBAAiBA,EAAOG,CAAI,EACxC,MACJ,CACA,KAAK,QAAQ,SAASA,CAAI,CAC9B,CAAC,EAGD,KAAK,OAAO,QAAQ,SAAU,CAAC,EAAG,CAACH,EAAYG,EAAWE,IAAiB,CACvE,GAAIL,EAAO,CACP,QAAQ,IAAI,gBAAiBA,EAAOG,CAAI,EACxC,MACJ,CAEIA,GACA,KAAK,QAAQ,UAAUA,CAAI,CAEnC,CAAC,EAED,KAAK,QAAU,GAEf,KAAK,QAAQ,YAAY,EACzB,MACJ,CAGA,GAAI,CAAC,KAAK,MACN,OAGJ,KAAK,OAAO,gBAAgBvB,CAAG,CACnC,MAAgB,CACZ,QAAQ,IAAI,8BAA8B,CAC9C,CACJ,CAAC,CACL,CAEA,MAAgB,CACZ,MAAO,CACH,QAAS,KAAK,QACd,OAAQ,KAAK,OACb,QAAS,KAAK,QACd,YAAa,KAAK,WACtB,CACJ,CACJ",
|
|
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", "CustomError", "message", "code", "HailerError", "error", "UserApi", "client", "userId", "error", "HailerError", "Kanban", "client", "processId", "options", "error", "HailerError", "activityId", "priority", "Ball", "client", "activityId", "toUserId", "error", "HailerError", "discussionIds", "ActivityApi", "client", "Kanban", "Ball", "processId", "phaseId", "options", "error", "HailerError", "activityId", "workflowId", "activities", "requests", "WorkspaceApi", "client", "error", "HailerError", "template", "id", "workspaceId", "productId", "TeamApi", "client", "error", "HailerError", "FileApi", "client", "fileId", "error", "HailerError", "file", "filename", "options", "base64Data", "resolve", "reject", "reader", "Activity", "client", "activityId", "options", "processId", "activityIds", "Discussion", "client", "discussionId", "options", "Snackbar", "client", "text", "buttonLabel", "duration", "Files", "client", "file", "filename", "options", "resolve", "reject", "reader", "Workflow", "client", "workflowId", "fieldId", "Ui", "client", "Activity", "Discussion", "Snackbar", "Workflow", "workspaceId", "insightId", "Files", "DEFAULT_ALLOWED_URLS", "DEFAULT_BACKEND_URL", "publicBackendMap", "App", "options", "manifestFile", "location", "manifestUrl", "manifestContent", "appId", "Form", "options", "formsKey", "res", "HailerError", "formsData", "InsightPublicApi", "options", "insightKey", "res", "HailerError", "input", "data", "row", "object", "header", "headerIndex", "ProductPublicApi", "options", "filter", "res", "HailerError", "id", "HailerPublicApi", "options", "InsightPublicApi", "Form", "App", "ProductPublicApi", "WorkflowApi", "client", "error", "HailerError", "workflowId", "workflowSpec", "option", "AppApi", "client", "config", "option", "error", "HailerError", "productId", "workspaceId", "id", "InsightApi", "client", "insightId", "options", "error", "HailerError", "update", "PermissionApi", "client", "error", "HailerError", "ProductApi", "client", "filter", "options", "error", "HailerError", "id", "product", "isPublic", "Payment", "client", "request", "error", "HailerError", "productId", "workspaceId", "Admin", "client", "request", "error", "HailerError", "codeId", "updates", "workspaceId", "entities", "days", "MetricsApi", "client", "options", "error", "HailerError", "metricTypes", "metricsArray", "HTTPWebSocket", "client", "url", "error", "data", "code", "reason", "HttpApi", "options", "entries", "HailerApi", "options", "allowedUrls", "DEFAULT_ALLOWED_URLS", "msg", "UserApi", "AppApi", "ActivityApi", "InsightApi", "WorkspaceApi", "TeamApi", "FileApi", "WorkflowApi", "PermissionApi", "HailerPublicApi", "Ui", "ProductApi", "Payment", "Admin", "MetricsApi", "HttpApi", "registerMessage", "DEFAULT_BACKEND_URL", "config", "error", "url", "event", "data", "publicBackendMap", "end"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
import { BallHolderEntry } from '../../types';
|
|
3
|
+
export declare class Ball {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
/**
|
|
7
|
+
* Pass the ball (activity responsibility) to another user.
|
|
8
|
+
*
|
|
9
|
+
* @param activityId activity to update
|
|
10
|
+
* @param toUserId recipient user id; must be a participant of the activity's discussion
|
|
11
|
+
*
|
|
12
|
+
* @throws {HailerError} if the activity has no ball tracking, the caller is a guest, or the target is not a participant
|
|
13
|
+
*/
|
|
14
|
+
pass(activityId: string, toUserId: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Take the ball (activity responsibility) for the current user.
|
|
17
|
+
*
|
|
18
|
+
* @param activityId activity to take
|
|
19
|
+
*
|
|
20
|
+
* @throws {HailerError} if ball tracking is disabled, the caller is a guest, or the caller lacks phase access
|
|
21
|
+
*/
|
|
22
|
+
take(activityId: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* List ball holders for activity discussions.
|
|
25
|
+
*
|
|
26
|
+
* @param discussionIds `'*'` to load every ball holder the user can see, or an array of discussionIds to restrict the result.
|
|
27
|
+
* Unknown or non-participant discussionIds are silently dropped. An empty array returns `[]` without hitting the backend.
|
|
28
|
+
*
|
|
29
|
+
* @returns array of ball holder entries for activities where the caller can access both the discussion and the workflow
|
|
30
|
+
*
|
|
31
|
+
* @throws {HailerError} if the request is invalid
|
|
32
|
+
*/
|
|
33
|
+
list(discussionIds: string[] | '*'): Promise<BallHolderEntry[]>;
|
|
34
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Client } from '@wishcore/wish-rpc';
|
|
2
2
|
import { ActivityCreateOptions, ActivityListOptions, Activity, ActivityFieldUpdateValue, ActivityUpdateOptions, ActivityFieldValue, PrintRequest, PrintResponse } from '../types';
|
|
3
3
|
import { Kanban } from './activity/kanban';
|
|
4
|
+
import { Ball } from './activity/ball';
|
|
4
5
|
export declare class ActivityApi {
|
|
5
6
|
private client;
|
|
6
7
|
kanban: Kanban;
|
|
8
|
+
ball: Ball;
|
|
7
9
|
constructor(client: Client);
|
|
8
10
|
/**
|
|
9
11
|
* Lists all activities from the specified process and phase
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
/**
|
|
3
|
+
* Sidestack control module for managing the expanded/collapsed state of the Hailer sidebar
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Check if sidestack is expanded
|
|
7
|
+
* const isExpanded = await hailer.ui.sidestack.isExpanded();
|
|
8
|
+
*
|
|
9
|
+
* // Expand or collapse the sidestack
|
|
10
|
+
* await hailer.ui.sidestack.setExpanded(true);
|
|
11
|
+
*
|
|
12
|
+
* // Toggle the current state
|
|
13
|
+
* const newState = await hailer.ui.sidestack.toggle();
|
|
14
|
+
*/
|
|
15
|
+
export declare class Sidestack {
|
|
16
|
+
private client;
|
|
17
|
+
constructor(client: Client);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current expanded state of the sidestack
|
|
20
|
+
*
|
|
21
|
+
* @returns Promise resolving to boolean - true if sidestack is expanded, false if collapsed
|
|
22
|
+
*/
|
|
23
|
+
isExpanded(): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the expanded state of the sidestack
|
|
26
|
+
*
|
|
27
|
+
* @param expanded - true to expand the sidestack, false to collapse it
|
|
28
|
+
* @returns Promise resolving to boolean - the new expanded state after the operation
|
|
29
|
+
*/
|
|
30
|
+
setExpanded(
|
|
31
|
+
/** Whether to expand (true) or collapse (false) the sidestack */
|
|
32
|
+
expanded: boolean): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Toggles the expanded/collapsed state of the sidestack
|
|
35
|
+
*
|
|
36
|
+
* @returns Promise resolving to boolean - the new expanded state after toggling
|
|
37
|
+
*/
|
|
38
|
+
toggle(): Promise<boolean>;
|
|
39
|
+
}
|
package/lib/tools/publish.cjs
CHANGED
|
@@ -24,9 +24,7 @@ var prompt = (question, { hidden = true, ctrlcExits = true } = {}) => new Promis
|
|
|
24
24
|
const onData = (data) => {
|
|
25
25
|
switch (data) {
|
|
26
26
|
case "\n":
|
|
27
|
-
// \n
|
|
28
27
|
case "\r":
|
|
29
|
-
// \r
|
|
30
28
|
case "":
|
|
31
29
|
releaseStdin(onData);
|
|
32
30
|
resolve(input);
|
|
@@ -40,7 +38,6 @@ var prompt = (question, { hidden = true, ctrlcExits = true } = {}) => new Promis
|
|
|
40
38
|
}
|
|
41
39
|
break;
|
|
42
40
|
case "\b":
|
|
43
|
-
// Backspace
|
|
44
41
|
case "\x7F":
|
|
45
42
|
input = input.slice(0, -1);
|
|
46
43
|
if (!hidden) {
|
|
@@ -68,7 +65,8 @@ var import_path = require("path");
|
|
|
68
65
|
(0, import_dotenv.config)({ path: (0, import_path.join)((0, import_os.homedir)(), ".env") });
|
|
69
66
|
function getArgValue(flag) {
|
|
70
67
|
const index = process.argv.indexOf(flag);
|
|
71
|
-
if (index === -1 || index + 1 >= process.argv.length)
|
|
68
|
+
if (index === -1 || index + 1 >= process.argv.length)
|
|
69
|
+
return void 0;
|
|
72
70
|
return process.argv[index + 1];
|
|
73
71
|
}
|
|
74
72
|
function hasFlag(flag) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../tools/publish.ts", "../../tools/minimal-password-prompt.ts"],
|
|
4
4
|
"sourcesContent": ["import { Client } from '@hailer/cli';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { prompt } from './minimal-password-prompt';\nimport { inspect } from 'util';\nimport { createInterface } from 'readline';\nimport { config as loadEnv } from 'dotenv';\nimport { homedir } from 'os';\nimport { join } from 'path';\n\n// Load ~/.env as fallback (doesn't overwrite existing env vars)\nloadEnv({ path: join(homedir(), '.env') });\n\n/** Get the value following a named flag, e.g. getArgValue('--user-api-key') */\nfunction getArgValue(flag: string): string | undefined {\n const index = process.argv.indexOf(flag);\n if (index === -1 || index + 1 >= process.argv.length) return undefined;\n return process.argv[index + 1];\n}\n\nfunction hasFlag(flag: string): boolean {\n return process.argv.includes(flag);\n}\n\nconst userApiKey = getArgValue('--user-api-key') || process.env.USER_API_KEY || process.env.HAILER_USER_API_KEY;\n\nlet email = getArgValue('--email') || process.env.EMAIL;\n\nif (!userApiKey && !email && !process.env.LOCAL) {\n console.log('Please provide authentication: --email, --user-api-key, or EMAIL env var.');\n console.log('');\n console.log('Usage:');\n console.log(' npm run publish-production -- --email user@mail.com (will prompt for password)');\n console.log(' npm run publish-production -- --user-api-key <key>');\n console.log(' EMAIL=user@mail.com npm run publish-production (going to be deprecated, use --email instead)');\n console.log(' USER_API_KEY=<key> npm run publish-production (going to be deprecated, use --user-api-key instead)');\n console.log('');\n console.log('Create and publish new app:');\n console.log(' npm run publish-production -- --create --app-name \"My App\" --workspace <id> --user-api-key <key> --yes');\n console.log('');\n console.log('Options:');\n console.log(' --email <email> User email for authentication');\n console.log(' --user-api-key <key> API key for authentication');\n console.log(' --create Create a new app before publishing');\n console.log(' --app-name <name> App name (with --create)');\n console.log(' --workspace <id> Workspace ID (with --create)');\n console.log(' --market Also publish to Hailer marketplace');\n console.log(' --yes Skip confirmation prompt (going to be deprecated, use --force instead)');\n console.log(' --force Skip confirmation prompt');\n console.log(' --host <host> Specify the host URL');\n process.exit(10);\n}\n\n(async () => {\n\n let password: string | undefined;\n\n const market = hasFlag('--market') || process.env.MARKET === 'true';\n\n const appPackageFile = process.argv[2];\n\n /** Detect mode from any position in argv */\n const mode = ['--development', '--staging', '--production', '--local']\n .find(m => process.argv.includes(m));\n\n let host = getArgValue(\"--host\") || process.env.HOST || 'https://localhost:9443';\n\n switch (mode) {\n case '--development':\n host = getArgValue(\"--host\") || process.env.HOST || 'https://testapi.hailer.biz';\n break;\n case '--staging':\n host = getArgValue(\"--host\") || process.env.HOST || 'https://api.hailer.biz';\n break;\n case '--production':\n host = getArgValue(\"--host\") || process.env.HOST || 'https://api.hailer.com';\n break;\n }\n\n if (process.env.LOCAL || mode === '--local') {\n host = getArgValue(\"--host\") || process.env.HOST || 'https://api.hailer.local.gd';\n if (!userApiKey) {\n console.log('Overriding credentials with local settings!');\n email = 'el@hailero.es';\n password = 'el@hailero.es';\n }\n }\n\n const isLocal = !!(process.env.LOCAL || mode === '--local');\n\n if (isLocal) {\n process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';\n }\n\n // Authenticate\n let cli: Client;\n\n if (userApiKey) {\n cli = await Client.create({ host, userApiKey, rejectUnauthorized: !isLocal }).catch(\n (error) => {\n console.log('Hailer Cli Error (API key auth):', error);\n process.exit(8);\n }\n );\n } else {\n if (!password) {\n password = await prompt('enter password for ' + email + ': ');\n }\n\n cli = await Client.create({ host, username: email, password, rejectUnauthorized: !isLocal }).catch(\n (error) => {\n if (error.msg === 'Invalid Login Data') {\n console.log('Invalid username or password when logging into Hailer.');\n } else {\n console.log('Hailer Cli Error:', error);\n }\n\n process.exit(8);\n }\n );\n }\n\n // Validate .tgz file\n if (!appPackageFile?.endsWith('.tgz')) {\n console.log('Failed getting .tgz file, found:', appPackageFile);\n process.exit(7);\n }\n\n const content = readFileSync(appPackageFile);\n let appId: string;\n\n // --create: Create a new app, then publish it\n if (hasFlag('--create')) {\n let appName = getArgValue('--app-name');\n let workspaceId = getArgValue('--workspace');\n\n if (!appName) {\n appName = await prompt('App name: ', { hidden: false });\n }\n\n if (!workspaceId) {\n workspaceId = await prompt('Workspace ID: ', { hidden: false });\n }\n\n if (!appName) {\n console.log('Error: --create requires --app-name <name>');\n process.exit(11);\n }\n if (!workspaceId) {\n console.log('Error: --create requires --workspace <id>');\n process.exit(12);\n }\n\n console.log('Creating new app...');\n console.log(' Name:', appName);\n console.log(' Workspace:', workspaceId);\n console.log(' Environment:', host);\n console.log();\n\n const appDoc = await cli.request('v3.app.create', [{\n name: appName,\n cid: workspaceId,\n }]).catch((error: any) => {\n console.log('Failed to create app:', error);\n process.exit(13);\n });\n\n appId = appDoc._id;\n console.log('App created with id:', appId);\n console.log();\n\n } else {\n // Normal publish: read appId from manifest\n const manifest = JSON.parse(readFileSync('./dist/manifest.json').toString());\n\n // Market code\n if (market) {\n if (!manifest.version) {\n manifest.version = '';\n manifest.versionDescription = '';\n\n const updatedManifestContent = JSON.stringify(manifest, null, 2);\n writeFileSync('./public/manifest.json', updatedManifestContent, 'utf-8');\n\n console.log('');\n console.log('Please set version in format (x.y.z) & versionDescription in file public/manifest.json! You have added MARKET=true or --market in your publish string.');\n console.log('');\n process.exit(10);\n }\n }\n\n const info = await cli.request('v2.core.init', [['network', 'networks', 'apps']]);\n\n const getAppById = (manifestAppId: string): { _id: string, name: string, cid: string } | null => {\n for (const appMap of Object.values(info.apps)) {\n for (const [id, app] of Object.entries(appMap as any)) {\n if (id === manifestAppId) {\n return app as any;\n }\n }\n }\n return null;\n }\n\n const app = getAppById(manifest.appId);\n\n if (!app) {\n const authInfo = userApiKey ? 'the provided API key' : email;\n console.log('The app was not found using:', authInfo);\n process.exit(2);\n }\n\n const personalApp = !app.cid;\n\n console.log('Publishing App');\n console.log(' Id:', manifest.appId);\n console.log(' Name:', app.name);\n if (personalApp) {\n console.log(' Workspace: any (personal app)');\n } else {\n console.log(' Workspace:', info.networks[app.cid]?.name, '(' + app.cid + ')');\n }\n console.log(' Environment:', host);\n console.log();\n\n // Market code\n if (market) {\n console.log(' Note: Also publishing app to Hailer market');\n }\n\n /** Default to publish (yes) */\n const promptOverwriteQuestion = async () => {\n if (hasFlag('--yes') || hasFlag('--force')) {\n return true;\n }\n\n return new Promise<boolean>(resolve => {\n const rl = createInterface(process.stdin, process.stdout);\n\n rl.setPrompt('Overwrite the app? (Y/n): ');\n rl.prompt();\n rl.on('line', (line) => {\n if (line.trim().toLocaleLowerCase().startsWith('n')) {\n resolve(false);\n } else {\n resolve(true);\n }\n rl.close();\n });\n });\n }\n\n const shouldOverwrite = await promptOverwriteQuestion();\n\n if (!shouldOverwrite) {\n console.log('Aborted publishing app.');\n process.exit(0);\n }\n\n appId = manifest.appId;\n }\n\n // Upload\n const formData = new FormData();\n formData.append('file', new Blob([content]), appPackageFile);\n formData.append('appId', appId);\n // Market code\n formData.append('publishMarket', market.toString());\n\n const headers: Record<string, string> = {};\n \n if (cli.sessionKey) {\n headers.hlrkey = cli.sessionKey;\n } else if (cli.userApiKey) {\n headers.hlrkey = cli.userApiKey;\n }\n\n const resp = await fetch(host + '/app/publish', {\n method: 'POST',\n headers,\n body: formData,\n }).catch((error) => {\n console.log('Publish error uploading file:', error);\n process.exit(9);\n });\n\n if (!resp.ok) {\n console.log('Publish failed with status:', resp.status, resp.statusText);\n const body = await resp.text();\n console.log('Response:', body);\n process.exit(9);\n }\n\n const body = await resp.text();\n let response;\n let infoMarket = '';\n\n try {\n response = JSON.parse(body);\n } catch (error) {\n console.log('Failed to parse publish response:', error);\n console.log('Response body:', body);\n process.exit(6);\n }\n\n // Update manifest.json with appId (--create) and/or targetId (--market)\n const manifestPath = './public/manifest.json';\n if (existsSync(manifestPath)) {\n const publicManifest = JSON.parse(readFileSync(manifestPath).toString());\n let manifestUpdated = false;\n\n if (hasFlag('--create')) {\n publicManifest.appId = appId;\n manifestUpdated = true;\n console.log('Updated', manifestPath, 'with appId:', appId);\n }\n\n if (response.manifest && response.manifest.targetId) {\n publicManifest.targetId = response.manifest.targetId;\n manifestUpdated = true;\n infoMarket = 'Note! Use targetId in public/manifest.json file when creating the product in market!';\n }\n\n if (manifestUpdated) {\n writeFileSync(manifestPath, JSON.stringify(publicManifest, null, 2), 'utf-8');\n }\n }\n\n console.log('App info:', inspect(response, { depth: 10, colors: true }));\n console.log();\n if (infoMarket)\n console.log(infoMarket);\n console.log('Published successfully!');\n\n cli.disconnect();\n})();\n", "// Re-written to TypeScript to fix typing issue, see: https://www.npmjs.com/package/minimal-password-prompt/v/1.1.0\n\nconst stdin = process.stdin;\nconst stdout = process.stdout;\n\nconst captureStdin = (onData: (data: string) => void) => {\n stdin.setEncoding('utf-8');\n stdin.setRawMode(true);\n stdin.on('data', onData);\n stdin.resume();\n};\n\nconst releaseStdin = (onData: (data: string) => void) => {\n stdin.pause();\n stdin.removeListener('data', onData);\n stdin.setRawMode(false);\n stdout.write('\\n');\n};\n\nexport const prompt = (question: string, { hidden = true, ctrlcExits = true } = {}): Promise<string> => (\n new Promise((resolve, reject) => {\n let input = '';\n const onData = (data: string) => {\n switch (data) {\n case '\\u000A': // \\n\n case '\\u000D': // \\r\n case '\\u0004': // Ctrl+D\n releaseStdin(onData);\n resolve(input);\n break;\n case '\\u0003': // Ctrl+C\n releaseStdin(onData);\n if (ctrlcExits) { // exit or raise error\n process.exit();\n } else {\n reject(new Error('Ctrl+C'));\n }\n break;\n case '\\u0008': // Backspace\n case '\\u007F': // Delete\n input = input.slice(0, -1);\n if (!hidden) {\n stdout.write('\\b \\b');\n }\n break;\n default: // any other\n input += data;\n if (!hidden) {\n stdout.write(data);\n }\n };\n };\n captureStdin(onData);\n stdout.write(question);\n })\n);\n"],
|
|
5
|
-
"mappings": ";;;AAAA,iBAAuB;AACvB,gBAAwD;;;ACCxD,IAAM,QAAQ,QAAQ;AACtB,IAAM,SAAS,QAAQ;AAEvB,IAAM,eAAe,CAAC,WAAmC;AACrD,QAAM,YAAY,OAAO;AACzB,QAAM,WAAW,IAAI;AACrB,QAAM,GAAG,QAAQ,MAAM;AACvB,QAAM,OAAO;AACj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vE,UAAQ,IAAI;AACZ,MAAI;AACA,YAAQ,IAAI,UAAU;AAC1B,UAAQ,IAAI,yBAAyB;AAErC,MAAI,WAAW;AACnB,GAAG;",
|
|
6
6
|
"names": ["loadEnv", "app", "body"]
|
|
7
7
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1137,4 +1137,14 @@ export interface AdminReferralEventListResponse {
|
|
|
1137
1137
|
totalTokensAwarded: number;
|
|
1138
1138
|
};
|
|
1139
1139
|
}
|
|
1140
|
+
export interface BallHolder {
|
|
1141
|
+
userId: string;
|
|
1142
|
+
assignedAt: string;
|
|
1143
|
+
}
|
|
1144
|
+
export interface BallHolderEntry {
|
|
1145
|
+
activityId: string;
|
|
1146
|
+
discussionId: string;
|
|
1147
|
+
activityName: string;
|
|
1148
|
+
ballHolder: BallHolder;
|
|
1149
|
+
}
|
|
1140
1150
|
export {};
|