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

@dbpath/environments

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbpath/environments - npm Package Compare versions

Comparing version 0.2.13 to 0.2.14

16

dist/src/environments.d.ts

@@ -1,9 +0,7 @@

import { ColumnDefn, ErrorsAnd, NameAnd, NameAndValidator } from "@dbpath/utils";
import { ErrorsAnd, NameAnd, NameAndValidator } from "@dbpath/utils";
import { PostgresEnv } from "@dbpath/postgres";
import { Dal } from "@dbpath/dal";
import { CommonEnvironment, Dal } from "@dbpath/dal";
import { OracleEnv } from "@dbpath/oracle";
export declare const dbPathDir = ".dbpath";
export type Environment = PostgresEnv;
export interface CurrentEnvironment {
currentEnvironment: string;
}
export declare const stateFileName = "dbpath.state.json";

@@ -20,5 +18,5 @@ export declare function currentEnvName(cwd: string, marker: string, env: string | undefined, cleanE: NameAnd<CleanEnvironment>): ErrorsAnd<string>;

}
export declare function dalFromCurrentEnvironment(cwd: string, envs: NameAnd<CleanEnvironment>, specifiedEnv: string | undefined): ErrorsAnd<DalAndEnv>;
export declare function dalFromCurrentEnvironment(cwd: string, envs: NameAnd<CleanEnvironment>, specifiedEnv: string | undefined): Promise<ErrorsAnd<DalAndEnv>>;
export declare function useDalAndEnv<T>(cwd: string, envs: NameAnd<CleanEnvironment>, specifiedEnv: string | undefined, fn: (dalAndEnv: DalAndEnv) => Promise<ErrorsAnd<T>>): Promise<ErrorsAnd<T>>;
export interface CleanEnvironment extends Required<Environment> {
export interface CleanEnvironment extends Required<CommonEnvironment> {
name: string;

@@ -29,3 +27,3 @@ }

export declare function sqlDialect(type: string): import("@dbpath/dal").DalDialect;
export declare function dalFor(env: Environment): ErrorsAnd<Dal>;
export declare function dalFor(env: CommonEnvironment): Promise<ErrorsAnd<Dal>>;
export interface EnvStatus {

@@ -38,2 +36,2 @@ name: string;

export declare function checkStatus(envs: NameAnd<CleanEnvironment>): Promise<NameAnd<EnvStatus>>;
export declare const statusColDefn: NameAnd<ColumnDefn<EnvStatus>>;
export declare function mapEnv<T>(e: CommonEnvironment, postGes: (e: PostgresEnv) => T, oracleFn: (e: OracleEnv) => T): T;

@@ -35,3 +35,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.statusColDefn = exports.checkStatus = exports.envIsUp = exports.dalFor = exports.sqlDialect = exports.environmentValidator = exports.cleanEnvironment = exports.useDalAndEnv = exports.dalFromCurrentEnvironment = exports.currentEnvironment = exports.saveEnvName = exports.currentEnvName = exports.stateFileName = exports.dbPathDir = void 0;
exports.mapEnv = exports.checkStatus = exports.envIsUp = exports.dalFor = exports.sqlDialect = exports.environmentValidator = exports.cleanEnvironment = exports.useDalAndEnv = exports.dalFromCurrentEnvironment = exports.currentEnvironment = exports.saveEnvName = exports.currentEnvName = exports.stateFileName = exports.dbPathDir = void 0;
const utils_1 = require("@dbpath/utils");

@@ -42,2 +42,3 @@ const postgres_1 = require("@dbpath/postgres");

const fs = __importStar(require("fs"));
const oracle_1 = require("@dbpath/oracle");
exports.dbPathDir = '.dbpath';

@@ -81,7 +82,9 @@ exports.stateFileName = 'dbpath.state.json';

function dalFromCurrentEnvironment(cwd, envs, specifiedEnv) {
const envAndNameOrErrors = currentEnvironment(cwd, exports.dbPathDir, envs, specifiedEnv);
if ((0, utils_1.hasErrors)(envAndNameOrErrors))
return envAndNameOrErrors;
const { env, envName } = envAndNameOrErrors;
return (0, utils_1.mapErrors)(dalFor(env), dal => (Object.assign({ dal }, envAndNameOrErrors)));
return __awaiter(this, void 0, void 0, function* () {
const envAndNameOrErrors = currentEnvironment(cwd, exports.dbPathDir, envs, specifiedEnv);
if ((0, utils_1.hasErrors)(envAndNameOrErrors))
return envAndNameOrErrors;
const { env, envName } = envAndNameOrErrors;
return (0, utils_1.mapErrors)(yield dalFor(env), dal => (Object.assign({ dal }, envAndNameOrErrors)));
});
}

@@ -91,3 +94,3 @@ exports.dalFromCurrentEnvironment = dalFromCurrentEnvironment;

return __awaiter(this, void 0, void 0, function* () {
const errorsOrDal = dalFromCurrentEnvironment(cwd, envs, specifiedEnv);
const errorsOrDal = yield dalFromCurrentEnvironment(cwd, envs, specifiedEnv);
if ((0, utils_1.hasErrors)(errorsOrDal))

@@ -125,2 +128,4 @@ return errorsOrDal;

return postgres_1.postgresDalDialect;
if (type === 'oracle')
return oracle_1.oracleDalDialect;
throw new Error(`Unknown environment type ${type}. Currently on postgres is supported. ${JSON.stringify(type)}`);

@@ -130,5 +135,9 @@ }

function dalFor(env) {
if (env.type === 'postgres')
return (0, postgres_1.postgresDal)(env);
throw new Error(`Unknown environment type ${env.type}. Currently on postgres is supported. ${JSON.stringify(env)}`);
return __awaiter(this, void 0, void 0, function* () {
if (env.type === 'postgres')
return (0, postgres_1.postgresDal)(env);
if (env.type === 'oracle')
return (0, oracle_1.oracleDal)(env);
throw new Error(`Unknown environment type ${env.type}. Currently on postgres is supported. ${JSON.stringify(env)}`);
});
}

@@ -139,3 +148,3 @@ exports.dalFor = dalFor;

return __awaiter(this, void 0, void 0, function* () {
let dal = dalFor(env);
let dal = yield dalFor(env);
if ((0, utils_1.hasErrors)(dal))

@@ -166,10 +175,9 @@ return false;

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() },
};
function mapEnv(e, postGes, oracleFn) {
if (e.type === 'postgres')
return postGes(e);
if (e.type === 'oracle')
return oracleFn(e);
throw new Error(`Unknown environment type ${e.type}. Currently on postgres is supported. ${JSON.stringify(e)}`);
}
exports.mapEnv = mapEnv;

@@ -1,3 +0,5 @@

import { NameAnd } from "@dbpath/utils";
import { CleanEnvironment } from "./environments";
import { ColumnDefn, NameAnd } from "@dbpath/utils";
import { CleanEnvironment, EnvStatus } from "./environments";
export declare const envColumnData: NameAnd<ColumnDefn<CleanEnvironment>>;
export declare const statusColDefn: NameAnd<ColumnDefn<EnvStatus>>;
export declare function prettyPrintEnvironments(envs: NameAnd<CleanEnvironment>): string[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.prettyPrintEnvironments = void 0;
exports.prettyPrintEnvironments = exports.statusColDefn = exports.envColumnData = void 0;
const utils_1 = require("@dbpath/utils");
const envColumnData = {
const environments_1 = require("./environments");
exports.envColumnData = {
"Environment": { dataFn: (t) => t.name },
"Type": { dataFn: (t) => t.type },
"Host": { dataFn: (t) => t.host },
"Port": { dataFn: (t) => t.port === undefined ? '' : t.port.toString() },
"Database": { dataFn: (t) => t.database },
"Host": { dataFn: (t) => (0, environments_1.mapEnv)(t, e => e.host, e => '') },
"Port": { dataFn: (t) => (0, environments_1.mapEnv)(t, e => e.port === undefined ? '' : e.port.toString(), e => '') },
"Database": { dataFn: (t) => (0, environments_1.mapEnv)(t, e => e.database, e => '') },
"Schema": { dataFn: (t) => (0, environments_1.mapEnv)(t, e => e.database, e => '') },
"UserName": { dataFn: (t) => t.username },
"Connection": { dataFn: (t) => (0, environments_1.mapEnv)(t, e => '', e => e.connection) },
};
exports.statusColDefn = {
"Environment": { dataFn: (t) => t.name },
"Up": { dataFn: (t) => t.up.toString() },
"Type": { dataFn: (t) => t.env.type },
"Host": { dataFn: (t) => (0, environments_1.mapEnv)(t.env, e => e.host, e => '') },
"Port": { dataFn: (t) => (0, environments_1.mapEnv)(t.env, e => e.port === undefined ? '' : e.port.toString(), e => '') },
"Database": { dataFn: (t) => (0, environments_1.mapEnv)(t.env, e => e.database, e => '') },
"Schema": { dataFn: (t) => (0, environments_1.mapEnv)(t.env, e => e.database, e => '') },
"UserName": { dataFn: (t) => t.env.username },
"Connection": { dataFn: (t) => (0, environments_1.mapEnv)(t.env, e => '', e => e.connection) },
};
function prettyPrintEnvironments(envs) {
return (0, utils_1.toColumns)(envColumnData)(Object.values(envs));
return (0, utils_1.toColumns)(exports.envColumnData)(Object.values(envs));
}
exports.prettyPrintEnvironments = prettyPrintEnvironments;
{
"name": "@dbpath/environments",
"description": "",
"version": "0.2.13",
"version": "0.2.14",
"main": "dist/index",

@@ -20,7 +20,7 @@ "types": "dist/index",

"dependencies": {
"@dbpath/utils": "0.2.13",
"@dbpath/files": "0.2.13",
"@dbpath/postgres": "0.2.13",
"@dbpath/mysql": "0.2.13",
"@dbpath/oracle": "0.2.13"
"@dbpath/utils": "0.2.14",
"@dbpath/files": "0.2.14",
"@dbpath/postgres": "0.2.14",
"@dbpath/mysql": "0.2.14",
"@dbpath/oracle": "0.2.14"
},

@@ -27,0 +27,0 @@ "devDependencies": {

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