@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.
- package/LICENSE +201 -0
- package/dist/capability.d.ts +21 -0
- package/dist/change.d.ts +129 -0
- package/dist/chunk-YUKHBJYL.mjs +1044 -0
- package/dist/client.d.ts +37 -0
- package/dist/comment.d.ts +43 -0
- package/dist/contact.d.ts +42 -0
- package/dist/errors.d.ts +11 -0
- package/dist/hm-types.d.ts +43109 -0
- package/dist/hm-types.mjs +272 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.mjs +891 -0
- package/dist/ref.d.ts +65 -0
- package/dist/signing.d.ts +16 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
// src/hm-types.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
var BlockRangeSchema = z.object({
|
|
4
|
+
// a block range should either have start+end
|
|
5
|
+
start: z.number().optional(),
|
|
6
|
+
end: z.number().optional(),
|
|
7
|
+
// or have expanded bool
|
|
8
|
+
expanded: z.boolean().optional()
|
|
9
|
+
});
|
|
10
|
+
var unpackedHmIdSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
uid: z.string(),
|
|
13
|
+
path: z.array(z.string()).nullable(),
|
|
14
|
+
version: z.string().nullable(),
|
|
15
|
+
blockRef: z.string().nullable(),
|
|
16
|
+
blockRange: BlockRangeSchema.nullable(),
|
|
17
|
+
hostname: z.string().nullable(),
|
|
18
|
+
scheme: z.string().nullable(),
|
|
19
|
+
latest: z.boolean().nullable().optional(),
|
|
20
|
+
// deprecated:
|
|
21
|
+
targetDocUid: z.string().nullable().optional(),
|
|
22
|
+
targetDocPath: z.array(z.string()).nullable().optional()
|
|
23
|
+
});
|
|
24
|
+
var HMBlockChildrenTypeSchema = z.union([z.literal("Group"), z.literal("Ordered"), z.literal("Unordered"), z.literal("Blockquote")]).nullable();
|
|
25
|
+
var HMEmbedViewSchema = z.union([z.literal("Content"), z.literal("Card"), z.literal("Comments")]);
|
|
26
|
+
var HMQueryStyleSchema = z.union([z.literal("Card"), z.literal("List")]);
|
|
27
|
+
var baseAnnotationProperties = {
|
|
28
|
+
starts: z.array(z.number()),
|
|
29
|
+
ends: z.array(z.number()),
|
|
30
|
+
attributes: z.object({}).optional(),
|
|
31
|
+
link: z.literal("").optional()
|
|
32
|
+
};
|
|
33
|
+
var BoldAnnotationSchema = z.object({
|
|
34
|
+
type: z.literal("Bold"),
|
|
35
|
+
...baseAnnotationProperties
|
|
36
|
+
}).strict();
|
|
37
|
+
var ItalicAnnotationSchema = z.object({
|
|
38
|
+
type: z.literal("Italic"),
|
|
39
|
+
...baseAnnotationProperties
|
|
40
|
+
}).strict();
|
|
41
|
+
var UnderlineAnnotationSchema = z.object({
|
|
42
|
+
type: z.literal("Underline"),
|
|
43
|
+
...baseAnnotationProperties
|
|
44
|
+
}).strict();
|
|
45
|
+
var StrikeAnnotationSchema = z.object({
|
|
46
|
+
type: z.literal("Strike"),
|
|
47
|
+
...baseAnnotationProperties
|
|
48
|
+
}).strict();
|
|
49
|
+
var CodeAnnotationSchema = z.object({
|
|
50
|
+
type: z.literal("Code"),
|
|
51
|
+
...baseAnnotationProperties
|
|
52
|
+
}).strict();
|
|
53
|
+
var LinkAnnotationSchema = z.object({
|
|
54
|
+
type: z.literal("Link"),
|
|
55
|
+
...baseAnnotationProperties,
|
|
56
|
+
link: z.string().optional()
|
|
57
|
+
// this should be required but we have seen some data that is missing it
|
|
58
|
+
}).strict();
|
|
59
|
+
var InlineEmbedAnnotationSchema = z.object({
|
|
60
|
+
type: z.literal("Embed"),
|
|
61
|
+
...baseAnnotationProperties,
|
|
62
|
+
link: z.string()
|
|
63
|
+
}).strict();
|
|
64
|
+
var HighlightAnnotationSchema = z.object({
|
|
65
|
+
type: z.literal("Range"),
|
|
66
|
+
...baseAnnotationProperties
|
|
67
|
+
}).strict();
|
|
68
|
+
var HMAnnotationSchema = z.discriminatedUnion("type", [
|
|
69
|
+
BoldAnnotationSchema,
|
|
70
|
+
ItalicAnnotationSchema,
|
|
71
|
+
UnderlineAnnotationSchema,
|
|
72
|
+
StrikeAnnotationSchema,
|
|
73
|
+
CodeAnnotationSchema,
|
|
74
|
+
LinkAnnotationSchema,
|
|
75
|
+
InlineEmbedAnnotationSchema,
|
|
76
|
+
HighlightAnnotationSchema
|
|
77
|
+
]);
|
|
78
|
+
var HMAnnotationsSchema = z.array(HMAnnotationSchema).optional();
|
|
79
|
+
var blockBaseProperties = {
|
|
80
|
+
id: z.string(),
|
|
81
|
+
revision: z.string().optional(),
|
|
82
|
+
attributes: z.object({}).optional().default({}),
|
|
83
|
+
// EMPTY ATTRIBUTES, override in specific block schemas
|
|
84
|
+
annotations: z.array(z.never()).optional(),
|
|
85
|
+
// EMPTY ANNOTATIONS, override in specific block schemas
|
|
86
|
+
text: z.literal("").optional(),
|
|
87
|
+
// EMPTY TEXT, override in specific block schemas
|
|
88
|
+
link: z.literal("").optional()
|
|
89
|
+
// EMPTY LINK, override in specific block schemas
|
|
90
|
+
};
|
|
91
|
+
var textBlockProperties = {
|
|
92
|
+
text: z.string().default(""),
|
|
93
|
+
annotations: HMAnnotationsSchema
|
|
94
|
+
};
|
|
95
|
+
var parentBlockAttributes = {
|
|
96
|
+
childrenType: HMBlockChildrenTypeSchema.optional()
|
|
97
|
+
};
|
|
98
|
+
var HMBlockParagraphSchema = z.object({
|
|
99
|
+
type: z.literal("Paragraph"),
|
|
100
|
+
...blockBaseProperties,
|
|
101
|
+
...textBlockProperties,
|
|
102
|
+
attributes: z.object(parentBlockAttributes).optional().default({})
|
|
103
|
+
}).strict();
|
|
104
|
+
var HMBlockHeadingSchema = z.object({
|
|
105
|
+
type: z.literal("Heading"),
|
|
106
|
+
...blockBaseProperties,
|
|
107
|
+
...textBlockProperties,
|
|
108
|
+
attributes: z.object(parentBlockAttributes).optional().default({})
|
|
109
|
+
}).strict();
|
|
110
|
+
var HMBlockCodeSchema = z.object({
|
|
111
|
+
type: z.literal("Code"),
|
|
112
|
+
...blockBaseProperties,
|
|
113
|
+
attributes: z.object({
|
|
114
|
+
...parentBlockAttributes,
|
|
115
|
+
language: z.string().optional()
|
|
116
|
+
}).optional().default({}),
|
|
117
|
+
text: z.string().default("")
|
|
118
|
+
}).strict();
|
|
119
|
+
var HMBlockMathSchema = z.object({
|
|
120
|
+
type: z.literal("Math"),
|
|
121
|
+
...blockBaseProperties,
|
|
122
|
+
attributes: z.object(parentBlockAttributes).optional().default({}),
|
|
123
|
+
text: z.string().default("")
|
|
124
|
+
}).strict();
|
|
125
|
+
function toNumber(value) {
|
|
126
|
+
if (typeof value == "number" && !isNaN(value)) {
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
if (typeof value == "string") {
|
|
130
|
+
const converted = Number(value);
|
|
131
|
+
if (!isNaN(converted)) {
|
|
132
|
+
return converted;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
console.warn("Value must be a number or a string that can be converted to a number", value);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
var HMBlockImageSchema = z.object({
|
|
139
|
+
type: z.literal("Image"),
|
|
140
|
+
...blockBaseProperties,
|
|
141
|
+
...textBlockProperties,
|
|
142
|
+
attributes: z.object({
|
|
143
|
+
...parentBlockAttributes,
|
|
144
|
+
width: z.number().optional(),
|
|
145
|
+
name: z.string().optional()
|
|
146
|
+
}).optional().default({}),
|
|
147
|
+
link: z.string()
|
|
148
|
+
}).strict();
|
|
149
|
+
var HMBlockVideoSchema = z.object({
|
|
150
|
+
type: z.literal("Video"),
|
|
151
|
+
...blockBaseProperties,
|
|
152
|
+
attributes: z.object({
|
|
153
|
+
...parentBlockAttributes,
|
|
154
|
+
width: z.number().optional(),
|
|
155
|
+
name: z.string().optional()
|
|
156
|
+
}).optional().default({}),
|
|
157
|
+
link: z.string()
|
|
158
|
+
}).strict();
|
|
159
|
+
var HMBlockFileSchema = z.object({
|
|
160
|
+
type: z.literal("File"),
|
|
161
|
+
...blockBaseProperties,
|
|
162
|
+
attributes: z.object({
|
|
163
|
+
...parentBlockAttributes,
|
|
164
|
+
size: z.number().optional().transform(toNumber),
|
|
165
|
+
// number of bytes, as a string
|
|
166
|
+
name: z.string().optional()
|
|
167
|
+
}).optional().default({}),
|
|
168
|
+
link: z.string()
|
|
169
|
+
}).strict();
|
|
170
|
+
var HMBlockButtonAlignmentSchema = z.union([z.literal("flex-start"), z.literal("center"), z.literal("flex-end")]).optional();
|
|
171
|
+
var HMBlockButtonSchema = z.object({
|
|
172
|
+
type: z.literal("Button"),
|
|
173
|
+
...blockBaseProperties,
|
|
174
|
+
attributes: z.object({
|
|
175
|
+
...parentBlockAttributes,
|
|
176
|
+
name: z.string().optional(),
|
|
177
|
+
alignment: HMBlockButtonAlignmentSchema
|
|
178
|
+
}).optional().default({}),
|
|
179
|
+
text: z.string().optional(),
|
|
180
|
+
link: z.string()
|
|
181
|
+
}).strict();
|
|
182
|
+
var HMBlockEmbedSchema = z.object({
|
|
183
|
+
type: z.literal("Embed"),
|
|
184
|
+
...blockBaseProperties,
|
|
185
|
+
link: z.string(),
|
|
186
|
+
// should be a hm:// URL
|
|
187
|
+
attributes: z.object({
|
|
188
|
+
...parentBlockAttributes,
|
|
189
|
+
view: HMEmbedViewSchema.optional()
|
|
190
|
+
}).optional().default({})
|
|
191
|
+
}).strict();
|
|
192
|
+
var HMBlockWebEmbedSchema = z.object({
|
|
193
|
+
type: z.literal("WebEmbed"),
|
|
194
|
+
...blockBaseProperties,
|
|
195
|
+
link: z.string()
|
|
196
|
+
// should be a HTTP(S) URL
|
|
197
|
+
}).strict();
|
|
198
|
+
var HMBlockNostrSchema = z.object({
|
|
199
|
+
type: z.literal("Nostr"),
|
|
200
|
+
...blockBaseProperties,
|
|
201
|
+
link: z.string()
|
|
202
|
+
// should be a nostr:// URL
|
|
203
|
+
}).strict();
|
|
204
|
+
var HMTimestampSchema = z.object({
|
|
205
|
+
seconds: z.bigint().or(z.number()),
|
|
206
|
+
nanos: z.number()
|
|
207
|
+
}).strict().or(z.string());
|
|
208
|
+
var HMBlockNodeSchema = z.lazy(
|
|
209
|
+
() => z.object({
|
|
210
|
+
children: z.array(HMBlockNodeSchema).optional(),
|
|
211
|
+
block: HMBlockSchema
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
var HMDocumentMetadataSchema = z.object({
|
|
215
|
+
name: z.string().optional(),
|
|
216
|
+
summary: z.string().optional(),
|
|
217
|
+
icon: z.string().optional(),
|
|
218
|
+
thumbnail: z.string().optional(),
|
|
219
|
+
// DEPRECATED
|
|
220
|
+
cover: z.string().optional(),
|
|
221
|
+
siteUrl: z.string().optional(),
|
|
222
|
+
layout: z.union([z.literal("Seed/Experimental/Newspaper"), z.literal("")]).optional(),
|
|
223
|
+
displayPublishTime: z.string().optional(),
|
|
224
|
+
seedExperimentalLogo: z.string().optional(),
|
|
225
|
+
seedExperimentalHomeOrder: z.union([z.literal("UpdatedFirst"), z.literal("CreatedFirst")]).optional(),
|
|
226
|
+
showOutline: z.boolean().optional(),
|
|
227
|
+
showActivity: z.boolean().optional(),
|
|
228
|
+
contentWidth: z.union([z.literal("S"), z.literal("M"), z.literal("L")]).optional(),
|
|
229
|
+
theme: z.object({
|
|
230
|
+
headerLayout: z.union([z.literal("Center"), z.literal("")]).optional()
|
|
231
|
+
}).optional(),
|
|
232
|
+
// Import taxonomy fields (comma-separated values from external sources like WordPress)
|
|
233
|
+
importCategories: z.string().optional(),
|
|
234
|
+
importTags: z.string().optional()
|
|
235
|
+
});
|
|
236
|
+
function hmMetadataJsonCorrection(metadata) {
|
|
237
|
+
if (typeof metadata.theme === "string") {
|
|
238
|
+
return {
|
|
239
|
+
...metadata,
|
|
240
|
+
theme: {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return metadata;
|
|
244
|
+
}
|
|
245
|
+
var visibilityMap = {
|
|
246
|
+
0: "PUBLIC",
|
|
247
|
+
1: "PUBLIC",
|
|
248
|
+
2: "PRIVATE",
|
|
249
|
+
RESOURCE_VISIBILITY_UNSPECIFIED: "PUBLIC",
|
|
250
|
+
RESOURCE_VISIBILITY_PUBLIC: "PUBLIC",
|
|
251
|
+
RESOURCE_VISIBILITY_PRIVATE: "PRIVATE",
|
|
252
|
+
UNSPECIFIED: "PUBLIC",
|
|
253
|
+
PUBLIC: "PUBLIC",
|
|
254
|
+
PRIVATE: "PRIVATE"
|
|
255
|
+
};
|
|
256
|
+
var HMResourceVisibilitySchema = z.union([z.string(), z.number()]).transform((val) => visibilityMap[val] ?? "PUBLIC");
|
|
257
|
+
var HMCommentSchema = z.object({
|
|
258
|
+
id: z.string(),
|
|
259
|
+
version: z.string(),
|
|
260
|
+
author: z.string(),
|
|
261
|
+
targetAccount: z.string(),
|
|
262
|
+
targetPath: z.string().optional(),
|
|
263
|
+
targetVersion: z.string(),
|
|
264
|
+
replyParent: z.string().optional(),
|
|
265
|
+
threadRoot: z.string().optional(),
|
|
266
|
+
threadRootVersion: z.string().optional(),
|
|
267
|
+
capability: z.string().optional(),
|
|
268
|
+
content: z.array(HMBlockNodeSchema),
|
|
269
|
+
createTime: HMTimestampSchema,
|
|
270
|
+
updateTime: HMTimestampSchema,
|
|
271
|
+
visibility: HMResourceVisibilitySchema
|
|
272
|
+
});
|
|
273
|
+
var HMBreadcrumbSchema = z.object({
|
|
274
|
+
name: z.string(),
|
|
275
|
+
path: z.string(),
|
|
276
|
+
isMissing: z.boolean().optional()
|
|
277
|
+
});
|
|
278
|
+
var HMCommentGroupSchema = z.object({
|
|
279
|
+
comments: z.array(HMCommentSchema),
|
|
280
|
+
moreCommentsCount: z.number(),
|
|
281
|
+
id: z.string(),
|
|
282
|
+
type: z.literal("commentGroup")
|
|
283
|
+
});
|
|
284
|
+
var HMExternalCommentGroupSchema = z.object({
|
|
285
|
+
comments: z.array(HMCommentSchema),
|
|
286
|
+
moreCommentsCount: z.number(),
|
|
287
|
+
id: z.string(),
|
|
288
|
+
target: z.lazy(() => HMMetadataPayloadSchema),
|
|
289
|
+
type: z.literal("externalCommentGroup")
|
|
290
|
+
});
|
|
291
|
+
var HMActivitySummarySchema = z.object({
|
|
292
|
+
latestCommentTime: HMTimestampSchema.optional(),
|
|
293
|
+
latestCommentId: z.string(),
|
|
294
|
+
commentCount: z.number(),
|
|
295
|
+
latestChangeTime: HMTimestampSchema,
|
|
296
|
+
isUnread: z.boolean()
|
|
297
|
+
});
|
|
298
|
+
var HMGenerationInfoSchema = z.object({
|
|
299
|
+
genesis: z.string(),
|
|
300
|
+
generation: z.union([z.bigint(), z.coerce.bigint()])
|
|
301
|
+
});
|
|
302
|
+
var HMRedirectInfoSchema = z.object({
|
|
303
|
+
type: z.literal("redirect"),
|
|
304
|
+
target: z.string()
|
|
305
|
+
});
|
|
306
|
+
var HMDocumentInfoSchema = z.object({
|
|
307
|
+
type: z.literal("document"),
|
|
308
|
+
id: unpackedHmIdSchema,
|
|
309
|
+
path: z.array(z.string()),
|
|
310
|
+
authors: z.array(z.string()),
|
|
311
|
+
createTime: HMTimestampSchema,
|
|
312
|
+
updateTime: HMTimestampSchema,
|
|
313
|
+
sortTime: z.instanceof(Date),
|
|
314
|
+
genesis: z.string(),
|
|
315
|
+
version: z.string(),
|
|
316
|
+
breadcrumbs: z.array(HMBreadcrumbSchema),
|
|
317
|
+
activitySummary: HMActivitySummarySchema,
|
|
318
|
+
generationInfo: HMGenerationInfoSchema,
|
|
319
|
+
redirectInfo: HMRedirectInfoSchema.optional(),
|
|
320
|
+
metadata: HMDocumentMetadataSchema,
|
|
321
|
+
visibility: HMResourceVisibilitySchema
|
|
322
|
+
});
|
|
323
|
+
var HMQueryResultSchema = z.object({
|
|
324
|
+
in: unpackedHmIdSchema,
|
|
325
|
+
results: z.array(HMDocumentInfoSchema),
|
|
326
|
+
mode: z.union([z.literal("Children"), z.literal("AllDescendants")]).optional()
|
|
327
|
+
});
|
|
328
|
+
var HMRoleSchema = z.enum(["writer", "agent", "none", "owner"]);
|
|
329
|
+
var HMMetadataPayloadSchema = z.object({
|
|
330
|
+
id: unpackedHmIdSchema,
|
|
331
|
+
metadata: HMDocumentMetadataSchema.or(z.null()),
|
|
332
|
+
hasSite: z.boolean().optional()
|
|
333
|
+
}).strict();
|
|
334
|
+
var HMAccountPayloadSchema = HMMetadataPayloadSchema.extend({
|
|
335
|
+
type: z.literal("account")
|
|
336
|
+
});
|
|
337
|
+
var HMAccountNotFoundSchema = z.object({
|
|
338
|
+
type: z.literal("account-not-found"),
|
|
339
|
+
uid: z.string()
|
|
340
|
+
});
|
|
341
|
+
var HMAccountResultSchema = z.discriminatedUnion("type", [HMAccountPayloadSchema, HMAccountNotFoundSchema]);
|
|
342
|
+
var HMAccountsMetadataSchema = z.record(
|
|
343
|
+
z.string(),
|
|
344
|
+
// account uid
|
|
345
|
+
HMMetadataPayloadSchema
|
|
346
|
+
);
|
|
347
|
+
var HMQueryInclusionSchema = z.object({
|
|
348
|
+
space: z.string(),
|
|
349
|
+
path: z.string().optional(),
|
|
350
|
+
mode: z.union([z.literal("Children"), z.literal("AllDescendants")])
|
|
351
|
+
});
|
|
352
|
+
var HMQuerySortSchema = z.object({
|
|
353
|
+
reverse: z.boolean().default(false),
|
|
354
|
+
term: z.union([
|
|
355
|
+
z.literal("Path"),
|
|
356
|
+
z.literal("Title"),
|
|
357
|
+
z.literal("CreateTime"),
|
|
358
|
+
z.literal("UpdateTime"),
|
|
359
|
+
z.literal("DisplayTime")
|
|
360
|
+
])
|
|
361
|
+
});
|
|
362
|
+
var HMQuerySchema = z.object({
|
|
363
|
+
includes: z.array(HMQueryInclusionSchema),
|
|
364
|
+
sort: z.array(HMQuerySortSchema).optional(),
|
|
365
|
+
limit: z.preprocess(
|
|
366
|
+
(val) => val === "" || val === null || val === void 0 ? void 0 : val,
|
|
367
|
+
z.coerce.number().optional()
|
|
368
|
+
)
|
|
369
|
+
});
|
|
370
|
+
var HMBlockQuerySchema = z.object({
|
|
371
|
+
type: z.literal("Query"),
|
|
372
|
+
...blockBaseProperties,
|
|
373
|
+
attributes: z.object({
|
|
374
|
+
...parentBlockAttributes,
|
|
375
|
+
style: HMQueryStyleSchema.optional().default("Card"),
|
|
376
|
+
columnCount: z.number().optional().default(3),
|
|
377
|
+
query: HMQuerySchema,
|
|
378
|
+
banner: z.boolean().optional().default(false)
|
|
379
|
+
})
|
|
380
|
+
}).strict();
|
|
381
|
+
var HMBlockGroupSchema = z.object({
|
|
382
|
+
type: z.literal("Group"),
|
|
383
|
+
id: z.string()
|
|
384
|
+
});
|
|
385
|
+
var HMBlockLinkSchema = z.object({
|
|
386
|
+
type: z.literal("Link"),
|
|
387
|
+
id: z.string(),
|
|
388
|
+
link: z.string().optional(),
|
|
389
|
+
text: z.string()
|
|
390
|
+
});
|
|
391
|
+
var HMBlockKnownSchema = z.discriminatedUnion("type", [
|
|
392
|
+
HMBlockParagraphSchema,
|
|
393
|
+
HMBlockHeadingSchema,
|
|
394
|
+
HMBlockCodeSchema,
|
|
395
|
+
HMBlockMathSchema,
|
|
396
|
+
HMBlockImageSchema,
|
|
397
|
+
HMBlockVideoSchema,
|
|
398
|
+
HMBlockFileSchema,
|
|
399
|
+
HMBlockButtonSchema,
|
|
400
|
+
HMBlockEmbedSchema,
|
|
401
|
+
HMBlockWebEmbedSchema,
|
|
402
|
+
HMBlockNostrSchema,
|
|
403
|
+
HMBlockQuerySchema,
|
|
404
|
+
HMBlockGroupSchema,
|
|
405
|
+
HMBlockLinkSchema
|
|
406
|
+
]);
|
|
407
|
+
var HMBlockUnknownSchema = z.object({
|
|
408
|
+
type: z.string(),
|
|
409
|
+
id: z.string(),
|
|
410
|
+
revision: z.string().optional(),
|
|
411
|
+
attributes: z.record(z.any()).optional(),
|
|
412
|
+
annotations: z.array(z.any()).optional(),
|
|
413
|
+
text: z.string().optional(),
|
|
414
|
+
link: z.string().optional()
|
|
415
|
+
}).passthrough();
|
|
416
|
+
var HMBlockSchema = z.union([HMBlockKnownSchema, HMBlockUnknownSchema]);
|
|
417
|
+
var knownBlockTypes = new Set(HMBlockKnownSchema.optionsMap.keys());
|
|
418
|
+
function isKnownBlockType(btype) {
|
|
419
|
+
return knownBlockTypes.has(btype);
|
|
420
|
+
}
|
|
421
|
+
var HMDocumentSchema = z.object({
|
|
422
|
+
content: z.array(HMBlockNodeSchema).default([]),
|
|
423
|
+
version: z.string().default(""),
|
|
424
|
+
account: z.string().default(""),
|
|
425
|
+
authors: z.array(z.string()),
|
|
426
|
+
path: z.string().default(""),
|
|
427
|
+
createTime: z.union([HMTimestampSchema, z.string()]).default(""),
|
|
428
|
+
updateTime: z.union([HMTimestampSchema, z.string()]).default(""),
|
|
429
|
+
metadata: HMDocumentMetadataSchema,
|
|
430
|
+
detachedBlocks: z.record(z.string(), HMBlockNodeSchema).optional(),
|
|
431
|
+
genesis: z.string(),
|
|
432
|
+
generationInfo: HMGenerationInfoSchema.optional(),
|
|
433
|
+
visibility: HMResourceVisibilitySchema
|
|
434
|
+
});
|
|
435
|
+
var HMResourceDocumentSchema = z.object({
|
|
436
|
+
type: z.literal("document"),
|
|
437
|
+
document: HMDocumentSchema,
|
|
438
|
+
id: unpackedHmIdSchema
|
|
439
|
+
});
|
|
440
|
+
var HMResourceCommentSchema = z.object({
|
|
441
|
+
type: z.literal("comment"),
|
|
442
|
+
comment: HMCommentSchema,
|
|
443
|
+
id: unpackedHmIdSchema
|
|
444
|
+
});
|
|
445
|
+
var HMResourceRedirectSchema = z.object({
|
|
446
|
+
type: z.literal("redirect"),
|
|
447
|
+
id: unpackedHmIdSchema,
|
|
448
|
+
redirectTarget: unpackedHmIdSchema
|
|
449
|
+
});
|
|
450
|
+
var HMResourceNotFoundSchema = z.object({
|
|
451
|
+
type: z.literal("not-found"),
|
|
452
|
+
id: unpackedHmIdSchema
|
|
453
|
+
});
|
|
454
|
+
var HMResourceTombstoneSchema = z.object({
|
|
455
|
+
type: z.literal("tombstone"),
|
|
456
|
+
id: unpackedHmIdSchema
|
|
457
|
+
});
|
|
458
|
+
var HMResourceErrorSchema = z.object({
|
|
459
|
+
type: z.literal("error"),
|
|
460
|
+
id: unpackedHmIdSchema,
|
|
461
|
+
message: z.string()
|
|
462
|
+
});
|
|
463
|
+
var HMResourceSchema = z.discriminatedUnion("type", [
|
|
464
|
+
HMResourceDocumentSchema,
|
|
465
|
+
HMResourceCommentSchema,
|
|
466
|
+
// todo: Contact, Capability
|
|
467
|
+
HMResourceRedirectSchema,
|
|
468
|
+
// what if there is a profile ALIAS? how is that different from a home doc redirect?
|
|
469
|
+
HMResourceNotFoundSchema,
|
|
470
|
+
HMResourceTombstoneSchema,
|
|
471
|
+
HMResourceErrorSchema
|
|
472
|
+
]);
|
|
473
|
+
var HMResolvedResourceSchema = z.discriminatedUnion("type", [
|
|
474
|
+
HMResourceDocumentSchema,
|
|
475
|
+
HMResourceCommentSchema,
|
|
476
|
+
HMResourceTombstoneSchema
|
|
477
|
+
]);
|
|
478
|
+
var HMContactRecordSchema = z.object({
|
|
479
|
+
id: z.string(),
|
|
480
|
+
subject: z.string(),
|
|
481
|
+
name: z.string(),
|
|
482
|
+
account: z.string(),
|
|
483
|
+
createTime: HMTimestampSchema.optional(),
|
|
484
|
+
updateTime: HMTimestampSchema.optional()
|
|
485
|
+
});
|
|
486
|
+
var HMAccountContactsRequestSchema = z.object({
|
|
487
|
+
key: z.literal("AccountContacts"),
|
|
488
|
+
input: z.string(),
|
|
489
|
+
// account UID
|
|
490
|
+
output: z.array(HMContactRecordSchema)
|
|
491
|
+
});
|
|
492
|
+
var HMSubjectContactsRequestSchema = z.object({
|
|
493
|
+
key: z.literal("SubjectContacts"),
|
|
494
|
+
input: z.string(),
|
|
495
|
+
// subject UID
|
|
496
|
+
output: z.array(HMContactRecordSchema)
|
|
497
|
+
});
|
|
498
|
+
var HMResourceRequestSchema = z.object({
|
|
499
|
+
key: z.literal("Resource"),
|
|
500
|
+
input: unpackedHmIdSchema,
|
|
501
|
+
output: HMResourceSchema
|
|
502
|
+
});
|
|
503
|
+
var HMResourceMetadataRequestSchema = z.object({
|
|
504
|
+
key: z.literal("ResourceMetadata"),
|
|
505
|
+
input: unpackedHmIdSchema,
|
|
506
|
+
output: HMMetadataPayloadSchema
|
|
507
|
+
});
|
|
508
|
+
var HMAccountRequestSchema = z.object({
|
|
509
|
+
key: z.literal("Account"),
|
|
510
|
+
input: z.string(),
|
|
511
|
+
output: HMAccountResultSchema
|
|
512
|
+
});
|
|
513
|
+
var HMCommentRequestSchema = z.object({
|
|
514
|
+
key: z.literal("Comment"),
|
|
515
|
+
input: z.string(),
|
|
516
|
+
output: HMCommentSchema
|
|
517
|
+
});
|
|
518
|
+
var HMSearchInputSchema = z.object({
|
|
519
|
+
query: z.string(),
|
|
520
|
+
accountUid: z.string().optional(),
|
|
521
|
+
includeBody: z.boolean().optional(),
|
|
522
|
+
contextSize: z.number().optional(),
|
|
523
|
+
perspectiveAccountUid: z.string().optional(),
|
|
524
|
+
searchType: z.number().optional()
|
|
525
|
+
});
|
|
526
|
+
var HMSearchResultItemSchema = z.object({
|
|
527
|
+
id: unpackedHmIdSchema,
|
|
528
|
+
metadata: HMDocumentMetadataSchema.optional(),
|
|
529
|
+
title: z.string(),
|
|
530
|
+
icon: z.string(),
|
|
531
|
+
parentNames: z.array(z.string()),
|
|
532
|
+
versionTime: z.any().optional(),
|
|
533
|
+
searchQuery: z.string(),
|
|
534
|
+
type: z.enum(["document", "contact"])
|
|
535
|
+
});
|
|
536
|
+
var HMSearchPayloadSchema = z.object({
|
|
537
|
+
entities: z.array(HMSearchResultItemSchema),
|
|
538
|
+
searchQuery: z.string()
|
|
539
|
+
});
|
|
540
|
+
var HMSearchRequestSchema = z.object({
|
|
541
|
+
key: z.literal("Search"),
|
|
542
|
+
input: HMSearchInputSchema,
|
|
543
|
+
output: HMSearchPayloadSchema
|
|
544
|
+
});
|
|
545
|
+
var HMQueryRequestSchema = z.object({
|
|
546
|
+
key: z.literal("Query"),
|
|
547
|
+
input: HMQuerySchema,
|
|
548
|
+
output: HMQueryResultSchema.nullable()
|
|
549
|
+
});
|
|
550
|
+
var HMListCommentsInputSchema = z.object({
|
|
551
|
+
targetId: unpackedHmIdSchema
|
|
552
|
+
});
|
|
553
|
+
var HMListCommentsOutputSchema = z.object({
|
|
554
|
+
comments: z.array(HMCommentSchema),
|
|
555
|
+
authors: z.record(z.string(), HMMetadataPayloadSchema)
|
|
556
|
+
});
|
|
557
|
+
var HMListCommentsRequestSchema = z.object({
|
|
558
|
+
key: z.literal("ListComments"),
|
|
559
|
+
input: HMListCommentsInputSchema,
|
|
560
|
+
output: HMListCommentsOutputSchema
|
|
561
|
+
});
|
|
562
|
+
var HMListDiscussionsInputSchema = z.object({
|
|
563
|
+
targetId: unpackedHmIdSchema,
|
|
564
|
+
commentId: z.string().optional()
|
|
565
|
+
});
|
|
566
|
+
var HMListDiscussionsOutputSchema = z.object({
|
|
567
|
+
discussions: z.array(HMCommentGroupSchema),
|
|
568
|
+
authors: z.record(z.string(), HMMetadataPayloadSchema),
|
|
569
|
+
citingDiscussions: z.array(HMExternalCommentGroupSchema)
|
|
570
|
+
});
|
|
571
|
+
var HMListDiscussionsRequestSchema = z.object({
|
|
572
|
+
key: z.literal("ListDiscussions"),
|
|
573
|
+
input: HMListDiscussionsInputSchema,
|
|
574
|
+
output: HMListDiscussionsOutputSchema
|
|
575
|
+
});
|
|
576
|
+
var HMListCommentsByReferenceInputSchema = z.object({
|
|
577
|
+
targetId: unpackedHmIdSchema
|
|
578
|
+
});
|
|
579
|
+
var HMListCommentsByReferenceRequestSchema = z.object({
|
|
580
|
+
key: z.literal("ListCommentsByReference"),
|
|
581
|
+
input: HMListCommentsByReferenceInputSchema,
|
|
582
|
+
output: HMListCommentsOutputSchema
|
|
583
|
+
});
|
|
584
|
+
var HMGetCommentReplyCountInputSchema = z.object({
|
|
585
|
+
id: z.string()
|
|
586
|
+
});
|
|
587
|
+
var HMGetCommentReplyCountRequestSchema = z.object({
|
|
588
|
+
key: z.literal("GetCommentReplyCount"),
|
|
589
|
+
input: HMGetCommentReplyCountInputSchema,
|
|
590
|
+
output: z.number()
|
|
591
|
+
});
|
|
592
|
+
var HMListEventsInputSchema = z.object({
|
|
593
|
+
pageSize: z.number().optional(),
|
|
594
|
+
pageToken: z.string().optional(),
|
|
595
|
+
trustedOnly: z.boolean().optional(),
|
|
596
|
+
filterAuthors: z.array(z.string()).optional(),
|
|
597
|
+
filterEventType: z.array(z.string()).optional(),
|
|
598
|
+
filterResource: z.string().optional(),
|
|
599
|
+
currentAccount: z.string().optional()
|
|
600
|
+
});
|
|
601
|
+
var HMLoadedEventSchema = z.object({}).passthrough();
|
|
602
|
+
var HMListEventsOutputSchema = z.object({
|
|
603
|
+
events: z.array(HMLoadedEventSchema),
|
|
604
|
+
nextPageToken: z.string()
|
|
605
|
+
});
|
|
606
|
+
var HMListEventsRequestSchema = z.object({
|
|
607
|
+
key: z.literal("ListEvents"),
|
|
608
|
+
input: HMListEventsInputSchema,
|
|
609
|
+
output: HMListEventsOutputSchema
|
|
610
|
+
});
|
|
611
|
+
var HMListAccountsOutputSchema = z.object({
|
|
612
|
+
accounts: z.array(HMMetadataPayloadSchema)
|
|
613
|
+
});
|
|
614
|
+
var HMListAccountsInputSchema = z.object({}).optional();
|
|
615
|
+
var HMListAccountsRequestSchema = z.object({
|
|
616
|
+
key: z.literal("ListAccounts"),
|
|
617
|
+
input: HMListAccountsInputSchema,
|
|
618
|
+
output: HMListAccountsOutputSchema
|
|
619
|
+
});
|
|
620
|
+
var HMGetCIDOutputSchema = z.object({
|
|
621
|
+
value: z.any()
|
|
622
|
+
});
|
|
623
|
+
var HMGetCIDInputSchema = z.object({
|
|
624
|
+
cid: z.string()
|
|
625
|
+
});
|
|
626
|
+
var HMGetCIDRequestSchema = z.object({
|
|
627
|
+
key: z.literal("GetCID"),
|
|
628
|
+
input: HMGetCIDInputSchema,
|
|
629
|
+
output: HMGetCIDOutputSchema
|
|
630
|
+
});
|
|
631
|
+
var HMListCommentsByAuthorOutputSchema = z.object({
|
|
632
|
+
comments: z.array(HMCommentSchema),
|
|
633
|
+
authors: z.record(z.string(), HMMetadataPayloadSchema)
|
|
634
|
+
});
|
|
635
|
+
var HMListCommentsByAuthorInputSchema = z.object({
|
|
636
|
+
authorId: unpackedHmIdSchema
|
|
637
|
+
});
|
|
638
|
+
var HMListCommentsByAuthorRequestSchema = z.object({
|
|
639
|
+
key: z.literal("ListCommentsByAuthor"),
|
|
640
|
+
input: HMListCommentsByAuthorInputSchema,
|
|
641
|
+
output: HMListCommentsByAuthorOutputSchema
|
|
642
|
+
});
|
|
643
|
+
var HMRawMentionSchema = z.object({
|
|
644
|
+
source: z.string(),
|
|
645
|
+
sourceType: z.string().optional(),
|
|
646
|
+
sourceDocument: z.string().optional(),
|
|
647
|
+
targetFragment: z.string().optional(),
|
|
648
|
+
isExact: z.boolean().optional()
|
|
649
|
+
});
|
|
650
|
+
var HMListCitationsOutputSchema = z.object({
|
|
651
|
+
citations: z.array(HMRawMentionSchema)
|
|
652
|
+
});
|
|
653
|
+
var HMListCitationsInputSchema = z.object({
|
|
654
|
+
targetId: unpackedHmIdSchema
|
|
655
|
+
});
|
|
656
|
+
var HMListCitationsRequestSchema = z.object({
|
|
657
|
+
key: z.literal("ListCitations"),
|
|
658
|
+
input: HMListCitationsInputSchema,
|
|
659
|
+
output: HMListCitationsOutputSchema
|
|
660
|
+
});
|
|
661
|
+
var HMRawDocumentChangeSchema = z.object({
|
|
662
|
+
id: z.string().optional(),
|
|
663
|
+
author: z.string().optional(),
|
|
664
|
+
deps: z.array(z.string()).optional(),
|
|
665
|
+
createTime: z.string().optional()
|
|
666
|
+
});
|
|
667
|
+
var HMListChangesOutputSchema = z.object({
|
|
668
|
+
changes: z.array(HMRawDocumentChangeSchema),
|
|
669
|
+
latestVersion: z.string().optional()
|
|
670
|
+
});
|
|
671
|
+
var HMListChangesInputSchema = z.object({
|
|
672
|
+
targetId: unpackedHmIdSchema
|
|
673
|
+
});
|
|
674
|
+
var HMListChangesRequestSchema = z.object({
|
|
675
|
+
key: z.literal("ListChanges"),
|
|
676
|
+
input: HMListChangesInputSchema,
|
|
677
|
+
output: HMListChangesOutputSchema
|
|
678
|
+
});
|
|
679
|
+
var HMRawCapabilitySchema = z.object({
|
|
680
|
+
id: z.string().optional(),
|
|
681
|
+
issuer: z.string().optional(),
|
|
682
|
+
delegate: z.string().optional(),
|
|
683
|
+
account: z.string().optional(),
|
|
684
|
+
path: z.string().optional(),
|
|
685
|
+
role: z.string().optional(),
|
|
686
|
+
noRecursive: z.boolean().optional(),
|
|
687
|
+
label: z.string().optional(),
|
|
688
|
+
createTime: z.string().optional()
|
|
689
|
+
});
|
|
690
|
+
var HMListCapabilitiesOutputSchema = z.object({
|
|
691
|
+
capabilities: z.array(HMRawCapabilitySchema)
|
|
692
|
+
});
|
|
693
|
+
var HMListCapabilitiesInputSchema = z.object({
|
|
694
|
+
targetId: unpackedHmIdSchema
|
|
695
|
+
});
|
|
696
|
+
var HMListCapabilitiesRequestSchema = z.object({
|
|
697
|
+
key: z.literal("ListCapabilities"),
|
|
698
|
+
input: HMListCapabilitiesInputSchema,
|
|
699
|
+
output: HMListCapabilitiesOutputSchema
|
|
700
|
+
});
|
|
701
|
+
var HMInteractionSummaryInputSchema = z.object({
|
|
702
|
+
id: unpackedHmIdSchema
|
|
703
|
+
});
|
|
704
|
+
var HMInteractionSummaryOutputSchema = z.object({
|
|
705
|
+
citations: z.number(),
|
|
706
|
+
comments: z.number(),
|
|
707
|
+
changes: z.number(),
|
|
708
|
+
children: z.number(),
|
|
709
|
+
blocks: z.record(
|
|
710
|
+
z.string(),
|
|
711
|
+
z.object({
|
|
712
|
+
citations: z.number(),
|
|
713
|
+
comments: z.number()
|
|
714
|
+
})
|
|
715
|
+
)
|
|
716
|
+
});
|
|
717
|
+
var HMInteractionSummaryRequestSchema = z.object({
|
|
718
|
+
key: z.literal("InteractionSummary"),
|
|
719
|
+
input: HMInteractionSummaryInputSchema,
|
|
720
|
+
output: HMInteractionSummaryOutputSchema
|
|
721
|
+
});
|
|
722
|
+
var HMPublishBlobsOutputSchema = z.object({
|
|
723
|
+
cids: z.array(z.string())
|
|
724
|
+
});
|
|
725
|
+
var HMPublishBlobsInputSchema = z.object({
|
|
726
|
+
blobs: z.array(
|
|
727
|
+
z.object({
|
|
728
|
+
cid: z.string().optional(),
|
|
729
|
+
data: z.custom((val) => ArrayBuffer.isView(val) && "byteLength" in val, {
|
|
730
|
+
message: "Expected Uint8Array or compatible binary data"
|
|
731
|
+
})
|
|
732
|
+
})
|
|
733
|
+
)
|
|
734
|
+
});
|
|
735
|
+
var HMPublishBlobsRequestSchema = z.object({
|
|
736
|
+
key: z.literal("PublishBlobs"),
|
|
737
|
+
input: HMPublishBlobsInputSchema,
|
|
738
|
+
output: HMPublishBlobsOutputSchema
|
|
739
|
+
});
|
|
740
|
+
var ProtoAnnotationSchema = z.object({
|
|
741
|
+
type: z.string(),
|
|
742
|
+
link: z.string().optional(),
|
|
743
|
+
attributes: z.record(z.string(), z.any()).optional(),
|
|
744
|
+
starts: z.array(z.number()).optional(),
|
|
745
|
+
ends: z.array(z.number()).optional()
|
|
746
|
+
});
|
|
747
|
+
var ProtoBlockSchema = z.object({
|
|
748
|
+
id: z.string().optional(),
|
|
749
|
+
type: z.string().optional(),
|
|
750
|
+
text: z.string().optional(),
|
|
751
|
+
link: z.string().optional(),
|
|
752
|
+
attributes: z.record(z.string(), z.any()).optional(),
|
|
753
|
+
annotations: z.array(ProtoAnnotationSchema).optional(),
|
|
754
|
+
revision: z.string().optional()
|
|
755
|
+
});
|
|
756
|
+
var ProtoSetAttributeValueSchema = z.union([
|
|
757
|
+
z.object({ case: z.literal("stringValue"), value: z.string() }),
|
|
758
|
+
z.object({ case: z.literal("intValue"), value: z.union([z.bigint(), z.coerce.bigint()]) }),
|
|
759
|
+
z.object({ case: z.literal("boolValue"), value: z.boolean() }),
|
|
760
|
+
z.object({ case: z.literal("nullValue"), value: z.object({}) }),
|
|
761
|
+
z.object({ case: z.undefined(), value: z.undefined().optional() })
|
|
762
|
+
]);
|
|
763
|
+
var ProtoDocumentChangeSchema = z.object({
|
|
764
|
+
op: z.union([
|
|
765
|
+
z.object({ case: z.literal("setMetadata"), value: z.object({ key: z.string(), value: z.string() }) }),
|
|
766
|
+
z.object({
|
|
767
|
+
case: z.literal("moveBlock"),
|
|
768
|
+
value: z.object({ blockId: z.string(), parent: z.string(), leftSibling: z.string() })
|
|
769
|
+
}),
|
|
770
|
+
z.object({ case: z.literal("replaceBlock"), value: ProtoBlockSchema }),
|
|
771
|
+
z.object({ case: z.literal("deleteBlock"), value: z.string() }),
|
|
772
|
+
z.object({
|
|
773
|
+
case: z.literal("setAttribute"),
|
|
774
|
+
value: z.object({ blockId: z.string(), key: z.array(z.string()), value: ProtoSetAttributeValueSchema })
|
|
775
|
+
}),
|
|
776
|
+
z.object({ case: z.undefined(), value: z.undefined().optional() })
|
|
777
|
+
])
|
|
778
|
+
});
|
|
779
|
+
var HMPrepareDocumentChangeInputSchema = z.object({
|
|
780
|
+
account: z.string(),
|
|
781
|
+
path: z.string().optional(),
|
|
782
|
+
baseVersion: z.string().optional(),
|
|
783
|
+
changes: z.array(ProtoDocumentChangeSchema),
|
|
784
|
+
capability: z.string().optional(),
|
|
785
|
+
visibility: z.number().int().optional()
|
|
786
|
+
});
|
|
787
|
+
var HMPrepareDocumentChangeOutputSchema = z.object({
|
|
788
|
+
unsignedChange: z.custom((val) => ArrayBuffer.isView(val) && "byteLength" in val, {
|
|
789
|
+
message: "Expected Uint8Array or compatible binary data"
|
|
790
|
+
})
|
|
791
|
+
});
|
|
792
|
+
var HMPrepareDocumentChangeRequestSchema = z.object({
|
|
793
|
+
key: z.literal("PrepareDocumentChange"),
|
|
794
|
+
input: HMPrepareDocumentChangeInputSchema,
|
|
795
|
+
output: HMPrepareDocumentChangeOutputSchema
|
|
796
|
+
});
|
|
797
|
+
var HMGetRequestSchema = z.discriminatedUnion("key", [
|
|
798
|
+
HMResourceRequestSchema,
|
|
799
|
+
HMResourceMetadataRequestSchema,
|
|
800
|
+
HMAccountRequestSchema,
|
|
801
|
+
HMCommentRequestSchema,
|
|
802
|
+
HMSearchRequestSchema,
|
|
803
|
+
HMQueryRequestSchema,
|
|
804
|
+
HMAccountContactsRequestSchema,
|
|
805
|
+
HMSubjectContactsRequestSchema,
|
|
806
|
+
HMListCommentsRequestSchema,
|
|
807
|
+
HMListDiscussionsRequestSchema,
|
|
808
|
+
HMListCommentsByReferenceRequestSchema,
|
|
809
|
+
HMGetCommentReplyCountRequestSchema,
|
|
810
|
+
HMListEventsRequestSchema,
|
|
811
|
+
HMListAccountsRequestSchema,
|
|
812
|
+
HMGetCIDRequestSchema,
|
|
813
|
+
HMListCommentsByAuthorRequestSchema,
|
|
814
|
+
HMListCitationsRequestSchema,
|
|
815
|
+
HMListChangesRequestSchema,
|
|
816
|
+
HMListCapabilitiesRequestSchema,
|
|
817
|
+
HMInteractionSummaryRequestSchema
|
|
818
|
+
]);
|
|
819
|
+
var HMActionSchema = z.discriminatedUnion("key", [
|
|
820
|
+
HMPublishBlobsRequestSchema,
|
|
821
|
+
HMPrepareDocumentChangeRequestSchema
|
|
822
|
+
]);
|
|
823
|
+
var HMRequestSchema = z.discriminatedUnion("key", [
|
|
824
|
+
HMResourceRequestSchema,
|
|
825
|
+
HMResourceMetadataRequestSchema,
|
|
826
|
+
HMAccountRequestSchema,
|
|
827
|
+
HMCommentRequestSchema,
|
|
828
|
+
HMSearchRequestSchema,
|
|
829
|
+
HMQueryRequestSchema,
|
|
830
|
+
HMAccountContactsRequestSchema,
|
|
831
|
+
HMSubjectContactsRequestSchema,
|
|
832
|
+
HMListCommentsRequestSchema,
|
|
833
|
+
HMListDiscussionsRequestSchema,
|
|
834
|
+
HMListCommentsByReferenceRequestSchema,
|
|
835
|
+
HMGetCommentReplyCountRequestSchema,
|
|
836
|
+
HMListEventsRequestSchema,
|
|
837
|
+
HMListAccountsRequestSchema,
|
|
838
|
+
HMGetCIDRequestSchema,
|
|
839
|
+
HMListCommentsByAuthorRequestSchema,
|
|
840
|
+
HMListCitationsRequestSchema,
|
|
841
|
+
HMListChangesRequestSchema,
|
|
842
|
+
HMListCapabilitiesRequestSchema,
|
|
843
|
+
HMInteractionSummaryRequestSchema,
|
|
844
|
+
HMPublishBlobsRequestSchema,
|
|
845
|
+
HMPrepareDocumentChangeRequestSchema
|
|
846
|
+
]);
|
|
847
|
+
var HYPERMEDIA_SCHEME = "hm";
|
|
848
|
+
function packBaseId(uid, path) {
|
|
849
|
+
const filteredPath = (path == null ? void 0 : path.filter((p) => p !== "")) || [];
|
|
850
|
+
const restPath = filteredPath.length ? `/${filteredPath.join("/")}` : "";
|
|
851
|
+
return `${HYPERMEDIA_SCHEME}://${uid}${restPath}`;
|
|
852
|
+
}
|
|
853
|
+
function packHmId(hmId) {
|
|
854
|
+
const { path, version, latest, blockRef, blockRange, uid } = hmId;
|
|
855
|
+
if (!uid) throw new Error("uid is required");
|
|
856
|
+
let responseUrl = packBaseId(uid, path);
|
|
857
|
+
responseUrl += getHMQueryString({
|
|
858
|
+
version,
|
|
859
|
+
latest
|
|
860
|
+
});
|
|
861
|
+
if (blockRef) {
|
|
862
|
+
responseUrl += `#${blockRef}${serializeBlockRange(blockRange)}`;
|
|
863
|
+
}
|
|
864
|
+
return responseUrl;
|
|
865
|
+
}
|
|
866
|
+
function getHMQueryString({
|
|
867
|
+
version,
|
|
868
|
+
latest,
|
|
869
|
+
panel
|
|
870
|
+
}) {
|
|
871
|
+
const query = {};
|
|
872
|
+
if (version) {
|
|
873
|
+
query.v = version;
|
|
874
|
+
}
|
|
875
|
+
if (latest) {
|
|
876
|
+
query.l = null;
|
|
877
|
+
}
|
|
878
|
+
if (panel) {
|
|
879
|
+
query.panel = panel;
|
|
880
|
+
}
|
|
881
|
+
return serializeHmQueryString(query);
|
|
882
|
+
}
|
|
883
|
+
function serializeBlockRange(range) {
|
|
884
|
+
let res = "";
|
|
885
|
+
if (range) {
|
|
886
|
+
if ("expanded" in range && range.expanded) {
|
|
887
|
+
res += "+";
|
|
888
|
+
} else if ("start" in range) {
|
|
889
|
+
res += `[${range.start}:${range.end}]`;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return res;
|
|
893
|
+
}
|
|
894
|
+
function serializeHmQueryString(query) {
|
|
895
|
+
const queryString = Object.entries(query).map(([key, value]) => value === null ? key : `${key}=${value}`).join("&");
|
|
896
|
+
if (!queryString) return "";
|
|
897
|
+
return `?${queryString}`;
|
|
898
|
+
}
|
|
899
|
+
function hmIdPathToEntityQueryPath(path) {
|
|
900
|
+
const filteredPath = path == null ? void 0 : path.filter((term) => !!term);
|
|
901
|
+
return (filteredPath == null ? void 0 : filteredPath.length) ? `/${filteredPath.join("/")}` : "";
|
|
902
|
+
}
|
|
903
|
+
function entityQueryPathToHmIdPath(path) {
|
|
904
|
+
if (!path) return [];
|
|
905
|
+
if (path === "/") return [];
|
|
906
|
+
return path.split("/").filter(Boolean);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
export {
|
|
910
|
+
BlockRangeSchema,
|
|
911
|
+
unpackedHmIdSchema,
|
|
912
|
+
HMBlockChildrenTypeSchema,
|
|
913
|
+
HMEmbedViewSchema,
|
|
914
|
+
HMQueryStyleSchema,
|
|
915
|
+
BoldAnnotationSchema,
|
|
916
|
+
ItalicAnnotationSchema,
|
|
917
|
+
UnderlineAnnotationSchema,
|
|
918
|
+
StrikeAnnotationSchema,
|
|
919
|
+
CodeAnnotationSchema,
|
|
920
|
+
LinkAnnotationSchema,
|
|
921
|
+
InlineEmbedAnnotationSchema,
|
|
922
|
+
HighlightAnnotationSchema,
|
|
923
|
+
HMAnnotationSchema,
|
|
924
|
+
HMAnnotationsSchema,
|
|
925
|
+
HMBlockParagraphSchema,
|
|
926
|
+
HMBlockHeadingSchema,
|
|
927
|
+
HMBlockCodeSchema,
|
|
928
|
+
HMBlockMathSchema,
|
|
929
|
+
toNumber,
|
|
930
|
+
HMBlockImageSchema,
|
|
931
|
+
HMBlockVideoSchema,
|
|
932
|
+
HMBlockFileSchema,
|
|
933
|
+
HMBlockButtonAlignmentSchema,
|
|
934
|
+
HMBlockButtonSchema,
|
|
935
|
+
HMBlockEmbedSchema,
|
|
936
|
+
HMBlockWebEmbedSchema,
|
|
937
|
+
HMBlockNostrSchema,
|
|
938
|
+
HMTimestampSchema,
|
|
939
|
+
HMBlockNodeSchema,
|
|
940
|
+
HMDocumentMetadataSchema,
|
|
941
|
+
hmMetadataJsonCorrection,
|
|
942
|
+
HMResourceVisibilitySchema,
|
|
943
|
+
HMCommentSchema,
|
|
944
|
+
HMBreadcrumbSchema,
|
|
945
|
+
HMCommentGroupSchema,
|
|
946
|
+
HMExternalCommentGroupSchema,
|
|
947
|
+
HMActivitySummarySchema,
|
|
948
|
+
HMGenerationInfoSchema,
|
|
949
|
+
HMRedirectInfoSchema,
|
|
950
|
+
HMDocumentInfoSchema,
|
|
951
|
+
HMQueryResultSchema,
|
|
952
|
+
HMRoleSchema,
|
|
953
|
+
HMMetadataPayloadSchema,
|
|
954
|
+
HMAccountPayloadSchema,
|
|
955
|
+
HMAccountNotFoundSchema,
|
|
956
|
+
HMAccountResultSchema,
|
|
957
|
+
HMAccountsMetadataSchema,
|
|
958
|
+
HMQueryInclusionSchema,
|
|
959
|
+
HMQuerySortSchema,
|
|
960
|
+
HMQuerySchema,
|
|
961
|
+
HMBlockQuerySchema,
|
|
962
|
+
HMBlockGroupSchema,
|
|
963
|
+
HMBlockLinkSchema,
|
|
964
|
+
HMBlockKnownSchema,
|
|
965
|
+
HMBlockUnknownSchema,
|
|
966
|
+
HMBlockSchema,
|
|
967
|
+
knownBlockTypes,
|
|
968
|
+
isKnownBlockType,
|
|
969
|
+
HMDocumentSchema,
|
|
970
|
+
HMResourceDocumentSchema,
|
|
971
|
+
HMResourceCommentSchema,
|
|
972
|
+
HMResourceRedirectSchema,
|
|
973
|
+
HMResourceNotFoundSchema,
|
|
974
|
+
HMResourceTombstoneSchema,
|
|
975
|
+
HMResourceErrorSchema,
|
|
976
|
+
HMResourceSchema,
|
|
977
|
+
HMResolvedResourceSchema,
|
|
978
|
+
HMContactRecordSchema,
|
|
979
|
+
HMAccountContactsRequestSchema,
|
|
980
|
+
HMSubjectContactsRequestSchema,
|
|
981
|
+
HMResourceRequestSchema,
|
|
982
|
+
HMResourceMetadataRequestSchema,
|
|
983
|
+
HMAccountRequestSchema,
|
|
984
|
+
HMCommentRequestSchema,
|
|
985
|
+
HMSearchInputSchema,
|
|
986
|
+
HMSearchResultItemSchema,
|
|
987
|
+
HMSearchPayloadSchema,
|
|
988
|
+
HMSearchRequestSchema,
|
|
989
|
+
HMQueryRequestSchema,
|
|
990
|
+
HMListCommentsInputSchema,
|
|
991
|
+
HMListCommentsOutputSchema,
|
|
992
|
+
HMListCommentsRequestSchema,
|
|
993
|
+
HMListDiscussionsInputSchema,
|
|
994
|
+
HMListDiscussionsOutputSchema,
|
|
995
|
+
HMListDiscussionsRequestSchema,
|
|
996
|
+
HMListCommentsByReferenceInputSchema,
|
|
997
|
+
HMListCommentsByReferenceRequestSchema,
|
|
998
|
+
HMGetCommentReplyCountInputSchema,
|
|
999
|
+
HMGetCommentReplyCountRequestSchema,
|
|
1000
|
+
HMListEventsInputSchema,
|
|
1001
|
+
HMLoadedEventSchema,
|
|
1002
|
+
HMListEventsOutputSchema,
|
|
1003
|
+
HMListEventsRequestSchema,
|
|
1004
|
+
HMListAccountsOutputSchema,
|
|
1005
|
+
HMListAccountsInputSchema,
|
|
1006
|
+
HMListAccountsRequestSchema,
|
|
1007
|
+
HMGetCIDOutputSchema,
|
|
1008
|
+
HMGetCIDInputSchema,
|
|
1009
|
+
HMGetCIDRequestSchema,
|
|
1010
|
+
HMListCommentsByAuthorOutputSchema,
|
|
1011
|
+
HMListCommentsByAuthorInputSchema,
|
|
1012
|
+
HMListCommentsByAuthorRequestSchema,
|
|
1013
|
+
HMRawMentionSchema,
|
|
1014
|
+
HMListCitationsOutputSchema,
|
|
1015
|
+
HMListCitationsInputSchema,
|
|
1016
|
+
HMListCitationsRequestSchema,
|
|
1017
|
+
HMRawDocumentChangeSchema,
|
|
1018
|
+
HMListChangesOutputSchema,
|
|
1019
|
+
HMListChangesInputSchema,
|
|
1020
|
+
HMListChangesRequestSchema,
|
|
1021
|
+
HMRawCapabilitySchema,
|
|
1022
|
+
HMListCapabilitiesOutputSchema,
|
|
1023
|
+
HMListCapabilitiesInputSchema,
|
|
1024
|
+
HMListCapabilitiesRequestSchema,
|
|
1025
|
+
HMInteractionSummaryInputSchema,
|
|
1026
|
+
HMInteractionSummaryOutputSchema,
|
|
1027
|
+
HMInteractionSummaryRequestSchema,
|
|
1028
|
+
HMPublishBlobsOutputSchema,
|
|
1029
|
+
HMPublishBlobsInputSchema,
|
|
1030
|
+
HMPublishBlobsRequestSchema,
|
|
1031
|
+
HMPrepareDocumentChangeInputSchema,
|
|
1032
|
+
HMPrepareDocumentChangeOutputSchema,
|
|
1033
|
+
HMPrepareDocumentChangeRequestSchema,
|
|
1034
|
+
HMGetRequestSchema,
|
|
1035
|
+
HMActionSchema,
|
|
1036
|
+
HMRequestSchema,
|
|
1037
|
+
HYPERMEDIA_SCHEME,
|
|
1038
|
+
packBaseId,
|
|
1039
|
+
packHmId,
|
|
1040
|
+
getHMQueryString,
|
|
1041
|
+
serializeBlockRange,
|
|
1042
|
+
hmIdPathToEntityQueryPath,
|
|
1043
|
+
entityQueryPathToHmIdPath
|
|
1044
|
+
};
|