diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..d784c54b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,20 @@ +*.html +*.yml +*.yaml +*.css +*.scss +*.md +*.markdown + +package/lib + +.well-known +android +ios +vendor +package.json +package-lock.json + +# The GH actions don't seem to compile and verify themselves well when Prettier is applied to them +.github/actions/javascript/**/index.js + diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..5bf7d205 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,9 @@ +module.exports = { + quoteProps: 'consistent', + singleQuote: true, + tabWidth: 2, + trailingComma: 'all', + useTabs: false, + singleAttributePerLine: true, + semi: false, +} diff --git a/.watchmanconfig b/.watchmanconfig index 9e26dfee..0967ef42 100644 --- a/.watchmanconfig +++ b/.watchmanconfig @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/config/.eslintrc.js b/config/.eslintrc.js index 4591ef3e..115d916f 100644 --- a/config/.eslintrc.js +++ b/config/.eslintrc.js @@ -1,18 +1,22 @@ module.exports = { root: true, ignorePatterns: [ - "**/node_modules", - "**/lib", - "**/.eslintrc.js", - "**/.prettierrc.js", - "**/jest.config.js", - "**/babel.config.js", - "**/metro.config.js", - "**/react-native.config.js", - "**/tsconfig.json" + '**/node_modules', + '**/lib', + '**/.eslintrc.js', + '**/.prettierrc.js', + '**/jest.config.js', + '**/babel.config.js', + '**/metro.config.js', + '**/react-native.config.js', + '**/tsconfig.json', ], - extends: ['@react-native','plugin:prettier/recommended'], - plugins: ['@typescript-eslint', 'prettier'], + extends: [ + '@react-native', + 'plugin:prettier/recommended', + 'plugin:@typescript-eslint/recommended', + ], + plugins: ['@typescript-eslint', 'jest'], parser: '@typescript-eslint/parser', parserOptions: { project: true, @@ -23,17 +27,4 @@ module.exports = { ecmaVersion: 2018, sourceType: 'module', }, - rules: { - 'prettier/prettier': [ - 'warn', - { - quoteProps: 'consistent', - singleQuote: true, - tabWidth: 2, - trailingComma: 'es5', - useTabs: false, - semi: false, - }, - ], - }, } diff --git a/example/.eslintrc.js b/example/.eslintrc.js index 9253aa34..9cf69884 100644 --- a/example/.eslintrc.js +++ b/example/.eslintrc.js @@ -5,4 +5,4 @@ module.exports = { project: true, tsconfigRootDir: __dirname, }, -}; +} diff --git a/example/.watchmanconfig b/example/.watchmanconfig index 9e26dfee..0967ef42 100644 --- a/example/.watchmanconfig +++ b/example/.watchmanconfig @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/example/babel.config.js b/example/babel.config.js index 3ca7ebaf..3e72a2e8 100644 --- a/example/babel.config.js +++ b/example/babel.config.js @@ -1,5 +1,5 @@ -const path = require('path'); -const pak = require('../package/package.json'); +const path = require('path') +const pak = require('../package/package.json') module.exports = { presets: ['module:@react-native/babel-preset'], @@ -10,12 +10,12 @@ module.exports = { extensions: ['.tsx', '.ts', '.js', '.json'], alias: { [pak.name]: path.join(__dirname, '../package', pak.source), - stream: 'stream-browserify', + 'stream': 'stream-browserify', 'react-native-sqlite-storage': 'react-native-nitro-sqlite', }, }, ], 'babel-plugin-transform-typescript-metadata', - ['@babel/plugin-proposal-decorators', {legacy: true}], + ['@babel/plugin-proposal-decorators', { legacy: true }], ], -}; +} diff --git a/example/metro.config.js b/example/metro.config.js index adf041c0..46d8edbb 100644 --- a/example/metro.config.js +++ b/example/metro.config.js @@ -1,42 +1,42 @@ -const fs = require('fs'); -const path = require('path'); -const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); -const exclusionList = require('metro-config/src/defaults/exclusionList'); -const escape = require('escape-string-regexp'); +const fs = require('fs') +const path = require('path') +const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config') +const exclusionList = require('metro-config/src/defaults/exclusionList') +const escape = require('escape-string-regexp') -const root = path.resolve(__dirname, '..'); -const rootNodeModulesPath = path.join(root, 'node_modules'); -const exampleNodeModulesPath = path.join(__dirname, 'node_modules'); +const root = path.resolve(__dirname, '..') +const rootNodeModulesPath = path.join(root, 'node_modules') +const exampleNodeModulesPath = path.join(__dirname, 'node_modules') function getPackageNames(nodeModulesPath) { if (!fs.existsSync(nodeModulesPath)) { - return []; + return [] } - const allFiles = fs.readdirSync(nodeModulesPath); + const allFiles = fs.readdirSync(nodeModulesPath) // Filter out only directories (package names) - const packageNames = allFiles.filter(file => { - const filePath = path.join(nodeModulesPath, file); - return fs.statSync(filePath).isDirectory(); - }); + const packageNames = allFiles.filter((file) => { + const filePath = path.join(nodeModulesPath, file) + return fs.statSync(filePath).isDirectory() + }) // Handle scoped packages (e.g., @scope/package) const scopedPackages = packageNames - .filter(pkg => pkg.startsWith('@')) - .flatMap(scope => { - const scopePath = path.join(nodeModulesPath, scope); - const scopedFiles = fs.readdirSync(scopePath); - return scopedFiles.map(scopedFile => `${scope}/${scopedFile}`); - }); + .filter((pkg) => pkg.startsWith('@')) + .flatMap((scope) => { + const scopePath = path.join(nodeModulesPath, scope) + const scopedFiles = fs.readdirSync(scopePath) + return scopedFiles.map((scopedFile) => `${scope}/${scopedFile}`) + }) // Return both regular and scoped package names return packageNames - .filter(pkg => !pkg.startsWith('@')) - .concat(scopedPackages); + .filter((pkg) => !pkg.startsWith('@')) + .concat(scopedPackages) } -const exampleNodeModules = getPackageNames(exampleNodeModulesPath); +const exampleNodeModules = getPackageNames(exampleNodeModulesPath) const config = { projectRoot: __dirname, @@ -48,7 +48,8 @@ const config = { unstable_enableSymlinks: true, blockList: exclusionList( exampleNodeModules.map( - m => new RegExp(`^${escape(path.join(rootNodeModulesPath, m))}\\/.*$`), + (m) => + new RegExp(`^${escape(path.join(rootNodeModulesPath, m))}\\/.*$`), ), ), @@ -70,6 +71,6 @@ const config = { }, }), }, -}; +} -module.exports = mergeConfig(getDefaultConfig(__dirname), config); +module.exports = mergeConfig(getDefaultConfig(__dirname), config) diff --git a/example/react-native.config.js b/example/react-native.config.js index 4b34e552..de42b61e 100644 --- a/example/react-native.config.js +++ b/example/react-native.config.js @@ -1,5 +1,5 @@ -const path = require('path'); -const pak = require('../package/package.json'); +const path = require('path') +const pak = require('../package/package.json') module.exports = { dependencies: { @@ -7,4 +7,4 @@ module.exports = { root: path.join(__dirname, '../package'), }, }, -}; +} diff --git a/example/src/App.tsx b/example/src/App.tsx index c044f64d..507bb35a 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -11,9 +11,18 @@ export default function App() { return ( - - - + + + diff --git a/example/src/initGlobals.ts b/example/src/initGlobals.ts index c40bfc37..e93d1887 100644 --- a/example/src/initGlobals.ts +++ b/example/src/initGlobals.ts @@ -1,11 +1,12 @@ import { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer' declare global { + // eslint-disable-next-line no-var var Buffer: typeof CraftzdogBuffer } if (!globalThis.process) { - // @ts-expect-error + // @ts-expect-error - if process is not defined, we need to set it to an empty object globalThis.process = {} } diff --git a/example/src/screens/BenchmarkScreen.tsx b/example/src/screens/BenchmarkScreen.tsx index 42774410..2602fbfe 100644 --- a/example/src/screens/BenchmarkScreen.tsx +++ b/example/src/screens/BenchmarkScreen.tsx @@ -36,13 +36,13 @@ const benchmarks: Benchmark[] = [ resetTestDb() testDb?.execute('DROP TABLE IF EXISTS User;') testDb?.execute( - 'CREATE TABLE User ( id REAL PRIMARY KEY, name TEXT NOT NULL, age REAL, networth REAL) STRICT;' + 'CREATE TABLE User ( id REAL PRIMARY KEY, name TEXT NOT NULL, age REAL, networth REAL) STRICT;', ) }, run: (i) => { testDb?.execute( 'INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', - [ids[i], stringValue, integerValue, doubleValue] + [ids[i], stringValue, integerValue, doubleValue], ) }, }, @@ -126,7 +126,10 @@ export function BenchmarkScreen() { benchmarks.map(({ description }, index) => { const time = results[description] return ( - + ) }), - [results] + [results], ) return ( diff --git a/example/src/screens/UnitTestScreen.tsx b/example/src/screens/UnitTestScreen.tsx index 15c6f103..84d79103 100644 --- a/example/src/screens/UnitTestScreen.tsx +++ b/example/src/screens/UnitTestScreen.tsx @@ -11,7 +11,7 @@ export function UnitTestScreen() { useEffect(() => { setResults([]) runTests( - registerUnitTests + registerUnitTests, // registerTypeORMTests ).then(setResults) }, []) diff --git a/example/src/tests/MochaRNAdapter.ts b/example/src/tests/MochaRNAdapter.ts index 1f3878ba..0d25e303 100644 --- a/example/src/tests/MochaRNAdapter.ts +++ b/example/src/tests/MochaRNAdapter.ts @@ -16,7 +16,7 @@ export const clearTests = () => { export const it = ( name: string, - f: MochaTypes.Func | MochaTypes.AsyncFunc + f: MochaTypes.Func | MochaTypes.AsyncFunc, ): void => { if (!only) { const test = new Mocha.Test(name, f) @@ -26,7 +26,7 @@ export const it = ( export const itOnly = ( name: string, - f: MochaTypes.Func | MochaTypes.AsyncFunc + f: MochaTypes.Func | MochaTypes.AsyncFunc, ): void => { clearTests() const test = new Mocha.Test(name, f) diff --git a/example/src/tests/db.ts b/example/src/tests/db.ts index c1b75a44..6e4e354c 100644 --- a/example/src/tests/db.ts +++ b/example/src/tests/db.ts @@ -38,7 +38,7 @@ export function resetLargeDb() { }) largeDb.execute( - 'CREATE TABLE Test ( id INT PRIMARY KEY, v1 TEXT, v2 TEXT, v3 TEXT, v4 TEXT, v5 TEXT, v6 INT, v7 INT, v8 INT, v9 INT, v10 INT, v11 REAL, v12 REAL, v13 REAL, v14 REAL) STRICT;' + 'CREATE TABLE Test ( id INT PRIMARY KEY, v1 TEXT, v2 TEXT, v3 TEXT, v4 TEXT, v5 TEXT, v6 INT, v7 INT, v8 INT, v9 INT, v10 INT, v11 REAL, v12 REAL, v13 REAL, v14 REAL) STRICT;', ) largeDb.execute('PRAGMA mmap_size=268435456') diff --git a/example/src/tests/unitTests.spec.ts b/example/src/tests/unitTests.spec.ts index ec60115e..45b4aa07 100644 --- a/example/src/tests/unitTests.spec.ts +++ b/example/src/tests/unitTests.spec.ts @@ -31,7 +31,7 @@ export function registerUnitTests() { testDbInternal.execute('DROP TABLE IF EXISTS User;') testDbInternal.execute( - 'CREATE TABLE User ( id REAL PRIMARY KEY, name TEXT NOT NULL, age REAL, networth REAL) STRICT;' + 'CREATE TABLE User ( id REAL PRIMARY KEY, name TEXT NOT NULL, age REAL, networth REAL) STRICT;', ) testDb = testDbInternal! @@ -48,7 +48,7 @@ export function registerUnitTests() { const networth = chance.floating() const res = testDb.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -65,7 +65,7 @@ export function registerUnitTests() { const networth = NITRO_SQLITE_NULL const res = testDb.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -94,7 +94,7 @@ export function registerUnitTests() { const networth = null const res = testDb.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -121,7 +121,7 @@ export function registerUnitTests() { const networth = chance.floating() testDb.execute( 'INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) const res = testDb.execute('SELECT * FROM User') @@ -145,7 +145,7 @@ export function registerUnitTests() { const networth = chance.floating() testDb.execute( 'INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) const res = testDb.execute('SELECT * FROM User WHERE id = ?', [id]) @@ -171,12 +171,12 @@ export function registerUnitTests() { try { testDb.execute( 'INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) } catch (e: unknown) { if (isError(e)) { expect(e.message).to.include( - 'cannot store TEXT value in REAL column User.age' + 'cannot store TEXT value in REAL column User.age', ) } else { expect.fail('Should have thrown a valid NitroSQLiteException') @@ -193,7 +193,7 @@ export function registerUnitTests() { await testDb.transaction((tx) => { const res = tx.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -223,7 +223,7 @@ export function registerUnitTests() { await testDb.transaction((tx) => { const res = tx.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -271,13 +271,13 @@ export function registerUnitTests() { WHERE [id] = ? ), 0) `, - [id, name, age, id] + [id, name, age, id], ) // ACT: Select statement to get incremented value and store it for checking later const results = tx.execute( 'SELECT [networth] FROM [User] WHERE [id] = ?', - [id] + [id], ) const row = results.rows?._array[0] as User | undefined @@ -296,7 +296,7 @@ export function registerUnitTests() { .map((_, index) => index * 1000) expect(actual).to.eql( expected, - 'Each transaction should read a different value' + 'Each transaction should read a different value', ) }) @@ -309,7 +309,7 @@ export function registerUnitTests() { await testDb.transaction((tx) => { const res = tx.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -348,7 +348,7 @@ export function registerUnitTests() { try { tx.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) } catch { tx.rollback() @@ -367,7 +367,7 @@ export function registerUnitTests() { try { testDb.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) } catch (e: unknown) { expect(e).to.not.equal(undefined) @@ -383,7 +383,7 @@ export function registerUnitTests() { await testDb.transaction((tx) => { tx.execute( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) tx.rollback() const res = testDb.execute('SELECT * FROM User') @@ -448,7 +448,7 @@ export function registerUnitTests() { await testDb.transaction(async (tx) => { const res = await tx.executeAsync( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) expect(res.rowsAffected).to.equal(1) @@ -479,7 +479,7 @@ export function registerUnitTests() { await testDb.transaction(async (tx) => { await tx.executeAsync( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) }) } catch (e) { @@ -505,7 +505,7 @@ export function registerUnitTests() { await testDb.transaction(async (tx) => { await tx.executeAsync( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) tx.commit() }) @@ -530,7 +530,7 @@ export function registerUnitTests() { await testDb.transaction(async (tx) => { await tx.executeAsync( 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth] + [id, name, age, networth], ) tx.rollback() }) @@ -564,13 +564,13 @@ export function registerUnitTests() { WHERE [id] = ? ), 0) `, - [id, name, age, id] + [id, name, age, id], ) // ACT: Select statement to get incremented value and store it for checking later const results = await tx.executeAsync( 'SELECT [networth] FROM [User] WHERE [id] = ?', - [id] + [id], ) const row = results.rows?._array[0] as User | undefined @@ -589,7 +589,7 @@ export function registerUnitTests() { .map((_, index) => index * 1000) expect(actual).to.eql( expected, - 'Each transaction should read a different value' + 'Each transaction should read a different value', ) }) diff --git a/package.json b/package.json index e70e9086..b14ba7ca 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "typecheck": "bun --filter=\"**\" typecheck", "lint": "bun package lint && bun example lint", "lint-cpp": "./scripts/clang-format.sh", + "prettier": "prettier --write .", "clean": "rm -rf **/tsconfig.tsbuildinfo node_modules package/node_module package/lib", "release": "./scripts/release.sh", "package": "bun --cwd package", diff --git a/package/.watchmanconfig b/package/.watchmanconfig index 9e26dfee..0967ef42 100644 --- a/package/.watchmanconfig +++ b/package/.watchmanconfig @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/package/nitro.json b/package/nitro.json index ee57c018..25621890 100644 --- a/package/nitro.json +++ b/package/nitro.json @@ -1,14 +1,10 @@ { - "cxxNamespace": [ - "rnnitrosqlite" - ], + "cxxNamespace": ["rnnitrosqlite"], "ios": { "iosModuleName": "RNNitroSQLite" }, "android": { - "androidNamespace": [ - "rnnitrosqlite" - ], + "androidNamespace": ["rnnitrosqlite"], "androidCxxLibName": "RNNitroSQLite" }, "autolinking": { @@ -19,9 +15,5 @@ "kotlin": "HybridNitroSQLiteOnLoad" } }, - "ignorePaths": [ - "node_modules", - "example", - "lib" - ] + "ignorePaths": ["node_modules", "example", "lib"] } diff --git a/package/src/nullHandling.ts b/package/src/nullHandling.ts index 48750def..d5675d3f 100644 --- a/package/src/nullHandling.ts +++ b/package/src/nullHandling.ts @@ -4,7 +4,7 @@ import { SQLiteQueryParamItem } from './types' let ENABLE_SIMPLE_NULL_HANDLING = false export function enableSimpleNullHandling( - shouldEnableSimpleNullHandling = true + shouldEnableSimpleNullHandling = true, ) { ENABLE_SIMPLE_NULL_HANDLING = shouldEnableSimpleNullHandling } @@ -22,7 +22,7 @@ export function isNitroSQLiteNull(value: any): value is SQLiteNullValue { } export function replaceWithNativeNullValue( - value: SQLiteQueryParamItem + value: SQLiteQueryParamItem, ): SQLiteValue { if (value === undefined || value === null) { return NITRO_SQLITE_NULL diff --git a/package/src/operations/execute.ts b/package/src/operations/execute.ts index 0b708198..0b8e2b92 100644 --- a/package/src/operations/execute.ts +++ b/package/src/operations/execute.ts @@ -12,7 +12,7 @@ import type { export function execute( dbName: string, query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): QueryResult { const transformedParams = isSimpleNullHandlingEnabled() ? toNativeQueryParams(params) @@ -21,7 +21,7 @@ export function execute( const nativeResult = HybridNitroSQLite.execute( dbName, query, - transformedParams + transformedParams, ) const result = buildJsQueryResult(nativeResult) return result @@ -30,7 +30,7 @@ export function execute( export async function executeAsync( dbName: string, query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): Promise> { const transformedParams = isSimpleNullHandlingEnabled() ? toNativeQueryParams(params) @@ -39,14 +39,14 @@ export async function executeAsync( const nativeResult = await HybridNitroSQLite.executeAsync( dbName, query, - transformedParams + transformedParams, ) const result = buildJsQueryResult(nativeResult) return result } function toNativeQueryParams( - params: SQLiteQueryParams | undefined + params: SQLiteQueryParams | undefined, ): NativeSQLiteQueryParams | undefined { return params?.map((param) => replaceWithNativeNullValue(param)) } @@ -66,8 +66,8 @@ function buildJsQueryResult({ return [key, null] } return [key, value] - }) - ) + }), + ), ) as Row[] } diff --git a/package/src/operations/executeBatch.ts b/package/src/operations/executeBatch.ts index b31aafee..48cd683d 100644 --- a/package/src/operations/executeBatch.ts +++ b/package/src/operations/executeBatch.ts @@ -12,7 +12,7 @@ import type { export function executeBatch( dbName: string, - commands: BatchQueryCommand[] + commands: BatchQueryCommand[], ): BatchQueryResult { const transformedCommands = isSimpleNullHandlingEnabled() ? toNativeBatchQueryCommands(commands) @@ -24,7 +24,7 @@ export function executeBatch( export async function executeBatchAsync( dbName: string, - commands: BatchQueryCommand[] + commands: BatchQueryCommand[], ): Promise { const transformedCommands = isSimpleNullHandlingEnabled() ? toNativeBatchQueryCommands(commands) @@ -32,13 +32,13 @@ export async function executeBatchAsync( const result = await HybridNitroSQLite.executeBatchAsync( dbName, - transformedCommands + transformedCommands, ) return result } function toNativeBatchQueryCommands( - commands: BatchQueryCommand[] + commands: BatchQueryCommand[], ): NativeBatchQueryCommand[] { return commands.map((command) => { const transformedParams = command.params?.map((param) => { diff --git a/package/src/operations/session.ts b/package/src/operations/session.ts index 7ac3d7c1..7d8ac8ec 100644 --- a/package/src/operations/session.ts +++ b/package/src/operations/session.ts @@ -13,7 +13,7 @@ import { execute, executeAsync } from './execute' import { executeBatch, executeBatchAsync } from './executeBatch' export function open( - options: NitroSQLiteConnectionOptions + options: NitroSQLiteConnectionOptions, ): NitroSQLiteConnection { openDb(options.name, options.location) @@ -27,11 +27,11 @@ export function open( transaction(options.name, fn), execute: ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): QueryResult => execute(options.name, query, params), executeAsync: ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): Promise> => executeAsync(options.name, query, params), executeBatch: (commands: BatchQueryCommand[]) => executeBatch(options.name, commands), diff --git a/package/src/operations/transaction.ts b/package/src/operations/transaction.ts index b4b07ad2..be1a3f04 100644 --- a/package/src/operations/transaction.ts +++ b/package/src/operations/transaction.ts @@ -22,7 +22,7 @@ export interface PendingTransaction { export const transaction = ( dbName: string, - fn: (tx: Transaction) => Promise | void + fn: (tx: Transaction) => Promise | void, ): Promise => { if (locks[dbName] == null) throw Error(`Nitro SQLite Error: No lock found on db: ${dbName}`) @@ -32,11 +32,11 @@ export const transaction = ( // Local transaction context object implementation const executeOnTransaction = ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): QueryResult => { if (isFinalized) { throw Error( - `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}` + `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`, ) } return execute(dbName, query, params) @@ -44,11 +44,11 @@ export const transaction = ( const executeAsyncOnTransaction = ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ): Promise> => { if (isFinalized) { throw Error( - `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}` + `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`, ) } return executeAsync(dbName, query, params) @@ -57,7 +57,7 @@ export const transaction = ( const commit = () => { if (isFinalized) { throw Error( - `Nitro SQLite Error: Cannot execute commit on finalized transaction: ${dbName}` + `Nitro SQLite Error: Cannot execute commit on finalized transaction: ${dbName}`, ) } const result = HybridNitroSQLite.execute(dbName, 'COMMIT') @@ -68,7 +68,7 @@ export const transaction = ( const rollback = () => { if (isFinalized) { throw Error( - `Nitro SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}` + `Nitro SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}`, ) } const result = HybridNitroSQLite.execute(dbName, 'ROLLBACK') diff --git a/package/src/specs/NitroSQLite.nitro.ts b/package/src/specs/NitroSQLite.nitro.ts index 8fc3b762..fdeb72dd 100644 --- a/package/src/specs/NitroSQLite.nitro.ts +++ b/package/src/specs/NitroSQLite.nitro.ts @@ -16,26 +16,26 @@ export interface NitroSQLite mainDbName: string, dbNameToAttach: string, alias: string, - location?: string + location?: string, ): void detach(mainDbName: string, alias: string): void execute( dbName: string, query: string, - params?: NativeSQLiteQueryParams + params?: NativeSQLiteQueryParams, ): NativeQueryResult executeAsync( dbName: string, query: string, - params?: NativeSQLiteQueryParams + params?: NativeSQLiteQueryParams, ): Promise executeBatch( dbName: string, - commands: NativeBatchQueryCommand[] + commands: NativeBatchQueryCommand[], ): BatchQueryResult executeBatchAsync( dbName: string, - commands: NativeBatchQueryCommand[] + commands: NativeBatchQueryCommand[], ): Promise loadFile(dbName: string, location: string): FileLoadResult loadFileAsync(dbName: string, location: string): Promise diff --git a/package/src/typeORM.ts b/package/src/typeORM.ts index 3b84e221..20b30b8c 100644 --- a/package/src/typeORM.ts +++ b/package/src/typeORM.ts @@ -18,7 +18,7 @@ interface TypeOrmNitroSQLiteConnection { sql: string, params: SQLiteQueryParams | undefined, okExecute: (res: QueryResult) => void, - failExecute: (msg: string) => void + failExecute: (msg: string) => void, ) => Promise transaction: (fn: (tx: Transaction) => Promise) => Promise close: (okClose: () => void, failClose: (e: unknown) => void) => void @@ -26,7 +26,7 @@ interface TypeOrmNitroSQLiteConnection { dbNameToAttach: string, alias: string, location: string | undefined, - callback: () => void + callback: () => void, ) => void detach: (alias: string, callback: () => void) => void } @@ -42,7 +42,7 @@ export const typeORMDriver = { location?: string }, ok: (db: TypeOrmNitroSQLiteConnection) => void, - fail: (msg: string) => void + fail: (msg: string) => void, ): TypeOrmNitroSQLiteConnection | null => { try { const db = Operations.open(options) @@ -52,7 +52,7 @@ export const typeORMDriver = { sql: string, params: SQLiteQueryParams | undefined, okExecute: (res: QueryResult) => void, - failExecute: (msg: string) => void + failExecute: (msg: string) => void, ) => { try { const result = await db.executeAsync(sql, params) @@ -62,7 +62,7 @@ export const typeORMDriver = { } }, transaction: ( - fn: (tx: Transaction) => Promise + fn: (tx: Transaction) => Promise, ): Promise => { return db.transaction(fn) }, @@ -78,7 +78,7 @@ export const typeORMDriver = { dbNameToAttach: string, alias: string, location: string | undefined, - callback: () => void + callback: () => void, ) => { db.attach(dbNameToAttach, alias, location) callback() diff --git a/package/src/types.ts b/package/src/types.ts index ec16f3ad..26e80f1b 100644 --- a/package/src/types.ts +++ b/package/src/types.ts @@ -67,12 +67,12 @@ export interface QueryResult { export type ExecuteQuery = ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ) => QueryResult export type ExecuteAsyncQuery = ( query: string, - params?: SQLiteQueryParams + params?: SQLiteQueryParams, ) => Promise> export interface Transaction {