datanotes 3.2.0 → 3.3.1

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 (63) hide show
  1. package/README.md +1 -0
  2. package/SECURITY.md +12 -0
  3. package/dist/api/client.d.cts +2 -0
  4. package/dist/api/client.d.ts +2 -0
  5. package/dist/api/docs.d.cts +14 -4
  6. package/dist/api/docs.d.ts +14 -4
  7. package/dist/api/extension-files.d.cts +23 -0
  8. package/dist/api/extension-files.d.ts +23 -0
  9. package/dist/api/extension-host.d.cts +108 -0
  10. package/dist/api/extension-host.d.ts +108 -0
  11. package/dist/api/extension-manifest.d.cts +154 -0
  12. package/dist/api/extension-manifest.d.ts +154 -0
  13. package/dist/api/extension-plan.d.cts +174 -0
  14. package/dist/api/extension-plan.d.ts +174 -0
  15. package/dist/api/extension-record.d.cts +65 -0
  16. package/dist/api/extension-record.d.ts +65 -0
  17. package/dist/api/extension-sdk.d.cts +65 -0
  18. package/dist/api/extension-sdk.d.ts +65 -0
  19. package/dist/api/extensions.cjs +19660 -0
  20. package/dist/api/extensions.d.cts +11 -0
  21. package/dist/api/extensions.d.ts +11 -0
  22. package/dist/api/extensions.js +19597 -0
  23. package/dist/api/index.cjs +1568 -375
  24. package/dist/api/index.js +1568 -375
  25. package/dist/api/mcp.cjs +1238 -27
  26. package/dist/api/mcp.js +1238 -27
  27. package/dist/datanotes.cjs +8365 -4335
  28. package/dist/docs/administration/extensions.md +213 -0
  29. package/dist/docs/api/operations/alter_table.md +4 -3
  30. package/dist/docs/api/operations/extensions_delete.md +29 -0
  31. package/dist/docs/api/operations/extensions_list.md +20 -0
  32. package/dist/docs/api/operations/extensions_record.md +44 -0
  33. package/dist/docs/api/operations/tags/extensions.md +9 -0
  34. package/dist/docs/api.md +9 -1
  35. package/dist/docs/develop/write-an-extension.md +369 -0
  36. package/dist/docs/guides/data-quality/check-constraints.md +10 -10
  37. package/dist/docs/guides/data-quality/hand-edits.md +8 -8
  38. package/dist/docs/guides/database-objects/bases.md +11 -11
  39. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +30 -10
  40. package/dist/docs/guides/database-objects/columns.md +38 -38
  41. package/dist/docs/guides/database-objects/relations.md +28 -28
  42. package/dist/docs/guides/database-objects/tables.md +167 -43
  43. package/dist/docs/guides/database-objects/views.md +44 -44
  44. package/dist/docs/guides/history/change-data-feed.md +34 -34
  45. package/dist/docs/guides/history/journal-and-undo.md +12 -12
  46. package/dist/docs/guides/history/restore.md +20 -20
  47. package/dist/docs/guides/history/table-history.md +31 -31
  48. package/dist/docs/guides/read-and-write/automatic-links.md +15 -15
  49. package/dist/docs/guides/read-and-write/import-notes.md +20 -20
  50. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +7 -7
  51. package/dist/docs/guides/read-and-write/read-and-filter.md +10 -10
  52. package/dist/docs/guides/read-and-write/write-rows.md +10 -10
  53. package/dist/docs/guides/search/text.md +1 -1
  54. package/dist/docs/guides/security/security-model.md +12 -0
  55. package/dist/docs/reference/cli.md +32 -1
  56. package/dist/docs/reference/glossary.md +8 -0
  57. package/dist/docs/reference/operations/auxiliary.md +1 -1
  58. package/dist/docs/reference/operations/rows.md +1 -1
  59. package/dist/docs/reference/operations/schema.md +3 -3
  60. package/dist/docs/reference/operations.md +4 -4
  61. package/dist/docs/release-notes.md +49 -0
  62. package/dist/docs/start/connect-agents.md +11 -0
  63. package/package.json +11 -1
package/dist/api/index.js CHANGED
@@ -1179,6 +1179,50 @@ var OPERATIONS = [
1179
1179
  ]
1180
1180
  },
1181
1181
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
1182
+ },
1183
+ "schema_references": {
1184
+ "type": "array",
1185
+ "items": {
1186
+ "title": "SchemaReference",
1187
+ "type": "object",
1188
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
1189
+ "properties": {
1190
+ "table": {
1191
+ "type": "string",
1192
+ "description": "The table whose column names it (full name)."
1193
+ },
1194
+ "base": {
1195
+ "type": "string",
1196
+ "description": "The base whose column names it."
1197
+ },
1198
+ "view": {
1199
+ "type": "string",
1200
+ "description": "The view whose query names it (full name)."
1201
+ },
1202
+ "column": {
1203
+ "type": "string",
1204
+ "description": "The column of the table or base."
1205
+ },
1206
+ "key": {
1207
+ "type": "string",
1208
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
1209
+ },
1210
+ "from": {
1211
+ "type": "string",
1212
+ "description": "The name as written before."
1213
+ },
1214
+ "to": {
1215
+ "type": "string",
1216
+ "description": "The name written in its place."
1217
+ }
1218
+ },
1219
+ "required": [
1220
+ "key",
1221
+ "from",
1222
+ "to"
1223
+ ]
1224
+ },
1225
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
1182
1226
  }
1183
1227
  },
1184
1228
  "required": [
@@ -1592,6 +1636,50 @@ var OPERATIONS = [
1592
1636
  ]
1593
1637
  },
1594
1638
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
1639
+ },
1640
+ "schema_references": {
1641
+ "type": "array",
1642
+ "items": {
1643
+ "title": "SchemaReference",
1644
+ "type": "object",
1645
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
1646
+ "properties": {
1647
+ "table": {
1648
+ "type": "string",
1649
+ "description": "The table whose column names it (full name)."
1650
+ },
1651
+ "base": {
1652
+ "type": "string",
1653
+ "description": "The base whose column names it."
1654
+ },
1655
+ "view": {
1656
+ "type": "string",
1657
+ "description": "The view whose query names it (full name)."
1658
+ },
1659
+ "column": {
1660
+ "type": "string",
1661
+ "description": "The column of the table or base."
1662
+ },
1663
+ "key": {
1664
+ "type": "string",
1665
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
1666
+ },
1667
+ "from": {
1668
+ "type": "string",
1669
+ "description": "The name as written before."
1670
+ },
1671
+ "to": {
1672
+ "type": "string",
1673
+ "description": "The name written in its place."
1674
+ }
1675
+ },
1676
+ "required": [
1677
+ "key",
1678
+ "from",
1679
+ "to"
1680
+ ]
1681
+ },
1682
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
1595
1683
  }
1596
1684
  },
1597
1685
  "required": [
@@ -1996,6 +2084,50 @@ var OPERATIONS = [
1996
2084
  ]
1997
2085
  },
1998
2086
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
2087
+ },
2088
+ "schema_references": {
2089
+ "type": "array",
2090
+ "items": {
2091
+ "title": "SchemaReference",
2092
+ "type": "object",
2093
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
2094
+ "properties": {
2095
+ "table": {
2096
+ "type": "string",
2097
+ "description": "The table whose column names it (full name)."
2098
+ },
2099
+ "base": {
2100
+ "type": "string",
2101
+ "description": "The base whose column names it."
2102
+ },
2103
+ "view": {
2104
+ "type": "string",
2105
+ "description": "The view whose query names it (full name)."
2106
+ },
2107
+ "column": {
2108
+ "type": "string",
2109
+ "description": "The column of the table or base."
2110
+ },
2111
+ "key": {
2112
+ "type": "string",
2113
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
2114
+ },
2115
+ "from": {
2116
+ "type": "string",
2117
+ "description": "The name as written before."
2118
+ },
2119
+ "to": {
2120
+ "type": "string",
2121
+ "description": "The name written in its place."
2122
+ }
2123
+ },
2124
+ "required": [
2125
+ "key",
2126
+ "from",
2127
+ "to"
2128
+ ]
2129
+ },
2130
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
1999
2131
  }
2000
2132
  },
2001
2133
  "required": [
@@ -2402,6 +2534,50 @@ var OPERATIONS = [
2402
2534
  ]
2403
2535
  },
2404
2536
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
2537
+ },
2538
+ "schema_references": {
2539
+ "type": "array",
2540
+ "items": {
2541
+ "title": "SchemaReference",
2542
+ "type": "object",
2543
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
2544
+ "properties": {
2545
+ "table": {
2546
+ "type": "string",
2547
+ "description": "The table whose column names it (full name)."
2548
+ },
2549
+ "base": {
2550
+ "type": "string",
2551
+ "description": "The base whose column names it."
2552
+ },
2553
+ "view": {
2554
+ "type": "string",
2555
+ "description": "The view whose query names it (full name)."
2556
+ },
2557
+ "column": {
2558
+ "type": "string",
2559
+ "description": "The column of the table or base."
2560
+ },
2561
+ "key": {
2562
+ "type": "string",
2563
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
2564
+ },
2565
+ "from": {
2566
+ "type": "string",
2567
+ "description": "The name as written before."
2568
+ },
2569
+ "to": {
2570
+ "type": "string",
2571
+ "description": "The name written in its place."
2572
+ }
2573
+ },
2574
+ "required": [
2575
+ "key",
2576
+ "from",
2577
+ "to"
2578
+ ]
2579
+ },
2580
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
2405
2581
  }
2406
2582
  },
2407
2583
  "required": [
@@ -2805,6 +2981,50 @@ var OPERATIONS = [
2805
2981
  ]
2806
2982
  },
2807
2983
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
2984
+ },
2985
+ "schema_references": {
2986
+ "type": "array",
2987
+ "items": {
2988
+ "title": "SchemaReference",
2989
+ "type": "object",
2990
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
2991
+ "properties": {
2992
+ "table": {
2993
+ "type": "string",
2994
+ "description": "The table whose column names it (full name)."
2995
+ },
2996
+ "base": {
2997
+ "type": "string",
2998
+ "description": "The base whose column names it."
2999
+ },
3000
+ "view": {
3001
+ "type": "string",
3002
+ "description": "The view whose query names it (full name)."
3003
+ },
3004
+ "column": {
3005
+ "type": "string",
3006
+ "description": "The column of the table or base."
3007
+ },
3008
+ "key": {
3009
+ "type": "string",
3010
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
3011
+ },
3012
+ "from": {
3013
+ "type": "string",
3014
+ "description": "The name as written before."
3015
+ },
3016
+ "to": {
3017
+ "type": "string",
3018
+ "description": "The name written in its place."
3019
+ }
3020
+ },
3021
+ "required": [
3022
+ "key",
3023
+ "from",
3024
+ "to"
3025
+ ]
3026
+ },
3027
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
2808
3028
  }
