@natlibfi/oracledb-mock 1.0.0 → 1.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.
@@ -0,0 +1,2 @@
1
+ # With this line @NatLibFi/melinda-js-lead owns any files in this repository
2
+ * @NatLibFi/melinda-js-lead
@@ -0,0 +1,40 @@
1
+ # NatLibFi/Melinda maintenance strategy
2
+ # https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ # Maintain dependencies for GitHub Actions
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+ time: "06:30"
12
+ timezone: "Europe/Helsinki"
13
+ target-branch: "dependencies"
14
+
15
+ # Minor updates to npm production dependencies daily
16
+ - package-ecosystem: "npm"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "daily"
20
+ time: "06:45"
21
+ timezone: "Europe/Helsinki"
22
+ versioning-strategy: lockfile-only
23
+ allow:
24
+ - dependency-type: "production"
25
+ target-branch: "dependencies"
26
+
27
+ # Major updates to npm dependencies weekly @tuesday
28
+ # Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
29
+ # - package-ecosystem: "npm"
30
+ # directory: "/"
31
+ # schedule:
32
+ # interval: "weekly"
33
+ # day: "tuesday"
34
+ # time: "07:00"
35
+ # timezone: "Europe/Helsinki"
36
+ # versioning-strategy: increase-if-necessary
37
+ # labels:
38
+ # - "npm major dependencies"
39
+ # reviewers:
40
+ # - "natlibfi/melinda-js-lead"
@@ -0,0 +1,70 @@
1
+ # Melinda node tests
2
+
3
+ name: Melinda-node-tests
4
+
5
+ on: push
6
+
7
+ jobs:
8
+ build-node-versions:
9
+ name: Node version matrix
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ node-version: [18.x, 19.x]
15
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
16
+
17
+ steps:
18
+ - name: Checkout the code
19
+ uses: actions/checkout@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v3
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+ env:
26
+ NPM_CONFIG_IGNORE_SCRIPTS: true
27
+ - run: npm audit --package-lock-only --production --audit-level=moderate
28
+ - run: npm i
29
+ - run: npm test
30
+ - run: npm run build --if-present
31
+
32
+ njsscan:
33
+ name: Njsscan-check
34
+ runs-on: ubuntu-latest
35
+
36
+ steps:
37
+ - name: Checkout the code
38
+ uses: actions/checkout@v3
39
+ - name: nodejsscan scan
40
+ id: njsscan
41
+ uses: ajinabraham/njsscan-action@master
42
+ with:
43
+ args: '.'
44
+
45
+ license-scan:
46
+ name: License compliance check
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - uses: actions/checkout@v3
51
+ - uses: mikaelvesavuori/license-compliance-action@v1.0.2
52
+ with:
53
+ exclude_pattern: /^@natlibfi/
54
+
55
+ publish:
56
+ runs-on: ubuntu-latest
57
+ needs: [build-node-versions, njsscan]
58
+ if: contains(github.ref, 'refs/tags/')
59
+
60
+ steps:
61
+ - uses: actions/checkout@v3
62
+ # Setup .npmrc file to publish to npm
63
+ - uses: actions/setup-node@v3
64
+ with:
65
+ node-version: '18.x'
66
+ registry-url: 'https://registry.npmjs.org'
67
+ - run: npm i
68
+ - run: npm publish
69
+ env:
70
+ NODE_AUTH_TOKEN: ${{ secrets.ORACLEDB_MOCK_NPM_TOKEN }}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/oracledb-mock-js.git"
15
15
  },
16
16
  "license": "LGPL-3.0+",
17
- "version": "1.0.0",
17
+ "version": "1.0.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=12"
@@ -36,22 +36,22 @@
36
36
  "deep-eql": "^4.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/cli": "^7.10.1",
40
- "@babel/core": "^7.10.1",
41
- "@babel/node": "^7.10.1",
42
- "@babel/preset-env": "^7.10.1",
43
- "@babel/register": "^7.10.1",
44
- "@natlibfi/eslint-config-melinda-backend": "^1.0.3",
45
- "@natlibfi/fixugen": "^1.0.0",
46
- "@natlibfi/fixura": "^2.1.2",
47
- "babel-eslint": "^10.1.0",
39
+ "@babel/cli": "^7.22.9",
40
+ "@babel/core": "^7.22.9",
41
+ "@babel/eslint-parser": "^7.22.9",
42
+ "@babel/node": "^7.22.6",
43
+ "@babel/preset-env": "^7.22.9",
44
+ "@babel/register": "^7.22.5",
45
+ "@natlibfi/eslint-config-melinda-backend": "^3.0.0",
46
+ "@natlibfi/fixugen": "^2.0.0",
47
+ "@natlibfi/fixura": "^3.0.0",
48
48
  "babel-plugin-istanbul": "^6.0.0",
