@hiai-gg/docsmint 2.0.4 → 2.1.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.
Files changed (46) hide show
  1. package/README.md +67 -2
  2. package/dist/backend/index.js +22540 -2807
  3. package/dist/backend-account-runtime-cleanup.js +2 -1
  4. package/dist/backend-api-key-facade.js +2 -1
  5. package/dist/backend-pipeline-cancellation.js +2 -1
  6. package/dist/client.d.ts +33 -7
  7. package/dist/client.js +55 -1
  8. package/dist/frontend/{HiAiEditor-DDpfdQEg.js → HiAiEditor-D6ad_auS.js} +2 -2
  9. package/dist/frontend/{SettingsDialog-DzlYW50I.js → SettingsDialog-B8Oswuqb.js} +4 -4
  10. package/dist/frontend/{Sidebar-rFiVen96.js → Sidebar-BV0IDqTS.js} +1 -1
  11. package/dist/frontend/api/settings.js +1 -1
  12. package/dist/frontend/app-shell.js +2 -2
  13. package/dist/frontend/{auth-client-CXR-7mIO.js → auth-client-C5EyWdAF.js} +416 -349
  14. package/dist/frontend/components/editor/compact-editor.js +1 -1
  15. package/dist/frontend/components/editor/document-editor.js +1 -1
  16. package/dist/frontend/components/settings.js +1 -1
  17. package/dist/frontend/components/sidebar.js +1 -1
  18. package/dist/frontend/{db-Dya0HRhS.js → db-CgTtukT4.js} +1 -1
  19. package/dist/frontend/{identity-BOA7Jejv.js → identity-CNhtuCJV.js} +1 -1
  20. package/dist/frontend/offline/identity.js +1 -1
  21. package/dist/frontend/{settings-BRcYFQa_.js → settings-CHx4wBwb.js} +1 -1
  22. package/dist/frontend-ssr/api/settings.js +1 -1
  23. package/dist/frontend-ssr/app-shell.js +2 -2
  24. package/dist/frontend-ssr/assets/{HiAiEditor-Bj6tiE97.js → HiAiEditor-Cj3B2Dt6.js} +2 -2
  25. package/dist/frontend-ssr/assets/{SettingsDialog-h4SFwpUa.js → SettingsDialog-DAT-Zxu0.js} +4 -4
  26. package/dist/frontend-ssr/assets/{Sidebar-BFBpsd3L.js → Sidebar-B_Ey6QNL.js} +1 -1
  27. package/dist/frontend-ssr/assets/{auth-client-BC4hSFKF.js → auth-client-CITU3xkE.js} +308 -227
  28. package/dist/frontend-ssr/assets/{db-C3rFdTZa.js → db-DxRzq-kx.js} +1 -1
  29. package/dist/frontend-ssr/assets/{identity-DNIo1bgc.js → identity-B7ngLQzZ.js} +1 -1
  30. package/dist/frontend-ssr/assets/{settings-DWCpfCPj.js → settings-BRxvn30Y.js} +1 -1
  31. package/dist/frontend-ssr/components/editor/compact-editor.js +1 -1
  32. package/dist/frontend-ssr/components/editor/document-editor.js +1 -1
  33. package/dist/frontend-ssr/components/settings.js +1 -1
  34. package/dist/frontend-ssr/components/sidebar.js +1 -1
  35. package/dist/frontend-ssr/offline/identity.js +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/lifecycle-runtime.js +4 -1
  39. package/dist/mcp-cli.js +301 -22
  40. package/dist/mcp-server.d.ts +92 -23
  41. package/dist/mcp-server.js +469 -22
  42. package/dist/types.d.ts +68 -1
  43. package/package.json +2 -2
  44. package/packages/cli/src/index.ts +1 -1
  45. package/packages/db/src/schema.ts +3 -1
  46. package/server.json +2 -2
