shamela 1.0.2 → 1.0.4
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 +36 -26
- package/dist/index.d.ts +62 -9
- package/dist/main.js +254 -214
- package/dist/main.js.map +1 -1
- package/package.json +20 -21
package/README.md
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
# Shamela
|
|
2
2
|
|
|
3
|
-
[](https://wakatime.com/badge/user/a0b906ce-b8e7-4463-8bce-383238df6d4b/project/faef70ab-efdb-448b-ab83-0fc66c95888e)
|
|
3
|
+
[](https://wakatime.com/badge/user/a0b906ce-b8e7-4463-8bce-383238df6d4b/project/faef70ab-efdb-448b-ab83-0fc66c95888e)
|
|
4
|
+
[](https://github.com/ragaeeb/shamela/actions/workflows/e2e.yml)
|
|
5
|
+
[](https://github.com/ragaeeb/shamela/actions/workflows/build.yml) 
|
|
6
|
+

|
|
7
|
+
[](https://codecov.io/gh/ragaeeb/shamela)
|
|
8
|
+
[](https://bundlejs.com/?q=shamela%401.0.5)
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
4
14
|
|
|
5
15
|
A `NodeJS` library for accessing and downloading Maktabah Shamela v4 APIs. This library provides easy-to-use functions to interact with the Shamela API, download master and book databases, and retrieve book data programmatically.
|
|
6
16
|
|
|
7
17
|
## Table of Contents
|
|
8
18
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [Environment Variables](#environment-variables)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [Getting Started](#getting-started)
|
|
23
|
+
- [API Functions](#api-functions)
|
|
24
|
+
- [getMasterMetadata](#getmastermetadata)
|
|
25
|
+
- [downloadMasterDatabase](#downloadmasterdatabase)
|
|
26
|
+
- [getBookMetadata](#getbookmetadata)
|
|
27
|
+
- [downloadBook](#downloadbook)
|
|
28
|
+
- [getBook](#getbook)
|
|
29
|
+
- [Examples](#examples)
|
|
30
|
+
- [Downloading the Master Database](#downloading-the-master-database)
|
|
31
|
+
- [Downloading a Book](#downloading-a-book)
|
|
32
|
+
- [Retrieving Book Data](#retrieving-book-data)
|
|
33
|
+
- [Testing](#testing)
|
|
34
|
+
- [License](#license)
|
|
25
35
|
|
|
26
36
|
## Installation
|
|
27
37
|
|
|
@@ -77,7 +87,7 @@ getMasterMetadata(version?: number): Promise<GetMasterMetadataResponsePayload>
|
|
|
77
87
|
|
|
78
88
|
```
|
|
79
89
|
|
|
80
|
-
-
|
|
90
|
+
- version (optional): The version number of the master database you want to fetch.
|
|
81
91
|
|
|
82
92
|
Example:
|
|
83
93
|
|
|
@@ -94,9 +104,9 @@ downloadMasterDatabase(options: DownloadMasterOptions): Promise<string>
|
|
|
94
104
|
|
|
95
105
|
```
|
|
96
106
|
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
107
|
+
- options: An object containing:
|
|
108
|
+
- masterMetadata (optional): The metadata obtained from getMasterMetadata.
|
|
109
|
+
- outputFile: An object specifying the output path.
|
|
100
110
|
|
|
101
111
|
Example:
|
|
102
112
|
|
|
@@ -114,10 +124,10 @@ Fetches metadata for a specific book.
|
|
|
114
124
|
getBookMetadata(id: number, options?: GetBookMetadataOptions): Promise<GetBookMetadataResponsePayload>
|
|
115
125
|
```
|
|
116
126
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
127
|
+
- id: The ID of the book.
|
|
128
|
+
- options (optional): An object containing:
|
|
129
|
+
- majorVersion: The major version of the book.
|
|
130
|
+
- minorVersion: The minor version of the book.
|
|
121
131
|
|
|
122
132
|
Example:
|
|
123
133
|
|
|
@@ -135,7 +145,7 @@ Retrieves the data of a book as a JavaScript object.
|
|
|
135
145
|
getBook(id: number): Promise<BookData>
|
|
136
146
|
```
|
|
137
147
|
|
|
138
|
-
-
|
|
148
|
+
- id: The ID of the book.
|
|
139
149
|
|
|
140
150
|
Example:
|
|
141
151
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,95 @@
|
|
|
1
|
-
type GetMasterMetadataResponsePayload = {
|
|
1
|
+
export type GetMasterMetadataResponsePayload = {
|
|
2
2
|
url: string;
|
|
3
3
|
version: number;
|
|
4
4
|
};
|
|
5
|
-
interface OutputOptions {
|
|
5
|
+
export interface OutputOptions {
|
|
6
6
|
path: string;
|
|
7
7
|
}
|
|
8
|
-
type DownloadMasterOptions = {
|
|
8
|
+
export type DownloadMasterOptions = {
|
|
9
9
|
masterMetadata?: GetMasterMetadataResponsePayload;
|
|
10
10
|
outputFile: OutputOptions;
|
|
11
11
|
};
|
|
12
|
-
type GetBookMetadataOptions = {
|
|
12
|
+
export type GetBookMetadataOptions = {
|
|
13
13
|
majorVersion: number;
|
|
14
14
|
minorVersion: number;
|
|
15
15
|
};
|
|
16
|
-
type GetBookMetadataResponsePayload = {
|
|
16
|
+
export type GetBookMetadataResponsePayload = {
|
|
17
17
|
majorRelease: number;
|
|
18
18
|
majorReleaseUrl: string;
|
|
19
19
|
minorRelease?: number;
|
|
20
20
|
minorReleaseUrl?: string;
|
|
21
21
|
};
|
|
22
|
-
type DownloadBookOptions = {
|
|
22
|
+
export type DownloadBookOptions = {
|
|
23
23
|
bookMetadata?: GetBookMetadataResponsePayload;
|
|
24
24
|
outputFile: OutputOptions;
|
|
25
25
|
};
|
|
26
|
-
type
|
|
26
|
+
export type Author = {
|
|
27
|
+
biography?: string;
|
|
28
|
+
death?: number;
|
|
29
|
+
id: number;
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
type PDFFile = {
|
|
33
|
+
file: string;
|
|
34
|
+
id?: string;
|
|
35
|
+
};
|
|
36
|
+
export type PDFLinks = {
|
|
37
|
+
alias?: number;
|
|
38
|
+
cover?: number;
|
|
39
|
+
cover_alias?: number;
|
|
40
|
+
files?: PDFFile[];
|
|
41
|
+
root?: string;
|
|
42
|
+
size?: number;
|
|
43
|
+
};
|
|
44
|
+
export type Metadata = {
|
|
45
|
+
coauthor?: number[];
|
|
46
|
+
date: string;
|
|
47
|
+
group?: number;
|
|
48
|
+
hide_diacritic?: boolean;
|
|
49
|
+
min_ver?: number;
|
|
50
|
+
prefix?: string;
|
|
51
|
+
shorts: Record<string, string>;
|
|
52
|
+
sub_books: number[];
|
|
53
|
+
suffix?: string;
|
|
54
|
+
};
|
|
55
|
+
export type Book = {
|
|
56
|
+
author: number | number[];
|
|
57
|
+
bibliography: string;
|
|
58
|
+
category: number;
|
|
59
|
+
date?: number;
|
|
60
|
+
hint?: string;
|
|
61
|
+
id: number;
|
|
62
|
+
major: number;
|
|
63
|
+
metadata: Metadata;
|
|
64
|
+
minor?: number;
|
|
65
|
+
name: string;
|
|
66
|
+
pdfLinks?: PDFLinks;
|
|
67
|
+
printed: number;
|
|
68
|
+
type: number;
|
|
69
|
+
};
|
|
70
|
+
export type Category = {
|
|
71
|
+
id: number;
|
|
72
|
+
name: string;
|
|
73
|
+
};
|
|
74
|
+
export type MasterData = {
|
|
75
|
+
authors: Author[];
|
|
76
|
+
books: Book[];
|
|
77
|
+
categories: Category[];
|
|
78
|
+
};
|
|
79
|
+
export type Page = {
|
|
27
80
|
content: string;
|
|
28
81
|
id: number;
|
|
29
82
|
number?: number;
|
|
30
83
|
page?: number;
|
|
31
84
|
part?: number;
|
|
32
85
|
};
|
|
33
|
-
type Title = {
|
|
86
|
+
export type Title = {
|
|
34
87
|
content: string;
|
|
35
88
|
id: number;
|
|
36
89
|
page: number;
|
|
37
90
|
parent?: number;
|
|
38
91
|
};
|
|
39
|
-
type BookData = {
|
|
92
|
+
export type BookData = {
|
|
40
93
|
pages: Page[];
|
|
41
94
|
titles?: Title[];
|
|
42
95
|
};
|