@telemetryos/root-sdk 1.8.3 → 1.9.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/CHANGELOG.md +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +166 -99
- package/dist/weather.d.ts +324 -111
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./types-mYnxD5LM.cjs"),D="1.8.3",U={version:D};class P{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class M{constructor(e){this._client=e}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async getByName(e){return(await this._client.request("applications.getByName",{name:e})).application}async setDependencies(e){return await this._client.request("applications.setDependencies",{applicationSpecifiers:e})}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class C{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}}class T{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class A{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}}class B{constructor(e){this._client=e}async fetch(e,t){var s;let o;typeof e=="string"?o=e:e instanceof URL?o=e.toString():(o=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let n={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((u,p)=>{n[p]=u}):Array.isArray(t.headers)?t.headers.forEach(([u,p])=>{n[u]=p}):n=t.headers);const i=await this._client.request("proxy.fetch",{url:o,method:(t==null?void 0:t.method)||"GET",headers:n,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!i.success)throw new TypeError(i.errorMessage,{cause:i.errorCause?Error(i.errorCause):void 0});const l=new Headers(i.headers),c={status:i.status,statusText:i.statusText,headers:l};let d=null;if(i.body!==null&&i.body!==void 0)if(i.bodyType==="binary"){const u=atob(i.body),p=new Uint8Array(u.length);for(let f=0;f<u.length;f++)p[f]=u.charCodeAt(f);d=p}else i.bodyType==="text"?d=i.body:i.bodyType==="json"&&(d=JSON.stringify(i.body));return new Response(d,c)}}class F{constructor(e){this._client=e}get application(){return new w("application","",this._client)}get instance(){return new w("instance",this._client.applicationInstance,this._client)}get device(){return new w("device",this._client.applicationInstance,this._client)}shared(e){return new w("shared",e,this._client)}}class w{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class k{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current user");return e.user}}class ${constructor(e){this._client=e}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success||!t.conditions)throw new Error(t.error||"Failed to fetch weather conditions");return t.conditions}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success||!t.forecast)throw new Error(t.error||"Failed to fetch daily forecast");return t.forecast}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success||!t.forecast)throw new Error(t.error||"Failed to fetch hourly forecast");return t.forecast}}class R{constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,o;const n=await this._client.request("currency.getRates",e);if(!n.success||!n.rates)throw((t=n.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=n.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((o=n.error)===null||o===void 0?void 0:o.message)||"Failed to fetch currency rates");return n.rates}}function I(a){return{...a,type:"client"}}const L=N.objectType({type:N.literalType("bridge"),name:N.stringType(),data:N.anyType()});class V{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),o=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},n=this._store._client._applicationSpecifier;o[n]={applicationSpecifier:n,entries:e.entries},s.set("navigation",o)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},o=this._store._client._applicationSpecifier;return s[o]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}const m=1e3*30,H=typeof window>"u"&&typeof self<"u",b=H?self:window;function y(a){H?self.postMessage(a):b.parent.postMessage(a,"*")}class x{constructor(e){this._applicationName=e,this._applicationInstance="",this._applicationSpecifier="",this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map}get accounts(){return new P(this)}get users(){return new k(this)}get store(){return new F(this)}get applications(){return new M(this)}get media(){return new A(this)}get proxy(){return new B(this)}get devices(){return new C(this)}get rootSettingsNavigation(){return new V(this.store)}get weather(){return new $(this)}get currency(){return new R(this)}get environment(){return new T(this)}get applicationName(){return this._applicationName}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}bind(){var e,t,s;const o=new URL(b.location.href),n=o.searchParams;if(this._applicationInstance=(e=n.get("applicationInstance"))!==null&&e!==void 0?e:"",!this._applicationInstance)throw new Error("Missing applicationInstance query parameter");if(this._applicationSpecifier=(t=n.get("applicationSpecifier"))!==null&&t!==void 0?t:"",!this._applicationSpecifier){const i=o.hostname.split(".");this._applicationSpecifier=(s=i[0])!==null&&s!==void 0?s:""}if(!this._applicationSpecifier||this._applicationSpecifier.length!==40)throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=i=>{if(i.source===b||!i.data||typeof i.data!="object"||!("type"in i.data)||i.data.type!=="client"&&i.data.type!=="bridge")return;let l;if(i.data.type==="client"){const c=this._messageInterceptors.get(i.data.name);if(!c){y(i.data);return}l={...c(i.data.data),type:"bridge"}}if(!l){const c=L.safeParse(i.data);if(!c.success)return;l=c.data;const d=this._onHandlers.get(l.name),u=this._onceHandlers.get(l.name);if(d)for(const p of d)p(l.data);if(u){for(const p of u)p(l.data);this._onceHandlers.delete(l.name)}}if(!H)for(let c=0;c<window.frames.length;c+=1)window.frames[c].postMessage(l,"*")},b.addEventListener("message",this._windowMessageHandler)}unbind(){this._windowMessageHandler&&b.removeEventListener("message",this._windowMessageHandler)}send(e,t){const s=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t});y(s)}request(e,t){const s=q(),o=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t,responseName:s});y(o);let n=!1,i;const l=new Promise((d,u)=>{const p=new Error(`${e} message request with response name of ${s} timed out after ${m}`);setTimeout(()=>{n=!0,this.off(s,i),u(p)},m)}),c=new Promise(d=>{i=u=>{n||d(u)},this.once(s,d)});return Promise.race([l,c])}async subscribe(e,t,s){let o,n;typeof t=="function"?n=t:(o=t,n=s);const i=q(),l=q();let c=this._subscriptionNamesBySubjectName.get(e);c||(c=[],this._subscriptionNamesBySubjectName.set(e,c)),c.push(i),this._subscriptionNamesByHandler.set(n,i),this.on(i,n);const d=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:o,responseName:l,subscriptionName:i});y(d);let u=!1,p;const f=new Promise((S,g)=>{const _=new Error(`${e} subscribe request with subscription name of ${i} and response name of ${l} timed out after ${m}`);setTimeout(()=>{u=!0,this.off(l,p),g(_)},m)}),E=new Promise(S=>{p=g=>{u||S(g)},this.on(l,S)});return Promise.race([f,E])}async unsubscribe(e,t,s){let o,n;typeof t=="function"?n=t:(o=t,n=s);const i=q();let l=[];if(n){const c=this._subscriptionNamesByHandler.get(n);if(!c)return{success:!1};l=[c],this._subscriptionNamesByHandler.delete(n)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const c of l){this.off(c,n);const d=I({telemetrySdkVersion:v,applicationInstance:this._applicationInstance,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,name:e,data:o,responseName:i,unsubscribeName:c});y(d);let u=!1,p;const f=new Promise((g,_)=>{const j=new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${m}`);setTimeout(()=>{u=!0,this.off(i,p),_(j)},m)}),E=new Promise(g=>{p=_=>{u||g(_)},this.once(i,g)});if(!(await Promise.race([f,E])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const o=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];o.length===0&&this._onHandlers.set(e,o),o.push(t)}once(e,t){var s;const o=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];o.length===0&&this._onceHandlers.set(e,o),o.push(t)}off(e,t){const s=this._onHandlers.get(e),o=this._onceHandlers.get(e);if(!(!s&&!o)){if(s){for(let n=0;n<s.length;n+=1)t&&s[n]!==t||(s.splice(n,1),n-=1);s.length===0&&this._onHandlers.delete(e)}if(o){for(let n=0;n<o.length;n+=1)t&&o[n]!==t||(o.splice(n,1),n-=1);o.length===0&&this._onceHandlers.delete(e)}}}}function q(){return Math.random().toString(36).slice(2,9)}const v=U.version;let r=null;function W(){return r}function O(a){r=new x(a),r.bind()}function G(){r==null||r.unbind(),r=null}function J(...a){return h(r),r.on(...a)}function K(...a){return h(r),r.once(...a)}function z(...a){return h(r),r.off(...a)}function Q(...a){return h(r),r.send(...a)}function X(...a){return h(r),r.request(...a)}function Y(...a){return h(r),r.subscribe(...a)}function Z(...a){return h(r),r.unsubscribe(...a)}function ee(){return h(r),r.store}function te(){return h(r),r.applications}function se(){return h(r),r.media}function ne(){return h(r),r.accounts}function ie(){return h(r),r.users}function re(){return h(r),r.devices}function oe(){return h(r),r.proxy}function ae(){return h(r),r.rootSettingsNavigation}function ce(){return h(r),r.weather}function le(){return h(r),r.currency}function ue(){return h(r),r.environment}function h(a){if(!a)throw new Error("SDK is not configured")}exports.Accounts=P;exports.Applications=M;exports.Client=x;exports.Currency=R;exports.Devices=C;exports.Environment=T;exports.Media=A;exports.Proxy=B;exports.Store=F;exports.StoreSlice=w;exports.Users=k;exports.Weather=$;exports.accounts=ne;exports.applications=te;exports.configure=O;exports.currency=le;exports.destroy=G;exports.devices=re;exports.environment=ue;exports.globalClient=W;exports.media=se;exports.off=z;exports.on=J;exports.once=K;exports.proxy=oe;exports.request=X;exports.rootSettingsNavigation=ae;exports.send=Q;exports.store=ee;exports.subscribe=Y;exports.telemetrySdkVersion=v;exports.unsubscribe=Z;exports.users=ie;exports.weather=ce;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./types-mYnxD5LM.cjs"),D="1.9.0",U={version:D};class C{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class P{constructor(e){this._client=e}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async getByName(e){return(await this._client.request("applications.getByName",{name:e})).application}async setDependencies(e){return await this._client.request("applications.setDependencies",{applicationSpecifiers:e})}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class M{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}}class T{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class A{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}}class B{constructor(e){this._client=e}async fetch(e,t){var s;let o;typeof e=="string"?o=e:e instanceof URL?o=e.toString():(o=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let n={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((u,h)=>{n[h]=u}):Array.isArray(t.headers)?t.headers.forEach(([u,h])=>{n[u]=h}):n=t.headers);const i=await this._client.request("proxy.fetch",{url:o,method:(t==null?void 0:t.method)||"GET",headers:n,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!i.success)throw new TypeError(i.errorMessage,{cause:i.errorCause?Error(i.errorCause):void 0});const l=new Headers(i.headers),c={status:i.status,statusText:i.statusText,headers:l};let d=null;if(i.body!==null&&i.body!==void 0)if(i.bodyType==="binary"){const u=atob(i.body),h=new Uint8Array(u.length);for(let f=0;f<u.length;f++)h[f]=u.charCodeAt(f);d=h}else i.bodyType==="text"?d=i.body:i.bodyType==="json"&&(d=JSON.stringify(i.body));return new Response(d,c)}}class F{constructor(e){this._client=e}get application(){return new w("application","",this._client)}get instance(){return new w("instance",this._client.applicationInstance,this._client)}get device(){return new w("device",this._client.applicationInstance,this._client)}shared(e){return new w("shared",e,this._client)}}class w{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class k{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current user");return e.user}}class ${constructor(e){this._client=e}async getCities(e){const t=await this._client.request("weather.getCities",e);if(!t.success)throw new Error(t.error||"Failed to fetch cities");return t.data||[]}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather conditions");return t}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch daily forecast");return t}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch hourly forecast");return t}async getAlerts(e){const t=await this._client.request("weather.getAlerts",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather alerts");return t}}class R{constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,o;const n=await this._client.request("currency.getRates",e);if(!n.success||!n.rates)throw((t=n.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=n.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((o=n.error)===null||o===void 0?void 0:o.message)||"Failed to fetch currency rates");return n.rates}}function I(a){return{...a,type:"client"}}const L=N.objectType({type:N.literalType("bridge"),name:N.stringType(),data:N.anyType()});class V{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),o=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},n=this._store._client._applicationSpecifier;o[n]={applicationSpecifier:n,entries:e.entries},s.set("navigation",o)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},o=this._store._client._applicationSpecifier;return s[o]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}const _=1e3*30,H=typeof window>"u"&&typeof self<"u",b=H?self:window;function y(a){H?self.postMessage(a):b.parent.postMessage(a,"*")}class x{constructor(e){this._applicationName=e,this._applicationInstance="",this._applicationSpecifier="",this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map}get accounts(){return new C(this)}get users(){return new k(this)}get store(){return new F(this)}get applications(){return new P(this)}get media(){return new A(this)}get proxy(){return new B(this)}get devices(){return new M(this)}get rootSettingsNavigation(){return new V(this.store)}get weather(){return new $(this)}get currency(){return new R(this)}get environment(){return new T(this)}get applicationName(){return this._applicationName}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}bind(){var e,t,s;const o=new URL(b.location.href),n=o.searchParams;if(this._applicationInstance=(e=n.get("applicationInstance"))!==null&&e!==void 0?e:"",!this._applicationInstance)throw new Error("Missing applicationInstance query parameter");if(this._applicationSpecifier=(t=n.get("applicationSpecifier"))!==null&&t!==void 0?t:"",!this._applicationSpecifier){const i=o.hostname.split(".");this._applicationSpecifier=(s=i[0])!==null&&s!==void 0?s:""}if(!this._applicationSpecifier||this._applicationSpecifier.length!==40)throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=i=>{if(i.source===b||!i.data||typeof i.data!="object"||!("type"in i.data)||i.data.type!=="client"&&i.data.type!=="bridge")return;let l;if(i.data.type==="client"){const c=this._messageInterceptors.get(i.data.name);if(!c){y(i.data);return}l={...c(i.data.data),type:"bridge"}}if(!l){const c=L.safeParse(i.data);if(!c.success)return;l=c.data;const d=this._onHandlers.get(l.name),u=this._onceHandlers.get(l.name);if(d)for(const h of d)h(l.data);if(u){for(const h of u)h(l.data);this._onceHandlers.delete(l.name)}}if(!H)for(let c=0;c<window.frames.length;c+=1)window.frames[c].postMessage(l,"*")},b.addEventListener("message",this._windowMessageHandler)}unbind(){this._windowMessageHandler&&b.removeEventListener("message",this._windowMessageHandler)}send(e,t){const s=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t});y(s)}request(e,t){const s=q(),o=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t,responseName:s});y(o);let n=!1,i;const l=new Promise((d,u)=>{const h=new Error(`${e} message request with response name of ${s} timed out after ${_}`);setTimeout(()=>{n=!0,this.off(s,i),u(h)},_)}),c=new Promise(d=>{i=u=>{n||d(u)},this.once(s,d)});return Promise.race([l,c])}async subscribe(e,t,s){let o,n;typeof t=="function"?n=t:(o=t,n=s);const i=q(),l=q();let c=this._subscriptionNamesBySubjectName.get(e);c||(c=[],this._subscriptionNamesBySubjectName.set(e,c)),c.push(i),this._subscriptionNamesByHandler.set(n,i),this.on(i,n);const d=I({telemetrySdkVersion:v,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:o,responseName:l,subscriptionName:i});y(d);let u=!1,h;const f=new Promise((S,g)=>{const m=new Error(`${e} subscribe request with subscription name of ${i} and response name of ${l} timed out after ${_}`);setTimeout(()=>{u=!0,this.off(l,h),g(m)},_)}),E=new Promise(S=>{h=g=>{u||S(g)},this.on(l,S)});return Promise.race([f,E])}async unsubscribe(e,t,s){let o,n;typeof t=="function"?n=t:(o=t,n=s);const i=q();let l=[];if(n){const c=this._subscriptionNamesByHandler.get(n);if(!c)return{success:!1};l=[c],this._subscriptionNamesByHandler.delete(n)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const c of l){this.off(c,n);const d=I({telemetrySdkVersion:v,applicationInstance:this._applicationInstance,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,name:e,data:o,responseName:i,unsubscribeName:c});y(d);let u=!1,h;const f=new Promise((g,m)=>{const j=new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${_}`);setTimeout(()=>{u=!0,this.off(i,h),m(j)},_)}),E=new Promise(g=>{h=m=>{u||g(m)},this.once(i,g)});if(!(await Promise.race([f,E])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const o=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];o.length===0&&this._onHandlers.set(e,o),o.push(t)}once(e,t){var s;const o=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];o.length===0&&this._onceHandlers.set(e,o),o.push(t)}off(e,t){const s=this._onHandlers.get(e),o=this._onceHandlers.get(e);if(!(!s&&!o)){if(s){for(let n=0;n<s.length;n+=1)t&&s[n]!==t||(s.splice(n,1),n-=1);s.length===0&&this._onHandlers.delete(e)}if(o){for(let n=0;n<o.length;n+=1)t&&o[n]!==t||(o.splice(n,1),n-=1);o.length===0&&this._onceHandlers.delete(e)}}}}function q(){return Math.random().toString(36).slice(2,9)}const v=U.version;let r=null;function W(){return r}function O(a){r=new x(a),r.bind()}function G(){r==null||r.unbind(),r=null}function J(...a){return p(r),r.on(...a)}function K(...a){return p(r),r.once(...a)}function z(...a){return p(r),r.off(...a)}function Q(...a){return p(r),r.send(...a)}function X(...a){return p(r),r.request(...a)}function Y(...a){return p(r),r.subscribe(...a)}function Z(...a){return p(r),r.unsubscribe(...a)}function ee(){return p(r),r.store}function te(){return p(r),r.applications}function se(){return p(r),r.media}function ne(){return p(r),r.accounts}function ie(){return p(r),r.users}function re(){return p(r),r.devices}function oe(){return p(r),r.proxy}function ae(){return p(r),r.rootSettingsNavigation}function ce(){return p(r),r.weather}function le(){return p(r),r.currency}function ue(){return p(r),r.environment}function p(a){if(!a)throw new Error("SDK is not configured")}exports.Accounts=C;exports.Applications=P;exports.Client=x;exports.Currency=R;exports.Devices=M;exports.Environment=T;exports.Media=A;exports.Proxy=B;exports.Store=F;exports.StoreSlice=w;exports.Users=k;exports.Weather=$;exports.accounts=ne;exports.applications=te;exports.configure=O;exports.currency=le;exports.destroy=G;exports.devices=re;exports.environment=ue;exports.globalClient=W;exports.media=se;exports.off=z;exports.on=J;exports.once=K;exports.proxy=oe;exports.request=X;exports.rootSettingsNavigation=ae;exports.send=Q;exports.store=ee;exports.subscribe=Y;exports.telemetrySdkVersion=v;exports.unsubscribe=Z;exports.users=ie;exports.weather=ce;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export { Proxy } from './proxy.js';
|
|
|
7
7
|
export { Store, StoreSlice } from './store.js';
|
|
8
8
|
export { Users } from './users.js';
|
|
9
9
|
export { Weather } from './weather.js';
|
|
10
|
-
export type {
|
|
10
|
+
export type { CitiesSearchParams, DailyForecast, DailyForecastData, DailyForecastParams, HourlyForecast, HourlyForecastData, HourlyForecastParams, WeatherAlert, WeatherAlerts, WeatherAlertSeverity, WeatherAlertsParams, WeatherCity, WeatherConditions, WeatherConditionsParams, WeatherPartOfDay, } from './weather.js';
|
|
11
11
|
export { Currency } from './currency.js';
|
|
12
|
-
export type { CurrencySymbols, CurrencyRates, CurrencyRatesParams
|
|
12
|
+
export type { CurrencySymbols, CurrencyRates, CurrencyRatesParams } from './currency.js';
|
|
13
13
|
import { Client } from './client.js';
|
|
14
14
|
export { Client, type SubscriptionResult, type MessageHandler } from './client.js';
|
|
15
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as P, a as
|
|
2
|
-
const
|
|
3
|
-
version:
|
|
1
|
+
import { o as P, a as C, s as M, l as T } from "./types-CCzf8sMT.js";
|
|
2
|
+
const A = "1.9.0", B = {
|
|
3
|
+
version: A
|
|
4
4
|
};
|
|
5
5
|
class F {
|
|
6
6
|
constructor(e) {
|
|
@@ -220,10 +220,10 @@ class j {
|
|
|
220
220
|
integrity: e.integrity
|
|
221
221
|
}));
|
|
222
222
|
let n = {};
|
|
223
|
-
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((u,
|
|
224
|
-
n[
|
|
225
|
-
}) : Array.isArray(t.headers) ? t.headers.forEach(([u,
|
|
226
|
-
n[u] =
|
|
223
|
+
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((u, h) => {
|
|
224
|
+
n[h] = u;
|
|
225
|
+
}) : Array.isArray(t.headers) ? t.headers.forEach(([u, h]) => {
|
|
226
|
+
n[u] = h;
|
|
227
227
|
}) : n = t.headers);
|
|
228
228
|
const i = await this._client.request("proxy.fetch", {
|
|
229
229
|
url: o,
|
|
@@ -243,10 +243,10 @@ class j {
|
|
|
243
243
|
let d = null;
|
|
244
244
|
if (i.body !== null && i.body !== void 0)
|
|
245
245
|
if (i.bodyType === "binary") {
|
|
246
|
-
const u = atob(i.body),
|
|
246
|
+
const u = atob(i.body), h = new Uint8Array(u.length);
|
|
247
247
|
for (let f = 0; f < u.length; f++)
|
|
248
|
-
|
|
249
|
-
d =
|
|
248
|
+
h[f] = u.charCodeAt(f);
|
|
249
|
+
d = h;
|
|
250
250
|
} else i.bodyType === "text" ? d = i.body : i.bodyType === "json" && (d = JSON.stringify(i.body));
|
|
251
251
|
return new Response(d, c);
|
|
252
252
|
}
|
|
@@ -435,75 +435,142 @@ class U {
|
|
|
435
435
|
this._client = e;
|
|
436
436
|
}
|
|
437
437
|
/**
|
|
438
|
-
*
|
|
438
|
+
* Searches for cities by name or country
|
|
439
439
|
*
|
|
440
|
-
* @param params -
|
|
441
|
-
* @returns A promise that resolves to
|
|
442
|
-
* @throws {Error} If the request fails
|
|
440
|
+
* @param params - Search parameters including optional country code and search query
|
|
441
|
+
* @returns A promise that resolves to an array of matching cities
|
|
442
|
+
* @throws {Error} If the request fails
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```typescript
|
|
446
|
+
* // Search for cities named "New York"
|
|
447
|
+
* const cities = await weather.getCities({ search: 'New York' })
|
|
448
|
+
*
|
|
449
|
+
* // Search for cities in the United States
|
|
450
|
+
* const cities = await weather.getCities({ countryCode: 'US' })
|
|
451
|
+
*
|
|
452
|
+
* // Get a cityId for use in other methods
|
|
453
|
+
* const cities = await weather.getCities({ search: 'London' })
|
|
454
|
+
* const cityId = cities[0].cityId
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
async getCities(e) {
|
|
458
|
+
const t = await this._client.request("weather.getCities", e);
|
|
459
|
+
if (!t.success)
|
|
460
|
+
throw new Error(t.error || "Failed to fetch cities");
|
|
461
|
+
return t.data || [];
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Retrieves current weather conditions for a specified city
|
|
465
|
+
*
|
|
466
|
+
* @param params - Weather request parameters including cityId and optional language
|
|
467
|
+
* @returns A promise that resolves to the current weather conditions with dual units (C/F, kph/mph, etc.)
|
|
468
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
443
469
|
*
|
|
444
470
|
* @example
|
|
445
471
|
* ```typescript
|
|
446
|
-
* // Get
|
|
447
|
-
* const
|
|
472
|
+
* // Get current conditions for a city
|
|
473
|
+
* const conditions = await weather.getConditions({ cityId: 12345 })
|
|
448
474
|
*
|
|
449
|
-
* //
|
|
450
|
-
* const
|
|
475
|
+
* // With localized language
|
|
476
|
+
* const conditions = await weather.getConditions({
|
|
477
|
+
* cityId: 12345,
|
|
478
|
+
* language: 'es'
|
|
479
|
+
* })
|
|
451
480
|
*
|
|
452
|
-
* //
|
|
453
|
-
*
|
|
481
|
+
* // Access both units
|
|
482
|
+
* console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`)
|
|
483
|
+
* console.log(`${conditions.windSpeedKph} kph / ${conditions.windSpeedMph} mph`)
|
|
454
484
|
* ```
|
|
455
485
|
*/
|
|
456
486
|
async getConditions(e) {
|
|
457
487
|
const t = await this._client.request("weather.getConditions", e);
|
|
458
|
-
if (!t.success
|
|
488
|
+
if (!t.success)
|
|
459
489
|
throw new Error(t.error || "Failed to fetch weather conditions");
|
|
460
|
-
return t
|
|
490
|
+
return t;
|
|
461
491
|
}
|
|
462
492
|
/**
|
|
463
|
-
* Retrieves daily weather forecast for a specified
|
|
493
|
+
* Retrieves daily weather forecast for a specified city
|
|
464
494
|
*
|
|
465
|
-
* @param params - Forecast request parameters including
|
|
466
|
-
* @returns A promise that resolves to
|
|
467
|
-
* @throws {Error} If the request fails or
|
|
495
|
+
* @param params - Forecast request parameters including cityId, optional language and days
|
|
496
|
+
* @returns A promise that resolves to daily forecast data with location information
|
|
497
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
468
498
|
*
|
|
469
499
|
* @example
|
|
470
500
|
* ```typescript
|
|
471
501
|
* // Get 5-day forecast
|
|
472
|
-
* const forecast = await weather.getDailyForecast({
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
502
|
+
* const forecast = await weather.getDailyForecast({ cityId: 12345 })
|
|
503
|
+
*
|
|
504
|
+
* // Get 10-day forecast
|
|
505
|
+
* const forecast = await weather.getDailyForecast({ cityId: 12345, days: 10 })
|
|
506
|
+
*
|
|
507
|
+
* // Access forecast data
|
|
508
|
+
* forecast.data.forEach(day => {
|
|
509
|
+
* console.log(`${day.forecastDate}: ${day.weatherDescription}`)
|
|
510
|
+
* console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`)
|
|
476
511
|
* })
|
|
477
512
|
* ```
|
|
478
513
|
*/
|
|
479
514
|
async getDailyForecast(e) {
|
|
480
515
|
const t = await this._client.request("weather.getDailyForecast", e);
|
|
481
|
-
if (!t.success
|
|
516
|
+
if (!t.success)
|
|
482
517
|
throw new Error(t.error || "Failed to fetch daily forecast");
|
|
483
|
-
return t
|
|
518
|
+
return t;
|
|
484
519
|
}
|
|
485
520
|
/**
|
|
486
|
-
* Retrieves hourly weather forecast for a specified
|
|
521
|
+
* Retrieves hourly weather forecast for a specified city
|
|
487
522
|
*
|
|
488
|
-
* @param params - Forecast request parameters including
|
|
489
|
-
* @returns A promise that resolves to
|
|
490
|
-
* @throws {Error} If the request fails or
|
|
523
|
+
* @param params - Forecast request parameters including cityId, optional language and hours
|
|
524
|
+
* @returns A promise that resolves to hourly forecast data with location information
|
|
525
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
491
526
|
*
|
|
492
527
|
* @example
|
|
493
528
|
* ```typescript
|
|
494
529
|
* // Get 24-hour forecast
|
|
495
|
-
* const forecast = await weather.getHourlyForecast({
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
530
|
+
* const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 24 })
|
|
531
|
+
*
|
|
532
|
+
* // Get 48-hour forecast
|
|
533
|
+
* const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 48 })
|
|
534
|
+
*
|
|
535
|
+
* // Access forecast data
|
|
536
|
+
* forecast.data.forEach(hour => {
|
|
537
|
+
* console.log(`${hour.forecastTimeLocal}: ${hour.weatherDescription}`)
|
|
538
|
+
* console.log(`Temp: ${hour.temperatureC}°C`)
|
|
499
539
|
* })
|
|
500
540
|
* ```
|
|
501
541
|
*/
|
|
502
542
|
async getHourlyForecast(e) {
|
|
503
543
|
const t = await this._client.request("weather.getHourlyForecast", e);
|
|
504
|
-
if (!t.success
|
|
544
|
+
if (!t.success)
|
|
505
545
|
throw new Error(t.error || "Failed to fetch hourly forecast");
|
|
506
|
-
return t
|
|
546
|
+
return t;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Retrieves weather alerts and warnings for a specified city
|
|
550
|
+
*
|
|
551
|
+
* @param params - Alert request parameters including cityId and optional language
|
|
552
|
+
* @returns A promise that resolves to weather alerts with location information
|
|
553
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* ```typescript
|
|
557
|
+
* // Get weather alerts for a city
|
|
558
|
+
* const alerts = await weather.getAlerts({ cityId: 12345 })
|
|
559
|
+
*
|
|
560
|
+
* // Check if there are any active alerts
|
|
561
|
+
* if (alerts.alerts.length > 0) {
|
|
562
|
+
* alerts.alerts.forEach(alert => {
|
|
563
|
+
* console.log(`${alert.severity}: ${alert.title}`)
|
|
564
|
+
* console.log(alert.description)
|
|
565
|
+
* })
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
async getAlerts(e) {
|
|
570
|
+
const t = await this._client.request("weather.getAlerts", e);
|
|
571
|
+
if (!t.success)
|
|
572
|
+
throw new Error(t.error || "Failed to fetch weather alerts");
|
|
573
|
+
return t;
|
|
507
574
|
}
|
|
508
575
|
}
|
|
509
576
|
class V {
|
|
@@ -557,9 +624,9 @@ function S(a) {
|
|
|
557
624
|
return { ...a, type: "client" };
|
|
558
625
|
}
|
|
559
626
|
const W = P({
|
|
560
|
-
type:
|
|
561
|
-
name:
|
|
562
|
-
data:
|
|
627
|
+
type: T("bridge"),
|
|
628
|
+
name: M(),
|
|
629
|
+
data: C()
|
|
563
630
|
});
|
|
564
631
|
class G {
|
|
565
632
|
/**
|
|
@@ -618,9 +685,9 @@ class G {
|
|
|
618
685
|
return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
|
|
619
686
|
}
|
|
620
687
|
}
|
|
621
|
-
const _ = 1e3 * 30,
|
|
622
|
-
function
|
|
623
|
-
|
|
688
|
+
const _ = 1e3 * 30, q = typeof window > "u" && typeof self < "u", y = q ? self : window;
|
|
689
|
+
function w(a) {
|
|
690
|
+
q ? self.postMessage(a) : y.parent.postMessage(a, "*");
|
|
624
691
|
}
|
|
625
692
|
class J {
|
|
626
693
|
/**
|
|
@@ -822,7 +889,7 @@ class J {
|
|
|
822
889
|
*/
|
|
823
890
|
bind() {
|
|
824
891
|
var e, t, s;
|
|
825
|
-
const o = new URL(
|
|
892
|
+
const o = new URL(y.location.href), n = o.searchParams;
|
|
826
893
|
if (this._applicationInstance = (e = n.get("applicationInstance")) !== null && e !== void 0 ? e : "", !this._applicationInstance)
|
|
827
894
|
throw new Error("Missing applicationInstance query parameter");
|
|
828
895
|
if (this._applicationSpecifier = (t = n.get("applicationSpecifier")) !== null && t !== void 0 ? t : "", !this._applicationSpecifier) {
|
|
@@ -832,13 +899,13 @@ class J {
|
|
|
832
899
|
if (!this._applicationSpecifier || this._applicationSpecifier.length !== 40)
|
|
833
900
|
throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
834
901
|
this._windowMessageHandler = (i) => {
|
|
835
|
-
if (i.source ===
|
|
902
|
+
if (i.source === y || !i.data || typeof i.data != "object" || !("type" in i.data) || i.data.type !== "client" && i.data.type !== "bridge")
|
|
836
903
|
return;
|
|
837
904
|
let l;
|
|
838
905
|
if (i.data.type === "client") {
|
|
839
906
|
const c = this._messageInterceptors.get(i.data.name);
|
|
840
907
|
if (!c) {
|
|
841
|
-
|
|
908
|
+
w(i.data);
|
|
842
909
|
return;
|
|
843
910
|
}
|
|
844
911
|
l = { ...c(i.data.data), type: "bridge" };
|
|
@@ -850,18 +917,18 @@ class J {
|
|
|
850
917
|
l = c.data;
|
|
851
918
|
const d = this._onHandlers.get(l.name), u = this._onceHandlers.get(l.name);
|
|
852
919
|
if (d)
|
|
853
|
-
for (const
|
|
854
|
-
|
|
920
|
+
for (const h of d)
|
|
921
|
+
h(l.data);
|
|
855
922
|
if (u) {
|
|
856
|
-
for (const
|
|
857
|
-
|
|
923
|
+
for (const h of u)
|
|
924
|
+
h(l.data);
|
|
858
925
|
this._onceHandlers.delete(l.name);
|
|
859
926
|
}
|
|
860
927
|
}
|
|
861
|
-
if (!
|
|
928
|
+
if (!q)
|
|
862
929
|
for (let c = 0; c < window.frames.length; c += 1)
|
|
863
930
|
window.frames[c].postMessage(l, "*");
|
|
864
|
-
},
|
|
931
|
+
}, y.addEventListener("message", this._windowMessageHandler);
|
|
865
932
|
}
|
|
866
933
|
/**
|
|
867
934
|
* Removes the message event listener and cleans up resources.
|
|
@@ -877,7 +944,7 @@ class J {
|
|
|
877
944
|
* of managing their own Client instances.
|
|
878
945
|
*/
|
|
879
946
|
unbind() {
|
|
880
|
-
this._windowMessageHandler &&
|
|
947
|
+
this._windowMessageHandler && y.removeEventListener("message", this._windowMessageHandler);
|
|
881
948
|
}
|
|
882
949
|
/**
|
|
883
950
|
* Sends a one-way message to the TelemetryOS platform.
|
|
@@ -901,7 +968,7 @@ class J {
|
|
|
901
968
|
name: e,
|
|
902
969
|
data: t
|
|
903
970
|
});
|
|
904
|
-
|
|
971
|
+
w(s);
|
|
905
972
|
}
|
|
906
973
|
/**
|
|
907
974
|
* Sends a message to the TelemetryOS platform and waits for a response.
|
|
@@ -930,12 +997,12 @@ class J {
|
|
|
930
997
|
data: t,
|
|
931
998
|
responseName: s
|
|
932
999
|
});
|
|
933
|
-
|
|
1000
|
+
w(o);
|
|
934
1001
|
let n = !1, i;
|
|
935
1002
|
const l = new Promise((d, u) => {
|
|
936
|
-
const
|
|
1003
|
+
const h = new Error(`${e} message request with response name of ${s} timed out after ${_}`);
|
|
937
1004
|
setTimeout(() => {
|
|
938
|
-
n = !0, this.off(s, i), u(
|
|
1005
|
+
n = !0, this.off(s, i), u(h);
|
|
939
1006
|
}, _);
|
|
940
1007
|
}), c = new Promise((d) => {
|
|
941
1008
|
i = (u) => {
|
|
@@ -960,19 +1027,19 @@ class J {
|
|
|
960
1027
|
responseName: l,
|
|
961
1028
|
subscriptionName: i
|
|
962
1029
|
});
|
|
963
|
-
|
|
964
|
-
let u = !1,
|
|
1030
|
+
w(d);
|
|
1031
|
+
let u = !1, h;
|
|
965
1032
|
const f = new Promise((b, g) => {
|
|
966
1033
|
const m = new Error(`${e} subscribe request with subscription name of ${i} and response name of ${l} timed out after ${_}`);
|
|
967
1034
|
setTimeout(() => {
|
|
968
|
-
u = !0, this.off(l,
|
|
1035
|
+
u = !0, this.off(l, h), g(m);
|
|
969
1036
|
}, _);
|
|
970
|
-
}),
|
|
971
|
-
|
|
1037
|
+
}), E = new Promise((b) => {
|
|
1038
|
+
h = (g) => {
|
|
972
1039
|
u || b(g);
|
|
973
1040
|
}, this.on(l, b);
|
|
974
1041
|
});
|
|
975
|
-
return Promise.race([f,
|
|
1042
|
+
return Promise.race([f, E]);
|
|
976
1043
|
}
|
|
977
1044
|
async unsubscribe(e, t, s) {
|
|
978
1045
|
let o, n;
|
|
@@ -998,19 +1065,19 @@ class J {
|
|
|
998
1065
|
responseName: i,
|
|
999
1066
|
unsubscribeName: c
|
|
1000
1067
|
});
|
|
1001
|
-
|
|
1002
|
-
let u = !1,
|
|
1068
|
+
w(d);
|
|
1069
|
+
let u = !1, h;
|
|
1003
1070
|
const f = new Promise((g, m) => {
|
|
1004
|
-
const
|
|
1071
|
+
const H = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${_}`);
|
|
1005
1072
|
setTimeout(() => {
|
|
1006
|
-
u = !0, this.off(i,
|
|
1073
|
+
u = !0, this.off(i, h), m(H);
|
|
1007
1074
|
}, _);
|
|
1008
|
-
}),
|
|
1009
|
-
|
|
1075
|
+
}), E = new Promise((g) => {
|
|
1076
|
+
h = (m) => {
|
|
1010
1077
|
u || g(m);
|
|
1011
1078
|
}, this.once(i, g);
|
|
1012
1079
|
});
|
|
1013
|
-
if (!(await Promise.race([f,
|
|
1080
|
+
if (!(await Promise.race([f, E])).success)
|
|
1014
1081
|
return { success: !1 };
|
|
1015
1082
|
}
|
|
1016
1083
|
return { success: !0 };
|
|
@@ -1090,7 +1157,7 @@ class J {
|
|
|
1090
1157
|
function N() {
|
|
1091
1158
|
return Math.random().toString(36).slice(2, 9);
|
|
1092
1159
|
}
|
|
1093
|
-
const I =
|
|
1160
|
+
const I = B.version;
|
|
1094
1161
|
let r = null;
|
|
1095
1162
|
function O() {
|
|
1096
1163
|
return r;
|
|
@@ -1102,60 +1169,60 @@ function Q() {
|
|
|
1102
1169
|
r == null || r.unbind(), r = null;
|
|
1103
1170
|
}
|
|
1104
1171
|
function X(...a) {
|
|
1105
|
-
return
|
|
1172
|
+
return p(r), r.on(...a);
|
|
1106
1173
|
}
|
|
1107
1174
|
function Y(...a) {
|
|
1108
|
-
return
|
|
1175
|
+
return p(r), r.once(...a);
|
|
1109
1176
|
}
|
|
1110
1177
|
function Z(...a) {
|
|
1111
|
-
return
|
|
1178
|
+
return p(r), r.off(...a);
|
|
1112
1179
|
}
|
|
1113
1180
|
function ee(...a) {
|
|
1114
|
-
return
|
|
1181
|
+
return p(r), r.send(...a);
|
|
1115
1182
|
}
|
|
1116
1183
|
function te(...a) {
|
|
1117
|
-
return
|
|
1184
|
+
return p(r), r.request(...a);
|
|
1118
1185
|
}
|
|
1119
1186
|
function se(...a) {
|
|
1120
|
-
return
|
|
1187
|
+
return p(r), r.subscribe(...a);
|
|
1121
1188
|
}
|
|
1122
1189
|
function ne(...a) {
|
|
1123
|
-
return
|
|
1190
|
+
return p(r), r.unsubscribe(...a);
|
|
1124
1191
|
}
|
|
1125
1192
|
function ie() {
|
|
1126
|
-
return
|
|
1193
|
+
return p(r), r.store;
|
|
1127
1194
|
}
|
|
1128
1195
|
function re() {
|
|
1129
|
-
return
|
|
1196
|
+
return p(r), r.applications;
|
|
1130
1197
|
}
|
|
1131
1198
|
function oe() {
|
|
1132
|
-
return
|
|
1199
|
+
return p(r), r.media;
|
|
1133
1200
|
}
|
|
1134
1201
|
function ae() {
|
|
1135
|
-
return
|
|
1202
|
+
return p(r), r.accounts;
|
|
1136
1203
|
}
|
|
1137
1204
|
function ce() {
|
|
1138
|
-
return
|
|
1205
|
+
return p(r), r.users;
|
|
1139
1206
|
}
|
|
1140
1207
|
function le() {
|
|
1141
|
-
return
|
|
1208
|
+
return p(r), r.devices;
|
|
1142
1209
|
}
|
|
1143
1210
|
function ue() {
|
|
1144
|
-
return
|
|
1145
|
-
}
|
|
1146
|
-
function pe() {
|
|
1147
|
-
return h(r), r.rootSettingsNavigation;
|
|
1211
|
+
return p(r), r.proxy;
|
|
1148
1212
|
}
|
|
1149
1213
|
function he() {
|
|
1150
|
-
return
|
|
1214
|
+
return p(r), r.rootSettingsNavigation;
|
|
1215
|
+
}
|
|
1216
|
+
function pe() {
|
|
1217
|
+
return p(r), r.weather;
|
|
1151
1218
|
}
|
|
1152
1219
|
function de() {
|
|
1153
|
-
return
|
|
1220
|
+
return p(r), r.currency;
|
|
1154
1221
|
}
|
|
1155
1222
|
function fe() {
|
|
1156
|
-
return
|
|
1223
|
+
return p(r), r.environment;
|
|
1157
1224
|
}
|
|
1158
|
-
function
|
|
1225
|
+
function p(a) {
|
|
1159
1226
|
if (!a)
|
|
1160
1227
|
throw new Error("SDK is not configured");
|
|
1161
1228
|
}
|
|
@@ -1186,12 +1253,12 @@ export {
|
|
|
1186
1253
|
Y as once,
|
|
1187
1254
|
ue as proxy,
|
|
1188
1255
|
te as request,
|
|
1189
|
-
|
|
1256
|
+
he as rootSettingsNavigation,
|
|
1190
1257
|
ee as send,
|
|
1191
1258
|
ie as store,
|
|
1192
1259
|
se as subscribe,
|
|
1193
1260
|
I as telemetrySdkVersion,
|
|
1194
1261
|
ne as unsubscribe,
|
|
1195
1262
|
ce as users,
|
|
1196
|
-
|
|
1263
|
+
pe as weather
|
|
1197
1264
|
};
|
package/dist/weather.d.ts
CHANGED
|
@@ -1,165 +1,378 @@
|
|
|
1
1
|
import type { Client } from './client.js';
|
|
2
2
|
/**
|
|
3
|
-
* Weather
|
|
3
|
+
* Weather location information shared across all weather endpoints
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/** Timezone */
|
|
15
|
-
Timezone: string;
|
|
16
|
-
/** Weather description text */
|
|
17
|
-
WeatherText: string;
|
|
18
|
-
/** State/Province */
|
|
19
|
-
State: string;
|
|
20
|
-
/** Part of day (day/night indicator) */
|
|
21
|
-
Pod: string;
|
|
22
|
-
/** Weather code (internal mapping) */
|
|
23
|
-
WeatherCode: string;
|
|
24
|
-
/** Wind direction in degrees */
|
|
25
|
-
WindDirectionDegrees: string;
|
|
26
|
-
/** Wind direction (cardinal direction in English) */
|
|
27
|
-
WindDirectionEnglish: string;
|
|
28
|
-
/** Wind direction (localized) */
|
|
29
|
-
WindDirectionLocalized: string;
|
|
30
|
-
/** Relative humidity percentage */
|
|
31
|
-
RelativeHumidity: number;
|
|
32
|
-
/** Unix timestamp */
|
|
33
|
-
Timestamp: number;
|
|
34
|
-
/** Longitude */
|
|
35
|
-
Longitude: number;
|
|
36
|
-
/** Latitude */
|
|
37
|
-
Latitude: number;
|
|
38
|
-
/** Temperature */
|
|
39
|
-
Temp: number;
|
|
40
|
-
/** Atmospheric pressure */
|
|
41
|
-
Pressure: number;
|
|
42
|
-
/** Wind speed */
|
|
43
|
-
WindSpeed: number;
|
|
44
|
-
/** Visibility distance */
|
|
45
|
-
Visibility: number;
|
|
46
|
-
/** Precipitation amount */
|
|
47
|
-
Precip: number;
|
|
5
|
+
type WeatherLocation = {
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
cityName: string;
|
|
9
|
+
stateName?: string;
|
|
10
|
+
stateCode?: string;
|
|
11
|
+
countryName: string;
|
|
12
|
+
countryCode: string;
|
|
13
|
+
timezone: string;
|
|
48
14
|
};
|
|
49
15
|
/**
|
|
50
|
-
*
|
|
16
|
+
* Current weather conditions
|
|
51
17
|
*/
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
18
|
+
export type WeatherPartOfDay = 'day' | 'night';
|
|
19
|
+
export type WeatherConditions = WeatherLocation & {
|
|
20
|
+
observedAtSec: number;
|
|
21
|
+
observedAtLocal: string;
|
|
22
|
+
sunrise: string;
|
|
23
|
+
sunset: string;
|
|
24
|
+
partOfDay: WeatherPartOfDay;
|
|
25
|
+
weatherCode: number;
|
|
26
|
+
weatherDescription: string;
|
|
27
|
+
weatherIcon: string;
|
|
28
|
+
temperatureC: number;
|
|
29
|
+
temperatureF: number;
|
|
30
|
+
temperatureFeelsLikeC: number;
|
|
31
|
+
temperatureFeelsLikeF: number;
|
|
32
|
+
dewPointC: number;
|
|
33
|
+
dewPointF: number;
|
|
34
|
+
windSpeedKph: number;
|
|
35
|
+
windSpeedMph: number;
|
|
36
|
+
gustSpeedKph: number;
|
|
37
|
+
gustSpeedMph: number;
|
|
38
|
+
windDirectionDeg: number;
|
|
39
|
+
windDirectionFull: string;
|
|
40
|
+
windDirectionShort: string;
|
|
41
|
+
pressureMb: number;
|
|
42
|
+
pressureInHg: number;
|
|
43
|
+
seaLevelPressureMb: number;
|
|
44
|
+
seaLevelPressureInHg: number;
|
|
45
|
+
visibilityKm: number;
|
|
46
|
+
visibilityMi: number;
|
|
47
|
+
humidity: number;
|
|
48
|
+
clouds: number;
|
|
49
|
+
precipitationRateMmph: number;
|
|
50
|
+
precipitationRateInph: number;
|
|
51
|
+
snowfallRateMmph: number;
|
|
52
|
+
snowfallRateInph: number;
|
|
53
|
+
uvIndex: number;
|
|
54
|
+
airQualityIndex: number;
|
|
69
55
|
};
|
|
70
56
|
/**
|
|
71
|
-
*
|
|
57
|
+
* Single day of forecast data
|
|
72
58
|
*/
|
|
73
|
-
export type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
export type DailyForecastData = {
|
|
60
|
+
forecastDate: string;
|
|
61
|
+
forecastDateSec: number;
|
|
62
|
+
weatherCode: number;
|
|
63
|
+
weatherDescription: string;
|
|
64
|
+
weatherIcon: string;
|
|
65
|
+
precipitationProbability: number;
|
|
66
|
+
temperatureC: number;
|
|
67
|
+
temperatureF: number;
|
|
68
|
+
maxTemperatureC: number;
|
|
69
|
+
maxTemperatureF: number;
|
|
70
|
+
minTemperatureC: number;
|
|
71
|
+
minTemperatureF: number;
|
|
72
|
+
highTemperatureC: number;
|
|
73
|
+
highTemperatureF: number;
|
|
74
|
+
lowTemperatureC: number;
|
|
75
|
+
lowTemperatureF: number;
|
|
76
|
+
maxTemperatureFeelsLikeC: number;
|
|
77
|
+
maxTemperatureFeelsLikeF: number;
|
|
78
|
+
minTemperatureFeelsLikeC: number;
|
|
79
|
+
minTemperatureFeelsLikeF: number;
|
|
80
|
+
dewPointC: number;
|
|
81
|
+
dewPointF: number;
|
|
82
|
+
windSpeedKph: number;
|
|
83
|
+
windSpeedMph: number;
|
|
84
|
+
gustSpeedKph: number;
|
|
85
|
+
gustSpeedMph: number;
|
|
86
|
+
windDirectionDeg: number;
|
|
87
|
+
windDirectionFull: string;
|
|
88
|
+
windDirectionShort: string;
|
|
89
|
+
pressureMb: number;
|
|
90
|
+
pressureInHg: number;
|
|
91
|
+
seaLevelPressureMb: number;
|
|
92
|
+
seaLevelPressureInHg: number;
|
|
93
|
+
visibilityKm: number;
|
|
94
|
+
visibilityMi: number;
|
|
95
|
+
humidity: number;
|
|
96
|
+
clouds: number;
|
|
97
|
+
precipitationMm: number;
|
|
98
|
+
precipitationIn: number;
|
|
99
|
+
snowfallMm: number;
|
|
100
|
+
snowfallIn: number;
|
|
101
|
+
snowDepthMm: number;
|
|
102
|
+
snowDepthIn: number;
|
|
103
|
+
uvIndex: number;
|
|
104
|
+
sunrise: string;
|
|
105
|
+
sunset: string;
|
|
106
|
+
moonrise: string;
|
|
107
|
+
moonset: string;
|
|
108
|
+
moonIllumination: number;
|
|
109
|
+
moonLunationPhase: number;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Daily weather forecast with location
|
|
113
|
+
*/
|
|
114
|
+
export type DailyForecast = WeatherLocation & {
|
|
115
|
+
data: DailyForecastData[];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Single hour of forecast data
|
|
119
|
+
*/
|
|
120
|
+
export type HourlyForecastData = {
|
|
121
|
+
forecastTimeSec: number;
|
|
122
|
+
forecastTimeLocal: string;
|
|
123
|
+
forecastTimeUtc: string;
|
|
124
|
+
partOfDay: WeatherPartOfDay;
|
|
125
|
+
weatherCode: number;
|
|
126
|
+
weatherDescription: string;
|
|
127
|
+
weatherIcon: string;
|
|
128
|
+
precipitationProbability: number;
|
|
129
|
+
temperatureC: number;
|
|
130
|
+
temperatureF: number;
|
|
131
|
+
temperatureFeelsLikeC: number;
|
|
132
|
+
temperatureFeelsLikeF: number;
|
|
133
|
+
dewPointC: number;
|
|
134
|
+
dewPointF: number;
|
|
135
|
+
windSpeedKph: number;
|
|
136
|
+
windSpeedMph: number;
|
|
137
|
+
gustSpeedKph: number;
|
|
138
|
+
gustSpeedMph: number;
|
|
139
|
+
windDirectionDeg: number;
|
|
140
|
+
windDirectionFull: string;
|
|
141
|
+
windDirectionShort: string;
|
|
142
|
+
pressureMb: number;
|
|
143
|
+
pressureInHg: number;
|
|
144
|
+
seaLevelPressureMb: number;
|
|
145
|
+
seaLevelPressureInHg: number;
|
|
146
|
+
visibilityKm: number;
|
|
147
|
+
visibilityMi: number;
|
|
148
|
+
humidity: number;
|
|
149
|
+
clouds: number;
|
|
150
|
+
precipitationMm: number;
|
|
151
|
+
precipitationIn: number;
|
|
152
|
+
snowfallMm: number;
|
|
153
|
+
snowfallIn: number;
|
|
154
|
+
snowDepthMm: number;
|
|
155
|
+
snowDepthIn: number;
|
|
156
|
+
uvIndex: number;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Hourly weather forecast with location
|
|
160
|
+
*/
|
|
161
|
+
export type HourlyForecast = WeatherLocation & {
|
|
162
|
+
data: HourlyForecastData[];
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Single weather alert/warning
|
|
166
|
+
*/
|
|
167
|
+
export type WeatherAlertSeverity = 'Advisory' | 'Watch' | 'Warning';
|
|
168
|
+
export type WeatherAlert = {
|
|
169
|
+
title: string;
|
|
170
|
+
description: string;
|
|
171
|
+
severity: WeatherAlertSeverity;
|
|
172
|
+
effectiveSec: number;
|
|
173
|
+
effectiveUtc: string;
|
|
174
|
+
effectiveLocal: string;
|
|
175
|
+
expiresSec: number;
|
|
176
|
+
expiresUtc: string;
|
|
177
|
+
expiresLocal: string;
|
|
178
|
+
onsetSec?: number;
|
|
179
|
+
onsetUtc?: string;
|
|
180
|
+
onsetLocal?: string;
|
|
181
|
+
endsSec?: number;
|
|
182
|
+
endsUtc?: string;
|
|
183
|
+
endsLocal?: string;
|
|
184
|
+
uri: string;
|
|
185
|
+
regions: string[];
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Weather alerts with location
|
|
189
|
+
*/
|
|
190
|
+
export type WeatherAlerts = WeatherLocation & {
|
|
191
|
+
alerts: WeatherAlert[];
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* City information for location search
|
|
195
|
+
*/
|
|
196
|
+
export type WeatherCity = {
|
|
197
|
+
cityId: number;
|
|
198
|
+
cityName: string;
|
|
199
|
+
stateName?: string;
|
|
200
|
+
stateCode?: string;
|
|
201
|
+
countryName: string;
|
|
202
|
+
countryCode: string;
|
|
203
|
+
latitude: number;
|
|
204
|
+
longitude: number;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Parameters for getting current weather conditions
|
|
208
|
+
*/
|
|
209
|
+
export type WeatherConditionsParams = {
|
|
210
|
+
/** WeatherBit city ID (required) */
|
|
211
|
+
cityId: number;
|
|
212
|
+
/** Language code for localized responses (optional) */
|
|
85
213
|
language?: string;
|
|
86
214
|
};
|
|
87
215
|
/**
|
|
88
|
-
* Parameters for daily forecast
|
|
216
|
+
* Parameters for getting daily forecast
|
|
89
217
|
*/
|
|
90
|
-
export type DailyForecastParams =
|
|
91
|
-
/**
|
|
218
|
+
export type DailyForecastParams = {
|
|
219
|
+
/** WeatherBit city ID (required) */
|
|
220
|
+
cityId: number;
|
|
221
|
+
/** Language code for localized responses (optional) */
|
|
222
|
+
language?: string;
|
|
223
|
+
/** Number of days to forecast, max 16 (optional, default 5) */
|
|
92
224
|
days?: number;
|
|
93
225
|
};
|
|
94
226
|
/**
|
|
95
|
-
* Parameters for hourly forecast
|
|
227
|
+
* Parameters for getting hourly forecast
|
|
96
228
|
*/
|
|
97
|
-
export type HourlyForecastParams =
|
|
98
|
-
/**
|
|
229
|
+
export type HourlyForecastParams = {
|
|
230
|
+
/** WeatherBit city ID (required) */
|
|
231
|
+
cityId: number;
|
|
232
|
+
/** Language code for localized responses (optional) */
|
|
233
|
+
language?: string;
|
|
234
|
+
/** Number of hours to forecast, max 120 (optional, default 12) */
|
|
99
235
|
hours?: number;
|
|
100
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Parameters for getting weather alerts
|
|
239
|
+
*/
|
|
240
|
+
export type WeatherAlertsParams = {
|
|
241
|
+
/** WeatherBit city ID (required) */
|
|
242
|
+
cityId: number;
|
|
243
|
+
/** Language code for localized responses (optional) */
|
|
244
|
+
language?: string;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Parameters for searching cities
|
|
248
|
+
*/
|
|
249
|
+
export type CitiesSearchParams = {
|
|
250
|
+
/** ISO country code filter (optional) */
|
|
251
|
+
countryCode?: string;
|
|
252
|
+
/** City name search query (optional) */
|
|
253
|
+
search?: string;
|
|
254
|
+
};
|
|
101
255
|
/**
|
|
102
256
|
* Weather API for retrieving weather data
|
|
103
257
|
*
|
|
104
|
-
* Provides access to current conditions
|
|
258
|
+
* Provides access to current conditions, forecasts, alerts, and city search
|
|
259
|
+
* through the TelemetryOS weather API v2.
|
|
105
260
|
*/
|
|
106
261
|
export declare class Weather {
|
|
107
262
|
_client: Client;
|
|
108
263
|
constructor(client: Client);
|
|
109
264
|
/**
|
|
110
|
-
*
|
|
265
|
+
* Searches for cities by name or country
|
|
266
|
+
*
|
|
267
|
+
* @param params - Search parameters including optional country code and search query
|
|
268
|
+
* @returns A promise that resolves to an array of matching cities
|
|
269
|
+
* @throws {Error} If the request fails
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* // Search for cities named "New York"
|
|
274
|
+
* const cities = await weather.getCities({ search: 'New York' })
|
|
275
|
+
*
|
|
276
|
+
* // Search for cities in the United States
|
|
277
|
+
* const cities = await weather.getCities({ countryCode: 'US' })
|
|
278
|
+
*
|
|
279
|
+
* // Get a cityId for use in other methods
|
|
280
|
+
* const cities = await weather.getCities({ search: 'London' })
|
|
281
|
+
* const cityId = cities[0].cityId
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
getCities(params: CitiesSearchParams): Promise<WeatherCity[]>;
|
|
285
|
+
/**
|
|
286
|
+
* Retrieves current weather conditions for a specified city
|
|
111
287
|
*
|
|
112
|
-
* @param params - Weather request parameters including
|
|
113
|
-
* @returns A promise that resolves to the current weather conditions
|
|
114
|
-
* @throws {Error} If the request fails or
|
|
288
|
+
* @param params - Weather request parameters including cityId and optional language
|
|
289
|
+
* @returns A promise that resolves to the current weather conditions with dual units (C/F, kph/mph, etc.)
|
|
290
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
115
291
|
*
|
|
116
292
|
* @example
|
|
117
293
|
* ```typescript
|
|
118
|
-
* // Get
|
|
119
|
-
* const
|
|
294
|
+
* // Get current conditions for a city
|
|
295
|
+
* const conditions = await weather.getConditions({ cityId: 12345 })
|
|
120
296
|
*
|
|
121
|
-
* //
|
|
122
|
-
* const
|
|
297
|
+
* // With localized language
|
|
298
|
+
* const conditions = await weather.getConditions({
|
|
299
|
+
* cityId: 12345,
|
|
300
|
+
* language: 'es'
|
|
301
|
+
* })
|
|
123
302
|
*
|
|
124
|
-
* //
|
|
125
|
-
*
|
|
303
|
+
* // Access both units
|
|
304
|
+
* console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`)
|
|
305
|
+
* console.log(`${conditions.windSpeedKph} kph / ${conditions.windSpeedMph} mph`)
|
|
126
306
|
* ```
|
|
127
307
|
*/
|
|
128
|
-
getConditions(params:
|
|
308
|
+
getConditions(params: WeatherConditionsParams): Promise<WeatherConditions>;
|
|
129
309
|
/**
|
|
130
|
-
* Retrieves daily weather forecast for a specified
|
|
310
|
+
* Retrieves daily weather forecast for a specified city
|
|
131
311
|
*
|
|
132
|
-
* @param params - Forecast request parameters including
|
|
133
|
-
* @returns A promise that resolves to
|
|
134
|
-
* @throws {Error} If the request fails or
|
|
312
|
+
* @param params - Forecast request parameters including cityId, optional language and days
|
|
313
|
+
* @returns A promise that resolves to daily forecast data with location information
|
|
314
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
135
315
|
*
|
|
136
316
|
* @example
|
|
137
317
|
* ```typescript
|
|
138
318
|
* // Get 5-day forecast
|
|
139
|
-
* const forecast = await weather.getDailyForecast({
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
319
|
+
* const forecast = await weather.getDailyForecast({ cityId: 12345 })
|
|
320
|
+
*
|
|
321
|
+
* // Get 10-day forecast
|
|
322
|
+
* const forecast = await weather.getDailyForecast({ cityId: 12345, days: 10 })
|
|
323
|
+
*
|
|
324
|
+
* // Access forecast data
|
|
325
|
+
* forecast.data.forEach(day => {
|
|
326
|
+
* console.log(`${day.forecastDate}: ${day.weatherDescription}`)
|
|
327
|
+
* console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`)
|
|
143
328
|
* })
|
|
144
329
|
* ```
|
|
145
330
|
*/
|
|
146
|
-
getDailyForecast(params: DailyForecastParams): Promise<
|
|
331
|
+
getDailyForecast(params: DailyForecastParams): Promise<DailyForecast>;
|
|
147
332
|
/**
|
|
148
|
-
* Retrieves hourly weather forecast for a specified
|
|
333
|
+
* Retrieves hourly weather forecast for a specified city
|
|
149
334
|
*
|
|
150
|
-
* @param params - Forecast request parameters including
|
|
151
|
-
* @returns A promise that resolves to
|
|
152
|
-
* @throws {Error} If the request fails or
|
|
335
|
+
* @param params - Forecast request parameters including cityId, optional language and hours
|
|
336
|
+
* @returns A promise that resolves to hourly forecast data with location information
|
|
337
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
153
338
|
*
|
|
154
339
|
* @example
|
|
155
340
|
* ```typescript
|
|
156
341
|
* // Get 24-hour forecast
|
|
157
|
-
* const forecast = await weather.getHourlyForecast({
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
342
|
+
* const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 24 })
|
|
343
|
+
*
|
|
344
|
+
* // Get 48-hour forecast
|
|
345
|
+
* const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 48 })
|
|
346
|
+
*
|
|
347
|
+
* // Access forecast data
|
|
348
|
+
* forecast.data.forEach(hour => {
|
|
349
|
+
* console.log(`${hour.forecastTimeLocal}: ${hour.weatherDescription}`)
|
|
350
|
+
* console.log(`Temp: ${hour.temperatureC}°C`)
|
|
161
351
|
* })
|
|
162
352
|
* ```
|
|
163
353
|
*/
|
|
164
|
-
getHourlyForecast(params: HourlyForecastParams): Promise<
|
|
354
|
+
getHourlyForecast(params: HourlyForecastParams): Promise<HourlyForecast>;
|
|
355
|
+
/**
|
|
356
|
+
* Retrieves weather alerts and warnings for a specified city
|
|
357
|
+
*
|
|
358
|
+
* @param params - Alert request parameters including cityId and optional language
|
|
359
|
+
* @returns A promise that resolves to weather alerts with location information
|
|
360
|
+
* @throws {Error} If the request fails or cityId is invalid
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* // Get weather alerts for a city
|
|
365
|
+
* const alerts = await weather.getAlerts({ cityId: 12345 })
|
|
366
|
+
*
|
|
367
|
+
* // Check if there are any active alerts
|
|
368
|
+
* if (alerts.alerts.length > 0) {
|
|
369
|
+
* alerts.alerts.forEach(alert => {
|
|
370
|
+
* console.log(`${alert.severity}: ${alert.title}`)
|
|
371
|
+
* console.log(alert.description)
|
|
372
|
+
* })
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
getAlerts(params: WeatherAlertsParams): Promise<WeatherAlerts>;
|
|
165
377
|
}
|
|
378
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telemetryos/root-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "The official TelemetryOS root application sdk package. Provides types and apis for building root TelemetryOS applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|