49
49
  "chai": "^4.2.0",
50
50
  "cross-env": "^7.0.2",
51
- "eslint": "^7.0.0",
52
- "mocha": "^7.1.2",
53
- "nodemon": "^2.0.4",
54
- "nyc": "^15.0.1"
51
+ "eslint": "^8.45.0",
52
+ "mocha": "^10.2.0",
53
+ "nodemon": "^3.0.1",
54
+ "nyc": "^15.1.0"
55
55
  },
56
56
  "eslintConfig": {
57
57
  "extends": "@natlibfi/melinda-backend"
@@ -61,9 +61,7 @@
61
61
  [
62
62
  "@babel/preset-env",
63
63
  {
64
- "targets": {
65
- "node": "12"
66
- }
64
+ "targets": "maintained node versions"
67
65
  }
68
66
  ]
69
67
  ],
@@ -80,8 +78,7 @@
80
78
  "*/*.spec.js"
81
79
  ],
82
80
  "reporter": [
83
- "lcov",
84
- "html"
81
+ "text"
85
82
  ],
86
83
  "require": [
87
84
  "@babel/register"
package/dist/index.js DELETED
@@ -1,112 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _deepEql = _interopRequireDefault(require("deep-eql"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /**
13
- *
14
- * @licstart The following is the entire license notice for the JavaScript code in this file.
15
- *
16
- * A mock for oracledb Node.js module
17
- *
18
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
19
- *
20
- * This file is part of oracledb-mock-js
21
- *
22
- * oracledb-mock-js program is free software: you can redistribute it and/or modify
23
- * it under the terms of the GNU Affero General Public License as
24
- * published by the Free Software Foundation, either version 3 of the
25
- * License, or (at your option) any later version.
26
- *
27
- * oracledb-mock-js is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU Affero General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU Affero General Public License
33
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- *
35
- * @licend The above is the entire license notice
36
- * for the JavaScript code in this file.
37
- *
38
- */
39
- var _default = () => {
40
- const options = [];
41
- const DEFAULT_OPTIONS = {
42
- queryPattern: /.*/u,
43
- results: []
44
- };
45
- const connection = {
46
- close: () => {},
47
- // eslint-disable-line no-empty-function
48
- break: () => {},
49
- // eslint-disable-line no-empty-function
50
- execute: (query, args) => {
51
- const rows = getRows();
52
- return {
53
- resultSet: {
54
- getRow: () => rows.shift(),
55
- // eslint-disable-line functional/immutable-data
56
- close: () => {} // eslint-disable-line no-empty-function
57
-
58
- }
59
- };
60
-
61
- function getRows() {
62
- const index = options.findIndex(({
63
- queryPattern,
64
- expectedArgs
65
- }) => {
66
- if (queryPattern.test(query) && (expectedArgs === undefined || (0, _deepEql.default)(args, expectedArgs))) {
67
- return true;
68
- }
69
-
70
- return false;
71
- });
72
-
73
- if (index >= 0) {
74
- const {
75
- results
76
- } = options.splice(index, 1).shift(); // eslint-disable-line functional/immutable-data
77
-
78
- return results;
79
- }
80
-
81
- return [];
82
- }
83
- }
84
- };
85
- return {
86
- getConnection: () => connection,
87
- createPool: () => ({
88
- getConnection: () => connection,
89
- close: () => {} // eslint-disable-line no-empty-function
90
-
91
- }),
92
- _clear: () => {
93
- // Clear array
94
- options.splice(0); // eslint-disable-line functional/immutable-data
95
-
96
- Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data
97
- },
98
- _execute: optList => {
99
- // Clear array
100
- options.splice(0); // eslint-disable-line functional/immutable-data
101
-
102
- optList.forEach(opts => {
103
- options.push({ ...DEFAULT_OPTIONS,
104
- ...opts
105
- }); // eslint-disable-line functional/immutable-data
106
- });
107
- }
108
- };
109
- };
110
-
111
- exports.default = _default;
112
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["options","DEFAULT_OPTIONS","queryPattern","results","connection","close","break","execute","query","args","rows","getRows","resultSet","getRow","shift","index","findIndex","expectedArgs","test","undefined","splice","getConnection","createPool","_clear","Object","keys","forEach","k","_execute","optList","opts","push"],"mappings":";;;;;;;AA4BA;;;;AA5BA;;;;;;;;;;;;;;;;;;;;;;;;;;;eA8Be,MAAM;AACnB,QAAMA,OAAO,GAAG,EAAhB;AACA,QAAMC,eAAe,GAAG;AACtBC,IAAAA,YAAY,EAAE,KADQ;AAEtBC,IAAAA,OAAO,EAAE;AAFa,GAAxB;AAKA,QAAMC,UAAU,GAAG;AACjBC,IAAAA,KAAK,EAAE,MAAM,CAAE,CADE;AACA;AACjBC,IAAAA,KAAK,EAAE,MAAM,CAAE,CAFE;AAEA;AACjBC,IAAAA,OAAO,EAAE,CAACC,KAAD,EAAQC,IAAR,KAAiB;AACxB,YAAMC,IAAI,GAAGC,OAAO,EAApB;AAEA,aAAO;AACLC,QAAAA,SAAS,EAAE;AACTC,UAAAA,MAAM,EAAE,MAAMH,IAAI,CAACI,KAAL,EADL;AACmB;AAC5BT,UAAAA,KAAK,EAAE,MAAM,CAAE,CAFN,CAEO;;AAFP;AADN,OAAP;;AAOA,eAASM,OAAT,GAAmB;AACjB,cAAMI,KA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C9C,OAFD;AAGD;AAlBI,GAAP;AAoBD,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* A mock for oracledb Node.js module\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of oracledb-mock-js\n*\n* oracledb-mock-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* oracledb-mock-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport deepEqual from 'deep-eql';\n\nexport default () => {\n const options = [];\n const DEFAULT_OPTIONS = {\n queryPattern: /.*/u,\n results: []\n };\n\n const connection = {\n close: () => {}, // eslint-disable-line no-empty-function\n break: () => {}, // eslint-disable-line no-empty-function\n execute: (query, args) => {\n const rows = getRows();\n\n return {\n resultSet: {\n getRow: () => rows.shift(), // eslint-disable-line functional/immutable-data\n close: () => {} // eslint-disable-line no-empty-function\n }\n };\n\n function getRows() {\n const index = options.findIndex(({queryPattern, expectedArgs}) => {\n if (queryPattern.test(query) && (expectedArgs === undefined || deepEqual(args, expectedArgs))) {\n return true;\n }\n\n return false;\n });\n\n if (index >= 0) {\n const {results} = options.splice(index, 1).shift(); // eslint-disable-line functional/immutable-data\n return results;\n }\n\n return [];\n }\n }\n };\n\n return {\n getConnection: () => connection,\n createPool: () => ({\n getConnection: () => connection,\n close: () => {} // eslint-disable-line no-empty-function\n }),\n _clear: () => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data\n },\n _execute: optList => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n\n optList.forEach(opts => {\n options.push({...DEFAULT_OPTIONS, ...opts}); // eslint-disable-line functional/immutable-data\n });\n }\n };\n};\n"],"file":"index.js"}
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- var _ = _interopRequireDefault(require("."));
4
-
5
- var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
6
-
7
- var _chai = require("chai");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- /**
12
- *
13
- * @licstart The following is the entire license notice for the JavaScript code in this file.
14
- *
15
- * A mock for oracledb Node.js module
16
- *
17
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
18
- *
19
- * This file is part of oracledb-mock-js
20
- *
21
- * oracledb-mock-js program is free software: you can redistribute it and/or modify
22
- * it under the terms of the GNU Affero General Public License as
23
- * published by the Free Software Foundation, either version 3 of the
24
- * License, or (at your option) any later version.
25
- *
26
- * oracledb-mock-js is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
- * GNU Affero General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU Affero General Public License
32
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
- *
34
- * @licend The above is the entire license notice
35
- * for the JavaScript code in this file.
36
- *
37
- */
38
- (0, _fixugen.default)({
39
- useMetadataFile: true,
40
- path: [__dirname, '..', 'test-fixtures'],
41
- callback: async ({
42
- dbResults,
43
- usePool = false,
44
- expectedResults,
45
- query,
46
- args = {}
47
- }) => {
48
- const mock = (0, _.default)();
49
-
50
- mock._execute(formatDbResults());
51
-
52
- if (usePool) {
53
- const pool = await mock.createPool();
54
- const connection = await pool.getConnection();
55
- const {
56
- resultSet
57
- } = await connection.execute(query, args);
58
- const results = await fetchResults(resultSet);
59
- (0, _chai.expect)(results).to.eql(expectedResults);
60
- await connection.close();
61
- await pool.close();
62
-
63
- mock._clear();
64
-
65
- return;
66
- }
67
-
68
- const connection = await mock.getConnection();
69
- const {
70
- resultSet
71
- } = await connection.execute(query, args);
72
- const results = await fetchResults(resultSet);
73
- (0, _chai.expect)(results).to.eql(expectedResults);
74
- await connection.close();
75
-
76
- mock._clear();
77
-
78
- async function fetchResults(resultSet, results = []) {
79
- const row = await resultSet.getRow();
80
-
81
- if (row) {
82
- return fetchResults(resultSet, results.concat(row));
83
- }
84
-
85
- await resultSet.close();
86
- return results;
87
- }
88
-
89
- function formatDbResults() {
90
- return dbResults.map(({
91
- queryPattern,
92
- ...rest
93
- }) => {
94
- if (queryPattern) {
95
- return { ...rest,
96
- queryPattern: new RegExp(queryPattern, 'u')
97
- };
98
- }
99
-
100
- return rest;
101
- });
102
- }
103
- }
104
- });
105
- //# sourceMappingURL=index.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.spec.js"],"names":["useMetadataFile","path","__dirname","callback","dbResults","usePool","expectedResults","query","args","mock","_execute","formatDbResults","pool","createPool","connection","getConnection","resultSet","execute","results","fetchResults","to","eql","close","_clear","row","getRow","concat","map","queryPattern","rest","RegExp"],"mappings":";;AA4BA;;AACA;;AACA;;;;AA9BA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,sBAAc;AACZA,EAAAA,eAAe,EAAE,IADL;AAEZC,EAAAA,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,eAAlB,CAFM;AAGZC,EAAAA,QAAQ,EAAE,OAAO;AAACC,IAAAA,SAAD;AAAYC,IAAAA,OAAO,GAAG,KAAtB;AAA6BC,IAAAA,eAA7B;AAA8CC,IAAAA,KAA9C;AAAqDC,IAAAA,IAAI,GAAG;AAA5D,GAAP,KAA2E;AACnF,UAAMC,IAAI,GAAG,gBAAb;;AAEAA,IAAAA,IAAI,CAACC,QAAL,CAAcC,eAAe,EAA7B;;AAEA,QAAIN,OAAJ,EAAa;AACX,YAAMO,IAAI,GAAG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AJ,EAAkB;AAChB,iBAAO,EACL,GAAGC,IADE;AAELD,YAAAA,YAAY,EAAE,IAAIE,MAAJ,CAAWF,YAAX,EAAyB,GAAzB;AAFT,WAAP;AAID;;AAED,eAAOC,IAAP;AACD,OATM,CAAP;AAUD;AACF;AAvDW,CAAd","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* A mock for oracledb Node.js module\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of oracledb-mock-js\n*\n* oracledb-mock-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* oracledb-mock-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createMock from '.';\nimport generateTests from '@natlibfi/fixugen';\nimport {expect} from 'chai';\n\ngenerateTests({\n useMetadataFile: true,\n path: [__dirname, '..', 'test-fixtures'],\n callback: async ({dbResults, usePool = false, expectedResults, query, args = {}}) => {\n const mock = createMock();\n\n mock._execute(formatDbResults());\n\n if (usePool) {\n const pool = await mock.createPool();\n const connection = await pool.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n expect(results).to.eql(expectedResults);\n\n await connection.close();\n await pool.close();\n\n mock._clear();\n return;\n }\n\n const connection = await mock.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n expect(results).to.eql(expectedResults);\n\n await connection.close();\n mock._clear();\n\n async function fetchResults(resultSet, results = []) {\n const row = await resultSet.getRow();\n\n if (row) {\n return fetchResults(resultSet, results.concat(row));\n }\n\n await resultSet.close();\n return results;\n }\n\n function formatDbResults() {\n return dbResults.map(({queryPattern, ...rest}) => {\n if (queryPattern) {\n return {\n ...rest,\n queryPattern: new RegExp(queryPattern, 'u')\n };\n }\n\n return rest;\n });\n }\n }\n});\n"],"file":"index.spec.js"}