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

sqljson-query

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqljson-query - npm Package Compare versions

Comparing version 1.7.21 to 1.7.22

lib/util/nullable.d.ts

7

lib/dbmd/relations-md-source-generator.js

@@ -29,5 +29,6 @@ "use strict";

const mod_1 = require("../util/mod");
const files_1 = require("../util/files");
const database_metadata_1 = require("./database-metadata");
async function generateRelationsMetadataSource(dbmdFile, sourceOutputDir, srcLang, javaPackage = undefined, preferLowercaseNames = true) {
const dbmdStoredPropsJson = await (0, mod_1.readTextFile)(dbmdFile);
const dbmdStoredPropsJson = await (0, files_1.readTextFile)(dbmdFile);
const dbmd = new database_metadata_1.DatabaseMetadata(JSON.parse(dbmdStoredPropsJson));

@@ -38,3 +39,3 @@ switch (srcLang) {

const outputFile = path.join(sourceOutputDir, 'relations-metadata.ts');
return await (0, mod_1.writeTextFile)(outputFile, autogenWarning + "\n\n" + relationsTSModuleSource(dbmd, preferLowercaseNames), { avoidWritingSameContents: true });
return await (0, files_1.writeTextFile)(outputFile, autogenWarning + "\n\n" + relationsTSModuleSource(dbmd, preferLowercaseNames), { avoidWritingSameContents: true });
}

@@ -45,3 +46,3 @@ case 'Java':

const header = autogenWarning + '\n' + (javaPackage ? `package ${javaPackage};\n\n` : '');
return await (0, mod_1.writeTextFile)(relsMdOutputFile, header + "\n\n" + relationsJavaSource(dbmd, preferLowercaseNames), { avoidWritingSameContents: true });
return await (0, files_1.writeTextFile)(relsMdOutputFile, header + "\n\n" + relationsJavaSource(dbmd, preferLowercaseNames), { avoidWritingSameContents: true });
}

@@ -48,0 +49,0 @@ default: return (0, mod_1.missingCase)(srcLang);

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

import { Nullable } from './util/mod';
import { Nullable } from './util/nullable';
import { QueryGroupSpec, QuerySpec, ResultRepr } from './query-specs';

@@ -6,3 +6,3 @@ import { ResultTypeSpec, ResultTypesSource } from './result-type-generation';

import { QueryPropertiesMetadata } from './query-properties-metadata-generation';
import { DatabaseMetadata } from './dbmd';
import { DatabaseMetadata } from './dbmd/database-metadata';
import { SourceGenerationOptions, SourceLanguage } from './source-generation-options';

@@ -9,0 +9,0 @@ export * from './source-generation-options';

@@ -18,3 +18,4 @@ "use strict";

exports.makeSqlResourceName = exports.generateQueryGroupSources = void 0;
const mod_1 = require("./util/mod");
const property_names_1 = require("./util/property-names");
const collections_1 = require("./util/collections");
const query_specs_1 = require("./query-specs");

@@ -34,3 +35,3 @@ const result_type_generation_1 = require("./result-type-generation");

const unqualNameSchemas = new Set((_a = queryGroupSpec.generateUnqualifiedNamesForSchemas) !== null && _a !== void 0 ? _a : []);
const propNameFn = (0, mod_1.propertyNameDefaultFunction)(queryGroupSpec.propertyNameDefault, dbmd.caseSensitivity);
const propNameFn = (0, property_names_1.propertyNameDefaultFunction)(queryGroupSpec.propertyNameDefault, dbmd.caseSensitivity);
const sqlSpecGen = new sql_spec_generator_1.SqlSpecGenerator(dbmd, defaultSchema, propNameFn);

@@ -41,3 +42,3 @@ const sqlSrcGen = new sql_source_generator_1.SqlSourceGenerator((0, sql_generation_1.getSqlDialect)(dbmd, 2), dbmd.caseSensitivity, unqualNameSchemas);

