Skip to content

Commit 4a4fead

Browse files
Additional metadata specified in protocol
Removed ack for chunked responses Removed sqlitemode connection arg https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md
1 parent a1115f7 commit 4a4fead

File tree

6 files changed

+21
-26
lines changed

6 files changed

+21
-26
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sqlitecloud-js
1+
# @sqlitecloud/drivers
22

33
[![npm package][npm-img]][npm-url]
44
[![Build Status][build-img]][build-url]
@@ -9,13 +9,13 @@
99
## Install
1010

1111
```bash
12-
npm install sqlitecloud-js
12+
npm install @sqlitecloud/drivers
1313
```
1414

1515
## Usage
1616

1717
```ts
18-
import { Database } from 'sqlitecloud-js'
18+
import { Database } from '@sqlitecloud/drivers'
1919

2020
let database = new Database('sqlitecloud://user:password@xxx.sqlite.cloud:8860/chinook.db')
2121

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "sqlitecloud-js",
3-
"version": "0.0.33",
2+
"name": "@sqlitecloud/drivers",
3+
"version": "0.0.35",
44
"description": "SQLiteCloud drivers for Typescript/Javascript in edge, web and node clients",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"test": "jest --coverage",
1212
"build": "rm -rf ./lib/ && tsc --project tsconfig.build.json && npx webpack",
13-
"publish": "npm run build && npm publish",
13+
"publish": "npm run build && npm publish --access public",
1414
"prettier": "prettier --write 'src/**/*'",
1515
"lint": "eslint ./src/ --fix && tsc --noEmit",
1616
"typedoc": "rm -rf ./docs/ && typedoc --out docs && typedoc --plugin typedoc-plugin-markdown --out docs/markdown",

src/connection.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export class SQLiteCloudConnection {
113113
config.compression = parseBoolean(config.compression)
114114
config.createDatabase = parseBoolean(config.createDatabase)
115115
config.nonlinearizable = parseBoolean(config.nonlinearizable)
116-
config.sqliteMode = parseBoolean(config.sqliteMode)
117116

118117
if (!config.username || !config.password || !config.host) {
119118
console.error('SQLiteCloudConnection.validateConfiguration - missing arguments', config)
@@ -251,9 +250,6 @@ export function getInitializationCommands(config: SQLiteCloudConfig): string {
251250
}
252251
commands += `USE DATABASE ${config.database}; `
253252
}
254-
if (config.sqliteMode) {
255-
commands += 'SET CLIENT KEY SQLITE TO 1; '
256-
}
257253
if (config.compression) {
258254
commands += 'SET CLIENT KEY COMPRESSION TO 1; '
259255
}

src/transport-tls.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ export class TlsSocketTransport implements ConnectionTransport {
185185
// no ending string? ask server for another chunk
186186
rowsetChunks.push(buffer)
187187
buffer = Buffer.alloc(0)
188-
const okCommand = formatCommand('OK')
189-
this.socket?.write(okCommand)
188+
189+
// no longer need to ack the server
190+
// const okCommand = formatCommand('OK')
191+
// this.socket?.write(okCommand)
190192
}
191193
}
192194
}
@@ -374,6 +376,11 @@ function parseRowsetColumnsMetadata(buffer: Buffer, metadata: SQLCloudRowsetMeta
374376
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].database = popForward() as string
375377
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].table = popForward() as string
376378
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].column = popForward() as string // original column name
379+
380+
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].notNull = popForward() as boolean
381+
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].primaryKey = popForward() as boolean
382+
for (let i = 0; i < metadata.numberOfColumns; i++) metadata.columns[i].autoIncrement = popForward() as boolean
383+
console.debug('metadata', metadata)
377384
}
378385

379386
return buffer

src/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export interface SQLiteCloudConfig {
2929
createDatabase?: boolean
3030
/** Database will be created in memory */
3131
dbMemory?: boolean
32-
/** Enable SQLite compatibility mode */
33-
sqliteMode?: boolean
3432
/* Enable compression */
3533
compression?: boolean
3634
/** Request for immediate responses from the server node without waiting for linerizability guarantees */
@@ -79,6 +77,12 @@ export interface SQLCloudRowsetMetadata {
7977
table?: string
8078
/** Original name of the column */
8179
column?: string
80+
/** Column is not nullable? */
81+
notNull?: boolean
82+
/** Column is primary key */
83+
primaryKey?: boolean
84+
/** Column has autoincrement flag */
85+
autoIncrement?: boolean
8286
}[]
8387
}
8488

test/connection-ws.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,4 @@ describe('connection-ws', () => {
463463
LONG_TIMEOUT
464464
)
465465
})
466-
467-
describe('anonimizeCommand', () => {
468-
it('should mask username and password', () => {
469-
const anonimized = anonimizeCommand('+62 AUTH USER admin PASSWORD notreallyapassword; USE DATABASE chinook.db; ')
470-
expect(anonimized).toBe('+62 AUTH USER ****** PASSWORD ******; USE DATABASE chinook.db; ')
471-
})
472-
473-
it('should leave other values untouched', () => {
474-
const anonimized = anonimizeCommand('+62 AUTH USER admin SOMETHING notreallyapassword; USE DATABASE chinook.db; ')
475-
expect(anonimized).toBe('+62 AUTH USER ****** SOMETHING notreallyapassword; USE DATABASE chinook.db; ')
476-
})
477-
})
478466
})

0 commit comments

Comments
 (0)