@quranjs/api 2.2.0 → 3.1.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/dist/index.d.ts CHANGED
@@ -1,256 +1,7 @@
1
- /**
2
- * Maps chapter number to verse count
3
- */
4
- declare const versesMapping: {
5
- readonly 1: 7;
6
- readonly 2: 286;
7
- readonly 3: 200;
8
- readonly 4: 176;
9
- readonly 5: 120;
10
- readonly 6: 165;
11
- readonly 7: 206;
12
- readonly 8: 75;
13
- readonly 9: 129;
14
- readonly 10: 109;
15
- readonly 11: 123;
16
- readonly 12: 111;
17
- readonly 13: 43;
18
- readonly 14: 52;
19
- readonly 15: 99;
20
- readonly 16: 128;
21
- readonly 17: 111;
22
- readonly 18: 110;
23
- readonly 19: 98;
24
- readonly 20: 135;
25
- readonly 21: 112;
26
- readonly 22: 78;
27
- readonly 23: 118;
28
- readonly 24: 64;
29
- readonly 25: 77;
30
- readonly 26: 227;
31
- readonly 27: 93;
32
- readonly 28: 88;
33
- readonly 29: 69;
34
- readonly 30: 60;
35
- readonly 31: 34;
36
- readonly 32: 30;
37
- readonly 33: 73;
38
- readonly 34: 54;
39
- readonly 35: 45;
40
- readonly 36: 83;
41
- readonly 37: 182;
42
- readonly 38: 88;
43
- readonly 39: 75;
44
- readonly 40: 85;
45
- readonly 41: 54;
46
- readonly 42: 53;
47
- readonly 43: 89;
48
- readonly 44: 59;
49
- readonly 45: 37;
50
- readonly 46: 35;
51
- readonly 47: 38;
52
- readonly 48: 29;
53
- readonly 49: 18;
54
- readonly 50: 45;
55
- readonly 51: 60;
56
- readonly 52: 49;
57
- readonly 53: 62;
58
- readonly 54: 55;
59
- readonly 55: 78;
60
- readonly 56: 96;
61
- readonly 57: 29;
62
- readonly 58: 22;
63
- readonly 59: 24;
64
- readonly 60: 13;
65
- readonly 61: 14;
66
- readonly 62: 11;
67
- readonly 63: 11;
68
- readonly 64: 18;
69
- readonly 65: 12;
70
- readonly 66: 12;
71
- readonly 67: 30;
72
- readonly 68: 52;
73
- readonly 69: 52;
74
- readonly 70: 44;
75
- readonly 71: 28;
76
- readonly 72: 28;
77
- readonly 73: 20;
78
- readonly 74: 56;
79
- readonly 75: 40;
80
- readonly 76: 31;
81
- readonly 77: 50;
82
- readonly 78: 40;
83
- readonly 79: 46;
84
- readonly 80: 42;
85
- readonly 81: 29;
86
- readonly 82: 19;
87
- readonly 83: 36;
88
- readonly 84: 25;
89
- readonly 85: 22;
90
- readonly 86: 17;
91
- readonly 87: 19;
92
- readonly 88: 26;
93
- readonly 89: 30;
94
- readonly 90: 20;
95
- readonly 91: 15;
96
- readonly 92: 21;
97
- readonly 93: 11;
98
- readonly 94: 8;
99
- readonly 95: 8;
100
- readonly 96: 19;
101
- readonly 97: 5;
102
- readonly 98: 8;
103
- readonly 99: 8;
104
- readonly 100: 11;
105
- readonly 101: 11;
106
- readonly 102: 8;
107
- readonly 103: 3;
108
- readonly 104: 9;
109
- readonly 105: 5;
110
- readonly 106: 4;
111
- readonly 107: 7;
112
- readonly 108: 3;
113
- readonly 109: 6;
114
- readonly 110: 3;
115
- readonly 111: 5;
116
- readonly 112: 4;
117
- readonly 113: 5;
118
- readonly 114: 6;
119
- };
120
-
121
- type _NumbersFrom0ToN<Nr extends number> = Nr extends Nr ? number extends Nr ? number : Nr extends 0 ? never : _NumbersFrom0ToNRec<Nr, [], 0> : never;
122
- type _NumbersFrom0ToNRec<Nr extends number, Counter extends unknown[], Accumulator extends number> = Counter["length"] extends Nr ? Accumulator : _NumbersFrom0ToNRec<Nr, [
123
- unknown,
124
- ...Counter
125
- ], Accumulator | Counter["length"]>;
126
- type NumberRange<Start extends number, End extends number> = Exclude<_NumbersFrom0ToN<End>, _NumbersFrom0ToN<Start>>;
127
- type NumberUnionToString<TType> = TType extends number ? `${TType}` : TType;
128
- /**
129
- * Builds a tuple with a length equal to the provided number literal.
130
- * Used for type-level arithmetic.
131
- */
132
- type BuildTuple<TLength extends number, TAccumulator extends unknown[] = []> = TAccumulator["length"] extends TLength ? TAccumulator : BuildTuple<TLength, [...TAccumulator, unknown]>;
133
- /**
134
- * Increments a numeric literal type by 1.
135
- */
136
- type Increment<TNumber extends number> = [
137
- ...BuildTuple<TNumber>,
138
- unknown
139
- ]["length"];
140
-
141
- /**
142
- * A `VerseKey` is a string literal in the form `${chapter}:${verse}` where:
143
- * - `chapter` is a valid chapter id from `versesMapping`
144
- * - `verse` is within the range 1..(verseCount for that chapter)
145
- */
146
- type VerseKey = {
147
- [TChapter in keyof typeof versesMapping]: `${TChapter}:${NumberRange<1, Increment<(typeof versesMapping)[TChapter]>>}`;
148
- }[keyof typeof versesMapping];
149
-
150
- type ChapterId = keyof typeof versesMapping | NumberUnionToString<keyof typeof versesMapping>;
151
-
152
- type _HizbNumber = NumberRange<1, 61>;
153
- type HizbNumber = _HizbNumber | NumberUnionToString<_HizbNumber>;
154
-
155
- type _JuzNumber = NumberRange<1, 31>;
156
- type JuzNumber = _JuzNumber | NumberUnionToString<_JuzNumber>;
157
-
158
- type _PageNumber = NumberRange<1, 605>;
159
- type PageNumber = _PageNumber | NumberUnionToString<_PageNumber>;
160
-
161
- type _RubNumber = NumberRange<1, 241>;
162
- type RubNumber = _RubNumber | NumberUnionToString<_RubNumber>;
163
-
164
- declare enum SearchNavigationType {
165
- SURAH = "surah",
166
- JUZ = "juz",
167
- HIZB = "hizb",
168
- AYAH = "ayah",
169
- RUB_EL_HIZB = "rub_el_hizb",
170
- SEARCH_PAGE = "search_page",
171
- PAGE = "page",
172
- RANGE = "range",
173
- QURAN_RANGE = "quran_range"
174
- }
175
- interface SearchResult {
176
- resultType: SearchNavigationType;
177
- key: number | string;
178
- name: string;
179
- arabic?: string;
180
- isArabic?: boolean;
181
- isTransliteration?: boolean;
182
- }
183
-
184
- interface SearchResponse {
185
- pagination: {
186
- currentPage: number;
187
- nextPage: number | null;
188
- perPage: number;
189
- totalPages: number;
190
- totalRecords: number;
191
- };
192
- result?: {
193
- navigation: SearchResult[];
194
- verses: SearchResult[];
195
- };
196
- }
197
-
198
- /**
199
- * Segment structure is [wordFrom, wordTo, timeFrom, timeTo] time is in ms
200
- */
201
- type Segment = [number, number, number, number];
202
-
203
- interface ChapterRecitation {
204
- id: number;
205
- chapterId: number;
206
- fileSize: number;
207
- format: string;
208
- audioUrl: string;
209
- }
210
- interface VerseRecitation {
211
- verseKey: VerseKey;
212
- url: string;
213
- id?: number;
214
- chapterId?: number;
215
- segments?: Segment[];
216
- format?: string;
217
- }
218
-
219
- interface AudioResponse {
220
- url?: string;
221
- duration?: number;
222
- format?: string;
223
- verseKey: string;
224
- segments?: Segment[];
225
- }
226
-
227
- interface TranslatedName {
228
- name: string;
229
- languageName: string;
230
- }
231
-
232
- interface Chapter {
233
- id: number;
234
- versesCount: number;
235
- bismillahPre: boolean;
236
- revelationOrder: number;
237
- revelationPlace: string;
238
- pages: Array<number>;
239
- nameComplex: string;
240
- nameSimple: string;
241
- transliteratedName: string;
242
- nameArabic: string;
243
- translatedName: TranslatedName;
244
- }
245
-
246
- interface ChapterInfo {
247
- id: number;
248
- chapterId: number;
249
- text: string;
250
- shortText: string;
251
- source: string;
252
- languageName?: string;
253
- }
1
+ import { Q as QuranClientConfig } from './index-BZgqOfA4.js';
2
+ export { A as ApiParams, f as ApiService, B as BaseApiParams, c as BinaryString, k as CachedToken, C as CustomFetcher, H as HTTPMethod, L as Language, O as OperationRequest, P as PaginationParams, j as PublicClientConfig, e as QuranFetchClient, a as QuranFont, R as RuntimeMode, S as SearchMode, d as SearchParams, i as ServerClientConfig, g as ServiceEnvironmentConfig, l as TokenResponse, h as TokenStorage, T as TranslationField, U as UserSession, V as VerseField, b as VerseRecitationField, W as WordField } from './index-BZgqOfA4.js';
3
+ import { T as TranslatedName, Q as QuranChapters, a as QuranVerses, b as QuranJuzs, c as QuranAudio, d as QuranResources, e as QuranSearch, C as ChapterId, J as JuzNumber, R as RubNumber, H as HizbNumber, P as PageNumber, V as VerseKey } from './verses-DnPcyHIi.js';
4
+ export { A as AudioResponse, h as Chapter, i as ChapterInfo, y as ChapterInfoResource, f as ChapterRecitation, B as ChapterReciterResource, o as CharType, p as Juz, L as LanguageResource, N as NormalizedVerseRecitation, q as Pagination, s as RecitationInfoResource, r as RecitationResource, x as RecitationStylesResource, D as SearchNavigationType, S as SearchResponse, E as SearchResult, j as Segment, k as Tafsir, w as TafsirInfoResource, v as TafsirResource, l as Translation, u as TranslationInfoResource, t as TranslationResource, m as Transliteration, n as Verse, z as VerseMediaResource, g as VerseRecitation, W as Word } from './verses-DnPcyHIi.js';
254
5
 
