@ellipticltd/aml-utils 0.8.0-EN-2570.4 → 0.8.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.
- package/.circleci/config.yml +4 -37
- package/.eslintrc +6 -30
- package/.idea/aml-utils.iml +8 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +52 -0
- package/README.md +0 -39
- package/index.d.ts +1 -0
- package/index.js +8 -0
- package/lib/{middleware/middleware.js → middleware.js} +1 -1
- package/lib/{types/types.js → types.js} +2 -2
- package/lib/{validations/validations.js → validations.js} +8 -8
- package/package.json +13 -28
- package/.huskyrc +0 -5
- package/.mocharc.json +0 -3
- package/.releaserc.json +0 -18
- package/commitlint.config.js +0 -1
- package/dist/errors/errors.d.ts +0 -9
- package/dist/errors/errors.js +0 -42
- package/dist/errors/errors.spec.d.ts +0 -1
- package/dist/errors/errors.spec.js +0 -23
- package/dist/file-parser/__tests/file-parser.spec.d.ts +0 -1
- package/dist/file-parser/__tests/file-parser.spec.js +0 -113
- package/dist/file-parser/__tests/parse-row.spec.d.ts +0 -1
- package/dist/file-parser/__tests/parse-row.spec.js +0 -29
- package/dist/file-parser/__tests/sanitize-rows.spec.d.ts +0 -1
- package/dist/file-parser/__tests/sanitize-rows.spec.js +0 -78
- package/dist/file-parser/errors.d.ts +0 -3
- package/dist/file-parser/errors.js +0 -11
- package/dist/file-parser/file-parser.d.ts +0 -8
- package/dist/file-parser/file-parser.js +0 -68
- package/dist/file-parser/parse-row.d.ts +0 -2
- package/dist/file-parser/parse-row.js +0 -39
- package/dist/file-parser/sanitzeRows.d.ts +0 -3
- package/dist/file-parser/sanitzeRows.js +0 -18
- package/dist/formatting/formatting.d.ts +0 -2
- package/dist/formatting/formatting.js +0 -17
- package/dist/formatting/formatting.spec.d.ts +0 -1
- package/dist/formatting/formatting.spec.js +0 -37
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -20
- package/dist/middleware/middleware.d.ts +0 -4
- package/dist/middleware/middleware.js +0 -22
- package/dist/orm-helpers/ormHelpers.d.ts +0 -1
- package/dist/orm-helpers/ormHelpers.js +0 -17
- package/dist/orm-helpers/ormHelpers.spec.d.ts +0 -1
- package/dist/orm-helpers/ormHelpers.spec.js +0 -38
- package/dist/types/types.d.ts +0 -17
- package/dist/types/types.js +0 -203
- package/dist/validations/validations.d.ts +0 -116
- package/dist/validations/validations.js +0 -296
- package/dist/validations/validations.spec.d.ts +0 -1
- package/dist/validations/validations.spec.js +0 -276
- package/lib/errors/errors.spec.js +0 -37
- package/lib/file-parser/__tests/file-parser.spec.js +0 -101
- package/lib/file-parser/__tests/parse-row.spec.js +0 -35
- package/lib/file-parser/__tests/sanitize-rows.spec.js +0 -88
- package/lib/file-parser/errors.ts +0 -7
- package/lib/file-parser/file-parser.ts +0 -84
- package/lib/file-parser/parse-row.ts +0 -52
- package/lib/file-parser/sanitzeRows.ts +0 -32
- package/lib/formatting/formatting.spec.js +0 -45
- package/lib/index.ts +0 -17
- package/lib/orm-helpers/ormHelpers.spec.js +0 -41
- package/lib/validations/validations.spec.js +0 -355
- package/tsconfig.json +0 -26
- /package/lib/{errors/errors.js → errors.js} +0 -0
- /package/lib/{formatting/formatting.js → formatting.js} +0 -0
- /package/lib/{orm-helpers/ormHelpers.js → ormHelpers.js} +0 -0
package/.circleci/config.yml
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
3
|
executors:
|
|
4
|
-
node-
|
|
4
|
+
node-8_4:
|
|
5
5
|
docker:
|
|
6
|
-
- image: circleci/node:
|
|
6
|
+
- image: circleci/node:8.4.0
|
|
7
7
|
working_directory: /tmp/workspace
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
install:
|
|
11
|
-
executor: node-
|
|
11
|
+
executor: node-8_4
|
|
12
12
|
steps:
|
|
13
13
|
- checkout
|
|
14
14
|
- restore_cache:
|
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
- workspace
|
|
29
29
|
|
|
30
30
|
unit_test:
|
|
31
|
-
executor: node-
|
|
31
|
+
executor: node-8_4
|
|
32
32
|
steps:
|
|
33
33
|
- attach_workspace:
|
|
34
34
|
at: /tmp
|
|
@@ -38,27 +38,6 @@ jobs:
|
|
|
38
38
|
- store_artifacts:
|
|
39
39
|
path: coverage
|
|
40
40
|
|
|
41
|
-
lint:
|
|
42
|
-
executor: node-12
|
|
43
|
-
steps:
|
|
44
|
-
- attach_workspace:
|
|
45
|
-
at: /tmp
|
|
46
|
-
- run:
|
|
47
|
-
name: lint
|
|
48
|
-
command: npm run lint
|
|
49
|
-
|
|
50
|
-
semantic_release:
|
|
51
|
-
executor: node-12
|
|
52
|
-
steps:
|
|
53
|
-
- checkout
|
|
54
|
-
- attach_workspace:
|
|
55
|
-
at: /tmp
|
|
56
|
-
- add_ssh_keys:
|
|
57
|
-
fingerprints:
|
|
58
|
-
- "14:c6:29:a4:9e:45:36:d2:0e:e9:be:41:35:d7:06:23"
|
|
59
|
-
- run:
|
|
60
|
-
command: npx semantic-release
|
|
61
|
-
|
|
62
41
|
workflows:
|
|
63
42
|
version: 2.1
|
|
64
43
|
build-test-deploy:
|
|
@@ -68,15 +47,3 @@ workflows:
|
|
|
68
47
|
- unit_test:
|
|
69
48
|
requires:
|
|
70
49
|
- install
|
|
71
|
-
|
|
72
|
-
- lint:
|
|
73
|
-
requires:
|
|
74
|
-
- install
|
|
75
|
-
|
|
76
|
-
- semantic_release:
|
|
77
|
-
context: npm
|
|
78
|
-
requires:
|
|
79
|
-
- lint
|
|
80
|
-
- unit_test
|
|
81
|
-
|
|
82
|
-
|
package/.eslintrc
CHANGED
|
@@ -1,44 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": [
|
|
2
|
+
"extends": [
|
|
3
|
+
"airbnb"
|
|
4
|
+
],
|
|
3
5
|
"overrides": [
|
|
4
6
|
{
|
|
5
7
|
"files": [
|
|
6
|
-
"*.
|
|
7
|
-
],
|
|
8
|
-
"parser": "@typescript-eslint/parser",
|
|
9
|
-
"parserOptions": {
|
|
10
|
-
"project": "tsconfig.json"
|
|
11
|
-
},
|
|
12
|
-
"rules": {
|
|
13
|
-
"no-unused-vars": 0
|
|
14
|
-
// annoyingly this must be switched off
|
|
15
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/46
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"files": [
|
|
20
|
-
"*.spec.js"
|
|
8
|
+
"*.spec.js",
|
|
21
9
|
],
|
|
22
10
|
"env": {
|
|
23
11
|
"mocha": true
|
|
24
|
-
}
|
|
25
|
-
"rules": {
|
|
26
|
-
"no-unused-expressions": 0,
|
|
27
|
-
"chai-friendly/no-unused-expressions": 2
|
|
28
|
-
},
|
|
29
|
-
"plugins": [
|
|
30
|
-
"chai-friendly"
|
|
31
|
-
]
|
|
12
|
+
}
|
|
32
13
|
}
|
|
33
14
|
],
|
|
34
15
|
"rules": {
|
|
35
16
|
"no-underscore-dangle": 0,
|
|
36
17
|
"prefer-object-spread": 0,
|
|
37
18
|
"new-parens": 0
|
|
38
|
-
},
|
|
39
|
-
"settings": {
|
|
40
|
-
"import/resolver": {
|
|
41
|
-
"typescript": {}
|
|
42
|
-
}
|
|
43
19
|
}
|
|
44
|
-
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/aml-utils.iml" filepath="$PROJECT_DIR$/.idea/aml-utils.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="13258785-846b-4fb0-8bed-0999c26076e5" name="Default Changelist" comment="">
|
|
5
|
+
<change beforePath="$PROJECT_DIR$/lib/validations.js" beforeDir="false" afterPath="$PROJECT_DIR$/lib/validations.js" afterDir="false" />
|
|
6
|
+
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
7
|
+
<change beforePath="$PROJECT_DIR$/test/validations.spec.js" beforeDir="false" afterPath="$PROJECT_DIR$/test/validations.spec.js" afterDir="false" />
|
|
8
|
+
</list>
|
|
9
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
10
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
11
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
12
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
13
|
+
</component>
|
|
14
|
+
<component name="Git.Settings">
|
|
15
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
16
|
+
</component>
|
|
17
|
+
<component name="ProjectId" id="1cYJJDg3VaPA7J75A1iS6a3J7sb" />
|
|
18
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
19
|
+
<component name="ProjectViewState">
|
|
20
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
21
|
+
<option name="showExcludedFiles" value="true" />
|
|
22
|
+
<option name="showLibraryContents" value="true" />
|
|
23
|
+
</component>
|
|
24
|
+
<component name="PropertiesComponent">
|
|
25
|
+
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
26
|
+
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
27
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
28
|
+
<property name="node.js.detected.package.eslint" value="true" />
|
|
29
|
+
<property name="node.js.path.for.package.eslint" value="project" />
|
|
30
|
+
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
|
31
|
+
<property name="nodejs_package_manager_path" value="npm" />
|
|
32
|
+
</component>
|
|
33
|
+
<component name="SvnConfiguration">
|
|
34
|
+
<configuration />
|
|
35
|
+
</component>
|
|
36
|
+
<component name="TaskManager">
|
|
37
|
+
<task active="true" id="Default" summary="Default task">
|
|
38
|
+
<changelist id="13258785-846b-4fb0-8bed-0999c26076e5" name="Default Changelist" comment="" />
|
|
39
|
+
<created>1590699519147</created>
|
|
40
|
+
<option name="number" value="Default" />
|
|
41
|
+
<option name="presentableId" value="Default" />
|
|
42
|
+
<updated>1590699519147</updated>
|
|
43
|
+
<workItem from="1590699522869" duration="144000" />
|
|
44
|
+
<workItem from="1590699690015" duration="407000" />
|
|
45
|
+
<workItem from="1590700324370" duration="1060000" />
|
|
46
|
+
</task>
|
|
47
|
+
<servers />
|
|
48
|
+
</component>
|
|
49
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
50
|
+
<option name="version" value="1" />
|
|
51
|
+
</component>
|
|
52
|
+
</project>
|
package/README.md
CHANGED
|
@@ -6,42 +6,3 @@ This is a library that contains a set of utilities used by aml-api. In particula
|
|
|
6
6
|
- Formatting functions (sql escaping)
|
|
7
7
|
- Validator functions, also used by swagger node middleware. E.g. Bitcoin and Ethereum addresses validators
|
|
8
8
|
- Express middlewares to validate params types
|
|
9
|
-
- An async CSV file parser
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Prereqs
|
|
13
|
-
-------
|
|
14
|
-
|
|
15
|
-
1. Correct version of node (use [nvm](https://github.com/creationix/nvm)).
|
|
16
|
-
|
|
17
|
-
Development
|
|
18
|
-
-----------
|
|
19
|
-
|
|
20
|
-
`nvm use` ensures you are running the correct version of node.js.
|
|
21
|
-
|
|
22
|
-
`npm i` installs your dependencies.
|
|
23
|
-
|
|
24
|
-
`npm run build:dev`:
|
|
25
|
-
- starts webpack on watch mode, recompiling any changes made to the code
|
|
26
|
-
|
|
27
|
-
To test your changes locally go to the repo you are working on's package.json and replace:
|
|
28
|
-
```
|
|
29
|
-
@ellipticltd/aml-utils: "*.*.*"
|
|
30
|
-
```
|
|
31
|
-
with
|
|
32
|
-
```
|
|
33
|
-
@ellipticltd/aml-utils: "file:../front-end-component-kit"
|
|
34
|
-
```
|
|
35
|
-
(if you repositories are in the same directory).
|
|
36
|
-
|
|
37
|
-
Commiting
|
|
38
|
-
-----------
|
|
39
|
-
|
|
40
|
-
This repository uses [Semantic release](https://semantic-release.gitbook.io/) for version publishing. To create a new version of the package simply push to bitbucket and CircleCI will create a new version. No change to this repo's package.json is required.
|
|
41
|
-
|
|
42
|
-
To work out what the next version of package should be a git commit linter is used. This is enforced by Husky and only commits with the following syntax can be [used](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-angular).
|
|
43
|
-
|
|
44
|
-
Setting up Semantic release
|
|
45
|
-
-----------
|
|
46
|
-
|
|
47
|
-
This [article](https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-bitbucket-user-key) explains the integration between Bitbucket and CirlceCI. An NPM token also needs to be provided for the write access to the npm package
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '@ellipticltd/aml-utils';
|
package/index.js
ADDED
|
@@ -2,9 +2,9 @@ const TC = require('type-check');
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
const E = require('
|
|
5
|
+
const E = require('./errors');
|
|
6
6
|
|
|
7
|
-
const V = require('
|
|
7
|
+
const V = require('./validations');
|
|
8
8
|
|
|
9
9
|
const customTypes = {
|
|
10
10
|
Integer: {
|
|
@@ -12,7 +12,8 @@ const addressValidator = require('wallet-address-validator');
|
|
|
12
12
|
const zilUtils = require('@zilliqa-js/util');
|
|
13
13
|
const web3 = require('web3-utils');
|
|
14
14
|
const stellarSDK = require('stellar-sdk');
|
|
15
|
-
const E = require('
|
|
15
|
+
const E = require('./errors');
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
const validations = {
|
|
18
19
|
_validate(Err, pred, x, msg) {
|
|
@@ -103,15 +104,15 @@ const validations = {
|
|
|
103
104
|
isCustomerReference(x) {
|
|
104
105
|
return (
|
|
105
106
|
_.isString(x)
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
&& (x != null ? x.length : undefined) > 0
|
|
108
|
+
&& (x != null ? x.length : undefined) <= 100
|
|
108
109
|
);
|
|
109
110
|
},
|
|
110
111
|
isCustomerLabelName(x) {
|
|
111
112
|
return (
|
|
112
113
|
_.isString(x)
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
&& (x != null ? x.length : undefined) > 0
|
|
115
|
+
&& (x != null ? x.length : undefined) <= 50
|
|
115
116
|
);
|
|
116
117
|
},
|
|
117
118
|
binanceCoin: {
|
|
@@ -123,7 +124,7 @@ const validations = {
|
|
|
123
124
|
return false;
|
|
124
125
|
}
|
|
125
126
|
return str.length === 64;
|
|
126
|
-
}
|
|
127
|
+
}
|
|
127
128
|
},
|
|
128
129
|
bitcoin: {
|
|
129
130
|
isAddress(str) {
|
|
@@ -237,8 +238,7 @@ const validations = {
|
|
|
237
238
|
if (!V.isHexadecimal(str)) {
|
|
238
239
|
return false;
|
|
239
240
|
}
|
|
240
|
-
return str.length === 64;
|
|
241
|
-
},
|
|
241
|
+
return str.length === 64; },
|
|
242
242
|
},
|
|
243
243
|
litecoin: {
|
|
244
244
|
isAddress(str) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ellipticltd/aml-utils",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Utilities, helpers, validations, type-checking, etc",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "10.1.0",
|
|
@@ -11,13 +11,12 @@
|
|
|
11
11
|
"url": "git+ssh://git@bitbucket.org/elliptic/aml-utils.git"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://bitbucket.org/elliptic/aml-utils#readme",
|
|
14
|
-
"main": "
|
|
14
|
+
"main": "index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"lint": "./node_modules/.bin/eslint --color 'lib/**/*.{js,ts}' 'test/**/*.js' ",
|
|
16
|
+
"test:unit": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
|
|
17
|
+
"compile": "./node_modules/coffee-script/bin/coffee -c index.coffee **/*.coffee",
|
|
18
|
+
"preprocess": "npm run compile",
|
|
19
|
+
"lint": "./node_modules/.bin/eslint --color 'lib/**/*.js' 'test/**/*.js' ",
|
|
21
20
|
"test": "nyc npm run test:unit && nyc report --reporter=html",
|
|
22
21
|
"coverage": "nyc npm run test:unit && nyc report --reporter=lcov --reporter=text-lcov | codecov --pipe"
|
|
23
22
|
},
|
|
@@ -35,32 +34,18 @@
|
|
|
35
34
|
"web3-utils": "1.0.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"
|
|
39
|
-
"@commitlint/config-angular": "^11.0.0",
|
|
40
|
-
"@commitlint/config-conventional": "^11.0.0",
|
|
41
|
-
"@semantic-release/git": "^9.0.0",
|
|
42
|
-
"@types/chai": "^4.2.14",
|
|
43
|
-
"@types/lodash": "^4.14.164",
|
|
44
|
-
"@types/mocha": "^8.0.3",
|
|
45
|
-
"@typescript-eslint/parser": "^4.6.1",
|
|
46
|
-
"chai": "^4.2.0",
|
|
37
|
+
"chai": "4.1.1",
|
|
47
38
|
"codecov": "^3.6.1",
|
|
39
|
+
"coffee-script": "1.12.7",
|
|
48
40
|
"eslint": "^6.6.0",
|
|
49
|
-
"eslint-config-airbnb
|
|
50
|
-
"eslint-
|
|
41
|
+
"eslint-config-airbnb": "^18.0.1",
|
|
42
|
+
"eslint-config-airbnb-base": "^14.0.0",
|
|
51
43
|
"eslint-plugin-coffeescript": "^1.0.0",
|
|
52
44
|
"eslint-plugin-import": "^2.18.2",
|
|
53
45
|
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"
|
|
56
|
-
"mocha": "^8.2.1",
|
|
46
|
+
"eslint-plugin-react": "^7.16.0",
|
|
47
|
+
"mocha": "3.5.0",
|
|
57
48
|
"mocha-lcov-reporter": "^1.3.0",
|
|
58
|
-
"nyc": "^14.1.1"
|
|
59
|
-
"semantic-release": "^17.2.2",
|
|
60
|
-
"sinon": "^9.2.1",
|
|
61
|
-
"sinon-chai": "^3.5.0",
|
|
62
|
-
"ts-mocha": "^8.0.0",
|
|
63
|
-
"ts-node": "^9.0.0",
|
|
64
|
-
"typescript": "^4.0.5"
|
|
49
|
+
"nyc": "^14.1.1"
|
|
65
50
|
}
|
|
66
51
|
}
|
package/.huskyrc
DELETED
package/.mocharc.json
DELETED
package/.releaserc.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": [
|
|
3
|
-
"master",
|
|
4
|
-
{
|
|
5
|
-
"name": "*",
|
|
6
|
-
"prerelease": "${name.substring(0,7)}"
|
|
7
|
-
}
|
|
8
|
-
],
|
|
9
|
-
"plugins": [
|
|
10
|
-
"@semantic-release/commit-analyzer",
|
|
11
|
-
"@semantic-release/npm",
|
|
12
|
-
[ "@semantic-release/git", {
|
|
13
|
-
"assets": ["package.json"],
|
|
14
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]"
|
|
15
|
-
}]
|
|
16
|
-
],
|
|
17
|
-
"repositoryUrl": "git@bitbucket.org:elliptic/aml-utils.git"
|
|
18
|
-
}
|
package/commitlint.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = { extends: ['@commitlint/config-angular'] };
|
package/dist/errors/errors.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const RequestError: any;
|
|
2
|
-
export const ServerError: any;
|
|
3
|
-
export const Forbidden: any;
|
|
4
|
-
export const Unauthorized: any;
|
|
5
|
-
export const BadRequest: any;
|
|
6
|
-
export const NotFound: any;
|
|
7
|
-
export const ConflictError: any;
|
|
8
|
-
export const InvalidArguments: any;
|
|
9
|
-
export const ServerTimeout: any;
|
package/dist/errors/errors.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const create = require('create-error');
|
|
3
|
-
const AppError = create('AppError');
|
|
4
|
-
const RequestError = create(AppError, 'RequestError');
|
|
5
|
-
RequestError.toJSON = () => ({
|
|
6
|
-
message: this.message,
|
|
7
|
-
});
|
|
8
|
-
const Forbidden = create(RequestError, 'ForbiddenError', {
|
|
9
|
-
status: 403,
|
|
10
|
-
});
|
|
11
|
-
const Unauthorized = create(RequestError, 'UnauthorizedError', {
|
|
12
|
-
status: 401,
|
|
13
|
-
});
|
|
14
|
-
const BadRequest = create(RequestError, 'BadRequestError', {
|
|
15
|
-
status: 400,
|
|
16
|
-
});
|
|
17
|
-
const NotFound = create(RequestError, 'NotFoundError', {
|
|
18
|
-
status: 404,
|
|
19
|
-
});
|
|
20
|
-
const ConflictError = create(RequestError, 'ConflictError', {
|
|
21
|
-
status: 409,
|
|
22
|
-
});
|
|
23
|
-
const ServerError = create(RequestError, 'ServerError', {
|
|
24
|
-
status: 500,
|
|
25
|
-
});
|
|
26
|
-
const InvalidArguments = create(RequestError, 'InvalidArgumentsError', {
|
|
27
|
-
status: 500,
|
|
28
|
-
});
|
|
29
|
-
const ServerTimeout = create(RequestError, 'ServerTimeoutError', {
|
|
30
|
-
status: 503,
|
|
31
|
-
});
|
|
32
|
-
module.exports = {
|
|
33
|
-
RequestError,
|
|
34
|
-
ServerError,
|
|
35
|
-
Forbidden,
|
|
36
|
-
Unauthorized,
|
|
37
|
-
BadRequest,
|
|
38
|
-
NotFound,
|
|
39
|
-
ConflictError,
|
|
40
|
-
InvalidArguments,
|
|
41
|
-
ServerTimeout,
|
|
42
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const { RequestError, Forbidden, Unauthorized, BadRequest, NotFound, } = require('./errors');
|
|
3
|
-
describe('lib/error', () => {
|
|
4
|
-
describe('RequestError', () => {
|
|
5
|
-
it('should inherit from Error', () => (new RequestError instanceof Error).should.be.true);
|
|
6
|
-
describe('Forbidden Error', () => {
|
|
7
|
-
it('should inherit from Error', () => new Forbidden instanceof Error);
|
|
8
|
-
return it('should inherit from RequestError', () => new Forbidden instanceof RequestError);
|
|
9
|
-
});
|
|
10
|
-
describe('Unauthorized Error', () => {
|
|
11
|
-
it('should inherit from Error', () => new Unauthorized instanceof Error);
|
|
12
|
-
return it('should inherit from RequestError', () => new Unauthorized instanceof RequestError);
|
|
13
|
-
});
|
|
14
|
-
describe('BadRequest Error', () => {
|
|
15
|
-
it('should inherit from Error', () => new BadRequest instanceof Error);
|
|
16
|
-
return it('should inherit from RequestError', () => new BadRequest instanceof RequestError);
|
|
17
|
-
});
|
|
18
|
-
return describe('NotFound Error', () => {
|
|
19
|
-
it('should inherit from Error', () => new NotFound instanceof Error);
|
|
20
|
-
return it('should inherit from RequestError', () => new NotFound instanceof RequestError);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
const sinon_1 = __importDefault(require("sinon"));
|
|
35
|
-
const chai_1 = require("chai");
|
|
36
|
-
const file_parser_1 = __importDefault(require("../file-parser"));
|
|
37
|
-
const sanitizeRows = __importStar(require("../sanitzeRows"));
|
|
38
|
-
const parseRow = __importStar(require("../parse-row"));
|
|
39
|
-
describe('file-parser', () => {
|
|
40
|
-
const dependencies = {
|
|
41
|
-
processRow: sinon_1.default.spy(),
|
|
42
|
-
};
|
|
43
|
-
const parsedRows = [];
|
|
44
|
-
const mockParseRow = sinon_1.default.stub(parseRow, 'default').returns(parsedRows);
|
|
45
|
-
const mockSanitizeRows = sinon_1.default.stub(sanitizeRows, 'default').returns([{}]);
|
|
46
|
-
const mockSetTimeout = sinon_1.default.stub(global, 'setTimeout').callsFake((callback) => callback());
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
sinon_1.default.resetHistory();
|
|
49
|
-
});
|
|
50
|
-
after(() => {
|
|
51
|
-
sinon_1.default.restore();
|
|
52
|
-
});
|
|
53
|
-
it('should call parseRow once per input new line', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const input = '\n';
|
|
55
|
-
yield file_parser_1.default(input, 50, dependencies);
|
|
56
|
-
chai_1.expect(mockParseRow).to.be.calledTwice;
|
|
57
|
-
}));
|
|
58
|
-
it('should call pass parseRow result into sanitizeRows', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
const input = '\n';
|
|
60
|
-
yield file_parser_1.default(input, 50, dependencies);
|
|
61
|
-
chai_1.expect(mockSanitizeRows).to.be.calledOnce;
|
|
62
|
-
chai_1.expect(mockSanitizeRows).to.be.deep.calledWith([[], []], dependencies.processRow);
|
|
63
|
-
}));
|
|
64
|
-
it('should throw error when number of rows is more than max rows', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
const input = '\n';
|
|
66
|
-
mockSanitizeRows.returns(new Array(20));
|
|
67
|
-
try {
|
|
68
|
-
yield file_parser_1.default(input, 10, dependencies);
|
|
69
|
-
chai_1.expect(1).to.equal(2);
|
|
70
|
-
}
|
|
71
|
-
catch (ex) {
|
|
72
|
-
chai_1.expect(ex.name).to.equal('TooManyRowsError');
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
it('should throw error when no rows returned from sanitizeRows', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
const input = '\n';
|
|
77
|
-
mockSanitizeRows.returns([]);
|
|
78
|
-
try {
|
|
79
|
-
yield file_parser_1.default(input, 10, dependencies);
|
|
80
|
-
chai_1.expect(1).to.equal(2);
|
|
81
|
-
}
|
|
82
|
-
catch (ex) {
|
|
83
|
-
chai_1.expect(ex.name).to.equal('Error');
|
|
84
|
-
}
|
|
85
|
-
}));
|
|
86
|
-
it('should throw error an error when content is "invalidFileType"', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
const input = 'invalidFileType';
|
|
88
|
-
mockSanitizeRows.returns([]);
|
|
89
|
-
try {
|
|
90
|
-
yield file_parser_1.default(input, 10, dependencies);
|
|
91
|
-
chai_1.expect(1).to.equal(2);
|
|
92
|
-
}
|
|
93
|
-
catch (ex) {
|
|
94
|
-
chai_1.expect(ex.message).to.equal('Invalid file type');
|
|
95
|
-
}
|
|
96
|
-
}));
|
|
97
|
-
it('should call process row once per row in single timeout', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
const input = '\n';
|
|
99
|
-
const fakeRows = (new Array(30)).fill({});
|
|
100
|
-
mockSanitizeRows.returns(fakeRows);
|
|
101
|
-
yield file_parser_1.default(input, 70, dependencies);
|
|
102
|
-
chai_1.expect(dependencies.processRow).to.be.callCount(30);
|
|
103
|
-
chai_1.expect(mockSetTimeout).to.be.calledOnce;
|
|
104
|
-
}));
|
|
105
|
-
it('should call process row once per row in two timeouts when more than 30 rows', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
const input = '\n';
|
|
107
|
-
const fakeRows = (new Array(50)).fill({});
|
|
108
|
-
mockSanitizeRows.returns(fakeRows);
|
|
109
|
-
yield file_parser_1.default(input, 70, dependencies);
|
|
110
|
-
chai_1.expect(dependencies.processRow).to.be.callCount(50);
|
|
111
|
-
chai_1.expect(mockSetTimeout).to.be.calledTwice;
|
|
112
|
-
}));
|
|
113
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|