2809
3029
  },
2810
3030
  "required": [
@@ -3213,6 +3433,50 @@ var OPERATIONS = [
3213
3433
  ]
3214
3434
  },
3215
3435
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
3436
+ },
3437
+ "schema_references": {
3438
+ "type": "array",
3439
+ "items": {
3440
+ "title": "SchemaReference",
3441
+ "type": "object",
3442
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
3443
+ "properties": {
3444
+ "table": {
3445
+ "type": "string",
3446
+ "description": "The table whose column names it (full name)."
3447
+ },
3448
+ "base": {
3449
+ "type": "string",
3450
+ "description": "The base whose column names it."
3451
+ },
3452
+ "view": {
3453
+ "type": "string",
3454
+ "description": "The view whose query names it (full name)."
3455
+ },
3456
+ "column": {
3457
+ "type": "string",
3458
+ "description": "The column of the table or base."
3459
+ },
3460
+ "key": {
3461
+ "type": "string",
3462
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
3463
+ },
3464
+ "from": {
3465
+ "type": "string",
3466
+ "description": "The name as written before."
3467
+ },
3468
+ "to": {
3469
+ "type": "string",
3470
+ "description": "The name written in its place."
3471
+ }
3472
+ },
3473
+ "required": [
3474
+ "key",
3475
+ "from",
3476
+ "to"
3477
+ ]
3478
+ },
3479
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
3216
3480
  }
3217
3481
  },
3218
3482
  "required": [
@@ -3237,7 +3501,7 @@ var OPERATIONS = [
3237
3501
  },
3238
3502
  {
3239
3503
  "name": "alter_table",
3240
- "description": 'Alter a table: move it (`catalog`, `schema`), rename it (`name`), change\n`partition` / `filename` patterns, `description` (changes, never goes: "" is refused), `aliases`,\n`exclude` folders, `row_template`\n("" removes it), `instructions` (how to fill a row, for agents; "" removes them), `history` (true | false | "default"), `autolink_target`\n(true | false | "default": may automatic links link its rows? default: yes, unless its rows are named by\na date or a time) or `tags` (key/value\nlabels merged into the table\'s, e.g. `{"domain": "health"}`; a `null` value removes that tag;\n`clear_tags: true` removes every tag first, so with `tags` the table keeps exactly those),\n`archive` (folder name inside the table folder) or `fields` (untyped fields, name \u2192 default; a\n`null` value removes one). Rows, archive and transaction log follow; links are updated; renamed\nrows keep their old name in `aliases`. A change of metadata only (tags, description, aliases,\nhistory, autolink_target, row_template, instructions, fields) rewrites the table entry alone: no row is moved or rewritten. Refused\nwhen a row cannot fill a pattern. Renaming or moving the table is refused while a CHECK that follows\nlinks, or a `ref_where` / `ref_by`, of another table reads it through a link (link targets are not\nrewritten): the conflicts name them. Use `dry_run` to see `planned_moves`; undo with undo_migration.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
3504
+ "description": 'Alter a table: move it (`catalog`, `schema`), rename it (`name`), change\n`partition` / `filename` patterns, `description` (changes, never goes: "" is refused), `aliases`,\n`exclude` folders, `row_template`\n("" removes it), `instructions` (how to fill a row, for agents; "" removes them), `history` (true | false | "default"), `autolink_target`\n(true | false | "default": may automatic links link its rows? default: yes, unless its rows are named by\na date or a time) or `tags` (key/value\nlabels merged into the table\'s, e.g. `{"domain": "health"}`; a `null` value removes that tag;\n`clear_tags: true` removes every tag first, so with `tags` the table keeps exactly those),\n`archive` (folder name inside the table folder) or `fields` (untyped fields, name \u2192 default; a\n`null` value removes one). Rows, archive and transaction log follow; links are updated; renamed\nrows keep their old name in `aliases`. A change of metadata only (tags, description, aliases,\nhistory, autolink_target, row_template, instructions, fields) rewrites the table entry alone: no row is moved or rewritten. Refused\nwhen a row cannot fill a pattern. Renaming or moving the table rewrites what names it in other\ndefinitions: the `ref` and `vocabulary` of the columns of other tables and bases (lists of links\nincluded) and the tables of views (`table`, `union[].table`, `join.table`); `schema_references`\nlists them. CHECKs and `ref_where` / `ref_by` that read it through a link follow the new `ref`. Use `dry_run` to see `planned_moves`; undo with undo_migration.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
3241
3505
  "inputSchema": {
3242
3506
  "additionalProperties": false,
3243
3507
  "properties": {
@@ -3818,6 +4082,50 @@ var OPERATIONS = [
3818
4082
  ]
3819
4083
  },
3820
4084
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
4085
+ },
4086
+ "schema_references": {
4087
+ "type": "array",
4088
+ "items": {
4089
+ "title": "SchemaReference",
4090
+ "type": "object",
4091
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
4092
+ "properties": {
4093
+ "table": {
4094
+ "type": "string",
4095
+ "description": "The table whose column names it (full name)."
4096
+ },
4097
+ "base": {
4098
+ "type": "string",
4099
+ "description": "The base whose column names it."
4100
+ },
4101
+ "view": {
4102
+ "type": "string",
4103
+ "description": "The view whose query names it (full name)."
4104
+ },
4105
+ "column": {
4106
+ "type": "string",
4107
+ "description": "The column of the table or base."
4108
+ },
4109
+ "key": {
4110
+ "type": "string",
4111
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
4112
+ },
4113
+ "from": {
4114
+ "type": "string",
4115
+ "description": "The name as written before."
4116
+ },
4117
+ "to": {
4118
+ "type": "string",
4119
+ "description": "The name written in its place."
4120
+ }
4121
+ },
4122
+ "required": [
4123
+ "key",
4124
+ "from",
4125
+ "to"
4126
+ ]
4127
+ },
4128
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
3821
4129
  }
3822
4130
  },
3823
4131
  "required": [
@@ -4278,6 +4586,50 @@ var OPERATIONS = [
4278
4586
  ]
4279
4587
  },
4280
4588
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
4589
+ },
4590
+ "schema_references": {
4591
+ "type": "array",
4592
+ "items": {
4593
+ "title": "SchemaReference",
4594
+ "type": "object",
4595
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
4596
+ "properties": {
4597
+ "table": {
4598
+ "type": "string",
4599
+ "description": "The table whose column names it (full name)."
4600
+ },
4601
+ "base": {
4602
+ "type": "string",
4603
+ "description": "The base whose column names it."
4604
+ },
4605
+ "view": {
4606
+ "type": "string",
4607
+ "description": "The view whose query names it (full name)."
4608
+ },
4609
+ "column": {
4610
+ "type": "string",
4611
+ "description": "The column of the table or base."
4612
+ },
4613
+ "key": {
4614
+ "type": "string",
4615
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
4616
+ },
4617
+ "from": {
4618
+ "type": "string",
4619
+ "description": "The name as written before."
4620
+ },
4621
+ "to": {
4622
+ "type": "string",
4623
+ "description": "The name written in its place."
4624
+ }
4625
+ },
4626
+ "required": [
4627
+ "key",
4628
+ "from",
4629
+ "to"
4630
+ ]
4631
+ },
4632
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
4281
4633
  }
4282
4634
  },
4283
4635
  "required": [
@@ -4683,6 +5035,50 @@ var OPERATIONS = [
4683
5035
  ]
4684
5036
  },
4685
5037
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
5038
+ },
5039
+ "schema_references": {
5040
+ "type": "array",
5041
+ "items": {
5042
+ "title": "SchemaReference",
5043
+ "type": "object",
5044
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
5045
+ "properties": {
5046
+ "table": {
5047
+ "type": "string",
5048
+ "description": "The table whose column names it (full name)."
5049
+ },
5050
+ "base": {
5051
+ "type": "string",
5052
+ "description": "The base whose column names it."
5053
+ },
5054
+ "view": {
5055
+ "type": "string",
5056
+ "description": "The view whose query names it (full name)."
5057
+ },
5058
+ "column": {
5059
+ "type": "string",
5060
+ "description": "The column of the table or base."
5061
+ },
5062
+ "key": {
5063
+ "type": "string",
5064
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
5065
+ },
5066
+ "from": {
5067
+ "type": "string",
5068
+ "description": "The name as written before."
5069
+ },
5070
+ "to": {
5071
+ "type": "string",
5072
+ "description": "The name written in its place."
5073
+ }
5074
+ },
5075
+ "required": [
5076
+ "key",
5077
+ "from",
5078
+ "to"
5079
+ ]
5080
+ },
5081
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
4686
5082
  }
4687
5083
  },
4688
5084
  "required": [
@@ -5749,10 +6145,54 @@ var OPERATIONS = [
5749
6145
  ]
5750
6146
  },
5751
6147
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
5752
- }
5753
- },
5754
- "required": [
5755
- "ok",
6148
+ },
6149
+ "schema_references": {
6150
+ "type": "array",
6151
+ "items": {
6152
+ "title": "SchemaReference",
6153
+ "type": "object",
6154
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
6155
+ "properties": {
6156
+ "table": {
6157
+ "type": "string",
6158
+ "description": "The table whose column names it (full name)."
6159
+ },
6160
+ "base": {
6161
+ "type": "string",
6162
+ "description": "The base whose column names it."
6163
+ },
6164
+ "view": {
6165
+ "type": "string",
6166
+ "description": "The view whose query names it (full name)."
6167
+ },
6168
+ "column": {
6169
+ "type": "string",
6170
+ "description": "The column of the table or base."
6171
+ },
6172
+ "key": {
6173
+ "type": "string",
6174
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
6175
+ },
6176
+ "from": {
6177
+ "type": "string",
6178
+ "description": "The name as written before."
6179
+ },
6180
+ "to": {
6181
+ "type": "string",
6182
+ "description": "The name written in its place."
6183
+ }
6184
+ },
6185
+ "required": [
6186
+ "key",
6187
+ "from",
6188
+ "to"
6189
+ ]
6190
+ },
6191
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
6192
+ }
6193
+ },
6194
+ "required": [
6195
+ "ok",
5756
6196
  "op",
5757
6197
  "dry_run",
5758
6198
  "notes_changed",
@@ -6159,6 +6599,50 @@ var OPERATIONS = [
6159
6599
  ]
6160
6600
  },
