New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

db-auto

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-auto - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

2

dist/index.js

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

}
const program = (0, cli_1.makeProgram)(config, "0.0.1");
const program = (0, cli_1.makeProgram)(config, (0, cli_1.findVersion)());
(0, cli_1.processProgram)(program, process.argv);

@@ -5,3 +5,4 @@ import { Command } from "commander";

export declare function makeConfig(cwd: string, envVars: NameAnd<string>): ErrorsAnd<CleanConfig>;
export declare function findVersion(): any;
export declare function makeProgram(config: CleanConfig, version: string): Command;
export declare function processProgram(program: Command, args: string[]): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processProgram = exports.makeProgram = exports.makeConfig = void 0;
exports.processProgram = exports.makeProgram = exports.findVersion = exports.makeConfig = void 0;
const commander_1 = require("commander");

@@ -16,2 +16,12 @@ const utils_1 = require("@db-auto/utils");

exports.makeConfig = makeConfig;
function findVersion() {
let packageJsonFileName = "../../package.json";
try {
return require(packageJsonFileName).version;
}
catch (e) {
return "version not known";
}
}
exports.findVersion = findVersion;
function makeProgram(config, version) {

@@ -30,3 +40,3 @@ let program = new commander_1.Command()

const where = options.where ? options.where : [];
const errorsOrresult = (0, path_1.processPathString)(config.tables, path, id, options, options.plan, where);
const errorsOrresult = (0, path_1.processPathString)(config.tables, (0, tables_1.makePathSpec)(path, id, options, where), options);
if ((0, utils_1.hasErrors)(errorsOrresult)) {

@@ -33,0 +43,0 @@ (0, utils_1.reportErrors)(errorsOrresult);

import { ErrorsAnd, NameAnd } from "@db-auto/utils";
import { CleanTable, SelectData } from "@db-auto/tables";
import { CleanTable, PathSpec, SelectData } from "@db-auto/tables";
export interface SelectDataPP {

@@ -16,4 +16,8 @@ type: 'selectData';

type PP = SelectDataPP | LinksPP | SqlPP;
export declare function processPathString(tables: NameAnd<CleanTable>, path: string, id: string | undefined, queryParams: NameAnd<string>, showPlan?: boolean, where?: string[]): ErrorsAnd<PP>;
interface ProcessPathOptions {
plan?: boolean;
sql?: boolean;
}
export declare function processPathString(tables: NameAnd<CleanTable>, pathSpec: PathSpec, options: ProcessPathOptions): ErrorsAnd<PP>;
export declare function prettyPrintPP(pp: PP): string[];
export {};

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

const tables_1 = require("@db-auto/tables");
function findLinks(tables, parts) {
let withoutQuery = parts.slice(0, -1);
function findLinks(tables, path) {
let withoutQuery = path.slice(0, -1);
if (withoutQuery.length === 0)
return { links: Object.keys(tables), type: 'links' };
const planOrErrors = (0, tables_1.buildPlan)(tables_1.clean, withoutQuery);
const planOrErrors = (0, tables_1.buildPlan)(tables_1.clean, { path: withoutQuery, wheres: [], queryParams: {}, id: undefined });
if ((0, utils_1.hasErrors)(planOrErrors))

@@ -24,13 +24,14 @@ return planOrErrors;

}
function processPathString(tables, path, id, queryParams, showPlan, where) {
const parts = path.split('.');
if (parts.length === 0)
function processPathString(tables, pathSpec, options) {
const path = pathSpec.path;
if (path.length === 0)
return ['Path must have at least one part'];
const lastPart = parts[parts.length - 1];
const lastPart = path[path.length - 1];
if (lastPart.endsWith('?'))
return processQueryPP(tables, parts);
let plan = (0, tables_1.buildPlan)(tables_1.clean, parts, id, queryParams, where);
return processQueryPP(tables, path);
let plan = (0, tables_1.buildPlan)(tables_1.clean, pathSpec);
if ((0, utils_1.hasErrors)(plan))
return plan;
const data = (0, tables_1.selectData)("all")(plan);
const { plan: showPlan, sql: showSql } = options;
if (showPlan)

@@ -37,0 +38,0 @@ return { type: 'selectData', data };

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

it('should handle notfound', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'notfound', undefined, {}, true, undefined)).toEqual([
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('notfound'), {})).toEqual([
"Cannot find table notfound in tables. Available tables are: driver,driver_aud,mission,mission_aud"

@@ -15,3 +15,3 @@ ]);

it('should handle notfound.?', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'notfound.?', undefined, {}, true, undefined)).toEqual([
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('notfound.?'), {})).toEqual([
"Cannot find table notfound in tables. Available tables are: driver,driver_aud,mission,mission_aud"

@@ -21,3 +21,3 @@ ]);

it('should handle driver.notfound.', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'driver.notfound', undefined, {}, true, undefined)).toEqual([
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('driver.notfound'), {})).toEqual([
"Cannot find link notfound in table DriverTable for path [driver]. Available links are: audit,mission"

@@ -27,3 +27,3 @@ ]);

it('should handle driver.notfound.?', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'driver.notfound.?', undefined, {}, true, undefined)).toEqual([
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('driver.notfound.?'), {})).toEqual([
"Cannot find link notfound in table DriverTable for path [driver]. Available links are: audit,mission",

@@ -33,3 +33,3 @@ ]);

it('should handle driver.mission.notfound.?', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'driver.mission.notfound.?', undefined, {}, true, undefined)).toEqual([
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('driver.mission.notfound.?'), {})).toEqual([
"Cannot find link notfound in table mission for path [driver.mission]. Available links are: driver,mission_aud"

@@ -41,3 +41,3 @@ ]);

it('should handle ?', () => {
expect((0, path_1.processPathString)(tables_1.clean, '?', undefined, {}, true, undefined))
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('?'), {}))
.toEqual({

@@ -49,3 +49,3 @@ "links": ["driver", "driver_aud", "mission", "mission_aud"],

it('should handle d?', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'd?', undefined, {}, true, undefined))
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('d?'), {}))
.toEqual({

@@ -57,3 +57,3 @@ "links": ["driver", "driver_aud"],

it('should handle notin?', () => {
expect((0, path_1.processPathString)(tables_1.clean, 'notin?', undefined, {}, true, undefined))
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)('notin?'), {}))
.toEqual({

@@ -65,3 +65,3 @@ "links": [],

it("should handle driver.?", () => {
expect((0, path_1.processPathString)(tables_1.clean, "driver.?", undefined, {}, true, undefined)).toEqual({
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)("driver.?"), {})).toEqual({
"links": ["mission", "audit"],

@@ -72,3 +72,3 @@ "type": "links"

it("should handle driver.m?", () => {
expect((0, path_1.processPathString)(tables_1.clean, "driver.m?", undefined, {}, true, undefined)).toEqual({
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)("driver.m?"), {})).toEqual({
"links": ["mission"],

@@ -79,3 +79,3 @@ "type": "links"

it("should handle driver.notin?", () => {
expect((0, path_1.processPathString)(tables_1.clean, "driver.notin?", undefined, {}, true, undefined)).toEqual({
expect((0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)("driver.notin?"), {})).toEqual({
"links": [],

@@ -88,4 +88,4 @@ "type": "links"

function forPlan(path) {
const actual = (0, path_1.processPathString)(tables_1.clean, path, undefined, {}, true, undefined);
const data = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, path.split('\.'), undefined, {}, undefined), (0, tables_1.selectData)("all"));
const actual = (0, path_1.processPathString)(tables_1.clean, (0, tables_1.makePathSpec)(path), { plan: true });
const data = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, (0, tables_1.makePathSpec)(path)), (0, tables_1.selectData)("all"));
const expected = { type: 'selectData', data };

@@ -108,5 +108,5 @@ return { actual, expected };

describe("returning a sql", () => {
function forSql(path, queryParam, wheres) {
const actual = (0, path_1.processPathString)(tables_1.clean, path, undefined, queryParam, false, wheres);
const sql = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, path.split('\.'), undefined, queryParam, wheres), plan => (0, tables_1.sqlFor)((0, tables_1.mergeSelectData)((0, tables_1.selectData)("all")(plan))));
function forSql(pathSpec) {
const actual = (0, path_1.processPathString)(tables_1.clean, pathSpec, { sql: true });
const sql = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, pathSpec), plan => (0, tables_1.sqlFor)((0, tables_1.mergeSelectData)((0, tables_1.selectData)("all")(plan))));
const expected = { type: 'sql', sql };

@@ -116,7 +116,7 @@ return { actual, expected };

it("should handle driver", () => {
const { actual, expected } = forSql("driver", {});
const { actual, expected } = forSql((0, tables_1.makePathSpec)("driver"));
expect(actual).toEqual(expected);
});
it("should handle driver.mission", () => {
const { actual, expected } = forSql("driver.mission", {});
const { actual, expected } = forSql((0, tables_1.makePathSpec)("driver.mission"));
expect(actual).toEqual(expected);

@@ -129,3 +129,3 @@ expect(expected.sql).toEqual([

it("should handle driver.mission with a query param and where", () => {
const { actual, expected } = forSql("driver.mission", {}, ["w1"]);
const { actual, expected } = forSql((0, tables_1.makePathSpec)("driver.mission", undefined, {}, ["w1"]));
expect(actual).toEqual(expected);

@@ -138,3 +138,3 @@ expect(expected.sql).toEqual([

it("should handle driver.mission with a query param and wheres", () => {
const { actual, expected } = forSql("driver.mission", {}, ["w1", "w2"]);
const { actual, expected } = forSql((0, tables_1.makePathSpec)("driver.mission", undefined, {}, ["w1", "w2"]));
expect(actual).toEqual(expected);

@@ -147,3 +147,3 @@ expect(expected.sql).toEqual([

it("should handle driver.mission with a query param and wheres and a queryparam in driver and mission", () => {
const { actual, expected } = forSql("driver.mission", { employeeNum: "123", "date": "thedate" }, ["w1", "w2"]);
const { actual, expected } = forSql((0, tables_1.makePathSpec)("driver.mission", undefined, { employeeNum: "123", "date": "thedate" }, ["w1", "w2"]));
expect(actual).toEqual(expected);

@@ -150,0 +150,0 @@ expect(expected.sql).toEqual([

{
"name": "db-auto",
"description": "",
"version": "0.0.16",
"version": "0.0.17",
"main": "dist/index",

@@ -24,9 +24,10 @@ "types": "dist/index",

"commander": "^10.0.0",
"@db-auto/oracle": "0.0.16",
"@db-auto/mysql": "0.0.16",
"@db-auto/tables": "0.0.16",
"@db-auto/utils": "0.0.16",
"@db-auto/files": "0.0.16",
"@db-auto/mocks": "0.0.16",
"@db-auto/environments": "0.0.16"
"@db-auto/oracle": "0.0.17",
"@db-auto/mysql": "0.0.17",
"@db-auto/postgres": "0.0.17",
"@db-auto/tables": "0.0.17",
"@db-auto/utils": "0.0.17",
"@db-auto/files": "0.0.17",
"@db-auto/mocks": "0.0.17",
"@db-auto/environments": "0.0.17"
},

@@ -33,0 +34,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