@saptools/cf-hana 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +47 -15
- package/dist/cli.js +1025 -85
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +531 -57
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 - 2026-07-01
|
|
4
|
+
|
|
5
|
+
- Add invalid table/view recovery suggestions for failed `query` statements, with nearby table and view names printed to stderr so stdout remains parseable.
|
|
6
|
+
- Add a private local metadata cache under `~/.saptools/cf-hana/metadata` with a strict 30-minute TTL and `--refresh-metadata` bypass.
|
|
7
|
+
- Include schema-scoped `SYS.TABLES` and `SYS.VIEWS` metadata for suggestions without caching credentials, parameters, result rows, or table data.
|
|
8
|
+
|
|
3
9
|
## 0.2.0 - 2026-06-25
|
|
4
10
|
|
|
5
11
|
- Change CLI `query` output for `SELECT`/`WITH` statements to compact CSV and
|
package/README.md
CHANGED
|
@@ -22,9 +22,10 @@ login on the hot path) and connections are pooled and reused within a process.
|
|
|
22
22
|
- **Query-builder shorthands** — `selectFrom`, `count`, `insertInto`, `update`,
|
|
23
23
|
`deleteFrom` — query a table by name without writing SQL.
|
|
24
24
|
- **Schema introspection** — list schemas, tables, and columns.
|
|
25
|
+
- **Table-name recovery** — failed CLI queries for missing tables/views show nearby schema-local suggestions on stderr.
|
|
25
26
|
- **Local SQL history** — direct SQL calls are appended to dated JSONL files
|
|
26
27
|
under `~/.saptools/cf-hana/histories/` with five-day retention.
|
|
27
|
-
- **Write backups** — CLI `UPDATE` and `DELETE` statements create a local CSV
|
|
28
|
+
- **Write backups** — CLI `UPDATE`, `UPSERT`, and `DELETE` statements create a local CSV
|
|
28
29
|
backup of matching rows before the write runs.
|
|
29
30
|
- **Compact CLI results** — CLI `SELECT`/`WITH` output is compact CSV with
|
|
30
31
|
bounded cells and optional saved refs for exact follow-up inspection.
|
|
@@ -91,9 +92,9 @@ cf-hana result <command> Inspect saved query refs
|
|
|
91
92
|
Common options: `--refresh`, `--role <runtime|hdi>`, `--binding <name>` /
|
|
92
93
|
`--binding-index <n>`, `--timeout <ms>`, `--read-only`, `--allow-destructive`,
|
|
93
94
|
`--limit <n>`, `--no-auto-limit`. The `query` command also accepts
|
|
94
|
-
`--param <value>` (repeatable), `--cell-limit <n>`, `--save`,
|
|
95
|
-
`--result-ttl-minutes <n
|
|
96
|
-
`--format <table|json|csv>`. CLI `UPDATE` and `DELETE` statements are backed up
|
|
95
|
+
`--param <value>` (repeatable), `--cell-limit <n>`, `--save`,
|
|
96
|
+
`--result-ttl-minutes <n>`, and `--refresh-metadata`. `tables` and `columns` still support
|
|
97
|
+
`--format <table|json|csv>`. CLI `UPDATE`, `UPSERT`, and `DELETE` statements are backed up
|
|
97
98
|
automatically before the write runs.
|
|
98
99
|
|
|
99
100
|
```bash
|
|
@@ -149,6 +150,31 @@ cf-hana result clear
|
|
|
149
150
|
API keeps returning full-fidelity `QueryResult` values and does not write result
|
|
150
151
|
refs.
|
|
151
152
|
|
|
153
|
+
## Invalid table/view suggestions and metadata cache
|
|
154
|
+
|
|
155
|
+
When `cf-hana query` fails with a likely HANA invalid table, view, or catalog
|
|
156
|
+
object error, the CLI keeps stdout empty/parseable and prints the original error
|
|
157
|
+
plus a small `Did you mean:` list to stderr. Suggestions are based on objects in
|
|
158
|
+
the active connection schema and include physical tables from `SYS.TABLES` and
|
|
159
|
+
views from `SYS.VIEWS`; `tables` output remains table-only for compatibility.
|
|
160
|
+
|
|
161
|
+
To avoid repeatedly reading catalog metadata after typo failures, cf-hana stores
|
|
162
|
+
only schema, object name, and object type under:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
~/.saptools/cf-hana/metadata/
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Metadata cache files are private (`0700` directories, `0600` files), written
|
|
169
|
+
atomically, and expire after exactly 30 minutes. The cache key is derived from
|
|
170
|
+
non-secret connection identity: selector, app name, host, active schema, role,
|
|
171
|
+
and driver. It does not include passwords, certificates, tokens, SQL parameter
|
|
172
|
+
values, result rows, or table data, and malformed cache files are treated as
|
|
173
|
+
misses. Pass `--refresh-metadata` to bypass this cache for a query; `--refresh`
|
|
174
|
+
also bypasses it because it refreshes the resolved connection identity. If
|
|
175
|
+
metadata lookup or cache I/O fails, cf-hana preserves the original query error
|
|
176
|
+
and simply omits suggestions.
|
|
177
|
+
|
|
152
178
|
## Programmatic API
|
|
153
179
|
|
|
154
180
|
| Export | Purpose |
|
|
@@ -156,7 +182,7 @@ refs.
|
|
|
156
182
|
| `connect(selector, options?)` | Open a reusable, pooled `HanaClient`. |
|
|
157
183
|
| `query(selector, sql, params?, options?)` | One-shot: connect, query, close. |
|
|
158
184
|
| `withConnection(selector, work, options?)` | Run `work` with a client that auto-closes. |
|
|
159
|
-
| `HanaClient` | `query`, `execute`, `backupWriteStatement`, `selectFrom`, `count`, `insertInto`, `update`, `deleteFrom`, `transaction`, `listSchemas`, `listTables`, `listColumns`, `explain`, `close`. |
|
|
185
|
+
| `HanaClient` | `query`, `execute`, `backupWriteStatement`, `selectFrom`, `count`, `insertInto`, `update`, `deleteFrom`, `transaction`, `listSchemas`, `listTables`, `listCatalogObjects`, `listColumns`, `explain`, `close`. |
|
|
160
186
|
| `createDriver`, `formatResult`, `build*` | Lower-level building blocks. |
|
|
161
187
|
|
|
162
188
|
`ConnectOptions` highlights: `role` (`runtime` | `hdi`), `bindingName` /
|
|
@@ -191,31 +217,37 @@ count, row count, truncation flag, and elapsed time. Parameter values,
|
|
|
191
217
|
credentials, certificates, and result rows are not stored.
|
|
192
218
|
|
|
193
219
|
History retention runs opportunistically after each append and deletes dated
|
|
194
|
-
history files older than five days. Helper-driven catalog SQL such as `tables
|
|
195
|
-
|
|
220
|
+
history files older than five days. Helper-driven catalog SQL such as `tables`,
|
|
221
|
+
`columns`, and table/view suggestion metadata reads is not recorded as user SQL
|
|
222
|
+
history.
|
|
196
223
|
|
|
197
224
|
## Write backups
|
|
198
225
|
|
|
199
|
-
When `cf-hana query` receives an `UPDATE` or `DELETE`, it first builds and runs a
|
|
226
|
+
When `cf-hana query` receives an `UPDATE`, `UPSERT`, or `DELETE`, it first builds and runs a
|
|
200
227
|
matching `SELECT`:
|
|
201
228
|
|
|
202
229
|
- `UPDATE <target> SET ... WHERE ...` becomes
|
|
203
230
|
`SELECT * FROM <target> WHERE ...`.
|
|
231
|
+
- `UPSERT <target> VALUES ... WHERE ...` becomes
|
|
232
|
+
`SELECT * FROM <target> WHERE ...`.
|
|
204
233
|
- `DELETE FROM <target> WHERE ...` becomes
|
|
205
234
|
`SELECT * FROM <target> WHERE ...`.
|
|
206
235
|
|
|
207
236
|
The backup is saved before the write runs:
|
|
208
237
|
|
|
209
238
|
```text
|
|
210
|
-
~/.saptools/cf-hana/backups
|
|
211
|
-
|
|
212
|
-
|
|
239
|
+
~/.saptools/cf-hana/backups/YYYYMM/
|
|
240
|
+
<region-org-space-app>-<operation>-<timestamp>.sql
|
|
241
|
+
<region-org-space-app>-<operation>-<timestamp>.statement.sql
|
|
242
|
+
<region-org-space-app>-<operation>-<timestamp>.json
|
|
213
243
|
```
|
|
214
244
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
245
|
+
The main `.sql` backup file contains CSV-formatted rows returned by the derived
|
|
246
|
+
`SELECT`, matching the requested region/org/space/app/action/timestamp naming
|
|
247
|
+
shape. The companion `.statement.sql` file contains the original write statement,
|
|
248
|
+
and `.json` contains non-secret metadata for auditability. Backup files are not
|
|
249
|
+
deleted by `cf-hana`; clean them up manually when they are no longer needed. The
|
|
250
|
+
backup path is printed to stderr so stdout remains parseable.
|
|
219
251
|
|
|
220
252
|
## Safety
|
|
221
253
|
|