@quranjs/api 3.2.1 → 3.4.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.
@@ -1,4 +1,4 @@
1
- import { e as QuranFetchClient, B as BaseApiParams, b as VerseRecitationField, d as SearchParams, P as PaginationParams, W as WordField, T as TranslationField, V as VerseField } from './index-BZgqOfA4.mjs';
1
+ import { A as ApiParams, e as QuranFetchClient, B as BaseApiParams, b as VerseRecitationField, d as SearchParams, P as PaginationParams, W as WordField, T as TranslationField, V as VerseField } from './index-BgoJducH.mjs';
2
2
 
3
3
  /**
4
4
  * Maps chapter number to verse count
@@ -197,6 +197,36 @@ interface SearchResponse {
197
197
  };
198
198
  }
199
199
 
200
+ interface Answer {
201
+ id: string | number;
202
+ body: string;
203
+ answeredBy?: string;
204
+ status: string;
205
+ language?: string;
206
+ }
207
+ interface AnswerQuestion {
208
+ id: string | number;
209
+ body: string;
210
+ type: string;
211
+ ranges: VerseKey[];
212
+ surah: number;
213
+ theme?: string[];
214
+ summary?: string;
215
+ references?: string[];
216
+ language?: string;
217
+ status: string;
218
+ answers: Answer[];
219
+ }
220
+ interface AnswersByAyahResponse {
221
+ questions: AnswerQuestion[];
222
+ totalCount?: number;
223
+ }
224
+ interface AnswerCount {
225
+ types?: Record<string, number>;
226
+ total: number;
227
+ }
228
+ type AnswerCountWithinRangeResponse = Record<string, AnswerCount>;
229
+
200
230
  /**
201
231
  * Segment structure is [wordFrom, wordTo, timeFrom, timeTo] time is in ms
202
232
  */
@@ -320,6 +350,52 @@ interface ChapterReciterResource {
320
350
  format?: string;
321
351
  filesSize?: number;
322
352
  }
353
+ type ContentSyncResourceGroup = "articles" | "recitations" | "tafsirs" | "translations";
354
+ type ContentSyncMutationType = "RESOURCE_CREATE" | "RESOURCE_UPDATE" | "RESOURCE_DELETE" | "ROW_CREATE" | "ROW_UPDATE" | "ROW_DELETE" | "RESOURCE_INVALIDATE";
355
+ interface ContentSyncOptions extends ApiParams {
356
+ /** Resource filter, e.g. `articles:*;translations:1,6`. */
357
+ resources?: string;
358
+ /** Set to true for the initial sync. */
359
+ bootstrap?: boolean;
360
+ /** Token returned by the final bootstrap or incremental page. */
361
+ syncToken?: string;
362
+ /** Pagination cursor from `nextPageUrl`. */
363
+ cursor?: string;
364
+ /** Page size, up to the API maximum. */
365
+ perPage?: number;
366
+ }
367
+ type ContentResourceSnapshotOptions = ApiParams;
368
+ interface ContentSyncMutation<TData extends Record<string, unknown> = Record<string, unknown>> {
369
+ sequence: number;
370
+ type: ContentSyncMutationType;
371
+ resourceGroup: ContentSyncResourceGroup;
372
+ resourceId: number;
373
+ resourceContentId: number | null;
374
+ recordType: string | null;
375
+ recordKey: string | null;
376
+ sourceRecordId: number | null;
377
+ changedAt: string;
378
+ data: TData | null;
379
+ snapshotUrl: string | null;
380
+ unavailableReason: string | null;
381
+ }
382
+ interface ContentSyncResponse<TData extends Record<string, unknown> = Record<string, unknown>> {
383
+ sync: {
384
+ syncUntilSequence: number;
385
+ hasMore: boolean;
386
+ nextPageUrl: string | null;
387
+ nextSyncToken: string | null;
388
+ mutations: ContentSyncMutation<TData>[];
389
+ };
390
+ }
391
+ interface ContentResourceSnapshot<TRecord extends Record<string, unknown> = Record<string, unknown>> {
392
+ resourceGroup: ContentSyncResourceGroup;
393
+ resourceId: number;
394
+ resourceContentId: number | null;
395
+ schemaVersion: number;
396
+ syncSequence: number;
397
+ records: TRecord[];
398
+ }
323
399
 
