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

radweb-server-postgres

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radweb-server-postgres - npm Package Compare versions

Comparing version 1.0.4 to 3.0.1

index.d.ts

6

package.json
{
"name": "radweb-server-postgres",
"version": "1.0.4",
"main":"PostgresDataProvider.js",
"version": "3.0.1",
"main":"index.js",
"Dependencies": {
"pg": "^7.6.1"
}
}

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

import { DataProviderFactory, DataProvider, Entity, Column } from 'radweb';
import { DataProviderFactory, DataProvider, Entity, Column, SQLCommand } from 'radweb';
import { Pool } from 'pg';

@@ -8,5 +8,7 @@ export declare class PostgresDataProvider implements DataProviderFactory {

doInTransaction(what: (dp: DataProviderFactory) => Promise<void>): Promise<void>;
createDirectSQLCommand(): SQLCommand;
}
export declare class PostgrestSchemaBuilder {
private pool;
verifyStructureOfAllEntities(): Promise<void>;
CreateIfNotExist(e: Entity<any>): Promise<void>;

@@ -13,0 +15,0 @@ private addColumnSqlSyntax;

@@ -84,2 +84,5 @@ "use strict";

};
PostgresDataProvider.prototype.createDirectSQLCommand = function () {
return new PostgrestBridgeToSQLCommand(this.pool);
};
return PostgresDataProvider;

@@ -95,2 +98,5 @@ }());

};
PostgresDataTransaction.prototype.createDirectSQLCommand = function () {
return new PostgrestBridgeToSQLCommand(this.source);
};
return PostgresDataTransaction;

@@ -126,2 +132,5 @@ }());

}
PostgressBridgeToSQLQueryResult.prototype.getcolumnNameAtIndex = function (index) {
return this.r.fields[index].name;
};
PostgressBridgeToSQLQueryResult.prototype.getColumnIndex = function (name) {

@@ -140,2 +149,40 @@ for (var i = 0; i < this.r.fields.length; i++) {

}
PostgrestSchemaBuilder.prototype.verifyStructureOfAllEntities = function () {
return __awaiter(this, void 0, void 0, function () {
var context, _i, allEntities_1, entity, x, err_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log("start verify structure");
context = new radweb_1.ServerContext();
_i = 0, allEntities_1 = radweb_1.allEntities;
_a.label = 1;
case 1:
if (!(_i < allEntities_1.length)) return [3 /*break*/, 8];
entity = allEntities_1[_i];
x = context.for(entity).create();
_a.label = 2;
case 2:
_a.trys.push([2, 6, , 7]);
if (!(x.__getDbName().toLowerCase().indexOf('from ') < 0)) return [3 /*break*/, 5];
return [4 /*yield*/, this.CreateIfNotExist(x)];
case 3:
_a.sent();
return [4 /*yield*/, this.verifyAllColumns(x)];
case 4:
_a.sent();
_a.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
err_2 = _a.sent();
console.log("failed verify structore of " + x.__getDbName() + " ", err_2);
return [3 /*break*/, 7];
case 7:
_i++;
return [3 /*break*/, 1];
case 8: return [2 /*return*/];
}
});
});
};
PostgrestSchemaBuilder.prototype.CreateIfNotExist = function (e) {

@@ -147,3 +194,3 @@ return __awaiter(this, void 0, void 0, function () {

case 0: return [4 /*yield*/, this.pool.query("select 1 from information_Schema.tables where table_name=$1", [e.__getDbName().toLowerCase()]).then(function (r) { return __awaiter(_this, void 0, void 0, function () {
var result_1;
var result_1, sql;
var _this = this;

@@ -165,3 +212,5 @@ return __generator(this, function (_a) {

});
return [4 /*yield*/, this.pool.query('create table ' + e.__getDbName() + ' (' + result_1 + '\r\n)')];
sql = 'create table ' + e.__getDbName() + ' (' + result_1 + '\r\n)';
console.log(sql);
return [4 /*yield*/, this.pool.query(sql)];
case 1:

@@ -204,3 +253,3 @@ _a.sent();

return __awaiter(this, void 0, void 0, function () {
var sql, err_2;
var sql, err_3;
return __generator(this, function (_a) {

@@ -219,2 +268,3 @@ switch (_a.label) {

sql = "alter table " + e.__getDbName() + " add column " + this.addColumnSqlSyntax(c(e));
console.log(sql);
return [4 /*yield*/, this.pool.query(sql)];

@@ -226,4 +276,4 @@ case 3:

case 5:
err_2 = _a.sent();
console.log(err_2);
err_3 = _a.sent();
console.log(err_3);
return [3 /*break*/, 6];

@@ -230,0 +280,0 @@ case 6: return [2 /*return*/];

Sorry, the diff of this file is not supported yet

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