ffc-pay-etl-framework 1.4.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { Sequelize } = require('sequelize')
|
|
1
|
+
const { Database } = require('ffc-database')
|
|
3
2
|
const debug = require('debug')('connection')
|
|
4
3
|
|
|
4
|
+
const DEFAULT_PORT = 5432
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
7
8
|
* @param {Object} options
|
|
@@ -11,32 +12,44 @@ const debug = require('debug')('connection')
|
|
|
11
12
|
* @param {Object} options.database
|
|
12
13
|
* @param {Object} options.host
|
|
13
14
|
* @param {Object} options.port
|
|
15
|
+
* @param {Object} [options.schema]
|
|
16
|
+
* @param {Object} [options.ssl]
|
|
17
|
+
* @param {Object} [options.tables]
|
|
18
|
+
* @param {Object} [options.pool]
|
|
19
|
+
* @param {Boolean} [options.useAzureManagedIdentity]
|
|
20
|
+
* @param {String} [options.azureClientId]
|
|
14
21
|
* @returns Connection
|
|
15
22
|
*/
|
|
16
23
|
async function postgresDatabaseConnection (options) {
|
|
17
24
|
const connectionname = options.connectionname
|
|
18
|
-
const username = options.username
|
|
19
|
-
const password = options.password
|
|
20
|
-
const database = options.database
|
|
21
|
-
const host = options.host
|
|
22
|
-
const port = options.port || DEFAULT_PORT
|
|
23
25
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const database = new Database({
|
|
27
|
+
database: options.database,
|
|
28
|
+
username: options.username,
|
|
29
|
+
password: options.password,
|
|
30
|
+
host: options.host,
|
|
31
|
+
port: options.port || DEFAULT_PORT,
|
|
32
|
+
schema: options.schema,
|
|
33
|
+
ssl: options.ssl,
|
|
34
|
+
tables: options.tables,
|
|
35
|
+
pool: options.pool,
|
|
36
|
+
useAzureManagedIdentity: options.useAzureManagedIdentity,
|
|
37
|
+
azureClientId: options.azureClientId
|
|
29
38
|
})
|
|
30
39
|
|
|
31
40
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const connection = database.connect()
|
|
42
|
+
await connection.client.raw('select 1')
|
|
43
|
+
debug('database connection succeeded')
|
|
34
44
|
return {
|
|
35
45
|
name: connectionname,
|
|
36
|
-
db:
|
|
46
|
+
db: {
|
|
47
|
+
...connection,
|
|
48
|
+
query: (sql) => connection.client.raw(sql)
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
} catch (e) {
|
|
39
|
-
debug('
|
|
52
|
+
debug('database connection failed')
|
|
40
53
|
debug(e)
|
|
41
54
|
throw e
|
|
42
55
|
}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
*
|
|
3
3
|
* @param {Object} options
|
|
4
4
|
* @param {Object} options.connectionname
|
|
5
|
-
* @param {Object} options.
|
|
5
|
+
* @param {Object} options.connection - the object returned by ffc-database's Database.connect()
|
|
6
6
|
* @returns Connection
|
|
7
7
|
*/
|
|
8
8
|
async function providedConnection (options) {
|
|
9
9
|
const connectionname = options.connectionname
|
|
10
|
-
const
|
|
10
|
+
const connection = options.connection
|
|
11
11
|
return {
|
|
12
12
|
name: connectionname,
|
|
13
|
-
db:
|
|
13
|
+
db: connection ? { ...connection, query: (sql) => connection.client.raw(sql) } : connection
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ffc-pay-etl-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A framework for creating ETL pipelines in node",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/DEFRA/ffc-pay-etl-framework",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@faker-js/faker": "10.5.0",
|
|
16
16
|
"csv-parse": "7.0.2",
|
|
17
|
-
"
|
|
17
|
+
"ffc-database": "2.0.0",
|
|
18
18
|
"validator": "13.15.23"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
@@ -26,12 +26,6 @@
|
|
|
26
26
|
"nodemon": "3.1.4",
|
|
27
27
|
"prettier": "3.3.3"
|
|
28
28
|
},
|
|
29
|
-
"overrides": {
|
|
30
|
-
"sequelize": {
|
|
31
|
-
"uuid": "11.1.1",
|
|
32
|
-
"moment": "2.31.0"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
29
|
"scripts": {
|
|
36
30
|
"test": "PORT=0 node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPatterns=test/unit",
|
|
37
31
|
"test:unit": "PORT=0 node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPatterns=test/unit",
|
|
@@ -49,4 +43,4 @@
|
|
|
49
43
|
"**/test-output/**"
|
|
50
44
|
]
|
|
51
45
|
}
|
|
52
|
-
}
|
|
46
|
+
}
|