diff --git a/docs/pages/apis/client.mdx b/docs/pages/apis/client.mdx index 02cdaffe7..dc1b02655 100644 --- a/docs/pages/apis/client.mdx +++ b/docs/pages/apis/client.mdx @@ -34,7 +34,7 @@ type Config = { example to create a client with specific connection information: ```js -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client({ user: 'database-user', @@ -48,7 +48,7 @@ const client = new Client({ ## client.connect ```js -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client() await client.connect() @@ -90,7 +90,7 @@ client.query(text: string, values?: any[]) => Promise **Plain text query** ```js -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client() await client.connect() @@ -104,7 +104,7 @@ await client.end() **Parameterized query** ```js -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client() await client.connect() @@ -142,7 +142,7 @@ await client.end() If you pass an object to `client.query` and the object has a `.submit` function on it, the client will pass it's GaussDB server connection to the object and delegate query dispatching to the supplied object. This is an advanced feature mostly intended for library authors. It is incidentally also currently how the callback and promise based queries above are handled internally, but this is subject to change. It is also how [gaussdb-cursor](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-cursor) and [gaussdb-query-stream](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-query-stream) work. ```js -import { Query } from 'gaussdb' +import { Query } from 'gaussdb-node' const query = new Query('select $1::text as name', ['brianc']) const result = client.query(query) diff --git a/docs/pages/apis/cursor.mdx b/docs/pages/apis/cursor.mdx index bfe53458c..794f1f6ff 100644 --- a/docs/pages/apis/cursor.mdx +++ b/docs/pages/apis/cursor.mdx @@ -18,7 +18,7 @@ $ npm install gaussdb gaussdb-cursor Instantiates a new Cursor. A cursor is an instance of `Submittable` and should be passed directly to the `client.query` method. ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' import Cursor from 'gaussdb-cursor' const pool = new Pool() @@ -55,7 +55,7 @@ If the cursor has read to the end of the result sets all subsequent calls to cur Here is an example of reading to the end of a cursor: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' import Cursor from 'gaussdb-cursor' const pool = new Pool() diff --git a/docs/pages/apis/pool.mdx b/docs/pages/apis/pool.mdx index 5e8ed8c92..d332615c9 100644 --- a/docs/pages/apis/pool.mdx +++ b/docs/pages/apis/pool.mdx @@ -56,7 +56,7 @@ type Config = { example to create a new pool with configuration: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool({ host: 'localhost', @@ -76,7 +76,7 @@ pool.query(text: string, values?: any[]) => Promise ``` ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() @@ -108,7 +108,7 @@ Acquires a client from the pool. - If the pool is 'full' and all clients are currently checked out will wait in a FIFO queue until a client becomes available by it being released back to the pool. ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() @@ -126,7 +126,7 @@ Client instances returned from `pool.connect` will have a `release` method which The `release` method on an acquired client returns it back to the pool. If you pass a truthy value in the `destroy` parameter, instead of releasing the client to the pool, the pool will be instructed to disconnect and destroy this client, leaving a space within itself for a new client. ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() @@ -138,7 +138,7 @@ client.release() ``` ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() assert(pool.totalCount === 0) @@ -171,7 +171,7 @@ Calling `pool.end` will drain the pool of all active clients, disconnect them, a ```js // again both promises and callbacks are supported: -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() diff --git a/docs/pages/apis/result.mdx b/docs/pages/apis/result.mdx index dc1f7f5ee..bbf24c050 100644 --- a/docs/pages/apis/result.mdx +++ b/docs/pages/apis/result.mdx @@ -18,7 +18,7 @@ Every result will have a rows array. If no rows are returned the array will be e Every result will have a fields array. This array contains the `name` and `dataTypeID` of each field in the result. These fields are ordered in the same order as the columns if you are using `arrayMode` for the query: ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool } = gaussdb const pool = new Pool() diff --git a/docs/pages/apis/utilities.mdx b/docs/pages/apis/utilities.mdx index 7db14bb56..791c0bb4c 100644 --- a/docs/pages/apis/utilities.mdx +++ b/docs/pages/apis/utilities.mdx @@ -9,7 +9,7 @@ import { Alert } from '/components/alert.tsx' Escapes a string as a [SQL identifier](https://www.gaussdb.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS). ```js -import { escapeIdentifier } from 'gaussdb'; +import { escapeIdentifier } from 'gaussdb-node'; const escapedIdentifier = escapeIdentifier('FooIdentifier') console.log(escapedIdentifier) // '"FooIdentifier"' ``` @@ -27,7 +27,7 @@ console.log(escapedIdentifier) // '"FooIdentifier"' Escapes a string as a [SQL literal](https://www.gaussdb.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS). ```js -import { escapeLiteral } from 'gaussdb'; +import { escapeLiteral } from 'gaussdb-node'; const escapedLiteral = escapeLiteral("hello 'world'") console.log(escapedLiteral) // "'hello ''world'''" ``` diff --git a/docs/pages/features/callbacks.mdx b/docs/pages/features/callbacks.mdx index fd034f908..3fd73b463 100644 --- a/docs/pages/features/callbacks.mdx +++ b/docs/pages/features/callbacks.mdx @@ -8,7 +8,7 @@ title: Callbacks ```js -const { Pool, Client } = require('gaussdb') +const { Pool, Client } = require('gaussdb-node') // pool const pool = new Pool() diff --git a/docs/pages/features/connecting.mdx b/docs/pages/features/connecting.mdx index e85b0571b..e7ff12d43 100644 --- a/docs/pages/features/connecting.mdx +++ b/docs/pages/features/connecting.mdx @@ -9,7 +9,7 @@ Both individual clients & pools will use these environment variables. Here's a t Both individual clients & pools will use these environment variables. Here's a tiny program connecting node.js to the GaussDB server: ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool, Client } = gaussdb // pools will use environment variables @@ -57,7 +57,7 @@ GAUSSDB_DATABASE=process.env.USER (fallback to GAUSSDATABASE) gaussdb-node also supports configuring a pool or client programmatically with connection information. Here's our same script from above modified to use programmatic (hard-coded in this case) values. This can be useful if your application already has a way to manage config values or you don't want to use environment variables. ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool, Client } = gaussdb const pool = new Pool({ @@ -88,7 +88,7 @@ await client.end() Many cloud providers include alternative methods for connecting to database instances using short-lived authentication tokens. gaussdb-node supports dynamic passwords via a callback function, either synchronous or asynchronous. The callback function must resolve to a string. ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool } = gaussdb import { RDS } from 'aws-sdk' @@ -121,7 +121,7 @@ const pool = new Pool({ Connections to unix sockets can also be made. This can be useful on distros like Ubuntu, where authentication is managed via the socket connection instead of a password. ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Client } = gaussdb client = new Client({ user: 'username', @@ -136,7 +136,7 @@ client = new Client({ You can initialize both a pool and a client with a connection string URI as well. This is common in environments like Heroku where the database connection string is supplied to your application dyno through an environment variable. Connection string parsing brought to you by [gaussdb-connection-string](https://github.com/HuaweiCloudDeveloper/gaussdb-node/tree/master/packages/gaussdb-connection-string). ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool, Client } = gaussdb const connectionString = 'gaussdb://dbuser:secretpassword@database.server.com:3211/mydb' diff --git a/docs/pages/features/esm.mdx b/docs/pages/features/esm.mdx index 7621d37ff..1a6788f2a 100644 --- a/docs/pages/features/esm.mdx +++ b/docs/pages/features/esm.mdx @@ -4,7 +4,7 @@ title: ESM ## ESM Support -As of v8.15.x gaussdb-node supporters the __ECMAScript Module__ (ESM) format. This means you can use `import` statements instead of `require` or `import gaussdb from 'gaussdb'`. +As of v8.15.x gaussdb-node supporters the __ECMAScript Module__ (ESM) format. This means you can use `import` statements instead of `require` or `import gaussdb from 'gaussdb-node'`. CommonJS modules are still supported. The ESM format is an opt-in feature and will not affect existing codebases that use CommonJS. @@ -13,7 +13,7 @@ The docs have been changed to show ESM usage, but in a CommonJS context you can If you're using CommonJS, you can use the following code to import the `gaussdb` module: ```js - const gaussdb = require('gaussdb') + const gaussdb = require('gaussdb-node') const { Client } = gaussdb // etc... ``` @@ -23,7 +23,7 @@ If you're using CommonJS, you can use the following code to import the `gaussdb` If you're using ESM, you can use the following code to import the `gaussdb` module: ```js - import { Client } from 'gaussdb' + import { Client } from 'gaussdb-node' // etc... ``` @@ -31,7 +31,7 @@ If you're using ESM, you can use the following code to import the `gaussdb` modu Previously if you were using ESM you would have to use the following code: ```js - import gaussdb from 'gaussdb' + import gaussdb from 'gaussdb-node' const { Client } = gaussdb // etc... ``` diff --git a/docs/pages/features/native.mdx b/docs/pages/features/native.mdx index 210633e75..febb2744f 100644 --- a/docs/pages/features/native.mdx +++ b/docs/pages/features/native.mdx @@ -15,12 +15,12 @@ $ npm install gaussdb pg-native Once `pg-native` is installed instead of requiring a `Client` or `Pool` constructor from `gaussdb` you do the following: ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { native } = gaussdb const { Client, Pool } = native ``` -When you access the `.native` property on `'gaussdb'` it will automatically require the `pg-native` package and wrap it in the same API. +When you access the `.native` property on `'gaussdb-node'` it will automatically require the `pg-native` package and wrap it in the same API.
Care has been taken to normalize between the two, but there might still be edge cases where things behave subtly differently due to the nature of using libpq over handling the binary protocol directly in JavaScript, so it's recommended you chose to either use the JavaScript driver or the native bindings both in development and production. For what its worth: I use the pure JavaScript driver because the JavaScript driver is more portable (doesn't need a compiler), and the pure JavaScript driver is plenty fast. diff --git a/docs/pages/features/pooling.mdx b/docs/pages/features/pooling.mdx index 192133f92..f2efb76ec 100644 --- a/docs/pages/features/pooling.mdx +++ b/docs/pages/features/pooling.mdx @@ -28,7 +28,7 @@ The client pool allows you to have a reusable pool of clients you can check out, ### Checkout, use, and return ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool } = gaussdb const pool = new Pool() @@ -61,7 +61,7 @@ client.release() If you don't need a transaction or you just need to run a single query, the pool has a convenience method to run a query on any available client in the pool. This is the preferred way to query with gaussdb-node if you can as it removes the risk of leaking a client. ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool } = gaussdb const pool = new Pool() @@ -75,7 +75,7 @@ console.log('user:', res.rows[0]) To shut down a pool call `pool.end()` on the pool. This will wait for all checked-out clients to be returned and then shut down all the clients and the pool timers. ```js -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' const { Pool } = gaussdb const pool = new Pool() diff --git a/docs/pages/features/ssl.mdx b/docs/pages/features/ssl.mdx index 86445d773..4ed2d3a12 100644 --- a/docs/pages/features/ssl.mdx +++ b/docs/pages/features/ssl.mdx @@ -22,7 +22,7 @@ const config = { }, } -import { Client, Pool } from 'gaussdb' +import { Client, Pool } from 'gaussdb-node' const client = new Client(config) await client.connect() diff --git a/docs/pages/features/transactions.mdx b/docs/pages/features/transactions.mdx index c4f780cff..a0fdfc31a 100644 --- a/docs/pages/features/transactions.mdx +++ b/docs/pages/features/transactions.mdx @@ -16,7 +16,7 @@ To execute a transaction with gaussdb-node you simply execute `BEGIN / COMMIT / ## Examples ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() const client = await pool.connect() diff --git a/docs/pages/guides/async-express.md b/docs/pages/guides/async-express.md index 8fb4b3405..9db2904ac 100644 --- a/docs/pages/guides/async-express.md +++ b/docs/pages/guides/async-express.md @@ -22,7 +22,7 @@ That's the same structure I used in the [project structure](/guides/project-stru My `db/index.js` file usually starts out like this: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() diff --git a/docs/pages/guides/project-structure.md b/docs/pages/guides/project-structure.md index f8e0aa28e..e3682ed59 100644 --- a/docs/pages/guides/project-structure.md +++ b/docs/pages/guides/project-structure.md @@ -27,7 +27,7 @@ The location doesn't really matter - I've found it usually ends up being somewha Typically I'll start out my `db/index.js` file like so: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() @@ -54,7 +54,7 @@ app.get('/:id', async (req, res, next) => { Imagine we have lots of routes scattered throughout many files under our `routes/` directory. We now want to go back and log every single query that's executed, how long it took, and the number of rows it returned. If we had required gaussdb-node directly in every route file we'd have to go edit every single route - that would take forever & be really error prone! But thankfully we put our data access into `db/index.js`. Let's go add some logging: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() @@ -74,7 +74,7 @@ _note: I didn't log the query parameters. Depending on your application you migh Now what if we need to check out a client from the pool to run several queries in a row in a transaction? We can add another method to our `db/index.js` file when we need to do this: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() diff --git a/docs/pages/index.mdx b/docs/pages/index.mdx index 5b3c6cb3d..88a730b79 100644 --- a/docs/pages/index.mdx +++ b/docs/pages/index.mdx @@ -22,7 +22,7 @@ gaussdb-node strives to be compatible with all recent LTS versions of node & the The simplest possible way to connect, query, and disconnect is with async/await: ```js -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client() await client.connect() @@ -36,7 +36,7 @@ await client.end() For the sake of simplicity, these docs will assume that the methods are successful. In real life use, make sure to properly handle errors thrown in the methods. A `try/catch` block is a great way to do so: ```ts -import { Client } from 'gaussdb' +import { Client } from 'gaussdb-node' const client = new Client() await client.connect() @@ -55,7 +55,7 @@ try { In most applications you'll wannt to use a [connection pool](/features/pooling) to manage your connections. This is a more advanced topic, but here's a simple example of how to use it: ```js -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' const pool = new Pool() const res = await pool.query('SELECT $1::text as message', ['Hello world!']) console.log(res.rows[0].message) // Hello world! diff --git a/packages/gaussdb-cloudflare/package.json b/packages/gaussdb-cloudflare/package.json index ab0e996c2..3b7a4bc58 100644 --- a/packages/gaussdb-cloudflare/package.json +++ b/packages/gaussdb-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-cloudflare", - "version": "0.1.0", + "version": "0.2.0", "description": "A socket implementation for GaussDB that can run on Cloudflare Workers using native TCP connections.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/gaussdb-connection-string/README.md b/packages/gaussdb-connection-string/README.md index 447dafdac..0ecbe6176 100644 --- a/packages/gaussdb-connection-string/README.md +++ b/packages/gaussdb-connection-string/README.md @@ -39,7 +39,7 @@ The resulting config contains a subset of the following properties: The gaussdb-connection-string `ConnectionOptions` interface is not compatible with the `ClientConfig` interface that [gaussdb.Client](https://node-gaussdb.com/apis/client) expects. To remedy this, use the `parseIntoClientConfig` function instead of `parse`: ```ts -import { ClientConfig } from 'gaussdb'; +import { ClientConfig } from 'gaussdb-node'; import { parseIntoClientConfig } from 'gaussdb-connection-string'; const config: ClientConfig = parseIntoClientConfig('gaussdb://someuser:somepassword@somehost:381/somedatabase') @@ -48,7 +48,7 @@ const config: ClientConfig = parseIntoClientConfig('gaussdb://someuser:somepassw You can also use `toClientConfig` to convert an existing `ConnectionOptions` interface into a `ClientConfig` interface: ```ts -import { ClientConfig } from 'gaussdb'; +import { ClientConfig } from 'gaussdb-node'; import { parse, toClientConfig } from 'gaussdb-connection-string'; const config = parse('gaussdb://someuser:somepassword@somehost:381/somedatabase') diff --git a/packages/gaussdb-connection-string/index.d.ts b/packages/gaussdb-connection-string/index.d.ts index 2752fde9d..f9f73ecb0 100644 --- a/packages/gaussdb-connection-string/index.d.ts +++ b/packages/gaussdb-connection-string/index.d.ts @@ -1,4 +1,4 @@ -import { ClientConfig } from 'gaussdb' +import { ClientConfig } from 'gaussdb-node' export function parse(connectionString: string, options?: Options): ConnectionOptions diff --git a/packages/gaussdb-connection-string/package.json b/packages/gaussdb-connection-string/package.json index 1e51f9ab7..383fd1281 100644 --- a/packages/gaussdb-connection-string/package.json +++ b/packages/gaussdb-connection-string/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-connection-string", - "version": "0.1.0", + "version": "0.2.0", "description": "Functions for dealing with a GaussDB connection string", "main": "./index.js", "types": "./index.d.ts", diff --git a/packages/gaussdb-cursor/index.js b/packages/gaussdb-cursor/index.js index 4f41e81b7..3252997b7 100644 --- a/packages/gaussdb-cursor/index.js +++ b/packages/gaussdb-cursor/index.js @@ -1,7 +1,7 @@ 'use strict' // note: can remove these deep requires when we bump min version of pg to 9.x -const Result = require('gaussdb/lib/result.js') -const prepare = require('gaussdb/lib/utils.js').prepareValue +const Result = require('gaussdb-node/lib/result.js') +const prepare = require('gaussdb-node/lib/utils.js').prepareValue const EventEmitter = require('events').EventEmitter const util = require('util') diff --git a/packages/gaussdb-cursor/package.json b/packages/gaussdb-cursor/package.json index 7f42b1ff1..f577da9f5 100644 --- a/packages/gaussdb-cursor/package.json +++ b/packages/gaussdb-cursor/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-cursor", - "version": "0.1.0", + "version": "0.2.0", "description": "Query cursor extension for GaussDB", "main": "index.js", "exports": { @@ -24,11 +24,11 @@ "author": "Brian M. Carlson", "license": "MIT", "devDependencies": { - "mocha": "^10.5.2", - "gaussdb": "^0.1.0" + "gaussdb-node": "^0.2.0", + "mocha": "^10.5.2" }, "peerDependencies": { - "gaussdb": "^0.1.0" + "gaussdb-node": "^0.2.0" }, "files": [ "index.js", diff --git a/packages/gaussdb-cursor/test/close.js b/packages/gaussdb-cursor/test/close.js index 2df7ce94d..9f7d790fb 100644 --- a/packages/gaussdb-cursor/test/close.js +++ b/packages/gaussdb-cursor/test/close.js @@ -1,6 +1,6 @@ const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const text = 'SELECT generate_series as num FROM generate_series(0, 50)' describe('close', function () { diff --git a/packages/gaussdb-cursor/test/error-handling.js b/packages/gaussdb-cursor/test/error-handling.js index c7b6a7736..d6cce2101 100644 --- a/packages/gaussdb-cursor/test/error-handling.js +++ b/packages/gaussdb-cursor/test/error-handling.js @@ -1,7 +1,7 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const text = 'SELECT generate_series as num FROM generate_series(0, 4)' diff --git a/packages/gaussdb-cursor/test/index.js b/packages/gaussdb-cursor/test/index.js index 0cacbfd4c..1cafd1928 100644 --- a/packages/gaussdb-cursor/test/index.js +++ b/packages/gaussdb-cursor/test/index.js @@ -1,6 +1,6 @@ const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const text = 'SELECT generate_series as num FROM generate_series(0, 5)' diff --git a/packages/gaussdb-cursor/test/no-data-handling.js b/packages/gaussdb-cursor/test/no-data-handling.js index 9e0c93035..a15cae4e8 100644 --- a/packages/gaussdb-cursor/test/no-data-handling.js +++ b/packages/gaussdb-cursor/test/no-data-handling.js @@ -1,5 +1,5 @@ const assert = require('assert') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const Cursor = require('../') describe('queries with no data', function () { diff --git a/packages/gaussdb-cursor/test/pool.js b/packages/gaussdb-cursor/test/pool.js index 77e04ad0f..8d02d4a49 100644 --- a/packages/gaussdb-cursor/test/pool.js +++ b/packages/gaussdb-cursor/test/pool.js @@ -1,7 +1,7 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const text = 'SELECT generate_series as num FROM generate_series(0, 50)' diff --git a/packages/gaussdb-cursor/test/promises.js b/packages/gaussdb-cursor/test/promises.js index 6fcdf6000..8870b5e20 100644 --- a/packages/gaussdb-cursor/test/promises.js +++ b/packages/gaussdb-cursor/test/promises.js @@ -1,6 +1,6 @@ const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const text = 'SELECT generate_series as num FROM generate_series(0, 5)' diff --git a/packages/gaussdb-cursor/test/query-config.js b/packages/gaussdb-cursor/test/query-config.js index 03b4af0d1..7f224e2bf 100644 --- a/packages/gaussdb-cursor/test/query-config.js +++ b/packages/gaussdb-cursor/test/query-config.js @@ -1,7 +1,7 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') describe('query config passed to result', () => { it('passes rowMode to result', (done) => { diff --git a/packages/gaussdb-cursor/test/transactions.js b/packages/gaussdb-cursor/test/transactions.js index ee62f26c2..ae148dc0c 100644 --- a/packages/gaussdb-cursor/test/transactions.js +++ b/packages/gaussdb-cursor/test/transactions.js @@ -1,6 +1,6 @@ const assert = require('assert') const Cursor = require('../') -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') // SKIP: 不支持 LISTEN/NOFITY statement // https://github.com/HuaweiCloudDeveloper/gaussdb-drivers/blob/master-dev/diff-gaussdb-postgres.md#%E4%B8%8D%E6%94%AF%E6%8C%81-listennofity-statement diff --git a/packages/gaussdb-esm-test/common-js-imports.test.cjs b/packages/gaussdb-esm-test/common-js-imports.test.cjs index e17ec2959..40af8a6a3 100644 --- a/packages/gaussdb-esm-test/common-js-imports.test.cjs +++ b/packages/gaussdb-esm-test/common-js-imports.test.cjs @@ -3,9 +3,9 @@ const test = require('node:test') const { describe, it } = test const paths = [ - 'gaussdb', - 'gaussdb/lib/index.js', - 'gaussdb/lib/connection-parameters.js', + 'gaussdb-node', + 'gaussdb-node/lib/index.js', + 'gaussdb-node/lib/connection-parameters.js', 'gaussdb-protocol/dist/messages.js', 'pg-native/lib/build-result.js', ] @@ -20,7 +20,7 @@ for (const path of paths) { describe('pg-native', () => { it('should work with commonjs', async () => { - const gaussdb = require('gaussdb') + const gaussdb = require('gaussdb-node') const pool = new gaussdb.native.Pool() const result = await pool.query('SELECT 1') diff --git a/packages/gaussdb-esm-test/gaussdb.test.js b/packages/gaussdb-esm-test/gaussdb.test.js index 906b33055..016e70bfb 100644 --- a/packages/gaussdb-esm-test/gaussdb.test.js +++ b/packages/gaussdb-esm-test/gaussdb.test.js @@ -11,9 +11,9 @@ import gaussdb, { escapeLiteral, Result, TypeOverrides, -} from 'gaussdb' +} from 'gaussdb-node' -describe('gaussdb', () => { +describe('gaussdb-node', () => { it('should export Client constructor', () => { assert.ok(new Client()) }) diff --git a/packages/gaussdb-esm-test/package.json b/packages/gaussdb-esm-test/package.json index 4998ee26a..d815539ac 100644 --- a/packages/gaussdb-esm-test/package.json +++ b/packages/gaussdb-esm-test/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-esm-test", - "version": "0.1.0", + "version": "0.2.0", "description": "A test module for GaussDB with ESM support", "main": "index.js", "type": "module", @@ -13,13 +13,13 @@ "test" ], "devDependencies": { - "gaussdb": "^0.1.0", - "gaussdb-cloudflare": "^0.1.0", - "gaussdb-cursor": "^0.1.0", - "pg-native": "^3.5.0", - "gaussdb-pool": "^0.1.0", - "gaussdb-protocol": "^0.1.0", - "gaussdb-query-stream": "^0.1.0" + "gaussdb-node": "^0.2.0", + "gaussdb-cloudflare": "^0.2.0", + "gaussdb-cursor": "^0.2.0", + "gaussdb-pool": "^0.2.0", + "gaussdb-protocol": "^0.2.0", + "gaussdb-query-stream": "^0.2.0", + "pg-native": "^3.5.0" }, "author": "Brian M. Carlson ", "license": "MIT" diff --git a/packages/gaussdb-node/package.json b/packages/gaussdb-node/package.json index 285068230..a498a1578 100644 --- a/packages/gaussdb-node/package.json +++ b/packages/gaussdb-node/package.json @@ -1,6 +1,6 @@ { - "name": "gaussdb", - "version": "0.1.0", + "name": "gaussdb-node", + "version": "0.2.0", "description": "GaussDB client - pure javascript & libpq with the same API", "keywords": [ "database", @@ -20,7 +20,7 @@ ".": { "import": "./esm/index.mjs", "require": "./lib/index.js", - "default": "./lib/index.js" + "default": "./lib/index.js" }, "./lib/*": { "import": "./lib/*", @@ -29,9 +29,9 @@ } }, "dependencies": { - "gaussdb-connection-string": "^0.1.0", - "gaussdb-pool": "^0.1.0", - "gaussdb-protocol": "^0.1.0", + "gaussdb-connection-string": "^0.2.0", + "gaussdb-pool": "^0.2.0", + "gaussdb-protocol": "^0.2.0", "pg-types": "2.2.0", "pgpass": "1.0.5" }, @@ -47,7 +47,7 @@ "wrangler": "^3.x" }, "optionalDependencies": { - "gaussdb-cloudflare": "^0.1.0" + "gaussdb-cloudflare": "^0.2.0" }, "peerDependencies": { "pg-native": ">=3.0.1" diff --git a/packages/gaussdb-node/test/cloudflare/vitest-cf.test.ts b/packages/gaussdb-node/test/cloudflare/vitest-cf.test.ts index ac3708a62..e6ae9ce77 100644 --- a/packages/gaussdb-node/test/cloudflare/vitest-cf.test.ts +++ b/packages/gaussdb-node/test/cloudflare/vitest-cf.test.ts @@ -1,4 +1,4 @@ -import { Pool } from 'gaussdb' +import { Pool } from 'gaussdb-node' import { test } from 'vitest' import assert from 'node:assert' import args from '../cli' diff --git a/packages/gaussdb-node/test/integration/client/prepared-statement-tests.js b/packages/gaussdb-node/test/integration/client/prepared-statement-tests.js index 5a7ec104d..54214ed23 100644 --- a/packages/gaussdb-node/test/integration/client/prepared-statement-tests.js +++ b/packages/gaussdb-node/test/integration/client/prepared-statement-tests.js @@ -128,12 +128,12 @@ const suite = new helper.Suite() const client = helper.client() client.query('CREATE TEMP TABLE zoom(name varchar(100));') client.query("INSERT INTO zoom (name) VALUES ('zed')") - client.query("INSERT INTO zoom (name) VALUES ('gaussdb')") + client.query("INSERT INTO zoom (name) VALUES ('gaussdb-node')") client.query("INSERT INTO zoom (name) VALUES ('node gaussdb')") const checkForResults = function (q) { assert.emits(q, 'row', function (row) { - assert.equal(row.name, 'gaussdb') + assert.equal(row.name, 'gaussdb-node') assert.emits(q, 'row', function (row) { assert.equal(row.name, 'node gaussdb') diff --git a/packages/gaussdb-pool/README.md b/packages/gaussdb-pool/README.md index 2e40f35ce..0a34988ec 100644 --- a/packages/gaussdb-pool/README.md +++ b/packages/gaussdb-pool/README.md @@ -27,7 +27,7 @@ const pool = new Pool() // and the node-pool (https://github.com/coopernurse/node-pool) constructor // allowing you to fully configure the behavior of both const pool2 = new Pool({ - database: 'gaussdb', + database: 'gaussdb-node', user: 'tset', password: 'secret!', port: 5432, @@ -40,7 +40,7 @@ const pool2 = new Pool({ // you can supply a custom client constructor // if you want to use the native gaussdb client -const NativeClient = require('gaussdb').native.Client +const NativeClient = require('gaussdb-node').native.Client const nativePool = new Pool({ Client: NativeClient }) // you can even pool pg-native clients directly diff --git a/packages/gaussdb-pool/index.js b/packages/gaussdb-pool/index.js index 01f88c580..5809f4625 100644 --- a/packages/gaussdb-pool/index.js +++ b/packages/gaussdb-pool/index.js @@ -92,7 +92,7 @@ class Pool extends EventEmitter { this.options.allowExitOnIdle = this.options.allowExitOnIdle || false this.options.maxLifetimeSeconds = this.options.maxLifetimeSeconds || 0 this.log = this.options.log || function () {} - this.Client = this.options.Client || Client || require('gaussdb').Client + this.Client = this.options.Client || Client || require('gaussdb-node').Client this.Promise = this.options.Promise || global.Promise if (typeof this.options.idleTimeoutMillis === 'undefined') { diff --git a/packages/gaussdb-pool/package.json b/packages/gaussdb-pool/package.json index 8583f7e4e..1ae78451b 100644 --- a/packages/gaussdb-pool/package.json +++ b/packages/gaussdb-pool/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-pool", - "version": "0.1.0", + "version": "0.2.0", "description": "Connection pool for GaussDB", "main": "index.js", "exports": { @@ -36,7 +36,7 @@ "mocha": "^10.5.2" }, "peerDependencies": { - "gaussdb": ">=0.1.0" + "gaussdb-node": ">=0.2.0" }, "files": [ "index.js", diff --git a/packages/gaussdb-pool/test/connection-timeout.js b/packages/gaussdb-pool/test/connection-timeout.js index 56fa4c5cb..b0e804b2b 100644 --- a/packages/gaussdb-pool/test/connection-timeout.js +++ b/packages/gaussdb-pool/test/connection-timeout.js @@ -138,7 +138,7 @@ describe('connection timeout', () => { }) it('continues processing after a connection failure', (done) => { - const Client = require('gaussdb').Client + const Client = require('gaussdb-node').Client const orgConnect = Client.prototype.connect let called = false @@ -173,7 +173,7 @@ describe('connection timeout', () => { }) it('releases newly connected clients if the queued already timed out', (done) => { - const Client = require('gaussdb').Client + const Client = require('gaussdb-node').Client const orgConnect = Client.prototype.connect diff --git a/packages/gaussdb-protocol/package.json b/packages/gaussdb-protocol/package.json index a52b6d39c..2d5fb2b85 100644 --- a/packages/gaussdb-protocol/package.json +++ b/packages/gaussdb-protocol/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-protocol", - "version": "0.1.0", + "version": "0.2.0", "description": "The GaussDB client/server binary protocol, implemented in TypeScript", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/gaussdb-query-stream/README.md b/packages/gaussdb-query-stream/README.md index cf8eab9a2..4157ec7a7 100644 --- a/packages/gaussdb-query-stream/README.md +++ b/packages/gaussdb-query-stream/README.md @@ -14,7 +14,7 @@ _requires gaussdb>=2.8.1_ ## use ```js -const gaussdb = require('gaussdb') +const gaussdb = require('gaussdb-node') const pool = new gaussdb.Pool() const QueryStream = require('gaussdb-query-stream') const JSONStream = require('JSONStream') diff --git a/packages/gaussdb-query-stream/package.json b/packages/gaussdb-query-stream/package.json index e11b43042..310e2337f 100644 --- a/packages/gaussdb-query-stream/package.json +++ b/packages/gaussdb-query-stream/package.json @@ -1,6 +1,6 @@ { "name": "gaussdb-query-stream", - "version": "0.1.0", + "version": "0.2.0", "description": "GaussDB query result returned as readable stream", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -43,16 +43,16 @@ "JSONStream": "~1.3.5", "concat-stream": "~1.0.1", "eslint-plugin-promise": "^6.0.1", + "gaussdb-node": "^0.2.0", "mocha": "^10.5.2", - "gaussdb": "^0.1.0", "stream-spec": "~0.3.5", "ts-node": "^8.5.4", "typescript": "^4.0.3" }, "peerDependencies": { - "gaussdb": "^0.1.0" + "gaussdb-node": "^0.2.0" }, "dependencies": { - "gaussdb-cursor": "^0.1.0" + "gaussdb-cursor": "^0.2.0" } } diff --git a/packages/gaussdb-query-stream/src/index.ts b/packages/gaussdb-query-stream/src/index.ts index 205786ab3..9cb4b7b32 100644 --- a/packages/gaussdb-query-stream/src/index.ts +++ b/packages/gaussdb-query-stream/src/index.ts @@ -1,5 +1,5 @@ import { Readable } from 'stream' -import { Submittable, Connection } from 'gaussdb' +import { Submittable, Connection } from 'gaussdb-node' import Cursor from 'gaussdb-cursor' interface QueryStreamConfig { diff --git a/packages/gaussdb-query-stream/test/async-iterator.ts b/packages/gaussdb-query-stream/test/async-iterator.ts index 9978dd3cd..7c0142816 100644 --- a/packages/gaussdb-query-stream/test/async-iterator.ts +++ b/packages/gaussdb-query-stream/test/async-iterator.ts @@ -1,5 +1,5 @@ import QueryStream from '../src' -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' import assert from 'assert' const queryText = 'SELECT * FROM generate_series(0, 200) num' diff --git a/packages/gaussdb-query-stream/test/client-options.ts b/packages/gaussdb-query-stream/test/client-options.ts index f1b982a7a..53703311e 100644 --- a/packages/gaussdb-query-stream/test/client-options.ts +++ b/packages/gaussdb-query-stream/test/client-options.ts @@ -1,4 +1,4 @@ -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' import assert from 'assert' import QueryStream from '../src' diff --git a/packages/gaussdb-query-stream/test/error.ts b/packages/gaussdb-query-stream/test/error.ts index 105820930..088b7853e 100644 --- a/packages/gaussdb-query-stream/test/error.ts +++ b/packages/gaussdb-query-stream/test/error.ts @@ -1,7 +1,7 @@ import assert from 'assert' import helper from './helper' import QueryStream from '../src' -import { Pool, Client } from 'gaussdb' +import { Pool, Client } from 'gaussdb-node' helper('error', function (client) { it('receives error on stream', function (done) { diff --git a/packages/gaussdb-query-stream/test/helper.ts b/packages/gaussdb-query-stream/test/helper.ts index b2f65f9f6..ea6aea460 100644 --- a/packages/gaussdb-query-stream/test/helper.ts +++ b/packages/gaussdb-query-stream/test/helper.ts @@ -1,4 +1,4 @@ -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' export default function (name, cb) { describe(name, function () { diff --git a/packages/gaussdb-query-stream/test/issue-3.ts b/packages/gaussdb-query-stream/test/issue-3.ts index 3e06faa25..bf60bc091 100644 --- a/packages/gaussdb-query-stream/test/issue-3.ts +++ b/packages/gaussdb-query-stream/test/issue-3.ts @@ -1,4 +1,4 @@ -import gaussdb from 'gaussdb' +import gaussdb from 'gaussdb-node' import QueryStream from '../src' describe('end semantics race condition', function () { diff --git a/packages/pg-native/bench/index.js b/packages/pg-native/bench/index.js index 20c216871..ed648b8f9 100644 --- a/packages/pg-native/bench/index.js +++ b/packages/pg-native/bench/index.js @@ -1,4 +1,4 @@ -const gaussdb = require('gaussdb').native +const gaussdb = require('gaussdb-node').native const Native = require('../') const warmup = function (fn, cb) { diff --git a/yarn.lock b/yarn.lock index 1b3db938f..071f66508 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4442,6 +4442,17 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +gaussdb-node@^0.1.0: + version "0.2.0" + dependencies: + gaussdb-connection-string "^0.2.0" + gaussdb-pool "^0.2.0" + gaussdb-protocol "^0.2.0" + pg-types "2.2.0" + pgpass "1.0.5" + optionalDependencies: + gaussdb-cloudflare "^0.2.0" + generic-pool@^2.1.1: version "2.5.4" resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-2.5.4.tgz#38c6188513e14030948ec6e5cf65523d9779299b" @@ -7019,6 +7030,11 @@ pg-numeric@1.0.2: resolved "https://registry.yarnpkg.com/pg-numeric/-/pg-numeric-1.0.2.tgz#816d9a44026086ae8ae74839acd6a09b0636aa3a" integrity sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw== +pg-protocol@*: + version "1.10.3" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.10.3.tgz#ac9e4778ad3f84d0c5670583bab976ea0a34f69f" + integrity sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ== + pg-types@2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz"