@hiai-gg/docsmint 0.3.0
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 +171 -0
- package/README.md +348 -0
- package/backend/src/lib/logger.ts +18 -0
- package/backend/src/lib/redis-factory.ts +40 -0
- package/backend/src/lib/storage-factory.ts +56 -0
- package/frontend/src/lib/components/editor/shared-document.ts +237 -0
- package/frontend/src/lib/extensions/context.ts +60 -0
- package/frontend/src/lib/extensions/doc-tabs.ts +18 -0
- package/frontend/src/lib/extensions/resolve.ts +48 -0
- package/frontend/src/lib/extensions/types.ts +202 -0
- package/frontend/src/lib/hosts/DocsmintSharedDocumentHost.svelte +65 -0
- package/frontend/src/lib/hosts/HiaiDocsDashboardHost.svelte +1007 -0
- package/frontend/src/lib/hosts/HiaiDocsExtensionProvider.svelte +20 -0
- package/frontend/src/lib/hosts/HiaiDocsSearchHost.svelte +996 -0
- package/frontend/src/lib/hosts/index.ts +25 -0
- package/frontend/src/lib/index.ts +65 -0
- package/frontend/src/lib/stores/doc-tab-registry.svelte.ts +68 -0
- package/package.json +178 -0
- package/packages/cli/src/client.ts +271 -0
- package/packages/cli/src/commands/config.ts +47 -0
- package/packages/cli/src/commands/create.ts +35 -0
- package/packages/cli/src/commands/delete.ts +37 -0
- package/packages/cli/src/commands/export.ts +36 -0
- package/packages/cli/src/commands/folders.ts +88 -0
- package/packages/cli/src/commands/history.ts +55 -0
- package/packages/cli/src/commands/list.ts +61 -0
- package/packages/cli/src/commands/read.ts +38 -0
- package/packages/cli/src/commands/restore.ts +30 -0
- package/packages/cli/src/commands/search.ts +56 -0
- package/packages/cli/src/commands/snapshot.ts +35 -0
- package/packages/cli/src/commands/update.ts +54 -0
- package/packages/cli/src/config.ts +83 -0
- package/packages/cli/src/format.ts +153 -0
- package/packages/cli/src/index.ts +73 -0
- package/packages/db/src/client.ts +20 -0
- package/packages/db/src/index.ts +5 -0
- package/packages/db/src/schema.ts +692 -0
- package/packages/db/src/with-tenant.ts +75 -0
- package/packages/mcp-server/src/client.ts +172 -0
- package/packages/mcp-server/src/index.ts +109 -0
- package/packages/mcp-server/src/tools/create-document.ts +32 -0
- package/packages/mcp-server/src/tools/create-folder.ts +24 -0
- package/packages/mcp-server/src/tools/create-snapshot.ts +30 -0
- package/packages/mcp-server/src/tools/export-document.ts +22 -0
- package/packages/mcp-server/src/tools/get-document.ts +20 -0
- package/packages/mcp-server/src/tools/list-documents.ts +42 -0
- package/packages/mcp-server/src/tools/list-folders.ts +25 -0
- package/packages/mcp-server/src/tools/search.ts +42 -0
- package/packages/mcp-server/src/tools/update-document.ts +30 -0
- package/packages/mcp-server/src/tools/version-history.ts +32 -0
- package/packages/mcp-server/src/types.ts +126 -0
- package/packages/sdk/dist/client.d.ts +187 -0
- package/packages/sdk/dist/client.js +568 -0
- package/packages/sdk/dist/index.d.ts +3 -0
- package/packages/sdk/dist/index.js +1 -0
- package/packages/sdk/dist/types.d.ts +391 -0
- package/packages/sdk/dist/types.js +8 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the hiai-docs REST API.
|
|
3
|
+
*
|
|
4
|
+
* All shapes are derived from the actual Elysia routes in
|
|
5
|
+
* `backend/src/api/routes/` — keep this file in sync if the backend
|
|
6
|
+
* response shapes change.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Full document record returned by `GET /api/documents/:id` and the
|
|
10
|
+
* create / duplicate / update endpoints. The list endpoint returns a
|
|
11
|
+
* trimmed shape (`DocsDocumentListItem`) — `DocsDocumentListItem` is a
|
|
12
|
+
* structural superset of `DocsDocument` and the list item omits the
|
|
13
|
+
* full `content` (only the first 200 chars), `contentJson`, and
|
|
14
|
+
* `metadata` fields.
|
|
15
|
+
*/
|
|
16
|
+
export interface DocsDocument {
|
|
17
|
+
id: string;
|
|
18
|
+
ownerId: string;
|
|
19
|
+
folderId: string | null;
|
|
20
|
+
categoryId: string | null;
|
|
21
|
+
title: string;
|
|
22
|
+
content: string;
|
|
23
|
+
contentJson?: unknown;
|
|
24
|
+
metadata?: unknown;
|
|
25
|
+
visibility: DocsDocumentVisibility;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
tags?: DocsTag[];
|
|
29
|
+
folderName?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export type DocsDocumentVisibility = "private" | "shared" | "public";
|
|
32
|
+
export interface DocsDocumentCreateInput {
|
|
33
|
+
title?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
folderId?: string;
|
|
36
|
+
categoryId?: string | null;
|
|
37
|
+
visibility?: DocsDocumentVisibility;
|
|
38
|
+
}
|
|
39
|
+
export interface DocsDocumentUpdateInput {
|
|
40
|
+
title?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
contentJson?: unknown;
|
|
43
|
+
metadata?: unknown;
|
|
44
|
+
folderId?: string | null;
|
|
45
|
+
categoryId?: string | null;
|
|
46
|
+
visibility?: DocsDocumentVisibility;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Document item returned by `GET /api/documents` (list endpoint).
|
|
50
|
+
* `content` is truncated to 200 chars server-side, `contentJson` and
|
|
51
|
+
* `metadata` are not included.
|
|
52
|
+
*/
|
|
53
|
+
export interface DocsDocumentListItem {
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
content: string;
|
|
57
|
+
folderId: string | null;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
tags: DocsTag[];
|
|
61
|
+
}
|
|
62
|
+
export interface DocsDocumentListResponse {
|
|
63
|
+
items: DocsDocumentListItem[];
|
|
64
|
+
total: number;
|
|
65
|
+
page: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
}
|
|
68
|
+
export interface DocsFolder {
|
|
69
|
+
id: string;
|
|
70
|
+
ownerId: string;
|
|
71
|
+
parentId: string | null;
|
|
72
|
+
name: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
categoryId?: string | null;
|
|
76
|
+
order?: number;
|
|
77
|
+
documentCount?: number;
|
|
78
|
+
subfolderCount?: number;
|
|
79
|
+
children?: DocsFolder[];
|
|
80
|
+
documents?: DocsDocumentListItem[];
|
|
81
|
+
}
|
|
82
|
+
export interface DocsFolderCreateInput {
|
|
83
|
+
name: string;
|
|
84
|
+
parentId?: string | null;
|
|
85
|
+
categoryId?: string | null;
|
|
86
|
+
}
|
|
87
|
+
export interface DocsFolderUpdateInput {
|
|
88
|
+
name?: string;
|
|
89
|
+
parentId?: string | null;
|
|
90
|
+
categoryId?: string | null;
|
|
91
|
+
order?: number;
|
|
92
|
+
}
|
|
93
|
+
export type DocsCategoryApiMode = "unavailable" | "global" | "general" | "category";
|
|
94
|
+
export interface DocsCategory {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
order: number;
|
|
98
|
+
apiMode: DocsCategoryApiMode;
|
|
99
|
+
apiPermissionRead: boolean;
|
|
100
|
+
apiPermissionEdit: boolean;
|
|
101
|
+
apiPermissionWrite: boolean;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
updatedAt: string;
|
|
104
|
+
documentCount?: number;
|
|
105
|
+
folderCount?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface DocsCategoryInput {
|
|
108
|
+
name: string;
|
|
109
|
+
apiMode?: DocsCategoryApiMode;
|
|
110
|
+
apiPermissionRead?: boolean;
|
|
111
|
+
apiPermissionEdit?: boolean;
|
|
112
|
+
apiPermissionWrite?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface DocsCategoryUpdate extends Partial<DocsCategoryInput> {
|
|
115
|
+
order?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Full tag record returned by create / update / list.
|
|
119
|
+
* `listTags()` also returns `documentCount` and `createdAt`; create
|
|
120
|
+
* and update return the bare row. Both shapes are accommodated.
|
|
121
|
+
*/
|
|
122
|
+
export interface DocsTag {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
color: string | null;
|
|
126
|
+
createdAt?: string;
|
|
127
|
+
documentCount?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Search hit as returned by `GET /api/search`. The backend uses
|
|
131
|
+
* snake_case in the JSON payload — we mirror that exactly here so
|
|
132
|
+
* consumers don't need to remap.
|
|
133
|
+
*/
|
|
134
|
+
export interface DocsSearchResult {
|
|
135
|
+
id: string;
|
|
136
|
+
title: string;
|
|
137
|
+
snippet: string;
|
|
138
|
+
score: number;
|
|
139
|
+
folder_id: string | null;
|
|
140
|
+
folder_name: string | null;
|
|
141
|
+
created_at: string;
|
|
142
|
+
updated_at: string;
|
|
143
|
+
tags?: DocsTag[];
|
|
144
|
+
/** Top matching text chunks, present when `includeChunks=true`. */
|
|
145
|
+
chunks?: DocsSearchChunk[];
|
|
146
|
+
}
|
|
147
|
+
export interface DocsSearchChunk {
|
|
148
|
+
chunkIndex: number;
|
|
149
|
+
chunkText: string;
|
|
150
|
+
charStart: number;
|
|
151
|
+
charEnd: number;
|
|
152
|
+
score: number;
|
|
153
|
+
}
|
|
154
|
+
export interface DocsSearchResponse {
|
|
155
|
+
items: DocsSearchResult[];
|
|
156
|
+
total: number;
|
|
157
|
+
page: number;
|
|
158
|
+
limit: number;
|
|
159
|
+
}
|
|
160
|
+
export interface DocsSearchOptions {
|
|
161
|
+
folder?: string;
|
|
162
|
+
tags?: string;
|
|
163
|
+
category?: string;
|
|
164
|
+
dateFrom?: string;
|
|
165
|
+
dateTo?: string;
|
|
166
|
+
sort?: string;
|
|
167
|
+
page?: number;
|
|
168
|
+
limit?: number;
|
|
169
|
+
graph?: boolean;
|
|
170
|
+
graphHops?: number;
|
|
171
|
+
graphBoost?: number;
|
|
172
|
+
includeChunks?: boolean;
|
|
173
|
+
}
|
|
174
|
+
export interface DocsGraphEntity {
|
|
175
|
+
name: string;
|
|
176
|
+
type: string;
|
|
177
|
+
}
|
|
178
|
+
export interface DocsGraphDocumentNeighbor {
|
|
179
|
+
docId: string;
|
|
180
|
+
relationType: string;
|
|
181
|
+
hopDistance: number;
|
|
182
|
+
}
|
|
183
|
+
export interface DocsGraphRelatedDocument extends DocsGraphDocumentNeighbor {
|
|
184
|
+
title: string;
|
|
185
|
+
snippet: string;
|
|
186
|
+
}
|
|
187
|
+
export interface DocsGraphEntitiesResponse {
|
|
188
|
+
entities: DocsGraphEntity[];
|
|
189
|
+
}
|
|
190
|
+
export interface DocsGraphRelatedResponse {
|
|
191
|
+
related: DocsGraphDocumentNeighbor[];
|
|
192
|
+
}
|
|
193
|
+
export interface DocsGraphSearchResponse {
|
|
194
|
+
query?: string;
|
|
195
|
+
entities: DocsGraphEntity[];
|
|
196
|
+
relatedDocs: DocsGraphRelatedDocument[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Suggestion hit returned by `GET /api/search/suggest`.
|
|
200
|
+
*/
|
|
201
|
+
export interface DocsSearchSuggestItem {
|
|
202
|
+
id: string;
|
|
203
|
+
title: string;
|
|
204
|
+
score: number;
|
|
205
|
+
}
|
|
206
|
+
export interface DocsShareLink {
|
|
207
|
+
id: string;
|
|
208
|
+
token: string;
|
|
209
|
+
documentId: string | null;
|
|
210
|
+
folderId: string | null;
|
|
211
|
+
expiresAt: string | null;
|
|
212
|
+
hasPassword: boolean;
|
|
213
|
+
role?: DocsShareRole;
|
|
214
|
+
createdAt: string;
|
|
215
|
+
}
|
|
216
|
+
export type DocsShareRole = "viewer" | "commenter" | "editor";
|
|
217
|
+
/**
|
|
218
|
+
* `GET /api/share` returns a richer list item with `title` and `type`
|
|
219
|
+
* derived from the joined document / folder row.
|
|
220
|
+
*/
|
|
221
|
+
export interface DocsShareLinkListItem {
|
|
222
|
+
id: string;
|
|
223
|
+
token: string;
|
|
224
|
+
documentId: string | null;
|
|
225
|
+
folderId: string | null;
|
|
226
|
+
hasPassword: boolean;
|
|
227
|
+
expiresAt: string | null;
|
|
228
|
+
createdAt: string;
|
|
229
|
+
title: string;
|
|
230
|
+
type: "document" | "folder";
|
|
231
|
+
role?: DocsShareRole;
|
|
232
|
+
}
|
|
233
|
+
export interface DocsShareListResponse {
|
|
234
|
+
links: DocsShareLinkListItem[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Response of `GET /api/share/:token` (public, no auth). The shape is
|
|
238
|
+
* a discriminated union — narrow on `type` to access the right `data`.
|
|
239
|
+
*/
|
|
240
|
+
export type DocsSharedContent = {
|
|
241
|
+
type: "document";
|
|
242
|
+
data: {
|
|
243
|
+
id: string;
|
|
244
|
+
title: string;
|
|
245
|
+
content: string | null;
|
|
246
|
+
contentJson: unknown;
|
|
247
|
+
metadata: unknown;
|
|
248
|
+
createdAt: string;
|
|
249
|
+
updatedAt: string;
|
|
250
|
+
};
|
|
251
|
+
} | {
|
|
252
|
+
type: "folder";
|
|
253
|
+
data: {
|
|
254
|
+
id: string;
|
|
255
|
+
name: string;
|
|
256
|
+
createdAt: string;
|
|
257
|
+
updatedAt: string;
|
|
258
|
+
folders?: Array<{
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
createdAt: string;
|
|
262
|
+
updatedAt: string;
|
|
263
|
+
}>;
|
|
264
|
+
documents: Array<{
|
|
265
|
+
id: string;
|
|
266
|
+
title: string;
|
|
267
|
+
createdAt: string;
|
|
268
|
+
updatedAt: string;
|
|
269
|
+
}>;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
export interface DocsAttachment {
|
|
273
|
+
id: string;
|
|
274
|
+
filename: string;
|
|
275
|
+
mimeType: string;
|
|
276
|
+
size: number;
|
|
277
|
+
url: string;
|
|
278
|
+
documentId?: string;
|
|
279
|
+
createdAt?: string;
|
|
280
|
+
}
|
|
281
|
+
export interface DocsAttachmentListResponse {
|
|
282
|
+
items: DocsAttachment[];
|
|
283
|
+
}
|
|
284
|
+
export interface DocsAttachmentPresignInput {
|
|
285
|
+
filename: string;
|
|
286
|
+
contentType: string;
|
|
287
|
+
size: number;
|
|
288
|
+
}
|
|
289
|
+
export interface DocsAttachmentPresignResponse {
|
|
290
|
+
url: string;
|
|
291
|
+
key: string;
|
|
292
|
+
maxSize: number;
|
|
293
|
+
expiresIn: number;
|
|
294
|
+
}
|
|
295
|
+
export interface DocsAttachmentConfirmInput extends DocsAttachmentPresignInput {
|
|
296
|
+
key: string;
|
|
297
|
+
}
|
|
298
|
+
export type DocsApiKeyScope = "global" | `category:${string}:${"read" | "edit" | "write"}`;
|
|
299
|
+
export interface DocsApiKeyCreated {
|
|
300
|
+
id: string;
|
|
301
|
+
key: string;
|
|
302
|
+
prefix: string;
|
|
303
|
+
}
|
|
304
|
+
export interface DocsApiKeyListItem {
|
|
305
|
+
id: string;
|
|
306
|
+
name: string;
|
|
307
|
+
prefix: string;
|
|
308
|
+
scopes: DocsApiKeyScope[];
|
|
309
|
+
lastUsedAt: string | null;
|
|
310
|
+
expiresAt: string | null;
|
|
311
|
+
createdAt: string;
|
|
312
|
+
recoverable: boolean;
|
|
313
|
+
}
|
|
314
|
+
export interface DocsApiKeyListResponse {
|
|
315
|
+
keys: DocsApiKeyListItem[];
|
|
316
|
+
}
|
|
317
|
+
export type DocsPipelineStatus = "pending" | "processing" | "ready" | "retrying" | "failed" | "ready_with_warnings" | "skipped" | "cancelled";
|
|
318
|
+
export interface DocsDocumentPipeline {
|
|
319
|
+
documentId: string;
|
|
320
|
+
generationId: string;
|
|
321
|
+
status: DocsPipelineStatus;
|
|
322
|
+
revision: string;
|
|
323
|
+
stages: {
|
|
324
|
+
prepare: DocsPipelineStatus;
|
|
325
|
+
embed: DocsPipelineStatus;
|
|
326
|
+
graph: DocsPipelineStatus;
|
|
327
|
+
summarize: DocsPipelineStatus;
|
|
328
|
+
finalize: DocsPipelineStatus;
|
|
329
|
+
};
|
|
330
|
+
batches: {
|
|
331
|
+
total: number;
|
|
332
|
+
completed: number;
|
|
333
|
+
failed: number;
|
|
334
|
+
};
|
|
335
|
+
updatedAt: string;
|
|
336
|
+
}
|
|
337
|
+
export interface DocsVersion {
|
|
338
|
+
id: string;
|
|
339
|
+
documentId: string;
|
|
340
|
+
content: string;
|
|
341
|
+
contentJson?: unknown;
|
|
342
|
+
createdBy: string;
|
|
343
|
+
createdAt: string;
|
|
344
|
+
label?: string | null;
|
|
345
|
+
description?: string | null;
|
|
346
|
+
isSnapshot?: boolean;
|
|
347
|
+
restoredFrom?: string | null;
|
|
348
|
+
}
|
|
349
|
+
export interface DocsVersionDiff {
|
|
350
|
+
v1: {
|
|
351
|
+
id: string;
|
|
352
|
+
label?: string | null;
|
|
353
|
+
createdAt: string;
|
|
354
|
+
};
|
|
355
|
+
v2: {
|
|
356
|
+
id: string;
|
|
357
|
+
label?: string | null;
|
|
358
|
+
createdAt: string;
|
|
359
|
+
};
|
|
360
|
+
changes: {
|
|
361
|
+
added: number;
|
|
362
|
+
removed: number;
|
|
363
|
+
modified: number;
|
|
364
|
+
};
|
|
365
|
+
hunks: Array<{
|
|
366
|
+
type: "add" | "remove" | "unchanged";
|
|
367
|
+
lines: string[];
|
|
368
|
+
}>;
|
|
369
|
+
}
|
|
370
|
+
export interface DocsHealthResponse {
|
|
371
|
+
status: string;
|
|
372
|
+
service: string;
|
|
373
|
+
timestamp: string;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Request-scoped credentials and cancellation metadata. This is intentionally
|
|
377
|
+
* transport-shaped so a host can forward an incoming hiai-docs session without
|
|
378
|
+
* exposing auth internals to the SDK.
|
|
379
|
+
*/
|
|
380
|
+
export interface DocsRequestContext {
|
|
381
|
+
/** Raw Authorization header value, e.g. `Bearer <token>`. */
|
|
382
|
+
authorization?: string;
|
|
383
|
+
cookie?: string;
|
|
384
|
+
requestId?: string;
|
|
385
|
+
/** Short-lived signed assertion from a trusted Docsmint workspace gateway. */
|
|
386
|
+
workspaceAssertion?: string;
|
|
387
|
+
/** @deprecated Use workspaceAssertion. */
|
|
388
|
+
externalTenantAssertion?: string;
|
|
389
|
+
headers?: HeadersInit;
|
|
390
|
+
signal?: AbortSignal;
|
|
391
|
+
}
|