@hiai-gg/docsmint 0.4.0 → 0.4.2
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/dist/backend/index.js
CHANGED
|
@@ -214237,7 +214237,7 @@ var swaggerConfig = {
|
|
|
214237
214237
|
documentation: {
|
|
214238
214238
|
info: {
|
|
214239
214239
|
title: "DocsMint API",
|
|
214240
|
-
version: "0.4.
|
|
214240
|
+
version: "0.4.2",
|
|
214241
214241
|
description: "Self-hosted AI-first documentation platform. Full-text + semantic search, version history, sharing, and folder organization.",
|
|
214242
214242
|
contact: { name: "HiAi-gg", url: "https://github.com/HiAi-gg/docsmint" },
|
|
214243
214243
|
license: {
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { Component, Snippet } from "svelte";
|
|
2
|
+
export interface DocsmintNavigationOptions {
|
|
3
|
+
replaceState?: boolean;
|
|
4
|
+
noScroll?: boolean;
|
|
5
|
+
keepFocus?: boolean;
|
|
6
|
+
invalidateAll?: boolean;
|
|
7
|
+
state?: App.PageState;
|
|
8
|
+
}
|
|
2
9
|
export interface DocsmintRouteAdapter {
|
|
3
10
|
pathname: string;
|
|
4
11
|
resolve(path: string): string;
|
|
5
|
-
navigate?(path: string): void | Promise<void>;
|
|
12
|
+
navigate?(path: string, options?: DocsmintNavigationOptions): void | Promise<void>;
|
|
6
13
|
}
|
|
7
|
-
export interface
|
|
14
|
+
export interface DocsmintRequestAdapter { fetch: typeof fetch; }
|
|
15
|
+
export interface DocsmintAppShellHostProps { route: DocsmintRouteAdapter; request?: DocsmintRequestAdapter; extensions?: Record<string, unknown>; children: Snippet; }
|
|
8
16
|
export declare const DocsmintAppShellHost: Component<DocsmintAppShellHostProps>;
|
|
@@ -12,22 +12,60 @@ export function createPersistentLifecycleRuntime(options) {
|
|
|
12
12
|
const lifecycle = createUserDataLifecycle({
|
|
13
13
|
async *exportUserData(context) {
|
|
14
14
|
const immutable = immutableContext(context);
|
|
15
|
-
const records = await options.runtime.database(immutable,
|
|
16
|
-
const result = [];
|
|
17
|
-
for await (const record of options.runtime.adapter.exportUserData(immutable))
|
|
18
|
-
result.push(record);
|
|
19
|
-
return result;
|
|
20
|
-
});
|
|
15
|
+
const records = await options.runtime.database(immutable, () => composeExport(options.runtime.adapter, hostSteps, immutable));
|
|
21
16
|
for (const record of records)
|
|
22
17
|
yield record;
|
|
23
18
|
},
|
|
24
19
|
async purgeUserData(context, gate) {
|
|
25
20
|
const immutable = immutableContext(context);
|
|
26
|
-
return options.runtime.database(immutable, () =>
|
|
21
|
+
return options.runtime.database(immutable, async () => {
|
|
22
|
+
const result = await options.runtime.adapter.purgeUserData(immutable, gate);
|
|
23
|
+
if (result.status === "already_completed")
|
|
24
|
+
return result;
|
|
25
|
+
const deletedByDomain = { ...result.deletedByDomain };
|
|
26
|
+
for (const step of hostSteps) {
|
|
27
|
+
if (!step.purge)
|
|
28
|
+
continue;
|
|
29
|
+
const outcome = await step.purge(immutable);
|
|
30
|
+
deletedByDomain[`host:${step.id}`] = outcome.deletedCount;
|
|
31
|
+
}
|
|
32
|
+
return { ...result, deletedByDomain };
|
|
33
|
+
});
|
|
27
34
|
},
|
|
28
35
|
}, async (context) => options.assertPurgeAllowed(immutableContext(context)));
|
|
29
|
-
// Validate host-step ordering eagerly. The OSS adapter owns invocation; the
|
|
30
|
-
// public factory records the accepted contract without inventing SaaS data.
|
|
31
|
-
void hostSteps;
|
|
32
36
|
return lifecycle;
|
|
33
37
|
}
|
|
38
|
+
async function composeExport(adapter, hostSteps, context) {
|
|
39
|
+
const ossRecords = [];
|
|
40
|
+
for await (const record of adapter.exportUserData(context))
|
|
41
|
+
ossRecords.push(record);
|
|
42
|
+
const manifest = ossRecords.shift();
|
|
43
|
+
const complete = ossRecords.pop();
|
|
44
|
+
if (manifest?.type !== "manifest" || complete?.type !== "complete") {
|
|
45
|
+
throw new Error("Persistent lifecycle adapter returned an invalid export stream");
|
|
46
|
+
}
|
|
47
|
+
if (ossRecords.some((record) => record.type === "manifest" || record.type === "complete")) {
|
|
48
|
+
throw new Error("Persistent lifecycle adapter returned a reserved record type");
|
|
49
|
+
}
|
|
50
|
+
const hash = new Bun.CryptoHasher("sha256");
|
|
51
|
+
const records = [];
|
|
52
|
+
const append = (record) => {
|
|
53
|
+
hash.update(`${JSON.stringify(record)}\n`, "utf8");
|
|
54
|
+
records.push(record);
|
|
55
|
+
};
|
|
56
|
+
append(manifest);
|
|
57
|
+
for (const record of ossRecords)
|
|
58
|
+
append(record);
|
|
59
|
+
for (const step of hostSteps) {
|
|
60
|
+
if (!step.export)
|
|
61
|
+
continue;
|
|
62
|
+
for await (const record of step.export(context)) {
|
|
63
|
+
if (record.type === "manifest" || record.type === "complete") {
|
|
64
|
+
throw new Error(`Lifecycle host step ${step.id} emitted a reserved record type`);
|
|
65
|
+
}
|
|
66
|
+
append(record);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
records.push({ type: "complete", recordCount: records.length, checksum: hash.digest("hex") });
|
|
70
|
+
return records;
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ import { registerSearch } from "./commands/search.js";
|
|
|
24
24
|
import { registerSnapshot } from "./commands/snapshot.js";
|
|
25
25
|
import { registerUpdate } from "./commands/update.js";
|
|
26
26
|
|
|
27
|
-
const VERSION = "0.4.
|
|
27
|
+
const VERSION = "0.4.2";
|
|
28
28
|
|
|
29
29
|
const program = new Command();
|
|
30
30
|
program
|