6161
6601
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
6602
+ },
6603
+ "schema_references": {
6604
+ "type": "array",
6605
+ "items": {
6606
+ "title": "SchemaReference",
6607
+ "type": "object",
6608
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
6609
+ "properties": {
6610
+ "table": {
6611
+ "type": "string",
6612
+ "description": "The table whose column names it (full name)."
6613
+ },
6614
+ "base": {
6615
+ "type": "string",
6616
+ "description": "The base whose column names it."
6617
+ },
6618
+ "view": {
6619
+ "type": "string",
6620
+ "description": "The view whose query names it (full name)."
6621
+ },
6622
+ "column": {
6623
+ "type": "string",
6624
+ "description": "The column of the table or base."
6625
+ },
6626
+ "key": {
6627
+ "type": "string",
6628
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
6629
+ },
6630
+ "from": {
6631
+ "type": "string",
6632
+ "description": "The name as written before."
6633
+ },
6634
+ "to": {
6635
+ "type": "string",
6636
+ "description": "The name written in its place."
6637
+ }
6638
+ },
6639
+ "required": [
6640
+ "key",
6641
+ "from",
6642
+ "to"
6643
+ ]
6644
+ },
6645
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
6162
6646
  }
6163
6647
  },
6164
6648
  "required": [
@@ -6597,6 +7081,50 @@ var OPERATIONS = [
6597
7081
  ]
6598
7082
  },
6599
7083
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
7084
+ },
7085
+ "schema_references": {
7086
+ "type": "array",
7087
+ "items": {
7088
+ "title": "SchemaReference",
7089
+ "type": "object",
7090
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
7091
+ "properties": {
7092
+ "table": {
7093
+ "type": "string",
7094
+ "description": "The table whose column names it (full name)."
7095
+ },
7096
+ "base": {
7097
+ "type": "string",
7098
+ "description": "The base whose column names it."
7099
+ },
7100
+ "view": {
7101
+ "type": "string",
7102
+ "description": "The view whose query names it (full name)."
7103
+ },
7104
+ "column": {
7105
+ "type": "string",
7106
+ "description": "The column of the table or base."
7107
+ },
7108
+ "key": {
7109
+ "type": "string",
7110
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
7111
+ },
7112
+ "from": {
7113
+ "type": "string",
7114
+ "description": "The name as written before."
7115
+ },
7116
+ "to": {
7117
+ "type": "string",
7118
+ "description": "The name written in its place."
7119
+ }
7120
+ },
7121
+ "required": [
7122
+ "key",
7123
+ "from",
7124
+ "to"
7125
+ ]
7126
+ },
7127
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
6600
7128
  }
6601
7129
  },
6602
7130
  "required": [
@@ -7039,6 +7567,50 @@ var OPERATIONS = [
7039
7567
  ]
7040
7568
  },
7041
7569
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
7570
+ },
7571
+ "schema_references": {
7572
+ "type": "array",
7573
+ "items": {
7574
+ "title": "SchemaReference",
7575
+ "type": "object",
7576
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
7577
+ "properties": {
7578
+ "table": {
7579
+ "type": "string",
7580
+ "description": "The table whose column names it (full name)."
7581
+ },
7582
+ "base": {
7583
+ "type": "string",
7584
+ "description": "The base whose column names it."
7585
+ },
7586
+ "view": {
7587
+ "type": "string",
7588
+ "description": "The view whose query names it (full name)."
7589
+ },
7590
+ "column": {
7591
+ "type": "string",
7592
+ "description": "The column of the table or base."
7593
+ },
7594
+ "key": {
7595
+ "type": "string",
7596
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
7597
+ },
7598
+ "from": {
7599
+ "type": "string",
7600
+ "description": "The name as written before."
7601
+ },
7602
+ "to": {
7603
+ "type": "string",
7604
+ "description": "The name written in its place."
7605
+ }
7606
+ },
7607
+ "required": [
7608
+ "key",
7609
+ "from",
7610
+ "to"
7611
+ ]
7612
+ },
7613
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
7042
7614
  }
7043
7615
  },
7044
7616
  "required": [
@@ -7556,6 +8128,50 @@ var OPERATIONS = [
7556
8128
  ]
7557
8129
  },
7558
8130
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
8131
+ },
8132
+ "schema_references": {
8133
+ "type": "array",
8134
+ "items": {
8135
+ "title": "SchemaReference",
8136
+ "type": "object",
8137
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
8138
+ "properties": {
8139
+ "table": {
8140
+ "type": "string",
8141
+ "description": "The table whose column names it (full name)."
8142
+ },
8143
+ "base": {
8144
+ "type": "string",
8145
+ "description": "The base whose column names it."
8146
+ },
8147
+ "view": {
8148
+ "type": "string",
8149
+ "description": "The view whose query names it (full name)."
8150
+ },
8151
+ "column": {
8152
+ "type": "string",
8153
+ "description": "The column of the table or base."
8154
+ },
8155
+ "key": {
8156
+ "type": "string",
8157
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
8158
+ },
8159
+ "from": {
8160
+ "type": "string",
8161
+ "description": "The name as written before."
8162
+ },
8163
+ "to": {
8164
+ "type": "string",
8165
+ "description": "The name written in its place."
8166
+ }
8167
+ },
8168
+ "required": [
8169
+ "key",
8170
+ "from",
8171
+ "to"
8172
+ ]
8173
+ },
8174
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
7559
8175
  }
7560
8176
  },
7561
8177
  "required": [
@@ -7991,6 +8607,50 @@ var OPERATIONS = [
7991
8607
  ]
7992
8608
  },
7993
8609
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
8610
+ },
8611
+ "schema_references": {
8612
+ "type": "array",
8613
+ "items": {
8614
+ "title": "SchemaReference",
8615
+ "type": "object",
8616
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
8617
+ "properties": {
8618
+ "table": {
8619
+ "type": "string",
8620
+ "description": "The table whose column names it (full name)."
8621
+ },
8622
+ "base": {
8623
+ "type": "string",
8624
+ "description": "The base whose column names it."
8625
+ },
8626
+ "view": {
8627
+ "type": "string",
8628
+ "description": "The view whose query names it (full name)."
8629
+ },
8630
+ "column": {
8631
+ "type": "string",
8632
+ "description": "The column of the table or base."
8633
+ },
8634
+ "key": {
8635
+ "type": "string",
8636
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
8637
+ },
8638
+ "from": {
8639
+ "type": "string",
8640
+ "description": "The name as written before."
8641
+ },
8642
+ "to": {
8643
+ "type": "string",
8644
+ "description": "The name written in its place."
8645
+ }
8646
+ },
8647
+ "required": [
8648
+ "key",
8649
+ "from",
8650
+ "to"
8651
+ ]
8652
+ },
8653
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
7994
8654
  }
7995
8655
  },
7996
8656
  "required": [
@@ -8443,6 +9103,50 @@ var OPERATIONS = [
8443
9103
  ]
8444
9104
  },
8445
9105
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
9106
+ },
9107
+ "schema_references": {
9108
+ "type": "array",
9109
+ "items": {
9110
+ "title": "SchemaReference",
9111
+ "type": "object",
9112
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
9113
+ "properties": {
9114
+ "table": {
9115
+ "type": "string",
9116
+ "description": "The table whose column names it (full name)."
9117
+ },
9118
+ "base": {
9119
+ "type": "string",
9120
+ "description": "The base whose column names it."
9121
+ },
9122
+ "view": {
9123
+ "type": "string",
9124
+ "description": "The view whose query names it (full name)."
9125
+ },
9126
+ "column": {
9127
+ "type": "string",
9128
+ "description": "The column of the table or base."
9129
+ },
9130
+ "key": {
9131
+ "type": "string",
9132
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
9133
+ },
9134
+ "from": {
9135
+ "type": "string",
9136
+ "description": "The name as written before."
9137
+ },
9138
+ "to": {
9139
+ "type": "string",
9140
+ "description": "The name written in its place."
9141
+ }
9142
+ },
9143
+ "required": [
9144
+ "key",
9145
+ "from",
9146
+ "to"
9147
+ ]
9148
+ },
9149
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
8446
9150
  }
8447
9151
  },
8448
9152
  "required": [
@@ -8907,6 +9611,50 @@ var OPERATIONS = [
8907
9611
  ]
8908
9612
  },
8909
9613
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
9614
+ },
9615
+ "schema_references": {
9616
+ "type": "array",
9617
+ "items": {
9618
+ "title": "SchemaReference",
9619
+ "type": "object",
9620
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
9621
+ "properties": {
9622
+ "table": {
9623
+ "type": "string",
9624
+ "description": "The table whose column names it (full name)."
9625
+ },
9626
+ "base": {
9627
+ "type": "string",
9628
+ "description": "The base whose column names it."
9629
+ },
9630
+ "view": {
9631
+ "type": "string",
9632
+ "description": "The view whose query names it (full name)."
9633
+ },
9634
+ "column": {
9635
+ "type": "string",
9636
+ "description": "The column of the table or base."
9637
+ },
9638
+ "key": {
9639
+ "type": "string",
9640
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
9641
+ },
9642
+ "from": {
9643
+ "type": "string",
9644
+ "description": "The name as written before."
9645
+ },
9646
+ "to": {
9647
+ "type": "string",
9648
+ "description": "The name written in its place."
9649
+ }
9650
+ },
9651
+ "required": [
9652
+ "key",
9653
+ "from",
9654
+ "to"
9655
+ ]
9656
+ },
9657
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
8910
9658
  }
8911
9659
  },
8912
9660
  "required": [
@@ -9989,6 +10737,50 @@ var OPERATIONS = [
9989
10737
  ]
9990
10738
  },
9991
10739
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
10740
+ },
10741
+ "schema_references": {
10742
+ "type": "array",
10743
+ "items": {
10744
+ "title": "SchemaReference",
10745
+ "type": "object",
10746
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
10747
+ "properties": {
10748
+ "table": {
10749
+ "type": "string",
10750
+ "description": "The table whose column names it (full name)."
10751
+ },
10752
+ "base": {
10753
+ "type": "string",
10754
+ "description": "The base whose column names it."
10755
+ },
10756
+ "view": {
10757
+ "type": "string",
10758
+ "description": "The view whose query names it (full name)."
10759
+ },
10760
+ "column": {
10761
+ "type": "string",
10762
+ "description": "The column of the table or base."
10763
+ },
10764
+ "key": {
10765
+ "type": "string",
10766
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
10767
+ },
10768
+ "from": {
10769
+ "type": "string",
10770
+ "description": "The name as written before."
10771
+ },
10772
+ "to": {
10773
+ "type": "string",
10774
+ "description": "The name written in its place."
10775
+ }
10776
+ },
10777
+ "required": [
10778
+ "key",
10779
+ "from",
10780
+ "to"
10781
+ ]
10782
+ },
10783
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
9992
10784
  }
