Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rds-data

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rds-data - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

4

lib/index.d.ts

@@ -1,2 +0,2 @@

export { RDSData } from "./RDSData";
export { default as RDSDatabase } from "./RDSDatabase";
export { RDSData } from './RDSData';
export { default as RDSDatabase } from './RDSDatabase';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RDSData_1 = require("./RDSData");
exports.RDSData = RDSData_1.RDSData;
Object.defineProperty(exports, "RDSData", { enumerable: true, get: function () { return RDSData_1.RDSData; } });
var RDSDatabase_1 = require("./RDSDatabase");
exports.RDSDatabase = RDSDatabase_1.default;
Object.defineProperty(exports, "RDSDatabase", { enumerable: true, get: function () { return RDSDatabase_1.default; } });

@@ -13,4 +13,10 @@ /// <reference types="node" />

}
export declare type RDSDataTypes = "stringValue" | "booleanValue" | "longValue" | "isNull" | "blobValue" | undefined;
export declare type RDSDataParameterValue = string | Buffer | boolean | number;
export interface RDSDataType {
name: string;
value: {
[x: string]: string | boolean | Buffer | null;
};
}
export declare type RDSDataTypes = 'stringValue' | 'booleanValue' | 'longValue' | 'isNull' | 'blobValue' | undefined;
export declare type RDSDataParameterValue = string | Buffer | boolean | number | null;
export interface RDSDataParameters {

@@ -40,9 +46,9 @@ [key: string]: RDSDataParameterValue;

export declare class RDSData {
private _rds;
private _config;
private rds;
private config;
constructor(options?: RDSDataOptions);
private getConnection;
query(sql: string, params?: RDSDataParameters, transactionId?: string): Promise<RDSDataResponse>;
private formatParameters;
private resultFormat;
private static formatParameters;
private static resultFormat;
transaction(): Promise<string>;

@@ -49,0 +55,0 @@ commit(transactionId: string): Promise<string>;

@@ -50,24 +50,25 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RDSData = void 0;
var aws_sdk_1 = require("aws-sdk");
var RDSData = /** @class */ (function () {
function RDSData(options) {
this._rds = null;
this._config = {
region: "",
secretArn: "",
resourceArn: "",
database: "",
this.rds = null;
this.config = {
region: '',
secretArn: '',
resourceArn: '',
database: '',
};
if (options) {
this._config = options;
this.config = options;
}
}
RDSData.prototype.getConnection = function () {
if (!this._rds) {
this._rds = new aws_sdk_1.RDSDataService({
apiVersion: "2018-08-01",
region: this._config.region,
if (!this.rds) {
this.rds = new aws_sdk_1.RDSDataService({
apiVersion: '2018-08-01',
region: this.config.region,
});
}
return this._rds;
return this.rds;
};

@@ -79,8 +80,8 @@ RDSData.prototype.query = function (sql, params, transactionId) {

return __generator(this, function (_a) {
parameters = this.formatParameters(params);
parameters = RDSData.formatParameters(params);
return [2 /*return*/, new Promise(function (resolve, reject) {
var queryParameters = {
secretArn: _this._config.secretArn,
resourceArn: _this._config.resourceArn,
database: _this._config.database,
secretArn: _this.config.secretArn,
resourceArn: _this.config.resourceArn,
database: _this.config.database,
includeResultMetadata: true,

@@ -97,3 +98,3 @@ parameters: parameters,

.then(function (response) {
var result = _this.resultFormat(response);
var result = RDSData.resultFormat(response);
resolve(result);

@@ -108,3 +109,3 @@ })

};
RDSData.prototype.formatParameters = function (params) {
RDSData.formatParameters = function (params) {
if (!params) {

@@ -114,13 +115,19 @@ return [];

var getType = function (val) {
return typeof val === "string"
? "stringValue"
: typeof val === "boolean"
? "booleanValue"
: typeof val === "number"
? "longValue"
: val === null
? "isNull"
: Buffer.isBuffer(val)
? "blobValue"
: undefined;
var t = typeof val;
if (t === 'string') {
return 'stringValue';
}
if (t === 'boolean') {
return 'booleanValue';
}
if (t === 'number') {
return 'longValue';
}
if (val === null) {
return 'isNull';
}
if (Buffer.isBuffer(val)) {
return 'blobValue';
}
return undefined;
};

@@ -132,26 +139,28 @@ var formatType = function (name, value, type) {

}
var getValue = function (t) {
if (t === 'isNull') {
return true;
}
if (t === 'blobValue') {
return value;
}
if (t === 'booleanValue') {
return !!value;
}
return (value === null || value === void 0 ? void 0 : value.toString()) || '';
};
return {
name: name,
value: (_a = {},
_a[type] = type === "isNull"
? null
: type === "blobValue"
? value
: type === "booleanValue"
? value
? true
: false
: value.toString(),
_a[type] = getValue(type),
_a),
};
};
var parameters = [];
for (var _i = 0, _a = Object.keys(params); _i < _a.length; _i++) {
var key = _a[_i];
parameters.push(formatType(key, params[key], getType(params[key])));
}
var parameters = Object.keys(params).map(function (key) {
return formatType(key, params[key], getType(params[key]));
});
return parameters;
};
RDSData.prototype.resultFormat = function (response) {
var _a, _b, _c, _d;
RDSData.resultFormat = function (response) {
var _a;
var insertId = response.generatedFields && response.generatedFields.length > 0 ? response.generatedFields[0].longValue : 0;

@@ -164,40 +173,40 @@ var columns = [];

return columns.push({
name: column.label || "",
tableName: column.tableName || "",
type: column.typeName || "",
name: column.label || '',
tableName: column.tableName || '',
type: column.typeName || '',
});
});
for (var _i = 0, _e = response.records; _i < _e.length; _i++) {
var record = _e[_i];
response.records.forEach(function (record) {
var _a, _b, _c;
var row = {};
for (var c = 0; c < record.length; c++) {
for (var c = 0; c < record.length; c += 1) {
/* tslint:disable:no-string-literal */
var isNull = (_b = record[c]["isNull"]) !== null && _b !== void 0 ? _b : false;
var isNull = (_a = record[c].isNull) !== null && _a !== void 0 ? _a : false;
var v = { isNull: isNull };
switch (columns[c].type) {
case "BINARY":
v.buffer = isNull ? undefined : Buffer.from((record[c]["blobValue"] || "").toString());
v.string = isNull ? undefined : (_c = v.buffer) === null || _c === void 0 ? void 0 : _c.toString("base64");
case 'BINARY':
v.buffer = isNull ? undefined : Buffer.from((record[c].blobValue || '').toString());
v.string = isNull ? undefined : (_b = v.buffer) === null || _b === void 0 ? void 0 : _b.toString('base64');
break;
case "BIT":
v.boolean = isNull ? undefined : record[c]["booleanValue"];
case 'BIT':
v.boolean = isNull ? undefined : record[c].booleanValue;
v.number = v.boolean ? 1 : 0;
break;
case "TIMESTAMP":
case "DATETIME":
case "DATE":
v.date = isNull ? undefined : new Date((_d = record[c]["stringValue"]) !== null && _d !== void 0 ? _d : "");
v.string = isNull ? undefined : record[c]["stringValue"];
case 'TIMESTAMP':
case 'DATETIME':
case 'DATE':
v.date = isNull ? undefined : new Date((_c = record[c].stringValue) !== null && _c !== void 0 ? _c : '');
v.string = isNull ? undefined : record[c].stringValue;
v.number = v.date ? v.date.getTime() : 0;
break;
case "INT":
case "INT UNSIGNED":
case "BIGINT":
case "BIGINT UNSIGNED":
v.number = isNull ? undefined : record[c]["longValue"];
case 'INT':
case 'INT UNSIGNED':
case 'BIGINT':
case 'BIGINT UNSIGNED':
v.number = isNull ? undefined : record[c].longValue;
break;
case "TEXT":
case "CHAR":
case "VARCHAR":
v.string = isNull ? undefined : record[c]["stringValue"];
case 'TEXT':
case 'CHAR':
case 'VARCHAR':
v.string = isNull ? undefined : record[c].stringValue;
break;

@@ -211,3 +220,3 @@ default:

data.push(row);
}
});
}

@@ -221,5 +230,5 @@ return { data: data, columns: columns, numberOfRecordsUpdated: numberOfRecordsUpdated, insertId: insertId };

.beginTransaction({
secretArn: _this._config.secretArn,
resourceArn: _this._config.resourceArn,
database: _this._config.database,
secretArn: _this.config.secretArn,
resourceArn: _this.config.resourceArn,
database: _this.config.database,
})

@@ -229,6 +238,6 @@ .promise()

var _a;
resolve((_a = response.transactionId) !== null && _a !== void 0 ? _a : "");
resolve((_a = response.transactionId) !== null && _a !== void 0 ? _a : '');
})
.catch(function () {
reject("");
.catch(function (e) {
reject(e);
});

@@ -242,4 +251,4 @@ });

.commitTransaction({
resourceArn: _this._config.resourceArn,
secretArn: _this._config.secretArn,
resourceArn: _this.config.resourceArn,
secretArn: _this.config.secretArn,
transactionId: transactionId,

@@ -250,6 +259,6 @@ })

var _a;
resolve((_a = response.transactionStatus) !== null && _a !== void 0 ? _a : "");
resolve((_a = response.transactionStatus) !== null && _a !== void 0 ? _a : '');
})
.catch(function () {
reject("");
.catch(function (e) {
reject(e);
});

@@ -263,4 +272,4 @@ });

.rollbackTransaction({
resourceArn: _this._config.resourceArn,
secretArn: _this._config.secretArn,
resourceArn: _this.config.resourceArn,
secretArn: _this.config.secretArn,
transactionId: transactionId,

@@ -271,6 +280,6 @@ })

var _a;
resolve((_a = response.transactionStatus) !== null && _a !== void 0 ? _a : "");
resolve((_a = response.transactionStatus) !== null && _a !== void 0 ? _a : '');
})
.catch(function () {
reject("");
.catch(function (e) {
reject(e);
});

@@ -277,0 +286,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var aws_sdk_1 = require("aws-sdk");
var RDSData_1 = require("./RDSData");
var aws_sdk_1 = require("aws-sdk");
var RDSDatabase = /** @class */ (function () {

@@ -6,0 +6,0 @@ function RDSDatabase(options) {

{
"name": "rds-data",
"version": "1.0.2",
"version": "1.1.0",
"description": "A decorator for the AWS Data API for Aurora Serverless. It decorates and abstracts the Amazon SDK's implementation to make it feel more like a traditional MySQL wrapper than an HTTP based web service. It is written in Typescript and provides type-aware return objects which allows for better support in Typescript-based solutions.",

@@ -12,2 +12,3 @@ "main": "./lib/index.js",

"lint": "tslint -p tsconfig.json",
"eslint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"prepare": "npm run build",

@@ -46,16 +47,28 @@ "prepublishOnly": "npm test && npm run lint",

"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"date-fns": "^2.12.0",
"jest": "^25.3.0",
"prettier": "^2.0.4",
"ts-jest": "^25.4.0",
"tslint": "^6.1.1",
"@types/jest": "^25.2.3",
"@types/node": "^14.0.4",
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"date-fns": "^2.14.0",
"eslint": "^7.0.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-json": "^2.1.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.20.0",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"ts-jest": "^26.0.0",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.8.3",
"typescript": "^3.9.3",
"uuid": "^8.1.0",
"uuid-base58": "^1.0.1"
},
"dependencies": {
"aws-sdk": "^2.657.0"
"aws-sdk": "^2.682.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