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

@tidbcloud/serverless

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tidbcloud/serverless - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

9

dist/index.d.ts

@@ -39,2 +39,5 @@ interface ServerlessError {

}
interface TxOptions {
isolation?: 'READ COMMITTED' | 'REPEATABLE READ';
}
type ExecuteArgs = object | any[] | null;

@@ -60,3 +63,3 @@

constructor(conn: Connection);
execute(query: string, args?: ExecuteArgs, options?: ExecuteOptions): Promise<FullResult | Row[]>;
execute(query: string, args?: ExecuteArgs, options?: ExecuteOptions, txOptions?: TxOptions): Promise<FullResult | Row[]>;
commit(): Promise<FullResult | Row[]>;

@@ -69,4 +72,4 @@ rollback(): Promise<FullResult | Row[]>;

constructor(config: Config);
begin(): Promise<Tx>;
execute(query: string, args?: ExecuteArgs, options?: ExecuteOptions): Promise<FullResult | Row[]>;
begin(txOptions?: TxOptions): Promise<Tx>;
execute(query: string, args?: ExecuteArgs, options?: ExecuteOptions, txOptions?: TxOptions): Promise<FullResult | Row[]>;
}

@@ -73,0 +76,0 @@ declare function connect(config: Config): Connection;

@@ -140,6 +140,6 @@ // src/format.ts

// src/version.ts
var Version = "0.0.6";
var Version = "0.0.7";
// src/serverless.ts
async function postQuery(config, body, session = "") {
async function postQuery(config, body, session = "", isolationLevel = null) {
let fetchCacheOption = { cache: "no-store" };

@@ -155,12 +155,16 @@ try {

const database = config.database ?? "";
const headers = {
"Content-Type": "application/json",
"User-Agent": `serverless-js/${Version}`,
Authorization: `Basic ${auth}`,
"TiDB-Database": database,
"TiDB-Session": session
};
if (isolationLevel) {
headers["TiDB-Isolation-Level"] = isolationLevel;
}
const response = await fetch2(url.toString(), {
method: "POST",
body,
headers: {
"Content-Type": "application/json",
"User-Agent": `serverless-js/${Version}`,
Authorization: `Basic ${auth}`,
"TiDB-Database": database,
"TiDB-Session": session
},
headers,
...fetchCacheOption

@@ -194,4 +198,4 @@ });

}
async execute(query, args = null, options = defaultExecuteOptions) {
return this.conn.execute(query, args, options);
async execute(query, args = null, options = defaultExecuteOptions, txOptions = {}) {
return this.conn.execute(query, args, options, txOptions);
}

@@ -229,12 +233,12 @@ async commit() {

}
async begin() {
async begin(txOptions = {}) {
const conn = new _Connection(this.config);
const tx = new Tx(conn);
await tx.execute("BEGIN");
await tx.execute("BEGIN", void 0, void 0, txOptions);
return tx;
}
async execute(query, args = null, options = defaultExecuteOptions) {
async execute(query, args = null, options = defaultExecuteOptions, txOptions = {}) {
const sql = args ? format(query, args) : query;
const body = JSON.stringify({ query: sql });
const resp = await postQuery(this.config, body, this.session ?? "");
const resp = await postQuery(this.config, body, this.session ?? "", sql == "BEGIN" ? txOptions.isolation : null);
this.session = resp?.session ?? null;

@@ -241,0 +245,0 @@ if (this.session === null || this.session === "") {

{
"name": "@tidbcloud/serverless",
"version": "0.0.6",
"version": "0.0.7",
"description": "TiDB Serverless driver",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs",

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