@ellipticltd/aml-utils 0.3.0 → 0.4.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 +3 -1
- package/.eslintrc +19 -2
- package/.idea/aml-utils.iml +12 -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 +208 -0
- package/.nycrc.json +11 -0
- package/codecov.yml +29 -0
- package/lib/formatting.js +1 -1
- package/lib/middleware.js +1 -1
- package/lib/ormHelpers.js +12 -13
- package/lib/types.js +10 -8
- package/lib/validations.js +11 -12
- package/package.json +19 -10
package/.circleci/config.yml
CHANGED
package/.eslintrc
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": [
|
|
3
|
-
|
|
2
|
+
"extends": [
|
|
3
|
+
"airbnb"
|
|
4
|
+
],
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": [
|
|
8
|
+
"*.spec.js",
|
|
9
|
+
],
|
|
10
|
+
"env": {
|
|
11
|
+
"mocha": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"rules": {
|
|
16
|
+
"no-underscore-dangle": 0,
|
|
17
|
+
"prefer-object-spread": 0,
|
|
18
|
+
"new-parens": 0
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</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,208 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="">
|
|
5
|
+
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
6
|
+
</list>
|
|
7
|
+
<ignored path="$PROJECT_DIR$/.tmp/" />
|
|
8
|
+
<ignored path="$PROJECT_DIR$/temp/" />
|
|
9
|
+
<ignored path="$PROJECT_DIR$/tmp/" />
|
|
10
|
+
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
|
11
|
+
<option name="TRACKING_ENABLED" value="true" />
|
|
12
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
13
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
14
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
15
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
16
|
+
</component>
|
|
17
|
+
<component name="FileEditorManager">
|
|
18
|
+
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
|
19
|
+
<file leaf-file-name="package.json" pinned="false" current-in-tab="true">
|
|
20
|
+
<entry file="file://$PROJECT_DIR$/package.json">
|
|
21
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
22
|
+
<state relative-caret-position="26">
|
|
23
|
+
<caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
|
|
24
|
+
</state>
|
|
25
|
+
</provider>
|
|
26
|
+
</entry>
|
|
27
|
+
</file>
|
|
28
|
+
<file leaf-file-name="validations.js" pinned="false" current-in-tab="false">
|
|
29
|
+
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
30
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
31
|
+
<state relative-caret-position="399">
|
|
32
|
+
<caret line="148" column="7" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
33
|
+
</state>
|
|
34
|
+
</provider>
|
|
35
|
+
</entry>
|
|
36
|
+
</file>
|
|
37
|
+
</leaf>
|
|
38
|
+
</component>
|
|
39
|
+
<component name="FindInProjectRecents">
|
|
40
|
+
<findStrings>
|
|
41
|
+
<find>addressVal</find>
|
|
42
|
+
</findStrings>
|
|
43
|
+
</component>
|
|
44
|
+
<component name="Git.Settings">
|
|
45
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
46
|
+
</component>
|
|
47
|
+
<component name="IdeDocumentHistory">
|
|
48
|
+
<option name="CHANGED_PATHS">
|
|
49
|
+
<list>
|
|
50
|
+
<option value="$PROJECT_DIR$/lib/validations.js" />
|
|
51
|
+
<option value="$PROJECT_DIR$/package.json" />
|
|
52
|
+
</list>
|
|
53
|
+
</option>
|
|
54
|
+
</component>
|
|
55
|
+
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
|
56
|
+
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
|
|
57
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
58
|
+
</component>
|
|
59
|
+
<component name="JsGulpfileManager">
|
|
60
|
+
<detection-done>true</detection-done>
|
|
61
|
+
<sorting>DEFINITION_ORDER</sorting>
|
|
62
|
+
</component>
|
|
63
|
+
<component name="NodeModulesDirectoryManager">
|
|
64
|
+
<handled-path value="$PROJECT_DIR$/node_modules" />
|
|
65
|
+
</component>
|
|
66
|
+
<component name="NodePackageJsonFileManager">
|
|
67
|
+
<packageJsonPaths>
|
|
68
|
+
<path value="$PROJECT_DIR$/package.json" />
|
|
69
|
+
</packageJsonPaths>
|
|
70
|
+
</component>
|
|
71
|
+
<component name="ProjectFrameBounds" extendedState="6">
|
|
72
|
+
<option name="y" value="23" />
|
|
73
|
+
<option name="width" value="1680" />
|
|
74
|
+
<option name="height" value="1027" />
|
|
75
|
+
</component>
|
|
76
|
+
<component name="ProjectView">
|
|
77
|
+
<navigator proportions="" version="1">
|
|
78
|
+
<foldersAlwaysOnTop value="true" />
|
|
79
|
+
</navigator>
|
|
80
|
+
<panes>
|
|
81
|
+
<pane id="Scope" />
|
|
82
|
+
<pane id="ProjectPane">
|
|
83
|
+
<subPane>
|
|
84
|
+
<expand>
|
|
85
|
+
<path>
|
|
86
|
+
<item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
|
|
87
|
+
<item name="aml-utils" type="462c0819:PsiDirectoryNode" />
|
|
88
|
+
</path>
|
|
89
|
+
<path>
|
|
90
|
+
<item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
|
|
91
|
+
<item name="aml-utils" type="462c0819:PsiDirectoryNode" />
|
|
92
|
+
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
|
93
|
+
</path>
|
|
94
|
+
</expand>
|
|
95
|
+
<select />
|
|
96
|
+
</subPane>
|
|
97
|
+
</pane>
|
|
98
|
+
</panes>
|
|
99
|
+
</component>
|
|
100
|
+
<component name="PropertiesComponent">
|
|
101
|
+
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
102
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
103
|
+
<property name="node.js.detected.package.eslint" value="true" />
|
|
104
|
+
<property name="node.js.path.for.package.eslint" value="project" />
|
|
105
|
+
<property name="node.js.selected.package.eslint" value="$PROJECT_DIR$/node_modules/eslint" />
|
|
106
|
+
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
|
107
|
+
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
|
108
|
+
<property name="nodejs_package_manager_path" value="npm" />
|
|
109
|
+
</component>
|
|
110
|
+
<component name="RunDashboard">
|
|
111
|
+
<option name="ruleStates">
|
|
112
|
+
<list>
|
|
113
|
+
<RuleState>
|
|
114
|
+
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
|
115
|
+
</RuleState>
|
|
116
|
+
<RuleState>
|
|
117
|
+
<option name="name" value="StatusDashboardGroupingRule" />
|
|
118
|
+
</RuleState>
|
|
119
|
+
</list>
|
|
120
|
+
</option>
|
|
121
|
+
</component>
|
|
122
|
+
<component name="SvnConfiguration">
|
|
123
|
+
<configuration />
|
|
124
|
+
</component>
|
|
125
|
+
<component name="TaskManager">
|
|
126
|
+
<task active="true" id="Default" summary="Default task">
|
|
127
|
+
<changelist id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="" />
|
|
128
|
+
<created>1563360614655</created>
|
|
129
|
+
<option name="number" value="Default" />
|
|
130
|
+
<option name="presentableId" value="Default" />
|
|
131
|
+
<updated>1563360614655</updated>
|
|
132
|
+
<workItem from="1563360615721" duration="151000" />
|
|
133
|
+
<workItem from="1567667753338" duration="597000" />
|
|
134
|
+
<workItem from="1574357456118" duration="8000" />
|
|
135
|
+
</task>
|
|
136
|
+
<servers />
|
|
137
|
+
</component>
|
|
138
|
+
<component name="TimeTrackingManager">
|
|
139
|
+
<option name="totallyTimeSpent" value="756000" />
|
|
140
|
+
</component>
|
|
141
|
+
<component name="ToolWindowManager">
|
|
142
|
+
<frame x="0" y="23" width="1920" height="1057" extended-state="6" />
|
|
143
|
+
<editor active="true" />
|
|
144
|
+
<layout>
|
|
145
|
+
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24907847" />
|
|
146
|
+
<window_info anchor="bottom" id="TODO" order="6" />
|
|
147
|
+
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
|
148
|
+
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
|
149
|
+
<window_info anchor="bottom" id="Version Control" order="7" />
|
|
150
|
+
<window_info id="npm" order="2" side_tool="true" />
|
|
151
|
+
<window_info anchor="bottom" id="Run" order="2" />
|
|
152
|
+
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
|
153
|
+
<window_info anchor="bottom" id="Terminal" order="7" />
|
|
154
|
+
<window_info id="Favorites" order="2" side_tool="true" />
|
|
155
|
+
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
|
156
|
+
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
|
157
|
+
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
|
158
|
+
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
|
159
|
+
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
|
160
|
+
<window_info anchor="bottom" id="Message" order="0" />
|
|
161
|
+
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
|
162
|
+
<window_info anchor="bottom" id="Find" order="1" />
|
|
163
|
+
</layout>
|
|
164
|
+
</component>
|
|
165
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
166
|
+
<option name="version" value="1" />
|
|
167
|
+
</component>
|
|
168
|
+
<component name="VcsContentAnnotationSettings">
|
|
169
|
+
<option name="myLimit" value="2678400000" />
|
|
170
|
+
</component>
|
|
171
|
+
<component name="editorHistoryManager">
|
|
172
|
+
<entry file="file://$PROJECT_DIR$/package.json">
|
|
173
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
174
|
+
<state relative-caret-position="364">
|
|
175
|
+
<caret line="28" column="27" lean-forward="true" selection-start-line="28" selection-start-column="27" selection-end-line="28" selection-end-column="27" />
|
|
176
|
+
</state>
|
|
177
|
+
</provider>
|
|
178
|
+
</entry>
|
|
179
|
+
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
180
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
181
|
+
<state relative-caret-position="1924">
|
|
182
|
+
<caret line="148" column="7" lean-forward="true" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
183
|
+
</state>
|
|
184
|
+
</provider>
|
|
185
|
+
</entry>
|
|
186
|
+
<entry file="file://$PROJECT_DIR$/package.json">
|
|
187
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
188
|
+
<state relative-caret-position="364">
|
|
189
|
+
<caret line="28" column="24" selection-start-line="28" selection-start-column="24" selection-end-line="28" selection-end-column="24" />
|
|
190
|
+
</state>
|
|
191
|
+
</provider>
|
|
192
|
+
</entry>
|
|
193
|
+
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
194
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
195
|
+
<state relative-caret-position="399">
|
|
196
|
+
<caret line="148" column="7" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
197
|
+
</state>
|
|
198
|
+
</provider>
|
|
199
|
+
</entry>
|
|
200
|
+
<entry file="file://$PROJECT_DIR$/package.json">
|
|
201
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
202
|
+
<state relative-caret-position="26">
|
|
203
|
+
<caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
|
|
204
|
+
</state>
|
|
205
|
+
</provider>
|
|
206
|
+
</entry>
|
|
207
|
+
</component>
|
|
208
|
+
</project>
|
package/.nycrc.json
ADDED
package/codecov.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
codecov:
|
|
2
|
+
require_ci_to_pass: yes
|
|
3
|
+
|
|
4
|
+
coverage:
|
|
5
|
+
precision: 2
|
|
6
|
+
round: down
|
|
7
|
+
range: "70...100"
|
|
8
|
+
|
|
9
|
+
status:
|
|
10
|
+
project:
|
|
11
|
+
default:
|
|
12
|
+
target: 85%
|
|
13
|
+
patch:
|
|
14
|
+
default:
|
|
15
|
+
target: 85%
|
|
16
|
+
changes: no
|
|
17
|
+
|
|
18
|
+
parsers:
|
|
19
|
+
gcov:
|
|
20
|
+
branch_detection:
|
|
21
|
+
conditional: yes
|
|
22
|
+
loop: yes
|
|
23
|
+
method: no
|
|
24
|
+
macro: no
|
|
25
|
+
|
|
26
|
+
comment:
|
|
27
|
+
layout: "reach,diff,flags,tree"
|
|
28
|
+
behavior: default
|
|
29
|
+
require_changes: no
|
package/lib/formatting.js
CHANGED
|
@@ -10,7 +10,7 @@ const rethrowError = (fnName, e) => {
|
|
|
10
10
|
return `${fnName} - ${e.name}: ${e.statusCode} - ${formattedError}`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const sqlEscapeWildcard = str => str.replace(/_|%|\\/g, x => `\\${x}`);
|
|
13
|
+
const sqlEscapeWildcard = (str) => str.replace(/_|%|\\/g, (x) => `\\${x}`);
|
|
14
14
|
|
|
15
15
|
module.exports = {
|
|
16
16
|
rethrowError,
|
package/lib/middleware.js
CHANGED
package/lib/ormHelpers.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
|
|
3
|
-
const includeNested = (orm, models) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
3
|
+
const includeNested = (orm, models) => _.map(_.toPairs(models), (arg) => {
|
|
4
|
+
const [modelName, inclusion] = arg;
|
|
5
|
+
const include = includeNested(orm, inclusion);
|
|
6
|
+
const model = orm[modelName];
|
|
7
|
+
if (_.isEmpty(include)) {
|
|
8
|
+
return model;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
model,
|
|
12
|
+
include,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
16
15
|
|
|
17
16
|
module.exports = {
|
|
18
17
|
includeNested,
|
package/lib/types.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const TC = require('type-check');
|
|
2
2
|
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
|
|
3
5
|
const E = require('./errors');
|
|
4
6
|
|
|
5
7
|
const V = require('./validations');
|
|
6
8
|
|
|
7
|
-
const _ = require('lodash');
|
|
8
|
-
|
|
9
9
|
const customTypes = {
|
|
10
10
|
Integer: {
|
|
11
11
|
typeOf: 'Number',
|
|
@@ -152,8 +152,7 @@ const withNullable = Object.keys(customTypes).reduce((acc, _type) => {
|
|
|
152
152
|
|
|
153
153
|
// for every type, add Nullable+type. A nullable string can also be empty
|
|
154
154
|
acc[`Nullable${_type}`] = Object.assign({}, customTypes[_type], {
|
|
155
|
-
validate: x =>
|
|
156
|
-
x == null || (typeOf === 'String' && x === '') || validate(x),
|
|
155
|
+
validate: (x) => x == null || (typeOf === 'String' && x === '') || validate(x),
|
|
157
156
|
});
|
|
158
157
|
|
|
159
158
|
return acc;
|
|
@@ -176,10 +175,13 @@ module.exports = {
|
|
|
176
175
|
return V.ensure(this.typeCheck(type, obj), msg);
|
|
177
176
|
},
|
|
178
177
|
checkArg(obj, prop, type, msg) {
|
|
178
|
+
let message;
|
|
179
179
|
if (msg == null) {
|
|
180
|
-
|
|
180
|
+
message = `Invalid ${prop}`;
|
|
181
|
+
} else {
|
|
182
|
+
message = msg;
|
|
181
183
|
}
|
|
182
|
-
this.ensureType(type, obj[prop],
|
|
184
|
+
this.ensureType(type, obj[prop], message);
|
|
183
185
|
return obj[prop];
|
|
184
186
|
},
|
|
185
187
|
checkArgs(input, types) {
|
|
@@ -197,8 +199,8 @@ module.exports = {
|
|
|
197
199
|
numKeys = 0;
|
|
198
200
|
|
|
199
201
|
Object.keys(fields).forEach((key) => {
|
|
200
|
-
|
|
201
|
-
V.ensure(this.parsedTypeCheck(
|
|
202
|
+
const objTypes = fields[key];
|
|
203
|
+
V.ensure(this.parsedTypeCheck(objTypes, input[key]), `Invalid ${key}`);
|
|
202
204
|
if (inputKeys[key]) {
|
|
203
205
|
numKeys += 1;
|
|
204
206
|
}
|
package/lib/validations.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const E = require('./errors');
|
|
2
1
|
const V = require('validator');
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
const {
|
|
@@ -11,6 +10,7 @@ const {
|
|
|
11
10
|
} = require('bitcore-lib');
|
|
12
11
|
const addressValidator = require('wallet-address-validator');
|
|
13
12
|
const web3 = require('web3-utils');
|
|
13
|
+
const E = require('./errors');
|
|
14
14
|
|
|
15
15
|
const validations = {
|
|
16
16
|
_validate(Err, pred, x, msg) {
|
|
@@ -59,8 +59,8 @@ const validations = {
|
|
|
59
59
|
|
|
60
60
|
check: {
|
|
61
61
|
matches(required, given, msg) {
|
|
62
|
-
|
|
63
|
-
const crit = _.intersection(
|
|
62
|
+
const newGiven = _.uniq(given);
|
|
63
|
+
const crit = _.intersection(newGiven, required).length === given.length;
|
|
64
64
|
if (crit) {
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
@@ -100,22 +100,21 @@ const validations = {
|
|
|
100
100
|
|
|
101
101
|
isCustomerReference(x) {
|
|
102
102
|
return (
|
|
103
|
-
_.isString(x)
|
|
104
|
-
(x != null ? x.length : undefined) > 0
|
|
105
|
-
(x != null ? x.length : undefined) <= 100
|
|
103
|
+
_.isString(x)
|
|
104
|
+
&& (x != null ? x.length : undefined) > 0
|
|
105
|
+
&& (x != null ? x.length : undefined) <= 100
|
|
106
106
|
);
|
|
107
107
|
},
|
|
108
108
|
isCustomerLabelName(x) {
|
|
109
109
|
return (
|
|
110
|
-
_.isString(x)
|
|
111
|
-
(x != null ? x.length : undefined) > 0
|
|
112
|
-
(x != null ? x.length : undefined) <= 50
|
|
110
|
+
_.isString(x)
|
|
111
|
+
&& (x != null ? x.length : undefined) > 0
|
|
112
|
+
&& (x != null ? x.length : undefined) <= 50
|
|
113
113
|
);
|
|
114
114
|
},
|
|
115
115
|
bitcoin: {
|
|
116
116
|
isAddress(str) {
|
|
117
|
-
const network =
|
|
118
|
-
process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
117
|
+
const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
119
118
|
return typeof str === 'string' && addressValidator.validate(str.trim(), 'BTC', network);
|
|
120
119
|
},
|
|
121
120
|
isBech32Address(str) {
|
|
@@ -244,7 +243,7 @@ const validations = {
|
|
|
244
243
|
Object.keys(V).forEach((k) => {
|
|
245
244
|
const v = V[k];
|
|
246
245
|
// don't trigger validation with null values (prevents swagger 500 error)
|
|
247
|
-
validations[k] = x => (x === null ? false : v(x));
|
|
246
|
+
validations[k] = (x) => (x === null ? false : v(x));
|
|
248
247
|
});
|
|
249
248
|
|
|
250
249
|
module.exports = validations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ellipticltd/aml-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Utilities, helpers, validations, type-checking, etc",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "10.1.0",
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
"homepage": "https://bitbucket.org/elliptic/aml-utils#readme",
|
|
14
14
|
"main": "index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"test": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
|
|
16
|
+
"test:unit": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
|
|
17
17
|
"compile": "./node_modules/coffee-script/bin/coffee -c index.coffee **/*.coffee",
|
|
18
|
-
"preprocess": "npm run compile"
|
|
18
|
+
"preprocess": "npm run compile",
|
|
19
|
+
"lint": "./node_modules/.bin/eslint --color 'lib/**/*.js' 'test/**/*.js' ",
|
|
20
|
+
"test": "nyc npm run test:unit && nyc report --reporter=html",
|
|
21
|
+
"coverage": "nyc npm run test:unit && nyc report --reporter=lcov --reporter=text-lcov | codecov --pipe"
|
|
19
22
|
},
|
|
20
23
|
"author": "Adam Joyce <adam@ellipitc.co>",
|
|
21
24
|
"license": "MIT",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"bitcore-lib": "
|
|
26
|
+
"bitcore-lib": "^8.10.1",
|
|
24
27
|
"create-error": "0.3.1",
|
|
25
28
|
"lodash": "^4.17.15",
|
|
26
29
|
"type-check": "0.3.2",
|
|
@@ -29,12 +32,18 @@
|
|
|
29
32
|
"web3-utils": "1.0.0"
|
|
30
33
|
},
|
|
31
34
|
"devDependencies": {
|
|
32
|
-
"@ellipticltd/eslint-config": "0.0.3",
|
|
33
35
|
"chai": "4.1.1",
|
|
36
|
+
"codecov": "^3.6.1",
|
|
34
37
|
"coffee-script": "1.12.7",
|
|
35
|
-
"eslint": "
|
|
36
|
-
"eslint-config-airbnb
|
|
37
|
-
"eslint-
|
|
38
|
-
"
|
|
38
|
+
"eslint": "^6.6.0",
|
|
39
|
+
"eslint-config-airbnb": "^18.0.1",
|
|
40
|
+
"eslint-config-airbnb-base": "^14.0.0",
|
|
41
|
+
"eslint-plugin-coffeescript": "^1.0.0",
|
|
42
|
+
"eslint-plugin-import": "^2.18.2",
|
|
43
|
+
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
44
|
+
"eslint-plugin-react": "^7.16.0",
|
|
45
|
+
"mocha": "3.5.0",
|
|
46
|
+
"mocha-lcov-reporter": "^1.3.0",
|
|
47
|
+
"nyc": "^14.1.1"
|
|
39
48
|
}
|
|
40
|
-
}
|
|
49
|
+
}
|