qodalis-cli-server-plugin-data-explorer 1.0.0b32__tar.gz → 1.0.0b34__tar.gz
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.
- qodalis_cli_server_plugin_data_explorer-1.0.0b34/PKG-INFO +189 -0
- qodalis_cli_server_plugin_data_explorer-1.0.0b34/README.md +167 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/pyproject.toml +2 -2
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/dashboard/extension.js +22 -22
- qodalis_cli_server_plugin_data_explorer-1.0.0b32/PKG-INFO +0 -20
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/.gitignore +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/__init__.py +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/dashboard/extension.css +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/data_explorer_controller.py +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/data_explorer_executor.py +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/data_explorer_policy.py +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/data_explorer_registry.py +0 -0
- {qodalis_cli_server_plugin_data_explorer-1.0.0b32 → qodalis_cli_server_plugin_data_explorer-1.0.0b34}/qodalis_cli_data_explorer/plugin.py +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: qodalis-cli-server-plugin-data-explorer
|
|
3
|
+
Version: 1.0.0b34
|
|
4
|
+
Summary: Data Explorer plugin for Qodalis CLI servers
|
|
5
|
+
Project-URL: Homepage, https://github.com/qodalis-solutions/cli-server-python
|
|
6
|
+
Project-URL: Repository, https://github.com/qodalis-solutions/cli-server-python
|
|
7
|
+
Project-URL: Issues, https://github.com/qodalis-solutions/cli-server-python/issues
|
|
8
|
+
Author-email: Nicolae Lupei <nicolae.lupei@qodalis.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: cli,data-explorer,plugin,qodalis
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: qodalis-cli-server-abstractions
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# qodalis-cli-server-plugin-data-explorer
|
|
24
|
+
|
|
25
|
+
Data Explorer plugin for [Qodalis CLI Server (Python)](https://github.com/qodalis-solutions/cli-server-python). Provides a registry, executor, and REST API for querying multiple data sources through pluggable provider backends.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install qodalis-cli-server-plugin-data-explorer
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from qodalis_cli import create_cli_server
|
|
37
|
+
from qodalis_cli_server_abstractions import DataExplorerProviderOptions
|
|
38
|
+
from qodalis_cli_data_explorer_sql import SqlDataExplorerProvider
|
|
39
|
+
|
|
40
|
+
def configure(builder):
|
|
41
|
+
builder.add_data_explorer_provider(
|
|
42
|
+
SqlDataExplorerProvider(":memory:"),
|
|
43
|
+
DataExplorerProviderOptions(
|
|
44
|
+
name="sql",
|
|
45
|
+
description="In-memory SQLite database",
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
app = create_cli_server(configure=configure)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## REST API
|
|
53
|
+
|
|
54
|
+
The Data Explorer endpoints are automatically mounted when providers are registered.
|
|
55
|
+
|
|
56
|
+
| Method | Endpoint | Description |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| GET | `/sources` | The sources the caller may use, with language, output format, templates, `readOnly` and `canExport` |
|
|
59
|
+
| POST | `/execute` | Execute a query against a data source (403 without the source's permissions, 429 over its rate limit) |
|
|
60
|
+
| GET | `/schema?source=<name>` | A source's schema: allowed tables only, without dropped columns (403 without the source's permissions) |
|
|
61
|
+
|
|
62
|
+
### Execute Request Body
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"source": "sql",
|
|
67
|
+
"query": "SELECT * FROM users",
|
|
68
|
+
"parameters": {}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Provider Options
|
|
73
|
+
|
|
74
|
+
| Option | Type | Default | Description |
|
|
75
|
+
|---|---|---|---|
|
|
76
|
+
| `name` | `str` | (required) | Unique source identifier |
|
|
77
|
+
| `description` | `str` | `""` | Human-readable description |
|
|
78
|
+
| `language` | `str` | `"sql"` | Query language identifier |
|
|
79
|
+
| `default_output_format` | `str` | `"table"` | Default output format (`table`, `json`, etc.) |
|
|
80
|
+
| `max_rows` | `int` | `1000` | Maximum rows returned per query |
|
|
81
|
+
| `timeout` | `int` | `30000` | Query timeout in milliseconds |
|
|
82
|
+
| `required_permissions` | `list[str]` | -- | Permissions the caller needs besides `data:query`; other callers do not see the source (ignored on an open server) |
|
|
83
|
+
| `read_only` | `bool` | `True` | Only queries that read are accepted, and SQL providers run them in a read-only transaction. Set `False` for a source that must write |
|
|
84
|
+
| `allowed_objects` | `list[str]` | all | Glob patterns of the tables, collections, Redis keys or indices the source shows and accepts |
|
|
85
|
+
| `mask_columns` | `list[str]` | -- | Glob patterns of columns/fields whose values are shown as `***` |
|
|
86
|
+
| `drop_columns` | `list[str]` | -- | Glob patterns of columns/fields removed from results and the schema |
|
|
87
|
+
| `audit` | `bool` | `True` | Writes a `data_query` entry to the server's audit log for every execute |
|
|
88
|
+
| `rate_limit` | `DataExplorerRateLimit(max_queries, window_seconds)` | -- | Executes allowed per caller and window; more answer 429 |
|
|
89
|
+
| `export_permissions` | `list[str]` | -- | Permissions needed to export results (`canExport` in `/sources`; advisory) |
|
|
90
|
+
| `fix_name_case` | `bool` | `True` | A read-only SQL query failing on an unquoted name that differs only in case runs again with the name quoted as the schema spells it (`executedQuery` in the result); off: only a hint is added to the error |
|
|
91
|
+
|
|
92
|
+
Over HTTP the options keep the camelCase names of the other servers (`readOnly`, `canExport`, `errorCode`).
|
|
93
|
+
|
|
94
|
+
### Read-only sources
|
|
95
|
+
|
|
96
|
+
Sources are read-only unless they set `read_only=False`. The server checks each query before the provider runs it:
|
|
97
|
+
|
|
98
|
+
- SQL: one statement starting with `SELECT`, `WITH`, `EXPLAIN`, `SHOW`, `DESCRIBE`, `VALUES` or `TABLE`, without write keywords (comments and strings ignored, as MySQL, Postgres, SQL Server and SQLite each read them: a query must pass under every reading).
|
|
99
|
+
- MongoDB (`shell` or `json` language): `show collections` or `db.<collection>.find|findOne|countDocuments|estimatedDocumentCount|distinct|aggregate(...)` without `$out`/`$merge`.
|
|
100
|
+
- Redis: read commands only (`GET`, `HGETALL`, `LRANGE`, `KEYS`, `SCAN`, ...).
|
|
101
|
+
- Elasticsearch: `GET`/`HEAD`, or `POST` to `_search`, `_count`, `_msearch`, `_mget`, `_field_caps`, `_validate/query`.
|
|
102
|
+
- Other languages are refused unless the provider sets `read_only_queries = True` (it can only read).
|
|
103
|
+
|
|
104
|
+
The SQL providers also run the query in a read-only transaction (SQLite `PRAGMA query_only`, Postgres `BEGIN READ ONLY`, MySQL `START TRANSACTION READ ONLY`, SQL Server a transaction that is always rolled back). Postgres runs the query only as a prepared statement, which refuses several statements, so none can end the transaction. MySQL and SQL Server cannot do that: aiomysql always turns multi-statements on and has no option to turn them off, and SQL Server runs a whole batch. On these the server's one-statement check is the guard (a statement after a `COMMIT`, or DDL, which MySQL commits implicitly, would escape the transaction).
|
|
105
|
+
|
|
106
|
+
`allowed_objects` and the read-only check are a convenience filter. Give the source a database account that can only read what staff may see: that account is the real boundary.
|
|
107
|
+
|
|
108
|
+
### Masked columns
|
|
109
|
+
|
|
110
|
+
`mask_columns` and `drop_columns` match the column names of the result, so on SQL sources with either option a masked or dropped column may only be selected by its own name: as a plain item of the outer select list (`SELECT email`, `SELECT u.email, name`, `SELECT *`). Anything else is refused before the query runs with `errorCode: "masked_column"` and `Masked column 'email' can only be selected by its own name`:
|
|
111
|
+
|
|
112
|
+
- an alias or a computation (`SELECT email AS e`, `upper(email)`, `email || ''`),
|
|
113
|
+
- a filter, sort or join on it (`WHERE email = ...`, `ORDER BY email`), a subquery or CTE that names it, `UNION`/`EXCEPT`/`INTERSECT`;
|
|
114
|
+
- a whole row used as a value (Postgres `SELECT u FROM users u`, `row_to_json(u)`): `'u' is a whole row and this source masks columns: select its columns by name`;
|
|
115
|
+
- a Unicode-escaped name (`U&"..."`).
|
|
116
|
+
|
|
117
|
+
A result that names a selected masked column under another name (SQL Server `FOR JSON`) is withheld with the same error. Other languages (MongoDB, Redis, Elasticsearch) mask by field name only. This is still a filter on the query text: keep data that must stay hidden out of the database account's reach (a view, column grants).
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from qodalis_cli_server_abstractions import DataExplorerProviderOptions, DataExplorerRateLimit
|
|
121
|
+
|
|
122
|
+
builder.add_data_explorer_provider(
|
|
123
|
+
provider,
|
|
124
|
+
DataExplorerProviderOptions(
|
|
125
|
+
name="billing",
|
|
126
|
+
description="Billing database",
|
|
127
|
+
required_permissions=["data:billing"],
|
|
128
|
+
allowed_objects=["public.invoices", "public.customers"],
|
|
129
|
+
mask_columns=["email", "*phone*"],
|
|
130
|
+
drop_columns=["password_hash"],
|
|
131
|
+
rate_limit=DataExplorerRateLimit(max_queries=30, window_seconds=60),
|
|
132
|
+
export_permissions=["data:export"],
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Queries run in order: permissions, rate limit (per user id, or client address when anonymous), read-only check, allowed objects, masked columns, the provider, `max_rows`, masking, then the audit entry (refused queries are audited too, with the refusal as `error`). A failing audit log never fails the query.
|
|
138
|
+
|
|
139
|
+
## Available Providers
|
|
140
|
+
|
|
141
|
+
| Package | Data Source |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `qodalis-cli-server-plugin-data-explorer-sql` | SQLite |
|
|
144
|
+
| `qodalis-cli-server-plugin-data-explorer-postgres` | PostgreSQL |
|
|
145
|
+
| `qodalis-cli-server-plugin-data-explorer-mysql` | MySQL |
|
|
146
|
+
| `qodalis-cli-server-plugin-data-explorer-mssql` | MS SQL Server |
|
|
147
|
+
| `qodalis-cli-server-plugin-data-explorer-mongo` | MongoDB |
|
|
148
|
+
| `qodalis-cli-server-plugin-data-explorer-redis` | Redis |
|
|
149
|
+
| `qodalis-cli-server-plugin-data-explorer-elasticsearch` | Elasticsearch |
|
|
150
|
+
|
|
151
|
+
## Terminal commands
|
|
152
|
+
|
|
153
|
+
No server-side command: the web CLI plugin [`@qodalis/cli-data-explorer`](https://www.npmjs.com/package/@qodalis/cli-data-explorer)
|
|
154
|
+
opens a console on a source (`data-explorer [--server <name>]`, `data:query` on a protected server) with `\format`,
|
|
155
|
+
`\templates`, `\use`, `\schema`, `\history`, `\help` and `\quit`. With the MCP endpoint on, AI clients get the `data_*`
|
|
156
|
+
tools.
|
|
157
|
+
|
|
158
|
+
## Install from the dashboard
|
|
159
|
+
|
|
160
|
+
Installable at runtime from the server marketplace (the dashboard's Plugins → Marketplace, or
|
|
161
|
+
`admin plugins install data-explorer`; it loads at the next start), or in code through the same entry, its options the
|
|
162
|
+
defaults of the settings below (a saved setting overrides them):
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from qodalis_cli_data_explorer import plugin as data_explorer
|
|
166
|
+
|
|
167
|
+
builder.add_plugin(data_explorer, {...})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Entry point `data-explorer = "qodalis_cli_data_explorer.plugin:create_plugin"` (group `qodalis_cli.plugins`), load order 30. Its settings
|
|
171
|
+
(provider `data-explorer`, section `settings`; `config set data-explorer.settings.<key> <value>`, then a restart):
|
|
172
|
+
|
|
173
|
+
| Setting | Type | Default | |
|
|
174
|
+
|---|---|---|---|
|
|
175
|
+
| `forceReadOnly` | boolean | `false` | Every source may only read, whatever its own setting |
|
|
176
|
+
| `maxRows` | number | `0` | The most rows any source returns; 0: each source its own |
|
|
177
|
+
| `rateLimitQueries` | number | `0` | Per caller and source, for sources without their own limit; 0: none |
|
|
178
|
+
| `rateLimitWindowSeconds` | number | `60` | Window (seconds) |
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
MIT
|
|
183
|
+
|
|
184
|
+
## Dashboard page
|
|
185
|
+
|
|
186
|
+
The admin dashboard's Data explorer page (`@qodalis/cli-dashboard-module-data-explorer`) is embedded in this package
|
|
187
|
+
(`qodalis_cli_data_explorer/dashboard`, copied at build by `scripts/copy_dashboard.py`). The server serves it at
|
|
188
|
+
`/qcli/modules/data-explorer` and lists it (permission `data:query`) when a provider is registered;
|
|
189
|
+
`CliServerOptions(dashboard_pages={"data-explorer": path})` serves another build, `False` leaves it out.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# qodalis-cli-server-plugin-data-explorer
|
|
2
|
+
|
|
3
|
+
Data Explorer plugin for [Qodalis CLI Server (Python)](https://github.com/qodalis-solutions/cli-server-python). Provides a registry, executor, and REST API for querying multiple data sources through pluggable provider backends.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install qodalis-cli-server-plugin-data-explorer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from qodalis_cli import create_cli_server
|
|
15
|
+
from qodalis_cli_server_abstractions import DataExplorerProviderOptions
|
|
16
|
+
from qodalis_cli_data_explorer_sql import SqlDataExplorerProvider
|
|
17
|
+
|
|
18
|
+
def configure(builder):
|
|
19
|
+
builder.add_data_explorer_provider(
|
|
20
|
+
SqlDataExplorerProvider(":memory:"),
|
|
21
|
+
DataExplorerProviderOptions(
|
|
22
|
+
name="sql",
|
|
23
|
+
description="In-memory SQLite database",
|
|
24
|
+
),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
app = create_cli_server(configure=configure)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## REST API
|
|
31
|
+
|
|
32
|
+
The Data Explorer endpoints are automatically mounted when providers are registered.
|
|
33
|
+
|
|
34
|
+
| Method | Endpoint | Description |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| GET | `/sources` | The sources the caller may use, with language, output format, templates, `readOnly` and `canExport` |
|
|
37
|
+
| POST | `/execute` | Execute a query against a data source (403 without the source's permissions, 429 over its rate limit) |
|
|
38
|
+
| GET | `/schema?source=<name>` | A source's schema: allowed tables only, without dropped columns (403 without the source's permissions) |
|
|
39
|
+
|
|
40
|
+
### Execute Request Body
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"source": "sql",
|
|
45
|
+
"query": "SELECT * FROM users",
|
|
46
|
+
"parameters": {}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Provider Options
|
|
51
|
+
|
|
52
|
+
| Option | Type | Default | Description |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| `name` | `str` | (required) | Unique source identifier |
|
|
55
|
+
| `description` | `str` | `""` | Human-readable description |
|
|
56
|
+
| `language` | `str` | `"sql"` | Query language identifier |
|
|
57
|
+
| `default_output_format` | `str` | `"table"` | Default output format (`table`, `json`, etc.) |
|
|
58
|
+
| `max_rows` | `int` | `1000` | Maximum rows returned per query |
|
|
59
|
+
| `timeout` | `int` | `30000` | Query timeout in milliseconds |
|
|
60
|
+
| `required_permissions` | `list[str]` | -- | Permissions the caller needs besides `data:query`; other callers do not see the source (ignored on an open server) |
|
|
61
|
+
| `read_only` | `bool` | `True` | Only queries that read are accepted, and SQL providers run them in a read-only transaction. Set `False` for a source that must write |
|
|
62
|
+
| `allowed_objects` | `list[str]` | all | Glob patterns of the tables, collections, Redis keys or indices the source shows and accepts |
|
|
63
|
+
| `mask_columns` | `list[str]` | -- | Glob patterns of columns/fields whose values are shown as `***` |
|
|
64
|
+
| `drop_columns` | `list[str]` | -- | Glob patterns of columns/fields removed from results and the schema |
|
|
65
|
+
| `audit` | `bool` | `True` | Writes a `data_query` entry to the server's audit log for every execute |
|
|
66
|
+
| `rate_limit` | `DataExplorerRateLimit(max_queries, window_seconds)` | -- | Executes allowed per caller and window; more answer 429 |
|
|
67
|
+
| `export_permissions` | `list[str]` | -- | Permissions needed to export results (`canExport` in `/sources`; advisory) |
|
|
68
|
+
| `fix_name_case` | `bool` | `True` | A read-only SQL query failing on an unquoted name that differs only in case runs again with the name quoted as the schema spells it (`executedQuery` in the result); off: only a hint is added to the error |
|
|
69
|
+
|
|
70
|
+
Over HTTP the options keep the camelCase names of the other servers (`readOnly`, `canExport`, `errorCode`).
|
|
71
|
+
|
|
72
|
+
### Read-only sources
|
|
73
|
+
|
|
74
|
+
Sources are read-only unless they set `read_only=False`. The server checks each query before the provider runs it:
|
|
75
|
+
|
|
76
|
+
- SQL: one statement starting with `SELECT`, `WITH`, `EXPLAIN`, `SHOW`, `DESCRIBE`, `VALUES` or `TABLE`, without write keywords (comments and strings ignored, as MySQL, Postgres, SQL Server and SQLite each read them: a query must pass under every reading).
|
|
77
|
+
- MongoDB (`shell` or `json` language): `show collections` or `db.<collection>.find|findOne|countDocuments|estimatedDocumentCount|distinct|aggregate(...)` without `$out`/`$merge`.
|
|
78
|
+
- Redis: read commands only (`GET`, `HGETALL`, `LRANGE`, `KEYS`, `SCAN`, ...).
|
|
79
|
+
- Elasticsearch: `GET`/`HEAD`, or `POST` to `_search`, `_count`, `_msearch`, `_mget`, `_field_caps`, `_validate/query`.
|
|
80
|
+
- Other languages are refused unless the provider sets `read_only_queries = True` (it can only read).
|
|
81
|
+
|
|
82
|
+
The SQL providers also run the query in a read-only transaction (SQLite `PRAGMA query_only`, Postgres `BEGIN READ ONLY`, MySQL `START TRANSACTION READ ONLY`, SQL Server a transaction that is always rolled back). Postgres runs the query only as a prepared statement, which refuses several statements, so none can end the transaction. MySQL and SQL Server cannot do that: aiomysql always turns multi-statements on and has no option to turn them off, and SQL Server runs a whole batch. On these the server's one-statement check is the guard (a statement after a `COMMIT`, or DDL, which MySQL commits implicitly, would escape the transaction).
|
|
83
|
+
|
|
84
|
+
`allowed_objects` and the read-only check are a convenience filter. Give the source a database account that can only read what staff may see: that account is the real boundary.
|
|
85
|
+
|
|
86
|
+
### Masked columns
|
|
87
|
+
|
|
88
|
+
`mask_columns` and `drop_columns` match the column names of the result, so on SQL sources with either option a masked or dropped column may only be selected by its own name: as a plain item of the outer select list (`SELECT email`, `SELECT u.email, name`, `SELECT *`). Anything else is refused before the query runs with `errorCode: "masked_column"` and `Masked column 'email' can only be selected by its own name`:
|
|
89
|
+
|
|
90
|
+
- an alias or a computation (`SELECT email AS e`, `upper(email)`, `email || ''`),
|
|
91
|
+
- a filter, sort or join on it (`WHERE email = ...`, `ORDER BY email`), a subquery or CTE that names it, `UNION`/`EXCEPT`/`INTERSECT`;
|
|
92
|
+
- a whole row used as a value (Postgres `SELECT u FROM users u`, `row_to_json(u)`): `'u' is a whole row and this source masks columns: select its columns by name`;
|
|
93
|
+
- a Unicode-escaped name (`U&"..."`).
|
|
94
|
+
|
|
95
|
+
A result that names a selected masked column under another name (SQL Server `FOR JSON`) is withheld with the same error. Other languages (MongoDB, Redis, Elasticsearch) mask by field name only. This is still a filter on the query text: keep data that must stay hidden out of the database account's reach (a view, column grants).
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from qodalis_cli_server_abstractions import DataExplorerProviderOptions, DataExplorerRateLimit
|
|
99
|
+
|
|
100
|
+
builder.add_data_explorer_provider(
|
|
101
|
+
provider,
|
|
102
|
+
DataExplorerProviderOptions(
|
|
103
|
+
name="billing",
|
|
104
|
+
description="Billing database",
|
|
105
|
+
required_permissions=["data:billing"],
|
|
106
|
+
allowed_objects=["public.invoices", "public.customers"],
|
|
107
|
+
mask_columns=["email", "*phone*"],
|
|
108
|
+
drop_columns=["password_hash"],
|
|
109
|
+
rate_limit=DataExplorerRateLimit(max_queries=30, window_seconds=60),
|
|
110
|
+
export_permissions=["data:export"],
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Queries run in order: permissions, rate limit (per user id, or client address when anonymous), read-only check, allowed objects, masked columns, the provider, `max_rows`, masking, then the audit entry (refused queries are audited too, with the refusal as `error`). A failing audit log never fails the query.
|
|
116
|
+
|
|
117
|
+
## Available Providers
|
|
118
|
+
|
|
119
|
+
| Package | Data Source |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `qodalis-cli-server-plugin-data-explorer-sql` | SQLite |
|
|
122
|
+
| `qodalis-cli-server-plugin-data-explorer-postgres` | PostgreSQL |
|
|
123
|
+
| `qodalis-cli-server-plugin-data-explorer-mysql` | MySQL |
|
|
124
|
+
| `qodalis-cli-server-plugin-data-explorer-mssql` | MS SQL Server |
|
|
125
|
+
| `qodalis-cli-server-plugin-data-explorer-mongo` | MongoDB |
|
|
126
|
+
| `qodalis-cli-server-plugin-data-explorer-redis` | Redis |
|
|
127
|
+
| `qodalis-cli-server-plugin-data-explorer-elasticsearch` | Elasticsearch |
|
|
128
|
+
|
|
129
|
+
## Terminal commands
|
|
130
|
+
|
|
131
|
+
No server-side command: the web CLI plugin [`@qodalis/cli-data-explorer`](https://www.npmjs.com/package/@qodalis/cli-data-explorer)
|
|
132
|
+
opens a console on a source (`data-explorer [--server <name>]`, `data:query` on a protected server) with `\format`,
|
|
133
|
+
`\templates`, `\use`, `\schema`, `\history`, `\help` and `\quit`. With the MCP endpoint on, AI clients get the `data_*`
|
|
134
|
+
tools.
|
|
135
|
+
|
|
136
|
+
## Install from the dashboard
|
|
137
|
+
|
|
138
|
+
Installable at runtime from the server marketplace (the dashboard's Plugins → Marketplace, or
|
|
139
|
+
`admin plugins install data-explorer`; it loads at the next start), or in code through the same entry, its options the
|
|
140
|
+
defaults of the settings below (a saved setting overrides them):
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from qodalis_cli_data_explorer import plugin as data_explorer
|
|
144
|
+
|
|
145
|
+
builder.add_plugin(data_explorer, {...})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Entry point `data-explorer = "qodalis_cli_data_explorer.plugin:create_plugin"` (group `qodalis_cli.plugins`), load order 30. Its settings
|
|
149
|
+
(provider `data-explorer`, section `settings`; `config set data-explorer.settings.<key> <value>`, then a restart):
|
|
150
|
+
|
|
151
|
+
| Setting | Type | Default | |
|
|
152
|
+
|---|---|---|---|
|
|
153
|
+
| `forceReadOnly` | boolean | `false` | Every source may only read, whatever its own setting |
|
|
154
|
+
| `maxRows` | number | `0` | The most rows any source returns; 0: each source its own |
|
|
155
|
+
| `rateLimitQueries` | number | `0` | Per caller and source, for sources without their own limit; 0: none |
|
|
156
|
+
| `rateLimitWindowSeconds` | number | `60` | Window (seconds) |
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
## Dashboard page
|
|
163
|
+
|
|
164
|
+
The admin dashboard's Data explorer page (`@qodalis/cli-dashboard-module-data-explorer`) is embedded in this package
|
|
165
|
+
(`qodalis_cli_data_explorer/dashboard`, copied at build by `scripts/copy_dashboard.py`). The server serves it at
|
|
166
|
+
`/qcli/modules/data-explorer` and lists it (permission `data:query`) when a provider is registered;
|
|
167
|
+
`CliServerOptions(dashboard_pages={"data-explorer": path})` serves another build, `False` leaves it out.
|
|
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qodalis-cli-server-plugin-data-explorer"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.0b34"
|
|
8
8
|
description = "Data Explorer plugin for Qodalis CLI servers"
|
|
9
|
-
readme =
|
|
9
|
+
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
requires-python = ">=3.10"
|
|
12
12
|
authors = [
|