datanotes 2.0.0 → 3.0.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 (181) hide show
  1. package/NOTICE +9 -0
  2. package/README.md +207 -28
  3. package/SECURITY.md +92 -45
  4. package/dist/THIRD-PARTY-NOTICES.txt +682 -0
  5. package/dist/api/catalog.d.cts +69 -0
  6. package/dist/api/catalog.d.ts +50 -2
  7. package/dist/api/cli-options.d.cts +39 -0
  8. package/dist/api/cli-options.d.ts +39 -0
  9. package/dist/api/client.d.cts +89 -0
  10. package/dist/api/client.d.ts +19 -30
  11. package/dist/api/docs.d.cts +211 -0
  12. package/dist/api/docs.d.ts +211 -0
  13. package/dist/api/guidance.d.cts +81 -0
  14. package/dist/api/guidance.d.ts +81 -0
  15. package/dist/api/index.cjs +6610 -2247
  16. package/dist/api/index.d.cts +13 -0
  17. package/dist/api/index.d.ts +10 -7
  18. package/dist/api/index.js +6610 -2247
  19. package/dist/api/local.cjs +118 -6
  20. package/dist/api/local.d.cts +95 -0
  21. package/dist/api/local.d.ts +70 -6
  22. package/dist/api/local.js +104 -6
  23. package/dist/api/mcp.cjs +17384 -0
  24. package/dist/api/mcp.d.cts +108 -0
  25. package/dist/api/mcp.d.ts +108 -0
  26. package/dist/api/mcp.js +17334 -0
  27. package/dist/api/otlp.d.cts +65 -0
  28. package/dist/api/redact.d.cts +17 -0
  29. package/dist/api/redact.d.ts +17 -0
  30. package/dist/api/requests.d.cts +26 -0
  31. package/dist/api/requests.d.ts +14 -16
  32. package/dist/api/results.d.cts +16 -0
  33. package/dist/api/results.d.ts +2 -1
  34. package/dist/api/tokens.d.cts +7 -0
  35. package/dist/datanotes.cjs +62911 -28409
  36. package/dist/docs/administration/configuration.md +59 -0
  37. package/dist/docs/administration/docker.md +80 -0
  38. package/dist/docs/administration/git-sync.md +71 -0
  39. package/dist/docs/administration/limits.md +69 -0
  40. package/dist/docs/administration/run-the-service.md +219 -0
  41. package/dist/docs/administration/status.md +61 -0
  42. package/dist/docs/administration/use-with-obsidian.md +75 -0
  43. package/dist/docs/api/operations/add_column.md +49 -0
  44. package/dist/docs/api/operations/add_constraint.md +55 -0
  45. package/dist/docs/api/operations/adopt_rows.md +50 -0
  46. package/dist/docs/api/operations/align_relations.md +41 -0
  47. package/dist/docs/api/operations/alter_column.md +46 -0
  48. package/dist/docs/api/operations/alter_table.md +67 -0
  49. package/dist/docs/api/operations/batch.md +48 -0
  50. package/dist/docs/api/operations/changes_stream.md +28 -0
  51. package/dist/docs/api/operations/check_table.md +29 -0
  52. package/dist/docs/api/operations/clone_table.md +48 -0
  53. package/dist/docs/api/operations/comment_on.md +42 -0
  54. package/dist/docs/api/operations/configure_database.md +52 -0
  55. package/dist/docs/api/operations/create_table.md +78 -0
  56. package/dist/docs/api/operations/create_view.md +54 -0
  57. package/dist/docs/api/operations/create_webhook.md +37 -0
  58. package/dist/docs/api/operations/define_base.md +52 -0
  59. package/dist/docs/api/operations/delete_rows.md +43 -0
  60. package/dist/docs/api/operations/delete_webhook.md +31 -0
  61. package/dist/docs/api/operations/describe_database.md +30 -0
  62. package/dist/docs/api/operations/describe_history.md +40 -0
  63. package/dist/docs/api/operations/describe_semantic_index.md +24 -0
  64. package/dist/docs/api/operations/describe_table.md +38 -0
  65. package/dist/docs/api/operations/docs.md +13 -0
  66. package/dist/docs/api/operations/drop_column.md +41 -0
  67. package/dist/docs/api/operations/drop_constraint.md +39 -0
  68. package/dist/docs/api/operations/drop_table.md +43 -0
  69. package/dist/docs/api/operations/drop_view.md +38 -0
  70. package/dist/docs/api/operations/engine_status.md +23 -0
  71. package/dist/docs/api/operations/graph_neighbors.md +32 -0
  72. package/dist/docs/api/operations/graph_path.md +32 -0
  73. package/dist/docs/api/operations/graph_traverse.md +43 -0
  74. package/dist/docs/api/operations/identify_session.md +24 -0
  75. package/dist/docs/api/operations/infer_table.md +43 -0
  76. package/dist/docs/api/operations/insert_row.md +48 -0
  77. package/dist/docs/api/operations/list_changes.md +35 -0
  78. package/dist/docs/api/operations/list_folder.md +28 -0
  79. package/dist/docs/api/operations/list_link_targets.md +44 -0
  80. package/dist/docs/api/operations/list_migrations.md +35 -0
  81. package/dist/docs/api/operations/list_tables.md +32 -0
  82. package/dist/docs/api/operations/list_webhooks.md +23 -0
  83. package/dist/docs/api/operations/manual_index.md +14 -0
  84. package/dist/docs/api/operations/manual_page.md +22 -0
  85. package/dist/docs/api/operations/merge_rows.md +44 -0
  86. package/dist/docs/api/operations/move_rows.md +52 -0
  87. package/dist/docs/api/operations/openapi.md +13 -0
  88. package/dist/docs/api/operations/openapi_post.md +20 -0
  89. package/dist/docs/api/operations/read_note.md +29 -0
  90. package/dist/docs/api/operations/recompute_columns.md +44 -0
  91. package/dist/docs/api/operations/record_tool_call.md +36 -0
  92. package/dist/docs/api/operations/rename_column.md +44 -0
  93. package/dist/docs/api/operations/rename_value.md +45 -0
  94. package/dist/docs/api/operations/restore_database.md +51 -0
  95. package/dist/docs/api/operations/restore_table.md +46 -0
  96. package/dist/docs/api/operations/search_notes.md +28 -0
  97. package/dist/docs/api/operations/select_rows.md +61 -0
  98. package/dist/docs/api/operations/semantic_search.md +34 -0
  99. package/dist/docs/api/operations/semantic_search_docs.md +26 -0
  100. package/dist/docs/api/operations/set_table_bases.md +44 -0
  101. package/dist/docs/api/operations/status.md +13 -0
  102. package/dist/docs/api/operations/stop_engine.md +23 -0
  103. package/dist/docs/api/operations/sync_semantic_index.md +33 -0
  104. package/dist/docs/api/operations/table_changes.md +31 -0
  105. package/dist/docs/api/operations/tags/auxiliary.md +14 -0
  106. package/dist/docs/api/operations/tags/change-feed.md +8 -0
  107. package/dist/docs/api/operations/tags/history.md +17 -0
  108. package/dist/docs/api/operations/tags/queries.md +15 -0
  109. package/dist/docs/api/operations/tags/rows-dml.md +16 -0
  110. package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
  111. package/dist/docs/api/operations/tags/service.md +15 -0
  112. package/dist/docs/api/operations/tags/tokens.md +13 -0
  113. package/dist/docs/api/operations/tokens_create.md +34 -0
  114. package/dist/docs/api/operations/tokens_delete.md +29 -0
  115. package/dist/docs/api/operations/tokens_list.md +21 -0
  116. package/dist/docs/api/operations/tokens_me.md +20 -0
  117. package/dist/docs/api/operations/tokens_rotate.md +29 -0
  118. package/dist/docs/api/operations/tokens_update.md +34 -0
  119. package/dist/docs/api/operations/undo_migration.md +46 -0
  120. package/dist/docs/api/operations/update_row.md +60 -0
  121. package/dist/docs/api/operations/update_rows.md +46 -0
  122. package/dist/docs/api/operations/vacuum_table.md +37 -0
  123. package/dist/docs/api.md +135 -0
  124. package/dist/docs/develop/build-an-app.md +320 -0
  125. package/dist/docs/develop/build-on-datanotes.md +138 -0
  126. package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
  127. package/dist/docs/develop/client.md +116 -0
  128. package/dist/docs/develop/concurrency.md +153 -0
  129. package/dist/docs/develop/http-api.md +79 -0
  130. package/dist/docs/develop/telemetry.md +86 -0
  131. package/dist/docs/guides/agents/docs-offline.md +99 -0
  132. package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
  133. package/dist/docs/guides/agents/prompts.md +495 -0
  134. package/dist/docs/guides/agents/reading-errors.md +112 -0
  135. package/dist/docs/guides/data-quality/check-constraints.md +379 -0
  136. package/dist/docs/guides/data-quality/check-table.md +63 -0
  137. package/dist/docs/guides/data-quality/hand-edits.md +507 -0
  138. package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
  139. package/dist/docs/guides/data-quality/validation.md +90 -0
  140. package/dist/docs/guides/database-objects/bases.md +480 -0
  141. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
  142. package/dist/docs/guides/database-objects/columns.md +1332 -0
  143. package/dist/docs/guides/database-objects/relations.md +1454 -0
  144. package/dist/docs/guides/database-objects/tables.md +1404 -0
  145. package/dist/docs/guides/database-objects/views.md +1003 -0
  146. package/dist/docs/guides/history/back-up.md +195 -0
  147. package/dist/docs/guides/history/change-data-feed.md +247 -0
  148. package/dist/docs/guides/history/journal-and-undo.md +262 -0
  149. package/dist/docs/guides/history/restore.md +341 -0
  150. package/dist/docs/guides/history/table-history.md +657 -0
  151. package/dist/docs/guides/history/vacuum.md +35 -0
  152. package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
  153. package/dist/docs/guides/read-and-write/batch.md +139 -0
  154. package/dist/docs/guides/read-and-write/import-notes.md +896 -0
  155. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
  156. package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
  157. package/dist/docs/guides/read-and-write/write-rows.md +573 -0
  158. package/dist/docs/guides/search/link-graph.md +146 -0
  159. package/dist/docs/guides/search/semantic.md +133 -0
  160. package/dist/docs/guides/search/text.md +142 -0
  161. package/dist/docs/guides/security/security-model.md +110 -0
  162. package/dist/docs/guides/security/tokens.md +60 -0
  163. package/dist/docs/guides/security/who-did-what.md +42 -0
  164. package/dist/docs/index.md +113 -0
  165. package/dist/docs/llms.txt +33 -0
  166. package/dist/docs/reference/cli.md +136 -0
  167. package/dist/docs/reference/compatibility.md +63 -0
  168. package/dist/docs/reference/errors.md +72 -0
  169. package/dist/docs/reference/glossary.md +161 -0
  170. package/dist/docs/reference/operations/auxiliary.md +116 -0
  171. package/dist/docs/reference/operations/history.md +168 -0
  172. package/dist/docs/reference/operations/queries.md +169 -0
  173. package/dist/docs/reference/operations/rows.md +185 -0
  174. package/dist/docs/reference/operations/schema.md +316 -0
  175. package/dist/docs/reference/operations.md +96 -0
  176. package/dist/docs/reference/settings.md +31 -0
  177. package/dist/docs/release-notes.md +67 -0
  178. package/dist/docs/start/connect-agents.md +204 -0
  179. package/dist/docs/start/how-it-works.md +317 -0
  180. package/dist/docs/start/quick-start.md +126 -0
  181. package/package.json +59 -14
