@natlibfi/ekirjasto-opds-feed-parser 0.0.0-post.147 → 0.0.0-post.149
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/README.md +1 -1
- package/lib/src/accessibility.d.ts +12 -0
- package/lib/src/accessibility.js +16 -0
- package/lib/src/accessibility_parser.d.ts +8 -0
- package/lib/src/accessibility_parser.js +71 -0
- package/lib/src/conformance.d.ts +6 -0
- package/lib/src/conformance.js +9 -0
- package/lib/src/conformance_parser.d.ts +7 -0
- package/lib/src/conformance_parser.js +53 -0
- package/lib/src/entry_parser.js +4 -0
- package/lib/src/opds_entry.d.ts +2 -0
- package/lib/src/ways_of_reading.d.ts +6 -0
- package/lib/src/ways_of_reading.js +9 -0
- package/lib/src/ways_of_reading_parser.d.ts +7 -0
- package/lib/src/ways_of_reading_parser.js +59 -0
- package/package.json +10 -6
- package/.github/CODEOWNERS +0 -4
- package/.github/pull_request_template.md +0 -12
- package/.github/workflows/release.yml +0 -102
- package/.github/workflows/test.yml +0 -23
- package/requirements-ci.txt +0 -1
- package/test/availability_parser_test.ts +0 -32
- package/test/category_parser_test.ts +0 -30
- package/test/contributor_parser_test.ts +0 -44
- package/test/copies_parser_test.ts +0 -30
- package/test/entry_parser_test.ts +0 -272
- package/test/feed_parser_test.ts +0 -244
- package/test/files/acquisition.xml +0 -416
- package/test/files/entry.xml +0 -33
- package/test/files/navigation.xml +0 -56
- package/test/holds_parser_test.ts +0 -30
- package/test/indirect_acquisition_parser_test.ts +0 -46
- package/test/link_parser_test.ts +0 -324
- package/test/namespace_parser_test.ts +0 -41
- package/test/opds_parser_test.ts +0 -147
- package/test/price_parser_test.ts +0 -30
- package/test/series_parser_test.ts +0 -30
- package/tsconfig.json +0 -15
- package/tslint.json +0 -54
- package/typings.json +0 -8
package/README.md
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Conformance from "./conformance";
|
|
2
|
+
import WaysOfReading from "./ways_of_reading";
|
|
3
|
+
export default class Accessibility {
|
|
4
|
+
conformance?: Conformance;
|
|
5
|
+
waysOfReading?: WaysOfReading;
|
|
6
|
+
constructor(args?: {
|
|
7
|
+
conformance?: Conformance;
|
|
8
|
+
waysOfReading?: WaysOfReading;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export interface AccessibilityArgs extends Accessibility {
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Define the Accessibility class
|
|
4
|
+
var Accessibility = /** @class */ (function () {
|
|
5
|
+
// This constructor is used when
|
|
6
|
+
// we are initializing a new Accessibility object
|
|
7
|
+
// with the given parameters
|
|
8
|
+
function Accessibility(args) {
|
|
9
|
+
if (args) {
|
|
10
|
+
this.conformance = args.conformance;
|
|
11
|
+
this.waysOfReading = args.waysOfReading;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return Accessibility;
|
|
15
|
+
}());
|
|
16
|
+
exports.default = Accessibility;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Accessibility from "./accessibility";
|
|
2
|
+
import Xml2jsOutputParser from "./xml2js_output_parser";
|
|
3
|
+
export default class AccessibilityParser extends Xml2jsOutputParser<Accessibility> {
|
|
4
|
+
parse(tag: any): Accessibility;
|
|
5
|
+
private parseConformance;
|
|
6
|
+
private parseWaysOfReading;
|
|
7
|
+
private createAccessibility;
|
|
8
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var accessibility_1 = require("./accessibility");
|
|
19
|
+
var conformance_parser_1 = require("./conformance_parser");
|
|
20
|
+
var ways_of_reading_parser_1 = require("./ways_of_reading_parser");
|
|
21
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
22
|
+
// AccessibilityParser class extends Xml2jsOutputParser
|
|
23
|
+
// to handle parsing of accessibility data
|
|
24
|
+
var AccessibilityParser = /** @class */ (function (_super) {
|
|
25
|
+
__extends(AccessibilityParser, _super);
|
|
26
|
+
function AccessibilityParser() {
|
|
27
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
}
|
|
29
|
+
// function parse is given a tag as parameter
|
|
30
|
+
// (it should be the XML element <accessibility>)
|
|
31
|
+
// and extracts accessibility details from it.
|
|
32
|
+
AccessibilityParser.prototype.parse = function (tag) {
|
|
33
|
+
var conformance = this.parseConformance(tag);
|
|
34
|
+
var waysOfReading = this.parseWaysOfReading(tag);
|
|
35
|
+
return this.createAccessibility(conformance, waysOfReading);
|
|
36
|
+
};
|
|
37
|
+
// helper function to parse the 'conformance' subtag
|
|
38
|
+
AccessibilityParser.prototype.parseConformance = function (tag) {
|
|
39
|
+
// first create instance of the ConformanceParser
|
|
40
|
+
// and define the subtag's name from <conformance>
|
|
41
|
+
var subtagName = "conformance";
|
|
42
|
+
var subtagParser = new conformance_parser_1.default(this.prefixes);
|
|
43
|
+
// then extract conformance metadata from XML using the parser
|
|
44
|
+
return this.parseSubtag(tag, subtagName, subtagParser);
|
|
45
|
+
};
|
|
46
|
+
// helper function to parse the 'waysOfReading' subtag
|
|
47
|
+
AccessibilityParser.prototype.parseWaysOfReading = function (tag) {
|
|
48
|
+
// first create a instance of the WaysOfReadingParser
|
|
49
|
+
// and define the subtag's name from <waysOfReading>
|
|
50
|
+
var subtagName = "waysOfReading";
|
|
51
|
+
var subtagParser = new ways_of_reading_parser_1.default(this.prefixes);
|
|
52
|
+
// then extract ways of reading metadata from XML using the parser
|
|
53
|
+
return this.parseSubtag(tag, subtagName, subtagParser);
|
|
54
|
+
};
|
|
55
|
+
// helper function that creates an Accessibility instance
|
|
56
|
+
// from the parsed data given as parameter
|
|
57
|
+
AccessibilityParser.prototype.createAccessibility = function (conformance, waysOfReading) {
|
|
58
|
+
// create an AccessibilityArgs object
|
|
59
|
+
// that holds the extracted data
|
|
60
|
+
var accessibilityArgs = {
|
|
61
|
+
conformance: conformance,
|
|
62
|
+
waysOfReading: waysOfReading,
|
|
63
|
+
};
|
|
64
|
+
// return a new Accessibility instance
|
|
65
|
+
// that is created using accessibilityArgs
|
|
66
|
+
// (there's a constructor init method for this)
|
|
67
|
+
return new accessibility_1.default(accessibilityArgs);
|
|
68
|
+
};
|
|
69
|
+
return AccessibilityParser;
|
|
70
|
+
}(xml2js_output_parser_1.default));
|
|
71
|
+
exports.default = AccessibilityParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Conformance from "./conformance";
|
|
2
|
+
import Xml2jsOutputParser from "./xml2js_output_parser";
|
|
3
|
+
export default class ConformanceParser extends Xml2jsOutputParser<Conformance> {
|
|
4
|
+
parse(tag: any): Conformance;
|
|
5
|
+
private extractConformsTo;
|
|
6
|
+
private createConformance;
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var conformance_1 = require("./conformance");
|
|
19
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
20
|
+
// this class extends Xml2jsOutputParser
|
|
21
|
+
// to handle parsing of conformance accessibility data
|
|
22
|
+
var ConformanceParser = /** @class */ (function (_super) {
|
|
23
|
+
__extends(ConformanceParser, _super);
|
|
24
|
+
function ConformanceParser() {
|
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
}
|
|
27
|
+
// parse function gets a tag <conformance>
|
|
28
|
+
// and extracts Conformance data from it
|
|
29
|
+
ConformanceParser.prototype.parse = function (tag) {
|
|
30
|
+
// extract the 'conformsTo' value from the tag
|
|
31
|
+
// using the helper function.
|
|
32
|
+
var conformsTo = this.extractConformsTo(tag);
|
|
33
|
+
// return new Conformance instance
|
|
34
|
+
return this.createConformance(conformsTo);
|
|
35
|
+
};
|
|
36
|
+
// helper function to extract the 'conformsTo' value from the tag
|
|
37
|
+
ConformanceParser.prototype.extractConformsTo = function (tag) {
|
|
38
|
+
// Use the existing method to parse the subtag content
|
|
39
|
+
return this.parseSubtagContent(tag, "conformsTo");
|
|
40
|
+
};
|
|
41
|
+
// helper function to create a Conformance instance
|
|
42
|
+
// from the extracted conformsTo element
|
|
43
|
+
ConformanceParser.prototype.createConformance = function (conformsTo) {
|
|
44
|
+
// create a ConformanceArgs object
|
|
45
|
+
// to hold the extracted data
|
|
46
|
+
var conformanceArgs = { conformsTo: conformsTo };
|
|
47
|
+
// return a new Conformance instance
|
|
48
|
+
// using the collected arguments
|
|
49
|
+
return new conformance_1.default(conformanceArgs);
|
|
50
|
+
};
|
|
51
|
+
return ConformanceParser;
|
|
52
|
+
}(xml2js_output_parser_1.default));
|
|
53
|
+
exports.default = ConformanceParser;
|
package/lib/src/entry_parser.js
CHANGED
|
@@ -15,6 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var accessibility_parser_1 = require("./accessibility_parser");
|
|
18
19
|
var opds_entry_1 = require("./opds_entry");
|
|
19
20
|
var partial_opds_entry_1 = require("./partial_opds_entry");
|
|
20
21
|
var complete_entry_link_1 = require("./complete_entry_link");
|
|
@@ -36,6 +37,8 @@ var EntryParser = /** @class */ (function (_super) {
|
|
|
36
37
|
var dcPrefix = this.prefixes[namespace_parser_1.default.DC_URI];
|
|
37
38
|
var schemaPrefix = this.prefixes[namespace_parser_1.default.SCHEMA_URI];
|
|
38
39
|
var id = this.parseSubtagContent(entry, atomPrefix + "id");
|
|
40
|
+
var accessibilityParser = new accessibility_parser_1.default(this.prefixes);
|
|
41
|
+
var accessibility = this.parseSubtag(entry, atomPrefix + "accessibility", accessibilityParser);
|
|
39
42
|
var updated = this.parseSubtagContent(entry, atomPrefix + "updated");
|
|
40
43
|
var title = this.parseSubtagContent(entry, atomPrefix + "title");
|
|
41
44
|
var contributorParser = new contributor_parser_1.default(this.prefixes);
|
|
@@ -83,6 +86,7 @@ var EntryParser = /** @class */ (function (_super) {
|
|
|
83
86
|
}
|
|
84
87
|
return new entryClass({
|
|
85
88
|
id: id,
|
|
89
|
+
accessibility: accessibility,
|
|
86
90
|
updated: updated,
|
|
87
91
|
title: title,
|
|
88
92
|
authors: authors,
|
package/lib/src/opds_entry.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Accessibility from "./accessibility";
|
|
1
2
|
import OPDSLink from "./opds_link";
|
|
2
3
|
import Contributor from "./contributor";
|
|
3
4
|
import Series from "./series";
|
|
@@ -5,6 +6,7 @@ import Category from "./category";
|
|
|
5
6
|
import Summary from "./summary";
|
|
6
7
|
export default class OPDSEntry {
|
|
7
8
|
id: string;
|
|
9
|
+
accessibility: Accessibility;
|
|
8
10
|
updated: string;
|
|
9
11
|
title: string;
|
|
10
12
|
authors: Array<Contributor>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import WaysOfReading from "./ways_of_reading";
|
|
2
|
+
import Xml2jsOutputParser from "./xml2js_output_parser";
|
|
3
|
+
export default class WaysOfReadingParser extends Xml2jsOutputParser<WaysOfReading> {
|
|
4
|
+
parse(tag: any): WaysOfReading;
|
|
5
|
+
private extractFeatures;
|
|
6
|
+
private createWaysOfReading;
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var ways_of_reading_1 = require("./ways_of_reading");
|
|
19
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
20
|
+
// this class extends Xml2jsOutputParser
|
|
21
|
+
// to handle parsing of ways of reading accessibility data
|
|
22
|
+
var WaysOfReadingParser = /** @class */ (function (_super) {
|
|
23
|
+
__extends(WaysOfReadingParser, _super);
|
|
24
|
+
function WaysOfReadingParser() {
|
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
}
|
|
27
|
+
// parse function gets a tag <waysOfReading>
|
|
28
|
+
// and extracts Conformance information from it.
|
|
29
|
+
WaysOfReadingParser.prototype.parse = function (tag) {
|
|
30
|
+
// extract an array of features
|
|
31
|
+
// from the 'feature' subtags in the tag
|
|
32
|
+
var featuresArray = this.extractFeatures(tag["feature"]);
|
|
33
|
+
// return new WaysOfReading instance
|
|
34
|
+
return this.createWaysOfReading(featuresArray);
|
|
35
|
+
};
|
|
36
|
+
// helper function to extract features from the 'feature' subtags
|
|
37
|
+
WaysOfReadingParser.prototype.extractFeatures = function (featureSubtags) {
|
|
38
|
+
// first check that featureSubtags is defined and is an array
|
|
39
|
+
if (!featureSubtags || !Array.isArray(featureSubtags)) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
// then extract the feature element contents from subtags,
|
|
43
|
+
// mapping each subtag to its content
|
|
44
|
+
return featureSubtags.map(function (subtag) { return subtag["_"]; });
|
|
45
|
+
};
|
|
46
|
+
// helper function to create a WaysOfReading instance
|
|
47
|
+
// from the extracted feature elements
|
|
48
|
+
WaysOfReadingParser.prototype.createWaysOfReading = function (features) {
|
|
49
|
+
// create a WaysOfReadingArgs object
|
|
50
|
+
// to hold the extracted data
|
|
51
|
+
var waysOfReadingArgs = { features: features };
|
|
52
|
+
// return a new WaysOfReading instance
|
|
53
|
+
// using the collected arguments
|
|
54
|
+
// (there's a constructor init method for this)
|
|
55
|
+
return new ways_of_reading_1.default(waysOfReadingArgs);
|
|
56
|
+
};
|
|
57
|
+
return WaysOfReadingParser;
|
|
58
|
+
}(xml2js_output_parser_1.default));
|
|
59
|
+
exports.default = WaysOfReadingParser;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@natlibfi/ekirjasto-opds-feed-parser",
|
|
3
3
|
"description": "E-kirjasto OPDS feed parser",
|
|
4
|
-
"version": "0.0.0-post.
|
|
4
|
+
"version": "0.0.0-post.149",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "The National Library of Finland"
|
|
7
7
|
},
|
|
@@ -15,18 +15,22 @@
|
|
|
15
15
|
"homepage": "https://github.com/NatLibFi/ekirjasto-opds-feed-parser",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git@github.com
|
|
19
|
-
},
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/NatLibFi/ekirjasto-opds-feed-parser/issues"
|
|
18
|
+
"url": "git+ssh://git@github.com/NatLibFi/ekirjasto-opds-feed-parser.git"
|
|
22
19
|
},
|
|
23
20
|
"engines": {
|
|
24
21
|
"node": ">=20"
|
|
25
22
|
},
|
|
26
23
|
"main": "lib/src/index.js",
|
|
27
24
|
"typings": "lib/src/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/src/**/*",
|
|
27
|
+
"CHANGELOG",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
28
31
|
"scripts": {
|
|
29
|
-
"
|
|
32
|
+
"prepare": "rm -rf lib && tsc",
|
|
33
|
+
"prepublishOnly": "npm test",
|
|
30
34
|
"lint": "tslint -c tslint.json src/*.ts test/*.ts",
|
|
31
35
|
"test": "rm -rf lib && npm run lint && tsc && mocha lib/test/*.js"
|
|
32
36
|
},
|
package/.github/CODEOWNERS
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
## Description
|
|
2
|
-
<!--- Provide a brief overview of what this pull request accomplishes -->
|
|
3
|
-
|
|
4
|
-
## Rationale for changes
|
|
5
|
-
<!--- Explain the necessity of this change -->
|
|
6
|
-
<!--- Include a link to the relevant Jira issue here. -->
|
|
7
|
-
|
|
8
|
-
## Documentation updates
|
|
9
|
-
<!--- Mention any modifications made to the documentation-->
|
|
10
|
-
|
|
11
|
-
## Review and testing instructions
|
|
12
|
-
<!--- Outline the steps the reviewer should follow to test this pull request -->
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
name: npm Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
release:
|
|
8
|
-
types: [published]
|
|
9
|
-
workflow_call:
|
|
10
|
-
inputs:
|
|
11
|
-
version-source:
|
|
12
|
-
description: "Set to 'dunamai' to compute from git, or 'release-tag' to use a provided tag."
|
|
13
|
-
required: true
|
|
14
|
-
type: string
|
|
15
|
-
release-tag:
|
|
16
|
-
description: "Release tag to use when version-source is release-tag."
|
|
17
|
-
required: false
|
|
18
|
-
type: string
|
|
19
|
-
publish-tag:
|
|
20
|
-
description: "npm dist-tag to publish with."
|
|
21
|
-
required: false
|
|
22
|
-
type: string
|
|
23
|
-
default: latest
|
|
24
|
-
|
|
25
|
-
concurrency:
|
|
26
|
-
group: npm-publish-${{ github.ref_name }}-${{ github.event_name }}
|
|
27
|
-
cancel-in-progress: true
|
|
28
|
-
|
|
29
|
-
permissions:
|
|
30
|
-
id-token: write # Required for OIDC
|
|
31
|
-
contents: read
|
|
32
|
-
|
|
33
|
-
jobs:
|
|
34
|
-
npm-publish:
|
|
35
|
-
runs-on: ubuntu-latest
|
|
36
|
-
steps:
|
|
37
|
-
- name: Resolve publish parameters (push)
|
|
38
|
-
if: github.event_name == 'push'
|
|
39
|
-
run: |
|
|
40
|
-
echo "VERSION_SOURCE=dunamai" >> "$GITHUB_ENV"
|
|
41
|
-
echo "PUBLISH_TAG=next" >> "$GITHUB_ENV"
|
|
42
|
-
|
|
43
|
-
- name: Resolve publish parameters (release)
|
|
44
|
-
if: github.event_name == 'release'
|
|
45
|
-
run: |
|
|
46
|
-
echo "VERSION_SOURCE=release-tag" >> "$GITHUB_ENV"
|
|
47
|
-
echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV"
|
|
48
|
-
echo "PUBLISH_TAG=latest" >> "$GITHUB_ENV"
|
|
49
|
-
|
|
50
|
-
- name: Resolve publish parameters (workflow_call)
|
|
51
|
-
if: github.event_name == 'workflow_call'
|
|
52
|
-
run: |
|
|
53
|
-
echo "VERSION_SOURCE=${{ inputs.version-source }}" >> "$GITHUB_ENV"
|
|
54
|
-
echo "RELEASE_TAG=${{ inputs.release-tag }}" >> "$GITHUB_ENV"
|
|
55
|
-
echo "PUBLISH_TAG=${{ inputs.publish-tag }}" >> "$GITHUB_ENV"
|
|
56
|
-
|
|
57
|
-
- uses: actions/checkout@v4
|
|
58
|
-
with:
|
|
59
|
-
persist-credentials: false
|
|
60
|
-
fetch-depth: 0
|
|
61
|
-
|
|
62
|
-
- uses: actions/setup-node@v4
|
|
63
|
-
with:
|
|
64
|
-
node-version: 20.17
|
|
65
|
-
registry-url: https://registry.npmjs.org/
|
|
66
|
-
cache: npm
|
|
67
|
-
|
|
68
|
-
- name: Upgrade npm (trusted publishing requirement) ⬆️
|
|
69
|
-
run: npm install -g npm@^11.5.1
|
|
70
|
-
|
|
71
|
-
- name: Set up Python 🐍
|
|
72
|
-
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_call' && inputs.version-source == 'dunamai') }}
|
|
73
|
-
uses: actions/setup-python@v5
|
|
74
|
-
with:
|
|
75
|
-
python-version: "3.10"
|
|
76
|
-
|
|
77
|
-
- name: Set up Dunamai 🪄
|
|
78
|
-
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_call' && inputs.version-source == 'dunamai') }}
|
|
79
|
-
run: pip install -r requirements-ci.txt
|
|
80
|
-
|
|
81
|
-
- name: Install locked dependencies 🔧
|
|
82
|
-
run: npm ci
|
|
83
|
-
|
|
84
|
-
- name: Version ✅
|
|
85
|
-
run: |
|
|
86
|
-
if [ "${VERSION_SOURCE}" = "dunamai" ]; then
|
|
87
|
-
npm version --no-git-tag-version $(dunamai from git --style semver)
|
|
88
|
-
else
|
|
89
|
-
if [ -z "${RELEASE_TAG}" ]; then
|
|
90
|
-
echo "release-tag input is required when version-source is not 'dunamai'." 1>&2
|
|
91
|
-
exit 1
|
|
92
|
-
fi
|
|
93
|
-
npm version --no-git-tag-version "${RELEASE_TAG}"
|
|
94
|
-
fi
|
|
95
|
-
|
|
96
|
-
- name: Test 🧪
|
|
97
|
-
env:
|
|
98
|
-
TZ: Europe/Helsinki
|
|
99
|
-
run: npm test
|
|
100
|
-
|
|
101
|
-
- name: Publish 📚 (OIDC Trusted Publishing)
|
|
102
|
-
run: npm publish --tag "${PUBLISH_TAG}" --access public --provenance
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
test:
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
|
|
8
|
-
steps:
|
|
9
|
-
- name: Checkout 🛎️
|
|
10
|
-
uses: actions/checkout@v3
|
|
11
|
-
|
|
12
|
-
- name: Install Node.js 💻
|
|
13
|
-
uses: actions/setup-node@v3
|
|
14
|
-
with:
|
|
15
|
-
node-version: 18
|
|
16
|
-
|
|
17
|
-
- name: Install locked dependencies 🔧
|
|
18
|
-
run: npm ci
|
|
19
|
-
|
|
20
|
-
- name: Test 🧪
|
|
21
|
-
env:
|
|
22
|
-
TZ: Europe/Helsinki
|
|
23
|
-
run: npm test
|
package/requirements-ci.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dunamai==1.25.0
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import PrefixMap from "../src/prefix_map";
|
|
2
|
-
import OPDSAvailability from "../src/opds_availability";
|
|
3
|
-
import AvailabilityParser from "../src/availability_parser";
|
|
4
|
-
import NamespaceParser from "../src/namespace_parser";
|
|
5
|
-
import chai = require("chai");
|
|
6
|
-
let expect = chai.expect;
|
|
7
|
-
|
|
8
|
-
describe("AvailabilityParser", () => {
|
|
9
|
-
let parser: AvailabilityParser;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
let prefixes: PrefixMap = {};
|
|
13
|
-
prefixes[NamespaceParser.OPDS_URI] = "opds:";
|
|
14
|
-
parser = new AvailabilityParser(prefixes);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("#parse", () => {
|
|
18
|
-
it("extract attributes", () => {
|
|
19
|
-
let availability = {
|
|
20
|
-
$: {
|
|
21
|
-
status: { value: "reserved" },
|
|
22
|
-
since: { value: "2016-07-26T15:46:19Z" },
|
|
23
|
-
until: { value: "2016-11-02T19:46:27Z" }
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
let parsed = parser.parse(availability);
|
|
27
|
-
expect(parsed.status).to.equals("reserved");
|
|
28
|
-
expect(parsed.since).to.equals("2016-07-26T15:46:19Z");
|
|
29
|
-
expect(parsed.until).to.equals("2016-11-02T19:46:27Z");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import PrefixMap from "../src/prefix_map";
|
|
2
|
-
import CategoryParser from "../src/category_parser";
|
|
3
|
-
import chai = require("chai");
|
|
4
|
-
let expect = chai.expect;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe("CategoryParser", () => {
|
|
8
|
-
let parser: CategoryParser;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
let prefixes: PrefixMap = {};
|
|
12
|
-
parser = new CategoryParser(prefixes);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe("#parse", () => {
|
|
16
|
-
it("extracts attributes", () => {
|
|
17
|
-
let category = {
|
|
18
|
-
"$": {
|
|
19
|
-
"term": {"value": "test term"},
|
|
20
|
-
"scheme": {"value": "test scheme"},
|
|
21
|
-
"label": {"value": "test label"}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
let parsedCategory = parser.parse(category);
|
|
25
|
-
expect(parsedCategory.term).to.equals("test term");
|
|
26
|
-
expect(parsedCategory.scheme).to.equals("test scheme");
|
|
27
|
-
expect(parsedCategory.label).to.equals("test label");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import PrefixMap from "../src/prefix_map";
|
|
2
|
-
import ContributorParser from "../src/contributor_parser";
|
|
3
|
-
import NamespaceParser from "../src/namespace_parser";
|
|
4
|
-
import chai = require("chai");
|
|
5
|
-
let expect = chai.expect;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe("ContributorParser", () => {
|
|
9
|
-
let parser: ContributorParser;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
let prefixes: PrefixMap = {};
|
|
13
|
-
prefixes[NamespaceParser.OPF_URI] = "opf:";
|
|
14
|
-
parser = new ContributorParser(prefixes);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("#parse", () => {
|
|
18
|
-
it("extracts name", () => {
|
|
19
|
-
let author = {
|
|
20
|
-
"name": [{"_": "test name"}],
|
|
21
|
-
};
|
|
22
|
-
let parsedAuthor = parser.parse(author);
|
|
23
|
-
expect(parsedAuthor.name).to.equals("test name");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("extracts uri", () => {
|
|
27
|
-
let author = {
|
|
28
|
-
"uri": [{"_": "test uri"}],
|
|
29
|
-
};
|
|
30
|
-
let parsedAuthor = parser.parse(author);
|
|
31
|
-
expect(parsedAuthor.uri).to.equals("test uri");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("extracts role", () => {
|
|
35
|
-
let author = {
|
|
36
|
-
$: {
|
|
37
|
-
"opf:role": {value: "test role"}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
let parsedAuthor = parser.parse(author);
|
|
41
|
-
expect(parsedAuthor.role).to.equals("test role");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import PrefixMap from "../src/prefix_map";
|
|
2
|
-
import OPDSCopies from "../src/opds_copies";
|
|
3
|
-
import CopiesParser from "../src/copies_parser";
|
|
4
|
-
import NamespaceParser from "../src/namespace_parser";
|
|
5
|
-
import chai = require("chai");
|
|
6
|
-
let expect = chai.expect;
|
|
7
|
-
|
|
8
|
-
describe("CopiesParser", () => {
|
|
9
|
-
let parser: CopiesParser;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
let prefixes: PrefixMap = {};
|
|
13
|
-
prefixes[NamespaceParser.OPDS_URI] = "opds:";
|
|
14
|
-
parser = new CopiesParser(prefixes);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("#parse", () => {
|
|
18
|
-
it("extract attributes", () => {
|
|
19
|
-
let copies = {
|
|
20
|
-
$: {
|
|
21
|
-
total: { value: "13" },
|
|
22
|
-
available: { value: "2" },
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
let parsed = parser.parse(copies);
|
|
26
|
-
expect(parsed.total).to.equals(13);
|
|
27
|
-
expect(parsed.available).to.equals(2);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|