const sqlSpecsByResultRepr = sqlSpecGen.generateSqlSpecs(query);
const generatedSqlsByResultRepr = (0, mod_1.mapEntries)(sqlSpecsByResultRepr, (resultRepr, sqlSpec) => ({
const generatedSqlsByResultRepr = (0, collections_1.mapEntries)(sqlSpecsByResultRepr, (resultRepr, sqlSpec) => ({
sqlSpec,

@@ -47,5 +48,5 @@ sqlText: sqlSrcGen.makeSql(sqlSpec),

}));
const sqlResourceNames = (0, mod_1.mapValues)(generatedSqlsByResultRepr, genSql => genSql.sqlResourceName);
const sqlResourceNames = (0, collections_1.mapValues)(generatedSqlsByResultRepr, genSql => genSql.sqlResourceName);
const paramNames = (0, query_specs_1.getQueryParamNames)(query);
const firstSqlSpec = (0, mod_1.firstValue)(sqlSpecsByResultRepr);
const firstSqlSpec = (0, collections_1.firstValue)(sqlSpecsByResultRepr);
return {

@@ -71,5 +72,5 @@ query,

specs: resultTypeSpecs,
sourceCodeByLanguage: (0, mod_1.makeMap)(opts.resultTypeLanguages, srcLang => srcLang, srcLang => (0, result_type_generation_1.makeResultTypesSource)(resultTypeSpecs, srcLang, queryName, queryTypesFileHeader, sqlResourceNames, params, opts))
sourceCodeByLanguage: (0, collections_1.makeMap)(opts.resultTypeLanguages, srcLang => srcLang, srcLang => (0, result_type_generation_1.makeResultTypesSource)(resultTypeSpecs, srcLang, queryName, queryTypesFileHeader, sqlResourceNames, params, opts))
};
}
//# sourceMappingURL=lib.js.map

@@ -32,4 +32,5 @@ "use strict";

const fs_1 = require("fs");
const files_1 = require("./util/files");
const args_1 = require("./util/args");
const mod_1 = require("./util/mod");
// import { readDatabaseMetadata } from './dbmd'; TODO
const query_specs_1 = require("./query-specs");

@@ -51,3 +52,3 @@ const lib_1 = require("./lib");

];
const parsedArgs = (0, mod_1.parseArgs)(args, requiredOptions, optionalOptions, 0);
const parsedArgs = (0, args_1.parseArgs)(args, requiredOptions, optionalOptions, 0);
if (typeof parsedArgs === 'string') // arg parsing error

@@ -64,3 +65,3 @@ throw new Error(parsedArgs);

javaPackage: (_a = parsedArgs['javaPackage']) !== null && _a !== void 0 ? _a : '',
javaEmitRecords: (0, mod_1.parseBoolOption)((_b = parsedArgs['javaEmitRecords']) !== null && _b !== void 0 ? _b : 'true', 'javaEmitRecords'),
javaEmitRecords: (0, args_1.parseBoolOption)((_b = parsedArgs['javaEmitRecords']) !== null && _b !== void 0 ? _b : 'true', 'javaEmitRecords'),
javaTypesHeaderFile: parsedArgs['javaTypesHeader'],

@@ -72,3 +73,3 @@ };

throw new Error('An output directory for result types is required.');
await (0, mod_1.requireFileExists)(opts.dbmdFile, 'The database metadata file was not found.');
await (0, files_1.requireFileExists)(opts.dbmdFile, 'The database metadata file was not found.');
await createOutputDirs(opts);

@@ -131,3 +132,3 @@ try {

"-- " + resultRepr + " results representation for " + queryName + "\n";
await (0, mod_1.writeTextFile)(sqlPath, header + genSql.sqlText + '\n', { avoidWritingSameContents: true });
await (0, files_1.writeTextFile)(sqlPath, header + genSql.sqlText + '\n', { avoidWritingSameContents: true });
}

@@ -141,3 +142,3 @@ }

const outputFile = path.join(outputDir, resTypesSrc.compilationUnitName);
await (0, mod_1.writeTextFile)(outputFile, resTypesSrc.sourceCode, { avoidWritingSameContents: true });
await (0, files_1.writeTextFile)(outputFile, resTypesSrc.sourceCode, { avoidWritingSameContents: true });
}

@@ -152,3 +153,3 @@ }

const sqlSpecPath = path.join(outputDir, sqlSpecFileName);
await (0, mod_1.writeTextFile)(sqlSpecPath, JSON.stringify(genSql.sqlSpec, null, 2) + '\n', { avoidWritingSameContents: true });
await (0, files_1.writeTextFile)(sqlSpecPath, JSON.stringify(genSql.sqlSpec, null, 2) + '\n', { avoidWritingSameContents: true });
}

@@ -159,6 +160,6 @@ }

const propsMdPath = path.join(outputDir, fileName);
await (0, mod_1.writeTextFile)(propsMdPath, JSON.stringify(propsMd, null, 2), { avoidWritingSameContents: true });
await (0, files_1.writeTextFile)(propsMdPath, JSON.stringify(propsMd, null, 2), { avoidWritingSameContents: true });
}
async function readDatabaseMetadata(dbmdFile) {
const jsonText = await (0, mod_1.readTextFile)(dbmdFile);
const jsonText = await (0, files_1.readTextFile)(dbmdFile);
const dbmdStoredProps = (0, lib_1.parseStoredDatabaseMetadata)(jsonText);

@@ -187,9 +188,9 @@ return new lib_1.DatabaseMetadata(dbmdStoredProps);

if (tsHeaderFile) {
(0, mod_1.requireFileExists)(tsHeaderFile, 'The TypeScript result types header file was not found.');
res.set('TS', await (0, mod_1.readTextFile)(tsHeaderFile));
(0, files_1.requireFileExists)(tsHeaderFile, 'The TypeScript result types header file was not found.');
res.set('TS', await (0, files_1.readTextFile)(tsHeaderFile));
}
const javaHeaderFile = opts.javaTypesHeaderFile;
if (javaHeaderFile) {
(0, mod_1.requireFileExists)(javaHeaderFile, 'The Java result types header file was not found.');
res.set('Java', await (0, mod_1.readTextFile)(javaHeaderFile));
(0, files_1.requireFileExists)(javaHeaderFile, 'The Java result types header file was not found.');
res.set('Java', await (0, files_1.readTextFile)(javaHeaderFile));
}

@@ -196,0 +197,0 @@ return res;

@@ -1,10 +0,7 @@

export * from './args';
export * from './collections';
export * from './database-names';
export * from './files';
export * from './objects';
export * from './process';
export * from './property-names';
export * from './strings';
export * from './nullable';
export declare function missingCase(caseVal: never): never;
export declare type Nullable<T> = T | null | undefined;

@@ -18,10 +18,8 @@ "use strict";

exports.missingCase = void 0;
__exportStar(require("./args"), exports);
__exportStar(require("./collections"), exports);
__exportStar(require("./database-names"), exports);
__exportStar(require("./files"), exports);
__exportStar(require("./objects"), exports);
__exportStar(require("./process"), exports);
__exportStar(require("./property-names"), exports);
__exportStar(require("./strings"), exports);
__exportStar(require("./nullable"), exports);
function missingCase(caseVal) {

@@ -28,0 +26,0 @@ let _;

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

import { CaseSensitivity } from '../dbmd';
import { CaseSensitivity } from '../dbmd/database-metadata';
import { PropertyNameDefault } from '../query-specs';
export declare function propertyNameDefaultFunction(propNameDefault: PropertyNameDefault | null | undefined, caseSensitivity: CaseSensitivity): (fieldName: string) => string;
{
"name": "sqljson-query",
"version": "1.7.21",
"version": "1.7.22",
"description": "Command line tool to generate SQL/JSON queries and Typescript types for query results.",

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

import * as path from 'path';
import { makeArrayValuesMap, indentLines, missingCase, readTextFile, writeTextFile, Nullable } from '../util/mod';
import { makeArrayValuesMap, indentLines, missingCase, Nullable } from '../util/mod';
import { writeTextFile, readTextFile } from '../util/files';
import { CaseSensitivity, DatabaseMetadata, RelMetadata } from './database-metadata';

@@ -4,0 +5,0 @@ import { SourceLanguage } from '../source-generation-options';

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

import { propertyNameDefaultFunction } from './util/property-names';
import { mapValues, firstValue, mapEntries, makeMap } from './util/collections';
import { Nullable } from './util/nullable';
import {
propertyNameDefaultFunction, mapValues, firstValue, mapEntries, Nullable, makeMap,
} from './util/mod';
import {
getQueryParamNames, QueryGroupSpec, QuerySpec, QueryTypesFileHeader, ResultRepr

@@ -15,3 +15,3 @@ } from './query-specs';

import { QueryPropertiesMetadata, makeQueryPropertiesMetadata } from './query-properties-metadata-generation';
import { DatabaseMetadata } from './dbmd';
import { DatabaseMetadata } from './dbmd/database-metadata';
import { SourceGenerationOptions, SourceLanguage } from './source-generation-options';

@@ -18,0 +18,0 @@

import * as path from 'path';
import { promises as fs } from 'fs';
import {
requireFileExists, writeTextFile, parseArgs, parseBoolOption, replaceAll, readTextFile, Nullable
} from './util/mod';
// import { readDatabaseMetadata } from './dbmd'; TODO
import { requireFileExists, writeTextFile, readTextFile } from './util/files';
import { parseArgs, parseBoolOption } from './util/args';
import { Nullable, replaceAll} from './util/mod';
import { QueryGroupSpec, ResultRepr, SpecError } from './query-specs';
import { SourceGenerationOptions, SourceLanguage } from './source-generation-options';
import { QueryPropertiesMetadata } from './query-properties-metadata-generation';
import { DatabaseMetadata, GeneratedResultTypes, GeneratedSql, generateQueryGroupSources, parseStoredDatabaseMetadata } from './lib';
import {
DatabaseMetadata, GeneratedResultTypes, GeneratedSql, generateQueryGroupSources,
parseStoredDatabaseMetadata
} from './lib';

@@ -12,0 +14,0 @@ export * from './lib';

@@ -1,9 +0,8 @@

export * from './args';
export * from './collections';
export * from './database-names';
export * from './files';
export * from './objects';
export * from './process';
export * from './property-names';
export * from './strings';
export * from './nullable';

@@ -15,4 +14,2 @@ export function missingCase(caseVal: never): never

return _;
}
export type Nullable<T> = T | null | undefined;
}

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

import { CaseSensitivity } from '../dbmd';
import { CaseSensitivity } from '../dbmd/database-metadata';
import { PropertyNameDefault } from '../query-specs';

@@ -3,0 +3,0 @@ import { lowerCamelCase, snakeCase, upperCamelCase } from './strings';

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