@@ -149,10 +149,11 @@ var accounts = pgTable("accounts", {
149
149
  id: uuid("id").primaryKey().defaultRandom(),
150
150
  userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
151
151
  accountId: text("account_id").notNull(),
152
- issuer: text("issuer").notNull(),
152
+ issuer: text("issuer"),
153
153
  providerId: text("provider_id").notNull(),
154
154
  accessToken: text("access_token"),
155
155
  refreshToken: text("refresh_token"),
156
+ idToken: text("id_token"),
156
157
  accessTokenExpiresAt: timestamp("access_token_expires_at"),
157
158
  refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
158
159
  scope: text("scope"),
@@ -149,10 +149,11 @@ var accounts = pgTable("accounts", {
149
149
  id: uuid("id").primaryKey().defaultRandom(),
150
150
  userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
151
151
  accountId: text("account_id").notNull(),
152
- issuer: text("issuer").notNull(),
152
+ issuer: text("issuer"),
153
153
  providerId: text("provider_id").notNull(),
154
154
  accessToken: text("access_token"),
155
155
  refreshToken: text("refresh_token"),
156
+ idToken: text("id_token"),
156
157
  accessTokenExpiresAt: timestamp("access_token_expires_at"),
157
158
  refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
158
159
  scope: text("scope"),
@@ -149,10 +149,11 @@ var accounts = pgTable("accounts", {
149
149
  id: uuid("id").primaryKey().defaultRandom(),
150
150
  userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
151
151
  accountId: text("account_id").notNull(),
152
- issuer: text("issuer").notNull(),
152
+ issuer: text("issuer"),
153
153
  providerId: text("provider_id").notNull(),
154
154
  accessToken: text("access_token"),
155
155
  refreshToken: text("refresh_token"),
156
+ idToken: text("id_token"),
156
157
  accessTokenExpiresAt: timestamp("access_token_expires_at"),
157
158
  refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
158
159
  scope: text("scope"),
package/dist/client.d.ts CHANGED
@@ -9,6 +9,8 @@
9
9
  */
10
10
  import type { DocsApiKeyCreated, DocsApiKeyListResponse, DocsAttachment, DocsAttachmentConfirmInput, DocsAttachmentListResponse, DocsAttachmentPresignInput, DocsAttachmentPresignResponse, DocsCategory, DocsCategoryListItem, DocsCategoryInput, DocsCategoryUpdate, DocsDocument, DocsDocumentCreateInput, DocsDocumentCursorPage, DocsDocumentIndexRefresh, DocsDocumentIndexStatus, DocsDocumentKnowledgeSummary, DocsDocumentListResponse, DocsDocumentPipeline, DocsPipelineWarningRetry, DocsDocumentUpdateInput, DocsFolder, DocsFolderCreateInput, DocsFolderUpdateInput, DocsGraphEntitiesResponse, DocsGraphRelatedResponse, DocsGraphSearchResponse, DocsHealthResponse, DocsRequestContext, DocsSearchOptions, DocsSearchResponse, DocsSearchSuggestItem, DocsSharedContent, DocsShareLink, DocsShareListResponse, DocsShareRole, DocsTag, DocsTrashResponse, DocsVersion, DocsVersionDiff } from "./types.js";
11
11
  export interface DocsClientConfig {
12
+ /** Explicit API prefix. Existing clients keep /api; no endpoint probing is performed. */
13
+ apiPrefix?: "/api" | "/api/v1";
12
14
  /** Base URL of the DocsMint API, e.g. `http://localhost:50700`. */
13
15
  baseUrl: string;
14
16
  /** Bearer token used as `Authorization: Bearer <apiKey>`. */
@@ -70,17 +72,12 @@ export declare class DocsClient {
70
72
  getDocMarkdown(id: string, context?: DocsRequestContext): Promise<string>;
71
73
  updateDoc(id: string, updates: DocsDocumentUpdateInput, context?: DocsRequestContext): Promise<DocsDocument>;
72
74
  deleteDoc(id: string, context?: DocsRequestContext): Promise<void>;
73
- listDocs(options?: {
74
- folderId?: string;
75
- tag?: string;
76
- page?: number;
77
- limit?: number;
78
- }, context?: DocsRequestContext): Promise<DocsDocumentListResponse>;
75
+ listDocs(options?: import("./types.js").DocsListOptions, context?: DocsRequestContext): Promise<DocsDocumentListResponse>;
79
76
  /**
80
77
  * List documents through the bounded cursor API. Cursors are opaque and
81
78
  * bound by the server to the authenticated workspace and category scope.
82
79
  */
83
- listDocuments(options?: {
80
+ listDocuments(options?: Omit<import("./types.js").DocsListOptions, "page" | "sortBy"> & {
84
81
  categoryId?: string;
85
82
  cursor?: string;
86
83
  limit?: number;
@@ -99,6 +96,8 @@ export declare class DocsClient {
99
96
  * Convenience alias for `getDocMarkdown` — both go through the same
100
97
  * `/api/documents/:id/export` endpoint on the backend.
101
98
  */
99
+ /** Read portable markdown and authorized document metadata in one request. */
100
+ exportDocWithMetadata(id: string, context?: DocsRequestContext): Promise<import("./types.js").DocsDocumentExport>;
102
101
  exportDoc(id: string, context?: DocsRequestContext): Promise<string>;
103
102
  /**
104
103
  * Import a document from raw content. Posts JSON to
@@ -146,6 +145,9 @@ export declare class DocsClient {
146
145
  revokeApiKey(id: string, context?: DocsRequestContext): Promise<{
147
146
  success: true;
148
147
  }>;
148
+ /** Inspect credentials without reading a document or selecting a workspace. */
149
+ whoami(context?: DocsRequestContext): Promise<import("./types.js").DocsIdentity>;
150
+ listWorkspaces(context?: DocsRequestContext): Promise<import("./types.js").DocsWorkspaceDescriptor[]>;
149
151
  search(query: string, options?: DocsSearchOptions, context?: DocsRequestContext): Promise<DocsSearchResponse>;
150
152
  /**
151
153
  * Product-facing search contract. The retrieval choice is explicitly typed
@@ -234,3 +236,27 @@ export declare class DocsClient {
234
236
  private snapshotContext;
235
237
  private toBlob;
236
238
  }
239
+ /** Canonical camelCase view without removing legacy wire aliases. */
240
+ export declare function normalizeDocsSearchResult(result: import("./types.js").DocsSearchResult): {
241
+ folderId: string | null;
242
+ folderName: string | null;
243
+ categoryId: string | null;
244
+ categoryName: string | null;
245
+ createdAt: string;
246
+ updatedAt: string;
247
+ effectiveCategoryId?: string | null;
248
+ effectiveCategoryName?: string | null;
249
+ workspaceId?: string | null;
250
+ workspaceSlug?: string | null;
251
+ url?: string | null;
252
+ id: string;
253
+ title: string;
254
+ snippet: string;
255
+ score: number;
256
+ folder_id: string | null;
257
+ folder_name: string | null;
258
+ created_at: string;
259
+ updated_at: string;
260
+ tags?: DocsTag[];
261
+ chunks?: import("./types.js").DocsSearchChunk[];
262
+ };
package/dist/client.js CHANGED
@@ -76,11 +76,15 @@ export class DocsTimeoutError extends DocsNetworkError {
76
76
  export class DocsClient {
77
77
  config;
78
78
  constructor(config) {
79
+ if (config.apiPrefix !== undefined && config.apiPrefix !== "/api" && config.apiPrefix !== "/api/v1") {
80
+ throw new Error("DocsClient: apiPrefix must be /api or /api/v1");
81
+ }
79
82
  if (!config.baseUrl) {
80
83
  throw new Error("DocsClient: `baseUrl` is required");
81
84
  }
82
85
  this.config = {
83
86
  baseUrl: config.baseUrl.replace(/\/+$/, ""),
87
+ apiPrefix: config.apiPrefix ?? "/api",
84
88
  apiKey: config.apiKey,
85
89
  requestContext: this.snapshotContext(config.requestContext),
86
90
  fetch: config.fetch ?? fetch,
@@ -126,6 +130,16 @@ export class DocsClient {
126
130
  return this.request("GET", "/api/documents", {
127
131
  query: this.cleanQuery({
128
132
  folderId: options?.folderId,
133
+ categoryId: options?.categoryId,
134
+ visibility: options?.visibility,
135
+ rootOnly: options?.rootOnly,
136
+ tagIds: options?.tagIds?.join(","),
137
+ tagMatch: options?.tagMatch,
138
+ q: options?.q,
139
+ updatedFrom: options?.updatedFrom,
140
+ updatedTo: options?.updatedTo,
141
+ sortBy: options?.sortBy,
142
+ sortOrder: options?.sortOrder,
129
143
  tag: options?.tag,
130
144
  page: options?.page,
131
145
  limit: options?.limit,
@@ -140,6 +154,15 @@ export class DocsClient {
140
154
  return this.request("GET", "/api/documents/cursor", {
141
155
  query: this.cleanQuery({
142
156
  categoryId: options.categoryId,
157
+ folderId: options.folderId,
158
+ rootOnly: options.rootOnly,
159
+ tag: options.tag,
160
+ tagIds: options.tagIds?.join(","),
161
+ tagMatch: options.tagMatch,
162
+ visibility: options.visibility,
163
+ q: options.q,
164
+ updatedFrom: options.updatedFrom,
165
+ updatedTo: options.updatedTo,
143
166
  cursor: options.cursor,
144
167
  limit: options.limit,
145
168
  sortBy: options.sortBy,
@@ -175,6 +198,16 @@ export class DocsClient {
175
198
  * Convenience alias for `getDocMarkdown` — both go through the same
176
199
  * `/api/documents/:id/export` endpoint on the backend.
177
200
  */
201
+ /** Read portable markdown and authorized document metadata in one request. */
202
+ async exportDocWithMetadata(id, context) {
203
+ const response = await this.fetchRaw("GET", `/api/documents/${encodeURIComponent(id)}/export`, { query: { format: "json" } }, context);
204
+ if (!response.ok)
205
+ throw await this.toApiError(response);
206
+ if (response.headers.get("content-type")?.includes("json"))
207
+ return response.json();
208
+ // Older servers return portable markdown even when an unknown format is supplied.
209
+ return { markdown: await response.text() };
210
+ }
178
211
  async exportDoc(id, context) {
179
212
  return this.getDocMarkdown(id, context);
180
213
  }
@@ -267,6 +300,13 @@ export class DocsClient {
267
300
  async revokeApiKey(id, context) {
268
301
  return this.request("DELETE", `/api/keys/${encodeURIComponent(id)}`, undefined, context);
269
302
  }
303
+ /** Inspect credentials without reading a document or selecting a workspace. */
304
+ async whoami(context) {
305
+ return this.request("GET", "/api/whoami", undefined, context);
306
+ }
307
+ async listWorkspaces(context) {
308
+ return this.request("GET", "/api/workspaces", undefined, context);
309
+ }
270
310
  // ── Search ───────────────────────────────────────────────────────────
271
311
  async search(query, options, context) {
272
312
  return this.request("GET", "/api/search", {
@@ -284,6 +324,7 @@ export class DocsClient {
284
324
  graphHops: options?.graphHops,
285
325
  graphBoost: options?.graphBoost,
286
326
  includeChunks: options?.includeChunks,
327
+ includeDiagnostics: options?.includeDiagnostics,
287
328
  }),
288
329
  }, context);
289
330
  }
@@ -516,7 +557,8 @@ export class DocsClient {
516
557
  throw this.wrapNetworkError(lastError, requestContext?.requestId);
517
558
  }
518
559
  buildUrl(path, query) {
519
- let url = `${this.config.baseUrl}${path}`;
560
+ const resolvedPath = path.startsWith("/api/") ? `${this.config.apiPrefix}${path.slice(4)}` : path;
561
+ let url = `${this.config.baseUrl}${resolvedPath}`;
520
562
  if (query && Object.keys(query).length > 0) {
521
563
  const params = new URLSearchParams();
522
564
  for (const [key, value] of Object.entries(query)) {
@@ -677,3 +719,15 @@ export class DocsClient {
677
719
  throw new Error("DocsClient.uploadAttachment: unsupported file type");
678
720
  }
679
721
  }
722
+ /** Canonical camelCase view without removing legacy wire aliases. */
723
+ export function normalizeDocsSearchResult(result) {
724
+ return {
725
+ ...result,
726
+ folderId: result.folderId === undefined ? result.folder_id : result.folderId,
727
+ folderName: result.folderName === undefined ? result.folder_name : result.folderName,
728
+ categoryId: result.effectiveCategoryId ?? result.categoryId ?? null,
729
+ categoryName: result.effectiveCategoryName ?? result.categoryName ?? null,
730
+ createdAt: result.createdAt ?? result.created_at,
731
+ updatedAt: result.updatedAt ?? result.updated_at,
732
+ };
733
+ }
@@ -14,8 +14,8 @@ import { t as je } from "./version_create_snapshot-3bu-0qzH.js";
14
14
  import { a as Me } from "./route-context-DYQlUfzL.js";
15
15
  import { a as Ne, n as Pe, o as Fe, r as Ie, s as Le, t as Re } from "./dialog-a_ZcpEC5.js";
16
16
  import { t as ze } from "./input-Q_7qCfnU.js";
17
- import { n as Be } from "./db-Dya0HRhS.js";
18
- import { a as Ve } from "./identity-BOA7Jejv.js";
17
+ import { n as Be } from "./db-CgTtukT4.js";
18
+ import { a as Ve } from "./identity-CNhtuCJV.js";
19
19
  import { A as He, C as S, D as Ue, E as C, O as w, S as We, T as Ge, g as Ke, h as qe, j as Je, k as Ye, v as Xe, w as Ze, x as T } from "./lib-aUbBbIW2.js";
20
20
  import { n as Qe, t as E } from "./dist-CcHOStsA.js";
21
21
  import { h as $e, u as D } from "./keyboard.svelte-CApmX0vl.js";
@@ -8,14 +8,14 @@ import { t as D } from "./utils-BlHvR6OL.js";
8
8
  import { a as ne, i as re, n as ie, o as ae, r as oe, s as O, t as se } from "./dialog-a_ZcpEC5.js";
9
9
  import { t as k } from "./input-Q_7qCfnU.js";
10
10
  import { t as A } from "./label-Dj8FDEhf.js";
11
- import { r as ce, t as le } from "./auth-client-CXR-7mIO.js";
12
- import { a as ue, r as de } from "./settings-BRcYFQa_.js";
11
+ import { r as ce, t as le } from "./auth-client-C5EyWdAF.js";
12
+ import { a as ue, r as de } from "./settings-CHx4wBwb.js";
13
13
  import { a as j, i as M, n as N, o as fe, s as P, t as F } from "./api-keys-DIwAdYkg.js";
14
14
  import { i as I } from "./categories-C8AAkhCR.js";
15
15
  import { t as pe } from "./context-D0zPFXZ4.js";
16
16
  import { t as me } from "./resolve-BG4HgzpN.js";
17
- import { n as L, t as R } from "./db-Dya0HRhS.js";
18
- import { a as z, t as B } from "./identity-BOA7Jejv.js";
17
+ import { n as L, t as R } from "./db-CgTtukT4.js";
18
+ import { a as z, t as B } from "./identity-CNhtuCJV.js";
19
19
  import { t as V } from "./editor-preferences.svelte-Bt_A9k7n.js";
20
20
  import { n as H, r as U, t as W } from "./search-preferences-B1GdbdUc.js";
21
21
  import { t as he } from "./theme.svelte-BRdxXd-B.js";
@@ -7,7 +7,7 @@ import { t as o } from "./copy-CRzvfZGb.js";
7
7
  import { t as s } from "./ellipsis-vertical-qxNgoXu-.js";
8
8
  import { a as c, i as l, r as u, t as d } from "./share-context-BJ4GF4yT.js";
9
9
  import { t as f } from "./loader-circle-D3t5NkvC.js";
10
- import { t as p } from "./SettingsDialog-DzlYW50I.js";
10
+ import { t as p } from "./SettingsDialog-B8Oswuqb.js";
11
11
  import { n as m, t as h } from "./tag-qbTBLj-g.js";
12
12
  import { t as g } from "./x-CvSSnrjl.js";
13
13
  import { t as _ } from "./action_cancel-Cuxsznzz.js";
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, r, t as i } from "../settings-BRcYFQa_.js";
1
+ import { a as e, i as t, n, r, t as i } from "../settings-CHx4wBwb.js";
2
2
  export { i as deleteAccount, n as getEmbeddingConfig, r as getProfile, t as updateEmbeddingConfig, e as updateProfile };
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./Icon-3EYzvNyk.js";
2
2
  import { n as t, t as n } from "./share-context-BJ4GF4yT.js";
3
- import { n as r } from "./SettingsDialog-DzlYW50I.js";
4
- import { t as i } from "./Sidebar-rFiVen96.js";
3
+ import { n as r } from "./SettingsDialog-B8Oswuqb.js";
4
+ import { t as i } from "./Sidebar-BV0IDqTS.js";
5
5
  import { t as a } from "./scroll_to_top_aria-CvkNF_Hu.js";
6
6
  import { o, r as s } from "./route-context-DYQlUfzL.js";
7
7
  import { t as c } from "./editor-preferences.svelte-Bt_A9k7n.js";