@saptools/cf-hana 0.3.5 → 0.4.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.
- package/CHANGELOG.md +15 -0
- package/README.md +97 -17
- package/dist/cli.js +3932 -3184
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +23 -8
- package/dist/index.js +922 -315
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ type StatementKind = "select" | "dml" | "ddl" | "unknown";
|
|
|
8
8
|
type DbUserRole = "runtime" | "hdi";
|
|
9
9
|
/** Where resolved credentials came from. */
|
|
10
10
|
type CredentialSource = "live";
|
|
11
|
+
/** Whether the app selector was pinned by the caller or inherited from `cf target`. */
|
|
12
|
+
type SelectorSource = "explicit" | "ambient";
|
|
11
13
|
/** Output rendering for CLI results. */
|
|
12
|
-
type OutputFormat = "table" | "json" | "csv";
|
|
14
|
+
type OutputFormat = "table" | "json" | "json-compact" | "csv";
|
|
13
15
|
interface QueryResultColumn {
|
|
14
16
|
readonly name: string;
|
|
15
17
|
readonly typeName: string;
|
|
@@ -94,15 +96,23 @@ interface HanaClientInfo {
|
|
|
94
96
|
readonly role: DbUserRole;
|
|
95
97
|
readonly driver: string;
|
|
96
98
|
readonly credentialSource: CredentialSource;
|
|
99
|
+
readonly selectorSource?: SelectorSource;
|
|
100
|
+
readonly regionConfirmed?: boolean;
|
|
101
|
+
readonly selectorCanBePinned?: boolean;
|
|
102
|
+
readonly bindingName?: string;
|
|
103
|
+
readonly bindingIndex?: number;
|
|
104
|
+
readonly availableBindingNames?: readonly string[];
|
|
97
105
|
}
|
|
98
106
|
|
|
99
|
-
type WriteBackupOperation = "update" | "upsert" | "delete";
|
|
107
|
+
type WriteBackupOperation = "update" | "upsert" | "replace" | "merge" | "delete";
|
|
100
108
|
interface WriteBackupPlan {
|
|
101
109
|
readonly operation: WriteBackupOperation;
|
|
102
110
|
readonly statementSql: string;
|
|
103
111
|
readonly selectSql: string;
|
|
104
112
|
readonly selectParams: readonly SqlParam[];
|
|
105
113
|
}
|
|
114
|
+
declare function buildWriteBackupPlan(sql: string, params?: readonly SqlParam[]): WriteBackupPlan | undefined;
|
|
115
|
+
|
|
106
116
|
interface SqlBackupWriteInput {
|
|
107
117
|
readonly operation: WriteBackupOperation;
|
|
108
118
|
readonly statementSql: string;
|
|
@@ -112,6 +122,7 @@ interface SqlBackupWriteInput {
|
|
|
112
122
|
interface SqlBackupWriteOptions {
|
|
113
123
|
readonly now?: Date;
|
|
114
124
|
readonly saptoolsRoot?: string;
|
|
125
|
+
readonly maxBytes?: number;
|
|
115
126
|
}
|
|
116
127
|
interface SqlBackupRecord {
|
|
117
128
|
readonly directory: string;
|
|
@@ -121,7 +132,6 @@ interface SqlBackupRecord {
|
|
|
121
132
|
readonly rowCount: number;
|
|
122
133
|
}
|
|
123
134
|
declare function cfHanaBackupRoot(saptoolsRoot?: string): string;
|
|
124
|
-
declare function buildWriteBackupPlan(sql: string, params?: readonly SqlParam[]): WriteBackupPlan | undefined;
|
|
125
135
|
declare function writeSqlBackup(input: SqlBackupWriteInput, options?: SqlBackupWriteOptions): Promise<SqlBackupRecord>;
|
|
126
136
|
|
|
127
137
|
interface CatalogObjectInfo {
|
|
@@ -246,14 +256,15 @@ declare class Transaction {
|
|
|
246
256
|
declare class HanaClient {
|
|
247
257
|
private readonly pool;
|
|
248
258
|
readonly info: HanaClientInfo;
|
|
249
|
-
|
|
259
|
+
readonly databaseUser: string;
|
|
260
|
+
constructor(pool: ConnectionPool, info: HanaClientInfo, databaseUser?: string);
|
|
250
261
|
/** Open a client for a `region/org/space/app` selector (or a bare app name). */
|
|
251
262
|
static connect(selector: string, options?: ConnectOptions): Promise<HanaClient>;
|
|
252
263
|
/** Run a SELECT (or any read) statement and return typed rows. */
|
|
253
264
|
query<TRow = QueryRow>(sql: string, params?: readonly SqlParam[], options?: QueryOptions): Promise<QueryResult<TRow>>;
|
|
254
265
|
/** Run a DML/DDL statement and return its affected-row count. */
|
|
255
266
|
execute(sql: string, params?: readonly SqlParam[], options?: QueryOptions): Promise<QueryResult>;
|
|
256
|
-
/** Back up rows
|
|
267
|
+
/** Back up pre-image rows required by a supported write before the caller runs it. */
|
|
257
268
|
backupWriteStatement(sql: string, params?: readonly SqlParam[], options?: QueryOptions): Promise<SqlBackupRecord | undefined>;
|
|
258
269
|
/** Run a typed `SELECT` built from a spec. */
|
|
259
270
|
selectFrom<TRow = QueryRow>(spec: SelectSpec): Promise<QueryResult<TRow>>;
|
|
@@ -320,9 +331,9 @@ declare function formatJson(result: QueryResult): string;
|
|
|
320
331
|
/** Render a result as RFC 4180 CSV. */
|
|
321
332
|
declare function formatCsv(result: QueryResult): string;
|
|
322
333
|
/** Render a query result in the requested output format. */
|
|
323
|
-
declare function formatResult(result: QueryResult, format: OutputFormat): string;
|
|
334
|
+
declare function formatResult(result: QueryResult, format: OutputFormat, compactColumn?: string): string;
|
|
324
335
|
|
|
325
|
-
type CfHanaErrorCode = "CONFIG" | "CREDENTIALS_NOT_FOUND" | "AMBIGUOUS_BINDING" | "CONNECTION" | "QUERY" | "READ_ONLY_VIOLATION" | "DESTRUCTIVE_BLOCKED" | "TIMEOUT" | "POOL_CLOSED";
|
|
336
|
+
type CfHanaErrorCode = "CONFIG" | "CREDENTIALS_NOT_FOUND" | "AMBIGUOUS_BINDING" | "CONNECTION" | "QUERY" | "BACKUP_REQUIRED" | "READ_ONLY_VIOLATION" | "DESTRUCTIVE_BLOCKED" | "TIMEOUT" | "POOL_CLOSED";
|
|
326
337
|
interface CfHanaErrorOptions {
|
|
327
338
|
readonly cause?: unknown;
|
|
328
339
|
}
|
|
@@ -345,6 +356,10 @@ declare class QueryError extends CfHanaError {
|
|
|
345
356
|
readonly databaseCode: number | undefined;
|
|
346
357
|
constructor(message: string, options?: QueryErrorOptions);
|
|
347
358
|
}
|
|
359
|
+
/** A CLI write was refused because its required pre-image could not be preserved. */
|
|
360
|
+
declare class BackupRequiredError extends CfHanaError {
|
|
361
|
+
constructor(message: string, options?: CfHanaErrorOptions);
|
|
362
|
+
}
|
|
348
363
|
/** A write/DDL statement was issued on a read-only client. */
|
|
349
364
|
declare class ReadOnlyViolationError extends CfHanaError {
|
|
350
365
|
constructor(message: string, options?: CfHanaErrorOptions);
|
|
@@ -356,4 +371,4 @@ declare class DestructiveStatementError extends CfHanaError {
|
|
|
356
371
|
/** Narrow an unknown thrown value to a human-readable message. */
|
|
357
372
|
declare function errorMessage(error: unknown): string;
|
|
358
373
|
|
|
359
|
-
export { type BuiltStatement, type CatalogObjectInfo, CfHanaError, type CfHanaErrorCode, type ColumnInfo, type ConnectOptions, type CredentialSource, CredentialsNotFoundError, type DbUserRole, DestructiveStatementError, type DriverConnectParams, type DriverConnection, type DriverExecResult, HanaClient, type HanaClientInfo, type HanaDriver, type OutputFormat, type PoolOptions, QueryError, type QueryOptions, type QueryResult, type QueryResultColumn, type QueryRow, ReadOnlyViolationError, type SelectSpec, type SqlBackupRecord, type SqlBackupWriteInput, type SqlBackupWriteOptions, type SqlParam, type StatementKind, type TableInfo, Transaction, type WriteBackupOperation, type WriteBackupPlan, buildCount, buildDelete, buildInsert, buildSelect, buildUpdate, buildWriteBackupPlan, cfHanaBackupRoot, connect, createDriver, errorMessage, formatCsv, formatJson, formatResult, formatTable, query, withConnection, writeSqlBackup };
|
|
374
|
+
export { BackupRequiredError, type BuiltStatement, type CatalogObjectInfo, CfHanaError, type CfHanaErrorCode, type ColumnInfo, type ConnectOptions, type CredentialSource, CredentialsNotFoundError, type DbUserRole, DestructiveStatementError, type DriverConnectParams, type DriverConnection, type DriverExecResult, HanaClient, type HanaClientInfo, type HanaDriver, type OutputFormat, type PoolOptions, QueryError, type QueryOptions, type QueryResult, type QueryResultColumn, type QueryRow, ReadOnlyViolationError, type SelectSpec, type SelectorSource, type SqlBackupRecord, type SqlBackupWriteInput, type SqlBackupWriteOptions, type SqlParam, type StatementKind, type TableInfo, Transaction, type WriteBackupOperation, type WriteBackupPlan, buildCount, buildDelete, buildInsert, buildSelect, buildUpdate, buildWriteBackupPlan, cfHanaBackupRoot, connect, createDriver, errorMessage, formatCsv, formatJson, formatResult, formatTable, query, withConnection, writeSqlBackup };
|