9993
10785
  },
9994
10786
  "required": [
@@ -10436,6 +11228,50 @@ var OPERATIONS = [
10436
11228
  ]
10437
11229
  },
10438
11230
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
11231
+ },
11232
+ "schema_references": {
11233
+ "type": "array",
11234
+ "items": {
11235
+ "title": "SchemaReference",
11236
+ "type": "object",
11237
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
11238
+ "properties": {
11239
+ "table": {
11240
+ "type": "string",
11241
+ "description": "The table whose column names it (full name)."
11242
+ },
11243
+ "base": {
11244
+ "type": "string",
11245
+ "description": "The base whose column names it."
11246
+ },
11247
+ "view": {
11248
+ "type": "string",
11249
+ "description": "The view whose query names it (full name)."
11250
+ },
11251
+ "column": {
11252
+ "type": "string",
11253
+ "description": "The column of the table or base."
11254
+ },
11255
+ "key": {
11256
+ "type": "string",
11257
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
11258
+ },
11259
+ "from": {
11260
+ "type": "string",
11261
+ "description": "The name as written before."
11262
+ },
11263
+ "to": {
11264
+ "type": "string",
11265
+ "description": "The name written in its place."
11266
+ }
11267
+ },
11268
+ "required": [
11269
+ "key",
11270
+ "from",
11271
+ "to"
11272
+ ]
11273
+ },
11274
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
10439
11275
  }
10440
11276
  },
10441
11277
  "required": [
@@ -11523,6 +12359,50 @@ var OPERATIONS = [
11523
12359
  ]
11524
12360
  },
11525
12361
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
12362
+ },
12363
+ "schema_references": {
12364
+ "type": "array",
12365
+ "items": {
12366
+ "title": "SchemaReference",
12367
+ "type": "object",
12368
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
12369
+ "properties": {
12370
+ "table": {
12371
+ "type": "string",
12372
+ "description": "The table whose column names it (full name)."
12373
+ },
12374
+ "base": {
12375
+ "type": "string",
12376
+ "description": "The base whose column names it."
12377
+ },
12378
+ "view": {
12379
+ "type": "string",
12380
+ "description": "The view whose query names it (full name)."
12381
+ },
12382
+ "column": {
12383
+ "type": "string",
12384
+ "description": "The column of the table or base."
12385
+ },
12386
+ "key": {
12387
+ "type": "string",
12388
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
12389
+ },
12390
+ "from": {
12391
+ "type": "string",
12392
+ "description": "The name as written before."
12393
+ },
12394
+ "to": {
12395
+ "type": "string",
12396
+ "description": "The name written in its place."
12397
+ }
12398
+ },
12399
+ "required": [
12400
+ "key",
12401
+ "from",
12402
+ "to"
12403
+ ]
12404
+ },
12405
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
11526
12406
  }
11527
12407
  },
11528
12408
  "required": [
@@ -12964,6 +13844,50 @@ var OPERATIONS = [
12964
13844
  ]
12965
13845
  },
12966
13846
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
13847
+ },
13848
+ "schema_references": {
13849
+ "type": "array",
13850
+ "items": {
13851
+ "title": "SchemaReference",
13852
+ "type": "object",
13853
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
13854
+ "properties": {
13855
+ "table": {
13856
+ "type": "string",
13857
+ "description": "The table whose column names it (full name)."
13858
+ },
13859
+ "base": {
13860
+ "type": "string",
13861
+ "description": "The base whose column names it."
13862
+ },
13863
+ "view": {
13864
+ "type": "string",
13865
+ "description": "The view whose query names it (full name)."
13866
+ },
13867
+ "column": {
13868
+ "type": "string",
13869
+ "description": "The column of the table or base."
13870
+ },
13871
+ "key": {
13872
+ "type": "string",
13873
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
13874
+ },
13875
+ "from": {
13876
+ "type": "string",
13877
+ "description": "The name as written before."
13878
+ },
13879
+ "to": {
13880
+ "type": "string",
13881
+ "description": "The name written in its place."
13882
+ }
13883
+ },
13884
+ "required": [
13885
+ "key",
13886
+ "from",
13887
+ "to"
13888
+ ]
13889
+ },
13890
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
12967
13891
  }
12968
13892
  },
12969
13893
  "required": [
@@ -13984,6 +14908,50 @@ var OPERATIONS = [
13984
14908
  ]
13985
14909
  },
13986
14910
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
14911
+ },
14912
+ "schema_references": {
14913
+ "type": "array",
14914
+ "items": {
14915
+ "title": "SchemaReference",
14916
+ "type": "object",
14917
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
14918
+ "properties": {
14919
+ "table": {
14920
+ "type": "string",
14921
+ "description": "The table whose column names it (full name)."
14922
+ },
14923
+ "base": {
14924
+ "type": "string",
14925
+ "description": "The base whose column names it."
14926
+ },
14927
+ "view": {
14928
+ "type": "string",
14929
+ "description": "The view whose query names it (full name)."
14930
+ },
14931
+ "column": {
14932
+ "type": "string",
14933
+ "description": "The column of the table or base."
14934
+ },
14935
+ "key": {
14936
+ "type": "string",
14937
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
14938
+ },
14939
+ "from": {
14940
+ "type": "string",
14941
+ "description": "The name as written before."
14942
+ },
14943
+ "to": {
14944
+ "type": "string",
14945
+ "description": "The name written in its place."
14946
+ }
14947
+ },
14948
+ "required": [
14949
+ "key",
14950
+ "from",
14951
+ "to"
14952
+ ]
14953
+ },
14954
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
13987
14955
  }
13988
14956
  },
13989
14957
  "required": [
@@ -14386,6 +15354,50 @@ var OPERATIONS = [
14386
15354
  ]
14387
15355
  },
14388
15356
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
15357
+ },
15358
+ "schema_references": {
15359
+ "type": "array",
15360
+ "items": {
15361
+ "title": "SchemaReference",
15362
+ "type": "object",
15363
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
15364
+ "properties": {
15365
+ "table": {
15366
+ "type": "string",
15367
+ "description": "The table whose column names it (full name)."
15368
+ },
15369
+ "base": {
15370
+ "type": "string",
15371
+ "description": "The base whose column names it."
15372
+ },
15373
+ "view": {
15374
+ "type": "string",
15375
+ "description": "The view whose query names it (full name)."
15376
+ },
15377
+ "column": {
15378
+ "type": "string",
15379
+ "description": "The column of the table or base."
15380
+ },
15381
+ "key": {
15382
+ "type": "string",
15383
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
15384
+ },
15385
+ "from": {
15386
+ "type": "string",
15387
+ "description": "The name as written before."
15388
+ },
15389
+ "to": {
15390
+ "type": "string",
15391
+ "description": "The name written in its place."
15392
+ }
15393
+ },
15394
+ "required": [
15395
+ "key",
15396
+ "from",
15397
+ "to"
15398
+ ]
15399
+ },
15400
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
14389
15401
  }
14390
15402
  },
14391
15403
  "required": [
@@ -14855,6 +15867,50 @@ var OPERATIONS = [
14855
15867
  ]
14856
15868
  },
14857
15869
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
15870
+ },
15871
+ "schema_references": {
15872
+ "type": "array",
15873
+ "items": {
15874
+ "title": "SchemaReference",
15875
+ "type": "object",
15876
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
15877
+ "properties": {
15878
+ "table": {
15879
+ "type": "string",
15880
+ "description": "The table whose column names it (full name)."
15881
+ },
15882
+ "base": {
15883
+ "type": "string",
15884
+ "description": "The base whose column names it."
15885
+ },
15886
+ "view": {
15887
+ "type": "string",
15888
+ "description": "The view whose query names it (full name)."
15889
+ },
15890
+ "column": {
15891
+ "type": "string",
15892
+ "description": "The column of the table or base."
15893
+ },
15894
+ "key": {
15895
+ "type": "string",
15896
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
15897
+ },
15898
+ "from": {
15899
+ "type": "string",
15900
+ "description": "The name as written before."
15901
+ },
15902
+ "to": {
15903
+ "type": "string",
15904
+ "description": "The name written in its place."
15905
+ }
15906
+ },
15907
+ "required": [
15908
+ "key",
15909
+ "from",
15910
+ "to"
15911
+ ]
15912
+ },
15913
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
14858
15914
  }
14859
15915
  },
14860
15916
  "required": [
@@ -15253,6 +16309,50 @@ var OPERATIONS = [
15253
16309
  ]
15254
16310
  },
15255
16311
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
16312
+ },
16313
+ "schema_references": {
16314
+ "type": "array",
16315
+ "items": {
16316
+ "title": "SchemaReference",
16317
+ "type": "object",
16318
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
16319
+ "properties": {
16320
+ "table": {
16321
+ "type": "string",
16322
+ "description": "The table whose column names it (full name)."
16323
+ },
16324
+ "base": {
16325
+ "type": "string",
16326
+ "description": "The base whose column names it."
16327
+ },
16328
+ "view": {
16329
+ "type": "string",
16330
+ "description": "The view whose query names it (full name)."
16331
+ },
16332
+ "column": {
16333
+ "type": "string",
16334
+ "description": "The column of the table or base."
16335
+ },
16336
+ "key": {
16337
+ "type": "string",
16338
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
16339
+ },
16340
+ "from": {
16341
+ "type": "string",
16342
+ "description": "The name as written before."
16343
+ },
16344
+ "to": {
16345
+ "type": "string",
16346
+ "description": "The name written in its place."
16347
+ }
16348
+ },
16349
+ "required": [
16350
+ "key",
16351
+ "from",
16352
+ "to"
16353
+ ]
16354
+ },
16355
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
15256
16356
  }
15257
16357
  },
15258
16358
  "required": [
@@ -15682,6 +16782,50 @@ var OPERATIONS = [
15682
16782
  ]
15683
16783
  },
