@natlibfi/ekirjasto-opds-feed-parser 1.0.0 → 2.0.1-post.1
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/acquisition_feed.d.ts +3 -0
- package/lib/src/acquisition_feed.js +26 -0
- package/lib/src/alternate_link.d.ts +5 -0
- package/lib/src/alternate_link.js +30 -0
- package/lib/src/availability_parser.d.ts +5 -0
- package/lib/src/availability_parser.js +34 -0
- package/lib/src/category.d.ts +8 -0
- package/lib/src/category.js +9 -0
- package/lib/src/category_parser.d.ts +5 -0
- package/lib/src/category_parser.js +33 -0
- package/lib/src/complete_entry_link.d.ts +6 -0
- package/lib/src/complete_entry_link.js +30 -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/contributor.d.ts +8 -0
- package/lib/src/contributor.js +9 -0
- package/lib/src/contributor_parser.d.ts +5 -0
- package/lib/src/contributor_parser.js +35 -0
- package/lib/src/copies_parser.d.ts +5 -0
- package/lib/src/copies_parser.js +33 -0
- package/lib/src/entry_parser.d.ts +5 -0
- package/lib/src/entry_parser.js +110 -0
- package/lib/src/feed_parser.d.ts +5 -0
- package/lib/src/feed_parser.js +61 -0
- package/lib/src/holds_parser.d.ts +5 -0
- package/lib/src/holds_parser.js +33 -0
- package/lib/src/index.d.ts +25 -0
- package/lib/src/index.js +45 -0
- package/lib/src/indirect_acquisition_parser.d.ts +5 -0
- package/lib/src/indirect_acquisition_parser.js +37 -0
- package/lib/src/lcp_passphrases.d.ts +10 -0
- package/lib/src/lcp_passphrases.js +20 -0
- package/lib/src/link_parser.d.ts +7 -0
- package/lib/src/link_parser.js +113 -0
- package/lib/src/namespace_parser.d.ts +14 -0
- package/lib/src/namespace_parser.js +76 -0
- package/lib/src/navigation_feed.d.ts +3 -0
- package/lib/src/navigation_feed.js +26 -0
- package/lib/src/opds_acquisition_link.d.ts +32 -0
- package/lib/src/opds_acquisition_link.js +48 -0
- package/lib/src/opds_artwork_link.d.ts +7 -0
- package/lib/src/opds_artwork_link.js +33 -0
- package/lib/src/opds_availability.d.ts +6 -0
- package/lib/src/opds_availability.js +2 -0
- package/lib/src/opds_catalog_root_link.d.ts +5 -0
- package/lib/src/opds_catalog_root_link.js +30 -0
- package/lib/src/opds_collection_link.d.ts +5 -0
- package/lib/src/opds_collection_link.js +30 -0
- package/lib/src/opds_copies.d.ts +5 -0
- package/lib/src/opds_copies.js +2 -0
- package/lib/src/opds_crawlable_link.d.ts +5 -0
- package/lib/src/opds_crawlable_link.js +30 -0
- package/lib/src/opds_entry.d.ts +29 -0
- package/lib/src/opds_entry.js +9 -0
- package/lib/src/opds_facet_link.d.ts +13 -0
- package/lib/src/opds_facet_link.js +30 -0
- package/lib/src/opds_feed.d.ts +19 -0
- package/lib/src/opds_feed.js +9 -0
- package/lib/src/opds_holds.d.ts +5 -0
- package/lib/src/opds_holds.js +2 -0
- package/lib/src/opds_indirect_acquisition.d.ts +5 -0
- package/lib/src/opds_indirect_acquisition.js +2 -0
- package/lib/src/opds_link.d.ts +15 -0
- package/lib/src/opds_link.js +13 -0
- package/lib/src/opds_parser.d.ts +5 -0
- package/lib/src/opds_parser.js +62 -0
- package/lib/src/opds_price.d.ts +5 -0
- package/lib/src/opds_price.js +2 -0
- package/lib/src/opds_shelf_link.d.ts +5 -0
- package/lib/src/opds_shelf_link.js +30 -0
- package/lib/src/partial_opds_entry.d.ts +3 -0
- package/lib/src/partial_opds_entry.js +26 -0
- package/lib/src/passphrases_parser.d.ts +7 -0
- package/lib/src/passphrases_parser.js +64 -0
- package/lib/src/prefix_map.d.ts +4 -0
- package/lib/src/prefix_map.js +2 -0
- package/lib/src/price_parser.d.ts +5 -0
- package/lib/src/price_parser.js +31 -0
- package/lib/src/search_link.d.ts +5 -0
- package/lib/src/search_link.js +30 -0
- package/lib/src/series.d.ts +7 -0
- package/lib/src/series.js +9 -0
- package/lib/src/series_parser.d.ts +5 -0
- package/lib/src/series_parser.js +34 -0
- package/lib/src/summary.d.ts +7 -0
- package/lib/src/summary.js +9 -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/lib/src/xml2js_output_parser.d.ts +11 -0
- package/lib/src/xml2js_output_parser.js +48 -0
- package/lib/src/xml_interface.d.ts +9 -0
- package/lib/src/xml_interface.js +2 -0
- package/package.json +14 -10
- 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,26 @@
|
|
|
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 opds_feed_1 = require("./opds_feed");
|
|
19
|
+
var AcquisitionFeed = /** @class */ (function (_super) {
|
|
20
|
+
__extends(AcquisitionFeed, _super);
|
|
21
|
+
function AcquisitionFeed() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
return AcquisitionFeed;
|
|
25
|
+
}(opds_feed_1.default));
|
|
26
|
+
exports.default = AcquisitionFeed;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 opds_link_1 = require("./opds_link");
|
|
19
|
+
var AlternateLink = /** @class */ (function (_super) {
|
|
20
|
+
__extends(AlternateLink, _super);
|
|
21
|
+
function AlternateLink(args) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
args.rel = AlternateLink.REL;
|
|
24
|
+
_this = _super.call(this, args) || this;
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
AlternateLink.REL = "alternate";
|
|
28
|
+
return AlternateLink;
|
|
29
|
+
}(opds_link_1.default));
|
|
30
|
+
exports.default = AlternateLink;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
19
|
+
var AvailabilityParser = /** @class */ (function (_super) {
|
|
20
|
+
__extends(AvailabilityParser, _super);
|
|
21
|
+
function AvailabilityParser() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
AvailabilityParser.prototype.parse = function (element) {
|
|
25
|
+
var parsed = {
|
|
26
|
+
status: this.parseAttribute(element, "status"),
|
|
27
|
+
since: this.parseAttribute(element, "since"),
|
|
28
|
+
until: this.parseAttribute(element, "until")
|
|
29
|
+
};
|
|
30
|
+
return parsed;
|
|
31
|
+
};
|
|
32
|
+
return AvailabilityParser;
|
|
33
|
+
}(xml2js_output_parser_1.default));
|
|
34
|
+
exports.default = AvailabilityParser;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 category_1 = require("./category");
|
|
19
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
20
|
+
var CategoryParser = /** @class */ (function (_super) {
|
|
21
|
+
__extends(CategoryParser, _super);
|
|
22
|
+
function CategoryParser() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
CategoryParser.prototype.parse = function (category) {
|
|
26
|
+
var term = this.parseAttribute(category, "term");
|
|
27
|
+
var scheme = this.parseAttribute(category, "scheme");
|
|
28
|
+
var label = this.parseAttribute(category, "label");
|
|
29
|
+
return new category_1.default({ term: term, scheme: scheme, label: label });
|
|
30
|
+
};
|
|
31
|
+
return CategoryParser;
|
|
32
|
+
}(xml2js_output_parser_1.default));
|
|
33
|
+
exports.default = CategoryParser;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 alternate_link_1 = require("./alternate_link");
|
|
19
|
+
var CompleteEntryLink = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CompleteEntryLink, _super);
|
|
21
|
+
function CompleteEntryLink(args) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
args.type = CompleteEntryLink.TYPE;
|
|
24
|
+
_this = _super.call(this, args) || this;
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
CompleteEntryLink.TYPE = "application/atom+xml;type=entry;profile=opds-catalog";
|
|
28
|
+
return CompleteEntryLink;
|
|
29
|
+
}(alternate_link_1.default));
|
|
30
|
+
exports.default = CompleteEntryLink;
|
|
@@ -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;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 contributor_1 = require("./contributor");
|
|
19
|
+
var namespace_parser_1 = require("./namespace_parser");
|
|
20
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
21
|
+
var ContributorParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(ContributorParser, _super);
|
|
23
|
+
function ContributorParser() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
ContributorParser.prototype.parse = function (contributor) {
|
|
27
|
+
var name = this.parseSubtagContent(contributor, "name");
|
|
28
|
+
var uri = this.parseSubtagContent(contributor, "uri");
|
|
29
|
+
var opfPrefix = this.prefixes[namespace_parser_1.default.OPF_URI];
|
|
30
|
+
var role = this.parseAttribute(contributor, opfPrefix + "role");
|
|
31
|
+
return new contributor_1.default({ name: name, uri: uri, role: role });
|
|
32
|
+
};
|
|
33
|
+
return ContributorParser;
|
|
34
|
+
}(xml2js_output_parser_1.default));
|
|
35
|
+
exports.default = ContributorParser;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
19
|
+
var CopiesParser = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CopiesParser, _super);
|
|
21
|
+
function CopiesParser() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
CopiesParser.prototype.parse = function (element) {
|
|
25
|
+
var parsed = {
|
|
26
|
+
total: parseInt(this.parseAttribute(element, "total")),
|
|
27
|
+
available: parseInt(this.parseAttribute(element, "available")),
|
|
28
|
+
};
|
|
29
|
+
return parsed;
|
|
30
|
+
};
|
|
31
|
+
return CopiesParser;
|
|
32
|
+
}(xml2js_output_parser_1.default));
|
|
33
|
+
exports.default = CopiesParser;
|
|
@@ -0,0 +1,110 @@
|
|
|
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_parser_1 = require("./accessibility_parser");
|
|
19
|
+
var opds_entry_1 = require("./opds_entry");
|
|
20
|
+
var partial_opds_entry_1 = require("./partial_opds_entry");
|
|
21
|
+
var complete_entry_link_1 = require("./complete_entry_link");
|
|
22
|
+
var link_parser_1 = require("./link_parser");
|
|
23
|
+
var contributor_parser_1 = require("./contributor_parser");
|
|
24
|
+
var series_parser_1 = require("./series_parser");
|
|
25
|
+
var category_parser_1 = require("./category_parser");
|
|
26
|
+
var namespace_parser_1 = require("./namespace_parser");
|
|
27
|
+
var summary_1 = require("./summary");
|
|
28
|
+
var xml2js_output_parser_1 = require("./xml2js_output_parser");
|
|
29
|
+
var EntryParser = /** @class */ (function (_super) {
|
|
30
|
+
__extends(EntryParser, _super);
|
|
31
|
+
function EntryParser() {
|
|
32
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
33
|
+
}
|
|
34
|
+
EntryParser.prototype.parse = function (entry) {
|
|
35
|
+
var linkParser = new link_parser_1.default(this.prefixes);
|
|
36
|
+
var atomPrefix = this.prefixes[namespace_parser_1.default.ATOM_URI];
|
|
37
|
+
var dcPrefix = this.prefixes[namespace_parser_1.default.DC_URI];
|
|
38
|
+
var schemaPrefix = this.prefixes[namespace_parser_1.default.SCHEMA_URI];
|
|
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);
|
|
42
|
+
var updated = this.parseSubtagContent(entry, atomPrefix + "updated");
|
|
43
|
+
var title = this.parseSubtagContent(entry, atomPrefix + "title");
|
|
44
|
+
var contributorParser = new contributor_parser_1.default(this.prefixes);
|
|
45
|
+
var authors = this.parseSubtags(entry, atomPrefix + "author", contributorParser);
|
|
46
|
+
var contributors = this.parseSubtags(entry, atomPrefix + "contributor", contributorParser);
|
|
47
|
+
var subtitle = this.parseSubtagContent(entry, schemaPrefix + "alternativeHeadline");
|
|
48
|
+
var seriesParser = new series_parser_1.default(this.prefixes);
|
|
49
|
+
var series = this.parseSubtag(entry, schemaPrefix + "Series", seriesParser);
|
|
50
|
+
var links = this.parseSubtags(entry, atomPrefix + "link", linkParser);
|
|
51
|
+
var categoryParser = new category_parser_1.default(this.prefixes);
|
|
52
|
+
var categories = this.parseSubtags(entry, atomPrefix + "category", categoryParser);
|
|
53
|
+
var rawIdentifiers = entry[dcPrefix + "identifier"];
|
|
54
|
+
var identifiers;
|
|
55
|
+
if (rawIdentifiers && rawIdentifiers.length > 0) {
|
|
56
|
+
identifiers = rawIdentifiers.map(function (identifier) {
|
|
57
|
+
return identifier["_"];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
identifiers = [];
|
|
62
|
+
}
|
|
63
|
+
var issued = this.parseSubtagContent(entry, dcPrefix + "issued");
|
|
64
|
+
var language = this.parseSubtagContent(entry, dcPrefix + "language");
|
|
65
|
+
var rights = this.parseSubtagContent(entry, atomPrefix + "rights");
|
|
66
|
+
var publisher = this.parseSubtagContent(entry, dcPrefix + "publisher");
|
|
67
|
+
var published = this.parseSubtagContent(entry, atomPrefix + "published");
|
|
68
|
+
var summaryLink;
|
|
69
|
+
var summaryContent = this.parseSubtagContent(entry, atomPrefix + "content");
|
|
70
|
+
if (!summaryContent) {
|
|
71
|
+
var subtag = entry[atomPrefix + "content"];
|
|
72
|
+
if (subtag && subtag.length > 0) {
|
|
73
|
+
summaryLink = this.parseAttribute(subtag[0], "src");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!summaryContent) {
|
|
77
|
+
summaryContent = this.parseSubtagContent(entry, atomPrefix + "summary");
|
|
78
|
+
}
|
|
79
|
+
var summary = new summary_1.default({ content: summaryContent, link: summaryLink });
|
|
80
|
+
var entryClass = opds_entry_1.default;
|
|
81
|
+
var completeEntryLink = links.find(function (link) {
|
|
82
|
+
return (link instanceof complete_entry_link_1.default);
|
|
83
|
+
});
|
|
84
|
+
if (completeEntryLink) {
|
|
85
|
+
entryClass = partial_opds_entry_1.default;
|
|
86
|
+
}
|
|
87
|
+
return new entryClass({
|
|
88
|
+
id: id,
|
|
89
|
+
accessibility: accessibility,
|
|
90
|
+
updated: updated,
|
|
91
|
+
title: title,
|
|
92
|
+
authors: authors,
|
|
93
|
+
contributors: contributors,
|
|
94
|
+
subtitle: subtitle,
|
|
95
|
+
series: series,
|
|
96
|
+
links: links,
|
|
97
|
+
categories: categories,
|
|
98
|
+
identifiers: identifiers,
|
|
99
|
+
issued: issued,
|
|
100
|
+
language: language,
|
|
101
|
+
rights: rights,
|
|
102
|
+
publisher: publisher,
|
|
103
|
+
published: published,
|
|
104
|
+
summary: summary,
|
|
105
|
+
unparsed: entry
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return EntryParser;
|
|
109
|
+
}(xml2js_output_parser_1.default));
|
|
110
|
+
exports.default = EntryParser;
|