255
6
  interface Footnote {
256
7
  id: number | string;
@@ -281,21 +32,6 @@ interface Reciter {
281
32
  };
282
33
  }
283
34
 
284
- interface Tafsir {
285
- id?: number;
286
- resourceId?: number;
287
- text?: string;
288
- resourceName?: string;
289
- languageName?: string;
290
- slug?: string;
291
- languageId?: number;
292
- groupVerseKeyFrom?: string;
293
- groupVerseKeyTo?: string;
294
- groupTafsirId?: number;
295
- startVerseId?: number;
296
- endVerseId?: number;
297
- }
298
-
299
35
  interface TafsirInfo {
300
36
  id?: number;
301
37
  name?: string;
@@ -305,666 +41,11 @@ interface TafsirInfo {
305
41
  translatedName: TranslatedName;
306
42
  }
307
43
 
308
- interface Translation {
309
- id?: number;
310
- text: string;
311
- resourceId: number;
312
- resourceName?: string;
313
- verseId?: number;
314
- languageId?: number;
315
- languageName?: string;
316
- verseKey?: VerseKey;
317
- chapterId?: number;
318
- verseNumber?: number;
319
- juzNumber?: number;
320
- hizbNumber?: number;
321
- rubNumber?: number;
322
- pageNumber?: number;
323
- }
324
-
325
- interface Transliteration {
326
- languageName?: string;
327
- text?: string;
328
- }
329
-
330
- declare enum CharType {
331
- Word = "word",
332
- End = "end",
333
- Pause = "pause",
334
- Sajdah = "sajdah",
335
- RubElHizb = "rub-el-hizb"
336
- }
337
- interface Word {
338
- id?: number;
339
- position: number;
340
- audioUrl: string;
341
- charTypeName: CharType;
342
- codeV1?: string;
343
- codeV2?: string;
344
- pageNumber?: number;
345
- lineNumber?: number;
346
- text?: string;
347
- textUthmani?: string;
348
- textIndopak?: string;
349
- textImlaei?: string;
350
- translation: Translation;
351
- transliteration: Transliteration;
352
- location?: string;
353
- verseKey?: VerseKey;
354
- }
355
-
356
- interface Verse {
357
- id: number;
358
- verseNumber: number;
359
- verseKey: VerseKey;
360
- chapterId?: number | string;
361
- pageNumber: number;
362
- juzNumber: number;
363
- hizbNumber: number;
364
- rubElHizbNumber: number;
365
- words?: Word[];
366
- textUthmani?: string;
367
- textUthmaniSimple?: string;
368
- textUthmaniTajweed?: string;
369
- textImlaei?: string;
370
- textImlaeiSimple?: string;
371
- textIndopak?: string;
372
- textIndopakNastaleeq?: string;
373
- sajdahNumber: null;
374
- imageUrl?: string;
375
- imageWidth?: number;
376
- v1Page?: number;
377
- v2Page?: number;
378
- codeV1?: string;
379
- codeV2?: string;
380
- translations?: Translation[];
381
- tafsirs?: Tafsir[];
382
- audio?: AudioResponse;
383
- }
384
-
385
- interface Juz {
386
- id: number;
387
- juzNumber: number;
388
- verseMapping: Record<number, string>;
389
- firstVerseId: number;
390
- lastVerseId: number;
391
- versesCount: number;
392
- }
393
-
394
- interface Pagination {
395
- perPage: number;
396
- currentPage: number;
397
- nextPage: number;
398
- totalPages: number;
399
- totalRecords: number;
400
- }
401
-
402
- interface RecitationResource {
403
- id?: number;
404
- reciterName?: string;
405
- style?: string;
406
- translatedName?: TranslatedName;
407
- }
408
- interface RecitationInfoResource {
409
- id?: number;
410
- info?: string;
411
- }
412
- interface TranslationResource {
413
- id?: number;
414
- name?: string;
415
- authorName?: string;
416
- slug?: string;
417
- languageName?: string;
418
- translatedName?: TranslatedName;
419
- }
420
- interface TranslationInfoResource {
421
- id?: number;
422
- info?: string;
423
- }
424
- interface TafsirResource {
425
- id?: number;
426
- name?: string;
427
- authorName?: string;
428
- slug?: string;
429
- languageName?: string;
430
- translatedName?: TranslatedName;
431
- }
432
- interface TafsirInfoResource {
433
- id?: number;
434
- info?: string;
435
- }
436
- interface RecitationStylesResource {
437
- mujawwad: string;
438
- murattal: string;
439
- muallim: string;
440
- }
441
- interface LanguageResource {
442
- id?: number;
443
- name?: string;
444
- nativeName?: string;
445
- isoCode?: string;
446
- direction?: string;
447
- translatedNames?: TranslatedName[];
448
- }
449
- interface ChapterInfoResource {
450
- id?: number;
451
- name?: string;
452
- authorName?: string;
453
- slug?: string;
454
- languageName?: string;
455
- translatedName?: TranslatedName;
456
- }
457
- interface VerseMediaResource {
458
- id?: number;
459
- name?: string;
460
- authorName?: string;
461
- languageName?: string;
462
- }
463
- interface ChapterReciterResource {
464
- id: number;
465
- name: string;
466
- arabicName?: string;
467
- relativePath?: string;
468
- format?: string;
469
- filesSize?: number;
470
- }
471
-
472
- type ApiParams = Record<string, string | number | boolean | unknown[] | undefined | Record<string, boolean>>;
473
- /**
474
- * Base parameters that are common across most API endpoints
475
- */
476
- interface BaseApiParams extends ApiParams {
477
- /** Language for the response */
478
- language?: Language;
479
- }
480
- /**
481
- * Pagination parameters
482
- */
483
- interface PaginationParams extends ApiParams {
484
- /** Page number for pagination */
485
- page?: number;
486
- /** Number of items per page */
487
- perPage?: number;
488
- }
489
- type BinaryString = "0" | "1";
490
- declare enum SearchMode {
491
- Advanced = "advanced",
492
- Quick = "quick"
493
- }
494
- /**
495
- * Search parameters
496
- */
497
- interface SearchParams extends BaseApiParams {
498
- /** Search mode */
499
- mode: SearchMode;
500
- /** Search query */
501
- query: string;
502
- /** Filter translations */
503
- filterTranslations?: string | string[];
504
- /** For advanced search, limit to exact matches */
505
- exactMatchesOnly?: BinaryString;
506
- /** Include text in the response */
507
- getText?: BinaryString;
508
- /** Include highlighted text */
509
- highlight?: BinaryString;
510
- /** Quick search navigational results count */
511
- navigationalResultsNumber?: number;
512
- /** Quick search verse results count */
513
- versesResultsNumber?: number;
514
- /** Comma-separated list of indexes */
515
- indexes?: string | string[];
516
- /** Page number for pagination */
517
- page?: number;
518
- /** Number of results to return */
519
- size?: number;
520
- /** Translation IDs to use for language detection */
521
- translationIds?: string | number | Array<string | number>;
522
- /** Quran fields to include in verse filters */
523
- fields?: Partial<Record<VerseField, boolean>>;
524
- /** Translation fields to include in verse filters */
525
- translationFields?: Partial<Record<TranslationField, boolean>>;
526
- /** Word fields to include in verse filters */
527
- wordFields?: Partial<Record<WordField, boolean>>;
528
- /** Include word data in verse filters */
529
- words?: boolean;
530
- }
531
-
532
- /**
533
- * Custom fetcher function type that matches the native fetch API
534
- */
535
- type CustomFetcher = typeof fetch;
536
- interface QuranClientConfig {
537
- /** Client ID for authentication */
538
- clientId: string;
539
- /** Client secret for authentication */
540
- clientSecret: string;
541
- /** Base URL for content APIs */
542
- contentBaseUrl?: string;
543
- /** Base URL for authentication */
544
- authBaseUrl?: string;
545
- /** Custom fetch implementation */
546
- fetch?: CustomFetcher;
547
- /** Default parameters for all API calls */
548
- defaults?: Partial<BaseApiParams>;
549
- }
550
- interface CachedToken {
551
- value: string;
552
- expiresAt: number;
553
- }
554
- interface TokenResponse {
555
- access_token: string;
556
- expires_in: number;
557
- }
558
-
559
- declare enum Language {
560
- ARABIC = "ar",
561
- ENGLISH = "en",
562
- URDU = "ur",
563
- BENGALI = "bn",
564
- TURKISH = "tr",
565
- SPANISH = "es",
566
- GERMAN = "de",
567
- BOSNIAN = "bs",
568
- RUSSIAN = "ru",
569
- ALBANIAN_AL = "al",
570
- FRENCH = "fr",
571
- DUTCH = "nl",
572
- TAMIL = "ta",
573
- TAJIK = "tg",
574
- INDONESIAN = "id",
575
- UZBEK = "uz",
576
- VIETNAMESE = "vi",
577
- CHINESE = "zh",
578
- ITALIAN = "it",
579
- JAPANESE = "ja",
580
- MALAYALAM = "ml",
581
- AMHARIC = "am",
582
- KAZAKH = "kk",
583
- PORTUGUESE = "pt",
584
- TAGALOG = "tl",
585
- THAI = "th",
586
- KOREAN = "ko",
587
- HINDI = "hi",
588
- KURDISH = "ku",
589
- HAUSA = "ha",
590
- AZERI = "az",
591
- SWAHILI = "sw",
592
- PERSIAN = "fa",
593
- SERBIAN = "sr",
594
- MARANAO = "mrn",
595
- AMAZIGH = "zgh",
596
- ASSAMESE = "as",
597
- BULGARIAN = "bg",
598
- CHECHEN = "ce",
599
- CZECH = "cs",
600
- DIVEHI = "dv",
601
- FINNISH = "fi",
602
- GUJAARATI = "gu",
603
- HEBREW = "he",
604
- GEORGIAN = "ka",
605
- CENTRAL_KHMER = "km",
606
- GANDA = "lg",
607
- MARATHI = "mr",
608
- YORUBA = "yo",
609
- MALAY = "ms",
610
- NEPALI = "ne",
611
- SWEDISH = "sv",
612
- TELUGU = "te",
613
- TATAR = "tt",
614
- UYGHUR = "ug",
615
- UKRAINIAN = "uk",
616
- NORWEGIAN = "no",
617
- OROMO = "om",
618
- POLISH = "pl",
619
- PASHTO = "ps",
620
- ROMANIAN = "ro",
621
- SINDHI = "sd",
622
- NORTHERN_SAMI = "se",
623
- SINHALA = "si",
624
- SOMALI = "so",
625
- ALBANIAN_SQ = "sq"
626
- }
627
- declare enum QuranFont {
628
- MadaniV1 = "code_v1",
629
- MadaniV2 = "code_v2",
630
- Uthmani = "text_uthmani"
631
- }
632
- type VerseField = "chapterId" | "textUthmani" | "textUthmaniSimple" | "textImlaei" | "textImlaeiSimple" | "textIndopak" | "textIndopakNastaleeq" | "textUthmaniTajweed" | "imageUrl" | "imageWidth" | "codeV1" | "codeV2" | "v1Page" | "v2Page";
633
- type WordField = "v1Page" | "v2Page" | "textUthmani" | "textImlaei" | "textIndopak" | "verseKey" | "location" | "codeV1" | "codeV2";
634
- type TranslationField = "resourceName" | "verseId" | "languageId" | "languageName" | "verseKey" | "chapterId" | "verseNumber" | "juzNumber" | "hizbNumber" | "rubNumber" | "pageNumber";
635
- type VerseRecitationField = "id" | "chapterId" | "segments" | "format";
636
-
637
- type Config = Required<Pick<QuranClientConfig, "contentBaseUrl" | "authBaseUrl">> & Omit<QuranClientConfig, "contentBaseUrl" | "authBaseUrl">;
638
- /**
639
- * Handles HTTP requests with authentication for the Quran API
640
- */
641
- declare class QuranFetcher {
642
- private config;
643
- private cachedToken;
644
- constructor(config: Config);
645
- /**
646
- * Update the configuration
647
- */
648
- updateConfig(config: Config): void;
649
- getFetch(): CustomFetcher;
650
- private doFetch;
651
- /**
652
- * Get access token for API authentication
653
- */
654
- private getAccessToken;
655
- /**
656
- * Clear cached token (useful for testing or forcing re-authentication)
657
- */
658
- clearCachedToken(): void;
659
- /**
660
- * Make URL with base URL and query parameters
661
- */
662
- private makeUrl;
663
- /**
664
- * Make authenticated HTTP request
665
- */
666
- fetch<T extends object>(url: string, params?: ApiParams): Promise<T>;
667
- }
668
-
669
- type GetChapterRecitationOptions = BaseApiParams;
670
- type GetVerseRecitationOptions = BaseApiParams & {
671
- fields?: Partial<Record<VerseRecitationField, boolean>>;
672
- };
673
- /**
674
- * Audio API methods
675
- */
676
- declare class QuranAudio {
677
- private fetcher;
678
- constructor(fetcher: QuranFetcher);
679
- /**
680
- * Get all chapter recitations for specific reciter
681
- * @param {string} reciterId
682
- * @param {GetChapterRecitationOptions} options
683
- * @example
684
- * client.audio.findAllChapterRecitations('2')
685
- */
686
- findAllChapterRecitations(reciterId: string, options?: GetChapterRecitationOptions): Promise<ChapterRecitation[]>;
687
- /**
688
- * Get a specific chapter recitation by reciter and chapter
689
- * @param {string} reciterId
690
- * @param {ChapterId} chapterId
691
- * @param {GetChapterRecitationOptions} options
692
- * @example
693
- * client.audio.findChapterRecitationById('2', '1')
694
- */
695
- findChapterRecitationById(reciterId: string, chapterId: ChapterId, options?: GetChapterRecitationOptions): Promise<ChapterRecitation>;
696
- /**
697
- * Get verse recitations by chapter
698
- * @param {ChapterId} chapterId
699
- * @param {string} recitationId
700
- * @param {GetVerseRecitationOptions} options
701
- * @example
702
- * client.audio.findVerseRecitationsByChapter('1', '2')
703
- */
704
- findVerseRecitationsByChapter(chapterId: ChapterId, recitationId: string, options?: GetVerseRecitationOptions): Promise<{
705
- audioFiles: VerseRecitation[];
706
- pagination: Pagination;
707
- }>;
708
- /**
709
- * Get verse recitations by verse key
710
- * @param {VerseKey} key
711
- * @param {string} recitationId
712
- * @param {GetVerseRecitationOptions} options
713
- * @example
714
- * client.audio.findVerseRecitationsByKey('1:1', '2')
715
- */
716
- findVerseRecitationsByKey(key: VerseKey, recitationId: string, options?: GetVerseRecitationOptions): Promise<{
717
- audioFiles: VerseRecitation[];
718
- pagination: Pagination;
719
- }>;
720
- }
721
-
722
- type GetChapterOptions = BaseApiParams;
723
- /**
724
- * Chapters API methods
725
- */
726
- declare class QuranChapters {
727
- private fetcher;
728
- constructor(fetcher: QuranFetcher);
729
- /**
730
- * Get all chapters.
731
- * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/list-chapters
732
- * @param {GetChapterOptions} options
733
- * @example
734
- * client.chapters.findAll()
735
- */
736
- findAll(options?: GetChapterOptions): Promise<Chapter[]>;
737
- /**
738
- * Get chapter by id.
739
- * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/get-chapter
740
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
741
- * @param {GetChapterOptions} options
742
- * @example
743
- * client.chapters.findById('1')
744
- * client.chapters.findById('114')
745
- */
746
- findById(id: ChapterId, options?: GetChapterOptions): Promise<Chapter>;
747
- /**
748
- * Get chapter info by id.
749
- * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/get-chapter-info
750
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
751
- * @param {GetChapterOptions} options
752
- * @example
753
- * client.chapters.findInfoById('1')
754
- * client.chapters.findInfoById('114')
755
- */
756
- findInfoById(id: ChapterId, options?: GetChapterOptions): Promise<ChapterInfo>;
757
- }
758
-
759
- /**
760
- * Juzs API methods
761
- */
762
- declare class QuranJuzs {
763
- private fetcher;
764
- constructor(fetcher: QuranFetcher);
765
- /**
766
- * Get All Juzs
767
- * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/juzs
768
- * @example
769
- * client.juzs.findAll()
770
- */
771
- findAll(): Promise<Juz[]>;
772
- }
773
-
774
- type GetResourceOptions = BaseApiParams;
775
- /**
776
- * Resources API methods
777
- */
778
- declare class QuranResources {
779
- private fetcher;
780
- constructor(fetcher: QuranFetcher);
781
- /**
782
- * Get all recitations.
783
- * @param {GetResourceOptions} options
784
- * @example
785
- * client.resources.findAllRecitations()
786
- */
787
- findAllRecitations(options?: GetResourceOptions): Promise<RecitationResource[]>;
788
- /**
789
- * Get all translations.
790
- * @param {GetResourceOptions} options
791
- * @example
792
- * client.resources.findAllTranslations()
793
- */
794
- findAllTranslations(options?: GetResourceOptions): Promise<TranslationResource[]>;
795
- /**
796
- * Get all tafsirs.
797
- * @param {GetResourceOptions} options
798
- * @example
799
- * client.resources.findAllTafsirs()
800
- */
801
- findAllTafsirs(options?: GetResourceOptions): Promise<TafsirResource[]>;
802
- /**
803
- * Get all languages.
804
- * @param {GetResourceOptions} options
805
- * @example
806
- * client.resources.findAllLanguages()
807
- */
808
- findAllLanguages(options?: GetResourceOptions): Promise<LanguageResource[]>;
809
- /**
810
- * Get recitation info by id.
811
- * @param {string} id recitation id
812
- * @param {GetResourceOptions} options
813
- * @example
814
- * client.resources.findRecitationInfo('1')
815
- */
816
- findRecitationInfo(id: string, options?: GetResourceOptions): Promise<RecitationInfoResource>;
817
- /**
818
- * Get translation info by id.
819
- * @param {string} id translation id
820
- * @param {GetResourceOptions} options
821
- * @example
822
- * client.resources.findTranslationInfo('131')
823
- */
824
- findTranslationInfo(id: string, options?: GetResourceOptions): Promise<TranslationInfoResource>;
825
- /**
826
- * Get tafsir info by id.
827
- * @param {string} id tafsir id
828
- * @param {GetResourceOptions} options
829
- * @example
830
- * client.resources.findTafsirInfo('171')
831
- */
832
- findTafsirInfo(id: string, options?: GetResourceOptions): Promise<TafsirInfoResource>;
833
- /**
834
- * Get all chapter infos.
835
- * @param {GetResourceOptions} options
836
- * @example
837
- * client.resources.findAllChapterInfos()
838
- */
839
- findAllChapterInfos(options?: GetResourceOptions): Promise<ChapterInfoResource[]>;
840
- /**
841
- * Get all chapter reciters.
842
- * @param {GetResourceOptions} options
843
- * @example
844
- * client.resources.findAllChapterReciters()
845
- */
846
- findAllChapterReciters(options?: GetResourceOptions): Promise<ChapterReciterResource[]>;
847
- /**
848
- * Get all recitation styles.
849
- * @param {GetResourceOptions} options
850
- * @example
851
- * client.resources.findAllRecitationStyles()
852
- */
853
- findAllRecitationStyles(options?: GetResourceOptions): Promise<RecitationStylesResource>;
854
- /**
855
- * Get verse media.
856
- * @param {GetResourceOptions} options
857
- * @example
858
- * client.resources.findVerseMedia()
859
- */
860
- findVerseMedia(options?: GetResourceOptions): Promise<VerseMediaResource>;
861
- }
862
-
863
- type SearchOptions = Omit<SearchParams, "query">;
864
- /**
865
- * Search API methods
866
- */
867
- declare class QuranSearch {
868
- private fetcher;
869
- constructor(fetcher: QuranFetcher);
870
- /**
871
- * Search
872
- * @description /v1/search
873
- * @param {string} query search query
874
- * @param {SearchOptions} options
875
- * @example
876
- * client.search.search('نور', { mode: SearchMode.Quick })
877
- * client.search.search('نور', { mode: SearchMode.Advanced, exactMatchesOnly: '1' })
878
- * client.search.search('نور', { mode: SearchMode.Quick, size: 10 })
879
- * client.search.search('نور', { mode: SearchMode.Quick, page: 2 })
880
- */
881
- search(query: string, options: SearchOptions): Promise<SearchResponse>;
882
- }
883
-
884
- type GetVerseOptions = BaseApiParams & PaginationParams & {
885
- reciter?: string | number;
886
- words?: boolean;
887
- translations?: string[] | number[];
888
- tafsirs?: string[] | number[];
889
- wordFields?: Partial<Record<WordField, boolean>>;
890
- translationFields?: Partial<Record<TranslationField, boolean>>;
891
- fields?: Partial<Record<VerseField, boolean>>;
892
- };
893
- /**
894
- * Verses API methods
895
- */
896
- declare class QuranVerses {
897
- private fetcher;
898
- constructor(fetcher: QuranFetcher);
899
- /**
900
- * Get a specific verse by its key.
901
- * @param {VerseKey} key verse key in format "chapter:verse" (e.g., "1:1")
902
- * @param {GetVerseOptions} options
903
- * @example
904
- * client.verses.findByKey('1:1')
905
- * client.verses.findByKey('2:255')
906
- */
907
- findByKey(key: VerseKey, options?: GetVerseOptions): Promise<Verse>;
908
- /**
909
- * Get verses by range.
910
- * @param {VerseKey} from start verse key (e.g., "1:1")
911
- * @param {VerseKey} to end verse key (e.g., "1:7")
912
- * @param {GetVerseOptions} options
913
- * @example
914
- * client.verses.findByRange('1:1', '1:7')
915
- */
916
- findByRange(from: VerseKey, to: VerseKey, options?: GetVerseOptions): Promise<Verse[]>;
917
- /**
918
- * Get verses by chapter.
919
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
920
- * @param {GetVerseOptions} options
921
- * @example
922
- * client.verses.findByChapter('1')
923
- */
924
- findByChapter(id: ChapterId, options?: GetVerseOptions): Promise<Verse[]>;
925
- /**
926
- * Get verses by page number.
927
- * @param {PageNumber} page page number
928
- * @param {GetVerseOptions} options
929
- * @example
930
- * client.verses.findByPage('1')
931
- */
932
- findByPage(page: PageNumber, options?: GetVerseOptions): Promise<Verse[]>;
933
- /**
934
- * Get verses by juz number.
935
- * @param {JuzNumber} juz juz number
936
- * @param {GetVerseOptions} options
937
- * @example
938
- * client.verses.findByJuz('1')
939
- */
940
- findByJuz(juz: JuzNumber, options?: GetVerseOptions): Promise<Verse[]>;
941
- /**
942
- * Get verses by hizb number.
943
- * @param {HizbNumber} hizb hizb number
944
- * @param {GetVerseOptions} options
945
- * @example
946
- * client.verses.findByHizb('1')
947
- */
948
- findByHizb(hizb: HizbNumber, options?: GetVerseOptions): Promise<Verse[]>;
949
- /**
950
- * Get verses by rub number.
951
- * @param {RubNumber} rub rub number
952
- * @param {GetVerseOptions} options
953
- * @example
954
- * client.verses.findByRub('1')
955
- */
956
- findByRub(rub: RubNumber, options?: GetVerseOptions): Promise<Verse[]>;
957
- /**
958
- * Get a random verse.
959
- * @param {GetVerseOptions} options
960
- * @example
961
- * client.verses.findRandom()
962
- */
963
- findRandom(options?: GetVerseOptions): Promise<Verse>;
964
- }
965
-
966
44
  /**
967
- * Main Quran API client
45
+ * Legacy universal Quran API client.
46
+ *
47
+ * Prefer `createPublicClient` from `@quranjs/api/public` or
48
+ * `createServerClient` from `@quranjs/api/server` for new applications.
968
49
  */
969
50
  declare class QuranClient {
970
51
  private config;
@@ -976,17 +57,8 @@ declare class QuranClient {
976
57
  readonly resources: QuranResources;
977
58
  readonly search: QuranSearch;
978
59
  constructor(config: QuranClientConfig);
979
- /**
980
- * Get the current configuration
981
- */
982
60
  getConfig(): QuranClientConfig;
983
- /**
984
- * Update the configuration
985
- */
986
61
  updateConfig(newConfig: Partial<QuranClientConfig>): void;
987
- /**
988
- * Clear cached authentication token
989
- */
990
62
  clearCachedToken(): void;
991
63
  }
992
64
 
@@ -1062,4 +134,4 @@ declare const isValidQuranPage: (page: string | number) => page is PageNumber;
1062
134
  */
1063
135
  declare const isValidVerseKey: (key: string) => key is VerseKey;
1064
136
 
1065
- export { type ApiParams, type AudioResponse, type BaseApiParams, type BinaryString, type CachedToken, type Chapter, type ChapterId, type ChapterInfo, type ChapterInfoResource, type ChapterRecitation, type ChapterReciterResource, CharType, type CustomFetcher, type Footnote, type HizbNumber, type Juz, type JuzNumber, Language, type LanguageResource, type PageNumber, type Pagination, type PaginationParams, QuranClient, type QuranClientConfig, QuranFont, type RecitationInfoResource, type RecitationResource, type RecitationStylesResource, type Reciter, type RubNumber, SearchMode, SearchNavigationType, type SearchParams, type SearchResponse, type SearchResult, type Segment, type Tafsir, type TafsirInfo, type TafsirInfoResource, type TafsirResource, type TokenResponse, type TranslatedName, type Translation, type TranslationField, type TranslationInfoResource, type TranslationResource, type Transliteration, type Verse, type VerseField, type VerseKey, type VerseMediaResource, type VerseRecitation, type VerseRecitationField, type Word, type WordField, isValidChapterId, isValidHizb, isValidJuz, isValidQuranPage, isValidRub, isValidVerseKey };
137
+ export { ChapterId, type Footnote, HizbNumber, JuzNumber, PageNumber, QuranClient, QuranClientConfig, type Reciter, RubNumber, type TafsirInfo, TranslatedName, VerseKey, isValidChapterId, isValidHizb, isValidJuz, isValidQuranPage, isValidRub, isValidVerseKey };