@quranjs/api 1.7.1 → 1.7.3

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.
Files changed (56) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +14 -0
  3. package/dist/index.min.js +13 -0
  4. package/dist/index.min.js.map +1 -0
  5. package/dist/index.min.mjs +6 -0
  6. package/dist/index.min.mjs.map +1 -0
  7. package/dist/index.umd.js +886 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/index.umd.min.js +53 -0
  10. package/dist/index.umd.min.js.map +1 -0
  11. package/package.json +25 -9
  12. package/dist/index.js +0 -13
  13. package/dist/index.js.map +0 -1
  14. package/dist/index.mjs +0 -6
  15. package/dist/index.mjs.map +0 -1
  16. package/src/index.ts +0 -2
  17. package/src/sdk/index.ts +0 -9
  18. package/src/sdk/utils.ts +0 -239
  19. package/src/sdk/v4/_fetcher.ts +0 -83
  20. package/src/sdk/v4/audio.ts +0 -246
  21. package/src/sdk/v4/chapters.ts +0 -80
  22. package/src/sdk/v4/index.ts +0 -17
  23. package/src/sdk/v4/juzs.ts +0 -22
  24. package/src/sdk/v4/resources.ts +0 -220
  25. package/src/sdk/v4/search.ts +0 -41
  26. package/src/sdk/v4/verses.ts +0 -234
  27. package/src/types/BaseApiOptions.ts +0 -6
  28. package/src/types/ChapterId.ts +0 -4
  29. package/src/types/FetchFn.ts +0 -1
  30. package/src/types/HizbNumber.ts +0 -4
  31. package/src/types/JuzNumber.ts +0 -4
  32. package/src/types/PageNumber.ts +0 -4
  33. package/src/types/RubNumber.ts +0 -4
  34. package/src/types/VerseKey.ts +0 -117
  35. package/src/types/api/ApiResponses.ts +0 -19
  36. package/src/types/api/AudioData.ts +0 -20
  37. package/src/types/api/AudioResponse.ts +0 -9
  38. package/src/types/api/Chapter.ts +0 -15
  39. package/src/types/api/ChapterInfo.ts +0 -8
  40. package/src/types/api/Footnote.ts +0 -6
  41. package/src/types/api/Juz.ts +0 -8
  42. package/src/types/api/Pagination.ts +0 -7
  43. package/src/types/api/Reciter.ts +0 -21
  44. package/src/types/api/Resources.ts +0 -81
  45. package/src/types/api/Segment.ts +0 -4
  46. package/src/types/api/Tafsir.ts +0 -7
  47. package/src/types/api/TafsirInfo.ts +0 -10
  48. package/src/types/api/TranslatedName.ts +0 -4
  49. package/src/types/api/Translation.ts +0 -21
  50. package/src/types/api/Transliteration.ts +0 -4
  51. package/src/types/api/Verse.ts +0 -35
  52. package/src/types/api/Word.ts +0 -30
  53. package/src/types/api/index.ts +0 -18
  54. package/src/types/index.ts +0 -136
  55. package/src/types/utils.ts +0 -24
  56. package/src/utils/misc.ts +0 -3
