Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'off'
},
root: true,
env: {
browser: true,
node: true
}
};
}
106 changes: 106 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
"description": "A JavaScript client for communicating with PlanetScale Edge API.",
"main": "dist/index.js",
"types": "dist/index.d.js",
"prettier": {
"semi": false,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true
},
"scripts": {
"build": "tsc",
"lint": "eslint .",
Expand Down Expand Up @@ -34,7 +43,10 @@
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
Expand Down
1 change: 0 additions & 1 deletion utils/api.ts → src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

type Something<T> = { some: T; none: false }
type Nothing = { none: true }
export type Option<T> = Something<T> | Nothing
Expand Down
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {Result, apiResult, unwrap, apiMessage, ClientError} from "../utils/api"
import {utf8Encode} from "../utils/text"
import { Result, apiResult, unwrap, apiMessage, ClientError } from './api'
import { utf8Encode } from './text'

export interface Credentials {
username: string
password: string
mysqlAddress: string

}

export interface QueryResultRow {
Expand Down Expand Up @@ -92,8 +91,7 @@ export default class Client {
}
}


async createSession(): Promise<QuerySession> {
async createSession(): Promise<QuerySession> {
const saved = await this.postJSON<QueryExecuteResponse>(
`${this.credentials.mysqlAddress}/psdb.v1alpha1.Database/CreateSession`,
{}
Expand Down Expand Up @@ -135,7 +133,7 @@ async createSession(): Promise<QuerySession> {
rows,
size: rows.length,
statement: rawQuery,
time: elapsedTime,
time: elapsedTime
}
} else if (saved.ok && saved.ok.error) {
return {
Expand Down
File renamed without changes.