@tensorix/metahub 0.1.10 → 0.1.11
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/README.md +19 -6
- package/README.zh-CN.md +7 -2
- package/dist/cli.js +1601 -595
- package/dist/cli.js.map +43 -38
- package/dist/core/compact.d.ts +42 -0
- package/dist/core/compact.d.ts.map +1 -0
- package/dist/core/config.d.ts +3 -3
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/context.d.ts +4 -4
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/crdt.d.ts +30 -7
- package/dist/core/crdt.d.ts.map +1 -1
- package/dist/core/databases.d.ts +22 -8
- package/dist/core/databases.d.ts.map +1 -1
- package/dist/core/db.d.ts +1 -27
- package/dist/core/db.d.ts.map +1 -1
- package/dist/core/documents.d.ts +28 -15
- package/dist/core/documents.d.ts.map +1 -1
- package/dist/core/driver.d.ts +25 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/history.d.ts +99 -11
- package/dist/core/history.d.ts.map +1 -1
- package/dist/core/hlc.d.ts +3 -3
- package/dist/core/hlc.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/indexing.d.ts +4 -4
- package/dist/core/indexing.d.ts.map +1 -1
- package/dist/core/integrity.d.ts +1 -1
- package/dist/core/integrity.d.ts.map +1 -1
- package/dist/core/node.d.ts +2 -2
- package/dist/core/node.d.ts.map +1 -1
- package/dist/core/properties.d.ts +10 -9
- package/dist/core/properties.d.ts.map +1 -1
- package/dist/core/records.d.ts +13 -8
- package/dist/core/records.d.ts.map +1 -1
- package/dist/core/resolve.d.ts +4 -4
- package/dist/core/resolve.d.ts.map +1 -1
- package/dist/core/schema-init.d.ts +37 -0
- package/dist/core/schema-init.d.ts.map +1 -0
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/search.d.ts +3 -3
- package/dist/core/search.d.ts.map +1 -1
- package/dist/core/sites-core.d.ts +60 -0
- package/dist/core/sites-core.d.ts.map +1 -0
- package/dist/core/sites.d.ts +11 -52
- package/dist/core/sites.d.ts.map +1 -1
- package/dist/core/sqlcols.d.ts +4 -0
- package/dist/core/sqlcols.d.ts.map +1 -0
- package/dist/core/sync/auth.d.ts +5 -3
- package/dist/core/sync/auth.d.ts.map +1 -1
- package/dist/core/sync/client.d.ts +11 -3
- package/dist/core/sync/client.d.ts.map +1 -1
- package/dist/core/sync/peers.d.ts +10 -10
- package/dist/core/sync/peers.d.ts.map +1 -1
- package/dist/core/sync/protocol.d.ts +5 -0
- package/dist/core/sync/protocol.d.ts.map +1 -1
- package/dist/core/sync/routes.d.ts.map +1 -1
- package/dist/core/sync/server.d.ts +10 -0
- package/dist/core/sync/server.d.ts.map +1 -1
- package/dist/db-worker.js +268 -0
- package/dist/index.js +1061 -340
- package/dist/index.js.map +31 -28
- package/dist/metahub-sdk.js +1 -0
- package/dist/mh-runtime.js +1 -0
- package/dist/sqlite3.wasm +0 -0
- package/dist/sw.js +1 -0
- package/dist/webui/server/assets.d.ts +8 -1
- package/dist/webui/server/assets.d.ts.map +1 -1
- package/dist/webui/server/icons.d.ts +4 -0
- package/dist/webui/server/icons.d.ts.map +1 -0
- package/dist/webui/server/routes.d.ts.map +1 -1
- package/dist/webui.js +57 -57
- package/package.json +3 -1
package/dist/core/indexing.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
import type { PropertyRow } from "./properties.ts";
|
|
3
|
-
export declare function hasIndex(db:
|
|
3
|
+
export declare function hasIndex(db: DbDriver, databaseId: string, propId: string): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Create an expression index on `data ->> '<propId>'` (with created_hlc as the
|
|
6
6
|
* sort tail), partial on this database. Idempotent. The expression matches
|
|
7
7
|
* exactly what listRecords emits, so the optimizer uses it.
|
|
8
8
|
*/
|
|
9
|
-
export declare function ensurePropIndex(db:
|
|
9
|
+
export declare function ensurePropIndex(db: DbDriver, databaseId: string, propId: string): void;
|
|
10
10
|
/**
|
|
11
11
|
* Ensure an index for a field that a query filters/sorts on — but only when it
|
|
12
12
|
* will pay off. relation fields are almost always query keys (cheap, index
|
|
13
13
|
* eagerly); other fields wait until the collection crosses the row threshold.
|
|
14
14
|
*/
|
|
15
|
-
export declare function maybeAutoIndex(db:
|
|
15
|
+
export declare function maybeAutoIndex(db: DbDriver, databaseId: string, prop: PropertyRow): void;
|
|
16
16
|
//# sourceMappingURL=indexing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../../src/core/indexing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../../src/core/indexing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsBnD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKlF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAMtF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAWxF"}
|
package/dist/core/integrity.d.ts
CHANGED
|
@@ -28,5 +28,5 @@ export declare function validateHub(db: Database): IntegrityReport;
|
|
|
28
28
|
* node) is a no-op. Report-only categories (dup_name, bad_config) are returned in
|
|
29
29
|
* `remaining` for human resolution, never auto-changed.
|
|
30
30
|
*/
|
|
31
|
-
export declare
|
|
31
|
+
export declare const repairHub: (db: Database) => RepairResult;
|
|
32
32
|
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrity.d.ts","sourceRoot":"","sources":["../../src/core/integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAqB3C,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,aAAa,GACb,UAAU,GACV,UAAU,GACV,cAAc,GACd,YAAY,CAAC;AAEjB,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,4EAA4E;IAC5E,SAAS,EAAE,eAAe,CAAC;CAC5B;AAuSD,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,eAAe,CAYzD;AAeD;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"integrity.d.ts","sourceRoot":"","sources":["../../src/core/integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAqB3C,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,aAAa,GACb,UAAU,GACV,UAAU,GACV,cAAc,GACd,YAAY,CAAC;AAEjB,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,4EAA4E;IAC5E,SAAS,EAAE,eAAe,CAAC;CAC5B;AAuSD,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,eAAe,CAYzD;AAeD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,gCAYV,CAAC"}
|
package/dist/core/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
/** Stable per-machine node id, persisted in the meta table. */
|
|
3
|
-
export declare function getNodeId(db:
|
|
3
|
+
export declare function getNodeId(db: DbDriver): string;
|
|
4
4
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/core/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAQ9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
export type PropType = "text" | "number" | "checkbox" | "select" | "multi_select" | "date" | "relation" | "url";
|
|
3
3
|
export declare const PROP_TYPES: ReadonlySet<string>;
|
|
4
4
|
export interface PropertyConfig {
|
|
@@ -15,21 +15,22 @@ export interface PropertyRow {
|
|
|
15
15
|
config: PropertyConfig | null;
|
|
16
16
|
position: number;
|
|
17
17
|
}
|
|
18
|
-
export declare
|
|
18
|
+
export declare const PROPERTY_COLS: readonly ["id", "database_id", "name", "type", "config", "position"];
|
|
19
|
+
export declare const addProperty: (db: DbDriver, databaseId: string, opts: {
|
|
19
20
|
name: string;
|
|
20
21
|
type: PropType;
|
|
21
22
|
config?: PropertyConfig;
|
|
22
23
|
position?: number;
|
|
23
24
|
indexed?: boolean;
|
|
24
|
-
})
|
|
25
|
-
export declare function getProperty(db:
|
|
26
|
-
export declare function listProperties(db:
|
|
27
|
-
export declare
|
|
25
|
+
}) => PropertyRow;
|
|
26
|
+
export declare function getProperty(db: DbDriver, id: string): PropertyRow | null;
|
|
27
|
+
export declare function listProperties(db: DbDriver, databaseId: string): PropertyRow[];
|
|
28
|
+
export declare const updateProperty: (db: DbDriver, id: string, fields: {
|
|
28
29
|
name?: string;
|
|
29
30
|
type?: PropType;
|
|
30
31
|
config?: PropertyConfig;
|
|
31
32
|
position?: number;
|
|
32
|
-
})
|
|
33
|
-
export declare function setPropertyWidth(db:
|
|
34
|
-
export declare
|
|
33
|
+
}) => PropertyRow;
|
|
34
|
+
export declare function setPropertyWidth(db: DbDriver, id: string, width: number): PropertyRow;
|
|
35
|
+
export declare const removeProperty: (db: DbDriver, id: string) => boolean;
|
|
35
36
|
//# sourceMappingURL=properties.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/core/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/core/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,cAAc,GACd,MAAM,GACN,UAAU,GACV,KAAK,CAAC;AAEV,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CASzC,CAAC;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,eAAO,MAAM,aAAa,sEAAuE,CAAC;AAyBlG,eAAO,MAAM,WAAW;UAId,MAAM;UACN,QAAQ;aACL,cAAc;eACZ,MAAM;cAIP,OAAO;iBAwBnB,CAAC;AAEH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAMxE;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,EAAE,CAU9E;AAED,eAAO,MAAM,cAAc;WAGR,MAAM;WAAS,QAAQ;aAAW,cAAc;eAAa,MAAM;iBA+BpF,CAAC;AAKH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAMrF;AAED,eAAO,MAAM,cAAc,uCAczB,CAAC"}
|
package/dist/core/records.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
export interface RecordRow {
|
|
3
3
|
id: string;
|
|
4
4
|
database_id: string;
|
|
5
|
+
/** Cells keyed by property NAME — friendly for CLI / external agents, but
|
|
6
|
+
* lossy when two properties share a name (one entry wins). */
|
|
5
7
|
values: Record<string, unknown>;
|
|
8
|
+
/** Cells keyed by property ID — lossless under duplicate names; the WebUI
|
|
9
|
+
* reads/writes through this. */
|
|
10
|
+
cells: Record<string, unknown>;
|
|
6
11
|
}
|
|
7
|
-
export declare
|
|
8
|
-
export declare
|
|
9
|
-
export declare function getRecord(db:
|
|
10
|
-
export declare function listRecords(db:
|
|
12
|
+
export declare const backfillRecordOrderKeys: (db: DbDriver, databaseId?: string | undefined) => void;
|
|
13
|
+
export declare const createRecord: (db: DbDriver, databaseId: string, data: Record<string, unknown>) => RecordRow;
|
|
14
|
+
export declare function getRecord(db: DbDriver, id: string): RecordRow | null;
|
|
15
|
+
export declare function listRecords(db: DbDriver, databaseId: string, opts?: {
|
|
11
16
|
filter?: Record<string, unknown>;
|
|
12
17
|
sort?: string;
|
|
13
18
|
limit?: number;
|
|
14
19
|
}): RecordRow[];
|
|
15
|
-
export declare
|
|
16
|
-
export declare
|
|
17
|
-
export declare
|
|
20
|
+
export declare const moveRecord: (db: DbDriver, id: string, targetId: string, where: "before" | "after") => RecordRow;
|
|
21
|
+
export declare const updateRecord: (db: DbDriver, id: string, data: Record<string, unknown>) => RecordRow;
|
|
22
|
+
export declare const deleteRecord: (db: DbDriver, id: string) => boolean;
|
|
18
23
|
//# sourceMappingURL=records.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/core/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/core/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsB5C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB;kEAC8D;IAC9D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;oCACgC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AA8LD,eAAO,MAAM,uBAAuB,yDA4BlC,CAAC;AAEH,eAAO,MAAM,YAAY,gFAkBvB,CAAC;AAEH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAMpE;AAOD,wBAAgB,WAAW,CACzB,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7E,SAAS,EAAE,CAiFb;AAED,eAAO,MAAM,UAAU,sFA0CrB,CAAC;AAEH,eAAO,MAAM,YAAY,wEAavB,CAAC;AAEH,eAAO,MAAM,YAAY,uCAOvB,CAAC"}
|
package/dist/core/resolve.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
/** Kinds reachable through the public reference resolver. `blk` is internal. */
|
|
3
3
|
export type PublicKind = "db" | "prop" | "rec" | "doc";
|
|
4
4
|
export interface Candidate {
|
|
@@ -12,7 +12,7 @@ export interface Candidate {
|
|
|
12
12
|
* all public kinds are searched (the generic `mh get`). `databaseId` narrows
|
|
13
13
|
* rec/doc/prop to one collection.
|
|
14
14
|
*/
|
|
15
|
-
export declare function resolveCandidates(db:
|
|
15
|
+
export declare function resolveCandidates(db: DbDriver, ref: string, opts?: {
|
|
16
16
|
kind?: PublicKind;
|
|
17
17
|
databaseId?: string;
|
|
18
18
|
}): Candidate[];
|
|
@@ -21,12 +21,12 @@ export declare function resolveCandidates(db: Database, ref: string, opts?: {
|
|
|
21
21
|
* keeps working). Otherwise a single candidate is returned; zero throws
|
|
22
22
|
* "no such …"; multiple throws a git-style ambiguity list.
|
|
23
23
|
*/
|
|
24
|
-
export declare function resolveEntity(db:
|
|
24
|
+
export declare function resolveEntity(db: DbDriver, ref: string, opts?: {
|
|
25
25
|
kind?: PublicKind;
|
|
26
26
|
databaseId?: string;
|
|
27
27
|
}): Candidate;
|
|
28
28
|
/** Resolve `ref` to one concrete row id. See {@link resolveEntity}. */
|
|
29
|
-
export declare function resolveRef(db:
|
|
29
|
+
export declare function resolveRef(db: DbDriver, ref: string, opts?: {
|
|
30
30
|
kind?: PublicKind;
|
|
31
31
|
databaseId?: string;
|
|
32
32
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAiFD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,SAAS,EAAE,CAiBb;AAQD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,SAAS,CAeX;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CACxB,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,MAAM,CAER"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
|
+
export declare function runSchema(db: DbDriver): void;
|
|
3
|
+
export declare function ftsAvailable(db: DbDriver): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Migrate legacy EAV records (record_values: one row per cell) to the JSON
|
|
6
|
+
* layout (records.data: one row per record). Idempotent — keyed off schema
|
|
7
|
+
* shape, no version flag. A no-op for fresh databases.
|
|
8
|
+
*/
|
|
9
|
+
export declare function migrateRecords(db: DbDriver): void;
|
|
10
|
+
/**
|
|
11
|
+
* Add the peer-pairing columns to a legacy `peers` table (token/label/node_id/
|
|
12
|
+
* enabled/last_sync_at/last_status/last_error). Idempotent — guarded per column,
|
|
13
|
+
* never drops the table so existing replication cursors survive.
|
|
14
|
+
*/
|
|
15
|
+
export declare function migratePeers(db: DbDriver): void;
|
|
16
|
+
/**
|
|
17
|
+
* Add the `blank_after` column to a legacy `doc_blocks` table. Idempotent —
|
|
18
|
+
* guarded by hasColumn; existing blocks default to 0 (canonical single-blank-line
|
|
19
|
+
* separators), so the migration never changes an existing document's body.
|
|
20
|
+
*/
|
|
21
|
+
export declare function migrateDocBlocks(db: DbDriver): void;
|
|
22
|
+
/**
|
|
23
|
+
* Add the `order_key` column to a legacy `documents` table and backfill it.
|
|
24
|
+
* Idempotent — guarded by hasColumn; backfill only touches rows with a NULL key,
|
|
25
|
+
* assigning per-parent fractional indices in current created_hlc order, so the
|
|
26
|
+
* displayed document order is unchanged until the user first drags something.
|
|
27
|
+
*/
|
|
28
|
+
export declare function migrateDocuments(db: DbDriver): void;
|
|
29
|
+
/**
|
|
30
|
+
* Add the `txn` change-group column to a legacy `crdt_changes` table.
|
|
31
|
+
* Idempotent — guarded by hasColumn; existing rows stay NULL (history falls
|
|
32
|
+
* back to time-gap clustering for them).
|
|
33
|
+
*/
|
|
34
|
+
export declare function migrateOplog(db: DbDriver): void;
|
|
35
|
+
/** Bring a freshly opened (or legacy) database to the current schema. */
|
|
36
|
+
export declare function initSchema(db: DbDriver): void;
|
|
37
|
+
//# sourceMappingURL=schema-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-init.d.ts","sourceRoot":"","sources":["../../src/core/schema-init.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAO5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAKlD;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAuBjD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAa/C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGnD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAInD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAG/C;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAO7C"}
|
package/dist/core/schema.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const CORE_SCHEMA = "\nCREATE TABLE IF NOT EXISTS meta (\n key TEXT PRIMARY KEY,\n value TEXT\n);\n\n-- CRDT oplog: one row per field assignment. Source of truth for sync.\nCREATE TABLE IF NOT EXISTS crdt_changes (\n hlc TEXT NOT NULL,\n node_id TEXT NOT NULL,\n dataset TEXT NOT NULL,\n row_id TEXT NOT NULL,\n col TEXT NOT NULL,\n value TEXT,\n PRIMARY KEY (dataset, row_id, col, hlc)\n);\nCREATE INDEX IF NOT EXISTS idx_changes_hlc ON crdt_changes(hlc);\n\n-- Per-peer replication cursors (SQLite rowids: monotonic in insertion order,\n-- so no change is ever skipped regardless of HLC/clock skew). Outbound side of\n-- a pairing: \"token\" is the credential the *remote* issued to us (sent as a\n-- Bearer header when we sync to them). See migratePeers in db.ts for the columns\n-- added to legacy databases.\nCREATE TABLE IF NOT EXISTS peers (\n url TEXT PRIMARY KEY,\n pull_cursor INTEGER NOT NULL DEFAULT 0,\n push_cursor INTEGER NOT NULL DEFAULT 0,\n token TEXT,\n label TEXT,\n node_id TEXT,\n enabled INTEGER NOT NULL DEFAULT 1,\n last_sync_at INTEGER,\n last_status TEXT,\n last_error TEXT\n);\n\n-- Inbound side of a pairing: credentials *we* issued to remote devices. A peer\n-- presents one of these on /sync; acceptsSyncToken() checks it alongside the\n-- managed master token. Revoke by deleting the row.\nCREATE TABLE IF NOT EXISTS peer_grants (\n token TEXT PRIMARY KEY,\n peer_url TEXT,\n node_id TEXT,\n created_at INTEGER\n);\n\n-- One-time pairing codes minted by \"mh config peer code\" / POST /api/pair/new.\n-- Short-lived and single-use: redeemed during the pairing handshake, then the\n-- two devices exchange durable peer_grants. used/exp gate redemption.\nCREATE TABLE IF NOT EXISTS pairing_codes (\n code TEXT PRIMARY KEY,\n exp INTEGER NOT NULL,\n used INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER\n);\n\nCREATE TABLE IF NOT EXISTS databases (\n id TEXT PRIMARY KEY,\n name TEXT,\n icon TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS properties (\n id TEXT PRIMARY KEY,\n database_id TEXT,\n name TEXT,\n type TEXT,\n config TEXT,\n position REAL,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_properties_db ON properties(database_id);\n\n-- One row per record. Field cells live in the data JSON object, keyed by\n-- property id (rename-safe). Each (record,property) is still an independent\n-- CRDT register in the oplog; materialize() folds the winner into data via\n-- json_set/json_remove. Hot fields get expression indexes on data->>'propid'\n-- (see indexing.ts) so filter/sort/limit push down to SQL.\nCREATE TABLE IF NOT EXISTS records (\n id TEXT PRIMARY KEY,\n database_id TEXT,\n created_hlc TEXT,\n order_key TEXT,\n data TEXT NOT NULL DEFAULT '{}',\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_records_db_hlc ON records(database_id, created_hlc);\n\nCREATE TABLE IF NOT EXISTS documents (\n id TEXT PRIMARY KEY,\n title TEXT,\n body TEXT, -- materialized cache: serialized from doc_blocks\n database_id TEXT,\n parent_id TEXT,\n created_hlc TEXT,\n order_key TEXT, -- fractional index among siblings (same parent_id); ties broken by created_hlc,id\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\n-- Document body as an ordered list of blocks; each (block,field) is an\n-- independent CRDT register so concurrent edits to different blocks merge.\n-- order_key is a fractional index (ties broken by id) giving display order.\nCREATE TABLE IF NOT EXISTS doc_blocks (\n id TEXT PRIMARY KEY,\n doc_id TEXT,\n text TEXT,\n order_key TEXT,\n blank_after INTEGER NOT NULL DEFAULT 0, -- extra blank lines kept after this block (user spacing)\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_doc_blocks_doc ON doc_blocks(doc_id);\n\n-- A named static site (Supabase-Storage-style bucket). Served at /sites/<name>/.\nCREATE TABLE IF NOT EXISTS sites (\n id TEXT PRIMARY KEY,\n name TEXT, -- URL slug; resolved by getSiteByName\n title TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\n-- One row per file in a site. content holds inline utf8/base64 text, or a blob\n-- hash (see cache.ts) when encoding = 'blob'. (site_id, path) maps to a stable\n-- id so re-uploads merge as a CRDT register instead of duplicating.\nCREATE TABLE IF NOT EXISTS site_files (\n id TEXT PRIMARY KEY,\n site_id TEXT,\n path TEXT,\n content_type TEXT,\n encoding TEXT, -- 'utf8' | 'base64' | 'blob'\n content TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_site_files_site ON site_files(site_id);\n";
|
|
1
|
+
export declare const CORE_SCHEMA = "\nCREATE TABLE IF NOT EXISTS meta (\n key TEXT PRIMARY KEY,\n value TEXT\n);\n\n-- CRDT oplog: one row per field assignment. Source of truth for sync.\n-- txn groups the changes of one logical mutation for history rendering\n-- (nullable: legacy rows and changes from pre-txn peers have none).\nCREATE TABLE IF NOT EXISTS crdt_changes (\n hlc TEXT NOT NULL,\n node_id TEXT NOT NULL,\n dataset TEXT NOT NULL,\n row_id TEXT NOT NULL,\n col TEXT NOT NULL,\n value TEXT,\n txn TEXT,\n PRIMARY KEY (dataset, row_id, col, hlc)\n);\nCREATE INDEX IF NOT EXISTS idx_changes_hlc ON crdt_changes(hlc);\n-- Serves history's \"every block ever attached to this doc\" lookup. Partial so\n-- it never indexes the large values other datasets carry (e.g. site file bodies).\nCREATE INDEX IF NOT EXISTS idx_changes_docref ON crdt_changes(value)\n WHERE dataset = 'doc_blocks' AND col = 'doc_id';\n\n-- Per-peer replication cursors (SQLite rowids: monotonic in insertion order,\n-- so no change is ever skipped regardless of HLC/clock skew). Outbound side of\n-- a pairing: \"token\" is the credential the *remote* issued to us (sent as a\n-- Bearer header when we sync to them). See migratePeers in db.ts for the columns\n-- added to legacy databases.\nCREATE TABLE IF NOT EXISTS peers (\n url TEXT PRIMARY KEY,\n pull_cursor INTEGER NOT NULL DEFAULT 0,\n push_cursor INTEGER NOT NULL DEFAULT 0,\n token TEXT,\n label TEXT,\n node_id TEXT,\n enabled INTEGER NOT NULL DEFAULT 1,\n last_sync_at INTEGER,\n last_status TEXT,\n last_error TEXT\n);\n\n-- Inbound side of a pairing: credentials *we* issued to remote devices. A peer\n-- presents one of these on /sync; acceptsSyncToken() checks it alongside the\n-- managed master token. Revoke by deleting the row.\nCREATE TABLE IF NOT EXISTS peer_grants (\n token TEXT PRIMARY KEY,\n peer_url TEXT,\n node_id TEXT,\n created_at INTEGER\n);\n\n-- One-time pairing codes minted by \"mh config peer code\" / POST /api/pair/new.\n-- Short-lived and single-use: redeemed during the pairing handshake, then the\n-- two devices exchange durable peer_grants. used/exp gate redemption.\nCREATE TABLE IF NOT EXISTS pairing_codes (\n code TEXT PRIMARY KEY,\n exp INTEGER NOT NULL,\n used INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER\n);\n\nCREATE TABLE IF NOT EXISTS databases (\n id TEXT PRIMARY KEY,\n name TEXT,\n icon TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS properties (\n id TEXT PRIMARY KEY,\n database_id TEXT,\n name TEXT,\n type TEXT,\n config TEXT,\n position REAL,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_properties_db ON properties(database_id);\n\n-- One row per record. Field cells live in the data JSON object, keyed by\n-- property id (rename-safe). Each (record,property) is still an independent\n-- CRDT register in the oplog; materialize() folds the winner into data via\n-- json_set/json_remove. Hot fields get expression indexes on data->>'propid'\n-- (see indexing.ts) so filter/sort/limit push down to SQL.\nCREATE TABLE IF NOT EXISTS records (\n id TEXT PRIMARY KEY,\n database_id TEXT,\n created_hlc TEXT,\n order_key TEXT,\n data TEXT NOT NULL DEFAULT '{}',\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_records_db_hlc ON records(database_id, created_hlc);\n\nCREATE TABLE IF NOT EXISTS documents (\n id TEXT PRIMARY KEY,\n title TEXT,\n body TEXT, -- materialized cache: serialized from doc_blocks\n database_id TEXT,\n parent_id TEXT,\n created_hlc TEXT,\n order_key TEXT, -- fractional index among siblings (same parent_id); ties broken by created_hlc,id\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\n-- Document body as an ordered list of blocks; each (block,field) is an\n-- independent CRDT register so concurrent edits to different blocks merge.\n-- order_key is a fractional index (ties broken by id) giving display order.\nCREATE TABLE IF NOT EXISTS doc_blocks (\n id TEXT PRIMARY KEY,\n doc_id TEXT,\n text TEXT,\n order_key TEXT,\n blank_after INTEGER NOT NULL DEFAULT 0, -- extra blank lines kept after this block (user spacing)\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_doc_blocks_doc ON doc_blocks(doc_id);\n\n-- A named static site (Supabase-Storage-style bucket). Served at /sites/<name>/.\nCREATE TABLE IF NOT EXISTS sites (\n id TEXT PRIMARY KEY,\n name TEXT, -- URL slug; resolved by getSiteByName\n title TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\n\n-- One row per file in a site. content holds inline utf8/base64 text, or a blob\n-- hash (see cache.ts) when encoding = 'blob'. (site_id, path) maps to a stable\n-- id so re-uploads merge as a CRDT register instead of duplicating.\nCREATE TABLE IF NOT EXISTS site_files (\n id TEXT PRIMARY KEY,\n site_id TEXT,\n path TEXT,\n content_type TEXT,\n encoding TEXT, -- 'utf8' | 'base64' | 'blob'\n content TEXT,\n created_hlc TEXT,\n __deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_site_files_site ON site_files(site_id);\n";
|
|
2
2
|
export declare const FTS_SCHEMA = "\nCREATE VIRTUAL TABLE IF NOT EXISTS search_fts USING fts5(\n kind UNINDEXED,\n id UNINDEXED,\n database_id UNINDEXED,\n title,\n body\n);\n";
|
|
3
3
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kzKAgJvB,CAAC;AAGF,eAAO,MAAM,UAAU,sJAQtB,CAAC"}
|
package/dist/core/search.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
export interface SearchHit {
|
|
3
3
|
type: "document" | "record";
|
|
4
4
|
id: string;
|
|
@@ -7,8 +7,8 @@ export interface SearchHit {
|
|
|
7
7
|
snippet: string;
|
|
8
8
|
}
|
|
9
9
|
/** Force a full rebuild of the search index (maintenance / repair). */
|
|
10
|
-
export declare function rebuildSearchIndex(db:
|
|
11
|
-
export declare function search(db:
|
|
10
|
+
export declare function rebuildSearchIndex(db: DbDriver): boolean;
|
|
11
|
+
export declare function search(db: DbDriver, query: string, opts?: {
|
|
12
12
|
limit?: number;
|
|
13
13
|
}): SearchHit[];
|
|
14
14
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/core/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/core/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAwKD,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAIxD;AAoFD,wBAAgB,MAAM,CACpB,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,SAAS,EAAE,CAWb"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
|
+
export interface SiteRow {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
title: string | null;
|
|
6
|
+
created_hlc: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SITE_COLS: readonly ["id", "name", "title", "created_hlc"];
|
|
9
|
+
export type FileEncoding = "utf8" | "base64" | "blob";
|
|
10
|
+
export interface SiteFileRow {
|
|
11
|
+
id: string;
|
|
12
|
+
site_id: string;
|
|
13
|
+
path: string;
|
|
14
|
+
content_type: string;
|
|
15
|
+
encoding: FileEncoding;
|
|
16
|
+
/** Inline text/base64, or a blob hash when encoding === "blob". */
|
|
17
|
+
content: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Manifest entry — file metadata without the (potentially large) content. */
|
|
20
|
+
export type SiteFileSummary = Omit<SiteFileRow, "content">;
|
|
21
|
+
export declare const SITE_FILE_COLS: readonly ["id", "site_id", "path", "content_type", "encoding", "content"];
|
|
22
|
+
export declare const SITE_FILE_SELECT: string;
|
|
23
|
+
/** Guess a content type from a file path's extension; default octet-stream. */
|
|
24
|
+
export declare function inferContentType(path: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Canonical site slug: lowercase, [a-z0-9-] only, no leading/trailing/repeated
|
|
27
|
+
* dashes. Applied at every write and lookup so the served URL (/sites/<name>/),
|
|
28
|
+
* duplicate detection, and sync replication all agree on one form regardless of
|
|
29
|
+
* how the name was typed (CLI, API, or browser). Throws when nothing usable
|
|
30
|
+
* remains (empty, or all-punctuation). Matches the WebUI's slugify exactly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeSiteName(raw: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Canonical in-site file path: drop empty / "." segments, resolve ".." within
|
|
35
|
+
* the bucket, strip leading and duplicate slashes. Files live in SQLite keyed by
|
|
36
|
+
* this exact string (there is no filesystem behind them), so normalizing at the
|
|
37
|
+
* write/serve boundary keeps storage, URL routing, and deletes consistent no
|
|
38
|
+
* matter how the path was typed or percent-encoded. May return "" (caller decides).
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeSitePath(raw: string): string;
|
|
41
|
+
export declare function getSite(db: DbDriver, id: string): SiteRow | null;
|
|
42
|
+
/** Most recently created live site with this name (URL routing). */
|
|
43
|
+
export declare function getSiteByName(db: DbDriver, name: string): SiteRow | null;
|
|
44
|
+
export declare function listSites(db: DbDriver): SiteRow[];
|
|
45
|
+
/** Resolve a site ref (`site_…` id or name) to its row, or throw. */
|
|
46
|
+
export declare function resolveSite(db: DbDriver, ref: string): SiteRow;
|
|
47
|
+
/**
|
|
48
|
+
* Portable half of file serving: canonical path resolution ("" / trailing "/"
|
|
49
|
+
* → index.html, same normalization putFile stored under) + the raw row. Used
|
|
50
|
+
* directly by the browser replica's worker, which must decode utf8/base64
|
|
51
|
+
* itself and cannot reach "blob" content at all (blob bytes live in the
|
|
52
|
+
* server's on-disk store, not the oplog — they don't replicate).
|
|
53
|
+
*/
|
|
54
|
+
export declare function getFileRow(db: DbDriver, siteId: string, path: string): {
|
|
55
|
+
content_type: string;
|
|
56
|
+
encoding: FileEncoding;
|
|
57
|
+
content: string | null;
|
|
58
|
+
} | null;
|
|
59
|
+
export declare function listFiles(db: DbDriver, siteId: string): SiteFileSummary[];
|
|
60
|
+
//# sourceMappingURL=sites-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-core.d.ts","sourceRoot":"","sources":["../../src/core/sites-core.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,iDAAkD,CAAC;AAIzE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,mEAAmE;IACnE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,8EAA8E;AAC9E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAE3D,eAAO,MAAM,cAAc,2EAEjB,CAAC;AAEX,eAAO,MAAM,gBAAgB,QAA4B,CAAC;AA+B1D,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD;AAID;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrD;AAID,wBAAgB,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAIhE;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAcxE;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,EAAE,CAIjD;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAK9D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAWjF;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE,CAMzE"}
|
package/dist/core/sites.d.ts
CHANGED
|
@@ -1,65 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
title: string | null;
|
|
6
|
-
created_hlc: string;
|
|
7
|
-
}
|
|
8
|
-
export type FileEncoding = "utf8" | "base64" | "blob";
|
|
9
|
-
export interface SiteFileRow {
|
|
10
|
-
id: string;
|
|
11
|
-
site_id: string;
|
|
12
|
-
path: string;
|
|
13
|
-
content_type: string;
|
|
14
|
-
encoding: FileEncoding;
|
|
15
|
-
/** Inline text/base64, or a blob hash when encoding === "blob". */
|
|
16
|
-
content: string | null;
|
|
17
|
-
}
|
|
18
|
-
/** Manifest entry — file metadata without the (potentially large) content. */
|
|
19
|
-
export type SiteFileSummary = Omit<SiteFileRow, "content">;
|
|
20
|
-
/** Guess a content type from a file path's extension; default octet-stream. */
|
|
21
|
-
export declare function inferContentType(path: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Canonical site slug: lowercase, [a-z0-9-] only, no leading/trailing/repeated
|
|
24
|
-
* dashes. Applied at every write and lookup so the served URL (/sites/<name>/),
|
|
25
|
-
* duplicate detection, and sync replication all agree on one form regardless of
|
|
26
|
-
* how the name was typed (CLI, API, or browser). Throws when nothing usable
|
|
27
|
-
* remains (empty, or all-punctuation). Matches the WebUI's slugify exactly.
|
|
28
|
-
*/
|
|
29
|
-
export declare function normalizeSiteName(raw: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Canonical in-site file path: drop empty / "." segments, resolve ".." within
|
|
32
|
-
* the bucket, strip leading and duplicate slashes. Files live in SQLite keyed by
|
|
33
|
-
* this exact string (there is no filesystem behind them), so normalizing at the
|
|
34
|
-
* write/serve boundary keeps storage, URL routing, and deletes consistent no
|
|
35
|
-
* matter how the path was typed or percent-encoded. May return "" (caller decides).
|
|
36
|
-
*/
|
|
37
|
-
export declare function normalizeSitePath(raw: string): string;
|
|
38
|
-
export declare function createSite(db: Database, opts: {
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
|
+
import { type SiteRow, type SiteFileRow } from "./sites-core.ts";
|
|
3
|
+
export * from "./sites-core.ts";
|
|
4
|
+
export declare const createSite: (db: DbDriver, opts: {
|
|
39
5
|
name: string;
|
|
40
6
|
title?: string;
|
|
41
|
-
})
|
|
42
|
-
export declare function getSite(db: Database, id: string): SiteRow | null;
|
|
43
|
-
/** Most recently created live site with this name (URL routing). */
|
|
44
|
-
export declare function getSiteByName(db: Database, name: string): SiteRow | null;
|
|
45
|
-
export declare function listSites(db: Database): SiteRow[];
|
|
46
|
-
/** Resolve a site ref (`site_…` id or name) to its row, or throw. */
|
|
47
|
-
export declare function resolveSite(db: Database, ref: string): SiteRow;
|
|
7
|
+
}) => SiteRow;
|
|
48
8
|
/** Rename a site and/or change its title. Guards against duplicate names. */
|
|
49
|
-
export declare
|
|
9
|
+
export declare const updateSite: (db: DbDriver, id: string, opts: {
|
|
50
10
|
name?: string;
|
|
51
11
|
title?: string;
|
|
52
|
-
})
|
|
53
|
-
export declare
|
|
12
|
+
}) => SiteRow;
|
|
13
|
+
export declare const deleteSite: (db: DbDriver, id: string) => boolean;
|
|
54
14
|
/** Upload or replace one file. Picks utf8 / base64 / blob storage automatically. */
|
|
55
|
-
export declare function putFile(db:
|
|
15
|
+
export declare function putFile(db: DbDriver, siteId: string, path: string, opts: {
|
|
56
16
|
data: string | Uint8Array | ArrayBuffer;
|
|
57
17
|
contentType?: string;
|
|
58
18
|
}): Promise<SiteFileRow>;
|
|
59
|
-
export declare
|
|
60
|
-
export declare function deleteFile(db: Database, siteId: string, path: string): boolean;
|
|
19
|
+
export declare const deleteFile: (db: DbDriver, siteId: string, path: string) => boolean;
|
|
61
20
|
/** Resolve a file to served bytes + content type. "" / trailing "/" → index.html. */
|
|
62
|
-
export declare function getFileForServe(db:
|
|
21
|
+
export declare function getFileForServe(db: DbDriver, siteId: string, path: string): Promise<{
|
|
63
22
|
contentType: string;
|
|
64
23
|
bytes: Uint8Array;
|
|
65
24
|
} | null>;
|
package/dist/core/sites.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/core/sites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/core/sites.ts"],"names":[],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AC/B,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/core/sync/auth.d.ts
CHANGED
|
@@ -36,10 +36,12 @@ declare const HTML_HEADERS: {
|
|
|
36
36
|
};
|
|
37
37
|
/** Self-contained password prompt: stores token to localStorage + cookie, reloads. */
|
|
38
38
|
export declare function unlockPage(): string;
|
|
39
|
-
/** Insert the
|
|
39
|
+
/** Insert the runtime into an HTML document (right after <head>, else prepend). */
|
|
40
40
|
export declare function injectShim(html: string): string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/** Inject the page runtime into HTML responses. Unconditional (unlike the old
|
|
42
|
+
* token-only shim): the offline bridge matters even in --debug mode where
|
|
43
|
+
* auth is off — the token half simply no-ops without a stored token. */
|
|
44
|
+
export declare function withShim(res: Response, _cfg: AuthConfig): Promise<Response>;
|
|
43
45
|
export declare function unauthorized(): Response;
|
|
44
46
|
export { HTML_HEADERS };
|
|
45
47
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/sync/auth.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAcD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAIlE;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED,0EAA0E;AAC1E,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
4
4
|
pulled: number;
|
|
5
5
|
}
|
|
6
|
+
export interface SyncOpts {
|
|
7
|
+
/** Bearer credential; defaults to the one stored for this peer (pairing). */
|
|
8
|
+
token?: string;
|
|
9
|
+
/** Max changes to pull this round — chunked initial hydration. */
|
|
10
|
+
pullLimit?: number;
|
|
11
|
+
/** Datasets this replica opts out of (partial replica, e.g. site_files). */
|
|
12
|
+
excludeDatasets?: string[];
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Run one push/pull round against a peer server. A single round is bidirectional
|
|
8
|
-
* (pushes local changes, pulls remote ones).
|
|
16
|
+
* (pushes local changes, pulls remote ones). The token defaults to the credential
|
|
9
17
|
* stored for this peer (set during pairing) and is sent as a Bearer header so a
|
|
10
18
|
* token-gated /sync accepts the request.
|
|
11
19
|
*/
|
|
12
|
-
export declare function syncWithPeer(db:
|
|
20
|
+
export declare function syncWithPeer(db: DbDriver, url: string, opts?: SyncOpts | string): Promise<SyncResult>;
|
|
13
21
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/core/sync/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/core/sync/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAyB7C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,QAAQ,GAAG,MAAW,GAC3B,OAAO,CAAC,UAAU,CAAC,CAiCrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DbDriver } from "../driver.ts";
|
|
2
2
|
export interface PeerRow {
|
|
3
3
|
url: string;
|
|
4
4
|
pull_cursor: number;
|
|
@@ -11,8 +11,8 @@ export interface PeerRow {
|
|
|
11
11
|
last_status: string | null;
|
|
12
12
|
last_error: string | null;
|
|
13
13
|
}
|
|
14
|
-
export declare function listPeers(db:
|
|
15
|
-
export declare function getPeer(db:
|
|
14
|
+
export declare function listPeers(db: DbDriver): PeerRow[];
|
|
15
|
+
export declare function getPeer(db: DbDriver, url: string): PeerRow | null;
|
|
16
16
|
export interface AddPeerInput {
|
|
17
17
|
url: string;
|
|
18
18
|
token?: string | null;
|
|
@@ -20,17 +20,17 @@ export interface AddPeerInput {
|
|
|
20
20
|
node_id?: string | null;
|
|
21
21
|
}
|
|
22
22
|
/** Upsert a peer, preserving replication cursors on conflict. */
|
|
23
|
-
export declare function addPeer(db:
|
|
23
|
+
export declare function addPeer(db: DbDriver, input: AddPeerInput): void;
|
|
24
24
|
/**
|
|
25
25
|
* Remove a peer AND revoke the credential we issued to it during pairing, so
|
|
26
26
|
* disconnecting is mutual: we stop syncing out to it (peers row) and it can no
|
|
27
27
|
* longer sync in to us (peer_grants row, keyed by peer_url). Grants minted for a
|
|
28
28
|
* peer that never sent a self_url have a null peer_url and can't be revoked here.
|
|
29
29
|
*/
|
|
30
|
-
export declare function removePeer(db:
|
|
31
|
-
export declare function setPeerEnabled(db:
|
|
32
|
-
export declare function setPeerLabel(db:
|
|
33
|
-
export declare function updatePeerStatus(db:
|
|
30
|
+
export declare function removePeer(db: DbDriver, url: string): boolean;
|
|
31
|
+
export declare function setPeerEnabled(db: DbDriver, url: string, enabled: boolean): boolean;
|
|
32
|
+
export declare function setPeerLabel(db: DbDriver, url: string, label: string): boolean;
|
|
33
|
+
export declare function updatePeerStatus(db: DbDriver, url: string, status: string, error?: string | null): void;
|
|
34
34
|
export interface PeerSyncOutcome {
|
|
35
35
|
url: string;
|
|
36
36
|
ok: boolean;
|
|
@@ -39,7 +39,7 @@ export interface PeerSyncOutcome {
|
|
|
39
39
|
error?: string;
|
|
40
40
|
}
|
|
41
41
|
/** Sync once with a single peer, recording status. Errors are captured, not thrown. */
|
|
42
|
-
export declare function syncPeer(db:
|
|
42
|
+
export declare function syncPeer(db: DbDriver, url: string): Promise<PeerSyncOutcome>;
|
|
43
43
|
/** Sync once with every enabled peer. Used by the auto-sync timer. */
|
|
44
|
-
export declare function syncAllPeers(db:
|
|
44
|
+
export declare function syncAllPeers(db: DbDriver): Promise<PeerSyncOutcome[]>;
|
|
45
45
|
//# sourceMappingURL=peers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peers.d.ts","sourceRoot":"","sources":["../../../src/core/sync/peers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"peers.d.ts","sourceRoot":"","sources":["../../../src/core/sync/peers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG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Q,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAUlF;AAED,sEAAsE;AACtE,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAK3E"}
|
|
@@ -7,6 +7,7 @@ export declare const ChangeSchema: z.ZodObject<{
|
|
|
7
7
|
row_id: z.ZodString;
|
|
8
8
|
col: z.ZodString;
|
|
9
9
|
value: z.ZodNullable<z.ZodString>;
|
|
10
|
+
txn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
11
|
}, z.core.$strip>;
|
|
11
12
|
export declare const SyncRequestSchema: z.ZodObject<{
|
|
12
13
|
node_id: z.ZodString;
|
|
@@ -18,7 +19,10 @@ export declare const SyncRequestSchema: z.ZodObject<{
|
|
|
18
19
|
row_id: z.ZodString;
|
|
19
20
|
col: z.ZodString;
|
|
20
21
|
value: z.ZodNullable<z.ZodString>;
|
|
22
|
+
txn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
23
|
}, z.core.$strip>>;
|
|
24
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
exclude_datasets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
26
|
}, z.core.$strip>;
|
|
23
27
|
export declare const SyncResponseSchema: z.ZodObject<{
|
|
24
28
|
node_id: z.ZodString;
|
|
@@ -29,6 +33,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
29
33
|
row_id: z.ZodString;
|
|
30
34
|
col: z.ZodString;
|
|
31
35
|
value: z.ZodNullable<z.ZodString>;
|
|
36
|
+
txn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
37
|
}, z.core.$strip>>;
|
|
33
38
|
cursor: z.ZodNumber;
|
|
34
39
|
}, z.core.$strip>;
|