15684
16784
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
16785
+ },
16786
+ "schema_references": {
16787
+ "type": "array",
16788
+ "items": {
16789
+ "title": "SchemaReference",
16790
+ "type": "object",
16791
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
16792
+ "properties": {
16793
+ "table": {
16794
+ "type": "string",
16795
+ "description": "The table whose column names it (full name)."
16796
+ },
16797
+ "base": {
16798
+ "type": "string",
16799
+ "description": "The base whose column names it."
16800
+ },
16801
+ "view": {
16802
+ "type": "string",
16803
+ "description": "The view whose query names it (full name)."
16804
+ },
16805
+ "column": {
16806
+ "type": "string",
16807
+ "description": "The column of the table or base."
16808
+ },
16809
+ "key": {
16810
+ "type": "string",
16811
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
16812
+ },
16813
+ "from": {
16814
+ "type": "string",
16815
+ "description": "The name as written before."
16816
+ },
16817
+ "to": {
16818
+ "type": "string",
16819
+ "description": "The name written in its place."
16820
+ }
16821
+ },
16822
+ "required": [
16823
+ "key",
16824
+ "from",
16825
+ "to"
16826
+ ]
16827
+ },
16828
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
15685
16829
  }
15686
16830
  },
15687
16831
  "required": [
@@ -16098,6 +17242,50 @@ var OPERATIONS = [
16098
17242
  ]
16099
17243
  },
16100
17244
  "description": "Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text."
17245
+ },
17246
+ "schema_references": {
17247
+ "type": "array",
17248
+ "items": {
17249
+ "title": "SchemaReference",
17250
+ "type": "object",
17251
+ "description": "A name of the moved table in another definition, rewritten to the new name.",
17252
+ "properties": {
17253
+ "table": {
17254
+ "type": "string",
17255
+ "description": "The table whose column names it (full name)."
17256
+ },
17257
+ "base": {
17258
+ "type": "string",
17259
+ "description": "The base whose column names it."
17260
+ },
17261
+ "view": {
17262
+ "type": "string",
17263
+ "description": "The view whose query names it (full name)."
17264
+ },
17265
+ "column": {
17266
+ "type": "string",
17267
+ "description": "The column of the table or base."
17268
+ },
17269
+ "key": {
17270
+ "type": "string",
17271
+ "description": "Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view's query."
17272
+ },
17273
+ "from": {
17274
+ "type": "string",
17275
+ "description": "The name as written before."
17276
+ },
17277
+ "to": {
17278
+ "type": "string",
17279
+ "description": "The name written in its place."
17280
+ }
17281
+ },
17282
+ "required": [
17283
+ "key",
17284
+ "from",
17285
+ "to"
17286
+ ]
17287
+ },
17288
+ "description": "alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views' queries read. Present when there is one."
16101
17289
  }
16102
17290
  },
