Some checks failed
morphit-release / Build + publish release tarball (push) Has been cancelled
272 lines
15 KiB
TypeScript
272 lines
15 KiB
TypeScript
/**
|
||
* @file Blurt Nexus (A.k.a. bridge) helpers.
|
||
* @author BeBlurt <https://beblurt.com/@beblurt>
|
||
* @description adaptation from Johan Nordberg <code@johan-nordberg.com> Database API helpers
|
||
* @license
|
||
* Copyright (c) 2022 BeBlurt. All Rights Reserved.
|
||
*
|
||
* Redistribution and use in source and binary forms, with or without modification,
|
||
* are permitted provided that the following conditions are met:
|
||
*
|
||
* 1. Redistribution of source code must retain the above copyright notice, this
|
||
* list of conditions and the following disclaimer.
|
||
*
|
||
* 2. Redistribution in binary form must reproduce the above copyright notice,
|
||
* this list of conditions and the following disclaimer in the documentation
|
||
* and/or other materials provided with the distribution.
|
||
*
|
||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||
* may be used to endorse or promote products derived from this software without
|
||
* specific prior written permission.
|
||
*
|
||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*
|
||
* You acknowledge that this software is not designed, licensed or intended for use
|
||
* in the design, construction, operation or maintenance of any military facility.
|
||
*/
|
||
import { NexusAccountNotifications, NexusAccountPostSort, NexusAccountPostsQuery, NexusCommunity, NexusCommunityContext, NexusCommunityExtended, NexusCommunityQuery, NexusCommunityRole, NexusCommunitySort, NexusCommunitySubscriber, NexusCommunitySubscription, NexusCommunitySummary, NexusCommunityTitle, NexusListCommunitiesQuery, NexusNotificationQuery, NexusPayoutStats, NexusPost, NexusPostHeader, NexusPostNotificationQuery, NexusPostQuery, NexusProfile, NexusProfileQuery, NexusRankedPostsQuery, NexusReferralAccountsCount, NexusReferralAccountsCountQuery, NexusReferralAccountsQuery, NexusSortGetRankedPost, NexusUnreadNotifications, NexusUnreadNotificationsQuery, ReferralAccount } from '../chain/nexus';
|
||
import { Client } from '../client';
|
||
export declare class Nexus {
|
||
readonly client: Client;
|
||
constructor(client: Client);
|
||
/**
|
||
* Convenience for calling Nexus/Bridge RPC methods directly.
|
||
*
|
||
* Backing JSON-RPC API namespace: `bridge`.
|
||
* Nexus responses are indexed Layer 2 views, not Layer 1 consensus objects.
|
||
*/
|
||
call(method: string, params?: any[] | {
|
||
[key: string]: any;
|
||
}): Promise<any>;
|
||
/**
|
||
* Return array of account notification objects for the account passed.
|
||
*
|
||
* Returned values for type:
|
||
* - new_community - a new community was created
|
||
* - set_role - mod/admin adds a role to an account
|
||
* - set_props - properties set for a community
|
||
* - set_label - a title/badge/label has been set for an account
|
||
* - mute_post - a post has been muted, with a reason
|
||
* - unmute_post - a post has been unmuted, with a reason
|
||
* - pin_post - a post has been pinned
|
||
* - unpin_post - a post has been unpinned
|
||
* - flag_post - a post has been flagged by a member, with a reason
|
||
* - error - provides feedback to developers for ops that cannot be interpreted
|
||
* - subscribe - an account has subscribed to a community
|
||
* - reply - a post has been replied to
|
||
* - reblog - a post has been reblogged/reblogged
|
||
* - follow - an account has followed another account
|
||
* - mention - author mentions an account
|
||
* - vote - voter votes for an author
|
||
*
|
||
* The score value is based on the originating account’s rank.
|
||
* @param account The account to fetch.
|
||
* @param min_score Minimum score of notification, default: 25 [optional].
|
||
* @param last_id Last notification ID, paging mechanism [optional].
|
||
* @param limit Number of results, default: 100 [optional].
|
||
*/
|
||
accountNotifications(account: string, min_score?: number, last_id?: number | null, limit?: number): Promise<NexusAccountNotifications[]>;
|
||
accountNotifications(options: NexusNotificationQuery): Promise<NexusAccountNotifications[]>;
|
||
/**
|
||
* Return a list of posts related to a given account.
|
||
* @param sort Values accepted:
|
||
* - blog: top posts authored by given account (excluding posts to communities - unless explicitely reblogged) plus reblogs ranked by creation/reblog time.
|
||
* - feed: top posts from blogs of accounts that given account is following ranked by creation/reblog time, not older than last month.
|
||
* - posts: top posts authored by given account, newer first comments - replies authored by given account, newer first.
|
||
* - comments:
|
||
* - replies: replies to posts of given account, newer first.
|
||
* - payout: all posts authored by given account that were not yet cashed out.
|
||
* @param account The account to fetch.
|
||
* @param start_author Name of author to start from, used for paging. Should be used in conjunction with `start_permlink`.
|
||
* @param start_permlink Permalink of post to start from, used for paging. Should be used in conjunction with `start_author`.
|
||
* @param limit Number of results, default: 20, max 100.
|
||
* @param observer A valid account [optional].
|
||
*/
|
||
getAccountPosts(sort: NexusAccountPostSort, account: string, start_author?: string | null, start_permlink?: string | null, limit?: number, observer?: string | null): Promise<NexusPost[]>;
|
||
getAccountPosts(options: NexusAccountPostsQuery): Promise<NexusPost[]>;
|
||
/**
|
||
* Return the lightweight Nexus post header for a post, or `null` when missing.
|
||
* Backing JSON-RPC method: `bridge.get_post_header`.
|
||
*/
|
||
getPostHeader(author: string, permlink: string): Promise<NexusPostHeader | null>;
|
||
/**
|
||
* Normalize a condenser-style post object into the Nexus bridge post shape.
|
||
* Backing JSON-RPC method: `bridge.normalize_post`.
|
||
*/
|
||
normalizePost(post: {
|
||
[key: string]: any;
|
||
}): Promise<NexusPost>;
|
||
/**
|
||
* Return a Nexus community object.
|
||
*
|
||
* Backing JSON-RPC method: `bridge.get_community`.
|
||
* Includes community metadata and leadership information. When `observer` is
|
||
* provided, Nexus may also include observer-specific subscription, title and
|
||
* role context.
|
||
*
|
||
* @param name Community account/category name.
|
||
* @param observer Optional observer account for viewer-specific context.
|
||
*/
|
||
getCommunity(name: string, observer?: string | null): Promise<NexusCommunityExtended>;
|
||
getCommunity(options: NexusCommunityQuery): Promise<NexusCommunityExtended>;
|
||
/**
|
||
* For a community/account: returns role, title, subscribed state.
|
||
* @param name The community account concerned.
|
||
* @param account The account to fetch.
|
||
*/
|
||
getCommunityContext(name: string, account: string): Promise<NexusCommunityContext>;
|
||
/**
|
||
* Gives a flattened discussion tree starting at given post. Modified `get_state` thread implementation.
|
||
* Returns an Object whose key is "author/permlink".
|
||
*/
|
||
getDiscussion(author: string, permlink: string): Promise<{
|
||
[key: string]: NexusPost;
|
||
}>;
|
||
/**
|
||
* Get payout stats for building treemap.
|
||
* @param limit Number of result, default: 250 [optional].
|
||
*/
|
||
getPayoutStats(limit?: number): Promise<NexusPayoutStats>;
|
||
/**
|
||
* Return one Nexus post view.
|
||
*
|
||
* Backing JSON-RPC method: `bridge.get_post`.
|
||
* Use `client.condenser.getContent` when you need the Layer 1 content object
|
||
* instead of the Nexus indexed/social view.
|
||
*
|
||
* @param author Post author.
|
||
* @param permlink Post permlink.
|
||
* @param observer Optional observer account for viewer-specific context.
|
||
*/
|
||
getPost(author: string, permlink: string, observer?: string | null): Promise<NexusPost>;
|
||
getPost(options: NexusPostQuery): Promise<NexusPost>;
|
||
/**
|
||
* Returns a resume of a profile with metadata parsed.
|
||
*/
|
||
getProfile(account: string, observer?: string | null): Promise<NexusProfile>;
|
||
getProfile(options: NexusProfileQuery): Promise<NexusProfile>;
|
||
/**
|
||
* Query Nexus-ranked posts.
|
||
*
|
||
* Backing JSON-RPC method: `bridge.get_ranked_posts`.
|
||
* This is a discovery/indexing helper. If exact chain content matters, use
|
||
* the returned `author` and `permlink` with `client.condenser.getContent`.
|
||
*
|
||
* @param sort Sorting of results, valid options are: 'trending', 'hot', 'created', 'promoted', 'payout', 'payout_comments', 'muted'.
|
||
* @param start_author Name of author to start from, used for paging. Should be used in conjunction with `start_permlink` [optional].
|
||
* @param start_permlink Permalink of post to start from, used for paging. Should be used in conjunction with `start_author` [optional].
|
||
* @param limit Number of results, default: 20 [optional].
|
||
* @param tag Specify a Tag [optional].
|
||
* @param observer A valid account [optional].
|
||
*/
|
||
getRankedPosts(sort: NexusSortGetRankedPost, start_author?: string | null, start_permlink?: string | null, limit?: number, tag?: string | null, observer?: string | null): Promise<NexusPost[]>;
|
||
getRankedPosts(options: NexusRankedPostsQuery): Promise<NexusPost[]>;
|
||
/**
|
||
* Returns a lists of all communities `account` subscribes to, plus role and title in each.
|
||
* The content of a community `account` subscribes to is [community name, community title, role_id, title].
|
||
* @param account The account to fetch.
|
||
*/
|
||
listAllSubscriptions(account: string): Promise<NexusCommunitySubscription[]>;
|
||
/**
|
||
* Return a paged list of Nexus communities.
|
||
*
|
||
* Backing JSON-RPC method: `bridge.list_communities`.
|
||
* This is the safest way to discover community names before calling
|
||
* `getCommunity`.
|
||
*
|
||
* @param last Name of community, paging mechanism [optional].
|
||
* @param limit Number of listed communities, default: 100 [optional].
|
||
* @param query Filters against title and about community fields [optional].
|
||
* @param sort Sorting of results, default: rank [optional].
|
||
* - rank: sort by community rank.
|
||
* - new: sort by newest community.
|
||
* - subs: sort by subscriptions.
|
||
* @param observer A valid account [optional].
|
||
*/
|
||
listCommunities(last?: string | null, limit?: number, query?: string | null, sort?: NexusCommunitySort, observer?: string | null): Promise<NexusCommunity[]>;
|
||
listCommunities(options: NexusListCommunitiesQuery): Promise<NexusCommunity[]>;
|
||
/**
|
||
* Returns a list of community account-roles (anyone with non-guest status).
|
||
* The content of a community account-roles array is [community name, role_id, title].
|
||
* @param community Community category name (account).
|
||
* @param last Name of subscriber, paging mechanism [optional].
|
||
* @param limit limit Number of listed communities, default: 50 [optional].
|
||
*/
|
||
listCommunityRoles(community: string, last?: string | null, limit?: number): Promise<NexusCommunityRole[]>;
|
||
/**
|
||
* Returns community accounts with custom titles.
|
||
* Backing JSON-RPC method: `bridge.list_community_titles`.
|
||
*/
|
||
listCommunityTitles(community: string, last?: string | null, limit?: number): Promise<NexusCommunityTitle[]>;
|
||
/**
|
||
* Returns top communities as [community name, community title].
|
||
* Backing JSON-RPC method: `bridge.list_top_communities`.
|
||
*/
|
||
listTopCommunities(limit?: number): Promise<NexusCommunitySummary[]>;
|
||
/**
|
||
* Returns a list of communities by new subscriber count.
|
||
* The content of a community array is [community name, community title].
|
||
* @param limit Number of listed communities, default: 25 [optional].
|
||
* @deprecated Use the correctly spelled `listPopCommunities` alias. This historical misspelling remains supported for backward compatibility.
|
||
*/
|
||
listPopComunities(limit?: number): Promise<NexusCommunitySummary[]>;
|
||
/** Correctly spelled alias for `listPopComunities`. */
|
||
listPopCommunities(limit?: number): Promise<NexusCommunitySummary[]>;
|
||
/**
|
||
* Returns a list of subscribers for a given community.
|
||
* The content of a subscriber array is [account, role_id, title, created_at].
|
||
* @param community Community category name (account).
|
||
* @param last Last account, paging mechanism [optional].
|
||
* @param limit Number of results, default: 100 [optional].
|
||
*/
|
||
listSubscribers(community: string, last?: string | null, limit?: number): Promise<NexusCommunitySubscriber[]>;
|
||
/**
|
||
* Return top trending topics as [name, title] pairs.
|
||
* Backing JSON-RPC method: `bridge.get_trending_topics`.
|
||
*/
|
||
getTrendingTopics(limit?: number, observer?: string | null): Promise<NexusCommunitySummary[]>;
|
||
/**
|
||
* Load notifications for a specific post.
|
||
* @param author Name of author.
|
||
* @param permlink Permlink of post.
|
||
* @param min_score Minimum score of notification, default: 25 [optional].
|
||
* @param last_id Last notification ID, paging mechanism [optional].
|
||
* @param limit Number of results, default: 100 [optional].
|
||
*/
|
||
postNotifications(author: string, permlink: string, min_score?: number, last_id?: number | null, limit?: number): Promise<NexusAccountNotifications[]>;
|
||
postNotifications(options: NexusPostNotificationQuery): Promise<NexusAccountNotifications[]>;
|
||
/**
|
||
* Load notifications for a specific post.
|
||
* @param account The account to fetch.
|
||
* @param min_score Minimum score of notification, default: 25 [optional].
|
||
*/
|
||
unreadNotifications(account: string, min_score?: number): Promise<NexusUnreadNotifications>;
|
||
unreadNotifications(options: NexusUnreadNotificationsQuery): Promise<NexusUnreadNotifications>;
|
||
/**
|
||
* Get all accounts of a referrer/campaign.
|
||
* @param referrer The referrer account to fetch [optional].
|
||
* @param campaign_id The campaign id to fetch [optional].
|
||
* @param limit Number of results, default: 100 [optional].
|
||
* @param last_created_at Last creation date (DESC order), paging mechanism [optional].
|
||
*/
|
||
referralAccounts(referrer?: string | null, campaign_id?: string | null, limit?: number, last_created_at?: string | null): Promise<ReferralAccount[]>;
|
||
referralAccounts(options: NexusReferralAccountsQuery): Promise<ReferralAccount[]>;
|
||
/**
|
||
* Load notifications for a specific post.
|
||
* @param referrer The referrer account to fetch [optional].
|
||
* @param campaign_id The campaign id to fetch [optional].
|
||
* @param start_date start creation date, analytics mechanism [optional].
|
||
* @param end_date end creation date, analytics mechanism [optional].
|
||
*/
|
||
referralAccountsCount(referrer?: string | null, campaign_id?: string | null, start_date?: string | null, end_date?: string | null): Promise<NexusReferralAccountsCount>;
|
||
referralAccountsCount(options: NexusReferralAccountsCountQuery): Promise<NexusReferralAccountsCount>;
|
||
}
|