@hiai-gg/docsmint 0.3.7 → 0.3.9
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/backend/src/lib/logger.ts +45 -15
- package/dist/backend/index.js +238 -150
- package/dist/client.d.ts +11 -0
- package/dist/client.js +9 -0
- package/dist/frontend/CategoryDialog-CxVyaBV5.js +611 -0
- package/dist/frontend/ConfirmDialog-NFGXRa3E.js +214 -0
- package/dist/frontend/CreateSnapshotDialog-BDgFTeFn.js +216 -0
- package/dist/frontend/DatePicker-BZRBluzF.js +256 -0
- package/dist/frontend/DeleteDialog-CvAr2WPu.js +174 -0
- package/dist/frontend/FolderNode-C6FJv99G.js +298 -0
- package/dist/frontend/FolderTreeSelector-CyB8y2Sm.js +103 -0
- package/dist/frontend/HiaiDocsExtensionProvider-DHWLzRUu.js +11 -0
- package/dist/frontend/Icon-CooFj4Ee.js +64 -0
- package/dist/frontend/SettingsDialog-BHh68rTB.js +1016 -0
- package/dist/frontend/ShareDialog-BUOkYSlw.js +165 -0
- package/dist/frontend/Sidebar-Cu3JrKDC.js +2021 -0
- package/dist/frontend/TagCreateDialog-B9YZBNHi.js +260 -0
- package/dist/frontend/api/settings.js +1 -1
- package/dist/frontend/app-shell.d.ts +8 -0
- package/dist/frontend/app-shell.js +291 -0
- package/dist/frontend/{bundle-mjs-CP6Owz-8.js → bundle-mjs-DllmqUxV.js} +583 -568
- package/dist/frontend/camera-iKXDOOWT.js +29 -0
- package/dist/frontend/check-D-UuvBuh.js +25 -0
- package/dist/frontend/chevron-down-CiPtYyFh.js +25 -0
- package/dist/frontend/circle-check-tSPE1V6t.js +29 -0
- package/dist/frontend/clock-DJHbHZb8.js +29 -0
- package/dist/frontend/components/category-dialog.js +1 -1
- package/dist/frontend/components/create-snapshot-dialog.js +1 -1
- package/dist/frontend/components/delete-dialog.js +1 -1
- package/dist/frontend/components/editor/document-editor.js +1367 -1356
- package/dist/frontend/components/editor/document-title.js +25 -25
- package/dist/frontend/components/editor/markdown-toggle.js +45 -45
- package/dist/frontend/components/folder-node.js +1 -1
- package/dist/frontend/components/folder-tree-selector.js +1 -1
- package/dist/frontend/components/save-as-dialog.js +169 -151
- package/dist/frontend/components/settings.js +1 -1
- package/dist/frontend/components/share-dialog.js +1 -1
- package/dist/frontend/components/sidebar.js +2 -2013
- package/dist/frontend/components/tag-create-dialog.js +1 -1
- package/dist/frontend/components/version-history.js +188 -187
- package/dist/frontend/confirm-dialog-C4jTRbiS.js +250 -0
- package/dist/frontend/copy-GppwRMjX.js +32 -0
- package/dist/frontend/dashboard.js +1187 -1155
- package/dist/frontend/dialog-Bevp9mmM.js +213 -0
- package/dist/frontend/{loader-circle-Bk-WFz9g.js → dist-C3857Spp.js} +93 -92
- package/dist/frontend/doc-tabs.js +2 -2
- package/dist/frontend/dropdown-menu-CRSby3e9.js +530 -0
- package/dist/frontend/extension.js +2 -11
- package/dist/frontend/{floating-layer-anchor-C51M4l6v.js → floating-layer-anchor-BDs7vO-M.js} +1414 -1412
- package/dist/frontend/folder-DeWhnD7O.js +45 -0
- package/dist/frontend/folder-refresh.js +1 -1
- package/dist/frontend/frontend.css +1 -1
- package/dist/frontend/i18n.js +2 -2
- package/dist/frontend/input-BWlOML_m.js +23 -0
- package/dist/frontend/keyboard.js +1 -1
- package/dist/frontend/{keyboard.svelte-D7H8DihC.js → keyboard.svelte-CApmX0vl.js} +53 -53
- package/dist/frontend/label-C2HfJNQ2.js +30 -0
- package/dist/frontend/{messages-BpYaLbzE.js → messages-C5Q890i2.js} +8 -8
- package/dist/frontend/rotate-ccw-B4Q7brmV.js +25 -0
- package/dist/frontend/search.js +673 -647
- package/dist/frontend/select-value-GXwx90Pr.js +1446 -0
- package/dist/frontend/{settings-blyobazp.js → settings-DSrUl4hW.js} +9 -9
- package/dist/frontend/shared-document.js +94 -94
- package/dist/frontend/subfolders-refresh-store.svelte-B2dKVmgz.js +65 -0
- package/dist/frontend/tag-HxRazVN_.js +54 -0
- package/dist/frontend/tag-store.svelte-CqrUXo0o.js +29 -0
- package/dist/frontend/textarea-DOAE-h42.js +23 -0
- package/dist/frontend/theme.js +1 -1
- package/dist/frontend/theme.svelte-DKfCy12k.js +49 -0
- package/dist/frontend/{utils-D8kmM3ub.js → utils-BPDRytUU.js} +2 -3
- package/dist/frontend/{utils-C0OW2678.js → utils-DrfHTcei.js} +2 -3
- package/dist/frontend/utils.js +1 -1
- package/dist/frontend/x-CzBsnJ2x.js +25 -0
- package/dist/frontend-ssr/api/attachments.js +2 -0
- package/dist/frontend-ssr/api/categories.js +2 -0
- package/dist/frontend-ssr/api/documents.js +2 -0
- package/dist/frontend-ssr/api/folders.js +2 -0
- package/dist/frontend-ssr/api/settings.js +2 -0
- package/dist/frontend-ssr/api/share.js +2 -0
- package/dist/frontend-ssr/api/tags.js +2 -0
- package/dist/frontend-ssr/app-shell.js +294 -0
- package/dist/frontend-ssr/assets/CategoryDialog-BcGW8-Kf.js +584 -0
- package/dist/frontend-ssr/assets/ConfirmDialog-DjMFKc0V.js +420 -0
- package/dist/frontend-ssr/assets/CreateSnapshotDialog-1bROJ-Rn.js +214 -0
- package/dist/frontend-ssr/assets/DatePicker-B1ML8OVz.js +312 -0
- package/dist/frontend-ssr/assets/DeleteDialog-tBYaP0L3.js +154 -0
- package/dist/frontend-ssr/assets/FolderNode-BZ0Q2QUS.js +171 -0
- package/dist/frontend-ssr/assets/FolderTreeSelector-DZNZ2oI6.js +147 -0
- package/dist/frontend-ssr/assets/HiaiDocsExtensionProvider-DAM-lX4R.js +13 -0
- package/dist/frontend-ssr/assets/Icon-B0Zqppjo.js +231 -0
- package/dist/frontend-ssr/assets/SettingsDialog-B8L_YqNA.js +1107 -0
- package/dist/frontend-ssr/assets/ShareDialog-vMvJLRfn.js +54 -0
- package/dist/frontend-ssr/assets/Sidebar-EHuUAx3W.js +2033 -0
- package/dist/frontend-ssr/assets/TagCreateDialog-B0DPEfmQ.js +264 -0
- package/dist/frontend-ssr/assets/api-keys-DFqX39MT.js +35 -0
- package/dist/frontend-ssr/assets/attachments-CWBxE3Vz.js +85 -0
- package/dist/frontend-ssr/assets/auth-client-x26kqY8Z.js +1286 -0
- package/dist/frontend-ssr/assets/camera-CdxscTw-.js +84 -0
- package/dist/frontend-ssr/assets/categories-AOqgcsn4.js +75 -0
- package/dist/frontend-ssr/assets/chevron-down-CSSNGNh_.js +80 -0
- package/dist/frontend-ssr/assets/chevron-right-B4p7Sk6X.js +80 -0
- package/dist/frontend-ssr/assets/circle-check-CI1v4vYh.js +84 -0
- package/dist/frontend-ssr/assets/client-DZMkDkDn.js +129 -0
- package/dist/frontend-ssr/assets/clipboard-CXOaoz2W.js +30 -0
- package/dist/frontend-ssr/assets/clock-IL-eX2di.js +84 -0
- package/dist/frontend-ssr/assets/confirm-dialog-BCthVwUY.js +429 -0
- package/dist/frontend-ssr/assets/context-jz1GGEUi.js +45 -0
- package/dist/frontend-ssr/assets/copy-CjV57nGQ.js +87 -0
- package/dist/frontend-ssr/assets/db-CnxeO66n.js +65 -0
- package/dist/frontend-ssr/assets/dialog-BOV1u6zP.js +157 -0
- package/dist/frontend-ssr/assets/dndzone-DMvTO_Jz.js +2114 -0
- package/dist/frontend-ssr/assets/document-drop-coordinator-CEaYACsC.js +109 -0
- package/dist/frontend-ssr/assets/documents-BnOTRdTY.js +108 -0
- package/dist/frontend-ssr/assets/dropdown-menu-Bj5rbqbB.js +555 -0
- package/dist/frontend-ssr/assets/editorExtensions-DUzwndMy.js +186 -0
- package/dist/frontend-ssr/assets/floating-layer-anchor-CYIE8Oj6.js +6114 -0
- package/dist/frontend-ssr/assets/folder-DChhG7qN.js +80 -0
- package/dist/frontend-ssr/assets/folders-CTfbS24J.js +127 -0
- package/dist/frontend-ssr/assets/identity-B3uHoDtf.js +99 -0
- package/dist/frontend-ssr/assets/input-DezGsU3y.js +19 -0
- package/dist/frontend-ssr/assets/keyboard.svelte-BgF47N3L.js +174 -0
- package/dist/frontend-ssr/assets/label-Bj8-TfFN.js +21 -0
- package/dist/frontend-ssr/assets/loader-circle-DZsrZ-er.js +80 -0
- package/dist/frontend-ssr/assets/markdown-CjqvGi5W.js +20 -0
- package/dist/frontend-ssr/assets/messages-CvqpZNJe.js +11125 -0
- package/dist/frontend-ssr/assets/resolve-BqHozBXl.js +32 -0
- package/dist/frontend-ssr/assets/rotate-ccw-BlgWwaiq.js +80 -0
- package/dist/frontend-ssr/assets/select-value-6Lk0ToYd.js +1526 -0
- package/dist/frontend-ssr/assets/settings-Bk5Hk9Vq.js +64 -0
- package/dist/frontend-ssr/assets/share-BTBJelxA.js +30 -0
- package/dist/frontend-ssr/assets/subfolders-refresh-store.svelte-DAh4gT16.js +77 -0
- package/dist/frontend-ssr/assets/tag-GZEuGWk1.js +166 -0
- package/dist/frontend-ssr/assets/tag-store.svelte-DPodKj6Z.js +21 -0
- package/dist/frontend-ssr/assets/tags-BId2wdYd.js +49 -0
- package/dist/frontend-ssr/assets/textarea-Dev-qSEc.js +21 -0
- package/dist/frontend-ssr/assets/theme.svelte-Co0-ssaD.js +67 -0
- package/dist/frontend-ssr/assets/utils-DtlPPXpJ.js +9 -0
- package/dist/frontend-ssr/assets/utils-DvZnctjz.js +23 -0
- package/dist/frontend-ssr/collaboration.js +39 -0
- package/dist/frontend-ssr/components/category-dialog.js +2 -0
- package/dist/frontend-ssr/components/create-snapshot-dialog.js +2 -0
- package/dist/frontend-ssr/components/delete-dialog.js +2 -0
- package/dist/frontend-ssr/components/editor/document-editor.js +2499 -0
- package/dist/frontend-ssr/components/editor/document-title.js +11 -0
- package/dist/frontend-ssr/components/editor/docx-serializer.js +186 -0
- package/dist/frontend-ssr/components/editor/extensions.js +2 -0
- package/dist/frontend-ssr/components/editor/markdown-toggle.js +20 -0
- package/dist/frontend-ssr/components/editor/markdown.js +2 -0
- package/dist/frontend-ssr/components/folder-node.js +2 -0
- package/dist/frontend-ssr/components/folder-tree-selector.js +2 -0
- package/dist/frontend-ssr/components/save-as-dialog.js +280 -0
- package/dist/frontend-ssr/components/settings.js +2 -0
- package/dist/frontend-ssr/components/share-dialog.js +2 -0
- package/dist/frontend-ssr/components/sidebar.js +2 -0
- package/dist/frontend-ssr/components/tag-create-dialog.js +2 -0
- package/dist/frontend-ssr/components/version-history.js +370 -0
- package/dist/frontend-ssr/dashboard.js +2542 -0
- package/dist/frontend-ssr/doc-tabs.js +23 -0
- package/dist/frontend-ssr/document-drop-coordinator.js +2 -0
- package/dist/frontend-ssr/extension.js +2 -0
- package/dist/frontend-ssr/folder-refresh.js +2 -0
- package/dist/frontend-ssr/i18n.js +10 -0
- package/dist/frontend-ssr/keyboard.js +2 -0
- package/dist/frontend-ssr/offline/identity.js +2 -0
- package/dist/frontend-ssr/search.js +332 -0
- package/dist/frontend-ssr/shared-document.js +273 -0
- package/dist/frontend-ssr/theme.js +9 -0
- package/dist/frontend-ssr/types.js +1 -0
- package/dist/frontend-ssr/utils/clipboard.js +2 -0
- package/dist/frontend-ssr/utils/dndzone.js +2 -0
- package/dist/frontend-ssr/utils.js +2 -0
- package/package.json +28 -1
- package/packages/cli/src/index.ts +1 -1
- package/packages/db/src/schema.ts +3 -0
- package/packages/mcp-server/src/index.ts +1 -1
- package/dist/frontend/CategoryDialog--rIE7FrH.js +0 -580
- package/dist/frontend/ConfirmDialog-Cpzyb55f.js +0 -212
- package/dist/frontend/CreateSnapshotDialog-CmkV-n2A.js +0 -216
- package/dist/frontend/DatePicker-Byynca7V.js +0 -257
- package/dist/frontend/DeleteDialog-ap6nOywZ.js +0 -174
- package/dist/frontend/FolderDialog-DmN_trV0.js +0 -247
- package/dist/frontend/FolderNode-C4B8a2fd.js +0 -317
- package/dist/frontend/FolderTreeSelector-D6ijiZTA.js +0 -100
- package/dist/frontend/Icon-DtNo0N1U.js +0 -64
- package/dist/frontend/SettingsDialog-2kTaTXAs.js +0 -992
- package/dist/frontend/ShareDialog-BBDGNF5n.js +0 -165
- package/dist/frontend/TagCreateDialog-DiLZnJo4.js +0 -258
- package/dist/frontend/camera-B7dAOd4s.js +0 -28
- package/dist/frontend/check-CDwRlG9T.js +0 -24
- package/dist/frontend/chevron-down-B7ZrjUmT.js +0 -24
- package/dist/frontend/circle-check-CDqeMB2d.js +0 -28
- package/dist/frontend/client-Bc5Fzx40.js +0 -2785
- package/dist/frontend/clock-Ck5Sn-Zl.js +0 -28
- package/dist/frontend/clsx-nmtDPO_P.js +0 -16
- package/dist/frontend/copy-CMAA6GP0.js +0 -31
- package/dist/frontend/dialog-BDkiG42a.js +0 -213
- package/dist/frontend/disclose-version-5I57E3LD.js +0 -3
- package/dist/frontend/ellipsis-vertical-BBuPldbW.js +0 -519
- package/dist/frontend/folder-TQjKY4yn.js +0 -44
- package/dist/frontend/index-client-jobkrWVL.js +0 -86
- package/dist/frontend/input-CBI6p4Xl.js +0 -23
- package/dist/frontend/label-C-GkhEp4.js +0 -30
- package/dist/frontend/rotate-ccw-CleZtJ5D.js +0 -24
- package/dist/frontend/select-value-CvrWRkXW.js +0 -1436
- package/dist/frontend/subfolders-refresh-store.svelte-BsheoQma.js +0 -65
- package/dist/frontend/tag-Dx3SmucJ.js +0 -53
- package/dist/frontend/tag-store.svelte-CIaF4sdZ.js +0 -29
- package/dist/frontend/textarea-Dfp78XlL.js +0 -23
- package/dist/frontend/theme.svelte-CROg1Hi5.js +0 -49
- package/dist/frontend/x-DaTdeDXv.js +0 -24
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region src/lib/components/sidebar/document-drop-coordinator.ts
|
|
2
|
+
function createDocumentPlacementWriter(options) {
|
|
3
|
+
const states = /* @__PURE__ */ new Map();
|
|
4
|
+
return function move(id, placement, initialConfirmed) {
|
|
5
|
+
let state = states.get(id);
|
|
6
|
+
if (!state) {
|
|
7
|
+
state = {
|
|
8
|
+
chain: Promise.resolve(),
|
|
9
|
+
confirmed: { ...initialConfirmed },
|
|
10
|
+
generation: 0
|
|
11
|
+
};
|
|
12
|
+
states.set(id, state);
|
|
13
|
+
}
|
|
14
|
+
const request = {
|
|
15
|
+
generation: ++state.generation,
|
|
16
|
+
placement: { ...placement },
|
|
17
|
+
token: options.optimistic(id, placement)
|
|
18
|
+
};
|
|
19
|
+
const run = state.chain.then(async () => {
|
|
20
|
+
try {
|
|
21
|
+
await options.patch(id, request.placement);
|
|
22
|
+
state.confirmed = { ...request.placement };
|
|
23
|
+
options.acknowledge(id, request.token);
|
|
24
|
+
if (options.refresh) options.refresh().catch(options.onRefreshError ?? (() => void 0));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
options.acknowledge(id, request.token);
|
|
27
|
+
if (request.generation === state.generation) options.rollback(id, state.confirmed);
|
|
28
|
+
options.onError(error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
state.chain = run.catch(() => void 0);
|
|
33
|
+
return run;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createDocumentDropCoordinator(options) {
|
|
37
|
+
const defer = options.defer ?? ((callback) => setTimeout(callback, 0));
|
|
38
|
+
const cancel = options.cancel ?? clearTimeout;
|
|
39
|
+
const expire = options.expire ?? ((callback) => setTimeout(callback, 1e3));
|
|
40
|
+
const cancelExpire = options.cancelExpire ?? clearTimeout;
|
|
41
|
+
let active;
|
|
42
|
+
function clearActive() {
|
|
43
|
+
if (active?.pending) cancel(active.pending);
|
|
44
|
+
if (active?.expiry) cancelExpire(active.expiry);
|
|
45
|
+
active = void 0;
|
|
46
|
+
}
|
|
47
|
+
function lookup(id) {
|
|
48
|
+
return active?.id === id ? active : void 0;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
/**
|
|
52
|
+
* Returns the document whose drag transaction is still awaiting a
|
|
53
|
+
* destination. UI state may already have been cleared by the source
|
|
54
|
+
* zone's finalize event before a category-header drop is delivered.
|
|
55
|
+
*/
|
|
56
|
+
pendingId(token) {
|
|
57
|
+
return active && !active.resolved && active.token === token ? active.id : null;
|
|
58
|
+
},
|
|
59
|
+
begin(id, token) {
|
|
60
|
+
if (active?.id === id && active.token === token) return;
|
|
61
|
+
clearActive();
|
|
62
|
+
active = {
|
|
63
|
+
id,
|
|
64
|
+
token,
|
|
65
|
+
resolved: false,
|
|
66
|
+
pending: null,
|
|
67
|
+
expiry: null
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
end(id, token) {
|
|
71
|
+
const transaction = active;
|
|
72
|
+
if (!transaction || transaction.id !== id || transaction.token !== token || transaction.resolved || transaction.expiry) return;
|
|
73
|
+
transaction.expiry = expire(() => {
|
|
74
|
+
if (active === transaction && !transaction.resolved) clearActive();
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
cancel() {
|
|
78
|
+
clearActive();
|
|
79
|
+
},
|
|
80
|
+
zone(id, placement) {
|
|
81
|
+
const transaction = lookup(id);
|
|
82
|
+
if (!transaction || transaction.resolved) return;
|
|
83
|
+
if (transaction.pending) cancel(transaction.pending);
|
|
84
|
+
transaction.pending = defer(() => {
|
|
85
|
+
if (active === transaction && !transaction.resolved) {
|
|
86
|
+
transaction.pending = null;
|
|
87
|
+
if (transaction.expiry) {
|
|
88
|
+
cancelExpire(transaction.expiry);
|
|
89
|
+
transaction.expiry = null;
|
|
90
|
+
}
|
|
91
|
+
transaction.resolved = true;
|
|
92
|
+
options.persist(id, placement);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
header(id, placement) {
|
|
97
|
+
const transaction = lookup(id);
|
|
98
|
+
if (!transaction || transaction.resolved) return;
|
|
99
|
+
if (transaction.pending) cancel(transaction.pending);
|
|
100
|
+
transaction.pending = null;
|
|
101
|
+
if (transaction.expiry) cancelExpire(transaction.expiry);
|
|
102
|
+
transaction.expiry = null;
|
|
103
|
+
transaction.resolved = true;
|
|
104
|
+
options.persist(id, placement);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { createDocumentPlacementWriter as n, createDocumentDropCoordinator as t };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { n as apiFetch } from "./client-DZMkDkDn.js";
|
|
2
|
+
//#region src/lib/api/documents.ts
|
|
3
|
+
var listDocumentsInflight = /* @__PURE__ */ new Map();
|
|
4
|
+
var listDocumentsTtl = /* @__PURE__ */ new Map();
|
|
5
|
+
var LIST_CACHE_TTL_MS = 5e3;
|
|
6
|
+
function clearDocumentsCache() {
|
|
7
|
+
listDocumentsInflight.clear();
|
|
8
|
+
listDocumentsTtl.clear();
|
|
9
|
+
}
|
|
10
|
+
function listDocumentsCacheKey(params) {
|
|
11
|
+
if (!params) return "all";
|
|
12
|
+
return JSON.stringify({
|
|
13
|
+
folderId: params.folderId ?? null,
|
|
14
|
+
tag: params.tag ?? null,
|
|
15
|
+
page: params.page ?? 1,
|
|
16
|
+
limit: params.limit ?? null
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function getTtlEntry(key) {
|
|
20
|
+
const entry = listDocumentsTtl.get(key);
|
|
21
|
+
if (!entry) return void 0;
|
|
22
|
+
if (Date.now() - entry.timestamp >= LIST_CACHE_TTL_MS) {
|
|
23
|
+
listDocumentsTtl.delete(key);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return entry;
|
|
27
|
+
}
|
|
28
|
+
function setTtlEntry(key, promise) {
|
|
29
|
+
listDocumentsTtl.set(key, {
|
|
30
|
+
promise,
|
|
31
|
+
timestamp: Date.now()
|
|
32
|
+
});
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
listDocumentsTtl.delete(key);
|
|
35
|
+
}, LIST_CACHE_TTL_MS);
|
|
36
|
+
}
|
|
37
|
+
function listDocuments(params, fetcher) {
|
|
38
|
+
const key = listDocumentsCacheKey(params);
|
|
39
|
+
const inflight = listDocumentsInflight.get(key);
|
|
40
|
+
if (inflight) return inflight;
|
|
41
|
+
const ttl = getTtlEntry(key);
|
|
42
|
+
if (ttl) return ttl.promise;
|
|
43
|
+
const searchParams = new URLSearchParams();
|
|
44
|
+
if (params?.folderId) searchParams.set("folderId", params.folderId);
|
|
45
|
+
if (params?.tag) searchParams.set("tag", params.tag);
|
|
46
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
47
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
48
|
+
const qs = searchParams.toString();
|
|
49
|
+
const promise = apiFetch(`/api/documents${qs ? `?${qs}` : ""}`, {}, fetcher).catch((err) => {
|
|
50
|
+
listDocumentsTtl.delete(key);
|
|
51
|
+
throw err;
|
|
52
|
+
});
|
|
53
|
+
listDocumentsInflight.set(key, promise);
|
|
54
|
+
setTtlEntry(key, promise);
|
|
55
|
+
promise.finally(() => {
|
|
56
|
+
listDocumentsInflight.delete(key);
|
|
57
|
+
});
|
|
58
|
+
return promise;
|
|
59
|
+
}
|
|
60
|
+
function getDocument(id, fetcher) {
|
|
61
|
+
return apiFetch(`/api/documents/${id}`, {}, fetcher);
|
|
62
|
+
}
|
|
63
|
+
function createDocument(data, fetcher) {
|
|
64
|
+
clearDocumentsCache();
|
|
65
|
+
return apiFetch("/api/documents", {
|
|
66
|
+
method: "POST",
|
|
67
|
+
body: JSON.stringify(data)
|
|
68
|
+
}, fetcher);
|
|
69
|
+
}
|
|
70
|
+
function updateDocument(id, data) {
|
|
71
|
+
clearDocumentsCache();
|
|
72
|
+
return apiFetch(`/api/documents/${id}`, {
|
|
73
|
+
method: "PATCH",
|
|
74
|
+
body: JSON.stringify(data)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function deleteDocument(id) {
|
|
78
|
+
clearDocumentsCache();
|
|
79
|
+
return apiFetch(`/api/documents/${id}`, { method: "DELETE" });
|
|
80
|
+
}
|
|
81
|
+
function importDocument(file, folderId) {
|
|
82
|
+
clearDocumentsCache();
|
|
83
|
+
const formData = new FormData();
|
|
84
|
+
formData.append("file", file);
|
|
85
|
+
if (folderId) formData.append("folderId", folderId);
|
|
86
|
+
return apiFetch("/api/documents/import", {
|
|
87
|
+
method: "POST",
|
|
88
|
+
body: formData
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Import one or more documents. Accepts any combination of supported
|
|
93
|
+
* file types (markdown, text, JSON, DOCX). The backend endpoint accepts
|
|
94
|
+
* a multipart body with multiple `file` parts and returns an
|
|
95
|
+
* `ImportResponse` describing per-file success/failure.
|
|
96
|
+
*/
|
|
97
|
+
function importDocuments(files, folderId) {
|
|
98
|
+
clearDocumentsCache();
|
|
99
|
+
const formData = new FormData();
|
|
100
|
+
for (const file of files) formData.append("file", file);
|
|
101
|
+
if (folderId) formData.append("folderId", folderId);
|
|
102
|
+
return apiFetch("/api/documents/import", {
|
|
103
|
+
method: "POST",
|
|
104
|
+
body: formData
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { importDocument as a, updateDocument as c, getDocument as i, createDocument as n, importDocuments as o, deleteDocument as r, listDocuments as s, clearDocumentsCache as t };
|