morphit/node_modules/@beblurt/dblurt/lib/content.d.ts

100 lines
4.3 KiB
TypeScript

import { CommentOperation, DeleteCommentOperation } from './chain/operation';
export declare const DEFAULT_CONTENT_TAG_LIMIT = 8;
export type CommentMetadataValue = string | number | boolean | null | CommentMetadataValue[] | {
[key: string]: CommentMetadataValue;
};
export type CommentMetadata = {
[key: string]: CommentMetadataValue;
};
export interface PermlinkNormalizationOptions {
/** Fallback when normalization removes every character. */
fallback?: string;
/** Maximum normalized length. Defaults to Blurt's safe public limit of 255 bytes/chars for ASCII slugs. */
maxLength?: number;
}
export interface ContentTagOptions {
/** Maximum number of tags to preserve. Defaults to the broad Blurt ecosystem convention of eight tags. */
maxTags?: number;
}
export interface CommentMetadataOptions extends ContentTagOptions {
app?: string;
format?: string;
tags?: string[];
/** Additional metadata fields. App/format/tags are SDK-owned and override colliding extra keys. */
extra?: CommentMetadata;
}
export interface PermlinkBuildOptions {
permlink?: string;
permlinkSuffix?: string;
}
export interface PostOperationOptions extends CommentMetadataOptions, PermlinkBuildOptions {
author: string;
title: string;
body: string;
tags: string[];
}
export interface ReplyOperationOptions extends CommentMetadataOptions, PermlinkBuildOptions {
author: string;
parentAuthor: string;
parentPermlink: string;
body: string;
}
export interface DeleteCommentOperationOptions {
author: string;
permlink: string;
}
export interface UpdateOperationOptions {
parentAuthor: string;
parentPermlink: string;
author: string;
permlink: string;
title: string;
body: string;
metadata?: CommentMetadata | string;
}
/** Normalize a string into a conservative Blurt permlink/category/tag slug. */
export declare function normalizePermlink(input: string, options?: PermlinkNormalizationOptions): string;
/** Normalize and de-duplicate content tags for json_metadata and top-level post categories. */
export declare function normalizeContentTags(tags: string[], options?: ContentTagOptions): string[];
/** Build a post permlink from a supplied permlink or title plus optional deterministic suffix. */
export declare function buildPostPermlink(options: {
title: string;
permlink?: string;
suffix?: string;
}): string;
/** Build a reply permlink from a supplied permlink or parent permlink plus optional deterministic suffix. */
export declare function buildReplyPermlink(options: {
parentPermlink: string;
permlink?: string;
suffix?: string;
}): string;
/** Build a JSON-encoded comment metadata string from normalized ecosystem fields. */
export declare function buildCommentMetadata(options?: CommentMetadataOptions): string;
/** Parse comment json_metadata, returning an empty object for blank/invalid/non-object values. */
export declare function parseCommentMetadata(jsonMetadata: string): CommentMetadata;
/**
* Build a top-level `comment` operation for a post without signing or broadcasting.
*
* The first normalized tag becomes the Layer 1 post category (`parent_permlink`).
* The returned operation is suitable for preview, tests, external signing or a
* later broadcast workflow. Throws {@link ValidationError} when no valid tag can
* be used as the top-level category.
*/
export declare function buildPostOperation(options: PostOperationOptions): CommentOperation;
/**
* Build a reply `comment` operation without signing or broadcasting.
*
* The caller supplies the parent author/permlink identity. The returned payload is
* only an operation tuple; authority checks, signing and broadcast remain separate
* application steps.
*/
export declare function buildReplyOperation(options: ReplyOperationOptions): CommentOperation;
/**
* Build an update `comment` operation from caller-supplied identity fields.
*
* Use this when the target post/reply identity is already known. The helper does
* not fetch existing content, check authority, sign or broadcast.
*/
export declare function buildUpdateOperation(options: UpdateOperationOptions): CommentOperation;
/** Build a `delete_comment` operation without signing or broadcasting. */
export declare function buildDeleteCommentOperation(options: DeleteCommentOperationOptions): DeleteCommentOperation;