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

relational-schema

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relational-schema - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

7

build/src/cli/entry.js

@@ -30,3 +30,3 @@ #! /usr/bin/env node

const logLevels = [types_1.LogLevel.debug, types_1.LogLevel.info];
yargs_1.default(hideBin(process.argv))
(0, yargs_1.default)(hideBin(process.argv))
.usage('Usage: $0 <command> [options]')

@@ -83,3 +83,3 @@ .command('introspect', 'Generate schema from database', (yargs) => {

}, (argv) => __awaiter(void 0, void 0, void 0, function* () {
yield print_relations_1.printRelationTree({
yield (0, print_relations_1.printRelationTree)({
root: argv.table,

@@ -115,7 +115,6 @@ schemaPath: argv.schemaFile,

const GENERATED_DIR = path_1.default.join(CURRENT, outdir);
yield index_1.generate({ conn, outdir: GENERATED_DIR, format, prettierConfig, logLevel: logs, options });
yield (0, index_1.generate)({ conn, outdir: GENERATED_DIR, format, prettierConfig, logLevel: logs, options });
}
catch (e) {
logger_1.logger.error(e);
logger_1.logger.debug(e.stack);
logger_1.logger.info('Use: "relation -h" to see help');

@@ -122,0 +121,0 @@ process.exit(1);

@@ -38,6 +38,6 @@ "use strict";

logger_1.logger.info(`Generating for db: ${conn.client} - ${conn.connection.database}`);
const schema = yield introspect_1.introspectSchema({ conn, logLevel, options });
const schema = yield (0, introspect_1.introspectSchema)({ conn, logLevel, options });
switch (format) {
case "es6" /* es6 */:
yield printer_1.writeFormattedFile({
yield (0, printer_1.writeFormattedFile)({
prettierConfig,

@@ -53,3 +53,3 @@ content: `

case "cjs" /* commonJS */:
yield printer_1.writeFormattedFile({
yield (0, printer_1.writeFormattedFile)({
prettierConfig,

@@ -65,3 +65,3 @@ content: `

case "ts" /* typescript */:
yield printer_1.writeFormattedFile({
yield (0, printer_1.writeFormattedFile)({
prettierConfig,

@@ -77,3 +77,3 @@ content: `

case "json" /* json */:
yield printer_1.writeFormattedFile({
yield (0, printer_1.writeFormattedFile)({
prettierConfig,

@@ -80,0 +80,0 @@ content: JSON.stringify(schema),

@@ -11,8 +11,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.introspectSchema = void 0;
const knex_1 = __importDefault(require("knex"));
const knex_1 = require("knex");
const types_1 = require("../types");

@@ -30,3 +27,3 @@ const postgres_introspection_1 = require("./postgres-introspection");

const { host, port, user, database, schema } = conn.connection;
const knex = knex_1.default(conn);
const knex = (0, knex_1.knex)(conn);
let DB;

@@ -33,0 +30,0 @@ if (conn.client === 'mysql') {

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

import Knex from 'knex';
import { Knex } from 'knex';
import { ColumnType, ConstraintDefinition, EnumDefinitions, LogLevel, RelationDefinition, TableColumnsDefinition, TableMap } from '../types';

@@ -17,3 +17,3 @@ export declare abstract class Introspection {

*/
protected query<T>(query: Knex.QueryBuilder<T>): Promise<T>;
protected query<T extends Record<string, any>>(query: Knex.QueryBuilder<T>): Promise<T>;
/**

@@ -20,0 +20,0 @@ * Helper to group and map over rows by table_name

import { ColumnType, ConstraintDefinition, EnumDefinitions, LogLevel, RelationDefinition, TableColumnsDefinition, TableMap } from '../types';
import Knex = require('knex');
import { Introspection } from './introspection';
import { Knex } from 'knex';
export declare class MySQLIntrospection extends Introspection {

@@ -5,0 +5,0 @@ protected readonly databaseName: string;

import { ColumnType, ConstraintDefinition, EnumDefinitions, LogLevel, RelationDefinition, TableColumnsDefinition, TableMap } from '../types';
import Knex = require('knex');
import { Knex } from 'knex';
import { Introspection } from './introspection';

@@ -4,0 +4,0 @@ export declare class PostgresIntrospection extends Introspection {

@@ -224,8 +224,8 @@ "use strict";

primaryKey: cardinality_resolver_1.CardinalityResolver.primaryKey(tableConstraints),
keys: lodash_1.sortBy(tableConstraints, (c) => c.constraintName),
uniqueKeyCombinations: lodash_1.sortBy(uniqueKeyCombinations, (u) => u.join(':')),
keys: (0, lodash_1.sortBy)(tableConstraints, (c) => c.constraintName),
uniqueKeyCombinations: (0, lodash_1.sortBy)(uniqueKeyCombinations, (u) => u.join(':')),
relations: [
...lodash_1.sortBy(forwardRels, (r) => r.constraintName),
...lodash_1.sortBy(backwardRels, (r) => r.constraintName),
...lodash_1.sortBy(tableTransitiveRelations, (r) => r.alias),
...(0, lodash_1.sortBy)(forwardRels, (r) => r.constraintName),
...(0, lodash_1.sortBy)(backwardRels, (r) => r.constraintName),
...(0, lodash_1.sortBy)(tableTransitiveRelations, (r) => r.alias),
],

@@ -232,0 +232,0 @@ columns: this.stableOrderedMap(tableColumns),

@@ -67,6 +67,6 @@ "use strict";

const parser = formatParser[format];
const out = path_1.join(directory, filename + '.' + extension);
const out = (0, path_1.join)(directory, filename + '.' + extension);
// append creates files if they don't exist - write overwrites contents
yield fs_extra_1.default.appendFile(out, '');
yield fs_extra_1.default.writeFile(out, prettier_1.format(fileHeader + content, Object.assign({ parser }, getPrettierConfig(prettierConfig))));
yield fs_extra_1.default.writeFile(out, (0, prettier_1.format)(fileHeader + content, Object.assign({ parser }, getPrettierConfig(prettierConfig))));
});

@@ -73,0 +73,0 @@ }

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

const { root, schemaPath, maxDepth, showBackwardRelations } = options;
const schemaFullPath = path_1.join(process.cwd(), schemaPath);
const schemaFullPath = (0, path_1.join)(process.cwd(), schemaPath);
logger_1.logger.debug('Loading schema from ', schemaFullPath);

@@ -15,0 +15,0 @@ const schema = require(schemaFullPath);

{
"name": "relational-schema",
"version": "0.6.0",
"version": "0.6.1",
"description": "Generate a js schema for a relational database",

@@ -20,5 +20,5 @@ "keywords": [

"docker:stop": "docker-compose down",
"test:pg": "DB=pg tsnd --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts && DB=pg jest --runInBand",
"test:mysql": "DB=mysql tsnd --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts && DB=mysql jest --runInBand",
"test:introspect": "tsnd --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts",
"test:pg": "DB=pg npx ts-node --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts && DB=pg jest --runInBand",
"test:mysql": "DB=mysql npx ts-node --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts && DB=mysql jest --runInBand",
"test:introspect": "npx ts-node --files --transpile-only -r tsconfig-paths/register ./test/helpers/introspect.ts",
"prepare": "npm run build",

@@ -52,3 +52,3 @@ "semantic-release": "semantic-release",

"@types/fs-extra": "^9.0.1",
"@types/jest": "^26.0.7",
"@types/jest": "^29.4.0",
"@types/lodash": "^4.14.157",

@@ -66,10 +66,9 @@ "@types/pg": "^7.14.5",

"faker": "^4.1.0",
"jest": "^26.6.3",
"jest": "^29.4.1",
"jest-extended": "^0.11.5",
"semantic-release": "^17.4.2",
"ts-jest": "^24.2.0",
"ts-node": "^9.1.1",
"ts-node-dev": "^1.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.0"
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "4.5.4"
},

@@ -79,5 +78,5 @@ "dependencies": {

"fs-extra": "^9.0.1",
"knex": "^0.21.2",
"knex": "^2.3.0",
"lodash": "^4.17.19",
"pg": "^8.4.1",
"pg": "^8.9.0",
"pluralize": "^8.0.0",

@@ -84,0 +83,0 @@ "prettier": "^2.2.1",

@@ -6,2 +6,3 @@ {

"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"declaration": true,

@@ -8,0 +9,0 @@ "newLine": "LF",

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

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

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

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