@alva-ai/toolkit 0.34.0-beta.0 → 0.34.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.
@@ -367,5 +367,5 @@ mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
367
367
  companyNews {
368
368
  createFeed(input: $input) { id producer { id } }
369
369
  }
370
- }`,or={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 ar(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(ar,"validateCompanyNewsCreateParams");var ae=class{constructor(e){this.client=e}client;static{s(this,"CompanyNewsResource")}async create(e){this.client._requireAuth(),ar(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:rr,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",or[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)||!Hn(r.feed_id)||!("cronjob_id"in r)||!Hn(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 Hn(t){return typeof t=="string"&&t.trim()===t&&/^[1-9]\d{0,18}$/.test(t)&&BigInt(t)<=9223372036854775807n}s(Hn,"validID");var ur="https://api-llm.prd.alva.ai",cr="https://data-tools.prd.space.id";function Ut(t){return typeof t=="object"&&t!==null}s(Ut,"isRecord");function pt(t,e){if(!Ut(t))return;let n=t[e];return typeof n=="string"&&n?n:void 0}s(pt,"stringField");function lr(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=pt(t,"code");i&&(e.code=i)}else if(Ut(t)){let i=pt(t,"code"),o=pt(t,"name"),r=pt(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(lr,"describeCause");function dr(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}=lr(Ut(t)?t.cause:void 0);return o&&(n.cause=o),{message:i?`${e}; cause: ${i}`:e,details:n}}s(dr,"describeFetchFailure");var mt=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;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;_markets;_schedules;_steward;_tradingPairs;_theses;_companyNews;constructor(e){this.baseUrl=e.baseUrl??ur,this.arraysBaseUrl=e.arraysBaseUrl??cr,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 Ne(this)}get run(){return this._run??=new De(this)}get deploy(){return this._deploy??=new Ue(this)}get serviceAccount(){return this._serviceAccount??=new Le(this)}get release(){return this._release??=new Fe(this)}get feed(){return this._feed??=new Ge(this)}get automation(){return this._automation??=new ee(this)}get playbooks(){return this._playbooks??=new je(this)}get secrets(){return this._secrets??=new Be(this)}get sdk(){return this._sdk??=new Qe(this)}get dataSkills(){return this._dataSkills??=new Ve(this)}get playbookSkills(){return this._playbookSkills??=new He(this)}get comments(){return this._comments??=new Ye(this)}get remix(){return this._remix??=new We(this)}get screenshot(){return this._screenshot??=new Ke(this)}get user(){return this._user??=new Xe(this)}get trading(){return this._trading??=new ze(this)}get portfolio(){return this._portfolio??=new Je(this)}get arraysJwt(){return this._arraysJwt??=new Ze(this)}get notifications(){return this._notifications??=new et(this)}get notificationPreferences(){return this._notificationPreferences??=new tt(this)}get subscriptions(){return this._subscriptions??=new nt(this)}get alerts(){return this._alerts??=new te(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new it(this)}get feedback(){return this._feedback??=new st(this)}get functions(){return this._functions??=new rt(this)}get credits(){return this._credits??=new ot(this)}get markets(){return this._markets??=new ne(this)}get tradingPairs(){return this._tradingPairs??=new re(this)}get schedules(){return this._schedules??=new ie(this)}get steward(){return this._steward??=new se(this)}get theses(){return this._theses??=new oe(this)}get companyNews(){return this._companyNews??=new ae(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 X(this)}get forYou(){return this._forYou??=new Z(this)}async _request(e,n,i){let r=`${i?.baseUrl??this.baseUrl}${n}`;if(i?.query){let N=new URLSearchParams;for(let[M,ht]of Object.entries(i.query))ht!=null&&N.set(M,String(ht));let H=N.toString();H&&(r+=`?${H}`)}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,y=i?.signal??this.signal;if(y?.aborted)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});let g=d!==void 0?new AbortController:void 0,v=!1,F,ve;g&&d!==void 0&&(y&&(ve=s(()=>g.abort(y.reason),"abortListener"),y.addEventListener("abort",ve,{once:!0})),F=setTimeout(()=>{v=!0,g.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${n}`))},d));let Lt={method:e,headers:a,body:u,signal:g?.signal??y};d!==void 0&&(Lt.timeout=d);try{c=await fetch(r,Lt)}catch(N){if(y?.aborted&&!v)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});if(v)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${n}`,0,{method:e,path:n,timeout_ms:d});let H=dr(N);throw new l("NETWORK_ERROR",H.message,0,{method:e,path:n,...H.details})}finally{ve&&y&&y.removeEventListener("abort",ve),F!==void 0&&clearTimeout(F)}if(!c.ok){let N="";try{N=await Promise.resolve(c.text())}catch{N=""}if((c.headers.get("content-type")??"").includes("application/json")&&N)try{let M=JSON.parse(N);if(M.error)throw new l(M.error.code??"UNKNOWN",M.error.message??`HTTP ${c.status}`,c.status)}catch(M){if(M instanceof l)throw M}throw new l("UNKNOWN",`HTTP ${c.status}: ${N.slice(0,200)}`,c.status)}if(c.status===204)return;let Ft=(c.headers.get("content-type")??"").toLowerCase();return Ft.includes("application/json")||Ft.includes("+json")?c.json():c.arrayBuffer()}};var pr="0.34.0-beta.0";Pt();return Jn(mr);})();
370
+ }`,or={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 ar(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(ar,"validateCompanyNewsCreateParams");var ae=class{constructor(e){this.client=e}client;static{s(this,"CompanyNewsResource")}async create(e){this.client._requireAuth(),ar(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:rr,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",or[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)||!Hn(r.feed_id)||!("cronjob_id"in r)||!Hn(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 Hn(t){return typeof t=="string"&&t.trim()===t&&/^[1-9]\d{0,18}$/.test(t)&&BigInt(t)<=9223372036854775807n}s(Hn,"validID");var ur="https://api-llm.prd.alva.ai",cr="https://data-tools.prd.space.id";function Ut(t){return typeof t=="object"&&t!==null}s(Ut,"isRecord");function pt(t,e){if(!Ut(t))return;let n=t[e];return typeof n=="string"&&n?n:void 0}s(pt,"stringField");function lr(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=pt(t,"code");i&&(e.code=i)}else if(Ut(t)){let i=pt(t,"code"),o=pt(t,"name"),r=pt(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(lr,"describeCause");function dr(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}=lr(Ut(t)?t.cause:void 0);return o&&(n.cause=o),{message:i?`${e}; cause: ${i}`:e,details:n}}s(dr,"describeFetchFailure");var mt=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;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;_markets;_schedules;_steward;_tradingPairs;_theses;_companyNews;constructor(e){this.baseUrl=e.baseUrl??ur,this.arraysBaseUrl=e.arraysBaseUrl??cr,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 Ne(this)}get run(){return this._run??=new De(this)}get deploy(){return this._deploy??=new Ue(this)}get serviceAccount(){return this._serviceAccount??=new Le(this)}get release(){return this._release??=new Fe(this)}get feed(){return this._feed??=new Ge(this)}get automation(){return this._automation??=new ee(this)}get playbooks(){return this._playbooks??=new je(this)}get secrets(){return this._secrets??=new Be(this)}get sdk(){return this._sdk??=new Qe(this)}get dataSkills(){return this._dataSkills??=new Ve(this)}get playbookSkills(){return this._playbookSkills??=new He(this)}get comments(){return this._comments??=new Ye(this)}get remix(){return this._remix??=new We(this)}get screenshot(){return this._screenshot??=new Ke(this)}get user(){return this._user??=new Xe(this)}get trading(){return this._trading??=new ze(this)}get portfolio(){return this._portfolio??=new Je(this)}get arraysJwt(){return this._arraysJwt??=new Ze(this)}get notifications(){return this._notifications??=new et(this)}get notificationPreferences(){return this._notificationPreferences??=new tt(this)}get subscriptions(){return this._subscriptions??=new nt(this)}get alerts(){return this._alerts??=new te(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new it(this)}get feedback(){return this._feedback??=new st(this)}get functions(){return this._functions??=new rt(this)}get credits(){return this._credits??=new ot(this)}get markets(){return this._markets??=new ne(this)}get tradingPairs(){return this._tradingPairs??=new re(this)}get schedules(){return this._schedules??=new ie(this)}get steward(){return this._steward??=new se(this)}get theses(){return this._theses??=new oe(this)}get companyNews(){return this._companyNews??=new ae(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 X(this)}get forYou(){return this._forYou??=new Z(this)}async _request(e,n,i){let r=`${i?.baseUrl??this.baseUrl}${n}`;if(i?.query){let N=new URLSearchParams;for(let[M,ht]of Object.entries(i.query))ht!=null&&N.set(M,String(ht));let H=N.toString();H&&(r+=`?${H}`)}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,y=i?.signal??this.signal;if(y?.aborted)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});let g=d!==void 0?new AbortController:void 0,v=!1,F,ve;g&&d!==void 0&&(y&&(ve=s(()=>g.abort(y.reason),"abortListener"),y.addEventListener("abort",ve,{once:!0})),F=setTimeout(()=>{v=!0,g.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${n}`))},d));let Lt={method:e,headers:a,body:u,signal:g?.signal??y};d!==void 0&&(Lt.timeout=d);try{c=await fetch(r,Lt)}catch(N){if(y?.aborted&&!v)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${n}`,0,{method:e,path:n});if(v)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${n}`,0,{method:e,path:n,timeout_ms:d});let H=dr(N);throw new l("NETWORK_ERROR",H.message,0,{method:e,path:n,...H.details})}finally{ve&&y&&y.removeEventListener("abort",ve),F!==void 0&&clearTimeout(F)}if(!c.ok){let N="";try{N=await Promise.resolve(c.text())}catch{N=""}if((c.headers.get("content-type")??"").includes("application/json")&&N)try{let M=JSON.parse(N);if(M.error)throw new l(M.error.code??"UNKNOWN",M.error.message??`HTTP ${c.status}`,c.status)}catch(M){if(M instanceof l)throw M}throw new l("UNKNOWN",`HTTP ${c.status}: ${N.slice(0,200)}`,c.status)}if(c.status===204)return;let Ft=(c.headers.get("content-type")??"").toLowerCase();return Ft.includes("application/json")||Ft.includes("+json")?c.json():c.arrayBuffer()}};var pr="0.34.0";Pt();return Jn(mr);})();
371
371
  //# sourceMappingURL=browser.global.js.map