relational-schema
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -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
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
24
149898
60
1911
+ Addedcolorette@2.0.19(transitive)
+ Addedcommander@10.0.1(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedgetopts@2.3.0(transitive)
+ Addedknex@2.5.1(transitive)
+ Addedpg-connection-string@2.6.1(transitive)
+ Addedrechoir@0.8.0(transitive)
+ Addedresolve-from@5.0.0(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-each@1.0.1(transitive)
- Removedarray-slice@1.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolorette@1.2.1(transitive)
- Removedcommander@6.2.1(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.94.3.1(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddetect-file@1.0.0(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedexpand-tilde@2.0.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfindup-sync@3.0.0(transitive)
- Removedfined@1.2.0(transitive)
- Removedflagged-respawn@1.0.1(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@1.0.0(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedget-value@2.0.6(transitive)
- Removedgetopts@2.2.5(transitive)
- Removedglobal-modules@1.0.0(transitive)
- Removedglobal-prefix@1.0.2(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedini@1.3.8(transitive)
- Removedis-absolute@1.0.0(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-relative@1.0.0(transitive)
- Removedis-unc-path@1.0.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedknex@0.21.21(transitive)
- Removedliftoff@3.1.0(transitive)
- Removedmake-iterator@1.0.1(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.defaults@1.1.0(transitive)
- Removedobject.map@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedparse-filepath@1.0.2(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-root@0.1.1(transitive)
- Removedpath-root-regex@0.1.2(transitive)
- Removedpg-connection-string@2.4.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedrechoir@0.6.2(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-dir@1.0.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunc-path-regex@0.1.2(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedv8flags@3.2.0(transitive)
- Removedwhich@1.3.1(transitive)
Updatedknex@^2.3.0
Updatedpg@^8.9.0