@quranjs/api 2.2.0 → 3.0.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.
@@ -0,0 +1,212 @@
1
+ import { R as RawOperation } from './runtime-utils-CxjOQDsB.js';
2
+ import { j as PublicClientConfig, A as ApiParams, U as UserSession, l as TokenResponse, O as OperationRequest } from './index-BZgqOfA4.js';
3
+
4
+ declare const createPublicClient: (config: PublicClientConfig) => {
5
+ audio: ((...args: unknown[]) => Promise<never>) & {
6
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
7
+ };
8
+ auth: {
9
+ v1: {
10
+ collections: {
11
+ addBookmark: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
12
+ create: (body: Record<string, unknown>) => Promise<unknown>;
13
+ get: (collectionId: string, query?: ApiParams) => Promise<unknown>;
14
+ list: (query?: ApiParams) => Promise<unknown>;
15
+ listAll: (query?: ApiParams) => Promise<unknown>;
16
+ remove: (collectionId: string) => Promise<unknown>;
17
+ removeBookmark: (collectionId: string, bookmarkId: string) => Promise<unknown>;
18
+ update: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
19
+ };
20
+ bookmarks: {
21
+ create: (body: Record<string, unknown>) => Promise<unknown>;
22
+ get: (bookmarkId: string) => Promise<unknown>;
23
+ list: (query?: ApiParams) => Promise<unknown>;
24
+ listCollections: (query?: ApiParams) => Promise<unknown>;
25
+ listRange: (query?: ApiParams) => Promise<unknown>;
26
+ remove: (bookmarkId: string) => Promise<unknown>;
27
+ };
28
+ goals: {
29
+ create: (body: Record<string, unknown>) => Promise<unknown>;
30
+ estimate: (query?: ApiParams) => Promise<unknown>;
31
+ getTodaysPlan: (query?: ApiParams) => Promise<unknown>;
32
+ remove: (id: string) => Promise<unknown>;
33
+ update: (id: string, body: Record<string, unknown>) => Promise<unknown>;
34
+ };
35
+ notes: {
36
+ create: (body: Record<string, unknown>) => Promise<unknown>;
37
+ get: (noteId: string) => Promise<unknown>;
38
+ list: (query?: ApiParams) => Promise<unknown>;
39
+ listByAttachedEntity: (query?: ApiParams) => Promise<unknown>;
40
+ listByRange: (query?: ApiParams) => Promise<unknown>;
41
+ listByVerseKey: (verseKey: string, query?: ApiParams) => Promise<unknown>;
42
+ publish: (noteId: string, body?: Record<string, unknown>) => Promise<unknown>;
43
+ remove: (noteId: string) => Promise<unknown>;
44
+ update: (noteId: string, body: Record<string, unknown>) => Promise<unknown>;
45
+ };
46
+ preferences: {
47
+ bulkUpdate: (body: Record<string, unknown>) => Promise<unknown>;
48
+ get: (query?: ApiParams) => Promise<unknown>;
49
+ update: (body: Record<string, unknown>) => Promise<unknown>;
50
+ };
51
+ raw: Record<string, RawOperation>;
52
+ readingSessions: {
53
+ create: (body: Record<string, unknown>) => Promise<unknown>;
54
+ list: (query?: ApiParams) => Promise<unknown>;
55
+ };
56
+ };
57
+ collections: {
58
+ addBookmark: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
59
+ create: (body: Record<string, unknown>) => Promise<unknown>;
60
+ get: (collectionId: string, query?: ApiParams) => Promise<unknown>;
61
+ list: (query?: ApiParams) => Promise<unknown>;
62
+ listAll: (query?: ApiParams) => Promise<unknown>;
63
+ remove: (collectionId: string) => Promise<unknown>;
64
+ removeBookmark: (collectionId: string, bookmarkId: string) => Promise<unknown>;
65
+ update: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
66
+ };
67
+ bookmarks: {
68
+ create: (body: Record<string, unknown>) => Promise<unknown>;
69
+ get: (bookmarkId: string) => Promise<unknown>;
70
+ list: (query?: ApiParams) => Promise<unknown>;
71
+ listCollections: (query?: ApiParams) => Promise<unknown>;
72
+ listRange: (query?: ApiParams) => Promise<unknown>;
73
+ remove: (bookmarkId: string) => Promise<unknown>;
74
+ };
75
+ goals: {
76
+ create: (body: Record<string, unknown>) => Promise<unknown>;
77
+ estimate: (query?: ApiParams) => Promise<unknown>;
78
+ getTodaysPlan: (query?: ApiParams) => Promise<unknown>;
79
+ remove: (id: string) => Promise<unknown>;
80
+ update: (id: string, body: Record<string, unknown>) => Promise<unknown>;
81
+ };
82
+ notes: {
83
+ create: (body: Record<string, unknown>) => Promise<unknown>;
84
+ get: (noteId: string) => Promise<unknown>;
85
+ list: (query?: ApiParams) => Promise<unknown>;
86
+ listByAttachedEntity: (query?: ApiParams) => Promise<unknown>;
87
+ listByRange: (query?: ApiParams) => Promise<unknown>;
88
+ listByVerseKey: (verseKey: string, query?: ApiParams) => Promise<unknown>;
89
+ publish: (noteId: string, body?: Record<string, unknown>) => Promise<unknown>;
90
+ remove: (noteId: string) => Promise<unknown>;
91
+ update: (noteId: string, body: Record<string, unknown>) => Promise<unknown>;
92
+ };
93
+ preferences: {
94
+ bulkUpdate: (body: Record<string, unknown>) => Promise<unknown>;
95
+ get: (query?: ApiParams) => Promise<unknown>;
96
+ update: (body: Record<string, unknown>) => Promise<unknown>;
97
+ };
98
+ raw: Record<string, RawOperation>;
99
+ readingSessions: {
100
+ create: (body: Record<string, unknown>) => Promise<unknown>;
101
+ list: (query?: ApiParams) => Promise<unknown>;
102
+ };
103
+ };
104
+ chapters: ((...args: unknown[]) => Promise<never>) & {
105
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
106
+ };
107
+ clearCachedTokens: () => void;
108
+ content: ((...args: unknown[]) => Promise<never>) & {
109
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
110
+ };
111
+ getUserSession: () => Promise<UserSession | null>;
112
+ juzs: ((...args: unknown[]) => Promise<never>) & {
113
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
114
+ };
115
+ oauth2: {
116
+ v1: {
117
+ authorizeUrl: (query: Record<string, string | number | undefined>) => string;
118
+ exchangeCode: (params: {
119
+ code: string;
120
+ codeVerifier?: string;
121
+ redirectUri: string;
122
+ scope?: string;
123
+ }) => Promise<TokenResponse>;
124
+ getUserInfo: (accessToken?: string) => Promise<unknown>;
125
+ introspect: () => never;
126
+ logout: (query?: ApiParams) => Promise<unknown>;
127
+ raw: Record<string, RawOperation>;
128
+ refresh: (refreshToken?: string) => Promise<TokenResponse>;
129
+ };
130
+ authorizeUrl: (query: Record<string, string | number | undefined>) => string;
131
+ exchangeCode: (params: {
132
+ code: string;
133
+ codeVerifier?: string;
134
+ redirectUri: string;
135
+ scope?: string;
136
+ }) => Promise<TokenResponse>;
137
+ getUserInfo: (accessToken?: string) => Promise<unknown>;
138
+ introspect: () => never;
139
+ logout: (query?: ApiParams) => Promise<unknown>;
140
+ raw: Record<string, RawOperation>;
141
+ refresh: (refreshToken?: string) => Promise<TokenResponse>;
142
+ };
143
+ quranReflect: {
144
+ v1: {
145
+ comments: {
146
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
147
+ };
148
+ posts: {
149
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
150
+ };
151
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
152
+ rooms: {
153
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
154
+ };
155
+ tags: {
156
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
157
+ };
158
+ users: {
159
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
160
+ };
161
+ };
162
+ comments: {
163
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
164
+ };
165
+ posts: {
166
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
167
+ };
168
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
169
+ rooms: {
170
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
171
+ };
172
+ tags: {
173
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
174
+ };
175
+ users: {
176
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
177
+ };
178
+ };
179
+ raw: {
180
+ auth: {
181
+ v1: Record<string, RawOperation>;
182
+ };
183
+ content: {
184
+ v4: ((...args: unknown[]) => Promise<never>) & {
185
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
186
+ };
187
+ };
188
+ oauth2: {
189
+ v1: Record<string, RawOperation>;
190
+ };
191
+ quranReflect: {
192
+ v1: Record<string, (request?: OperationRequest) => Promise<unknown>>;
193
+ };
194
+ search: {
195
+ v1: ((...args: unknown[]) => Promise<never>) & {
196
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
197
+ };
198
+ };
199
+ };
200
+ resources: ((...args: unknown[]) => Promise<never>) & {
201
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
202
+ };
203
+ search: ((...args: unknown[]) => Promise<never>) & {
204
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
205
+ };
206
+ verses: ((...args: unknown[]) => Promise<never>) & {
207
+ [key: string]: (((...args: unknown[]) => Promise<never>) & /*elided*/ any) | undefined;
208
+ };
209
+ };
210
+ type PublicClient = ReturnType<typeof createPublicClient>;
211
+
212
+ export { type PublicClient, createPublicClient };
@@ -0,0 +1,3 @@
1
+ 'use strict';var L=require('humps');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var L__default=/*#__PURE__*/_interopDefault(L);var T={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}}};var l=T;var b=(o,t)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&t.set("Content-Type",o.contentType),o.body):(t.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},R=(o,t)=>{let s=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,e=o.idToken??o.id_token??t?.idToken,n=o.refreshToken??o.refresh_token??t?.refreshToken,a=o.tokenType??o.token_type??t?.tokenType,u=o.scope??t?.scope,p=s?Date.now()+s*1e3:t?.expiresAt;return {accessToken:r,expiresAt:p,idToken:e,refreshToken:n,scope:u,tokenType:a}};var k=(o,t,s)=>({...s,operationName:s.operationName??t,service:s.service??o.service,tags:s.tags??[],version:s.version??o.version});var w={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},d=o=>{let t=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return t.length===0?"misc":t.map((s,r)=>{let e=s.toLowerCase();return r===0?e:e.charAt(0).toUpperCase()+e.slice(1)}).join("")},N=o=>{let t=d(o);return t.charAt(0).toUpperCase()+t.slice(1)},h=o=>o.startsWith("{")&&o.endsWith("}"),O=o=>{let t=o.split("/").filter(Boolean);return t[0]?.match(/^v\d+$/)?t.slice(1):t},F=o=>{let t=O(o.path),s=t.at(-1),r=t.filter(a=>!h(a)),e=r.at(-1),n=r[0];return t.length===1?w[o.method]:t.length===2&&s&&h(s)?o.method==="get"?"get":o.method==="delete"?"remove":"update":s&&!h(s)&&e?e===n?`${w[o.method]}ById`:d(e):d(o.operationName)},m=(o,t)=>{let s={};for(let[r,e]of Object.entries(t.operations)){let n=k(t,r,e);s[r]=a=>o.requestOperation(n,a);}return s},y=(o,t)=>{let s={};for(let[r,e]of Object.entries(o.operations)){let n=k(o,r,e),a=O(n.path).filter(f=>!h(f)),u=d(a[0]??"misc"),p=F(n),i=s[u]??{},c=p;i[c]&&(c=`${p}${N(r)}`),i[c]=t[r],s[u]=i;}return s};var{decamelize:C}=L__default.default,P=o=>o.startsWith("/")?o:`/${o}`,S=o=>o.endsWith("/")?o.slice(0,-1):o;var g=(o,t)=>o.replace(/\{([^}]+)\}/g,(s,r)=>{let e=t?.[r];if(e===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(e))}),E=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),A=["wordFields","translationFields","fields"],G=new Set([...A,...A.map(o=>C(o))]),H=new Set(["navigationalResultsNumber","versesResultsNumber"]),U=o=>{if(!o)return "";let t=new URLSearchParams;for(let[s,r]of Object.entries(o)){if(r===void 0)continue;let e=H.has(s)?s:C(s);if(G.has(s)||G.has(e)){let n=Object.entries(r).filter(([,a])=>a).map(([a])=>C(a));n.length>0&&t.set(e,n.join(","));continue}typeof r=="string"?t.set(e,r):typeof r=="number"||typeof r=="boolean"?t.set(e,r.toString()):Array.isArray(r)&&t.set(e,r.join(","));}return t.size===0?"":`?${t.toString()}`};var I={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},x={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},B={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},q={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:j}=L__default.default,v=class{constructor(t){this.config=t;this.userSession=t.userSession;}userSession;clearCachedTokens(){}getFetch(){let t=this.config.fetch??globalThis.fetch;if(typeof t!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return t}async getUserSession(){let t=await this.config.storage?.getSession?.();return t!==void 0?t:this.userSession??null}async setUserSession(t){if(!this.config.storage){this.userSession=t;return}if(!t){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(t),this.userSession=t;}buildServiceUrl(t,s,r){let{baseUrl:e,usesGateway:n}=this.resolveServiceBaseUrl(t),a=this.normalizeServicePath(t,s,n);return `${e}${a}${U(r)}`}async requestOperation(t,s){return this.request(t.service,g(t.path,s?.path),s?.query,{...s,auth:s?.auth==="auto"||!s?.auth?t.auth:s.auth,method:s?.method??t.method.toUpperCase(),path:void 0})}async request(t,s,r,e={}){if(e.basicAuth)throw new Error("client_secret is server-only. Use @quranjs/api/server.");let n=this.resolveAuthMode(t,e.auth),a=this.buildServiceUrl(t,s,r),u=new Headers(e.headers),p=b(e,u);t!=="oauth2"&&u.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(t,n,u,e);let i=await this.getFetch()(a,{body:p,headers:u,method:e.method??"GET"});if(!i.ok)throw new Error(`${i.status} ${i.statusText}`);if(i.status===204)return;if(!(i.headers.get("content-type")??"").includes("application/json"))return await i.text();let f=await i.json();return j(f)}resolveAuthMode(t,s="auto"){if(s!=="auto"){if(s==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");return s}return t==="auth"||t==="quranReflect"?"user":"none"}async applyAuthenticationHeaders(t,s,r,e){if(e.accessToken){this.setTokenHeaders(t,r,e.accessToken);return}if(s==="none")return;let n=await this.getUserSession();if(!n?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(t,r,n.accessToken);}setTokenHeaders(t,s,r){if(t==="oauth2"){s.set("Authorization",`Bearer ${r}`);return}s.set("x-auth-token",r);}resolveServiceBaseUrl(t){let{services:s}=this.config,r=t==="auth"?s?.authBaseUrl:t==="quranReflect"?s?.quranReflectBaseUrl:s?.oauth2BaseUrl??s?.tokenHost;return r?{baseUrl:S(r),usesGateway:false}:s?.gatewayUrl&&t!=="oauth2"?{baseUrl:S(s.gatewayUrl),usesGateway:true}:{baseUrl:I[t],usesGateway:false}}normalizeServicePath(t,s,r){let e=P(E(s));for(let a of q[t])if(e.startsWith(a)){e=P(e.slice(a.length));break}let n=r?B[t]:x[t];return e.startsWith(n)||n.length===0?e:`${n}${e}`}};var V="This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.",$=(o,t)=>(s,r,e)=>o.request(t,g(r,e?.path),e?.query,{...e,auth:"user",method:s,path:void 0,query:void 0}),z=o=>{let t=m(o,l.auth.v1),s=y(l.auth.v1,t),r=$(o,"auth");return {...s,collections:{...s.collections,addBookmark:(e,n)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:e}}),create:e=>r("POST","/v1/collections",{body:e}),get:(e,n)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:e},query:n}),list:e=>r("GET","/v1/collections",{query:e}),listAll:e=>r("GET","/v1/collections/all",{query:e}),remove:e=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:e}}),removeBookmark:(e,n)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:e}}),update:(e,n)=>r("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:e}})},bookmarks:{...s.bookmarks,create:e=>r("POST","/v1/bookmarks",{body:e}),get:e=>r("GET","/v1/bookmarks/bookmark",{query:{bookmarkId:e}}),list:e=>r("GET","/v1/bookmarks",{query:e}),listCollections:e=>r("GET","/v1/bookmarks/collections",{query:e}),listRange:e=>r("GET","/v1/bookmarks/ayahs-range",{query:e}),remove:e=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:e}})},goals:{...s.goals,create:e=>r("POST","/v1/goals",{body:e}),estimate:e=>r("GET","/v1/goals/estimate",{query:e}),getTodaysPlan:e=>r("GET","/v1/goals/get-todays-plan",{query:e}),remove:e=>r("DELETE","/v1/goals/{id}",{path:{id:e}}),update:(e,n)=>r("PUT","/v1/goals/{id}",{body:n,path:{id:e}})},notes:{...s.notes,create:e=>r("POST","/v1/notes",{body:e}),get:e=>r("GET","/v1/notes/{noteId}",{path:{noteId:e}}),list:e=>r("GET","/v1/notes",{query:e}),listByAttachedEntity:e=>r("GET","/v1/notes/by-attached-entity",{query:e}),listByRange:e=>r("GET","/v1/notes/by-range",{query:e}),listByVerseKey:(e,n)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:e},query:n}),publish:(e,n)=>r("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:e}}),remove:e=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:e}}),update:(e,n)=>r("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:e}})},preferences:{...s.preferences,bulkUpdate:e=>r("POST","/v1/preferences/bulk",{body:e}),get:e=>r("GET","/v1/preferences",{query:e}),update:e=>r("POST","/v1/preferences",{body:e})},raw:t,readingSessions:{...s.readingSessions,create:e=>r("POST","/v1/reading-sessions",{body:e}),list:e=>r("GET","/v1/reading-sessions",{query:e})}}},W=o=>{let t=m(o,l.quranReflect.v1),s=y(l.quranReflect.v1,t);return {comments:s.comments??{},posts:s.posts??{},raw:t,rooms:s.rooms??{},tags:s.tags??{},users:s.users??{}}},K=(o,t)=>{let s=m(o,l.oauth2.v1),r=async(e,n={})=>{if(t.clientType!=="public")throw new Error("This OAuth2 exchange requires a backend because your client is confidential.");if(n.requiresRefreshToken&&!e.get("refresh_token"))throw new Error("Missing refresh token.");e.set("client_id",t.clientId);let a=e.get("refresh_token")??void 0,u=n.requiresRefreshToken?await o.getUserSession():null,p=n.requiresRefreshToken&&a?{...u??{},refreshToken:a}:u,i=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",body:e,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(R(i,p)),i};return {authorizeUrl:e=>o.buildServiceUrl("oauth2","/oauth2/auth",e),exchangeCode:e=>{let n=new URLSearchParams({code:e.code,grant_type:"authorization_code",redirect_uri:e.redirectUri});return e.codeVerifier&&n.set("code_verifier",e.codeVerifier),e.scope&&n.set("scope",e.scope),r(n)},getUserInfo:e=>o.request("oauth2","/userinfo",void 0,{accessToken:e,auth:"user",method:"GET"}),introspect:()=>{throw new Error("Token introspection requires @quranjs/api/server or a backend.")},logout:e=>o.request("oauth2","/oauth2/sessions/logout",e,{auth:"none",method:"GET"}),raw:s,refresh:async e=>{let n=await o.getUserSession(),a=new URLSearchParams({grant_type:"refresh_token",refresh_token:e??n?.refreshToken??""});return r(a,{requiresRefreshToken:true})}}},Q=()=>{let o=()=>Promise.reject(new Error(V)),t=new Proxy(o,{apply(){return Promise.reject(new Error(V))},get(s,r){if(r!=="then")return t}});return t},_=o=>{let t=new v(o);t.getFetch();let s=z(t),r=W(t),e=K(t,o),n=Q(),a={auth:{v1:s.raw},content:{v4:n},oauth2:{v1:e.raw},quranReflect:{v1:r.raw},search:{v1:n}};return {audio:n,auth:{...s,v1:s},chapters:n,clearCachedTokens:()=>t.clearCachedTokens(),content:n,getUserSession:()=>t.getUserSession(),juzs:n,oauth2:{...e,v1:e},quranReflect:{...r,v1:r},raw:a,resources:n,search:n,verses:n}};var ye=o=>{if(o.clientSecret)throw new Error("client_secret is server-only. Use @quranjs/api/server.");return _(o)};
2
+ exports.createPublicClient=ye;//# sourceMappingURL=public.min.js.map
3
+ //# sourceMappingURL=public.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generated/specs/public-operation-catalog.json","../src/generated/public-contracts.ts","../src/lib/http-utils.ts","../src/generated/contracts.ts","../src/lib/runtime-utils.ts","../src/lib/url.ts","../src/lib/service-config.ts","../src/sdk/public-fetcher.ts","../src/runtime/create-public-client.ts","../src/public.ts"],"names":["public_operation_catalog_default","publicOperationCatalog","prepareBody","request","headers","toUserSession","token","currentSession","expiresIn","accessToken","idToken","refreshToken","tokenType","scope","expiresAt","resolveCatalogOperation","section","operationName","operation","HTTP_METHOD_TO_MUTATION_NAME","toCamelCase","value","parts","part","index","lower","toPascalCase","camel","isPathParam","segment","getResourceSegments","path","segments","pickGeneratedMethodName","resourceSegments","lastSegment","literalSegments","lastLiteral","groupLiteral","createRawClient","fetcher","rawOperations","resolvedOperation","createGeneratedGroups","groups","literals","groupName","suggestedName","currentGroup","methodName","decamelize","humps","ensureLeadingSlash","removeTrailingSlash","replacePathParams","params","_match","rawKey","normalizePathTemplate","fieldsKey","fieldsKeySet","key","preservedKeys","paramsToString","paramsString","rawValue","fields","fieldKey","DEFAULT_BASE_URLS","DIRECT_PATH_PREFIX","GATEWAY_PATH_PREFIX","LEGACY_PREFIXES","camelizeKeys","PublicQuranFetcher","config","doFetch","storedSession","session","service","query","baseUrl","usesGateway","servicePath","effectiveAuth","url","body","response","json","auth","services","directBaseUrl","normalizedPath","legacyPrefix","prefix","SERVER_ONLY_MESSAGE","createUserServiceRequest","method","createAuthFacade","raw","generatedGroups","collectionId","bookmarkId","id","noteId","verseKey","createQuranReflectFacade","createOAuth2Facade","exchangeToken","options","requestRefreshToken","createServerOnlyGuard","fail","proxy","_target","property","createPublicRuntimeClient","authV1","quranReflectV1","oauth2V1","serverOnlyGuard","createPublicClient"],"mappings":"oJAAA,IAAAA,CAAAA,CAAA,CACE,IAAA,CAAQ,CACN,GAAM,CACJ,UAAA,CAAc,CACZ,gBAAA,CAAoB,CAClB,KAAQ,MAAA,CACR,MAAA,CAAU,MACV,IAAA,CAAQ,iBACV,EACA,iBAAA,CAAqB,CACnB,IAAA,CAAQ,MAAA,CACR,MAAA,CAAU,MAAA,CACV,KAAQ,iBACV,CAAA,CACA,yCAA4C,CAC1C,IAAA,CAAQ,OACR,MAAA,CAAU,MAAA,CACV,KAAQ,0CACV,CAAA,CACA,2CAA8C,CAC5C,IAAA,CAAQ,OACR,MAAA,CAAU,QAAA,CACV,KAAQ,0CACV,CAAA,CACA,8BAAA,CAAkC,CAChC,IAAA,CAAQ,MAAA,CACR,OAAU,KAAA,CACV,IAAA,CAAQ,gCACV,CAAA,CACA,+BAAA,CAAmC,CACjC,IAAA,CAAQ,MAAA,CACR,OAAU,MAAA,CACV,IAAA,CAAQ,gCACV,CAAA,CACA,iCAAA,CAAqC,CACnC,IAAA,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"auth\": {\n \"v1\": {\n \"operations\": {\n \"getV1Collections\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/collections\"\n },\n \"postV1Collections\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/collections\"\n },\n \"postV1CollectionsByCollectionIdBookmarks\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/collections/{collectionId}/bookmarks\"\n },\n \"deleteV1CollectionsByCollectionIdBookmarks\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/collections/{collectionId}/bookmarks\"\n },\n \"getV1CollectionsByCollectionId\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/collections/{collectionId}\"\n },\n \"postV1CollectionsByCollectionId\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/collections/{collectionId}\"\n },\n \"deleteV1CollectionsByCollectionId\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/collections/{collectionId}\"\n },\n \"deleteV1CollectionsByCollectionIdBookmarksByBookmarkId\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/collections/{collectionId}/bookmarks/{bookmarkId}\"\n },\n \"getV1CollectionsAll\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/collections/all\"\n },\n \"getV1Bookmarks\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/bookmarks\"\n },\n \"postV1Bookmarks\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/bookmarks\"\n },\n \"deleteV1BookmarksByBookmarkId\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/bookmarks/{bookmarkId}\"\n },\n \"getV1BookmarksAyahsRange\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/bookmarks/ayahs-range\"\n },\n \"getV1BookmarksBookmark\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/bookmarks/bookmark\"\n },\n \"getV1BookmarksCollections\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/bookmarks/collections\"\n },\n \"getV1Preferences\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/preferences\"\n },\n \"postV1Preferences\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/preferences\"\n },\n \"postV1PreferencesBulk\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/preferences/bulk\"\n },\n \"getV1ReadingSessions\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/reading-sessions\"\n },\n \"postV1ReadingSessions\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/reading-sessions\"\n },\n \"getV1GoalsGetTodaysPlan\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/goals/get-todays-plan\"\n },\n \"putV1GoalsById\": {\n \"auth\": \"user\",\n \"method\": \"put\",\n \"path\": \"/v1/goals/{id}\"\n },\n \"deleteV1GoalsById\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/goals/{id}\"\n },\n \"postV1Goals\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/goals\"\n },\n \"getV1GoalsEstimate\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/goals/estimate\"\n },\n \"getV1Streaks\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/streaks\"\n },\n \"getV1StreaksCurrentStreakDays\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/streaks/current-streak-days\"\n },\n \"getV1ActivityDays\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/activity-days\"\n },\n \"postV1ActivityDays\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/activity-days\"\n },\n \"getV1ActivityDaysEstimateReadingTime\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/activity-days/estimate-reading-time\"\n },\n \"getV1Notes\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes\"\n },\n \"postV1Notes\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/notes\"\n },\n \"getV1NotesByVerseByVerseKey\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes/by-verse/{verseKey}\"\n },\n \"getV1NotesByAttachedEntity\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes/by-attached-entity\"\n },\n \"getV1NotesCountWithinRange\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes/count-within-range\"\n },\n \"getV1NotesByRange\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes/by-range\"\n },\n \"getV1NotesByNoteId\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/notes/{noteId}\"\n },\n \"patchV1NotesByNoteId\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/notes/{noteId}\"\n },\n \"deleteV1NotesByNoteId\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/notes/{noteId}\"\n },\n \"postV1NotesByNoteIdPublish\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/notes/{noteId}/publish\"\n }\n },\n \"service\": \"auth\",\n \"version\": \"v1\"\n }\n },\n \"oauth2\": {\n \"v1\": {\n \"operations\": {\n \"oauth2TokenExchange\": {\n \"auth\": \"none\",\n \"method\": \"post\",\n \"path\": \"/oauth2/token\"\n },\n \"introspectOauth2Token\": {\n \"auth\": \"none\",\n \"method\": \"post\",\n \"path\": \"/oauth2/introspect\"\n },\n \"oAuth2Authorize\": {\n \"auth\": \"none\",\n \"method\": \"get\",\n \"path\": \"/oauth2/auth\"\n },\n \"getOidcUserInfo\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/userinfo\"\n },\n \"revokeOidcSession\": {\n \"auth\": \"none\",\n \"method\": \"get\",\n \"path\": \"/oauth2/sessions/logout\"\n }\n },\n \"service\": \"oauth2\",\n \"version\": \"v1\"\n }\n },\n \"quranReflect\": {\n \"v1\": {\n \"operations\": {\n \"usersControllerProfile\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/profile\"\n },\n \"usersControllerUpdateProfile\": {\n \"auth\": \"user\",\n \"method\": \"put\",\n \"path\": \"/v1/users/profile\"\n },\n \"usersControllerEditProfile\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/users/profile\"\n },\n \"usersControllerRooms\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/my-rooms\"\n },\n \"usersControllerSearch\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/search\"\n },\n \"usersControllerToggleFollow\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/users/{followeeId}/toggle-follow\"\n },\n \"usersControllerRemoveFollower\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/users/{followerId}/remove-follower\"\n },\n \"usersControllerGetUserProfile\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/{id}\"\n },\n \"usersControllerGetUserProfile2\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/{username}/profile\"\n },\n \"usersControllerGetUserFollowers\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/{id}/followers\"\n },\n \"usersControllerGetUserFollowing\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/users/{id}/following\"\n },\n \"roomsControllerAdminsAccess\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/admins-access\"\n },\n \"roomsControllerCreateNewGroup\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/groups\"\n },\n \"roomsControllerUpdateGroup\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/rooms/groups\"\n },\n \"roomsControllerCreateNewPage\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/pages\"\n },\n \"roomsControllerUpdatePage\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/rooms/pages\"\n },\n \"roomsControllerGetRoomMembers\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/{id}/members\"\n },\n \"roomsControllerInviteUserToRoom\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/{id}/invite\"\n },\n \"roomsControllerAcceptInvite\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/{id}/accept-invite\"\n },\n \"roomsControllerRejectInvite\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/{id}/reject-invite\"\n },\n \"roomsControllerRemoveMember\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/rooms/{id}/members/{userId}\"\n },\n \"roomsControllerGetRooms\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/joined-rooms\"\n },\n \"roomsControllerGetRooms2\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/managed-rooms\"\n },\n \"roomsControllerSearchRooms\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/search\"\n },\n \"roomsControllerGetRoomProfile\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/group/{url}\"\n },\n \"roomsControllerGetRoomProfile2\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/page/{subdomain}\"\n },\n \"roomsControllerAcceptByPrivateToken\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/group/{url}/accept/{token}\"\n },\n \"roomsControllerAcceptByPrivateToken2\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/page/{subdomain}/accept/{token}\"\n },\n \"roomsControllerGetRoomProfileById\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/{id}\"\n },\n \"roomsControllerGetRoomPosts\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/rooms/{id}/posts\"\n },\n \"roomsControllerJoinRoom\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/{groupId}/join\"\n },\n \"roomsControllerLeaveGroup\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/{groupId}/leave\"\n },\n \"roomsControllerFollowPage\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/{pageId}/follow\"\n },\n \"roomsControllerUnfollowPage\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/rooms/{pageId}/unfollow\"\n },\n \"roomsControllerUpdatePostPrivacy\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/rooms/{roomId}/posts/{postId}/privacy\"\n },\n \"postsControllerFeed\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/feed\"\n },\n \"postsControllerGetRelatedPosts\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/{postId}/related\"\n },\n \"postsControllerGetLoggedinUserPosts\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/my-posts\"\n },\n \"postsControllerGetLikedState\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/{id}/liked\"\n },\n \"postsControllerFindOne\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/{id}\"\n },\n \"postsControllerEdit\": {\n \"auth\": \"user\",\n \"method\": \"patch\",\n \"path\": \"/v1/posts/{id}\"\n },\n \"postsControllerDelete\": {\n \"auth\": \"user\",\n \"method\": \"delete\",\n \"path\": \"/v1/posts/{id}\"\n },\n \"postsControllerViewTracking\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/viewed/{id}\"\n },\n \"postsControllerCreate\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/posts\"\n },\n \"postsControllerReportAbuse\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/posts/{id}/report\"\n },\n \"postsControllerGetUserPost\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/user-posts/{id}\"\n },\n \"postsControllerToggleLike\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/posts/{id}/toggle-like\"\n },\n \"postsControllerToggleSave\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/posts/{id}/toggle-save\"\n },\n \"postsControllerGetComments\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/{id}/comments\"\n },\n \"postsControllerGetAllComment\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/{id}/all-comments\"\n },\n \"postsControllerExportMultiplePosts\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/posts/export/pdf\"\n },\n \"postsControllerGetMyPostsCountWithinRange\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/count-within-range\"\n },\n \"postsControllerGetMyPostsByVerse\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/posts/by-verse/{verseKey}\"\n },\n \"tagsControllerFind\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/tags\"\n },\n \"commentsControllerCreate\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/comments\"\n },\n \"commentsControllerDeleteComment\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/comments/{id}/delete\"\n },\n \"commentsControllerToggleLike\": {\n \"auth\": \"user\",\n \"method\": \"post\",\n \"path\": \"/v1/comments/{id}/toggle-like\"\n },\n \"commentsControllerGet\": {\n \"auth\": \"user\",\n \"method\": \"get\",\n \"path\": \"/v1/comments/{id}/replies\"\n }\n },\n \"service\": \"quranReflect\",\n \"version\": \"v1\"\n }\n }\n}\n","import type {\n CatalogOperationDefinition as BaseCatalogOperationDefinition,\n OperationDefinition as BaseOperationDefinition,\n ServiceOperationCatalog as BaseServiceOperationCatalog,\n HttpMethod,\n OperationAuthMode,\n} from \"./contracts\";\nimport publicOperationCatalogJson from \"./specs/public-operation-catalog.json\";\n\nexport type AuthService = \"auth\" | \"quranReflect\";\n\nexport type PublicApiService = AuthService | \"oauth2\";\n\nexport interface OperationDefinition\n extends Omit<BaseOperationDefinition, \"service\"> {\n service: PublicApiService;\n}\n\nexport interface CatalogOperationDefinition\n extends Omit<BaseCatalogOperationDefinition, \"service\"> {\n service?: PublicApiService;\n}\n\nexport interface ServiceOperationCatalog\n extends Omit<BaseServiceOperationCatalog, \"operations\" | \"service\"> {\n operations: Record<string, CatalogOperationDefinition>;\n service: PublicApiService;\n}\n\ninterface PublicOperationCatalog {\n auth: { v1: ServiceOperationCatalog };\n oauth2: { v1: ServiceOperationCatalog };\n quranReflect: { v1: ServiceOperationCatalog };\n}\n\nexport const publicOperationCatalog =\n publicOperationCatalogJson as PublicOperationCatalog;\n\nexport type { HttpMethod, OperationAuthMode };\n","import type { OperationRequest, TokenResponse, UserSession } from \"@/types\";\n\nexport const encodeBasicAuth = (username: string, password: string): string => {\n const raw = `${username}:${password}`;\n\n if (typeof Buffer !== \"undefined\") {\n return Buffer.from(raw).toString(\"base64\");\n }\n\n if (typeof globalThis.btoa === \"function\") {\n return globalThis.btoa(raw);\n }\n\n throw new Error(\"No base64 encoder available for HTTP basic auth.\");\n};\n\nexport const prepareBody = (\n request: OperationRequest,\n headers: Headers,\n): string | URLSearchParams | undefined => {\n if (request.body === undefined || request.body === null) {\n return undefined;\n }\n\n if (\n typeof request.body === \"string\" ||\n request.body instanceof URLSearchParams\n ) {\n if (request.contentType) {\n headers.set(\"Content-Type\", request.contentType);\n }\n\n return request.body;\n }\n\n headers.set(\"Content-Type\", request.contentType ?? \"application/json\");\n return JSON.stringify(request.body);\n};\n\nexport const toUserSession = (\n token: TokenResponse & {\n accessToken?: string;\n expiresIn?: number;\n idToken?: string;\n refreshToken?: string;\n tokenType?: string;\n },\n currentSession?: Partial<UserSession> | null,\n): UserSession => {\n const expiresIn = token.expiresIn ?? token.expires_in;\n const accessToken = token.accessToken ?? token.access_token;\n const idToken = token.idToken ?? token.id_token ?? currentSession?.idToken;\n const refreshToken =\n token.refreshToken ?? token.refresh_token ?? currentSession?.refreshToken;\n const tokenType =\n token.tokenType ?? token.token_type ?? currentSession?.tokenType;\n const scope = token.scope ?? currentSession?.scope;\n const expiresAt = expiresIn\n ? Date.now() + expiresIn * 1000\n : currentSession?.expiresAt;\n\n return {\n accessToken,\n expiresAt,\n idToken,\n refreshToken,\n scope,\n tokenType,\n };\n};\n","import type { ApiService } from \"@/types\";\n\nimport operationCatalogJson from \"./specs/operation-catalog.json\";\n\nexport type HttpMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\nexport type OperationAuthMode = \"none\" | \"app\" | \"user\";\n\nexport interface OperationDefinition {\n auth: OperationAuthMode;\n method: HttpMethod;\n operationId?: string;\n operationName: string;\n path: string;\n serverUrl?: string;\n service: ApiService;\n tags: string[];\n version: string;\n}\n\nexport type CatalogOperationDefinition = Omit<\n OperationDefinition,\n \"operationName\" | \"service\" | \"tags\" | \"version\"\n> &\n Partial<\n Pick<OperationDefinition, \"operationName\" | \"service\" | \"tags\" | \"version\">\n >;\n\nexport interface ServiceOperationCatalog {\n operations: Record<string, CatalogOperationDefinition>;\n service: ApiService;\n version: string;\n}\n\ninterface OperationCatalog {\n auth: { v1: ServiceOperationCatalog };\n content: { v4: ServiceOperationCatalog };\n oauth2: { v1: ServiceOperationCatalog };\n quranReflect: { v1: ServiceOperationCatalog };\n search: { v1: ServiceOperationCatalog };\n}\n\nexport const operationCatalog = operationCatalogJson as OperationCatalog;\n\nexport const resolveCatalogOperation = (\n section: ServiceOperationCatalog,\n operationName: string,\n operation: CatalogOperationDefinition,\n): OperationDefinition => {\n return {\n ...operation,\n operationName: operation.operationName ?? operationName,\n service: operation.service ?? section.service,\n tags: operation.tags ?? [],\n version: operation.version ?? section.version,\n };\n};\n\nexport const getOperationByName = (\n service: ApiService,\n version: string,\n operationName: string,\n): OperationDefinition | undefined => {\n const serviceCatalog = operationCatalog[service] as\n | Record<string, ServiceOperationCatalog | undefined>\n | undefined;\n if (!serviceCatalog) {\n return undefined;\n }\n\n const versionCatalog = serviceCatalog[version];\n const operation = versionCatalog?.operations[operationName];\n if (!versionCatalog || !operation) {\n return undefined;\n }\n\n return resolveCatalogOperation(versionCatalog, operationName, operation);\n};\n","import type {\n HttpMethod,\n OperationDefinition,\n ServiceOperationCatalog,\n} from \"@/generated/contracts\";\nimport { resolveCatalogOperation } from \"@/generated/contracts\";\n\nexport const HTTP_METHOD_TO_MUTATION_NAME: Record<HttpMethod, string> = {\n delete: \"remove\",\n get: \"list\",\n patch: \"update\",\n post: \"create\",\n put: \"update\",\n};\n\nexport const toCamelCase = (value: string): string => {\n const parts = value\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/[^A-Za-z0-9]+/g, \" \")\n .trim()\n .split(/\\s+/)\n .filter(Boolean);\n\n if (parts.length === 0) {\n return \"misc\";\n }\n\n return parts\n .map((part, index) => {\n const lower = part.toLowerCase();\n if (index === 0) {\n return lower;\n }\n\n return lower.charAt(0).toUpperCase() + lower.slice(1);\n })\n .join(\"\");\n};\n\nexport const toPascalCase = (value: string): string => {\n const camel = toCamelCase(value);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n};\n\nexport const isPathParam = (segment: string): boolean =>\n segment.startsWith(\"{\") && segment.endsWith(\"}\");\n\nexport const getResourceSegments = (path: string): string[] => {\n const segments = path.split(\"/\").filter(Boolean);\n if (segments[0]?.match(/^v\\d+$/)) {\n return segments.slice(1);\n }\n\n return segments;\n};\n\nexport const pickGeneratedMethodName = (\n operation: OperationDefinition,\n): string => {\n const resourceSegments = getResourceSegments(operation.path);\n const lastSegment = resourceSegments.at(-1);\n const literalSegments = resourceSegments.filter(\n (segment) => !isPathParam(segment),\n );\n const lastLiteral = literalSegments.at(-1);\n const groupLiteral = literalSegments[0];\n\n if (resourceSegments.length === 1) {\n return HTTP_METHOD_TO_MUTATION_NAME[operation.method];\n }\n\n if (\n resourceSegments.length === 2 &&\n lastSegment &&\n isPathParam(lastSegment)\n ) {\n if (operation.method === \"get\") {\n return \"get\";\n }\n\n if (operation.method === \"delete\") {\n return \"remove\";\n }\n\n return \"update\";\n }\n\n if (lastSegment && !isPathParam(lastSegment) && lastLiteral) {\n if (lastLiteral === groupLiteral) {\n return `${HTTP_METHOD_TO_MUTATION_NAME[operation.method]}ById`;\n }\n\n return toCamelCase(lastLiteral);\n }\n\n return toCamelCase(operation.operationName);\n};\n\nexport type RawOperation = (request?: unknown) => Promise<unknown>;\nexport type GeneratedGroup = Record<string, RawOperation>;\nexport type GeneratedGroups = Record<string, GeneratedGroup>;\n\nexport interface FetcherLike {\n request<T = unknown>(\n service: string,\n path: string,\n query?: unknown,\n request?: unknown,\n ): Promise<T>;\n requestOperation<T = unknown>(\n operation: OperationDefinition,\n request?: unknown,\n ): Promise<T>;\n getUserSession(): Promise<unknown>;\n setUserSession(session: unknown): Promise<void>;\n buildServiceUrl(service: string, path: string, query?: unknown): string;\n}\n\nexport const createRawClient = (\n fetcher: FetcherLike,\n section: ServiceOperationCatalog,\n): Record<string, RawOperation> => {\n const rawOperations: Record<string, RawOperation> = {};\n\n for (const [operationName, operation] of Object.entries(section.operations)) {\n const resolvedOperation = resolveCatalogOperation(\n section,\n operationName,\n operation,\n );\n\n rawOperations[operationName] = (request?: unknown) =>\n fetcher.requestOperation(resolvedOperation, request);\n }\n\n return rawOperations;\n};\n\nexport const createGeneratedGroups = (\n section: ServiceOperationCatalog,\n rawOperations: Record<string, RawOperation>,\n): GeneratedGroups => {\n const groups: GeneratedGroups = {};\n\n for (const [operationName, operation] of Object.entries(section.operations)) {\n const resolvedOperation = resolveCatalogOperation(\n section,\n operationName,\n operation,\n );\n const literals = getResourceSegments(resolvedOperation.path).filter(\n (segment) => !isPathParam(segment),\n );\n const groupName = toCamelCase(literals[0] ?? \"misc\");\n const suggestedName = pickGeneratedMethodName(resolvedOperation);\n const currentGroup = groups[groupName] ?? {};\n let methodName = suggestedName;\n\n if (currentGroup[methodName]) {\n methodName = `${suggestedName}${toPascalCase(operationName)}`;\n }\n\n currentGroup[methodName] = rawOperations[operationName]!;\n groups[groupName] = currentGroup;\n }\n\n return groups;\n};\n","import type { ApiParams } from \"@/types\";\nimport humps from \"humps\";\n\nconst { decamelize } = humps;\n\nexport const ensureLeadingSlash = (value: string): string =>\n value.startsWith(\"/\") ? value : `/${value}`;\n\nexport const removeTrailingSlash = (value: string): string =>\n value.endsWith(\"/\") ? value.slice(0, -1) : value;\n\nexport const removeBeginningSlash = (url: string) => {\n return url.startsWith(\"/\") ? url.slice(1) : url;\n};\n\nexport const replacePathParams = (\n path: string,\n params?: Record<string, string | number>,\n): string => {\n return path.replace(/\\{([^}]+)\\}/g, (_match: string, rawKey: string) => {\n const value = params?.[rawKey];\n if (value === undefined) {\n throw new Error(`Missing path parameter: ${rawKey}`);\n }\n\n return encodeURIComponent(String(value));\n });\n};\n\nexport const normalizePathTemplate = (path: string): string =>\n path.replace(/(^|\\/):([A-Za-z0-9_]+)/g, \"$1{$2}\");\n\nconst fieldsKey = [\"wordFields\", \"translationFields\", \"fields\"] as const;\nconst fieldsKeySet = new Set<string>([\n ...fieldsKey,\n ...fieldsKey.map((key) => decamelize(key)),\n]);\nconst preservedKeys = new Set([\n \"navigationalResultsNumber\",\n \"versesResultsNumber\",\n]);\n\nexport const paramsToString = (params?: ApiParams): string => {\n if (!params) return \"\";\n\n const paramsString = new URLSearchParams();\n\n for (const [rawKey, rawValue] of Object.entries(params)) {\n if (rawValue === undefined) continue;\n\n const key = preservedKeys.has(rawKey) ? rawKey : decamelize(rawKey);\n\n // fields is a special case, it's an object with boolean values\n if (fieldsKeySet.has(rawKey) || fieldsKeySet.has(key)) {\n const fields = Object.entries(rawValue as Record<string, boolean>)\n .filter(([, value]) => value)\n .map(([fieldKey]) => decamelize(fieldKey));\n if (fields.length > 0) {\n paramsString.set(key, fields.join(\",\"));\n }\n continue;\n }\n\n if (typeof rawValue === \"string\") {\n paramsString.set(key, rawValue);\n } else if (typeof rawValue === \"number\") {\n paramsString.set(key, rawValue.toString());\n } else if (typeof rawValue === \"boolean\") {\n paramsString.set(key, rawValue.toString());\n } else if (Array.isArray(rawValue)) {\n paramsString.set(key, rawValue.join(\",\"));\n }\n }\n\n if (paramsString.size === 0) return \"\";\n return `?${paramsString.toString()}`;\n};\n","export const API_BASE_URL = \"https://apis.quran.foundation\";\n\nexport const DEFAULT_BASE_URLS = {\n auth: \"https://apis.quran.foundation/auth\",\n content: \"https://apis.quran.foundation/content\",\n oauth2: \"https://oauth2.quran.foundation\",\n quranReflect: \"https://apis.quran.foundation/quran-reflect\",\n search: \"https://apis.quran.foundation/search\",\n} as const;\n\nexport const DIRECT_PATH_PREFIX = {\n auth: \"/v1\",\n content: \"/api/v4\",\n oauth2: \"\",\n quranReflect: \"/v1\",\n search: \"/v1\",\n} as const;\n\nexport const GATEWAY_PATH_PREFIX = {\n auth: \"/auth/v1\",\n content: \"/content/api/v4\",\n oauth2: \"\",\n quranReflect: \"/quran-reflect/v1\",\n search: \"/search/v1\",\n} as const;\n\nexport const LEGACY_PREFIXES = {\n auth: [\"/auth/v1\", \"/v1\"] as const,\n content: [\"/content/api/v4\", \"/api/v4\"] as const,\n oauth2: [] as const,\n quranReflect: [\"/quran-reflect/v1\", \"/v1\"] as const,\n search: [\"/search/v1\", \"/v1\"] as const,\n} as const;\n","import type {\n OperationDefinition,\n PublicApiService,\n} from \"@/generated/public-contracts\";\nimport type {\n ApiParams,\n CustomFetcher,\n OperationRequest,\n PublicClientConfig,\n UserSession,\n} from \"@/types\";\nimport { prepareBody } from \"@/lib/http-utils\";\nimport {\n DEFAULT_BASE_URLS,\n DIRECT_PATH_PREFIX,\n GATEWAY_PATH_PREFIX,\n LEGACY_PREFIXES,\n} from \"@/lib/service-config\";\nimport {\n ensureLeadingSlash,\n normalizePathTemplate,\n paramsToString,\n removeTrailingSlash,\n replacePathParams,\n} from \"@/lib/url\";\nimport humps from \"humps\";\n\nconst { camelizeKeys } = humps;\n\nexport class PublicQuranFetcher {\n private userSession: UserSession | null | undefined;\n\n constructor(private readonly config: PublicClientConfig) {\n this.userSession = config.userSession;\n }\n\n public clearCachedTokens(): void {\n return;\n }\n\n public getFetch(): CustomFetcher {\n const doFetch = this.config.fetch ?? globalThis.fetch;\n\n if (typeof doFetch !== \"function\") {\n throw new Error(\n \"No fetch function available. Please provide a fetch implementation or ensure global fetch is available.\",\n );\n }\n\n return doFetch;\n }\n\n public async getUserSession(): Promise<UserSession | null> {\n const storedSession = await this.config.storage?.getSession?.();\n if (storedSession !== undefined) {\n return storedSession;\n }\n\n return this.userSession ?? null;\n }\n\n public async setUserSession(session: UserSession | null): Promise<void> {\n if (!this.config.storage) {\n this.userSession = session;\n return;\n }\n\n if (!session) {\n if (this.config.storage.clearSession) {\n await this.config.storage.clearSession();\n this.userSession = null;\n return;\n }\n\n await this.config.storage.setSession?.(null);\n this.userSession = null;\n return;\n }\n\n await this.config.storage.setSession?.(session);\n this.userSession = session;\n }\n\n public buildServiceUrl(\n service: PublicApiService,\n path: string,\n query?: ApiParams,\n ): string {\n const { baseUrl, usesGateway } = this.resolveServiceBaseUrl(service);\n const servicePath = this.normalizeServicePath(service, path, usesGateway);\n return `${baseUrl}${servicePath}${paramsToString(query)}`;\n }\n\n public async requestOperation<T = unknown>(\n operation: OperationDefinition,\n request?: OperationRequest,\n ): Promise<T> {\n return this.request<T>(\n operation.service,\n replacePathParams(operation.path, request?.path),\n request?.query,\n {\n ...request,\n auth:\n request?.auth === \"auto\" || !request?.auth\n ? operation.auth\n : request.auth,\n method:\n request?.method ??\n (operation.method.toUpperCase() as OperationRequest[\"method\"]),\n path: undefined,\n },\n );\n }\n\n public async request<T = unknown>(\n service: PublicApiService,\n path: string,\n query?: ApiParams,\n request: OperationRequest = {},\n ): Promise<T> {\n if (request.basicAuth) {\n throw new Error(\"client_secret is server-only. Use @quranjs/api/server.\");\n }\n\n const effectiveAuth = this.resolveAuthMode(service, request.auth);\n const url = this.buildServiceUrl(service, path, query);\n const headers = new Headers(request.headers);\n const body = prepareBody(request, headers);\n\n if (service !== \"oauth2\") {\n headers.set(\"x-client-id\", this.config.clientId);\n }\n\n await this.applyAuthenticationHeaders(\n service,\n effectiveAuth,\n headers,\n request,\n );\n\n const response = await this.getFetch()(url, {\n body,\n headers,\n method: request.method ?? \"GET\",\n });\n\n if (!response.ok) {\n throw new Error(`${response.status} ${response.statusText}`);\n }\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"application/json\")) {\n return (await response.text()) as T;\n }\n\n const json = await response.json();\n return camelizeKeys(json as object) as T;\n }\n\n private resolveAuthMode(\n service: PublicApiService,\n auth: OperationRequest[\"auth\"] = \"auto\",\n ): \"none\" | \"user\" {\n if (auth !== \"auto\") {\n if (auth === \"app\") {\n throw new Error(\n \"This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.\",\n );\n }\n\n return auth;\n }\n\n if (service === \"auth\" || service === \"quranReflect\") {\n return \"user\";\n }\n\n return \"none\";\n }\n\n private async applyAuthenticationHeaders(\n service: PublicApiService,\n auth: \"none\" | \"user\",\n headers: Headers,\n request: OperationRequest,\n ): Promise<void> {\n if (request.accessToken) {\n this.setTokenHeaders(service, headers, request.accessToken);\n return;\n }\n\n if (auth === \"none\") {\n return;\n }\n\n const session = await this.getUserSession();\n if (!session?.accessToken) {\n throw new Error(\n \"This operation requires a user session. Sign in first or use @quranjs/api/server.\",\n );\n }\n\n this.setTokenHeaders(service, headers, session.accessToken);\n }\n\n private setTokenHeaders(\n service: PublicApiService,\n headers: Headers,\n accessToken: string,\n ): void {\n if (service === \"oauth2\") {\n headers.set(\"Authorization\", `Bearer ${accessToken}`);\n return;\n }\n\n headers.set(\"x-auth-token\", accessToken);\n }\n\n private resolveServiceBaseUrl(service: PublicApiService): {\n baseUrl: string;\n usesGateway: boolean;\n } {\n const { services } = this.config;\n const directBaseUrl =\n service === \"auth\"\n ? services?.authBaseUrl\n : service === \"quranReflect\"\n ? services?.quranReflectBaseUrl\n : (services?.oauth2BaseUrl ?? services?.tokenHost);\n\n if (directBaseUrl) {\n return {\n baseUrl: removeTrailingSlash(directBaseUrl),\n usesGateway: false,\n };\n }\n\n if (services?.gatewayUrl && service !== \"oauth2\") {\n return {\n baseUrl: removeTrailingSlash(services.gatewayUrl),\n usesGateway: true,\n };\n }\n\n return {\n baseUrl: DEFAULT_BASE_URLS[service],\n usesGateway: false,\n };\n }\n\n private normalizeServicePath(\n service: PublicApiService,\n path: string,\n usesGateway: boolean,\n ): string {\n let normalizedPath = ensureLeadingSlash(normalizePathTemplate(path));\n for (const legacyPrefix of LEGACY_PREFIXES[service]) {\n if (normalizedPath.startsWith(legacyPrefix)) {\n normalizedPath = ensureLeadingSlash(\n normalizedPath.slice(legacyPrefix.length),\n );\n break;\n }\n }\n\n const prefix = usesGateway\n ? GATEWAY_PATH_PREFIX[service]\n : DIRECT_PATH_PREFIX[service];\n\n if (normalizedPath.startsWith(prefix) || prefix.length === 0) {\n return normalizedPath;\n }\n\n return `${prefix}${normalizedPath}`;\n }\n}\n","import type {\n ApiParams,\n HTTPMethod,\n OperationRequest,\n PublicClientConfig,\n TokenResponse,\n} from \"@/types\";\nimport {\n AuthService,\n publicOperationCatalog,\n} from \"@/generated/public-contracts\";\nimport { toUserSession } from \"@/lib/http-utils\";\nimport { createGeneratedGroups, createRawClient } from \"@/lib/runtime-utils\";\nimport { replacePathParams } from \"@/lib/url\";\nimport { PublicQuranFetcher } from \"@/sdk/public-fetcher\";\n\ntype RawOperation = (request?: OperationRequest) => Promise<unknown>;\ntype GeneratedGroup = Record<string, RawOperation>;\ntype QuranReflectFacade = {\n comments: GeneratedGroup;\n posts: GeneratedGroup;\n raw: Record<string, RawOperation>;\n rooms: GeneratedGroup;\n tags: GeneratedGroup;\n users: GeneratedGroup;\n};\n\nconst SERVER_ONLY_MESSAGE =\n \"This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.\";\n\nconst createUserServiceRequest =\n (fetcher: PublicQuranFetcher, service: AuthService) =>\n (method: HTTPMethod, path: string, request?: OperationRequest) => {\n return fetcher.request<unknown>(\n service,\n replacePathParams(path, request?.path),\n request?.query,\n {\n ...request,\n auth: \"user\",\n method,\n path: undefined,\n query: undefined,\n },\n );\n };\n\nconst createAuthFacade = (fetcher: PublicQuranFetcher) => {\n const raw = createRawClient(fetcher, publicOperationCatalog.auth.v1);\n const generatedGroups = createGeneratedGroups(\n publicOperationCatalog.auth.v1,\n raw,\n );\n const request = createUserServiceRequest(fetcher, \"auth\");\n\n return {\n ...generatedGroups,\n collections: {\n ...generatedGroups.collections,\n addBookmark: (collectionId: string, body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/collections/{collectionId}/bookmarks\", {\n body,\n path: { collectionId },\n }),\n create: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/collections\", { body }),\n get: (collectionId: string, query?: ApiParams) =>\n request(\"GET\", \"/v1/collections/{collectionId}\", {\n path: { collectionId },\n query,\n }),\n list: (query?: ApiParams) => request(\"GET\", \"/v1/collections\", { query }),\n listAll: (query?: ApiParams) =>\n request(\"GET\", \"/v1/collections/all\", { query }),\n remove: (collectionId: string) =>\n request(\"DELETE\", \"/v1/collections/{collectionId}\", {\n path: { collectionId },\n }),\n removeBookmark: (collectionId: string, bookmarkId: string) =>\n request(\n \"DELETE\",\n \"/v1/collections/{collectionId}/bookmarks/{bookmarkId}\",\n {\n path: { bookmarkId, collectionId },\n },\n ),\n update: (collectionId: string, body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/collections/{collectionId}\", {\n body,\n path: { collectionId },\n }),\n },\n bookmarks: {\n ...generatedGroups.bookmarks,\n create: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/bookmarks\", { body }),\n get: (bookmarkId: string) =>\n request(\"GET\", \"/v1/bookmarks/bookmark\", {\n query: { bookmarkId },\n }),\n list: (query?: ApiParams) => request(\"GET\", \"/v1/bookmarks\", { query }),\n listCollections: (query?: ApiParams) =>\n request(\"GET\", \"/v1/bookmarks/collections\", { query }),\n listRange: (query?: ApiParams) =>\n request(\"GET\", \"/v1/bookmarks/ayahs-range\", { query }),\n remove: (bookmarkId: string) =>\n request(\"DELETE\", \"/v1/bookmarks/{bookmarkId}\", {\n path: { bookmarkId },\n }),\n },\n goals: {\n ...generatedGroups.goals,\n create: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/goals\", { body }),\n estimate: (query?: ApiParams) =>\n request(\"GET\", \"/v1/goals/estimate\", { query }),\n getTodaysPlan: (query?: ApiParams) =>\n request(\"GET\", \"/v1/goals/get-todays-plan\", { query }),\n remove: (id: string) =>\n request(\"DELETE\", \"/v1/goals/{id}\", { path: { id } }),\n update: (id: string, body: Record<string, unknown>) =>\n request(\"PUT\", \"/v1/goals/{id}\", {\n body,\n path: { id },\n }),\n },\n notes: {\n ...generatedGroups.notes,\n create: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/notes\", { body }),\n get: (noteId: string) =>\n request(\"GET\", \"/v1/notes/{noteId}\", { path: { noteId } }),\n list: (query?: ApiParams) => request(\"GET\", \"/v1/notes\", { query }),\n listByAttachedEntity: (query?: ApiParams) =>\n request(\"GET\", \"/v1/notes/by-attached-entity\", { query }),\n listByRange: (query?: ApiParams) =>\n request(\"GET\", \"/v1/notes/by-range\", { query }),\n listByVerseKey: (verseKey: string, query?: ApiParams) =>\n request(\"GET\", \"/v1/notes/by-verse/{verseKey}\", {\n path: { verseKey },\n query,\n }),\n publish: (noteId: string, body?: Record<string, unknown>) =>\n request(\"POST\", \"/v1/notes/{noteId}/publish\", {\n body,\n path: { noteId },\n }),\n remove: (noteId: string) =>\n request(\"DELETE\", \"/v1/notes/{noteId}\", { path: { noteId } }),\n update: (noteId: string, body: Record<string, unknown>) =>\n request(\"PATCH\", \"/v1/notes/{noteId}\", {\n body,\n path: { noteId },\n }),\n },\n preferences: {\n ...generatedGroups.preferences,\n bulkUpdate: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/preferences/bulk\", { body }),\n get: (query?: ApiParams) => request(\"GET\", \"/v1/preferences\", { query }),\n update: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/preferences\", { body }),\n },\n raw,\n readingSessions: {\n ...generatedGroups.readingSessions,\n create: (body: Record<string, unknown>) =>\n request(\"POST\", \"/v1/reading-sessions\", { body }),\n list: (query?: ApiParams) =>\n request(\"GET\", \"/v1/reading-sessions\", { query }),\n },\n };\n};\n\nconst createQuranReflectFacade = (\n fetcher: PublicQuranFetcher,\n): QuranReflectFacade => {\n const raw = createRawClient(fetcher, publicOperationCatalog.quranReflect.v1);\n const generatedGroups = createGeneratedGroups(\n publicOperationCatalog.quranReflect.v1,\n raw,\n );\n\n return {\n comments: generatedGroups.comments ?? {},\n posts: generatedGroups.posts ?? {},\n raw,\n rooms: generatedGroups.rooms ?? {},\n tags: generatedGroups.tags ?? {},\n users: generatedGroups.users ?? {},\n };\n};\n\nconst createOAuth2Facade = (\n fetcher: PublicQuranFetcher,\n config: PublicClientConfig,\n) => {\n const raw = createRawClient(fetcher, publicOperationCatalog.oauth2.v1);\n\n const exchangeToken = async (\n body: URLSearchParams,\n options: { requiresRefreshToken?: boolean } = {},\n ) => {\n if (config.clientType !== \"public\") {\n throw new Error(\n \"This OAuth2 exchange requires a backend because your client is confidential.\",\n );\n }\n\n if (options.requiresRefreshToken && !body.get(\"refresh_token\")) {\n throw new Error(\"Missing refresh token.\");\n }\n\n body.set(\"client_id\", config.clientId);\n\n const requestRefreshToken = body.get(\"refresh_token\") ?? undefined;\n const storedSession = options.requiresRefreshToken\n ? await fetcher.getUserSession()\n : null;\n const currentSession =\n options.requiresRefreshToken && requestRefreshToken\n ? { ...(storedSession ?? {}), refreshToken: requestRefreshToken }\n : storedSession;\n\n const token = await fetcher.request<TokenResponse>(\n \"oauth2\",\n \"/oauth2/token\",\n undefined,\n {\n auth: \"none\",\n body,\n contentType: \"application/x-www-form-urlencoded\",\n method: \"POST\",\n },\n );\n\n await fetcher.setUserSession(toUserSession(token, currentSession));\n return token;\n };\n\n return {\n authorizeUrl: (query: Record<string, string | number | undefined>) =>\n fetcher.buildServiceUrl(\"oauth2\", \"/oauth2/auth\", query as ApiParams),\n exchangeCode: (params: {\n code: string;\n codeVerifier?: string;\n redirectUri: string;\n scope?: string;\n }) => {\n const body = new URLSearchParams({\n code: params.code,\n grant_type: \"authorization_code\",\n redirect_uri: params.redirectUri,\n });\n\n if (params.codeVerifier) {\n body.set(\"code_verifier\", params.codeVerifier);\n }\n\n if (params.scope) {\n body.set(\"scope\", params.scope);\n }\n\n return exchangeToken(body);\n },\n getUserInfo: (accessToken?: string) =>\n fetcher.request(\"oauth2\", \"/userinfo\", undefined, {\n accessToken,\n auth: \"user\",\n method: \"GET\",\n }),\n introspect: () => {\n throw new Error(\n \"Token introspection requires @quranjs/api/server or a backend.\",\n );\n },\n logout: (query?: ApiParams) =>\n fetcher.request(\"oauth2\", \"/oauth2/sessions/logout\", query, {\n auth: \"none\",\n method: \"GET\",\n }),\n raw,\n refresh: async (refreshToken?: string) => {\n const currentSession = await fetcher.getUserSession();\n const body = new URLSearchParams({\n grant_type: \"refresh_token\",\n refresh_token: refreshToken ?? currentSession?.refreshToken ?? \"\",\n });\n\n return exchangeToken(body, { requiresRefreshToken: true });\n },\n };\n};\n\ntype ServerOnlyGuard = ((...args: unknown[]) => Promise<never>) & {\n [key: string]: ServerOnlyGuard | undefined;\n};\n\nconst createServerOnlyGuard = (): ServerOnlyGuard => {\n const fail = (() =>\n Promise.reject(new Error(SERVER_ONLY_MESSAGE))) as ServerOnlyGuard;\n const proxy = new Proxy(fail, {\n apply() {\n return Promise.reject(new Error(SERVER_ONLY_MESSAGE));\n },\n get(_target, property) {\n if (property === \"then\") {\n return undefined;\n }\n\n return proxy;\n },\n });\n\n return proxy;\n};\n\nexport const createPublicRuntimeClient = (config: PublicClientConfig) => {\n const fetcher = new PublicQuranFetcher(config);\n fetcher.getFetch();\n\n const authV1 = createAuthFacade(fetcher);\n const quranReflectV1 = createQuranReflectFacade(fetcher);\n const oauth2V1 = createOAuth2Facade(fetcher, config);\n const serverOnlyGuard = createServerOnlyGuard();\n\n const raw = {\n auth: {\n v1: authV1.raw,\n },\n content: {\n v4: serverOnlyGuard,\n },\n oauth2: {\n v1: oauth2V1.raw,\n },\n quranReflect: {\n v1: quranReflectV1.raw,\n },\n search: {\n v1: serverOnlyGuard,\n },\n };\n\n return {\n audio: serverOnlyGuard,\n auth: {\n ...authV1,\n v1: authV1,\n },\n chapters: serverOnlyGuard,\n clearCachedTokens: () => fetcher.clearCachedTokens(),\n content: serverOnlyGuard,\n getUserSession: () => fetcher.getUserSession(),\n juzs: serverOnlyGuard,\n oauth2: {\n ...oauth2V1,\n v1: oauth2V1,\n },\n quranReflect: {\n ...quranReflectV1,\n v1: quranReflectV1,\n },\n raw,\n resources: serverOnlyGuard,\n search: serverOnlyGuard,\n verses: serverOnlyGuard,\n };\n};\n","import type { PublicClientConfig } from \"@/types\";\n\nimport { createPublicRuntimeClient } from \"./runtime/create-public-client\";\n\nexport const createPublicClient = (config: PublicClientConfig) => {\n if ((config as PublicClientConfig & { clientSecret?: string }).clientSecret) {\n throw new Error(\"client_secret is server-only. Use @quranjs/api/server.\");\n }\n\n return createPublicRuntimeClient(config);\n};\n\nexport type PublicClient = ReturnType<typeof createPublicClient>;\n"]}
@@ -0,0 +1,3 @@
1
+ import L from'humps';var T={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}}};var l=T;var b=(o,t)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&t.set("Content-Type",o.contentType),o.body):(t.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},R=(o,t)=>{let s=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,e=o.idToken??o.id_token??t?.idToken,n=o.refreshToken??o.refresh_token??t?.refreshToken,a=o.tokenType??o.token_type??t?.tokenType,u=o.scope??t?.scope,p=s?Date.now()+s*1e3:t?.expiresAt;return {accessToken:r,expiresAt:p,idToken:e,refreshToken:n,scope:u,tokenType:a}};var k=(o,t,s)=>({...s,operationName:s.operationName??t,service:s.service??o.service,tags:s.tags??[],version:s.version??o.version});var w={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},d=o=>{let t=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return t.length===0?"misc":t.map((s,r)=>{let e=s.toLowerCase();return r===0?e:e.charAt(0).toUpperCase()+e.slice(1)}).join("")},N=o=>{let t=d(o);return t.charAt(0).toUpperCase()+t.slice(1)},h=o=>o.startsWith("{")&&o.endsWith("}"),O=o=>{let t=o.split("/").filter(Boolean);return t[0]?.match(/^v\d+$/)?t.slice(1):t},F=o=>{let t=O(o.path),s=t.at(-1),r=t.filter(a=>!h(a)),e=r.at(-1),n=r[0];return t.length===1?w[o.method]:t.length===2&&s&&h(s)?o.method==="get"?"get":o.method==="delete"?"remove":"update":s&&!h(s)&&e?e===n?`${w[o.method]}ById`:d(e):d(o.operationName)},m=(o,t)=>{let s={};for(let[r,e]of Object.entries(t.operations)){let n=k(t,r,e);s[r]=a=>o.requestOperation(n,a);}return s},y=(o,t)=>{let s={};for(let[r,e]of Object.entries(o.operations)){let n=k(o,r,e),a=O(n.path).filter(f=>!h(f)),u=d(a[0]??"misc"),p=F(n),i=s[u]??{},c=p;i[c]&&(c=`${p}${N(r)}`),i[c]=t[r],s[u]=i;}return s};var{decamelize:C}=L,P=o=>o.startsWith("/")?o:`/${o}`,S=o=>o.endsWith("/")?o.slice(0,-1):o;var g=(o,t)=>o.replace(/\{([^}]+)\}/g,(s,r)=>{let e=t?.[r];if(e===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(e))}),E=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),A=["wordFields","translationFields","fields"],G=new Set([...A,...A.map(o=>C(o))]),H=new Set(["navigationalResultsNumber","versesResultsNumber"]),U=o=>{if(!o)return "";let t=new URLSearchParams;for(let[s,r]of Object.entries(o)){if(r===void 0)continue;let e=H.has(s)?s:C(s);if(G.has(s)||G.has(e)){let n=Object.entries(r).filter(([,a])=>a).map(([a])=>C(a));n.length>0&&t.set(e,n.join(","));continue}typeof r=="string"?t.set(e,r):typeof r=="number"||typeof r=="boolean"?t.set(e,r.toString()):Array.isArray(r)&&t.set(e,r.join(","));}return t.size===0?"":`?${t.toString()}`};var I={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},x={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},B={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},q={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:j}=L,v=class{constructor(t){this.config=t;this.userSession=t.userSession;}userSession;clearCachedTokens(){}getFetch(){let t=this.config.fetch??globalThis.fetch;if(typeof t!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return t}async getUserSession(){let t=await this.config.storage?.getSession?.();return t!==void 0?t:this.userSession??null}async setUserSession(t){if(!this.config.storage){this.userSession=t;return}if(!t){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(t),this.userSession=t;}buildServiceUrl(t,s,r){let{baseUrl:e,usesGateway:n}=this.resolveServiceBaseUrl(t),a=this.normalizeServicePath(t,s,n);return `${e}${a}${U(r)}`}async requestOperation(t,s){return this.request(t.service,g(t.path,s?.path),s?.query,{...s,auth:s?.auth==="auto"||!s?.auth?t.auth:s.auth,method:s?.method??t.method.toUpperCase(),path:void 0})}async request(t,s,r,e={}){if(e.basicAuth)throw new Error("client_secret is server-only. Use @quranjs/api/server.");let n=this.resolveAuthMode(t,e.auth),a=this.buildServiceUrl(t,s,r),u=new Headers(e.headers),p=b(e,u);t!=="oauth2"&&u.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(t,n,u,e);let i=await this.getFetch()(a,{body:p,headers:u,method:e.method??"GET"});if(!i.ok)throw new Error(`${i.status} ${i.statusText}`);if(i.status===204)return;if(!(i.headers.get("content-type")??"").includes("application/json"))return await i.text();let f=await i.json();return j(f)}resolveAuthMode(t,s="auto"){if(s!=="auto"){if(s==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");return s}return t==="auth"||t==="quranReflect"?"user":"none"}async applyAuthenticationHeaders(t,s,r,e){if(e.accessToken){this.setTokenHeaders(t,r,e.accessToken);return}if(s==="none")return;let n=await this.getUserSession();if(!n?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(t,r,n.accessToken);}setTokenHeaders(t,s,r){if(t==="oauth2"){s.set("Authorization",`Bearer ${r}`);return}s.set("x-auth-token",r);}resolveServiceBaseUrl(t){let{services:s}=this.config,r=t==="auth"?s?.authBaseUrl:t==="quranReflect"?s?.quranReflectBaseUrl:s?.oauth2BaseUrl??s?.tokenHost;return r?{baseUrl:S(r),usesGateway:false}:s?.gatewayUrl&&t!=="oauth2"?{baseUrl:S(s.gatewayUrl),usesGateway:true}:{baseUrl:I[t],usesGateway:false}}normalizeServicePath(t,s,r){let e=P(E(s));for(let a of q[t])if(e.startsWith(a)){e=P(e.slice(a.length));break}let n=r?B[t]:x[t];return e.startsWith(n)||n.length===0?e:`${n}${e}`}};var V="This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.",$=(o,t)=>(s,r,e)=>o.request(t,g(r,e?.path),e?.query,{...e,auth:"user",method:s,path:void 0,query:void 0}),z=o=>{let t=m(o,l.auth.v1),s=y(l.auth.v1,t),r=$(o,"auth");return {...s,collections:{...s.collections,addBookmark:(e,n)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:e}}),create:e=>r("POST","/v1/collections",{body:e}),get:(e,n)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:e},query:n}),list:e=>r("GET","/v1/collections",{query:e}),listAll:e=>r("GET","/v1/collections/all",{query:e}),remove:e=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:e}}),removeBookmark:(e,n)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:e}}),update:(e,n)=>r("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:e}})},bookmarks:{...s.bookmarks,create:e=>r("POST","/v1/bookmarks",{body:e}),get:e=>r("GET","/v1/bookmarks/bookmark",{query:{bookmarkId:e}}),list:e=>r("GET","/v1/bookmarks",{query:e}),listCollections:e=>r("GET","/v1/bookmarks/collections",{query:e}),listRange:e=>r("GET","/v1/bookmarks/ayahs-range",{query:e}),remove:e=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:e}})},goals:{...s.goals,create:e=>r("POST","/v1/goals",{body:e}),estimate:e=>r("GET","/v1/goals/estimate",{query:e}),getTodaysPlan:e=>r("GET","/v1/goals/get-todays-plan",{query:e}),remove:e=>r("DELETE","/v1/goals/{id}",{path:{id:e}}),update:(e,n)=>r("PUT","/v1/goals/{id}",{body:n,path:{id:e}})},notes:{...s.notes,create:e=>r("POST","/v1/notes",{body:e}),get:e=>r("GET","/v1/notes/{noteId}",{path:{noteId:e}}),list:e=>r("GET","/v1/notes",{query:e}),listByAttachedEntity:e=>r("GET","/v1/notes/by-attached-entity",{query:e}),listByRange:e=>r("GET","/v1/notes/by-range",{query:e}),listByVerseKey:(e,n)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:e},query:n}),publish:(e,n)=>r("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:e}}),remove:e=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:e}}),update:(e,n)=>r("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:e}})},preferences:{...s.preferences,bulkUpdate:e=>r("POST","/v1/preferences/bulk",{body:e}),get:e=>r("GET","/v1/preferences",{query:e}),update:e=>r("POST","/v1/preferences",{body:e})},raw:t,readingSessions:{...s.readingSessions,create:e=>r("POST","/v1/reading-sessions",{body:e}),list:e=>r("GET","/v1/reading-sessions",{query:e})}}},W=o=>{let t=m(o,l.quranReflect.v1),s=y(l.quranReflect.v1,t);return {comments:s.comments??{},posts:s.posts??{},raw:t,rooms:s.rooms??{},tags:s.tags??{},users:s.users??{}}},K=(o,t)=>{let s=m(o,l.oauth2.v1),r=async(e,n={})=>{if(t.clientType!=="public")throw new Error("This OAuth2 exchange requires a backend because your client is confidential.");if(n.requiresRefreshToken&&!e.get("refresh_token"))throw new Error("Missing refresh token.");e.set("client_id",t.clientId);let a=e.get("refresh_token")??void 0,u=n.requiresRefreshToken?await o.getUserSession():null,p=n.requiresRefreshToken&&a?{...u??{},refreshToken:a}:u,i=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",body:e,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(R(i,p)),i};return {authorizeUrl:e=>o.buildServiceUrl("oauth2","/oauth2/auth",e),exchangeCode:e=>{let n=new URLSearchParams({code:e.code,grant_type:"authorization_code",redirect_uri:e.redirectUri});return e.codeVerifier&&n.set("code_verifier",e.codeVerifier),e.scope&&n.set("scope",e.scope),r(n)},getUserInfo:e=>o.request("oauth2","/userinfo",void 0,{accessToken:e,auth:"user",method:"GET"}),introspect:()=>{throw new Error("Token introspection requires @quranjs/api/server or a backend.")},logout:e=>o.request("oauth2","/oauth2/sessions/logout",e,{auth:"none",method:"GET"}),raw:s,refresh:async e=>{let n=await o.getUserSession(),a=new URLSearchParams({grant_type:"refresh_token",refresh_token:e??n?.refreshToken??""});return r(a,{requiresRefreshToken:true})}}},Q=()=>{let o=()=>Promise.reject(new Error(V)),t=new Proxy(o,{apply(){return Promise.reject(new Error(V))},get(s,r){if(r!=="then")return t}});return t},_=o=>{let t=new v(o);t.getFetch();let s=z(t),r=W(t),e=K(t,o),n=Q(),a={auth:{v1:s.raw},content:{v4:n},oauth2:{v1:e.raw},quranReflect:{v1:r.raw},search:{v1:n}};return {audio:n,auth:{...s,v1:s},chapters:n,clearCachedTokens:()=>t.clearCachedTokens(),content:n,getUserSession:()=>t.getUserSession(),juzs:n,oauth2:{...e,v1:e},quranReflect:{...r,v1:r},raw:a,resources:n,search:n,verses:n}};var ye=o=>{if(o.clientSecret)throw new Error("client_secret is server-only. Use @quranjs/api/server.");return _(o)};
2
+ export{ye as createPublicClient};//# sourceMappingURL=public.min.mjs.map
3
+ //# sourceMappingURL=public.min.mjs.map