16103
17291
  "required": [
@@ -16867,130 +18055,402 @@ function classOf(cp) {
16867
18055
  return k;
16868
18056
  }
16869
18057
 
16870
- // src/api/otlp.ts
16871
- var SEVERITY_NUMBER = { DEBUG: 5, INFO: 9, WARN: 13, ERROR: 17 };
16872
- var SPAN_KIND = { internal: 1, server: 2, client: 3, producer: 4, consumer: 5 };
16873
- var STATUS_CODE = { unset: 0, ok: 1, error: 2 };
16874
- function attr(key, v) {
16875
- if (v === void 0 || v === null) return null;
16876
- if (typeof v === "boolean") return { key, value: { boolValue: v } };
16877
- if (typeof v === "number") return Number.isInteger(v) ? { key, value: { intValue: String(v) } } : { key, value: { doubleValue: v } };
16878
- return { key, value: { stringValue: v } };
18058
+ // src/api/tracing.ts
18059
+ var TRACEPARENT_HEADER = "traceparent";
18060
+ var TRACESTATE_HEADER = "tracestate";
18061
+ var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
18062
+ function parseTraceparent(traceparent, tracestate) {
18063
+ const m = TRACEPARENT.exec((typeof traceparent === "string" ? traceparent : "").trim().toLowerCase());
18064
+ if (!m) return null;
18065
+ const [, version, traceId, spanId, flags, rest] = m;
18066
+ if (version === "ff" || version === "00" && rest !== void 0) return null;
18067
+ if (/^0+$/.test(traceId) || /^0+$/.test(spanId)) return null;
18068
+ const state = (typeof tracestate === "string" ? tracestate : "").trim();
18069
+ return { traceId, spanId, sampled: (parseInt(flags, 16) & 1) === 1, ...state ? { traceState: state.slice(0, 512) } : {} };
16879
18070
  }
16880
- var attrs = (a) => Object.entries(a).map(([k, v]) => attr(k, v)).filter((x) => x !== null);
16881
- var fetchSend = async (url, body, headers) => {
16882
- const res = await fetch(url, { method: "POST", headers, body });
16883
- if (!res.ok) throw new Error(`OTLP HTTP ${res.status}`);
16884
- };
16885
- function unixNano(ms) {
16886
- const whole = Math.floor(ms);
16887
- const frac = Math.round((ms - whole) * 1e6);
16888
- return (BigInt(whole) * BigInt(1e6) + BigInt(frac)).toString();
18071
+ function formatTraceparent(ctx) {
18072
+ return `00-${ctx.traceId}-${ctx.spanId}-${ctx.sampled ? "01" : "00"}`;
16889
18073
  }
16890
- var Pb = class {
16891
- constructor() {
16892
- this.parts = [];
16893
- }
16894
- varint(v) {
16895
- if (typeof v === "number" && v >= 0 && v < 2 ** 31) {
16896
- let x2 = v;
16897
- while (x2 >= 128) {
16898
- this.parts.push(x2 & 127 | 128);
16899
- x2 >>>= 7;
16900
- }
16901
- this.parts.push(x2);
16902
- return;
16903
- }
16904
- let x = BigInt.asUintN(64, BigInt(v));
16905
- const b128 = BigInt(128);
16906
- const low7 = BigInt(127);
16907
- const seven = BigInt(7);
16908
- while (x >= b128) {
16909
- this.parts.push(Number(x & low7) | 128);
16910
- x >>= seven;
16911
- }
16912
- this.parts.push(Number(x));
16913
- }
16914
- tag(field, wire) {
16915
- this.varint(field << 3 | wire);
18074
+ function traceHeaders(ctx) {
18075
+ return { [TRACEPARENT_HEADER]: formatTraceparent(ctx), ...ctx.traceState ? { [TRACESTATE_HEADER]: ctx.traceState } : {} };
18076
+ }
18077
+ function randomHex(bytes) {
18078
+ const b = new Uint8Array(bytes);
18079
+ const c = globalThis.crypto;
18080
+ if (c?.getRandomValues) c.getRandomValues(b);
18081
+ else for (let i = 0; i < bytes; i++) b[i] = Math.floor(Math.random() * 256);
18082
+ const hex = Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
18083
+ return /^0+$/.test(hex) ? randomHex(bytes) : hex;
18084
+ }
18085
+ var newTraceId = () => randomHex(16);
18086
+ var newSpanId = () => randomHex(8);
18087
+ var perf = globalThis.performance;
18088
+ var defaultNow = perf ? () => perf.timeOrigin + perf.now() : () => Date.now();
18089
+ var TraceSpan = class {
18090
+ constructor(tracer, name, kind, parent, recording, attributes) {
18091
+ this.tracer = tracer;
18092
+ this.name = name;
18093
+ this.kind = kind;
18094
+ this.parent = parent;
18095
+ this.recording = recording;
18096
+ this.attributes = {};
18097
+ this.events = [];
18098
+ this.status = { code: "unset" };
18099
+ this.ended = false;
18100
+ this.context = {
18101
+ traceId: parent?.traceId ?? newTraceId(),
18102
+ spanId: newSpanId(),
18103
+ sampled: recording,
18104
+ ...parent?.traceState ? { traceState: parent.traceState } : {}
18105
+ };
18106
+ this.startMs = tracer.now();
18107
+ this.setAttributes(attributes);
16916
18108
  }
16917
- uint(field, v) {
16918
- this.tag(field, 0);
16919
- this.varint(v);
18109
+ setAttribute(key, value) {
18110
+ if (value !== void 0 && value !== null) this.attributes[key] = value;
16920
18111
  return this;
16921
18112
  }
16922
- fixed32(field, v) {
16923
- this.tag(field, 5);
16924
- for (let i = 0; i < 4; i++) this.parts.push(v >>> 8 * i & 255);
18113
+ setAttributes(attributes) {
18114
+ for (const k in attributes) this.setAttribute(k, attributes[k]);
16925
18115
  return this;
16926
18116
  }
16927
- fixed64(field, v) {
16928
- this.tag(field, 1);
16929
- for (let i = 0; i < 8; i++) this.parts.push(Number(v >> BigInt(8 * i) & BigInt(255)));
18117
+ addEvent(name, attributes = {}) {
18118
+ this.events.push({ name, timeMs: this.tracer.now(), attributes });
16930
18119
  return this;
16931
18120
  }
16932
- double(field, v) {
16933
- this.tag(field, 1);
16934
- const b = new DataView(new ArrayBuffer(8));
16935
- b.setFloat64(0, v, true);
16936
- for (let i = 0; i < 8; i++) this.parts.push(b.getUint8(i));
16937
- return this;
18121
+ /** An `exception` event, `error.type` and status ERROR. */
18122
+ recordException(e) {
18123
+ const type = e instanceof Error ? e.name : typeof e;
18124
+ const message = e instanceof Error ? e.message : String(e);
18125
+ this.addEvent("exception", { "exception.type": type, "exception.message": message, ...e instanceof Error && e.stack ? { "exception.stacktrace": e.stack.slice(0, 8192) } : {} });
18126
+ if (!("error.type" in this.attributes)) this.attributes["error.type"] = type;
18127
+ return this.setStatus("error", message);
16938
18128
  }
16939
- bytes(field, data) {
16940
- this.tag(field, 2);
16941
- this.varint(data.length);
16942
- for (const x of data) this.parts.push(x);
18129
+ setStatus(code, message) {
18130
+ if (this.status.code === "error" && code !== "error") return this;
18131
+ this.status = code === "error" && message ? { code, message } : { code };
16943
18132
  return this;
16944
18133
  }
16945
- /** An id given in hex (trace and span ids), as bytes. */
16946
- hex(field, hex) {
16947
- const out = [];
16948
- for (let i = 0; i < hex.length; i += 2) out.push(parseInt(hex.slice(i, i + 2), 16));
16949
- return this.bytes(field, out);
18134
+ end() {
18135
+ if (this.ended) return;
18136
+ this.ended = true;
18137
+ if (!this.recording) return;
18138
+ this.tracer.send({
18139
+ traceId: this.context.traceId,
18140
+ spanId: this.context.spanId,
18141
+ ...this.parent ? { parentSpanId: this.parent.spanId } : {},
18142
+ ...this.context.traceState ? { traceState: this.context.traceState } : {},
18143
+ name: this.name,
18144
+ kind: this.kind,
18145
+ startMs: this.startMs,
18146
+ endMs: this.tracer.now(),
18147
+ attributes: this.attributes,
18148
+ events: this.events,
18149
+ status: this.status
18150
+ });
16950
18151
  }
16951
- string(field, s) {
16952
- return this.bytes(field, new TextEncoder().encode(s));
18152
+ };
18153
+ var Tracer = class {
18154
+ constructor(o) {
18155
+ this.o = o;
18156
+ this.now = o.now ?? defaultNow;
16953
18157
  }
16954
- message(field, m) {
16955
- return this.bytes(field, m.finish());
18158
+ /** A new span: a child of `parent` (a context or a `traceparent` header), or a new trace. */
18159
+ startSpan(name, opts = {}) {
18160
+ const parent = typeof opts.parent === "string" ? parseTraceparent(opts.parent) : opts.parent ?? null;
18161
+ const ratio = this.o.sampleRatio ?? 1;
18162
+ const span = new TraceSpan(this, name, opts.kind ?? "internal", parent, true, opts.attributes ?? {});
18163
+ const recording = parent ? parent.sampled : ratio >= 1 || ratio > 0 && parseInt(span.context.traceId.slice(-13), 16) / 2 ** 52 < ratio;
18164
+ return recording ? span : new TraceSpan(this, name, opts.kind ?? "internal", parent ?? { ...span.context, sampled: false }, false, {});
16956
18165
  }
16957
- finish() {
16958
- return Uint8Array.from(this.parts);
18166
+ /** @internal */
18167
+ send(span) {
18168
+ try {
18169
+ this.o.export([span]);
18170
+ } catch {
18171
+ }
16959
18172
  }
16960
18173
  };
16961
- function pbValue(v) {
16962
- if (typeof v === "string") return new Pb().string(1, v);
16963
- if (typeof v === "boolean") return new Pb().uint(2, v ? 1 : 0);
16964
- return Number.isInteger(v) ? new Pb().uint(3, BigInt(v)) : new Pb().double(4, v);
18174
+
18175
+ // src/api/client.ts
18176
+ var ACTOR_HEADER = "X-Datanotes-Actor";
18177
+ var UNREACHABLE = {
18178
+ hint: "Start the engine (datanotes serve --database <folder>) or check its address; datanotes status --database <folder> shows whether it runs and where.",
18179
+ docs: `${DOCS_BASE}/start/connect-agents.md#how-the-mcp-server-reaches-the-engine`
18180
+ };
18181
+ var AUTH = {
18182
+ hint: "Send the engine's owner token (httpServerToken in settings.json in the engine's store: datanotes store path shows where) or a named token the owner made with POST /datanotes/tokens/create/, as Authorization: Bearer <token>.",
18183
+ docs: `${DOCS_BASE}/develop/http-api.md#authenticate-your-requests`
18184
+ };
18185
+ var DatanotesError = class extends Error {
18186
+ /** `unreachable`: the engine did not answer; `auth`: the token was refused. */
18187
+ constructor(message, kind = "http", status = 0, guidance = kind === "unreachable" ? UNREACHABLE : kind === "auth" ? AUTH : null) {
18188
+ super(guidedText(message, guidance));
18189
+ this.kind = kind;
18190
+ this.status = status;
18191
+ this.name = "DatanotesError";
18192
+ if (guidance) {
18193
+ this.hint = guidance.hint;
18194
+ this.docs = guidance.docs;
18195
+ }
18196
+ }
18197
+ };
18198
+ var fetchTransport = async (req) => {
18199
+ const res = await fetch(req.url, { method: req.method, headers: req.headers, ...req.body !== void 0 ? { body: req.body } : {} });
18200
+ return { status: res.status, text: await res.text() };
18201
+ };
18202
+ function isEngineAnswer(json) {
18203
+ if (json === null || typeof json !== "object" || Array.isArray(json)) return false;
18204
+ const o = json;
18205
+ return typeof o.ok === "boolean" || typeof o.error === "string";
16965
18206
  }
16966
- function pbAttrs(m, field, a) {
16967
- for (const [k, v] of Object.entries(a)) {
16968
- if (v === void 0 || v === null) continue;
16969
- m.message(field, new Pb().string(1, k).message(2, pbValue(v)));
18207
+ function clientSpan(tracer, method, url, parent) {
18208
+ let target;
18209
+ try {
18210
+ target = new URL(url);
18211
+ } catch {
18212
+ target = null;
16970
18213
  }
16971
- return m;
18214
+ return tracer.startSpan(target ? `${method} ${target.pathname}` : method, {
18215
+ kind: "client",
18216
+ parent,
18217
+ attributes: {
18218
+ "http.request.method": method,
18219
+ "url.full": target ? `${target.protocol}//${target.host}${target.pathname}` : void 0,
18220
+ "server.address": target?.hostname,
18221
+ "server.port": target ? Number(target.port || (target.protocol === "https:" ? 443 : 80)) : void 0
18222
+ }
18223
+ });
16972
18224
  }
16973
- var OtlpBatcher = class {
16974
- constructor(o, path, maxBatch) {
18225
+ function parse(text) {
18226
+ try {
18227
+ return text.trim() ? JSON.parse(text) : void 0;
18228
+ } catch {
18229
+ return void 0;
18230
+ }
18231
+ }
18232
+ function trimTrailingSlashes(s) {
18233
+ let end = s.length;
18234
+ while (end > 0 && s.charCodeAt(end - 1) === 47) end--;
18235
+ return end === s.length ? s : s.slice(0, end);
18236
+ }
18237
+ var DatanotesClient = class {
18238
+ constructor(o) {
16975
18239
  this.o = o;
16976
- this.path = path;
16977
- this.maxBatch = maxBatch;
16978
- this.buffer = [];
16979
- this.inflight = Promise.resolve();
16980
- this.timer = null;
16981
- /** Items sent, and items lost because the collector did not take them (or the buffer was full). */
16982
- this.sent = 0;
16983
- this.dropped = 0;
16984
- const every = o.flushMs ?? 5e3;
16985
- if (every > 0) {
16986
- this.timer = setInterval(() => void this.flush(), every);
16987
- this.timer.unref?.();
16988
- }
18240
+ this.url = trimTrailingSlashes(o.url);
18241
+ this.send = o.transport ?? fetchTransport;
16989
18242
  }
16990
- push(items) {
16991
- const room = this.maxBatch * 8 - this.buffer.length;
16992
- if (room < items.length) this.dropped += items.length - Math.max(room, 0);
16993
- for (let i = 0; i < Math.min(items.length, Math.max(room, 0)); i++) this.buffer.push(items[i]);
18243
+ /** The parent of a request: the call's own `trace`, else the client's. */
18244
+ parentOf(trace) {
18245
+ const given = trace ?? (typeof this.o.trace === "function" ? this.o.trace() : this.o.trace);
18246
+ return typeof given === "string" ? parseTraceparent(given) : given ?? null;
18247
+ }
18248
+ /**
18249
+ * Send a request; the answer's status, its JSON (when it is JSON) and its text. `trace`: the
18250
+ * trace this request continues (over the client's `trace` option).
18251
+ */
18252
+ async request(method, path, body, opts = {}) {
18253
+ if (!this.url) throw new DatanotesError("engine address not set", "unreachable");
18254
+ if (!this.o.token) throw new DatanotesError("token not set", "auth");
18255
+ const actor = opts.actor ?? this.o.actor;
18256
+ const parent = this.parentOf(opts.trace);
18257
+ const span = this.o.tracer ? clientSpan(this.o.tracer, method, `${this.url}${path}`, parent) : void 0;
18258
+ const sent = span?.context ?? parent;
18259
+ let res;
18260
+ try {
18261
+ res = await this.send({
18262
+ url: `${this.url}${path}`,
18263
+ method,
18264
+ headers: {
18265
+ Authorization: `Bearer ${this.o.token}`,
18266
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {},
18267
+ ...opts.accept ? { Accept: opts.accept } : {},
18268
+ ...actor && Object.keys(actor).length ? { [ACTOR_HEADER]: JSON.stringify(actor) } : {},
18269
+ ...sent ? traceHeaders(sent) : {}
18270
+ },
18271
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
18272
+ });
18273
+ } catch (e) {
18274
+ span?.recordException(e);
18275
+ span?.end();
18276
+ throw new DatanotesError(`engine unreachable at ${this.url}: ${e instanceof Error ? e.message : String(e)}`, "unreachable");
18277
+ }
18278
+ span?.setAttribute("http.response.status_code", res.status);
18279
+ if (res.status >= 400) span?.setAttribute("error.type", String(res.status));
18280
+ if (res.status >= 500) span?.setStatus("error", `HTTP ${res.status}`);
18281
+ span?.end();
18282
+ if (res.status === 401) throw new DatanotesError("token refused by the engine", "auth", 401);
18283
+ const json = parse(res.text);
18284
+ const unreachable = res.status === 0 || res.status === 502 || res.status === 504 || res.status === 503 && !isEngineAnswer(json);
18285
+ if (unreachable) throw new DatanotesError(`engine unreachable at ${this.url} (HTTP ${res.status})`, "unreachable", res.status);
18286
+ return { status: res.status, json, text: res.text };
18287
+ }
18288
+ /** `POST /datanotes/<route>` and its JSON answer; throws on an error status. */
18289
+ async post(route, body = {}, actor) {
18290
+ const r = await this.request("POST", `/datanotes${route}`, body, actor ? { actor } : {});
18291
+ if (r.status >= 400) throw Object.assign(new DatanotesError(resultOf(r.status, r.json, r.text).value, "http", r.status), guidanceIn(r.json));
18292
+ return r.json;
18293
+ }
18294
+ /**
18295
+ * Run an operation of the catalogue (`select_rows`, `insert_row`, …) with an agent's arguments.
18296
+ * Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
18297
+ * with the same message the engine gives.
18298
+ */
18299
+ async call(name, args = {}, actor, options = {}) {
18300
+ let req;
18301
+ try {
18302
+ req = operationRequest(name, args);
18303
+ } catch (e) {
18304
+ if (e instanceof OperationInputError) return { ok: false, value: e.message };
18305
+ throw e;
18306
+ }
18307
+ const problem = checkArguments(name, args);
18308
+ if (problem) return { ok: false, value: guidedText(problem.message, problem) };
18309
+ const r = await this.request(req.method, req.path, req.body, { ...actor ? { actor } : {}, ...options.trace ? { trace: options.trace } : {} });
18310
+ return resultOf(r.status, r.json, r.text);
18311
+ }
18312
+ /** True when the engine answers `GET /` (no token needed). */
18313
+ async ping() {
18314
+ try {
18315
+ const r = await this.send({ url: `${this.url}/`, method: "GET", headers: {} });
18316
+ return r.status === 200;
18317
+ } catch {
18318
+ return false;
18319
+ }
18320
+ }
18321
+ /**
18322
+ * Record an agent's tool call in the change feed (what MCP servers report). Answers what the
18323
+ * engine said: `takes_summary` when it records a `value` sent cut with its `summary`.
18324
+ */
18325
+ async recordToolCall(call, actor) {
18326
+ return this.post("/tool-calls/record/", call, actor);
18327
+ }
18328
+ };
18329
+
18330
+ // src/api/otlp.ts
18331
+ var SEVERITY_NUMBER = { DEBUG: 5, INFO: 9, WARN: 13, ERROR: 17 };
18332
+ var SPAN_KIND = { internal: 1, server: 2, client: 3, producer: 4, consumer: 5 };
18333
+ var STATUS_CODE = { unset: 0, ok: 1, error: 2 };
18334
+ function attr(key, v) {
18335
+ if (v === void 0 || v === null) return null;
18336
+ if (typeof v === "boolean") return { key, value: { boolValue: v } };
18337
+ if (typeof v === "number") return Number.isInteger(v) ? { key, value: { intValue: String(v) } } : { key, value: { doubleValue: v } };
18338
+ return { key, value: { stringValue: v } };
18339
+ }
18340
+ var attrs = (a) => Object.entries(a).map(([k, v]) => attr(k, v)).filter((x) => x !== null);
18341
+ var fetchSend = async (url, body, headers) => {
18342
+ const res = await fetch(url, { method: "POST", headers, body });
18343
+ if (!res.ok) throw new Error(`OTLP HTTP ${res.status}`);
18344
+ };
18345
+ function unixNano(ms) {
18346
+ const whole = Math.floor(ms);
18347
+ const frac = Math.round((ms - whole) * 1e6);
18348
+ return (BigInt(whole) * BigInt(1e6) + BigInt(frac)).toString();
18349
+ }
18350
+ var Pb = class {
18351
+ constructor() {
18352
+ this.parts = [];
18353
+ }
18354
+ varint(v) {
18355
+ if (typeof v === "number" && v >= 0 && v < 2 ** 31) {
18356
+ let x2 = v;
18357
+ while (x2 >= 128) {
18358
+ this.parts.push(x2 & 127 | 128);
18359
+ x2 >>>= 7;
18360
+ }
18361
+ this.parts.push(x2);
18362
+ return;
18363
+ }
18364
+ let x = BigInt.asUintN(64, BigInt(v));
18365
+ const b128 = BigInt(128);
18366
+ const low7 = BigInt(127);
18367
+ const seven = BigInt(7);
18368
+ while (x >= b128) {
18369
+ this.parts.push(Number(x & low7) | 128);
18370
+ x >>= seven;
18371
+ }
18372
+ this.parts.push(Number(x));
18373
+ }
18374
+ tag(field, wire) {
18375
+ this.varint(field << 3 | wire);
18376
+ }
18377
+ uint(field, v) {
18378
+ this.tag(field, 0);
18379
+ this.varint(v);
18380
+ return this;
18381
+ }
18382
+ fixed32(field, v) {
18383
+ this.tag(field, 5);
18384
+ for (let i = 0; i < 4; i++) this.parts.push(v >>> 8 * i & 255);
18385
+ return this;
18386
+ }
18387
+ fixed64(field, v) {
18388
+ this.tag(field, 1);
18389
+ for (let i = 0; i < 8; i++) this.parts.push(Number(v >> BigInt(8 * i) & BigInt(255)));
18390
+ return this;
18391
+ }
18392
+ double(field, v) {
18393
+ this.tag(field, 1);
18394
+ const b = new DataView(new ArrayBuffer(8));
18395
+ b.setFloat64(0, v, true);
18396
+ for (let i = 0; i < 8; i++) this.parts.push(b.getUint8(i));
18397
+ return this;
18398
+ }
18399
+ bytes(field, data) {
18400
+ this.tag(field, 2);
18401
+ this.varint(data.length);
18402
+ for (const x of data) this.parts.push(x);
18403
+ return this;
18404
+ }
18405
+ /** An id given in hex (trace and span ids), as bytes. */
18406
+ hex(field, hex) {
18407
+ const out = [];
18408
+ for (let i = 0; i < hex.length; i += 2) out.push(parseInt(hex.slice(i, i + 2), 16));
18409
+ return this.bytes(field, out);
18410
+ }
18411
+ string(field, s) {
18412
+ return this.bytes(field, new TextEncoder().encode(s));
18413
+ }
18414
+ message(field, m) {
18415
+ return this.bytes(field, m.finish());
18416
+ }
18417
+ finish() {
18418
+ return Uint8Array.from(this.parts);
18419
+ }
18420
+ };
18421
+ function pbValue(v) {
18422
+ if (typeof v === "string") return new Pb().string(1, v);
18423
+ if (typeof v === "boolean") return new Pb().uint(2, v ? 1 : 0);
18424
+ return Number.isInteger(v) ? new Pb().uint(3, BigInt(v)) : new Pb().double(4, v);
18425
+ }
18426
+ function pbAttrs(m, field, a) {
18427
+ for (const [k, v] of Object.entries(a)) {
18428
+ if (v === void 0 || v === null) continue;
18429
+ m.message(field, new Pb().string(1, k).message(2, pbValue(v)));
18430
+ }
18431
+ return m;
18432
+ }
18433
+ var OtlpBatcher = class {
18434
+ constructor(o, path, maxBatch) {
18435
+ this.o = o;
18436
+ this.path = path;
18437
+ this.maxBatch = maxBatch;
18438
+ this.buffer = [];
18439
+ this.inflight = Promise.resolve();
18440
+ this.timer = null;
18441
+ /** Items sent, and items lost because the collector did not take them (or the buffer was full). */
18442
+ this.sent = 0;
18443
+ this.dropped = 0;
18444
+ const every = o.flushMs ?? 5e3;
18445
+ if (every > 0) {
18446
+ this.timer = setInterval(() => void this.flush(), every);
18447
+ this.timer.unref?.();
18448
+ }
18449
+ }
18450
+ push(items) {
18451
+ const room = this.maxBatch * 8 - this.buffer.length;
18452
+ if (room < items.length) this.dropped += items.length - Math.max(room, 0);
18453
+ for (let i = 0; i < Math.min(items.length, Math.max(room, 0)); i++) this.buffer.push(items[i]);
16994
18454
  if (this.buffer.length >= this.maxBatch) void this.flush();
16995
18455
  }
16996
18456
  resource() {
@@ -17000,7 +18460,7 @@ var OtlpBatcher = class {
17000
18460
  flush() {
17001
18461
  if (this.buffer.length === 0) return this.inflight;
17002
18462
  const send = this.o.send ?? fetchSend;
17003
- const url = `${this.o.endpoint.replace(/\/+$/, "")}${this.path}`;
18463
+ const url = `${trimTrailingSlashes(this.o.endpoint)}${this.path}`;
17004
18464
  const protobuf = (this.o.protocol ?? "http/protobuf") === "http/protobuf";
17005
18465
  const headers = { "Content-Type": protobuf ? "application/x-protobuf" : "application/json", ...this.o.headers ?? {} };
17006
18466
  while (this.buffer.length > 0) {
@@ -17192,273 +18652,6 @@ function otlpProtocol(v) {
17192
18652
  const p = (v ?? "").trim().toLowerCase();
17193
18653
  return p === "http/protobuf" || p === "http/json" ? p : void 0;
17194
18654
  }
17195
-
17196
- // src/api/tracing.ts
17197
- var TRACEPARENT_HEADER = "traceparent";
17198
- var TRACESTATE_HEADER = "tracestate";
17199
- var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
17200
- function parseTraceparent(traceparent, tracestate) {
17201
- const m = TRACEPARENT.exec((typeof traceparent === "string" ? traceparent : "").trim().toLowerCase());
17202
- if (!m) return null;
17203
- const [, version, traceId, spanId, flags, rest] = m;
17204
- if (version === "ff" || version === "00" && rest !== void 0) return null;
17205
- if (/^0+$/.test(traceId) || /^0+$/.test(spanId)) return null;
17206
- const state = (typeof tracestate === "string" ? tracestate : "").trim();
17207
- return { traceId, spanId, sampled: (parseInt(flags, 16) & 1) === 1, ...state ? { traceState: state.slice(0, 512) } : {} };
17208
- }
17209
- function formatTraceparent(ctx) {
17210
- return `00-${ctx.traceId}-${ctx.spanId}-${ctx.sampled ? "01" : "00"}`;
17211
- }
17212
- function traceHeaders(ctx) {
17213
- return { [TRACEPARENT_HEADER]: formatTraceparent(ctx), ...ctx.traceState ? { [TRACESTATE_HEADER]: ctx.traceState } : {} };
17214
- }
17215
- function randomHex(bytes) {
17216
- const b = new Uint8Array(bytes);
17217
- const c = globalThis.crypto;
17218
- if (c?.getRandomValues) c.getRandomValues(b);
17219
- else for (let i = 0; i < bytes; i++) b[i] = Math.floor(Math.random() * 256);
17220
- const hex = Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
17221
- return /^0+$/.test(hex) ? randomHex(bytes) : hex;
17222
- }
17223
- var newTraceId = () => randomHex(16);
17224
- var newSpanId = () => randomHex(8);
17225
- var perf = globalThis.performance;
17226
- var defaultNow = perf ? () => perf.timeOrigin + perf.now() : () => Date.now();
17227
- var TraceSpan = class {
17228
- constructor(tracer, name, kind, parent, recording, attributes) {
17229
- this.tracer = tracer;
17230
- this.name = name;
17231
- this.kind = kind;
17232
- this.parent = parent;
17233
- this.recording = recording;
17234
- this.attributes = {};
17235
- this.events = [];
17236
- this.status = { code: "unset" };
17237
- this.ended = false;
17238
- this.context = {
17239
- traceId: parent?.traceId ?? newTraceId(),
17240
- spanId: newSpanId(),
17241
- sampled: recording,
17242
- ...parent?.traceState ? { traceState: parent.traceState } : {}
17243
- };
17244
- this.startMs = tracer.now();
17245
- this.setAttributes(attributes);
17246
- }
17247
- setAttribute(key, value) {
17248
- if (value !== void 0 && value !== null) this.attributes[key] = value;
17249
- return this;
17250
- }
17251
- setAttributes(attributes) {
17252
- for (const k in attributes) this.setAttribute(k, attributes[k]);
17253
- return this;
17254
- }
17255
- addEvent(name, attributes = {}) {
17256
- this.events.push({ name, timeMs: this.tracer.now(), attributes });
17257
- return this;
17258
- }
17259
- /** An `exception` event, `error.type` and status ERROR. */
17260
- recordException(e) {
17261
- const type = e instanceof Error ? e.name : typeof e;
17262
- const message = e instanceof Error ? e.message : String(e);
17263
- this.addEvent("exception", { "exception.type": type, "exception.message": message, ...e instanceof Error && e.stack ? { "exception.stacktrace": e.stack.slice(0, 8192) } : {} });
17264
- if (!("error.type" in this.attributes)) this.attributes["error.type"] = type;
17265
- return this.setStatus("error", message);
17266
- }
17267
- setStatus(code, message) {
17268
- if (this.status.code === "error" && code !== "error") return this;
17269
- this.status = code === "error" && message ? { code, message } : { code };
17270
- return this;
17271
- }
17272
- end() {
17273
- if (this.ended) return;
17274
- this.ended = true;
17275
- if (!this.recording) return;
17276
- this.tracer.send({
17277
- traceId: this.context.traceId,
17278
- spanId: this.context.spanId,
17279
- ...this.parent ? { parentSpanId: this.parent.spanId } : {},
17280
- ...this.context.traceState ? { traceState: this.context.traceState } : {},
17281
- name: this.name,
17282
- kind: this.kind,
17283
- startMs: this.startMs,
17284
- endMs: this.tracer.now(),
17285
- attributes: this.attributes,
17286
- events: this.events,
17287
- status: this.status
17288
- });
17289
- }
17290
- };
17291
- var Tracer = class {
17292
- constructor(o) {
17293
- this.o = o;
17294
- this.now = o.now ?? defaultNow;
17295
- }
17296
- /** A new span: a child of `parent` (a context or a `traceparent` header), or a new trace. */
17297
- startSpan(name, opts = {}) {
17298
- const parent = typeof opts.parent === "string" ? parseTraceparent(opts.parent) : opts.parent ?? null;
17299
- const ratio = this.o.sampleRatio ?? 1;
17300
- const span = new TraceSpan(this, name, opts.kind ?? "internal", parent, true, opts.attributes ?? {});
17301
- const recording = parent ? parent.sampled : ratio >= 1 || ratio > 0 && parseInt(span.context.traceId.slice(-13), 16) / 2 ** 52 < ratio;
17302
- return recording ? span : new TraceSpan(this, name, opts.kind ?? "internal", parent ?? { ...span.context, sampled: false }, false, {});
17303
- }
17304
- /** @internal */
17305
- send(span) {
17306
- try {
17307
- this.o.export([span]);
17308
- } catch {
17309
- }
17310
- }
17311
- };
17312
-
17313
- // src/api/client.ts
17314
- var ACTOR_HEADER = "X-Datanotes-Actor";
17315
- var UNREACHABLE = {
17316
- hint: "Start the engine (datanotes serve --database <folder>) or check its address; datanotes status --database <folder> shows whether it runs and where.",
17317
- docs: `${DOCS_BASE}/start/connect-agents.md#how-the-mcp-server-reaches-the-engine`
17318
- };
17319
- var AUTH = {
17320
- hint: "Send the engine's owner token (httpServerToken in settings.json in the engine's store: datanotes store path shows where) or a named token the owner made with POST /datanotes/tokens/create/, as Authorization: Bearer <token>.",
17321
- docs: `${DOCS_BASE}/develop/http-api.md#authenticate-your-requests`
17322
- };
17323
- var DatanotesError = class extends Error {
17324
- /** `unreachable`: the engine did not answer; `auth`: the token was refused. */
17325
- constructor(message, kind = "http", status = 0, guidance = kind === "unreachable" ? UNREACHABLE : kind === "auth" ? AUTH : null) {
17326
- super(guidedText(message, guidance));
17327
- this.kind = kind;
17328
- this.status = status;
17329
- this.name = "DatanotesError";
17330
- if (guidance) {
17331
- this.hint = guidance.hint;
17332
- this.docs = guidance.docs;
17333
- }
17334
- }
17335
- };
17336
- var fetchTransport = async (req) => {
17337
- const res = await fetch(req.url, { method: req.method, headers: req.headers, ...req.body !== void 0 ? { body: req.body } : {} });
17338
- return { status: res.status, text: await res.text() };
17339
- };
17340
- function isEngineAnswer(json) {
17341
- if (json === null || typeof json !== "object" || Array.isArray(json)) return false;
17342
- const o = json;
17343
- return typeof o.ok === "boolean" || typeof o.error === "string";
17344
- }
17345
- function clientSpan(tracer, method, url, parent) {
17346
- let target;
17347
- try {
17348
- target = new URL(url);
17349
- } catch {
17350
- target = null;
17351
- }
17352
- return tracer.startSpan(target ? `${method} ${target.pathname}` : method, {
17353
- kind: "client",
17354
- parent,
17355
- attributes: {
17356
- "http.request.method": method,
17357
- "url.full": target ? `${target.protocol}//${target.host}${target.pathname}` : void 0,
17358
- "server.address": target?.hostname,
17359
- "server.port": target ? Number(target.port || (target.protocol === "https:" ? 443 : 80)) : void 0
17360
- }
17361
- });
17362
- }
17363
- function parse(text) {
17364
- try {
17365
- return text.trim() ? JSON.parse(text) : void 0;
17366
- } catch {
17367
- return void 0;
17368
- }
17369
- }
17370
- var DatanotesClient = class {
17371
- constructor(o) {
17372
- this.o = o;
17373
- this.url = o.url.replace(/\/+$/, "");
17374
- this.send = o.transport ?? fetchTransport;
17375
- }
17376
- /** The parent of a request: the call's own `trace`, else the client's. */
17377
- parentOf(trace) {
17378
- const given = trace ?? (typeof this.o.trace === "function" ? this.o.trace() : this.o.trace);
17379
- return typeof given === "string" ? parseTraceparent(given) : given ?? null;
17380
- }
17381
- /**
17382
- * Send a request; the answer's status, its JSON (when it is JSON) and its text. `trace`: the
17383
- * trace this request continues (over the client's `trace` option).
17384
- */
17385
- async request(method, path, body, opts = {}) {
17386
- if (!this.url) throw new DatanotesError("engine address not set", "unreachable");
17387
- if (!this.o.token) throw new DatanotesError("token not set", "auth");
17388
- const actor = opts.actor ?? this.o.actor;
17389
- const parent = this.parentOf(opts.trace);
17390
- const span = this.o.tracer ? clientSpan(this.o.tracer, method, `${this.url}${path}`, parent) : void 0;
17391
- const sent = span?.context ?? parent;
17392
- let res;
17393
- try {
17394
- res = await this.send({
17395
- url: `${this.url}${path}`,
17396
- method,
17397
- headers: {
17398
- Authorization: `Bearer ${this.o.token}`,
17399
- ...body !== void 0 ? { "Content-Type": "application/json" } : {},
17400
- ...opts.accept ? { Accept: opts.accept } : {},
17401
- ...actor && Object.keys(actor).length ? { [ACTOR_HEADER]: JSON.stringify(actor) } : {},
17402
- ...sent ? traceHeaders(sent) : {}
17403
- },
17404
- ...body !== void 0 ? { body: JSON.stringify(body) } : {}
17405
- });
17406
- } catch (e) {
17407
- span?.recordException(e);
17408
- span?.end();
17409
- throw new DatanotesError(`engine unreachable at ${this.url}: ${e instanceof Error ? e.message : String(e)}`, "unreachable");
17410
- }
17411
- span?.setAttribute("http.response.status_code", res.status);
17412
- if (res.status >= 400) span?.setAttribute("error.type", String(res.status));
17413
- if (res.status >= 500) span?.setStatus("error", `HTTP ${res.status}`);
17414
- span?.end();
17415
- if (res.status === 401) throw new DatanotesError("token refused by the engine", "auth", 401);
17416
- const json = parse(res.text);
17417
- const unreachable = res.status === 0 || res.status === 502 || res.status === 504 || res.status === 503 && !isEngineAnswer(json);
17418
- if (unreachable) throw new DatanotesError(`engine unreachable at ${this.url} (HTTP ${res.status})`, "unreachable", res.status);
17419
- return { status: res.status, json, text: res.text };
17420
- }
17421
- /** `POST /datanotes/<route>` and its JSON answer; throws on an error status. */
17422
- async post(route, body = {}, actor) {
17423
- const r = await this.request("POST", `/datanotes${route}`, body, actor ? { actor } : {});
17424
- if (r.status >= 400) throw Object.assign(new DatanotesError(resultOf(r.status, r.json, r.text).value, "http", r.status), guidanceIn(r.json));
17425
- return r.json;
17426
- }
17427
- /**
17428
- * Run an operation of the catalogue (`select_rows`, `insert_row`, …) with an agent's arguments.
17429
- * Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
17430
- * with the same message the engine gives.
17431
- */
17432
- async call(name, args = {}, actor, options = {}) {
17433
- let req;
17434
- try {
17435
- req = operationRequest(name, args);
17436
- } catch (e) {
17437
- if (e instanceof OperationInputError) return { ok: false, value: e.message };
17438
- throw e;
17439
- }
17440
- const problem = checkArguments(name, args);
17441
- if (problem) return { ok: false, value: guidedText(problem.message, problem) };
17442
- const r = await this.request(req.method, req.path, req.body, { ...actor ? { actor } : {}, ...options.trace ? { trace: options.trace } : {} });
17443
- return resultOf(r.status, r.json, r.text);
17444
- }
17445
- /** True when the engine answers `GET /` (no token needed). */
17446
- async ping() {
17447
- try {
17448
- const r = await this.send({ url: `${this.url}/`, method: "GET", headers: {} });
17449
- return r.status === 200;
17450
- } catch {
17451
- return false;
17452
- }
17453
- }
17454
- /**
17455
- * Record an agent's tool call in the change feed (what MCP servers report). Answers what the
17456
- * engine said: `takes_summary` when it records a `value` sent cut with its `summary`.
17457
- */
17458
- async recordToolCall(call, actor) {
17459
- return this.post("/tool-calls/record/", call, actor);
17460
- }
17461
- };
17462
18655
  export {
17463
18656
  ACTOR_HEADER,
17464
18657
  CALLABLE_OPERATIONS,