shamela 1.3.2 → 1.3.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.
@@ -0,0 +1,226 @@
1
+ //#region src/db/types.d.ts
2
+
3
+ /**
4
+ * A record that can be deleted by patches.
5
+ */
6
+ type Deletable = {
7
+ /** Indicates if it was deleted in the patch if it is set to '1 */
8
+ is_deleted?: string;
9
+ };
10
+ type Unique = {
11
+ /** Unique identifier */
12
+ id: number;
13
+ };
14
+ /**
15
+ * Database row structure for the author table.
16
+ */
17
+ type AuthorRow = Deletable & Unique & {
18
+ /** Author biography */
19
+ biography: string;
20
+ /** Death year */
21
+ death_number: string;
22
+ /** The death year as a text */
23
+ death_text: string;
24
+ /** Author name */
25
+ name: string;
26
+ };
27
+ /**
28
+ * Database row structure for the book table.
29
+ */
30
+ type BookRow = Deletable & Unique & {
31
+ /** Serialized author ID(s) "2747, 3147" or "513" */
32
+ author: string;
33
+ /** Bibliography information */
34
+ bibliography: string;
35
+ /** Category ID */
36
+ category: string;
37
+ /** Publication date (or 99999 for unavailable) */
38
+ date: string;
39
+ /** Hint or description */
40
+ hint: string;
41
+ /** Major version */
42
+ major_release: string;
43
+ /** Serialized metadata */
44
+ metadata: string;
45
+ /** Minor version */
46
+ minor_release: string;
47
+ /** Book name */
48
+ name: string;
49
+ /** Serialized PDF links */
50
+ pdf_links: string;
51
+ /** Printed flag */
52
+ printed: string;
53
+ /** Book type */
54
+ type: string;
55
+ };
56
+ /**
57
+ * Database row structure for the category table.
58
+ */
59
+ type CategoryRow = Deletable & Unique & {
60
+ /** Category name */
61
+ name: string;
62
+ /** Category order in the list to show. */
63
+ order: string;
64
+ };
65
+ /**
66
+ * Database row structure for the page table.
67
+ */
68
+ type PageRow = Deletable & Unique & {
69
+ /** Page content */
70
+ content: string;
71
+ /** Page number */
72
+ number: string | null;
73
+ /** Page reference */
74
+ page: string | null;
75
+ /** Part number */
76
+ part: string | null;
77
+ /** Additional metadata */
78
+ services: string | null;
79
+ };
80
+ /**
81
+ * Database row structure for the title table.
82
+ */
83
+ type TitleRow = Deletable & Unique & {
84
+ /** Title content */
85
+ content: string;
86
+ /** Page number */
87
+ page: string;
88
+ /** Parent title ID */
89
+ parent: string | null;
90
+ };
91
+ //#endregion
92
+ //#region src/types.d.ts
93
+ /**
94
+ * Represents an author entity.
95
+ */
96
+ type Author = AuthorRow;
97
+ /**
98
+ * Represents a book entity.
99
+ */
100
+ type Book = BookRow;
101
+ /**
102
+ * A category for a book.
103
+ */
104
+ type Category = CategoryRow;
105
+ /**
106
+ * A page in a book.
107
+ */
108
+ type Page = Pick<PageRow, 'id' | 'content'> & {
109
+ page?: number;
110
+ part?: string;
111
+ number?: string;
112
+ };
113
+ /**
114
+ * A title heading in a book.
115
+ */
116
+ type Title = Pick<TitleRow, 'id' | 'content'> & {
117
+ page: number;
118
+ parent?: number;
119
+ };
120
+ /**
121
+ * Represents book content data.
122
+ */
123
+ type BookData = {
124
+ /** Array of pages in the book */
125
+ pages: Page[];
126
+ /** Array of titles/chapters */
127
+ titles: Title[];
128
+ };
129
+ /**
130
+ * Master data structure containing all core entities.
131
+ */
132
+ type MasterData = {
133
+ /** Array of all authors */
134
+ authors: Author[];
135
+ /** Array of all books */
136
+ books: Book[];
137
+ /** Array of all categories */
138
+ categories: Category[];
139
+ /** Version number for the downloaded master database */
140
+ version: number;
141
+ };
142
+ /**
143
+ * Options for downloading a book.
144
+ */
145
+ type DownloadBookOptions = {
146
+ /** Optional book metadata */
147
+ bookMetadata?: GetBookMetadataResponsePayload;
148
+ /** Output file configuration */
149
+ outputFile: OutputOptions;
150
+ };
151
+ /**
152
+ * Options for downloading master data.
153
+ */
154
+ type DownloadMasterOptions = {
155
+ /** Optional master metadata */
156
+ masterMetadata?: GetMasterMetadataResponsePayload;
157
+ /** Output file configuration */
158
+ outputFile: OutputOptions;
159
+ };
160
+ /**
161
+ * Options for getting book metadata.
162
+ */
163
+ type GetBookMetadataOptions = {
164
+ /** Major version number */
165
+ majorVersion: number;
166
+ /** Minor version number */
167
+ minorVersion: number;
168
+ };
169
+ /**
170
+ * Response payload for book metadata requests.
171
+ */
172
+ type GetBookMetadataResponsePayload = {
173
+ /** Major release version */
174
+ majorRelease: number;
175
+ /** URL for major release download */
176
+ majorReleaseUrl: string;
177
+ /** Optional minor release version */
178
+ minorRelease?: number;
179
+ /** Optional URL for minor release download */
180
+ minorReleaseUrl?: string;
181
+ };
182
+ /**
183
+ * Response payload for master metadata requests.
184
+ */
185
+ type GetMasterMetadataResponsePayload = {
186
+ /** Download URL */
187
+ url: string;
188
+ /** Version number */
189
+ version: number;
190
+ };
191
+ type NodeJSOutput = {
192
+ /** Output file path (Node.js only) */
193
+ path: string;
194
+ writer?: never;
195
+ };
196
+ type CustomOutput = {
197
+ /** Custom writer used when path is not provided */
198
+ writer: (payload: string | Uint8Array) => Promise<void> | void;
199
+ path?: undefined;
200
+ };
201
+ /**
202
+ * Output file options.
203
+ */
204
+ type OutputOptions = NodeJSOutput | CustomOutput;
205
+ /**
206
+ * Runtime configuration for the library.
207
+ */
208
+ type ShamelaConfig = {
209
+ /** API key used to authenticate against Shamela services */
210
+ apiKey?: string;
211
+ /** Endpoint used for book metadata */
212
+ booksEndpoint?: string;
213
+ /** Endpoint used for master metadata */
214
+ masterPatchEndpoint?: string;
215
+ /** Optional override for the sql.js wasm asset location */
216
+ sqlJsWasmUrl?: string;
217
+ /** Optional custom fetch implementation for environments without a global fetch */
218
+ fetchImplementation?: typeof fetch;
219
+ };
220
+ /**
221
+ * Valid configuration keys.
222
+ */
223
+ type ShamelaConfigKey = keyof ShamelaConfig;
224
+ //#endregion
225
+ export { DownloadBookOptions as a, GetBookMetadataResponsePayload as c, OutputOptions as d, Page as f, Title as h, Category as i, GetMasterMetadataResponsePayload as l, ShamelaConfigKey as m, Book as n, DownloadMasterOptions as o, ShamelaConfig as p, BookData as r, GetBookMetadataOptions as s, Author as t, MasterData as u };
226
+ //# sourceMappingURL=types-C693UiUs.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { a as DownloadBookOptions, c as GetBookMetadataResponsePayload, d as OutputOptions, f as Page, h as Title, i as Category, l as GetMasterMetadataResponsePayload, m as ShamelaConfigKey, n as Book, o as DownloadMasterOptions, p as ShamelaConfig, r as BookData, s as GetBookMetadataOptions, t as Author, u as MasterData } from "./types-C693UiUs.js";
2
+ export { Author, Book, BookData, Category, DownloadBookOptions, DownloadMasterOptions, GetBookMetadataOptions, GetBookMetadataResponsePayload, GetMasterMetadataResponsePayload, MasterData, OutputOptions, Page, ShamelaConfig, ShamelaConfigKey, Title };
package/dist/types.js ADDED
File without changes
package/package.json CHANGED
@@ -7,30 +7,40 @@
7
7
  },
