Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge mowali branch #286

Merged
merged 144 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 137 commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
53f1b03
Tests converted to Jest
partiallyordered Sep 23, 2019
26cc810
Added rules engine jsonpath dynamic fact
partiallyordered Sep 23, 2019
ee5f780
Updated rules engine API. Added jsonpath package to dependencies. Add…
partiallyordered Sep 24, 2019
7cbbe92
Updated hapi/subtext to patch vulnerability
partiallyordered Sep 24, 2019
c0ce090
Updated example rules and corresponding tests to reflect real form of…
partiallyordered Sep 24, 2019
ae4a017
Added switch endpoint to config to obtain payer and payee information…
partiallyordered Sep 25, 2019
52e7f2f
Tests converted to Jest
partiallyordered Sep 23, 2019
c51c04d
Replaced coverage-check script. Added coverage threshold to jest conf…
partiallyordered Sep 25, 2019
b3ed58b
Uninstalled and reinstalled jest to fix vulnerability
partiallyordered Sep 25, 2019
dc1e922
Added junit + config. Added test:junit npm script. Modified circle co…
partiallyordered Sep 25, 2019
a2027f3
Merge remote-tracking branch 'msk-/test-with-jest'
partiallyordered Sep 25, 2019
7d006cd
Modified example rules and corresponding tests to better reflect actu…
partiallyordered Sep 25, 2019
293fbf4
Merge remote-tracking branch 'origin/master'
partiallyordered Sep 25, 2019
b9aec14
Updated redirect address to redirect fsp. Made the linter happy. Adde…
partiallyordered Oct 24, 2019
271e28f
Merged upstream into fork
partiallyordered Oct 25, 2019
4b4acff
Merge conflicts resolved
partiallyordered Nov 7, 2019
d830523
Manual merge from upstream
partiallyordered Nov 7, 2019
9ddfa59
Integrated properly the new `model/rules.js` into `model/quotes.js` a…
Nov 8, 2019
5cc9bba
Simplified block of code that was unnecessarily using `map`.
Nov 8, 2019
1dc5496
Merge pull request #1 from vbarzokas/bugfix/integrate-rules-engine-fi…
partiallyordered Nov 8, 2019
9f8df68
Forwarding event-handler-modified quote request and headers instead o…
partiallyordered Nov 8, 2019
bc17ba5
Fixed tests by poorly mocking handleRuleEvents on the quotes model
partiallyordered Nov 8, 2019
c967661
Cleaned a little bit the result of `handleRuleEvents`;
Nov 8, 2019
75b879f
Merge pull request #2 from vbarzokas/bugfix/update-unit-tests
partiallyordered Nov 11, 2019
5bcb954
Deduplicated the functionality of request sending
Nov 11, 2019
6e82010
Removed `setImmediate` from all places that it was used.
Nov 11, 2019
b0444a5
Use `CreateInternalServerFSPIOPError` instead of `CreateFSPIOPError`
Nov 11, 2019
87ec59c
Merge pull request #3 from vbarzokas/feature/cleanup-code
partiallyordered Nov 12, 2019
3b04304
mowdev-3411
Dec 5, 2019
b36efd3
added more rules
Dec 5, 2019
6567058
Feature/846 async logging (#100)
lewisdaly Dec 5, 2019
03fc69d
Feature/update json rules engine (#101)
partiallyordered Dec 5, 2019
78bdc53
Feature/test fx rules (#102)
partiallyordered Dec 5, 2019
71dff00
added more rules and tests
Dec 6, 2019
7a5cb58
test discard
Dec 6, 2019
6b058cc
test discard
Dec 6, 2019
1dd36cb
test discard
Dec 6, 2019
28549b8
stripe off accept header for PUT requests
Dec 12, 2019
621ff7c
added package-lock.json
Dec 12, 2019
61c4dd0
Merge branch 'master' into feature/mowdev-3411
shashi165 Dec 12, 2019
e27d8dc
added more rules
Dec 18, 2019
72e1dac
Merge remote-tracking branch 'origin/feature/mowdev-3411' into featur…
Dec 18, 2019
da91411
fixed the package.json version
Dec 19, 2019
b6b3890
fixed version number
Dec 19, 2019
4e4db82
fixed the Object.assign
Dec 19, 2019
578f61a
removed rules.json
Dec 19, 2019
026bbf5
update package-lock.json
Dec 19, 2019
200d721
Merge branch 'master' into feature/mowdev-3411
shashi165 Dec 19, 2019
3a87289
Attempt cache refresh
KamuelaFranco Jan 6, 2020
cbb418f
Replace audit:check with audit
KamuelaFranco Jan 6, 2020
2c5d6f6
Debug with verbose audit
KamuelaFranco Jan 6, 2020
1be3256
Skip vulnerability check because of network errors
KamuelaFranco Jan 6, 2020
736f5b3
Skip vuln check step
KamuelaFranco Jan 6, 2020
693f3ae
downgrade helm version
Jan 6, 2020
58a285b
temp logging
Jan 8, 2020
99ceeb5
renamed switchEndpoint to a better name
Jan 8, 2020
745d45f
removed config from dockerfile
shashi165 Jan 9, 2020
f6e8f6c
Added synchronous responses for rules engine invalid quote errors (#127)
partiallyordered Jan 16, 2020
53f4907
added error code
shashi165 Jan 16, 2020
06eaf8c
added swagger changes
shashi165 Jan 16, 2020
5f1dc1b
added error handling when there are no active accounts
shashi165 Jan 22, 2020
b1f7e1c
added error handling when there are no active accounts
shashi165 Jan 22, 2020
85f748d
added error handling when there are no active accounts
shashi165 Jan 22, 2020
b0e3047
fixed error responses sync and async
shashi165 Jan 24, 2020
9767ad7
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
1d814b3
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
ec8ce82
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
c876ec3
removed fspiop-uri header
shashi165 Jan 27, 2020
24b82fb
removed fspiop-signature header
shashi165 Jan 27, 2020
6ff4541
added one more error code to sync errors
shashi165 Jan 27, 2020
9641b2f
added more error handling
shashi165 Jan 29, 2020
a3131ad
Merged from master
partiallyordered Feb 10, 2020
ab806e0
Merged from master
partiallyordered Mar 2, 2020
99a2226
Updated package version
partiallyordered Mar 2, 2020
50858fe
Do not modify headers in case they are only being relayed to another …
Mar 18, 2020
76e654a
Do not delete `FSPIOP-Signature` header unless if `modifyHeaders` is …
Mar 18, 2020
c9cde80
Merged `master` into this branch.
May 11, 2020
de7996b
merge master
May 19, 2020
464b4da
fixed the bug with createQuoteExtensions
May 20, 2020
5a49911
fixed issue with createQuoteExtension
May 21, 2020
8c735ae
Revert change of the error message as it breaks tests.
May 22, 2020
05b7dfc
Aligned an error message with the master branch to match Postman test…
Jun 25, 2020
39121ef
Fixed some npm vulnerabilities and skipped the rest.
Jun 25, 2020
1261ad1
Updated circle CI config according to master branch.
Jun 25, 2020
2669bdd
Removed `quoteId` from error log message as it causes error due its e…
Jun 30, 2020
4303335
fixed error message
Jun 30, 2020
78179bf
added test currencies
shashi165 Aug 28, 2020
b10cfdb
resolve audit issues
shashi165 Aug 28, 2020
c7a99bf
fix audit issues
shashi165 Aug 28, 2020
d4685b0
fix audit issues
shashi165 Aug 28, 2020
94191ac
WIP
shashi165 Sep 28, 2021
ee4f419
WIP
shashi165 Sep 28, 2021
dcdafd1
WIP
shashi165 Sep 28, 2021
520646e
WIP
shashi165 Sep 28, 2021
a622f8f
WIP
shashi165 Sep 28, 2021
df6d07e
WIP
shashi165 Sep 28, 2021
688f8c6
WIP
shashi165 Sep 28, 2021
3d30128
WIP
shashi165 Sep 28, 2021
6341d1e
WIP
shashi165 Sep 28, 2021
555b294
WIP
shashi165 Sep 29, 2021
f710217
WIP
shashi165 Sep 29, 2021
41932a1
WIP
shashi165 Sep 29, 2021
a481ee1
WIP
shashi165 Sep 29, 2021
57f6ef3
WIP
shashi165 Sep 29, 2021
8577e2d
WIP
shashi165 Sep 29, 2021
2740e7e
WIP
shashi165 Sep 29, 2021
0d0941b
WIP
shashi165 Sep 29, 2021
3d97c09
WIP
shashi165 Sep 29, 2021
13d1aba
WIP
shashi165 Sep 29, 2021
e8e70b4
WIP
shashi165 Sep 29, 2021
6cdc5b4
Fixed the tests
shashi165 Sep 30, 2021
fcec97c
changed the way we add headers
shashi165 Oct 1, 2021
50ad88d
refactoring
shashi165 Oct 1, 2021
132d458
refactoring
shashi165 Oct 1, 2021
26af659
removed the hardcoded headers
shashi165 Oct 4, 2021
4443563
removed the hardcoded headers
shashi165 Oct 4, 2021
690d727
updated README
shashi165 Oct 4, 2021
f957580
fixed swagger
shashi165 Oct 5, 2021
cc42204
revert sync changes
shashi165 Oct 11, 2021
7d5d13d
revert sync changes
shashi165 Oct 11, 2021
dacc612
revert sync changes
shashi165 Oct 11, 2021
d6f7786
revert sync changes
shashi165 Oct 11, 2021
b5bcb32
revert sync changes
shashi165 Oct 11, 2021
049a4b9
revert sync changes
shashi165 Oct 13, 2021
171a454
revert sync changes
shashi165 Oct 13, 2021
6b157b9
Merge branch 'master' into feat/merge-mowali-branch
shashi165 Oct 13, 2021
97b23a4
fixed issue with createPayerParty
shashi165 Oct 14, 2021
9afa36b
Merge branch 'feat/merge-mowali-branch' of https://github.com/mojaloo…
shashi165 Oct 14, 2021
efdd3ce
fixed issue with createPayerParty
shashi165 Oct 14, 2021
5fa201d
fixed issue with eslint version
shashi165 Oct 18, 2021
77e4c1c
Update src/model/quotes.js
shashi165 Oct 20, 2021
d94cb7d
Update src/model/quotes.js
shashi165 Oct 20, 2021
89ed573
Update src/model/quotes.js
shashi165 Oct 20, 2021
0cbc8ff
Update src/model/quotes.js
shashi165 Oct 20, 2021
84e4722
fixed audit issue
shashi165 Oct 29, 2021
8ebc2e7
Merge branch 'feat/merge-mowali-branch' of https://github.com/mojaloo…
shashi165 Oct 29, 2021
2e237e0
fixed audit issue
shashi165 Oct 29, 2021
014dd95
bring in latest mowali version
shashi165 Feb 7, 2022
690fedd
fixed tests
shashi165 Feb 8, 2022
261f36f
audit resolve
shashi165 Feb 8, 2022
7824f6e
revert package version
shashi165 Feb 8, 2022
77d9882
removed the implementation specific payer/payee validation
shashi165 Feb 9, 2022
c15c30b
removed the implementation specific payer/payee validation
shashi165 Feb 9, 2022
efb4075
removed comments
shashi165 Feb 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"reject": [
"json-rules-engine"
"json-rules-engine",
"eslint"
]
}
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,119 @@ push a release triggering another subsequent build that also publishes a docker
- It is unknown if a race condition might occur with multiple merges with master in
quick succession, but this is a suspected edge case.


## How to use quoting-service JSON rules
### About rules.json
The rules.json file acts as a rules engine and enables you to define arbitrary rules that will accept or reject quotes. A rule is defined as an object with a title, a conditions object, and an event object. A rule specifies that if certain conditions are met, then the specified event will be generated.

The rules engine used by the quoting-service is an off-the-shelf rules engine, called json-rules-engine. For detailed information on how to write rules, see the [json-rules-engine documentation](https://github.com/CacheControl/json-rules-engine/blob/master/docs/rules.md). This page only focuses on those details that are relevant for adding support for new currencies.

### Conditions
Conditions are a combination of facts, paths, operators, and values.

Each rule's conditions must have either an all or an any operator at its root, containing an array of conditions. The all operator specifies that all conditions must be met for the rule to be applied. The any operator only requires one condition to be met for the rule to be applied.

Operators within the individual conditions can take the following values:

- `equal:` fact must equal value (string or numeric value)
- `notEqual:` fact must not equal value (string or numeric value)
- `in:` fact must be included in value (an array)
- `notIn:` fact must not be included in value (an array)
- `contains:` fact (an array) must include value
- `doesNotContain:` fact (an array) must not include value

### Events
Event objects must have a type property, and an optional params property. There are two types of events:

- `INTERCEPT_QUOTE`: Used for redirecting quote requests.
- `INVALID_QUOTE_REQUEST`: Used for validation rules. You do not have to use this type of event when adding support for new currencies.

### Configuration – an example
```
[
{
"title": "This is UGX -> ZMW transfer rule",
"conditions": {
"all": [
{
"fact": "headers",
"path": "$.fspiop-source",
"operator": "notIn",
"value":[
"DFSPUGX",
"DFSPZMW"
]
},
{
"fact": "payer",
"path": "$.accounts[?(@.ledgerAccountType == 'POSITION' && @.isActive == 1)].currency",
"operator": "equal",
"value": "UGX"
},
{
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == 'POSITION' && @.isActive == 1)].currency",
"operator": "equal",
"value": "ZMW"
}
]
},
"event":{
"type": "INTERCEPT_QUOTE",
"params":{
"rerouteToFsp": "DFSPUGX",
"additionalHeaders": {
"x-fspiop-sourcecurrency": "UGX",
"x-fspiop-destinationcurrency": "ZMW"
}
}
}
},
{
"title": "Payee fsp should have only one active account",
"conditions": {
"all": [
{
"any": [
{
"fact": "payload",
"path": "$.amount.currency",
"operator": "notIn",
"value": {
"fact": "payer",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)].currency"
}
},
{
"fact": "payload",
"path": "$.amount.currency",
"operator": "notIn",
"value": {
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)].currency"
}
}
]
},
{
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)]",
"operator": "isArray",
"value": true
}
]
},
"event": {
"type": "INVALID_QUOTE_REQUEST",
"params": {
"FSPIOPError": "PAYEE_ERROR",
"message": "Payee FSP has more than 1 active currency account. Switch does not support more than 1 active currency account for Forex Requests"
}
}
}
]

```
## Additional Notes

N/A
47 changes: 41 additions & 6 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
},
"1500|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
"decision": "ignore",
"madeAt": 1630492434834,
"expiresAt": 1631097196218
"madeAt": 1632976633787,
"expiresAt": 1635568626757
},
"1675|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1630492438539,
"expiresAt": 1631097196218
"madeAt": 1632976636922,
"expiresAt": 1635568626757
},
"1676|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1630492438539,
"expiresAt": 1631097196218
"madeAt": 1632976636922,
"expiresAt": 1635568626757
},
"1693|@mojaloop/central-services-shared>shins>sanitize-html>postcss": {
"decision": "ignore",
Expand All @@ -51,6 +51,41 @@
"1781|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1630492425076
},
"1002401|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1635508643052,
"expiresAt": 1638100635402
},
"1002401|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1635508643052,
"expiresAt": 1638100635402
},
"1002401|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>npmlog>gauge>wide-align>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1634145313719,
"expiresAt": 1636737304260
},
"1002865|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1634145316146,
"expiresAt": 1636737304260
},
"1002866|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1634145316146,
"expiresAt": 1636737304260
},
"1003019|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
"decision": "ignore",
"madeAt": 1634145318834,
"expiresAt": 1636737304260
},
"1002401|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>npmlog>gauge>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1635508643052,
"expiresAt": 1638100635402
}
},
"rules": {},
Expand Down
Loading