ffc-pay-etl-framework 1.4.7 → 2.0.1

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 DEFAULT_PORT = 5432
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 sequelize = new Sequelize(database, username, password, {
25
- host,
26
- port,
27
- dialect: 'postgres',
28
- logging: false
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
- await sequelize.authenticate()
33
- debug('sequelize.authenticate succeeded')
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: sequelize
46
+ db: {
47
+ ...connection,
48
+ query: (sql) => connection.client.raw(sql)
49
+ }
37
50
  }
38
51
  } catch (e) {
39
- debug('sequelize.authenticate failed')
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.sequelize
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 sequelize = options.sequelize
10
+ const connection = options.connection
11
11
  return {
12
12
  name: connectionname,
13
- db: sequelize
13
+ db: connection ? { ...connection, query: (sql) => connection.client.raw(sql) } : connection
14
14
  }
15
15
  }
16
16
 
@@ -27,7 +27,18 @@ function fakerTransformer (options) {
27
27
  throw new Error(`Locale "${options.locale}" is not supported by Faker v10.`)
28
28
  }
29
29
 
30
- faker = new Faker({ locale: selectedLocale })
30
+ // Build a fallback chain so undefined locale data (e.g. company.name_pattern in en_GB)
31
+ // falls back through en and finally base, matching Faker v10's locale resolution.
32
+ // Faker v10's allLocales registry always includes 'en' and 'base'.
33
+ const localeChain = [selectedLocale]
34
+ if (localeKey !== 'en') {
35
+ localeChain.push(allLocales.en)
36
+ }
37
+ if (localeKey !== 'base') {
38
+ localeChain.push(allLocales.base)
39
+ }
40
+
41
+ faker = new Faker({ locale: localeChain })
31
42
  } else {
32
43
  faker = defaultFaker
33
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-etl-framework",
3
- "version": "1.4.7",
3
+ "version": "2.0.1",
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
- "sequelize": "6.37.8",
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",