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

Update configuration schema for MongoDB adaptor. #354

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions packages/mongodb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @openfn/language-mongodb

## 1.2.0

### Minor Changes

- Update configuration schema for MongoDB adaptor:
- Rename `clusterUrl` to `clusterHostname`
- Change `clusterHostname` format from `uri` to `hostname`
- Update `Adaptor.js` and tests to use new name

The MongoDB adaptor configuration expects a hostname, not a strict
URI. The existing configuration prevented a user from saving a
"correct" configuration in Lightning, due to the JSON schema verification
failing. Changing the format of this configuration property to `hostname`
resolves this issue and justifies a name change of the property.

## 1.1.1

### Patch Changes
Expand Down
12 changes: 6 additions & 6 deletions packages/mongodb/configuration-schema.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"clusterUrl": {
"title": "Cluster URL",
"clusterHostname": {
"title": "Cluster Hostname",
"type": "string",
"description": "Your MongoDB cluster / host URL",
"format": "uri",
"description": "Your MongoDB cluster hostname",
"format": "hostname",
"minLength": 1,
"examples": [
"yourCluster-xxxyzzz.mongodb.net"
Expand Down Expand Up @@ -34,8 +34,8 @@
"type": "object",
"additionalProperties": true,
"required": [
"clusterUrl",
"clusterHostname",
"username",
"password"
]
}
}
4 changes: 2 additions & 2 deletions packages/mongodb/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export function execute(...operations) {
* @returns {State}
*/
function connect(state) {
const { clusterUrl, username, password } = state.configuration;
const { clusterHostname, username, password } = state.configuration;

const uri = `mongodb+srv://${encodeURIComponent(
username
)}:${encodeURIComponent(
password
)}@${clusterUrl}/test?retryWrites=true&w=majority`;
)}@${clusterHostname}/test?retryWrites=true&w=majority`;

const client = new MongoClient(uri, { useNewUrlParser: true });

Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('execute', () => {
configuration: {
username: 'hello',
password: 'there',
clusterUrl: 'demo.mongodb.net',
clusterHostname: 'demo.mongodb.net',
},
};
let operations = [
Expand Down