Skip to content

Commit f968d4f

Browse files
committed
Resolve merge conflict
2 parents cfd0019 + e30b41d commit f968d4f

File tree

168 files changed

+2672
-1963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+2672
-1963
lines changed

.eslintrc

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414
},
1515
"rules": {
1616
"@typescript-eslint/no-unused-vars": ["error", {
17-
"args": "none"
17+
"args": "none",
18+
"varsIgnorePattern": "^_$"
1819
}],
19-
"no-unused-vars": "off"
20+
"no-unused-vars": ["error", {
21+
"args": "none",
22+
"varsIgnorePattern": "^_$"
23+
}],
24+
"no-var": "error",
25+
"prefer-const": "error"
2026
},
2127
"overrides": [
2228
{

docs/pages/apis/utilities.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Alert } from '/components/alert.tsx'
99
Escapes a string as a [SQL identifier](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS).
1010

1111
```js
12-
const { escapeIdentifier } = require('pg')
12+
import { escapeIdentifier } from 'pg';
1313
const escapedIdentifier = escapeIdentifier('FooIdentifier')
1414
console.log(escapedIdentifier) // '"FooIdentifier"'
1515
```
@@ -27,7 +27,7 @@ console.log(escapedIdentifier) // '"FooIdentifier"'
2727
Escapes a string as a [SQL literal](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS).
2828

2929
```js
30-
const { escapeLiteral } = require('pg')
30+
import { escapeLiteral } from 'pg';
3131
const escapedLiteral = escapeLiteral("hello 'world'")
3232
console.log(escapedLiteral) // "'hello ''world'''"
3333
```

docs/pages/features/connecting.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ const signerOptions = {
101101
username: 'api-user',
102102
}
103103

104-
const signer = new RDS.Signer()
104+
const signer = new RDS.Signer(signerOptions)
105105

106-
const getPassword = () => signer.getAuthToken(signerOptions)
106+
const getPassword = () => signer.getAuthToken()
107107

108108
const pool = new Pool({
109109
user: signerOptions.username,

docs/pages/guides/upgrading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pg.end()
5050
// new way, available since 6.0.0:
5151

5252
// create a pool
53-
var pool = new pg.Pool()
53+
const pool = new pg.Pool()
5454

5555
// connection using created pool
5656
pool.connect(function (err, client, done) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@typescript-eslint/eslint-plugin": "^7.0.0",
2424
"@typescript-eslint/parser": "^6.17.0",
2525
"eslint": "^8.56.0",
26-
"eslint-config-prettier": "^9.1.0",
26+
"eslint-config-prettier": "^10.1.2",
2727
"eslint-plugin-node": "^11.1.0",
2828
"eslint-plugin-prettier": "^5.1.2",
2929
"lerna": "^3.19.0",

packages/pg-connection-string/.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lib-cov
1212

1313
# Coverage directory used by tools like istanbul
1414
coverage
15+
.nyc_output
1516

1617
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
1718
.grunt
@@ -23,4 +24,7 @@ build/Release
2324
# Deployed apps should consider commenting this line out:
2425
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
2526
node_modules
26-
package-lock.json
27+
package-lock.json
28+
29+
# TypeScript output directory
30+
dist
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extension": ["js", "ts"],
3+
"require": "tsx"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"processes":{"417f2d4c-eaf2-4112-952c-a801df7fb93d":{"parent":null,"children":[]}},"files":{"/Users/bmc/src/node-postgres/packages/pg-connection-string/index.js":["417f2d4c-eaf2-4112-952c-a801df7fb93d"]},"externalIds":{}}

packages/pg-connection-string/README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ pg-connection-string
33

44
[![NPM](https://nodei.co/npm/pg-connection-string.png?compact=true)](https://nodei.co/npm/pg-connection-string/)
55

6-
[![Build Status](https://travis-ci.org/iceddev/pg-connection-string.svg?branch=master)](https://travis-ci.org/iceddev/pg-connection-string)
7-
[![Coverage Status](https://coveralls.io/repos/github/iceddev/pg-connection-string/badge.svg?branch=master)](https://coveralls.io/github/iceddev/pg-connection-string?branch=master)
8-
96
Functions for dealing with a PostgresSQL connection string
107

118
`parse` method taken from [node-postgres](https://github.com/brianc/node-postgres.git)
@@ -15,9 +12,9 @@ MIT License
1512
## Usage
1613

1714
```js
18-
var parse = require('pg-connection-string').parse;
15+
const parse = require('pg-connection-string').parse;
1916

20-
var config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')
17+
const config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')
2118
```
2219

2320
The resulting config contains a subset of the following properties:

packages/pg-connection-string/index.d.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,29 @@ export interface Options {
77
useLibpqCompat?: boolean
88
}
99

10+
interface SSLConfig {
11+
ca?: string
12+
cert?: string | null
13+
key?: string
14+
rejectUnauthorized?: boolean
15+
}
16+
1017
export interface ConnectionOptions {
1118
host: string | null
1219
password?: string
1320
user?: string
1421
port?: string | null
1522
database: string | null | undefined
1623
client_encoding?: string
17-
ssl?: boolean | string
24+
ssl?: boolean | string | SSLConfig
1825

1926
application_name?: string
2027
fallback_application_name?: string
2128
options?: string
29+
keepalives?: number
30+
31+
// We allow any other options to be passed through
32+
[key: string]: unknown
2233
}
2334

2435
export function toClientConfig(config: ConnectionOptions): ClientConfig

packages/pg-connection-string/index.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,8 @@ function toClientConfig(config) {
169169
if (typeof sslConfig === 'boolean') {
170170
c[key] = sslConfig
171171
}
172-
// else path is taken. multiple tests produce a sslConfig that is an object
173-
// and we can console.log to see that we take this path
174-
//
175-
// see https://github.com/istanbuljs/babel-plugin-istanbul/issues/186#issuecomment-1137765139
176-
// istanbul ignore else
177-
else if (typeof sslConfig === 'object') {
172+
173+
if (typeof sslConfig === 'object') {
178174
c[key] = toConnectionOptions(sslConfig)
179175
}
180176
} else if (value !== undefined && value !== null) {

packages/pg-connection-string/package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
}
1414
},
1515
"scripts": {
16-
"test": "istanbul cover _mocha && npm run check-coverage",
17-
"check-coverage": "istanbul check-coverage --statements 100 --branches 100 --lines 100 --functions 100",
18-
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
16+
"test": "nyc --reporter=lcov mocha && npm run check-coverage",
17+
"check-coverage": "nyc check-coverage --statements 100 --branches 100 --lines 100 --functions 100"
1918
},
2019
"repository": {
2120
"type": "git",
@@ -35,10 +34,14 @@
3534
},
3635
"homepage": "https://github.com/brianc/node-postgres/tree/master/packages/pg-connection-string",
3736
"devDependencies": {
37+
"@types/pg": "^8.12.0",
3838
"chai": "^4.1.1",
3939
"coveralls": "^3.0.4",
4040
"istanbul": "^0.4.5",
41-
"mocha": "^10.5.2"
41+
"mocha": "^10.5.2",
42+
"nyc": "^15",
43+
"tsx": "^4.19.4",
44+
"typescript": "^4.0.3"
4245
},
4346
"files": [
4447
"index.js",
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
'use strict'
2-
3-
const chai = require('chai')
1+
import chai from 'chai'
42
const expect = chai.expect
53
chai.should()
64

7-
const { parse, toClientConfig, parseIntoClientConfig } = require('../')
5+
import { parse, toClientConfig, parseIntoClientConfig } from '../'
86

97
describe('toClientConfig', function () {
108
it('converts connection info', function () {
119
const config = parse('postgres://brian:pw@boom:381/lala')
1210
const clientConfig = toClientConfig(config)
1311

14-
clientConfig.user.should.equal('brian')
15-
clientConfig.password.should.equal('pw')
16-
clientConfig.host.should.equal('boom')
17-
clientConfig.port.should.equal(381)
18-
clientConfig.database.should.equal('lala')
12+
clientConfig.user?.should.equal('brian')
13+
clientConfig.password?.should.equal('pw')
14+
clientConfig.host?.should.equal('boom')
15+
clientConfig.port?.should.equal(381)
16+
clientConfig.database?.should.equal('lala')
1917
})
2018

2119
it('converts query params', function () {
@@ -24,45 +22,47 @@ describe('toClientConfig', function () {
2422
)
2523
const clientConfig = toClientConfig(config)
2624

27-
clientConfig.application_name.should.equal('TheApp')
28-
clientConfig.fallback_application_name.should.equal('TheAppFallback')
29-
clientConfig.client_encoding.should.equal('utf8')
30-
clientConfig.options.should.equal('-c geqo=off')
25+
clientConfig.application_name?.should.equal('TheApp')
26+
clientConfig.fallback_application_name?.should.equal('TheAppFallback')
27+
clientConfig.client_encoding?.should.equal('utf8')
28+
clientConfig.options?.should.equal('-c geqo=off')
3129
})
3230

3331
it('converts SSL boolean', function () {
3432
const config = parse('pg:///?ssl=true')
3533
const clientConfig = toClientConfig(config)
3634

37-
clientConfig.ssl.should.equal(true)
35+
clientConfig.ssl?.should.equal(true)
3836
})
3937

4038
it('converts sslmode=disable', function () {
4139
const config = parse('pg:///?sslmode=disable')
4240
const clientConfig = toClientConfig(config)
4341

44-
clientConfig.ssl.should.equal(false)
42+
clientConfig.ssl?.should.equal(false)
4543
})
4644

4745
it('converts sslmode=noverify', function () {
4846
const config = parse('pg:///?sslmode=no-verify')
4947
const clientConfig = toClientConfig(config)
5048

51-
clientConfig.ssl.rejectUnauthorized.should.equal(false)
49+
clientConfig.ssl?.should.deep.equal({
50+
rejectUnauthorized: false,
51+
})
5252
})
5353

5454
it('converts other sslmode options', function () {
5555
const config = parse('pg:///?sslmode=verify-ca')
5656
const clientConfig = toClientConfig(config)
5757

58-
clientConfig.ssl.should.deep.equal({})
58+
clientConfig.ssl?.should.deep.equal({})
5959
})
6060

6161
it('converts other sslmode options', function () {
6262
const config = parse('pg:///?sslmode=verify-ca')
6363
const clientConfig = toClientConfig(config)
6464

65-
clientConfig.ssl.should.deep.equal({})
65+
clientConfig.ssl?.should.deep.equal({})
6666
})
6767

6868
it('converts ssl cert options', function () {
@@ -77,7 +77,7 @@ describe('toClientConfig', function () {
7777
const config = parse(connectionString)
7878
const clientConfig = toClientConfig(config)
7979

80-
clientConfig.ssl.should.deep.equal({
80+
clientConfig.ssl?.should.deep.equal({
8181
ca: 'example ca\n',
8282
cert: 'example cert\n',
8383
key: 'example key\n',
@@ -87,9 +87,9 @@ describe('toClientConfig', function () {
8787
it('converts unix domain sockets', function () {
8888
const config = parse('socket:/some path/?db=my[db]&encoding=utf8&client_encoding=bogus')
8989
const clientConfig = toClientConfig(config)
90-
clientConfig.host.should.equal('/some path/')
91-
clientConfig.database.should.equal('my[db]', 'must to be escaped and unescaped through "my%5Bdb%5D"')
92-
clientConfig.client_encoding.should.equal('utf8')
90+
clientConfig.host?.should.equal('/some path/')
91+
clientConfig.database?.should.equal('my[db]', 'must to be escaped and unescaped through "my%5Bdb%5D"')
92+
clientConfig.client_encoding?.should.equal('utf8')
9393
})
9494

9595
it('handles invalid port', function () {
@@ -106,20 +106,20 @@ describe('toClientConfig', function () {
106106

107107
const clientConfig = toClientConfig(config)
108108

109-
clientConfig.host.should.equal('boom')
110-
clientConfig.database.should.equal('lala')
111-
clientConfig.ssl.should.deep.equal({})
109+
clientConfig.host?.should.equal('boom')
110+
clientConfig.database?.should.equal('lala')
111+
clientConfig.ssl?.should.deep.equal({})
112112
})
113113
})
114114

115115
describe('parseIntoClientConfig', function () {
116116
it('converts url', function () {
117117
const clientConfig = parseIntoClientConfig('postgres://brian:pw@boom:381/lala')
118118

119-
clientConfig.user.should.equal('brian')
120-
clientConfig.password.should.equal('pw')
121-
clientConfig.host.should.equal('boom')
122-
clientConfig.port.should.equal(381)
123-
clientConfig.database.should.equal('lala')
119+
clientConfig.user?.should.equal('brian')
120+
clientConfig.password?.should.equal('pw')
121+
clientConfig.host?.should.equal('boom')
122+
clientConfig.port?.should.equal(381)
123+
clientConfig.database?.should.equal('lala')
124124
})
125125
})

0 commit comments

Comments
 (0)