@alva-ai/toolkit 0.37.0-beta.0 → 0.37.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.
@@ -401,5 +401,5 @@ mutation ToolkitStewardPublishDailyBrief($input: PublishStewardDailyBriefInput!)
401
401
  companyNews {
402
402
  createFeed(input: $input) { id producer { id } }
403
403
  }
404
- }`,so={INVALID_ARGUMENT:400,UNAUTHENTICATED:401,PERMISSION_DENIED:403,NOT_FOUND:404,ALREADY_EXISTS:409,ABORTED:409,FAILED_PRECONDITION:412,RESOURCE_EXHAUSTED:429,INTERNAL:500,UNKNOWN:500,DATA_LOSS:500,UNAVAILABLE:503,DEADLINE_EXCEEDED:504};function oo(t){if(typeof t?.name!="string"||t.name.trim()!==t.name||!/^[a-zA-Z0-9][a-zA-Z0-9-]{0,63}$/.test(t.name)||t.name==="news-lane")throw new l("INVALID_ARGUMENT","name must be 1-64 alphanumeric/hyphen characters and distinct from news-lane",400);if(!Array.isArray(t.tickers)||t.tickers.length<1||t.tickers.length>1e3||t.tickers.some(e=>typeof e!="string"||e.trim()!==e||!/^[A-Z0-9][A-Z0-9.-]{0,19}$/.test(e))||new Set(t.tickers).size!==t.tickers.length)throw new l("INVALID_ARGUMENT","tickers must contain 1-1000 unique uppercase symbols",400);for(let[e,n]of[["initial_lookback_hours",168],["page_size",100]]){let i=t[e];if(i!==void 0&&(!Number.isInteger(i)||i<0||i>n))throw new l("INVALID_ARGUMENT",`${e} must be an integer from 0 to ${n} (0 selects the default)`,400)}}s(oo,"validateCompanyNewsCreateParams");var he=class{constructor(e){this.client=e}client;static{s(this,"CompanyNewsResource")}async create(e){this.client._requireAuth(),oo(e);let n={name:e.name,tickers:e.tickers,...e.initial_lookback_hours===void 0?{}:{initialLookbackHours:e.initial_lookback_hours},...e.page_size===void 0?{}:{pageSize:e.page_size}},i=await this.client._request("POST","/query",{body:{query:ro,variables:{input:n}}});if(Array.isArray(i?.errors)&&i.errors.length>0){let a=i.errors.map(c=>c?.extensions?.code),u=typeof a[0]=="string"&&a.every(c=>c===a[0])?a[0]:"GRAPHQL_ERROR";throw new l(u,i.errors.map(c=>c?.message).filter(Boolean).join("; ")||"Company News creation failed",so[u]??502,{errors:i.errors})}let o=i?.data?.companyNews?.createFeed,r={feed_id:o?.id,cronjob_id:o?.producer?.id};if(typeof r!="object"||r===null||!("feed_id"in r)||!Pi(r.feed_id)||!("cronjob_id"in r)||!Pi(r.cronjob_id))throw new l("INVALID_RESPONSE","company news response must contain decimal int64 feed_id and cronjob_id strings",502);return{feed_id:r.feed_id,cronjob_id:r.cronjob_id}}};function Pi(t){return typeof t=="string"&&t.trim()===t&&/^[1-9]\d{0,18}$/.test(t)&&BigInt(t)<=9223372036854775807n}s(Pi,"validID");var ao="https://api-llm.prd.alva.ai",uo="https://data-tools.prd.space.id";function Ht(t){return typeof t=="object"&&t!==null}s(Ht,"isRecord");function bt(t,e){if(!Ht(t))return;let n=t[e];return typeof n=="string"&&n?n:void 0}s(bt,"stringField");function co(t){if(t==null)return{};let e={};if(t instanceof Error){t.name&&(e.name=t.name),t.message&&(e.message=t.message);let i=bt(t,"code");i&&(e.code=i)}else if(Ht(t)){let i=bt(t,"code"),o=bt(t,"name"),r=bt(t,"message");i&&(e.code=i),o&&(e.name=o),r&&(e.message=r)}else e.message=String(t);let n=[e.code,e.name,e.message].filter(i=>!!i);return{message:n.length>0?n.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(co,"describeCause");function lo(t){let e=t instanceof Error&&t.message?t.message:"Network request failed",n={};t instanceof Error?(n.name=t.name,n.message=t.message):n.message=String(t);let{message:i,details:o}=co(Ht(t)?t.cause:void 0);return o&&(n.cause=o),{message:i?`${e}; cause: ${i}`:e,details:n}}s(lo,"describeFetchFailure");var wt=class{static{s(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;signal;originSessionId;originSessionKind;originInboxPath;_fs;_run;_deploy;_serviceAccount;_release;_feed;_x;_forYou;_automation;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_follows;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;_markets;_schedules;_steward;_tradingPairs;_theses;_companyNews;constructor(e){this.baseUrl=e.baseUrl??ao,this.arraysBaseUrl=e.arraysBaseUrl??uo,this.viewer_token=e.viewer_token,this.pbsvToken=e.pbsvToken,this.apiKey=e.apiKey,this.gaClientId=e.gaClientId,this.gaSessionId=e.gaSessionId,this.utmParams=e.utmParams,this.signal=e.signal,this.originSessionId=e.originSessionId,this.originSessionKind=e.originSessionKind,this.originInboxPath=e.originInboxPath}get fs(){return this._fs??=new Oe(this)}get run(){return this._run??=new Ge(this)}get deploy(){return this._deploy??=new Me(this)}get serviceAccount(){return this._serviceAccount??=new $e(this)}get release(){return this._release??=new je(this)}get feed(){return this._feed??=new Qe(this)}get automation(){return this._automation??=new re(this)}get playbooks(){return this._playbooks??=new He(this)}get secrets(){return this._secrets??=new Ye(this)}get sdk(){return this._sdk??=new Ke(this)}get dataSkills(){return this._dataSkills??=new Xe(this)}get playbookSkills(){return this._playbookSkills??=new ze(this)}get comments(){return this._comments??=new Je(this)}get remix(){return this._remix??=new Ze(this)}get screenshot(){return this._screenshot??=new et(this)}get user(){return this._user??=new tt(this)}get trading(){return this._trading??=new nt(this)}get portfolio(){return this._portfolio??=new it(this)}get arraysJwt(){return this._arraysJwt??=new rt(this)}get notifications(){return this._notifications??=new st(this)}get notificationPreferences(){return this._notificationPreferences??=new ot(this)}get subscriptions(){return this._subscriptions??=new at(this)}get follows(){return this._follows??=new se(this)}get alerts(){return this._alerts??=new oe(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new ct(this)}get feedback(){return this._feedback??=new lt(this)}get functions(){return this._functions??=new dt(this)}get credits(){return this._credits??=new pt(this)}get markets(){return this._markets??=new ae(this)}get tradingPairs(){return this._tradingPairs??=new le(this)}get schedules(){return this._schedules??=new ue(this)}get steward(){return this._steward??=new ce(this)}get theses(){return this._theses??=new pe(this)}get companyNews(){return this._companyNews??=new he(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new l("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}get x(){return this._x??=new ee(this)}get forYou(){return this._forYou??=new ie(this)}async _request(e,n,i){let r=`${i?.baseUrl??this.baseUrl}${n}`;if(i?.query){let O=new URLSearchParams;for(let[j,Pt]of Object.entries(i.query))Pt!=null&&O.set(j,String(Pt));let X=O.toString();X&&(r+=`?${X}`)}let a={};i?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams),this.originSessionId&&!i?.noAuth&&(a["X-Alva-Origin-Session-Id"]=this.originSessionId);let u;i?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",u=i.rawBody):i?.jsonBody!==void 0?(a["Content-Type"]="application/json",u=i.jsonBody):i?.body!==void 0&&(a["Content-Type"]="application/json",u=JSON.stringify(i.body));let c,d=i?.timeoutMs,p=i?.signal??this.signal;if(p?.aborted)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});let P=d!==void 0?new AbortController:void 0,_=!1,g,Ne;P&&d!==void 0&&(p&&(Ne=s(()=>P.abort(p.reason),"abortListener"),p.addEventListener("abort",Ne,{once:!0})),g=setTimeout(()=>{_=!0,P.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${n}`))},d));let Yt={method:e,headers:a,body:u,signal:P?.signal??p};d!==void 0&&(Yt.timeout=d);try{c=await fetch(r,Yt)}catch(O){if(p?.aborted&&!_)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});if(_)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${n}`,0,{method:e,path:n,timeout_ms:d});let X=lo(O);throw new l("NETWORK_ERROR",X.message,0,{method:e,path:n,...X.details})}finally{Ne&&p&&p.removeEventListener("abort",Ne),g!==void 0&&clearTimeout(g)}if(!c.ok){let O="";try{O=await Promise.resolve(c.text())}catch{O=""}if((c.headers.get("content-type")??"").includes("application/json")&&O)try{let j=JSON.parse(O);if(j.error)throw new l(j.error.code??"UNKNOWN",j.error.message??`HTTP ${c.status}`,c.status,j.details)}catch(j){if(j instanceof l)throw j}throw new l("UNKNOWN",`HTTP ${c.status}: ${O.slice(0,200)}`,c.status)}if(c.status===204)return;let Kt=(c.headers.get("content-type")??"").toLowerCase();return Kt.includes("application/json")||Kt.includes("+json")?c.json():c.arrayBuffer()}};var po="0.37.0-beta.0";Et();return Ei(ho);})();
404
+ }`,so={INVALID_ARGUMENT:400,UNAUTHENTICATED:401,PERMISSION_DENIED:403,NOT_FOUND:404,ALREADY_EXISTS:409,ABORTED:409,FAILED_PRECONDITION:412,RESOURCE_EXHAUSTED:429,INTERNAL:500,UNKNOWN:500,DATA_LOSS:500,UNAVAILABLE:503,DEADLINE_EXCEEDED:504};function oo(t){if(typeof t?.name!="string"||t.name.trim()!==t.name||!/^[a-zA-Z0-9][a-zA-Z0-9-]{0,63}$/.test(t.name)||t.name==="news-lane")throw new l("INVALID_ARGUMENT","name must be 1-64 alphanumeric/hyphen characters and distinct from news-lane",400);if(!Array.isArray(t.tickers)||t.tickers.length<1||t.tickers.length>1e3||t.tickers.some(e=>typeof e!="string"||e.trim()!==e||!/^[A-Z0-9][A-Z0-9.-]{0,19}$/.test(e))||new Set(t.tickers).size!==t.tickers.length)throw new l("INVALID_ARGUMENT","tickers must contain 1-1000 unique uppercase symbols",400);for(let[e,n]of[["initial_lookback_hours",168],["page_size",100]]){let i=t[e];if(i!==void 0&&(!Number.isInteger(i)||i<0||i>n))throw new l("INVALID_ARGUMENT",`${e} must be an integer from 0 to ${n} (0 selects the default)`,400)}}s(oo,"validateCompanyNewsCreateParams");var he=class{constructor(e){this.client=e}client;static{s(this,"CompanyNewsResource")}async create(e){this.client._requireAuth(),oo(e);let n={name:e.name,tickers:e.tickers,...e.initial_lookback_hours===void 0?{}:{initialLookbackHours:e.initial_lookback_hours},...e.page_size===void 0?{}:{pageSize:e.page_size}},i=await this.client._request("POST","/query",{body:{query:ro,variables:{input:n}}});if(Array.isArray(i?.errors)&&i.errors.length>0){let a=i.errors.map(c=>c?.extensions?.code),u=typeof a[0]=="string"&&a.every(c=>c===a[0])?a[0]:"GRAPHQL_ERROR";throw new l(u,i.errors.map(c=>c?.message).filter(Boolean).join("; ")||"Company News creation failed",so[u]??502,{errors:i.errors})}let o=i?.data?.companyNews?.createFeed,r={feed_id:o?.id,cronjob_id:o?.producer?.id};if(typeof r!="object"||r===null||!("feed_id"in r)||!Pi(r.feed_id)||!("cronjob_id"in r)||!Pi(r.cronjob_id))throw new l("INVALID_RESPONSE","company news response must contain decimal int64 feed_id and cronjob_id strings",502);return{feed_id:r.feed_id,cronjob_id:r.cronjob_id}}};function Pi(t){return typeof t=="string"&&t.trim()===t&&/^[1-9]\d{0,18}$/.test(t)&&BigInt(t)<=9223372036854775807n}s(Pi,"validID");var ao="https://api-llm.prd.alva.ai",uo="https://data-tools.prd.space.id";function Ht(t){return typeof t=="object"&&t!==null}s(Ht,"isRecord");function bt(t,e){if(!Ht(t))return;let n=t[e];return typeof n=="string"&&n?n:void 0}s(bt,"stringField");function co(t){if(t==null)return{};let e={};if(t instanceof Error){t.name&&(e.name=t.name),t.message&&(e.message=t.message);let i=bt(t,"code");i&&(e.code=i)}else if(Ht(t)){let i=bt(t,"code"),o=bt(t,"name"),r=bt(t,"message");i&&(e.code=i),o&&(e.name=o),r&&(e.message=r)}else e.message=String(t);let n=[e.code,e.name,e.message].filter(i=>!!i);return{message:n.length>0?n.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(co,"describeCause");function lo(t){let e=t instanceof Error&&t.message?t.message:"Network request failed",n={};t instanceof Error?(n.name=t.name,n.message=t.message):n.message=String(t);let{message:i,details:o}=co(Ht(t)?t.cause:void 0);return o&&(n.cause=o),{message:i?`${e}; cause: ${i}`:e,details:n}}s(lo,"describeFetchFailure");var wt=class{static{s(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;signal;originSessionId;originSessionKind;originInboxPath;_fs;_run;_deploy;_serviceAccount;_release;_feed;_x;_forYou;_automation;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_follows;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;_markets;_schedules;_steward;_tradingPairs;_theses;_companyNews;constructor(e){this.baseUrl=e.baseUrl??ao,this.arraysBaseUrl=e.arraysBaseUrl??uo,this.viewer_token=e.viewer_token,this.pbsvToken=e.pbsvToken,this.apiKey=e.apiKey,this.gaClientId=e.gaClientId,this.gaSessionId=e.gaSessionId,this.utmParams=e.utmParams,this.signal=e.signal,this.originSessionId=e.originSessionId,this.originSessionKind=e.originSessionKind,this.originInboxPath=e.originInboxPath}get fs(){return this._fs??=new Oe(this)}get run(){return this._run??=new Ge(this)}get deploy(){return this._deploy??=new Me(this)}get serviceAccount(){return this._serviceAccount??=new $e(this)}get release(){return this._release??=new je(this)}get feed(){return this._feed??=new Qe(this)}get automation(){return this._automation??=new re(this)}get playbooks(){return this._playbooks??=new He(this)}get secrets(){return this._secrets??=new Ye(this)}get sdk(){return this._sdk??=new Ke(this)}get dataSkills(){return this._dataSkills??=new Xe(this)}get playbookSkills(){return this._playbookSkills??=new ze(this)}get comments(){return this._comments??=new Je(this)}get remix(){return this._remix??=new Ze(this)}get screenshot(){return this._screenshot??=new et(this)}get user(){return this._user??=new tt(this)}get trading(){return this._trading??=new nt(this)}get portfolio(){return this._portfolio??=new it(this)}get arraysJwt(){return this._arraysJwt??=new rt(this)}get notifications(){return this._notifications??=new st(this)}get notificationPreferences(){return this._notificationPreferences??=new ot(this)}get subscriptions(){return this._subscriptions??=new at(this)}get follows(){return this._follows??=new se(this)}get alerts(){return this._alerts??=new oe(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new ct(this)}get feedback(){return this._feedback??=new lt(this)}get functions(){return this._functions??=new dt(this)}get credits(){return this._credits??=new pt(this)}get markets(){return this._markets??=new ae(this)}get tradingPairs(){return this._tradingPairs??=new le(this)}get schedules(){return this._schedules??=new ue(this)}get steward(){return this._steward??=new ce(this)}get theses(){return this._theses??=new pe(this)}get companyNews(){return this._companyNews??=new he(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new l("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}get x(){return this._x??=new ee(this)}get forYou(){return this._forYou??=new ie(this)}async _request(e,n,i){let r=`${i?.baseUrl??this.baseUrl}${n}`;if(i?.query){let O=new URLSearchParams;for(let[j,Pt]of Object.entries(i.query))Pt!=null&&O.set(j,String(Pt));let X=O.toString();X&&(r+=`?${X}`)}let a={};i?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams),this.originSessionId&&!i?.noAuth&&(a["X-Alva-Origin-Session-Id"]=this.originSessionId);let u;i?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",u=i.rawBody):i?.jsonBody!==void 0?(a["Content-Type"]="application/json",u=i.jsonBody):i?.body!==void 0&&(a["Content-Type"]="application/json",u=JSON.stringify(i.body));let c,d=i?.timeoutMs,p=i?.signal??this.signal;if(p?.aborted)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});let P=d!==void 0?new AbortController:void 0,_=!1,g,Ne;P&&d!==void 0&&(p&&(Ne=s(()=>P.abort(p.reason),"abortListener"),p.addEventListener("abort",Ne,{once:!0})),g=setTimeout(()=>{_=!0,P.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${n}`))},d));let Yt={method:e,headers:a,body:u,signal:P?.signal??p};d!==void 0&&(Yt.timeout=d);try{c=await fetch(r,Yt)}catch(O){if(p?.aborted&&!_)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});if(_)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${n}`,0,{method:e,path:n,timeout_ms:d});let X=lo(O);throw new l("NETWORK_ERROR",X.message,0,{method:e,path:n,...X.details})}finally{Ne&&p&&p.removeEventListener("abort",Ne),g!==void 0&&clearTimeout(g)}if(!c.ok){let O="";try{O=await Promise.resolve(c.text())}catch{O=""}if((c.headers.get("content-type")??"").includes("application/json")&&O)try{let j=JSON.parse(O);if(j.error)throw new l(j.error.code??"UNKNOWN",j.error.message??`HTTP ${c.status}`,c.status,j.details)}catch(j){if(j instanceof l)throw j}throw new l("UNKNOWN",`HTTP ${c.status}: ${O.slice(0,200)}`,c.status)}if(c.status===204)return;let Kt=(c.headers.get("content-type")??"").toLowerCase();return Kt.includes("application/json")||Kt.includes("+json")?c.json():c.arrayBuffer()}};var po="0.37.0";Et();return Ei(ho);})();
405
405
  //# sourceMappingURL=browser.global.js.map