324
400
  interface ChapterInfo {
325
401
  id: number;
@@ -494,6 +570,43 @@ interface Pagination {
494
570
  totalRecords: number;
495
571
  }
496
572
 
573
+ type GetAnswersByAyahOptions = BaseApiParams & {
574
+ page?: number;
575
+ pageSize?: number;
576
+ };
577
+ type CountAnswersWithinRangeOptions = BaseApiParams;
578
+ /**
579
+ * Quran answers API methods.
580
+ */
581
+ declare class QuranAnswers {
582
+ private fetcher;
583
+ constructor(fetcher: QuranFetchClient);
584
+ /**
585
+ * Get published answer questions linked to a specific ayah.
586
+ * @param {VerseKey} key verse key in format "chapter:verse" (e.g., "2:255")
587
+ * @param {GetAnswersByAyahOptions} options
588
+ * @example
589
+ * client.answers.findByAyah("2:255", { page: 1, pageSize: 2 })
590
+ */
591
+ findByAyah(key: VerseKey, options?: GetAnswersByAyahOptions): Promise<AnswersByAyahResponse>;
592
+ /**
593
+ * Get a published answer question by id.
594
+ * @param {string | number} questionId question id
595
+ * @example
596
+ * client.answers.findByQuestionId("988")
597
+ */
598
+ findByQuestionId(questionId: string | number): Promise<AnswerQuestion>;
599
+ /**
600
+ * Get a verse-key to answer-count map within an inclusive ayah range.
601
+ * @param {VerseKey} from start verse key in format "chapter:verse"
602
+ * @param {VerseKey} to end verse key in format "chapter:verse"
603
+ * @param {CountAnswersWithinRangeOptions} options
604
+ * @example
605
+ * client.answers.countWithinRange("2:255", "2:256")
606
+ */
607
+ countWithinRange(from: VerseKey, to: VerseKey, options?: CountAnswersWithinRangeOptions): Promise<AnswerCountWithinRangeResponse>;
608
+ }
609
+
497
610
  type GetChapterRecitationOptions = BaseApiParams;
498
611
  type GetVerseRecitationOptions = BaseApiParams & {
499
612
  fields?: Partial<Record<VerseRecitationField, boolean>>;
@@ -739,6 +852,22 @@ declare class QuranResources {
739
852
  * client.resources.findVerseMedia()
740
853
  */
741
854
  findVerseMedia(options?: GetResourceOptions): Promise<VerseMediaResource>;
855
+ /**
856
+ * Bootstrap or incrementally sync public content resources.
857
+ * @param {ContentSyncOptions} options
858
+ * @example
859
+ * client.resources.sync({ bootstrap: true, resources: "translations:19" })
860
+ */
861
+ sync<TData extends Record<string, unknown> = Record<string, unknown>>(options?: ContentSyncOptions): Promise<ContentSyncResponse<TData>>;
862
+ /**
863
+ * Fetch the current full snapshot for a syncable public content resource.
864
+ * @param {ContentSyncResourceGroup} resourceGroup
865
+ * @param {string | number} id
866
+ * @param {ContentResourceSnapshotOptions} options
867
+ * @example
868
+ * client.resources.findSnapshot("translations", 19)
869
+ */
870
+ findSnapshot<TRecord extends Record<string, unknown> = Record<string, unknown>>(resourceGroup: ContentSyncResourceGroup, id: string | number, options?: ContentResourceSnapshotOptions): Promise<ContentResourceSnapshot<TRecord>>;
742
871
  }
743
872
 
744
873
  type SearchOptions = Omit<SearchParams, "query">;
@@ -844,4 +973,4 @@ declare class QuranVerses {
844
973
  findRandom(options?: GetVerseOptions): Promise<Verse>;
845
974
  }
846
975
 
847
- export { type AudioResponse as A, type RecitationResource as B, type ChapterId as C, type RecitationInfoResource as D, type TranslationResource as E, type TranslationInfoResource as F, type TafsirResource as G, type HizbNumber as H, type TafsirInfoResource as I, type JuzNumber as J, type RecitationStylesResource as K, type LanguageResource as L, type ChapterInfoResource as M, type NormalizedVerseRecitation as N, type VerseMediaResource as O, type PageNumber as P, QuranChapters as Q, type RubNumber as R, type SearchResponse as S, type TranslatedName as T, type ChapterReciterResource as U, type VerseKey as V, type Word as W, SearchNavigationType as X, type SearchResult as Y, QuranVerses as a, QuranJuzs as b, QuranAudio as c, QuranHadithReferences as d, QuranResources as e, QuranSearch as f, type ChapterRecitation as g, type VerseRecitation as h, type Chapter as i, type ChapterInfo as j, type ChapterInfoResponse as k, type HadithReference as l, type HadithReferencesByAyahResponse as m, type HadithGrade as n, type HadithContent as o, type Hadith as p, type HadithsByAyahResponse as q, type HadithCountWithinRangeResponse as r, type Segment as s, type Tafsir as t, type Translation as u, type Transliteration as v, type Verse as w, CharType as x, type Juz as y, type Pagination as z };
976
+ export { type VerseMediaResource as $, type Answer as A, type Translation as B, type ChapterId as C, type Transliteration as D, type Verse as E, CharType as F, type Juz as G, type HizbNumber as H, type Pagination as I, type JuzNumber as J, type RecitationResource as K, type RecitationInfoResource as L, type TranslationResource as M, type NormalizedVerseRecitation as N, type TranslationInfoResource as O, type PageNumber as P, QuranChapters as Q, type RubNumber as R, type SearchResponse as S, type TranslatedName as T, type TafsirResource as U, type VerseKey as V, type Word as W, type TafsirInfoResource as X, type RecitationStylesResource as Y, type LanguageResource as Z, type ChapterInfoResource as _, QuranAnswers as a, type ChapterReciterResource as a0, type ContentSyncResourceGroup as a1, type ContentSyncMutationType as a2, type ContentSyncOptions as a3, type ContentResourceSnapshotOptions as a4, type ContentSyncMutation as a5, type ContentSyncResponse as a6, type ContentResourceSnapshot as a7, SearchNavigationType as a8, type SearchResult as a9, QuranVerses as b, QuranJuzs as c, QuranAudio as d, QuranHadithReferences as e, QuranResources as f, QuranSearch as g, type AnswerQuestion as h, type AnswersByAyahResponse as i, type AnswerCount as j, type AnswerCountWithinRangeResponse as k, type ChapterRecitation as l, type VerseRecitation as m, type AudioResponse as n, type Chapter as o, type ChapterInfo as p, type ChapterInfoResponse as q, type HadithReference as r, type HadithReferencesByAyahResponse as s, type HadithGrade as t, type HadithContent as u, type Hadith as v, type HadithsByAyahResponse as w, type HadithCountWithinRangeResponse as x, type Segment as y, type Tafsir as z };
@@ -1,4 +1,4 @@
1
- import { e as QuranFetchClient, B as BaseApiParams, b as VerseRecitationField, d as SearchParams, P as PaginationParams, W as WordField, T as TranslationField, V as VerseField } from './index-BZgqOfA4.js';
1
+ import { A as ApiParams, e as QuranFetchClient, B as BaseApiParams, b as VerseRecitationField, d as SearchParams, P as PaginationParams, W as WordField, T as TranslationField, V as VerseField } from './index-BgoJducH.js';
2
2
 
3
3
  /**
4
4
  * Maps chapter number to verse count
@@ -197,6 +197,36 @@ interface SearchResponse {
197
197
  };
198
198
  }
199
199
 
200
+ interface Answer {
201
+ id: string | number;
202
+ body: string;
203
+ answeredBy?: string;
204
+ status: string;
205
+ language?: string;
206
+ }
207
+ interface AnswerQuestion {
208
+ id: string | number;
209
+ body: string;
210
+ type: string;
211
+ ranges: VerseKey[];
212
+ surah: number;
213
+ theme?: string[];
214
+ summary?: string;
215
+ references?: string[];
216
+ language?: string;
217
+ status: string;
218
+ answers: Answer[];
219
+ }
220
+ interface AnswersByAyahResponse {
221
+ questions: AnswerQuestion[];
222
+ totalCount?: number;
223
+ }
224
+ interface AnswerCount {
225
+ types?: Record<string, number>;
226
+ total: number;
227
+ }
228
+ type AnswerCountWithinRangeResponse = Record<string, AnswerCount>;
229
+
200
230
  /**
201
231
  * Segment structure is [wordFrom, wordTo, timeFrom, timeTo] time is in ms
202
232
  */
@@ -320,6 +350,52 @@ interface ChapterReciterResource {
320
350
  format?: string;
321
351
  filesSize?: number;
322
352
  }
353
+ type ContentSyncResourceGroup = "articles" | "recitations" | "tafsirs" | "translations";
354
+ type ContentSyncMutationType = "RESOURCE_CREATE" | "RESOURCE_UPDATE" | "RESOURCE_DELETE" | "ROW_CREATE" | "ROW_UPDATE" | "ROW_DELETE" | "RESOURCE_INVALIDATE";
355
+ interface ContentSyncOptions extends ApiParams {
356
+ /** Resource filter, e.g. `articles:*;translations:1,6`. */
357
+ resources?: string;
358
+ /** Set to true for the initial sync. */
359
+ bootstrap?: boolean;
360
+ /** Token returned by the final bootstrap or incremental page. */
361
+ syncToken?: string;
362
+ /** Pagination cursor from `nextPageUrl`. */
363
+ cursor?: string;
364
+ /** Page size, up to the API maximum. */
365
+ perPage?: number;
366
+ }
367
+ type ContentResourceSnapshotOptions = ApiParams;
368
+ interface ContentSyncMutation<TData extends Record<string, unknown> = Record<string, unknown>> {
369
+ sequence: number;
370
+ type: ContentSyncMutationType;
371
+ resourceGroup: ContentSyncResourceGroup;
372
+ resourceId: number;
373
+ resourceContentId: number | null;
374
+ recordType: string | null;
375
+ recordKey: string | null;
376
+ sourceRecordId: number | null;
377
+ changedAt: string;
378
+ data: TData | null;
379
+ snapshotUrl: string | null;
380
+ unavailableReason: string | null;
381
+ }
382
+ interface ContentSyncResponse<TData extends Record<string, unknown> = Record<string, unknown>> {
383
+ sync: {
384
+ syncUntilSequence: number;
385
+ hasMore: boolean;
386
+ nextPageUrl: string | null;
387
+ nextSyncToken: string | null;
388
+ mutations: ContentSyncMutation<TData>[];
389
+ };
390
+ }
391
+ interface ContentResourceSnapshot<TRecord extends Record<string, unknown> = Record<string, unknown>> {
392
+ resourceGroup: ContentSyncResourceGroup;
393
+ resourceId: number;
394
+ resourceContentId: number | null;
395
+ schemaVersion: number;
396
+ syncSequence: number;
397
+ records: TRecord[];
398
+ }
323
399
 
324
400
  interface ChapterInfo {
325
401
  id: number;
@@ -494,6 +570,43 @@ interface Pagination {
494
570
  totalRecords: number;
495
571
  }
496
572
 
573
+ type GetAnswersByAyahOptions = BaseApiParams & {
574
+ page?: number;
575
+ pageSize?: number;
576
+ };
577
+ type CountAnswersWithinRangeOptions = BaseApiParams;
578
+ /**
579
+ * Quran answers API methods.
580
+ */
581
+ declare class QuranAnswers {
582
+ private fetcher;
583
+ constructor(fetcher: QuranFetchClient);
584
+ /**
585
+ * Get published answer questions linked to a specific ayah.
586
+ * @param {VerseKey} key verse key in format "chapter:verse" (e.g., "2:255")
587
+ * @param {GetAnswersByAyahOptions} options
588
+ * @example
589
+ * client.answers.findByAyah("2:255", { page: 1, pageSize: 2 })
590
+ */
591
+ findByAyah(key: VerseKey, options?: GetAnswersByAyahOptions): Promise<AnswersByAyahResponse>;
592
+ /**
593
+ * Get a published answer question by id.
594
+ * @param {string | number} questionId question id
595
+ * @example
596
+ * client.answers.findByQuestionId("988")
597
+ */
598
+ findByQuestionId(questionId: string | number): Promise<AnswerQuestion>;
599
+ /**
600
+ * Get a verse-key to answer-count map within an inclusive ayah range.
601
+ * @param {VerseKey} from start verse key in format "chapter:verse"
602
+ * @param {VerseKey} to end verse key in format "chapter:verse"
603
+ * @param {CountAnswersWithinRangeOptions} options
604
+ * @example
605
+ * client.answers.countWithinRange("2:255", "2:256")
606
+ */
607
+ countWithinRange(from: VerseKey, to: VerseKey, options?: CountAnswersWithinRangeOptions): Promise<AnswerCountWithinRangeResponse>;
608
+ }
609
+
497
610
  type GetChapterRecitationOptions = BaseApiParams;
498
611
  type GetVerseRecitationOptions = BaseApiParams & {
499
612
  fields?: Partial<Record<VerseRecitationField, boolean>>;
@@ -739,6 +852,22 @@ declare class QuranResources {
739
852
  * client.resources.findVerseMedia()
740
853
  */
741
854
  findVerseMedia(options?: GetResourceOptions): Promise<VerseMediaResource>;
855
+ /**
856
+ * Bootstrap or incrementally sync public content resources.
857
+ * @param {ContentSyncOptions} options
858
+ * @example
859
+ * client.resources.sync({ bootstrap: true, resources: "translations:19" })
860
+ */
861
+ sync<TData extends Record<string, unknown> = Record<string, unknown>>(options?: ContentSyncOptions): Promise<ContentSyncResponse<TData>>;
862
+ /**
863
+ * Fetch the current full snapshot for a syncable public content resource.
864
+ * @param {ContentSyncResourceGroup} resourceGroup
865
+ * @param {string | number} id
866
+ * @param {ContentResourceSnapshotOptions} options
867
+ * @example
868
+ * client.resources.findSnapshot("translations", 19)
869
+ */
870
+ findSnapshot<TRecord extends Record<string, unknown> = Record<string, unknown>>(resourceGroup: ContentSyncResourceGroup, id: string | number, options?: ContentResourceSnapshotOptions): Promise<ContentResourceSnapshot<TRecord>>;
742
871
  }
743
872
 
744
873
  type SearchOptions = Omit<SearchParams, "query">;
@@ -844,4 +973,4 @@ declare class QuranVerses {
844
973
  findRandom(options?: GetVerseOptions): Promise<Verse>;
845
974
  }
846
975
 
847
- export { type AudioResponse as A, type RecitationResource as B, type ChapterId as C, type RecitationInfoResource as D, type TranslationResource as E, type TranslationInfoResource as F, type TafsirResource as G, type HizbNumber as H, type TafsirInfoResource as I, type JuzNumber as J, type RecitationStylesResource as K, type LanguageResource as L, type ChapterInfoResource as M, type NormalizedVerseRecitation as N, type VerseMediaResource as O, type PageNumber as P, QuranChapters as Q, type RubNumber as R, type SearchResponse as S, type TranslatedName as T, type ChapterReciterResource as U, type VerseKey as V, type Word as W, SearchNavigationType as X, type SearchResult as Y, QuranVerses as a, QuranJuzs as b, QuranAudio as c, QuranHadithReferences as d, QuranResources as e, QuranSearch as f, type ChapterRecitation as g, type VerseRecitation as h, type Chapter as i, type ChapterInfo as j, type ChapterInfoResponse as k, type HadithReference as l, type HadithReferencesByAyahResponse as m, type HadithGrade as n, type HadithContent as o, type Hadith as p, type HadithsByAyahResponse as q, type HadithCountWithinRangeResponse as r, type Segment as s, type Tafsir as t, type Translation as u, type Transliteration as v, type Verse as w, CharType as x, type Juz as y, type Pagination as z };
976
+ export { type VerseMediaResource as $, type Answer as A, type Translation as B, type ChapterId as C, type Transliteration as D, type Verse as E, CharType as F, type Juz as G, type HizbNumber as H, type Pagination as I, type JuzNumber as J, type RecitationResource as K, type RecitationInfoResource as L, type TranslationResource as M, type NormalizedVerseRecitation as N, type TranslationInfoResource as O, type PageNumber as P, QuranChapters as Q, type RubNumber as R, type SearchResponse as S, type TranslatedName as T, type TafsirResource as U, type VerseKey as V, type Word as W, type TafsirInfoResource as X, type RecitationStylesResource as Y, type LanguageResource as Z, type ChapterInfoResource as _, QuranAnswers as a, type ChapterReciterResource as a0, type ContentSyncResourceGroup as a1, type ContentSyncMutationType as a2, type ContentSyncOptions as a3, type ContentResourceSnapshotOptions as a4, type ContentSyncMutation as a5, type ContentSyncResponse as a6, type ContentResourceSnapshot as a7, SearchNavigationType as a8, type SearchResult as a9, QuranVerses as b, QuranJuzs as c, QuranAudio as d, QuranHadithReferences as e, QuranResources as f, QuranSearch as g, type AnswerQuestion as h, type AnswersByAyahResponse as i, type AnswerCount as j, type AnswerCountWithinRangeResponse as k, type ChapterRecitation as l, type VerseRecitation as m, type AudioResponse as n, type Chapter as o, type ChapterInfo as p, type ChapterInfoResponse as q, type HadithReference as r, type HadithReferencesByAyahResponse as s, type HadithGrade as t, type HadithContent as u, type Hadith as v, type HadithsByAyahResponse as w, type HadithCountWithinRangeResponse as x, type Segment as y, type Tafsir as z };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "version": "3.2.1",
14
+ "version": "3.4.0",
15
15
  "main": "dist/index.min.js",
16
16
  "module": "dist/index.min.mjs",
17
17
  "types": "dist/index.d.ts",
@@ -1,3 +0,0 @@
1
- type RawOperation = (request?: unknown) => Promise<unknown>;
2
-
3
- export type { RawOperation as R };
@@ -1,3 +0,0 @@
1
- type RawOperation = (request?: unknown) => Promise<unknown>;
2
-
3
- export type { RawOperation as R };