@quranjs/api 1.2.0 → 1.5.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/README.md +7 -0
- package/dist/api.cjs.development.js +30 -30
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +30 -30
- package/dist/api.esm.js.map +1 -1
- package/dist/types/ChapterId.d.ts +4 -1
- package/dist/types/HizbNumber.d.ts +4 -1
- package/dist/types/JuzNumber.d.ts +4 -1
- package/dist/types/PageNumber.d.ts +4 -1
- package/dist/types/RubNumber.d.ts +4 -1
- package/dist/types/VerseKey.d.ts +2 -1
- package/dist/types/utils.d.ts +5 -0
- package/package.json +1 -1
- package/src/sdk/v4/audio.ts +22 -22
- package/src/sdk/v4/chapters.ts +9 -9
- package/src/sdk/v4/resources.ts +23 -23
- package/src/sdk/v4/search.ts +6 -6
- package/src/types/ChapterId.ts +4 -115
- package/src/types/HizbNumber.ts +4 -61
- package/src/types/JuzNumber.ts +4 -31
- package/src/types/PageNumber.ts +4 -519
- package/src/types/RubNumber.ts +4 -241
- package/src/types/VerseKey.ts +116 -6236
- package/src/types/utils.ts +24 -0
package/src/sdk/v4/resources.ts
CHANGED
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
} from '../../types';
|
|
15
15
|
import { fetcher } from './_fetcher';
|
|
16
16
|
|
|
17
|
-
type
|
|
17
|
+
type GetResourceOptions = Partial<{
|
|
18
18
|
language: Language;
|
|
19
19
|
}>;
|
|
20
20
|
|
|
21
|
-
const defaultOptions:
|
|
21
|
+
const defaultOptions: GetResourceOptions = {
|
|
22
22
|
language: Language.ARABIC,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getResourcesOptions = (options:
|
|
25
|
+
const getResourcesOptions = (options: GetResourceOptions = {}) => {
|
|
26
26
|
const final: any = { ...defaultOptions, ...options };
|
|
27
27
|
return final;
|
|
28
28
|
};
|
|
@@ -30,11 +30,11 @@ const getResourcesOptions = (options: GetResourcesOptions = {}) => {
|
|
|
30
30
|
/**
|
|
31
31
|
* Get all recitations.
|
|
32
32
|
* @description https://quran.api-docs.io/v4/resources/recitations
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {GetResourceOptions} options
|
|
34
34
|
* @example
|
|
35
35
|
* quran.v4.resources.findAllRecitations()
|
|
36
36
|
*/
|
|
37
|
-
const findAllRecitations = async (options?:
|
|
37
|
+
const findAllRecitations = async (options?: GetResourceOptions) => {
|
|
38
38
|
const params = getResourcesOptions(options);
|
|
39
39
|
const { recitations } = await fetcher<{
|
|
40
40
|
recitations: RecitationResource[];
|
|
@@ -48,11 +48,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => {
|
|
|
48
48
|
* Get all recitation info.
|
|
49
49
|
* @description https://quran.api-docs.io/v4/resources/recitation-info
|
|
50
50
|
* @param {string} id recitation id
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {GetResourceOptions} options
|
|
52
52
|
* @example
|
|
53
53
|
* quran.v4.resources.findRecitationInfo('1')
|
|
54
54
|
*/
|
|
55
|
-
// const findRecitationInfo = async (id: string, options?:
|
|
55
|
+
// const findRecitationInfo = async (id: string, options?: GetResourceOptions) => {
|
|
56
56
|
// const params = getResourcesOptions(options);
|
|
57
57
|
// const { info } = await fetcher<{
|
|
58
58
|
// info: RecitationInfoResource;
|
|
@@ -64,11 +64,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => {
|
|
|
64
64
|
/**
|
|
65
65
|
* Get all translations.
|
|
66
66
|
* @description https://quran.api-docs.io/v4/resources/translations
|
|
67
|
-
* @param {
|
|
67
|
+
* @param {GetResourceOptions} options
|
|
68
68
|
* @example
|
|
69
69
|
* quran.v4.resources.findAllTranslations()
|
|
70
70
|
*/
|
|
71
|
-
const findAllTranslations = async (options?:
|
|
71
|
+
const findAllTranslations = async (options?: GetResourceOptions) => {
|
|
72
72
|
const params = getResourcesOptions(options);
|
|
73
73
|
const { translations } = await fetcher<{
|
|
74
74
|
translations: TranslationResource[];
|
|
@@ -82,11 +82,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => {
|
|
|
82
82
|
* Get translation info.
|
|
83
83
|
* @description https://quran.api-docs.io/v4/resources/translation-info
|
|
84
84
|
* @param {string} id translation id
|
|
85
|
-
* @param {
|
|
85
|
+
* @param {GetResourceOptions} options
|
|
86
86
|
* @example
|
|
87
87
|
* quran.v4.resources.findTranslationInfo('169')
|
|
88
88
|
*/
|
|
89
|
-
// const findTranslationInfo = async (id: string, options?:
|
|
89
|
+
// const findTranslationInfo = async (id: string, options?: GetResourceOptions) => {
|
|
90
90
|
// const params = getResourcesOptions(options);
|
|
91
91
|
// const { info } = await fetcher<{
|
|
92
92
|
// info: TranslationInfoResource;
|
|
@@ -98,11 +98,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => {
|
|
|
98
98
|
/**
|
|
99
99
|
* Get all tafsirs.
|
|
100
100
|
* @description https://quran.api-docs.io/v4/resources/tafsirs
|
|
101
|
-
* @param {
|
|
101
|
+
* @param {GetResourceOptions} options
|
|
102
102
|
* @example
|
|
103
103
|
* quran.v4.resources.findAllTafsirs()
|
|
104
104
|
*/
|
|
105
|
-
const findAllTafsirs = async (options?:
|
|
105
|
+
const findAllTafsirs = async (options?: GetResourceOptions) => {
|
|
106
106
|
const params = getResourcesOptions(options);
|
|
107
107
|
const { tafsirs } = await fetcher<{
|
|
108
108
|
tafsirs: TafsirResource[];
|
|
@@ -116,11 +116,11 @@ const findAllTafsirs = async (options?: GetResourcesOptions) => {
|
|
|
116
116
|
* Get tafsir info.
|
|
117
117
|
* @description https://quran.api-docs.io/v4/resources/tafsirs-info
|
|
118
118
|
* @param {string} id tafsir id
|
|
119
|
-
* @param {
|
|
119
|
+
* @param {GetResourceOptions} options
|
|
120
120
|
* @example
|
|
121
121
|
* quran.v4.resources.findTranslationInfo('1')
|
|
122
122
|
*/
|
|
123
|
-
// const findTafsirInfo = async (id: string, options?:
|
|
123
|
+
// const findTafsirInfo = async (id: string, options?: GetResourceOptions) => {
|
|
124
124
|
// const params = getResourcesOptions(options);
|
|
125
125
|
// const { info } = await fetcher<{
|
|
126
126
|
// info: TafsirInfoResource;
|
|
@@ -146,11 +146,11 @@ const findAllRecitationStyles = async () => {
|
|
|
146
146
|
/**
|
|
147
147
|
* Get all languages.
|
|
148
148
|
* @description https://quran.api-docs.io/v4/resources/languages
|
|
149
|
-
* @param {
|
|
149
|
+
* @param {GetResourceOptions} options
|
|
150
150
|
* @example
|
|
151
151
|
* quran.v4.resources.findAllLanguages()
|
|
152
152
|
*/
|
|
153
|
-
const findAllLanguages = async (options?:
|
|
153
|
+
const findAllLanguages = async (options?: GetResourceOptions) => {
|
|
154
154
|
const params = getResourcesOptions(options);
|
|
155
155
|
const { languages } = await fetcher<{
|
|
156
156
|
languages: LanguageResource[];
|
|
@@ -162,11 +162,11 @@ const findAllLanguages = async (options?: GetResourcesOptions) => {
|
|
|
162
162
|
/**
|
|
163
163
|
* Get all chapter infos.
|
|
164
164
|
* @description https://quran.api-docs.io/v4/resources/chapter-info
|
|
165
|
-
* @param {
|
|
165
|
+
* @param {GetResourceOptions} options
|
|
166
166
|
* @example
|
|
167
167
|
* quran.v4.resources.findAllChapterInfos()
|
|
168
168
|
*/
|
|
169
|
-
const findAllChapterInfos = async (options?:
|
|
169
|
+
const findAllChapterInfos = async (options?: GetResourceOptions) => {
|
|
170
170
|
const params = getResourcesOptions(options);
|
|
171
171
|
const { chapterInfos } = await fetcher<{
|
|
172
172
|
chapterInfos: ChapterInfoResource[];
|
|
@@ -178,11 +178,11 @@ const findAllChapterInfos = async (options?: GetResourcesOptions) => {
|
|
|
178
178
|
/**
|
|
179
179
|
* Get verse media.
|
|
180
180
|
* @description https://quran.api-docs.io/v4/resources/verse_media
|
|
181
|
-
* @param {
|
|
181
|
+
* @param {GetResourceOptions} options
|
|
182
182
|
* @example
|
|
183
183
|
* quran.v4.resources.findVerseMedia()
|
|
184
184
|
*/
|
|
185
|
-
const findVerseMedia = async (options?:
|
|
185
|
+
const findVerseMedia = async (options?: GetResourceOptions) => {
|
|
186
186
|
const params = getResourcesOptions(options);
|
|
187
187
|
const { verseMedia } = await fetcher<{
|
|
188
188
|
verseMedia: VerseMediaResource;
|
|
@@ -194,11 +194,11 @@ const findVerseMedia = async (options?: GetResourcesOptions) => {
|
|
|
194
194
|
/**
|
|
195
195
|
* Get all chapter reciters.
|
|
196
196
|
* @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters
|
|
197
|
-
* @param {
|
|
197
|
+
* @param {GetResourceOptions} options
|
|
198
198
|
* @example
|
|
199
199
|
* quran.v4.resources.findAllChapterReciters()
|
|
200
200
|
*/
|
|
201
|
-
const findAllChapterReciters = async (options?:
|
|
201
|
+
const findAllChapterReciters = async (options?: GetResourceOptions) => {
|
|
202
202
|
const params = getResourcesOptions(options);
|
|
203
203
|
const { reciters } = await fetcher<{
|
|
204
204
|
reciters: ChapterReciterResource[];
|
package/src/sdk/v4/search.ts
CHANGED
|
@@ -20,13 +20,13 @@ const getSearchOptions = (q: string, options: SearchOptions = {}) => {
|
|
|
20
20
|
/**
|
|
21
21
|
* Search
|
|
22
22
|
* @description https://quran.api-docs.io/v4/search/KfCmk4KQYbtyK9adj
|
|
23
|
-
* @param q search query
|
|
24
|
-
* @param
|
|
23
|
+
* @param {string} q search query
|
|
24
|
+
* @param {SearchOptions} options
|
|
25
25
|
* @example
|
|
26
|
-
* quran.v4.search.search('
|
|
27
|
-
* quran.v4.search.search('
|
|
28
|
-
* quran.v4.search.search('
|
|
29
|
-
* quran.v4.search.search('
|
|
26
|
+
* quran.v4.search.search('نور')
|
|
27
|
+
* quran.v4.search.search('نور', { language: Language.ENGLISH })
|
|
28
|
+
* quran.v4.search.search('نور', { language: Language.ENGLISH, size: 10 })
|
|
29
|
+
* quran.v4.search.search('نور', { language: Language.ENGLISH, page: 2 })
|
|
30
30
|
*/
|
|
31
31
|
const search = async (q: string, options?: SearchOptions) => {
|
|
32
32
|
const params = getSearchOptions(q, options);
|
package/src/types/ChapterId.ts
CHANGED
|
@@ -1,115 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
| '4'
|
|
6
|
-
| '5'
|
|
7
|
-
| '6'
|
|
8
|
-
| '7'
|
|
9
|
-
| '8'
|
|
10
|
-
| '9'
|
|
11
|
-
| '10'
|
|
12
|
-
| '11'
|
|
13
|
-
| '12'
|
|
14
|
-
| '13'
|
|
15
|
-
| '14'
|
|
16
|
-
| '15'
|
|
17
|
-
| '16'
|
|
18
|
-
| '17'
|
|
19
|
-
| '18'
|
|
20
|
-
| '19'
|
|
21
|
-
| '20'
|
|
22
|
-
| '21'
|
|
23
|
-
| '22'
|
|
24
|
-
| '23'
|
|
25
|
-
| '24'
|
|
26
|
-
| '25'
|
|
27
|
-
| '26'
|
|
28
|
-
| '27'
|
|
29
|
-
| '28'
|
|
30
|
-
| '29'
|
|
31
|
-
| '30'
|
|
32
|
-
| '31'
|
|
33
|
-
| '32'
|
|
34
|
-
| '33'
|
|
35
|
-
| '34'
|
|
36
|
-
| '35'
|
|
37
|
-
| '36'
|
|
38
|
-
| '37'
|
|
39
|
-
| '38'
|
|
40
|
-
| '39'
|
|
41
|
-
| '40'
|
|
42
|
-
| '41'
|
|
43
|
-
| '42'
|
|
44
|
-
| '43'
|
|
45
|
-
| '44'
|
|
46
|
-
| '45'
|
|
47
|
-
| '46'
|
|
48
|
-
| '47'
|
|
49
|
-
| '48'
|
|
50
|
-
| '49'
|
|
51
|
-
| '50'
|
|
52
|
-
| '51'
|
|
53
|
-
| '52'
|
|
54
|
-
| '53'
|
|
55
|
-
| '54'
|
|
56
|
-
| '55'
|
|
57
|
-
| '56'
|
|
58
|
-
| '57'
|
|
59
|
-
| '58'
|
|
60
|
-
| '59'
|
|
61
|
-
| '60'
|
|
62
|
-
| '61'
|
|
63
|
-
| '62'
|
|
64
|
-
| '63'
|
|
65
|
-
| '64'
|
|
66
|
-
| '65'
|
|
67
|
-
| '66'
|
|
68
|
-
| '67'
|
|
69
|
-
| '68'
|
|
70
|
-
| '69'
|
|
71
|
-
| '70'
|
|
72
|
-
| '71'
|
|
73
|
-
| '72'
|
|
74
|
-
| '73'
|
|
75
|
-
| '74'
|
|
76
|
-
| '75'
|
|
77
|
-
| '76'
|
|
78
|
-
| '77'
|
|
79
|
-
| '78'
|
|
80
|
-
| '79'
|
|
81
|
-
| '80'
|
|
82
|
-
| '81'
|
|
83
|
-
| '82'
|
|
84
|
-
| '83'
|
|
85
|
-
| '84'
|
|
86
|
-
| '85'
|
|
87
|
-
| '86'
|
|
88
|
-
| '87'
|
|
89
|
-
| '88'
|
|
90
|
-
| '89'
|
|
91
|
-
| '90'
|
|
92
|
-
| '91'
|
|
93
|
-
| '92'
|
|
94
|
-
| '93'
|
|
95
|
-
| '94'
|
|
96
|
-
| '95'
|
|
97
|
-
| '96'
|
|
98
|
-
| '97'
|
|
99
|
-
| '98'
|
|
100
|
-
| '99'
|
|
101
|
-
| '100'
|
|
102
|
-
| '101'
|
|
103
|
-
| '102'
|
|
104
|
-
| '103'
|
|
105
|
-
| '104'
|
|
106
|
-
| '105'
|
|
107
|
-
| '106'
|
|
108
|
-
| '107'
|
|
109
|
-
| '108'
|
|
110
|
-
| '109'
|
|
111
|
-
| '110'
|
|
112
|
-
| '111'
|
|
113
|
-
| '112'
|
|
114
|
-
| '113'
|
|
115
|
-
| '114';
|
|
1
|
+
import { NumberRange, NumberUnionToString } from './utils';
|
|
2
|
+
|
|
3
|
+
type _ChapterId = NumberRange<1, 115>;
|
|
4
|
+
export type ChapterId = _ChapterId | NumberUnionToString<_ChapterId>;
|
package/src/types/HizbNumber.ts
CHANGED
|
@@ -1,61 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
| '4'
|
|
6
|
-
| '5'
|
|
7
|
-
| '6'
|
|
8
|
-
| '7'
|
|
9
|
-
| '8'
|
|
10
|
-
| '9'
|
|
11
|
-
| '10'
|
|
12
|
-
| '11'
|
|
13
|
-
| '12'
|
|
14
|
-
| '13'
|
|
15
|
-
| '14'
|
|
16
|
-
| '15'
|
|
17
|
-
| '16'
|
|
18
|
-
| '17'
|
|
19
|
-
| '18'
|
|
20
|
-
| '19'
|
|
21
|
-
| '20'
|
|
22
|
-
| '21'
|
|
23
|
-
| '22'
|
|
24
|
-
| '23'
|
|
25
|
-
| '24'
|
|
26
|
-
| '25'
|
|
27
|
-
| '26'
|
|
28
|
-
| '27'
|
|
29
|
-
| '28'
|
|
30
|
-
| '29'
|
|
31
|
-
| '30'
|
|
32
|
-
| '31'
|
|
33
|
-
| '32'
|
|
34
|
-
| '33'
|
|
35
|
-
| '34'
|
|
36
|
-
| '35'
|
|
37
|
-
| '36'
|
|
38
|
-
| '37'
|
|
39
|
-
| '38'
|
|
40
|
-
| '39'
|
|
41
|
-
| '40'
|
|
42
|
-
| '41'
|
|
43
|
-
| '42'
|
|
44
|
-
| '43'
|
|
45
|
-
| '44'
|
|
46
|
-
| '45'
|
|
47
|
-
| '46'
|
|
48
|
-
| '47'
|
|
49
|
-
| '48'
|
|
50
|
-
| '49'
|
|
51
|
-
| '50'
|
|
52
|
-
| '51'
|
|
53
|
-
| '52'
|
|
54
|
-
| '53'
|
|
55
|
-
| '54'
|
|
56
|
-
| '55'
|
|
57
|
-
| '56'
|
|
58
|
-
| '57'
|
|
59
|
-
| '58'
|
|
60
|
-
| '59'
|
|
61
|
-
| '60';
|
|
1
|
+
import { NumberRange, NumberUnionToString } from './utils';
|
|
2
|
+
|
|
3
|
+
type _HizbNumber = NumberRange<1, 61>;
|
|
4
|
+
export type HizbNumber = _HizbNumber | NumberUnionToString<_HizbNumber>;
|
package/src/types/JuzNumber.ts
CHANGED
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
| '4'
|
|
6
|
-
| '5'
|
|
7
|
-
| '6'
|
|
8
|
-
| '7'
|
|
9
|
-
| '8'
|
|
10
|
-
| '9'
|
|
11
|
-
| '10'
|
|
12
|
-
| '11'
|
|
13
|
-
| '12'
|
|
14
|
-
| '13'
|
|
15
|
-
| '14'
|
|
16
|
-
| '15'
|
|
17
|
-
| '16'
|
|
18
|
-
| '17'
|
|
19
|
-
| '18'
|
|
20
|
-
| '19'
|
|
21
|
-
| '20'
|
|
22
|
-
| '21'
|
|
23
|
-
| '22'
|
|
24
|
-
| '23'
|
|
25
|
-
| '24'
|
|
26
|
-
| '25'
|
|
27
|
-
| '26'
|
|
28
|
-
| '27'
|
|
29
|
-
| '28'
|
|
30
|
-
| '29'
|
|
31
|
-
| '30';
|
|
1
|
+
import { NumberRange, NumberUnionToString } from './utils';
|
|
2
|
+
|
|
3
|
+
type _JuzNumber = NumberRange<1, 31>;
|
|
4
|
+
export type JuzNumber = _JuzNumber | NumberUnionToString<_JuzNumber>;
|