@@ -1,246 +0,0 @@
1
- import {
2
- ChapterRecitation,
3
- VerseRecitation,
4
- ChapterId,
5
- HizbNumber,
6
- JuzNumber,
7
- Language,
8
- PageNumber,
9
- Pagination,
10
- RubNumber,
11
- VerseKey,
12
- VerseRecitationField,
13
- } from '../../types';
14
- import Utils from '../utils';
15
- import { fetcher, mergeApiOptions } from './_fetcher';
16
- import { BaseApiOptions } from '../../types/BaseApiOptions';
17
-
18
- type GetChapterRecitationOptions = Partial<BaseApiOptions>;
19
-
20
- const defaultChapterRecitationsOptions: GetChapterRecitationOptions = {
21
- language: Language.ARABIC,
22
- };
23
-
24
- type GetVerseRecitationOptions = Partial<
25
- BaseApiOptions & {
26
- fields: Partial<Record<VerseRecitationField, boolean>>;
27
- }
28
- >;
29
-
30
- const defaultVerseRecitationsOptions: GetVerseRecitationOptions = {
31
- language: Language.ARABIC,
32
- };
33
-
34
- /**
35
- * Get all chapter recitations for specific reciter
36
- * @description https://quran.api-docs.io/v4/audio-recitations/list-of-all-surah-audio-files-for-specific-reciter
37
- * @param {string} reciterId
38
- * @param {GetChapterRecitationOptions} options
39
- * @example
40
- * quran.v4.audio.findAllChapterRecitations('2')
41
- */
42
- const findAllChapterRecitations = async (
43
- reciterId: string,
44
- options?: GetChapterRecitationOptions
45
- ) => {
46
- const params = mergeApiOptions(options, defaultChapterRecitationsOptions);
47
- const { audioFiles } = await fetcher<{ audioFiles: ChapterRecitation[] }>(
48
- `/chapter_recitations/${reciterId}`,
49
- params,
50
- options?.fetchFn
51
- );
52
- return audioFiles;
53
- };
54
-
55
- /**
56
- * Get chapter recitation for specific reciter and a specific chapter
57
- * @description https://quran.api-docs.io/v4/audio-recitations/get-single-surah-audio-for-specific-reciter
58
- * @param {ChapterId} chapterId
59
- * @param {string} reciterId
60
- * @param {GetChapterRecitationOptions} options
61
- * @example
62
- * quran.v4.audio.findChapterRecitationById('1', '2') // first chapter recitation for reciter 2
63
- */
64
- const findChapterRecitationById = async (
65
- chapterId: ChapterId,
66
- reciterId: string,
67
- options?: GetChapterRecitationOptions
68
- ) => {
69
- if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id');
70
-
71
- const params = mergeApiOptions(options, defaultChapterRecitationsOptions);
72
- const { audioFile } = await fetcher<{ audioFile: ChapterRecitation }>(
73
- `/chapter_recitations/${reciterId}/${chapterId}`,
74
- params,
75
- options?.fetchFn
76
- );
77
-
78
- return audioFile;
79
- };
80
-
81
- /**
82
- * Get all verse audio files for a specific reciter and a specific chapter
83
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-surah
84
- * @param {ChapterId} chapterId
85
- * @param {string} recitationId
86
- * @param {GetVerseRecitationOptions} options
87
- * @example
88
- * quran.v4.audio.findVerseRecitationsByChapter('1', '2')
89
- */
90
- const findVerseRecitationsByChapter = async (
91
- chapterId: ChapterId,
92
- recitationId: string,
93
- options?: GetVerseRecitationOptions
94
- ) => {
95
- if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id');
96
-
97
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
98
- const data = await fetcher<{
99
- audioFiles: VerseRecitation[];
100
- pagination: Pagination;
101
- }>(
102
- `/recitations/${recitationId}/by_chapter/${chapterId}`,
103
- params,
104
- options?.fetchFn
105
- );
106
-
107
- return data;
108
- };
109
-
110
- /**
111
- * Get all verse audio files for a specific reciter and a specific juz
112
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-juz
113
- * @param {JuzNumber} juz
114
- * @param {string} recitationId
115
- * @param {GetRecitationsOptions} options
116
- * @example
117
- * quran.v4.audio.findVerseRecitationsByJuz('1', '2')
118
- */
119
- const findVerseRecitationsByJuz = async (
120
- juz: JuzNumber,
121
- recitationId: string,
122
- options?: GetVerseRecitationOptions
123
- ) => {
124
- if (!Utils.isValidJuz(juz)) throw new Error('Invalid juz');
125
-
126
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
127
- const data = await fetcher<{
128
- audioFiles: VerseRecitation[];
129
- pagination: Pagination;
130
- }>(`/recitations/${recitationId}/by_juz/${juz}`, params, options?.fetchFn);
131
-
132
- return data;
133
- };
134
-
135
- /**
136
- * Get all verse audio files for a specific reciter and a specific mushaf page
137
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-madani-mushaf-page
138
- * @param {PageNumber} page
139
- * @param {string} recitationId
140
- * @param {GetVerseRecitationOptions} options
141
- * @example
142
- * quran.v4.audio.findVerseRecitationsByPage('1', '2')
143
- */
144
- const findVerseRecitationsByPage = async (
145
- page: PageNumber,
146
- recitationId: string,
147
- options?: GetVerseRecitationOptions
148
- ) => {
149
- if (!Utils.isValidQuranPage(page)) throw new Error('Invalid page');
150
-
151
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
152
- const data = await fetcher<{
153
- audioFiles: VerseRecitation[];
154
- pagination: Pagination;
155
- }>(`/recitations/${recitationId}/by_page/${page}`, params, options?.fetchFn);
156
-
157
- return data;
158
- };
159
-
160
- /**
161
- * Get all verse audio files for a specific reciter and a specific rub
162
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-rub
163
- * @param {RubNumber} rub
164
- * @param {string} recitationId
165
- * @param {GetVerseRecitationOptions} options
166
- * @example
167
- * quran.v4.audio.findVerseRecitationsByRub('1', '2')
168
- */
169
- const findVerseRecitationsByRub = async (
170
- rub: RubNumber,
171
- recitationId: string,
172
- options?: GetVerseRecitationOptions
173
- ) => {
174
- if (!Utils.isValidRub(rub)) throw new Error('Invalid rub');
175
-
176
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
177
- const data = await fetcher<{
178
- audioFiles: VerseRecitation[];
179
- pagination: Pagination;
180
- }>(`/recitations/${recitationId}/by_rub/${rub}`, params, options?.fetchFn);
181
-
182
- return data;
183
- };
184
-
185
- /**
186
- * Get all verse audio files for a specific reciter and a specific hizb
187
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-hizb
188
- * @param {HizbNumber} hizb
189
- * @param {string} recitationId
190
- * @param {GetVerseRecitationOptions} options
191
- * @example
192
- * quran.v4.audio.findVerseRecitationsByHizb('1', '2')
193
- */
194
- const findVerseRecitationsByHizb = async (
195
- hizb: HizbNumber,
196
- recitationId: string,
197
- options?: GetVerseRecitationOptions
198
- ) => {
199
- if (!Utils.isValidHizb(hizb)) throw new Error('Invalid hizb');
200
-
201
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
202
- const data = await fetcher<{
203
- audioFiles: VerseRecitation[];
204
- pagination: Pagination;
205
- }>(`/recitations/${recitationId}/by_hizb/${hizb}`, params, options?.fetchFn);
206
-
207
- return data;
208
- };
209
-
210
- /**
211
- * Get all verse audio files for a specific reciter and a specific verse
212
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-ayah
213
- * @param {VerseKey} key
214
- * @param {string} recitationId
215
- * @param {GetVerseRecitationOptions} options
216
- * @example
217
- * quran.v4.audio.findVerseRecitationsByKey('1:1', '2')
218
- */
219
- const findVerseRecitationsByKey = async (
220
- key: VerseKey,
221
- recitationId: string,
222
- options?: GetVerseRecitationOptions
223
- ) => {
224
- if (!Utils.isValidVerseKey(key)) throw new Error('Invalid verse key');
225
-
226
- const params = mergeApiOptions(options, defaultVerseRecitationsOptions);
227
- const data = await fetcher<{
228
- audioFiles: VerseRecitation[];
229
- pagination: Pagination;
230
- }>(`/recitations/${recitationId}/by_ayah/${key}`, params, options?.fetchFn);
231
-
232
- return data;
233
- };
234
-
235
- const audio = {
236
- findAllChapterRecitations,
237
- findChapterRecitationById,
238
- findVerseRecitationsByChapter,
239
- findVerseRecitationsByJuz,
240
- findVerseRecitationsByPage,
241
- findVerseRecitationsByRub,
242
- findVerseRecitationsByHizb,
243
- findVerseRecitationsByKey,
244
- };
245
-
246
- export default audio;
@@ -1,80 +0,0 @@
1
- import { Chapter, ChapterId, ChapterInfo, Language } from '../../types';
2
- import { fetcher, mergeApiOptions } from './_fetcher';
3
- import Utils from '../utils';
4
- import { BaseApiOptions } from '../../types/BaseApiOptions';
5
-
6
- type GetChapterOptions = Partial<BaseApiOptions>;
7
-
8
- const defaultOptions: GetChapterOptions = {
9
- language: Language.ARABIC,
10
- };
11
-
12
- /**
13
- * Get all chapters.
14
- * @description https://quran.api-docs.io/v4/chapters/list-chapters
15
- * @param {GetChapterOptions} options
16
- * @example
17
- * quran.v4.chapters.findAll()
18
- */
19
- const findAll = async (options?: GetChapterOptions) => {
20
- const params = mergeApiOptions(options, defaultOptions);
21
- const { chapters } = await fetcher<{ chapters: Chapter[] }>(
22
- '/chapters',
23
- params,
24
- options?.fetchFn
25
- );
26
-
27
- return chapters;
28
- };
29
-
30
- /**
31
- * Get chapter by id.
32
- * @description https://quran.api-docs.io/v4/chapters/get-chapter
33
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
34
- * @param {GetChapterOptions} options
35
- * @example
36
- * quran.v4.chapters.findById('1')
37
- * quran.v4.chapters.findById('114')
38
- */
39
- const findById = async (id: ChapterId, options?: GetChapterOptions) => {
40
- if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id');
41
-
42
- const params = mergeApiOptions(options, defaultOptions);
43
- const { chapter } = await fetcher<{ chapter: Chapter }>(
44
- `/chapters/${id}`,
45
- params,
46
- options?.fetchFn
47
- );
48
-
49
- return chapter;
50
- };
51
-
52
- /**
53
- * Get chapter info by id.
54
- * @description https://quran.api-docs.io/v4/chapters/chapter_info
55
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
56
- * @param {GetChapterOptions} options
57
- * @example
58
- * quran.v4.chapters.findInfoById('1')
59
- * quran.v4.chapters.findInfoById('114')
60
- */
61
- const findInfoById = async (id: ChapterId, options?: GetChapterOptions) => {
62
- if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id');
63
-
64
- const params = mergeApiOptions(options, defaultOptions);
65
- const { chapterInfo } = await fetcher<{ chapterInfo: ChapterInfo }>(
66
- `/chapters/${id}/info`,
67
- params,
68
- options?.fetchFn
69
- );
70
-
71
- return chapterInfo;
72
- };
73
-
74
- const chapters = {
75
- findAll,
76
- findById,
77
- findInfoById,
78
- };
79
-
80
- export default chapters;
@@ -1,17 +0,0 @@
1
- import chapters from './chapters';
2
- import verses from './verses';
3
- import juzs from './juzs';
4
- import audio from './audio';
5
- import resources from './resources';
6
- import search from './search';
7
-
8
- const v4 = {
9
- chapters,
10
- verses,
11
- juzs,
12
- audio,
13
- resources,
14
- search,
15
- };
16
-
17
- export default v4;
@@ -1,22 +0,0 @@
1
- import { Juz } from '../../types';
2
- import { BaseApiOptions } from '../../types/BaseApiOptions';
3
- import { fetcher } from './_fetcher';
4
-
5
- /**
6
- * Get All Juzs
7
- * @description https://quran.api-docs.io/v4/juz/get-all-juzs
8
- * @example
9
- * quran.v4.juzs.findAll()
10
- */
11
- const findAll = async (options?: Omit<BaseApiOptions, 'language'>) => {
12
- const { juzs } = await fetcher<{ juzs: Juz[] }>(
13
- '/juzs',
14
- undefined,
15
- options?.fetchFn
16
- );
17
- return juzs;
18
- };
19
-
20
- const juzs = { findAll };
21
-
22
- export default juzs;
@@ -1,220 +0,0 @@
1
- import {
2
- ChapterInfoResource,
3
- ChapterReciterResource,
4
- Language,
5
- LanguageResource,
6
- // RecitationInfoResource,
7
- RecitationResource,
8
- RecitationStylesResource,
9
- // TafsirInfoResource,
10
- TafsirResource,
11
- // TranslationInfoResource,
12
- TranslationResource,
13
- VerseMediaResource,
14
- } from '../../types';
15
- import { BaseApiOptions } from '../../types/BaseApiOptions';
16
- import { fetcher, mergeApiOptions } from './_fetcher';
17
-
18
- type GetResourceOptions = Partial<BaseApiOptions>;
19
-
20
- const defaultOptions: GetResourceOptions = {
21
- language: Language.ARABIC,
22
- };
23
-
24
- /**
25
- * Get all recitations.
26
- * @description https://quran.api-docs.io/v4/resources/recitations
27
- * @param {GetResourceOptions} options
28
- * @example
29
- * quran.v4.resources.findAllRecitations()
30
- */
31
- const findAllRecitations = async (options?: GetResourceOptions) => {
32
- const params = mergeApiOptions(options);
33
- const { recitations } = await fetcher<{
34
- recitations: RecitationResource[];
35
- }>('/resources/recitations', params, options?.fetchFn);
36
-
37
- return recitations;
38
- };
39
-
40
- // TODO: uncomment when API is ready
41
- /**
42
- * Get all recitation info.
43
- * @description https://quran.api-docs.io/v4/resources/recitation-info
44
- * @param {string} id recitation id
45
- * @param {GetResourceOptions} options
46
- * @example
47
- * quran.v4.resources.findRecitationInfo('1')
48
- */
49
- // const findRecitationInfo = async (id: string, options?: GetResourceOptions) => {
50
- // const params = mergeApiOptions(options, defaultOptions);
51
- // const { info } = await fetcher<{
52
- // info: RecitationInfoResource;
53
- // }>(`/resources/recitations/${id}/info`, params, options?.fetchFn);
54
-
55
- // return info;
56
- // };
57
-
58
- /**
59
- * Get all translations.
60
- * @description https://quran.api-docs.io/v4/resources/translations
61
- * @param {GetResourceOptions} options
62
- * @example
63
- * quran.v4.resources.findAllTranslations()
64
- */
65
- const findAllTranslations = async (options?: GetResourceOptions) => {
66
- const params = mergeApiOptions(options, defaultOptions);
67
- const { translations } = await fetcher<{
68
- translations: TranslationResource[];
69
- }>('/resources/translations', params, options?.fetchFn);
70
-
71
- return translations;
72
- };
73
-
74
- // TODO: uncomment when API is ready
75
- /**
76
- * Get translation info.
77
- * @description https://quran.api-docs.io/v4/resources/translation-info
78
- * @param {string} id translation id
79
- * @param {GetResourceOptions} options
80
- * @example
81
- * quran.v4.resources.findTranslationInfo('169')
82
- */
83
- // const findTranslationInfo = async (id: string, options?: GetResourceOptions) => {
84
- // const params = mergeApiOptions(options, defaultOptions);
85
- // const { info } = await fetcher<{
86
- // info: TranslationInfoResource;
87
- // }>(`/resources/translations/${id}/info`, params, options?.fetchFn);
88
-
89
- // return info;
90
- // };
91
-
92
- /**
93
- * Get all tafsirs.
94
- * @description https://quran.api-docs.io/v4/resources/tafsirs
95
- * @param {GetResourceOptions} options
96
- * @example
97
- * quran.v4.resources.findAllTafsirs()
98
- */
99
- const findAllTafsirs = async (options?: GetResourceOptions) => {
100
- const params = mergeApiOptions(options, defaultOptions);
101
- const { tafsirs } = await fetcher<{
102
- tafsirs: TafsirResource[];
103
- }>('/resources/tafsirs', params, options?.fetchFn);
104
-
105
- return tafsirs;
106
- };
107
-
108
- // TODO: uncomment when API is ready
109
- /**
110
- * Get tafsir info.
111
- * @description https://quran.api-docs.io/v4/resources/tafsirs-info
112
- * @param {string} id tafsir id
113
- * @param {GetResourceOptions} options
114
- * @example
115
- * quran.v4.resources.findTranslationInfo('1')
116
- */
117
- // const findTafsirInfo = async (id: string, options?: GetResourceOptions) => {
118
- // const params = mergeApiOptions(options, defaultOptions);
119
- // const { info } = await fetcher<{
120
- // info: TafsirInfoResource;
121
- // }>(`/resources/tafsirs/${id}/info`, params, options?.fetchFn);
122
-
123
- // return info;
124
- // };
125
-
126
- /**
127
- * Get all recitation styles.
128
- * @description https://quran.api-docs.io/v4/resources/recitation-styles
129
- * @example
130
- * quran.v4.resources.findAllRecitationStyles()
131
- */
132
- const findAllRecitationStyles = async (
133
- options?: Omit<BaseApiOptions, 'language'>
134
- ) => {
135
- const { recitationStyles } = await fetcher<{
136
- recitationStyles: RecitationStylesResource;
137
- }>('/resources/recitation_styles', undefined, options?.fetchFn);
138
-
139
- return recitationStyles;
140
- };
141
-
142
- /**
143
- * Get all languages.
144
- * @description https://quran.api-docs.io/v4/resources/languages
145
- * @param {GetResourceOptions} options
146
- * @example
147
- * quran.v4.resources.findAllLanguages()
148
- */
149
- const findAllLanguages = async (options?: GetResourceOptions) => {
150
- const params = mergeApiOptions(options, defaultOptions);
151
- const { languages } = await fetcher<{
152
- languages: LanguageResource[];
153
- }>('/resources/languages', params, options?.fetchFn);
154
-
155
- return languages;
156
- };
157
-
158
- /**
159
- * Get all chapter infos.
160
- * @description https://quran.api-docs.io/v4/resources/chapter-info
161
- * @param {GetResourceOptions} options
162
- * @example
163
- * quran.v4.resources.findAllChapterInfos()
164
- */
165
- const findAllChapterInfos = async (options?: GetResourceOptions) => {
166
- const params = mergeApiOptions(options, defaultOptions);
167
- const { chapterInfos } = await fetcher<{
168
- chapterInfos: ChapterInfoResource[];
169
- }>('/resources/chapter_infos', params, options?.fetchFn);
170
-
171
- return chapterInfos;
172
- };
173
-
174
- /**
175
- * Get verse media.
176
- * @description https://quran.api-docs.io/v4/resources/verse_media
177
- * @param {GetResourceOptions} options
178
- * @example
179
- * quran.v4.resources.findVerseMedia()
180
- */
181
- const findVerseMedia = async (options?: GetResourceOptions) => {
182
- const params = mergeApiOptions(options, defaultOptions);
183
- const { verseMedia } = await fetcher<{
184
- verseMedia: VerseMediaResource;
185
- }>(`/resources/verse_media`, params, options?.fetchFn);
186
-
187
- return verseMedia;
188
- };
189
-
190
- /**
191
- * Get all chapter reciters.
192
- * @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters
193
- * @param {GetResourceOptions} options
194
- * @example
195
- * quran.v4.resources.findAllChapterReciters()
196
- */
197
- const findAllChapterReciters = async (options?: GetResourceOptions) => {
198
- const params = mergeApiOptions(options, defaultOptions);
199
- const { reciters } = await fetcher<{
200
- reciters: ChapterReciterResource[];
201
- }>(`/resources/chapter_reciters`, params, options?.fetchFn);
202
-
203
- return reciters;
204
- };
205
-
206
- const resources = {
207
- findAllRecitations,
208
- findAllTranslations,
209
- findAllTafsirs,
210
- findAllRecitationStyles,
211
- findAllLanguages,
212
- findVerseMedia,
213
- findAllChapterReciters,
214
- findAllChapterInfos,
215
- // findRecitationInfo
216
- // findTranslationInfo
217
- // findTafsirInfo
218
- };
219
-
220
- export default resources;
@@ -1,41 +0,0 @@
1
- import { Language, SearchResponse } from '../../types';
2
- import { BaseApiOptions } from '../../types/BaseApiOptions';
3
- import { fetcher, mergeApiOptions } from './_fetcher';
4
-
5
- type SearchOptions = Partial<
6
- BaseApiOptions & {
7
- size: number;
8
- page: number;
9
- }
10
- >;
11
-
12
- const defaultSearchOptions: SearchOptions = {
13
- language: Language.ARABIC,
14
- size: 30,
15
- };
16
-
17
- /**
18
- * Search
19
- * @description https://quran.api-docs.io/v4/search/KfCmk4KQYbtyK9adj
20
- * @param {string} q search query
21
- * @param {SearchOptions} options
22
- * @example
23
- * quran.v4.search.search('نور')
24
- * quran.v4.search.search('نور', { language: Language.ENGLISH })
25
- * quran.v4.search.search('نور', { language: Language.ENGLISH, size: 10 })
26
- * quran.v4.search.search('نور', { language: Language.ENGLISH, page: 2 })
27
- */
28
- const search = async (q: string, options?: SearchOptions) => {
29
- const params = mergeApiOptions({ q, ...options }, defaultSearchOptions);
30
- const { search } = await fetcher<SearchResponse>(
31
- '/search',
32
- params,
33
- options?.fetchFn
34
- );
35
-
36
- return search;
37
- };
38
-
39
- const searchApi = { search };
40
-
41
- export default searchApi;