datanotes 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api/extension-columns.d.cts +64 -0
- package/dist/api/extension-columns.d.ts +64 -0
- package/dist/api/extension-plan.d.cts +1 -1
- package/dist/api/extension-plan.d.ts +1 -1
- package/dist/api/extensions.cjs +1088 -5
- package/dist/api/extensions.js +1088 -5
- package/dist/api/index.cjs +1088 -5
- package/dist/api/index.js +1088 -5
- package/dist/api/mcp.cjs +1088 -5
- package/dist/api/mcp.js +1088 -5
- package/dist/datanotes.cjs +4701 -1665
- package/dist/docs/administration/extensions.md +2 -1
- package/dist/docs/administration/git-sync.md +17 -0
- package/dist/docs/administration/limits.md +29 -0
- package/dist/docs/administration/use-with-obsidian.md +12 -0
- package/dist/docs/api/operations/alter_table.md +6 -1
- package/dist/docs/api/operations/create_table.md +5 -0
- package/dist/docs/api/operations/describe_table.md +1 -1
- package/dist/docs/api/operations/pack_rows.md +45 -0
- package/dist/docs/api/operations/tags/auxiliary.md +2 -0
- package/dist/docs/api/operations/unpack_rows.md +40 -0
- package/dist/docs/api.md +3 -1
- package/dist/docs/develop/write-an-extension.md +8 -2
- package/dist/docs/guides/data-quality/check-constraints.md +10 -10
- package/dist/docs/guides/data-quality/hand-edits.md +8 -8
- package/dist/docs/guides/database-objects/bases.md +11 -11
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +10 -10
- package/dist/docs/guides/database-objects/columns.md +41 -41
- package/dist/docs/guides/database-objects/packs.md +563 -0
- package/dist/docs/guides/database-objects/relations.md +28 -28
- package/dist/docs/guides/database-objects/tables.md +28 -28
- package/dist/docs/guides/database-objects/views.md +44 -44
- package/dist/docs/guides/history/change-data-feed.md +34 -34
- package/dist/docs/guides/history/journal-and-undo.md +12 -12
- package/dist/docs/guides/history/restore.md +20 -20
- package/dist/docs/guides/history/table-history.md +31 -31
- package/dist/docs/guides/read-and-write/automatic-links.md +15 -15
- package/dist/docs/guides/read-and-write/import-notes.md +21 -21
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +7 -7
- package/dist/docs/guides/read-and-write/read-and-filter.md +10 -10
- package/dist/docs/guides/read-and-write/write-rows.md +10 -10
- package/dist/docs/guides/search/text.md +1 -1
- package/dist/docs/reference/cli.md +3 -1
- package/dist/docs/reference/operations/auxiliary.md +30 -1
- package/dist/docs/reference/operations/queries.md +1 -1
- package/dist/docs/reference/operations/rows.md +3 -3
- package/dist/docs/reference/operations/schema.md +8 -4
- package/dist/docs/reference/operations.md +55 -53
- package/dist/docs/reference/settings.md +1 -0
- package/dist/docs/release-notes.md +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Datanotes is the open-source database engine for Markdown: it runs a folder of n
|
|
|
14
14
|
|
|
15
15
|
- **Agents can't write garbage.** Every write is checked against its table: types, links, unique values and CHECK constraints. A refused write changes nothing. Its answer says which value broke which rule and how to fix it.
|
|
16
16
|
- **Every change can be undone.** The engine journals every write it makes. It records who made it: the agent, its session and its token. `undo_migration` takes any change back.
|
|
17
|
-
- **It's still just Markdown.** A row is a note, and its front matter keys are the columns. Read it, edit it, grep it or commit it to Git. The engine reads your hand edits and checks them too.
|
|
17
|
+
- **It's still just Markdown.** A row is a note, or a section of a pack note, and its front matter keys are the columns. Read it, edit it, grep it or commit it to Git. The engine reads your hand edits and checks them too.
|
|
18
18
|
- **Extensions.** Install tables and MCP tools from a git repository, pinned and confirmed (`datanotes extension install`).
|
|
19
19
|
- **Local first.** Datanotes is Apache-2.0 and runs on your machine. Nothing leaves it unless you turn that feature on.
|
|
20
20
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column bindings of an extension: the manifest columns of a dependency role may be bound to
|
|
3
|
+
* columns of another name in the user's table (`--map role.column=column`). The manifest names
|
|
4
|
+
* columns in its view queries, CHECKs and link filters; this module rewrites those names to the
|
|
5
|
+
* bound ones, following link columns from role to role (`book.author.name`). Pure: no I/O.
|
|
6
|
+
*
|
|
7
|
+
* What it cannot rewrite safely it reports as an issue (fail closed), never guesses: a mapped
|
|
8
|
+
* column named in the outer clauses of a union view, or under a query key it does not know.
|
|
9
|
+
*/
|
|
10
|
+
import type { ExtensionManifest, ManifestColumn } from "./extension-manifest.cjs";
|
|
11
|
+
/** role → (manifest column → bound column); only the columns whose names differ matter. */
|
|
12
|
+
export type ColumnMap = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
13
|
+
/** A place where a mapped column is named and cannot be rewritten. */
|
|
14
|
+
export interface ColumnIssue {
|
|
15
|
+
role: string;
|
|
16
|
+
column: string;
|
|
17
|
+
/** Where it is named: `view vw_x (union order_by)`. */
|
|
18
|
+
where: string;
|
|
19
|
+
}
|
|
20
|
+
type Obj = Record<string, unknown>;
|
|
21
|
+
/** Rewrites the column names of bound roles; `issues` collects what it could not rewrite. */
|
|
22
|
+
export declare class ColumnBinder {
|
|
23
|
+
private readonly manifest;
|
|
24
|
+
readonly issues: ColumnIssue[];
|
|
25
|
+
private readonly map;
|
|
26
|
+
constructor(manifest: Pick<ExtensionManifest, "tables">, map: ColumnMap);
|
|
27
|
+
/** True when no role has a column bound to another name: every rewrite is the identity. */
|
|
28
|
+
get empty(): boolean;
|
|
29
|
+
/** The bound name of a role's manifest column. */
|
|
30
|
+
name(role: string | null, column: string): string;
|
|
31
|
+
/** The manifest columns of a role bound to another name. */
|
|
32
|
+
mapped(role: string): string[];
|
|
33
|
+
/** The role a link column of `role` points to (`ref: "@x"`, or `self`), or null. */
|
|
34
|
+
private linkRole;
|
|
35
|
+
/** A dotted column path read on `role`: each part on the role the previous link points to. */
|
|
36
|
+
path(role: string | null, dotted: string): string;
|
|
37
|
+
/** A group_by or join expression: `col`, `path`, `date(col)`, `date(col)+1`. */
|
|
38
|
+
expr(role: string | null, e: string): string;
|
|
39
|
+
/** A `where` filter (or a CHECK) on `role`: keys are column paths; `or` / `and` / `not` nest. */
|
|
40
|
+
where(role: string | null, where: unknown): unknown;
|
|
41
|
+
/** A column spec of `role`: its link filter (`ref_where`), `ref_by`, `inverse`. */
|
|
42
|
+
column(role: string, c: ManifestColumn): ManifestColumn;
|
|
43
|
+
/** A view query: the tables it reads are roles (`@meal`); every column it names follows them. */
|
|
44
|
+
query(view: string, q: Obj): Obj;
|
|
45
|
+
private order;
|
|
46
|
+
/** `count`, `count:col`, `sum:meal.kcal`. */
|
|
47
|
+
private aggregate;
|
|
48
|
+
/** `{table, on: {left expr: right expr}, as, type, columns, where}`: `columns` and `where` read the joined table. */
|
|
49
|
+
private join;
|
|
50
|
+
/** `{union: [{table, columns, where}], …}`: each part on its role; the outer clauses read every part, so a mapped column there is an issue. */
|
|
51
|
+
private union;
|
|
52
|
+
/** A clause the binder does not rewrite: an issue for each mapped column it names. */
|
|
53
|
+
private unknown;
|
|
54
|
+
/**
|
|
55
|
+
* The mapped columns a value names, where nothing rewrites it: a word that is a mapped column of
|
|
56
|
+
* one of `roles`, or a later part of a dotted path (`author.name`) that is a mapped column of any
|
|
57
|
+
* role. `keys(key, inKeys)` tells whether the keys under `key` are names too.
|
|
58
|
+
*/
|
|
59
|
+
named(v: unknown, roles: string[], keys: (key: string, inKeys: boolean) => boolean): {
|
|
60
|
+
role: string;
|
|
61
|
+
column: string;
|
|
62
|
+
}[];
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column bindings of an extension: the manifest columns of a dependency role may be bound to
|
|
3
|
+
* columns of another name in the user's table (`--map role.column=column`). The manifest names
|
|
4
|
+
* columns in its view queries, CHECKs and link filters; this module rewrites those names to the
|
|
5
|
+
* bound ones, following link columns from role to role (`book.author.name`). Pure: no I/O.
|
|
6
|
+
*
|
|
7
|
+
* What it cannot rewrite safely it reports as an issue (fail closed), never guesses: a mapped
|
|
8
|
+
* column named in the outer clauses of a union view, or under a query key it does not know.
|
|
9
|
+
*/
|
|
10
|
+
import type { ExtensionManifest, ManifestColumn } from "./extension-manifest.js";
|
|
11
|
+
/** role → (manifest column → bound column); only the columns whose names differ matter. */
|
|
12
|
+
export type ColumnMap = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
13
|
+
/** A place where a mapped column is named and cannot be rewritten. */
|
|
14
|
+
export interface ColumnIssue {
|
|
15
|
+
role: string;
|
|
16
|
+
column: string;
|
|
17
|
+
/** Where it is named: `view vw_x (union order_by)`. */
|
|
18
|
+
where: string;
|
|
19
|
+
}
|
|
20
|
+
type Obj = Record<string, unknown>;
|
|
21
|
+
/** Rewrites the column names of bound roles; `issues` collects what it could not rewrite. */
|
|
22
|
+
export declare class ColumnBinder {
|
|
23
|
+
private readonly manifest;
|
|
24
|
+
readonly issues: ColumnIssue[];
|
|
25
|
+
private readonly map;
|
|
26
|
+
constructor(manifest: Pick<ExtensionManifest, "tables">, map: ColumnMap);
|
|
27
|
+
/** True when no role has a column bound to another name: every rewrite is the identity. */
|
|
28
|
+
get empty(): boolean;
|
|
29
|
+
/** The bound name of a role's manifest column. */
|
|
30
|
+
name(role: string | null, column: string): string;
|
|
31
|
+
/** The manifest columns of a role bound to another name. */
|
|
32
|
+
mapped(role: string): string[];
|
|
33
|
+
/** The role a link column of `role` points to (`ref: "@x"`, or `self`), or null. */
|
|
34
|
+
private linkRole;
|
|
35
|
+
/** A dotted column path read on `role`: each part on the role the previous link points to. */
|
|
36
|
+
path(role: string | null, dotted: string): string;
|
|
37
|
+
/** A group_by or join expression: `col`, `path`, `date(col)`, `date(col)+1`. */
|
|
38
|
+
expr(role: string | null, e: string): string;
|
|
39
|
+
/** A `where` filter (or a CHECK) on `role`: keys are column paths; `or` / `and` / `not` nest. */
|
|
40
|
+
where(role: string | null, where: unknown): unknown;
|
|
41
|
+
/** A column spec of `role`: its link filter (`ref_where`), `ref_by`, `inverse`. */
|
|
42
|
+
column(role: string, c: ManifestColumn): ManifestColumn;
|
|
43
|
+
/** A view query: the tables it reads are roles (`@meal`); every column it names follows them. */
|
|
44
|
+
query(view: string, q: Obj): Obj;
|
|
45
|
+
private order;
|
|
46
|
+
/** `count`, `count:col`, `sum:meal.kcal`. */
|
|
47
|
+
private aggregate;
|
|
48
|
+
/** `{table, on: {left expr: right expr}, as, type, columns, where}`: `columns` and `where` read the joined table. */
|
|
49
|
+
private join;
|
|
50
|
+
/** `{union: [{table, columns, where}], …}`: each part on its role; the outer clauses read every part, so a mapped column there is an issue. */
|
|
51
|
+
private union;
|
|
52
|
+
/** A clause the binder does not rewrite: an issue for each mapped column it names. */
|
|
53
|
+
private unknown;
|
|
54
|
+
/**
|
|
55
|
+
* The mapped columns a value names, where nothing rewrites it: a word that is a mapped column of
|
|
56
|
+
* one of `roles`, or a later part of a dotted path (`author.name`) that is a mapped column of any
|
|
57
|
+
* role. `keys(key, inKeys)` tells whether the keys under `key` are names too.
|
|
58
|
+
*/
|
|
59
|
+
named(v: unknown, roles: string[], keys: (key: string, inKeys: boolean) => boolean): {
|
|
60
|
+
role: string;
|
|
61
|
+
column: string;
|
|
62
|
+
}[];
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -48,7 +48,7 @@ export interface TableChoice {
|
|
|
48
48
|
proposed: boolean;
|
|
49
49
|
candidates: string[];
|
|
50
50
|
}
|
|
51
|
-
export type ProblemCode = "engine_too_old" | "unknown_role" | "table_not_found" | "table_missing" | "table_exists" | "owned_create" | "ambiguous_dependency" | "missing_column" | "column_differs" | "owned_column_map" | "migration_conflict" | "base_differs" | "view_exists" | "tool_name_taken" | "token_exists" | "too_many_operations" | "already_installed" | "downgrade" | "same_version";
|
|
51
|
+
export type ProblemCode = "engine_too_old" | "unknown_role" | "table_not_found" | "table_missing" | "table_exists" | "owned_create" | "ambiguous_dependency" | "missing_column" | "column_differs" | "owned_column_map" | "column_map_unsupported" | "migration_conflict" | "base_differs" | "view_exists" | "tool_name_taken" | "token_exists" | "too_many_operations" | "already_installed" | "downgrade" | "same_version";
|
|
52
52
|
/** Something that keeps the plan from being written: what is wrong, how to fix it, where to read more. */
|
|
53
53
|
export interface PlanProblem {
|
|
54
54
|
code: ProblemCode;
|
|
@@ -48,7 +48,7 @@ export interface TableChoice {
|
|
|
48
48
|
proposed: boolean;
|
|
49
49
|
candidates: string[];
|
|
50
50
|
}
|
|
51
|
-
export type ProblemCode = "engine_too_old" | "unknown_role" | "table_not_found" | "table_missing" | "table_exists" | "owned_create" | "ambiguous_dependency" | "missing_column" | "column_differs" | "owned_column_map" | "migration_conflict" | "base_differs" | "view_exists" | "tool_name_taken" | "token_exists" | "too_many_operations" | "already_installed" | "downgrade" | "same_version";
|
|
51
|
+
export type ProblemCode = "engine_too_old" | "unknown_role" | "table_not_found" | "table_missing" | "table_exists" | "owned_create" | "ambiguous_dependency" | "missing_column" | "column_differs" | "owned_column_map" | "column_map_unsupported" | "migration_conflict" | "base_differs" | "view_exists" | "tool_name_taken" | "token_exists" | "too_many_operations" | "already_installed" | "downgrade" | "same_version";
|
|
52
52
|
/** Something that keeps the plan from being written: what is wrong, how to fix it, where to read more. */
|
|
53
53
|
export interface PlanProblem {
|
|
54
54
|
code: ProblemCode;
|