@liberfi.io/ui-channels 0.1.1 → 0.1.3

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.
@@ -1,2 +1,2 @@
1
- 'use strict';var utils=require('@liberfi.io/utils');function c(a){let e=utils.chainIdBySlug(a.chain);if(!e)throw new Error(`Unsupported chain: ${a.chain}`);return {...a,chain:e}}function h(a){return {...a,list:a.list.map(c)}}var p=class{endpoint;accessToken;constructor({endpoint:e,accessToken:n}){this.endpoint=e,this.accessToken=n;}async get(e){let n=await this._requestOptions(),s=await utils.get(`${this.endpoint}/channels/${e}`,n);return c(s.data)}async subscribe(e){let n=await this._requestOptions();await utils.post(`${this.endpoint}/channels/${e}/subscribe`,{notification_enabled:true},n);}async unsubscribe(e){let n=await this._requestOptions();await utils.del(`${this.endpoint}/channels/${e}/subscribe`,n);}async getChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getSubscribedChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/subscribed${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getMyChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/my${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getChannelEvents(e,n){let s=await this._requestOptions(),t=new URLSearchParams;n?.limit&&t.set("limit",n.limit.toString()),n?.next_page&&t.set("next_page",n.next_page.toString()),n?.timestamp&&t.set("timestamp",n.timestamp.toString());let r=t.toString(),i=`${this.endpoint}/channels/${e}/events${r?`?${r}`:""}`;return (await utils.get(i,s)).data}async create(e){let n=await this._requestOptions(),s=await utils.post(`${this.endpoint}/channels`,e,n);return c(s.data)}async update(e){let n=await this._requestOptions(),s=await utils.put(`${this.endpoint}/channels/${e.id}`,e,n);return c(s.data)}async updateSources(e){let n=await this._requestOptions();return (await utils.put(`${this.endpoint}/channels/${e.channel_id}/sources`,e,n)).data}async getSources(e){let n=await this._requestOptions();return (await utils.get(`${this.endpoint}/channels/${e}/sources`,n)).data}async _requestOptions(){let e=typeof this.accessToken=="string"?this.accessToken:await this.accessToken.getToken(),n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),{headers:n}}};exports.ChannelsClient=p;//# sourceMappingURL=index.js.map
1
+ 'use strict';var utils=require('@liberfi.io/utils');function c(a){let e=utils.chainIdBySlug(a.chain);if(!e)throw new Error(`Unsupported chain: ${a.chain}`);return {...a,chain:e}}function h(a){return {...a,list:a.list.map(c)}}var p=class{endpoint;accessToken;constructor({endpoint:e,accessToken:n}){this.endpoint=e,this.accessToken=n;}async get(e){let n=await this._requestOptions(),s=await utils.get(`${this.endpoint}/channels/${e}`,n);return c(s.data)}async subscribe(e){let n=await this._requestOptions();await utils.post(`${this.endpoint}/channels/${e}/subscribe`,{notification_enabled:true},n);}async unsubscribe(e){let n=await this._requestOptions();await utils.del(`${this.endpoint}/channels/${e}/subscribe`,n);}async getChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getSubscribedChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/subscribed${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getMyChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/my${t?`?${t}`:""}`,i=await utils.get(r,n);return h(i.data)}async getChannelEvents(e,n){let s=await this._requestOptions(),t=new URLSearchParams;n?.limit&&t.set("limit",n.limit.toString()),n?.next_page&&t.set("next_page",n.next_page.toString()),n?.timestamp&&t.set("timestamp",n.timestamp.toString());let r=t.toString(),i=`${this.endpoint}/channels/${e}/events${r?`?${r}`:""}`;return await utils.get(i,s)}async create(e){let n=await this._requestOptions(),s=await utils.post(`${this.endpoint}/channels`,e,n);return c(s.data)}async update(e){let n=await this._requestOptions(),s=await utils.put(`${this.endpoint}/channels/${e.id}`,e,n);return c(s.data)}async updateSources(e){let n=await this._requestOptions();return (await utils.put(`${this.endpoint}/channels/${e.channel_id}/sources`,e,n)).data}async getSources(e){let n=await this._requestOptions();return (await utils.get(`${this.endpoint}/channels/${e}/sources`,n)).data}async _requestOptions(){let e=typeof this.accessToken=="string"?this.accessToken:await this.accessToken.getToken(),n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),{headers:n}}};exports.ChannelsClient=p;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/utils.ts","../../src/client/client.ts"],"names":["convertFromChannelDTO","input","chain","chainIdBySlug","convertFromChannelsListDTO","ChannelsClient","endpoint","accessToken","id","requestOptions","resp","get","post","del","options","queryParams","queryString","url","channelId","params","put","token","headers"],"mappings":"oDAIO,SAASA,CAAAA,CAAsBC,EAA4B,CAChE,IAAMC,CAAAA,CAAQC,mBAAAA,CAAcF,EAAM,KAAK,CAAA,CACvC,GAAI,CAACC,EAAO,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsBD,EAAM,KAAK,CAAA,CAAE,CAAA,CAC/D,OAAO,CACL,GAAGA,CAAAA,CACH,KAAA,CAAAC,CACF,CACF,CAEO,SAASE,CAAAA,CACdH,CAAAA,CACkB,CAClB,OAAO,CACL,GAAGA,CAAAA,CACH,KAAMA,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAID,CAAqB,CAC5C,CACF,CCEO,IAAMK,CAAAA,CAAN,KAAoD,CACxC,QAAA,CACA,WAAA,CAEjB,WAAA,CAAY,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAY,EAA0B,CAC5D,IAAA,CAAK,QAAA,CAAWD,CAAAA,CAChB,KAAK,WAAA,CAAcC,EACrB,CAEA,MAAM,IAAIC,CAAAA,CAA8B,CACtC,IAAMC,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,EAAgB,CAC5CC,CAAAA,CAAO,MAAMC,SAAAA,CACjB,CAAA,EAAG,IAAA,CAAK,QAAQ,aAAaH,CAAE,CAAA,CAAA,CAC/BC,CACF,CAAA,CACA,OAAOT,CAAAA,CAAsBU,CAAAA,CAAK,IAAI,CACxC,CAEA,MAAM,SAAA,CAAUF,CAAAA,CAA2B,CACzC,IAAMC,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,GAClC,MAAMG,UAAAA,CACJ,CAAA,EAAG,IAAA,CAAK,QAAQ,CAAA,UAAA,EAAaJ,CAAE,CAAA,UAA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T,CACF,CAAA,EACY,IACd,CAEA,MAAM,iBAAwD,CAC5D,IAAMY,CAAAA,CACJ,OAAO,KAAK,WAAA,EAAgB,QAAA,CACxB,IAAA,CAAK,WAAA,CACL,MAAM,IAAA,CAAK,WAAA,CAAY,QAAA,EAAS,CAEhCC,EAAkC,CACtC,cAAA,CAAgB,kBAClB,CAAA,CAEA,OAAID,CAAAA,GACFC,CAAAA,CAAQ,aAAA,CAAgB,CAAA,OAAA,EAAUD,CAAK,CAAA,CAAA,CAAA,CAGlC,CAAE,OAAA,CAAAC,CAAQ,CACnB,CACF","file":"index.js","sourcesContent":["import { API, Channel } from \"@liberfi.io/types\";\nimport { chainIdBySlug } from \"@liberfi.io/utils\";\nimport { ChannelDTO, ChannelsListDTO } from \"./types\";\n\nexport function convertFromChannelDTO(input: ChannelDTO): Channel {\n const chain = chainIdBySlug(input.chain);\n if (!chain) throw new Error(`Unsupported chain: ${input.chain}`);\n return {\n ...input,\n chain,\n };\n}\n\nexport function convertFromChannelsListDTO(\n input: ChannelsListDTO,\n): API.ChannelsList {\n return {\n ...input,\n list: input.list.map(convertFromChannelDTO),\n };\n}\n","import { API, ChannelSource } from \"@liberfi.io/types\";\nimport { Channel } from \"@liberfi.io/types\";\nimport { del, get, post, put } from \"@liberfi.io/utils\";\nimport {\n ChannelEventsListResponse,\n ChannelResponse,\n ChannelsListResponse,\n ChannelSourcesResponse,\n SubscribeResponse,\n UnsubscribeResponse,\n} from \"./types\";\nimport { convertFromChannelDTO, convertFromChannelsListDTO } from \"./utils\";\n\nexport interface ChannelsClientOptions {\n endpoint: string;\n accessToken:\n | string\n | {\n getToken(): Promise<string | undefined | null>;\n };\n}\n\nexport class ChannelsClient implements API.IChannelsClient {\n private readonly endpoint: string;\n private readonly accessToken: ChannelsClientOptions[\"accessToken\"];\n\n constructor({ endpoint, accessToken }: ChannelsClientOptions) {\n this.endpoint = endpoint;\n this.accessToken = accessToken;\n }\n\n async get(id: string): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelResponse>(\n `${this.endpoint}/channels/${id}`,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async subscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await post<SubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n { notification_enabled: true },\n requestOptions,\n );\n }\n\n async unsubscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await del<UnsubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n requestOptions,\n );\n }\n\n async getChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getSubscribedChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/subscribed${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getMyChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/my${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getChannelEvents(\n channelId: string,\n options?: API.ListChannelEventsOptions,\n ): Promise<API.ChannelEventsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.limit) {\n queryParams.set(\"limit\", options.limit.toString());\n }\n if (options?.next_page) {\n queryParams.set(\"next_page\", options.next_page.toString());\n }\n if (options?.timestamp) {\n queryParams.set(\"timestamp\", options.timestamp.toString());\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/${channelId}/events${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelEventsListResponse>(url, requestOptions);\n return resp.data;\n }\n\n async create(params: API.CreateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await post<ChannelResponse>(\n `${this.endpoint}/channels`,\n params,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async update(options: API.UpdateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelResponse>(\n `${this.endpoint}/channels/${options.id}`,\n options,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async updateSources(\n options: API.UpdateChannelSourcesOptions,\n ): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${options.channel_id}/sources`,\n options,\n requestOptions,\n );\n return resp.data;\n }\n\n async getSources(channelId: string): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${channelId}/sources`,\n requestOptions,\n );\n return resp.data;\n }\n\n async _requestOptions(): Promise<Omit<RequestInit, \"method\">> {\n const token =\n typeof this.accessToken === \"string\"\n ? this.accessToken\n : await this.accessToken.getToken();\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return { headers };\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/client/utils.ts","../../src/client/client.ts"],"names":["convertFromChannelDTO","input","chain","chainIdBySlug","convertFromChannelsListDTO","ChannelsClient","endpoint","accessToken","id","requestOptions","resp","get","post","del","options","queryParams","queryString","url","channelId","params","put","token","headers"],"mappings":"oDAIO,SAASA,EAAsBC,CAAAA,CAA4B,CAChE,IAAMC,CAAAA,CAAQC,oBAAcF,CAAAA,CAAM,KAAK,CAAA,CACvC,GAAI,CAACC,CAAAA,CAAO,MAAM,IAAI,KAAA,CAAM,sBAAsBD,CAAAA,CAAM,KAAK,CAAA,CAAE,CAAA,CAC/D,OAAO,CACL,GAAGA,CAAAA,CACH,KAAA,CAAAC,CACF,CACF,CAEO,SAASE,CAAAA,CACdH,EACkB,CAClB,OAAO,CACL,GAAGA,EACH,IAAA,CAAMA,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAID,CAAqB,CAC5C,CACF,CCEO,IAAMK,EAAN,KAAoD,CACxC,QAAA,CACA,WAAA,CAEjB,YAAY,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAY,CAAA,CAA0B,CAC5D,IAAA,CAAK,QAAA,CAAWD,EAChB,IAAA,CAAK,WAAA,CA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,CAEA,MAAM,aAAA,CACJI,CAAAA,CAC+B,CAC/B,IAAML,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,GAMlC,OAAA,CALa,MAAMW,SAAAA,CACjB,CAAA,EAAG,KAAK,QAAQ,CAAA,UAAA,EAAaN,CAAAA,CAAQ,UAAU,WAC/CA,CAAAA,CACAL,CACF,CAAA,EACY,IACd,CAEA,MAAM,UAAA,CAAWS,CAAAA,CAAkD,CACjE,IAAMT,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,GAKlC,OAAA,CAJa,MAAME,SAAAA,CACjB,CAAA,EAAG,KAAK,QAAQ,CAAA,UAAA,EAAaO,CAAS,CAAA,QAAA,CAAA,CACtCT,CACF,CAAA,EACY,IACd,CAEA,MAAM,iBAAwD,CAC5D,IAAMY,CAAAA,CACJ,OAAO,KAAK,WAAA,EAAgB,QAAA,CACxB,IAAA,CAAK,WAAA,CACL,MAAM,IAAA,CAAK,WAAA,CAAY,QAAA,EAAS,CAEhCC,EAAkC,CACtC,cAAA,CAAgB,kBAClB,CAAA,CAEA,OAAID,CAAAA,GACFC,CAAAA,CAAQ,aAAA,CAAgB,CAAA,OAAA,EAAUD,CAAK,CAAA,CAAA,CAAA,CAGlC,CAAE,OAAA,CAAAC,CAAQ,CACnB,CACF","file":"index.js","sourcesContent":["import { API, Channel } from \"@liberfi.io/types\";\nimport { chainIdBySlug } from \"@liberfi.io/utils\";\nimport { ChannelDTO, ChannelsListDTO } from \"./types\";\n\nexport function convertFromChannelDTO(input: ChannelDTO): Channel {\n const chain = chainIdBySlug(input.chain);\n if (!chain) throw new Error(`Unsupported chain: ${input.chain}`);\n return {\n ...input,\n chain,\n };\n}\n\nexport function convertFromChannelsListDTO(\n input: ChannelsListDTO,\n): API.ChannelsList {\n return {\n ...input,\n list: input.list.map(convertFromChannelDTO),\n };\n}\n","import { API, ChannelSource } from \"@liberfi.io/types\";\nimport { Channel } from \"@liberfi.io/types\";\nimport { del, get, post, put } from \"@liberfi.io/utils\";\nimport {\n ChannelEventsListResponse,\n ChannelResponse,\n ChannelsListResponse,\n ChannelSourcesResponse,\n SubscribeResponse,\n UnsubscribeResponse,\n} from \"./types\";\nimport { convertFromChannelDTO, convertFromChannelsListDTO } from \"./utils\";\n\nexport interface ChannelsClientOptions {\n endpoint: string;\n accessToken:\n | string\n | {\n getToken(): Promise<string | undefined | null>;\n };\n}\n\nexport class ChannelsClient implements API.IChannelsClient {\n private readonly endpoint: string;\n private readonly accessToken: ChannelsClientOptions[\"accessToken\"];\n\n constructor({ endpoint, accessToken }: ChannelsClientOptions) {\n this.endpoint = endpoint;\n this.accessToken = accessToken;\n }\n\n async get(id: string): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelResponse>(\n `${this.endpoint}/channels/${id}`,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async subscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await post<SubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n { notification_enabled: true },\n requestOptions,\n );\n }\n\n async unsubscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await del<UnsubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n requestOptions,\n );\n }\n\n async getChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getSubscribedChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/subscribed${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getMyChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/my${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getChannelEvents(\n channelId: string,\n options?: API.ListChannelEventsOptions,\n ): Promise<API.ChannelEventsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.limit) {\n queryParams.set(\"limit\", options.limit.toString());\n }\n if (options?.next_page) {\n queryParams.set(\"next_page\", options.next_page.toString());\n }\n if (options?.timestamp) {\n queryParams.set(\"timestamp\", options.timestamp.toString());\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/${channelId}/events${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelEventsListResponse>(url, requestOptions);\n return resp;\n }\n\n async create(params: API.CreateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await post<ChannelResponse>(\n `${this.endpoint}/channels`,\n params,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async update(options: API.UpdateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelResponse>(\n `${this.endpoint}/channels/${options.id}`,\n options,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async updateSources(\n options: API.UpdateChannelSourcesOptions,\n ): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${options.channel_id}/sources`,\n options,\n requestOptions,\n );\n return resp.data;\n }\n\n async getSources(channelId: string): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${channelId}/sources`,\n requestOptions,\n );\n return resp.data;\n }\n\n async _requestOptions(): Promise<Omit<RequestInit, \"method\">> {\n const token =\n typeof this.accessToken === \"string\"\n ? this.accessToken\n : await this.accessToken.getToken();\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return { headers };\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {get,post,del,put,chainIdBySlug}from'@liberfi.io/utils';function c(a){let e=chainIdBySlug(a.chain);if(!e)throw new Error(`Unsupported chain: ${a.chain}`);return {...a,chain:e}}function h(a){return {...a,list:a.list.map(c)}}var p=class{endpoint;accessToken;constructor({endpoint:e,accessToken:n}){this.endpoint=e,this.accessToken=n;}async get(e){let n=await this._requestOptions(),s=await get(`${this.endpoint}/channels/${e}`,n);return c(s.data)}async subscribe(e){let n=await this._requestOptions();await post(`${this.endpoint}/channels/${e}/subscribe`,{notification_enabled:true},n);}async unsubscribe(e){let n=await this._requestOptions();await del(`${this.endpoint}/channels/${e}/subscribe`,n);}async getChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getSubscribedChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/subscribed${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getMyChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/my${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getChannelEvents(e,n){let s=await this._requestOptions(),t=new URLSearchParams;n?.limit&&t.set("limit",n.limit.toString()),n?.next_page&&t.set("next_page",n.next_page.toString()),n?.timestamp&&t.set("timestamp",n.timestamp.toString());let r=t.toString(),i=`${this.endpoint}/channels/${e}/events${r?`?${r}`:""}`;return (await get(i,s)).data}async create(e){let n=await this._requestOptions(),s=await post(`${this.endpoint}/channels`,e,n);return c(s.data)}async update(e){let n=await this._requestOptions(),s=await put(`${this.endpoint}/channels/${e.id}`,e,n);return c(s.data)}async updateSources(e){let n=await this._requestOptions();return (await put(`${this.endpoint}/channels/${e.channel_id}/sources`,e,n)).data}async getSources(e){let n=await this._requestOptions();return (await get(`${this.endpoint}/channels/${e}/sources`,n)).data}async _requestOptions(){let e=typeof this.accessToken=="string"?this.accessToken:await this.accessToken.getToken(),n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),{headers:n}}};export{p as ChannelsClient};//# sourceMappingURL=index.mjs.map
1
+ import {get,post,del,put,chainIdBySlug}from'@liberfi.io/utils';function c(a){let e=chainIdBySlug(a.chain);if(!e)throw new Error(`Unsupported chain: ${a.chain}`);return {...a,chain:e}}function h(a){return {...a,list:a.list.map(c)}}var p=class{endpoint;accessToken;constructor({endpoint:e,accessToken:n}){this.endpoint=e,this.accessToken=n;}async get(e){let n=await this._requestOptions(),s=await get(`${this.endpoint}/channels/${e}`,n);return c(s.data)}async subscribe(e){let n=await this._requestOptions();await post(`${this.endpoint}/channels/${e}/subscribe`,{notification_enabled:true},n);}async unsubscribe(e){let n=await this._requestOptions();await del(`${this.endpoint}/channels/${e}/subscribe`,n);}async getChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getSubscribedChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/subscribed${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getMyChannels(e){let n=await this._requestOptions(),s=new URLSearchParams;e?.chain&&s.set("chain",e.chain),e?.page&&s.set("page",e.page.toString()),e?.size&&s.set("size",e.size.toString()),e?.search&&s.set("search",e.search),e?.sort&&s.set("sort",e.sort),e?.order&&s.set("order",e.order);let t=s.toString(),r=`${this.endpoint}/channels/my${t?`?${t}`:""}`,i=await get(r,n);return h(i.data)}async getChannelEvents(e,n){let s=await this._requestOptions(),t=new URLSearchParams;n?.limit&&t.set("limit",n.limit.toString()),n?.next_page&&t.set("next_page",n.next_page.toString()),n?.timestamp&&t.set("timestamp",n.timestamp.toString());let r=t.toString(),i=`${this.endpoint}/channels/${e}/events${r?`?${r}`:""}`;return await get(i,s)}async create(e){let n=await this._requestOptions(),s=await post(`${this.endpoint}/channels`,e,n);return c(s.data)}async update(e){let n=await this._requestOptions(),s=await put(`${this.endpoint}/channels/${e.id}`,e,n);return c(s.data)}async updateSources(e){let n=await this._requestOptions();return (await put(`${this.endpoint}/channels/${e.channel_id}/sources`,e,n)).data}async getSources(e){let n=await this._requestOptions();return (await get(`${this.endpoint}/channels/${e}/sources`,n)).data}async _requestOptions(){let e=typeof this.accessToken=="string"?this.accessToken:await this.accessToken.getToken(),n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),{headers:n}}};export{p as ChannelsClient};//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/utils.ts","../../src/client/client.ts"],"names":["convertFromChannelDTO","input","chain","chainIdBySlug","convertFromChannelsListDTO","ChannelsClient","endpoint","accessToken","id","requestOptions","resp","get","post","del","options","queryParams","queryString","url","channelId","params","put","token","headers"],"mappings":"+DAIO,SAASA,CAAAA,CAAsBC,EAA4B,CAChE,IAAMC,CAAAA,CAAQC,aAAAA,CAAcF,EAAM,KAAK,CAAA,CACvC,GAAI,CAACC,EAAO,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsBD,EAAM,KAAK,CAAA,CAAE,CAAA,CAC/D,OAAO,CACL,GAAGA,CAAAA,CACH,KAAA,CAAAC,CACF,CACF,CAEO,SAASE,CAAAA,CACdH,CAAAA,CACkB,CAClB,OAAO,CACL,G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,CAEA,MAAM,MAAA,CAAOI,CAAAA,CAAqD,CAChE,IAAML,CAAAA,CAAiB,MAAM,IAAA,CAAK,iBAAgB,CAC5CC,CAAAA,CAAO,MAAMU,GAAAA,CACjB,GAAG,IAAA,CAAK,QAAQ,CAAA,UAAA,EAAaN,CAAAA,CAAQ,EAAE,CAAA,CAAA,CACvCA,CAAAA,CACAL,CACF,CAAA,CACA,OAAOT,CAAAA,CAAsBU,CAAAA,CAAK,IAAI,CACxC,CAEA,MAAM,aAAA,CACJI,CAAAA,CAC+B,CAC/B,IAAML,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,GAMlC,OAAA,CALa,MAAMW,GAAAA,CACjB,CAAA,EAAG,KAAK,QAAQ,CAAA,UAAA,EAAaN,CAAAA,CAAQ,UAAU,WAC/CA,CAAAA,CACAL,CACF,CAAA,EACY,IACd,CAEA,MAAM,UAAA,CAAWS,CAAAA,CAAkD,CACjE,IAAMT,CAAAA,CAAiB,MAAM,IAAA,CAAK,eAAA,GAKlC,OAAA,CAJa,MAAME,GAAAA,CACjB,CAAA,EAAG,KAAK,QAAQ,CAAA,UAAA,EAAaO,CAAS,CAAA,QAAA,CAAA,CACtCT,CACF,CAAA,EACY,IACd,CAEA,MAAM,iBAAwD,CAC5D,IAAMY,CAAAA,CACJ,OAAO,KAAK,WAAA,EAAgB,QAAA,CACxB,IAAA,CAAK,WAAA,CACL,MAAM,IAAA,CAAK,WAAA,CAAY,QAAA,EAAS,CAEhCC,EAAkC,CACtC,cAAA,CAAgB,kBAClB,CAAA,CAEA,OAAID,CAAAA,GACFC,CAAAA,CAAQ,aAAA,CAAgB,CAAA,OAAA,EAAUD,CAAK,CAAA,CAAA,CAAA,CAGlC,CAAE,OAAA,CAAAC,CAAQ,CACnB,CACF","file":"index.mjs","sourcesContent":["import { API, Channel } from \"@liberfi.io/types\";\nimport { chainIdBySlug } from \"@liberfi.io/utils\";\nimport { ChannelDTO, ChannelsListDTO } from \"./types\";\n\nexport function convertFromChannelDTO(input: ChannelDTO): Channel {\n const chain = chainIdBySlug(input.chain);\n if (!chain) throw new Error(`Unsupported chain: ${input.chain}`);\n return {\n ...input,\n chain,\n };\n}\n\nexport function convertFromChannelsListDTO(\n input: ChannelsListDTO,\n): API.ChannelsList {\n return {\n ...input,\n list: input.list.map(convertFromChannelDTO),\n };\n}\n","import { API, ChannelSource } from \"@liberfi.io/types\";\nimport { Channel } from \"@liberfi.io/types\";\nimport { del, get, post, put } from \"@liberfi.io/utils\";\nimport {\n ChannelEventsListResponse,\n ChannelResponse,\n ChannelsListResponse,\n ChannelSourcesResponse,\n SubscribeResponse,\n UnsubscribeResponse,\n} from \"./types\";\nimport { convertFromChannelDTO, convertFromChannelsListDTO } from \"./utils\";\n\nexport interface ChannelsClientOptions {\n endpoint: string;\n accessToken:\n | string\n | {\n getToken(): Promise<string | undefined | null>;\n };\n}\n\nexport class ChannelsClient implements API.IChannelsClient {\n private readonly endpoint: string;\n private readonly accessToken: ChannelsClientOptions[\"accessToken\"];\n\n constructor({ endpoint, accessToken }: ChannelsClientOptions) {\n this.endpoint = endpoint;\n this.accessToken = accessToken;\n }\n\n async get(id: string): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelResponse>(\n `${this.endpoint}/channels/${id}`,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async subscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await post<SubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n { notification_enabled: true },\n requestOptions,\n );\n }\n\n async unsubscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await del<UnsubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n requestOptions,\n );\n }\n\n async getChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getSubscribedChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/subscribed${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getMyChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/my${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getChannelEvents(\n channelId: string,\n options?: API.ListChannelEventsOptions,\n ): Promise<API.ChannelEventsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.limit) {\n queryParams.set(\"limit\", options.limit.toString());\n }\n if (options?.next_page) {\n queryParams.set(\"next_page\", options.next_page.toString());\n }\n if (options?.timestamp) {\n queryParams.set(\"timestamp\", options.timestamp.toString());\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/${channelId}/events${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelEventsListResponse>(url, requestOptions);\n return resp.data;\n }\n\n async create(params: API.CreateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await post<ChannelResponse>(\n `${this.endpoint}/channels`,\n params,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async update(options: API.UpdateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelResponse>(\n `${this.endpoint}/channels/${options.id}`,\n options,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async updateSources(\n options: API.UpdateChannelSourcesOptions,\n ): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${options.channel_id}/sources`,\n options,\n requestOptions,\n );\n return resp.data;\n }\n\n async getSources(channelId: string): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${channelId}/sources`,\n requestOptions,\n );\n return resp.data;\n }\n\n async _requestOptions(): Promise<Omit<RequestInit, \"method\">> {\n const token =\n typeof this.accessToken === \"string\"\n ? this.accessToken\n : await this.accessToken.getToken();\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return { headers };\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/client/utils.ts","../../src/client/client.ts"],"names":["convertFromChannelDTO","input","chain","chainIdBySlug","convertFromChannelsListDTO","ChannelsClient","endpoint","accessToken","id","requestOptions","resp","get","post","del","options","queryParams","queryString","url","channelId","params","put","token","headers"],"mappings":"+DAIO,SAASA,EAAsBC,CAAAA,CAA4B,CAChE,IAAMC,CAAAA,CAAQC,cAAcF,CAAAA,CAAM,KAAK,CAAA,CACvC,GAAI,CAACC,CAAAA,CAAO,MAAM,IAAI,KAAA,CAAM,sBAAsBD,CAAAA,CAAM,KAAK,CAAA,CAAE,CAAA,CAC/D,OAAO,CACL,GAAGA,CAAAA,CACH,KAAA,CAAAC,CACF,CACF,CAEO,SAASE,CAAAA,CACdH,EACkB,CAClB,OAAO,CACL,GAAGA,EACH,IAAA,CAAMA,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAID,CAAqB,CAC5C,CACF,CCEO,IAAMK,EAAN,KAAoD,CACxC,QAAA,CACA,WAAA,CAEjB,YAAY,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAY,CAAA,CAA0B,CAC5D,IAAA,CAAK,QAAA,CAAWD,EAChB,IAAA,CAAK,WAAA,CAAcC,EACrB,CAEA,MAAM,GAAA,CAAIC,CAAAA,CAA8B,CACtC,IAAMC,EAAiB,MAAM,IAAA,CAAK,eAAA,EAAgB,CAC5CC,EAAO,MAAMC,GAAAA,CACjB,CAAA,EAAG,IAAA,CAAK,QAAQ,CAAA,UAAA,EAAaH,CAAE,CAAA,CAAA,CAC/BC,CACF,EACA,OAAOT,CAAAA,CAAsBU,CAAAA,CAAK,IAAI,CACxC,CAEA,MAAM,SAAA,CAAUF,CAAAA,CAA2B,CACzC,IAAMC,CAAAA,CAAiB,MAAM,IAAA,CAAK,iBAAgB,CAClD,MAAMG,IAAAA,CACJ,CAAA,EAAG,KAAK,QAAQ,CAAA,UAAA,EAAaJ,CAAE,CAAA,UAAA,CAAA,CAC/B,CAAE,oBAAA,CAAsB,IAAK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MY,CAAAA,CACJ,OAAO,KAAK,WAAA,EAAgB,QAAA,CACxB,IAAA,CAAK,WAAA,CACL,MAAM,IAAA,CAAK,WAAA,CAAY,QAAA,EAAS,CAEhCC,EAAkC,CACtC,cAAA,CAAgB,kBAClB,CAAA,CAEA,OAAID,CAAAA,GACFC,CAAAA,CAAQ,aAAA,CAAgB,CAAA,OAAA,EAAUD,CAAK,CAAA,CAAA,CAAA,CAGlC,CAAE,OAAA,CAAAC,CAAQ,CACnB,CACF","file":"index.mjs","sourcesContent":["import { API, Channel } from \"@liberfi.io/types\";\nimport { chainIdBySlug } from \"@liberfi.io/utils\";\nimport { ChannelDTO, ChannelsListDTO } from \"./types\";\n\nexport function convertFromChannelDTO(input: ChannelDTO): Channel {\n const chain = chainIdBySlug(input.chain);\n if (!chain) throw new Error(`Unsupported chain: ${input.chain}`);\n return {\n ...input,\n chain,\n };\n}\n\nexport function convertFromChannelsListDTO(\n input: ChannelsListDTO,\n): API.ChannelsList {\n return {\n ...input,\n list: input.list.map(convertFromChannelDTO),\n };\n}\n","import { API, ChannelSource } from \"@liberfi.io/types\";\nimport { Channel } from \"@liberfi.io/types\";\nimport { del, get, post, put } from \"@liberfi.io/utils\";\nimport {\n ChannelEventsListResponse,\n ChannelResponse,\n ChannelsListResponse,\n ChannelSourcesResponse,\n SubscribeResponse,\n UnsubscribeResponse,\n} from \"./types\";\nimport { convertFromChannelDTO, convertFromChannelsListDTO } from \"./utils\";\n\nexport interface ChannelsClientOptions {\n endpoint: string;\n accessToken:\n | string\n | {\n getToken(): Promise<string | undefined | null>;\n };\n}\n\nexport class ChannelsClient implements API.IChannelsClient {\n private readonly endpoint: string;\n private readonly accessToken: ChannelsClientOptions[\"accessToken\"];\n\n constructor({ endpoint, accessToken }: ChannelsClientOptions) {\n this.endpoint = endpoint;\n this.accessToken = accessToken;\n }\n\n async get(id: string): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelResponse>(\n `${this.endpoint}/channels/${id}`,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async subscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await post<SubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n { notification_enabled: true },\n requestOptions,\n );\n }\n\n async unsubscribe(id: string): Promise<void> {\n const requestOptions = await this._requestOptions();\n await del<UnsubscribeResponse>(\n `${this.endpoint}/channels/${id}/subscribe`,\n requestOptions,\n );\n }\n\n async getChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getSubscribedChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/subscribed${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getMyChannels(\n options?: API.ListChannelsOptions,\n ): Promise<API.ChannelsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.chain) {\n queryParams.set(\"chain\", options.chain);\n }\n if (options?.page) {\n queryParams.set(\"page\", options.page.toString());\n }\n if (options?.size) {\n queryParams.set(\"size\", options.size.toString());\n }\n if (options?.search) {\n queryParams.set(\"search\", options.search);\n }\n if (options?.sort) {\n queryParams.set(\"sort\", options.sort);\n }\n if (options?.order) {\n queryParams.set(\"order\", options.order);\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/my${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelsListResponse>(url, requestOptions);\n return convertFromChannelsListDTO(resp.data);\n }\n\n async getChannelEvents(\n channelId: string,\n options?: API.ListChannelEventsOptions,\n ): Promise<API.ChannelEventsList> {\n const requestOptions = await this._requestOptions();\n const queryParams = new URLSearchParams();\n if (options?.limit) {\n queryParams.set(\"limit\", options.limit.toString());\n }\n if (options?.next_page) {\n queryParams.set(\"next_page\", options.next_page.toString());\n }\n if (options?.timestamp) {\n queryParams.set(\"timestamp\", options.timestamp.toString());\n }\n const queryString = queryParams.toString();\n const url = `${this.endpoint}/channels/${channelId}/events${queryString ? `?${queryString}` : \"\"}`;\n const resp = await get<ChannelEventsListResponse>(url, requestOptions);\n return resp;\n }\n\n async create(params: API.CreateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await post<ChannelResponse>(\n `${this.endpoint}/channels`,\n params,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async update(options: API.UpdateChannelOptions): Promise<Channel> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelResponse>(\n `${this.endpoint}/channels/${options.id}`,\n options,\n requestOptions,\n );\n return convertFromChannelDTO(resp.data);\n }\n\n async updateSources(\n options: API.UpdateChannelSourcesOptions,\n ): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await put<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${options.channel_id}/sources`,\n options,\n requestOptions,\n );\n return resp.data;\n }\n\n async getSources(channelId: string): Promise<Array<ChannelSource>> {\n const requestOptions = await this._requestOptions();\n const resp = await get<ChannelSourcesResponse>(\n `${this.endpoint}/channels/${channelId}/sources`,\n requestOptions,\n );\n return resp.data;\n }\n\n async _requestOptions(): Promise<Omit<RequestInit, \"method\">> {\n const token =\n typeof this.accessToken === \"string\"\n ? this.accessToken\n : await this.accessToken.getToken();\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return { headers };\n }\n}\n"]}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { z } from '@liberfi.io/ui';
3
3
  import * as _liberfi_io_types from '@liberfi.io/types';
