apps-consumer-utils
Advanced tools
Comparing version 1.0.2 to 1.0.4-0
11
index.js
"use strict"; | ||
let R = require("ramda"); | ||
let dedynamise = require('dynamodb-data-types').AttributeValue.unwrap; | ||
const R = require("ramda"); | ||
const dedynamise = require('dynamodb-data-types').AttributeValue.unwrap; | ||
@@ -41,6 +41,7 @@ module.exports = { | ||
// getId :: Object -> String | ||
"getId": (content) => { | ||
return content.Source.split('-')[0] + '.' + content.Id; | ||
}, | ||
"getId": (content) => R.head(content.Source.split('-')) + '.' + content.Id, | ||
// getId :: Object -> String | ||
"getSource": (content) => R.head(content.Source.split('-')), | ||
// getLatestEventById :: [Object] -> [Object] | ||
@@ -47,0 +48,0 @@ "getLatestEventsById": (records) => { |
{ | ||
"name": "apps-consumer-utils", | ||
"version": "1.0.2", | ||
"version": "1.0.4-0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"lint": "eslint .", | ||
"cover": "nyc --report-dir ./coverage/unit yarn run test", | ||
"test": "_mocha -- -R spec test/ --recursive" | ||
}, | ||
@@ -13,8 +15,10 @@ "author": "", | ||
"dynamodb-data-types": "3.0.1", | ||
"ramda": "0.26.1" | ||
"ramda": "0.27.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "4.2.0", | ||
"mocha": "6.2.0" | ||
"eslint": "6.8.0", | ||
"mocha": "6.2.0", | ||
"nyc": "15.0.0" | ||
} | ||
} |
@@ -5,5 +5,44 @@ # apps-consumer-utils | ||
### Running tests | ||
## Deploy | ||
### CI | ||
A drone pipeline will perform CI steps such as audit and tests on the repo. | ||
### NPM package | ||
This repo is delivered as an NPM package via a drone pipeline. | ||
A new version can be deployed by updating the version number from `package.json` file by following the semantic versioning syntax and tagging the commit with that version. When pushing the newly tag to git, a new package version will be published. | ||
To bump up the package version, use [npm version](https://docs.npmjs.com/cli/version.html) with [--git-tag-version](https://docs.npmjs.com/cli/version.html#git-tag-version) option - this will bump up the package version and it will automatically commit and tag the version change. | ||
Eg: | ||
```bash | ||
npm version patch --git-tag-version | ||
``` | ||
The above will increment the third digit of the version and it will tag the commit with that version. | ||
Short description for semantic versioning syntax: | ||
```bash | ||
Stage | Rule | Example | ||
---------------------------------------------------------------------------------- | ||
major | Increment the first digit and reset 2nd and 3rd digits to zero | 4.0.0 | ||
minor | Increment the middle digit and reset the 3rd digit to zero | 3.4.0 | ||
patch | Increment the 3rd digit | 3.4.2 | ||
``` | ||
To trigger the drone pipeline, run: | ||
```bash | ||
git push origin <tag> | ||
``` | ||
Note that `git push origin --tags` does not trigger the drone pipeline. It is however better to trigger it with only 1 tag referenced using `git push origin <tag>`. | ||
## Running tests | ||
``` | ||
git clone ... | ||
@@ -15,1 +54,8 @@ | ||
--- | ||
## Change logs | ||
### v 1.0.3 | ||
- Added `getSource` utility function. | ||
- moved ramda version to `0.27.0` |
"use strict"; | ||
let index = require("../index"); | ||
let assert = require("chai").assert; | ||
const index = require("../index"); | ||
const assert = require("chai").assert; | ||
describe("Chronos consumer utilities", () => { | ||
describe('getId', () => { | ||
it('should not return the id', () => { | ||
const content = { | ||
Source: 'nationals-article', | ||
Id: '123' | ||
}; | ||
assert.equal(index.getId(content), 'nationals.123'); | ||
}); | ||
}); | ||
describe('getSource', () => { | ||
it('should not return the source', () => { | ||
const content = {Source: 'nationals-article'}; | ||
assert.equal(index.getSource(content), 'nationals'); | ||
}); | ||
}); | ||
describe('normalizeJSON', () => { | ||
it('should not add deleted field to non-delete event', () => { | ||
@@ -53,3 +70,2 @@ assert.deepEqual(index.normalizeJSON({ | ||
describe('getEventIds', () => { | ||
it('should reject records with no id', () => { | ||
@@ -142,19 +158,19 @@ assert.deepEqual(index.getEventIds([{}]), []); | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
} | ||
}]); | ||
} | ||
}]); | ||
@@ -186,36 +202,36 @@ assert.equal(actual[0].dynamodb.Keys.Id.N, "666666"); | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666666" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666666" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454701555000" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454701555000" | ||
} | ||
} | ||
}]); | ||
} | ||
}]); | ||
@@ -247,53 +263,53 @@ assert.equal(actual[0].dynamodb.Keys.Id.N, "666666"); | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454601555555" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666666" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666666" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454701555000" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454701555000" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
} | ||
}, | ||
{ | ||
dynamodb: { | ||
Keys: { | ||
Id: { | ||
N: "666667" | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454801995000" | ||
} | ||
Source: { | ||
S: "nationals-article" | ||
} | ||
}, | ||
NewImage: { | ||
LastModifiedTime: { | ||
N: "1454801995000" | ||
} | ||
} | ||
} | ||
} | ||
]); | ||
@@ -308,3 +324,2 @@ | ||
}); | ||
}); |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18380
8
369
59
4
2
+ Addedramda@0.27.0(transitive)
- Removedramda@0.26.1(transitive)
Updatedramda@0.27.0