@db-auto/environments
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -1,2 +0,2 @@ | ||
import { ErrorsAnd, NameAnd, NameAndValidator } from "@db-auto/utils"; | ||
import { ColumnDefn, ErrorsAnd, NameAnd, NameAndValidator } from "@db-auto/utils"; | ||
import { PostgresEnv } from "@db-auto/postgres"; | ||
@@ -21,1 +21,9 @@ export type Environment = PostgresEnv; | ||
export declare function dalFor(env: Environment): import("@db-auto/dal").Dal; | ||
export interface EnvStatus { | ||
name: string; | ||
up: boolean; | ||
env: CleanEnvironment; | ||
} | ||
export declare function envIsUp(env: CleanEnvironment): Promise<boolean>; | ||
export declare function checkStatus(envs: NameAnd<CleanEnvironment>): Promise<NameAnd<EnvStatus>>; | ||
export declare const statusColDefn: NameAnd<ColumnDefn<EnvStatus>>; |
@@ -25,4 +25,13 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dalFor = exports.sqlDialect = exports.environmentValidator = exports.cleanEnvironment = exports.currentEnvironment = exports.saveEnvName = exports.currentEnvName = void 0; | ||
exports.statusColDefn = exports.checkStatus = exports.envIsUp = exports.dalFor = exports.sqlDialect = exports.environmentValidator = exports.cleanEnvironment = exports.currentEnvironment = exports.saveEnvName = exports.currentEnvName = void 0; | ||
const utils_1 = require("@db-auto/utils"); | ||
@@ -108,1 +117,37 @@ const postgres_1 = require("@db-auto/postgres"); | ||
exports.dalFor = dalFor; | ||
//TODO do in parallel | ||
function envIsUp(env) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let dal = dalFor(env); | ||
try { | ||
const dialect = sqlDialect(env.type); | ||
yield dal.query(dialect.safeQuery); | ||
return true; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
finally { | ||
yield dal.close(); | ||
} | ||
}); | ||
} | ||
exports.envIsUp = envIsUp; | ||
function checkStatus(envs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let result = {}; | ||
for (const [name, env] of Object.entries(envs)) | ||
result[name] = { name, env, up: yield envIsUp(env) }; | ||
return result; | ||
}); | ||
} | ||
exports.checkStatus = checkStatus; | ||
exports.statusColDefn = { | ||
"Environment": { dataFn: (t) => t.name }, | ||
"Type": { dataFn: (t) => t.env.type }, | ||
"Host": { dataFn: (t) => t.env.host }, | ||
"Port": { dataFn: (t) => t.env.port === undefined ? '' : t.env.port.toString() }, | ||
"Database": { dataFn: (t) => t.env.database }, | ||
"UserName": { dataFn: (t) => t.env.username }, | ||
"Up": { dataFn: (t) => t.up.toString() }, | ||
}; |
{ | ||
"name": "@db-auto/environments", | ||
"description": "", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"main": "dist/index", | ||
@@ -20,6 +20,6 @@ "types": "dist/index", | ||
"dependencies": { | ||
"@db-auto/utils": "0.0.28", | ||
"@db-auto/postgres": "0.0.28", | ||
"@db-auto/mysql": "0.0.28", | ||
"@db-auto/oracle": "0.0.28" | ||
"@db-auto/utils": "0.0.29", | ||
"@db-auto/postgres": "0.0.29", | ||
"@db-auto/mysql": "0.0.29", | ||
"@db-auto/oracle": "0.0.29" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15127
279
+ Added@db-auto/dal@0.0.29(transitive)
+ Added@db-auto/mysql@0.0.29(transitive)
+ Added@db-auto/oracle@0.0.29(transitive)
+ Added@db-auto/postgres@0.0.29(transitive)
+ Added@db-auto/utils@0.0.29(transitive)
- Removed@db-auto/dal@0.0.28(transitive)
- Removed@db-auto/mysql@0.0.28(transitive)
- Removed@db-auto/oracle@0.0.28(transitive)
- Removed@db-auto/postgres@0.0.28(transitive)
- Removed@db-auto/utils@0.0.28(transitive)
Updated@db-auto/mysql@0.0.29
Updated@db-auto/oracle@0.0.29
Updated@db-auto/postgres@0.0.29
Updated@db-auto/utils@0.0.29