8
8
  "description": "Library to interact with the Maktabah Shamela v4 APIs",
9
9
  "devDependencies": {
10
- "@biomejs/biome": "^2.2.7",
11
- "@types/node": "^24.9.1",
12
- "@types/react": "^19.2.2",
13
- "@types/react-dom": "^19.2.2",
10
+ "@biomejs/biome": "^2.3.8",
11
+ "@types/bun": "^1.3.3",
12
+ "@types/node": "^24.10.1",
13
+ "@types/react": "^19.2.7",
14
+ "@types/react-dom": "^19.2.3",
14
15
  "@types/sql.js": "^1.4.9",
15
- "next": "^16.0.0",
16
- "react": "^19.2.0",
17
- "react-dom": "^19.2.0",
18
- "semantic-release": "^25.0.1",
19
- "tsdown": "^0.15.9",
16
+ "next": "^16.0.7",
17
+ "react": "^19.2.1",
18
+ "react-dom": "^19.2.1",
19
+ "semantic-release": "^25.0.2",
20
+ "tsdown": "^0.17.0",
20
21
  "typescript": "^5.9.3"
21
22
  },
22
23
  "engines": {
23
- "bun": ">=1.3.0",
24
+ "bun": ">=1.3.2",
24
25
  "node": ">=22.0.0"
25
26
  },
26
27
  "exports": {
27
28
  ".": {
29
+ "default": "./dist/index.js",
28
30
  "import": "./dist/index.js",
29
31
  "types": "./dist/index.d.ts"
32
+ },
33
+ "./content": {
34
+ "default": "./dist/content.js",
35
+ "import": "./dist/content.js",
36
+ "types": "./dist/content.d.ts"
37
+ },
38
+ "./types": {
39
+ "types": "./dist/types.d.ts"
30
40
  }
31
41
  },
32
42
  "files": [
33
- "dist/**"
43
+ "dist"
34
44
  ],
35
45
  "homepage": "https://github.com/ragaeeb/shamela",
36
46
  "keywords": [
@@ -52,13 +62,13 @@
52
62
  "demo": "next dev demo",
53
63
  "demo:build": "next build demo",
54
64
  "demo:start": "next start demo",
65
+ "e2e": "RUN_E2E=true bun test e2e",
55
66
  "format": "biome format --write .",
56
- "lint": "biome check .",
57
- "test": "bun test src --coverage --coverage-reporter=lcov"
67
+ "lint": "biome check ."
58
68
  },
59
69
  "sideEffects": false,
60
70
  "source": "src/index.ts",
61
71
  "type": "module",
62
72
  "types": "dist/index.d.ts",
63
- "version": "1.3.2"
73
+ "version": "1.3.4"
64
74
  }