diff --git a/CHANGELOG.json b/CHANGELOG.json index 957fb1c..48467cf 100644 --- a/CHANGELOG.json +++ b/CHANGELOG.json @@ -7,7 +7,8 @@ "New Node.js minimum version of 18. [16 is end of life](https://nodejs.org/en/blog/announcements/nodejs16-eol)", "Load HANA Connection via CDS Env API and profile Hybrid instead of direct binding with cds-dk", "cds bind based connections are MUCH faster after the first call", - "PostgresSQL and SQLite support on key commands thanks to CDS abstraction" + "PostgresSQL and SQLite support on key commands thanks to CDS abstraction", + "Commands: tables and querySimple support profile based access and db abstraction" ] }, { diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a306ca..640d06b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/). +## [3.202309.1] - 2023-09-06 + +**Changed** + +- [CAP version 7.2.0](https://cap.cloud.sap/docs/releases/aug23) +- New Node.js minimum version of 18. [16 is end of life](https://nodejs.org/en/blog/announcements/nodejs16-eol) +- Load HANA Connection via CDS Env API and profile Hybrid instead of direct binding with cds-dk +- cds bind based connections are MUCH faster after the first call +- PostgresSQL and SQLite support on key commands thanks to CDS abstraction +- Commands: tables and querySimple support profile based access and db abstraction + ## [3.202308.1] - 2023-08-25 **Changed** diff --git a/bin/cds.js b/bin/cds.js index 7719735..6ac4f71 100644 --- a/bin/cds.js +++ b/bin/cds.js @@ -1,4 +1,3 @@ -// @ts-check import * as base from '../utils/base.js' import * as dbInspect from '../utils/dbInspect.js' //import * as conn from '../utils/connections.js' diff --git a/types/bin/index.d.ts b/types/bin/index.d.ts index e1c0bc2..c20c9f6 100644 --- a/types/bin/index.d.ts +++ b/types/bin/index.d.ts @@ -1 +1 @@ -export function init(): Promise<(typeof import("./containers.js") | typeof import("./dataTypes.js") | typeof import("./featureUsage.js") | typeof import("./functions.js") | typeof import("./hanaCloudHDIInstances.js") | typeof import("./indexes.js") | typeof import("./inspectTable.js") | typeof import("./querySimple.js") | typeof import("./hanaCloudSBSSInstances.js") | typeof import("./schemas.js") | typeof import("./hanaCloudSchemaInstances.js") | typeof import("./hanaCloudSecureStoreInstances.js") | typeof import("./tables.js") | typeof import("./hanaCloudUPSInstances.js") | typeof import("./version.js") | typeof import("./activateHDI.js") | typeof import("./adminHDI.js") | typeof import("./adminHDIGroup.js") | typeof import("./callProcedure.js") | typeof import("./certificates.js") | typeof import("./cds.js") | typeof import("./openChangeLog.js") | typeof import("./changeLog.js") | typeof import("./changeLogUI.js") | typeof import("./connect.js") | typeof import("./containersUI.js") | typeof import("./copy2DefaultEnv.js") | typeof import("./copy2Env.js") | typeof import("./copy2Secrets.js") | typeof import("./createContainer.js") | typeof import("./createGroup.js") | typeof import("./createContainerUsers.js") | typeof import("./createJWT.js") | typeof import("./createModule.js") | typeof import("./createXSAAdmin.js") | typeof import("./dataTypesUI.js") | typeof import("./dataVolumes.js") | typeof import("./disks.js") | typeof import("./dropContainer.js") | typeof import("./dropGroup.js") | typeof import("./features.js") | typeof import("./featuresUI.js") | typeof import("./featureUsageUI.js") | typeof import("./functionsUI.js") | typeof import("./hanaCloudHDIInstancesUI.js") | typeof import("./hanaCloudInstances.js") | typeof import("./hanaCloudStart.js") | typeof import("./hanaCloudStop.js") | typeof import("./hdbsql.js") | typeof import("./hostInformation.js") | typeof import("./indexesUI.js") | typeof import("./iniContents.js") | typeof import("./iniFiles.js") | typeof import("./inspectFunction.js") | typeof import("./inspectIndex.js") | typeof import("./inspectJWT.js") | typeof import("./inspectLibMember.js") | typeof import("./inspectLibrary.js") | typeof import("./inspectProcedure.js") | typeof import("./inspectTableUI.js") | typeof import("./inspectTrigger.js") | typeof import("./inspectUser.js") | typeof import("./inspectView.js") | typeof import("./libraries.js") | typeof import("./massConvert.js") | typeof import("./massConvertUI.js") | typeof import("./massRename.js") | typeof import("./massUsers.js") | typeof import("./matrix.js") | typeof import("./objects.js") | typeof import("./openBAS.js") | typeof import("./openDBExplorer.js") | typeof import("./ports.js") | typeof import("./privilegeError.js") | typeof import("./procedures.js") | typeof import("./querySimpleUI.js") | typeof import("./readMe.js") | typeof import("./readMeUI.js") | typeof import("./openReadMe.js") | typeof import("./reclaim.js") | typeof import("./rick.js") | typeof import("./roles.js") | typeof import("./hanaCloudSBSSInstancesUI.js") | typeof import("./schemasUI.js") | typeof import("./hanaCloudSchemaInstancesUI.js") | typeof import("./hanaCloudSecureStoreInstancesUI.js") | typeof import("./connectViaServiceKey.js") | typeof import("./sequences.js") | typeof import("./status.js") | typeof import("./synonyms.js") | typeof import("./systemInfo.js") | typeof import("./systemInfoUI.js") | typeof import("./tablesUI.js") | typeof import("./traces.js") | typeof import("./traceContents.js") | typeof import("./triggers.js") | typeof import("./UI.js") | typeof import("./hanaCloudUPSInstancesUI.js") | typeof import("./users.js") | typeof import("./views.js") | typeof import("./btp.js") | typeof import("./btpSubs.js") | typeof import("./btpInfo.js") | typeof import("./issue.js"))[]>; +export function init(): Promise<(typeof import("./containers.js") | typeof import("./dataTypes.js") | typeof import("./featureUsage.js") | typeof import("./functions.js") | typeof import("./hanaCloudHDIInstances.js") | typeof import("./indexes.js") | typeof import("./inspectTable.js") | typeof import("./querySimple.js") | typeof import("./hanaCloudSBSSInstances.js") | typeof import("./schemas.js") | typeof import("./hanaCloudSchemaInstances.js") | typeof import("./hanaCloudSecureStoreInstances.js") | typeof import("./tables.js") | typeof import("./tablesPG.js") | typeof import("./tablesSQLite.js") | typeof import("./hanaCloudUPSInstances.js") | typeof import("./version.js") | typeof import("./activateHDI.js") | typeof import("./adminHDI.js") | typeof import("./adminHDIGroup.js") | typeof import("./callProcedure.js") | typeof import("./certificates.js") | typeof import("./cds.js") | typeof import("./openChangeLog.js") | typeof import("./changeLog.js") | typeof import("./changeLogUI.js") | typeof import("./connect.js") | typeof import("./containersUI.js") | typeof import("./copy2DefaultEnv.js") | typeof import("./copy2Env.js") | typeof import("./copy2Secrets.js") | typeof import("./createContainer.js") | typeof import("./createGroup.js") | typeof import("./createContainerUsers.js") | typeof import("./createJWT.js") | typeof import("./createModule.js") | typeof import("./createXSAAdmin.js") | typeof import("./dataTypesUI.js") | typeof import("./dataVolumes.js") | typeof import("./disks.js") | typeof import("./dropContainer.js") | typeof import("./dropGroup.js") | typeof import("./features.js") | typeof import("./featuresUI.js") | typeof import("./featureUsageUI.js") | typeof import("./functionsUI.js") | typeof import("./hanaCloudHDIInstancesUI.js") | typeof import("./hanaCloudInstances.js") | typeof import("./hanaCloudStart.js") | typeof import("./hanaCloudStop.js") | typeof import("./hdbsql.js") | typeof import("./hostInformation.js") | typeof import("./indexesUI.js") | typeof import("./iniContents.js") | typeof import("./iniFiles.js") | typeof import("./inspectFunction.js") | typeof import("./inspectIndex.js") | typeof import("./inspectJWT.js") | typeof import("./inspectLibMember.js") | typeof import("./inspectLibrary.js") | typeof import("./inspectProcedure.js") | typeof import("./inspectTableUI.js") | typeof import("./inspectTrigger.js") | typeof import("./inspectUser.js") | typeof import("./inspectView.js") | typeof import("./libraries.js") | typeof import("./massConvert.js") | typeof import("./massConvertUI.js") | typeof import("./massRename.js") | typeof import("./massUsers.js") | typeof import("./matrix.js") | typeof import("./objects.js") | typeof import("./openBAS.js") | typeof import("./openDBExplorer.js") | typeof import("./ports.js") | typeof import("./privilegeError.js") | typeof import("./procedures.js") | typeof import("./querySimpleUI.js") | typeof import("./readMe.js") | typeof import("./readMeUI.js") | typeof import("./openReadMe.js") | typeof import("./reclaim.js") | typeof import("./rick.js") | typeof import("./roles.js") | typeof import("./hanaCloudSBSSInstancesUI.js") | typeof import("./schemasUI.js") | typeof import("./hanaCloudSchemaInstancesUI.js") | typeof import("./hanaCloudSecureStoreInstancesUI.js") | typeof import("./connectViaServiceKey.js") | typeof import("./sequences.js") | typeof import("./status.js") | typeof import("./synonyms.js") | typeof import("./systemInfo.js") | typeof import("./systemInfoUI.js") | typeof import("./tablesUI.js") | typeof import("./traces.js") | typeof import("./traceContents.js") | typeof import("./triggers.js") | typeof import("./UI.js") | typeof import("./hanaCloudUPSInstancesUI.js") | typeof import("./users.js") | typeof import("./views.js") | typeof import("./btp.js") | typeof import("./btpSubs.js") | typeof import("./btpInfo.js") | typeof import("./issue.js"))[]>; diff --git a/types/bin/inspectView.d.ts b/types/bin/inspectView.d.ts index fc5c6f5..ed4a03d 100644 --- a/types/bin/inspectView.d.ts +++ b/types/bin/inspectView.d.ts @@ -1,6 +1,7 @@ export function handler(argv: any): void; export function viewInspect(prompts: any): Promise<{ basic: any; + parameters: any; fields: any; sql: string; cds: string; diff --git a/types/bin/querySimple.d.ts b/types/bin/querySimple.d.ts index 2077462..10465a6 100644 --- a/types/bin/querySimple.d.ts +++ b/types/bin/querySimple.d.ts @@ -36,4 +36,14 @@ export namespace inputPrompts { let required_3: boolean; export { required_3 as required }; } + namespace profile { + let description_4: string; + export { description_4 as description }; + let type_4: string; + export { type_4 as type }; + let required_4: boolean; + export { required_4 as required }; + export function ask_1(): void; + export { ask_1 as ask }; + } } diff --git a/types/bin/tables.d.ts b/types/bin/tables.d.ts index a70904b..44e7042 100644 --- a/types/bin/tables.d.ts +++ b/types/bin/tables.d.ts @@ -1,5 +1,10 @@ -export function handler(argv: any): void; -export function getTables(prompts: any): Promise; +export function handler(argv: any): Promise; +export function getTables(prompts: any): Promise<{ + SCHEMA_NAME?: string; + TABLE_NAME: string; + TABLE_OID?: string; + COMMENTS?: string; +}[]>; export const command: "tables [schema] [table]"; export const aliases: string[]; export const describe: string; @@ -26,4 +31,13 @@ export namespace inputPrompts { let required_2: boolean; export { required_2 as required }; } + namespace profile { + let description_3: string; + export { description_3 as description }; + let type_3: string; + export { type_3 as type }; + let required_3: boolean; + export { required_3 as required }; + export function ask(): void; + } } diff --git a/types/bin/tablesPG.d.ts b/types/bin/tablesPG.d.ts new file mode 100644 index 0000000..cecaa2b --- /dev/null +++ b/types/bin/tablesPG.d.ts @@ -0,0 +1,28 @@ +export function handler(argv: any): void; +export const command: "tablesPG [schema] [table]"; +export const aliases: string[]; +export const describe: string; +export const builder: import("yargs").CommandBuilder<{}, {}>; +export namespace inputPrompts { + namespace table { + let description: string; + let type: string; + let required: boolean; + } + namespace schema { + let description_1: string; + export { description_1 as description }; + let type_1: string; + export { type_1 as type }; + let required_1: boolean; + export { required_1 as required }; + } + namespace profile { + let description_2: string; + export { description_2 as description }; + let type_2: string; + export { type_2 as type }; + let required_2: boolean; + export { required_2 as required }; + } +} diff --git a/types/bin/tablesSQLite.d.ts b/types/bin/tablesSQLite.d.ts new file mode 100644 index 0000000..1566c68 --- /dev/null +++ b/types/bin/tablesSQLite.d.ts @@ -0,0 +1,20 @@ +export function handler(argv: any): void; +export const command: "tablesSQLite [table]"; +export const aliases: string[]; +export const describe: string; +export const builder: import("yargs").CommandBuilder<{}, {}>; +export namespace inputPrompts { + namespace table { + let description: string; + let type: string; + let required: boolean; + } + namespace profile { + let description_1: string; + export { description_1 as description }; + let type_1: string; + export { type_1 as type }; + let required_1: boolean; + export { required_1 as required }; + } +} diff --git a/types/utils/database/hanaCDS.d.ts b/types/utils/database/hanaCDS.d.ts new file mode 100644 index 0000000..a0bc2b4 --- /dev/null +++ b/types/utils/database/hanaCDS.d.ts @@ -0,0 +1,6 @@ +export default class _default extends DBClientClass { + constructor(prompts: any, optionsCDS: any); + listTables(): Promise; + #private; +} +import DBClientClass from "./index.js"; diff --git a/types/utils/database/hanaDirect.d.ts b/types/utils/database/hanaDirect.d.ts new file mode 100644 index 0000000..b86d41d --- /dev/null +++ b/types/utils/database/hanaDirect.d.ts @@ -0,0 +1,8 @@ +export default class _default extends DBClientClass { + constructor(prompts: any); + connect(): Promise; + listTables(): Promise; + execSQL(query: any): Promise; + #private; +} +import DBClientClass from "./index.js"; diff --git a/types/utils/database/index.d.ts b/types/utils/database/index.d.ts new file mode 100644 index 0000000..ffe97cd --- /dev/null +++ b/types/utils/database/index.d.ts @@ -0,0 +1,95 @@ +/** + * Database Client Abstract Super Class + * @class + * @constructor + * @public + * @classdesc Database Client Abstract Level + */ +export default class dbClientClass { + /** + * Static Factory Method to initialize the DB Client in your selected Flavor + * @param {object} prompts - processed input prompts + * @returns {Promise} childClass - flavor specific DB client class instance + */ + static getNewClient(prompts: object): Promise; + /** + * Create an instance of the database client specific to the prompt profile + * @param {typeof import("prompt")} prompts - input prompts current value + */ + constructor(prompts: any, optionsCDS: any); + /** + * Connect to the target database + * @returns {Promise} cds connection object + */ + connect(): Promise; + /** + * Disconnect from the target database + */ + disconnect(): void; + /** + * Connect to the target database and set a specific Schema + * @param {String} schema - Database Schema name + * @returns {Promise} cds connection object + */ + connectTargetSchema(schema: string): Promise; + /** + * Database specific wildcard handling + * @param {String} input - database object name that needs wildcard handling + */ + adjustWildcard(input: string): string; + /** + * TableData as JSON + * @typedef {Object} TableLine + * @property {String} [SCHEMA_NAME] + * @property {String} TABLE_NAME + * @property {String} [TABLE_OID] + * @property {String} [COMMENTS] + */ + /** + * TableData as JSON + * @typedef {Array.} TableData + */ + /** + * return a list of database tables + * @returns {Promise} table of database tables + */ + listTables(): Promise<{ + SCHEMA_NAME?: string; + TABLE_NAME: string; + TABLE_OID?: string; + COMMENTS?: string; + }[]>; + /** + * Execute single SQL Statement and directly return result set + * @param {string} sql - SQL Statement + * @returns {Promise} - result set object + */ + execSQL(query: any): Promise; + /** + * Getter for Prompts Private Attribute + * @returns {typeof import("prompt")} prompts - input prompts current value + */ + getPrompts(): any; + /** + * Getter for CDS or HDB database object Private Attribute + * @returns @type {Object} + */ + getDB(): any; + /** + * Getter for database kind/flavor Private Attribute + * @returns @type {String} Database Kind / Flavor + */ + getKind(): any; + /** + * Setter for CDS or HDB database object Private Attribute + * @param @type {Object} db + */ + setDB(db: any): void; + /** + * From Input parameters, calculate the schema that should be used for the rest of this operation + * @param @type {typeof import("prompt")} prompts - input prompts current value + * @param @type {Object} optionsCDS - CDS based Connection Options + */ + schemaCalculation(prompts: any, optionsCDS: any): string; + #private; +} diff --git a/types/utils/database/postgres.d.ts b/types/utils/database/postgres.d.ts new file mode 100644 index 0000000..a0bc2b4 --- /dev/null +++ b/types/utils/database/postgres.d.ts @@ -0,0 +1,6 @@ +export default class _default extends DBClientClass { + constructor(prompts: any, optionsCDS: any); + listTables(): Promise; + #private; +} +import DBClientClass from "./index.js"; diff --git a/types/utils/database/sqlite.d.ts b/types/utils/database/sqlite.d.ts new file mode 100644 index 0000000..a0bc2b4 --- /dev/null +++ b/types/utils/database/sqlite.d.ts @@ -0,0 +1,6 @@ +export default class _default extends DBClientClass { + constructor(prompts: any, optionsCDS: any); + listTables(): Promise; + #private; +} +import DBClientClass from "./index.js"; diff --git a/types/utils/dbInspect.d.ts b/types/utils/dbInspect.d.ts index 9fa7fb1..31a9b02 100644 --- a/types/utils/dbInspect.d.ts +++ b/types/utils/dbInspect.d.ts @@ -44,6 +44,22 @@ export function getCalcViewFields(db: object, schema: string, viewId: string, vi * @returns {Promise} */ export function getViewFields(db: object, viewOid: string): Promise; +/** + * Get View Parameters and Metadata + * @param {object} db - Database Connection + * @param {string} schema - Schema + * @param {string} viewId - View Unique ID + * @param {string} viewOid - View Unique ID + * @returns {Promise} + */ +export function getCalcViewParameters(db: object, schema: string, viewId: string, viewOid: string): Promise; +/** + * Get View Parameters and Metadata + * @param {object} db - Database Connection + * @param {string} viewOid - View Unique ID + * @returns {Promise} + */ +export function getViewParameters(db: object, viewOid: string): Promise; /** * Get DB Table Details * @param {object} db - Database Connection @@ -114,9 +130,10 @@ export function getFunctionPramCols(db: object, funcOid: string): Promise} */ -export function formatCDS(db: object, object: object, fields: object, constraints: object, type: string, schema?: string, parent?: string): Promise; +export function formatCDS(db: object, object: object, fields: object, constraints: object, type: string, schema?: string, parent?: string, parameters?: object): Promise; /** * Get Geo Columns requires special lookup and details * @param {object} db - Database Connection