@seed-hypermedia/client 0.0.3 → 0.0.5

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.
@@ -31,3 +31,30 @@ export declare function emitFrontmatter(metadata: HMMetadata): string;
31
31
  * as placeholder links (not resolved).
32
32
  */
33
33
  export declare function blocksToMarkdown(doc: HMDocument, options?: BlocksToMarkdownOptions): string;
34
+ /**
35
+ * Convert a title string into a URL-safe slug.
36
+ *
37
+ * - Lowercases the string
38
+ * - Replaces non-alphanumeric characters with hyphens
39
+ * - Trims leading/trailing hyphens
40
+ * - Truncates to 60 characters
41
+ */
42
+ export declare function slugify(title: string): string;
43
+ /**
44
+ * Build a draft filename from a slug and nanoid.
45
+ * Format: `<slug>_<nanoid>.md` — human-readable + collision-safe.
46
+ * If the slug is empty, the filename is just `<nanoid>.md`.
47
+ */
48
+ export declare function draftFilename(slug: string, id: string): string;
49
+ /**
50
+ * Extract the draft ID (nanoid) from a draft filename.
51
+ *
52
+ * Handles both formats:
53
+ * - `<slug>_<nanoid>.md` → returns the nanoid part
54
+ * - `<nanoid>.md` → returns the nanoid (legacy/no-slug)
55
+ * - `<nanoid>.json` → returns the nanoid (legacy JSON)
56
+ */
57
+ export declare function parseDraftFilename(filename: string): {
58
+ id: string;
59
+ ext: string;
60
+ };
@@ -264,6 +264,7 @@ var HMCommentSchema = z.object({
264
264
  targetPath: z.string().optional(),
265
265
  targetVersion: z.string(),
266
266
  replyParent: z.string().optional(),
267
+ replyParentVersion: z.string().optional(),
267
268
  threadRoot: z.string().optional(),
268
269
  threadRootVersion: z.string().optional(),
269
270
  capability: z.string().optional(),
@@ -604,7 +605,11 @@ var HMDraftMetaBaseSchema = z.object({
604
605
  editUid: z.string().optional(),
605
606
  editPath: z.array(z.string()).optional(),
606
607
  metadata: HMDocumentMetadataSchema,
607
- visibility: HMResourceVisibilitySchema.optional().default("PUBLIC")
608
+ visibility: HMResourceVisibilitySchema.optional().default("PUBLIC"),
609
+ // deps and navigation live in the index entry for .md drafts
610
+ // (for .json drafts they come from the content file for backwards compat)
611
+ deps: z.array(z.string().min(1)).default([]),
612
+ navigation: z.array(HMNavigationItemSchema).optional()
608
613
  });
609
614
  var draftLocationRefinement = (data) => data.editUid || data.locationUid;
610
615
  var HMDraftMetaSchema = HMDraftMetaBaseSchema.refine(draftLocationRefinement, {
@@ -925,6 +930,17 @@ var HMPrepareDocumentChangeRequestSchema = z.object({
925
930
  input: HMPrepareDocumentChangeInputSchema,
926
931
  output: HMPrepareDocumentChangeOutputSchema
927
932
  });
933
+ var HMListCommentVersionsInputSchema = z.object({
934
+ id: z.string()
935
+ });
936
+ var HMListCommentVersionsOutputSchema = z.object({
937
+ versions: z.array(HMCommentSchema)
938
+ });
939
+ var HMListCommentVersionsRequestSchema = z.object({
940
+ key: z.literal("ListCommentVersions"),
941
+ input: HMListCommentVersionsInputSchema,
942
+ output: HMListCommentVersionsOutputSchema
943
+ });
928
944
  var HMGetRequestSchema = z.discriminatedUnion("key", [
929
945
  HMResourceRequestSchema,
930
946
  HMResourceMetadataRequestSchema,
@@ -945,7 +961,8 @@ var HMGetRequestSchema = z.discriminatedUnion("key", [
945
961
  HMListCitationsRequestSchema,
946
962
  HMListChangesRequestSchema,
947
963
  HMListCapabilitiesRequestSchema,
948
- HMInteractionSummaryRequestSchema
964
+ HMInteractionSummaryRequestSchema,
965
+ HMListCommentVersionsRequestSchema
949
966
  ]);
950
967
  var HMActionSchema = z.discriminatedUnion("key", [
951
968
  HMPublishBlobsRequestSchema,
@@ -972,6 +989,7 @@ var HMRequestSchema = z.discriminatedUnion("key", [
972
989
  HMListChangesRequestSchema,
973
990
  HMListCapabilitiesRequestSchema,
974
991
  HMInteractionSummaryRequestSchema,
992
+ HMListCommentVersionsRequestSchema,
975
993
  HMPublishBlobsRequestSchema,
976
994
  HMPrepareDocumentChangeRequestSchema
977
995
  ]);
@@ -1274,6 +1292,9 @@ export {
1274
1292
  HMPrepareDocumentChangeInputSchema,
1275
1293
  HMPrepareDocumentChangeOutputSchema,
1276
1294
  HMPrepareDocumentChangeRequestSchema,
1295
+ HMListCommentVersionsInputSchema,
1296
+ HMListCommentVersionsOutputSchema,
1297
+ HMListCommentVersionsRequestSchema,
1277
1298
  HMGetRequestSchema,
1278
1299
  HMActionSchema,
1279
1300
  HMRequestSchema,
package/dist/comment.d.ts CHANGED
@@ -40,6 +40,19 @@ export type DeleteCommentInput = {
40
40
  visibility?: 'Private' | '';
41
41
  };
42
42
  export declare function deleteComment(input: DeleteCommentInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
43
+ /** Input for updating an existing comment. */
44
+ export type UpdateCommentInput = {
45
+ commentId: string;
46
+ targetAccount: string;
47
+ targetPath: string;
48
+ targetVersion: string;
49
+ content: HMBlockNode[];
50
+ replyParentVersion?: string | null;
51
+ rootReplyCommentVersion?: string | null;
52
+ visibility?: 'Private' | '';
53
+ };
54
+ /** Creates a signed update blob for an existing comment. */
55
+ export declare function updateComment(input: UpdateCommentInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
43
56
  /**
44
57
  * Compute the record ID ("authority/tsid") from raw CBOR-encoded comment blob bytes.
45
58
  * The TSID is a 10-byte base58btc value: 6 bytes ms timestamp + 4 bytes SHA256 prefix.
@@ -0,0 +1,157 @@
1
+ import { HMBlockChildrenType } from './hm-types';
2
+ export type EditorBlock = EditorParagraphBlock | EditorHeadingBlock | EditorCodeBlock | EditorImageBlock | EditorVideoBlock | EditorFileBlock | EditorButtonBlock | EditorEmbedBlock | EditorWebEmbedBlock | EditorMathBlock | EditorNostrBlock | EditorQueryBlock | EditorUnknownBlock;
3
+ export type HMInlineContent = EditorText | EditorInlineEmbed | EditorLink;
4
+ export interface EditorBaseBlock {
5
+ id: string;
6
+ props: EditorBlockProps;
7
+ children: Array<EditorBlock>;
8
+ }
9
+ export interface EditorBlockProps {
10
+ childrenType?: HMBlockChildrenType;
11
+ columnCount?: string;
12
+ listLevel?: string;
13
+ level?: number | string;
14
+ ref?: string;
15
+ revision?: string;
16
+ }
17
+ export interface EditorParagraphBlock extends EditorBaseBlock {
18
+ type: 'paragraph';
19
+ content: Array<HMInlineContent>;
20
+ }
21
+ export interface EditorHeadingBlock extends EditorBaseBlock {
22
+ type: 'heading';
23
+ content: Array<HMInlineContent>;
24
+ }
25
+ export interface EditorCodeBlock extends EditorBaseBlock {
26
+ type: 'code-block';
27
+ content: Array<HMInlineContent>;
28
+ props: EditorBlockProps & {
29
+ language?: string;
30
+ };
31
+ }
32
+ export interface DraftMediaRef {
33
+ draftId: string;
34
+ mediaId: string;
35
+ name: string;
36
+ mime: string;
37
+ size: number;
38
+ }
39
+ export interface MediaBlockProps extends EditorBlockProps {
40
+ url?: string;
41
+ src?: string;
42
+ displaySrc?: string;
43
+ fileBinary?: Uint8Array | number[];
44
+ mediaRef?: DraftMediaRef;
45
+ name?: string;
46
+ width?: string;
47
+ defaultOpen?: string;
48
+ size?: string;
49
+ alignment?: string;
50
+ }
51
+ export interface EditorImageBlock extends EditorBaseBlock {
52
+ type: 'image';
53
+ props: MediaBlockProps;
54
+ content: Array<HMInlineContent>;
55
+ }
56
+ export interface EditorVideoBlock extends EditorBaseBlock {
57
+ type: 'video';
58
+ props: MediaBlockProps;
59
+ content: Array<HMInlineContent>;
60
+ }
61
+ export interface EditorFileBlock extends EditorBaseBlock {
62
+ type: 'file';
63
+ props: MediaBlockProps;
64
+ content: Array<HMInlineContent>;
65
+ }
66
+ export interface EditorButtonBlock extends EditorBaseBlock {
67
+ type: 'button';
68
+ props: MediaBlockProps;
69
+ content: Array<HMInlineContent>;
70
+ }
71
+ export interface EditorEmbedBlock extends EditorBaseBlock {
72
+ type: 'embed';
73
+ props: EditorBlockProps & {
74
+ view: 'Content' | 'Card';
75
+ url: string;
76
+ };
77
+ content: Array<HMInlineContent>;
78
+ }
79
+ export interface EditorMathBlock extends EditorBaseBlock {
80
+ type: 'math';
81
+ content: Array<HMInlineContent>;
82
+ }
83
+ export type EditorWebEmbedBlock = EditorBaseBlock & {
84
+ type: 'web-embed';
85
+ props: EditorBlockProps & {
86
+ url?: string;
87
+ };
88
+ content: Array<HMInlineContent>;
89
+ };
90
+ export type EditorNostrBlock = EditorBaseBlock & {
91
+ type: 'nostr';
92
+ props: EditorBlockProps & {
93
+ name?: string;
94
+ url?: string;
95
+ text?: string;
96
+ size?: string;
97
+ };
98
+ content: Array<HMInlineContent>;
99
+ };
100
+ export type EditorQueryBlock = EditorBaseBlock & {
101
+ type: 'query';
102
+ props: EditorBlockProps & {
103
+ style: 'Card' | 'List';
104
+ columnCount?: '1' | '2' | '3';
105
+ queryLimit?: string;
106
+ queryIncludes?: string;
107
+ querySort?: string;
108
+ banner?: 'true' | 'false';
109
+ };
110
+ content: Array<HMInlineContent>;
111
+ };
112
+ export type EditorUnknownBlock = EditorBaseBlock & {
113
+ type: 'unknown';
114
+ props: EditorBlockProps & {
115
+ originalType: string;
116
+ originalData: string;
117
+ };
118
+ content: Array<HMInlineContent>;
119
+ };
120
+ export interface EditorText {
121
+ type: 'text';
122
+ text: string;
123
+ styles: EditorInlineStyles;
124
+ }
125
+ export interface EditorLink {
126
+ type: 'link';
127
+ href: string;
128
+ content: Array<HMInlineContent>;
129
+ }
130
+ export interface EditorInlineEmbed {
131
+ type: 'inline-embed';
132
+ link: string;
133
+ styles: EditorInlineStyles | {};
134
+ }
135
+ export interface EditorInlineStyles {
136
+ bold?: boolean;
137
+ italic?: boolean;
138
+ underline?: boolean;
139
+ strike?: boolean;
140
+ code?: boolean;
141
+ math?: boolean;
142
+ range?: boolean;
143
+ }
144
+ export type EditorAnnotationType = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'link' | 'inline-embed' | 'range';
145
+ export type EditorBlockType = EditorBlock['type'];
146
+ export type SearchResult = {
147
+ key: string;
148
+ title: string;
149
+ subtitle?: string;
150
+ icon?: string;
151
+ path?: string[] | null;
152
+ versionTime?: string;
153
+ searchQuery?: string;
154
+ onSelect?: () => void | Promise<void>;
155
+ onFocus: () => void;
156
+ onMouseEnter: () => void;
157
+ };
@@ -0,0 +1,12 @@
1
+ import { EditorBlock } from './editor-types';
2
+ import { HMBlock, HMBlockNode } from './hm-types';
3
+ /** Convert a single BlockNote EditorBlock into an HMBlock. */
4
+ export declare function editorBlockToHMBlock(editorBlock: EditorBlock): HMBlock;
5
+ /**
6
+ * Convert an array of BlockNote EditorBlocks into an HMBlockNode tree.
7
+ *
8
+ * This is the tree-level wrapper around `editorBlockToHMBlock` that recursively
9
+ * converts children. Useful when serializing editor content to the HM block format
10
+ * (e.g. for saving drafts as markdown or publishing documents).
11
+ */
12
+ export declare function editorBlocksToHMBlockNodes(editorBlocks: EditorBlock[]): HMBlockNode[];