@larsgw/formica 0.5.1 → 0.6.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/CHANGELOG.md +18 -0
- package/README.md +20 -1
- package/lib/bin/process-resources-index.js +7 -5
- package/lib/catalog/value.js +2 -2
- package/package.json +1 -1
- package/src/bin/process-resources-index.ts +6 -4
- package/src/catalog/value.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# [0.6.0](https://github.com/identification-resources/formica/compare/v0.5.2...v0.6.0) (2024-01-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **catalog:** add entry type, key type values ([ed6e4fb](https://github.com/identification-resources/formica/commit/ed6e4fb545e09cddb5d466f602bffb8a8483f043))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [0.5.2](https://github.com/identification-resources/formica/compare/v0.5.1...v0.5.2) (2023-11-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **resources:** fix GBIF index generation ([c88e2d2](https://github.com/identification-resources/formica/commit/c88e2d2b306b930ca0b00b978e3eb89b8adfb656))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
1
19
|
## [0.5.1](https://github.com/identification-resources/formica/compare/v0.5.0...v0.5.1) (2023-11-03)
|
|
2
20
|
|
|
3
21
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,17 @@
|
|
|
3
3
|
**Formica** is an SDK and a collection of tools for the data in the Library of
|
|
4
4
|
Identification Resources.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
Install globally:
|
|
9
|
+
|
|
10
|
+
npm install --global @larsgw/formica
|
|
11
|
+
|
|
12
|
+
Run locally:
|
|
13
|
+
|
|
14
|
+
npx --package @larsgw/formica -- ...
|
|
15
|
+
|
|
16
|
+
## CLI
|
|
7
17
|
|
|
8
18
|
- `loir-validate-catalog [./catalog.csv ./authors.csv ./places.csv ./publishers.csv]`:
|
|
9
19
|
Validate the CSV files containing metadata ([schema](https://github.com/identification-resources/catalog/blob/main/docs/tools-resources.md)).
|
|
@@ -17,3 +27,12 @@ Identification Resources.
|
|
|
17
27
|
`--update` flag in a Git repo to update existing Darwin Core files while keeping
|
|
18
28
|
the identifiers stable (in most cases).
|
|
19
29
|
- `loir-resources-index [./resources]`: Create indices of the Darwin Core archives.
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const Formica = require('@larsgw/formica')
|
|
35
|
+
|
|
36
|
+
// Load catalog data
|
|
37
|
+
const catalog = Formica.catalog.loadData(`...`, 'catalog')
|
|
38
|
+
```
|
|
@@ -96,7 +96,7 @@ function main(args) {
|
|
|
96
96
|
file = _a.sent();
|
|
97
97
|
return [2 /*return*/, Promise.all(index_1.resources.parseTextFileHeader(file).map(function (resource, index) {
|
|
98
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var amendedResource, dwcFile, _a,
|
|
99
|
+
var amendedResource, dwcFile, _a, header, dwc, _b, _c, gbifColumn, gbifAcceptedColumn, _i, dwc_1, taxon, gbifId;
|
|
100
100
|
return __generator(this, function (_d) {
|
|
101
101
|
switch (_d.label) {
|
|
102
102
|
case 0:
|
|
@@ -108,14 +108,16 @@ function main(args) {
|
|
|
108
108
|
_c = (_b = index_1.csv).parseCsv;
|
|
109
109
|
return [4 /*yield*/, fs_1.promises.readFile(dwcFile, 'utf-8')];
|
|
110
110
|
case 1:
|
|
111
|
-
_a = _c.apply(_b, [_d.sent()]),
|
|
111
|
+
_a = _c.apply(_b, [_d.sent()]), header = _a[0], dwc = _a.slice(1);
|
|
112
|
+
gbifColumn = header.indexOf('gbifTaxonID');
|
|
113
|
+
gbifAcceptedColumn = header.indexOf('gbifAcceptedTaxonID');
|
|
112
114
|
for (_i = 0, dwc_1 = dwc; _i < dwc_1.length; _i++) {
|
|
113
115
|
taxon = dwc_1[_i];
|
|
114
|
-
gbifId = taxon[
|
|
116
|
+
gbifId = taxon[gbifColumn];
|
|
115
117
|
if (gbifId) {
|
|
116
118
|
addTaxon(gbifIndex, gbifId, taxon);
|
|
117
|
-
if (taxon[
|
|
118
|
-
addTaxon(gbifIndex, taxon[
|
|
119
|
+
if (taxon[gbifAcceptedColumn] !== taxon[gbifColumn]) {
|
|
120
|
+
addTaxon(gbifIndex, taxon[gbifAcceptedColumn], taxon);
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
amendedResource.taxonCount += 1;
|
package/lib/catalog/value.js
CHANGED
|
@@ -7,8 +7,8 @@ var spdxLicenseList = require("spdx-license-list");
|
|
|
7
7
|
var ietfTagListFactory = require("ietf-language-tag-regex");
|
|
8
8
|
var ietfTagList = ietfTagListFactory();
|
|
9
9
|
exports.FORMATS = {
|
|
10
|
-
ENTRY_TYPE: ['print', 'online', 'cd'],
|
|
11
|
-
KEY_TYPE: ['key', 'matrix', 'reference', 'gallery', 'checklist', 'supplement', 'collection'],
|
|
10
|
+
ENTRY_TYPE: ['print', 'online', 'cd', 'application'],
|
|
11
|
+
KEY_TYPE: ['key', 'matrix', 'reference', 'gallery', 'checklist', 'supplement', 'collection', 'algorithm'],
|
|
12
12
|
COMPLETE: ['TRUE', 'FALSE'],
|
|
13
13
|
ID: /^B\d+$/,
|
|
14
14
|
EDTF_0: /^(\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}:\d{2}(Z|[-+]\d{2}(:\d{2})?))?)?)?|\d{4}(-\d{2}(-\d{2})?)?\/(\d{4}(-\d{2}(-\d{2})?)?|\.\.))$/,
|
package/package.json
CHANGED
|
@@ -54,13 +54,15 @@ async function main (args: string[]): Promise<void> {
|
|
|
54
54
|
return
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const [
|
|
57
|
+
const [header, ...dwc] = csv.parseCsv(await fs.readFile(dwcFile, 'utf-8'))
|
|
58
|
+
const gbifColumn = header.indexOf('gbifTaxonID')
|
|
59
|
+
const gbifAcceptedColumn = header.indexOf('gbifAcceptedTaxonID')
|
|
58
60
|
for (const taxon of dwc) {
|
|
59
|
-
const gbifId = taxon[
|
|
61
|
+
const gbifId = taxon[gbifColumn]
|
|
60
62
|
if (gbifId) {
|
|
61
63
|
addTaxon(gbifIndex, gbifId, taxon)
|
|
62
|
-
if (taxon[
|
|
63
|
-
addTaxon(gbifIndex, taxon[
|
|
64
|
+
if (taxon[gbifAcceptedColumn] !== taxon[gbifColumn]) {
|
|
65
|
+
addTaxon(gbifIndex, taxon[gbifAcceptedColumn], taxon)
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
amendedResource.taxonCount += 1
|
package/src/catalog/value.ts
CHANGED
|
@@ -6,8 +6,8 @@ import ietfTagListFactory = require('ietf-language-tag-regex')
|
|
|
6
6
|
const ietfTagList = ietfTagListFactory()
|
|
7
7
|
|
|
8
8
|
export const FORMATS = {
|
|
9
|
-
ENTRY_TYPE: ['print', 'online', 'cd'],
|
|
10
|
-
KEY_TYPE: ['key', 'matrix', 'reference', 'gallery', 'checklist', 'supplement', 'collection'],
|
|
9
|
+
ENTRY_TYPE: ['print', 'online', 'cd', 'application'],
|
|
10
|
+
KEY_TYPE: ['key', 'matrix', 'reference', 'gallery', 'checklist', 'supplement', 'collection', 'algorithm'],
|
|
11
11
|
COMPLETE: ['TRUE', 'FALSE'],
|
|
12
12
|
|
|
13
13
|
ID: /^B\d+$/,
|