Skip to content

Commit

Permalink
feat: fix jsdoc stuff and rename some types
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedriad1 committed Mar 30, 2022
1 parent 32d0a60 commit 58fd19f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 60 deletions.
44 changes: 22 additions & 22 deletions src/sdk/v4/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ import { decamelize } from 'humps';
import Utils from '../utils';
import { fetcher } from './_fetcher';

type GetChapterRecitationsOptions = Partial<{
type GetChapterRecitationOptions = Partial<{
language: Language;
}>;

const defaultChapterRecitationsOptions: GetChapterRecitationsOptions = {
const defaultChapterRecitationsOptions: GetChapterRecitationOptions = {
language: Language.ARABIC,
};

const getChapterRecitationsOptions = (
options: GetChapterRecitationsOptions = {}
options: GetChapterRecitationOptions = {}
) => {
const final: any = { ...defaultChapterRecitationsOptions, ...options };

return final;
};

type GetVerseRecitationsOptions = Partial<{
type GetVerseRecitationOptions = Partial<{
language: Language;
fields: Partial<Record<VerseRecitationField, boolean>>;
}>;

const defaultVerseRecitationsOptions: GetVerseRecitationsOptions = {
const defaultVerseRecitationsOptions: GetVerseRecitationOptions = {
language: Language.ARABIC,
};

const getVerseRecitationsOptions = (
options: GetVerseRecitationsOptions = {}
options: GetVerseRecitationOptions = {}
) => {
const initial = { ...defaultVerseRecitationsOptions, ...options };
const final: any = { language: initial.language };
Expand All @@ -61,13 +61,13 @@ const getVerseRecitationsOptions = (
* Get all chapter recitations for specific reciter
* @description https://quran.api-docs.io/v4/audio-recitations/list-of-all-surah-audio-files-for-specific-reciter
* @param {string} reciterId
* @param {GetChapterRecitationsOptions} options
* @param {GetChapterRecitationOptions} options
* @example
* quran.v4.audio.findAllChapterRecitations('2')
*/
const findAllChapterRecitations = async (
reciterId: string,
options?: GetChapterRecitationsOptions
options?: GetChapterRecitationOptions
) => {
const params = getChapterRecitationsOptions(options);
const { audioFiles } = await fetcher<{ audioFiles: ChapterRecitation[] }>(
Expand All @@ -82,14 +82,14 @@ const findAllChapterRecitations = async (
* @description https://quran.api-docs.io/v4/audio-recitations/get-single-surah-audio-for-specific-reciter
* @param {ChapterId} chapterId
* @param {string} reciterId
* @param {GetChapterRecitationsOptions} options
* @param {GetChapterRecitationOptions} options
* @example
* quran.v4.audio.findChapterRecitationById('1', '2') // first chapter recitation for reciter 2
*/
const findChapterRecitationById = async (
chapterId: ChapterId,
reciterId: string,
options?: GetChapterRecitationsOptions
options?: GetChapterRecitationOptions
) => {
if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id');

Expand All @@ -107,14 +107,14 @@ const findChapterRecitationById = async (
* @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-surah
* @param {ChapterId} chapterId
* @param {string} recitationId
* @param {GetVerseRecitationsOptions} options
* @param {GetVerseRecitationOptions} options
* @example
* quran.v4.audio.findVerseRecitationsByChapter('1', '2')
*/
const findVerseRecitationsByChapter = async (
chapterId: ChapterId,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id');

Expand All @@ -139,7 +139,7 @@ const findVerseRecitationsByChapter = async (
const findVerseRecitationsByJuz = async (
juz: JuzNumber,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidJuz(juz)) throw new Error('Invalid juz');

Expand All @@ -157,14 +157,14 @@ const findVerseRecitationsByJuz = async (
* @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-madani-mushaf-page
* @param {PageNumber} page
* @param {string} recitationId
* @param {GetVerseRecitationsOptions} options
* @param {GetVerseRecitationOptions} options
* @example
* quran.v4.audio.findVerseRecitationsByPage('1', '2')
*/
const findVerseRecitationsByPage = async (
page: PageNumber,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidQuranPage(page)) throw new Error('Invalid page');

Expand All @@ -182,14 +182,14 @@ const findVerseRecitationsByPage = async (
* @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-rub
* @param {RubNumber} rub
* @param {string} recitationId
* @param {GetVerseRecitationsOptions} options
* @param {GetVerseRecitationOptions} options
* @example
* quran.v4.audio.findVerseRecitationsByRub('1', '2')
*/
const findVerseRecitationsByRub = async (
rub: RubNumber,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidRub(rub)) throw new Error('Invalid rub');

Expand All @@ -207,14 +207,14 @@ const findVerseRecitationsByRub = async (
* @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-hizb
* @param {HizbNumber} hizb
* @param {string} recitationId
* @param {GetVerseRecitationsOptions} options
* @param {GetVerseRecitationOptions} options
* @example
* quran.v4.audio.findVerseRecitationsByHizb('1', '2')
*/
const findVerseRecitationsByHizb = async (
hizb: HizbNumber,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidHizb(hizb)) throw new Error('Invalid hizb');

Expand All @@ -228,18 +228,18 @@ const findVerseRecitationsByHizb = async (
};

/**
* Get all verse audio files for a specific reciter and a specific hizb
* Get all verse audio files for a specific reciter and a specific verse
* @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-ayah
* @param {VerseKey} key
* @param {string} recitationId
* @param {GetVerseRecitationsOptions} options
* @param {GetVerseRecitationOptions} options
* @example
* quran.v4.audio.findVerseRecitationsByKey('1:1', '2')
*/
const findVerseRecitationsByKey = async (
key: VerseKey,
recitationId: string,
options?: GetVerseRecitationsOptions
options?: GetVerseRecitationOptions
) => {
if (!Utils.isValidVerseKey(key)) throw new Error('Invalid verse key');

Expand Down
18 changes: 9 additions & 9 deletions src/sdk/v4/chapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import { Chapter, ChapterId, ChapterInfo, Language } from '../../types';
import { fetcher } from './_fetcher';
import Utils from '../utils';

type Options = Partial<{
type GetChapterOptions = Partial<{
language: Language;
}>;

const defaultOptions: Options = {
const defaultOptions: GetChapterOptions = {
language: Language.ARABIC,
};

const getChapterOptions = (options: Options = {}) => {
const getChapterOptions = (options: GetChapterOptions = {}) => {
const final: any = { ...defaultOptions, ...options };
return final;
};

/**
* Get all chapters.
* @description https://quran.api-docs.io/v4/chapters/list-chapters
* @param {Options} options
* @param {GetChapterOptions} options
* @example
* quran.v4.chapters.findAll()
*/
const findAll = async (options?: Options) => {
const findAll = async (options?: GetChapterOptions) => {
const params = getChapterOptions(options);
const { chapters } = await fetcher<{ chapters: Chapter[] }>(
'/chapters',
Expand All @@ -36,12 +36,12 @@ const findAll = async (options?: Options) => {
* Get chapter by id.
* @description https://quran.api-docs.io/v4/chapters/get-chapter
* @param {ChapterId} id chapter id, minimum 1, maximum 114
* @param {Options} options
* @param {GetChapterOptions} options
* @example
* quran.v4.chapters.findById('1')
* quran.v4.chapters.findById('114')
*/
const findById = async (id: ChapterId, options?: Options) => {
const findById = async (id: ChapterId, options?: GetChapterOptions) => {
if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id');

const params = getChapterOptions(options);
Expand All @@ -57,12 +57,12 @@ const findById = async (id: ChapterId, options?: Options) => {
* Get chapter info by id.
* @description https://quran.api-docs.io/v4/chapters/chapter_info
* @param {ChapterId} id chapter id, minimum 1, maximum 114
* @param {Options} options
* @param {GetChapterOptions} options
* @example
* quran.v4.chapters.findInfoById('1')
* quran.v4.chapters.findInfoById('114')
*/
const findInfoById = async (id: ChapterId, options?: Options) => {
const findInfoById = async (id: ChapterId, options?: GetChapterOptions) => {
if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id');

const params = getChapterOptions(options);
Expand Down
46 changes: 23 additions & 23 deletions src/sdk/v4/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ import {
} from '../../types';
import { fetcher } from './_fetcher';

type GetResourcesOptions = Partial<{
type GetResourceOptions = Partial<{
language: Language;
}>;

const defaultOptions: GetResourcesOptions = {
const defaultOptions: GetResourceOptions = {
language: Language.ARABIC,
};

const getResourcesOptions = (options: GetResourcesOptions = {}) => {
const getResourcesOptions = (options: GetResourceOptions = {}) => {
const final: any = { ...defaultOptions, ...options };
return final;
};

/**
* Get all recitations.
* @description https://quran.api-docs.io/v4/resources/recitations
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllRecitations()
*/
const findAllRecitations = async (options?: GetResourcesOptions) => {
const findAllRecitations = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { recitations } = await fetcher<{
recitations: RecitationResource[];
Expand All @@ -48,11 +48,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => {
* Get all recitation info.
* @description https://quran.api-docs.io/v4/resources/recitation-info
* @param {string} id recitation id
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findRecitationInfo('1')
*/
// const findRecitationInfo = async (id: string, options?: GetResourcesOptions) => {
// const findRecitationInfo = async (id: string, options?: GetResourceOptions) => {
// const params = getResourcesOptions(options);
// const { info } = await fetcher<{
// info: RecitationInfoResource;
Expand All @@ -64,11 +64,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => {
/**
* Get all translations.
* @description https://quran.api-docs.io/v4/resources/translations
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllTranslations()
*/
const findAllTranslations = async (options?: GetResourcesOptions) => {
const findAllTranslations = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { translations } = await fetcher<{
translations: TranslationResource[];
Expand All @@ -82,11 +82,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => {
* Get translation info.
* @description https://quran.api-docs.io/v4/resources/translation-info
* @param {string} id translation id
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findTranslationInfo('169')
*/
// const findTranslationInfo = async (id: string, options?: GetResourcesOptions) => {
// const findTranslationInfo = async (id: string, options?: GetResourceOptions) => {
// const params = getResourcesOptions(options);
// const { info } = await fetcher<{
// info: TranslationInfoResource;
Expand All @@ -98,11 +98,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => {
/**
* Get all tafsirs.
* @description https://quran.api-docs.io/v4/resources/tafsirs
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllTafsirs()
*/
const findAllTafsirs = async (options?: GetResourcesOptions) => {
const findAllTafsirs = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { tafsirs } = await fetcher<{
tafsirs: TafsirResource[];
Expand All @@ -116,11 +116,11 @@ const findAllTafsirs = async (options?: GetResourcesOptions) => {
* Get tafsir info.
* @description https://quran.api-docs.io/v4/resources/tafsirs-info
* @param {string} id tafsir id
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findTranslationInfo('1')
*/
// const findTafsirInfo = async (id: string, options?: GetResourcesOptions) => {
// const findTafsirInfo = async (id: string, options?: GetResourceOptions) => {
// const params = getResourcesOptions(options);
// const { info } = await fetcher<{
// info: TafsirInfoResource;
Expand All @@ -146,11 +146,11 @@ const findAllRecitationStyles = async () => {
/**
* Get all languages.
* @description https://quran.api-docs.io/v4/resources/languages
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllLanguages()
*/
const findAllLanguages = async (options?: GetResourcesOptions) => {
const findAllLanguages = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { languages } = await fetcher<{
languages: LanguageResource[];
Expand All @@ -162,11 +162,11 @@ const findAllLanguages = async (options?: GetResourcesOptions) => {
/**
* Get all chapter infos.
* @description https://quran.api-docs.io/v4/resources/chapter-info
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllChapterInfos()
*/
const findAllChapterInfos = async (options?: GetResourcesOptions) => {
const findAllChapterInfos = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { chapterInfos } = await fetcher<{
chapterInfos: ChapterInfoResource[];
Expand All @@ -178,11 +178,11 @@ const findAllChapterInfos = async (options?: GetResourcesOptions) => {
/**
* Get verse media.
* @description https://quran.api-docs.io/v4/resources/verse_media
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findVerseMedia()
*/
const findVerseMedia = async (options?: GetResourcesOptions) => {
const findVerseMedia = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { verseMedia } = await fetcher<{
verseMedia: VerseMediaResource;
Expand All @@ -194,11 +194,11 @@ const findVerseMedia = async (options?: GetResourcesOptions) => {
/**
* Get all chapter reciters.
* @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters
* @param {GetResourcesOptions} options
* @param {GetResourceOptions} options
* @example
* quran.v4.resources.findAllChapterReciters()
*/
const findAllChapterReciters = async (options?: GetResourcesOptions) => {
const findAllChapterReciters = async (options?: GetResourceOptions) => {
const params = getResourcesOptions(options);
const { reciters } = await fetcher<{
reciters: ChapterReciterResource[];
Expand Down
Loading

2 comments on commit 58fd19f

@vercel
Copy link

@vercel vercel bot commented on 58fd19f Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

quranjs-docs – ./docs

quranjs-docs-ahmed-riad.vercel.app
quranjs-docs.vercel.app
quranjs-docs-git-master-ahmed-riad.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 58fd19f Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

api – ./docs

api-git-master-quranjs.vercel.app
api-quranjs.vercel.app
quranjs.vercel.app

Please sign in to comment.