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

@databases/mysql-config

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@databases/mysql-config - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/tsconfig.tsbuildinfo

93

lib/__tests__/index.test.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
test('get root config', () => {
expect(__1.getMySqlConfigSync()).toEqual({
connectionStringEnvironmentVariable: 'MYSQL_URL',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user'
}
});
expect(__1.getMySqlConfigSync()).toEqual({
connectionStringEnvironmentVariable: 'MYSQL_URL',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user',
},
});
});
test('valid config', () => {
expect(__1._testReadMySqlConfigSync(__dirname + '/fixtures/empty.json')).toEqual({
connectionStringEnvironmentVariable: 'DATABASE_URL',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user'
}
});
expect(__1._testReadMySqlConfigSync(__dirname + '/fixtures/override.json')).toEqual({
connectionStringEnvironmentVariable: 'PG_CONNECTION',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user'
}
});
expect(__1._testReadMySqlConfigSync(__dirname + '/fixtures/empty.json')).toEqual({
connectionStringEnvironmentVariable: 'DATABASE_URL',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user',
},
});
expect(__1._testReadMySqlConfigSync(__dirname + '/fixtures/override.json')).toEqual({
connectionStringEnvironmentVariable: 'PG_CONNECTION',
test: {
connectTimeoutSeconds: 20,
containerName: 'mysql-test',
debug: false,
image: 'mysql:5.7.24',
mySqlDb: 'test-db',
mySqlPassword: 'password',
mySqlUser: 'test-user',
},
});
});
test('invalid config', () => {
expect(() => __1._testReadMySqlConfigSync(__dirname + '/fixtures/invalid.json')).toThrowError(/MySqlConfig.connectionStringEnvironmentVariable should be string/);
});
expect(() => __1._testReadMySqlConfigSync(__dirname + '/fixtures/invalid.json'))
.toThrowErrorMatchingInlineSnapshot(`
"Unable to assign {connectionStringEnvironmentVariable: 10} to { connectionStringEnvironmentVariable: string | undefined; test: TestConfig | undefined; }
The types of \\"connectionStringEnvironmentVariable\\" are not compatible
Unable to assign 10 to string | undefined
Unable to assign 10 to string
Expected string, but was 10
And unable to assign 10 to undefined
Expected literal undefined, but was 10 (i.e. a number)"
`);
});
//# sourceMappingURL=index.test.js.map

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

import { MySqlConfig } from './MySqlConfig.validator';
import MySqlConfig from './MySqlConfig';
export declare function getMySqlConfig(searchFrom?: string): Promise<MySqlConfig>;

@@ -3,0 +3,0 @@ export declare function getMySqlConfigSync(searchFrom?: string): MySqlConfig;

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "__esModule", { value: true });
exports._testReadMySqlConfigSync = exports.getMySqlConfigSync = exports.getMySqlConfig = void 0;
const cosmiconfig = require("cosmiconfig");
const MySqlConfig_validator_1 = require("./MySqlConfig.validator");
const MySqlConfig_1 = require("./MySqlConfig");
const explorer = cosmiconfig('mysql');
async function getMySqlConfig(searchFrom) {
return parseResult(await explorer.search(searchFrom));
return parseResult(await explorer.search(searchFrom));
}
exports.getMySqlConfig = getMySqlConfig;
function getMySqlConfigSync(searchFrom) {
return parseResult(explorer.searchSync(searchFrom));
return parseResult(explorer.searchSync(searchFrom));
}
exports.getMySqlConfigSync = getMySqlConfigSync;
function _testReadMySqlConfigSync(filename) {
return parseResult(explorer.loadSync(filename));
return parseResult(explorer.loadSync(filename));
}
exports._testReadMySqlConfigSync = _testReadMySqlConfigSync;
function parseResult(result) {
return MySqlConfig_validator_1.default(result ? result.config : {});
}
return MySqlConfig_1.MySqlConfigSchema.parse(result ? result.config : {});
}
//# sourceMappingURL=index.js.map

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

import * as ft from 'funtypes';
export interface TestConfig {

@@ -20,5 +21,2 @@ /**

*
* See https://github.com/mysqljs/mysql/pull/1962
* for issues supporting mysql 8
*
* @default "mysql:5.7.24"

@@ -71,2 +69,3 @@ */

}
export declare const TestConfigSchema: ft.Runtype<TestConfig>;
interface MySqlConfig {

@@ -87,2 +86,3 @@ /**

}
export declare const MySqlConfigSchema: ft.Runtype<MySqlConfig>;
export default MySqlConfig;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.MySqlConfigSchema = exports.TestConfigSchema = void 0;
const ft = require("funtypes");
function withDefault(type, defaultValue) {
return ft.Union(type, ft.Undefined.withParser({
parse() {
return { success: true, value: defaultValue };
},
name: `undefined`,
}));
}
function integer({ min = -Math.pow(2, 31), max = Math.pow(2, 32), }) {
return ft.Number.withConstraint((value) => {
if (value !== Math.floor(value)) {
return `Expected an integer but got ${value}`;
}
if (value < min || value > max) {
return `Expected an integer between ${min} and ${max} but got ${value}`;
}
return true;
}, { name: `Integer` });
}
exports.TestConfigSchema = ft
.Object({
debug: withDefault(ft.Boolean, false),
migrationsScript: ft.Union(ft.String, ft.Array(ft.String), ft.Undefined),
image: withDefault(ft.String, `mysql:5.7.24`),
containerName: withDefault(ft.String, `mysql-test`),
connectTimeoutSeconds: withDefault(integer({ min: 0 }), 20),
port: withDefault(integer({ min: 0, max: 65535 }), undefined),
mySqlUser: withDefault(ft.String, `test-user`),
mySqlPassword: withDefault(ft.String, `password`),
mySqlDb: withDefault(ft.String, `test-db`),
})
.withConstraint((value) => true, { name: `TestConfig` });
exports.MySqlConfigSchema = ft.Object({
connectionStringEnvironmentVariable: withDefault(ft.String, `DATABASE_URL`),
test: withDefault(exports.TestConfigSchema, exports.TestConfigSchema.parse({})),
});
//# sourceMappingURL=MySqlConfig.js.map
{
"name": "@databases/mysql-config",
"version": "2.0.0",
"version": "2.1.0",
"description": "",

@@ -8,13 +8,9 @@ "main": "./lib/index.js",

"dependencies": {
"@types/cosmiconfig": "^5.0.3",
"ajv": "^6.7.0",
"cosmiconfig": "^5.0.7"
"cosmiconfig": "^5.0.7",
"funtypes": "^4.1.0"
},
"devDependencies": {
"typescript-json-validator": "^1.0.0"
"@types/cosmiconfig": "^5.0.3"
},
"scripts": {
"schema": "typescript-json-validator src/MySqlConfig.ts MySqlConfig",
"build": "yarn schema"
},
"scripts": {},
"repository": "https://github.com/ForbesLindesay/atdatabases/tree/master/packages/mysql-config",

@@ -21,0 +17,0 @@ "bugs": "https://github.com/ForbesLindesay/atdatabases/issues",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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