Socket
Socket
Sign inDemoInstall

@sap/hdi

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/hdi - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

lib/main/promises/ContainerGroupPromises.js

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## 4.2.0
Features:
- hana-client 2.10.x support
- added APIs `getDefaultContainerRoleAdminPrivileges`, `getDefaultCommonPrivileges` and `grant/revokeDISupportPrivilege` to HDI-API
- added APIs `import/exportContainerForCopy` and `getDependencies` to Container-API
- added APIs `import/exportContainerForCopy`, `grant/revokeContainerSupportPrivileges`, `getDefaultContainerRoleAdminPrivileges`, `getDefaultCommonPrivileges` and `enable/disableContainerUser` to ContainerGroup-API
## 4.1.0

@@ -2,0 +9,0 @@ Features:

@@ -27,2 +27,6 @@ 'use strict';

const HDIPromises = require('./lib/main/promises/HDIPromises');
const ContainerGroupPromises = require('./lib/main/promises/ContainerGroupPromises');
const ContainerPromises = require('./lib/main/promises/ContainerPromises');
module.exports = {

@@ -32,2 +36,7 @@ HDI,

Container,
promises: {
HDI: HDIPromises,
ContainerGroup: ContainerGroupPromises,
Container: ContainerPromises
},
ResultTuple,

@@ -34,0 +43,0 @@ DependencyResultTuple,

54

lib/main/Container.js

@@ -147,3 +147,3 @@ 'use strict';

this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params, this.lock_connection, new Set()),
this.executeCall(sql, null, {}, this.lock_connection)
this.executeCall(sql, null, null, {}, this.lock_connection)
], (e, r) => {

@@ -164,2 +164,54 @@ if (e){

exportContainerForCopy(tableName, tableSchema, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'EXPORT_CONTAINER_FOR_COPY';
const sql = `call ${this.apiSchema}.${command} ('${tableSchema}', '${tableName}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?);`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
importContainerForCopy(tableName, tableSchema, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'IMPORT_CONTAINER_FOR_COPY';
const sql = `call ${this.apiSchema}.${command} ('${tableSchema}', '${tableName}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?);`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**

@@ -166,0 +218,0 @@ * Configures a container with the given configuration parameters and the given parameters.

@@ -269,3 +269,79 @@ 'use strict';

/**
* Grants the given privileges on the container's API objects to the given users.
* Exports the container with the given container-id, incl. all corresponding schemata, tables, etc.
* NOTE: The table must be created before calling this function. Furthermore, the [containerName]#DI user must be granted SELECT and INSERT privileges on the specified table.
* Requires EXECUTE privilege on EXPORT_CONTAINER_FOR_COPY
* @param {string} container container name for the exported files to be placed in
* @param {string} tableName table name for the exported files to be placed in
* @param {string} tableSchema schema of the specified table
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
exportContainerForCopy(container, tableName, tableSchema, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'EXPORT_CONTAINER_FOR_COPY';
const sql = `call ${this.apiSchema}.${command} ('${container}','${tableSchema}', '${tableName}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?);`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Imports the container with the given container-id, incl. all corresponding schemata, tables, etc.
* NOTE: The table must be created before calling this function. Furthermore, the [containerName]#DI user must be granted SELECT privileges on the specified table.
* Requires EXECUTE privilege on IMPORT_CONTAINER_FOR_COPY
* @param {string} container container name for the exported files to be placed in
* @param {string} tableName table name for the exported files to be placed in
* @param {string} tableSchema schema of the specified table
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
importContainerForCopy(container, tableName, tableSchema, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'IMPORT_CONTAINER_FOR_COPY';
const sql = `call ${this.apiSchema}.${command} ('${container}','${tableSchema}', '${tableName}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?);`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Grants the given privilege on the container's API objects to the given users.
* Requires EXECUTE privilege on GRANT_CONTAINER_API_PRIVILEGES

@@ -539,2 +615,148 @@ * @param {string} container the affected container.

/**
* Grants the given privilege on the container's metadata schemas to the given principal (user or role); for support use cases only.
* Requires EXECUTE privilege on GRANT_CONTAINER_SUPPORT_PRIVILEGE
* @param {string} container the affected container.
* @param {string} principal name of the target user/role
* @param {string} privilege the schema privilege to grant
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
grantContainerSupportPrivilege(container, privilege, principal, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'GRANT_CONTAINER_SUPPORT_PRIVILEGE';
const sql = `call ${this.apiSchema}.${command}('${container}','${privilege}','${principal}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Revokes the given privilege on the container's metadata schemas to the given principal (user or role); for support use cases only.
* Requires EXECUTE privilege on REVOKE_CONTAINER_SUPPORT_PRIVILEGE
* @param {string} container the affected container.
* @param {string} principal name of the target user/role
* @param {string} privilege the schema privilege to grant
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
revokeContainerSupportPrivilege(container, privilege, principal, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'REVOKE_CONTAINER_SUPPORT_PRIVILEGE';
const sql = `call ${this.apiSchema}.${command}('${container}','${privilege}','${principal}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Disables the specified container user after it has been enabled by a call to ENABLE_CONTAINER_USER.
* Requires EXECUTE privilege on DISABLE_CONTAINER_USER
* @param {string} containerUser the affected container user.
* @param {Parameter[]} params parameters controlling the current procedure call
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
disableContainerUser(containerUser, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'DISABLE_CONTAINER_USER';
const sql = `call ${this.apiSchema}.${command}('${containerUser}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql,null, this.password)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Enables the specified container user so it can be used for accessing a container for support purposes.
* Requires EXECUTE privilege on ENABLE_CONTAINER_USER
* @param {string} containerUser the affected container user.
* @param {Parameter[]} params parameters controlling the current procedure call
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
enableContainerUser(containerUser, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'ENABLE_CONTAINER_USER';
const sql = `call ${this.apiSchema}.${command}('${containerUser}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql,null, this.password)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Returns the default privileges required for administration of a container group

@@ -567,2 +789,2 @@ * Requires SELECT privilege on _SYS_DI.T_DEFAULT_CONTAINER_GROUP_ADMIN_PRIVILEGES

}
module.exports = ContainerGroupBase;
module.exports = ContainerGroupBase;

@@ -337,2 +337,75 @@ 'use strict';

/**
* Grants the given privilege on the _SYS_DI schema to the given principal (user or role); for support use cases only.
* Requires EXECUTE privilege on GRANT_DI_SUPPORT_PRIVILEGE
* @param {string} privilege to grant
* @param {string} principal name of the target user/role
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
grantDISupportPrivilege(privilege, principal, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'GRANT_DI_SUPPORT_PRIVILEGE';
const sql = `call ${this.apiSchema}.${command}('${privilege}','${principal}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Revokes the given privilege on the _SYS_DI schema from the given principal (user or role); for support use cases only.
* Requires EXECUTE privilege on REVOKE_DI_SUPPORT_PRIVILEGE
* @param {string} privilege to grant
* @param {string} principal name of the target user/role
* @param {Parameter[]} params parameters controlling the current procedure call
* @param {ResultTupleCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
revokeDISupportPrivilege(privilege, principal, params, cb) {
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
try {
typeCheck(params, 'params', Parameter);
} catch (error) {
return callback(error);
}
const command = 'REVOKE_DI_SUPPORT_PRIVILEGE';
const sql = `call ${this.apiSchema}.${command}('${privilege}','${principal}', ${this.paramSchema}.${CONSTANTS.PARAMETERS_TABLE}, ?, ?, ?)`;
async.series([
this.fillHelperTable(CONSTANTS.PARAMETERS_TABLE, params),
this.executeCall(sql)
], series_callback(callback));
};
if (cb){
return fn(cb);
} else {
return wrap(fn);
}
}
/**
* Returns the default privileges required for general HDI administration

@@ -364,2 +437,2 @@ * Requires SELECT privilege on _SYS_DI.T_DEFAULT_DI_ADMIN_PRIVILEGES

}
module.exports = HDI;
module.exports = HDI;

@@ -41,3 +41,10 @@ 'use strict';

this.apiSchema = quote_sql_identifier(apiSchema);
/**
* password that need to bound while using API enable/ disable container User
*
* @name HDIBase#password
*/
this.password = credentials.password;
/**
* Connection to the HANA database.

@@ -201,2 +208,3 @@ * @name HDIBase#connection

* @param {ResultTuple} result An instance of type ResultTuple or a class extending ResultTuple. Contains the result of the procedure call.
* @package {string} password password that need to be bound while enabling or disabling container user
* @param {TableRow[]} sqlParams Parameters for the procedure call. Array of objects of type TableRow or a class extending TableRow.

@@ -207,3 +215,3 @@ * @param {Connection} connection Optional db connection. Default is local object connection.

*/
executeCall(sqlStmt, result = null, sqlParams = {}, connection = this.connection) {
executeCall(sqlStmt, result = null, password = null, sqlParams = {}, connection = this.connection) {
/**

@@ -232,6 +240,9 @@ * Prepares an sql statement.

*/
function fillResult(parameters, messages, results, result){
function fillResult(parameters, messages, password, results, result){
result.rc = parameters.RETURN_CODE;
result.requestId = parameters.REQUEST_ID;
result.messages = messages;
if (password !== null) {
result.password = password;
}
result.fillResultFromResultSet((typeof results !== 'undefined') ? results : []);

@@ -248,3 +259,3 @@ return result;

*/
function execute(parameters, result) {
function execute(parameters, result, password) {
return function(preparedStatement, callback){

@@ -256,3 +267,3 @@ preparedStatement.exec(parameters, (err, parameters, messages, results) => {

} else {
return callback(null, fillResult(parameters, messages, results, result));
return callback(null, fillResult(parameters, messages, password, results, result));
}

@@ -269,3 +280,3 @@ });

prepare(connection, sqlStmt),
execute(sqlParams, result)
execute(sqlParams, result, password)
], callback);

@@ -275,2 +286,3 @@ };

/* eslint-enable no-shadow */

@@ -306,2 +318,56 @@ /**

/**
* Returns the default privileges required for role administration of a container
* Requires SELECT privilege on _SYS_DI.T_DEFAULT_CONTAINER_ROLE_ADMIN_PRIVILEGES
* Requires DI.API version greater or equal 15 (OP) or greater or equal 1001 (CE)
* @param {string} principalSchema schema of the target user/role (empty for global principals)
* @param {string} principalName name of the target user/role
* @param {APIPrivilegesCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
getDefaultContainerRoleAdminPrivileges(principalSchema, principalName, cb) {
const sql = `select PRIVILEGE_NAME, OBJECT_NAME from ${CONSTANTS.DEFAULT_CONTAINER_ROLE_ADMIN_TABLE}`;
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
this.getAPIPrivileges(sql, principalSchema, principalName, callback);
};
if (cb){
fn(cb);
} else {
return wrap(fn);
}
}
/**
* Returns the default common privileges required for working with HDI
* Requires SELECT privilege on _SYS_DI.T_DEFAULT_COMMON_PRIVILEGES
* @param {string} principalSchema schema of the target user/role (empty for global principals)
* @param {string} principalName name of the target user/role
* @param {APIPrivilegesCB} [cb] - The callback handling the result. If not supplied, a function taking a callback as the first parameter will be returned.
* @returns {Function | undefined} If no callback was supplied, returns a function taking a callback as the first parameter. Otherwise returns undefined.
* @async
*/
getDefaultCommonPrivileges(principalSchema, principalName, cb) {
const sql = `select PRIVILEGE_NAME, OBJECT_NAME from ${CONSTANTS.DI_DEFAULT_COMMON_PRIVILEGES}`;
/**
* Function wrapped for async
* @param {Function} callback Callback Function
* @returns {undefined}
*/
const fn = (callback) => {
this.getAPIPrivileges(sql, principalSchema, principalName, callback);
};
if (cb){
fn(cb);
} else {
return wrap(fn);
}
}
/**
* Returns the default privileges required for administration of a container

@@ -308,0 +374,0 @@ * Requires SELECT privilege on _SYS_DI.T_DEFAULT_CONTAINER_ADMIN_PRIVILEGES

@@ -30,3 +30,5 @@ 'use strict';

this.DI_DEFAULT_COMMON_PRIVILEGES = `${this.SYS_DI_SCHEMA }.T_DEFAULT_COMMON_PRIVILEGES`;
this.DI_ADMIN_PRIVILEGES_TABLE = `${this.SYS_DI_SCHEMA }.T_DEFAULT_DI_ADMIN_PRIVILEGES`;
this.DEFAULT_CONTAINER_ROLE_ADMIN_TABLE = `${this.SYS_DI_SCHEMA }.T_DEFAULT_CONTAINER_ROLE_ADMIN_PRIVILEGES`;
this.GROUP_ADMIN_PRIVILEGES_TABLE = `${this.SYS_DI_SCHEMA }.T_DEFAULT_CONTAINER_GROUP_ADMIN_PRIVILEGES`;

@@ -33,0 +35,0 @@ this.CONTAINER_ADMIN_PRIVILEGES_TABLE = `${this.SYS_DI_SCHEMA }.T_DEFAULT_CONTAINER_ADMIN_PRIVILEGES`;

2

npm-shrinkwrap.json
{
"name": "@sap/hdi",
"version": "4.1.0",
"version": "4.2.0",
"lockfileVersion": 1,

@@ -5,0 +5,0 @@ "requires": true,

{
"name": "@sap/hdi",
"description": "HDI client library for node.js",
"version": "4.1.0",
"version": "4.2.0",
"license": "See LICENSE file",

@@ -14,3 +14,3 @@ "repository": {

"peerDependencies": {
"@sap/hana-client": "2.7.x || 2.8.x || 2.9.x"
"@sap/hana-client": "2.7.x || 2.8.x || 2.9.x || 2.10.x"
},

@@ -17,0 +17,0 @@ "engines": {

@@ -16,3 +16,3 @@ @sap/hdi

Note : @sap/hana-client must be installed by yourself. Version 2.7.x , 2.8.x and 2.9.x are currently supported by @sap/hdi 4.1.0.
Note: @sap/hana-client must be installed by yourself. Version 2.7.x, 2.8.x, 2.9.x and 2.10.x are currently supported by @sap/hdi 4.2.0.
To install the latest @sap/hana-client simply run `npm install @sap/hana-client`.

@@ -19,0 +19,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc