Socket
Socket
Sign inDemoInstall

naorm-sqlite

Package Overview
Dependencies
52
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

dist/commonjs/generate/db-wrapper/db-wrapper.test.js

2

dist/commonjs/generate/db-wrapper/sqlite3-wasm-db.js

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

processIndex(sql) {
this.db.prepare(sql).run();
this.db.prepare(sql).stepFinalize();
return [];

@@ -48,0 +48,0 @@ }

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

const computedType = col.computedTypeByConventionSet[conventionSet.name];
const propertyName = `${col.columnName.replace(/"/g, '\\"')}`;
const propertyName = `${col.columnName.replace(/\\"/g, '\\\\"').replace(/"/g, '\\"')}`;
const type = `${computedType}${col.isExplicitlyNotNull ? '' : ' | null'}`;

@@ -53,3 +53,4 @@ return `${jsDocComment}\t"${propertyName}": ${type};`;

const extendsStr = conventionSet.extends || '';
const modelString = parsedStatement.preStatementJSDoc +
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const modelString = jsDocComment +
`export ${conventionSet.typescriptConstruct} ${varName} ${extendsStr} {`

@@ -60,3 +61,3 @@ + `\n${resultColumns.join('\n')}` + '\n};';

function generateColumnArrayString(parsedStatement, varName) {
const jsDocComment = parsedStatement.preStatementJSDoc ? parsedStatement.preStatementJSDoc.trim() + '\n' : '';
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const columnsJSON = JSON.stringify(parsedStatement.resultColumns, null, '\t');

@@ -67,7 +68,11 @@ const arrayString = `${jsDocComment}export const ${varName} = ${columnsJSON};`;

function generateSourceSQLStatement(parsedStatement, sqlVarName) {
const escapedSQLStatement = parsedStatement.statement.replace(/`/g, "\\`");
const sourceSQLString = parsedStatement.preStatementJSDoc +
const escapedSQLStatement = parsedStatement.statement.replace(/\\`/g, '\\\\`').replace(/`/g, '\\`');
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const sourceSQLString = jsDocComment +
`export const ${sqlVarName} = \`${escapedSQLStatement}\`;`;
return sourceSQLString;
}
function getJSDocComment(preStatementJSDoc) {
return preStatementJSDoc ? preStatementJSDoc.trim() + '\n' : '';
}
function getBatchArrayExport(fileIdentifier, sqlStatementStringIds) {

@@ -74,0 +79,0 @@ const batchArrayExport = `export const ${fileIdentifier}Statements = [`

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

const path_1 = require("path");
const url_1 = require("url");
const default_config_js_1 = require("./default-config.js");

@@ -52,7 +53,16 @@ const enquirer_1 = __importDefault(require("enquirer"));

const { gitIgnore } = yield prompt({ name: 'gitIgnore', type: 'confirm', message: 'Add naorm-generated directory to gitignore?', initial: true });
const schemaFilePath = (0, path_1.join)(__dirname, '..', 'naorm-config.schema.json');
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const fileName = global.__filename ? __filename : (0, url_1.fileURLToPath)(import.meta.url);
const schemaFilePath = (0, path_1.join)(fileName, '..', '..', '..', 'naorm-config.schema.json');
const outFile = (0, path_1.join)(configDir, 'naorm-config.json');
const outFileContent = Object.assign({ $schema: `.${path_1.posix.sep}${(0, path_1.relative)(configDir, schemaFilePath).split(path_1.sep).join(path_1.posix.sep)}` }, default_config_js_1.DEFAULT_NAORM_CONFIG);
if (!useRecommended) {
outFileContent.conventionSets = [];
outFileContent.conventionSets = [{
name: '',
typescriptConstruct: 'interface',
extends: null,
importStatements: [],
typeConventions: [],
}];
}

@@ -59,0 +69,0 @@ (0, fs_1.writeFileSync)(outFile, JSON.stringify(outFileContent, null, '\t'));

@@ -42,3 +42,3 @@ import { BaseDB } from './base-db.js';

processIndex(sql) {
this.db.prepare(sql).run();
this.db.prepare(sql).stepFinalize();
return [];

@@ -45,0 +45,0 @@ }

@@ -41,3 +41,3 @@ import { join } from 'path';

const computedType = col.computedTypeByConventionSet[conventionSet.name];
const propertyName = `${col.columnName.replace(/"/g, '\\"')}`;
const propertyName = `${col.columnName.replace(/\\"/g, '\\\\"').replace(/"/g, '\\"')}`;
const type = `${computedType}${col.isExplicitlyNotNull ? '' : ' | null'}`;

@@ -49,3 +49,4 @@ return `${jsDocComment}\t"${propertyName}": ${type};`;

const extendsStr = conventionSet.extends || '';
const modelString = parsedStatement.preStatementJSDoc +
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const modelString = jsDocComment +
`export ${conventionSet.typescriptConstruct} ${varName} ${extendsStr} {`

@@ -56,3 +57,3 @@ + `\n${resultColumns.join('\n')}` + '\n};';

function generateColumnArrayString(parsedStatement, varName) {
const jsDocComment = parsedStatement.preStatementJSDoc ? parsedStatement.preStatementJSDoc.trim() + '\n' : '';
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const columnsJSON = JSON.stringify(parsedStatement.resultColumns, null, '\t');

@@ -63,7 +64,11 @@ const arrayString = `${jsDocComment}export const ${varName} = ${columnsJSON};`;

function generateSourceSQLStatement(parsedStatement, sqlVarName) {
const escapedSQLStatement = parsedStatement.statement.replace(/`/g, "\\`");
const sourceSQLString = parsedStatement.preStatementJSDoc +
const escapedSQLStatement = parsedStatement.statement.replace(/\\`/g, '\\\\`').replace(/`/g, '\\`');
const jsDocComment = getJSDocComment(parsedStatement.preStatementJSDoc);
const sourceSQLString = jsDocComment +
`export const ${sqlVarName} = \`${escapedSQLStatement}\`;`;
return sourceSQLString;
}
function getJSDocComment(preStatementJSDoc) {
return preStatementJSDoc ? preStatementJSDoc.trim() + '\n' : '';
}
function getBatchArrayExport(fileIdentifier, sqlStatementStringIds) {

@@ -70,0 +75,0 @@ const batchArrayExport = `export const ${fileIdentifier}Statements = [`

@@ -12,2 +12,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { join, relative, sep, posix } from 'path';
import { fileURLToPath } from 'url';
import { DEFAULT_NAORM_CONFIG } from './default-config.js';

@@ -46,7 +47,16 @@ import enquirer from 'enquirer';

const { gitIgnore } = yield prompt({ name: 'gitIgnore', type: 'confirm', message: 'Add naorm-generated directory to gitignore?', initial: true });
const schemaFilePath = join(__dirname, '..', 'naorm-config.schema.json');
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const fileName = global.__filename ? __filename : fileURLToPath(import.meta.url);
const schemaFilePath = join(fileName, '..', '..', '..', 'naorm-config.schema.json');
const outFile = join(configDir, 'naorm-config.json');
const outFileContent = Object.assign({ $schema: `.${posix.sep}${relative(configDir, schemaFilePath).split(sep).join(posix.sep)}` }, DEFAULT_NAORM_CONFIG);
if (!useRecommended) {
outFileContent.conventionSets = [];
outFileContent.conventionSets = [{
name: '',
typescriptConstruct: 'interface',
extends: null,
importStatements: [],
typeConventions: [],
}];
}

@@ -53,0 +63,0 @@ writeFileSync(outFile, JSON.stringify(outFileContent, null, '\t'));

{
"name": "naorm-sqlite",
"version": "0.2.0",
"version": "0.2.1",
"description": "A Command-Line Interface that generates TypeScript code from SQLite files in your code base.",

@@ -55,3 +55,3 @@ "keywords": [

"jest": "^29.3.1",
"rimraf": "^3.0.2",
"rimraf": "^4.0.5",
"semantic-release": "^20.0.2",

@@ -66,6 +66,6 @@ "ts-jest": "^29.0.3",

"camel-case": "~4.1.2",
"commander": "~9.4.1",
"commander": "~10.0.0",
"enquirer": "~2.3.6",
"glob": "~8.0.3"
"glob": "~8.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc