@seed-hypermedia/client 0.0.1

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.
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ import type { HMPrepareDocumentChangeInput, HMRequest, HMSigner } from './hm-types';
3
+ /**
4
+ * Deserializes a URL query string using a Zod schema.
5
+ * If the query contains only a __value key, returns the primitive value directly.
6
+ */
7
+ export declare function deserializeQueryString<T>(queryString: string, schema: z.ZodType<T>): T;
8
+ export type PublishDocumentInput = {
9
+ account: string;
10
+ changes: HMPrepareDocumentChangeInput['changes'];
11
+ path?: string;
12
+ baseVersion?: string;
13
+ genesis?: string;
14
+ generation?: number | bigint;
15
+ capability?: string;
16
+ visibility?: number;
17
+ };
18
+ export type SeedClientOptions = {
19
+ fetch?: typeof globalThis.fetch;
20
+ headers?: Record<string, string>;
21
+ };
22
+ type PublishBlobsRequest = Extract<HMRequest, {
23
+ key: 'PublishBlobs';
24
+ }>;
25
+ export type SeedClient = {
26
+ request<K extends HMRequest['key']>(key: K, input: Extract<HMRequest, {
27
+ key: K;
28
+ }>['input']): Promise<Extract<HMRequest, {
29
+ key: K;
30
+ }>['output']>;
31
+ publish(input: PublishBlobsRequest['input']): Promise<PublishBlobsRequest['output']>;
32
+ publishBlobs(input: PublishBlobsRequest['input']): Promise<PublishBlobsRequest['output']>;
33
+ publishDocument(input: PublishDocumentInput, signer: HMSigner): Promise<void>;
34
+ baseUrl: string;
35
+ };
36
+ export declare function createSeedClient(baseUrl: string, options?: SeedClientOptions): SeedClient;
37
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { HMBlockNode, HMPublishBlobsInput, HMSigner, UnpackedHypermediaId } from './hm-types';
2
+ /**
3
+ * Removes trailing empty blocks from comment content before publishing.
4
+ * The editor always keeps a trailing empty paragraph for UX, but we
5
+ * don't want to publish it.
6
+ */
7
+ export declare function trimTrailingEmptyBlocks(blocks: HMBlockNode[]): HMBlockNode[];
8
+ export type CommentAttachmentBlob = {
9
+ cid: string;
10
+ data: Uint8Array;
11
+ };
12
+ type PrepareAttachments = (binaries: Uint8Array[]) => Promise<{
13
+ blobs: CommentAttachmentBlob[];
14
+ resultCIDs: string[];
15
+ }>;
16
+ type CreateCommentBaseInput = {
17
+ docId: UnpackedHypermediaId;
18
+ docVersion: string;
19
+ replyCommentVersion?: string | null;
20
+ rootReplyCommentVersion?: string | null;
21
+ quotingBlockId?: string;
22
+ visibility?: 'Private' | '';
23
+ };
24
+ export type CreateCommentInput = (CreateCommentBaseInput & {
25
+ content: HMBlockNode[];
26
+ blobs?: CommentAttachmentBlob[];
27
+ }) | (CreateCommentBaseInput & {
28
+ getContent: (prepareAttachments: PrepareAttachments) => Promise<{
29
+ blockNodes: HMBlockNode[];
30
+ blobs: CommentAttachmentBlob[];
31
+ }>;
32
+ prepareAttachments?: PrepareAttachments;
33
+ });
34
+ export declare function createComment(input: CreateCommentInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
35
+ export type DeleteCommentInput = {
36
+ commentId: string;
37
+ targetAccount: string;
38
+ targetPath: string;
39
+ targetVersion: string;
40
+ visibility?: 'Private' | '';
41
+ };
42
+ export declare function deleteComment(input: DeleteCommentInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
43
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { HMPublishBlobsInput, HMSigner } from './hm-types';
2
+ export type CreateContactInput = {
3
+ /** The subject account UID (base58btc-encoded principal) */
4
+ subjectUid: string;
5
+ /** The display name for the contact */
6
+ name: string;
7
+ };
8
+ export type UpdateContactInput = {
9
+ /** The contact record ID in format "authority/tsid" */
10
+ contactId: string;
11
+ /** The subject account UID */
12
+ subjectUid: string;
13
+ /** The updated display name */
14
+ name: string;
15
+ };
16
+ export type DeleteContactInput = {
17
+ /** The contact record ID in format "authority/tsid" */
18
+ contactId: string;
19
+ };
20
+ export type CreateContactResult = HMPublishBlobsInput & {
21
+ /** The record ID in format "authority/tsid" */
22
+ recordId: string;
23
+ };
24
+ /**
25
+ * Create a new contact blob and compute its record ID.
26
+ * Returns the publish input plus a `recordId` in "authority/tsid" format.
27
+ */
28
+ export declare function createContact(input: CreateContactInput, signer: HMSigner): Promise<CreateContactResult>;
29
+ /**
30
+ * Update an existing contact blob. Reuses the original TSID.
31
+ */
32
+ export declare function updateContact(input: UpdateContactInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
33
+ /**
34
+ * Delete a contact by publishing a tombstone blob.
35
+ * A tombstone has the same TSID but no subject and no name.
36
+ */
37
+ export declare function deleteContact(input: DeleteContactInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
38
+ /**
39
+ * Compute the record ID ("authority/tsid") from raw CBOR-encoded contact blob bytes.
40
+ * Useful for resolving a CID to a record ID after fetching the blob.
41
+ */
42
+ export declare function contactRecordIdFromBlob(blobData: Uint8Array): Promise<string>;
@@ -0,0 +1,11 @@
1
+ export declare class SeedClientError extends Error {
2
+ readonly status: number;
3
+ readonly body?: string;
4
+ constructor(message: string, status: number, body?: string);
5
+ }
6
+ export declare class SeedNetworkError extends Error {
7
+ constructor(message: string, options?: ErrorOptions);
8
+ }
9
+ export declare class SeedValidationError extends Error {
10
+ constructor(message: string);
11
+ }