@@ -0,0 +1,52 @@
1
+ # Configure the database (persisted in metastore.yaml `config:`): `root` (rename the database
2
+
3
+ `POST /datanotes/operations/configure_database/` (operation `configure_database`)
4
+
5
+ Configure the database (persisted in metastore.yaml `config:`): `root` (rename the database
6
+ folder; links follow; revert by renaming back), `default_catalog`, `default_schema`,
7
+ `default_partition` ("" = flat) and `default_filename` (date formats for new time-based tables),
8
+ `archive_folder`, `timezone` (IANA; completes date-times written without offset), `history`
9
+ (transaction log for every table: true in a database the engine creates, false when
10
+ `config` lacks it, as in a metastore from before 3.0.0; change it only on the user's request), `autolink` (the text a write
11
+ puts in a body links the notes it mentions; on by default). Returns describe_database.
12
+ Renaming `root` moves the folder (links to its notes are rewritten; the tables' archive and
13
+ `exclude` folders inside it follow); the move is listed in the journal as `move_database` (undo
14
+ and time travel read older entries with the new paths) and cannot be undone. Settings changes are
15
+ not journaled (no `migration_id`, nothing for undo_migration): to revert, call it again with the
16
+ previous values.
17
+
18
+ The metastore changes only through operations: never edit metastore.yaml by hand (no validation).
19
+
20
+ ## Parameters
21
+
22
+ | Name | In | Type | Required | Description |
23
+ | --- | --- | --- | --- | --- |
24
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
25
+
26
+ ## Request body
27
+
28
+ `application/json`
29
+
30
+ | Property | Type | Required | Default | Description |
31
+ | --- | --- | --- | --- | --- |
32
+ | `root` | `string \| null` | no | `null` | |
33
+ | `default_catalog` | `string \| null` | no | `null` | |
34
+ | `default_schema` | `string \| null` | no | `null` | |
35
+ | `default_partition` | `string \| null` | no | `null` | |
36
+ | `default_filename` | `string \| null` | no | `null` | |
37
+ | `archive_folder` | `string \| null` | no | `null` | |
38
+ | `timezone` | `string \| null` | no | `null` | |
39
+ | `history` | `boolean \| null` | no | `null` | |
40
+ | `autolink` | `boolean \| null` | no | `null` | Automatic links: the text a write puts in a note's body links the notes it mentions by name (on by default). A write's own `autolink` overrides it. |
41
+
42
+ ## Responses
43
+
44
+ | Status | Description | Body |
45
+ | --- | --- | --- |
46
+ | 200 | Done. | `DatabaseDescription` (application/json) |
47
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
48
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
49
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
50
+ | 500 | Unexpected error. | `Error` (application/json) |
51
+
52
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,78 @@
1
+ # Create a table: `name`, in `catalog` and `schema` (default: the database's defaults); the definition
2
+
3
+ `POST /datanotes/operations/create_table/` (operation `create_table`)
4
+
5
+ Create a table: `name`, in `catalog` and `schema` (default: the database's defaults); the definition
6
+ goes in metastore.yaml, the rows in `<root>/<catalog>/<schema>/<name>/`. Names: lowercase letters,
7
+ digits, `_` (no dots: pass the catalog and the schema as their own arguments).
8
+ - `description` (required): what a row of the table records. Every column needs its own `description`
9
+ too, what it holds: the table is refused otherwise, with every missing one listed. Descriptions are how
10
+ agents and people understand the schema, so write them for a reader who never saw the notes. The
11
+ engine writes those of `id` and of `identity` "uuid" / "created" columns.
12
+ - `columns`: specs like `{"name": "kind", "type": "enum", "values": ["a","b"], "required": true,
13
+ "description": "What kind of entry the row is"}`.
14
+ Types: string, integer, number, boolean, date, datetime, enum, link, list (+ `items`), json.
15
+ Attributes: required, default (`"{now}"`/`"{today}"`), min, max, step, values, `ordered` (enum in
16
+ order: filters/avg use the position), ref (link target, full `catalog.schema.table` or "self"),
17
+ unique, label, description, aliases, `generated` (e.g. `"date(occurred_at)"`, `"{name} {surname}"`),
18
+ `identity` ("filename" | "created"), `vocabulary` (allowed values = names of another table's rows),
19
+ `hierarchy: true` (one parent link to its own table), `dense` (written on every row),
20
+ `inverse` on a link column: the column of the `ref` table that links back (`friends` ↔
21
+ `friends`, `children` ↔ `parents`, `partner` ↔ `partner`); writes keep both sides in step.
22
+ - `time_column`: rows named by that date/datetime; otherwise `filename` (e.g. `"{name}"`).
23
+ - The table's options, as alter_table names them: `aliases` (how agents find it, with the
24
+ description), `partition`, `exclude`, `archive`, `history` (keep its versions; default: the
25
+ database's setting), `autolink_target` (true / false: may automatic links link its rows? default:
26
+ yes, unless its rows are named by a date or a time, as with `time_column`).
27
+ - `row_template`: markdown body of new rows. Shared columns come from bases: `set_table_bases`.
28
+ - `tags`: key/value labels of the table, strings (`{"domain": "health"}`); list_tables and
29
+ describe_table return them, alter_table changes them.
30
+ Enum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", …}`): describe_table shows them and a refused value lists them.
31
+ Generated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet).
32
+ Filtered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.
33
+
34
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
35
+
36
+ ## Parameters
37
+
38
+ | Name | In | Type | Required | Description |
39
+ | --- | --- | --- | --- | --- |
40
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
41
+
42
+ ## Request body
43
+
44
+ `application/json`, required
45
+
46
+ | Property | Type | Required | Default | Description |
47
+ | --- | --- | --- | --- | --- |
48
+ | `name` | `string` | yes | | |
49
+ | `description` | `string \| null` | no | `null` | What a row of the table records (required: the table is refused without it, as without a column's own description). |
50
+ | `columns` | `object[]` | yes | | |
51
+ | `catalog` | `string \| null` | no | `null` | |
52
+ | `schema` | `string \| null` | no | `null` | |
53
+ | `time_column` | `string \| null` | no | `null` | |
54
+ | `filename` | `string \| null` | no | `null` | File name pattern of the rows, e.g. "{name}" (instead of time_column). |
55
+ | `partition` | `string \| null` | no | `null` | Sub-folder pattern of the rows, e.g. "{occurred_at:YYYY/MM}"; "" = flat. |
56
+ | `exclude` | `string[] \| null` | no | `null` | Folders whose notes are never rows of the table (e.g. templates that create them). |
57
+ | `archive` | `string \| null` | no | `null` | Archive folder: a folder name inside the table folder (default: the database's archive_folder). |
58
+ | `aliases` | `string[] \| null` | no | `null` | Other words for what the table records, for agents. |
59
+ | `history` | `boolean \| null` | no | `null` | Keep the table's versions (time travel, restore); default: the database's setting. |
60
+ | `autolink_target` | `boolean \| null` | no | `null` | May automatic links link the table's rows? Default: yes, unless its rows are named by a date or a time. |
61
+ | `row_template` | `string \| null` | no | `null` | Markdown body of new rows; {column} placeholders are filled from the row. |
62
+ | `fields` | `object \| null` | no | `null` | Untyped fields of the table (name → default), kept on every row; a field cannot share a name with a column. |
63
+ | `tags` | `object \| null` | no | `null` | Key/value labels of the table (strings), e.g. {"domain": "health"}. |
64
+ | `dry_run` | `boolean` | no | `false` | |
65
+
66
+ ## Responses
67
+
68
+ | Status | Description | Body |
69
+ | --- | --- | --- |
70
+ | 200 | Done. | `OpResult` (application/json) |
71
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
72
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
73
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
74
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
75
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
76
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
77
+
78
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,54 @@
1
+ # Create (or `replace`) a view: a named select stored in metastore.yaml. Name it with the prefix
2
+
3
+ `POST /datanotes/operations/create_view/` (operation `create_view`)
4
+
5
+ Create (or `replace`) a view: a named select stored in metastore.yaml. Name it with the prefix
6
+ `vw_` (e.g. `vw_open_tasks`): views share names and folders with tables. `query` takes the
7
+ select_rows parameters (table, columns, where, order_by, limit, join, group_by, aggregates, expand;
8
+ relative dates keep it current) and must run now. Or `query: {union: [{table, columns, where}, …],
9
+ columns, where, order_by, limit, expand}` stacks the rows of several tables (UNION ALL, each row
10
+ tagged `_source`). Its filters may read the note the view is shown for: `{this.<property>}`
11
+ (`{this.date+1d}`, `{this.date-1w}` shift a date), `{this.link}`, `{this.name}`, `{this.path}`,
12
+ filled in from select_rows `this_note` (one view serves every daily note, every project note).
13
+ `description` and `aliases` let agents find it; `labels` are column headings. Views are selected with
14
+ `select_rows(table=<view>)`, which may narrow them further (where, columns, order_by, limit; a `where`
15
+ operator the view already has on a column replaces it). A view writes no note: it lives only in
16
+ metastore.yaml.
17
+
18
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
19
+
20
+ ## Parameters
21
+
22
+ | Name | In | Type | Required | Description |
23
+ | --- | --- | --- | --- | --- |
24
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
25
+
26
+ ## Request body
27
+
28
+ `application/json`, required
29
+
30
+ | Property | Type | Required | Default | Description |
31
+ | --- | --- | --- | --- | --- |
32
+ | `name` | `string` | yes | | |
33
+ | `query` | `object` | yes | | |
34
+ | `catalog` | `string \| null` | no | `null` | |
35
+ | `schema` | `string \| null` | no | `null` | |
36
+ | `description` | `string \| null` | no | `null` | What the view shows, for agents and people. |
37
+ | `aliases` | `string[] \| null` | no | `null` | |
38
+ | `labels` | `object \| null` | no | `null` | |
39
+ | `replace` | `boolean` | no | `false` | |
40
+ | `dry_run` | `boolean` | no | `false` | |
41
+
42
+ ## Responses
43
+
44
+ | Status | Description | Body |
45
+ | --- | --- | --- |
46
+ | 200 | Done. | `OpResult` (application/json) |
47
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
48
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
49
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
50
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
51
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
52
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
53
+
54
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,37 @@
1
+ # Push row changes to a URL (a service that would rather be called than poll `list_changes`): batches of up to 100 events POSTed as `{webhook, events, last}`, signed with `X-Datanotes-Signature: sha256=<HMAC of the body>`, retried with backoff until a 2xx. Events are those of `list_changes` (hand edits with their `violations`; the hand edits the service has seen are recorded before it stops). Starts from now unless `since`. Returns the webhook with its `secret` — shown only here: give it to the receiver. Only on the user's explicit request: a webhook sends the database's changes (and, with `since`, its past ones) to that address.
2
+
3
+ `POST /datanotes/operations/create_webhook/` (operation `create_webhook`)
4
+
5
+ Push row changes to a URL (a service that would rather be called than poll `list_changes`): batches of up to 100 events POSTed as `{webhook, events, last}`, signed with `X-Datanotes-Signature: sha256=<HMAC of the body>`, retried with backoff until a 2xx. Events are those of `list_changes` (hand edits with their `violations`; the hand edits the service has seen are recorded before it stops). Starts from now unless `since`. Returns the webhook with its `secret` — shown only here: give it to the receiver. Only on the user's explicit request: a webhook sends the database's changes (and, with `since`, its past ones) to that address.
6
+
7
+ ## Parameters
8
+
9
+ | Name | In | Type | Required | Description |
10
+ | --- | --- | --- | --- | --- |
11
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
12
+
13
+ ## Request body
14
+
15
+ `application/json`, required
16
+
17
+ | Property | Type | Required | Default | Description |
18
+ | --- | --- | --- | --- | --- |
19
+ | `url` | `string` | yes | | |
20
+ | `tables` | `string[] \| null` | no | `null` | |
21
+ | `kinds` | `("insert" \| "update" \| "delete" \| "move" \| "metastore" \| "tool_call" \| "unreadable")[] \| null` | no | `null` | |
22
+ | `columns` | `string[] \| null` | no | `null` | |
23
+ | `exclude_actor` | `string \| null` | no | `null` | |
24
+ | `where` | `object \| null` | no | `null` | |
25
+ | `since` | `integer \| null` | no | `null` | |
26
+
27
+ ## Responses
28
+
29
+ | Status | Description | Body |
30
+ | --- | --- | --- |
31
+ | 200 | Done. | `object` (application/json) |
32
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
33
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
34
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
35
+ | 500 | Unexpected error. | `Error` (application/json) |
36
+
37
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,52 @@
1
+ # Create or replace a base: a named set of columns (same spec as `create_table`) that tables
2
+
3
+ `POST /datanotes/operations/define_base/` (operation `define_base`)
4
+
5
+ Create or replace a base: a named set of columns (same spec as `create_table`) that tables
6
+ inherit, like a parent class (`bases` in `metastore.yaml`). Tables using it get the columns
7
+ with the same name and meaning; `ref: "self"` means the inheriting table (e.g. a `parent`
8
+ column with `hierarchy: true`). `bases` builds on other bases. Descriptions are required, as in
9
+ create_table: `description` says what the tables of the base share, and each column has its `description`
10
+ (a column given without one keeps the one the base had for it). Replacing a base changes
11
+ every inheriting table: `rename_columns` (`{"old": "new"}`) renames the column on their rows,
12
+ `drop_columns` removes it from their rows; dropping a column without listing it is refused.
13
+ A renamed column is followed into the CHECKs and `ref_where` / `ref_by` that read it (the base's
14
+ own included); dropping one they read is refused, naming them. All affected rows are validated
15
+ before any write, inherited `ref_where` / `ref_by` and CHECKs that follow links included.
16
+ Enum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", …}`): describe_table shows them and a refused value lists them.
17
+
18
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
19
+
20
+ ## Parameters
21
+
22
+ | Name | In | Type | Required | Description |
23
+ | --- | --- | --- | --- | --- |
24
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
25
+
26
+ ## Request body
27
+
28
+ `application/json`, required
29
+
30
+ | Property | Type | Required | Default | Description |
31
+ | --- | --- | --- | --- | --- |
32
+ | `name` | `string` | yes | | |
33
+ | `columns` | `object[]` | yes | | |
34
+ | `bases` | `string[] \| null` | no | `null` | |
35
+ | `description` | `string \| null` | no | `null` | What the tables of the base share (required, as a table's description is). |
36
+ | `rename_columns` | `object \| null` | no | `null` | |
37
+ | `drop_columns` | `string[] \| null` | no | `null` | |
38
+ | `dry_run` | `boolean` | no | `false` | |
39
+
40
+ ## Responses
41
+
42
+ | Status | Description | Body |
43
+ | --- | --- | --- |
44
+ | 200 | Done. | `OpResult` (application/json) |
45
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
46
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
47
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
48
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
49
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
50
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
51
+
52
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,43 @@
1
+ # Delete rows matching `where`. `mode`: "archive" (default, move to the table's archive
2
+
3
+ `POST /datanotes/operations/delete_rows/` (operation `delete_rows`)
4
+
5
+ Delete rows matching `where`. `mode`: "archive" (default, move to the table's archive
6
+ folder) or "delete" (trash; content journaled for undo). `on_referenced`: "restrict"
7
+ (default, refuse rows other notes link to), "set_null" (clear front matter links to them) or
8
+ "ignore" (the links stay, to no row: an archived row is gone as a trashed one, so check_table
9
+ reports them as `broken_link` and new links to it are refused). `where` is required: `{}` deletes every row.
10
+
11
+ ## Parameters
12
+
13
+ | Name | In | Type | Required | Description |
14
+ | --- | --- | --- | --- | --- |
15
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
16
+
17
+ ## Request body
18
+
19
+ `application/json`, required
20
+
21
+ | Property | Type | Required | Default | Description |
22
+ | --- | --- | --- | --- | --- |
23
+ | `table` | `string` | yes | | |
24
+ | `where` | `object` | yes | | The rows to change; {} is every row of the table. |
25
+ | `mode` | `"archive" \| "delete" \| null` | no | `null` | |
26
+ | `on_referenced` | `"restrict" \| "set_null" \| "ignore" \| null` | no | `null` | |
27
+ | `dry_run` | `boolean` | no | `false` | |
28
+
29
+ ## Responses
30
+
31
+ | Status | Description | Body |
32
+ | --- | --- | --- |
33
+ | 200 | Done. | `OpResult` (application/json) |
34
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
35
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
36
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
37
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
38
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
39
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
40
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
41
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
42
+
43
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,31 @@
1
+ # Stop and remove a webhook (by `id` from list_webhooks).
2
+
3
+ `POST /datanotes/operations/delete_webhook/` (operation `delete_webhook`)
4
+
5
+ Stop and remove a webhook (by `id` from list_webhooks).
6
+
7
+ ## Parameters
8
+
9
+ | Name | In | Type | Required | Description |
10
+ | --- | --- | --- | --- | --- |
11
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
12
+
13
+ ## Request body
14
+
15
+ `application/json`, required
16
+
17
+ | Property | Type | Required | Default | Description |
18
+ | --- | --- | --- | --- | --- |
19
+ | `id` | `string` | yes | | |
20
+
21
+ ## Responses
22
+
23
+ | Status | Description | Body |
24
+ | --- | --- | --- |
25
+ | 200 | Done. | `object` (application/json) |
26
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
27
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
28
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
29
+ | 500 | Unexpected error. | `Error` (application/json) |
30
+
31
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,30 @@
1
+ # Describe the database: its folder (`root`), `metastore` (`metastore.yaml`: read it freely,
2
+
3
+ `POST /datanotes/operations/describe_database/` (operation `describe_database`)
4
+
5
+ Describe the database: its folder (`root`), `metastore` (`metastore.yaml`: read it freely,
6
+ but it is read-only for agents and changes only through the schema operations), configuration
7
+ (default catalog and schema, row partition and file-name formats, archive folder, time zone,
8
+ history, automatic links),
9
+ journal folder, `bases` (shared column sets and the tables using them), `catalogs` → `schemas` → `tables` (with `row_count`, `tags`, and `unreadable_count` when some rows' front matter cannot be read) and `views`;
10
+ catalogs and schemas show their `comment` (set with `comment_on`). A table or base defined before
11
+ descriptions were required has `missing_descriptions`: what lacks one, for alter_table / alter_column
12
+ (define_base for a base) to fill, so every table and column says what it holds.
13
+
14
+ ## Request body
15
+
16
+ `application/json`
17
+
18
+ | Property | Type | Required | Default | Description |
19
+ | --- | --- | --- | --- | --- |
20
+
21
+ ## Responses
22
+
23
+ | Status | Description | Body |
24
+ | --- | --- | --- |
25
+ | 200 | Done. | `DatabaseDescription` (application/json) |
26
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
27
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
28
+ | 500 | Unexpected error. | `Error` (application/json) |
29
+
30
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,40 @@
1
+ # DESCRIBE HISTORY: the table's versions, newest first — `version`, `timestamp`, `operation`
2
+
3
+ `POST /datanotes/operations/describe_history/` (operation `describe_history`)
4
+
5
+ DESCRIBE HISTORY: the table's versions, newest first — `version`, `timestamp`, `operation`
6
+ (CREATE TABLE, WRITE, UPDATE, DELETE, MERGE, ALTER TABLE, ADD COLUMNS, RESTORE, UNDO, …;
7
+ `EXTERNAL_EDIT` = changed outside the engine: an editor, git, sync), `operation_metrics` and `migration_id` (undo).
8
+ An EXTERNAL_EDIT's `operation_metrics.violations` counts the rules this table's rows break because of the hand edits it holds (each once): the edited rows whose front matter changed and the rows of the table linking to them, a removed or renamed row included (rows of other tables count in their table; a body-only edit is not checked); every rule its rows break when its definition was edited in metastore.yaml. Absent when nothing was checked, or when the edits were logged right before an engine write (the change feed has them); check_table lists the rows invalid now.
9
+ Works for dropped tables too (full `catalog.schema.table`). Use a version with `select_rows`
10
+ (time travel), `table_changes` or `restore_table`.
11
+ Without `table`: the history of the whole database — the commits of every table with a log (dropped
12
+ ones included), newest first, each with its `table` (the result's `tables` lists the logged tables).
13
+ An operation that changed several tables (a cascade, inverse links, restore_database) commits to each
14
+ with the same `migration_id`, and the operations of a `batch` carry its id as `batch`: their commits list
15
+ in `tables` every table that operation (or batch) committed to. Pick a moment for `restore_database`
16
+ from it (`timestamp`, or `before_migration` with a `migration_id` or a `batch`).
17
+ `limit` (default 50) counts commits; `since` (ISO date or date-time): only commits at or after it.
18
+
19
+ ## Request body
20
+
21
+ `application/json`
22
+
23
+ | Property | Type | Required | Default | Description |
24
+ | --- | --- | --- | --- | --- |
25
+ | `table` | `string \| null` | no | `null` | A table; omitted, the whole database. |
26
+ | `limit` | `integer \| null` | no | `null` | |
27
+ | `since` | `string \| null` | no | `null` | |
28
+
29
+ ## Responses
30
+
31
+ | Status | Description | Body |
32
+ | --- | --- | --- |
33
+ | 200 | Done. | `object` (application/json) |
34
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
35
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
36
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
37
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
38
+ | 500 | Unexpected error. | `Error` (application/json) |
39
+
40
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,24 @@
1
+ # The semantic search index: `enabled`, `provider`, `model`, `files`, `passages`, `pending`,
2
+
3
+ `POST /datanotes/operations/describe_semantic_index/` (operation `describe_semantic_index`)
4
+
5
+ The semantic search index: `enabled`, `provider`, `model`, `files`, `passages`, `pending`,
6
+ `running`, `last_sync`, `last_error`. sync_semantic_index brings it up to date.
7
+
8
+ ## Request body
9
+
10
+ `application/json`
11
+
12
+ | Property | Type | Required | Default | Description |
13
+ | --- | --- | --- | --- | --- |
14
+
15
+ ## Responses
16
+
17
+ | Status | Description | Body |
18
+ | --- | --- | --- |
19
+ | 200 | Done. | `SemanticStatus` (application/json) |
20
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
21
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
22
+ | 500 | Unexpected error. | `Error` (application/json) |
23
+
24
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,38 @@
1
+ # Describe a table (`catalog.schema.table` or a shorter unambiguous name): `qualified`, `name`,
2
+
3
+ `POST /datanotes/operations/describe_table/` (operation `describe_table`)
4
+
5
+ Describe a table (`catalog.schema.table` or a shorter unambiguous name): `qualified`, `name`,
6
+ `catalog`, `schema`, `description`, `aliases`, `layout` (`folder`, `row_folder`: the folder pattern
7
+ of new rows, `archive`), `options` (`partition`, `filename`, `archive`, `exclude`), typed `columns`
8
+ with label/aliases/description and the dense flag, `untyped_fields`, `row_count`, and when set:
9
+ `tags`, `bases` (the bases it inherits from, in order), `constraints` (its CHECKs, name → where), `row_template`, `history`,
10
+ `autolink_target`, `fields` (their values).
11
+
12
+ Before adding a column (e.g. a new metric), read `columns` and match your concept against
13
+ `name`, `label`, `aliases` and `description`; reuse an existing column when it means the same.
14
+
15
+ `missing_descriptions` (`{table, columns}`), present only when something has no description (a table
16
+ defined before descriptions were required), names what lacks one: write them with alter_table
17
+ `description` and alter_column `changes.description`, asking the user when the meaning is unclear.
18
+
19
+ ## Request body
20
+
21
+ `application/json`, required
22
+
23
+ | Property | Type | Required | Default | Description |
24
+ | --- | --- | --- | --- | --- |
25
+ | `table` | `string` | yes | | |
26
+
27
+ ## Responses
28
+
29
+ | Status | Description | Body |
30
+ | --- | --- | --- |
31
+ | 200 | Done. | `object` (application/json) |
32
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
33
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
34
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
35
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
36
+ | 500 | Unexpected error. | `Error` (application/json) |
37
+
38
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,13 @@
1
+ # This document in an interactive console (Swagger UI, served by the engine; public). Authorize with a token to try the routes.
2
+
3
+ `GET /datanotes/docs` (operation `docs`)
4
+
5
+ No authentication needed.
6
+
7
+ ## Responses
8
+
9
+ | Status | Description | Body |
10
+ | --- | --- | --- |
11
+ | 200 | HTML page. | `string` (text/html) |
12
+
13
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,41 @@
1
+ # Remove a column from the schema and every row. Previous values are journaled; revert with
2
+
3
+ `POST /datanotes/operations/drop_column/` (operation `drop_column`)
4
+
5
+ Remove a column from the schema and every row. Previous values are journaled; revert with
6
+ `undo_migration`. Refused while a CHECK, `ref_where` or `ref_by` of any table reads the column
7
+ (directly or through a link): the conflicts name them; drop or change them first.
8
+
9
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
10
+
11
+ ## Parameters
12
+
13
+ | Name | In | Type | Required | Description |
14
+ | --- | --- | --- | --- | --- |
15
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
16
+
17
+ ## Request body
18
+
19
+ `application/json`, required
20
+
21
+ | Property | Type | Required | Default | Description |
22
+ | --- | --- | --- | --- | --- |
23
+ | `table` | `string` | yes | | |
24
+ | `column` | `string` | yes | | The column's name. |
25
+ | `dry_run` | `boolean` | no | `false` | |
26
+
27
+ ## Responses
28
+
29
+ | Status | Description | Body |
30
+ | --- | --- | --- |
31
+ | 200 | Done. | `OpResult` (application/json) |
32
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
33
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
34
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
35
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
36
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
37
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
38
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
39
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
40
+
41
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,39 @@
1
+ # Remove the CHECK constraint `name` from `table`.
2
+
3
+ `POST /datanotes/operations/drop_constraint/` (operation `drop_constraint`)
4
+
5
+ Remove the CHECK constraint `name` from `table`.
6
+
7
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
8
+
9
+ ## Parameters
10
+
11
+ | Name | In | Type | Required | Description |
12
+ | --- | --- | --- | --- | --- |
13
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
14
+
15
+ ## Request body
16
+
17
+ `application/json`, required
18
+
19
+ | Property | Type | Required | Default | Description |
20
+ | --- | --- | --- | --- | --- |
21
+ | `table` | `string` | yes | | |
22
+ | `name` | `string` | yes | | |
23
+ | `dry_run` | `boolean` | no | `false` | |
24
+
25
+ ## Responses
26
+
27
+ | Status | Description | Body |
28
+ | --- | --- | --- |
29
+ | 200 | Done. | `OpResult` (application/json) |
30
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
31
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
32
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
33
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
34
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
35
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
36
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
37
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
38
+
39
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
@@ -0,0 +1,43 @@
1
+ # Drop a table. Refused while it has rows unless `mode: "archive"`, which removes the
2
+
3
+ `POST /datanotes/operations/drop_table/` (operation `drop_table`)
4
+
5
+ Drop a table. Refused while it has rows unless `mode: "archive"`, which removes the
6
+ definition from `metastore.yaml` and moves all rows to the table's archive folder (nothing is
7
+ hard-deleted; undo restores). The transaction log is kept: `restore_table` can bring it back.
8
+ Refused while a CHECK that follows links, or a `ref_where` / `ref_by`, of another table reads this
9
+ table through a link (link targets are not rewritten): the conflicts name them; drop or change them first.
10
+
11
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
12
+
13
+ ## Parameters
14
+
15
+ | Name | In | Type | Required | Description |
16
+ | --- | --- | --- | --- | --- |
17
+ | `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |
18
+
19
+ ## Request body
20
+
21
+ `application/json`, required
22
+
23
+ | Property | Type | Required | Default | Description |
24
+ | --- | --- | --- | --- | --- |
25
+ | `table` | `string` | yes | | |
26
+ | `mode` | `"archive" \| null` | no | `null` | "archive": drop a table that has rows, moving them to its archive folder. |
27
+ | `dry_run` | `boolean` | no | `false` | |
28
+
29
+ ## Responses
30
+
31
+ | Status | Description | Body |
32
+ | --- | --- | --- |
33
+ | 200 | Done. | `OpResult` (application/json) |
34
+ | 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
35
+ | 401 | Missing or wrong bearer token. | `Error` (application/json) |
36
+ | 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
37
+ | 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
38
+ | 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
39
+ | 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
40
+ | 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
41
+ | 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |
42
+
43
+ The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).