4
- import { Channel as Channel$1, ChannelSource, API, IChannelsClient, Chain } from '@liberfi.io/types';
4
+ import { Channel, ChannelSource, API, IChannelsClient, Chain, ChannelEvent, Token } from '@liberfi.io/types';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
- import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
6
+ import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, useInfiniteQuery, UseMutationOptions } from '@tanstack/react-query';
7
7
  import * as react from 'react';
8
8
  import { PropsWithChildren } from 'react';
9
9
 
@@ -42,7 +42,7 @@ type BaseFormUIProps = {
42
42
  declare function BaseFormUI({ isSubmitting, onSubmit, defaultValues, submitLabel, }: BaseFormUIProps): react_jsx_runtime.JSX.Element;
43
43
 
44
44
  type CreateChannelWidgetProps = {
45
- onSuccess?: (channel: Channel$1) => void;
45
+ onSuccess?: (channel: Channel) => void;
46
46
  onError?: (error: unknown) => void;
47
47
  };
48
48
  declare function CreateChannelWidget({ onSuccess, onError, }: CreateChannelWidgetProps): react_jsx_runtime.JSX.Element;
@@ -67,7 +67,7 @@ declare function useUpdateBaseForm(id: string): {
67
67
  type UpdateChannelFormType = "base" | "wallets" | "social";
68
68
  interface UpdateChannelFormUIProps {
69
69
  /** channel */
70
- channel: Channel$1;
70
+ channel: Channel;
71
71
  /** default form type */
72
72
  type?: UpdateChannelFormType;
73
73
  /** base form default values */
@@ -95,7 +95,7 @@ type UpdateChannelWidgetProps = {
95
95
  };
96
96
  declare function UpdateChannelWidget({ id, type, }: UpdateChannelWidgetProps): react_jsx_runtime.JSX.Element;
97
97
 
98
- declare function useUpdateWalletsForm(id: string, channel?: Channel$1): {
98
+ declare function useUpdateWalletsForm(id: string, channel?: Channel): {
99
99
  isLoading: boolean;
100
100
  isSubmitting: boolean;
101
101
  wallets: _liberfi_io_types.ChannelSource[] | undefined;
@@ -104,7 +104,7 @@ declare function useUpdateWalletsForm(id: string, channel?: Channel$1): {
104
104
 
105
105
  type WalletsFormUIProps = {
106
106
  /** channel */
107
- channel: Channel$1;
107
+ channel: Channel;
108
108
  /** already added wallets */
109
109
  wallets?: Array<ChannelSource>;
110
110
  /** submit wallets (include both already added wallets & new added wallets) */
@@ -122,15 +122,15 @@ type WalletsListUIProps = {
122
122
  declare function WalletsListUI({ wallets, onSubmit, isSubmitting, }: WalletsListUIProps): react_jsx_runtime.JSX.Element;
123
123
 
124
124
  type SocialsFormUIProps = {
125
- channel: Channel$1;
125
+ channel: Channel;
126
126
  };
127
127
  declare function SocialsFormUI({ channel }: SocialsFormUIProps): react_jsx_runtime.JSX.Element;
128
128
 
129
129
  type ChannelsUIProps = {
130
- channels: Array<Channel$1>;
131
- onSelect?: (channel: Channel$1) => void;
132
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
133
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
130
+ channels: Array<Channel>;
131
+ onSelect?: (channel: Channel) => void;
132
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
133
+ customFooterActions?: (channel: Channel) => React.ReactNode;
134
134
  };
135
135
  declare function ChannelsUI({ channels, onSelect, customHeaderActions, customFooterActions, }: ChannelsUIProps): react_jsx_runtime.JSX.Element;
136
136
 
@@ -145,74 +145,75 @@ type ChannelsEmptyUIProps = {
145
145
  declare function ChannelsEmptyUI({ message }: ChannelsEmptyUIProps): react_jsx_runtime.JSX.Element;
146
146
 
147
147
  type TrendingChannelsWidgetProps = {
148
- onSelect?: (channel: Channel$1) => void;
149
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
150
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
148
+ onSelect?: (channel: Channel) => void;
149
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
150
+ customFooterActions?: (channel: Channel) => React.ReactNode;
151
151
  };
152
152
  declare function TrendingChannelsWidget({ onSelect, customHeaderActions, customFooterActions, }: TrendingChannelsWidgetProps): react_jsx_runtime.JSX.Element;
153
153
 
154
154
  declare const useTrendingChannels: () => _tanstack_react_query.UseQueryResult<_liberfi_io_types.ChannelsList, Error>;
155
155
 
156
156
  type SubscribedChannelsWidgetProps = {
157
- onSelect?: (channel: Channel$1) => void;
158
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
159
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
157
+ onSelect?: (channel: Channel) => void;
158
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
159
+ customFooterActions?: (channel: Channel) => React.ReactNode;
160
160
  };
161
161
  declare function SubscribedChannelsWidget({ onSelect, customHeaderActions, customFooterActions, }: SubscribedChannelsWidgetProps): react_jsx_runtime.JSX.Element;
162
162
 
163
163
  declare const useSubscribedChannels: () => _tanstack_react_query.UseQueryResult<_liberfi_io_types.ChannelsList, Error>;
164
164
 
165
165
  type MyChannelsWidgetProps = {
166
- onSelect?: (channel: Channel$1) => void;
167
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
168
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
166
+ onSelect?: (channel: Channel) => void;
167
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
168
+ customFooterActions?: (channel: Channel) => React.ReactNode;
169
169
  };
170
170
  declare function MyChannelsWidget({ onSelect, customHeaderActions, customFooterActions, }: MyChannelsWidgetProps): react_jsx_runtime.JSX.Element;
171
171
 
172
172
  declare const useMyChannels: () => _tanstack_react_query.UseQueryResult<_liberfi_io_types.ChannelsList, Error>;
173
173
 
174
174
  type ChannelAttributesProps = {
175
- channel: Channel$1;
175
+ channel: Channel;
176
176
  };
177
177
  declare function ChannelAttributes({ channel }: ChannelAttributesProps): react_jsx_runtime.JSX.Element;
178
178
 
179
179
  type ChannelBaseInfoProps = {
180
- channel: Channel$1;
180
+ channel: Channel;
181
181
  customActions?: React.ReactNode;
182
182
  };
183
183
  declare function ChannelBaseInfo({ channel, customActions, }: ChannelBaseInfoProps): react_jsx_runtime.JSX.Element;
184
184
 
185
185
  type ChannelEditButtonProps = {
186
- channel: Channel$1;
187
- onEdit?: (channel: Channel$1) => void;
186
+ channel: Channel;
187
+ onEdit?: (channel: Channel) => void;
188
188
  };
189
189
  declare function ChannelEditButton({ channel, onEdit }: ChannelEditButtonProps): react_jsx_runtime.JSX.Element;
190
190
 
191
191
  type ChannelStatsProps = {
192
- channel: Channel$1;
192
+ channel: Channel;
193
193
  };
194
194
  declare function ChannelStats({ channel }: ChannelStatsProps): react_jsx_runtime.JSX.Element;
195
195
 
196
196
  type ChannelSubscribeButtonProps = {
197
- channel: Channel$1;
198
- onSubscribeSuccess?: (channel: Channel$1) => void;
199
- onUnsubscribeSuccess?: (channel: Channel$1) => void;
200
- onSubscribeError?: (channel: Channel$1, error: unknown) => void;
201
- onUnsubscribeError?: (channel: Channel$1, error: unknown) => void;
197
+ channel: Channel;
198
+ onSubscribeSuccess?: (channel: Channel) => void;
199
+ onUnsubscribeSuccess?: (channel: Channel) => void;
200
+ onSubscribeError?: (channel: Channel, error: unknown) => void;
201
+ onUnsubscribeError?: (channel: Channel, error: unknown) => void;
202
202
  };
203
203
  declare function ChannelSubscribeButton({ channel, onSubscribeSuccess, onUnsubscribeSuccess, onSubscribeError, onUnsubscribeError, }: ChannelSubscribeButtonProps): react_jsx_runtime.JSX.Element;
204
204
 
205
205
  type ChannelDetailUIProps = {
206
- channel: Channel$1;
206
+ channel: Channel;
207
207
  headerActions?: React.ReactNode;
208
208
  footerActions?: React.ReactNode;
209
+ className?: string;
209
210
  };
210
- declare function ChannelDetailUI({ channel, headerActions, footerActions, }: ChannelDetailUIProps): react_jsx_runtime.JSX.Element;
211
+ declare function ChannelDetailUI({ channel, headerActions, footerActions, className, }: ChannelDetailUIProps): react_jsx_runtime.JSX.Element;
211
212
 
212
213
  type ChannelDetailWidgetProps = {
213
214
  id: string;
214
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
215
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
215
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
216
+ customFooterActions?: (channel: Channel) => React.ReactNode;
216
217
  };
217
218
  declare function ChannelDetailWidget({ id, customHeaderActions, customFooterActions, }: ChannelDetailWidgetProps): react_jsx_runtime.JSX.Element;
218
219
 
@@ -220,85 +221,19 @@ declare const useChannelDetail: (id: string) => _tanstack_react_query.UseQueryRe
220
221
 
221
222
  type ChannelHomePageProps = {
222
223
  onCreateChannel?: () => void;
223
- onSelectChannel?: (channel: Channel$1) => void;
224
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
225
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
224
+ onSelectChannel?: (channel: Channel) => void;
225
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
226
+ customFooterActions?: (channel: Channel) => React.ReactNode;
226
227
  };
227
228
  declare function ChannelsHomePage({ onCreateChannel, onSelectChannel, customHeaderActions, customFooterActions, }: ChannelHomePageProps): react_jsx_runtime.JSX.Element;
228
229
 
229
230
  type ChannelDetailPageProps = {
230
231
  id: string;
231
- customHeaderActions?: (channel: Channel$1) => React.ReactNode;
232
- customFooterActions?: (channel: Channel$1) => React.ReactNode;
232
+ customHeaderActions?: (channel: Channel) => React.ReactNode;
233
+ customFooterActions?: (channel: Channel) => React.ReactNode;
233
234
  };
234
235
  declare function ChannelsDetailPage({ id, customHeaderActions, customFooterActions, }: ChannelDetailPageProps): react_jsx_runtime.JSX.Element;
235
236
 
236
- interface Channel {
237
- id: string;
238
- imageUrl: string;
239
- name: string;
240
- description: string;
241
- createdAt: string;
242
- people: number;
243
- volume: number;
244
- followers: number;
245
- createdBy: string;
246
- timeAgo: number;
247
- socials: Socials;
248
- dex: ChannelDex;
249
- }
250
- interface Trading {
251
- id: string;
252
- date: number;
253
- channel: Channel;
254
- address: string;
255
- token: {
256
- symbol: string;
257
- image: string;
258
- address: string;
259
- chainIcon: string;
260
- };
261
- mc: number;
262
- amount: number;
263
- type: "buy" | "sell";
264
- }
265
- interface Socials {
266
- telegram: string;
267
- discord: string;
268
- }
269
- interface ChannelDex {
270
- fromToken: ChannelDexToken;
271
- toToken: ChannelDexToken;
272
- txs7d: ChannelDexTxs;
273
- pnl7d: ChannelDexPnl;
274
- wr7d: ChannelDexWr;
275
- }
276
- interface ChannelDexToken {
277
- name: string;
278
- image: string;
279
- }
280
- interface ChannelDexTxs {
281
- total: number;
282
- bullish: number;
283
- bearish: number;
284
- }
285
- interface ChannelDexPnl {
286
- total: number;
287
- }
288
- interface ChannelDexWr {
289
- total: number;
290
- }
291
-
292
- type Props = {
293
- trading: Trading[];
294
- onBuy: (item: Trading) => void;
295
- };
296
- declare function TradingUI({ trading, onBuy }: Props): react_jsx_runtime.JSX.Element;
297
-
298
- declare function TradingWidget(): react_jsx_runtime.JSX.Element;
299
-
300
- declare const useTrading: () => Trading[];
301
-
302
237
  interface ChannelsContextValue {
303
238
  client: API.IChannelsClient;
304
239
  }
@@ -314,9 +249,12 @@ declare function channelEventsQueryKey(channelId: string, params: UseChannelEven
314
249
  declare function fetchChannelEvents(client: IChannelsClient, channelId: string, params: UseChannelEventsQueryParams): Promise<API.ChannelEventsList>;
315
250
  declare function useChannelEventsQuery(channelId: string, params?: UseChannelEventsQueryParams, options?: Omit<UseQueryOptions<API.ChannelEventsList, Error, API.ChannelEventsList, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<_liberfi_io_types.ChannelEventsList, Error>;
316
251
 
252
+ declare function channelEventsInfiniteQueryKey(channelId: string): string[];
253
+ declare function useChannelEventsInfiniteQuery(channelId: string, params?: UseChannelEventsQueryParams, options?: Omit<UseInfiniteQueryOptions<API.ChannelEventsList, Error, InfiniteData<API.ChannelEventsList>, string[], UseChannelEventsQueryParams>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">): ReturnType<typeof useInfiniteQuery<API.ChannelEventsList, Error>>;
254
+
317
255
  declare function channelQueryKey(id: string): string[];
318
- declare function fetchChannel(client: IChannelsClient, id: string): Promise<Channel$1>;
319
- declare function useChannelQuery(id: string, options?: Omit<UseQueryOptions<Channel$1, Error, Channel$1, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<Channel$1, Error>;
256
+ declare function fetchChannel(client: IChannelsClient, id: string): Promise<Channel>;
257
+ declare function useChannelQuery(id: string, options?: Omit<UseQueryOptions<Channel, Error, Channel, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<Channel, Error>;
320
258
 
321
259
  declare function useChannelsContext(): ChannelsContextValue;
322
260
 
@@ -336,8 +274,8 @@ declare function useChannelSourcesQuery(channelId: string, options?: Omit<UseQue
336
274
  interface UseCreateChannelMutationParams extends Omit<API.CreateChannelOptions, "chain"> {
337
275
  chain: Chain;
338
276
  }
339
- declare function createChannel(client: IChannelsClient, params: UseCreateChannelMutationParams): Promise<Channel$1>;
340
- declare function useCreateChannelMutation(options?: Omit<UseMutationOptions<Channel$1, Error, UseCreateChannelMutationParams, string[]>, "mutationFn">): _tanstack_react_query.UseMutationResult<Channel$1, Error, UseCreateChannelMutationParams, string[]>;
277
+ declare function createChannel(client: IChannelsClient, params: UseCreateChannelMutationParams): Promise<Channel>;
278
+ declare function useCreateChannelMutation(options?: Omit<UseMutationOptions<Channel, Error, UseCreateChannelMutationParams, string[]>, "mutationFn">): _tanstack_react_query.UseMutationResult<Channel, Error, UseCreateChannelMutationParams, string[]>;
341
279
 
342
280
  interface UseMyChannelsListQueryParams extends Omit<API.ListChannelsOptions, "chain"> {
343
281
  chain?: Chain;
@@ -362,8 +300,8 @@ declare function useUnsubscribeChannelMutation(options?: Omit<UseMutationOptions
362
300
  interface UseUpdateChannelMutationParams extends Omit<API.UpdateChannelOptions, "chain"> {
363
301
  chain?: Chain;
364
302
  }
365
- declare function updateChannel(client: IChannelsClient, params: UseUpdateChannelMutationParams): Promise<Channel$1>;
366
- declare function useUpdateChannelMutation(options?: Omit<UseMutationOptions<Channel$1, Error, UseUpdateChannelMutationParams, string[]>, "mutationFn">): _tanstack_react_query.UseMutationResult<Channel$1, Error, UseUpdateChannelMutationParams, string[]>;
303
+ declare function updateChannel(client: IChannelsClient, params: UseUpdateChannelMutationParams): Promise<Channel>;
304
+ declare function useUpdateChannelMutation(options?: Omit<UseMutationOptions<Channel, Error, UseUpdateChannelMutationParams, string[]>, "mutationFn">): _tanstack_react_query.UseMutationResult<Channel, Error, UseUpdateChannelMutationParams, string[]>;
367
305
 
368
306
  type UseUpdateChannelSourcesMutationParams = API.UpdateChannelSourcesOptions;
369
307
  declare function updateChannelSources(client: IChannelsClient, params: UseUpdateChannelSourcesMutationParams): Promise<Array<ChannelSource>>;
@@ -373,4 +311,10 @@ declare const useUpload: () => (file: File) => Promise<string>;
373
311
 
374
312
  declare function parseWalletsText(value: string): Array<Partial<WalletValues>>;
375
313
 
376
- export { BaseFormUI, type BaseFormUIProps, ChannelAttributes, type ChannelAttributesProps, ChannelBaseInfo, type ChannelBaseInfoProps, type ChannelDetailPageProps, ChannelDetailUI, type ChannelDetailUIProps, ChannelDetailWidget, type ChannelDetailWidgetProps, ChannelEditButton, type ChannelEditButtonProps, type ChannelHomePageProps, ChannelStats, type ChannelStatsProps, ChannelSubscribeButton, type ChannelSubscribeButtonProps, ChannelsContext, type ChannelsContextValue, ChannelsDetailPage, ChannelsEmptyUI, type ChannelsEmptyUIProps, ChannelsHomePage, ChannelsProvider, type ChannelsProviderProps, ChannelsSkeletonUI, type ChannelsSkeletonUIProps, ChannelsUI, type ChannelsUIProps, CreateChannelWidget, type CreateChannelWidgetProps, MyChannelsWidget, type MyChannelsWidgetProps, SocialsFormUI, type SocialsFormUIProps, SubscribedChannelsWidget, type SubscribedChannelsWidgetProps, TradingUI, TradingWidget, TrendingChannelsWidget, type TrendingChannelsWidgetProps, type UpdateChannelFormType, UpdateChannelFormUI, type UpdateChannelFormUIProps, UpdateChannelWidget, type UpdateChannelWidgetProps, type UseChannelEventsQueryParams, type UseChannelsListQueryParams, type UseCreateChannelMutationParams, type UseMyChannelsListQueryParams, type UseSubscribedChannelsListQueryParams, type UseUpdateChannelMutationParams, type UseUpdateChannelSourcesMutationParams, WalletsFormUI, type WalletsFormUIProps, WalletsListUI, type WalletsListUIProps, channelEventsQueryKey, channelQueryKey, channelSourcesQueryKey, channelsListQueryKey, createChannel, fetchChannel, fetchChannelEvents, fetchChannelSources, fetchChannelsList, fetchMyChannelsList, fetchSubscribedChannelsList, myChannelsListQueryKey, parseWalletsText, subscribeChannel, subscribedChannelsListQueryKey, unsubscribeChannel, updateChannel, updateChannelSources, useChannelDetail, useChannelEventsQuery, useChannelQuery, useChannelSourcesQuery, useChannelsClient, useChannelsContext, useChannelsListQuery, useCreateChannelMutation, useMyChannels, useMyChannelsListQuery, useSubscribeChannelMutation, useSubscribedChannels, useSubscribedChannelsListQuery, useTrading, useTrendingChannels, useUnsubscribeChannelMutation, useUpdateBaseForm, useUpdateChannelMutation, useUpdateChannelSourcesMutation, useUpdateWalletsForm, useUpload, _default as version };
314
+ type ChannelEventRowProps = {
315
+ event: ChannelEvent;
316
+ walletAliases?: Record<string, string | undefined>;
317
+ tokens?: Record<string, Token>;
318
+ };
319
+
320
+ export { BaseFormUI, type BaseFormUIProps, type BaseFormValues, ChannelAttributes, type ChannelAttributesProps, ChannelBaseInfo, type ChannelBaseInfoProps, type ChannelDetailPageProps, ChannelDetailUI, type ChannelDetailUIProps, ChannelDetailWidget, type ChannelDetailWidgetProps, ChannelEditButton, type ChannelEditButtonProps, type ChannelEventRowProps, type ChannelHomePageProps, ChannelStats, type ChannelStatsProps, ChannelSubscribeButton, type ChannelSubscribeButtonProps, ChannelsContext, type ChannelsContextValue, ChannelsDetailPage, ChannelsEmptyUI, type ChannelsEmptyUIProps, ChannelsHomePage, ChannelsProvider, type ChannelsProviderProps, ChannelsSkeletonUI, type ChannelsSkeletonUIProps, ChannelsUI, type ChannelsUIProps, CreateChannelWidget, type CreateChannelWidgetProps, MyChannelsWidget, type MyChannelsWidgetProps, SocialsFormUI, type SocialsFormUIProps, SubscribedChannelsWidget, type SubscribedChannelsWidgetProps, TrendingChannelsWidget, type TrendingChannelsWidgetProps, type UpdateChannelFormType, UpdateChannelFormUI, type UpdateChannelFormUIProps, UpdateChannelWidget, type UpdateChannelWidgetProps, type UseChannelEventsQueryParams, type UseChannelsListQueryParams, type UseCreateChannelMutationParams, type UseMyChannelsListQueryParams, type UseSubscribedChannelsListQueryParams, type UseUpdateChannelMutationParams, type UseUpdateChannelSourcesMutationParams, type WalletValues, WalletsFormUI, type WalletsFormUIProps, type WalletsFormValues, WalletsListUI, type WalletsListUIProps, baseFormSchema, channelEventsInfiniteQueryKey, channelEventsQueryKey, channelQueryKey, channelSourcesQueryKey, channelsListQueryKey, createChannel, fetchChannel, fetchChannelEvents, fetchChannelSources, fetchChannelsList, fetchMyChannelsList, fetchSubscribedChannelsList, myChannelsListQueryKey, parseWalletsText, subscribeChannel, subscribedChannelsListQueryKey, unsubscribeChannel, updateChannel, updateChannelSources, useChannelDetail, useChannelEventsInfiniteQuery, useChannelEventsQuery, useChannelQuery, useChannelSourcesQuery, useChannelsClient, useChannelsContext, useChannelsListQuery, useCreateChannelMutation, useMyChannels, useMyChannelsListQuery, useSubscribeChannelMutation, useSubscribedChannels, useSubscribedChannelsListQuery, useTrendingChannels, useUnsubscribeChannelMutation, useUpdateBaseForm, useUpdateChannelMutation, useUpdateChannelSourcesMutation, useUpdateWalletsForm, useUpload, _default as version, walletSchema, walletsFormSchema };